@malloy-publisher/sdk 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Dashboard-H1kJlDFo.es.js → DashboardTile-BFcxdv7R.es.js} +15918 -17760
- package/dist/DashboardTile-sg8LjUk8.cjs.js +137 -0
- package/dist/RenderedResult-B48wAjM8.cjs.js +141 -0
- package/dist/{RenderedResult-BRgIgxWh.es.js → RenderedResult-CBLHr32C.es.js} +193 -183
- package/dist/{ServerProvider-Boxrv6Ym.es.js → ServerProvider-DCV8BUWD.es.js} +529 -521
- package/dist/ServerProvider-HRqT3w1C.cjs.js +1 -0
- package/dist/builder/index.cjs.js +146 -58
- package/dist/builder/index.es.js +9076 -6479
- package/dist/builder-entry.d.ts +4 -0
- package/dist/client/api.d.ts +82 -48
- package/dist/client/configuration.d.ts +1 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.es.js +84 -82
- package/dist/components/Dashboard/Dashboard.d.ts +8 -15
- package/dist/components/Dashboard/DashboardGrid.d.ts +23 -6
- package/dist/components/Dashboard/DashboardTile.d.ts +10 -1
- package/dist/components/Dashboard/DashboardView.d.ts +36 -0
- package/dist/components/Dashboard/TileCard.d.ts +15 -4
- package/dist/components/Dashboard/TileFilterTag.d.ts +12 -0
- package/dist/components/Dashboard/index.d.ts +3 -0
- package/dist/components/Dashboard/telemetry.d.ts +15 -3
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +8 -1
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +16 -5
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +29 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +48 -21
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +17 -4
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +2 -10
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +2 -2
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +3 -1
- package/dist/components/DashboardBuilder/InlineMarkdown.d.ts +18 -0
- package/dist/components/DashboardBuilder/InlineText.d.ts +19 -0
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +15 -0
- package/dist/components/DashboardBuilder/SaveNotice.d.ts +27 -0
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +19 -7
- package/dist/components/DashboardBuilder/SourceViewPicker.d.ts +9 -0
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +7 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +14 -12
- package/dist/components/DashboardBuilder/TileMenu.d.ts +11 -3
- package/dist/components/DashboardBuilder/annotationText.d.ts +4 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +4 -0
- package/dist/components/DashboardBuilder/changedTile.d.ts +7 -0
- package/dist/components/DashboardBuilder/chartLine.d.ts +33 -0
- package/dist/components/DashboardBuilder/controls.d.ts +2 -2
- package/dist/components/DashboardBuilder/document.d.ts +42 -26
- package/dist/components/DashboardBuilder/documentSession.d.ts +100 -0
- package/dist/components/DashboardBuilder/legacyNotebook.d.ts +73 -0
- package/dist/components/DashboardBuilder/loadMalloy.d.ts +15 -0
- package/dist/components/DashboardBuilder/malloyText.d.ts +45 -5
- package/dist/components/DashboardBuilder/malloyTree.d.ts +119 -0
- package/dist/components/DashboardBuilder/newDashboard.d.ts +3 -1
- package/dist/components/DashboardBuilder/openDraft.d.ts +10 -0
- package/dist/components/DashboardBuilder/preview.d.ts +24 -4
- package/dist/components/DashboardBuilder/readDocument.d.ts +4 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +16 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +14 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +13 -13
- package/dist/components/DashboardBuilder/spliceResult.d.ts +11 -0
- package/dist/components/DashboardBuilder/tagParse.d.ts +24 -0
- package/dist/components/DashboardBuilder/telemetry.d.ts +43 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +3 -1
- package/dist/components/DashboardBuilder/testing/inline.d.ts +4 -0
- package/dist/components/DashboardBuilder/useBuilderSession.d.ts +89 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +9 -6
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +17 -55
- package/dist/components/DashboardBuilder/useDocumentEditor.d.ts +105 -0
- package/dist/components/DashboardBuilder/useExitGuard.d.ts +19 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +3 -3
- package/dist/components/DocumentCreate/canRetry.d.ts +6 -0
- package/dist/components/DocumentCreate/createDocument.d.ts +58 -0
- package/dist/components/DocumentCreate/documentPath.d.ts +10 -0
- package/dist/components/DocumentCreate/events.d.ts +10 -0
- package/dist/components/DocumentCreate/exportedSources.d.ts +7 -0
- package/dist/components/DocumentCreate/guards.d.ts +12 -0
- package/dist/components/DocumentCreate/index.d.ts +6 -0
- package/dist/components/DocumentCreate/newNotebook.d.ts +9 -0
- package/dist/components/DocumentCreate/useDocumentChoices.d.ts +32 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +2 -1
- package/dist/components/NarrowEditGate.d.ts +8 -0
- package/dist/components/Notebook/Notebook.d.ts +1 -1
- package/dist/components/Package/NewDocumentDialog.d.ts +33 -0
- package/dist/components/Package/Package.d.ts +1 -0
- package/dist/components/Package/documentLocation.d.ts +28 -0
- package/dist/components/Package/index.d.ts +4 -0
- package/dist/components/Package/useDocumentLocation.d.ts +12 -0
- package/dist/components/PackageSection.d.ts +2 -2
- package/dist/components/RenderedResult/RenderedResult.d.ts +2 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +8 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +3 -1
- package/dist/components/RenderedResult/resultSizing.d.ts +9 -1
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/UnsavedChangesDialog.d.ts +9 -0
- package/dist/components/given/GivensPanel.d.ts +2 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useNarrowScreen.d.ts +4 -0
- package/dist/hooks/useQueryResult.d.ts +2 -0
- package/dist/hooks/useSettled.d.ts +14 -0
- package/dist/index.cjs.js +23 -24
- package/dist/index.es.js +9714 -7072
- package/dist/text/index.cjs.js +1 -0
- package/dist/text/index.d.ts +2 -0
- package/dist/text/index.es.js +6 -0
- package/dist/text-entry-BJwltZiy.cjs.js +7 -0
- package/dist/text-entry-CbbBcZl8.es.js +196 -0
- package/dist/text-entry.d.ts +2 -0
- package/dist/utils/clock.d.ts +2 -0
- package/package.json +10 -1
- package/src/builder-entry.ts +35 -0
- package/src/components/Dashboard/Dashboard.tsx +27 -278
- package/src/components/Dashboard/DashboardGrid.tsx +68 -7
- package/src/components/Dashboard/DashboardTile.spec.tsx +24 -0
- package/src/components/Dashboard/DashboardTile.tsx +31 -4
- package/src/components/Dashboard/DashboardView.spec.tsx +212 -0
- package/src/components/Dashboard/DashboardView.tsx +352 -0
- package/src/components/Dashboard/RowsDialog.tsx +1 -1
- package/src/components/Dashboard/TileCard.tsx +44 -10
- package/src/components/Dashboard/TileFilterTag.spec.tsx +73 -0
- package/src/components/Dashboard/TileFilterTag.tsx +78 -0
- package/src/components/Dashboard/defaultTileSpan.spec.ts +32 -0
- package/src/components/Dashboard/index.ts +3 -0
- package/src/components/Dashboard/telemetry.ts +16 -5
- package/src/components/DashboardBuilder/AddTileDialog.spec.tsx +88 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +137 -111
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +85 -27
- package/src/components/DashboardBuilder/ChartPicker.render.spec.tsx +25 -0
- package/src/components/DashboardBuilder/ChartPicker.spec.ts +77 -0
- package/src/components/DashboardBuilder/ChartPicker.tsx +153 -0
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +205 -0
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +192 -0
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +329 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +363 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +194 -0
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +157 -0
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +124 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +103 -78
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +177 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +610 -315
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +58 -8
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +191 -0
- package/src/components/DashboardBuilder/DashboardEditor.filterTag.spec.tsx +162 -0
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +316 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +56 -10
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +5 -22
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +96 -14
- package/src/components/DashboardBuilder/DashboardEditor.tsx +482 -332
- package/src/components/DashboardBuilder/DiffDialog.spec.tsx +25 -0
- package/src/components/DashboardBuilder/DiffDialog.tsx +5 -24
- package/src/components/DashboardBuilder/DrillDialog.tsx +1 -1
- package/src/components/DashboardBuilder/FilterDialog.tsx +10 -3
- package/src/components/DashboardBuilder/FilterStrip.tsx +26 -4
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +184 -0
- package/src/components/DashboardBuilder/InlineText.tsx +106 -0
- package/src/components/DashboardBuilder/NotebookEditor.tsx +44 -0
- package/src/components/DashboardBuilder/SaveNotice.tsx +113 -0
- package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +87 -0
- package/src/components/DashboardBuilder/SettingsPopover.tsx +225 -67
- package/src/components/DashboardBuilder/SourceViewPicker.tsx +122 -0
- package/src/components/DashboardBuilder/TextTileBody.tsx +28 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +89 -115
- package/src/components/DashboardBuilder/TileMenu.tsx +168 -90
- package/src/components/DashboardBuilder/annotationText.spec.ts +33 -0
- package/src/components/DashboardBuilder/annotationText.ts +17 -0
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +248 -0
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +41 -0
- package/src/components/DashboardBuilder/catalog.aggregate.spec.ts +49 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +2 -0
- package/src/components/DashboardBuilder/catalog.ts +61 -21
- package/src/components/DashboardBuilder/changedTile.spec.ts +46 -0
- package/src/components/DashboardBuilder/changedTile.ts +28 -0
- package/src/components/DashboardBuilder/chartLine.spec.ts +180 -0
- package/src/components/DashboardBuilder/chartLine.ts +121 -0
- package/src/components/DashboardBuilder/controls.spec.ts +21 -10
- package/src/components/DashboardBuilder/controls.ts +22 -8
- package/src/components/DashboardBuilder/document.ts +53 -5
- package/src/components/DashboardBuilder/documentSession.spec.ts +209 -0
- package/src/components/DashboardBuilder/documentSession.ts +257 -0
- package/src/components/DashboardBuilder/emptyStart.spec.ts +131 -0
- package/src/components/DashboardBuilder/invariants.spec.ts +6 -2
- package/src/components/DashboardBuilder/legacyNotebook.chart.spec.ts +77 -0
- package/src/components/DashboardBuilder/legacyNotebook.convert.spec.ts +630 -0
- package/src/components/DashboardBuilder/legacyNotebook.read.spec.ts +338 -0
- package/src/components/DashboardBuilder/legacyNotebook.ts +1117 -0
- package/src/components/DashboardBuilder/loadMalloy.spec.ts +80 -0
- package/src/components/DashboardBuilder/loadMalloy.ts +39 -0
- package/src/components/DashboardBuilder/malloyText.spec.ts +48 -0
- package/src/components/DashboardBuilder/malloyText.ts +181 -27
- package/src/components/DashboardBuilder/malloyTree.ts +155 -7
- package/src/components/DashboardBuilder/newDashboard.spec.ts +46 -2
- package/src/components/DashboardBuilder/newDashboard.ts +30 -3
- package/src/components/DashboardBuilder/openDraft.ts +52 -0
- package/src/components/DashboardBuilder/preview.shapes.spec.ts +75 -0
- package/src/components/DashboardBuilder/preview.spec.ts +159 -12
- package/src/components/DashboardBuilder/preview.ts +83 -9
- package/src/components/DashboardBuilder/readDocument.spec.ts +139 -27
- package/src/components/DashboardBuilder/readDocument.ts +130 -44
- package/src/components/DashboardBuilder/readForEditor.spec.ts +80 -0
- package/src/components/DashboardBuilder/readForEditor.ts +47 -0
- package/src/components/DashboardBuilder/scannerShapes.spec.ts +14 -13
- package/src/components/DashboardBuilder/sortable.spec.ts +65 -0
- package/src/components/DashboardBuilder/sortable.tsx +2 -12
- package/src/components/DashboardBuilder/spliceDocument.chart.spec.ts +340 -0
- package/src/components/DashboardBuilder/spliceDocument.imports.spec.ts +167 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +229 -94
- package/src/components/DashboardBuilder/spliceDocument.ts +762 -130
- package/src/components/DashboardBuilder/spliceResult.ts +15 -0
- package/src/components/DashboardBuilder/statementExtent.spec.ts +33 -30
- package/src/components/DashboardBuilder/tagParse.spec.ts +149 -0
- package/src/components/DashboardBuilder/tagParse.ts +103 -0
- package/src/components/DashboardBuilder/telemetry.ts +47 -0
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +197 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +16 -1
- package/src/components/DashboardBuilder/testing/inline.ts +25 -0
- package/src/components/DashboardBuilder/textTiles.spec.ts +718 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +335 -0
- package/src/components/DashboardBuilder/useBuilderSession.ts +292 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +65 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.spec.tsx +60 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +36 -10
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +16 -13
- package/src/components/DashboardBuilder/useDashboardEditor.ts +54 -181
- package/src/components/DashboardBuilder/useDocumentEditor.spec.ts +565 -0
- package/src/components/DashboardBuilder/useDocumentEditor.ts +399 -0
- package/src/components/DashboardBuilder/useExitGuard.spec.ts +159 -0
- package/src/components/DashboardBuilder/useExitGuard.ts +89 -0
- package/src/components/DashboardBuilder/useFilterForm.existing.spec.tsx +41 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +24 -2
- package/src/components/DashboardBuilder/useFilterForm.ts +41 -13
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +28 -5
- package/src/components/DashboardBuilder/useTileReorder.ts +5 -7
- package/src/components/DocumentCreate/canRetry.spec.ts +32 -0
- package/src/components/DocumentCreate/canRetry.ts +19 -0
- package/src/components/DocumentCreate/createDocument.spec.ts +310 -0
- package/src/components/DocumentCreate/createDocument.ts +159 -0
- package/src/components/DocumentCreate/documentPath.ts +40 -0
- package/src/components/DocumentCreate/events.ts +15 -0
- package/src/components/DocumentCreate/exportedSources.ts +25 -0
- package/src/components/DocumentCreate/guards.ts +45 -0
- package/src/components/DocumentCreate/index.ts +27 -0
- package/src/components/DocumentCreate/newNotebook.spec.ts +156 -0
- package/src/components/DocumentCreate/newNotebook.ts +44 -0
- package/src/components/DocumentCreate/useDocumentChoices.spec.tsx +138 -0
- package/src/components/DocumentCreate/useDocumentChoices.ts +113 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +2 -1
- package/src/components/Model/ModelExplorer.spec.tsx +2 -2
- package/src/components/Model/SourcesExplorer.tsx +2 -4
- package/src/components/NarrowEditGate.spec.tsx +73 -0
- package/src/components/NarrowEditGate.tsx +29 -0
- package/src/components/Notebook/Notebook.layout.spec.tsx +94 -0
- package/src/components/Notebook/Notebook.tsx +66 -27
- package/src/components/Package/NewDocumentDialog.spec.tsx +749 -0
- package/src/components/Package/NewDocumentDialog.tsx +401 -0
- package/src/components/Package/Package.artifacts.spec.tsx +190 -0
- package/src/components/Package/Package.create.spec.tsx +380 -0
- package/src/components/Package/Package.notebooks.spec.tsx +18 -0
- package/src/components/Package/Package.tsx +366 -171
- package/src/components/Package/documentLocation.spec.ts +81 -0
- package/src/components/Package/documentLocation.ts +55 -0
- package/src/components/Package/index.ts +13 -0
- package/src/components/Package/useDocumentLocation.ts +59 -0
- package/src/components/PackageSection.tsx +2 -2
- package/src/components/RenderedResult/RenderedResult.tsx +18 -1
- package/src/components/RenderedResult/ResultContainer.tsx +44 -11
- package/src/components/RenderedResult/ResultPanel.tsx +4 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +68 -0
- package/src/components/RenderedResult/resultSizing.ts +14 -3
- package/src/components/ServerProvider.tsx +2 -1
- package/src/components/UnsavedChangesDialog.spec.tsx +70 -0
- package/src/components/UnsavedChangesDialog.tsx +49 -0
- package/src/components/given/GivensPanel.spec.tsx +6 -6
- package/src/components/given/GivensPanel.tsx +3 -3
- package/src/components/index.ts +2 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useNarrowScreen.ts +21 -0
- package/src/hooks/useQueryResult.ts +16 -0
- package/src/hooks/useSettled.spec.ts +41 -0
- package/src/hooks/useSettled.ts +27 -0
- package/src/mainEntry.spec.ts +145 -0
- package/src/text-entry.ts +12 -0
- package/src/textEntry.spec.ts +118 -0
- package/src/utils/clock.spec.ts +12 -0
- package/src/utils/clock.ts +6 -0
- package/vite.config.ts +4 -0
- package/dist/Dashboard-ChyylkTD.cjs.js +0 -136
- package/dist/RenderedResult-AJPMUkAD.cjs.js +0 -135
- package/dist/ServerProvider-CXrOKD6g.cjs.js +0 -1
- package/dist/components/DashboardBuilder/useTileResize.d.ts +0 -29
- package/dist/components/Package/NewDashboardDialog.d.ts +0 -18
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +0 -121
- package/src/components/DashboardBuilder/useTileResize.ts +0 -110
- package/src/components/Package/NewDashboardDialog.spec.tsx +0 -129
- package/src/components/Package/NewDashboardDialog.tsx +0 -265
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
"use strict";var nu=Object.create;var oa=Object.defineProperty;var ru=Object.getOwnPropertyDescriptor;var iu=Object.getOwnPropertyNames;var su=Object.getPrototypeOf,ou=Object.prototype.hasOwnProperty;var au=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of iu(t))!ou.call(e,i)&&i!==n&&oa(e,i,{get:()=>t[i],enumerable:!(r=ru(t,i))||r.enumerable});return e};var aa=(e,t,n)=>(n=e!=null?nu(su(e)):{},au(t||!e||!e.__esModule?oa(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),S=require("react"),lu=require("react-dom"),k=require("@mui/material"),j=require("../Dashboard-ChyylkTD.cjs.js"),Be=require("../ServerProvider-CXrOKD6g.cjs.js"),cu=require("@tanstack/react-query");var du=Symbol.for("preact-signals");function Pi(){if(vt>1)vt--;else{var e,t=!1;for((function(){var i=ui;for(ui=void 0;i!==void 0;){var s=i.S;if(s.v===i.v)for(var o=s.t;o!==void 0;o=o.x)o.i===i.i&&(o.i=s.i);i=i.o}})();cr!==void 0;){var n=cr;for(cr=void 0,di++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&ll(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(di=0,vt--,t)throw e}}function ue(e){if(vt>0)return e();us=++uu,vt++;try{return e()}finally{Pi()}}var lr,ie=void 0;function H(e){var t=ie,n=lr;ie=void 0,lr=void 0;try{return e()}finally{ie=t,lr=n}}var cr=void 0,vt=0,di=0,uu=0,us=0,ui=void 0,fi=0;function al(e){if(ie!==void 0){var t=e.n;if(t===void 0||t.t!==ie)return t={i:0,S:e,p:ie.s,n:void 0,t:ie,e:void 0,x:void 0,r:t},ie.s!==void 0&&(ie.s.n=t),ie.s=t,e.n=t,32&ie.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=ie.s,t.n=void 0,ie.s.n=t,ie.s=t),t}}function Re(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}Re.prototype.brand=du;Re.prototype.h=function(){return!0};Re.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:H(function(){var r;(r=t.W)==null||r.call(t)}))};Re.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&H(function(){var i;(i=t.Z)==null||i.call(t)}))}};Re.prototype.subscribe=function(e){var t=this;return tt(function(){var n=t.value;H(function(){return e(n)})},{name:"sub"})};Re.prototype.valueOf=function(){return this.value};Re.prototype.toString=function(){return this.value+""};Re.prototype.toJSON=function(){return this.value};Re.prototype.peek=function(){var e=this;return H(function(){return e.value})};Object.defineProperty(Re.prototype,"value",{get:function(){var e=al(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(di>100)throw new Error("Cycle detected");(function(n){vt!==0&&di===0&&n.l!==us&&(n.l=us,ui={S:n,v:n.v,i:n.i,o:ui})})(this),this.v=e,this.i++,fi++,vt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Pi()}}}});function En(e,t){return new Re(e,t)}function ll(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function cl(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function dl(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function Ht(e,t){Re.call(this,void 0,t),this.x=e,this.s=void 0,this.g=fi-1,this.f=4}Ht.prototype=new Re;Ht.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===fi))return!0;if(this.g=fi,this.f|=1,this.i>0&&!ll(this))return this.f&=-2,!0;var e=ie;try{cl(this),ie=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return ie=e,dl(this),this.f&=-2,!0};Ht.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}Re.prototype.S.call(this,e)};Ht.prototype.U=function(e){if(this.t!==void 0&&(Re.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};Ht.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(Ht.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=al(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function la(e,t){return new Ht(e,t)}function ul(e){var t=e.m;if(e.m=void 0,typeof t=="function"){vt++;var n=ie;ie=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,to(e),r}finally{ie=n,Pi()}}}function to(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,ul(e)}function fu(e){if(ie!==this)throw new Error("Out-of-order effect");dl(this),ie=e,this.f&=-2,8&this.f&&to(this),Pi()}function On(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,lr&&lr.push(this)}On.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};On.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ul(this),cl(this),vt++;var e=ie;return ie=this,fu.bind(this,e)};On.prototype.N=function(){2&this.f||(this.f|=2,this.u=cr,cr=this)};On.prototype.d=function(){this.f|=8,1&this.f||to(this)};On.prototype.dispose=function(){this.d()};function tt(e,t){var n=new On(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var hu=Object.create,no=Object.defineProperty,pu=Object.defineProperties,gu=Object.getOwnPropertyDescriptor,vu=Object.getOwnPropertyDescriptors,ca=Object.getOwnPropertySymbols,mu=Object.prototype.hasOwnProperty,yu=Object.prototype.propertyIsEnumerable,bu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Tn=e=>{throw TypeError(e)},fs=(e,t,n)=>t in e?no(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xu=(e,t)=>{for(var n in t||(t={}))mu.call(t,n)&&fs(e,n,t[n]);if(ca)for(var n of ca(t))yu.call(t,n)&&fs(e,n,t[n]);return e},wu=(e,t)=>pu(e,vu(t)),da=(e,t)=>no(e,"name",{value:t,configurable:!0}),_u=e=>{var t;return[,,,hu((t=void 0)!=null?t:null)]},fl=["class","method","getter","setter","accessor","field","value","get","set"],qn=e=>e!==void 0&&typeof e!="function"?Tn("Function expected"):e,ku=(e,t,n,r,i)=>({kind:fl[e],name:t,metadata:r,addInitializer:s=>n._?Tn("Already initialized"):i.push(qn(s||null))}),hl=(e,t)=>fs(t,bu("metadata"),e[3]),Mt=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},Dn=(e,t,n,r,i,s)=>{var o,a,l,u,d,c=t&7,h=!!(t&8),f=!!(t&16),v=c>3?e.length+1:c?h?1:2:0,p=fl[c+5],w=c>3&&(e[v-1]=[]),x=e[v]||(e[v]=[]),m=c&&(!f&&!h&&(i=i.prototype),c<5&&(c>3||!f)&&gu(c<4?i:{get[n](){return Qe(this,s)},set[n](b){return kt(this,s,b)}},n));c?f&&c<4&&da(s,(c>2?"set ":c>1?"get ":"")+n):da(i,n);for(var g=r.length-1;g>=0;g--)u=ku(c,n,l={},e[3],x),c&&(u.static=h,u.private=f,d=u.access={has:f?b=>Su(i,b):b=>n in b},c^3&&(d.get=f?b=>(c^1?Qe:$u)(b,i,c^4?s:m.get):b=>b[n]),c>2&&(d.set=f?(b,_)=>kt(b,i,_,c^4?s:m.set):(b,_)=>b[n]=_)),a=(0,r[g])(c?c<4?f?s:m[p]:c>4?void 0:{get:m.get,set:m.set}:i,u),l._=1,c^4||a===void 0?qn(a)&&(c>4?w.unshift(a):c?f?s=a:m[p]=a:i=a):typeof a!="object"||a===null?Tn("Object expected"):(qn(o=a.get)&&(m.get=o),qn(o=a.set)&&(m.set=o),qn(o=a.init)&&w.unshift(o));return c||hl(e,i),m&&no(i,n,m),f?c^4?s:m:i},ro=(e,t,n)=>t.has(e)||Tn("Cannot "+n),Su=(e,t)=>Object(t)!==t?Tn('Cannot use the "in" operator on this value'):e.has(t),Qe=(e,t,n)=>(ro(e,t,"read from private field"),n?n.call(e):t.get(e)),Hn=(e,t,n)=>t.has(e)?Tn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),kt=(e,t,n,r)=>(ro(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),$u=(e,t,n)=>(ro(e,t,"access private method"),n);function hs(e,t){if(t){let n;return la(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return la(e)}function rt(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((r,i)=>!rt(r,t[i]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(s=>!rt(e[s],t[s]))}return!1}function K({get:e},t){return{init(n){return En(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function ge(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=hs(e.bind(this)),n.set(this,r)),r.value}}function Hi(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),i=Object.getOwnPropertyDescriptor(r,n.name);i&&Object.defineProperty(r,n.name,wu(xu({},i),{enumerable:e}))})}}function $r(...e){const t=e.map(n=>tt(n));return()=>t.forEach(n=>n())}var pl,gl,vl,ml,yl,bl,Ie,io,Ki,ps,gs,Pe,so,Yi,xl,vs,oo,Xi,ms,ys;bl=[K],yl=[K],ml=[K],vl=[Hi()],gl=[Hi()],pl=[Hi()];var Kt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Mt(Ie,5,this),Hn(this,Pe),Hn(this,io,Mt(Ie,8,this)),Mt(Ie,11,this),Hn(this,so,Mt(Ie,12,this)),Mt(Ie,15,this),Hn(this,oo,Mt(Ie,16,this)),Mt(Ie,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Qe(this,Pe,ms)}get initial(){return Qe(this,Pe,ps)}get previous(){return Qe(this,Pe,xl)}set current(e){const t=H(()=>Qe(this,Pe,ms));e&&t&&this.equals(t,e)||ue(()=>{Qe(this,Pe,ps)||kt(this,Pe,e,gs),kt(this,Pe,t,vs),kt(this,Pe,e,ys)})}reset(e=this.defaultValue){ue(()=>{kt(this,Pe,void 0,vs),kt(this,Pe,e,gs),kt(this,Pe,e,ys)})}};Ie=_u();io=new WeakMap;Pe=new WeakSet;so=new WeakMap;oo=new WeakMap;Ki=Dn(Ie,20,"#initial",bl,Pe,io),ps=Ki.get,gs=Ki.set;Yi=Dn(Ie,20,"#previous",yl,Pe,so),xl=Yi.get,vs=Yi.set;Xi=Dn(Ie,20,"#current",ml,Pe,oo),ms=Xi.get,ys=Xi.set;Dn(Ie,2,"current",vl,Kt);Dn(Ie,2,"initial",gl,Kt);Dn(Ie,2,"previous",pl,Kt);hl(Ie,Kt);function Qi(e){return H(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var It,Eu=class{constructor(){Hn(this,It,new WeakMap)}get(e,t){var n;return e?(n=Qe(this,It).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Qe(this,It).has(e)||Qe(this,It).set(e,new Map),(r=Qe(this,It).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Qe(this,It).get(e))==null?void 0:t.clear():void 0}};It=new WeakMap;var Ou=Object.create,wl=Object.defineProperty,Tu=Object.getOwnPropertyDescriptor,ua=Object.getOwnPropertySymbols,Du=Object.prototype.hasOwnProperty,Cu=Object.prototype.propertyIsEnumerable,_l=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Mi=e=>{throw TypeError(e)},fa=Math.pow,bs=(e,t,n)=>t in e?wl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pu=(e,t)=>{for(var n in t||(t={}))Du.call(t,n)&&bs(e,n,t[n]);if(ua)for(var n of ua(t))Cu.call(t,n)&&bs(e,n,t[n]);return e},Mu=e=>{var t;return[,,,Ou((t=e?.[_l("metadata")])!=null?t:null)]},kl=["class","method","getter","setter","accessor","field","value","get","set"],Sl=e=>e!==void 0&&typeof e!="function"?Mi("Function expected"):e,Iu=(e,t,n,r,i)=>({kind:kl[e],name:t,metadata:r,addInitializer:s=>n._?Mi("Already initialized"):i.push(Sl(s||null))}),ju=(e,t)=>bs(t,_l("metadata"),e[3]),Au=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)s[i].call(n);return r},$l=(e,t,n,r,i,s)=>{for(var o,a,l,u,d=t&7,c=!1,h=!1,f=2,v=kl[d+5],p=e[f]||(e[f]=[]),w=(i=i.prototype,Tu(i,n)),x=r.length-1;x>=0;x--)l=Iu(d,n,a={},e[3],p),l.static=c,l.private=h,u=l.access={has:m=>n in m},u.get=m=>m[n],o=(0,r[x])(w[v],l),a._=1,Sl(o)&&(w[v]=o);return w&&wl(i,n,w),i},El=(e,t,n)=>t.has(e)||Mi("Cannot "+n),Ru=(e,t,n)=>(El(e,t,"read from private field"),t.get(e)),Lu=(e,t,n)=>t.has(e)?Mi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Wu=(e,t,n,r)=>(El(e,t,"write to private field"),t.set(e,n),n),Ze=class xs{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new xs(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new xs(t,n)}},dt=class jt{constructor(t,n,r,i){this.left=t,this.top=n,this.width=r,this.height=i,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:i,width:s,height:o,scale:a}=this,l=new jt(i+t,r+n,s,o);return l.scale=Pu({},a),l}get boundingRectangle(){const{width:t,height:n,left:r,top:i,right:s,bottom:o}=this;return{width:t,height:n,left:r,top:i,right:s,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:i}=this;return new Ze((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof jt))return!1;const{left:n,top:r,width:i,height:s}=this;return n===t.left&&r===t.top&&i===t.width&&s===t.height}containsPoint(t){const{top:n,left:r,bottom:i,right:s}=this;return n<=t.y&&t.y<=i&&r<=t.x&&t.x<=s}intersectionArea(t){return t instanceof jt?zu(this,t):0}intersectionRatio(t){const{area:n}=this,r=this.intersectionArea(t);return r/(t.area+n-r)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}get aspectRatio(){const{width:t,height:n}=this;return t/n}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:i}){return new jt(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],l=o==="x"?s.left:s.top,u=o==="x"?s.width:s.height;return a=="start"?l:a=="end"?l+u:l+u/2};return Ze.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return jt.from(t).intersectionRatio(jt.from(n))}};function zu(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),o=i-r,a=s-n;return r<i&&n<s?o*a:0}var Ol,Tl,ws,Xr,Er,Ii=class extends(ws=Kt,Tl=[ge],Ol=[ge],ws){constructor(t){const n=Ze.from(t);super(n,(r,i)=>Ze.equals(r,i)),Au(Er,5,this),Lu(this,Xr,0),this.velocity={x:0,y:0}}get delta(){return Ze.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=Ze.from(t),i={x:r.x-n.x,y:r.y-n.y},s=Date.now(),o=s-Ru(this,Xr),a=l=>Math.round(l/o*100);ue(()=>{Wu(this,Xr,s),this.velocity={x:a(i.x),y:a(i.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Ze.from(t)),this.velocity={x:0,y:0}}};Er=Mu(ws);Xr=new WeakMap;$l(Er,2,"delta",Tl,Ii);$l(Er,2,"direction",Ol,Ii);ju(Er,Ii);function _s({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(fa(r,2)+fa(i,2))>n:"x"in n&&"y"in n?r>n.x&&i>n.y:"x"in n?r>n.x:"y"in n?i>n.y:!1}var Dl=(e=>(e.Horizontal="x",e.Vertical="y",e))(Dl||{}),Cl=Object.values(Dl),Fu=Object.create,ao=Object.defineProperty,Nu=Object.defineProperties,Bu=Object.getOwnPropertyDescriptor,Vu=Object.getOwnPropertyDescriptors,hi=Object.getOwnPropertySymbols,Pl=Object.prototype.hasOwnProperty,Ml=Object.prototype.propertyIsEnumerable,Il=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Cn=e=>{throw TypeError(e)},ks=(e,t,n)=>t in e?ao(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lo=(e,t)=>{for(var n in t||(t={}))Pl.call(t,n)&&ks(e,n,t[n]);if(hi)for(var n of hi(t))Ml.call(t,n)&&ks(e,n,t[n]);return e},co=(e,t)=>Nu(e,Vu(t)),ha=(e,t)=>ao(e,"name",{value:t,configurable:!0}),jl=(e,t)=>{var n={};for(var r in e)Pl.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&hi)for(var r of hi(e))t.indexOf(r)<0&&Ml.call(e,r)&&(n[r]=e[r]);return n},Pn=e=>{var t;return[,,,Fu((t=e?.[Il("metadata")])!=null?t:null)]},Al=["class","method","getter","setter","accessor","field","value","get","set"],Kn=e=>e!==void 0&&typeof e!="function"?Cn("Function expected"):e,Gu=(e,t,n,r,i)=>({kind:Al[e],name:t,metadata:r,addInitializer:s=>n._?Cn("Already initialized"):i.push(Kn(s||null))}),Yt=(e,t)=>ks(t,Il("metadata"),e[3]),N=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},Y=(e,t,n,r,i,s)=>{var o,a,l,u,d,c=t&7,h=!!(t&8),f=!!(t&16),v=c>3?e.length+1:c?h?1:2:0,p=Al[c+5],w=c>3&&(e[v-1]=[]),x=e[v]||(e[v]=[]),m=c&&(!f&&!h&&(i=i.prototype),c<5&&(c>3||!f)&&Bu(c<4?i:{get[n](){return pe(this,s)},set[n](b){return He(this,s,b)}},n));c?f&&c<4&&ha(s,(c>2?"set ":c>1?"get ":"")+n):ha(i,n);for(var g=r.length-1;g>=0;g--)u=Gu(c,n,l={},e[3],x),c&&(u.static=h,u.private=f,d=u.access={has:f?b=>Uu(i,b):b=>n in b},c^3&&(d.get=f?b=>(c^1?pe:Rl)(b,i,c^4?s:m.get):b=>b[n]),c>2&&(d.set=f?(b,_)=>He(b,i,_,c^4?s:m.set):(b,_)=>b[n]=_)),a=(0,r[g])(c?c<4?f?s:m[p]:c>4?void 0:{get:m.get,set:m.set}:i,u),l._=1,c^4||a===void 0?Kn(a)&&(c>4?w.unshift(a):c?f?s=a:m[p]=a:i=a):typeof a!="object"||a===null?Cn("Object expected"):(Kn(o=a.get)&&(m.get=o),Kn(o=a.set)&&(m.set=o),Kn(o=a.init)&&w.unshift(o));return c||Yt(e,i),m&&ao(i,n,m),f?c^4?s:m:i},uo=(e,t,n)=>t.has(e)||Cn("Cannot "+n),Uu=(e,t)=>Object(t)!==t?Cn('Cannot use the "in" operator on this value'):e.has(t),pe=(e,t,n)=>(uo(e,t,"read from private field"),n?n.call(e):t.get(e)),J=(e,t,n)=>t.has(e)?Cn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),He=(e,t,n,r)=>(uo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Rl=(e,t,n)=>(uo(e,t,"access private method"),n);function Ll(e,t){return{plugin:e,options:t}}function Or(e){return t=>Ll(e,t)}function gr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Wl,vr,fo,Qr;Wl=[K];var Me=class{constructor(e,t){this.manager=e,this.options=t,J(this,fo,N(vr,8,this,!1)),N(vr,11,this),J(this,Qr,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return H(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=tt(e.bind(this));return pe(this,Qr).add(t),t}destroy(){pe(this,Qr).forEach(e=>e())}static configure(e){return Ll(this,e)}};vr=Pn(null);fo=new WeakMap;Qr=new WeakMap;Y(vr,4,"disabled",Wl,Me,fo);Yt(vr,Me);var Tr=class extends Me{},Zr,Zi=class{constructor(e){this.manager=e,this.instances=new Map,J(this,Zr,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(gr).reduce((r,i)=>{const s=r.find(({plugin:o})=>o===i.plugin);return s?(s.options=i.options,r):[...r,i]},[]),n=t.map(({plugin:r})=>r);for(const r of pe(this,Zr))if(!n.includes(r)){if(r.prototype instanceof Tr)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);He(this,Zr,n)}get(e){return this.instances.get(e)}register(e,t){const n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;const r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){const t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(const e of this.instances.values())e.destroy();this.instances.clear()}};Zr=new WeakMap;function qu(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Wr=[],an,ln,Hu=class extends Me{constructor(e){super(e),J(this,an),J(this,ln),this.computeCollisions=this.computeCollisions.bind(this),He(this,ln,En(Wr)),this.destroy=$r(()=>{const t=this.computeCollisions(),n=H(()=>this.manager.dragOperation.position.current);if(t!==Wr){const r=pe(this,an);if(He(this,an,n),r&&n.x==r.x&&n.y==r.y)return}else He(this,an,void 0);pe(this,ln).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){H(()=>{e?pe(this,ln).value=this.computeCollisions():He(this,an,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return Wr;const a=[],l=[];for(const u of e??n.droppables){if(u.disabled||i&&!u.accepts(i))continue;const d=t??u.collisionDetector;if(!d)continue;l.push(u),u.shape;const c=H(()=>d({droppable:u,dragOperation:r}));c&&(u.collisionPriority!=null&&(c.priority=u.collisionPriority),a.push(c))}return l.length===0?Wr:(a.sort(qu),a)}get collisions(){return pe(this,ln).value}};an=new WeakMap;ln=new WeakMap;var zl,Fl,Nl,ho,Bl,it,po,pn,go,vo;Nl=[K],Fl=[K],zl=[K];var yt=class At{constructor(t,n){J(this,po,N(it,8,this)),N(it,11,this),J(this,pn),J(this,go,N(it,12,this)),N(it,15,this),J(this,vo,N(it,16,this)),N(it,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let l=i;He(this,pn,En(i)),this.manager=n,this.data=s,this.disabled=o,this.effects=()=>{var u;return[()=>{const{id:d,manager:c}=this;if(d!==l)return l=d,c?.registry.register(this),()=>c?.registry.unregister(this)},...(u=r?.())!=null?u:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),n&&a&&queueMicrotask(this.register)}get id(){var t,n;const r=pe(this,pn).value;return(n=(t=At.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=At.pendingIdChanges)==null?void 0:n.get(this))!=null?r:pe(this,pn).peek();t!==i&&(At.pendingIdChanges||(At.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return Rl(s=At,ho,Bl).call(s)})),At.pendingIdChanges.set(this,t))}register(){var t;return(t=this.manager)==null?void 0:t.registry.register(this)}unregister(){var t;(t=this.manager)==null||t.registry.unregister(this)}destroy(){var t;(t=this.manager)==null||t.registry.unregister(this)}};it=Pn(null);ho=new WeakSet;Bl=function(){const e=yt.pendingIdChanges;yt.pendingIdChanges=null,e&&ue(()=>{for(const[t,n]of e)pe(t,pn).value=n})};po=new WeakMap;pn=new WeakMap;go=new WeakMap;vo=new WeakMap;Y(it,4,"manager",Nl,yt,po);Y(it,4,"data",Fl,yt,go);Y(it,4,"disabled",zl,yt,vo);J(yt,ho);Yt(it,yt);yt.pendingIdChanges=null;var ji=yt,pa=class{constructor(){this.map=En(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;if(r&&r.id===e){const a=this.cleanupFunctions.get(r);a?.(),this.cleanupFunctions.delete(r)}const s=new Map(n);for(const[a,l]of n)if(l===t&&a!==e){s.delete(a);break}s.set(e,t),this.map.value=s;const o=$r(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;const r=this.cleanupFunctions.get(t);r?.(),this.cleanupFunctions.delete(t);const i=new Map(n);i.delete(e),this.map.value=i}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this){const t=this.cleanupFunctions.get(e);t?.(),e.destroy()}this.map.value=new Map}},Vl,Gl,Ul,ql,Hl,Kl,Ss,je,mo,yo,bo,ut=class extends(Ss=ji,Kl=[K],Hl=[K],ql=[K],Ul=[ge],Gl=[ge],Vl=[ge],Ss){constructor(t,n){var r=t,{modifiers:i,type:s,sensors:o,plugins:a,effects:l}=r,u=jl(r,["modifiers","type","sensors","plugins","effects"]);super(co(lo({},u),{effects:()=>{var d;return[...(d=l?.())!=null?d:[],()=>{const{manager:c,plugins:h}=this;if(!(!c||!h))for(const f of h){const{plugin:v}=gr(f);c.registry.plugins.register(v)}}]}}),n),N(je,5,this),J(this,mo,N(je,8,this)),N(je,11,this),J(this,yo,N(je,12,this)),N(je,15,this),J(this,bo,N(je,16,this,this.isDragSource?"dragging":"idle")),N(je,19,this),this.type=s,this.sensors=o,this.modifiers=i,this.alignment=u.alignment,this.plugins=a}pluginConfig(t){if(this.plugins)for(const n of this.plugins){const r=gr(n);if(r.plugin===t)return r.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};je=Pn(Ss);mo=new WeakMap;yo=new WeakMap;bo=new WeakMap;Y(je,4,"type",Kl,ut,mo);Y(je,4,"modifiers",Hl,ut,yo);Y(je,4,"status",ql,ut,bo);Y(je,2,"isDropping",Ul,ut);Y(je,2,"isDragging",Gl,ut);Y(je,2,"isDragSource",Vl,ut);Yt(je,ut);var Yl,Xl,Ql,Zl,Jl,ec,$s,xe,xo,wo,_o,ko,So,ft=class extends($s=ji,ec=[K],Jl=[K],Zl=[K],Ql=[K],Xl=[K],Yl=[ge],$s){constructor(t,n){var r=t,{accept:i,collisionDetector:s,collisionPriority:o,type:a}=r,l=jl(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),N(xe,5,this),J(this,xo,N(xe,8,this)),N(xe,11,this),J(this,wo,N(xe,12,this)),N(xe,15,this),J(this,_o,N(xe,16,this)),N(xe,19,this),J(this,ko,N(xe,20,this)),N(xe,23,this),J(this,So,N(xe,24,this)),N(xe,27,this),this.accept=i,this.collisionDetector=s,this.collisionPriority=o,this.type=a}accepts(t){const{accept:n}=this;return n?typeof n=="function"?n(t):t.type?Array.isArray(n)?n.includes(t.type):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}};xe=Pn($s);xo=new WeakMap;wo=new WeakMap;_o=new WeakMap;ko=new WeakMap;So=new WeakMap;Y(xe,4,"accept",ec,ft,xo);Y(xe,4,"type",Jl,ft,wo);Y(xe,4,"collisionDetector",Zl,ft,_o);Y(xe,4,"collisionPriority",Ql,ft,ko);Y(xe,4,"shape",Xl,ft,So);Y(xe,2,"isDropTarget",Yl,ft);Yt(xe,ft);var Ku=class{constructor(){this.registry=new Map}addEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){const{registry:n}=this,r=n.get(e);if(r)for(const i of r)i(...t)}},Yu=class extends Ku{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function Jr(e,t=!0){let n=!1;return co(lo({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Xu=class extends Tr{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=$r(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||ji.pendingIdChanges)return;const o=Jr({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;H(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},Mn=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(Mn||{}),In=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(In||{}),tc,nc,rc,ic,sc,oc,ac,et,$o;ac=[K],oc=[ge],sc=[ge],ic=[ge],rc=[ge],nc=[ge],tc=[ge];var bt=class{constructor(){N(et,5,this),J(this,$o,N(et,8,this,"idle")),N(et,11,this)}get current(){return this.value}get idle(){return this.value==="idle"}get initializing(){return this.value==="initializing"}get initialized(){const{value:e}=this;return e!=="idle"&&e!=="initialization-pending"}get dragging(){return this.value==="dragging"}get dropped(){return this.value==="dropped"}set(e){this.value=e}};et=Pn(null);$o=new WeakMap;Y(et,4,"value",ac,bt,$o);Y(et,2,"current",oc,bt);Y(et,2,"idle",sc,bt);Y(et,2,"initializing",ic,bt);Y(et,2,"initialized",rc,bt);Y(et,2,"dragging",nc,bt);Y(et,2,"dropped",tc,bt);Yt(et,bt);var Qu=class{constructor(e){this.manager=e}setDragSource(e){const{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e=="string"||typeof e=="number"?e:e.id}setDropTarget(e){return H(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=Jr({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return H(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const r=new AbortController,{event:i,coordinates:s}=e;ue(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=i??null,t.position.reset(s)});const o=Jr({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",o),o.defaultPrevented?(t.reset(),r.abort(),r):(t.status.set("initializing"),t.controller=r,this.manager.renderer.rendering.then(()=>{if(r.signal.aborted)return;const{status:a}=t;a.current==="initializing"&&ue(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:i,operation:t.snapshot(),cancelable:!1})})}),r)})}move(e){return H(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=Jr({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var a,l,u,d,c;if(o.defaultPrevented)return;const h=(c=e.to)!=null?c:{x:r.position.current.x+((l=(a=e.by)==null?void 0:a.x)!=null?l:0),y:r.position.current.y+((d=(u=e.by)==null?void 0:u.y)!=null?d:0)};r.position.current=h})})}stop(e={}){return H(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:i}=r;if(!i||i.signal.aborted)return;let s;const o=()=>{const l={resume:()=>{},abort:()=>{}};return s=new Promise((u,d)=>{l.resume=u,l.abort=d}),l};i.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=H(()=>{var d;return((d=r.source)==null?void 0:d.status)==="dropping"}),u=()=>{r.controller===i&&(r.controller=void 0),r.reset()};if(l){const{source:d}=r,c=tt(()=>{d?.status==="idle"&&(c(),u())})}else this.manager.renderer.rendering.then(u)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),s?s.then(a).catch(()=>r.reset()):a()})}},bn=class extends Me{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Zu=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(const n of e??[])n.controller=this}onEvent(e){var t;if(!this.activated)if((t=this.constraints)!=null&&t.length)for(const n of this.constraints)n.onEvent(e);else this.activate(e)}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},ei,lc=class{constructor(e){this.options=e,J(this,ei)}set controller(e){He(this,ei,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=pe(this,ei))==null||t.activate(e)}};ei=new WeakMap;var ga=class extends Me{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Ju=class{constructor(e){this.draggables=new pa,this.droppables=new pa,this.plugins=new Zi(e),this.sensors=new Zi(e),this.modifiers=new Zi(e)}register(e,t){if(e instanceof ut)return this.draggables.register(e.id,e);if(e instanceof ft)return this.droppables.register(e.id,e);if(e.prototype instanceof ga)return this.modifiers.register(e,t);if(e.prototype instanceof bn)return this.sensors.register(e,t);if(e.prototype instanceof Me)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof ji)return e instanceof ut?this.draggables.unregister(e.id,e):e instanceof ft?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof ga)return this.modifiers.unregister(e);if(e.prototype instanceof bn)return this.sensors.unregister(e);if(e.prototype instanceof Me)return this.plugins.unregister(e);throw new Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},cc,dc,uc,fc,hc,pc,gc,vc,mc,Yn,ti,cn,ce,Eo,Oo,To,Do,Co,Xn;mc=[ge],vc=[K],gc=[K],pc=[K],hc=[K],fc=[K],uc=[ge],dc=[ge],cc=[ge];var ot=class{constructor(e){N(ce,5,this),J(this,Yn),J(this,ti),J(this,cn,new Kt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new bt,J(this,Eo,N(ce,8,this,!1)),N(ce,11,this),J(this,Oo,N(ce,12,this,null)),N(ce,15,this),J(this,To,N(ce,16,this,null)),N(ce,19,this),J(this,Do,N(ce,20,this,null)),N(ce,23,this),J(this,Co,N(ce,24,this,[])),N(ce,27,this),this.position=new Ii({x:0,y:0}),J(this,Xn,{x:0,y:0}),He(this,Yn,e)}get shape(){const{current:e,initial:t,previous:n}=pe(this,cn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?pe(this,cn).current=e:pe(this,cn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=pe(this,Yn).registry.draggables.get(t);return n&&He(this,ti,n),(e=n??pe(this,ti))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=pe(this,Yn).registry.droppables.get(t))!=null?e:null}get transform(){const{x:e,y:t}=this.position.delta;let n={x:e,y:t};for(const r of this.modifiers)n=r.apply(co(lo({},this.snapshot()),{transform:n}));return He(this,Xn,n),n}snapshot(){return H(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:pe(this,Xn),shape:this.shape?Qi(this.shape):null,position:Qi(this.position),status:Qi(this.status),canceled:this.canceled}))}reset(){ue(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,pe(this,cn).reset(),this.position.reset({x:0,y:0}),He(this,Xn,{x:0,y:0}),this.modifiers=[]})}};ce=Pn(null);Yn=new WeakMap;ti=new WeakMap;cn=new WeakMap;Eo=new WeakMap;Oo=new WeakMap;To=new WeakMap;Do=new WeakMap;Co=new WeakMap;Xn=new WeakMap;Y(ce,2,"shape",mc,ot);Y(ce,4,"canceled",vc,ot,Eo);Y(ce,4,"activatorEvent",gc,ot,Oo);Y(ce,4,"sourceIdentifier",pc,ot,To);Y(ce,4,"targetIdentifier",hc,ot,Do);Y(ce,4,"modifiers",fc,ot,Co);Y(ce,2,"source",uc,ot);Y(ce,2,"target",dc,ot);Y(ce,2,"transform",cc,ot);Yt(ce,ot);var ef={get rendering(){return Promise.resolve()}};function st(e,t){return typeof e=="function"?e(t):e??t}var tf=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(h=>h.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},i=st(r.plugins,[]),s=st(r.sensors,[]),o=st(r.modifiers,[]),a=(n=r.renderer)!=null?n:ef,l=new Yu(this),u=new Ju(this);this.registry=u,this.monitor=l,this.renderer=a,this.actions=new Qu(this),this.dragOperation=new ot(this),this.collisionObserver=new Hu(this),this.plugins=[Xu,...i],this.modifiers=o,this.sensors=s;const{destroy:d}=this,c=$r(()=>{var h,f,v;const p=H(()=>this.dragOperation.modifiers),w=this.modifiers;for(const x of p)w.includes(x)||x.destroy();this.dragOperation.modifiers=(v=(f=(h=this.dragOperation.source)==null?void 0:h.modifiers)==null?void 0:f.map(x=>{const{plugin:m,options:g}=gr(x);return new m(this,g)}))!=null?v:w});this.destroy=()=>{c(),d()}}get plugins(){return this.registry.plugins.values}set plugins(t){this.registry.plugins.values=t}get modifiers(){return this.registry.modifiers.values}set modifiers(t){this.registry.modifiers.values=t}get sensors(){return this.registry.sensors.values}set sensors(t){this.registry.sensors.values=t}},yc=e=>{throw TypeError(e)},Po=(e,t,n)=>t.has(e)||yc("Cannot "+n),F=(e,t,n)=>(Po(e,t,"read from private field"),t.get(e)),Ne=(e,t,n)=>t.has(e)?yc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qe=(e,t,n,r)=>(Po(e,t,"write to private field"),t.set(e,n),n),bc=(e,t,n)=>(Po(e,t,"access private method"),n);function Ai(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function xc(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,a=(Ai(s)?s.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],i])}return r}function Ri(e){const{width:t,height:n,top:r,left:i,bottom:s,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:i,bottom:s,right:o}}function Mo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Dr(e){return"nodeType"in e}function Ke(e){var t,n,r;return e?Mo(e)?e:Dr(e)?"defaultView"in e?(t=e.defaultView)!=null?t:window:(r=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?r:window:window:window}function Io(e){const{Document:t}=Ke(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Tt(e){return!e||Mo(e)?!1:e instanceof Ke(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function wc(e){return e instanceof Ke(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function jn(e){return e?Mo(e)?e.document:Dr(e)?Io(e)?e:Tt(e)||wc(e)?e.ownerDocument:document:document:document}function nf(e){var t,n,r,i;const{documentElement:s}=jn(e),o=Ke(e).visualViewport,a=(t=o?.width)!=null?t:s.clientWidth,l=(n=o?.height)!=null?n:s.clientHeight,u=(r=o?.offsetTop)!=null?r:0,d=(i=o?.offsetLeft)!=null?i:0;return{top:u,left:d,right:d+a,bottom:u+l,width:a,height:l}}function rf(e,t){if(sf(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function sf(e){return e.tagName==="DETAILS"}function mr(e,t=e.getBoundingClientRect(),n=0){var r,i,s,o,a;let l=t;const{ownerDocument:u}=e,d=(r=u.defaultView)!=null?r:window;let c=e.parentElement;for(;c&&c!==u.documentElement;){if(!rf(c)){const g=c.getBoundingClientRect(),b=n*(g.bottom-g.top),_=n*(g.right-g.left),$=n*(g.bottom-g.top),O=n*(g.right-g.left);l={top:Math.max(l.top,g.top-b),right:Math.min(l.right,g.right+_),bottom:Math.min(l.bottom,g.bottom+$),left:Math.max(l.left,g.left-O),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}c=c.parentElement}const h=d.visualViewport,f=(i=h?.offsetTop)!=null?i:0,v=(s=h?.offsetLeft)!=null?s:0,p=(o=h?.width)!=null?o:d.innerWidth,w=(a=h?.height)!=null?a:d.innerHeight,x=n*w,m=n*p;return l={top:Math.max(l.top,f-x),right:Math.min(l.right,v+p+m),bottom:Math.min(l.bottom,f+w+x),left:Math.max(l.left,v-m),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top,l.width<0&&(l.width=0),l.height<0&&(l.height=0),l}function xn(e){return{x:e.clientX,y:e.clientY}}var _c=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Es(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const i=r.contentDocument;i&&!t.has(i)&&n.push(...Es(i,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const i=r.parent;i&&i.document&&i.document!==e&&n.push(...Es(i.document,t))}}catch{}return n}function jo(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function kc(){var e,t;const n=jo()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Ao(e){return!e||!Dr(e)?!1:e instanceof Ke(e).ShadowRoot}function pi(e){if(e&&Dr(e)){let t=e.getRootNode();if(Ao(t))return t;if(t instanceof Document)return t}return jn(e)}function Ro(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function of(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((s,o)=>{const a=r[o];if(va(s)&&va(a)&&(s.type!=="file"&&(s.value=a.value),s.type==="radio"&&s.name&&(s.name=`Cloned__${s.name}`)),ma(s)&&ma(a)&&a.width>0&&a.height>0){const l=s.getContext("2d");l?.drawImage(a,0,0)}}),n}function va(e){return"value"in e}function ma(e){return e.tagName==="CANVAS"}function Sc(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(af(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return Sc(i,{x:t-s,y:n-o})}}return r}function af(e){return e?.tagName==="IFRAME"}var Os=new WeakMap;function lf(e){return e.closest(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react/jsx-runtime"),_=require("react"),sf=require("react-dom"),L=require("../DashboardTile-sg8LjUk8.cjs.js"),S=require("@mui/material"),ye=require("../text-entry-BJwltZiy.cjs.js"),Ye=require("../ServerProvider-HRqT3w1C.cjs.js"),of=require("@malloydata/malloy-tag"),af=require("@tanstack/react-query");var lf=Symbol.for("preact-signals");function si(){if(Pt>1)Pt--;else{var e,t=!1;for((function(){var s=Ns;for(Ns=void 0;s!==void 0;){var i=s.S;if(i.v===s.v)for(var o=i.t;o!==void 0;o=o.x)o.i===s.i&&(o.i=i.i);s=s.o}})();Cr!==void 0;){var n=Cr;for(Cr=void 0,Ls++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Zl(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(Ls=0,Pt--,t)throw e}}function De(e){if(Pt>0)return e();qi=++cf,Pt++;try{return e()}finally{si()}}var Er,$e=void 0;function he(e){var t=$e,n=Er;$e=void 0,Er=void 0;try{return e()}finally{$e=t,Er=n}}var Cr=void 0,Pt=0,Ls=0,cf=0,qi=0,Ns=void 0,Fs=0;function Xl(e){if($e!==void 0){var t=e.n;if(t===void 0||t.t!==$e)return t={i:0,S:e,p:$e.s,n:void 0,t:$e,e:void 0,x:void 0,r:t},$e.s!==void 0&&($e.s.n=t),$e.s=t,e.n=t,32&$e.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=$e.s,t.n=void 0,$e.s.n=t,$e.s=t),t}}function tt(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}tt.prototype.brand=lf;tt.prototype.h=function(){return!0};tt.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:he(function(){var r;(r=t.W)==null||r.call(t)}))};tt.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&he(function(){var s;(s=t.Z)==null||s.call(t)}))}};tt.prototype.subscribe=function(e){var t=this;return pt(function(){var n=t.value;he(function(){return e(n)})},{name:"sub"})};tt.prototype.valueOf=function(){return this.value};tt.prototype.toString=function(){return this.value+""};tt.prototype.toJSON=function(){return this.value};tt.prototype.peek=function(){var e=this;return he(function(){return e.value})};Object.defineProperty(tt.prototype,"value",{get:function(){var e=Xl(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ls>100)throw new Error("Cycle detected");(function(n){Pt!==0&&Ls===0&&n.l!==qi&&(n.l=qi,Ns={S:n,v:n.v,i:n.i,o:Ns})})(this),this.v=e,this.i++,Fs++,Pt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{si()}}}});function Kn(e,t){return new tt(e,t)}function Zl(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Ql(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Jl(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function bn(e,t){tt.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Fs-1,this.f=4}bn.prototype=new tt;bn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Fs))return!0;if(this.g=Fs,this.f|=1,this.i>0&&!Zl(this))return this.f&=-2,!0;var e=$e;try{Ql(this),$e=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return $e=e,Jl(this),this.f&=-2,!0};bn.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}tt.prototype.S.call(this,e)};bn.prototype.U=function(e){if(this.t!==void 0&&(tt.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};bn.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(bn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Xl(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Na(e,t){return new bn(e,t)}function ec(e){var t=e.m;if(e.m=void 0,typeof t=="function"){Pt++;var n=$e;$e=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Ao(e),r}finally{$e=n,si()}}}function Ao(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,ec(e)}function df(e){if($e!==this)throw new Error("Out-of-order effect");Jl(this),$e=e,this.f&=-2,8&this.f&&Ao(this),si()}function Hn(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Er&&Er.push(this)}Hn.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};Hn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ec(this),Ql(this),Pt++;var e=$e;return $e=this,df.bind(this,e)};Hn.prototype.N=function(){2&this.f||(this.f|=2,this.u=Cr,Cr=this)};Hn.prototype.d=function(){this.f|=8,1&this.f||Ao(this)};Hn.prototype.dispose=function(){this.d()};function pt(e,t){var n=new Hn(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var uf=Object.create,jo=Object.defineProperty,ff=Object.defineProperties,hf=Object.getOwnPropertyDescriptor,pf=Object.getOwnPropertyDescriptors,Fa=Object.getOwnPropertySymbols,gf=Object.prototype.hasOwnProperty,mf=Object.prototype.propertyIsEnumerable,vf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Yn=e=>{throw TypeError(e)},Gi=(e,t,n)=>t in e?jo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bf=(e,t)=>{for(var n in t||(t={}))gf.call(t,n)&&Gi(e,n,t[n]);if(Fa)for(var n of Fa(t))mf.call(t,n)&&Gi(e,n,t[n]);return e},yf=(e,t)=>ff(e,pf(t)),za=(e,t)=>jo(e,"name",{value:t,configurable:!0}),xf=e=>{var t;return[,,,uf((t=void 0)!=null?t:null)]},tc=["class","method","getter","setter","accessor","field","value","get","set"],fr=e=>e!==void 0&&typeof e!="function"?Yn("Function expected"):e,wf=(e,t,n,r,s)=>({kind:tc[e],name:t,metadata:r,addInitializer:i=>n._?Yn("Already initialized"):s.push(fr(i||null))}),nc=(e,t)=>Gi(t,vf("metadata"),e[3]),rn=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},Xn=(e,t,n,r,s,i)=>{var o,a,l,u,c,d=t&7,f=!!(t&8),p=!!(t&16),m=d>3?e.length+1:d?f?1:2:0,g=tc[d+5],x=d>3&&(e[m-1]=[]),k=e[m]||(e[m]=[]),b=d&&(!p&&!f&&(s=s.prototype),d<5&&(d>3||!p)&&hf(d<4?s:{get[n](){return ct(this,i)},set[n](y){return qt(this,i,y)}},n));d?p&&d<4&&za(i,(d>2?"set ":d>1?"get ":"")+n):za(s,n);for(var h=r.length-1;h>=0;h--)u=wf(d,n,l={},e[3],k),d&&(u.static=f,u.private=p,c=u.access={has:p?y=>kf(s,y):y=>n in y},d^3&&(c.get=p?y=>(d^1?ct:_f)(y,s,d^4?i:b.get):y=>y[n]),d>2&&(c.set=p?(y,w)=>qt(y,s,w,d^4?i:b.set):(y,w)=>y[n]=w)),a=(0,r[h])(d?d<4?p?i:b[g]:d>4?void 0:{get:b.get,set:b.set}:s,u),l._=1,d^4||a===void 0?fr(a)&&(d>4?x.unshift(a):d?p?i=a:b[g]=a:s=a):typeof a!="object"||a===null?Yn("Object expected"):(fr(o=a.get)&&(b.get=o),fr(o=a.set)&&(b.set=o),fr(o=a.init)&&x.unshift(o));return d||nc(e,s),b&&jo(s,n,b),p?d^4?i:b:s},Po=(e,t,n)=>t.has(e)||Yn("Cannot "+n),kf=(e,t)=>Object(t)!==t?Yn('Cannot use the "in" operator on this value'):e.has(t),ct=(e,t,n)=>(Po(e,t,"read from private field"),n?n.call(e):t.get(e)),hr=(e,t,n)=>t.has(e)?Yn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qt=(e,t,n,r)=>(Po(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),_f=(e,t,n)=>(Po(e,t,"access private method"),n);function Ui(e,t){if(t){let n;return Na(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return Na(e)}function vt(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((r,s)=>!vt(r,t[s]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(i=>!vt(e[i],t[i]))}return!1}function pe({get:e},t){return{init(n){return Kn(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Pe(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Ui(e.bind(this)),n.set(this,r)),r.value}}function bi(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),s=Object.getOwnPropertyDescriptor(r,n.name);s&&Object.defineProperty(r,n.name,yf(bf({},s),{enumerable:e}))})}}function Yr(...e){const t=e.map(n=>pt(n));return()=>t.forEach(n=>n())}var rc,sc,ic,oc,ac,lc,Qe,Mo,yi,Vi,Ki,Xe,Ro,xi,cc,Hi,Lo,wi,Yi,Xi;lc=[pe],ac=[pe],oc=[pe],ic=[bi()],sc=[bi()],rc=[bi()];var yn=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,rn(Qe,5,this),hr(this,Xe),hr(this,Mo,rn(Qe,8,this)),rn(Qe,11,this),hr(this,Ro,rn(Qe,12,this)),rn(Qe,15,this),hr(this,Lo,rn(Qe,16,this)),rn(Qe,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return ct(this,Xe,Yi)}get initial(){return ct(this,Xe,Vi)}get previous(){return ct(this,Xe,cc)}set current(e){const t=he(()=>ct(this,Xe,Yi));e&&t&&this.equals(t,e)||De(()=>{ct(this,Xe,Vi)||qt(this,Xe,e,Ki),qt(this,Xe,t,Hi),qt(this,Xe,e,Xi)})}reset(e=this.defaultValue){De(()=>{qt(this,Xe,void 0,Hi),qt(this,Xe,e,Ki),qt(this,Xe,e,Xi)})}};Qe=xf();Mo=new WeakMap;Xe=new WeakSet;Ro=new WeakMap;Lo=new WeakMap;yi=Xn(Qe,20,"#initial",lc,Xe,Mo),Vi=yi.get,Ki=yi.set;xi=Xn(Qe,20,"#previous",ac,Xe,Ro),cc=xi.get,Hi=xi.set;wi=Xn(Qe,20,"#current",oc,Xe,Lo),Yi=wi.get,Xi=wi.set;Xn(Qe,2,"current",ic,yn);Xn(Qe,2,"initial",sc,yn);Xn(Qe,2,"previous",rc,yn);nc(Qe,yn);function ki(e){return he(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var sn,Sf=class{constructor(){hr(this,sn,new WeakMap)}get(e,t){var n;return e?(n=ct(this,sn).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return ct(this,sn).has(e)||ct(this,sn).set(e,new Map),(r=ct(this,sn).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=ct(this,sn).get(e))==null?void 0:t.clear():void 0}};sn=new WeakMap;var $f=Object.create,dc=Object.defineProperty,Tf=Object.getOwnPropertyDescriptor,Wa=Object.getOwnPropertySymbols,Of=Object.prototype.hasOwnProperty,Ef=Object.prototype.propertyIsEnumerable,uc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ii=e=>{throw TypeError(e)},Ba=Math.pow,Zi=(e,t,n)=>t in e?dc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Cf=(e,t)=>{for(var n in t||(t={}))Of.call(t,n)&&Zi(e,n,t[n]);if(Wa)for(var n of Wa(t))Ef.call(t,n)&&Zi(e,n,t[n]);return e},If=e=>{var t;return[,,,$f((t=e?.[uc("metadata")])!=null?t:null)]},fc=["class","method","getter","setter","accessor","field","value","get","set"],hc=e=>e!==void 0&&typeof e!="function"?ii("Function expected"):e,Df=(e,t,n,r,s)=>({kind:fc[e],name:t,metadata:r,addInitializer:i=>n._?ii("Already initialized"):s.push(hc(i||null))}),Af=(e,t)=>Zi(t,uc("metadata"),e[3]),jf=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)i[s].call(n);return r},pc=(e,t,n,r,s,i)=>{for(var o,a,l,u,c=t&7,d=!1,f=!1,p=2,m=fc[c+5],g=e[p]||(e[p]=[]),x=(s=s.prototype,Tf(s,n)),k=r.length-1;k>=0;k--)l=Df(c,n,a={},e[3],g),l.static=d,l.private=f,u=l.access={has:b=>n in b},u.get=b=>b[n],o=(0,r[k])(x[m],l),a._=1,hc(o)&&(x[m]=o);return x&&dc(s,n,x),s},gc=(e,t,n)=>t.has(e)||ii("Cannot "+n),Pf=(e,t,n)=>(gc(e,t,"read from private field"),t.get(e)),Mf=(e,t,n)=>t.has(e)?ii("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Rf=(e,t,n,r)=>(gc(e,t,"write to private field"),t.set(e,n),n),dt=class Qi{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Qi(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Qi(t,n)}},St=class on{constructor(t,n,r,s){this.left=t,this.top=n,this.width=r,this.height=s,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:s,width:i,height:o,scale:a}=this,l=new on(s+t,r+n,i,o);return l.scale=Cf({},a),l}get boundingRectangle(){const{width:t,height:n,left:r,top:s,right:i,bottom:o}=this;return{width:t,height:n,left:r,top:s,right:i,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:s}=this;return new dt((t+r)/2,(n+s)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof on))return!1;const{left:n,top:r,width:s,height:i}=this;return n===t.left&&r===t.top&&s===t.width&&i===t.height}containsPoint(t){const{top:n,left:r,bottom:s,right:i}=this;return n<=t.y&&t.y<=s&&r<=t.x&&t.x<=i}intersectionArea(t){return t instanceof on?Lf(this,t):0}intersectionRatio(t){const{area:n}=this,r=this.intersectionArea(t);return r/(t.area+n-r)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}get aspectRatio(){const{width:t,height:n}=this;return t/n}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:s}){return new on(n,t,r,s)}static delta(t,n,r={x:"center",y:"center"}){const s=(i,o)=>{const a=r[o],l=o==="x"?i.left:i.top,u=o==="x"?i.width:i.height;return a=="start"?l:a=="end"?l+u:l+u/2};return dt.delta({x:s(t,"x"),y:s(t,"y")},{x:s(n,"x"),y:s(n,"y")})}static intersectionRatio(t,n){return on.from(t).intersectionRatio(on.from(n))}};function Lf(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),o=s-r,a=i-n;return r<s&&n<i?o*a:0}var mc,vc,Ji,ks,Xr,oi=class extends(Ji=yn,vc=[Pe],mc=[Pe],Ji){constructor(t){const n=dt.from(t);super(n,(r,s)=>dt.equals(r,s)),jf(Xr,5,this),Mf(this,ks,0),this.velocity={x:0,y:0}}get delta(){return dt.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=dt.from(t),s={x:r.x-n.x,y:r.y-n.y},i=Date.now(),o=i-Pf(this,ks),a=l=>Math.round(l/o*100);De(()=>{Rf(this,ks,i),this.velocity={x:a(s.x),y:a(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(dt.from(t)),this.velocity={x:0,y:0}}};Xr=If(Ji);ks=new WeakMap;pc(Xr,2,"delta",vc,oi);pc(Xr,2,"direction",mc,oi);Af(Xr,oi);function eo({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(Ba(r,2)+Ba(s,2))>n:"x"in n&&"y"in n?r>n.x&&s>n.y:"x"in n?r>n.x:"y"in n?s>n.y:!1}var bc=(e=>(e.Horizontal="x",e.Vertical="y",e))(bc||{}),yc=Object.values(bc),Nf=Object.create,No=Object.defineProperty,Ff=Object.defineProperties,zf=Object.getOwnPropertyDescriptor,Wf=Object.getOwnPropertyDescriptors,zs=Object.getOwnPropertySymbols,xc=Object.prototype.hasOwnProperty,wc=Object.prototype.propertyIsEnumerable,kc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Zn=e=>{throw TypeError(e)},to=(e,t,n)=>t in e?No(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fo=(e,t)=>{for(var n in t||(t={}))xc.call(t,n)&&to(e,n,t[n]);if(zs)for(var n of zs(t))wc.call(t,n)&&to(e,n,t[n]);return e},zo=(e,t)=>Ff(e,Wf(t)),qa=(e,t)=>No(e,"name",{value:t,configurable:!0}),_c=(e,t)=>{var n={};for(var r in e)xc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&zs)for(var r of zs(e))t.indexOf(r)<0&&wc.call(e,r)&&(n[r]=e[r]);return n},Qn=e=>{var t;return[,,,Nf((t=e?.[kc("metadata")])!=null?t:null)]},Sc=["class","method","getter","setter","accessor","field","value","get","set"],pr=e=>e!==void 0&&typeof e!="function"?Zn("Function expected"):e,Bf=(e,t,n,r,s)=>({kind:Sc[e],name:t,metadata:r,addInitializer:i=>n._?Zn("Already initialized"):s.push(pr(i||null))}),xn=(e,t)=>to(t,kc("metadata"),e[3]),ae=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},ge=(e,t,n,r,s,i)=>{var o,a,l,u,c,d=t&7,f=!!(t&8),p=!!(t&16),m=d>3?e.length+1:d?f?1:2:0,g=Sc[d+5],x=d>3&&(e[m-1]=[]),k=e[m]||(e[m]=[]),b=d&&(!p&&!f&&(s=s.prototype),d<5&&(d>3||!p)&&zf(d<4?s:{get[n](){return je(this,i)},set[n](y){return it(this,i,y)}},n));d?p&&d<4&&qa(i,(d>2?"set ":d>1?"get ":"")+n):qa(s,n);for(var h=r.length-1;h>=0;h--)u=Bf(d,n,l={},e[3],k),d&&(u.static=f,u.private=p,c=u.access={has:p?y=>qf(s,y):y=>n in y},d^3&&(c.get=p?y=>(d^1?je:$c)(y,s,d^4?i:b.get):y=>y[n]),d>2&&(c.set=p?(y,w)=>it(y,s,w,d^4?i:b.set):(y,w)=>y[n]=w)),a=(0,r[h])(d?d<4?p?i:b[g]:d>4?void 0:{get:b.get,set:b.set}:s,u),l._=1,d^4||a===void 0?pr(a)&&(d>4?x.unshift(a):d?p?i=a:b[g]=a:s=a):typeof a!="object"||a===null?Zn("Object expected"):(pr(o=a.get)&&(b.get=o),pr(o=a.set)&&(b.set=o),pr(o=a.init)&&x.unshift(o));return d||xn(e,s),b&&No(s,n,b),p?d^4?i:b:s},Wo=(e,t,n)=>t.has(e)||Zn("Cannot "+n),qf=(e,t)=>Object(t)!==t?Zn('Cannot use the "in" operator on this value'):e.has(t),je=(e,t,n)=>(Wo(e,t,"read from private field"),n?n.call(e):t.get(e)),be=(e,t,n)=>t.has(e)?Zn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),it=(e,t,n,r)=>(Wo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),$c=(e,t,n)=>(Wo(e,t,"access private method"),n);function Tc(e,t){return{plugin:e,options:t}}function Zr(e){return t=>Tc(e,t)}function Mr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Oc,Rr,Bo,_s;Oc=[pe];var Ze=class{constructor(e,t){this.manager=e,this.options=t,be(this,Bo,ae(Rr,8,this,!1)),ae(Rr,11,this),be(this,_s,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return he(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=pt(e.bind(this));return je(this,_s).add(t),t}destroy(){je(this,_s).forEach(e=>e())}static configure(e){return Tc(this,e)}};Rr=Qn(null);Bo=new WeakMap;_s=new WeakMap;ge(Rr,4,"disabled",Oc,Ze,Bo);xn(Rr,Ze);var Qr=class extends Ze{},Ss,_i=class{constructor(e){this.manager=e,this.instances=new Map,be(this,Ss,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(Mr).reduce((r,s)=>{const i=r.find(({plugin:o})=>o===s.plugin);return i?(i.options=s.options,r):[...r,s]},[]),n=t.map(({plugin:r})=>r);for(const r of je(this,Ss))if(!n.includes(r)){if(r.prototype instanceof Qr)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);it(this,Ss,n)}get(e){return this.instances.get(e)}register(e,t){const n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;const r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){const t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(const e of this.instances.values())e.destroy();this.instances.clear()}};Ss=new WeakMap;function Gf(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var ls=[],En,Cn,Uf=class extends Ze{constructor(e){super(e),be(this,En),be(this,Cn),this.computeCollisions=this.computeCollisions.bind(this),it(this,Cn,Kn(ls)),this.destroy=Yr(()=>{const t=this.computeCollisions(),n=he(()=>this.manager.dragOperation.position.current);if(t!==ls){const r=je(this,En);if(it(this,En,n),r&&n.x==r.x&&n.y==r.y)return}else it(this,En,void 0);je(this,Cn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){he(()=>{e?je(this,Cn).value=this.computeCollisions():it(this,En,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:i,status:o}=r;if(!o.initialized||!i)return ls;const a=[],l=[];for(const u of e??n.droppables){if(u.disabled||s&&!u.accepts(s))continue;const c=t??u.collisionDetector;if(!c)continue;l.push(u),u.shape;const d=he(()=>c({droppable:u,dragOperation:r}));d&&(u.collisionPriority!=null&&(d.priority=u.collisionPriority),a.push(d))}return l.length===0?ls:(a.sort(Gf),a)}get collisions(){return je(this,Cn).value}};En=new WeakMap;Cn=new WeakMap;var Ec,Cc,Ic,qo,Dc,bt,Go,Mn,Uo,Vo;Ic=[pe],Cc=[pe],Ec=[pe];var Rt=class an{constructor(t,n){be(this,Go,ae(bt,8,this)),ae(bt,11,this),be(this,Mn),be(this,Uo,ae(bt,12,this)),ae(bt,15,this),be(this,Vo,ae(bt,16,this)),ae(bt,19,this);const{effects:r,id:s,data:i={},disabled:o=!1,register:a=!0}=t;let l=s;it(this,Mn,Kn(s)),this.manager=n,this.data=i,this.disabled=o,this.effects=()=>{var u;return[()=>{const{id:c,manager:d}=this;if(c!==l)return l=c,d?.registry.register(this),()=>d?.registry.unregister(this)},...(u=r?.())!=null?u:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),n&&a&&queueMicrotask(this.register)}get id(){var t,n;const r=je(this,Mn).value;return(n=(t=an.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const s=(r=(n=an.pendingIdChanges)==null?void 0:n.get(this))!=null?r:je(this,Mn).peek();t!==s&&(an.pendingIdChanges||(an.pendingIdChanges=new Map,queueMicrotask(()=>{var i;return $c(i=an,qo,Dc).call(i)})),an.pendingIdChanges.set(this,t))}register(){var t;return(t=this.manager)==null?void 0:t.registry.register(this)}unregister(){var t;(t=this.manager)==null||t.registry.unregister(this)}destroy(){var t;(t=this.manager)==null||t.registry.unregister(this)}};bt=Qn(null);qo=new WeakSet;Dc=function(){const e=Rt.pendingIdChanges;Rt.pendingIdChanges=null,e&&De(()=>{for(const[t,n]of e)je(t,Mn).value=n})};Go=new WeakMap;Mn=new WeakMap;Uo=new WeakMap;Vo=new WeakMap;ge(bt,4,"manager",Ic,Rt,Go);ge(bt,4,"data",Cc,Rt,Uo);ge(bt,4,"disabled",Ec,Rt,Vo);be(Rt,qo);xn(bt,Rt);Rt.pendingIdChanges=null;var ai=Rt,Ga=class{constructor(){this.map=Kn(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),s=()=>this.unregister(e,t);if(r===t)return s;if(r&&r.id===e){const a=this.cleanupFunctions.get(r);a?.(),this.cleanupFunctions.delete(r)}const i=new Map(n);for(const[a,l]of n)if(l===t&&a!==e){i.delete(a);break}i.set(e,t),this.map.value=i;const o=Yr(...t.effects());return this.cleanupFunctions.set(t,o),s},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;const r=this.cleanupFunctions.get(t);r?.(),this.cleanupFunctions.delete(t);const s=new Map(n);s.delete(e),this.map.value=s}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this){const t=this.cleanupFunctions.get(e);t?.(),e.destroy()}this.map.value=new Map}},Ac,jc,Pc,Mc,Rc,Lc,no,Je,Ko,Ho,Yo,$t=class extends(no=ai,Lc=[pe],Rc=[pe],Mc=[pe],Pc=[Pe],jc=[Pe],Ac=[Pe],no){constructor(t,n){var r=t,{modifiers:s,type:i,sensors:o,plugins:a,effects:l}=r,u=_c(r,["modifiers","type","sensors","plugins","effects"]);super(zo(Fo({},u),{effects:()=>{var c;return[...(c=l?.())!=null?c:[],()=>{const{manager:d,plugins:f}=this;if(!(!d||!f))for(const p of f){const{plugin:m}=Mr(p);d.registry.plugins.register(m)}}]}}),n),ae(Je,5,this),be(this,Ko,ae(Je,8,this)),ae(Je,11,this),be(this,Ho,ae(Je,12,this)),ae(Je,15,this),be(this,Yo,ae(Je,16,this,this.isDragSource?"dragging":"idle")),ae(Je,19,this),this.type=i,this.sensors=o,this.modifiers=s,this.alignment=u.alignment,this.plugins=a}pluginConfig(t){if(this.plugins)for(const n of this.plugins){const r=Mr(n);if(r.plugin===t)return r.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};Je=Qn(no);Ko=new WeakMap;Ho=new WeakMap;Yo=new WeakMap;ge(Je,4,"type",Lc,$t,Ko);ge(Je,4,"modifiers",Rc,$t,Ho);ge(Je,4,"status",Mc,$t,Yo);ge(Je,2,"isDropping",Pc,$t);ge(Je,2,"isDragging",jc,$t);ge(Je,2,"isDragSource",Ac,$t);xn(Je,$t);var Nc,Fc,zc,Wc,Bc,qc,ro,Fe,Xo,Zo,Qo,Jo,ea,Tt=class extends(ro=ai,qc=[pe],Bc=[pe],Wc=[pe],zc=[pe],Fc=[pe],Nc=[Pe],ro){constructor(t,n){var r=t,{accept:s,collisionDetector:i,collisionPriority:o,type:a}=r,l=_c(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),ae(Fe,5,this),be(this,Xo,ae(Fe,8,this)),ae(Fe,11,this),be(this,Zo,ae(Fe,12,this)),ae(Fe,15,this),be(this,Qo,ae(Fe,16,this)),ae(Fe,19,this),be(this,Jo,ae(Fe,20,this)),ae(Fe,23,this),be(this,ea,ae(Fe,24,this)),ae(Fe,27,this),this.accept=s,this.collisionDetector=i,this.collisionPriority=o,this.type=a}accepts(t){const{accept:n}=this;return n?typeof n=="function"?n(t):t.type?Array.isArray(n)?n.includes(t.type):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}};Fe=Qn(ro);Xo=new WeakMap;Zo=new WeakMap;Qo=new WeakMap;Jo=new WeakMap;ea=new WeakMap;ge(Fe,4,"accept",qc,Tt,Xo);ge(Fe,4,"type",Bc,Tt,Zo);ge(Fe,4,"collisionDetector",Wc,Tt,Qo);ge(Fe,4,"collisionPriority",zc,Tt,Jo);ge(Fe,4,"shape",Fc,Tt,ea);ge(Fe,2,"isDropTarget",Nc,Tt);xn(Fe,Tt);var Vf=class{constructor(){this.registry=new Map}addEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){const{registry:n}=this,r=n.get(e);if(r)for(const s of r)s(...t)}},Kf=class extends Vf{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function $s(e,t=!0){let n=!1;return zo(Fo({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Hf=class extends Qr{constructor(e){super(e);const t=(r,s)=>r.map(({id:i})=>i).join("")===s.map(({id:i})=>i).join("");let n=[];this.destroy=Yr(()=>{const{dragOperation:r,collisionObserver:s}=e;r.status.initializing&&(n=[],s.enable())},()=>{const{collisionObserver:r,monitor:s}=e,{collisions:i}=r;if(r.isDisabled()||ai.pendingIdChanges)return;const o=$s({collisions:i});if(s.dispatch("collision",o),o.defaultPrevented||t(i,n))return;n=i;const[a]=i;he(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},Jn=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(Jn||{}),er=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(er||{}),Gc,Uc,Vc,Kc,Hc,Yc,Xc,ht,ta;Xc=[pe],Yc=[Pe],Hc=[Pe],Kc=[Pe],Vc=[Pe],Uc=[Pe],Gc=[Pe];var Nt=class{constructor(){ae(ht,5,this),be(this,ta,ae(ht,8,this,"idle")),ae(ht,11,this)}get current(){return this.value}get idle(){return this.value==="idle"}get initializing(){return this.value==="initializing"}get initialized(){const{value:e}=this;return e!=="idle"&&e!=="initialization-pending"}get dragging(){return this.value==="dragging"}get dropped(){return this.value==="dropped"}set(e){this.value=e}};ht=Qn(null);ta=new WeakMap;ge(ht,4,"value",Xc,Nt,ta);ge(ht,2,"current",Yc,Nt);ge(ht,2,"idle",Hc,Nt);ge(ht,2,"initializing",Kc,Nt);ge(ht,2,"initialized",Vc,Nt);ge(ht,2,"dragging",Uc,Nt);ge(ht,2,"dropped",Gc,Nt);xn(ht,Nt);var Yf=class{constructor(e){this.manager=e}setDragSource(e){const{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e=="string"||typeof e=="number"?e:e.id}setDropTarget(e){return he(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=$s({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return he(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const r=new AbortController,{event:s,coordinates:i}=e;De(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(i)});const o=$s({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",o),o.defaultPrevented?(t.reset(),r.abort(),r):(t.status.set("initializing"),t.controller=r,this.manager.renderer.rendering.then(()=>{if(r.signal.aborted)return;const{status:a}=t;a.current==="initializing"&&De(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:s,operation:t.snapshot(),cancelable:!1})})}),r)})}move(e){return he(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:i}=r;if(!s.dragging||!i||i.signal.aborted)return;const o=$s({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var a,l,u,c,d;if(o.defaultPrevented)return;const f=(d=e.to)!=null?d:{x:r.position.current.x+((l=(a=e.by)==null?void 0:a.x)!=null?l:0),y:r.position.current.y+((c=(u=e.by)==null?void 0:u.y)!=null?c:0)};r.position.current=f})})}stop(e={}){return he(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:s}=r;if(!s||s.signal.aborted)return;let i;const o=()=>{const l={resume:()=>{},abort:()=>{}};return i=new Promise((u,c)=>{l.resume=u,l.abort=c}),l};s.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=he(()=>{var c;return((c=r.source)==null?void 0:c.status)==="dropping"}),u=()=>{r.controller===s&&(r.controller=void 0),r.reset()};if(l){const{source:c}=r,d=pt(()=>{c?.status==="idle"&&(d(),u())})}else this.manager.renderer.rendering.then(u)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),i?i.then(a).catch(()=>r.reset()):a()})}},Wn=class extends Ze{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Xf=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(const n of e??[])n.controller=this}onEvent(e){var t;if(!this.activated)if((t=this.constraints)!=null&&t.length)for(const n of this.constraints)n.onEvent(e);else this.activate(e)}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},Ts,Zc=class{constructor(e){this.options=e,be(this,Ts)}set controller(e){it(this,Ts,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=je(this,Ts))==null||t.activate(e)}};Ts=new WeakMap;var Ua=class extends Ze{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Zf=class{constructor(e){this.draggables=new Ga,this.droppables=new Ga,this.plugins=new _i(e),this.sensors=new _i(e),this.modifiers=new _i(e)}register(e,t){if(e instanceof $t)return this.draggables.register(e.id,e);if(e instanceof Tt)return this.droppables.register(e.id,e);if(e.prototype instanceof Ua)return this.modifiers.register(e,t);if(e.prototype instanceof Wn)return this.sensors.register(e,t);if(e.prototype instanceof Ze)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof ai)return e instanceof $t?this.draggables.unregister(e.id,e):e instanceof Tt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Ua)return this.modifiers.unregister(e);if(e.prototype instanceof Wn)return this.sensors.unregister(e);if(e.prototype instanceof Ze)return this.plugins.unregister(e);throw new Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},Qc,Jc,ed,td,nd,rd,sd,id,od,gr,Os,In,Ie,na,ra,sa,ia,oa,mr;od=[Pe],id=[pe],sd=[pe],rd=[pe],nd=[pe],td=[pe],ed=[Pe],Jc=[Pe],Qc=[Pe];var xt=class{constructor(e){ae(Ie,5,this),be(this,gr),be(this,Os),be(this,In,new yn(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Nt,be(this,na,ae(Ie,8,this,!1)),ae(Ie,11,this),be(this,ra,ae(Ie,12,this,null)),ae(Ie,15,this),be(this,sa,ae(Ie,16,this,null)),ae(Ie,19,this),be(this,ia,ae(Ie,20,this,null)),ae(Ie,23,this),be(this,oa,ae(Ie,24,this,[])),ae(Ie,27,this),this.position=new oi({x:0,y:0}),be(this,mr,{x:0,y:0}),it(this,gr,e)}get shape(){const{current:e,initial:t,previous:n}=je(this,In);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?je(this,In).current=e:je(this,In).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=je(this,gr).registry.draggables.get(t);return n&&it(this,Os,n),(e=n??je(this,Os))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=je(this,gr).registry.droppables.get(t))!=null?e:null}get transform(){const{x:e,y:t}=this.position.delta;let n={x:e,y:t};for(const r of this.modifiers)n=r.apply(zo(Fo({},this.snapshot()),{transform:n}));return it(this,mr,n),n}snapshot(){return he(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:je(this,mr),shape:this.shape?ki(this.shape):null,position:ki(this.position),status:ki(this.status),canceled:this.canceled}))}reset(){De(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,je(this,In).reset(),this.position.reset({x:0,y:0}),it(this,mr,{x:0,y:0}),this.modifiers=[]})}};Ie=Qn(null);gr=new WeakMap;Os=new WeakMap;In=new WeakMap;na=new WeakMap;ra=new WeakMap;sa=new WeakMap;ia=new WeakMap;oa=new WeakMap;mr=new WeakMap;ge(Ie,2,"shape",od,xt);ge(Ie,4,"canceled",id,xt,na);ge(Ie,4,"activatorEvent",sd,xt,ra);ge(Ie,4,"sourceIdentifier",rd,xt,sa);ge(Ie,4,"targetIdentifier",nd,xt,ia);ge(Ie,4,"modifiers",td,xt,oa);ge(Ie,2,"source",ed,xt);ge(Ie,2,"target",Jc,xt);ge(Ie,2,"transform",Qc,xt);xn(Ie,xt);var Qf={get rendering(){return Promise.resolve()}};function yt(e,t){return typeof e=="function"?e(t):e??t}var Jf=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(f=>f.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},s=yt(r.plugins,[]),i=yt(r.sensors,[]),o=yt(r.modifiers,[]),a=(n=r.renderer)!=null?n:Qf,l=new Kf(this),u=new Zf(this);this.registry=u,this.monitor=l,this.renderer=a,this.actions=new Yf(this),this.dragOperation=new xt(this),this.collisionObserver=new Uf(this),this.plugins=[Hf,...s],this.modifiers=o,this.sensors=i;const{destroy:c}=this,d=Yr(()=>{var f,p,m;const g=he(()=>this.dragOperation.modifiers),x=this.modifiers;for(const k of g)x.includes(k)||k.destroy();this.dragOperation.modifiers=(m=(p=(f=this.dragOperation.source)==null?void 0:f.modifiers)==null?void 0:p.map(k=>{const{plugin:b,options:h}=Mr(k);return new b(this,h)}))!=null?m:x});this.destroy=()=>{d(),c()}}get plugins(){return this.registry.plugins.values}set plugins(t){this.registry.plugins.values=t}get modifiers(){return this.registry.modifiers.values}set modifiers(t){this.registry.modifiers.values=t}get sensors(){return this.registry.sensors.values}set sensors(t){this.registry.sensors.values=t}},ad=e=>{throw TypeError(e)},aa=(e,t,n)=>t.has(e)||ad("Cannot "+n),oe=(e,t,n)=>(aa(e,t,"read from private field"),t.get(e)),nt=(e,t,n)=>t.has(e)?ad("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),st=(e,t,n,r)=>(aa(e,t,"write to private field"),t.set(e,n),n),ld=(e,t,n)=>(aa(e,t,"access private method"),n);function li(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function cd(e,t){const n=e.getAnimations();let r=null;for(const s of n){if(s.playState!=="running")continue;const{effect:i}=s,a=(li(i)?i.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],s])}return r}function ci(e){const{width:t,height:n,top:r,left:s,bottom:i,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:s,bottom:i,right:o}}function la(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Jr(e){return"nodeType"in e}function ot(e){var t,n,r;return e?la(e)?e:Jr(e)?"defaultView"in e?(t=e.defaultView)!=null?t:window:(r=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?r:window:window:window}function ca(e){const{Document:t}=ot(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Yt(e){return!e||la(e)?!1:e instanceof ot(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function dd(e){return e instanceof ot(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function tr(e){return e?la(e)?e.document:Jr(e)?ca(e)?e:Yt(e)||dd(e)?e.ownerDocument:document:document:document}function eh(e){var t,n,r,s;const{documentElement:i}=tr(e),o=ot(e).visualViewport,a=(t=o?.width)!=null?t:i.clientWidth,l=(n=o?.height)!=null?n:i.clientHeight,u=(r=o?.offsetTop)!=null?r:0,c=(s=o?.offsetLeft)!=null?s:0;return{top:u,left:c,right:c+a,bottom:u+l,width:a,height:l}}function th(e,t){if(nh(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function nh(e){return e.tagName==="DETAILS"}function Lr(e,t=e.getBoundingClientRect(),n=0){var r,s,i,o,a;let l=t;const{ownerDocument:u}=e,c=(r=u.defaultView)!=null?r:window;let d=e.parentElement;for(;d&&d!==u.documentElement;){if(!th(d)){const h=d.getBoundingClientRect(),y=n*(h.bottom-h.top),w=n*(h.right-h.left),D=n*(h.bottom-h.top),T=n*(h.right-h.left);l={top:Math.max(l.top,h.top-y),right:Math.min(l.right,h.right+w),bottom:Math.min(l.bottom,h.bottom+D),left:Math.max(l.left,h.left-T),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}d=d.parentElement}const f=c.visualViewport,p=(s=f?.offsetTop)!=null?s:0,m=(i=f?.offsetLeft)!=null?i:0,g=(o=f?.width)!=null?o:c.innerWidth,x=(a=f?.height)!=null?a:c.innerHeight,k=n*x,b=n*g;return l={top:Math.max(l.top,p-k),right:Math.min(l.right,m+g+b),bottom:Math.min(l.bottom,p+x+k),left:Math.max(l.left,m-b),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top,l.width<0&&(l.width=0),l.height<0&&(l.height=0),l}function Bn(e){return{x:e.clientX,y:e.clientY}}var ud=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function so(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const s=r.contentDocument;s&&!t.has(s)&&n.push(...so(s,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const s=r.parent;s&&s.document&&s.document!==e&&n.push(...so(s.document,t))}}catch{}return n}function da(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function fd(){var e,t;const n=da()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function ua(e){return!e||!Jr(e)?!1:e instanceof ot(e).ShadowRoot}function Ws(e){if(e&&Jr(e)){let t=e.getRootNode();if(ua(t))return t;if(t instanceof Document)return t}return tr(e)}function fa(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function rh(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((i,o)=>{const a=r[o];if(Va(i)&&Va(a)&&(i.type!=="file"&&(i.value=a.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),Ka(i)&&Ka(a)&&a.width>0&&a.height>0){const l=i.getContext("2d");l?.drawImage(a,0,0)}}),n}function Va(e){return"value"in e}function Ka(e){return e.tagName==="CANVAS"}function hd(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(sh(r)){const{contentDocument:s}=r;if(s){const{left:i,top:o}=r.getBoundingClientRect();return hd(s,{x:t-i,y:n-o})}}return r}function sh(e){return e?.tagName==="IFRAME"}var io=new WeakMap;function ih(e){return e.closest(`
|
|
2
2
|
input:not([disabled]),
|
|
3
3
|
select:not([disabled]),
|
|
4
4
|
textarea:not([disabled]),
|
|
5
5
|
button:not([disabled]),
|
|
6
6
|
a[href],
|
|
7
7
|
[contenteditable]:not([contenteditable="false"])
|
|
8
|
-
`)}var $c=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:i}]=e;t.removeEventListener(n,r,i)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],i=[];for(const o of n)for(const a of r){const{type:l,listener:u,options:d}=a,c=[o,a];o.addEventListener(l,u,d),this.entries.add(c),i.push(c)}const s=this.entries;return function(){for(const a of i){const[l,{type:u,listener:d,options:c}]=a;l.removeEventListener(u,d,c),s.delete(a)}}}};function wn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function cf(e){const t=new Set;let n=wn(e);for(;n;)t.add(n),n=wn(n);return t}function df(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Ec(e,t){const n=()=>performance.now();let r,i;return function(...s){const o=this;i?(r?.(),r=df(()=>{e.apply(o,s),i=n()},t-(n()-i))):(e.apply(o,s),i=n())}}function uf(e,t){return e===t?!0:!e||!t?!1:e.top==t.top&&e.left==t.left&&e.right==t.right&&e.bottom==t.bottom}function ff(e,t=e.getBoundingClientRect()){const{width:n,height:r}=mr(e,t);return n>0&&r>0}var hf=_c?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ni,pf=class extends hf{constructor(e){super(t=>{if(!F(this,ni)){qe(this,ni,!0);return}e(t,this)}),Ne(this,ni,!1)}};ni=new WeakMap;var ya=Array.from({length:100},(e,t)=>t/100),Oc=75,Rt,gi,wt,Lt,Qn,De,dr,Zn,vi,Tc,Dc,Cc=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,Ne(this,vi),this.disconnect=()=>{var s,o,a;qe(this,dr,!0),(s=F(this,wt))==null||s.disconnect(),(o=F(this,Lt))==null||o.disconnect(),F(this,Qn).disconnect(),(a=F(this,De))==null||a.remove()},Ne(this,Rt,!0),Ne(this,gi),Ne(this,wt),Ne(this,Lt),Ne(this,Qn),Ne(this,De),Ne(this,dr,!1),Ne(this,Zn,Ec(()=>{var s,o,a;const{element:l}=this;if((s=F(this,Lt))==null||s.disconnect(),F(this,dr)||!F(this,Rt)||!l.isConnected)return;const u=(o=l.ownerDocument)!=null?o:document,{innerHeight:d,innerWidth:c}=(a=u.defaultView)!=null?a:window,h=l.getBoundingClientRect(),f=mr(l,h),{top:v,left:p,bottom:w,right:x}=f,m=-Math.floor(v),g=-Math.floor(p),b=-Math.floor(c-x),_=-Math.floor(d-w),$=`${m}px ${b}px ${_}px ${g}px`;this.boundingClientRect=h,qe(this,Lt,new IntersectionObserver(O=>{const[C]=O,{intersectionRect:I}=C;(C.intersectionRatio!==1?C.intersectionRatio:dt.intersectionRatio(I,mr(l)))!==1&&F(this,Zn).call(this)},{threshold:ya,rootMargin:$,root:u})),F(this,Lt).observe(l),bc(this,vi,Tc).call(this)},Oc)),this.boundingClientRect=e.getBoundingClientRect(),qe(this,Rt,ff(e,this.boundingClientRect));let r=!0;this.callback=s=>{r&&(r=!1,n.skipInitial)||t(s)};const i=e.ownerDocument;n?.debug&&(qe(this,De,document.createElement("div")),F(this,De).style.background="rgba(0,0,0,0.15)",F(this,De).style.position="fixed",F(this,De).style.pointerEvents="none",i.body.appendChild(F(this,De))),qe(this,Qn,new IntersectionObserver(s=>{var o,a;const l=s[s.length-1],{boundingClientRect:u,isIntersecting:d}=l,{width:c,height:h}=u,f=F(this,Rt);qe(this,Rt,d),!(!c&&!h)&&(f&&!d?((o=F(this,Lt))==null||o.disconnect(),this.callback(null),(a=F(this,wt))==null||a.disconnect(),qe(this,wt,void 0),F(this,De)&&(F(this,De).style.visibility="hidden")):F(this,Zn).call(this),d&&!F(this,wt)&&(qe(this,wt,new pf(F(this,Zn))),F(this,wt).observe(e)))},{threshold:ya,root:i})),F(this,Rt)&&!n.skipInitial&&this.callback(this.boundingClientRect),F(this,Qn).observe(e)}};Rt=new WeakMap;gi=new WeakMap;wt=new WeakMap;Lt=new WeakMap;Qn=new WeakMap;De=new WeakMap;dr=new WeakMap;Zn=new WeakMap;vi=new WeakSet;Tc=function(){F(this,dr)||(bc(this,vi,Dc).call(this),!uf(this.boundingClientRect,F(this,gi))&&(this.callback(this.boundingClientRect),qe(this,gi,this.boundingClientRect)))};Dc=function(){if(F(this,De)){const{top:e,left:t,width:n,height:r}=mr(this.element);F(this,De).style.overflow="hidden",F(this,De).style.visibility="visible",F(this,De).style.top=`${Math.floor(e)}px`,F(this,De).style.left=`${Math.floor(t)}px`,F(this,De).style.width=`${Math.floor(n)}px`,F(this,De).style.height=`${Math.floor(r)}px`}};var zr=new WeakMap,Fr=new WeakMap;function gf(e,t){let n=zr.get(e);return n||(n={disconnect:new Cc(e,i=>{const s=zr.get(e);s&&s.callbacks.forEach(o=>o(i))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),zr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(zr.delete(e),n.disconnect())}}function vf(e,t){const n=new Set;for(const r of e){const i=gf(r,t);n.add(i)}return()=>n.forEach(r=>r())}function mf(e,t){var n;const r=e.ownerDocument;if(!Fr.has(r)){const o=new AbortController,a=new Set;document.addEventListener("scroll",l=>a.forEach(u=>u(l)),{capture:!0,passive:!0,signal:o.signal}),Fr.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:i,disconnect:s}=(n=Fr.get(r))!=null?n:{};return!i||!s?()=>{}:(i.add(t),()=>{i.delete(t),i.size===0&&(s(),Fr.delete(r))})}var Jn,er,ri,Ts,yf=class{constructor(e,t,n){this.callback=t,Ne(this,Jn),Ne(this,er,!1),Ne(this,ri),Ne(this,Ts,Ec(o=>{if(!F(this,er)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of F(this,ri))if(o.target.contains(a)){this.callback(F(this,Jn).boundingClientRect);break}}},Oc));const r=cf(e),i=vf(r,t),s=mf(e,F(this,Ts));qe(this,ri,r),qe(this,Jn,new Cc(e,t,n)),this.disconnect=()=>{F(this,er)||(qe(this,er,!0),i(),s(),F(this,Jn).disconnect())}}};Jn=new WeakMap;er=new WeakMap;ri=new WeakMap;Ts=new WeakMap;function Ds(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function vn(e){try{Ds(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function ba(e){return!_c||!e?!1:e===jn(e).scrollingElement}function Pc(e){var t,n;const r=Ke(e),i=ba(e)?nf(e):Ri(e),s=r.visualViewport,o=ba(e)?{height:(t=s?.height)!=null?t:r.innerHeight,width:(n=s?.width)!=null?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-o.width,y:e.scrollHeight-o.height}},l=a.current.y<=0,u=a.current.x<=0,d=a.current.y>=a.max.y,c=a.current.x>=a.max.x;return{rect:i,position:a,isTop:l,isLeft:u,isBottom:d,isRight:c}}function bf(e,t){const{isTop:n,isBottom:r,isLeft:i,isRight:s,position:o}=Pc(e),{x:a,y:l}=t??{x:0,y:0},u=!n&&o.current.y+l>0,d=!r&&o.current.y+l<o.max.y,c=!i&&o.current.x+a>0,h=!s&&o.current.x+a<o.max.x;return{top:u,bottom:d,left:c,right:h,x:c||h,y:u||d}}var Lo=class{constructor(t){this.scheduler=t,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:n,resolvers:r}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const i of n)i();for(const i of r)i()}}schedule(t){return this.tasks.add(t),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(n=>this.resolvers.add(n))}},mi=new Lo(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),xf=new Lo(e=>setTimeout(e,50)),yi=new Map,wf=yi.clear.bind(yi);function ht(e,t=!1){if(!t)return xa(e);let n=yi.get(e);return n||(n=xa(e),yi.set(e,n),xf.schedule(wf),n)}function xa(e){return Ke(e).getComputedStyle(e)}function _f(e,t=ht(e,!0)){return t.position==="fixed"||t.position==="sticky"}function kf(e,t=ht(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const s=t[i];return typeof s=="string"?n.test(s):!1})}var Sf={excludeElement:!0,escapeShadowDOM:!0};function Cs(e,t=Sf){const{limit:n,excludeElement:r,escapeShadowDOM:i}=t,s=new Set;function o(a){if(n!=null&&s.size>=n||!a)return s;if(Io(a)&&a.scrollingElement!=null&&!s.has(a.scrollingElement))return s.add(a.scrollingElement),s;if(i&&Ao(a))return o(a.host);if(!Tt(a))return wc(a)?o(a.parentElement):s;if(s.has(a))return s;const l=ht(a,!0);if(r&&a===e||kf(a,l)&&s.add(a),_f(a,l)){const{scrollingElement:u}=a.ownerDocument;return u&&s.add(u),s}return o(a.parentNode)}return e?o(e):s}function _n(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=wn(e);for(;r;){if(r===t)return n;const i=Ri(r),{x:s,y:o}=$f(r,i);n.x=n.x+i.left,n.y=n.y+i.top,n.scaleX=n.scaleX*s,n.scaleY=n.scaleY*o,r=wn(r)}return n}function $f(e,t=Ri(e)){const n=Math.round(t.width),r=Math.round(t.height);if(Tt(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const i=ht(e,!0);return{x:(parseFloat(i.width)||n)/n,y:(parseFloat(i.height)||r)/r}}function Ef(e){if(!e||e==="none")return null;const t=e.split(" "),n=parseFloat(t[0]),r=parseFloat(t[1]);return isNaN(n)&&isNaN(r)?null:{x:isNaN(n)?r:n,y:isNaN(r)?n:r}}function yr(e){if(!e||e==="none")return null;const[t,n,r="0"]=e.split(" "),i={x:parseFloat(t),y:parseFloat(n),z:parseInt(r,10)};return isNaN(i.x)&&isNaN(i.y)?null:{x:isNaN(i.x)?0:i.x,y:isNaN(i.y)?0:i.y,z:isNaN(i.z)?0:i.z}}function Li(e){var t,n,r,i,s,o,a,l,u;const{scale:d,transform:c,translate:h}=e,f=Ef(d),v=yr(h),p=Of(c);if(!p&&!f&&!v)return null;const w={x:(t=f?.x)!=null?t:1,y:(n=f?.y)!=null?n:1},x={x:(r=v?.x)!=null?r:0,y:(i=v?.y)!=null?i:0},m={x:(s=p?.x)!=null?s:0,y:(o=p?.y)!=null?o:0,scaleX:(a=p?.scaleX)!=null?a:1,scaleY:(l=p?.scaleY)!=null?l:1};return{x:x.x+m.x,y:x.y+m.y,z:(u=v?.z)!=null?u:0,scaleX:w.x*m.scaleX,scaleY:w.y*m.scaleY}}function Of(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var Je=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(Je||{}),Tf={x:.2,y:.2},Df={x:10,y:10};function Cf(e,t,n,r=25,i=Tf,s=Df){const{x:o,y:a}=t,{rect:l,isTop:u,isBottom:d,isLeft:c,isRight:h}=Pc(e),f=_n(e),v=ht(e,!0),p=Li(v),w=p!==null?p?.scaleX<0:!1,x=p!==null?p?.scaleY<0:!1,m=new dt(l.left*f.scaleX+f.x,l.top*f.scaleY+f.y,l.width*f.scaleX,l.height*f.scaleY),g={x:0,y:0},b={x:0,y:0},_={height:m.height*i.y,width:m.width*i.x};return _.height>0&&(!u||x&&!d)&&a<=m.top+_.height&&n?.y!==1&&o>=m.left-s.x&&o<=m.right+s.x?(g.y=x?1:-1,b.y=r*Math.abs((m.top+_.height-a)/_.height)):_.height>0&&(!d||x&&!u)&&a>=m.bottom-_.height&&n?.y!==-1&&o>=m.left-s.x&&o<=m.right+s.x&&(g.y=x?-1:1,b.y=r*Math.abs((m.bottom-_.height-a)/_.height)),_.width>0&&(!h||w&&!c)&&o>=m.right-_.width&&n?.x!==-1&&a>=m.top-s.y&&a<=m.bottom+s.y?(g.x=w?-1:1,b.x=r*Math.abs((m.right-_.width-o)/_.width)):_.width>0&&(!c||w&&!h)&&o<=m.left+_.width&&n?.x!==1&&a>=m.top-s.y&&a<=m.bottom+s.y&&(g.x=w?1:-1,b.x=r*Math.abs((m.left+_.width-o)/_.width)),{direction:g,speed:b}}function Mc(e,{block:t="nearest",inline:n="nearest"}={}){if(!Tt(e))return;const r=Cs(e),i=[];for(const s of r){if(!Tt(s))continue;const{top:o,left:a}=Pf(e,s);let l=o,u=a;for(const d of i)l-=d.scrollTop,u-=d.scrollLeft;if(t!=="none"){const d=l<s.scrollTop,c=l+e.offsetHeight>s.scrollTop+s.clientHeight;d!==c&&(t==="center"?s.scrollTop=l-s.clientHeight/2+e.offsetHeight/2:d?s.scrollTop=l:s.scrollTop=l+e.offsetHeight-s.clientHeight)}if(n!=="none"){const d=u<s.scrollLeft,c=u+e.offsetWidth>s.scrollLeft+s.clientWidth;d!==c&&(n==="center"?s.scrollLeft=u-s.clientWidth/2+e.offsetWidth/2:d?s.scrollLeft=u:s.scrollLeft=u+e.offsetWidth-s.clientWidth)}i.push(s)}}function wa(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const i=r.offsetParent;if(!Tt(i))break;t+=i.clientTop,n+=i.clientLeft,r=i}return{top:t,left:n}}function Pf(e,t){const n=wa(e),r=wa(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function Mf(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left+s+(1-r)*parseFloat(n),l=e.top+o+(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=r?e.width*r:e.width,d=i?e.height*i:e.height;return{width:u,height:d,top:l,right:a+u,bottom:l+d,left:a}}function If(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left-s-(1-r)*parseFloat(n),l=e.top-o-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=r?e.width/r:e.width,d=i?e.height/i:e.height;return{width:u,height:d,top:l,right:a+u,bottom:l+d,left:a}}function Ic({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function _a(e,t=ht(e).translate,n=!0){if(n){const r=xc(e,i=>"translate"in i);if(r){const{translate:i=""}=r[0];if(typeof i=="string"){const s=yr(i);if(s)return s}}}if(t){const r=yr(t);if(r)return r}return{x:0,y:0,z:0}}var jf=new Lo(e=>setTimeout(e,0)),ur=new Map,Af=ur.clear.bind(ur);function Rf(e){const t=e.ownerDocument;let n=ur.get(t);if(n)return n;n=t.getAnimations(),ur.set(t,n),jf.schedule(Af);const r=n.filter(i=>Ai(i.effect)&&i.effect.target===e);return ur.set(e,r),n}function Lf(e,t){const n=Rf(e).filter(r=>{var i,s;if(Ai(r.effect)){const{target:o}=r.effect;if((s=o&&((i=t.isValidTarget)==null?void 0:i.call(t,o)))!=null?s:!0)return r.effect.getKeyframes().some(l=>{for(const u of t.properties)if(l[u])return!0})}}).map(r=>{const{effect:i,currentTime:s}=r,o=i?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof o=="number"&&typeof s=="number"&&s<o)return r.currentTime=o,()=>{r.currentTime=s}});if(n.length>0)return()=>n.forEach(r=>r?.())}var ct=class extends dt{constructor(e,t={}){var n,r,i,s;const{frameTransform:o=_n(e),ignoreTransforms:a,getBoundingClientRect:l=Ri}=t,u=Lf(e,{properties:["transform","translate","scale","width","height"],isValidTarget:_=>(_!==e||jo())&&_.contains(e)}),d=l(e);let{top:c,left:h,width:f,height:v}=d,p;const w=ht(e),x=Li(w),m={x:(n=x?.scaleX)!=null?n:1,y:(r=x?.scaleY)!=null?r:1},g=Wf(e,w);u?.(),x&&(p=If(d,x,w.transformOrigin),(a||g)&&(c=p.top,h=p.left,f=p.width,v=p.height));const b={width:(i=p?.width)!=null?i:f,height:(s=p?.height)!=null?s:v};if(g&&!a&&p){const _=Mf(p,g,w.transformOrigin);c=_.top,h=_.left,f=_.width,v=_.height,m.x=g.scaleX,m.y=g.scaleY}o&&(a||(h*=o.scaleX,f*=o.scaleX,c*=o.scaleY,v*=o.scaleY),h+=o.x,c+=o.y),super(h,c,f,v),this.scale=m,this.intrinsicWidth=b.width,this.intrinsicHeight=b.height}};function Wf(e,t){const n=e.getAnimations();if(!n.length)return null;let r,i,s,o=!1;for(const a of n){if(a.playState!=="running")continue;const l=Ai(a.effect)?a.effect.getKeyframes():[],u=l[l.length-1];if(!u)continue;const{transform:d,translate:c,scale:h}=u;typeof d=="string"&&d&&(r=d,o=!0),typeof c=="string"&&c&&(i=c,o=!0),typeof h=="string"&&h&&(s=h,o=!0)}return o?Li({transform:r??t.transform,translate:i??t.translate,scale:s??t.scale}):null}function fr(e){return"style"in e&&typeof e.style=="object"&&e.style!==null&&"setProperty"in e.style&&"removeProperty"in e.style&&typeof e.style.setProperty=="function"&&typeof e.style.removeProperty=="function"}var zf=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(fr(n))for(const[r,i]of Object.entries(e)){const s=`${t}${r}`;this.initial.has(s)||this.initial.set(s,n.style.getPropertyValue(s)),n.style.setProperty(s,typeof i=="string"?i:`${i}px`)}}remove(e,t=""){const{element:n}=this;if(fr(n))for(const r of e){const i=`${t}${r}`;n.style.removeProperty(i)}}reset(){const{element:e}=this;if(fr(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function Vt(e){return e?e instanceof Ke(e).Element||Dr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function br(e){if(!e)return!1;const{KeyboardEvent:t}=Ke(e.target);return e instanceof t}function Ff(e){if(!e)return!1;const{PointerEvent:t}=Ke(e.target);return e instanceof t}function Nf(e){if(!Vt(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||Bf(e)}function Bf(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var Ji={};function Ps(e){const t=Ji[e]==null?0:Ji[e]+1;return Ji[e]=t,`${e}-${t}`}var Wo=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const i=Ze.distance(t.shape.center,n);return{id:r,value:1/i,type:In.PointerIntersection,priority:Mn.High}}return null},Vf=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:i}=e,s=Ze.distance(t.shape.center,i.current),a=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:a,type:In.ShapeIntersection,priority:Mn.Normal}}return null},jc=e=>{var t;return(t=Wo(e))!=null?t:Vf(e)},Gf=e=>{const{dragOperation:t,droppable:n}=e,{shape:r,position:i}=t;if(!n.shape)return null;const s=r?dt.from(r.current.boundingRectangle).corners:void 0,a=dt.from(n.shape.boundingRectangle).corners.reduce((l,u,d)=>{var c;return l+Ze.distance(Ze.from(u),(c=s?.[d])!=null?c:i.current)},0)/4;return{id:n.id,value:1/a,type:In.Collision,priority:Mn.Normal}},Uf=Object.create,zo=Object.defineProperty,qf=Object.defineProperties,Hf=Object.getOwnPropertyDescriptor,Kf=Object.getOwnPropertyDescriptors,bi=Object.getOwnPropertySymbols,Ac=Object.prototype.hasOwnProperty,Rc=Object.prototype.propertyIsEnumerable,Lc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),An=e=>{throw TypeError(e)},Ms=(e,t,n)=>t in e?zo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xr=(e,t)=>{for(var n in t||(t={}))Ac.call(t,n)&&Ms(e,n,t[n]);if(bi)for(var n of bi(t))Rc.call(t,n)&&Ms(e,n,t[n]);return e},Fo=(e,t)=>qf(e,Kf(t)),ka=(e,t)=>zo(e,"name",{value:t,configurable:!0}),Wc=(e,t)=>{var n={};for(var r in e)Ac.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&bi)for(var r of bi(e))t.indexOf(r)<0&&Rc.call(e,r)&&(n[r]=e[r]);return n},Rn=e=>{var t;return[,,,Uf((t=e?.[Lc("metadata")])!=null?t:null)]},zc=["class","method","getter","setter","accessor","field","value","get","set"],tr=e=>e!==void 0&&typeof e!="function"?An("Function expected"):e,Yf=(e,t,n,r,i)=>({kind:zc[e],name:t,metadata:r,addInitializer:s=>n._?An("Already initialized"):i.push(tr(s||null))}),Xt=(e,t)=>Ms(t,Lc("metadata"),e[3]),we=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},nt=(e,t,n,r,i,s)=>{var o,a,l,u,d,c=t&7,h=!!(t&8),f=!!(t&16),v=c>3?e.length+1:c?h?1:2:0,p=zc[c+5],w=c>3&&(e[v-1]=[]),x=e[v]||(e[v]=[]),m=c&&(!f&&!h&&(i=i.prototype),c<5&&(c>3||!f)&&Hf(c<4?i:{get[n](){return re(this,s)},set[n](b){return Ae(this,s,b)}},n));c?f&&c<4&&ka(s,(c>2?"set ":c>1?"get ":"")+n):ka(i,n);for(var g=r.length-1;g>=0;g--)u=Yf(c,n,l={},e[3],x),c&&(u.static=h,u.private=f,d=u.access={has:f?b=>Xf(i,b):b=>n in b},c^3&&(d.get=f?b=>(c^1?re:Gt)(b,i,c^4?s:m.get):b=>b[n]),c>2&&(d.set=f?(b,_)=>Ae(b,i,_,c^4?s:m.set):(b,_)=>b[n]=_)),a=(0,r[g])(c?c<4?f?s:m[p]:c>4?void 0:{get:m.get,set:m.set}:i,u),l._=1,c^4||a===void 0?tr(a)&&(c>4?w.unshift(a):c?f?s=a:m[p]=a:i=a):typeof a!="object"||a===null?An("Object expected"):(tr(o=a.get)&&(m.get=o),tr(o=a.set)&&(m.set=o),tr(o=a.init)&&w.unshift(o));return c||Xt(e,i),m&&zo(i,n,m),f?c^4?s:m:i},No=(e,t,n)=>t.has(e)||An("Cannot "+n),Xf=(e,t)=>Object(t)!==t?An('Cannot use the "in" operator on this value'):e.has(t),re=(e,t,n)=>(No(e,t,"read from private field"),n?n.call(e):t.get(e)),ve=(e,t,n)=>t.has(e)?An("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ae=(e,t,n,r)=>(No(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Gt=(e,t,n)=>(No(e,t,"access private method"),n),Sa={role:"button",roleDescription:"draggable"},Qf="dnd-kit-description",Zf="dnd-kit-announcement",Jf={draggable:"To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item in a given direction. Press space again to drop the item in its new position, or press escape to cancel."},eh={dragstart({operation:{source:e}}){if(e)return`Picked up draggable item ${e.id}.`},dragover({operation:{source:e,target:t}}){if(!(!e||e.id===t?.id))return t?`Draggable item ${e.id} was moved over droppable target ${t.id}.`:`Draggable item ${e.id} is no longer over a droppable target.`},dragend({operation:{source:e,target:t},canceled:n}){if(e)return n?`Dragging was cancelled. Draggable item ${e.id} was dropped.`:t?`Draggable item ${e.id} was dropped over droppable target ${t.id}`:`Draggable item ${e.id} was dropped.`}};function th(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function nh(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function rh(e){const t=document.createElement("div");return t.id=e,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.style.setProperty("position","fixed"),t.style.setProperty("width","1px"),t.style.setProperty("height","1px"),t.style.setProperty("margin","-1px"),t.style.setProperty("border","0"),t.style.setProperty("padding","0"),t.style.setProperty("overflow","hidden"),t.style.setProperty("clip","rect(0 0 0 0)"),t.style.setProperty("clip-path","inset(100%)"),t.style.setProperty("white-space","nowrap"),t}var ih=["dragover","dragmove"],sh=class extends Me{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=Qf,announcement:i=Zf}={},announcements:s=eh,screenReaderInstructions:o=Jf,debounce:a=500}=t??{},l=n?`${r}-${n}`:Ps(r),u=n?`${i}-${n}`:Ps(i);let d,c,h,f;const v=(_=f)=>{!h||!_||h?.nodeValue!==_&&(h.nodeValue=_)},p=()=>mi.schedule(v),w=oh(p,a),x=Object.entries(s).map(([_,$])=>this.manager.monitor.addEventListener(_,(O,C)=>{const I=h;if(!I)return;const P=$?.(O,C);P&&I.nodeValue!==P&&(f=P,ih.includes(_)?w():(p(),w.cancel()))})),m=()=>{let _=[];d?.isConnected||(d=nh(l,o.draggable),_.push(d)),c?.isConnected||(c=rh(u),h=document.createTextNode(""),c.appendChild(h),_.push(c)),_.length>0&&document.body.append(..._)},g=new Set;function b(){for(const _ of g)_()}this.registerEffect(()=>{var _;g.clear();for(const $ of this.manager.registry.draggables.value){const O=(_=$.handle)!=null?_:$.element;if(O){(!d||!c)&&g.add(m),(!th(O)||jo())&&!O.hasAttribute("tabindex")&&g.add(()=>O.setAttribute("tabindex","0")),!O.hasAttribute("role")&&O.tagName.toLowerCase()!=="button"&&g.add(()=>O.setAttribute("role",Sa.role)),O.hasAttribute("aria-roledescription")||g.add(()=>O.setAttribute("aria-roledescription",Sa.roleDescription)),O.hasAttribute("aria-describedby")||g.add(()=>O.setAttribute("aria-describedby",l));for(const I of["aria-pressed","aria-grabbed"]){const P=String($.isDragging);O.getAttribute(I)!==P&&g.add(()=>O.setAttribute(I,P))}const C=String($.disabled);O.getAttribute("aria-disabled")!==C&&g.add(()=>O.setAttribute("aria-disabled",C))}}g.size>0&&mi.schedule(b)}),this.destroy=()=>{super.destroy(),d?.remove(),c?.remove(),x.forEach(_=>_())}}};function oh(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var xi=new Map,Fc,Nc,Bc,Vc,Is,hr,mt,Bo,kn,Gc,Uc,qc,Hc,Dt=class extends(Is=Tr,Vc=[K],Bc=[ge],Nc=[ge],Fc=[ge],Is){constructor(t,n){super(t,n),we(mt,5,this),ve(this,kn),ve(this,hr,new Set),ve(this,Bo,we(mt,8,this,new Set)),we(mt,11,this),this.registerEffect(Gt(this,kn,Gc))}register(t){return re(this,hr).add(t),()=>{re(this,hr).delete(t)}}addRoot(t){return H(()=>{const n=new Set(this.additionalRoots);n.add(t),this.additionalRoots=n}),()=>{H(()=>{const n=new Set(this.additionalRoots);n.delete(t),this.additionalRoots=n})}}get sourceRoot(){var t;const{source:n}=this.manager.dragOperation;return pi((t=n?.element)!=null?t:null)}get targetRoot(){var t;const{target:n}=this.manager.dragOperation;return pi((t=n?.element)!=null?t:null)}get roots(){const{status:t}=this.manager.dragOperation;if(t.initializing||t.initialized){const n=[this.sourceRoot,this.targetRoot].filter(r=>r!=null);return new Set([...n,...this.additionalRoots])}return new Set}};mt=Rn(Is);hr=new WeakMap;Bo=new WeakMap;kn=new WeakSet;Gc=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of re(this,hr))t.push(Gt(this,kn,Uc).call(this,n,r));return()=>{for(const n of t)n()}};Uc=function(e,t){let n=xi.get(e);n||(n=new Map,xi.set(e,n));let r=n.get(t);if(!r){const s=Io(e)?Gt(this,kn,qc).call(this,e,n,t):Gt(this,kn,Hc).call(this,e,n,t);if(!s)return()=>{};r=s,n.set(t,r)}r.refCount++;let i=!1;return()=>{i||(i=!0,r.refCount--,r.refCount===0&&r.cleanup())}};qc=function(e,t,n){var r;const i=e.createElement("style"),{nonce:s}=(r=this.options)!=null?r:{};s&&i.setAttribute("nonce",s),i.textContent=n,e.head.prepend(i);const o=new MutationObserver(a=>{for(const l of a)for(const u of Array.from(l.removedNodes))if(u===i){e.head.prepend(i);return}});return o.observe(e.head,{childList:!0}),{refCount:0,cleanup:()=>{o.disconnect(),i.remove(),t.delete(n),t.size===0&&xi.delete(e)}}};Hc=function(e,t,n){"adoptedStyleSheets"in e&&Array.isArray(e.adoptedStyleSheets);const r=e.ownerDocument.defaultView,{CSSStyleSheet:i}=r??{};if(!i)return null;const s=new i;return s.replaceSync(n),e.adoptedStyleSheets.push(s),{refCount:0,cleanup:()=>{var o;if(Ao(e)&&((o=e.host)!=null&&o.isConnected)){const a=e.adoptedStyleSheets.indexOf(s);a!==-1&&e.adoptedStyleSheets.splice(a,1)}t.delete(n),t.size===0&&xi.delete(e)}}};nt(mt,4,"additionalRoots",Vc,Dt,Bo);nt(mt,2,"sourceRoot",Bc,Dt);nt(mt,2,"targetRoot",Nc,Dt);nt(mt,2,"roots",Fc,Dt);Xt(mt,Dt);Dt.configure=Or(Dt);var Wi=Dt,ah=class extends Me{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(Wi),i=r?.register(`* { cursor: ${n} !important; }`);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}}},Cr="data-dnd-",js=`${Cr}dropping`,Te="--dnd-",lt=`${Cr}dragging`,wi=`${Cr}placeholder`,lh=[lt,wi,"popover","aria-pressed","aria-grabbing"],ch=["view-transition-name"],dh=`
|
|
9
|
-
:is(:root,:host) [${
|
|
8
|
+
`)}var pd=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:s}]=e;t.removeEventListener(n,r,s)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],s=[];for(const o of n)for(const a of r){const{type:l,listener:u,options:c}=a,d=[o,a];o.addEventListener(l,u,c),this.entries.add(d),s.push(d)}const i=this.entries;return function(){for(const a of s){const[l,{type:u,listener:c,options:d}]=a;l.removeEventListener(u,c,d),i.delete(a)}}}};function qn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function oh(e){const t=new Set;let n=qn(e);for(;n;)t.add(n),n=qn(n);return t}function ah(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function gd(e,t){const n=()=>performance.now();let r,s;return function(...i){const o=this;s?(r?.(),r=ah(()=>{e.apply(o,i),s=n()},t-(n()-s))):(e.apply(o,i),s=n())}}function lh(e,t){return e===t?!0:!e||!t?!1:e.top==t.top&&e.left==t.left&&e.right==t.right&&e.bottom==t.bottom}function ch(e,t=e.getBoundingClientRect()){const{width:n,height:r}=Lr(e,t);return n>0&&r>0}var dh=ud?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},Es,uh=class extends dh{constructor(e){super(t=>{if(!oe(this,Es)){st(this,Es,!0);return}e(t,this)}),nt(this,Es,!1)}};Es=new WeakMap;var Ha=Array.from({length:100},(e,t)=>t/100),md=75,ln,Bs,Wt,cn,vr,Ke,Ir,br,qs,vd,bd,yd=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,nt(this,qs),this.disconnect=()=>{var i,o,a;st(this,Ir,!0),(i=oe(this,Wt))==null||i.disconnect(),(o=oe(this,cn))==null||o.disconnect(),oe(this,vr).disconnect(),(a=oe(this,Ke))==null||a.remove()},nt(this,ln,!0),nt(this,Bs),nt(this,Wt),nt(this,cn),nt(this,vr),nt(this,Ke),nt(this,Ir,!1),nt(this,br,gd(()=>{var i,o,a;const{element:l}=this;if((i=oe(this,cn))==null||i.disconnect(),oe(this,Ir)||!oe(this,ln)||!l.isConnected)return;const u=(o=l.ownerDocument)!=null?o:document,{innerHeight:c,innerWidth:d}=(a=u.defaultView)!=null?a:window,f=l.getBoundingClientRect(),p=Lr(l,f),{top:m,left:g,bottom:x,right:k}=p,b=-Math.floor(m),h=-Math.floor(g),y=-Math.floor(d-k),w=-Math.floor(c-x),D=`${b}px ${y}px ${w}px ${h}px`;this.boundingClientRect=f,st(this,cn,new IntersectionObserver(T=>{const[A]=T,{intersectionRect:I}=A;(A.intersectionRatio!==1?A.intersectionRatio:St.intersectionRatio(I,Lr(l)))!==1&&oe(this,br).call(this)},{threshold:Ha,rootMargin:D,root:u})),oe(this,cn).observe(l),ld(this,qs,vd).call(this)},md)),this.boundingClientRect=e.getBoundingClientRect(),st(this,ln,ch(e,this.boundingClientRect));let r=!0;this.callback=i=>{r&&(r=!1,n.skipInitial)||t(i)};const s=e.ownerDocument;n?.debug&&(st(this,Ke,document.createElement("div")),oe(this,Ke).style.background="rgba(0,0,0,0.15)",oe(this,Ke).style.position="fixed",oe(this,Ke).style.pointerEvents="none",s.body.appendChild(oe(this,Ke))),st(this,vr,new IntersectionObserver(i=>{var o,a;const l=i[i.length-1],{boundingClientRect:u,isIntersecting:c}=l,{width:d,height:f}=u,p=oe(this,ln);st(this,ln,c),!(!d&&!f)&&(p&&!c?((o=oe(this,cn))==null||o.disconnect(),this.callback(null),(a=oe(this,Wt))==null||a.disconnect(),st(this,Wt,void 0),oe(this,Ke)&&(oe(this,Ke).style.visibility="hidden")):oe(this,br).call(this),c&&!oe(this,Wt)&&(st(this,Wt,new uh(oe(this,br))),oe(this,Wt).observe(e)))},{threshold:Ha,root:s})),oe(this,ln)&&!n.skipInitial&&this.callback(this.boundingClientRect),oe(this,vr).observe(e)}};ln=new WeakMap;Bs=new WeakMap;Wt=new WeakMap;cn=new WeakMap;vr=new WeakMap;Ke=new WeakMap;Ir=new WeakMap;br=new WeakMap;qs=new WeakSet;vd=function(){oe(this,Ir)||(ld(this,qs,bd).call(this),!lh(this.boundingClientRect,oe(this,Bs))&&(this.callback(this.boundingClientRect),st(this,Bs,this.boundingClientRect)))};bd=function(){if(oe(this,Ke)){const{top:e,left:t,width:n,height:r}=Lr(this.element);oe(this,Ke).style.overflow="hidden",oe(this,Ke).style.visibility="visible",oe(this,Ke).style.top=`${Math.floor(e)}px`,oe(this,Ke).style.left=`${Math.floor(t)}px`,oe(this,Ke).style.width=`${Math.floor(n)}px`,oe(this,Ke).style.height=`${Math.floor(r)}px`}};var cs=new WeakMap,ds=new WeakMap;function fh(e,t){let n=cs.get(e);return n||(n={disconnect:new yd(e,s=>{const i=cs.get(e);i&&i.callbacks.forEach(o=>o(s))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),cs.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(cs.delete(e),n.disconnect())}}function hh(e,t){const n=new Set;for(const r of e){const s=fh(r,t);n.add(s)}return()=>n.forEach(r=>r())}function ph(e,t){var n;const r=e.ownerDocument;if(!ds.has(r)){const o=new AbortController,a=new Set;document.addEventListener("scroll",l=>a.forEach(u=>u(l)),{capture:!0,passive:!0,signal:o.signal}),ds.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:s,disconnect:i}=(n=ds.get(r))!=null?n:{};return!s||!i?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(i(),ds.delete(r))})}var yr,xr,Cs,oo,gh=class{constructor(e,t,n){this.callback=t,nt(this,yr),nt(this,xr,!1),nt(this,Cs),nt(this,oo,gd(o=>{if(!oe(this,xr)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of oe(this,Cs))if(o.target.contains(a)){this.callback(oe(this,yr).boundingClientRect);break}}},md));const r=oh(e),s=hh(r,t),i=ph(e,oe(this,oo));st(this,Cs,r),st(this,yr,new yd(e,t,n)),this.disconnect=()=>{oe(this,xr)||(st(this,xr,!0),s(),i(),oe(this,yr).disconnect())}}};yr=new WeakMap;xr=new WeakMap;Cs=new WeakMap;oo=new WeakMap;function ao(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function Ln(e){try{ao(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function Ya(e){return!ud||!e?!1:e===tr(e).scrollingElement}function xd(e){var t,n;const r=ot(e),s=Ya(e)?eh(e):ci(e),i=r.visualViewport,o=Ya(e)?{height:(t=i?.height)!=null?t:r.innerHeight,width:(n=i?.width)!=null?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-o.width,y:e.scrollHeight-o.height}},l=a.current.y<=0,u=a.current.x<=0,c=a.current.y>=a.max.y,d=a.current.x>=a.max.x;return{rect:s,position:a,isTop:l,isLeft:u,isBottom:c,isRight:d}}function mh(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:i,position:o}=xd(e),{x:a,y:l}=t??{x:0,y:0},u=!n&&o.current.y+l>0,c=!r&&o.current.y+l<o.max.y,d=!s&&o.current.x+a>0,f=!i&&o.current.x+a<o.max.x;return{top:u,bottom:c,left:d,right:f,x:d||f,y:u||c}}var ha=class{constructor(t){this.scheduler=t,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:n,resolvers:r}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const s of n)s();for(const s of r)s()}}schedule(t){return this.tasks.add(t),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(n=>this.resolvers.add(n))}},Gs=new ha(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),vh=new ha(e=>setTimeout(e,50)),Us=new Map,bh=Us.clear.bind(Us);function Ot(e,t=!1){if(!t)return Xa(e);let n=Us.get(e);return n||(n=Xa(e),Us.set(e,n),vh.schedule(bh),n)}function Xa(e){return ot(e).getComputedStyle(e)}function yh(e,t=Ot(e,!0)){return t.position==="fixed"||t.position==="sticky"}function xh(e,t=Ot(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const i=t[s];return typeof i=="string"?n.test(i):!1})}var wh={excludeElement:!0,escapeShadowDOM:!0};function lo(e,t=wh){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,i=new Set;function o(a){if(n!=null&&i.size>=n||!a)return i;if(ca(a)&&a.scrollingElement!=null&&!i.has(a.scrollingElement))return i.add(a.scrollingElement),i;if(s&&ua(a))return o(a.host);if(!Yt(a))return dd(a)?o(a.parentElement):i;if(i.has(a))return i;const l=Ot(a,!0);if(r&&a===e||xh(a,l)&&i.add(a),yh(a,l)){const{scrollingElement:u}=a.ownerDocument;return u&&i.add(u),i}return o(a.parentNode)}return e?o(e):i}function Gn(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=qn(e);for(;r;){if(r===t)return n;const s=ci(r),{x:i,y:o}=kh(r,s);n.x=n.x+s.left,n.y=n.y+s.top,n.scaleX=n.scaleX*i,n.scaleY=n.scaleY*o,r=qn(r)}return n}function kh(e,t=ci(e)){const n=Math.round(t.width),r=Math.round(t.height);if(Yt(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const s=Ot(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function _h(e){if(!e||e==="none")return null;const t=e.split(" "),n=parseFloat(t[0]),r=parseFloat(t[1]);return isNaN(n)&&isNaN(r)?null:{x:isNaN(n)?r:n,y:isNaN(r)?n:r}}function Nr(e){if(!e||e==="none")return null;const[t,n,r="0"]=e.split(" "),s={x:parseFloat(t),y:parseFloat(n),z:parseInt(r,10)};return isNaN(s.x)&&isNaN(s.y)?null:{x:isNaN(s.x)?0:s.x,y:isNaN(s.y)?0:s.y,z:isNaN(s.z)?0:s.z}}function di(e){var t,n,r,s,i,o,a,l,u;const{scale:c,transform:d,translate:f}=e,p=_h(c),m=Nr(f),g=Sh(d);if(!g&&!p&&!m)return null;const x={x:(t=p?.x)!=null?t:1,y:(n=p?.y)!=null?n:1},k={x:(r=m?.x)!=null?r:0,y:(s=m?.y)!=null?s:0},b={x:(i=g?.x)!=null?i:0,y:(o=g?.y)!=null?o:0,scaleX:(a=g?.scaleX)!=null?a:1,scaleY:(l=g?.scaleY)!=null?l:1};return{x:k.x+b.x,y:k.y+b.y,z:(u=m?.z)!=null?u:0,scaleX:x.x*b.scaleX,scaleY:x.y*b.scaleY}}function Sh(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var ut=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(ut||{}),$h={x:.2,y:.2},Th={x:10,y:10};function Oh(e,t,n,r=25,s=$h,i=Th){const{x:o,y:a}=t,{rect:l,isTop:u,isBottom:c,isLeft:d,isRight:f}=xd(e),p=Gn(e),m=Ot(e,!0),g=di(m),x=g!==null?g?.scaleX<0:!1,k=g!==null?g?.scaleY<0:!1,b=new St(l.left*p.scaleX+p.x,l.top*p.scaleY+p.y,l.width*p.scaleX,l.height*p.scaleY),h={x:0,y:0},y={x:0,y:0},w={height:b.height*s.y,width:b.width*s.x};return w.height>0&&(!u||k&&!c)&&a<=b.top+w.height&&n?.y!==1&&o>=b.left-i.x&&o<=b.right+i.x?(h.y=k?1:-1,y.y=r*Math.abs((b.top+w.height-a)/w.height)):w.height>0&&(!c||k&&!u)&&a>=b.bottom-w.height&&n?.y!==-1&&o>=b.left-i.x&&o<=b.right+i.x&&(h.y=k?-1:1,y.y=r*Math.abs((b.bottom-w.height-a)/w.height)),w.width>0&&(!f||x&&!d)&&o>=b.right-w.width&&n?.x!==-1&&a>=b.top-i.y&&a<=b.bottom+i.y?(h.x=x?-1:1,y.x=r*Math.abs((b.right-w.width-o)/w.width)):w.width>0&&(!d||x&&!f)&&o<=b.left+w.width&&n?.x!==1&&a>=b.top-i.y&&a<=b.bottom+i.y&&(h.x=x?1:-1,y.x=r*Math.abs((b.left+w.width-o)/w.width)),{direction:h,speed:y}}function wd(e,{block:t="nearest",inline:n="nearest"}={}){if(!Yt(e))return;const r=lo(e),s=[];for(const i of r){if(!Yt(i))continue;const{top:o,left:a}=Eh(e,i);let l=o,u=a;for(const c of s)l-=c.scrollTop,u-=c.scrollLeft;if(t!=="none"){const c=l<i.scrollTop,d=l+e.offsetHeight>i.scrollTop+i.clientHeight;c!==d&&(t==="center"?i.scrollTop=l-i.clientHeight/2+e.offsetHeight/2:c?i.scrollTop=l:i.scrollTop=l+e.offsetHeight-i.clientHeight)}if(n!=="none"){const c=u<i.scrollLeft,d=u+e.offsetWidth>i.scrollLeft+i.clientWidth;c!==d&&(n==="center"?i.scrollLeft=u-i.clientWidth/2+e.offsetWidth/2:c?i.scrollLeft=u:i.scrollLeft=u+e.offsetWidth-i.clientWidth)}s.push(i)}}function Za(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const s=r.offsetParent;if(!Yt(s))break;t+=s.clientTop,n+=s.clientLeft,r=s}return{top:t,left:n}}function Eh(e,t){const n=Za(e),r=Za(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function Ch(e,t,n){const{scaleX:r,scaleY:s,x:i,y:o}=t,a=e.left+i+(1-r)*parseFloat(n),l=e.top+o+(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),u=r?e.width*r:e.width,c=s?e.height*s:e.height;return{width:u,height:c,top:l,right:a+u,bottom:l+c,left:a}}function Ih(e,t,n){const{scaleX:r,scaleY:s,x:i,y:o}=t,a=e.left-i-(1-r)*parseFloat(n),l=e.top-o-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),u=r?e.width/r:e.width,c=s?e.height/s:e.height;return{width:u,height:c,top:l,right:a+u,bottom:l+c,left:a}}function kd({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function Qa(e,t=Ot(e).translate,n=!0){if(n){const r=cd(e,s=>"translate"in s);if(r){const{translate:s=""}=r[0];if(typeof s=="string"){const i=Nr(s);if(i)return i}}}if(t){const r=Nr(t);if(r)return r}return{x:0,y:0,z:0}}var Dh=new ha(e=>setTimeout(e,0)),Dr=new Map,Ah=Dr.clear.bind(Dr);function jh(e){const t=e.ownerDocument;let n=Dr.get(t);if(n)return n;n=t.getAnimations(),Dr.set(t,n),Dh.schedule(Ah);const r=n.filter(s=>li(s.effect)&&s.effect.target===e);return Dr.set(e,r),n}function Ph(e,t){const n=jh(e).filter(r=>{var s,i;if(li(r.effect)){const{target:o}=r.effect;if((i=o&&((s=t.isValidTarget)==null?void 0:s.call(t,o)))!=null?i:!0)return r.effect.getKeyframes().some(l=>{for(const u of t.properties)if(l[u])return!0})}}).map(r=>{const{effect:s,currentTime:i}=r,o=s?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof o=="number"&&typeof i=="number"&&i<o)return r.currentTime=o,()=>{r.currentTime=i}});if(n.length>0)return()=>n.forEach(r=>r?.())}var _t=class extends St{constructor(e,t={}){var n,r,s,i;const{frameTransform:o=Gn(e),ignoreTransforms:a,getBoundingClientRect:l=ci}=t,u=Ph(e,{properties:["transform","translate","scale","width","height"],isValidTarget:w=>(w!==e||da())&&w.contains(e)}),c=l(e);let{top:d,left:f,width:p,height:m}=c,g;const x=Ot(e),k=di(x),b={x:(n=k?.scaleX)!=null?n:1,y:(r=k?.scaleY)!=null?r:1},h=Mh(e,x);u?.(),k&&(g=Ih(c,k,x.transformOrigin),(a||h)&&(d=g.top,f=g.left,p=g.width,m=g.height));const y={width:(s=g?.width)!=null?s:p,height:(i=g?.height)!=null?i:m};if(h&&!a&&g){const w=Ch(g,h,x.transformOrigin);d=w.top,f=w.left,p=w.width,m=w.height,b.x=h.scaleX,b.y=h.scaleY}o&&(a||(f*=o.scaleX,p*=o.scaleX,d*=o.scaleY,m*=o.scaleY),f+=o.x,d+=o.y),super(f,d,p,m),this.scale=b,this.intrinsicWidth=y.width,this.intrinsicHeight=y.height}};function Mh(e,t){const n=e.getAnimations();if(!n.length)return null;let r,s,i,o=!1;for(const a of n){if(a.playState!=="running")continue;const l=li(a.effect)?a.effect.getKeyframes():[],u=l[l.length-1];if(!u)continue;const{transform:c,translate:d,scale:f}=u;typeof c=="string"&&c&&(r=c,o=!0),typeof d=="string"&&d&&(s=d,o=!0),typeof f=="string"&&f&&(i=f,o=!0)}return o?di({transform:r??t.transform,translate:s??t.translate,scale:i??t.scale}):null}function Ar(e){return"style"in e&&typeof e.style=="object"&&e.style!==null&&"setProperty"in e.style&&"removeProperty"in e.style&&typeof e.style.setProperty=="function"&&typeof e.style.removeProperty=="function"}var Rh=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(Ar(n))for(const[r,s]of Object.entries(e)){const i=`${t}${r}`;this.initial.has(i)||this.initial.set(i,n.style.getPropertyValue(i)),n.style.setProperty(i,typeof s=="string"?s:`${s}px`)}}remove(e,t=""){const{element:n}=this;if(Ar(n))for(const r of e){const s=`${t}${r}`;n.style.removeProperty(s)}}reset(){const{element:e}=this;if(Ar(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function gn(e){return e?e instanceof ot(e).Element||Jr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function Fr(e){if(!e)return!1;const{KeyboardEvent:t}=ot(e.target);return e instanceof t}function Lh(e){if(!e)return!1;const{PointerEvent:t}=ot(e.target);return e instanceof t}function Nh(e){if(!gn(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||Fh(e)}function Fh(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var Si={};function co(e){const t=Si[e]==null?0:Si[e]+1;return Si[e]=t,`${e}-${t}`}var pa=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const s=dt.distance(t.shape.center,n);return{id:r,value:1/s,type:er.PointerIntersection,priority:Jn.High}}return null},zh=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:s}=e,i=dt.distance(t.shape.center,s.current),a=r/(n.current.area+t.shape.area-r)/i;return{id:t.id,value:a,type:er.ShapeIntersection,priority:Jn.Normal}}return null},_d=e=>{var t;return(t=pa(e))!=null?t:zh(e)},Wh=e=>{const{dragOperation:t,droppable:n}=e,{shape:r,position:s}=t;if(!n.shape)return null;const i=r?St.from(r.current.boundingRectangle).corners:void 0,a=St.from(n.shape.boundingRectangle).corners.reduce((l,u,c)=>{var d;return l+dt.distance(dt.from(u),(d=i?.[c])!=null?d:s.current)},0)/4;return{id:n.id,value:1/a,type:er.Collision,priority:Jn.Normal}},Bh=Object.create,ga=Object.defineProperty,qh=Object.defineProperties,Gh=Object.getOwnPropertyDescriptor,Uh=Object.getOwnPropertyDescriptors,Vs=Object.getOwnPropertySymbols,Sd=Object.prototype.hasOwnProperty,$d=Object.prototype.propertyIsEnumerable,Td=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),nr=e=>{throw TypeError(e)},uo=(e,t,n)=>t in e?ga(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zr=(e,t)=>{for(var n in t||(t={}))Sd.call(t,n)&&uo(e,n,t[n]);if(Vs)for(var n of Vs(t))$d.call(t,n)&&uo(e,n,t[n]);return e},ma=(e,t)=>qh(e,Uh(t)),Ja=(e,t)=>ga(e,"name",{value:t,configurable:!0}),Od=(e,t)=>{var n={};for(var r in e)Sd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Vs)for(var r of Vs(e))t.indexOf(r)<0&&$d.call(e,r)&&(n[r]=e[r]);return n},rr=e=>{var t;return[,,,Bh((t=e?.[Td("metadata")])!=null?t:null)]},Ed=["class","method","getter","setter","accessor","field","value","get","set"],wr=e=>e!==void 0&&typeof e!="function"?nr("Function expected"):e,Vh=(e,t,n,r,s)=>({kind:Ed[e],name:t,metadata:r,addInitializer:i=>n._?nr("Already initialized"):s.push(wr(i||null))}),wn=(e,t)=>uo(t,Td("metadata"),e[3]),ze=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},gt=(e,t,n,r,s,i)=>{var o,a,l,u,c,d=t&7,f=!!(t&8),p=!!(t&16),m=d>3?e.length+1:d?f?1:2:0,g=Ed[d+5],x=d>3&&(e[m-1]=[]),k=e[m]||(e[m]=[]),b=d&&(!p&&!f&&(s=s.prototype),d<5&&(d>3||!p)&&Gh(d<4?s:{get[n](){return ke(this,i)},set[n](y){return et(this,i,y)}},n));d?p&&d<4&&Ja(i,(d>2?"set ":d>1?"get ":"")+n):Ja(s,n);for(var h=r.length-1;h>=0;h--)u=Vh(d,n,l={},e[3],k),d&&(u.static=f,u.private=p,c=u.access={has:p?y=>Kh(s,y):y=>n in y},d^3&&(c.get=p?y=>(d^1?ke:mn)(y,s,d^4?i:b.get):y=>y[n]),d>2&&(c.set=p?(y,w)=>et(y,s,w,d^4?i:b.set):(y,w)=>y[n]=w)),a=(0,r[h])(d?d<4?p?i:b[g]:d>4?void 0:{get:b.get,set:b.set}:s,u),l._=1,d^4||a===void 0?wr(a)&&(d>4?x.unshift(a):d?p?i=a:b[g]=a:s=a):typeof a!="object"||a===null?nr("Object expected"):(wr(o=a.get)&&(b.get=o),wr(o=a.set)&&(b.set=o),wr(o=a.init)&&x.unshift(o));return d||wn(e,s),b&&ga(s,n,b),p?d^4?i:b:s},va=(e,t,n)=>t.has(e)||nr("Cannot "+n),Kh=(e,t)=>Object(t)!==t?nr('Cannot use the "in" operator on this value'):e.has(t),ke=(e,t,n)=>(va(e,t,"read from private field"),n?n.call(e):t.get(e)),Me=(e,t,n)=>t.has(e)?nr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),et=(e,t,n,r)=>(va(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),mn=(e,t,n)=>(va(e,t,"access private method"),n),el={role:"button",roleDescription:"draggable"},Hh="dnd-kit-description",Yh="dnd-kit-announcement",Xh={draggable:"To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item in a given direction. Press space again to drop the item in its new position, or press escape to cancel."},Zh={dragstart({operation:{source:e}}){if(e)return`Picked up draggable item ${e.id}.`},dragover({operation:{source:e,target:t}}){if(!(!e||e.id===t?.id))return t?`Draggable item ${e.id} was moved over droppable target ${t.id}.`:`Draggable item ${e.id} is no longer over a droppable target.`},dragend({operation:{source:e,target:t},canceled:n}){if(e)return n?`Dragging was cancelled. Draggable item ${e.id} was dropped.`:t?`Draggable item ${e.id} was dropped over droppable target ${t.id}`:`Draggable item ${e.id} was dropped.`}};function Qh(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function Jh(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function ep(e){const t=document.createElement("div");return t.id=e,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.style.setProperty("position","fixed"),t.style.setProperty("width","1px"),t.style.setProperty("height","1px"),t.style.setProperty("margin","-1px"),t.style.setProperty("border","0"),t.style.setProperty("padding","0"),t.style.setProperty("overflow","hidden"),t.style.setProperty("clip","rect(0 0 0 0)"),t.style.setProperty("clip-path","inset(100%)"),t.style.setProperty("white-space","nowrap"),t}var tp=["dragover","dragmove"],np=class extends Ze{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=Hh,announcement:s=Yh}={},announcements:i=Zh,screenReaderInstructions:o=Xh,debounce:a=500}=t??{},l=n?`${r}-${n}`:co(r),u=n?`${s}-${n}`:co(s);let c,d,f,p;const m=(w=p)=>{!f||!w||f?.nodeValue!==w&&(f.nodeValue=w)},g=()=>Gs.schedule(m),x=rp(g,a),k=Object.entries(i).map(([w,D])=>this.manager.monitor.addEventListener(w,(T,A)=>{const I=f;if(!I)return;const C=D?.(T,A);C&&I.nodeValue!==C&&(p=C,tp.includes(w)?x():(g(),x.cancel()))})),b=()=>{let w=[];c?.isConnected||(c=Jh(l,o.draggable),w.push(c)),d?.isConnected||(d=ep(u),f=document.createTextNode(""),d.appendChild(f),w.push(d)),w.length>0&&document.body.append(...w)},h=new Set;function y(){for(const w of h)w()}this.registerEffect(()=>{var w;h.clear();for(const D of this.manager.registry.draggables.value){const T=(w=D.handle)!=null?w:D.element;if(T){(!c||!d)&&h.add(b),(!Qh(T)||da())&&!T.hasAttribute("tabindex")&&h.add(()=>T.setAttribute("tabindex","0")),!T.hasAttribute("role")&&T.tagName.toLowerCase()!=="button"&&h.add(()=>T.setAttribute("role",el.role)),T.hasAttribute("aria-roledescription")||h.add(()=>T.setAttribute("aria-roledescription",el.roleDescription)),T.hasAttribute("aria-describedby")||h.add(()=>T.setAttribute("aria-describedby",l));for(const I of["aria-pressed","aria-grabbed"]){const C=String(D.isDragging);T.getAttribute(I)!==C&&h.add(()=>T.setAttribute(I,C))}const A=String(D.disabled);T.getAttribute("aria-disabled")!==A&&h.add(()=>T.setAttribute("aria-disabled",A))}}h.size>0&&Gs.schedule(y)}),this.destroy=()=>{super.destroy(),c?.remove(),d?.remove(),k.forEach(w=>w())}}};function rp(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var Ks=new Map,Cd,Id,Dd,Ad,fo,jr,Mt,ba,Un,jd,Pd,Md,Rd,Xt=class extends(fo=Qr,Ad=[pe],Dd=[Pe],Id=[Pe],Cd=[Pe],fo){constructor(t,n){super(t,n),ze(Mt,5,this),Me(this,Un),Me(this,jr,new Set),Me(this,ba,ze(Mt,8,this,new Set)),ze(Mt,11,this),this.registerEffect(mn(this,Un,jd))}register(t){return ke(this,jr).add(t),()=>{ke(this,jr).delete(t)}}addRoot(t){return he(()=>{const n=new Set(this.additionalRoots);n.add(t),this.additionalRoots=n}),()=>{he(()=>{const n=new Set(this.additionalRoots);n.delete(t),this.additionalRoots=n})}}get sourceRoot(){var t;const{source:n}=this.manager.dragOperation;return Ws((t=n?.element)!=null?t:null)}get targetRoot(){var t;const{target:n}=this.manager.dragOperation;return Ws((t=n?.element)!=null?t:null)}get roots(){const{status:t}=this.manager.dragOperation;if(t.initializing||t.initialized){const n=[this.sourceRoot,this.targetRoot].filter(r=>r!=null);return new Set([...n,...this.additionalRoots])}return new Set}};Mt=rr(fo);jr=new WeakMap;ba=new WeakMap;Un=new WeakSet;jd=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of ke(this,jr))t.push(mn(this,Un,Pd).call(this,n,r));return()=>{for(const n of t)n()}};Pd=function(e,t){let n=Ks.get(e);n||(n=new Map,Ks.set(e,n));let r=n.get(t);if(!r){const i=ca(e)?mn(this,Un,Md).call(this,e,n,t):mn(this,Un,Rd).call(this,e,n,t);if(!i)return()=>{};r=i,n.set(t,r)}r.refCount++;let s=!1;return()=>{s||(s=!0,r.refCount--,r.refCount===0&&r.cleanup())}};Md=function(e,t,n){var r;const s=e.createElement("style"),{nonce:i}=(r=this.options)!=null?r:{};i&&s.setAttribute("nonce",i),s.textContent=n,e.head.prepend(s);const o=new MutationObserver(a=>{for(const l of a)for(const u of Array.from(l.removedNodes))if(u===s){e.head.prepend(s);return}});return o.observe(e.head,{childList:!0}),{refCount:0,cleanup:()=>{o.disconnect(),s.remove(),t.delete(n),t.size===0&&Ks.delete(e)}}};Rd=function(e,t,n){"adoptedStyleSheets"in e&&Array.isArray(e.adoptedStyleSheets);const r=e.ownerDocument.defaultView,{CSSStyleSheet:s}=r??{};if(!s)return null;const i=new s;return i.replaceSync(n),e.adoptedStyleSheets.push(i),{refCount:0,cleanup:()=>{var o;if(ua(e)&&((o=e.host)!=null&&o.isConnected)){const a=e.adoptedStyleSheets.indexOf(i);a!==-1&&e.adoptedStyleSheets.splice(a,1)}t.delete(n),t.size===0&&Ks.delete(e)}}};gt(Mt,4,"additionalRoots",Ad,Xt,ba);gt(Mt,2,"sourceRoot",Dd,Xt);gt(Mt,2,"targetRoot",Id,Xt);gt(Mt,2,"roots",Cd,Xt);wn(Mt,Xt);Xt.configure=Zr(Xt);var ui=Xt,sp=class extends Ze{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(ui),s=r?.register(`* { cursor: ${n} !important; }`);if(s){const i=this.destroy.bind(this);this.destroy=()=>{s(),i()}}}},es="data-dnd-",ho=`${es}dropping`,Ve="--dnd-",kt=`${es}dragging`,Hs=`${es}placeholder`,ip=[kt,Hs,"popover","aria-pressed","aria-grabbing"],op=["view-transition-name"],ap=`
|
|
9
|
+
:is(:root,:host) [${kt}] {
|
|
10
10
|
position: fixed !important;
|
|
11
11
|
pointer-events: none !important;
|
|
12
12
|
touch-action: none;
|
|
13
13
|
z-index: calc(infinity);
|
|
14
14
|
will-change: translate;
|
|
15
|
-
top: var(${
|
|
16
|
-
left: var(${
|
|
15
|
+
top: var(${Ve}top, 0px) !important;
|
|
16
|
+
left: var(${Ve}left, 0px) !important;
|
|
17
17
|
right: unset !important;
|
|
18
18
|
bottom: unset !important;
|
|
19
|
-
width: var(${
|
|
20
|
-
max-width: var(${
|
|
21
|
-
height: var(${
|
|
22
|
-
max-height: var(${
|
|
23
|
-
transform: var(${
|
|
24
|
-
transition: var(${
|
|
19
|
+
width: var(${Ve}width, auto);
|
|
20
|
+
max-width: var(${Ve}width, auto);
|
|
21
|
+
height: var(${Ve}height, auto);
|
|
22
|
+
max-height: var(${Ve}height, auto);
|
|
23
|
+
transform: var(${Ve}transform, none) !important;
|
|
24
|
+
transition: var(${Ve}transition) !important;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
:is(:root,:host) [${
|
|
27
|
+
:is(:root,:host) [${Hs}] {
|
|
28
28
|
transition: none;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
:is(:root,:host) [${
|
|
31
|
+
:is(:root,:host) [${Hs}='hidden'] {
|
|
32
32
|
visibility: hidden;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
[${
|
|
35
|
+
[${kt}] * {
|
|
36
36
|
pointer-events: none !important;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
[${
|
|
40
|
-
translate: var(${
|
|
39
|
+
[${kt}]:not([${ho}]) {
|
|
40
|
+
translate: var(${Ve}translate) !important;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
[${
|
|
44
|
-
scale: var(${
|
|
45
|
-
transform-origin: var(${
|
|
43
|
+
[${kt}][style*='${Ve}scale'] {
|
|
44
|
+
scale: var(${Ve}scale) !important;
|
|
45
|
+
transform-origin: var(${Ve}transform-origin) !important;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
@layer dnd-kit {
|
|
49
|
-
:where([${
|
|
49
|
+
:where([${kt}][popover]) {
|
|
50
50
|
overflow: visible;
|
|
51
51
|
background: unset;
|
|
52
52
|
border: unset;
|
|
@@ -60,51 +60,139 @@
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
[${
|
|
63
|
+
[${kt}]::backdrop, [${es}overlay]:not([${kt}]) {
|
|
64
64
|
display: none;
|
|
65
65
|
visibility: hidden;
|
|
66
66
|
}
|
|
67
|
-
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function uh(e,t="hidden"){return H(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const i=fh(n,r.registry.droppables),s=[],o=of(n),{remove:a}=o;return hh(i,o,s),ph(o,t),o.remove=()=>{s.forEach(l=>l()),a.call(o)},o})}function fh(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const i=`${Cr}${Ps("dom-id")}`;r.element.setAttribute(i,""),n.set(r,i)}return n}function hh(e,t,n){for(const[r,i]of e){if(!r.element)continue;const s=`[${i}]`,o=t.matches(s)?t:t.querySelector(s);if(r.element.removeAttribute(i),!o)continue;const a=r.element;r.proxy=o,o.removeAttribute(i),Os.set(a,o),n.push(()=>{Os.delete(a),r.proxy=void 0})}}function ph(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(wi,t)}function Kc(e,t){return e===t?!0:wn(e)===wn(t)}function $a(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&Vt(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>vn(t))}function As(e){return e.tagName==="TR"}function gh(e,t,n){const r=new MutationObserver(i=>{let s=!1;for(const o of i){if(o.target!==e){s=!0;continue}if(o.type!=="attributes")continue;const a=o.attributeName;if(a.startsWith("aria-")||lh.includes(a))continue;const l=e.getAttribute(a);if(a==="style"){if(fr(e)&&fr(t)){const u=e.style;for(const d of Array.from(t.style))u.getPropertyValue(d)===""&&t.style.removeProperty(d);for(const d of Array.from(u)){if(ch.includes(d)||d.startsWith(Te))continue;const c=u.getPropertyValue(d);t.style.setProperty(d,c)}}}else l!==null?t.setAttribute(a,l):t.removeAttribute(a)}s&&n&&t.replaceChildren(...e.cloneNode(!0).childNodes)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function vh(e,t,n){const r=new MutationObserver(i=>{for(const s of i)if(s.addedNodes.length!==0)for(const o of Array.from(s.addedNodes)){if(o.contains(e)&&e.nextElementSibling!==t){e.insertAdjacentElement("afterend",t),vn(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),vn(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement("afterend",t),vn(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function mh(e){return new ResizeObserver(()=>{var t,n,r;const i=new ct(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},o=(e.width-i.width)*s.x+e.delta.x,a=(e.height-i.height)*s.y+e.delta.y,l=kc();if(e.styles.set({width:i.width-e.widthOffset,height:i.height-e.heightOffset,top:e.top+a+l.y,left:e.left+o+l.x},Te),(n=e.getElementMutationObserver())==null||n.takeRecords(),As(e.element)&&As(e.placeholder)){const p=Array.from(e.element.cells),w=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(p.map(x=>x.style.width));for(const[x,m]of p.entries()){const g=w[x];m.style.width=`${g.getBoundingClientRect().width}px`}}const u=(r=e.getTranslate())!=null?r:{x:0,y:0},d=e.left+o+l.x+u.x,c=e.top+a+l.y+u.y,h=i.width-e.widthOffset,f=i.height-e.heightOffset,v=e.frameTransform;e.dragOperation.shape=new dt(d*v.scaleX+v.x,c*v.scaleY+v.y,h*v.scaleX,f*v.scaleY)})}var yh=250,bh="ease";function xh(e){var t,n,r,i;const{animation:s}=e;if(typeof s=="function"){const m=s({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(m).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=yh,easing:a=bh}=s??{};vn(e.feedbackElement);const[,l]=(t=xc(e.feedbackElement,m=>"translate"in m))!=null?t:[];l?.pause();const u=(n=e.placeholder)!=null?n:e.element,d={frameTransform:Kc(e.feedbackElement,u)?null:void 0},c=new ct(e.feedbackElement,d),h=(r=yr(ht(e.feedbackElement).translate))!=null?r:e.translate,f=new ct(u,d),v=dt.delta(c,f,e.alignment),p={x:h.x-v.x,y:h.y-v.y},w=Math.round(c.intrinsicHeight)!==Math.round(f.intrinsicHeight)?{minHeight:[`${c.intrinsicHeight}px`,`${f.intrinsicHeight}px`],maxHeight:[`${c.intrinsicHeight}px`,`${f.intrinsicHeight}px`]}:{},x=Math.round(c.intrinsicWidth)!==Math.round(f.intrinsicWidth)?{minWidth:[`${c.intrinsicWidth}px`,`${f.intrinsicWidth}px`],maxWidth:[`${c.intrinsicWidth}px`,`${f.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Te),e.feedbackElement.setAttribute(js,""),(i=e.getElementMutationObserver())==null||i.takeRecords(),Ic({element:e.feedbackElement,keyframes:Fo(xr(xr({},w),x),{translate:[`${h.x}px ${h.y}px 0`,`${p.x}px ${p.y}px 0`]}),options:{duration:Ro(Ke(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(js),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Yc,Rs,wr,Vo,ii,Xc,Qc,Sn=class extends(Rs=Me,Yc=[K],Rs){constructor(t,n){super(t,n),ve(this,ii),ve(this,Vo,we(wr,8,this)),we(wr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(Wi),i=r?.register(dh);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}this.registerEffect(Gt(this,ii,Xc).bind(this,r)),this.registerEffect(Gt(this,ii,Qc))}};wr=Rn(Rs);Vo=new WeakMap;ii=new WeakSet;Xc=function(e){const{overlay:t}=this;if(!t||!e)return;const n=pi(t);if(n)return e.addRoot(n)};Qc=function(){var e,t,n,r,i,s,o;const{state:a,manager:l,options:u}=this,{dragOperation:d}=l,{position:c,source:h,status:f}=d;if(f.idle){a.current={},a.initial={};return}if(!h)return;const{element:v}=h,p=h.pluginConfig(Sn),w=(t=(e=p?.feedback)!=null?e:u?.feedback)!=null?t:"default",x=typeof w=="function"?w(h,l):w;if(!v||x==="none"||!f.initialized||f.initializing)return;const{initial:m}=a,g=(n=this.overlay)!=null?n:v,b=_n(g),_=_n(v),$=!Kc(v,g),O=new ct(v,{frameTransform:$?_:null,ignoreTransforms:!$}),C={x:_.scaleX/b.scaleX,y:_.scaleY/b.scaleY};let{width:I,height:P,top:U,left:W}=O;$&&(I=I/C.x,P=P/C.y);const M=new zf(g),z=ht(v),{transition:V,translate:ee,boxSizing:Se,paddingBlockStart:oe,paddingBlockEnd:Le,paddingInlineStart:Ve,paddingInlineEnd:Ce,borderInlineStartWidth:Ye,borderInlineEndWidth:Ge,borderBlockStartWidth:We,borderBlockEndWidth:Xe}=z,$e=V.split(",").filter(Z=>!/^\s*(transform|translate|scale)\b/.test(Z)).join(","),fe=Li(z),L=z.transform,G=x==="clone",_e=Se==="content-box",X=_e?parseInt(Ve)+parseInt(Ce)+parseInt(Ye)+parseInt(Ge):0,ze=_e?parseInt(oe)+parseInt(Le)+parseInt(We)+parseInt(Xe):0,ne=x!=="move"&&!this.overlay?uh(h,G?"clone":"hidden"):null,at=H(()=>br(l.dragOperation.activatorEvent));if(!m.translate){if(this.overlay&&fe)m.translate={x:fe.x,y:fe.y};else if(ee!=="none"){const Z=yr(ee);Z&&(m.translate=Z)}}if(!m.transformOrigin){const Z=H(()=>c.current),R=W+((r=fe?.x)!=null?r:0),te=U+((i=fe?.y)!=null?i:0);m.transformOrigin={x:(Z.x-R*b.scaleX-b.x)/(I*b.scaleX),y:(Z.y-te*b.scaleY-b.y)/(P*b.scaleY)}}const{transformOrigin:Fe}=m,xt=U*b.scaleY+b.y,T=W*b.scaleX+b.x;if(!m.coordinates&&(m.coordinates={x:T,y:xt},C.x!==1||C.y!==1)){const{scaleX:Z,scaleY:R}=_,{x:te,y:Oe}=Fe;m.coordinates.x+=(I*Z-I)*te,m.coordinates.y+=(P*R-P)*Oe}m.dimensions||(m.dimensions={width:I,height:P}),m.frameTransform||(m.frameTransform=b);const A={x:m.coordinates.x-T,y:m.coordinates.y-xt},q={width:(m.dimensions.width*m.frameTransform.scaleX-I*b.scaleX)*Fe.x,height:(m.dimensions.height*m.frameTransform.scaleY-P*b.scaleY)*Fe.y},E={x:A.x/b.scaleX+q.width,y:A.y/b.scaleY+q.height},D={left:W+E.x,top:U+E.y};g.setAttribute(lt,"true");const B=H(()=>d.transform),Q=(s=m.translate)!=null?s:{x:0,y:0},Ue=B.x*b.scaleX+Q.x,ke=B.y*b.scaleY+Q.y,se=kc();M.set({width:I-X,height:P-ze,top:D.top+se.y,left:D.left+se.x,translate:`${Ue}px ${ke}px 0`,transform:this.overlay?"none":L,transition:$e?`${$e}, translate 0ms linear`:"translate 0ms linear",scale:$?`${C.x} ${C.y}`:"","transform-origin":`${Fe.x*100}% ${Fe.y*100}%`},Te),ne&&(v.insertAdjacentElement("afterend",ne),u?.rootElement&&(typeof u.rootElement=="function"?u.rootElement(h):u.rootElement).appendChild(v)),Ds(g)&&(g.hasAttribute("popover")||g.setAttribute("popover","manual"),vn(g),g.addEventListener("beforetoggle",$a));let Ee,Qt,Ct;const Rr=mh({placeholder:ne,element:v,feedbackElement:g,frameTransform:b,transformOrigin:Fe,width:I,height:P,top:U,left:W,widthOffset:X,heightOffset:ze,delta:E,styles:M,dragOperation:d,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>Ee,getSavedCellWidths:()=>Ct,setSavedCellWidths:Z=>{Ct=Z}}),Pt=new ct(g);H(()=>d.shape=Pt);const Zt=Ke(g),Wn=Z=>{this.manager.actions.stop({event:Z})},ra=Ro(Zt);at&&Zt.addEventListener("resize",Wn),H(()=>h.status)==="idle"&&requestAnimationFrame(()=>h.status="dragging"),ne&&(Rr.observe(ne),Ee=gh(v,ne,G),Qt=vh(v,ne,g));const Lr=(o=l.dragOperation.source)==null?void 0:o.id,zn=()=>{var Z;if(!at||Lr==null)return;const R=l.registry.draggables.get(Lr),te=(Z=R?.handle)!=null?Z:R?.element;Tt(te)&&te.focus()},Fn=()=>{Ee?.disconnect(),Qt?.disconnect(),Rr.disconnect(),Zt.removeEventListener("resize",Wn),Ds(g)&&(g.removeEventListener("beforetoggle",$a),g.removeAttribute("popover")),g.removeAttribute(lt),M.reset();const Z=()=>{var R;if(Ct&&As(v)){const he=Array.from(v.cells);for(const[ae,Jt]of he.entries())Jt.style.width=(R=Ct[ae])!=null?R:""}h.status="idle";const te=a.current.translate!=null,Oe=d.status.dragging;ne&&(!Oe&&te||ne.parentElement!==g.parentElement)&&g.isConnected&&ne.replaceWith(g),ne?.remove()};g===this.overlay?setTimeout(Z,0):Z()},Gi=u?.dropAnimation,Nn=this,Ui=$r(()=>{var Z,R,te;const{transform:Oe,status:he}=d;if(!(!Oe.x&&!Oe.y&&!a.current.translate)&&he.dragging){const ae=(Z=m.translate)!=null?Z:{x:0,y:0},Jt={x:Oe.x/b.scaleX+ae.x,y:Oe.y/b.scaleY+ae.y},ia=a.current.translate,tu=H(()=>d.modifiers),qi=H(()=>{var Vn;return(Vn=d.shape)==null?void 0:Vn.current}),Bn=u?.keyboardTransition,sa=at&&!ra&&Bn!==null?`${(R=Bn?.duration)!=null?R:250}ms ${(te=Bn?.easing)!=null?te:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(M.set({transition:$e?`${$e}, translate ${sa}`:`translate ${sa}`,translate:`${Jt.x}px ${Jt.y}px 0`},Te),Ee?.takeRecords(),qi&&qi!==Pt&&ia&&!tu.length){const Vn=Ze.delta(Jt,ia);d.shape=dt.from(qi.boundingRectangle).translate(Vn.x*b.scaleX,Vn.y*b.scaleY)}else d.shape=new ct(g);a.current.translate=Jt}},function(){if(d.status.dropped){this.dispose(),h.status="dropping";const Z=p?.dropAnimation!==void 0?p.dropAnimation:Nn.dropAnimation!==void 0?Nn.dropAnimation:Gi;let R=a.current.translate;const te=R!=null;if(!R&&v!==g&&(R={x:0,y:0}),!R||Z===null){Fn();return}l.renderer.rendering.then(()=>{xh({source:h,element:v,feedbackElement:g,placeholder:ne,translate:R,moved:te,transition:V,alignment:h.alignment,styles:M,animation:Z??void 0,getElementMutationObserver:()=>Ee,cleanup:Fn,restoreFocus:zn})})}});return()=>{Fn(),Ui()}};nt(wr,4,"overlay",Yc,Sn,Vo);Xt(wr,Sn);Sn.configure=Or(Sn);var Go=Sn,Gn=!0,wh=!1,Zc,Jc,ed,td,St,Uo,qo;td=(ed=[K],Je.Forward),Jc=(Zc=[K],Je.Reverse);var _r=class{constructor(){ve(this,Uo,we(St,8,this,Gn)),we(St,11,this),ve(this,qo,we(St,12,this,Gn)),we(St,15,this)}isLocked(e){return e===Je.Idle?!1:e==null?this[Je.Forward]===Gn&&this[Je.Reverse]===Gn:this[e]===Gn}unlock(e){e!==Je.Idle&&(this[e]=wh)}};St=Rn(null);Uo=new WeakMap;qo=new WeakMap;nt(St,4,td,ed,_r,Uo);nt(St,4,Jc,Zc,_r,qo);Xt(St,_r);var _h=[Je.Forward,Je.Reverse],Ea=class{constructor(){this.x=new _r,this.y=new _r}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},kh=class extends Me{constructor(e){super(e);const t=En(new Ea);let n=null;this.signal=t,tt(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Ea;return}const{delta:i}=e.dragOperation.position;if(n){const s={x:Oa(i.x,n.x),y:Oa(i.y,n.y)},o=t.peek();ue(()=>{for(const a of Cl)for(const l of _h)s[a]===l&&o[a].unlock(l);t.value=o})}n=i})}get current(){return this.signal.peek()}};function Oa(e,t){return Math.sign(e-t)}var nd,Ls,kr,Ho,_t,Ws,Pr=class extends(Ls=Tr,nd=[K],Ls){constructor(e){super(e),ve(this,Ho,we(kr,8,this,!1)),we(kr,11,this),ve(this,_t),ve(this,Ws,()=>{if(!re(this,_t))return;const{element:s,by:o}=re(this,_t);o.y&&(s.scrollTop+=o.y),o.x&&(s.scrollLeft+=o.x)}),this.scroll=(s,o)=>{var a;if(this.disabled)return!1;const l=this.getScrollableElements();if(!l)return Ae(this,_t,void 0),!1;const{position:u}=this.manager.dragOperation,d=u?.current;if(d){const{by:c}=s??{},h=c?{x:Ta(c.x),y:Ta(c.y)}:void 0,f=h?void 0:this.scrollIntentTracker.current;if(f?.isLocked())return!1;for(const v of l){const p=bf(v,c);if(p.x||p.y){const{speed:w,direction:x}=Cf(v,d,h,o?.acceleration,o?.threshold);if(f)for(const m of Cl)f[m].isLocked(x[m])&&(w[m]=0,x[m]=0);if(x.x||x.y){const{x:m,y:g}=c??x,b=m*w.x,_=g*w.y;if(b||_){const $=(a=re(this,_t))==null?void 0:a.by;if(this.autoScrolling&&$&&($.x&&!b||$.y&&!_))continue;return Ae(this,_t,{element:v,by:{x:b,y:_}}),mi.schedule(re(this,Ws)),!0}}}}}return Ae(this,_t,void 0),!1};let t=null,n=null;const r=hs(()=>{const{position:s,source:o}=e.dragOperation;if(!s)return null;const a=Sc(pi(o?.element),s.current);return a&&(t=a),a??t}),i=hs(()=>{const s=r.value,{documentElement:o}=jn(s);if(!s||s===o){const{target:a}=e.dragOperation,l=a?.element;if(l){const u=Cs(l,{excludeElement:!1});return n=u,u}}if(s){const a=Cs(s,{excludeElement:!1});return this.autoScrolling&&n&&a.size<n?.size?n:(n=a,a)}return n=null,null},rt);this.getScrollableElements=()=>i.value,this.scrollIntentTracker=new kh(e),this.destroy=e.monitor.addEventListener("dragmove",s=>{this.disabled||s.defaultPrevented||!br(e.dragOperation.activatorEvent)||!s.by||this.scroll({by:s.by})&&s.preventDefault()})}};kr=Rn(Ls);Ho=new WeakMap;_t=new WeakMap;Ws=new WeakMap;nt(kr,4,"autoScrolling",nd,Pr,Ho);Xt(kr,Pr);function Ta(e){return e>0?Je.Forward:e<0?Je.Reverse:Je.Idle}var Sh=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:t,resolvers:n}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const r of t)r();for(const r of n)r()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(t=>this.resolvers.add(t))}},$h=new Sh(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Eh=10,zs=class extends Me{constructor(t,n){super(t,n);const r=t.registry.plugins.get(Pr);if(!r)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=tt(()=>{var i,s,o;if(this.disabled)return;const{position:a,status:l}=t.dragOperation;if(l.dragging){const u={acceleration:(i=this.options)==null?void 0:i.acceleration,threshold:typeof((s=this.options)==null?void 0:s.threshold)=="number"?{x:this.options.threshold,y:this.options.threshold}:(o=this.options)==null?void 0:o.threshold};if(r.scroll(void 0,u)){r.autoScrolling=!0;const c=setInterval(()=>$h.schedule(()=>r.scroll(void 0,u)),Eh);return()=>{clearInterval(c)}}else r.autoScrolling=!1}})}};zs.configure=Or(zs);var rd=zs,Da={capture:!0,passive:!0},nr,Oh=class extends Tr{constructor(e){super(e),ve(this,nr),this.handleScroll=()=>{re(this,nr)==null&&Ae(this,nr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),Ae(this,nr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=tt(()=>{var n,r,i;if(t.status.dragging){const o=(i=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?i:document;return o.addEventListener("scroll",this.handleScroll,Da),()=>{o.removeEventListener("scroll",this.handleScroll,Da)}}})}};nr=new WeakMap;var Th="* { user-select: none !important; -webkit-user-select: none !important; }",Dh=class extends Me{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(Wi),n=t?.register(Th);if(this.destroy=tt(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return es(),document.addEventListener("selectionchange",es,{capture:!0}),()=>{document.removeEventListener("selectionchange",es,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function es(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var rr=Object.freeze({offset:10,keyboardCodes:{start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter","Tab"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},preventActivation(e,t){var n;const r=(n=t.handle)!=null?n:t.element;return e.target!==r}}),dn,_i=class extends bn{constructor(t,n){super(t),this.manager=t,this.options=n,ve(this,dn,[]),this.listeners=new $c,this.handleSourceKeyDown=(r,i,s)=>{if(this.disabled||r.defaultPrevented||!Vt(r.target)||i.disabled)return;const{keyboardCodes:o=rr.keyboardCodes,preventActivation:a=rr.preventActivation}=s??{};o.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(a?.(r,i)||this.handleStart(r,i,s))}}bind(t,n=this.options){return tt(()=>{var i;const s=(i=t.handle)!=null?i:t.element,o=a=>{br(a)&&this.handleSourceKeyDown(a,t,n)};if(s)return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}})}handleStart(t,n,r){const{element:i}=n;if(!i)throw new Error("Source draggable does not have an associated element");t.preventDefault(),t.stopImmediatePropagation(),Mc(i);const{center:s}=new ct(i);if(this.manager.actions.start({event:t,coordinates:{x:s.x,y:s.y},source:n}).signal.aborted)return this.cleanup();this.sideEffects();const a=jn(i),l=[this.listeners.bind(a,[{type:"keydown",listener:u=>this.handleKeyDown(u,n,r),options:{capture:!0}}])];re(this,dn).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:i=rr.keyboardCodes}=r??{};if(en(t,[...i.end,...i.cancel])){t.preventDefault();const s=en(t,i.cancel);this.handleEnd(t,s);return}en(t,i.up)?this.handleMove("up",t):en(t,i.down)&&this.handleMove("down",t),en(t,i.left)?this.handleMove("left",t):en(t,i.right)&&this.handleMove("right",t)}handleEnd(t,n){this.manager.actions.stop({event:t,canceled:n}),this.cleanup()}handleMove(t,n){var r,i;const{shape:s}=this.manager.dragOperation,o=n.shiftKey?5:1;let a={x:0,y:0},l=(i=(r=this.options)==null?void 0:r.offset)!=null?i:rr.offset;if(typeof l=="number"&&(l={x:l,y:l}),!!s){switch(t){case"up":a={x:0,y:-l.y*o};break;case"down":a={x:0,y:l.y*o};break;case"left":a={x:-l.x*o,y:0};break;case"right":a={x:l.x*o,y:0};break}(a.x||a.y)&&(n.preventDefault(),this.manager.actions.move({event:n,by:a}))}}sideEffects(){const t=this.manager.registry.plugins.get(rd);t?.disabled===!1&&(t.disable(),re(this,dn).push(()=>{t.enable()}))}cleanup(){re(this,dn).forEach(t=>t()),Ae(this,dn,[])}destroy(){this.cleanup(),this.listeners.clear()}};dn=new WeakMap;_i.configure=Or(_i);_i.defaults=rr;var id=_i;function en(e,t){return t.includes(e.code)}var Wt,Ch=class extends lc{constructor(){super(...arguments),ve(this,Wt)}onEvent(e){switch(e.type){case"pointerdown":Ae(this,Wt,xn(e));break;case"pointermove":if(!re(this,Wt))return;const{x:t,y:n}=xn(e),r={x:t-re(this,Wt).x,y:n-re(this,Wt).y},{tolerance:i}=this.options;if(i&&_s(r,i)){this.abort();return}_s(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){Ae(this,Wt,void 0)}};Wt=new WeakMap;var un,zt,Ph=class extends lc{constructor(){super(...arguments),ve(this,un),ve(this,zt)}onEvent(e){switch(e.type){case"pointerdown":Ae(this,zt,xn(e)),Ae(this,un,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!re(this,zt))return;const{x:t,y:n}=xn(e),r={x:t-re(this,zt).x,y:n-re(this,zt).y};_s(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){re(this,un)&&(clearTimeout(re(this,un)),Ae(this,zt,void 0),Ae(this,un,void 0))}};un=new WeakMap;zt=new WeakMap;var gn=class{};gn.Delay=Ph;gn.Distance=Ch;var Fs=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:i}=e;if(!(r==="mouse"&&Vt(i)&&(t.handle===i||(n=t.handle)!=null&&n.contains(i))))return r==="touch"?[new gn.Delay({value:250,tolerance:5})]:Nf(i)&&!e.defaultPrevented?[new gn.Delay({value:200,tolerance:0})]:[new gn.Delay({value:200,tolerance:10}),new gn.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;if(r===t.element||r===t.handle||!Vt(r)||(n=t.handle)!=null&&n.contains(r))return!1;const i=lf(r);return i===t.element?!1:!!i}}),fn,ki=class extends bn{constructor(t,n){super(t),this.manager=t,this.options=n,ve(this,fn,new Set),this.listeners=new $c,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:r,coordinates:i}=this.latest;!r||!i||this.manager.actions.move({event:r,to:i})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(t,n,r=this.options){const{activationConstraints:i=Fs.activationConstraints}=r??{};return typeof i=="function"?i(t,n):i}bind(t,n=this.options){return tt(()=>{var i;const s=new AbortController,{signal:o}=s,a=u=>{Ff(u)&&this.handlePointerDown(u,t,n)};let l=[(i=t.handle)!=null?i:t.element];n?.activatorElements&&(Array.isArray(n.activatorElements)?l=n.activatorElements:l=n.activatorElements(t));for(const u of l)u&&(jh(u.ownerDocument.defaultView),u.addEventListener("pointerdown",a,{signal:o}));return()=>s.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!Vt(t.target)||n.disabled||Mh(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:i=Fs.preventActivation}=r??{};if(i?.(t,n))return;const{target:s}=t,o=Tt(s)&&s.draggable&&s.getAttribute("draggable")==="true",a=_n(n.element),{x:l,y:u}=xn(t);this.initialCoordinates={x:l*a.scaleX+a.x,y:u*a.scaleY+a.y};const d=this.activationConstraints(t,n,r);t.sensor=this;const c=new Zu(d,p=>this.handleStart(n,p));c.signal.onabort=()=>this.handleCancel(t),c.onEvent(t),this.controller=c;const h=Es(),f=this.listeners.bind(h,[{type:"pointermove",listener:p=>this.handlePointerMove(p,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:Nr,options:{capture:!0}}]),v=()=>{f(),this.initialCoordinates=void 0};re(this,fn).add(v)}handlePointerMove(t,n){var r,i;if(((r=this.controller)==null?void 0:r.activated)===!1){(i=this.controller)==null||i.onEvent(t);return}if(this.manager.dragOperation.status.dragging){const s=xn(t),o=_n(n.element);s.x=s.x*o.scaleX+o.x,s.y=s.y*o.scaleY+o.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=s,mi.schedule(this.handleMove)}}handlePointerUp(t){const{status:n}=this.manager.dragOperation;if(!n.idle){t.preventDefault(),t.stopPropagation();const r=!n.initialized;this.manager.actions.stop({event:t,canceled:r})}this.cleanup()}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel(t))}handleStart(t,n){const{manager:r,initialCoordinates:i}=this;if(!i||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:i,event:n,source:t}).signal.aborted)return this.cleanup();n.preventDefault();const a=jn(n.target).body;try{a.setPointerCapture(n.pointerId)}catch{this.handleCancel(n);return}const l=Vt(n.target)?[n.target,a]:a,u=this.listeners.bind(l,[{type:"touchmove",listener:Nr,options:{passive:!1}},{type:"click",listener:Nr},{type:"contextmenu",listener:Nr},{type:"keydown",listener:this.handleKeyDown}]);re(this,fn).add(u)}handleCancel(t){const{dragOperation:n}=this.manager;n.status.initialized&&this.manager.actions.stop({event:t,canceled:!0}),this.cleanup()}cleanup(){const{controller:t}=this;this.controller=void 0,t&&!t.signal.aborted&&t.abort(),this.latest={event:void 0,coordinates:void 0},re(this,fn).forEach(n=>n()),re(this,fn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};fn=new WeakMap;ki.configure=Or(ki);ki.defaults=Fs;var Ns=ki;function Mh(e){return"sensor"in e}function Nr(e){e.preventDefault()}function Ih(){}var Ca=new WeakSet;function jh(e){!e||Ca.has(e)||(e.addEventListener("touchmove",Ih,{capture:!1,passive:!1}),Ca.add(e))}var mn={modifiers:[],plugins:[sh,rd,ah,Go,Dh],sensors:[Ns,id]},sd=class extends tf{constructor(e={}){const t=st(e.plugins,mn.plugins),n=st(e.sensors,mn.sensors),r=st(e.modifiers,mn.modifiers);super(Fo(xr({},e),{plugins:[Oh,Pr,Wi,...t],sensors:n,modifiers:r}))}},od,ad,Bs,$t,Ko,Yo,zi=class extends(Bs=ut,ad=[K],od=[K],Bs){constructor(e,t){var n=e,{element:r,effects:i=()=>[],handle:s}=n,o=Wc(n,["element","effects","handle"]);super(xr({effects:()=>[...i(),()=>{var a,l;const{manager:u}=this;if(!u)return;const c=((l=(a=this.sensors)==null?void 0:a.map(gr))!=null?l:[...u.sensors]).map(h=>{const f=h instanceof bn?h:u.registry.register(h.plugin),v=h instanceof bn?void 0:h.options;return f.bind(this,v)});return function(){c.forEach(f=>f())}}]},o),t),ve(this,Ko,we($t,8,this)),we($t,11,this),ve(this,Yo,we($t,12,this)),we($t,15,this),this.element=r,this.handle=s}};$t=Rn(Bs);Ko=new WeakMap;Yo=new WeakMap;nt($t,4,"handle",ad,zi,Ko);nt($t,4,"element",od,zi,Yo);Xt($t,zi);var ld,cd,Vs,Et,Xo,ts,dd,ud,pr,Qo,Fi=class extends(Vs=ft,cd=[K],ld=[K],Vs){constructor(e,t){var n=e,{element:r,effects:i=()=>[]}=n,s=Wc(n,["element","effects"]);const{collisionDetector:o=jc}=s,a=u=>{const{manager:d,element:c}=this;if(!c||u===null){this.shape=void 0;return}if(!d)return;const h=new ct(c),f=H(()=>this.shape);return h&&f?.equals(h)?f:(this.shape=h,h)},l=En(!1);super(Fo(xr({},s),{collisionDetector:o,effects:()=>[...i(),()=>{const{element:u,manager:d}=this;if(!d)return;const{dragOperation:c}=d,{source:h}=c;l.value=!!(h&&c.status.initialized&&u&&!this.disabled&&this.accepts(h))},()=>{const{element:u}=this;if(l.value&&u){const d=new yf(u,a);return()=>{d.disconnect(),this.shape=void 0}}},()=>{var u;if((u=this.manager)!=null&&u.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),ve(this,pr),ve(this,Xo,we(Et,8,this)),we(Et,11,this),ve(this,Qo,we(Et,12,this)),we(Et,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){Ae(this,pr,e,ud)}get element(){var e;return(e=this.proxy)!=null?e:re(this,pr,dd)}};Et=Rn(Vs);Xo=new WeakMap;pr=new WeakSet;Qo=new WeakMap;ts=nt(Et,20,"#element",cd,pr,Xo),dd=ts.get,ud=ts.set;nt(Et,4,"proxy",ld,Fi,Qo);Xt(Et,Fi);function Ah(e){return e!=null&&typeof e=="object"&&"current"in e}function yn(e){var t;if(e!=null)return Ah(e)?(t=e.current)!=null?t:void 0:e}var Rh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ln=Rh?S.useLayoutEffect:S.useEffect;function Lh(){const e=S.useState(0)[1];return S.useCallback(()=>{e(t=>t+1)},[e])}function fd(e,t){const n=S.useRef(new Map),r=Lh();return Ln(()=>{if(!e){n.current.clear();return}return tt(()=>{var i;let s=!1,o=!1;for(const a of n.current){const[l]=a,u=H(()=>a[1]),d=e[l];u!==d&&(s=!0,n.current.set(l,d),o=(i=t?.(l,u,d))!=null?i:!1)}s&&(o?queueMicrotask(()=>lu.flushSync(r)):r())})},[e]),S.useMemo(()=>e&&new Proxy(e,{get(i,s){const o=i[s];return n.current.set(s,o),o}}),[e])}function Wh(e,t){e()}function tn(e){const t=S.useRef(e);return Ln(()=>{t.current=e},[e]),t}function le(e,t,n=S.useEffect,r=Object.is){const i=S.useRef(e);n(()=>{const s=i.current;r(e,s)||(i.current=e,t(e,s))},[t,e])}function si(e,t){const n=S.useRef(yn(e));Ln(()=>{const r=yn(e);r!==n.current&&(n.current=r,t(r))})}var zh=Object.defineProperty,Fh=Object.defineProperties,Nh=Object.getOwnPropertyDescriptors,Si=Object.getOwnPropertySymbols,hd=Object.prototype.hasOwnProperty,pd=Object.prototype.propertyIsEnumerable,Pa=(e,t,n)=>t in e?zh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bh=(e,t)=>{for(var n in t||(t={}))hd.call(t,n)&&Pa(e,n,t[n]);if(Si)for(var n of Si(t))pd.call(t,n)&&Pa(e,n,t[n]);return e},Vh=(e,t)=>Fh(e,Nh(t)),Gh=(e,t)=>{var n={};for(var r in e)hd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Si)for(var r of Si(e))t.indexOf(r)<0&&pd.call(e,r)&&(n[r]=e[r]);return n},Uh=new sd,gd=S.createContext(Uh),qh=S.memo(S.forwardRef(({children:e},t)=>{const[n,r]=S.useState(0),i=S.useRef(null),s=S.useRef(null),o=S.useMemo(()=>({renderer:{get rendering(){var a;return(a=i.current)!=null?a:Promise.resolve()}},trackRendering(a){i.current||(i.current=new Promise(l=>{s.current=l})),S.startTransition(()=>{a(),r(l=>l+1)})}}),[]);return Ln(()=>{var a;(a=s.current)==null||a.call(s),i.current=null},[e,n]),S.useImperativeHandle(t,()=>o),null})),ns=[void 0,rt];function Hh(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:i,onDragStart:s,onDragMove:o,onDragOver:a,onDragEnd:l}=t,u=Gh(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const d=S.useRef(null),{plugins:c,modifiers:h,sensors:f}=u,v=st(c,mn.plugins),p=st(f,mn.sensors),w=st(h,mn.modifiers),x=tn(i),m=tn(s),g=tn(a),b=tn(o),_=tn(l),$=tn(r),O=Kh(()=>{var C;return(C=u.manager)!=null?C:new sd(u)});return S.useEffect(()=>{if(!d.current)throw new Error("Renderer not found");const{renderer:C,trackRendering:I}=d.current,{monitor:P}=O;O.renderer=C;const U=[P.addEventListener("beforedragstart",W=>{const M=x.current;M&&I(()=>M(W,O))}),P.addEventListener("dragstart",W=>{var M;return(M=m.current)==null?void 0:M.call(m,W,O)}),P.addEventListener("dragover",W=>{const M=g.current;M&&I(()=>M(W,O))}),P.addEventListener("dragmove",W=>{const M=b.current;M&&I(()=>M(W,O))}),P.addEventListener("dragend",W=>{const M=_.current;M&&I(()=>M(W,O))}),P.addEventListener("collision",W=>{var M;return(M=$.current)==null?void 0:M.call($,W,O)})];return()=>U.forEach(W=>W())},[O]),le(v,()=>O&&(O.plugins=v),...ns),le(p,()=>O&&(O.sensors=p),...ns),le(w,()=>O&&(O.modifiers=w),...ns),y.jsxs(gd.Provider,{value:O,children:[y.jsx(qh,{ref:d,children:n}),n]})}function Kh(e){const t=S.useRef(null);return t.current||(t.current=e()),S.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}function Yh(){return S.useContext(gd)}function vd(e){var t;const n=(t=Yh())!=null?t:void 0,[r]=S.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Ln(r.register,[n,r]),r}var Xh=Object.create,md=Object.defineProperty,Qh=Object.getOwnPropertyDescriptor,yd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ni=e=>{throw TypeError(e)},Zh=(e,t,n)=>t in e?md(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jh=e=>{var t;return[,,,Xh((t=e?.[yd("metadata")])!=null?t:null)]},bd=["class","method","getter","setter","accessor","field","value","get","set"],xd=e=>e!==void 0&&typeof e!="function"?Ni("Function expected"):e,ep=(e,t,n,r,i)=>({kind:bd[e],name:t,metadata:r,addInitializer:s=>n._?Ni("Already initialized"):i.push(xd(s||null))}),tp=(e,t)=>Zh(t,yd("metadata"),e[3]),np=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)s[i].call(n);return r},wd=(e,t,n,r,i,s)=>{for(var o,a,l,u,d=t&7,c=!1,h=!1,f=2,v=bd[d+5],p=e[f]||(e[f]=[]),w=(i=i.prototype,Qh(i,n)),x=r.length-1;x>=0;x--)l=ep(d,n,a={},e[3],p),l.static=c,l.private=h,u=l.access={has:m=>n in m},u.get=m=>m[n],o=(0,r[x])(w[v],l),a._=1,xd(o)&&(w[v]=o);return w&&md(i,n,w),i},_d=(e,t,n)=>t.has(e)||Ni("Cannot "+n),rp=(e,t,n)=>(_d(e,t,"read from private field"),t.get(e)),ip=(e,t,n)=>t.has(e)?Ni("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),sp=(e,t,n,r)=>(_d(e,t,"write to private field"),t.set(e,n),n),Nt=class Gs{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Gs(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Gs(t,n)}},kd,Sd,Us,oi,Mr,Zo=class extends(Us=Kt,Sd=[ge],kd=[ge],Us){constructor(e){const t=Nt.from(e);super(t,(n,r)=>Nt.equals(n,r)),np(Mr,5,this),ip(this,oi,0),this.velocity={x:0,y:0}}get delta(){return Nt.delta(this.current,this.initial)}get direction(){const{current:e,previous:t}=this;if(!t)return null;const n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up"}get current(){return super.current}set current(e){const{current:t}=this,n=Nt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-rp(this,oi),o=a=>Math.round(a/s*100);ue(()=>{sp(this,oi,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Nt.from(e)),this.velocity={x:0,y:0}}};Mr=Jh(Us);oi=new WeakMap;wd(Mr,2,"delta",Sd,Zo);wd(Mr,2,"direction",kd,Zo);tp(Mr,Zo);var $d=(e=>(e.Horizontal="x",e.Vertical="y",e))($d||{});Object.values($d);var op=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const i=Nt.distance(t.shape.center,n);return{id:r,value:1/i,type:In.PointerIntersection,priority:Mn.High}}return null},ap=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:i}=e,s=Nt.distance(t.shape.center,i.current),a=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:a,type:In.ShapeIntersection,priority:Mn.Normal}}return null},lp=e=>{var t;return(t=op(e))!=null?t:ap(e)};function cp(e){const{collisionDetector:t,data:n,disabled:r,element:i,id:s,accept:o,type:a}=e,l=vd(d=>new Fi(Vh(Bh({},e),{register:!1,element:yn(i)}),d)),u=fd(l);return le(s,()=>l.id=s),si(i,d=>l.element=d),le(o,()=>l.accept=o,void 0,rt),le(t,()=>l.collisionDetector=t??lp),le(n,()=>n&&(l.data=n)),le(r,()=>l.disabled=r===!0),le(a,()=>l.type=a),{droppable:u,get isDropTarget(){return u.isDropTarget},ref:S.useCallback(d=>{var c,h;!d&&((c=l.element)!=null&&c.isConnected)&&!((h=l.manager)!=null&&h.dragOperation.status.idle)||(l.element=d??void 0)},[l])}}function dp(e,t=[]){const n=new Map;for(const s of e.tiles)for(const o of s.filters??[])n.set(o.given,(n.get(o.given)??0)+1);const r=[],i=new Set;for(const s of e.localGivens??[])i.add(s.name),r.push({name:s.name,...s.label===void 0?{}:{label:s.label},type:s.type,...s.suggest?{field:s.suggest.dimension}:{},origin:"dashboard",local:s,boundTiles:n.get(s.name)??0});for(const s of t)i.has(s.name)||(i.add(s.name),r.push({...s,origin:"model",boundTiles:n.get(s.name)??0}));for(const[s,o]of n)i.has(s)||r.push({name:s,origin:"model",boundTiles:o});return r}function $i(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function up(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function ai(e,t){const n=up(e),r=t?.replace(/_type$/,"");if(!n||!r)return!0;const i=new Set(["date","timestamp"]);return i.has(n)?i.has(r):n===r}function Ma(e){switch(e?.replace(/_type$/,"")){case"string":return"text";case"number":return"a number";case"date":return"a date";case"timestamp":return"a timestamp";case"boolean":return"true or false";default:return e??"an unknown type"}}function fp(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const hp=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function pp(e,t){const r=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",i=/^[A-Z_]/.test(r)?r:`F_${r}`,s=new Set(t);if(!s.has(i))return i;for(let o=2;;o++)if(!s.has(`${i}_${o}`))return`${i}_${o}`}const Ia=[{kind:"select",label:"Pick one",hint:"A dropdown of the field's values"},{kind:"multiselect",label:"Pick several",hint:"The same, taking more than one"},{kind:"text",label:"Text",hint:"A box taking Malloy filter syntax"},{kind:"number",label:"Number range",hint:"A slider over the field's values"},{kind:"date",label:"Since a date",hint:"A date picker; tiles keep rows on or after it"}];function Br(e){const t=e.label.trim()||e.name,n=e.field.split(".").at(-1)??e.field;switch(e.kind){case"select":case"multiselect":return{name:e.name,type:"filter<string>",default:"f''",label:t,control:e.kind,...e.source?{suggest:{source:e.source,dimension:n}}:{}};case"text":return{name:e.name,type:"filter<string>",default:"f''",label:t};case"number":return{name:e.name,type:"filter<number>",default:"f''",label:t,...e.range?{rangeMin:e.range.min,rangeMax:e.range.max}:{}};case"date":return{name:e.name,type:"date",default:`@${e.dateDefault??new Date().toISOString().slice(0,10)}`,label:t}}}const qs=e=>e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function gp(e,t){return e.tiles.map(n=>{const r=(n.filters??[]).find(i=>i.given===t.name);return{include:r!==void 0,field:r?.field??t.field??t.name.toLowerCase(),...r?.op!==void 0?{op:r.op}:$i(t.type)!==void 0?{op:$i(t.type)}:{}}})}function vp(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!qs(s))return;const o=(s.filters??[]).filter(l=>l.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?s.filters=a:delete s.filters})}function mp(e,t){const n=(e.localGivens??[]).filter(s=>s.name!==t.name),r=(e.localGivens??[]).findIndex(s=>s.name===t.name),i=[...n];i.splice(r>=0?r:i.length,0,t),e.localGivens=i}function yp(e,t){for(const r of e.tiles){const i=(r.filters??[]).filter(s=>s.given!==t);i.length>0?r.filters=i:delete r.filters}const n=(e.localGivens??[]).filter(r=>r.name!==t);n.length>0?e.localGivens=n:delete e.localGivens}const bp=j.createSvgIcon(y.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"})),xp=j.createSvgIcon(y.jsx("path",{d:"m14.06 9.02.92.92L5.92 19H5v-.92zM17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29m-3.6 3.19L3 17.25V21h3.75L17.81 9.94z"})),wp=j.createSvgIcon(y.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"})),_p=j.createSvgIcon(y.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"})),Hs=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),rs=Hs?"⌘":"Ctrl+",kp=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"};function Sp(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e}),S.useEffect(()=>{const n=r=>{const i=t.current,s=Hs?r.metaKey:r.ctrlKey,o=r.key.toLowerCase();if(r.key==="Escape"){i.escape();return}if(!kp(r.target)){if(s&&o==="z"){r.preventDefault(),r.shiftKey?i.redo():i.undo();return}if(!Hs&&s&&o==="y"){r.preventDefault(),i.redo();return}if(s&&o==="s"){r.preventDefault(),i.save?.();return}!s&&!r.altKey&&!r.shiftKey&&(r.key==="ArrowLeft"||r.key==="ArrowRight")&&(r.preventDefault(),i.nudge(r.key==="ArrowRight"?1:-1))}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[])}function $p({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:i,saving:s,onSave:o,actions:a,onAddTile:l,onSettings:u}){const{theme:d}=Be.usePublisherTheme();return y.jsxs(j.DashboardBar,{left:y.jsx(k.Chip,{size:"medium",variant:"outlined",icon:y.jsx(xp,{sx:{fontSize:20}}),label:"Editing",sx:{height:37,fontSize:"0.875rem",fontWeight:500,border:d.border,color:d.tileTitle,"& .MuiChip-icon":{color:"inherit"},"& .MuiChip-label":{fontSize:"0.875rem"}}}),children:[l&&y.jsx(k.Button,{startIcon:y.jsx(j.AddIcon,{}),onClick:l,"aria-label":"Add tile",children:"Tile"}),y.jsx(k.Button,{startIcon:y.jsx(bp,{}),onClick:c=>u(c.currentTarget),children:"Settings"}),y.jsx(k.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),y.jsx(k.Tooltip,{title:`Undo (${rs}Z)`,children:y.jsx("span",{children:y.jsx(k.IconButton,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:y.jsx(_p,{fontSize:"small"})})})}),y.jsx(k.Tooltip,{title:`Redo (${rs}⇧Z)`,children:y.jsx("span",{children:y.jsx(k.IconButton,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:y.jsx(wp,{fontSize:"small"})})})}),o&&y.jsx(y.Fragment,{children:y.jsx(k.Tooltip,{title:i?`Save (${rs}S)`:"",children:y.jsx("span",{children:y.jsx(k.Button,{variant:i?"contained":"outlined",disabled:!i||s,onClick:o,sx:{minWidth:124},children:s?"Saving…":i?"Save changes":"Saved"})})})}),a&&y.jsxs(y.Fragment,{children:[y.jsx(k.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),a]})]})}const Ep=["bar_chart","line_chart","scatter_chart","shape_map","segment_map","big_value","sparkline"];function Vr(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function ja(e){for(const t of e??[]){const n=/^#\s*([a-z_]+)/.exec(t.trim())?.[1];if(n&&Ep.includes(n))return n}}const Op=1;function Ed(e,t,n){const r=[];for(const i of e??[]){const s=i.name,o=i.kind;if(typeof s=="string"){if(o==="dimension"||o==="measure"){const a=i.type?.kind;r.push({name:t+s,kind:o,...a?{type:a}:{}})}else if(o==="join"&&n>0){const a=i.schema?.fields;r.push(...Ed(a,`${t}${s}.`,n-1))}}}return r}function Tp(e){const t=new Map;for(const n of e.sourceInfos??[]){let r;try{r=typeof n=="string"?JSON.parse(n):n}catch{continue}const i=r;i?.name&&t.set(i.name,Ed(i.schema?.fields,"",Op))}return t}function Aa(e,t){return!e||t===void 0?void 0:e.sources.find(r=>r.name===t)?.fields.filter(r=>r.kind==="dimension")}const Dp=e=>(e??"").startsWith("dashboards/"),Od=e=>e.modelPath??e.path??"";function Td(e){const t=[],n=new Set;for(const r of e){const i=Od(r);if(Dp(i))continue;const s=Tp(r);for(const o of r.sources??[]){const a=o.name;if(!a||n.has(a))continue;n.add(a);const l=(o.givens??[]).map(u=>u.name).filter(u=>typeof u=="string");t.push({name:a,modelPath:i,...Vr(o.annotations)?{description:Vr(o.annotations)}:{},views:(o.views??[]).filter(u=>typeof u.name=="string").map(u=>({name:u.name,...Vr(u.annotations)?{description:Vr(u.annotations)}:{},...ja(u.annotations)?{chart:ja(u.annotations)}:{}})),givens:l,fields:s.get(a)??[]})}}return{sources:t}}function Cp(e,t,n){const r=new Set;for(const i of t){if(i.kind==="names"){for(const o of i.names)r.add(o);continue}const s=n.find(o=>Od(o)===i.path);if(!s)return e;for(const o of s.sources??[])o.name&&r.add(o.name)}return{...e,sources:e.sources.filter(i=>r.has(i.name))}}const pt=e=>`${e.source}.${e.name}`;function Pp(e,t){if(!t)return[];const n=new Set;for(const r of e.sources)n.add(r.base);for(const r of e.imports)if(r.kind==="names")for(const i of r.names)n.add(i);return t.sources.filter(r=>n.has(r.name))}function Mp({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s}){const{theme:o}=Be.usePublisherTheme(),a=S.useMemo(()=>Pp(t,n),[t,n]),[l,u]=S.useState(""),[d,c]=S.useState(""),[h,f]=S.useState(""),[v,p]=S.useState(Math.ceil(r/2));S.useEffect(()=>{e&&(u(t.sources[0]?.base??a[0]?.name??""),c(""),f(""),p(Math.ceil(r/2)))},[e,t,a,r]);const w=a.find(m=>m.name===l),x=l!==""&&d!=="";return y.jsx(j.AppDialog,{open:e,onClose:i,title:"Add a tile",description:"A tile shows one view of one source this dashboard imports.",actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:i,children:"Cancel"}),y.jsx(k.Button,{variant:"contained",disabled:!x,onClick:()=>s({base:l,view:d,...h.trim()?{label:h.trim()}:{},colspan:v}),children:"Add tile"})]}),children:y.jsx(k.Stack,{sx:{gap:2,pt:1},children:a.length===0?y.jsx(k.Typography,{variant:"body2",sx:{color:o.tileTitle},children:n?"This dashboard imports no source by name, so there is nothing to put a tile on. Import a source in the file first.":"The package's sources are still loading."}):y.jsxs(y.Fragment,{children:[y.jsx(k.TextField,{select:!0,size:"small",label:"Source",value:l,onChange:m=>{u(m.target.value),c("")},inputProps:{"aria-label":"Source"},children:a.map(m=>y.jsxs(k.MenuItem,{value:m.name,children:[m.name,m.description&&y.jsx(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:m.description})]},m.name))}),y.jsxs(k.Box,{children:[y.jsx(k.Typography,{variant:"subtitle2",sx:{mb:.5},children:"View"}),y.jsxs(k.List,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:280,overflowY:"auto",border:o.border,borderRadius:1},children:[(w?.views??[]).map(m=>y.jsxs(k.ListItemButton,{selected:d===m.name,onClick:()=>c(m.name),"aria-label":`View ${m.name}`,children:[y.jsx(k.ListItemText,{primary:m.name,secondary:m.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),m.chart&&y.jsx(k.Chip,{size:"small",variant:"outlined",label:m.chart.replace(/_chart$/,"")})]},m.name)),w&&w.views.length===0&&y.jsx(k.Typography,{variant:"body2",sx:{p:1.5,color:o.tileTitle},children:"This source declares no views."})]})]}),y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5},children:[y.jsx(k.TextField,{size:"small",label:"Title",placeholder:"Uses the view's name",value:h,onChange:m=>f(m.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}}),y.jsx(k.TextField,{size:"small",type:"number",label:`Width (of ${r})`,value:v,onChange:m=>p(Math.min(Math.max(Number(m.target.value)||1,1),r)),inputProps:{min:1,max:r,"aria-label":"Tile width"},sx:{width:140}})]})]})})})}const Ra=4e3;function Ip(e,t){const n=e.split(`
|
|
68
|
-
|
|
69
|
-
`);if(n.length>Ra||r.length>Ra)return[...n.map(l=>({kind:"del",text:l})),...r.map(l=>({kind:"add",text:l}))];const i=Array.from({length:n.length+1},()=>new Uint32Array(r.length+1));for(let l=n.length-1;l>=0;l--)for(let u=r.length-1;u>=0;u--)i[l][u]=n[l]===r[u]?i[l+1][u+1]+1:Math.max(i[l+1][u],i[l][u+1]);const s=[];let o=0,a=0;for(;o<n.length&&a<r.length;)n[o]===r[a]?(s.push({kind:"same",text:n[o]}),o++,a++):i[o+1][a]>=i[o][a+1]?s.push({kind:"del",text:n[o++]}):s.push({kind:"add",text:r[a++]});for(;o<n.length;)s.push({kind:"del",text:n[o++]});for(;a<r.length;)s.push({kind:"add",text:r[a++]});return s}function jp(e,t=3){const n=new Array(e.length).fill(!1);e.forEach((s,o)=>{if(s.kind!=="same")for(let a=Math.max(0,o-t);a<=Math.min(e.length-1,o+t);a++)n[a]=!0});const r=[];let i=0;return e.forEach((s,o)=>{n[o]?(i>0&&r.push({kind:"fold",count:i}),i=0,r.push(s)):i++}),i>0&&r.push({kind:"fold",count:i}),r}function Ap({open:e,before:t,after:n,onConfirm:r,onClose:i}){const{theme:s}=Be.usePublisherTheme(),o=S.useMemo(()=>e?jp(Ip(t,n)):[],[e,t,n]),a=o.filter(u=>u.kind==="add").length,l=o.filter(u=>u.kind==="del").length;return y.jsx(j.AppDialog,{open:e,onClose:i,maxWidth:"md",title:"Review the change to the file",description:y.jsxs(y.Fragment,{children:["A tile was added or removed, which moves declarations. Lines the builder does not own — comments, other Malloy — are left where they were; check they still read right."," ",y.jsxs(k.Box,{component:"span",sx:{fontVariantNumeric:"tabular-nums"},children:["+",a," −",l]})]}),actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:i,children:"Keep editing"}),y.jsx(k.Button,{variant:"contained",onClick:r,children:"Save this"})]}),children:y.jsx(k.Box,{component:"pre","aria-label":"File changes",sx:{m:0,px:2,py:1,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,lineHeight:1.6,overflowX:"auto",bgcolor:s.background,color:s.foreground},children:o.map((u,d)=>u.kind==="fold"?y.jsx(k.Box,{component:"span",sx:{display:"block",opacity:.55,py:.25},children:`⋯ ${u.count} unchanged line${u.count===1?"":"s"}`},d):y.jsxs(k.Box,{component:"span",sx:{display:"block",mx:-2,px:2,whiteSpace:"pre",bgcolor:u.kind==="add"?"rgba(46, 125, 91, 0.16)":u.kind==="del"?"rgba(168, 41, 31, 0.14)":"transparent",textDecoration:u.kind==="del"?"line-through":"none",opacity:u.kind==="del"?.8:1},children:[u.kind==="add"?"+ ":u.kind==="del"?"− ":" ",u.text]},d))})})}const is="self";function Rp({open:e,document:t,source:n,givenNames:r,dashboards:i,onClose:s,onApply:o}){const{theme:a}=Be.usePublisherTheme(),[l,u]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const v=(t.drills??[]).filter(p=>p.source===n.name);u((n.dimensions??[]).map(p=>{const w=v.find(x=>x.name===p.name);return{name:p.name,expression:p.expression,to:w?.to??[],given:w?.given??""}}))},[e,n,t]);const d=(v,p)=>u(w=>w.map((x,m)=>{if(m!==v)return x;const g={...x};return p(g),g})),c=[is,...i.filter(v=>v!==is)],h=v=>v===is?"This dashboard":v,f=()=>{n&&(o(l.filter(v=>v.to.length>0).map(v=>({source:n.name,name:v.name,expression:v.expression,to:v.to,...v.given?{given:v.given}:{}}))),s())};return y.jsx(j.AppDialog,{open:e,onClose:s,title:"Clickable cells",description:"A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the dashboard it opens.",actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:s,children:"Cancel"}),y.jsx(k.Button,{variant:"contained",onClick:f,disabled:l.length===0,children:"Apply"})]}),children:y.jsx(k.Stack,{sx:{gap:2,pt:1},children:l.length===0?y.jsx(k.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?y.jsxs(y.Fragment,{children:[y.jsx(k.Box,{component:"code",children:n.name})," declares no dimensions of its own in this file. A drill is a tag on the dimension's declaration, so a dimension the model declares is made clickable in the model; to make one clickable here, declare it in"," ",y.jsx(k.Box,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):l.map((v,p)=>y.jsxs(k.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[y.jsxs(k.Box,{sx:{minWidth:0,pt:.75},children:[y.jsx(k.Typography,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:v.name}),y.jsxs(k.Typography,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:v.expression,children:["is ",v.expression]})]}),y.jsx(k.TextField,{select:!0,size:"small",label:"Clicks go to",value:v.to,inputProps:{"aria-label":`Where ${v.name} goes`},SelectProps:{multiple:!0,renderValue:w=>w.length===0?"Not clickable":w.map(h).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:w=>d(p,x=>{const m=w.target.value;x.to=Array.isArray(m)?m:String(m).split(",").filter(Boolean)}),children:c.map(w=>y.jsxs(k.MenuItem,{value:w,children:[y.jsx(k.Checkbox,{size:"small",checked:v.to.includes(w),sx:{p:0,mr:1}}),y.jsx(k.ListItemText,{primary:h(w)})]},w))}),y.jsxs(k.TextField,{select:!0,size:"small",label:"Sets the control",value:v.given,disabled:v.to.length===0,inputProps:{"aria-label":`Control ${v.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:v.given===""?`Named ${v.name}, like the dimension`:void 0,onChange:w=>d(p,x=>{x.given=w.target.value}),children:[y.jsx(k.MenuItem,{value:"",children:y.jsx("em",{children:"Same name as the dimension"})}),r.map(w=>y.jsx(k.MenuItem,{value:w,children:w},w))]})]},v.name))})})}const Dd=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function Lp({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:s}){const o=S.useRef(n);e&&(o.current=n);const a=e?n:o.current,l=a!==void 0,[u,d]=S.useState({kind:"new"}),[c,h]=S.useState(""),[f,v]=S.useState("select"),[p,w]=S.useState(""),[x,m]=S.useState(""),[g,b]=S.useState([]),[_,$]=S.useState(!1),O=T=>t.sources.find(A=>A.name===T.source)?.base??T.source;S.useEffect(()=>{if(e)if(n){d({kind:"existing",name:n.name}),h(n.label??"");const T=gp(t,n);b(T);const A=T.filter(E=>E.include),q=new Set(A.map(E=>E.field));m(q.size===1?A[0].field:n.field??""),$(q.size>1)}else d({kind:"new"}),h(""),v("select"),m(""),w(new Date().toISOString().slice(0,10)),b(t.tiles.map(T=>({include:qs(T),field:""}))),$(!1)},[e,n,t]);const C=S.useMemo(()=>[...(t.localGivens??[]).map(T=>T.name),...r.map(T=>T.name)],[t,r]),I=S.useMemo(()=>x.trim()?pp(x.trim(),C):"",[x,C]),P=u.kind==="existing"?n??r.find(T=>T.name===u.name):I?{name:I,type:Br({name:I,label:c,kind:f,field:x}).type}:void 0,U=P?.type!==void 0&&!P.type.startsWith("filter<"),W=g.find(T=>T.include)?.op??$i(P?.type),M=(T,A)=>b(q=>q.map((E,D)=>D===T?{...E,...A}:E)),z=T=>b(A=>A.map(q=>({...q,op:T}))),V=T=>{const A=$i(T);b(q=>q.map(({op:E,...D})=>A?{...D,op:A}:D))},ee=T=>{d({kind:"existing",name:T.name}),m(T.field??""),V(T.type)},Se=T=>{v(T),V(Br({name:"X",label:c,kind:T,field:x}).type)},oe=t.tiles.map(qs),Le=oe.filter(Boolean).length,Ve=g.filter((T,A)=>T.include&&oe[A]).length,Ce=t.tiles.filter((T,A)=>(g[A]?.include??!1)&&oe[A]),Ye=Ce.length>0?Ce:t.tiles.filter((T,A)=>oe[A]),Ge=S.useMemo(()=>{const T=new Map;let A=!1;for(const q of Ye){const E=i?.(q);if(E){A=!0;for(const D of E)T.has(D.name)||T.set(D.name,D)}}return A?[...T.values()]:void 0},[g,t.tiles,i]),We=(()=>{const T=x.trim();for(const A of Ce){const q=i?.(A);if(!q||q.some(E=>E.name===T))return O(A)}return Ce[0]?O(Ce[0]):t.sources[0]?.base})(),Xe=T=>b(A=>A.map((q,E)=>({...q,include:T&&oe[E]}))),$e=S.useMemo(()=>_?g:g.map(T=>({...T,field:x})),[_,g,x]),fe=T=>{for(const A of Ye){const q=i?.(A)?.find(E=>E.name===T.trim());if(q?.type)return q.type}},L=T=>ai(P?.type,T.type),G=(T,A)=>{if(T.trim()==="")return"Pick the field this filter compares.";const q=A?i?.(A):void 0;if(!q)return;const E=q.find(D=>D.name===T.trim());if(!E)return`Not a field of ${A?O(A):"the tiles' source"}.`;if(E.type&&!ai(P?.type,E.type))return`${T.trim()} is ${Ma(E.type)}; this filter compares ${Ma(P?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},_e=T=>{if(m(T),l||u.kind!=="new")return;const A=fe(T),q=Br({name:"X",label:c,kind:f,field:T}).type;A&&!ai(q,A)&&Se(fp(A))},X=$e.map((T,A)=>T.include&&oe[A]?G(T.field,t.tiles[A]):void 0),ze=X.every(T=>T===void 0),ne=!_&&Ve>0?Ce.map(T=>G(x,T)).find(Boolean):void 0,at=P!==void 0&&ze&&(u.kind==="existing"||x.trim()!==""&&I!==""),Fe=()=>{if(!(!P||!at))if(u.kind==="new")s(P.name,$e,Br({name:P.name,label:c.trim()||Dd(P.name),kind:f,field:x.trim(),...We?{source:We}:{},...p?{dateDefault:p}:{}}));else if(n?.origin==="dashboard"&&n.local){const T=c.trim(),A=T!==(n.local.label??"");s(P.name,$e,A?{...n.local,...T?{label:T}:{}}:void 0)}else s(P.name,$e)},xt=l&&a.origin==="model";return{editing:l,shown:a,fromModel:xt,source:u,setSource:d,label:c,setLabel:h,kind:f,dateDefault:p,setDateDefault:w,field:x,rows:g,setRows:b,perTile:_,setPerTile:$,newName:I,target:P,valueTyped:U,commonOp:W,setRow:M,setCommonOp:z,pickExisting:ee,pickKind:Se,bindable:oe,bindableCount:Le,included:Ve,commonFields:Ge,setAll:Xe,accepts:L,pickField:_e,rowProblems:X,commonProblem:ne,canApply:at,apply:Fe}}function La({value:e,onChange:t,fields:n,accepts:r,label:i,ariaLabel:s,error:o,helperText:a,disabled:l,autoFocus:u,placeholder:d,sx:c}){const h=S.useMemo(()=>(n??[]).filter(v=>r?.(v)??!0).map(v=>v.name),[n,r]),f=S.useMemo(()=>new Map((n??[]).map(v=>[v.name,v.type])),[n]);return y.jsx(k.Autocomplete,{freeSolo:!0,size:"small",options:h,inputValue:e,onInputChange:(v,p)=>t(p),value:e,onChange:(v,p)=>t(typeof p=="string"?p:""),disabled:l,disableClearable:!0,renderOption:(v,p)=>S.createElement("li",{...v,key:p},y.jsx(k.Typography,{variant:"body2",sx:{flex:1},children:p}),f.get(p)&&y.jsx(k.Typography,{variant:"caption",sx:{opacity:.6},children:f.get(p)?.replace(/_type$/,"")})),renderInput:v=>y.jsx(k.TextField,{...v,label:i,placeholder:d,autoFocus:u,error:o,helperText:a,inputProps:{...v.inputProps,"aria-label":s}}),sx:c})}const Wa=e=>e?.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:{label:"From the model",reason:"Declared on its source, which this dashboard does not write."};function Wp({open:e,document:t,control:n,available:r,fieldsFor:i,onClose:s,onApply:o,onRemove:a}){const{theme:l}=Be.usePublisherTheme(),{editing:u,shown:d,fromModel:c,source:h,setSource:f,label:v,setLabel:p,kind:w,dateDefault:x,setDateDefault:m,field:g,rows:b,setRows:_,perTile:$,setPerTile:O,newName:C,target:I,valueTyped:P,commonOp:U,setRow:W,setCommonOp:M,pickExisting:z,pickKind:V,bindable:ee,bindableCount:Se,included:oe,commonFields:Le,setAll:Ve,accepts:Ce,pickField:Ye,rowProblems:Ge,commonProblem:We,canApply:Xe,apply:$e}=Lp({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:o}),fe=(L,G,_e)=>y.jsx(k.TextField,{select:!0,size:"small",label:"Compares",value:L??">=",onChange:X=>G(X.target.value),inputProps:{"aria-label":_e},sx:{width:130},children:hp.filter(X=>X.op!=="~").map(X=>y.jsx(k.MenuItem,{value:X.op,children:X.label},X.op))});return y.jsx(j.AppDialog,{open:e,onClose:s,title:u?d.label??d.name:"Add a filter",description:u?y.jsxs(y.Fragment,{children:[y.jsxs(k.Box,{component:"span",sx:{fontFamily:"ui-monospace, monospace"},children:["$",d.name]}),c?" · declared in the model, so its label and options are set there":" · declared in this dashboard"]}):"A control on the page, and the tiles it filters.",actions:y.jsxs(y.Fragment,{children:[u&&y.jsx(k.Button,{color:"error",onClick:()=>a(d.name),"aria-label":`Remove control ${d.name}`,sx:{mr:"auto"},children:"Remove from dashboard"}),y.jsx(k.Button,{onClick:s,children:"Cancel"}),y.jsx(k.Tooltip,{title:Xe||I===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:y.jsx("span",{children:y.jsx(k.Button,{variant:"contained",onClick:$e,disabled:!Xe,children:u?"Apply":"Add filter"})})})]}),children:y.jsxs(k.Stack,{sx:{gap:2.5,pt:1},children:[!u&&r.length>0&&y.jsxs(k.ToggleButtonGroup,{exclusive:!0,size:"small",value:h.kind,onChange:(L,G)=>{G==="new"?f({kind:"new"}):G==="existing"&&r[0]&&z(r[0])},"aria-label":"Where the filter comes from",children:[y.jsx(k.ToggleButton,{value:"new",children:"New in this dashboard"}),y.jsx(k.ToggleButton,{value:"existing",children:"From the model"})]}),!u&&h.kind==="existing"?y.jsx(k.TextField,{select:!0,size:"small",label:"Control",value:h.name,onChange:L=>{const G=r.find(_e=>_e.name===L.target.value);G&&z(G)},children:r.map(L=>y.jsxs(k.MenuItem,{value:L.name,children:[L.label??L.name,y.jsxs(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",L.name]})]},L.name))}):null,y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!$&&y.jsx(La,{value:g,onChange:Ye,fields:Le,accepts:Ce,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!u,error:We!==void 0,helperText:We??(!u&&C?`Declared as $${C}`:void 0),sx:{flex:1,minWidth:200}}),!c&&y.jsx(k.TextField,{size:"small",label:"Label",placeholder:C?Dd(C):"",value:v,onChange:L=>p(L.target.value),inputProps:{"aria-label":"Control label"},sx:{flex:1,minWidth:160}}),P&&!$&&fe(U,M,"Comparison")]}),!u&&h.kind==="new"&&y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5},children:[y.jsx(k.TextField,{select:!0,size:"small",label:"Control",value:w,onChange:L=>V(L.target.value),inputProps:{"aria-label":"Kind of control"},slotProps:{select:{renderValue:L=>Ia.find(G=>G.kind===L)?.label??String(L)}},sx:{flex:1},children:Ia.map(L=>y.jsxs(k.MenuItem,{value:L.kind,children:[L.label,y.jsx(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:L.hint})]},L.kind))}),w==="date"&&y.jsx(k.TextField,{size:"small",type:"date",label:"Starts at",value:x,onChange:L=>m(L.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),y.jsxs(k.Box,{children:[y.jsxs(k.Stack,{direction:"row",sx:{alignItems:"center",gap:.5},children:[y.jsx(k.Checkbox,{size:"small",checked:Se>0&&oe===Se,indeterminate:oe>0&&oe<Se,disabled:Se===0,onChange:L=>Ve(L.target.checked),inputProps:{"aria-label":"All tiles"}}),y.jsxs(k.Typography,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",oe," of ",t.tiles.length," tiles"]}),y.jsx(k.Button,{size:"small",onClick:()=>{$||_(L=>L.map(G=>({...G,field:g}))),O(L=>!L)},children:$?"Same field for all":"Adjust per tile"})]}),y.jsx(k.Stack,{sx:{gap:$?1:0},children:t.tiles.map((L,G)=>{const _e=b[G],X=L.label??L.name,ze=$?Ge[G]:void 0;return y.jsxs(k.Stack,{direction:"row",sx:{gap:1,alignItems:$?"flex-start":"center",opacity:ee[G]?1:.6},children:[y.jsx(k.Checkbox,{size:"small",disabled:!ee[G],checked:(_e?.include??!1)&&ee[G],inputProps:{"aria-label":`Filter ${X}`},onChange:ne=>W(G,{include:ne.target.checked})}),y.jsx(k.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:$?1:0},noWrap:!0,children:X}),ee[G]?$&&y.jsxs(y.Fragment,{children:[P&&fe(_e?.op,ne=>W(G,{op:ne}),`Comparison for ${X}`),y.jsx(La,{value:_e?.field??"",onChange:ne=>W(G,{field:ne}),fields:i?.(L),accepts:Ce,label:"Field",ariaLabel:`Field for ${X}`,disabled:!_e?.include,error:ze!==void 0,helperText:ze,sx:{width:220}})]}):y.jsx(k.Tooltip,{title:Wa(t.tiles[G]).reason,children:y.jsx(k.Typography,{variant:"caption",sx:{color:l.tileTitle},children:Wa(t.tiles[G]).label})})]},`${L.source}.${L.name}`)})}),oe===0&&y.jsx(k.Typography,{variant:"caption",sx:{color:"warning.main",display:"block",mt:1},children:"No tile is ticked, so this control will not appear on the dashboard."})]})]})})}function Cd(e,t,n,r){const[i,s]=S.useState(void 0);return S.useEffect(()=>{t&&e!==void 0&&s(structuredClone(e))},[t,e]),{draft:i,patch:u=>s(d=>{if(d===void 0)return d;const c=structuredClone(d);return u(c),c}),close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const zp=e=>({title:e.title,...e.description===void 0?{}:{description:e.description},...e.columns===void 0?{}:{columns:e.columns},...e.autorun===void 0?{}:{autorun:e.autorun}}),ss=[2,3,4,6,8,12,16,24];function Fp({anchor:e,settings:t,onClose:n,onCommit:r}){const{theme:i}=Be.usePublisherTheme(),{draft:s,patch:o,close:a}=Cd(t,e!==null,r,n),l=s?.columns!==void 0&&!ss.includes(s.columns)?[...ss,s.columns].sort((u,d)=>u-d):ss;return y.jsx(k.Popover,{open:e!==null&&s!==void 0,anchorEl:e,onClose:a,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:380,p:2}}},children:s&&y.jsxs(k.Stack,{sx:{gap:1.5},children:[y.jsx(k.Typography,{variant:"overline",sx:{color:i.tileTitle,lineHeight:1.5},children:"Dashboard"}),y.jsx(k.TextField,{size:"small",label:"Title",value:s.title,autoFocus:!0,inputProps:{"aria-label":"Dashboard title"},onChange:u=>o(d=>{d.title=u.target.value})}),y.jsx(k.TextField,{size:"small",label:"Description",multiline:!0,minRows:3,maxRows:10,value:s.description??"",helperText:"Markdown. A blank line starts a new paragraph.",inputProps:{"aria-label":"Dashboard description"},onChange:u=>o(d=>{const c=u.target.value;c.trim()===""?delete d.description:d.description=c})}),y.jsxs(k.TextField,{select:!0,size:"small",label:"Grid width",value:s.columns??"",helperText:"Columns across the page. Tiles are placed in these.",inputProps:{"aria-label":"Grid width"},onChange:u=>o(d=>{const c=Number(u.target.value);c?d.columns=c:delete d.columns}),children:[y.jsx(k.MenuItem,{value:"",children:"Default (2)"}),l.map(u=>y.jsx(k.MenuItem,{value:u,children:u},u))]}),y.jsx(k.FormControlLabel,{control:y.jsx(k.Switch,{size:"small",checked:s.autorun!==!1,slotProps:{input:{"aria-label":"Run as controls change"}},onChange:u=>o(d=>{u.target.checked?delete d.autorun:d.autorun=!1})}),label:y.jsxs(k.Typography,{variant:"body2",children:["Run as controls change",y.jsx(k.Typography,{component:"span",variant:"caption",sx:{display:"block",opacity:.7},children:"Off, readers press Apply. For a page whose queries are slow."})]})})]})})}const Np=j.createSvgIcon(y.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function Bp({controls:e,tileCount:t,unknownFieldsOf:n,onEdit:r,onAdd:i,children:s}){const{theme:o}=Be.usePublisherTheme();return y.jsx(y.Fragment,{children:y.jsxs(k.Stack,{sx:{gap:1},children:[y.jsxs(k.Stack,{direction:"row","aria-label":"Filters",sx:{gap:1,alignItems:"center",flexWrap:"wrap",minHeight:32},children:[y.jsx(Np,{sx:{fontSize:18,color:o.tileTitle,opacity:.7}}),y.jsx(k.Typography,{variant:"subtitle2",sx:{color:o.tileTitle,mr:.5},children:"Filters"}),e.length===0&&y.jsx(k.Typography,{variant:"body2",sx:{color:o.tileTitle,opacity:.8},children:"None yet."}),e.map(a=>{const l=n(a.name,a.type);return y.jsx(k.Tooltip,{title:l.length>0?`$${a.name} · cannot filter on: ${l.join(", ")}`:`$${a.name} · ${a.origin==="dashboard"?"declared here":"from the model"} · ${a.boundTiles} of ${t} tiles`,children:y.jsx(k.Chip,{size:"small",label:a.label??a.name,"aria-label":`Edit filter ${a.name}`,color:l.length>0?"warning":"default",variant:a.origin==="dashboard"?"filled":"outlined",onClick:()=>r(a),sx:{opacity:a.boundTiles===0?.6:1,cursor:"pointer",transition:"opacity 120ms"}})},a.name)}),y.jsx(k.Box,{sx:{ml:"auto"},children:y.jsx(j.SecondaryButton,{label:"Filter",icon:y.jsx(j.AddIcon,{}),onClick:()=>i(),ariaLabel:"Add filter",ariaHasPopup:"dialog"})})]}),s]})})}const Vp=(e,t)=>e.map((n,r)=>{const i=t[r]??!1;if(i===(n.break??!1))return n;const s={...n};return i?s.break=!0:delete s.break,s}),Gp=(e,t,n)=>{const r=[...e],[i]=r.splice(t,1);if(!i)return[...e];const s=r[t];i.break&&s&&!s.break&&(r[t]={...s,break:!0});const o={...i};return delete o.break,r.splice(n,0,o),r},Pd=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),Md=e=>`gap.${e}`,Up=(e,t)=>{const n=[];let r=0;e.forEach((s,o)=>{const a=Math.min(s.colspan??1,t),l=o===0||s.break===!0||r+a>t;l&&o>0&&r<t&&n.push({kind:"gap",after:pt(e[o-1]),colspan:t-r}),l&&(r=0),n.push(Pd(s,o)),r+=a});const i=e.at(-1);return i&&r<t&&n.push({kind:"gap",after:pt(i),colspan:t-r}),n};var qp=Object.create,Id=Object.defineProperty,Hp=Object.defineProperties,Kp=Object.getOwnPropertyDescriptor,Yp=Object.getOwnPropertyDescriptors,Ei=Object.getOwnPropertySymbols,jd=Object.prototype.hasOwnProperty,Ad=Object.prototype.propertyIsEnumerable,Xp=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ir=e=>{throw TypeError(e)},Ks=(e,t,n)=>t in e?Id(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,os=(e,t)=>{for(var n in t||(t={}))jd.call(t,n)&&Ks(e,n,t[n]);if(Ei)for(var n of Ei(t))Ad.call(t,n)&&Ks(e,n,t[n]);return e},as=(e,t)=>Hp(e,Yp(t)),Qp=(e,t)=>{var n={};for(var r in e)jd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ei)for(var r of Ei(e))t.indexOf(r)<0&&Ad.call(e,r)&&(n[r]=e[r]);return n},Zp=e=>{var t;return[,,,qp((t=void 0)!=null?t:null)]},Rd=["class","method","getter","setter","accessor","field","value","get","set"],ir=e=>e!==void 0&&typeof e!="function"?Ir("Function expected"):e,Jp=(e,t,n,r,i)=>({kind:Rd[e],name:t,metadata:r,addInitializer:s=>n._?Ir("Already initialized"):i.push(ir(s||null))}),eg=(e,t)=>Ks(t,Xp("metadata"),e[3]),Gr=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},Ld=(e,t,n,r,i,s)=>{for(var o,a,l,u,d,c=t&7,h=!1,f=!1,v=e.length+1,p=Rd[c+5],w=e[v-1]=[],x=e[v]||(e[v]=[]),m=(i=i.prototype,Kp({get[n](){return sr(this,s)},set[n](b){return Ft(this,s,b)}},n)),g=r.length-1;g>=0;g--)u=Jp(c,n,l={},e[3],x),u.static=h,u.private=f,d=u.access={has:b=>n in b},d.get=b=>b[n],d.set=(b,_)=>b[n]=_,a=(0,r[g])({get:m.get,set:m.set},u),l._=1,a===void 0?ir(a)&&(m[p]=a):typeof a!="object"||a===null?Ir("Object expected"):(ir(o=a.get)&&(m.get=o),ir(o=a.set)&&(m.set=o),ir(o=a.init)&&w.unshift(o));return m&&Id(i,n,m),i},Wd=(e,t,n)=>t.has(e)||Ir("Cannot "+n),sr=(e,t,n)=>(Wd(e,t,"read from private field"),t.get(e)),Un=(e,t,n)=>t.has(e)?Ir("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ft=(e,t,n,r)=>(Wd(e,t,"write to private field"),t.set(e,n),n);function Bt(e){return e instanceof ta||e instanceof Bd}var Ur=10,tg=class extends Me{constructor(e){super(e);const t=tt(()=>{const{dragOperation:r}=e;if(br(r.activatorEvent)&&Bt(r.source)&&r.status.initialized){const i=e.registry.plugins.get(Pr);if(i)return i.disable(),()=>i.enable()}}),n=e.monitor.addEventListener("dragmove",(r,i)=>{queueMicrotask(()=>{if(this.disabled||r.defaultPrevented||!r.nativeEvent)return;const{dragOperation:s}=i;if(!br(r.nativeEvent)||!Bt(s.source)||!s.shape)return;const{actions:o,collisionObserver:a,registry:l}=i,{by:u}=r;if(!u)return;const d=ng(u),{source:c,target:h}=s,{center:f}=s.shape.current,v=[],p=[];ue(()=>{for(const _ of l.droppables){const{id:$}=_;if(!_.accepts(c)||$===h?.id&&Bt(_)||!_.element)continue;let O=_.shape;const C=new ct(_.element,{getBoundingClientRect:I=>mr(I,void 0,.2)});!C.height||!C.width||(d=="down"&&f.y+Ur<C.center.y||d=="up"&&f.y-Ur>C.center.y||d=="left"&&f.x-Ur>C.center.x||d=="right"&&f.x+Ur<C.center.x)&&(v.push(_),_.shape=C,p.push(()=>_.shape=O))}}),r.preventDefault(),a.disable();const w=a.computeCollisions(v,Gf);ue(()=>p.forEach(_=>_()));const[x]=w;if(!x)return;const{id:m}=x,{index:g,group:b}=c.sortable;o.setDropTarget(m).then(()=>{const{source:_,target:$,shape:O}=s;if(!_||!Bt(_)||!O)return;const{index:C,group:I,target:P}=_.sortable,U=g!==C||b!==I,W=U?P:$?.element;if(!W)return;Mc(W);const M=new ct(W);if(!M)return;const z=dt.delta(M,dt.from(O.current.boundingRectangle),_.alignment);o.move({by:z}),U?o.setDropTarget(_.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function ng(e){const{x:t,y:n}=e;if(t>0)return"right";if(t<0)return"left";if(n>0)return"down";if(n<0)return"up"}var rg=Object.defineProperty,ig=Object.defineProperties,sg=Object.getOwnPropertyDescriptors,za=Object.getOwnPropertySymbols,og=Object.prototype.hasOwnProperty,ag=Object.prototype.propertyIsEnumerable,Fa=(e,t,n)=>t in e?rg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nn=(e,t)=>{for(var n in t||(t={}))og.call(t,n)&&Fa(e,n,t[n]);if(za)for(var n of za(t))ag.call(t,n)&&Fa(e,n,t[n]);return e},rn=(e,t)=>ig(e,sg(t));function lg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function qr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function ls(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function cg(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const l=(g,b)=>g===b||g!==null&&typeof g=="object"&&"id"in g&&g.id===b;if(Array.isArray(e)){const g=e.findIndex(_=>l(_,s.id)),b=e.findIndex(_=>l(_,o.id));if(g===-1||b===-1){if(ls(s)){const _=s.initialIndex,$=s.index;return _===$||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,$)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const _=s.index;if(_!==g)return n(e,g,_)}return n(e,g,b)}const u=Object.entries(e);let d=-1,c,h=-1,f;for(const[g,b]of u)if(d===-1&&(d=b.findIndex(_=>l(_,s.id)),d!==-1&&(c=g)),h===-1&&(h=b.findIndex(_=>l(_,o.id)),h!==-1&&(f=g)),d!==-1&&h!==-1)break;if(d===-1&&ls(s)){const g=s.initialGroup==null?void 0:qr(e,s.initialGroup),b=s.initialIndex,_=s.group==null?void 0:qr(e,s.group),$=s.index;if(g==null||_==null||g===_&&b===$)return"preventDefault"in t&&t.preventDefault(),e;if(g===_)return rn(nn({},e),{[g]:n(e[g],b,$)});const O=e[g][b];return rn(nn({},e),{[g]:[...e[g].slice(0,b),...e[g].slice(b+1)],[_]:[...e[_].slice(0,$),O,...e[_].slice($)]})}if(!s.manager)return e;const{dragOperation:v}=s.manager,p=(i=(r=v.shape)==null?void 0:r.current.center)!=null?i:v.position.current;if(f==null){const g=qr(e,o.id);if(g!=null){const b=o.shape&&p.y>o.shape.center.y?e[g].length:0;f=g,h=b}}if(c==null||f==null||c===f&&d===h){if(c!=null&&c===f&&d===h&&ls(s)){const g=s.group==null?void 0:qr(e,s.group),b=s.group!=null&&g!==c,_=s.index!==d;if(b||_){const $=s.group==null?c:g;if($!=null){if(c===$)return rn(nn({},e),{[c]:n(e[c],d,s.index)});const O=e[c][d];return rn(nn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[$]:[...e[$].slice(0,s.index),O,...e[$].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(c===f)return rn(nn({},e),{[c]:n(e[c],d,h)});const x=o.shape&&Math.round(p.y)>Math.round(o.shape.center.y)?1:0,m=e[c][d];return rn(nn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[f]:[...e[f].slice(0,h+x),m,...e[f].slice(h+x)]})}function dg(e,t){return cg(e,t,lg)}function Na(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function Ba(e,t,n){var r;for(const[i,s]of t)for(const o of s){const a=e.get(o.id);if(o.index!==a||o.group!==i||!((r=n.get(i))!=null&&r.has(o)))return!0}return!1}var Va="__default__",ug=class extends Me{constructor(e){super(e);const t=()=>{const r=new Map;for(const i of e.registry.droppables)if(i instanceof ta){const{sortable:s}=i,{group:o}=s;let a=r.get(o);a||(a=new Set,r.set(o,a)),a.add(s)}return r},n=[e.monitor.addEventListener("dragover",(r,i)=>{if(this.disabled)return;const{dragOperation:s}=i,{source:o,target:a}=s;if(!Bt(o)||!Bt(a)||o.sortable===a.sortable)return;const l=t(),u=Na(l),d=o.sortable.group===a.sortable.group,c=l.get(o.sortable.group),h=d?c:l.get(a.sortable.group);!c||!h||queueMicrotask(()=>{r.defaultPrevented||i.renderer.rendering.then(()=>{var f,v;const p=t();if(Ba(u,l,p))return;const w=o.sortable.element,x=a.sortable.element;if(!x||!w||!d&&a.id===o.sortable.group)return;const m=Hr(c),g=d?m:Hr(h),b=(f=o.sortable.group)!=null?f:Va,_=(v=a.sortable.group)!=null?v:Va,$={[b]:m,[_]:g},O=dg($,r);if($===O)return;const C=O[_].indexOf(o.sortable),I=O[_].indexOf(a.sortable);i.collisionObserver.disable(),Ga(w,C,x,I),ue(()=>{for(const[P,U]of O[b].entries())U.index=P;if(!d)for(const[P,U]of O[_].entries())U.group=a.sortable.group,U.index=P}),i.actions.setDropTarget(o.id).then(()=>i.collisionObserver.enable())})})}),e.monitor.addEventListener("dragend",(r,i)=>{if(!r.canceled)return;const{dragOperation:s}=i,{source:o}=s;Bt(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),l=Na(a),u=a.get(o.sortable.initialGroup);u&&i.renderer.rendering.then(()=>{const d=t();if(Ba(l,a,d))return;const c=Hr(u),h=Hr(u,hg),f=o.sortable.element,v=h.indexOf(o.sortable),p=c[v],w=p?.element;!p||!w||!f||(Ga(f,p.index,w,o.index),ue(()=>{for(const x of a.values()){const m=Array.from(x).values();for(const g of m)g.index=g.initialIndex,g.group=g.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function Ga(e,t,n,r){const i=r<t?"afterend":"beforebegin";n.insertAdjacentElement(i,e)}function fg(e,t){return e.index-t.index}function hg(e,t){return e.initialIndex-t.initialIndex}function Hr(e,t=fg){return Array.from(e).sort(t)}var Ua=[tg,ug],zd={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function qa(e){var t,n;return typeof e=="boolean"?{draggable:e,droppable:e}:{draggable:(t=e?.draggable)!=null?t:!1,droppable:(n=e?.droppable)!=null?n:!1}}var Kr=new Eu,Fd,Nd,Ot,Jo,or,ar,ea,hn;Nd=[K],Fd=[K];var Bi=class{constructor(e,t){Un(this,Jo,Gr(Ot,8,this)),Gr(Ot,11,this),Un(this,or),Un(this,ar),Un(this,ea,Gr(Ot,12,this)),Gr(Ot,15,this),Un(this,hn),this.register=()=>(ue(()=>{var v,p;(v=this.manager)==null||v.registry.register(this.droppable),(p=this.manager)==null||p.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{ue(()=>{var v,p;(v=this.manager)==null||v.registry.unregister(this.droppable),(p=this.manager)==null||p.registry.unregister(this.draggable)})},this.destroy=()=>{ue(()=>{this.droppable.destroy(),this.draggable.destroy()})};var n=e,{effects:r=()=>[],disabled:i,group:s,index:o,sensors:a,type:l,transition:u=zd,plugins:d}=n,c=Qp(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const h=st(d,Ua),f=qa(i);this.droppable=new ta(as(os({},c),{disabled:f.droppable}),t,this),this.draggable=new Bd(as(os({},c),{disabled:f.draggable,plugins:h,effects:()=>[()=>{var v,p,w;const x=(v=this.manager)==null?void 0:v.dragOperation.status;x?.initializing&&this.id===((w=(p=this.manager)==null?void 0:p.dragOperation.source)==null?void 0:w.id)&&Kr.clear(this.manager),x?.dragging&&Kr.set(this.manager,this.id,H(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:v,group:p,manager:w}=this,x=sr(this,ar),m=sr(this,or);(v!==x||p!==m)&&(Ft(this,ar,v),Ft(this,or,p),this.animate())},()=>{var v,p;const{target:w}=this,{isDragSource:x}=this.draggable;((p=(v=this.draggable.pluginConfig(Go))==null?void 0:v.feedback)!=null?p:"default")==="move"&&x&&(this.droppable.disabled=!w)},...r()],type:l,sensors:a}),t,this),Ft(this,hn,c.element),this.manager=t,this.index=o,Ft(this,ar,o),this.group=s,Ft(this,or,s),this.type=l,this.transition=u}get initialIndex(){var e,t;return(t=(e=Kr.get(this.manager,this.id))==null?void 0:e.initialIndex)!=null?t:this.index}get initialGroup(){var e,t;return(t=(e=Kr.get(this.manager,this.id))==null?void 0:e.initialGroup)!=null?t:this.group}animate(){H(()=>{const{manager:e,transition:t}=this,{shape:n}=this.droppable;if(!e)return;const{idle:r}=e.dragOperation.status;!n||!t||r&&!t.idle||e.renderer.rendering.then(()=>{const{element:i}=this;if(!i)return;for(const d of i.getAnimations())"transitionProperty"in d&&(d.transitionProperty==="transform"||d.transitionProperty==="translate"||d.transitionProperty==="scale")&&d.cancel();const s=this.refreshShape();if(!s)return;const o={x:n.boundingRectangle.left-s.boundingRectangle.left,y:n.boundingRectangle.top-s.boundingRectangle.top},{translate:a}=ht(i),l=_a(i,a,!1),u=_a(i,a);if(o.x||o.y){const d=Ro(Ke(i))?as(os({},t),{duration:0}):t;Ic({element:i,keyframes:{translate:[`${l.x+o.x}px ${l.y+o.y}px ${l.z}`,`${u.x}px ${u.y}px ${u.z}`]},options:d}).then(()=>{e.dragOperation.status.dragging||(this.droppable.shape=void 0)})}})})}get manager(){return this.draggable.manager}set manager(e){ue(()=>{this.draggable.manager=e,this.droppable.manager=e})}set element(e){ue(()=>{const t=sr(this,hn),n=this.droppable.element,r=this.draggable.element;(!n||n===t)&&(this.droppable.element=e),(!r||r===t)&&(this.draggable.element=e),Ft(this,hn,e)})}get element(){var e,t;const n=sr(this,hn);if(n)return(t=(e=Os.get(n))!=null?e:n)!=null?t:this.droppable.element}set target(e){this.droppable.element=e}get target(){return this.droppable.element}set source(e){this.draggable.element=e}get source(){return this.draggable.element}get disabled(){const{disabled:e}=this.draggable,{disabled:t}=this.droppable;return e===t?e:{draggable:e,droppable:t}}set plugins(e){this.draggable.plugins=st(e,Ua)}set disabled(e){const t=qa(e);ue(()=>{this.droppable.disabled=t.droppable,this.draggable.disabled=t.draggable})}set data(e){ue(()=>{this.droppable.data=e,this.draggable.data=e})}set handle(e){this.draggable.handle=e}set id(e){this.droppable.id=e,this.draggable.id=e}get id(){return this.droppable.id}set sensors(e){this.draggable.sensors=e}set modifiers(e){this.draggable.modifiers=e}set collisionPriority(e){this.droppable.collisionPriority=e}set collisionDetector(e){this.droppable.collisionDetector=e??jc}set alignment(e){this.draggable.alignment=e}get alignment(){return this.draggable.alignment}set type(e){ue(()=>{this.droppable.type=e,this.draggable.type=e})}get type(){return this.draggable.type}set accept(e){this.droppable.accept=e}get accept(){return this.droppable.accept}get isDropTarget(){return this.droppable.isDropTarget}get isDragSource(){return this.draggable.isDragSource}get isDragging(){return this.draggable.isDragging}get isDropping(){return this.draggable.isDropping}get status(){return this.draggable.status}refreshShape(){return this.droppable.refreshShape()}accepts(e){return this.droppable.accepts(e)}};Ot=Zp();Jo=new WeakMap;or=new WeakMap;ar=new WeakMap;ea=new WeakMap;hn=new WeakMap;Ld(Ot,4,"index",Nd,Bi,Jo);Ld(Ot,4,"group",Fd,Bi,ea);eg(Ot,Bi);var Bd=class extends zi{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get initialIndex(){return this.sortable.initialIndex}get group(){return this.sortable.group}get initialGroup(){return this.sortable.initialGroup}},ta=class extends Fi{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},pg=Object.defineProperty,gg=Object.defineProperties,vg=Object.getOwnPropertyDescriptors,Ha=Object.getOwnPropertySymbols,mg=Object.prototype.hasOwnProperty,yg=Object.prototype.propertyIsEnumerable,Ka=(e,t,n)=>t in e?pg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,cs=(e,t)=>{for(var n in t||(t={}))mg.call(t,n)&&Ka(e,n,t[n]);if(Ha)for(var n of Ha(t))yg.call(t,n)&&Ka(e,n,t[n]);return e},bg=(e,t)=>gg(e,vg(t));function xg(e){const{accept:t,collisionDetector:n,collisionPriority:r,id:i,data:s,element:o,handle:a,index:l,group:u,disabled:d,modifiers:c,sensors:h,target:f,type:v,plugins:p}=e,w=cs(cs({},zd),e.transition),x=vd(g=>new Bi(bg(cs({},e),{transition:w,register:!1,handle:yn(a),element:yn(o),target:yn(f)}),g)),m=fd(x,wg);return le(i,()=>x.id=i),Ln(()=>{ue(()=>{x.group=u,x.index=l})},[x,u,l]),le(v,()=>x.type=v),le(t,()=>x.accept=t,void 0,rt),le(s,()=>s&&(x.data=s)),le(l,()=>{var g;(g=x.manager)!=null&&g.dragOperation.status.idle&&w?.idle&&x.refreshShape()},Wh),si(a,g=>x.handle=g),si(o,g=>x.element=g),si(f,g=>x.target=g),le(d,()=>x.disabled=d??!1,void 0,rt),le(h,()=>x.sensors=h,void 0,rt),le(n,()=>x.collisionDetector=n),le(r,()=>x.collisionPriority=r),le(p,()=>x.plugins=p,void 0,rt),le(w,()=>x.transition=w,void 0,rt),le(c,()=>x.modifiers=c,void 0,rt),le(e.alignment,()=>x.alignment=e.alignment),{sortable:m,get isDragging(){return m.isDragging},get isDropping(){return m.isDropping},get isDragSource(){return m.isDragSource},get isDropTarget(){return m.isDropTarget},handleRef:S.useCallback(g=>{x.handle=g??void 0},[x]),ref:S.useCallback(g=>{var b,_;!g&&((b=x.element)!=null&&b.isConnected)&&!((_=x.manager)!=null&&_.dragOperation.status.idle)||(x.element=g??void 0)},[x]),sourceRef:S.useCallback(g=>{var b,_;!g&&((b=x.source)!=null&&b.isConnected)&&!((_=x.manager)!=null&&_.dragOperation.status.idle)||(x.source=g??void 0)},[x]),targetRef:S.useCallback(g=>{var b,_;!g&&((b=x.target)!=null&&b.isConnected)&&!((_=x.manager)!=null&&_.dragOperation.status.idle)||(x.target=g??void 0)},[x])}}function wg(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const Ys="tile",Vd="gap",_g='[role="separator"]',kg=[Ns.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>(Ns.defaults.preventActivation?.(e,t)??!1)||e.target instanceof Element&&e.target.closest(_g)!==null}),id],Sg=e=>[...e,Go.configure({feedback:"clone"})];function $g({id:e,index:t,children:n}){const{ref:r,handleRef:i,isDragSource:s}=xg({id:e,index:t,type:Ys,accept:Ys,collisionDetector:Wo,plugins:Sg});return y.jsx(y.Fragment,{children:n({ref:r,handleRef:i,isDragSource:s})})}function Eg({id:e,after:t,children:n}){const{ref:r,isDropTarget:i}=cp({id:e,type:Vd,accept:Ys,collisionDetector:Wo,data:{after:t}});return y.jsx(y.Fragment,{children:n({ref:r,isDropTarget:i})})}const Og=j.createSvgIcon(y.jsx("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"})),Tg=j.createSvgIcon(y.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}));function Dg({tile:e,index:t,selected:n,menuOpen:r,resizeSpan:i,columns:s,onSelect:o,onOpenMenu:a,onResizeStart:l,onResizeMove:u,onResizeEnd:d,children:c}){const{theme:h}=Be.usePublisherTheme();return y.jsx($g,{id:pt(e),index:t,children:({ref:f,handleRef:v,isDragSource:p})=>y.jsxs(k.Box,{ref:f,onClick:o,onPointerDown:w=>{w.button===0&&o()},"aria-label":`Tile ${e.name}`,"aria-current":n,sx:{position:"relative",display:"grid",minWidth:0,cursor:"grab",borderRadius:1,outline:n?`2px solid ${h.drillLink}`:"2px solid transparent",outlineOffset:2,transition:"outline-color 120ms, opacity 120ms, box-shadow 120ms","&&[data-dnd-dragging]":{opacity:1,outline:"none",boxShadow:"0 12px 32px rgba(0, 0, 0, 0.22)"},"&&[data-dnd-placeholder]":{opacity:.45,outline:`2px dashed ${h.drillLink}`,boxShadow:"none"},"&:hover .builder-affordance, &:focus-within .builder-affordance":{opacity:1},"&:hover":{outlineColor:n?h.drillLink:h.cardBorder,boxShadow:"0 2px 10px rgba(0, 0, 0, 0.10)"}},children:[c,y.jsx(k.Box,{ref:v,className:"builder-affordance","aria-label":`Move ${e.label??e.name}`,sx:{position:"absolute",top:"2px",left:"2px",display:"grid",placeItems:"center",width:"22px",height:"22px",borderRadius:"4px",cursor:"grab",touchAction:"none",zIndex:2,color:h.tileTitle,bgcolor:h.tile,opacity:p||n?.9:0,transition:"opacity 120ms","&:hover":{opacity:1},"&:active":{cursor:"grabbing"},"&:focus-visible":{opacity:1,outline:`2px solid ${h.drillLink}`,outlineOffset:1}},children:y.jsx(Og,{sx:{fontSize:16}})}),i===void 0&&y.jsx(k.IconButton,{className:"builder-affordance",size:"small","aria-label":`Settings for ${e.label??e.name}`,onClick:w=>{w.stopPropagation(),a(w.currentTarget)},sx:{position:"absolute",top:"2px",right:"2px",width:22,height:22,zIndex:2,color:h.tileTitle,bgcolor:h.tile,opacity:n||r?.9:0,transition:"opacity 120ms","&:hover":{opacity:1,bgcolor:h.tile}},children:y.jsx(Tg,{sx:{fontSize:16}})}),i!==void 0&&y.jsxs(k.Box,{"aria-hidden":!0,sx:{position:"absolute",top:"6px",right:"6px",px:.75,py:.25,borderRadius:"4px",bgcolor:h.drillLink,color:h.tile,fontSize:11,fontVariantNumeric:"tabular-nums",zIndex:4,pointerEvents:"none"},children:[i," of ",s," ·"," ",Math.round(i/s*100),"%"]}),e.declaration.kind!=="inherited"&&y.jsx(k.Box,{className:"builder-affordance",role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label??e.name}`,onPointerDown:l,onPointerMove:u,onPointerUp:d,onPointerCancel:d,sx:{position:"absolute",top:0,bottom:0,right:"-5px",width:"10px",cursor:"col-resize",touchAction:"none",zIndex:1,opacity:i!==void 0||n?1:0,transition:"opacity 120ms","&:hover":{opacity:1},"&::after":{content:'""',position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"4px",height:"28px",borderRadius:"2px",bgcolor:h.drillLink}}})]})})}function Cg({tile:e}){const{theme:t}=Be.usePublisherTheme();return y.jsxs(j.TileCard,{sx:{minHeight:140},children:[y.jsx(j.TileHeading,{title:e.label??e.name,subtitle:e.subtitle}),y.jsxs(k.Typography,{variant:"caption",sx:{display:"block",color:t.tileTitle,opacity:.7},children:[e.source," → ",e.name]})]})}function Pg({after:e}){const{theme:t}=Be.usePublisherTheme();return y.jsx(Eg,{id:Md(e),after:e,children:({ref:n,isDropTarget:r})=>y.jsx(k.Box,{ref:n,"aria-hidden":!0,sx:{minHeight:48,borderRadius:1,border:`1px dashed ${t.drillLink}`,bgcolor:r?`color-mix(in srgb, ${t.drillLink} 12%, transparent)`:"transparent",opacity:r?.95:.4,transition:"opacity 120ms, background-color 120ms"}})})}function Mg({columns:e}){const{theme:t}=Be.usePublisherTheme();return y.jsx(k.Box,{"aria-hidden":!0,sx:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3,display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,gap:`${j.GRID_GAP_PX}px`},children:Array.from({length:e},(n,r)=>y.jsx(k.Box,{sx:{borderLeft:`1px dashed ${t.drillLink}`,borderRight:r===e-1?`1px dashed ${t.drillLink}`:"none",opacity:.35}},r))})}var Ig=Object.defineProperty,jg=Object.defineProperties,Ag=Object.getOwnPropertyDescriptors,Ya=Object.getOwnPropertySymbols,Rg=Object.prototype.hasOwnProperty,Lg=Object.prototype.propertyIsEnumerable,Xa=(e,t,n)=>t in e?Ig(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t)=>{for(var n in t||(t={}))Rg.call(t,n)&&Xa(e,n,t[n]);if(Ya)for(var n of Ya(t))Lg.call(t,n)&&Xa(e,n,t[n]);return e},on=(e,t)=>jg(e,Ag(t));function Wg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Yr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function ds(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function zg(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const l=(g,b)=>g===b||g!==null&&typeof g=="object"&&"id"in g&&g.id===b;if(Array.isArray(e)){const g=e.findIndex(_=>l(_,s.id)),b=e.findIndex(_=>l(_,o.id));if(g===-1||b===-1){if(ds(s)){const _=s.initialIndex,$=s.index;return _===$||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,$)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const _=s.index;if(_!==g)return n(e,g,_)}return n(e,g,b)}const u=Object.entries(e);let d=-1,c,h=-1,f;for(const[g,b]of u)if(d===-1&&(d=b.findIndex(_=>l(_,s.id)),d!==-1&&(c=g)),h===-1&&(h=b.findIndex(_=>l(_,o.id)),h!==-1&&(f=g)),d!==-1&&h!==-1)break;if(d===-1&&ds(s)){const g=s.initialGroup==null?void 0:Yr(e,s.initialGroup),b=s.initialIndex,_=s.group==null?void 0:Yr(e,s.group),$=s.index;if(g==null||_==null||g===_&&b===$)return"preventDefault"in t&&t.preventDefault(),e;if(g===_)return on(sn({},e),{[g]:n(e[g],b,$)});const O=e[g][b];return on(sn({},e),{[g]:[...e[g].slice(0,b),...e[g].slice(b+1)],[_]:[...e[_].slice(0,$),O,...e[_].slice($)]})}if(!s.manager)return e;const{dragOperation:v}=s.manager,p=(i=(r=v.shape)==null?void 0:r.current.center)!=null?i:v.position.current;if(f==null){const g=Yr(e,o.id);if(g!=null){const b=o.shape&&p.y>o.shape.center.y?e[g].length:0;f=g,h=b}}if(c==null||f==null||c===f&&d===h){if(c!=null&&c===f&&d===h&&ds(s)){const g=s.group==null?void 0:Yr(e,s.group),b=s.group!=null&&g!==c,_=s.index!==d;if(b||_){const $=s.group==null?c:g;if($!=null){if(c===$)return on(sn({},e),{[c]:n(e[c],d,s.index)});const O=e[c][d];return on(sn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[$]:[...e[$].slice(0,s.index),O,...e[$].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(c===f)return on(sn({},e),{[c]:n(e[c],d,h)});const x=o.shape&&Math.round(p.y)>Math.round(o.shape.center.y)?1:0,m=e[c][d];return on(sn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[f]:[...e[f].slice(0,h+x),m,...e[f].slice(h+x)]})}function Fg(e,t){return zg(e,t,Wg)}function Ng({tiles:e,commit:t,onLanded:n}){const[r,i]=S.useState(void 0),s=S.useRef(void 0),[o,a]=S.useState(!1);return{dragging:o,preview:r,onDragStart:()=>{a(!0),s.current=e},onDragOver:c=>{const{source:h,target:f}=c.operation;if(!h||!f)return;const v=s.current??e;let p;if(f.type===Vd){const{after:w}=f.data,x=v.findIndex(b=>pt(b)===h.id);if(x<0||w===h.id)return;const g=v.filter((b,_)=>_!==x).findIndex(b=>pt(b)===w)+1;p=Gp(v,x,g)}else{const w=v.map(pt),x=Fg(w,c);if(x.every((g,b)=>g===w[b]))return;const m=new Map(v.map(g=>[pt(g),g]));p=Vp(x.map(g=>m.get(g)),e.map(g=>g.break??!1))}s.current=p,i(p)},onDragEnd:c=>{a(!1);const h=s.current;if(s.current=void 0,i(void 0),c.canceled||!h)return;t(h);const f=h.findIndex(v=>pt(v)===c.operation.source?.id);f>=0&&n(f)}}}const Qa=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function Bg({tiles:e,columns:t,onStart:n,commit:r}){const[i,s]=S.useState(void 0),o=S.useRef(null);return{resize:i,gridBox:o,startResize:(d,c)=>{const h=o.current?.getBoundingClientRect(),f=d.currentTarget.parentElement?.getBoundingClientRect();!h||!f||(d.stopPropagation(),d.preventDefault(),d.currentTarget.setPointerCapture(d.pointerId),Qa(!0),n(c),s({index:c,span:e[c]?.colspan??1,left:f.left,track:(h.width-j.GRID_GAP_PX*(t-1))/t}))},onResize:d=>{if(!i)return;const c=d.clientX-i.left,h=Math.round((c+j.GRID_GAP_PX)/(i.track+j.GRID_GAP_PX)),f=Math.min(Math.max(h,1),t);f!==i.span&&s({...i,span:f})},endResize:d=>{if(d.currentTarget.hasPointerCapture(d.pointerId)&&d.currentTarget.releasePointerCapture(d.pointerId),Qa(!1),!i)return;const{index:c,span:h}=i;s(void 0),r(c,h)}}}function Vg({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:i,columns:s,onDrills:o}){const{theme:a}=Be.usePublisherTheme(),{draft:l,patch:u,close:d,discard:c}=Cd(t,e!==null,r,n),h=l!==void 0&&l.declaration.kind!=="inherited";return y.jsx(k.Popover,{open:e!==null&&l!==void 0,anchorEl:e,onClose:d,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:l&&y.jsxs(k.Stack,{sx:{gap:1.5},children:[y.jsxs(k.Typography,{variant:"overline",sx:{color:a.tileTitle,lineHeight:1.5},children:[l.source," → ",l.name]}),h?y.jsxs(y.Fragment,{children:[y.jsx(k.TextField,{size:"small",label:"Title",value:l.label??"",autoFocus:!0,inputProps:{"aria-label":"Tile title"},onChange:f=>u(v=>{const p=f.target.value;p===""?delete v.label:v.label=p})}),y.jsx(k.TextField,{size:"small",label:"Subtitle",value:l.subtitle??"",inputProps:{"aria-label":"Tile subtitle"},onChange:f=>u(v=>{const p=f.target.value;p===""?delete v.subtitle:v.subtitle=p})}),y.jsxs(k.Stack,{direction:"row",sx:{gap:.5,alignItems:"center"},children:[y.jsx(k.Typography,{variant:"caption",sx:{color:a.tileTitle,mr:.5},children:"Width"}),[["Full",1],["½",2],["⅓",3],["¼",4]].map(([f,v])=>{const p=Math.max(1,Math.round(s/v)),w=(l.colspan??1)===p;return y.jsx(k.Button,{size:"small",variant:w?"contained":"outlined","aria-label":`Width ${f}`,"aria-pressed":w,onClick:()=>u(x=>{x.colspan=p}),sx:{minWidth:40,px:1},children:f},f)})]})]}):y.jsx(k.Typography,{variant:"body2",sx:{color:a.tileTitle},children:"Declared on its source, so its title and layout are set in the model. It can still be moved."}),l?.declaration.kind==="opaque"&&y.jsxs(k.Typography,{variant:"body2",sx:{color:a.tileTitle},children:["Its body is ",l.declaration.why,", so a filter has no single place to go. Everything else here is editable."]}),y.jsx(k.Divider,{}),y.jsxs(k.Stack,{direction:"row",sx:{justifyContent:"space-between"},children:[h?y.jsx(k.Button,{size:"small",onClick:()=>{d(),o()},children:"Clickable cells…"}):y.jsx("span",{}),y.jsx(k.Button,{color:"error",size:"small",onClick:()=>{c(),i()},children:"Remove tile"})]})]})})}const Gd=e=>e.ok===!1,me=(e,...t)=>t.every(n=>typeof e?.[n]=="function"),Vi=e=>e!==void 0&&e.ruleIndex!==void 0&&(e.childCount??0)>0,de={sourceDefinition:e=>me(e,"sourceNameDef","isDefine","sqExplore"),exploreQueryDef:e=>me(e,"exploreQueryNameDef","isDefine","vExpr"),defExploreQuery:e=>me(e,"VIEW","subQueryDefList"),defDimension:e=>me(e,"defList","DIMENSION"),exploreProperties:e=>me(e,"exploreStatement","OCURLY","CCURLY"),queryProperties:e=>me(e,"queryStatement","OCURLY","CCURLY"),queryStatement:e=>me(e,"whereStatement","aggregateStatement","nestStatement"),whereStatement:e=>me(e,"WHERE","filterClauseList"),givenDef:e=>me(e,"givenNameDef"),givenStatement:e=>me(e,"GIVEN","givenDefList"),importStatement:e=>me(e,"IMPORT","importURL"),vArrow:e=>me(e,"ARROW","vExpr","segExpr"),segRefine:e=>me(e,"PLUS","segExpr"),segOps:e=>me(e,"queryProperties"),segField:e=>me(e,"fieldPath")&&!me(e,"segExpr"),segParen:e=>me(e,"OPAREN","CPAREN","vExpr"),compare:e=>me(e,"fieldExpr","compareOp"),givenRef:e=>me(e,"GIVEN_REF")};function Gg(e){const t=new Int32Array([...e].length+1);let n=0;for(let r=0;r<e.length;)t[n++]=r,r+=e.codePointAt(r)>65535?2:1;return t[n]=e.length,t}function Ug(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
`
|
|
73
|
-
|
|
74
|
-
`)
|
|
75
|
-
|
|
76
|
-
`
|
|
77
|
-
|
|
78
|
-
`})}
|
|
79
|
-
`).
|
|
80
|
-
`),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
`:"")
|
|
85
|
-
|
|
86
|
-
|
|
67
|
+
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function lp(e,t="hidden"){return he(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=cp(n,r.registry.droppables),i=[],o=rh(n),{remove:a}=o;return dp(s,o,i),up(o,t),o.remove=()=>{i.forEach(l=>l()),a.call(o)},o})}function cp(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${es}${co("dom-id")}`;r.element.setAttribute(s,""),n.set(r,s)}return n}function dp(e,t,n){for(const[r,s]of e){if(!r.element)continue;const i=`[${s}]`,o=t.matches(i)?t:t.querySelector(i);if(r.element.removeAttribute(s),!o)continue;const a=r.element;r.proxy=o,o.removeAttribute(s),io.set(a,o),n.push(()=>{io.delete(a),r.proxy=void 0})}}function up(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Hs,t)}function Ld(e,t){return e===t?!0:qn(e)===qn(t)}function tl(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&gn(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>Ln(t))}function po(e){return e.tagName==="TR"}function fp(e,t,n){const r=new MutationObserver(s=>{let i=!1;for(const o of s){if(o.target!==e){i=!0;continue}if(o.type!=="attributes")continue;const a=o.attributeName;if(a.startsWith("aria-")||ip.includes(a))continue;const l=e.getAttribute(a);if(a==="style"){if(Ar(e)&&Ar(t)){const u=e.style;for(const c of Array.from(t.style))u.getPropertyValue(c)===""&&t.style.removeProperty(c);for(const c of Array.from(u)){if(op.includes(c)||c.startsWith(Ve))continue;const d=u.getPropertyValue(c);t.style.setProperty(c,d)}}}else l!==null?t.setAttribute(a,l):t.removeAttribute(a)}i&&n&&t.replaceChildren(...e.cloneNode(!0).childNodes)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function hp(e,t,n){const r=new MutationObserver(s=>{for(const i of s)if(i.addedNodes.length!==0)for(const o of Array.from(i.addedNodes)){if(o.contains(e)&&e.nextElementSibling!==t){e.insertAdjacentElement("afterend",t),Ln(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),Ln(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement("afterend",t),Ln(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function pp(e){return new ResizeObserver(()=>{var t,n,r;const s=new _t(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),i=(t=e.transformOrigin)!=null?t:{x:1,y:1},o=(e.width-s.width)*i.x+e.delta.x,a=(e.height-s.height)*i.y+e.delta.y,l=fd();if(e.styles.set({width:s.width-e.widthOffset,height:s.height-e.heightOffset,top:e.top+a+l.y,left:e.left+o+l.x},Ve),(n=e.getElementMutationObserver())==null||n.takeRecords(),po(e.element)&&po(e.placeholder)){const g=Array.from(e.element.cells),x=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(g.map(k=>k.style.width));for(const[k,b]of g.entries()){const h=x[k];b.style.width=`${h.getBoundingClientRect().width}px`}}const u=(r=e.getTranslate())!=null?r:{x:0,y:0},c=e.left+o+l.x+u.x,d=e.top+a+l.y+u.y,f=s.width-e.widthOffset,p=s.height-e.heightOffset,m=e.frameTransform;e.dragOperation.shape=new St(c*m.scaleX+m.x,d*m.scaleY+m.y,f*m.scaleX,p*m.scaleY)})}var gp=250,mp="ease";function vp(e){var t,n,r,s;const{animation:i}=e;if(typeof i=="function"){const b=i({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(b).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=gp,easing:a=mp}=i??{};Ln(e.feedbackElement);const[,l]=(t=cd(e.feedbackElement,b=>"translate"in b))!=null?t:[];l?.pause();const u=(n=e.placeholder)!=null?n:e.element,c={frameTransform:Ld(e.feedbackElement,u)?null:void 0},d=new _t(e.feedbackElement,c),f=(r=Nr(Ot(e.feedbackElement).translate))!=null?r:e.translate,p=new _t(u,c),m=St.delta(d,p,e.alignment),g={x:f.x-m.x,y:f.y-m.y},x=Math.round(d.intrinsicHeight)!==Math.round(p.intrinsicHeight)?{minHeight:[`${d.intrinsicHeight}px`,`${p.intrinsicHeight}px`],maxHeight:[`${d.intrinsicHeight}px`,`${p.intrinsicHeight}px`]}:{},k=Math.round(d.intrinsicWidth)!==Math.round(p.intrinsicWidth)?{minWidth:[`${d.intrinsicWidth}px`,`${p.intrinsicWidth}px`],maxWidth:[`${d.intrinsicWidth}px`,`${p.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Ve),e.feedbackElement.setAttribute(ho,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),kd({element:e.feedbackElement,keyframes:ma(zr(zr({},x),k),{translate:[`${f.x}px ${f.y}px 0`,`${g.x}px ${g.y}px 0`]}),options:{duration:fa(ot(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(ho),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Nd,go,Wr,ya,Is,Fd,zd,Vn=class extends(go=Ze,Nd=[pe],go){constructor(t,n){super(t,n),Me(this,Is),Me(this,ya,ze(Wr,8,this)),ze(Wr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(ui),s=r?.register(ap);if(s){const i=this.destroy.bind(this);this.destroy=()=>{s(),i()}}this.registerEffect(mn(this,Is,Fd).bind(this,r)),this.registerEffect(mn(this,Is,zd))}};Wr=rr(go);ya=new WeakMap;Is=new WeakSet;Fd=function(e){const{overlay:t}=this;if(!t||!e)return;const n=Ws(t);if(n)return e.addRoot(n)};zd=function(){var e,t,n,r,s,i,o;const{state:a,manager:l,options:u}=this,{dragOperation:c}=l,{position:d,source:f,status:p}=c;if(p.idle){a.current={},a.initial={};return}if(!f)return;const{element:m}=f,g=f.pluginConfig(Vn),x=(t=(e=g?.feedback)!=null?e:u?.feedback)!=null?t:"default",k=typeof x=="function"?x(f,l):x;if(!m||k==="none"||!p.initialized||p.initializing)return;const{initial:b}=a,h=(n=this.overlay)!=null?n:m,y=Gn(h),w=Gn(m),D=!Ld(m,h),T=new _t(m,{frameTransform:D?w:null,ignoreTransforms:!D}),A={x:w.scaleX/y.scaleX,y:w.scaleY/y.scaleY};let{width:I,height:C,top:W,left:F}=T;D&&(I=I/A.x,C=C/A.y);const G=new Rh(h),J=Ot(m),{transition:Q,translate:se,boxSizing:ce,paddingBlockStart:te,paddingBlockEnd:ue,paddingInlineStart:E,paddingInlineEnd:U,borderInlineStartWidth:B,borderInlineEndWidth:R,borderBlockStartWidth:q,borderBlockEndWidth:N}=J,Y=Q.split(",").filter(O=>!/^\s*(transform|translate|scale)\b/.test(O)).join(","),V=di(J),$=J.transform,j=k==="clone",z=ce==="content-box",X=z?parseInt(E)+parseInt(U)+parseInt(B)+parseInt(R):0,ie=z?parseInt(te)+parseInt(ue)+parseInt(q)+parseInt(N):0,Z=k!=="move"&&!this.overlay?lp(f,j?"clone":"hidden"):null,le=he(()=>Fr(l.dragOperation.activatorEvent));if(!b.translate){if(this.overlay&&V)b.translate={x:V.x,y:V.y};else if(se!=="none"){const O=Nr(se);O&&(b.translate=O)}}if(!b.transformOrigin){const O=he(()=>d.current),M=F+((r=V?.x)!=null?r:0),H=W+((s=V?.y)!=null?s:0);b.transformOrigin={x:(O.x-M*y.scaleX-y.x)/(I*y.scaleX),y:(O.y-H*y.scaleY-y.y)/(C*y.scaleY)}}const{transformOrigin:me}=b,re=W*y.scaleY+y.y,ve=F*y.scaleX+y.x;if(!b.coordinates&&(b.coordinates={x:ve,y:re},A.x!==1||A.y!==1)){const{scaleX:O,scaleY:M}=w,{x:H,y:ee}=me;b.coordinates.x+=(I*O-I)*H,b.coordinates.y+=(C*M-C)*ee}b.dimensions||(b.dimensions={width:I,height:C}),b.frameTransform||(b.frameTransform=y);const de={x:b.coordinates.x-ve,y:b.coordinates.y-re},Ae={width:(b.dimensions.width*b.frameTransform.scaleX-I*y.scaleX)*me.x,height:(b.dimensions.height*b.frameTransform.scaleY-C*y.scaleY)*me.y},We={x:de.x/y.scaleX+Ae.width,y:de.y/y.scaleY+Ae.height},P={left:F+We.x,top:W+We.y};h.setAttribute(kt,"true");const K=he(()=>c.transform),ne=(i=b.translate)!=null?i:{x:0,y:0},fe=K.x*y.scaleX+ne.x,Re=K.y*y.scaleY+ne.y,Et=fd();G.set({width:I-X,height:C-ie,top:P.top+Et.y,left:P.left+Et.x,translate:`${fe}px ${Re}px 0`,transform:this.overlay?"none":$,transition:Y?`${Y}, translate 0ms linear`:"translate 0ms linear",scale:D?`${A.x} ${A.y}`:"","transform-origin":`${me.x*100}% ${me.y*100}%`},Ve),Z&&(m.insertAdjacentElement("afterend",Z),u?.rootElement&&(typeof u.rootElement=="function"?u.rootElement(f):u.rootElement).appendChild(m)),ao(h)&&(h.hasAttribute("popover")||h.setAttribute("popover","manual"),Ln(h),h.addEventListener("beforetoggle",tl));let Be,Ft,at;const Ct=pp({placeholder:Z,element:m,feedbackElement:h,frameTransform:y,transformOrigin:me,width:I,height:C,top:W,left:F,widthOffset:X,heightOffset:ie,delta:We,styles:G,dragOperation:c,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>Be,getSavedCellWidths:()=>at,setSavedCellWidths:O=>{at=O}}),Zt=new _t(h);he(()=>c.shape=Zt);const zt=ot(h),It=O=>{this.manager.actions.stop({event:O})},Qt=fa(zt);le&&zt.addEventListener("resize",It),he(()=>f.status)==="idle"&&requestAnimationFrame(()=>f.status="dragging"),Z&&(Ct.observe(Z),Be=fp(m,Z,j),Ft=hp(m,Z,h));const lt=(o=l.dragOperation.source)==null?void 0:o.id,ir=()=>{var O;if(!le||lt==null)return;const M=l.registry.draggables.get(lt),H=(O=M?.handle)!=null?O:M?.element;Yt(H)&&H.focus()},Dt=()=>{Be?.disconnect(),Ft?.disconnect(),Ct.disconnect(),zt.removeEventListener("resize",It),ao(h)&&(h.removeEventListener("beforetoggle",tl),h.removeAttribute("popover")),h.removeAttribute(kt),G.reset();const O=()=>{var M;if(at&&po(m)){const Ee=Array.from(m.cells);for(const[_e,Se]of Ee.entries())Se.style.width=(M=at[_e])!=null?M:""}f.status="idle";const H=a.current.translate!=null,ee=c.status.dragging;Z&&(!ee&&H||Z.parentElement!==h.parentElement)&&h.isConnected&&Z.replaceWith(h),Z?.remove()};h===this.overlay?setTimeout(O,0):O()},Jt=u?.dropAnimation,en=this,or=Yr(()=>{var O,M,H;const{transform:ee,status:Ee}=c;if(!(!ee.x&&!ee.y&&!a.current.translate)&&Ee.dragging){const _e=(O=b.translate)!=null?O:{x:0,y:0},Se={x:ee.x/y.scaleX+_e.x,y:ee.y/y.scaleY+_e.y},mt=a.current.translate,as=he(()=>c.modifiers),ar=he(()=>{var tn;return(tn=c.shape)==null?void 0:tn.current}),At=u?.keyboardTransition,lr=le&&!Qt&&At!==null?`${(M=At?.duration)!=null?M:250}ms ${(H=At?.easing)!=null?H:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(G.set({transition:Y?`${Y}, translate ${lr}`:`translate ${lr}`,translate:`${Se.x}px ${Se.y}px 0`},Ve),Be?.takeRecords(),ar&&ar!==Zt&&mt&&!as.length){const tn=dt.delta(Se,mt);c.shape=St.from(ar.boundingRectangle).translate(tn.x*y.scaleX,tn.y*y.scaleY)}else c.shape=new _t(h);a.current.translate=Se}},function(){if(c.status.dropped){this.dispose(),f.status="dropping";const O=g?.dropAnimation!==void 0?g.dropAnimation:en.dropAnimation!==void 0?en.dropAnimation:Jt;let M=a.current.translate;const H=M!=null;if(!M&&m!==h&&(M={x:0,y:0}),!M||O===null){Dt();return}l.renderer.rendering.then(()=>{vp({source:f,element:m,feedbackElement:h,placeholder:Z,translate:M,moved:H,transition:Q,alignment:f.alignment,styles:G,animation:O??void 0,getElementMutationObserver:()=>Be,cleanup:Dt,restoreFocus:ir})})}});return()=>{Dt(),or()}};gt(Wr,4,"overlay",Nd,Vn,ya);wn(Wr,Vn);Vn.configure=Zr(Vn);var xa=Vn,cr=!0,bp=!1,Wd,Bd,qd,Gd,Gt,wa,ka;Gd=(qd=[pe],ut.Forward),Bd=(Wd=[pe],ut.Reverse);var Br=class{constructor(){Me(this,wa,ze(Gt,8,this,cr)),ze(Gt,11,this),Me(this,ka,ze(Gt,12,this,cr)),ze(Gt,15,this)}isLocked(e){return e===ut.Idle?!1:e==null?this[ut.Forward]===cr&&this[ut.Reverse]===cr:this[e]===cr}unlock(e){e!==ut.Idle&&(this[e]=bp)}};Gt=rr(null);wa=new WeakMap;ka=new WeakMap;gt(Gt,4,Gd,qd,Br,wa);gt(Gt,4,Bd,Wd,Br,ka);wn(Gt,Br);var yp=[ut.Forward,ut.Reverse],nl=class{constructor(){this.x=new Br,this.y=new Br}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},xp=class extends Ze{constructor(e){super(e);const t=Kn(new nl);let n=null;this.signal=t,pt(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new nl;return}const{delta:s}=e.dragOperation.position;if(n){const i={x:rl(s.x,n.x),y:rl(s.y,n.y)},o=t.peek();De(()=>{for(const a of yc)for(const l of yp)i[a]===l&&o[a].unlock(l);t.value=o})}n=s})}get current(){return this.signal.peek()}};function rl(e,t){return Math.sign(e-t)}var Ud,mo,qr,_a,Bt,vo,ts=class extends(mo=Qr,Ud=[pe],mo){constructor(e){super(e),Me(this,_a,ze(qr,8,this,!1)),ze(qr,11,this),Me(this,Bt),Me(this,vo,()=>{if(!ke(this,Bt))return;const{element:i,by:o}=ke(this,Bt);o.y&&(i.scrollTop+=o.y),o.x&&(i.scrollLeft+=o.x)}),this.scroll=(i,o)=>{var a;if(this.disabled)return!1;const l=this.getScrollableElements();if(!l)return et(this,Bt,void 0),!1;const{position:u}=this.manager.dragOperation,c=u?.current;if(c){const{by:d}=i??{},f=d?{x:sl(d.x),y:sl(d.y)}:void 0,p=f?void 0:this.scrollIntentTracker.current;if(p?.isLocked())return!1;for(const m of l){const g=mh(m,d);if(g.x||g.y){const{speed:x,direction:k}=Oh(m,c,f,o?.acceleration,o?.threshold);if(p)for(const b of yc)p[b].isLocked(k[b])&&(x[b]=0,k[b]=0);if(k.x||k.y){const{x:b,y:h}=d??k,y=b*x.x,w=h*x.y;if(y||w){const D=(a=ke(this,Bt))==null?void 0:a.by;if(this.autoScrolling&&D&&(D.x&&!y||D.y&&!w))continue;return et(this,Bt,{element:m,by:{x:y,y:w}}),Gs.schedule(ke(this,vo)),!0}}}}}return et(this,Bt,void 0),!1};let t=null,n=null;const r=Ui(()=>{const{position:i,source:o}=e.dragOperation;if(!i)return null;const a=hd(Ws(o?.element),i.current);return a&&(t=a),a??t}),s=Ui(()=>{const i=r.value,{documentElement:o}=tr(i);if(!i||i===o){const{target:a}=e.dragOperation,l=a?.element;if(l){const u=lo(l,{excludeElement:!1});return n=u,u}}if(i){const a=lo(i,{excludeElement:!1});return this.autoScrolling&&n&&a.size<n?.size?n:(n=a,a)}return n=null,null},vt);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new xp(e),this.destroy=e.monitor.addEventListener("dragmove",i=>{this.disabled||i.defaultPrevented||!Fr(e.dragOperation.activatorEvent)||!i.by||this.scroll({by:i.by})&&i.preventDefault()})}};qr=rr(mo);_a=new WeakMap;Bt=new WeakMap;vo=new WeakMap;gt(qr,4,"autoScrolling",Ud,ts,_a);wn(qr,ts);function sl(e){return e>0?ut.Forward:e<0?ut.Reverse:ut.Idle}var wp=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:t,resolvers:n}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const r of t)r();for(const r of n)r()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(t=>this.resolvers.add(t))}},kp=new wp(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),_p=10,bo=class extends Ze{constructor(t,n){super(t,n);const r=t.registry.plugins.get(ts);if(!r)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=pt(()=>{var s,i,o;if(this.disabled)return;const{position:a,status:l}=t.dragOperation;if(l.dragging){const u={acceleration:(s=this.options)==null?void 0:s.acceleration,threshold:typeof((i=this.options)==null?void 0:i.threshold)=="number"?{x:this.options.threshold,y:this.options.threshold}:(o=this.options)==null?void 0:o.threshold};if(r.scroll(void 0,u)){r.autoScrolling=!0;const d=setInterval(()=>kp.schedule(()=>r.scroll(void 0,u)),_p);return()=>{clearInterval(d)}}else r.autoScrolling=!1}})}};bo.configure=Zr(bo);var Vd=bo,il={capture:!0,passive:!0},kr,Sp=class extends Qr{constructor(e){super(e),Me(this,kr),this.handleScroll=()=>{ke(this,kr)==null&&et(this,kr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),et(this,kr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=pt(()=>{var n,r,s;if(t.status.dragging){const o=(s=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?s:document;return o.addEventListener("scroll",this.handleScroll,il),()=>{o.removeEventListener("scroll",this.handleScroll,il)}}})}};kr=new WeakMap;var $p="* { user-select: none !important; -webkit-user-select: none !important; }",Tp=class extends Ze{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(ui),n=t?.register($p);if(this.destroy=pt(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return $i(),document.addEventListener("selectionchange",$i,{capture:!0}),()=>{document.removeEventListener("selectionchange",$i,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function $i(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var _r=Object.freeze({offset:10,keyboardCodes:{start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter","Tab"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},preventActivation(e,t){var n;const r=(n=t.handle)!=null?n:t.element;return e.target!==r}}),Dn,Ys=class extends Wn{constructor(t,n){super(t),this.manager=t,this.options=n,Me(this,Dn,[]),this.listeners=new pd,this.handleSourceKeyDown=(r,s,i)=>{if(this.disabled||r.defaultPrevented||!gn(r.target)||s.disabled)return;const{keyboardCodes:o=_r.keyboardCodes,preventActivation:a=_r.preventActivation}=i??{};o.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(a?.(r,s)||this.handleStart(r,s,i))}}bind(t,n=this.options){return pt(()=>{var s;const i=(s=t.handle)!=null?s:t.element,o=a=>{Fr(a)&&this.handleSourceKeyDown(a,t,n)};if(i)return i.addEventListener("keydown",o),()=>{i.removeEventListener("keydown",o)}})}handleStart(t,n,r){const{element:s}=n;if(!s)throw new Error("Source draggable does not have an associated element");t.preventDefault(),t.stopImmediatePropagation(),wd(s);const{center:i}=new _t(s);if(this.manager.actions.start({event:t,coordinates:{x:i.x,y:i.y},source:n}).signal.aborted)return this.cleanup();this.sideEffects();const a=tr(s),l=[this.listeners.bind(a,[{type:"keydown",listener:u=>this.handleKeyDown(u,n,r),options:{capture:!0}}])];ke(this,Dn).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:s=_r.keyboardCodes}=r??{};if(kn(t,[...s.end,...s.cancel])){t.preventDefault();const i=kn(t,s.cancel);this.handleEnd(t,i);return}kn(t,s.up)?this.handleMove("up",t):kn(t,s.down)&&this.handleMove("down",t),kn(t,s.left)?this.handleMove("left",t):kn(t,s.right)&&this.handleMove("right",t)}handleEnd(t,n){this.manager.actions.stop({event:t,canceled:n}),this.cleanup()}handleMove(t,n){var r,s;const{shape:i}=this.manager.dragOperation,o=n.shiftKey?5:1;let a={x:0,y:0},l=(s=(r=this.options)==null?void 0:r.offset)!=null?s:_r.offset;if(typeof l=="number"&&(l={x:l,y:l}),!!i){switch(t){case"up":a={x:0,y:-l.y*o};break;case"down":a={x:0,y:l.y*o};break;case"left":a={x:-l.x*o,y:0};break;case"right":a={x:l.x*o,y:0};break}(a.x||a.y)&&(n.preventDefault(),this.manager.actions.move({event:n,by:a}))}}sideEffects(){const t=this.manager.registry.plugins.get(Vd);t?.disabled===!1&&(t.disable(),ke(this,Dn).push(()=>{t.enable()}))}cleanup(){ke(this,Dn).forEach(t=>t()),et(this,Dn,[])}destroy(){this.cleanup(),this.listeners.clear()}};Dn=new WeakMap;Ys.configure=Zr(Ys);Ys.defaults=_r;var Kd=Ys;function kn(e,t){return t.includes(e.code)}var dn,Op=class extends Zc{constructor(){super(...arguments),Me(this,dn)}onEvent(e){switch(e.type){case"pointerdown":et(this,dn,Bn(e));break;case"pointermove":if(!ke(this,dn))return;const{x:t,y:n}=Bn(e),r={x:t-ke(this,dn).x,y:n-ke(this,dn).y},{tolerance:s}=this.options;if(s&&eo(r,s)){this.abort();return}eo(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){et(this,dn,void 0)}};dn=new WeakMap;var An,un,Ep=class extends Zc{constructor(){super(...arguments),Me(this,An),Me(this,un)}onEvent(e){switch(e.type){case"pointerdown":et(this,un,Bn(e)),et(this,An,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!ke(this,un))return;const{x:t,y:n}=Bn(e),r={x:t-ke(this,un).x,y:n-ke(this,un).y};eo(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){ke(this,An)&&(clearTimeout(ke(this,An)),et(this,un,void 0),et(this,An,void 0))}};An=new WeakMap;un=new WeakMap;var Rn=class{};Rn.Delay=Ep;Rn.Distance=Op;var yo=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:s}=e;if(!(r==="mouse"&&gn(s)&&(t.handle===s||(n=t.handle)!=null&&n.contains(s))))return r==="touch"?[new Rn.Delay({value:250,tolerance:5})]:Nh(s)&&!e.defaultPrevented?[new Rn.Delay({value:200,tolerance:0})]:[new Rn.Delay({value:200,tolerance:10}),new Rn.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;if(r===t.element||r===t.handle||!gn(r)||(n=t.handle)!=null&&n.contains(r))return!1;const s=ih(r);return s===t.element?!1:!!s}}),jn,Xs=class extends Wn{constructor(t,n){super(t),this.manager=t,this.options=n,Me(this,jn,new Set),this.listeners=new pd,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:r,coordinates:s}=this.latest;!r||!s||this.manager.actions.move({event:r,to:s})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(t,n,r=this.options){const{activationConstraints:s=yo.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return pt(()=>{var s;const i=new AbortController,{signal:o}=i,a=u=>{Lh(u)&&this.handlePointerDown(u,t,n)};let l=[(s=t.handle)!=null?s:t.element];n?.activatorElements&&(Array.isArray(n.activatorElements)?l=n.activatorElements:l=n.activatorElements(t));for(const u of l)u&&(Dp(u.ownerDocument.defaultView),u.addEventListener("pointerdown",a,{signal:o}));return()=>i.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!gn(t.target)||n.disabled||Cp(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=yo.preventActivation}=r??{};if(s?.(t,n))return;const{target:i}=t,o=Yt(i)&&i.draggable&&i.getAttribute("draggable")==="true",a=Gn(n.element),{x:l,y:u}=Bn(t);this.initialCoordinates={x:l*a.scaleX+a.x,y:u*a.scaleY+a.y};const c=this.activationConstraints(t,n,r);t.sensor=this;const d=new Xf(c,g=>this.handleStart(n,g));d.signal.onabort=()=>this.handleCancel(t),d.onEvent(t),this.controller=d;const f=so(),p=this.listeners.bind(f,[{type:"pointermove",listener:g=>this.handlePointerMove(g,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:us,options:{capture:!0}}]),m=()=>{p(),this.initialCoordinates=void 0};ke(this,jn).add(m)}handlePointerMove(t,n){var r,s;if(((r=this.controller)==null?void 0:r.activated)===!1){(s=this.controller)==null||s.onEvent(t);return}if(this.manager.dragOperation.status.dragging){const i=Bn(t),o=Gn(n.element);i.x=i.x*o.scaleX+o.x,i.y=i.y*o.scaleY+o.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=i,Gs.schedule(this.handleMove)}}handlePointerUp(t){const{status:n}=this.manager.dragOperation;if(!n.idle){t.preventDefault(),t.stopPropagation();const r=!n.initialized;this.manager.actions.stop({event:t,canceled:r})}this.cleanup()}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel(t))}handleStart(t,n){const{manager:r,initialCoordinates:s}=this;if(!s||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:s,event:n,source:t}).signal.aborted)return this.cleanup();n.preventDefault();const a=tr(n.target).body;try{a.setPointerCapture(n.pointerId)}catch{this.handleCancel(n);return}const l=gn(n.target)?[n.target,a]:a,u=this.listeners.bind(l,[{type:"touchmove",listener:us,options:{passive:!1}},{type:"click",listener:us},{type:"contextmenu",listener:us},{type:"keydown",listener:this.handleKeyDown}]);ke(this,jn).add(u)}handleCancel(t){const{dragOperation:n}=this.manager;n.status.initialized&&this.manager.actions.stop({event:t,canceled:!0}),this.cleanup()}cleanup(){const{controller:t}=this;this.controller=void 0,t&&!t.signal.aborted&&t.abort(),this.latest={event:void 0,coordinates:void 0},ke(this,jn).forEach(n=>n()),ke(this,jn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};jn=new WeakMap;Xs.configure=Zr(Xs);Xs.defaults=yo;var Hd=Xs;function Cp(e){return"sensor"in e}function us(e){e.preventDefault()}function Ip(){}var ol=new WeakSet;function Dp(e){!e||ol.has(e)||(e.addEventListener("touchmove",Ip,{capture:!1,passive:!1}),ol.add(e))}var Nn={modifiers:[],plugins:[np,Vd,sp,xa,Tp],sensors:[Hd,Kd]},Yd=class extends Jf{constructor(e={}){const t=yt(e.plugins,Nn.plugins),n=yt(e.sensors,Nn.sensors),r=yt(e.modifiers,Nn.modifiers);super(ma(zr({},e),{plugins:[Sp,ts,ui,...t],sensors:n,modifiers:r}))}},Xd,Zd,xo,Ut,Sa,$a,fi=class extends(xo=$t,Zd=[pe],Xd=[pe],xo){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:i}=n,o=Od(n,["element","effects","handle"]);super(zr({effects:()=>[...s(),()=>{var a,l;const{manager:u}=this;if(!u)return;const d=((l=(a=this.sensors)==null?void 0:a.map(Mr))!=null?l:[...u.sensors]).map(f=>{const p=f instanceof Wn?f:u.registry.register(f.plugin),m=f instanceof Wn?void 0:f.options;return p.bind(this,m)});return function(){d.forEach(p=>p())}}]},o),t),Me(this,Sa,ze(Ut,8,this)),ze(Ut,11,this),Me(this,$a,ze(Ut,12,this)),ze(Ut,15,this),this.element=r,this.handle=i}};Ut=rr(xo);Sa=new WeakMap;$a=new WeakMap;gt(Ut,4,"handle",Zd,fi,Sa);gt(Ut,4,"element",Xd,fi,$a);wn(Ut,fi);var Qd,Jd,wo,Vt,Ta,Ti,eu,tu,Pr,Oa,hi=class extends(wo=Tt,Jd=[pe],Qd=[pe],wo){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,i=Od(n,["element","effects"]);const{collisionDetector:o=_d}=i,a=u=>{const{manager:c,element:d}=this;if(!d||u===null){this.shape=void 0;return}if(!c)return;const f=new _t(d),p=he(()=>this.shape);return f&&p?.equals(f)?p:(this.shape=f,f)},l=Kn(!1);super(ma(zr({},i),{collisionDetector:o,effects:()=>[...s(),()=>{const{element:u,manager:c}=this;if(!c)return;const{dragOperation:d}=c,{source:f}=d;l.value=!!(f&&d.status.initialized&&u&&!this.disabled&&this.accepts(f))},()=>{const{element:u}=this;if(l.value&&u){const c=new gh(u,a);return()=>{c.disconnect(),this.shape=void 0}}},()=>{var u;if((u=this.manager)!=null&&u.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),Me(this,Pr),Me(this,Ta,ze(Vt,8,this)),ze(Vt,11,this),Me(this,Oa,ze(Vt,12,this)),ze(Vt,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){et(this,Pr,e,tu)}get element(){var e;return(e=this.proxy)!=null?e:ke(this,Pr,eu)}};Vt=rr(wo);Ta=new WeakMap;Pr=new WeakSet;Oa=new WeakMap;Ti=gt(Vt,20,"#element",Jd,Pr,Ta),eu=Ti.get,tu=Ti.set;gt(Vt,4,"proxy",Qd,hi,Oa);wn(Vt,hi);function Ap(e){return e!=null&&typeof e=="object"&&"current"in e}function Fn(e){var t;if(e!=null)return Ap(e)?(t=e.current)!=null?t:void 0:e}var jp=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",sr=jp?_.useLayoutEffect:_.useEffect;function Pp(){const e=_.useState(0)[1];return _.useCallback(()=>{e(t=>t+1)},[e])}function nu(e,t){const n=_.useRef(new Map),r=Pp();return sr(()=>{if(!e){n.current.clear();return}return pt(()=>{var s;let i=!1,o=!1;for(const a of n.current){const[l]=a,u=he(()=>a[1]),c=e[l];u!==c&&(i=!0,n.current.set(l,c),o=(s=t?.(l,u,c))!=null?s:!1)}i&&(o?queueMicrotask(()=>sf.flushSync(r)):r())})},[e]),_.useMemo(()=>e&&new Proxy(e,{get(s,i){const o=s[i];return n.current.set(i,o),o}}),[e])}function Mp(e,t){e()}function _n(e){const t=_.useRef(e);return sr(()=>{t.current=e},[e]),t}function Ce(e,t,n=_.useEffect,r=Object.is){const s=_.useRef(e);n(()=>{const i=s.current;r(e,i)||(s.current=e,t(e,i))},[t,e])}function Ds(e,t){const n=_.useRef(Fn(e));sr(()=>{const r=Fn(e);r!==n.current&&(n.current=r,t(r))})}var Rp=Object.defineProperty,Lp=Object.defineProperties,Np=Object.getOwnPropertyDescriptors,Zs=Object.getOwnPropertySymbols,ru=Object.prototype.hasOwnProperty,su=Object.prototype.propertyIsEnumerable,al=(e,t,n)=>t in e?Rp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fp=(e,t)=>{for(var n in t||(t={}))ru.call(t,n)&&al(e,n,t[n]);if(Zs)for(var n of Zs(t))su.call(t,n)&&al(e,n,t[n]);return e},zp=(e,t)=>Lp(e,Np(t)),Wp=(e,t)=>{var n={};for(var r in e)ru.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Zs)for(var r of Zs(e))t.indexOf(r)<0&&su.call(e,r)&&(n[r]=e[r]);return n},Bp=new Yd,iu=_.createContext(Bp),qp=_.memo(_.forwardRef(({children:e},t)=>{const[n,r]=_.useState(0),s=_.useRef(null),i=_.useRef(null),o=_.useMemo(()=>({renderer:{get rendering(){var a;return(a=s.current)!=null?a:Promise.resolve()}},trackRendering(a){s.current||(s.current=new Promise(l=>{i.current=l})),_.startTransition(()=>{a(),r(l=>l+1)})}}),[]);return sr(()=>{var a;(a=i.current)==null||a.call(i),s.current=null},[e,n]),_.useImperativeHandle(t,()=>o),null})),Oi=[void 0,vt];function Gp(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:i,onDragMove:o,onDragOver:a,onDragEnd:l}=t,u=Wp(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const c=_.useRef(null),{plugins:d,modifiers:f,sensors:p}=u,m=yt(d,Nn.plugins),g=yt(p,Nn.sensors),x=yt(f,Nn.modifiers),k=_n(s),b=_n(i),h=_n(a),y=_n(o),w=_n(l),D=_n(r),T=Up(()=>{var A;return(A=u.manager)!=null?A:new Yd(u)});return _.useEffect(()=>{if(!c.current)throw new Error("Renderer not found");const{renderer:A,trackRendering:I}=c.current,{monitor:C}=T;T.renderer=A;const W=[C.addEventListener("beforedragstart",F=>{const G=k.current;G&&I(()=>G(F,T))}),C.addEventListener("dragstart",F=>{var G;return(G=b.current)==null?void 0:G.call(b,F,T)}),C.addEventListener("dragover",F=>{const G=h.current;G&&I(()=>G(F,T))}),C.addEventListener("dragmove",F=>{const G=y.current;G&&I(()=>G(F,T))}),C.addEventListener("dragend",F=>{const G=w.current;G&&I(()=>G(F,T))}),C.addEventListener("collision",F=>{var G;return(G=D.current)==null?void 0:G.call(D,F,T)})];return()=>W.forEach(F=>F())},[T]),Ce(m,()=>T&&(T.plugins=m),...Oi),Ce(g,()=>T&&(T.sensors=g),...Oi),Ce(x,()=>T&&(T.modifiers=x),...Oi),v.jsxs(iu.Provider,{value:T,children:[v.jsx(qp,{ref:c,children:n}),n]})}function Up(e){const t=_.useRef(null);return t.current||(t.current=e()),_.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}function Vp(){return _.useContext(iu)}function ou(e){var t;const n=(t=Vp())!=null?t:void 0,[r]=_.useState(()=>e(n));return r.manager!==n&&(r.manager=n),sr(r.register,[n,r]),r}var Kp=Object.create,au=Object.defineProperty,Hp=Object.getOwnPropertyDescriptor,lu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),pi=e=>{throw TypeError(e)},Yp=(e,t,n)=>t in e?au(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xp=e=>{var t;return[,,,Kp((t=e?.[lu("metadata")])!=null?t:null)]},cu=["class","method","getter","setter","accessor","field","value","get","set"],du=e=>e!==void 0&&typeof e!="function"?pi("Function expected"):e,Zp=(e,t,n,r,s)=>({kind:cu[e],name:t,metadata:r,addInitializer:i=>n._?pi("Already initialized"):s.push(du(i||null))}),Qp=(e,t)=>Yp(t,lu("metadata"),e[3]),Jp=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)i[s].call(n);return r},uu=(e,t,n,r,s,i)=>{for(var o,a,l,u,c=t&7,d=!1,f=!1,p=2,m=cu[c+5],g=e[p]||(e[p]=[]),x=(s=s.prototype,Hp(s,n)),k=r.length-1;k>=0;k--)l=Zp(c,n,a={},e[3],g),l.static=d,l.private=f,u=l.access={has:b=>n in b},u.get=b=>b[n],o=(0,r[k])(x[m],l),a._=1,du(o)&&(x[m]=o);return x&&au(s,n,x),s},fu=(e,t,n)=>t.has(e)||pi("Cannot "+n),eg=(e,t,n)=>(fu(e,t,"read from private field"),t.get(e)),tg=(e,t,n)=>t.has(e)?pi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ng=(e,t,n,r)=>(fu(e,t,"write to private field"),t.set(e,n),n),hn=class ko{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new ko(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new ko(t,n)}},hu,pu,_o,As,ns,Ea=class extends(_o=yn,pu=[Pe],hu=[Pe],_o){constructor(e){const t=hn.from(e);super(t,(n,r)=>hn.equals(n,r)),Jp(ns,5,this),tg(this,As,0),this.velocity={x:0,y:0}}get delta(){return hn.delta(this.current,this.initial)}get direction(){const{current:e,previous:t}=this;if(!t)return null;const n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up"}get current(){return super.current}set current(e){const{current:t}=this,n=hn.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),i=s-eg(this,As),o=a=>Math.round(a/i*100);De(()=>{ng(this,As,s),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(hn.from(e)),this.velocity={x:0,y:0}}};ns=Xp(_o);As=new WeakMap;uu(ns,2,"delta",pu,Ea);uu(ns,2,"direction",hu,Ea);Qp(ns,Ea);var gu=(e=>(e.Horizontal="x",e.Vertical="y",e))(gu||{});Object.values(gu);var rg=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const s=hn.distance(t.shape.center,n);return{id:r,value:1/s,type:er.PointerIntersection,priority:Jn.High}}return null},sg=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:s}=e,i=hn.distance(t.shape.center,s.current),a=r/(n.current.area+t.shape.area-r)/i;return{id:t.id,value:a,type:er.ShapeIntersection,priority:Jn.Normal}}return null},ig=e=>{var t;return(t=rg(e))!=null?t:sg(e)};function og(e){const{collisionDetector:t,data:n,disabled:r,element:s,id:i,accept:o,type:a}=e,l=ou(c=>new hi(zp(Fp({},e),{register:!1,element:Fn(s)}),c)),u=nu(l);return Ce(i,()=>l.id=i),Ds(s,c=>l.element=c),Ce(o,()=>l.accept=o,void 0,vt),Ce(t,()=>l.collisionDetector=t??ig),Ce(n,()=>n&&(l.data=n)),Ce(r,()=>l.disabled=r===!0),Ce(a,()=>l.type=a),{droppable:u,get isDropTarget(){return u.isDropTarget},ref:_.useCallback(c=>{var d,f;!c&&((d=l.element)!=null&&d.isConnected)&&!((f=l.manager)!=null&&f.dragOperation.status.idle)||(l.element=c??void 0)},[l])}}const Ue=e=>e.kind==="text",we=e=>e.kind!=="text",Ei=e=>we(e)?e.label??e.name:e.name,He=e=>Ue(e)?`text.${e.name}`:`${e.source}.${e.name}`;function ag(e,t=[]){const n=new Map;for(const i of e.tiles)for(const o of we(i)?i.filters??[]:[])n.set(o.given,(n.get(o.given)??0)+1);const r=[],s=new Set;for(const i of e.localGivens??[])s.add(i.name),r.push({name:i.name,...i.label===void 0?{}:{label:i.label},type:i.type,...i.suggest?{field:i.suggest.dimension}:{},origin:"dashboard",local:i,boundTiles:n.get(i.name)??0});for(const i of t)s.has(i.name)||(s.add(i.name),r.push({...i,origin:"model",boundTiles:n.get(i.name)??0}));for(const[i,o]of n)s.has(i)||r.push({name:i,origin:"model",boundTiles:o});return r}function Qs(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function lg(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function js(e,t){const n=lg(e),r=t?.replace(/_type$/,"");if(!n||!r)return!0;const s=new Set(["date","timestamp"]);return s.has(n)?s.has(r):n===r}function ll(e){switch(e?.replace(/_type$/,"")){case"string":return"text";case"number":return"a number";case"date":return"a date";case"timestamp":return"a timestamp";case"boolean":return"true or false";default:return e??"an unknown type"}}function cg(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const dg=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function ug(e,t){const r=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",s=/^[A-Z_]/.test(r)?r:`F_${r}`,i=ye.isStrictName(s)?s:`${s}_FILTER`,o=new Set(t);if(!o.has(i))return i;for(let a=2;;a++)if(!o.has(`${i}_${a}`))return`${i}_${a}`}const cl=[{kind:"select",label:"Pick one",hint:"A dropdown of the field's values"},{kind:"multiselect",label:"Pick several",hint:"The same, taking more than one"},{kind:"text",label:"Text",hint:"A box taking Malloy filter syntax"},{kind:"number",label:"Number range",hint:"A slider over the field's values"},{kind:"date",label:"On or after a date",hint:"A date picker; tiles keep rows on or after it"}];function fs(e){const t=e.label.trim()||e.name,n=e.field;switch(e.kind){case"select":case"multiselect":return{name:e.name,type:"filter<string>",default:"f''",label:t,control:e.kind,...e.source?{suggest:{source:e.source,dimension:n}}:{}};case"text":return{name:e.name,type:"filter<string>",default:"f''",label:t};case"number":return{name:e.name,type:"filter<number>",default:"f''",label:t,...e.range?{rangeMin:e.range.min,rangeMax:e.range.max}:{}};case"date":return{name:e.name,type:"date",default:`@${e.dateDefault??new Date().toISOString().slice(0,10)}`,label:t}}}const So=e=>we(e)&&e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function fg(e,t){return e.tiles.map(n=>{const r=(we(n)?n.filters??[]:[]).find(s=>s.given===t.name);return{include:r!==void 0,field:r?.field??t.field??t.name.toLowerCase(),...r?.op!==void 0?{op:r.op}:Qs(t.type)!==void 0?{op:Qs(t.type)}:{}}})}function hg(e,t,n){n.forEach((r,s)=>{const i=e.tiles[s];if(!i||!So(i))return;const o=(i.filters??[]).filter(l=>l.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?i.filters=a:delete i.filters})}function pg(e,t){const n=(e.localGivens??[]).filter(i=>i.name!==t.name),r=(e.localGivens??[]).findIndex(i=>i.name===t.name),s=[...n];s.splice(r>=0?r:s.length,0,t),e.localGivens=s}function gg(e,t){for(const r of e.tiles){if(!we(r))continue;const s=(r.filters??[]).filter(i=>i.given!==t);s.length>0?r.filters=s:delete r.filters}const n=(e.localGivens??[]).filter(r=>r.name!==t);n.length>0?e.localGivens=n:delete e.localGivens}const mg=L.createSvgIcon(v.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"})),vg=L.createSvgIcon(v.jsx("path",{d:"m14.06 9.02.92.92L5.92 19H5v-.92zM17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29m-3.6 3.19L3 17.25V21h3.75L17.81 9.94z"})),bg=L.createSvgIcon(v.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"})),yg=L.createSvgIcon(v.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"})),$o=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),Ci=$o?"⌘":"Ctrl+",xg=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"},dl=e=>e instanceof Element&&e.closest('[role="dialog"], .MuiPopover-root, .MuiDialog-root')!==null;function wg(e){const t=_.useRef(e);_.useEffect(()=>{t.current=e});const[n,r]=_.useState(!1);_.useEffect(()=>{n&&(r(!1),t.current.save?.())},[n]),_.useEffect(()=>{const s=i=>{const o=t.current;if(o.paused)return;const a=$o?i.metaKey:i.ctrlKey,l=i.key.toLowerCase();if(i.key==="Escape"){o.escape();return}if(xg(i.target)){if(a&&l==="s"){if(i.preventDefault(),!o.save||dl(i.target))return;i.target.blur(),r(!0)}return}if(a&&l==="z"){i.preventDefault(),i.shiftKey?o.redo():o.undo();return}if(!$o&&a&&l==="y"){i.preventDefault(),o.redo();return}if(a&&l==="s"){i.preventDefault(),dl(i.target)||o.save?.();return}o.nudge&&!a&&!i.altKey&&!i.shiftKey&&(i.key==="ArrowLeft"||i.key==="ArrowRight")&&(i.preventDefault(),o.nudge(i.key==="ArrowRight"?1:-1))};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[])}const kg={package:"Saves to the package file",browser:"Saves in this browser",host:"Saves to the app this is embedded in"};function _g({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:s,saving:i,onSave:o,savesTo:a="package",saveLabel:l,saveButton:u,actions:c,onExit:d,onAddTile:f,onSettings:p}){const{theme:m}=Ye.usePublisherTheme();return v.jsxs(L.DashboardBar,{left:v.jsx(S.Chip,{size:"medium",variant:"outlined",icon:v.jsx(vg,{sx:{fontSize:20}}),label:"Editing",sx:{height:37,fontSize:"0.875rem",fontWeight:500,border:m.border,color:m.tileTitle,"& .MuiChip-icon":{color:"inherit"},"& .MuiChip-label":{fontSize:"0.875rem"}}}),children:[f&&v.jsx(S.Button,{startIcon:v.jsx(L.AddIcon,{}),onClick:f,"aria-label":"Add tile",children:"Tile"}),p&&v.jsx(S.Button,{startIcon:v.jsx(mg,{}),onClick:g=>p(g.currentTarget),children:"Settings"}),v.jsx(S.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),v.jsx(S.Tooltip,{title:`Undo (${Ci}Z)`,children:v.jsx("span",{children:v.jsx(S.IconButton,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:v.jsx(yg,{fontSize:"small"})})})}),v.jsx(S.Tooltip,{title:`Redo (${Ci}⇧Z)`,children:v.jsx("span",{children:v.jsx(S.IconButton,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:v.jsx(bg,{fontSize:"small"})})})}),o&&v.jsx(v.Fragment,{children:v.jsxs(S.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center"},children:[v.jsx(S.Tooltip,{title:s?`Save (${Ci}S)`:"",children:v.jsx("span",{children:v.jsx(S.Button,{ref:u,variant:s?"contained":"outlined",disabled:!s||i,onClick:o,sx:{minWidth:124},children:i?"Saving…":s?"Save changes":"Saved"})})}),v.jsx(S.Typography,{variant:"caption",sx:{fontSize:11,lineHeight:1.2,opacity:.7},children:l??kg[a]})]})}),(c||d)&&v.jsxs(v.Fragment,{children:[v.jsx(S.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),c,d&&v.jsx(L.SecondaryButton,{label:"Close",icon:v.jsx(L.CheckIcon,{}),onClick:d})]})]})}function Sg(e,t){const n=new Map(e.tiles.map((r,s)=>[He(r),{tile:r,index:s}]));for(const[r,s]of t.tiles.entries()){const i=n.get(He(s));if(!i||i.index!==r||JSON.stringify(i.tile)!==JSON.stringify(s))return He(s)}}const mu=_.createContext(void 0);function vu(e,t){const n=_.useContext(mu),r=_.useRef(t);r.current=t,_.useEffect(()=>{if(!n||!e)return;const i=()=>r.current();return n.commitRef.current=i,()=>{n.commitRef.current===i&&(n.commitRef.current=void 0)}},[n,e]);const s=_.useRef(!1);_.useLayoutEffect(()=>{!e&&!s.current||(s.current=e,n?.setDirty(e))},[n,e]),_.useLayoutEffect(()=>()=>{s.current&&n?.setDirty(!1)},[n])}const bu=["bar_chart","line_chart","scatter_chart","shape_map","segment_map","big_value","sparkline"],yu=["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"],gi=e=>yu.includes(e),To=new Set([...bu,"viz"]);function Ht(e){const t=e.trim();if(!/^#[ \t]/.test(t)||/[{=]/.test(t))return;const n=t.slice(1).trim().split(/[ \t]+/),r=[];let s;for(const i of n)if(i.startsWith("-")){if(s!==void 0)return;const o=i.slice(1);if(!To.has(o))return;r.push(o)}else{if(s!==void 0||!To.has(i))return;s=i}return{negated:r,...s!==void 0&&{pick:s}}}function Gr(e){const t=e.trim();return!/^#[ \t]/.test(t)||Ht(t)?!1:(t.replace(/"(?:[^"\\]|\\.)*"/g,'""').match(/[A-Za-z_]+/g)??[]).some(r=>To.has(r))}function zn(e,t){return["#",...yu.filter(r=>r!==e&&(t===void 0||t.includes(r))).map(r=>`-${r}`),"-viz",...e==="none"?[]:[e]].join(" ")}function $g(e){return e.pick!==void 0?gi(e.pick)?e.pick:"custom":e.negated.includes("viz")?"none":"custom"}function Tg(e){if(e.length===0)return"default";if(e.length>1)return"custom";const t=Ht(e[0]);return t?$g(t):"custom"}function Og(e){const t=e.filter(n=>Ht(n));return e.some(Gr)?"custom":t.length===0?void 0:Tg(t)}const Eg=e=>e.filter(t=>Ht(t)||Gr(t)),xu=e=>e.ok===!1,Le=(e,...t)=>t.every(n=>typeof e?.[n]=="function"),rs=e=>e!==void 0&&e.ruleIndex!==void 0&&(e.childCount??0)>0,Oe={sourceDefinition:e=>Le(e,"sourceNameDef","isDefine","sqExplore"),exploreQueryDef:e=>Le(e,"exploreQueryNameDef","isDefine","vExpr"),defExploreQuery:e=>Le(e,"VIEW","subQueryDefList"),defDimension:e=>Le(e,"defList","DIMENSION"),exploreProperties:e=>Le(e,"exploreStatement","OCURLY","CCURLY"),queryProperties:e=>Le(e,"queryStatement","OCURLY","CCURLY"),queryStatement:e=>Le(e,"whereStatement","aggregateStatement","nestStatement"),whereStatement:e=>Le(e,"WHERE","filterClauseList"),givenDef:e=>Le(e,"givenNameDef"),givenStatement:e=>Le(e,"GIVEN","givenDefList"),importStatement:e=>Le(e,"IMPORT","importURL"),vArrow:e=>Le(e,"ARROW","vExpr","segExpr"),segRefine:e=>Le(e,"PLUS","segExpr"),segOps:e=>Le(e,"queryProperties"),segField:e=>Le(e,"fieldPath")&&!Le(e,"segExpr"),segParen:e=>Le(e,"OPAREN","CPAREN","vExpr"),compare:e=>Le(e,"fieldExpr","compareOp"),givenRef:e=>Le(e,"GIVEN_REF")};function Cg(e){const t=new Int32Array([...e].length+1);let n=0;for(let r=0;r<e.length;)t[n++]=r,r+=e.codePointAt(r)>65535?2:1;return t[n]=e.length,t}function Ig(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
68
|
+
`&&t.push(n+1);return t}class Ca{constructor(t){this.text=t,this.map=Cg(t),this.lineStarts=Ig(t)}map;lineStarts;commentLines=new Set;proseLines=new Set;blocks=[];span(t){if(!rs(t))return;const n=t.start,r=t.stop;if(!n||!r)return;const s=this.map[n.startIndex],i=this.map[r.stopIndex+1];if(!(s===void 0||i===void 0||i<s))return{start:s,end:i}}terminal(t){const n=t?.symbol;if(!n)return;const r=this.map[n.startIndex],s=this.map[n.stopIndex+1];if(!(r===void 0||s===void 0||s<r))return{start:r,end:s}}utf16(t){return this.map[t]}text_(t){const n=this.span(t);return n&&this.text.slice(n.start,n.end)}line(t){let n=0,r=this.lineStarts.length-1;for(;n<r;){const s=n+r+1>>1;this.lineStarts[s]<=t?n=s:r=s-1}return n}positioned(t){const n=this.span(t);return n&&{span:n,line:this.line(n.start)}}indentAt(t){const n=this.lineStarts[this.line(t)];return/^[ \t]*/.exec(this.text.slice(n))?.[0]??""}}function ss(e,t,n=[]){rs(e)&&t(e)&&n.push(e);for(let r=0;r<(e.childCount??0);r++)ss(e.getChild(r),t,n);return n}const Dg=e=>Le(e,"OCURLY","CCURLY");function Ur(e,t){const n=[],r=s=>{if(rs(s)){if(t(s)){n.push(s);return}if(!Dg(s))for(let i=0;i<(s.childCount??0);i++)r(s.getChild(i))}};for(let s=0;s<(e.childCount??0);s++)r(e.getChild(s));return n}const Ne=(e,t)=>e[t]?.call(e),vn=(e,t)=>e[t]?.call(e)??[];function Ag(e,t){if(!Oe.compare(t)||(t.childCount??0)!==3)return;const n=t.getChild(2);if(!Oe.givenRef(n))return;const r=e.text_(t.getChild(0)),s=e.text_(t.getChild(1)),i=e.text_(n)??"";if(!(r===void 0||s===void 0))return{field:r,op:s.trim(),given:i.replace(/^\$/,"")}}function wu(e,t){const n=e.positioned(t);if(!n)return;const r=Ne(t,"filterClauseList"),s=[];for(const i of r?vn(r,"fieldExpr"):[]){const o=e.positioned(i);if(!o)continue;const a=ss(i,Oe.givenRef).map(l=>e.text_(l)).filter(l=>l!==void 0).map(l=>l.replace(/^\$/,""));s.push({...o,givens:a,binding:Ag(e,i)})}return{...n,clauses:s}}function Oo(e,t){const n=e.span(t);if(!n)return;const r=[],s=[];for(const u of Ur(t,Oe.queryStatement)){const c=e.positioned(u);c&&r.push(c);const d=Ne(u,"whereStatement");if(d&&Oe.whereStatement(d)){const f=wu(e,d);f&&s.push(f)}}const i=n.start+1,o=n.end-1,a=!e.text.slice(n.start,n.end).includes(`
|
|
69
|
+
`),l=r.length?e.indentAt(r[0].span.start):e.indentAt(n.start)+" ";return{span:n,openEnd:i,closeStart:o,statements:r,wheres:s,indent:l,oneLine:a}}function Ia(e,t,n){const r=[],s=e.line(t.start),i=e.line(n);for(let o=s;o<i;o++){if(e.commentLines.has(o)||e.proseLines.has(o))continue;const a=e.text.slice(e.lineStarts[o],e.lineStarts[o+1]??e.text.length).trim();a.startsWith("#")&&!a.startsWith("##")&&r.push({line:o,text:a})}return r}function jg(e,t){const n=Ne(t,"segExpr");if(!n)return{kind:"unsupported",why:"an unreadable expression"};const r=Oe.vArrow(t);if(Oe.segOps(n)){const s=Ne(n,"queryProperties"),i=s&&Oo(e,s);return i?{kind:"inline",stage:i,...r?{pipeline:!0}:{}}:{kind:"unsupported",why:"an unreadable body"}}if(r)return{kind:"unsupported",why:"a `->` pipeline from a named view"};if(Oe.segField(n)){const s=e.span(n);return s?{kind:"reference",from:e.text.slice(s.start,s.end),fromSpan:s}:{kind:"unsupported",why:"an unreadable name"}}if(Oe.segRefine(n)){const s=vn(n,"segExpr"),i=s[0],o=s[s.length-1];let a=i;for(;Oe.segRefine(a);){const f=vn(a,"segExpr");if(f.some(p=>Oe.segOps(p)||Oe.segParen(p)))return{kind:"unsupported",why:"a chained refinement"};a=f[0]}if(a&&Oe.segParen(a))return{kind:"unsupported",why:"a parenthesized expression"};if(!a||!Oe.segField(a))return{kind:"unsupported",why:"a `{ … } + { … }` compound refinement"};const l=e.span(i);if(!l||!o)return{kind:"unsupported",why:"an unreadable refinement"};if(!Oe.segOps(o)){const f=e.span(n);return f?{kind:"reference",from:e.text.slice(f.start,f.end),fromSpan:f}:{kind:"unsupported",why:"an unreadable refinement"}}const u=e.text.slice(l.start,l.end),c=Ne(o,"queryProperties"),d=c&&Oo(e,c);return d?{kind:"reference",from:u,fromSpan:l,refinement:d}:{kind:"reference",from:u,fromSpan:l}}return{kind:"unsupported",why:"a parenthesized expression"}}function Pg(e,t){const n=[];for(const r of Ur(t,Oe.defExploreQuery)){const s=e.span(r),i=Ne(r,"subQueryDefList");if(!s||!i)continue;const o=vn(i,"exploreQueryDef").filter(Oe.exploreQueryDef),a=e.terminal(Ne(r,"VIEW"));for(const l of o){const u=e.span(l),c=Ne(l,"exploreQueryNameDef"),d=e.text_(c),f=Ne(l,"vExpr");!u||!d||!f||n.push({name:d,span:u,line:e.line(u.start),statement:s,tags:Ia(e,s,a?.start??u.start),siblings:o.length,body:jg(e,f)})}}return n}function Mg(e,t){const n=[];for(const r of Ur(t,Oe.defDimension)){const s=e.span(r),i=Ne(r,"defList");if(!s||!i)continue;const o=e.terminal(Ne(r,"DIMENSION"));for(const a of vn(i,"fieldDef")){const l=e.span(a),u=e.text_(Ne(a,"fieldNameDef"))?.trim(),c=e.text_(Ne(a,"fieldExpr"))?.trim();!l||!u||c===void 0||n.push({name:u,expression:c,span:l,line:e.line(l.start),statement:s,tags:Ia(e,s,o?.start??l.start)})}}return n}function Rg(e,t){const n=[];for(const r of ss(t,Oe.sourceDefinition)){const s=e.span(r),i=e.text_(Ne(r,"sourceNameDef")),o=Ne(r,"sqExplore");if(!s||!i||!o)continue;const a=e.span(o),l=a?e.text.slice(a.start,a.end):"",u=(/^\s*(`[^`]*`|[A-Za-z_][A-Za-z0-9_.]*)/.exec(l)?.[1]??"").trim(),c=Ur(o,Oe.exploreProperties)[0],d=c&&Oo(e,c),f={start:e.lineStarts[e.line(s.start)],end:s.end},p=[];if(c)for(const m of Ur(c,Oe.whereStatement)){const g=wu(e,m);g&&p.push(g)}n.push({name:i,base:u,span:s,line:e.line(s.start),statement:f,...d?{properties:d}:{},views:c?Pg(e,c):[],dimensions:c?Mg(e,c):[],wheres:p})}return n}function Lg(e,t){const n=[];for(const r of ss(t,Oe.givenStatement)){const s=e.terminal(Ne(r,"GIVEN")),i=Ne(r,"givenDefList"),o=s?e.line(s.start):void 0;for(const a of i?vn(i,"givenDef"):[]){const l=e.span(a),u=e.span(Ne(a,"givenNameDef")),c=u&&e.text.slice(u.start,u.end);if(!l||!u||!c)continue;const d={start:u.start,end:l.end},f=e.line(d.start);n.push({name:c,declaration:e.text.slice(d.start,d.end),span:d,line:f,statement:{start:e.lineStarts[f],end:d.end},tags:Ia(e,l,d.start),...o!==void 0&&o!==f?{blockHeader:o}:{}})}}return n}function Ng(e,t){const n=[];for(const r of ss(t,Oe.importStatement)){const s=e.span(r),i=e.text_(Ne(r,"importURL"));if(!s||i===void 0)continue;const o=Ne(r,"importSelect"),a=o?vn(o,"importItem").map(l=>e.text_(l)).filter(l=>l!==void 0).map(l=>l.trim()):void 0;n.push({from:i.replace(/^['"]|['"]$/g,""),...a&&a.length>0?{names:a}:{},span:s,line:e.line(s.start),statement:s})}return n}async function ku(e){let t;try{t=await mi(e,"file://dashboard-builder.malloy")}catch(f){return{ok:!1,reason:`Malloy could not read this file: ${f}`}}const n=t.problems.filter(f=>f.code==="syntax-error");if(n.length>0)return{ok:!1,reason:`This file has a Malloy syntax error, so it cannot be edited here: ${n[0].message??"unknown"}`};const r=t.parse,s=r?.root;if(!s||!rs(s)||typeof s.getChild!="function")return{ok:!1,reason:`This build of Malloy does not expose a parse tree the builder can read (malloy ${r?.malloyVersion??"unknown"}), so editing is off.`};const i=r?.tokenStream??{},o=typeof i.getTokens=="function"?i.getTokens():void 0;if(!o||typeof i.tokenSource?.vocabulary?.getSymbolicName!="function"||o.length===0&&e.trim()!=="")return{ok:!1,reason:`This build of Malloy does not expose a token stream the builder can read (malloy ${r?.malloyVersion??"unknown"}), so it cannot tell a comment from code and editing is off.`};const a=new Ca(e),l=Da(a,i);a.commentLines=l.lines;const u=e.split(`
|
|
70
|
+
`),c=f=>l.lines.has(f);a.proseLines=ye.markdownLines(u,c),a.blocks=ye.blockSpans(u,c).filter(([f])=>!u[f].trimStart().startsWith("##"));const d=Rg(a,s);return d.length===0&&/^\s*source:/m.test(e)?{ok:!1,reason:`The builder could not locate this file's sources in Malloy's parse tree (malloy ${r?.malloyVersion??"unknown"}), so editing is off.`}:{ok:!0,parsed:{text:e,lineStarts:a.lineStarts,imports:Ng(a,s),sources:d,givens:Lg(a,s),textBlocks:zg(a,i),trailingComment:f=>l.trailing.get(f),comments:l.all,commentLine:f=>l.lines.has(f),proseLine:f=>a.proseLines.has(f),commentIn:f=>l.all.find(p=>p.start>=f.start&&p.start<f.end),blockStart:f=>Fg(a,l.lines,f)}}}async function mi(e,t){const{MalloyTranslator:n}=await L.loadMalloy(),r=new n(t,null,{urls:{[t]:e}});return{problems:r.translate().problems??[],parse:r.parseStep?.response?.parse}}function Da(e,t){const n=new Map,r=new Set,s=[],i=t.tokenSource?.vocabulary;for(const c of t.getTokens?.()??[]){const d=i?.getSymbolicName(c.type);if(d!=="COMMENT_TO_EOL"&&d!=="BLOCK_COMMENT")continue;const f=e.utf16(c.startIndex);let p=e.utf16(c.stopIndex+1);if(!(f===void 0||p===void 0||p<f)){for(;p>f&&(e.text[p-1]===`
|
|
71
|
+
`||e.text[p-1]==="\r");)p--;s.push({start:f,end:p})}}const o=[...s].sort((c,d)=>c.start-d.start);let a="",l=0;for(const c of o)a+=e.text.slice(l,Math.max(l,c.start)),a+=e.text.slice(Math.max(l,c.start),Math.max(l,c.end)).replace(/[^\n\r]/g," "),l=Math.max(l,c.end);a+=e.text.slice(l);const u=c=>a.slice(e.lineStarts[c],e.lineStarts[c+1]??a.length);for(const c of s){const d=e.line(c.start),f=e.line(c.end-1);for(let g=d;g<=f;g++)u(g).trim()===""&&r.add(g);const p=a.slice(e.lineStarts[d],c.start).trim(),m=a.slice(c.end,e.lineStarts[f+1]??a.length).trim();p!==""&&m===""&&n.set(f,c)}return{trailing:n,lines:r,all:s}}function Fg(e,t,n){const r=i=>e.text.slice(e.lineStarts[i],e.lineStarts[i+1]??e.text.length).trim();let s=n;for(let i=n-1;i>=0;i--){const o=r(i),a=e.blocks.find(([,l])=>l===i);if(a){s=i=a[0];continue}if(o===""&&!t.has(i))break;if(o.startsWith("#")||t.has(i))s=i;else break}return s}function zg(e,t){const n=t.getTokens?.()??[],r=t.tokenSource?.vocabulary,s=a=>r?.getSymbolicName(a.type),i=a=>e.text.slice(e.utf16(a.startIndex)??0,e.utf16(a.stopIndex+1)??e.text.length),o=[];for(let a=0;a<n.length;a++){if(s(n[a])!=="DOC_BLOCK_ANNOTATION_BEGIN")continue;const l=ye.textBlockOpener(i(n[a]).replace(/\r?\n$/,""));if(!l)continue;const u=[];let c=a+1;for(;s(n[c]??n[a])==="BLOCK_ANNOTATION_TEXT";c++)u.push(i(n[c]));const d=n[c];if(!d||s(d)!=="BLOCK_ANNOTATION_END")continue;const f=e.line(e.utf16(n[a].startIndex)??0),p=e.utf16(d.stopIndex+1)??e.text.length,m=l.name===void 0&&l.rest?[`${l.rest}
|
|
72
|
+
`]:[];o.push({...l.name===void 0?{}:{name:l.name},route:l.route,body:[...m,...u].join("").replace(/\r\n?/g,`
|
|
73
|
+
`).replace(/\n$/,""),span:{start:e.lineStarts[f],end:p},line:f}),a=c}return o}function _u(e,t){for(let n=t+1;n<e.length;n++)if(e[n]==="\\")n++;else if(e[n]==='"')return n;return e.length}function Aa(e){let t=0,n=0;for(let r=0;r<e.length;r++){const s=e[r];if(s==='"')r=_u(e,r);else if(s==="{"||s==="[")t++===0&&n++;else if(s==="}"||s==="]")t--;else if(n===1&&t===1&&e.startsWith("tiles",r)&&!/[A-Za-z0-9_]/.test(e[r-1]??" ")){const i=/^tiles\s*=\s*\[/.exec(e.slice(r));if(i)return Wg(e,r+i[0].length-1)}}}function Wg(e,t){const n=[];let r=0,s=t+1;const i=o=>{const a=e.slice(s,o),l=a.length-a.trimStart().length,u=a.trim();u!==""&&n.push({text:u,span:{start:s+l,end:s+l+u.length}})};for(let o=t+1;o<e.length;o++){const a=e[o];if(a==='"')o=_u(e,o);else if(a==="{"||a==="[")r++;else if(a==="}")r--;else if(a==="]"){if(r===0)return i(o),{open:t,close:o,entries:n};r--}else a===","&&r===0&&(i(o),s=o+1)}}function Bg(e,t){const n=e[t];if(n==="`"){for(let r=t+1;r<e.length;r++)if(e[r]==="\\")r++;else{if(e[r]==="`")return r+1;if(e[r]===`
|
|
74
|
+
`)return e.length}return e.length}if(e.startsWith("<<<",t)){let r=t+3;for(;;){const s=e.indexOf(`
|
|
75
|
+
`,r),i=s===-1?e.length:s;if(e.slice(r,i).trim()===">>>")return i;if(s===-1)return e.length;r=s+1}}if(n==='"'||n==="'"){const r=n.repeat(3);if(e.startsWith(r,t)){for(let s=t+3;s<e.length;s++)if(e[s]==="\\")s++;else if(e.startsWith(r,s))return s+3;return e.length}for(let s=t+1;s<e.length;s++)if(e[s]==="\\")s++;else{if(e[s]===n)return s+1;if(e[s]===`
|
|
76
|
+
`)return s}return e.length}return t}function qg(e){const t=/^([ \t]*)f(['"])((?:\\.|(?!\2)[^\\])*)\2/;let n="",r=0;for(;r<e.length;){const s=Bg(e,r);if(s>r){n+=e.slice(r,s),r=s;continue}const i=e[r];if(/[=[,]/.test(i)){const o=t.exec(e.slice(r+1));if(o){const a=o[3].replace(/\\/g,"\\\\").replace(/"/g,'\\"');n+=`${i}${o[1]}"f'${a}'"`,r+=1+o[0].length;continue}}n+=i,r+=1}return n}function Su(e,t){const n=e(t);if(n.log.length===0)return{tag:n.tag,errors:[]};const r=t.map(i=>{if(e([i]).log.length===0)return i;const o=qg(i);return e([o]).log.length===0?o:i}),s=e(r);return{tag:s.tag,errors:s.log.map(i=>i.message)}}const Vr=e=>e.ok===!1;function is(e,t,n){const r=e.blockStart(n),s=[],i=[];for(let o=r;o<n;o++){if(e.commentLine(o))continue;if(e.proseLine(o)){i.push(o);continue}const a=t[o].trim();a.startsWith("#")&&!a.startsWith("##")&&s.push({line:o,text:a})}return{start:r,tags:s,prose:i}}const Js=e=>e.map(t=>t.text);function ul(e){const t=Js(e),n=Og(t);return n===void 0?{}:n==="custom"?{chart:n,chartLines:Eg(t)}:{chart:n}}function Gg(e){if(!e)return;const t=[];for(const n of e.wheres)for(const r of n.clauses){if(!r.binding)continue;const{field:s,op:i,given:o}=r.binding;t.push({field:ye.readPath(s),given:o,...i==="~"?{}:{op:i}})}return t.length>0?t:void 0}function Ug(e,t,n){const r=[];for(const s of e.givens){const i=/^([A-Za-z_][A-Za-z0-9_]*)\s*::\s*(\S+)\s+is\s+([\s\S]+)$/.exec(s.declaration);i&&r.push({name:i[1],type:i[2],default:i[3].trim(),...Vg(n(Js(is(e,t,s.line).tags)).tag)})}return r.length>0?r:void 0}function Vg(e){if(!e)return{};const t=e.tag("suggest"),n=t?.text("dimension"),r=e.numeric("range_min"),s=e.numeric("range_max");return{...e.text("label")===void 0?{}:{label:e.text("label")},...e.text("description")===void 0?{}:{description:e.text("description")},...e.text("control")===void 0?{}:{control:e.text("control")},...t&&n?{suggest:{...t.text("source")===void 0?{}:{source:t.text("source")},...t.text("query")===void 0?{}:{query:t.text("query")},dimension:n}}:{},...r===void 0?{}:{rangeMin:r},...s===void 0?{}:{rangeMax:s}}}function Ii(e,t){const n=e?.text(t)?.trim();if(n===void 0||!/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/.test(n))return;const r=Number(n);return Number.isInteger(r)&&r>=1?r:void 0}const Kg=/^"((?:[^"\\]|\\.)+)"$/,Hg=/^([A-Za-z_][A-Za-z0-9_]*)\s*\{/;async function Kr(e,t){try{return await Yg(e,t)}catch(n){return{ok:!1,reason:`A value in this file's tags cannot be read (${n instanceof Error?n.message:String(n)}), so it cannot be opened in the builder.`}}}async function Yg(e,t){const{parseAnnotation:n}=await L.loadMalloyTag(),r=ye.splitSourceLines(e),s=await ku(e);if(xu(s))return{ok:!1,reason:s.reason,...s.line?{line:s.line}:{}};const i=s.parsed,o=ye.descriptionNotes(r).text,a=ye.artifactTag(r);if(a===void 0)return{ok:!1,reason:"No `## artifact { … }` tag, so this file is not a composite dashboard."};if(!ye.artifactLeads(a.text))return{ok:!1,reason:ye.ARTIFACT_NOT_FIRST,line:a.from+1};const{tag:l,errors:u}=Su(n,[ye.tagAnnotation(a.text)]),c=l?.tag("artifact"),d=c?.text("kind"),f=d==="notebook"||d!=="dashboard"&&t?.startsWith("notebooks/")?"notebook":void 0,p=Aa(a.text);if(p===void 0)return u.length>0?{ok:!1,reason:`The \`## artifact\` tag does not parse: ${u[0]}`}:f==="notebook"?{ok:!1,legacyNotebook:!0,reason:"This notebook is in the cell format, with no `tiles=[…]` list."}:{ok:!1,reason:"The `## artifact` tag has no `tiles=[…]` list the builder can read."};const m=i.imports.map(T=>T.names?{kind:"names",names:T.names,from:T.from}:{kind:"all",from:T.from}),g=[],x=[],k=new Map;for(const T of i.sources){const A={name:T.name,base:T.base};T.dimensions.length>0&&(A.dimensions=T.dimensions.map(C=>({name:C.name,expression:C.expression})));const I=new Set(T.wheres.flatMap(C=>C.clauses.flatMap(W=>W.givens)));I.size>0&&(A.scopedBy=Array.from(I)),g.push(A);for(const C of T.dimensions){const W=n(Js(is(i,r,C.line).tags)).tag?.tag("drill");if(!W)continue;const F=W.textArray("to")??[W.text("to")??""];x.push({source:T.name,name:C.name,expression:C.expression,to:F.filter(Boolean),...W.text("given")?{given:W.text("given")}:{}})}k.set(T.name,new Map(T.views.map(C=>[C.name,C])))}const b=[];for(const{text:T}of p.entries){const A=Kg.exec(T),I=A?void 0:Hg.exec(T)?.[1];if(I!==void 0){const te=n([`# ${T}`]).tag?.tag(I);if(te?.text("kind")!=="text")return{ok:!1,reason:`The tile \`${T}\` is neither a quoted \`source -> view\` expression nor a \`${I} { kind=text }\` entry, which are the only forms the builder can lay out.`};if(b.some(E=>Ue(E)&&E.name===I))return{ok:!1,reason:`Two text tiles are named \`${I}\`, so the builder cannot tell them apart.`};const ue=Ii(te,"colspan");b.push({kind:"text",name:I,markdown:i.textBlocks.find(E=>E.name===I)?.body??"",...ue===void 0?{}:{colspan:ue},...te.has("break")?{break:!0}:{}});continue}const C=A?.[1]??T,W=A?ye.tileSteps(C):void 0;if(!W)return{ok:!1,reason:`The tile \`${C}\` is not a \`source -> view\` expression, which is the only form the builder can lay out.`};const{source:F,view:G}=W,J=k.get(F)?.get(G);if(J===void 0){b.push({name:G,source:F,declaration:{kind:"inherited"}});continue}const Q=n(Js(J.tags)).tag,se=J.body.kind==="reference"?{kind:"reference",from:J.body.from}:J.body.kind==="inline"?{kind:"inline"}:void 0;if(se===void 0){b.push({name:G,source:F,declaration:{kind:"opaque",why:J.body.kind==="unsupported"?J.body.why:"unreadable"},...Q?.text("label")?{label:Q.text("label")}:{},...Q?.text("subtitle")?{subtitle:Q.text("subtitle")}:{},...Q?.numeric("colspan")!==void 0?{colspan:Q.numeric("colspan")}:{},...ul(J.tags),...Q?.has("break")?{break:!0}:{},...Q?.has("borderless")?{borderless:!0}:{}});continue}const ce=Gg(J.body.kind==="reference"?J.body.refinement:J.body.kind==="inline"?J.body.stage:void 0);b.push({name:G,source:F,declaration:se,...ce?{filters:ce}:{},...Q?.text("label")?{label:Q.text("label")}:{},...Q?.text("subtitle")?{subtitle:Q.text("subtitle")}:{},...Q?.numeric("colspan")!==void 0?{colspan:Q.numeric("colspan")}:{},...ul(J.tags),...Q?.has("break")?{break:!0}:{},...Q?.has("borderless")?{borderless:!0}:{}})}const h=Ug(i,r,n),y={},w=c?.tag("givens");for(const T of Object.keys(w?.dict??{})){const A=w?.text(T);A!==void 0&&(y[T]=A)}const D=l?.tag("dashboard")?.has("columns")?Ii(l.tag("dashboard"),"columns"):c?.array("tiles")?Ii(c,"dashboard_columns"):void 0;return{ok:!0,document:{...f?{kind:f}:{},title:c?.text("title")??"",...o?{description:o}:{},...D===void 0?{}:{columns:D},...c?.has("autorun")?{autorun:c.isTrue("autorun")}:{},imports:m,sources:g,...h?{localGivens:h}:{},...Object.keys(y).length>0?{startingGivens:y}:{},...x.length>0?{drills:x}:{},tiles:b}}}const ei=e=>e.ok===!1;async function fl(e){const{problems:t}=await mi(e,"file://splice-check.malloy");return t.filter(n=>n.code==="syntax-error").map(n=>n.message??"").sort()}function Te(e){const t=n=>{if(Array.isArray(n))return n.map(t);if(n&&typeof n=="object"){const r={};for(const s of Object.keys(n).sort())r[s]=t(n[s]);return r}return n};return JSON.stringify(t(e))}function $u(e){return e.replace(/^(?:[ \t]*\r?\n)+/,"").trimEnd()}function Xg(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
77
|
+
`&&t.push(n+1);return t}function Zg(e,t){let n=e;for(const r of[...t].sort((s,i)=>i.start-s.start||i.end-s.end))n=n.slice(0,r.start)+r.text+n.slice(r.end);return n}const Tu=e=>e==="none"||gi(e)?e:void 0;function Ou(e,t=!0){const n=[];e.colspan!==void 0&&n.push(`# colspan=${e.colspan}`),e.break&&n.push("# break"),e.borderless&&n.push("# borderless"),e.label!==void 0&&n.push(`# label=${jt(e.label)}`),e.subtitle!==void 0&&n.push(`# subtitle=${jt(e.subtitle)}`);const r=t?Tu(e.chart):void 0;return r!==void 0&&n.push(zn(r,e.chartCarried)),n}function Ps(e){return/^#\s*([a-z_]+)/.exec(e)?.[1]}const Qg=new Set(["colspan","break","borderless","label","subtitle"]),Jg=new Set(["label","description","control","suggest","range_min","range_max"]),rt=e=>e.kind??"dashboard";function hl(e){const t=[];if(e.label!==void 0&&t.push(`label=${jt(e.label)}`),e.description!==void 0&&t.push(`description=${jt(e.description)}`),e.control!==void 0&&t.push(`control=${e.control}`),e.suggest){const n=e.suggest.source!==void 0?`source=${e.suggest.source}`:e.suggest.query!==void 0?`query=${jt(e.suggest.query)}`:void 0;t.push(`suggest { ${n?`${n} `:""}dimension=${jt(e.suggest.dimension)} }`)}return e.rangeMin!==void 0&&t.push(`range_min=${e.rangeMin}`),e.rangeMax!==void 0&&t.push(`range_max=${e.rangeMax}`),t.length>0?`# ${t.join(" ")}`:void 0}const pl=e=>`given: ${e.name} :: ${e.type} is ${e.default}`;function em(e,t,n){const r=e.sources.find(s=>s.name===t)?.views.find(s=>s.name===n);return r?r.line:-1}function gl(e){return`# drill { to=${e.to.length===1?e.to[0]:`[${e.to.map(n=>`"${n}"`).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const ti=e=>`${e.source}.${e.name}`,jt=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,Eo=e=>Ue(e)?Te(["text",e.name]):Te([e.name,e.source,e.declaration]),ft=Eo,ml=e=>Te(e.tiles.map(ft));function tm(e,t,n){if(rt(e)!==rt(t)&&!n)return{ok:!1,reason:"The document's kind is not changed by an ordinary edit; switch it with the explicit kind change."};const r=new Set(e.tiles.map(ft)),s=new Set(t.tiles.map(ft)),i=e.tiles.filter(f=>!s.has(ft(f))),o=t.tiles.filter(f=>!r.has(ft(f))),l=i.length>0||o.length>0||ml(e)!==ml(t);for(const f of o)if(we(f)&&f.declaration.kind!=="reference")return{ok:!1,reason:`A new tile names a view of a source; \`${f.name}\` is ${f.declaration.kind==="inline"?"an inline query":"not declared here"}, which the builder cannot write.`};const u=new Map(e.sources.map(f=>[f.name,f])),c=new Set(t.imports.flatMap(f=>f.kind==="names"?f.names:[]));for(const f of e.sources)c.add(f.base);const d=t.sources.filter(f=>!u.has(f.name));for(const f of e.sources){const p=t.sources.find(m=>m.name===f.name);if(!p||p.base!==f.base)return{ok:!1,reason:`The source \`${f.name}\` cannot be changed or removed here.`}}for(const f of d){if(!o.some(p=>we(p)&&p.source===f.name))return{ok:!1,reason:`A new source \`${f.name}\` needs a tile on it.`};if(!c.has(f.base))return{ok:!1,reason:`\`${f.base}\` is not imported by name in this file, so a tile cannot be put on it. Add it as a source first.`}}return{currentKeys:r,nextKeys:s,removedTiles:i,addedTiles:o,newSources:d,currentSources:u,reordered:l}}const vl=(e,t)=>e.colspan!==t.colspan||!!e.break!=!!t.break;function nm(e){let t="";for(let n=0;n<e.length;n++){if(e[n]!=='"'){t+=e[n];continue}const r=Hr(e,n);t+="x".repeat(Math.min(r,e.length-1)-n+1),n=r}return t}function bl(e,t){if(t===void 0)return`${e.name} { kind=text${e.colspan===void 0?"":` colspan=${e.colspan}`}${e.break?" break":""} }`;const n=nm(t),r=n.indexOf("{"),s=n.lastIndexOf("}");let i=t.slice(r+1,s),o=n.slice(r+1,s);const a=u=>{const c=u.exec(o);c&&(i=i.slice(0,c.index)+i.slice(c.index+c[0].length),o=o.slice(0,c.index)+o.slice(c.index+c[0].length))};a(/\s*\bcolspan\s*=\s*[^\s}]+/),a(/\s*\bbreak\b(?!\s*=)/);const l=[i.trim(),e.colspan===void 0?"":`colspan=${e.colspan}`,e.break?"break":""].filter(Boolean);return`${t.slice(0,r)}{ ${l.join(" ")} }${t.slice(s+1)}`}function rm(e){const{lines:t,wholeLine:n,current:r,next:s,reordered:i,currentKeys:o,nextKeys:a,edits:l}=e,u=new Map(r.tiles.filter(Ue).map(b=>[b.name,b])),c=s.tiles.filter(Ue).some(b=>{const h=u.get(b.name);return h!==void 0&&vl(h,b)});if(!i&&!c)return;const d=ye.artifactTag(t);if(!d)return{ok:!1,reason:"Could not find the `## artifact` tag to reorder."};const f=d.text,p=Aa(f);if(!p)return{ok:!1,reason:"Could not read the `tiles=[…]` list to rewrite it."};if(a.size===0&&o.size>0)return{ok:!1,reason:"A dashboard with no tiles is not served, so the last tile cannot be removed. Add another tile first."};const m=new Map;for(const{text:b}of p.entries){const h=/^"((?:[^"\\]|\\.)+)"$/.exec(b);if(h){const w=h[1].split("->").map(D=>D.trim());w.length===2&&m.set(`${w[0]}->${w[1]}`,b);continue}const y=/^([A-Za-z_][A-Za-z0-9_]*)\s*\{/.exec(b)?.[1];y!==void 0&&m.set(`text.${y}`,b)}const g=s.tiles.map(b=>{const h=!o.has(ft(b));if(Ue(b)){const y=m.get(`text.${b.name}`);return y!==void 0?u.has(b.name)&&!vl(u.get(b.name),b)?y:bl(b,y):h?bl(b):void 0}return m.get(`${b.source}->${b.name}`)??(h?`"${b.source} -> ${b.name}"`:void 0)});if(g.some(b=>b===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const x=f.slice(0,p.open).search(/tiles\s*=\s*$/),k=`${f.slice(0,x)}tiles=[${sm(f,p,g)}]${f.slice(p.close+1)}`;k!==f&&l.push({...Eu(n,d),text:`${k}
|
|
78
|
+
`})}function Eu(e,t){return{start:e(t.from).start,end:e(t.block?t.to-1:t.from).end}}function sm(e,t,n){const r=t.entries[0],s=t.entries[t.entries.length-1];if(!r||!/\n/.test(e.slice(t.open,t.close)))return n.join(", ");const i=e.slice(t.open+1,r.span.start),o=e.slice(s.span.end,t.close),a=i.slice(i.lastIndexOf(`
|
|
79
|
+
`)),l=t.entries.length>1?e.slice(r.span.end,t.entries[1].span.start):`,${a.startsWith(`
|
|
80
|
+
`)?a:" "}`;return`${i}${n.join(l)}${o}`}function yl(e,t){let n=0,r=0;for(let s=0;s<e.length;s++){const i=e[s];if(i==='"')s=Hr(e,s);else if(i==="{"||i==="[")n++===0&&r++;else if(i==="}"||i==="]")n--;else if(r===1&&n===1&&e.startsWith(t,s)&&!/[A-Za-z0-9_]/.test(e[s-1]??" ")){const o=/^\s*=\s*/.exec(e.slice(s+t.length));if(!o)continue;const a=s+t.length+o[0].length,l=e[a]==='"'?Hr(e,a)+1:a+(/^[^\s}]*/.exec(e.slice(a))?.[0].length??0),u=s-(/\s*$/.exec(e.slice(0,s))?.[0].length??0);return e.slice(0,u)+e.slice(l)}}return e}function im(e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(r==='"')n=Hr(e,n);else if(r==="{"||r==="[")t++;else if(r==="}"||r==="]")t--;else if(t===0&&e.startsWith("dashboard",n)&&!/[A-Za-z0-9_]/.test(e[n-1]??" ")){const s=/^dashboard\s*\{/.exec(e.slice(n));if(!s)continue;let i=1,o=n+s[0].length;for(;o<e.length&&i>0;o++)e[o]==='"'?o=Hr(e,o):e[o]==="{"?i++:e[o]==="}"&&i--;const a=n-(/\s*$/.exec(e.slice(0,n))?.[0].length??0);return e.slice(0,a)+e.slice(o)}}return e}function Hr(e,t){for(let n=t+1;n<e.length;n++)if(e[n]==="\\")n++;else if(e[n]==='"')return n;return e.length}function om(e){const{lines:t,wholeLine:n,current:r,next:s,edits:i}=e;if(rt(r)!==rt(s)||r.title!==s.title||r.autorun!==s.autorun||r.columns!==s.columns||Te(r.startingGivens)!==Te(s.startingGivens)){const o=ye.artifactTag(t);if(!o)return{ok:!1,reason:"Could not find the `## artifact` tag to change the page's settings."};const a=Eu(n,o),l=i.find(b=>b.start===a.start&&b.end===a.end);let u=l?l.text.replace(/\n$/,""):o.text;rt(r)!==rt(s)&&(u=yl(u,"kind"));const c=u.indexOf("artifact"),d=u.indexOf("{",c);let f=0,p=-1;for(let b=d;b<u.length;b++)if(u[b]==="{")f++;else if(u[b]==="}"&&--f===0){p=b;break}if(d<0||p<0)return{ok:!1,reason:"Could not read the `## artifact { … }` tag."};let m=u.slice(d+1,p);const g=o.block?`
|
|
81
|
+
${/\n([ \t]+)\S/.exec(m)?.[1]??" "}`:" ",x=b=>o.block?`${m.trimEnd()}${g}${b}
|
|
82
|
+
`:`${m.trimEnd()} ${b} `,k=(b,h)=>{const y=new RegExp(`${o.block?"[ \\t]*":"\\s*"}\\b${b}=(?:"(?:[^"\\\\]|\\\\.)*"|[^\\s}]+)`);if(h===void 0){const w=new RegExp(`
|
|
83
|
+
${y.source}[ \\t]*(?=
|
|
84
|
+
)`);m=m.replace(o.block&&w.test(m)?w:y,"")}else y.test(m)?m=m.replace(y,w=>`${o.block?w.slice(0,w.length-w.trimStart().length):" "}${b}=${h}`):m=x(`${b}=${h}`)};if(rt(r)!==rt(s)&&rt(s)==="notebook"?m=x("kind=notebook"):rt(r)!==rt(s)&&e.modelPath?.startsWith("notebooks/")&&(m=x("kind=dashboard")),r.title!==s.title&&k("title",s.title?jt(s.title):void 0),r.autorun!==s.autorun&&k("autorun",s.autorun===void 0?void 0:String(s.autorun)),Te(r.startingGivens)!==Te(s.startingGivens)){m=m.replace(/\s*\bgivens\s*\{[^}]*\}/,"");const b=Object.entries(s.startingGivens??{});b.length>0&&(m=x(`givens { ${b.map(([h,y])=>`${h}=${jt(y)}`).join(" ")} }`))}o.block?u=`${u.slice(0,d+1)}${m}${u.slice(p)}`:(m=m.replace(/\s{2,}/g," "),u=`${u.slice(0,d+1)}${m.startsWith(" ")?m:` ${m}`}${m.endsWith(" ")?"":" "}${u.slice(p)}`),r.columns!==s.columns&&(u=yl(u,"dashboard_columns"),u=im(u),s.columns!==void 0&&(u=`${u.trimEnd()} dashboard { columns=${s.columns} }`)),l?l.text=`${u}
|
|
85
|
+
`:i.push({...a,text:`${u}
|
|
86
|
+
`})}if(r.description!==s.description){const{read:o,blankAbove:a,below:l,belowBlock:u,inBlock:c}=ye.descriptionNotes(t);if(c||s.description===void 0&&u)return{ok:!1,reason:"The description is written in a `##|\"` block, which the builder cannot edit in place. Change it in the file's text."};const d=$u(s.description??"").split(`
|
|
87
|
+
`).map(g=>g.trim()===""?'##"':`##" ${g.trim()}`).join(`
|
|
88
|
+
`),f=o.length>0&&o[0]<ye.artifactLine(t),p=s.description===void 0,m=f?[...o.slice(1),...p?l:[]]:[...o,...a];for(const g of m)i.push({...n(g),text:""});if(f)i.push({...n(o[0]),text:s.description===void 0?"":`${d}
|
|
89
|
+
`});else if(s.description!==void 0){const g=n(ye.artifactLine(t)).start;i.push({start:g,end:g,text:`${d}
|
|
90
|
+
`})}}}function am(e){const{lines:t,wholeLine:n,indentOf:r,current:s,next:i,edits:o,parsed:a}=e,l=new Map((s.localGivens??[]).map(p=>[p.name,p])),u=new Map((i.localGivens??[]).map(p=>[p.name,p])),c=new Map(a.givens.map(p=>[p.name,p])),d=new Set;for(const[p,m]of l){const g=u.get(p);if(g!==void 0&&Te(g)===Te(m))continue;const x=c.get(p);if(x===void 0)return{ok:!1,reason:`Could not find where the given \`${p}\` is declared.`};const{tags:k,prose:b}=is(a,t,x.line),y=[...(g===void 0?k:k.filter(C=>{const W=Ps(C.text);return W!==void 0&&Jg.has(W)})).map(C=>C.line),...g===void 0?b:[]];for(const C of y)o.push({...n(C),text:""}),d.add(C);const w=Lt(a,x.span.end-1);if(g===void 0){o.push({start:n(x.line).start,end:n(w).end,text:""});for(let Q=x.line;Q<=w;Q++)d.add(Q);const C=Math.min(x.line,...y),W=x.blockHeader??C,F=(t[w+1]??"x").trim()==="",G=W===0||t[W-1].trim()==="",J=x.blockHeader===void 0||![...c.values()].some(Q=>Q.blockHeader===x.blockHeader&&Q.line>x.line&&u.has([...c.entries()].find(([,se])=>se===Q)?.[0]??""));F&&G&&J&&!d.has(w+1)&&(o.push({...n(w+1),text:""}),d.add(w+1));continue}const D=r(x.line),T=hl(g),I=g.type!==m.type||g.default!==m.default?x.blockHeader===void 0?pl(g):`${g.name} :: ${g.type} is ${g.default}`:t.slice(x.line,w+1).join(`
|
|
91
|
+
`).trim();o.push({start:n(x.line).start,end:n(w).end,text:(T?`${D}${T}
|
|
92
|
+
`:"")+`${D}${I}
|
|
93
|
+
`})}for(const[p,m]of c){if(m.blockHeader===void 0||u.has(p))continue;![...c.values()].some(x=>x.blockHeader===m.blockHeader&&!d.has(x.line))&&!d.has(m.blockHeader)&&(o.push({...n(m.blockHeader),text:""}),d.add(m.blockHeader))}const f=[...u.values()].filter(p=>!l.has(p.name));if(f.length>0){const p=Math.max(-1,...[...c.values()].map(h=>h.line)),m=(()=>{let h=-1;for(let y=0;y<t.length;y++){const w=t[y].trim();(w.startsWith("import ")||h>=0&&/^}\s*from\s/.test(w))&&(h=y)}return h})(),g=p>=0?p:m,x=f.map(h=>{const y=hl(h);return(y?`${y}
|
|
94
|
+
`:"")+`${pl(h)}
|
|
87
95
|
`}).join(`
|
|
88
|
-
`),
|
|
89
|
-
${
|
|
90
|
-
`})}}function
|
|
91
|
-
`});
|
|
92
|
-
`})
|
|
93
|
-
`)}
|
|
94
|
-
`)
|
|
96
|
+
`),k=g>=0?n(g).end:n(0).end;o.push({start:k,end:k,text:`
|
|
97
|
+
${x}`}),t.some(h=>h.trim().startsWith("##! experimental.givens"))||o.push({start:0,end:0,text:`##! experimental.givens
|
|
98
|
+
`})}}const xl=(e,t)=>`import { ${e.join(", ")} } from ${jt(t)}`;function lm(e){const{parsed:t,current:n,next:r,edits:s,wholeLine:i}=e,o=d=>Te(d.imports.flatMap(f=>f.kind==="all"?[f.from]:[]).sort());if(o(n)!==o(r))return{ok:!1,reason:"A whole-file `import` cannot be changed here."};if(Te(n.imports)===Te(r.imports))return;const a=r.imports.flatMap(d=>d.kind==="names"?[{...d,claimed:!1}]:[]),l=new Set([...r.sources.map(d=>d.base),...r.tiles.filter(we).map(d=>d.source)]),u=t.imports.map((d,f)=>({statement:d,entry:n.imports[f]}));for(const{statement:d,entry:f}of u){if(!f||f.kind!=="names")continue;const p=a.find(h=>!h.claimed&&h.from===f.from);p&&(p.claimed=!0);const m=p?.names??[],x=f.names.filter(h=>!m.includes(h)).find(h=>l.has(h));if(x!==void 0)return{ok:!1,reason:`\`${x}\` is still read by a tile, so its import cannot be removed.`};if(Te(m)===Te(f.names))continue;const k=m.length===0?ja(t,d.statement):d.statement,b=t.commentIn(k);if(b)return{ok:!1,reason:`Changing this import would also remove the comment inside it (\`${t.text.slice(b.start,b.end).trim()}\`), so nothing was written. Delete it in the file first.`};s.push({...k,text:m.length===0?"":xl(m,f.from)})}const c=a.filter(d=>!d.claimed);if(c.length>0){const d=t.imports.at(-1);if(!d)return{ok:!1,reason:"This file has no `import` to put a source beside. Import its first source in the file."};const f=i(Lt(t,d.statement.end-1)).end;s.push({start:f,end:f,text:c.map(p=>`${xl(p.names,p.from)}
|
|
99
|
+
`).join("")})}}function cm(e){const{lines:t,wholeLine:n,indentOf:r,current:s,next:i,edits:o,parsed:a}=e,l=new Map((s.drills??[]).map(c=>[ti(c),c])),u=new Map((i.drills??[]).map(c=>[ti(c),c]));for(const c of new Set([...l.keys(),...u.keys()])){const d=l.get(c),f=u.get(c);if(d&&f&&Te(d)===Te(f))continue;const p=f??d;if(f&&f.to.length===0)return{ok:!1,reason:`The drill on \`${c}\` names no destination.`};const m=a.sources.find(b=>b.name===p.source)?.dimensions.find(b=>b.name===p.name);if(m===void 0)return{ok:!1,reason:`\`${p.name}\` is not a dimension \`${p.source}\` declares in this file, so a drill cannot be put on it here.`};const{tags:g}=is(a,t,m.line),x=g.find(b=>/^#\s*drill\b/.test(b.text)),k=r(m.line);if(f===void 0)x&&o.push({...n(x.line),text:""});else if(x)o.push({...n(x.line),text:`${k}${gl(f)}
|
|
100
|
+
`});else{const b=n(m.line).start;o.push({start:b,end:b,text:`${k}${gl(f)}
|
|
101
|
+
`})}}}function dm(e){const{lines:t,wholeLine:n,removedTiles:r,edits:s,parsed:i}=e;for(const o of r){if(Ue(o)||o.declaration.kind==="inherited")continue;const a=Cu(e,o);if(!a)return{ok:!1,reason:`Could not find where \`${o.name}\` is declared.`};if(a.siblings>1)return{ok:!1,reason:`\`${o.name}\` is one of several views declared by a single \`view:\` statement, which the builder does not restructure.`};const l=Lt(i,a.statement.start),u=Lt(i,a.statement.end-1),c=i.trailingComment(u),d=c&&c.start>=a.statement.end?c.end:a.statement.end;if(i.text.slice(i.lineStarts[l],a.statement.start).trim()!==""||i.text.slice(d,n(u).end).trim()!==""){s.push({...ja(i,a.statement),text:""});continue}s.push({start:i.lineStarts[l],end:n(u).end,text:""});const p=l===0?"":t[l-1].trim();(t[u+1]??"x").trim()===""&&(l===0||p===""||p.endsWith("{"))&&s.push({...n(u+1),text:""})}}function um(e){const{sourceText:t,lines:n,wholeLine:r,addedTiles:s,newSources:i,currentSources:o,edits:a,parsed:l}=e,u=new Map;for(const f of s){if(Ue(f))continue;const p=u.get(f.source)??[];p.push(f),u.set(f.source,p)}const c=(f,p)=>{const m=f.declaration.kind==="reference"?f.declaration.from:f.name,g=(f.filters??[]).map(x=>`where: ${ye.malloyPath(x.field)} ${x.op??"~"} $${x.given}`).join(", ");return[...Ou(f).map(x=>`${p}${x}`),`${p}view: ${f.name} is ${m}${g?` + { ${g} }`:""}`].join(`
|
|
102
|
+
`)};let d=-1;for(const f of l.sources)d=Math.max(d,Lt(l,f.span.end-1));for(const[f,p]of u)if(o.has(f)){const m=l.sources.find(y=>y.name===f);if(!m)return{ok:!1,reason:`Could not find where the source \`${f}\` is declared.`};if(!m.properties)return{ok:!1,reason:`\`${f}\` never opens an \`extend { … }\` block, so a new tile cannot be added inside it.`};const g=m.line,x=Lt(l,m.properties.closeStart);let k=" ";for(let y=g+1;y<x;y++){const w=/^(\s+)view:/.exec(n[y]);if(w){k=w[1];break}}const b=r(x).start,h=(n[x-1]??"").trim()==="";a.push({start:b,end:b,text:(h?"":`
|
|
103
|
+
`)+p.map(y=>c(y,k)).join(`
|
|
95
104
|
|
|
96
105
|
`)+`
|
|
97
|
-
`})}else{const
|
|
98
|
-
source: ${
|
|
99
|
-
`+
|
|
106
|
+
`})}else{const m=i.find(h=>h.name===f);if(!m)return{ok:!1,reason:`The tile's source \`${f}\` is not declared.`};const g=`
|
|
107
|
+
source: ${m.name} is ${m.base} extend {
|
|
108
|
+
`+p.map(h=>c(h," ")).join(`
|
|
100
109
|
|
|
101
110
|
`)+`
|
|
102
111
|
}
|
|
103
|
-
`;let
|
|
112
|
+
`;let x=d;if(x<0)for(let h=0;h<n.length;h++){const y=n[h].trim();(/^(import\s|given:|}\s*from\s)/.test(y)||/^[A-Z_]+\s*::/.test(y))&&(x=h)}const k=x>=0?r(x).end:t.length,b=k===t.length&&!t.endsWith(`
|
|
104
113
|
`)?`
|
|
105
|
-
`:"";a.push({start:
|
|
106
|
-
`})}const
|
|
107
|
-
`
|
|
108
|
-
|
|
109
|
-
${
|
|
110
|
-
`),a=lv(e),l=p=>({start:a[p],end:p+1<a.length?a[p+1]:e.length}),u=p=>/^\s*/.exec(o[p])?.[0]??"",d=[],c={...i,sourceText:e,parsed:s.parsed,lines:o,starts:a,wholeLine:l,indentOf:u,current:r,next:t,edits:d};for(const p of[gv,yv,bv,xv,wv,_v,kv]){const w=p(c);if(w)return w}const h=p=>{const{drills:w,localGivens:x,...m}=p,g=p.tiles.map(b=>{if(b.filters?.length)return b;const{filters:_,...$}=b;return $});return{...m,tiles:g,...w?.length?{drills:[...w].sort((b,_)=>Di(b).localeCompare(Di(_)))}:{},...x?.length?{localGivens:x}:{}}};if(d.length===0)return be(h(r))!==be(h(t))?{ok:!1,reason:"No part of this edit was recognized, so nothing was written. Your changes are still here."}:{ok:!0,source:e};const f=cv(e,d);if((await Ja(e)).length===0){const p=await Ja(f);if(p.length>0)return{ok:!1,reason:`The edit would have produced a file Malloy cannot parse, so it was not written (${p[0]}). Your changes are still here.`}}const v=await Ti(f);return Oi(v)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${v.reason}`}:be(h(v.document))!==be(h(t))?{ok:!1,reason:"What was written did not read back as what was asked for, so it was not written. Your changes are still here."}:{ok:!0,source:f}}function Ov(e){const[t,n]=S.useState({stack:[e.document],index:0}),[r,i]=S.useState(e.source),[s,o]=S.useState(void 0),[a,l]=S.useState(e.document),u=t.stack[t.index],d=S.useCallback(x=>{o(void 0),n(m=>{const g=structuredClone(m.stack[m.index]);if(x(g),JSON.stringify(g)===JSON.stringify(m.stack[m.index]))return m;const _=[...m.stack.slice(0,m.index+1),g].slice(-100);return{stack:_,index:_.length-1}})},[]),c=S.useCallback(()=>{o(void 0),n(x=>x.index>0?{...x,index:x.index-1}:x)},[]),h=S.useCallback(()=>{o(void 0),n(x=>x.index<x.stack.length-1?{...x,index:x.index+1}:x)},[]),f=S.useCallback(async()=>{const x=await eo(r,u);if(Zs(x))return o(x.reason),{ok:!1,reason:x.reason};try{await e.onSave?.(x.source)}catch(m){const g=`Could not save: ${m}`;return o(g),{ok:!1,reason:g}}return i(x.source),l(u),o(void 0),{ok:!0}},[u,e,r]),v=S.useMemo(()=>JSON.stringify(u)!==JSON.stringify(a),[u,a]),p=S.useMemo(()=>{const x=new Set(a.tiles.map(Js)),m=new Set(u.tiles.map(Js));return[...x].some(g=>!m.has(g))||[...m].some(g=>!x.has(g))},[u,a]),w=S.useCallback(async()=>{const x=await eo(r,u);return Zs(x)?{ok:!1,reason:x.reason}:{ok:!0,source:x.source}},[u,r]);return{document:u,source:r,canUndo:t.index>0,canRedo:t.index<t.stack.length-1,dirty:v,...s===void 0?{}:{error:s},update:d,undo:c,redo:h,save:f,preview:w,structural:p}}function eu({source:e,document:t,onSave:n,onChange:r,onDirtyChange:i,renderTile:s,controls:o,givens:a,catalog:l,toolbar:u,dashboards:d,onEvent:c,savesTo:h="package"}){const f=Ov({source:e,document:t,...n?{onSave:n}:{}}),[v,p]=S.useState(void 0),[w,x]=S.useState(!1),m=f.document.columns??j.DEFAULT_COLUMNS,{resize:g,gridBox:b,startResize:_,onResize:$,endResize:O}=Bg({tiles:f.document.tiles,columns:m,onStart:p,commit:(E,D)=>f.update(B=>{B.tiles[E].colspan=D})}),{dragging:C,preview:I,onDragStart:P,onDragOver:U,onDragEnd:W}=Ng({tiles:f.document.tiles,commit:E=>f.update(D=>{D.tiles=E}),onLanded:p}),[M,z]=S.useState(void 0),[V,ee]=S.useState(void 0),[Se,oe]=S.useState(!1),[Le,Ve]=S.useState(void 0),[Ce,Ye]=S.useState(null),[Ge,We]=S.useState(void 0);S.useEffect(()=>{r?.(f.document)},[f.document,r]),S.useEffect(()=>{i?.(f.dirty)},[f.dirty,i]);const Xe=S.useMemo(()=>zp(f.document),[f.document]),$e=S.useMemo(()=>{const E=new Set((t.localGivens??[]).map(D=>D.name));return(a??[]).filter(D=>!E.has(D.name))},[t,a]),fe=S.useMemo(()=>dp(f.document,$e),[f.document,$e]),L=S.useMemo(()=>new Map(f.document.sources.map(E=>[E.name,Aa(l,E.base)])),[l,f.document.sources]),G=S.useCallback(E=>L.get(E.source)??Aa(l,E.source),[L,l]),_e=(E,D)=>{const B=[];for(const Q of f.document.tiles){const Ue=G(Q);if(!Ue)continue;const ke=new Map(Ue.map(se=>[se.name,se.type]));for(const se of Q.filters??[])se.given===E&&(!ke.has(se.field)||!ai(D,ke.get(se.field)))&&B.push(`${se.field} on ${Q.label??Q.name} (${f.document.sources.find(Ee=>Ee.name===Q.source)?.base??Q.source})`)}return B},X=S.useMemo(()=>fe.filter(E=>E.origin==="model"&&E.boundTiles===0),[fe]),ze=S.useCallback(()=>{We(void 0),x(!0);const E=j.now(),{structural:D}=f,B=f.document.tiles.length;f.save().then(Q=>{Q.ok===!0?c?.({type:"dashboard.saved",tiles:B,structural:D,where:h,durationMs:j.now()-E}):c?.({type:"dashboard.save_refused",reason:Q.reason})}).finally(()=>x(!1))},[f,c,h]),ne=S.useCallback(()=>{if(!(!n||!f.dirty||w)){if(!f.structural){ze();return}f.preview().then(E=>{E.ok?We({before:f.source,after:E.source}):ze()})}},[n,f,w,ze]),at=E=>{oe(!1),f.update(D=>{let B=D.sources.find(ke=>ke.base===E.base);if(!B){const ke=new Set(D.sources.map(Ee=>Ee.name));let se=`${E.base}_tiles`;for(let Ee=2;ke.has(se);Ee++)se=`${E.base}_tiles_${Ee}`;B={name:se,base:E.base},D.sources.push(B)}const Q=new Set(D.tiles.filter(ke=>ke.source===B.name).map(ke=>ke.name));let Ue=`${E.view}_tile`;for(let ke=2;Q.has(Ue);ke++)Ue=`${E.view}_tile_${ke}`;D.tiles.push({name:Ue,source:B.name,declaration:{kind:"reference",from:E.view},colspan:E.colspan,...E.label?{label:E.label}:{}})}),p(f.document.tiles.length)},Fe=E=>{ee(void 0),p(void 0),f.update(D=>{D.tiles.splice(E,1)})};Sp(S.useMemo(()=>({undo:f.undo,redo:f.redo,...n?{save:ne}:{},escape:()=>{!V&&!M&&p(void 0)},nudge:E=>{if(v===void 0)return;const D=f.document.tiles[v];if(!D||D.declaration.kind==="inherited")return;const B=Math.min(Math.max((D.colspan??1)+E,1),m);B!==(D.colspan??1)&&f.update(Q=>{Q.tiles[v].colspan=B})}}),[f,n,ne,V,M,v,m]));const xt=(E,D,B)=>{z(void 0),f.update(Q=>{B&&mp(Q,B),vp(Q,E,D)})},T=E=>{z(void 0),f.update(D=>yp(D,E))},A=(()=>{const E=f.document.tiles;return g!==void 0?E.map((D,B)=>B===g.index?{...D,colspan:g.span}:D):I??E})(),q=C?Up(A,m):A.map(Pd);return y.jsxs(k.Stack,{sx:{gap:0},children:[y.jsx($p,{canUndo:f.canUndo,canRedo:f.canRedo,onUndo:f.undo,onRedo:f.redo,dirty:f.dirty,saving:w,...n?{onSave:ne}:{},...u?{actions:u}:{},...l?{onAddTile:()=>oe(!0)}:{},onSettings:Ye}),y.jsxs(k.Stack,{sx:{gap:2,px:"4px",pb:"4px"},children:[y.jsx(j.DashboardProse,{title:f.document.title||"Untitled dashboard",...f.document.description?{description:f.document.description}:{}}),y.jsx(Bp,{controls:fe,tileCount:f.document.tiles.length,unknownFieldsOf:_e,onEdit:E=>z({control:E}),onAdd:()=>z({}),children:o}),f.error&&y.jsx(k.Alert,{severity:"warning",children:f.error}),y.jsx(Hh,{sensors:kg,onDragStart:P,onDragOver:U,onDragEnd:W,children:y.jsxs(k.Box,{ref:b,sx:{position:"relative"},children:[(g!==void 0||C)&&y.jsx(Mg,{columns:m}),y.jsx(j.DashboardGrid,{tiles:q,columns:m,keyOf:E=>E.kind==="gap"?Md(E.after):pt(E.tile),renderTile:E=>{if(E.kind==="gap")return y.jsx(Pg,{after:E.after});const{tile:D,index:B}=E;return y.jsx(Dg,{tile:D,index:B,selected:B===v,menuOpen:V?.index===B,resizeSpan:g?.index===B?g.span:void 0,columns:m,onSelect:()=>p(B),onOpenMenu:Q=>{p(B),ee({anchor:Q,index:B})},onResizeStart:Q=>_(Q,B),onResizeMove:$,onResizeEnd:O,children:s?s(D):y.jsx(Cg,{tile:D})})}})]})}),y.jsx(Wp,{open:M!==void 0,document:f.document,...M?.control?{control:M.control}:{},available:X,...l?{fieldsFor:G}:{},onClose:()=>z(void 0),onApply:xt,onRemove:T}),y.jsx(Vg,{anchor:V?.anchor??null,tile:V===void 0?void 0:f.document.tiles[V.index],onClose:()=>ee(void 0),onCommit:E=>{const D=V?.index;D!==void 0&&f.update(B=>{B.tiles[D]=E})},onRemove:()=>{V!==void 0&&Fe(V.index)},columns:m,onDrills:()=>{V!==void 0&&Ve(f.document.tiles[V.index]?.source)}}),y.jsx(Rp,{open:Le!==void 0,document:f.document,source:f.document.sources.find(E=>E.name===Le),givenNames:fe.map(E=>E.name),dashboards:d??[],onClose:()=>Ve(void 0),onApply:E=>f.update(D=>{const Q=[...(D.drills??[]).filter(Ue=>Ue.source!==Le),...E];Q.length===0?delete D.drills:D.drills=Q})}),y.jsx(Fp,{anchor:Ce,settings:Xe,onClose:()=>Ye(null),onCommit:E=>f.update(D=>{D.title=E.title,E.description===void 0?delete D.description:D.description=E.description,E.columns===void 0?delete D.columns:D.columns=E.columns,E.autorun===void 0?delete D.autorun:D.autorun=E.autorun})}),y.jsx(Mp,{open:Se,document:f.document,catalog:l,columns:m,onClose:()=>oe(!1),onAdd:at}),y.jsx(Ap,{open:Ge!==void 0,before:Ge?.before??"",after:Ge?.after??"",onConfirm:ze,onClose:()=>We(void 0)})]})]})}function Tv(e,t){const n=new Set;for(const s of e.tiles)for(const o of s.filters??[])n.add(o.given);const r=[],i=new Set;for(const s of e.localGivens??[])n.has(s.name)&&(i.add(s.name),r.push(Dv(s)));for(const s of t)s.name===void 0||i.has(s.name)||!n.has(s.name)||(i.add(s.name),r.push(s));return r}function Dv(e){return{name:e.name,type:e.type,default:e.default,...e.label===void 0?{}:{label:e.label},...e.description===void 0?{}:{description:e.description},...e.control===void 0?{}:{control:e.control},...e.suggest?{suggest:{...e.suggest.source===void 0?{}:{source:e.suggest.source},...e.suggest.query===void 0?{}:{query:e.suggest.query},dimension:e.suggest.dimension}}:{},...e.rangeMin===void 0?{}:{rangeMin:e.rangeMin},...e.rangeMax===void 0?{}:{rangeMax:e.rangeMax}}}function Cv(e,t,n,r=new Map){if(t.declaration.kind==="inherited")return{expression:`${t.source} -> ${t.name}`,givenNames:void 0};const i=t.source,s=t.declaration.kind==="reference"?t.declaration.from:t.name,o=new Map((e.localGivens??[]).map(d=>[d.name,d.type])),a=[],l=[];for(const d of t.filters??[]){const c=`where: ${d.field} ${d.op??"~"}`;if(n.has(d.given)){a.push(d.given),l.push(`${c} $${d.given}`);continue}if(!o.has(d.given))continue;const h=j.malloyLiteral(r.get(d.given),o.get(d.given));h!==void 0&&l.push(`${c} ${h}`)}const u=l.join(", ");return{expression:`${i} -> ${s}`+(u?` + { ${u} }`:""),givenNames:a}}async function Pv(e){const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t),n=>n.toString(16).padStart(2,"0")).join("")}const sl=(e,t,n,r)=>({workspace:e,type:"dashboard",path:`${t}/${n}/${r}`});function Mv(e){const{onExit:t,onEvent:n,onDirtyChange:r}=e,i=(()=>{if("resourceUri"in e)try{return j.parseResourceUri(e.resourceUri)}catch{return}})(),s="resourceUri"in e?i?.environmentName??"":e.environmentName,o="resourceUri"in e?i?.packageName??"":e.packageName,a="resourceUri"in e?e.dashboard:e.dashboardName,l=i?.versionId,u="resourceUri"in e?!!i?.environmentName&&!!i?.packageName:!0,{apiClients:d,mutable:c}=Be.useServer(),h=cu.useQueryClient(),f=S.useRef(j.now()),v=S.useRef(n);v.current=n;const p=S.useRef(r);p.current=r;const w=j.useOptionalDocumentStorage()?.documentStorage,x=`dashboards/${a}.malloy`,m=j.useQueryWithApiError({queryKey:["dashboard-editor-model",s,o,x,l],queryFn:()=>d.models.getModel(s,o,x,l),enabled:u}),g=m.data?.data?.sourceText,[b,_]=S.useState(void 0),[$,O]=S.useState(void 0),[C,I]=S.useState(w===void 0),[P,U]=S.useState(!1),[W,M]=S.useState(void 0);S.useEffect(()=>{if(!w)return;let R=!1;return M(void 0),(async()=>{try{const te=await w.listWorkspaces(!1),Oe=te.find(he=>he.authoritative)??te.find(he=>he.writeable);if(R)return;if(_(Oe),Oe!==void 0){const he=await w.getDocument(sl(Oe.name,s,o,x)).catch(ae=>{if(!j.isDocumentNotFound(ae))throw ae});if(R)return;O(he),U(he!==void 0)}}catch(te){if(R)return;M(ol(te))}R||I(!0)})(),()=>{R=!0}},[w,s,o,x]);const z=b?.authoritative===!0,V=z&&W!==void 0,[ee,Se]=S.useState(void 0),oe=(z||ee===!0)&&$!==void 0,[Le,Ve]=S.useState(void 0),[Ce,Ye]=S.useState(void 0),Ge=S.useRef(void 0),We=S.useRef(void 0),[Xe,$e]=S.useState(void 0),fe=m.dataUpdatedAt,L=S.useRef(fe);L.current=fe;const G=Xe!==void 0&&Xe.onFetch===fe?Xe.text:g,_e=S.useRef(G);_e.current=G;const X=oe?$:G,[ze,ne]=S.useState(!1),[at,Fe]=S.useState(void 0),[xt,T]=S.useState(void 0),A=X!==void 0&&X!==xt,q=Le?.source,E=A&&ze&&q!==void 0&&X!==at,D=E?q:A?X:q??X,B=E?X:void 0,Q=S.useRef(q);Q.current=q;const Ue=S.useRef(X);Ue.current=X;const ke=S.useRef("package");ke.current=oe?z?"record":"draft":"package",S.useEffect(()=>{if(D===void 0||!C||V||D===Q.current)return;let R=!1;const te=_e.current,Oe=Ue.current;return Ti(D).then(he=>{if(!R){if(Oi(he)){const ae=he.line?`${he.reason} (line ${he.line})`:he.reason;Ye(ae),v.current?.({type:"dashboard.open_refused",reason:ae});return}Ye(void 0),Ge.current=void 0,We.current=te,$e(void 0),Fe(void 0),T(Oe),Ve(ae=>({source:D,document:he.document,generation:(ae?.generation??0)+1})),v.current?.({type:"dashboard.opened",from:ke.current,tiles:he.document.tiles.length,durationMs:j.now()-f.current})}}),()=>{R=!0}},[D,C,V]);const se=b===void 0?void 0:sl(b.name,s,o,x),Ee=S.useCallback(async R=>{if(!w||!se)throw new Error("This host keeps no documents, so there is nowhere to save.");await w.saveDocument(se,R),Ve(te=>te&&{...te,source:R}),O(R),(z||ee===!0)&&T(R),z||Se(te=>te??!1)},[w,se,z,ee]),[Qt,Ct]=S.useState(void 0),Rr=S.useCallback(async R=>{const te=We.current,Oe=Ge.current??(te===void 0?void 0:await Pv(te));if(Oe===void 0)throw new Error("The package file is still loading; try again.");let he;try{he=await d.models.updateModelSource(s,o,x,{source:R,expectedHash:Oe})}catch(ae){throw h.invalidateQueries({queryKey:["dashboard-editor-model",s,o,x,l]}),new Error(Av(ae))}if(Ve(ae=>ae&&{...ae,source:R}),$e({text:R,onFetch:L.current}),T(R),Ge.current=he.data.contentHash,Ct(void 0),w&&se)try{await w.deleteDocument(se),O(void 0),U(!1)}catch(ae){j.isDocumentNotFound(ae)?(O(void 0),U(!1)):Ct(ol(ae))}Se(!1),await h.invalidateQueries({queryKey:["dashboard-editor-model",s,o,x,l]});for(const ae of["dashboard-editor-manifest","dashboards","dashboard"])h.invalidateQueries({queryKey:[ae]})},[d,s,o,x,l,w,se,h]),Pt=z?"host":c?"package":"browser",Zt=b?.writeable===!0,Wn=l!==void 0&&Pt==="package",Lr=W===void 0?z?w&&se&&Zt?Ee:void 0:Wn?void 0:c?Rr:w&&se&&Zt?Ee:void 0:void 0,zn=b?.name,Fn=S.useCallback(R=>{v.current?.(R.type==="dashboard.saved"&&R.where!=="package"&&zn!==void 0?{...R,workspace:zn}:R)},[zn]),Gi=S.useCallback(R=>{ne(R),p.current?.(R)},[]),Nn=R=>{f.current=j.now(),Fe(R?$:G),Se(R)},Ui=()=>{f.current=j.now(),Fe(B)};if(!u&&"resourceUri"in e)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["A dashboard resource URI must name an environment and a package. Received: ",e.resourceUri]});if(m.isError)return y.jsx(j.ApiErrorDisplay,{error:m.error,context:"Opening the dashboard"});if(!g||!C)return y.jsxs(k.Stack,{sx:{gap:2},children:[y.jsx(j.DashboardBar,{}),y.jsx(j.Loading,{text:"Opening the dashboard…"})]});if(V)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened: ",W]});if(Ce)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened in the builder: ",Ce]});const Z=$!==void 0&&$!==g;return y.jsxs(k.Stack,{sx:{gap:2},children:[!z&&P&&Z&&ee===void 0&&y.jsx(k.Alert,{severity:"info",action:y.jsxs(k.Stack,{direction:"row",sx:{gap:1},children:[y.jsx(k.Button,{size:"small",onClick:()=>Nn(!0),children:"Resume"}),y.jsx(k.Button,{size:"small",onClick:()=>Nn(!1),children:"Start from the package"})]}),children:"You have edits to this dashboard saved in this browser that the package does not have."}),B!==void 0&&y.jsx(k.Alert,{severity:"warning",action:y.jsx(k.Button,{size:"small",onClick:Ui,children:"Load it"}),children:Pt==="package"?"This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and until you do, saving is refused.":Pt==="host"?"This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and saving keeps yours and writes over it.":"The package's copy of this dashboard changed since you opened it. Your edits are still here; loading the new version replaces them."}),Qt!==void 0&&y.jsxs(k.Alert,{severity:"warning",children:["The file was saved into the package, but the copy kept beside it could not be cleared, so it will be offered again:"," ",Qt]}),Le&&y.jsx(jv,{environmentName:s,packageName:o,modelPath:x,slug:a,...l!==void 0?{versionId:l}:{},opened:Le,onSave:Lr,onDirtyChange:Gi,savesTo:Pt,...n?{onEvent:Fn}:{},toolbar:t&&y.jsx(j.SecondaryButton,{label:"Done editing",icon:y.jsx(j.CheckIcon,{}),onClick:t}),note:Iv({authoritative:z,mutable:c,pinnedPackageSave:Wn,...b?{workspace:b}:{},...W!==void 0?{readFailure:W}:{},...l!==void 0?{versionId:l}:{}})},Le.generation)]})}function Iv({authoritative:e,mutable:t,pinnedPackageSave:n,workspace:r,readFailure:i,versionId:s}){return i!==void 0?`The saved copy could not be read, so Save is off: ${i}`:e&&r?r.writeable?r.description:`${r.description}: you cannot save into it.`:n?`Reading version ${s}: a version is a fixed point in history, so Save is off.`:t?"Save writes the file into the package.":r?`${r.description}: this server does not take writes.`:"This server does not take writes."}function jv({environmentName:e,packageName:t,modelPath:n,slug:r,versionId:i,opened:s,onSave:o,onDirtyChange:a,onEvent:l,savesTo:u,toolbar:d,note:c}){const{apiClients:h}=Be.useServer(),{data:f,isSuccess:v}=j.useQueryWithApiError({queryKey:["dashboard-editor-manifest",e,t,r,i],queryFn:()=>h.dashboards.getDashboard(e,t,r,i)}),p=f?.data,{data:w}=j.useQueryWithApiError({queryKey:["dashboard-editor-dashboards",e,t,i],queryFn:()=>h.dashboards.listDashboards(e,t,i)}),x=S.useMemo(()=>(w?.data??[]).map(M=>M.name).filter(M=>!!M&&M!==r),[w,r]),m=S.useMemo(()=>{const M=n.slice(0,n.lastIndexOf("/")+1);return s.document.imports.map(z=>({...z,path:new URL(z.from,`https://malloy.invalid/${M}`).pathname.slice(1)}))},[s.document.imports,n]),{data:g}=j.useQueryWithApiError({queryKey:["dashboard-editor-catalog",e,t,...m.map(M=>M.path),i],queryFn:async()=>{const M=(await h.models.listModels(e,t,i)).data.filter(ee=>ee.path&&!ee.error),V=(await Promise.allSettled(M.map(ee=>h.models.getModel(e,t,ee.path,i).then(Se=>Se.data)))).flatMap(ee=>ee.status==="fulfilled"?[ee.value]:[]);return Cp(Td(V),m,V)},enabled:m.length>0}),[b,_]=S.useState(s.document);S.useEffect(()=>_(s.document),[s.document]);const $=S.useMemo(()=>p?.givens??[],[p]),O=S.useMemo(()=>new Set($.map(M=>M.name).filter(M=>M!==void 0)),[$]),C=S.useMemo(()=>Tv(b,$),[b,$]),{declaredTypes:I,applied:P,panel:U}=j.useDocumentControls({specs:C,loaded:v,startingValues:p?.startingGivens,documentKey:`${e}/${t}/${i??""}/${r}/edit`,autorun:p?.autorun!==!1,environmentName:e,packageName:t,modelPath:p?.path,versionId:i,documentName:r}),W=S.useMemo(()=>function(z){const V=Cv(b,z,O,P);return y.jsx(j.DashboardTile,{environmentName:e,packageName:t,versionId:i,modelPath:n,tile:V.expression,label:z.label??j.tileTitle(`${z.source} -> ${z.name}`),subtitle:z.subtitle,borderless:z.borderless,givens:P,declaredTypes:I,givenNames:V.givenNames,height:j.TILE_MAX_HEIGHT})},[b,O,e,t,i,n,P,I]);return y.jsxs(k.Stack,{sx:{gap:1},children:[y.jsx(eu,{source:s.source,document:s.document,renderTile:W,givens:C.filter(M=>M.name!==void 0).map(M=>({name:M.name,...M.label?{label:M.label}:{},...M.type?{type:M.type}:{},...M.suggest?.dimension?{field:M.suggest.dimension}:{}})),onChange:_,onDirtyChange:a,...g?{catalog:g}:{},dashboards:x,...l?{onEvent:l}:{},toolbar:d,controls:v?y.jsx(j.GivensPanel,{...U,layout:"bar"}):void 0,...o?{onSave:o}:{},savesTo:u}),y.jsx(k.Box,{sx:{px:.5},children:y.jsx(k.Typography,{variant:"caption",sx:{opacity:.7},children:c})})]})}function ol(e){return e instanceof Error?e.message:String(e)}function Av(e){const t=e.response?.data;return t?.message?t.message:e instanceof Error?e.message:String(e)}typeof globalThis.process>"u"?globalThis.process={env:{}}:globalThis.process.env===void 0&&(globalThis.process.env={});exports.DashboardBuilder=eu;exports.DashboardEditor=Mv;exports.buildCatalog=Td;exports.readDashboardDocument=Ti;exports.readFailed=Oi;exports.spliceDashboardDocument=eo;exports.spliceFailed=Zs;
|
|
114
|
+
`:"";a.push({start:k,end:k,text:b+g}),d=x}}function fm(e){const{lines:t,starts:n,wholeLine:r,indentOf:s,current:i,next:o,edits:a,parsed:l}=e,u=new Map(i.tiles.map(c=>[ft(c),c]));for(const c of o.tiles){const d=u.get(ft(c));if(d===void 0||Ue(c)||Ue(d)||Te(ni(d))===Te(ni(c)))continue;if(c.declaration.kind==="inherited")return{ok:!1,reason:`\`${c.source} -> ${c.name}\` is declared on its source, not in this dashboard, so its presentation cannot be changed here.`};const f=em(l,c.source,c.name);if(f<0)return{ok:!1,reason:`Could not find where \`${c.name}\` is declared inside \`${c.source}\`.`};const{tags:p}=is(l,t,f),m=s(f),g=Ou(c,!1),x=new Map(g.map(I=>[Ps(I)??I,I])),k=new Set,b=Tu(c.chart),h=wl(d)!==wl(c);if(h){const I=p.filter(F=>Gr(F.text)),C=p.filter(F=>Ht(F.text)),W=d.chart==="custom"?p.filter(F=>Ht(F.text)||Gr(F.text)):I.length>0?I:C.length>1?C:[];if(W.length>0)return{ok:!1,reason:`\`${c.source} -> ${c.name}\` has a chart line the builder does not model (${W.map(F=>F.text).join(" and ")}), so its chart cannot be changed here.`}}let y=!1;for(const I of p){if(h&&Ht(I.text)){b===void 0?a.push({...r(I.line),text:""}):I.text!==zn(b,c.chartCarried)&&a.push({...r(I.line),text:`${m}${zn(b,c.chartCarried)}
|
|
115
|
+
`}),y=!0;continue}const C=Ps(I.text);if(C===void 0||!Qg.has(C))continue;const W=x.get(C);if(W===void 0){a.push({...r(I.line),text:""});continue}k.add(C),W!==I.text&&a.push({...r(I.line),text:`${m}${W}
|
|
116
|
+
`})}const w=g.filter(I=>!k.has(Ps(I)??I));if(h&&b!==void 0&&!y&&w.push(zn(b,c.chartCarried)),w.length>0){const I=n[f];a.push({start:I,end:I,text:w.map(C=>`${m}${C}
|
|
117
|
+
`).join("")})}if(Te(d.filters)===Te(c.filters))continue;const D=Cu(e,c);if(!D)return{ok:!1,reason:`Could not find \`${c.name}\`'s declaration to filter it.`};if(D.body.kind==="reference"){const I=ym(e,c,D);if(I)return I;continue}if(D.body.kind!=="inline")return{ok:!1,reason:`\`${c.name}\`'s body is ${D.body.why}, so there is no single first stage to write its filter into.`};const T=Iu(c.filters,D.body.stage);if(T)return Du(c.name,T.given);const A=Au(e,c,D.body.stage);if(A)return A}}const wl=e=>e.chart==="default"?void 0:e.chart,ni=e=>{const{chartLines:t,chartCarried:n,...r}=e;if(r.chart!=="default")return r;const{chart:s,...i}=r;return i};function hm(e,t){const n=new Map(e.tiles.map(r=>[ft(r),r]));return{...t,tiles:t.tiles.map(r=>{const s=n.get(ft(r));return we(r)&&r.chart===void 0&&s&&we(s)&&s.chart!==void 0?{...r,chart:s.chart}:r})}}function Ms(e){if(e.includes("\r"))return"Text uses plain line breaks; a carriage return cannot be written.";if(/^\|##/m.test(e))return"A line starting with `|##` would close the text early. Indent that line or reword it."}function pm(e,t,n){if(n.has(e.name))return`Two text tiles are named \`${e.name}\`, so they could not be told apart.`;if(n.add(e.name),t===void 0&&!ye.isIdentifier(e.name))return`The text tile name ${JSON.stringify(e.name)} must be a bare word.`;if(t===void 0||e.markdown!==t.markdown){const r=Ms(e.markdown);if(r)return r}if(e.colspan!==void 0&&e.colspan!==t?.colspan&&!(Number.isInteger(e.colspan)&&e.colspan>=1))return"A text tile's width is a whole number of columns, 1 or more."}const Di=e=>`##|(markdown) ${e.name}
|
|
118
|
+
${e.markdown===""?"":`${e.markdown}
|
|
119
|
+
`}|##
|
|
120
|
+
`;function gm(e){const{sourceText:t,lines:n,wholeLine:r,current:s,next:i,parsed:o,edits:a}=e,l=new Map(s.tiles.filter(Ue).map(p=>[p.name,p])),u=i.tiles.filter(Ue),c=p=>o.textBlocks.find(m=>m.name===p),d=new Set(u.map(p=>p.name));for(const p of l.keys()){const m=d.has(p)?void 0:c(p);if(!m)continue;const g=Lt(o,m.span.end-1);a.push({...m.span,text:""});const x=r(g+1),k=m.line===0||n[m.line-1].trim()==="";x.end>x.start&&n[g+1].trim()===""&&k?a.push({...x,text:""}):m.line>0&&k&&t.slice(m.span.end).trim()===""&&a.push({...r(m.line-1),text:""})}const f=[];for(const p of u){const m=l.get(p.name),g=c(p.name);if(m===void 0){if(g)return{ok:!1,reason:`A block named \`${p.name}\` is already in this file, so a new text tile cannot take that name.`};f.push(Di(p))}else m.markdown!==p.markdown&&(g?a.push({...g.span,text:Di(p)}):f.push(Di(p)))}if(f.length>0){const p=o.textBlocks.filter(b=>b.name===void 0||d.has(b.name)),m=p[p.length-1],g=o.sources.find(b=>b.name.endsWith("_tiles"));if(m){const b=m.span.end,h=t.slice(b);a.push({start:b,end:b,text:`
|
|
121
|
+
${f.join(`
|
|
122
|
+
`)}${h===""||h.startsWith(`
|
|
123
|
+
`)?"":`
|
|
124
|
+
`}`});return}if(g){const b=e.starts[o.blockStart(g.line)],h=b===0||t.slice(0,b).endsWith(`
|
|
125
|
+
|
|
126
|
+
`);a.push({start:b,end:b,text:`${h?"":`
|
|
127
|
+
`}${f.join(`
|
|
128
|
+
`)}
|
|
129
|
+
`});return}const x=t.length,k=t===""||t.endsWith(`
|
|
130
|
+
|
|
131
|
+
`)?"":t.endsWith(`
|
|
132
|
+
`)?`
|
|
133
|
+
`:`
|
|
134
|
+
|
|
135
|
+
`;a.push({start:x,end:x,text:k+f.join(`
|
|
136
|
+
`)})}}const hs=(e,t=ye.isBareName)=>t(e)?void 0:`The name ${JSON.stringify(e)} cannot be written as a Malloy name.`;function mm(e,t){const n=new Map(e.tiles.map(o=>[ft(o),o]));if(rt(t)==="notebook"&&t.columns!==void 0&&(rt(e)!=="notebook"||t.columns!==e.columns))return"A notebook is one column, so its width is not written. Clear the width when switching a dashboard to a notebook.";const r=new Set;for(const o of t.tiles){const a=n.get(ft(o));if(Ue(o)){const d=pm(o,a&&Ue(a)?a:void 0,r);if(d)return d;continue}const l=a&&we(a)?a:void 0;if(a&&!l)continue;const u=o.chart;if(u!==void 0&&u!=="default"&&u!=="none"&&!gi(u)&&!(u==="custom"&&l?.chart==="custom"))return`"${String(u)}" is not a chart this editor writes.`;const c=new Set(l?.filters?.map(d=>d.field));for(const d of o.filters??[])if(!c.has(d.field)&&/[\r\n]/.test(d.field))return"A filter field is one line.";if(a===void 0){const d=[o.name,o.source];o.declaration.kind==="reference"&&d.push(o.declaration.from);for(const f of d){const p=hs(f);if(p)return p}}for(const d of["label","subtitle"]){const f=o[d];if(f===void 0||f===l?.[d])continue;const p=L.annotationTextProblem(`tile ${d}`,f);if(p)return p}}const s=new Set(e.sources.map(o=>o.name));for(const o of t.sources)if(!s.has(o.name))for(const a of[o.name,o.base]){const l=hs(a);if(l)return l}if(t.description!==e.description)for(const o of(t.description??"").split(/\r?\n/)){const a=L.annotationTextProblem("description line",o);if(a)return a}if(t.title!==e.title){const o=L.annotationTextProblem("title",t.title);if(o)return o}const i=new Map((e.localGivens??[]).map(o=>[o.name,o]));for(const o of t.localGivens??[]){const a=i.get(o.name);if(a===void 0){const u=hs(o.name,ye.isStrictName);if(u)return u}const l=o.suggest?.source;if(l!==void 0&&l!==a?.suggest?.source){const u=hs(l);if(u)return`The suggest source is not a name. ${u}`}for(const u of["query","dimension"]){const c=o.suggest?.[u];if(c===void 0||c===a?.suggest?.[u])continue;const d=L.annotationTextProblem(`suggest ${u}`,c);if(d)return d}for(const u of["label","description"]){const c=o[u];if(c===void 0||c===i.get(o.name)?.[u])continue;const d=L.annotationTextProblem(`given ${u}`,c);if(d)return d}}for(const[o,a]of Object.entries(t.startingGivens??{})){if(a===e.startingGivens?.[o])continue;const l=L.annotationTextProblem(`starting value for ${o}`,a);if(l)return l}}const Lt=(e,t)=>e.lineStarts.findLastIndex(n=>n<=t);function Cu(e,t){return e.parsed.sources.find(n=>n.name===t.source)?.views.find(n=>n.name===t.name)}function Iu(e,t){if(!t)return;const n=new Set;for(const r of t.wheres)for(const s of r.clauses)if(!s.binding)for(const i of s.givens)n.add(i);return(e??[]).find(r=>n.has(r.given))}function Du(e,t){return{ok:!1,reason:`\`${e}\` already filters on \`$${t}\` in a \`where:\` the builder does not manage, so binding it again would filter on it twice. Edit that \`where:\` in the file instead.`}}const Rs=e=>`where: ${ye.malloyPath(e.field)} ${e.op??"~"} $${e.given}`;function kl(e,t,n){return{ok:!1,reason:`Removing a filter from \`${e}\` would also remove the comment written beside it (\`${t.text.slice(n.start,n.end).trim()}\`), so nothing was written. Delete it in the file first.`}}function vm(e,t,n){const r=e.commentIn(n);if(r)return r;const s=e.trailingComment(Lt(e,t.end-1));return s&&s.start>=t.end&&e.text.slice(t.end,s.start).trim()===""?s:void 0}function bm(e,t){const n=e[t].span;return t+1<e.length?{start:n.start,end:e[t+1].span.start}:t>0?{start:e[t-1].span.end,end:n.end}:n}function ja(e,t){const n=e.lineStarts[e.lineStarts.findLastIndex(a=>a<=t.start)],r=e.text.slice(n,t.start),s=e.text.indexOf(`
|
|
137
|
+
`,t.end),i=e.text.slice(t.end,s<0?void 0:s);if(r.trim()===""&&i.trim()==="")return{start:n,end:s<0?e.text.length:s+1};if(r.trim()===""){const a=/^\s*/.exec(i)?.[0].length??0;return{start:t.start,end:t.end+a}}const o=r.replace(/[\s,]*$/,"");return{start:n+o.length,end:t.end}}function Au(e,t,n){const{parsed:r,edits:s}=e,i=new Map((t.filters??[]).map(f=>[f.given,f])),o=new Set;let a;for(const f of n.wheres){const p=f.clauses.map((g,x)=>({clause:g,index:x})).filter(({clause:g})=>g.binding!==void 0);if(p.length===0)continue;const m=p.filter(({clause:g})=>i.has(g.binding.given));for(const{clause:g}of p)o.add(g.binding.given);if(m.length===0&&p.length===f.clauses.length){const g=ja(r,f.span),x=vm(r,f.span,g);if(x)return kl(t.name,r,x);s.push({...g,text:""});continue}m.length>0&&(a=f.span);for(let g=p.length-1;g>=0;g--){const{clause:x,index:k}=p[g],b=i.get(x.binding.given);if(!b){const y=bm(f.clauses,k),w=r.commentIn(y);if(w)return kl(t.name,r,w);s.push({...y,text:""});continue}const h=Rs(b).replace(/^where:\s*/,"");h!==r.text.slice(x.span.start,x.span.end)&&s.push({...x.span,text:h})}}const l=(t.filters??[]).filter(f=>!o.has(f.given));if(l.length===0)return;let u=a?.end??(n.statements.length>0?n.statements[n.statements.length-1].span.end:n.openEnd);if(!n.oneLine){const f=r.trailingComment(Lt(r,u));f&&f.start>=u&&(u=f.end)}const c=a!==void 0&&!/,\s*$/.test(r.text.slice(0,u))?", ":" ",d=n.oneLine?`${c}${l.map(Rs).join(", ")}`:l.map(f=>`
|
|
138
|
+
${n.indent}${Rs(f)}`).join("");s.push({start:u,end:u,text:d})}function ym(e,t,n){if(n.body.kind!=="reference")return;const{edits:r}=e,{fromSpan:s,refinement:i}=n.body,o=Iu(t.filters,i);if(o)return Du(t.name,o.given);const a=t.filters??[];if(!i){if(a.length===0)return;const c=` + { ${a.map(Rs).join(", ")} }`;r.push({start:s.end,end:s.end,text:c});return}const l=i.wheres.some(c=>c.clauses.some(d=>!d.binding)),u=i.statements.some(c=>!i.wheres.some(d=>d.span.start===c.span.start));if(a.length===0&&!l&&!u){const c={start:s.end,end:i.span.end},d=e.parsed.commentIn(c);if(d)return{ok:!1,reason:`Removing the last filter from \`${t.name}\` would also remove the comment beside its refinement (\`${e.parsed.text.slice(d.start,d.end).trim()}\`), so nothing was written. Delete it in the file first, or edit the refinement there.`};r.push({...c,text:""});return}return Au(e,t,i)}async function ju(e,t,n={}){if(!(e.includes(`\r
|
|
139
|
+
`)&&!/(?<!\r)\n/.test(e)))return _l(e,t,n);const s=await _l(e.replace(/\r\n/g,`
|
|
140
|
+
`),t,n);return ei(s)?s:{...s,source:s.source.replace(/\n/g,`\r
|
|
141
|
+
`)}}async function _l(e,t,n){const r=await Kr(e,n.modelPath);if(Vr(r))return{ok:!1,reason:`Cannot edit a file that will not open: ${r.reason}`};const s=r.document,i=hm(s,t),o=tm(s,i,n.changeKind===!0);if("reason"in o)return o;const a=mm(s,i);if(a)return{ok:!1,reason:a};const l=await ku(e);if(xu(l))return{ok:!1,reason:`Cannot edit a file that will not open: ${l.reason}`};const u=e.split(`
|
|
142
|
+
`),c=Xg(e),d=b=>({start:c[b],end:b+1<c.length?c[b+1]:e.length}),f=b=>/^\s*/.exec(u[b])?.[0]??"",p=[],m={...o,sourceText:e,parsed:l.parsed,lines:u,starts:c,wholeLine:d,indentOf:f,current:s,next:i,edits:p,...n.modelPath!==void 0?{modelPath:n.modelPath}:{}};for(const b of[rm,om,lm,am,cm,dm,um,fm,gm]){const h=b(m);if(h)return h}const g=b=>{const{drills:h,localGivens:y,kind:w,description:D,...T}=b,A=b.tiles.map(I=>{if(Ue(I))return I;if(I.filters?.length)return ni(I);const{filters:C,...W}=I;return ni(W)});return{...T,...D===void 0?{}:{description:$u(D)},...w==="notebook"?{kind:w}:{},tiles:A,...h?.length?{drills:[...h].sort((I,C)=>ti(I).localeCompare(ti(C)))}:{},...y?.length?{localGivens:y}:{}}};if(p.length===0)return Te(g(s))!==Te(g(i))?{ok:!1,reason:"No part of this edit was recognized, so nothing was written. Your changes are still here."}:{ok:!0,source:e};const x=Zg(e,p);if((await fl(e)).length===0){const b=await fl(x);if(b.length>0)return{ok:!1,reason:`The edit would have produced a file Malloy cannot parse, so it was not written (${b[0]}). Your changes are still here.`}}const k=await Kr(x,n.modelPath);return Vr(k)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${k.reason}`}:Te(g(k.document))!==Te(g(i))?{ok:!1,reason:"What was written did not read back as what was asked for, so it was not written. Your changes are still here."}:{ok:!0,source:x}}function Pa(e,t,n,r){const[s,i]=_.useState(void 0);return _.useEffect(()=>{t&&e!==void 0&&i(structuredClone(e))},[t,e]),{draft:s,patch:u=>i(c=>{if(c===void 0)return c;const d=structuredClone(c);return u(d),d}),close:()=>{s!==void 0&&e!==void 0&&JSON.stringify(s)!==JSON.stringify(e)&&n(s),r()},discard:()=>i(void 0)}}function Pu({markdown:e,placeholder:t,onCommit:n,variant:r="document"}){const{theme:s}=Ye.usePublisherTheme(),[i,o]=_.useState(!1),a=_.useMemo(()=>i?{text:e}:void 0,[i,e]),{draft:l,patch:u,close:c,discard:d}=Pa(a,i,h=>n(h.text),()=>o(!1)),f=i&&l!==void 0&&l.text!==e,p=l!==void 0&&l.text!==e?Ms(l.text):void 0;vu(f,()=>p!==void 0?!1:(c(),!0));const m=_.useRef(null),g=_.useRef(!1);_.useEffect(()=>{i||(g.current=!1)},[i]);const x=_.useCallback(h=>{!h||g.current||(g.current=!0,h.setSelectionRange(h.value.length,h.value.length))},[]);if(!i||l===void 0){const h=e.trim()?Ms(e):void 0;return v.jsxs(S.Box,{role:"button",tabIndex:0,onClick:y=>{y.target.closest("a")?y.preventDefault():o(!0)},onKeyDown:y=>{y.target===y.currentTarget&&(y.key!=="Enter"&&y.key!==" "||(y.preventDefault(),o(!0)))},sx:{cursor:"text",minHeight:24,borderRadius:"2px","&:hover, &:focus-visible":{outline:"1px dashed currentColor"}},children:[e.trim()?v.jsx(L.Prose,{variant:r,children:e}):v.jsx(S.Typography,{variant:"body2",sx:{color:s.tileTitle,opacity:.6},children:t}),h&&v.jsx(S.Typography,{variant:"caption",color:"error",role:"alert",children:h})]})}const k=l.text!==e?Ms(l.text):void 0,b=()=>{k===void 0&&c()};return v.jsxs(S.Stack,{spacing:1,children:[v.jsx(S.TextField,{multiline:!0,autoFocus:!0,minRows:3,maxRows:14,fullWidth:!0,value:l.text,placeholder:t,error:k!==void 0,helperText:k,inputRef:x,inputProps:{"aria-label":"Markdown"},onChange:h=>u(y=>{y.text=h.target.value}),onKeyDown:h=>{h.key==="Escape"?b():h.key==="Enter"&&(h.metaKey||h.ctrlKey)&&(h.preventDefault(),b())},onBlur:h=>{h.relatedTarget instanceof Node&&m.current?.contains(h.relatedTarget)||c()}}),v.jsxs(S.Stack,{ref:m,direction:"row",spacing:1,children:[v.jsx(S.Button,{size:"small",variant:"outlined",disabled:k!==void 0,onClick:b,children:"Done"}),v.jsx(S.Button,{size:"small",onMouseDown:h=>h.preventDefault(),onClick:()=>{d(),o(!1)},children:"Cancel"})]})]})}function Ai({value:e,placeholder:t,ariaLabel:n,onCommit:r,faintWhenEmpty:s=!1}){const[i,o]=_.useState(void 0),a=_.useRef(!1),l=()=>{a.current||i===void 0||(o(void 0),i!==e&&r(i))};vu(i!==void 0&&i!==e,()=>(l(),!0));const u=()=>{a.current=!1,o(e)};if(i===void 0){const c=e===""&&s;return v.jsx(S.Box,{component:"button",type:"button",className:c?"builder-affordance":void 0,onClick:u,onKeyDown:d=>{d.key!=="Enter"&&d.key!==" "||(d.preventDefault(),u())},sx:{all:"unset",boxSizing:"border-box",font:"inherit",color:"inherit",cursor:"text",display:"inline-block",maxWidth:"100%",borderRadius:"2px",opacity:c?0:1,fontStyle:c?"italic":void 0,"&:hover, &:focus-visible":{outline:"1px dashed currentColor"}},children:e===""?t:e})}return v.jsx(S.InputBase,{autoFocus:!0,fullWidth:!0,value:i,placeholder:t,inputProps:{"aria-label":n},onFocus:c=>c.target.select(),onChange:c=>o(c.target.value),onKeyDown:c=>{c.key==="Enter"&&!c.nativeEvent.isComposing?l():c.key==="Escape"&&(a.current=!0,o(void 0))},onBlur:l,sx:{font:"inherit",color:"inherit",p:0,"& input":{p:0}}})}function ps(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function Sl(e){for(const t of e??[]){const n=/^#\s*(?:-[A-Za-z_]+\s+)*([a-z_]+)/.exec(t.trim())?.[1];if(n&&bu.includes(n))return n}}const xm=1;function Mu(e,t,n){const r=[];for(const s of e??[]){const i=s.name,o=s.kind;if(typeof i=="string"){if(o==="dimension"||o==="measure"){const a=s.type?.kind;r.push({name:t+i,kind:o,...a?{type:a}:{}})}else if(o==="join"&&n>0){const a=s.schema?.fields;r.push(...Mu(a,`${t}${i}.`,n-1))}}}return r}function wm(e){const t=new Map;for(const n of Ru(e))t.set(n.name,Mu(n.schema?.fields,"",xm));return t}function Ru(e){const t=[];for(const n of e.sourceInfos??[])try{const r=typeof n=="string"?JSON.parse(n):n;r?.name&&t.push(r)}catch{continue}return t}const km=e=>(e.annotations??[]).some(t=>{const n=t.value??"";return n.startsWith("#(malloy)")&&of.parseTag(n.slice(9)).tag?.has("calculation")===!0});function _m(e){const t=new Map;for(const n of Ru(e)){const r=new Set;for(const s of n.schema?.fields??[]){if(s.kind!=="view"||typeof s.name!="string")continue;const i=s.schema?.fields;i&&i.length>0&&i.every(km)&&r.add(s.name)}t.set(n.name,r)}return t}function $l(e,t){return!e||t===void 0?void 0:e.sources.find(r=>r.name===t)?.fields.filter(r=>r.kind==="dimension")}const Lu=e=>(e??"").startsWith("dashboards/"),Nu=e=>e.modelPath??e.path??"";function Fu(e){const t=[],n=new Set;for(const r of e){const s=Nu(r);if(Lu(s))continue;const i=wm(r),o=_m(r);for(const a of r.sources??[]){const l=a.name;if(!l||n.has(l))continue;n.add(l);const u=(a.givens??[]).map(c=>c.name).filter(c=>typeof c=="string");t.push({name:l,modelPath:s,...ps(a.annotations)?{description:ps(a.annotations)}:{},views:(a.views??[]).filter(c=>typeof c.name=="string").map(c=>({name:c.name,...ps(c.annotations)?{description:ps(c.annotations)}:{},...Sl(c.annotations)?{chart:Sl(c.annotations)}:{},...o.get(l)?.has(c.name)?{aggregateOnly:!0}:{}})),givens:u,fields:i.get(l)??[]})}}return{sources:t}}function Sm(e,t,n){const r=new Set;for(const s of t){if(s.kind==="names"){for(const o of s.names)r.add(o);continue}const i=n.find(o=>Nu(o)===s.path);if(!i)return e;for(const o of i.sources??[])o.name&&r.add(o.name)}return{...e,sources:e.sources.filter(s=>r.has(s.name))}}const $m={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map"};function Tm(e,t,n){const r=e!==void 0?void 0:n==="loading"?"Still loading this view's details":n==="unlisted"?"Not a view the catalog lists, so its shape is unknown":void 0,s=o=>{if(t!==o){if(o==="big_value")return e?.aggregateOnly===!0?void 0:r??"Needs a view with only totals (no group by)";if(o==="shape_map"||o==="segment_map")return e?.chart===o?void 0:r??"Needs a view that already carries a map chart"}};return[{value:"default",label:"From the view"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"].map(o=>{const a=s(o);return{value:o,label:$m[o],...a?{disabled:!0,reason:a}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Co({state:e,view:t,viewStatus:n,cellLabel:r,disabledReason:s,onOpen:i,onChange:o}){const a=Tm(t,e,n),l=_.useId();return v.jsx(S.TextField,{select:!0,size:"small",variant:"standard",label:"Viz type",value:e,disabled:s!==void 0,onChange:u=>{const c=u.target.value;a.find(d=>d.value===c)?.disabled||o(c)},helperText:s,FormHelperTextProps:{id:l},SelectProps:{...i?{onOpen:i}:{},renderValue:u=>a.find(c=>c.value===u)?.label??String(u),MenuProps:{MenuListProps:{disabledItemsFocusable:!0}},SelectDisplayProps:{"aria-label":`Viz type, ${r}`,"aria-labelledby":void 0,...s?{"aria-describedby":l}:{}}},sx:{minWidth:140},children:a.map(u=>v.jsx(S.MenuItem,{value:u.value,disabled:u.value==="custom"||u.disabled===!0,children:v.jsx(S.ListItemText,{primary:u.label,...u.reason?{secondary:u.reason}:{}})},u.value))})}function Om({sources:e,source:t,view:n,onSource:r,onView:s}){const{theme:i}=Ye.usePublisherTheme(),o=e.find(a=>a.name===t);return v.jsxs(v.Fragment,{children:[v.jsx(S.TextField,{select:!0,size:"small",label:"Source",value:t,onChange:a=>r(a.target.value),inputProps:{"aria-label":"Source"},children:e.map(a=>v.jsxs(S.MenuItem,{value:a.name,disabled:a.views.length===0,children:[a.name,a.views.length===0&&v.jsx(S.Typography,{component:"span",variant:"caption",sx:{ml:1},children:"declares no views"}),a.description&&v.jsx(S.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:a.description})]},a.name))}),v.jsxs(S.Box,{children:[v.jsx(S.Typography,{variant:"subtitle2",sx:{mb:.5},children:"View"}),v.jsxs(S.List,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:"min(280px, 30vh)",overflowY:"auto",border:i.border,borderRadius:1},children:[(o?.views??[]).map(a=>v.jsxs(S.ListItemButton,{selected:n===a.name,onClick:()=>s(a.name),"aria-label":`View ${a.name}`,children:[v.jsx(S.ListItemText,{primary:a.name,secondary:a.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),a.chart&&v.jsx(S.Chip,{size:"small",variant:"outlined",label:a.chart.replace(/_chart$/,"")})]},a.name)),o&&o.views.length===0&&v.jsx(S.Typography,{variant:"body2",sx:{p:1.5,color:i.tileTitle},children:"This source declares no views."})]})]})]})}function Em(e,t){if(!t)return[];const n=new Set;for(const r of e.sources)n.add(r.base);for(const r of e.imports)if(r.kind==="names")for(const s of r.names)n.add(s);return t.sources.filter(r=>n.has(r.name))}function Cm({open:e,document:t,catalog:n,columns:r,onClose:s,onAdd:i,onAddText:o}){const{theme:a}=Ye.usePublisherTheme(),l=t.kind==="notebook"?"notebook":"dashboard",u=_.useMemo(()=>Em(t,n),[t,n]),[c,d]=_.useState("query"),[f,p]=_.useState(""),[m,g]=_.useState(""),[x,k]=_.useState(""),[b,h]=_.useState("default"),[y,w]=_.useState(Math.ceil(r/2));_.useEffect(()=>{if(!e)return;d("query");const I=C=>u.some(W=>W.name===C&&W.views.length>0);p(t.sources.map(C=>C.base).find(I)??u.find(C=>C.views.length>0)?.name??""),g(""),k(""),h("default"),w(Math.ceil(r/2))},[e,t,u,r]);const D=f!==""&&m!=="",T=[f,m].filter(I=>I!==""&&!ye.isBareName(I)).map(I=>`"${I}" is not a plain Malloy name, so a tile cannot be written for it.`)[0],A=u.find(I=>I.name===f)?.views.find(I=>I.name===m);return v.jsx(L.AppDialog,{open:e,onClose:s,title:"Add a tile",description:`A tile shows one view of one source this ${l} imports.`,actions:v.jsxs(v.Fragment,{children:[v.jsx(S.Button,{onClick:s,children:"Cancel"}),v.jsx(S.Button,{variant:"contained",disabled:c==="query"&&(!D||T!==void 0),onClick:()=>c==="text"?o():i({base:f,view:m,...x.trim()?{label:x.trim()}:{},...b!=="default"?{chart:b,...A?{chartCarried:A.chart?[A.chart]:[]}:{}}:{},colspan:y}),children:c==="text"?"Add text":"Add tile"})]}),children:v.jsxs(S.Stack,{sx:{gap:2,pt:1},children:[v.jsxs(S.ToggleButtonGroup,{size:"small",exclusive:!0,value:c,"aria-label":"Tile type",onChange:(I,C)=>{C!==null&&d(C)},children:[v.jsx(S.ToggleButton,{value:"query",sx:{px:1.5},children:"Query"}),v.jsx(S.ToggleButton,{value:"text",sx:{px:1.5},children:"Text"})]}),c==="text"?v.jsx(S.Typography,{variant:"body2",sx:{color:a.tileTitle},children:"A text tile holds markdown: a heading, a paragraph, a list. It is added empty, and written on the tile itself."}):u.length===0?v.jsx(S.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?`This ${l} imports no source by name, so there is nothing to put a tile on. Import a source in the file first.`:"The package's sources are still loading."}):v.jsxs(v.Fragment,{children:[v.jsx(Om,{sources:u,source:f,view:m,onSource:I=>{p(I),g("")},onView:I=>{g(I),h("default")}}),T&&v.jsx(S.Typography,{variant:"body2",color:"error",children:T}),v.jsx(Co,{state:b,view:A,cellLabel:"new tile",...A?{}:{disabledReason:"Pick a view to choose its chart."},onChange:I=>h(I)}),v.jsxs(S.Stack,{direction:"row",sx:{gap:1.5},children:[v.jsx(S.TextField,{size:"small",label:"Title",placeholder:"Uses the view's name",value:x,onChange:I=>k(I.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}}),r>1&&v.jsx(S.TextField,{size:"small",type:"number",label:`Width (of ${r})`,value:y,onChange:I=>w(Math.min(Math.max(Number(I.target.value)||1,1),r)),inputProps:{min:1,max:r,"aria-label":"Tile width"},sx:{width:140}})]})]})]})})}const Tl=4e3;function Im(e,t){const n=e.split(`
|
|
143
|
+
`),r=t.split(`
|
|
144
|
+
`);if(n.length>Tl||r.length>Tl)return[...n.map(l=>({kind:"del",text:l})),...r.map(l=>({kind:"add",text:l}))];const s=Array.from({length:n.length+1},()=>new Uint32Array(r.length+1));for(let l=n.length-1;l>=0;l--)for(let u=r.length-1;u>=0;u--)s[l][u]=n[l]===r[u]?s[l+1][u+1]+1:Math.max(s[l+1][u],s[l][u+1]);const i=[];let o=0,a=0;for(;o<n.length&&a<r.length;)n[o]===r[a]?(i.push({kind:"same",text:n[o]}),o++,a++):s[o+1][a]>=s[o][a+1]?i.push({kind:"del",text:n[o++]}):i.push({kind:"add",text:r[a++]});for(;o<n.length;)i.push({kind:"del",text:n[o++]});for(;a<r.length;)i.push({kind:"add",text:r[a++]});return i}function Dm(e,t=3){const n=new Array(e.length).fill(!1);e.forEach((i,o)=>{if(i.kind!=="same")for(let a=Math.max(0,o-t);a<=Math.min(e.length-1,o+t);a++)n[a]=!0});const r=[];let s=0;return e.forEach((i,o)=>{n[o]?(s>0&&r.push({kind:"fold",count:s}),s=0,r.push(i)):s++}),s>0&&r.push({kind:"fold",count:s}),r}function Am({open:e,before:t,after:n,onClose:r}){const{theme:s}=Ye.usePublisherTheme(),i=_.useMemo(()=>e?Dm(Im(t,n)):[],[e,t,n]),o=i.filter(l=>l.kind==="add").length,a=i.filter(l=>l.kind==="del").length;return v.jsx(L.AppDialog,{open:e,onClose:r,maxWidth:"md",title:"The change to the file",description:v.jsxs(v.Fragment,{children:["What the last save wrote. Lines the builder does not own, such as comments and other Malloy, are left where they were."," ",v.jsxs(S.Box,{component:"span",sx:{fontVariantNumeric:"tabular-nums"},children:["+",o," −",a]})]}),actions:v.jsx(S.Button,{onClick:r,children:"Close"}),children:v.jsx(S.Box,{component:"pre","aria-label":"File changes",sx:{m:0,px:2,py:1,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,lineHeight:1.6,overflowX:"auto",bgcolor:s.background,color:s.foreground},children:i.map((l,u)=>l.kind==="fold"?v.jsx(S.Box,{component:"span",sx:{display:"block",opacity:.55,py:.25},children:`⋯ ${l.count} unchanged line${l.count===1?"":"s"}`},u):v.jsxs(S.Box,{component:"span",sx:{display:"block",mx:-2,px:2,whiteSpace:"pre",bgcolor:l.kind==="add"?"rgba(46, 125, 91, 0.16)":l.kind==="del"?"rgba(168, 41, 31, 0.14)":"transparent",opacity:l.kind==="del"?.8:1},children:[l.kind==="add"?"+ ":l.kind==="del"?"− ":" ",l.text]},u))})})}const ji=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function jm({lastSave:e,unit:t,moved:n},r){if(!e)return[];const s=[],i=n?n.after-n.before:0;return i===1?s.push(`Added a ${t}`):i>1?s.push(`Added ${ji(i,t)}`):i<0?s.push(`Removed ${ji(-i,t)}`):e.structural?s.push(`Changed the ${t}s in the file`):s.push("Saved your edits"),r.length>0&&s.push(`Removed ${ji(r.length,"comment")} with their ${t}s`),e.clearsHistory&&s.push("Undo history was cleared"),s}function Pm(e){const{lastSave:t,canUndoSave:n,undone:r,viewing:s,onView:i,onUndoSave:o}=e;if(r)return v.jsx(S.Alert,{severity:"info",role:"status",children:"Save undone. Your edits are back and unsaved."});if(!t)return null;const a=t.removedComments??[];return v.jsxs(v.Fragment,{children:[v.jsxs(S.Alert,{severity:"success",role:"status",action:v.jsxs(v.Fragment,{children:[v.jsx(S.Button,{color:"inherit",size:"small",onClick:()=>i(!0),children:"View change"}),v.jsx(S.Button,{color:"inherit",size:"small",disabled:!n,onClick:()=>void o(),children:"Undo save"})]}),children:[jm(e,a).join(". "),".",a.length>0&&v.jsx(S.Box,{component:"span","aria-label":"Comments removed with their cell",sx:{display:"block",whiteSpace:"pre",fontFamily:"monospace",fontSize:12,mt:.5},children:a.join(`
|
|
145
|
+
`)})]}),v.jsx(Am,{open:s,before:t.before,after:t.after,onClose:()=>i(!1)})]})}const Pi="self";function Mm({open:e,document:t,source:n,givenNames:r,dashboards:s,onClose:i,onApply:o}){const{theme:a}=Ye.usePublisherTheme(),[l,u]=_.useState([]);_.useEffect(()=>{if(!e||!n)return;const m=(t.drills??[]).filter(g=>g.source===n.name);u((n.dimensions??[]).map(g=>{const x=m.find(k=>k.name===g.name);return{name:g.name,expression:g.expression,to:x?.to??[],given:x?.given??""}}))},[e,n,t]);const c=(m,g)=>u(x=>x.map((k,b)=>{if(b!==m)return k;const h={...k};return g(h),h})),d=[Pi,...s.filter(m=>m!==Pi)],f=m=>m===Pi?"This dashboard":m,p=()=>{n&&(o(l.filter(m=>m.to.length>0).map(m=>({source:n.name,name:m.name,expression:m.expression,to:m.to,...m.given?{given:m.given}:{}}))),i())};return v.jsx(L.AppDialog,{open:e,onClose:i,title:"Drill-through",description:"A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the dashboard it opens.",actions:v.jsxs(v.Fragment,{children:[v.jsx(S.Button,{onClick:i,children:"Cancel"}),v.jsx(S.Button,{variant:"contained",onClick:p,disabled:l.length===0,children:"Apply"})]}),children:v.jsx(S.Stack,{sx:{gap:2,pt:1},children:l.length===0?v.jsx(S.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?v.jsxs(v.Fragment,{children:[v.jsx(S.Box,{component:"code",children:n.name})," declares no dimensions of its own in this file. A drill is a tag on the dimension's declaration, so a dimension the model declares is made clickable in the model; to make one clickable here, declare it in"," ",v.jsx(S.Box,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):l.map((m,g)=>v.jsxs(S.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[v.jsxs(S.Box,{sx:{minWidth:0,pt:.75},children:[v.jsx(S.Typography,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:m.name}),v.jsxs(S.Typography,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:m.expression,children:["is ",m.expression]})]}),v.jsx(S.TextField,{select:!0,size:"small",label:"Clicks go to",value:m.to,inputProps:{"aria-label":`Where ${m.name} goes`},SelectProps:{multiple:!0,renderValue:x=>x.length===0?"Not clickable":x.map(f).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:x=>c(g,k=>{const b=x.target.value;k.to=Array.isArray(b)?b:String(b).split(",").filter(Boolean)}),children:d.map(x=>v.jsxs(S.MenuItem,{value:x,children:[v.jsx(S.Checkbox,{size:"small",checked:m.to.includes(x),sx:{p:0,mr:1}}),v.jsx(S.ListItemText,{primary:f(x)})]},x))}),v.jsxs(S.TextField,{select:!0,size:"small",label:"Sets the control",value:m.given,disabled:m.to.length===0,inputProps:{"aria-label":`Control ${m.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:m.given===""?`Named ${m.name}, like the dimension`:void 0,onChange:x=>c(g,k=>{k.given=x.target.value}),children:[v.jsx(S.MenuItem,{value:"",children:v.jsx("em",{children:"Same name as the dimension"})}),r.map(x=>v.jsx(S.MenuItem,{value:x,children:x},x))]})]},m.name))})})}const zu=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function Rm({open:e,document:t,control:n,available:r,fieldsFor:s,onApply:i}){const o=_.useRef(n);e&&(o.current=n);const a=e?n:o.current,l=a!==void 0,[u,c]=_.useState({kind:"new"}),[d,f]=_.useState(""),[p,m]=_.useState("select"),[g,x]=_.useState(""),[k,b]=_.useState(""),[h,y]=_.useState([]),[w,D]=_.useState(!1),[T,A]=_.useState(!1),I=P=>t.sources.find(K=>K.name===P.source)?.base??P.source;_.useEffect(()=>{if(e)if(A(n!==void 0),n){c({kind:"existing",name:n.name}),f(n.label??"");const P=fg(t,n);y(P);const K=P.filter(fe=>fe.include),ne=new Set(K.map(fe=>fe.field));b(ne.size===1?K[0].field:n.field??""),D(ne.size>1)}else c({kind:"new"}),f(""),m("select"),b(""),x(new Date().toISOString().slice(0,10)),y(t.tiles.map(P=>({include:So(P),field:""}))),D(!1)},[e,n,t]);const C=_.useMemo(()=>[...(t.localGivens??[]).map(P=>P.name),...r.map(P=>P.name)],[t,r]),W=_.useMemo(()=>k.trim()?ug(k.trim(),C):"",[k,C]),F=u.kind==="existing"?n??r.find(P=>P.name===u.name):W?{name:W,type:fs({name:W,label:d,kind:p,field:k}).type}:void 0,G=F?.type!==void 0&&!F.type.startsWith("filter<"),J=h.find(P=>P.include)?.op??Qs(F?.type),Q=(P,K)=>{A(!0),y(ne=>ne.map((fe,Re)=>Re===P?{...fe,...K}:fe))},se=P=>{A(!0),y(K=>K.map(ne=>({...ne,op:P})))},ce=P=>{const K=Qs(P);y(ne=>ne.map(({op:fe,...Re})=>K?{...Re,op:K}:Re))},te=P=>{A(!0),c({kind:"existing",name:P.name}),b(P.field??""),ce(P.type)},ue=P=>{A(!0),m(P),ce(fs({name:"X",label:d,kind:P,field:k}).type)},E=t.tiles.map(So),U=E.filter(Boolean).length,B=h.filter((P,K)=>P.include&&E[K]).length,R=t.tiles.filter((P,K)=>(h[K]?.include??!1)&&E[K]&&we(P)),q=R.length>0?R:t.tiles.filter((P,K)=>E[K]&&we(P)),N=_.useMemo(()=>{const P=new Map;let K=!1;for(const ne of q){const fe=s?.(ne);if(fe){K=!0;for(const Re of fe)P.has(Re.name)||P.set(Re.name,Re)}}return K?[...P.values()]:void 0},[h,t.tiles,s]),Y=(()=>{const P=k.trim();for(const K of R){const ne=s?.(K);if(!ne||ne.some(fe=>fe.name===P))return I(K)}return R[0]?I(R[0]):t.sources[0]?.base})(),V=P=>{A(!0),y(K=>K.map((ne,fe)=>({...ne,include:P&&E[fe]})))},$=_.useMemo(()=>w?h:h.map(P=>({...P,field:k})),[w,h,k]),j=P=>{for(const K of q){const ne=s?.(K)?.find(fe=>fe.name===P.trim());if(ne?.type)return ne.type}},z=P=>js(F?.type,P.type),X=(P,K)=>{if(P.trim()==="")return"Pick the field this filter compares.";const ne=K?s?.(K):void 0;if(!ne)return;const fe=ne.find(Re=>Re.name===P.trim());if(!fe)return`Not a field of ${K?I(K):"the tiles' source"}.`;if(fe.type&&!js(F?.type,fe.type))return`${P.trim()} is ${ll(fe.type)}; this filter compares ${ll(F?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},ie=P=>{if(A(!0),b(P),l||u.kind!=="new")return;const K=j(P),ne=fs({name:"X",label:d,kind:p,field:P}).type;K&&!js(ne,K)&&ue(cg(K))},Z=P=>{const K=t.tiles[P];return K&&we(K)?K:void 0},le=$.map((P,K)=>P.include&&E[K]?X(P.field,Z(K)):void 0),me=le.every(P=>P===void 0),re=T?le:le.map(()=>{}),ve=T&&!w&&B>0?R.map(P=>X(k,P)).find(Boolean):void 0,de=F!==void 0&&me&&(u.kind==="existing"||k.trim()!==""&&W!==""),Ae=()=>{if(!(!F||!de))if(u.kind==="new")i(F.name,$,fs({name:F.name,label:d.trim()||zu(F.name),kind:p,field:k.trim(),...Y?{source:Y}:{},...g?{dateDefault:g}:{}}));else if(n?.origin==="dashboard"&&n.local){const P=d.trim(),K=P!==(n.local.label??"");i(F.name,$,K?{...n.local,...P?{label:P}:{}}:void 0)}else i(F.name,$)},We=l&&a.origin==="model";return{editing:l,shown:a,fromModel:We,source:u,setSource:c,label:d,setLabel:f,kind:p,dateDefault:g,setDateDefault:x,field:k,rows:h,setRows:y,perTile:w,setPerTile:D,newName:W,target:F,valueTyped:G,commonOp:J,setRow:Q,setCommonOp:se,pickExisting:te,pickKind:ue,bindable:E,bindableCount:U,included:B,commonFields:N,setAll:V,accepts:z,pickField:ie,rowProblems:re,commonProblem:ve,canApply:de,apply:Ae}}function Ol({value:e,onChange:t,fields:n,accepts:r,label:s,ariaLabel:i,error:o,helperText:a,disabled:l,autoFocus:u,placeholder:c,sx:d}){const f=_.useMemo(()=>(n??[]).filter(m=>r?.(m)??!0).map(m=>m.name),[n,r]),p=_.useMemo(()=>new Map((n??[]).map(m=>[m.name,m.type])),[n]);return v.jsx(S.Autocomplete,{freeSolo:!0,size:"small",options:f,inputValue:e,onInputChange:(m,g)=>t(g),value:e,onChange:(m,g)=>t(typeof g=="string"?g:""),disabled:l,disableClearable:!0,renderOption:(m,g)=>_.createElement("li",{...m,key:g},v.jsx(S.Typography,{variant:"body2",sx:{flex:1},children:g}),p.get(g)&&v.jsx(S.Typography,{variant:"caption",sx:{opacity:.6},children:p.get(g)?.replace(/_type$/,"")})),renderInput:m=>v.jsx(S.TextField,{...m,label:s,placeholder:c,autoFocus:u,error:o,helperText:a,inputProps:{...m.inputProps,"aria-label":i}}),sx:d})}const El=e=>e&&we(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:{label:"From the model",reason:"Declared on its source, which this dashboard does not write."};function Lm({open:e,document:t,control:n,available:r,fieldsFor:s,onClose:i,onApply:o,onRemove:a}){const{theme:l}=Ye.usePublisherTheme(),{editing:u,shown:c,fromModel:d,source:f,setSource:p,label:m,setLabel:g,kind:x,dateDefault:k,setDateDefault:b,field:h,rows:y,setRows:w,perTile:D,setPerTile:T,newName:A,target:I,valueTyped:C,commonOp:W,setRow:F,setCommonOp:G,pickExisting:J,pickKind:Q,bindable:se,bindableCount:ce,included:te,commonFields:ue,setAll:E,accepts:U,pickField:B,rowProblems:R,commonProblem:q,canApply:N,apply:Y}=Rm({open:e,document:t,control:n,available:r,fieldsFor:s,onApply:o}),V=($,j,z)=>v.jsx(S.TextField,{select:!0,size:"small",label:"Compares",value:$??">=",onChange:X=>j(X.target.value),inputProps:{"aria-label":z},sx:{width:130},children:dg.filter(X=>X.op!=="~").map(X=>v.jsx(S.MenuItem,{value:X.op,children:X.label},X.op))});return v.jsx(L.AppDialog,{open:e,onClose:i,title:u?c.label??c.name:"Add a filter",description:u?v.jsxs(v.Fragment,{children:[v.jsxs(S.Box,{component:"span",sx:{fontFamily:"ui-monospace, monospace"},children:["$",c.name]}),d?" · declared in the model, so its label and options are set there":" · declared in this dashboard"]}):"A control on the page, and the tiles it filters.",actions:v.jsxs(v.Fragment,{children:[u&&v.jsx(S.Button,{color:"error",onClick:()=>a(c.name),"aria-label":`Remove control ${c.name}`,sx:{mr:"auto"},children:"Remove from dashboard"}),v.jsx(S.Button,{onClick:i,children:"Cancel"}),v.jsx(S.Tooltip,{title:N||I===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:v.jsx("span",{children:v.jsx(S.Button,{variant:"contained",onClick:Y,disabled:!N,children:u?"Apply":"Add filter"})})})]}),children:v.jsxs(S.Stack,{sx:{gap:2.5,pt:1},children:[!u&&r.length>0&&v.jsxs(S.ToggleButtonGroup,{exclusive:!0,size:"small",value:f.kind,onChange:($,j)=>{j==="new"?p({kind:"new"}):j==="existing"&&r[0]&&J(r[0])},"aria-label":"Where the filter comes from",children:[v.jsx(S.ToggleButton,{value:"new",children:"New in this dashboard"}),v.jsx(S.ToggleButton,{value:"existing",children:"From the model"})]}),!u&&f.kind==="existing"?v.jsx(S.TextField,{select:!0,size:"small",label:"Control",value:f.name,onChange:$=>{const j=r.find(z=>z.name===$.target.value);j&&J(j)},children:r.map($=>v.jsxs(S.MenuItem,{value:$.name,children:[$.label??$.name,v.jsxs(S.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",$.name]})]},$.name))}):null,v.jsxs(S.Stack,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!D&&v.jsx(Ol,{value:h,onChange:B,fields:ue,accepts:U,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!u,error:q!==void 0,helperText:q??(!u&&A?`Declared as $${A}`:void 0),sx:{flex:1,minWidth:200}}),!d&&v.jsx(S.TextField,{size:"small",label:"Label",placeholder:A?zu(A):"",value:m,onChange:$=>g($.target.value),inputProps:{"aria-label":"Control label"},sx:{flex:1,minWidth:160}}),C&&!D&&V(W,G,"Comparison")]}),!u&&f.kind==="new"&&v.jsxs(S.Stack,{direction:"row",sx:{gap:1.5},children:[v.jsx(S.TextField,{select:!0,size:"small",label:"Control",value:x,onChange:$=>Q($.target.value),inputProps:{"aria-label":"Kind of control"},slotProps:{select:{renderValue:$=>cl.find(j=>j.kind===$)?.label??String($)}},sx:{flex:1},children:cl.map($=>v.jsxs(S.MenuItem,{value:$.kind,children:[$.label,v.jsx(S.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:$.hint})]},$.kind))}),x==="date"&&v.jsx(S.TextField,{size:"small",type:"date",label:"Starts at",value:k,onChange:$=>b($.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),v.jsxs(S.Box,{children:[v.jsxs(S.Stack,{direction:"row",sx:{alignItems:"center",gap:.5},children:[v.jsx(S.Checkbox,{size:"small",checked:ce>0&&te===ce,indeterminate:te>0&&te<ce,disabled:ce===0,onChange:$=>E($.target.checked),inputProps:{"aria-label":"All tiles"}}),v.jsxs(S.Typography,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",te," of ",t.tiles.length," tiles"]}),v.jsx(S.Button,{size:"small",onClick:()=>{D||w($=>$.map(j=>({...j,field:h}))),T($=>!$)},children:D?"Same field for all":"Adjust per tile"})]}),v.jsx(S.Stack,{sx:{gap:D?1:0},children:t.tiles.map(($,j)=>{if(!we($))return null;const z=y[j],X=$.label??$.name,ie=D?R[j]:void 0;return v.jsxs(S.Stack,{direction:"row",sx:{gap:1,alignItems:D?"flex-start":"center",opacity:se[j]?1:.6},children:[v.jsx(S.Checkbox,{size:"small",disabled:!se[j],checked:(z?.include??!1)&&se[j],inputProps:{"aria-label":`Filter ${X}`},onChange:Z=>F(j,{include:Z.target.checked})}),v.jsx(S.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:D?1:0},noWrap:!0,children:X}),se[j]?D&&v.jsxs(v.Fragment,{children:[C&&V(z?.op,Z=>F(j,{op:Z}),`Comparison for ${X}`),v.jsx(Ol,{value:z?.field??"",onChange:Z=>F(j,{field:Z}),fields:s?.($),accepts:U,label:"Field",ariaLabel:`Field for ${X}`,disabled:!z?.include,error:ie!==void 0,helperText:ie,sx:{width:220}})]}):v.jsx(S.Tooltip,{title:El(t.tiles[j]).reason,children:v.jsx(S.Typography,{variant:"caption",sx:{color:l.tileTitle},children:El(t.tiles[j]).label})})]},`${$.source}.${$.name}`)})}),te===0&&v.jsx(S.Typography,{variant:"caption",sx:{color:"warning.main",display:"block",mt:1},children:"No tile is ticked, so this control will not appear on the dashboard."})]})]})})}const Wu=L.createSvgIcon(v.jsx("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2m5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12z"})),Nm=e=>({imports:e.imports,...e.kind===void 0?{}:{kind:e.kind},...e.columns===void 0?{}:{columns:e.columns},...e.autorun===void 0?{}:{autorun:e.autorun}}),Fm=e=>`../${e}`;function zm(e,t,n){const r=Fm(n);if(e.some(i=>i.kind==="names"&&i.names.includes(t)))return e;const s=e.findIndex(i=>i.kind==="names"&&i.from===r);return s<0?[...e,{kind:"names",names:[t],from:r}]:e.map((i,o)=>o===s&&i.kind==="names"?{...i,names:[...i.names,t]}:i)}const Wm=(e,t)=>e.flatMap(n=>{if(n.kind!=="names"||!n.names.includes(t))return[n];const r=n.names.filter(s=>s!==t);return r.length===0?[]:[{...n,names:r}]}),Mi=[2,3,4,6,12,L.MAX_COLUMNS];function Bm({anchor:e,settings:t,catalog:n,inUse:r,onClose:s,onCommit:i}){const{theme:o}=Ye.usePublisherTheme(),{draft:a,patch:l,close:u}=Pa(t,e!==null,i,s),c=a?.kind==="notebook",d=new Set((a?.imports??[]).flatMap(g=>g.kind==="names"?g.names:[])),f=(n?.sources??[]).filter(g=>!d.has(g.name)&&!g.modelPath.startsWith("dashboards/")&&!g.modelPath.startsWith("notebooks/")),p=a?.columns??L.DEFAULT_COLUMNS,m=Mi.includes(p)?Mi:[...Mi,p].sort((g,x)=>g-x);return v.jsx(S.Popover,{open:e!==null&&a!==void 0,anchorEl:e,onClose:u,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:380,p:2}}},children:a&&v.jsxs(S.Stack,{sx:{gap:1.5},children:[v.jsx(S.Typography,{variant:"overline",sx:{color:o.tileTitle,lineHeight:1.5},children:c?"Notebook":"Dashboard"}),v.jsxs(S.Stack,{direction:"row",sx:{gap:1,alignItems:"center",flexWrap:"wrap"},children:[v.jsx(S.Typography,{variant:"caption",sx:{color:o.tileTitle},children:"Show as"}),v.jsxs(S.ToggleButtonGroup,{size:"small",exclusive:!0,value:c?"notebook":"dashboard","aria-label":"Show as",onChange:(g,x)=>{x!==null&&l(k=>{x==="notebook"?(k.kind="notebook",delete k.columns):delete k.kind})},children:[v.jsx(S.ToggleButton,{value:"dashboard",sx:{px:1.5},children:"Dashboard"}),v.jsx(S.ToggleButton,{value:"notebook",sx:{px:1.5},children:"Notebook"})]})]}),!c&&v.jsx(S.TextField,{select:!0,size:"small",label:"Grid width",value:p,helperText:"Columns across the page. Tiles are placed in these.",inputProps:{"aria-label":"Grid width"},onChange:g=>l(x=>{x.columns=Number(g.target.value)}),children:m.map(g=>v.jsx(S.MenuItem,{value:g,children:g},g))}),v.jsxs(S.Stack,{sx:{gap:.75},children:[v.jsx(S.Typography,{variant:"caption",sx:{color:o.tileTitle},children:"Sources"}),v.jsxs(S.Stack,{direction:"row","aria-label":"Sources",sx:{gap:.75,flexWrap:"wrap"},children:[a.imports.length===0&&v.jsx(S.Typography,{variant:"body2",sx:{opacity:.7},children:"None imported."}),a.imports.flatMap(g=>g.kind==="all"?[v.jsx(S.Chip,{size:"small",variant:"outlined",label:g.from,title:"Every declaration in this file; edit it in the file"},`all ${g.from}`)]:g.names.map(x=>v.jsx(S.Chip,{size:"small",label:x,title:r.has(x)?`${x} from ${g.from}; a tile reads it`:`${x} from ${g.from}`,...r.has(x)?{}:{onDelete:()=>l(k=>{k.imports=Wm(k.imports,x)}),deleteIcon:v.jsx(Wu,{"aria-label":`Remove source ${x}`})}},`${g.from} ${x}`)))]}),n&&f.length>0&&v.jsx(S.TextField,{select:!0,size:"small",label:"Add a source",value:"",inputProps:{"aria-label":"Add a source"},onChange:g=>{const x=f.find(k=>`${k.modelPath} ${k.name}`===g.target.value);x&&l(k=>{k.imports=zm(k.imports,x.name,x.modelPath)})},children:f.map(g=>v.jsxs(S.MenuItem,{value:`${g.modelPath} ${g.name}`,children:[g.name,v.jsx(S.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.7},children:g.modelPath})]},`${g.modelPath} ${g.name}`))})]}),v.jsx(S.FormControlLabel,{control:v.jsx(S.Switch,{size:"small",checked:a.autorun!==!1,slotProps:{input:{"aria-label":"Run as controls change"}},onChange:g=>l(x=>{g.target.checked?delete x.autorun:x.autorun=!1})}),label:v.jsxs(S.Typography,{variant:"body2",children:["Run as controls change",v.jsx(S.Typography,{component:"span",variant:"caption",sx:{display:"block",opacity:.7},children:"Off, readers press Apply. For a page whose queries are slow."})]})})]})})}const qm=L.createSvgIcon(v.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"})),Gm=49;function Um({controls:e,tileCount:t,unknownFieldsOf:n,onEdit:r,onAdd:s,onRemove:i,children:o}){const{theme:a}=Ye.usePublisherTheme();return v.jsx(v.Fragment,{children:v.jsxs(S.Stack,{sx:{gap:1,position:"sticky",top:Gm,zIndex:4,bgcolor:a.background,pb:1},children:[v.jsxs(S.Stack,{direction:"row","aria-label":"Filters",sx:{gap:1,alignItems:"center",flexWrap:"wrap",minHeight:32},children:[v.jsx(qm,{sx:{fontSize:18,color:a.tileTitle,opacity:.7}}),v.jsx(S.Typography,{variant:"subtitle2",sx:{color:a.tileTitle,mr:.5},children:"Filters"}),e.length===0&&v.jsx(S.Typography,{variant:"body2",sx:{color:a.tileTitle,opacity:.8},children:"None yet."}),e.map(l=>{const u=n(l.name,l.type);return v.jsx(S.Tooltip,{title:u.length>0?`$${l.name} · cannot filter on: ${u.join(", ")}`:`$${l.name} · ${l.origin==="dashboard"?"declared here":"from the model"} · ${l.boundTiles} of ${t} tiles`,children:v.jsx(S.Chip,{size:"small",label:l.label??l.name,"aria-label":`Edit filter ${l.name}`,color:u.length>0?"warning":"default",variant:l.origin==="dashboard"?"filled":"outlined",onClick:()=>r(l),onDelete:()=>i(l.name),deleteIcon:v.jsx(Wu,{"aria-label":`Remove filter ${l.name}`}),sx:{opacity:l.boundTiles===0?.6:1,cursor:"pointer",transition:"opacity 120ms"}})},l.name)}),v.jsx(S.Box,{sx:{ml:"auto"},children:v.jsx(L.SecondaryButton,{label:"Filter",icon:v.jsx(L.AddIcon,{}),onClick:()=>s(),ariaLabel:"Add filter",ariaHasPopup:"dialog"})})]}),o]})})}const Vm=(e,t)=>e.map((n,r)=>{const s=t[r]??!1;if(s===(n.break??!1))return n;const i={...n};return s?i.break=!0:delete i.break,i}),Km=(e,t,n)=>{const r=[...e],[s]=r.splice(t,1);if(!s)return[...e];const i=r[t];s.break&&i&&!i.break&&(r[t]={...i,break:!0});const o={...s};return delete o.break,r.splice(n,0,o),r},Bu=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),qu=e=>`gap.${e}`,Hm=(e,t)=>{const n=[];let r=0;e.forEach((i,o)=>{const a=Math.min(i.colspan??1,t),l=o===0||i.break===!0||r+a>t;l&&o>0&&r<t&&n.push({kind:"gap",after:He(e[o-1]),colspan:t-r}),l&&(r=0),n.push(Bu(i,o)),r+=a});const s=e.at(-1);return s&&r<t&&n.push({kind:"gap",after:He(s),colspan:t-r}),n};var Ym=Object.create,Gu=Object.defineProperty,Xm=Object.defineProperties,Zm=Object.getOwnPropertyDescriptor,Qm=Object.getOwnPropertyDescriptors,ri=Object.getOwnPropertySymbols,Uu=Object.prototype.hasOwnProperty,Vu=Object.prototype.propertyIsEnumerable,Jm=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),os=e=>{throw TypeError(e)},Io=(e,t,n)=>t in e?Gu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ri=(e,t)=>{for(var n in t||(t={}))Uu.call(t,n)&&Io(e,n,t[n]);if(ri)for(var n of ri(t))Vu.call(t,n)&&Io(e,n,t[n]);return e},Li=(e,t)=>Xm(e,Qm(t)),ev=(e,t)=>{var n={};for(var r in e)Uu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ri)for(var r of ri(e))t.indexOf(r)<0&&Vu.call(e,r)&&(n[r]=e[r]);return n},tv=e=>{var t;return[,,,Ym((t=void 0)!=null?t:null)]},Ku=["class","method","getter","setter","accessor","field","value","get","set"],Sr=e=>e!==void 0&&typeof e!="function"?os("Function expected"):e,nv=(e,t,n,r,s)=>({kind:Ku[e],name:t,metadata:r,addInitializer:i=>n._?os("Already initialized"):s.push(Sr(i||null))}),rv=(e,t)=>Io(t,Jm("metadata"),e[3]),gs=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},Hu=(e,t,n,r,s,i)=>{for(var o,a,l,u,c,d=t&7,f=!1,p=!1,m=e.length+1,g=Ku[d+5],x=e[m-1]=[],k=e[m]||(e[m]=[]),b=(s=s.prototype,Zm({get[n](){return $r(this,i)},set[n](y){return fn(this,i,y)}},n)),h=r.length-1;h>=0;h--)u=nv(d,n,l={},e[3],k),u.static=f,u.private=p,c=u.access={has:y=>n in y},c.get=y=>y[n],c.set=(y,w)=>y[n]=w,a=(0,r[h])({get:b.get,set:b.set},u),l._=1,a===void 0?Sr(a)&&(b[g]=a):typeof a!="object"||a===null?os("Object expected"):(Sr(o=a.get)&&(b.get=o),Sr(o=a.set)&&(b.set=o),Sr(o=a.init)&&x.unshift(o));return b&&Gu(s,n,b),s},Yu=(e,t,n)=>t.has(e)||os("Cannot "+n),$r=(e,t,n)=>(Yu(e,t,"read from private field"),t.get(e)),dr=(e,t,n)=>t.has(e)?os("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),fn=(e,t,n,r)=>(Yu(e,t,"write to private field"),t.set(e,n),n);function pn(e){return e instanceof La||e instanceof Ju}var ms=10,sv=class extends Ze{constructor(e){super(e);const t=pt(()=>{const{dragOperation:r}=e;if(Fr(r.activatorEvent)&&pn(r.source)&&r.status.initialized){const s=e.registry.plugins.get(ts);if(s)return s.disable(),()=>s.enable()}}),n=e.monitor.addEventListener("dragmove",(r,s)=>{queueMicrotask(()=>{if(this.disabled||r.defaultPrevented||!r.nativeEvent)return;const{dragOperation:i}=s;if(!Fr(r.nativeEvent)||!pn(i.source)||!i.shape)return;const{actions:o,collisionObserver:a,registry:l}=s,{by:u}=r;if(!u)return;const c=iv(u),{source:d,target:f}=i,{center:p}=i.shape.current,m=[],g=[];De(()=>{for(const w of l.droppables){const{id:D}=w;if(!w.accepts(d)||D===f?.id&&pn(w)||!w.element)continue;let T=w.shape;const A=new _t(w.element,{getBoundingClientRect:I=>Lr(I,void 0,.2)});!A.height||!A.width||(c=="down"&&p.y+ms<A.center.y||c=="up"&&p.y-ms>A.center.y||c=="left"&&p.x-ms>A.center.x||c=="right"&&p.x+ms<A.center.x)&&(m.push(w),w.shape=A,g.push(()=>w.shape=T))}}),r.preventDefault(),a.disable();const x=a.computeCollisions(m,Wh);De(()=>g.forEach(w=>w()));const[k]=x;if(!k)return;const{id:b}=k,{index:h,group:y}=d.sortable;o.setDropTarget(b).then(()=>{const{source:w,target:D,shape:T}=i;if(!w||!pn(w)||!T)return;const{index:A,group:I,target:C}=w.sortable,W=h!==A||y!==I,F=W?C:D?.element;if(!F)return;wd(F);const G=new _t(F);if(!G)return;const J=St.delta(G,St.from(T.current.boundingRectangle),w.alignment);o.move({by:J}),W?o.setDropTarget(w.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function iv(e){const{x:t,y:n}=e;if(t>0)return"right";if(t<0)return"left";if(n>0)return"down";if(n<0)return"up"}var ov=Object.defineProperty,av=Object.defineProperties,lv=Object.getOwnPropertyDescriptors,Cl=Object.getOwnPropertySymbols,cv=Object.prototype.hasOwnProperty,dv=Object.prototype.propertyIsEnumerable,Il=(e,t,n)=>t in e?ov(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Sn=(e,t)=>{for(var n in t||(t={}))cv.call(t,n)&&Il(e,n,t[n]);if(Cl)for(var n of Cl(t))dv.call(t,n)&&Il(e,n,t[n]);return e},$n=(e,t)=>av(e,lv(t));function uv(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function vs(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function Ni(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function fv(e,t,n){var r,s;const{source:i,target:o,canceled:a}=t.operation;if(!i||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const l=(h,y)=>h===y||h!==null&&typeof h=="object"&&"id"in h&&h.id===y;if(Array.isArray(e)){const h=e.findIndex(w=>l(w,i.id)),y=e.findIndex(w=>l(w,o.id));if(h===-1||y===-1){if(Ni(i)){const w=i.initialIndex,D=i.index;return w===D||w<0||w>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,w,D)}return e}if(!a&&"index"in i&&typeof i.index=="number"){const w=i.index;if(w!==h)return n(e,h,w)}return n(e,h,y)}const u=Object.entries(e);let c=-1,d,f=-1,p;for(const[h,y]of u)if(c===-1&&(c=y.findIndex(w=>l(w,i.id)),c!==-1&&(d=h)),f===-1&&(f=y.findIndex(w=>l(w,o.id)),f!==-1&&(p=h)),c!==-1&&f!==-1)break;if(c===-1&&Ni(i)){const h=i.initialGroup==null?void 0:vs(e,i.initialGroup),y=i.initialIndex,w=i.group==null?void 0:vs(e,i.group),D=i.index;if(h==null||w==null||h===w&&y===D)return"preventDefault"in t&&t.preventDefault(),e;if(h===w)return $n(Sn({},e),{[h]:n(e[h],y,D)});const T=e[h][y];return $n(Sn({},e),{[h]:[...e[h].slice(0,y),...e[h].slice(y+1)],[w]:[...e[w].slice(0,D),T,...e[w].slice(D)]})}if(!i.manager)return e;const{dragOperation:m}=i.manager,g=(s=(r=m.shape)==null?void 0:r.current.center)!=null?s:m.position.current;if(p==null){const h=vs(e,o.id);if(h!=null){const y=o.shape&&g.y>o.shape.center.y?e[h].length:0;p=h,f=y}}if(d==null||p==null||d===p&&c===f){if(d!=null&&d===p&&c===f&&Ni(i)){const h=i.group==null?void 0:vs(e,i.group),y=i.group!=null&&h!==d,w=i.index!==c;if(y||w){const D=i.group==null?d:h;if(D!=null){if(d===D)return $n(Sn({},e),{[d]:n(e[d],c,i.index)});const T=e[d][c];return $n(Sn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[D]:[...e[D].slice(0,i.index),T,...e[D].slice(i.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===p)return $n(Sn({},e),{[d]:n(e[d],c,f)});const k=o.shape&&Math.round(g.y)>Math.round(o.shape.center.y)?1:0,b=e[d][c];return $n(Sn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[p]:[...e[p].slice(0,f+k),b,...e[p].slice(f+k)]})}function hv(e,t){return fv(e,t,uv)}function Dl(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function Al(e,t,n){var r;for(const[s,i]of t)for(const o of i){const a=e.get(o.id);if(o.index!==a||o.group!==s||!((r=n.get(s))!=null&&r.has(o)))return!0}return!1}var jl="__default__",pv=class extends Ze{constructor(e){super(e);const t=()=>{const r=new Map;for(const s of e.registry.droppables)if(s instanceof La){const{sortable:i}=s,{group:o}=i;let a=r.get(o);a||(a=new Set,r.set(o,a)),a.add(i)}return r},n=[e.monitor.addEventListener("dragover",(r,s)=>{if(this.disabled)return;const{dragOperation:i}=s,{source:o,target:a}=i;if(!pn(o)||!pn(a)||o.sortable===a.sortable)return;const l=t(),u=Dl(l),c=o.sortable.group===a.sortable.group,d=l.get(o.sortable.group),f=c?d:l.get(a.sortable.group);!d||!f||queueMicrotask(()=>{r.defaultPrevented||s.renderer.rendering.then(()=>{var p,m;const g=t();if(Al(u,l,g))return;const x=o.sortable.element,k=a.sortable.element;if(!k||!x||!c&&a.id===o.sortable.group)return;const b=bs(d),h=c?b:bs(f),y=(p=o.sortable.group)!=null?p:jl,w=(m=a.sortable.group)!=null?m:jl,D={[y]:b,[w]:h},T=hv(D,r);if(D===T)return;const A=T[w].indexOf(o.sortable),I=T[w].indexOf(a.sortable);s.collisionObserver.disable(),Pl(x,A,k,I),De(()=>{for(const[C,W]of T[y].entries())W.index=C;if(!c)for(const[C,W]of T[w].entries())W.group=a.sortable.group,W.index=C}),s.actions.setDropTarget(o.id).then(()=>s.collisionObserver.enable())})})}),e.monitor.addEventListener("dragend",(r,s)=>{if(!r.canceled)return;const{dragOperation:i}=s,{source:o}=i;pn(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),l=Dl(a),u=a.get(o.sortable.initialGroup);u&&s.renderer.rendering.then(()=>{const c=t();if(Al(l,a,c))return;const d=bs(u),f=bs(u,mv),p=o.sortable.element,m=f.indexOf(o.sortable),g=d[m],x=g?.element;!g||!x||!p||(Pl(p,g.index,x,o.index),De(()=>{for(const k of a.values()){const b=Array.from(k).values();for(const h of b)h.index=h.initialIndex,h.group=h.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function Pl(e,t,n,r){const s=r<t?"afterend":"beforebegin";n.insertAdjacentElement(s,e)}function gv(e,t){return e.index-t.index}function mv(e,t){return e.initialIndex-t.initialIndex}function bs(e,t=gv){return Array.from(e).sort(t)}var Ml=[sv,pv],Xu={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function Rl(e){var t,n;return typeof e=="boolean"?{draggable:e,droppable:e}:{draggable:(t=e?.draggable)!=null?t:!1,droppable:(n=e?.droppable)!=null?n:!1}}var ys=new Sf,Zu,Qu,Kt,Ma,Tr,Or,Ra,Pn;Qu=[pe],Zu=[pe];var vi=class{constructor(e,t){dr(this,Ma,gs(Kt,8,this)),gs(Kt,11,this),dr(this,Tr),dr(this,Or),dr(this,Ra,gs(Kt,12,this)),gs(Kt,15,this),dr(this,Pn),this.register=()=>(De(()=>{var m,g;(m=this.manager)==null||m.registry.register(this.droppable),(g=this.manager)==null||g.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{De(()=>{var m,g;(m=this.manager)==null||m.registry.unregister(this.droppable),(g=this.manager)==null||g.registry.unregister(this.draggable)})},this.destroy=()=>{De(()=>{this.droppable.destroy(),this.draggable.destroy()})};var n=e,{effects:r=()=>[],disabled:s,group:i,index:o,sensors:a,type:l,transition:u=Xu,plugins:c}=n,d=ev(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const f=yt(c,Ml),p=Rl(s);this.droppable=new La(Li(Ri({},d),{disabled:p.droppable}),t,this),this.draggable=new Ju(Li(Ri({},d),{disabled:p.draggable,plugins:f,effects:()=>[()=>{var m,g,x;const k=(m=this.manager)==null?void 0:m.dragOperation.status;k?.initializing&&this.id===((x=(g=this.manager)==null?void 0:g.dragOperation.source)==null?void 0:x.id)&&ys.clear(this.manager),k?.dragging&&ys.set(this.manager,this.id,he(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:m,group:g,manager:x}=this,k=$r(this,Or),b=$r(this,Tr);(m!==k||g!==b)&&(fn(this,Or,m),fn(this,Tr,g),this.animate())},()=>{var m,g;const{target:x}=this,{isDragSource:k}=this.draggable;((g=(m=this.draggable.pluginConfig(xa))==null?void 0:m.feedback)!=null?g:"default")==="move"&&k&&(this.droppable.disabled=!x)},...r()],type:l,sensors:a}),t,this),fn(this,Pn,d.element),this.manager=t,this.index=o,fn(this,Or,o),this.group=i,fn(this,Tr,i),this.type=l,this.transition=u}get initialIndex(){var e,t;return(t=(e=ys.get(this.manager,this.id))==null?void 0:e.initialIndex)!=null?t:this.index}get initialGroup(){var e,t;return(t=(e=ys.get(this.manager,this.id))==null?void 0:e.initialGroup)!=null?t:this.group}animate(){he(()=>{const{manager:e,transition:t}=this,{shape:n}=this.droppable;if(!e)return;const{idle:r}=e.dragOperation.status;!n||!t||r&&!t.idle||e.renderer.rendering.then(()=>{const{element:s}=this;if(!s)return;for(const c of s.getAnimations())"transitionProperty"in c&&(c.transitionProperty==="transform"||c.transitionProperty==="translate"||c.transitionProperty==="scale")&&c.cancel();const i=this.refreshShape();if(!i)return;const o={x:n.boundingRectangle.left-i.boundingRectangle.left,y:n.boundingRectangle.top-i.boundingRectangle.top},{translate:a}=Ot(s),l=Qa(s,a,!1),u=Qa(s,a);if(o.x||o.y){const c=fa(ot(s))?Li(Ri({},t),{duration:0}):t;kd({element:s,keyframes:{translate:[`${l.x+o.x}px ${l.y+o.y}px ${l.z}`,`${u.x}px ${u.y}px ${u.z}`]},options:c}).then(()=>{e.dragOperation.status.dragging||(this.droppable.shape=void 0)})}})})}get manager(){return this.draggable.manager}set manager(e){De(()=>{this.draggable.manager=e,this.droppable.manager=e})}set element(e){De(()=>{const t=$r(this,Pn),n=this.droppable.element,r=this.draggable.element;(!n||n===t)&&(this.droppable.element=e),(!r||r===t)&&(this.draggable.element=e),fn(this,Pn,e)})}get element(){var e,t;const n=$r(this,Pn);if(n)return(t=(e=io.get(n))!=null?e:n)!=null?t:this.droppable.element}set target(e){this.droppable.element=e}get target(){return this.droppable.element}set source(e){this.draggable.element=e}get source(){return this.draggable.element}get disabled(){const{disabled:e}=this.draggable,{disabled:t}=this.droppable;return e===t?e:{draggable:e,droppable:t}}set plugins(e){this.draggable.plugins=yt(e,Ml)}set disabled(e){const t=Rl(e);De(()=>{this.droppable.disabled=t.droppable,this.draggable.disabled=t.draggable})}set data(e){De(()=>{this.droppable.data=e,this.draggable.data=e})}set handle(e){this.draggable.handle=e}set id(e){this.droppable.id=e,this.draggable.id=e}get id(){return this.droppable.id}set sensors(e){this.draggable.sensors=e}set modifiers(e){this.draggable.modifiers=e}set collisionPriority(e){this.droppable.collisionPriority=e}set collisionDetector(e){this.droppable.collisionDetector=e??_d}set alignment(e){this.draggable.alignment=e}get alignment(){return this.draggable.alignment}set type(e){De(()=>{this.droppable.type=e,this.draggable.type=e})}get type(){return this.draggable.type}set accept(e){this.droppable.accept=e}get accept(){return this.droppable.accept}get isDropTarget(){return this.droppable.isDropTarget}get isDragSource(){return this.draggable.isDragSource}get isDragging(){return this.draggable.isDragging}get isDropping(){return this.draggable.isDropping}get status(){return this.draggable.status}refreshShape(){return this.droppable.refreshShape()}accepts(e){return this.droppable.accepts(e)}};Kt=tv();Ma=new WeakMap;Tr=new WeakMap;Or=new WeakMap;Ra=new WeakMap;Pn=new WeakMap;Hu(Kt,4,"index",Qu,vi,Ma);Hu(Kt,4,"group",Zu,vi,Ra);rv(Kt,vi);var Ju=class extends fi{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get initialIndex(){return this.sortable.initialIndex}get group(){return this.sortable.group}get initialGroup(){return this.sortable.initialGroup}},La=class extends hi{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},vv=Object.defineProperty,bv=Object.defineProperties,yv=Object.getOwnPropertyDescriptors,Ll=Object.getOwnPropertySymbols,xv=Object.prototype.hasOwnProperty,wv=Object.prototype.propertyIsEnumerable,Nl=(e,t,n)=>t in e?vv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fi=(e,t)=>{for(var n in t||(t={}))xv.call(t,n)&&Nl(e,n,t[n]);if(Ll)for(var n of Ll(t))wv.call(t,n)&&Nl(e,n,t[n]);return e},kv=(e,t)=>bv(e,yv(t));function _v(e){const{accept:t,collisionDetector:n,collisionPriority:r,id:s,data:i,element:o,handle:a,index:l,group:u,disabled:c,modifiers:d,sensors:f,target:p,type:m,plugins:g}=e,x=Fi(Fi({},Xu),e.transition),k=ou(h=>new vi(kv(Fi({},e),{transition:x,register:!1,handle:Fn(a),element:Fn(o),target:Fn(p)}),h)),b=nu(k,Sv);return Ce(s,()=>k.id=s),sr(()=>{De(()=>{k.group=u,k.index=l})},[k,u,l]),Ce(m,()=>k.type=m),Ce(t,()=>k.accept=t,void 0,vt),Ce(i,()=>i&&(k.data=i)),Ce(l,()=>{var h;(h=k.manager)!=null&&h.dragOperation.status.idle&&x?.idle&&k.refreshShape()},Mp),Ds(a,h=>k.handle=h),Ds(o,h=>k.element=h),Ds(p,h=>k.target=h),Ce(c,()=>k.disabled=c??!1,void 0,vt),Ce(f,()=>k.sensors=f,void 0,vt),Ce(n,()=>k.collisionDetector=n),Ce(r,()=>k.collisionPriority=r),Ce(g,()=>k.plugins=g,void 0,vt),Ce(x,()=>k.transition=x,void 0,vt),Ce(d,()=>k.modifiers=d,void 0,vt),Ce(e.alignment,()=>k.alignment=e.alignment),{sortable:b,get isDragging(){return b.isDragging},get isDropping(){return b.isDropping},get isDragSource(){return b.isDragSource},get isDropTarget(){return b.isDropTarget},handleRef:_.useCallback(h=>{k.handle=h??void 0},[k]),ref:_.useCallback(h=>{var y,w;!h&&((y=k.element)!=null&&y.isConnected)&&!((w=k.manager)!=null&&w.dragOperation.status.idle)||(k.element=h??void 0)},[k]),sourceRef:_.useCallback(h=>{var y,w;!h&&((y=k.source)!=null&&y.isConnected)&&!((w=k.manager)!=null&&w.dragOperation.status.idle)||(k.source=h??void 0)},[k]),targetRef:_.useCallback(h=>{var y,w;!h&&((y=k.target)!=null&&y.isConnected)&&!((w=k.manager)!=null&&w.dragOperation.status.idle)||(k.target=h??void 0)},[k])}}function Sv(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const Do="tile",ef="gap",$v=[Hd.configure({activatorElements:e=>[e.element]}),Kd],Tv=e=>[...e,xa.configure({feedback:"clone"})];function Ov({id:e,index:t,children:n}){const{ref:r,handleRef:s,isDragSource:i}=_v({id:e,index:t,type:Do,accept:Do,collisionDetector:pa,plugins:Tv});return v.jsx(v.Fragment,{children:n({ref:r,handleRef:s,isDragSource:i})})}function Ev({id:e,after:t,children:n}){const{ref:r,isDropTarget:s}=og({id:e,type:ef,accept:Do,collisionDetector:pa,data:{after:t}});return v.jsx(v.Fragment,{children:n({ref:r,isDropTarget:s})})}const Cv=L.createSvgIcon(v.jsx("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"})),Iv=L.createSvgIcon(v.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}));function Dv({tile:e,index:t,selected:n,flash:r=!1,menuOpen:s,onInsertAfter:i,onSelect:o,onOpenMenu:a,children:l}){const{theme:u}=Ye.usePublisherTheme();return v.jsx(Ov,{id:He(e),index:t,children:({ref:c,handleRef:d,isDragSource:f})=>v.jsxs(S.Box,{ref:c,onClick:o,onPointerDown:p=>{p.button===0&&o()},"aria-label":`Tile ${e.name}`,"aria-current":n,"data-tile-key":He(e),"data-flash":r||void 0,sx:{position:"relative",display:"grid",minWidth:0,cursor:"grab",borderRadius:1,outline:n?`2px solid ${u.drillLink}`:"2px solid transparent",outlineOffset:2,...r&&{outlineColor:u.drillLink,boxShadow:`0 0 0 6px color-mix(in srgb, ${u.drillLink} 25%, transparent)`},transition:"outline-color 120ms, opacity 120ms, box-shadow 120ms","&&[data-dnd-dragging]":{opacity:1,outline:"none",boxShadow:"0 12px 32px rgba(0, 0, 0, 0.22)"},"&&[data-dnd-placeholder]":{opacity:.45,outline:`2px dashed ${u.drillLink}`,boxShadow:"none"},"&:hover .builder-affordance, &:focus-within .builder-affordance":{opacity:1},"&:hover":{outlineColor:n?u.drillLink:u.cardBorder,boxShadow:"0 2px 10px rgba(0, 0, 0, 0.10)"}},children:[l,v.jsx(S.Box,{ref:d,className:"builder-affordance","aria-label":`Move ${Ei(e)}`,sx:{position:"absolute",top:"2px",left:"2px",display:"grid",placeItems:"center",width:"22px",height:"22px",borderRadius:"4px",cursor:"grab",touchAction:"none",zIndex:2,color:u.tileTitle,bgcolor:u.tile,opacity:f||n?.9:0,transition:"opacity 120ms","&:hover":{opacity:1},"&:active":{cursor:"grabbing"},"&:focus-visible":{opacity:1,outline:`2px solid ${u.drillLink}`,outlineOffset:1}},children:v.jsx(Cv,{sx:{fontSize:16}})}),v.jsx(S.IconButton,{className:"builder-affordance",size:"small","aria-label":`Settings for ${Ei(e)}`,onClick:p=>{p.stopPropagation(),a(p.currentTarget)},sx:{position:"absolute",top:"2px",right:"2px",width:22,height:22,zIndex:2,color:u.tileTitle,bgcolor:u.tile,opacity:n||s?.9:0,transition:"opacity 120ms","&:hover":{opacity:1,bgcolor:u.tile}},children:v.jsx(Iv,{sx:{fontSize:16}})}),i&&v.jsx(S.IconButton,{className:"builder-affordance",size:"small","aria-label":`Insert tile after ${Ei(e)}`,onClick:p=>{p.stopPropagation(),i()},sx:{position:"absolute",bottom:"-18px",left:"50%",transform:"translateX(-50%)",width:20,height:20,zIndex:3,color:u.tileTitle,bgcolor:u.tile,border:u.cardBorder,opacity:0,transition:"opacity 120ms","&:hover, &:focus-visible":{opacity:1,bgcolor:u.tile}},children:v.jsx(L.AddIcon,{sx:{fontSize:14}})})]})})}function Av({tile:e,heading:t,note:n}){const{theme:r}=Ye.usePublisherTheme();return v.jsxs(L.TileCard,{sx:{minHeight:140},children:[v.jsx(L.TileHeading,{title:t?.title??e.label??e.name,subtitle:t?t.subtitle:e.subtitle}),n&&v.jsx(S.Typography,{variant:"body2",sx:{color:r.tileTitle,py:2},children:n}),v.jsxs(S.Typography,{variant:"caption",sx:{display:"block",color:r.tileTitle,opacity:.7},children:[e.source," → ",e.name]})]})}function jv({after:e}){const{theme:t}=Ye.usePublisherTheme();return v.jsx(Ev,{id:qu(e),after:e,children:({ref:n,isDropTarget:r})=>v.jsx(S.Box,{ref:n,"aria-hidden":!0,sx:{minHeight:48,borderRadius:1,border:`1px dashed ${t.drillLink}`,bgcolor:r?`color-mix(in srgb, ${t.drillLink} 12%, transparent)`:"transparent",opacity:r?.95:.4,transition:"opacity 120ms, background-color 120ms"}})})}function Pv({columns:e}){const{theme:t}=Ye.usePublisherTheme();return v.jsx(S.Box,{"aria-hidden":!0,sx:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3,display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,gap:`${L.GRID_GAP_PX}px`},children:Array.from({length:e},(n,r)=>v.jsx(S.Box,{sx:{borderLeft:`1px dashed ${t.drillLink}`,borderRight:r===e-1?`1px dashed ${t.drillLink}`:"none",opacity:.35}},r))})}const Mv="Write markdown: # heading, **bold**, - list";function Rv({tile:e,onChange:t}){return v.jsx(L.TileCard,{sx:{minHeight:72},children:v.jsx(Pu,{markdown:e.markdown,placeholder:Mv,onCommit:t})})}var Lv=Object.defineProperty,Nv=Object.defineProperties,Fv=Object.getOwnPropertyDescriptors,Fl=Object.getOwnPropertySymbols,zv=Object.prototype.hasOwnProperty,Wv=Object.prototype.propertyIsEnumerable,zl=(e,t,n)=>t in e?Lv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tn=(e,t)=>{for(var n in t||(t={}))zv.call(t,n)&&zl(e,n,t[n]);if(Fl)for(var n of Fl(t))Wv.call(t,n)&&zl(e,n,t[n]);return e},On=(e,t)=>Nv(e,Fv(t));function Bv(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function xs(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function zi(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function qv(e,t,n){var r,s;const{source:i,target:o,canceled:a}=t.operation;if(!i||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const l=(h,y)=>h===y||h!==null&&typeof h=="object"&&"id"in h&&h.id===y;if(Array.isArray(e)){const h=e.findIndex(w=>l(w,i.id)),y=e.findIndex(w=>l(w,o.id));if(h===-1||y===-1){if(zi(i)){const w=i.initialIndex,D=i.index;return w===D||w<0||w>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,w,D)}return e}if(!a&&"index"in i&&typeof i.index=="number"){const w=i.index;if(w!==h)return n(e,h,w)}return n(e,h,y)}const u=Object.entries(e);let c=-1,d,f=-1,p;for(const[h,y]of u)if(c===-1&&(c=y.findIndex(w=>l(w,i.id)),c!==-1&&(d=h)),f===-1&&(f=y.findIndex(w=>l(w,o.id)),f!==-1&&(p=h)),c!==-1&&f!==-1)break;if(c===-1&&zi(i)){const h=i.initialGroup==null?void 0:xs(e,i.initialGroup),y=i.initialIndex,w=i.group==null?void 0:xs(e,i.group),D=i.index;if(h==null||w==null||h===w&&y===D)return"preventDefault"in t&&t.preventDefault(),e;if(h===w)return On(Tn({},e),{[h]:n(e[h],y,D)});const T=e[h][y];return On(Tn({},e),{[h]:[...e[h].slice(0,y),...e[h].slice(y+1)],[w]:[...e[w].slice(0,D),T,...e[w].slice(D)]})}if(!i.manager)return e;const{dragOperation:m}=i.manager,g=(s=(r=m.shape)==null?void 0:r.current.center)!=null?s:m.position.current;if(p==null){const h=xs(e,o.id);if(h!=null){const y=o.shape&&g.y>o.shape.center.y?e[h].length:0;p=h,f=y}}if(d==null||p==null||d===p&&c===f){if(d!=null&&d===p&&c===f&&zi(i)){const h=i.group==null?void 0:xs(e,i.group),y=i.group!=null&&h!==d,w=i.index!==c;if(y||w){const D=i.group==null?d:h;if(D!=null){if(d===D)return On(Tn({},e),{[d]:n(e[d],c,i.index)});const T=e[d][c];return On(Tn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[D]:[...e[D].slice(0,i.index),T,...e[D].slice(i.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===p)return On(Tn({},e),{[d]:n(e[d],c,f)});const k=o.shape&&Math.round(g.y)>Math.round(o.shape.center.y)?1:0,b=e[d][c];return On(Tn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[p]:[...e[p].slice(0,f+k),b,...e[p].slice(f+k)]})}function Gv(e,t){return qv(e,t,Bv)}function Uv({tiles:e,commit:t,onLanded:n}){const[r,s]=_.useState(void 0),i=_.useRef(void 0),[o,a]=_.useState(!1);return{dragging:o,preview:r,onDragStart:()=>{a(!0),i.current=e},onDragOver:d=>{const{source:f,target:p}=d.operation;if(!f||!p)return;const m=i.current??e;let g;if(p.type===ef){const{after:x}=p.data,k=m.findIndex(y=>He(y)===f.id);if(k<0||x===f.id)return;const h=m.filter((y,w)=>w!==k).findIndex(y=>He(y)===x)+1;g=Km(m,k,h)}else{const x=m.map(He),k=Gv(x,d);if(k.every((h,y)=>h===x[y]))return;const b=new Map(m.map(h=>[He(h),h]));g=Vm(k.map(h=>b.get(h)),e.map(h=>h.break??!1))}i.current=g,s(g)},onDragEnd:d=>{a(!1);const f=i.current;if(i.current=void 0,s(void 0),d.canceled||!f)return;t(f);const p=f.findIndex(m=>He(m)===d.operation.source?.id);p>=0&&n(p)}}}const Vv=e=>e&&e.length===1?`This tile's chart line (${e[0]}) is not one the builder models, so its chart cannot be changed here.`:`This tile has ${e?.length??"several"} chart lines${e?` (${e.join(" and ")})`:""}, so its chart cannot be changed here.`,Kv="This tile's view is declared on its source, so its chart is set in the model.";function Wl({columns:e,colspan:t,onPick:n}){const{theme:r}=Ye.usePublisherTheme();return v.jsxs(S.Stack,{direction:"row",sx:{gap:.5,alignItems:"center"},children:[v.jsx(S.Typography,{variant:"caption",sx:{color:r.tileTitle,mr:.5},children:"Width"}),[["Full",1],["½",2],["⅓",3],["¼",4]].map(([s,i])=>{const o=L.presetSpan(e,i),a=(t??1)===o;return v.jsx(S.Button,{size:"small",variant:a?"contained":"outlined","aria-label":`Width ${s}`,"aria-pressed":a,onClick:()=>n(o),sx:{minWidth:40,px:1},children:s},s)})]})}function Hv({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:s,removeBlocked:i,columns:o,onDrills:a,view:l}){const u=_.useId(),{theme:c}=Ye.usePublisherTheme(),{draft:d,patch:f,close:p,discard:m}=Pa(t,e!==null,r,n),g=d!==void 0&&we(d)?d:void 0,x=g!==void 0&&g.declaration.kind!=="inherited",k=h=>f(y=>{we(y)&&h(y)}),b=t&&we(t)?t.chart:void 0;return v.jsx(S.Popover,{open:e!==null&&d!==void 0,anchorEl:e,onClose:p,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:d&&v.jsxs(S.Stack,{sx:{gap:1.5},children:[v.jsx(S.Typography,{variant:"overline",sx:{color:c.tileTitle,lineHeight:1.5},children:g?`${g.source} → ${g.name}`:`Text · ${d.name}`}),!g&&o>1&&v.jsx(Wl,{columns:o,colspan:d.colspan,onPick:h=>f(y=>{y.colspan=h})}),g&&x&&v.jsxs(v.Fragment,{children:[v.jsx(Co,{state:g.chart??"default",view:l,cellLabel:`${g.source} ${g.name}`,...g.chart==="custom"?{disabledReason:Vv(g.chartLines)}:{},onChange:h=>k(y=>{const w=b;h===(w??"default")?(w===void 0?delete y.chart:y.chart=w,delete y.chartCarried):(y.chart=h,l?y.chartCarried=l.chart?[l.chart]:[]:delete y.chartCarried)})}),o>1&&v.jsx(Wl,{columns:o,colspan:g.colspan,onPick:h=>k(y=>{y.colspan=h})})]}),g&&!x&&v.jsxs(v.Fragment,{children:[v.jsx(S.Typography,{variant:"body2",sx:{color:c.tileTitle},children:"Declared on its source, so its title and layout are set in the model. It can still be moved."}),v.jsx(Co,{state:"default",view:l,cellLabel:`${g.source} ${g.name}`,disabledReason:Kv,onChange:()=>{}})]}),g?.declaration.kind==="opaque"&&v.jsxs(S.Typography,{variant:"body2",sx:{color:c.tileTitle},children:["Its body is ",g.declaration.why,", so a filter has no single place to go. Everything else here is editable."]}),v.jsx(S.Divider,{}),v.jsxs(S.Stack,{direction:"row",sx:{justifyContent:"space-between"},children:[x?v.jsx(S.Button,{size:"small",onClick:()=>{p(),a()},children:"Drill-through…"}):v.jsx("span",{}),v.jsx(S.Button,{color:"error",size:"small","aria-disabled":i!==void 0||void 0,"aria-describedby":i!==void 0?u:void 0,disableRipple:i!==void 0,sx:i!==void 0?{opacity:.5,cursor:"default"}:void 0,onClick:()=>{i===void 0&&(m(),s())},children:"Remove tile"})]}),i!==void 0&&v.jsx(S.Typography,{id:u,variant:"caption",sx:{color:c.tileTitle},children:i})]})})}function Yv({dirty:e,saving:t,canSave:n,save:r,onExit:s}){const[i,o]=_.useState("idle"),[a,l]=_.useState(!1),u=_.useRef(r);u.current=r;const c=_.useRef(s);c.current=s;const d=_.useRef(0),f=_.useCallback(async()=>{const m=++d.current;l(!1),o("saving");try{await u.current()}catch{d.current===m&&o("idle");return}d.current===m&&l(!0)},[]);return _.useEffect(()=>{if(i==="waiting"){if(t)return;e?f():(o("idle"),c.current())}else if(i==="saving"){if(!a||t)return;o("idle"),e||c.current()}},[i,a,t,e,f]),{requestExit:_.useCallback(()=>{i==="idle"&&(e?o("asking"):c.current())},[i,e]),dialog:{open:i==="asking",canSave:n,onKeepEditing:()=>{i==="asking"&&o("idle")},onDiscard:()=>{i==="asking"&&(o("idle"),c.current())},onSaveAndExit:()=>{i==="asking"&&(t?o("waiting"):f())}}}}function Xv({editor:e,onSave:t,onExit:n,onDirtyChange:r,onSaveNoticeChange:s,onChange:i,extraDirty:o=!1,report:a,unit:l,prepare:u,shortcuts:c}){const[d,f]=_.useState(!1),[p,m]=_.useState(!1),[g,x]=_.useState(!1),[k,b]=_.useState(void 0),h=_.useRef(null),y=_.useRef(a);y.current=a;const w=e.dirty||o,D=(e.edited??e.dirty)||o;_.useEffect(()=>{i?.(e.document)},[e.document,i]),_.useLayoutEffect(()=>{r?.(D)},[D,r]);const T=_.useRef(r);T.current=r,_.useEffect(()=>()=>T.current?.(!1),[]);const A=e.lastSave!==void 0&&!!t;_.useEffect(()=>{s?.(A)},[A,s]);const I=_.useRef(s);I.current=s,_.useEffect(()=>()=>I.current?.(!1),[]),_.useEffect(()=>{A||m(!1)},[A]);const C=_.useRef(l);C.current=l,_.useEffect(()=>{x(!1)},[e.document]);const W=_.useCallback(()=>{f(!0),x(!1);const R=L.now(),{structural:q}=e,N=e.pendingOpen??!1,Y=y.current.size,V={before:C.current.count(e.saved),after:C.current.count(e.document)};return e.save().then($=>{$.ok===!0?(b(V),y.current.saved({size:Y,structural:q,fromOpen:N,durationMs:L.now()-R})):y.current.refused($.reason)}).finally(()=>f(!1))},[e]),F=_.useRef(!1),G=_.useRef(!1);_.useEffect(()=>{!G.current||d||(G.current=!1,h.current?.focus())},[g,d]);const J=_.useCallback(()=>{if(!t||d||F.current||!e.canUndoSave)return;F.current=!0,f(!0);const R=L.now(),q=e.lastSave?.structural??!1,N=y.current.size;return e.undoSave().then(Y=>{Y.ok===!0?(G.current=!0,x(!0),y.current.undone({size:N,structural:q,fromOpen:!1,durationMs:L.now()-R})):y.current.undoRefused(Y.reason)}).finally(()=>{F.current=!1,f(!1)})},[t,d,e]),Q=_.useCallback(()=>{if(!(!t||!e.dirty||d))return W()},[t,e,d,W]),se=_.useRef(Q);se.current=Q;const ce=_.useCallback(()=>{const R=()=>se.current();return u?u(R):R()},[u]),te=Yv({dirty:D,saving:d,canSave:!!t,save:ce,onExit:()=>n?.()});wg(_.useMemo(()=>({...c,undo:e.undo,redo:e.redo,...t?{save:ce}:{},paused:te.dialog.open||p}),[c,e,t,ce,te.dialog.open,p]));const ue=!!t&&!d&&e.canUndoSave,E=e.lastSave,U={...E?{lastSave:E}:{},unit:l.name,moved:k,canUndoSave:ue,undone:g&&E===void 0,viewing:p,onView:m,onUndoSave:J},B={canUndo:e.canUndo,canRedo:e.canRedo,onUndo:e.undo,onRedo:e.redo,dirty:w,saving:d,saveButton:h,...t?{onSave:ce}:{},...n?{onExit:te.requestExit}:{}};return{saving:d,save:ce,exitGuard:te,undoSave:J,canUndoSave:ue,lastSave:E,notice:U,toolbarProps:B}}function Zv(e){const{splice:t,onSave:n,structural:r,clearsHistory:s,opensDirty:i=!1}=e,[o,a]=_.useState({stack:[e.document],index:0}),[l,u]=_.useState(e.source),[c,d]=_.useState(void 0),[f,p]=_.useState(e.document),[m,g]=_.useState(i),[x,k]=_.useState(e.replaces),[b,h]=_.useState(!1),y=o.stack[o.index],w=_.useRef(o);w.current=o;const D=_.useRef(!1),[T,A]=_.useState(!1),I=R=>{D.current=R,A(R)},[C,W]=_.useState(void 0),F=_.useCallback(R=>{d(void 0),a(q=>{const N=structuredClone(q.stack[q.index]);if(R(N),JSON.stringify(N)===JSON.stringify(q.stack[q.index]))return q;const V=[...q.stack.slice(0,q.index+1),N].slice(-100);return{stack:V,index:V.length-1}})},[]),G=_.useCallback(()=>{d(void 0),a(R=>R.index>0?{...R,index:R.index-1}:R)},[]),J=_.useCallback(()=>{d(void 0),a(R=>R.index<R.stack.length-1?{...R,index:R.index+1}:R)},[]),Q=_.useCallback(async(R,q)=>{try{return await t(R,q)}catch(N){return{ok:!1,reason:`Could not build the file: ${N instanceof Error?N.message:String(N)}`}}},[t]),se=_.useCallback(async()=>{if(D.current)return{ok:!1,reason:"A save is still being written."};const R={source:l,saved:f,history:w.current,pendingOpen:m,replacing:x,unwritten:b},q=s?.(f,y)??!1,N=r?.(f,y)??!1;I(!0);try{const Y=await Q(l,y);if(ei(Y))return d(Y.reason),{ok:!1,reason:Y.reason};try{await n?.(Y.source,{purpose:"save",document:y})}catch($){const j=`Could not save: ${$ instanceof Error?$.message:String($)}`;return d(j),{ok:!1,reason:j}}u(Y.source),p(y),g(!1),k(void 0),h(!1);const V=q?{stack:[y],index:0}:R.history;return a($=>$===R.history?V:q?{stack:[$.stack[$.index]],index:0}:$),W(n?{before:R,after:V,lastSave:{before:x??l,after:Y.source,structural:N,clearsHistory:q}}:void 0),d(void 0),{ok:!0}}finally{I(!1)}},[y,Q,n,l,f,m,x,b,s,r]),ce=_.useCallback(async()=>{if(D.current)return{ok:!1,reason:"A save is still being written."};if(!n||C===void 0||C.after!==w.current)return{ok:!1,reason:"There is no save to undo."};const{before:R}=C;I(!0);try{await n(R.replacing??R.source,{purpose:"undo",document:R.saved})}catch(q){const N=`Could not undo the save: ${q instanceof Error?q.message:String(q)}`;return d(N),{ok:!1,reason:N}}finally{I(!1)}return u(R.source),p(R.saved),g(R.pendingOpen),k(R.replacing),h(R.unwritten||R.replacing!==void 0),a(q=>q===C.after?R.history:q),W(void 0),d(void 0),{ok:!0}},[n,C]),te=_.useMemo(()=>b||JSON.stringify(y)!==JSON.stringify(f),[y,f,b]),ue=_.useMemo(()=>r?.(f,y)??!1,[y,f,r]),E=_.useMemo(()=>s?.(f,y)??!1,[y,f,s]),U=C!==void 0&&C.after===o,B=_.useCallback(async()=>{const R=await Q(l,y);return ei(R)?{ok:!1,reason:R.reason}:{ok:!0,source:R.source}},[y,Q,l]);return{document:y,saved:f,source:l,canUndo:o.index>0,canRedo:o.index<o.stack.length-1,dirty:te||m,edited:te,pendingOpen:m,...c===void 0?{}:{error:c},update:F,undo:G,redo:J,save:se,preview:B,structural:ue,clearsHistory:E,canUndoSave:U&&!T&&n!==void 0,...U?{lastSave:C.lastSave}:{},undoSave:ce}}const Qv=(e,t)=>{const n=new Set(e.tiles.map(Eo)),r=new Set(t.tiles.map(Eo));return[...n].some(s=>!r.has(s))||[...r].some(s=>!n.has(s))};function Jv(e){const{conversion:t,modelPath:n,...r}=e,s=t?.from,i=t?.to,o=_.useCallback((a,l)=>ju(s!==void 0&&a===s?i:a,l,{changeKind:!0,...n!==void 0?{modelPath:n}:{}}),[s,i,n]);return Zv({...r,splice:o,structural:Qv,opensDirty:t!==void 0})}function tf({source:e,document:t,onSave:n,onChange:r,onDirtyChange:s,onSaveNoticeChange:i,renderTile:o,controls:a,givens:l,catalog:u,toolbar:c,onExit:d,dashboards:f,onEvent:p,conversion:m,savesTo:g="package",saveLabel:x,replaces:k,modelPath:b}){const h=Jv({source:e,document:t,...n?{onSave:n}:{},...m?{conversion:m}:{},...k!==void 0?{replaces:k}:{},...b!==void 0?{modelPath:b}:{}}),[y,w]=_.useState(void 0),[D,T]=_.useState(void 0),A=_.useRef(!1),I=_.useRef(h.document),C=h.document.kind==="notebook",W=C?1:h.document.columns??L.DEFAULT_COLUMNS,F=_.useRef(null),{dragging:G,preview:J,onDragStart:Q,onDragOver:se,onDragEnd:ce}=Uv({tiles:h.document.tiles,commit:O=>h.update(M=>{M.tiles=O}),onLanded:w}),[te,ue]=_.useState(void 0),[E,U]=_.useState(void 0),[B,R]=_.useState(!1),[q,N]=_.useState(void 0),Y=O=>{N(O),R(!0)},[V,$]=_.useState(void 0),[j,z]=_.useState(null),X=_.useMemo(()=>Nm(h.document),[h.document]),ie=_.useMemo(()=>new Set([...h.document.sources.map(O=>O.base),...h.document.tiles.filter(we).map(O=>O.source)]),[h.document]),Z=_.useMemo(()=>{const O=new Set((t.localGivens??[]).map(M=>M.name));return(l??[]).filter(M=>!O.has(M.name))},[t,l]),le=_.useMemo(()=>ag(h.document,Z),[h.document,Z]),me=_.useMemo(()=>new Map(h.document.sources.map(O=>[O.name,$l(u,O.base)])),[u,h.document.sources]),re=_.useCallback(O=>me.get(O.source)??$l(u,O.source),[me,u]),ve=E===void 0?void 0:h.document.tiles[E.index],de=ve&&we(ve)?ve:void 0,Ae=(()=>{if(!de||!u)return;const O=h.document.sources.find(H=>H.name===de.source)?.base??de.source,M=de.declaration.kind==="reference"?de.declaration.from:de.name;return u.sources.find(H=>H.name===O)?.views.find(H=>H.name===M)})(),We=(O,M)=>{const H=[];for(const ee of h.document.tiles){if(!we(ee))continue;const Ee=re(ee);if(!Ee)continue;const _e=new Map(Ee.map(Se=>[Se.name,Se.type]));for(const Se of ee.filters??[])Se.given===O&&(!_e.has(Se.field)||!js(M,_e.get(Se.field)))&&H.push(`${Se.field} on ${ee.label??ee.name} (${h.document.sources.find(mt=>mt.name===ee.source)?.base??ee.source})`)}return H},P=_.useMemo(()=>le.filter(O=>O.origin==="model"&&O.boundTiles===0),[le]),K=_.useMemo(()=>({escape:()=>{!E&&!te&&w(void 0)},nudge:O=>{if(G||y===void 0||C)return;const M=h.document.tiles[y];if(!M||we(M)&&M.declaration.kind==="inherited")return;const H=L.nudgedSpan(M.colspan??1,O,W);H!==(M.colspan??1)&&h.update(ee=>{ee.tiles[y].colspan=H})}}),[h,E,te,y,W,C,G]);_.useEffect(()=>{const O=I.current;if(I.current=h.document,!A.current)return;A.current=!1;const M=Sg(O,h.document);if(M===void 0)return;T(M),Array.from(F.current?.querySelectorAll("[data-tile-key]")??[]).find(ee=>ee.dataset.tileKey===M)?.scrollIntoView?.({block:"nearest",behavior:"smooth"})},[h.document,F]),_.useEffect(()=>{if(D===void 0)return;const O=setTimeout(()=>T(void 0),1500);return()=>clearTimeout(O)},[D]);const ne=_.useMemo(()=>({...h,undo:()=>{A.current=!0,h.undo()},redo:()=>{A.current=!0,h.redo()}}),[h]),[fe,Re]=_.useState(!1),Et=_.useRef(void 0),Be=_.useRef(void 0),Ft=_.useMemo(()=>({setDirty:Re,commitRef:Et}),[]),at=_.useCallback(O=>{if(!Et.current)return O();if(Et.current())return new Promise(M=>{Be.current=()=>M(O())})},[]);_.useEffect(()=>{if(fe||!Be.current)return;const O=Be.current;Be.current=void 0,O()},[fe,h.dirty]);const Ct=Xv({editor:ne,extraDirty:fe,prepare:at,unit:{name:"tile",count:O=>O.tiles.length},onSave:n,onExit:d,onDirtyChange:s,onSaveNoticeChange:i,onChange:r,shortcuts:K,report:{size:h.document.tiles.length,saved:({size:O,structural:M,durationMs:H,fromOpen:ee})=>p?.(C?{type:"notebook.saved",cells:O,structural:M,converted:ee,where:g,durationMs:H}:{type:"dashboard.saved",tiles:O,structural:M,where:g,durationMs:H}),refused:O=>p?.({type:C?"notebook.save_refused":"dashboard.save_refused",reason:O}),undone:({size:O,structural:M,durationMs:H})=>p?.(C?{type:"notebook.save_undone",cells:O,structural:M,where:g,durationMs:H}:{type:"dashboard.save_undone",tiles:O,structural:M,where:g,durationMs:H}),undoRefused:O=>p?.({type:C?"notebook.save_undo_refused":"dashboard.save_undo_refused",reason:O})}}),Zt=O=>{R(!1),h.update(M=>{let H=M.sources.find(_e=>_e.base===O.base);if(!H){const _e=new Set(M.sources.map(mt=>mt.name));let Se=`${O.base}_tiles`;for(let mt=2;_e.has(Se);mt++)Se=`${O.base}_tiles_${mt}`;H={name:Se,base:O.base},M.sources.push(H)}const ee=new Set(M.tiles.filter(we).filter(_e=>_e.source===H.name).map(_e=>_e.name));let Ee=`${O.view}_tile`;for(let _e=2;ee.has(Ee);_e++)Ee=`${O.view}_tile_${_e}`;M.tiles.splice(q??M.tiles.length,0,{name:Ee,source:H.name,declaration:{kind:"reference",from:O.view},...C?{}:{colspan:O.colspan},...O.label?{label:O.label}:{},...O.chart?{chart:O.chart}:{},...O.chartCarried?{chartCarried:O.chartCarried}:{}})}),w(q??h.document.tiles.length)},zt=()=>{R(!1),h.update(O=>{const M=new Set(O.tiles.filter(Ue).map(ee=>ee.name));let H=1;for(;M.has(`text_${H}`);)H++;O.tiles.splice(q??O.tiles.length,0,{kind:"text",name:`text_${H}`,markdown:"",...C?{}:{colspan:W}})}),w(q??h.document.tiles.length)},It=(O,M)=>h.update(H=>{const ee=H.tiles.find(Ee=>He(Ee)===O);ee&&M(ee)}),Qt=(O,M)=>{if(O.declaration.kind==="inherited")return;const H=He(O),ee=Ee=>_e=>It(H,Se=>{we(Se)&&(_e===""?delete Se[Ee]:Se[Ee]=_e)});return{title:v.jsx(Ai,{value:O.label??"",placeholder:M,ariaLabel:"Tile title",onCommit:ee("label")}),subtitle:v.jsx(Ai,{value:O.subtitle??"",placeholder:"Add a subtitle",ariaLabel:"Tile subtitle",faintWhenEmpty:!0,onCommit:ee("subtitle")})}},lt=O=>{U(void 0),w(void 0),h.update(M=>{M.tiles.splice(O,1)})},ir=(O,M,H)=>{ue(void 0),h.update(ee=>{H&&pg(ee,H),hg(ee,O,M)})},Dt=O=>{ue(void 0),h.update(M=>gg(M,O))},Jt=J??h.document.tiles,en=h.document.tiles.length===0,or=G?Hm(Jt,W):Jt.map(Bu);return v.jsx(mu.Provider,{value:Ft,children:v.jsxs(S.Stack,{sx:{gap:0},children:[v.jsx(_g,{...Ct.toolbarProps,...c?{actions:c}:{},...u?{onAddTile:()=>Y()}:{},onSettings:z,savesTo:g,...x?{saveLabel:x}:{}}),v.jsxs(S.Stack,{sx:{gap:2,px:"4px",pb:"4px"},children:[h.pendingOpen&&v.jsx(S.Alert,{severity:"info",children:"This notebook is in the cell format. Saving rewrites it as a layout notebook, and a named query run once becomes that tile's view; Undo save puts it back."}),v.jsx(Pm,{...Ct.notice}),v.jsxs(S.Box,{children:[v.jsx(S.Typography,{variant:"h5",sx:{fontWeight:600},children:v.jsx(Ai,{value:h.document.title,placeholder:C?"Untitled notebook":"Untitled dashboard",ariaLabel:C?"Notebook title":"Dashboard title",onCommit:O=>h.update(M=>{M.title=O})})}),v.jsx(Pu,{variant:"caption",markdown:h.document.description??"",placeholder:"Add a description",onCommit:O=>h.update(M=>{O.trim()===""?delete M.description:M.description=O})})]}),en?v.jsxs(S.Stack,{sx:{alignItems:"flex-start",gap:1,py:3,px:2,border:1,borderStyle:"dashed",borderColor:"divider",borderRadius:1},children:[v.jsxs(S.Typography,{variant:"body2",children:["This ",C?"notebook":"dashboard"," is not served until it has a tile."]}),u&&v.jsx(S.Button,{size:"small",variant:"contained",onClick:()=>Y(),children:"Add tile"})]}):v.jsx(Um,{controls:le,tileCount:h.document.tiles.length,unknownFieldsOf:We,onEdit:O=>ue({control:O}),onAdd:()=>ue({}),onRemove:Dt,children:a}),h.error&&v.jsx(S.Alert,{severity:"warning",children:h.error}),v.jsx(Gp,{sensors:$v,onDragStart:Q,onDragOver:se,onDragEnd:ce,children:v.jsxs(S.Box,{ref:F,sx:{position:"relative"},children:[!C&&G&&v.jsx(Pv,{columns:W}),v.jsx(L.DashboardGrid,{tiles:or,columns:W,keyOf:O=>O.kind==="gap"?qu(O.after):He(O.tile),renderTile:O=>{if(O.kind==="gap")return v.jsx(jv,{after:O.after});const{tile:M,index:H}=O;return v.jsx(Dv,{tile:M,index:H,selected:H===y,flash:He(M)===D,menuOpen:E?.index===H,...C&&u?{onInsertAfter:()=>Y(H+1)}:{},onSelect:()=>w(H),onOpenMenu:ee=>{w(H),U({anchor:ee,index:H})},children:Ue(M)?v.jsx(Rv,{tile:M,onChange:ee=>It(He(M),Ee=>{Ue(Ee)&&(Ee.markdown=ee)})}):o&&!h.pendingOpen?o(M,Qt(M,L.tileTitle(`${M.source} -> ${M.name}`))):v.jsx(Av,{tile:M,heading:Qt(M,M.name),...h.pendingOpen?{note:"Preview appears after you Save"}:{}})})}})]})}),C&&u&&!en&&v.jsx(S.Button,{size:"small",startIcon:v.jsx(L.AddIcon,{}),"aria-label":"Add tile at the end",onClick:()=>Y(),sx:{alignSelf:"center"},children:"Add tile"}),v.jsx(Lm,{open:te!==void 0,document:h.document,...te?.control?{control:te.control}:{},available:P,...u?{fieldsFor:re}:{},onClose:()=>ue(void 0),onApply:ir,onRemove:Dt}),v.jsx(Hv,{anchor:E?.anchor??null,tile:E===void 0?void 0:h.document.tiles[E.index],onClose:()=>U(void 0),onCommit:O=>{const M=E?.index;M!==void 0&&h.update(H=>{H.tiles[M]=O})},onRemove:()=>{E!==void 0&<(E.index)},...h.document.tiles.length===1&&h.saved.tiles.length>0?{removeBlocked:"A saved dashboard needs at least one tile."}:{},columns:W,view:Ae,onDrills:()=>{$(de?.source)}}),v.jsx(Mm,{open:V!==void 0,document:h.document,source:h.document.sources.find(O=>O.name===V),givenNames:le.map(O=>O.name),dashboards:f??[],onClose:()=>$(void 0),onApply:O=>h.update(M=>{const ee=[...(M.drills??[]).filter(Ee=>Ee.source!==V),...O];ee.length===0?delete M.drills:M.drills=ee})}),v.jsx(Bm,{anchor:j,settings:X,catalog:u,inUse:ie,onClose:()=>z(null),onCommit:O=>h.update(M=>{O.kind===void 0?delete M.kind:M.kind=O.kind,O.columns===void 0?delete M.columns:M.columns=O.columns,O.autorun===void 0?delete M.autorun:M.autorun=O.autorun,M.imports=O.imports})}),v.jsx(Cm,{open:B,document:h.document,catalog:u,columns:W,onClose:()=>R(!1),onAdd:Zt,onAddText:zt}),v.jsx(L.UnsavedChangesDialog,{...Ct.exitGuard.dialog})]})]})})}function eb(e,t){const n=new Set;for(const i of e.tiles)for(const o of we(i)?i.filters??[]:[])n.add(o.given);const r=[],s=new Set;for(const i of e.localGivens??[])n.has(i.name)&&(s.add(i.name),r.push(tb(i)));for(const i of t)i.name===void 0||s.has(i.name)||!n.has(i.name)||(s.add(i.name),r.push(i));return r}function tb(e){return{name:e.name,type:e.type,default:e.default,...e.label===void 0?{}:{label:e.label},...e.description===void 0?{}:{description:e.description},...e.control===void 0?{}:{control:e.control},...e.suggest?{suggest:{...e.suggest.source===void 0?{}:{source:e.suggest.source},...e.suggest.query===void 0?{}:{query:e.suggest.query},dimension:e.suggest.dimension}}:{},...e.rangeMin===void 0?{}:{rangeMin:e.rangeMin},...e.rangeMax===void 0?{}:{rangeMax:e.rangeMax}}}function nb(e){return e.kind==="inline"?!0:e.kind==="opaque"&&(e.why.includes("compound")||e.why.includes("pipeline"))}function Bl(e){return e.split("->").map(t=>t.trim().replace(/\s+/g," ")).join(" -> ").replace(/\s+/g," ")}function rb(e,t,n,r=new Map,s){if(t.declaration.kind==="inherited")return{expression:`${t.source} -> ${t.name}`,givenNames:void 0,reads:s&&[...s]};const i=t.source,o=t.declaration.kind==="reference"?t.declaration.from:t.name,a=new Map((e.localGivens??[]).map(g=>[g.name,g.type])),l=e.sources.find(g=>g.name===i)?.scopedBy??[],u=new Set([...l,...s??[]].filter(g=>n.has(g))),c=new Set([...l,...s??[]]),d=[];for(const g of t.filters??[]){const x=`where: ${ye.malloyPath(g.field)} ${g.op??"~"}`;if(n.has(g.given)){u.add(g.given),c.add(g.given),d.push(`${x} $${g.given}`);continue}if(!a.has(g.given))continue;c.add(g.given);const k=L.malloyLiteral(r.get(g.given),a.get(g.given));k!==void 0&&d.push(`${x} ${k}`)}const f=d.join(", "),p=t.chart,m=p==="none"||gi(p)?zn(p,t.chartCarried):p==="custom"&&t.chartLines?.length?t.chartLines.join(`
|
|
146
|
+
`):p==="default"&&nb(t.declaration)?zn("none"):void 0;return{...m?{annotation:m}:{},expression:`${i} -> ${o}`+(f?` + { ${f} }`:""),givenNames:Array.from(u),reads:s||c.size>0?Array.from(c):void 0}}const sb=e=>e.ok===!1,ur=(e,t)=>{const n=e[t];return typeof n=="function"?n.call(e):void 0},ib=[["runStatement","run"],["docAnnotations","notes"],["importStatement","definition"],["defineSourceStatement","definition"],["defineQuery","definition"],["defineGivenStatement","definition"],["defineUserTypeStatement","definition"],["exportStatement","definition"]],ob=/^[A-Za-z_][A-Za-z0-9_]*$/,ab="file:///publisher-notebook-builder/notebook.malloy",ws=e=>e.replace(/\r\n?/g,`
|
|
147
|
+
`);async function lb(e){const t=(E,U)=>({ok:!1,refused:`Line ${E+1}: ${U}`,line:E+1}),n=/\r(?!\n)/.exec(e);if(n)return t(e.slice(0,n.index).split(`
|
|
148
|
+
`).length-1,"a carriage return that is not part of a CRLF line ending, so the cells cannot be located. Fix: save the file with LF or CRLF line endings.");let r,s;try{r=await mi(e,ab),s=await L.loadMalloy()}catch(E){return t(0,`Malloy could not read this notebook: ${E}`)}const i=r.problems.find(E=>E.code==="syntax-error");if(i)return t(i.at?.range?.start?.line??0,`Malloy could not parse this notebook (${i.message??"unknown"}), so it cannot be edited here. Fix: correct the syntax on that line.`);const o=r.parse?.root,a=r.parse?.tokenStream,l=a?.tokenSource?.vocabulary,u=typeof a?.getTokens=="function"?a.getTokens():void 0;if(!o||typeof o.getChild!="function"||!a||!u||typeof l?.getSymbolicName!="function"||u.length===0&&e.trim()!=="")return{ok:!1,refused:"This build of Malloy does not expose a parse tree and token stream the notebook builder can read, so editing is off."};const c=E=>l.getSymbolicName(E.type),d=E=>s.routeOf({value:E.trimStart()}),f=E=>s.payloadOf({value:E}),p=E=>E==="markdown"||E==='"'||E==="text",m=E=>ws(f(E)).replace(/\n$/,""),g=(E,U)=>{const B=f(E).trim(),R=d(E)!=='"'&&ob.test(B)?"":B;return ws([R&&`${R}
|
|
149
|
+
`,...U].join("")).replace(/\n$/,"")},x=new Ca(e),k=Da(x,a),b=E=>e.slice(x.utf16(E.startIndex),x.utf16(E.stopIndex+1)),h=E=>{const U=E.start?.startIndex,B=E.stop?.stopIndex,R=x.span(E);if(U===void 0||B===void 0||!R)return;let q=R.end;for(;q>R.start&&(e[q-1]===`
|
|
150
|
+
`||e[q-1]==="\r");)q--;return{startCp:U,stopCp:B,...R,startLine:x.line(R.start),endLine:x.line(Math.max(R.start,q-1))}},y=E=>{let U=0,B=u.length;for(;U<B;){const R=U+B>>1;u[R].startIndex<E?U=R+1:B=R}return U},w=(E,U)=>{const B=[],R=[],q={lines:[],insertAt:x.utf16(E)};let N=-2;for(let Y=y(E);Y<u.length;Y++){const V=u[Y];if(V.startIndex>U)break;if(V.channel!==0)continue;const $=c(V);if($!=="ANNOTATION"&&$!=="BLOCK_ANNOTATION_BEGIN"){q.insertAt=x.lineStarts[x.line(x.utf16(V.startIndex))];break}const j=ws(b(V)),z=[];if($==="BLOCK_ANNOTATION_BEGIN"){for(;c(u[Y+1]??V)==="BLOCK_ANNOTATION_TEXT";)z.push(b(u[++Y]));c(u[Y+1]??V)==="BLOCK_ANNOTATION_END"&&Y++}if(p(d(j))){const X=x.utf16(V.startIndex),ie=x.lineStarts[x.line(X)],Z=/^[ \t]*$/.test(e.slice(ie,X));R.push({start:Z?ie:X,end:x.utf16(u[Y].stopIndex+1)})}if($==="ANNOTATION"){const X=j.replace(/\n$/,"");if(Ht(X)){const ie=x.utf16(V.startIndex),Z=x.lineStarts[x.line(ie)];q.lines.push({span:{start:/^[ \t]*$/.test(e.slice(Z,ie))?Z:ie,end:x.utf16(V.stopIndex+1)},text:X})}else Gr(X)&&q.unmodelled===void 0&&(q.unmodelled=X.trim())}if(d(j)!=="markdown")N=-2;else if($==="BLOCK_ANNOTATION_BEGIN")B.push(g(j,z)),N=-2;else{const X=m(j);V.line===N+1?B[B.length-1]+=`
|
|
151
|
+
${X}`:B.push(X),N=V.line}}return{markdown:B.length>0?B.join(`
|
|
152
|
+
|
|
153
|
+
`):void 0,prose:R,chart:q}},D=[],T=[],A=(E,U,B="remove it, or rewrite it as an import, source:, query:, given:, type: or export statement, a run:, or a `##(markdown)` / `##|(markdown)` prose note.")=>t(E,`${U}, which no notebook cell can hold, so the notebook cannot be edited here. Fix: ${B}`);for(let E=0;E<(o.childCount??0);E++){const U=o.getChild(E);if(!rs(U)){const V=U?.symbol,$=V?c(V):void 0;if(V&&$==="EOF")continue;if(V&&$==="SEMI"){D.push([V.startIndex,V.stopIndex]);continue}return A((V?.line??1)-1,"a token outside any statement")}const B=h(U);if(!B)return A(0,"a statement with no readable range");const R=ib.find(([V])=>ur(U,V)!==void 0);if(!R&&ur(U,"ignoredObjectAnnotations"))return A(B.startLine,"a # tag that annotates no statement","move the tag directly above its run:, or write trailing prose as a `##(markdown)` note.");if(!R){const V=e.slice(B.start,B.end).split(`
|
|
154
|
+
`)[0];return A(B.startLine,`\`${V.trim()}\` is a statement the notebook reader does not recognize`)}D.push([B.startCp,B.stopCp]);const[q,N]=R;if(N!=="notes"){const{markdown:V,prose:$,chart:j}=w(B.startCp,B.stopCp);T.push({kind:"statement",run:N==="run",...V!==void 0&&{markdown:V},prose:$,chart:j,startLine:B.startLine,endLine:B.endLine});continue}const Y=ur(U,q);for(const V of ur(Y,"docAnnotation")??[]){const $=h(V);if(!$)return A(B.startLine,"a note with no readable range");const j=ur(V,"docBlockAnnotation")!==void 0,z=u.filter(re=>re.startIndex>=$.startCp&&re.stopIndex<=$.stopCp),X=z.filter(re=>c(re)==="BLOCK_ANNOTATION_TEXT"),ie=X[X.length-1]??z[0],Z=ws(j&&ie?e.slice($.start,x.utf16(ie.stopIndex+1)).replace(/\r?\n$/,""):e.slice($.start,$.end)),le=d(Z),me=p(le)?j?g(Z.split(`
|
|
155
|
+
`,1)[0],X.map(b)):m(Z):void 0;T.push({kind:"note",note:{text:Z,route:le,...me!==void 0&&{body:me},block:j,startLine:$.startLine,endLine:$.endLine}})}}for(const E of u){if(c(E)!=="BLOCK_ANNOTATION_END")continue;const U=b(E).trimStart().replace(/^\|#{1,2}/,"").trim();if(U)return t(E.line-1,`the text after a block's closer (\`${U}\`) is not part of any cell, so the notebook cannot be edited here. Fix: put it on its own line, or inside the block.`)}let I=0;for(const E of u){if(E.channel!==0||c(E)==="EOF")continue;for(;I<D.length&&D[I][1]<E.startIndex;)I++;const[U,B]=D[I]??[1/0,-1/0];if(E.startIndex<U||E.stopIndex>B)return A(E.line-1,"a token outside any statement")}const C=T.findIndex(E=>E.kind==="note"&&ye.setsArtifactProperty(E.note.text));if(C<0)return t(0,"this file has no ## artifact note, so it is not a notebook the builder can edit. Fix: add `## artifact { kind=notebook }` after the ##! line.");const W=T.findIndex((E,U)=>U<C&&E.kind==="statement");if(W>=0)return t(T[W].startLine,'a statement sits above the `## artifact` tag, where only `##!` flags, comments and `"` notes may. Fix: move it below the artifact tag.');for(let E=1;E<T.length;E++){const U=T[E-1],B=T[E],R=U.kind==="note"?U.note.endLine:U.endLine,q=B.kind==="note"?B.note.startLine:B.startLine;if(q<=R)return A(q,"a line holding two statements or notes","put each statement and note on its own line.")}const F=E=>x.lineStarts[E+1]??e.length,G=[];let J=-1,Q=!0,se;T.forEach((E,U)=>{if(E.kind==="statement"){Q=!1,se=void 0,G.push({cell:{kind:E.run?"query":"definition",...E.markdown!==void 0&&{markdown:E.markdown},...E.prose.length>0&&{prose:E.prose},...E.run&&{chart:E.chart},id:""},startLine:E.startLine,endLine:E.endLine});return}const{note:B}=E;if(!(U>C&&B.body!==void 0)){Q&&(J=B.endLine),se=void 0;return}if(Q=!1,!B.block&&se&&se.endLine+1===B.startLine){se.cell.markdown+=`
|
|
156
|
+
${B.body}`,se.endLine=B.endLine;return}const q={cell:{kind:"markdown",markdown:B.body,id:""},startLine:B.startLine,endLine:B.endLine};G.push(q),se=B.block?void 0:q});const ce={start:0,end:F(J)};let te=J;const ue=G.map(({cell:E,startLine:U,endLine:B},R)=>{let q=U;for(;q-1>te&&k.lines.has(q-1);)q--;return te=B,{...E,span:{start:x.lineStarts[q],end:F(B)},id:String(R)}});for(const E of[ce,...ue.map(U=>U.span)]){const U=k.all.find(B=>B.start<E.start&&B.end>E.start||B.start<E.end&&B.end>E.end);if(U)return A(x.line(U.start),"a comment that straddles a cell","start the comment on its own line.")}return{ok:!0,source:{text:e,header:ce,cells:ue}}}const cb=e=>e.ok===!1,db=/^[A-Za-z_][A-Za-z0-9_]*$/,ql=/^query\s*:\s*([A-Za-z_][A-Za-z0-9_]*)\s+is\s+/,Gl=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;function Wi(e){let t="",n=0;for(;n<e.length;){const r=e.slice(n,n+2);if(r==="//"||r==="--"){const s=e.indexOf(`
|
|
157
|
+
`,n),i=s<0?e.length:s;t+=" ".repeat(i-n),n=i}else if(r==="/*"){const s=e.indexOf("*/",n+2),i=s<0?e.length:s+2;t+=e.slice(n,i).replace(/[^\n]/g," "),n=i}else if(e[n]==="'"||e[n]==='"'||e[n]==="`"){const s=e[n];let i=n+1;for(;i<e.length&&e[i]!==s;)i+=e[i]==="\\"?2:1;const o=Math.min(i,e.length);t+=s+e.slice(n+1,o).replace(/[^\n]/g," "),o<e.length&&(t+=s),n=o+1}else t+=e[n],n++}return t}function Ul(e){const t=[];let n=0;for(let r=0;r<e.length;r++){const s=e[r];s==="{"||s==="("||s==="["?n++:s==="}"||s===")"||s==="]"?n--:n===0&&s==="-"&&e[r+1]===">"&&t.push(r)}return t}function Vl(e,t,n){let r=e;for(const s of[...n].sort((i,o)=>o.start-i.start))r=r.slice(0,s.start-t)+r.slice(s.end-t);return r}function Kl(e,t){const n=t.split(`
|
|
158
|
+
`).map(r=>r.startsWith("|##")?` ${r}`:r).join(`
|
|
159
|
+
`);return`##|(markdown) ${e}
|
|
160
|
+
${n===""?"":`${n}
|
|
161
|
+
`}|##
|
|
162
|
+
`}function ub(e){return e.trim()===""?"":/^\s*(#|\/\/|--|\/\*)/.test(e)?` ${e.trimStart()}`:` ${e}`}function fb(e){const t=(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),n=t.length>40?t.lastIndexOf("_",40):t.length,r=t.slice(0,n>0?n:40);return/^[a-z]/.test(r)&&ye.isBareName(r)?r:void 0}async function hb(e){const t=await lb(e);if(sb(t))return{ok:!1,refused:t.refused,line:t.line};const{header:n,cells:r}=t.source,s=($,j)=>({ok:!1,refused:`Line ${$+1}: ${j}`,line:$+1}),i=e.slice(n.start,n.end).split(`
|
|
163
|
+
`),o=ye.artifactTag(i);if(o&&!ye.artifactLeads(o.text))return s(o.from,ye.ARTIFACT_NOT_FIRST);if(!o||Aa(o.text))return s(Math.max(o?.from??0,0),"this notebook already lists its tiles, so there is nothing to convert.");const l=(await mi(e,"file:///publisher-notebook-builder/convert.malloy")).parse?.tokenStream,u=l?.tokenSource?.vocabulary,c=l?.getTokens?.()??[];if(typeof u?.getSymbolicName!="function")return s(0,"Malloy's token stream is not available.");const d=await L.loadMalloy(),{parseAnnotation:f}=await L.loadMalloyTag(),p=$=>u.getSymbolicName($.type),m=new Ca(e),g=Da(m,l),x=$=>e.slice(m.utf16($.startIndex),m.utf16($.stopIndex+1)),k=$=>d.routeOf({value:$.trimStart()}),b=$=>d.payloadOf({value:$}),h=$=>$.replace(/\r\n?/g,`
|
|
164
|
+
`),y=new Set(e.match(/[A-Za-z_][A-Za-z0-9_]*/g)),w=$=>{let j=$;for(let z=2;y.has(j);z++)j=`${$}_${z}`;return y.add(j),j},D=$=>{const j=c.filter(re=>re.channel===0&&m.utf16(re.startIndex)>=$.span.start&&m.utf16(re.stopIndex+1)<=$.span.end),z=[],X=[],ie=[];let Z;for(let re=0;re<j.length;re++){const ve=p(j[re]);if(ve!=="ANNOTATION"&&ve!=="BLOCK_ANNOTATION_BEGIN"){Z=j[re];break}let de=re;const Ae=[];if(ve==="BLOCK_ANNOTATION_BEGIN"){for(;p(j[de+1]??j[re])==="BLOCK_ANNOTATION_TEXT";)Ae.push(x(j[++de]));p(j[de+1]??j[re])==="BLOCK_ANNOTATION_END"&&de++}const We=h(x(j[re])),P=k(We),K=m.utf16(j[re].startIndex),ne=m.lineStarts[m.line(K)],fe={start:/^[ \t]*$/.test(e.slice(ne,K))?ne:K,end:m.utf16(j[de].stopIndex+1)};P==="markdown"?z.push(fe):P==='"'&&(X.push(fe),ie.push(ve==="ANNOTATION"?h(b(We)).replace(/\n$/,"").trim():[h(b(We.split(`
|
|
165
|
+
`,1)[0])),...Ae.map(h)].map(Re=>Re.trim()).filter(Boolean).join(" "))),re=de}if(!Z)return;const le=m.utf16(Z.startIndex),me=e.slice($.span.start,$.span.end);return{cell:$,above:Vl(e.slice($.span.start,le),$.span.start,($.kind==="query"?[...z,...X]:z).filter(re=>re.end<=le)),statement:e.slice(le,$.span.end).trimEnd(),kept:Vl(me,$.span.start,z),...$.kind==="query"&&ie.length>0&&{caption:ie.join(" ")},line:m.line(le)}},T=new Map,A=new Map;for(const[$,j]of r.entries()){if(j.kind==="markdown")continue;const z=D(j);if(!z)return s(m.line(j.span.start),"a cell with no statement the converter can place.");A.set($,z);const X=ql.exec(z.statement);j.kind==="definition"&&X&&T.set(X[1],{expression:z.statement.slice(X[0].length).trim(),cell:$})}const I=$=>{const j=/^run\s*:\s*/.exec($.statement);if(!j)return s($.line,"a run that is not `run: <query>`.");let z=$.statement.slice(j[0].length).trim();const X=[];for(let re=0;re<10;re++){const ve=Wi(z),de=/^[A-Za-z_][A-Za-z0-9_]*/.exec(ve)?.[0],Ae=de?T.get(de):void 0;if(!de||!Ae)break;const We=z.slice(de.length).trim(),P=ve.slice(de.length).trim();if(P!==""&&!P.startsWith("->")&&!P.startsWith("+"))break;if(P.startsWith("+")&&Ul(Wi(Ae.expression)).length!==1)return s($.line,`\`${de} + { … }\` refines a query with more than one stage, which cannot become one view.`);X.push(de);const K=/(\/\/|--)[^\n]*$/.test(Ae.expression)?`
|
|
166
|
+
`:" ";z=`${Ae.expression}${We===""?"":`${K}${We}`}`}const ie=Wi(z);if(T.has(/^[A-Za-z_][A-Za-z0-9_]*/.exec(ie)?.[0]??""))return s($.line,"this run names a query defined through more than 10 other queries, which the converter does not follow.");const Z=Ul(ie);if(Z.length===0)return s($.line,"this run is not `source -> view`, so it cannot become a tile. Fix: write it as `run: <source> -> <view>`.");const le=z.slice(0,Z[0]).trim();if(/\bextend\b/.test(ie.slice(0,Z[0])))return s($.line,"this run extends its source inline before `->`, so it cannot become a tile. Fix: declare the extension with a `source:` statement and run that.");if(!db.test(le)&&!/^`[^`]+`$/.test(le))return s($.line,"the source of this run is not a name, so it cannot become a tile. Fix: name it with a `source:` statement and run that.");const me=z.slice(Z[0]+2).trim();return me===""?s($.line,"this run has nothing after `->`."):{source:le,body:me,used:X}},C=new Map,W=[],F=new Set,G=new Map;let J=0,Q=0;const se=new Map;for(const $ of A.values()){if($.cell.kind!=="query")continue;const j=I($);if("ok"in j)return j;for(const z of j.used)se.set(z,(se.get(z)??0)+1)}const ce=$=>se.get($)===1&&(e.match(new RegExp(`\\b${$}\\b`,"g"))??[]).length===2,te=new Map;for(const[$,j]of r.entries()){if(j.kind==="markdown"){const P=w(`text_${++J}`);W.push(`${P} { kind=text }`);const K=g.all.filter(ne=>ne.start>=j.span.start&&ne.end<=j.span.end).map(ne=>`${e.slice(ne.start,ne.end)}
|
|
167
|
+
`).join("");G.set($,K+Kl(P,j.markdown??""));continue}const z=A.get($);let X="";if(j.markdown!==void 0){const P=w(`text_${++J}`);W.push(`${P} { kind=text }`),X=`${Kl(P,j.markdown)}
|
|
168
|
+
`}if(j.kind==="definition"){const P=ql.exec(z.statement)?.[1];if(P&&ce(P)){F.add($),te.set(P,z.above.split(`
|
|
169
|
+
`).filter(K=>K.trim()!=="")),X&&G.set($,X.replace(/\n$/,""));continue}G.set($,`${X}${z.kept}`);continue}const ie=I(z),Z=ie.source.replace(/`/g,"").replace(/[^A-Za-z0-9_]+/g,"_").replace(/^(?=[0-9])/,"_");let le=C.get(ie.source);le||(le={name:w(`${Z}_tiles`),base:ie.source,views:[]},C.set(ie.source,le));const me=[...ie.used.flatMap(P=>te.get(P)??[]),...z.above.split(`
|
|
170
|
+
`)].filter(P=>P.trim()!==""),re=me.filter(P=>/^\s*#(?!["(|])/.test(P)),ve=re.length>0?Su(f,re).tag:void 0,de=w(fb(ve?.text("label")??z.caption)??`tile_${Q+1}`);Q++,W.push(`"${le.name} -> ${de}"`);const Ae=me.map(ub);if(z.caption!==void 0){const P=L.annotationTextProblem("caption",z.caption)===void 0;P&&!ve?.has("label")?Ae.push(` # label=${Gl(z.caption)}`):P&&!ve?.has("subtitle")?Ae.push(` # subtitle=${Gl(z.caption)}`):Ae.push(` #" ${z.caption}`)}const We=ie.body.split(`
|
|
171
|
+
`).map((P,K)=>K===0||P.trim()===""?P:` ${P}`).join(`
|
|
172
|
+
`);le.views.push([...Ae,` view: ${de} is ${We}`].join(`
|
|
173
|
+
`)),F.add($),X&&G.set($,X.replace(/\n$/,""))}const ue=(()=>{let $=0;const j=o.text;for(let z=j.indexOf("{");z<j.length;z++)if(j[z]==='"')for(z++;z<j.length&&j[z]!=='"';z++)j[z]==="\\"&&z++;else if(j[z]==="{")$++;else if(j[z]==="}"&&--$===0)return z;return-1})();if(ue<0)return s(o.from,"the `## artifact { … }` tag never closes.");const E=W.length===0?`
|
|
174
|
+
tiles=[]
|
|
175
|
+
`:`
|
|
176
|
+
tiles=[
|
|
177
|
+
${W.map($=>` ${$}`).join(`,
|
|
178
|
+
`)}
|
|
179
|
+
]
|
|
180
|
+
`,U=`${o.text.slice(0,ue).trimEnd().replace(/^##(?!\|)/,"##|")}${E}${o.text.slice(ue)}`;i.splice(o.from,o.block?o.to-o.from:1,...(o.block?U:`${U}
|
|
181
|
+
|##`).split(`
|
|
182
|
+
`));const B=$=>{const j=$.text.split(`
|
|
183
|
+
`),z=j.pop(),X=[];let ie=0;for(const Z of j){const le=$.at[ie]??-1,me=g.all.some(re=>le>=re.start&&le<re.end);(Z.trim()!==""||X.at(-1)?.trim()!==""||me)&&X.push(Z),ie+=Z.length+1}return X.map(Z=>`${Z}
|
|
184
|
+
`).join("")+z},R={text:"",at:[]},q=($,j)=>{R.text+=e.slice($,j);for(let z=$;z<j;z++)R.at.push(z)};let N=i.join(`
|
|
185
|
+
`),Y=n.end;for(const[$,j]of r.entries()){q(Y,j.span.start),Y=j.span.end;const z=G.get($);z!==void 0&&(N+=B(R)+(z.endsWith(`
|
|
186
|
+
`)?z:`${z}
|
|
187
|
+
`),R.text="",R.at=[])}q(Y,e.length),N=`${N.trimEnd()}
|
|
188
|
+
`+(R.text.trim()===""?"":B(R)),N=`${N.trimEnd()}
|
|
189
|
+
`;const V=[...C.values()].map($=>`source: ${$.name} is ${$.base} extend {
|
|
190
|
+
${$.views.join(`
|
|
191
|
+
|
|
192
|
+
`)}
|
|
193
|
+
}
|
|
194
|
+
`);return V.length>0&&(N+=`
|
|
195
|
+
${V.join(`
|
|
196
|
+
`)}`),e.includes(`\r
|
|
197
|
+
`)&&(N=N.replace(/\r?\n/g,`\r
|
|
198
|
+
`)),{ok:!0,text:N,tiles:W.length}}const Bi=(e,t)=>t!==void 0&&!/\bline \d+/i.test(e)?`${e} (line ${t})`:e;async function pb(e,t){const n=await Kr(e,t);if(!Vr(n))return{ok:!0,document:n.document};if(!n.legacyNotebook)return{ok:!1,reason:Bi(n.reason,n.line)};const r=await hb(e);if(cb(r))return{ok:!1,reason:Bi(r.refused,r.line)};const s=await Kr(r.text,t);return Vr(s)?{ok:!1,reason:`The converted notebook cannot be opened: ${Bi(s.reason,s.line)}`}:{ok:!0,document:s.document,conversion:{from:e,to:r.text}}}const Hl="a .malloynb notebook is read, not edited. Fix: rewrite it as a `.malloy` notebook under notebooks/ to edit it here.",Yl="the server did not send this notebook's text, so there is nothing here to edit. Fix: edit the file in the package.";function nf(e){const{onExit:t,onEvent:n,onDirtyChange:r,kind:s="dashboard",path:i}=e,o=s==="notebook",{environmentName:a,packageName:l,versionId:u,namesBoth:c}=L.resolveEditorTarget(e),d="resourceUri"in e?e.dashboard:e.dashboardName,f=o?"notebook":"dashboard",p=o?"notebook.open_refused":"dashboard.open_refused",{apiClients:m,mutable:g,isLoadingStatus:x}=Ye.useServer(),k=af.useQueryClient(),b=_.useRef(L.now()),h=_.useRef(n);h.current=n;const y=_.useRef(r);y.current=r;const w=L.useOptionalDocumentStorage()?.documentStorage,D=o&&/\.malloynb$/i.test(d),T=i??`${s}s/${d}.malloy`,A=L.useQueryWithApiError({queryKey:["dashboard-editor-model",a,l,T,u,o],queryFn:()=>m.models.getModel(a,l,T,u,o?!0:void 0),enabled:c&&!D}),I=A.data?.data?.sourceText,[C,W]=_.useState(void 0),[F,G]=_.useState(void 0),[J,Q]=_.useState(w===void 0),[se,ce]=_.useState(!1),[te,ue]=_.useState(void 0);_.useEffect(()=>{if(!w)return;let xe=!1;return ue(void 0),(async()=>{try{const qe=L.chooseWorkspace(await w.listWorkspaces(!1));if(xe)return;if(W(qe),qe!==void 0&&(!o||qe.authoritative)){const nn=await w.getDocument(L.locatorFor(s,qe.name,a,l,T)).catch(Ge=>{if(!L.isDocumentNotFound(Ge))throw Ge});if(xe)return;G(nn),ce(nn!==void 0)}}catch(qe){if(xe)return;ue(L.storageErrorMessage(qe))}xe||Q(!0)})(),()=>{xe=!0}},[w,s,o,a,l,T]);const E=C?.authoritative===!0,U=E&&te!==void 0,[B,R]=_.useState(void 0),q=(E||B===!0)&&F!==void 0,[N,Y]=_.useState(void 0),[V,$]=_.useState(D?Hl:void 0),j=_.useRef(void 0),z=_.useRef(void 0),[X,ie]=_.useState(void 0),Z=A.dataUpdatedAt,le=_.useRef(Z);le.current=Z;const me=X!==void 0&&X.onFetch===Z?X.text:I,re=_.useRef(me);re.current=me;const ve=q?F:me,[de,Ae]=_.useState(!1),[We,P]=_.useState(!1),[K,ne]=_.useState(void 0),[fe,Re]=_.useState(void 0),Et=ve!==void 0&&ve!==fe,Be=N?.source,Ft=Et&&(de||We)&&Be!==void 0&&ve!==K,at=Ft?Be:Et?ve:Be??ve,Ct=Ft?ve:void 0,Zt=_.useRef(Be);Zt.current=Be;const zt=_.useRef(ve);zt.current=ve;const It=_.useRef("package");It.current=q?E?"record":"draft":"package",_.useEffect(()=>{if(at===void 0||!J||U||at===Zt.current)return;let xe=!1;const qe=re.current,nn=zt.current;return pb(at,T).then(Ge=>{if(!xe){if(Ge.ok===!1){$(Ge.reason),h.current?.({type:p,reason:Ge.reason});return}$(void 0),j.current=void 0,z.current=qe,ie(void 0),ne(void 0),Re(nn),Y(wt=>({source:at,document:Ge.document,...Ge.conversion?{conversion:Ge.conversion}:{},...qe!==void 0?{packageText:qe}:{},generation:(wt?.generation??0)+1})),h.current?.(o||Ge.document.kind==="notebook"?{type:"notebook.opened",from:It.current==="package"?"package":"record",cells:Ge.document.tiles.length,durationMs:L.now()-b.current}:{type:"dashboard.opened",from:It.current,tiles:Ge.document.tiles.length,durationMs:L.now()-b.current})}}).catch(Ge=>{if(xe)return;const wt=`Could not read the ${f}: ${Ge instanceof Error?Ge.message:String(Ge)}`;$(wt),h.current?.({type:p,reason:wt})}),()=>{xe=!0}},[at,T,J,U,o,f,p]),_.useEffect(()=>{D&&h.current?.({type:"notebook.open_refused",reason:Hl})},[D]);const Qt=o&&!N&&J&&!q&&A.isSuccess&&!A.isFetching&&I===void 0;_.useEffect(()=>{Qt&&($(Yl),h.current?.({type:"notebook.open_refused",reason:Yl}))},[Qt]);const lt=C===void 0?void 0:L.locatorFor(s,C.name,a,l,T),ir=_.useCallback(async xe=>{if(!w||!lt)throw new Error("This host keeps no documents, so there is nowhere to save.");await w.saveDocument(lt,xe),Y(qe=>qe&&{...qe,source:xe}),G(xe),(E||B===!0)&&Re(xe),E||R(qe=>qe??!1)},[w,lt,E,B]),[Dt,Jt]=_.useState(void 0),en=_.useCallback(async xe=>{const qe=await L.expectedHashFor(j.current,z.current);if(qe===void 0)throw new Error("The package file is still loading; try again.");const nn=["dashboard-editor-model",a,l,T,u,o];await L.writePackageFile({apiClients:m,queryClient:k,environmentName:a,packageName:l,modelPath:T,source:xe,expectedHash:qe,invalidateOnError:[nn],afterWrite:async Ge=>{if(Y(wt=>wt&&{...wt,source:xe}),ie({text:xe,onFetch:le.current}),Re(xe),j.current=Ge,Jt(void 0),w&<)try{await w.deleteDocument(lt),G(void 0),ce(!1)}catch(wt){L.isDocumentNotFound(wt)?(G(void 0),ce(!1)):Jt(L.storageErrorMessage(wt))}R(!1)},invalidate:[{queryKey:nn,wait:!0},{queryKey:L.modelResultsKey({environmentName:a,packageName:l,versionId:u,modelPath:T})},{queryKey:["dashboard-editor-manifest"]},{queryKey:["dashboards"]},{queryKey:["dashboard"]},...o?[{queryKey:[L.encodeResourceUri({environmentName:a,packageName:l,modelPath:T})]}]:[]]})},[m,a,l,T,u,o,w,lt,k]),or=C?.writeable===!0,O=g===!0,{savesTo:M,pinnedPackageSave:H,writer:ee}=L.saveTarget({authoritative:E,mutable:O,...u!==void 0?{versionId:u}:{},canStore:!!w&&!!lt&&or&&(!o||E),readFailed:te!==void 0}),Ee=ee==="storage"?ir:ee==="package"?en:void 0,_e=C?.name,Se=_.useCallback(xe=>{h.current?.(L.withWorkspace(xe,_e))},[_e]),mt=_.useCallback(xe=>{Ae(xe),y.current?.(xe)},[]),as=xe=>{b.current=L.now(),ne(xe?F:me),R(xe)},ar=()=>{b.current=L.now(),ne(Ct)},At=M==="host"&&C?.description?C.description:void 0,lr=!E&&g===void 0?x?"Checking whether this server takes writes.":"This server did not say whether it takes writes, so Save is off.":L.saveCaption({authoritative:E,mutable:O,pinnedPackageSave:H,...C?{workspace:C}:{},...te!==void 0?{readFailure:te}:{},...u!==void 0?{versionId:u}:{}}),tn=lr===At?"":lr;if(!c&&"resourceUri"in e)return v.jsxs(S.Alert,{severity:"error",sx:{m:2},children:["A ",f," resource URI must name an environment and a package. Received: ",e.resourceUri]});if(V)return v.jsxs(S.Alert,{severity:"error",sx:{m:2},children:["This ",f," cannot be opened in the builder: ",V]});if(A.isError&&!N)return v.jsx(L.ApiErrorDisplay,{error:A.error,context:`Opening the ${f}`});if(!N&&(!I||!J))return v.jsxs(S.Stack,{sx:{gap:2},children:[v.jsx(L.DashboardBar,{}),v.jsx(L.Loading,{text:`Opening the ${f}…`})]});if(U)return v.jsxs(S.Alert,{severity:"error",sx:{m:2},children:["This ",f," cannot be opened: ",te]});const rf=F!==void 0&&F!==I;return v.jsxs(S.Stack,{sx:{gap:2},children:[A.isError&&v.jsxs(S.Alert,{severity:"warning",children:["The ",f," could not be re-read from the server:"," ",A.error?.message,". Your edits are still here."]}),!o&&!E&&se&&rf&&B===void 0&&v.jsx(S.Alert,{severity:"info",action:v.jsxs(S.Stack,{direction:"row",sx:{gap:1},children:[v.jsx(S.Button,{size:"small",onClick:()=>as(!0),children:"Resume"}),v.jsx(S.Button,{size:"small",onClick:()=>as(!1),children:"Start from the package"})]}),children:"You have edits to this dashboard saved in this browser that the package does not have."}),Ct!==void 0&&v.jsx(S.Alert,{severity:"warning",action:v.jsx(S.Button,{size:"small",onClick:ar,children:"Load it"}),children:de?M==="package"?"This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and until you do, saving is refused.":M==="host"?"This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and saving keeps yours and writes over it.":"The package's copy of this dashboard changed since you opened it. Your edits are still here; loading the new version replaces them.":"This dashboard changed since you opened it. Loading the new version drops Undo save."}),Dt!==void 0&&v.jsxs(S.Alert,{severity:"warning",children:["The file was saved into the package, but the copy kept beside it could not be cleared, so it will be offered again:"," ",Dt]}),N&&v.jsx(gb,{kind:s,environmentName:a,packageName:l,modelPath:T,slug:d,modelGivens:A.data?.data?.givens,...u!==void 0?{versionId:u}:{},opened:N,...q&&ee==="package"&&N.packageText!==void 0?{replaces:N.packageText}:{},onSave:Ee,onDirtyChange:mt,onSaveNoticeChange:P,savesTo:M,...At?{saveLabel:At}:{},...n?{onEvent:Se}:{},...t?{onExit:t}:{},note:tn},N.generation)]})}function gb({kind:e,modelGivens:t,environmentName:n,packageName:r,modelPath:s,slug:i,versionId:o,opened:a,replaces:l,onSave:u,onDirtyChange:c,onSaveNoticeChange:d,onEvent:f,savesTo:p,saveLabel:m,onExit:g,note:x}){const{apiClients:k}=Ye.useServer(),b=e==="notebook",[h,y]=_.useState(a.document.tiles.length>0);_.useEffect(()=>y(a.document.tiles.length>0),[a.generation,a.document]);const{data:w,isSuccess:D,isError:T}=L.useQueryWithApiError({queryKey:["dashboard-editor-manifest",n,r,i,o,e],queryFn:async()=>{if(!b)return(await k.dashboards.getDashboard(n,r,i,o)).data;const N=(await k.notebooks.getNotebook(n,r,s,o)).data;return N.dashboard??{...N.startingGivens?{startingGivens:N.startingGivens}:{},...N.autorun===void 0?{}:{autorun:N.autorun}}},enabled:h}),A=w,{data:I}=L.useQueryWithApiError({queryKey:["dashboards",n,r,o],staleTime:6e4,queryFn:()=>k.dashboards.listDashboards(n,r,o),enabled:!b}),C=_.useMemo(()=>(I?.data??[]).map(N=>N.name).filter(N=>!!N&&N!==i),[I,i]),W=_.useMemo(()=>{const N=s.slice(0,s.lastIndexOf("/")+1);return a.document.imports.map(Y=>({...Y,path:new URL(Y.from,`https://malloy.invalid/${N}`).pathname.slice(1)}))},[a.document.imports,s]),{data:F}=L.useQueryWithApiError({queryKey:["dashboard-editor-catalog",n,r,...W.map(N=>N.path),o],queryFn:async()=>{const N=(await k.models.listModels(n,r,o)).data.filter($=>$.path&&!$.error&&!Lu($.path)&&!$.path.startsWith("notebooks/")),V=(await Promise.allSettled(N.map($=>k.models.getModel(n,r,$.path,o).then(j=>j.data)))).flatMap($=>$.status==="fulfilled"?[$.value]:[]);return Sm(Fu(V),W,V)},enabled:W.length>0}),[G,J]=_.useState(a.document);_.useEffect(()=>J(a.document),[a.document]);const Q=_.useMemo(()=>u&&p==="package"?async(N,Y)=>{await u(N),y(Y.document.tiles.length>0)}:u,[u,p]),se=_.useMemo(()=>A?.givens??(a.conversion?t??[]:[]),[A,a.conversion,t]),ce=_.useMemo(()=>new Set(se.map(N=>N.name).filter(N=>N!==void 0)),[se]),te=_.useMemo(()=>eb(G,se),[G,se]),{declaredTypes:ue,applied:E,panel:U}=L.useDocumentControls({specs:te,loaded:D,startingValues:A?.startingGivens,documentKey:`${n}/${r}/${o??""}/${b?"notebook/":""}${i}/edit`,autorun:A?.autorun!==!1,environmentName:n,packageName:r,modelPath:A?.path,versionId:o,documentName:i}),B=!h||D||T,R=_.useMemo(()=>new Map((A?.tiles??[]).flatMap(N=>N.kind!=="text"&&N.query&&N.givenNames?[[Bl(N.query),N.givenNames]]:[])),[A]),q=_.useMemo(()=>function(Y,V){if(!B)return v.jsx(L.Loading,{text:"Running…"});const $=rb(G,Y,ce,E,R.get(Bl(`${Y.source} -> ${Y.name}`)));return v.jsx(L.DashboardTile,{environmentName:n,packageName:r,versionId:o,modelPath:s,tile:$.expression,...$.annotation?{annotation:$.annotation}:{},label:Y.label??L.tileTitle(`${Y.source} -> ${Y.name}`),subtitle:Y.subtitle,...V?{heading:V}:{},borderless:Y.borderless,givens:E,declaredTypes:ue,givenNames:$.givenNames,ignoredFilters:L.tileIgnoredFilterLabels($.reads,te),height:L.TILE_MAX_HEIGHT})},[G,B,ce,R,n,r,o,s,E,ue,te]);return v.jsxs(S.Stack,{sx:{gap:1},children:[v.jsx(tf,{source:a.source,document:a.document,renderTile:q,givens:te.filter(N=>N.name!==void 0).map(N=>({name:N.name,...N.label?{label:N.label}:{},...N.type?{type:N.type}:{},...N.suggest?.dimension?{field:N.suggest.dimension}:{}})),onChange:J,onDirtyChange:c,onSaveNoticeChange:d,...a.conversion?{conversion:a.conversion}:{},...F?{catalog:F}:{},dashboards:C,...f?{onEvent:f}:{},...g?{onExit:g}:{},controls:D?v.jsx(L.GivensPanel,{...U,layout:"bar"}):void 0,...Q?{onSave:Q}:{},savesTo:p,...m?{saveLabel:m}:{},...l!==void 0?{replaces:l}:{},modelPath:s}),v.jsx(S.Box,{sx:{px:.5},children:v.jsx(S.Typography,{variant:"caption",sx:{opacity:.7},children:x})})]})}function mb(e){const{onExit:t,onEvent:n,onDirtyChange:r,path:s}=e,i="resourceUri"in e?{resourceUri:e.resourceUri,dashboard:e.notebook}:{environmentName:e.environmentName,packageName:e.packageName,dashboardName:e.notebookName};return v.jsx(nf,{...i,kind:"notebook",...t?{onExit:t}:{},...n?{onEvent:n}:{},...r?{onDirtyChange:r}:{},...s!==void 0?{path:s}:{}})}typeof globalThis.process>"u"?globalThis.process={env:{}}:globalThis.process.env===void 0&&(globalThis.process.env={});exports.MAX_SLUG_ATTEMPTS=L.MAX_SLUG_ATTEMPTS;exports.createDocument=L.createDocument;exports.createRoute=L.createRoute;exports.documentPathFor=L.documentPathFor;exports.documentPathForTitle=L.documentPathForTitle;exports.locatorFor=L.locatorFor;exports.newDashboardSource=L.newDashboardSource;exports.newDocumentProblem=L.newDocumentProblem;exports.newNotebookSource=L.newNotebookSource;exports.slugFor=L.slugFor;exports.slugOrFallback=L.slugOrFallback;exports.useDocumentChoices=L.useDocumentChoices;exports.DashboardBuilder=tf;exports.DashboardEditor=nf;exports.NotebookEditor=mb;exports.buildCatalog=Fu;exports.readDashboardDocument=Kr;exports.readFailed=Vr;exports.spliceDashboardDocument=ju;exports.spliceFailed=ei;
|