@aiquants/markdown-explorer 0.15.0 → 0.17.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.
- package/CHANGELOG.md +173 -15
- package/README.md +73 -27
- package/dist/EditSurface-0owpPyLE.js +786 -0
- package/dist/EditSurface-D-nhilRk.cjs +2 -0
- package/dist/{ExplorerSplit-BPLECNpv.js → ExplorerSplit-8c93p1hy.js} +613 -592
- package/dist/ExplorerSplit-bpEvHrCo.cjs +1 -0
- package/dist/MultiLayout-BXfzR6XC.cjs +1 -0
- package/dist/MultiLayout-Dy3DD_09.js +963 -0
- package/dist/NativeScrollBar-CI9fTvkt.js +65 -0
- package/dist/NativeScrollBar-Ddn0iHjv.cjs +1 -0
- package/dist/TreeLayout-CKZ-XQgn.cjs +1 -0
- package/dist/TreeLayout-eFQmzpNj.js +72 -0
- package/dist/client/storage.d.cts +1 -0
- package/dist/client/storage.d.ts +1 -0
- package/dist/core/geometry.d.cts +20 -1
- package/dist/core/geometry.d.ts +20 -1
- package/dist/core/labels.d.cts +17 -0
- package/dist/core/labels.d.ts +17 -0
- package/dist/core/location.d.cts +3 -0
- package/dist/core/location.d.ts +3 -0
- package/dist/core/treeSettings.d.cts +3 -1
- package/dist/core/treeSettings.d.ts +3 -1
- package/dist/index-5gwNJ8CB.cjs +13 -0
- package/dist/index-h9e3p5Pd.js +3645 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +25 -25
- package/dist/location-D85EXiPt.cjs +1 -0
- package/dist/location-G7psbmv_.js +499 -0
- package/dist/{merge-Bi2VedIr.js → merge-CS3p9BVw.js} +5 -5
- package/dist/{merge-BFk7nT59.cjs → merge-C_g05UGC.cjs} +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +1 -1
- package/dist/{storage-BSthKLSG.js → storage-CmGHg7OA.js} +11 -10
- package/dist/storage-DM0EvkVf.cjs +1 -0
- package/dist/storage.cjs +1 -1
- package/dist/storage.js +1 -1
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/useSplitPersistence-B1b5Lg5E.js +42 -0
- package/dist/useSplitPersistence-DRjsPZdH.cjs +1 -0
- package/docs/behavior/dom-hooks.md +19 -11
- package/docs/behavior/layout.md +121 -42
- package/docs/behavior/localization.md +12 -6
- package/docs/behavior/url-contract.md +18 -6
- package/package.json +5 -5
- package/dist/EditSurface-BLlu5zEt.cjs +0 -2
- package/dist/EditSurface-CF2io496.js +0 -705
- package/dist/ExplorerSplit-Cjvy0JHP.cjs +0 -1
- package/dist/MultiLayout-BjA0k-5n.cjs +0 -1
- package/dist/MultiLayout-D8F0BfxA.js +0 -947
- package/dist/NativeScrollBar-BFF12oEd.js +0 -59
- package/dist/NativeScrollBar-BUWXPvTV.cjs +0 -1
- package/dist/TreeLayout-CQUpgsxz.cjs +0 -1
- package/dist/TreeLayout-rhyVTfrI.js +0 -29
- package/dist/index-Dn7cYy-4.cjs +0 -13
- package/dist/index-v997iKxe.js +0 -3464
- package/dist/location-D6RE3wAN.cjs +0 -1
- package/dist/location-IRD9h42r.js +0 -444
- package/dist/storage-Dgi4JXaB.cjs +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";const l=require("react/jsx-runtime"),a=require("react"),Y=require("react-router"),$=require("./location-D85EXiPt.cjs"),D=require("./dataRoute-BONacTPi.cjs"),me=require("@aiquants/markdown"),Ie=require("@aiquants/markdown/source-lines"),Bn=require("@aiquants/markdown/viewer-settings"),X=require("./storage-DM0EvkVf.cjs"),Hn=require("@aiquants/route-revalidation");function Vn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const y=Vn(a),Be=Object.freeze(["en","ja"]),Nt="en",Dt=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"])}),Un=/\{(\w+)\}/gu,Pt={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}`,editDraftDocument:"Edit the document's Markdown without saving, to try it in the preview (or double-click the document)",editDraftDocumentNamed:e=>`Edit ${e} without saving`,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",editView:"View",editViewNamed:e=>`View of ${e}`,editViewEditor:"Editor",editViewEditorTooltip:"Show the editor (Ctrl+E, or ⌘E on a Mac, switches with the preview)",editViewSplit:"Side by side",editViewSplitTooltip:"Show the editor and the preview side by side",editViewSplitResize:"Resize the editor and the preview",editViewPreview:"Preview",editViewPreviewTooltip:"Show the preview (Ctrl+E, or ⌘E on a Mac, switches with the editor)",historyOpen:"History",draftUnsaved:"Unsaved changes",draftStatus:"Draft, not saved",draftNotSaved:"This draft is not saved: the document cannot be saved here.",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",draftDiscardTitle:"Discard the draft?",draftDiscardBody:e=>`The changes to ${e} are not saved anywhere and will be lost.`,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",settingReadmePlacement:"README",readmePlacementMixed:"Mixed",readmePlacementFirst:"First",readmePlacementLast:"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.",folderReadmeMissing:e=>`${e} has no README.`,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.",pdfNotShown:"This browser does not show PDF files inside the page. Open it in a new tab or download 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",viewerMermaidInteractionModeTouch:"Touch 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)",viewerMermaidModeNoneTouch:"No interaction (a finger scrolls the page)",viewerMermaidModeZoomTouch:"Zoom only (two fingers)",viewerMermaidModePanTouch:"Pan only (one-finger drag while the diagram overflows)",viewerMermaidModeBothTouch:"Zoom and pan (two fingers, one finger while the diagram overflows)",viewerMermaidZoomIn:"Zoom In",viewerMermaidZoomOut:"Zoom Out",viewerMermaidResetView:"Reset View",viewerMermaidPanUp:"Pan Up",viewerMermaidPanDown:"Pan Down",viewerMermaidPanLeft:"Pan Left",viewerMermaidPanRight:"Pan Right",viewerMermaidDiagram:"Diagram (arrow keys pan, + and - zoom, 0 resets)",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"},zn={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} を編集`,editDraftDocument:"文書の Markdown を保存せずに編集し、プレビューで確かめる (文書のダブルクリックでも)",editDraftDocumentNamed:e=>`${e} を保存せずに編集`,editExternallyLabel:"元のエディタで開く",editExternally:"文書を元のエディタで、新しいタブに開く",editExternallyNamed:e=>`${e} を元のエディタで開く`,editorRegion:e=>`${e} を編集中`,editorLabel:e=>`${e} の Markdown`,editLoading:"編集のためにソースを読み込み中…",editToolbar:"エディタ",saveDraft:"保存",saveDraftTooltip:"下書きを保存 (Ctrl+S、Mac は ⌘S)",closeEditor:"編集を閉じる",editView:"表示",editViewNamed:e=>`${e} の表示`,editViewEditor:"エディタ",editViewEditorTooltip:"エディタを表示 (Ctrl+E、Mac は ⌘E でプレビューと切り替え)",editViewSplit:"並べて表示",editViewSplitTooltip:"エディタとプレビューを並べて表示",editViewSplitResize:"エディタとプレビューの割合を変更",editViewPreview:"プレビュー",editViewPreviewTooltip:"プレビューを表示 (Ctrl+E、Mac は ⌘E でエディタと切り替え)",historyOpen:"履歴",draftUnsaved:"保存していない変更があります",draftStatus:"保存しない下書き",draftNotSaved:"この下書きは保存しません。ここでは文書を保存できません。",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:"変更を破棄",draftDiscardTitle:"下書きを破棄しますか?",draftDiscardBody:e=>`${e} への変更はどこにも保存されず、失われます。`,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:"後に",settingReadmePlacement:"README の位置",readmePlacementMixed:"混ぜる",readmePlacementFirst:"先に",readmePlacementLast:"後に",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:"エクスプローラーで文書を選んでください。",folderReadmeMissing:e=>`${e} には README がありません。`,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:"このファイルはここでは表示できません。ダウンロードして開いてください。",pdfNotShown:"このブラウザはページの中に PDF を表示しません。新しいタブで開くか、ダウンロードしてください。",viewerLoading:"データを読み込み中...",viewerErrorPrefix:"エラー: ",viewerStyleTitle:"表示スタイル",viewerSelectStyle:"表示スタイルを選択",viewerPinStyle:"スタイル選択をピン留め",viewerUnpinStyle:"スタイル選択のピン留めを解除",viewerErrorTitle:"エラーが発生しました",viewerMissingImage:"画像が見つかりません",viewerOpenToc:"目次を開く",viewerTocTitle:"目次",viewerPinToc:"目次をピン留め",viewerUnpinToc:"目次のピン留めを解除",viewerSelectAlign:"揃えを選択",viewerAlignTitle:"揃え",viewerPinAlign:"揃え選択をピン留め",viewerUnpinAlign:"揃え選択のピン留めを解除",viewerAlignLeft:"左揃え",viewerAlignCenter:"中央揃え",viewerAlignRight:"右揃え",viewerMermaidInteractionMode:"マウス操作モード",viewerMermaidInteractionModeTouch:"タッチ操作モード",viewerMermaidModeNone:"操作なし",viewerMermaidModeZoom:"拡大縮小のみ",viewerMermaidModePan:"移動のみ (左ドラッグ)",viewerMermaidModePanShift:"移動のみ (Shift+ドラッグ)",viewerMermaidModeBoth:"拡大縮小+移動 (左ドラッグ)",viewerMermaidModeBothShift:"拡大縮小+移動 (Shift+ドラッグ)",viewerMermaidModeNoneTouch:"操作なし (指はページをスクロール)",viewerMermaidModeZoomTouch:"拡大縮小のみ (2 本指)",viewerMermaidModePanTouch:"移動のみ (はみ出す図を 1 本指でドラッグ)",viewerMermaidModeBothTouch:"拡大縮小+移動 (2 本指・はみ出す図は 1 本指)",viewerMermaidZoomIn:"拡大",viewerMermaidZoomOut:"縮小",viewerMermaidResetView:"表示を元に戻す",viewerMermaidPanUp:"上へ移動",viewerMermaidPanDown:"下へ移動",viewerMermaidPanLeft:"左へ移動",viewerMermaidPanRight:"右へ移動",viewerMermaidDiagram:"図 (矢印キーで移動、+ と - で拡大縮小、0 で元に戻す)",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:"ここへパネルをドロップ"},_t=Object.freeze({en:Object.freeze(Pt),ja:Object.freeze(zn)}),Ke=Object.freeze(Object.keys(Pt)),Zn=new Set(Ke),Gn=e=>Zn.has(e),Ee=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,Ft=e=>{if(e===void 0)return Nt;if(Be.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${Be.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${Ee(e)}`)},He=(e,t)=>{const n=_t[Ft(e)];if(t===void 0)return n;if(t===null||typeof t!="object")throw new RangeError(`[markdown-explorer] labels must be an object; got ${Ee(t)}`);if(!$.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${Ee(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!Gn(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${Ke.join(", ")}`);const i=r[s];if(i===void 0)continue;const f=typeof n[s];if(typeof i!==f)throw new TypeError(`[markdown-explorer] labels.${s} must be a ${f}; got ${Ee(i)}`);if(typeof i=="string"&&i.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const h=Dt[s];if(typeof i=="string"&&h!==void 0){for(const[,m]of i.matchAll(Un))if(!h.includes(m??""))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${String(m)}}; it accepts ${h.map(u=>`{${u}}`).join(", ")}`)}o[s]=i}return Object.freeze(o)},Kn=(e,t)=>{if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;const n=e,r=t,o=Object.keys(n),s=Object.keys(r);return o.length===s.length&&s.every(i=>Object.hasOwn(n,i)&&Object.is(n[i],r[i]))},Ve=Object.freeze(["light","dark"]),Wn=e=>{if(e===void 0)return"light";if(Ve.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${Ve.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},$t=a.createContext(null),P=()=>{const e=a.use($t);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},he=e=>{const{viewSettings:t}=P(),n=()=>e(t.getSnapshot());return a.useSyncExternalStore(t.subscribe,n,n)},Re=()=>{const{config:e}=P(),t=Y.useParams()["*"],[n]=Y.useSearchParams(),r=n.toString();return a.useMemo(()=>$.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])},qt={unauthorized:["failureUnauthorizedTitle","failureUnauthorizedBody"],forbidden:["failureForbiddenTitle","failureForbiddenBody"],"not-found":["failureNotFoundTitle","failureNotFoundBody"],"not-configured":["failureNotConfiguredTitle","failureNotConfiguredBody"],invalid:["failureInvalidTitle","failureInvalidBody"],"too-large":["failureTooLargeTitle","failureTooLargeBody"],unsupported:["failureUnsupportedTitle","failureUnsupportedBody"],failed:["failureFailedTitle","failureFailedBody"]},ee=(e,t)=>e[qt[t][0]],se=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=P(),s=ee(o,e.reason),i=o[qt[e.reason][1]],f=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":f,"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:i}),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]})},Xn=(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 ee(e,n.failure.reason)}switch(r.kind){case"draft":return e.draftStatus;case"saving":return e.draftSaving;case"conflicts":return e.draftConflicts(r.count);case"grant":return e.editGrantTitle;case"failed":return e.draftSaveFailed(ee(e,r.failure.reason));case"saved":if(!o)return r.merged?e.draftSavedMerged:e.draftSaved;break}return o?e.draftUnsaved:""},Yn=(e,t,n)=>{switch(t.kind){case"draft":return e.draftNotSaved;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(ee(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()}}},It="<<<<<<<",Bt="=======",Ht=">>>>>>>",lt=(e,t)=>e===t||e.startsWith(`${t} `),at=e=>Vt(e.split(`
|
|
2
|
+
`)),Vt=e=>{const t=[];let n=null,r=null,o=0;for(const s of e){o+=1;const i=s.charCodeAt(0);i!==60&&i!==61&&i!==62||(lt(s,It)?(n=o,r=null):s===Bt?n!==null&&r===null?r=o:n=null:lt(s,Ht)&&(n!==null&&r!==null&&t.push({start:n,separator:r,end:o}),n=null,r=null))}return t},ct=e=>e.includes(`\r
|
|
3
|
+
`)?`\r
|
|
4
|
+
`:`
|
|
5
|
+
`,Ne=e=>e.replace(/\r\n?/gu,`
|
|
6
|
+
`),Qn=(e,t)=>t===`
|
|
7
|
+
`?e:e.replaceAll(`
|
|
8
|
+
`,`\r
|
|
9
|
+
`),Jn=3,er=/^\d+(?:\.\d+)?$/u,tr=e=>{if(e===null||!er.test(e))return null;const t=Number(e);return t>=$.EDIT_SPLIT_MIN_PERCENT&&t<=$.EDIT_SPLIT_MAX_PERCENT?t:null},De=Object.freeze({kind:"idle"}),dt=Object.freeze({kind:"draft"}),nr=({data:e,conflictLabels:t,onSaveSettled:n,sideBySideSetting:r,editorShareSetting:o})=>{const s=new Map,i=new Map,f=new Map,h=new Map,m=new Map,u=ae();let p=null,E=null,x=null;const C=(c,d)=>{c.value={...c.value,...d},u.emit()},O=(c,d)=>s.get(c)===d,k=async(c,d)=>{d.controller.abort(),d.controller=new AbortController;const{signal:w}=d.controller;C(d,{phase:{kind:"opening"}});const T=await e.edit(c,w);if(!O(c,d)||w.aborted||!("kind"in T))return;if(T.kind==="grant"){C(d,{phase:{kind:"grant",href:T.href}});return}if(T.kind==="failure"){C(d,{phase:{kind:"failed",failure:T.failure}});return}const M=Ne(T.text),N=T.kind==="draft";d.base={text:M,version:N?null:T.version},d.draft=M,d.ending=ct(T.text),C(d,{phase:{kind:"editing"},history:N?!1:T.history,dirty:!1,save:N?dt:De,generation:d.value.generation+1})},j=c=>{const d=s.get(c);d!==void 0&&(d.controller.abort(),s.delete(c),f.delete(c))},A=(c,d,w)=>(c.set(d,w),()=>{c.get(d)===w&&c.delete(d)}),b=(c,d,w,T={})=>{C(d,{...T,save:w}),n(c,w)},g=async c=>{h.get(c)?.flush();const d=s.get(c);if(d===void 0||d.value.phase.kind!=="editing"||d.base===null||d.value.save.kind==="saving")return;const{version:w}=d.base;if(w===null){n(c,dt);return}const T=at(d.draft).length;if(T>0){b(c,d,{kind:"conflicts",count:T});return}d.controller.abort(),d.controller=new AbortController;const{signal:M}=d.controller;let N={text:d.base.text,version:w},F=d.draft,z=!1;C(d,{save:{kind:"saving"}});for(let I=0;I<Jn;I+=1){const B=await e.save(c,N.version,Qn(F,d.ending),M);if(!O(c,d)||M.aborted||!("kind"in B))return;if(B.kind==="saved"){h.get(c)?.flush(),d.base={text:F,version:B.version},b(c,d,{kind:"saved",merged:z},{dirty:d.draft!==F});return}if(B.kind==="grant"){b(c,d,{kind:"grant",href:B.href});return}if(B.kind==="failure"){b(c,d,{kind:"failed",failure:B.failure});return}const{mergeDraft:K}=await Promise.resolve().then(()=>require("./merge-C_g05UGC.cjs"));if(!O(c,d)||M.aborted)return;const H=h.get(c);H?.flush();const Q=Ne(B.text),v=K(N.text,d.draft,Q,t());if(N={text:Q,version:B.version},d.base=N,d.ending=ct(B.text),d.draft=v.text,H?.adopt(v.text),v.kind==="conflicts"){b(c,d,{kind:"conflicts",count:v.conflicts},{dirty:!0,generation:d.value.generation+1});return}if(z=!0,F=v.text,F===N.text){b(c,d,{kind:"saved",merged:z},{dirty:!1,generation:d.value.generation+1});return}C(d,{dirty:!0,generation:d.value.generation+1})}b(c,d,{kind:"failed",failure:{reason:"failed"}})};return{session:c=>s.get(c)?.value,subscribe:u.subscribe,start:(c,d)=>{const w=s.get(c);if(w!==void 0){C(w,{request:{anchor:d},view:"editor"}),(w.value.phase.kind==="failed"||w.value.phase.kind==="grant")&&k(c,w);return}i.delete(c);const T={value:{path:c,phase:{kind:"opening"},view:"editor",previewPrepared:!1,history:!1,dirty:!1,save:De,generation:0,request:{anchor:d}},base:null,draft:"",ending:`
|
|
10
|
+
`,controller:new AbortController};s.set(c,T),k(c,T)},retry:c=>{const d=s.get(c);d===void 0||d.value.phase.kind==="editing"||k(c,d)},draft:c=>{const d=s.get(c);return d===void 0||d.base===null?null:d.draft},setDraft:(c,d)=>{const w=s.get(c);if(w===void 0||w.base===null)return;w.draft=d;const T={},M=d!==w.base.text;M!==w.value.dirty&&(T.dirty=M);const{save:N}=w.value;if(N.kind==="conflicts"){const F=at(d).length;F===0?T.save=De:F!==N.count&&(T.save={kind:"conflicts",count:F})}(T.dirty!==void 0||T.save!==void 0)&&C(w,T)},consumeRequest:c=>{const d=s.get(c);d!==void 0&&d.value.request!==null&&C(d,{request:null})},save:g,replaceDraft:(c,d)=>{const w=h.get(c);w?.flush();const T=s.get(c);if(T===void 0||T.base===null)return;const M=Ne(d);T.draft=M,w?.adopt(M),C(T,{dirty:M!==T.base.text,generation:T.value.generation+1})},close:c=>{if(!s.has(c))return;const d=h.get(c),w=d===void 0?null:d.returnPoint();j(c),w===null?i.delete(c):i.set(c,w),u.emit()},takeReturn:c=>{const d=i.get(c)??null;return i.delete(c),d},dirtyPaths:()=>[...s.values()].filter(c=>c.value.dirty).map(c=>c.value.path),discard:c=>{for(const d of c)j(d);c.length>0&&u.emit()},editorState:{get:c=>f.get(c),set:(c,d)=>{s.has(c)&&f.set(c,d)}},bindEditor:(c,d)=>A(h,c,d),bindView:(c,d)=>A(m,c,d),viewAnchor:c=>{const d=m.get(c);return d===void 0?null:d.anchor()},flush:c=>h.get(c)?.flush(),flushDrafts:()=>{for(const c of h.values())c.flush()},nextConflict:c=>h.get(c)?.nextConflict()===!0,hasSessions:()=>s.size>0,unsavedAmong:c=>{for(const d of h.values())d.flush();return c.filter(d=>s.get(d)?.value.dirty===!0)},askToDiscard:c=>new Promise(d=>{x?.settle(!1);const w={paths:c,settle:T=>{if(x===w){if(x=null,T)for(const M of c)j(M);u.emit(),d(T)}}};x=w,u.emit()}),discardRequest:()=>x,sideBySide:()=>(p??=r.read(),p),setSideBySide:c=>{p!==c&&(p=c,r.write(c),u.emit())},editorShare:()=>(E??=o.read()??$.EDIT_SPLIT_DEFAULT_PERCENT,E),setEditorShare:c=>{if(!Number.isFinite(c))throw new RangeError(`[markdown-explorer] an editor share must be a finite number; got ${String(c)}`);const d=Math.min($.EDIT_SPLIT_MAX_PERCENT,Math.max($.EDIT_SPLIT_MIN_PERCENT,c));E!==d&&(E=d,o.write(d))},setView:(c,d)=>{const w=s.get(c);w===void 0||w.value.view===d||(h.get(c)?.beforeView(d),C(w,{view:d,previewPrepared:w.value.previewPrepared||d==="preview"}))},preparePreview:c=>{const d=s.get(c);d!==void 0&&!d.value.previewPrepared&&C(d,{previewPrepared:!0})}}},We=e=>{e.preventDefault(),e.stopPropagation()},Ut=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,zt="data-aqmx-content-pane",be=Object.freeze({[zt]:""}),rr="--aqmx-dialog-left",or="--aqmx-dialog-top",sr='[data-testid="markdown-explorer"]',ir=e=>{const t=e.closest(sr)?.querySelectorAll(`[${zt}]`),n=t?.item(t.length-1);if(!(n instanceof HTMLElement))throw new Error("[markdown-explorer] a dialog opened where the explorer marks no content pane");return n},lr=e=>{const t=Ut(getComputedStyle(e).marginTop);if(Number.isNaN(t))return null;const n=ir(e),r=e.getBoundingClientRect(),o=e.ownerDocument.documentElement,{left:s,top:i}=$.centeredDialogPosition(n.getBoundingClientRect(),{width:r.width+2*t,height:r.height+2*t},{width:o.clientWidth,height:o.clientHeight});return e.style.setProperty(rr,`${String(s)}px`),e.style.setProperty(or,`${String(i)}px`),n},ar=e=>e.preventDefault(),Zt=({open:e,onOpen:t,onDismiss:n})=>{const r=a.useRef(null),o=a.useRef(null),s=a.useRef(!1),i=a.useRef(t);a.useLayoutEffect(()=>{i.current=t},[t]),a.useLayoutEffect(()=>{s.current=e;const u=r.current;if(u!==null)if(e&&!u.open){const p=u.ownerDocument.activeElement;o.current=p instanceof HTMLElement?p:null,u.showModal(),i.current?.()}else!e&&u.open&&(u.close(),o.current?.isConnected===!0&&o.current.focus(),o.current=null)},[e]),a.useLayoutEffect(()=>{const u=r.current;if(!e||u===null)return;const p=new ResizeObserver(()=>x());let E=null;const x=()=>{const O=lr(u);O===null||O===E||(E!==null&&p.unobserve(E),p.observe(O),E=O)};x(),p.observe(u);const C=u.ownerDocument.defaultView;return C?.addEventListener("resize",x),u.ownerDocument.addEventListener("scroll",x,{capture:!0,passive:!0}),()=>{p.disconnect(),C?.removeEventListener("resize",x),u.ownerDocument.removeEventListener("scroll",x,{capture:!0})}},[e]);const f=a.useCallback(u=>{u.key!=="Escape"||u.defaultPrevented||(We(u),n())},[n]),h=a.useCallback(u=>{u.target===u.currentTarget&&n()},[n]),m=a.useCallback(()=>{s.current&&n()},[n]);return{ref:r,onKeyDown:f,onClick:h,onCancel:ar,onClose:m}},Gt=({open:e,title:t,body:n,confirmLabel:r,cancelLabel:o,onConfirm:s,onCancel:i,testId:f})=>{const h=a.useRef(null),m=a.useId(),u=a.useId(),p=a.useCallback(()=>h.current?.focus(),[]),E=Zt({open:e,onOpen:p,onDismiss:i});return l.jsx("dialog",{...E,className:"aqmx-confirm","aria-labelledby":m,"aria-describedby":u,"data-testid":f,children:l.jsxs("div",{className:"aqmx-confirm-panel",children:[l.jsx("p",{id:m,className:"aqmx-confirm-title",children:t}),l.jsx("p",{id:u,className:"aqmx-confirm-body",children:n}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{ref:h,type:"button",className:"aqmx-callout-action","data-testid":`${f}-cancel`,onClick:i,children:o}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-aqmx-tone":"danger","data-testid":`${f}-confirm`,onClick:s,children:r})]})]})})},pe=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},Kt=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),ue=e=>e.status==="fulfilled"?e.value:void 0,Wt=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!1}),cr=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!0}),dr=(e,t,n)=>{const r=new Set,o=[...e].reverse();for(let s=o.pop();s!==void 0;s=o.pop()){if(s.type!=="directory"||r.has(s.path))continue;r.add(s.path);const i=s.lazy===!0?n(s.path):void 0,f=s.lazy===!0?i?.status==="loaded"?i.entries:null:s.children===void 0?[]:s.children;if(s.path===t)return f;if(f!==null)for(const h of[...f].reverse())o.push(h)}return null},Xt=(e,t,n)=>{const r=ue(e.read(t));if(r===void 0||r.status==="deferred")return Wt;if(r.status==="error")return{readme:{status:"failed",failure:r.failure,retry:()=>e.retry(t)},claim:!1};const o=dr(r.entries,n,i=>e.children(t,i));if(o!==null)return{readme:{status:"ok",readme:$.folderReadmeOf(o)},claim:!1};const s=e.children(t,n);return s===void 0||s.status==="loading"?cr:s.status==="failed"?{readme:{status:"failed",failure:s.failure,retry:()=>e.retryChildren(t,n)},claim:!0}:{readme:{status:"ok",readme:$.folderReadmeOf(s.entries)},claim:!0}},ur=(e,t,n)=>{const{readme:r}=Xt(e,t,n);return r.status==="ok"?r.readme:null},fr=(e,t,n)=>{const r=Y.matchPath({path:`${e.basePath}/*`,end:!0},t.pathname);if(r===null)return new Set;const{location:o}=$.resolveExplorerLocation(e,r.params["*"],new URLSearchParams(t.search));switch(o.view){case"tree":{const s=o.folder===null?o.doc:n(o.source,o.folder);return new Set(s===null?[]:[s])}case"single":return new Set([o.doc]);case"multi":return new Set(o.docs)}},Yt=e=>{const{edits:t}=P(),n=a.useCallback(()=>t.session(e),[t,e]);return a.useSyncExternalStore(t.subscribe,n,mr)},Qt=()=>!1,mr=()=>{},hr=()=>{const{edits:e}=P();return a.useSyncExternalStore(e.subscribe,e.hasSessions,Qt)},Jt=()=>{const{edits:e}=P();return a.useSyncExternalStore(e.subscribe,e.sideBySide,Qt)},pr=()=>null,vr=()=>{const{edits:e,labels:t,config:n,trees:r}=P(),o=a.useRef([]),s=a.useCallback(({nextLocation:x})=>{const C=fr(n,x,(O,k)=>ur(r,O,k));return e.flushDrafts(),o.current=e.dirtyPaths().filter(O=>!C.has(O)),o.current.length>0},[e,n,r]),i=Y.useBlocker(s),f=hr();a.useEffect(()=>{if(!f)return;const x=C=>{e.flushDrafts(),e.dirtyPaths().length!==0&&(C.preventDefault(),C.returnValue=!0)};return window.addEventListener("beforeunload",x),()=>window.removeEventListener("beforeunload",x)},[f,e]);const h=a.useSyncExternalStore(e.subscribe,e.discardRequest,pr),m=i.state==="blocked",u=m?o.current:h===null?[]:h.paths,p=u.map(x=>D.lastPathSegment(x)).join(", "),E=u.length>0&&u.every(x=>e.session(x)?.save.kind==="draft");return l.jsx(Gt,{open:m||h!==null,title:E?t.draftDiscardTitle:t.unsavedTitle,body:E?t.draftDiscardBody(p):t.unsavedBody(p),confirmLabel:t.unsavedDiscard,cancelLabel:t.unsavedStay,testId:"markdown-explorer-unsaved-guard",onConfirm:()=>{if(i.state==="blocked"){e.discard(o.current),i.proceed();return}h?.settle(!0)},onCancel:()=>{if(i.state==="blocked"){i.reset();return}h?.settle(!1)}})};function gr({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm2.25 8.5a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Zm0 3a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",clipRule:"evenodd"}))}const wr=y.forwardRef(gr);let Pe=null;const en=()=>(Pe??=Promise.resolve().then(()=>require("./EditSurface-D-nhilRk.cjs")).catch(e=>{throw Pe=null,e}),Pe),Er=()=>{en().catch(()=>{})},xr=e=>{const{default:t}=a.use(en());return l.jsx(t,{...e})};class br extends a.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 Xe=`[${Ie.SOURCE_LINES_ATTRIBUTE}]`,yr="[data-aqmd-content]",Sr='a[href], button, input, select, textarea, summary, label, [contenteditable], [role="menu"], iframe, video, audio, object, embed, svg',kr=200,ve=e=>Ie.parseSourceLines(e.getAttribute(Ie.SOURCE_LINES_ATTRIBUTE)),Rr=(e,t)=>{for(let r=e;r!==null&&t.contains(r);r=r.parentElement){const o=ve(r);if(o!==null)return{block:r,lines:o,own:!0}}let n=null;for(const r of t.querySelectorAll(Xe)){if(!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))break;const o=ve(r);o!==null&&(n={block:r,lines:o})}return n===null?null:{...n,own:!1}},Tr=(e,t)=>{let n=0;for(let r=e.indexOf(t);r>=0;r=e.indexOf(t,r+t.length))n+=1;return n},tn=e=>e.closest(yr)!==null&&e.closest(Sr)===null,nn=(e,t,n)=>{const r=Rr(e,t);if(r===null)return null;const{block:o,own:s}=r;if(!s){const f=r.lines.last+1;return{lines:{first:f,last:f},word:null,occurrence:0,clientTop:ye(e)}}const i=Or(o,n);return i===null?{lines:r.lines,word:null,occurrence:0,clientTop:ye(o)}:{lines:r.lines,word:i.text,occurrence:i.occurrence,clientTop:i.clientTop}},rn=(e,t)=>{let n=null,r=null,o=null;for(const i of e.querySelectorAll(Xe)){const f=ve(i);if(f===null)continue;n??=sn(t,i);const{top:h,bottom:m}=i.getBoundingClientRect();h<=n&&n<m?r={lines:f,block:i}:o===null&&h>=n&&(o={lines:f,block:i})}const s=r===null?o:r;return s===null?null:{lines:s.lines,word:null,occurrence:0,clientTop:ye(s.block)}},on=e=>e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,sn=(e,t)=>{const n=Number.parseFloat(getComputedStyle(t).scrollMarginTop);return on(e)+(Number.isFinite(n)?n:0)},Or=(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>kr||/[\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:Tr(o.toString(),r),clientTop:n.getBoundingClientRect().top}},Cr=(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 i=0;for(let f=r;f<=o;f+=1){const h=n[f-1]??"";for(let m=h.indexOf(t.word);m>=0;m=h.indexOf(t.word,m+t.word.length)){if(i===t.occurrence)return{line:f,column:m};i+=1}}return i>0?Lr(n,r,o,t.word)??s:s},Lr=(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},ln=(e,t)=>{let n=null,r=null;for(const o of e.querySelectorAll(Xe)){const s=ve(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},an=(e,t)=>{const{bottom:n}=e.getBoundingClientRect(),r=ye(e),o=ve(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},ye=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:i,height:f}=s.getBoundingClientRect();if(f>0)return i}return e.getBoundingClientRect().top},Ye=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})}),Mr=e=>Ye[e],ge=()=>{const e=Y.useNavigate();return a.useCallback((t,n)=>{e(t,Ye[n])},[e])},cn=({navigation:e,...t})=>l.jsx(Y.Link,{...t,...Ye[e]}),Qe=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},dn=(e,t)=>{const n=a.useRef(null),r=a.useRef(null),o=a.useRef(null),s=a.useCallback(()=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,r.current=null},[]);a.useEffect(()=>s,[s]);const i=a.useCallback(m=>{if(r.current!==m)return;const u=o.current;if(u!==null){u.then(()=>i(m));return}e.prefetch(m);const p=e.peek(m);if(p?.status!=="pending")return;const E=Promise.allSettled([p.promise]);o.current=E,E.then(()=>{o.current===E&&(o.current=null)})},[e]),f=a.useCallback(m=>{const u=t(m);u!==r.current&&(s(),u!==null&&(r.current=u,n.current=window.setTimeout(()=>{n.current=null,i(u)},$.PREFETCH_DWELL_MS)))},[s,t,i]),h=a.useCallback(m=>{t(m)!==r.current&&s()},[s,t]);return a.useMemo(()=>({onPointerOver:m=>f(m.target),onPointerOut:m=>h(m.relatedTarget),onFocus:m=>f(m.target),onBlur:m=>h(m.relatedTarget)}),[f,h])},Ar=a.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-Ddn0iHjv.cjs")).then(e=>({default:e.NativeScrollBar})));class jr extends a.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 un=({scroller:e,withCircle:t})=>l.jsx(jr,{children:l.jsx(a.Suspense,{fallback:null,children:l.jsx(Ar,{scroller:e,withCircle:t})})}),fn=e=>l.jsx(un,{scroller:e,withCircle:!0}),mn=()=>{const e=new Map,t=new Set;let n=!1;const r=o=>{t.add(o),!n&&(n=!0,queueMicrotask(()=>{n=!1,t.clear()}))};return{hold:o=>{e.set(o,(e.get(o)??0)+1);let s=!1;return()=>{if(s)return;s=!0;const i=e.get(o);if(i!==void 0&&i>1){e.set(o,i-1);return}e.delete(o),r(o)}},isHeld:o=>e.has(o),resumes:o=>t.delete(o),heldKeys:()=>[...e.keys()]}},Se=(e,t)=>{if(Object.is(e,t))return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;if(Array.isArray(e)||Array.isArray(t))return!(Array.isArray(e)&&Array.isArray(t))||e.length!==t.length?!1:e.every((s,i)=>Se(s,t[i]));const n=e,r=t,o=Object.keys(n);return o.length!==Object.keys(r).length?!1:o.every(s=>Object.hasOwn(r,s)&&Se(n[s],r[s]))},Nr=55e3,ut=Object.freeze({status:"deferred"}),ft=Object.freeze({status:"refreshed"}),_e=Object.freeze({status:"superseded"}),re=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,hn=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",Dr=({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=mn(),o=ae(),s=new WeakSet;let i=0;const f=o.emit,h=()=>(i+=1,i),m=()=>{if(!(n.size<=t))for(const b of[...n.keys()]){if(n.size<=t)return;r.isHeld(b)||n.delete(b)}},u=(b,g)=>{n.delete(b),n.set(b,g)},p=b=>performance.now()-b.validatedAt>=Nr,E=(b,g,c)=>{const d=n.get(b),w=re(d?.snapshot),T=c||d?.refreshPending===!0,M=pe(e.document(b,{refresh:T}).then(F=>({status:"loaded",document:F}))),N={snapshot:{status:"pending",promise:M,previous:w},validatedAt:performance.now(),opened:g,background:null,refreshPending:!1,seeded:void 0,stamp:h()};return u(b,N),m(),M.then(F=>{n.get(b)===N&&(N.snapshot=F,N.stamp=h(),f())}),N},x=(b,g,c,d,w,T)=>{g.background===c&&(g.background=null,!(n.get(b)!==g||g.snapshot!==d)&&(w.kind==="failure"&&d.document.kind!=="failure"||(g.validatedAt=T,g.stamp=h(),Se(d.document,w)||(g.snapshot={status:"loaded",document:w}),f())))},C=async(b,g)=>{const c=g.snapshot;if(c.status!=="loaded")return null;const d={};g.background=d;const w=performance.now(),T=e.document(b,{refresh:g.refreshPending});g.refreshPending=!1;const M=await T,N=g.background===d&&n.get(b)===g&&g.snapshot===c;return x(b,g,d,c,M,w),N?M:null},O=(b,g)=>{const{snapshot:c}=g;return c.status==="pending"?!1:c.status==="loaded"&&c.document.kind!=="failure"?(C(b,g),!1):(c.status==="loaded"&&s.add(c),E(b,!0,!1),!0)},k=b=>{const g=r.hold(b);let c=!1;return()=>{if(c)return;c=!0,g();const d=n.get(b);d!==void 0&&u(b,d),m()}};return{peek:b=>n.get(b)?.snapshot,peekSeeded:b=>n.get(b)?.seeded,answerStampOf:b=>n.get(b)?.stamp,prefetch:b=>{const g=n.get(b);g!==void 0&&g.snapshot.status!=="deferred"||(E(b,!1,!1),f())},open:b=>{const g=r.resumes(b),c=k(b),d=n.get(b);if(d===void 0||d.snapshot.status==="deferred")return E(b,!0,!1),f(),c;if(u(b,d),g)return c;const{snapshot:w}=d;return w.status==="pending"?(d.opened=!0,c):w.document.kind==="failure"?(d.opened||p(d)?(s.add(w),E(b,!0,!1),f()):d.opened=!0,c):(d.opened=!0,d.background===null&&p(d)&&C(b,d),c)},retain:k,retry:b=>{const g=n.get(b);g===void 0||g.snapshot.status!=="loaded"||g.snapshot.document.kind!=="failure"||(E(b,!0,!1),f())},seed:(b,g)=>{const c=performance.now(),d=pe(g.then(F=>F===null?ut:{status:"loaded",document:F},()=>ut)),w=n.get(b);if(w!==void 0&&w.snapshot.status==="loaded"){const F=w.snapshot,z={};w.background=z,d.then(I=>{if(I.status==="loaded"){x(b,w,z,F,I.document,c);return}w.background===z&&(w.background=null)});return}const T=w!==void 0&&w.snapshot.status==="pending"?w.snapshot.previous:null,M={status:"pending",promise:d,previous:T},N={snapshot:M,validatedAt:c,opened:w?.opened===!0,background:null,refreshPending:w?.refreshPending===!0,seeded:M,stamp:h()};u(b,N),m(),d.then(F=>{n.get(b)===N&&(F.status==="deferred"&&r.isHeld(b)?E(b,N.opened,!1):(N.snapshot=F,N.stamp=h()),f())})},invalidate:()=>{let b=!1;for(const[g,c]of[...n]){if(c.validatedAt=Number.NEGATIVE_INFINITY,c.opened=!0,c.refreshPending=!0,!r.isHeld(g))continue;const{snapshot:d}=c;if(d.status!=="pending"){O(g,c)&&(b=!0);continue}d.promise.then(()=>{n.get(g)===c&&c.refreshPending&&r.isHeld(g)&&O(g,c)&&f()})}b&&f()},refresh:async b=>{const g=n.get(b);if(g!==void 0&&hn(g.snapshot)){g.refreshPending=!0;const d=await C(b,g);return d===null?_e:d.kind==="failure"?{status:"failed",failure:d.failure}:ft}const c=E(b,!0,!0);return f(),c.snapshot.status!=="pending"?_e:(await c.snapshot.promise,n.get(b)===c?ft:_e)},clear:()=>{n.clear();for(const b of r.heldKeys())E(b,!0,!1);f()},subscribe:o.subscribe,noteFailureShown:b=>s.has(b)?!1:(s.add(b),!0)}};function Pr({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"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"}),y.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 _r=y.forwardRef(Pr);function Fr({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"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"}),y.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 $r=y.forwardRef(Fr);function qr({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"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 Ir=y.forwardRef(qr),Br=2e3,mt=Object.freeze({outcome:"idle"}),Hr=e=>{const t=navigator.clipboard;return t===void 0?Promise.reject(new Error("[markdown-explorer] this browser has no asynchronous clipboard")):t.writeText(e)},Vr=({text:e})=>{const{announcer:t,labels:n}=P(),[r,o]=a.useState(mt);a.useEffect(()=>{if(r.outcome==="idle")return;const h=setTimeout(()=>o(mt),Br);return()=>clearTimeout(h)},[r]);const s=h=>{o({outcome:h}),t.announce(h==="copied"?n.copiedText:n.copyTextFailed)},i=()=>{Hr(e).then(()=>s("copied"),()=>s("failed"))},f=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:f,onClick:i,"data-aqmx-copy-outcome":r.outcome,"data-testid":"markdown-explorer-file-copy",children:r.outcome==="copied"?l.jsx(_r,{}):r.outcome==="failed"?l.jsx(Ir,{}):l.jsx($r,{})})},le=a.createContext("fill"),Ur=Object.freeze({blockSize:"100%"}),ce=({scrollerProps:e,children:t})=>a.use(le)==="content"?l.jsx(me.HostedScrollArea,{scrollerProps:e,children:t}):l.jsx(me.HostedScrollArea,{scrollerProps:{...e,style:Ur},rowClassName:"aqmx-document-scroll-row",renderScrollBar:fn,children:t});function zr({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M10.75 2.75a.75.75 0 0 0-1.5 0v8.614L6.295 8.235a.75.75 0 1 0-1.09 1.03l4.25 4.5a.75.75 0 0 0 1.09 0l4.25-4.5a.75.75 0 0 0-1.09-1.03l-2.955 3.129V2.75Z"}),y.createElement("path",{d:"M3.5 12.75a.75.75 0 0 0-1.5 0v2.5A2.75 2.75 0 0 0 4.75 18h10.5A2.75 2.75 0 0 0 18 15.25v-2.5a.75.75 0 0 0-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5Z"}))}const Zr=y.forwardRef(zr);function Gr({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.25 5.5a.75.75 0 0 0-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75v-4a.75.75 0 0 1 1.5 0v4A2.25 2.25 0 0 1 12.75 17h-8.5A2.25 2.25 0 0 1 2 14.75v-8.5A2.25 2.25 0 0 1 4.25 4h5a.75.75 0 0 1 0 1.5h-5Z",clipRule:"evenodd"}),y.createElement("path",{fillRule:"evenodd",d:"M6.194 12.753a.75.75 0 0 0 1.06.053L16.5 4.44v2.81a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.553l-9.056 8.194a.75.75 0 0 0-.053 1.06Z",clipRule:"evenodd"}))}const Kr=y.forwardRef(Gr),Te=({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(Kr,{})}),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(Zr,{})})]})};function Wr({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm4.75 6.75a.75.75 0 0 1 1.5 0v2.546l.943-1.048a.75.75 0 0 1 1.114 1.004l-2.25 2.5a.75.75 0 0 1-1.114 0l-2.25-2.5a.75.75 0 1 1 1.114-1.004l.943 1.048V8.75Z",clipRule:"evenodd"}))}const Xr=y.forwardRef(Wr),Yr=Object.freeze({className:"aqmx-document-stage"}),Qr=({document:e})=>{const{labels:t}=P();return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[l.jsx(Te,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(Xr,{})}),l.jsx(ce,{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})]})})]})},Oe="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",Jr=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},eo=/(%[0-9A-Fa-f]{2})/u,Je=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(eo).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))},pn=e=>`#${encodeURIComponent(e)}`,to=e=>{if(e==="#")return!0;const t=Je(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},vn=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},no="http://www.w3.org/1999/xhtml",ht=(e,t)=>{if(t==="")return null;const n=vn(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===no&&r.getAttribute("name")===t)return r;return null},gn=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=ht(e,t.slice(1));if(n!==null)return n;const r=Je(t);return r===null?null:ht(e,r)},pt=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"},ro=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"},oo=(e,t)=>{const n=t.closest(Oe),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&pt(r))return r;const o=e.getBoundingClientRect().height,{documentElement:s,scrollingElement:i}=e.ownerDocument;for(let f=e.parentElement;f!==null&&f!==s;f=f.parentElement)if(pt(f)&&f.scrollHeight>f.clientHeight&&f.clientHeight<o)return f;return i instanceof Element&&ro(e.ownerDocument)&&i.scrollHeight>i.clientHeight&&i.clientHeight<o?i:r},so=Object.freeze({scrollerOf:oo,reveal:e=>{e.scrollIntoView(Ue)}}),Ue=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),io=(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")}}},lo=(e,t)=>{if(t.getClientRects().length===0)return;const n=e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,{scrollMarginTop:r,scrollMarginBottom:o}=getComputedStyle(t),s=Number.parseFloat(r),i=t.getBoundingClientRect(),f=i.height+s+Number.parseFloat(o)>e.clientHeight;if(!f&&Math.abs(i.top-s-n)<1){t.scrollIntoView(Ue);return}e.scrollBy({top:f?i.top-n-e.clientHeight:i.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(Ue)},ao=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(Oe)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},vt=(e,t,n)=>{if(e===null)return null;const r=gn(e,t);return r===null?(to(t)&&ao(e,n),null):(io(e,r),lo(n.scrollerOf(e,r),r),n.reveal(r),r)};function co({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M3.28 2.22a.75.75 0 0 0-1.06 1.06L5.44 6.5H2.75a.75.75 0 0 0 0 1.5h4.5A.75.75 0 0 0 8 7.25v-4.5a.75.75 0 0 0-1.5 0v2.69L3.28 2.22ZM13.5 2.75a.75.75 0 0 0-1.5 0v4.5c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-2.69l3.22-3.22a.75.75 0 0 0-1.06-1.06L13.5 5.44V2.75ZM3.28 17.78l3.22-3.22v2.69a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.69l-3.22 3.22a.75.75 0 1 0 1.06 1.06ZM13.5 14.56l3.22 3.22a.75.75 0 1 0 1.06-1.06l-3.22-3.22h2.69a.75.75 0 0 0 0-1.5h-4.5a.75.75 0 0 0-.75.75v4.5a.75.75 0 0 0 1.5 0v-2.69Z"}))}const uo=y.forwardRef(co);function fo({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M6.75 8.25a.75.75 0 0 0 0 1.5h4.5a.75.75 0 0 0 0-1.5h-4.5Z"}),y.createElement("path",{fillRule:"evenodd",d:"M9 2a7 7 0 1 0 4.391 12.452l3.329 3.328a.75.75 0 1 0 1.06-1.06l-3.328-3.329A7 7 0 0 0 9 2ZM3.5 9a5.5 5.5 0 1 1 11 0 5.5 5.5 0 0 1-11 0Z",clipRule:"evenodd"}))}const mo=y.forwardRef(fo);function ho({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M9 6a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0v-1.5h-1.5a.75.75 0 0 1 0-1.5h1.5v-1.5A.75.75 0 0 1 9 6Z"}),y.createElement("path",{fillRule:"evenodd",d:"M2 9a7 7 0 1 1 12.452 4.391l3.328 3.329a.75.75 0 1 1-1.06 1.06l-3.329-3.328A7 7 0 0 1 2 9Zm7-5.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11Z",clipRule:"evenodd"}))}const po=y.forwardRef(ho);function vo({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M1 5.25A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25v9.5A2.25 2.25 0 0 1 16.75 17H3.25A2.25 2.25 0 0 1 1 14.75v-9.5Zm1.5 5.81v3.69c0 .414.336.75.75.75h13.5a.75.75 0 0 0 .75-.75v-2.69l-2.22-2.219a.75.75 0 0 0-1.06 0l-1.91 1.909.47.47a.75.75 0 1 1-1.06 1.06L6.53 8.091a.75.75 0 0 0-1.06 0l-2.97 2.97ZM12 7a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",clipRule:"evenodd"}))}const go=y.forwardRef(vo),ze="data-aqmx-key-repeat",ke=Object.freeze({[ze]:"allow"}),wo=`[${ze}="${ke[ze]}"]`,Eo=()=>{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(wo)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},xe=Object.freeze([1/$.GOLDEN_RATIO**2,1/$.GOLDEN_RATIO,1,$.GOLDEN_RATIO,$.GOLDEN_RATIO**2]),gt=Object.freeze({mode:"fit"}),xo=1,wn=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),wt=`[data-testid="${wn["data-testid"]}"]`,En=a.createContext(null),bo=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=xo?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,Et=(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},xt=(e,t,n)=>{if(e.mode==="level"){const o=Et(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=Et(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},yo=(e,t)=>{if(e<=0||t<=0)return 0;const n=Math.trunc(Math.log(t/e)/Math.log($.GOLDEN_RATIO));return n===0?0:n},bt=e=>{const t=e[0],n=e[1];return e.length!==2||t===void 0||n===void 0?null:{distance:Math.hypot(n.clientX-t.clientX,n.clientY-t.clientY),middle:{x:(t.clientX+n.clientX)/2,y:(t.clientY+n.clientY)/2}}},So=e=>{const t=xe[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},yt=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},ko=({document:e})=>{const{labels:t}=P(),n=a.use(En),[r]=a.useState(()=>n===null?null:n.read(e.url)),[o,s]=a.useState(r===null?gt:r.zoom),[i,f]=a.useState(r===null?null:r.reported),[h,m]=a.useState(null),u=a.useRef(null),p=a.useCallback(g=>{const{naturalWidth:c,naturalHeight:d}=g;f(w=>yt(w,c,d))},[]),E=a.useCallback(g=>{u.current=g,!(g===null||!g.complete)&&(g.naturalWidth>0||g.naturalHeight>0?p(g):g.decode().then(()=>p(g),()=>{}))},[p]);a.useEffect(()=>{n!==null&&i!==null&&n.save(e.url,{zoom:o,reported:i})},[n,e.url,o,i]),a.useLayoutEffect(()=>{const g=u.current;if(g===null||i===null||o.mode!=="fit")return;const c=()=>m(w=>yt(w,g.clientWidth,g.clientHeight));if(c(),typeof ResizeObserver>"u")return;const d=new ResizeObserver(c);return d.observe(g),()=>d.disconnect()},[i,o.mode]);const x=i===null||h===null?null:bo(i,h),C=xt(o,x,-1),O=xt(o,x,1),k=o.mode==="level"?So(o.index):null,j=a.useRef({zoomIn:O,zoomOut:C});a.useLayoutEffect(()=>{j.current={zoomIn:O,zoomOut:C}});const A=a.useRef(null);a.useLayoutEffect(()=>{const g=A.current,c=u.current?.closest(wt);A.current=null,!(g===null||c===null||c===void 0)&&(c.scrollLeft=g.across*c.scrollWidth-g.x,c.scrollTop=g.down*c.scrollHeight-g.y)},[o]),a.useEffect(()=>{const g=u.current?.closest(wt);if(g==null)return;let c=null;const d=M=>{const N=bt(M.touches);c=N===null?null:{distance:N.distance,steps:0}},w=M=>{const N=bt(M.touches);if(c===null||N===null)return;M.preventDefault();const F=yo(c.distance,N.distance);if(F===c.steps)return;const z=F>c.steps?1:-1,I=z===1?j.current.zoomIn:j.current.zoomOut;if(I===null)return;c.steps+=z;const B=g.getBoundingClientRect(),K=N.middle.x-B.left,H=N.middle.y-B.top;A.current=g.scrollWidth>0&&g.scrollHeight>0?{x:K,y:H,across:(g.scrollLeft+K)/g.scrollWidth,down:(g.scrollTop+H)/g.scrollHeight}:null,s(I)},T=M=>{M.touches.length<2&&(c=null)};return g.addEventListener("touchstart",d,{passive:!0}),g.addEventListener("touchmove",w,{passive:!1}),g.addEventListener("touchend",T,{passive:!0}),g.addEventListener("touchcancel",T,{passive:!0}),()=>{g.removeEventListener("touchstart",d),g.removeEventListener("touchmove",w),g.removeEventListener("touchend",T),g.removeEventListener("touchcancel",T)}},[]);const b=o.mode==="level"&&k!==null?{width:`${o.base.width*k}px`,height:`${o.base.height*k}px`}:void 0;return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[l.jsxs(Te,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(go,{}),children:[l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":C===null,onClick:()=>{C!==null&&s(C)},...ke,children:l.jsx(mo,{})}),l.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:k===null?t.imageFitLevel:t.imageZoomLevel(Math.round(k*100))}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":O===null,onClick:()=>{O!==null&&s(O)},...ke,children:l.jsx(po,{})}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(gt),children:l.jsx(uo,{})})]}),l.jsx(ce,{scrollerProps:wn,children:l.jsx("img",{ref:E,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:b,onLoad:g=>p(g.currentTarget),"data-testid":"markdown-explorer-image"})})]})},xn=a.createContext(null),Ce=a.createContext(void 0),bn=a.createContext(null),Le=()=>{const e=a.use(xn);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},Ro=()=>{const e=a.use(bn);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},Me=(e,t,n,r)=>t.kind==="panel"?$.explorerHref(e,{view:"tree",source:n,doc:r}):t.view==="single"?$.explorerHref(e,{view:"single",source:n,doc:r,overrides:t.overrides,embed:t.embed}):$.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides}),To=({children:e})=>{const{config:t}=P(),n=Le(),r=Re(),o=r.kind==="location"?r.location.source:void 0,s=Y.useHref(Me(t,n.navigation,o,n.currentPath));return l.jsx(Ce,{value:o,children:l.jsx(bn,{value:s,children:e})})},Oo='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',Co=e=>{const t=e instanceof Element?e.closest(Oo):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,Lo=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:i,scope:f,children:h})=>{const m=Y.useHref(e),u=p=>{if(Ae(p)){if(p.preventDefault(),t===f.currentPath&&n!==""){f.scrollWithin(n);return}i(t,n)}};return l.jsx("a",{...s,href:m,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:u,children:h})},Mo=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:i}=P(),f=Le(),h=a.use(Ce),m=Jr(e),{navigation:u}=f,p=`${Me(i,u,h,t)}${m}`,E=n===!1?"false":void 0;return u.kind==="page"?l.jsx(cn,{...o,to:p,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":E,children:s}):l.jsx(Lo,{to:p,docPath:t,fragment:m,exists:E,className:r,attributes:o,onDocumentLink:u.onDocumentLink,scope:f,children:s})},Ao=({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,")"]})]})},jo=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=P(),i=a.use(Ce),f=Y.useHref(`${Me(s,r.navigation,i,r.currentPath)}${e}`),h=m=>{Ae(m)&&(m.preventDefault(),r.scrollWithin(e))};return l.jsx("a",{...n,href:f,className:t,onClick:h,children:o})},No=({href:e,className:t,attributes:n,children:r})=>{const o=Le();if(o.navigation.kind==="page"){const s=i=>{if(!Ae(i))return;const f=i.currentTarget;e==="#"?o.followEmptyFragment(i.nativeEvent):f.href===f.ownerDocument.URL&&o.followSameUrlJump(e,i.nativeEvent)};return l.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return l.jsx(jo,{href:e,className:t,attributes:n,scope:o,children:r})},Do=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:i})=>t==="doc"?n===void 0||!D.isAcceptableDocumentPath(n)?l.jsx(Ao,{className:o,attributes:s,children:i}):l.jsx(Mo,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:i}):e.startsWith("#")?l.jsx(No,{href:e,className:o,attributes:s,children:i}):l.jsx("a",{...s,href:e,className:o,children:i}),Po=()=>{const{config:e}=P(),t=Le(),n=a.use(Ce),r=ge();return a.useCallback((o,s)=>{if(!Ae(s))return!0;s.preventDefault();const i=pn(o.id),{navigation:f}=t;return f.kind==="panel"||Je(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(i),!0):(r(`${Me(e,f,n,t.currentPath)}${i}`,"follow-link"),!0)},[e,t,n,r])},_o=()=>{const e=Ro();return a.useCallback(t=>`${e}${pn(t.id)}`,[e])};function Fo({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M3 3.5A1.5 1.5 0 0 1 4.5 2h6.879a1.5 1.5 0 0 1 1.06.44l4.122 4.12A1.5 1.5 0 0 1 17 7.622V16.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 16.5v-13Z"}))}const $o=y.forwardRef(Fo);function qo({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M1 4.75C1 3.784 1.784 3 2.75 3h14.5c.966 0 1.75.784 1.75 1.75v10.515a1.75 1.75 0 0 1-1.75 1.75h-1.5c-.078 0-.155-.005-.23-.015H4.48c-.075.01-.152.015-.23.015h-1.5A1.75 1.75 0 0 1 1 15.265V4.75Zm16.5 7.385V11.01a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25Zm0 2.005a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .108.069.2.165.235h1.585a.25.25 0 0 0 .25-.25v-1.11Zm-15 1.11v-1.11a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.164.235H2.75a.25.25 0 0 1-.25-.25Zm2-4.24v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V11.01a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25Zm13-2.005V7.88a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25ZM4.25 7.63a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V7.88a.25.25 0 0 1 .25-.25h1.5Zm0-3.13a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5Zm11.5 1.625a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5Zm-9 3.125a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",clipRule:"evenodd"}))}const Io=y.forwardRef(qo);function Bo({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M17.721 1.599a.75.75 0 0 1 .279.583v11.29a2.25 2.25 0 0 1-1.774 2.2l-2.041.44a2.216 2.216 0 0 1-.938-4.332l2.662-.577a.75.75 0 0 0 .591-.733V6.112l-8 1.73v7.684a2.25 2.25 0 0 1-1.774 2.2l-2.042.44a2.216 2.216 0 1 1-.935-4.331l2.659-.573A.75.75 0 0 0 7 12.529V4.236a.75.75 0 0 1 .591-.733l9.5-2.054a.75.75 0 0 1 .63.15Z",clipRule:"evenodd"}))}const Ho=y.forwardRef(Bo),Vo=Object.freeze({className:"aqmx-document-stage"}),Uo=()=>()=>{},zo=()=>navigator.pdfViewerEnabled!==!1,Zo=()=>null,Go=({document:e})=>{const{labels:t}=P(),n=a.useSyncExternalStore(Uo,zo,Zo);return n===null?null:n?l.jsx("iframe",{className:"aqmx-document-frame",src:e.url,title:e.name,"data-testid":"markdown-explorer-media-player"}):l.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-pdf-not-shown",children:[l.jsx("p",{className:"aqmx-callout-body",children:t.pdfNotShown}),l.jsxs("div",{className:"aqmx-callout-actions",children:[l.jsx("a",{className:"aqmx-callout-action",href:e.url,target:"_blank",rel:"noopener noreferrer","data-testid":"markdown-explorer-pdf-not-shown-open",children:t.openInNewTab}),l.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-pdf-not-shown-download",children:t.download})]})]})},Ko=e=>{switch(e){case"video":return l.jsx(Io,{});case"audio":return l.jsx(Ho,{});case"pdf":return l.jsx($o,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},Wo=({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(Go,{document:e});default:{const n=e.mediaType;throw new RangeError(`[markdown-explorer] unknown media type ${String(n)}`)}}},Xo=({document:e})=>l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[l.jsx(Te,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:Ko(e.mediaType)}),l.jsx(ce,{scrollerProps:Vo,children:l.jsx(Wo,{document:e})})]}),Yo=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,mermaidInteractionModeTouch:e.viewerMermaidInteractionModeTouch,mermaidModeNone:e.viewerMermaidModeNone,mermaidModeZoom:e.viewerMermaidModeZoom,mermaidModePan:e.viewerMermaidModePan,mermaidModePanShift:e.viewerMermaidModePanShift,mermaidModeBoth:e.viewerMermaidModeBoth,mermaidModeBothShift:e.viewerMermaidModeBothShift,mermaidModeNoneTouch:e.viewerMermaidModeNoneTouch,mermaidModeZoomTouch:e.viewerMermaidModeZoomTouch,mermaidModePanTouch:e.viewerMermaidModePanTouch,mermaidModeBothTouch:e.viewerMermaidModeBothTouch,mermaidZoomIn:e.viewerMermaidZoomIn,mermaidZoomOut:e.viewerMermaidZoomOut,mermaidResetView:e.viewerMermaidResetView,mermaidPanUp:e.viewerMermaidPanUp,mermaidPanDown:e.viewerMermaidPanDown,mermaidPanLeft:e.viewerMermaidPanLeft,mermaidPanRight:e.viewerMermaidPanRight,mermaidDiagram:e.viewerMermaidDiagram,mermaidRetry:e.viewerMermaidRetry,embeddedVideo:e.viewerEmbeddedVideo,embeddedPost:e.viewerEmbeddedPost,embeddedFrame:e.viewerEmbeddedFrame}),yn=(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},Sn=(e,t)=>e!==void 0?e:t!==void 0?t:Bn.DEFAULT_CONTENT_ALIGN,kn=Object.freeze({kind:"empty"}),et=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),Qo=(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 $.explorerHref(e,{...t,overrides:r})},fe=({kind:e,view:t,label:n,stale:r,busy:o,frameRef:s,intent:i,children:f})=>{const h=a.use(le);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":h,className:"aqmx-document",...i,children:[r?l.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,f]})},Jo=({absence:e,announces:t,announceFailure:n})=>{const{labels:r,announcer:o}=P(),s=e.kind==="no-readme"?e.folder:null,i=e.kind==="failure"?e.folder:null,f=e.kind==="failure"?e.failure:null;switch(a.useEffect(()=>{t&&s!==null&&o.announce(r.folderReadmeMissing(D.lastPathSegment(s)))},[t,s,o,r]),a.useEffect(()=>{i!==null&&f!==null&&n(r.documentFailed(D.lastPathSegment(i),ee(r,f.reason)))},[i,f,n,r]),e.kind){case"empty":return l.jsx(fe,{kind:"empty",label:r.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:r.documentEmpty})})});case"loading":return l.jsx(tt,{label:r.documentRegion});case"no-readme":return l.jsx(fe,{kind:"empty",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-folder-empty",children:l.jsx("p",{className:"aqmx-empty-title",children:r.folderReadmeMissing(D.lastPathSegment(e.folder))})})});case"failure":return l.jsx(fe,{kind:"failure",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx(ce,{scrollerProps:nt,children:l.jsx(se,{failure:e.failure,alert:!1,onRetry:e.onRetry,testId:"markdown-explorer-folder-failure"})})})}},tt=({label:e})=>{const{labels:t}=P();return l.jsxs(fe,{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:et.map(n=>l.jsx("span",{},n))}),l.jsx("p",{className:"aqmx-sr-only",children:t.documentLoading})]})},St=Object.freeze(["wheel","touchstart","pointerdown","keydown"]),es=({path:e,document:t,viewer:n,editing:r})=>{const{reportMathDiagnostics:o,edits:s}=P(),i=a.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),f=Po(),h=_o(),m=a.useMemo(()=>o===void 0?void 0:c=>o(e,c),[o,e]),u=a.useRef(null),{editable:p,doubleClick:E,region:x,paneScroll:C,stale:O}=r;a.useLayoutEffect(()=>{if(p)return s.bindView(e,{anchor:()=>{const c=u.current,d=x(),w=c===null?null:c.querySelector(Oe);return c===null||d===null||w===null?null:rn(c,C.scrollerOf(d,w))}})},[s,e,p,x,C]);const k=c=>{const d=u.current,{target:w}=c;!E||d===null||!(w instanceof Element)||!tn(w)||(c.stopPropagation(),s.start(e,nn(w,d,d.ownerDocument.getSelection())))},j=a.useRef(null),A=a.useRef(O);a.useLayoutEffect(()=>{A.current=O});const b=a.useEffectEvent(c=>{const d=u.current,w=x(),T=d===null?null:ln(d,c.line);if(w===null||T===null)return!1;const M=C.scrollerOf(w,T);return M.scrollTop+=an(T,c.line)-c.clientTop,!0}),g=a.useEffectEvent(c=>{const d=x();if(d===null)return;const w=()=>{for(const M of St)d.removeEventListener(M,T,!0);j.current?.release===w&&(j.current=null)},T=()=>w();for(const M of St)d.addEventListener(M,T,{capture:!0,passive:!0});j.current={point:c,release:w}});return a.useLayoutEffect(()=>{const c=s.takeReturn(e);if(c!==null)return queueMicrotask(()=>{b(c)&&A.current&&g(c)}),()=>j.current?.release()},[s,e]),a.useLayoutEffect(()=>{const c=j.current;c===null||O||(c.release(),b(c.point))},[t,O]),l.jsx("div",{ref:u,className:"aqmx-document-viewer",onDoubleClick:k,children:l.jsx(me.MarkdownViewer,{...n,onHeadingSelect:f,headingHref:h,onMathDiagnostics:m,parseResult:i,content:null})})},Rn=({document:e,viewer:t})=>{const{labels:n}=P();return l.jsxs(l.Fragment,{children:[l.jsx(Te,{name:e.name,openUrl:D.explorerPlainTextHref(e.url),downloadUrl:e.url,icon:l.jsx(wr,{}),children:e.truncated?null:l.jsx(Vr,{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(me.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},ts=({path:e,name:t,viewer:n})=>{const{data:r,documents:o,announcer:s,labels:i}=P(),f=a.useCallback(()=>o.answerStampOf(e),[o,e]),h=a.useSyncExternalStore(o.subscribe,f,f),[m,u]=a.useState(0),p=a.useMemo(()=>({path:e,stamp:h,attempt:m}),[e,h,m]),[E,x]=a.useState(null),C=a.useEffectEvent(k=>{x(k),k.kind==="failure"&&s.announce(i.documentFailed(t,ee(i,k.failure.reason)))});a.useEffect(()=>{const k=new AbortController;return r.text(p.path,k.signal).then(j=>{"kind"in j&&C(j)}),()=>k.abort()},[r,p]);const O=a.useCallback(()=>u(k=>k+1),[]);return E===null?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-markup-skeleton",children:et.map(k=>l.jsx("span",{},k))}),l.jsx("p",{className:"aqmx-sr-only",children:i.markupLoading})]}):E.kind==="failure"?l.jsx(ce,{scrollerProps:nt,children:l.jsx(se,{failure:E.failure,alert:!1,onRetry:O,testId:"markdown-explorer-markup-failure"})}):l.jsx(Rn,{document:E,viewer:n})},nt=Object.freeze({className:"aqmx-document-failure","data-aqmx-document-scroller":""}),ns=Object.freeze({reason:"failed"}),rs=e=>l.jsx(br,{fallback:t=>l.jsx("div",{className:"aqmx-edit-message",children:l.jsx(se,{failure:ns,alert:!1,onRetry:t,testId:"markdown-explorer-edit-load-failure"})}),children:l.jsx(a.Suspense,{fallback:l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-edit-skeleton",children:et.map(t=>l.jsx("span",{},t))}),children:l.jsx(xr,{...e})})}),os=({path:e,document:t,view:n,viewer:r,onRetry:o,editing:s})=>{switch(t.kind){case"markdown":{const{session:i,layout:f,region:h,paneScroll:m,stale:u}=s;if(n==="edit"&&i!==void 0)return l.jsx(rs,{path:e,name:t.name,session:i,layout:f,viewer:r,region:h,paneScroll:m});if(n==="markup")return l.jsx(ts,{path:e,name:t.name,viewer:r});const p=t.edit!==null&&(t.edit.kind==="inline"||t.edit.kind==="draft");return l.jsx(es,{path:e,document:t,viewer:r,editing:{editable:p,doubleClick:p&&f==="fill",region:h,paneScroll:m,stale:u}})}case"text":return l.jsx(Rn,{document:t,viewer:r});case"image":return l.jsx(ko,{document:t});case"media":return l.jsx(Xo,{document:t});case"file":return l.jsx(Qr,{document:t});case"failure":return l.jsx(ce,{scrollerProps:nt,children:l.jsx(se,{failure:t.failure,alert:!1,onRetry:o,testId:"markdown-explorer-document-failure"})});default:{const i=t;throw new RangeError(`[markdown-explorer] unknown document kind in ${JSON.stringify(i)}`)}}},ss='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',is=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:gn(e,n),r===void 0?null:vn(e,r.id),e.querySelector(Oe),e.querySelector(ss)];for(const s of o)if(s instanceof HTMLElement&&Qe(s))return s;return null},kt=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&Qe(t)},ls=e=>{const t=a.useRef(!1);return a.useLayoutEffect(()=>{const n=e.current;if(n===null)throw new Error("[markdown-explorer] the document region is not mounted");const r=n.ownerDocument,o=r.defaultView;if(o===null)throw new Error("[markdown-explorer] the document region's document has no window");let s=!1,i;const f=E=>{s=!(E.target instanceof Node&&n.contains(E.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(i),i=setTimeout(()=>{s=!1},0)},h=E=>{t.current=E.target instanceof Node&&n.contains(E.target)},m=E=>{E.relatedTarget===null&&s&&(t.current=!1)},u=()=>{const{activeElement:E,body:x}=r;E!==null&&E!==x&&(t.current=n.contains(E))},p=()=>{s&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",f,!0),o.addEventListener("mousedown",f,!0),o.addEventListener("focusin",h,!0),o.addEventListener("blur",u),o.addEventListener("focus",p),n.addEventListener("focusout",m),()=>{clearTimeout(i),o.removeEventListener("pointerdown",f,!0),o.removeEventListener("mousedown",f,!0),o.removeEventListener("focusin",h,!0),o.removeEventListener("blur",u),o.removeEventListener("focus",p),n.removeEventListener("focusout",m)}},[e]),t},as=({path:e,snapshot:t,markup:n,stale:r,viewer:o,editLayout:s,regionLabel:i,navigation:f,fragment:h,paneScroll:m,announces:u,announceFailure:p,onDocumentShown:E})=>{const{labels:x,announcer:C,documents:O}=P(),{document:k}=t,j=a.useRef(null),A=a.useRef(null),b=a.useRef(null),g=a.useRef(0),c=ls(j),d=a.useRef({path:e,document:k}),w=a.useRef(null),T=a.useCallback(U=>{const G=j.current,W=vt(G,U,m);G!==null&&W!==null&&kt(G,W,c.current)},[m,c]),M=a.useCallback((U,G)=>{const W=g.current;setTimeout(()=>{!G.defaultPrevented&&g.current===W&&T(U)},0)},[T]),N=a.useCallback(U=>{setTimeout(()=>{U.defaultPrevented||T("#")},0)},[T]),F=a.useMemo(()=>({navigation:f,currentPath:e,scrollWithin:T,followSameUrlJump:M,followEmptyFragment:N}),[f,e,T,M,N]),z=a.useCallback(()=>O.retry(e),[O,e]),I=dn(O,Co),B=Yt(e),K=B!==void 0?"edit":n?"markup":"rendered",H=k.kind==="markdown"?K:void 0,Q=a.useCallback(()=>j.current,[]),v=a.useMemo(()=>({session:B,layout:s,region:Q,paneScroll:m,stale:r}),[B,s,Q,m,r]),S=H==="edit"?!1:r,R=a.use(le),L=H==="edit"&&s==="fill"?"fill":R,_=a.useEffectEvent((U,G)=>{const W=A.current;if(W!==null&&W.path===U&&W.snapshot===G)return;A.current={path:U,snapshot:G};const J=G.document;if(J.kind==="failure"){O.noteFailureShown(G)&&p(x.documentFailed(D.lastPathSegment(U),ee(x,J.failure.reason)));return}E?.(U,J),u&&(W===null||W.path!==U||W.snapshot.document.kind==="failure")&&C.announce(x.documentShown(J.name))});a.useEffect(()=>{_(e,t)},[e,t]);const q=a.useEffectEvent(()=>{h.kind==="panel"&&h.consume()}),Z=a.useEffectEvent(U=>{const G=j.current;if(G===null||!c.current)return null;const{activeElement:W,body:J}=G.ownerDocument;return W!==null&&W!==J?null:is(G,k,U)}),V=a.useEffectEvent(U=>{const G=j.current;G!==null&&kt(G,U,c.current)}),te=a.useEffectEvent(U=>m.reveal(U)),ot=a.useEffectEvent(U=>vt(j.current,U,m));return a.useEffect(()=>{if(r)return;const U=d.current.path!==e,G=U||d.current.document!==k;d.current={path:e,document:k};const W=w.current!==e;w.current=e;let J=null;h.kind==="page"?b.current!==h.navigation&&(b.current=h.navigation,g.current+=1,J=h.fragment):h.fragment!==null&&(J=h.fragment,q());const st=()=>{const je=J===null?null:ot(J);if(!G){je!==null&&V(je);return}const it=Z(h.fragment);U&&je===null&&it!==null&&te(it)};W?queueMicrotask(st):st()},[h,e,k,r]),l.jsx(le,{value:L,children:l.jsx(fe,{kind:k.kind,view:H,label:i(e,k),stale:S,busy:S,frameRef:j,intent:I,children:l.jsx(xn,{value:F,children:l.jsx(To,{children:l.jsx(os,{path:e,document:k,view:K,viewer:o,onRetry:z,editing:v},e)})})})})},rt=Object.freeze({kind:"skeleton"}),cs=(e,t,n,r,o)=>{if(t?.status==="loaded")return{kind:"document",path:e,snapshot:t,stale:!1};const s=re(t);if(s!==null)return{kind:"document",path:e,snapshot:s,stale:!0};if(o&&t?.status==="pending")return{kind:"streaming",path:e,promise:t.promise};const i=n===null||n===e?null:re(r);return n===null||i===null?rt:{kind:"document",path:n,snapshot:i,stale:!0}},ds=(e,t)=>t.status==="deferred"?rt:{kind:"document",path:e,snapshot:t,stale:!1},us=({requestedPath:e,content:t,markup:n,...r})=>{const o=t.kind==="streaming"?ds(t.path,a.use(t.promise)):t;return o.kind!=="document"?l.jsx(tt,{label:r.regionLabel(e,null)}):l.jsx(as,{path:o.path,snapshot:o.snapshot,markup:n,stale:o.stale,...r})},Tn=({path:e,absence:t,markup:n,display:r,navigation:o,fragment:s,paneScroll:i,announces:f,announceFailure:h,onDocumentShown:m})=>{const{config:u,labels:p,theme:E,documents:x}=P(),C=me.useMarkdownToolbarState(),O=a.useRef(!1);a.useLayoutEffect(()=>{O.current=!0},[]);const[k,j]=a.useState(null),[A,b]=a.useState(n),g=a.useCallback(()=>e===null?void 0:x.peek(e),[x,e]),c=a.useSyncExternalStore(x.subscribe,g,g),d=a.useCallback(()=>k===null?void 0:x.peek(k),[x,k]),w=a.useSyncExternalStore(x.subscribe,d,d);a.useLayoutEffect(()=>e===null?void 0:x.open(e),[x,e]),a.useLayoutEffect(()=>k===null?void 0:x.retain(k),[x,k]);const T=e===null?rt:cs(e,c,k,w,!O.current),M=e===null?null:T.kind==="document"&&!T.stale?T.path:k;M!==k&&j(M);const N=T.kind!=="document"||T.path===e;N&&n!==A&&b(n);const F=a.useMemo(()=>Yo(p),[p]),z=a.useMemo(()=>[...u.iframeHosts],[u]),I=o.kind==="panel",B=a.useMemo(()=>({labels:F,emptyMessage:p.documentEmpty,theme:E,availableStyles:u.documentStyles,iFrameAllowedDomains:z,embeds:u.embeds,linkComponent:Do,toolbar:C,style:r.style,onStyleChange:r.onStyleChange,align:r.align,onAlignChange:r.onAlignChange,showToc:r.showToc,showStyle:r.showStyle,showAlign:r.showAlign,padding:r.padding,width:r.width===void 0?void 0:`min(${r.width}, 100%)`,maxWidth:r.maxWidth===void 0?void 0:`min(${r.maxWidth}, 100%)`,renderScrollBar:I?void 0:fn}),[F,p.documentEmpty,E,u.documentStyles,z,u.embeds,C,r,I]),K=a.useCallback((Q,v)=>I?v===null||v.kind==="failure"?D.lastPathSegment(Q):v.name:p.documentRegion,[I,p.documentRegion]),H=I?"content":"fill";return e===null?l.jsx(le,{value:H,children:l.jsx(Jo,{absence:t,announces:f,announceFailure:h})}):l.jsx(le,{value:H,children:l.jsx(a.Suspense,{fallback:l.jsx(tt,{label:K(e,null)}),children:l.jsx(us,{requestedPath:e,content:T,markup:N?n:A,viewer:B,editLayout:r.editLayout,regionLabel:K,navigation:o,fragment:s,paneScroll:i,announces:f,announceFailure:h,onDocumentShown:m})})})},fs=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:i,announcer:f}=P(),h=he(M=>M.style),m=he(M=>M.align),u=ge(),p=Y.useLocation(),E=Re(),{view:x,overrides:C,embed:O}=r,k=a.useCallback(M=>{if(E.kind!=="location")return;const N=Qo(s,E.location,M);N!==null&&u(N,"browse")},[s,u,E]),j=a.useCallback(M=>{i.update({style:M}),k("style")},[i,k]),A=a.useCallback(M=>{i.update({align:M}),k("align")},[i,k]),b=yn(s,C.style,h),g=Sn(C.align,m),c=a.useMemo(()=>({style:b,onStyleChange:j,align:g,onAlignChange:A,showToc:O.showToc!==!1,showStyle:O.showStyle!==!1,showAlign:O.showAlign!==!1,padding:O.padding,width:O.width,maxWidth:O.maxWidth,editLayout:"fill"}),[b,j,g,A,O]),d=a.useMemo(()=>({kind:"page",view:x,overrides:C,embed:O}),[x,C,O]),w=a.useMemo(()=>({kind:"page",fragment:p.hash,navigation:p}),[p]),T=a.useCallback(M=>f.announce(M),[f]);return l.jsx(Tn,{path:e,absence:t,markup:n,display:c,navigation:d,fragment:w,paneScroll:so,announces:!0,announceFailure:T,onDocumentShown:o})},ms=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:i}=P(),f=he(d=>d.style),h=he(d=>d.align),[m,u]=a.useState(()=>yn(s,void 0,f)),p=Sn(void 0,h),E=a.useCallback(d=>i.update({align:d}),[i]),{maximized:x,onDocumentLink:C,pendingHash:O,onHashConsumed:k,announceFailure:j,paneScroll:A}=r,b=a.useMemo(()=>({style:m,onStyleChange:u,align:p,onAlignChange:E,showToc:x,showStyle:x,showAlign:x,padding:void 0,width:void 0,maxWidth:void 0,editLayout:x?"fill":"content"}),[m,p,E,x]),g=a.useMemo(()=>({kind:"panel",onDocumentLink:C}),[C]),c=a.useMemo(()=>({kind:"panel",fragment:O,consume:k}),[O,k]);return l.jsx(Tn,{path:e,absence:t,markup:n,display:b,navigation:g,fragment:c,paneScroll:A,announces:!1,announceFailure:j,onDocumentShown:o})},On=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>r.kind==="page"?l.jsx(fs,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o}):l.jsx(ms,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o});function hs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.755 10.059a7.5 7.5 0 0 1 12.548-3.364l1.903 1.903h-3.183a.75.75 0 1 0 0 1.5h4.992a.75.75 0 0 0 .75-.75V4.356a.75.75 0 0 0-1.5 0v3.18l-1.9-1.9A9 9 0 0 0 3.306 9.67a.75.75 0 1 0 1.45.388Zm15.408 3.352a.75.75 0 0 0-.919.53 7.5 7.5 0 0 1-12.548 3.364l-1.902-1.903h3.183a.75.75 0 0 0 0-1.5H2.984a.75.75 0 0 0-.75.75v4.992a.75.75 0 0 0 1.5 0v-3.18l1.9 1.9a9 9 0 0 0 15.059-4.035.75.75 0 0 0-.53-.918Z",clipRule:"evenodd"}))}const Cn=y.forwardRef(hs);function ps({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"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 Ln=y.forwardRef(ps);function vs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"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 gs=y.forwardRef(vs);function ws({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"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"}),y.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 Es=y.forwardRef(ws);function xs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"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 bs=y.forwardRef(xs);function ys({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"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"}),y.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 Ss=y.forwardRef(ys);function ks({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),y.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 Mn=y.forwardRef(ks);function Rs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{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"}),y.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 Ts=y.forwardRef(Rs);function Os({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M15 3.75H9v16.5h6V3.75ZM16.5 20.25h3.375c1.035 0 1.875-.84 1.875-1.875V5.625c0-1.036-.84-1.875-1.875-1.875H16.5v16.5ZM4.125 3.75H7.5v16.5H4.125a1.875 1.875 0 0 1-1.875-1.875V5.625c0-1.036.84-1.875 1.875-1.875Z"}))}const Cs=y.forwardRef(Os),An=({href:e,onRetry:t,testId:n})=>{const{labels:r,onEditGrant:o}=P(),[s,i]=a.useState(!1),f=()=>{o===void 0||s||(i(!0),o(e).then(h=>{h&&t()}).finally(()=>i(!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:f,children:r.editGrantAction}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":`${n}-retry`,onClick:t,children:r.editGrantRetry})]})]})},Ls="Control+E Meta+E",jn=(e,t,n)=>n&&t?"split":e.view,Ze=(e,t,n,r)=>{if(n==="split"){e.setSideBySide(!0);return}e.setView(t,n),r&&e.sideBySide()&&e.setSideBySide(!1)},Ms=e=>e==="split"?null:e,Nn=e=>e==="preview"?"editor":"preview",Dn=e=>/Mac|iPhone|iPad|iPod/u.test(e),Pn=(e,t)=>{if(e.isComposing||e.altKey||e.shiftKey||(t?!e.metaKey||e.ctrlKey:!e.ctrlKey||e.metaKey))return!1;const n=e.key.toLowerCase();return n==="e"||e.code==="KeyE"&&/^\p{L}$/u.test(n)&&!/^[a-z]$/u.test(n)},Rt=(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)},As=({path:e,documentName:t,open:n,onClose:r})=>{const{data:o,edits:s,labels:i,locale:f,announcer:h}=P(),m=a.useId(),[u,p]=a.useState(null),[E,x]=a.useState(0),[C,O]=a.useState(null),[k,j]=a.useState(null),A=a.useMemo(()=>new Intl.DateTimeFormat(f,{dateStyle:"medium",timeStyle:"short"}),[f]),b=a.useCallback(()=>{O(null),j(null)},[]),g=Zt({open:n,onOpen:b,onDismiss:r});a.useEffect(()=>{if(!n)return;const w=new AbortController;return p(null),o.revisions(e,w.signal).then(T=>{"kind"in T&&p(T)}),()=>w.abort()},[n,o,e,E]),a.useEffect(()=>{if(!n||C===null)return;const w=new AbortController;return j(null),o.revision(e,C,w.signal).then(T=>{"kind"in T&&j(T)}),()=>w.abort()},[n,o,e,C]);const c=()=>{k===null||k.kind!=="revision"||(s.replaceDraft(e,k.text),h.announce(i.historyRestored(t)),r())},d=u!==null&&u.kind==="revisions"?u.revisions.find(w=>w.id===C):void 0;return l.jsx("dialog",{...g,className:"aqmx-confirm aqmx-history","aria-labelledby":m,"data-testid":"markdown-explorer-history",children:l.jsxs("div",{className:"aqmx-confirm-panel aqmx-history-panel",children:[l.jsx("p",{id:m,className:"aqmx-confirm-title",children:i.historyTitle(t)}),u===null?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-loading",children:i.historyLoading}):u.kind==="failure"?l.jsx(se,{failure:u.failure,alert:!1,onRetry:()=>x(w=>w+1),testId:"markdown-explorer-history-failure"}):u.revisions.length===0?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-empty",children:i.historyEmpty}):l.jsx("ul",{className:"aqmx-history-list","data-testid":"markdown-explorer-history-list",children:u.revisions.map(w=>l.jsx("li",{children:l.jsxs("button",{type:"button",className:"aqmx-history-entry","aria-pressed":w.id===C,"data-testid":"markdown-explorer-history-entry",onClick:()=>O(w.id),children:[l.jsx("span",{children:Rt(w,A,i.historyEntry)}),w.current?l.jsx("span",{className:"aqmx-history-mark",children:i.historyCurrent}):null,w.kept?l.jsx("span",{className:"aqmx-history-mark",children:i.historyKept}):null]})},w.id))}),C===null?null:k===null?l.jsx("p",{className:"aqmx-history-note",children:i.historyLoading}):k.kind==="failure"?l.jsx(se,{failure:k.failure,alert:!1,testId:"markdown-explorer-history-revision-failure"}):l.jsx("section",{className:"aqmx-history-text",tabIndex:0,"aria-label":d===void 0?i.historyTitle(t):Rt(d,A,i.historyEntry),"data-testid":"markdown-explorer-history-text",children:l.jsx("pre",{children:k.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:i.historyClose}),l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":k===null||k.kind!=="revision","data-testid":"markdown-explorer-history-restore",onClick:c,children:i.historyRestore})]})]})})},js=e=>{const{documents:t}=P(),n=a.useCallback(()=>t.peek(e),[t,e]),r=a.useCallback(()=>t.peekSeeded(e),[t,e]),o=a.useSyncExternalStore(t.subscribe,n,r),s=re(o)?.document;return s===void 0||s.kind==="failure"?{edit:null,name:D.lastPathSegment(e)}:{edit:s.kind==="markdown"?s.edit:null,name:s.name}},ne=e=>{e.stopPropagation()},Ns=({path:e,documentName:t,iconOnly:n,previewAvailable:r,draft:o})=>{const{draftConverter:s,edits:i,labels:f}=P(),h=a.useSyncExternalStore(i.subscribe,()=>i.session(e)!==void 0,()=>!1),[m,u]=a.useState(null),p=()=>{if(!h){i.start(e,i.viewAnchor(e));return}i.flush(e);const O=i.session(e);O?.dirty===!0?u(O.save.kind==="draft"?"draft":"unsaved"):i.close(e)},E=()=>{h||(Er(),r&&i.sideBySide()&&s?.prepare?.())},x=n?o?f.editDraftDocumentNamed(t):f.editDocumentNamed(t):null,C=o?f.editDraftDocument:f.editDocument;return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:x===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:h?f.closeEditor:x===null?C:x,"aria-label":x===null?void 0:x,"aria-pressed":h,"data-testid":"markdown-explorer-document-edit",onClick:p,onDoubleClick:ne,onPointerEnter:E,onFocus:E,children:[l.jsx(Ts,{"aria-hidden":"true"}),x===null?l.jsx("span",{children:f.editDocumentLabel}):null]}),l.jsx(Gt,{open:m!==null,title:m==="draft"?f.draftDiscardTitle:f.unsavedTitle,body:m==="draft"?f.draftDiscardBody(t):f.unsavedBody(t),confirmLabel:f.unsavedDiscard,cancelLabel:f.unsavedStay,testId:"markdown-explorer-edit-close-confirm",onConfirm:()=>{u(null),i.close(e)},onCancel:()=>u(null)})]})},Ds=({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(gs,{"aria-hidden":"true"}),o===null?l.jsx("span",{children:r.editExternallyLabel}):null]})},Ps=({session:e})=>{const{labels:t}=P(),n=Xn(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})},_s=Object.freeze(["editor","split","preview"]),Fs=Object.freeze(["editor","preview"]),$s=Object.freeze({editor:Ln,split:Cs,preview:Mn}),qs=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{draftConverter:s,edits:i,labels:f}=P(),h=Jt(),m=jn(r,h,o),u=o?_s:Fs,p=a.useId(),E=a.useRef(new Map),x={editor:{label:f.editViewEditor,tooltip:f.editViewEditorTooltip},split:{label:f.editViewSplit,tooltip:f.editViewSplitTooltip},preview:{label:f.editViewPreview,tooltip:f.editViewPreviewTooltip}},C=()=>{i.preparePreview(e),s?.prepare?.()},O=k=>{if(!Pn(k.nativeEvent,Dn(navigator.platform)))return;We(k);const j=Nn(m);Ze(i,e,j,o),E.current.get(j)?.focus()};return l.jsx("div",{role:"radiogroup","aria-label":n?f.editViewNamed(t):f.editView,className:"aqmx-edit-view","data-testid":"markdown-explorer-edit-view",onKeyDown:O,children:u.map(k=>{const j=$s[k],{label:A,tooltip:b}=x[k],g=k==="preview"?C:void 0;return l.jsxs("label",{className:n?"aqmx-icon-button":"aqmx-icon-button aqmx-labelled-button",children:[l.jsx("input",{ref:c=>{c===null?E.current.delete(k):E.current.set(k,c)},type:"radio",name:p,value:k,checked:k===m,"aria-label":A,"aria-keyshortcuts":k==="split"?void 0:Ls,title:b,"data-testid":`markdown-explorer-edit-view-${k}`,onChange:()=>Ze(i,e,k,o),onDoubleClick:ne,onPointerEnter:g,onFocus:g}),l.jsx(j,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:A})]},k)})})},Is=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{edits:s,labels:i}=P(),[f,h]=a.useState(!1);if(r.phase.kind!=="editing")return null;const m=r.save.kind==="saving",u=m||!r.dirty,p=()=>{s.flush(e);const x=s.session(e);x===void 0||!x.dirty||x.save.kind==="saving"||s.save(e)},E=x=>n?{className:"aqmx-icon-button","aria-label":x}:{className:"aqmx-icon-button aqmx-labelled-button"};return l.jsxs(l.Fragment,{children:[r.save.kind==="conflicts"?l.jsxs("button",{type:"button",...E(i.conflictNext),title:i.conflictNext,"data-testid":"markdown-explorer-edit-next-conflict",onClick:()=>s.nextConflict(e),onDoubleClick:ne,children:[l.jsx(Es,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:i.conflictNext})]}):null,l.jsx(qs,{path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o}),r.history?l.jsxs("button",{type:"button",...E(i.historyOpen),title:i.historyOpen,"aria-haspopup":"dialog","data-testid":"markdown-explorer-edit-history",onClick:()=>h(!0),onDoubleClick:ne,children:[l.jsx(bs,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:i.historyOpen})]}):null,r.save.kind==="draft"?null:l.jsxs("button",{type:"button",...E(i.saveDraft),title:i.saveDraftTooltip,"aria-disabled":u,"aria-busy":m,"aria-keyshortcuts":"Control+S Meta+S","data-testid":"markdown-explorer-edit-save",onClick:p,onDoubleClick:ne,children:[l.jsx(Ss,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:i.saveDraft})]}),r.history?l.jsx(As,{path:e,documentName:t,open:f,onClose:()=>h(!1)}):null]})},Bs=({path:e,session:t})=>{const{edits:n}=P();return t.save.kind!=="grant"?null:l.jsx(An,{href:t.save.href,onRetry:()=>{n.save(e)},testId:"markdown-explorer-save-grant"})},Hs=e=>{const{documents:t}=P(),n=a.useCallback(()=>t.peek(e),[t,e]),r=a.useCallback(()=>t.peekSeeded(e),[t,e]),o=a.useSyncExternalStore(t.subscribe,n,r);return re(o)?.document.kind==="markdown"},_n=e=>{const{config:t}=P(),n=ge(),r=a.useCallback(()=>n($.explorerHref(t,{...e,markup:!e.markup}),"browse"),[t,n,e]);return a.useMemo(()=>({shown:e.markup,toggle:r}),[e.markup,r])},Vs=new Set,Us=(e,t)=>{const{documents:n,announcer:r,labels:o}=P(),s=a.useCallback(()=>n.peek(e),[n,e]),i=a.useCallback(()=>n.peekSeeded(e),[n,e]),f=a.useSyncExternalStore(n.subscribe,s,i),h=a.useCallback(()=>n.answerStampOf(e),[n,e]),m=a.useSyncExternalStore(n.subscribe,h,h),[u]=a.useState(()=>new Set),[p,E]=a.useState(Vs),[x,C]=a.useState(null);x!==null&&x.path!==e&&C(null);const O=a.useRef(null);a.useLayoutEffect(()=>(O.current=e,()=>{O.current=null}),[e]);const k=a.useCallback(()=>{const b=e,g=n.peek(b);if(u.has(b)||g?.status==="pending")return;const c=t&&!hn(g);u.add(b),E(new Set(u)),C(null),(async()=>{try{const d=await n.refresh(b);if(O.current!==b||d.status==="superseded")return;if(d.status==="failed"){C({path:b,failure:d.failure,stamp:n.answerStampOf(b)}),r.announce(o.documentRefreshFailed(ee(o,d.failure.reason)));return}const w=re(n.peek(b));if(c||w===null||w.document.kind==="failure")return;r.announce(o.documentRefreshed(w.document.name))}finally{u.delete(b),E(new Set(u))}})()},[e,t,u,n,r,o]),j=p.has(e),A=x!==null&&x.path===e&&x.stamp===m?x.failure:null;return{refreshing:j,unavailable:j||f?.status==="pending",failure:A,refresh:k}},Fn=Object.freeze({kind:"page"}),$n=({path:e,placement:t,markup:n})=>{const{labels:r}=P(),{refreshing:o,unavailable:s,failure:i,refresh:f}=Us(e,t.kind==="page"),h=Hs(e),m=js(e),u=Yt(e),p=t.kind==="panel"?r.refreshDocumentNamed(t.documentName):null,E=t.kind==="panel"?r.showMarkupNamed(t.documentName):null,x=t.kind==="panel",C=t.kind==="panel"?t.documentName:m.name,O=t.kind==="page"||t.maximized;return l.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar","data-aqmx-editing":u===void 0?void 0:"true",children:[l.jsxs("div",{className:"aqmx-document-refresh-row",children:[u===void 0?null:l.jsx(Ps,{session:u}),u===void 0?null:l.jsx(Is,{path:e,documentName:C,iconOnly:x,session:u,previewAvailable:O}),u===void 0&&h?l.jsxs("button",{type:"button",className:E===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:E===null?r.showMarkup:E,"aria-label":E===null?void 0:E,"aria-pressed":n.shown,"data-testid":"markdown-explorer-document-markup",onClick:n.toggle,onDoubleClick:ne,children:[l.jsx(Ln,{"aria-hidden":"true"}),E===null?l.jsx("span",{children:r.showMarkupLabel}):null]}):null,u!==void 0||m.edit?.kind==="inline"||m.edit?.kind==="draft"?l.jsx(Ns,{path:e,documentName:C,iconOnly:x,previewAvailable:O,draft:m.edit?.kind==="draft"}):m.edit?.kind==="external"?l.jsx(Ds,{href:m.edit.href,documentName:C,iconOnly:x}):null,u===void 0?l.jsxs("button",{type:"button",className:p===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:p===null?r.refreshDocument:p,"aria-label":p===null?void 0:p,"aria-disabled":s,"aria-busy":o,"data-aqmx-busy":o?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:f,onDoubleClick:ne,children:[l.jsx(Cn,{"aria-hidden":"true"}),p===null?l.jsx("span",{children:r.refreshDocumentLabel}):null]}):null]}),u!==void 0||i===null?null:l.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":i.reason,children:r.documentRefreshFailed(ee(r,i.reason))}),u===void 0?null:l.jsx(Bs,{path:e,session:u})]})},zs=({location:e})=>{const t=e.doc,n=a.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),r=_n(e);return l.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",...be,children:[l.jsx($n,{path:t,placement:Fn,markup:r}),l.jsx(On,{path:t,absence:kn,markup:e.markup,variant:n})]})},qn=({holds:e,testId:t})=>{const{labels:n,announcer:r}=P(),o=a.useId();a.useLayoutEffect(()=>e?r.claim(o):void 0,[e,r,o]);const s=a.useCallback(()=>r.shownIn(o),[r,o]),i=a.useSyncExternalStore(r.subscribe,s,s);return l.jsx("div",{className:"aqmx-sr-only",role:"status","aria-live":"polite","aria-atomic":"true","data-testid":t,children:i.length>1?n.announcementSequence(i):i[0]})},ie=Object.freeze([]),Zs=e=>{const t=new Set;let n=ie,r=[],o=!1;const s=[],i=u=>{n=u;for(const p of[...t])p()},f=()=>s.at(-1)?.region,h=u=>{const p=f();u(),f()!==p&&n!==ie&&i(ie)},m=()=>{o=!1;const u=r.map(p=>"sentence"in p?p.sentence:p.list(p.items));r=[],i(Object.freeze(u))};return{announce:u=>{if(typeof u=="string")r.push({sentence:u});else{const p=r.find(E=>"list"in E&&E.list===u.list);p!==void 0&&"items"in p?p.items.push(u.item):r.push({list:u.list,items:[u.item]})}o||(o=!0,n!==ie&&i(ie),e.request(m))},subscribe:u=>(t.add(u),()=>{t.delete(u)}),claim:u=>{const p={region:u};return h(()=>s.push(p)),()=>h(()=>{const E=s.indexOf(p);E!==-1&&s.splice(E,1)})},shownIn:u=>f()===u?n:ie}},de=Object.freeze({status:"cancelled"}),Gs=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(D.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return D.failureOf(n,r)},Ks=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((m,u)=>globalThis.fetch(m,u)),o=(m,u)=>`${e}/${m}?${new URLSearchParams(u).toString()}`,s=async(m,u,p,E)=>{let x;try{x=await r(m,{credentials:"same-origin",...u,headers:{Accept:"application/json",...u.headers}})}catch{return E({reason:"failed"})}x.status===401&&t(null);const C=x.headers.get(D.EXPLORER_SCOPE_HEADER);C!==null&&t(C);let O;try{O=await x.json()}catch{return E({reason:D.failureReasonOfStatus(x.status)})}let k;try{k=p(O)}catch{k=!1}if(k)return O;const j=Gs(O);return E(j!==null?j:{reason:x.status===200?"failed":D.failureReasonOfStatus(x.status)})},i={[D.EXPLORER_PROOF_HEADER]:D.EXPLORER_REFRESH_PROOF},f={[D.EXPLORER_PROOF_HEADER]:D.EXPLORER_EDIT_PROOF,"Content-Type":`${D.EXPLORER_DRAFT_MEDIA_TYPE}; charset=utf-8`},h=async(m,u,p)=>{const E=await s(m,u,p,x=>D.failureDocument(x.reason,x.code));return u.signal.aborted?de:E};return{tree:m=>s(o("tree",{[D.EXPLORER_DATA_QUERY.source]:m}),{method:"GET"},D.isExplorerTreeResult,u=>({status:"error",failure:u})),children:async(m,u,p)=>{const E=await s(o("children",{[D.EXPLORER_DATA_QUERY.source]:m,[D.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:p},D.isExplorerChildrenResult,x=>({status:"error",failure:x}));return p.aborted?de:E},ancestors:async(m,u,p)=>{const E=await s(o("ancestors",{[D.EXPLORER_DATA_QUERY.source]:m,[D.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:p},D.isExplorerAncestorsResult,x=>({status:"error",failure:x}));return p.aborted?de:E},reveal:async(m,u,p)=>{const E=await s(o("reveal",{[D.EXPLORER_DATA_QUERY.source]:m,[D.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:p},D.isExplorerRevealResult,x=>({status:"error",failure:x}));return p.aborted?de:E},document:(m,{refresh:u})=>s(o("document",{[D.EXPLORER_DATA_QUERY.path]:m}),u?{method:"GET",headers:i}:{method:"GET"},D.isExplorerDocument,p=>D.failureDocument(p.reason,p.code)),text:async(m,u)=>{const p=await s(o("text",{[D.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:u},D.isExplorerTextAnswer,E=>D.failureDocument(E.reason,E.code));return u.aborted?de:p},edit:(m,u)=>h(o("edit",{[D.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:u},D.isExplorerEditAnswer),save:(m,u,p,E)=>h(o("save",{[D.EXPLORER_DATA_QUERY.path]:m,[D.EXPLORER_DATA_QUERY.base]:u}),{method:"POST",headers:f,body:p,signal:E},D.isExplorerSaveAnswer),preview:(m,u,p)=>h(o("preview",{[D.EXPLORER_DATA_QUERY.path]:m}),{method:"POST",headers:f,body:u,signal:p},D.isExplorerPreviewAnswer),revisions:(m,u)=>h(o("revisions",{[D.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:u},D.isExplorerRevisionsAnswer),revision:(m,u,p)=>h(o("revision",{[D.EXPLORER_DATA_QUERY.path]:m,[D.EXPLORER_DATA_QUERY.revision]:u}),{method:"GET",signal:p},D.isExplorerRevisionAnswer),refresh:m=>s(o("refresh",{[D.EXPLORER_DATA_QUERY.source]:m}),{method:"POST",headers:i},D.isExplorerTreeResult,u=>({status:"error",failure:u}))}},Ws=()=>{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}}},Xs=e=>{const t=X.readStorage(e);if(t===null)return $.NO_TREE_SETTING_CHANGES;try{return $.readTreeSettingChanges(JSON.parse(t))}catch(n){return console.warn(`[markdown-explorer] localStorage key ${JSON.stringify(e)} does not hold JSON; using the default tree settings.`,n),$.NO_TREE_SETTING_CHANGES}},Tt=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=Xs(e);n={changes:s,settings:$.applyTreeSettingChanges(t,s)}}return n},o=ae();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:i,settings:f}=r(),h=$.recordTreeSettingChange(i,s,$.advanceTreeSetting(f,s)[s],t);return n={changes:h,settings:$.applyTreeSettingChanges(t,h)},o.emit(),X.writeStorage(e,$.serializeTreeSettingChanges(h)),n.settings}}},Ys=Object.freeze({status:"refreshed"}),Qs=Object.freeze({status:"superseded"}),Ge=Object.freeze({status:"deferred"}),Js=Kt(Ge),In=4,ei=In-1,Ot=Object.freeze({status:"loading"}),ti=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),ni=e=>{const t=new Map,n=mn(),r=new Map,o=new Map,s=new Map,i=new Map,f=ae(),h=new Set;let m=0,u=0;const p={direct:null,bulk:null},E=new Set;let x=!1,C=0;const O=()=>{C+=1,f.emit()},k=v=>o.get(v)??0,j=v=>{let S=i.get(v);return S===void 0&&(S={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},i.set(v,S)),S},A=(v,S,R)=>{v.inFlight.delete(S),m-=1,R.lane==="bulk"&&(u-=1)},b=v=>{const S=i.get(v);if(S!==void 0){for(const[R,L]of[...S.inFlight])A(S,R,L),L.controller.abort();S.direct.clear(),S.bulk.clear(),S.unclaimed.clear()}},g=v=>{const S=k(v)+1;return o.set(v,S),b(v),S},c=(v,S)=>{const R=ue(v),L={promise:v,opened:S,stale:!1,loadedAt:R?.status==="ok"?R.loadedAt:null};return v.status==="pending"&&v.then(_=>{_.status==="ok"&&(L.loadedAt=_.loadedAt)}),L},d=v=>{let S=r.get(v);return S===void 0&&(S=new Map,r.set(v,S)),S},w=v=>{const S=[...i.keys()],R=p[v],L=R===null?0:S.indexOf(R)+1;for(let _=0;_<S.length;_+=1){const q=S[(L+_)%S.length],Z=q===void 0?void 0:i.get(q);if(!(q===void 0||Z===void 0)){for(const V of Z[v])if((Z.claims.get(V)??0)!==0)return Z[v].delete(V),p[v]=q,{sourceId:q,path:V}}}return null},T=(v,S,R,L)=>{const _=i.get(v);if(_===void 0||_.inFlight.get(S)!==R)return;A(_,S,R);const q=(_.claims.get(S)??0)>0,Z=d(v);if(L.status==="ok"?Z.set(S,{status:"loaded",entries:L.entries}):L.status==="error"&&q?Z.set(S,{status:"failed",failure:L.failure}):Z.delete(S),O(),L.status==="error"&&q){const V={sourceId:v,path:S,failure:L.failure};for(const te of[...h])te(V)}N()},M=(v,S,R)=>{const L={controller:new AbortController,lane:R};j(v).inFlight.set(S,L),m+=1,R==="bulk"&&(u+=1),e.children(v,S,L.controller.signal).then(_=>T(v,S,L,_),()=>T(v,S,L,ti))},N=()=>{for(;m<In;){const v=w("direct");if(v!==null){M(v.sourceId,v.path,"direct");continue}const S=u<ei?w("bulk"):null;if(S===null)return;M(S.sourceId,S.path,"bulk")}},F=(v,S,R)=>{if(!(S.direct.delete(R)||S.bulk.delete(R))){const _=S.inFlight.get(R);if(_===void 0)return!1;A(S,R,_),_.controller.abort()}return r.get(v)?.delete(R),!0},z=()=>{x=!1;let v=!1;for(const S of E){const R=j(S);for(const L of R.unclaimed)(R.claims.get(L)??0)===0&&F(S,R,L)&&(v=!0);R.unclaimed.clear()}E.clear(),v&&(O(),N())},I=(v,S)=>{t.set(v,c(pe(e.tree(v)),S))},B=(v,S,R)=>{g(v);const L=c(Kt(S),R);return t.set(v,L),r.delete(v),O(),N(),L},K=(v,S,R,L)=>{if(R!==k(v)||t.get(v)!==S)return;const _=ue(S.promise);if(!(L.status!=="ok"||_?.status!=="ok"||S.loadedAt===null||L.loadedAt<=S.loadedAt)){if(Se(_.entries,L.entries)){S.loadedAt=L.loadedAt;return}B(v,L,S.opened)}},H=(v,S)=>{const R=t.get(v);return R!==void 0&&ue(R.promise)?.status===S},Q=(v,S)=>{S.stale=!1;const R=k(v);e.tree(v).then(L=>K(v,S,R,L))};return{read:v=>t.get(v)?.promise??Js,open:v=>{const S=n.resumes(v),R=n.hold(v),L=t.get(v);return L===void 0||H(v,"deferred")?(I(v,!0),O()):S||(L.opened&&H(v,"error")?(I(v,!0),O()):(L.opened=!0,L.stale&&H(v,"ok")&&Q(v,L))),R},retry:v=>{H(v,"error")&&(I(v,!0),O())},seed:(v,S)=>{const R=S.then(q=>q===null?Ge:q,()=>Ge),L=t.get(v);if(L!==void 0&&H(v,"ok")){const q=k(v);R.then(Z=>K(v,L,q,Z));return}g(v);const _=c(pe(R),L?.opened===!0);t.set(v,_),r.delete(v),N(),R.then(q=>{t.get(v)===_&&(q.status==="deferred"&&n.isHeld(v)&&I(v,_.opened),O())})},refresh:async v=>{const S=(s.get(v)??0)+1;s.set(v,S);const R=await e.refresh(v);if(s.get(v)!==S)return Qs;if(R.status==="error")return{status:"failed",failure:R.failure};const L=t.get(v);if(!(L!==void 0&&L.loadedAt!==null&&H(v,"ok")&&L.loadedAt>R.loadedAt)){const q=B(v,R,!0);if(L!==void 0&&L.promise.status==="pending"){const Z=k(v);L.promise.then(V=>K(v,q,Z,V))}}for(const[q,Z]of t)q!==v&&ue(Z.promise)?.status==="ok"&&(Z.stale=!0);return Ys},children:(v,S)=>r.get(v)?.get(S),claimChildren:(v,S)=>{const R=j(v),L=d(v);let _=!1,q=!1;for(const[V,te]of S)R.claims.set(V,(R.claims.get(V)??0)+1),L.get(V)===void 0?(L.set(V,Ot),R[te].add(V),_=!0,q=!0):te==="direct"&&R.bulk.delete(V)&&(R.direct.add(V),q=!0);_&&O(),q&&N();let Z=!1;return()=>{if(!Z){Z=!0;for(const V of S.keys()){const te=(R.claims.get(V)??0)-1;te>0?R.claims.set(V,te):(R.claims.delete(V),R.unclaimed.add(V))}E.add(v),!x&&(x=!0,queueMicrotask(z))}}},retryChildren:(v,S)=>{const R=r.get(v);if(R===void 0||R.get(S)?.status!=="failed")return;const L=j(v);if((L.claims.get(S)??0)>0){R.set(S,Ot),L.direct.add(S),O(),N();return}R.delete(S),O()},pendingChildren:v=>{const S=i.get(v);return S===void 0?0:S.direct.size+S.bulk.size+S.inFlight.size},clear:()=>{for(const v of new Set([...t.keys(),...r.keys(),...o.keys(),...i.keys()]))g(v);for(const[v,S]of s)s.set(v,S+1);t.clear(),r.clear(),O()},subscribeChildrenFailures:v=>(h.add(v),()=>{h.delete(v)}),subscribe:f.subscribe,version:()=>C}},ri=(e,t)=>{let n=e;const r=ae();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},oi=1;let we=0,oe=null;const si=()=>{const{documentElement:e,body:t}=document;we===0&&(oe={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"),we+=1;let n=!1;return()=>{n||(n=!0,we-=1,!(we>0||oe===null)&&(e.style.overflow=oe.htmlOverflow,t.style.overflow=oe.bodyOverflow,e.style.scrollbarGutter=oe.htmlGutter,t.style.scrollbarGutter=oe.bodyGutter,oe=null))}},ii=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],Ct=1,li=1e3,Lt=e=>e.getClientRects().length>0,Fe="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.",ai=e=>{if(!Lt(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+oi)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. ${Fe}`;if(t.height<Ct)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. ${Fe}`;for(const{selector:r,name:o}of ii)for(const s of e.querySelectorAll(r)){if(!Lt(s))continue;const i=s.getBoundingClientRect().height;if(i<Ct)return`[markdown-explorer] the explorer's ${o} collapsed to ${String(Math.round(i))}px while lockDocumentScroll stops the page from scrolling, so it cannot be read. ${Fe}`}return null},ci=e=>{let t=!1,n;const r=()=>{n=void 0;const i=ai(e);i!==null&&(t=!0,console.error(i))},o=()=>{t||(clearTimeout(n),n=setTimeout(r,li))},s=typeof ResizeObserver>"u"?null:new ResizeObserver(o);return s?.observe(e),window.addEventListener("resize",o),o(),()=>{clearTimeout(n),s?.disconnect(),window.removeEventListener("resize",o)}},di=(e,t)=>{a.useEffect(()=>e?si():void 0,[e]),a.useEffect(()=>{const n=t.current;if(!(!e||n===null))return ci(n)},[e,t])},Mt='[data-testid="markdown-explorer-view-switch"]',ui=[{control:Mt,successors:[Mt,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],fi=e=>{for(const t of ui){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},mi=(e,t)=>{const n=a.useRef(null);a.useEffect(()=>{const o=f=>{const h=e.current;n.current=h!==null&&f instanceof Element&&h.contains(f)?fi(f):null},s=f=>o(f.target);o(document.activeElement);const i=f=>{const h=f.target;f.relatedTarget!==null||!(h instanceof Element)||queueMicrotask(()=>{n.current?.element===h&&h.isConnected&&document.activeElement!==h&&(n.current=null)})};return document.addEventListener("focusin",s),document.addEventListener("focusout",i),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",i)}},[e]);const r=a.useRef(t);a.useLayoutEffect(()=>{if(r.current===t)return;r.current=t;const o=n.current;if(o===null)return;const s=()=>{const h=document.activeElement;if(h!==null&&h!==document.body&&h!==o.element)return!0;const m=e.current;if(m===null)return!0;for(const u of o.control.successors)for(const p of m.querySelectorAll(u))if(p!==o.element&&(p.focus({preventScroll:!0}),document.activeElement===p))return!0;return!1};if(s())return;const i=e.current;if(i===null)return;const f=new MutationObserver(()=>{s()&&f.disconnect()});return f.observe(i,{childList:!0,subtree:!0}),()=>f.disconnect()},[t,e])},hi=a.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-CKZ-XQgn.cjs")).then(e=>({default:e.TreeLayout}))),pi=a.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-BXfzR6XC.cjs")).then(e=>({default:e.MultiLayout}))),vi=64,gi={request:e=>{requestAnimationFrame(e)}},At=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)},wi=(e,t)=>{const[n,r]=a.useState(()=>({overrides:t,locale:e,labels:He(e,t)}));if(n.locale===e&&Kn(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:He(e,t)};return r(o),o.labels},Ei=(e,t,n)=>{const[r,o]=a.useState(()=>({scope:t,store:Tt(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:Tt(e,n)};return o(s),s.store},qe=(e,t)=>{const[n,r]=a.useState(()=>({scope:e,value:t()}));if(n.scope===e)return n.value;const o={scope:e,value:t()};return r(o),o.value},xi=()=>Zs(gi),jt="on",bi="off",yi=Object.freeze({kind:"unavailable"}),Si=e=>{if(e!==void 0&&(e===null||typeof e!="object"||typeof e.convert!="function"))throw new TypeError("[markdown-explorer] draftConverter must be an object with a convert function")},ki=(e,t)=>{const n=re(e.peek(t));return n===null||n.document.kind==="failure"?D.lastPathSegment(t):n.document.name},Ri=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:i,renderTreeFailure:f,lockDocumentScroll:h=!1,onMathDiagnostics:m,onEditGrant:u,draftConverter:p})=>{X.assertStorageNamespace(n),Si(p);const E=Ft(r),x=Wn(s),C=wi(E,o),{revalidate:O}=Y.useRevalidator(),k=a.useRef(()=>{}),j=Y.useHref(t.dataPath),[A]=a.useState(()=>{const R=Ks({dataPath:j,onScope:_=>k.current(_)}),L={documents:Dr({client:R,capacity:Math.max(vi,t.multiView.maxPanels*2)}),trees:ni(R)};return $e(L,e),X.syncStorageScope(n,e.scope),{data:R,...L,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(A.aligned.pageData!==e||A.aligned.storageNamespace!==n){const R=A.aligned.pageData;A.aligned.pageData=e,A.aligned.storageNamespace=n,R!==e&&(R.scope!==e.scope?A.aligned.pendingReader=e:$e(A,e)),X.syncStorageScope(n,e.scope)}const b=Ei(X.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);a.useLayoutEffect(()=>{const R=A.aligned.pendingReader;R!==null&&(A.aligned.pendingReader=null,At(A),$e(A,R))},[e,A]),a.useLayoutEffect(()=>{let R=!1;return k.current=L=>{L===e.scope||R||(R=!0,L!==null&&(At(A),X.clearExplorerStorage(n)),O())},()=>{k.current=()=>{}}},[e,O,A,n]);const g=a.useRef(t.settingsCookie);a.useLayoutEffect(()=>{g.current=t.settingsCookie},[t.settingsCookie]);const[c]=a.useState(()=>ri(e.settings,R=>{document.cookie=$.viewSettingsCookieString(g.current,R,window.location.protocol==="https:")})),d=qe(e.scope,xi),w=qe(e.scope,Ws),T=a.useRef(C);a.useLayoutEffect(()=>{T.current=C},[C]);const M=qe(e.scope,()=>nr({data:A.data,conflictLabels:()=>({ours:T.current.conflictOurs,theirs:T.current.conflictTheirs}),onSaveSettled:(R,L)=>{L.kind==="saved"&&A.documents.refresh(R);const _=Yn(T.current,L,ki(A.documents,R));_!==null&&d.announce(_)},sideBySideSetting:{read:()=>X.readStorage(X.storageKeys(n).editPreview)===jt,write:R=>X.writeStorage(X.storageKeys(n).editPreview,R?jt:bi)},editorShareSetting:{read:()=>tr(X.readStorage(X.storageKeys(n).editSplit)),write:R=>X.writeStorage(X.storageKeys(n).editSplit,String(R))}})),N=a.useMemo(()=>pe(e.notices.catch(()=>[])),[e.notices]),F=e.sources.map(R=>R.id).join(`
|
|
12
|
+
`),z=a.useMemo(()=>$.withExplorerSources(t,F.split(`
|
|
13
|
+
`)),[t,F]),I=a.useRef(m);a.useLayoutEffect(()=>{I.current=m},[m]);const[B]=a.useState(()=>(R,L)=>{I.current?.(R,L)}),K=m===void 0?void 0:B,H=a.useRef(p);a.useLayoutEffect(()=>{H.current=p},[p]);const[Q]=a.useState(()=>{let R=!1;return{convert:(L,_)=>{const q=H.current;return q===void 0?Promise.resolve(yi):q.convert(L,_)},prepare:()=>{try{H.current?.prepare?.()}catch(L){if(R)return;R=!0,console.error("[markdown-explorer] the draft converter's prepare threw",L)}}}}),v=p===void 0?void 0:Q,S=a.useMemo(()=>({config:z,labels:C,locale:E,theme:x,storageNamespace:n,scope:e.scope,sources:e.sources,notices:N,documents:A.documents,trees:A.trees,data:A.data,viewSettings:c,treeSettings:b,announcer:d,reveals:w,edits:M,onEditGrant:u,draftConverter:v,renderTreeFailure:f,reportMathDiagnostics:K}),[z,C,E,x,n,e.scope,e.sources,N,A,c,b,d,w,M,u,v,f,K]);return l.jsx($t,{value:S,children:l.jsx(Oi,{renderFrame:i,lockDocumentScroll:h},e.scope)})},Ti=({ref:e,theme:t,view:n,children:r})=>{const[o]=a.useState(Eo);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})},Oi=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=P(),o=Re(),{hash:s}=Y.useLocation(),i=ge(),f=a.useRef(null);di(t,f),a.useLayoutEffect(()=>{o.kind==="redirect"&&i(`${o.href}${s}`,"browse")},[o,s,i]);const{location:h}=o,m=h.view;mi(f,m);const u=h.view==="tree"?l.jsx(a.Suspense,{fallback:l.jsx("section",{className:"aqmx-split-fallback","aria-label":r.explorerRegion,"aria-busy":"true","data-testid":"markdown-explorer-split-loading",...be}),children:l.jsx(hi,{location:h})}):h.view==="multi"?l.jsx(a.Suspense,{fallback:l.jsx("section",{className:"aqmx-stage-fallback","aria-label":r.multiRegion,"aria-busy":"true","data-testid":"markdown-explorer-stage-loading",...be}),children:l.jsx(pi,{location:h})}):l.jsx(zs,{location:h}),p=l.jsxs(Ti,{ref:f,theme:n,view:m,children:[u,l.jsx(vr,{}),l.jsx(qn,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?p:e({view:m,children:p})},Ci=Hn.createShouldRevalidate({submissions:"skip",otherPath:"skip",query:"skip",hashChange:"skip"});exports.ALLOW_KEY_REPEAT=ke;exports.CONFLICT_OURS_MARKER=It;exports.CONFLICT_SEPARATOR=Bt;exports.CONFLICT_THEIRS_MARKER=Ht;exports.CONTENT_PANE=be;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=Nt;exports.DocumentPane=On;exports.DocumentRefreshBar=$n;exports.EXPLORER_THEMES=Ve;exports.EditGrantNotice=An;exports.ExplorerLink=cn;exports.FOLDER_README_LOADING=Wt;exports.FailureView=se;exports.ForwardRef=Cn;exports.ForwardRef$1=Mn;exports.ImageViewMemoryContext=En;exports.LazyNativeScrollBar=un;exports.LiveRegion=qn;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=_t;exports.MARKDOWN_EXPLORER_LABEL_KEYS=Ke;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=Dt;exports.MARKDOWN_EXPLORER_LOCALES=Be;exports.MarkdownExplorer=Ri;exports.NO_DOCUMENT=kn;exports.PAGE_DOCUMENT_REFRESH=Fn;exports.anchorOfDoubleClick=nn;exports.anchorOfView=rn;exports.blockAtLine=ln;exports.chooseEditView=Ze;exports.consumeKey=We;exports.createEmitter=ae;exports.cssPixels=Ut;exports.editViewOf=jn;exports.explorerNavigationOptions=Mr;exports.failureTitleOf=ee;exports.findConflictsInLines=Vt;exports.focusWithoutScroll=Qe;exports.frameTopOf=on;exports.isApplePlatform=Dn;exports.isEditViewShortcut=Pn;exports.isEditingDoubleClick=tn;exports.lineTopIn=an;exports.loadedOf=re;exports.paneShownAlone=Ms;exports.positionInSource=Cr;exports.readFolderReadme=Xt;exports.resolveMarkdownExplorerLabels=He;exports.shouldRevalidateExplorer=Ci;exports.toggledEditView=Nn;exports.useExplorer=P;exports.useExplorerLocation=Re;exports.useExplorerNavigate=ge;exports.useIntentPrefetch=dn;exports.usePageMarkupToggle=_n;exports.useSideBySide=Jt;exports.useViewSetting=he;exports.visibleTopOf=sn;
|