@aiquants/markdown-explorer 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/README.md +61 -21
  3. package/dist/{EditSurface-Bk4tdJ99.cjs → EditSurface-CRc4g0Qa.cjs} +5 -5
  4. package/dist/{EditSurface-Dhvw9IDD.js → EditSurface-CcWEczj3.js} +333 -336
  5. package/dist/{ExplorerSplit-Q5VqUBDE.js → ExplorerSplit-97SeIAOS.js} +81 -81
  6. package/dist/{ExplorerSplit-BAFiXU-V.cjs → ExplorerSplit-ByxxXlgs.cjs} +1 -1
  7. package/dist/{MultiLayout-Bq_TS3ez.cjs → MultiLayout-B_yMVDt_.cjs} +1 -1
  8. package/dist/{MultiLayout-DlATT7km.js → MultiLayout-CnbuAlxd.js} +22 -22
  9. package/dist/{NativeScrollBar-TsIcS3JZ.js → NativeScrollBar-BXdaM3EA.js} +1 -1
  10. package/dist/{NativeScrollBar-A6-qEpz7.cjs → NativeScrollBar-D4a7fBOS.cjs} +1 -1
  11. package/dist/{TreeLayout-zrSo4MNZ.js → TreeLayout-BIQBKAkV.js} +3 -3
  12. package/dist/{TreeLayout-l-r2pPao.cjs → TreeLayout-C6QDpEBS.cjs} +1 -1
  13. package/dist/core/config.d.cts +13 -0
  14. package/dist/core/config.d.ts +13 -0
  15. package/dist/core/contracts.d.cts +22 -4
  16. package/dist/core/contracts.d.ts +22 -4
  17. package/dist/core/labels.d.cts +9 -0
  18. package/dist/core/labels.d.ts +9 -0
  19. package/dist/core/textEncoding.d.cts +4 -0
  20. package/dist/core/textEncoding.d.ts +4 -0
  21. package/dist/{dataRoute-Diu_7gle.js → dataRoute-BEvesOvN.js} +105 -97
  22. package/dist/dataRoute-Cv7fgCW7.cjs +1 -0
  23. package/dist/index-BwTVYkTR.cjs +13 -0
  24. package/dist/index-CeZDCyEl.js +4088 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.d.cts +2 -2
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.js +24 -23
  29. package/dist/location-CasigkBk.cjs +1 -0
  30. package/dist/location-gXXmC7CQ.js +643 -0
  31. package/dist/{merge-BzMpSaxx.js → merge-DqjUgcV_.js} +1 -1
  32. package/dist/{merge-DlPkU2Jc.cjs → merge-QLktbpZY.cjs} +1 -1
  33. package/dist/{sanitizePolicy-Du3lFZd-.cjs → sanitizePolicy-CZwOaJ92.cjs} +1 -1
  34. package/dist/{sanitizePolicy-BvhYIqVO.js → sanitizePolicy-gVKBhabq.js} +1 -1
  35. package/dist/sanitizeWorker.cjs +1 -1
  36. package/dist/sanitizeWorker.js +1 -1
  37. package/dist/server/fileSystemSource.d.cts +1 -0
  38. package/dist/server/fileSystemSource.d.ts +1 -0
  39. package/dist/server/ports.d.cts +8 -1
  40. package/dist/server/ports.d.ts +8 -1
  41. package/dist/server.cjs +1 -1
  42. package/dist/server.d.cts +1 -0
  43. package/dist/server.d.ts +1 -0
  44. package/dist/server.js +783 -768
  45. package/dist/styles/markdown-explorer.css +1 -1
  46. package/dist/{useSplitPersistence-HfAb8Kzh.js → useSplitPersistence-BPNjvuJi.js} +1 -1
  47. package/dist/{useSplitPersistence-CR4Oxtaa.cjs → useSplitPersistence-Bmpb2prR.cjs} +1 -1
  48. package/docs/behavior/dom-hooks.md +13 -6
  49. package/docs/behavior/layout.md +19 -10
  50. package/docs/behavior/localization.md +6 -3
  51. package/docs/behavior/security.md +6 -4
  52. package/docs/behavior/url-contract.md +2 -2
  53. package/package.json +5 -5
  54. package/dist/dataRoute-vXGZMVB-.cjs +0 -1
  55. package/dist/index-BNFl3BsO.cjs +0 -13
  56. package/dist/index-Jz6zeO4O.js +0 -3703
  57. package/dist/location-8Ho8ZNv_.js +0 -499
  58. package/dist/location-DN0AI4ir.cjs +0 -1
