@aiquants/markdown-explorer 0.25.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -0
- package/README.md +40 -25
- package/dist/{EditSurface-Co4Rvfa1.cjs → EditSurface-B1yD7ywF.cjs} +1 -1
- package/dist/{EditSurface-Blymamic.js → EditSurface-sUNqYw9o.js} +5 -5
- package/dist/{ExplorerSplit-WApgYMPb.cjs → ExplorerSplit-Bn3ZnEMZ.cjs} +1 -1
- package/dist/{ExplorerSplit-BZ0PA3z3.js → ExplorerSplit-pClUl3-e.js} +3 -3
- package/dist/{MultiLayout-dAW_JCzg.cjs → MultiLayout-0Jh08fxo.cjs} +1 -1
- package/dist/{MultiLayout-B5-1N3JD.js → MultiLayout-B-ft4_Vs.js} +4 -4
- package/dist/{NativeScrollBar-BraWuZvN.js → NativeScrollBar-ByawerpG.js} +1 -1
- package/dist/{NativeScrollBar-ThVMbI0Y.cjs → NativeScrollBar-D9QrjRJa.cjs} +1 -1
- package/dist/{TreeLayout-C60lb9hP.cjs → TreeLayout-CXHbKdxy.cjs} +1 -1
- package/dist/{TreeLayout-CChoxh9W.js → TreeLayout-DjIVKBG4.js} +3 -3
- package/dist/core/config.d.cts +7 -0
- package/dist/core/config.d.ts +7 -0
- package/dist/core/contracts.d.cts +8 -2
- package/dist/core/contracts.d.ts +8 -2
- package/dist/core/dataRoute.d.cts +40 -0
- package/dist/core/dataRoute.d.ts +40 -0
- package/dist/core/labels.d.cts +10 -1
- package/dist/core/labels.d.ts +10 -1
- package/dist/{dataRoute-BEvesOvN.js → dataRoute-DLhQfdoW.js} +111 -103
- package/dist/dataRoute-DwYtgyt6.cjs +1 -0
- package/dist/index-BNAkC0g3.js +4800 -0
- package/dist/index-DRMNpWDJ.cjs +15 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +27 -26
- package/dist/{location-DIxIjqs7.js → location-BNFdxzhn.js} +134 -130
- package/dist/location-yvU5HUY1.cjs +1 -0
- package/dist/{merge-DRWmjC24.cjs → merge-BBU1pDoT.cjs} +1 -1
- package/dist/{merge-CgSp-0Dd.js → merge-DhHzRcAI.js} +1 -1
- package/dist/{sanitizePolicy-gVKBhabq.js → sanitizePolicy-By0tKOpZ.js} +1 -1
- package/dist/{sanitizePolicy-CZwOaJ92.cjs → sanitizePolicy-T5T-3vV5.cjs} +1 -1
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +1 -1
- package/dist/server/ports.d.cts +4 -3
- package/dist/server/ports.d.ts +4 -3
- package/dist/server.cjs +1 -1
- package/dist/server.js +500 -493
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/{useSplitPersistence-Df63lnQZ.js → useSplitPersistence-D5EjJwCg.js} +1 -1
- package/dist/{useSplitPersistence-D-T75Hlh.cjs → useSplitPersistence-xGOSwpLM.cjs} +1 -1
- package/docs/behavior/dom-hooks.md +10 -6
- package/docs/behavior/layout.md +8 -3
- package/docs/behavior/localization.md +5 -2
- package/docs/behavior/security.md +7 -2
- package/docs/behavior/url-contract.md +3 -3
- package/package.json +5 -5
- package/dist/dataRoute-Cv7fgCW7.cjs +0 -1
- package/dist/index-B6FkGD-p.cjs +0 -13
- package/dist/index-Bd6hgisa.js +0 -4097
- package/dist/location-D3DgoELB.cjs +0 -1
package/dist/index-B6FkGD-p.cjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";const i=require("react/jsx-runtime"),l=require("react"),J=require("react-router"),V=require("./location-D3DgoELB.cjs"),de=require("@aiquants/markdown/code-blocks"),D=require("./dataRoute-Cv7fgCW7.cjs"),ue=require("@aiquants/markdown"),Xe=require("@aiquants/markdown/source-lines"),Ye=require("@aiquants/spreadsheet/tsv"),St=require("@aiquants/spreadsheet/view"),br=require("@aiquants/markdown/viewer-settings"),Q=require("./storage-DM0EvkVf.cjs"),Sr=require("@aiquants/route-revalidation");function yr(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 S=yr(l),Qe=Object.freeze(["en","ja"]),Xt="en",st=e=>`viewerSpreadsheet${e.charAt(0).toUpperCase()}${e.slice(1)}`,Yt=Object.freeze(Object.keys(de.SPREADSHEET_BLOCK_LABEL_CATALOGS.en)),Qt=e=>Object.fromEntries(Yt.map(t=>[st(t),de.SPREADSHEET_BLOCK_LABEL_CATALOGS[e][t].text])),Jt=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(Yt.filter(e=>de.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e].length>0).map(e=>[st(e),de.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e]]))}),kr=/\{(\w+)\}/gu,en={...Qt("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",showSpreadsheetMarkup:e=>`Show the table's ${e} 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…",spreadsheetLoading:"Loading the table…",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.",spreadsheetFirstSheetOnly:"Only the first sheet of this spreadsheet is shown.",spreadsheetTruncated:"The table shows only part of this file. Download it to open the whole file.",spreadsheetUnreadableEncoding:([e,t])=>t===void 0?`This file's text is not ${e}, so it cannot be shown as a table. Download it to open it.`:`This file's text is neither ${e} nor ${t}, so it cannot be shown as a table. Download it to open it.`,spreadsheetEmpty:"This file has no data.",spreadsheetNotText:"This file is not text, so it cannot be shown as a table. Download it to open it.",spreadsheetLongRow:"No row of this file ends within the part read for the preview, so it cannot be shown as a table. Download it to open it.",spreadsheetFullscreen:e=>`${e} (full screen)`,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.",viewerSvgImageCopyImage:"Copy the image",viewerSvgImageCopiedImage:"Copied the image.",viewerSvgImageCopyImageFailed:"Could not copy the image.",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"},Rr={...Qt("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 を書いたまま表示",showSpreadsheetMarkup:e=>`表の ${e} を書いたまま表示`,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:"ソースを読み込み中…",spreadsheetLoading:"表を読み込み中…",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 を表示しません。新しいタブで開くか、ダウンロードしてください。",spreadsheetFirstSheetOnly:"このスプレッドシートは最初のシートだけを表示しています。",spreadsheetTruncated:"表はこのファイルの一部だけを表示しています。全体はダウンロードして開いてください。",spreadsheetUnreadableEncoding:([e,t])=>t===void 0?`このファイルの文字は ${e} ではないため、表として表示できません。ダウンロードして開いてください。`:`このファイルの文字は ${e} でも ${t} でもないため、表として表示できません。ダウンロードして開いてください。`,spreadsheetEmpty:"このファイルにはデータがありません。",spreadsheetNotText:"このファイルは文字のファイルではないため、表として表示できません。ダウンロードして開いてください。",spreadsheetLongRow:"プレビューに読む範囲の中でこのファイルの行が 1 つも終わらないため、表として表示できません。ダウンロードして開いてください。",spreadsheetFullscreen:e=>`${e} (全画面)`,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:"ソースをコピーできませんでした。",viewerSvgImageCopyImage:"画像をコピー",viewerSvgImageCopiedImage:"画像をコピーしました。",viewerSvgImageCopyImageFailed:"画像をコピーできませんでした。",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:"ここへパネルをドロップ"},tn=Object.freeze({en:Object.freeze(en),ja:Object.freeze(Rr)}),at=Object.freeze(Object.keys(en)),Tr=new Set(at),Cr=e=>Tr.has(e),Oe=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,nn=e=>{if(e===void 0)return Xt;if(Qe.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${Qe.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${Oe(e)}`)},Je=(e,t)=>{const n=tn[nn(e)];if(t===void 0)return n;if(t===null||typeof t!="object")throw new RangeError(`[markdown-explorer] labels must be an object; got ${Oe(t)}`);if(!V.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${Oe(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!Cr(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${at.join(", ")}`);const a=r[s];if(a===void 0)continue;const d=typeof n[s];if(typeof a!==d)throw new TypeError(`[markdown-explorer] labels.${s} must be a ${d}; got ${Oe(a)}`);if(typeof a=="string"&&a.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const m=Jt[s];if(typeof a=="string"&&m!==void 0){for(const[,w]of a.matchAll(kr))if(!m.includes(w??""))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${String(w)}}; it accepts ${m.map(c=>`{${c}}`).join(", ")}`)}o[s]=a}return Object.freeze(o)},Or=(e,t)=>{if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;const n=e,r=t,o=Object.keys(n),s=Object.keys(r);return o.length===s.length&&s.every(a=>Object.hasOwn(n,a)&&Object.is(n[a],r[a]))},et=Object.freeze(["light","dark"]),Lr=e=>{if(e===void 0)return"light";if(et.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${et.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},rn=l.createContext(null),F=()=>{const e=l.use(rn);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},pe=e=>{const{viewSettings:t}=F(),n=()=>e(t.getSnapshot());return l.useSyncExternalStore(t.subscribe,n,n)},Pe=()=>{const{config:e}=F(),t=J.useParams()["*"],[n]=J.useSearchParams(),r=n.toString();return l.useMemo(()=>V.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])},on={unauthorized:["failureUnauthorizedTitle","failureUnauthorizedBody"],forbidden:["failureForbiddenTitle","failureForbiddenBody"],"not-found":["failureNotFoundTitle","failureNotFoundBody"],"not-configured":["failureNotConfiguredTitle","failureNotConfiguredBody"],invalid:["failureInvalidTitle","failureInvalidBody"],"too-large":["failureTooLargeTitle","failureTooLargeBody"],unsupported:["failureUnsupportedTitle","failureUnsupportedBody"],failed:["failureFailedTitle","failureFailedBody"]},te=(e,t)=>e[on[t][0]],fe=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=F(),s=te(o,e.reason),a=o[on[e.reason][1]],d=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":d,"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:a}),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]})},Ar=(e,t)=>{const{phase:n,save:r,dirty:o}=t;switch(n.kind){case"opening":return e.editLoading;case"grant":return e.editGrantTitle;case"failed":return te(e,n.failure.reason)}switch(r.kind){case"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(te(e,r.failure.reason));case"saved":if(!o)return r.merged?e.draftSavedMerged:e.draftSaved;break}return o?e.draftUnsaved:""},Mr=(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(te(e,t.failure.reason));case"idle":case"saving":return null}},me=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},sn="<<<<<<<",an="=======",ln=">>>>>>>",yt=(e,t)=>e===t||e.startsWith(`${t} `),kt=e=>cn(e.split(`
|
|
2
|
-
`)),cn=e=>{const t=[];let n=null,r=null,o=0;for(const s of e){o+=1;const a=s.charCodeAt(0);a!==60&&a!==61&&a!==62||(yt(s,sn)?(n=o,r=null):s===an?n!==null&&r===null?r=o:n=null:yt(s,ln)&&(n!==null&&r!==null&&t.push({start:n,separator:r,end:o}),n=null,r=null))}return t},Rt=e=>e.includes(`\r
|
|
3
|
-
`)?`\r
|
|
4
|
-
`:`
|
|
5
|
-
`,$e=e=>e.replace(/\r\n?/gu,`
|
|
6
|
-
`),jr=(e,t)=>t===`
|
|
7
|
-
`?e:e.replaceAll(`
|
|
8
|
-
`,`\r
|
|
9
|
-
`),Nr=3,Pr=/^\d+(?:\.\d+)?$/u,Dr=e=>{if(e===null||!Pr.test(e))return null;const t=Number(e);return t>=V.EDIT_SPLIT_MIN_PERCENT&&t<=V.EDIT_SPLIT_MAX_PERCENT?t:null},Be=Object.freeze({kind:"idle"}),Tt=Object.freeze({kind:"draft"}),_r=({data:e,conflictLabels:t,onSaveSettled:n,sideBySideSetting:r,editorShareSetting:o})=>{const s=new Map,a=new Map,d=new Map,m=new Map,w=new Map,c=me();let f=null,p=null,v=null;const x=(u,h)=>{u.value={...u.value,...h},c.emit()},R=(u,h)=>s.get(u)===h,C=async(u,h)=>{h.controller.abort(),h.controller=new AbortController;const{signal:k}=h.controller;x(h,{phase:{kind:"opening"}});const A=await e.edit(u,k);if(!R(u,h)||k.aborted||!("kind"in A))return;if(A.kind==="grant"){x(h,{phase:{kind:"grant",href:A.href}});return}if(A.kind==="failure"){x(h,{phase:{kind:"failed",failure:A.failure}});return}const I=$e(A.text),q=A.kind==="draft";h.base={text:I,version:q?null:A.version},h.draft=I,h.ending=Rt(A.text),x(h,{phase:{kind:"editing"},history:q?!1:A.history,dirty:!1,save:q?Tt:Be,generation:h.value.generation+1})},j=u=>{const h=s.get(u);h!==void 0&&(h.controller.abort(),s.delete(u),d.delete(u))},N=(u,h,k)=>(u.set(h,k),()=>{u.get(h)===k&&u.delete(h)}),$=(u,h,k,A={})=>{x(h,{...A,save:k}),n(u,k)},P=async u=>{m.get(u)?.flush();const h=s.get(u);if(h===void 0||h.value.phase.kind!=="editing"||h.base===null||h.value.save.kind==="saving")return;const{version:k}=h.base;if(k===null){n(u,Tt);return}const A=kt(h.draft).length;if(A>0){$(u,h,{kind:"conflicts",count:A});return}h.controller.abort(),h.controller=new AbortController;const{signal:I}=h.controller;let q={text:h.base.text,version:k},E=h.draft,T=!1;x(h,{save:{kind:"saving"}});for(let M=0;M<Nr;M+=1){const O=await e.save(u,q.version,jr(E,h.ending),I);if(!R(u,h)||I.aborted||!("kind"in O))return;if(O.kind==="saved"){m.get(u)?.flush(),h.base={text:E,version:O.version},$(u,h,{kind:"saved",merged:T},{dirty:h.draft!==E});return}if(O.kind==="grant"){$(u,h,{kind:"grant",href:O.href});return}if(O.kind==="failure"){$(u,h,{kind:"failed",failure:O.failure});return}const{mergeDraft:_}=await Promise.resolve().then(()=>require("./merge-DRWmjC24.cjs"));if(!R(u,h)||I.aborted)return;const B=m.get(u);B?.flush();const K=$e(O.text),g=_(q.text,h.draft,K,t());if(q={text:K,version:O.version},h.base=q,h.ending=Rt(O.text),h.draft=g.text,B?.adopt(g.text),g.kind==="conflicts"){$(u,h,{kind:"conflicts",count:g.conflicts},{dirty:!0,generation:h.value.generation+1});return}if(T=!0,E=g.text,E===q.text){$(u,h,{kind:"saved",merged:T},{dirty:!1,generation:h.value.generation+1});return}x(h,{dirty:!0,generation:h.value.generation+1})}$(u,h,{kind:"failed",failure:{reason:"failed"}})};return{session:u=>s.get(u)?.value,subscribe:c.subscribe,start:(u,h)=>{const k=s.get(u);if(k!==void 0){x(k,{request:{anchor:h},view:"editor"}),(k.value.phase.kind==="failed"||k.value.phase.kind==="grant")&&C(u,k);return}a.delete(u);const A={value:{path:u,phase:{kind:"opening"},view:"editor",previewPrepared:!1,history:!1,dirty:!1,save:Be,generation:0,request:{anchor:h}},base:null,draft:"",ending:`
|
|
10
|
-
`,controller:new AbortController};s.set(u,A),C(u,A)},retry:u=>{const h=s.get(u);h===void 0||h.value.phase.kind==="editing"||C(u,h)},draft:u=>{const h=s.get(u);return h===void 0||h.base===null?null:h.draft},setDraft:(u,h)=>{const k=s.get(u);if(k===void 0||k.base===null)return;k.draft=h;const A={},I=h!==k.base.text;I!==k.value.dirty&&(A.dirty=I);const{save:q}=k.value;if(q.kind==="conflicts"){const E=kt(h).length;E===0?A.save=Be:E!==q.count&&(A.save={kind:"conflicts",count:E})}(A.dirty!==void 0||A.save!==void 0)&&x(k,A)},consumeRequest:u=>{const h=s.get(u);h!==void 0&&h.value.request!==null&&x(h,{request:null})},save:P,replaceDraft:(u,h)=>{const k=m.get(u);k?.flush();const A=s.get(u);if(A===void 0||A.base===null)return;const I=$e(h);A.draft=I,k?.adopt(I),x(A,{dirty:I!==A.base.text,generation:A.value.generation+1})},close:u=>{if(!s.has(u))return;const h=m.get(u),k=h===void 0?null:h.returnPoint();j(u),k===null?a.delete(u):a.set(u,k),c.emit()},takeReturn:u=>{const h=a.get(u)??null;return a.delete(u),h},dirtyPaths:()=>[...s.values()].filter(u=>u.value.dirty).map(u=>u.value.path),discard:u=>{for(const h of u)j(h);u.length>0&&c.emit()},editorState:{get:u=>d.get(u),set:(u,h)=>{s.has(u)&&d.set(u,h)}},bindEditor:(u,h)=>N(m,u,h),bindView:(u,h)=>N(w,u,h),viewAnchor:u=>{const h=w.get(u);return h===void 0?null:h.anchor()},flush:u=>m.get(u)?.flush(),flushDrafts:()=>{for(const u of m.values())u.flush()},nextConflict:u=>m.get(u)?.nextConflict()===!0,hasSessions:()=>s.size>0,unsavedAmong:u=>{for(const h of m.values())h.flush();return u.filter(h=>s.get(h)?.value.dirty===!0)},askToDiscard:u=>new Promise(h=>{v?.settle(!1);const k={paths:u,settle:A=>{if(v===k){if(v=null,A)for(const I of u)j(I);c.emit(),h(A)}}};v=k,c.emit()}),discardRequest:()=>v,sideBySide:()=>(f??=r.read(),f),setSideBySide:u=>{f!==u&&(f=u,r.write(u),c.emit())},editorShare:()=>(p??=o.read()??V.EDIT_SPLIT_DEFAULT_PERCENT,p),setEditorShare:u=>{if(!Number.isFinite(u))throw new RangeError(`[markdown-explorer] an editor share must be a finite number; got ${String(u)}`);const h=Math.min(V.EDIT_SPLIT_MAX_PERCENT,Math.max(V.EDIT_SPLIT_MIN_PERCENT,u));p!==h&&(p=h,o.write(h))},setView:(u,h)=>{const k=s.get(u);k===void 0||k.value.view===h||(m.get(u)?.beforeView(h),x(k,{view:h,previewPrepared:k.value.previewPrepared||h==="preview"}))},preparePreview:u=>{const h=s.get(u);h!==void 0&&!h.value.previewPrepared&&x(h,{previewPrepared:!0})}}},it=e=>{e.preventDefault(),e.stopPropagation()},dn=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,un="data-aqmx-content-pane",Ae=Object.freeze({[un]:""}),Ir="--aqmx-dialog-left",Fr="--aqmx-dialog-top",qr='[data-testid="markdown-explorer"]',$r=e=>{const t=e.closest(qr)?.querySelectorAll(`[${un}]`),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},Br=e=>{const t=dn(getComputedStyle(e).marginTop);if(Number.isNaN(t))return null;const n=$r(e),r=e.getBoundingClientRect(),o=e.ownerDocument.documentElement,{left:s,top:a}=V.centeredDialogPosition(n.getBoundingClientRect(),{width:r.width+2*t,height:r.height+2*t},{width:o.clientWidth,height:o.clientHeight});return e.style.setProperty(Ir,`${String(s)}px`),e.style.setProperty(Fr,`${String(a)}px`),n},Hr=e=>e.preventDefault(),fn=({open:e,onOpen:t,onDismiss:n})=>{const r=l.useRef(null),o=l.useRef(null),s=l.useRef(!1),a=l.useRef(t);l.useLayoutEffect(()=>{a.current=t},[t]),l.useLayoutEffect(()=>{s.current=e;const c=r.current;if(c!==null)if(e&&!c.open){const f=c.ownerDocument.activeElement;o.current=f instanceof HTMLElement?f:null,c.showModal(),a.current?.()}else!e&&c.open&&(c.close(),o.current?.isConnected===!0&&o.current.focus(),o.current=null)},[e]),l.useLayoutEffect(()=>{const c=r.current;if(!e||c===null)return;const f=new ResizeObserver(()=>v());let p=null;const v=()=>{const R=Br(c);R===null||R===p||(p!==null&&f.unobserve(p),f.observe(R),p=R)};v(),f.observe(c);const x=c.ownerDocument.defaultView;return x?.addEventListener("resize",v),c.ownerDocument.addEventListener("scroll",v,{capture:!0,passive:!0}),()=>{f.disconnect(),x?.removeEventListener("resize",v),c.ownerDocument.removeEventListener("scroll",v,{capture:!0})}},[e]);const d=l.useCallback(c=>{c.key!=="Escape"||c.defaultPrevented||(it(c),n())},[n]),m=l.useCallback(c=>{c.target===c.currentTarget&&n()},[n]),w=l.useCallback(()=>{s.current&&n()},[n]);return{ref:r,onKeyDown:d,onClick:m,onCancel:Hr,onClose:w}},mn=({open:e,title:t,body:n,confirmLabel:r,cancelLabel:o,onConfirm:s,onCancel:a,testId:d})=>{const m=l.useRef(null),w=l.useId(),c=l.useId(),f=l.useCallback(()=>m.current?.focus(),[]),p=fn({open:e,onOpen:f,onDismiss:a});return i.jsx("dialog",{...p,className:"aqmx-confirm","aria-labelledby":w,"aria-describedby":c,"data-testid":d,children:i.jsxs("div",{className:"aqmx-confirm-panel",children:[i.jsx("p",{id:w,className:"aqmx-confirm-title",children:t}),i.jsx("p",{id:c,className:"aqmx-confirm-body",children:n}),i.jsxs("div",{className:"aqmx-confirm-actions",children:[i.jsx("button",{ref:m,type:"button",className:"aqmx-callout-action","data-testid":`${d}-cancel`,onClick:a,children:o}),i.jsx("button",{type:"button",className:"aqmx-callout-action","data-aqmx-tone":"danger","data-testid":`${d}-confirm`,onClick:s,children:r})]})]})})},we=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},hn=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),he=e=>e.status==="fulfilled"?e.value:void 0,gn=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!1}),Ur=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!0}),Vr=(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 a=s.lazy===!0?n(s.path):void 0,d=s.lazy===!0?a?.status==="loaded"?a.entries:null:s.children===void 0?[]:s.children;if(s.path===t)return d;if(d!==null)for(const m of[...d].reverse())o.push(m)}return null},pn=(e,t,n)=>{const r=he(e.read(t));if(r===void 0||r.status==="deferred")return gn;if(r.status==="error")return{readme:{status:"failed",failure:r.failure,retry:()=>e.retry(t)},claim:!1};const o=Vr(r.entries,n,a=>e.children(t,a));if(o!==null)return{readme:{status:"ok",readme:V.folderReadmeOf(o)},claim:!1};const s=e.children(t,n);return s===void 0||s.status==="loading"?Ur:s.status==="failed"?{readme:{status:"failed",failure:s.failure,retry:()=>e.retryChildren(t,n)},claim:!0}:{readme:{status:"ok",readme:V.folderReadmeOf(s.entries)},claim:!0}},zr=(e,t,n)=>{const{readme:r}=pn(e,t,n);return r.status==="ok"?r.readme:null},Zr=(e,t,n)=>{const r=J.matchPath({path:`${e.basePath}/*`,end:!0},t.pathname);if(r===null)return new Set;const{location:o}=V.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)}},wn=e=>{const{edits:t}=F(),n=l.useCallback(()=>t.session(e),[t,e]);return l.useSyncExternalStore(t.subscribe,n,Gr)},vn=()=>!1,Gr=()=>{},Kr=()=>{const{edits:e}=F();return l.useSyncExternalStore(e.subscribe,e.hasSessions,vn)},En=()=>{const{edits:e}=F();return l.useSyncExternalStore(e.subscribe,e.sideBySide,vn)},Wr=()=>null,Xr=()=>{const{edits:e,labels:t,config:n,trees:r}=F(),o=l.useRef([]),s=l.useCallback(({nextLocation:v})=>{const x=Zr(n,v,(R,C)=>zr(r,R,C));return e.flushDrafts(),o.current=e.dirtyPaths().filter(R=>!x.has(R)),o.current.length>0},[e,n,r]),a=J.useBlocker(s),d=Kr();l.useEffect(()=>{if(!d)return;const v=x=>{e.flushDrafts(),e.dirtyPaths().length!==0&&(x.preventDefault(),x.returnValue=!0)};return window.addEventListener("beforeunload",v),()=>window.removeEventListener("beforeunload",v)},[d,e]);const m=l.useSyncExternalStore(e.subscribe,e.discardRequest,Wr),w=a.state==="blocked",c=w?o.current:m===null?[]:m.paths,f=c.map(v=>D.lastPathSegment(v)).join(", "),p=c.length>0&&c.every(v=>e.session(v)?.save.kind==="draft");return i.jsx(mn,{open:w||m!==null,title:p?t.draftDiscardTitle:t.unsavedTitle,body:p?t.draftDiscardBody(f):t.unsavedBody(f),confirmLabel:t.unsavedDiscard,cancelLabel:t.unsavedStay,testId:"markdown-explorer-unsaved-guard",onConfirm:()=>{if(a.state==="blocked"){e.discard(o.current),a.proceed();return}m?.settle(!0)},onCancel:()=>{if(a.state==="blocked"){a.reset();return}m?.settle(!1)}})};function Yr({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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 Qr=S.forwardRef(Yr);let He=null;const xn=()=>(He??=Promise.resolve().then(()=>require("./EditSurface-Co4Rvfa1.cjs")).catch(e=>{throw He=null,e}),He),Jr=()=>{xn().catch(()=>{})},eo=e=>{const{default:t}=l.use(xn());return i.jsx(t,{...e})};class to extends l.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 lt=`[${Xe.SOURCE_LINES_ATTRIBUTE}]`,no="[data-aqmd-content]",ro='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]',oo=200,ve=e=>Xe.parseSourceLines(e.getAttribute(Xe.SOURCE_LINES_ATTRIBUTE)),so=(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(lt)){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}},ao=(e,t)=>{let n=0;for(let r=e.indexOf(t);r>=0;r=e.indexOf(t,r+t.length))n+=1;return n},bn=e=>e.closest(no)!==null&&e.closest(ro)===null,Sn=(e,t,n)=>{const r=so(e,t);if(r===null)return null;const{block:o,own:s}=r;if(!s){const d=r.lines.last+1;return{lines:{first:d,last:d},word:null,occurrence:0,clientTop:Me(e)}}const a=io(o,n);return a===null?{lines:r.lines,word:null,occurrence:0,clientTop:Me(o)}:{lines:r.lines,word:a.text,occurrence:a.occurrence,clientTop:a.clientTop}},yn=(e,t)=>{let n=null,r=null,o=null;for(const a of e.querySelectorAll(lt)){const d=ve(a);if(d===null)continue;n??=Rn(t,a);const{top:m,bottom:w}=a.getBoundingClientRect();m<=n&&n<w?r={lines:d,block:a}:o===null&&m>=n&&(o={lines:d,block:a})}const s=r===null?o:r;return s===null?null:{lines:s.lines,word:null,occurrence:0,clientTop:Me(s.block)}},kn=e=>e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,Rn=(e,t)=>{const n=Number.parseFloat(getComputedStyle(t).scrollMarginTop);return kn(e)+(Number.isFinite(n)?n:0)},io=(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>oo||/[\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:ao(o.toString(),r),clientTop:n.getBoundingClientRect().top}},lo=(e,t)=>{const n=e.split(`
|
|
11
|
-
`),r=Math.min(t.lines.first,n.length),o=Math.min(t.lines.last,n.length),s={line:r,column:0};if(t.word===null)return s;let a=0;for(let d=r;d<=o;d+=1){const m=n[d-1]??"";for(let w=m.indexOf(t.word);w>=0;w=m.indexOf(t.word,w+t.word.length)){if(a===t.occurrence)return{line:d,column:w};a+=1}}return a>0?co(n,r,o,t.word)??s:s},co=(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},Tn=(e,t)=>{let n=null,r=null;for(const o of e.querySelectorAll(lt)){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},Cn=(e,t)=>{const{bottom:n}=e.getBoundingClientRect(),r=Me(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},Me=e=>{const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let n=t.nextNode();n!==null;n=t.nextNode()){const o=(n.textContent??"").search(/\S/u);if(o<0)continue;const s=e.ownerDocument.createRange();s.setStart(n,o),s.setEnd(n,o+1);const{top:a,height:d}=s.getBoundingClientRect();if(d>0)return a}return e.getBoundingClientRect().top},ct=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})}),uo=e=>ct[e],Ee=()=>{const e=J.useNavigate();return l.useCallback((t,n)=>{e(t,ct[n])},[e])},On=({navigation:e,...t})=>i.jsx(J.Link,{...t,...ct[e]}),dt=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},Ln=(e,t)=>{const n=l.useRef(null),r=l.useRef(null),o=l.useRef(null),s=l.useCallback(()=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,r.current=null},[]);l.useEffect(()=>s,[s]);const a=l.useCallback(w=>{if(r.current!==w)return;const c=o.current;if(c!==null){c.then(()=>a(w));return}e.prefetch(w);const f=e.peek(w);if(f?.status!=="pending")return;const p=Promise.allSettled([f.promise]);o.current=p,p.then(()=>{o.current===p&&(o.current=null)})},[e]),d=l.useCallback(w=>{const c=t(w);c!==r.current&&(s(),c!==null&&(r.current=c,n.current=window.setTimeout(()=>{n.current=null,a(c)},V.PREFETCH_DWELL_MS)))},[s,t,a]),m=l.useCallback(w=>{t(w)!==r.current&&s()},[s,t]);return l.useMemo(()=>({onPointerOver:w=>d(w.target),onPointerOut:w=>m(w.relatedTarget),onFocus:w=>d(w.target),onBlur:w=>m(w.relatedTarget)}),[d,m])},fo=l.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-ThVMbI0Y.cjs")).then(e=>({default:e.NativeScrollBar})));class mo extends l.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 An=({scroller:e,withCircle:t})=>i.jsx(mo,{children:i.jsx(l.Suspense,{fallback:null,children:i.jsx(fo,{scroller:e,withCircle:t})})}),Mn=e=>i.jsx(An,{scroller:e,withCircle:!0}),jn=()=>{const e=new Map,t=new Set;let n=!1;const r=o=>{t.add(o),!n&&(n=!0,queueMicrotask(()=>{n=!1,t.clear()}))};return{hold:o=>{e.set(o,(e.get(o)??0)+1);let s=!1;return()=>{if(s)return;s=!0;const a=e.get(o);if(a!==void 0&&a>1){e.set(o,a-1);return}e.delete(o),r(o)}},isHeld:o=>e.has(o),resumes:o=>t.delete(o),heldKeys:()=>[...e.keys()]}},je=(e,t)=>{if(Object.is(e,t))return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;if(Array.isArray(e)||Array.isArray(t))return!(Array.isArray(e)&&Array.isArray(t))||e.length!==t.length?!1:e.every((s,a)=>je(s,t[a]));const n=e,r=t,o=Object.keys(n);return o.length!==Object.keys(r).length?!1:o.every(s=>Object.hasOwn(r,s)&&je(n[s],r[s]))},ho=55e3,Ct=Object.freeze({status:"deferred"}),Ue=Object.freeze({status:"refreshed"}),Ve=Object.freeze({status:"shown",failed:!1}),ke=Object.freeze({status:"shown",failed:!0}),Re=Object.freeze({status:"superseded"}),oe=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,go=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",po=({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=jn(),o=me(),s=new WeakSet,a=new Map,d=new Map,m=new Map;let w=0;const c=o.emit,f=()=>(w+=1,w),p=()=>{if(!(n.size<=t))for(const E of[...n.keys()]){if(n.size<=t)return;r.isHeld(E)||n.delete(E)}},v=(E,T)=>{n.delete(E),n.set(E,T)},x=E=>performance.now()-E.validatedAt>=ho,R=(E,T,M)=>{const O=n.get(E),_=oe(O?.snapshot),B=M||O?.refreshPending===!0,K=we(e.document(E,{refresh:B}).then(b=>({status:"loaded",document:b}))),g={snapshot:{status:"pending",promise:K,previous:_},validatedAt:performance.now(),opened:T,background:null,refreshPending:!1,seeded:void 0,stamp:f()};return v(E,g),p(),K.then(b=>{n.get(E)===g&&(g.snapshot=b,g.stamp=f(),c())}),g},C=(E,T,M,O,_,B)=>{T.background===M&&(T.background=null,!(n.get(E)!==T||T.snapshot!==O)&&(_.kind==="failure"&&O.document.kind!=="failure"||(T.validatedAt=B,T.stamp=f(),je(O.document,_)||(T.snapshot={status:"loaded",document:_}),c())))},j=async(E,T)=>{const M=T.snapshot;if(M.status!=="loaded")return null;const O={};T.background=O;const _=performance.now(),B=e.document(E,{refresh:T.refreshPending});T.refreshPending=!1;const K=await B,g=T.background===O&&n.get(E)===T&&T.snapshot===M;return C(E,T,O,M,K,_),g?K:null},N=(E,T)=>{const{snapshot:M}=T;return M.status==="pending"?!1:M.status==="loaded"&&M.document.kind!=="failure"?(j(E,T),!1):(M.status==="loaded"&&s.add(M),R(E,!0,!1),!0)},$=E=>{d.delete(E);const T=m.get(E);if(T!==void 0){m.delete(E);for(const M of T)M()}},P=(E,T)=>new Promise(M=>{if(d.get(E)===T||!r.isHeld(E)){M();return}const O=m.get(E);O===void 0?m.set(E,new Set([M])):O.add(M)}),u=(E,T)=>{const M=a.get(E);if(M===void 0){T.resolve(null);return}if(M.last!==null&&M.last.stamp>=T.stamp){T.resolve(M.last);return}M.waiters.add(T)},h=async(E,T,M)=>{const O=await new Promise(_=>u(E,{stamp:T.stamp,resolve:_}));if(n.get(E)!==T)return Re;if(O===null)return M?Ue:Ve;if(!M)return O.failure===null?Ve:ke;switch(O.before){case"copy":return O.failure===null?Ue:{status:"failed",failure:O.failure};case"failure":return O.failure===null?Ve:ke;case"none":return O.failure===null?Ue:ke}},k=E=>{const T={showing:"none",last:null,waiters:new Set};a.set(E,T);let M=!1;return{settle:(O,_)=>{if(M||O===void 0)return;const B={stamp:O,failure:_,before:T.showing};T.last=B,_===null?T.showing="copy":T.showing==="none"&&(T.showing="failure");for(const K of[...T.waiters])O<K.stamp||(T.waiters.delete(K),K.resolve(B))},release:()=>{if(M)return;M=!0,a.get(E)===T&&a.delete(E);const O=[...T.waiters];T.waiters.clear(),O.length>0&&queueMicrotask(()=>{for(const _ of O)u(E,_)})}}},A=E=>{const T=r.hold(E);let M=!1;return()=>{if(M)return;M=!0,T();const O=n.get(E);O!==void 0&&v(E,O),p(),r.isHeld(E)||queueMicrotask(()=>{r.isHeld(E)||$(E)})}};return{peek:E=>n.get(E)?.snapshot,peekSeeded:E=>n.get(E)?.seeded,answerStampOf:E=>n.get(E)?.stamp,prefetch:E=>{const T=n.get(E);T!==void 0&&T.snapshot.status!=="deferred"||(R(E,!1,!1),c())},open:E=>{const T=r.resumes(E),M=A(E),O=n.get(E);if(O===void 0||O.snapshot.status==="deferred")return R(E,!0,!1),c(),M;if(v(E,O),T)return M;const{snapshot:_}=O;return _.status==="pending"?(O.opened=!0,M):_.document.kind==="failure"?(O.opened||x(O)?(s.add(_),R(E,!0,!1),c()):O.opened=!0,M):(O.opened=!0,O.background===null&&x(O)&&j(E,O),M)},retain:A,retry:E=>{const T=n.get(E);T===void 0||T.snapshot.status!=="loaded"||T.snapshot.document.kind!=="failure"||(R(E,!0,!1),c())},seed:(E,T)=>{const M=performance.now(),O=we(T.then(b=>b===null?Ct:{status:"loaded",document:b},()=>Ct)),_=n.get(E);if(_!==void 0&&_.snapshot.status==="loaded"){const b=_.snapshot,y={};_.background=y,O.then(L=>{if(L.status==="loaded"){C(E,_,y,b,L.document,M);return}_.background===y&&(_.background=null)});return}const B=_!==void 0&&_.snapshot.status==="pending"?_.snapshot.previous:null,K={status:"pending",promise:O,previous:B},g={snapshot:K,validatedAt:M,opened:_?.opened===!0,background:null,refreshPending:_?.refreshPending===!0,seeded:K,stamp:f()};v(E,g),p(),O.then(b=>{n.get(E)===g&&(b.status==="deferred"&&r.isHeld(E)?R(E,g.opened,!1):(g.snapshot=b,g.stamp=f()),c())})},invalidate:()=>{let E=!1;for(const[T,M]of[...n]){if(M.validatedAt=Number.NEGATIVE_INFINITY,M.opened=!0,M.refreshPending=!0,!r.isHeld(T))continue;const{snapshot:O}=M;if(O.status!=="pending"){N(T,M)&&(E=!0);continue}O.promise.then(()=>{n.get(T)===M&&M.refreshPending&&r.isHeld(T)&&N(T,M)&&c()})}E&&c()},refresh:async E=>{const T=n.get(E);if(T!==void 0&&go(T.snapshot)){T.refreshPending=!0;const _=await j(E,T);return _===null?Re:_.kind==="failure"?{status:"failed",failure:_.failure}:h(E,T,!0)}const M=R(E,!0,!0);if(c(),M.snapshot.status!=="pending")return Re;const O=await M.snapshot.promise;return n.get(E)!==M||O.status!=="loaded"?Re:O.document.kind==="failure"?ke:(await P(E,O),h(E,M,!1))},clear:()=>{n.clear();for(const E of r.heldKeys())R(E,!0,!1);c()},subscribe:o.subscribe,readPart:k,noteShown:(E,T)=>{d.set(E,T);const M=m.get(E);if(M!==void 0){m.delete(E);for(const O of M)O()}},noteFailureShown:E=>s.has(E)?!1:(s.add(E),!0)}},ae=l.createContext("fill"),wo=Object.freeze({blockSize:"100%"}),xe=({scrollerProps:e,children:t})=>l.use(ae)==="content"?i.jsx(ue.HostedScrollArea,{scrollerProps:e,children:t}):i.jsx(ue.HostedScrollArea,{scrollerProps:{...e,style:wo},rowClassName:"aqmx-document-scroll-row",renderScrollBar:Mn,children:t}),vo=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),Eo=Object.freeze({className:"aqmx-document-failure","data-aqmx-document-scroller":""}),be=({label:e,testId:t})=>i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":t,children:vo.map(n=>i.jsx("span",{},n))}),i.jsx("p",{className:"aqmx-sr-only",children:e})]}),ut=({failure:e,onRetry:t,testId:n})=>i.jsx(xe,{scrollerProps:Eo,children:i.jsx(fe,{failure:e,alert:!1,onRetry:t,testId:n})});function xo({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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"}),S.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 bo=S.forwardRef(xo);function So({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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"}),S.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 yo=S.forwardRef(So);function ko({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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 Ro=S.forwardRef(ko),To=2e3,Ot=Object.freeze({outcome:"idle"}),Co=e=>{const t=navigator.clipboard;return t===void 0?Promise.reject(new Error("[markdown-explorer] this browser has no asynchronous clipboard")):t.writeText(e)},Oo=({text:e})=>{const{announcer:t,labels:n}=F(),[r,o]=l.useState(Ot);l.useEffect(()=>{if(r.outcome==="idle")return;const m=setTimeout(()=>o(Ot),To);return()=>clearTimeout(m)},[r]);const s=m=>{o({outcome:m}),t.announce(m==="copied"?n.copiedText:n.copyTextFailed)},a=()=>{Co(e).then(()=>s("copied"),()=>s("failed"))},d=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:d,onClick:a,"data-aqmx-copy-outcome":r.outcome,"data-testid":"markdown-explorer-file-copy",children:r.outcome==="copied"?i.jsx(bo,{}):r.outcome==="failed"?i.jsx(Ro,{}):i.jsx(yo,{})})},Nn=l.createContext(null),Lo=()=>{const e=l.use(Nn);if(e===null)throw new Error("[markdown-explorer] a document's content reads its own part only inside a document pane (DocumentContentChannelContext)");return e};function Ao({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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"}),S.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 Mo=S.forwardRef(Ao);function jo({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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"}),S.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 No=S.forwardRef(jo),Se=({name:e,openUrl:t,downloadUrl:n,icon:r,children:o})=>{const{labels:s}=F();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(No,{})}),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(Mo,{})})]})};function Po({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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 Do=S.forwardRef(Po),_o=Object.freeze({className:"aqmx-document-stage"}),Io=({document:e})=>{const{labels:t}=F();return i.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[i.jsx(Se,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:i.jsx(Do,{})}),i.jsx(xe,{scrollerProps:_o,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})]})})]})},De="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",Fo=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},qo=/(%[0-9A-Fa-f]{2})/u,ft=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(qo).flatMap((r,o)=>o%2===1?[Number.parseInt(r.slice(1),16)]:[...t.encode(r)]);return new TextDecoder("utf-8",{ignoreBOM:!0}).decode(Uint8Array.from(n))},Pn=e=>`#${encodeURIComponent(e)}`,$o=e=>{if(e==="#")return!0;const t=ft(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},Dn=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},Bo="http://www.w3.org/1999/xhtml",Lt=(e,t)=>{if(t==="")return null;const n=Dn(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===Bo&&r.getAttribute("name")===t)return r;return null},_n=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=Lt(e,t.slice(1));if(n!==null)return n;const r=ft(t);return r===null?null:Lt(e,r)},At=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"},Ho=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(De),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&At(r))return r;const o=e.getBoundingClientRect().height,{documentElement:s,scrollingElement:a}=e.ownerDocument;for(let d=e.parentElement;d!==null&&d!==s;d=d.parentElement)if(At(d)&&d.scrollHeight>d.clientHeight&&d.clientHeight<o)return d;return a instanceof Element&&Ho(e.ownerDocument)&&a.scrollHeight>a.clientHeight&&a.clientHeight<o?a:r},Vo=Object.freeze({scrollerOf:Uo,reveal:e=>{e.scrollIntoView(tt)}}),tt=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),zo=(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")}}},Zo=(e,t)=>{if(t.getClientRects().length===0)return;const n=e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,{scrollMarginTop:r,scrollMarginBottom:o}=getComputedStyle(t),s=Number.parseFloat(r),a=t.getBoundingClientRect(),d=a.height+s+Number.parseFloat(o)>e.clientHeight;if(!d&&Math.abs(a.top-s-n)<1){t.scrollIntoView(tt);return}e.scrollBy({top:d?a.top-n-e.clientHeight:a.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(tt)},Go=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(De)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},Mt=(e,t,n)=>{if(e===null)return null;const r=_n(e,t);return r===null?($o(t)&&Go(e,n),null):(zo(e,r),Zo(n.scrollerOf(e,r),r),n.reveal(r),r)};function Ko({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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 Wo=S.forwardRef(Ko);function Xo({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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"}),S.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 Yo=S.forwardRef(Xo);function Qo({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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"}),S.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 Jo=S.forwardRef(Qo);function es({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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 ts=S.forwardRef(es),nt="data-aqmx-key-repeat",Ne=Object.freeze({[nt]:"allow"}),ns=`[${nt}="${Ne[nt]}"]`,rs=()=>{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(ns)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},Le=Object.freeze([1/V.GOLDEN_RATIO**2,1/V.GOLDEN_RATIO,1,V.GOLDEN_RATIO,V.GOLDEN_RATIO**2]),jt=Object.freeze({mode:"fit"}),os=1,In=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),Nt=`[data-testid="${In["data-testid"]}"]`,Fn=l.createContext(null),ss=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=os?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,Pt=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<Le.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?Le.findIndex(o=>o>t):Le.findLastIndex(o=>o<t);return r===-1?null:r},Dt=(e,t,n)=>{if(e.mode==="level"){const o=Pt(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=Pt(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},as=(e,t)=>{if(e<=0||t<=0)return 0;const n=Math.trunc(Math.log(t/e)/Math.log(V.GOLDEN_RATIO));return n===0?0:n},_t=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}}},is=e=>{const t=Le[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},It=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},ls=({document:e})=>{const{labels:t}=F(),n=l.use(Fn),[r]=l.useState(()=>n===null?null:n.read(e.url)),[o,s]=l.useState(r===null?jt:r.zoom),[a,d]=l.useState(r===null?null:r.reported),[m,w]=l.useState(null),c=l.useRef(null),f=l.useCallback(P=>{const{naturalWidth:u,naturalHeight:h}=P;d(k=>It(k,u,h))},[]),p=l.useCallback(P=>{c.current=P,!(P===null||!P.complete)&&(P.naturalWidth>0||P.naturalHeight>0?f(P):P.decode().then(()=>f(P),()=>{}))},[f]);l.useEffect(()=>{n!==null&&a!==null&&n.save(e.url,{zoom:o,reported:a})},[n,e.url,o,a]),l.useLayoutEffect(()=>{const P=c.current;if(P===null||a===null||o.mode!=="fit")return;const u=()=>w(k=>It(k,P.clientWidth,P.clientHeight));if(u(),typeof ResizeObserver>"u")return;const h=new ResizeObserver(u);return h.observe(P),()=>h.disconnect()},[a,o.mode]);const v=a===null||m===null?null:ss(a,m),x=Dt(o,v,-1),R=Dt(o,v,1),C=o.mode==="level"?is(o.index):null,j=l.useRef({zoomIn:R,zoomOut:x});l.useLayoutEffect(()=>{j.current={zoomIn:R,zoomOut:x}});const N=l.useRef(null);l.useLayoutEffect(()=>{const P=N.current,u=c.current?.closest(Nt);N.current=null,!(P===null||u===null||u===void 0)&&(u.scrollLeft=P.across*u.scrollWidth-P.x,u.scrollTop=P.down*u.scrollHeight-P.y)},[o]),l.useEffect(()=>{const P=c.current?.closest(Nt);if(P==null)return;let u=null;const h=I=>{const q=_t(I.touches);u=q===null?null:{distance:q.distance,steps:0}},k=I=>{const q=_t(I.touches);if(u===null||q===null)return;I.preventDefault();const E=as(u.distance,q.distance);if(E===u.steps)return;const T=E>u.steps?1:-1,M=T===1?j.current.zoomIn:j.current.zoomOut;if(M===null)return;u.steps+=T;const O=P.getBoundingClientRect(),_=q.middle.x-O.left,B=q.middle.y-O.top;N.current=P.scrollWidth>0&&P.scrollHeight>0?{x:_,y:B,across:(P.scrollLeft+_)/P.scrollWidth,down:(P.scrollTop+B)/P.scrollHeight}:null,s(M)},A=I=>{I.touches.length<2&&(u=null)};return P.addEventListener("touchstart",h,{passive:!0}),P.addEventListener("touchmove",k,{passive:!1}),P.addEventListener("touchend",A,{passive:!0}),P.addEventListener("touchcancel",A,{passive:!0}),()=>{P.removeEventListener("touchstart",h),P.removeEventListener("touchmove",k),P.removeEventListener("touchend",A),P.removeEventListener("touchcancel",A)}},[]);const $=o.mode==="level"&&C!==null?{width:`${o.base.width*C}px`,height:`${o.base.height*C}px`}:void 0;return i.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[i.jsxs(Se,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:i.jsx(ts,{}),children:[i.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":x===null,onClick:()=>{x!==null&&s(x)},...Ne,children:i.jsx(Yo,{})}),i.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:C===null?t.imageFitLevel:t.imageZoomLevel(Math.round(C*100))}),i.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":R===null,onClick:()=>{R!==null&&s(R)},...Ne,children:i.jsx(Jo,{})}),i.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(jt),children:i.jsx(Wo,{})})]}),i.jsx(xe,{scrollerProps:In,children:i.jsx("img",{ref:p,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:$,onLoad:P=>f(P.currentTarget),"data-testid":"markdown-explorer-image"})})]})},cs=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"}},qn=l.createContext(null),_e=l.createContext(void 0),$n=l.createContext(null),Ie=()=>{const e=l.use(qn);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},ds=()=>{const e=l.use($n);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},Fe=(e,t,n,r)=>t.kind==="panel"?V.explorerHref(e,{view:"tree",source:n,doc:r}):t.view==="single"?V.explorerHref(e,{view:"single",source:n,doc:r,overrides:t.overrides,embed:t.embed}):V.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides}),us=({children:e})=>{const{config:t}=F(),n=Ie(),r=Pe(),o=r.kind==="location"?r.location.source:void 0,s=J.useHref(Fe(t,n.navigation,o,n.currentPath));return i.jsx(_e,{value:o,children:i.jsx($n,{value:s,children:e})})},fs='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',ms=e=>{const t=e instanceof Element?e.closest(fs):null;return t===null?null:t.getAttribute("data-doc-path")},qe=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,hs=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:a,scope:d,children:m})=>{const w=J.useHref(e),c=f=>{if(qe(f)){if(f.preventDefault(),t===d.currentPath&&n!==""){d.scrollWithin(n);return}a(t,n)}};return i.jsx("a",{...s,href:w,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:c,children:m})},gs=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:a}=F(),d=Ie(),m=l.use(_e),w=Fo(e),{navigation:c}=d,f=`${Fe(a,c,m,t)}${w}`,p=n===!1?"false":void 0;return c.kind==="page"?i.jsx(On,{...o,to:f,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":p,children:s}):i.jsx(hs,{to:f,docPath:t,fragment:w,exists:p,className:r,attributes:o,onDocumentLink:c.onDocumentLink,scope:d,children:s})},ps=({className:e,attributes:t,children:n})=>{const{labels:r}=F();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,")"]})]})},ws=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=F(),a=l.use(_e),d=J.useHref(`${Fe(s,r.navigation,a,r.currentPath)}${e}`),m=w=>{qe(w)&&(w.preventDefault(),r.scrollWithin(e))};return i.jsx("a",{...n,href:d,className:t,onClick:m,children:o})},vs=({href:e,className:t,attributes:n,children:r})=>{const o=Ie();if(o.navigation.kind==="page"){const s=a=>{if(!qe(a))return;const d=a.currentTarget;e==="#"?o.followEmptyFragment(a.nativeEvent):d.href===d.ownerDocument.URL&&o.followSameUrlJump(e,a.nativeEvent)};return i.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return i.jsx(ws,{href:e,className:t,attributes:n,scope:o,children:r})},Es=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:a})=>t==="doc"?n===void 0||!D.isAcceptableDocumentPath(n)?i.jsx(ps,{className:o,attributes:s,children:a}):i.jsx(gs,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:a}):e.startsWith("#")?i.jsx(vs,{href:e,className:o,attributes:s,children:a}):i.jsx("a",{...s,href:e,className:o,children:a}),xs=()=>{const{config:e}=F(),t=Ie(),n=l.use(_e),r=Ee();return l.useCallback((o,s)=>{if(!qe(s))return!0;s.preventDefault();const a=Pn(o.id),{navigation:d}=t;return d.kind==="panel"||ft(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(a),!0):(r(`${Fe(e,d,n,t.currentPath)}${a}`,"follow-link"),!0)},[e,t,n,r])},bs=()=>{const e=ds();return l.useCallback(t=>`${e}${Pn(t.id)}`,[e])};function Ss({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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 ys=S.forwardRef(Ss);function ks({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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 Rs=S.forwardRef(ks);function Ts({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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 Cs=S.forwardRef(Ts),Os=Object.freeze({className:"aqmx-document-stage"}),Ls=()=>()=>{},As=()=>navigator.pdfViewerEnabled!==!1,Ms=()=>null,js=({document:e})=>{const{labels:t}=F(),n=l.useSyncExternalStore(Ls,As,Ms);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})]})]})},Ns=e=>{switch(e){case"video":return i.jsx(Rs,{});case"audio":return i.jsx(Cs,{});case"pdf":return i.jsx(ys,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},Ps=({document:e})=>{const{labels:t}=F();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(js,{document:e});default:{const n=e.mediaType;throw new RangeError(`[markdown-explorer] unknown media type ${String(n)}`)}}},Ds=({document:e})=>i.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[i.jsx(Se,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:Ns(e.mediaType)}),i.jsx(xe,{scrollerProps:Os,children:i.jsx(Ps,{document:e})})]}),mt=e=>{switch(e.kind){case"markdown":return"markdown";case"image":return e.imageType==="svg"?"svg":null;case"spreadsheet":return e.format;default:return null}},_s=e=>{const{documents:t}=F(),n=l.useCallback(()=>t.peek(e),[t,e]),r=l.useCallback(()=>t.peekSeeded(e),[t,e]),o=l.useSyncExternalStore(t.subscribe,n,r),s=oe(o);return s===null?null:mt(s.document)},Bn=e=>{const{config:t}=F(),n=Ee(),r=l.useCallback(()=>n(V.explorerHref(t,{...e,markup:!e.markup}),"browse"),[t,n,e]);return l.useMemo(()=>({shown:e.markup,toggle:r}),[e.markup,r])};function Is({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.createElement("path",{fillRule:"evenodd",d:"M.99 5.24A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25l.01 9.5A2.25 2.25 0 0 1 16.76 17H3.26A2.267 2.267 0 0 1 1 14.74l-.01-9.5Zm8.26 9.52v-.625a.75.75 0 0 0-.75-.75H3.25a.75.75 0 0 0-.75.75v.615c0 .414.336.75.75.75h5.373a.75.75 0 0 0 .627-.74Zm1.5 0a.75.75 0 0 0 .627.74h5.373a.75.75 0 0 0 .75-.75v-.615a.75.75 0 0 0-.75-.75H11.5a.75.75 0 0 0-.75.75v.625Zm6.75-3.63v-.625a.75.75 0 0 0-.75-.75H11.5a.75.75 0 0 0-.75.75v.625c0 .414.336.75.75.75h5.25a.75.75 0 0 0 .75-.75Zm-8.25 0v-.625a.75.75 0 0 0-.75-.75H3.25a.75.75 0 0 0-.75.75v.625c0 .414.336.75.75.75H8.5a.75.75 0 0 0 .75-.75ZM17.5 7.5v-.625a.75.75 0 0 0-.75-.75H11.5a.75.75 0 0 0-.75.75V7.5c0 .414.336.75.75.75h5.25a.75.75 0 0 0 .75-.75Zm-8.25 0v-.625a.75.75 0 0 0-.75-.75H3.25a.75.75 0 0 0-.75.75V7.5c0 .414.336.75.75.75H8.5a.75.75 0 0 0 .75-.75Z",clipRule:"evenodd"}))}const Fs=S.forwardRef(Is),qs=100,$s=32767,Bs=Object.freeze({maxCells:St.SPREADSHEET_MAX_OPERATION_CELLS,maxColumns:St.SPREADSHEET_MAX_OPERATION_CELLS/qs,maxCellLength:$s}),Hn=44,Un=10,Vn=13,Te='"',Ft=(e,t)=>{let n=t;for(;n<e.length;){const r=e.charCodeAt(n);if(r===Hn||r===Un||r===Vn)return n;n+=1}return n};function*Hs(e,t){let n=[],r=0;for(;;){let o;if(e.startsWith(Te,r)){o="";let a=r+1;for(;;){const m=e.indexOf(Te,a);if(m<0){o+=e.slice(a),r=e.length;break}if(o+=e.slice(a,m),e.startsWith(Te,m+1)){o+=Te,a=m+2;continue}r=m+1;break}const d=Ft(e,r);o+=e.slice(r,d),r=d}else{const a=Ft(e,r);o=e.slice(r,a),r=a}if(n.push(o),r>=e.length){t==="whole"&&(yield n);return}const s=e.charCodeAt(r);if(r+=1,s!==Hn&&(yield n,n=[],s===Vn&&e.charCodeAt(r)===Un&&(r+=1),r>=e.length))return}}const Us=(e,t,n)=>t==="csv"?Hs(e,n):n==="whole"?Ye.iterateTsvRows(e):Ye.iterateTsvPrefixRows(e),Vs=(e,t)=>{if(e.length<=t)return e;const n=e.charCodeAt(t-1);return e.slice(0,n>=55296&&n<=56319?t-1:t)},zs=(e,t)=>{const n=[];let r=0,o=!1,s=!1;for(const d of e){const m=d.length>t.maxColumns?d.slice(0,t.maxColumns):d,w=Math.max(r,m.length);if((n.length+1)*w>t.maxCells){s=!0;break}const c=m.some(f=>f.length>t.maxCellLength)?m.map(f=>Vs(f,t.maxCellLength)):m;c!==d&&(o=!0),n.push(c),r=w}return{rows:n.map(d=>d.length===r?d:[...d,...Array(r-d.length).fill("")]),truncated:s||o,full:s}},ze=(e,t,n,r,o)=>{const s=V.decodeText(e,t,r);if(s===null)return{kind:"unreadable",code:"encoding",encodings:V.textEncodingsOf(e,t,r)};if(s.includes("\0"))return{kind:"unreadable",code:"binary"};const a=zs(Us(s,n,t?"whole":"prefix"),o);return t?a.truncated||a.rows.some(d=>d.some(m=>m!==""))?{kind:"table",table:a}:{kind:"empty"}:a.rows.length===0?{kind:"unreadable",code:"long-row"}:{kind:"table",table:{...a,truncated:!0}}},zn=64*1024,Zs=e=>{let t=new Uint8Array(Math.min(e,zn)),n=0;return{append:r=>{if(n+r.byteLength>t.byteLength){const o=new Uint8Array(Math.min(e,Math.max(t.byteLength*2,n+r.byteLength)));o.set(t.subarray(0,n)),t=o}t.set(r,n),n+=r.byteLength},bytes:()=>t.subarray(0,n),length:()=>n}},Gs=async e=>{for(;;){const{done:t,value:n}=await e.read();if(t)return!0;if(n.byteLength>0)return!1}},Ks=async(e,t)=>{const{format:n,legacyEncoding:r,maxBytes:o,budget:s}=t,a=e.getReader(),d=Zs(o);let m=zn;try{for(;;){const{done:w,value:c}=await a.read();if(w)return ze(d.bytes(),!0,n,r,s);const f=o-d.length();if(d.append(c.byteLength>f?c.subarray(0,f):c),d.length()===o){const v=c.byteLength<=f&&await Gs(a);return ze(d.bytes(),v,n,r,s)}if(d.length()<m)continue;m=d.length()*2;const p=ze(d.bytes(),!1,n,r,s);if(p.kind==="unreadable"&&p.code!=="long-row"||p.kind==="table"&&p.table.full)return p}}finally{a.cancel().catch(()=>{})}},Ws=async(e,t,n,r)=>{const o=await e.asset(D.explorerPlainTextHref(t),r);if(o.status==="cancelled")return null;if(o.status==="error")return{kind:"failure",failure:o.failure};let s;try{s=await Ks(o.body,n)}catch{return r.aborted?null:{kind:"failure",failure:{reason:"failed"}}}return r.aborted?null:s.kind==="table"?{kind:"table",rows:s.table.rows,truncated:s.table.truncated}:s},Zn=(e,t,n)=>{const{documents:r,labels:o}=F(),s=Lo(),a=l.useCallback(()=>r.answerStampOf(e),[r,e]),d=l.useSyncExternalStore(r.subscribe,a,a),[m,w]=l.useState(0),c=l.useMemo(()=>({read:n,stamp:d,attempt:m}),[n,d,m]),[f,p]=l.useState({settled:null,shown:null,failure:null}),v=l.useRef(null),x=l.useEffectEvent((j,N)=>{if(v.current?.settle(N.stamp,j.kind==="failure"?j.failure:null),j.kind==="read"){p({settled:N,shown:j.value,failure:null});return}if(f.shown!==null){p({settled:N,shown:f.shown,failure:null});return}p({settled:N,shown:null,failure:j.failure}),s.announceFailure(o.documentFailed(t,te(o,j.failure.reason)))});l.useEffect(()=>{const j=s.readPart();return v.current=j,()=>{v.current=null,j.release()}},[s]),l.useEffect(()=>{const j=new AbortController;return c.read(j.signal).then(N=>{N!==null&&!j.signal.aborted&&x(N,c)}),()=>j.abort()},[c]);const R=f.settled!==c&&(f.shown!==null||f.failure!==null);l.useLayoutEffect(()=>R?s.holdBusy():void 0,[R,s]);const C=l.useCallback(()=>w(j=>j+1),[]);return{shown:f.shown,failure:f.failure,retry:C}},Gn=(e,t)=>{const n={};for(const r of Object.keys(de.SPREADSHEET_BLOCK_LABEL_CATALOGS[t])){const o=e[st(r)];o!==de.SPREADSHEET_BLOCK_LABEL_CATALOGS[t][r].text&&(n[r]=o)}return n},Xs=(e,t)=>Object.fromEntries(Object.entries(Gn(e,t)).map(([n,r])=>[`spreadsheet${n.charAt(0).toUpperCase()}${n.slice(1)}`,r])),Ys=(e,t)=>({...Xs(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,svgImageCopyImage:e.viewerSvgImageCopyImage,svgImageCopiedImage:e.viewerSvgImageCopiedImage,svgImageCopyImageFailed:e.viewerSvgImageCopyImageFailed}),Kn=(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},Wn=(e,t)=>e!==void 0?e:t!==void 0?t:br.DEFAULT_CONTENT_ALIGN,Qs=Object.freeze({className:"aqmx-document-spreadsheet-body","data-aqmx-document-scroller":""}),Js=(e,t)=>{switch(t.code){case"encoding":return e.spreadsheetUnreadableEncoding(t.encodings);case"binary":return e.spreadsheetNotText;case"long-row":return e.spreadsheetLongRow}},ea=({path:e,document:t})=>{const{config:n,data:r,labels:o,locale:s,theme:a}=F(),d=l.use(ae),{name:m,url:w,format:c}=t,f=l.useMemo(()=>({format:c,legacyEncoding:n.legacyTextEncoding,maxBytes:n.spreadsheets.maxBytes,budget:Bs}),[c,n.legacyTextEncoding,n.spreadsheets.maxBytes]),p=l.useCallback(async N=>{const $=await Ws(r,w,f,N);return $===null||$.kind==="failure"?$:{kind:"read",value:$}},[r,w,f]),{shown:v,failure:x,retry:R}=Zn(e,m,p),C=l.useMemo(()=>({...Gn(o,s),table:m,fullscreenDialog:o.spreadsheetFullscreen(m)}),[o,s,m]),j=l.useMemo(()=>v?.kind==="table"?Ye.serializeTsv(v.rows):null,[v]);return i.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-spreadsheet-view","data-aqmx-spreadsheet":v===null?x===null?"loading":"failure":v.kind,children:[i.jsx(Se,{name:m,openUrl:D.explorerPlainTextHref(w),downloadUrl:w,icon:i.jsx(Fs,{})}),i.jsx(xe,{scrollerProps:Qs,children:i.jsxs("div",{className:"aqmx-document-spreadsheet-column",children:[t.firstSheetOnly?i.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-first-sheet",children:o.spreadsheetFirstSheetOnly}):null,v?.kind==="table"&&v.truncated?i.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-truncated",children:o.spreadsheetTruncated}):null,v===null&&x===null?i.jsx(be,{label:o.spreadsheetLoading,testId:"markdown-explorer-spreadsheet-skeleton"}):null,v===null&&x!==null?i.jsx("div",{className:"aqmx-document-spreadsheet-failure",children:i.jsx(fe,{failure:x,alert:!1,onRetry:R,testId:"markdown-explorer-spreadsheet-failure"})}):null,v?.kind==="empty"?i.jsx("div",{className:"aqmx-document-spreadsheet-stage",children:i.jsx("p",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-spreadsheet-empty",children:o.spreadsheetEmpty})}):null,v?.kind==="unreadable"?i.jsx("div",{className:"aqmx-document-spreadsheet-stage",children:i.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-spreadsheet-unreadable","data-aqmx-unreadable":v.code,children:[i.jsx("p",{className:"aqmx-callout-body",children:Js(o,v)}),i.jsx("a",{className:"aqmx-callout-action",href:w,download:m,"data-testid":"markdown-explorer-spreadsheet-unreadable-download",children:o.download})]})}):null,j===null?null:i.jsx("div",{className:"aqmx-document-spreadsheet","data-theme":a,children:i.jsx(ue.SpreadsheetBlock,{tsv:j,layout:d==="fill"?"fill":"inline",locale:s,labels:C})})]})})]})},Xn=Object.freeze({kind:"empty"}),ta=(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 V.explorerHref(e,{...t,overrides:r})},ge=({kind:e,view:t,label:n,stale:r,busy:o,frameRef:s,intent:a,children:d})=>{const m=l.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":m,className:"aqmx-document",...a,children:[r?i.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,d]})},na=({absence:e,announces:t,announceFailure:n})=>{const{labels:r,announcer:o}=F(),s=e.kind==="no-readme"?e.folder:null,a=e.kind==="failure"?e.folder:null,d=e.kind==="failure"?e.failure:null;switch(l.useEffect(()=>{t&&s!==null&&o.announce(r.folderReadmeMissing(D.lastPathSegment(s)))},[t,s,o,r]),l.useEffect(()=>{a!==null&&d!==null&&n(r.documentFailed(D.lastPathSegment(a),te(r,d.reason)))},[a,d,n,r]),e.kind){case"empty":return i.jsx(ge,{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(ht,{label:r.documentRegion});case"no-readme":return i.jsx(ge,{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(ge,{kind:"failure",label:r.documentRegion,stale:!1,busy:!1,children:i.jsx(ut,{failure:e.failure,onRetry:e.onRetry,testId:"markdown-explorer-folder-failure"})})}},ht=({label:e})=>{const{labels:t}=F();return i.jsx(ge,{kind:"loading",label:e,stale:!1,busy:!0,children:i.jsx(be,{label:t.documentLoading,testId:"markdown-explorer-document-skeleton"})})},qt=Object.freeze(["wheel","touchstart","pointerdown","keydown"]),ra=({path:e,document:t,viewer:n,editing:r})=>{const{reportMathDiagnostics:o,edits:s}=F(),a=l.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),d=xs(),m=bs(),w=l.useMemo(()=>o===void 0?void 0:u=>o(e,u),[o,e]),c=l.useRef(null),{editable:f,doubleClick:p,region:v,paneScroll:x,stale:R}=r;l.useLayoutEffect(()=>{if(f)return s.bindView(e,{anchor:()=>{const u=c.current,h=v(),k=u===null?null:u.querySelector(De);return u===null||h===null||k===null?null:yn(u,x.scrollerOf(h,k))}})},[s,e,f,v,x]);const C=u=>{const h=c.current,{target:k}=u;!p||h===null||!(k instanceof Element)||!bn(k)||(u.stopPropagation(),s.start(e,Sn(k,h,h.ownerDocument.getSelection())))},j=l.useRef(null),N=l.useRef(R);l.useLayoutEffect(()=>{N.current=R});const $=l.useEffectEvent(u=>{const h=c.current,k=v(),A=h===null?null:Tn(h,u.line);if(k===null||A===null)return!1;const I=x.scrollerOf(k,A);return I.scrollTop+=Cn(A,u.line)-u.clientTop,!0}),P=l.useEffectEvent(u=>{const h=v();if(h===null)return;const k=()=>{for(const I of qt)h.removeEventListener(I,A,!0);j.current?.release===k&&(j.current=null)},A=()=>k();for(const I of qt)h.addEventListener(I,A,{capture:!0,passive:!0});j.current={point:u,release:k}});return l.useLayoutEffect(()=>{const u=s.takeReturn(e);if(u!==null)return queueMicrotask(()=>{$(u)&&N.current&&P(u)}),()=>j.current?.release()},[s,e]),l.useLayoutEffect(()=>{const u=j.current;u===null||R||(u.release(),$(u.point))},[t,R]),i.jsx("div",{ref:c,className:"aqmx-document-viewer",onDoubleClick:C,children:i.jsx(ue.MarkdownViewer,{...n,onHeadingSelect:d,headingHref:m,onMathDiagnostics:w,parseResult:a,content:null})})},Yn=({document:e,viewer:t})=>{const{labels:n}=F();return i.jsxs(i.Fragment,{children:[i.jsx(Se,{name:e.name,openUrl:D.explorerPlainTextHref(e.url),downloadUrl:e.url,icon:i.jsx(Qr,{}),children:e.truncated?null:i.jsx(Oo,{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(ue.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},Ze=({path:e,name:t,viewer:n})=>{const{data:r,labels:o}=F(),s=l.useCallback(async w=>{const c=await r.text(e,w);return"kind"in c?c.kind==="failure"?{kind:"failure",failure:c.failure}:{kind:"read",value:c}:null},[r,e]),{shown:a,failure:d,retry:m}=Zn(e,t,s);return a!==null?i.jsx(Yn,{document:a,viewer:n}):d!==null?i.jsx(ut,{failure:d,onRetry:m,testId:"markdown-explorer-markup-failure"}):i.jsx(be,{label:o.markupLoading,testId:"markdown-explorer-markup-skeleton"})},oa=Object.freeze({reason:"failed"}),sa=e=>{const{labels:t}=F();return i.jsx(to,{fallback:n=>i.jsx("div",{className:"aqmx-edit-message",children:i.jsx(fe,{failure:oa,alert:!1,onRetry:n,testId:"markdown-explorer-edit-load-failure"})}),children:i.jsx(l.Suspense,{fallback:i.jsx(be,{label:t.editLoading,testId:"markdown-explorer-edit-skeleton"}),children:i.jsx(eo,{...e})})})},aa=({path:e,document:t,view:n,viewer:r,onRetry:o,editing:s})=>{switch(t.kind){case"markdown":{const{session:a,layout:d,region:m,paneScroll:w,stale:c}=s;if(n==="edit"&&a!==void 0)return i.jsx(sa,{path:e,name:t.name,session:a,layout:d,viewer:r,region:m,paneScroll:w});if(n==="markup")return i.jsx(Ze,{path:e,name:t.name,viewer:r});const f=t.edit!==null&&(t.edit.kind==="inline"||t.edit.kind==="draft");return i.jsx(ra,{path:e,document:t,viewer:r,editing:{editable:f,doubleClick:f&&d==="fill",region:m,paneScroll:w,stale:c}})}case"text":return i.jsx(Yn,{document:t,viewer:r});case"image":return n==="markup"&&mt(t)==="svg"?i.jsx(Ze,{path:e,name:t.name,viewer:r}):i.jsx(ls,{document:t});case"media":return i.jsx(Ds,{document:t});case"spreadsheet":return n==="markup"?i.jsx(Ze,{path:e,name:t.name,viewer:r}):i.jsx(ea,{path:e,document:t});case"file":return i.jsx(Io,{document:t});case"failure":return i.jsx(ut,{failure:t.failure,onRetry:o,testId:"markdown-explorer-document-failure"});default:{const a=t;throw new RangeError(`[markdown-explorer] unknown document kind in ${JSON.stringify(a)}`)}}},ia='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',la=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:_n(e,n),r===void 0?null:Dn(e,r.id),e.querySelector(De),e.querySelector(ia)];for(const s of o)if(s instanceof HTMLElement&&dt(s))return s;return null},$t=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&dt(t)},ca=e=>{const t=l.useRef(!1);return l.useLayoutEffect(()=>{const n=e.current;if(n===null)throw new Error("[markdown-explorer] the document region is not mounted");const r=n.ownerDocument,o=r.defaultView;if(o===null)throw new Error("[markdown-explorer] the document region's document has no window");let s=!1,a;const d=p=>{s=!(p.target instanceof Node&&n.contains(p.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(a),a=setTimeout(()=>{s=!1},0)},m=p=>{t.current=p.target instanceof Node&&n.contains(p.target)},w=p=>{p.relatedTarget===null&&s&&(t.current=!1)},c=()=>{const{activeElement:p,body:v}=r;p!==null&&p!==v&&(t.current=n.contains(p))},f=()=>{s&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",d,!0),o.addEventListener("mousedown",d,!0),o.addEventListener("focusin",m,!0),o.addEventListener("blur",c),o.addEventListener("focus",f),n.addEventListener("focusout",w),()=>{clearTimeout(a),o.removeEventListener("pointerdown",d,!0),o.removeEventListener("mousedown",d,!0),o.removeEventListener("focusin",m,!0),o.removeEventListener("blur",c),o.removeEventListener("focus",f),n.removeEventListener("focusout",w)}},[e]),t},da=Object.freeze({count:0,recovered:!1}),ua=({path:e,snapshot:t,markup:n,stale:r,viewer:o,editLayout:s,regionLabel:a,navigation:d,fragment:m,paneScroll:w,announces:c,announceFailure:f,onDocumentShown:p})=>{const{labels:v,announcer:x,documents:R}=F(),{document:C}=t,j=l.useRef(null),N=l.useRef(null),$=l.useRef(null),P=l.useRef(0),u=ca(j),h=l.useRef({path:e,document:C}),k=l.useRef(null),A=l.useCallback(U=>{const z=j.current,X=Mt(z,U,w);z!==null&&X!==null&&$t(z,X,u.current)},[w,u]),I=l.useCallback((U,z)=>{const X=P.current;setTimeout(()=>{!z.defaultPrevented&&P.current===X&&A(U)},0)},[A]),q=l.useCallback(U=>{setTimeout(()=>{U.defaultPrevented||A("#")},0)},[A]),E=l.useMemo(()=>({navigation:d,currentPath:e,scrollWithin:A,followSameUrlJump:I,followEmptyFragment:q}),[d,e,A,I,q]),T=l.useCallback(()=>R.retry(e),[R,e]),M=Ln(R,ms),O=wn(e),_=O!==void 0?"edit":n?"markup":"rendered",B=mt(C)===null?void 0:_,K=l.useCallback(()=>j.current,[]),g=l.useMemo(()=>({session:O,layout:s,region:K,paneScroll:w,stale:r}),[O,s,K,w,r]),b=B==="edit"?!1:r,y=l.use(ae),L=B==="edit"&&s==="fill"?"fill":y,[H,Z]=l.useState(0),W=l.useRef(0),G=l.useRef(!1),[ee,pt]=l.useState(da),[wt,fr]=l.useState(0),vt=l.useRef(f),Et=l.useRef(r);l.useLayoutEffect(()=>{vt.current=f,Et.current=r},[f,r]);const mr=l.useMemo(()=>({announceFailure:U=>{Et.current||vt.current(U)},readPart:()=>{const U=R.readPart(e);W.current+=1;let z=!1,X=!1,Y=!1;return{settle:(ie,le)=>{if(U.settle(ie,le),!(Y||z)){if(le!==null){X=!0,G.current=!1;return}z=!0,pt(ye=>({count:ye.count+1,recovered:X}))}},release:()=>{Y||(Y=!0,U.release(),W.current-=1,z||fr(ie=>ie+1))}}},holdBusy:()=>{Z(z=>z+1);let U=!0;return()=>{U&&(U=!1,Z(z=>z-1))}}}),[R,e]),xt=b||H>0,hr=l.useEffectEvent((U,z)=>{const X=N.current;if(X!==null&&X.path===U&&X.snapshot===z)return;N.current={path:U,snapshot:z},R.noteShown(U,z);const Y=z.document;if(Y.kind==="failure"){G.current=!1,R.noteFailureShown(z)&&f(v.documentFailed(D.lastPathSegment(U),te(v,Y.failure.reason)));return}p?.(U,Y),!(!c||X!==null&&X.path===U&&X.snapshot.document.kind!=="failure")&&(G.current=W.current>0,G.current||x.announce(v.documentShown(Y.name)))});l.useEffect(()=>{hr(e,t)},[e,t]);const gr=l.useEffectEvent(()=>{m.kind==="panel"&&m.consume()}),bt=l.useEffectEvent(U=>{const z=j.current;if(z===null||!u.current)return null;const{activeElement:X,body:Y}=z.ownerDocument;return X!==null&&X!==Y?null:la(z,C,U)}),pr=l.useEffectEvent(U=>{const z=G.current;G.current=!1,!r&&(U&&bt(null),c&&(U||z)&&C.kind!=="failure"&&x.announce(v.documentShown(C.name)))});l.useEffect(()=>{ee.count>0&&pr(ee.recovered)},[ee]);const wr=l.useEffectEvent(()=>{W.current>0||!G.current||(G.current=!1,c&&!r&&C.kind!=="failure"&&x.announce(v.documentShown(C.name)))});l.useEffect(()=>{wt>0&&wr()},[wt]);const vr=l.useEffectEvent(U=>{const z=j.current;z!==null&&$t(z,U,u.current)}),Er=l.useEffectEvent(U=>w.reveal(U)),xr=l.useEffectEvent(U=>Mt(j.current,U,w));return l.useEffect(()=>{if(r)return;const U=h.current.path!==e,z=U||h.current.document!==C;h.current={path:e,document:C};const X=k.current!==e;k.current=e;let Y=null;m.kind==="page"?$.current!==m.navigation&&($.current=m.navigation,P.current+=1,Y=m.fragment):m.fragment!==null&&(Y=m.fragment,gr());const ie=()=>{const le=Y===null?null:xr(Y);if(!z){le!==null&&vr(le);return}const ye=bt(m.fragment);U&&le===null&&ye!==null&&Er(ye)};X?queueMicrotask(ie):ie()},[m,e,C,r]),i.jsx(ae,{value:L,children:i.jsx(ge,{kind:C.kind,view:B,label:a(e,C),stale:xt,busy:xt,frameRef:j,intent:M,children:i.jsx(qn,{value:E,children:i.jsx(us,{children:i.jsx(Nn,{value:mr,children:i.jsx(aa,{path:e,document:C,view:_,viewer:o,onRetry:T,editing:g},e)})})})})})},gt=Object.freeze({kind:"skeleton"}),fa=(e,t,n,r,o)=>{if(t?.status==="loaded")return{kind:"document",path:e,snapshot:t,stale:!1};const s=oe(t);if(s!==null)return{kind:"document",path:e,snapshot:s,stale:!0};if(o&&t?.status==="pending")return{kind:"streaming",path:e,promise:t.promise};const a=n===null||n===e?null:oe(r);return n===null||a===null?gt:{kind:"document",path:n,snapshot:a,stale:!0}},ma=(e,t)=>t.status==="deferred"?gt:{kind:"document",path:e,snapshot:t,stale:!1},ha=({requestedPath:e,content:t,markup:n,...r})=>{const o=t.kind==="streaming"?ma(t.path,l.use(t.promise)):t;return o.kind!=="document"?i.jsx(ht,{label:r.regionLabel(e,null)}):i.jsx(ua,{path:o.path,snapshot:o.snapshot,markup:n,stale:o.stale,...r})},Qn=({path:e,absence:t,markup:n,display:r,navigation:o,fragment:s,paneScroll:a,announces:d,announceFailure:m,onDocumentShown:w})=>{const{config:c,labels:f,locale:p,theme:v,documents:x,data:R}=F(),C=ue.useMarkdownToolbarState(),j=l.useRef(!1);l.useLayoutEffect(()=>{j.current=!0},[]);const[N,$]=l.useState(null),[P,u]=l.useState(n),h=l.useCallback(()=>e===null?void 0:x.peek(e),[x,e]),k=l.useSyncExternalStore(x.subscribe,h,h),A=l.useCallback(()=>N===null?void 0:x.peek(N),[x,N]),I=l.useSyncExternalStore(x.subscribe,A,A);l.useLayoutEffect(()=>e===null?void 0:x.open(e),[x,e]),l.useLayoutEffect(()=>N===null?void 0:x.retain(N),[x,N]);const q=e===null?gt:fa(e,k,N,I,!j.current),E=e===null?null:q.kind==="document"&&!q.stale?q.path:N;E!==N&&$(E);const T=q.kind!=="document"||q.path===e;T&&n!==P&&u(n);const M=l.useMemo(()=>Ys(f,p),[f,p]),O=l.useMemo(()=>({read:(y,L)=>cs(R,y,L)}),[R]),_=l.useMemo(()=>[...c.iframeHosts],[c]),B=o.kind==="panel",K=l.useMemo(()=>({labels:M,spreadsheetLocale:p,emptyMessage:f.documentEmpty,theme:v,availableStyles:c.documentStyles,iFrameAllowedDomains:_,embeds:c.embeds,linkComponent:Es,toolbar:C,style:r.style,onStyleChange:r.onStyleChange,align:r.align,onAlignChange:r.onAlignChange,showToc:r.showToc,showStyle:r.showStyle,showAlign:r.showAlign,padding:r.padding,width:r.width===void 0?void 0:`min(${r.width}, 100%)`,maxWidth:r.maxWidth===void 0?void 0:`min(${r.maxWidth}, 100%)`,renderScrollBar:B?void 0:Mn,imageSource:O}),[M,p,f.documentEmpty,v,c.documentStyles,_,c.embeds,C,r,B,O]),g=l.useCallback((y,L)=>B?L===null||L.kind==="failure"?D.lastPathSegment(y):L.name:f.documentRegion,[B,f.documentRegion]),b=B?"content":"fill";return e===null?i.jsx(ae,{value:b,children:i.jsx(na,{absence:t,announces:d,announceFailure:m})}):i.jsx(ae,{value:b,children:i.jsx(l.Suspense,{fallback:i.jsx(ht,{label:g(e,null)}),children:i.jsx(ha,{requestedPath:e,content:q,markup:T?n:P,viewer:K,editLayout:r.editLayout,regionLabel:g,navigation:o,fragment:s,paneScroll:a,announces:d,announceFailure:m,onDocumentShown:w})})})},ga=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:a,announcer:d}=F(),m=pe(I=>I.style),w=pe(I=>I.align),c=Ee(),f=J.useLocation(),p=Pe(),{view:v,overrides:x,embed:R}=r,C=l.useCallback(I=>{if(p.kind!=="location")return;const q=ta(s,p.location,I);q!==null&&c(q,"browse")},[s,c,p]),j=l.useCallback(I=>{a.update({style:I}),C("style")},[a,C]),N=l.useCallback(I=>{a.update({align:I}),C("align")},[a,C]),$=Kn(s,x.style,m),P=Wn(x.align,w),u=l.useMemo(()=>({style:$,onStyleChange:j,align:P,onAlignChange:N,showToc:R.showToc!==!1,showStyle:R.showStyle!==!1,showAlign:R.showAlign!==!1,padding:R.padding,width:R.width,maxWidth:R.maxWidth,editLayout:"fill"}),[$,j,P,N,R]),h=l.useMemo(()=>({kind:"page",view:v,overrides:x,embed:R}),[v,x,R]),k=l.useMemo(()=>({kind:"page",fragment:f.hash,navigation:f}),[f]),A=l.useCallback(I=>d.announce(I),[d]);return i.jsx(Qn,{path:e,absence:t,markup:n,display:u,navigation:h,fragment:k,paneScroll:Vo,announces:!0,announceFailure:A,onDocumentShown:o})},pa=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:a}=F(),d=pe(h=>h.style),m=pe(h=>h.align),[w,c]=l.useState(()=>Kn(s,void 0,d)),f=Wn(void 0,m),p=l.useCallback(h=>a.update({align:h}),[a]),{maximized:v,onDocumentLink:x,pendingHash:R,onHashConsumed:C,announceFailure:j,paneScroll:N}=r,$=l.useMemo(()=>({style:w,onStyleChange:c,align:f,onAlignChange:p,showToc:v,showStyle:v,showAlign:v,padding:void 0,width:void 0,maxWidth:void 0,editLayout:v?"fill":"content"}),[w,f,p,v]),P=l.useMemo(()=>({kind:"panel",onDocumentLink:x}),[x]),u=l.useMemo(()=>({kind:"panel",fragment:R,consume:C}),[R,C]);return i.jsx(Qn,{path:e,absence:t,markup:n,display:$,navigation:P,fragment:u,paneScroll:N,announces:!1,announceFailure:j,onDocumentShown:o})},Jn=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>r.kind==="page"?i.jsx(ga,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o}):i.jsx(pa,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o});function wa({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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 er=S.forwardRef(wa);function va({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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 tr=S.forwardRef(va);function Ea({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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 xa=S.forwardRef(Ea);function ba({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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"}),S.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 Sa=S.forwardRef(ba);function ya({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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 ka=S.forwardRef(ya);function Ra({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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"}),S.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 Ta=S.forwardRef(Ra);function Ca({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),S.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 nr=S.forwardRef(Ca);function Oa({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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"}),S.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 La=S.forwardRef(Oa);function Aa({title:e,titleId:t,...n},r){return S.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?S.createElement("title",{id:t},e):null,S.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 Ma=S.forwardRef(Aa),rr=({href:e,onRetry:t,testId:n})=>{const{labels:r,onEditGrant:o}=F(),[s,a]=l.useState(!1),d=()=>{o===void 0||s||(a(!0),o(e).then(m=>{m&&t()}).finally(()=>a(!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:d,children:r.editGrantAction}),i.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":`${n}-retry`,onClick:t,children:r.editGrantRetry})]})]})},ja="Control+E Meta+E",or=(e,t,n)=>n&&t?"split":e.view,rt=(e,t,n,r)=>{if(n==="split"){e.setSideBySide(!0);return}e.setView(t,n),r&&e.sideBySide()&&e.setSideBySide(!1)},Na=e=>e==="split"?null:e,sr=e=>e==="preview"?"editor":"preview",ar=e=>/Mac|iPhone|iPad|iPod/u.test(e),ir=(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)},Bt=(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)},Pa=({path:e,documentName:t,open:n,onClose:r})=>{const{data:o,edits:s,labels:a,locale:d,announcer:m}=F(),w=l.useId(),[c,f]=l.useState(null),[p,v]=l.useState(0),[x,R]=l.useState(null),[C,j]=l.useState(null),N=l.useMemo(()=>new Intl.DateTimeFormat(d,{dateStyle:"medium",timeStyle:"short"}),[d]),$=l.useCallback(()=>{R(null),j(null)},[]),P=fn({open:n,onOpen:$,onDismiss:r});l.useEffect(()=>{if(!n)return;const k=new AbortController;return f(null),o.revisions(e,k.signal).then(A=>{"kind"in A&&f(A)}),()=>k.abort()},[n,o,e,p]),l.useEffect(()=>{if(!n||x===null)return;const k=new AbortController;return j(null),o.revision(e,x,k.signal).then(A=>{"kind"in A&&j(A)}),()=>k.abort()},[n,o,e,x]);const u=()=>{C===null||C.kind!=="revision"||(s.replaceDraft(e,C.text),m.announce(a.historyRestored(t)),r())},h=c!==null&&c.kind==="revisions"?c.revisions.find(k=>k.id===x):void 0;return i.jsx("dialog",{...P,className:"aqmx-confirm aqmx-history","aria-labelledby":w,"data-testid":"markdown-explorer-history",children:i.jsxs("div",{className:"aqmx-confirm-panel aqmx-history-panel",children:[i.jsx("p",{id:w,className:"aqmx-confirm-title",children:a.historyTitle(t)}),c===null?i.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-loading",children:a.historyLoading}):c.kind==="failure"?i.jsx(fe,{failure:c.failure,alert:!1,onRetry:()=>v(k=>k+1),testId:"markdown-explorer-history-failure"}):c.revisions.length===0?i.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-empty",children:a.historyEmpty}):i.jsx("ul",{className:"aqmx-history-list","data-testid":"markdown-explorer-history-list",children:c.revisions.map(k=>i.jsx("li",{children:i.jsxs("button",{type:"button",className:"aqmx-history-entry","aria-pressed":k.id===x,"data-testid":"markdown-explorer-history-entry",onClick:()=>R(k.id),children:[i.jsx("span",{children:Bt(k,N,a.historyEntry)}),k.current?i.jsx("span",{className:"aqmx-history-mark",children:a.historyCurrent}):null,k.kept?i.jsx("span",{className:"aqmx-history-mark",children:a.historyKept}):null]})},k.id))}),x===null?null:C===null?i.jsx("p",{className:"aqmx-history-note",children:a.historyLoading}):C.kind==="failure"?i.jsx(fe,{failure:C.failure,alert:!1,testId:"markdown-explorer-history-revision-failure"}):i.jsx("section",{className:"aqmx-history-text",tabIndex:0,"aria-label":h===void 0?a.historyTitle(t):Bt(h,N,a.historyEntry),"data-testid":"markdown-explorer-history-text",children:i.jsx("pre",{children:C.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:a.historyClose}),i.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":C===null||C.kind!=="revision","data-testid":"markdown-explorer-history-restore",onClick:u,children:a.historyRestore})]})]})})},Da=e=>{const{documents:t}=F(),n=l.useCallback(()=>t.peek(e),[t,e]),r=l.useCallback(()=>t.peekSeeded(e),[t,e]),o=l.useSyncExternalStore(t.subscribe,n,r),s=oe(o)?.document;return s===void 0||s.kind==="failure"?{edit:null,name:D.lastPathSegment(e)}:{edit:s.kind==="markdown"||s.kind==="spreadsheet"?s.edit:null,name:s.name}},re=e=>{e.stopPropagation()},_a=({path:e,documentName:t,iconOnly:n,previewAvailable:r,draft:o})=>{const{draftConverter:s,edits:a,labels:d}=F(),m=l.useSyncExternalStore(a.subscribe,()=>a.session(e)!==void 0,()=>!1),[w,c]=l.useState(null),f=()=>{if(!m){a.start(e,a.viewAnchor(e));return}a.flush(e);const R=a.session(e);R?.dirty===!0?c(R.save.kind==="draft"?"draft":"unsaved"):a.close(e)},p=()=>{m||(Jr(),r&&a.sideBySide()&&s?.prepare?.())},v=n?o?d.editDraftDocumentNamed(t):d.editDocumentNamed(t):null,x=o?d.editDraftDocument:d.editDocument;return i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:v===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:m?d.closeEditor:v===null?x:v,"aria-label":v===null?void 0:v,"aria-pressed":m,"data-testid":"markdown-explorer-document-edit",onClick:f,onDoubleClick:re,onPointerEnter:p,onFocus:p,children:[i.jsx(La,{"aria-hidden":"true"}),v===null?i.jsx("span",{children:d.editDocumentLabel}):null]}),i.jsx(mn,{open:w!==null,title:w==="draft"?d.draftDiscardTitle:d.unsavedTitle,body:w==="draft"?d.draftDiscardBody(t):d.unsavedBody(t),confirmLabel:d.unsavedDiscard,cancelLabel:d.unsavedStay,testId:"markdown-explorer-edit-close-confirm",onConfirm:()=>{c(null),a.close(e)},onCancel:()=>c(null)})]})},Ia=({href:e,documentName:t,iconOnly:n})=>{const{labels:r}=F(),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:re,children:[i.jsx(xa,{"aria-hidden":"true"}),o===null?i.jsx("span",{children:r.editExternallyLabel}):null]})},Fa=({session:e})=>{const{labels:t}=F(),n=Ar(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})},qa=Object.freeze(["editor","split","preview"]),$a=Object.freeze(["editor","preview"]),Ba=Object.freeze({editor:tr,split:Ma,preview:nr}),Ha=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{draftConverter:s,edits:a,labels:d}=F(),m=En(),w=or(r,m,o),c=o?qa:$a,f=l.useId(),p=l.useRef(new Map),v={editor:{label:d.editViewEditor,tooltip:d.editViewEditorTooltip},split:{label:d.editViewSplit,tooltip:d.editViewSplitTooltip},preview:{label:d.editViewPreview,tooltip:d.editViewPreviewTooltip}},x=()=>{a.preparePreview(e),s?.prepare?.()},R=C=>{if(!ir(C.nativeEvent,ar(navigator.platform)))return;it(C);const j=sr(w);rt(a,e,j,o),p.current.get(j)?.focus()};return i.jsx("div",{role:"radiogroup","aria-label":n?d.editViewNamed(t):d.editView,className:"aqmx-edit-view","data-testid":"markdown-explorer-edit-view",onKeyDown:R,children:c.map(C=>{const j=Ba[C],{label:N,tooltip:$}=v[C],P=C==="preview"?x:void 0;return i.jsxs("label",{className:n?"aqmx-icon-button":"aqmx-icon-button aqmx-labelled-button",children:[i.jsx("input",{ref:u=>{u===null?p.current.delete(C):p.current.set(C,u)},type:"radio",name:f,value:C,checked:C===w,"aria-label":N,"aria-keyshortcuts":C==="split"?void 0:ja,title:$,"data-testid":`markdown-explorer-edit-view-${C}`,onChange:()=>rt(a,e,C,o),onDoubleClick:re,onPointerEnter:P,onFocus:P}),i.jsx(j,{"aria-hidden":"true"}),n?null:i.jsx("span",{children:N})]},C)})})},Ua=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{edits:s,labels:a}=F(),[d,m]=l.useState(!1);if(r.phase.kind!=="editing")return null;const w=r.save.kind==="saving",c=w||!r.dirty,f=()=>{s.flush(e);const v=s.session(e);v===void 0||!v.dirty||v.save.kind==="saving"||s.save(e)},p=v=>n?{className:"aqmx-icon-button","aria-label":v}:{className:"aqmx-icon-button aqmx-labelled-button"};return i.jsxs(i.Fragment,{children:[r.save.kind==="conflicts"?i.jsxs("button",{type:"button",...p(a.conflictNext),title:a.conflictNext,"data-testid":"markdown-explorer-edit-next-conflict",onClick:()=>s.nextConflict(e),onDoubleClick:re,children:[i.jsx(Sa,{"aria-hidden":"true"}),n?null:i.jsx("span",{children:a.conflictNext})]}):null,i.jsx(Ha,{path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o}),r.history?i.jsxs("button",{type:"button",...p(a.historyOpen),title:a.historyOpen,"aria-haspopup":"dialog","data-testid":"markdown-explorer-edit-history",onClick:()=>m(!0),onDoubleClick:re,children:[i.jsx(ka,{"aria-hidden":"true"}),n?null:i.jsx("span",{children:a.historyOpen})]}):null,r.save.kind==="draft"?null:i.jsxs("button",{type:"button",...p(a.saveDraft),title:a.saveDraftTooltip,"aria-disabled":c,"aria-busy":w,"aria-keyshortcuts":"Control+S Meta+S","data-testid":"markdown-explorer-edit-save",onClick:f,onDoubleClick:re,children:[i.jsx(Ta,{"aria-hidden":"true"}),n?null:i.jsx("span",{children:a.saveDraft})]}),r.history?i.jsx(Pa,{path:e,documentName:t,open:d,onClose:()=>m(!1)}):null]})},Va=({path:e,session:t})=>{const{edits:n}=F();return t.save.kind!=="grant"?null:i.jsx(rr,{href:t.save.href,onRetry:()=>{n.save(e)},testId:"markdown-explorer-save-grant"})},za=new Set,Za=(e,t,n)=>{const{documents:r,announcer:o,labels:s}=F(),a=l.useCallback(()=>r.peek(e),[r,e]),d=l.useCallback(()=>r.peekSeeded(e),[r,e]),m=l.useSyncExternalStore(r.subscribe,a,d),w=l.useCallback(()=>r.answerStampOf(e),[r,e]),c=l.useSyncExternalStore(r.subscribe,w,w),[f]=l.useState(()=>new Set),[p,v]=l.useState(za),[x,R]=l.useState(null);x!==null&&(x.path!==e||x.markup!==n)&&R(null);const C=l.useRef(null);l.useLayoutEffect(()=>(C.current=e,()=>{C.current=null}),[e]);const j=l.useRef(n);l.useLayoutEffect(()=>{j.current=n},[n]);const N=l.useCallback(()=>{const u=e,h=r.peek(u);f.has(u)||h?.status==="pending"||(f.add(u),v(new Set(f)),R(null),(async()=>{try{const k=await r.refresh(u);if(C.current!==u||k.status==="superseded")return;if(k.status==="failed"){R({path:u,failure:k.failure,stamp:r.answerStampOf(u),markup:j.current}),o.announce(s.documentRefreshFailed(te(s,k.failure.reason)));return}if(k.status==="shown"&&(t||k.failed))return;const A=oe(r.peek(u));if(A===null||A.document.kind==="failure")return;o.announce(s.documentRefreshed(A.document.name))}finally{f.delete(u),v(new Set(f))}})())},[e,t,f,r,o,s]),$=p.has(e),P=x!==null&&x.path===e&&x.stamp===c&&x.markup===n?x.failure:null;return{refreshing:$,unavailable:$||m?.status==="pending",failure:P,refresh:N}},Ga=(e,t)=>{switch(t){case"markdown":return e.showMarkup;case"svg":return e.showSvgMarkup;case"csv":case"tsv":return e.showSpreadsheetMarkup(t.toUpperCase())}},lr=Object.freeze({kind:"page"}),cr=({path:e,placement:t,markup:n})=>{const{labels:r}=F(),{refreshing:o,unavailable:s,failure:a,refresh:d}=Za(e,t.kind==="page",n.shown),m=_s(e),w=Da(e),c=wn(e),f=t.kind==="panel"?r.refreshDocumentNamed(t.documentName):null,p=t.kind==="panel"?r.showMarkupNamed(t.documentName):null,v=t.kind==="panel",x=t.kind==="panel"?t.documentName:w.name,R=t.kind==="page"||t.maximized;return i.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar","data-aqmx-editing":c===void 0?void 0:"true",children:[i.jsxs("div",{className:"aqmx-document-refresh-row",children:[c===void 0?null:i.jsx(Fa,{session:c}),c===void 0?null:i.jsx(Ua,{path:e,documentName:x,iconOnly:v,session:c,previewAvailable:R}),c===void 0&&m!==null?i.jsxs("button",{type:"button",className:p===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:p===null?Ga(r,m):p,"aria-label":p===null?void 0:p,"aria-pressed":n.shown,"data-testid":"markdown-explorer-document-markup",onClick:n.toggle,onDoubleClick:re,children:[i.jsx(tr,{"aria-hidden":"true"}),p===null?i.jsx("span",{children:r.showMarkupLabel}):null]}):null,c!==void 0||w.edit?.kind==="inline"||w.edit?.kind==="draft"?i.jsx(_a,{path:e,documentName:x,iconOnly:v,previewAvailable:R,draft:w.edit?.kind==="draft"}):w.edit?.kind==="external"?i.jsx(Ia,{href:w.edit.href,documentName:x,iconOnly:v}):null,c===void 0?i.jsxs("button",{type:"button",className:f===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:f===null?r.refreshDocument:f,"aria-label":f===null?void 0:f,"aria-disabled":s,"aria-busy":o,"data-aqmx-busy":o?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:d,onDoubleClick:re,children:[i.jsx(er,{"aria-hidden":"true"}),f===null?i.jsx("span",{children:r.refreshDocumentLabel}):null]}):null]}),c!==void 0||a===null?null:i.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":a.reason,children:r.documentRefreshFailed(te(r,a.reason))}),c===void 0?null:i.jsx(Va,{path:e,session:c})]})},Ka=({location:e})=>{const t=e.doc,n=l.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),r=Bn(e);return i.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",...Ae,children:[i.jsx(cr,{path:t,placement:lr,markup:r}),i.jsx(Jn,{path:t,absence:Xn,markup:e.markup,variant:n})]})},dr=({holds:e,testId:t})=>{const{labels:n,announcer:r}=F(),o=l.useId();l.useLayoutEffect(()=>e?r.claim(o):void 0,[e,r,o]);const s=l.useCallback(()=>r.shownIn(o),[r,o]),a=l.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:a.length>1?n.announcementSequence(a):a[0]})},ce=Object.freeze([]),Wa=e=>{const t=new Set;let n=ce,r=[],o=!1;const s=[],a=c=>{n=c;for(const f of[...t])f()},d=()=>s.at(-1)?.region,m=c=>{const f=d();c(),d()!==f&&n!==ce&&a(ce)},w=()=>{o=!1;const c=r.map(f=>"sentence"in f?f.sentence:f.list(f.items));r=[],a(Object.freeze(c))};return{announce:c=>{if(typeof c=="string")r.push({sentence:c});else{const f=r.find(p=>"list"in p&&p.list===c.list);f!==void 0&&"items"in f?f.items.push(c.item):r.push({list:c.list,items:[c.item]})}o||(o=!0,n!==ce&&a(ce),e.request(w))},subscribe:c=>(t.add(c),()=>{t.delete(c)}),claim:c=>{const f={region:c};return m(()=>s.push(f)),()=>m(()=>{const p=s.indexOf(f);p!==-1&&s.splice(p,1)})},shownIn:c=>d()===c?n:ce}},ne=Object.freeze({status:"cancelled"}),Ht=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)},Xa=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((c,f)=>globalThis.fetch(c,f)),o=(c,f)=>`${e}/${c}?${new URLSearchParams(f).toString()}`,s=c=>{c.status===401&&t(null);const f=c.headers.get(D.EXPLORER_SCOPE_HEADER);f!==null&&t(f)},a=async(c,f,p,v)=>{let x;try{x=await r(c,{credentials:"same-origin",...f,headers:{Accept:"application/json",...f.headers}})}catch{return v({reason:"failed"})}s(x);let R;try{R=await x.json()}catch{return v({reason:D.failureReasonOfStatus(x.status)})}let C;try{C=p(R)}catch{C=!1}if(C)return R;const j=Ht(R);return v(j!==null?j:{reason:x.status===200?"failed":D.failureReasonOfStatus(x.status)})},d={[D.EXPLORER_PROOF_HEADER]:D.EXPLORER_REFRESH_PROOF},m={[D.EXPLORER_PROOF_HEADER]:D.EXPLORER_EDIT_PROOF,"Content-Type":`${D.EXPLORER_DRAFT_MEDIA_TYPE}; charset=utf-8`},w=async(c,f,p)=>{const v=await a(c,f,p,x=>D.failureDocument(x.reason,x.code));return f.signal.aborted?ne:v};return{tree:c=>a(o("tree",{[D.EXPLORER_DATA_QUERY.source]:c}),{method:"GET"},D.isExplorerTreeResult,f=>({status:"error",failure:f})),children:async(c,f,p)=>{const v=await a(o("children",{[D.EXPLORER_DATA_QUERY.source]:c,[D.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:p},D.isExplorerChildrenResult,x=>({status:"error",failure:x}));return p.aborted?ne:v},ancestors:async(c,f,p)=>{const v=await a(o("ancestors",{[D.EXPLORER_DATA_QUERY.source]:c,[D.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:p},D.isExplorerAncestorsResult,x=>({status:"error",failure:x}));return p.aborted?ne:v},reveal:async(c,f,p)=>{const v=await a(o("reveal",{[D.EXPLORER_DATA_QUERY.source]:c,[D.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:p},D.isExplorerRevealResult,x=>({status:"error",failure:x}));return p.aborted?ne:v},document:(c,{refresh:f})=>a(o("document",{[D.EXPLORER_DATA_QUERY.path]:c}),f?{method:"GET",headers:d}:{method:"GET"},D.isExplorerDocument,p=>D.failureDocument(p.reason,p.code)),text:async(c,f)=>{const p=await a(o("text",{[D.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:f},D.isExplorerTextAnswer,v=>D.failureDocument(v.reason,v.code));return f.aborted?ne:p},asset:async(c,f)=>{let p;try{p=await r(c,{method:"GET",credentials:"same-origin",signal:f})}catch{return f.aborted?ne:{status:"error",failure:{reason:"failed"}}}if(s(p),p.ok)return f.aborted?ne:{status:"ok",body:p.body===null?new ReadableStream({start:R=>R.close()}):p.body};let v=null;try{v=await p.json()}catch{}if(f.aborted)return ne;const x=Ht(v);return{status:"error",failure:x===null?{reason:D.failureReasonOfStatus(p.status)}:x}},edit:(c,f)=>w(o("edit",{[D.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:f},D.isExplorerEditAnswer),save:(c,f,p,v)=>w(o("save",{[D.EXPLORER_DATA_QUERY.path]:c,[D.EXPLORER_DATA_QUERY.base]:f}),{method:"POST",headers:m,body:p,signal:v},D.isExplorerSaveAnswer),preview:(c,f,p)=>w(o("preview",{[D.EXPLORER_DATA_QUERY.path]:c}),{method:"POST",headers:m,body:f,signal:p},D.isExplorerPreviewAnswer),revisions:(c,f)=>w(o("revisions",{[D.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:f},D.isExplorerRevisionsAnswer),revision:(c,f,p)=>w(o("revision",{[D.EXPLORER_DATA_QUERY.path]:c,[D.EXPLORER_DATA_QUERY.revision]:f}),{method:"GET",signal:p},D.isExplorerRevisionAnswer),refresh:c=>a(o("refresh",{[D.EXPLORER_DATA_QUERY.source]:c}),{method:"POST",headers:d},D.isExplorerTreeResult,f=>({status:"error",failure:f}))}},Ya=()=>{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}}},Qa=e=>{const t=Q.readStorage(e);if(t===null)return V.NO_TREE_SETTING_CHANGES;try{return V.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),V.NO_TREE_SETTING_CHANGES}},Ut=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=Qa(e);n={changes:s,settings:V.applyTreeSettingChanges(t,s)}}return n},o=me();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:a,settings:d}=r(),m=V.recordTreeSettingChange(a,s,V.advanceTreeSetting(d,s)[s],t);return n={changes:m,settings:V.applyTreeSettingChanges(t,m)},o.emit(),Q.writeStorage(e,V.serializeTreeSettingChanges(m)),n.settings}}},Ja=Object.freeze({status:"refreshed"}),ei=Object.freeze({status:"superseded"}),ot=Object.freeze({status:"deferred"}),ti=hn(ot),ur=4,ni=ur-1,Vt=Object.freeze({status:"loading"}),ri=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),oi=e=>{const t=new Map,n=jn(),r=new Map,o=new Map,s=new Map,a=new Map,d=me(),m=new Set;let w=0,c=0;const f={direct:null,bulk:null},p=new Set;let v=!1,x=0;const R=()=>{x+=1,d.emit()},C=g=>o.get(g)??0,j=g=>{let b=a.get(g);return b===void 0&&(b={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},a.set(g,b)),b},N=(g,b,y)=>{g.inFlight.delete(b),w-=1,y.lane==="bulk"&&(c-=1)},$=g=>{const b=a.get(g);if(b!==void 0){for(const[y,L]of[...b.inFlight])N(b,y,L),L.controller.abort();b.direct.clear(),b.bulk.clear(),b.unclaimed.clear()}},P=g=>{const b=C(g)+1;return o.set(g,b),$(g),b},u=(g,b)=>{const y=he(g),L={promise:g,opened:b,stale:!1,loadedAt:y?.status==="ok"?y.loadedAt:null};return g.status==="pending"&&g.then(H=>{H.status==="ok"&&(L.loadedAt=H.loadedAt)}),L},h=g=>{let b=r.get(g);return b===void 0&&(b=new Map,r.set(g,b)),b},k=g=>{const b=[...a.keys()],y=f[g],L=y===null?0:b.indexOf(y)+1;for(let H=0;H<b.length;H+=1){const Z=b[(L+H)%b.length],W=Z===void 0?void 0:a.get(Z);if(!(Z===void 0||W===void 0)){for(const G of W[g])if((W.claims.get(G)??0)!==0)return W[g].delete(G),f[g]=Z,{sourceId:Z,path:G}}}return null},A=(g,b,y,L)=>{const H=a.get(g);if(H===void 0||H.inFlight.get(b)!==y)return;N(H,b,y);const Z=(H.claims.get(b)??0)>0,W=h(g);if(L.status==="ok"?W.set(b,{status:"loaded",entries:L.entries}):L.status==="error"&&Z?W.set(b,{status:"failed",failure:L.failure}):W.delete(b),R(),L.status==="error"&&Z){const G={sourceId:g,path:b,failure:L.failure};for(const ee of[...m])ee(G)}q()},I=(g,b,y)=>{const L={controller:new AbortController,lane:y};j(g).inFlight.set(b,L),w+=1,y==="bulk"&&(c+=1),e.children(g,b,L.controller.signal).then(H=>A(g,b,L,H),()=>A(g,b,L,ri))},q=()=>{for(;w<ur;){const g=k("direct");if(g!==null){I(g.sourceId,g.path,"direct");continue}const b=c<ni?k("bulk"):null;if(b===null)return;I(b.sourceId,b.path,"bulk")}},E=(g,b,y)=>{if(!(b.direct.delete(y)||b.bulk.delete(y))){const H=b.inFlight.get(y);if(H===void 0)return!1;N(b,y,H),H.controller.abort()}return r.get(g)?.delete(y),!0},T=()=>{v=!1;let g=!1;for(const b of p){const y=j(b);for(const L of y.unclaimed)(y.claims.get(L)??0)===0&&E(b,y,L)&&(g=!0);y.unclaimed.clear()}p.clear(),g&&(R(),q())},M=(g,b)=>{t.set(g,u(we(e.tree(g)),b))},O=(g,b,y)=>{P(g);const L=u(hn(b),y);return t.set(g,L),r.delete(g),R(),q(),L},_=(g,b,y,L)=>{if(y!==C(g)||t.get(g)!==b)return;const H=he(b.promise);if(!(L.status!=="ok"||H?.status!=="ok"||b.loadedAt===null||L.loadedAt<=b.loadedAt)){if(je(H.entries,L.entries)){b.loadedAt=L.loadedAt;return}O(g,L,b.opened)}},B=(g,b)=>{const y=t.get(g);return y!==void 0&&he(y.promise)?.status===b},K=(g,b)=>{b.stale=!1;const y=C(g);e.tree(g).then(L=>_(g,b,y,L))};return{read:g=>t.get(g)?.promise??ti,open:g=>{const b=n.resumes(g),y=n.hold(g),L=t.get(g);return L===void 0||B(g,"deferred")?(M(g,!0),R()):b||(L.opened&&B(g,"error")?(M(g,!0),R()):(L.opened=!0,L.stale&&B(g,"ok")&&K(g,L))),y},retry:g=>{B(g,"error")&&(M(g,!0),R())},seed:(g,b)=>{const y=b.then(Z=>Z===null?ot:Z,()=>ot),L=t.get(g);if(L!==void 0&&B(g,"ok")){const Z=C(g);y.then(W=>_(g,L,Z,W));return}P(g);const H=u(we(y),L?.opened===!0);t.set(g,H),r.delete(g),q(),y.then(Z=>{t.get(g)===H&&(Z.status==="deferred"&&n.isHeld(g)&&M(g,H.opened),R())})},refresh:async g=>{const b=(s.get(g)??0)+1;s.set(g,b);const y=await e.refresh(g);if(s.get(g)!==b)return ei;if(y.status==="error")return{status:"failed",failure:y.failure};const L=t.get(g);if(!(L!==void 0&&L.loadedAt!==null&&B(g,"ok")&&L.loadedAt>y.loadedAt)){const Z=O(g,y,!0);if(L!==void 0&&L.promise.status==="pending"){const W=C(g);L.promise.then(G=>_(g,Z,W,G))}}for(const[Z,W]of t)Z!==g&&he(W.promise)?.status==="ok"&&(W.stale=!0);return Ja},children:(g,b)=>r.get(g)?.get(b),claimChildren:(g,b)=>{const y=j(g),L=h(g);let H=!1,Z=!1;for(const[G,ee]of b)y.claims.set(G,(y.claims.get(G)??0)+1),L.get(G)===void 0?(L.set(G,Vt),y[ee].add(G),H=!0,Z=!0):ee==="direct"&&y.bulk.delete(G)&&(y.direct.add(G),Z=!0);H&&R(),Z&&q();let W=!1;return()=>{if(!W){W=!0;for(const G of b.keys()){const ee=(y.claims.get(G)??0)-1;ee>0?y.claims.set(G,ee):(y.claims.delete(G),y.unclaimed.add(G))}p.add(g),!v&&(v=!0,queueMicrotask(T))}}},retryChildren:(g,b)=>{const y=r.get(g);if(y===void 0||y.get(b)?.status!=="failed")return;const L=j(g);if((L.claims.get(b)??0)>0){y.set(b,Vt),L.direct.add(b),R(),q();return}y.delete(b),R()},pendingChildren:g=>{const b=a.get(g);return b===void 0?0:b.direct.size+b.bulk.size+b.inFlight.size},clear:()=>{for(const g of new Set([...t.keys(),...r.keys(),...o.keys(),...a.keys()]))P(g);for(const[g,b]of s)s.set(g,b+1);t.clear(),r.clear(),R()},subscribeChildrenFailures:g=>(m.add(g),()=>{m.delete(g)}),subscribe:d.subscribe,version:()=>x}},si=(e,t)=>{let n=e;const r=me();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},ai=1;let Ce=0,se=null;const ii=()=>{const{documentElement:e,body:t}=document;Ce===0&&(se={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"),Ce+=1;let n=!1;return()=>{n||(n=!0,Ce-=1,!(Ce>0||se===null)&&(e.style.overflow=se.htmlOverflow,t.style.overflow=se.bodyOverflow,e.style.scrollbarGutter=se.htmlGutter,t.style.scrollbarGutter=se.bodyGutter,se=null))}},li=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],zt=1,ci=1e3,Zt=e=>e.getClientRects().length>0,Ge="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.",di=e=>{if(!Zt(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+ai)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. ${Ge}`;if(t.height<zt)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. ${Ge}`;for(const{selector:r,name:o}of li)for(const s of e.querySelectorAll(r)){if(!Zt(s))continue;const a=s.getBoundingClientRect().height;if(a<zt)return`[markdown-explorer] the explorer's ${o} collapsed to ${String(Math.round(a))}px while lockDocumentScroll stops the page from scrolling, so it cannot be read. ${Ge}`}return null},ui=e=>{let t=!1,n;const r=()=>{n=void 0;const a=di(e);a!==null&&(t=!0,console.error(a))},o=()=>{t||(clearTimeout(n),n=setTimeout(r,ci))},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)}},fi=(e,t)=>{l.useEffect(()=>e?ii():void 0,[e]),l.useEffect(()=>{const n=t.current;if(!(!e||n===null))return ui(n)},[e,t])},Gt='[data-testid="markdown-explorer-view-switch"]',mi=[{control:Gt,successors:[Gt,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],hi=e=>{for(const t of mi){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},gi=(e,t)=>{const n=l.useRef(null);l.useEffect(()=>{const o=d=>{const m=e.current;n.current=m!==null&&d instanceof Element&&m.contains(d)?hi(d):null},s=d=>o(d.target);o(document.activeElement);const a=d=>{const m=d.target;d.relatedTarget!==null||!(m instanceof Element)||queueMicrotask(()=>{n.current?.element===m&&m.isConnected&&document.activeElement!==m&&(n.current=null)})};return document.addEventListener("focusin",s),document.addEventListener("focusout",a),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",a)}},[e]);const r=l.useRef(t);l.useLayoutEffect(()=>{if(r.current===t)return;r.current=t;const o=n.current;if(o===null)return;const s=()=>{const m=document.activeElement;if(m!==null&&m!==document.body&&m!==o.element)return!0;const w=e.current;if(w===null)return!0;for(const c of o.control.successors)for(const f of w.querySelectorAll(c))if(f!==o.element&&(f.focus({preventScroll:!0}),document.activeElement===f))return!0;return!1};if(s())return;const a=e.current;if(a===null)return;const d=new MutationObserver(()=>{s()&&d.disconnect()});return d.observe(a,{childList:!0,subtree:!0}),()=>d.disconnect()},[t,e])},pi=l.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-C60lb9hP.cjs")).then(e=>({default:e.TreeLayout}))),wi=l.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-dAW_JCzg.cjs")).then(e=>({default:e.MultiLayout}))),vi=64,Ei={request:e=>{requestAnimationFrame(e)}},Kt=e=>{e.documents.clear(),e.trees.clear()},Ke=(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)},xi=(e,t)=>{const[n,r]=l.useState(()=>({overrides:t,locale:e,labels:Je(e,t)}));if(n.locale===e&&Or(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:Je(e,t)};return r(o),o.labels},bi=(e,t,n)=>{const[r,o]=l.useState(()=>({scope:t,store:Ut(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:Ut(e,n)};return o(s),s.store},We=(e,t)=>{const[n,r]=l.useState(()=>({scope:e,value:t()}));if(n.scope===e)return n.value;const o={scope:e,value:t()};return r(o),o.value},Si=()=>Wa(Ei),Wt="on",yi="off",ki=Object.freeze({kind:"unavailable"}),Ri=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")},Ti=(e,t)=>{const n=oe(e.peek(t));return n===null||n.document.kind==="failure"?D.lastPathSegment(t):n.document.name},Ci=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:a,renderTreeFailure:d,lockDocumentScroll:m=!1,onMathDiagnostics:w,onEditGrant:c,draftConverter:f})=>{Q.assertStorageNamespace(n),Ri(f);const p=nn(r),v=Lr(s),x=xi(p,o),{revalidate:R}=J.useRevalidator(),C=l.useRef(()=>{}),j=J.useHref(t.dataPath),[N]=l.useState(()=>{const y=Xa({dataPath:j,onScope:H=>C.current(H)}),L={documents:po({client:y,capacity:Math.max(vi,t.multiView.maxPanels*2)}),trees:oi(y)};return Ke(L,e),Q.syncStorageScope(n,e.scope),{data:y,...L,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(N.aligned.pageData!==e||N.aligned.storageNamespace!==n){const y=N.aligned.pageData;N.aligned.pageData=e,N.aligned.storageNamespace=n,y!==e&&(y.scope!==e.scope?N.aligned.pendingReader=e:Ke(N,e)),Q.syncStorageScope(n,e.scope)}const $=bi(Q.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);l.useLayoutEffect(()=>{const y=N.aligned.pendingReader;y!==null&&(N.aligned.pendingReader=null,Kt(N),Ke(N,y))},[e,N]),l.useLayoutEffect(()=>{let y=!1;return C.current=L=>{L===e.scope||y||(y=!0,L!==null&&(Kt(N),Q.clearExplorerStorage(n)),R())},()=>{C.current=()=>{}}},[e,R,N,n]);const P=l.useRef(t.settingsCookie);l.useLayoutEffect(()=>{P.current=t.settingsCookie},[t.settingsCookie]);const[u]=l.useState(()=>si(e.settings,y=>{document.cookie=V.viewSettingsCookieString(P.current,y,window.location.protocol==="https:")})),h=We(e.scope,Si),k=We(e.scope,Ya),A=l.useRef(x);l.useLayoutEffect(()=>{A.current=x},[x]);const I=We(e.scope,()=>_r({data:N.data,conflictLabels:()=>({ours:A.current.conflictOurs,theirs:A.current.conflictTheirs}),onSaveSettled:(y,L)=>{L.kind==="saved"&&N.documents.refresh(y);const H=Mr(A.current,L,Ti(N.documents,y));H!==null&&h.announce(H)},sideBySideSetting:{read:()=>Q.readStorage(Q.storageKeys(n).editPreview)===Wt,write:y=>Q.writeStorage(Q.storageKeys(n).editPreview,y?Wt:yi)},editorShareSetting:{read:()=>Dr(Q.readStorage(Q.storageKeys(n).editSplit)),write:y=>Q.writeStorage(Q.storageKeys(n).editSplit,String(y))}})),q=l.useMemo(()=>we(e.notices.catch(()=>[])),[e.notices]),E=e.sources.map(y=>y.id).join(`
|
|
12
|
-
`),T=l.useMemo(()=>V.withExplorerSources(t,E.split(`
|
|
13
|
-
`)),[t,E]),M=l.useRef(w);l.useLayoutEffect(()=>{M.current=w},[w]);const[O]=l.useState(()=>(y,L)=>{M.current?.(y,L)}),_=w===void 0?void 0:O,B=l.useRef(f);l.useLayoutEffect(()=>{B.current=f},[f]);const[K]=l.useState(()=>{let y=!1;return{convert:(L,H)=>{const Z=B.current;return Z===void 0?Promise.resolve(ki):Z.convert(L,H)},prepare:()=>{try{B.current?.prepare?.()}catch(L){if(y)return;y=!0,console.error("[markdown-explorer] the draft converter's prepare threw",L)}}}}),g=f===void 0?void 0:K,b=l.useMemo(()=>({config:T,labels:x,locale:p,theme:v,storageNamespace:n,scope:e.scope,sources:e.sources,notices:q,documents:N.documents,trees:N.trees,data:N.data,viewSettings:u,treeSettings:$,announcer:h,reveals:k,edits:I,onEditGrant:c,draftConverter:g,renderTreeFailure:d,reportMathDiagnostics:_}),[T,x,p,v,n,e.scope,e.sources,q,N,u,$,h,k,I,c,g,d,_]);return i.jsx(rn,{value:b,children:i.jsx(Li,{renderFrame:a,lockDocumentScroll:m},e.scope)})},Oi=({ref:e,theme:t,view:n,children:r})=>{const[o]=l.useState(rs);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})},Li=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=F(),o=Pe(),{hash:s}=J.useLocation(),a=Ee(),d=l.useRef(null);fi(t,d),l.useLayoutEffect(()=>{o.kind==="redirect"&&a(`${o.href}${s}`,"browse")},[o,s,a]);const{location:m}=o,w=m.view;gi(d,w);const c=m.view==="tree"?i.jsx(l.Suspense,{fallback:i.jsx("section",{className:"aqmx-split-fallback","aria-label":r.explorerRegion,"aria-busy":"true","data-testid":"markdown-explorer-split-loading",...Ae}),children:i.jsx(pi,{location:m})}):m.view==="multi"?i.jsx(l.Suspense,{fallback:i.jsx("section",{className:"aqmx-stage-fallback","aria-label":r.multiRegion,"aria-busy":"true","data-testid":"markdown-explorer-stage-loading",...Ae}),children:i.jsx(wi,{location:m})}):i.jsx(Ka,{location:m}),f=i.jsxs(Oi,{ref:d,theme:n,view:w,children:[c,i.jsx(Xr,{}),i.jsx(dr,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?f:e({view:w,children:f})},Ai=Sr.createShouldRevalidate({submissions:"skip",otherPath:"skip",query:"skip",hashChange:"skip"});exports.ALLOW_KEY_REPEAT=Ne;exports.CONFLICT_OURS_MARKER=sn;exports.CONFLICT_SEPARATOR=an;exports.CONFLICT_THEIRS_MARKER=ln;exports.CONTENT_PANE=Ae;exports.ContentSkeleton=be;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=Xt;exports.DocumentPane=Jn;exports.DocumentRefreshBar=cr;exports.EXPLORER_THEMES=et;exports.EditGrantNotice=rr;exports.ExplorerLink=On;exports.FOLDER_README_LOADING=gn;exports.FailureView=fe;exports.ForwardRef=er;exports.ForwardRef$1=nr;exports.ImageViewMemoryContext=Fn;exports.LazyNativeScrollBar=An;exports.LiveRegion=dr;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=tn;exports.MARKDOWN_EXPLORER_LABEL_KEYS=at;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=Jt;exports.MARKDOWN_EXPLORER_LOCALES=Qe;exports.MarkdownExplorer=Ci;exports.NO_DOCUMENT=Xn;exports.PAGE_DOCUMENT_REFRESH=lr;exports.anchorOfDoubleClick=Sn;exports.anchorOfView=yn;exports.blockAtLine=Tn;exports.chooseEditView=rt;exports.consumeKey=it;exports.createEmitter=me;exports.cssPixels=dn;exports.editViewOf=or;exports.explorerNavigationOptions=uo;exports.failureTitleOf=te;exports.findConflictsInLines=cn;exports.focusWithoutScroll=dt;exports.frameTopOf=kn;exports.isApplePlatform=ar;exports.isEditViewShortcut=ir;exports.isEditingDoubleClick=bn;exports.lineTopIn=Cn;exports.loadedOf=oe;exports.paneShownAlone=Na;exports.positionInSource=lo;exports.readFolderReadme=pn;exports.resolveMarkdownExplorerLabels=Je;exports.shouldRevalidateExplorer=Ai;exports.toggledEditView=sr;exports.useExplorer=F;exports.useExplorerLocation=Pe;exports.useExplorerNavigate=Ee;exports.useIntentPrefetch=Ln;exports.usePageMarkupToggle=Bn;exports.useSideBySide=En;exports.useViewSetting=pe;exports.visibleTopOf=Rn;
|