@aiquants/markdown-explorer 0.10.0 → 0.11.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 (38) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +2 -1
  3. package/dist/{EditSurface-1Jf0CG-f.js → EditSurface-BK_Pz_LF.js} +1 -1
  4. package/dist/{EditSurface-B-l3Do_C.cjs → EditSurface-CfbYYXrc.cjs} +1 -1
  5. package/dist/ExplorerSplit-51frK8xf.cjs +1 -0
  6. package/dist/{ExplorerSplit-D0zf7Cr_.js → ExplorerSplit-DwlWWfRv.js} +216 -213
  7. package/dist/{MultiLayout-Bq10p3a3.cjs → MultiLayout-B4PtS45V.cjs} +1 -1
  8. package/dist/{MultiLayout-Jy9BKofx.js → MultiLayout-CeR_l6Rb.js} +4 -4
  9. package/dist/{NativeScrollBar-CyiyL47o.js → NativeScrollBar-CVWeTlHC.js} +1 -1
  10. package/dist/{NativeScrollBar-Dt6xH5Mb.cjs → NativeScrollBar-Dp4YWBp7.cjs} +1 -1
  11. package/dist/{TreeLayout-kVWFEKJD.cjs → TreeLayout-D-NyhuVM.cjs} +1 -1
  12. package/dist/{TreeLayout-8pRo1ANN.js → TreeLayout-min5AOhr.js} +3 -3
  13. package/dist/core/contracts.d.cts +1 -0
  14. package/dist/core/contracts.d.ts +1 -0
  15. package/dist/core/labels.d.cts +2 -0
  16. package/dist/core/labels.d.ts +2 -0
  17. package/dist/core/treeSettings.d.cts +2 -1
  18. package/dist/core/treeSettings.d.ts +2 -1
  19. package/dist/dataRoute-CIFFX5bd.cjs +1 -0
  20. package/dist/{dataRoute-Csl1WBDz.js → dataRoute-CU9CKP44.js} +54 -54
  21. package/dist/{index-CfcJEnrC.js → index-BPj19kIo.js} +10 -6
  22. package/dist/{index-sNJrKoGN.cjs → index-DJ_FUtYM.cjs} +4 -4
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +3 -3
  25. package/dist/{location-Dc1qNEGm.js → location-BT23fKeh.js} +123 -112
  26. package/dist/location-LNl0QOXI.cjs +1 -0
  27. package/dist/{merge-D0aGvFKC.cjs → merge-AnqxGn__.cjs} +1 -1
  28. package/dist/{merge-SRCxtHk2.js → merge-hyUGPGbJ.js} +1 -1
  29. package/dist/sanitizeWorker.cjs +1 -1
  30. package/dist/sanitizeWorker.js +1 -1
  31. package/dist/server.cjs +1 -1
  32. package/dist/server.js +548 -540
  33. package/docs/behavior/dom-hooks.md +1 -1
  34. package/docs/behavior/localization.md +1 -0
  35. package/package.json +1 -1
  36. package/dist/ExplorerSplit-WX8afxrQ.cjs +0 -1
  37. package/dist/dataRoute-8pyILcjL.cjs +0 -1
  38. package/dist/location-CRYkEWiC.cjs +0 -1
