@aiquants/markdown-explorer 0.35.0 → 0.36.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 (81) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +31 -2
  3. package/dist/{EditSurface-CLG70Vnn.cjs → EditSurface-B70iRFkG.cjs} +1 -1
  4. package/dist/{EditSurface-D2j1kCEE.js → EditSurface-BCFJRyIM.js} +5 -5
  5. package/dist/{ExplorerSplit-D_0VohOv.cjs → ExplorerSplit-BNrHrIus.cjs} +1 -1
  6. package/dist/{ExplorerSplit-CfP1smbT.js → ExplorerSplit-Bgccz2nm.js} +77 -77
  7. package/dist/{MultiLayout-CxV5SI7f.cjs → MultiLayout-Bo9LAXiY.cjs} +1 -1
  8. package/dist/{MultiLayout-BeJ5Lubb.js → MultiLayout-Dy5TIC2t.js} +4 -4
  9. package/dist/{NativeScrollBar-RWXpVhbI.cjs → NativeScrollBar-Bj-LKej0.cjs} +1 -1
  10. package/dist/{NativeScrollBar-BM5NULzg.js → NativeScrollBar-DpZMYhmf.js} +2 -2
  11. package/dist/TreeLayout-DsSKW_Qj.js +103 -0
  12. package/dist/TreeLayout-T8sc_wg7.cjs +1 -0
  13. package/dist/core/config.d.cts +6 -0
  14. package/dist/core/config.d.ts +6 -0
  15. package/dist/core/contracts.d.cts +21 -0
  16. package/dist/core/contracts.d.ts +21 -0
  17. package/dist/core/dataRoute.d.cts +5 -1
  18. package/dist/core/dataRoute.d.ts +5 -1
  19. package/dist/core/documentId.d.cts +6 -0
  20. package/dist/core/documentId.d.ts +6 -0
  21. package/dist/core/labels.d.cts +10 -0
  22. package/dist/core/labels.d.ts +10 -0
  23. package/dist/core/location.d.cts +21 -0
  24. package/dist/core/location.d.ts +21 -0
  25. package/dist/explorerCore-B3RGmMG6.js +1083 -0
  26. package/dist/explorerCore-CUkyKtm8.cjs +1 -0
  27. package/dist/{index-C1YMH-yI.js → index-D0l_BJqb.js} +2536 -2372
  28. package/dist/index-lpL7GltU.cjs +18 -0
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.d.cts +2 -1
  31. package/dist/index.d.ts +2 -1
  32. package/dist/index.js +38 -33
  33. package/dist/location-Dh6K-y7w.js +761 -0
  34. package/dist/location-DrOP6t1F.cjs +1 -0
  35. package/dist/{merge-Bb_HpPhe.js → merge-BwcqBd4c.js} +1 -1
  36. package/dist/{merge-DQUYEGCx.cjs → merge-Dckw7r9T.cjs} +1 -1
  37. package/dist/ownUrls-BTPGNhBt.cjs +1 -0
  38. package/dist/ownUrls-DD0cSCsF.js +409 -0
  39. package/dist/{sanitizeJob-BYRk17nr.js → sanitizeJob-BYqzjFJC.js} +1 -1
  40. package/dist/{sanitizeJob-Cs9o3Vpl.cjs → sanitizeJob-CudE1RUP.cjs} +1 -1
  41. package/dist/{sanitizePolicy-CiQfnxyd.cjs → sanitizePolicy-C-ehd0J_.cjs} +1 -1
  42. package/dist/{sanitizePolicy-CEMdaLUB.js → sanitizePolicy-DAPnUUVm.js} +1 -1
  43. package/dist/sanitizeWorker.cjs +1 -1
  44. package/dist/sanitizeWorker.js +3 -3
  45. package/dist/{sanitizerService-KWXv7bPm.js → sanitizerService-B8v4ap9t.js} +1 -1
  46. package/dist/{sanitizerService-BY4CPCoA.cjs → sanitizerService-DomN7lwC.cjs} +1 -1
  47. package/dist/server/errors.d.cts +1 -1
  48. package/dist/server/errors.d.ts +1 -1
  49. package/dist/server/ports.d.cts +19 -0
  50. package/dist/server/ports.d.ts +19 -0
  51. package/dist/server.cjs +1 -1
  52. package/dist/server.d.cts +1 -1
  53. package/dist/server.d.ts +1 -1
  54. package/dist/server.js +6 -6
  55. package/dist/serverBrowser.cjs +1 -1
  56. package/dist/serverBrowser.js +3 -3
  57. package/dist/serverCore.cjs +1 -1
  58. package/dist/serverCore.d.cts +1 -1
  59. package/dist/serverCore.d.ts +1 -1
  60. package/dist/serverCore.js +4 -4
  61. package/dist/{tapScrollCircle-DdX0Wri0.cjs → tapScrollCircle-DyLInGck.cjs} +1 -1
  62. package/dist/{tapScrollCircle-BEydRn0y.js → tapScrollCircle-smKLgRa2.js} +1 -1
  63. package/dist/testing.cjs +1 -1
  64. package/dist/testing.d.cts +5 -0
  65. package/dist/testing.d.ts +5 -0
  66. package/dist/testing.js +80 -2
  67. package/dist/{useSplitPersistence-B2Fj508K.cjs → useSplitPersistence-BUa_KMsV.cjs} +1 -1
  68. package/dist/{useSplitPersistence-Fkqak8G8.js → useSplitPersistence-pnb21dsr.js} +1 -1
  69. package/docs/behavior/dom-hooks.md +3 -1
  70. package/docs/behavior/security.md +23 -2
  71. package/docs/behavior/url-contract.md +26 -0
  72. package/package.json +2 -2
  73. package/dist/TreeLayout-AxLw-36S.js +0 -103
  74. package/dist/TreeLayout-Bg2YH-EY.cjs +0 -1
  75. package/dist/explorerCore-DLpDuSev.js +0 -998
  76. package/dist/explorerCore-DYrxS9ez.cjs +0 -1
  77. package/dist/index-LQWQfpAf.cjs +0 -18
  78. package/dist/location--KvTA0Ri.js +0 -726
  79. package/dist/location-D8DyDkuA.cjs +0 -1
  80. package/dist/ownUrls-B259RGgd.cjs +0 -1
  81. package/dist/ownUrls-Dh5g6ZJi.js +0 -370
