@aiquants/markdown-explorer 0.31.0 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +5 -4
  3. package/dist/{EditSurface-BBHPQhf3.cjs → EditSurface-BPqqykro.cjs} +1 -1
  4. package/dist/{EditSurface-N7HkpyJA.js → EditSurface-CWq35IWQ.js} +1 -1
  5. package/dist/{ExplorerSplit-DMqbSL3i.js → ExplorerSplit-BRY4uy6x.js} +2 -2
  6. package/dist/{ExplorerSplit-C7GvlQ-G.cjs → ExplorerSplit-CQxr6b0v.cjs} +1 -1
  7. package/dist/{MultiLayout-9g9_IBi5.js → MultiLayout-DYNGlNy0.js} +3 -2
  8. package/dist/{MultiLayout-mDzolCaK.cjs → MultiLayout-TXbet9k3.cjs} +1 -1
  9. package/dist/{NativeScrollBar-BiLLVz18.js → NativeScrollBar-BsWdvkHa.js} +2 -2
  10. package/dist/{NativeScrollBar-B0QLIVf3.cjs → NativeScrollBar-UpjxjLlB.cjs} +1 -1
  11. package/dist/{TreeLayout-OjVoHBDI.js → TreeLayout-BQEgZhz9.js} +2 -2
  12. package/dist/{TreeLayout-DKq_aXBx.cjs → TreeLayout-C0O1OGi4.cjs} +1 -1
  13. package/dist/core/labels.d.cts +1 -0
  14. package/dist/core/labels.d.ts +1 -0
  15. package/dist/{index-C8yNTkdV.js → index-CO-RgTml.js} +7 -5
  16. package/dist/{index-CT-daekP.cjs → index-DSkK8iLE.cjs} +5 -5
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/{merge-Be3mcQZD.js → merge-D7L_pINl.js} +1 -1
  20. package/dist/{merge-Cv6zPoVK.cjs → merge-DZI4pkWI.cjs} +1 -1
  21. package/dist/styles/markdown-explorer.css +1 -1
  22. package/dist/{tapScrollCircle-Cy1KyTg2.js → tapScrollCircle-CRKZremf.js} +1 -1
  23. package/dist/{tapScrollCircle-37FU6daT.cjs → tapScrollCircle-Cbf17x8g.cjs} +1 -1
  24. package/docs/behavior/layout.md +21 -13
  25. package/docs/behavior/localization.md +1 -1
  26. package/package.json +9 -9
@@ -1,4 +1,4 @@
1
- "use strict";const l=require("react/jsx-runtime"),d=require("react"),te=require("react-router"),H=require("./location-BxiJRTyw.cjs"),ve=require("@aiquants/markdown/code-blocks"),_=require("./dataRoute-DwYtgyt6.cjs"),Ee=require("@aiquants/markdown"),wt=require("@aiquants/markdown/source-lines"),vt=require("@aiquants/spreadsheet/tsv"),Gt=require("@aiquants/spreadsheet/view"),Co=require("@aiquants/markdown/viewer-settings"),J=require("./storage-DM0EvkVf.cjs"),Oo=require("@aiquants/route-revalidation");function Ao(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const y=Ao(d),Et=Object.freeze(["en","ja"]),jn="en",Lt=e=>`viewerSpreadsheet${e.charAt(0).toUpperCase()}${e.slice(1)}`,Pn=Object.freeze(Object.keys(ve.SPREADSHEET_BLOCK_LABEL_CATALOGS.en)),_n=e=>Object.fromEntries(Pn.map(t=>[Lt(t),ve.SPREADSHEET_BLOCK_LABEL_CATALOGS[e][t].text])),In=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"]),viewerSvgImageFullscreenDialog:Object.freeze(["name"]),...Object.fromEntries(Pn.filter(e=>ve.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e].length>0).map(e=>[Lt(e),ve.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e]]))}),Mo=/\{(\w+)\}/gu,Fn={..._n("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.",spreadsheetWorkbookFirstSheet:"The whole workbook could not be read, so only its first sheet is shown.",spreadsheetSheets:e=>`Sheets of ${e}`,spreadsheetSheetName:(e,t)=>`${e}, sheet ${t}`,spreadsheetUnshownSheets:e=>e===1?"1 sheet is not shown (a hidden sheet or a chart sheet).":`${e} sheets are not shown (hidden sheets or chart sheets).`,spreadsheetUnlistedSheets:e=>`Only the first ${e} sheets are listed.`,spreadsheetSheetLoading:"Loading the sheet…",spreadsheetSheetEmpty:"This sheet has no data.",spreadsheetWorkbookEncrypted:"This workbook is password-protected, so it cannot be shown. Download it to open it.",spreadsheetNotWorkbook:"This file cannot be read as an Excel (.xlsx) or OpenDocument (.ods) workbook. Download it to open it.",spreadsheetWorkbookTooLarge:"This workbook is too large to preview. Download it to open it.",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",viewerMermaidFullscreen:"View full screen",viewerMermaidExitFullscreen:"Exit full screen",viewerMermaidFullscreenDialog:"Diagram (full screen)",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.",viewerSvgImageFullscreen:"View full screen",viewerSvgImageExitFullscreen:"Exit full screen",viewerSvgImageFullscreenDialog:"{name} (full screen)",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"},No={..._n("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 を表示しません。新しいタブで開くか、ダウンロードしてください。",spreadsheetWorkbookFirstSheet:"ブック全体を読めなかったため、最初のシートだけを表示しています。",spreadsheetSheets:e=>`${e} のシート`,spreadsheetSheetName:(e,t)=>`${e} のシート「${t}」`,spreadsheetUnshownSheets:e=>`非表示のシートかグラフのシートが ${e} 枚あり、表示していません。`,spreadsheetUnlistedSheets:e=>`最初の ${e} 枚のシートだけを並べています。`,spreadsheetSheetLoading:"シートを読み込み中…",spreadsheetSheetEmpty:"このシートにはデータがありません。",spreadsheetWorkbookEncrypted:"このブックはパスワードで保護されているため、表示できません。ダウンロードして開いてください。",spreadsheetNotWorkbook:"このファイルは Excel (.xlsx) や OpenDocument (.ods) のブックとして読めません。ダウンロードして開いてください。",spreadsheetWorkbookTooLarge:"このブックはプレビューするには大きすぎます。ダウンロードして開いてください。",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:"右へ移動",viewerMermaidFullscreen:"全画面で見る",viewerMermaidExitFullscreen:"全画面を閉じる",viewerMermaidFullscreenDialog:"図 (全画面)",viewerMermaidDiagram:"図 (矢印キーで移動、+ と - で拡大縮小、0 で元に戻す)",viewerMermaidRetry:"再試行",viewerEmbeddedVideo:"埋め込みの動画",viewerEmbeddedPost:"埋め込みの投稿",viewerEmbeddedFrame:"埋め込みのコンテンツ",viewerBlockFailed:"このブロックを表示できませんでした。",viewerSvgImageToolbar:"SVG の画像",viewerSvgImageSource:"ソース",viewerSvgImageSourceRegion:"{name} のソース",viewerSvgImageLoading:"ソースを読み込み中…",viewerSvgImageFailed:"ソースを読み込めませんでした。",viewerSvgImageRetry:"再試行",viewerSvgImageTruncated:"このファイルは先頭だけを表示しています。",viewerSvgImageCopy:"ソースをコピー",viewerSvgImageCopied:"ソースをコピーしました。",viewerSvgImageCopyFailed:"ソースをコピーできませんでした。",viewerSvgImageCopyImage:"画像をコピー",viewerSvgImageCopiedImage:"画像をコピーしました。",viewerSvgImageCopyImageFailed:"画像をコピーできませんでした。",viewerSvgImageFullscreen:"全画面で見る",viewerSvgImageExitFullscreen:"全画面を閉じる",viewerSvgImageFullscreenDialog:"{name} (全画面)",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:"ここへパネルをドロップ"},$n=Object.freeze({en:Object.freeze(Fn),ja:Object.freeze(No)}),Ct=Object.freeze(Object.keys(Fn)),Do=new Set(Ct),jo=e=>Do.has(e),Fe=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,qn=e=>{if(e===void 0)return jn;if(Et.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${Et.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${Fe(e)}`)},xt=(e,t)=>{const n=$n[qn(e)];if(t===void 0)return n;if(t===null||typeof t!="object")throw new RangeError(`[markdown-explorer] labels must be an object; got ${Fe(t)}`);if(!H.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${Fe(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!jo(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${Ct.join(", ")}`);const a=r[s];if(a===void 0)continue;const i=typeof n[s];if(typeof a!==i)throw new TypeError(`[markdown-explorer] labels.${s} must be a ${i}; got ${Fe(a)}`);if(typeof a=="string"&&a.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const m=In[s];if(typeof a=="string"&&m!==void 0){for(const[,f]of a.matchAll(Mo))if(!m.includes(f??""))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${String(f)}}; it accepts ${m.map(c=>`{${c}}`).join(", ")}`)}o[s]=a}return Object.freeze(o)},Po=(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]))},bt=Object.freeze(["light","dark"]),_o=e=>{if(e===void 0)return"light";if(bt.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${bt.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},Bn=d.createContext(null),F=()=>{const e=d.use(Bn);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},Re=e=>{const{viewSettings:t}=F(),n=()=>e(t.getSnapshot());return d.useSyncExternalStore(t.subscribe,n,n)},Ke=()=>{const{config:e}=F(),t=te.useParams()["*"],[n]=te.useSearchParams(),r=n.toString();return d.useMemo(()=>H.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])},Un={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"]},re=(e,t)=>e[Un[t][0]],ce=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=F(),s=re(o,e.reason),a=o[Un[e.reason][1]],i=e.reason==="unauthorized"||e.reason==="forbidden"||e.reason==="failed"?"danger":"warning";return l.jsxs("div",{className:"aqmx-callout",role:t?"alert":void 0,"data-aqmx-tone":i,"data-testid":r===null?void 0:r,"data-aqmx-failure":r===null?void 0:e.reason,children:[l.jsx("p",{className:"aqmx-callout-title",children:s}),l.jsx("p",{className:"aqmx-callout-body",children:a}),e.reason==="unauthorized"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:()=>window.location.reload(),children:o.reloadPage}):n!==void 0&&e.reason==="failed"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:n,children:o.retry}):null]})},Io=(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 re(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(re(e,r.failure.reason));case"saved":if(!o)return r.merged?e.draftSavedMerged:e.draftSaved;break}return o?e.draftUnsaved:""},Fo=(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(re(e,t.failure.reason));case"idle":case"saving":return null}},xe=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},Hn="<<<<<<<",zn="=======",Vn=">>>>>>>",Kt=(e,t)=>e===t||e.startsWith(`${t} `),Xt=e=>Zn(e.split(`
1
+ "use strict";const l=require("react/jsx-runtime"),d=require("react"),te=require("react-router"),H=require("./location-BxiJRTyw.cjs"),ve=require("@aiquants/markdown/code-blocks"),_=require("./dataRoute-DwYtgyt6.cjs"),Ee=require("@aiquants/markdown"),wt=require("@aiquants/markdown/source-lines"),vt=require("@aiquants/spreadsheet/tsv"),Gt=require("@aiquants/spreadsheet/view"),Co=require("@aiquants/markdown/viewer-settings"),J=require("./storage-DM0EvkVf.cjs"),Oo=require("@aiquants/route-revalidation");function Ao(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const y=Ao(d),Et=Object.freeze(["en","ja"]),jn="en",Lt=e=>`viewerSpreadsheet${e.charAt(0).toUpperCase()}${e.slice(1)}`,Pn=Object.freeze(Object.keys(ve.SPREADSHEET_BLOCK_LABEL_CATALOGS.en)),_n=e=>Object.fromEntries(Pn.map(t=>[Lt(t),ve.SPREADSHEET_BLOCK_LABEL_CATALOGS[e][t].text])),In=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"]),viewerSvgImageFullscreenDialog:Object.freeze(["name"]),...Object.fromEntries(Pn.filter(e=>ve.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e].length>0).map(e=>[Lt(e),ve.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e]]))}),Mo=/\{(\w+)\}/gu,Fn={..._n("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.",spreadsheetWorkbookFirstSheet:"The whole workbook could not be read, so only its first sheet is shown.",spreadsheetSheets:e=>`Sheets of ${e}`,spreadsheetSheetName:(e,t)=>`${e}, sheet ${t}`,spreadsheetUnshownSheets:e=>e===1?"1 sheet is not shown (a hidden sheet or a chart sheet).":`${e} sheets are not shown (hidden sheets or chart sheets).`,spreadsheetUnlistedSheets:e=>`Only the first ${e} sheets are listed.`,spreadsheetSheetLoading:"Loading the sheet…",spreadsheetSheetEmpty:"This sheet has no data.",spreadsheetWorkbookEncrypted:"This workbook is password-protected, so it cannot be shown. Download it to open it.",spreadsheetNotWorkbook:"This file cannot be read as an Excel (.xlsx) or OpenDocument (.ods) workbook. Download it to open it.",spreadsheetWorkbookTooLarge:"This workbook is too large to preview. Download it to open it.",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",viewerMermaidFullscreen:"View full screen",viewerMermaidExitFullscreen:"Exit full screen",viewerMermaidFullscreenDialog:"Diagram (full screen)",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.",viewerSvgImageFullscreen:"View full screen",viewerSvgImageExitFullscreen:"Exit full screen",viewerSvgImageFullscreenDialog:"{name} (full screen)",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",panelMoreActions:"More actions",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"},No={..._n("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 を表示しません。新しいタブで開くか、ダウンロードしてください。",spreadsheetWorkbookFirstSheet:"ブック全体を読めなかったため、最初のシートだけを表示しています。",spreadsheetSheets:e=>`${e} のシート`,spreadsheetSheetName:(e,t)=>`${e} のシート「${t}」`,spreadsheetUnshownSheets:e=>`非表示のシートかグラフのシートが ${e} 枚あり、表示していません。`,spreadsheetUnlistedSheets:e=>`最初の ${e} 枚のシートだけを並べています。`,spreadsheetSheetLoading:"シートを読み込み中…",spreadsheetSheetEmpty:"このシートにはデータがありません。",spreadsheetWorkbookEncrypted:"このブックはパスワードで保護されているため、表示できません。ダウンロードして開いてください。",spreadsheetNotWorkbook:"このファイルは Excel (.xlsx) や OpenDocument (.ods) のブックとして読めません。ダウンロードして開いてください。",spreadsheetWorkbookTooLarge:"このブックはプレビューするには大きすぎます。ダウンロードして開いてください。",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:"右へ移動",viewerMermaidFullscreen:"全画面で見る",viewerMermaidExitFullscreen:"全画面を閉じる",viewerMermaidFullscreenDialog:"図 (全画面)",viewerMermaidDiagram:"図 (矢印キーで移動、+ と - で拡大縮小、0 で元に戻す)",viewerMermaidRetry:"再試行",viewerEmbeddedVideo:"埋め込みの動画",viewerEmbeddedPost:"埋め込みの投稿",viewerEmbeddedFrame:"埋め込みのコンテンツ",viewerBlockFailed:"このブロックを表示できませんでした。",viewerSvgImageToolbar:"SVG の画像",viewerSvgImageSource:"ソース",viewerSvgImageSourceRegion:"{name} のソース",viewerSvgImageLoading:"ソースを読み込み中…",viewerSvgImageFailed:"ソースを読み込めませんでした。",viewerSvgImageRetry:"再試行",viewerSvgImageTruncated:"このファイルは先頭だけを表示しています。",viewerSvgImageCopy:"ソースをコピー",viewerSvgImageCopied:"ソースをコピーしました。",viewerSvgImageCopyFailed:"ソースをコピーできませんでした。",viewerSvgImageCopyImage:"画像をコピー",viewerSvgImageCopiedImage:"画像をコピーしました。",viewerSvgImageCopyImageFailed:"画像をコピーできませんでした。",viewerSvgImageFullscreen:"全画面で見る",viewerSvgImageExitFullscreen:"全画面を閉じる",viewerSvgImageFullscreenDialog:"{name} (全画面)",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:"下へ移動",panelMoreActions:"その他の操作",panelMoved:"{title} を {column} 列目の {position} 番目へ移動しました",panelMoveUnavailable:"{title} は「{move}」できません",panelDragStarted:"{title} を持ち上げました",panelDragCancelled:"{title} の移動を取り消しました",hiddenPanelsTitle:"隠したパネル:",hiddenPanelBadge:"非表示",hiddenPanelNotice:"このパネルは隠しています",multiColumnEmpty:"この列は空です",multiColumnRegion:"{column} 列目",panelDropHere:"ここへパネルをドロップ"},$n=Object.freeze({en:Object.freeze(Fn),ja:Object.freeze(No)}),Ct=Object.freeze(Object.keys(Fn)),Do=new Set(Ct),jo=e=>Do.has(e),Fe=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,qn=e=>{if(e===void 0)return jn;if(Et.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${Et.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${Fe(e)}`)},xt=(e,t)=>{const n=$n[qn(e)];if(t===void 0)return n;if(t===null||typeof t!="object")throw new RangeError(`[markdown-explorer] labels must be an object; got ${Fe(t)}`);if(!H.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${Fe(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!jo(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${Ct.join(", ")}`);const a=r[s];if(a===void 0)continue;const i=typeof n[s];if(typeof a!==i)throw new TypeError(`[markdown-explorer] labels.${s} must be a ${i}; got ${Fe(a)}`);if(typeof a=="string"&&a.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const m=In[s];if(typeof a=="string"&&m!==void 0){for(const[,f]of a.matchAll(Mo))if(!m.includes(f??""))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${String(f)}}; it accepts ${m.map(c=>`{${c}}`).join(", ")}`)}o[s]=a}return Object.freeze(o)},Po=(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]))},bt=Object.freeze(["light","dark"]),_o=e=>{if(e===void 0)return"light";if(bt.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${bt.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},Bn=d.createContext(null),F=()=>{const e=d.use(Bn);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},Re=e=>{const{viewSettings:t}=F(),n=()=>e(t.getSnapshot());return d.useSyncExternalStore(t.subscribe,n,n)},Ke=()=>{const{config:e}=F(),t=te.useParams()["*"],[n]=te.useSearchParams(),r=n.toString();return d.useMemo(()=>H.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])},Un={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"]},re=(e,t)=>e[Un[t][0]],ce=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=F(),s=re(o,e.reason),a=o[Un[e.reason][1]],i=e.reason==="unauthorized"||e.reason==="forbidden"||e.reason==="failed"?"danger":"warning";return l.jsxs("div",{className:"aqmx-callout",role:t?"alert":void 0,"data-aqmx-tone":i,"data-testid":r===null?void 0:r,"data-aqmx-failure":r===null?void 0:e.reason,children:[l.jsx("p",{className:"aqmx-callout-title",children:s}),l.jsx("p",{className:"aqmx-callout-body",children:a}),e.reason==="unauthorized"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:()=>window.location.reload(),children:o.reloadPage}):n!==void 0&&e.reason==="failed"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:n,children:o.retry}):null]})},Io=(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 re(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(re(e,r.failure.reason));case"saved":if(!o)return r.merged?e.draftSavedMerged:e.draftSaved;break}return o?e.draftUnsaved:""},Fo=(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(re(e,t.failure.reason));case"idle":case"saving":return null}},xe=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},Hn="<<<<<<<",zn="=======",Vn=">>>>>>>",Kt=(e,t)=>e===t||e.startsWith(`${t} `),Xt=e=>Zn(e.split(`
2
2
  `)),Zn=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||(Kt(s,Hn)?(n=o,r=null):s===zn?n!==null&&r===null?r=o:n=null:Kt(s,Vn)&&(n!==null&&r!==null&&t.push({start:n,separator:r,end:o}),n=null,r=null))}return t},Yt=e=>e.includes(`\r
3
3
  `)?`\r
4
4
  `:`
@@ -6,10 +6,10 @@
6
6
  `),$o=(e,t)=>t===`
7
7
  `?e:e.replaceAll(`
8
8
  `,`\r
9
- `),qo=3,Bo=/^\d+(?:\.\d+)?$/u,Uo=e=>{if(e===null||!Bo.test(e))return null;const t=Number(e);return t>=H.EDIT_SPLIT_MIN_PERCENT&&t<=H.EDIT_SPLIT_MAX_PERCENT?t:null},rt=Object.freeze({kind:"idle"}),Qt=Object.freeze({kind:"draft"}),Ho=({data:e,conflictLabels:t,onSaveSettled:n,sideBySideSetting:r,editorShareSetting:o})=>{const s=new Map,a=new Map,i=new Map,m=new Map,f=new Map,c=xe();let u=null,h=null,w=null;const E=(p,g)=>{p.value={...p.value,...g},c.emit()},b=(p,g)=>s.get(p)===g,T=async(p,g)=>{g.controller.abort(),g.controller=new AbortController;const{signal:R}=g.controller;E(g,{phase:{kind:"opening"}});const N=await e.edit(p,R);if(!b(p,g)||R.aborted||!("kind"in N))return;if(N.kind==="grant"){E(g,{phase:{kind:"grant",href:N.href}});return}if(N.kind==="failure"){E(g,{phase:{kind:"failed",failure:N.failure}});return}const I=nt(N.text),$=N.kind==="draft";g.base={text:I,version:$?null:N.version},g.draft=I,g.ending=Yt(N.text),E(g,{phase:{kind:"editing"},history:$?!1:N.history,dirty:!1,save:$?Qt:rt,generation:g.value.generation+1})},O=p=>{const g=s.get(p);g!==void 0&&(g.controller.abort(),s.delete(p),i.delete(p))},L=(p,g,R)=>(p.set(g,R),()=>{p.get(g)===R&&p.delete(g)}),q=(p,g,R,N={})=>{E(g,{...N,save:R}),n(p,R)},j=async p=>{m.get(p)?.flush();const g=s.get(p);if(g===void 0||g.value.phase.kind!=="editing"||g.base===null||g.value.save.kind==="saving")return;const{version:R}=g.base;if(R===null){n(p,Qt);return}const N=Xt(g.draft).length;if(N>0){q(p,g,{kind:"conflicts",count:N});return}g.controller.abort(),g.controller=new AbortController;const{signal:I}=g.controller;let $={text:g.base.text,version:R},x=g.draft,k=!1;E(g,{save:{kind:"saving"}});for(let A=0;A<qo;A+=1){const M=await e.save(p,$.version,$o(x,g.ending),I);if(!b(p,g)||I.aborted||!("kind"in M))return;if(M.kind==="saved"){m.get(p)?.flush(),g.base={text:x,version:M.version},q(p,g,{kind:"saved",merged:k},{dirty:g.draft!==x});return}if(M.kind==="grant"){q(p,g,{kind:"grant",href:M.href});return}if(M.kind==="failure"){q(p,g,{kind:"failed",failure:M.failure});return}const{mergeDraft:P}=await Promise.resolve().then(()=>require("./merge-Cv6zPoVK.cjs"));if(!b(p,g)||I.aborted)return;const B=m.get(p);B?.flush();const G=nt(M.text),v=P($.text,g.draft,G,t());if($={text:G,version:M.version},g.base=$,g.ending=Yt(M.text),g.draft=v.text,B?.adopt(v.text),v.kind==="conflicts"){q(p,g,{kind:"conflicts",count:v.conflicts},{dirty:!0,generation:g.value.generation+1});return}if(k=!0,x=v.text,x===$.text){q(p,g,{kind:"saved",merged:k},{dirty:!1,generation:g.value.generation+1});return}E(g,{dirty:!0,generation:g.value.generation+1})}q(p,g,{kind:"failed",failure:{reason:"failed"}})};return{session:p=>s.get(p)?.value,subscribe:c.subscribe,start:(p,g)=>{const R=s.get(p);if(R!==void 0){E(R,{request:{anchor:g},view:"editor"}),(R.value.phase.kind==="failed"||R.value.phase.kind==="grant")&&T(p,R);return}a.delete(p);const N={value:{path:p,phase:{kind:"opening"},view:"editor",previewPrepared:!1,history:!1,dirty:!1,save:rt,generation:0,request:{anchor:g}},base:null,draft:"",ending:`
10
- `,controller:new AbortController};s.set(p,N),T(p,N)},retry:p=>{const g=s.get(p);g===void 0||g.value.phase.kind==="editing"||T(p,g)},draft:p=>{const g=s.get(p);return g===void 0||g.base===null?null:g.draft},setDraft:(p,g)=>{const R=s.get(p);if(R===void 0||R.base===null)return;R.draft=g;const N={},I=g!==R.base.text;I!==R.value.dirty&&(N.dirty=I);const{save:$}=R.value;if($.kind==="conflicts"){const x=Xt(g).length;x===0?N.save=rt:x!==$.count&&(N.save={kind:"conflicts",count:x})}(N.dirty!==void 0||N.save!==void 0)&&E(R,N)},consumeRequest:p=>{const g=s.get(p);g!==void 0&&g.value.request!==null&&E(g,{request:null})},save:j,replaceDraft:(p,g)=>{const R=m.get(p);R?.flush();const N=s.get(p);if(N===void 0||N.base===null)return;const I=nt(g);N.draft=I,R?.adopt(I),E(N,{dirty:I!==N.base.text,generation:N.value.generation+1})},close:p=>{if(!s.has(p))return;const g=m.get(p),R=g===void 0?null:g.returnPoint();O(p),R===null?a.delete(p):a.set(p,R),c.emit()},takeReturn:p=>{const g=a.get(p)??null;return a.delete(p),g},dirtyPaths:()=>[...s.values()].filter(p=>p.value.dirty).map(p=>p.value.path),discard:p=>{for(const g of p)O(g);p.length>0&&c.emit()},editorState:{get:p=>i.get(p),set:(p,g)=>{s.has(p)&&i.set(p,g)}},bindEditor:(p,g)=>L(m,p,g),bindView:(p,g)=>L(f,p,g),viewAnchor:p=>{const g=f.get(p);return g===void 0?null:g.anchor()},flush:p=>m.get(p)?.flush(),flushDrafts:()=>{for(const p of m.values())p.flush()},nextConflict:p=>m.get(p)?.nextConflict()===!0,hasSessions:()=>s.size>0,unsavedAmong:p=>{for(const g of m.values())g.flush();return p.filter(g=>s.get(g)?.value.dirty===!0)},askToDiscard:p=>new Promise(g=>{w?.settle(!1);const R={paths:p,settle:N=>{if(w===R){if(w=null,N)for(const I of p)O(I);c.emit(),g(N)}}};w=R,c.emit()}),discardRequest:()=>w,sideBySide:()=>(u??=r.read(),u),setSideBySide:p=>{u!==p&&(u=p,r.write(p),c.emit())},editorShare:()=>(h??=o.read()??H.EDIT_SPLIT_DEFAULT_PERCENT,h),setEditorShare:p=>{if(!Number.isFinite(p))throw new RangeError(`[markdown-explorer] an editor share must be a finite number; got ${String(p)}`);const g=Math.min(H.EDIT_SPLIT_MAX_PERCENT,Math.max(H.EDIT_SPLIT_MIN_PERCENT,p));h!==g&&(h=g,o.write(g))},setView:(p,g)=>{const R=s.get(p);R===void 0||R.value.view===g||(m.get(p)?.beforeView(g),E(R,{view:g,previewPrepared:R.value.previewPrepared||g==="preview"}))},preparePreview:p=>{const g=s.get(p);g!==void 0&&!g.value.previewPrepared&&E(g,{previewPrepared:!0})}}},Ot=e=>{e.preventDefault(),e.stopPropagation()},Wn=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,Gn="data-aqmx-content-pane",Ue=Object.freeze({[Gn]:""}),zo="--aqmx-dialog-left",Vo="--aqmx-dialog-top",Zo='[data-testid="markdown-explorer"]',Wo=e=>{const t=e.closest(Zo)?.querySelectorAll(`[${Gn}]`),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},Go=e=>{const t=Wn(getComputedStyle(e).marginTop);if(Number.isNaN(t))return null;const n=Wo(e),r=e.getBoundingClientRect(),o=e.ownerDocument.documentElement,{left:s,top:a}=H.centeredDialogPosition(n.getBoundingClientRect(),{width:r.width+2*t,height:r.height+2*t},{width:o.clientWidth,height:o.clientHeight});return e.style.setProperty(zo,`${String(s)}px`),e.style.setProperty(Vo,`${String(a)}px`),n},Ko=e=>e.preventDefault(),Kn=({open:e,onOpen:t,onDismiss:n})=>{const r=d.useRef(null),o=d.useRef(null),s=d.useRef(!1),a=d.useRef(t);d.useLayoutEffect(()=>{a.current=t},[t]),d.useLayoutEffect(()=>{s.current=e;const c=r.current;if(c!==null)if(e&&!c.open){const u=c.ownerDocument.activeElement;o.current=u instanceof HTMLElement?u:null,c.showModal(),a.current?.()}else!e&&c.open&&(c.close(),o.current?.isConnected===!0&&o.current.focus(),o.current=null)},[e]),d.useLayoutEffect(()=>{const c=r.current;if(!e||c===null)return;const u=new ResizeObserver(()=>w());let h=null;const w=()=>{const b=Go(c);b===null||b===h||(h!==null&&u.unobserve(h),u.observe(b),h=b)};w(),u.observe(c);const E=c.ownerDocument.defaultView;return E?.addEventListener("resize",w),c.ownerDocument.addEventListener("scroll",w,{capture:!0,passive:!0}),()=>{u.disconnect(),E?.removeEventListener("resize",w),c.ownerDocument.removeEventListener("scroll",w,{capture:!0})}},[e]);const i=d.useCallback(c=>{c.key!=="Escape"||c.defaultPrevented||(Ot(c),n())},[n]),m=d.useCallback(c=>{c.target===c.currentTarget&&n()},[n]),f=d.useCallback(()=>{s.current&&n()},[n]);return{ref:r,onKeyDown:i,onClick:m,onCancel:Ko,onClose:f}},Xn=({open:e,title:t,body:n,confirmLabel:r,cancelLabel:o,onConfirm:s,onCancel:a,testId:i})=>{const m=d.useRef(null),f=d.useId(),c=d.useId(),u=d.useCallback(()=>m.current?.focus(),[]),h=Kn({open:e,onOpen:u,onDismiss:a});return l.jsx("dialog",{...h,className:"aqmx-confirm","aria-labelledby":f,"aria-describedby":c,"data-testid":i,children:l.jsxs("div",{className:"aqmx-confirm-panel",children:[l.jsx("p",{id:f,className:"aqmx-confirm-title",children:t}),l.jsx("p",{id:c,className:"aqmx-confirm-body",children:n}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{ref:m,type:"button",className:"aqmx-callout-action","data-testid":`${i}-cancel`,onClick:a,children:o}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-aqmx-tone":"danger","data-testid":`${i}-confirm`,onClick:s,children:r})]})]})})},Te=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},Yn=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),Se=e=>e.status==="fulfilled"?e.value:void 0,Qn=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!1}),Xo=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!0}),Yo=(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,i=s.lazy===!0?a?.status==="loaded"?a.entries:null:s.children===void 0?[]:s.children;if(s.path===t)return i;if(i!==null)for(const m of[...i].reverse())o.push(m)}return null},Jn=(e,t,n)=>{const r=Se(e.read(t));if(r===void 0||r.status==="deferred")return Qn;if(r.status==="error")return{readme:{status:"failed",failure:r.failure,retry:()=>e.retry(t)},claim:!1};const o=Yo(r.entries,n,a=>e.children(t,a));if(o!==null)return{readme:{status:"ok",readme:H.folderReadmeOf(o)},claim:!1};const s=e.children(t,n);return s===void 0||s.status==="loading"?Xo:s.status==="failed"?{readme:{status:"failed",failure:s.failure,retry:()=>e.retryChildren(t,n)},claim:!0}:{readme:{status:"ok",readme:H.folderReadmeOf(s.entries)},claim:!0}},Qo=(e,t,n)=>{const{readme:r}=Jn(e,t,n);return r.status==="ok"?r.readme:null},Jo=(e,t,n)=>{const r=te.matchPath({path:`${e.basePath}/*`,end:!0},t.pathname);if(r===null)return new Set;const{location:o}=H.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)}},er=e=>{const{edits:t}=F(),n=d.useCallback(()=>t.session(e),[t,e]);return d.useSyncExternalStore(t.subscribe,n,es)},tr=()=>!1,es=()=>{},ts=()=>{const{edits:e}=F();return d.useSyncExternalStore(e.subscribe,e.hasSessions,tr)},nr=()=>{const{edits:e}=F();return d.useSyncExternalStore(e.subscribe,e.sideBySide,tr)},ns=()=>null,rs=()=>{const{edits:e,labels:t,config:n,trees:r}=F(),o=d.useRef([]),s=d.useCallback(({nextLocation:w})=>{const E=Jo(n,w,(b,T)=>Qo(r,b,T));return e.flushDrafts(),o.current=e.dirtyPaths().filter(b=>!E.has(b)),o.current.length>0},[e,n,r]),a=te.useBlocker(s),i=ts();d.useEffect(()=>{if(!i)return;const w=E=>{e.flushDrafts(),e.dirtyPaths().length!==0&&(E.preventDefault(),E.returnValue=!0)};return window.addEventListener("beforeunload",w),()=>window.removeEventListener("beforeunload",w)},[i,e]);const m=d.useSyncExternalStore(e.subscribe,e.discardRequest,ns),f=a.state==="blocked",c=f?o.current:m===null?[]:m.paths,u=c.map(w=>_.lastPathSegment(w)).join(", "),h=c.length>0&&c.every(w=>e.session(w)?.save.kind==="draft");return l.jsx(Xn,{open:f||m!==null,title:h?t.draftDiscardTitle:t.unsavedTitle,body:h?t.draftDiscardBody(u):t.unsavedBody(u),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 os({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm2.25 8.5a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Zm0 3a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",clipRule:"evenodd"}))}const ss=y.forwardRef(os);let ot=null;const rr=()=>(ot??=Promise.resolve().then(()=>require("./EditSurface-BBHPQhf3.cjs")).catch(e=>{throw ot=null,e}),ot),as=()=>{rr().catch(()=>{})},ls=e=>{const{default:t}=d.use(rr());return l.jsx(t,{...e})};class is extends d.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 or="[data-aqmd-fullscreen]",cs=e=>e instanceof Element&&e.closest(or)!==null,At=`[${wt.SOURCE_LINES_ATTRIBUTE}]`,ds="[data-aqmd-content]",us=`a[href], button, input, select, textarea, summary, label, [contenteditable], [role="menu"], iframe, video, audio, object, embed, svg, [data-aqmd-spreadsheet-editable], ${or}, [data-aqmd-svg-image-source]`,fs=200,Le=e=>wt.parseSourceLines(e.getAttribute(wt.SOURCE_LINES_ATTRIBUTE)),ms=(e,t)=>{for(let r=e;r!==null&&t.contains(r);r=r.parentElement){const o=Le(r);if(o!==null)return{block:r,lines:o,own:!0}}let n=null;for(const r of t.querySelectorAll(At)){if(!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))break;const o=Le(r);o!==null&&(n={block:r,lines:o})}return n===null?null:{...n,own:!1}},hs=(e,t)=>{let n=0;for(let r=e.indexOf(t);r>=0;r=e.indexOf(t,r+t.length))n+=1;return n},sr=e=>e.closest(ds)!==null&&e.closest(us)===null,ar=(e,t,n)=>{const r=ms(e,t);if(r===null)return null;const{block:o,own:s}=r;if(!s){const i=r.lines.last+1;return{lines:{first:i,last:i},word:null,occurrence:0,clientTop:He(e)}}const a=ps(o,n);return a===null?{lines:r.lines,word:null,occurrence:0,clientTop:He(o)}:{lines:r.lines,word:a.text,occurrence:a.occurrence,clientTop:a.clientTop}},lr=(e,t)=>{let n=null,r=null,o=null;for(const a of e.querySelectorAll(At)){const i=Le(a);if(i===null)continue;n??=cr(t,a);const{top:m,bottom:f}=a.getBoundingClientRect();m<=n&&n<f?r={lines:i,block:a}:o===null&&m>=n&&(o={lines:i,block:a})}const s=r===null?o:r;return s===null?null:{lines:s.lines,word:null,occurrence:0,clientTop:He(s.block)}},ir=e=>e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,cr=(e,t)=>{const n=Number.parseFloat(getComputedStyle(t).scrollMarginTop);return ir(e)+(Number.isFinite(n)?n:0)},ps=(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>fs||/[\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:hs(o.toString(),r),clientTop:n.getBoundingClientRect().top}},gs=(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 i=r;i<=o;i+=1){const m=n[i-1]??"";for(let f=m.indexOf(t.word);f>=0;f=m.indexOf(t.word,f+t.word.length)){if(a===t.occurrence)return{line:i,column:f};a+=1}}return a>0?ws(n,r,o,t.word)??s:s},ws=(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},dr=(e,t)=>{let n=null,r=null;for(const o of e.querySelectorAll(At)){const s=Le(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},ur=(e,t)=>{const{bottom:n}=e.getBoundingClientRect(),r=He(e),o=Le(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},He=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:i}=s.getBoundingClientRect();if(i>0)return a}return e.getBoundingClientRect().top},Mt=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})}),vs=e=>Mt[e],Oe=()=>{const e=te.useNavigate();return d.useCallback((t,n)=>{e(t,Mt[n])},[e])},fr=({navigation:e,...t})=>l.jsx(te.Link,{...t,...Mt[e]}),Nt=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},mr=(e,t)=>{const n=d.useRef(null),r=d.useRef(null),o=d.useRef(null),s=d.useCallback(()=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,r.current=null},[]);d.useEffect(()=>s,[s]);const a=d.useCallback(f=>{if(r.current!==f)return;const c=o.current;if(c!==null){c.then(()=>a(f));return}e.prefetch(f);const u=e.peek(f);if(u?.status!=="pending")return;const h=Promise.allSettled([u.promise]);o.current=h,h.then(()=>{o.current===h&&(o.current=null)})},[e]),i=d.useCallback(f=>{const c=t(f);c!==r.current&&(s(),c!==null&&(r.current=c,n.current=window.setTimeout(()=>{n.current=null,a(c)},H.PREFETCH_DWELL_MS)))},[s,t,a]),m=d.useCallback(f=>{t(f)!==r.current&&s()},[s,t]);return d.useMemo(()=>({onPointerOver:f=>i(f.target),onPointerOut:f=>m(f.relatedTarget),onFocus:f=>i(f.target),onBlur:f=>m(f.relatedTarget)}),[i,m])},Es=d.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-B0QLIVf3.cjs")).then(e=>({default:e.NativeScrollBar})));class xs extends d.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 hr=({scroller:e,withCircle:t})=>l.jsx(xs,{children:l.jsx(d.Suspense,{fallback:null,children:l.jsx(Es,{scroller:e,withCircle:t})})}),pr=e=>l.jsx(hr,{scroller:e,withCircle:!0}),bs=8,Xe=H.CONTROL_BLOCK_PIXELS,gr=H.FIBONACCI_SPACING_PIXELS[3],Dt=Xe+2*gr,Ss=-(Xe+gr),wr=Object.freeze({minSpeedMultiplier:.25,maxSpeedMultiplier:18});let vr=null,st=null;const St=new Set,ys=e=>(St.add(e),()=>{St.delete(e)}),ks=()=>{st===null&&(st=Promise.resolve().then(()=>require("./tapScrollCircle-37FU6daT.cjs")).then(e=>{const t=e.TAP_SCROLL_CIRCLE.renderVisual;if(t===void 0)throw new TypeError("[markdown-explorer] the bars' tap-scroll circle has no look to share");vr=t;for(const n of[...St])n()}).catch(e=>{st=null,console.error("[markdown-explorer] the look of a table's tap-scroll circle failed to load; the circle still scrolls without it.",e)}))},Rs=({look:e,state:t})=>e(t),Ts=e=>{const t=d.useSyncExternalStore(ys,()=>vr,()=>null);return d.useEffect(()=>{t===null&&ks()},[t]),t===null?null:l.jsx(Rs,{look:t,state:e})},Er=Object.freeze({renderVisual:e=>l.jsx(Ts,{...e}),...wr,size:Xe}),xr=()=>{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()]}},ze=(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)=>ze(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)&&ze(n[s],r[s]))},Ls=55e3,Jt=Object.freeze({status:"deferred"}),at=Object.freeze({status:"refreshed"}),lt=Object.freeze({status:"shown",failed:!1}),je=Object.freeze({status:"shown",failed:!0}),Pe=Object.freeze({status:"superseded"}),le=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,Cs=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",Os=({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=xr(),o=xe(),s=new WeakSet,a=new Map,i=new Map,m=new Map;let f=0;const c=o.emit,u=()=>(f+=1,f),h=()=>{if(!(n.size<=t))for(const x of[...n.keys()]){if(n.size<=t)return;r.isHeld(x)||n.delete(x)}},w=(x,k)=>{n.delete(x),n.set(x,k)},E=x=>performance.now()-x.validatedAt>=Ls,b=(x,k,A)=>{const M=n.get(x),P=le(M?.snapshot),B=A||M?.refreshPending===!0,G=Te(e.document(x,{refresh:B}).then(S=>({status:"loaded",document:S}))),v={snapshot:{status:"pending",promise:G,previous:P},validatedAt:performance.now(),opened:k,background:null,refreshPending:!1,seeded:void 0,stamp:u()};return w(x,v),h(),G.then(S=>{n.get(x)===v&&(v.snapshot=S,v.stamp=u(),c())}),v},T=(x,k,A,M,P,B)=>{k.background===A&&(k.background=null,!(n.get(x)!==k||k.snapshot!==M)&&(P.kind==="failure"&&M.document.kind!=="failure"||(k.validatedAt=B,k.stamp=u(),ze(M.document,P)||(k.snapshot={status:"loaded",document:P}),c())))},O=async(x,k)=>{const A=k.snapshot;if(A.status!=="loaded")return null;const M={};k.background=M;const P=performance.now(),B=e.document(x,{refresh:k.refreshPending});k.refreshPending=!1;const G=await B,v=k.background===M&&n.get(x)===k&&k.snapshot===A;return T(x,k,M,A,G,P),v?G:null},L=(x,k)=>{const{snapshot:A}=k;return A.status==="pending"?!1:A.status==="loaded"&&A.document.kind!=="failure"?(O(x,k),!1):(A.status==="loaded"&&s.add(A),b(x,!0,!1),!0)},q=x=>{i.delete(x);const k=m.get(x);if(k!==void 0){m.delete(x);for(const A of k)A()}},j=(x,k)=>new Promise(A=>{if(i.get(x)===k||!r.isHeld(x)){A();return}const M=m.get(x);M===void 0?m.set(x,new Set([A])):M.add(A)}),p=(x,k)=>{const A=a.get(x);if(A===void 0){k.resolve(null);return}if(A.last!==null&&A.last.stamp>=k.stamp){k.resolve(A.last);return}A.waiters.add(k)},g=async(x,k,A)=>{const M=await new Promise(P=>p(x,{stamp:k.stamp,resolve:P}));if(n.get(x)!==k)return Pe;if(M===null)return A?at:lt;if(!A)return M.failure===null?lt:je;switch(M.before){case"copy":return M.failure===null?at:{status:"failed",failure:M.failure};case"failure":return M.failure===null?lt:je;case"none":return M.failure===null?at:je}},R=x=>{const k={showing:"none",last:null,waiters:new Set};a.set(x,k);let A=!1;return{settle:(M,P)=>{if(A||M===void 0)return;const B={stamp:M,failure:P,before:k.showing};k.last=B,P===null?k.showing="copy":k.showing==="none"&&(k.showing="failure");for(const G of[...k.waiters])M<G.stamp||(k.waiters.delete(G),G.resolve(B))},release:()=>{if(A)return;A=!0,a.get(x)===k&&a.delete(x);const M=[...k.waiters];k.waiters.clear(),M.length>0&&queueMicrotask(()=>{for(const P of M)p(x,P)})}}},N=x=>{const k=r.hold(x);let A=!1;return()=>{if(A)return;A=!0,k();const M=n.get(x);M!==void 0&&w(x,M),h(),r.isHeld(x)||queueMicrotask(()=>{r.isHeld(x)||q(x)})}};return{peek:x=>n.get(x)?.snapshot,peekSeeded:x=>n.get(x)?.seeded,answerStampOf:x=>n.get(x)?.stamp,prefetch:x=>{const k=n.get(x);k!==void 0&&k.snapshot.status!=="deferred"||(b(x,!1,!1),c())},open:x=>{const k=r.resumes(x),A=N(x),M=n.get(x);if(M===void 0||M.snapshot.status==="deferred")return b(x,!0,!1),c(),A;if(w(x,M),k)return A;const{snapshot:P}=M;return P.status==="pending"?(M.opened=!0,A):P.document.kind==="failure"?(M.opened||E(M)?(s.add(P),b(x,!0,!1),c()):M.opened=!0,A):(M.opened=!0,M.background===null&&E(M)&&O(x,M),A)},retain:N,retry:x=>{const k=n.get(x);k===void 0||k.snapshot.status!=="loaded"||k.snapshot.document.kind!=="failure"||(b(x,!0,!1),c())},seed:(x,k)=>{const A=performance.now(),M=Te(k.then(S=>S===null?Jt:{status:"loaded",document:S},()=>Jt)),P=n.get(x);if(P!==void 0&&P.snapshot.status==="loaded"){const S=P.snapshot,C={};P.background=C,M.then(D=>{if(D.status==="loaded"){T(x,P,C,S,D.document,A);return}P.background===C&&(P.background=null)});return}const B=P!==void 0&&P.snapshot.status==="pending"?P.snapshot.previous:null,G={status:"pending",promise:M,previous:B},v={snapshot:G,validatedAt:A,opened:P?.opened===!0,background:null,refreshPending:P?.refreshPending===!0,seeded:G,stamp:u()};w(x,v),h(),M.then(S=>{n.get(x)===v&&(S.status==="deferred"&&r.isHeld(x)?b(x,v.opened,!1):(v.snapshot=S,v.stamp=u()),c())})},invalidate:()=>{let x=!1;for(const[k,A]of[...n]){if(A.validatedAt=Number.NEGATIVE_INFINITY,A.opened=!0,A.refreshPending=!0,!r.isHeld(k))continue;const{snapshot:M}=A;if(M.status!=="pending"){L(k,A)&&(x=!0);continue}M.promise.then(()=>{n.get(k)===A&&A.refreshPending&&r.isHeld(k)&&L(k,A)&&c()})}x&&c()},refresh:async x=>{const k=n.get(x);if(k!==void 0&&Cs(k.snapshot)){k.refreshPending=!0;const P=await O(x,k);return P===null?Pe:P.kind==="failure"?{status:"failed",failure:P.failure}:g(x,k,!0)}const A=b(x,!0,!0);if(c(),A.snapshot.status!=="pending")return Pe;const M=await A.snapshot.promise;return n.get(x)!==A||M.status!=="loaded"?Pe:M.document.kind==="failure"?je:(await j(x,M),g(x,A,!1))},clear:()=>{n.clear();for(const x of r.heldKeys())b(x,!0,!1);c()},subscribe:o.subscribe,readPart:R,noteShown:(x,k)=>{i.set(x,k);const A=m.get(x);if(A!==void 0){m.delete(x);for(const M of A)M()}},noteFailureShown:x=>s.has(x)?!1:(s.add(x),!0)}},de=d.createContext("fill"),As="--aqmx-tap-circle-gutter",Ms=Object.freeze({blockSize:"100%",[As]:`${String(Dt)}px`}),Ae=({scrollerProps:e,children:t})=>d.use(de)==="content"?l.jsx(Ee.HostedScrollArea,{scrollerProps:e,children:t}):l.jsx(Ee.HostedScrollArea,{scrollerProps:{...e,style:Ms},rowClassName:"aqmx-document-scroll-row",renderScrollBar:pr,children:t}),Ns=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),Ds=Object.freeze({className:"aqmx-document-failure","data-aqmx-document-scroller":""}),ue=({label:e,testId:t})=>l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":t,children:Ns.map(n=>l.jsx("span",{},n))}),l.jsx("p",{className:"aqmx-sr-only",children:e})]}),jt=({failure:e,onRetry:t,testId:n})=>l.jsx(Ae,{scrollerProps:Ds,children:l.jsx(ce,{failure:e,alert:!1,onRetry:t,testId:n})});function js({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M18 5.25a2.25 2.25 0 0 0-2.012-2.238A2.25 2.25 0 0 0 13.75 1h-1.5a2.25 2.25 0 0 0-2.238 2.012c-.875.092-1.6.686-1.884 1.488H11A2.5 2.5 0 0 1 13.5 7v7h2.25A2.25 2.25 0 0 0 18 11.75v-6.5ZM12.25 2.5a.75.75 0 0 0-.75.75v.25h3v-.25a.75.75 0 0 0-.75-.75h-1.5Z",clipRule:"evenodd"}),y.createElement("path",{fillRule:"evenodd",d:"M3 6a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H3Zm6.874 4.166a.75.75 0 1 0-1.248-.832l-2.493 3.739-.853-.853a.75.75 0 0 0-1.06 1.06l1.5 1.5a.75.75 0 0 0 1.154-.114l3-4.5Z",clipRule:"evenodd"}))}const Ps=y.forwardRef(js);function _s({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M15.988 3.012A2.25 2.25 0 0 1 18 5.25v6.5A2.25 2.25 0 0 1 15.75 14H13.5v-3.379a3 3 0 0 0-.879-2.121l-3.12-3.121a3 3 0 0 0-1.402-.791 2.252 2.252 0 0 1 1.913-1.576A2.25 2.25 0 0 1 12.25 1h1.5a2.25 2.25 0 0 1 2.238 2.012ZM11.5 3.25a.75.75 0 0 1 .75-.75h1.5a.75.75 0 0 1 .75.75v.25h-3v-.25Z",clipRule:"evenodd"}),y.createElement("path",{d:"M3.5 6A1.5 1.5 0 0 0 2 7.5v9A1.5 1.5 0 0 0 3.5 18h7a1.5 1.5 0 0 0 1.5-1.5v-5.879a1.5 1.5 0 0 0-.44-1.06L8.44 6.439A1.5 1.5 0 0 0 7.378 6H3.5Z"}))}const Is=y.forwardRef(_s);function Fs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",clipRule:"evenodd"}))}const $s=y.forwardRef(Fs),qs=2e3,en=Object.freeze({outcome:"idle"}),Bs=e=>{const t=navigator.clipboard;return t===void 0?Promise.reject(new Error("[markdown-explorer] this browser has no asynchronous clipboard")):t.writeText(e)},Us=({text:e})=>{const{announcer:t,labels:n}=F(),[r,o]=d.useState(en);d.useEffect(()=>{if(r.outcome==="idle")return;const m=setTimeout(()=>o(en),qs);return()=>clearTimeout(m)},[r]);const s=m=>{o({outcome:m}),t.announce(m==="copied"?n.copiedText:n.copyTextFailed)},a=()=>{Bs(e).then(()=>s("copied"),()=>s("failed"))},i=r.outcome==="copied"?n.copiedText:r.outcome==="failed"?n.copyTextFailed:n.copyText;return l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":n.copyText,title:i,onClick:a,"data-aqmx-copy-outcome":r.outcome,"data-testid":"markdown-explorer-file-copy",children:r.outcome==="copied"?l.jsx(Ps,{}):r.outcome==="failed"?l.jsx($s,{}):l.jsx(Is,{})})},br=d.createContext(null),Hs=()=>{const e=d.use(br);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 zs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M10.75 2.75a.75.75 0 0 0-1.5 0v8.614L6.295 8.235a.75.75 0 1 0-1.09 1.03l4.25 4.5a.75.75 0 0 0 1.09 0l4.25-4.5a.75.75 0 0 0-1.09-1.03l-2.955 3.129V2.75Z"}),y.createElement("path",{d:"M3.5 12.75a.75.75 0 0 0-1.5 0v2.5A2.75 2.75 0 0 0 4.75 18h10.5A2.75 2.75 0 0 0 18 15.25v-2.5a.75.75 0 0 0-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5Z"}))}const Vs=y.forwardRef(zs);function Zs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.25 5.5a.75.75 0 0 0-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75v-4a.75.75 0 0 1 1.5 0v4A2.25 2.25 0 0 1 12.75 17h-8.5A2.25 2.25 0 0 1 2 14.75v-8.5A2.25 2.25 0 0 1 4.25 4h5a.75.75 0 0 1 0 1.5h-5Z",clipRule:"evenodd"}),y.createElement("path",{fillRule:"evenodd",d:"M6.194 12.753a.75.75 0 0 0 1.06.053L16.5 4.44v2.81a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.553l-9.056 8.194a.75.75 0 0 0-.053 1.06Z",clipRule:"evenodd"}))}const Ws=y.forwardRef(Zs),Me=({name:e,openUrl:t,downloadUrl:n,icon:r,children:o})=>{const{labels:s}=F();return l.jsxs("div",{className:"aqmx-document-toolbar",children:[l.jsx("span",{className:"aqmx-document-file-icon","aria-hidden":"true",children:r}),l.jsx("span",{className:"aqmx-document-title",title:e,"data-testid":"markdown-explorer-file-name",children:e}),o,l.jsx("a",{className:"aqmx-icon-button",href:t,target:"_blank",rel:"noopener noreferrer","aria-label":s.openInNewTab,title:s.openInNewTab,"data-testid":"markdown-explorer-file-open",children:l.jsx(Ws,{})}),l.jsx("a",{className:"aqmx-icon-button",href:n,download:e,"aria-label":s.download,title:s.download,"data-testid":"markdown-explorer-file-download",children:l.jsx(Vs,{})})]})};function Gs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm4.75 6.75a.75.75 0 0 1 1.5 0v2.546l.943-1.048a.75.75 0 0 1 1.114 1.004l-2.25 2.5a.75.75 0 0 1-1.114 0l-2.25-2.5a.75.75 0 1 1 1.114-1.004l.943 1.048V8.75Z",clipRule:"evenodd"}))}const Ks=y.forwardRef(Gs),Xs=Object.freeze({className:"aqmx-document-stage"}),Ys=({document:e})=>{const{labels:t}=F();return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[l.jsx(Me,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(Ks,{})}),l.jsx(Ae,{scrollerProps:Xs,children:l.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-file-not-shown",children:[l.jsx("p",{className:"aqmx-callout-body",children:t.fileNotShown}),l.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-file-not-shown-download",children:t.download})]})})]})},tn=["keydown","pointerdown","wheel","touchstart"],$e=new WeakMap,Ve=new WeakMap,Qs=e=>{const t=Ve.get(e);if(t!==void 0){t.count+=1;return}Ve.set(e,{count:1,original:e.style.overflowAnchor}),e.style.overflowAnchor="none"},Js=e=>{const t=Ve.get(e);t!==void 0&&(t.count-=1,!(t.count>0)&&(Ve.delete(e),e.style.overflowAnchor=t.original))},ea=(e,t,n)=>{for(let r=t;r!==null&&r!==n;r=r.parentElement){e.observe(r);for(let o=r.previousElementSibling;o!==null;o=o.previousElementSibling)e.observe(o)}},ta=e=>{const t=new Map;for(let n=e.parentElement;n!==null;n=n.parentElement)t.set(n,{top:n.scrollTop,left:n.scrollLeft});return t},Sr=e=>{$e.get(e)?.()},yr=(e,t,n)=>{Sr(e);let r=new Map;const o=new Set,s=()=>{const u=t();return u===null?!1:(r=ta(u),!0)};if(!s()||typeof ResizeObserver>"u")return;const a=()=>{for(const u of r.keys())!(u instanceof HTMLElement)||o.has(u)||(o.add(u),Qs(u))};a();const{ownerDocument:i}=e,m=new ResizeObserver(()=>{if(!s()){c();return}a()});for(const{element:u,boundary:h}of n)ea(m,u,h);const f=u=>{const h=u.target===i?i.scrollingElement:u.target;if(!(h instanceof Element))return;const w=r.get(h);w!==void 0&&(h.scrollTop!==w.top||h.scrollLeft!==w.left)&&c()},c=()=>{m.disconnect();for(const u of tn)i.removeEventListener(u,c,!0);i.removeEventListener("scroll",f,!0);for(const u of o)Js(u);o.clear(),$e.get(e)===c&&$e.delete(e)};for(const u of tn)i.addEventListener(u,c,{capture:!0,passive:!0});i.addEventListener("scroll",f,{capture:!0,passive:!0}),$e.set(e,c)},Ye="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",na=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},ra=/(%[0-9A-Fa-f]{2})/u,Pt=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(ra).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))},kr=e=>`#${encodeURIComponent(e)}`,oa=e=>{if(e==="#")return!0;const t=Pt(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},Rr=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},sa="http://www.w3.org/1999/xhtml",nn=(e,t)=>{if(t==="")return null;const n=Rr(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===sa&&r.getAttribute("name")===t)return r;return null},Tr=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=nn(e,t.slice(1));if(n!==null)return n;const r=Pt(t);return r===null?null:nn(e,r)},rn=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"},aa=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"},la=(e,t)=>{const n=t.closest(Ye),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&rn(r))return r;const o=e.getBoundingClientRect().height,{documentElement:s,scrollingElement:a}=e.ownerDocument;for(let i=e.parentElement;i!==null&&i!==s;i=i.parentElement)if(rn(i)&&i.scrollHeight>i.clientHeight&&i.clientHeight<o)return i;return a instanceof Element&&aa(e.ownerDocument)&&a.scrollHeight>a.clientHeight&&a.clientHeight<o?a:r},ia=Object.freeze({scrollerOf:la,reveal:e=>{e.scrollIntoView(Ze)},keepAtStart:(e,t)=>{yr(e,()=>t.isConnected?(Lr(e,t),t):null,[{element:t,boundary:e}])}}),Ze=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),ca=(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")}}},Lr=(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(),i=a.height+s+Number.parseFloat(o)>e.clientHeight;if(!i&&Math.abs(a.top-s-n)<1){t.scrollIntoView(Ze);return}e.scrollBy({top:i?a.top-n-e.clientHeight:a.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(Ze)},da=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(Ye)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},on=(e,t,n)=>{if(e===null)return null;const r=Tr(e,t);return r===null?(oa(t)&&da(e,n),null):(ca(e,r),n.keepAtStart(n.scrollerOf(e,r),r),r)};function ua({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M3.28 2.22a.75.75 0 0 0-1.06 1.06L5.44 6.5H2.75a.75.75 0 0 0 0 1.5h4.5A.75.75 0 0 0 8 7.25v-4.5a.75.75 0 0 0-1.5 0v2.69L3.28 2.22ZM13.5 2.75a.75.75 0 0 0-1.5 0v4.5c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-2.69l3.22-3.22a.75.75 0 0 0-1.06-1.06L13.5 5.44V2.75ZM3.28 17.78l3.22-3.22v2.69a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.69l-3.22 3.22a.75.75 0 1 0 1.06 1.06ZM13.5 14.56l3.22 3.22a.75.75 0 1 0 1.06-1.06l-3.22-3.22h2.69a.75.75 0 0 0 0-1.5h-4.5a.75.75 0 0 0-.75.75v4.5a.75.75 0 0 0 1.5 0v-2.69Z"}))}const fa=y.forwardRef(ua);function ma({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M6.75 8.25a.75.75 0 0 0 0 1.5h4.5a.75.75 0 0 0 0-1.5h-4.5Z"}),y.createElement("path",{fillRule:"evenodd",d:"M9 2a7 7 0 1 0 4.391 12.452l3.329 3.328a.75.75 0 1 0 1.06-1.06l-3.328-3.329A7 7 0 0 0 9 2ZM3.5 9a5.5 5.5 0 1 1 11 0 5.5 5.5 0 0 1-11 0Z",clipRule:"evenodd"}))}const ha=y.forwardRef(ma);function pa({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M9 6a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0v-1.5h-1.5a.75.75 0 0 1 0-1.5h1.5v-1.5A.75.75 0 0 1 9 6Z"}),y.createElement("path",{fillRule:"evenodd",d:"M2 9a7 7 0 1 1 12.452 4.391l3.328 3.329a.75.75 0 1 1-1.06 1.06l-3.329-3.328A7 7 0 0 1 2 9Zm7-5.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11Z",clipRule:"evenodd"}))}const ga=y.forwardRef(pa);function wa({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M1 5.25A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25v9.5A2.25 2.25 0 0 1 16.75 17H3.25A2.25 2.25 0 0 1 1 14.75v-9.5Zm1.5 5.81v3.69c0 .414.336.75.75.75h13.5a.75.75 0 0 0 .75-.75v-2.69l-2.22-2.219a.75.75 0 0 0-1.06 0l-1.91 1.909.47.47a.75.75 0 1 1-1.06 1.06L6.53 8.091a.75.75 0 0 0-1.06 0l-2.97 2.97ZM12 7a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",clipRule:"evenodd"}))}const va=y.forwardRef(wa),yt="data-aqmx-key-repeat",We=Object.freeze({[yt]:"allow"}),Ea=`[${yt}="${We[yt]}"]`,xa=()=>{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(Ea)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},qe=Object.freeze([1/H.GOLDEN_RATIO**2,1/H.GOLDEN_RATIO,1,H.GOLDEN_RATIO,H.GOLDEN_RATIO**2]),sn=Object.freeze({mode:"fit"}),ba=1,Cr=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),an=`[data-testid="${Cr["data-testid"]}"]`,Or=d.createContext(null),Sa=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=ba?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,ln=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<qe.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?qe.findIndex(o=>o>t):qe.findLastIndex(o=>o<t);return r===-1?null:r},cn=(e,t,n)=>{if(e.mode==="level"){const o=ln(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=ln(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},ya=(e,t)=>{if(e<=0||t<=0)return 0;const n=Math.trunc(Math.log(t/e)/Math.log(H.GOLDEN_RATIO));return n===0?0:n},dn=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}}},ka=e=>{const t=qe[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},un=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},Ra=({document:e})=>{const{labels:t}=F(),n=d.use(Or),[r]=d.useState(()=>n===null?null:n.read(e.url)),[o,s]=d.useState(r===null?sn:r.zoom),[a,i]=d.useState(r===null?null:r.reported),[m,f]=d.useState(null),c=d.useRef(null),u=d.useCallback(j=>{const{naturalWidth:p,naturalHeight:g}=j;i(R=>un(R,p,g))},[]),h=d.useCallback(j=>{c.current=j,!(j===null||!j.complete)&&(j.naturalWidth>0||j.naturalHeight>0?u(j):j.decode().then(()=>u(j),()=>{}))},[u]);d.useEffect(()=>{n!==null&&a!==null&&n.save(e.url,{zoom:o,reported:a})},[n,e.url,o,a]),d.useLayoutEffect(()=>{const j=c.current;if(j===null||a===null||o.mode!=="fit")return;const p=()=>f(R=>un(R,j.clientWidth,j.clientHeight));if(p(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(p);return g.observe(j),()=>g.disconnect()},[a,o.mode]);const w=a===null||m===null?null:Sa(a,m),E=cn(o,w,-1),b=cn(o,w,1),T=o.mode==="level"?ka(o.index):null,O=d.useRef({zoomIn:b,zoomOut:E});d.useLayoutEffect(()=>{O.current={zoomIn:b,zoomOut:E}});const L=d.useRef(null);d.useLayoutEffect(()=>{const j=L.current,p=c.current?.closest(an);L.current=null,!(j===null||p===null||p===void 0)&&(p.scrollLeft=j.across*p.scrollWidth-j.x,p.scrollTop=j.down*p.scrollHeight-j.y)},[o]),d.useEffect(()=>{const j=c.current?.closest(an);if(j==null)return;let p=null;const g=I=>{const $=dn(I.touches);p=$===null?null:{distance:$.distance,steps:0}},R=I=>{const $=dn(I.touches);if(p===null||$===null)return;I.preventDefault();const x=ya(p.distance,$.distance);if(x===p.steps)return;const k=x>p.steps?1:-1,A=k===1?O.current.zoomIn:O.current.zoomOut;if(A===null)return;p.steps+=k;const M=j.getBoundingClientRect(),P=$.middle.x-M.left,B=$.middle.y-M.top;L.current=j.scrollWidth>0&&j.scrollHeight>0?{x:P,y:B,across:(j.scrollLeft+P)/j.scrollWidth,down:(j.scrollTop+B)/j.scrollHeight}:null,s(A)},N=I=>{I.touches.length<2&&(p=null)};return j.addEventListener("touchstart",g,{passive:!0}),j.addEventListener("touchmove",R,{passive:!1}),j.addEventListener("touchend",N,{passive:!0}),j.addEventListener("touchcancel",N,{passive:!0}),()=>{j.removeEventListener("touchstart",g),j.removeEventListener("touchmove",R),j.removeEventListener("touchend",N),j.removeEventListener("touchcancel",N)}},[]);const q=o.mode==="level"&&T!==null?{width:`${o.base.width*T}px`,height:`${o.base.height*T}px`}:void 0;return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[l.jsxs(Me,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(va,{}),children:[l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":E===null,onClick:()=>{E!==null&&s(E)},...We,children:l.jsx(ha,{})}),l.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:T===null?t.imageFitLevel:t.imageZoomLevel(Math.round(T*100))}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":b===null,onClick:()=>{b!==null&&s(b)},...We,children:l.jsx(ga,{})}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(sn),children:l.jsx(fa,{})})]}),l.jsx(Ae,{scrollerProps:Cr,children:l.jsx("img",{ref:h,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:q,onLoad:j=>u(j.currentTarget),"data-testid":"markdown-explorer-image"})})]})},Ta=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"}},Ar=d.createContext(null),Qe=d.createContext(void 0),Mr=d.createContext(null),Je=()=>{const e=d.use(Ar);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},La=()=>{const e=d.use(Mr);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},et=(e,t,n,r)=>t.kind==="panel"?H.explorerHref(e,{view:"tree",source:n,doc:r}):t.view==="single"?H.explorerHref(e,{view:"single",source:n,doc:r,overrides:t.overrides,embed:t.embed}):H.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides}),Ca=({children:e})=>{const{config:t}=F(),n=Je(),r=Ke(),o=r.kind==="location"?r.location.source:void 0,s=te.useHref(et(t,n.navigation,o,n.currentPath));return l.jsx(Qe,{value:o,children:l.jsx(Mr,{value:s,children:e})})},Oa='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',Aa=e=>{const t=e instanceof Element?e.closest(Oa):null;return t===null?null:t.getAttribute("data-doc-path")},tt=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Ma=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:a,scope:i,children:m})=>{const f=te.useHref(e),c=u=>{if(tt(u)){if(u.preventDefault(),t===i.currentPath&&n!==""){i.scrollWithin(n);return}a(t,n)}};return l.jsx("a",{...s,href:f,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:c,children:m})},Na=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:a}=F(),i=Je(),m=d.use(Qe),f=na(e),{navigation:c}=i,u=`${et(a,c,m,t)}${f}`,h=n===!1?"false":void 0;return c.kind==="page"?l.jsx(fr,{...o,to:u,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":h,children:s}):l.jsx(Ma,{to:u,docPath:t,fragment:f,exists:h,className:r,attributes:o,onDocumentLink:c.onDocumentLink,scope:i,children:s})},Da=({className:e,attributes:t,children:n})=>{const{labels:r}=F();return l.jsxs("a",{...t,className:e===void 0?"aqmx-document-inert-link":`${e} aqmx-document-inert-link`,title:r.inertLink,"data-link-kind":"doc","data-doc-exists":"false",children:[n,l.jsxs("span",{className:"aqmx-sr-only",children:[" (",r.inertLink,")"]})]})},ja=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=F(),a=d.use(Qe),i=te.useHref(`${et(s,r.navigation,a,r.currentPath)}${e}`),m=f=>{tt(f)&&(f.preventDefault(),r.scrollWithin(e))};return l.jsx("a",{...n,href:i,className:t,onClick:m,children:o})},Pa=({href:e,className:t,attributes:n,children:r})=>{const o=Je();if(o.navigation.kind==="page"){const s=a=>{if(!tt(a))return;const i=a.currentTarget;e==="#"?o.followEmptyFragment(a.nativeEvent):i.href===i.ownerDocument.URL&&o.followSameUrlJump(e,a.nativeEvent)};return l.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return l.jsx(ja,{href:e,className:t,attributes:n,scope:o,children:r})},_a=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:a})=>t==="doc"?n===void 0||!_.isAcceptableDocumentPath(n)?l.jsx(Da,{className:o,attributes:s,children:a}):l.jsx(Na,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:a}):e.startsWith("#")?l.jsx(Pa,{href:e,className:o,attributes:s,children:a}):l.jsx("a",{...s,href:e,className:o,children:a}),Ia=()=>{const{config:e}=F(),t=Je(),n=d.use(Qe),r=Oe();return d.useCallback((o,s)=>{if(!tt(s))return!0;s.preventDefault();const a=kr(o.id),{navigation:i}=t;return i.kind==="panel"||Pt(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(a),!0):(r(`${et(e,i,n,t.currentPath)}${a}`,"follow-link"),!0)},[e,t,n,r])},Fa=()=>{const e=La();return d.useCallback(t=>`${e}${kr(t.id)}`,[e])};function $a({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M3 3.5A1.5 1.5 0 0 1 4.5 2h6.879a1.5 1.5 0 0 1 1.06.44l4.122 4.12A1.5 1.5 0 0 1 17 7.622V16.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 16.5v-13Z"}))}const qa=y.forwardRef($a);function Ba({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M1 4.75C1 3.784 1.784 3 2.75 3h14.5c.966 0 1.75.784 1.75 1.75v10.515a1.75 1.75 0 0 1-1.75 1.75h-1.5c-.078 0-.155-.005-.23-.015H4.48c-.075.01-.152.015-.23.015h-1.5A1.75 1.75 0 0 1 1 15.265V4.75Zm16.5 7.385V11.01a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25Zm0 2.005a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .108.069.2.165.235h1.585a.25.25 0 0 0 .25-.25v-1.11Zm-15 1.11v-1.11a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.164.235H2.75a.25.25 0 0 1-.25-.25Zm2-4.24v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V11.01a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25Zm13-2.005V7.88a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25ZM4.25 7.63a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V7.88a.25.25 0 0 1 .25-.25h1.5Zm0-3.13a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5Zm11.5 1.625a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5Zm-9 3.125a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",clipRule:"evenodd"}))}const Ua=y.forwardRef(Ba);function Ha({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M17.721 1.599a.75.75 0 0 1 .279.583v11.29a2.25 2.25 0 0 1-1.774 2.2l-2.041.44a2.216 2.216 0 0 1-.938-4.332l2.662-.577a.75.75 0 0 0 .591-.733V6.112l-8 1.73v7.684a2.25 2.25 0 0 1-1.774 2.2l-2.042.44a2.216 2.216 0 1 1-.935-4.331l2.659-.573A.75.75 0 0 0 7 12.529V4.236a.75.75 0 0 1 .591-.733l9.5-2.054a.75.75 0 0 1 .63.15Z",clipRule:"evenodd"}))}const za=y.forwardRef(Ha),Va=Object.freeze({className:"aqmx-document-stage"}),Za=()=>()=>{},Wa=()=>navigator.pdfViewerEnabled!==!1,Ga=()=>null,Ka=({document:e})=>{const{labels:t}=F(),n=d.useSyncExternalStore(Za,Wa,Ga);return n===null?null:n?l.jsx("iframe",{className:"aqmx-document-frame",src:e.url,title:e.name,"data-testid":"markdown-explorer-media-player"}):l.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-pdf-not-shown",children:[l.jsx("p",{className:"aqmx-callout-body",children:t.pdfNotShown}),l.jsxs("div",{className:"aqmx-callout-actions",children:[l.jsx("a",{className:"aqmx-callout-action",href:e.url,target:"_blank",rel:"noopener noreferrer","data-testid":"markdown-explorer-pdf-not-shown-open",children:t.openInNewTab}),l.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-pdf-not-shown-download",children:t.download})]})]})},Xa=e=>{switch(e){case"video":return l.jsx(Ua,{});case"audio":return l.jsx(za,{});case"pdf":return l.jsx(qa,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},Ya=({document:e})=>{const{labels:t}=F();switch(e.mediaType){case"video":return l.jsx("video",{className:"aqmx-document-video",src:e.url,controls:!0,preload:"metadata","aria-label":e.name,"data-testid":"markdown-explorer-media-player",children:t.mediaUnsupported});case"audio":return l.jsx("audio",{className:"aqmx-document-audio",src:e.url,controls:!0,preload:"metadata","aria-label":e.name,"data-testid":"markdown-explorer-media-player",children:t.mediaUnsupported});case"pdf":return l.jsx(Ka,{document:e});default:{const n=e.mediaType;throw new RangeError(`[markdown-explorer] unknown media type ${String(n)}`)}}},Qa=({document:e})=>l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[l.jsx(Me,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:Xa(e.mediaType)}),l.jsx(Ae,{scrollerProps:Va,children:l.jsx(Ya,{document:e})})]}),_t=e=>{switch(e.kind){case"markdown":return"markdown";case"image":return e.imageType==="svg"?"svg":null;case"spreadsheet":return e.format==="workbook"?null:e.format;default:return null}},Ja=e=>{const{documents:t}=F(),n=d.useCallback(()=>t.peek(e),[t,e]),r=d.useCallback(()=>t.peekSeeded(e),[t,e]),o=d.useSyncExternalStore(t.subscribe,n,r),s=le(o);return s===null?null:_t(s.document)},Nr=e=>{const{config:t}=F(),n=Oe(),r=d.useCallback(()=>n(H.explorerHref(t,{...e,markup:!e.markup}),"browse"),[t,n,e]);return d.useMemo(()=>({shown:e.markup,toggle:r}),[e.markup,r])};function el({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"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 tl=y.forwardRef(el),nl=100,rl=32767,Be=Object.freeze({maxCells:Gt.SPREADSHEET_MAX_OPERATION_CELLS,maxColumns:Gt.SPREADSHEET_MAX_OPERATION_CELLS/nl,maxCellLength:rl}),Dr=44,jr=10,Pr=13,_e='"',fn=(e,t)=>{let n=t;for(;n<e.length;){const r=e.charCodeAt(n);if(r===Dr||r===jr||r===Pr)return n;n+=1}return n};function*ol(e,t){let n=[],r=0;for(;;){let o;if(e.startsWith(_e,r)){o="";let a=r+1;for(;;){const m=e.indexOf(_e,a);if(m<0){o+=e.slice(a),r=e.length;break}if(o+=e.slice(a,m),e.startsWith(_e,m+1)){o+=_e,a=m+2;continue}r=m+1;break}const i=fn(e,r);o+=e.slice(r,i),r=i}else{const a=fn(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!==Dr&&(yield n,n=[],s===Pr&&e.charCodeAt(r)===jr&&(r+=1),r>=e.length))return}}const sl=(e,t,n)=>t==="csv"?ol(e,n):n==="whole"?vt.iterateTsvRows(e):vt.iterateTsvPrefixRows(e),al=(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)},_r=(e,t)=>{const n=[];let r=0,o=!1,s=!1;for(const i of e){const m=i.length>t.maxColumns?i.slice(0,t.maxColumns):i,f=Math.max(r,m.length);if((n.length+1)*f>t.maxCells){s=!0;break}const c=m.some(u=>u.length>t.maxCellLength)?m.map(u=>al(u,t.maxCellLength)):m;c!==i&&(o=!0),n.push(c),r=f}return{rows:n.map(i=>i.length===r?i:[...i,...Array(r-i.length).fill("")]),truncated:s||o,full:s}},it=(e,t,n,r,o)=>{const s=H.decodeText(e,t,r);if(s===null)return{kind:"unreadable",code:"encoding",encodings:H.textEncodingsOf(e,t,r)};if(s.includes("\0"))return{kind:"unreadable",code:"binary"};const a=_r(sl(s,n,t?"whole":"prefix"),o);return t?a.truncated||a.rows.some(i=>i.some(m=>m!==""))?{kind:"table",table:a}:{kind:"empty"}:a.rows.length===0?{kind:"unreadable",code:"long-row"}:{kind:"table",table:{...a,truncated:!0}}},ll=Object.freeze({maxPartBytes:64*1024*1024,maxSheets:256}),Ir=e=>{const t=[];let n=0,r=!1;const o=s=>{if(r)return;const a=Math.max(n,Math.min(s.length,e.maxColumns));(t.length+1)*a>e.maxCells&&(r=!0),t.push(s),n=a};return{addRow:(s,a,i)=>{if(a.size===0||r)return;let m=-1;for(const u of a.keys())u>m&&(m=u);const f=Array(Math.min(m,e.maxColumns)+1).fill("");for(const[u,h]of a)u<=e.maxColumns&&(f[u]=h);const c=Math.min(f.length,e.maxColumns);if(n===0&&(s+1)*c>e.maxCells){const u=Math.floor(e.maxCells/c);for(;t.length<u;)t.push([]);o(f);return}for(;t.length<s&&!r;)o([]);for(let u=0;u<i&&!r;u+=1)o(u===0?f:[...f])},full:()=>r,table:()=>_r(t,e)}},il=e=>{const t=Array.from(e.currentTarget.querySelectorAll('[role="tab"]')),n=e.target instanceof HTMLButtonElement?t.indexOf(e.target):-1;if(n===-1)return;const r=getComputedStyle(e.currentTarget).direction==="rtl"?"ArrowRight":"ArrowLeft",o=r==="ArrowLeft"?"ArrowRight":"ArrowLeft",s=e.key===o?(n+1)%t.length:e.key===r?(n-1+t.length)%t.length:e.key==="Home"?0:e.key==="End"?t.length-1:null;s!==null&&(e.preventDefault(),t[s]?.focus())},cl=({names:e,selected:t,onSelect:n,label:r,tabIdOf:o,panelId:s})=>l.jsx("div",{role:"tablist","aria-label":r,className:"aqmx-sheet-tabs","data-testid":"markdown-explorer-spreadsheet-sheets",onKeyDown:il,children:e.map((a,i)=>l.jsx("button",{type:"button",role:"tab",id:o(i),"aria-selected":i===t,"aria-controls":s,tabIndex:i===t?0:-1,className:"aqmx-sheet-tab","data-aqmx-sheet-tab":i,onClick:()=>n(i),children:a},i))}),Fr=64*1024,dl=e=>{let t=new Uint8Array(Math.min(e,Fr)),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}},ul=async e=>{for(;;){const{done:t,value:n}=await e.read();if(t)return!0;if(n.byteLength>0)return!1}},fl=async(e,t)=>{const{format:n,legacyEncoding:r,maxBytes:o,budget:s}=t,a=e.getReader(),i=dl(o);let m=Fr;try{for(;;){const{done:f,value:c}=await a.read();if(f)return it(i.bytes(),!0,n,r,s);const u=o-i.length();if(i.append(c.byteLength>u?c.subarray(0,u):c),i.length()===o){const w=c.byteLength<=u&&await ul(a);return it(i.bytes(),w,n,r,s)}if(i.length()<m)continue;m=i.length()*2;const h=it(i.bytes(),!1,n,r,s);if(h.kind==="unreadable"&&h.code!=="long-row"||h.kind==="table"&&h.table.full)return h}}finally{a.cancel().catch(()=>{})}},$r=async(e,t,n,r)=>{const o=await e.asset(_.explorerPlainTextHref(t),r);if(o.status==="cancelled")return null;if(o.status==="error")return{kind:"failure",failure:o.failure};let s;try{s=await fl(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},It=(e,t,n)=>{const{documents:r,labels:o}=F(),s=Hs(),a=d.useCallback(()=>r.answerStampOf(e),[r,e]),i=d.useSyncExternalStore(r.subscribe,a,a),[m,f]=d.useState(0),c=d.useMemo(()=>({read:n,stamp:i,attempt:m}),[n,i,m]),[u,h]=d.useState({settled:null,shown:null,failure:null}),w=d.useRef(null),E=d.useEffectEvent((O,L)=>{if(w.current?.settle(L.stamp,O.kind==="failure"?O.failure:null),O.kind==="read"){h({settled:L,shown:O.value,failure:null});return}if(u.shown!==null){h({settled:L,shown:u.shown,failure:null});return}h({settled:L,shown:null,failure:O.failure}),s.announceFailure(o.documentFailed(t,re(o,O.failure.reason)))});d.useEffect(()=>{const O=s.readPart();return w.current=O,()=>{w.current=null,O.release()}},[s]),d.useEffect(()=>{const O=new AbortController;return c.read(O.signal).then(L=>{L!==null&&!O.signal.aborted&&E(L,c)}),()=>O.abort()},[c]);const b=u.settled!==c&&(u.shown!==null||u.failure!==null);d.useLayoutEffect(()=>b?s.holdBusy():void 0,[b,s]);const T=d.useCallback(()=>f(O=>O+1),[]);return{shown:u.shown,failure:u.failure,retry:T}},qr=(e,t)=>{const n={};for(const r of Object.keys(ve.SPREADSHEET_BLOCK_LABEL_CATALOGS[t])){const o=e[Lt(r)];o!==ve.SPREADSHEET_BLOCK_LABEL_CATALOGS[t][r].text&&(n[r]=o)}return n},ml=(e,t)=>Object.fromEntries(Object.entries(qr(e,t)).map(([n,r])=>[`spreadsheet${n.charAt(0).toUpperCase()}${n.slice(1)}`,r])),hl=(e,t)=>({...ml(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,mermaidFullscreen:e.viewerMermaidFullscreen,mermaidExitFullscreen:e.viewerMermaidExitFullscreen,mermaidFullscreenDialog:e.viewerMermaidFullscreenDialog,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,svgImageFullscreen:e.viewerSvgImageFullscreen,svgImageExitFullscreen:e.viewerSvgImageExitFullscreen,svgImageFullscreenDialog:e.viewerSvgImageFullscreenDialog}),Br=(e,t,n)=>t!==void 0?t:n!==void 0?n:e.defaultDocumentStyle,Ur=(e,t)=>e!==void 0?e:t!==void 0?t:Co.DEFAULT_CONTENT_ALIGN;class Y extends Error{refusal;constructor(t,n){super(n),this.name="WorkbookError",this.refusal=t}}const pl=new Map([["lt","<"],["gt",">"],["amp","&"],["quot",'"'],["apos","'"]]),gl=/&(#x[0-9A-Fa-f]+|#[0-9]+|[A-Za-z_][A-Za-z0-9._-]*);/gu,wl=/([^\s=/>]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/gu,vl=/^[^\s/>]+/u,ge=e=>{throw new Y("not-workbook",`the XML ${e}`)},mn=e=>Number.isInteger(e)&&e>=0&&e<=1114111?String.fromCodePoint(e):ge(`refers to the code point ${e}`),Hr=e=>e.includes("&")?e.replace(gl,(t,n)=>n.startsWith("#x")?mn(Number.parseInt(n.slice(2),16)):n.startsWith("#")?mn(Number.parseInt(n.slice(1),10)):pl.get(n)??ge(`names the undeclared entity ${t}`)):e,kt=e=>e.slice(e.indexOf(":")+1),El=(e,t)=>{let n="";for(let r=t;r<e.length;r+=1){const o=e[r];if(n!=="")o===n&&(n="");else if(o==='"'||o==="'")n=o;else if(o===">")return r}return-1},xl=e=>{const t=new Map;for(const n of e.matchAll(wl))t.set(kt(n[1]??""),Hr(n[2]??n[3]??""));return t},zr=(e,t)=>{let n="";const r=()=>{let o=0;for(;!t();){const s=n.indexOf("<",o);if(s===-1)break;if(s>o&&(e.text?.(Hr(n.slice(o,s))),o=s),n.startsWith("<!--",s)){const f=n.indexOf("-->",s+4);if(f===-1)break;o=f+3;continue}if(n.startsWith("<![CDATA[",s)){const f=n.indexOf("]]>",s+9);if(f===-1)break;e.text?.(n.slice(s+9,f)),o=f+3;continue}const a=n.slice(s);if(a.length<9&&("<!--".startsWith(a)||"<![CDATA[".startsWith(a)))break;if(n.startsWith("<!",s)&&ge("declares a document type or another declaration"),n.startsWith("<?",s)){const f=n.indexOf("?>",s+2);if(f===-1)break;o=f+2;continue}const i=El(n,s+1);if(i===-1)break;const m=n.slice(s+1,i);if(m.startsWith("/"))e.end?.(kt(m.slice(1).trim()));else{const f=m.endsWith("/"),c=f?m.slice(0,-1):m,u=vl.exec(c)?.[0]??ge("has a tag without a name"),h=kt(u);e.start?.(h,xl(c.slice(u.length)),f),f&&e.end?.(h)}o=i+1}n=n.slice(o)};return{write:o=>{n+=o,r()},finish:()=>{r(),!t()&&n.includes("<")&&ge("ends inside a tag, a comment or a section")}}},Ne=async(e,t,n)=>{const r=zr(t,n),o=new TextDecoder("utf-8",{fatal:!0}),s=e.getReader();try{for(;!n();){const{done:a,value:i}=await s.read();if(a){r.write(o.decode()),r.finish();return}r.write(o.decode(i,{stream:!0}))}}catch(a){if(a instanceof Y)throw a;ge("could not be read as UTF-8 text")}finally{s.cancel().catch(()=>{})}},bl=101010256,Sl=33639248,yl=67324752,Vr=22,kl=65535,hn=46,pn=30,Rl=1,gn=0,Tl=8,Ll=65535,be=4294967295,Cl=new TextDecoder("utf-8"),ee=e=>{throw new Y("not-workbook",`the ZIP package ${e}`)},Ol=e=>{const t=e.byteLength-Vr,n=Math.max(0,t-kl);for(let r=t;r>=n;r-=1)if(e.getUint32(r,!0)===bl)return r;return ee("has no end of central directory record")},Al=e=>{if(e.byteLength<Vr)return ee("is shorter than its end record");const t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=Ol(t),r=t.getUint16(n+4,!0),o=t.getUint16(n+6,!0),s=t.getUint16(n+10,!0),a=t.getUint32(n+12,!0),i=t.getUint32(n+16,!0);if(r!==0||o!==0)return ee("spans several disks");if(s===Ll||a===be||i===be)return ee("is a ZIP64 package");if(i+a>n)return ee("has a central directory past its end record");const m=new Map;let f=i;for(let c=0;c<s;c+=1){if(f+hn>n||t.getUint32(f,!0)!==Sl)return ee("has a malformed central directory");const u=t.getUint16(f+8,!0),h=t.getUint16(f+10,!0),w=t.getUint32(f+20,!0),E=t.getUint32(f+24,!0),b=t.getUint16(f+28,!0),T=t.getUint16(f+30,!0),O=t.getUint16(f+32,!0),L=t.getUint32(f+42,!0),q=f+hn;if(q+b>n)return ee("has a name past its central directory");const j=Cl.decode(e.subarray(q,q+b));if(w===be||E===be||L===be)return ee("has a ZIP64 entry");if(!j.endsWith("/")){if(m.has(j))return ee(`names ${j} twice`);m.set(j,{name:j,encrypted:(u&Rl)!==0,method:h,compressedSize:w,uncompressedSize:E,localHeaderOffset:L})}f=q+b+T+O}return{bytes:e,entries:m}},Ml=(e,t)=>{const{bytes:n}=e,r=new DataView(n.buffer,n.byteOffset,n.byteLength),o=t.localHeaderOffset;if(o+pn>n.byteLength||r.getUint32(o,!0)!==yl)return ee(`has no local header for ${t.name}`);const s=o+pn+r.getUint16(o+26,!0)+r.getUint16(o+28,!0),a=s+t.compressedSize;return a>n.byteLength?ee(`has the data of ${t.name} past its end`):{start:s,end:a}},Zr=e=>new ReadableStream({start(t){e.byteLength>0&&t.enqueue(e),t.close()}}),Nl=e=>Zr(e).pipeThrough(new DecompressionStream("deflate-raw")),Dl=(e,t)=>{let n=0;return new TransformStream({transform(r,o){if(n+=r.byteLength,n>t){o.error(new Y("too-large",`${e} inflates past ${t} bytes`));return}o.enqueue(r)}})},Ce=(e,t,n)=>{const r=e.entries.get(t);if(r===void 0)return null;if(r.encrypted)throw new Y("encrypted",`${t} is encrypted`);if(r.method!==gn&&r.method!==Tl)return ee(`compresses ${t} with method ${r.method}`);if(r.uncompressedSize>n)throw new Y("too-large",`${t} declares ${r.uncompressedSize} bytes`);const{start:o,end:s}=Ml(e,r),a=e.bytes.subarray(o,s);return(r.method===gn?Zr(a):Nl(a)).pipeThrough(Dl(t,n))},Ge=async(e,t,n)=>{const r=Ce(e,t,n);if(r===null)return null;const o=new TextDecoder("utf-8",{fatal:!0}),s=r.getReader();let a="";try{for(;;){const{done:i,value:m}=await s.read();if(i)break;a+=o.decode(m,{stream:!0})}return a+o.decode()}catch(i){if(i instanceof Y)throw i;return ee(`has ${t}, which does not inflate to UTF-8 text`)}finally{s.releaseLock()}},wn="content.xml",jl="META-INF/manifest.xml",Wr=e=>{throw new Y("not-workbook",`the spreadsheet ${e}`)},vn=(e,t)=>Ce(e,wn,t.maxPartBytes)??Wr(`has no ${wn}`),Pl=async(e,t)=>{const n=Ce(e,jl,t.maxPartBytes);if(n===null)return!1;let r=!1;return await Ne(n,{start:o=>{o==="encryption-data"&&(r=!0)}},()=>r),r},_l=async e=>{const t=[],n=new Set;let r=null,o=0;return await Ne(e,{start:(s,a,i)=>{s==="style"?r=a.get("family")==="table"?a.get("name")??null:null:s==="table-properties"&&r!==null&&a.get("display")==="false"?n.add(r):s==="table"&&(o===0&&t.push({name:a.get("name")??"",style:a.get("style-name")??""}),i||(o+=1))},end:s=>{s==="style"?r=null:s==="table"&&(o=Math.max(0,o-1))}},()=>!1),{tables:t,hidingStyles:n}},ct=e=>{const t=Number(e);return Number.isInteger(t)&&t>0?t:1},Il=async(e,t,n)=>{const r=Ir(n);let o=0,s=0,a=!1,i=!1,m=0,f=1,c=new Map,u=0,h=null;return await Ne(e,{start:(w,E,b)=>{if(w==="table"){s===0&&(a=o===t,o+=1),b||(s+=1);return}!a||s!==1||(w==="table-row"?(f=ct(E.get("number-rows-repeated")),c=new Map,u=0):w==="table-cell"||w==="covered-table-cell"?h={repeat:ct(E.get("number-columns-repeated")),covered:w==="covered-table-cell",parts:[],paragraphs:0,paragraphDepth:0,annotationDepth:0}:h!==null&&h.annotationDepth===0&&(w==="annotation"&&!b?h.annotationDepth+=1:w==="p"||w==="h"?(h.paragraphs>0&&h.parts.push(`
9
+ `),qo=3,Bo=/^\d+(?:\.\d+)?$/u,Uo=e=>{if(e===null||!Bo.test(e))return null;const t=Number(e);return t>=H.EDIT_SPLIT_MIN_PERCENT&&t<=H.EDIT_SPLIT_MAX_PERCENT?t:null},rt=Object.freeze({kind:"idle"}),Qt=Object.freeze({kind:"draft"}),Ho=({data:e,conflictLabels:t,onSaveSettled:n,sideBySideSetting:r,editorShareSetting:o})=>{const s=new Map,a=new Map,i=new Map,m=new Map,f=new Map,c=xe();let u=null,h=null,w=null;const E=(p,g)=>{p.value={...p.value,...g},c.emit()},b=(p,g)=>s.get(p)===g,T=async(p,g)=>{g.controller.abort(),g.controller=new AbortController;const{signal:R}=g.controller;E(g,{phase:{kind:"opening"}});const N=await e.edit(p,R);if(!b(p,g)||R.aborted||!("kind"in N))return;if(N.kind==="grant"){E(g,{phase:{kind:"grant",href:N.href}});return}if(N.kind==="failure"){E(g,{phase:{kind:"failed",failure:N.failure}});return}const I=nt(N.text),$=N.kind==="draft";g.base={text:I,version:$?null:N.version},g.draft=I,g.ending=Yt(N.text),E(g,{phase:{kind:"editing"},history:$?!1:N.history,dirty:!1,save:$?Qt:rt,generation:g.value.generation+1})},O=p=>{const g=s.get(p);g!==void 0&&(g.controller.abort(),s.delete(p),i.delete(p))},L=(p,g,R)=>(p.set(g,R),()=>{p.get(g)===R&&p.delete(g)}),q=(p,g,R,N={})=>{E(g,{...N,save:R}),n(p,R)},j=async p=>{m.get(p)?.flush();const g=s.get(p);if(g===void 0||g.value.phase.kind!=="editing"||g.base===null||g.value.save.kind==="saving")return;const{version:R}=g.base;if(R===null){n(p,Qt);return}const N=Xt(g.draft).length;if(N>0){q(p,g,{kind:"conflicts",count:N});return}g.controller.abort(),g.controller=new AbortController;const{signal:I}=g.controller;let $={text:g.base.text,version:R},x=g.draft,k=!1;E(g,{save:{kind:"saving"}});for(let A=0;A<qo;A+=1){const M=await e.save(p,$.version,$o(x,g.ending),I);if(!b(p,g)||I.aborted||!("kind"in M))return;if(M.kind==="saved"){m.get(p)?.flush(),g.base={text:x,version:M.version},q(p,g,{kind:"saved",merged:k},{dirty:g.draft!==x});return}if(M.kind==="grant"){q(p,g,{kind:"grant",href:M.href});return}if(M.kind==="failure"){q(p,g,{kind:"failed",failure:M.failure});return}const{mergeDraft:P}=await Promise.resolve().then(()=>require("./merge-DZI4pkWI.cjs"));if(!b(p,g)||I.aborted)return;const B=m.get(p);B?.flush();const G=nt(M.text),v=P($.text,g.draft,G,t());if($={text:G,version:M.version},g.base=$,g.ending=Yt(M.text),g.draft=v.text,B?.adopt(v.text),v.kind==="conflicts"){q(p,g,{kind:"conflicts",count:v.conflicts},{dirty:!0,generation:g.value.generation+1});return}if(k=!0,x=v.text,x===$.text){q(p,g,{kind:"saved",merged:k},{dirty:!1,generation:g.value.generation+1});return}E(g,{dirty:!0,generation:g.value.generation+1})}q(p,g,{kind:"failed",failure:{reason:"failed"}})};return{session:p=>s.get(p)?.value,subscribe:c.subscribe,start:(p,g)=>{const R=s.get(p);if(R!==void 0){E(R,{request:{anchor:g},view:"editor"}),(R.value.phase.kind==="failed"||R.value.phase.kind==="grant")&&T(p,R);return}a.delete(p);const N={value:{path:p,phase:{kind:"opening"},view:"editor",previewPrepared:!1,history:!1,dirty:!1,save:rt,generation:0,request:{anchor:g}},base:null,draft:"",ending:`
10
+ `,controller:new AbortController};s.set(p,N),T(p,N)},retry:p=>{const g=s.get(p);g===void 0||g.value.phase.kind==="editing"||T(p,g)},draft:p=>{const g=s.get(p);return g===void 0||g.base===null?null:g.draft},setDraft:(p,g)=>{const R=s.get(p);if(R===void 0||R.base===null)return;R.draft=g;const N={},I=g!==R.base.text;I!==R.value.dirty&&(N.dirty=I);const{save:$}=R.value;if($.kind==="conflicts"){const x=Xt(g).length;x===0?N.save=rt:x!==$.count&&(N.save={kind:"conflicts",count:x})}(N.dirty!==void 0||N.save!==void 0)&&E(R,N)},consumeRequest:p=>{const g=s.get(p);g!==void 0&&g.value.request!==null&&E(g,{request:null})},save:j,replaceDraft:(p,g)=>{const R=m.get(p);R?.flush();const N=s.get(p);if(N===void 0||N.base===null)return;const I=nt(g);N.draft=I,R?.adopt(I),E(N,{dirty:I!==N.base.text,generation:N.value.generation+1})},close:p=>{if(!s.has(p))return;const g=m.get(p),R=g===void 0?null:g.returnPoint();O(p),R===null?a.delete(p):a.set(p,R),c.emit()},takeReturn:p=>{const g=a.get(p)??null;return a.delete(p),g},dirtyPaths:()=>[...s.values()].filter(p=>p.value.dirty).map(p=>p.value.path),discard:p=>{for(const g of p)O(g);p.length>0&&c.emit()},editorState:{get:p=>i.get(p),set:(p,g)=>{s.has(p)&&i.set(p,g)}},bindEditor:(p,g)=>L(m,p,g),bindView:(p,g)=>L(f,p,g),viewAnchor:p=>{const g=f.get(p);return g===void 0?null:g.anchor()},flush:p=>m.get(p)?.flush(),flushDrafts:()=>{for(const p of m.values())p.flush()},nextConflict:p=>m.get(p)?.nextConflict()===!0,hasSessions:()=>s.size>0,unsavedAmong:p=>{for(const g of m.values())g.flush();return p.filter(g=>s.get(g)?.value.dirty===!0)},askToDiscard:p=>new Promise(g=>{w?.settle(!1);const R={paths:p,settle:N=>{if(w===R){if(w=null,N)for(const I of p)O(I);c.emit(),g(N)}}};w=R,c.emit()}),discardRequest:()=>w,sideBySide:()=>(u??=r.read(),u),setSideBySide:p=>{u!==p&&(u=p,r.write(p),c.emit())},editorShare:()=>(h??=o.read()??H.EDIT_SPLIT_DEFAULT_PERCENT,h),setEditorShare:p=>{if(!Number.isFinite(p))throw new RangeError(`[markdown-explorer] an editor share must be a finite number; got ${String(p)}`);const g=Math.min(H.EDIT_SPLIT_MAX_PERCENT,Math.max(H.EDIT_SPLIT_MIN_PERCENT,p));h!==g&&(h=g,o.write(g))},setView:(p,g)=>{const R=s.get(p);R===void 0||R.value.view===g||(m.get(p)?.beforeView(g),E(R,{view:g,previewPrepared:R.value.previewPrepared||g==="preview"}))},preparePreview:p=>{const g=s.get(p);g!==void 0&&!g.value.previewPrepared&&E(g,{previewPrepared:!0})}}},Ot=e=>{e.preventDefault(),e.stopPropagation()},Wn=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,Gn="data-aqmx-content-pane",Ue=Object.freeze({[Gn]:""}),zo="--aqmx-dialog-left",Vo="--aqmx-dialog-top",Zo='[data-testid="markdown-explorer"]',Wo=e=>{const t=e.closest(Zo)?.querySelectorAll(`[${Gn}]`),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},Go=e=>{const t=Wn(getComputedStyle(e).marginTop);if(Number.isNaN(t))return null;const n=Wo(e),r=e.getBoundingClientRect(),o=e.ownerDocument.documentElement,{left:s,top:a}=H.centeredDialogPosition(n.getBoundingClientRect(),{width:r.width+2*t,height:r.height+2*t},{width:o.clientWidth,height:o.clientHeight});return e.style.setProperty(zo,`${String(s)}px`),e.style.setProperty(Vo,`${String(a)}px`),n},Ko=e=>e.preventDefault(),Kn=({open:e,onOpen:t,onDismiss:n})=>{const r=d.useRef(null),o=d.useRef(null),s=d.useRef(!1),a=d.useRef(t);d.useLayoutEffect(()=>{a.current=t},[t]),d.useLayoutEffect(()=>{s.current=e;const c=r.current;if(c!==null)if(e&&!c.open){const u=c.ownerDocument.activeElement;o.current=u instanceof HTMLElement?u:null,c.showModal(),a.current?.()}else!e&&c.open&&(c.close(),o.current?.isConnected===!0&&o.current.focus(),o.current=null)},[e]),d.useLayoutEffect(()=>{const c=r.current;if(!e||c===null)return;const u=new ResizeObserver(()=>w());let h=null;const w=()=>{const b=Go(c);b===null||b===h||(h!==null&&u.unobserve(h),u.observe(b),h=b)};w(),u.observe(c);const E=c.ownerDocument.defaultView;return E?.addEventListener("resize",w),c.ownerDocument.addEventListener("scroll",w,{capture:!0,passive:!0}),()=>{u.disconnect(),E?.removeEventListener("resize",w),c.ownerDocument.removeEventListener("scroll",w,{capture:!0})}},[e]);const i=d.useCallback(c=>{c.key!=="Escape"||c.defaultPrevented||(Ot(c),n())},[n]),m=d.useCallback(c=>{c.target===c.currentTarget&&n()},[n]),f=d.useCallback(()=>{s.current&&n()},[n]);return{ref:r,onKeyDown:i,onClick:m,onCancel:Ko,onClose:f}},Xn=({open:e,title:t,body:n,confirmLabel:r,cancelLabel:o,onConfirm:s,onCancel:a,testId:i})=>{const m=d.useRef(null),f=d.useId(),c=d.useId(),u=d.useCallback(()=>m.current?.focus(),[]),h=Kn({open:e,onOpen:u,onDismiss:a});return l.jsx("dialog",{...h,className:"aqmx-confirm","aria-labelledby":f,"aria-describedby":c,"data-testid":i,children:l.jsxs("div",{className:"aqmx-confirm-panel",children:[l.jsx("p",{id:f,className:"aqmx-confirm-title",children:t}),l.jsx("p",{id:c,className:"aqmx-confirm-body",children:n}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{ref:m,type:"button",className:"aqmx-callout-action","data-testid":`${i}-cancel`,onClick:a,children:o}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-aqmx-tone":"danger","data-testid":`${i}-confirm`,onClick:s,children:r})]})]})})},Te=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},Yn=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),Se=e=>e.status==="fulfilled"?e.value:void 0,Qn=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!1}),Xo=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!0}),Yo=(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,i=s.lazy===!0?a?.status==="loaded"?a.entries:null:s.children===void 0?[]:s.children;if(s.path===t)return i;if(i!==null)for(const m of[...i].reverse())o.push(m)}return null},Jn=(e,t,n)=>{const r=Se(e.read(t));if(r===void 0||r.status==="deferred")return Qn;if(r.status==="error")return{readme:{status:"failed",failure:r.failure,retry:()=>e.retry(t)},claim:!1};const o=Yo(r.entries,n,a=>e.children(t,a));if(o!==null)return{readme:{status:"ok",readme:H.folderReadmeOf(o)},claim:!1};const s=e.children(t,n);return s===void 0||s.status==="loading"?Xo:s.status==="failed"?{readme:{status:"failed",failure:s.failure,retry:()=>e.retryChildren(t,n)},claim:!0}:{readme:{status:"ok",readme:H.folderReadmeOf(s.entries)},claim:!0}},Qo=(e,t,n)=>{const{readme:r}=Jn(e,t,n);return r.status==="ok"?r.readme:null},Jo=(e,t,n)=>{const r=te.matchPath({path:`${e.basePath}/*`,end:!0},t.pathname);if(r===null)return new Set;const{location:o}=H.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)}},er=e=>{const{edits:t}=F(),n=d.useCallback(()=>t.session(e),[t,e]);return d.useSyncExternalStore(t.subscribe,n,es)},tr=()=>!1,es=()=>{},ts=()=>{const{edits:e}=F();return d.useSyncExternalStore(e.subscribe,e.hasSessions,tr)},nr=()=>{const{edits:e}=F();return d.useSyncExternalStore(e.subscribe,e.sideBySide,tr)},ns=()=>null,rs=()=>{const{edits:e,labels:t,config:n,trees:r}=F(),o=d.useRef([]),s=d.useCallback(({nextLocation:w})=>{const E=Jo(n,w,(b,T)=>Qo(r,b,T));return e.flushDrafts(),o.current=e.dirtyPaths().filter(b=>!E.has(b)),o.current.length>0},[e,n,r]),a=te.useBlocker(s),i=ts();d.useEffect(()=>{if(!i)return;const w=E=>{e.flushDrafts(),e.dirtyPaths().length!==0&&(E.preventDefault(),E.returnValue=!0)};return window.addEventListener("beforeunload",w),()=>window.removeEventListener("beforeunload",w)},[i,e]);const m=d.useSyncExternalStore(e.subscribe,e.discardRequest,ns),f=a.state==="blocked",c=f?o.current:m===null?[]:m.paths,u=c.map(w=>_.lastPathSegment(w)).join(", "),h=c.length>0&&c.every(w=>e.session(w)?.save.kind==="draft");return l.jsx(Xn,{open:f||m!==null,title:h?t.draftDiscardTitle:t.unsavedTitle,body:h?t.draftDiscardBody(u):t.unsavedBody(u),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 os({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm2.25 8.5a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Zm0 3a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",clipRule:"evenodd"}))}const ss=y.forwardRef(os);let ot=null;const rr=()=>(ot??=Promise.resolve().then(()=>require("./EditSurface-BPqqykro.cjs")).catch(e=>{throw ot=null,e}),ot),as=()=>{rr().catch(()=>{})},ls=e=>{const{default:t}=d.use(rr());return l.jsx(t,{...e})};class is extends d.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 or="[data-aqmd-fullscreen]",cs=e=>e instanceof Element&&e.closest(or)!==null,At=`[${wt.SOURCE_LINES_ATTRIBUTE}]`,ds="[data-aqmd-content]",us=`a[href], button, input, select, textarea, summary, label, [contenteditable], [role="menu"], iframe, video, audio, object, embed, svg, [data-aqmd-spreadsheet-editable], ${or}, [data-aqmd-svg-image-source]`,fs=200,Le=e=>wt.parseSourceLines(e.getAttribute(wt.SOURCE_LINES_ATTRIBUTE)),ms=(e,t)=>{for(let r=e;r!==null&&t.contains(r);r=r.parentElement){const o=Le(r);if(o!==null)return{block:r,lines:o,own:!0}}let n=null;for(const r of t.querySelectorAll(At)){if(!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))break;const o=Le(r);o!==null&&(n={block:r,lines:o})}return n===null?null:{...n,own:!1}},hs=(e,t)=>{let n=0;for(let r=e.indexOf(t);r>=0;r=e.indexOf(t,r+t.length))n+=1;return n},sr=e=>e.closest(ds)!==null&&e.closest(us)===null,ar=(e,t,n)=>{const r=ms(e,t);if(r===null)return null;const{block:o,own:s}=r;if(!s){const i=r.lines.last+1;return{lines:{first:i,last:i},word:null,occurrence:0,clientTop:He(e)}}const a=ps(o,n);return a===null?{lines:r.lines,word:null,occurrence:0,clientTop:He(o)}:{lines:r.lines,word:a.text,occurrence:a.occurrence,clientTop:a.clientTop}},lr=(e,t)=>{let n=null,r=null,o=null;for(const a of e.querySelectorAll(At)){const i=Le(a);if(i===null)continue;n??=cr(t,a);const{top:m,bottom:f}=a.getBoundingClientRect();m<=n&&n<f?r={lines:i,block:a}:o===null&&m>=n&&(o={lines:i,block:a})}const s=r===null?o:r;return s===null?null:{lines:s.lines,word:null,occurrence:0,clientTop:He(s.block)}},ir=e=>e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,cr=(e,t)=>{const n=Number.parseFloat(getComputedStyle(t).scrollMarginTop);return ir(e)+(Number.isFinite(n)?n:0)},ps=(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>fs||/[\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:hs(o.toString(),r),clientTop:n.getBoundingClientRect().top}},gs=(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 i=r;i<=o;i+=1){const m=n[i-1]??"";for(let f=m.indexOf(t.word);f>=0;f=m.indexOf(t.word,f+t.word.length)){if(a===t.occurrence)return{line:i,column:f};a+=1}}return a>0?ws(n,r,o,t.word)??s:s},ws=(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},dr=(e,t)=>{let n=null,r=null;for(const o of e.querySelectorAll(At)){const s=Le(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},ur=(e,t)=>{const{bottom:n}=e.getBoundingClientRect(),r=He(e),o=Le(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},He=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:i}=s.getBoundingClientRect();if(i>0)return a}return e.getBoundingClientRect().top},Mt=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})}),vs=e=>Mt[e],Oe=()=>{const e=te.useNavigate();return d.useCallback((t,n)=>{e(t,Mt[n])},[e])},fr=({navigation:e,...t})=>l.jsx(te.Link,{...t,...Mt[e]}),Nt=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},mr=(e,t)=>{const n=d.useRef(null),r=d.useRef(null),o=d.useRef(null),s=d.useCallback(()=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,r.current=null},[]);d.useEffect(()=>s,[s]);const a=d.useCallback(f=>{if(r.current!==f)return;const c=o.current;if(c!==null){c.then(()=>a(f));return}e.prefetch(f);const u=e.peek(f);if(u?.status!=="pending")return;const h=Promise.allSettled([u.promise]);o.current=h,h.then(()=>{o.current===h&&(o.current=null)})},[e]),i=d.useCallback(f=>{const c=t(f);c!==r.current&&(s(),c!==null&&(r.current=c,n.current=window.setTimeout(()=>{n.current=null,a(c)},H.PREFETCH_DWELL_MS)))},[s,t,a]),m=d.useCallback(f=>{t(f)!==r.current&&s()},[s,t]);return d.useMemo(()=>({onPointerOver:f=>i(f.target),onPointerOut:f=>m(f.relatedTarget),onFocus:f=>i(f.target),onBlur:f=>m(f.relatedTarget)}),[i,m])},Es=d.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-UpjxjLlB.cjs")).then(e=>({default:e.NativeScrollBar})));class xs extends d.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 hr=({scroller:e,withCircle:t})=>l.jsx(xs,{children:l.jsx(d.Suspense,{fallback:null,children:l.jsx(Es,{scroller:e,withCircle:t})})}),pr=e=>l.jsx(hr,{scroller:e,withCircle:!0}),bs=8,Xe=H.CONTROL_BLOCK_PIXELS,gr=H.FIBONACCI_SPACING_PIXELS[3],Dt=Xe+2*gr,Ss=-(Xe+gr),wr=Object.freeze({minSpeedMultiplier:.25,maxSpeedMultiplier:18});let vr=null,st=null;const St=new Set,ys=e=>(St.add(e),()=>{St.delete(e)}),ks=()=>{st===null&&(st=Promise.resolve().then(()=>require("./tapScrollCircle-Cbf17x8g.cjs")).then(e=>{const t=e.TAP_SCROLL_CIRCLE.renderVisual;if(t===void 0)throw new TypeError("[markdown-explorer] the bars' tap-scroll circle has no look to share");vr=t;for(const n of[...St])n()}).catch(e=>{st=null,console.error("[markdown-explorer] the look of a table's tap-scroll circle failed to load; the circle still scrolls without it.",e)}))},Rs=({look:e,state:t})=>e(t),Ts=e=>{const t=d.useSyncExternalStore(ys,()=>vr,()=>null);return d.useEffect(()=>{t===null&&ks()},[t]),t===null?null:l.jsx(Rs,{look:t,state:e})},Er=Object.freeze({renderVisual:e=>l.jsx(Ts,{...e}),...wr,size:Xe}),xr=()=>{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()]}},ze=(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)=>ze(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)&&ze(n[s],r[s]))},Ls=55e3,Jt=Object.freeze({status:"deferred"}),at=Object.freeze({status:"refreshed"}),lt=Object.freeze({status:"shown",failed:!1}),je=Object.freeze({status:"shown",failed:!0}),Pe=Object.freeze({status:"superseded"}),le=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,Cs=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",Os=({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=xr(),o=xe(),s=new WeakSet,a=new Map,i=new Map,m=new Map;let f=0;const c=o.emit,u=()=>(f+=1,f),h=()=>{if(!(n.size<=t))for(const x of[...n.keys()]){if(n.size<=t)return;r.isHeld(x)||n.delete(x)}},w=(x,k)=>{n.delete(x),n.set(x,k)},E=x=>performance.now()-x.validatedAt>=Ls,b=(x,k,A)=>{const M=n.get(x),P=le(M?.snapshot),B=A||M?.refreshPending===!0,G=Te(e.document(x,{refresh:B}).then(S=>({status:"loaded",document:S}))),v={snapshot:{status:"pending",promise:G,previous:P},validatedAt:performance.now(),opened:k,background:null,refreshPending:!1,seeded:void 0,stamp:u()};return w(x,v),h(),G.then(S=>{n.get(x)===v&&(v.snapshot=S,v.stamp=u(),c())}),v},T=(x,k,A,M,P,B)=>{k.background===A&&(k.background=null,!(n.get(x)!==k||k.snapshot!==M)&&(P.kind==="failure"&&M.document.kind!=="failure"||(k.validatedAt=B,k.stamp=u(),ze(M.document,P)||(k.snapshot={status:"loaded",document:P}),c())))},O=async(x,k)=>{const A=k.snapshot;if(A.status!=="loaded")return null;const M={};k.background=M;const P=performance.now(),B=e.document(x,{refresh:k.refreshPending});k.refreshPending=!1;const G=await B,v=k.background===M&&n.get(x)===k&&k.snapshot===A;return T(x,k,M,A,G,P),v?G:null},L=(x,k)=>{const{snapshot:A}=k;return A.status==="pending"?!1:A.status==="loaded"&&A.document.kind!=="failure"?(O(x,k),!1):(A.status==="loaded"&&s.add(A),b(x,!0,!1),!0)},q=x=>{i.delete(x);const k=m.get(x);if(k!==void 0){m.delete(x);for(const A of k)A()}},j=(x,k)=>new Promise(A=>{if(i.get(x)===k||!r.isHeld(x)){A();return}const M=m.get(x);M===void 0?m.set(x,new Set([A])):M.add(A)}),p=(x,k)=>{const A=a.get(x);if(A===void 0){k.resolve(null);return}if(A.last!==null&&A.last.stamp>=k.stamp){k.resolve(A.last);return}A.waiters.add(k)},g=async(x,k,A)=>{const M=await new Promise(P=>p(x,{stamp:k.stamp,resolve:P}));if(n.get(x)!==k)return Pe;if(M===null)return A?at:lt;if(!A)return M.failure===null?lt:je;switch(M.before){case"copy":return M.failure===null?at:{status:"failed",failure:M.failure};case"failure":return M.failure===null?lt:je;case"none":return M.failure===null?at:je}},R=x=>{const k={showing:"none",last:null,waiters:new Set};a.set(x,k);let A=!1;return{settle:(M,P)=>{if(A||M===void 0)return;const B={stamp:M,failure:P,before:k.showing};k.last=B,P===null?k.showing="copy":k.showing==="none"&&(k.showing="failure");for(const G of[...k.waiters])M<G.stamp||(k.waiters.delete(G),G.resolve(B))},release:()=>{if(A)return;A=!0,a.get(x)===k&&a.delete(x);const M=[...k.waiters];k.waiters.clear(),M.length>0&&queueMicrotask(()=>{for(const P of M)p(x,P)})}}},N=x=>{const k=r.hold(x);let A=!1;return()=>{if(A)return;A=!0,k();const M=n.get(x);M!==void 0&&w(x,M),h(),r.isHeld(x)||queueMicrotask(()=>{r.isHeld(x)||q(x)})}};return{peek:x=>n.get(x)?.snapshot,peekSeeded:x=>n.get(x)?.seeded,answerStampOf:x=>n.get(x)?.stamp,prefetch:x=>{const k=n.get(x);k!==void 0&&k.snapshot.status!=="deferred"||(b(x,!1,!1),c())},open:x=>{const k=r.resumes(x),A=N(x),M=n.get(x);if(M===void 0||M.snapshot.status==="deferred")return b(x,!0,!1),c(),A;if(w(x,M),k)return A;const{snapshot:P}=M;return P.status==="pending"?(M.opened=!0,A):P.document.kind==="failure"?(M.opened||E(M)?(s.add(P),b(x,!0,!1),c()):M.opened=!0,A):(M.opened=!0,M.background===null&&E(M)&&O(x,M),A)},retain:N,retry:x=>{const k=n.get(x);k===void 0||k.snapshot.status!=="loaded"||k.snapshot.document.kind!=="failure"||(b(x,!0,!1),c())},seed:(x,k)=>{const A=performance.now(),M=Te(k.then(S=>S===null?Jt:{status:"loaded",document:S},()=>Jt)),P=n.get(x);if(P!==void 0&&P.snapshot.status==="loaded"){const S=P.snapshot,C={};P.background=C,M.then(D=>{if(D.status==="loaded"){T(x,P,C,S,D.document,A);return}P.background===C&&(P.background=null)});return}const B=P!==void 0&&P.snapshot.status==="pending"?P.snapshot.previous:null,G={status:"pending",promise:M,previous:B},v={snapshot:G,validatedAt:A,opened:P?.opened===!0,background:null,refreshPending:P?.refreshPending===!0,seeded:G,stamp:u()};w(x,v),h(),M.then(S=>{n.get(x)===v&&(S.status==="deferred"&&r.isHeld(x)?b(x,v.opened,!1):(v.snapshot=S,v.stamp=u()),c())})},invalidate:()=>{let x=!1;for(const[k,A]of[...n]){if(A.validatedAt=Number.NEGATIVE_INFINITY,A.opened=!0,A.refreshPending=!0,!r.isHeld(k))continue;const{snapshot:M}=A;if(M.status!=="pending"){L(k,A)&&(x=!0);continue}M.promise.then(()=>{n.get(k)===A&&A.refreshPending&&r.isHeld(k)&&L(k,A)&&c()})}x&&c()},refresh:async x=>{const k=n.get(x);if(k!==void 0&&Cs(k.snapshot)){k.refreshPending=!0;const P=await O(x,k);return P===null?Pe:P.kind==="failure"?{status:"failed",failure:P.failure}:g(x,k,!0)}const A=b(x,!0,!0);if(c(),A.snapshot.status!=="pending")return Pe;const M=await A.snapshot.promise;return n.get(x)!==A||M.status!=="loaded"?Pe:M.document.kind==="failure"?je:(await j(x,M),g(x,A,!1))},clear:()=>{n.clear();for(const x of r.heldKeys())b(x,!0,!1);c()},subscribe:o.subscribe,readPart:R,noteShown:(x,k)=>{i.set(x,k);const A=m.get(x);if(A!==void 0){m.delete(x);for(const M of A)M()}},noteFailureShown:x=>s.has(x)?!1:(s.add(x),!0)}},de=d.createContext("fill"),As="--aqmx-tap-circle-gutter",Ms=Object.freeze({blockSize:"100%",[As]:`${String(Dt)}px`}),Ae=({scrollerProps:e,children:t})=>d.use(de)==="content"?l.jsx(Ee.HostedScrollArea,{scrollerProps:e,children:t}):l.jsx(Ee.HostedScrollArea,{scrollerProps:{...e,style:Ms},rowClassName:"aqmx-document-scroll-row",renderScrollBar:pr,children:t}),Ns=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),Ds=Object.freeze({className:"aqmx-document-failure","data-aqmx-document-scroller":""}),ue=({label:e,testId:t})=>l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":t,children:Ns.map(n=>l.jsx("span",{},n))}),l.jsx("p",{className:"aqmx-sr-only",children:e})]}),jt=({failure:e,onRetry:t,testId:n})=>l.jsx(Ae,{scrollerProps:Ds,children:l.jsx(ce,{failure:e,alert:!1,onRetry:t,testId:n})});function js({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M18 5.25a2.25 2.25 0 0 0-2.012-2.238A2.25 2.25 0 0 0 13.75 1h-1.5a2.25 2.25 0 0 0-2.238 2.012c-.875.092-1.6.686-1.884 1.488H11A2.5 2.5 0 0 1 13.5 7v7h2.25A2.25 2.25 0 0 0 18 11.75v-6.5ZM12.25 2.5a.75.75 0 0 0-.75.75v.25h3v-.25a.75.75 0 0 0-.75-.75h-1.5Z",clipRule:"evenodd"}),y.createElement("path",{fillRule:"evenodd",d:"M3 6a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H3Zm6.874 4.166a.75.75 0 1 0-1.248-.832l-2.493 3.739-.853-.853a.75.75 0 0 0-1.06 1.06l1.5 1.5a.75.75 0 0 0 1.154-.114l3-4.5Z",clipRule:"evenodd"}))}const Ps=y.forwardRef(js);function _s({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M15.988 3.012A2.25 2.25 0 0 1 18 5.25v6.5A2.25 2.25 0 0 1 15.75 14H13.5v-3.379a3 3 0 0 0-.879-2.121l-3.12-3.121a3 3 0 0 0-1.402-.791 2.252 2.252 0 0 1 1.913-1.576A2.25 2.25 0 0 1 12.25 1h1.5a2.25 2.25 0 0 1 2.238 2.012ZM11.5 3.25a.75.75 0 0 1 .75-.75h1.5a.75.75 0 0 1 .75.75v.25h-3v-.25Z",clipRule:"evenodd"}),y.createElement("path",{d:"M3.5 6A1.5 1.5 0 0 0 2 7.5v9A1.5 1.5 0 0 0 3.5 18h7a1.5 1.5 0 0 0 1.5-1.5v-5.879a1.5 1.5 0 0 0-.44-1.06L8.44 6.439A1.5 1.5 0 0 0 7.378 6H3.5Z"}))}const Is=y.forwardRef(_s);function Fs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",clipRule:"evenodd"}))}const $s=y.forwardRef(Fs),qs=2e3,en=Object.freeze({outcome:"idle"}),Bs=e=>{const t=navigator.clipboard;return t===void 0?Promise.reject(new Error("[markdown-explorer] this browser has no asynchronous clipboard")):t.writeText(e)},Us=({text:e})=>{const{announcer:t,labels:n}=F(),[r,o]=d.useState(en);d.useEffect(()=>{if(r.outcome==="idle")return;const m=setTimeout(()=>o(en),qs);return()=>clearTimeout(m)},[r]);const s=m=>{o({outcome:m}),t.announce(m==="copied"?n.copiedText:n.copyTextFailed)},a=()=>{Bs(e).then(()=>s("copied"),()=>s("failed"))},i=r.outcome==="copied"?n.copiedText:r.outcome==="failed"?n.copyTextFailed:n.copyText;return l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":n.copyText,title:i,onClick:a,"data-aqmx-copy-outcome":r.outcome,"data-testid":"markdown-explorer-file-copy",children:r.outcome==="copied"?l.jsx(Ps,{}):r.outcome==="failed"?l.jsx($s,{}):l.jsx(Is,{})})},br=d.createContext(null),Hs=()=>{const e=d.use(br);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 zs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M10.75 2.75a.75.75 0 0 0-1.5 0v8.614L6.295 8.235a.75.75 0 1 0-1.09 1.03l4.25 4.5a.75.75 0 0 0 1.09 0l4.25-4.5a.75.75 0 0 0-1.09-1.03l-2.955 3.129V2.75Z"}),y.createElement("path",{d:"M3.5 12.75a.75.75 0 0 0-1.5 0v2.5A2.75 2.75 0 0 0 4.75 18h10.5A2.75 2.75 0 0 0 18 15.25v-2.5a.75.75 0 0 0-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5Z"}))}const Vs=y.forwardRef(zs);function Zs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.25 5.5a.75.75 0 0 0-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75v-4a.75.75 0 0 1 1.5 0v4A2.25 2.25 0 0 1 12.75 17h-8.5A2.25 2.25 0 0 1 2 14.75v-8.5A2.25 2.25 0 0 1 4.25 4h5a.75.75 0 0 1 0 1.5h-5Z",clipRule:"evenodd"}),y.createElement("path",{fillRule:"evenodd",d:"M6.194 12.753a.75.75 0 0 0 1.06.053L16.5 4.44v2.81a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.553l-9.056 8.194a.75.75 0 0 0-.053 1.06Z",clipRule:"evenodd"}))}const Ws=y.forwardRef(Zs),Me=({name:e,openUrl:t,downloadUrl:n,icon:r,children:o})=>{const{labels:s}=F();return l.jsxs("div",{className:"aqmx-document-toolbar",children:[l.jsx("span",{className:"aqmx-document-file-icon","aria-hidden":"true",children:r}),l.jsx("span",{className:"aqmx-document-title",title:e,"data-testid":"markdown-explorer-file-name",children:e}),o,l.jsx("a",{className:"aqmx-icon-button",href:t,target:"_blank",rel:"noopener noreferrer","aria-label":s.openInNewTab,title:s.openInNewTab,"data-testid":"markdown-explorer-file-open",children:l.jsx(Ws,{})}),l.jsx("a",{className:"aqmx-icon-button",href:n,download:e,"aria-label":s.download,title:s.download,"data-testid":"markdown-explorer-file-download",children:l.jsx(Vs,{})})]})};function Gs({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm4.75 6.75a.75.75 0 0 1 1.5 0v2.546l.943-1.048a.75.75 0 0 1 1.114 1.004l-2.25 2.5a.75.75 0 0 1-1.114 0l-2.25-2.5a.75.75 0 1 1 1.114-1.004l.943 1.048V8.75Z",clipRule:"evenodd"}))}const Ks=y.forwardRef(Gs),Xs=Object.freeze({className:"aqmx-document-stage"}),Ys=({document:e})=>{const{labels:t}=F();return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[l.jsx(Me,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(Ks,{})}),l.jsx(Ae,{scrollerProps:Xs,children:l.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-file-not-shown",children:[l.jsx("p",{className:"aqmx-callout-body",children:t.fileNotShown}),l.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-file-not-shown-download",children:t.download})]})})]})},tn=["keydown","pointerdown","wheel","touchstart"],$e=new WeakMap,Ve=new WeakMap,Qs=e=>{const t=Ve.get(e);if(t!==void 0){t.count+=1;return}Ve.set(e,{count:1,original:e.style.overflowAnchor}),e.style.overflowAnchor="none"},Js=e=>{const t=Ve.get(e);t!==void 0&&(t.count-=1,!(t.count>0)&&(Ve.delete(e),e.style.overflowAnchor=t.original))},ea=(e,t,n)=>{for(let r=t;r!==null&&r!==n;r=r.parentElement){e.observe(r);for(let o=r.previousElementSibling;o!==null;o=o.previousElementSibling)e.observe(o)}},ta=e=>{const t=new Map;for(let n=e.parentElement;n!==null;n=n.parentElement)t.set(n,{top:n.scrollTop,left:n.scrollLeft});return t},Sr=e=>{$e.get(e)?.()},yr=(e,t,n)=>{Sr(e);let r=new Map;const o=new Set,s=()=>{const u=t();return u===null?!1:(r=ta(u),!0)};if(!s()||typeof ResizeObserver>"u")return;const a=()=>{for(const u of r.keys())!(u instanceof HTMLElement)||o.has(u)||(o.add(u),Qs(u))};a();const{ownerDocument:i}=e,m=new ResizeObserver(()=>{if(!s()){c();return}a()});for(const{element:u,boundary:h}of n)ea(m,u,h);const f=u=>{const h=u.target===i?i.scrollingElement:u.target;if(!(h instanceof Element))return;const w=r.get(h);w!==void 0&&(h.scrollTop!==w.top||h.scrollLeft!==w.left)&&c()},c=()=>{m.disconnect();for(const u of tn)i.removeEventListener(u,c,!0);i.removeEventListener("scroll",f,!0);for(const u of o)Js(u);o.clear(),$e.get(e)===c&&$e.delete(e)};for(const u of tn)i.addEventListener(u,c,{capture:!0,passive:!0});i.addEventListener("scroll",f,{capture:!0,passive:!0}),$e.set(e,c)},Ye="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",na=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},ra=/(%[0-9A-Fa-f]{2})/u,Pt=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(ra).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))},kr=e=>`#${encodeURIComponent(e)}`,oa=e=>{if(e==="#")return!0;const t=Pt(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},Rr=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},sa="http://www.w3.org/1999/xhtml",nn=(e,t)=>{if(t==="")return null;const n=Rr(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===sa&&r.getAttribute("name")===t)return r;return null},Tr=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=nn(e,t.slice(1));if(n!==null)return n;const r=Pt(t);return r===null?null:nn(e,r)},rn=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"},aa=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"},la=(e,t)=>{const n=t.closest(Ye),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&rn(r))return r;const o=e.getBoundingClientRect().height,{documentElement:s,scrollingElement:a}=e.ownerDocument;for(let i=e.parentElement;i!==null&&i!==s;i=i.parentElement)if(rn(i)&&i.scrollHeight>i.clientHeight&&i.clientHeight<o)return i;return a instanceof Element&&aa(e.ownerDocument)&&a.scrollHeight>a.clientHeight&&a.clientHeight<o?a:r},ia=Object.freeze({scrollerOf:la,reveal:e=>{e.scrollIntoView(Ze)},keepAtStart:(e,t)=>{yr(e,()=>t.isConnected?(Lr(e,t),t):null,[{element:t,boundary:e}])}}),Ze=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),ca=(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")}}},Lr=(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(),i=a.height+s+Number.parseFloat(o)>e.clientHeight;if(!i&&Math.abs(a.top-s-n)<1){t.scrollIntoView(Ze);return}e.scrollBy({top:i?a.top-n-e.clientHeight:a.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(Ze)},da=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(Ye)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},on=(e,t,n)=>{if(e===null)return null;const r=Tr(e,t);return r===null?(oa(t)&&da(e,n),null):(ca(e,r),n.keepAtStart(n.scrollerOf(e,r),r),r)};function ua({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M3.28 2.22a.75.75 0 0 0-1.06 1.06L5.44 6.5H2.75a.75.75 0 0 0 0 1.5h4.5A.75.75 0 0 0 8 7.25v-4.5a.75.75 0 0 0-1.5 0v2.69L3.28 2.22ZM13.5 2.75a.75.75 0 0 0-1.5 0v4.5c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-2.69l3.22-3.22a.75.75 0 0 0-1.06-1.06L13.5 5.44V2.75ZM3.28 17.78l3.22-3.22v2.69a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.69l-3.22 3.22a.75.75 0 1 0 1.06 1.06ZM13.5 14.56l3.22 3.22a.75.75 0 1 0 1.06-1.06l-3.22-3.22h2.69a.75.75 0 0 0 0-1.5h-4.5a.75.75 0 0 0-.75.75v4.5a.75.75 0 0 0 1.5 0v-2.69Z"}))}const fa=y.forwardRef(ua);function ma({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M6.75 8.25a.75.75 0 0 0 0 1.5h4.5a.75.75 0 0 0 0-1.5h-4.5Z"}),y.createElement("path",{fillRule:"evenodd",d:"M9 2a7 7 0 1 0 4.391 12.452l3.329 3.328a.75.75 0 1 0 1.06-1.06l-3.328-3.329A7 7 0 0 0 9 2ZM3.5 9a5.5 5.5 0 1 1 11 0 5.5 5.5 0 0 1-11 0Z",clipRule:"evenodd"}))}const ha=y.forwardRef(ma);function pa({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M9 6a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0v-1.5h-1.5a.75.75 0 0 1 0-1.5h1.5v-1.5A.75.75 0 0 1 9 6Z"}),y.createElement("path",{fillRule:"evenodd",d:"M2 9a7 7 0 1 1 12.452 4.391l3.328 3.329a.75.75 0 1 1-1.06 1.06l-3.329-3.328A7 7 0 0 1 2 9Zm7-5.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11Z",clipRule:"evenodd"}))}const ga=y.forwardRef(pa);function wa({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M1 5.25A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25v9.5A2.25 2.25 0 0 1 16.75 17H3.25A2.25 2.25 0 0 1 1 14.75v-9.5Zm1.5 5.81v3.69c0 .414.336.75.75.75h13.5a.75.75 0 0 0 .75-.75v-2.69l-2.22-2.219a.75.75 0 0 0-1.06 0l-1.91 1.909.47.47a.75.75 0 1 1-1.06 1.06L6.53 8.091a.75.75 0 0 0-1.06 0l-2.97 2.97ZM12 7a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",clipRule:"evenodd"}))}const va=y.forwardRef(wa),yt="data-aqmx-key-repeat",We=Object.freeze({[yt]:"allow"}),Ea=`[${yt}="${We[yt]}"]`,xa=()=>{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(Ea)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},qe=Object.freeze([1/H.GOLDEN_RATIO**2,1/H.GOLDEN_RATIO,1,H.GOLDEN_RATIO,H.GOLDEN_RATIO**2]),sn=Object.freeze({mode:"fit"}),ba=1,Cr=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),an=`[data-testid="${Cr["data-testid"]}"]`,Or=d.createContext(null),Sa=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=ba?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,ln=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<qe.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?qe.findIndex(o=>o>t):qe.findLastIndex(o=>o<t);return r===-1?null:r},cn=(e,t,n)=>{if(e.mode==="level"){const o=ln(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=ln(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},ya=(e,t)=>{if(e<=0||t<=0)return 0;const n=Math.trunc(Math.log(t/e)/Math.log(H.GOLDEN_RATIO));return n===0?0:n},dn=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}}},ka=e=>{const t=qe[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},un=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},Ra=({document:e})=>{const{labels:t}=F(),n=d.use(Or),[r]=d.useState(()=>n===null?null:n.read(e.url)),[o,s]=d.useState(r===null?sn:r.zoom),[a,i]=d.useState(r===null?null:r.reported),[m,f]=d.useState(null),c=d.useRef(null),u=d.useCallback(j=>{const{naturalWidth:p,naturalHeight:g}=j;i(R=>un(R,p,g))},[]),h=d.useCallback(j=>{c.current=j,!(j===null||!j.complete)&&(j.naturalWidth>0||j.naturalHeight>0?u(j):j.decode().then(()=>u(j),()=>{}))},[u]);d.useEffect(()=>{n!==null&&a!==null&&n.save(e.url,{zoom:o,reported:a})},[n,e.url,o,a]),d.useLayoutEffect(()=>{const j=c.current;if(j===null||a===null||o.mode!=="fit")return;const p=()=>f(R=>un(R,j.clientWidth,j.clientHeight));if(p(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(p);return g.observe(j),()=>g.disconnect()},[a,o.mode]);const w=a===null||m===null?null:Sa(a,m),E=cn(o,w,-1),b=cn(o,w,1),T=o.mode==="level"?ka(o.index):null,O=d.useRef({zoomIn:b,zoomOut:E});d.useLayoutEffect(()=>{O.current={zoomIn:b,zoomOut:E}});const L=d.useRef(null);d.useLayoutEffect(()=>{const j=L.current,p=c.current?.closest(an);L.current=null,!(j===null||p===null||p===void 0)&&(p.scrollLeft=j.across*p.scrollWidth-j.x,p.scrollTop=j.down*p.scrollHeight-j.y)},[o]),d.useEffect(()=>{const j=c.current?.closest(an);if(j==null)return;let p=null;const g=I=>{const $=dn(I.touches);p=$===null?null:{distance:$.distance,steps:0}},R=I=>{const $=dn(I.touches);if(p===null||$===null)return;I.preventDefault();const x=ya(p.distance,$.distance);if(x===p.steps)return;const k=x>p.steps?1:-1,A=k===1?O.current.zoomIn:O.current.zoomOut;if(A===null)return;p.steps+=k;const M=j.getBoundingClientRect(),P=$.middle.x-M.left,B=$.middle.y-M.top;L.current=j.scrollWidth>0&&j.scrollHeight>0?{x:P,y:B,across:(j.scrollLeft+P)/j.scrollWidth,down:(j.scrollTop+B)/j.scrollHeight}:null,s(A)},N=I=>{I.touches.length<2&&(p=null)};return j.addEventListener("touchstart",g,{passive:!0}),j.addEventListener("touchmove",R,{passive:!1}),j.addEventListener("touchend",N,{passive:!0}),j.addEventListener("touchcancel",N,{passive:!0}),()=>{j.removeEventListener("touchstart",g),j.removeEventListener("touchmove",R),j.removeEventListener("touchend",N),j.removeEventListener("touchcancel",N)}},[]);const q=o.mode==="level"&&T!==null?{width:`${o.base.width*T}px`,height:`${o.base.height*T}px`}:void 0;return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[l.jsxs(Me,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(va,{}),children:[l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":E===null,onClick:()=>{E!==null&&s(E)},...We,children:l.jsx(ha,{})}),l.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:T===null?t.imageFitLevel:t.imageZoomLevel(Math.round(T*100))}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":b===null,onClick:()=>{b!==null&&s(b)},...We,children:l.jsx(ga,{})}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(sn),children:l.jsx(fa,{})})]}),l.jsx(Ae,{scrollerProps:Cr,children:l.jsx("img",{ref:h,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:q,onLoad:j=>u(j.currentTarget),"data-testid":"markdown-explorer-image"})})]})},Ta=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"}},Ar=d.createContext(null),Qe=d.createContext(void 0),Mr=d.createContext(null),Je=()=>{const e=d.use(Ar);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},La=()=>{const e=d.use(Mr);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},et=(e,t,n,r)=>t.kind==="panel"?H.explorerHref(e,{view:"tree",source:n,doc:r}):t.view==="single"?H.explorerHref(e,{view:"single",source:n,doc:r,overrides:t.overrides,embed:t.embed}):H.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides}),Ca=({children:e})=>{const{config:t}=F(),n=Je(),r=Ke(),o=r.kind==="location"?r.location.source:void 0,s=te.useHref(et(t,n.navigation,o,n.currentPath));return l.jsx(Qe,{value:o,children:l.jsx(Mr,{value:s,children:e})})},Oa='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',Aa=e=>{const t=e instanceof Element?e.closest(Oa):null;return t===null?null:t.getAttribute("data-doc-path")},tt=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Ma=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:a,scope:i,children:m})=>{const f=te.useHref(e),c=u=>{if(tt(u)){if(u.preventDefault(),t===i.currentPath&&n!==""){i.scrollWithin(n);return}a(t,n)}};return l.jsx("a",{...s,href:f,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:c,children:m})},Na=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:a}=F(),i=Je(),m=d.use(Qe),f=na(e),{navigation:c}=i,u=`${et(a,c,m,t)}${f}`,h=n===!1?"false":void 0;return c.kind==="page"?l.jsx(fr,{...o,to:u,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":h,children:s}):l.jsx(Ma,{to:u,docPath:t,fragment:f,exists:h,className:r,attributes:o,onDocumentLink:c.onDocumentLink,scope:i,children:s})},Da=({className:e,attributes:t,children:n})=>{const{labels:r}=F();return l.jsxs("a",{...t,className:e===void 0?"aqmx-document-inert-link":`${e} aqmx-document-inert-link`,title:r.inertLink,"data-link-kind":"doc","data-doc-exists":"false",children:[n,l.jsxs("span",{className:"aqmx-sr-only",children:[" (",r.inertLink,")"]})]})},ja=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=F(),a=d.use(Qe),i=te.useHref(`${et(s,r.navigation,a,r.currentPath)}${e}`),m=f=>{tt(f)&&(f.preventDefault(),r.scrollWithin(e))};return l.jsx("a",{...n,href:i,className:t,onClick:m,children:o})},Pa=({href:e,className:t,attributes:n,children:r})=>{const o=Je();if(o.navigation.kind==="page"){const s=a=>{if(!tt(a))return;const i=a.currentTarget;e==="#"?o.followEmptyFragment(a.nativeEvent):i.href===i.ownerDocument.URL&&o.followSameUrlJump(e,a.nativeEvent)};return l.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return l.jsx(ja,{href:e,className:t,attributes:n,scope:o,children:r})},_a=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:a})=>t==="doc"?n===void 0||!_.isAcceptableDocumentPath(n)?l.jsx(Da,{className:o,attributes:s,children:a}):l.jsx(Na,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:a}):e.startsWith("#")?l.jsx(Pa,{href:e,className:o,attributes:s,children:a}):l.jsx("a",{...s,href:e,className:o,children:a}),Ia=()=>{const{config:e}=F(),t=Je(),n=d.use(Qe),r=Oe();return d.useCallback((o,s)=>{if(!tt(s))return!0;s.preventDefault();const a=kr(o.id),{navigation:i}=t;return i.kind==="panel"||Pt(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(a),!0):(r(`${et(e,i,n,t.currentPath)}${a}`,"follow-link"),!0)},[e,t,n,r])},Fa=()=>{const e=La();return d.useCallback(t=>`${e}${kr(t.id)}`,[e])};function $a({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M3 3.5A1.5 1.5 0 0 1 4.5 2h6.879a1.5 1.5 0 0 1 1.06.44l4.122 4.12A1.5 1.5 0 0 1 17 7.622V16.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 16.5v-13Z"}))}const qa=y.forwardRef($a);function Ba({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M1 4.75C1 3.784 1.784 3 2.75 3h14.5c.966 0 1.75.784 1.75 1.75v10.515a1.75 1.75 0 0 1-1.75 1.75h-1.5c-.078 0-.155-.005-.23-.015H4.48c-.075.01-.152.015-.23.015h-1.5A1.75 1.75 0 0 1 1 15.265V4.75Zm16.5 7.385V11.01a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25Zm0 2.005a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .108.069.2.165.235h1.585a.25.25 0 0 0 .25-.25v-1.11Zm-15 1.11v-1.11a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.164.235H2.75a.25.25 0 0 1-.25-.25Zm2-4.24v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V11.01a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25Zm13-2.005V7.88a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25ZM4.25 7.63a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V7.88a.25.25 0 0 1 .25-.25h1.5Zm0-3.13a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5Zm11.5 1.625a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5Zm-9 3.125a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",clipRule:"evenodd"}))}const Ua=y.forwardRef(Ba);function Ha({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M17.721 1.599a.75.75 0 0 1 .279.583v11.29a2.25 2.25 0 0 1-1.774 2.2l-2.041.44a2.216 2.216 0 0 1-.938-4.332l2.662-.577a.75.75 0 0 0 .591-.733V6.112l-8 1.73v7.684a2.25 2.25 0 0 1-1.774 2.2l-2.042.44a2.216 2.216 0 1 1-.935-4.331l2.659-.573A.75.75 0 0 0 7 12.529V4.236a.75.75 0 0 1 .591-.733l9.5-2.054a.75.75 0 0 1 .63.15Z",clipRule:"evenodd"}))}const za=y.forwardRef(Ha),Va=Object.freeze({className:"aqmx-document-stage"}),Za=()=>()=>{},Wa=()=>navigator.pdfViewerEnabled!==!1,Ga=()=>null,Ka=({document:e})=>{const{labels:t}=F(),n=d.useSyncExternalStore(Za,Wa,Ga);return n===null?null:n?l.jsx("iframe",{className:"aqmx-document-frame",src:e.url,title:e.name,"data-testid":"markdown-explorer-media-player"}):l.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-pdf-not-shown",children:[l.jsx("p",{className:"aqmx-callout-body",children:t.pdfNotShown}),l.jsxs("div",{className:"aqmx-callout-actions",children:[l.jsx("a",{className:"aqmx-callout-action",href:e.url,target:"_blank",rel:"noopener noreferrer","data-testid":"markdown-explorer-pdf-not-shown-open",children:t.openInNewTab}),l.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-pdf-not-shown-download",children:t.download})]})]})},Xa=e=>{switch(e){case"video":return l.jsx(Ua,{});case"audio":return l.jsx(za,{});case"pdf":return l.jsx(qa,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},Ya=({document:e})=>{const{labels:t}=F();switch(e.mediaType){case"video":return l.jsx("video",{className:"aqmx-document-video",src:e.url,controls:!0,preload:"metadata","aria-label":e.name,"data-testid":"markdown-explorer-media-player",children:t.mediaUnsupported});case"audio":return l.jsx("audio",{className:"aqmx-document-audio",src:e.url,controls:!0,preload:"metadata","aria-label":e.name,"data-testid":"markdown-explorer-media-player",children:t.mediaUnsupported});case"pdf":return l.jsx(Ka,{document:e});default:{const n=e.mediaType;throw new RangeError(`[markdown-explorer] unknown media type ${String(n)}`)}}},Qa=({document:e})=>l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[l.jsx(Me,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:Xa(e.mediaType)}),l.jsx(Ae,{scrollerProps:Va,children:l.jsx(Ya,{document:e})})]}),_t=e=>{switch(e.kind){case"markdown":return"markdown";case"image":return e.imageType==="svg"?"svg":null;case"spreadsheet":return e.format==="workbook"?null:e.format;default:return null}},Ja=e=>{const{documents:t}=F(),n=d.useCallback(()=>t.peek(e),[t,e]),r=d.useCallback(()=>t.peekSeeded(e),[t,e]),o=d.useSyncExternalStore(t.subscribe,n,r),s=le(o);return s===null?null:_t(s.document)},Nr=e=>{const{config:t}=F(),n=Oe(),r=d.useCallback(()=>n(H.explorerHref(t,{...e,markup:!e.markup}),"browse"),[t,n,e]);return d.useMemo(()=>({shown:e.markup,toggle:r}),[e.markup,r])};function el({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"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 tl=y.forwardRef(el),nl=100,rl=32767,Be=Object.freeze({maxCells:Gt.SPREADSHEET_MAX_OPERATION_CELLS,maxColumns:Gt.SPREADSHEET_MAX_OPERATION_CELLS/nl,maxCellLength:rl}),Dr=44,jr=10,Pr=13,_e='"',fn=(e,t)=>{let n=t;for(;n<e.length;){const r=e.charCodeAt(n);if(r===Dr||r===jr||r===Pr)return n;n+=1}return n};function*ol(e,t){let n=[],r=0;for(;;){let o;if(e.startsWith(_e,r)){o="";let a=r+1;for(;;){const m=e.indexOf(_e,a);if(m<0){o+=e.slice(a),r=e.length;break}if(o+=e.slice(a,m),e.startsWith(_e,m+1)){o+=_e,a=m+2;continue}r=m+1;break}const i=fn(e,r);o+=e.slice(r,i),r=i}else{const a=fn(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!==Dr&&(yield n,n=[],s===Pr&&e.charCodeAt(r)===jr&&(r+=1),r>=e.length))return}}const sl=(e,t,n)=>t==="csv"?ol(e,n):n==="whole"?vt.iterateTsvRows(e):vt.iterateTsvPrefixRows(e),al=(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)},_r=(e,t)=>{const n=[];let r=0,o=!1,s=!1;for(const i of e){const m=i.length>t.maxColumns?i.slice(0,t.maxColumns):i,f=Math.max(r,m.length);if((n.length+1)*f>t.maxCells){s=!0;break}const c=m.some(u=>u.length>t.maxCellLength)?m.map(u=>al(u,t.maxCellLength)):m;c!==i&&(o=!0),n.push(c),r=f}return{rows:n.map(i=>i.length===r?i:[...i,...Array(r-i.length).fill("")]),truncated:s||o,full:s}},it=(e,t,n,r,o)=>{const s=H.decodeText(e,t,r);if(s===null)return{kind:"unreadable",code:"encoding",encodings:H.textEncodingsOf(e,t,r)};if(s.includes("\0"))return{kind:"unreadable",code:"binary"};const a=_r(sl(s,n,t?"whole":"prefix"),o);return t?a.truncated||a.rows.some(i=>i.some(m=>m!==""))?{kind:"table",table:a}:{kind:"empty"}:a.rows.length===0?{kind:"unreadable",code:"long-row"}:{kind:"table",table:{...a,truncated:!0}}},ll=Object.freeze({maxPartBytes:64*1024*1024,maxSheets:256}),Ir=e=>{const t=[];let n=0,r=!1;const o=s=>{if(r)return;const a=Math.max(n,Math.min(s.length,e.maxColumns));(t.length+1)*a>e.maxCells&&(r=!0),t.push(s),n=a};return{addRow:(s,a,i)=>{if(a.size===0||r)return;let m=-1;for(const u of a.keys())u>m&&(m=u);const f=Array(Math.min(m,e.maxColumns)+1).fill("");for(const[u,h]of a)u<=e.maxColumns&&(f[u]=h);const c=Math.min(f.length,e.maxColumns);if(n===0&&(s+1)*c>e.maxCells){const u=Math.floor(e.maxCells/c);for(;t.length<u;)t.push([]);o(f);return}for(;t.length<s&&!r;)o([]);for(let u=0;u<i&&!r;u+=1)o(u===0?f:[...f])},full:()=>r,table:()=>_r(t,e)}},il=e=>{const t=Array.from(e.currentTarget.querySelectorAll('[role="tab"]')),n=e.target instanceof HTMLButtonElement?t.indexOf(e.target):-1;if(n===-1)return;const r=getComputedStyle(e.currentTarget).direction==="rtl"?"ArrowRight":"ArrowLeft",o=r==="ArrowLeft"?"ArrowRight":"ArrowLeft",s=e.key===o?(n+1)%t.length:e.key===r?(n-1+t.length)%t.length:e.key==="Home"?0:e.key==="End"?t.length-1:null;s!==null&&(e.preventDefault(),t[s]?.focus())},cl=({names:e,selected:t,onSelect:n,label:r,tabIdOf:o,panelId:s})=>l.jsx("div",{role:"tablist","aria-label":r,className:"aqmx-sheet-tabs","data-testid":"markdown-explorer-spreadsheet-sheets",onKeyDown:il,children:e.map((a,i)=>l.jsx("button",{type:"button",role:"tab",id:o(i),"aria-selected":i===t,"aria-controls":s,tabIndex:i===t?0:-1,className:"aqmx-sheet-tab","data-aqmx-sheet-tab":i,onClick:()=>n(i),children:a},i))}),Fr=64*1024,dl=e=>{let t=new Uint8Array(Math.min(e,Fr)),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}},ul=async e=>{for(;;){const{done:t,value:n}=await e.read();if(t)return!0;if(n.byteLength>0)return!1}},fl=async(e,t)=>{const{format:n,legacyEncoding:r,maxBytes:o,budget:s}=t,a=e.getReader(),i=dl(o);let m=Fr;try{for(;;){const{done:f,value:c}=await a.read();if(f)return it(i.bytes(),!0,n,r,s);const u=o-i.length();if(i.append(c.byteLength>u?c.subarray(0,u):c),i.length()===o){const w=c.byteLength<=u&&await ul(a);return it(i.bytes(),w,n,r,s)}if(i.length()<m)continue;m=i.length()*2;const h=it(i.bytes(),!1,n,r,s);if(h.kind==="unreadable"&&h.code!=="long-row"||h.kind==="table"&&h.table.full)return h}}finally{a.cancel().catch(()=>{})}},$r=async(e,t,n,r)=>{const o=await e.asset(_.explorerPlainTextHref(t),r);if(o.status==="cancelled")return null;if(o.status==="error")return{kind:"failure",failure:o.failure};let s;try{s=await fl(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},It=(e,t,n)=>{const{documents:r,labels:o}=F(),s=Hs(),a=d.useCallback(()=>r.answerStampOf(e),[r,e]),i=d.useSyncExternalStore(r.subscribe,a,a),[m,f]=d.useState(0),c=d.useMemo(()=>({read:n,stamp:i,attempt:m}),[n,i,m]),[u,h]=d.useState({settled:null,shown:null,failure:null}),w=d.useRef(null),E=d.useEffectEvent((O,L)=>{if(w.current?.settle(L.stamp,O.kind==="failure"?O.failure:null),O.kind==="read"){h({settled:L,shown:O.value,failure:null});return}if(u.shown!==null){h({settled:L,shown:u.shown,failure:null});return}h({settled:L,shown:null,failure:O.failure}),s.announceFailure(o.documentFailed(t,re(o,O.failure.reason)))});d.useEffect(()=>{const O=s.readPart();return w.current=O,()=>{w.current=null,O.release()}},[s]),d.useEffect(()=>{const O=new AbortController;return c.read(O.signal).then(L=>{L!==null&&!O.signal.aborted&&E(L,c)}),()=>O.abort()},[c]);const b=u.settled!==c&&(u.shown!==null||u.failure!==null);d.useLayoutEffect(()=>b?s.holdBusy():void 0,[b,s]);const T=d.useCallback(()=>f(O=>O+1),[]);return{shown:u.shown,failure:u.failure,retry:T}},qr=(e,t)=>{const n={};for(const r of Object.keys(ve.SPREADSHEET_BLOCK_LABEL_CATALOGS[t])){const o=e[Lt(r)];o!==ve.SPREADSHEET_BLOCK_LABEL_CATALOGS[t][r].text&&(n[r]=o)}return n},ml=(e,t)=>Object.fromEntries(Object.entries(qr(e,t)).map(([n,r])=>[`spreadsheet${n.charAt(0).toUpperCase()}${n.slice(1)}`,r])),hl=(e,t)=>({...ml(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,mermaidFullscreen:e.viewerMermaidFullscreen,mermaidExitFullscreen:e.viewerMermaidExitFullscreen,mermaidFullscreenDialog:e.viewerMermaidFullscreenDialog,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,svgImageFullscreen:e.viewerSvgImageFullscreen,svgImageExitFullscreen:e.viewerSvgImageExitFullscreen,svgImageFullscreenDialog:e.viewerSvgImageFullscreenDialog}),Br=(e,t,n)=>t!==void 0?t:n!==void 0?n:e.defaultDocumentStyle,Ur=(e,t)=>e!==void 0?e:t!==void 0?t:Co.DEFAULT_CONTENT_ALIGN;class Y extends Error{refusal;constructor(t,n){super(n),this.name="WorkbookError",this.refusal=t}}const pl=new Map([["lt","<"],["gt",">"],["amp","&"],["quot",'"'],["apos","'"]]),gl=/&(#x[0-9A-Fa-f]+|#[0-9]+|[A-Za-z_][A-Za-z0-9._-]*);/gu,wl=/([^\s=/>]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/gu,vl=/^[^\s/>]+/u,ge=e=>{throw new Y("not-workbook",`the XML ${e}`)},mn=e=>Number.isInteger(e)&&e>=0&&e<=1114111?String.fromCodePoint(e):ge(`refers to the code point ${e}`),Hr=e=>e.includes("&")?e.replace(gl,(t,n)=>n.startsWith("#x")?mn(Number.parseInt(n.slice(2),16)):n.startsWith("#")?mn(Number.parseInt(n.slice(1),10)):pl.get(n)??ge(`names the undeclared entity ${t}`)):e,kt=e=>e.slice(e.indexOf(":")+1),El=(e,t)=>{let n="";for(let r=t;r<e.length;r+=1){const o=e[r];if(n!=="")o===n&&(n="");else if(o==='"'||o==="'")n=o;else if(o===">")return r}return-1},xl=e=>{const t=new Map;for(const n of e.matchAll(wl))t.set(kt(n[1]??""),Hr(n[2]??n[3]??""));return t},zr=(e,t)=>{let n="";const r=()=>{let o=0;for(;!t();){const s=n.indexOf("<",o);if(s===-1)break;if(s>o&&(e.text?.(Hr(n.slice(o,s))),o=s),n.startsWith("<!--",s)){const f=n.indexOf("-->",s+4);if(f===-1)break;o=f+3;continue}if(n.startsWith("<![CDATA[",s)){const f=n.indexOf("]]>",s+9);if(f===-1)break;e.text?.(n.slice(s+9,f)),o=f+3;continue}const a=n.slice(s);if(a.length<9&&("<!--".startsWith(a)||"<![CDATA[".startsWith(a)))break;if(n.startsWith("<!",s)&&ge("declares a document type or another declaration"),n.startsWith("<?",s)){const f=n.indexOf("?>",s+2);if(f===-1)break;o=f+2;continue}const i=El(n,s+1);if(i===-1)break;const m=n.slice(s+1,i);if(m.startsWith("/"))e.end?.(kt(m.slice(1).trim()));else{const f=m.endsWith("/"),c=f?m.slice(0,-1):m,u=vl.exec(c)?.[0]??ge("has a tag without a name"),h=kt(u);e.start?.(h,xl(c.slice(u.length)),f),f&&e.end?.(h)}o=i+1}n=n.slice(o)};return{write:o=>{n+=o,r()},finish:()=>{r(),!t()&&n.includes("<")&&ge("ends inside a tag, a comment or a section")}}},Ne=async(e,t,n)=>{const r=zr(t,n),o=new TextDecoder("utf-8",{fatal:!0}),s=e.getReader();try{for(;!n();){const{done:a,value:i}=await s.read();if(a){r.write(o.decode()),r.finish();return}r.write(o.decode(i,{stream:!0}))}}catch(a){if(a instanceof Y)throw a;ge("could not be read as UTF-8 text")}finally{s.cancel().catch(()=>{})}},bl=101010256,Sl=33639248,yl=67324752,Vr=22,kl=65535,hn=46,pn=30,Rl=1,gn=0,Tl=8,Ll=65535,be=4294967295,Cl=new TextDecoder("utf-8"),ee=e=>{throw new Y("not-workbook",`the ZIP package ${e}`)},Ol=e=>{const t=e.byteLength-Vr,n=Math.max(0,t-kl);for(let r=t;r>=n;r-=1)if(e.getUint32(r,!0)===bl)return r;return ee("has no end of central directory record")},Al=e=>{if(e.byteLength<Vr)return ee("is shorter than its end record");const t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=Ol(t),r=t.getUint16(n+4,!0),o=t.getUint16(n+6,!0),s=t.getUint16(n+10,!0),a=t.getUint32(n+12,!0),i=t.getUint32(n+16,!0);if(r!==0||o!==0)return ee("spans several disks");if(s===Ll||a===be||i===be)return ee("is a ZIP64 package");if(i+a>n)return ee("has a central directory past its end record");const m=new Map;let f=i;for(let c=0;c<s;c+=1){if(f+hn>n||t.getUint32(f,!0)!==Sl)return ee("has a malformed central directory");const u=t.getUint16(f+8,!0),h=t.getUint16(f+10,!0),w=t.getUint32(f+20,!0),E=t.getUint32(f+24,!0),b=t.getUint16(f+28,!0),T=t.getUint16(f+30,!0),O=t.getUint16(f+32,!0),L=t.getUint32(f+42,!0),q=f+hn;if(q+b>n)return ee("has a name past its central directory");const j=Cl.decode(e.subarray(q,q+b));if(w===be||E===be||L===be)return ee("has a ZIP64 entry");if(!j.endsWith("/")){if(m.has(j))return ee(`names ${j} twice`);m.set(j,{name:j,encrypted:(u&Rl)!==0,method:h,compressedSize:w,uncompressedSize:E,localHeaderOffset:L})}f=q+b+T+O}return{bytes:e,entries:m}},Ml=(e,t)=>{const{bytes:n}=e,r=new DataView(n.buffer,n.byteOffset,n.byteLength),o=t.localHeaderOffset;if(o+pn>n.byteLength||r.getUint32(o,!0)!==yl)return ee(`has no local header for ${t.name}`);const s=o+pn+r.getUint16(o+26,!0)+r.getUint16(o+28,!0),a=s+t.compressedSize;return a>n.byteLength?ee(`has the data of ${t.name} past its end`):{start:s,end:a}},Zr=e=>new ReadableStream({start(t){e.byteLength>0&&t.enqueue(e),t.close()}}),Nl=e=>Zr(e).pipeThrough(new DecompressionStream("deflate-raw")),Dl=(e,t)=>{let n=0;return new TransformStream({transform(r,o){if(n+=r.byteLength,n>t){o.error(new Y("too-large",`${e} inflates past ${t} bytes`));return}o.enqueue(r)}})},Ce=(e,t,n)=>{const r=e.entries.get(t);if(r===void 0)return null;if(r.encrypted)throw new Y("encrypted",`${t} is encrypted`);if(r.method!==gn&&r.method!==Tl)return ee(`compresses ${t} with method ${r.method}`);if(r.uncompressedSize>n)throw new Y("too-large",`${t} declares ${r.uncompressedSize} bytes`);const{start:o,end:s}=Ml(e,r),a=e.bytes.subarray(o,s);return(r.method===gn?Zr(a):Nl(a)).pipeThrough(Dl(t,n))},Ge=async(e,t,n)=>{const r=Ce(e,t,n);if(r===null)return null;const o=new TextDecoder("utf-8",{fatal:!0}),s=r.getReader();let a="";try{for(;;){const{done:i,value:m}=await s.read();if(i)break;a+=o.decode(m,{stream:!0})}return a+o.decode()}catch(i){if(i instanceof Y)throw i;return ee(`has ${t}, which does not inflate to UTF-8 text`)}finally{s.releaseLock()}},wn="content.xml",jl="META-INF/manifest.xml",Wr=e=>{throw new Y("not-workbook",`the spreadsheet ${e}`)},vn=(e,t)=>Ce(e,wn,t.maxPartBytes)??Wr(`has no ${wn}`),Pl=async(e,t)=>{const n=Ce(e,jl,t.maxPartBytes);if(n===null)return!1;let r=!1;return await Ne(n,{start:o=>{o==="encryption-data"&&(r=!0)}},()=>r),r},_l=async e=>{const t=[],n=new Set;let r=null,o=0;return await Ne(e,{start:(s,a,i)=>{s==="style"?r=a.get("family")==="table"?a.get("name")??null:null:s==="table-properties"&&r!==null&&a.get("display")==="false"?n.add(r):s==="table"&&(o===0&&t.push({name:a.get("name")??"",style:a.get("style-name")??""}),i||(o+=1))},end:s=>{s==="style"?r=null:s==="table"&&(o=Math.max(0,o-1))}},()=>!1),{tables:t,hidingStyles:n}},ct=e=>{const t=Number(e);return Number.isInteger(t)&&t>0?t:1},Il=async(e,t,n)=>{const r=Ir(n);let o=0,s=0,a=!1,i=!1,m=0,f=1,c=new Map,u=0,h=null;return await Ne(e,{start:(w,E,b)=>{if(w==="table"){s===0&&(a=o===t,o+=1),b||(s+=1);return}!a||s!==1||(w==="table-row"?(f=ct(E.get("number-rows-repeated")),c=new Map,u=0):w==="table-cell"||w==="covered-table-cell"?h={repeat:ct(E.get("number-columns-repeated")),covered:w==="covered-table-cell",parts:[],paragraphs:0,paragraphDepth:0,annotationDepth:0}:h!==null&&h.annotationDepth===0&&(w==="annotation"&&!b?h.annotationDepth+=1:w==="p"||w==="h"?(h.paragraphs>0&&h.parts.push(`
12
12
  `),h.paragraphs+=1,b||(h.paragraphDepth+=1)):h.paragraphDepth>0&&(w==="s"?h.parts.push(" ".repeat(ct(E.get("c")))):w==="tab"?h.parts.push(" "):w==="line-break"&&h.parts.push(`
13
- `))))},end:w=>{if(w==="table"){s=Math.max(0,s-1),s===0&&a&&(a=!1,i=!0);return}if(h!==null&&h.annotationDepth>0){w==="annotation"&&(h.annotationDepth-=1);return}if(!(!a||s!==1))if((w==="table-cell"||w==="covered-table-cell")&&h!==null){const E=h.covered?"":h.parts.join("");if(E!==""){const b=Math.min(u+h.repeat,n.maxColumns+1);for(let T=u;T<b;T+=1)c.set(T,E)}u+=h.repeat,h=null}else w==="table-row"?(r.addRow(m,c,f),m+=f):(w==="p"||w==="h")&&h!==null&&(h.paragraphDepth=Math.max(0,h.paragraphDepth-1))},text:w=>{h!==null&&h.annotationDepth===0&&h.paragraphDepth>0&&h.parts.push(w)}},()=>i||r.full()),r.table()},Fl=async(e,t)=>{if(await Pl(e,t))throw new Y("encrypted","the spreadsheet's manifest names encryption data");const{tables:n,hidingStyles:r}=await _l(vn(e,t)),o=[];let s=0;return n.forEach((a,i)=>{if(r.has(a.style)){s+=1;return}o.push({name:a.name,read:async m=>Il(vn(e,t),i,m)})}),o.length===0&&Wr("shows no table"),{sheets:o.slice(0,t.maxSheets),unshownSheets:s,unlistedSheets:Math.max(0,o.length-t.maxSheets)}},pe=Object.freeze({kind:"general"}),$l=new Map([[0,"General"],[1,"0"],[2,"0.00"],[3,"#,##0"],[4,"#,##0.00"],[9,"0%"],[10,"0.00%"],[11,"0.00E+00"],[12,"# ?/?"],[13,"# ??/??"],[14,"mm-dd-yy"],[15,"d-mmm-yy"],[16,"d-mmm"],[17,"mmm-yy"],[18,"h:mm AM/PM"],[19,"h:mm:ss AM/PM"],[20,"h:mm"],[21,"h:mm:ss"],[22,"m/d/yy h:mm"],...[27,28,29,30,31,34,35,36,50,51,52,53,54,55,56,57,58].map(e=>[e,"yyyy-mm-dd"]),[32,"h:mm"],[33,"h:mm:ss"],[37,"#,##0 ;(#,##0)"],[38,"#,##0 ;[Red](#,##0)"],[39,"#,##0.00;(#,##0.00)"],[40,"#,##0.00;[Red](#,##0.00)"],[45,"mm:ss"],[46,"[h]:mm:ss"],[47,"mmss.0"],[48,"##0.0E+0"],[49,"@"]]),ql=/^\[(h+|m+|s+)\]$/iu,Bl=e=>{let t="",n=!1;for(let r=0;r<e.length;r+=1){const o=e[r];if(o===";")break;if(o==='"'){const s=e.indexOf('"',r+1);r=s===-1?e.length:s}else if(o==="\\"||o==="_"||o==="*")r+=1;else if(o==="["){const s=e.indexOf("]",r+1),a=e.slice(r,s===-1?e.length:s+1);ql.test(a)&&(t+=a.slice(1,-1),n=!0),r=s===-1?e.length:s}else t+=o}return{text:t.toLowerCase(),elapsed:n}},Ul=e=>{const{text:t,elapsed:n}=Bl(e);if(t===""||t==="general"||t.includes("@")||/[0#?.]e[+-]/u.test(t))return pe;const r=n||/[hs]/u.test(t)||t.includes("am/pm")||t.includes("a/p"),o=/[ydge]/u.test(t.replace(/am\/pm|a\/p/gu,""))||t.includes("m")&&!r;if(o||r)return{kind:"date-time",date:o,time:r,seconds:t.includes("s"),elapsed:n};if(/[0#?]\s*\/\s*[0#?]/u.test(t))return pe;const s=/[0#?][0#?,]*(?:\.[0#?]*)?,*/u.exec(t)?.[0];if(s===void 0)return pe;const a=/,*$/u.exec(s)?.[0].length??0,[i="",m=""]=s.slice(0,s.length-a).split("."),f=(m.match(/[0#?]/gu)??[]).length;return t.includes("%")?{kind:"percent",decimals:f}:{kind:"fixed",decimals:f,grouping:i.includes(","),scale:1e3**a}},Hl=(e,t)=>{const n=t.get(e)??$l.get(e);return n===void 0?pe:Ul(n)},Ft=e=>{if(Number.isInteger(e)&&Math.abs(e)<1e15)return String(e);const[t="",n]=e.toPrecision(15).split("e"),r=t.includes(".")?t.replace(/0+$/u,"").replace(/\.$/u,""):t;return n===void 0?r:`${r}E${n.startsWith("-")?n:`+${n.replace("+","")}`}`},En=(e,t,n)=>{const r=Math.abs(e).toFixed(t);if(r.includes("e"))return Ft(e);const[o="",s]=r.split("."),a=n?o.replace(/\B(?=(\d{3})+(?!\d))/gu,","):o;return`${e<0&&/[1-9]/u.test(r)?"-":""}${a}${s===void 0?"":`.${s}`}`},zl=864e5,xn=86400,Vl=2958465,we=(e,t)=>String(e).padStart(t,"0"),Zl=(e,t)=>{if(!t&&e===0)return"1900-01-00";if(!t&&e===60)return"1900-02-29";const n=t?Date.UTC(1904,0,1):e<60?Date.UTC(1899,11,31):Date.UTC(1899,11,30),r=new Date(n+e*zl);return`${we(r.getUTCFullYear(),4)}-${we(r.getUTCMonth()+1,2)}-${we(r.getUTCDate(),2)}`},Wl=(e,t,n)=>{if(e<0||e>=Vl+1)return Ft(e);let r=Math.floor(e),o=Math.round((e-r)*xn);o===xn&&(r+=1,o=0);const s=Math.floor(o/3600),a=Math.floor(o%3600/60),i=`${we(t.elapsed?r*24+s:s,2)}:${we(a,2)}${t.seconds?`:${we(o%60,2)}`:""}`;if(t.elapsed||!t.date)return i;const m=Zl(r,n);return t.time?`${m} ${i}`:m},Gl=(e,t,n)=>{switch(t.kind){case"general":return Ft(e);case"date-time":return Wl(e,t,n);case"percent":return`${En(e*100,t.decimals,!1)}%`;case"fixed":return En(e/t.scale,t.decimals,t.grouping)}},Gr="_rels/.rels",oe=e=>{throw new Y("not-workbook",`the workbook ${e}`)},$t=(e,t)=>{const n=zr(t,()=>!1);n.write(e),n.finish()},Kl=(e,t)=>{try{return decodeURIComponent(e)}catch{return oe(`points to a malformed part name (${t})`)}},Xl=(e,t)=>{const r=[...t.startsWith("/")?[]:e.split("/").slice(0,-1)];for(const o of t.split("/"))o===""||o==="."||(o===".."?(r.length===0&&oe(`points above its root (${t})`),r.pop()):r.push(Kl(o,t)));return r.join("/")},Yl=e=>{const t=e.lastIndexOf("/");return`${e.slice(0,t+1)}_rels/${e.slice(t+1)}.rels`},bn=async(e,t,n)=>{const r=await Ge(e,t===""?Gr:Yl(t),n.maxPartBytes),o=new Map;return r===null||$t(r,{start:(s,a)=>{if(s!=="Relationship")return;const i=a.get("Id"),m=a.get("Type"),f=a.get("Target");i===void 0||m===void 0||f===void 0||a.get("TargetMode")==="External"||o.set(i,{type:m,target:Xl(t,f)})}}),o},dt=(e,t)=>{for(const n of e.values())if(n.type.endsWith(`/${t}`))return n.target;return null},Ql=e=>{const t=[];let n=!1;return $t(e,{start:(r,o)=>{if(r==="workbookPr"){const s=o.get("date1904");n=s==="1"||s==="true"}else r==="sheet"&&t.push({name:o.get("name")??"",state:o.get("state")??"visible",relationship:o.get("id")??""})}}),{sheets:t,date1904:n}},Jl=async e=>{const t=[];let n=null,r=!1,o=0;return await Ne(e,{start:(s,a,i)=>{s==="si"?n=[]:s==="rPh"&&!i?o+=1:s==="t"&&o===0&&(r=!i)},end:s=>{s==="si"&&n!==null?(t.push(n.join("")),n=null):s==="rPh"?o=Math.max(0,o-1):s==="t"&&(r=!1)},text:s=>{r&&n!==null&&n.push(s)}},()=>!1),t},ei=e=>{const t=new Map,n=[];let r=!1;return $t(e,{start:(o,s)=>{if(o==="numFmt"){const a=Number(s.get("numFmtId")),i=s.get("formatCode");Number.isInteger(a)&&i!==void 0&&t.set(a,i)}else if(o==="cellXfs")r=!0;else if(o==="xf"&&r){const a=Number(s.get("numFmtId")??"0");n.push(Number.isInteger(a)?a:0)}},end:o=>{o==="cellXfs"&&(r=!1)}}),n.map(o=>Hl(o,t))},ti=/^(\d{4}-\d{2}-\d{2})(?:T(\d{2}:\d{2}(?::\d{2})?)(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?$/u,ni=e=>{const t=ti.exec(e);if(t===null)return e;const[,n,r]=t;return r===void 0||/^00:00(?::00)?$/u.test(r)?n??e:`${n} ${r}`},ri=/^([A-Za-z]{1,3})(\d+)$/u,oi=e=>{const t=ri.exec(e)?.[1];if(t===void 0)return null;let n=0;for(const r of t.toUpperCase())n=n*26+(r.charCodeAt(0)-64);return n-1},si=(e,t,n,r)=>{const o=e.value.join("");switch(e.type){case"s":return o===""?"":t[Number(o)]??oe(`refers to the shared string ${o}, past its ${t.length}`);case"inlineStr":return e.inline.join("");case"b":return o===""?"":o==="1"||o==="true"?"TRUE":"FALSE";case"str":case"e":return o;case"d":return ni(o.trim());default:{const s=o.trim();if(s==="")return"";const a=Number(s);return Number.isFinite(a)?Gl(a,n[e.style]??pe,r):s}}},ai=async(e,t,n,r,o)=>{const s=Ir(t);let a=-1,i=new Map,m=0,f=null;return await Ne(e,{start:(c,u,h)=>{if(c==="row"){const w=Number(u.get("r"));a=Number.isInteger(w)&&w>a+1?w-1:a+1,i=new Map,m=0}else if(c==="c"){const w=oi(u.get("r")??"")??m,E=Number(u.get("s")??"0");f={column:w,type:u.get("t")??"n",style:Number.isInteger(E)?E:0,value:[],inline:[],inValue:!1,inInlineText:!1,phoneticDepth:0}}else f!==null&&(c==="v"?f.inValue=!h:c==="rPh"&&!h?f.phoneticDepth+=1:c==="t"&&f.type==="inlineStr"&&f.phoneticDepth===0&&(f.inInlineText=!h))},end:c=>{if(c==="c"&&f!==null){const u=si(f,n,r,o);u!==""&&i.set(f.column,u),m=f.column+1,f=null}else c==="row"?s.addRow(a,i,1):f!==null&&(c==="v"?f.inValue=!1:c==="rPh"?f.phoneticDepth=Math.max(0,f.phoneticDepth-1):c==="t"&&(f.inInlineText=!1))},text:c=>{f!==null&&(f.inValue?f.value.push(c):f.inInlineText&&f.inline.push(c))}},s.full),s.table()},li=async(e,t)=>{const n=dt(await bn(e,"",t),"officeDocument")??oe("has no officeDocument relationship"),r=await Ge(e,n,t.maxPartBytes)??oe(`has no part ${n}`),{sheets:o,date1904:s}=Ql(r),a=await bn(e,n,t),i=dt(a,"sharedStrings"),m=i===null?null:Ce(e,i,t.maxPartBytes),f=m===null?[]:await Jl(m),c=dt(a,"styles"),u=c===null?null:await Ge(e,c,t.maxPartBytes),h=u===null?[]:ei(u),w=[];let E=0;for(const b of o){const T=a.get(b.relationship)??oe(`lists the sheet ${b.name} without its relationship`);if(b.state!=="visible"||!T.type.endsWith("/worksheet")){E+=1;continue}e.entries.has(T.target)||oe(`has no part ${T.target} for the sheet ${b.name}`),w.push({name:b.name,read:async O=>{const L=Ce(e,T.target,t.maxPartBytes)??oe(`has no part ${T.target}`);return ai(L,O,f,h,s)}})}return w.length===0&&oe("shows no sheet"),{sheets:w.slice(0,t.maxSheets),unshownSheets:E,unlistedSheets:Math.max(0,w.length-t.maxSheets)}},ii=Object.freeze([80,75,3,4]),ci=Object.freeze([208,207,17,224,161,177,26,225]),ut=Uint8Array.from([..."EncryptedPackage"].flatMap(e=>[e.charCodeAt(0),0])),di=new Set(["application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.spreadsheet-template"]),ui="mimetype",Kr=(e,t)=>e.byteLength>=t.length&&t.every((n,r)=>e[r]===n),Xr=e=>Kr(e,ii),Yr=e=>Kr(e,ci),fi=e=>{const t=e.byteLength-ut.byteLength;for(let n=0;n<=t;n+=1)if(e[n]===ut[0]&&ut.every((r,o)=>e[n+o]===r))return!0;return!1},mi=async(e,t)=>{if(Yr(e))throw fi(e)?new Y("encrypted","the bytes are a password-protected workbook"):new Y("not-workbook","the bytes are a compound file (a legacy .xls)");if(!Xr(e))throw new Y("not-workbook","the bytes are no ZIP package");const n=Al(e),r=await Ge(n,ui,t.maxPartBytes);if(r!==null&&di.has(r.trim()))return Fl(n,t);if(n.entries.has(Gr))return li(n,t);throw new Y("not-workbook","the ZIP package is neither an OpenDocument spreadsheet nor an Office Open XML package")},hi=async(e,t)=>{const n=e.getReader(),r=[];let o=0;try{for(;;){const{done:i,value:m}=await n.read();if(i)break;if(o+=m.byteLength,o>t)return null;r.push(m)}}finally{n.cancel().catch(()=>{})}const s=new Uint8Array(o);let a=0;for(const i of r)s.set(i,a),a+=i.byteLength;return s},Qr=async(e,t)=>{try{return{kind:"table",table:await e.read(t)}}catch(n){return{kind:"refused",refusal:n instanceof Y?n.refusal:"not-workbook"}}},pi=async(e,t,n,r,o)=>{const s=await e.asset(_.explorerWorkbookHref(t),o);if(s.status==="cancelled")return null;if(s.status==="error")return{kind:"failure",failure:s.failure};let a;try{a=await hi(s.body,n.maxBytes)}catch{return o.aborted?null:{kind:"failure",failure:{reason:"failed"}}}if(o.aborted)return null;if(a===null)return{kind:"refused",refusal:"too-large"};if(!(Xr(a)||Yr(a)))return{kind:"not-package"};try{const i=await mi(a,n.limits),m=r===null?-1:i.sheets.findIndex(h=>h.name===r),f=Math.max(m,0),c=i.sheets[f];if(c===void 0)return{kind:"refused",refusal:"not-workbook"};const u=await Qr(c,n.budget);return o.aborted?null:{kind:"workbook",workbook:i,selected:f,sheet:u}}catch(i){return i instanceof Y?{kind:"refused",refusal:i.refusal}:o.aborted?null:{kind:"failure",failure:{reason:"failed"}}}},gi=Object.freeze({className:"aqmx-document-spreadsheet-body","data-aqmx-document-scroller":""}),wi=(e,t)=>{switch(t.code){case"encoding":return e.spreadsheetUnreadableEncoding(t.encodings);case"binary":return e.spreadsheetNotText;case"long-row":return e.spreadsheetLongRow}},Sn=(e,t)=>{switch(t){case"encrypted":return e.spreadsheetWorkbookEncrypted;case"not-workbook":return e.spreadsheetNotWorkbook;case"too-large":return e.spreadsheetWorkbookTooLarge}},ft=e=>e.every(t=>t.every(n=>n==="")),Jr=({name:e,url:t,openUrl:n,state:r,children:o})=>l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-spreadsheet-view","data-aqmx-spreadsheet":r,children:[l.jsx(Me,{name:e,openUrl:n,downloadUrl:t,icon:l.jsx(tl,{})}),l.jsx(Ae,{scrollerProps:gi,children:l.jsx("div",{className:"aqmx-document-spreadsheet-column",children:o})})]}),eo=({rows:e,title:t})=>{const{labels:n,locale:r,theme:o}=F(),s=d.use(de),a=d.useMemo(()=>({...qr(n,r),table:t,fullscreenDialog:n.spreadsheetFullscreen(t)}),[n,r,t]),i=d.useMemo(()=>vt.serializeTsv(e),[e]);return l.jsx("div",{className:"aqmx-document-spreadsheet","data-theme":o,children:l.jsx(Ee.SpreadsheetBlock,{tsv:i,layout:s==="fill"?"fill":"inline",locale:r,labels:a,tapScrollCircle:Er})})},ye=({note:e,testId:t,code:n,download:r})=>{const{labels:o}=F();return l.jsx("div",{className:"aqmx-document-spreadsheet-stage",children:r===void 0?l.jsx("p",{className:"aqmx-callout",role:"note","data-testid":t,children:e}):l.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":t,"data-aqmx-unreadable":n,children:[l.jsx("p",{className:"aqmx-callout-body",children:e}),l.jsx("a",{className:"aqmx-callout-action",href:r.url,download:r.name,"data-testid":"markdown-explorer-spreadsheet-unreadable-download",children:o.download})]})})},to=({reading:e,name:t,url:n})=>{const{labels:r}=F();switch(e.kind){case"table":return l.jsxs(l.Fragment,{children:[e.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-truncated",children:r.spreadsheetTruncated}):null,l.jsx(eo,{rows:e.rows,title:t})]});case"empty":return l.jsx(ye,{note:r.spreadsheetEmpty,testId:"markdown-explorer-spreadsheet-empty"});case"unreadable":return l.jsx(ye,{note:wi(r,e),testId:"markdown-explorer-spreadsheet-unreadable",code:e.code,download:{url:n,name:t}})}},vi=({path:e,document:t})=>t.format==="workbook"?l.jsx(xi,{path:e,document:t}):l.jsx(Ei,{path:e,document:t,format:t.format}),Ei=({path:e,document:t,format:n})=>{const{config:r,data:o,labels:s}=F(),{name:a,url:i}=t,m=d.useCallback(async h=>{const w=await $r(o,i,{format:n,legacyEncoding:r.legacyTextEncoding,maxBytes:r.spreadsheets.maxBytes,budget:Be},h);return w===null||w.kind==="failure"?w:{kind:"read",value:w}},[o,i,n,r.legacyTextEncoding,r.spreadsheets.maxBytes]),{shown:f,failure:c,retry:u}=It(e,a,m);return l.jsxs(Jr,{name:a,url:i,openUrl:_.explorerPlainTextHref(i),state:f===null?c===null?"loading":"failure":f.kind,children:[f===null&&c===null?l.jsx(ue,{label:s.spreadsheetLoading,testId:"markdown-explorer-spreadsheet-skeleton"}):null,f===null&&c!==null?l.jsx("div",{className:"aqmx-document-spreadsheet-failure",children:l.jsx(ce,{failure:c,alert:!1,onRetry:u,testId:"markdown-explorer-spreadsheet-failure"})}):null,f===null?null:l.jsx(to,{reading:f,name:a,url:i})]})},xi=({path:e,document:t})=>{const{config:n,data:r,labels:o}=F(),{name:s,url:a,firstSheetText:i}=t,m=d.useId(),f=d.useRef(null),c=d.useCallback(async x=>{const k=await pi(r,a,{maxBytes:n.spreadsheets.maxWorkbookBytes,limits:ll,budget:Be},f.current,x);if(k===null||k.kind==="failure")return k;if(k.kind==="workbook")return{kind:"read",value:k};if(i!==null){const A=await $r(r,a,{format:i,legacyEncoding:n.legacyTextEncoding,maxBytes:n.spreadsheets.maxBytes,budget:Be},x);return A===null||A.kind==="failure"?A:{kind:"read",value:{kind:"first-sheet",reading:A}}}return{kind:"read",value:{kind:"refused",refusal:k.kind==="not-package"?"not-workbook":k.refusal}}},[r,a,i,n.legacyTextEncoding,n.spreadsheets.maxBytes,n.spreadsheets.maxWorkbookBytes]),{shown:u,failure:h,retry:w}=It(e,s,c),[E,b]=d.useState(null),T=d.useRef(new WeakMap),O=u?.kind==="workbook"?u:null,L=O===null?null:E!==null&&E.workbook===O.workbook?E:{workbook:O.workbook,index:O.selected,reading:O.sheet},q=x=>{if(O===null)return;const k=O.workbook.sheets[x];if(k===void 0)return;f.current=k.name;let A=T.current.get(O.workbook);A===void 0&&(A=new Map([[O.selected,O.sheet]]),T.current.set(O.workbook,A));const M=A.get(x),P={workbook:O.workbook,index:x,reading:M??null};if(b(P),M!==void 0)return;const B=A;Qr(k,Be).then(G=>{B.set(x,G),b(v=>v===P?{...P,reading:G}:v)})},j=L===null?null:L.reading===null?"loading":L.reading.kind==="refused"?"unreadable":ft(L.reading.table.rows)?"empty":"table",p=u===null?h===null?"loading":"failure":u.kind==="first-sheet"?u.reading.kind:u.kind==="refused"?"unreadable":j??"loading",g=i===null?a:_.explorerPlainTextHref(a),R=x=>`${m}-sheet-${x}`,N=`${m}-panel`,I=L===null?null:O?.workbook.sheets[L.index]?.name??null,$=O!==null&&O.workbook.sheets.length>1;return l.jsxs(Jr,{name:s,url:a,openUrl:g,state:p,children:[u===null&&h===null?l.jsx(ue,{label:o.spreadsheetLoading,testId:"markdown-explorer-spreadsheet-skeleton"}):null,u===null&&h!==null?l.jsx("div",{className:"aqmx-document-spreadsheet-failure",children:l.jsx(ce,{failure:h,alert:!1,onRetry:w,testId:"markdown-explorer-spreadsheet-failure"})}):null,u?.kind==="refused"?l.jsx(ye,{note:Sn(o,u.refusal),testId:"markdown-explorer-spreadsheet-unreadable",code:u.refusal,download:{url:a,name:s}}):null,u?.kind==="first-sheet"?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-first-sheet",children:o.spreadsheetWorkbookFirstSheet}),l.jsx(to,{reading:u.reading,name:s,url:a})]}):null,O===null||L===null||I===null?null:l.jsxs(l.Fragment,{children:[O.workbook.unshownSheets>0?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-unshown-sheets",children:o.spreadsheetUnshownSheets(O.workbook.unshownSheets)}):null,O.workbook.unlistedSheets>0?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-unlisted-sheets",children:o.spreadsheetUnlistedSheets(O.workbook.sheets.length)}):null,$?l.jsx(cl,{names:O.workbook.sheets.map(x=>x.name),selected:L.index,onSelect:q,label:o.spreadsheetSheets(s),tabIdOf:R,panelId:N}):null,l.jsxs("div",{className:"aqmx-document-spreadsheet-sheet","data-testid":"markdown-explorer-spreadsheet-sheet","data-aqmx-sheet":L.index,...$?{role:"tabpanel",id:N,"aria-labelledby":R(L.index)}:{},children:[L.reading===null?l.jsx(ue,{label:o.spreadsheetSheetLoading,testId:"markdown-explorer-spreadsheet-sheet-skeleton"}):null,L.reading?.kind==="table"&&L.reading.table.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-truncated",children:o.spreadsheetTruncated}):null,L.reading?.kind==="refused"?l.jsx(ye,{note:Sn(o,L.reading.refusal),testId:"markdown-explorer-spreadsheet-unreadable",code:L.reading.refusal,download:{url:a,name:s}}):null,L.reading?.kind==="table"&&ft(L.reading.table.rows)?l.jsx(ye,{note:o.spreadsheetSheetEmpty,testId:"markdown-explorer-spreadsheet-empty"}):null,L.reading?.kind==="table"&&!ft(L.reading.table.rows)?l.jsx(eo,{rows:L.reading.table.rows,title:o.spreadsheetSheetName(s,I)},L.index):null]})]})]})},no=Object.freeze({kind:"empty"}),bi=(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 H.explorerHref(e,{...t,overrides:r})},ke=({kind:e,view:t,label:n,stale:r,busy:o,frameRef:s,intent:a,children:i})=>{const m=d.use(de);return l.jsxs("section",{ref:s,role:"region","aria-label":n,"aria-busy":o,"data-testid":"markdown-explorer-document","data-aqmx-document-kind":e,"data-aqmx-document-view":t,"data-aqmx-document-flow":m,className:"aqmx-document",...a,children:[r?l.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,i]})},Si=({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,i=e.kind==="failure"?e.failure:null;switch(d.useEffect(()=>{t&&s!==null&&o.announce(r.folderReadmeMissing(_.lastPathSegment(s)))},[t,s,o,r]),d.useEffect(()=>{a!==null&&i!==null&&n(r.documentFailed(_.lastPathSegment(a),re(r,i.reason)))},[a,i,n,r]),e.kind){case"empty":return l.jsx(ke,{kind:"empty",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-document-empty",children:l.jsx("p",{className:"aqmx-empty-title",children:r.documentEmpty})})});case"loading":return l.jsx(qt,{label:r.documentRegion});case"no-readme":return l.jsx(ke,{kind:"empty",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-folder-empty",children:l.jsx("p",{className:"aqmx-empty-title",children:r.folderReadmeMissing(_.lastPathSegment(e.folder))})})});case"failure":return l.jsx(ke,{kind:"failure",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx(jt,{failure:e.failure,onRetry:e.onRetry,testId:"markdown-explorer-folder-failure"})})}},qt=({label:e})=>{const{labels:t}=F();return l.jsx(ke,{kind:"loading",label:e,stale:!1,busy:!0,children:l.jsx(ue,{label:t.documentLoading,testId:"markdown-explorer-document-skeleton"})})},yn=Object.freeze(["wheel","touchstart","pointerdown","keydown"]),yi=({path:e,document:t,viewer:n,editing:r})=>{const{reportMathDiagnostics:o,edits:s}=F(),a=d.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),i=Ia(),m=Fa(),f=d.useMemo(()=>o===void 0?void 0:p=>o(e,p),[o,e]),c=d.useRef(null),{editable:u,doubleClick:h,region:w,paneScroll:E,stale:b}=r;d.useLayoutEffect(()=>{if(u)return s.bindView(e,{anchor:()=>{const p=c.current,g=w(),R=p===null?null:p.querySelector(Ye);return p===null||g===null||R===null?null:lr(p,E.scrollerOf(g,R))}})},[s,e,u,w,E]);const T=p=>{const g=c.current,{target:R}=p;!h||g===null||!(R instanceof Element)||!sr(R)||(p.stopPropagation(),s.start(e,ar(R,g,g.ownerDocument.getSelection())))},O=d.useRef(null),L=d.useRef(b);d.useLayoutEffect(()=>{L.current=b});const q=d.useEffectEvent(p=>{const g=c.current,R=w(),N=g===null?null:dr(g,p.line);if(R===null||N===null)return!1;const I=E.scrollerOf(R,N);return I.scrollTop+=ur(N,p.line)-p.clientTop,!0}),j=d.useEffectEvent(p=>{const g=w();if(g===null)return;const R=()=>{for(const I of yn)g.removeEventListener(I,N,!0);O.current?.release===R&&(O.current=null)},N=()=>R();for(const I of yn)g.addEventListener(I,N,{capture:!0,passive:!0});O.current={point:p,release:R}});return d.useLayoutEffect(()=>{const p=s.takeReturn(e);if(p!==null)return queueMicrotask(()=>{q(p)&&L.current&&j(p)}),()=>O.current?.release()},[s,e]),d.useLayoutEffect(()=>{const p=O.current;p===null||b||(p.release(),q(p.point))},[t,b]),l.jsx("div",{ref:c,className:"aqmx-document-viewer",onDoubleClick:T,children:l.jsx(Ee.MarkdownViewer,{...n,onHeadingSelect:i,headingHref:m,onMathDiagnostics:f,parseResult:a,content:null})})},ro=({document:e,viewer:t})=>{const{labels:n}=F();return l.jsxs(l.Fragment,{children:[l.jsx(Me,{name:e.name,openUrl:_.explorerPlainTextHref(e.url),downloadUrl:e.url,icon:l.jsx(ss,{}),children:e.truncated?null:l.jsx(Us,{text:e.text})}),e.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-text-truncated",children:n.textTruncated}):null,l.jsx("div",{className:"aqmx-document-viewer",children:l.jsx(Ee.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},mt=({path:e,name:t,viewer:n})=>{const{data:r,labels:o}=F(),s=d.useCallback(async f=>{const c=await r.text(e,f);return"kind"in c?c.kind==="failure"?{kind:"failure",failure:c.failure}:{kind:"read",value:c}:null},[r,e]),{shown:a,failure:i,retry:m}=It(e,t,s);return a!==null?l.jsx(ro,{document:a,viewer:n}):i!==null?l.jsx(jt,{failure:i,onRetry:m,testId:"markdown-explorer-markup-failure"}):l.jsx(ue,{label:o.markupLoading,testId:"markdown-explorer-markup-skeleton"})},ki=Object.freeze({reason:"failed"}),Ri=e=>{const{labels:t}=F();return l.jsx(is,{fallback:n=>l.jsx("div",{className:"aqmx-edit-message",children:l.jsx(ce,{failure:ki,alert:!1,onRetry:n,testId:"markdown-explorer-edit-load-failure"})}),children:l.jsx(d.Suspense,{fallback:l.jsx(ue,{label:t.editLoading,testId:"markdown-explorer-edit-skeleton"}),children:l.jsx(ls,{...e})})})},Ti=({path:e,document:t,view:n,viewer:r,onRetry:o,editing:s})=>{switch(t.kind){case"markdown":{const{session:a,layout:i,region:m,paneScroll:f,stale:c}=s;if(n==="edit"&&a!==void 0)return l.jsx(Ri,{path:e,name:t.name,session:a,layout:i,viewer:r,region:m,paneScroll:f});if(n==="markup")return l.jsx(mt,{path:e,name:t.name,viewer:r});const u=t.edit!==null&&(t.edit.kind==="inline"||t.edit.kind==="draft");return l.jsx(yi,{path:e,document:t,viewer:r,editing:{editable:u,doubleClick:u&&i==="fill",region:m,paneScroll:f,stale:c}})}case"text":return l.jsx(ro,{document:t,viewer:r});case"image":return n==="markup"&&_t(t)==="svg"?l.jsx(mt,{path:e,name:t.name,viewer:r}):l.jsx(Ra,{document:t});case"media":return l.jsx(Qa,{document:t});case"spreadsheet":return n==="markup"?l.jsx(mt,{path:e,name:t.name,viewer:r}):l.jsx(vi,{path:e,document:t});case"file":return l.jsx(Ys,{document:t});case"failure":return l.jsx(jt,{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)}`)}}},Li='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',Ci=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:Tr(e,n),r===void 0?null:Rr(e,r.id),e.querySelector(Ye),e.querySelector(Li)];for(const s of o)if(s instanceof HTMLElement&&Nt(s))return s;return null},kn=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&Nt(t)},Oi=e=>{const t=d.useRef(!1);return d.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 i=h=>{s=!(h.target instanceof Node&&n.contains(h.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(a),a=setTimeout(()=>{s=!1},0)},m=h=>{t.current=h.target instanceof Node&&n.contains(h.target)},f=h=>{h.relatedTarget===null&&s&&(t.current=!1)},c=()=>{const{activeElement:h,body:w}=r;h!==null&&h!==w&&(t.current=n.contains(h))},u=()=>{s&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",i,!0),o.addEventListener("mousedown",i,!0),o.addEventListener("focusin",m,!0),o.addEventListener("blur",c),o.addEventListener("focus",u),n.addEventListener("focusout",f),()=>{clearTimeout(a),o.removeEventListener("pointerdown",i,!0),o.removeEventListener("mousedown",i,!0),o.removeEventListener("focusin",m,!0),o.removeEventListener("blur",c),o.removeEventListener("focus",u),n.removeEventListener("focusout",f)}},[e]),t},Ai=Object.freeze({count:0,recovered:!1}),Mi=({path:e,snapshot:t,markup:n,stale:r,viewer:o,editLayout:s,regionLabel:a,navigation:i,fragment:m,paneScroll:f,announces:c,announceFailure:u,onDocumentShown:h})=>{const{labels:w,announcer:E,documents:b}=F(),{document:T}=t,O=d.useRef(null),L=d.useRef(null),q=d.useRef(null),j=d.useRef(0),p=Oi(O),g=d.useRef({path:e,document:T}),R=d.useRef(null),N=d.useCallback(z=>{const V=O.current,X=on(V,z,f);V!==null&&X!==null&&kn(V,X,p.current)},[f,p]),I=d.useCallback((z,V)=>{const X=j.current;setTimeout(()=>{!V.defaultPrevented&&j.current===X&&N(z)},0)},[N]),$=d.useCallback(z=>{setTimeout(()=>{z.defaultPrevented||N("#")},0)},[N]),x=d.useMemo(()=>({navigation:i,currentPath:e,scrollWithin:N,followSameUrlJump:I,followEmptyFragment:$}),[i,e,N,I,$]),k=d.useCallback(()=>b.retry(e),[b,e]),A=mr(b,Aa),M=er(e),P=M!==void 0?"edit":n?"markup":"rendered",B=_t(T)===null?void 0:P,G=d.useCallback(()=>O.current,[]),v=d.useMemo(()=>({session:M,layout:s,region:G,paneScroll:f,stale:r}),[M,s,G,f,r]),S=B==="edit"?!1:r,C=d.use(de),D=B==="edit"&&s==="fill"?"fill":C,[U,Z]=d.useState(0),K=d.useRef(0),W=d.useRef(!1),[ne,Ut]=d.useState(Ai),[Ht,Eo]=d.useState(0),zt=d.useRef(u),Vt=d.useRef(r);d.useLayoutEffect(()=>{zt.current=u,Vt.current=r},[u,r]);const xo=d.useMemo(()=>({announceFailure:z=>{Vt.current||zt.current(z)},readPart:()=>{const z=b.readPart(e);K.current+=1;let V=!1,X=!1,Q=!1;return{settle:(fe,me)=>{if(z.settle(fe,me),!(Q||V)){if(me!==null){X=!0,W.current=!1;return}V=!0,Ut(De=>({count:De.count+1,recovered:X}))}},release:()=>{Q||(Q=!0,z.release(),K.current-=1,V||Eo(fe=>fe+1))}}},holdBusy:()=>{Z(V=>V+1);let z=!0;return()=>{z&&(z=!1,Z(V=>V-1))}}}),[b,e]),Zt=S||U>0,bo=d.useEffectEvent((z,V)=>{const X=L.current;if(X!==null&&X.path===z&&X.snapshot===V)return;L.current={path:z,snapshot:V},b.noteShown(z,V);const Q=V.document;if(Q.kind==="failure"){W.current=!1,b.noteFailureShown(V)&&u(w.documentFailed(_.lastPathSegment(z),re(w,Q.failure.reason)));return}h?.(z,Q),!(!c||X!==null&&X.path===z&&X.snapshot.document.kind!=="failure")&&(W.current=K.current>0,W.current||E.announce(w.documentShown(Q.name)))});d.useEffect(()=>{bo(e,t)},[e,t]);const So=d.useEffectEvent(()=>{m.kind==="panel"&&m.consume()}),Wt=d.useEffectEvent(z=>{const V=O.current;if(V===null||!p.current)return null;const{activeElement:X,body:Q}=V.ownerDocument;return X!==null&&X!==Q?null:Ci(V,T,z)}),yo=d.useEffectEvent(z=>{const V=W.current;W.current=!1,!r&&(z&&Wt(null),c&&(z||V)&&T.kind!=="failure"&&E.announce(w.documentShown(T.name)))});d.useEffect(()=>{ne.count>0&&yo(ne.recovered)},[ne]);const ko=d.useEffectEvent(()=>{K.current>0||!W.current||(W.current=!1,c&&!r&&T.kind!=="failure"&&E.announce(w.documentShown(T.name)))});d.useEffect(()=>{Ht>0&&ko()},[Ht]);const Ro=d.useEffectEvent(z=>{const V=O.current;V!==null&&kn(V,z,p.current)}),To=d.useEffectEvent(z=>f.reveal(z)),Lo=d.useEffectEvent(z=>on(O.current,z,f));return d.useEffect(()=>{if(r)return;const z=g.current.path!==e,V=z||g.current.document!==T;g.current={path:e,document:T};const X=R.current!==e;R.current=e;let Q=null;m.kind==="page"?q.current!==m.navigation&&(q.current=m.navigation,j.current+=1,Q=m.fragment):m.fragment!==null&&(Q=m.fragment,So());const fe=()=>{const me=Q===null?null:Lo(Q);if(!V){me!==null&&Ro(me);return}const De=Wt(m.fragment);z&&me===null&&De!==null&&To(De)};X?queueMicrotask(fe):fe()},[m,e,T,r]),l.jsx(de,{value:D,children:l.jsx(ke,{kind:T.kind,view:B,label:a(e,T),stale:Zt,busy:Zt,frameRef:O,intent:A,children:l.jsx(Ar,{value:x,children:l.jsx(Ca,{children:l.jsx(br,{value:xo,children:l.jsx(Ti,{path:e,document:T,view:P,viewer:o,onRetry:k,editing:v},e)})})})})})},Bt=Object.freeze({kind:"skeleton"}),Ni=(e,t,n,r,o)=>{if(t?.status==="loaded")return{kind:"document",path:e,snapshot:t,stale:!1};const s=le(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:le(r);return n===null||a===null?Bt:{kind:"document",path:n,snapshot:a,stale:!0}},Di=(e,t)=>t.status==="deferred"?Bt:{kind:"document",path:e,snapshot:t,stale:!1},ji=({requestedPath:e,content:t,markup:n,...r})=>{const o=t.kind==="streaming"?Di(t.path,d.use(t.promise)):t;return o.kind!=="document"?l.jsx(qt,{label:r.regionLabel(e,null)}):l.jsx(Mi,{path:o.path,snapshot:o.snapshot,markup:n,stale:o.stale,...r})},oo=({path:e,absence:t,markup:n,display:r,navigation:o,fragment:s,paneScroll:a,announces:i,announceFailure:m,onDocumentShown:f})=>{const{config:c,labels:u,locale:h,theme:w,documents:E,data:b}=F(),T=Ee.useMarkdownToolbarState(),O=d.useRef(!1);d.useLayoutEffect(()=>{O.current=!0},[]);const[L,q]=d.useState(null),[j,p]=d.useState(n),g=d.useCallback(()=>e===null?void 0:E.peek(e),[E,e]),R=d.useSyncExternalStore(E.subscribe,g,g),N=d.useCallback(()=>L===null?void 0:E.peek(L),[E,L]),I=d.useSyncExternalStore(E.subscribe,N,N);d.useLayoutEffect(()=>e===null?void 0:E.open(e),[E,e]),d.useLayoutEffect(()=>L===null?void 0:E.retain(L),[E,L]);const $=e===null?Bt:Ni(e,R,L,I,!O.current),x=e===null?null:$.kind==="document"&&!$.stale?$.path:L;x!==L&&q(x);const k=$.kind!=="document"||$.path===e;k&&n!==j&&p(n);const A=d.useMemo(()=>hl(u,h),[u,h]),M=d.useMemo(()=>({read:(C,D)=>Ta(b,C,D)}),[b]),P=d.useMemo(()=>[...c.iframeHosts],[c]),B=o.kind==="panel",G=d.useMemo(()=>({labels:A,spreadsheetLocale:h,spreadsheetTapScrollCircle:Er,emptyMessage:u.documentEmpty,theme:w,availableStyles:c.documentStyles,iFrameAllowedDomains:P,embeds:c.embeds,linkComponent:_a,toolbar:T,style:r.style,onStyleChange:r.onStyleChange,align:r.align,onAlignChange:r.onAlignChange,showToc:r.showToc,showStyle:r.showStyle,showAlign:r.showAlign,padding:r.padding,width:r.width===void 0?void 0:`min(${r.width}, 100%)`,maxWidth:r.maxWidth===void 0?void 0:`min(${r.maxWidth}, 100%)`,renderScrollBar:B?void 0:pr,scrollBarGutter:B?void 0:Dt,imageSource:M}),[A,h,u.documentEmpty,w,c.documentStyles,P,c.embeds,T,r,B,M]),v=d.useCallback((C,D)=>B?D===null||D.kind==="failure"?_.lastPathSegment(C):D.name:u.documentRegion,[B,u.documentRegion]),S=B?"content":"fill";return e===null?l.jsx(de,{value:S,children:l.jsx(Si,{absence:t,announces:i,announceFailure:m})}):l.jsx(de,{value:S,children:l.jsx(d.Suspense,{fallback:l.jsx(qt,{label:v(e,null)}),children:l.jsx(ji,{requestedPath:e,content:$,markup:k?n:j,viewer:G,editLayout:r.editLayout,regionLabel:v,navigation:o,fragment:s,paneScroll:a,announces:i,announceFailure:m,onDocumentShown:f})})})},Pi=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:a,announcer:i}=F(),m=Re(I=>I.style),f=Re(I=>I.align),c=Oe(),u=te.useLocation(),h=Ke(),{view:w,overrides:E,embed:b}=r,T=d.useCallback(I=>{if(h.kind!=="location")return;const $=bi(s,h.location,I);$!==null&&c($,"browse")},[s,c,h]),O=d.useCallback(I=>{a.update({style:I}),T("style")},[a,T]),L=d.useCallback(I=>{a.update({align:I}),T("align")},[a,T]),q=Br(s,E.style,m),j=Ur(E.align,f),p=d.useMemo(()=>({style:q,onStyleChange:O,align:j,onAlignChange:L,showToc:b.showToc!==!1,showStyle:b.showStyle!==!1,showAlign:b.showAlign!==!1,padding:b.padding,width:b.width,maxWidth:b.maxWidth,editLayout:"fill"}),[q,O,j,L,b]),g=d.useMemo(()=>({kind:"page",view:w,overrides:E,embed:b}),[w,E,b]),R=d.useMemo(()=>({kind:"page",fragment:u.hash,navigation:u}),[u]),N=d.useCallback(I=>i.announce(I),[i]);return l.jsx(oo,{path:e,absence:t,markup:n,display:p,navigation:g,fragment:R,paneScroll:ia,announces:!0,announceFailure:N,onDocumentShown:o})},_i=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:a}=F(),i=Re(g=>g.style),m=Re(g=>g.align),[f,c]=d.useState(()=>Br(s,void 0,i)),u=Ur(void 0,m),h=d.useCallback(g=>a.update({align:g}),[a]),{maximized:w,onDocumentLink:E,pendingHash:b,onHashConsumed:T,announceFailure:O,paneScroll:L}=r,q=d.useMemo(()=>({style:f,onStyleChange:c,align:u,onAlignChange:h,showToc:w,showStyle:w,showAlign:w,padding:void 0,width:void 0,maxWidth:void 0,editLayout:w?"fill":"content"}),[f,u,h,w]),j=d.useMemo(()=>({kind:"panel",onDocumentLink:E}),[E]),p=d.useMemo(()=>({kind:"panel",fragment:b,consume:T}),[b,T]);return l.jsx(oo,{path:e,absence:t,markup:n,display:q,navigation:j,fragment:p,paneScroll:L,announces:!1,announceFailure:O,onDocumentShown:o})},so=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>r.kind==="page"?l.jsx(Pi,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o}):l.jsx(_i,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o});function Ii({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.755 10.059a7.5 7.5 0 0 1 12.548-3.364l1.903 1.903h-3.183a.75.75 0 1 0 0 1.5h4.992a.75.75 0 0 0 .75-.75V4.356a.75.75 0 0 0-1.5 0v3.18l-1.9-1.9A9 9 0 0 0 3.306 9.67a.75.75 0 1 0 1.45.388Zm15.408 3.352a.75.75 0 0 0-.919.53 7.5 7.5 0 0 1-12.548 3.364l-1.902-1.903h3.183a.75.75 0 0 0 0-1.5H2.984a.75.75 0 0 0-.75.75v4.992a.75.75 0 0 0 1.5 0v-3.18l1.9 1.9a9 9 0 0 0 15.059-4.035.75.75 0 0 0-.53-.918Z",clipRule:"evenodd"}))}const ao=y.forwardRef(Ii);function Fi({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M14.447 3.026a.75.75 0 0 1 .527.921l-4.5 16.5a.75.75 0 0 1-1.448-.394l4.5-16.5a.75.75 0 0 1 .921-.527ZM16.72 6.22a.75.75 0 0 1 1.06 0l5.25 5.25a.75.75 0 0 1 0 1.06l-5.25 5.25a.75.75 0 1 1-1.06-1.06L21.44 12l-4.72-4.72a.75.75 0 0 1 0-1.06Zm-9.44 0a.75.75 0 0 1 0 1.06L2.56 12l4.72 4.72a.75.75 0 0 1-1.06 1.06L.97 12.53a.75.75 0 0 1 0-1.06l5.25-5.25a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const lo=y.forwardRef(Fi);function $i({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M15.75 2.25H21a.75.75 0 0 1 .75.75v5.25a.75.75 0 0 1-1.5 0V4.81L8.03 17.03a.75.75 0 0 1-1.06-1.06L19.19 3.75h-3.44a.75.75 0 0 1 0-1.5Zm-10.5 4.5a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h10.5a1.5 1.5 0 0 0 1.5-1.5V10.5a.75.75 0 0 1 1.5 0v8.25a3 3 0 0 1-3 3H5.25a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h8.25a.75.75 0 0 1 0 1.5H5.25Z",clipRule:"evenodd"}))}const qi=y.forwardRef($i);function Bi({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M11.47 13.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 0 0-1.06-1.06L12 11.69 5.03 4.72a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",clipRule:"evenodd"}),y.createElement("path",{fillRule:"evenodd",d:"M11.47 19.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 1 0-1.06-1.06L12 17.69l-6.97-6.97a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",clipRule:"evenodd"}))}const Ui=y.forwardRef(Bi);function Hi({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25ZM12.75 6a.75.75 0 0 0-1.5 0v6c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-3.75V6Z",clipRule:"evenodd"}))}const zi=y.forwardRef(Hi);function Vi({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M9 1.5H5.625c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5Zm6.61 10.936a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 14.47a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",clipRule:"evenodd"}),y.createElement("path",{d:"M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"}))}const Zi=y.forwardRef(Vi);function Wi({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),y.createElement("path",{fillRule:"evenodd",d:"M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 0 1 0-1.113ZM17.25 12a5.25 5.25 0 1 1-10.5 0 5.25 5.25 0 0 1 10.5 0Z",clipRule:"evenodd"}))}const io=y.forwardRef(Wi);function Gi({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M21.731 2.269a2.625 2.625 0 0 0-3.712 0l-1.157 1.157 3.712 3.712 1.157-1.157a2.625 2.625 0 0 0 0-3.712ZM19.513 8.199l-3.712-3.712-8.4 8.4a5.25 5.25 0 0 0-1.32 2.214l-.8 2.685a.75.75 0 0 0 .933.933l2.685-.8a5.25 5.25 0 0 0 2.214-1.32l8.4-8.4Z"}),y.createElement("path",{d:"M5.25 5.25a3 3 0 0 0-3 3v10.5a3 3 0 0 0 3 3h10.5a3 3 0 0 0 3-3V13.5a.75.75 0 0 0-1.5 0v5.25a1.5 1.5 0 0 1-1.5 1.5H5.25a1.5 1.5 0 0 1-1.5-1.5V8.25a1.5 1.5 0 0 1 1.5-1.5h5.25a.75.75 0 0 0 0-1.5H5.25Z"}))}const Ki=y.forwardRef(Gi);function Xi({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M15 3.75H9v16.5h6V3.75ZM16.5 20.25h3.375c1.035 0 1.875-.84 1.875-1.875V5.625c0-1.036-.84-1.875-1.875-1.875H16.5v16.5ZM4.125 3.75H7.5v16.5H4.125a1.875 1.875 0 0 1-1.875-1.875V5.625c0-1.036.84-1.875 1.875-1.875Z"}))}const Yi=y.forwardRef(Xi),co=({href:e,onRetry:t,testId:n})=>{const{labels:r,onEditGrant:o}=F(),[s,a]=d.useState(!1),i=()=>{o===void 0||s||(a(!0),o(e).then(m=>{m&&t()}).finally(()=>a(!1)))};return l.jsxs("div",{className:"aqmx-callout aqmx-edit-grant","data-testid":n,children:[l.jsx("p",{className:"aqmx-callout-title",children:r.editGrantTitle}),l.jsx("p",{className:"aqmx-callout-body",children:r.editGrantBody}),l.jsxs("div",{className:"aqmx-edit-grant-actions",children:[o===void 0?l.jsx("a",{className:"aqmx-callout-action",href:e,target:"_blank",rel:"noopener","data-testid":`${n}-open`,children:r.editGrantAction}):l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":s,"data-testid":`${n}-open`,onClick:i,children:r.editGrantAction}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":`${n}-retry`,onClick:t,children:r.editGrantRetry})]})]})},Qi="Control+E Meta+E",uo=(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)},Ji=e=>e==="split"?null:e,fo=e=>e==="preview"?"editor":"preview",mo=e=>/Mac|iPhone|iPad|iPod/u.test(e),ho=(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)},Rn=(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)},ec=({path:e,documentName:t,open:n,onClose:r})=>{const{data:o,edits:s,labels:a,locale:i,announcer:m}=F(),f=d.useId(),[c,u]=d.useState(null),[h,w]=d.useState(0),[E,b]=d.useState(null),[T,O]=d.useState(null),L=d.useMemo(()=>new Intl.DateTimeFormat(i,{dateStyle:"medium",timeStyle:"short"}),[i]),q=d.useCallback(()=>{b(null),O(null)},[]),j=Kn({open:n,onOpen:q,onDismiss:r});d.useEffect(()=>{if(!n)return;const R=new AbortController;return u(null),o.revisions(e,R.signal).then(N=>{"kind"in N&&u(N)}),()=>R.abort()},[n,o,e,h]),d.useEffect(()=>{if(!n||E===null)return;const R=new AbortController;return O(null),o.revision(e,E,R.signal).then(N=>{"kind"in N&&O(N)}),()=>R.abort()},[n,o,e,E]);const p=()=>{T===null||T.kind!=="revision"||(s.replaceDraft(e,T.text),m.announce(a.historyRestored(t)),r())},g=c!==null&&c.kind==="revisions"?c.revisions.find(R=>R.id===E):void 0;return l.jsx("dialog",{...j,className:"aqmx-confirm aqmx-history","aria-labelledby":f,"data-testid":"markdown-explorer-history",children:l.jsxs("div",{className:"aqmx-confirm-panel aqmx-history-panel",children:[l.jsx("p",{id:f,className:"aqmx-confirm-title",children:a.historyTitle(t)}),c===null?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-loading",children:a.historyLoading}):c.kind==="failure"?l.jsx(ce,{failure:c.failure,alert:!1,onRetry:()=>w(R=>R+1),testId:"markdown-explorer-history-failure"}):c.revisions.length===0?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-empty",children:a.historyEmpty}):l.jsx("ul",{className:"aqmx-history-list","data-testid":"markdown-explorer-history-list",children:c.revisions.map(R=>l.jsx("li",{children:l.jsxs("button",{type:"button",className:"aqmx-history-entry","aria-pressed":R.id===E,"data-testid":"markdown-explorer-history-entry",onClick:()=>b(R.id),children:[l.jsx("span",{children:Rn(R,L,a.historyEntry)}),R.current?l.jsx("span",{className:"aqmx-history-mark",children:a.historyCurrent}):null,R.kept?l.jsx("span",{className:"aqmx-history-mark",children:a.historyKept}):null]})},R.id))}),E===null?null:T===null?l.jsx("p",{className:"aqmx-history-note",children:a.historyLoading}):T.kind==="failure"?l.jsx(ce,{failure:T.failure,alert:!1,testId:"markdown-explorer-history-revision-failure"}):l.jsx("section",{className:"aqmx-history-text",tabIndex:0,"aria-label":g===void 0?a.historyTitle(t):Rn(g,L,a.historyEntry),"data-testid":"markdown-explorer-history-text",children:l.jsx("pre",{children:T.text})}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":"markdown-explorer-history-close",onClick:r,children:a.historyClose}),l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":T===null||T.kind!=="revision","data-testid":"markdown-explorer-history-restore",onClick:p,children:a.historyRestore})]})]})})},tc=e=>{const{documents:t}=F(),n=d.useCallback(()=>t.peek(e),[t,e]),r=d.useCallback(()=>t.peekSeeded(e),[t,e]),o=d.useSyncExternalStore(t.subscribe,n,r),s=le(o)?.document;return s===void 0||s.kind==="failure"?{edit:null,name:_.lastPathSegment(e)}:{edit:s.kind==="markdown"||s.kind==="spreadsheet"?s.edit:null,name:s.name}},ae=e=>{e.stopPropagation()},nc=({path:e,documentName:t,iconOnly:n,previewAvailable:r,draft:o})=>{const{draftConverter:s,edits:a,labels:i}=F(),m=d.useSyncExternalStore(a.subscribe,()=>a.session(e)!==void 0,()=>!1),[f,c]=d.useState(null),u=()=>{if(!m){a.start(e,a.viewAnchor(e));return}a.flush(e);const b=a.session(e);b?.dirty===!0?c(b.save.kind==="draft"?"draft":"unsaved"):a.close(e)},h=()=>{m||(as(),r&&a.sideBySide()&&s?.prepare?.())},w=n?o?i.editDraftDocumentNamed(t):i.editDocumentNamed(t):null,E=o?i.editDraftDocument:i.editDocument;return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:w===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:m?i.closeEditor:w===null?E:w,"aria-label":w===null?void 0:w,"aria-pressed":m,"data-testid":"markdown-explorer-document-edit",onClick:u,onDoubleClick:ae,onPointerEnter:h,onFocus:h,children:[l.jsx(Ki,{"aria-hidden":"true"}),w===null?l.jsx("span",{children:i.editDocumentLabel}):null]}),l.jsx(Xn,{open:f!==null,title:f==="draft"?i.draftDiscardTitle:i.unsavedTitle,body:f==="draft"?i.draftDiscardBody(t):i.unsavedBody(t),confirmLabel:i.unsavedDiscard,cancelLabel:i.unsavedStay,testId:"markdown-explorer-edit-close-confirm",onConfirm:()=>{c(null),a.close(e)},onCancel:()=>c(null)})]})},rc=({href:e,documentName:t,iconOnly:n})=>{const{labels:r}=F(),o=n?r.editExternallyNamed(t):null;return l.jsxs("a",{className:o===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",href:e,target:"_blank",rel:"noopener noreferrer",title:o===null?r.editExternally:o,"aria-label":o===null?void 0:o,"data-testid":"markdown-explorer-document-edit-external",onDoubleClick:ae,children:[l.jsx(qi,{"aria-hidden":"true"}),o===null?l.jsx("span",{children:r.editExternallyLabel}):null]})},oc=({session:e})=>{const{labels:t}=F(),n=Io(t,e);return l.jsx("p",{className:"aqmx-edit-status",title:n===""?void 0:n,"data-testid":"markdown-explorer-edit-status","data-aqmx-save":e.save.kind,children:n})},sc=Object.freeze(["editor","split","preview"]),ac=Object.freeze(["editor","preview"]),lc=Object.freeze({editor:lo,split:Yi,preview:io}),ic=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{draftConverter:s,edits:a,labels:i}=F(),m=nr(),f=uo(r,m,o),c=o?sc:ac,u=d.useId(),h=d.useRef(new Map),w={editor:{label:i.editViewEditor,tooltip:i.editViewEditorTooltip},split:{label:i.editViewSplit,tooltip:i.editViewSplitTooltip},preview:{label:i.editViewPreview,tooltip:i.editViewPreviewTooltip}},E=()=>{a.preparePreview(e),s?.prepare?.()},b=T=>{if(!ho(T.nativeEvent,mo(navigator.platform)))return;Ot(T);const O=fo(f);Rt(a,e,O,o),h.current.get(O)?.focus()};return l.jsx("div",{role:"radiogroup","aria-label":n?i.editViewNamed(t):i.editView,className:"aqmx-edit-view","data-testid":"markdown-explorer-edit-view",onKeyDown:b,children:c.map(T=>{const O=lc[T],{label:L,tooltip:q}=w[T],j=T==="preview"?E:void 0;return l.jsxs("label",{className:n?"aqmx-icon-button":"aqmx-icon-button aqmx-labelled-button",children:[l.jsx("input",{ref:p=>{p===null?h.current.delete(T):h.current.set(T,p)},type:"radio",name:u,value:T,checked:T===f,"aria-label":L,"aria-keyshortcuts":T==="split"?void 0:Qi,title:q,"data-testid":`markdown-explorer-edit-view-${T}`,onChange:()=>Rt(a,e,T,o),onDoubleClick:ae,onPointerEnter:j,onFocus:j}),l.jsx(O,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:L})]},T)})})},cc=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{edits:s,labels:a}=F(),[i,m]=d.useState(!1);if(r.phase.kind!=="editing")return null;const f=r.save.kind==="saving",c=f||!r.dirty,u=()=>{s.flush(e);const w=s.session(e);w===void 0||!w.dirty||w.save.kind==="saving"||s.save(e)},h=w=>n?{className:"aqmx-icon-button","aria-label":w}:{className:"aqmx-icon-button aqmx-labelled-button"};return l.jsxs(l.Fragment,{children:[r.save.kind==="conflicts"?l.jsxs("button",{type:"button",...h(a.conflictNext),title:a.conflictNext,"data-testid":"markdown-explorer-edit-next-conflict",onClick:()=>s.nextConflict(e),onDoubleClick:ae,children:[l.jsx(Ui,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.conflictNext})]}):null,l.jsx(ic,{path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o}),r.history?l.jsxs("button",{type:"button",...h(a.historyOpen),title:a.historyOpen,"aria-haspopup":"dialog","data-testid":"markdown-explorer-edit-history",onClick:()=>m(!0),onDoubleClick:ae,children:[l.jsx(zi,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.historyOpen})]}):null,r.save.kind==="draft"?null:l.jsxs("button",{type:"button",...h(a.saveDraft),title:a.saveDraftTooltip,"aria-disabled":c,"aria-busy":f,"aria-keyshortcuts":"Control+S Meta+S","data-testid":"markdown-explorer-edit-save",onClick:u,onDoubleClick:ae,children:[l.jsx(Zi,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.saveDraft})]}),r.history?l.jsx(ec,{path:e,documentName:t,open:i,onClose:()=>m(!1)}):null]})},dc=({path:e,session:t})=>{const{edits:n}=F();return t.save.kind!=="grant"?null:l.jsx(co,{href:t.save.href,onRetry:()=>{n.save(e)},testId:"markdown-explorer-save-grant"})},uc=new Set,fc=(e,t,n)=>{const{documents:r,announcer:o,labels:s}=F(),a=d.useCallback(()=>r.peek(e),[r,e]),i=d.useCallback(()=>r.peekSeeded(e),[r,e]),m=d.useSyncExternalStore(r.subscribe,a,i),f=d.useCallback(()=>r.answerStampOf(e),[r,e]),c=d.useSyncExternalStore(r.subscribe,f,f),[u]=d.useState(()=>new Set),[h,w]=d.useState(uc),[E,b]=d.useState(null);E!==null&&(E.path!==e||E.markup!==n)&&b(null);const T=d.useRef(null);d.useLayoutEffect(()=>(T.current=e,()=>{T.current=null}),[e]);const O=d.useRef(n);d.useLayoutEffect(()=>{O.current=n},[n]);const L=d.useCallback(()=>{const p=e,g=r.peek(p);u.has(p)||g?.status==="pending"||(u.add(p),w(new Set(u)),b(null),(async()=>{try{const R=await r.refresh(p);if(T.current!==p||R.status==="superseded")return;if(R.status==="failed"){b({path:p,failure:R.failure,stamp:r.answerStampOf(p),markup:O.current}),o.announce(s.documentRefreshFailed(re(s,R.failure.reason)));return}if(R.status==="shown"&&(t||R.failed))return;const N=le(r.peek(p));if(N===null||N.document.kind==="failure")return;o.announce(s.documentRefreshed(N.document.name))}finally{u.delete(p),w(new Set(u))}})())},[e,t,u,r,o,s]),q=h.has(e),j=E!==null&&E.path===e&&E.stamp===c&&E.markup===n?E.failure:null;return{refreshing:q,unavailable:q||m?.status==="pending",failure:j,refresh:L}},mc=(e,t)=>{switch(t){case"markdown":return e.showMarkup;case"svg":return e.showSvgMarkup;case"csv":case"tsv":return e.showSpreadsheetMarkup(t.toUpperCase())}},po=Object.freeze({kind:"page"}),go=({path:e,placement:t,markup:n})=>{const{labels:r}=F(),{refreshing:o,unavailable:s,failure:a,refresh:i}=fc(e,t.kind==="page",n.shown),m=Ja(e),f=tc(e),c=er(e),u=t.kind==="panel"?r.refreshDocumentNamed(t.documentName):null,h=t.kind==="panel"?r.showMarkupNamed(t.documentName):null,w=t.kind==="panel",E=t.kind==="panel"?t.documentName:f.name,b=t.kind==="page"||t.maximized;return l.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar","data-aqmx-editing":c===void 0?void 0:"true",children:[l.jsxs("div",{className:"aqmx-document-refresh-row",children:[c===void 0?null:l.jsx(oc,{session:c}),c===void 0?null:l.jsx(cc,{path:e,documentName:E,iconOnly:w,session:c,previewAvailable:b}),c===void 0&&m!==null?l.jsxs("button",{type:"button",className:h===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:h===null?mc(r,m):h,"aria-label":h===null?void 0:h,"aria-pressed":n.shown,"data-testid":"markdown-explorer-document-markup",onClick:n.toggle,onDoubleClick:ae,children:[l.jsx(lo,{"aria-hidden":"true"}),h===null?l.jsx("span",{children:r.showMarkupLabel}):null]}):null,c!==void 0||f.edit?.kind==="inline"||f.edit?.kind==="draft"?l.jsx(nc,{path:e,documentName:E,iconOnly:w,previewAvailable:b,draft:f.edit?.kind==="draft"}):f.edit?.kind==="external"?l.jsx(rc,{href:f.edit.href,documentName:E,iconOnly:w}):null,c===void 0?l.jsxs("button",{type:"button",className:u===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:u===null?r.refreshDocument:u,"aria-label":u===null?void 0:u,"aria-disabled":s,"aria-busy":o,"data-aqmx-busy":o?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:i,onDoubleClick:ae,children:[l.jsx(ao,{"aria-hidden":"true"}),u===null?l.jsx("span",{children:r.refreshDocumentLabel}):null]}):null]}),c!==void 0||a===null?null:l.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":a.reason,children:r.documentRefreshFailed(re(r,a.reason))}),c===void 0?null:l.jsx(dc,{path:e,session:c})]})},hc=({location:e})=>{const t=e.doc,n=d.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),r=Nr(e);return l.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",...Ue,children:[l.jsx(go,{path:t,placement:po,markup:r}),l.jsx(so,{path:t,absence:no,markup:e.markup,variant:n})]})},wo=({holds:e,testId:t})=>{const{labels:n,announcer:r}=F(),o=d.useId();d.useLayoutEffect(()=>e?r.claim(o):void 0,[e,r,o]);const s=d.useCallback(()=>r.shownIn(o),[r,o]),a=d.useSyncExternalStore(r.subscribe,s,s);return l.jsx("div",{className:"aqmx-sr-only",role:"status","aria-live":"polite","aria-atomic":"true","data-testid":t,children:a.length>1?n.announcementSequence(a):a[0]})},he=Object.freeze([]),pc=e=>{const t=new Set;let n=he,r=[],o=!1;const s=[],a=c=>{n=c;for(const u of[...t])u()},i=()=>s.at(-1)?.region,m=c=>{const u=i();c(),i()!==u&&n!==he&&a(he)},f=()=>{o=!1;const c=r.map(u=>"sentence"in u?u.sentence:u.list(u.items));r=[],a(Object.freeze(c))};return{announce:c=>{if(typeof c=="string")r.push({sentence:c});else{const u=r.find(h=>"list"in h&&h.list===c.list);u!==void 0&&"items"in u?u.items.push(c.item):r.push({list:c.list,items:[c.item]})}o||(o=!0,n!==he&&a(he),e.request(f))},subscribe:c=>(t.add(c),()=>{t.delete(c)}),claim:c=>{const u={region:c};return m(()=>s.push(u)),()=>m(()=>{const h=s.indexOf(u);h!==-1&&s.splice(h,1)})},shownIn:c=>i()===c?n:he}},se=Object.freeze({status:"cancelled"}),Tn=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(_.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return _.failureOf(n,r)},gc=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((c,u)=>globalThis.fetch(c,u)),o=(c,u)=>`${e}/${c}?${new URLSearchParams(u).toString()}`,s=c=>{c.status===401&&t(null);const u=c.headers.get(_.EXPLORER_SCOPE_HEADER);u!==null&&t(u)},a=async(c,u,h,w)=>{let E;try{E=await r(c,{credentials:"same-origin",...u,headers:{Accept:"application/json",...u.headers}})}catch{return w({reason:"failed"})}s(E);let b;try{b=await E.json()}catch{return w({reason:_.failureReasonOfStatus(E.status)})}let T;try{T=h(b)}catch{T=!1}if(T)return b;const O=Tn(b);return w(O!==null?O:{reason:E.status===200?"failed":_.failureReasonOfStatus(E.status)})},i={[_.EXPLORER_PROOF_HEADER]:_.EXPLORER_REFRESH_PROOF},m={[_.EXPLORER_PROOF_HEADER]:_.EXPLORER_EDIT_PROOF,"Content-Type":`${_.EXPLORER_DRAFT_MEDIA_TYPE}; charset=utf-8`},f=async(c,u,h)=>{const w=await a(c,u,h,E=>_.failureDocument(E.reason,E.code));return u.signal.aborted?se:w};return{tree:c=>a(o("tree",{[_.EXPLORER_DATA_QUERY.source]:c}),{method:"GET"},_.isExplorerTreeResult,u=>({status:"error",failure:u})),children:async(c,u,h)=>{const w=await a(o("children",{[_.EXPLORER_DATA_QUERY.source]:c,[_.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:h},_.isExplorerChildrenResult,E=>({status:"error",failure:E}));return h.aborted?se:w},ancestors:async(c,u,h)=>{const w=await a(o("ancestors",{[_.EXPLORER_DATA_QUERY.source]:c,[_.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:h},_.isExplorerAncestorsResult,E=>({status:"error",failure:E}));return h.aborted?se:w},reveal:async(c,u,h)=>{const w=await a(o("reveal",{[_.EXPLORER_DATA_QUERY.source]:c,[_.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:h},_.isExplorerRevealResult,E=>({status:"error",failure:E}));return h.aborted?se:w},document:(c,{refresh:u})=>a(o("document",{[_.EXPLORER_DATA_QUERY.path]:c}),u?{method:"GET",headers:i}:{method:"GET"},_.isExplorerDocument,h=>_.failureDocument(h.reason,h.code)),text:async(c,u)=>{const h=await a(o("text",{[_.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:u},_.isExplorerTextAnswer,w=>_.failureDocument(w.reason,w.code));return u.aborted?se:h},asset:async(c,u)=>{let h;try{h=await r(c,{method:"GET",credentials:"same-origin",signal:u})}catch{return u.aborted?se:{status:"error",failure:{reason:"failed"}}}if(s(h),h.ok)return u.aborted?se:{status:"ok",body:h.body===null?new ReadableStream({start:b=>b.close()}):h.body};let w=null;try{w=await h.json()}catch{}if(u.aborted)return se;const E=Tn(w);return{status:"error",failure:E===null?{reason:_.failureReasonOfStatus(h.status)}:E}},edit:(c,u)=>f(o("edit",{[_.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:u},_.isExplorerEditAnswer),save:(c,u,h,w)=>f(o("save",{[_.EXPLORER_DATA_QUERY.path]:c,[_.EXPLORER_DATA_QUERY.base]:u}),{method:"POST",headers:m,body:h,signal:w},_.isExplorerSaveAnswer),preview:(c,u,h)=>f(o("preview",{[_.EXPLORER_DATA_QUERY.path]:c}),{method:"POST",headers:m,body:u,signal:h},_.isExplorerPreviewAnswer),revisions:(c,u)=>f(o("revisions",{[_.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:u},_.isExplorerRevisionsAnswer),revision:(c,u,h)=>f(o("revision",{[_.EXPLORER_DATA_QUERY.path]:c,[_.EXPLORER_DATA_QUERY.revision]:u}),{method:"GET",signal:h},_.isExplorerRevisionAnswer),refresh:c=>a(o("refresh",{[_.EXPLORER_DATA_QUERY.source]:c}),{method:"POST",headers:i},_.isExplorerTreeResult,u=>({status:"error",failure:u}))}},wc=()=>{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}}},vc=e=>{const t=J.readStorage(e);if(t===null)return H.NO_TREE_SETTING_CHANGES;try{return H.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),H.NO_TREE_SETTING_CHANGES}},Ln=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=vc(e);n={changes:s,settings:H.applyTreeSettingChanges(t,s)}}return n},o=xe();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:a,settings:i}=r(),m=H.recordTreeSettingChange(a,s,H.advanceTreeSetting(i,s)[s],t);return n={changes:m,settings:H.applyTreeSettingChanges(t,m)},o.emit(),J.writeStorage(e,H.serializeTreeSettingChanges(m)),n.settings}}},Ec=Object.freeze({status:"refreshed"}),xc=Object.freeze({status:"superseded"}),Tt=Object.freeze({status:"deferred"}),bc=Yn(Tt),vo=4,Sc=vo-1,Cn=Object.freeze({status:"loading"}),yc=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),kc=e=>{const t=new Map,n=xr(),r=new Map,o=new Map,s=new Map,a=new Map,i=xe(),m=new Set;let f=0,c=0;const u={direct:null,bulk:null},h=new Set;let w=!1,E=0;const b=()=>{E+=1,i.emit()},T=v=>o.get(v)??0,O=v=>{let S=a.get(v);return S===void 0&&(S={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},a.set(v,S)),S},L=(v,S,C)=>{v.inFlight.delete(S),f-=1,C.lane==="bulk"&&(c-=1)},q=v=>{const S=a.get(v);if(S!==void 0){for(const[C,D]of[...S.inFlight])L(S,C,D),D.controller.abort();S.direct.clear(),S.bulk.clear(),S.unclaimed.clear()}},j=v=>{const S=T(v)+1;return o.set(v,S),q(v),S},p=(v,S)=>{const C=Se(v),D={promise:v,opened:S,stale:!1,loadedAt:C?.status==="ok"?C.loadedAt:null};return v.status==="pending"&&v.then(U=>{U.status==="ok"&&(D.loadedAt=U.loadedAt)}),D},g=v=>{let S=r.get(v);return S===void 0&&(S=new Map,r.set(v,S)),S},R=v=>{const S=[...a.keys()],C=u[v],D=C===null?0:S.indexOf(C)+1;for(let U=0;U<S.length;U+=1){const Z=S[(D+U)%S.length],K=Z===void 0?void 0:a.get(Z);if(!(Z===void 0||K===void 0)){for(const W of K[v])if((K.claims.get(W)??0)!==0)return K[v].delete(W),u[v]=Z,{sourceId:Z,path:W}}}return null},N=(v,S,C,D)=>{const U=a.get(v);if(U===void 0||U.inFlight.get(S)!==C)return;L(U,S,C);const Z=(U.claims.get(S)??0)>0,K=g(v);if(D.status==="ok"?K.set(S,{status:"loaded",entries:D.entries}):D.status==="error"&&Z?K.set(S,{status:"failed",failure:D.failure}):K.delete(S),b(),D.status==="error"&&Z){const W={sourceId:v,path:S,failure:D.failure};for(const ne of[...m])ne(W)}$()},I=(v,S,C)=>{const D={controller:new AbortController,lane:C};O(v).inFlight.set(S,D),f+=1,C==="bulk"&&(c+=1),e.children(v,S,D.controller.signal).then(U=>N(v,S,D,U),()=>N(v,S,D,yc))},$=()=>{for(;f<vo;){const v=R("direct");if(v!==null){I(v.sourceId,v.path,"direct");continue}const S=c<Sc?R("bulk"):null;if(S===null)return;I(S.sourceId,S.path,"bulk")}},x=(v,S,C)=>{if(!(S.direct.delete(C)||S.bulk.delete(C))){const U=S.inFlight.get(C);if(U===void 0)return!1;L(S,C,U),U.controller.abort()}return r.get(v)?.delete(C),!0},k=()=>{w=!1;let v=!1;for(const S of h){const C=O(S);for(const D of C.unclaimed)(C.claims.get(D)??0)===0&&x(S,C,D)&&(v=!0);C.unclaimed.clear()}h.clear(),v&&(b(),$())},A=(v,S)=>{t.set(v,p(Te(e.tree(v)),S))},M=(v,S,C)=>{j(v);const D=p(Yn(S),C);return t.set(v,D),r.delete(v),b(),$(),D},P=(v,S,C,D)=>{if(C!==T(v)||t.get(v)!==S)return;const U=Se(S.promise);if(!(D.status!=="ok"||U?.status!=="ok"||S.loadedAt===null||D.loadedAt<=S.loadedAt)){if(ze(U.entries,D.entries)){S.loadedAt=D.loadedAt;return}M(v,D,S.opened)}},B=(v,S)=>{const C=t.get(v);return C!==void 0&&Se(C.promise)?.status===S},G=(v,S)=>{S.stale=!1;const C=T(v);e.tree(v).then(D=>P(v,S,C,D))};return{read:v=>t.get(v)?.promise??bc,open:v=>{const S=n.resumes(v),C=n.hold(v),D=t.get(v);return D===void 0||B(v,"deferred")?(A(v,!0),b()):S||(D.opened&&B(v,"error")?(A(v,!0),b()):(D.opened=!0,D.stale&&B(v,"ok")&&G(v,D))),C},retry:v=>{B(v,"error")&&(A(v,!0),b())},seed:(v,S)=>{const C=S.then(Z=>Z===null?Tt:Z,()=>Tt),D=t.get(v);if(D!==void 0&&B(v,"ok")){const Z=T(v);C.then(K=>P(v,D,Z,K));return}j(v);const U=p(Te(C),D?.opened===!0);t.set(v,U),r.delete(v),$(),C.then(Z=>{t.get(v)===U&&(Z.status==="deferred"&&n.isHeld(v)&&A(v,U.opened),b())})},refresh:async v=>{const S=(s.get(v)??0)+1;s.set(v,S);const C=await e.refresh(v);if(s.get(v)!==S)return xc;if(C.status==="error")return{status:"failed",failure:C.failure};const D=t.get(v);if(!(D!==void 0&&D.loadedAt!==null&&B(v,"ok")&&D.loadedAt>C.loadedAt)){const Z=M(v,C,!0);if(D!==void 0&&D.promise.status==="pending"){const K=T(v);D.promise.then(W=>P(v,Z,K,W))}}for(const[Z,K]of t)Z!==v&&Se(K.promise)?.status==="ok"&&(K.stale=!0);return Ec},children:(v,S)=>r.get(v)?.get(S),claimChildren:(v,S)=>{const C=O(v),D=g(v);let U=!1,Z=!1;for(const[W,ne]of S)C.claims.set(W,(C.claims.get(W)??0)+1),D.get(W)===void 0?(D.set(W,Cn),C[ne].add(W),U=!0,Z=!0):ne==="direct"&&C.bulk.delete(W)&&(C.direct.add(W),Z=!0);U&&b(),Z&&$();let K=!1;return()=>{if(!K){K=!0;for(const W of S.keys()){const ne=(C.claims.get(W)??0)-1;ne>0?C.claims.set(W,ne):(C.claims.delete(W),C.unclaimed.add(W))}h.add(v),!w&&(w=!0,queueMicrotask(k))}}},retryChildren:(v,S)=>{const C=r.get(v);if(C===void 0||C.get(S)?.status!=="failed")return;const D=O(v);if((D.claims.get(S)??0)>0){C.set(S,Cn),D.direct.add(S),b(),$();return}C.delete(S),b()},pendingChildren:v=>{const S=a.get(v);return S===void 0?0:S.direct.size+S.bulk.size+S.inFlight.size},clear:()=>{for(const v of new Set([...t.keys(),...r.keys(),...o.keys(),...a.keys()]))j(v);for(const[v,S]of s)s.set(v,S+1);t.clear(),r.clear(),b()},subscribeChildrenFailures:v=>(m.add(v),()=>{m.delete(v)}),subscribe:i.subscribe,version:()=>E}},Rc=(e,t)=>{let n=e;const r=xe();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},Tc=1;let Ie=0,ie=null;const Lc=()=>{const{documentElement:e,body:t}=document;Ie===0&&(ie={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"),Ie+=1;let n=!1;return()=>{n||(n=!0,Ie-=1,!(Ie>0||ie===null)&&(e.style.overflow=ie.htmlOverflow,t.style.overflow=ie.bodyOverflow,e.style.scrollbarGutter=ie.htmlGutter,t.style.scrollbarGutter=ie.bodyGutter,ie=null))}},Cc=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],On=1,Oc=1e3,An=e=>e.getClientRects().length>0,ht="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.",Ac=e=>{if(!An(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+Tc)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. ${ht}`;if(t.height<On)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. ${ht}`;for(const{selector:r,name:o}of Cc)for(const s of e.querySelectorAll(r)){if(!An(s))continue;const a=s.getBoundingClientRect().height;if(a<On)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. ${ht}`}return null},Mc=e=>{let t=!1,n;const r=()=>{n=void 0;const a=Ac(e);a!==null&&(t=!0,console.error(a))},o=()=>{t||(clearTimeout(n),n=setTimeout(r,Oc))},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)}},Nc=(e,t)=>{d.useEffect(()=>e?Lc():void 0,[e]),d.useEffect(()=>{const n=t.current;if(!(!e||n===null))return Mc(n)},[e,t])},Mn='[data-testid="markdown-explorer-view-switch"]',Dc=[{control:Mn,successors:[Mn,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],jc=e=>{for(const t of Dc){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},Pc=(e,t)=>{const n=d.useRef(null);d.useEffect(()=>{const o=i=>{const m=e.current;n.current=m!==null&&i instanceof Element&&m.contains(i)?jc(i):null},s=i=>o(i.target);o(document.activeElement);const a=i=>{const m=i.target;i.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=d.useRef(t);d.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 f=e.current;if(f===null)return!0;for(const c of o.control.successors)for(const u of f.querySelectorAll(c))if(u!==o.element&&(u.focus({preventScroll:!0}),document.activeElement===u))return!0;return!1};if(s())return;const a=e.current;if(a===null)return;const i=new MutationObserver(()=>{s()&&i.disconnect()});return i.observe(a,{childList:!0,subtree:!0}),()=>i.disconnect()},[t,e])},_c=d.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-DKq_aXBx.cjs")).then(e=>({default:e.TreeLayout}))),Ic=d.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-mDzolCaK.cjs")).then(e=>({default:e.MultiLayout}))),Fc=64,$c={request:e=>{requestAnimationFrame(e)}},Nn=e=>{e.documents.clear(),e.trees.clear()},pt=(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)},qc=(e,t)=>{const[n,r]=d.useState(()=>({overrides:t,locale:e,labels:xt(e,t)}));if(n.locale===e&&Po(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:xt(e,t)};return r(o),o.labels},Bc=(e,t,n)=>{const[r,o]=d.useState(()=>({scope:t,store:Ln(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:Ln(e,n)};return o(s),s.store},gt=(e,t)=>{const[n,r]=d.useState(()=>({scope:e,value:t()}));if(n.scope===e)return n.value;const o={scope:e,value:t()};return r(o),o.value},Uc=()=>pc($c),Dn="on",Hc="off",zc=Object.freeze({kind:"unavailable"}),Vc=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")},Zc=(e,t)=>{const n=le(e.peek(t));return n===null||n.document.kind==="failure"?_.lastPathSegment(t):n.document.name},Wc=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:a,renderTreeFailure:i,lockDocumentScroll:m=!1,onMathDiagnostics:f,onEditGrant:c,draftConverter:u})=>{J.assertStorageNamespace(n),Vc(u);const h=qn(r),w=_o(s),E=qc(h,o),{revalidate:b}=te.useRevalidator(),T=d.useRef(()=>{}),O=te.useHref(t.dataPath),[L]=d.useState(()=>{const C=gc({dataPath:O,onScope:U=>T.current(U)}),D={documents:Os({client:C,capacity:Math.max(Fc,t.multiView.maxPanels*2)}),trees:kc(C)};return pt(D,e),J.syncStorageScope(n,e.scope),{data:C,...D,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(L.aligned.pageData!==e||L.aligned.storageNamespace!==n){const C=L.aligned.pageData;L.aligned.pageData=e,L.aligned.storageNamespace=n,C!==e&&(C.scope!==e.scope?L.aligned.pendingReader=e:pt(L,e)),J.syncStorageScope(n,e.scope)}const q=Bc(J.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);d.useLayoutEffect(()=>{const C=L.aligned.pendingReader;C!==null&&(L.aligned.pendingReader=null,Nn(L),pt(L,C))},[e,L]),d.useLayoutEffect(()=>{let C=!1;return T.current=D=>{D===e.scope||C||(C=!0,D!==null&&(Nn(L),J.clearExplorerStorage(n)),b())},()=>{T.current=()=>{}}},[e,b,L,n]);const j=d.useRef(t.settingsCookie);d.useLayoutEffect(()=>{j.current=t.settingsCookie},[t.settingsCookie]);const[p]=d.useState(()=>Rc(e.settings,C=>{document.cookie=H.viewSettingsCookieString(j.current,C,window.location.protocol==="https:")})),g=gt(e.scope,Uc),R=gt(e.scope,wc),N=d.useRef(E);d.useLayoutEffect(()=>{N.current=E},[E]);const I=gt(e.scope,()=>Ho({data:L.data,conflictLabels:()=>({ours:N.current.conflictOurs,theirs:N.current.conflictTheirs}),onSaveSettled:(C,D)=>{D.kind==="saved"&&L.documents.refresh(C);const U=Fo(N.current,D,Zc(L.documents,C));U!==null&&g.announce(U)},sideBySideSetting:{read:()=>J.readStorage(J.storageKeys(n).editPreview)===Dn,write:C=>J.writeStorage(J.storageKeys(n).editPreview,C?Dn:Hc)},editorShareSetting:{read:()=>Uo(J.readStorage(J.storageKeys(n).editSplit)),write:C=>J.writeStorage(J.storageKeys(n).editSplit,String(C))}})),$=d.useMemo(()=>Te(e.notices.catch(()=>[])),[e.notices]),x=e.sources.map(C=>C.id).join(`
13
+ `))))},end:w=>{if(w==="table"){s=Math.max(0,s-1),s===0&&a&&(a=!1,i=!0);return}if(h!==null&&h.annotationDepth>0){w==="annotation"&&(h.annotationDepth-=1);return}if(!(!a||s!==1))if((w==="table-cell"||w==="covered-table-cell")&&h!==null){const E=h.covered?"":h.parts.join("");if(E!==""){const b=Math.min(u+h.repeat,n.maxColumns+1);for(let T=u;T<b;T+=1)c.set(T,E)}u+=h.repeat,h=null}else w==="table-row"?(r.addRow(m,c,f),m+=f):(w==="p"||w==="h")&&h!==null&&(h.paragraphDepth=Math.max(0,h.paragraphDepth-1))},text:w=>{h!==null&&h.annotationDepth===0&&h.paragraphDepth>0&&h.parts.push(w)}},()=>i||r.full()),r.table()},Fl=async(e,t)=>{if(await Pl(e,t))throw new Y("encrypted","the spreadsheet's manifest names encryption data");const{tables:n,hidingStyles:r}=await _l(vn(e,t)),o=[];let s=0;return n.forEach((a,i)=>{if(r.has(a.style)){s+=1;return}o.push({name:a.name,read:async m=>Il(vn(e,t),i,m)})}),o.length===0&&Wr("shows no table"),{sheets:o.slice(0,t.maxSheets),unshownSheets:s,unlistedSheets:Math.max(0,o.length-t.maxSheets)}},pe=Object.freeze({kind:"general"}),$l=new Map([[0,"General"],[1,"0"],[2,"0.00"],[3,"#,##0"],[4,"#,##0.00"],[9,"0%"],[10,"0.00%"],[11,"0.00E+00"],[12,"# ?/?"],[13,"# ??/??"],[14,"mm-dd-yy"],[15,"d-mmm-yy"],[16,"d-mmm"],[17,"mmm-yy"],[18,"h:mm AM/PM"],[19,"h:mm:ss AM/PM"],[20,"h:mm"],[21,"h:mm:ss"],[22,"m/d/yy h:mm"],...[27,28,29,30,31,34,35,36,50,51,52,53,54,55,56,57,58].map(e=>[e,"yyyy-mm-dd"]),[32,"h:mm"],[33,"h:mm:ss"],[37,"#,##0 ;(#,##0)"],[38,"#,##0 ;[Red](#,##0)"],[39,"#,##0.00;(#,##0.00)"],[40,"#,##0.00;[Red](#,##0.00)"],[45,"mm:ss"],[46,"[h]:mm:ss"],[47,"mmss.0"],[48,"##0.0E+0"],[49,"@"]]),ql=/^\[(h+|m+|s+)\]$/iu,Bl=e=>{let t="",n=!1;for(let r=0;r<e.length;r+=1){const o=e[r];if(o===";")break;if(o==='"'){const s=e.indexOf('"',r+1);r=s===-1?e.length:s}else if(o==="\\"||o==="_"||o==="*")r+=1;else if(o==="["){const s=e.indexOf("]",r+1),a=e.slice(r,s===-1?e.length:s+1);ql.test(a)&&(t+=a.slice(1,-1),n=!0),r=s===-1?e.length:s}else t+=o}return{text:t.toLowerCase(),elapsed:n}},Ul=e=>{const{text:t,elapsed:n}=Bl(e);if(t===""||t==="general"||t.includes("@")||/[0#?.]e[+-]/u.test(t))return pe;const r=n||/[hs]/u.test(t)||t.includes("am/pm")||t.includes("a/p"),o=/[ydge]/u.test(t.replace(/am\/pm|a\/p/gu,""))||t.includes("m")&&!r;if(o||r)return{kind:"date-time",date:o,time:r,seconds:t.includes("s"),elapsed:n};if(/[0#?]\s*\/\s*[0#?]/u.test(t))return pe;const s=/[0#?][0#?,]*(?:\.[0#?]*)?,*/u.exec(t)?.[0];if(s===void 0)return pe;const a=/,*$/u.exec(s)?.[0].length??0,[i="",m=""]=s.slice(0,s.length-a).split("."),f=(m.match(/[0#?]/gu)??[]).length;return t.includes("%")?{kind:"percent",decimals:f}:{kind:"fixed",decimals:f,grouping:i.includes(","),scale:1e3**a}},Hl=(e,t)=>{const n=t.get(e)??$l.get(e);return n===void 0?pe:Ul(n)},Ft=e=>{if(Number.isInteger(e)&&Math.abs(e)<1e15)return String(e);const[t="",n]=e.toPrecision(15).split("e"),r=t.includes(".")?t.replace(/0+$/u,"").replace(/\.$/u,""):t;return n===void 0?r:`${r}E${n.startsWith("-")?n:`+${n.replace("+","")}`}`},En=(e,t,n)=>{const r=Math.abs(e).toFixed(t);if(r.includes("e"))return Ft(e);const[o="",s]=r.split("."),a=n?o.replace(/\B(?=(\d{3})+(?!\d))/gu,","):o;return`${e<0&&/[1-9]/u.test(r)?"-":""}${a}${s===void 0?"":`.${s}`}`},zl=864e5,xn=86400,Vl=2958465,we=(e,t)=>String(e).padStart(t,"0"),Zl=(e,t)=>{if(!t&&e===0)return"1900-01-00";if(!t&&e===60)return"1900-02-29";const n=t?Date.UTC(1904,0,1):e<60?Date.UTC(1899,11,31):Date.UTC(1899,11,30),r=new Date(n+e*zl);return`${we(r.getUTCFullYear(),4)}-${we(r.getUTCMonth()+1,2)}-${we(r.getUTCDate(),2)}`},Wl=(e,t,n)=>{if(e<0||e>=Vl+1)return Ft(e);let r=Math.floor(e),o=Math.round((e-r)*xn);o===xn&&(r+=1,o=0);const s=Math.floor(o/3600),a=Math.floor(o%3600/60),i=`${we(t.elapsed?r*24+s:s,2)}:${we(a,2)}${t.seconds?`:${we(o%60,2)}`:""}`;if(t.elapsed||!t.date)return i;const m=Zl(r,n);return t.time?`${m} ${i}`:m},Gl=(e,t,n)=>{switch(t.kind){case"general":return Ft(e);case"date-time":return Wl(e,t,n);case"percent":return`${En(e*100,t.decimals,!1)}%`;case"fixed":return En(e/t.scale,t.decimals,t.grouping)}},Gr="_rels/.rels",oe=e=>{throw new Y("not-workbook",`the workbook ${e}`)},$t=(e,t)=>{const n=zr(t,()=>!1);n.write(e),n.finish()},Kl=(e,t)=>{try{return decodeURIComponent(e)}catch{return oe(`points to a malformed part name (${t})`)}},Xl=(e,t)=>{const r=[...t.startsWith("/")?[]:e.split("/").slice(0,-1)];for(const o of t.split("/"))o===""||o==="."||(o===".."?(r.length===0&&oe(`points above its root (${t})`),r.pop()):r.push(Kl(o,t)));return r.join("/")},Yl=e=>{const t=e.lastIndexOf("/");return`${e.slice(0,t+1)}_rels/${e.slice(t+1)}.rels`},bn=async(e,t,n)=>{const r=await Ge(e,t===""?Gr:Yl(t),n.maxPartBytes),o=new Map;return r===null||$t(r,{start:(s,a)=>{if(s!=="Relationship")return;const i=a.get("Id"),m=a.get("Type"),f=a.get("Target");i===void 0||m===void 0||f===void 0||a.get("TargetMode")==="External"||o.set(i,{type:m,target:Xl(t,f)})}}),o},dt=(e,t)=>{for(const n of e.values())if(n.type.endsWith(`/${t}`))return n.target;return null},Ql=e=>{const t=[];let n=!1;return $t(e,{start:(r,o)=>{if(r==="workbookPr"){const s=o.get("date1904");n=s==="1"||s==="true"}else r==="sheet"&&t.push({name:o.get("name")??"",state:o.get("state")??"visible",relationship:o.get("id")??""})}}),{sheets:t,date1904:n}},Jl=async e=>{const t=[];let n=null,r=!1,o=0;return await Ne(e,{start:(s,a,i)=>{s==="si"?n=[]:s==="rPh"&&!i?o+=1:s==="t"&&o===0&&(r=!i)},end:s=>{s==="si"&&n!==null?(t.push(n.join("")),n=null):s==="rPh"?o=Math.max(0,o-1):s==="t"&&(r=!1)},text:s=>{r&&n!==null&&n.push(s)}},()=>!1),t},ei=e=>{const t=new Map,n=[];let r=!1;return $t(e,{start:(o,s)=>{if(o==="numFmt"){const a=Number(s.get("numFmtId")),i=s.get("formatCode");Number.isInteger(a)&&i!==void 0&&t.set(a,i)}else if(o==="cellXfs")r=!0;else if(o==="xf"&&r){const a=Number(s.get("numFmtId")??"0");n.push(Number.isInteger(a)?a:0)}},end:o=>{o==="cellXfs"&&(r=!1)}}),n.map(o=>Hl(o,t))},ti=/^(\d{4}-\d{2}-\d{2})(?:T(\d{2}:\d{2}(?::\d{2})?)(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?$/u,ni=e=>{const t=ti.exec(e);if(t===null)return e;const[,n,r]=t;return r===void 0||/^00:00(?::00)?$/u.test(r)?n??e:`${n} ${r}`},ri=/^([A-Za-z]{1,3})(\d+)$/u,oi=e=>{const t=ri.exec(e)?.[1];if(t===void 0)return null;let n=0;for(const r of t.toUpperCase())n=n*26+(r.charCodeAt(0)-64);return n-1},si=(e,t,n,r)=>{const o=e.value.join("");switch(e.type){case"s":return o===""?"":t[Number(o)]??oe(`refers to the shared string ${o}, past its ${t.length}`);case"inlineStr":return e.inline.join("");case"b":return o===""?"":o==="1"||o==="true"?"TRUE":"FALSE";case"str":case"e":return o;case"d":return ni(o.trim());default:{const s=o.trim();if(s==="")return"";const a=Number(s);return Number.isFinite(a)?Gl(a,n[e.style]??pe,r):s}}},ai=async(e,t,n,r,o)=>{const s=Ir(t);let a=-1,i=new Map,m=0,f=null;return await Ne(e,{start:(c,u,h)=>{if(c==="row"){const w=Number(u.get("r"));a=Number.isInteger(w)&&w>a+1?w-1:a+1,i=new Map,m=0}else if(c==="c"){const w=oi(u.get("r")??"")??m,E=Number(u.get("s")??"0");f={column:w,type:u.get("t")??"n",style:Number.isInteger(E)?E:0,value:[],inline:[],inValue:!1,inInlineText:!1,phoneticDepth:0}}else f!==null&&(c==="v"?f.inValue=!h:c==="rPh"&&!h?f.phoneticDepth+=1:c==="t"&&f.type==="inlineStr"&&f.phoneticDepth===0&&(f.inInlineText=!h))},end:c=>{if(c==="c"&&f!==null){const u=si(f,n,r,o);u!==""&&i.set(f.column,u),m=f.column+1,f=null}else c==="row"?s.addRow(a,i,1):f!==null&&(c==="v"?f.inValue=!1:c==="rPh"?f.phoneticDepth=Math.max(0,f.phoneticDepth-1):c==="t"&&(f.inInlineText=!1))},text:c=>{f!==null&&(f.inValue?f.value.push(c):f.inInlineText&&f.inline.push(c))}},s.full),s.table()},li=async(e,t)=>{const n=dt(await bn(e,"",t),"officeDocument")??oe("has no officeDocument relationship"),r=await Ge(e,n,t.maxPartBytes)??oe(`has no part ${n}`),{sheets:o,date1904:s}=Ql(r),a=await bn(e,n,t),i=dt(a,"sharedStrings"),m=i===null?null:Ce(e,i,t.maxPartBytes),f=m===null?[]:await Jl(m),c=dt(a,"styles"),u=c===null?null:await Ge(e,c,t.maxPartBytes),h=u===null?[]:ei(u),w=[];let E=0;for(const b of o){const T=a.get(b.relationship)??oe(`lists the sheet ${b.name} without its relationship`);if(b.state!=="visible"||!T.type.endsWith("/worksheet")){E+=1;continue}e.entries.has(T.target)||oe(`has no part ${T.target} for the sheet ${b.name}`),w.push({name:b.name,read:async O=>{const L=Ce(e,T.target,t.maxPartBytes)??oe(`has no part ${T.target}`);return ai(L,O,f,h,s)}})}return w.length===0&&oe("shows no sheet"),{sheets:w.slice(0,t.maxSheets),unshownSheets:E,unlistedSheets:Math.max(0,w.length-t.maxSheets)}},ii=Object.freeze([80,75,3,4]),ci=Object.freeze([208,207,17,224,161,177,26,225]),ut=Uint8Array.from([..."EncryptedPackage"].flatMap(e=>[e.charCodeAt(0),0])),di=new Set(["application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.spreadsheet-template"]),ui="mimetype",Kr=(e,t)=>e.byteLength>=t.length&&t.every((n,r)=>e[r]===n),Xr=e=>Kr(e,ii),Yr=e=>Kr(e,ci),fi=e=>{const t=e.byteLength-ut.byteLength;for(let n=0;n<=t;n+=1)if(e[n]===ut[0]&&ut.every((r,o)=>e[n+o]===r))return!0;return!1},mi=async(e,t)=>{if(Yr(e))throw fi(e)?new Y("encrypted","the bytes are a password-protected workbook"):new Y("not-workbook","the bytes are a compound file (a legacy .xls)");if(!Xr(e))throw new Y("not-workbook","the bytes are no ZIP package");const n=Al(e),r=await Ge(n,ui,t.maxPartBytes);if(r!==null&&di.has(r.trim()))return Fl(n,t);if(n.entries.has(Gr))return li(n,t);throw new Y("not-workbook","the ZIP package is neither an OpenDocument spreadsheet nor an Office Open XML package")},hi=async(e,t)=>{const n=e.getReader(),r=[];let o=0;try{for(;;){const{done:i,value:m}=await n.read();if(i)break;if(o+=m.byteLength,o>t)return null;r.push(m)}}finally{n.cancel().catch(()=>{})}const s=new Uint8Array(o);let a=0;for(const i of r)s.set(i,a),a+=i.byteLength;return s},Qr=async(e,t)=>{try{return{kind:"table",table:await e.read(t)}}catch(n){return{kind:"refused",refusal:n instanceof Y?n.refusal:"not-workbook"}}},pi=async(e,t,n,r,o)=>{const s=await e.asset(_.explorerWorkbookHref(t),o);if(s.status==="cancelled")return null;if(s.status==="error")return{kind:"failure",failure:s.failure};let a;try{a=await hi(s.body,n.maxBytes)}catch{return o.aborted?null:{kind:"failure",failure:{reason:"failed"}}}if(o.aborted)return null;if(a===null)return{kind:"refused",refusal:"too-large"};if(!(Xr(a)||Yr(a)))return{kind:"not-package"};try{const i=await mi(a,n.limits),m=r===null?-1:i.sheets.findIndex(h=>h.name===r),f=Math.max(m,0),c=i.sheets[f];if(c===void 0)return{kind:"refused",refusal:"not-workbook"};const u=await Qr(c,n.budget);return o.aborted?null:{kind:"workbook",workbook:i,selected:f,sheet:u}}catch(i){return i instanceof Y?{kind:"refused",refusal:i.refusal}:o.aborted?null:{kind:"failure",failure:{reason:"failed"}}}},gi=Object.freeze({className:"aqmx-document-spreadsheet-body","data-aqmx-document-scroller":""}),wi=(e,t)=>{switch(t.code){case"encoding":return e.spreadsheetUnreadableEncoding(t.encodings);case"binary":return e.spreadsheetNotText;case"long-row":return e.spreadsheetLongRow}},Sn=(e,t)=>{switch(t){case"encrypted":return e.spreadsheetWorkbookEncrypted;case"not-workbook":return e.spreadsheetNotWorkbook;case"too-large":return e.spreadsheetWorkbookTooLarge}},ft=e=>e.every(t=>t.every(n=>n==="")),Jr=({name:e,url:t,openUrl:n,state:r,children:o})=>l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-spreadsheet-view","data-aqmx-spreadsheet":r,children:[l.jsx(Me,{name:e,openUrl:n,downloadUrl:t,icon:l.jsx(tl,{})}),l.jsx(Ae,{scrollerProps:gi,children:l.jsx("div",{className:"aqmx-document-spreadsheet-column",children:o})})]}),eo=({rows:e,title:t})=>{const{labels:n,locale:r,theme:o}=F(),s=d.use(de),a=d.useMemo(()=>({...qr(n,r),table:t,fullscreenDialog:n.spreadsheetFullscreen(t)}),[n,r,t]),i=d.useMemo(()=>vt.serializeTsv(e),[e]);return l.jsx("div",{className:"aqmx-document-spreadsheet","data-theme":o,children:l.jsx(Ee.SpreadsheetBlock,{tsv:i,layout:s==="fill"?"fill":"inline",locale:r,labels:a,tapScrollCircle:Er})})},ye=({note:e,testId:t,code:n,download:r})=>{const{labels:o}=F();return l.jsx("div",{className:"aqmx-document-spreadsheet-stage",children:r===void 0?l.jsx("p",{className:"aqmx-callout",role:"note","data-testid":t,children:e}):l.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":t,"data-aqmx-unreadable":n,children:[l.jsx("p",{className:"aqmx-callout-body",children:e}),l.jsx("a",{className:"aqmx-callout-action",href:r.url,download:r.name,"data-testid":"markdown-explorer-spreadsheet-unreadable-download",children:o.download})]})})},to=({reading:e,name:t,url:n})=>{const{labels:r}=F();switch(e.kind){case"table":return l.jsxs(l.Fragment,{children:[e.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-truncated",children:r.spreadsheetTruncated}):null,l.jsx(eo,{rows:e.rows,title:t})]});case"empty":return l.jsx(ye,{note:r.spreadsheetEmpty,testId:"markdown-explorer-spreadsheet-empty"});case"unreadable":return l.jsx(ye,{note:wi(r,e),testId:"markdown-explorer-spreadsheet-unreadable",code:e.code,download:{url:n,name:t}})}},vi=({path:e,document:t})=>t.format==="workbook"?l.jsx(xi,{path:e,document:t}):l.jsx(Ei,{path:e,document:t,format:t.format}),Ei=({path:e,document:t,format:n})=>{const{config:r,data:o,labels:s}=F(),{name:a,url:i}=t,m=d.useCallback(async h=>{const w=await $r(o,i,{format:n,legacyEncoding:r.legacyTextEncoding,maxBytes:r.spreadsheets.maxBytes,budget:Be},h);return w===null||w.kind==="failure"?w:{kind:"read",value:w}},[o,i,n,r.legacyTextEncoding,r.spreadsheets.maxBytes]),{shown:f,failure:c,retry:u}=It(e,a,m);return l.jsxs(Jr,{name:a,url:i,openUrl:_.explorerPlainTextHref(i),state:f===null?c===null?"loading":"failure":f.kind,children:[f===null&&c===null?l.jsx(ue,{label:s.spreadsheetLoading,testId:"markdown-explorer-spreadsheet-skeleton"}):null,f===null&&c!==null?l.jsx("div",{className:"aqmx-document-spreadsheet-failure",children:l.jsx(ce,{failure:c,alert:!1,onRetry:u,testId:"markdown-explorer-spreadsheet-failure"})}):null,f===null?null:l.jsx(to,{reading:f,name:a,url:i})]})},xi=({path:e,document:t})=>{const{config:n,data:r,labels:o}=F(),{name:s,url:a,firstSheetText:i}=t,m=d.useId(),f=d.useRef(null),c=d.useCallback(async x=>{const k=await pi(r,a,{maxBytes:n.spreadsheets.maxWorkbookBytes,limits:ll,budget:Be},f.current,x);if(k===null||k.kind==="failure")return k;if(k.kind==="workbook")return{kind:"read",value:k};if(i!==null){const A=await $r(r,a,{format:i,legacyEncoding:n.legacyTextEncoding,maxBytes:n.spreadsheets.maxBytes,budget:Be},x);return A===null||A.kind==="failure"?A:{kind:"read",value:{kind:"first-sheet",reading:A}}}return{kind:"read",value:{kind:"refused",refusal:k.kind==="not-package"?"not-workbook":k.refusal}}},[r,a,i,n.legacyTextEncoding,n.spreadsheets.maxBytes,n.spreadsheets.maxWorkbookBytes]),{shown:u,failure:h,retry:w}=It(e,s,c),[E,b]=d.useState(null),T=d.useRef(new WeakMap),O=u?.kind==="workbook"?u:null,L=O===null?null:E!==null&&E.workbook===O.workbook?E:{workbook:O.workbook,index:O.selected,reading:O.sheet},q=x=>{if(O===null)return;const k=O.workbook.sheets[x];if(k===void 0)return;f.current=k.name;let A=T.current.get(O.workbook);A===void 0&&(A=new Map([[O.selected,O.sheet]]),T.current.set(O.workbook,A));const M=A.get(x),P={workbook:O.workbook,index:x,reading:M??null};if(b(P),M!==void 0)return;const B=A;Qr(k,Be).then(G=>{B.set(x,G),b(v=>v===P?{...P,reading:G}:v)})},j=L===null?null:L.reading===null?"loading":L.reading.kind==="refused"?"unreadable":ft(L.reading.table.rows)?"empty":"table",p=u===null?h===null?"loading":"failure":u.kind==="first-sheet"?u.reading.kind:u.kind==="refused"?"unreadable":j??"loading",g=i===null?a:_.explorerPlainTextHref(a),R=x=>`${m}-sheet-${x}`,N=`${m}-panel`,I=L===null?null:O?.workbook.sheets[L.index]?.name??null,$=O!==null&&O.workbook.sheets.length>1;return l.jsxs(Jr,{name:s,url:a,openUrl:g,state:p,children:[u===null&&h===null?l.jsx(ue,{label:o.spreadsheetLoading,testId:"markdown-explorer-spreadsheet-skeleton"}):null,u===null&&h!==null?l.jsx("div",{className:"aqmx-document-spreadsheet-failure",children:l.jsx(ce,{failure:h,alert:!1,onRetry:w,testId:"markdown-explorer-spreadsheet-failure"})}):null,u?.kind==="refused"?l.jsx(ye,{note:Sn(o,u.refusal),testId:"markdown-explorer-spreadsheet-unreadable",code:u.refusal,download:{url:a,name:s}}):null,u?.kind==="first-sheet"?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-first-sheet",children:o.spreadsheetWorkbookFirstSheet}),l.jsx(to,{reading:u.reading,name:s,url:a})]}):null,O===null||L===null||I===null?null:l.jsxs(l.Fragment,{children:[O.workbook.unshownSheets>0?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-unshown-sheets",children:o.spreadsheetUnshownSheets(O.workbook.unshownSheets)}):null,O.workbook.unlistedSheets>0?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-unlisted-sheets",children:o.spreadsheetUnlistedSheets(O.workbook.sheets.length)}):null,$?l.jsx(cl,{names:O.workbook.sheets.map(x=>x.name),selected:L.index,onSelect:q,label:o.spreadsheetSheets(s),tabIdOf:R,panelId:N}):null,l.jsxs("div",{className:"aqmx-document-spreadsheet-sheet","data-testid":"markdown-explorer-spreadsheet-sheet","data-aqmx-sheet":L.index,...$?{role:"tabpanel",id:N,"aria-labelledby":R(L.index)}:{},children:[L.reading===null?l.jsx(ue,{label:o.spreadsheetSheetLoading,testId:"markdown-explorer-spreadsheet-sheet-skeleton"}):null,L.reading?.kind==="table"&&L.reading.table.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-truncated",children:o.spreadsheetTruncated}):null,L.reading?.kind==="refused"?l.jsx(ye,{note:Sn(o,L.reading.refusal),testId:"markdown-explorer-spreadsheet-unreadable",code:L.reading.refusal,download:{url:a,name:s}}):null,L.reading?.kind==="table"&&ft(L.reading.table.rows)?l.jsx(ye,{note:o.spreadsheetSheetEmpty,testId:"markdown-explorer-spreadsheet-empty"}):null,L.reading?.kind==="table"&&!ft(L.reading.table.rows)?l.jsx(eo,{rows:L.reading.table.rows,title:o.spreadsheetSheetName(s,I)},L.index):null]})]})]})},no=Object.freeze({kind:"empty"}),bi=(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 H.explorerHref(e,{...t,overrides:r})},ke=({kind:e,view:t,label:n,stale:r,busy:o,frameRef:s,intent:a,children:i})=>{const m=d.use(de);return l.jsxs("section",{ref:s,role:"region","aria-label":n,"aria-busy":o,"data-testid":"markdown-explorer-document","data-aqmx-document-kind":e,"data-aqmx-document-view":t,"data-aqmx-document-flow":m,className:"aqmx-document",...a,children:[r?l.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,i]})},Si=({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,i=e.kind==="failure"?e.failure:null;switch(d.useEffect(()=>{t&&s!==null&&o.announce(r.folderReadmeMissing(_.lastPathSegment(s)))},[t,s,o,r]),d.useEffect(()=>{a!==null&&i!==null&&n(r.documentFailed(_.lastPathSegment(a),re(r,i.reason)))},[a,i,n,r]),e.kind){case"empty":return l.jsx(ke,{kind:"empty",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-document-empty",children:l.jsx("p",{className:"aqmx-empty-title",children:r.documentEmpty})})});case"loading":return l.jsx(qt,{label:r.documentRegion});case"no-readme":return l.jsx(ke,{kind:"empty",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-folder-empty",children:l.jsx("p",{className:"aqmx-empty-title",children:r.folderReadmeMissing(_.lastPathSegment(e.folder))})})});case"failure":return l.jsx(ke,{kind:"failure",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx(jt,{failure:e.failure,onRetry:e.onRetry,testId:"markdown-explorer-folder-failure"})})}},qt=({label:e})=>{const{labels:t}=F();return l.jsx(ke,{kind:"loading",label:e,stale:!1,busy:!0,children:l.jsx(ue,{label:t.documentLoading,testId:"markdown-explorer-document-skeleton"})})},yn=Object.freeze(["wheel","touchstart","pointerdown","keydown"]),yi=({path:e,document:t,viewer:n,editing:r})=>{const{reportMathDiagnostics:o,edits:s}=F(),a=d.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),i=Ia(),m=Fa(),f=d.useMemo(()=>o===void 0?void 0:p=>o(e,p),[o,e]),c=d.useRef(null),{editable:u,doubleClick:h,region:w,paneScroll:E,stale:b}=r;d.useLayoutEffect(()=>{if(u)return s.bindView(e,{anchor:()=>{const p=c.current,g=w(),R=p===null?null:p.querySelector(Ye);return p===null||g===null||R===null?null:lr(p,E.scrollerOf(g,R))}})},[s,e,u,w,E]);const T=p=>{const g=c.current,{target:R}=p;!h||g===null||!(R instanceof Element)||!sr(R)||(p.stopPropagation(),s.start(e,ar(R,g,g.ownerDocument.getSelection())))},O=d.useRef(null),L=d.useRef(b);d.useLayoutEffect(()=>{L.current=b});const q=d.useEffectEvent(p=>{const g=c.current,R=w(),N=g===null?null:dr(g,p.line);if(R===null||N===null)return!1;const I=E.scrollerOf(R,N);return I.scrollTop+=ur(N,p.line)-p.clientTop,!0}),j=d.useEffectEvent(p=>{const g=w();if(g===null)return;const R=()=>{for(const I of yn)g.removeEventListener(I,N,!0);O.current?.release===R&&(O.current=null)},N=()=>R();for(const I of yn)g.addEventListener(I,N,{capture:!0,passive:!0});O.current={point:p,release:R}});return d.useLayoutEffect(()=>{const p=s.takeReturn(e);if(p!==null)return queueMicrotask(()=>{q(p)&&L.current&&j(p)}),()=>O.current?.release()},[s,e]),d.useLayoutEffect(()=>{const p=O.current;p===null||b||(p.release(),q(p.point))},[t,b]),l.jsx("div",{ref:c,className:"aqmx-document-viewer",onDoubleClick:T,children:l.jsx(Ee.MarkdownViewer,{...n,onHeadingSelect:i,headingHref:m,onMathDiagnostics:f,parseResult:a,content:null})})},ro=({document:e,viewer:t})=>{const{labels:n}=F();return l.jsxs(l.Fragment,{children:[l.jsx(Me,{name:e.name,openUrl:_.explorerPlainTextHref(e.url),downloadUrl:e.url,icon:l.jsx(ss,{}),children:e.truncated?null:l.jsx(Us,{text:e.text})}),e.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-text-truncated",children:n.textTruncated}):null,l.jsx("div",{className:"aqmx-document-viewer",children:l.jsx(Ee.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},mt=({path:e,name:t,viewer:n})=>{const{data:r,labels:o}=F(),s=d.useCallback(async f=>{const c=await r.text(e,f);return"kind"in c?c.kind==="failure"?{kind:"failure",failure:c.failure}:{kind:"read",value:c}:null},[r,e]),{shown:a,failure:i,retry:m}=It(e,t,s);return a!==null?l.jsx(ro,{document:a,viewer:n}):i!==null?l.jsx(jt,{failure:i,onRetry:m,testId:"markdown-explorer-markup-failure"}):l.jsx(ue,{label:o.markupLoading,testId:"markdown-explorer-markup-skeleton"})},ki=Object.freeze({reason:"failed"}),Ri=e=>{const{labels:t}=F();return l.jsx(is,{fallback:n=>l.jsx("div",{className:"aqmx-edit-message",children:l.jsx(ce,{failure:ki,alert:!1,onRetry:n,testId:"markdown-explorer-edit-load-failure"})}),children:l.jsx(d.Suspense,{fallback:l.jsx(ue,{label:t.editLoading,testId:"markdown-explorer-edit-skeleton"}),children:l.jsx(ls,{...e})})})},Ti=({path:e,document:t,view:n,viewer:r,onRetry:o,editing:s})=>{switch(t.kind){case"markdown":{const{session:a,layout:i,region:m,paneScroll:f,stale:c}=s;if(n==="edit"&&a!==void 0)return l.jsx(Ri,{path:e,name:t.name,session:a,layout:i,viewer:r,region:m,paneScroll:f});if(n==="markup")return l.jsx(mt,{path:e,name:t.name,viewer:r});const u=t.edit!==null&&(t.edit.kind==="inline"||t.edit.kind==="draft");return l.jsx(yi,{path:e,document:t,viewer:r,editing:{editable:u,doubleClick:u&&i==="fill",region:m,paneScroll:f,stale:c}})}case"text":return l.jsx(ro,{document:t,viewer:r});case"image":return n==="markup"&&_t(t)==="svg"?l.jsx(mt,{path:e,name:t.name,viewer:r}):l.jsx(Ra,{document:t});case"media":return l.jsx(Qa,{document:t});case"spreadsheet":return n==="markup"?l.jsx(mt,{path:e,name:t.name,viewer:r}):l.jsx(vi,{path:e,document:t});case"file":return l.jsx(Ys,{document:t});case"failure":return l.jsx(jt,{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)}`)}}},Li='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',Ci=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:Tr(e,n),r===void 0?null:Rr(e,r.id),e.querySelector(Ye),e.querySelector(Li)];for(const s of o)if(s instanceof HTMLElement&&Nt(s))return s;return null},kn=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&Nt(t)},Oi=e=>{const t=d.useRef(!1);return d.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 i=h=>{s=!(h.target instanceof Node&&n.contains(h.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(a),a=setTimeout(()=>{s=!1},0)},m=h=>{t.current=h.target instanceof Node&&n.contains(h.target)},f=h=>{h.relatedTarget===null&&s&&(t.current=!1)},c=()=>{const{activeElement:h,body:w}=r;h!==null&&h!==w&&(t.current=n.contains(h))},u=()=>{s&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",i,!0),o.addEventListener("mousedown",i,!0),o.addEventListener("focusin",m,!0),o.addEventListener("blur",c),o.addEventListener("focus",u),n.addEventListener("focusout",f),()=>{clearTimeout(a),o.removeEventListener("pointerdown",i,!0),o.removeEventListener("mousedown",i,!0),o.removeEventListener("focusin",m,!0),o.removeEventListener("blur",c),o.removeEventListener("focus",u),n.removeEventListener("focusout",f)}},[e]),t},Ai=Object.freeze({count:0,recovered:!1}),Mi=({path:e,snapshot:t,markup:n,stale:r,viewer:o,editLayout:s,regionLabel:a,navigation:i,fragment:m,paneScroll:f,announces:c,announceFailure:u,onDocumentShown:h})=>{const{labels:w,announcer:E,documents:b}=F(),{document:T}=t,O=d.useRef(null),L=d.useRef(null),q=d.useRef(null),j=d.useRef(0),p=Oi(O),g=d.useRef({path:e,document:T}),R=d.useRef(null),N=d.useCallback(z=>{const V=O.current,X=on(V,z,f);V!==null&&X!==null&&kn(V,X,p.current)},[f,p]),I=d.useCallback((z,V)=>{const X=j.current;setTimeout(()=>{!V.defaultPrevented&&j.current===X&&N(z)},0)},[N]),$=d.useCallback(z=>{setTimeout(()=>{z.defaultPrevented||N("#")},0)},[N]),x=d.useMemo(()=>({navigation:i,currentPath:e,scrollWithin:N,followSameUrlJump:I,followEmptyFragment:$}),[i,e,N,I,$]),k=d.useCallback(()=>b.retry(e),[b,e]),A=mr(b,Aa),M=er(e),P=M!==void 0?"edit":n?"markup":"rendered",B=_t(T)===null?void 0:P,G=d.useCallback(()=>O.current,[]),v=d.useMemo(()=>({session:M,layout:s,region:G,paneScroll:f,stale:r}),[M,s,G,f,r]),S=B==="edit"?!1:r,C=d.use(de),D=B==="edit"&&s==="fill"?"fill":C,[U,Z]=d.useState(0),K=d.useRef(0),W=d.useRef(!1),[ne,Ut]=d.useState(Ai),[Ht,Eo]=d.useState(0),zt=d.useRef(u),Vt=d.useRef(r);d.useLayoutEffect(()=>{zt.current=u,Vt.current=r},[u,r]);const xo=d.useMemo(()=>({announceFailure:z=>{Vt.current||zt.current(z)},readPart:()=>{const z=b.readPart(e);K.current+=1;let V=!1,X=!1,Q=!1;return{settle:(fe,me)=>{if(z.settle(fe,me),!(Q||V)){if(me!==null){X=!0,W.current=!1;return}V=!0,Ut(De=>({count:De.count+1,recovered:X}))}},release:()=>{Q||(Q=!0,z.release(),K.current-=1,V||Eo(fe=>fe+1))}}},holdBusy:()=>{Z(V=>V+1);let z=!0;return()=>{z&&(z=!1,Z(V=>V-1))}}}),[b,e]),Zt=S||U>0,bo=d.useEffectEvent((z,V)=>{const X=L.current;if(X!==null&&X.path===z&&X.snapshot===V)return;L.current={path:z,snapshot:V},b.noteShown(z,V);const Q=V.document;if(Q.kind==="failure"){W.current=!1,b.noteFailureShown(V)&&u(w.documentFailed(_.lastPathSegment(z),re(w,Q.failure.reason)));return}h?.(z,Q),!(!c||X!==null&&X.path===z&&X.snapshot.document.kind!=="failure")&&(W.current=K.current>0,W.current||E.announce(w.documentShown(Q.name)))});d.useEffect(()=>{bo(e,t)},[e,t]);const So=d.useEffectEvent(()=>{m.kind==="panel"&&m.consume()}),Wt=d.useEffectEvent(z=>{const V=O.current;if(V===null||!p.current)return null;const{activeElement:X,body:Q}=V.ownerDocument;return X!==null&&X!==Q?null:Ci(V,T,z)}),yo=d.useEffectEvent(z=>{const V=W.current;W.current=!1,!r&&(z&&Wt(null),c&&(z||V)&&T.kind!=="failure"&&E.announce(w.documentShown(T.name)))});d.useEffect(()=>{ne.count>0&&yo(ne.recovered)},[ne]);const ko=d.useEffectEvent(()=>{K.current>0||!W.current||(W.current=!1,c&&!r&&T.kind!=="failure"&&E.announce(w.documentShown(T.name)))});d.useEffect(()=>{Ht>0&&ko()},[Ht]);const Ro=d.useEffectEvent(z=>{const V=O.current;V!==null&&kn(V,z,p.current)}),To=d.useEffectEvent(z=>f.reveal(z)),Lo=d.useEffectEvent(z=>on(O.current,z,f));return d.useEffect(()=>{if(r)return;const z=g.current.path!==e,V=z||g.current.document!==T;g.current={path:e,document:T};const X=R.current!==e;R.current=e;let Q=null;m.kind==="page"?q.current!==m.navigation&&(q.current=m.navigation,j.current+=1,Q=m.fragment):m.fragment!==null&&(Q=m.fragment,So());const fe=()=>{const me=Q===null?null:Lo(Q);if(!V){me!==null&&Ro(me);return}const De=Wt(m.fragment);z&&me===null&&De!==null&&To(De)};X?queueMicrotask(fe):fe()},[m,e,T,r]),l.jsx(de,{value:D,children:l.jsx(ke,{kind:T.kind,view:B,label:a(e,T),stale:Zt,busy:Zt,frameRef:O,intent:A,children:l.jsx(Ar,{value:x,children:l.jsx(Ca,{children:l.jsx(br,{value:xo,children:l.jsx(Ti,{path:e,document:T,view:P,viewer:o,onRetry:k,editing:v},e)})})})})})},Bt=Object.freeze({kind:"skeleton"}),Ni=(e,t,n,r,o)=>{if(t?.status==="loaded")return{kind:"document",path:e,snapshot:t,stale:!1};const s=le(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:le(r);return n===null||a===null?Bt:{kind:"document",path:n,snapshot:a,stale:!0}},Di=(e,t)=>t.status==="deferred"?Bt:{kind:"document",path:e,snapshot:t,stale:!1},ji=({requestedPath:e,content:t,markup:n,...r})=>{const o=t.kind==="streaming"?Di(t.path,d.use(t.promise)):t;return o.kind!=="document"?l.jsx(qt,{label:r.regionLabel(e,null)}):l.jsx(Mi,{path:o.path,snapshot:o.snapshot,markup:n,stale:o.stale,...r})},oo=({path:e,absence:t,markup:n,display:r,navigation:o,fragment:s,paneScroll:a,announces:i,announceFailure:m,onDocumentShown:f})=>{const{config:c,labels:u,locale:h,theme:w,documents:E,data:b}=F(),T=Ee.useMarkdownToolbarState(),O=d.useRef(!1);d.useLayoutEffect(()=>{O.current=!0},[]);const[L,q]=d.useState(null),[j,p]=d.useState(n),g=d.useCallback(()=>e===null?void 0:E.peek(e),[E,e]),R=d.useSyncExternalStore(E.subscribe,g,g),N=d.useCallback(()=>L===null?void 0:E.peek(L),[E,L]),I=d.useSyncExternalStore(E.subscribe,N,N);d.useLayoutEffect(()=>e===null?void 0:E.open(e),[E,e]),d.useLayoutEffect(()=>L===null?void 0:E.retain(L),[E,L]);const $=e===null?Bt:Ni(e,R,L,I,!O.current),x=e===null?null:$.kind==="document"&&!$.stale?$.path:L;x!==L&&q(x);const k=$.kind!=="document"||$.path===e;k&&n!==j&&p(n);const A=d.useMemo(()=>hl(u,h),[u,h]),M=d.useMemo(()=>({read:(C,D)=>Ta(b,C,D)}),[b]),P=d.useMemo(()=>[...c.iframeHosts],[c]),B=o.kind==="panel",G=d.useMemo(()=>({labels:A,spreadsheetLocale:h,spreadsheetTapScrollCircle:Er,emptyMessage:u.documentEmpty,theme:w,availableStyles:c.documentStyles,iFrameAllowedDomains:P,embeds:c.embeds,linkComponent:_a,toolbar:T,style:r.style,onStyleChange:r.onStyleChange,align:r.align,onAlignChange:r.onAlignChange,showToc:r.showToc,showStyle:r.showStyle,showAlign:r.showAlign,padding:r.padding,width:r.width===void 0?void 0:`min(${r.width}, 100%)`,maxWidth:r.maxWidth===void 0?void 0:`min(${r.maxWidth}, 100%)`,renderScrollBar:B?void 0:pr,scrollBarGutter:B?void 0:Dt,imageSource:M}),[A,h,u.documentEmpty,w,c.documentStyles,P,c.embeds,T,r,B,M]),v=d.useCallback((C,D)=>B?D===null||D.kind==="failure"?_.lastPathSegment(C):D.name:u.documentRegion,[B,u.documentRegion]),S=B?"content":"fill";return e===null?l.jsx(de,{value:S,children:l.jsx(Si,{absence:t,announces:i,announceFailure:m})}):l.jsx(de,{value:S,children:l.jsx(d.Suspense,{fallback:l.jsx(qt,{label:v(e,null)}),children:l.jsx(ji,{requestedPath:e,content:$,markup:k?n:j,viewer:G,editLayout:r.editLayout,regionLabel:v,navigation:o,fragment:s,paneScroll:a,announces:i,announceFailure:m,onDocumentShown:f})})})},Pi=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:a,announcer:i}=F(),m=Re(I=>I.style),f=Re(I=>I.align),c=Oe(),u=te.useLocation(),h=Ke(),{view:w,overrides:E,embed:b}=r,T=d.useCallback(I=>{if(h.kind!=="location")return;const $=bi(s,h.location,I);$!==null&&c($,"browse")},[s,c,h]),O=d.useCallback(I=>{a.update({style:I}),T("style")},[a,T]),L=d.useCallback(I=>{a.update({align:I}),T("align")},[a,T]),q=Br(s,E.style,m),j=Ur(E.align,f),p=d.useMemo(()=>({style:q,onStyleChange:O,align:j,onAlignChange:L,showToc:b.showToc!==!1,showStyle:b.showStyle!==!1,showAlign:b.showAlign!==!1,padding:b.padding,width:b.width,maxWidth:b.maxWidth,editLayout:"fill"}),[q,O,j,L,b]),g=d.useMemo(()=>({kind:"page",view:w,overrides:E,embed:b}),[w,E,b]),R=d.useMemo(()=>({kind:"page",fragment:u.hash,navigation:u}),[u]),N=d.useCallback(I=>i.announce(I),[i]);return l.jsx(oo,{path:e,absence:t,markup:n,display:p,navigation:g,fragment:R,paneScroll:ia,announces:!0,announceFailure:N,onDocumentShown:o})},_i=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:a}=F(),i=Re(g=>g.style),m=Re(g=>g.align),[f,c]=d.useState(()=>Br(s,void 0,i)),u=Ur(void 0,m),h=d.useCallback(g=>a.update({align:g}),[a]),{maximized:w,onDocumentLink:E,pendingHash:b,onHashConsumed:T,announceFailure:O,paneScroll:L}=r,q=d.useMemo(()=>({style:f,onStyleChange:c,align:u,onAlignChange:h,showToc:w,showStyle:w,showAlign:w,padding:void 0,width:void 0,maxWidth:void 0,editLayout:w?"fill":"content"}),[f,u,h,w]),j=d.useMemo(()=>({kind:"panel",onDocumentLink:E}),[E]),p=d.useMemo(()=>({kind:"panel",fragment:b,consume:T}),[b,T]);return l.jsx(oo,{path:e,absence:t,markup:n,display:q,navigation:j,fragment:p,paneScroll:L,announces:!1,announceFailure:O,onDocumentShown:o})},so=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>r.kind==="page"?l.jsx(Pi,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o}):l.jsx(_i,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o});function Ii({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M4.755 10.059a7.5 7.5 0 0 1 12.548-3.364l1.903 1.903h-3.183a.75.75 0 1 0 0 1.5h4.992a.75.75 0 0 0 .75-.75V4.356a.75.75 0 0 0-1.5 0v3.18l-1.9-1.9A9 9 0 0 0 3.306 9.67a.75.75 0 1 0 1.45.388Zm15.408 3.352a.75.75 0 0 0-.919.53 7.5 7.5 0 0 1-12.548 3.364l-1.902-1.903h3.183a.75.75 0 0 0 0-1.5H2.984a.75.75 0 0 0-.75.75v4.992a.75.75 0 0 0 1.5 0v-3.18l1.9 1.9a9 9 0 0 0 15.059-4.035.75.75 0 0 0-.53-.918Z",clipRule:"evenodd"}))}const ao=y.forwardRef(Ii);function Fi({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M14.447 3.026a.75.75 0 0 1 .527.921l-4.5 16.5a.75.75 0 0 1-1.448-.394l4.5-16.5a.75.75 0 0 1 .921-.527ZM16.72 6.22a.75.75 0 0 1 1.06 0l5.25 5.25a.75.75 0 0 1 0 1.06l-5.25 5.25a.75.75 0 1 1-1.06-1.06L21.44 12l-4.72-4.72a.75.75 0 0 1 0-1.06Zm-9.44 0a.75.75 0 0 1 0 1.06L2.56 12l4.72 4.72a.75.75 0 0 1-1.06 1.06L.97 12.53a.75.75 0 0 1 0-1.06l5.25-5.25a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const lo=y.forwardRef(Fi);function $i({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M15.75 2.25H21a.75.75 0 0 1 .75.75v5.25a.75.75 0 0 1-1.5 0V4.81L8.03 17.03a.75.75 0 0 1-1.06-1.06L19.19 3.75h-3.44a.75.75 0 0 1 0-1.5Zm-10.5 4.5a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h10.5a1.5 1.5 0 0 0 1.5-1.5V10.5a.75.75 0 0 1 1.5 0v8.25a3 3 0 0 1-3 3H5.25a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h8.25a.75.75 0 0 1 0 1.5H5.25Z",clipRule:"evenodd"}))}const qi=y.forwardRef($i);function Bi({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M11.47 13.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 0 0-1.06-1.06L12 11.69 5.03 4.72a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",clipRule:"evenodd"}),y.createElement("path",{fillRule:"evenodd",d:"M11.47 19.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 1 0-1.06-1.06L12 17.69l-6.97-6.97a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",clipRule:"evenodd"}))}const Ui=y.forwardRef(Bi);function Hi({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25ZM12.75 6a.75.75 0 0 0-1.5 0v6c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-3.75V6Z",clipRule:"evenodd"}))}const zi=y.forwardRef(Hi);function Vi({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{fillRule:"evenodd",d:"M9 1.5H5.625c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5Zm6.61 10.936a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 14.47a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",clipRule:"evenodd"}),y.createElement("path",{d:"M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"}))}const Zi=y.forwardRef(Vi);function Wi({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),y.createElement("path",{fillRule:"evenodd",d:"M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 0 1 0-1.113ZM17.25 12a5.25 5.25 0 1 1-10.5 0 5.25 5.25 0 0 1 10.5 0Z",clipRule:"evenodd"}))}const io=y.forwardRef(Wi);function Gi({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M21.731 2.269a2.625 2.625 0 0 0-3.712 0l-1.157 1.157 3.712 3.712 1.157-1.157a2.625 2.625 0 0 0 0-3.712ZM19.513 8.199l-3.712-3.712-8.4 8.4a5.25 5.25 0 0 0-1.32 2.214l-.8 2.685a.75.75 0 0 0 .933.933l2.685-.8a5.25 5.25 0 0 0 2.214-1.32l8.4-8.4Z"}),y.createElement("path",{d:"M5.25 5.25a3 3 0 0 0-3 3v10.5a3 3 0 0 0 3 3h10.5a3 3 0 0 0 3-3V13.5a.75.75 0 0 0-1.5 0v5.25a1.5 1.5 0 0 1-1.5 1.5H5.25a1.5 1.5 0 0 1-1.5-1.5V8.25a1.5 1.5 0 0 1 1.5-1.5h5.25a.75.75 0 0 0 0-1.5H5.25Z"}))}const Ki=y.forwardRef(Gi);function Xi({title:e,titleId:t,...n},r){return y.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?y.createElement("title",{id:t},e):null,y.createElement("path",{d:"M15 3.75H9v16.5h6V3.75ZM16.5 20.25h3.375c1.035 0 1.875-.84 1.875-1.875V5.625c0-1.036-.84-1.875-1.875-1.875H16.5v16.5ZM4.125 3.75H7.5v16.5H4.125a1.875 1.875 0 0 1-1.875-1.875V5.625c0-1.036.84-1.875 1.875-1.875Z"}))}const Yi=y.forwardRef(Xi),co=({href:e,onRetry:t,testId:n})=>{const{labels:r,onEditGrant:o}=F(),[s,a]=d.useState(!1),i=()=>{o===void 0||s||(a(!0),o(e).then(m=>{m&&t()}).finally(()=>a(!1)))};return l.jsxs("div",{className:"aqmx-callout aqmx-edit-grant","data-testid":n,children:[l.jsx("p",{className:"aqmx-callout-title",children:r.editGrantTitle}),l.jsx("p",{className:"aqmx-callout-body",children:r.editGrantBody}),l.jsxs("div",{className:"aqmx-edit-grant-actions",children:[o===void 0?l.jsx("a",{className:"aqmx-callout-action",href:e,target:"_blank",rel:"noopener","data-testid":`${n}-open`,children:r.editGrantAction}):l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":s,"data-testid":`${n}-open`,onClick:i,children:r.editGrantAction}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":`${n}-retry`,onClick:t,children:r.editGrantRetry})]})]})},Qi="Control+E Meta+E",uo=(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)},Ji=e=>e==="split"?null:e,fo=e=>e==="preview"?"editor":"preview",mo=e=>/Mac|iPhone|iPad|iPod/u.test(e),ho=(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)},Rn=(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)},ec=({path:e,documentName:t,open:n,onClose:r})=>{const{data:o,edits:s,labels:a,locale:i,announcer:m}=F(),f=d.useId(),[c,u]=d.useState(null),[h,w]=d.useState(0),[E,b]=d.useState(null),[T,O]=d.useState(null),L=d.useMemo(()=>new Intl.DateTimeFormat(i,{dateStyle:"medium",timeStyle:"short"}),[i]),q=d.useCallback(()=>{b(null),O(null)},[]),j=Kn({open:n,onOpen:q,onDismiss:r});d.useEffect(()=>{if(!n)return;const R=new AbortController;return u(null),o.revisions(e,R.signal).then(N=>{"kind"in N&&u(N)}),()=>R.abort()},[n,o,e,h]),d.useEffect(()=>{if(!n||E===null)return;const R=new AbortController;return O(null),o.revision(e,E,R.signal).then(N=>{"kind"in N&&O(N)}),()=>R.abort()},[n,o,e,E]);const p=()=>{T===null||T.kind!=="revision"||(s.replaceDraft(e,T.text),m.announce(a.historyRestored(t)),r())},g=c!==null&&c.kind==="revisions"?c.revisions.find(R=>R.id===E):void 0;return l.jsx("dialog",{...j,className:"aqmx-confirm aqmx-history","aria-labelledby":f,"data-testid":"markdown-explorer-history",children:l.jsxs("div",{className:"aqmx-confirm-panel aqmx-history-panel",children:[l.jsx("p",{id:f,className:"aqmx-confirm-title",children:a.historyTitle(t)}),c===null?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-loading",children:a.historyLoading}):c.kind==="failure"?l.jsx(ce,{failure:c.failure,alert:!1,onRetry:()=>w(R=>R+1),testId:"markdown-explorer-history-failure"}):c.revisions.length===0?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-empty",children:a.historyEmpty}):l.jsx("ul",{className:"aqmx-history-list","data-testid":"markdown-explorer-history-list",children:c.revisions.map(R=>l.jsx("li",{children:l.jsxs("button",{type:"button",className:"aqmx-history-entry","aria-pressed":R.id===E,"data-testid":"markdown-explorer-history-entry",onClick:()=>b(R.id),children:[l.jsx("span",{children:Rn(R,L,a.historyEntry)}),R.current?l.jsx("span",{className:"aqmx-history-mark",children:a.historyCurrent}):null,R.kept?l.jsx("span",{className:"aqmx-history-mark",children:a.historyKept}):null]})},R.id))}),E===null?null:T===null?l.jsx("p",{className:"aqmx-history-note",children:a.historyLoading}):T.kind==="failure"?l.jsx(ce,{failure:T.failure,alert:!1,testId:"markdown-explorer-history-revision-failure"}):l.jsx("section",{className:"aqmx-history-text",tabIndex:0,"aria-label":g===void 0?a.historyTitle(t):Rn(g,L,a.historyEntry),"data-testid":"markdown-explorer-history-text",children:l.jsx("pre",{children:T.text})}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":"markdown-explorer-history-close",onClick:r,children:a.historyClose}),l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":T===null||T.kind!=="revision","data-testid":"markdown-explorer-history-restore",onClick:p,children:a.historyRestore})]})]})})},tc=e=>{const{documents:t}=F(),n=d.useCallback(()=>t.peek(e),[t,e]),r=d.useCallback(()=>t.peekSeeded(e),[t,e]),o=d.useSyncExternalStore(t.subscribe,n,r),s=le(o)?.document;return s===void 0||s.kind==="failure"?{edit:null,name:_.lastPathSegment(e)}:{edit:s.kind==="markdown"||s.kind==="spreadsheet"?s.edit:null,name:s.name}},ae=e=>{e.stopPropagation()},nc=({path:e,documentName:t,iconOnly:n,previewAvailable:r,draft:o})=>{const{draftConverter:s,edits:a,labels:i}=F(),m=d.useSyncExternalStore(a.subscribe,()=>a.session(e)!==void 0,()=>!1),[f,c]=d.useState(null),u=()=>{if(!m){a.start(e,a.viewAnchor(e));return}a.flush(e);const b=a.session(e);b?.dirty===!0?c(b.save.kind==="draft"?"draft":"unsaved"):a.close(e)},h=()=>{m||(as(),r&&a.sideBySide()&&s?.prepare?.())},w=n?o?i.editDraftDocumentNamed(t):i.editDocumentNamed(t):null,E=o?i.editDraftDocument:i.editDocument;return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:w===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:m?i.closeEditor:w===null?E:w,"aria-label":w===null?void 0:w,"aria-pressed":m,"data-testid":"markdown-explorer-document-edit",onClick:u,onDoubleClick:ae,onPointerEnter:h,onFocus:h,children:[l.jsx(Ki,{"aria-hidden":"true"}),w===null?l.jsx("span",{children:i.editDocumentLabel}):null]}),l.jsx(Xn,{open:f!==null,title:f==="draft"?i.draftDiscardTitle:i.unsavedTitle,body:f==="draft"?i.draftDiscardBody(t):i.unsavedBody(t),confirmLabel:i.unsavedDiscard,cancelLabel:i.unsavedStay,testId:"markdown-explorer-edit-close-confirm",onConfirm:()=>{c(null),a.close(e)},onCancel:()=>c(null)})]})},rc=({href:e,documentName:t,iconOnly:n})=>{const{labels:r}=F(),o=n?r.editExternallyNamed(t):null;return l.jsxs("a",{className:o===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",href:e,target:"_blank",rel:"noopener noreferrer",title:o===null?r.editExternally:o,"aria-label":o===null?void 0:o,"data-testid":"markdown-explorer-document-edit-external",onDoubleClick:ae,children:[l.jsx(qi,{"aria-hidden":"true"}),o===null?l.jsx("span",{children:r.editExternallyLabel}):null]})},oc=({session:e})=>{const{labels:t}=F(),n=Io(t,e);return l.jsx("p",{className:"aqmx-edit-status",title:n===""?void 0:n,"data-testid":"markdown-explorer-edit-status","data-aqmx-save":e.save.kind,children:n})},sc=Object.freeze(["editor","split","preview"]),ac=Object.freeze(["editor","preview"]),lc=Object.freeze({editor:lo,split:Yi,preview:io}),ic=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{draftConverter:s,edits:a,labels:i}=F(),m=nr(),f=uo(r,m,o),c=o?sc:ac,u=d.useId(),h=d.useRef(new Map),w={editor:{label:i.editViewEditor,tooltip:i.editViewEditorTooltip},split:{label:i.editViewSplit,tooltip:i.editViewSplitTooltip},preview:{label:i.editViewPreview,tooltip:i.editViewPreviewTooltip}},E=()=>{a.preparePreview(e),s?.prepare?.()},b=T=>{if(!ho(T.nativeEvent,mo(navigator.platform)))return;Ot(T);const O=fo(f);Rt(a,e,O,o),h.current.get(O)?.focus()};return l.jsx("div",{role:"radiogroup","aria-label":n?i.editViewNamed(t):i.editView,className:"aqmx-edit-view","data-testid":"markdown-explorer-edit-view",onKeyDown:b,children:c.map(T=>{const O=lc[T],{label:L,tooltip:q}=w[T],j=T==="preview"?E:void 0;return l.jsxs("label",{className:n?"aqmx-icon-button":"aqmx-icon-button aqmx-labelled-button",children:[l.jsx("input",{ref:p=>{p===null?h.current.delete(T):h.current.set(T,p)},type:"radio",name:u,value:T,checked:T===f,"aria-label":L,"aria-keyshortcuts":T==="split"?void 0:Qi,title:q,"data-testid":`markdown-explorer-edit-view-${T}`,onChange:()=>Rt(a,e,T,o),onDoubleClick:ae,onPointerEnter:j,onFocus:j}),l.jsx(O,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:L})]},T)})})},cc=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{edits:s,labels:a}=F(),[i,m]=d.useState(!1);if(r.phase.kind!=="editing")return null;const f=r.save.kind==="saving",c=f||!r.dirty,u=()=>{s.flush(e);const w=s.session(e);w===void 0||!w.dirty||w.save.kind==="saving"||s.save(e)},h=w=>n?{className:"aqmx-icon-button","aria-label":w}:{className:"aqmx-icon-button aqmx-labelled-button"};return l.jsxs(l.Fragment,{children:[r.save.kind==="conflicts"?l.jsxs("button",{type:"button",...h(a.conflictNext),title:a.conflictNext,"data-testid":"markdown-explorer-edit-next-conflict",onClick:()=>s.nextConflict(e),onDoubleClick:ae,children:[l.jsx(Ui,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.conflictNext})]}):null,l.jsx(ic,{path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o}),r.history?l.jsxs("button",{type:"button",...h(a.historyOpen),title:a.historyOpen,"aria-haspopup":"dialog","data-testid":"markdown-explorer-edit-history",onClick:()=>m(!0),onDoubleClick:ae,children:[l.jsx(zi,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.historyOpen})]}):null,r.save.kind==="draft"?null:l.jsxs("button",{type:"button",...h(a.saveDraft),title:a.saveDraftTooltip,"aria-disabled":c,"aria-busy":f,"aria-keyshortcuts":"Control+S Meta+S","data-testid":"markdown-explorer-edit-save",onClick:u,onDoubleClick:ae,children:[l.jsx(Zi,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.saveDraft})]}),r.history?l.jsx(ec,{path:e,documentName:t,open:i,onClose:()=>m(!1)}):null]})},dc=({path:e,session:t})=>{const{edits:n}=F();return t.save.kind!=="grant"?null:l.jsx(co,{href:t.save.href,onRetry:()=>{n.save(e)},testId:"markdown-explorer-save-grant"})},uc=new Set,fc=(e,t,n)=>{const{documents:r,announcer:o,labels:s}=F(),a=d.useCallback(()=>r.peek(e),[r,e]),i=d.useCallback(()=>r.peekSeeded(e),[r,e]),m=d.useSyncExternalStore(r.subscribe,a,i),f=d.useCallback(()=>r.answerStampOf(e),[r,e]),c=d.useSyncExternalStore(r.subscribe,f,f),[u]=d.useState(()=>new Set),[h,w]=d.useState(uc),[E,b]=d.useState(null);E!==null&&(E.path!==e||E.markup!==n)&&b(null);const T=d.useRef(null);d.useLayoutEffect(()=>(T.current=e,()=>{T.current=null}),[e]);const O=d.useRef(n);d.useLayoutEffect(()=>{O.current=n},[n]);const L=d.useCallback(()=>{const p=e,g=r.peek(p);u.has(p)||g?.status==="pending"||(u.add(p),w(new Set(u)),b(null),(async()=>{try{const R=await r.refresh(p);if(T.current!==p||R.status==="superseded")return;if(R.status==="failed"){b({path:p,failure:R.failure,stamp:r.answerStampOf(p),markup:O.current}),o.announce(s.documentRefreshFailed(re(s,R.failure.reason)));return}if(R.status==="shown"&&(t||R.failed))return;const N=le(r.peek(p));if(N===null||N.document.kind==="failure")return;o.announce(s.documentRefreshed(N.document.name))}finally{u.delete(p),w(new Set(u))}})())},[e,t,u,r,o,s]),q=h.has(e),j=E!==null&&E.path===e&&E.stamp===c&&E.markup===n?E.failure:null;return{refreshing:q,unavailable:q||m?.status==="pending",failure:j,refresh:L}},mc=(e,t)=>{switch(t){case"markdown":return e.showMarkup;case"svg":return e.showSvgMarkup;case"csv":case"tsv":return e.showSpreadsheetMarkup(t.toUpperCase())}},po=Object.freeze({kind:"page"}),go=({path:e,placement:t,markup:n})=>{const{labels:r}=F(),{refreshing:o,unavailable:s,failure:a,refresh:i}=fc(e,t.kind==="page",n.shown),m=Ja(e),f=tc(e),c=er(e),u=t.kind==="panel"?r.refreshDocumentNamed(t.documentName):null,h=t.kind==="panel"?r.showMarkupNamed(t.documentName):null,w=t.kind==="panel",E=t.kind==="panel"?t.documentName:f.name,b=t.kind==="page"||t.maximized;return l.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar","data-aqmx-editing":c===void 0?void 0:"true",children:[l.jsxs("div",{className:"aqmx-document-refresh-row",children:[c===void 0?null:l.jsx(oc,{session:c}),c===void 0?null:l.jsx(cc,{path:e,documentName:E,iconOnly:w,session:c,previewAvailable:b}),c===void 0&&m!==null?l.jsxs("button",{type:"button",className:h===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:h===null?mc(r,m):h,"aria-label":h===null?void 0:h,"aria-pressed":n.shown,"data-testid":"markdown-explorer-document-markup",onClick:n.toggle,onDoubleClick:ae,children:[l.jsx(lo,{"aria-hidden":"true"}),h===null?l.jsx("span",{children:r.showMarkupLabel}):null]}):null,c!==void 0||f.edit?.kind==="inline"||f.edit?.kind==="draft"?l.jsx(nc,{path:e,documentName:E,iconOnly:w,previewAvailable:b,draft:f.edit?.kind==="draft"}):f.edit?.kind==="external"?l.jsx(rc,{href:f.edit.href,documentName:E,iconOnly:w}):null,c===void 0?l.jsxs("button",{type:"button",className:u===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:u===null?r.refreshDocument:u,"aria-label":u===null?void 0:u,"aria-disabled":s,"aria-busy":o,"data-aqmx-busy":o?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:i,onDoubleClick:ae,children:[l.jsx(ao,{"aria-hidden":"true"}),u===null?l.jsx("span",{children:r.refreshDocumentLabel}):null]}):null]}),c!==void 0||a===null?null:l.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":a.reason,children:r.documentRefreshFailed(re(r,a.reason))}),c===void 0?null:l.jsx(dc,{path:e,session:c})]})},hc=({location:e})=>{const t=e.doc,n=d.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),r=Nr(e);return l.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",...Ue,children:[l.jsx(go,{path:t,placement:po,markup:r}),l.jsx(so,{path:t,absence:no,markup:e.markup,variant:n})]})},wo=({holds:e,testId:t})=>{const{labels:n,announcer:r}=F(),o=d.useId();d.useLayoutEffect(()=>e?r.claim(o):void 0,[e,r,o]);const s=d.useCallback(()=>r.shownIn(o),[r,o]),a=d.useSyncExternalStore(r.subscribe,s,s);return l.jsx("div",{className:"aqmx-sr-only",role:"status","aria-live":"polite","aria-atomic":"true","data-testid":t,children:a.length>1?n.announcementSequence(a):a[0]})},he=Object.freeze([]),pc=e=>{const t=new Set;let n=he,r=[],o=!1;const s=[],a=c=>{n=c;for(const u of[...t])u()},i=()=>s.at(-1)?.region,m=c=>{const u=i();c(),i()!==u&&n!==he&&a(he)},f=()=>{o=!1;const c=r.map(u=>"sentence"in u?u.sentence:u.list(u.items));r=[],a(Object.freeze(c))};return{announce:c=>{if(typeof c=="string")r.push({sentence:c});else{const u=r.find(h=>"list"in h&&h.list===c.list);u!==void 0&&"items"in u?u.items.push(c.item):r.push({list:c.list,items:[c.item]})}o||(o=!0,n!==he&&a(he),e.request(f))},subscribe:c=>(t.add(c),()=>{t.delete(c)}),claim:c=>{const u={region:c};return m(()=>s.push(u)),()=>m(()=>{const h=s.indexOf(u);h!==-1&&s.splice(h,1)})},shownIn:c=>i()===c?n:he}},se=Object.freeze({status:"cancelled"}),Tn=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(_.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return _.failureOf(n,r)},gc=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((c,u)=>globalThis.fetch(c,u)),o=(c,u)=>`${e}/${c}?${new URLSearchParams(u).toString()}`,s=c=>{c.status===401&&t(null);const u=c.headers.get(_.EXPLORER_SCOPE_HEADER);u!==null&&t(u)},a=async(c,u,h,w)=>{let E;try{E=await r(c,{credentials:"same-origin",...u,headers:{Accept:"application/json",...u.headers}})}catch{return w({reason:"failed"})}s(E);let b;try{b=await E.json()}catch{return w({reason:_.failureReasonOfStatus(E.status)})}let T;try{T=h(b)}catch{T=!1}if(T)return b;const O=Tn(b);return w(O!==null?O:{reason:E.status===200?"failed":_.failureReasonOfStatus(E.status)})},i={[_.EXPLORER_PROOF_HEADER]:_.EXPLORER_REFRESH_PROOF},m={[_.EXPLORER_PROOF_HEADER]:_.EXPLORER_EDIT_PROOF,"Content-Type":`${_.EXPLORER_DRAFT_MEDIA_TYPE}; charset=utf-8`},f=async(c,u,h)=>{const w=await a(c,u,h,E=>_.failureDocument(E.reason,E.code));return u.signal.aborted?se:w};return{tree:c=>a(o("tree",{[_.EXPLORER_DATA_QUERY.source]:c}),{method:"GET"},_.isExplorerTreeResult,u=>({status:"error",failure:u})),children:async(c,u,h)=>{const w=await a(o("children",{[_.EXPLORER_DATA_QUERY.source]:c,[_.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:h},_.isExplorerChildrenResult,E=>({status:"error",failure:E}));return h.aborted?se:w},ancestors:async(c,u,h)=>{const w=await a(o("ancestors",{[_.EXPLORER_DATA_QUERY.source]:c,[_.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:h},_.isExplorerAncestorsResult,E=>({status:"error",failure:E}));return h.aborted?se:w},reveal:async(c,u,h)=>{const w=await a(o("reveal",{[_.EXPLORER_DATA_QUERY.source]:c,[_.EXPLORER_DATA_QUERY.path]:u}),{method:"GET",signal:h},_.isExplorerRevealResult,E=>({status:"error",failure:E}));return h.aborted?se:w},document:(c,{refresh:u})=>a(o("document",{[_.EXPLORER_DATA_QUERY.path]:c}),u?{method:"GET",headers:i}:{method:"GET"},_.isExplorerDocument,h=>_.failureDocument(h.reason,h.code)),text:async(c,u)=>{const h=await a(o("text",{[_.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:u},_.isExplorerTextAnswer,w=>_.failureDocument(w.reason,w.code));return u.aborted?se:h},asset:async(c,u)=>{let h;try{h=await r(c,{method:"GET",credentials:"same-origin",signal:u})}catch{return u.aborted?se:{status:"error",failure:{reason:"failed"}}}if(s(h),h.ok)return u.aborted?se:{status:"ok",body:h.body===null?new ReadableStream({start:b=>b.close()}):h.body};let w=null;try{w=await h.json()}catch{}if(u.aborted)return se;const E=Tn(w);return{status:"error",failure:E===null?{reason:_.failureReasonOfStatus(h.status)}:E}},edit:(c,u)=>f(o("edit",{[_.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:u},_.isExplorerEditAnswer),save:(c,u,h,w)=>f(o("save",{[_.EXPLORER_DATA_QUERY.path]:c,[_.EXPLORER_DATA_QUERY.base]:u}),{method:"POST",headers:m,body:h,signal:w},_.isExplorerSaveAnswer),preview:(c,u,h)=>f(o("preview",{[_.EXPLORER_DATA_QUERY.path]:c}),{method:"POST",headers:m,body:u,signal:h},_.isExplorerPreviewAnswer),revisions:(c,u)=>f(o("revisions",{[_.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:u},_.isExplorerRevisionsAnswer),revision:(c,u,h)=>f(o("revision",{[_.EXPLORER_DATA_QUERY.path]:c,[_.EXPLORER_DATA_QUERY.revision]:u}),{method:"GET",signal:h},_.isExplorerRevisionAnswer),refresh:c=>a(o("refresh",{[_.EXPLORER_DATA_QUERY.source]:c}),{method:"POST",headers:i},_.isExplorerTreeResult,u=>({status:"error",failure:u}))}},wc=()=>{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}}},vc=e=>{const t=J.readStorage(e);if(t===null)return H.NO_TREE_SETTING_CHANGES;try{return H.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),H.NO_TREE_SETTING_CHANGES}},Ln=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=vc(e);n={changes:s,settings:H.applyTreeSettingChanges(t,s)}}return n},o=xe();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:a,settings:i}=r(),m=H.recordTreeSettingChange(a,s,H.advanceTreeSetting(i,s)[s],t);return n={changes:m,settings:H.applyTreeSettingChanges(t,m)},o.emit(),J.writeStorage(e,H.serializeTreeSettingChanges(m)),n.settings}}},Ec=Object.freeze({status:"refreshed"}),xc=Object.freeze({status:"superseded"}),Tt=Object.freeze({status:"deferred"}),bc=Yn(Tt),vo=4,Sc=vo-1,Cn=Object.freeze({status:"loading"}),yc=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),kc=e=>{const t=new Map,n=xr(),r=new Map,o=new Map,s=new Map,a=new Map,i=xe(),m=new Set;let f=0,c=0;const u={direct:null,bulk:null},h=new Set;let w=!1,E=0;const b=()=>{E+=1,i.emit()},T=v=>o.get(v)??0,O=v=>{let S=a.get(v);return S===void 0&&(S={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},a.set(v,S)),S},L=(v,S,C)=>{v.inFlight.delete(S),f-=1,C.lane==="bulk"&&(c-=1)},q=v=>{const S=a.get(v);if(S!==void 0){for(const[C,D]of[...S.inFlight])L(S,C,D),D.controller.abort();S.direct.clear(),S.bulk.clear(),S.unclaimed.clear()}},j=v=>{const S=T(v)+1;return o.set(v,S),q(v),S},p=(v,S)=>{const C=Se(v),D={promise:v,opened:S,stale:!1,loadedAt:C?.status==="ok"?C.loadedAt:null};return v.status==="pending"&&v.then(U=>{U.status==="ok"&&(D.loadedAt=U.loadedAt)}),D},g=v=>{let S=r.get(v);return S===void 0&&(S=new Map,r.set(v,S)),S},R=v=>{const S=[...a.keys()],C=u[v],D=C===null?0:S.indexOf(C)+1;for(let U=0;U<S.length;U+=1){const Z=S[(D+U)%S.length],K=Z===void 0?void 0:a.get(Z);if(!(Z===void 0||K===void 0)){for(const W of K[v])if((K.claims.get(W)??0)!==0)return K[v].delete(W),u[v]=Z,{sourceId:Z,path:W}}}return null},N=(v,S,C,D)=>{const U=a.get(v);if(U===void 0||U.inFlight.get(S)!==C)return;L(U,S,C);const Z=(U.claims.get(S)??0)>0,K=g(v);if(D.status==="ok"?K.set(S,{status:"loaded",entries:D.entries}):D.status==="error"&&Z?K.set(S,{status:"failed",failure:D.failure}):K.delete(S),b(),D.status==="error"&&Z){const W={sourceId:v,path:S,failure:D.failure};for(const ne of[...m])ne(W)}$()},I=(v,S,C)=>{const D={controller:new AbortController,lane:C};O(v).inFlight.set(S,D),f+=1,C==="bulk"&&(c+=1),e.children(v,S,D.controller.signal).then(U=>N(v,S,D,U),()=>N(v,S,D,yc))},$=()=>{for(;f<vo;){const v=R("direct");if(v!==null){I(v.sourceId,v.path,"direct");continue}const S=c<Sc?R("bulk"):null;if(S===null)return;I(S.sourceId,S.path,"bulk")}},x=(v,S,C)=>{if(!(S.direct.delete(C)||S.bulk.delete(C))){const U=S.inFlight.get(C);if(U===void 0)return!1;L(S,C,U),U.controller.abort()}return r.get(v)?.delete(C),!0},k=()=>{w=!1;let v=!1;for(const S of h){const C=O(S);for(const D of C.unclaimed)(C.claims.get(D)??0)===0&&x(S,C,D)&&(v=!0);C.unclaimed.clear()}h.clear(),v&&(b(),$())},A=(v,S)=>{t.set(v,p(Te(e.tree(v)),S))},M=(v,S,C)=>{j(v);const D=p(Yn(S),C);return t.set(v,D),r.delete(v),b(),$(),D},P=(v,S,C,D)=>{if(C!==T(v)||t.get(v)!==S)return;const U=Se(S.promise);if(!(D.status!=="ok"||U?.status!=="ok"||S.loadedAt===null||D.loadedAt<=S.loadedAt)){if(ze(U.entries,D.entries)){S.loadedAt=D.loadedAt;return}M(v,D,S.opened)}},B=(v,S)=>{const C=t.get(v);return C!==void 0&&Se(C.promise)?.status===S},G=(v,S)=>{S.stale=!1;const C=T(v);e.tree(v).then(D=>P(v,S,C,D))};return{read:v=>t.get(v)?.promise??bc,open:v=>{const S=n.resumes(v),C=n.hold(v),D=t.get(v);return D===void 0||B(v,"deferred")?(A(v,!0),b()):S||(D.opened&&B(v,"error")?(A(v,!0),b()):(D.opened=!0,D.stale&&B(v,"ok")&&G(v,D))),C},retry:v=>{B(v,"error")&&(A(v,!0),b())},seed:(v,S)=>{const C=S.then(Z=>Z===null?Tt:Z,()=>Tt),D=t.get(v);if(D!==void 0&&B(v,"ok")){const Z=T(v);C.then(K=>P(v,D,Z,K));return}j(v);const U=p(Te(C),D?.opened===!0);t.set(v,U),r.delete(v),$(),C.then(Z=>{t.get(v)===U&&(Z.status==="deferred"&&n.isHeld(v)&&A(v,U.opened),b())})},refresh:async v=>{const S=(s.get(v)??0)+1;s.set(v,S);const C=await e.refresh(v);if(s.get(v)!==S)return xc;if(C.status==="error")return{status:"failed",failure:C.failure};const D=t.get(v);if(!(D!==void 0&&D.loadedAt!==null&&B(v,"ok")&&D.loadedAt>C.loadedAt)){const Z=M(v,C,!0);if(D!==void 0&&D.promise.status==="pending"){const K=T(v);D.promise.then(W=>P(v,Z,K,W))}}for(const[Z,K]of t)Z!==v&&Se(K.promise)?.status==="ok"&&(K.stale=!0);return Ec},children:(v,S)=>r.get(v)?.get(S),claimChildren:(v,S)=>{const C=O(v),D=g(v);let U=!1,Z=!1;for(const[W,ne]of S)C.claims.set(W,(C.claims.get(W)??0)+1),D.get(W)===void 0?(D.set(W,Cn),C[ne].add(W),U=!0,Z=!0):ne==="direct"&&C.bulk.delete(W)&&(C.direct.add(W),Z=!0);U&&b(),Z&&$();let K=!1;return()=>{if(!K){K=!0;for(const W of S.keys()){const ne=(C.claims.get(W)??0)-1;ne>0?C.claims.set(W,ne):(C.claims.delete(W),C.unclaimed.add(W))}h.add(v),!w&&(w=!0,queueMicrotask(k))}}},retryChildren:(v,S)=>{const C=r.get(v);if(C===void 0||C.get(S)?.status!=="failed")return;const D=O(v);if((D.claims.get(S)??0)>0){C.set(S,Cn),D.direct.add(S),b(),$();return}C.delete(S),b()},pendingChildren:v=>{const S=a.get(v);return S===void 0?0:S.direct.size+S.bulk.size+S.inFlight.size},clear:()=>{for(const v of new Set([...t.keys(),...r.keys(),...o.keys(),...a.keys()]))j(v);for(const[v,S]of s)s.set(v,S+1);t.clear(),r.clear(),b()},subscribeChildrenFailures:v=>(m.add(v),()=>{m.delete(v)}),subscribe:i.subscribe,version:()=>E}},Rc=(e,t)=>{let n=e;const r=xe();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},Tc=1;let Ie=0,ie=null;const Lc=()=>{const{documentElement:e,body:t}=document;Ie===0&&(ie={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"),Ie+=1;let n=!1;return()=>{n||(n=!0,Ie-=1,!(Ie>0||ie===null)&&(e.style.overflow=ie.htmlOverflow,t.style.overflow=ie.bodyOverflow,e.style.scrollbarGutter=ie.htmlGutter,t.style.scrollbarGutter=ie.bodyGutter,ie=null))}},Cc=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],On=1,Oc=1e3,An=e=>e.getClientRects().length>0,ht="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.",Ac=e=>{if(!An(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+Tc)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. ${ht}`;if(t.height<On)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. ${ht}`;for(const{selector:r,name:o}of Cc)for(const s of e.querySelectorAll(r)){if(!An(s))continue;const a=s.getBoundingClientRect().height;if(a<On)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. ${ht}`}return null},Mc=e=>{let t=!1,n;const r=()=>{n=void 0;const a=Ac(e);a!==null&&(t=!0,console.error(a))},o=()=>{t||(clearTimeout(n),n=setTimeout(r,Oc))},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)}},Nc=(e,t)=>{d.useEffect(()=>e?Lc():void 0,[e]),d.useEffect(()=>{const n=t.current;if(!(!e||n===null))return Mc(n)},[e,t])},Mn='[data-testid="markdown-explorer-view-switch"]',Dc=[{control:Mn,successors:[Mn,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],jc=e=>{for(const t of Dc){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},Pc=(e,t)=>{const n=d.useRef(null);d.useEffect(()=>{const o=i=>{const m=e.current;n.current=m!==null&&i instanceof Element&&m.contains(i)?jc(i):null},s=i=>o(i.target);o(document.activeElement);const a=i=>{const m=i.target;i.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=d.useRef(t);d.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 f=e.current;if(f===null)return!0;for(const c of o.control.successors)for(const u of f.querySelectorAll(c))if(u!==o.element&&(u.focus({preventScroll:!0}),document.activeElement===u))return!0;return!1};if(s())return;const a=e.current;if(a===null)return;const i=new MutationObserver(()=>{s()&&i.disconnect()});return i.observe(a,{childList:!0,subtree:!0}),()=>i.disconnect()},[t,e])},_c=d.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-C0O1OGi4.cjs")).then(e=>({default:e.TreeLayout}))),Ic=d.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-TXbet9k3.cjs")).then(e=>({default:e.MultiLayout}))),Fc=64,$c={request:e=>{requestAnimationFrame(e)}},Nn=e=>{e.documents.clear(),e.trees.clear()},pt=(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)},qc=(e,t)=>{const[n,r]=d.useState(()=>({overrides:t,locale:e,labels:xt(e,t)}));if(n.locale===e&&Po(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:xt(e,t)};return r(o),o.labels},Bc=(e,t,n)=>{const[r,o]=d.useState(()=>({scope:t,store:Ln(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:Ln(e,n)};return o(s),s.store},gt=(e,t)=>{const[n,r]=d.useState(()=>({scope:e,value:t()}));if(n.scope===e)return n.value;const o={scope:e,value:t()};return r(o),o.value},Uc=()=>pc($c),Dn="on",Hc="off",zc=Object.freeze({kind:"unavailable"}),Vc=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")},Zc=(e,t)=>{const n=le(e.peek(t));return n===null||n.document.kind==="failure"?_.lastPathSegment(t):n.document.name},Wc=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:a,renderTreeFailure:i,lockDocumentScroll:m=!1,onMathDiagnostics:f,onEditGrant:c,draftConverter:u})=>{J.assertStorageNamespace(n),Vc(u);const h=qn(r),w=_o(s),E=qc(h,o),{revalidate:b}=te.useRevalidator(),T=d.useRef(()=>{}),O=te.useHref(t.dataPath),[L]=d.useState(()=>{const C=gc({dataPath:O,onScope:U=>T.current(U)}),D={documents:Os({client:C,capacity:Math.max(Fc,t.multiView.maxPanels*2)}),trees:kc(C)};return pt(D,e),J.syncStorageScope(n,e.scope),{data:C,...D,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(L.aligned.pageData!==e||L.aligned.storageNamespace!==n){const C=L.aligned.pageData;L.aligned.pageData=e,L.aligned.storageNamespace=n,C!==e&&(C.scope!==e.scope?L.aligned.pendingReader=e:pt(L,e)),J.syncStorageScope(n,e.scope)}const q=Bc(J.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);d.useLayoutEffect(()=>{const C=L.aligned.pendingReader;C!==null&&(L.aligned.pendingReader=null,Nn(L),pt(L,C))},[e,L]),d.useLayoutEffect(()=>{let C=!1;return T.current=D=>{D===e.scope||C||(C=!0,D!==null&&(Nn(L),J.clearExplorerStorage(n)),b())},()=>{T.current=()=>{}}},[e,b,L,n]);const j=d.useRef(t.settingsCookie);d.useLayoutEffect(()=>{j.current=t.settingsCookie},[t.settingsCookie]);const[p]=d.useState(()=>Rc(e.settings,C=>{document.cookie=H.viewSettingsCookieString(j.current,C,window.location.protocol==="https:")})),g=gt(e.scope,Uc),R=gt(e.scope,wc),N=d.useRef(E);d.useLayoutEffect(()=>{N.current=E},[E]);const I=gt(e.scope,()=>Ho({data:L.data,conflictLabels:()=>({ours:N.current.conflictOurs,theirs:N.current.conflictTheirs}),onSaveSettled:(C,D)=>{D.kind==="saved"&&L.documents.refresh(C);const U=Fo(N.current,D,Zc(L.documents,C));U!==null&&g.announce(U)},sideBySideSetting:{read:()=>J.readStorage(J.storageKeys(n).editPreview)===Dn,write:C=>J.writeStorage(J.storageKeys(n).editPreview,C?Dn:Hc)},editorShareSetting:{read:()=>Uo(J.readStorage(J.storageKeys(n).editSplit)),write:C=>J.writeStorage(J.storageKeys(n).editSplit,String(C))}})),$=d.useMemo(()=>Te(e.notices.catch(()=>[])),[e.notices]),x=e.sources.map(C=>C.id).join(`
14
14
  `),k=d.useMemo(()=>H.withExplorerSources(t,x.split(`
15
15
  `)),[t,x]),A=d.useRef(f);d.useLayoutEffect(()=>{A.current=f},[f]);const[M]=d.useState(()=>(C,D)=>{A.current?.(C,D)}),P=f===void 0?void 0:M,B=d.useRef(u);d.useLayoutEffect(()=>{B.current=u},[u]);const[G]=d.useState(()=>{let C=!1;return{convert:(D,U)=>{const Z=B.current;return Z===void 0?Promise.resolve(zc):Z.convert(D,U)},prepare:()=>{try{B.current?.prepare?.()}catch(D){if(C)return;C=!0,console.error("[markdown-explorer] the draft converter's prepare threw",D)}}}}),v=u===void 0?void 0:G,S=d.useMemo(()=>({config:k,labels:E,locale:h,theme:w,storageNamespace:n,scope:e.scope,sources:e.sources,notices:$,documents:L.documents,trees:L.trees,data:L.data,viewSettings:p,treeSettings:q,announcer:g,reveals:R,edits:I,onEditGrant:c,draftConverter:v,renderTreeFailure:i,reportMathDiagnostics:P}),[k,E,h,w,n,e.scope,e.sources,$,L,p,q,g,R,I,c,v,i,P]);return l.jsx(Bn,{value:S,children:l.jsx(Kc,{renderFrame:a,lockDocumentScroll:m},e.scope)})},Gc=({ref:e,theme:t,view:n,children:r})=>{const[o]=d.useState(xa);return l.jsx("div",{ref:e,className:"aqmx-root","data-aqmx-theme":t,"data-aqmx-view":n,"data-testid":"markdown-explorer",onKeyDownCapture:o.onKeyDownCapture,onKeyUpCapture:o.onKeyUpCapture,onBlurCapture:o.onBlurCapture,children:r})},Kc=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=F(),o=Ke(),{hash:s}=te.useLocation(),a=Oe(),i=d.useRef(null);Nc(t,i),d.useLayoutEffect(()=>{o.kind==="redirect"&&a(`${o.href}${s}`,"browse")},[o,s,a]);const{location:m}=o,f=m.view;Pc(i,f);const c=m.view==="tree"?l.jsx(d.Suspense,{fallback:l.jsx("section",{className:"aqmx-split-fallback","aria-label":r.explorerRegion,"aria-busy":"true","data-testid":"markdown-explorer-split-loading",...Ue}),children:l.jsx(_c,{location:m})}):m.view==="multi"?l.jsx(d.Suspense,{fallback:l.jsx("section",{className:"aqmx-stage-fallback","aria-label":r.multiRegion,"aria-busy":"true","data-testid":"markdown-explorer-stage-loading",...Ue}),children:l.jsx(Ic,{location:m})}):l.jsx(hc,{location:m}),u=l.jsxs(Gc,{ref:i,theme:n,view:f,children:[c,l.jsx(rs,{}),l.jsx(wo,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?u:e({view:f,children:u})},Xc=Oo.createShouldRevalidate({submissions:"skip",otherPath:"skip",query:"skip",hashChange:"skip"});exports.ALLOW_KEY_REPEAT=We;exports.CONFLICT_OURS_MARKER=Hn;exports.CONFLICT_SEPARATOR=zn;exports.CONFLICT_THEIRS_MARKER=Vn;exports.CONTENT_PANE=Ue;exports.ContentSkeleton=ue;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=jn;exports.DocumentPane=so;exports.DocumentRefreshBar=go;exports.EXPLORER_THEMES=bt;exports.EditGrantNotice=co;exports.ExplorerLink=fr;exports.FOLDER_README_LOADING=Qn;exports.FailureView=ce;exports.ForwardRef=ao;exports.ForwardRef$1=io;exports.ImageViewMemoryContext=Or;exports.LazyNativeScrollBar=hr;exports.LiveRegion=wo;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=$n;exports.MARKDOWN_EXPLORER_LABEL_KEYS=Ct;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=In;exports.MARKDOWN_EXPLORER_LOCALES=Et;exports.MarkdownExplorer=Wc;exports.NATIVE_SCROLL_BAR_WIDTH=bs;exports.NEAREST=Ze;exports.NO_DOCUMENT=no;exports.PAGE_DOCUMENT_REFRESH=po;exports.TAP_SCROLL_CIRCLE_GUTTER=Dt;exports.TAP_SCROLL_CIRCLE_OFFSET_X=Ss;exports.TAP_SCROLL_CIRCLE_SIZE=Xe;exports.TAP_SCROLL_CIRCLE_SPEED_RANGE=wr;exports.alignToStart=Lr;exports.anchorOfDoubleClick=ar;exports.anchorOfView=lr;exports.blockAtLine=dr;exports.chooseEditView=Rt;exports.consumeKey=Ot;exports.createEmitter=xe;exports.cssPixels=Wn;exports.editViewOf=uo;exports.explorerNavigationOptions=vs;exports.failureTitleOf=re;exports.findConflictsInLines=Zn;exports.focusWithoutScroll=Nt;exports.frameTopOf=ir;exports.isApplePlatform=mo;exports.isEditViewShortcut=ho;exports.isEditingDoubleClick=sr;exports.isInFullscreenBlock=cs;exports.keepInView=yr;exports.lineTopIn=ur;exports.loadedOf=le;exports.paneShownAlone=Ji;exports.positionInSource=gs;exports.readFolderReadme=Jn;exports.resolveMarkdownExplorerLabels=xt;exports.shouldRevalidateExplorer=Xc;exports.stopKeepingInView=Sr;exports.toggledEditView=fo;exports.useExplorer=F;exports.useExplorerLocation=Ke;exports.useExplorerNavigate=Oe;exports.useIntentPrefetch=mr;exports.usePageMarkupToggle=Nr;exports.useSideBySide=nr;exports.useViewSetting=Re;exports.visibleTopOf=cr;