@@ -1,4 +1,4 @@
1
- "use strict";const l=require("react/jsx-runtime"),i=require("react"),Y=require("react-router"),I=require("./location-CRYkEWiC.cjs"),N=require("./dataRoute-8pyILcjL.cjs"),de=require("@aiquants/markdown"),$e=require("@aiquants/markdown/source-lines"),yn=require("@aiquants/markdown/viewer-settings"),J=require("./storage-Dgi4JXaB.cjs");function Sn(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 E=Sn(i),qe=Object.freeze(["en","ja"]),Ct="en",Ot=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"])}),kn=/\{(\w+)\}/gu,At={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}`,showMarkupLabel:"Source",showMarkup:"Show the document's Markdown as written",showMarkupNamed:e=>`Source of ${e}`,editDocumentLabel:"Edit",editDocument:"Edit the document's Markdown (or double-click the document)",editDocumentNamed:e=>`Edit ${e}`,editExternallyLabel:"Open in its editor",editExternally:"Open the document in its own editor, in a new tab",editExternallyNamed:e=>`Open ${e} in its editor`,editorRegion:e=>`Editing ${e}`,editorLabel:e=>`Markdown of ${e}`,editLoading:"Loading the source for editing…",editToolbar:"Editor",saveDraft:"Save",saveDraftTooltip:"Save the draft (Ctrl+S, or ⌘S on a Mac)",closeEditor:"Close editor",previewToggle:"Preview",historyOpen:"History",draftUnsaved:"Unsaved changes",draftSaving:"Saving…",draftSaved:"Saved",draftSavedMerged:"Saved, merged with changes saved elsewhere",draftConflicts:e=>e===1?"1 conflict with changes saved elsewhere: choose what to keep, then save":`${e} conflicts with changes saved elsewhere: choose what to keep, then save`,draftSaveFailed:e=>`Could not save: ${e}`,documentSaved:e=>`Saved ${e}`,documentSavedMerged:e=>`Saved ${e}, merged with changes saved elsewhere`,conflictOurs:"your draft",conflictTheirs:"saved elsewhere",conflictUseOurs:"Use my lines",conflictUseTheirs:"Use the saved lines",conflictKeepBoth:"Keep both",conflictNext:"Next conflict",editGrantTitle:"Editing needs your permission",editGrantBody:"Allow this site to change documents on your behalf. You are asked once; signing out asks again.",editGrantAction:"Grant permission",editGrantRetry:"Try again",unsavedTitle:"Discard unsaved changes?",unsavedBody:e=>`${e} has changes that are not saved.`,unsavedDiscard:"Discard changes",unsavedStay:"Keep editing",historyTitle:e=>`Revisions of ${e}`,historyLoading:"Loading the revisions…",historyEmpty:"No revisions are kept for this document.",historyCurrent:"Current",historyKept:"Kept",historyEntry:(e,t)=>t===""?e:`${e} by ${t}`,historyRestore:"Put into the draft",historyClose:"Close",historyRestored:e=>`Put the revision into the draft of ${e}; save to keep it`,previewRegion:"Preview",previewUpdating:"Updating the preview…",previewFailed:e=>`Could not preview: ${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…",markupLoading:"Loading the source…",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",copyText:"Copy the text",copiedText:"Copied the text",copyTextFailed:"Could not copy the text",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"},Rn={explorerRegion:"エクスプローラー",sourceLabel:"ソース",refreshTreeLabel:"ツリーを更新",refreshTree:"ソースからツリーと開いている文書を読み込み直す",treeRefreshed:"ツリーをソースから読み込み直しました",treeRefreshFailed:e=>`ツリーを読み込み直せませんでした: ${e}`,refreshDocumentLabel:"文書を更新",refreshDocument:"ソースから文書を読み込み直す",refreshDocumentNamed:e=>`${e} を更新`,documentRefreshed:e=>`${e} を読み込み直しました`,documentRefreshFailed:e=>`文書を読み込み直せませんでした: ${e}`,showMarkupLabel:"ソース",showMarkup:"文書の Markdown を書いたまま表示",showMarkupNamed:e=>`${e} のソース`,editDocumentLabel:"編集",editDocument:"文書の Markdown を編集 (文書のダブルクリックでも)",editDocumentNamed:e=>`${e} を編集`,editExternallyLabel:"元のエディタで開く",editExternally:"文書を元のエディタで、新しいタブに開く",editExternallyNamed:e=>`${e} を元のエディタで開く`,editorRegion:e=>`${e} を編集中`,editorLabel:e=>`${e} の Markdown`,editLoading:"編集のためにソースを読み込み中…",editToolbar:"エディタ",saveDraft:"保存",saveDraftTooltip:"下書きを保存 (Ctrl+S、Mac は ⌘S)",closeEditor:"編集を閉じる",previewToggle:"プレビュー",historyOpen:"履歴",draftUnsaved:"保存していない変更があります",draftSaving:"保存中…",draftSaved:"保存しました",draftSavedMerged:"ほかで保存された変更と統合して保存しました",draftConflicts:e=>`ほかで保存された変更と ${e} か所が重なりました。残す方を選んでから保存してください`,draftSaveFailed:e=>`保存できませんでした: ${e}`,documentSaved:e=>`${e} を保存しました`,documentSavedMerged:e=>`${e} を、ほかで保存された変更と統合して保存しました`,conflictOurs:"あなたの下書き",conflictTheirs:"ほかで保存された版",conflictUseOurs:"自分の行を使う",conflictUseTheirs:"保存された行を使う",conflictKeepBoth:"両方を残す",conflictNext:"次の衝突へ",editGrantTitle:"編集には許可が必要です",editGrantBody:"このサイトがあなたに代わって文書を変えることを許可してください。尋ねるのは 1 回だけで、サインアウトすると次にまた尋ねます。",editGrantAction:"許可する",editGrantRetry:"もう一度試す",unsavedTitle:"保存していない変更を破棄しますか?",unsavedBody:e=>`${e} に保存していない変更があります。`,unsavedDiscard:"変更を破棄",unsavedStay:"編集を続ける",historyTitle:e=>`${e} の版`,historyLoading:"版の一覧を読み込み中…",historyEmpty:"この文書の版は残っていません。",historyCurrent:"現在の版",historyKept:"保持",historyEntry:(e,t)=>t===""?e:`${e} (${t})`,historyRestore:"下書きに戻す",historyClose:"閉じる",historyRestored:e=>`${e} の下書きに版を戻しました。残すには保存してください`,previewRegion:"プレビュー",previewUpdating:"プレビューを更新中…",previewFailed: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:"文書を読み込み中…",markupLoading:"ソースを読み込み中…",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:"ダウンロード",copyText:"テキストをコピー",copiedText:"テキストをコピーしました",copyTextFailed:"テキストをコピーできませんでした",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:"ここへパネルをドロップ"},Lt=Object.freeze({en:Object.freeze(At),ja:Object.freeze(Rn)}),Ze=Object.freeze(Object.keys(At)),Tn=new Set(Ze),Cn=e=>Tn.has(e),we=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,jt=e=>{if(e===void 0)return Ct;if(qe.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${qe.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${we(e)}`)},Ie=(e,t)=>{const n=Lt[jt(e)];if(t===void 0)return n;if(t===null||typeof t!="object")throw new RangeError(`[markdown-explorer] labels must be an object; got ${we(t)}`);if(!I.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${we(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!Cn(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${Ze.join(", ")}`);const a=r[s];if(a===void 0)continue;const u=typeof n[s];if(typeof a!==u)throw new TypeError(`[markdown-explorer] labels.${s} must be a ${u}; got ${we(a)}`);if(typeof a=="string"&&a.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const g=Ot[s];if(typeof a=="string"&&g!==void 0){for(const[,m]of a.matchAll(kn))if(!g.includes(m??""))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${String(m)}}; it accepts ${g.map(f=>`{${f}}`).join(", ")}`)}o[s]=a}return Object.freeze(o)},On=(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]))},Be=Object.freeze(["light","dark"]),An=e=>{if(e===void 0)return"light";if(Be.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${Be.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},Mt=i.createContext(null),P=()=>{const e=i.use(Mt);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},ue=e=>{const{viewSettings:t}=P(),n=()=>e(t.getSnapshot());return i.useSyncExternalStore(t.subscribe,n,n)},Se=()=>{const{config:e}=P(),t=Y.useParams()["*"],[n]=Y.useSearchParams(),r=n.toString();return i.useMemo(()=>I.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])},Nt={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[Nt[t][0]],le=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=P(),s=te(o,e.reason),a=o[Nt[e.reason][1]],u=e.reason==="unauthorized"||e.reason==="forbidden"||e.reason==="failed"?"danger":"warning";return l.jsxs("div",{className:"aqmx-callout",role:t?"alert":void 0,"data-aqmx-tone":u,"data-testid":r===null?void 0:r,"data-aqmx-failure":r===null?void 0:e.reason,children:[l.jsx("p",{className:"aqmx-callout-title",children:s}),l.jsx("p",{className:"aqmx-callout-body",children:a}),e.reason==="unauthorized"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:()=>window.location.reload(),children:o.reloadPage}):n!==void 0&&e.reason==="failed"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:n,children:o.retry}):null]})},Ln=(e,t)=>{const{phase:n,save:r,dirty:o}=t;switch(n.kind){case"opening":return e.editLoading;case"grant":return e.editGrantTitle;case"failed":return te(e,n.failure.reason)}switch(r.kind){case"saving":return e.draftSaving;case"conflicts":return e.draftConflicts(r.count);case"grant":return e.editGrantTitle;case"failed":return e.draftSaveFailed(te(e,r.failure.reason));case"saved":if(!o)return r.merged?e.draftSavedMerged:e.draftSaved;break}return o?e.draftUnsaved:""},jn=(e,t,n)=>{switch(t.kind){case"saved":return t.merged?e.documentSavedMerged(n):e.documentSaved(n);case"conflicts":return e.draftConflicts(t.count);case"grant":return e.editGrantTitle;case"failed":return e.draftSaveFailed(te(e,t.failure.reason));case"idle":case"saving":return null}},ae=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},Dt="<<<<<<<",Pt="=======",_t=">>>>>>>",rt=(e,t)=>e===t||e.startsWith(`${t} `),ot=e=>Ft(e.split(`
1
+ "use strict";const l=require("react/jsx-runtime"),i=require("react"),Y=require("react-router"),I=require("./location-LNl0QOXI.cjs"),N=require("./dataRoute-CIFFX5bd.cjs"),de=require("@aiquants/markdown"),$e=require("@aiquants/markdown/source-lines"),yn=require("@aiquants/markdown/viewer-settings"),J=require("./storage-Dgi4JXaB.cjs");function Sn(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 E=Sn(i),qe=Object.freeze(["en","ja"]),Ct="en",Ot=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"])}),kn=/\{(\w+)\}/gu,At={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}`,showMarkupLabel:"Source",showMarkup:"Show the document's Markdown as written",showMarkupNamed:e=>`Source of ${e}`,editDocumentLabel:"Edit",editDocument:"Edit the document's Markdown (or double-click the document)",editDocumentNamed:e=>`Edit ${e}`,editExternallyLabel:"Open in its editor",editExternally:"Open the document in its own editor, in a new tab",editExternallyNamed:e=>`Open ${e} in its editor`,editorRegion:e=>`Editing ${e}`,editorLabel:e=>`Markdown of ${e}`,editLoading:"Loading the source for editing…",editToolbar:"Editor",saveDraft:"Save",saveDraftTooltip:"Save the draft (Ctrl+S, or ⌘S on a Mac)",closeEditor:"Close editor",previewToggle:"Preview",historyOpen:"History",draftUnsaved:"Unsaved changes",draftSaving:"Saving…",draftSaved:"Saved",draftSavedMerged:"Saved, merged with changes saved elsewhere",draftConflicts:e=>e===1?"1 conflict with changes saved elsewhere: choose what to keep, then save":`${e} conflicts with changes saved elsewhere: choose what to keep, then save`,draftSaveFailed:e=>`Could not save: ${e}`,documentSaved:e=>`Saved ${e}`,documentSavedMerged:e=>`Saved ${e}, merged with changes saved elsewhere`,conflictOurs:"your draft",conflictTheirs:"saved elsewhere",conflictUseOurs:"Use my lines",conflictUseTheirs:"Use the saved lines",conflictKeepBoth:"Keep both",conflictNext:"Next conflict",editGrantTitle:"Editing needs your permission",editGrantBody:"Allow this site to change documents on your behalf. You are asked once; signing out asks again.",editGrantAction:"Grant permission",editGrantRetry:"Try again",unsavedTitle:"Discard unsaved changes?",unsavedBody:e=>`${e} has changes that are not saved.`,unsavedDiscard:"Discard changes",unsavedStay:"Keep editing",historyTitle:e=>`Revisions of ${e}`,historyLoading:"Loading the revisions…",historyEmpty:"No revisions are kept for this document.",historyCurrent:"Current",historyKept:"Kept",historyEntry:(e,t)=>t===""?e:`${e} by ${t}`,historyRestore:"Put into the draft",historyClose:"Close",historyRestored:e=>`Put the revision into the draft of ${e}; save to keep it`,previewRegion:"Preview",previewUpdating:"Updating the preview…",previewFailed:e=>`Could not preview: ${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",sortOldest:"Modified old→new",sortNewest:"Modified new→old",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…",markupLoading:"Loading the source…",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",copyText:"Copy the text",copiedText:"Copied the text",copyTextFailed:"Could not copy the text",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"},Rn={explorerRegion:"エクスプローラー",sourceLabel:"ソース",refreshTreeLabel:"ツリーを更新",refreshTree:"ソースからツリーと開いている文書を読み込み直す",treeRefreshed:"ツリーをソースから読み込み直しました",treeRefreshFailed:e=>`ツリーを読み込み直せませんでした: ${e}`,refreshDocumentLabel:"文書を更新",refreshDocument:"ソースから文書を読み込み直す",refreshDocumentNamed:e=>`${e} を更新`,documentRefreshed:e=>`${e} を読み込み直しました`,documentRefreshFailed:e=>`文書を読み込み直せませんでした: ${e}`,showMarkupLabel:"ソース",showMarkup:"文書の Markdown を書いたまま表示",showMarkupNamed:e=>`${e} のソース`,editDocumentLabel:"編集",editDocument:"文書の Markdown を編集 (文書のダブルクリックでも)",editDocumentNamed:e=>`${e} を編集`,editExternallyLabel:"元のエディタで開く",editExternally:"文書を元のエディタで、新しいタブに開く",editExternallyNamed:e=>`${e} を元のエディタで開く`,editorRegion:e=>`${e} を編集中`,editorLabel:e=>`${e} の Markdown`,editLoading:"編集のためにソースを読み込み中…",editToolbar:"エディタ",saveDraft:"保存",saveDraftTooltip:"下書きを保存 (Ctrl+S、Mac は ⌘S)",closeEditor:"編集を閉じる",previewToggle:"プレビュー",historyOpen:"履歴",draftUnsaved:"保存していない変更があります",draftSaving:"保存中…",draftSaved:"保存しました",draftSavedMerged:"ほかで保存された変更と統合して保存しました",draftConflicts:e=>`ほかで保存された変更と ${e} か所が重なりました。残す方を選んでから保存してください`,draftSaveFailed:e=>`保存できませんでした: ${e}`,documentSaved:e=>`${e} を保存しました`,documentSavedMerged:e=>`${e} を、ほかで保存された変更と統合して保存しました`,conflictOurs:"あなたの下書き",conflictTheirs:"ほかで保存された版",conflictUseOurs:"自分の行を使う",conflictUseTheirs:"保存された行を使う",conflictKeepBoth:"両方を残す",conflictNext:"次の衝突へ",editGrantTitle:"編集には許可が必要です",editGrantBody:"このサイトがあなたに代わって文書を変えることを許可してください。尋ねるのは 1 回だけで、サインアウトすると次にまた尋ねます。",editGrantAction:"許可する",editGrantRetry:"もう一度試す",unsavedTitle:"保存していない変更を破棄しますか?",unsavedBody:e=>`${e} に保存していない変更があります。`,unsavedDiscard:"変更を破棄",unsavedStay:"編集を続ける",historyTitle:e=>`${e} の版`,historyLoading:"版の一覧を読み込み中…",historyEmpty:"この文書の版は残っていません。",historyCurrent:"現在の版",historyKept:"保持",historyEntry:(e,t)=>t===""?e:`${e} (${t})`,historyRestore:"下書きに戻す",historyClose:"閉じる",historyRestored:e=>`${e} の下書きに版を戻しました。残すには保存してください`,previewRegion:"プレビュー",previewUpdating:"プレビューを更新中…",previewFailed: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:"名前の降順",sortOldest:"更新日時の昇順 (古い順)",sortNewest:"更新日時の降順 (新しい順)",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:"文書を読み込み中…",markupLoading:"ソースを読み込み中…",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:"ダウンロード",copyText:"テキストをコピー",copiedText:"テキストをコピーしました",copyTextFailed:"テキストをコピーできませんでした",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:"ここへパネルをドロップ"},Lt=Object.freeze({en:Object.freeze(At),ja:Object.freeze(Rn)}),Ze=Object.freeze(Object.keys(At)),Tn=new Set(Ze),Cn=e=>Tn.has(e),we=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,jt=e=>{if(e===void 0)return Ct;if(qe.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${qe.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${we(e)}`)},Ie=(e,t)=>{const n=Lt[jt(e)];if(t===void 0)return n;if(t===null||typeof t!="object")throw new RangeError(`[markdown-explorer] labels must be an object; got ${we(t)}`);if(!I.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${we(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!Cn(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${Ze.join(", ")}`);const a=r[s];if(a===void 0)continue;const u=typeof n[s];if(typeof a!==u)throw new TypeError(`[markdown-explorer] labels.${s} must be a ${u}; got ${we(a)}`);if(typeof a=="string"&&a.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const g=Ot[s];if(typeof a=="string"&&g!==void 0){for(const[,m]of a.matchAll(kn))if(!g.includes(m??""))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${String(m)}}; it accepts ${g.map(f=>`{${f}}`).join(", ")}`)}o[s]=a}return Object.freeze(o)},On=(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]))},Be=Object.freeze(["light","dark"]),An=e=>{if(e===void 0)return"light";if(Be.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${Be.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},Mt=i.createContext(null),P=()=>{const e=i.use(Mt);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},ue=e=>{const{viewSettings:t}=P(),n=()=>e(t.getSnapshot());return i.useSyncExternalStore(t.subscribe,n,n)},Se=()=>{const{config:e}=P(),t=Y.useParams()["*"],[n]=Y.useSearchParams(),r=n.toString();return i.useMemo(()=>I.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])},Nt={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[Nt[t][0]],le=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=P(),s=te(o,e.reason),a=o[Nt[e.reason][1]],u=e.reason==="unauthorized"||e.reason==="forbidden"||e.reason==="failed"?"danger":"warning";return l.jsxs("div",{className:"aqmx-callout",role:t?"alert":void 0,"data-aqmx-tone":u,"data-testid":r===null?void 0:r,"data-aqmx-failure":r===null?void 0:e.reason,children:[l.jsx("p",{className:"aqmx-callout-title",children:s}),l.jsx("p",{className:"aqmx-callout-body",children:a}),e.reason==="unauthorized"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:()=>window.location.reload(),children:o.reloadPage}):n!==void 0&&e.reason==="failed"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:n,children:o.retry}):null]})},Ln=(e,t)=>{const{phase:n,save:r,dirty:o}=t;switch(n.kind){case"opening":return e.editLoading;case"grant":return e.editGrantTitle;case"failed":return te(e,n.failure.reason)}switch(r.kind){case"saving":return e.draftSaving;case"conflicts":return e.draftConflicts(r.count);case"grant":return e.editGrantTitle;case"failed":return e.draftSaveFailed(te(e,r.failure.reason));case"saved":if(!o)return r.merged?e.draftSavedMerged:e.draftSaved;break}return o?e.draftUnsaved:""},jn=(e,t,n)=>{switch(t.kind){case"saved":return t.merged?e.documentSavedMerged(n):e.documentSaved(n);case"conflicts":return e.draftConflicts(t.count);case"grant":return e.editGrantTitle;case"failed":return e.draftSaveFailed(te(e,t.failure.reason));case"idle":case"saving":return null}},ae=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},Dt="<<<<<<<",Pt="=======",_t=">>>>>>>",rt=(e,t)=>e===t||e.startsWith(`${t} `),ot=e=>Ft(e.split(`
2
2
  `)),Ft=e=>{const t=[];let n=null,r=null,o=0;for(const s of e){o+=1;const a=s.charCodeAt(0);a!==60&&a!==61&&a!==62||(rt(s,Dt)?(n=o,r=null):s===Pt?n!==null&&r===null?r=o:n=null:rt(s,_t)&&(n!==null&&r!==null&&t.push({start:n,separator:r,end:o}),n=null,r=null))}return t},st=e=>e.includes(`\r
3
3
  `)?`\r
4
4
  `:`
@@ -6,8 +6,8 @@
6
6
  `),Mn=(e,t)=>t===`
7
7
  `?e:e.replaceAll(`
8
8
  `,`\r
9
- `),Nn=3,Me=Object.freeze({kind:"idle"}),Dn=({data:e,conflictLabels:t,onSaveSettled:n,previewSetting:r})=>{const o=new Map,s=new Map,a=new Map,u=new Map,g=new Map,m=ae();let f=null,v=null;const h=(c,d)=>{c.value={...c.value,...d},m.emit()},S=(c,d)=>o.get(c)===d,A=async(c,d)=>{d.controller.abort(),d.controller=new AbortController;const{signal:p}=d.controller;h(d,{phase:{kind:"opening"}});const x=await e.edit(c,p);if(!S(c,d)||p.aborted||!("kind"in x))return;if(x.kind==="grant"){h(d,{phase:{kind:"grant",href:x.href}});return}if(x.kind==="failure"){h(d,{phase:{kind:"failed",failure:x.failure}});return}const k=je(x.text);d.base={text:k,version:x.version},d.draft=k,d.ending=st(x.text),h(d,{phase:{kind:"editing"},history:x.history,dirty:!1,save:Me,generation:d.value.generation+1})},y=c=>{const d=o.get(c);d!==void 0&&(d.controller.abort(),o.delete(c),a.delete(c))},C=(c,d,p)=>(c.set(d,p),()=>{c.get(d)===p&&c.delete(d)}),R=(c,d,p,x={})=>{h(d,{...x,save:p}),n(c,p)},M=async c=>{u.get(c)?.flush();const d=o.get(c);if(d===void 0||d.value.phase.kind!=="editing"||d.base===null||d.value.save.kind==="saving")return;const p=ot(d.draft).length;if(p>0){R(c,d,{kind:"conflicts",count:p});return}d.controller.abort(),d.controller=new AbortController;const{signal:x}=d.controller;let k=d.base,j=d.draft,T=!1;h(d,{save:{kind:"saving"}});for(let D=0;D<Nn;D+=1){const F=await e.save(c,k.version,Mn(j,d.ending),x);if(!S(c,d)||x.aborted||!("kind"in F))return;if(F.kind==="saved"){u.get(c)?.flush(),d.base={text:j,version:F.version},R(c,d,{kind:"saved",merged:T},{dirty:d.draft!==j});return}if(F.kind==="grant"){R(c,d,{kind:"grant",href:F.href});return}if(F.kind==="failure"){R(c,d,{kind:"failed",failure:F.failure});return}const{mergeDraft:V}=await Promise.resolve().then(()=>require("./merge-D0aGvFKC.cjs"));if(!S(c,d)||x.aborted)return;const K=u.get(c);K?.flush();const X=je(F.text),G=V(k.text,d.draft,X,t());if(k={text:X,version:F.version},d.base=k,d.ending=st(F.text),d.draft=G.text,K?.adopt(G.text),G.kind==="conflicts"){R(c,d,{kind:"conflicts",count:G.conflicts},{dirty:!0,generation:d.value.generation+1});return}if(T=!0,j=G.text,j===k.text){R(c,d,{kind:"saved",merged:T},{dirty:!1,generation:d.value.generation+1});return}h(d,{dirty:!0,generation:d.value.generation+1})}R(c,d,{kind:"failed",failure:{reason:"failed"}})};return{session:c=>o.get(c)?.value,subscribe:m.subscribe,start:(c,d)=>{const p=o.get(c);if(p!==void 0){h(p,{request:{anchor:d}}),(p.value.phase.kind==="failed"||p.value.phase.kind==="grant")&&A(c,p);return}s.delete(c);const x={value:{path:c,phase:{kind:"opening"},history:!1,dirty:!1,save:Me,generation:0,request:{anchor:d}},base:null,draft:"",ending:`
10
- `,controller:new AbortController};o.set(c,x),A(c,x)},retry:c=>{const d=o.get(c);d===void 0||d.value.phase.kind==="editing"||A(c,d)},draft:c=>{const d=o.get(c);return d===void 0||d.base===null?null:d.draft},setDraft:(c,d)=>{const p=o.get(c);if(p===void 0||p.base===null)return;p.draft=d;const x={},k=d!==p.base.text;k!==p.value.dirty&&(x.dirty=k);const{save:j}=p.value;if(j.kind==="conflicts"){const T=ot(d).length;T===0?x.save=Me:T!==j.count&&(x.save={kind:"conflicts",count:T})}(x.dirty!==void 0||x.save!==void 0)&&h(p,x)},consumeRequest:c=>{const d=o.get(c);d!==void 0&&d.value.request!==null&&h(d,{request:null})},save:M,replaceDraft:(c,d)=>{const p=u.get(c);p?.flush();const x=o.get(c);if(x===void 0||x.base===null)return;const k=je(d);x.draft=k,p?.adopt(k),h(x,{dirty:k!==x.base.text,generation:x.value.generation+1})},close:c=>{if(!o.has(c))return;const d=u.get(c),p=d===void 0?null:d.returnPoint();y(c),p===null?s.delete(c):s.set(c,p),m.emit()},takeReturn:c=>{const d=s.get(c)??null;return s.delete(c),d},dirtyPaths:()=>[...o.values()].filter(c=>c.value.dirty).map(c=>c.value.path),discard:c=>{for(const d of c)y(d);c.length>0&&m.emit()},editorState:{get:c=>a.get(c),set:(c,d)=>{o.has(c)&&a.set(c,d)}},bindEditor:(c,d)=>C(u,c,d),bindView:(c,d)=>C(g,c,d),viewAnchor:c=>{const d=g.get(c);return d===void 0?null:d.anchor()},flush:c=>u.get(c)?.flush(),flushDrafts:()=>{for(const c of u.values())c.flush()},nextConflict:c=>u.get(c)?.nextConflict()===!0,hasSessions:()=>o.size>0,unsavedAmong:c=>{for(const d of u.values())d.flush();return c.filter(d=>o.get(d)?.value.dirty===!0)},askToDiscard:c=>new Promise(d=>{v?.settle(!1);const p={paths:c,settle:x=>{if(v===p){if(v=null,x)for(const k of c)y(k);m.emit(),d(x)}}};v=p,m.emit()}),discardRequest:()=>v,previewShown:()=>(f??=r.read(),f),setPreviewShown:c=>{f!==c&&(f=c,r.write(c),m.emit())}}},Ve=e=>{e.preventDefault(),e.stopPropagation()},$t=({open:e,title:t,body:n,confirmLabel:r,cancelLabel:o,onConfirm:s,onCancel:a,testId:u})=>{const g=i.useRef(null),m=i.useRef(null),f=i.useRef(null),v=i.useId(),h=i.useId();i.useLayoutEffect(()=>{const y=g.current;if(y!==null)if(e&&!y.open){const C=y.ownerDocument.activeElement;f.current=C instanceof HTMLElement?C:null,y.showModal(),m.current?.focus()}else!e&&y.open&&(y.close(),f.current?.isConnected===!0&&f.current.focus(),f.current=null)},[e]);const S=y=>{y.key!=="Escape"||y.defaultPrevented||(Ve(y),a())},A=y=>{y.target===y.currentTarget&&a()};return l.jsx("dialog",{ref:g,className:"aqmx-confirm","aria-labelledby":v,"aria-describedby":h,"data-testid":u,onKeyDown:S,onClick:A,onCancel:y=>y.preventDefault(),children:l.jsxs("div",{className:"aqmx-confirm-panel",children:[l.jsx("p",{id:v,className:"aqmx-confirm-title",children:t}),l.jsx("p",{id:h,className:"aqmx-confirm-body",children:n}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{ref:m,type:"button",className:"aqmx-callout-action","data-testid":`${u}-cancel`,onClick:a,children:o}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-aqmx-tone":"danger","data-testid":`${u}-confirm`,onClick:s,children:r})]})]})})},Pn=(e,t)=>{const n=Y.matchPath({path:`${e.basePath}/*`,end:!0},t.pathname);if(n===null)return new Set;const{location:r}=I.resolveExplorerLocation(e,n.params["*"],new URLSearchParams(t.search));switch(r.view){case"tree":return new Set(r.doc===null?[]:[r.doc]);case"single":return new Set([r.doc]);case"multi":return new Set(r.docs)}},qt=e=>{const{edits:t}=P(),n=i.useCallback(()=>t.session(e),[t,e]);return i.useSyncExternalStore(t.subscribe,n,_n)},It=()=>!1,_n=()=>{},Fn=()=>{const{edits:e}=P();return i.useSyncExternalStore(e.subscribe,e.hasSessions,It)},Bt=()=>{const{edits:e}=P();return i.useSyncExternalStore(e.subscribe,e.previewShown,It)},$n=()=>null,qn=()=>{const{edits:e,labels:t,config:n}=P(),r=i.useRef([]),o=i.useCallback(({nextLocation:v})=>{const h=Pn(n,v);return e.flushDrafts(),r.current=e.dirtyPaths().filter(S=>!h.has(S)),r.current.length>0},[e,n]),s=Y.useBlocker(o),a=Fn();i.useEffect(()=>{if(!a)return;const v=h=>{e.flushDrafts(),e.dirtyPaths().length!==0&&(h.preventDefault(),h.returnValue=!0)};return window.addEventListener("beforeunload",v),()=>window.removeEventListener("beforeunload",v)},[a,e]);const u=i.useSyncExternalStore(e.subscribe,e.discardRequest,$n),g=s.state==="blocked",f=(g?r.current:u===null?[]:u.paths).map(v=>N.lastPathSegment(v)).join(", ");return l.jsx($t,{open:g||u!==null,title:t.unsavedTitle,body:t.unsavedBody(f),confirmLabel:t.unsavedDiscard,cancelLabel:t.unsavedStay,testId:"markdown-explorer-unsaved-guard",onConfirm:()=>{if(s.state==="blocked"){e.discard(r.current),s.proceed();return}u?.settle(!0)},onCancel:()=>{if(s.state==="blocked"){s.reset();return}u?.settle(!1)}})};function In({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 Bn=E.forwardRef(In);let Ne=null;const Ut=()=>(Ne??=Promise.resolve().then(()=>require("./EditSurface-B-l3Do_C.cjs")).catch(e=>{throw Ne=null,e}),Ne),lt=()=>{Ut().catch(()=>{})},Un=e=>{const{default:t}=i.use(Ut());return l.jsx(t,{...e})};class Hn extends i.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}retry=()=>this.setState({failed:!1});render(){return this.state.failed?this.props.fallback(this.retry):this.props.children}}const Ge=`[${$e.SOURCE_LINES_ATTRIBUTE}]`,zn="[data-aqmd-content]",Zn='a[href], button, input, select, textarea, summary, label, [contenteditable], [role="menu"], iframe, video, audio, object, embed, svg',Vn=200,fe=e=>$e.parseSourceLines(e.getAttribute($e.SOURCE_LINES_ATTRIBUTE)),Gn=(e,t)=>{for(let r=e;r!==null&&t.contains(r);r=r.parentElement){const o=fe(r);if(o!==null)return{block:r,lines:o,own:!0}}let n=null;for(const r of t.querySelectorAll(Ge)){if(!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))break;const o=fe(r);o!==null&&(n={block:r,lines:o})}return n===null?null:{...n,own:!1}},Kn=(e,t)=>{let n=0;for(let r=e.indexOf(t);r>=0;r=e.indexOf(t,r+t.length))n+=1;return n},Wn=e=>e.closest(zn)!==null&&e.closest(Zn)===null,Xn=(e,t,n)=>{const r=Gn(e,t);if(r===null)return null;const{block:o,own:s}=r;if(!s){const u=r.lines.last+1;return{lines:{first:u,last:u},word:null,occurrence:0,clientTop:Ee(e)}}const a=Qn(o,n);return a===null?{lines:r.lines,word:null,occurrence:0,clientTop:Ee(o)}:{lines:r.lines,word:a.text,occurrence:a.occurrence,clientTop:a.clientTop}},Yn=(e,t)=>{let n=null,r=null,o=null;for(const a of e.querySelectorAll(Ge)){const u=fe(a);if(u===null)continue;n??=zt(t,a);const{top:g,bottom:m}=a.getBoundingClientRect();g<=n&&n<m?r={lines:u,block:a}:o===null&&g>=n&&(o={lines:u,block:a})}const s=r===null?o:r;return s===null?null:{lines:s.lines,word:null,occurrence:0,clientTop:Ee(s.block)}},Ht=e=>e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,zt=(e,t)=>{const n=Number.parseFloat(getComputedStyle(t).scrollMarginTop);return Ht(e)+(Number.isFinite(n)?n:0)},Qn=(e,t)=>{if(t===null||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!(e.contains(n.startContainer)&&e.contains(n.endContainer)))return null;const r=n.toString().trim();if(r===""||r.length>Vn||/[\r\n]/u.test(r))return null;const o=e.ownerDocument.createRange();return o.setStart(e,0),o.setEnd(n.startContainer,n.startOffset),{text:r,occurrence:Kn(o.toString(),r),clientTop:n.getBoundingClientRect().top}},Jn=(e,t)=>{const n=e.split(`
11
- `),r=Math.min(t.lines.first,n.length),o=Math.min(t.lines.last,n.length),s={line:r,column:0};if(t.word===null)return s;let a=0;for(let u=r;u<=o;u+=1){const g=n[u-1]??"";for(let m=g.indexOf(t.word);m>=0;m=g.indexOf(t.word,m+t.word.length)){if(a===t.occurrence)return{line:u,column:m};a+=1}}return a>0?er(n,r,o,t.word)??s:s},er=(e,t,n,r)=>{for(let o=n;o>=t;o-=1){const s=(e[o-1]??"").lastIndexOf(r);if(s>=0)return{line:o,column:s}}return null},Zt=(e,t)=>{let n=null,r=null;for(const o of e.querySelectorAll(Ge)){const s=fe(o);s===null||s.first>t||(s.last>=t?n=o:(r===null||s.last>=r.last)&&(r={element:o,last:s.last}))}return n!==null?n:r===null?null:r.element},Vt=(e,t)=>{const{bottom:n}=e.getBoundingClientRect(),r=Ee(e),o=fe(e);if(o===null)return r;const s=Math.min(Math.max(t-o.first,0)/(o.last-o.first+1),1);return r+(n-r)*s},Ee=e=>{const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let n=t.nextNode();n!==null;n=t.nextNode()){const o=(n.textContent??"").search(/\S/u);if(o<0)continue;const s=e.ownerDocument.createRange();s.setStart(n,o),s.setEnd(n,o+1);const{top:a,height:u}=s.getBoundingClientRect();if(u>0)return a}return e.getBoundingClientRect().top},Ke=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})}),tr=e=>Ke[e],he=()=>{const e=Y.useNavigate();return i.useCallback((t,n)=>{e(t,Ke[n])},[e])},Gt=({navigation:e,...t})=>l.jsx(Y.Link,{...t,...Ke[e]}),We=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},Kt=(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(m=>{if(r.current!==m)return;const f=o.current;if(f!==null){f.then(()=>a(m));return}e.prefetch(m);const v=e.peek(m);if(v?.status!=="pending")return;const h=Promise.allSettled([v.promise]);o.current=h,h.then(()=>{o.current===h&&(o.current=null)})},[e]),u=i.useCallback(m=>{const f=t(m);f!==r.current&&(s(),f!==null&&(r.current=f,n.current=window.setTimeout(()=>{n.current=null,a(f)},I.PREFETCH_DWELL_MS)))},[s,t,a]),g=i.useCallback(m=>{t(m)!==r.current&&s()},[s,t]);return i.useMemo(()=>({onPointerOver:m=>u(m.target),onPointerOut:m=>g(m.relatedTarget),onFocus:m=>u(m.target),onBlur:m=>g(m.relatedTarget)}),[u,g])},nr=i.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-Dt6xH5Mb.cjs")).then(e=>({default:e.NativeScrollBar})));class rr 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 Wt=({scroller:e,withCircle:t})=>l.jsx(rr,{children:l.jsx(i.Suspense,{fallback:null,children:l.jsx(nr,{scroller:e,withCircle:t})})}),Xt=e=>l.jsx(Wt,{scroller:e,withCircle:!0}),Yt=()=>{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()]}},be=(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)=>be(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)&&be(n[s],r[s]))},me=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},Qt=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),ge=e=>e.status==="fulfilled"?e.value:void 0,or=55e3,it=Object.freeze({status:"deferred"}),at=Object.freeze({status:"refreshed"}),De=Object.freeze({status:"superseded"}),oe=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,Jt=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",sr=({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=Yt(),o=ae(),s=new WeakSet;let a=0;const u=o.emit,g=()=>(a+=1,a),m=()=>{if(!(n.size<=t))for(const c of[...n.keys()]){if(n.size<=t)return;r.isHeld(c)||n.delete(c)}},f=(c,d)=>{n.delete(c),n.set(c,d)},v=c=>performance.now()-c.validatedAt>=or,h=(c,d,p)=>{const x=n.get(c),k=oe(x?.snapshot),j=p||x?.refreshPending===!0,T=me(e.document(c,{refresh:j}).then(F=>({status:"loaded",document:F}))),D={snapshot:{status:"pending",promise:T,previous:k},validatedAt:performance.now(),opened:d,background:null,refreshPending:!1,seeded:void 0,stamp:g()};return f(c,D),m(),T.then(F=>{n.get(c)===D&&(D.snapshot=F,D.stamp=g(),u())}),D},S=(c,d,p,x,k,j)=>{d.background===p&&(d.background=null,!(n.get(c)!==d||d.snapshot!==x)&&(k.kind==="failure"&&x.document.kind!=="failure"||(d.validatedAt=j,d.stamp=g(),be(x.document,k)||(d.snapshot={status:"loaded",document:k}),u())))},A=async(c,d)=>{const p=d.snapshot;if(p.status!=="loaded")return null;const x={};d.background=x;const k=performance.now(),j=e.document(c,{refresh:d.refreshPending});d.refreshPending=!1;const T=await j,D=d.background===x&&n.get(c)===d&&d.snapshot===p;return S(c,d,x,p,T,k),D?T:null},y=(c,d)=>{const{snapshot:p}=d;return p.status==="pending"?!1:p.status==="loaded"&&p.document.kind!=="failure"?(A(c,d),!1):(p.status==="loaded"&&s.add(p),h(c,!0,!1),!0)},C=c=>{const d=r.hold(c);let p=!1;return()=>{if(p)return;p=!0,d();const x=n.get(c);x!==void 0&&f(c,x),m()}};return{peek:c=>n.get(c)?.snapshot,peekSeeded:c=>n.get(c)?.seeded,answerStampOf:c=>n.get(c)?.stamp,prefetch:c=>{const d=n.get(c);d!==void 0&&d.snapshot.status!=="deferred"||(h(c,!1,!1),u())},open:c=>{const d=r.resumes(c),p=C(c),x=n.get(c);if(x===void 0||x.snapshot.status==="deferred")return h(c,!0,!1),u(),p;if(f(c,x),d)return p;const{snapshot:k}=x;return k.status==="pending"?(x.opened=!0,p):k.document.kind==="failure"?(x.opened||v(x)?(s.add(k),h(c,!0,!1),u()):x.opened=!0,p):(x.opened=!0,x.background===null&&v(x)&&A(c,x),p)},retain:C,retry:c=>{const d=n.get(c);d===void 0||d.snapshot.status!=="loaded"||d.snapshot.document.kind!=="failure"||(h(c,!0,!1),u())},seed:(c,d)=>{const p=performance.now(),x=me(d.then(F=>F===null?it:{status:"loaded",document:F},()=>it)),k=n.get(c);if(k!==void 0&&k.snapshot.status==="loaded"){const F=k.snapshot,V={};k.background=V,x.then(K=>{if(K.status==="loaded"){S(c,k,V,F,K.document,p);return}k.background===V&&(k.background=null)});return}const j=k!==void 0&&k.snapshot.status==="pending"?k.snapshot.previous:null,T={status:"pending",promise:x,previous:j},D={snapshot:T,validatedAt:p,opened:k?.opened===!0,background:null,refreshPending:k?.refreshPending===!0,seeded:T,stamp:g()};f(c,D),m(),x.then(F=>{n.get(c)===D&&(F.status==="deferred"&&r.isHeld(c)?h(c,D.opened,!1):(D.snapshot=F,D.stamp=g()),u())})},invalidate:()=>{let c=!1;for(const[d,p]of[...n]){if(p.validatedAt=Number.NEGATIVE_INFINITY,p.opened=!0,p.refreshPending=!0,!r.isHeld(d))continue;const{snapshot:x}=p;if(x.status!=="pending"){y(d,p)&&(c=!0);continue}x.promise.then(()=>{n.get(d)===p&&p.refreshPending&&r.isHeld(d)&&y(d,p)&&u()})}c&&u()},refresh:async c=>{const d=n.get(c);if(d!==void 0&&Jt(d.snapshot)){d.refreshPending=!0;const x=await A(c,d);return x===null?De:x.kind==="failure"?{status:"failed",failure:x.failure}:at}const p=h(c,!0,!0);return u(),p.snapshot.status!=="pending"?De:(await p.snapshot.promise,n.get(c)===p?at:De)},clear:()=>{n.clear();for(const c of r.heldKeys())h(c,!0,!1);u()},subscribe:o.subscribe,noteFailureShown:c=>s.has(c)?!1:(s.add(c),!0)}};function lr({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M18 5.25a2.25 2.25 0 0 0-2.012-2.238A2.25 2.25 0 0 0 13.75 1h-1.5a2.25 2.25 0 0 0-2.238 2.012c-.875.092-1.6.686-1.884 1.488H11A2.5 2.5 0 0 1 13.5 7v7h2.25A2.25 2.25 0 0 0 18 11.75v-6.5ZM12.25 2.5a.75.75 0 0 0-.75.75v.25h3v-.25a.75.75 0 0 0-.75-.75h-1.5Z",clipRule:"evenodd"}),E.createElement("path",{fillRule:"evenodd",d:"M3 6a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H3Zm6.874 4.166a.75.75 0 1 0-1.248-.832l-2.493 3.739-.853-.853a.75.75 0 0 0-1.06 1.06l1.5 1.5a.75.75 0 0 0 1.154-.114l3-4.5Z",clipRule:"evenodd"}))}const ir=E.forwardRef(lr);function ar({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M15.988 3.012A2.25 2.25 0 0 1 18 5.25v6.5A2.25 2.25 0 0 1 15.75 14H13.5v-3.379a3 3 0 0 0-.879-2.121l-3.12-3.121a3 3 0 0 0-1.402-.791 2.252 2.252 0 0 1 1.913-1.576A2.25 2.25 0 0 1 12.25 1h1.5a2.25 2.25 0 0 1 2.238 2.012ZM11.5 3.25a.75.75 0 0 1 .75-.75h1.5a.75.75 0 0 1 .75.75v.25h-3v-.25Z",clipRule:"evenodd"}),E.createElement("path",{d:"M3.5 6A1.5 1.5 0 0 0 2 7.5v9A1.5 1.5 0 0 0 3.5 18h7a1.5 1.5 0 0 0 1.5-1.5v-5.879a1.5 1.5 0 0 0-.44-1.06L8.44 6.439A1.5 1.5 0 0 0 7.378 6H3.5Z"}))}const cr=E.forwardRef(ar);function dr({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",clipRule:"evenodd"}))}const ur=E.forwardRef(dr),fr=2e3,ct=Object.freeze({outcome:"idle"}),mr=e=>{const t=navigator.clipboard;return t===void 0?Promise.reject(new Error("[markdown-explorer] this browser has no asynchronous clipboard")):t.writeText(e)},hr=({text:e})=>{const{announcer:t,labels:n}=P(),[r,o]=i.useState(ct);i.useEffect(()=>{if(r.outcome==="idle")return;const g=setTimeout(()=>o(ct),fr);return()=>clearTimeout(g)},[r]);const s=g=>{o({outcome:g}),t.announce(g==="copied"?n.copiedText:n.copyTextFailed)},a=()=>{mr(e).then(()=>s("copied"),()=>s("failed"))},u=r.outcome==="copied"?n.copiedText:r.outcome==="failed"?n.copyTextFailed:n.copyText;return l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":n.copyText,title:u,onClick:a,"data-aqmx-copy-outcome":r.outcome,"data-testid":"markdown-explorer-file-copy",children:r.outcome==="copied"?l.jsx(ir,{}):r.outcome==="failed"?l.jsx(ur,{}):l.jsx(cr,{})})},ie=i.createContext("fill"),pr=Object.freeze({blockSize:"100%"}),pe=({scrollerProps:e,children:t})=>i.use(ie)==="content"?l.jsx(de.HostedScrollArea,{scrollerProps:e,children:t}):l.jsx(de.HostedScrollArea,{scrollerProps:{...e,style:pr},rowClassName:"aqmx-document-scroll-row",renderScrollBar:Xt,children:t});function gr({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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"}),E.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 vr=E.forwardRef(gr);function wr({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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"}),E.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 xr=E.forwardRef(wr),ke=({name:e,openUrl:t,downloadUrl:n,icon:r,children:o})=>{const{labels:s}=P();return l.jsxs("div",{className:"aqmx-document-toolbar",children:[l.jsx("span",{className:"aqmx-document-file-icon","aria-hidden":"true",children:r}),l.jsx("span",{className:"aqmx-document-title",title:e,"data-testid":"markdown-explorer-file-name",children:e}),o,l.jsx("a",{className:"aqmx-icon-button",href:t,target:"_blank",rel:"noopener noreferrer","aria-label":s.openInNewTab,title:s.openInNewTab,"data-testid":"markdown-explorer-file-open",children:l.jsx(xr,{})}),l.jsx("a",{className:"aqmx-icon-button",href:n,download:e,"aria-label":s.download,title:s.download,"data-testid":"markdown-explorer-file-download",children:l.jsx(vr,{})})]})};function Er({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 br=E.forwardRef(Er),yr=Object.freeze({className:"aqmx-document-stage"}),Sr=({document:e})=>{const{labels:t}=P();return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[l.jsx(ke,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(br,{})}),l.jsx(pe,{scrollerProps:yr,children:l.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-file-not-shown",children:[l.jsx("p",{className:"aqmx-callout-body",children:t.fileNotShown}),l.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-file-not-shown-download",children:t.download})]})})]})},Re="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",kr=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},Rr=/(%[0-9A-Fa-f]{2})/u,Xe=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(Rr).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))},en=e=>`#${encodeURIComponent(e)}`,Tr=e=>{if(e==="#")return!0;const t=Xe(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},tn=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},Cr="http://www.w3.org/1999/xhtml",dt=(e,t)=>{if(t==="")return null;const n=tn(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===Cr&&r.getAttribute("name")===t)return r;return null},nn=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=dt(e,t.slice(1));if(n!==null)return n;const r=Xe(t);return r===null?null:dt(e,r)},ut=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"},Or=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"},Ar=(e,t)=>{const n=t.closest(Re),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&ut(r))return r;const o=e.getBoundingClientRect().height,{documentElement:s,scrollingElement:a}=e.ownerDocument;for(let u=e.parentElement;u!==null&&u!==s;u=u.parentElement)if(ut(u)&&u.scrollHeight>u.clientHeight&&u.clientHeight<o)return u;return a instanceof Element&&Or(e.ownerDocument)&&a.scrollHeight>a.clientHeight&&a.clientHeight<o?a:r},Lr=Object.freeze({scrollerOf:Ar,reveal:e=>{e.scrollIntoView(Ue)}}),Ue=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),jr=(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")}}},Mr=(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(),u=a.height+s+Number.parseFloat(o)>e.clientHeight;if(!u&&Math.abs(a.top-s-n)<1){t.scrollIntoView(Ue);return}e.scrollBy({top:u?a.top-n-e.clientHeight:a.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(Ue)},Nr=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(Re)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},ft=(e,t,n)=>{if(e===null)return null;const r=nn(e,t);return r===null?(Tr(t)&&Nr(e,n),null):(jr(e,r),Mr(n.scrollerOf(e,r),r),n.reveal(r),r)};function Dr({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 Pr=E.forwardRef(Dr);function _r({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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"}),E.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 Fr=E.forwardRef(_r);function $r({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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"}),E.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 qr=E.forwardRef($r);function Ir({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 Br=E.forwardRef(Ir),He="data-aqmx-key-repeat",ye=Object.freeze({[He]:"allow"}),Ur=`[${He}="${ye[He]}"]`,Hr=()=>{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(Ur)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},xe=Object.freeze([1/I.GOLDEN_RATIO**2,1/I.GOLDEN_RATIO,1,I.GOLDEN_RATIO,I.GOLDEN_RATIO**2]),mt=Object.freeze({mode:"fit"}),zr=1,Zr=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),rn=i.createContext(null),Vr=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=zr?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,ht=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<xe.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?xe.findIndex(o=>o>t):xe.findLastIndex(o=>o<t);return r===-1?null:r},pt=(e,t,n)=>{if(e.mode==="level"){const o=ht(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=ht(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},Gr=e=>{const t=xe[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},gt=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},Kr=({document:e})=>{const{labels:t}=P(),n=i.use(rn),[r]=i.useState(()=>n===null?null:n.read(e.url)),[o,s]=i.useState(r===null?mt:r.zoom),[a,u]=i.useState(r===null?null:r.reported),[g,m]=i.useState(null),f=i.useRef(null),v=i.useCallback(M=>{const{naturalWidth:c,naturalHeight:d}=M;u(p=>gt(p,c,d))},[]),h=i.useCallback(M=>{f.current=M,!(M===null||!M.complete)&&(M.naturalWidth>0||M.naturalHeight>0?v(M):M.decode().then(()=>v(M),()=>{}))},[v]);i.useEffect(()=>{n!==null&&a!==null&&n.save(e.url,{zoom:o,reported:a})},[n,e.url,o,a]),i.useLayoutEffect(()=>{const M=f.current;if(M===null||a===null||o.mode!=="fit")return;const c=()=>m(p=>gt(p,M.clientWidth,M.clientHeight));if(c(),typeof ResizeObserver>"u")return;const d=new ResizeObserver(c);return d.observe(M),()=>d.disconnect()},[a,o.mode]);const S=a===null||g===null?null:Vr(a,g),A=pt(o,S,-1),y=pt(o,S,1),C=o.mode==="level"?Gr(o.index):null,R=o.mode==="level"&&C!==null?{width:`${o.base.width*C}px`,height:`${o.base.height*C}px`}:void 0;return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[l.jsxs(ke,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(Br,{}),children:[l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":A===null,onClick:()=>{A!==null&&s(A)},...ye,children:l.jsx(Fr,{})}),l.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:C===null?t.imageFitLevel:t.imageZoomLevel(Math.round(C*100))}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":y===null,onClick:()=>{y!==null&&s(y)},...ye,children:l.jsx(qr,{})}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(mt),children:l.jsx(Pr,{})})]}),l.jsx(pe,{scrollerProps:Zr,children:l.jsx("img",{ref:h,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:R,onLoad:M=>v(M.currentTarget),"data-testid":"markdown-explorer-image"})})]})},on=i.createContext(null),Te=i.createContext(void 0),sn=i.createContext(null),Ce=()=>{const e=i.use(on);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},Wr=()=>{const e=i.use(sn);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},Oe=(e,t,n,r)=>t.kind==="panel"?I.explorerHref(e,{view:"tree",source:n,doc:r}):t.view==="single"?I.explorerHref(e,{view:"single",source:n,doc:r,overrides:t.overrides,embed:t.embed}):I.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides}),Xr=({children:e})=>{const{config:t}=P(),n=Ce(),r=Se(),o=r.kind==="location"?r.location.source:void 0,s=Y.useHref(Oe(t,n.navigation,o,n.currentPath));return l.jsx(Te,{value:o,children:l.jsx(sn,{value:s,children:e})})},Yr='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',Qr=e=>{const t=e instanceof Element?e.closest(Yr):null;return t===null?null:t.getAttribute("data-doc-path")},Ae=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Jr=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:a,scope:u,children:g})=>{const m=Y.useHref(e),f=v=>{if(Ae(v)){if(v.preventDefault(),t===u.currentPath&&n!==""){u.scrollWithin(n);return}a(t,n)}};return l.jsx("a",{...s,href:m,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:f,children:g})},eo=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:a}=P(),u=Ce(),g=i.use(Te),m=kr(e),{navigation:f}=u,v=`${Oe(a,f,g,t)}${m}`,h=n===!1?"false":void 0;return f.kind==="page"?l.jsx(Gt,{...o,to:v,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":h,children:s}):l.jsx(Jr,{to:v,docPath:t,fragment:m,exists:h,className:r,attributes:o,onDocumentLink:f.onDocumentLink,scope:u,children:s})},to=({className:e,attributes:t,children:n})=>{const{labels:r}=P();return l.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,l.jsxs("span",{className:"aqmx-sr-only",children:[" (",r.inertLink,")"]})]})},no=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=P(),a=i.use(Te),u=Y.useHref(`${Oe(s,r.navigation,a,r.currentPath)}${e}`),g=m=>{Ae(m)&&(m.preventDefault(),r.scrollWithin(e))};return l.jsx("a",{...n,href:u,className:t,onClick:g,children:o})},ro=({href:e,className:t,attributes:n,children:r})=>{const o=Ce();if(o.navigation.kind==="page"){const s=a=>{if(!Ae(a))return;const u=a.currentTarget;e==="#"?o.followEmptyFragment(a.nativeEvent):u.href===u.ownerDocument.URL&&o.followSameUrlJump(e,a.nativeEvent)};return l.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return l.jsx(no,{href:e,className:t,attributes:n,scope:o,children:r})},oo=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:a})=>t==="doc"?n===void 0||!N.isAcceptableDocumentPath(n)?l.jsx(to,{className:o,attributes:s,children:a}):l.jsx(eo,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:a}):e.startsWith("#")?l.jsx(ro,{href:e,className:o,attributes:s,children:a}):l.jsx("a",{...s,href:e,className:o,children:a}),so=()=>{const{config:e}=P(),t=Ce(),n=i.use(Te),r=he();return i.useCallback((o,s)=>{if(!Ae(s))return!0;s.preventDefault();const a=en(o.id),{navigation:u}=t;return u.kind==="panel"||Xe(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(a),!0):(r(`${Oe(e,u,n,t.currentPath)}${a}`,"follow-link"),!0)},[e,t,n,r])},lo=()=>{const e=Wr();return i.useCallback(t=>`${e}${en(t.id)}`,[e])};function io({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 ao=E.forwardRef(io);function co({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 uo=E.forwardRef(co);function fo({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 mo=E.forwardRef(fo),ho=Object.freeze({className:"aqmx-document-stage"}),po=e=>{switch(e){case"video":return l.jsx(uo,{});case"audio":return l.jsx(mo,{});case"pdf":return l.jsx(ao,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},go=({document:e})=>{const{labels:t}=P();switch(e.mediaType){case"video":return l.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 l.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 l.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)}`)}}},vo=({document:e})=>l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[l.jsx(ke,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:po(e.mediaType)}),l.jsx(pe,{scrollerProps:ho,children:l.jsx(go,{document:e})})]}),wo=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}),ln=(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},an=(e,t)=>e!==void 0?e:t!==void 0?t:yn.DEFAULT_CONTENT_ALIGN,Ye=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),xo=(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 I.explorerHref(e,{...t,overrides:r})},Qe=({kind:e,view:t,label:n,stale:r,busy:o,frameRef:s,intent:a,children:u})=>{const g=i.use(ie);return l.jsxs("section",{ref:s,role:"region","aria-label":n,"aria-busy":o,"data-testid":"markdown-explorer-document","data-aqmx-document-kind":e,"data-aqmx-document-view":t,"data-aqmx-document-flow":g,className:"aqmx-document",...a,children:[r?l.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,u]})},Eo=()=>{const{labels:e}=P();return l.jsx(Qe,{kind:"empty",label:e.documentRegion,stale:!1,busy:!1,children:l.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-document-empty",children:l.jsx("p",{className:"aqmx-empty-title",children:e.documentEmpty})})})},cn=({label:e})=>{const{labels:t}=P();return l.jsxs(Qe,{kind:"loading",label:e,stale:!1,busy:!0,children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-document-skeleton",children:Ye.map(n=>l.jsx("span",{},n))}),l.jsx("p",{className:"aqmx-sr-only",children:t.documentLoading})]})},vt=Object.freeze(["wheel","touchstart","pointerdown","keydown"]),bo=({path:e,document:t,viewer:n,editing:r})=>{const{reportMathDiagnostics:o,edits:s}=P(),a=i.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),u=so(),g=lo(),m=i.useMemo(()=>o===void 0?void 0:p=>o(e,p),[o,e]),f=i.useRef(null),{editable:v,doubleClick:h,region:S,paneScroll:A,stale:y}=r;i.useLayoutEffect(()=>{if(v)return s.bindView(e,{anchor:()=>{const p=f.current,x=S(),k=p===null?null:p.querySelector(Re);return p===null||x===null||k===null?null:Yn(p,A.scrollerOf(x,k))}})},[s,e,v,S,A]);const C=p=>{const x=f.current,{target:k}=p;!h||x===null||!(k instanceof Element)||!Wn(k)||(p.stopPropagation(),s.start(e,Xn(k,x,x.ownerDocument.getSelection())))},R=i.useRef(null),M=i.useRef(y);i.useLayoutEffect(()=>{M.current=y});const c=i.useEffectEvent(p=>{const x=f.current,k=S(),j=x===null?null:Zt(x,p.line);if(k===null||j===null)return!1;const T=A.scrollerOf(k,j);return T.scrollTop+=Vt(j,p.line)-p.clientTop,!0}),d=i.useEffectEvent(p=>{const x=S();if(x===null)return;const k=()=>{for(const T of vt)x.removeEventListener(T,j,!0);R.current?.release===k&&(R.current=null)},j=()=>k();for(const T of vt)x.addEventListener(T,j,{capture:!0,passive:!0});R.current={point:p,release:k}});return i.useLayoutEffect(()=>{const p=s.takeReturn(e);if(p!==null)return queueMicrotask(()=>{c(p)&&M.current&&d(p)}),()=>R.current?.release()},[s,e]),i.useLayoutEffect(()=>{const p=R.current;p===null||y||(p.release(),c(p.point))},[t,y]),l.jsx("div",{ref:f,className:"aqmx-document-viewer",onDoubleClick:C,children:l.jsx(de.MarkdownViewer,{...n,onHeadingSelect:u,headingHref:g,onMathDiagnostics:m,parseResult:a,content:null})})},dn=({document:e,viewer:t})=>{const{labels:n}=P();return l.jsxs(l.Fragment,{children:[l.jsx(ke,{name:e.name,openUrl:N.explorerPlainTextHref(e.url),downloadUrl:e.url,icon:l.jsx(Bn,{}),children:e.truncated?null:l.jsx(hr,{text:e.text})}),e.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-text-truncated",children:n.textTruncated}):null,l.jsx("div",{className:"aqmx-document-viewer",children:l.jsx(de.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},yo=({path:e,name:t,viewer:n})=>{const{data:r,documents:o,announcer:s,labels:a}=P(),u=i.useCallback(()=>o.answerStampOf(e),[o,e]),g=i.useSyncExternalStore(o.subscribe,u,u),[m,f]=i.useState(0),v=i.useMemo(()=>({path:e,stamp:g,attempt:m}),[e,g,m]),[h,S]=i.useState(null),A=i.useEffectEvent(C=>{S(C),C.kind==="failure"&&s.announce(a.documentFailed(t,te(a,C.failure.reason)))});i.useEffect(()=>{const C=new AbortController;return r.text(v.path,C.signal).then(R=>{"kind"in R&&A(R)}),()=>C.abort()},[r,v]);const y=i.useCallback(()=>f(C=>C+1),[]);return h===null?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-markup-skeleton",children:Ye.map(C=>l.jsx("span",{},C))}),l.jsx("p",{className:"aqmx-sr-only",children:a.markupLoading})]}):h.kind==="failure"?l.jsx(pe,{scrollerProps:un,children:l.jsx(le,{failure:h.failure,alert:!1,onRetry:y,testId:"markdown-explorer-markup-failure"})}):l.jsx(dn,{document:h,viewer:n})},un=Object.freeze({className:"aqmx-document-failure","data-aqmx-document-scroller":""}),So=Object.freeze({reason:"failed"}),ko=e=>l.jsx(Hn,{fallback:t=>l.jsx("div",{className:"aqmx-edit-message",children:l.jsx(le,{failure:So,alert:!1,onRetry:t,testId:"markdown-explorer-edit-load-failure"})}),children:l.jsx(i.Suspense,{fallback:l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-edit-skeleton",children:Ye.map(t=>l.jsx("span",{},t))}),children:l.jsx(Un,{...e})})}),Ro=({path:e,document:t,view:n,viewer:r,onRetry:o,editing:s})=>{switch(t.kind){case"markdown":{const{session:a,layout:u,region:g,paneScroll:m,stale:f}=s;if(n==="edit"&&a!==void 0)return l.jsx(ko,{path:e,name:t.name,session:a,layout:u,viewer:r,region:g,paneScroll:m});if(n==="markup")return l.jsx(yo,{path:e,name:t.name,viewer:r});const v=t.edit!==null&&t.edit.kind==="inline";return l.jsx(bo,{path:e,document:t,viewer:r,editing:{editable:v,doubleClick:v&&u==="fill",region:g,paneScroll:m,stale:f}})}case"text":return l.jsx(dn,{document:t,viewer:r});case"image":return l.jsx(Kr,{document:t});case"media":return l.jsx(vo,{document:t});case"file":return l.jsx(Sr,{document:t});case"failure":return l.jsx(pe,{scrollerProps:un,children:l.jsx(le,{failure:t.failure,alert:!1,onRetry:o,testId:"markdown-explorer-document-failure"})});default:{const a=t;throw new RangeError(`[markdown-explorer] unknown document kind in ${JSON.stringify(a)}`)}}},To='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',Co=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:nn(e,n),r===void 0?null:tn(e,r.id),e.querySelector(Re),e.querySelector(To)];for(const s of o)if(s instanceof HTMLElement&&We(s))return s;return null},wt=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&We(t)},Oo=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 u=h=>{s=!(h.target instanceof Node&&n.contains(h.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(a),a=setTimeout(()=>{s=!1},0)},g=h=>{t.current=h.target instanceof Node&&n.contains(h.target)},m=h=>{h.relatedTarget===null&&s&&(t.current=!1)},f=()=>{const{activeElement:h,body:S}=r;h!==null&&h!==S&&(t.current=n.contains(h))},v=()=>{s&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",u,!0),o.addEventListener("mousedown",u,!0),o.addEventListener("focusin",g,!0),o.addEventListener("blur",f),o.addEventListener("focus",v),n.addEventListener("focusout",m),()=>{clearTimeout(a),o.removeEventListener("pointerdown",u,!0),o.removeEventListener("mousedown",u,!0),o.removeEventListener("focusin",g,!0),o.removeEventListener("blur",f),o.removeEventListener("focus",v),n.removeEventListener("focusout",m)}},[e]),t},Ao=({path:e,snapshot:t,markup:n,stale:r,viewer:o,editLayout:s,regionLabel:a,navigation:u,fragment:g,paneScroll:m,announces:f,announceFailure:v,onDocumentShown:h})=>{const{labels:S,announcer:A,documents:y}=P(),{document:C}=t,R=i.useRef(null),M=i.useRef(null),c=i.useRef(null),d=i.useRef(0),p=Oo(R),x=i.useRef({path:e,document:C}),k=i.useRef(null),j=i.useCallback(U=>{const Z=R.current,W=ft(Z,U,m);Z!==null&&W!==null&&wt(Z,W,p.current)},[m,p]),T=i.useCallback((U,Z)=>{const W=d.current;setTimeout(()=>{!Z.defaultPrevented&&d.current===W&&j(U)},0)},[j]),D=i.useCallback(U=>{setTimeout(()=>{U.defaultPrevented||j("#")},0)},[j]),F=i.useMemo(()=>({navigation:u,currentPath:e,scrollWithin:j,followSameUrlJump:T,followEmptyFragment:D}),[u,e,j,T,D]),V=i.useCallback(()=>y.retry(e),[y,e]),K=Kt(y,Qr),X=qt(e),G=X!==void 0?"edit":n?"markup":"rendered",_=C.kind==="markdown"?G:void 0,z=i.useCallback(()=>R.current,[]),w=i.useMemo(()=>({session:X,layout:s,region:z,paneScroll:m,stale:r}),[X,s,z,m,r]),b=_==="edit"?!1:r,O=i.use(ie),L=_==="edit"&&s==="fill"?"fill":O,$=i.useEffectEvent((U,Z)=>{const W=M.current;if(W!==null&&W.path===U&&W.snapshot===Z)return;M.current={path:U,snapshot:Z};const Q=Z.document;if(Q.kind==="failure"){y.noteFailureShown(Z)&&v(S.documentFailed(N.lastPathSegment(U),te(S,Q.failure.reason)));return}h?.(U,Q),f&&(W===null||W.path!==U||W.snapshot.document.kind==="failure")&&A.announce(S.documentShown(Q.name))});i.useEffect(()=>{$(e,t)},[e,t]);const q=i.useEffectEvent(()=>{g.kind==="panel"&&g.consume()}),H=i.useEffectEvent(U=>{const Z=R.current;if(Z===null||!p.current)return null;const{activeElement:W,body:Q}=Z.ownerDocument;return W!==null&&W!==Q?null:Co(Z,C,U)}),B=i.useEffectEvent(U=>{const Z=R.current;Z!==null&&wt(Z,U,p.current)}),ee=i.useEffectEvent(U=>m.reveal(U)),et=i.useEffectEvent(U=>ft(R.current,U,m));return i.useEffect(()=>{if(r)return;const U=x.current.path!==e,Z=U||x.current.document!==C;x.current={path:e,document:C};const W=k.current!==e;k.current=e;let Q=null;g.kind==="page"?c.current!==g.navigation&&(c.current=g.navigation,d.current+=1,Q=g.fragment):g.fragment!==null&&(Q=g.fragment,q());const tt=()=>{const Le=Q===null?null:et(Q);if(!Z){Le!==null&&B(Le);return}const nt=H(g.fragment);U&&Le===null&&nt!==null&&ee(nt)};W?queueMicrotask(tt):tt()},[g,e,C,r]),l.jsx(ie,{value:L,children:l.jsx(Qe,{kind:C.kind,view:_,label:a(e,C),stale:b,busy:b,frameRef:R,intent:K,children:l.jsx(on,{value:F,children:l.jsx(Xr,{children:l.jsx(Ro,{path:e,document:C,view:G,viewer:o,onRetry:V,editing:w},e)})})})})},Je=Object.freeze({kind:"skeleton"}),Lo=(e,t,n,r,o)=>{if(t?.status==="loaded")return{kind:"document",path:e,snapshot:t,stale:!1};const s=oe(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:oe(r);return n===null||a===null?Je:{kind:"document",path:n,snapshot:a,stale:!0}},jo=(e,t)=>t.status==="deferred"?Je:{kind:"document",path:e,snapshot:t,stale:!1},Mo=({requestedPath:e,content:t,markup:n,...r})=>{const o=t.kind==="streaming"?jo(t.path,i.use(t.promise)):t;return o.kind!=="document"?l.jsx(cn,{label:r.regionLabel(e,null)}):l.jsx(Ao,{path:o.path,snapshot:o.snapshot,markup:n,stale:o.stale,...r})},fn=({path:e,markup:t,display:n,navigation:r,fragment:o,paneScroll:s,announces:a,announceFailure:u,onDocumentShown:g})=>{const{config:m,labels:f,theme:v,documents:h}=P(),S=de.useMarkdownToolbarState(),A=i.useRef(!1);i.useLayoutEffect(()=>{A.current=!0},[]);const[y,C]=i.useState(null),[R,M]=i.useState(t),c=i.useCallback(()=>e===null?void 0:h.peek(e),[h,e]),d=i.useSyncExternalStore(h.subscribe,c,c),p=i.useCallback(()=>y===null?void 0:h.peek(y),[h,y]),x=i.useSyncExternalStore(h.subscribe,p,p);i.useLayoutEffect(()=>e===null?void 0:h.open(e),[h,e]),i.useLayoutEffect(()=>y===null?void 0:h.retain(y),[h,y]);const k=e===null?Je:Lo(e,d,y,x,!A.current),j=e===null?null:k.kind==="document"&&!k.stale?k.path:y;j!==y&&C(j);const T=k.kind!=="document"||k.path===e;T&&t!==R&&M(t);const D=i.useMemo(()=>wo(f),[f]),F=i.useMemo(()=>[...m.iframeHosts],[m]),V=r.kind==="panel",K=i.useMemo(()=>({labels:D,emptyMessage:f.documentEmpty,theme:v,availableStyles:m.documentStyles,iFrameAllowedDomains:F,embeds:m.embeds,linkComponent:oo,toolbar:S,style:n.style,onStyleChange:n.onStyleChange,align:n.align,onAlignChange:n.onAlignChange,showToc:n.showToc,showStyle:n.showStyle,showAlign:n.showAlign,padding:n.padding,width:n.width===void 0?void 0:`min(${n.width}, 100%)`,maxWidth:n.maxWidth===void 0?void 0:`min(${n.maxWidth}, 100%)`,renderScrollBar:V?void 0:Xt}),[D,f.documentEmpty,v,m.documentStyles,F,m.embeds,S,n,V]),X=i.useCallback((_,z)=>V?z===null||z.kind==="failure"?N.lastPathSegment(_):z.name:f.documentRegion,[V,f.documentRegion]),G=V?"content":"fill";return e===null?l.jsx(ie,{value:G,children:l.jsx(Eo,{})}):l.jsx(ie,{value:G,children:l.jsx(i.Suspense,{fallback:l.jsx(cn,{label:X(e,null)}),children:l.jsx(Mo,{requestedPath:e,content:k,markup:T?t:R,viewer:K,editLayout:n.editLayout,regionLabel:X,navigation:r,fragment:o,paneScroll:s,announces:a,announceFailure:u,onDocumentShown:g})})})},No=({path:e,markup:t,variant:n,onDocumentShown:r})=>{const{config:o,viewSettings:s,announcer:a}=P(),u=ue(j=>j.style),g=ue(j=>j.align),m=he(),f=Y.useLocation(),v=Se(),{view:h,overrides:S,embed:A}=n,y=i.useCallback(j=>{if(v.kind!=="location")return;const T=xo(o,v.location,j);T!==null&&m(T,"browse")},[o,m,v]),C=i.useCallback(j=>{s.update({style:j}),y("style")},[s,y]),R=i.useCallback(j=>{s.update({align:j}),y("align")},[s,y]),M=ln(o,S.style,u),c=an(S.align,g),d=i.useMemo(()=>({style:M,onStyleChange:C,align:c,onAlignChange:R,showToc:A.showToc!==!1,showStyle:A.showStyle!==!1,showAlign:A.showAlign!==!1,padding:A.padding,width:A.width,maxWidth:A.maxWidth,editLayout:"fill"}),[M,C,c,R,A]),p=i.useMemo(()=>({kind:"page",view:h,overrides:S,embed:A}),[h,S,A]),x=i.useMemo(()=>({kind:"page",fragment:f.hash,navigation:f}),[f]),k=i.useCallback(j=>a.announce(j),[a]);return l.jsx(fn,{path:e,markup:t,display:d,navigation:p,fragment:x,paneScroll:Lr,announces:!0,announceFailure:k,onDocumentShown:r})},Do=({path:e,markup:t,variant:n,onDocumentShown:r})=>{const{config:o,viewSettings:s}=P(),a=ue(p=>p.style),u=ue(p=>p.align),[g,m]=i.useState(()=>ln(o,void 0,a)),f=an(void 0,u),v=i.useCallback(p=>s.update({align:p}),[s]),{maximized:h,onDocumentLink:S,pendingHash:A,onHashConsumed:y,announceFailure:C,paneScroll:R}=n,M=i.useMemo(()=>({style:g,onStyleChange:m,align:f,onAlignChange:v,showToc:h,showStyle:h,showAlign:h,padding:void 0,width:void 0,maxWidth:void 0,editLayout:h?"fill":"content"}),[g,f,v,h]),c=i.useMemo(()=>({kind:"panel",onDocumentLink:S}),[S]),d=i.useMemo(()=>({kind:"panel",fragment:A,consume:y}),[A,y]);return l.jsx(fn,{path:e,markup:t,display:M,navigation:c,fragment:d,paneScroll:R,announces:!1,announceFailure:C,onDocumentShown:r})},mn=({path:e,markup:t,variant:n,onDocumentShown:r})=>n.kind==="page"?l.jsx(No,{path:e,markup:t,variant:n,onDocumentShown:r}):l.jsx(Do,{path:e,markup:t,variant:n,onDocumentShown:r});function Po({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 hn=E.forwardRef(Po);function _o({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M14.447 3.026a.75.75 0 0 1 .527.921l-4.5 16.5a.75.75 0 0 1-1.448-.394l4.5-16.5a.75.75 0 0 1 .921-.527ZM16.72 6.22a.75.75 0 0 1 1.06 0l5.25 5.25a.75.75 0 0 1 0 1.06l-5.25 5.25a.75.75 0 1 1-1.06-1.06L21.44 12l-4.72-4.72a.75.75 0 0 1 0-1.06Zm-9.44 0a.75.75 0 0 1 0 1.06L2.56 12l4.72 4.72a.75.75 0 0 1-1.06 1.06L.97 12.53a.75.75 0 0 1 0-1.06l5.25-5.25a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const Fo=E.forwardRef(_o);function $o({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M15.75 2.25H21a.75.75 0 0 1 .75.75v5.25a.75.75 0 0 1-1.5 0V4.81L8.03 17.03a.75.75 0 0 1-1.06-1.06L19.19 3.75h-3.44a.75.75 0 0 1 0-1.5Zm-10.5 4.5a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h10.5a1.5 1.5 0 0 0 1.5-1.5V10.5a.75.75 0 0 1 1.5 0v8.25a3 3 0 0 1-3 3H5.25a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h8.25a.75.75 0 0 1 0 1.5H5.25Z",clipRule:"evenodd"}))}const qo=E.forwardRef($o);function Io({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M11.47 13.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 0 0-1.06-1.06L12 11.69 5.03 4.72a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",clipRule:"evenodd"}),E.createElement("path",{fillRule:"evenodd",d:"M11.47 19.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 1 0-1.06-1.06L12 17.69l-6.97-6.97a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",clipRule:"evenodd"}))}const Bo=E.forwardRef(Io);function Uo({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25ZM12.75 6a.75.75 0 0 0-1.5 0v6c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-3.75V6Z",clipRule:"evenodd"}))}const Ho=E.forwardRef(Uo);function zo({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M9 1.5H5.625c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5Zm6.61 10.936a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 14.47a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",clipRule:"evenodd"}),E.createElement("path",{d:"M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"}))}const Zo=E.forwardRef(zo);function Vo({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),E.createElement("path",{fillRule:"evenodd",d:"M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 0 1 0-1.113ZM17.25 12a5.25 5.25 0 1 1-10.5 0 5.25 5.25 0 0 1 10.5 0Z",clipRule:"evenodd"}))}const pn=E.forwardRef(Vo);function Go({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{d:"M21.731 2.269a2.625 2.625 0 0 0-3.712 0l-1.157 1.157 3.712 3.712 1.157-1.157a2.625 2.625 0 0 0 0-3.712ZM19.513 8.199l-3.712-3.712-8.4 8.4a5.25 5.25 0 0 0-1.32 2.214l-.8 2.685a.75.75 0 0 0 .933.933l2.685-.8a5.25 5.25 0 0 0 2.214-1.32l8.4-8.4Z"}),E.createElement("path",{d:"M5.25 5.25a3 3 0 0 0-3 3v10.5a3 3 0 0 0 3 3h10.5a3 3 0 0 0 3-3V13.5a.75.75 0 0 0-1.5 0v5.25a1.5 1.5 0 0 1-1.5 1.5H5.25a1.5 1.5 0 0 1-1.5-1.5V8.25a1.5 1.5 0 0 1 1.5-1.5h5.25a.75.75 0 0 0 0-1.5H5.25Z"}))}const Ko=E.forwardRef(Go),gn=({href:e,onRetry:t,testId:n})=>{const{labels:r,onEditGrant:o}=P(),[s,a]=i.useState(!1),u=()=>{o===void 0||s||(a(!0),o(e).then(g=>{g&&t()}).finally(()=>a(!1)))};return l.jsxs("div",{className:"aqmx-callout aqmx-edit-grant","data-testid":n,children:[l.jsx("p",{className:"aqmx-callout-title",children:r.editGrantTitle}),l.jsx("p",{className:"aqmx-callout-body",children:r.editGrantBody}),l.jsxs("div",{className:"aqmx-edit-grant-actions",children:[o===void 0?l.jsx("a",{className:"aqmx-callout-action",href:e,target:"_blank",rel:"noopener","data-testid":`${n}-open`,children:r.editGrantAction}):l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":s,"data-testid":`${n}-open`,onClick:u,children:r.editGrantAction}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":`${n}-retry`,onClick:t,children:r.editGrantRetry})]})]})},xt=(e,t,n)=>{const r=e.modifiedAt===null?Number.NaN:Date.parse(e.modifiedAt);return n(Number.isNaN(r)?e.id:t.format(r),e.author===null?"":e.author)},Wo=({path:e,documentName:t,open:n,onClose:r})=>{const{data:o,edits:s,labels:a,locale:u,announcer:g}=P(),m=i.useRef(null),f=i.useRef(null),v=i.useId(),[h,S]=i.useState(null),[A,y]=i.useState(0),[C,R]=i.useState(null),[M,c]=i.useState(null),d=i.useMemo(()=>new Intl.DateTimeFormat(u,{dateStyle:"medium",timeStyle:"short"}),[u]);i.useLayoutEffect(()=>{const T=m.current;if(T!==null)if(n&&!T.open){const D=T.ownerDocument.activeElement;f.current=D instanceof HTMLElement?D:null,R(null),c(null),T.showModal()}else!n&&T.open&&(T.close(),f.current?.isConnected===!0&&f.current.focus(),f.current=null)},[n]),i.useEffect(()=>{if(!n)return;const T=new AbortController;return S(null),o.revisions(e,T.signal).then(D=>{"kind"in D&&S(D)}),()=>T.abort()},[n,o,e,A]),i.useEffect(()=>{if(!n||C===null)return;const T=new AbortController;return c(null),o.revision(e,C,T.signal).then(D=>{"kind"in D&&c(D)}),()=>T.abort()},[n,o,e,C]);const p=()=>{M===null||M.kind!=="revision"||(s.replaceDraft(e,M.text),g.announce(a.historyRestored(t)),r())},x=T=>{T.key!=="Escape"||T.defaultPrevented||(Ve(T),r())},k=T=>{T.target===T.currentTarget&&r()},j=h!==null&&h.kind==="revisions"?h.revisions.find(T=>T.id===C):void 0;return l.jsx("dialog",{ref:m,className:"aqmx-confirm aqmx-history","aria-labelledby":v,"data-testid":"markdown-explorer-history",onKeyDown:x,onClick:k,onCancel:T=>T.preventDefault(),children:l.jsxs("div",{className:"aqmx-confirm-panel aqmx-history-panel",children:[l.jsx("p",{id:v,className:"aqmx-confirm-title",children:a.historyTitle(t)}),h===null?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-loading",children:a.historyLoading}):h.kind==="failure"?l.jsx(le,{failure:h.failure,alert:!1,onRetry:()=>y(T=>T+1),testId:"markdown-explorer-history-failure"}):h.revisions.length===0?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-empty",children:a.historyEmpty}):l.jsx("ul",{className:"aqmx-history-list","data-testid":"markdown-explorer-history-list",children:h.revisions.map(T=>l.jsx("li",{children:l.jsxs("button",{type:"button",className:"aqmx-history-entry","aria-pressed":T.id===C,"data-testid":"markdown-explorer-history-entry",onClick:()=>R(T.id),children:[l.jsx("span",{children:xt(T,d,a.historyEntry)}),T.current?l.jsx("span",{className:"aqmx-history-mark",children:a.historyCurrent}):null,T.kept?l.jsx("span",{className:"aqmx-history-mark",children:a.historyKept}):null]})},T.id))}),C===null?null:M===null?l.jsx("p",{className:"aqmx-history-note",children:a.historyLoading}):M.kind==="failure"?l.jsx(le,{failure:M.failure,alert:!1,testId:"markdown-explorer-history-revision-failure"}):l.jsx("section",{className:"aqmx-history-text",tabIndex:0,"aria-label":j===void 0?a.historyTitle(t):xt(j,d,a.historyEntry),"data-testid":"markdown-explorer-history-text",children:l.jsx("pre",{children:M.text})}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":"markdown-explorer-history-close",onClick:r,children:a.historyClose}),l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":M===null||M.kind!=="revision","data-testid":"markdown-explorer-history-restore",onClick:p,children:a.historyRestore})]})]})})},Xo=e=>{const{documents:t}=P(),n=i.useCallback(()=>t.peek(e),[t,e]),r=i.useCallback(()=>t.peekSeeded(e),[t,e]),o=i.useSyncExternalStore(t.subscribe,n,r),s=oe(o)?.document;return s===void 0||s.kind==="failure"?{edit:null,name:N.lastPathSegment(e)}:{edit:s.kind==="markdown"?s.edit:null,name:s.name}},ne=e=>{e.stopPropagation()},Yo=({path:e,documentName:t,iconOnly:n})=>{const{edits:r,labels:o}=P(),s=i.useSyncExternalStore(r.subscribe,()=>r.session(e)!==void 0,()=>!1),[a,u]=i.useState(!1),g=()=>{if(!s){r.start(e,r.viewAnchor(e));return}r.flush(e),r.session(e)?.dirty===!0?u(!0):r.close(e)},m=n?o.editDocumentNamed(t):null;return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:m===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:s?o.closeEditor:m===null?o.editDocument:m,"aria-label":m===null?void 0:m,"aria-pressed":s,"data-testid":"markdown-explorer-document-edit",onClick:g,onDoubleClick:ne,onPointerEnter:lt,onFocus:lt,children:[l.jsx(Ko,{"aria-hidden":"true"}),m===null?l.jsx("span",{children:o.editDocumentLabel}):null]}),l.jsx($t,{open:a,title:o.unsavedTitle,body:o.unsavedBody(t),confirmLabel:o.unsavedDiscard,cancelLabel:o.unsavedStay,testId:"markdown-explorer-edit-close-confirm",onConfirm:()=>{u(!1),r.close(e)},onCancel:()=>u(!1)})]})},Qo=({href:e,documentName:t,iconOnly:n})=>{const{labels:r}=P(),o=n?r.editExternallyNamed(t):null;return l.jsxs("a",{className:o===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",href:e,target:"_blank",rel:"noopener noreferrer",title:o===null?r.editExternally:o,"aria-label":o===null?void 0:o,"data-testid":"markdown-explorer-document-edit-external",onDoubleClick:ne,children:[l.jsx(qo,{"aria-hidden":"true"}),o===null?l.jsx("span",{children:r.editExternallyLabel}):null]})},Jo=({session:e})=>{const{labels:t}=P(),n=Ln(t,e);return l.jsx("p",{className:"aqmx-edit-status",title:n===""?void 0:n,"data-testid":"markdown-explorer-edit-status","data-aqmx-save":e.save.kind,children:n})},es=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{edits:s,labels:a}=P(),u=Bt(),[g,m]=i.useState(!1);if(r.phase.kind!=="editing")return null;const f=r.save.kind==="saving",v=f||!r.dirty,h=()=>{s.flush(e);const A=s.session(e);A===void 0||!A.dirty||A.save.kind==="saving"||s.save(e)},S=A=>n?{className:"aqmx-icon-button","aria-label":A}:{className:"aqmx-icon-button aqmx-labelled-button"};return l.jsxs(l.Fragment,{children:[r.save.kind==="conflicts"?l.jsxs("button",{type:"button",...S(a.conflictNext),title:a.conflictNext,"data-testid":"markdown-explorer-edit-next-conflict",onClick:()=>s.nextConflict(e),onDoubleClick:ne,children:[l.jsx(Bo,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.conflictNext})]}):null,o?l.jsxs("button",{type:"button",...S(a.previewToggle),title:a.previewToggle,"aria-pressed":u,"data-testid":"markdown-explorer-edit-preview-toggle",onClick:()=>s.setPreviewShown(!u),onDoubleClick:ne,children:[l.jsx(pn,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.previewToggle})]}):null,r.history?l.jsxs("button",{type:"button",...S(a.historyOpen),title:a.historyOpen,"aria-haspopup":"dialog","data-testid":"markdown-explorer-edit-history",onClick:()=>m(!0),onDoubleClick:ne,children:[l.jsx(Ho,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.historyOpen})]}):null,l.jsxs("button",{type:"button",...S(a.saveDraft),title:a.saveDraftTooltip,"aria-disabled":v,"aria-busy":f,"aria-keyshortcuts":"Control+S Meta+S","data-testid":"markdown-explorer-edit-save",onClick:h,onDoubleClick:ne,children:[l.jsx(Zo,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.saveDraft})]}),r.history?l.jsx(Wo,{path:e,documentName:t,open:g,onClose:()=>m(!1)}):null]})},ts=({path:e,session:t})=>{const{edits:n}=P();return t.save.kind!=="grant"?null:l.jsx(gn,{href:t.save.href,onRetry:()=>{n.save(e)},testId:"markdown-explorer-save-grant"})},ns=e=>{const{documents:t}=P(),n=i.useCallback(()=>t.peek(e),[t,e]),r=i.useCallback(()=>t.peekSeeded(e),[t,e]),o=i.useSyncExternalStore(t.subscribe,n,r);return oe(o)?.document.kind==="markdown"},vn=e=>{const{config:t}=P(),n=he(),r=i.useCallback(()=>n(I.explorerHref(t,{...e,markup:!e.markup}),"browse"),[t,n,e]);return i.useMemo(()=>({shown:e.markup,toggle:r}),[e.markup,r])},rs=new Set,os=(e,t)=>{const{documents:n,announcer:r,labels:o}=P(),s=i.useCallback(()=>n.peek(e),[n,e]),a=i.useCallback(()=>n.peekSeeded(e),[n,e]),u=i.useSyncExternalStore(n.subscribe,s,a),g=i.useCallback(()=>n.answerStampOf(e),[n,e]),m=i.useSyncExternalStore(n.subscribe,g,g),[f]=i.useState(()=>new Set),[v,h]=i.useState(rs),[S,A]=i.useState(null);S!==null&&S.path!==e&&A(null);const y=i.useRef(null);i.useLayoutEffect(()=>(y.current=e,()=>{y.current=null}),[e]);const C=i.useCallback(()=>{const c=e,d=n.peek(c);if(f.has(c)||d?.status==="pending")return;const p=t&&!Jt(d);f.add(c),h(new Set(f)),A(null),(async()=>{try{const x=await n.refresh(c);if(y.current!==c||x.status==="superseded")return;if(x.status==="failed"){A({path:c,failure:x.failure,stamp:n.answerStampOf(c)}),r.announce(o.documentRefreshFailed(te(o,x.failure.reason)));return}const k=oe(n.peek(c));if(p||k===null||k.document.kind==="failure")return;r.announce(o.documentRefreshed(k.document.name))}finally{f.delete(c),h(new Set(f))}})()},[e,t,f,n,r,o]),R=v.has(e),M=S!==null&&S.path===e&&S.stamp===m?S.failure:null;return{refreshing:R,unavailable:R||u?.status==="pending",failure:M,refresh:C}},wn=Object.freeze({kind:"page"}),xn=({path:e,placement:t,markup:n})=>{const{labels:r}=P(),{refreshing:o,unavailable:s,failure:a,refresh:u}=os(e,t.kind==="page"),g=ns(e),m=Xo(e),f=qt(e),v=t.kind==="panel"?r.refreshDocumentNamed(t.documentName):null,h=t.kind==="panel"?r.showMarkupNamed(t.documentName):null,S=t.kind==="panel",A=t.kind==="panel"?t.documentName:m.name,y=t.kind==="page"||t.maximized;return l.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar","data-aqmx-editing":f===void 0?void 0:"true",children:[l.jsxs("div",{className:"aqmx-document-refresh-row",children:[f===void 0?null:l.jsx(Jo,{session:f}),f===void 0?null:l.jsx(es,{path:e,documentName:A,iconOnly:S,session:f,previewAvailable:y}),f===void 0&&g?l.jsxs("button",{type:"button",className:h===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:h===null?r.showMarkup:h,"aria-label":h===null?void 0:h,"aria-pressed":n.shown,"data-testid":"markdown-explorer-document-markup",onClick:n.toggle,onDoubleClick:ne,children:[l.jsx(Fo,{"aria-hidden":"true"}),h===null?l.jsx("span",{children:r.showMarkupLabel}):null]}):null,f!==void 0||m.edit?.kind==="inline"?l.jsx(Yo,{path:e,documentName:A,iconOnly:S}):m.edit?.kind==="external"?l.jsx(Qo,{href:m.edit.href,documentName:A,iconOnly:S}):null,f===void 0?l.jsxs("button",{type:"button",className:v===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:v===null?r.refreshDocument:v,"aria-label":v===null?void 0:v,"aria-disabled":s,"aria-busy":o,"data-aqmx-busy":o?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:u,onDoubleClick:ne,children:[l.jsx(hn,{"aria-hidden":"true"}),v===null?l.jsx("span",{children:r.refreshDocumentLabel}):null]}):null]}),f!==void 0||a===null?null:l.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":a.reason,children:r.documentRefreshFailed(te(r,a.reason))}),f===void 0?null:l.jsx(ts,{path:e,session:f})]})},ss=({location:e})=>{const t=e.doc,n=i.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),r=vn(e);return l.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",children:[l.jsx(xn,{path:t,placement:wn,markup:r}),l.jsx(mn,{path:t,markup:e.markup,variant:n})]})},En=({holds:e,testId:t})=>{const{labels:n,announcer:r}=P(),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 l.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]})},se=Object.freeze([]),ls=e=>{const t=new Set;let n=se,r=[],o=!1;const s=[],a=f=>{n=f;for(const v of[...t])v()},u=()=>s.at(-1)?.region,g=f=>{const v=u();f(),u()!==v&&n!==se&&a(se)},m=()=>{o=!1;const f=r.map(v=>"sentence"in v?v.sentence:v.list(v.items));r=[],a(Object.freeze(f))};return{announce:f=>{if(typeof f=="string")r.push({sentence:f});else{const v=r.find(h=>"list"in h&&h.list===f.list);v!==void 0&&"items"in v?v.items.push(f.item):r.push({list:f.list,items:[f.item]})}o||(o=!0,n!==se&&a(se),e.request(m))},subscribe:f=>(t.add(f),()=>{t.delete(f)}),claim:f=>{const v={region:f};return g(()=>s.push(v)),()=>g(()=>{const h=s.indexOf(v);h!==-1&&s.splice(h,1)})},shownIn:f=>u()===f?n:se}},ce=Object.freeze({status:"cancelled"}),is=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(N.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return N.failureOf(n,r)},as=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((m,f)=>globalThis.fetch(m,f)),o=(m,f)=>`${e}/${m}?${new URLSearchParams(f).toString()}`,s=async(m,f,v,h)=>{let S;try{S=await r(m,{credentials:"same-origin",...f,headers:{Accept:"application/json",...f.headers}})}catch{return h({reason:"failed"})}S.status===401&&t(null);const A=S.headers.get(N.EXPLORER_SCOPE_HEADER);A!==null&&t(A);let y;try{y=await S.json()}catch{return h({reason:N.failureReasonOfStatus(S.status)})}let C;try{C=v(y)}catch{C=!1}if(C)return y;const R=is(y);return h(R!==null?R:{reason:S.status===200?"failed":N.failureReasonOfStatus(S.status)})},a={[N.EXPLORER_PROOF_HEADER]:N.EXPLORER_REFRESH_PROOF},u={[N.EXPLORER_PROOF_HEADER]:N.EXPLORER_EDIT_PROOF,"Content-Type":`${N.EXPLORER_DRAFT_MEDIA_TYPE}; charset=utf-8`},g=async(m,f,v)=>{const h=await s(m,f,v,S=>N.failureDocument(S.reason,S.code));return f.signal.aborted?ce:h};return{tree:m=>s(o("tree",{[N.EXPLORER_DATA_QUERY.source]:m}),{method:"GET"},N.isExplorerTreeResult,f=>({status:"error",failure:f})),children:async(m,f,v)=>{const h=await s(o("children",{[N.EXPLORER_DATA_QUERY.source]:m,[N.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:v},N.isExplorerChildrenResult,S=>({status:"error",failure:S}));return v.aborted?ce:h},ancestors:async(m,f,v)=>{const h=await s(o("ancestors",{[N.EXPLORER_DATA_QUERY.source]:m,[N.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:v},N.isExplorerAncestorsResult,S=>({status:"error",failure:S}));return v.aborted?ce:h},reveal:async(m,f,v)=>{const h=await s(o("reveal",{[N.EXPLORER_DATA_QUERY.source]:m,[N.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:v},N.isExplorerRevealResult,S=>({status:"error",failure:S}));return v.aborted?ce:h},document:(m,{refresh:f})=>s(o("document",{[N.EXPLORER_DATA_QUERY.path]:m}),f?{method:"GET",headers:a}:{method:"GET"},N.isExplorerDocument,v=>N.failureDocument(v.reason,v.code)),text:async(m,f)=>{const v=await s(o("text",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:f},N.isExplorerTextAnswer,h=>N.failureDocument(h.reason,h.code));return f.aborted?ce:v},edit:(m,f)=>g(o("edit",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:f},N.isExplorerEditAnswer),save:(m,f,v,h)=>g(o("save",{[N.EXPLORER_DATA_QUERY.path]:m,[N.EXPLORER_DATA_QUERY.base]:f}),{method:"POST",headers:u,body:v,signal:h},N.isExplorerSaveAnswer),preview:(m,f,v)=>g(o("preview",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"POST",headers:u,body:f,signal:v},N.isExplorerPreviewAnswer),revisions:(m,f)=>g(o("revisions",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:f},N.isExplorerRevisionsAnswer),revision:(m,f,v)=>g(o("revision",{[N.EXPLORER_DATA_QUERY.path]:m,[N.EXPLORER_DATA_QUERY.revision]:f}),{method:"GET",signal:v},N.isExplorerRevisionAnswer),refresh:m=>s(o("refresh",{[N.EXPLORER_DATA_QUERY.source]:m}),{method:"POST",headers:a},N.isExplorerTreeResult,f=>({status:"error",failure:f}))}},cs=()=>{let e=null,t=null;return{settle:n=>{e=n},mayMove:n=>e!==n,move:(n,r,o)=>{e=r,t={sourceId:n,path:r,ancestors:o}},take:(n,r)=>{const o=t!==null&&t.sourceId===n&&t.path===r?t.ancestors:null;return t=null,o}}},ds=e=>{const t=J.readStorage(e);if(t===null)return I.NO_TREE_SETTING_CHANGES;try{return I.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),I.NO_TREE_SETTING_CHANGES}},Et=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=ds(e);n={changes:s,settings:I.applyTreeSettingChanges(t,s)}}return n},o=ae();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:a,settings:u}=r(),g=I.recordTreeSettingChange(a,s,I.advanceTreeSetting(u,s)[s],t);return n={changes:g,settings:I.applyTreeSettingChanges(t,g)},o.emit(),J.writeStorage(e,I.serializeTreeSettingChanges(g)),n.settings}}},us=Object.freeze({status:"refreshed"}),fs=Object.freeze({status:"superseded"}),ze=Object.freeze({status:"deferred"}),ms=Qt(ze),bn=4,hs=bn-1,bt=Object.freeze({status:"loading"}),ps=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),gs=e=>{const t=new Map,n=Yt(),r=new Map,o=new Map,s=new Map,a=new Map,u=ae(),g=new Set;let m=0,f=0;const v={direct:null,bulk:null},h=new Set;let S=!1,A=0;const y=()=>{A+=1,u.emit()},C=w=>o.get(w)??0,R=w=>{let b=a.get(w);return b===void 0&&(b={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},a.set(w,b)),b},M=(w,b,O)=>{w.inFlight.delete(b),m-=1,O.lane==="bulk"&&(f-=1)},c=w=>{const b=a.get(w);if(b!==void 0){for(const[O,L]of[...b.inFlight])M(b,O,L),L.controller.abort();b.direct.clear(),b.bulk.clear(),b.unclaimed.clear()}},d=w=>{const b=C(w)+1;return o.set(w,b),c(w),b},p=(w,b)=>{const O=ge(w),L={promise:w,opened:b,stale:!1,loadedAt:O?.status==="ok"?O.loadedAt:null};return w.status==="pending"&&w.then($=>{$.status==="ok"&&(L.loadedAt=$.loadedAt)}),L},x=w=>{let b=r.get(w);return b===void 0&&(b=new Map,r.set(w,b)),b},k=w=>{const b=[...a.keys()],O=v[w],L=O===null?0:b.indexOf(O)+1;for(let $=0;$<b.length;$+=1){const q=b[(L+$)%b.length],H=q===void 0?void 0:a.get(q);if(!(q===void 0||H===void 0)){for(const B of H[w])if((H.claims.get(B)??0)!==0)return H[w].delete(B),v[w]=q,{sourceId:q,path:B}}}return null},j=(w,b,O,L)=>{const $=a.get(w);if($===void 0||$.inFlight.get(b)!==O)return;M($,b,O);const q=($.claims.get(b)??0)>0,H=x(w);if(L.status==="ok"?H.set(b,{status:"loaded",entries:L.entries}):L.status==="error"&&q?H.set(b,{status:"failed",failure:L.failure}):H.delete(b),y(),L.status==="error"&&q){const B={sourceId:w,path:b,failure:L.failure};for(const ee of[...g])ee(B)}D()},T=(w,b,O)=>{const L={controller:new AbortController,lane:O};R(w).inFlight.set(b,L),m+=1,O==="bulk"&&(f+=1),e.children(w,b,L.controller.signal).then($=>j(w,b,L,$),()=>j(w,b,L,ps))},D=()=>{for(;m<bn;){const w=k("direct");if(w!==null){T(w.sourceId,w.path,"direct");continue}const b=f<hs?k("bulk"):null;if(b===null)return;T(b.sourceId,b.path,"bulk")}},F=(w,b,O)=>{if(!(b.direct.delete(O)||b.bulk.delete(O))){const $=b.inFlight.get(O);if($===void 0)return!1;M(b,O,$),$.controller.abort()}return r.get(w)?.delete(O),!0},V=()=>{S=!1;let w=!1;for(const b of h){const O=R(b);for(const L of O.unclaimed)(O.claims.get(L)??0)===0&&F(b,O,L)&&(w=!0);O.unclaimed.clear()}h.clear(),w&&(y(),D())},K=(w,b)=>{t.set(w,p(me(e.tree(w)),b))},X=(w,b,O)=>{d(w);const L=p(Qt(b),O);return t.set(w,L),r.delete(w),y(),D(),L},G=(w,b,O,L)=>{if(O!==C(w)||t.get(w)!==b)return;const $=ge(b.promise);if(!(L.status!=="ok"||$?.status!=="ok"||b.loadedAt===null||L.loadedAt<=b.loadedAt)){if(be($.entries,L.entries)){b.loadedAt=L.loadedAt;return}X(w,L,b.opened)}},_=(w,b)=>{const O=t.get(w);return O!==void 0&&ge(O.promise)?.status===b},z=(w,b)=>{b.stale=!1;const O=C(w);e.tree(w).then(L=>G(w,b,O,L))};return{read:w=>t.get(w)?.promise??ms,open:w=>{const b=n.resumes(w),O=n.hold(w),L=t.get(w);return L===void 0||_(w,"deferred")?(K(w,!0),y()):b||(L.opened&&_(w,"error")?(K(w,!0),y()):(L.opened=!0,L.stale&&_(w,"ok")&&z(w,L))),O},retry:w=>{_(w,"error")&&(K(w,!0),y())},seed:(w,b)=>{const O=b.then(q=>q===null?ze:q,()=>ze),L=t.get(w);if(L!==void 0&&_(w,"ok")){const q=C(w);O.then(H=>G(w,L,q,H));return}d(w);const $=p(me(O),L?.opened===!0);t.set(w,$),r.delete(w),D(),O.then(q=>{t.get(w)===$&&(q.status==="deferred"&&n.isHeld(w)&&K(w,$.opened),y())})},refresh:async w=>{const b=(s.get(w)??0)+1;s.set(w,b);const O=await e.refresh(w);if(s.get(w)!==b)return fs;if(O.status==="error")return{status:"failed",failure:O.failure};const L=t.get(w);if(!(L!==void 0&&L.loadedAt!==null&&_(w,"ok")&&L.loadedAt>O.loadedAt)){const q=X(w,O,!0);if(L!==void 0&&L.promise.status==="pending"){const H=C(w);L.promise.then(B=>G(w,q,H,B))}}for(const[q,H]of t)q!==w&&ge(H.promise)?.status==="ok"&&(H.stale=!0);return us},children:(w,b)=>r.get(w)?.get(b),claimChildren:(w,b)=>{const O=R(w),L=x(w);let $=!1,q=!1;for(const[B,ee]of b)O.claims.set(B,(O.claims.get(B)??0)+1),L.get(B)===void 0?(L.set(B,bt),O[ee].add(B),$=!0,q=!0):ee==="direct"&&O.bulk.delete(B)&&(O.direct.add(B),q=!0);$&&y(),q&&D();let H=!1;return()=>{if(!H){H=!0;for(const B of b.keys()){const ee=(O.claims.get(B)??0)-1;ee>0?O.claims.set(B,ee):(O.claims.delete(B),O.unclaimed.add(B))}h.add(w),!S&&(S=!0,queueMicrotask(V))}}},retryChildren:(w,b)=>{const O=r.get(w);if(O===void 0||O.get(b)?.status!=="failed")return;const L=R(w);if((L.claims.get(b)??0)>0){O.set(b,bt),L.direct.add(b),y(),D();return}O.delete(b),y()},pendingChildren:w=>{const b=a.get(w);return b===void 0?0:b.direct.size+b.bulk.size+b.inFlight.size},clear:()=>{for(const w of new Set([...t.keys(),...r.keys(),...o.keys(),...a.keys()]))d(w);for(const[w,b]of s)s.set(w,b+1);t.clear(),r.clear(),y()},subscribeChildrenFailures:w=>(g.add(w),()=>{g.delete(w)}),subscribe:u.subscribe,version:()=>A}},vs=(e,t)=>{let n=e;const r=ae();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},ws=1;let ve=0,re=null;const xs=()=>{const{documentElement:e,body:t}=document;ve===0&&(re={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"),ve+=1;let n=!1;return()=>{n||(n=!0,ve-=1,!(ve>0||re===null)&&(e.style.overflow=re.htmlOverflow,t.style.overflow=re.bodyOverflow,e.style.scrollbarGutter=re.htmlGutter,t.style.scrollbarGutter=re.bodyGutter,re=null))}},Es=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],yt=1,St=e=>e.getClientRects().length>0,Pe="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.",bs=e=>{if(!St(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+ws)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. ${Pe}`;if(t.height<yt)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. ${Pe}`;for(const{selector:r,name:o}of Es)for(const s of e.querySelectorAll(r)){if(!St(s))continue;const a=s.getBoundingClientRect().height;if(a<yt)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. ${Pe}`}return null},ys=e=>{let t=!1;const n=()=>{if(t)return;const o=bs(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)}},Ss=(e,t)=>{i.useEffect(()=>e?xs():void 0,[e]),i.useEffect(()=>{const n=t.current;if(!(!e||n===null))return ys(n)},[e,t])},kt='[data-testid="markdown-explorer-view-switch"]',ks=[{control:kt,successors:[kt,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],Rs=e=>{for(const t of ks){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},Ts=(e,t)=>{const n=i.useRef(null);i.useEffect(()=>{const o=u=>{const g=e.current;n.current=g!==null&&u instanceof Element&&g.contains(u)?Rs(u):null},s=u=>o(u.target);o(document.activeElement);const a=u=>{const g=u.target;u.relatedTarget!==null||!(g instanceof Element)||queueMicrotask(()=>{n.current?.element===g&&g.isConnected&&document.activeElement!==g&&(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 g=document.activeElement;if(g!==null&&g!==document.body&&g!==o.element)return!0;const m=e.current;if(m===null)return!0;for(const f of o.control.successors)for(const v of m.querySelectorAll(f))if(v!==o.element&&(v.focus({preventScroll:!0}),document.activeElement===v))return!0;return!1};if(s())return;const a=e.current;if(a===null)return;const u=new MutationObserver(()=>{s()&&u.disconnect()});return u.observe(a,{childList:!0,subtree:!0}),()=>u.disconnect()},[t,e])},Cs=i.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-kVWFEKJD.cjs")).then(e=>({default:e.TreeLayout}))),Os=i.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-Bq10p3a3.cjs")).then(e=>({default:e.MultiLayout}))),As=64,Ls={request:e=>{requestAnimationFrame(e)}},Rt=e=>{e.documents.clear(),e.trees.clear()},_e=(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)},js=(e,t)=>{const[n,r]=i.useState(()=>({overrides:t,locale:e,labels:Ie(e,t)}));if(n.locale===e&&On(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:Ie(e,t)};return r(o),o.labels},Ms=(e,t,n)=>{const[r,o]=i.useState(()=>({scope:t,store:Et(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:Et(e,n)};return o(s),s.store},Fe=(e,t)=>{const[n,r]=i.useState(()=>({scope:e,value:t()}));if(n.scope===e)return n.value;const o={scope:e,value:t()};return r(o),o.value},Ns=()=>ls(Ls),Tt="on",Ds="off",Ps=(e,t)=>{const n=oe(e.peek(t));return n===null||n.document.kind==="failure"?N.lastPathSegment(t):n.document.name},_s=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:a,renderTreeFailure:u,lockDocumentScroll:g=!1,onMathDiagnostics:m,onEditGrant:f})=>{J.assertStorageNamespace(n);const v=jt(r),h=An(s),S=js(v,o),{revalidate:A}=Y.useRevalidator(),y=i.useRef(()=>{}),C=Y.useHref(t.dataPath),[R]=i.useState(()=>{const _=as({dataPath:C,onScope:w=>y.current(w)}),z={documents:sr({client:_,capacity:Math.max(As,t.multiView.maxPanels*2)}),trees:gs(_)};return _e(z,e),J.syncStorageScope(n,e.scope),{data:_,...z,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(R.aligned.pageData!==e||R.aligned.storageNamespace!==n){const _=R.aligned.pageData;R.aligned.pageData=e,R.aligned.storageNamespace=n,_!==e&&(_.scope!==e.scope?R.aligned.pendingReader=e:_e(R,e)),J.syncStorageScope(n,e.scope)}const M=Ms(J.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);i.useLayoutEffect(()=>{const _=R.aligned.pendingReader;_!==null&&(R.aligned.pendingReader=null,Rt(R),_e(R,_))},[e,R]),i.useLayoutEffect(()=>{let _=!1;return y.current=z=>{z===e.scope||_||(_=!0,z!==null&&(Rt(R),J.clearExplorerStorage(n)),A())},()=>{y.current=()=>{}}},[e,A,R,n]);const c=i.useRef(t.settingsCookie);i.useLayoutEffect(()=>{c.current=t.settingsCookie},[t.settingsCookie]);const[d]=i.useState(()=>vs(e.settings,_=>{document.cookie=I.viewSettingsCookieString(c.current,_,window.location.protocol==="https:")})),p=Fe(e.scope,Ns),x=Fe(e.scope,cs),k=i.useRef(S);i.useLayoutEffect(()=>{k.current=S},[S]);const j=Fe(e.scope,()=>Dn({data:R.data,conflictLabels:()=>({ours:k.current.conflictOurs,theirs:k.current.conflictTheirs}),onSaveSettled:(_,z)=>{z.kind==="saved"&&R.documents.refresh(_);const w=jn(k.current,z,Ps(R.documents,_));w!==null&&p.announce(w)},previewSetting:{read:()=>J.readStorage(J.storageKeys(n).editPreview)===Tt,write:_=>J.writeStorage(J.storageKeys(n).editPreview,_?Tt:Ds)}})),T=i.useMemo(()=>me(e.notices.catch(()=>[])),[e.notices]),D=e.sources.map(_=>_.id).join(`
9
+ `),Nn=3,Me=Object.freeze({kind:"idle"}),Dn=({data:e,conflictLabels:t,onSaveSettled:n,previewSetting:r})=>{const o=new Map,s=new Map,a=new Map,u=new Map,g=new Map,m=ae();let f=null,v=null;const h=(c,d)=>{c.value={...c.value,...d},m.emit()},S=(c,d)=>o.get(c)===d,A=async(c,d)=>{d.controller.abort(),d.controller=new AbortController;const{signal:p}=d.controller;h(d,{phase:{kind:"opening"}});const x=await e.edit(c,p);if(!S(c,d)||p.aborted||!("kind"in x))return;if(x.kind==="grant"){h(d,{phase:{kind:"grant",href:x.href}});return}if(x.kind==="failure"){h(d,{phase:{kind:"failed",failure:x.failure}});return}const k=je(x.text);d.base={text:k,version:x.version},d.draft=k,d.ending=st(x.text),h(d,{phase:{kind:"editing"},history:x.history,dirty:!1,save:Me,generation:d.value.generation+1})},y=c=>{const d=o.get(c);d!==void 0&&(d.controller.abort(),o.delete(c),a.delete(c))},C=(c,d,p)=>(c.set(d,p),()=>{c.get(d)===p&&c.delete(d)}),R=(c,d,p,x={})=>{h(d,{...x,save:p}),n(c,p)},M=async c=>{u.get(c)?.flush();const d=o.get(c);if(d===void 0||d.value.phase.kind!=="editing"||d.base===null||d.value.save.kind==="saving")return;const p=ot(d.draft).length;if(p>0){R(c,d,{kind:"conflicts",count:p});return}d.controller.abort(),d.controller=new AbortController;const{signal:x}=d.controller;let k=d.base,j=d.draft,T=!1;h(d,{save:{kind:"saving"}});for(let D=0;D<Nn;D+=1){const F=await e.save(c,k.version,Mn(j,d.ending),x);if(!S(c,d)||x.aborted||!("kind"in F))return;if(F.kind==="saved"){u.get(c)?.flush(),d.base={text:j,version:F.version},R(c,d,{kind:"saved",merged:T},{dirty:d.draft!==j});return}if(F.kind==="grant"){R(c,d,{kind:"grant",href:F.href});return}if(F.kind==="failure"){R(c,d,{kind:"failed",failure:F.failure});return}const{mergeDraft:V}=await Promise.resolve().then(()=>require("./merge-AnqxGn__.cjs"));if(!S(c,d)||x.aborted)return;const K=u.get(c);K?.flush();const X=je(F.text),G=V(k.text,d.draft,X,t());if(k={text:X,version:F.version},d.base=k,d.ending=st(F.text),d.draft=G.text,K?.adopt(G.text),G.kind==="conflicts"){R(c,d,{kind:"conflicts",count:G.conflicts},{dirty:!0,generation:d.value.generation+1});return}if(T=!0,j=G.text,j===k.text){R(c,d,{kind:"saved",merged:T},{dirty:!1,generation:d.value.generation+1});return}h(d,{dirty:!0,generation:d.value.generation+1})}R(c,d,{kind:"failed",failure:{reason:"failed"}})};return{session:c=>o.get(c)?.value,subscribe:m.subscribe,start:(c,d)=>{const p=o.get(c);if(p!==void 0){h(p,{request:{anchor:d}}),(p.value.phase.kind==="failed"||p.value.phase.kind==="grant")&&A(c,p);return}s.delete(c);const x={value:{path:c,phase:{kind:"opening"},history:!1,dirty:!1,save:Me,generation:0,request:{anchor:d}},base:null,draft:"",ending:`
10
+ `,controller:new AbortController};o.set(c,x),A(c,x)},retry:c=>{const d=o.get(c);d===void 0||d.value.phase.kind==="editing"||A(c,d)},draft:c=>{const d=o.get(c);return d===void 0||d.base===null?null:d.draft},setDraft:(c,d)=>{const p=o.get(c);if(p===void 0||p.base===null)return;p.draft=d;const x={},k=d!==p.base.text;k!==p.value.dirty&&(x.dirty=k);const{save:j}=p.value;if(j.kind==="conflicts"){const T=ot(d).length;T===0?x.save=Me:T!==j.count&&(x.save={kind:"conflicts",count:T})}(x.dirty!==void 0||x.save!==void 0)&&h(p,x)},consumeRequest:c=>{const d=o.get(c);d!==void 0&&d.value.request!==null&&h(d,{request:null})},save:M,replaceDraft:(c,d)=>{const p=u.get(c);p?.flush();const x=o.get(c);if(x===void 0||x.base===null)return;const k=je(d);x.draft=k,p?.adopt(k),h(x,{dirty:k!==x.base.text,generation:x.value.generation+1})},close:c=>{if(!o.has(c))return;const d=u.get(c),p=d===void 0?null:d.returnPoint();y(c),p===null?s.delete(c):s.set(c,p),m.emit()},takeReturn:c=>{const d=s.get(c)??null;return s.delete(c),d},dirtyPaths:()=>[...o.values()].filter(c=>c.value.dirty).map(c=>c.value.path),discard:c=>{for(const d of c)y(d);c.length>0&&m.emit()},editorState:{get:c=>a.get(c),set:(c,d)=>{o.has(c)&&a.set(c,d)}},bindEditor:(c,d)=>C(u,c,d),bindView:(c,d)=>C(g,c,d),viewAnchor:c=>{const d=g.get(c);return d===void 0?null:d.anchor()},flush:c=>u.get(c)?.flush(),flushDrafts:()=>{for(const c of u.values())c.flush()},nextConflict:c=>u.get(c)?.nextConflict()===!0,hasSessions:()=>o.size>0,unsavedAmong:c=>{for(const d of u.values())d.flush();return c.filter(d=>o.get(d)?.value.dirty===!0)},askToDiscard:c=>new Promise(d=>{v?.settle(!1);const p={paths:c,settle:x=>{if(v===p){if(v=null,x)for(const k of c)y(k);m.emit(),d(x)}}};v=p,m.emit()}),discardRequest:()=>v,previewShown:()=>(f??=r.read(),f),setPreviewShown:c=>{f!==c&&(f=c,r.write(c),m.emit())}}},Ve=e=>{e.preventDefault(),e.stopPropagation()},$t=({open:e,title:t,body:n,confirmLabel:r,cancelLabel:o,onConfirm:s,onCancel:a,testId:u})=>{const g=i.useRef(null),m=i.useRef(null),f=i.useRef(null),v=i.useId(),h=i.useId();i.useLayoutEffect(()=>{const y=g.current;if(y!==null)if(e&&!y.open){const C=y.ownerDocument.activeElement;f.current=C instanceof HTMLElement?C:null,y.showModal(),m.current?.focus()}else!e&&y.open&&(y.close(),f.current?.isConnected===!0&&f.current.focus(),f.current=null)},[e]);const S=y=>{y.key!=="Escape"||y.defaultPrevented||(Ve(y),a())},A=y=>{y.target===y.currentTarget&&a()};return l.jsx("dialog",{ref:g,className:"aqmx-confirm","aria-labelledby":v,"aria-describedby":h,"data-testid":u,onKeyDown:S,onClick:A,onCancel:y=>y.preventDefault(),children:l.jsxs("div",{className:"aqmx-confirm-panel",children:[l.jsx("p",{id:v,className:"aqmx-confirm-title",children:t}),l.jsx("p",{id:h,className:"aqmx-confirm-body",children:n}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{ref:m,type:"button",className:"aqmx-callout-action","data-testid":`${u}-cancel`,onClick:a,children:o}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-aqmx-tone":"danger","data-testid":`${u}-confirm`,onClick:s,children:r})]})]})})},Pn=(e,t)=>{const n=Y.matchPath({path:`${e.basePath}/*`,end:!0},t.pathname);if(n===null)return new Set;const{location:r}=I.resolveExplorerLocation(e,n.params["*"],new URLSearchParams(t.search));switch(r.view){case"tree":return new Set(r.doc===null?[]:[r.doc]);case"single":return new Set([r.doc]);case"multi":return new Set(r.docs)}},qt=e=>{const{edits:t}=P(),n=i.useCallback(()=>t.session(e),[t,e]);return i.useSyncExternalStore(t.subscribe,n,_n)},It=()=>!1,_n=()=>{},Fn=()=>{const{edits:e}=P();return i.useSyncExternalStore(e.subscribe,e.hasSessions,It)},Bt=()=>{const{edits:e}=P();return i.useSyncExternalStore(e.subscribe,e.previewShown,It)},$n=()=>null,qn=()=>{const{edits:e,labels:t,config:n}=P(),r=i.useRef([]),o=i.useCallback(({nextLocation:v})=>{const h=Pn(n,v);return e.flushDrafts(),r.current=e.dirtyPaths().filter(S=>!h.has(S)),r.current.length>0},[e,n]),s=Y.useBlocker(o),a=Fn();i.useEffect(()=>{if(!a)return;const v=h=>{e.flushDrafts(),e.dirtyPaths().length!==0&&(h.preventDefault(),h.returnValue=!0)};return window.addEventListener("beforeunload",v),()=>window.removeEventListener("beforeunload",v)},[a,e]);const u=i.useSyncExternalStore(e.subscribe,e.discardRequest,$n),g=s.state==="blocked",f=(g?r.current:u===null?[]:u.paths).map(v=>N.lastPathSegment(v)).join(", ");return l.jsx($t,{open:g||u!==null,title:t.unsavedTitle,body:t.unsavedBody(f),confirmLabel:t.unsavedDiscard,cancelLabel:t.unsavedStay,testId:"markdown-explorer-unsaved-guard",onConfirm:()=>{if(s.state==="blocked"){e.discard(r.current),s.proceed();return}u?.settle(!0)},onCancel:()=>{if(s.state==="blocked"){s.reset();return}u?.settle(!1)}})};function In({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 Bn=E.forwardRef(In);let Ne=null;const Ut=()=>(Ne??=Promise.resolve().then(()=>require("./EditSurface-CfbYYXrc.cjs")).catch(e=>{throw Ne=null,e}),Ne),lt=()=>{Ut().catch(()=>{})},Un=e=>{const{default:t}=i.use(Ut());return l.jsx(t,{...e})};class Hn extends i.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}retry=()=>this.setState({failed:!1});render(){return this.state.failed?this.props.fallback(this.retry):this.props.children}}const Ge=`[${$e.SOURCE_LINES_ATTRIBUTE}]`,zn="[data-aqmd-content]",Zn='a[href], button, input, select, textarea, summary, label, [contenteditable], [role="menu"], iframe, video, audio, object, embed, svg',Vn=200,fe=e=>$e.parseSourceLines(e.getAttribute($e.SOURCE_LINES_ATTRIBUTE)),Gn=(e,t)=>{for(let r=e;r!==null&&t.contains(r);r=r.parentElement){const o=fe(r);if(o!==null)return{block:r,lines:o,own:!0}}let n=null;for(const r of t.querySelectorAll(Ge)){if(!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))break;const o=fe(r);o!==null&&(n={block:r,lines:o})}return n===null?null:{...n,own:!1}},Kn=(e,t)=>{let n=0;for(let r=e.indexOf(t);r>=0;r=e.indexOf(t,r+t.length))n+=1;return n},Wn=e=>e.closest(zn)!==null&&e.closest(Zn)===null,Xn=(e,t,n)=>{const r=Gn(e,t);if(r===null)return null;const{block:o,own:s}=r;if(!s){const u=r.lines.last+1;return{lines:{first:u,last:u},word:null,occurrence:0,clientTop:Ee(e)}}const a=Qn(o,n);return a===null?{lines:r.lines,word:null,occurrence:0,clientTop:Ee(o)}:{lines:r.lines,word:a.text,occurrence:a.occurrence,clientTop:a.clientTop}},Yn=(e,t)=>{let n=null,r=null,o=null;for(const a of e.querySelectorAll(Ge)){const u=fe(a);if(u===null)continue;n??=zt(t,a);const{top:g,bottom:m}=a.getBoundingClientRect();g<=n&&n<m?r={lines:u,block:a}:o===null&&g>=n&&(o={lines:u,block:a})}const s=r===null?o:r;return s===null?null:{lines:s.lines,word:null,occurrence:0,clientTop:Ee(s.block)}},Ht=e=>e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,zt=(e,t)=>{const n=Number.parseFloat(getComputedStyle(t).scrollMarginTop);return Ht(e)+(Number.isFinite(n)?n:0)},Qn=(e,t)=>{if(t===null||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!(e.contains(n.startContainer)&&e.contains(n.endContainer)))return null;const r=n.toString().trim();if(r===""||r.length>Vn||/[\r\n]/u.test(r))return null;const o=e.ownerDocument.createRange();return o.setStart(e,0),o.setEnd(n.startContainer,n.startOffset),{text:r,occurrence:Kn(o.toString(),r),clientTop:n.getBoundingClientRect().top}},Jn=(e,t)=>{const n=e.split(`
11
+ `),r=Math.min(t.lines.first,n.length),o=Math.min(t.lines.last,n.length),s={line:r,column:0};if(t.word===null)return s;let a=0;for(let u=r;u<=o;u+=1){const g=n[u-1]??"";for(let m=g.indexOf(t.word);m>=0;m=g.indexOf(t.word,m+t.word.length)){if(a===t.occurrence)return{line:u,column:m};a+=1}}return a>0?er(n,r,o,t.word)??s:s},er=(e,t,n,r)=>{for(let o=n;o>=t;o-=1){const s=(e[o-1]??"").lastIndexOf(r);if(s>=0)return{line:o,column:s}}return null},Zt=(e,t)=>{let n=null,r=null;for(const o of e.querySelectorAll(Ge)){const s=fe(o);s===null||s.first>t||(s.last>=t?n=o:(r===null||s.last>=r.last)&&(r={element:o,last:s.last}))}return n!==null?n:r===null?null:r.element},Vt=(e,t)=>{const{bottom:n}=e.getBoundingClientRect(),r=Ee(e),o=fe(e);if(o===null)return r;const s=Math.min(Math.max(t-o.first,0)/(o.last-o.first+1),1);return r+(n-r)*s},Ee=e=>{const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let n=t.nextNode();n!==null;n=t.nextNode()){const o=(n.textContent??"").search(/\S/u);if(o<0)continue;const s=e.ownerDocument.createRange();s.setStart(n,o),s.setEnd(n,o+1);const{top:a,height:u}=s.getBoundingClientRect();if(u>0)return a}return e.getBoundingClientRect().top},Ke=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})}),tr=e=>Ke[e],he=()=>{const e=Y.useNavigate();return i.useCallback((t,n)=>{e(t,Ke[n])},[e])},Gt=({navigation:e,...t})=>l.jsx(Y.Link,{...t,...Ke[e]}),We=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},Kt=(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(m=>{if(r.current!==m)return;const f=o.current;if(f!==null){f.then(()=>a(m));return}e.prefetch(m);const v=e.peek(m);if(v?.status!=="pending")return;const h=Promise.allSettled([v.promise]);o.current=h,h.then(()=>{o.current===h&&(o.current=null)})},[e]),u=i.useCallback(m=>{const f=t(m);f!==r.current&&(s(),f!==null&&(r.current=f,n.current=window.setTimeout(()=>{n.current=null,a(f)},I.PREFETCH_DWELL_MS)))},[s,t,a]),g=i.useCallback(m=>{t(m)!==r.current&&s()},[s,t]);return i.useMemo(()=>({onPointerOver:m=>u(m.target),onPointerOut:m=>g(m.relatedTarget),onFocus:m=>u(m.target),onBlur:m=>g(m.relatedTarget)}),[u,g])},nr=i.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-Dp4YWBp7.cjs")).then(e=>({default:e.NativeScrollBar})));class rr 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 Wt=({scroller:e,withCircle:t})=>l.jsx(rr,{children:l.jsx(i.Suspense,{fallback:null,children:l.jsx(nr,{scroller:e,withCircle:t})})}),Xt=e=>l.jsx(Wt,{scroller:e,withCircle:!0}),Yt=()=>{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()]}},be=(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)=>be(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)&&be(n[s],r[s]))},me=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},Qt=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),ge=e=>e.status==="fulfilled"?e.value:void 0,or=55e3,it=Object.freeze({status:"deferred"}),at=Object.freeze({status:"refreshed"}),De=Object.freeze({status:"superseded"}),oe=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,Jt=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",sr=({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=Yt(),o=ae(),s=new WeakSet;let a=0;const u=o.emit,g=()=>(a+=1,a),m=()=>{if(!(n.size<=t))for(const c of[...n.keys()]){if(n.size<=t)return;r.isHeld(c)||n.delete(c)}},f=(c,d)=>{n.delete(c),n.set(c,d)},v=c=>performance.now()-c.validatedAt>=or,h=(c,d,p)=>{const x=n.get(c),k=oe(x?.snapshot),j=p||x?.refreshPending===!0,T=me(e.document(c,{refresh:j}).then(F=>({status:"loaded",document:F}))),D={snapshot:{status:"pending",promise:T,previous:k},validatedAt:performance.now(),opened:d,background:null,refreshPending:!1,seeded:void 0,stamp:g()};return f(c,D),m(),T.then(F=>{n.get(c)===D&&(D.snapshot=F,D.stamp=g(),u())}),D},S=(c,d,p,x,k,j)=>{d.background===p&&(d.background=null,!(n.get(c)!==d||d.snapshot!==x)&&(k.kind==="failure"&&x.document.kind!=="failure"||(d.validatedAt=j,d.stamp=g(),be(x.document,k)||(d.snapshot={status:"loaded",document:k}),u())))},A=async(c,d)=>{const p=d.snapshot;if(p.status!=="loaded")return null;const x={};d.background=x;const k=performance.now(),j=e.document(c,{refresh:d.refreshPending});d.refreshPending=!1;const T=await j,D=d.background===x&&n.get(c)===d&&d.snapshot===p;return S(c,d,x,p,T,k),D?T:null},y=(c,d)=>{const{snapshot:p}=d;return p.status==="pending"?!1:p.status==="loaded"&&p.document.kind!=="failure"?(A(c,d),!1):(p.status==="loaded"&&s.add(p),h(c,!0,!1),!0)},C=c=>{const d=r.hold(c);let p=!1;return()=>{if(p)return;p=!0,d();const x=n.get(c);x!==void 0&&f(c,x),m()}};return{peek:c=>n.get(c)?.snapshot,peekSeeded:c=>n.get(c)?.seeded,answerStampOf:c=>n.get(c)?.stamp,prefetch:c=>{const d=n.get(c);d!==void 0&&d.snapshot.status!=="deferred"||(h(c,!1,!1),u())},open:c=>{const d=r.resumes(c),p=C(c),x=n.get(c);if(x===void 0||x.snapshot.status==="deferred")return h(c,!0,!1),u(),p;if(f(c,x),d)return p;const{snapshot:k}=x;return k.status==="pending"?(x.opened=!0,p):k.document.kind==="failure"?(x.opened||v(x)?(s.add(k),h(c,!0,!1),u()):x.opened=!0,p):(x.opened=!0,x.background===null&&v(x)&&A(c,x),p)},retain:C,retry:c=>{const d=n.get(c);d===void 0||d.snapshot.status!=="loaded"||d.snapshot.document.kind!=="failure"||(h(c,!0,!1),u())},seed:(c,d)=>{const p=performance.now(),x=me(d.then(F=>F===null?it:{status:"loaded",document:F},()=>it)),k=n.get(c);if(k!==void 0&&k.snapshot.status==="loaded"){const F=k.snapshot,V={};k.background=V,x.then(K=>{if(K.status==="loaded"){S(c,k,V,F,K.document,p);return}k.background===V&&(k.background=null)});return}const j=k!==void 0&&k.snapshot.status==="pending"?k.snapshot.previous:null,T={status:"pending",promise:x,previous:j},D={snapshot:T,validatedAt:p,opened:k?.opened===!0,background:null,refreshPending:k?.refreshPending===!0,seeded:T,stamp:g()};f(c,D),m(),x.then(F=>{n.get(c)===D&&(F.status==="deferred"&&r.isHeld(c)?h(c,D.opened,!1):(D.snapshot=F,D.stamp=g()),u())})},invalidate:()=>{let c=!1;for(const[d,p]of[...n]){if(p.validatedAt=Number.NEGATIVE_INFINITY,p.opened=!0,p.refreshPending=!0,!r.isHeld(d))continue;const{snapshot:x}=p;if(x.status!=="pending"){y(d,p)&&(c=!0);continue}x.promise.then(()=>{n.get(d)===p&&p.refreshPending&&r.isHeld(d)&&y(d,p)&&u()})}c&&u()},refresh:async c=>{const d=n.get(c);if(d!==void 0&&Jt(d.snapshot)){d.refreshPending=!0;const x=await A(c,d);return x===null?De:x.kind==="failure"?{status:"failed",failure:x.failure}:at}const p=h(c,!0,!0);return u(),p.snapshot.status!=="pending"?De:(await p.snapshot.promise,n.get(c)===p?at:De)},clear:()=>{n.clear();for(const c of r.heldKeys())h(c,!0,!1);u()},subscribe:o.subscribe,noteFailureShown:c=>s.has(c)?!1:(s.add(c),!0)}};function lr({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M18 5.25a2.25 2.25 0 0 0-2.012-2.238A2.25 2.25 0 0 0 13.75 1h-1.5a2.25 2.25 0 0 0-2.238 2.012c-.875.092-1.6.686-1.884 1.488H11A2.5 2.5 0 0 1 13.5 7v7h2.25A2.25 2.25 0 0 0 18 11.75v-6.5ZM12.25 2.5a.75.75 0 0 0-.75.75v.25h3v-.25a.75.75 0 0 0-.75-.75h-1.5Z",clipRule:"evenodd"}),E.createElement("path",{fillRule:"evenodd",d:"M3 6a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H3Zm6.874 4.166a.75.75 0 1 0-1.248-.832l-2.493 3.739-.853-.853a.75.75 0 0 0-1.06 1.06l1.5 1.5a.75.75 0 0 0 1.154-.114l3-4.5Z",clipRule:"evenodd"}))}const ir=E.forwardRef(lr);function ar({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M15.988 3.012A2.25 2.25 0 0 1 18 5.25v6.5A2.25 2.25 0 0 1 15.75 14H13.5v-3.379a3 3 0 0 0-.879-2.121l-3.12-3.121a3 3 0 0 0-1.402-.791 2.252 2.252 0 0 1 1.913-1.576A2.25 2.25 0 0 1 12.25 1h1.5a2.25 2.25 0 0 1 2.238 2.012ZM11.5 3.25a.75.75 0 0 1 .75-.75h1.5a.75.75 0 0 1 .75.75v.25h-3v-.25Z",clipRule:"evenodd"}),E.createElement("path",{d:"M3.5 6A1.5 1.5 0 0 0 2 7.5v9A1.5 1.5 0 0 0 3.5 18h7a1.5 1.5 0 0 0 1.5-1.5v-5.879a1.5 1.5 0 0 0-.44-1.06L8.44 6.439A1.5 1.5 0 0 0 7.378 6H3.5Z"}))}const cr=E.forwardRef(ar);function dr({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",clipRule:"evenodd"}))}const ur=E.forwardRef(dr),fr=2e3,ct=Object.freeze({outcome:"idle"}),mr=e=>{const t=navigator.clipboard;return t===void 0?Promise.reject(new Error("[markdown-explorer] this browser has no asynchronous clipboard")):t.writeText(e)},hr=({text:e})=>{const{announcer:t,labels:n}=P(),[r,o]=i.useState(ct);i.useEffect(()=>{if(r.outcome==="idle")return;const g=setTimeout(()=>o(ct),fr);return()=>clearTimeout(g)},[r]);const s=g=>{o({outcome:g}),t.announce(g==="copied"?n.copiedText:n.copyTextFailed)},a=()=>{mr(e).then(()=>s("copied"),()=>s("failed"))},u=r.outcome==="copied"?n.copiedText:r.outcome==="failed"?n.copyTextFailed:n.copyText;return l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":n.copyText,title:u,onClick:a,"data-aqmx-copy-outcome":r.outcome,"data-testid":"markdown-explorer-file-copy",children:r.outcome==="copied"?l.jsx(ir,{}):r.outcome==="failed"?l.jsx(ur,{}):l.jsx(cr,{})})},ie=i.createContext("fill"),pr=Object.freeze({blockSize:"100%"}),pe=({scrollerProps:e,children:t})=>i.use(ie)==="content"?l.jsx(de.HostedScrollArea,{scrollerProps:e,children:t}):l.jsx(de.HostedScrollArea,{scrollerProps:{...e,style:pr},rowClassName:"aqmx-document-scroll-row",renderScrollBar:Xt,children:t});function gr({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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"}),E.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 vr=E.forwardRef(gr);function wr({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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"}),E.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 xr=E.forwardRef(wr),ke=({name:e,openUrl:t,downloadUrl:n,icon:r,children:o})=>{const{labels:s}=P();return l.jsxs("div",{className:"aqmx-document-toolbar",children:[l.jsx("span",{className:"aqmx-document-file-icon","aria-hidden":"true",children:r}),l.jsx("span",{className:"aqmx-document-title",title:e,"data-testid":"markdown-explorer-file-name",children:e}),o,l.jsx("a",{className:"aqmx-icon-button",href:t,target:"_blank",rel:"noopener noreferrer","aria-label":s.openInNewTab,title:s.openInNewTab,"data-testid":"markdown-explorer-file-open",children:l.jsx(xr,{})}),l.jsx("a",{className:"aqmx-icon-button",href:n,download:e,"aria-label":s.download,title:s.download,"data-testid":"markdown-explorer-file-download",children:l.jsx(vr,{})})]})};function Er({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 br=E.forwardRef(Er),yr=Object.freeze({className:"aqmx-document-stage"}),Sr=({document:e})=>{const{labels:t}=P();return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[l.jsx(ke,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(br,{})}),l.jsx(pe,{scrollerProps:yr,children:l.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-file-not-shown",children:[l.jsx("p",{className:"aqmx-callout-body",children:t.fileNotShown}),l.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-file-not-shown-download",children:t.download})]})})]})},Re="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",kr=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},Rr=/(%[0-9A-Fa-f]{2})/u,Xe=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(Rr).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))},en=e=>`#${encodeURIComponent(e)}`,Tr=e=>{if(e==="#")return!0;const t=Xe(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},tn=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},Cr="http://www.w3.org/1999/xhtml",dt=(e,t)=>{if(t==="")return null;const n=tn(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===Cr&&r.getAttribute("name")===t)return r;return null},nn=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=dt(e,t.slice(1));if(n!==null)return n;const r=Xe(t);return r===null?null:dt(e,r)},ut=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"},Or=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"},Ar=(e,t)=>{const n=t.closest(Re),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&ut(r))return r;const o=e.getBoundingClientRect().height,{documentElement:s,scrollingElement:a}=e.ownerDocument;for(let u=e.parentElement;u!==null&&u!==s;u=u.parentElement)if(ut(u)&&u.scrollHeight>u.clientHeight&&u.clientHeight<o)return u;return a instanceof Element&&Or(e.ownerDocument)&&a.scrollHeight>a.clientHeight&&a.clientHeight<o?a:r},Lr=Object.freeze({scrollerOf:Ar,reveal:e=>{e.scrollIntoView(Ue)}}),Ue=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),jr=(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")}}},Mr=(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(),u=a.height+s+Number.parseFloat(o)>e.clientHeight;if(!u&&Math.abs(a.top-s-n)<1){t.scrollIntoView(Ue);return}e.scrollBy({top:u?a.top-n-e.clientHeight:a.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(Ue)},Nr=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(Re)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},ft=(e,t,n)=>{if(e===null)return null;const r=nn(e,t);return r===null?(Tr(t)&&Nr(e,n),null):(jr(e,r),Mr(n.scrollerOf(e,r),r),n.reveal(r),r)};function Dr({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 Pr=E.forwardRef(Dr);function _r({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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"}),E.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 Fr=E.forwardRef(_r);function $r({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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"}),E.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 qr=E.forwardRef($r);function Ir({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 Br=E.forwardRef(Ir),He="data-aqmx-key-repeat",ye=Object.freeze({[He]:"allow"}),Ur=`[${He}="${ye[He]}"]`,Hr=()=>{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(Ur)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},xe=Object.freeze([1/I.GOLDEN_RATIO**2,1/I.GOLDEN_RATIO,1,I.GOLDEN_RATIO,I.GOLDEN_RATIO**2]),mt=Object.freeze({mode:"fit"}),zr=1,Zr=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),rn=i.createContext(null),Vr=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=zr?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,ht=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<xe.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?xe.findIndex(o=>o>t):xe.findLastIndex(o=>o<t);return r===-1?null:r},pt=(e,t,n)=>{if(e.mode==="level"){const o=ht(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=ht(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},Gr=e=>{const t=xe[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},gt=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},Kr=({document:e})=>{const{labels:t}=P(),n=i.use(rn),[r]=i.useState(()=>n===null?null:n.read(e.url)),[o,s]=i.useState(r===null?mt:r.zoom),[a,u]=i.useState(r===null?null:r.reported),[g,m]=i.useState(null),f=i.useRef(null),v=i.useCallback(M=>{const{naturalWidth:c,naturalHeight:d}=M;u(p=>gt(p,c,d))},[]),h=i.useCallback(M=>{f.current=M,!(M===null||!M.complete)&&(M.naturalWidth>0||M.naturalHeight>0?v(M):M.decode().then(()=>v(M),()=>{}))},[v]);i.useEffect(()=>{n!==null&&a!==null&&n.save(e.url,{zoom:o,reported:a})},[n,e.url,o,a]),i.useLayoutEffect(()=>{const M=f.current;if(M===null||a===null||o.mode!=="fit")return;const c=()=>m(p=>gt(p,M.clientWidth,M.clientHeight));if(c(),typeof ResizeObserver>"u")return;const d=new ResizeObserver(c);return d.observe(M),()=>d.disconnect()},[a,o.mode]);const S=a===null||g===null?null:Vr(a,g),A=pt(o,S,-1),y=pt(o,S,1),C=o.mode==="level"?Gr(o.index):null,R=o.mode==="level"&&C!==null?{width:`${o.base.width*C}px`,height:`${o.base.height*C}px`}:void 0;return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[l.jsxs(ke,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(Br,{}),children:[l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":A===null,onClick:()=>{A!==null&&s(A)},...ye,children:l.jsx(Fr,{})}),l.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:C===null?t.imageFitLevel:t.imageZoomLevel(Math.round(C*100))}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":y===null,onClick:()=>{y!==null&&s(y)},...ye,children:l.jsx(qr,{})}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(mt),children:l.jsx(Pr,{})})]}),l.jsx(pe,{scrollerProps:Zr,children:l.jsx("img",{ref:h,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:R,onLoad:M=>v(M.currentTarget),"data-testid":"markdown-explorer-image"})})]})},on=i.createContext(null),Te=i.createContext(void 0),sn=i.createContext(null),Ce=()=>{const e=i.use(on);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},Wr=()=>{const e=i.use(sn);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},Oe=(e,t,n,r)=>t.kind==="panel"?I.explorerHref(e,{view:"tree",source:n,doc:r}):t.view==="single"?I.explorerHref(e,{view:"single",source:n,doc:r,overrides:t.overrides,embed:t.embed}):I.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides}),Xr=({children:e})=>{const{config:t}=P(),n=Ce(),r=Se(),o=r.kind==="location"?r.location.source:void 0,s=Y.useHref(Oe(t,n.navigation,o,n.currentPath));return l.jsx(Te,{value:o,children:l.jsx(sn,{value:s,children:e})})},Yr='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',Qr=e=>{const t=e instanceof Element?e.closest(Yr):null;return t===null?null:t.getAttribute("data-doc-path")},Ae=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Jr=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:a,scope:u,children:g})=>{const m=Y.useHref(e),f=v=>{if(Ae(v)){if(v.preventDefault(),t===u.currentPath&&n!==""){u.scrollWithin(n);return}a(t,n)}};return l.jsx("a",{...s,href:m,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:f,children:g})},eo=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:a}=P(),u=Ce(),g=i.use(Te),m=kr(e),{navigation:f}=u,v=`${Oe(a,f,g,t)}${m}`,h=n===!1?"false":void 0;return f.kind==="page"?l.jsx(Gt,{...o,to:v,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":h,children:s}):l.jsx(Jr,{to:v,docPath:t,fragment:m,exists:h,className:r,attributes:o,onDocumentLink:f.onDocumentLink,scope:u,children:s})},to=({className:e,attributes:t,children:n})=>{const{labels:r}=P();return l.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,l.jsxs("span",{className:"aqmx-sr-only",children:[" (",r.inertLink,")"]})]})},no=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=P(),a=i.use(Te),u=Y.useHref(`${Oe(s,r.navigation,a,r.currentPath)}${e}`),g=m=>{Ae(m)&&(m.preventDefault(),r.scrollWithin(e))};return l.jsx("a",{...n,href:u,className:t,onClick:g,children:o})},ro=({href:e,className:t,attributes:n,children:r})=>{const o=Ce();if(o.navigation.kind==="page"){const s=a=>{if(!Ae(a))return;const u=a.currentTarget;e==="#"?o.followEmptyFragment(a.nativeEvent):u.href===u.ownerDocument.URL&&o.followSameUrlJump(e,a.nativeEvent)};return l.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return l.jsx(no,{href:e,className:t,attributes:n,scope:o,children:r})},oo=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:a})=>t==="doc"?n===void 0||!N.isAcceptableDocumentPath(n)?l.jsx(to,{className:o,attributes:s,children:a}):l.jsx(eo,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:a}):e.startsWith("#")?l.jsx(ro,{href:e,className:o,attributes:s,children:a}):l.jsx("a",{...s,href:e,className:o,children:a}),so=()=>{const{config:e}=P(),t=Ce(),n=i.use(Te),r=he();return i.useCallback((o,s)=>{if(!Ae(s))return!0;s.preventDefault();const a=en(o.id),{navigation:u}=t;return u.kind==="panel"||Xe(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(a),!0):(r(`${Oe(e,u,n,t.currentPath)}${a}`,"follow-link"),!0)},[e,t,n,r])},lo=()=>{const e=Wr();return i.useCallback(t=>`${e}${en(t.id)}`,[e])};function io({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 ao=E.forwardRef(io);function co({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 uo=E.forwardRef(co);function fo({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 mo=E.forwardRef(fo),ho=Object.freeze({className:"aqmx-document-stage"}),po=e=>{switch(e){case"video":return l.jsx(uo,{});case"audio":return l.jsx(mo,{});case"pdf":return l.jsx(ao,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},go=({document:e})=>{const{labels:t}=P();switch(e.mediaType){case"video":return l.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 l.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 l.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)}`)}}},vo=({document:e})=>l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[l.jsx(ke,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:po(e.mediaType)}),l.jsx(pe,{scrollerProps:ho,children:l.jsx(go,{document:e})})]}),wo=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}),ln=(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},an=(e,t)=>e!==void 0?e:t!==void 0?t:yn.DEFAULT_CONTENT_ALIGN,Ye=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),xo=(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 I.explorerHref(e,{...t,overrides:r})},Qe=({kind:e,view:t,label:n,stale:r,busy:o,frameRef:s,intent:a,children:u})=>{const g=i.use(ie);return l.jsxs("section",{ref:s,role:"region","aria-label":n,"aria-busy":o,"data-testid":"markdown-explorer-document","data-aqmx-document-kind":e,"data-aqmx-document-view":t,"data-aqmx-document-flow":g,className:"aqmx-document",...a,children:[r?l.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,u]})},Eo=()=>{const{labels:e}=P();return l.jsx(Qe,{kind:"empty",label:e.documentRegion,stale:!1,busy:!1,children:l.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-document-empty",children:l.jsx("p",{className:"aqmx-empty-title",children:e.documentEmpty})})})},cn=({label:e})=>{const{labels:t}=P();return l.jsxs(Qe,{kind:"loading",label:e,stale:!1,busy:!0,children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-document-skeleton",children:Ye.map(n=>l.jsx("span",{},n))}),l.jsx("p",{className:"aqmx-sr-only",children:t.documentLoading})]})},vt=Object.freeze(["wheel","touchstart","pointerdown","keydown"]),bo=({path:e,document:t,viewer:n,editing:r})=>{const{reportMathDiagnostics:o,edits:s}=P(),a=i.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),u=so(),g=lo(),m=i.useMemo(()=>o===void 0?void 0:p=>o(e,p),[o,e]),f=i.useRef(null),{editable:v,doubleClick:h,region:S,paneScroll:A,stale:y}=r;i.useLayoutEffect(()=>{if(v)return s.bindView(e,{anchor:()=>{const p=f.current,x=S(),k=p===null?null:p.querySelector(Re);return p===null||x===null||k===null?null:Yn(p,A.scrollerOf(x,k))}})},[s,e,v,S,A]);const C=p=>{const x=f.current,{target:k}=p;!h||x===null||!(k instanceof Element)||!Wn(k)||(p.stopPropagation(),s.start(e,Xn(k,x,x.ownerDocument.getSelection())))},R=i.useRef(null),M=i.useRef(y);i.useLayoutEffect(()=>{M.current=y});const c=i.useEffectEvent(p=>{const x=f.current,k=S(),j=x===null?null:Zt(x,p.line);if(k===null||j===null)return!1;const T=A.scrollerOf(k,j);return T.scrollTop+=Vt(j,p.line)-p.clientTop,!0}),d=i.useEffectEvent(p=>{const x=S();if(x===null)return;const k=()=>{for(const T of vt)x.removeEventListener(T,j,!0);R.current?.release===k&&(R.current=null)},j=()=>k();for(const T of vt)x.addEventListener(T,j,{capture:!0,passive:!0});R.current={point:p,release:k}});return i.useLayoutEffect(()=>{const p=s.takeReturn(e);if(p!==null)return queueMicrotask(()=>{c(p)&&M.current&&d(p)}),()=>R.current?.release()},[s,e]),i.useLayoutEffect(()=>{const p=R.current;p===null||y||(p.release(),c(p.point))},[t,y]),l.jsx("div",{ref:f,className:"aqmx-document-viewer",onDoubleClick:C,children:l.jsx(de.MarkdownViewer,{...n,onHeadingSelect:u,headingHref:g,onMathDiagnostics:m,parseResult:a,content:null})})},dn=({document:e,viewer:t})=>{const{labels:n}=P();return l.jsxs(l.Fragment,{children:[l.jsx(ke,{name:e.name,openUrl:N.explorerPlainTextHref(e.url),downloadUrl:e.url,icon:l.jsx(Bn,{}),children:e.truncated?null:l.jsx(hr,{text:e.text})}),e.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-text-truncated",children:n.textTruncated}):null,l.jsx("div",{className:"aqmx-document-viewer",children:l.jsx(de.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},yo=({path:e,name:t,viewer:n})=>{const{data:r,documents:o,announcer:s,labels:a}=P(),u=i.useCallback(()=>o.answerStampOf(e),[o,e]),g=i.useSyncExternalStore(o.subscribe,u,u),[m,f]=i.useState(0),v=i.useMemo(()=>({path:e,stamp:g,attempt:m}),[e,g,m]),[h,S]=i.useState(null),A=i.useEffectEvent(C=>{S(C),C.kind==="failure"&&s.announce(a.documentFailed(t,te(a,C.failure.reason)))});i.useEffect(()=>{const C=new AbortController;return r.text(v.path,C.signal).then(R=>{"kind"in R&&A(R)}),()=>C.abort()},[r,v]);const y=i.useCallback(()=>f(C=>C+1),[]);return h===null?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-markup-skeleton",children:Ye.map(C=>l.jsx("span",{},C))}),l.jsx("p",{className:"aqmx-sr-only",children:a.markupLoading})]}):h.kind==="failure"?l.jsx(pe,{scrollerProps:un,children:l.jsx(le,{failure:h.failure,alert:!1,onRetry:y,testId:"markdown-explorer-markup-failure"})}):l.jsx(dn,{document:h,viewer:n})},un=Object.freeze({className:"aqmx-document-failure","data-aqmx-document-scroller":""}),So=Object.freeze({reason:"failed"}),ko=e=>l.jsx(Hn,{fallback:t=>l.jsx("div",{className:"aqmx-edit-message",children:l.jsx(le,{failure:So,alert:!1,onRetry:t,testId:"markdown-explorer-edit-load-failure"})}),children:l.jsx(i.Suspense,{fallback:l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-edit-skeleton",children:Ye.map(t=>l.jsx("span",{},t))}),children:l.jsx(Un,{...e})})}),Ro=({path:e,document:t,view:n,viewer:r,onRetry:o,editing:s})=>{switch(t.kind){case"markdown":{const{session:a,layout:u,region:g,paneScroll:m,stale:f}=s;if(n==="edit"&&a!==void 0)return l.jsx(ko,{path:e,name:t.name,session:a,layout:u,viewer:r,region:g,paneScroll:m});if(n==="markup")return l.jsx(yo,{path:e,name:t.name,viewer:r});const v=t.edit!==null&&t.edit.kind==="inline";return l.jsx(bo,{path:e,document:t,viewer:r,editing:{editable:v,doubleClick:v&&u==="fill",region:g,paneScroll:m,stale:f}})}case"text":return l.jsx(dn,{document:t,viewer:r});case"image":return l.jsx(Kr,{document:t});case"media":return l.jsx(vo,{document:t});case"file":return l.jsx(Sr,{document:t});case"failure":return l.jsx(pe,{scrollerProps:un,children:l.jsx(le,{failure:t.failure,alert:!1,onRetry:o,testId:"markdown-explorer-document-failure"})});default:{const a=t;throw new RangeError(`[markdown-explorer] unknown document kind in ${JSON.stringify(a)}`)}}},To='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',Co=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:nn(e,n),r===void 0?null:tn(e,r.id),e.querySelector(Re),e.querySelector(To)];for(const s of o)if(s instanceof HTMLElement&&We(s))return s;return null},wt=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&We(t)},Oo=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 u=h=>{s=!(h.target instanceof Node&&n.contains(h.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(a),a=setTimeout(()=>{s=!1},0)},g=h=>{t.current=h.target instanceof Node&&n.contains(h.target)},m=h=>{h.relatedTarget===null&&s&&(t.current=!1)},f=()=>{const{activeElement:h,body:S}=r;h!==null&&h!==S&&(t.current=n.contains(h))},v=()=>{s&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",u,!0),o.addEventListener("mousedown",u,!0),o.addEventListener("focusin",g,!0),o.addEventListener("blur",f),o.addEventListener("focus",v),n.addEventListener("focusout",m),()=>{clearTimeout(a),o.removeEventListener("pointerdown",u,!0),o.removeEventListener("mousedown",u,!0),o.removeEventListener("focusin",g,!0),o.removeEventListener("blur",f),o.removeEventListener("focus",v),n.removeEventListener("focusout",m)}},[e]),t},Ao=({path:e,snapshot:t,markup:n,stale:r,viewer:o,editLayout:s,regionLabel:a,navigation:u,fragment:g,paneScroll:m,announces:f,announceFailure:v,onDocumentShown:h})=>{const{labels:S,announcer:A,documents:y}=P(),{document:C}=t,R=i.useRef(null),M=i.useRef(null),c=i.useRef(null),d=i.useRef(0),p=Oo(R),x=i.useRef({path:e,document:C}),k=i.useRef(null),j=i.useCallback(U=>{const Z=R.current,W=ft(Z,U,m);Z!==null&&W!==null&&wt(Z,W,p.current)},[m,p]),T=i.useCallback((U,Z)=>{const W=d.current;setTimeout(()=>{!Z.defaultPrevented&&d.current===W&&j(U)},0)},[j]),D=i.useCallback(U=>{setTimeout(()=>{U.defaultPrevented||j("#")},0)},[j]),F=i.useMemo(()=>({navigation:u,currentPath:e,scrollWithin:j,followSameUrlJump:T,followEmptyFragment:D}),[u,e,j,T,D]),V=i.useCallback(()=>y.retry(e),[y,e]),K=Kt(y,Qr),X=qt(e),G=X!==void 0?"edit":n?"markup":"rendered",_=C.kind==="markdown"?G:void 0,z=i.useCallback(()=>R.current,[]),w=i.useMemo(()=>({session:X,layout:s,region:z,paneScroll:m,stale:r}),[X,s,z,m,r]),b=_==="edit"?!1:r,O=i.use(ie),L=_==="edit"&&s==="fill"?"fill":O,$=i.useEffectEvent((U,Z)=>{const W=M.current;if(W!==null&&W.path===U&&W.snapshot===Z)return;M.current={path:U,snapshot:Z};const Q=Z.document;if(Q.kind==="failure"){y.noteFailureShown(Z)&&v(S.documentFailed(N.lastPathSegment(U),te(S,Q.failure.reason)));return}h?.(U,Q),f&&(W===null||W.path!==U||W.snapshot.document.kind==="failure")&&A.announce(S.documentShown(Q.name))});i.useEffect(()=>{$(e,t)},[e,t]);const q=i.useEffectEvent(()=>{g.kind==="panel"&&g.consume()}),H=i.useEffectEvent(U=>{const Z=R.current;if(Z===null||!p.current)return null;const{activeElement:W,body:Q}=Z.ownerDocument;return W!==null&&W!==Q?null:Co(Z,C,U)}),B=i.useEffectEvent(U=>{const Z=R.current;Z!==null&&wt(Z,U,p.current)}),ee=i.useEffectEvent(U=>m.reveal(U)),et=i.useEffectEvent(U=>ft(R.current,U,m));return i.useEffect(()=>{if(r)return;const U=x.current.path!==e,Z=U||x.current.document!==C;x.current={path:e,document:C};const W=k.current!==e;k.current=e;let Q=null;g.kind==="page"?c.current!==g.navigation&&(c.current=g.navigation,d.current+=1,Q=g.fragment):g.fragment!==null&&(Q=g.fragment,q());const tt=()=>{const Le=Q===null?null:et(Q);if(!Z){Le!==null&&B(Le);return}const nt=H(g.fragment);U&&Le===null&&nt!==null&&ee(nt)};W?queueMicrotask(tt):tt()},[g,e,C,r]),l.jsx(ie,{value:L,children:l.jsx(Qe,{kind:C.kind,view:_,label:a(e,C),stale:b,busy:b,frameRef:R,intent:K,children:l.jsx(on,{value:F,children:l.jsx(Xr,{children:l.jsx(Ro,{path:e,document:C,view:G,viewer:o,onRetry:V,editing:w},e)})})})})},Je=Object.freeze({kind:"skeleton"}),Lo=(e,t,n,r,o)=>{if(t?.status==="loaded")return{kind:"document",path:e,snapshot:t,stale:!1};const s=oe(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:oe(r);return n===null||a===null?Je:{kind:"document",path:n,snapshot:a,stale:!0}},jo=(e,t)=>t.status==="deferred"?Je:{kind:"document",path:e,snapshot:t,stale:!1},Mo=({requestedPath:e,content:t,markup:n,...r})=>{const o=t.kind==="streaming"?jo(t.path,i.use(t.promise)):t;return o.kind!=="document"?l.jsx(cn,{label:r.regionLabel(e,null)}):l.jsx(Ao,{path:o.path,snapshot:o.snapshot,markup:n,stale:o.stale,...r})},fn=({path:e,markup:t,display:n,navigation:r,fragment:o,paneScroll:s,announces:a,announceFailure:u,onDocumentShown:g})=>{const{config:m,labels:f,theme:v,documents:h}=P(),S=de.useMarkdownToolbarState(),A=i.useRef(!1);i.useLayoutEffect(()=>{A.current=!0},[]);const[y,C]=i.useState(null),[R,M]=i.useState(t),c=i.useCallback(()=>e===null?void 0:h.peek(e),[h,e]),d=i.useSyncExternalStore(h.subscribe,c,c),p=i.useCallback(()=>y===null?void 0:h.peek(y),[h,y]),x=i.useSyncExternalStore(h.subscribe,p,p);i.useLayoutEffect(()=>e===null?void 0:h.open(e),[h,e]),i.useLayoutEffect(()=>y===null?void 0:h.retain(y),[h,y]);const k=e===null?Je:Lo(e,d,y,x,!A.current),j=e===null?null:k.kind==="document"&&!k.stale?k.path:y;j!==y&&C(j);const T=k.kind!=="document"||k.path===e;T&&t!==R&&M(t);const D=i.useMemo(()=>wo(f),[f]),F=i.useMemo(()=>[...m.iframeHosts],[m]),V=r.kind==="panel",K=i.useMemo(()=>({labels:D,emptyMessage:f.documentEmpty,theme:v,availableStyles:m.documentStyles,iFrameAllowedDomains:F,embeds:m.embeds,linkComponent:oo,toolbar:S,style:n.style,onStyleChange:n.onStyleChange,align:n.align,onAlignChange:n.onAlignChange,showToc:n.showToc,showStyle:n.showStyle,showAlign:n.showAlign,padding:n.padding,width:n.width===void 0?void 0:`min(${n.width}, 100%)`,maxWidth:n.maxWidth===void 0?void 0:`min(${n.maxWidth}, 100%)`,renderScrollBar:V?void 0:Xt}),[D,f.documentEmpty,v,m.documentStyles,F,m.embeds,S,n,V]),X=i.useCallback((_,z)=>V?z===null||z.kind==="failure"?N.lastPathSegment(_):z.name:f.documentRegion,[V,f.documentRegion]),G=V?"content":"fill";return e===null?l.jsx(ie,{value:G,children:l.jsx(Eo,{})}):l.jsx(ie,{value:G,children:l.jsx(i.Suspense,{fallback:l.jsx(cn,{label:X(e,null)}),children:l.jsx(Mo,{requestedPath:e,content:k,markup:T?t:R,viewer:K,editLayout:n.editLayout,regionLabel:X,navigation:r,fragment:o,paneScroll:s,announces:a,announceFailure:u,onDocumentShown:g})})})},No=({path:e,markup:t,variant:n,onDocumentShown:r})=>{const{config:o,viewSettings:s,announcer:a}=P(),u=ue(j=>j.style),g=ue(j=>j.align),m=he(),f=Y.useLocation(),v=Se(),{view:h,overrides:S,embed:A}=n,y=i.useCallback(j=>{if(v.kind!=="location")return;const T=xo(o,v.location,j);T!==null&&m(T,"browse")},[o,m,v]),C=i.useCallback(j=>{s.update({style:j}),y("style")},[s,y]),R=i.useCallback(j=>{s.update({align:j}),y("align")},[s,y]),M=ln(o,S.style,u),c=an(S.align,g),d=i.useMemo(()=>({style:M,onStyleChange:C,align:c,onAlignChange:R,showToc:A.showToc!==!1,showStyle:A.showStyle!==!1,showAlign:A.showAlign!==!1,padding:A.padding,width:A.width,maxWidth:A.maxWidth,editLayout:"fill"}),[M,C,c,R,A]),p=i.useMemo(()=>({kind:"page",view:h,overrides:S,embed:A}),[h,S,A]),x=i.useMemo(()=>({kind:"page",fragment:f.hash,navigation:f}),[f]),k=i.useCallback(j=>a.announce(j),[a]);return l.jsx(fn,{path:e,markup:t,display:d,navigation:p,fragment:x,paneScroll:Lr,announces:!0,announceFailure:k,onDocumentShown:r})},Do=({path:e,markup:t,variant:n,onDocumentShown:r})=>{const{config:o,viewSettings:s}=P(),a=ue(p=>p.style),u=ue(p=>p.align),[g,m]=i.useState(()=>ln(o,void 0,a)),f=an(void 0,u),v=i.useCallback(p=>s.update({align:p}),[s]),{maximized:h,onDocumentLink:S,pendingHash:A,onHashConsumed:y,announceFailure:C,paneScroll:R}=n,M=i.useMemo(()=>({style:g,onStyleChange:m,align:f,onAlignChange:v,showToc:h,showStyle:h,showAlign:h,padding:void 0,width:void 0,maxWidth:void 0,editLayout:h?"fill":"content"}),[g,f,v,h]),c=i.useMemo(()=>({kind:"panel",onDocumentLink:S}),[S]),d=i.useMemo(()=>({kind:"panel",fragment:A,consume:y}),[A,y]);return l.jsx(fn,{path:e,markup:t,display:M,navigation:c,fragment:d,paneScroll:R,announces:!1,announceFailure:C,onDocumentShown:r})},mn=({path:e,markup:t,variant:n,onDocumentShown:r})=>n.kind==="page"?l.jsx(No,{path:e,markup:t,variant:n,onDocumentShown:r}):l.jsx(Do,{path:e,markup:t,variant:n,onDocumentShown:r});function Po({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.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 hn=E.forwardRef(Po);function _o({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M14.447 3.026a.75.75 0 0 1 .527.921l-4.5 16.5a.75.75 0 0 1-1.448-.394l4.5-16.5a.75.75 0 0 1 .921-.527ZM16.72 6.22a.75.75 0 0 1 1.06 0l5.25 5.25a.75.75 0 0 1 0 1.06l-5.25 5.25a.75.75 0 1 1-1.06-1.06L21.44 12l-4.72-4.72a.75.75 0 0 1 0-1.06Zm-9.44 0a.75.75 0 0 1 0 1.06L2.56 12l4.72 4.72a.75.75 0 0 1-1.06 1.06L.97 12.53a.75.75 0 0 1 0-1.06l5.25-5.25a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const Fo=E.forwardRef(_o);function $o({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M15.75 2.25H21a.75.75 0 0 1 .75.75v5.25a.75.75 0 0 1-1.5 0V4.81L8.03 17.03a.75.75 0 0 1-1.06-1.06L19.19 3.75h-3.44a.75.75 0 0 1 0-1.5Zm-10.5 4.5a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h10.5a1.5 1.5 0 0 0 1.5-1.5V10.5a.75.75 0 0 1 1.5 0v8.25a3 3 0 0 1-3 3H5.25a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h8.25a.75.75 0 0 1 0 1.5H5.25Z",clipRule:"evenodd"}))}const qo=E.forwardRef($o);function Io({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M11.47 13.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 0 0-1.06-1.06L12 11.69 5.03 4.72a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",clipRule:"evenodd"}),E.createElement("path",{fillRule:"evenodd",d:"M11.47 19.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 1 0-1.06-1.06L12 17.69l-6.97-6.97a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",clipRule:"evenodd"}))}const Bo=E.forwardRef(Io);function Uo({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25ZM12.75 6a.75.75 0 0 0-1.5 0v6c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-3.75V6Z",clipRule:"evenodd"}))}const Ho=E.forwardRef(Uo);function zo({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M9 1.5H5.625c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5Zm6.61 10.936a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 14.47a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",clipRule:"evenodd"}),E.createElement("path",{d:"M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"}))}const Zo=E.forwardRef(zo);function Vo({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),E.createElement("path",{fillRule:"evenodd",d:"M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 0 1 0-1.113ZM17.25 12a5.25 5.25 0 1 1-10.5 0 5.25 5.25 0 0 1 10.5 0Z",clipRule:"evenodd"}))}const pn=E.forwardRef(Vo);function Go({title:e,titleId:t,...n},r){return E.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?E.createElement("title",{id:t},e):null,E.createElement("path",{d:"M21.731 2.269a2.625 2.625 0 0 0-3.712 0l-1.157 1.157 3.712 3.712 1.157-1.157a2.625 2.625 0 0 0 0-3.712ZM19.513 8.199l-3.712-3.712-8.4 8.4a5.25 5.25 0 0 0-1.32 2.214l-.8 2.685a.75.75 0 0 0 .933.933l2.685-.8a5.25 5.25 0 0 0 2.214-1.32l8.4-8.4Z"}),E.createElement("path",{d:"M5.25 5.25a3 3 0 0 0-3 3v10.5a3 3 0 0 0 3 3h10.5a3 3 0 0 0 3-3V13.5a.75.75 0 0 0-1.5 0v5.25a1.5 1.5 0 0 1-1.5 1.5H5.25a1.5 1.5 0 0 1-1.5-1.5V8.25a1.5 1.5 0 0 1 1.5-1.5h5.25a.75.75 0 0 0 0-1.5H5.25Z"}))}const Ko=E.forwardRef(Go),gn=({href:e,onRetry:t,testId:n})=>{const{labels:r,onEditGrant:o}=P(),[s,a]=i.useState(!1),u=()=>{o===void 0||s||(a(!0),o(e).then(g=>{g&&t()}).finally(()=>a(!1)))};return l.jsxs("div",{className:"aqmx-callout aqmx-edit-grant","data-testid":n,children:[l.jsx("p",{className:"aqmx-callout-title",children:r.editGrantTitle}),l.jsx("p",{className:"aqmx-callout-body",children:r.editGrantBody}),l.jsxs("div",{className:"aqmx-edit-grant-actions",children:[o===void 0?l.jsx("a",{className:"aqmx-callout-action",href:e,target:"_blank",rel:"noopener","data-testid":`${n}-open`,children:r.editGrantAction}):l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":s,"data-testid":`${n}-open`,onClick:u,children:r.editGrantAction}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":`${n}-retry`,onClick:t,children:r.editGrantRetry})]})]})},xt=(e,t,n)=>{const r=e.modifiedAt===null?Number.NaN:Date.parse(e.modifiedAt);return n(Number.isNaN(r)?e.id:t.format(r),e.author===null?"":e.author)},Wo=({path:e,documentName:t,open:n,onClose:r})=>{const{data:o,edits:s,labels:a,locale:u,announcer:g}=P(),m=i.useRef(null),f=i.useRef(null),v=i.useId(),[h,S]=i.useState(null),[A,y]=i.useState(0),[C,R]=i.useState(null),[M,c]=i.useState(null),d=i.useMemo(()=>new Intl.DateTimeFormat(u,{dateStyle:"medium",timeStyle:"short"}),[u]);i.useLayoutEffect(()=>{const T=m.current;if(T!==null)if(n&&!T.open){const D=T.ownerDocument.activeElement;f.current=D instanceof HTMLElement?D:null,R(null),c(null),T.showModal()}else!n&&T.open&&(T.close(),f.current?.isConnected===!0&&f.current.focus(),f.current=null)},[n]),i.useEffect(()=>{if(!n)return;const T=new AbortController;return S(null),o.revisions(e,T.signal).then(D=>{"kind"in D&&S(D)}),()=>T.abort()},[n,o,e,A]),i.useEffect(()=>{if(!n||C===null)return;const T=new AbortController;return c(null),o.revision(e,C,T.signal).then(D=>{"kind"in D&&c(D)}),()=>T.abort()},[n,o,e,C]);const p=()=>{M===null||M.kind!=="revision"||(s.replaceDraft(e,M.text),g.announce(a.historyRestored(t)),r())},x=T=>{T.key!=="Escape"||T.defaultPrevented||(Ve(T),r())},k=T=>{T.target===T.currentTarget&&r()},j=h!==null&&h.kind==="revisions"?h.revisions.find(T=>T.id===C):void 0;return l.jsx("dialog",{ref:m,className:"aqmx-confirm aqmx-history","aria-labelledby":v,"data-testid":"markdown-explorer-history",onKeyDown:x,onClick:k,onCancel:T=>T.preventDefault(),children:l.jsxs("div",{className:"aqmx-confirm-panel aqmx-history-panel",children:[l.jsx("p",{id:v,className:"aqmx-confirm-title",children:a.historyTitle(t)}),h===null?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-loading",children:a.historyLoading}):h.kind==="failure"?l.jsx(le,{failure:h.failure,alert:!1,onRetry:()=>y(T=>T+1),testId:"markdown-explorer-history-failure"}):h.revisions.length===0?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-empty",children:a.historyEmpty}):l.jsx("ul",{className:"aqmx-history-list","data-testid":"markdown-explorer-history-list",children:h.revisions.map(T=>l.jsx("li",{children:l.jsxs("button",{type:"button",className:"aqmx-history-entry","aria-pressed":T.id===C,"data-testid":"markdown-explorer-history-entry",onClick:()=>R(T.id),children:[l.jsx("span",{children:xt(T,d,a.historyEntry)}),T.current?l.jsx("span",{className:"aqmx-history-mark",children:a.historyCurrent}):null,T.kept?l.jsx("span",{className:"aqmx-history-mark",children:a.historyKept}):null]})},T.id))}),C===null?null:M===null?l.jsx("p",{className:"aqmx-history-note",children:a.historyLoading}):M.kind==="failure"?l.jsx(le,{failure:M.failure,alert:!1,testId:"markdown-explorer-history-revision-failure"}):l.jsx("section",{className:"aqmx-history-text",tabIndex:0,"aria-label":j===void 0?a.historyTitle(t):xt(j,d,a.historyEntry),"data-testid":"markdown-explorer-history-text",children:l.jsx("pre",{children:M.text})}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":"markdown-explorer-history-close",onClick:r,children:a.historyClose}),l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":M===null||M.kind!=="revision","data-testid":"markdown-explorer-history-restore",onClick:p,children:a.historyRestore})]})]})})},Xo=e=>{const{documents:t}=P(),n=i.useCallback(()=>t.peek(e),[t,e]),r=i.useCallback(()=>t.peekSeeded(e),[t,e]),o=i.useSyncExternalStore(t.subscribe,n,r),s=oe(o)?.document;return s===void 0||s.kind==="failure"?{edit:null,name:N.lastPathSegment(e)}:{edit:s.kind==="markdown"?s.edit:null,name:s.name}},ne=e=>{e.stopPropagation()},Yo=({path:e,documentName:t,iconOnly:n})=>{const{edits:r,labels:o}=P(),s=i.useSyncExternalStore(r.subscribe,()=>r.session(e)!==void 0,()=>!1),[a,u]=i.useState(!1),g=()=>{if(!s){r.start(e,r.viewAnchor(e));return}r.flush(e),r.session(e)?.dirty===!0?u(!0):r.close(e)},m=n?o.editDocumentNamed(t):null;return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:m===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:s?o.closeEditor:m===null?o.editDocument:m,"aria-label":m===null?void 0:m,"aria-pressed":s,"data-testid":"markdown-explorer-document-edit",onClick:g,onDoubleClick:ne,onPointerEnter:lt,onFocus:lt,children:[l.jsx(Ko,{"aria-hidden":"true"}),m===null?l.jsx("span",{children:o.editDocumentLabel}):null]}),l.jsx($t,{open:a,title:o.unsavedTitle,body:o.unsavedBody(t),confirmLabel:o.unsavedDiscard,cancelLabel:o.unsavedStay,testId:"markdown-explorer-edit-close-confirm",onConfirm:()=>{u(!1),r.close(e)},onCancel:()=>u(!1)})]})},Qo=({href:e,documentName:t,iconOnly:n})=>{const{labels:r}=P(),o=n?r.editExternallyNamed(t):null;return l.jsxs("a",{className:o===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",href:e,target:"_blank",rel:"noopener noreferrer",title:o===null?r.editExternally:o,"aria-label":o===null?void 0:o,"data-testid":"markdown-explorer-document-edit-external",onDoubleClick:ne,children:[l.jsx(qo,{"aria-hidden":"true"}),o===null?l.jsx("span",{children:r.editExternallyLabel}):null]})},Jo=({session:e})=>{const{labels:t}=P(),n=Ln(t,e);return l.jsx("p",{className:"aqmx-edit-status",title:n===""?void 0:n,"data-testid":"markdown-explorer-edit-status","data-aqmx-save":e.save.kind,children:n})},es=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{edits:s,labels:a}=P(),u=Bt(),[g,m]=i.useState(!1);if(r.phase.kind!=="editing")return null;const f=r.save.kind==="saving",v=f||!r.dirty,h=()=>{s.flush(e);const A=s.session(e);A===void 0||!A.dirty||A.save.kind==="saving"||s.save(e)},S=A=>n?{className:"aqmx-icon-button","aria-label":A}:{className:"aqmx-icon-button aqmx-labelled-button"};return l.jsxs(l.Fragment,{children:[r.save.kind==="conflicts"?l.jsxs("button",{type:"button",...S(a.conflictNext),title:a.conflictNext,"data-testid":"markdown-explorer-edit-next-conflict",onClick:()=>s.nextConflict(e),onDoubleClick:ne,children:[l.jsx(Bo,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.conflictNext})]}):null,o?l.jsxs("button",{type:"button",...S(a.previewToggle),title:a.previewToggle,"aria-pressed":u,"data-testid":"markdown-explorer-edit-preview-toggle",onClick:()=>s.setPreviewShown(!u),onDoubleClick:ne,children:[l.jsx(pn,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.previewToggle})]}):null,r.history?l.jsxs("button",{type:"button",...S(a.historyOpen),title:a.historyOpen,"aria-haspopup":"dialog","data-testid":"markdown-explorer-edit-history",onClick:()=>m(!0),onDoubleClick:ne,children:[l.jsx(Ho,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.historyOpen})]}):null,l.jsxs("button",{type:"button",...S(a.saveDraft),title:a.saveDraftTooltip,"aria-disabled":v,"aria-busy":f,"aria-keyshortcuts":"Control+S Meta+S","data-testid":"markdown-explorer-edit-save",onClick:h,onDoubleClick:ne,children:[l.jsx(Zo,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.saveDraft})]}),r.history?l.jsx(Wo,{path:e,documentName:t,open:g,onClose:()=>m(!1)}):null]})},ts=({path:e,session:t})=>{const{edits:n}=P();return t.save.kind!=="grant"?null:l.jsx(gn,{href:t.save.href,onRetry:()=>{n.save(e)},testId:"markdown-explorer-save-grant"})},ns=e=>{const{documents:t}=P(),n=i.useCallback(()=>t.peek(e),[t,e]),r=i.useCallback(()=>t.peekSeeded(e),[t,e]),o=i.useSyncExternalStore(t.subscribe,n,r);return oe(o)?.document.kind==="markdown"},vn=e=>{const{config:t}=P(),n=he(),r=i.useCallback(()=>n(I.explorerHref(t,{...e,markup:!e.markup}),"browse"),[t,n,e]);return i.useMemo(()=>({shown:e.markup,toggle:r}),[e.markup,r])},rs=new Set,os=(e,t)=>{const{documents:n,announcer:r,labels:o}=P(),s=i.useCallback(()=>n.peek(e),[n,e]),a=i.useCallback(()=>n.peekSeeded(e),[n,e]),u=i.useSyncExternalStore(n.subscribe,s,a),g=i.useCallback(()=>n.answerStampOf(e),[n,e]),m=i.useSyncExternalStore(n.subscribe,g,g),[f]=i.useState(()=>new Set),[v,h]=i.useState(rs),[S,A]=i.useState(null);S!==null&&S.path!==e&&A(null);const y=i.useRef(null);i.useLayoutEffect(()=>(y.current=e,()=>{y.current=null}),[e]);const C=i.useCallback(()=>{const c=e,d=n.peek(c);if(f.has(c)||d?.status==="pending")return;const p=t&&!Jt(d);f.add(c),h(new Set(f)),A(null),(async()=>{try{const x=await n.refresh(c);if(y.current!==c||x.status==="superseded")return;if(x.status==="failed"){A({path:c,failure:x.failure,stamp:n.answerStampOf(c)}),r.announce(o.documentRefreshFailed(te(o,x.failure.reason)));return}const k=oe(n.peek(c));if(p||k===null||k.document.kind==="failure")return;r.announce(o.documentRefreshed(k.document.name))}finally{f.delete(c),h(new Set(f))}})()},[e,t,f,n,r,o]),R=v.has(e),M=S!==null&&S.path===e&&S.stamp===m?S.failure:null;return{refreshing:R,unavailable:R||u?.status==="pending",failure:M,refresh:C}},wn=Object.freeze({kind:"page"}),xn=({path:e,placement:t,markup:n})=>{const{labels:r}=P(),{refreshing:o,unavailable:s,failure:a,refresh:u}=os(e,t.kind==="page"),g=ns(e),m=Xo(e),f=qt(e),v=t.kind==="panel"?r.refreshDocumentNamed(t.documentName):null,h=t.kind==="panel"?r.showMarkupNamed(t.documentName):null,S=t.kind==="panel",A=t.kind==="panel"?t.documentName:m.name,y=t.kind==="page"||t.maximized;return l.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar","data-aqmx-editing":f===void 0?void 0:"true",children:[l.jsxs("div",{className:"aqmx-document-refresh-row",children:[f===void 0?null:l.jsx(Jo,{session:f}),f===void 0?null:l.jsx(es,{path:e,documentName:A,iconOnly:S,session:f,previewAvailable:y}),f===void 0&&g?l.jsxs("button",{type:"button",className:h===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:h===null?r.showMarkup:h,"aria-label":h===null?void 0:h,"aria-pressed":n.shown,"data-testid":"markdown-explorer-document-markup",onClick:n.toggle,onDoubleClick:ne,children:[l.jsx(Fo,{"aria-hidden":"true"}),h===null?l.jsx("span",{children:r.showMarkupLabel}):null]}):null,f!==void 0||m.edit?.kind==="inline"?l.jsx(Yo,{path:e,documentName:A,iconOnly:S}):m.edit?.kind==="external"?l.jsx(Qo,{href:m.edit.href,documentName:A,iconOnly:S}):null,f===void 0?l.jsxs("button",{type:"button",className:v===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:v===null?r.refreshDocument:v,"aria-label":v===null?void 0:v,"aria-disabled":s,"aria-busy":o,"data-aqmx-busy":o?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:u,onDoubleClick:ne,children:[l.jsx(hn,{"aria-hidden":"true"}),v===null?l.jsx("span",{children:r.refreshDocumentLabel}):null]}):null]}),f!==void 0||a===null?null:l.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":a.reason,children:r.documentRefreshFailed(te(r,a.reason))}),f===void 0?null:l.jsx(ts,{path:e,session:f})]})},ss=({location:e})=>{const t=e.doc,n=i.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),r=vn(e);return l.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",children:[l.jsx(xn,{path:t,placement:wn,markup:r}),l.jsx(mn,{path:t,markup:e.markup,variant:n})]})},En=({holds:e,testId:t})=>{const{labels:n,announcer:r}=P(),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 l.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]})},se=Object.freeze([]),ls=e=>{const t=new Set;let n=se,r=[],o=!1;const s=[],a=f=>{n=f;for(const v of[...t])v()},u=()=>s.at(-1)?.region,g=f=>{const v=u();f(),u()!==v&&n!==se&&a(se)},m=()=>{o=!1;const f=r.map(v=>"sentence"in v?v.sentence:v.list(v.items));r=[],a(Object.freeze(f))};return{announce:f=>{if(typeof f=="string")r.push({sentence:f});else{const v=r.find(h=>"list"in h&&h.list===f.list);v!==void 0&&"items"in v?v.items.push(f.item):r.push({list:f.list,items:[f.item]})}o||(o=!0,n!==se&&a(se),e.request(m))},subscribe:f=>(t.add(f),()=>{t.delete(f)}),claim:f=>{const v={region:f};return g(()=>s.push(v)),()=>g(()=>{const h=s.indexOf(v);h!==-1&&s.splice(h,1)})},shownIn:f=>u()===f?n:se}},ce=Object.freeze({status:"cancelled"}),is=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(N.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return N.failureOf(n,r)},as=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((m,f)=>globalThis.fetch(m,f)),o=(m,f)=>`${e}/${m}?${new URLSearchParams(f).toString()}`,s=async(m,f,v,h)=>{let S;try{S=await r(m,{credentials:"same-origin",...f,headers:{Accept:"application/json",...f.headers}})}catch{return h({reason:"failed"})}S.status===401&&t(null);const A=S.headers.get(N.EXPLORER_SCOPE_HEADER);A!==null&&t(A);let y;try{y=await S.json()}catch{return h({reason:N.failureReasonOfStatus(S.status)})}let C;try{C=v(y)}catch{C=!1}if(C)return y;const R=is(y);return h(R!==null?R:{reason:S.status===200?"failed":N.failureReasonOfStatus(S.status)})},a={[N.EXPLORER_PROOF_HEADER]:N.EXPLORER_REFRESH_PROOF},u={[N.EXPLORER_PROOF_HEADER]:N.EXPLORER_EDIT_PROOF,"Content-Type":`${N.EXPLORER_DRAFT_MEDIA_TYPE}; charset=utf-8`},g=async(m,f,v)=>{const h=await s(m,f,v,S=>N.failureDocument(S.reason,S.code));return f.signal.aborted?ce:h};return{tree:m=>s(o("tree",{[N.EXPLORER_DATA_QUERY.source]:m}),{method:"GET"},N.isExplorerTreeResult,f=>({status:"error",failure:f})),children:async(m,f,v)=>{const h=await s(o("children",{[N.EXPLORER_DATA_QUERY.source]:m,[N.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:v},N.isExplorerChildrenResult,S=>({status:"error",failure:S}));return v.aborted?ce:h},ancestors:async(m,f,v)=>{const h=await s(o("ancestors",{[N.EXPLORER_DATA_QUERY.source]:m,[N.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:v},N.isExplorerAncestorsResult,S=>({status:"error",failure:S}));return v.aborted?ce:h},reveal:async(m,f,v)=>{const h=await s(o("reveal",{[N.EXPLORER_DATA_QUERY.source]:m,[N.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:v},N.isExplorerRevealResult,S=>({status:"error",failure:S}));return v.aborted?ce:h},document:(m,{refresh:f})=>s(o("document",{[N.EXPLORER_DATA_QUERY.path]:m}),f?{method:"GET",headers:a}:{method:"GET"},N.isExplorerDocument,v=>N.failureDocument(v.reason,v.code)),text:async(m,f)=>{const v=await s(o("text",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:f},N.isExplorerTextAnswer,h=>N.failureDocument(h.reason,h.code));return f.aborted?ce:v},edit:(m,f)=>g(o("edit",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:f},N.isExplorerEditAnswer),save:(m,f,v,h)=>g(o("save",{[N.EXPLORER_DATA_QUERY.path]:m,[N.EXPLORER_DATA_QUERY.base]:f}),{method:"POST",headers:u,body:v,signal:h},N.isExplorerSaveAnswer),preview:(m,f,v)=>g(o("preview",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"POST",headers:u,body:f,signal:v},N.isExplorerPreviewAnswer),revisions:(m,f)=>g(o("revisions",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:f},N.isExplorerRevisionsAnswer),revision:(m,f,v)=>g(o("revision",{[N.EXPLORER_DATA_QUERY.path]:m,[N.EXPLORER_DATA_QUERY.revision]:f}),{method:"GET",signal:v},N.isExplorerRevisionAnswer),refresh:m=>s(o("refresh",{[N.EXPLORER_DATA_QUERY.source]:m}),{method:"POST",headers:a},N.isExplorerTreeResult,f=>({status:"error",failure:f}))}},cs=()=>{let e=null,t=null;return{settle:n=>{e=n},mayMove:n=>e!==n,move:(n,r,o)=>{e=r,t={sourceId:n,path:r,ancestors:o}},take:(n,r)=>{const o=t!==null&&t.sourceId===n&&t.path===r?t.ancestors:null;return t=null,o}}},ds=e=>{const t=J.readStorage(e);if(t===null)return I.NO_TREE_SETTING_CHANGES;try{return I.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),I.NO_TREE_SETTING_CHANGES}},Et=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=ds(e);n={changes:s,settings:I.applyTreeSettingChanges(t,s)}}return n},o=ae();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:a,settings:u}=r(),g=I.recordTreeSettingChange(a,s,I.advanceTreeSetting(u,s)[s],t);return n={changes:g,settings:I.applyTreeSettingChanges(t,g)},o.emit(),J.writeStorage(e,I.serializeTreeSettingChanges(g)),n.settings}}},us=Object.freeze({status:"refreshed"}),fs=Object.freeze({status:"superseded"}),ze=Object.freeze({status:"deferred"}),ms=Qt(ze),bn=4,hs=bn-1,bt=Object.freeze({status:"loading"}),ps=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),gs=e=>{const t=new Map,n=Yt(),r=new Map,o=new Map,s=new Map,a=new Map,u=ae(),g=new Set;let m=0,f=0;const v={direct:null,bulk:null},h=new Set;let S=!1,A=0;const y=()=>{A+=1,u.emit()},C=w=>o.get(w)??0,R=w=>{let b=a.get(w);return b===void 0&&(b={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},a.set(w,b)),b},M=(w,b,O)=>{w.inFlight.delete(b),m-=1,O.lane==="bulk"&&(f-=1)},c=w=>{const b=a.get(w);if(b!==void 0){for(const[O,L]of[...b.inFlight])M(b,O,L),L.controller.abort();b.direct.clear(),b.bulk.clear(),b.unclaimed.clear()}},d=w=>{const b=C(w)+1;return o.set(w,b),c(w),b},p=(w,b)=>{const O=ge(w),L={promise:w,opened:b,stale:!1,loadedAt:O?.status==="ok"?O.loadedAt:null};return w.status==="pending"&&w.then($=>{$.status==="ok"&&(L.loadedAt=$.loadedAt)}),L},x=w=>{let b=r.get(w);return b===void 0&&(b=new Map,r.set(w,b)),b},k=w=>{const b=[...a.keys()],O=v[w],L=O===null?0:b.indexOf(O)+1;for(let $=0;$<b.length;$+=1){const q=b[(L+$)%b.length],H=q===void 0?void 0:a.get(q);if(!(q===void 0||H===void 0)){for(const B of H[w])if((H.claims.get(B)??0)!==0)return H[w].delete(B),v[w]=q,{sourceId:q,path:B}}}return null},j=(w,b,O,L)=>{const $=a.get(w);if($===void 0||$.inFlight.get(b)!==O)return;M($,b,O);const q=($.claims.get(b)??0)>0,H=x(w);if(L.status==="ok"?H.set(b,{status:"loaded",entries:L.entries}):L.status==="error"&&q?H.set(b,{status:"failed",failure:L.failure}):H.delete(b),y(),L.status==="error"&&q){const B={sourceId:w,path:b,failure:L.failure};for(const ee of[...g])ee(B)}D()},T=(w,b,O)=>{const L={controller:new AbortController,lane:O};R(w).inFlight.set(b,L),m+=1,O==="bulk"&&(f+=1),e.children(w,b,L.controller.signal).then($=>j(w,b,L,$),()=>j(w,b,L,ps))},D=()=>{for(;m<bn;){const w=k("direct");if(w!==null){T(w.sourceId,w.path,"direct");continue}const b=f<hs?k("bulk"):null;if(b===null)return;T(b.sourceId,b.path,"bulk")}},F=(w,b,O)=>{if(!(b.direct.delete(O)||b.bulk.delete(O))){const $=b.inFlight.get(O);if($===void 0)return!1;M(b,O,$),$.controller.abort()}return r.get(w)?.delete(O),!0},V=()=>{S=!1;let w=!1;for(const b of h){const O=R(b);for(const L of O.unclaimed)(O.claims.get(L)??0)===0&&F(b,O,L)&&(w=!0);O.unclaimed.clear()}h.clear(),w&&(y(),D())},K=(w,b)=>{t.set(w,p(me(e.tree(w)),b))},X=(w,b,O)=>{d(w);const L=p(Qt(b),O);return t.set(w,L),r.delete(w),y(),D(),L},G=(w,b,O,L)=>{if(O!==C(w)||t.get(w)!==b)return;const $=ge(b.promise);if(!(L.status!=="ok"||$?.status!=="ok"||b.loadedAt===null||L.loadedAt<=b.loadedAt)){if(be($.entries,L.entries)){b.loadedAt=L.loadedAt;return}X(w,L,b.opened)}},_=(w,b)=>{const O=t.get(w);return O!==void 0&&ge(O.promise)?.status===b},z=(w,b)=>{b.stale=!1;const O=C(w);e.tree(w).then(L=>G(w,b,O,L))};return{read:w=>t.get(w)?.promise??ms,open:w=>{const b=n.resumes(w),O=n.hold(w),L=t.get(w);return L===void 0||_(w,"deferred")?(K(w,!0),y()):b||(L.opened&&_(w,"error")?(K(w,!0),y()):(L.opened=!0,L.stale&&_(w,"ok")&&z(w,L))),O},retry:w=>{_(w,"error")&&(K(w,!0),y())},seed:(w,b)=>{const O=b.then(q=>q===null?ze:q,()=>ze),L=t.get(w);if(L!==void 0&&_(w,"ok")){const q=C(w);O.then(H=>G(w,L,q,H));return}d(w);const $=p(me(O),L?.opened===!0);t.set(w,$),r.delete(w),D(),O.then(q=>{t.get(w)===$&&(q.status==="deferred"&&n.isHeld(w)&&K(w,$.opened),y())})},refresh:async w=>{const b=(s.get(w)??0)+1;s.set(w,b);const O=await e.refresh(w);if(s.get(w)!==b)return fs;if(O.status==="error")return{status:"failed",failure:O.failure};const L=t.get(w);if(!(L!==void 0&&L.loadedAt!==null&&_(w,"ok")&&L.loadedAt>O.loadedAt)){const q=X(w,O,!0);if(L!==void 0&&L.promise.status==="pending"){const H=C(w);L.promise.then(B=>G(w,q,H,B))}}for(const[q,H]of t)q!==w&&ge(H.promise)?.status==="ok"&&(H.stale=!0);return us},children:(w,b)=>r.get(w)?.get(b),claimChildren:(w,b)=>{const O=R(w),L=x(w);let $=!1,q=!1;for(const[B,ee]of b)O.claims.set(B,(O.claims.get(B)??0)+1),L.get(B)===void 0?(L.set(B,bt),O[ee].add(B),$=!0,q=!0):ee==="direct"&&O.bulk.delete(B)&&(O.direct.add(B),q=!0);$&&y(),q&&D();let H=!1;return()=>{if(!H){H=!0;for(const B of b.keys()){const ee=(O.claims.get(B)??0)-1;ee>0?O.claims.set(B,ee):(O.claims.delete(B),O.unclaimed.add(B))}h.add(w),!S&&(S=!0,queueMicrotask(V))}}},retryChildren:(w,b)=>{const O=r.get(w);if(O===void 0||O.get(b)?.status!=="failed")return;const L=R(w);if((L.claims.get(b)??0)>0){O.set(b,bt),L.direct.add(b),y(),D();return}O.delete(b),y()},pendingChildren:w=>{const b=a.get(w);return b===void 0?0:b.direct.size+b.bulk.size+b.inFlight.size},clear:()=>{for(const w of new Set([...t.keys(),...r.keys(),...o.keys(),...a.keys()]))d(w);for(const[w,b]of s)s.set(w,b+1);t.clear(),r.clear(),y()},subscribeChildrenFailures:w=>(g.add(w),()=>{g.delete(w)}),subscribe:u.subscribe,version:()=>A}},vs=(e,t)=>{let n=e;const r=ae();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},ws=1;let ve=0,re=null;const xs=()=>{const{documentElement:e,body:t}=document;ve===0&&(re={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"),ve+=1;let n=!1;return()=>{n||(n=!0,ve-=1,!(ve>0||re===null)&&(e.style.overflow=re.htmlOverflow,t.style.overflow=re.bodyOverflow,e.style.scrollbarGutter=re.htmlGutter,t.style.scrollbarGutter=re.bodyGutter,re=null))}},Es=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],yt=1,St=e=>e.getClientRects().length>0,Pe="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.",bs=e=>{if(!St(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+ws)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. ${Pe}`;if(t.height<yt)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. ${Pe}`;for(const{selector:r,name:o}of Es)for(const s of e.querySelectorAll(r)){if(!St(s))continue;const a=s.getBoundingClientRect().height;if(a<yt)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. ${Pe}`}return null},ys=e=>{let t=!1;const n=()=>{if(t)return;const o=bs(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)}},Ss=(e,t)=>{i.useEffect(()=>e?xs():void 0,[e]),i.useEffect(()=>{const n=t.current;if(!(!e||n===null))return ys(n)},[e,t])},kt='[data-testid="markdown-explorer-view-switch"]',ks=[{control:kt,successors:[kt,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],Rs=e=>{for(const t of ks){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},Ts=(e,t)=>{const n=i.useRef(null);i.useEffect(()=>{const o=u=>{const g=e.current;n.current=g!==null&&u instanceof Element&&g.contains(u)?Rs(u):null},s=u=>o(u.target);o(document.activeElement);const a=u=>{const g=u.target;u.relatedTarget!==null||!(g instanceof Element)||queueMicrotask(()=>{n.current?.element===g&&g.isConnected&&document.activeElement!==g&&(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 g=document.activeElement;if(g!==null&&g!==document.body&&g!==o.element)return!0;const m=e.current;if(m===null)return!0;for(const f of o.control.successors)for(const v of m.querySelectorAll(f))if(v!==o.element&&(v.focus({preventScroll:!0}),document.activeElement===v))return!0;return!1};if(s())return;const a=e.current;if(a===null)return;const u=new MutationObserver(()=>{s()&&u.disconnect()});return u.observe(a,{childList:!0,subtree:!0}),()=>u.disconnect()},[t,e])},Cs=i.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-D-NyhuVM.cjs")).then(e=>({default:e.TreeLayout}))),Os=i.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-B4PtS45V.cjs")).then(e=>({default:e.MultiLayout}))),As=64,Ls={request:e=>{requestAnimationFrame(e)}},Rt=e=>{e.documents.clear(),e.trees.clear()},_e=(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)},js=(e,t)=>{const[n,r]=i.useState(()=>({overrides:t,locale:e,labels:Ie(e,t)}));if(n.locale===e&&On(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:Ie(e,t)};return r(o),o.labels},Ms=(e,t,n)=>{const[r,o]=i.useState(()=>({scope:t,store:Et(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:Et(e,n)};return o(s),s.store},Fe=(e,t)=>{const[n,r]=i.useState(()=>({scope:e,value:t()}));if(n.scope===e)return n.value;const o={scope:e,value:t()};return r(o),o.value},Ns=()=>ls(Ls),Tt="on",Ds="off",Ps=(e,t)=>{const n=oe(e.peek(t));return n===null||n.document.kind==="failure"?N.lastPathSegment(t):n.document.name},_s=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:a,renderTreeFailure:u,lockDocumentScroll:g=!1,onMathDiagnostics:m,onEditGrant:f})=>{J.assertStorageNamespace(n);const v=jt(r),h=An(s),S=js(v,o),{revalidate:A}=Y.useRevalidator(),y=i.useRef(()=>{}),C=Y.useHref(t.dataPath),[R]=i.useState(()=>{const _=as({dataPath:C,onScope:w=>y.current(w)}),z={documents:sr({client:_,capacity:Math.max(As,t.multiView.maxPanels*2)}),trees:gs(_)};return _e(z,e),J.syncStorageScope(n,e.scope),{data:_,...z,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(R.aligned.pageData!==e||R.aligned.storageNamespace!==n){const _=R.aligned.pageData;R.aligned.pageData=e,R.aligned.storageNamespace=n,_!==e&&(_.scope!==e.scope?R.aligned.pendingReader=e:_e(R,e)),J.syncStorageScope(n,e.scope)}const M=Ms(J.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);i.useLayoutEffect(()=>{const _=R.aligned.pendingReader;_!==null&&(R.aligned.pendingReader=null,Rt(R),_e(R,_))},[e,R]),i.useLayoutEffect(()=>{let _=!1;return y.current=z=>{z===e.scope||_||(_=!0,z!==null&&(Rt(R),J.clearExplorerStorage(n)),A())},()=>{y.current=()=>{}}},[e,A,R,n]);const c=i.useRef(t.settingsCookie);i.useLayoutEffect(()=>{c.current=t.settingsCookie},[t.settingsCookie]);const[d]=i.useState(()=>vs(e.settings,_=>{document.cookie=I.viewSettingsCookieString(c.current,_,window.location.protocol==="https:")})),p=Fe(e.scope,Ns),x=Fe(e.scope,cs),k=i.useRef(S);i.useLayoutEffect(()=>{k.current=S},[S]);const j=Fe(e.scope,()=>Dn({data:R.data,conflictLabels:()=>({ours:k.current.conflictOurs,theirs:k.current.conflictTheirs}),onSaveSettled:(_,z)=>{z.kind==="saved"&&R.documents.refresh(_);const w=jn(k.current,z,Ps(R.documents,_));w!==null&&p.announce(w)},previewSetting:{read:()=>J.readStorage(J.storageKeys(n).editPreview)===Tt,write:_=>J.writeStorage(J.storageKeys(n).editPreview,_?Tt:Ds)}})),T=i.useMemo(()=>me(e.notices.catch(()=>[])),[e.notices]),D=e.sources.map(_=>_.id).join(`
12
12
  `),F=i.useMemo(()=>I.withExplorerSources(t,D.split(`
13
13
  `)),[t,D]),V=i.useRef(m);i.useLayoutEffect(()=>{V.current=m},[m]);const[K]=i.useState(()=>(_,z)=>{V.current?.(_,z)}),X=m===void 0?void 0:K,G=i.useMemo(()=>({config:F,labels:S,locale:v,theme:h,storageNamespace:n,scope:e.scope,sources:e.sources,notices:T,documents:R.documents,trees:R.trees,data:R.data,viewSettings:d,treeSettings:M,announcer:p,reveals:x,edits:j,onEditGrant:f,renderTreeFailure:u,reportMathDiagnostics:X}),[F,S,v,h,n,e.scope,e.sources,T,R,d,M,p,x,j,f,u,X]);return l.jsx(Mt,{value:G,children:l.jsx($s,{renderFrame:a,lockDocumentScroll:g},e.scope)})},Fs=({ref:e,theme:t,view:n,children:r})=>{const[o]=i.useState(Hr);return l.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})},$s=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=P(),o=Se(),{hash:s}=Y.useLocation(),a=he(),u=i.useRef(null);Ss(t,u),i.useLayoutEffect(()=>{o.kind==="redirect"&&a(`${o.href}${s}`,"browse")},[o,s,a]);const{location:g}=o,m=g.view;Ts(u,m);const f=g.view==="tree"?l.jsx(i.Suspense,{fallback:l.jsx("section",{className:"aqmx-split-fallback","aria-label":r.explorerRegion,"aria-busy":"true","data-testid":"markdown-explorer-split-loading"}),children:l.jsx(Cs,{location:g})}):g.view==="multi"?l.jsx(i.Suspense,{fallback:l.jsx("section",{className:"aqmx-stage-fallback","aria-label":r.multiRegion,"aria-busy":"true","data-testid":"markdown-explorer-stage-loading"}),children:l.jsx(Os,{location:g})}):l.jsx(ss,{location:g}),v=l.jsxs(Fs,{ref:u,theme:n,view:m,children:[f,l.jsx(qn,{}),l.jsx(En,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?v:e({view:m,children:v})},qs=({currentUrl:e,nextUrl:t,formMethod:n,defaultShouldRevalidate:r})=>n===void 0&&e.href===t.href&&r;exports.ALLOW_KEY_REPEAT=ye;exports.CONFLICT_OURS_MARKER=Dt;exports.CONFLICT_SEPARATOR=Pt;exports.CONFLICT_THEIRS_MARKER=_t;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=Ct;exports.DocumentPane=mn;exports.DocumentRefreshBar=xn;exports.EXPLORER_THEMES=Be;exports.EditGrantNotice=gn;exports.ExplorerLink=Gt;exports.FailureView=le;exports.ForwardRef=hn;exports.ForwardRef$1=pn;exports.ImageViewMemoryContext=rn;exports.LazyNativeScrollBar=Wt;exports.LiveRegion=En;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=Lt;exports.MARKDOWN_EXPLORER_LABEL_KEYS=Ze;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=Ot;exports.MARKDOWN_EXPLORER_LOCALES=qe;exports.MarkdownExplorer=_s;exports.PAGE_DOCUMENT_REFRESH=wn;exports.blockAtLine=Zt;exports.consumeKey=Ve;exports.createEmitter=ae;exports.explorerNavigationOptions=tr;exports.failureTitleOf=te;exports.findConflictsInLines=Ft;exports.focusWithoutScroll=We;exports.frameTopOf=Ht;exports.lineTopIn=Vt;exports.positionInSource=Jn;exports.resolveMarkdownExplorerLabels=Ie;exports.shouldRevalidateExplorer=qs;exports.useExplorer=P;exports.useExplorerLocation=Se;exports.useExplorerNavigate=he;exports.useIntentPrefetch=Kt;exports.usePageMarkupToggle=vn;exports.usePreviewShown=Bt;exports.useViewSetting=ue;exports.visibleTopOf=zt;