@@ -0,0 +1,18 @@
1
+ /*! Bundled third-party code: @heroicons/react 2.2.0 (MIT, ./licenses/@heroicons/react/LICENSE) */
2
+ "use strict";const z=require("./describeValue-Ccvhbt36.cjs"),l=require("react/jsx-runtime"),c=require("react"),re=require("react-router"),V=require("./location-DrOP6t1F.cjs"),Ae=require("@aiquants/markdown/code-blocks"),P=require("./ownUrls-BTPGNhBt.cjs"),De=require("@aiquants/markdown"),Vt=require("@aiquants/markdown/source-lines"),zt=require("@aiquants/spreadsheet/tsv"),xn=require("@aiquants/spreadsheet/view"),ds=require("@aiquants/markdown/viewer-settings"),ae=require("./storage-BpYsprog.cjs"),Mt=require("@aiquants/markdown/converter"),us=require("@aiquants/route-revalidation");function fs(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 R=fs(c),fr=Object.freeze(["reload","notify"]),mr=Object.freeze(["signed-in","signed-out"]),ms=Object.freeze([`
3
+ `,`\r
4
+ `]),hs=Object.freeze(["fetch","persistSettings","subscribeHostChanges","onReload","onSessionEnded","onDraftChange"]),ps=Object.freeze(["guardUnload","confirmUnversionedSaves"]),bn=(e,t,n)=>{if(!(t===void 0||typeof t=="string"&&n.includes(t)))throw new RangeError(`[markdown-explorer] ${e} must be ${n.map(z.describeValue).join(" or ")}; got ${z.describeValue(t)}`)},ws=e=>{for(const n of hs){const r=e[n];if(r!==void 0&&typeof r!="function")throw new TypeError(`[markdown-explorer] ${n} must be a function; got ${z.describeValue(r)}`)}for(const n of ps){const r=e[n];if(r!==void 0&&typeof r!="boolean")throw new TypeError(`[markdown-explorer] ${n} must be a boolean; got ${z.describeValue(r)}`)}bn("hostChangePolicy",e.hostChangePolicy,fr),bn("accountState",e.accountState,mr);const{paletteKey:t}=e;if(t!==void 0){if(typeof t!="string")throw new TypeError(`[markdown-explorer] paletteKey must be a non-empty string; got ${z.describeValue(t)}`);if(t==="")throw new RangeError("[markdown-explorer] paletteKey must be a non-empty string; got an empty string")}},Gt=(e,t)=>{if(!Array.isArray(t))throw new TypeError(`[markdown-explorer] ${e} must be an array of strings; got ${z.describeValue(t)}`);for(const n of t){if(typeof n!="string")throw new TypeError(`[markdown-explorer] ${e} must hold strings only; got ${z.describeValue(n)}`);if(n==="")throw new RangeError(`[markdown-explorer] ${e} must hold non-empty strings; got an empty string`)}},gs=(e,t)=>{Gt(`${e}'s paths`,t)},vs=e=>{if(!z.isPlainObject(e))throw new TypeError(`[markdown-explorer] a host change must be a plain object; got ${z.describeValue(e)}`);Gt("a host change's sourceIds",e.sourceIds),Gt("a host change's paths",e.paths)},kn=(e,t)=>{if(typeof t!="string")throw new TypeError(`[markdown-explorer] restoreDrafts takes ${e} as a string; got ${z.describeValue(t)}`);if(t.includes("\r"))throw new RangeError(`[markdown-explorer] restoreDrafts takes ${e} with its lines ending in "\\n" alone; got a text with "\\r"`)},Es=e=>{if(!Array.isArray(e))throw new TypeError(`[markdown-explorer] restoreDrafts takes an array of drafts; got ${z.describeValue(e)}`);const t=new Set;for(const n of e){if(!z.isPlainObject(n))throw new TypeError(`[markdown-explorer] restoreDrafts takes each draft as a plain object; got ${z.describeValue(n)}`);const{path:r,base:o,lineEnding:s}=n;if(typeof r!="string")throw new TypeError(`[markdown-explorer] restoreDrafts takes a draft's path as a string; got ${z.describeValue(r)}`);if(r==="")throw new RangeError("[markdown-explorer] restoreDrafts takes non-empty paths; got an empty string");if(t.has(r))throw new RangeError(`[markdown-explorer] restoreDrafts takes one draft per path; got ${z.describeValue(r)} twice`);if(t.add(r),!z.isPlainObject(o))throw new TypeError(`[markdown-explorer] restoreDrafts takes a draft's base as a plain object; got ${z.describeValue(o)}`);if(kn("base.text",o.text),o.version!==null&&typeof o.version!="string")throw new TypeError(`[markdown-explorer] restoreDrafts takes base.version as a string or null; got ${z.describeValue(o.version)}`);if(kn("draft",n.draft),!ms.includes(s))throw new RangeError(`[markdown-explorer] restoreDrafts takes lineEnding as "\\n" or "\\r\\n"; got ${z.describeValue(s)}`)}},ys=e=>{if(typeof e!="string")throw new TypeError(`[markdown-explorer] announce takes a string; got ${z.describeValue(e)}`);if(e==="")throw new RangeError("[markdown-explorer] announce takes a non-empty string; got an empty string")},xs=e=>{if(!z.isPlainObject(e))throw new TypeError(`[markdown-explorer] reportMediaFailure takes a plain object; got ${z.describeValue(e)}`);const{url:t,final:n}=e;if(typeof t!="string")throw new TypeError(`[markdown-explorer] reportMediaFailure takes url as a string; got ${z.describeValue(t)}`);if(t==="")throw new RangeError("[markdown-explorer] reportMediaFailure takes a non-empty url; got an empty string");if(typeof n!="boolean")throw new TypeError(`[markdown-explorer] reportMediaFailure takes final as a boolean; got ${z.describeValue(n)}`)},Zt=Object.freeze(["en","ja"]),hr="en",nn=e=>`viewerSpreadsheet${e.charAt(0).toUpperCase()}${e.slice(1)}`,pr=Object.freeze(Object.keys(Ae.SPREADSHEET_BLOCK_LABEL_CATALOGS.en)),wr=e=>Object.fromEntries(pr.map(t=>[nn(t),Ae.SPREADSHEET_BLOCK_LABEL_CATALOGS[e][t].text])),gr=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"]),panelGroupMinimumExceededDetail:Object.freeze(["required","available"]),panelGroupMaximumInsufficientDetail:Object.freeze(["total","needed"]),viewerSvgImageSourceRegion:Object.freeze(["name"]),viewerSvgImageFullscreenDialog:Object.freeze(["name"]),...Object.fromEntries(pr.filter(e=>Ae.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e].length>0).map(e=>[nn(e),Ae.SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS[e]]))}),bs=/\{(\w+)\}|[{}]/gu,vr={...wr("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}`,documentMaximize:"Maximize the document",documentRestore:"Restore the document to its size",documentMaximized:e=>`Maximized ${e}`,documentRestored:e=>`Restored ${e} to its size`,documentRefreshFailed:e=>`Could not reload the document: ${e}`,documentReloadedAfterChange:e=>`Reloaded ${e}, which changed elsewhere`,documentChangedElsewhere:e=>`${e} changed elsewhere`,reload:"Reload",mediaLoadFailed:e=>`Could not load ${e}`,mediaLoadFailedCount:e=>`Could not load ${e} media files`,mediaUnplayable:e=>`Cannot play ${e}`,mediaUnplayableCount:e=>`Cannot play ${e} media files`,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",unversionedSaveTitle:"Save without keeping the previous version?",unversionedSaveBody:"This source does not keep previous versions. Once saved, the previous content cannot be restored.",unversionedSaveConfirm:"Save",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",settingShowFolderReadme:"Show folder READMEs",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.",failureUnauthorizedSignInBody:"Sign in again to continue.",failureUnauthorizedSignedOutBody:"Sign in to open it.",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",signInAgain:"Sign in again",signIn:"Sign in",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",copyPermalinkLabel:"Permalink",copyPermalink:"Copy permalink",copyPermalinkNamed:e=>`Copy the permalink of ${e}`,permalinkCopied:e=>`Copied the permalink (${e})`,permalinkCopyFailed:e=>`Could not copy the permalink: ${e}`,permalinkClipboardRefused:"The browser did not allow the copy",documentIdFailedTitle:"This link's document cannot be opened",documentIdInvalid:"The link's ID is not valid. Check how it was copied.",documentIdNotFound:"No document has this ID. It may have been moved or removed.",documentIdForbidden:"You cannot open this link's document.",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",viewerSelectStyle:"Display options",viewerPinStyle:"Pin display options",viewerUnpinStyle:"Unpin display options",viewerStyleSectionTitle:"Style",viewerMeasureTitle:"Width",viewerColorsTitle:"Colors",viewerMeasureFill:"Full width",viewerMeasureReading:"Reading width",viewerColorsDefault:"Document colors",viewerColorsSepia:"Sepia",viewerColorsDarkLowGlare:"Dark, low glare",viewerColorsHighContrast:"High contrast",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",viewerMermaidLoading:"Loading diagram...",viewerMermaidInitializationFailed:"Mermaid failed to initialize globally.",viewerMermaidRenderFailed:"An unknown error occurred while rendering the diagram.",viewerMermaidEmptyDrawing:"Failed to render Mermaid diagram: SVG content is empty or invalid.",viewerMermaidSource:"Source",viewerMermaidSourceRegion:"Diagram source",viewerMermaidCopySource:"Copy the source",viewerMermaidCopiedSource:"Copied the source.",viewerMermaidCopySourceFailed:"Could not copy the source.",viewerMermaidTypeC4:"C4 diagram",viewerMermaidTypeFlowchart:"Flowchart",viewerMermaidTypeSwimlane:"Swimlane diagram",viewerMermaidTypeEntityRelationship:"Entity relationship diagram",viewerMermaidTypeGitGraph:"Git graph",viewerMermaidTypeGantt:"Gantt chart",viewerMermaidTypeInfo:"Mermaid information",viewerMermaidTypePie:"Pie chart",viewerMermaidTypeQuadrantChart:"Quadrant chart",viewerMermaidTypeXyChart:"XY chart",viewerMermaidTypeRequirement:"Requirement diagram",viewerMermaidTypeSequence:"Sequence diagram",viewerMermaidTypeClass:"Class diagram",viewerMermaidTypeState:"State diagram",viewerMermaidTypeJourney:"User journey",viewerMermaidTypeTimeline:"Timeline",viewerMermaidTypeMindmap:"Mind map",viewerMermaidTypeKanban:"Kanban board",viewerMermaidTypeSankey:"Sankey diagram",viewerMermaidTypePacket:"Packet diagram",viewerMermaidTypeRadar:"Radar chart",viewerMermaidTypeBlock:"Block diagram",viewerMermaidTypeTreeView:"Tree view",viewerMermaidTypeArchitecture:"Architecture diagram",viewerMermaidTypeEventModeling:"Event modeling diagram",viewerMermaidTypeIshikawa:"Ishikawa diagram",viewerMermaidTypeVenn:"Venn diagram",viewerMermaidTypeTreemap:"Treemap",viewerMermaidTypeWardley:"Wardley map",viewerMermaidTypeCynefin:"Cynefin diagram",viewerMermaidTypeRailroad:"Railroad diagram",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)",viewerCodeBlockCopy:"Copy the code",viewerCodeBlockCopied:"Copied the code.",viewerCodeBlockCopyFailed:"Could not copy the code.",viewerDisplayMathCopy:"Copy the formula",viewerDisplayMathCopied:"Copied the formula.",viewerDisplayMathCopyFailed:"Could not copy the formula.",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",panelGroupMinimumExceededSummary:"Layout unavailable: minimum panel sizes exceed the container.",panelGroupMinimumExceededDetail:"Min required: {required}px | Available: {available}px",panelGroupMaximumInsufficientSummary:"Layout unavailable: panels cannot fill the container with their maximum sizes.",panelGroupMaximumInsufficientDetail:"Max total: {total}px | Needed: {needed}px"},ks={...wr("ja"),explorerRegion:"エクスプローラー",sourceLabel:"ソース",refreshTreeLabel:"ツリーを更新",refreshTree:"ソースからツリーと開いている文書を読み込み直す",treeRefreshed:"ツリーをソースから読み込み直しました",treeRefreshFailed:e=>`ツリーを読み込み直せませんでした: ${e}`,refreshDocumentLabel:"文書を更新",refreshDocument:"ソースから文書を読み込み直す",refreshDocumentNamed:e=>`${e} を更新`,documentRefreshed:e=>`${e} を読み込み直しました`,documentMaximize:"文書を最大化",documentRestore:"文書を元のサイズに戻す",documentMaximized:e=>`${e} を最大化しました`,documentRestored:e=>`${e} を元のサイズに戻しました`,documentRefreshFailed:e=>`文書を読み込み直せませんでした: ${e}`,documentReloadedAfterChange:e=>`ほかで変更された ${e} を読み込み直しました`,documentChangedElsewhere:e=>`${e} はほかで変更されました`,reload:"読み込み直す",mediaLoadFailed:e=>`${e} を読み込めませんでした`,mediaLoadFailedCount:e=>`${e} 個の媒体を読み込めませんでした`,mediaUnplayable:e=>`${e} を再生できません`,mediaUnplayableCount: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:"編集を続ける",unversionedSaveTitle:"前の版を残さずに保存しますか?",unversionedSaveBody:"この保存先は前の版を残しません。保存すると前の内容へ戻せません。",unversionedSaveConfirm:"保存する",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:"開いた文書をツリーで表示",settingShowFolderReadme:"フォルダーの README を表示",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:"ページを再読み込みして、もう一度サインインしてください。",failureUnauthorizedSignInBody:"もう一度サインインすると続けられます。",failureUnauthorizedSignedOutBody:"サインインすると開けます。",failureForbiddenTitle:"アクセスが許可されていません",failureForbiddenBody:"これを開く権限がありません。",failureNotFoundTitle:"見つかりません",failureNotFoundBody:"移動または削除された可能性があります。",failureNotConfiguredTitle:"このソースは設定されていません",failureNotConfiguredBody:"管理者に設定を依頼してください。",failureInvalidTitle:"アドレスが正しくありません",failureInvalidBody:"このアドレスに含まれる文書の経路は使えません。",failureTooLargeTitle:"大きすぎて表示できません",failureTooLargeBody:"このファイルは表示できる大きさを超えています。",failureUnsupportedTitle:"表示できない形式です",failureUnsupportedBody:"この種類のファイルはここでは表示できません。",failureFailedTitle:"読み込みに失敗しました",failureFailedBody:"しばらくしてからもう一度お試しください。",retry:"再試行",reloadPage:"ページを再読み込み",signInAgain:"もう一度サインイン",signIn:"サインイン",imageZoomIn:"拡大",imageZoomOut:"縮小",imageFit:"画面に合わせる",imageFitLevel:"全体",imageZoomLevel:e=>`${String(e)}%`,openInNewTab:"新しいタブで開く",download:"ダウンロード",copyText:"テキストをコピー",copiedText:"テキストをコピーしました",copyTextFailed:"テキストをコピーできませんでした",copyPermalinkLabel:"固定リンク",copyPermalink:"固定リンクをコピー",copyPermalinkNamed:e=>`${e} の固定リンクをコピー`,permalinkCopied:e=>`固定リンクをコピーしました (${e})`,permalinkCopyFailed:e=>`固定リンクをコピーできませんでした: ${e}`,permalinkClipboardRefused:"ブラウザがコピーを許しませんでした",documentIdFailedTitle:"このリンクの文書を開けません",documentIdInvalid:"リンクの ID が正しくありません。書き写した ID を確かめてください。",documentIdNotFound:"この ID の文書はありません。移されたか消された可能性があります。",documentIdForbidden:"このリンクの文書を開く権限がありません。",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:"表示の設定のピン留めを解除",viewerStyleSectionTitle:"スタイル",viewerMeasureTitle:"幅",viewerColorsTitle:"配色",viewerMeasureFill:"全幅",viewerMeasureReading:"読みやすい幅",viewerColorsDefault:"文書の配色",viewerColorsSepia:"セピア",viewerColorsDarkLowGlare:"ダーク (まぶしさ控えめ)",viewerColorsHighContrast:"高コントラスト",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:"再試行",viewerMermaidLoading:"図を読み込み中...",viewerMermaidInitializationFailed:"Mermaid を初期化できませんでした。",viewerMermaidRenderFailed:"図の描画中に不明なエラーが発生しました。",viewerMermaidEmptyDrawing:"Mermaid の図を描画できませんでした: SVG の内容が空か不正です。",viewerMermaidSource:"ソース",viewerMermaidSourceRegion:"図のソース",viewerMermaidCopySource:"ソースをコピー",viewerMermaidCopiedSource:"ソースをコピーしました。",viewerMermaidCopySourceFailed:"ソースをコピーできませんでした。",viewerMermaidTypeC4:"C4 の図",viewerMermaidTypeFlowchart:"流れ図",viewerMermaidTypeSwimlane:"スイムレーンの図",viewerMermaidTypeEntityRelationship:"実体関連図",viewerMermaidTypeGitGraph:"Git のグラフ",viewerMermaidTypeGantt:"ガントチャート",viewerMermaidTypeInfo:"Mermaid の情報の図",viewerMermaidTypePie:"円グラフ",viewerMermaidTypeQuadrantChart:"四象限の図",viewerMermaidTypeXyChart:"XY のグラフ",viewerMermaidTypeRequirement:"要求図",viewerMermaidTypeSequence:"シーケンス図",viewerMermaidTypeClass:"クラス図",viewerMermaidTypeState:"状態図",viewerMermaidTypeJourney:"ユーザージャーニーの図",viewerMermaidTypeTimeline:"年表",viewerMermaidTypeMindmap:"マインドマップ",viewerMermaidTypeKanban:"カンバンのボード",viewerMermaidTypeSankey:"サンキー図",viewerMermaidTypePacket:"パケットの図",viewerMermaidTypeRadar:"レーダーチャート",viewerMermaidTypeBlock:"ブロック図",viewerMermaidTypeTreeView:"ツリーの表示",viewerMermaidTypeArchitecture:"アーキテクチャ図",viewerMermaidTypeEventModeling:"イベントモデリングの図",viewerMermaidTypeIshikawa:"特性要因図",viewerMermaidTypeVenn:"ベン図",viewerMermaidTypeTreemap:"ツリーマップ",viewerMermaidTypeWardley:"ワードリーマップ",viewerMermaidTypeCynefin:"クネビンの図",viewerMermaidTypeRailroad:"構文図",viewerEmbeddedVideo:"埋め込みの動画",viewerEmbeddedPost:"埋め込みの投稿",viewerEmbeddedFrame:"埋め込みのコンテンツ",viewerBlockFailed:"このブロックを表示できませんでした。",viewerSvgImageToolbar:"SVG の画像",viewerSvgImageSource:"ソース",viewerSvgImageSourceRegion:"{name} のソース",viewerSvgImageLoading:"ソースを読み込み中…",viewerSvgImageFailed:"ソースを読み込めませんでした。",viewerSvgImageRetry:"再試行",viewerSvgImageTruncated:"このファイルは先頭だけを表示しています。",viewerSvgImageCopy:"ソースをコピー",viewerSvgImageCopied:"ソースをコピーしました。",viewerSvgImageCopyFailed:"ソースをコピーできませんでした。",viewerSvgImageCopyImage:"画像をコピー",viewerSvgImageCopiedImage:"画像をコピーしました。",viewerSvgImageCopyImageFailed:"画像をコピーできませんでした。",viewerSvgImageFullscreen:"全画面で見る",viewerSvgImageExitFullscreen:"全画面を閉じる",viewerSvgImageFullscreenDialog:"{name} (全画面)",viewerCodeBlockCopy:"コードをコピー",viewerCodeBlockCopied:"コードをコピーしました。",viewerCodeBlockCopyFailed:"コードをコピーできませんでした。",viewerDisplayMathCopy:"数式をコピー",viewerDisplayMathCopied:"数式をコピーしました。",viewerDisplayMathCopyFailed:"数式をコピーできませんでした。",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:"ここへパネルをドロップ",panelGroupMinimumExceededSummary:"レイアウトを表示できません: パネルの最小の大きさの合計が枠を超えています。",panelGroupMinimumExceededDetail:"必要な最小: {required}px | 使える長さ: {available}px",panelGroupMaximumInsufficientSummary:"レイアウトを表示できません: パネルを最大の大きさにしても枠を満たせません。",panelGroupMaximumInsufficientDetail:"最大の合計: {total}px | 必要な長さ: {needed}px"},Er=Object.freeze({en:Object.freeze(vr),ja:Object.freeze(ks)}),rn=Object.freeze(Object.keys(vr)),Ss=new Set(rn),Ts=e=>Ss.has(e),yr=e=>{if(e===void 0)return hr;if(Zt.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${Zt.map(z.describeValue).join(" or ")}), not a BCP 47 tag; got ${z.describeValue(e)}`)},Wt=(e,t)=>{const n=Er[yr(e)];if(t===void 0)return n;if(t===null||typeof t!="object")throw new RangeError(`[markdown-explorer] labels must be an object; got ${z.describeValue(t)}`);if(!z.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${z.describeValue(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!Ts(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${rn.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 ${z.describeValue(a)}`);if(typeof a=="string"&&a.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const f=gr[s];if(typeof a=="string"&&f!==void 0){const w=f.map(g=>`{${g}}`).join(", ");for(const g of a.matchAll(bs)){const d=g[1];if(d===void 0)throw new RangeError(`[markdown-explorer] labels.${s} holds a brace outside a placeholder at index ${String(g.index)}; it accepts ${w}, and no other braces`);if(!f.includes(d))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${d}}; it accepts ${w}`)}}o[s]=a}return Object.freeze(o)},Rs=(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]))},Kt=Object.freeze(["light","dark"]),Cs=e=>{if(e===void 0)return"light";if(Kt.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${Kt.map(z.describeValue).join(" or ")}; got ${z.describeValue(e)}`)},Ms=()=>{window.location.reload()},$e=Object.freeze({guardUnload:!0,onReload:Ms,accountState:"signed-in",confirmUnversionedSaves:!1}),xr=c.createContext(null),F=()=>{const e=c.use(xr);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},ge=e=>{const{viewSettings:t}=F(),n=()=>e(t.getSnapshot());return c.useSyncExternalStore(t.subscribe,n,n)},Ke=()=>{const{config:e}=F(),t=re.useParams()["*"],[n]=re.useSearchParams(),r=n.toString();return c.useMemo(()=>V.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])},Ls=()=>{const e=new Map,t=new Set,n=new Set,r=()=>{for(const s of[...n])s()},o=s=>{t.delete(s)&&r()};return{show:s=>{e.set(s,(e.get(s)??0)+1);let a=!1;return()=>{if(a)return;a=!0;const i=(e.get(s)??0)-1;if(i>0){e.set(s,i);return}e.delete(s),o(s)}},shown:s=>e.has(s),mark:s=>{const a=s.filter(i=>e.has(i)&&!t.has(i));for(const i of a)t.add(i);a.length>0&&r()},changed:s=>t.has(s),dismiss:o,subscribe:s=>(n.add(s),()=>{n.delete(s)})}},Os=2,As=1,Ds=2,Ns=3,Ps=4,Sn=Object.freeze(["error","loadstart","progress","stalled"]),Xt=Object.freeze({marked:!1,final:!1,stalled:!1,progress:0,error:null}),ct=Object.freeze([]),_s=e=>e.marked&&e.progress<=Os&&(e.final||e.stalled),js=(e,t)=>e===As?null:t||e===Ds?"media-load":e===Ns||e===Ps?"media-unplayable":null,Is=(e,t)=>{switch(t.kind){case"report":return{...e,marked:!0,final:t.final,progress:0,error:e.error===null?null:"media-load"};case"stalled":return{...e,stalled:!0};case"progress":return{...e,stalled:!1,progress:e.progress+1};case"loadstart":return Xt;case"error":{const n=js(t.code,e.marked);return n===null?e:{...e,error:n}}case"source-error":return{...e,error:e.marked?"media-load":"media-unplayable"}}},Fs=e=>e.error==="media-load"||_s(e)?"media-load":e.error,Tn=(e,t,n)=>{if(e===""||t===""||!URL.canParse(e,n)||!URL.canParse(t,n))return!1;const r=new URL(e,n),o=new URL(t,n);return r.hash="",o.hash="",r.href===o.href},$s=(e,t)=>{if(!URL.canParse(e,t))return e;const n=new URL(e,t),r=n.searchParams.get(P.EXPLORER_DATA_QUERY.path);return P.lastPathSegment(r===null?n.pathname:r)},qs=e=>{for(let t=e.nextElementSibling;t!==null;t=t.nextElementSibling)if(t instanceof HTMLSourceElement)return!1;return!0},Bs=e=>{const{target:t,type:n}=e;if(t instanceof HTMLSourceElement){const r=t.parentElement;return n==="error"&&r instanceof HTMLMediaElement&&qs(t)?{element:r,arrival:{kind:"source-error"},url:t.src}:null}return t instanceof HTMLMediaElement?n==="error"?{element:t,arrival:{kind:"error",code:t.error===null?null:t.error.code},url:t.currentSrc}:n==="stalled"||n==="progress"||n==="loadstart"?{element:t,arrival:{kind:n},url:t.currentSrc}:null:null},Us=()=>{const e=new WeakMap,t=new Map,n=new Map,r=new WeakMap,o=new Map,s=new Set;let a=ct,i=null;const f=(h,v,E)=>{if(v===null){o.delete(h);return}o.get(h)?.kind!==v&&o.set(h,{kind:v,target:h,url:E,name:$s(E,document.baseURI)})},w=h=>{for(const b of[...o.keys()])b.isConnected||o.delete(b);const v=[...o.values()],E=v.length===a.length&&v.every((b,k)=>b===a[k]);if(E||(a=Object.freeze(v)),!(E&&!h))for(const b of[...s])b()},g=(h,v,E)=>{const b=Is(e.get(h)??Xt,v);e.set(h,b),f(h,Fs(b),E)},d=h=>{const v=Bs(h);v!==null&&(g(v.element,v.arrival,v.url),w(!1))},p=h=>{const v=h.ended?0:h.currentTime,E=!h.paused,b=r.get(h);b!==void 0&&h.removeEventListener("loadedmetadata",b);const k=()=>{r.delete(h),h.currentTime=v,E&&h.play().catch(()=>{})};r.set(h,k),h.addEventListener("loadedmetadata",k,{once:!0}),h.load()};return{observe:h=>{i=h;for(const v of Sn)h.addEventListener(v,d,!0);return()=>{for(const v of Sn)h.removeEventListener(v,d,!0);i===h&&(i=null)}},report:h=>{const v=document.baseURI;if(i!==null)for(const E of i.querySelectorAll("video, audio"))Tn(E.currentSrc,h.url,v)&&g(E,{kind:"report",final:h.final},E.currentSrc);for(const[E,b]of t)Tn(b,h.url,v)&&f(E,"media-load",b);w(!1)},registerPdfFrame:(h,v)=>(t.set(v,h),()=>{t.delete(v),o.delete(v),w(!1)}),pdfGeneration:h=>n.get(h)??0,subscribe:h=>(s.add(h),()=>{s.delete(h)}),notices:()=>a,reload:h=>{let v=!1;for(const E of[...o.values()])E.kind!=="media-load"||!h.contains(E.target)||(o.delete(E.target),E.target instanceof HTMLIFrameElement?(n.set(E.url,(n.get(E.url)??0)+1),v=!0):(e.set(E.target,Xt),p(E.target)));w(v)}}},br={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"]},le=(e,t)=>e[br[t][0]],ve=({failure:e,alert:t,onRetry:n,testId:r,text:o})=>{const{labels:s,edits:a,guardUnload:i,onReload:f,onSessionEnded:w,accountState:g}=F(),d=e.reason==="unauthorized"?w:void 0,p=o===void 0?le(s,e.reason):o.title,h=o===void 0?s[d===void 0?br[e.reason][1]:g==="signed-out"?"failureUnauthorizedSignedOutBody":"failureUnauthorizedSignInBody"]:o.body,v=e.reason==="unauthorized"||e.reason==="forbidden"||e.reason==="failed"?"danger":"warning",E=()=>{if(i){f();return}a.flushDrafts();const b=a.dirtyPaths();if(b.length===0){f();return}a.askToDiscard(b).then(k=>{k&&f()})};return l.jsxs("div",{className:"aqmx-callout",role:t?"alert":void 0,"data-aqmx-tone":v,"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:p}),l.jsx("p",{className:"aqmx-callout-body",children:h}),d!==void 0?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:()=>{d().then(b=>{b&&n?.()})},children:g==="signed-out"?s.signIn:s.signInAgain}):e.reason==="unauthorized"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:E,children:s.reloadPage}):n!==void 0&&e.reason==="failed"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:n,children:s.retry}):null]})},Hs=(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 le(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(le(e,r.failure.reason));case"saved":if(!o)return r.merged?e.draftSavedMerged:e.draftSaved;break}return o?e.draftUnsaved:""},Vs=(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(le(e,t.failure.reason));case"idle":case"saving":return null}},Ne=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},kr="<<<<<<<",Sr="=======",Tr=">>>>>>>",Rn=(e,t)=>e===t||e.startsWith(`${t} `),Cn=e=>Rr(e.split(`
5
+ `)),Rr=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||(Rn(s,kr)?(n=o,r=null):s===Sr?n!==null&&r===null?r=o:n=null:Rn(s,Tr)&&(n!==null&&r!==null&&t.push({start:n,separator:r,end:o}),n=null,r=null))}return t},Lt=e=>e.includes(`\r
6
+ `)?`\r
7
+ `:`
8
+ `,ot=e=>e.replace(/\r\n?/gu,`
9
+ `),zs=(e,t)=>t===`
10
+ `?e:e.replaceAll(`
11
+ `,`\r
12
+ `),Gs=3,Zs=/^\d+(?:\.\d+)?$/u,Ws=e=>{if(e===null||!Zs.test(e))return null;const t=Number(e);return t>=V.EDIT_SPLIT_MIN_PERCENT&&t<=V.EDIT_SPLIT_MAX_PERCENT?t:null},qe=Object.freeze({kind:"idle"}),Ot=Object.freeze({kind:"draft"}),Ks=({data:e,conflictLabels:t,onSaveSettled:n,sideBySideSetting:r,editorShareSetting:o})=>{const s=new Map,a=new Map,i=new Map,f=new Map,w=new Map,g=Ne();let d=null,p=null,h=null;const v=new Set,E=new Set;let b=!1;const k=(u,m)=>{u.value={...u.value,...m},g.emit()},L=u=>{const m=s.get(u);return m===void 0||m.base===null||!m.value.dirty?null:{path:u,base:{text:m.base.text,version:m.base.version},draft:m.draft,lineEnding:m.ending}},A=()=>{b=!1;const u=[...E];E.clear();for(const m of v){const S=m.first?new Set([...s.keys(),...u]):u;m.first=!1;const x=[],O=[];for(const $ of S){const y=L($);y!==null?(x.push(y),m.kept.add($)):m.kept.delete($)&&O.push($)}(x.length>0||O.length>0)&&m.listener({kept:x,ended:O})}},C=()=>{b||(b=!0,queueMicrotask(A))},M=u=>{E.add(u),C()},B=(u,m)=>s.get(u)===m,I=async(u,m)=>{m.controller.abort(),m.controller=new AbortController;const{signal:S}=m.controller;k(m,{phase:{kind:"opening"}});const x=await e.edit(u,S);if(!B(u,m)||S.aborted||!("kind"in x))return;if(x.kind==="grant"){k(m,{phase:{kind:"grant",href:x.href}});return}if(x.kind==="failure"){k(m,{phase:{kind:"failed",failure:x.failure}});return}const O=ot(x.text),$=x.kind==="draft";m.base={text:O,version:$?null:x.version},m.draft=O,m.ending=Lt(x.text),M(u),k(m,{phase:{kind:"editing"},history:$?!1:x.history,dirty:!1,save:$?Ot:qe,generation:m.value.generation+1})},H=u=>{const m=s.get(u);m!==void 0&&(m.controller.abort(),s.delete(u),i.delete(u),M(u))},_=(u,m,S)=>(u.set(m,S),()=>{u.get(m)===S&&u.delete(m)}),U=(u,m,S,x={})=>{k(m,{...x,save:S}),n(u,S)},Z=async u=>{f.get(u)?.flush();const m=s.get(u);if(m===void 0||m.value.phase.kind!=="editing"||m.base===null||m.value.save.kind==="saving")return;const{version:S}=m.base;if(S===null){n(u,Ot);return}const x=Cn(m.draft).length;if(x>0){U(u,m,{kind:"conflicts",count:x});return}m.controller.abort(),m.controller=new AbortController;const{signal:O}=m.controller;let $={text:m.base.text,version:S},y=m.draft,T=!1;k(m,{save:{kind:"saving"}});for(let D=0;D<Gs;D+=1){const N=await e.save(u,$.version,zs(y,m.ending),O);if(!B(u,m)||O.aborted||!("kind"in N))return;if(N.kind==="saved"){f.get(u)?.flush(),m.base={text:y,version:N.version},M(u),U(u,m,{kind:"saved",merged:T},{dirty:m.draft!==y});return}if(N.kind==="grant"){U(u,m,{kind:"grant",href:N.href});return}if(N.kind==="failure"){U(u,m,{kind:"failed",failure:N.failure});return}const{mergeDraft:q}=await Promise.resolve().then(()=>require("./merge-Dckw7r9T.cjs"));if(!B(u,m)||O.aborted)return;const X=f.get(u);X?.flush();const K=ot(N.text),W=q($.text,m.draft,K,t());if($={text:K,version:N.version},m.base=$,m.ending=Lt(N.text),m.draft=W.text,M(u),X?.adopt(W.text),W.kind==="conflicts"){U(u,m,{kind:"conflicts",count:W.conflicts},{dirty:!0,generation:m.value.generation+1});return}if(T=!0,y=W.text,y===$.text){U(u,m,{kind:"saved",merged:T},{dirty:!1,generation:m.value.generation+1});return}k(m,{dirty:!0,generation:m.value.generation+1})}U(u,m,{kind:"failed",failure:{reason:"failed"}})},Q=async(u,m)=>{if(m.kind==="failure")return{restored:!1,reason:m.failure.reason};if(m.kind==="grant")return{restored:!1,reason:"forbidden"};const S=ot(m.text);let x,O,$;if(m.kind==="draft")x={text:S,version:null},O=u.draft,$=Ot;else if(u.base.version===m.version)x={text:S,version:m.version},O=u.draft,$=qe;else{const{mergeDraft:y}=await Promise.resolve().then(()=>require("./merge-Dckw7r9T.cjs")),T=y(u.base.text,u.draft,S,t());x={text:S,version:m.version},O=T.text,$=T.kind==="conflicts"?{kind:"conflicts",count:T.conflicts}:qe}if(s.has(u.path))return{restored:!1,reason:"failed"};if(O!==x.text){const y=m.kind==="edit"&&m.history;s.set(u.path,{value:{path:u.path,phase:{kind:"editing"},view:"editor",previewPrepared:!1,history:y,dirty:!0,save:$,generation:1,request:null},base:x,draft:O,ending:Lt(m.text),controller:new AbortController}),M(u.path),g.emit()}return{restored:!0}};return{session:u=>s.get(u)?.value,subscribe:g.subscribe,start:(u,m)=>{const S=s.get(u);if(S!==void 0){k(S,{request:{anchor:m},view:"editor"}),(S.value.phase.kind==="failed"||S.value.phase.kind==="grant")&&I(u,S);return}a.delete(u);const x={value:{path:u,phase:{kind:"opening"},view:"editor",previewPrepared:!1,history:!1,dirty:!1,save:qe,generation:0,request:{anchor:m}},base:null,draft:"",ending:`
13
+ `,controller:new AbortController};s.set(u,x),I(u,x)},retry:u=>{const m=s.get(u);m===void 0||m.value.phase.kind==="editing"||I(u,m)},draft:u=>{const m=s.get(u);return m===void 0||m.base===null?null:m.draft},setDraft:(u,m)=>{const S=s.get(u);if(S===void 0||S.base===null)return;m!==S.draft&&M(u),S.draft=m;const x={},O=m!==S.base.text;O!==S.value.dirty&&(x.dirty=O);const{save:$}=S.value;if($.kind==="conflicts"){const y=Cn(m).length;y===0?x.save=qe:y!==$.count&&(x.save={kind:"conflicts",count:y})}(x.dirty!==void 0||x.save!==void 0)&&k(S,x)},consumeRequest:u=>{const m=s.get(u);m!==void 0&&m.value.request!==null&&k(m,{request:null})},save:Z,replaceDraft:(u,m)=>{const S=f.get(u);S?.flush();const x=s.get(u);if(x===void 0||x.base===null)return;const O=ot(m);O!==x.draft&&M(u),x.draft=O,S?.adopt(O),k(x,{dirty:O!==x.base.text,generation:x.value.generation+1})},close:u=>{if(!s.has(u))return;const m=f.get(u),S=m===void 0?null:m.returnPoint();H(u),S===null?a.delete(u):a.set(u,S),g.emit()},takeReturn:u=>{const m=a.get(u)??null;return a.delete(u),m},dirtyPaths:()=>[...s.values()].filter(u=>u.value.dirty).map(u=>u.value.path),discard:u=>{for(const m of u)H(m);u.length>0&&g.emit()},editorState:{get:u=>i.get(u),set:(u,m)=>{s.has(u)&&i.set(u,m)}},bindEditor:(u,m)=>_(f,u,m),bindView:(u,m)=>_(w,u,m),viewAnchor:u=>{const m=w.get(u);return m===void 0?null:m.anchor()},flush:u=>f.get(u)?.flush(),flushDrafts:()=>{for(const u of f.values())u.flush()},nextConflict:u=>f.get(u)?.nextConflict()===!0,hasSessions:()=>s.size>0,unsavedAmong:u=>{for(const m of f.values())m.flush();return u.filter(m=>s.get(m)?.value.dirty===!0)},askToDiscard:u=>new Promise(m=>{h?.settle(!1);const S={paths:u,settle:x=>{if(h===S){if(h=null,x)for(const O of u)H(O);g.emit(),m(x)}}};h=S,g.emit()}),discardRequest:()=>h,subscribeDrafts:u=>{const m={listener:u,kept:new Set,first:!0};return v.add(m),C(),()=>{v.delete(m)}},restoreDrafts:async u=>{const{signal:m}=new AbortController,S=await Promise.all(u.map(async $=>{const y=await e.edit($.path,m);if(!("kind"in y))throw new Error("[markdown-explorer] the transport answered a restore read as cancelled, though nothing aborted it");return{draft:$,answer:y}})),x=[],O=[];for(const{draft:$,answer:y}of S){const T=await Q($,y);T.restored?x.push($.path):O.push({path:$.path,reason:T.reason})}return{restored:x,failed:O}},sideBySide:()=>(d??=r.read(),d),setSideBySide:u=>{d!==u&&(d=u,r.write(u),g.emit())},editorShare:()=>(p??=o.read()??V.EDIT_SPLIT_DEFAULT_PERCENT,p),setEditorShare:u=>{if(!Number.isFinite(u))throw new RangeError(`[markdown-explorer] an editor share must be a finite number; got ${z.describeValue(u)}`);const m=Math.min(V.EDIT_SPLIT_MAX_PERCENT,Math.max(V.EDIT_SPLIT_MIN_PERCENT,u));p!==m&&(p=m,o.write(m))},setView:(u,m)=>{const S=s.get(u);S===void 0||S.value.view===m||(f.get(u)?.beforeView(m),k(S,{view:m,previewPrepared:S.value.previewPrepared||m==="preview"}))},preparePreview:u=>{const m=s.get(u);m!==void 0&&!m.value.previewPrepared&&k(m,{previewPrepared:!0})}}},on=e=>{e.preventDefault(),e.stopPropagation()},Cr=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,Mr="data-aqmx-content-pane",mt=Object.freeze({[Mr]:""}),Xs="--aqmx-dialog-left",Ys="--aqmx-dialog-top",Qs='[data-testid="markdown-explorer"]',Js=e=>{const t=e.closest(Qs)?.querySelectorAll(`[${Mr}]`),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},ea=e=>{const t=Cr(getComputedStyle(e).marginTop);if(Number.isNaN(t))return null;const n=Js(e),r=e.getBoundingClientRect(),o=e.ownerDocument.documentElement,{left:s,top:a}=V.centeredDialogPosition(n.getBoundingClientRect(),{width:r.width+2*t,height:r.height+2*t},{width:o.clientWidth,height:o.clientHeight});return e.style.setProperty(Xs,`${String(s)}px`),e.style.setProperty(Ys,`${String(a)}px`),n},ta=e=>e.preventDefault(),Lr=({open:e,onOpen:t,onDismiss:n})=>{const r=c.useRef(null),o=c.useRef(null),s=c.useRef(!1),a=c.useRef(t);c.useLayoutEffect(()=>{a.current=t},[t]),c.useLayoutEffect(()=>{s.current=e;const g=r.current;if(g!==null)if(e&&!g.open){const d=g.ownerDocument.activeElement;o.current=d instanceof HTMLElement?d:null,g.showModal(),a.current?.()}else!e&&g.open&&(g.close(),o.current?.isConnected===!0&&o.current.focus(),o.current=null)},[e]),c.useLayoutEffect(()=>{const g=r.current;if(!e||g===null)return;const d=new ResizeObserver(()=>h());let p=null;const h=()=>{const E=ea(g);E===null||E===p||(p!==null&&d.unobserve(p),d.observe(E),p=E)};h(),d.observe(g);const v=g.ownerDocument.defaultView;return v?.addEventListener("resize",h),g.ownerDocument.addEventListener("scroll",h,{capture:!0,passive:!0}),()=>{d.disconnect(),v?.removeEventListener("resize",h),g.ownerDocument.removeEventListener("scroll",h,{capture:!0})}},[e]);const i=c.useCallback(g=>{g.key!=="Escape"||g.defaultPrevented||(on(g),n())},[n]),f=c.useCallback(g=>{g.target===g.currentTarget&&n()},[n]),w=c.useCallback(()=>{s.current&&n()},[n]);return{ref:r,onKeyDown:i,onClick:f,onCancel:ta,onClose:w}},sn=({open:e,title:t,body:n,confirmLabel:r,cancelLabel:o,onConfirm:s,onCancel:a,testId:i})=>{const f=c.useRef(null),w=c.useId(),g=c.useId(),d=c.useCallback(()=>f.current?.focus(),[]),p=Lr({open:e,onOpen:d,onDismiss:a});return l.jsx("dialog",{...p,className:"aqmx-confirm","aria-labelledby":w,"aria-describedby":g,"data-testid":i,children:l.jsxs("div",{className:"aqmx-confirm-panel",children:[l.jsx("p",{id:w,className:"aqmx-confirm-title",children:t}),l.jsx("p",{id:g,className:"aqmx-confirm-body",children:n}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{ref:f,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})]})]})})},Ge=e=>{const t=e;return t.status===void 0&&(t.status="pending",e.then(n=>{t.status="fulfilled",t.value=n},n=>{t.status="rejected",t.reason=n})),t},Or=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),Ve=e=>e.status==="fulfilled"?e.value:void 0,Ar=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!1}),na=Object.freeze({readme:Object.freeze({status:"loading"}),claim:!0}),ra=(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 f of[...i].reverse())o.push(f)}return null},Dr=(e,t,n)=>{const r=Ve(e.read(t));if(r===void 0||r.status==="deferred")return Ar;if(r.status==="error")return{readme:{status:"failed",failure:r.failure,retry:()=>e.retry(t)},claim:!1};const o=ra(r.entries,n,a=>e.children(t,a));if(o!==null)return{readme:{status:"ok",readme:V.folderReadmeOf(o)},claim:!1};const s=e.children(t,n);return s===void 0||s.status==="loading"?na:s.status==="failed"?{readme:{status:"failed",failure:s.failure,retry:()=>e.retryChildren(t,n)},claim:!0}:{readme:{status:"ok",readme:V.folderReadmeOf(s.entries)},claim:!0}},oa=(e,t,n)=>{const{readme:r}=Dr(e,t,n);return r.status==="ok"?r.readme:null},sa=(e,t,n)=>{const r=re.matchPath({path:`${e.basePath}/*`,end:!0},t.pathname);if(r===null)return new Set;const{location:o}=V.resolveExplorerLocation(e,r.params["*"],new URLSearchParams(t.search));switch(o.view){case"tree":{const s=o.folder===null?o.doc:n(o.source,o.folder);return new Set(s===null?[]:[s])}case"single":return new Set([o.doc]);case"multi":return new Set(o.docs)}},Nr=e=>{const{edits:t}=F(),n=c.useCallback(()=>t.session(e),[t,e]);return c.useSyncExternalStore(t.subscribe,n,aa)},Pr=()=>!1,aa=()=>{},ia=()=>{const{edits:e}=F();return c.useSyncExternalStore(e.subscribe,e.hasSessions,Pr)},_r=()=>{const{edits:e}=F();return c.useSyncExternalStore(e.subscribe,e.sideBySide,Pr)},la=()=>null,ca=()=>{const{edits:e,labels:t,config:n,trees:r,guardUnload:o}=F(),s=c.useRef([]),a=c.useCallback(({nextLocation:v})=>{const E=sa(n,v,(b,k)=>oa(r,b,k));return e.flushDrafts(),s.current=e.dirtyPaths().filter(b=>!E.has(b)),s.current.length>0},[e,n,r]),i=re.useBlocker(a),f=ia();c.useEffect(()=>{if(!(f&&o))return;const v=E=>{e.flushDrafts(),e.dirtyPaths().length!==0&&(E.preventDefault(),E.returnValue=!0)};return window.addEventListener("beforeunload",v),()=>window.removeEventListener("beforeunload",v)},[f,e,o]);const w=c.useSyncExternalStore(e.subscribe,e.discardRequest,la),g=i.state==="blocked";c.useEffect(()=>{w!==null&&i.state==="blocked"&&i.reset()},[w,i]);const d=w!==null?w.paths:g?s.current:[],p=d.map(v=>P.lastPathSegment(v)).join(", "),h=d.length>0&&d.every(v=>e.session(v)?.save.kind==="draft");return l.jsx(sn,{open:g||w!==null,title:h?t.draftDiscardTitle:t.unsavedTitle,body:h?t.draftDiscardBody(p):t.unsavedBody(p),confirmLabel:t.unsavedDiscard,cancelLabel:t.unsavedStay,testId:"markdown-explorer-unsaved-guard",onConfirm:()=>{if(w!==null){w.settle(!0);return}i.state==="blocked"&&(e.discard(s.current),i.proceed())},onCancel:()=>{if(w!==null){w.settle(!1);return}i.state==="blocked"&&i.reset()}})},da=async(e,t)=>{const n=await t.documents.refresh(e);if(n.status==="refreshed"||n.status==="shown"&&!n.failed){t.announcer.announce(t.labels.documentReloadedAfterChange(t.nameOf(e)));return}n.status==="failed"&&t.documentChanges.mark([e])},ua=(e,t)=>{vs(e);for(const r of e.sourceIds)t.trees.reloadSource(r);const n=[];for(const r of e.paths){if(t.documents.noteChanged(r),t.edits.session(r)!==void 0||!t.documentChanges.shown(r))continue;const o=t.documents.peek(r);o?.status!=="loaded"||o.document.kind==="failure"||(t.policy==="notify"?n.push(r):da(r,t))}n.length>0&&t.documentChanges.mark(n)};function fa({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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 ma=R.forwardRef(fa);let At=null;const jr=()=>(At??=Promise.resolve().then(()=>require("./EditSurface-B70iRFkG.cjs")).catch(e=>{throw At=null,e}),At),ha=()=>{jr().catch(()=>{})},pa=e=>{const{default:t}=c.use(jr());return l.jsx(t,{...e})};class wa extends c.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 Ir="[data-aqmd-fullscreen]",ga="[data-aqmd-fullscreen-dialog]:modal",va=e=>e instanceof Element&&e.closest(Ir)!==null,Ea=e=>e.querySelector(ga)!==null,an=`[${Vt.SOURCE_LINES_ATTRIBUTE}]`,ya="[data-aqmd-content]",xa=`a[href], button, input, select, textarea, summary, label, [contenteditable], [role="menu"], iframe, video, audio, object, embed, svg, [data-aqmd-spreadsheet-editable], ${Ir}, [data-aqmd-svg-image-source]`,ba=200,Ze=e=>Vt.parseSourceLines(e.getAttribute(Vt.SOURCE_LINES_ATTRIBUTE)),ka=(e,t)=>{for(let r=e;r!==null&&t.contains(r);r=r.parentElement){const o=Ze(r);if(o!==null)return{block:r,lines:o,own:!0}}let n=null;for(const r of t.querySelectorAll(an)){if(!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))break;const o=Ze(r);o!==null&&(n={block:r,lines:o})}return n===null?null:{...n,own:!1}},Sa=(e,t)=>{let n=0;for(let r=e.indexOf(t);r>=0;r=e.indexOf(t,r+t.length))n+=1;return n},Fr=e=>e.closest(ya)!==null&&e.closest(xa)===null,$r=(e,t,n)=>{const r=ka(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:ht(e)}}const a=Ta(o,n);return a===null?{lines:r.lines,word:null,occurrence:0,clientTop:ht(o)}:{lines:r.lines,word:a.text,occurrence:a.occurrence,clientTop:a.clientTop}},qr=(e,t)=>{let n=null,r=null,o=null;for(const a of e.querySelectorAll(an)){const i=Ze(a);if(i===null)continue;n??=Ur(t,a);const{top:f,bottom:w}=a.getBoundingClientRect();f<=n&&n<w?r={lines:i,block:a}:o===null&&f>=n&&(o={lines:i,block:a})}const s=r===null?o:r;return s===null?null:{lines:s.lines,word:null,occurrence:0,clientTop:ht(s.block)}},Br=e=>e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,Ur=(e,t)=>{const n=Number.parseFloat(getComputedStyle(t).scrollMarginTop);return Br(e)+(Number.isFinite(n)?n:0)},Ta=(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>ba||/[\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:Sa(o.toString(),r),clientTop:n.getBoundingClientRect().top}},Ra=(e,t)=>{const n=e.split(`
14
+ `),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 f=n[i-1]??"";for(let w=f.indexOf(t.word);w>=0;w=f.indexOf(t.word,w+t.word.length)){if(a===t.occurrence)return{line:i,column:w};a+=1}}return a>0?Ca(n,r,o,t.word)??s:s},Ca=(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},Hr=(e,t)=>{let n=null,r=null;for(const o of e.querySelectorAll(an)){const s=Ze(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},Vr=(e,t)=>{const{bottom:n}=e.getBoundingClientRect(),r=ht(e),o=Ze(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},ht=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},Be=(e,t)=>Object.freeze({replace:t.replace,preventScrollReset:t.preventScrollReset,defaultShouldRevalidate:!1,state:Object.freeze({aqmxNavigation:e})}),xt=Object.freeze({browse:Be("browse",{replace:!0,preventScrollReset:!0}),"close-folder":Be("close-folder",{replace:!0,preventScrollReset:!0}),"switch-source":Be("switch-source",{replace:!1,preventScrollReset:!0}),"switch-view":Be("switch-view",{replace:!1,preventScrollReset:!1}),"follow-link":Be("follow-link",{replace:!1,preventScrollReset:!1})}),Ma=Object.freeze(Object.keys(xt)),La=e=>xt[e],Oa=(e,t)=>{if(e===re.NavigationType.Pop||typeof t!="object"||t===null||!("aqmxNavigation"in t))return null;const{aqmxNavigation:n}=t;return Ma.find(r=>r===n)??null},xe=()=>{const e=re.useNavigate();return c.useCallback((t,n)=>{e(t,xt[n])},[e])},zr=({navigation:e,...t})=>l.jsx(re.Link,{...t,...xt[e]}),ln=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},Gr=(e,t)=>{const n=c.useRef(null),r=c.useRef(null),o=c.useRef(null),s=c.useCallback(()=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,r.current=null},[]);c.useEffect(()=>s,[s]);const a=c.useCallback(w=>{if(r.current!==w)return;const g=o.current;if(g!==null){g.then(()=>a(w));return}e.prefetch(w);const d=e.peek(w);if(d?.status!=="pending")return;const p=Promise.allSettled([d.promise]);o.current=p,p.then(()=>{o.current===p&&(o.current=null)})},[e]),i=c.useCallback(w=>{const g=t(w);g!==r.current&&(s(),g!==null&&(r.current=g,n.current=window.setTimeout(()=>{n.current=null,a(g)},V.PREFETCH_DWELL_MS)))},[s,t,a]),f=c.useCallback(w=>{t(w)!==r.current&&s()},[s,t]);return c.useMemo(()=>({onPointerOver:w=>i(w.target),onPointerOut:w=>f(w.relatedTarget),onFocus:w=>i(w.target),onBlur:w=>f(w.relatedTarget)}),[i,f])},Aa=c.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-Bj-LKej0.cjs")).then(e=>({default:e.NativeScrollBar})));class Da extends c.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 Zr=({scroller:e,kind:t})=>l.jsx(Da,{children:l.jsx(c.Suspense,{fallback:null,children:l.jsx(Aa,{scroller:e,kind:t})})}),Wr=e=>l.jsx(Zr,{scroller:e,kind:"content"}),Kr=Object.freeze({showArrowButtons:!0,enableThumbDrag:!0,enableTrackClick:!0}),Xr=Object.freeze({showArrowButtons:!1,enableThumbDrag:!1,enableTrackClick:!1}),cn=e=>e?Xr:Kr,Na=8,Pa="--aqmx-scroll-bar-slot-size",dn=`var(${Pa})`,un=V.CONTROL_BLOCK_PIXELS,_a=V.FIBONACCI_SPACING_PIXELS[3],ja="--aqmx-tap-circle-gutter-size",fn=`var(${ja})`,Ia=-(un+_a),Yr=Object.freeze({minSpeedMultiplier:.25,maxSpeedMultiplier:18});let Qr=null,Dt=null;const Yt=new Set,Fa=e=>(Yt.add(e),()=>{Yt.delete(e)}),$a=()=>{Dt===null&&(Dt=Promise.resolve().then(()=>require("./tapScrollCircle-DyLInGck.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");Qr=t;for(const n of[...Yt])n()}).catch(e=>{Dt=null,console.error("[markdown-explorer] the look of a table's tap-scroll circle failed to load; the circle still scrolls without it.",e)}))},qa=({look:e,state:t})=>e(t),Ba=e=>{const t=c.useSyncExternalStore(Fa,()=>Qr,()=>null);return c.useEffect(()=>{t===null&&$a()},[t]),t===null?null:l.jsx(qa,{look:t,state:e})},Jr=Object.freeze({renderVisual:e=>l.jsx(Ba,{...e}),...Yr,size:un}),Ua=Object.freeze({...Jr,visibility:"scrolling"}),eo=e=>e?Ua:Jr,to="(pointer: coarse)",Ha=e=>{const t=window.matchMedia(to);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},Va=()=>window.matchMedia(to).matches,za=()=>!1,mn=()=>c.useSyncExternalStore(Ha,Va,za),no=()=>{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()]}},pt=(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)=>pt(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)&&pt(n[s],r[s]))},Ga=55e3,Mn=Object.freeze({status:"deferred"}),Nt=Object.freeze({status:"refreshed"}),Pt=Object.freeze({status:"shown",failed:!1}),st=Object.freeze({status:"shown",failed:!0}),at=Object.freeze({status:"superseded"}),me=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,Za=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",Wa=({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 ${z.describeValue(t)}`);const n=new Map,r=no(),o=Ne(),s=new WeakSet,a=new Map,i=new Map,f=new Map;let w=0;const g=o.emit,d=()=>(w+=1,w),p=()=>{if(!(n.size<=t))for(const u of[...n.keys()]){if(n.size<=t)return;r.isHeld(u)||n.delete(u)}},h=(u,m)=>{n.delete(u),n.set(u,m)},v=u=>performance.now()-u.validatedAt>=Ga,E=(u,m,S)=>{const x=n.get(u),O=me(x?.snapshot),$=S||x?.refreshPending===!0,y=Ge(e.document(u,{refresh:$}).then(D=>({status:"loaded",document:D}))),T={snapshot:{status:"pending",promise:y,previous:O},validatedAt:performance.now(),opened:m,background:null,refreshPending:!1,seeded:void 0,stamp:d()};return h(u,T),p(),y.then(D=>{n.get(u)===T&&(T.snapshot=D,T.stamp=d(),g())}),T},b=(u,m,S,x,O,$)=>{m.background===S&&(m.background=null,!(n.get(u)!==m||m.snapshot!==x)&&(O.kind==="failure"&&x.document.kind!=="failure"||(m.validatedAt=$,m.stamp=d(),pt(x.document,O)||(m.snapshot={status:"loaded",document:O}),g())))},k=async(u,m)=>{const S=m.snapshot;if(S.status!=="loaded")return null;const x={};m.background=x;const O=performance.now(),$=e.document(u,{refresh:m.refreshPending});m.refreshPending=!1;const y=await $,T=m.background===x&&n.get(u)===m&&m.snapshot===S;return b(u,m,x,S,y,O),T?y:null},L=u=>{u.validatedAt=Number.NEGATIVE_INFINITY,u.opened=!0,u.refreshPending=!0},A=u=>{u.background=null},C=(u,m)=>{const{snapshot:S}=m;return S.status==="pending"?!1:S.status==="loaded"&&S.document.kind!=="failure"?(k(u,m),!1):(S.status==="loaded"&&s.add(S),E(u,!0,!1),!0)},M=u=>{i.delete(u);const m=f.get(u);if(m!==void 0){f.delete(u);for(const S of m)S()}},B=(u,m)=>new Promise(S=>{if(i.get(u)===m||!r.isHeld(u)){S();return}const x=f.get(u);x===void 0?f.set(u,new Set([S])):x.add(S)}),I=(u,m)=>{const S=a.get(u);if(S===void 0){m.resolve(null);return}if(S.last!==null&&S.last.stamp>=m.stamp){m.resolve(S.last);return}S.waiters.add(m)},H=async(u,m,S)=>{const x=await new Promise(O=>I(u,{stamp:m.stamp,resolve:O}));if(n.get(u)!==m)return at;if(x===null)return S?Nt:Pt;if(!S)return x.failure===null?Pt:st;switch(x.before){case"copy":return x.failure===null?Nt:{status:"failed",failure:x.failure};case"failure":return x.failure===null?Pt:st;case"none":return x.failure===null?Nt:st}},_=u=>{const m={showing:"none",last:null,waiters:new Set};a.set(u,m);let S=!1;return{settle:(x,O)=>{if(S||x===void 0)return;const $={stamp:x,failure:O,before:m.showing};m.last=$,O===null?m.showing="copy":m.showing==="none"&&(m.showing="failure");for(const y of[...m.waiters])x<y.stamp||(m.waiters.delete(y),y.resolve($))},release:()=>{if(S)return;S=!0,a.get(u)===m&&a.delete(u);const x=[...m.waiters];m.waiters.clear(),x.length>0&&queueMicrotask(()=>{for(const O of x)I(u,O)})}}},U=u=>{const m=r.hold(u);let S=!1;return()=>{if(S)return;S=!0,m();const x=n.get(u);x!==void 0&&h(u,x),p(),r.isHeld(u)||queueMicrotask(()=>{r.isHeld(u)||M(u)})}};return{peek:u=>n.get(u)?.snapshot,peekSeeded:u=>n.get(u)?.seeded,answerStampOf:u=>n.get(u)?.stamp,prefetch:u=>{const m=n.get(u);m!==void 0&&m.snapshot.status!=="deferred"||(E(u,!1,!1),g())},open:u=>{const m=r.resumes(u),S=U(u),x=n.get(u);if(x===void 0||x.snapshot.status==="deferred")return E(u,!0,!1),g(),S;if(h(u,x),m)return S;const{snapshot:O}=x;return O.status==="pending"?(x.opened=!0,S):O.document.kind==="failure"?(x.opened||v(x)?(s.add(O),E(u,!0,!1),g()):x.opened=!0,S):(x.opened=!0,x.background===null&&v(x)&&k(u,x),S)},retain:U,retry:u=>{const m=n.get(u);m===void 0||m.snapshot.status!=="loaded"||m.snapshot.document.kind!=="failure"||(E(u,!0,!1),g())},seed:(u,m)=>{const S=performance.now(),x=Ge(m.then(D=>D===null?Mn:{status:"loaded",document:D},()=>Mn)),O=n.get(u);if(O!==void 0&&O.snapshot.status==="loaded"){const D=O.snapshot,N={};O.background=N,x.then(q=>{if(q.status==="loaded"){b(u,O,N,D,q.document,S);return}O.background===N&&(O.background=null)});return}const $=O!==void 0&&O.snapshot.status==="pending"?O.snapshot.previous:null,y={status:"pending",promise:x,previous:$},T={snapshot:y,validatedAt:S,opened:O?.opened===!0,background:null,refreshPending:O?.refreshPending===!0,seeded:y,stamp:d()};h(u,T),p(),x.then(D=>{n.get(u)===T&&(D.status==="deferred"&&r.isHeld(u)?E(u,T.opened,!1):(T.snapshot=D,T.stamp=d()),g())})},invalidate:()=>{let u=!1;for(const[m,S]of[...n]){if(L(S),!r.isHeld(m)){A(S);continue}const{snapshot:x}=S;if(x.status!=="pending"){C(m,S)&&(u=!0);continue}x.promise.then(()=>{n.get(m)===S&&S.refreshPending&&r.isHeld(m)&&C(m,S)&&g()})}u&&g()},noteChanged:u=>{const m=n.get(u);if(m===void 0)return;if(L(m),!r.isHeld(u)){A(m);return}const{snapshot:S}=m;if(S.status==="pending"){E(u,m.opened,!0),g();return}S.status==="loaded"&&S.document.kind==="failure"&&(s.add(S),E(u,!0,!1),g())},refresh:async u=>{const m=n.get(u);if(m!==void 0&&Za(m.snapshot)){m.refreshPending=!0;const O=await k(u,m);return O===null?at:O.kind==="failure"?{status:"failed",failure:O.failure}:H(u,m,!0)}const S=E(u,!0,!0);if(g(),S.snapshot.status!=="pending")return at;const x=await S.snapshot.promise;return n.get(u)!==S||x.status!=="loaded"?at:x.document.kind==="failure"?st:(await B(u,x),H(u,S,!1))},clear:()=>{n.clear();for(const u of r.heldKeys())E(u,!0,!1);g()},subscribe:o.subscribe,readPart:_,noteShown:(u,m)=>{i.set(u,m);const S=f.get(u);if(S!==void 0){f.delete(u);for(const x of S)x()}},noteFailureShown:u=>s.has(u)?!1:(s.add(u),!0)}},Ee=c.createContext("fill"),Ka="--aqmx-tap-circle-gutter",Xa=Object.freeze({blockSize:"100%",[Ka]:fn}),Xe=({scrollerProps:e,children:t})=>c.use(Ee)==="content"?l.jsx(De.HostedScrollArea,{scrollerProps:e,children:t}):l.jsx(De.HostedScrollArea,{scrollerProps:{...e,style:Xa},rowClassName:"aqmx-document-scroll-row",renderScrollBar:Wr,barInlineSize:dn,children:t}),Ya=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),Qa=Object.freeze({className:"aqmx-document-failure","data-aqmx-document-scroller":""}),ye=({label:e,testId:t})=>l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":t,children:Ya.map(n=>l.jsx("span",{},n))}),l.jsx("p",{className:"aqmx-sr-only",children:e})]}),wt=({failure:e,onRetry:t,testId:n,text:r})=>l.jsx(Xe,{scrollerProps:Qa,children:l.jsx(ve,{failure:e,alert:!1,onRetry:t,testId:n,text:r})});function Ja({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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"}),R.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 ei=R.forwardRef(Ja);function ti({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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"}),R.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 ni=R.forwardRef(ti);function ri({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.createElement("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",clipRule:"evenodd"}))}const ro=R.forwardRef(ri),oi=2e3,Ln=Object.freeze({outcome:"idle",message:null}),oo=()=>{const{announcer:e}=F(),[t,n]=c.useState(Ln),r=c.useRef(0);c.useEffect(()=>{if(t.outcome==="idle")return;const s=setTimeout(()=>n(Ln),oi);return()=>clearTimeout(s)},[t]);const o=c.useCallback(()=>{r.current+=1;const s=r.current;return(a,i)=>{r.current===s&&(n({outcome:a,message:i}),e.announce(i))}},[e]);return{shown:t,press:o}},si=(e,t)=>new Promise(n=>n(e.writeText(t))),ai=({text:e})=>{const{labels:t}=F(),{shown:n,press:r}=oo(),o=()=>{const a=r(),i=navigator.clipboard;if(i===void 0){a("failed",t.copyTextFailed);return}si(i,e).then(()=>a("copied",t.copiedText),f=>{console.error("[markdown-explorer] could not copy the text",f),a("failed",t.copyTextFailed)})},s=n.message===null?t.copyText:n.message;return l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.copyText,title:s,onClick:o,"data-aqmx-copy-outcome":n.outcome,"data-testid":"markdown-explorer-file-copy",children:n.outcome==="copied"?l.jsx(ei,{}):n.outcome==="failed"?l.jsx(ro,{}):l.jsx(ni,{})})},so=c.createContext(null),ii=()=>{const e=c.use(so);if(e===null)throw new Error("[markdown-explorer] a document's content reads its own part only inside a document pane (DocumentContentChannelContext)");return e},li=new Set,ao=(e,t,n)=>{const{documents:r,announcer:o,labels:s}=F(),a=c.useCallback(()=>r.peek(e),[r,e]),i=c.useCallback(()=>r.peekSeeded(e),[r,e]),f=c.useSyncExternalStore(r.subscribe,a,i),w=c.useCallback(()=>r.answerStampOf(e),[r,e]),g=c.useSyncExternalStore(r.subscribe,w,w),[d]=c.useState(()=>new Set),[p,h]=c.useState(li),[v,E]=c.useState(null);v!==null&&(v.path!==e||v.markup!==n)&&E(null);const b=c.useRef(null);c.useLayoutEffect(()=>(b.current=e,()=>{b.current=null}),[e]);const k=c.useRef(n);c.useLayoutEffect(()=>{k.current=n},[n]);const L=c.useCallback(()=>{const M=e,B=r.peek(M);d.has(M)||B?.status==="pending"||(d.add(M),h(new Set(d)),E(null),(async()=>{try{const I=await r.refresh(M);if(b.current!==M||I.status==="superseded")return;if(I.status==="failed"){E({path:M,failure:I.failure,stamp:r.answerStampOf(M),markup:k.current}),o.announce(s.documentRefreshFailed(le(s,I.failure.reason)));return}if(I.status==="shown"&&(t||I.failed))return;const H=me(r.peek(M));if(H===null||H.document.kind==="failure")return;o.announce(s.documentRefreshed(H.document.name))}finally{d.delete(M),h(new Set(d))}})())},[e,t,d,r,o,s]),A=p.has(e),C=v!==null&&v.path===e&&v.stamp===g&&v.markup===n?v.failure:null;return{refreshing:A,unavailable:A||f?.status==="pending",failure:C,refresh:L}},ci=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]),di=(e,t)=>{const{mediaFailures:n}=F(),[r,o]=c.useState(()=>({path:t,notices:ct}));return c.useEffect(()=>{const s=()=>{const a=e.current,i=a===null?ct:n.notices().filter(f=>a.contains(f.target));o(f=>f.path===t&&ci(f.notices,i)?f:{path:t,notices:i})};return s(),n.subscribe(s)},[n,e,t]),r.path===t?r.notices:ct},On=(e,t,n)=>{const[r]=e;return r===void 0?null:e.length===1?t(r.name):n(e.length)},_t=({kind:e,tone:t,text:n,onReload:r})=>{const{labels:o}=F(),s=c.useId();return l.jsxs("div",{className:"aqmx-callout aqmx-document-notice","data-aqmx-tone":t,"data-testid":"markdown-explorer-document-notice","data-aqmx-notice":e,children:[l.jsx("p",{id:s,className:"aqmx-callout-body",children:n}),r===null?null:l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-describedby":s,onClick:r,children:o.reload})]})},ui=({path:e,name:t,editing:n,announces:r,markup:o,region:s,focusDocument:a})=>{const{labels:i,documentChanges:f,mediaFailures:w}=F(),{refresh:g}=ao(e,r,o);c.useLayoutEffect(()=>f.show(e),[f,e]);const d=c.useCallback(()=>f.changed(e),[f,e]),p=c.useSyncExternalStore(f.subscribe,d,d);c.useEffect(()=>{n&&f.dismiss(e)},[n,f,e]);const h=di(s,e),v=A=>{A.currentTarget===A.currentTarget.ownerDocument.activeElement&&a()},E=A=>{v(A),f.dismiss(e),g()},b=A=>{const C=s.current;C!==null&&(v(A),w.reload(C))},k=On(h.filter(A=>A.kind==="media-load"),i.mediaLoadFailed,i.mediaLoadFailedCount),L=On(h.filter(A=>A.kind==="media-unplayable"),i.mediaUnplayable,i.mediaUnplayableCount);return l.jsxs("div",{className:"aqmx-document-notices",role:"status","aria-live":"polite","aria-atomic":"false","data-testid":"markdown-explorer-document-notices",children:[p&&!n?l.jsx(_t,{kind:"changed",tone:"info",text:i.documentChangedElsewhere(t),onReload:E}):null,k===null?null:l.jsx(_t,{kind:"media-load",tone:"warning",text:k,onReload:b}),L===null?null:l.jsx(_t,{kind:"media-unplayable",tone:"warning",text:L,onReload:null})]})};function fi({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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"}),R.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 mi=R.forwardRef(fi);function hi({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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"}),R.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 pi=R.forwardRef(hi),Ye=({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(pi,{})}),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(mi,{})})]})};function wi({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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 gi=R.forwardRef(wi),vi=Object.freeze({className:"aqmx-document-stage"}),Ei=({document:e})=>{const{labels:t}=F();return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[l.jsx(Ye,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(gi,{})}),l.jsx(Xe,{scrollerProps:vi,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})]})})]})},An=["keydown","pointerdown","wheel","touchstart"],dt=new WeakMap,gt=new WeakMap,yi=e=>{const t=gt.get(e);if(t!==void 0){t.count+=1;return}gt.set(e,{count:1,original:e.style.overflowAnchor}),e.style.overflowAnchor="none"},xi=e=>{const t=gt.get(e);t!==void 0&&(t.count-=1,!(t.count>0)&&(gt.delete(e),e.style.overflowAnchor=t.original))},bi=(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)}},ki=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},io=e=>{dt.get(e)?.()},lo=(e,t,n)=>{io(e);let r=new Map;const o=new Set,s=()=>{const d=t();return d===null?!1:(r=ki(d),!0)};if(!s()||typeof ResizeObserver>"u")return;const a=()=>{for(const d of r.keys())!(d instanceof HTMLElement)||o.has(d)||(o.add(d),yi(d))};a();const{ownerDocument:i}=e,f=new ResizeObserver(()=>{if(!s()){g();return}a()});for(const{element:d,boundary:p}of n)bi(f,d,p);const w=d=>{const p=d.target===i?i.scrollingElement:d.target;if(!(p instanceof Element))return;const h=r.get(p);h!==void 0&&(p.scrollTop!==h.top||p.scrollLeft!==h.left)&&g()},g=()=>{f.disconnect();for(const d of An)i.removeEventListener(d,g,!0);i.removeEventListener("scroll",w,!0);for(const d of o)xi(d);o.clear(),dt.get(e)===g&&dt.delete(e)};for(const d of An)i.addEventListener(d,g,{capture:!0,passive:!0});i.addEventListener("scroll",w,{capture:!0,passive:!0}),dt.set(e,g)},bt="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",Si=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},Ti=/(%[0-9A-Fa-f]{2})/u,hn=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(Ti).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))},co=e=>`#${encodeURIComponent(e)}`,Ri=e=>{if(e==="#")return!0;const t=hn(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},uo=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},Ci="http://www.w3.org/1999/xhtml",Dn=(e,t)=>{if(t==="")return null;const n=uo(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===Ci&&r.getAttribute("name")===t)return r;return null},fo=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=Dn(e,t.slice(1));if(n!==null)return n;const r=hn(t);return r===null?null:Dn(e,r)},Nn=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"},Mi=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"},Li=(e,t)=>{const n=t.closest(bt),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&Nn(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(Nn(i)&&i.scrollHeight>i.clientHeight&&i.clientHeight<o)return i;return a instanceof Element&&Mi(e.ownerDocument)&&a.scrollHeight>a.clientHeight&&a.clientHeight<o?a:r},Oi=Object.freeze({scrollerOf:Li,reveal:e=>{e.scrollIntoView(vt)},keepAtStart:(e,t)=>{lo(e,()=>t.isConnected?(mo(e,t),t):null,[{element:t,boundary:e}])}}),vt=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),Ai=(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")}}},mo=(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(vt);return}e.scrollBy({top:i?a.top-n-e.clientHeight:a.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(vt)},Di=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(bt)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},Pn=(e,t,n)=>{if(e===null)return null;const r=fo(e,t);return r===null?(Ri(t)&&Di(e,n),null):(Ai(e,r),n.keepAtStart(n.scrollerOf(e,r),r),r)};function Ni({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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 Pi=R.forwardRef(Ni);function _i({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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"}),R.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 ji=R.forwardRef(_i);function Ii({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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"}),R.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 Fi=R.forwardRef(Ii);function $i({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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 qi=R.forwardRef($i),Qt="data-aqmx-key-repeat",Et=Object.freeze({[Qt]:"allow"}),Bi=`[${Qt}="${Et[Qt]}"]`,Ui=()=>{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(Bi)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},ut=Object.freeze([1/V.GOLDEN_RATIO**2,1/V.GOLDEN_RATIO,1,V.GOLDEN_RATIO,V.GOLDEN_RATIO**2]),_n=Object.freeze({mode:"fit"}),Hi=1,ho=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),jn=`[data-testid="${ho["data-testid"]}"]`,po=c.createContext(null),Vi=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=Hi?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,In=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<ut.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?ut.findIndex(o=>o>t):ut.findLastIndex(o=>o<t);return r===-1?null:r},Fn=(e,t,n)=>{if(e.mode==="level"){const o=In(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=In(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},zi=(e,t)=>{if(e<=0||t<=0)return 0;const n=Math.trunc(Math.log(t/e)/Math.log(V.GOLDEN_RATIO));return n===0?0:n},$n=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}}},Gi=e=>{const t=ut[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${z.describeValue(e)}`);return t},qn=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},Zi=({document:e})=>{const{labels:t}=F(),n=c.use(po),[r]=c.useState(()=>n===null?null:n.read(e.url)),[o,s]=c.useState(r===null?_n:r.zoom),[a,i]=c.useState(r===null?null:r.reported),[f,w]=c.useState(null),g=c.useRef(null),d=c.useCallback(C=>{const{naturalWidth:M,naturalHeight:B}=C;i(I=>qn(I,M,B))},[]),p=c.useCallback(C=>{g.current=C,!(C===null||!C.complete)&&(C.naturalWidth>0||C.naturalHeight>0?d(C):C.decode().then(()=>d(C),()=>{}))},[d]);c.useEffect(()=>{n!==null&&a!==null&&n.save(e.url,{zoom:o,reported:a})},[n,e.url,o,a]),c.useLayoutEffect(()=>{const C=g.current;if(C===null||a===null||o.mode!=="fit")return;const M=()=>w(I=>qn(I,C.clientWidth,C.clientHeight));if(M(),typeof ResizeObserver>"u")return;const B=new ResizeObserver(M);return B.observe(C),()=>B.disconnect()},[a,o.mode]);const h=a===null||f===null?null:Vi(a,f),v=Fn(o,h,-1),E=Fn(o,h,1),b=o.mode==="level"?Gi(o.index):null,k=c.useRef({zoomIn:E,zoomOut:v});c.useLayoutEffect(()=>{k.current={zoomIn:E,zoomOut:v}});const L=c.useRef(null);c.useLayoutEffect(()=>{const C=L.current,M=g.current?.closest(jn);L.current=null,!(C===null||M===null||M===void 0)&&(M.scrollLeft=C.across*M.scrollWidth-C.x,M.scrollTop=C.down*M.scrollHeight-C.y)},[o]),c.useEffect(()=>{const C=g.current?.closest(jn);if(C==null)return;let M=null;const B=_=>{const U=$n(_.touches);M=U===null?null:{distance:U.distance,steps:0}},I=_=>{const U=$n(_.touches);if(M===null||U===null)return;_.preventDefault();const Z=zi(M.distance,U.distance);if(Z===M.steps)return;const Q=Z>M.steps?1:-1,u=Q===1?k.current.zoomIn:k.current.zoomOut;if(u===null)return;M.steps+=Q;const m=C.getBoundingClientRect(),S=U.middle.x-m.left,x=U.middle.y-m.top;L.current=C.scrollWidth>0&&C.scrollHeight>0?{x:S,y:x,across:(C.scrollLeft+S)/C.scrollWidth,down:(C.scrollTop+x)/C.scrollHeight}:null,s(u)},H=_=>{_.touches.length<2&&(M=null)};return C.addEventListener("touchstart",B,{passive:!0}),C.addEventListener("touchmove",I,{passive:!1}),C.addEventListener("touchend",H,{passive:!0}),C.addEventListener("touchcancel",H,{passive:!0}),()=>{C.removeEventListener("touchstart",B),C.removeEventListener("touchmove",I),C.removeEventListener("touchend",H),C.removeEventListener("touchcancel",H)}},[]);const A=o.mode==="level"&&b!==null?{width:`${o.base.width*b}px`,height:`${o.base.height*b}px`}:void 0;return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[l.jsxs(Ye,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(qi,{}),children:[l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":v===null,onClick:()=>{v!==null&&s(v)},...Et,children:l.jsx(ji,{})}),l.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:b===null?t.imageFitLevel:t.imageZoomLevel(Math.round(b*100))}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":E===null,onClick:()=>{E!==null&&s(E)},...Et,children:l.jsx(Fi,{})}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(_n),children:l.jsx(Pi,{})})]}),l.jsx(Xe,{scrollerProps:ho,children:l.jsx("img",{ref:p,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:A,onLoad:C=>d(C.currentTarget),"data-testid":"markdown-explorer-image"})})]})},Wi=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"}},wo=c.createContext(null),go=c.createContext(void 0),kt=c.createContext(void 0),vo=c.createContext(null),St=()=>{const e=c.use(wo);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},Ki=()=>{const e=c.use(vo);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},Tt=(e,t,n,r)=>t.kind==="panel"?V.explorerHref(e,{view:"tree",source:n,doc:r}):t.view==="single"?V.explorerHref(e,{view:"single",source:n,doc:r,overrides:t.overrides,embed:t.embed}):V.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides}),Eo=(e,t,n,r)=>t.view==="tree"?V.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides,maximized:t.maximized()}):Tt(e,t,n,r),Xi=({children:e})=>{const{config:t}=F(),n=St(),r=Ke(),o=r.kind==="location"?r.location.source:void 0,s=re.useHref(Tt(t,n.navigation,o,n.currentPath));return l.jsx(kt,{value:o,children:l.jsx(vo,{value:s,children:e})})},Yi='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',Qi=e=>{const t=e instanceof Element?e.closest(Yi):null;return t===null?null:t.getAttribute("data-doc-path")},Qe=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Ji=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:a,scope:i,children:f})=>{const w=re.useHref(e),g=d=>{if(Qe(d)){if(d.preventDefault(),t===i.currentPath&&n!==""){i.scrollWithin(n);return}a(t,n)}};return l.jsx("a",{...s,href:w,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:g,children:f})},el=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:a}=F(),i=St(),f=c.use(kt),w=xe(),g=Si(e),{navigation:d}=i,p=`${Tt(a,d,f,t)}${g}`,h=n===!1?"false":void 0;if(d.kind==="page"){const v=E=>{if(!Qe(E))return;const b=`${Eo(a,d,f,t)}${g}`;b!==p&&(E.preventDefault(),w(b,"follow-link"))};return l.jsx(zr,{...o,to:p,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":h,onClick:v,children:s})}return l.jsx(Ji,{to:p,docPath:t,fragment:g,exists:h,className:r,attributes:o,onDocumentLink:d.onDocumentLink,scope:i,children:s})},tl=({className:e,attributes:t,children:n})=>{const{labels:r,locale:o}=F(),s=c.use(go),{lang:a,dir:i,...f}=t,w=a??s;return l.jsxs("a",{...f,className:e===void 0?"aqmx-document-inert-link":`${e} aqmx-document-inert-link`,title:r.inertLink,lang:w===void 0?void 0:o,"data-link-kind":"doc","data-doc-exists":"false",children:[l.jsx("span",{lang:w,dir:i,children:n}),l.jsxs("span",{className:"aqmx-sr-only",children:[" (",r.inertLink,")"]})]})},nl=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=F(),a=c.use(kt),i=re.useHref(`${Tt(s,r.navigation,a,r.currentPath)}${e}`),f=w=>{Qe(w)&&(w.preventDefault(),r.scrollWithin(e))};return l.jsx("a",{...n,href:i,className:t,onClick:f,children:o})},rl=({href:e,className:t,attributes:n,children:r})=>{const o=St();if(o.navigation.kind==="page"){const s=a=>{Qe(a)&&(e==="#"?o.followEmptyFragment(a.nativeEvent):o.followFragmentJump(e,a.nativeEvent))};return l.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return l.jsx(nl,{href:e,className:t,attributes:n,scope:o,children:r})},ol=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:a})=>t==="doc"?n===void 0||!P.isAcceptableDocumentPath(n)?l.jsx(tl,{className:o,attributes:s,children:a}):l.jsx(el,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:a}):e.startsWith("#")?l.jsx(rl,{href:e,className:o,attributes:s,children:a}):l.jsx("a",{...s,href:e,className:o,children:a}),sl=()=>{const{config:e}=F(),t=St(),n=c.use(kt),r=xe();return c.useCallback((o,s)=>{if(!Qe(s))return!0;s.preventDefault();const a=co(o.id),{navigation:i}=t;return i.kind==="panel"||hn(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(a),!0):(r(`${Eo(e,i,n,t.currentPath)}${a}`,"follow-link"),!0)},[e,t,n,r])},al=()=>{const e=Ki();return c.useCallback(t=>`${e}${co(t.id)}`,[e])};function il({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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 ll=R.forwardRef(il);function cl({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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 dl=R.forwardRef(cl);function ul({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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 fl=R.forwardRef(ul),ml=Object.freeze({className:"aqmx-document-stage"}),hl=()=>()=>{},pl=()=>navigator.pdfViewerEnabled!==!1,wl=()=>null,gl=({document:e})=>{const{labels:t,mediaFailures:n}=F(),r=c.useSyncExternalStore(hl,pl,wl),o=c.useCallback(()=>n.pdfGeneration(e.url),[n,e.url]),s=c.useSyncExternalStore(n.subscribe,o,o),a=c.useCallback(i=>n.registerPdfFrame(e.url,i),[n,e.url]);return r===null?null:r?l.jsx("iframe",{ref:a,className:"aqmx-document-frame",src:e.url,title:e.name,"data-testid":"markdown-explorer-media-player"},s):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})]})]})},vl=e=>{switch(e){case"video":return l.jsx(dl,{});case"audio":return l.jsx(fl,{});case"pdf":return l.jsx(ll,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${z.describeValue(t)}`)}}},El=({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(gl,{document:e});default:{const n=e.mediaType;throw new RangeError(`[markdown-explorer] unknown media type ${z.describeValue(n)}`)}}},yl=({document:e})=>l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[l.jsx(Ye,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:vl(e.mediaType)}),l.jsx(Xe,{scrollerProps:ml,children:l.jsx(El,{document:e})})]}),pn=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}},xl=e=>{const{documents:t}=F(),n=c.useCallback(()=>t.peek(e),[t,e]),r=c.useCallback(()=>t.peekSeeded(e),[t,e]),o=c.useSyncExternalStore(t.subscribe,n,r),s=me(o);return s===null?null:pn(s.document)},yo=e=>{const{config:t}=F(),n=xe(),r=c.useCallback(()=>n(V.explorerHref(t,{...e,markup:!e.markup}),"browse"),[t,n,e]);return c.useMemo(()=>({shown:e.markup,toggle:r}),[e.markup,r])};function bl({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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 kl=R.forwardRef(bl),Sl=100,Tl=32767,ft=Object.freeze({maxCells:xn.SPREADSHEET_MAX_OPERATION_CELLS,maxColumns:xn.SPREADSHEET_MAX_OPERATION_CELLS/Sl,maxCellLength:Tl}),xo=44,bo=10,ko=13,it='"',Bn=(e,t)=>{let n=t;for(;n<e.length;){const r=e.charCodeAt(n);if(r===xo||r===bo||r===ko)return n;n+=1}return n};function*Rl(e,t){let n=[],r=0;for(;;){let o;if(e.startsWith(it,r)){o="";let a=r+1;for(;;){const f=e.indexOf(it,a);if(f<0){o+=e.slice(a),r=e.length;break}if(o+=e.slice(a,f),e.startsWith(it,f+1)){o+=it,a=f+2;continue}r=f+1;break}const i=Bn(e,r);o+=e.slice(r,i),r=i}else{const a=Bn(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!==xo&&(yield n,n=[],s===ko&&e.charCodeAt(r)===bo&&(r+=1),r>=e.length))return}}const Cl=(e,t,n)=>t==="csv"?Rl(e,n):n==="whole"?zt.iterateTsvRows(e):zt.iterateTsvPrefixRows(e),Ml=(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)},So=(e,t)=>{const n=[];let r=0,o=!1,s=!1;for(const i of e){const f=i.length>t.maxColumns?i.slice(0,t.maxColumns):i,w=Math.max(r,f.length);if((n.length+1)*w>t.maxCells){s=!0;break}const g=f.some(d=>d.length>t.maxCellLength)?f.map(d=>Ml(d,t.maxCellLength)):f;g!==i&&(o=!0),n.push(g),r=w}return{rows:n.map(i=>i.length===r?i:[...i,...Array(r-i.length).fill("")]),truncated:s||o,full:s}},jt=(e,t,n,r,o)=>{const s=V.decodeText(e,t,r);if(s===null)return{kind:"unreadable",code:"encoding",encodings:V.textEncodingsOf(e,t,r)};if(s.includes("\0"))return{kind:"unreadable",code:"binary"};const a=So(Cl(s,n,t?"whole":"prefix"),o);return t?a.truncated||a.rows.some(i=>i.some(f=>f!==""))?{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}),To=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 f=-1;for(const d of a.keys())d>f&&(f=d);const w=Array(Math.min(f,e.maxColumns)+1).fill("");for(const[d,p]of a)d<=e.maxColumns&&(w[d]=p);const g=Math.min(w.length,e.maxColumns);if(n===0&&(s+1)*g>e.maxCells){const d=Math.floor(e.maxCells/g);for(;t.length<d;)t.push([]);o(w);return}for(;t.length<s&&!r;)o([]);for(let d=0;d<i&&!r;d+=1)o(d===0?w:[...w])},full:()=>r,table:()=>So(t,e)}},Ol=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())},Al=({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:Ol,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))}),Ro=64*1024,Dl=e=>{let t=new Uint8Array(Math.min(e,Ro)),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}},Nl=async e=>{for(;;){const{done:t,value:n}=await e.read();if(t)return!0;if(n.byteLength>0)return!1}},Pl=async(e,t)=>{const{format:n,legacyEncoding:r,maxBytes:o,budget:s}=t,a=e.getReader(),i=Dl(o);let f=Ro;try{for(;;){const{done:w,value:g}=await a.read();if(w)return jt(i.bytes(),!0,n,r,s);const d=o-i.length();if(i.append(g.byteLength>d?g.subarray(0,d):g),i.length()===o){const h=g.byteLength<=d&&await Nl(a);return jt(i.bytes(),h,n,r,s)}if(i.length()<f)continue;f=i.length()*2;const p=jt(i.bytes(),!1,n,r,s);if(p.kind==="unreadable"&&p.code!=="long-row"||p.kind==="table"&&p.table.full)return p}}finally{a.cancel().catch(()=>{})}},Co=async(e,t,n,r)=>{const o=await e.asset(P.explorerPlainTextHref(t),r);if(o.status==="cancelled")return null;if(o.status==="error")return{kind:"failure",failure:o.failure};let s;try{s=await Pl(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},wn=(e,t,n)=>{const{documents:r,labels:o}=F(),s=ii(),a=c.useCallback(()=>r.answerStampOf(e),[r,e]),i=c.useSyncExternalStore(r.subscribe,a,a),[f,w]=c.useState(0),g=c.useMemo(()=>({read:n,stamp:i,attempt:f}),[n,i,f]),[d,p]=c.useState({settled:null,shown:null,failure:null}),h=c.useRef(null),v=c.useEffectEvent((k,L)=>{if(h.current?.settle(L.stamp,k.kind==="failure"?k.failure:null),k.kind==="read"){p({settled:L,shown:k.value,failure:null});return}if(d.shown!==null){p({settled:L,shown:d.shown,failure:null});return}p({settled:L,shown:null,failure:k.failure}),s.announceFailure(o.documentFailed(t,le(o,k.failure.reason)))});c.useEffect(()=>{const k=s.readPart();return h.current=k,()=>{h.current=null,k.release()}},[s]),c.useEffect(()=>{const k=new AbortController;return g.read(k.signal).then(L=>{L!==null&&!k.signal.aborted&&v(L,g)}),()=>k.abort()},[g]);const E=d.settled!==g&&(d.shown!==null||d.failure!==null);c.useLayoutEffect(()=>E?s.holdBusy():void 0,[E,s]);const b=c.useCallback(()=>w(k=>k+1),[]);return{shown:d.shown,failure:d.failure,retry:b}},Mo=(e,t)=>{const n={};for(const r of Object.keys(Ae.SPREADSHEET_BLOCK_LABEL_CATALOGS[t])){const o=e[nn(r)];o!==Ae.SPREADSHEET_BLOCK_LABEL_CATALOGS[t][r].text&&(n[r]=o)}return n},_l=(e,t)=>Object.fromEntries(Object.entries(Mo(e,t)).map(([n,r])=>[`spreadsheet${n.charAt(0).toUpperCase()}${n.slice(1)}`,r])),jl=(e,t)=>({..._l(e,t),loading:e.viewerLoading,errorPrefix:e.viewerErrorPrefix,styleTitle:e.viewerStyleTitle,selectStyleAria:e.viewerSelectStyle,pinStyleAria:e.viewerPinStyle,unpinStyleAria:e.viewerUnpinStyle,styleSectionTitle:e.viewerStyleSectionTitle,measureTitle:e.viewerMeasureTitle,colorsTitle:e.viewerColorsTitle,measureFill:e.viewerMeasureFill,measureReading:e.viewerMeasureReading,colorsDefault:e.viewerColorsDefault,colorsSepia:e.viewerColorsSepia,colorsDarkLowGlare:e.viewerColorsDarkLowGlare,colorsHighContrast:e.viewerColorsHighContrast,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,mermaidLoading:e.viewerMermaidLoading,mermaidInitializationFailed:e.viewerMermaidInitializationFailed,mermaidRenderFailed:e.viewerMermaidRenderFailed,mermaidEmptyDrawing:e.viewerMermaidEmptyDrawing,mermaidSource:e.viewerMermaidSource,mermaidSourceRegion:e.viewerMermaidSourceRegion,mermaidCopySource:e.viewerMermaidCopySource,mermaidCopiedSource:e.viewerMermaidCopiedSource,mermaidCopySourceFailed:e.viewerMermaidCopySourceFailed,mermaidTypeC4:e.viewerMermaidTypeC4,mermaidTypeFlowchart:e.viewerMermaidTypeFlowchart,mermaidTypeSwimlane:e.viewerMermaidTypeSwimlane,mermaidTypeEntityRelationship:e.viewerMermaidTypeEntityRelationship,mermaidTypeGitGraph:e.viewerMermaidTypeGitGraph,mermaidTypeGantt:e.viewerMermaidTypeGantt,mermaidTypeInfo:e.viewerMermaidTypeInfo,mermaidTypePie:e.viewerMermaidTypePie,mermaidTypeQuadrantChart:e.viewerMermaidTypeQuadrantChart,mermaidTypeXyChart:e.viewerMermaidTypeXyChart,mermaidTypeRequirement:e.viewerMermaidTypeRequirement,mermaidTypeSequence:e.viewerMermaidTypeSequence,mermaidTypeClass:e.viewerMermaidTypeClass,mermaidTypeState:e.viewerMermaidTypeState,mermaidTypeJourney:e.viewerMermaidTypeJourney,mermaidTypeTimeline:e.viewerMermaidTypeTimeline,mermaidTypeMindmap:e.viewerMermaidTypeMindmap,mermaidTypeKanban:e.viewerMermaidTypeKanban,mermaidTypeSankey:e.viewerMermaidTypeSankey,mermaidTypePacket:e.viewerMermaidTypePacket,mermaidTypeRadar:e.viewerMermaidTypeRadar,mermaidTypeBlock:e.viewerMermaidTypeBlock,mermaidTypeTreeView:e.viewerMermaidTypeTreeView,mermaidTypeArchitecture:e.viewerMermaidTypeArchitecture,mermaidTypeEventModeling:e.viewerMermaidTypeEventModeling,mermaidTypeIshikawa:e.viewerMermaidTypeIshikawa,mermaidTypeVenn:e.viewerMermaidTypeVenn,mermaidTypeTreemap:e.viewerMermaidTypeTreemap,mermaidTypeWardley:e.viewerMermaidTypeWardley,mermaidTypeCynefin:e.viewerMermaidTypeCynefin,mermaidTypeRailroad:e.viewerMermaidTypeRailroad,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,codeBlockCopy:e.viewerCodeBlockCopy,codeBlockCopied:e.viewerCodeBlockCopied,codeBlockCopyFailed:e.viewerCodeBlockCopyFailed,displayMathCopy:e.viewerDisplayMathCopy,displayMathCopied:e.viewerDisplayMathCopied,displayMathCopyFailed:e.viewerDisplayMathCopyFailed}),Lo=(e,t,n)=>t!==void 0?t:n!==void 0?n:e.defaultDocumentStyle,Oo=(e,t)=>e!==void 0?e:t!==void 0?t:ds.DEFAULT_CONTENT_ALIGN;class ne extends Error{refusal;constructor(t,n){super(n),this.name="WorkbookError",this.refusal=t}}const Il=new Map([["lt","<"],["gt",">"],["amp","&"],["quot",'"'],["apos","'"]]),Fl=/&(#x[0-9A-Fa-f]+|#[0-9]+|[A-Za-z_][A-Za-z0-9._-]*);/gu,$l=/([^\s=/>]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/gu,ql=/^[^\s/>]+/u,Le=e=>{throw new ne("not-workbook",`the XML ${e}`)},Un=e=>Number.isInteger(e)&&e>=0&&e<=1114111?String.fromCodePoint(e):Le(`refers to the code point ${e}`),Ao=e=>e.includes("&")?e.replace(Fl,(t,n)=>n.startsWith("#x")?Un(Number.parseInt(n.slice(2),16)):n.startsWith("#")?Un(Number.parseInt(n.slice(1),10)):Il.get(n)??Le(`names the undeclared entity ${t}`)):e,Jt=e=>e.slice(e.indexOf(":")+1),Bl=(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},Ul=e=>{const t=new Map;for(const n of e.matchAll($l))t.set(Jt(n[1]??""),Ao(n[2]??n[3]??""));return t},Do=(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?.(Ao(n.slice(o,s))),o=s),n.startsWith("<!--",s)){const w=n.indexOf("-->",s+4);if(w===-1)break;o=w+3;continue}if(n.startsWith("<![CDATA[",s)){const w=n.indexOf("]]>",s+9);if(w===-1)break;e.text?.(n.slice(s+9,w)),o=w+3;continue}const a=n.slice(s);if(a.length<9&&("<!--".startsWith(a)||"<![CDATA[".startsWith(a)))break;if(n.startsWith("<!",s)&&Le("declares a document type or another declaration"),n.startsWith("<?",s)){const w=n.indexOf("?>",s+2);if(w===-1)break;o=w+2;continue}const i=Bl(n,s+1);if(i===-1)break;const f=n.slice(s+1,i);if(f.startsWith("/"))e.end?.(Jt(f.slice(1).trim()));else{const w=f.endsWith("/"),g=w?f.slice(0,-1):f,d=ql.exec(g)?.[0]??Le("has a tag without a name"),p=Jt(d);e.start?.(p,Ul(g.slice(d.length)),w),w&&e.end?.(p)}o=i+1}n=n.slice(o)};return{write:o=>{n+=o,r()},finish:()=>{r(),!t()&&n.includes("<")&&Le("ends inside a tag, a comment or a section")}}},Je=async(e,t,n)=>{const r=Do(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 ne)throw a;Le("could not be read as UTF-8 text")}finally{s.cancel().catch(()=>{})}},Hl=101010256,Vl=33639248,zl=67324752,No=22,Gl=65535,Hn=46,Vn=30,Zl=1,zn=0,Wl=8,Kl=65535,Ue=4294967295,Xl=new TextDecoder("utf-8"),ie=e=>{throw new ne("not-workbook",`the ZIP package ${e}`)},Yl=e=>{const t=e.byteLength-No,n=Math.max(0,t-Gl);for(let r=t;r>=n;r-=1)if(e.getUint32(r,!0)===Hl)return r;return ie("has no end of central directory record")},Ql=e=>{if(e.byteLength<No)return ie("is shorter than its end record");const t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=Yl(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 ie("spans several disks");if(s===Kl||a===Ue||i===Ue)return ie("is a ZIP64 package");if(i+a>n)return ie("has a central directory past its end record");const f=new Map;let w=i;for(let g=0;g<s;g+=1){if(w+Hn>n||t.getUint32(w,!0)!==Vl)return ie("has a malformed central directory");const d=t.getUint16(w+8,!0),p=t.getUint16(w+10,!0),h=t.getUint32(w+20,!0),v=t.getUint32(w+24,!0),E=t.getUint16(w+28,!0),b=t.getUint16(w+30,!0),k=t.getUint16(w+32,!0),L=t.getUint32(w+42,!0),A=w+Hn;if(A+E>n)return ie("has a name past its central directory");const C=Xl.decode(e.subarray(A,A+E));if(h===Ue||v===Ue||L===Ue)return ie("has a ZIP64 entry");if(!C.endsWith("/")){if(f.has(C))return ie(`names ${C} twice`);f.set(C,{name:C,encrypted:(d&Zl)!==0,method:p,compressedSize:h,uncompressedSize:v,localHeaderOffset:L})}w=A+E+b+k}return{bytes:e,entries:f}},Jl=(e,t)=>{const{bytes:n}=e,r=new DataView(n.buffer,n.byteOffset,n.byteLength),o=t.localHeaderOffset;if(o+Vn>n.byteLength||r.getUint32(o,!0)!==zl)return ie(`has no local header for ${t.name}`);const s=o+Vn+r.getUint16(o+26,!0)+r.getUint16(o+28,!0),a=s+t.compressedSize;return a>n.byteLength?ie(`has the data of ${t.name} past its end`):{start:s,end:a}},Po=e=>new ReadableStream({start(t){e.byteLength>0&&t.enqueue(e),t.close()}}),ec=e=>Po(e).pipeThrough(new DecompressionStream("deflate-raw")),tc=(e,t)=>{let n=0;return new TransformStream({transform(r,o){if(n+=r.byteLength,n>t){o.error(new ne("too-large",`${e} inflates past ${t} bytes`));return}o.enqueue(r)}})},We=(e,t,n)=>{const r=e.entries.get(t);if(r===void 0)return null;if(r.encrypted)throw new ne("encrypted",`${t} is encrypted`);if(r.method!==zn&&r.method!==Wl)return ie(`compresses ${t} with method ${r.method}`);if(r.uncompressedSize>n)throw new ne("too-large",`${t} declares ${r.uncompressedSize} bytes`);const{start:o,end:s}=Jl(e,r),a=e.bytes.subarray(o,s);return(r.method===zn?Po(a):ec(a)).pipeThrough(tc(t,n))},yt=async(e,t,n)=>{const r=We(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:f}=await s.read();if(i)break;a+=o.decode(f,{stream:!0})}return a+o.decode()}catch(i){if(i instanceof ne)throw i;return ie(`has ${t}, which does not inflate to UTF-8 text`)}finally{s.releaseLock()}},Gn="content.xml",nc="META-INF/manifest.xml",_o=e=>{throw new ne("not-workbook",`the spreadsheet ${e}`)},Zn=(e,t)=>We(e,Gn,t.maxPartBytes)??_o(`has no ${Gn}`),rc=async(e,t)=>{const n=We(e,nc,t.maxPartBytes);if(n===null)return!1;let r=!1;return await Je(n,{start:o=>{o==="encryption-data"&&(r=!0)}},()=>r),r},oc=async e=>{const t=[],n=new Set;let r=null,o=0;return await Je(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}},It=e=>{const t=Number(e);return Number.isInteger(t)&&t>0?t:1},sc=async(e,t,n)=>{const r=To(n);let o=0,s=0,a=!1,i=!1,f=0,w=1,g=new Map,d=0,p=null;return await Je(e,{start:(h,v,E)=>{if(h==="table"){s===0&&(a=o===t,o+=1),E||(s+=1);return}!a||s!==1||(h==="table-row"?(w=It(v.get("number-rows-repeated")),g=new Map,d=0):h==="table-cell"||h==="covered-table-cell"?p={repeat:It(v.get("number-columns-repeated")),covered:h==="covered-table-cell",parts:[],paragraphs:0,paragraphDepth:0,annotationDepth:0}:p!==null&&p.annotationDepth===0&&(h==="annotation"&&!E?p.annotationDepth+=1:h==="p"||h==="h"?(p.paragraphs>0&&p.parts.push(`
15
+ `),p.paragraphs+=1,E||(p.paragraphDepth+=1)):p.paragraphDepth>0&&(h==="s"?p.parts.push(" ".repeat(It(v.get("c")))):h==="tab"?p.parts.push(" "):h==="line-break"&&p.parts.push(`
16
+ `))))},end:h=>{if(h==="table"){s=Math.max(0,s-1),s===0&&a&&(a=!1,i=!0);return}if(p!==null&&p.annotationDepth>0){h==="annotation"&&(p.annotationDepth-=1);return}if(!(!a||s!==1))if((h==="table-cell"||h==="covered-table-cell")&&p!==null){const v=p.covered?"":p.parts.join("");if(v!==""){const E=Math.min(d+p.repeat,n.maxColumns+1);for(let b=d;b<E;b+=1)g.set(b,v)}d+=p.repeat,p=null}else h==="table-row"?(r.addRow(f,g,w),f+=w):(h==="p"||h==="h")&&p!==null&&(p.paragraphDepth=Math.max(0,p.paragraphDepth-1))},text:h=>{p!==null&&p.annotationDepth===0&&p.paragraphDepth>0&&p.parts.push(h)}},()=>i||r.full()),r.table()},ac=async(e,t)=>{if(await rc(e,t))throw new ne("encrypted","the spreadsheet's manifest names encryption data");const{tables:n,hidingStyles:r}=await oc(Zn(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 f=>sc(Zn(e,t),i,f)})}),o.length===0&&_o("shows no table"),{sheets:o.slice(0,t.maxSheets),unshownSheets:s,unlistedSheets:Math.max(0,o.length-t.maxSheets)}},Ce=Object.freeze({kind:"general"}),ic=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,"@"]]),lc=/^\[(h+|m+|s+)\]$/iu,cc=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);lc.test(a)&&(t+=a.slice(1,-1),n=!0),r=s===-1?e.length:s}else t+=o}return{text:t.toLowerCase(),elapsed:n}},dc=e=>{const{text:t,elapsed:n}=cc(e);if(t===""||t==="general"||t.includes("@")||/[0#?.]e[+-]/u.test(t))return Ce;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 Ce;const s=/[0#?][0#?,]*(?:\.[0#?]*)?,*/u.exec(t)?.[0];if(s===void 0)return Ce;const a=/,*$/u.exec(s)?.[0].length??0,[i="",f=""]=s.slice(0,s.length-a).split("."),w=(f.match(/[0#?]/gu)??[]).length;return t.includes("%")?{kind:"percent",decimals:w}:{kind:"fixed",decimals:w,grouping:i.includes(","),scale:1e3**a}},uc=(e,t)=>{const n=t.get(e)??ic.get(e);return n===void 0?Ce:dc(n)},gn=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("+","")}`}`},Wn=(e,t,n)=>{const r=Math.abs(e).toFixed(t);if(r.includes("e"))return gn(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}`}`},fc=864e5,Kn=86400,mc=2958465,Oe=(e,t)=>String(e).padStart(t,"0"),hc=(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*fc);return`${Oe(r.getUTCFullYear(),4)}-${Oe(r.getUTCMonth()+1,2)}-${Oe(r.getUTCDate(),2)}`},pc=(e,t,n)=>{if(e<0||e>=mc+1)return gn(e);let r=Math.floor(e),o=Math.round((e-r)*Kn);o===Kn&&(r+=1,o=0);const s=Math.floor(o/3600),a=Math.floor(o%3600/60),i=`${Oe(t.elapsed?r*24+s:s,2)}:${Oe(a,2)}${t.seconds?`:${Oe(o%60,2)}`:""}`;if(t.elapsed||!t.date)return i;const f=hc(r,n);return t.time?`${f} ${i}`:f},wc=(e,t,n)=>{switch(t.kind){case"general":return gn(e);case"date-time":return pc(e,t,n);case"percent":return`${Wn(e*100,t.decimals,!1)}%`;case"fixed":return Wn(e/t.scale,t.decimals,t.grouping)}},jo="_rels/.rels",fe=e=>{throw new ne("not-workbook",`the workbook ${e}`)},vn=(e,t)=>{const n=Do(t,()=>!1);n.write(e),n.finish()},gc=(e,t)=>{try{return decodeURIComponent(e)}catch{return fe(`points to a malformed part name (${t})`)}},vc=(e,t)=>{const r=[...t.startsWith("/")?[]:e.split("/").slice(0,-1)];for(const o of t.split("/"))o===""||o==="."||(o===".."?(r.length===0&&fe(`points above its root (${t})`),r.pop()):r.push(gc(o,t)));return r.join("/")},Ec=e=>{const t=e.lastIndexOf("/");return`${e.slice(0,t+1)}_rels/${e.slice(t+1)}.rels`},Xn=async(e,t,n)=>{const r=await yt(e,t===""?jo:Ec(t),n.maxPartBytes),o=new Map;return r===null||vn(r,{start:(s,a)=>{if(s!=="Relationship")return;const i=a.get("Id"),f=a.get("Type"),w=a.get("Target");i===void 0||f===void 0||w===void 0||a.get("TargetMode")==="External"||o.set(i,{type:f,target:vc(t,w)})}}),o},Ft=(e,t)=>{for(const n of e.values())if(n.type.endsWith(`/${t}`))return n.target;return null},yc=e=>{const t=[];let n=!1;return vn(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}},xc=async e=>{const t=[];let n=null,r=!1,o=0;return await Je(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},bc=e=>{const t=new Map,n=[];let r=!1;return vn(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=>uc(o,t))},kc=/^(\d{4}-\d{2}-\d{2})(?:T(\d{2}:\d{2}(?::\d{2})?)(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?$/u,Sc=e=>{const t=kc.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}`},Tc=/^([A-Za-z]{1,3})(\d+)$/u,Rc=e=>{const t=Tc.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},Cc=(e,t,n,r)=>{const o=e.value.join("");switch(e.type){case"s":return o===""?"":t[Number(o)]??fe(`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 Sc(o.trim());default:{const s=o.trim();if(s==="")return"";const a=Number(s);return Number.isFinite(a)?wc(a,n[e.style]??Ce,r):s}}},Mc=async(e,t,n,r,o)=>{const s=To(t);let a=-1,i=new Map,f=0,w=null;return await Je(e,{start:(g,d,p)=>{if(g==="row"){const h=Number(d.get("r"));a=Number.isInteger(h)&&h>a+1?h-1:a+1,i=new Map,f=0}else if(g==="c"){const h=Rc(d.get("r")??"")??f,v=Number(d.get("s")??"0");w={column:h,type:d.get("t")??"n",style:Number.isInteger(v)?v:0,value:[],inline:[],inValue:!1,inInlineText:!1,phoneticDepth:0}}else w!==null&&(g==="v"?w.inValue=!p:g==="rPh"&&!p?w.phoneticDepth+=1:g==="t"&&w.type==="inlineStr"&&w.phoneticDepth===0&&(w.inInlineText=!p))},end:g=>{if(g==="c"&&w!==null){const d=Cc(w,n,r,o);d!==""&&i.set(w.column,d),f=w.column+1,w=null}else g==="row"?s.addRow(a,i,1):w!==null&&(g==="v"?w.inValue=!1:g==="rPh"?w.phoneticDepth=Math.max(0,w.phoneticDepth-1):g==="t"&&(w.inInlineText=!1))},text:g=>{w!==null&&(w.inValue?w.value.push(g):w.inInlineText&&w.inline.push(g))}},s.full),s.table()},Lc=async(e,t)=>{const n=Ft(await Xn(e,"",t),"officeDocument")??fe("has no officeDocument relationship"),r=await yt(e,n,t.maxPartBytes)??fe(`has no part ${n}`),{sheets:o,date1904:s}=yc(r),a=await Xn(e,n,t),i=Ft(a,"sharedStrings"),f=i===null?null:We(e,i,t.maxPartBytes),w=f===null?[]:await xc(f),g=Ft(a,"styles"),d=g===null?null:await yt(e,g,t.maxPartBytes),p=d===null?[]:bc(d),h=[];let v=0;for(const E of o){const b=a.get(E.relationship)??fe(`lists the sheet ${E.name} without its relationship`);if(E.state!=="visible"||!b.type.endsWith("/worksheet")){v+=1;continue}e.entries.has(b.target)||fe(`has no part ${b.target} for the sheet ${E.name}`),h.push({name:E.name,read:async k=>{const L=We(e,b.target,t.maxPartBytes)??fe(`has no part ${b.target}`);return Mc(L,k,w,p,s)}})}return h.length===0&&fe("shows no sheet"),{sheets:h.slice(0,t.maxSheets),unshownSheets:v,unlistedSheets:Math.max(0,h.length-t.maxSheets)}},Oc=Object.freeze([80,75,3,4]),Ac=Object.freeze([208,207,17,224,161,177,26,225]),$t=Uint8Array.from([..."EncryptedPackage"].flatMap(e=>[e.charCodeAt(0),0])),Dc=new Set(["application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.spreadsheet-template"]),Nc="mimetype",Io=(e,t)=>e.byteLength>=t.length&&t.every((n,r)=>e[r]===n),Fo=e=>Io(e,Oc),$o=e=>Io(e,Ac),Pc=e=>{const t=e.byteLength-$t.byteLength;for(let n=0;n<=t;n+=1)if(e[n]===$t[0]&&$t.every((r,o)=>e[n+o]===r))return!0;return!1},_c=async(e,t)=>{if($o(e))throw Pc(e)?new ne("encrypted","the bytes are a password-protected workbook"):new ne("not-workbook","the bytes are a compound file (a legacy .xls)");if(!Fo(e))throw new ne("not-workbook","the bytes are no ZIP package");const n=Ql(e),r=await yt(n,Nc,t.maxPartBytes);if(r!==null&&Dc.has(r.trim()))return ac(n,t);if(n.entries.has(jo))return Lc(n,t);throw new ne("not-workbook","the ZIP package is neither an OpenDocument spreadsheet nor an Office Open XML package")},jc=async(e,t)=>{const n=e.getReader(),r=[];let o=0;try{for(;;){const{done:i,value:f}=await n.read();if(i)break;if(o+=f.byteLength,o>t)return null;r.push(f)}}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},qo=async(e,t)=>{try{return{kind:"table",table:await e.read(t)}}catch(n){return{kind:"refused",refusal:n instanceof ne?n.refusal:"not-workbook"}}},Ic=async(e,t,n,r,o)=>{const s=await e.asset(P.explorerWorkbookHref(t),o);if(s.status==="cancelled")return null;if(s.status==="error")return{kind:"failure",failure:s.failure};let a;try{a=await jc(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(!(Fo(a)||$o(a)))return{kind:"not-package"};try{const i=await _c(a,n.limits),f=r===null?-1:i.sheets.findIndex(p=>p.name===r),w=Math.max(f,0),g=i.sheets[w];if(g===void 0)return{kind:"refused",refusal:"not-workbook"};const d=await qo(g,n.budget);return o.aborted?null:{kind:"workbook",workbook:i,selected:w,sheet:d}}catch(i){return i instanceof ne?{kind:"refused",refusal:i.refusal}:o.aborted?null:{kind:"failure",failure:{reason:"failed"}}}},Fc=Object.freeze({className:"aqmx-document-spreadsheet-body","data-aqmx-document-scroller":""}),$c=(e,t)=>{switch(t.code){case"encoding":return e.spreadsheetUnreadableEncoding(t.encodings);case"binary":return e.spreadsheetNotText;case"long-row":return e.spreadsheetLongRow}},Yn=(e,t)=>{switch(t){case"encrypted":return e.spreadsheetWorkbookEncrypted;case"not-workbook":return e.spreadsheetNotWorkbook;case"too-large":return e.spreadsheetWorkbookTooLarge}},qt=e=>e.every(t=>t.every(n=>n==="")),Bo=({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(Ye,{name:e,openUrl:n,downloadUrl:t,icon:l.jsx(kl,{})}),l.jsx(Xe,{scrollerProps:Fc,children:l.jsx("div",{className:"aqmx-document-spreadsheet-column",children:o})})]}),Uo=({rows:e,title:t})=>{const{labels:n,locale:r,theme:o}=F(),s=c.use(Ee),a=c.useMemo(()=>({...Mo(n,r),table:t,fullscreenDialog:n.spreadsheetFullscreen(t)}),[n,r,t]),i=c.useMemo(()=>zt.serializeTsv(e),[e]),f=mn();return l.jsx("div",{className:"aqmx-document-spreadsheet","data-theme":o,children:l.jsx(De.SpreadsheetBlock,{tsv:i,layout:s==="fill"?"fill":"inline",locale:r,labels:a,tapScrollCircle:eo(f),scrollBarControls:cn(f)})})},ze=({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})]})})},Ho=({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(Uo,{rows:e.rows,title:t})]});case"empty":return l.jsx(ze,{note:r.spreadsheetEmpty,testId:"markdown-explorer-spreadsheet-empty"});case"unreadable":return l.jsx(ze,{note:$c(r,e),testId:"markdown-explorer-spreadsheet-unreadable",code:e.code,download:{url:n,name:t}})}},qc=({path:e,document:t})=>t.format==="workbook"?l.jsx(Uc,{path:e,document:t}):l.jsx(Bc,{path:e,document:t,format:t.format}),Bc=({path:e,document:t,format:n})=>{const{config:r,data:o,labels:s}=F(),{name:a,url:i}=t,f=c.useCallback(async p=>{const h=await Co(o,i,{format:n,legacyEncoding:r.legacyTextEncoding,maxBytes:r.spreadsheets.maxBytes,budget:ft},p);return h===null||h.kind==="failure"?h:{kind:"read",value:h}},[o,i,n,r.legacyTextEncoding,r.spreadsheets.maxBytes]),{shown:w,failure:g,retry:d}=wn(e,a,f);return l.jsxs(Bo,{name:a,url:i,openUrl:P.explorerPlainTextHref(i),state:w===null?g===null?"loading":"failure":w.kind,children:[w===null&&g===null?l.jsx(ye,{label:s.spreadsheetLoading,testId:"markdown-explorer-spreadsheet-skeleton"}):null,w===null&&g!==null?l.jsx("div",{className:"aqmx-document-spreadsheet-failure",children:l.jsx(ve,{failure:g,alert:!1,onRetry:d,testId:"markdown-explorer-spreadsheet-failure"})}):null,w===null?null:l.jsx(Ho,{reading:w,name:a,url:i})]})},Uc=({path:e,document:t})=>{const{config:n,data:r,labels:o}=F(),{name:s,url:a,firstSheetText:i}=t,f=c.useId(),w=c.useRef(null),g=c.useCallback(async Z=>{const Q=await Ic(r,a,{maxBytes:n.spreadsheets.maxWorkbookBytes,limits:Ll,budget:ft},w.current,Z);if(Q===null||Q.kind==="failure")return Q;if(Q.kind==="workbook")return{kind:"read",value:Q};if(i!==null){const u=await Co(r,a,{format:i,legacyEncoding:n.legacyTextEncoding,maxBytes:n.spreadsheets.maxBytes,budget:ft},Z);return u===null||u.kind==="failure"?u:{kind:"read",value:{kind:"first-sheet",reading:u}}}return{kind:"read",value:{kind:"refused",refusal:Q.kind==="not-package"?"not-workbook":Q.refusal}}},[r,a,i,n.legacyTextEncoding,n.spreadsheets.maxBytes,n.spreadsheets.maxWorkbookBytes]),{shown:d,failure:p,retry:h}=wn(e,s,g),[v,E]=c.useState(null),b=c.useRef(new WeakMap),k=d?.kind==="workbook"?d:null,L=k===null?null:v!==null&&v.workbook===k.workbook?v:{workbook:k.workbook,index:k.selected,reading:k.sheet},A=Z=>{if(k===null)return;const Q=k.workbook.sheets[Z];if(Q===void 0)return;w.current=Q.name;let u=b.current.get(k.workbook);u===void 0&&(u=new Map([[k.selected,k.sheet]]),b.current.set(k.workbook,u));const m=u.get(Z),S={workbook:k.workbook,index:Z,reading:m??null};if(E(S),m!==void 0)return;const x=u;qo(Q,ft).then(O=>{x.set(Z,O),E($=>$===S?{...S,reading:O}:$)})},C=L===null?null:L.reading===null?"loading":L.reading.kind==="refused"?"unreadable":qt(L.reading.table.rows)?"empty":"table",M=d===null?p===null?"loading":"failure":d.kind==="first-sheet"?d.reading.kind:d.kind==="refused"?"unreadable":C??"loading",B=i===null?a:P.explorerPlainTextHref(a),I=Z=>`${f}-sheet-${Z}`,H=`${f}-panel`,_=L===null?null:k?.workbook.sheets[L.index]?.name??null,U=k!==null&&k.workbook.sheets.length>1;return l.jsxs(Bo,{name:s,url:a,openUrl:B,state:M,children:[d===null&&p===null?l.jsx(ye,{label:o.spreadsheetLoading,testId:"markdown-explorer-spreadsheet-skeleton"}):null,d===null&&p!==null?l.jsx("div",{className:"aqmx-document-spreadsheet-failure",children:l.jsx(ve,{failure:p,alert:!1,onRetry:h,testId:"markdown-explorer-spreadsheet-failure"})}):null,d?.kind==="refused"?l.jsx(ze,{note:Yn(o,d.refusal),testId:"markdown-explorer-spreadsheet-unreadable",code:d.refusal,download:{url:a,name:s}}):null,d?.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(Ho,{reading:d.reading,name:s,url:a})]}):null,k===null||L===null||_===null?null:l.jsxs(l.Fragment,{children:[k.workbook.unshownSheets>0?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-unshown-sheets",children:o.spreadsheetUnshownSheets(k.workbook.unshownSheets)}):null,k.workbook.unlistedSheets>0?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-spreadsheet-unlisted-sheets",children:o.spreadsheetUnlistedSheets(k.workbook.sheets.length)}):null,U?l.jsx(Al,{names:k.workbook.sheets.map(Z=>Z.name),selected:L.index,onSelect:A,label:o.spreadsheetSheets(s),tabIdOf:I,panelId:H}):null,l.jsxs("div",{className:"aqmx-document-spreadsheet-sheet","data-testid":"markdown-explorer-spreadsheet-sheet","data-aqmx-sheet":L.index,...U?{role:"tabpanel",id:H,"aria-labelledby":I(L.index)}:{},children:[L.reading===null?l.jsx(ye,{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(ze,{note:Yn(o,L.reading.refusal),testId:"markdown-explorer-spreadsheet-unreadable",code:L.reading.refusal,download:{url:a,name:s}}):null,L.reading?.kind==="table"&&qt(L.reading.table.rows)?l.jsx(ze,{note:o.spreadsheetSheetEmpty,testId:"markdown-explorer-spreadsheet-empty"}):null,L.reading?.kind==="table"&&!qt(L.reading.table.rows)?l.jsx(Uo,{rows:L.reading.table.rows,title:o.spreadsheetSheetName(s,_)},L.index):null]})]})]})},Vo=Object.freeze({kind:"empty"}),Hc=(e,t,n)=>{if(t.view==="multi"||t.overrides[n]===void 0)return null;const r=n==="style"?{align:t.overrides.align}:{style:t.overrides.style};return V.explorerHref(e,{...t,overrides:r})},Me=({kind:e,view:t,label:n,stale:r,busy:o,frameRef:s,intent:a,children:i})=>{const f=c.use(Ee);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":f,className:"aqmx-document",...a,children:[r?l.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,i]})},Vc=Object.freeze({invalid:"documentIdInvalid","not-found":"documentIdNotFound",forbidden:"documentIdForbidden"}),Qn=(e,t)=>{const n=Vc[t];return n===void 0?void 0:{title:e.documentIdFailedTitle,body:e[n]}},zc=({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,f=e.kind==="document-id"?e.failure:null;switch(c.useEffect(()=>{t&&s!==null&&o.announce(r.folderReadmeMissing(P.lastPathSegment(s)))},[t,s,o,r]),c.useEffect(()=>{a!==null&&i!==null&&n(r.documentFailed(P.lastPathSegment(a),le(r,i.reason)))},[a,i,n,r]),c.useEffect(()=>{if(f===null)return;const w=Qn(r,f.reason);n(r.announcementSequence([r.documentIdFailedTitle,w===void 0?le(r,f.reason):w.body]))},[f,n,r]),e.kind){case"empty":return l.jsx(Me,{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(En,{label:r.documentRegion});case"no-readme":return l.jsx(Me,{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(P.lastPathSegment(e.folder))})})});case"failure":return l.jsx(Me,{kind:"failure",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx(wt,{failure:e.failure,onRetry:e.onRetry,testId:"markdown-explorer-folder-failure"})});case"document-id":return l.jsx(Me,{kind:"failure",label:r.documentRegion,stale:!1,busy:!1,children:l.jsx(wt,{failure:e.failure,onRetry:e.onRetry,testId:"markdown-explorer-document-id-failure",text:Qn(r,e.failure.reason)})})}},En=({label:e})=>{const{labels:t}=F();return l.jsx(Me,{kind:"loading",label:e,stale:!1,busy:!0,children:l.jsx(ye,{label:t.documentLoading,testId:"markdown-explorer-document-skeleton"})})},Jn=Object.freeze(["wheel","touchstart","pointerdown","keydown"]),Gc=({path:e,document:t,viewer:n,editing:r})=>{const{reportMathDiagnostics:o,edits:s}=F(),a=c.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),i=sl(),f=al(),w=c.useMemo(()=>o===void 0?void 0:M=>o(e,M),[o,e]),g=c.useRef(null),{editable:d,doubleClick:p,region:h,paneScroll:v,stale:E}=r;c.useLayoutEffect(()=>{if(d)return s.bindView(e,{anchor:()=>{const M=g.current,B=h(),I=M===null?null:M.querySelector(bt);return M===null||B===null||I===null?null:qr(M,v.scrollerOf(B,I))}})},[s,e,d,h,v]);const b=M=>{const B=g.current,{target:I}=M;!p||B===null||!(I instanceof Element)||!Fr(I)||(M.stopPropagation(),s.start(e,$r(I,B,B.ownerDocument.getSelection())))},k=c.useRef(null),L=c.useRef(E);c.useLayoutEffect(()=>{L.current=E});const A=c.useEffectEvent(M=>{const B=g.current,I=h(),H=B===null?null:Hr(B,M.line);if(I===null||H===null)return!1;const _=v.scrollerOf(I,H);return _.scrollTop+=Vr(H,M.line)-M.clientTop,!0}),C=c.useEffectEvent(M=>{const B=h();if(B===null)return;const I=()=>{for(const _ of Jn)B.removeEventListener(_,H,!0);k.current?.release===I&&(k.current=null)},H=()=>I();for(const _ of Jn)B.addEventListener(_,H,{capture:!0,passive:!0});k.current={point:M,release:I}});return c.useLayoutEffect(()=>{const M=s.takeReturn(e);if(M!==null)return queueMicrotask(()=>{A(M)&&L.current&&C(M)}),()=>k.current?.release()},[s,e]),c.useLayoutEffect(()=>{const M=k.current;M===null||E||(M.release(),A(M.point))},[t,E]),l.jsx("div",{ref:g,className:"aqmx-document-viewer",onDoubleClick:b,children:l.jsx(De.MarkdownViewer,{...n,onHeadingSelect:i,headingHref:f,onMathDiagnostics:w,parseResult:a,content:null})})},zo=({document:e,viewer:t})=>{const{labels:n}=F();return l.jsxs(l.Fragment,{children:[l.jsx(Ye,{name:e.name,openUrl:P.explorerPlainTextHref(e.url),downloadUrl:e.url,icon:l.jsx(ma,{}),children:e.truncated?null:l.jsx(ai,{text:e.text})}),e.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-text-truncated",children:n.textTruncated}):null,l.jsx("div",{className:"aqmx-document-viewer",children:l.jsx(De.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},Bt=({path:e,name:t,viewer:n})=>{const{data:r,labels:o}=F(),s=c.useCallback(async w=>{const g=await r.text(e,w);return"kind"in g?g.kind==="failure"?{kind:"failure",failure:g.failure}:{kind:"read",value:g}:null},[r,e]),{shown:a,failure:i,retry:f}=wn(e,t,s);return a!==null?l.jsx(zo,{document:a,viewer:n}):i!==null?l.jsx(wt,{failure:i,onRetry:f,testId:"markdown-explorer-markup-failure"}):l.jsx(ye,{label:o.markupLoading,testId:"markdown-explorer-markup-skeleton"})},Zc=Object.freeze({reason:"failed"}),Wc=e=>{const{labels:t}=F();return l.jsx(wa,{fallback:n=>l.jsx("div",{className:"aqmx-edit-message",children:l.jsx(ve,{failure:Zc,alert:!1,onRetry:n,testId:"markdown-explorer-edit-load-failure"})}),children:l.jsx(c.Suspense,{fallback:l.jsx(ye,{label:t.editLoading,testId:"markdown-explorer-edit-skeleton"}),children:l.jsx(pa,{...e})})})},Kc=({path:e,document:t,view:n,viewer:r,contentViewer:o,onRetry:s,editing:a})=>{switch(t.kind){case"markdown":{const{session:i,layout:f,region:w,paneScroll:g,stale:d}=a;if(n==="edit"&&i!==void 0)return l.jsx(Wc,{path:e,name:t.name,session:i,layout:f,viewer:o,region:w,paneScroll:g});if(n==="markup")return l.jsx(Bt,{path:e,name:t.name,viewer:o});const p=t.edit!==null&&(t.edit.kind==="inline"||t.edit.kind==="draft");return l.jsx(Gc,{path:e,document:t,viewer:o,editing:{editable:p,doubleClick:p&&f==="fill",region:w,paneScroll:g,stale:d}})}case"text":return l.jsx(zo,{document:t,viewer:o});case"image":return n==="markup"&&pn(t)==="svg"?l.jsx(Bt,{path:e,name:t.name,viewer:r}):l.jsx(Zi,{document:t});case"media":return l.jsx(yl,{document:t});case"spreadsheet":return n==="markup"?l.jsx(Bt,{path:e,name:t.name,viewer:r}):l.jsx(qc,{path:e,document:t});case"file":return l.jsx(Ei,{document:t});case"failure":return l.jsx(wt,{failure:t.failure,onRetry:s,testId:"markdown-explorer-document-failure"});default:{const i=t;throw new RangeError(`[markdown-explorer] unknown document kind ${z.describeValue(i.kind)}`)}}},Xc=e=>{const{document:t,viewer:n}=e,r=t.kind==="markdown"||t.kind==="text"?t.lang:void 0,o=c.useMemo(()=>r===void 0?n:{...n,contentLang:r},[n,r]);return l.jsx(go,{value:r,children:l.jsx(Kc,{...e,contentViewer:o})})},Yc='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',er=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:fo(e,n),r===void 0?null:uo(e,r.id),e.querySelector(bt),e.querySelector(Yc)];for(const s of o)if(s instanceof HTMLElement&&ln(s))return s;return null},tr=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&ln(t)},Qc=e=>{const t=c.useRef(!1);return c.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=p=>{s=!(p.target instanceof Node&&n.contains(p.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(a),a=setTimeout(()=>{s=!1},0)},f=p=>{t.current=p.target instanceof Node&&n.contains(p.target)},w=p=>{p.relatedTarget===null&&s&&(t.current=!1)},g=()=>{const{activeElement:p,body:h}=r;p!==null&&p!==h&&(t.current=n.contains(p))},d=()=>{s&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",i,!0),o.addEventListener("mousedown",i,!0),o.addEventListener("focusin",f,!0),o.addEventListener("blur",g),o.addEventListener("focus",d),n.addEventListener("focusout",w),()=>{clearTimeout(a),o.removeEventListener("pointerdown",i,!0),o.removeEventListener("mousedown",i,!0),o.removeEventListener("focusin",f,!0),o.removeEventListener("blur",g),o.removeEventListener("focus",d),n.removeEventListener("focusout",w)}},[e]),t},Jc=Object.freeze({count:0,recovered:!1}),ed=({path:e,snapshot:t,markup:n,stale:r,viewer:o,editLayout:s,regionLabel:a,navigation:i,fragment:f,paneScroll:w,announces:g,announceFailure:d,onDocumentShown:p})=>{const{labels:h,announcer:v,documents:E}=F(),{document:b}=t,k=c.useRef(null),L=c.useRef(null),A=c.useRef(null),C=c.useRef(null),[M,B]=c.useState(null),I=c.useRef(null),H=Qc(k),_=c.useRef({path:e,document:b}),U=c.useRef(null),Z=c.useCallback(G=>{const Y=k.current,ee=Pn(Y,G,w);Y!==null&&ee!==null&&tr(Y,ee,H.current)},[w,H]),Q=c.useCallback((G,Y)=>{const ee=C.current;setTimeout(()=>{Y.defaultPrevented||c.startTransition(()=>B({fragment:G,from:ee}))},0)},[]),u=c.useCallback(G=>{setTimeout(()=>{G.defaultPrevented||Z("#")},0)},[Z]),m=c.useMemo(()=>({navigation:i,currentPath:e,scrollWithin:Z,followFragmentJump:Q,followEmptyFragment:u}),[i,e,Z,Q,u]),S=c.useCallback(()=>E.retry(e),[E,e]),x=Gr(E,Qi),O=Nr(e),$=O!==void 0?"edit":n?"markup":"rendered",y=pn(b)===null?void 0:$,T=c.useCallback(()=>k.current,[]),D=c.useCallback(()=>{const G=k.current;G!==null&&er(G,b,null)},[b]),N=c.useMemo(()=>({session:O,layout:s,region:T,paneScroll:w,stale:r}),[O,s,T,w,r]),q=y==="edit"?!1:r,X=c.use(Ee),K=y==="edit"&&s==="fill"?"fill":X,[W,oe]=c.useState(0),he=c.useRef(0),ce=c.useRef(!1),[Pe,et]=c.useState(Jc),[be,Rt]=c.useState(0),_e=c.useRef(d),je=c.useRef(r);c.useLayoutEffect(()=>{_e.current=d,je.current=r},[d,r]);const pe=c.useMemo(()=>({announceFailure:G=>{je.current||_e.current(G)},readPart:()=>{const G=E.readPart(e);he.current+=1;let Y=!1,ee=!1,se=!1;return{settle:(Se,Te)=>{if(G.settle(Se,Te),!(se||Y)){if(Te!==null){ee=!0,ce.current=!1;return}Y=!0,et(rt=>({count:rt.count+1,recovered:ee}))}},release:()=>{se||(se=!0,G.release(),he.current-=1,Y||Rt(Se=>Se+1))}}},holdBusy:()=>{oe(Y=>Y+1);let G=!0;return()=>{G&&(G=!1,oe(Y=>Y-1))}}}),[E,e]),Ie=q||W>0,tt=c.useEffectEvent((G,Y)=>{const ee=L.current;if(ee!==null&&ee.path===G&&ee.snapshot===Y)return;L.current={path:G,snapshot:Y},E.noteShown(G,Y);const se=Y.document;if(se.kind==="failure"){ce.current=!1,E.noteFailureShown(Y)&&d(h.documentFailed(P.lastPathSegment(G),le(h,se.failure.reason)));return}p?.(G,se),!(!g||ee!==null&&ee.path===G&&ee.snapshot.document.kind!=="failure")&&(ce.current=he.current>0,ce.current||v.announce(h.documentShown(se.name)))});c.useEffect(()=>{tt(e,t)},[e,t]);const nt=c.useEffectEvent(()=>{f.kind==="panel"&&f.consume()}),Fe=c.useEffectEvent(G=>{const Y=k.current;if(Y===null||!H.current)return null;const{activeElement:ee,body:se}=Y.ownerDocument;return ee!==null&&ee!==se?null:er(Y,b,G)}),Ct=c.useEffectEvent(G=>{const Y=ce.current;ce.current=!1,!r&&(G&&Fe(null),g&&(G||Y)&&b.kind!=="failure"&&v.announce(h.documentShown(b.name)))});c.useEffect(()=>{Pe.count>0&&Ct(Pe.recovered)},[Pe]);const j=c.useEffectEvent(()=>{he.current>0||!ce.current||(ce.current=!1,g&&!r&&b.kind!=="failure"&&v.announce(h.documentShown(b.name)))});c.useEffect(()=>{be>0&&j()},[be]);const J=c.useEffectEvent(G=>{const Y=k.current;Y!==null&&tr(Y,G,H.current)}),te=c.useEffectEvent(G=>w.reveal(G)),ke=c.useEffectEvent(G=>Pn(k.current,G,w));return c.useEffect(()=>{if(r)return;const G=_.current.path!==e,Y=G||_.current.document!==b;_.current={path:e,document:b};const ee=U.current!==e;U.current=e;let se=null;f.kind==="page"?A.current!==f.navigation&&(A.current=f.navigation,se=f.fragment):f.fragment!==null&&(se=f.fragment,nt());const Se=()=>{const Te=se===null?null:ke(se);if(!Y){Te!==null&&J(Te);return}const rt=Fe(f.fragment);G&&Te===null&&rt!==null&&te(rt)};ee?queueMicrotask(Se):Se()},[f,e,b,r]),c.useLayoutEffect(()=>{C.current=f.kind==="page"?f.navigation:null},[f]),c.useEffect(()=>{M===null||M===I.current||r||(I.current=M,!(f.kind==="page"&&f.navigation!==M.from)&&Z(M.fragment))},[M,f,r,Z]),l.jsxs(Ee,{value:K,children:[l.jsx(ui,{path:e,name:b.kind==="failure"?P.lastPathSegment(e):b.name,editing:O!==void 0,announces:g,markup:n,region:k,focusDocument:D}),l.jsx(Me,{kind:b.kind,view:y,label:a(e,b),stale:Ie,busy:Ie,frameRef:k,intent:x,children:l.jsx(wo,{value:m,children:l.jsx(Xi,{children:l.jsx(so,{value:pe,children:l.jsx(Xc,{path:e,document:b,view:$,viewer:o,onRetry:S,editing:N},e)})})})})]})},yn=Object.freeze({kind:"skeleton"}),td=(e,t,n,r,o)=>{if(t?.status==="loaded")return{kind:"document",path:e,snapshot:t,stale:!1};const s=me(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:me(r);return n===null||a===null?yn:{kind:"document",path:n,snapshot:a,stale:!0}},nd=(e,t)=>t.status==="deferred"?yn:{kind:"document",path:e,snapshot:t,stale:!1},rd=({requestedPath:e,content:t,markup:n,...r})=>{const o=t.kind==="streaming"?nd(t.path,c.use(t.promise)):t;return o.kind!=="document"?l.jsx(En,{label:r.regionLabel(e,null)}):l.jsx(ed,{path:o.path,snapshot:o.snapshot,markup:n,stale:o.stale,...r})},Go=({path:e,absence:t,markup:n,display:r,navigation:o,fragment:s,paneScroll:a,announces:i,announceFailure:f,onDocumentShown:w})=>{const{config:g,labels:d,locale:p,theme:h,documents:v,data:E,fetch:b}=F(),k=De.useMarkdownToolbarState(),L=c.useRef(!1);c.useLayoutEffect(()=>{L.current=!0},[]);const[A,C]=c.useState(null),[M,B]=c.useState(n),I=c.useCallback(()=>e===null?void 0:v.peek(e),[v,e]),H=c.useSyncExternalStore(v.subscribe,I,I),_=c.useCallback(()=>A===null?void 0:v.peek(A),[v,A]),U=c.useSyncExternalStore(v.subscribe,_,_);c.useLayoutEffect(()=>e===null?void 0:v.open(e),[v,e]),c.useLayoutEffect(()=>A===null?void 0:v.retain(A),[v,A]);const Z=e===null?yn:td(e,H,A,U,!L.current),Q=e===null?null:Z.kind==="document"&&!Z.stale?Z.path:A;Q!==A&&C(Q);const u=Z.kind!=="document"||Z.path===e;u&&n!==M&&B(n);const m=c.useMemo(()=>jl(d,p),[d,p]),S=c.useMemo(()=>({read:(N,q)=>Wi(E,N,q)}),[E]),x=c.useMemo(()=>[...g.iframeHosts],[g]),O=o.kind==="panel",$=mn(),y=c.useMemo(()=>({labels:m,labelsLang:p,spreadsheetLocale:p,spreadsheetTapScrollCircle:eo($),spreadsheetScrollBarControls:cn($),emptyMessage:d.documentEmpty,theme:h,availableStyles:g.documentStyles,iFrameAllowedDomains:x,embeds:g.embeds,fetch:b,linkComponent:ol,toolbar:k,style:r.style,onStyleChange:r.onStyleChange,align:r.align,onAlignChange:r.onAlignChange,measure:r.measure,onMeasureChange:r.onMeasureChange,contentColors:r.documentColors,onContentColorsChange:r.onDocumentColorsChange,showToc:r.showToc,showStyle:r.showStyle,showAlign:r.showAlign,showMeasure:r.showMeasure,showContentColors:r.showContentColors,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:O?void 0:Wr,scrollBarInlineSize:O?void 0:dn,scrollBarGutter:O?void 0:fn,imageSource:S}),[m,p,$,d.documentEmpty,h,g.documentStyles,x,g.embeds,b,k,r,O,S]),T=c.useCallback((N,q)=>O?q===null||q.kind==="failure"?P.lastPathSegment(N):q.name:d.documentRegion,[O,d.documentRegion]),D=O?"content":"fill";return e===null?l.jsx(Ee,{value:D,children:l.jsx(zc,{absence:t,announces:i,announceFailure:f})}):l.jsx(Ee,{value:D,children:l.jsx(c.Suspense,{fallback:l.jsx(En,{label:T(e,null)}),children:l.jsx(rd,{requestedPath:e,content:Z,markup:u?n:M,viewer:y,editLayout:r.editLayout,regionLabel:T,navigation:o,fragment:s,paneScroll:a,announces:i,announceFailure:f,onDocumentShown:w})})})},Zo=()=>{const{viewSettings:e}=F(),t=ge(s=>s.measure),n=ge(s=>s.documentColors),r=c.useCallback(s=>e.update({measure:s}),[e]),o=c.useCallback(s=>e.update({documentColors:s}),[e]);return c.useMemo(()=>({measure:t,onMeasureChange:r,documentColors:n,onDocumentColorsChange:o}),[t,r,n,o])},od=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:a,announcer:i}=F(),f=ge(_=>_.style),w=ge(_=>_.align),g=xe(),d=re.useLocation(),p=Ke(),{overrides:h,embed:v}=r,E=c.useCallback(_=>{if(p.kind!=="location")return;const U=Hc(s,p.location,_);U!==null&&g(U,"browse")},[s,g,p]),b=c.useCallback(_=>{a.update({style:_}),E("style")},[a,E]),k=c.useCallback(_=>{a.update({align:_}),E("align")},[a,E]),L=Lo(s,h.style,f),A=Oo(h.align,w),C=Zo(),M=c.useMemo(()=>({style:L,onStyleChange:b,align:A,onAlignChange:k,...C,showToc:v.showToc!==!1,showStyle:v.showStyle!==!1,showAlign:v.showAlign!==!1,showMeasure:v.showStyle!==!1,showContentColors:v.showStyle!==!1,padding:v.padding,width:v.width,maxWidth:v.maxWidth,editLayout:"fill"}),[L,b,A,k,C,v]),B=r,I=c.useMemo(()=>({kind:"page",fragment:d.hash,navigation:d}),[d]),H=c.useCallback(_=>i.announce(_),[i]);return l.jsx(Go,{path:e,absence:t,markup:n,display:M,navigation:B,fragment:I,paneScroll:Oi,announces:!0,announceFailure:H,onDocumentShown:o})},sd=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>{const{config:s,viewSettings:a}=F(),i=ge(I=>I.style),f=ge(I=>I.align),[w,g]=c.useState(()=>Lo(s,void 0,i)),d=Oo(void 0,f),p=c.useCallback(I=>a.update({align:I}),[a]),h=Zo(),{maximized:v,onDocumentLink:E,pendingHash:b,onHashConsumed:k,announceFailure:L,paneScroll:A}=r,C=c.useMemo(()=>({style:w,onStyleChange:g,align:d,onAlignChange:p,...h,showToc:v,showStyle:v,showAlign:v,showMeasure:v,showContentColors:v,padding:void 0,width:void 0,maxWidth:void 0,editLayout:v?"fill":"content"}),[w,d,p,h,v]),M=c.useMemo(()=>({kind:"panel",onDocumentLink:E}),[E]),B=c.useMemo(()=>({kind:"panel",fragment:b,consume:k}),[b,k]);return l.jsx(Go,{path:e,absence:t,markup:n,display:C,navigation:M,fragment:B,paneScroll:A,announces:!1,announceFailure:L,onDocumentShown:o})},Wo=({path:e,absence:t,markup:n,variant:r,onDocumentShown:o})=>r.kind==="page"?l.jsx(od,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o}):l.jsx(sd,{path:e,absence:t,markup:n,variant:r,onDocumentShown:o});function ad({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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 Ko=R.forwardRef(ad);function id({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.createElement("path",{fillRule:"evenodd",d:"M3.22 3.22a.75.75 0 0 1 1.06 0l3.97 3.97V4.5a.75.75 0 0 1 1.5 0V9a.75.75 0 0 1-.75.75H4.5a.75.75 0 0 1 0-1.5h2.69L3.22 4.28a.75.75 0 0 1 0-1.06Zm17.56 0a.75.75 0 0 1 0 1.06l-3.97 3.97h2.69a.75.75 0 0 1 0 1.5H15a.75.75 0 0 1-.75-.75V4.5a.75.75 0 0 1 1.5 0v2.69l3.97-3.97a.75.75 0 0 1 1.06 0ZM3.75 15a.75.75 0 0 1 .75-.75H9a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0v-2.69l-3.97 3.97a.75.75 0 0 1-1.06-1.06l3.97-3.97H4.5a.75.75 0 0 1-.75-.75Zm10.5 0a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 0 1.5h-2.69l3.97 3.97a.75.75 0 1 1-1.06 1.06l-3.97-3.97v2.69a.75.75 0 0 1-1.5 0V15Z",clipRule:"evenodd"}))}const ld=R.forwardRef(id);function cd({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.createElement("path",{fillRule:"evenodd",d:"M15 3.75a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0V5.56l-3.97 3.97a.75.75 0 1 1-1.06-1.06l3.97-3.97h-2.69a.75.75 0 0 1-.75-.75Zm-12 0A.75.75 0 0 1 3.75 3h4.5a.75.75 0 0 1 0 1.5H5.56l3.97 3.97a.75.75 0 0 1-1.06 1.06L4.5 5.56v2.69a.75.75 0 0 1-1.5 0v-4.5Zm11.47 11.78a.75.75 0 1 1 1.06-1.06l3.97 3.97v-2.69a.75.75 0 0 1 1.5 0v4.5a.75.75 0 0 1-.75.75h-4.5a.75.75 0 0 1 0-1.5h2.69l-3.97-3.97Zm-4.94-1.06a.75.75 0 0 1 0 1.06L5.56 19.5h2.69a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75v-4.5a.75.75 0 0 1 1.5 0v2.69l3.97-3.97a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const Xo=R.forwardRef(cd);function dd({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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 Yo=R.forwardRef(dd);function ud({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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 fd=R.forwardRef(ud);function md({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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"}),R.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 hd=R.forwardRef(md);function pd({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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 wd=R.forwardRef(pd);function gd({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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"}),R.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 vd=R.forwardRef(gd);function Ed({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),R.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 Qo=R.forwardRef(Ed);function yd({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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"}),R.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 xd=R.forwardRef(yd);function bd({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.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 kd=R.forwardRef(bd),Jo=({href:e,onRetry:t,testId:n})=>{const{labels:r,onEditGrant:o}=F(),[s,a]=c.useState(!1),i=()=>{o===void 0||s||(a(!0),o(e).then(f=>{f&&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})]})]})},Sd="Control+E Meta+E",es=(e,t,n)=>n&&t?"split":e.view,en=(e,t,n,r)=>{if(n==="split"){e.setSideBySide(!0);return}e.setView(t,n),r&&e.sideBySide()&&e.setSideBySide(!1)},Td=e=>e==="split"?null:e,ts=e=>e==="preview"?"editor":"preview",ns=e=>/Mac|iPhone|iPad|iPod/u.test(e),rs=(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)},nr=(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)},Rd=({path:e,documentName:t,open:n,onClose:r})=>{const{data:o,edits:s,labels:a,locale:i,announcer:f}=F(),w=c.useId(),[g,d]=c.useState(null),[p,h]=c.useState(0),[v,E]=c.useState(null),[b,k]=c.useState(null),[L,A]=c.useState(0),C=c.useMemo(()=>new Intl.DateTimeFormat(i,{dateStyle:"medium",timeStyle:"short"}),[i]),M=c.useCallback(()=>{E(null),k(null)},[]),B=Lr({open:n,onOpen:M,onDismiss:r});c.useEffect(()=>{if(!n)return;const _=new AbortController;return d(null),o.revisions(e,_.signal).then(U=>{"kind"in U&&d(U)}),()=>_.abort()},[n,o,e,p]),c.useEffect(()=>{if(!n||v===null)return;const _=new AbortController;return k(null),o.revision(e,v,_.signal).then(U=>{"kind"in U&&k(U)}),()=>_.abort()},[n,o,e,v,L]);const I=()=>{b===null||b.kind!=="revision"||(s.replaceDraft(e,b.text),f.announce(a.historyRestored(t)),r())},H=g!==null&&g.kind==="revisions"?g.revisions.find(_=>_.id===v):void 0;return l.jsx("dialog",{...B,className:"aqmx-confirm aqmx-history","aria-labelledby":w,"data-testid":"markdown-explorer-history",children:l.jsxs("div",{className:"aqmx-confirm-panel aqmx-history-panel",children:[l.jsx("p",{id:w,className:"aqmx-confirm-title",children:a.historyTitle(t)}),g===null?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-loading",children:a.historyLoading}):g.kind==="failure"?l.jsx(ve,{failure:g.failure,alert:!1,onRetry:()=>h(_=>_+1),testId:"markdown-explorer-history-failure"}):g.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:g.revisions.map(_=>l.jsx("li",{children:l.jsxs("button",{type:"button",className:"aqmx-history-entry","aria-pressed":_.id===v,"data-testid":"markdown-explorer-history-entry",onClick:()=>E(_.id),children:[l.jsx("span",{children:nr(_,C,a.historyEntry)}),_.current?l.jsx("span",{className:"aqmx-history-mark",children:a.historyCurrent}):null,_.kept?l.jsx("span",{className:"aqmx-history-mark",children:a.historyKept}):null]})},_.id))}),v===null?null:b===null?l.jsx("p",{className:"aqmx-history-note",children:a.historyLoading}):b.kind==="failure"?l.jsx(ve,{failure:b.failure,alert:!1,onRetry:()=>A(_=>_+1),testId:"markdown-explorer-history-revision-failure"}):l.jsx("section",{className:"aqmx-history-text",tabIndex:0,"aria-label":H===void 0?a.historyTitle(t):nr(H,C,a.historyEntry),"data-testid":"markdown-explorer-history-text",children:l.jsx("pre",{children:b.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":b===null||b.kind!=="revision","data-testid":"markdown-explorer-history-restore",onClick:I,children:a.historyRestore})]})]})})},Cd=(e,t)=>{if(!t||e===void 0||e.history||!e.dirty||e.phase.kind!=="editing")return!1;const{kind:n}=e.save;return n!=="draft"&&n!=="saving"&&n!=="conflicts"},os=e=>{const{edits:t,labels:n,confirmUnversionedSaves:r}=F(),[o,s]=c.useState(!1),a=c.useCallback(()=>{t.flush(e),Cd(t.session(e),r)?s(!0):t.save(e)},[t,e,r]),i=l.jsx(sn,{open:o,title:n.unversionedSaveTitle,body:n.unversionedSaveBody,confirmLabel:n.unversionedSaveConfirm,cancelLabel:n.unsavedStay,testId:"markdown-explorer-unversioned-save-confirm",onConfirm:()=>{s(!1),t.save(e)},onCancel:()=>s(!1)});return{requestSave:a,confirmation:i}},Md=e=>{const{documents:t}=F(),n=c.useCallback(()=>t.peek(e),[t,e]),r=c.useCallback(()=>t.peekSeeded(e),[t,e]),o=c.useSyncExternalStore(t.subscribe,n,r),s=me(o)?.document;return s===void 0||s.kind==="failure"?{edit:null,name:P.lastPathSegment(e)}:{edit:s.kind==="markdown"||s.kind==="spreadsheet"?s.edit:null,name:s.name}},de=e=>{e.stopPropagation()},Ld=({path:e,documentName:t,iconOnly:n,previewAvailable:r,draft:o})=>{const{draftConverter:s,edits:a,labels:i}=F(),f=c.useSyncExternalStore(a.subscribe,()=>a.session(e)!==void 0,()=>!1),[w,g]=c.useState(null),d=()=>{if(!f){a.start(e,a.viewAnchor(e));return}a.flush(e);const E=a.session(e);E?.dirty===!0?g(E.save.kind==="draft"?"draft":"unsaved"):a.close(e)},p=()=>{f||(ha(),r&&a.sideBySide()&&s?.prepare?.())},h=n?o?i.editDraftDocumentNamed(t):i.editDocumentNamed(t):null,v=o?i.editDraftDocument:i.editDocument;return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:h===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:f?i.closeEditor:h===null?v:h,"aria-label":h===null?void 0:h,"aria-pressed":f,"data-testid":"markdown-explorer-document-edit",onClick:d,onDoubleClick:de,onPointerEnter:p,onFocus:p,children:[l.jsx(xd,{"aria-hidden":"true"}),h===null?l.jsx("span",{children:i.editDocumentLabel}):null]}),l.jsx(sn,{open:w!==null,title:w==="draft"?i.draftDiscardTitle:i.unsavedTitle,body:w==="draft"?i.draftDiscardBody(t):i.unsavedBody(t),confirmLabel:i.unsavedDiscard,cancelLabel:i.unsavedStay,testId:"markdown-explorer-edit-close-confirm",onConfirm:()=>{g(null),a.close(e)},onCancel:()=>g(null)})]})},Od=({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:de,children:[l.jsx(fd,{"aria-hidden":"true"}),o===null?l.jsx("span",{children:r.editExternallyLabel}):null]})},Ad=({session:e})=>{const{labels:t}=F(),n=Hs(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})},Dd=Object.freeze(["editor","split","preview"]),Nd=Object.freeze(["editor","preview"]),Pd=Object.freeze({editor:Yo,split:kd,preview:Qo}),_d=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{draftConverter:s,edits:a,labels:i}=F(),f=_r(),w=es(r,f,o),g=o?Dd:Nd,d=c.useId(),p=c.useRef(new Map),h={editor:{label:i.editViewEditor,tooltip:i.editViewEditorTooltip},split:{label:i.editViewSplit,tooltip:i.editViewSplitTooltip},preview:{label:i.editViewPreview,tooltip:i.editViewPreviewTooltip}},v=()=>{a.preparePreview(e),s?.prepare?.()},E=b=>{if(!rs(b.nativeEvent,ns(navigator.platform)))return;on(b);const k=ts(w);en(a,e,k,o),p.current.get(k)?.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:E,children:g.map(b=>{const k=Pd[b],{label:L,tooltip:A}=h[b],C=b==="preview"?v:void 0;return l.jsxs("label",{className:n?"aqmx-icon-button":"aqmx-icon-button aqmx-labelled-button",children:[l.jsx("input",{ref:M=>{M===null?p.current.delete(b):p.current.set(b,M)},type:"radio",name:d,value:b,checked:b===w,"aria-label":L,"aria-keyshortcuts":b==="split"?void 0:Sd,title:A,"data-testid":`markdown-explorer-edit-view-${b}`,onChange:()=>en(a,e,b,o),onDoubleClick:de,onPointerEnter:C,onFocus:C}),l.jsx(k,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:L})]},b)})})},jd=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{edits:s,labels:a}=F(),[i,f]=c.useState(!1),{requestSave:w,confirmation:g}=os(e);if(r.phase.kind!=="editing")return null;const d=r.save.kind==="saving",p=d||!r.dirty,h=()=>{s.flush(e);const E=s.session(e);E===void 0||!E.dirty||E.save.kind==="saving"||w()},v=E=>n?{className:"aqmx-icon-button","aria-label":E}:{className:"aqmx-icon-button aqmx-labelled-button"};return l.jsxs(l.Fragment,{children:[r.save.kind==="conflicts"?l.jsxs("button",{type:"button",...v(a.conflictNext),title:a.conflictNext,"data-testid":"markdown-explorer-edit-next-conflict",onClick:()=>s.nextConflict(e),onDoubleClick:de,children:[l.jsx(hd,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.conflictNext})]}):null,l.jsx(_d,{path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o}),r.history?l.jsxs("button",{type:"button",...v(a.historyOpen),title:a.historyOpen,"aria-haspopup":"dialog","data-testid":"markdown-explorer-edit-history",onClick:()=>f(!0),onDoubleClick:de,children:[l.jsx(wd,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.historyOpen})]}):null,r.save.kind==="draft"?null:l.jsxs("button",{type:"button",...v(a.saveDraft),title:a.saveDraftTooltip,"aria-disabled":p,"aria-busy":d,"aria-keyshortcuts":"Control+S Meta+S","data-testid":"markdown-explorer-edit-save",onClick:h,onDoubleClick:de,children:[l.jsx(vd,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.saveDraft})]}),r.history?l.jsx(Rd,{path:e,documentName:t,open:i,onClose:()=>f(!1)}):null,g]})},Id=({path:e,session:t})=>{const{edits:n}=F();return t.save.kind!=="grant"?null:l.jsx(Jo,{href:t.save.href,onRetry:()=>{n.save(e)},testId:"markdown-explorer-save-grant"})},ss=c.createContext(null);function Fd({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.createElement("path",{fillRule:"evenodd",d:"M7.502 6h7.128A3.375 3.375 0 0 1 18 9.375v9.375a3 3 0 0 0 3-3V6.108c0-1.505-1.125-2.811-2.664-2.94a48.972 48.972 0 0 0-.673-.05A3 3 0 0 0 15 1.5h-1.5a3 3 0 0 0-2.663 1.618c-.225.015-.45.032-.673.05C8.662 3.295 7.554 4.542 7.502 6ZM13.5 3A1.5 1.5 0 0 0 12 4.5h4.5A1.5 1.5 0 0 0 15 3h-1.5Z",clipRule:"evenodd"}),R.createElement("path",{fillRule:"evenodd",d:"M3 9.375C3 8.339 3.84 7.5 4.875 7.5h9.75c1.036 0 1.875.84 1.875 1.875v11.25c0 1.035-.84 1.875-1.875 1.875h-9.75A1.875 1.875 0 0 1 3 20.625V9.375Zm9.586 4.594a.75.75 0 0 0-1.172-.938l-2.476 3.096-.908-.907a.75.75 0 0 0-1.06 1.06l1.5 1.5a.75.75 0 0 0 1.116-.062l3-3.75Z",clipRule:"evenodd"}))}const $d=R.forwardRef(Fd);function qd({title:e,titleId:t,...n},r){return R.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?R.createElement("title",{id:t},e):null,R.createElement("path",{fillRule:"evenodd",d:"M19.902 4.098a3.75 3.75 0 0 0-5.304 0l-4.5 4.5a3.75 3.75 0 0 0 1.035 6.037.75.75 0 0 1-.646 1.353 5.25 5.25 0 0 1-1.449-8.45l4.5-4.5a5.25 5.25 0 1 1 7.424 7.424l-1.757 1.757a.75.75 0 1 1-1.06-1.06l1.757-1.757a3.75 3.75 0 0 0 0-5.304Zm-7.389 4.267a.75.75 0 0 1 1-.353 5.25 5.25 0 0 1 1.449 8.45l-4.5 4.5a5.25 5.25 0 1 1-7.424-7.424l1.757-1.757a.75.75 0 1 1 1.06 1.06l-1.757 1.757a3.75 3.75 0 1 0 5.304 5.304l4.5-4.5a3.75 3.75 0 0 0-1.035-6.037.75.75 0 0 1-.354-1Z",clipRule:"evenodd"}))}const Bd=R.forwardRef(qd),Ud=e=>{const{documents:t}=F(),n=c.useCallback(()=>t.peek(e),[t,e]),r=c.useCallback(()=>t.peekSeeded(e),[t,e]),o=me(c.useSyncExternalStore(t.subscribe,n,r));return o!==null&&o.document.kind!=="failure"},Hd=(e,t)=>{switch(e.view){case"single":return{view:"document-id",id:t,opens:"single",overrides:e.overrides,embed:e.embed};case"tree":return{view:"document-id",id:t,overrides:e.overrides};case"multi":return{view:"document-id",id:t}}},Vd=(e,t)=>new Promise(n=>n(e.write([t()]))),zd=({path:e,placement:t})=>{const{config:n,data:r,labels:o}=F(),{location:s}=Ke(),{shown:a,press:i}=oo(),f=Ud(e),w=re.useHref(n.basePath),g=v=>{const E=V.explorerHref(n,Hd(s,v));return new URL(`${w}${E.slice(n.basePath.length)}`,window.location.origin).href},d=()=>{if(!f)return;const v=i(),E=A=>{console.error("[markdown-explorer] could not copy the permalink",A),v("failed",o.permalinkCopyFailed(o.permalinkClipboardRefused))},b=navigator.clipboard;if(b===void 0||typeof ClipboardItem>"u"){v("failed",o.permalinkCopyFailed(o.permalinkClipboardRefused));return}const k=r.issueId(e),L=k.then(A=>A.status==="ok"?new Blob([g(A.id)],{type:"text/plain"}):Promise.reject(new Error(`[markdown-explorer] the document ID was not issued: ${A.failure.reason}`)));L.catch(()=>{}),Vd(b,()=>new ClipboardItem({"text/plain":L})).then(()=>k.then(A=>{A.status==="ok"&&v("copied",o.permalinkCopied(P.groupDocumentId(A.id)))}),A=>k.then(C=>{C.status==="error"?v("failed",o.permalinkCopyFailed(le(o,C.failure.reason))):E(A)}))},p=t.kind==="panel"?o.copyPermalinkNamed(t.documentName):null,h=a.message===null?p===null?o.copyPermalink:p:a.message;return l.jsxs("button",{type:"button",className:p===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:h,"aria-label":p===null?void 0:p,"aria-disabled":!f,"data-aqmx-copy-outcome":a.outcome,"data-testid":"markdown-explorer-document-permalink",onClick:d,onDoubleClick:de,children:[a.outcome==="copied"?l.jsx($d,{"aria-hidden":"true"}):a.outcome==="failed"?l.jsx(ro,{"aria-hidden":"true"}):l.jsx(Bd,{"aria-hidden":"true"}),p===null?l.jsx("span",{children:o.copyPermalinkLabel}):null]})},Gd=(e,t)=>{switch(t){case"markdown":return e.showMarkup;case"svg":return e.showSvgMarkup;case"csv":case"tsv":return e.showSpreadsheetMarkup(t.toUpperCase())}},Zd=({maximize:e})=>{const{labels:t}=F(),n=e.maximized?t.documentRestore:t.documentMaximize;return l.jsx("button",{type:"button",className:"aqmx-icon-button",title:n,"aria-label":n,"data-testid":"markdown-explorer-document-maximize",onClick:e.toggle,onDoubleClick:de,children:e.maximized?l.jsx(ld,{"aria-hidden":"true"}):l.jsx(Xo,{"aria-hidden":"true"})})},as=Object.freeze({kind:"page"}),is=({path:e,placement:t,markup:n,maximize:r})=>{const{config:o,labels:s}=F(),{refreshing:a,unavailable:i,failure:f,refresh:w}=ao(e,t.kind==="page",n.shown),g=xl(e),d=Md(e),p=Nr(e),h=t.kind==="panel"?s.refreshDocumentNamed(t.documentName):null,v=t.kind==="panel"?s.showMarkupNamed(t.documentName):null,E=t.kind==="panel",b=t.kind==="panel"?t.documentName:d.name,k=t.kind==="page"||t.maximized,L=c.use(ss),A=t.kind==="page"?L:null,C=A===null?null:A.onBar;c.useLayoutEffect(()=>{if(C!==null)return C(!0),()=>C(!1)},[C]);const M=A===null?void 0:A.lane?"merged":"covering";return l.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar","data-aqmx-editing":p===void 0?void 0:"true","data-aqmx-sheet-bar":M,children:[l.jsxs("div",{className:"aqmx-document-refresh-row",children:[p===void 0?null:l.jsx(Ad,{session:p}),p===void 0?null:l.jsx(jd,{path:e,documentName:b,iconOnly:E,session:p,previewAvailable:k}),p===void 0&&g!==null?l.jsxs("button",{type:"button",className:v===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:v===null?Gd(s,g):v,"aria-label":v===null?void 0:v,"aria-pressed":n.shown,"data-testid":"markdown-explorer-document-markup",onClick:n.toggle,onDoubleClick:de,children:[l.jsx(Yo,{"aria-hidden":"true"}),v===null?l.jsx("span",{children:s.showMarkupLabel}):null]}):null,p!==void 0||d.edit?.kind==="inline"||d.edit?.kind==="draft"?l.jsx(Ld,{path:e,documentName:b,iconOnly:E,previewAvailable:k,draft:d.edit?.kind==="draft"}):d.edit?.kind==="external"?l.jsx(Od,{href:d.edit.href,documentName:b,iconOnly:E}):null,p===void 0?l.jsxs("button",{type:"button",className:h===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:h===null?s.refreshDocument:h,"aria-label":h===null?void 0:h,"aria-disabled":i,"aria-busy":a,"data-aqmx-busy":a?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:w,onDoubleClick:de,children:[l.jsx(Ko,{"aria-hidden":"true"}),h===null?l.jsx("span",{children:s.refreshDocumentLabel}):null]}):null,p===void 0&&o.documentIds!==null?l.jsx(zd,{path:e,placement:t}):null,r===null?null:l.jsx(Zd,{maximize:r})]}),p!==void 0||f===null?null:l.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":f.reason,children:s.documentRefreshFailed(le(s,f.reason))}),p===void 0?null:l.jsx(Id,{path:e,session:p})]})},Wd=({location:e})=>{const t=e.doc,n=c.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),r=yo(e);return l.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",...mt,children:[l.jsx(is,{path:t,placement:as,markup:r,maximize:null}),l.jsx(Wo,{path:t,absence:Vo,markup:e.markup,variant:n})]})},ls=({holds:e,deferWhileFullscreenIn:t,testId:n})=>{const{labels:r,announcer:o}=F(),s=c.useId();c.useLayoutEffect(()=>{if(!e)return;const f=t===null?null:()=>t.current!==null&&Ea(t.current);return o.claim(s,f)},[e,o,s,t]),c.useEffect(()=>{if(t===null)return;const f=t.current;if(f===null)return;const w=()=>o.publishDeferred();return f.addEventListener("close",w,!0),()=>f.removeEventListener("close",w,!0)},[o,t]);const a=c.useCallback(()=>o.shownIn(s),[o,s]),i=c.useSyncExternalStore(o.subscribe,a,a);return l.jsx("div",{className:"aqmx-sr-only",role:"status","aria-live":"polite","aria-atomic":"true","data-testid":n,children:i.length>1?r.announcementSequence(i):i[0]})},Re=Object.freeze([]),Kd=e=>{const t=new Set;let n=Re,r=[],o=!1;const s=[];let a=[];const i=h=>{n=h;for(const v of[...t])v()},f=()=>s.at(-1)?.region,w=()=>s.at(-1)?.defers?.()===!0,g=h=>{const v=f();h(),f()!==v&&n!==Re&&i(Re)},d=()=>{o=!1;const h=r.map(E=>"sentence"in E?E.sentence:E.list(E.items));if(r=[],w()){for(const E of h)a.at(-1)!==E&&a.push(E);return}const v=[...a,...h];a=[],i(Object.freeze(v))},p=()=>{o||(o=!0,n!==Re&&i(Re),e.request(d))};return{announce:h=>{if(typeof h=="string")r.push({sentence:h});else{const v=r.find(E=>"list"in E&&E.list===h.list);v!==void 0&&"items"in v?v.items.push(h.item):r.push({list:h.list,items:[h.item]})}p()},subscribe:h=>(t.add(h),()=>{t.delete(h)}),claim:(h,v)=>{const E={region:h,defers:v};return g(()=>s.push(E)),()=>g(()=>{const b=s.indexOf(E);b!==-1&&s.splice(b,1)})},publishDeferred:()=>{a.length>0&&!w()&&p()},shownIn:h=>f()===h?n:Re}},ue=Object.freeze({status:"cancelled"}),Xd=e=>P.isExplorerResolvedDocumentId(e)&&(e.status!=="ok"||V.hasDocumentUrl(e.path)),rr=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(P.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return P.failureOf(n,r)},Yd=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((d,p)=>globalThis.fetch(d,p)),o=(d,p)=>`${e}/${d}?${new URLSearchParams(p).toString()}`,s=d=>{d.status===401&&t(null);const p=d.headers.get(P.EXPLORER_SCOPE_HEADER);p!==null&&t(p)},a=async(d,p,h,v)=>{let E;try{E=await r(d,{credentials:"same-origin",...p,headers:{Accept:"application/json",...p.headers}})}catch{return v({reason:"failed"})}s(E);let b;try{b=await E.json()}catch{return v({reason:P.failureReasonOfStatus(E.status)})}let k;try{k=h(b)}catch{k=!1}if(k)return b;const L=rr(b);return v(L!==null?L:{reason:E.status===200?"failed":P.failureReasonOfStatus(E.status)})},i={[P.EXPLORER_PROOF_HEADER]:P.EXPLORER_REFRESH_PROOF},f={[P.EXPLORER_PROOF_HEADER]:P.EXPLORER_EDIT_PROOF,"Content-Type":`${P.EXPLORER_DRAFT_MEDIA_TYPE}; charset=utf-8`},w={[P.EXPLORER_PROOF_HEADER]:P.EXPLORER_DOCUMENT_ID_PROOF},g=async(d,p,h)=>{const v=await a(d,p,h,E=>P.failureDocument(E.reason,E.code));return p.signal.aborted?ue:v};return{tree:d=>a(o("tree",{[P.EXPLORER_DATA_QUERY.source]:d}),{method:"GET"},P.isExplorerTreeResult,p=>({status:"error",failure:p})),children:async(d,p,h)=>{const v=await a(o("children",{[P.EXPLORER_DATA_QUERY.source]:d,[P.EXPLORER_DATA_QUERY.path]:p}),{method:"GET",signal:h},P.isExplorerChildrenResult,E=>({status:"error",failure:E}));return h.aborted?ue:v},ancestors:async(d,p,h)=>{const v=await a(o("ancestors",{[P.EXPLORER_DATA_QUERY.source]:d,[P.EXPLORER_DATA_QUERY.path]:p}),{method:"GET",signal:h},P.isExplorerAncestorsResult,E=>({status:"error",failure:E}));return h.aborted?ue:v},reveal:async(d,p,h)=>{const v=await a(o("reveal",{[P.EXPLORER_DATA_QUERY.source]:d,[P.EXPLORER_DATA_QUERY.path]:p}),{method:"GET",signal:h},P.isExplorerRevealResult,E=>({status:"error",failure:E}));return h.aborted?ue:v},document:(d,{refresh:p})=>a(o("document",{[P.EXPLORER_DATA_QUERY.path]:d}),p?{method:"GET",headers:i}:{method:"GET"},P.isExplorerDocument,h=>P.failureDocument(h.reason,h.code)),text:async(d,p)=>{const h=await a(o("text",{[P.EXPLORER_DATA_QUERY.path]:d}),{method:"GET",signal:p},P.isExplorerTextAnswer,v=>P.failureDocument(v.reason,v.code));return p.aborted?ue:h},asset:async(d,p)=>{let h;try{h=await r(d,{method:"GET",credentials:"same-origin",signal:p})}catch{return p.aborted?ue:{status:"error",failure:{reason:"failed"}}}if(s(h),h.ok)return p.aborted?ue:{status:"ok",body:h.body===null?new ReadableStream({start:b=>b.close()}):h.body};let v=null;try{v=await h.json()}catch{}if(p.aborted)return ue;const E=rr(v);return{status:"error",failure:E===null?{reason:P.failureReasonOfStatus(h.status)}:E}},edit:(d,p)=>g(o("edit",{[P.EXPLORER_DATA_QUERY.path]:d}),{method:"GET",signal:p},P.isExplorerEditAnswer),save:(d,p,h,v)=>g(o("save",{[P.EXPLORER_DATA_QUERY.path]:d,[P.EXPLORER_DATA_QUERY.base]:p}),{method:"POST",headers:f,body:h,signal:v},P.isExplorerSaveAnswer),preview:(d,p,h)=>g(o("preview",{[P.EXPLORER_DATA_QUERY.path]:d}),{method:"POST",headers:f,body:p,signal:h},P.isExplorerPreviewAnswer),revisions:(d,p)=>g(o("revisions",{[P.EXPLORER_DATA_QUERY.path]:d}),{method:"GET",signal:p},P.isExplorerRevisionsAnswer),revision:(d,p,h)=>g(o("revision",{[P.EXPLORER_DATA_QUERY.path]:d,[P.EXPLORER_DATA_QUERY.revision]:p}),{method:"GET",signal:h},P.isExplorerRevisionAnswer),refresh:d=>a(o("refresh",{[P.EXPLORER_DATA_QUERY.source]:d}),{method:"POST",headers:i},P.isExplorerTreeResult,p=>({status:"error",failure:p})),issueId:d=>a(o("issue-id",{[P.EXPLORER_DATA_QUERY.path]:d}),{method:"POST",headers:w},P.isExplorerIssuedDocumentId,p=>({status:"error",failure:p})),resolveId:async(d,p)=>{const h=await a(o("resolve-id",{[P.EXPLORER_DATA_QUERY.id]:d}),{method:"GET",signal:p},Xd,v=>({status:"error",failure:v}));return p.aborted?ue:h}}},Qd=()=>{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}}},Jd=e=>{const t=ae.readStorage(e);if(t===null)return V.NO_TREE_SETTING_CHANGES;try{return V.readTreeSettingChanges(JSON.parse(t))}catch(n){return console.warn(`[markdown-explorer] localStorage key ${z.describeValue(e)} does not hold JSON; using the default tree settings.`,n),V.NO_TREE_SETTING_CHANGES}},or=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=Jd(e);n={changes:s,settings:V.applyTreeSettingChanges(t,s)}}return n},o=Ne();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:a,settings:i}=r(),f=V.recordTreeSettingChange(a,s,V.advanceTreeSetting(i,s)[s],t);return n={changes:f,settings:V.applyTreeSettingChanges(t,f)},o.emit(),ae.writeStorage(e,V.serializeTreeSettingChanges(f)),n.settings}}},eu=Object.freeze({status:"refreshed"}),tu=Object.freeze({status:"superseded"}),nu=Object.freeze({status:"unshown"}),tn=Object.freeze({status:"deferred"}),ru=Or(tn),cs=4,ou=cs-1,sr=Object.freeze({status:"loading"}),su=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),au=e=>{const t=new Map,n=no(),r=new Map,o=new Map,s=new Map,a=new Map,i=Ne(),f=new Set;let w=0,g=0;const d={direct:null,bulk:null},p=new Set;let h=!1,v=0;const E=()=>{v+=1,i.emit()},b=y=>o.get(y)??0,k=y=>{let T=a.get(y);return T===void 0&&(T={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},a.set(y,T)),T},L=(y,T,D)=>{y.inFlight.delete(T),w-=1,D.lane==="bulk"&&(g-=1)},A=y=>{const T=a.get(y);if(T!==void 0){for(const[D,N]of[...T.inFlight])L(T,D,N),N.controller.abort();T.direct.clear(),T.bulk.clear(),T.unclaimed.clear()}},C=y=>{const T=b(y)+1;return o.set(y,T),A(y),T},M=(y,T)=>{const D=Ve(y),N={promise:y,opened:T,stale:!1,loadedAt:D?.status==="ok"?D.loadedAt:null};return y.status==="pending"&&y.then(q=>{q.status==="ok"&&(N.loadedAt=q.loadedAt)}),N},B=y=>{let T=r.get(y);return T===void 0&&(T=new Map,r.set(y,T)),T},I=y=>{const T=[...a.keys()],D=d[y],N=D===null?0:T.indexOf(D)+1;for(let q=0;q<T.length;q+=1){const X=T[(N+q)%T.length],K=X===void 0?void 0:a.get(X);if(!(X===void 0||K===void 0)){for(const W of K[y])if((K.claims.get(W)??0)!==0)return K[y].delete(W),d[y]=X,{sourceId:X,path:W}}}return null},H=(y,T,D,N)=>{const q=a.get(y);if(q===void 0||q.inFlight.get(T)!==D)return;L(q,T,D);const X=(q.claims.get(T)??0)>0,K=B(y);if(N.status==="ok"?K.set(T,{status:"loaded",entries:N.entries}):N.status==="error"&&X?K.set(T,{status:"failed",failure:N.failure}):K.delete(T),E(),N.status==="error"&&X){const W={sourceId:y,path:T,failure:N.failure};for(const oe of[...f])oe(W)}U()},_=(y,T,D)=>{const N={controller:new AbortController,lane:D};k(y).inFlight.set(T,N),w+=1,D==="bulk"&&(g+=1),e.children(y,T,N.controller.signal).then(q=>H(y,T,N,q),()=>H(y,T,N,su))},U=()=>{for(;w<cs;){const y=I("direct");if(y!==null){_(y.sourceId,y.path,"direct");continue}const T=g<ou?I("bulk"):null;if(T===null)return;_(T.sourceId,T.path,"bulk")}},Z=(y,T,D)=>{if(!(T.direct.delete(D)||T.bulk.delete(D))){const q=T.inFlight.get(D);if(q===void 0)return!1;L(T,D,q),q.controller.abort()}return r.get(y)?.delete(D),!0},Q=()=>{h=!1;let y=!1;for(const T of p){const D=k(T);for(const N of D.unclaimed)(D.claims.get(N)??0)===0&&Z(T,D,N)&&(y=!0);D.unclaimed.clear()}p.clear(),y&&(E(),U())},u=(y,T)=>{t.set(y,M(Ge(e.tree(y)),T))},m=(y,T,D)=>{C(y);const N=M(Or(T),D);return t.set(y,N),r.delete(y),E(),U(),N},S=(y,T,D,N)=>{if(D!==b(y)||t.get(y)!==T)return;const q=Ve(T.promise);if(!(N.status!=="ok"||q?.status!=="ok"||T.loadedAt===null||N.loadedAt<=T.loadedAt)){if(pt(q.entries,N.entries)){T.loadedAt=N.loadedAt;return}m(y,N,T.opened)}},x=(y,T)=>{const D=t.get(y);return D!==void 0&&Ve(D.promise)?.status===T},O=(y,T)=>{T.stale=!1;const D=b(y);e.tree(y).then(N=>S(y,T,D,N))},$=async(y,T)=>{const D=(s.get(y)??0)+1;s.set(y,D);const N=await e.refresh(y);if(s.get(y)!==D)return tu;if(N.status==="error")return{status:"failed",failure:N.failure};const q=t.get(y);if(!(q!==void 0&&q.loadedAt!==null&&x(y,"ok")&&q.loadedAt>N.loadedAt)){const K=m(y,N,!0);if(q!==void 0&&q.promise.status==="pending"){const W=b(y);q.promise.then(oe=>S(y,K,W,oe))}}if(T)for(const[K,W]of t)K!==y&&Ve(W.promise)?.status==="ok"&&(W.stale=!0);return eu};return{read:y=>t.get(y)?.promise??ru,open:y=>{const T=n.resumes(y),D=n.hold(y),N=t.get(y);return N===void 0||x(y,"deferred")?(u(y,!0),E()):T||(N.opened&&x(y,"error")?(u(y,!0),E()):(N.opened=!0,N.stale&&x(y,"ok")&&O(y,N))),D},retry:y=>{x(y,"error")&&(u(y,!0),E())},seed:(y,T)=>{const D=T.then(X=>X===null?tn:X,()=>tn),N=t.get(y);if(N!==void 0&&x(y,"ok")){const X=b(y);D.then(K=>S(y,N,X,K));return}C(y);const q=M(Ge(D),N?.opened===!0);t.set(y,q),r.delete(y),U(),D.then(X=>{t.get(y)===q&&(X.status==="deferred"&&n.isHeld(y)&&u(y,q.opened),E())})},refresh:y=>$(y,!0),reloadSource:y=>{if(n.isHeld(y))return $(y,!1);const T=t.get(y);return T!==void 0&&(T.stale=!0),Promise.resolve(nu)},children:(y,T)=>r.get(y)?.get(T),claimChildren:(y,T)=>{const D=k(y),N=B(y);let q=!1,X=!1;for(const[W,oe]of T)D.claims.set(W,(D.claims.get(W)??0)+1),N.get(W)===void 0?(N.set(W,sr),D[oe].add(W),q=!0,X=!0):oe==="direct"&&D.bulk.delete(W)&&(D.direct.add(W),X=!0);q&&E(),X&&U();let K=!1;return()=>{if(!K){K=!0;for(const W of T.keys()){const oe=(D.claims.get(W)??0)-1;oe>0?D.claims.set(W,oe):(D.claims.delete(W),D.unclaimed.add(W))}p.add(y),!h&&(h=!0,queueMicrotask(Q))}}},retryChildren:(y,T)=>{const D=r.get(y);if(D===void 0||D.get(T)?.status!=="failed")return;const N=k(y);if((N.claims.get(T)??0)>0){D.set(T,sr),N.direct.add(T),E(),U();return}D.delete(T),E()},pendingChildren:y=>{const T=a.get(y);return T===void 0?0:T.direct.size+T.bulk.size+T.inFlight.size},clear:()=>{for(const y of new Set([...t.keys(),...r.keys(),...o.keys(),...a.keys()]))C(y);for(const[y,T]of s)s.set(y,T+1);t.clear(),r.clear(),E()},subscribeChildrenFailures:y=>(f.add(y),()=>{f.delete(y)}),subscribe:i.subscribe,version:()=>v}},iu=(e,t)=>{let n=e;const r=Ne();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},lu=Object.freeze({kind:"loading"}),cu=Object.freeze({reason:"invalid"}),du=Object.freeze({reason:"failed"}),uu=(e,t)=>{const{config:n,data:r,sources:o}=F(),s=xe(),a=e.kind==="document-id"?e:null,[i,f]=c.useState(null),[w,g]=c.useState(null),d=c.useMemo(()=>a===null?null:i!==null&&i.opening===a?i:{opening:a,retries:0},[a,i]),p=d===null?null:d.opening.id===null?cu:d.retries===0&&t!==null&&t.id===d.opening.id?t.failure:w!==null&&w.attempt===d?w.failure:null,h=d!==null&&p===null,{hash:v}=re.useLocation(),E=c.useRef(v);c.useLayoutEffect(()=>{E.current=v},[v]),c.useEffect(()=>{if(!h||d===null||d.opening.id===null)return;const{opens:k,id:L}=d.opening,A=new AbortController;return r.resolveId(L,A.signal).then(C=>{if(!(C.status==="cancelled"||A.signal.aborted)){if(C.status==="error")return g({attempt:d,failure:C.failure});if(!o.some(M=>M.id===C.source))return g({attempt:d,failure:du});s(`${V.explorerHref(n,V.documentIdOpeningTarget(k,C.path,C.source))}${E.current}`,"browse")}}),()=>A.abort()},[h,d,r,o,n,s]);const b=c.useCallback(()=>{d!==null&&f({opening:d.opening,retries:d.retries+1})},[d]);return c.useMemo(()=>d===null?null:p===null?lu:{kind:"document-id",failure:p,onRetry:b},[d,p,b])},fu=1;let lt=0,we=null;const mu=()=>{const{documentElement:e,body:t}=document;lt===0&&(we={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"),lt+=1;let n=!1;return()=>{n||(n=!0,lt-=1,!(lt>0||we===null)&&(e.style.overflow=we.htmlOverflow,t.style.overflow=we.bodyOverflow,e.style.scrollbarGutter=we.htmlGutter,t.style.scrollbarGutter=we.bodyGutter,we=null))}},hu=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],ar=1,pu=1e3,ir=e=>e.getClientRects().length>0,Ut="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.",wu=e=>{if(!ir(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+fu)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. ${Ut}`;if(t.height<ar)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. ${Ut}`;for(const{selector:r,name:o}of hu)for(const s of e.querySelectorAll(r)){if(!ir(s))continue;const a=s.getBoundingClientRect().height;if(a<ar)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. ${Ut}`}return null},gu=e=>{let t=!1,n;const r=()=>{n=void 0;const a=wu(e);a!==null&&(t=!0,console.error(a))},o=()=>{t||(clearTimeout(n),n=setTimeout(r,pu))},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)}},vu=e=>(c.useEffect(()=>e?mu():void 0,[e]),c.useCallback(t=>e?gu(t):void 0,[e])),lr='[data-testid="markdown-explorer-view-switch"]',Eu=[{control:lr,successors:[lr,'[data-testid="markdown-explorer-sheet-toggle"]','[data-testid="markdown-explorer-rail-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],yu=e=>{for(const t of Eu){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},xu=(e,t)=>{const n=c.useRef(null);c.useEffect(()=>{const o=i=>{const f=e.current;n.current=f!==null&&i instanceof Element&&f.contains(i)?yu(i):null},s=i=>o(i.target);o(document.activeElement);const a=i=>{const f=i.target;i.relatedTarget!==null||!(f instanceof Element)||queueMicrotask(()=>{n.current?.element===f&&f.isConnected&&document.activeElement!==f&&(n.current=null)})};return document.addEventListener("focusin",s),document.addEventListener("focusout",a),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",a)}},[e]);const r=c.useRef(t);c.useLayoutEffect(()=>{if(r.current===t)return;r.current=t;const o=n.current;if(o===null)return;const s=()=>{const f=document.activeElement;if(f!==null&&f!==document.body&&f!==o.element)return!0;const w=e.current;if(w===null)return!0;for(const g of o.control.successors)for(const d of w.querySelectorAll(g))if(d!==o.element&&(d.focus({preventScroll:!0}),document.activeElement===d))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])},bu=c.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-T8sc_wg7.cjs")).then(e=>({default:e.TreeLayout}))),ku=c.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-Bo9LAXiY.cjs")).then(e=>({default:e.MultiLayout}))),Su=64,Tu={request:e=>{requestAnimationFrame(e)}},cr=e=>{e.documents.clear(),e.trees.clear()},Ht=(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)},Ru=(e,t)=>{const[n,r]=c.useState(()=>({overrides:t,locale:e,labels:Wt(e,t)}));if(n.locale===e&&Rs(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:Wt(e,t)};return r(o),o.labels},Cu=(e,t,n)=>{const[r,o]=c.useState(()=>({scope:t,store:or(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:or(e,n)};return o(s),s.store},He=(e,t)=>{const[n,r]=c.useState(()=>({scope:e,value:t()}));if(n.scope===e)return n.value;const o={scope:e,value:t()};return r(o),o.value},Mu=()=>Kd(Tu),dr="on",Lu="off",Ou=Object.freeze({kind:"unavailable"}),Au=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")},ur=(e,t)=>{const n=me(e.peek(t));return n===null||n.document.kind==="failure"?P.lastPathSegment(t):n.document.name},Du=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:a,renderTreeFailure:i,lockDocumentScroll:f=!1,onMathDiagnostics:w,onEditGrant:g,draftConverter:d,fetch:p,persistSettings:h,subscribeHostChanges:v,hostChangePolicy:E="reload",ref:b,guardUnload:k=$e.guardUnload,onReload:L,onSessionEnded:A,onDraftChange:C,accountState:M=$e.accountState,confirmUnversionedSaves:B=$e.confirmUnversionedSaves,paletteKey:I})=>{ae.assertStorageNamespace(n),Au(d),ws({fetch:p,persistSettings:h,subscribeHostChanges:v,onReload:L,onSessionEnded:A,onDraftChange:C,guardUnload:k,confirmUnversionedSaves:B,hostChangePolicy:E,accountState:M,paletteKey:I});const H=yr(r),_=Cs(s),U=Ru(H,o),{revalidate:Z}=re.useRevalidator(),Q=c.useRef(()=>{}),u=re.useHref(t.dataPath),m=c.useRef({fetch:p,persistSettings:h,onReload:L,onSessionEnded:A,onDraftChange:C,hostChangePolicy:E});c.useLayoutEffect(()=>{m.current={fetch:p,persistSettings:h,onReload:L,onSessionEnded:A,onDraftChange:C,hostChangePolicy:E}},[p,h,L,A,C,E]);const[S]=c.useState(()=>({fetch:(j,J)=>{const te=m.current.fetch;return te===void 0?globalThis.fetch(j,J):te(j,J)},reload:()=>{const j=m.current.onReload;j===void 0?$e.onReload():j()},restoreSession:()=>{const j=m.current.onSessionEnded;return j===void 0?Promise.resolve(!1):j()}})),[x]=c.useState(()=>{const j=Yd({dataPath:u,onScope:te=>Q.current(te),fetch:S.fetch}),J={documents:Wa({client:j,capacity:Math.max(Su,t.multiView.maxPanels*2)}),trees:au(j)};return Ht(J,e),ae.syncStorageScope(n,e.scope),{data:j,...J,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(x.aligned.pageData!==e||x.aligned.storageNamespace!==n){const j=x.aligned.pageData;x.aligned.pageData=e,x.aligned.storageNamespace=n,j!==e&&(j.scope!==e.scope?x.aligned.pendingReader=e:Ht(x,e)),ae.syncStorageScope(n,e.scope)}const O=Cu(ae.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);c.useLayoutEffect(()=>{const j=x.aligned.pendingReader;j!==null&&(x.aligned.pendingReader=null,cr(x),Ht(x,j))},[e,x]),c.useLayoutEffect(()=>{let j=!1;return Q.current=J=>{J===e.scope||j||(j=!0,J!==null&&(cr(x),ae.clearExplorerStorage(n)),Z())},()=>{Q.current=()=>{}}},[e,Z,x,n]);const $=c.useRef(t.settingsCookie);c.useLayoutEffect(()=>{$.current=t.settingsCookie},[t.settingsCookie]);const[y]=c.useState(()=>iu(e.settings,j=>{const J=m.current.persistSettings;if(J!==void 0){J(V.serializeViewSettings(j));return}document.cookie=V.viewSettingsCookieString($.current,j,window.location.protocol==="https:")})),T=He(e.scope,Mu),D=He(e.scope,Qd),N=He(e.scope,Us),q=He(e.scope,Ls),X=c.useRef(U);c.useLayoutEffect(()=>{X.current=U},[U]);const K=He(e.scope,()=>Ks({data:x.data,conflictLabels:()=>({ours:X.current.conflictOurs,theirs:X.current.conflictTheirs}),onSaveSettled:(j,J)=>{J.kind==="saved"&&x.documents.refresh(j);const te=Vs(X.current,J,ur(x.documents,j));te!==null&&T.announce(te)},sideBySideSetting:{read:()=>ae.readStorage(ae.storageKeys(n).editPreview)===dr,write:j=>ae.writeStorage(ae.storageKeys(n).editPreview,j?dr:Lu)},editorShareSetting:{read:()=>Ws(ae.readStorage(ae.storageKeys(n).editSplit)),write:j=>ae.writeStorage(ae.storageKeys(n).editSplit,String(j))}})),W=c.useMemo(()=>Ge(e.notices.catch(()=>[])),[e.notices]),oe=e.sources.map(j=>j.id).join(`
17
+ `),he=c.useMemo(()=>V.withExplorerSources(t,oe.split(`
18
+ `)),[t,oe]),ce=c.useRef(w);c.useLayoutEffect(()=>{ce.current=w},[w]);const[Pe]=c.useState(()=>(j,J)=>{ce.current?.(j,J)}),et=w===void 0?void 0:Pe,be=c.useRef(d);c.useLayoutEffect(()=>{be.current=d},[d]);const[Rt]=c.useState(()=>{let j=!1;return{convert:(J,te)=>{const ke=be.current;return ke===void 0?Promise.resolve(Ou):ke.convert(J,te)},prepare:()=>{try{be.current?.prepare?.()}catch(J){if(j)return;j=!0,console.error("[markdown-explorer] the draft converter's prepare threw",J)}}}}),_e=d===void 0?void 0:Rt;c.useEffect(()=>{if(v===void 0)return;let j=!0;const J=v(te=>{j&&ua(te,{trees:x.trees,documents:x.documents,edits:K,documentChanges:q,announcer:T,labels:X.current,nameOf:ke=>ur(x.documents,ke),policy:m.current.hostChangePolicy})});if(typeof J!="function")throw j=!1,new TypeError(`[markdown-explorer] subscribeHostChanges must return its unsubscribe function; got ${z.describeValue(J)}`);return()=>{j=!1,J()}},[v,x,K,q,T]);const je=C!==void 0;c.useEffect(()=>{if(je)return K.subscribeDrafts(j=>m.current.onDraftChange?.(j))},[K,je]);const pe=c.useRef({edits:K,announcer:T,mediaFailures:N});c.useLayoutEffect(()=>{pe.current={edits:K,announcer:T,mediaFailures:N}},[K,T,N]);const Ie=c.useRef(null);c.useImperativeHandle(b,()=>({flushUnsaved:()=>{const{edits:j}=pe.current;return j.flushDrafts(),j.dirtyPaths()},confirmDiscard:async j=>{gs("confirmDiscard",j);const{edits:J}=pe.current,te=J.unsavedAmong([...new Set(j)]);return te.length===0?!0:J.askToDiscard(te)},restoreDrafts:async j=>(Es(j),pe.current.edits.restoreDrafts(j)),announce:j=>{ys(j),pe.current.announcer.announce(j)},owns:j=>Ie.current?.contains(j)===!0,reportMediaFailure:j=>{xs(j),pe.current.mediaFailures.report(j)}}),[]);const tt=p===void 0?void 0:S.fetch,nt=L===void 0?$e.onReload:S.reload,Fe=A===void 0?void 0:S.restoreSession,Ct=c.useMemo(()=>({config:he,labels:U,locale:H,theme:_,storageNamespace:n,scope:e.scope,sources:e.sources,notices:W,documents:x.documents,trees:x.trees,data:x.data,viewSettings:y,treeSettings:O,announcer:T,reveals:D,edits:K,mediaFailures:N,documentChanges:q,onEditGrant:g,draftConverter:_e,renderTreeFailure:i,reportMathDiagnostics:et,fetch:tt,guardUnload:k,onReload:nt,onSessionEnded:Fe,accountState:M,confirmUnversionedSaves:B,paletteKey:I}),[he,U,H,_,n,e.scope,e.sources,W,x,y,O,T,D,K,N,q,g,_e,i,et,tt,k,nt,Fe,M,B,I]);return l.jsx(xr,{value:Ct,children:l.jsx(Pu,{renderFrame:a,lockDocumentScroll:f,rootRef:Ie,documentIdAnswer:e.documentId},e.scope)})},Nu=({ref:e,theme:t,view:n,children:r})=>{const[o]=c.useState(Ui);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})},Pu=({renderFrame:e,lockDocumentScroll:t,rootRef:n,documentIdAnswer:r})=>{const{theme:o,labels:s,mediaFailures:a}=F(),i=Ke(),f=uu(i,r),{hash:w}=re.useLocation(),g=xe(),d=vu(t),p=c.useCallback(k=>{if(n.current=k,k===null)return;const L=a.observe(k),A=d(k);return()=>{A?.(),L(),n.current=null}},[a,n,d]);c.useLayoutEffect(()=>{i.kind==="redirect"&&g(`${i.href}${w}`,"browse")},[i,w,g]);const{location:h}=i,v=h.view;xu(n,v);const E=h.view==="tree"?l.jsx(c.Suspense,{fallback:l.jsx("section",{className:"aqmx-split-fallback","aria-label":s.explorerRegion,"aria-busy":"true","data-testid":"markdown-explorer-split-loading",...mt}),children:l.jsx(bu,{location:h,opening:f})}):h.view==="multi"?l.jsx(c.Suspense,{fallback:l.jsx("section",{className:"aqmx-stage-fallback","aria-label":s.multiRegion,"aria-busy":"true","data-testid":"markdown-explorer-stage-loading",...mt}),children:l.jsx(ku,{location:h})}):l.jsx(Wd,{location:h}),b=l.jsxs(Nu,{ref:p,theme:o,view:v,children:[E,l.jsx(ca,{}),l.jsx(ls,{holds:!0,deferWhileFullscreenIn:n,testId:"markdown-explorer-announcer"})]});return e===void 0?b:e({view:v,children:b})},_u=e=>{if(e instanceof Mt.MarkdownResourceExhaustedError||e instanceof Mt.MarkdownConversionTimeoutError)return P.failureDocument("too-large");if(!(e instanceof Mt.MarkdownConversionError))throw e;switch(e.code){case"unavailable":return{kind:"unavailable"};case"invalid_argument":return P.failureDocument("invalid");case"internal":return P.failureDocument("failed");default:throw e}},ju=e=>({timeoutMs:e.conversion.deadlineMs,options:{deniedPathSegments:[...e.deny],maxHtmlBytes:e.conversion.maxHtmlBytes,includeSourceLines:!0}}),Iu=us.createShouldRevalidate({submissions:"skip",otherPath:"skip",query:"skip",hashChange:"skip"});exports.ALLOW_KEY_REPEAT=Et;exports.CONFLICT_OURS_MARKER=kr;exports.CONFLICT_SEPARATOR=Sr;exports.CONFLICT_THEIRS_MARKER=Tr;exports.CONTENT_PANE=mt;exports.ContentSkeleton=ye;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=hr;exports.DocumentPane=Wo;exports.DocumentRefreshBar=is;exports.EXPLORER_ACCOUNT_STATES=mr;exports.EXPLORER_HOST_CHANGE_POLICIES=fr;exports.EXPLORER_THEMES=Kt;exports.EditGrantNotice=Jo;exports.ExplorerLink=zr;exports.FOLDER_README_LOADING=Ar;exports.FailureView=ve;exports.ForwardRef=Ko;exports.ForwardRef$1=Qo;exports.ForwardRef$2=Xo;exports.ImageViewMemoryContext=po;exports.LazyNativeScrollBar=Zr;exports.LiveRegion=ls;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=Er;exports.MARKDOWN_EXPLORER_LABEL_KEYS=rn;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=gr;exports.MARKDOWN_EXPLORER_LOCALES=Zt;exports.MarkdownExplorer=Du;exports.NATIVE_SCROLL_BAR_SLOT_LENGTH=dn;exports.NATIVE_SCROLL_BAR_WIDTH=Na;exports.NEAREST=vt;exports.NO_DOCUMENT=Vo;exports.PAGE_DOCUMENT_REFRESH=as;exports.SCROLL_BAR_CONTROLS=Kr;exports.SheetBarContext=ss;exports.TAP_SCROLL_CIRCLE_GUTTER_LENGTH=fn;exports.TAP_SCROLL_CIRCLE_OFFSET_X=Ia;exports.TAP_SCROLL_CIRCLE_SIZE=un;exports.TAP_SCROLL_CIRCLE_SPEED_RANGE=Yr;exports.TOUCH_SCROLL_BAR_CONTROLS=Xr;exports.alignToStart=mo;exports.anchorOfDoubleClick=$r;exports.anchorOfView=qr;exports.blockAtLine=Hr;exports.chooseEditView=en;exports.consumeKey=on;exports.createEmitter=Ne;exports.cssPixels=Cr;exports.draftAnswerOf=_u;exports.draftConversionOf=ju;exports.editViewOf=es;exports.explorerNavigationOf=Oa;exports.explorerNavigationOptions=La;exports.failureTitleOf=le;exports.findConflictsInLines=Rr;exports.focusWithoutScroll=ln;exports.frameTopOf=Br;exports.isApplePlatform=ns;exports.isEditViewShortcut=rs;exports.isEditingDoubleClick=Fr;exports.isInFullscreenBlock=va;exports.keepInView=lo;exports.lineTopIn=Vr;exports.loadedOf=me;exports.paneShownAlone=Td;exports.positionInSource=Ra;exports.readFolderReadme=Dr;exports.resolveMarkdownExplorerLabels=Wt;exports.scrollBarControlsFor=cn;exports.shouldRevalidateExplorer=Iu;exports.stopKeepingInView=io;exports.toggledEditView=ts;exports.useCoarsePointer=mn;exports.useExplorer=F;exports.useExplorerLocation=Ke;exports.useExplorerNavigate=xe;exports.useIntentPrefetch=Gr;exports.usePageMarkupToggle=yo;exports.useSaveRequest=os;exports.useSideBySide=_r;exports.useViewSetting=ge;exports.visibleTopOf=Ur;