@@ -1,13 +0,0 @@
1
- "use strict";const i=require("react/jsx-runtime"),a=require("react"),Y=require("react-router"),I=require("./location-DN0AI4ir.cjs"),le=require("@aiquants/markdown/code-blocks"),D=require("./dataRoute-vXGZMVB-.cjs"),he=require("@aiquants/markdown"),Be=require("@aiquants/markdown/source-lines"),Gn=require("@aiquants/markdown/viewer-settings"),X=require("./storage-DM0EvkVf.cjs"),Kn=require("@aiquants/route-revalidation");function Wn(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=Wn(a),He=Object.freeze(["en","ja"]),Ft="en",We=e=>`viewerSpreadsheet${e.charAt(0).toUpperCase()}${e.slice(1)}`,It=Object.freeze(Object.keys(le.SPREADSHEET_BLOCK_LABEL_CATALOGS.en)),$t=e=>Object.fromEntries(It.map(t=>[We(t),le.SPREADSHEET_BLOCK_LABEL_CATALOGS[e][t].text])),qt=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"]),viewerSvgImageSourceRegion:Object.freeze(["name"]),...Object.fromEntries(It.filter(e=>le.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e].length>0).map(e=>[We(e),le.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e]]))}),Xn=/\{(\w+)\}/gu,Bt={...$t("en"),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",showSvgMarkup:"Show the image's SVG 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}`,previewTablePending:"This table can be edited once the preview shows the draft.",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",viewerBlockFailed:"This block could not be shown.",viewerSvgImageToolbar:"SVG image",viewerSvgImageSource:"Source",viewerSvgImageSourceRegion:"Source of {name}",viewerSvgImageLoading:"Loading the source…",viewerSvgImageFailed:"The source could not be read.",viewerSvgImageRetry:"Try again",viewerSvgImageTruncated:"Only the beginning of this file is shown.",viewerSvgImageCopy:"Copy the source",viewerSvgImageCopied:"Copied the source.",viewerSvgImageCopyFailed:"Could not copy the source.",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",panelMove:"Move the panel",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"},Yn={...$t("ja"),explorerRegion:"エクスプローラー",sourceLabel:"ソース",refreshTreeLabel:"ツリーを更新",refreshTree:"ソースからツリーと開いている文書を読み込み直す",treeRefreshed:"ツリーをソースから読み込み直しました",treeRefreshFailed:e=>`ツリーを読み込み直せませんでした: ${e}`,refreshDocumentLabel:"文書を更新",refreshDocument:"ソースから文書を読み込み直す",refreshDocumentNamed:e=>`${e} を更新`,documentRefreshed:e=>`${e} を読み込み直しました`,documentRefreshFailed:e=>`文書を読み込み直せませんでした: ${e}`,showMarkupLabel:"ソース",showMarkup:"文書の Markdown を書いたまま表示",showSvgMarkup:"画像の SVG を書いたまま表示",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}`,previewTablePending:"プレビューが下書きを描くと、この表を編集できます。",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:"埋め込みのコンテンツ",viewerBlockFailed:"このブロックを表示できませんでした。",viewerSvgImageToolbar:"SVG の画像",viewerSvgImageSource:"ソース",viewerSvgImageSourceRegion:"{name} のソース",viewerSvgImageLoading:"ソースを読み込み中…",viewerSvgImageFailed:"ソースを読み込めませんでした。",viewerSvgImageRetry:"再試行",viewerSvgImageTruncated:"このファイルは先頭だけを表示しています。",viewerSvgImageCopy:"ソースをコピー",viewerSvgImageCopied:"ソースをコピーしました。",viewerSvgImageCopyFailed:"ソースをコピーできませんでした。",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:"カスタム",panelMove:"パネルを移動",panelMovePreviousColumn:"前の列へ移動",panelMoveNextColumn:"次の列へ移動",panelMoveUp:"上へ移動",panelMoveDown:"下へ移動",panelMoved:"{title} を {column} 列目の {position} 番目へ移動しました",panelMoveUnavailable:"{title} は「{move}」できません",panelDragStarted:"{title} を持ち上げました",panelDragCancelled:"{title} の移動を取り消しました",hiddenPanelsTitle:"隠したパネル:",hiddenPanelBadge:"非表示",hiddenPanelNotice:"このパネルは隠しています",multiColumnEmpty:"この列は空です",multiColumnRegion:"{column} 列目",panelDropHere:"ここへパネルをドロップ"},Ht=Object.freeze({en:Object.freeze(Bt),ja:Object.freeze(Yn)}),Xe=Object.freeze(Object.keys(Bt)),Qn=new Set(Xe),Jn=e=>Qn.has(e),xe=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,Vt=e=>{if(e===void 0)return Ft;if(He.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${He.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${xe(e)}`)},Ve=(e,t)=>{const n=Ht[Vt(e)];if(t===void 0)return n;if(t===null||typeof t!="object")throw new RangeError(`[markdown-explorer] labels must be an object; got ${xe(t)}`);if(!I.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${xe(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!Jn(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${Xe.join(", ")}`);const l=r[s];if(l===void 0)continue;const f=typeof n[s];if(typeof l!==f)throw new TypeError(`[markdown-explorer] labels.${s} must be a ${f}; got ${xe(l)}`);if(typeof l=="string"&&l.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const h=qt[s];if(typeof l=="string"&&h!==void 0){for(const[,m]of l.matchAll(Xn))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]=l}return Object.freeze(o)},er=(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(l=>Object.hasOwn(n,l)&&Object.is(n[l],r[l]))},Ue=Object.freeze(["light","dark"]),tr=e=>{if(e===void 0)return"light";if(Ue.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${Ue.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},Ut=a.createContext(null),P=()=>{const e=a.use(Ut);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},pe=e=>{const{viewSettings:t}=P(),n=()=>e(t.getSnapshot());return a.useSyncExternalStore(t.subscribe,n,n)},Te=()=>{const{config:e}=P(),t=Y.useParams()["*"],[n]=Y.useSearchParams(),r=n.toString();return a.useMemo(()=>I.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])},zt={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[zt[t][0]],se=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=P(),s=ee(o,e.reason),l=o[zt[e.reason][1]],f=e.reason==="unauthorized"||e.reason==="forbidden"||e.reason==="failed"?"danger":"warning";return i.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:[i.jsx("p",{className:"aqmx-callout-title",children:s}),i.jsx("p",{className:"aqmx-callout-body",children:l}),e.reason==="unauthorized"?i.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:()=>window.location.reload(),children:o.reloadPage}):n!==void 0&&e.reason==="failed"?i.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:n,children:o.retry}):null]})},nr=(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:""},rr=(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}},ce=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},Zt="<<<<<<<",Gt="=======",Kt=">>>>>>>",dt=(e,t)=>e===t||e.startsWith(`${t} `),ut=e=>Wt(e.split(`
2
- `)),Wt=e=>{const t=[];let n=null,r=null,o=0;for(const s of e){o+=1;const l=s.charCodeAt(0);l!==60&&l!==61&&l!==62||(dt(s,Zt)?(n=o,r=null):s===Gt?n!==null&&r===null?r=o:n=null:dt(s,Kt)&&(n!==null&&r!==null&&t.push({start:n,separator:r,end:o}),n=null,r=null))}return t},ft=e=>e.includes(`\r
3
- `)?`\r
4
- `:`
5
- `,De=e=>e.replace(/\r\n?/gu,`
6
- `),or=(e,t)=>t===`
7
- `?e:e.replaceAll(`
8
- `,`\r
9
- `),sr=3,ir=/^\d+(?:\.\d+)?$/u,lr=e=>{if(e===null||!ir.test(e))return null;const t=Number(e);return t>=I.EDIT_SPLIT_MIN_PERCENT&&t<=I.EDIT_SPLIT_MAX_PERCENT?t:null},Pe=Object.freeze({kind:"idle"}),mt=Object.freeze({kind:"draft"}),ar=({data:e,conflictLabels:t,onSaveSettled:n,sideBySideSetting:r,editorShareSetting:o})=>{const s=new Map,l=new Map,f=new Map,h=new Map,m=new Map,u=ce();let p=null,v=null,b=null;const R=(c,d)=>{c.value={...c.value,...d},u.emit()},O=(c,d)=>s.get(c)===d,T=async(c,d)=>{d.controller.abort(),d.controller=new AbortController;const{signal:E}=d.controller;R(d,{phase:{kind:"opening"}});const L=await e.edit(c,E);if(!O(c,d)||E.aborted||!("kind"in L))return;if(L.kind==="grant"){R(d,{phase:{kind:"grant",href:L.href}});return}if(L.kind==="failure"){R(d,{phase:{kind:"failed",failure:L.failure}});return}const M=De(L.text),j=L.kind==="draft";d.base={text:M,version:j?null:L.version},d.draft=M,d.ending=ft(L.text),R(d,{phase:{kind:"editing"},history:j?!1:L.history,dirty:!1,save:j?mt:Pe,generation:d.value.generation+1})},N=c=>{const d=s.get(c);d!==void 0&&(d.controller.abort(),s.delete(c),f.delete(c))},A=(c,d,E)=>(c.set(d,E),()=>{c.get(d)===E&&c.delete(d)}),x=(c,d,E,L={})=>{R(d,{...L,save:E}),n(c,E)},w=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:E}=d.base;if(E===null){n(c,mt);return}const L=ut(d.draft).length;if(L>0){x(c,d,{kind:"conflicts",count:L});return}d.controller.abort(),d.controller=new AbortController;const{signal:M}=d.controller;let j={text:d.base.text,version:E},F=d.draft,z=!1;R(d,{save:{kind:"saving"}});for(let U=0;U<sr;U+=1){const B=await e.save(c,j.version,or(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},x(c,d,{kind:"saved",merged:z},{dirty:d.draft!==F});return}if(B.kind==="grant"){x(c,d,{kind:"grant",href:B.href});return}if(B.kind==="failure"){x(c,d,{kind:"failed",failure:B.failure});return}const{mergeDraft:K}=await Promise.resolve().then(()=>require("./merge-DlPkU2Jc.cjs"));if(!O(c,d)||M.aborted)return;const q=h.get(c);q?.flush();const Q=De(B.text),g=K(j.text,d.draft,Q,t());if(j={text:Q,version:B.version},d.base=j,d.ending=ft(B.text),d.draft=g.text,q?.adopt(g.text),g.kind==="conflicts"){x(c,d,{kind:"conflicts",count:g.conflicts},{dirty:!0,generation:d.value.generation+1});return}if(z=!0,F=g.text,F===j.text){x(c,d,{kind:"saved",merged:z},{dirty:!1,generation:d.value.generation+1});return}R(d,{dirty:!0,generation:d.value.generation+1})}x(c,d,{kind:"failed",failure:{reason:"failed"}})};return{session:c=>s.get(c)?.value,subscribe:u.subscribe,start:(c,d)=>{const E=s.get(c);if(E!==void 0){R(E,{request:{anchor:d},view:"editor"}),(E.value.phase.kind==="failed"||E.value.phase.kind==="grant")&&T(c,E);return}l.delete(c);const L={value:{path:c,phase:{kind:"opening"},view:"editor",previewPrepared:!1,history:!1,dirty:!1,save:Pe,generation:0,request:{anchor:d}},base:null,draft:"",ending:`
10
- `,controller:new AbortController};s.set(c,L),T(c,L)},retry:c=>{const d=s.get(c);d===void 0||d.value.phase.kind==="editing"||T(c,d)},draft:c=>{const d=s.get(c);return d===void 0||d.base===null?null:d.draft},setDraft:(c,d)=>{const E=s.get(c);if(E===void 0||E.base===null)return;E.draft=d;const L={},M=d!==E.base.text;M!==E.value.dirty&&(L.dirty=M);const{save:j}=E.value;if(j.kind==="conflicts"){const F=ut(d).length;F===0?L.save=Pe:F!==j.count&&(L.save={kind:"conflicts",count:F})}(L.dirty!==void 0||L.save!==void 0)&&R(E,L)},consumeRequest:c=>{const d=s.get(c);d!==void 0&&d.value.request!==null&&R(d,{request:null})},save:w,replaceDraft:(c,d)=>{const E=h.get(c);E?.flush();const L=s.get(c);if(L===void 0||L.base===null)return;const M=De(d);L.draft=M,E?.adopt(M),R(L,{dirty:M!==L.base.text,generation:L.value.generation+1})},close:c=>{if(!s.has(c))return;const d=h.get(c),E=d===void 0?null:d.returnPoint();N(c),E===null?l.delete(c):l.set(c,E),u.emit()},takeReturn:c=>{const d=l.get(c)??null;return l.delete(c),d},dirtyPaths:()=>[...s.values()].filter(c=>c.value.dirty).map(c=>c.value.path),discard:c=>{for(const d of c)N(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=>{b?.settle(!1);const E={paths:c,settle:L=>{if(b===E){if(b=null,L)for(const M of c)N(M);u.emit(),d(L)}}};b=E,u.emit()}),discardRequest:()=>b,sideBySide:()=>(p??=r.read(),p),setSideBySide:c=>{p!==c&&(p=c,r.write(c),u.emit())},editorShare:()=>(v??=o.read()??I.EDIT_SPLIT_DEFAULT_PERCENT,v),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(I.EDIT_SPLIT_MAX_PERCENT,Math.max(I.EDIT_SPLIT_MIN_PERCENT,c));v!==d&&(v=d,o.write(d))},setView:(c,d)=>{const E=s.get(c);E===void 0||E.value.view===d||(h.get(c)?.beforeView(d),R(E,{view:d,previewPrepared:E.value.previewPrepared||d==="preview"}))},preparePreview:c=>{const d=s.get(c);d!==void 0&&!d.value.previewPrepared&&R(d,{previewPrepared:!0})}}},Ye=e=>{e.preventDefault(),e.stopPropagation()},Xt=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,Yt="data-aqmx-content-pane",Se=Object.freeze({[Yt]:""}),cr="--aqmx-dialog-left",dr="--aqmx-dialog-top",ur='[data-testid="markdown-explorer"]',fr=e=>{const t=e.closest(ur)?.querySelectorAll(`[${Yt}]`),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},mr=e=>{const t=Xt(getComputedStyle(e).marginTop);if(Number.isNaN(t))return null;const n=fr(e),r=e.getBoundingClientRect(),o=e.ownerDocument.documentElement,{left:s,top:l}=I.centeredDialogPosition(n.getBoundingClientRect(),{width:r.width+2*t,height:r.height+2*t},{width:o.clientWidth,height:o.clientHeight});return e.style.setProperty(cr,`${String(s)}px`),e.style.setProperty(dr,`${String(l)}px`),n},hr=e=>e.preventDefault(),Qt=({open:e,onOpen:t,onDismiss:n})=>{const r=a.useRef(null),o=a.useRef(null),s=a.useRef(!1),l=a.useRef(t);a.useLayoutEffect(()=>{l.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(),l.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(()=>b());let v=null;const b=()=>{const O=mr(u);O===null||O===v||(v!==null&&p.unobserve(v),p.observe(O),v=O)};b(),p.observe(u);const R=u.ownerDocument.defaultView;return R?.addEventListener("resize",b),u.ownerDocument.addEventListener("scroll",b,{capture:!0,passive:!0}),()=>{p.disconnect(),R?.removeEventListener("resize",b),u.ownerDocument.removeEventListener("scroll",b,{capture:!0})}},[e]);const f=a.useCallback(u=>{u.key!=="Escape"||u.defaultPrevented||(Ye(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:hr,onClose:m}},Jt=({open:e,title:t,body:n,confirmLabel:r,cancelLabel:o,onConfirm:s,onCancel:l,testId:f})=>{const h=a.useRef(null),m=a.useId(),u=a.useId(),p=a.useCallback(()=>h.current?.focus(),[]),v=Qt({open:e,onOpen:p,onDismiss:l});return i.jsx("dialog",{...v,className:"aqmx-confirm","aria-labelledby":m,"aria-describedby":u,"data-testid":f,children:i.jsxs("div",{className:"aqmx-confirm-panel",children:[i.jsx("p",{id:m,className:"aqmx-confirm-title",children:t}),i.jsx("p",{id:u,className:"aqmx-confirm-body",children:n}),i.jsxs("div",{className:"aqmx-confirm-actions",children:[i.jsx("button",{ref:h,type:"button",className:"aqmx-callout-action","data-testid":`${f}-cancel`,onClick:l,children:o}),i.jsx("button",{type:"button",className:"aqmx-callout-action","data-aqmx-tone":"danger","data-testid":`${f}-confirm`,onClick:s,children:r})]})]})})},ge=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},en=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),fe=e=>e.status==="fulfilled"?e.value:void 0,tn=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!1}),pr=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!0}),gr=(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 l=s.lazy===!0?n(s.path):void 0,f=s.lazy===!0?l?.status==="loaded"?l.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},nn=(e,t,n)=>{const r=fe(e.read(t));if(r===void 0||r.status==="deferred")return tn;if(r.status==="error")return{readme:{status:"failed",failure:r.failure,retry:()=>e.retry(t)},claim:!1};const o=gr(r.entries,n,l=>e.children(t,l));if(o!==null)return{readme:{status:"ok",readme:I.folderReadmeOf(o)},claim:!1};const s=e.children(t,n);return s===void 0||s.status==="loading"?pr:s.status==="failed"?{readme:{status:"failed",failure:s.failure,retry:()=>e.retryChildren(t,n)},claim:!0}:{readme:{status:"ok",readme:I.folderReadmeOf(s.entries)},claim:!0}},vr=(e,t,n)=>{const{readme:r}=nn(e,t,n);return r.status==="ok"?r.readme:null},wr=(e,t,n)=>{const r=Y.matchPath({path:`${e.basePath}/*`,end:!0},t.pathname);if(r===null)return new Set;const{location:o}=I.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)}},rn=e=>{const{edits:t}=P(),n=a.useCallback(()=>t.session(e),[t,e]);return a.useSyncExternalStore(t.subscribe,n,Er)},on=()=>!1,Er=()=>{},xr=()=>{const{edits:e}=P();return a.useSyncExternalStore(e.subscribe,e.hasSessions,on)},sn=()=>{const{edits:e}=P();return a.useSyncExternalStore(e.subscribe,e.sideBySide,on)},br=()=>null,Sr=()=>{const{edits:e,labels:t,config:n,trees:r}=P(),o=a.useRef([]),s=a.useCallback(({nextLocation:b})=>{const R=wr(n,b,(O,T)=>vr(r,O,T));return e.flushDrafts(),o.current=e.dirtyPaths().filter(O=>!R.has(O)),o.current.length>0},[e,n,r]),l=Y.useBlocker(s),f=xr();a.useEffect(()=>{if(!f)return;const b=R=>{e.flushDrafts(),e.dirtyPaths().length!==0&&(R.preventDefault(),R.returnValue=!0)};return window.addEventListener("beforeunload",b),()=>window.removeEventListener("beforeunload",b)},[f,e]);const h=a.useSyncExternalStore(e.subscribe,e.discardRequest,br),m=l.state==="blocked",u=m?o.current:h===null?[]:h.paths,p=u.map(b=>D.lastPathSegment(b)).join(", "),v=u.length>0&&u.every(b=>e.session(b)?.save.kind==="draft");return i.jsx(Jt,{open:m||h!==null,title:v?t.draftDiscardTitle:t.unsavedTitle,body:v?t.draftDiscardBody(p):t.unsavedBody(p),confirmLabel:t.unsavedDiscard,cancelLabel:t.unsavedStay,testId:"markdown-explorer-unsaved-guard",onConfirm:()=>{if(l.state==="blocked"){e.discard(o.current),l.proceed();return}h?.settle(!0)},onCancel:()=>{if(l.state==="blocked"){l.reset();return}h?.settle(!1)}})};function yr({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 kr=y.forwardRef(yr);let _e=null;const ln=()=>(_e??=Promise.resolve().then(()=>require("./EditSurface-Bk4tdJ99.cjs")).catch(e=>{throw _e=null,e}),_e),Rr=()=>{ln().catch(()=>{})},Tr=e=>{const{default:t}=a.use(ln());return i.jsx(t,{...e})};class Or 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 Qe=`[${Be.SOURCE_LINES_ATTRIBUTE}]`,Lr="[data-aqmd-content]",Cr='a[href], button, input, select, textarea, summary, label, [contenteditable], [role="menu"], iframe, video, audio, object, embed, svg, [data-aqmd-spreadsheet-editable], [data-aqmd-spreadsheet-fullscreen], [data-aqmd-svg-image-source]',Ar=200,ve=e=>Be.parseSourceLines(e.getAttribute(Be.SOURCE_LINES_ATTRIBUTE)),Mr=(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(Qe)){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}},jr=(e,t)=>{let n=0;for(let r=e.indexOf(t);r>=0;r=e.indexOf(t,r+t.length))n+=1;return n},an=e=>e.closest(Lr)!==null&&e.closest(Cr)===null,cn=(e,t,n)=>{const r=Mr(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 l=Nr(o,n);return l===null?{lines:r.lines,word:null,occurrence:0,clientTop:ye(o)}:{lines:r.lines,word:l.text,occurrence:l.occurrence,clientTop:l.clientTop}},dn=(e,t)=>{let n=null,r=null,o=null;for(const l of e.querySelectorAll(Qe)){const f=ve(l);if(f===null)continue;n??=fn(t,l);const{top:h,bottom:m}=l.getBoundingClientRect();h<=n&&n<m?r={lines:f,block:l}:o===null&&h>=n&&(o={lines:f,block:l})}const s=r===null?o:r;return s===null?null:{lines:s.lines,word:null,occurrence:0,clientTop:ye(s.block)}},un=e=>e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,fn=(e,t)=>{const n=Number.parseFloat(getComputedStyle(t).scrollMarginTop);return un(e)+(Number.isFinite(n)?n:0)},Nr=(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>Ar||/[\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:jr(o.toString(),r),clientTop:n.getBoundingClientRect().top}},Dr=(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 l=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(l===t.occurrence)return{line:f,column:m};l+=1}}return l>0?Pr(n,r,o,t.word)??s:s},Pr=(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},mn=(e,t)=>{let n=null,r=null;for(const o of e.querySelectorAll(Qe)){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},hn=(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:l,height:f}=s.getBoundingClientRect();if(f>0)return l}return e.getBoundingClientRect().top},Je=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})}),_r=e=>Je[e],we=()=>{const e=Y.useNavigate();return a.useCallback((t,n)=>{e(t,Je[n])},[e])},pn=({navigation:e,...t})=>i.jsx(Y.Link,{...t,...Je[e]}),et=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},gn=(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 l=a.useCallback(m=>{if(r.current!==m)return;const u=o.current;if(u!==null){u.then(()=>l(m));return}e.prefetch(m);const p=e.peek(m);if(p?.status!=="pending")return;const v=Promise.allSettled([p.promise]);o.current=v,v.then(()=>{o.current===v&&(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,l(u)},I.PREFETCH_DWELL_MS)))},[s,t,l]),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])},Fr=a.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-A6-qEpz7.cjs")).then(e=>({default:e.NativeScrollBar})));class Ir 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 vn=({scroller:e,withCircle:t})=>i.jsx(Ir,{children:i.jsx(a.Suspense,{fallback:null,children:i.jsx(Fr,{scroller:e,withCircle:t})})}),wn=e=>i.jsx(vn,{scroller:e,withCircle:!0}),En=()=>{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 l=e.get(o);if(l!==void 0&&l>1){e.set(o,l-1);return}e.delete(o),r(o)}},isHeld:o=>e.has(o),resumes:o=>t.delete(o),heldKeys:()=>[...e.keys()]}},ke=(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,l)=>ke(s,t[l]));const n=e,r=t,o=Object.keys(n);return o.length!==Object.keys(r).length?!1:o.every(s=>Object.hasOwn(r,s)&&ke(n[s],r[s]))},$r=55e3,ht=Object.freeze({status:"deferred"}),pt=Object.freeze({status:"refreshed"}),Fe=Object.freeze({status:"superseded"}),re=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,xn=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",qr=({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=En(),o=ce(),s=new WeakSet;let l=0;const f=o.emit,h=()=>(l+=1,l),m=()=>{if(!(n.size<=t))for(const x of[...n.keys()]){if(n.size<=t)return;r.isHeld(x)||n.delete(x)}},u=(x,w)=>{n.delete(x),n.set(x,w)},p=x=>performance.now()-x.validatedAt>=$r,v=(x,w,c)=>{const d=n.get(x),E=re(d?.snapshot),L=c||d?.refreshPending===!0,M=ge(e.document(x,{refresh:L}).then(F=>({status:"loaded",document:F}))),j={snapshot:{status:"pending",promise:M,previous:E},validatedAt:performance.now(),opened:w,background:null,refreshPending:!1,seeded:void 0,stamp:h()};return u(x,j),m(),M.then(F=>{n.get(x)===j&&(j.snapshot=F,j.stamp=h(),f())}),j},b=(x,w,c,d,E,L)=>{w.background===c&&(w.background=null,!(n.get(x)!==w||w.snapshot!==d)&&(E.kind==="failure"&&d.document.kind!=="failure"||(w.validatedAt=L,w.stamp=h(),ke(d.document,E)||(w.snapshot={status:"loaded",document:E}),f())))},R=async(x,w)=>{const c=w.snapshot;if(c.status!=="loaded")return null;const d={};w.background=d;const E=performance.now(),L=e.document(x,{refresh:w.refreshPending});w.refreshPending=!1;const M=await L,j=w.background===d&&n.get(x)===w&&w.snapshot===c;return b(x,w,d,c,M,E),j?M:null},O=(x,w)=>{const{snapshot:c}=w;return c.status==="pending"?!1:c.status==="loaded"&&c.document.kind!=="failure"?(R(x,w),!1):(c.status==="loaded"&&s.add(c),v(x,!0,!1),!0)},T=x=>{const w=r.hold(x);let c=!1;return()=>{if(c)return;c=!0,w();const d=n.get(x);d!==void 0&&u(x,d),m()}};return{peek:x=>n.get(x)?.snapshot,peekSeeded:x=>n.get(x)?.seeded,answerStampOf:x=>n.get(x)?.stamp,prefetch:x=>{const w=n.get(x);w!==void 0&&w.snapshot.status!=="deferred"||(v(x,!1,!1),f())},open:x=>{const w=r.resumes(x),c=T(x),d=n.get(x);if(d===void 0||d.snapshot.status==="deferred")return v(x,!0,!1),f(),c;if(u(x,d),w)return c;const{snapshot:E}=d;return E.status==="pending"?(d.opened=!0,c):E.document.kind==="failure"?(d.opened||p(d)?(s.add(E),v(x,!0,!1),f()):d.opened=!0,c):(d.opened=!0,d.background===null&&p(d)&&R(x,d),c)},retain:T,retry:x=>{const w=n.get(x);w===void 0||w.snapshot.status!=="loaded"||w.snapshot.document.kind!=="failure"||(v(x,!0,!1),f())},seed:(x,w)=>{const c=performance.now(),d=ge(w.then(F=>F===null?ht:{status:"loaded",document:F},()=>ht)),E=n.get(x);if(E!==void 0&&E.snapshot.status==="loaded"){const F=E.snapshot,z={};E.background=z,d.then(U=>{if(U.status==="loaded"){b(x,E,z,F,U.document,c);return}E.background===z&&(E.background=null)});return}const L=E!==void 0&&E.snapshot.status==="pending"?E.snapshot.previous:null,M={status:"pending",promise:d,previous:L},j={snapshot:M,validatedAt:c,opened:E?.opened===!0,background:null,refreshPending:E?.refreshPending===!0,seeded:M,stamp:h()};u(x,j),m(),d.then(F=>{n.get(x)===j&&(F.status==="deferred"&&r.isHeld(x)?v(x,j.opened,!1):(j.snapshot=F,j.stamp=h()),f())})},invalidate:()=>{let x=!1;for(const[w,c]of[...n]){if(c.validatedAt=Number.NEGATIVE_INFINITY,c.opened=!0,c.refreshPending=!0,!r.isHeld(w))continue;const{snapshot:d}=c;if(d.status!=="pending"){O(w,c)&&(x=!0);continue}d.promise.then(()=>{n.get(w)===c&&c.refreshPending&&r.isHeld(w)&&O(w,c)&&f()})}x&&f()},refresh:async x=>{const w=n.get(x);if(w!==void 0&&xn(w.snapshot)){w.refreshPending=!0;const d=await R(x,w);return d===null?Fe:d.kind==="failure"?{status:"failed",failure:d.failure}:pt}const c=v(x,!0,!0);return f(),c.snapshot.status!=="pending"?Fe:(await c.snapshot.promise,n.get(x)===c?pt:Fe)},clear:()=>{n.clear();for(const x of r.heldKeys())v(x,!0,!1);f()},subscribe:o.subscribe,noteFailureShown:x=>s.has(x)?!1:(s.add(x),!0)}};function Br({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 Hr=y.forwardRef(Br);function Vr({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 Ur=y.forwardRef(Vr);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",{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 Zr=y.forwardRef(zr),Gr=2e3,gt=Object.freeze({outcome:"idle"}),Kr=e=>{const t=navigator.clipboard;return t===void 0?Promise.reject(new Error("[markdown-explorer] this browser has no asynchronous clipboard")):t.writeText(e)},Wr=({text:e})=>{const{announcer:t,labels:n}=P(),[r,o]=a.useState(gt);a.useEffect(()=>{if(r.outcome==="idle")return;const h=setTimeout(()=>o(gt),Gr);return()=>clearTimeout(h)},[r]);const s=h=>{o({outcome:h}),t.announce(h==="copied"?n.copiedText:n.copyTextFailed)},l=()=>{Kr(e).then(()=>s("copied"),()=>s("failed"))},f=r.outcome==="copied"?n.copiedText:r.outcome==="failed"?n.copyTextFailed:n.copyText;return i.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":n.copyText,title:f,onClick:l,"data-aqmx-copy-outcome":r.outcome,"data-testid":"markdown-explorer-file-copy",children:r.outcome==="copied"?i.jsx(Hr,{}):r.outcome==="failed"?i.jsx(Zr,{}):i.jsx(Ur,{})})},ae=a.createContext("fill"),Xr=Object.freeze({blockSize:"100%"}),de=({scrollerProps:e,children:t})=>a.use(ae)==="content"?i.jsx(he.HostedScrollArea,{scrollerProps:e,children:t}):i.jsx(he.HostedScrollArea,{scrollerProps:{...e,style:Xr},rowClassName:"aqmx-document-scroll-row",renderScrollBar:wn,children:t});function Yr({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 Qr=y.forwardRef(Yr);function Jr({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 eo=y.forwardRef(Jr),Oe=({name:e,openUrl:t,downloadUrl:n,icon:r,children:o})=>{const{labels:s}=P();return i.jsxs("div",{className:"aqmx-document-toolbar",children:[i.jsx("span",{className:"aqmx-document-file-icon","aria-hidden":"true",children:r}),i.jsx("span",{className:"aqmx-document-title",title:e,"data-testid":"markdown-explorer-file-name",children:e}),o,i.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:i.jsx(eo,{})}),i.jsx("a",{className:"aqmx-icon-button",href:n,download:e,"aria-label":s.download,title:s.download,"data-testid":"markdown-explorer-file-download",children:i.jsx(Qr,{})})]})};function to({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 no=y.forwardRef(to),ro=Object.freeze({className:"aqmx-document-stage"}),oo=({document:e})=>{const{labels:t}=P();return i.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[i.jsx(Oe,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:i.jsx(no,{})}),i.jsx(de,{scrollerProps:ro,children:i.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-file-not-shown",children:[i.jsx("p",{className:"aqmx-callout-body",children:t.fileNotShown}),i.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-file-not-shown-download",children:t.download})]})})]})},Le="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",so=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},io=/(%[0-9A-Fa-f]{2})/u,tt=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(io).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))},bn=e=>`#${encodeURIComponent(e)}`,lo=e=>{if(e==="#")return!0;const t=tt(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},Sn=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},ao="http://www.w3.org/1999/xhtml",vt=(e,t)=>{if(t==="")return null;const n=Sn(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===ao&&r.getAttribute("name")===t)return r;return null},yn=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=vt(e,t.slice(1));if(n!==null)return n;const r=tt(t);return r===null?null:vt(e,r)},wt=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"},co=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"},uo=(e,t)=>{const n=t.closest(Le),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&wt(r))return r;const o=e.getBoundingClientRect().height,{documentElement:s,scrollingElement:l}=e.ownerDocument;for(let f=e.parentElement;f!==null&&f!==s;f=f.parentElement)if(wt(f)&&f.scrollHeight>f.clientHeight&&f.clientHeight<o)return f;return l instanceof Element&&co(e.ownerDocument)&&l.scrollHeight>l.clientHeight&&l.clientHeight<o?l:r},fo=Object.freeze({scrollerOf:uo,reveal:e=>{e.scrollIntoView(ze)}}),ze=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),mo=(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")}}},ho=(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),l=t.getBoundingClientRect(),f=l.height+s+Number.parseFloat(o)>e.clientHeight;if(!f&&Math.abs(l.top-s-n)<1){t.scrollIntoView(ze);return}e.scrollBy({top:f?l.top-n-e.clientHeight:l.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(ze)},po=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(Le)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},Et=(e,t,n)=>{if(e===null)return null;const r=yn(e,t);return r===null?(lo(t)&&po(e,n),null):(mo(e,r),ho(n.scrollerOf(e,r),r),n.reveal(r),r)};function go({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 vo=y.forwardRef(go);function wo({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 Eo=y.forwardRef(wo);function xo({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 bo=y.forwardRef(xo);function So({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 yo=y.forwardRef(So),Ze="data-aqmx-key-repeat",Re=Object.freeze({[Ze]:"allow"}),ko=`[${Ze}="${Re[Ze]}"]`,Ro=()=>{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(ko)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},be=Object.freeze([1/I.GOLDEN_RATIO**2,1/I.GOLDEN_RATIO,1,I.GOLDEN_RATIO,I.GOLDEN_RATIO**2]),xt=Object.freeze({mode:"fit"}),To=1,kn=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),bt=`[data-testid="${kn["data-testid"]}"]`,Rn=a.createContext(null),Oo=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=To?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,St=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<be.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?be.findIndex(o=>o>t):be.findLastIndex(o=>o<t);return r===-1?null:r},yt=(e,t,n)=>{if(e.mode==="level"){const o=St(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=St(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},Lo=(e,t)=>{if(e<=0||t<=0)return 0;const n=Math.trunc(Math.log(t/e)/Math.log(I.GOLDEN_RATIO));return n===0?0:n},kt=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}}},Co=e=>{const t=be[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},Rt=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},Ao=({document:e})=>{const{labels:t}=P(),n=a.use(Rn),[r]=a.useState(()=>n===null?null:n.read(e.url)),[o,s]=a.useState(r===null?xt:r.zoom),[l,f]=a.useState(r===null?null:r.reported),[h,m]=a.useState(null),u=a.useRef(null),p=a.useCallback(w=>{const{naturalWidth:c,naturalHeight:d}=w;f(E=>Rt(E,c,d))},[]),v=a.useCallback(w=>{u.current=w,!(w===null||!w.complete)&&(w.naturalWidth>0||w.naturalHeight>0?p(w):w.decode().then(()=>p(w),()=>{}))},[p]);a.useEffect(()=>{n!==null&&l!==null&&n.save(e.url,{zoom:o,reported:l})},[n,e.url,o,l]),a.useLayoutEffect(()=>{const w=u.current;if(w===null||l===null||o.mode!=="fit")return;const c=()=>m(E=>Rt(E,w.clientWidth,w.clientHeight));if(c(),typeof ResizeObserver>"u")return;const d=new ResizeObserver(c);return d.observe(w),()=>d.disconnect()},[l,o.mode]);const b=l===null||h===null?null:Oo(l,h),R=yt(o,b,-1),O=yt(o,b,1),T=o.mode==="level"?Co(o.index):null,N=a.useRef({zoomIn:O,zoomOut:R});a.useLayoutEffect(()=>{N.current={zoomIn:O,zoomOut:R}});const A=a.useRef(null);a.useLayoutEffect(()=>{const w=A.current,c=u.current?.closest(bt);A.current=null,!(w===null||c===null||c===void 0)&&(c.scrollLeft=w.across*c.scrollWidth-w.x,c.scrollTop=w.down*c.scrollHeight-w.y)},[o]),a.useEffect(()=>{const w=u.current?.closest(bt);if(w==null)return;let c=null;const d=M=>{const j=kt(M.touches);c=j===null?null:{distance:j.distance,steps:0}},E=M=>{const j=kt(M.touches);if(c===null||j===null)return;M.preventDefault();const F=Lo(c.distance,j.distance);if(F===c.steps)return;const z=F>c.steps?1:-1,U=z===1?N.current.zoomIn:N.current.zoomOut;if(U===null)return;c.steps+=z;const B=w.getBoundingClientRect(),K=j.middle.x-B.left,q=j.middle.y-B.top;A.current=w.scrollWidth>0&&w.scrollHeight>0?{x:K,y:q,across:(w.scrollLeft+K)/w.scrollWidth,down:(w.scrollTop+q)/w.scrollHeight}:null,s(U)},L=M=>{M.touches.length<2&&(c=null)};return w.addEventListener("touchstart",d,{passive:!0}),w.addEventListener("touchmove",E,{passive:!1}),w.addEventListener("touchend",L,{passive:!0}),w.addEventListener("touchcancel",L,{passive:!0}),()=>{w.removeEventListener("touchstart",d),w.removeEventListener("touchmove",E),w.removeEventListener("touchend",L),w.removeEventListener("touchcancel",L)}},[]);const x=o.mode==="level"&&T!==null?{width:`${o.base.width*T}px`,height:`${o.base.height*T}px`}:void 0;return i.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[i.jsxs(Oe,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:i.jsx(yo,{}),children:[i.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":R===null,onClick:()=>{R!==null&&s(R)},...Re,children:i.jsx(Eo,{})}),i.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:T===null?t.imageFitLevel:t.imageZoomLevel(Math.round(T*100))}),i.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":O===null,onClick:()=>{O!==null&&s(O)},...Re,children:i.jsx(bo,{})}),i.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(xt),children:i.jsx(vo,{})})]}),i.jsx(de,{scrollerProps:kn,children:i.jsx("img",{ref:v,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:x,onLoad:w=>p(w.currentTarget),"data-testid":"markdown-explorer-image"})})]})},Mo=async(e,t,n)=>{const r=await e.text(t,n);if(!("kind"in r))throw n.reason;return r.kind==="text"?{kind:"text",text:r.text,truncated:r.truncated}:{kind:"failure",retryable:r.failure.reason==="failed"}},Tn=a.createContext(null),Ce=a.createContext(void 0),On=a.createContext(null),Ae=()=>{const e=a.use(Tn);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},jo=()=>{const e=a.use(On);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"?I.explorerHref(e,{view:"tree",source:n,doc:r}):t.view==="single"?I.explorerHref(e,{view:"single",source:n,doc:r,overrides:t.overrides,embed:t.embed}):I.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides}),No=({children:e})=>{const{config:t}=P(),n=Ae(),r=Te(),o=r.kind==="location"?r.location.source:void 0,s=Y.useHref(Me(t,n.navigation,o,n.currentPath));return i.jsx(Ce,{value:o,children:i.jsx(On,{value:s,children:e})})},Do='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',Po=e=>{const t=e instanceof Element?e.closest(Do):null;return t===null?null:t.getAttribute("data-doc-path")},je=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,_o=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:l,scope:f,children:h})=>{const m=Y.useHref(e),u=p=>{if(je(p)){if(p.preventDefault(),t===f.currentPath&&n!==""){f.scrollWithin(n);return}l(t,n)}};return i.jsx("a",{...s,href:m,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:u,children:h})},Fo=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:l}=P(),f=Ae(),h=a.use(Ce),m=so(e),{navigation:u}=f,p=`${Me(l,u,h,t)}${m}`,v=n===!1?"false":void 0;return u.kind==="page"?i.jsx(pn,{...o,to:p,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":v,children:s}):i.jsx(_o,{to:p,docPath:t,fragment:m,exists:v,className:r,attributes:o,onDocumentLink:u.onDocumentLink,scope:f,children:s})},Io=({className:e,attributes:t,children:n})=>{const{labels:r}=P();return i.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,i.jsxs("span",{className:"aqmx-sr-only",children:[" (",r.inertLink,")"]})]})},$o=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=P(),l=a.use(Ce),f=Y.useHref(`${Me(s,r.navigation,l,r.currentPath)}${e}`),h=m=>{je(m)&&(m.preventDefault(),r.scrollWithin(e))};return i.jsx("a",{...n,href:f,className:t,onClick:h,children:o})},qo=({href:e,className:t,attributes:n,children:r})=>{const o=Ae();if(o.navigation.kind==="page"){const s=l=>{if(!je(l))return;const f=l.currentTarget;e==="#"?o.followEmptyFragment(l.nativeEvent):f.href===f.ownerDocument.URL&&o.followSameUrlJump(e,l.nativeEvent)};return i.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return i.jsx($o,{href:e,className:t,attributes:n,scope:o,children:r})},Bo=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:l})=>t==="doc"?n===void 0||!D.isAcceptableDocumentPath(n)?i.jsx(Io,{className:o,attributes:s,children:l}):i.jsx(Fo,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:l}):e.startsWith("#")?i.jsx(qo,{href:e,className:o,attributes:s,children:l}):i.jsx("a",{...s,href:e,className:o,children:l}),Ho=()=>{const{config:e}=P(),t=Ae(),n=a.use(Ce),r=we();return a.useCallback((o,s)=>{if(!je(s))return!0;s.preventDefault();const l=bn(o.id),{navigation:f}=t;return f.kind==="panel"||tt(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(l),!0):(r(`${Me(e,f,n,t.currentPath)}${l}`,"follow-link"),!0)},[e,t,n,r])},Vo=()=>{const e=jo();return a.useCallback(t=>`${e}${bn(t.id)}`,[e])};function Uo({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 zo=y.forwardRef(Uo);function Zo({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 Go=y.forwardRef(Zo);function Ko({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 Wo=y.forwardRef(Ko),Xo=Object.freeze({className:"aqmx-document-stage"}),Yo=()=>()=>{},Qo=()=>navigator.pdfViewerEnabled!==!1,Jo=()=>null,es=({document:e})=>{const{labels:t}=P(),n=a.useSyncExternalStore(Yo,Qo,Jo);return n===null?null:n?i.jsx("iframe",{className:"aqmx-document-frame",src:e.url,title:e.name,"data-testid":"markdown-explorer-media-player"}):i.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-pdf-not-shown",children:[i.jsx("p",{className:"aqmx-callout-body",children:t.pdfNotShown}),i.jsxs("div",{className:"aqmx-callout-actions",children:[i.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}),i.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-pdf-not-shown-download",children:t.download})]})]})},ts=e=>{switch(e){case"video":return i.jsx(Go,{});case"audio":return i.jsx(Wo,{});case"pdf":return i.jsx(zo,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},ns=({document:e})=>{const{labels:t}=P();switch(e.mediaType){case"video":return i.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 i.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 i.jsx(es,{document:e});default:{const n=e.mediaType;throw new RangeError(`[markdown-explorer] unknown media type ${String(n)}`)}}},rs=({document:e})=>i.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[i.jsx(Oe,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:ts(e.mediaType)}),i.jsx(de,{scrollerProps:Xo,children:i.jsx(ns,{document:e})})]}),nt=e=>e.kind==="markdown"?"markdown":e.kind==="image"&&e.imageType==="svg"?"svg":null,os=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);return s===null?null:nt(s.document)},Ln=e=>{const{config:t}=P(),n=we(),r=a.useCallback(()=>n(I.explorerHref(t,{...e,markup:!e.markup}),"browse"),[t,n,e]);return a.useMemo(()=>({shown:e.markup,toggle:r}),[e.markup,r])},ss=(e,t)=>{const n={};for(const r of Object.keys(le.SPREADSHEET_BLOCK_LABEL_CATALOGS[t])){const o=e[We(r)];o!==le.SPREADSHEET_BLOCK_LABEL_CATALOGS[t][r].text&&(n[`spreadsheet${r.charAt(0).toUpperCase()}${r.slice(1)}`]=o)}return n},is=(e,t)=>({...ss(e,t),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,blockFailed:e.viewerBlockFailed,svgImageToolbar:e.viewerSvgImageToolbar,svgImageSource:e.viewerSvgImageSource,svgImageSourceRegion:e.viewerSvgImageSourceRegion,svgImageLoading:e.viewerSvgImageLoading,svgImageFailed:e.viewerSvgImageFailed,svgImageRetry:e.viewerSvgImageRetry,svgImageTruncated:e.viewerSvgImageTruncated,svgImageCopy:e.viewerSvgImageCopy,svgImageCopied:e.viewerSvgImageCopied,svgImageCopyFailed:e.viewerSvgImageCopyFailed}),Cn=(e,t,n)=>{if(t!==void 0)return t;if(n!==void 0)return n;const[r]=e.documentStyles;if(r===void 0)throw new Error("[markdown-explorer] the configuration has no document style");return r.name},An=(e,t)=>e!==void 0?e:t!==void 0?t:Gn.DEFAULT_CONTENT_ALIGN,Mn=Object.freeze({kind:"empty"}),rt=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),ls=(e,t,n)=>{if(t.view==="multi"||t.overrides[n]===void 0)return null;const r=n==="style"?{align:t.overrides.align}:{style:t.overrides.style};return I.explorerHref(e,{...t,overrides:r})},me=({kind:e,view:t,label:n,stale:r,busy:o,frameRef:s,intent:l,children:f})=>{const h=a.use(ae);return i.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",...l,children:[r?i.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,f]})},as=({absence:e,announces:t,announceFailure:n})=>{const{labels:r,announcer:o}=P(),s=e.kind==="no-readme"?e.folder:null,l=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(()=>{l!==null&&f!==null&&n(r.documentFailed(D.lastPathSegment(l),ee(r,f.reason)))},[l,f,n,r]),e.kind){case"empty":return i.jsx(me,{kind:"empty",label:r.documentRegion,stale:!1,busy:!1,children:i.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-document-empty",children:i.jsx("p",{className:"aqmx-empty-title",children:r.documentEmpty})})});case"loading":return i.jsx(ot,{label:r.documentRegion});case"no-readme":return i.jsx(me,{kind:"empty",label:r.documentRegion,stale:!1,busy:!1,children:i.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-folder-empty",children:i.jsx("p",{className:"aqmx-empty-title",children:r.folderReadmeMissing(D.lastPathSegment(e.folder))})})});case"failure":return i.jsx(me,{kind:"failure",label:r.documentRegion,stale:!1,busy:!1,children:i.jsx(de,{scrollerProps:st,children:i.jsx(se,{failure:e.failure,alert:!1,onRetry:e.onRetry,testId:"markdown-explorer-folder-failure"})})})}},ot=({label:e})=>{const{labels:t}=P();return i.jsxs(me,{kind:"loading",label:e,stale:!1,busy:!0,children:[i.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-document-skeleton",children:rt.map(n=>i.jsx("span",{},n))}),i.jsx("p",{className:"aqmx-sr-only",children:t.documentLoading})]})},Tt=Object.freeze(["wheel","touchstart","pointerdown","keydown"]),cs=({path:e,document:t,viewer:n,editing:r})=>{const{reportMathDiagnostics:o,edits:s}=P(),l=a.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),f=Ho(),h=Vo(),m=a.useMemo(()=>o===void 0?void 0:c=>o(e,c),[o,e]),u=a.useRef(null),{editable:p,doubleClick:v,region:b,paneScroll:R,stale:O}=r;a.useLayoutEffect(()=>{if(p)return s.bindView(e,{anchor:()=>{const c=u.current,d=b(),E=c===null?null:c.querySelector(Le);return c===null||d===null||E===null?null:dn(c,R.scrollerOf(d,E))}})},[s,e,p,b,R]);const T=c=>{const d=u.current,{target:E}=c;!v||d===null||!(E instanceof Element)||!an(E)||(c.stopPropagation(),s.start(e,cn(E,d,d.ownerDocument.getSelection())))},N=a.useRef(null),A=a.useRef(O);a.useLayoutEffect(()=>{A.current=O});const x=a.useEffectEvent(c=>{const d=u.current,E=b(),L=d===null?null:mn(d,c.line);if(E===null||L===null)return!1;const M=R.scrollerOf(E,L);return M.scrollTop+=hn(L,c.line)-c.clientTop,!0}),w=a.useEffectEvent(c=>{const d=b();if(d===null)return;const E=()=>{for(const M of Tt)d.removeEventListener(M,L,!0);N.current?.release===E&&(N.current=null)},L=()=>E();for(const M of Tt)d.addEventListener(M,L,{capture:!0,passive:!0});N.current={point:c,release:E}});return a.useLayoutEffect(()=>{const c=s.takeReturn(e);if(c!==null)return queueMicrotask(()=>{x(c)&&A.current&&w(c)}),()=>N.current?.release()},[s,e]),a.useLayoutEffect(()=>{const c=N.current;c===null||O||(c.release(),x(c.point))},[t,O]),i.jsx("div",{ref:u,className:"aqmx-document-viewer",onDoubleClick:T,children:i.jsx(he.MarkdownViewer,{...n,onHeadingSelect:f,headingHref:h,onMathDiagnostics:m,parseResult:l,content:null})})},jn=({document:e,viewer:t})=>{const{labels:n}=P();return i.jsxs(i.Fragment,{children:[i.jsx(Oe,{name:e.name,openUrl:D.explorerPlainTextHref(e.url),downloadUrl:e.url,icon:i.jsx(kr,{}),children:e.truncated?null:i.jsx(Wr,{text:e.text})}),e.truncated?i.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-text-truncated",children:n.textTruncated}):null,i.jsx("div",{className:"aqmx-document-viewer",children:i.jsx(he.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},Ot=({path:e,name:t,viewer:n})=>{const{data:r,documents:o,announcer:s,labels:l}=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]),[v,b]=a.useState(null),R=a.useEffectEvent(T=>{b(T),T.kind==="failure"&&s.announce(l.documentFailed(t,ee(l,T.failure.reason)))});a.useEffect(()=>{const T=new AbortController;return r.text(p.path,T.signal).then(N=>{"kind"in N&&R(N)}),()=>T.abort()},[r,p]);const O=a.useCallback(()=>u(T=>T+1),[]);return v===null?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-markup-skeleton",children:rt.map(T=>i.jsx("span",{},T))}),i.jsx("p",{className:"aqmx-sr-only",children:l.markupLoading})]}):v.kind==="failure"?i.jsx(de,{scrollerProps:st,children:i.jsx(se,{failure:v.failure,alert:!1,onRetry:O,testId:"markdown-explorer-markup-failure"})}):i.jsx(jn,{document:v,viewer:n})},st=Object.freeze({className:"aqmx-document-failure","data-aqmx-document-scroller":""}),ds=Object.freeze({reason:"failed"}),us=e=>i.jsx(Or,{fallback:t=>i.jsx("div",{className:"aqmx-edit-message",children:i.jsx(se,{failure:ds,alert:!1,onRetry:t,testId:"markdown-explorer-edit-load-failure"})}),children:i.jsx(a.Suspense,{fallback:i.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-edit-skeleton",children:rt.map(t=>i.jsx("span",{},t))}),children:i.jsx(Tr,{...e})})}),fs=({path:e,document:t,view:n,viewer:r,onRetry:o,editing:s})=>{switch(t.kind){case"markdown":{const{session:l,layout:f,region:h,paneScroll:m,stale:u}=s;if(n==="edit"&&l!==void 0)return i.jsx(us,{path:e,name:t.name,session:l,layout:f,viewer:r,region:h,paneScroll:m});if(n==="markup")return i.jsx(Ot,{path:e,name:t.name,viewer:r});const p=t.edit!==null&&(t.edit.kind==="inline"||t.edit.kind==="draft");return i.jsx(cs,{path:e,document:t,viewer:r,editing:{editable:p,doubleClick:p&&f==="fill",region:h,paneScroll:m,stale:u}})}case"text":return i.jsx(jn,{document:t,viewer:r});case"image":return n==="markup"&&nt(t)==="svg"?i.jsx(Ot,{path:e,name:t.name,viewer:r}):i.jsx(Ao,{document:t});case"media":return i.jsx(rs,{document:t});case"file":return i.jsx(oo,{document:t});case"failure":return i.jsx(de,{scrollerProps:st,children:i.jsx(se,{failure:t.failure,alert:!1,onRetry:o,testId:"markdown-explorer-document-failure"})});default:{const l=t;throw new RangeError(`[markdown-explorer] unknown document kind in ${JSON.stringify(l)}`)}}},ms='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',hs=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:yn(e,n),r===void 0?null:Sn(e,r.id),e.querySelector(Le),e.querySelector(ms)];for(const s of o)if(s instanceof HTMLElement&&et(s))return s;return null},Lt=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&et(t)},ps=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,l;const f=v=>{s=!(v.target instanceof Node&&n.contains(v.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(l),l=setTimeout(()=>{s=!1},0)},h=v=>{t.current=v.target instanceof Node&&n.contains(v.target)},m=v=>{v.relatedTarget===null&&s&&(t.current=!1)},u=()=>{const{activeElement:v,body:b}=r;v!==null&&v!==b&&(t.current=n.contains(v))},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(l),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},gs=({path:e,snapshot:t,markup:n,stale:r,viewer:o,editLayout:s,regionLabel:l,navigation:f,fragment:h,paneScroll:m,announces:u,announceFailure:p,onDocumentShown:v})=>{const{labels:b,announcer:R,documents:O}=P(),{document:T}=t,N=a.useRef(null),A=a.useRef(null),x=a.useRef(null),w=a.useRef(0),c=ps(N),d=a.useRef({path:e,document:T}),E=a.useRef(null),L=a.useCallback(V=>{const G=N.current,W=Et(G,V,m);G!==null&&W!==null&&Lt(G,W,c.current)},[m,c]),M=a.useCallback((V,G)=>{const W=w.current;setTimeout(()=>{!G.defaultPrevented&&w.current===W&&L(V)},0)},[L]),j=a.useCallback(V=>{setTimeout(()=>{V.defaultPrevented||L("#")},0)},[L]),F=a.useMemo(()=>({navigation:f,currentPath:e,scrollWithin:L,followSameUrlJump:M,followEmptyFragment:j}),[f,e,L,M,j]),z=a.useCallback(()=>O.retry(e),[O,e]),U=gn(O,Po),B=rn(e),K=B!==void 0?"edit":n?"markup":"rendered",q=nt(T)===null?void 0:K,Q=a.useCallback(()=>N.current,[]),g=a.useMemo(()=>({session:B,layout:s,region:Q,paneScroll:m,stale:r}),[B,s,Q,m,r]),S=q==="edit"?!1:r,k=a.use(ae),C=q==="edit"&&s==="fill"?"fill":k,_=a.useEffectEvent((V,G)=>{const W=A.current;if(W!==null&&W.path===V&&W.snapshot===G)return;A.current={path:V,snapshot:G};const J=G.document;if(J.kind==="failure"){O.noteFailureShown(G)&&p(b.documentFailed(D.lastPathSegment(V),ee(b,J.failure.reason)));return}v?.(V,J),u&&(W===null||W.path!==V||W.snapshot.document.kind==="failure")&&R.announce(b.documentShown(J.name))});a.useEffect(()=>{_(e,t)},[e,t]);const $=a.useEffectEvent(()=>{h.kind==="panel"&&h.consume()}),Z=a.useEffectEvent(V=>{const G=N.current;if(G===null||!c.current)return null;const{activeElement:W,body:J}=G.ownerDocument;return W!==null&&W!==J?null:hs(G,T,V)}),H=a.useEffectEvent(V=>{const G=N.current;G!==null&&Lt(G,V,c.current)}),te=a.useEffectEvent(V=>m.reveal(V)),lt=a.useEffectEvent(V=>Et(N.current,V,m));return a.useEffect(()=>{if(r)return;const V=d.current.path!==e,G=V||d.current.document!==T;d.current={path:e,document:T};const W=E.current!==e;E.current=e;let J=null;h.kind==="page"?x.current!==h.navigation&&(x.current=h.navigation,w.current+=1,J=h.fragment):h.fragment!==null&&(J=h.fragment,$());const at=()=>{const Ne=J===null?null:lt(J);if(!G){Ne!==null&&H(Ne);return}const ct=Z(h.fragment);V&&Ne===null&&ct!==null&&te(ct)};W?queueMicrotask(at):at()},[h,e,T,r]),i.jsx(ae,{value:C,children:i.jsx(me,{kind:T.kind,view:q,label:l(e,T),stale:S,busy:S,frameRef:N,intent:U,children:i.jsx(Tn,{value:F,children:i.jsx(No,{children:i.jsx(fs,{path:e,document:T,view:K,viewer:o,onRetry:z,editing:g},e)})})})})},it=Object.freeze({kind:"skeleton"}),vs=(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 l=n===null||n===e?null:re(r);return n===null||l===null?it:{kind:"document",path:n,snapshot:l,stale:!0}},ws=(e,t)=>t.status==="deferred"?it:{kind:"document",path:e,snapshot:t,stale:!1},Es=({requestedPath:e,content:t,markup:n,...r})=>{const o=t.kind==="streaming"?ws(t.path,a.use(t.promise)):t;return o.kind!=="document"?i.jsx(ot,{label:r.regionLabel(e,null)}):i.jsx(gs,{path:o.path,snapshot:o.snapshot,markup:n,stale:o.stale,...r})},Nn=({path:e,absence:t,markup:n,display:r,navigation:o,fragment:s,paneScroll:l,announces:f,announceFailure:h,onDocumentShown:m})=>{const{config:u,labels:p,locale:v,theme:b,documents:R,data:O}=P(),T=he.useMarkdownToolbarState(),N=a.useRef(!1);a.useLayoutEffect(()=>{N.current=!0},[]);const[A,x]=a.useState(null),[w,c]=a.useState(n),d=a.useCallback(()=>e===null?void 0:R.peek(e),[R,e]),E=a.useSyncExternalStore(R.subscribe,d,d),L=a.useCallback(()=>A===null?void 0:R.peek(A),[R,A]),M=a.useSyncExternalStore(R.subscribe,L,L);a.useLayoutEffect(()=>e===null?void 0:R.open(e),[R,e]),a.useLayoutEffect(()=>A===null?void 0:R.retain(A),[R,A]);const j=e===null?it:vs(e,E,A,M,!N.current),F=e===null?null:j.kind==="document"&&!j.stale?j.path:A;F!==A&&x(F);const z=j.kind!=="document"||j.path===e;z&&n!==w&&c(n);const U=a.useMemo(()=>is(p,v),[p,v]),B=a.useMemo(()=>({read:(k,C)=>Mo(O,k,C)}),[O]),K=a.useMemo(()=>[...u.iframeHosts],[u]),q=o.kind==="panel",Q=a.useMemo(()=>({labels:U,spreadsheetLocale:v,emptyMessage:p.documentEmpty,theme:b,availableStyles:u.documentStyles,iFrameAllowedDomains:K,embeds:u.embeds,linkComponent:Bo,toolbar:T,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:q?void 0:wn,imageSource:B}),[U,v,p.documentEmpty,b,u.documentStyles,K,u.embeds,T,r,q,B]),g=a.useCallback((k,C)=>q?C===null||C.kind==="failure"?D.lastPathSegment(k):C.name:p.documentRegion,[q,p.documentRegion]),S=q?"content":"fill";return e===null?i.jsx(ae,{value:S,children:i.jsx(as,{absence:t,announces:f,announceFailure:h})}):i.jsx(ae,{value:S,children:i.jsx(a.Suspense,{fallback:i.jsx(ot,{label:g(e,null)}),children:i.jsx(Es,{requestedPath:e,content:j,markup:z?n:w,viewer:Q,editLayout:r.editLayout,regionLabel:g,navigation:o,fragment:s,paneScroll:l,announces:f,announceFailure:h,onDocumentShown:m})})})},xs=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:l,announcer:f}=P(),h=pe(M=>M.style),m=pe(M=>M.align),u=we(),p=Y.useLocation(),v=Te(),{view:b,overrides:R,embed:O}=r,T=a.useCallback(M=>{if(v.kind!=="location")return;const j=ls(s,v.location,M);j!==null&&u(j,"browse")},[s,u,v]),N=a.useCallback(M=>{l.update({style:M}),T("style")},[l,T]),A=a.useCallback(M=>{l.update({align:M}),T("align")},[l,T]),x=Cn(s,R.style,h),w=An(R.align,m),c=a.useMemo(()=>({style:x,onStyleChange:N,align:w,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"}),[x,N,w,A,O]),d=a.useMemo(()=>({kind:"page",view:b,overrides:R,embed:O}),[b,R,O]),E=a.useMemo(()=>({kind:"page",fragment:p.hash,navigation:p}),[p]),L=a.useCallback(M=>f.announce(M),[f]);return i.jsx(Nn,{path:e,absence:t,markup:n,display:c,navigation:d,fragment:E,paneScroll:fo,announces:!0,announceFailure:L,onDocumentShown:o})},bs=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:l}=P(),f=pe(d=>d.style),h=pe(d=>d.align),[m,u]=a.useState(()=>Cn(s,void 0,f)),p=An(void 0,h),v=a.useCallback(d=>l.update({align:d}),[l]),{maximized:b,onDocumentLink:R,pendingHash:O,onHashConsumed:T,announceFailure:N,paneScroll:A}=r,x=a.useMemo(()=>({style:m,onStyleChange:u,align:p,onAlignChange:v,showToc:b,showStyle:b,showAlign:b,padding:void 0,width:void 0,maxWidth:void 0,editLayout:b?"fill":"content"}),[m,p,v,b]),w=a.useMemo(()=>({kind:"panel",onDocumentLink:R}),[R]),c=a.useMemo(()=>({kind:"panel",fragment:O,consume:T}),[O,T]);return i.jsx(Nn,{path:e,absence:t,markup:n,display:x,navigation:w,fragment:c,paneScroll:A,announces:!1,announceFailure:N,onDocumentShown:o})},Dn=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>r.kind==="page"?i.jsx(xs,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o}):i.jsx(bs,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o});function Ss({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 Pn=y.forwardRef(Ss);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:"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 _n=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",{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 Rs=y.forwardRef(ks);function Ts({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 Os=y.forwardRef(Ts);function Ls({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 Cs=y.forwardRef(Ls);function As({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 Ms=y.forwardRef(As);function js({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 Fn=y.forwardRef(js);function Ns({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 Ds=y.forwardRef(Ns);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",{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 _s=y.forwardRef(Ps),In=({href:e,onRetry:t,testId:n})=>{const{labels:r,onEditGrant:o}=P(),[s,l]=a.useState(!1),f=()=>{o===void 0||s||(l(!0),o(e).then(h=>{h&&t()}).finally(()=>l(!1)))};return i.jsxs("div",{className:"aqmx-callout aqmx-edit-grant","data-testid":n,children:[i.jsx("p",{className:"aqmx-callout-title",children:r.editGrantTitle}),i.jsx("p",{className:"aqmx-callout-body",children:r.editGrantBody}),i.jsxs("div",{className:"aqmx-edit-grant-actions",children:[o===void 0?i.jsx("a",{className:"aqmx-callout-action",href:e,target:"_blank",rel:"noopener","data-testid":`${n}-open`,children:r.editGrantAction}):i.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":s,"data-testid":`${n}-open`,onClick:f,children:r.editGrantAction}),i.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":`${n}-retry`,onClick:t,children:r.editGrantRetry})]})]})},Fs="Control+E Meta+E",$n=(e,t,n)=>n&&t?"split":e.view,Ge=(e,t,n,r)=>{if(n==="split"){e.setSideBySide(!0);return}e.setView(t,n),r&&e.sideBySide()&&e.setSideBySide(!1)},Is=e=>e==="split"?null:e,qn=e=>e==="preview"?"editor":"preview",Bn=e=>/Mac|iPhone|iPad|iPod/u.test(e),Hn=(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)},Ct=(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)},$s=({path:e,documentName:t,open:n,onClose:r})=>{const{data:o,edits:s,labels:l,locale:f,announcer:h}=P(),m=a.useId(),[u,p]=a.useState(null),[v,b]=a.useState(0),[R,O]=a.useState(null),[T,N]=a.useState(null),A=a.useMemo(()=>new Intl.DateTimeFormat(f,{dateStyle:"medium",timeStyle:"short"}),[f]),x=a.useCallback(()=>{O(null),N(null)},[]),w=Qt({open:n,onOpen:x,onDismiss:r});a.useEffect(()=>{if(!n)return;const E=new AbortController;return p(null),o.revisions(e,E.signal).then(L=>{"kind"in L&&p(L)}),()=>E.abort()},[n,o,e,v]),a.useEffect(()=>{if(!n||R===null)return;const E=new AbortController;return N(null),o.revision(e,R,E.signal).then(L=>{"kind"in L&&N(L)}),()=>E.abort()},[n,o,e,R]);const c=()=>{T===null||T.kind!=="revision"||(s.replaceDraft(e,T.text),h.announce(l.historyRestored(t)),r())},d=u!==null&&u.kind==="revisions"?u.revisions.find(E=>E.id===R):void 0;return i.jsx("dialog",{...w,className:"aqmx-confirm aqmx-history","aria-labelledby":m,"data-testid":"markdown-explorer-history",children:i.jsxs("div",{className:"aqmx-confirm-panel aqmx-history-panel",children:[i.jsx("p",{id:m,className:"aqmx-confirm-title",children:l.historyTitle(t)}),u===null?i.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-loading",children:l.historyLoading}):u.kind==="failure"?i.jsx(se,{failure:u.failure,alert:!1,onRetry:()=>b(E=>E+1),testId:"markdown-explorer-history-failure"}):u.revisions.length===0?i.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-empty",children:l.historyEmpty}):i.jsx("ul",{className:"aqmx-history-list","data-testid":"markdown-explorer-history-list",children:u.revisions.map(E=>i.jsx("li",{children:i.jsxs("button",{type:"button",className:"aqmx-history-entry","aria-pressed":E.id===R,"data-testid":"markdown-explorer-history-entry",onClick:()=>O(E.id),children:[i.jsx("span",{children:Ct(E,A,l.historyEntry)}),E.current?i.jsx("span",{className:"aqmx-history-mark",children:l.historyCurrent}):null,E.kept?i.jsx("span",{className:"aqmx-history-mark",children:l.historyKept}):null]})},E.id))}),R===null?null:T===null?i.jsx("p",{className:"aqmx-history-note",children:l.historyLoading}):T.kind==="failure"?i.jsx(se,{failure:T.failure,alert:!1,testId:"markdown-explorer-history-revision-failure"}):i.jsx("section",{className:"aqmx-history-text",tabIndex:0,"aria-label":d===void 0?l.historyTitle(t):Ct(d,A,l.historyEntry),"data-testid":"markdown-explorer-history-text",children:i.jsx("pre",{children:T.text})}),i.jsxs("div",{className:"aqmx-confirm-actions",children:[i.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":"markdown-explorer-history-close",onClick:r,children:l.historyClose}),i.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":T===null||T.kind!=="revision","data-testid":"markdown-explorer-history-restore",onClick:c,children:l.historyRestore})]})]})})},qs=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()},Bs=({path:e,documentName:t,iconOnly:n,previewAvailable:r,draft:o})=>{const{draftConverter:s,edits:l,labels:f}=P(),h=a.useSyncExternalStore(l.subscribe,()=>l.session(e)!==void 0,()=>!1),[m,u]=a.useState(null),p=()=>{if(!h){l.start(e,l.viewAnchor(e));return}l.flush(e);const O=l.session(e);O?.dirty===!0?u(O.save.kind==="draft"?"draft":"unsaved"):l.close(e)},v=()=>{h||(Rr(),r&&l.sideBySide()&&s?.prepare?.())},b=n?o?f.editDraftDocumentNamed(t):f.editDocumentNamed(t):null,R=o?f.editDraftDocument:f.editDocument;return i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:b===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:h?f.closeEditor:b===null?R:b,"aria-label":b===null?void 0:b,"aria-pressed":h,"data-testid":"markdown-explorer-document-edit",onClick:p,onDoubleClick:ne,onPointerEnter:v,onFocus:v,children:[i.jsx(Ds,{"aria-hidden":"true"}),b===null?i.jsx("span",{children:f.editDocumentLabel}):null]}),i.jsx(Jt,{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),l.close(e)},onCancel:()=>u(null)})]})},Hs=({href:e,documentName:t,iconOnly:n})=>{const{labels:r}=P(),o=n?r.editExternallyNamed(t):null;return i.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:[i.jsx(Rs,{"aria-hidden":"true"}),o===null?i.jsx("span",{children:r.editExternallyLabel}):null]})},Vs=({session:e})=>{const{labels:t}=P(),n=nr(t,e);return i.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})},Us=Object.freeze(["editor","split","preview"]),zs=Object.freeze(["editor","preview"]),Zs=Object.freeze({editor:_n,split:_s,preview:Fn}),Gs=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{draftConverter:s,edits:l,labels:f}=P(),h=sn(),m=$n(r,h,o),u=o?Us:zs,p=a.useId(),v=a.useRef(new Map),b={editor:{label:f.editViewEditor,tooltip:f.editViewEditorTooltip},split:{label:f.editViewSplit,tooltip:f.editViewSplitTooltip},preview:{label:f.editViewPreview,tooltip:f.editViewPreviewTooltip}},R=()=>{l.preparePreview(e),s?.prepare?.()},O=T=>{if(!Hn(T.nativeEvent,Bn(navigator.platform)))return;Ye(T);const N=qn(m);Ge(l,e,N,o),v.current.get(N)?.focus()};return i.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(T=>{const N=Zs[T],{label:A,tooltip:x}=b[T],w=T==="preview"?R:void 0;return i.jsxs("label",{className:n?"aqmx-icon-button":"aqmx-icon-button aqmx-labelled-button",children:[i.jsx("input",{ref:c=>{c===null?v.current.delete(T):v.current.set(T,c)},type:"radio",name:p,value:T,checked:T===m,"aria-label":A,"aria-keyshortcuts":T==="split"?void 0:Fs,title:x,"data-testid":`markdown-explorer-edit-view-${T}`,onChange:()=>Ge(l,e,T,o),onDoubleClick:ne,onPointerEnter:w,onFocus:w}),i.jsx(N,{"aria-hidden":"true"}),n?null:i.jsx("span",{children:A})]},T)})})},Ks=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{edits:s,labels:l}=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 b=s.session(e);b===void 0||!b.dirty||b.save.kind==="saving"||s.save(e)},v=b=>n?{className:"aqmx-icon-button","aria-label":b}:{className:"aqmx-icon-button aqmx-labelled-button"};return i.jsxs(i.Fragment,{children:[r.save.kind==="conflicts"?i.jsxs("button",{type:"button",...v(l.conflictNext),title:l.conflictNext,"data-testid":"markdown-explorer-edit-next-conflict",onClick:()=>s.nextConflict(e),onDoubleClick:ne,children:[i.jsx(Os,{"aria-hidden":"true"}),n?null:i.jsx("span",{children:l.conflictNext})]}):null,i.jsx(Gs,{path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o}),r.history?i.jsxs("button",{type:"button",...v(l.historyOpen),title:l.historyOpen,"aria-haspopup":"dialog","data-testid":"markdown-explorer-edit-history",onClick:()=>h(!0),onDoubleClick:ne,children:[i.jsx(Cs,{"aria-hidden":"true"}),n?null:i.jsx("span",{children:l.historyOpen})]}):null,r.save.kind==="draft"?null:i.jsxs("button",{type:"button",...v(l.saveDraft),title:l.saveDraftTooltip,"aria-disabled":u,"aria-busy":m,"aria-keyshortcuts":"Control+S Meta+S","data-testid":"markdown-explorer-edit-save",onClick:p,onDoubleClick:ne,children:[i.jsx(Ms,{"aria-hidden":"true"}),n?null:i.jsx("span",{children:l.saveDraft})]}),r.history?i.jsx($s,{path:e,documentName:t,open:f,onClose:()=>h(!1)}):null]})},Ws=({path:e,session:t})=>{const{edits:n}=P();return t.save.kind!=="grant"?null:i.jsx(In,{href:t.save.href,onRetry:()=>{n.save(e)},testId:"markdown-explorer-save-grant"})},Xs=new Set,Ys=(e,t)=>{const{documents:n,announcer:r,labels:o}=P(),s=a.useCallback(()=>n.peek(e),[n,e]),l=a.useCallback(()=>n.peekSeeded(e),[n,e]),f=a.useSyncExternalStore(n.subscribe,s,l),h=a.useCallback(()=>n.answerStampOf(e),[n,e]),m=a.useSyncExternalStore(n.subscribe,h,h),[u]=a.useState(()=>new Set),[p,v]=a.useState(Xs),[b,R]=a.useState(null);b!==null&&b.path!==e&&R(null);const O=a.useRef(null);a.useLayoutEffect(()=>(O.current=e,()=>{O.current=null}),[e]);const T=a.useCallback(()=>{const x=e,w=n.peek(x);if(u.has(x)||w?.status==="pending")return;const c=t&&!xn(w);u.add(x),v(new Set(u)),R(null),(async()=>{try{const d=await n.refresh(x);if(O.current!==x||d.status==="superseded")return;if(d.status==="failed"){R({path:x,failure:d.failure,stamp:n.answerStampOf(x)}),r.announce(o.documentRefreshFailed(ee(o,d.failure.reason)));return}const E=re(n.peek(x));if(c||E===null||E.document.kind==="failure")return;r.announce(o.documentRefreshed(E.document.name))}finally{u.delete(x),v(new Set(u))}})()},[e,t,u,n,r,o]),N=p.has(e),A=b!==null&&b.path===e&&b.stamp===m?b.failure:null;return{refreshing:N,unavailable:N||f?.status==="pending",failure:A,refresh:T}},Vn=Object.freeze({kind:"page"}),Un=({path:e,placement:t,markup:n})=>{const{labels:r}=P(),{refreshing:o,unavailable:s,failure:l,refresh:f}=Ys(e,t.kind==="page"),h=os(e),m=qs(e),u=rn(e),p=t.kind==="panel"?r.refreshDocumentNamed(t.documentName):null,v=t.kind==="panel"?r.showMarkupNamed(t.documentName):null,b=t.kind==="panel",R=t.kind==="panel"?t.documentName:m.name,O=t.kind==="page"||t.maximized;return i.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar","data-aqmx-editing":u===void 0?void 0:"true",children:[i.jsxs("div",{className:"aqmx-document-refresh-row",children:[u===void 0?null:i.jsx(Vs,{session:u}),u===void 0?null:i.jsx(Ks,{path:e,documentName:R,iconOnly:b,session:u,previewAvailable:O}),u===void 0&&h!==null?i.jsxs("button",{type:"button",className:v===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:v===null?h==="svg"?r.showSvgMarkup:r.showMarkup:v,"aria-label":v===null?void 0:v,"aria-pressed":n.shown,"data-testid":"markdown-explorer-document-markup",onClick:n.toggle,onDoubleClick:ne,children:[i.jsx(_n,{"aria-hidden":"true"}),v===null?i.jsx("span",{children:r.showMarkupLabel}):null]}):null,u!==void 0||m.edit?.kind==="inline"||m.edit?.kind==="draft"?i.jsx(Bs,{path:e,documentName:R,iconOnly:b,previewAvailable:O,draft:m.edit?.kind==="draft"}):m.edit?.kind==="external"?i.jsx(Hs,{href:m.edit.href,documentName:R,iconOnly:b}):null,u===void 0?i.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:[i.jsx(Pn,{"aria-hidden":"true"}),p===null?i.jsx("span",{children:r.refreshDocumentLabel}):null]}):null]}),u!==void 0||l===null?null:i.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":l.reason,children:r.documentRefreshFailed(ee(r,l.reason))}),u===void 0?null:i.jsx(Ws,{path:e,session:u})]})},Qs=({location:e})=>{const t=e.doc,n=a.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),r=Ln(e);return i.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",...Se,children:[i.jsx(Un,{path:t,placement:Vn,markup:r}),i.jsx(Dn,{path:t,absence:Mn,markup:e.markup,variant:n})]})},zn=({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]),l=a.useSyncExternalStore(r.subscribe,s,s);return i.jsx("div",{className:"aqmx-sr-only",role:"status","aria-live":"polite","aria-atomic":"true","data-testid":t,children:l.length>1?n.announcementSequence(l):l[0]})},ie=Object.freeze([]),Js=e=>{const t=new Set;let n=ie,r=[],o=!1;const s=[],l=u=>{n=u;for(const p of[...t])p()},f=()=>s.at(-1)?.region,h=u=>{const p=f();u(),f()!==p&&n!==ie&&l(ie)},m=()=>{o=!1;const u=r.map(p=>"sentence"in p?p.sentence:p.list(p.items));r=[],l(Object.freeze(u))};return{announce:u=>{if(typeof u=="string")r.push({sentence:u});else{const p=r.find(v=>"list"in v&&v.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&&l(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 v=s.indexOf(p);v!==-1&&s.splice(v,1)})},shownIn:u=>f()===u?n:ie}},ue=Object.freeze({status:"cancelled"}),ei=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)},ti=({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,v)=>{let b;try{b=await r(m,{credentials:"same-origin",...u,headers:{Accept:"application/json",...u.headers}})}catch{return v({reason:"failed"})}b.status===401&&t(null);const R=b.headers.get(D.EXPLORER_SCOPE_HEADER);R!==null&&t(R);let O;try{O=await b.json()}catch{return v({reason:D.failureReasonOfStatus(b.status)})}let T;try{T=p(O)}catch{T=!1}if(T)return O;const N=ei(O);return v(N!==null?N:{reason:b.status===200?"failed":D.failureReasonOfStatus(b.status)})},l={[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 v=await s(m,u,p,b=>D.failureDocument(b.reason,b.code));return u.signal.aborted?ue:v};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 v=await s(o("children",{[D.EXPLORER_DATA_QUERY.source]:m,[D.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:p},D.isExplorerChildrenResult,b=>({status:"error",failure:b}));return p.aborted?ue:v},ancestors:async(m,u,p)=>{const v=await s(o("ancestors",{[D.EXPLORER_DATA_QUERY.source]:m,[D.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:p},D.isExplorerAncestorsResult,b=>({status:"error",failure:b}));return p.aborted?ue:v},reveal:async(m,u,p)=>{const v=await s(o("reveal",{[D.EXPLORER_DATA_QUERY.source]:m,[D.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:p},D.isExplorerRevealResult,b=>({status:"error",failure:b}));return p.aborted?ue:v},document:(m,{refresh:u})=>s(o("document",{[D.EXPLORER_DATA_QUERY.path]:m}),u?{method:"GET",headers:l}:{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,v=>D.failureDocument(v.reason,v.code));return u.aborted?ue:p},edit:(m,u)=>h(o("edit",{[D.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:u},D.isExplorerEditAnswer),save:(m,u,p,v)=>h(o("save",{[D.EXPLORER_DATA_QUERY.path]:m,[D.EXPLORER_DATA_QUERY.base]:u}),{method:"POST",headers:f,body:p,signal:v},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:l},D.isExplorerTreeResult,u=>({status:"error",failure:u}))}},ni=()=>{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}}},ri=e=>{const t=X.readStorage(e);if(t===null)return I.NO_TREE_SETTING_CHANGES;try{return I.readTreeSettingChanges(JSON.parse(t))}catch(n){return console.warn(`[markdown-explorer] localStorage key ${JSON.stringify(e)} does not hold JSON; using the default tree settings.`,n),I.NO_TREE_SETTING_CHANGES}},At=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=ri(e);n={changes:s,settings:I.applyTreeSettingChanges(t,s)}}return n},o=ce();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:l,settings:f}=r(),h=I.recordTreeSettingChange(l,s,I.advanceTreeSetting(f,s)[s],t);return n={changes:h,settings:I.applyTreeSettingChanges(t,h)},o.emit(),X.writeStorage(e,I.serializeTreeSettingChanges(h)),n.settings}}},oi=Object.freeze({status:"refreshed"}),si=Object.freeze({status:"superseded"}),Ke=Object.freeze({status:"deferred"}),ii=en(Ke),Zn=4,li=Zn-1,Mt=Object.freeze({status:"loading"}),ai=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),ci=e=>{const t=new Map,n=En(),r=new Map,o=new Map,s=new Map,l=new Map,f=ce(),h=new Set;let m=0,u=0;const p={direct:null,bulk:null},v=new Set;let b=!1,R=0;const O=()=>{R+=1,f.emit()},T=g=>o.get(g)??0,N=g=>{let S=l.get(g);return S===void 0&&(S={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},l.set(g,S)),S},A=(g,S,k)=>{g.inFlight.delete(S),m-=1,k.lane==="bulk"&&(u-=1)},x=g=>{const S=l.get(g);if(S!==void 0){for(const[k,C]of[...S.inFlight])A(S,k,C),C.controller.abort();S.direct.clear(),S.bulk.clear(),S.unclaimed.clear()}},w=g=>{const S=T(g)+1;return o.set(g,S),x(g),S},c=(g,S)=>{const k=fe(g),C={promise:g,opened:S,stale:!1,loadedAt:k?.status==="ok"?k.loadedAt:null};return g.status==="pending"&&g.then(_=>{_.status==="ok"&&(C.loadedAt=_.loadedAt)}),C},d=g=>{let S=r.get(g);return S===void 0&&(S=new Map,r.set(g,S)),S},E=g=>{const S=[...l.keys()],k=p[g],C=k===null?0:S.indexOf(k)+1;for(let _=0;_<S.length;_+=1){const $=S[(C+_)%S.length],Z=$===void 0?void 0:l.get($);if(!($===void 0||Z===void 0)){for(const H of Z[g])if((Z.claims.get(H)??0)!==0)return Z[g].delete(H),p[g]=$,{sourceId:$,path:H}}}return null},L=(g,S,k,C)=>{const _=l.get(g);if(_===void 0||_.inFlight.get(S)!==k)return;A(_,S,k);const $=(_.claims.get(S)??0)>0,Z=d(g);if(C.status==="ok"?Z.set(S,{status:"loaded",entries:C.entries}):C.status==="error"&&$?Z.set(S,{status:"failed",failure:C.failure}):Z.delete(S),O(),C.status==="error"&&$){const H={sourceId:g,path:S,failure:C.failure};for(const te of[...h])te(H)}j()},M=(g,S,k)=>{const C={controller:new AbortController,lane:k};N(g).inFlight.set(S,C),m+=1,k==="bulk"&&(u+=1),e.children(g,S,C.controller.signal).then(_=>L(g,S,C,_),()=>L(g,S,C,ai))},j=()=>{for(;m<Zn;){const g=E("direct");if(g!==null){M(g.sourceId,g.path,"direct");continue}const S=u<li?E("bulk"):null;if(S===null)return;M(S.sourceId,S.path,"bulk")}},F=(g,S,k)=>{if(!(S.direct.delete(k)||S.bulk.delete(k))){const _=S.inFlight.get(k);if(_===void 0)return!1;A(S,k,_),_.controller.abort()}return r.get(g)?.delete(k),!0},z=()=>{b=!1;let g=!1;for(const S of v){const k=N(S);for(const C of k.unclaimed)(k.claims.get(C)??0)===0&&F(S,k,C)&&(g=!0);k.unclaimed.clear()}v.clear(),g&&(O(),j())},U=(g,S)=>{t.set(g,c(ge(e.tree(g)),S))},B=(g,S,k)=>{w(g);const C=c(en(S),k);return t.set(g,C),r.delete(g),O(),j(),C},K=(g,S,k,C)=>{if(k!==T(g)||t.get(g)!==S)return;const _=fe(S.promise);if(!(C.status!=="ok"||_?.status!=="ok"||S.loadedAt===null||C.loadedAt<=S.loadedAt)){if(ke(_.entries,C.entries)){S.loadedAt=C.loadedAt;return}B(g,C,S.opened)}},q=(g,S)=>{const k=t.get(g);return k!==void 0&&fe(k.promise)?.status===S},Q=(g,S)=>{S.stale=!1;const k=T(g);e.tree(g).then(C=>K(g,S,k,C))};return{read:g=>t.get(g)?.promise??ii,open:g=>{const S=n.resumes(g),k=n.hold(g),C=t.get(g);return C===void 0||q(g,"deferred")?(U(g,!0),O()):S||(C.opened&&q(g,"error")?(U(g,!0),O()):(C.opened=!0,C.stale&&q(g,"ok")&&Q(g,C))),k},retry:g=>{q(g,"error")&&(U(g,!0),O())},seed:(g,S)=>{const k=S.then($=>$===null?Ke:$,()=>Ke),C=t.get(g);if(C!==void 0&&q(g,"ok")){const $=T(g);k.then(Z=>K(g,C,$,Z));return}w(g);const _=c(ge(k),C?.opened===!0);t.set(g,_),r.delete(g),j(),k.then($=>{t.get(g)===_&&($.status==="deferred"&&n.isHeld(g)&&U(g,_.opened),O())})},refresh:async g=>{const S=(s.get(g)??0)+1;s.set(g,S);const k=await e.refresh(g);if(s.get(g)!==S)return si;if(k.status==="error")return{status:"failed",failure:k.failure};const C=t.get(g);if(!(C!==void 0&&C.loadedAt!==null&&q(g,"ok")&&C.loadedAt>k.loadedAt)){const $=B(g,k,!0);if(C!==void 0&&C.promise.status==="pending"){const Z=T(g);C.promise.then(H=>K(g,$,Z,H))}}for(const[$,Z]of t)$!==g&&fe(Z.promise)?.status==="ok"&&(Z.stale=!0);return oi},children:(g,S)=>r.get(g)?.get(S),claimChildren:(g,S)=>{const k=N(g),C=d(g);let _=!1,$=!1;for(const[H,te]of S)k.claims.set(H,(k.claims.get(H)??0)+1),C.get(H)===void 0?(C.set(H,Mt),k[te].add(H),_=!0,$=!0):te==="direct"&&k.bulk.delete(H)&&(k.direct.add(H),$=!0);_&&O(),$&&j();let Z=!1;return()=>{if(!Z){Z=!0;for(const H of S.keys()){const te=(k.claims.get(H)??0)-1;te>0?k.claims.set(H,te):(k.claims.delete(H),k.unclaimed.add(H))}v.add(g),!b&&(b=!0,queueMicrotask(z))}}},retryChildren:(g,S)=>{const k=r.get(g);if(k===void 0||k.get(S)?.status!=="failed")return;const C=N(g);if((C.claims.get(S)??0)>0){k.set(S,Mt),C.direct.add(S),O(),j();return}k.delete(S),O()},pendingChildren:g=>{const S=l.get(g);return S===void 0?0:S.direct.size+S.bulk.size+S.inFlight.size},clear:()=>{for(const g of new Set([...t.keys(),...r.keys(),...o.keys(),...l.keys()]))w(g);for(const[g,S]of s)s.set(g,S+1);t.clear(),r.clear(),O()},subscribeChildrenFailures:g=>(h.add(g),()=>{h.delete(g)}),subscribe:f.subscribe,version:()=>R}},di=(e,t)=>{let n=e;const r=ce();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},ui=1;let Ee=0,oe=null;const fi=()=>{const{documentElement:e,body:t}=document;Ee===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"),Ee+=1;let n=!1;return()=>{n||(n=!0,Ee-=1,!(Ee>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))}},mi=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],jt=1,hi=1e3,Nt=e=>e.getClientRects().length>0,Ie="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.",pi=e=>{if(!Nt(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+ui)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. ${Ie}`;if(t.height<jt)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. ${Ie}`;for(const{selector:r,name:o}of mi)for(const s of e.querySelectorAll(r)){if(!Nt(s))continue;const l=s.getBoundingClientRect().height;if(l<jt)return`[markdown-explorer] the explorer's ${o} collapsed to ${String(Math.round(l))}px while lockDocumentScroll stops the page from scrolling, so it cannot be read. ${Ie}`}return null},gi=e=>{let t=!1,n;const r=()=>{n=void 0;const l=pi(e);l!==null&&(t=!0,console.error(l))},o=()=>{t||(clearTimeout(n),n=setTimeout(r,hi))},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)}},vi=(e,t)=>{a.useEffect(()=>e?fi():void 0,[e]),a.useEffect(()=>{const n=t.current;if(!(!e||n===null))return gi(n)},[e,t])},Dt='[data-testid="markdown-explorer-view-switch"]',wi=[{control:Dt,successors:[Dt,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],Ei=e=>{for(const t of wi){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},xi=(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)?Ei(f):null},s=f=>o(f.target);o(document.activeElement);const l=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",l),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",l)}},[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 l=e.current;if(l===null)return;const f=new MutationObserver(()=>{s()&&f.disconnect()});return f.observe(l,{childList:!0,subtree:!0}),()=>f.disconnect()},[t,e])},bi=a.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-l-r2pPao.cjs")).then(e=>({default:e.TreeLayout}))),Si=a.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-Bq_TS3ez.cjs")).then(e=>({default:e.MultiLayout}))),yi=64,ki={request:e=>{requestAnimationFrame(e)}},Pt=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)},Ri=(e,t)=>{const[n,r]=a.useState(()=>({overrides:t,locale:e,labels:Ve(e,t)}));if(n.locale===e&&er(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:Ve(e,t)};return r(o),o.labels},Ti=(e,t,n)=>{const[r,o]=a.useState(()=>({scope:t,store:At(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:At(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},Oi=()=>Js(ki),_t="on",Li="off",Ci=Object.freeze({kind:"unavailable"}),Ai=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")},Mi=(e,t)=>{const n=re(e.peek(t));return n===null||n.document.kind==="failure"?D.lastPathSegment(t):n.document.name},ji=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:l,renderTreeFailure:f,lockDocumentScroll:h=!1,onMathDiagnostics:m,onEditGrant:u,draftConverter:p})=>{X.assertStorageNamespace(n),Ai(p);const v=Vt(r),b=tr(s),R=Ri(v,o),{revalidate:O}=Y.useRevalidator(),T=a.useRef(()=>{}),N=Y.useHref(t.dataPath),[A]=a.useState(()=>{const k=ti({dataPath:N,onScope:_=>T.current(_)}),C={documents:qr({client:k,capacity:Math.max(yi,t.multiView.maxPanels*2)}),trees:ci(k)};return $e(C,e),X.syncStorageScope(n,e.scope),{data:k,...C,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(A.aligned.pageData!==e||A.aligned.storageNamespace!==n){const k=A.aligned.pageData;A.aligned.pageData=e,A.aligned.storageNamespace=n,k!==e&&(k.scope!==e.scope?A.aligned.pendingReader=e:$e(A,e)),X.syncStorageScope(n,e.scope)}const x=Ti(X.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);a.useLayoutEffect(()=>{const k=A.aligned.pendingReader;k!==null&&(A.aligned.pendingReader=null,Pt(A),$e(A,k))},[e,A]),a.useLayoutEffect(()=>{let k=!1;return T.current=C=>{C===e.scope||k||(k=!0,C!==null&&(Pt(A),X.clearExplorerStorage(n)),O())},()=>{T.current=()=>{}}},[e,O,A,n]);const w=a.useRef(t.settingsCookie);a.useLayoutEffect(()=>{w.current=t.settingsCookie},[t.settingsCookie]);const[c]=a.useState(()=>di(e.settings,k=>{document.cookie=I.viewSettingsCookieString(w.current,k,window.location.protocol==="https:")})),d=qe(e.scope,Oi),E=qe(e.scope,ni),L=a.useRef(R);a.useLayoutEffect(()=>{L.current=R},[R]);const M=qe(e.scope,()=>ar({data:A.data,conflictLabels:()=>({ours:L.current.conflictOurs,theirs:L.current.conflictTheirs}),onSaveSettled:(k,C)=>{C.kind==="saved"&&A.documents.refresh(k);const _=rr(L.current,C,Mi(A.documents,k));_!==null&&d.announce(_)},sideBySideSetting:{read:()=>X.readStorage(X.storageKeys(n).editPreview)===_t,write:k=>X.writeStorage(X.storageKeys(n).editPreview,k?_t:Li)},editorShareSetting:{read:()=>lr(X.readStorage(X.storageKeys(n).editSplit)),write:k=>X.writeStorage(X.storageKeys(n).editSplit,String(k))}})),j=a.useMemo(()=>ge(e.notices.catch(()=>[])),[e.notices]),F=e.sources.map(k=>k.id).join(`
12
- `),z=a.useMemo(()=>I.withExplorerSources(t,F.split(`
13
- `)),[t,F]),U=a.useRef(m);a.useLayoutEffect(()=>{U.current=m},[m]);const[B]=a.useState(()=>(k,C)=>{U.current?.(k,C)}),K=m===void 0?void 0:B,q=a.useRef(p);a.useLayoutEffect(()=>{q.current=p},[p]);const[Q]=a.useState(()=>{let k=!1;return{convert:(C,_)=>{const $=q.current;return $===void 0?Promise.resolve(Ci):$.convert(C,_)},prepare:()=>{try{q.current?.prepare?.()}catch(C){if(k)return;k=!0,console.error("[markdown-explorer] the draft converter's prepare threw",C)}}}}),g=p===void 0?void 0:Q,S=a.useMemo(()=>({config:z,labels:R,locale:v,theme:b,storageNamespace:n,scope:e.scope,sources:e.sources,notices:j,documents:A.documents,trees:A.trees,data:A.data,viewSettings:c,treeSettings:x,announcer:d,reveals:E,edits:M,onEditGrant:u,draftConverter:g,renderTreeFailure:f,reportMathDiagnostics:K}),[z,R,v,b,n,e.scope,e.sources,j,A,c,x,d,E,M,u,g,f,K]);return i.jsx(Ut,{value:S,children:i.jsx(Di,{renderFrame:l,lockDocumentScroll:h},e.scope)})},Ni=({ref:e,theme:t,view:n,children:r})=>{const[o]=a.useState(Ro);return i.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})},Di=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=P(),o=Te(),{hash:s}=Y.useLocation(),l=we(),f=a.useRef(null);vi(t,f),a.useLayoutEffect(()=>{o.kind==="redirect"&&l(`${o.href}${s}`,"browse")},[o,s,l]);const{location:h}=o,m=h.view;xi(f,m);const u=h.view==="tree"?i.jsx(a.Suspense,{fallback:i.jsx("section",{className:"aqmx-split-fallback","aria-label":r.explorerRegion,"aria-busy":"true","data-testid":"markdown-explorer-split-loading",...Se}),children:i.jsx(bi,{location:h})}):h.view==="multi"?i.jsx(a.Suspense,{fallback:i.jsx("section",{className:"aqmx-stage-fallback","aria-label":r.multiRegion,"aria-busy":"true","data-testid":"markdown-explorer-stage-loading",...Se}),children:i.jsx(Si,{location:h})}):i.jsx(Qs,{location:h}),p=i.jsxs(Ni,{ref:f,theme:n,view:m,children:[u,i.jsx(Sr,{}),i.jsx(zn,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?p:e({view:m,children:p})},Pi=Kn.createShouldRevalidate({submissions:"skip",otherPath:"skip",query:"skip",hashChange:"skip"});exports.ALLOW_KEY_REPEAT=Re;exports.CONFLICT_OURS_MARKER=Zt;exports.CONFLICT_SEPARATOR=Gt;exports.CONFLICT_THEIRS_MARKER=Kt;exports.CONTENT_PANE=Se;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=Ft;exports.DocumentPane=Dn;exports.DocumentRefreshBar=Un;exports.EXPLORER_THEMES=Ue;exports.EditGrantNotice=In;exports.ExplorerLink=pn;exports.FOLDER_README_LOADING=tn;exports.FailureView=se;exports.ForwardRef=Pn;exports.ForwardRef$1=Fn;exports.ImageViewMemoryContext=Rn;exports.LazyNativeScrollBar=vn;exports.LiveRegion=zn;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=Ht;exports.MARKDOWN_EXPLORER_LABEL_KEYS=Xe;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=qt;exports.MARKDOWN_EXPLORER_LOCALES=He;exports.MarkdownExplorer=ji;exports.NO_DOCUMENT=Mn;exports.PAGE_DOCUMENT_REFRESH=Vn;exports.anchorOfDoubleClick=cn;exports.anchorOfView=dn;exports.blockAtLine=mn;exports.chooseEditView=Ge;exports.consumeKey=Ye;exports.createEmitter=ce;exports.cssPixels=Xt;exports.editViewOf=$n;exports.explorerNavigationOptions=_r;exports.failureTitleOf=ee;exports.findConflictsInLines=Wt;exports.focusWithoutScroll=et;exports.frameTopOf=un;exports.isApplePlatform=Bn;exports.isEditViewShortcut=Hn;exports.isEditingDoubleClick=an;exports.lineTopIn=hn;exports.loadedOf=re;exports.paneShownAlone=Is;exports.positionInSource=Dr;exports.readFolderReadme=nn;exports.resolveMarkdownExplorerLabels=Ve;exports.shouldRevalidateExplorer=Pi;exports.toggledEditView=qn;exports.useExplorer=P;exports.useExplorerLocation=Te;exports.useExplorerNavigate=we;exports.useIntentPrefetch=gn;exports.usePageMarkupToggle=Ln;exports.useSideBySide=sn;exports.useViewSetting=pe;exports.visibleTopOf=fn;