@malloy-publisher/sdk 0.9.2 → 0.9.4
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/{RenderedResult-CBLHr32C.es.js → RenderedResult-DwB0-9Yx.es.js} +118 -119
- package/dist/{RenderedResult-B48wAjM8.cjs.js → RenderedResult-hKjFEqaN.cjs.js} +2 -2
- package/dist/{ServerProvider-DCV8BUWD.es.js → ServerProvider-CcSrGaRN.es.js} +1281 -1142
- package/dist/ServerProvider-Gbf1YPOP.cjs.js +1 -0
- package/dist/builder/index.cjs.js +112 -115
- package/dist/builder/index.es.js +11766 -11502
- package/dist/builder-entry.d.ts +1 -1
- package/dist/client/api.d.ts +170 -9
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +93 -89
- package/dist/client-entry.d.ts +2 -0
- package/dist/components/ApiErrorDisplay.d.ts +11 -0
- package/dist/components/AppDialog.d.ts +6 -6
- package/dist/components/Dashboard/DashboardGrid.d.ts +18 -3
- package/dist/components/Dashboard/DashboardTile.d.ts +12 -2
- package/dist/components/Dashboard/DashboardView.d.ts +38 -3
- package/dist/components/Dashboard/TileCard.d.ts +16 -2
- package/dist/components/Dashboard/dropValueUrlTags.d.ts +6 -0
- package/dist/components/Dashboard/index.d.ts +3 -2
- package/dist/components/Dashboard/telemetry.d.ts +2 -1
- package/dist/components/Dashboard/textSource.d.ts +19 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +7 -8
- package/dist/components/DashboardBuilder/BuilderDialogs.d.ts +25 -0
- package/dist/components/DashboardBuilder/BuilderGrid.d.ts +31 -0
- package/dist/components/DashboardBuilder/BuilderHeader.d.ts +17 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +14 -17
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +3 -1
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +15 -7
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +28 -2
- package/dist/components/DashboardBuilder/EditorSurface.d.ts +33 -0
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +6 -4
- package/dist/components/DashboardBuilder/InlineText.d.ts +1 -1
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +1 -1
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +4 -1
- package/dist/components/DashboardBuilder/TileFrame.d.ts +43 -6
- package/dist/components/DashboardBuilder/TileMenu.d.ts +6 -8
- package/dist/components/DashboardBuilder/builderReport.d.ts +13 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +0 -18
- package/dist/components/DashboardBuilder/documentSession.d.ts +2 -2
- package/dist/components/DashboardBuilder/imports.d.ts +19 -0
- package/dist/components/DashboardBuilder/inlineEdit.d.ts +18 -0
- package/dist/components/DashboardBuilder/readDocument.d.ts +3 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +1 -1
- package/dist/components/DashboardBuilder/sortable.d.ts +2 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +2 -0
- package/dist/components/DashboardBuilder/testing/resize.d.ts +7 -0
- package/dist/components/DashboardBuilder/tileDisplayTitle.d.ts +7 -0
- package/dist/components/DashboardBuilder/useBuilderSelection.d.ts +53 -0
- package/dist/components/DashboardBuilder/useBuilderSession.d.ts +4 -7
- package/dist/components/DashboardBuilder/useControlBindings.d.ts +30 -0
- package/dist/components/DashboardBuilder/useConversionConfirm.d.ts +20 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +2 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +3 -1
- package/dist/components/DashboardBuilder/useHostCopy.d.ts +26 -0
- package/dist/components/DashboardBuilder/useOpenDraftCommit.d.ts +17 -0
- package/dist/components/DashboardBuilder/useOpenedDocument.d.ts +71 -0
- package/dist/components/DashboardBuilder/useSaveChannel.d.ts +50 -0
- package/dist/components/DashboardBuilder/useTileEditing.d.ts +33 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +32 -0
- package/dist/components/Loading.d.ts +13 -0
- package/dist/components/Notebook/NotebookCell.d.ts +1 -5
- package/dist/components/Package/Package.d.ts +16 -1
- package/dist/components/Package/index.d.ts +1 -1
- package/dist/components/Prose.d.ts +1 -1
- package/dist/components/RenderedResult/loadRenderer.d.ts +7 -0
- package/dist/components/given/paramCodec.d.ts +8 -1
- package/dist/components/index.d.ts +1 -2
- package/dist/components/styles.d.ts +4 -4
- package/dist/hooks/givenValue.d.ts +6 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useCompiledDocument.d.ts +23 -0
- package/dist/hooks/useDocumentControls.d.ts +6 -1
- package/dist/hooks/useNearViewport.d.ts +16 -0
- package/dist/hooks/useQueryWithApiError.d.ts +7 -2
- package/dist/hooks/useSuggestOptions.d.ts +9 -2
- package/dist/index.cjs.js +14 -14
- package/dist/index.es.js +9760 -10363
- package/dist/text/index.es.js +1 -1
- package/dist/{text-entry-CbbBcZl8.es.js → text-entry-CA0LZ1xL.es.js} +8 -8
- package/dist/text-entry.d.ts +1 -1
- package/dist/theme/accent.d.ts +29 -0
- package/dist/theme/buildVegaThemeOverride.d.ts +3 -3
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/keys.d.ts +1 -1
- package/dist/theme/motion.d.ts +31 -0
- package/dist/theme/readChartAnnotations.d.ts +1 -1
- package/dist/theme/resolveTheme.d.ts +4 -4
- package/dist/theme/types.d.ts +33 -5
- package/dist/{DashboardTile-BFcxdv7R.es.js → useCompiledDocument-BU6d8FPp.es.js} +6978 -6289
- package/dist/useCompiledDocument-pOg2W-Yt.cjs.js +142 -0
- package/package.json +11 -11
- package/src/builder-entry.ts +1 -0
- package/src/client-entry.ts +8 -0
- package/src/clientEntry.spec.ts +17 -0
- package/src/components/ApiErrorDisplay.tsx +37 -18
- package/src/components/AppDialog.tsx +8 -7
- package/src/components/Dashboard/Dashboard.spec.tsx +3 -32
- package/src/components/Dashboard/Dashboard.tsx +2 -2
- package/src/components/Dashboard/DashboardGrid.tsx +23 -5
- package/src/components/Dashboard/DashboardTile.spec.tsx +97 -2
- package/src/components/Dashboard/DashboardTile.tsx +95 -31
- package/src/components/Dashboard/DashboardView.spec.tsx +156 -0
- package/src/components/Dashboard/DashboardView.tsx +165 -89
- package/src/components/Dashboard/RowsDialog.tsx +3 -2
- package/src/components/Dashboard/TileCard.tsx +17 -2
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +177 -0
- package/src/components/Dashboard/dropValueUrlTags.ts +108 -0
- package/src/components/Dashboard/index.ts +11 -2
- package/src/components/Dashboard/telemetry.ts +2 -1
- package/src/components/Dashboard/textSource.spec.ts +36 -0
- package/src/components/Dashboard/textSource.ts +39 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +16 -56
- package/src/components/DashboardBuilder/BuilderDialogs.tsx +162 -0
- package/src/components/DashboardBuilder/BuilderGrid.tsx +245 -0
- package/src/components/DashboardBuilder/BuilderHeader.tsx +107 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +86 -113
- package/src/components/DashboardBuilder/ChartPicker.tsx +4 -1
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +5 -5
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +74 -83
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +62 -18
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +55 -108
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +10 -62
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +50 -57
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +53 -40
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +10 -8
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +227 -704
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +32 -52
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +1 -50
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +12 -18
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +4 -24
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +4 -4
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +8 -13
- package/src/components/DashboardBuilder/DashboardEditor.textSource.spec.tsx +317 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +142 -820
- package/src/components/DashboardBuilder/DrillDialog.tsx +2 -2
- package/src/components/DashboardBuilder/EditorSurface.tsx +471 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +13 -8
- package/src/components/DashboardBuilder/FilterStrip.tsx +117 -79
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +7 -9
- package/src/components/DashboardBuilder/InlineText.tsx +23 -17
- package/src/components/DashboardBuilder/NotebookEditor.tsx +3 -3
- package/src/components/DashboardBuilder/TextTileBody.tsx +5 -2
- package/src/components/DashboardBuilder/TileFrame.tsx +255 -90
- package/src/components/DashboardBuilder/TileMenu.tsx +41 -91
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +1 -1
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +9 -4
- package/src/components/DashboardBuilder/builderReport.ts +74 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +0 -44
- package/src/components/DashboardBuilder/catalog.ts +0 -36
- package/src/components/DashboardBuilder/controls.spec.ts +1 -1
- package/src/components/DashboardBuilder/controls.ts +1 -1
- package/src/components/DashboardBuilder/documentSession.ts +3 -2
- package/src/components/DashboardBuilder/imports.spec.ts +61 -0
- package/src/components/DashboardBuilder/imports.ts +93 -0
- package/src/components/DashboardBuilder/inlineEdit.tsx +78 -0
- package/src/components/DashboardBuilder/legacyNotebook.ts +1 -1
- package/src/components/DashboardBuilder/malloyTree.ts +5 -1
- package/src/components/DashboardBuilder/newDashboard.ts +1 -1
- package/src/components/DashboardBuilder/preview.ts +1 -1
- package/src/components/DashboardBuilder/readDocument.spec.ts +36 -0
- package/src/components/DashboardBuilder/readDocument.ts +10 -4
- package/src/components/DashboardBuilder/readForEditor.ts +7 -2
- package/src/components/DashboardBuilder/sortable.spec.ts +25 -1
- package/src/components/DashboardBuilder/sortable.tsx +11 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +8 -3
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +62 -6
- package/src/components/DashboardBuilder/testing/documentKindRule.json +40 -0
- package/src/components/DashboardBuilder/testing/inline.ts +1 -1
- package/src/components/DashboardBuilder/testing/resize.ts +48 -0
- package/src/components/DashboardBuilder/testing/urlRenderTags.json +62 -0
- package/src/components/DashboardBuilder/textTiles.spec.ts +43 -1
- package/src/components/DashboardBuilder/tileDisplayTitle.ts +13 -0
- package/src/components/DashboardBuilder/useBuilderSelection.ts +121 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +0 -85
- package/src/components/DashboardBuilder/useBuilderSession.ts +6 -43
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +32 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +11 -1
- package/src/components/DashboardBuilder/useControlBindings.ts +152 -0
- package/src/components/DashboardBuilder/useConversionConfirm.ts +55 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +5 -2
- package/src/components/DashboardBuilder/useDraft.ts +15 -2
- package/src/components/DashboardBuilder/useHostCopy.ts +104 -0
- package/src/components/DashboardBuilder/useOpenDraftCommit.ts +47 -0
- package/src/components/DashboardBuilder/useOpenedDocument.ts +314 -0
- package/src/components/DashboardBuilder/useSaveChannel.ts +275 -0
- package/src/components/DashboardBuilder/useTileEditing.ts +141 -0
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +146 -0
- package/src/components/DashboardBuilder/useTileResize.ts +133 -0
- package/src/components/DataAppViewer/DataAppViewer.tsx +7 -4
- package/src/components/DocumentCreate/guards.ts +1 -1
- package/src/components/Environment/Environment.tsx +0 -10
- package/src/components/Loading.tsx +14 -0
- package/src/components/Model/Model.tsx +16 -9
- package/src/components/Model/ModelExplorer.tsx +2 -2
- package/src/components/Notebook/Notebook.tsx +6 -2
- package/src/components/Notebook/NotebookCell.tsx +90 -215
- package/src/components/Package/Package.artifacts.spec.tsx +8 -12
- package/src/components/Package/Package.create.spec.tsx +22 -1
- package/src/components/Package/Package.tsx +51 -27
- package/src/components/Package/index.ts +1 -1
- package/src/components/Prose.spec.tsx +37 -0
- package/src/components/Prose.tsx +35 -5
- package/src/components/RenderedResult/RenderedResult.tsx +5 -7
- package/src/components/RenderedResult/ResultContainer.tsx +7 -2
- package/src/components/RenderedResult/ResultPanel.tsx +20 -5
- package/src/components/RenderedResult/loadRenderer.ts +42 -0
- package/src/components/given/GivenInput.spec.tsx +5 -5
- package/src/components/given/GivenInput.tsx +46 -38
- package/src/components/given/GivensPanel.tsx +2 -8
- package/src/components/given/paramCodec.ts +27 -1
- package/src/components/index.ts +1 -2
- package/src/components/styles.ts +4 -5
- package/src/hooks/givenValue.ts +9 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useCompiledDocument.spec.tsx +86 -0
- package/src/hooks/useCompiledDocument.ts +59 -0
- package/src/hooks/useDimensionalFilterRangeData.ts +3 -1
- package/src/hooks/useDocumentControls.ts +13 -1
- package/src/hooks/useNearViewport.spec.tsx +150 -0
- package/src/hooks/useNearViewport.ts +102 -0
- package/src/hooks/useQueryResult.ts +7 -1
- package/src/hooks/useQueryWithApiError.ts +10 -3
- package/src/hooks/useRawQueryData.ts +3 -1
- package/src/hooks/useSuggestOptions.dom.spec.ts +40 -1
- package/src/hooks/useSuggestOptions.ts +42 -10
- package/src/text-entry.ts +1 -1
- package/src/textEntry.spec.ts +2 -8
- package/src/theme/accent.spec.ts +116 -0
- package/src/theme/accent.ts +148 -0
- package/src/theme/buildTableCssVars.spec.ts +24 -0
- package/src/theme/buildTableCssVars.ts +1 -2
- package/src/theme/buildVegaThemeOverride.spec.ts +38 -2
- package/src/theme/buildVegaThemeOverride.ts +5 -5
- package/src/theme/defaults.ts +34 -0
- package/src/theme/index.ts +9 -0
- package/src/theme/keys.ts +6 -0
- package/src/theme/motion.ts +44 -0
- package/src/theme/readChartAnnotations.spec.ts +18 -0
- package/src/theme/readChartAnnotations.ts +1 -1
- package/src/theme/resolveTheme.spec.ts +73 -0
- package/src/theme/resolveTheme.ts +61 -20
- package/src/theme/types.ts +30 -5
- package/src/utils/queryClient.ts +8 -0
- package/dist/DashboardTile-sg8LjUk8.cjs.js +0 -137
- package/dist/ServerProvider-HRqT3w1C.cjs.js +0 -1
- package/dist/components/Dashboard/DashboardBar.d.ts +0 -21
- package/dist/components/Dashboard/ExploreDialog.d.ts +0 -20
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +0 -7
- package/dist/components/DashboardBuilder/SaveNotice.d.ts +0 -27
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +0 -32
- package/dist/components/DashboardBuilder/diff.d.ts +0 -35
- package/src/components/Dashboard/DashboardBar.tsx +0 -88
- package/src/components/Dashboard/ExploreDialog.tsx +0 -89
- package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +0 -194
- package/src/components/DashboardBuilder/DiffDialog.spec.tsx +0 -25
- package/src/components/DashboardBuilder/DiffDialog.tsx +0 -103
- package/src/components/DashboardBuilder/SaveNotice.tsx +0 -113
- package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +0 -87
- package/src/components/DashboardBuilder/SettingsPopover.tsx +0 -326
- package/src/components/DashboardBuilder/diff.spec.ts +0 -44
- package/src/components/DashboardBuilder/diff.ts +0 -93
- /package/dist/{components/DashboardBuilder → utils}/malloyText.d.ts +0 -0
- /package/src/{components/DashboardBuilder → utils}/malloyText.spec.ts +0 -0
- /package/src/{components/DashboardBuilder → utils}/malloyText.ts +0 -0
|
@@ -1,52 +1,52 @@
|
|
|
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(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),C=require("../useCompiledDocument-pOg2W-Yt.cjs.js"),$=require("@mui/material"),k=require("react"),Ke=require("../ServerProvider-Gbf1YPOP.cjs.js"),me=require("../text-entry-BJwltZiy.cjs.js"),sf=require("react-dom"),of=require("@malloydata/malloy-tag"),af=require("@tanstack/react-query"),lf={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map"};function cf(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:lf[o],...a?{disabled:!0,reason:a}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Ei({state:e,view:t,viewStatus:n,cellLabel:r,disabledReason:s,onOpen:i,onChange:o,variant:a="standard"}){const l=cf(t,e,n),u=k.useId();return x.jsx($.TextField,{select:!0,size:"small",variant:a,label:"Viz type",value:e,disabled:s!==void 0,onChange:c=>{const d=c.target.value;l.find(f=>f.value===d)?.disabled||o(d)},helperText:s,FormHelperTextProps:{id:u},SelectProps:{...i?{onOpen:i}:{},renderValue:c=>l.find(d=>d.value===c)?.label??String(c),MenuProps:{MenuListProps:{disabledItemsFocusable:!0}},SelectDisplayProps:{"aria-label":`Viz type, ${r}`,"aria-labelledby":void 0,...s?{"aria-describedby":u}:{}}},sx:{minWidth:140},children:l.map(c=>x.jsx($.MenuItem,{value:c.value,disabled:c.value==="custom"||c.disabled===!0,children:x.jsx($.ListItemText,{primary:c.label,...c.reason?{secondary:c.reason}:{}})},c.value))})}function df({sources:e,source:t,view:n,onSource:r,onView:s}){const{theme:i}=Ke.usePublisherTheme(),o=e.find(a=>a.name===t);return x.jsxs(x.Fragment,{children:[x.jsx($.TextField,{select:!0,size:"small",label:"Source",value:t,onChange:a=>r(a.target.value),inputProps:{"aria-label":"Source"},children:e.map(a=>x.jsxs($.MenuItem,{value:a.name,disabled:a.views.length===0,children:[a.name,a.views.length===0&&x.jsx($.Typography,{component:"span",variant:"caption",sx:{ml:1},children:"declares no views"}),a.description&&x.jsx($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:a.description})]},a.name))}),x.jsxs($.Box,{children:[x.jsx($.Typography,{variant:"subtitle2",sx:{mb:.5},children:"View"}),x.jsxs($.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=>x.jsxs($.ListItemButton,{selected:n===a.name,onClick:()=>s(a.name),"aria-label":`View ${a.name}`,children:[x.jsx($.ListItemText,{primary:a.name,secondary:a.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),a.chart&&x.jsx($.Chip,{size:"small",variant:"outlined",label:a.chart.replace(/_chart$/,"")})]},a.name)),o&&o.views.length===0&&x.jsx($.Typography,{variant:"body2",sx:{p:1.5,color:i.tileTitle},children:"This source declares no views."})]})]})]})}function uf({open:e,document:t,catalog:n,columns:r,onClose:s,onAdd:i,onAddText:o}){const{theme:a}=Ke.usePublisherTheme(),l=k.useMemo(()=>n?.sources??[],[n]),[u,c]=k.useState("query"),[d,f]=k.useState(""),[p,h]=k.useState(""),[v,y]=k.useState(""),[w,g]=k.useState("default"),[m,b]=k.useState(Math.ceil(r/2));k.useEffect(()=>{if(!e)return;c("query");const I=T=>l.some(D=>D.name===T&&D.views.length>0);f(t.sources.map(T=>T.base).find(I)??l.find(T=>T.views.length>0)?.name??""),h(""),y(""),g("default"),b(Math.ceil(r/2))},[e,t,l,r]);const _=d!==""&&p!=="",O=[d,p].filter(I=>I!==""&&!me.isBareName(I)).map(I=>`"${I}" is not a plain Malloy name, so a tile cannot be written for it.`)[0],E=l.find(I=>I.name===d)?.views.find(I=>I.name===p);return x.jsx(C.AppDialog,{open:e,onClose:s,title:"Add a tile",description:"A tile shows one view of a source in this package.",actions:x.jsxs(x.Fragment,{children:[x.jsx($.Button,{onClick:s,children:"Cancel"}),x.jsx($.Button,{variant:"contained",disabled:u==="query"&&(!_||O!==void 0),onClick:()=>u==="text"?o():i({base:d,modelPath:l.find(I=>I.name===d)?.modelPath??"",view:p,...v.trim()?{label:v.trim()}:{},...w!=="default"?{chart:w,...E?{chartCarried:E.chart?[E.chart]:[]}:{}}:{},colspan:m}),children:u==="text"?"Add text":"Add tile"})]}),children:x.jsxs($.Stack,{sx:{gap:2,pt:1},children:[x.jsxs($.ToggleButtonGroup,{size:"small",exclusive:!0,value:u,"aria-label":"Tile type",onChange:(I,T)=>{T!==null&&c(T)},children:[x.jsx($.ToggleButton,{value:"query",sx:{px:1.5},children:"Query"}),x.jsx($.ToggleButton,{value:"text",sx:{px:1.5},children:"Text"})]}),u==="text"?x.jsx($.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."}):l.length===0?x.jsx($.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?"This package publishes no source with a view to put on a tile.":"The package's sources are still loading."}):x.jsxs(x.Fragment,{children:[x.jsx(df,{sources:l,source:d,view:p,onSource:I=>{f(I),h("")},onView:I=>{h(I),g("default")}}),O&&x.jsx($.Typography,{variant:"body2",color:"error",children:O}),x.jsx(Ei,{state:w,view:E,cellLabel:"new tile",variant:"outlined",...E?{}:{disabledReason:"Pick a view to choose its chart."},onChange:I=>g(I)}),x.jsx($.Stack,{direction:"row",sx:{gap:1.5},children:x.jsx($.TextField,{size:"small",label:"Title",placeholder:"Uses the view's name",value:v,onChange:I=>y(I.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}})})]})]})})}const je=e=>e.kind==="text",xe=e=>e.kind!=="text",Wr=e=>xe(e)?e.label??e.name:e.name,Fe=e=>je(e)?`text.${e.name}`:`${e.source}.${e.name}`,si="self";function ff({open:e,document:t,source:n,givenNames:r,dashboards:s,onClose:i,onApply:o}){const{theme:a}=Ke.usePublisherTheme(),[l,u]=k.useState([]);k.useEffect(()=>{if(!e||!n)return;const h=(t.drills??[]).filter(v=>v.source===n.name);u((n.dimensions??[]).map(v=>{const y=h.find(w=>w.name===v.name);return{name:v.name,expression:v.expression,to:y?.to??[],given:y?.given??""}}))},[e,n,t]);const c=(h,v)=>u(y=>y.map((w,g)=>{if(g!==h)return w;const m={...w};return v(m),m})),d=[si,...s.filter(h=>h!==si)],f=h=>h===si?"This dashboard":h,p=()=>{n&&(o(l.filter(h=>h.to.length>0).map(h=>({source:n.name,name:h.name,expression:h.expression,to:h.to,...h.given?{given:h.given}:{}}))),i())};return x.jsx(C.AppDialog,{open:e,onClose:i,title:"Drill",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:x.jsxs(x.Fragment,{children:[x.jsx($.Button,{onClick:i,children:"Cancel"}),x.jsx($.Button,{variant:"contained",onClick:p,disabled:l.length===0,children:"Apply"})]}),children:x.jsx($.Stack,{sx:{gap:2,pt:1},children:l.length===0?x.jsx($.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?x.jsxs(x.Fragment,{children:[x.jsx($.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"," ",x.jsx($.Box,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):l.map((h,v)=>x.jsxs($.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[x.jsxs($.Box,{sx:{minWidth:0,pt:.75},children:[x.jsx($.Typography,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:h.name}),x.jsxs($.Typography,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:h.expression,children:["is ",h.expression]})]}),x.jsx($.TextField,{select:!0,size:"small",label:"Clicks go to",value:h.to,inputProps:{"aria-label":`Where ${h.name} goes`},SelectProps:{multiple:!0,renderValue:y=>y.length===0?"Not clickable":y.map(f).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:y=>c(v,w=>{const g=y.target.value;w.to=Array.isArray(g)?g:String(g).split(",").filter(Boolean)}),children:d.map(y=>x.jsxs($.MenuItem,{value:y,children:[x.jsx($.Checkbox,{size:"small",checked:h.to.includes(y),sx:{p:0,mr:1}}),x.jsx($.ListItemText,{primary:f(y)})]},y))}),x.jsxs($.TextField,{select:!0,size:"small",label:"Sets the filter",value:h.given,disabled:h.to.length===0,inputProps:{"aria-label":`Control ${h.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:h.given===""?`Named ${h.name}, like the dimension`:void 0,onChange:y=>c(v,w=>{w.given=y.target.value}),children:[x.jsx($.MenuItem,{value:"",children:x.jsx("em",{children:"Same name as the dimension"})}),r.map(y=>x.jsx($.MenuItem,{value:y,children:y},y))]})]},h.name))})})}function hf(e,t=[]){const n=new Map;for(const i of e.tiles)for(const o of xe(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 bs(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function pf(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function rs(e,t){const n=pf(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 Da(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 gf(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const mf=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function vf(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=me.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 Aa=[{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 Br(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 Ci=e=>xe(e)&&e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function bf(e,t){return e.tiles.map(n=>{const r=(xe(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}:bs(t.type)!==void 0?{op:bs(t.type)}:{}}})}function yf(e,t,n){n.forEach((r,s)=>{const i=e.tiles[s];if(!i||!Ci(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 xf(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 wf(e,t){for(const r of e.tiles){if(!xe(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 Bl=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function _f({open:e,document:t,control:n,available:r,fieldsFor:s,onApply:i}){const o=k.useRef(n);e&&(o.current=n);const a=e?n:o.current,l=a!==void 0,[u,c]=k.useState({kind:"new"}),[d,f]=k.useState(""),[p,h]=k.useState("select"),[v,y]=k.useState(""),[w,g]=k.useState(""),[m,b]=k.useState([]),[_,O]=k.useState(!1),[E,I]=k.useState(!1),T=M=>t.sources.find(U=>U.name===M.source)?.base??M.source;k.useEffect(()=>{if(e)if(I(n!==void 0),n){c({kind:"existing",name:n.name}),f(n.label??"");const M=bf(t,n);b(M);const U=M.filter(ve=>ve.include),de=new Set(U.map(ve=>ve.field));g(de.size===1?U[0].field:n.field??""),O(de.size>1)}else c({kind:"new"}),f(""),h("select"),g(""),y(new Date().toISOString().slice(0,10)),b(t.tiles.map(M=>({include:Ci(M),field:""}))),O(!1)},[e,n,t]);const D=k.useMemo(()=>[...(t.localGivens??[]).map(M=>M.name),...r.map(M=>M.name)],[t,r]),L=k.useMemo(()=>w.trim()?vf(w.trim(),D):"",[w,D]),R=u.kind==="existing"?n??r.find(M=>M.name===u.name):L?{name:L,type:Br({name:L,label:d,kind:p,field:w}).type}:void 0,z=R?.type!==void 0&&!R.type.startsWith("filter<"),K=m.find(M=>M.include)?.op??bs(R?.type),G=(M,U)=>{I(!0),b(de=>de.map((ve,Re)=>Re===M?{...ve,...U}:ve))},X=M=>{I(!0),b(U=>U.map(de=>({...de,op:M})))},Y=M=>{const U=bs(M);b(de=>de.map(({op:ve,...Re})=>U?{...Re,op:U}:Re))},se=M=>{I(!0),c({kind:"existing",name:M.name}),g(M.field??""),Y(M.type)},te=M=>{I(!0),h(M),Y(Br({name:"X",label:d,kind:M,field:w}).type)},A=t.tiles.map(Ci),B=A.filter(Boolean).length,N=m.filter((M,U)=>M.include&&A[U]).length,j=t.tiles.filter((M,U)=>(m[U]?.include??!1)&&A[U]&&xe(M)),q=j.length>0?j:t.tiles.filter((M,U)=>A[U]&&xe(M)),J=k.useMemo(()=>{const M=new Map;let U=!1;for(const de of q){const ve=s?.(de);if(ve){U=!0;for(const Re of ve)M.has(Re.name)||M.set(Re.name,Re)}}return U?[...M.values()]:void 0},[m,t.tiles,s]),ee=(()=>{const M=w.trim();for(const U of j){const de=s?.(U);if(!de||de.some(ve=>ve.name===M))return T(U)}return j[0]?T(j[0]):t.sources[0]?.base})(),H=M=>{I(!0),b(U=>U.map((de,ve)=>({...de,include:M&&A[ve]})))},S=k.useMemo(()=>_?m:m.map(M=>({...M,field:w})),[_,m,w]),P=M=>{for(const U of q){const de=s?.(U)?.find(ve=>ve.name===M.trim());if(de?.type)return de.type}},F=M=>rs(R?.type,M.type),V=(M,U)=>{if(M.trim()==="")return"Pick the field this filter compares.";const de=U?s?.(U):void 0;if(!de)return;const ve=de.find(Re=>Re.name===M.trim());if(!ve)return`Not a field of ${U?T(U):"the tiles' source"}.`;if(ve.type&&!rs(R?.type,ve.type))return`${M.trim()} is ${Da(ve.type)}; this filter compares ${Da(R?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},ie=M=>{if(I(!0),g(M),l||u.kind!=="new")return;const U=P(M),de=Br({name:"X",label:d,kind:p,field:M}).type;U&&!rs(de,U)&&te(gf(U))},Z=M=>{const U=t.tiles[M];return U&&xe(U)?U:void 0},oe=S.map((M,U)=>M.include&&A[U]?V(M.field,Z(U)):void 0),W=oe.every(M=>M===void 0),Q=E?oe:oe.map(()=>{}),ne=E&&!_&&N>0?j.map(M=>V(w,M)).find(Boolean):void 0,re=R!==void 0&&W&&(u.kind==="existing"||w.trim()!==""&&L!==""),ce=()=>{if(!(!R||!re))if(u.kind==="new")i(R.name,S,Br({name:R.name,label:d.trim()||Bl(R.name),kind:p,field:w.trim(),...ee?{source:ee}:{},...v?{dateDefault:v}:{}}));else if(n?.origin==="dashboard"&&n.local){const M=d.trim(),U=M!==(n.local.label??"");i(R.name,S,U?{...n.local,...M?{label:M}:{}}:void 0)}else i(R.name,S)},pe=l&&a.origin==="model";return{editing:l,shown:a,fromModel:pe,source:u,setSource:c,label:d,setLabel:f,kind:p,dateDefault:v,setDateDefault:y,field:w,rows:m,setRows:b,perTile:_,setPerTile:O,newName:L,target:R,valueTyped:z,commonOp:K,setRow:G,setCommonOp:X,pickExisting:se,pickKind:te,bindable:A,bindableCount:B,included:N,commonFields:J,setAll:H,accepts:F,pickField:ie,rowProblems:Q,commonProblem:ne,canApply:re,apply:ce}}function Pa({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=k.useMemo(()=>(n??[]).filter(h=>r?.(h)??!0).map(h=>h.name),[n,r]),p=k.useMemo(()=>new Map((n??[]).map(h=>[h.name,h.type])),[n]);return x.jsx($.Autocomplete,{freeSolo:!0,size:"small",options:f,inputValue:e,onInputChange:(h,v)=>t(v),value:e,onChange:(h,v)=>t(typeof v=="string"?v:""),disabled:l,disableClearable:!0,renderOption:(h,v)=>k.createElement("li",{...h,key:v},x.jsx($.Typography,{variant:"body2",sx:{flex:1},children:v}),p.get(v)&&x.jsx($.Typography,{variant:"caption",sx:{opacity:.6},children:p.get(v)?.replace(/_type$/,"")})),renderInput:h=>x.jsx($.TextField,{...h,label:s,placeholder:c,autoFocus:u,error:o,helperText:a,inputProps:{...h.inputProps,"aria-label":i}}),sx:d})}const Ma=e=>e&&xe(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 kf({open:e,document:t,control:n,available:r,fieldsFor:s,onClose:i,onApply:o,onRemove:a}){const{theme:l}=Ke.usePublisherTheme(),{editing:u,shown:c,fromModel:d,source:f,setSource:p,label:h,setLabel:v,kind:y,dateDefault:w,setDateDefault:g,field:m,rows:b,setRows:_,perTile:O,setPerTile:E,newName:I,target:T,valueTyped:D,commonOp:L,setRow:R,setCommonOp:z,pickExisting:K,pickKind:G,bindable:X,bindableCount:Y,included:se,commonFields:te,setAll:A,accepts:B,pickField:N,rowProblems:j,commonProblem:q,canApply:J,apply:ee}=_f({open:e,document:t,control:n,available:r,fieldsFor:s,onApply:o}),H=(S,P,F)=>x.jsx($.TextField,{select:!0,size:"small",label:"Compares",value:S??">=",onChange:V=>P(V.target.value),inputProps:{"aria-label":F},sx:{width:130},children:mf.filter(V=>V.op!=="~").map(V=>x.jsx($.MenuItem,{value:V.op,children:V.label},V.op))});return x.jsx(C.AppDialog,{open:e,onClose:i,title:u?c.label??c.name:"Add a filter",description:u?x.jsxs(x.Fragment,{children:[x.jsxs($.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 filter on the page, and the tiles it filters.",actions:x.jsxs(x.Fragment,{children:[u&&x.jsx($.Button,{color:"error",startIcon:x.jsx(C.DeleteOutlineIcon,{}),onClick:()=>a(c.name),sx:S=>({mr:"auto",color:C.dangerTextColor(S)}),children:"Remove filter"}),x.jsx($.Button,{onClick:i,children:"Cancel"}),x.jsx($.Tooltip,{title:J||T===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:x.jsx("span",{children:x.jsx($.Button,{variant:"contained",onClick:ee,disabled:!J,children:u?"Apply":"Add filter"})})})]}),children:x.jsxs($.Stack,{sx:{gap:2.5,pt:1},children:[!u&&r.length>0&&x.jsxs($.ToggleButtonGroup,{exclusive:!0,size:"small",value:f.kind,onChange:(S,P)=>{P==="new"?p({kind:"new"}):P==="existing"&&r[0]&&K(r[0])},"aria-label":"Where the filter comes from",children:[x.jsx($.ToggleButton,{value:"new",children:"New in this dashboard"}),x.jsx($.ToggleButton,{value:"existing",children:"From the model"})]}),!u&&f.kind==="existing"?x.jsx($.TextField,{select:!0,size:"small",label:"Filter",value:f.name,onChange:S=>{const P=r.find(F=>F.name===S.target.value);P&&K(P)},children:r.map(S=>x.jsxs($.MenuItem,{value:S.name,children:[S.label??S.name,x.jsxs($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",S.name]})]},S.name))}):null,x.jsxs($.Stack,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!O&&x.jsx(Pa,{value:m,onChange:N,fields:te,accepts:B,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!u,error:q!==void 0,helperText:q??(!u&&I?`Declared as $${I}`:void 0),sx:{flex:1,minWidth:200}}),!d&&x.jsx($.TextField,{size:"small",label:"Label",placeholder:I?Bl(I):"",value:h,onChange:S=>v(S.target.value),inputProps:{"aria-label":"Filter label"},sx:{flex:1,minWidth:160}}),D&&!O&&H(L,z,"Comparison")]}),!u&&f.kind==="new"&&x.jsxs($.Stack,{direction:"row",sx:{gap:1.5},children:[x.jsx($.TextField,{select:!0,size:"small",label:"Filter kind",value:y,onChange:S=>G(S.target.value),inputProps:{"aria-label":"Filter kind"},slotProps:{select:{renderValue:S=>Aa.find(P=>P.kind===S)?.label??String(S)}},sx:{flex:1},children:Aa.map(S=>x.jsxs($.MenuItem,{value:S.kind,children:[S.label,x.jsx($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:S.hint})]},S.kind))}),y==="date"&&x.jsx($.TextField,{size:"small",type:"date",label:"Starts at",value:w,onChange:S=>g(S.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),x.jsxs($.Box,{children:[x.jsxs($.Stack,{direction:"row",sx:{alignItems:"center",gap:.5},children:[x.jsx($.Checkbox,{size:"small",checked:Y>0&&se===Y,indeterminate:se>0&&se<Y,disabled:Y===0,onChange:S=>A(S.target.checked),inputProps:{"aria-label":"All tiles"}}),x.jsxs($.Typography,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",se," of ",t.tiles.length," tiles"]}),x.jsx($.Button,{size:"small",onClick:()=>{O||_(S=>S.map(P=>({...P,field:m}))),E(S=>!S)},children:O?"Same field for all":"Adjust per tile"})]}),x.jsx($.Stack,{sx:{gap:O?1:0},children:t.tiles.map((S,P)=>{if(!xe(S))return null;const F=b[P],V=S.label??S.name,ie=O?j[P]:void 0;return x.jsxs($.Stack,{direction:"row",sx:{gap:1,alignItems:O?"flex-start":"center",opacity:X[P]?1:.6},children:[x.jsx($.Checkbox,{size:"small",disabled:!X[P],checked:(F?.include??!1)&&X[P],inputProps:{"aria-label":`Filter ${V}`},onChange:Z=>R(P,{include:Z.target.checked})}),x.jsx($.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:O?1:0},noWrap:!0,children:V}),X[P]?O&&x.jsxs(x.Fragment,{children:[D&&H(F?.op,Z=>R(P,{op:Z}),`Comparison for ${V}`),x.jsx(Pa,{value:F?.field??"",onChange:Z=>R(P,{field:Z}),fields:s?.(S),accepts:B,label:"Field",ariaLabel:`Field for ${V}`,disabled:!F?.include,error:ie!==void 0,helperText:ie,sx:{width:220}})]}):x.jsx($.Tooltip,{title:Ma(t.tiles[P]).reason,children:x.jsx($.Typography,{variant:"caption",sx:{color:l.tileTitle},children:Ma(t.tiles[P]).label})})]},`${S.source}.${S.name}`)})}),se===0&&x.jsx($.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 Sf=C.createSvgIcon(x.jsx("path",{d:"M11.71 17.99C8.53 17.84 6 15.22 6 12c0-3.31 2.69-6 6-6 3.22 0 5.84 2.53 5.99 5.71l-2.1-.63C15.48 9.31 13.89 8 12 8c-2.21 0-4 1.79-4 4 0 1.89 1.31 3.48 3.08 3.89zM22 12c0 .3-.01.6-.04.9l-1.97-.59c.01-.1.01-.21.01-.31 0-4.42-3.58-8-8-8s-8 3.58-8 8 3.58 8 8 8c.1 0 .21 0 .31-.01l.59 1.97c-.3.03-.6.04-.9.04-5.52 0-10-4.48-10-10S6.48 2 12 2s10 4.48 10 10m-3.77 4.26L22 15l-10-3 3 10 1.26-3.77 4.27 4.27 1.98-1.98z"}));function Gl(e,t,n,r){const[s,i]=k.useState(void 0);return k.useEffect(()=>{t&&e!==void 0&&i(structuredClone(e))},[t,e]),{draft:s,patch:c=>i(d=>{if(d===void 0)return d;const f=structuredClone(d);return c(f),f}),apply:c=>{if(s===void 0)return;const d=structuredClone(s);c(d),i(d),JSON.stringify(d)!==JSON.stringify(e)&&n(d)},close:()=>{s!==void 0&&e!==void 0&&JSON.stringify(s)!==JSON.stringify(e)&&n(s),r()},discard:()=>i(void 0)}}const $f=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.`,Tf="This tile's view is declared on its source, so its chart is set in the model.";function Of({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:s,removeBlocked:i,onDrills:o,view:a}){const l=k.useId(),{theme:u}=Ke.usePublisherTheme(),{draft:c,apply:d,close:f,discard:p}=Gl(t,e!==null,r,n),h=c!==void 0&&xe(c)?c:void 0,v=h!==void 0&&h.declaration.kind!=="inherited",y=m=>d(b=>{xe(b)&&m(b)}),w=k.useRef(void 0),g=e!==null;return k.useEffect(()=>{g&&(w.current=t&&xe(t)?t.chart:void 0)},[g]),x.jsx($.Popover,{open:e!==null&&c!==void 0,anchorEl:e,onClose:f,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:c&&x.jsxs($.Stack,{sx:{gap:1.5},children:[x.jsx($.Typography,{variant:"overline",sx:{color:u.tileTitle,lineHeight:1.5},children:h?`${h.source} → ${h.name}`:`Text · ${c.name}`}),h&&v&&x.jsx(x.Fragment,{children:x.jsx(Ei,{state:h.chart??"default",view:a,cellLabel:`${h.source} ${h.name}`,...h.chart==="custom"?{disabledReason:$f(h.chartLines)}:{},onChange:m=>y(b=>{const _=w.current;m===(_??"default")?(_===void 0?delete b.chart:b.chart=_,delete b.chartCarried):(b.chart=m,a?b.chartCarried=a.chart?[a.chart]:[]:delete b.chartCarried)})})}),h&&!v&&x.jsxs(x.Fragment,{children:[x.jsx($.Typography,{variant:"body2",sx:{color:u.tileTitle},children:"Declared on its source, so its title and layout are set in the model. It can still be moved."}),x.jsx(Ei,{state:"default",view:a,cellLabel:`${h.source} ${h.name}`,disabledReason:Tf,onChange:()=>{}})]}),h?.declaration.kind==="opaque"&&x.jsxs($.Typography,{variant:"body2",sx:{color:u.tileTitle},children:["Its body is ",h.declaration.why,", so a filter has no single place to go. Everything else here is editable."]}),x.jsxs($.Stack,{direction:"row",sx:{justifyContent:"space-between"},children:[v?x.jsx($.Button,{size:"small",startIcon:x.jsx(Sf,{}),"aria-haspopup":"dialog",onClick:()=>{f(),o()},children:"Drill"}):x.jsx("span",{}),x.jsx($.Button,{color:"error",size:"small",startIcon:x.jsx(C.DeleteOutlineIcon,{}),"aria-disabled":i!==void 0||void 0,"aria-describedby":i!==void 0?l:void 0,disableRipple:i!==void 0,sx:m=>({color:C.dangerTextColor(m),...i!==void 0?{opacity:.5,cursor:"default"}:{}}),onClick:()=>{i===void 0&&(p(),s())},children:"Delete"})]}),i!==void 0&&x.jsx($.Typography,{id:l,variant:"caption",sx:{color:u.tileTitle},children:i})]})})}function Ef({editor:e,catalog:t,columns:n,dashboards:r,bindings:s,tiles:i,drillSource:o,setDrillSource:a,confirmConversion:l,exitDialog:u}){const{filterDialog:c,setFilterDialog:d}=s,{menu:f,setMenu:p}=i,h=f===void 0?void 0:e.document.tiles[f.index],v=h&&xe(h)?h:void 0,y=(()=>{if(!v||!t)return;const w=e.document.sources.find(m=>m.name===v.source)?.base??v.source,g=v.declaration.kind==="reference"?v.declaration.from:v.name;return t.sources.find(m=>m.name===w)?.views.find(m=>m.name===g)})();return x.jsxs(x.Fragment,{children:[x.jsx(kf,{open:c!==void 0,document:e.document,...c?.control?{control:c.control}:{},available:s.available,...t?{fieldsFor:s.fieldsFor}:{},onClose:()=>d(void 0),onApply:s.applyFilter,onRemove:s.dropControl}),x.jsx(Of,{anchor:f?.anchor??null,tile:f===void 0?void 0:e.document.tiles[f.index],onClose:()=>p(void 0),onCommit:w=>{const g=f?.index;g!==void 0&&e.update(m=>{m.tiles[g]=w})},onRemove:()=>{f!==void 0&&i.removeTile(f.index)},...e.document.tiles.length===1&&e.saved.tiles.length>0?{removeBlocked:"A saved dashboard needs at least one tile."}:{},view:y,onDrills:()=>{a(v?.source)}}),x.jsx(ff,{open:o!==void 0,document:e.document,source:e.document.sources.find(w=>w.name===o),givenNames:s.controlList.map(w=>w.name),dashboards:r??[],onClose:()=>a(void 0),onApply:w=>e.update(g=>{const b=[...(g.drills??[]).filter(_=>_.source!==o),...w];b.length===0?delete g.drills:g.drills=b})}),x.jsx(C.AppDialog,{open:l!==void 0,onClose:()=>l?.stop(),title:"Convert this notebook?",description:"Saving rewrites this notebook in the tile layout. The builder cannot take that back; the file's history in your repository can.",actions:x.jsxs(x.Fragment,{children:[x.jsx($.Button,{onClick:()=>l?.stop(),children:"Cancel"}),x.jsx($.Button,{variant:"contained",onClick:()=>l?.go(),children:"Convert and save"})]}),children:null}),x.jsx(C.UnsavedChangesDialog,{...u}),x.jsx(uf,{open:i.addingTile,document:e.document,catalog:t,columns:n,onClose:i.closeAdd,onAdd:i.addTile,onAddText:i.addText})]})}var Cf=Symbol.for("preact-signals");function zs(){if(yt>1)yt--;else{var e,t=!1;for((function(){var s=xs;for(xs=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}})();lr!==void 0;){var n=lr;for(lr=void 0,ys++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Kl(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(ys=0,yt--,t)throw e}}function Te(e){if(yt>0)return e();Ii=++If,yt++;try{return e()}finally{zs()}}var ar,we=void 0;function ue(e){var t=we,n=ar;we=void 0,ar=void 0;try{return e()}finally{we=t,ar=n}}var lr=void 0,yt=0,ys=0,If=0,Ii=0,xs=void 0,ws=0;function ql(e){if(we!==void 0){var t=e.n;if(t===void 0||t.t!==we)return t={i:0,S:e,p:we.s,n:void 0,t:we,e:void 0,x:void 0,r:t},we.s!==void 0&&(we.s.n=t),we.s=t,e.n=t,32&we.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=we.s,t.n=void 0,we.s.n=t,we.s=t),t}}function Ue(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}Ue.prototype.brand=Cf;Ue.prototype.h=function(){return!0};Ue.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:ue(function(){var r;(r=t.W)==null||r.call(t)}))};Ue.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&&ue(function(){var s;(s=t.Z)==null||s.call(t)}))}};Ue.prototype.subscribe=function(e){var t=this;return st(function(){var n=t.value;ue(function(){return e(n)})},{name:"sub"})};Ue.prototype.valueOf=function(){return this.value};Ue.prototype.toString=function(){return this.value+""};Ue.prototype.toJSON=function(){return this.value};Ue.prototype.peek=function(){var e=this;return ue(function(){return e.value})};Object.defineProperty(Ue.prototype,"value",{get:function(){var e=ql(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ys>100)throw new Error("Cycle detected");(function(n){yt!==0&&ys===0&&n.l!==Ii&&(n.l=Ii,xs={S:n,v:n.v,i:n.i,o:xs})})(this),this.v=e,this.i++,ws++,yt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{zs()}}}});function Tn(e,t){return new Ue(e,t)}function Kl(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 Ul(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 Vl(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 Xt(e,t){Ue.call(this,void 0,t),this.x=e,this.s=void 0,this.g=ws-1,this.f=4}Xt.prototype=new Ue;Xt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ws))return!0;if(this.g=ws,this.f|=1,this.i>0&&!Kl(this))return this.f&=-2,!0;var e=we;try{Ul(this),we=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 we=e,Vl(this),this.f&=-2,!0};Xt.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)}Ue.prototype.S.call(this,e)};Xt.prototype.U=function(e){if(this.t!==void 0&&(Ue.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)}};Xt.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(Xt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=ql(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function ja(e,t){return new Xt(e,t)}function Hl(e){var t=e.m;if(e.m=void 0,typeof t=="function"){yt++;var n=we;we=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,yo(e),r}finally{we=n,zs()}}}function yo(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Hl(e)}function Df(e){if(we!==this)throw new Error("Out-of-order effect");Vl(this),we=e,this.f&=-2,8&this.f&&yo(this),zs()}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,ar&&ar.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,Hl(this),Ul(this),yt++;var e=we;return we=this,Df.bind(this,e)};On.prototype.N=function(){2&this.f||(this.f|=2,this.u=lr,lr=this)};On.prototype.d=function(){this.f|=8,1&this.f||yo(this)};On.prototype.dispose=function(){this.d()};function st(e,t){var n=new On(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Af=Object.create,xo=Object.defineProperty,Pf=Object.defineProperties,Mf=Object.getOwnPropertyDescriptor,jf=Object.getOwnPropertyDescriptors,Ra=Object.getOwnPropertySymbols,Rf=Object.prototype.hasOwnProperty,Lf=Object.prototype.propertyIsEnumerable,Nf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),En=e=>{throw TypeError(e)},Di=(e,t,n)=>t in e?xo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ff=(e,t)=>{for(var n in t||(t={}))Rf.call(t,n)&&Di(e,n,t[n]);if(Ra)for(var n of Ra(t))Lf.call(t,n)&&Di(e,n,t[n]);return e},zf=(e,t)=>Pf(e,jf(t)),La=(e,t)=>xo(e,"name",{value:t,configurable:!0}),Wf=e=>{var t;return[,,,Af((t=void 0)!=null?t:null)]},Xl=["class","method","getter","setter","accessor","field","value","get","set"],Kn=e=>e!==void 0&&typeof e!="function"?En("Function expected"):e,Bf=(e,t,n,r,s)=>({kind:Xl[e],name:t,metadata:r,addInitializer:i=>n._?En("Already initialized"):s.push(Kn(i||null))}),Yl=(e,t)=>Di(t,Nf("metadata"),e[3]),jt=(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},Cn=(e,t,n,r,s,i)=>{var o,a,l,u,c,d=t&7,f=!!(t&8),p=!!(t&16),h=d>3?e.length+1:d?f?1:2:0,v=Xl[d+5],y=d>3&&(e[h-1]=[]),w=e[h]||(e[h]=[]),g=d&&(!p&&!f&&(s=s.prototype),d<5&&(d>3||!p)&&Mf(d<4?s:{get[n](){return Je(this,i)},set[n](b){return Ot(this,i,b)}},n));d?p&&d<4&&La(i,(d>2?"set ":d>1?"get ":"")+n):La(s,n);for(var m=r.length-1;m>=0;m--)u=Bf(d,n,l={},e[3],w),d&&(u.static=f,u.private=p,c=u.access={has:p?b=>Gf(s,b):b=>n in b},d^3&&(c.get=p?b=>(d^1?Je:qf)(b,s,d^4?i:g.get):b=>b[n]),d>2&&(c.set=p?(b,_)=>Ot(b,s,_,d^4?i:g.set):(b,_)=>b[n]=_)),a=(0,r[m])(d?d<4?p?i:g[v]:d>4?void 0:{get:g.get,set:g.set}:s,u),l._=1,d^4||a===void 0?Kn(a)&&(d>4?y.unshift(a):d?p?i=a:g[v]=a:s=a):typeof a!="object"||a===null?En("Object expected"):(Kn(o=a.get)&&(g.get=o),Kn(o=a.set)&&(g.set=o),Kn(o=a.init)&&y.unshift(o));return d||Yl(e,s),g&&xo(s,n,g),p?d^4?i:g:s},wo=(e,t,n)=>t.has(e)||En("Cannot "+n),Gf=(e,t)=>Object(t)!==t?En('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)),Un=(e,t,n)=>t.has(e)?En("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ot=(e,t,n,r)=>(wo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),qf=(e,t,n)=>(wo(e,t,"access private method"),n);function Ai(e,t){if(t){let n;return ja(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return ja(e)}function ot(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)=>!ot(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=>!ot(e[i],t[i]))}return!1}function fe({get:e},t){return{init(n){return Tn(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Ee(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Ai(e.bind(this)),n.set(this,r)),r.value}}function ii(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,zf(Ff({},s),{enumerable:e}))})}}function Er(...e){const t=e.map(n=>st(n));return()=>t.forEach(n=>n())}var Zl,Ql,Jl,ec,tc,nc,Be,_o,oi,Pi,Mi,ze,ko,ai,rc,ji,So,li,Ri,Li;nc=[fe],tc=[fe],ec=[fe],Jl=[ii()],Ql=[ii()],Zl=[ii()];var Yt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,jt(Be,5,this),Un(this,ze),Un(this,_o,jt(Be,8,this)),jt(Be,11,this),Un(this,ko,jt(Be,12,this)),jt(Be,15,this),Un(this,So,jt(Be,16,this)),jt(Be,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Je(this,ze,Ri)}get initial(){return Je(this,ze,Pi)}get previous(){return Je(this,ze,rc)}set current(e){const t=ue(()=>Je(this,ze,Ri));e&&t&&this.equals(t,e)||Te(()=>{Je(this,ze,Pi)||Ot(this,ze,e,Mi),Ot(this,ze,t,ji),Ot(this,ze,e,Li)})}reset(e=this.defaultValue){Te(()=>{Ot(this,ze,void 0,ji),Ot(this,ze,e,Mi),Ot(this,ze,e,Li)})}};Be=Wf();_o=new WeakMap;ze=new WeakSet;ko=new WeakMap;So=new WeakMap;oi=Cn(Be,20,"#initial",nc,ze,_o),Pi=oi.get,Mi=oi.set;ai=Cn(Be,20,"#previous",tc,ze,ko),rc=ai.get,ji=ai.set;li=Cn(Be,20,"#current",ec,ze,So),Ri=li.get,Li=li.set;Cn(Be,2,"current",Jl,Yt);Cn(Be,2,"initial",Ql,Yt);Cn(Be,2,"previous",Zl,Yt);Yl(Be,Yt);function ci(e){return ue(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Rt,Kf=class{constructor(){Un(this,Rt,new WeakMap)}get(e,t){var n;return e?(n=Je(this,Rt).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Je(this,Rt).has(e)||Je(this,Rt).set(e,new Map),(r=Je(this,Rt).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Je(this,Rt).get(e))==null?void 0:t.clear():void 0}};Rt=new WeakMap;var Uf=Object.create,sc=Object.defineProperty,Vf=Object.getOwnPropertyDescriptor,Na=Object.getOwnPropertySymbols,Hf=Object.prototype.hasOwnProperty,Xf=Object.prototype.propertyIsEnumerable,ic=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ws=e=>{throw TypeError(e)},Fa=Math.pow,Ni=(e,t,n)=>t in e?sc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Yf=(e,t)=>{for(var n in t||(t={}))Hf.call(t,n)&&Ni(e,n,t[n]);if(Na)for(var n of Na(t))Xf.call(t,n)&&Ni(e,n,t[n]);return e},Zf=e=>{var t;return[,,,Uf((t=e?.[ic("metadata")])!=null?t:null)]},oc=["class","method","getter","setter","accessor","field","value","get","set"],ac=e=>e!==void 0&&typeof e!="function"?Ws("Function expected"):e,Qf=(e,t,n,r,s)=>({kind:oc[e],name:t,metadata:r,addInitializer:i=>n._?Ws("Already initialized"):s.push(ac(i||null))}),Jf=(e,t)=>Ni(t,ic("metadata"),e[3]),eh=(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},lc=(e,t,n,r,s,i)=>{for(var o,a,l,u,c=t&7,d=!1,f=!1,p=2,h=oc[c+5],v=e[p]||(e[p]=[]),y=(s=s.prototype,Vf(s,n)),w=r.length-1;w>=0;w--)l=Qf(c,n,a={},e[3],v),l.static=d,l.private=f,u=l.access={has:g=>n in g},u.get=g=>g[n],o=(0,r[w])(y[h],l),a._=1,ac(o)&&(y[h]=o);return y&&sc(s,n,y),s},cc=(e,t,n)=>t.has(e)||Ws("Cannot "+n),th=(e,t,n)=>(cc(e,t,"read from private field"),t.get(e)),nh=(e,t,n)=>t.has(e)?Ws("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),rh=(e,t,n,r)=>(cc(e,t,"write to private field"),t.set(e,n),n),et=class Fi{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Fi(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 Fi(t,n)}},ft=class Lt{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 Lt(s+t,r+n,i,o);return l.scale=Yf({},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 et((t+r)/2,(n+s)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Lt))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 Lt?sh(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 Lt(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 et.delta({x:s(t,"x"),y:s(t,"y")},{x:s(n,"x"),y:s(n,"y")})}static intersectionRatio(t,n){return Lt.from(t).intersectionRatio(Lt.from(n))}};function sh(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 dc,uc,zi,ss,Cr,Bs=class extends(zi=Yt,uc=[Ee],dc=[Ee],zi){constructor(t){const n=et.from(t);super(n,(r,s)=>et.equals(r,s)),eh(Cr,5,this),nh(this,ss,0),this.velocity={x:0,y:0}}get delta(){return et.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=et.from(t),s={x:r.x-n.x,y:r.y-n.y},i=Date.now(),o=i-th(this,ss),a=l=>Math.round(l/o*100);Te(()=>{rh(this,ss,i),this.velocity={x:a(s.x),y:a(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(et.from(t)),this.velocity={x:0,y:0}}};Cr=Zf(zi);ss=new WeakMap;lc(Cr,2,"delta",uc,Bs);lc(Cr,2,"direction",dc,Bs);Jf(Cr,Bs);function Wi({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(Fa(r,2)+Fa(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 fc=(e=>(e.Horizontal="x",e.Vertical="y",e))(fc||{}),hc=Object.values(fc),ih=Object.create,$o=Object.defineProperty,oh=Object.defineProperties,ah=Object.getOwnPropertyDescriptor,lh=Object.getOwnPropertyDescriptors,_s=Object.getOwnPropertySymbols,pc=Object.prototype.hasOwnProperty,gc=Object.prototype.propertyIsEnumerable,mc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),In=e=>{throw TypeError(e)},Bi=(e,t,n)=>t in e?$o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,To=(e,t)=>{for(var n in t||(t={}))pc.call(t,n)&&Bi(e,n,t[n]);if(_s)for(var n of _s(t))gc.call(t,n)&&Bi(e,n,t[n]);return e},Oo=(e,t)=>oh(e,lh(t)),za=(e,t)=>$o(e,"name",{value:t,configurable:!0}),vc=(e,t)=>{var n={};for(var r in e)pc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&_s)for(var r of _s(e))t.indexOf(r)<0&&gc.call(e,r)&&(n[r]=e[r]);return n},Dn=e=>{var t;return[,,,ih((t=e?.[mc("metadata")])!=null?t:null)]},bc=["class","method","getter","setter","accessor","field","value","get","set"],Vn=e=>e!==void 0&&typeof e!="function"?In("Function expected"):e,ch=(e,t,n,r,s)=>({kind:bc[e],name:t,metadata:r,addInitializer:i=>n._?In("Already initialized"):s.push(Vn(i||null))}),Zt=(e,t)=>Bi(t,mc("metadata"),e[3]),le=(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},he=(e,t,n,r,s,i)=>{var o,a,l,u,c,d=t&7,f=!!(t&8),p=!!(t&16),h=d>3?e.length+1:d?f?1:2:0,v=bc[d+5],y=d>3&&(e[h-1]=[]),w=e[h]||(e[h]=[]),g=d&&(!p&&!f&&(s=s.prototype),d<5&&(d>3||!p)&&ah(d<4?s:{get[n](){return Oe(this,i)},set[n](b){return Ze(this,i,b)}},n));d?p&&d<4&&za(i,(d>2?"set ":d>1?"get ":"")+n):za(s,n);for(var m=r.length-1;m>=0;m--)u=ch(d,n,l={},e[3],w),d&&(u.static=f,u.private=p,c=u.access={has:p?b=>dh(s,b):b=>n in b},d^3&&(c.get=p?b=>(d^1?Oe:yc)(b,s,d^4?i:g.get):b=>b[n]),d>2&&(c.set=p?(b,_)=>Ze(b,s,_,d^4?i:g.set):(b,_)=>b[n]=_)),a=(0,r[m])(d?d<4?p?i:g[v]:d>4?void 0:{get:g.get,set:g.set}:s,u),l._=1,d^4||a===void 0?Vn(a)&&(d>4?y.unshift(a):d?p?i=a:g[v]=a:s=a):typeof a!="object"||a===null?In("Object expected"):(Vn(o=a.get)&&(g.get=o),Vn(o=a.set)&&(g.set=o),Vn(o=a.init)&&y.unshift(o));return d||Zt(e,s),g&&$o(s,n,g),p?d^4?i:g:s},Eo=(e,t,n)=>t.has(e)||In("Cannot "+n),dh=(e,t)=>Object(t)!==t?In('Cannot use the "in" operator on this value'):e.has(t),Oe=(e,t,n)=>(Eo(e,t,"read from private field"),n?n.call(e):t.get(e)),ge=(e,t,n)=>t.has(e)?In("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ze=(e,t,n,r)=>(Eo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),yc=(e,t,n)=>(Eo(e,t,"access private method"),n);function xc(e,t){return{plugin:e,options:t}}function Ir(e){return t=>xc(e,t)}function pr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var wc,gr,Co,is;wc=[fe];var We=class{constructor(e,t){this.manager=e,this.options=t,ge(this,Co,le(gr,8,this,!1)),le(gr,11,this),ge(this,is,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return ue(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=st(e.bind(this));return Oe(this,is).add(t),t}destroy(){Oe(this,is).forEach(e=>e())}static configure(e){return xc(this,e)}};gr=Dn(null);Co=new WeakMap;is=new WeakMap;he(gr,4,"disabled",wc,We,Co);Zt(gr,We);var Dr=class extends We{},os,di=class{constructor(e){this.manager=e,this.instances=new Map,ge(this,os,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(pr).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 Oe(this,os))if(!n.includes(r)){if(r.prototype instanceof Dr)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);Ze(this,os,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()}};os=new WeakMap;function uh(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Gr=[],an,ln,fh=class extends We{constructor(e){super(e),ge(this,an),ge(this,ln),this.computeCollisions=this.computeCollisions.bind(this),Ze(this,ln,Tn(Gr)),this.destroy=Er(()=>{const t=this.computeCollisions(),n=ue(()=>this.manager.dragOperation.position.current);if(t!==Gr){const r=Oe(this,an);if(Ze(this,an,n),r&&n.x==r.x&&n.y==r.y)return}else Ze(this,an,void 0);Oe(this,ln).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){ue(()=>{e?Oe(this,ln).value=this.computeCollisions():Ze(this,an,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:i,status:o}=r;if(!o.initialized||!i)return Gr;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=ue(()=>c({droppable:u,dragOperation:r}));d&&(u.collisionPriority!=null&&(d.priority=u.collisionPriority),a.push(d))}return l.length===0?Gr:(a.sort(uh),a)}get collisions(){return Oe(this,ln).value}};an=new WeakMap;ln=new WeakMap;var _c,kc,Sc,Io,$c,at,Do,pn,Ao,Po;Sc=[fe],kc=[fe],_c=[fe];var wt=class Nt{constructor(t,n){ge(this,Do,le(at,8,this)),le(at,11,this),ge(this,pn),ge(this,Ao,le(at,12,this)),le(at,15,this),ge(this,Po,le(at,16,this)),le(at,19,this);const{effects:r,id:s,data:i={},disabled:o=!1,register:a=!0}=t;let l=s;Ze(this,pn,Tn(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=Oe(this,pn).value;return(n=(t=Nt.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const s=(r=(n=Nt.pendingIdChanges)==null?void 0:n.get(this))!=null?r:Oe(this,pn).peek();t!==s&&(Nt.pendingIdChanges||(Nt.pendingIdChanges=new Map,queueMicrotask(()=>{var i;return yc(i=Nt,Io,$c).call(i)})),Nt.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)}};at=Dn(null);Io=new WeakSet;$c=function(){const e=wt.pendingIdChanges;wt.pendingIdChanges=null,e&&Te(()=>{for(const[t,n]of e)Oe(t,pn).value=n})};Do=new WeakMap;pn=new WeakMap;Ao=new WeakMap;Po=new WeakMap;he(at,4,"manager",Sc,wt,Do);he(at,4,"data",kc,wt,Ao);he(at,4,"disabled",_c,wt,Po);ge(wt,Io);Zt(at,wt);wt.pendingIdChanges=null;var Gs=wt,Wa=class{constructor(){this.map=Tn(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=Er(...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}},Tc,Oc,Ec,Cc,Ic,Dc,Gi,Ge,Mo,jo,Ro,ht=class extends(Gi=Gs,Dc=[fe],Ic=[fe],Cc=[fe],Ec=[Ee],Oc=[Ee],Tc=[Ee],Gi){constructor(t,n){var r=t,{modifiers:s,type:i,sensors:o,plugins:a,effects:l}=r,u=vc(r,["modifiers","type","sensors","plugins","effects"]);super(Oo(To({},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:h}=pr(p);d.registry.plugins.register(h)}}]}}),n),le(Ge,5,this),ge(this,Mo,le(Ge,8,this)),le(Ge,11,this),ge(this,jo,le(Ge,12,this)),le(Ge,15,this),ge(this,Ro,le(Ge,16,this,this.isDragSource?"dragging":"idle")),le(Ge,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=pr(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}};Ge=Dn(Gi);Mo=new WeakMap;jo=new WeakMap;Ro=new WeakMap;he(Ge,4,"type",Dc,ht,Mo);he(Ge,4,"modifiers",Ic,ht,jo);he(Ge,4,"status",Cc,ht,Ro);he(Ge,2,"isDropping",Ec,ht);he(Ge,2,"isDragging",Oc,ht);he(Ge,2,"isDragSource",Tc,ht);Zt(Ge,ht);var Ac,Pc,Mc,jc,Rc,Lc,qi,Pe,Lo,No,Fo,zo,Wo,pt=class extends(qi=Gs,Lc=[fe],Rc=[fe],jc=[fe],Mc=[fe],Pc=[fe],Ac=[Ee],qi){constructor(t,n){var r=t,{accept:s,collisionDetector:i,collisionPriority:o,type:a}=r,l=vc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),le(Pe,5,this),ge(this,Lo,le(Pe,8,this)),le(Pe,11,this),ge(this,No,le(Pe,12,this)),le(Pe,15,this),ge(this,Fo,le(Pe,16,this)),le(Pe,19,this),ge(this,zo,le(Pe,20,this)),le(Pe,23,this),ge(this,Wo,le(Pe,24,this)),le(Pe,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}};Pe=Dn(qi);Lo=new WeakMap;No=new WeakMap;Fo=new WeakMap;zo=new WeakMap;Wo=new WeakMap;he(Pe,4,"accept",Lc,pt,Lo);he(Pe,4,"type",Rc,pt,No);he(Pe,4,"collisionDetector",jc,pt,Fo);he(Pe,4,"collisionPriority",Mc,pt,zo);he(Pe,4,"shape",Pc,pt,Wo);he(Pe,2,"isDropTarget",Ac,pt);Zt(Pe,pt);var hh=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)}},ph=class extends hh{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function as(e,t=!0){let n=!1;return Oo(To({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var gh=class extends Dr{constructor(e){super(e);const t=(r,s)=>r.map(({id:i})=>i).join("")===s.map(({id:i})=>i).join("");let n=[];this.destroy=Er(()=>{const{dragOperation:r,collisionObserver:s}=e;r.status.initializing&&(n=[],s.enable())},()=>{const{collisionObserver:r,monitor:s}=e,{collisions:i}=r;if(r.isDisabled()||Gs.pendingIdChanges)return;const o=as({collisions:i});if(s.dispatch("collision",o),o.defaultPrevented||t(i,n))return;n=i;const[a]=i;ue(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},An=(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))(An||{}),Pn=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Pn||{}),Nc,Fc,zc,Wc,Bc,Gc,qc,rt,Bo;qc=[fe],Gc=[Ee],Bc=[Ee],Wc=[Ee],zc=[Ee],Fc=[Ee],Nc=[Ee];var kt=class{constructor(){le(rt,5,this),ge(this,Bo,le(rt,8,this,"idle")),le(rt,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}};rt=Dn(null);Bo=new WeakMap;he(rt,4,"value",qc,kt,Bo);he(rt,2,"current",Gc,kt);he(rt,2,"idle",Bc,kt);he(rt,2,"initializing",Wc,kt);he(rt,2,"initialized",zc,kt);he(rt,2,"dragging",Fc,kt);he(rt,2,"dropped",Nc,kt);Zt(rt,kt);var mh=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 ue(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=as({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return ue(()=>{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;Te(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(i)});const o=as({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"&&Te(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:s,operation:t.snapshot(),cancelable:!1})})}),r)})}move(e){return ue(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:i}=r;if(!s.dragging||!i||i.signal.aborted)return;const o=as({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 ue(()=>{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=ue(()=>{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=st(()=>{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()})}},xn=class extends We{constructor(e,t){super(e,t),this.manager=e,this.options=t}},vh=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)}},ls,Kc=class{constructor(e){this.options=e,ge(this,ls)}set controller(e){Ze(this,ls,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Oe(this,ls))==null||t.activate(e)}};ls=new WeakMap;var Ba=class extends We{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},bh=class{constructor(e){this.draggables=new Wa,this.droppables=new Wa,this.plugins=new di(e),this.sensors=new di(e),this.modifiers=new di(e)}register(e,t){if(e instanceof ht)return this.draggables.register(e.id,e);if(e instanceof pt)return this.droppables.register(e.id,e);if(e.prototype instanceof Ba)return this.modifiers.register(e,t);if(e.prototype instanceof xn)return this.sensors.register(e,t);if(e.prototype instanceof We)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Gs)return e instanceof ht?this.draggables.unregister(e.id,e):e instanceof pt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Ba)return this.modifiers.unregister(e);if(e.prototype instanceof xn)return this.sensors.unregister(e);if(e.prototype instanceof We)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()}},Uc,Vc,Hc,Xc,Yc,Zc,Qc,Jc,ed,Hn,cs,cn,$e,Go,qo,Ko,Uo,Vo,Xn;ed=[Ee],Jc=[fe],Qc=[fe],Zc=[fe],Yc=[fe],Xc=[fe],Hc=[Ee],Vc=[Ee],Uc=[Ee];var ct=class{constructor(e){le($e,5,this),ge(this,Hn),ge(this,cs),ge(this,cn,new Yt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new kt,ge(this,Go,le($e,8,this,!1)),le($e,11,this),ge(this,qo,le($e,12,this,null)),le($e,15,this),ge(this,Ko,le($e,16,this,null)),le($e,19,this),ge(this,Uo,le($e,20,this,null)),le($e,23,this),ge(this,Vo,le($e,24,this,[])),le($e,27,this),this.position=new Bs({x:0,y:0}),ge(this,Xn,{x:0,y:0}),Ze(this,Hn,e)}get shape(){const{current:e,initial:t,previous:n}=Oe(this,cn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Oe(this,cn).current=e:Oe(this,cn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Oe(this,Hn).registry.draggables.get(t);return n&&Ze(this,cs,n),(e=n??Oe(this,cs))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Oe(this,Hn).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(Oo(To({},this.snapshot()),{transform:n}));return Ze(this,Xn,n),n}snapshot(){return ue(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Oe(this,Xn),shape:this.shape?ci(this.shape):null,position:ci(this.position),status:ci(this.status),canceled:this.canceled}))}reset(){Te(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Oe(this,cn).reset(),this.position.reset({x:0,y:0}),Ze(this,Xn,{x:0,y:0}),this.modifiers=[]})}};$e=Dn(null);Hn=new WeakMap;cs=new WeakMap;cn=new WeakMap;Go=new WeakMap;qo=new WeakMap;Ko=new WeakMap;Uo=new WeakMap;Vo=new WeakMap;Xn=new WeakMap;he($e,2,"shape",ed,ct);he($e,4,"canceled",Jc,ct,Go);he($e,4,"activatorEvent",Qc,ct,qo);he($e,4,"sourceIdentifier",Zc,ct,Ko);he($e,4,"targetIdentifier",Yc,ct,Uo);he($e,4,"modifiers",Xc,ct,Vo);he($e,2,"source",Hc,ct);he($e,2,"target",Vc,ct);he($e,2,"transform",Uc,ct);Zt($e,ct);var yh={get rendering(){return Promise.resolve()}};function lt(e,t){return typeof e=="function"?e(t):e??t}var xh=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=lt(r.plugins,[]),i=lt(r.sensors,[]),o=lt(r.modifiers,[]),a=(n=r.renderer)!=null?n:yh,l=new ph(this),u=new bh(this);this.registry=u,this.monitor=l,this.renderer=a,this.actions=new mh(this),this.dragOperation=new ct(this),this.collisionObserver=new fh(this),this.plugins=[gh,...s],this.modifiers=o,this.sensors=i;const{destroy:c}=this,d=Er(()=>{var f,p,h;const v=ue(()=>this.dragOperation.modifiers),y=this.modifiers;for(const w of v)y.includes(w)||w.destroy();this.dragOperation.modifiers=(h=(p=(f=this.dragOperation.source)==null?void 0:f.modifiers)==null?void 0:p.map(w=>{const{plugin:g,options:m}=pr(w);return new g(this,m)}))!=null?h:y});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}},td=e=>{throw TypeError(e)},Ho=(e,t,n)=>t.has(e)||td("Cannot "+n),ae=(e,t,n)=>(Ho(e,t,"read from private field"),t.get(e)),Ve=(e,t,n)=>t.has(e)?td("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ye=(e,t,n,r)=>(Ho(e,t,"write to private field"),t.set(e,n),n),nd=(e,t,n)=>(Ho(e,t,"access private method"),n);function qs(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function rd(e,t){const n=e.getAnimations();let r=null;for(const s of n){if(s.playState!=="running")continue;const{effect:i}=s,a=(qs(i)?i.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],s])}return r}function Ks(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 Xo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Ar(e){return"nodeType"in e}function Qe(e){var t,n,r;return e?Xo(e)?e:Ar(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 Yo(e){const{Document:t}=Qe(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Pt(e){return!e||Xo(e)?!1:e instanceof Qe(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function sd(e){return e instanceof Qe(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function Mn(e){return e?Xo(e)?e.document:Ar(e)?Yo(e)?e:Pt(e)||sd(e)?e.ownerDocument:document:document:document}function wh(e){var t,n,r,s;const{documentElement:i}=Mn(e),o=Qe(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 _h(e,t){if(kh(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function kh(e){return e.tagName==="DETAILS"}function mr(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(!_h(d)){const m=d.getBoundingClientRect(),b=n*(m.bottom-m.top),_=n*(m.right-m.left),O=n*(m.bottom-m.top),E=n*(m.right-m.left);l={top:Math.max(l.top,m.top-b),right:Math.min(l.right,m.right+_),bottom:Math.min(l.bottom,m.bottom+O),left:Math.max(l.left,m.left-E),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,h=(i=f?.offsetLeft)!=null?i:0,v=(o=f?.width)!=null?o:c.innerWidth,y=(a=f?.height)!=null?a:c.innerHeight,w=n*y,g=n*v;return l={top:Math.max(l.top,p-w),right:Math.min(l.right,h+v+g),bottom:Math.min(l.bottom,p+y+w),left:Math.max(l.left,h-g),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 wn(e){return{x:e.clientX,y:e.clientY}}var id=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ki(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(...Ki(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(...Ki(s.document,t))}}catch{}return n}function Zo(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function od(){var e,t;const n=Zo()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Qo(e){return!e||!Ar(e)?!1:e instanceof Qe(e).ShadowRoot}function ks(e){if(e&&Ar(e)){let t=e.getRootNode();if(Qo(t))return t;if(t instanceof Document)return t}return Mn(e)}function Jo(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Sh(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(Ga(i)&&Ga(a)&&(i.type!=="file"&&(i.value=a.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),qa(i)&&qa(a)&&a.width>0&&a.height>0){const l=i.getContext("2d");l?.drawImage(a,0,0)}}),n}function Ga(e){return"value"in e}function qa(e){return e.tagName==="CANVAS"}function ad(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if($h(r)){const{contentDocument:s}=r;if(s){const{left:i,top:o}=r.getBoundingClientRect();return ad(s,{x:t-i,y:n-o})}}return r}function $h(e){return e?.tagName==="IFRAME"}var Ui=new WeakMap;function Th(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 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) [${
|
|
8
|
+
`)}var ld=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 _n(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Oh(e){const t=new Set;let n=_n(e);for(;n;)t.add(n),n=_n(n);return t}function Eh(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function cd(e,t){const n=()=>performance.now();let r,s;return function(...i){const o=this;s?(r?.(),r=Eh(()=>{e.apply(o,i),s=n()},t-(n()-s))):(e.apply(o,i),s=n())}}function Ch(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 Ih(e,t=e.getBoundingClientRect()){const{width:n,height:r}=mr(e,t);return n>0&&r>0}var Dh=id?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ds,Ah=class extends Dh{constructor(e){super(t=>{if(!ae(this,ds)){Ye(this,ds,!0);return}e(t,this)}),Ve(this,ds,!1)}};ds=new WeakMap;var Ka=Array.from({length:100},(e,t)=>t/100),dd=75,Ft,Ss,$t,zt,Yn,Ne,cr,Zn,$s,ud,fd,hd=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,Ve(this,$s),this.disconnect=()=>{var i,o,a;Ye(this,cr,!0),(i=ae(this,$t))==null||i.disconnect(),(o=ae(this,zt))==null||o.disconnect(),ae(this,Yn).disconnect(),(a=ae(this,Ne))==null||a.remove()},Ve(this,Ft,!0),Ve(this,Ss),Ve(this,$t),Ve(this,zt),Ve(this,Yn),Ve(this,Ne),Ve(this,cr,!1),Ve(this,Zn,cd(()=>{var i,o,a;const{element:l}=this;if((i=ae(this,zt))==null||i.disconnect(),ae(this,cr)||!ae(this,Ft)||!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=mr(l,f),{top:h,left:v,bottom:y,right:w}=p,g=-Math.floor(h),m=-Math.floor(v),b=-Math.floor(d-w),_=-Math.floor(c-y),O=`${g}px ${b}px ${_}px ${m}px`;this.boundingClientRect=f,Ye(this,zt,new IntersectionObserver(E=>{const[I]=E,{intersectionRect:T}=I;(I.intersectionRatio!==1?I.intersectionRatio:ft.intersectionRatio(T,mr(l)))!==1&&ae(this,Zn).call(this)},{threshold:Ka,rootMargin:O,root:u})),ae(this,zt).observe(l),nd(this,$s,ud).call(this)},dd)),this.boundingClientRect=e.getBoundingClientRect(),Ye(this,Ft,Ih(e,this.boundingClientRect));let r=!0;this.callback=i=>{r&&(r=!1,n.skipInitial)||t(i)};const s=e.ownerDocument;n?.debug&&(Ye(this,Ne,document.createElement("div")),ae(this,Ne).style.background="rgba(0,0,0,0.15)",ae(this,Ne).style.position="fixed",ae(this,Ne).style.pointerEvents="none",s.body.appendChild(ae(this,Ne))),Ye(this,Yn,new IntersectionObserver(i=>{var o,a;const l=i[i.length-1],{boundingClientRect:u,isIntersecting:c}=l,{width:d,height:f}=u,p=ae(this,Ft);Ye(this,Ft,c),!(!d&&!f)&&(p&&!c?((o=ae(this,zt))==null||o.disconnect(),this.callback(null),(a=ae(this,$t))==null||a.disconnect(),Ye(this,$t,void 0),ae(this,Ne)&&(ae(this,Ne).style.visibility="hidden")):ae(this,Zn).call(this),c&&!ae(this,$t)&&(Ye(this,$t,new Ah(ae(this,Zn))),ae(this,$t).observe(e)))},{threshold:Ka,root:s})),ae(this,Ft)&&!n.skipInitial&&this.callback(this.boundingClientRect),ae(this,Yn).observe(e)}};Ft=new WeakMap;Ss=new WeakMap;$t=new WeakMap;zt=new WeakMap;Yn=new WeakMap;Ne=new WeakMap;cr=new WeakMap;Zn=new WeakMap;$s=new WeakSet;ud=function(){ae(this,cr)||(nd(this,$s,fd).call(this),!Ch(this.boundingClientRect,ae(this,Ss))&&(this.callback(this.boundingClientRect),Ye(this,Ss,this.boundingClientRect)))};fd=function(){if(ae(this,Ne)){const{top:e,left:t,width:n,height:r}=mr(this.element);ae(this,Ne).style.overflow="hidden",ae(this,Ne).style.visibility="visible",ae(this,Ne).style.top=`${Math.floor(e)}px`,ae(this,Ne).style.left=`${Math.floor(t)}px`,ae(this,Ne).style.width=`${Math.floor(n)}px`,ae(this,Ne).style.height=`${Math.floor(r)}px`}};var qr=new WeakMap,Kr=new WeakMap;function Ph(e,t){let n=qr.get(e);return n||(n={disconnect:new hd(e,s=>{const i=qr.get(e);i&&i.callbacks.forEach(o=>o(s))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),qr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(qr.delete(e),n.disconnect())}}function Mh(e,t){const n=new Set;for(const r of e){const s=Ph(r,t);n.add(s)}return()=>n.forEach(r=>r())}function jh(e,t){var n;const r=e.ownerDocument;if(!Kr.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}),Kr.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:s,disconnect:i}=(n=Kr.get(r))!=null?n:{};return!s||!i?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(i(),Kr.delete(r))})}var Qn,Jn,us,Vi,Rh=class{constructor(e,t,n){this.callback=t,Ve(this,Qn),Ve(this,Jn,!1),Ve(this,us),Ve(this,Vi,cd(o=>{if(!ae(this,Jn)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of ae(this,us))if(o.target.contains(a)){this.callback(ae(this,Qn).boundingClientRect);break}}},dd));const r=Oh(e),s=Mh(r,t),i=jh(e,ae(this,Vi));Ye(this,us,r),Ye(this,Qn,new hd(e,t,n)),this.disconnect=()=>{ae(this,Jn)||(Ye(this,Jn,!0),s(),i(),ae(this,Qn).disconnect())}}};Qn=new WeakMap;Jn=new WeakMap;us=new WeakMap;Vi=new WeakMap;function Hi(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function mn(e){try{Hi(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function Ua(e){return!id||!e?!1:e===Mn(e).scrollingElement}function pd(e){var t,n;const r=Qe(e),s=Ua(e)?wh(e):Ks(e),i=r.visualViewport,o=Ua(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 Lh(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:i,position:o}=pd(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 ea=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))}},Ts=new ea(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Nh=new ea(e=>setTimeout(e,50)),Os=new Map,Fh=Os.clear.bind(Os);function gt(e,t=!1){if(!t)return Va(e);let n=Os.get(e);return n||(n=Va(e),Os.set(e,n),Nh.schedule(Fh),n)}function Va(e){return Qe(e).getComputedStyle(e)}function zh(e,t=gt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Wh(e,t=gt(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 Bh={excludeElement:!0,escapeShadowDOM:!0};function Xi(e,t=Bh){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,i=new Set;function o(a){if(n!=null&&i.size>=n||!a)return i;if(Yo(a)&&a.scrollingElement!=null&&!i.has(a.scrollingElement))return i.add(a.scrollingElement),i;if(s&&Qo(a))return o(a.host);if(!Pt(a))return sd(a)?o(a.parentElement):i;if(i.has(a))return i;const l=gt(a,!0);if(r&&a===e||Wh(a,l)&&i.add(a),zh(a,l)){const{scrollingElement:u}=a.ownerDocument;return u&&i.add(u),i}return o(a.parentNode)}return e?o(e):i}function kn(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=_n(e);for(;r;){if(r===t)return n;const s=Ks(r),{x:i,y:o}=Gh(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=_n(r)}return n}function Gh(e,t=Ks(e)){const n=Math.round(t.width),r=Math.round(t.height);if(Pt(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const s=gt(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function qh(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 vr(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 Us(e){var t,n,r,s,i,o,a,l,u;const{scale:c,transform:d,translate:f}=e,p=qh(c),h=vr(f),v=Kh(d);if(!v&&!p&&!h)return null;const y={x:(t=p?.x)!=null?t:1,y:(n=p?.y)!=null?n:1},w={x:(r=h?.x)!=null?r:0,y:(s=h?.y)!=null?s:0},g={x:(i=v?.x)!=null?i:0,y:(o=v?.y)!=null?o:0,scaleX:(a=v?.scaleX)!=null?a:1,scaleY:(l=v?.scaleY)!=null?l:1};return{x:w.x+g.x,y:w.y+g.y,z:(u=h?.z)!=null?u:0,scaleX:y.x*g.scaleX,scaleY:y.y*g.scaleY}}function Kh(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 tt=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(tt||{}),Uh={x:.2,y:.2},Vh={x:10,y:10};function Hh(e,t,n,r=25,s=Uh,i=Vh){const{x:o,y:a}=t,{rect:l,isTop:u,isBottom:c,isLeft:d,isRight:f}=pd(e),p=kn(e),h=gt(e,!0),v=Us(h),y=v!==null?v?.scaleX<0:!1,w=v!==null?v?.scaleY<0:!1,g=new ft(l.left*p.scaleX+p.x,l.top*p.scaleY+p.y,l.width*p.scaleX,l.height*p.scaleY),m={x:0,y:0},b={x:0,y:0},_={height:g.height*s.y,width:g.width*s.x};return _.height>0&&(!u||w&&!c)&&a<=g.top+_.height&&n?.y!==1&&o>=g.left-i.x&&o<=g.right+i.x?(m.y=w?1:-1,b.y=r*Math.abs((g.top+_.height-a)/_.height)):_.height>0&&(!c||w&&!u)&&a>=g.bottom-_.height&&n?.y!==-1&&o>=g.left-i.x&&o<=g.right+i.x&&(m.y=w?-1:1,b.y=r*Math.abs((g.bottom-_.height-a)/_.height)),_.width>0&&(!f||y&&!d)&&o>=g.right-_.width&&n?.x!==-1&&a>=g.top-i.y&&a<=g.bottom+i.y?(m.x=y?-1:1,b.x=r*Math.abs((g.right-_.width-o)/_.width)):_.width>0&&(!d||y&&!f)&&o<=g.left+_.width&&n?.x!==1&&a>=g.top-i.y&&a<=g.bottom+i.y&&(m.x=y?1:-1,b.x=r*Math.abs((g.left+_.width-o)/_.width)),{direction:m,speed:b}}function gd(e,{block:t="nearest",inline:n="nearest"}={}){if(!Pt(e))return;const r=Xi(e),s=[];for(const i of r){if(!Pt(i))continue;const{top:o,left:a}=Xh(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 Ha(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const s=r.offsetParent;if(!Pt(s))break;t+=s.clientTop,n+=s.clientLeft,r=s}return{top:t,left:n}}function Xh(e,t){const n=Ha(e),r=Ha(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function Yh(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 Zh(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 md({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function Xa(e,t=gt(e).translate,n=!0){if(n){const r=rd(e,s=>"translate"in s);if(r){const{translate:s=""}=r[0];if(typeof s=="string"){const i=vr(s);if(i)return i}}}if(t){const r=vr(t);if(r)return r}return{x:0,y:0,z:0}}var Qh=new ea(e=>setTimeout(e,0)),dr=new Map,Jh=dr.clear.bind(dr);function ep(e){const t=e.ownerDocument;let n=dr.get(t);if(n)return n;n=t.getAnimations(),dr.set(t,n),Qh.schedule(Jh);const r=n.filter(s=>qs(s.effect)&&s.effect.target===e);return dr.set(e,r),n}function tp(e,t){const n=ep(e).filter(r=>{var s,i;if(qs(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 ut=class extends ft{constructor(e,t={}){var n,r,s,i;const{frameTransform:o=kn(e),ignoreTransforms:a,getBoundingClientRect:l=Ks}=t,u=tp(e,{properties:["transform","translate","scale","width","height"],isValidTarget:_=>(_!==e||Zo())&&_.contains(e)}),c=l(e);let{top:d,left:f,width:p,height:h}=c,v;const y=gt(e),w=Us(y),g={x:(n=w?.scaleX)!=null?n:1,y:(r=w?.scaleY)!=null?r:1},m=np(e,y);u?.(),w&&(v=Zh(c,w,y.transformOrigin),(a||m)&&(d=v.top,f=v.left,p=v.width,h=v.height));const b={width:(s=v?.width)!=null?s:p,height:(i=v?.height)!=null?i:h};if(m&&!a&&v){const _=Yh(v,m,y.transformOrigin);d=_.top,f=_.left,p=_.width,h=_.height,g.x=m.scaleX,g.y=m.scaleY}o&&(a||(f*=o.scaleX,p*=o.scaleX,d*=o.scaleY,h*=o.scaleY),f+=o.x,d+=o.y),super(f,d,p,h),this.scale=g,this.intrinsicWidth=b.width,this.intrinsicHeight=b.height}};function np(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=qs(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?Us({transform:r??t.transform,translate:s??t.translate,scale:i??t.scale}):null}function ur(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 rp=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(ur(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(ur(n))for(const r of e){const s=`${t}${r}`;n.style.removeProperty(s)}}reset(){const{element:e}=this;if(ur(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function Ut(e){return e?e instanceof Qe(e).Element||Ar(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function br(e){if(!e)return!1;const{KeyboardEvent:t}=Qe(e.target);return e instanceof t}function sp(e){if(!e)return!1;const{PointerEvent:t}=Qe(e.target);return e instanceof t}function ip(e){if(!Ut(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||op(e)}function op(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var ui={};function Yi(e){const t=ui[e]==null?0:ui[e]+1;return ui[e]=t,`${e}-${t}`}var ta=({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=et.distance(t.shape.center,n);return{id:r,value:1/s,type:Pn.PointerIntersection,priority:An.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:s}=e,i=et.distance(t.shape.center,s.current),a=r/(n.current.area+t.shape.area-r)/i;return{id:t.id,value:a,type:Pn.ShapeIntersection,priority:An.Normal}}return null},vd=e=>{var t;return(t=ta(e))!=null?t:ap(e)},lp=e=>{const{dragOperation:t,droppable:n}=e,{shape:r,position:s}=t;if(!n.shape)return null;const i=r?ft.from(r.current.boundingRectangle).corners:void 0,a=ft.from(n.shape.boundingRectangle).corners.reduce((l,u,c)=>{var d;return l+et.distance(et.from(u),(d=i?.[c])!=null?d:s.current)},0)/4;return{id:n.id,value:1/a,type:Pn.Collision,priority:An.Normal}},cp=Object.create,na=Object.defineProperty,dp=Object.defineProperties,up=Object.getOwnPropertyDescriptor,fp=Object.getOwnPropertyDescriptors,Es=Object.getOwnPropertySymbols,bd=Object.prototype.hasOwnProperty,yd=Object.prototype.propertyIsEnumerable,xd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),jn=e=>{throw TypeError(e)},Zi=(e,t,n)=>t in e?na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yr=(e,t)=>{for(var n in t||(t={}))bd.call(t,n)&&Zi(e,n,t[n]);if(Es)for(var n of Es(t))yd.call(t,n)&&Zi(e,n,t[n]);return e},ra=(e,t)=>dp(e,fp(t)),Ya=(e,t)=>na(e,"name",{value:t,configurable:!0}),wd=(e,t)=>{var n={};for(var r in e)bd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Es)for(var r of Es(e))t.indexOf(r)<0&&yd.call(e,r)&&(n[r]=e[r]);return n},Rn=e=>{var t;return[,,,cp((t=e?.[xd("metadata")])!=null?t:null)]},_d=["class","method","getter","setter","accessor","field","value","get","set"],er=e=>e!==void 0&&typeof e!="function"?jn("Function expected"):e,hp=(e,t,n,r,s)=>({kind:_d[e],name:t,metadata:r,addInitializer:i=>n._?jn("Already initialized"):s.push(er(i||null))}),Qt=(e,t)=>Zi(t,xd("metadata"),e[3]),Me=(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},it=(e,t,n,r,s,i)=>{var o,a,l,u,c,d=t&7,f=!!(t&8),p=!!(t&16),h=d>3?e.length+1:d?f?1:2:0,v=_d[d+5],y=d>3&&(e[h-1]=[]),w=e[h]||(e[h]=[]),g=d&&(!p&&!f&&(s=s.prototype),d<5&&(d>3||!p)&&up(d<4?s:{get[n](){return ye(this,i)},set[n](b){return qe(this,i,b)}},n));d?p&&d<4&&Ya(i,(d>2?"set ":d>1?"get ":"")+n):Ya(s,n);for(var m=r.length-1;m>=0;m--)u=hp(d,n,l={},e[3],w),d&&(u.static=f,u.private=p,c=u.access={has:p?b=>pp(s,b):b=>n in b},d^3&&(c.get=p?b=>(d^1?ye:Vt)(b,s,d^4?i:g.get):b=>b[n]),d>2&&(c.set=p?(b,_)=>qe(b,s,_,d^4?i:g.set):(b,_)=>b[n]=_)),a=(0,r[m])(d?d<4?p?i:g[v]:d>4?void 0:{get:g.get,set:g.set}:s,u),l._=1,d^4||a===void 0?er(a)&&(d>4?y.unshift(a):d?p?i=a:g[v]=a:s=a):typeof a!="object"||a===null?jn("Object expected"):(er(o=a.get)&&(g.get=o),er(o=a.set)&&(g.set=o),er(o=a.init)&&y.unshift(o));return d||Qt(e,s),g&&na(s,n,g),p?d^4?i:g:s},sa=(e,t,n)=>t.has(e)||jn("Cannot "+n),pp=(e,t)=>Object(t)!==t?jn('Cannot use the "in" operator on this value'):e.has(t),ye=(e,t,n)=>(sa(e,t,"read from private field"),n?n.call(e):t.get(e)),Ce=(e,t,n)=>t.has(e)?jn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qe=(e,t,n,r)=>(sa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Vt=(e,t,n)=>(sa(e,t,"access private method"),n),Za={role:"button",roleDescription:"draggable"},gp="dnd-kit-description",mp="dnd-kit-announcement",vp={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."},bp={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 yp(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function xp(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function wp(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 _p=["dragover","dragmove"],kp=class extends We{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=gp,announcement:s=mp}={},announcements:i=bp,screenReaderInstructions:o=vp,debounce:a=500}=t??{},l=n?`${r}-${n}`:Yi(r),u=n?`${s}-${n}`:Yi(s);let c,d,f,p;const h=(_=p)=>{!f||!_||f?.nodeValue!==_&&(f.nodeValue=_)},v=()=>Ts.schedule(h),y=Sp(v,a),w=Object.entries(i).map(([_,O])=>this.manager.monitor.addEventListener(_,(E,I)=>{const T=f;if(!T)return;const D=O?.(E,I);D&&T.nodeValue!==D&&(p=D,_p.includes(_)?y():(v(),y.cancel()))})),g=()=>{let _=[];c?.isConnected||(c=xp(l,o.draggable),_.push(c)),d?.isConnected||(d=wp(u),f=document.createTextNode(""),d.appendChild(f),_.push(d)),_.length>0&&document.body.append(..._)},m=new Set;function b(){for(const _ of m)_()}this.registerEffect(()=>{var _;m.clear();for(const O of this.manager.registry.draggables.value){const E=(_=O.handle)!=null?_:O.element;if(E){(!c||!d)&&m.add(g),(!yp(E)||Zo())&&!E.hasAttribute("tabindex")&&m.add(()=>E.setAttribute("tabindex","0")),!E.hasAttribute("role")&&E.tagName.toLowerCase()!=="button"&&m.add(()=>E.setAttribute("role",Za.role)),E.hasAttribute("aria-roledescription")||m.add(()=>E.setAttribute("aria-roledescription",Za.roleDescription)),E.hasAttribute("aria-describedby")||m.add(()=>E.setAttribute("aria-describedby",l));for(const T of["aria-pressed","aria-grabbed"]){const D=String(O.isDragging);E.getAttribute(T)!==D&&m.add(()=>E.setAttribute(T,D))}const I=String(O.disabled);E.getAttribute("aria-disabled")!==I&&m.add(()=>E.setAttribute("aria-disabled",I))}}m.size>0&&Ts.schedule(b)}),this.destroy=()=>{super.destroy(),c?.remove(),d?.remove(),w.forEach(_=>_())}}};function Sp(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var Cs=new Map,kd,Sd,$d,Td,Qi,fr,xt,ia,Sn,Od,Ed,Cd,Id,Mt=class extends(Qi=Dr,Td=[fe],$d=[Ee],Sd=[Ee],kd=[Ee],Qi){constructor(t,n){super(t,n),Me(xt,5,this),Ce(this,Sn),Ce(this,fr,new Set),Ce(this,ia,Me(xt,8,this,new Set)),Me(xt,11,this),this.registerEffect(Vt(this,Sn,Od))}register(t){return ye(this,fr).add(t),()=>{ye(this,fr).delete(t)}}addRoot(t){return ue(()=>{const n=new Set(this.additionalRoots);n.add(t),this.additionalRoots=n}),()=>{ue(()=>{const n=new Set(this.additionalRoots);n.delete(t),this.additionalRoots=n})}}get sourceRoot(){var t;const{source:n}=this.manager.dragOperation;return ks((t=n?.element)!=null?t:null)}get targetRoot(){var t;const{target:n}=this.manager.dragOperation;return ks((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}};xt=Rn(Qi);fr=new WeakMap;ia=new WeakMap;Sn=new WeakSet;Od=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of ye(this,fr))t.push(Vt(this,Sn,Ed).call(this,n,r));return()=>{for(const n of t)n()}};Ed=function(e,t){let n=Cs.get(e);n||(n=new Map,Cs.set(e,n));let r=n.get(t);if(!r){const i=Yo(e)?Vt(this,Sn,Cd).call(this,e,n,t):Vt(this,Sn,Id).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())}};Cd=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&&Cs.delete(e)}}};Id=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(Qo(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&&Cs.delete(e)}}};it(xt,4,"additionalRoots",Td,Mt,ia);it(xt,2,"sourceRoot",$d,Mt);it(xt,2,"targetRoot",Sd,Mt);it(xt,2,"roots",kd,Mt);Qt(xt,Mt);Mt.configure=Ir(Mt);var Vs=Mt,$p=class extends We{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(Vs),s=r?.register(`* { cursor: ${n} !important; }`);if(s){const i=this.destroy.bind(this);this.destroy=()=>{s(),i()}}}},Pr="data-dnd-",Ji=`${Pr}dropping`,Le="--dnd-",dt=`${Pr}dragging`,Is=`${Pr}placeholder`,Tp=[dt,Is,"popover","aria-pressed","aria-grabbing"],Op=["view-transition-name"],Ep=`
|
|
9
|
+
:is(:root,:host) [${dt}] {
|
|
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(${Le}top, 0px) !important;
|
|
16
|
+
left: var(${Le}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(${Le}width, auto);
|
|
20
|
+
max-width: var(${Le}width, auto);
|
|
21
|
+
height: var(${Le}height, auto);
|
|
22
|
+
max-height: var(${Le}height, auto);
|
|
23
|
+
transform: var(${Le}transform, none) !important;
|
|
24
|
+
transition: var(${Le}transition) !important;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
:is(:root,:host) [${
|
|
27
|
+
:is(:root,:host) [${Is}] {
|
|
28
28
|
transition: none;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
:is(:root,:host) [${
|
|
31
|
+
:is(:root,:host) [${Is}='hidden'] {
|
|
32
32
|
visibility: hidden;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
[${
|
|
35
|
+
[${dt}] * {
|
|
36
36
|
pointer-events: none !important;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
[${
|
|
40
|
-
translate: var(${
|
|
39
|
+
[${dt}]:not([${Ji}]) {
|
|
40
|
+
translate: var(${Le}translate) !important;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
[${
|
|
44
|
-
scale: var(${
|
|
45
|
-
transform-origin: var(${
|
|
43
|
+
[${dt}][style*='${Le}scale'] {
|
|
44
|
+
scale: var(${Le}scale) !important;
|
|
45
|
+
transform-origin: var(${Le}transform-origin) !important;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
@layer dnd-kit {
|
|
49
|
-
:where([${
|
|
49
|
+
:where([${dt}][popover]) {
|
|
50
50
|
overflow: visible;
|
|
51
51
|
background: unset;
|
|
52
52
|
border: unset;
|
|
@@ -60,139 +60,136 @@
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
[${
|
|
63
|
+
[${dt}]::backdrop, [${Pr}overlay]:not([${dt}]) {
|
|
64
64
|
display: none;
|
|
65
65
|
visibility: hidden;
|
|
66
66
|
}
|
|
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
|
|
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
|
|
70
|
-
`),c=f=>l.lines.has(f);a.proseLines=
|
|
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
|
|
72
|
-
`]:[];o.push({...l.name===void 0?{}:{name:l.name},route:l.route,body:[...
|
|
73
|
-
`).replace(/\n$/,""),span:{start:e.lineStarts[f],end:p},line:f}),a=c}return o}function
|
|
67
|
+
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Cp(e,t="hidden"){return ue(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=Ip(n,r.registry.droppables),i=[],o=Sh(n),{remove:a}=o;return Dp(s,o,i),Ap(o,t),o.remove=()=>{i.forEach(l=>l()),a.call(o)},o})}function Ip(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${Pr}${Yi("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),Ui.set(a,o),n.push(()=>{Ui.delete(a),r.proxy=void 0})}}function Ap(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Is,t)}function Dd(e,t){return e===t?!0:_n(e)===_n(t)}function Qa(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&Ut(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>mn(t))}function eo(e){return e.tagName==="TR"}function Pp(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-")||Tp.includes(a))continue;const l=e.getAttribute(a);if(a==="style"){if(ur(e)&&ur(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(Le))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 Mp(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),mn(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),mn(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement("afterend",t),mn(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function jp(e){return new ResizeObserver(()=>{var t,n,r;const s=new ut(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=od();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},Le),(n=e.getElementMutationObserver())==null||n.takeRecords(),eo(e.element)&&eo(e.placeholder)){const v=Array.from(e.element.cells),y=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(v.map(w=>w.style.width));for(const[w,g]of v.entries()){const m=y[w];g.style.width=`${m.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,h=e.frameTransform;e.dragOperation.shape=new ft(c*h.scaleX+h.x,d*h.scaleY+h.y,f*h.scaleX,p*h.scaleY)})}var Rp=250,Lp="ease";function Np(e){var t,n,r,s;const{animation:i}=e;if(typeof i=="function"){const g=i({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(g).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=Rp,easing:a=Lp}=i??{};mn(e.feedbackElement);const[,l]=(t=rd(e.feedbackElement,g=>"translate"in g))!=null?t:[];l?.pause();const u=(n=e.placeholder)!=null?n:e.element,c={frameTransform:Dd(e.feedbackElement,u)?null:void 0},d=new ut(e.feedbackElement,c),f=(r=vr(gt(e.feedbackElement).translate))!=null?r:e.translate,p=new ut(u,c),h=ft.delta(d,p,e.alignment),v={x:f.x-h.x,y:f.y-h.y},y=Math.round(d.intrinsicHeight)!==Math.round(p.intrinsicHeight)?{minHeight:[`${d.intrinsicHeight}px`,`${p.intrinsicHeight}px`],maxHeight:[`${d.intrinsicHeight}px`,`${p.intrinsicHeight}px`]}:{},w=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},Le),e.feedbackElement.setAttribute(Ji,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),md({element:e.feedbackElement,keyframes:ra(yr(yr({},y),w),{translate:[`${f.x}px ${f.y}px 0`,`${v.x}px ${v.y}px 0`]}),options:{duration:Jo(Qe(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(Ji),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Ad,to,xr,oa,fs,Pd,Md,$n=class extends(to=We,Ad=[fe],to){constructor(t,n){super(t,n),Ce(this,fs),Ce(this,oa,Me(xr,8,this)),Me(xr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(Vs),s=r?.register(Ep);if(s){const i=this.destroy.bind(this);this.destroy=()=>{s(),i()}}this.registerEffect(Vt(this,fs,Pd).bind(this,r)),this.registerEffect(Vt(this,fs,Md))}};xr=Rn(to);oa=new WeakMap;fs=new WeakSet;Pd=function(e){const{overlay:t}=this;if(!t||!e)return;const n=ks(t);if(n)return e.addRoot(n)};Md=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:h}=f,v=f.pluginConfig($n),y=(t=(e=v?.feedback)!=null?e:u?.feedback)!=null?t:"default",w=typeof y=="function"?y(f,l):y;if(!h||w==="none"||!p.initialized||p.initializing)return;const{initial:g}=a,m=(n=this.overlay)!=null?n:h,b=kn(m),_=kn(h),O=!Dd(h,m),E=new ut(h,{frameTransform:O?_:null,ignoreTransforms:!O}),I={x:_.scaleX/b.scaleX,y:_.scaleY/b.scaleY};let{width:T,height:D,top:L,left:R}=E;O&&(T=T/I.x,D=D/I.y);const z=new rp(m),K=gt(h),{transition:G,translate:X,boxSizing:Y,paddingBlockStart:se,paddingBlockEnd:te,paddingInlineStart:A,paddingInlineEnd:B,borderInlineStartWidth:N,borderInlineEndWidth:j,borderBlockStartWidth:q,borderBlockEndWidth:J}=K,ee=G.split(",").filter(be=>!/^\s*(transform|translate|scale)\b/.test(be)).join(","),H=Us(K),S=K.transform,P=w==="clone",F=Y==="content-box",V=F?parseInt(A)+parseInt(B)+parseInt(N)+parseInt(j):0,ie=F?parseInt(se)+parseInt(te)+parseInt(q)+parseInt(J):0,Z=w!=="move"&&!this.overlay?Cp(f,P?"clone":"hidden"):null,oe=ue(()=>br(l.dragOperation.activatorEvent));if(!g.translate){if(this.overlay&&H)g.translate={x:H.x,y:H.y};else if(X!=="none"){const be=vr(X);be&&(g.translate=be)}}if(!g.transformOrigin){const be=ue(()=>d.current),Ie=R+((r=H?.x)!=null?r:0),He=L+((s=H?.y)!=null?s:0);g.transformOrigin={x:(be.x-Ie*b.scaleX-b.x)/(T*b.scaleX),y:(be.y-He*b.scaleY-b.y)/(D*b.scaleY)}}const{transformOrigin:W}=g,Q=L*b.scaleY+b.y,ne=R*b.scaleX+b.x;if(!g.coordinates&&(g.coordinates={x:ne,y:Q},I.x!==1||I.y!==1)){const{scaleX:be,scaleY:Ie}=_,{x:He,y:St}=W;g.coordinates.x+=(T*be-T)*He,g.coordinates.y+=(D*Ie-D)*St}g.dimensions||(g.dimensions={width:T,height:D}),g.frameTransform||(g.frameTransform=b);const re={x:g.coordinates.x-ne,y:g.coordinates.y-Q},ce={width:(g.dimensions.width*g.frameTransform.scaleX-T*b.scaleX)*W.x,height:(g.dimensions.height*g.frameTransform.scaleY-D*b.scaleY)*W.y},pe={x:re.x/b.scaleX+ce.width,y:re.y/b.scaleY+ce.height},M={left:R+pe.x,top:L+pe.y};m.setAttribute(dt,"true");const U=ue(()=>c.transform),de=(i=g.translate)!=null?i:{x:0,y:0},ve=U.x*b.scaleX+de.x,Re=U.y*b.scaleY+de.y,Nn=od();z.set({width:T-V,height:D-ie,top:M.top+Nn.y,left:M.left+Nn.x,translate:`${ve}px ${Re}px 0`,transform:this.overlay?"none":S,transition:ee?`${ee}, translate 0ms linear`:"translate 0ms linear",scale:O?`${I.x} ${I.y}`:"","transform-origin":`${W.x*100}% ${W.y*100}%`},Le),Z&&(h.insertAdjacentElement("afterend",Z),u?.rootElement&&(typeof u.rootElement=="function"?u.rootElement(f):u.rootElement).appendChild(h)),Hi(m)&&(m.hasAttribute("popover")||m.setAttribute("popover","manual"),mn(m),m.addEventListener("beforetoggle",Qa));let mt,Fn,vt;const Sa=jp({placeholder:Z,element:h,feedbackElement:m,frameTransform:b,transformOrigin:W,width:T,height:D,top:L,left:R,widthOffset:V,heightOffset:ie,delta:pe,styles:z,dragOperation:c,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>mt,getSavedCellWidths:()=>vt,setSavedCellWidths:be=>{vt=be}}),$a=new ut(m);ue(()=>c.shape=$a);const ei=Qe(m),Ta=be=>{this.manager.actions.stop({event:be})},Ju=Jo(ei);oe&&ei.addEventListener("resize",Ta),ue(()=>f.status)==="idle"&&requestAnimationFrame(()=>f.status="dragging"),Z&&(Sa.observe(Z),mt=Pp(h,Z,P),Fn=Mp(h,Z,m));const Oa=(o=l.dragOperation.source)==null?void 0:o.id,ef=()=>{var be;if(!oe||Oa==null)return;const Ie=l.registry.draggables.get(Oa),He=(be=Ie?.handle)!=null?be:Ie?.element;Pt(He)&&He.focus()},ti=()=>{mt?.disconnect(),Fn?.disconnect(),Sa.disconnect(),ei.removeEventListener("resize",Ta),Hi(m)&&(m.removeEventListener("beforetoggle",Qa),m.removeAttribute("popover")),m.removeAttribute(dt),z.reset();const be=()=>{var Ie;if(vt&&eo(h)){const ni=Array.from(h.cells);for(const[zr,Jt]of ni.entries())Jt.style.width=(Ie=vt[zr])!=null?Ie:""}f.status="idle";const He=a.current.translate!=null,St=c.status.dragging;Z&&(!St&&He||Z.parentElement!==m.parentElement)&&m.isConnected&&Z.replaceWith(m),Z?.remove()};m===this.overlay?setTimeout(be,0):be()},tf=u?.dropAnimation,Ea=this,nf=Er(()=>{var be,Ie,He;const{transform:St,status:ni}=c;if(!(!St.x&&!St.y&&!a.current.translate)&&ni.dragging){const zr=(be=g.translate)!=null?be:{x:0,y:0},Jt={x:St.x/b.scaleX+zr.x,y:St.y/b.scaleY+zr.y},Ca=a.current.translate,rf=ue(()=>c.modifiers),ri=ue(()=>{var Wn;return(Wn=c.shape)==null?void 0:Wn.current}),zn=u?.keyboardTransition,Ia=oe&&!Ju&&zn!==null?`${(Ie=zn?.duration)!=null?Ie:250}ms ${(He=zn?.easing)!=null?He:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(z.set({transition:ee?`${ee}, translate ${Ia}`:`translate ${Ia}`,translate:`${Jt.x}px ${Jt.y}px 0`},Le),mt?.takeRecords(),ri&&ri!==$a&&Ca&&!rf.length){const Wn=et.delta(Jt,Ca);c.shape=ft.from(ri.boundingRectangle).translate(Wn.x*b.scaleX,Wn.y*b.scaleY)}else c.shape=new ut(m);a.current.translate=Jt}},function(){if(c.status.dropped){this.dispose(),f.status="dropping";const be=v?.dropAnimation!==void 0?v.dropAnimation:Ea.dropAnimation!==void 0?Ea.dropAnimation:tf;let Ie=a.current.translate;const He=Ie!=null;if(!Ie&&h!==m&&(Ie={x:0,y:0}),!Ie||be===null){ti();return}l.renderer.rendering.then(()=>{Np({source:f,element:h,feedbackElement:m,placeholder:Z,translate:Ie,moved:He,transition:G,alignment:f.alignment,styles:z,animation:be??void 0,getElementMutationObserver:()=>mt,cleanup:ti,restoreFocus:ef})})}});return()=>{ti(),nf()}};it(xr,4,"overlay",Ad,$n,oa);Qt(xr,$n);$n.configure=Ir($n);var aa=$n,Bn=!0,Fp=!1,jd,Rd,Ld,Nd,Et,la,ca;Nd=(Ld=[fe],tt.Forward),Rd=(jd=[fe],tt.Reverse);var wr=class{constructor(){Ce(this,la,Me(Et,8,this,Bn)),Me(Et,11,this),Ce(this,ca,Me(Et,12,this,Bn)),Me(Et,15,this)}isLocked(e){return e===tt.Idle?!1:e==null?this[tt.Forward]===Bn&&this[tt.Reverse]===Bn:this[e]===Bn}unlock(e){e!==tt.Idle&&(this[e]=Fp)}};Et=Rn(null);la=new WeakMap;ca=new WeakMap;it(Et,4,Nd,Ld,wr,la);it(Et,4,Rd,jd,wr,ca);Qt(Et,wr);var zp=[tt.Forward,tt.Reverse],Ja=class{constructor(){this.x=new wr,this.y=new wr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},Wp=class extends We{constructor(e){super(e);const t=Tn(new Ja);let n=null;this.signal=t,st(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Ja;return}const{delta:s}=e.dragOperation.position;if(n){const i={x:el(s.x,n.x),y:el(s.y,n.y)},o=t.peek();Te(()=>{for(const a of hc)for(const l of zp)i[a]===l&&o[a].unlock(l);t.value=o})}n=s})}get current(){return this.signal.peek()}};function el(e,t){return Math.sign(e-t)}var Fd,no,_r,da,Tt,ro,Mr=class extends(no=Dr,Fd=[fe],no){constructor(e){super(e),Ce(this,da,Me(_r,8,this,!1)),Me(_r,11,this),Ce(this,Tt),Ce(this,ro,()=>{if(!ye(this,Tt))return;const{element:i,by:o}=ye(this,Tt);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 qe(this,Tt,void 0),!1;const{position:u}=this.manager.dragOperation,c=u?.current;if(c){const{by:d}=i??{},f=d?{x:tl(d.x),y:tl(d.y)}:void 0,p=f?void 0:this.scrollIntentTracker.current;if(p?.isLocked())return!1;for(const h of l){const v=Lh(h,d);if(v.x||v.y){const{speed:y,direction:w}=Hh(h,c,f,o?.acceleration,o?.threshold);if(p)for(const g of hc)p[g].isLocked(w[g])&&(y[g]=0,w[g]=0);if(w.x||w.y){const{x:g,y:m}=d??w,b=g*y.x,_=m*y.y;if(b||_){const O=(a=ye(this,Tt))==null?void 0:a.by;if(this.autoScrolling&&O&&(O.x&&!b||O.y&&!_))continue;return qe(this,Tt,{element:h,by:{x:b,y:_}}),Ts.schedule(ye(this,ro)),!0}}}}}return qe(this,Tt,void 0),!1};let t=null,n=null;const r=Ai(()=>{const{position:i,source:o}=e.dragOperation;if(!i)return null;const a=ad(ks(o?.element),i.current);return a&&(t=a),a??t}),s=Ai(()=>{const i=r.value,{documentElement:o}=Mn(i);if(!i||i===o){const{target:a}=e.dragOperation,l=a?.element;if(l){const u=Xi(l,{excludeElement:!1});return n=u,u}}if(i){const a=Xi(i,{excludeElement:!1});return this.autoScrolling&&n&&a.size<n?.size?n:(n=a,a)}return n=null,null},ot);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new Wp(e),this.destroy=e.monitor.addEventListener("dragmove",i=>{this.disabled||i.defaultPrevented||!br(e.dragOperation.activatorEvent)||!i.by||this.scroll({by:i.by})&&i.preventDefault()})}};_r=Rn(no);da=new WeakMap;Tt=new WeakMap;ro=new WeakMap;it(_r,4,"autoScrolling",Fd,Mr,da);Qt(_r,Mr);function tl(e){return e>0?tt.Forward:e<0?tt.Reverse:tt.Idle}var Bp=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))}},Gp=new Bp(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),qp=10,so=class extends We{constructor(t,n){super(t,n);const r=t.registry.plugins.get(Mr);if(!r)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=st(()=>{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(()=>Gp.schedule(()=>r.scroll(void 0,u)),qp);return()=>{clearInterval(d)}}else r.autoScrolling=!1}})}};so.configure=Ir(so);var zd=so,nl={capture:!0,passive:!0},tr,Kp=class extends Dr{constructor(e){super(e),Ce(this,tr),this.handleScroll=()=>{ye(this,tr)==null&&qe(this,tr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),qe(this,tr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=st(()=>{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,nl),()=>{o.removeEventListener("scroll",this.handleScroll,nl)}}})}};tr=new WeakMap;var Up="* { user-select: none !important; -webkit-user-select: none !important; }",Vp=class extends We{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(Vs),n=t?.register(Up);if(this.destroy=st(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return fi(),document.addEventListener("selectionchange",fi,{capture:!0}),()=>{document.removeEventListener("selectionchange",fi,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function fi(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var nr=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,Ds=class extends xn{constructor(t,n){super(t),this.manager=t,this.options=n,Ce(this,dn,[]),this.listeners=new ld,this.handleSourceKeyDown=(r,s,i)=>{if(this.disabled||r.defaultPrevented||!Ut(r.target)||s.disabled)return;const{keyboardCodes:o=nr.keyboardCodes,preventActivation:a=nr.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 st(()=>{var s;const i=(s=t.handle)!=null?s:t.element,o=a=>{br(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(),gd(s);const{center:i}=new ut(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=Mn(s),l=[this.listeners.bind(a,[{type:"keydown",listener:u=>this.handleKeyDown(u,n,r),options:{capture:!0}}])];ye(this,dn).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:s=nr.keyboardCodes}=r??{};if(en(t,[...s.end,...s.cancel])){t.preventDefault();const i=en(t,s.cancel);this.handleEnd(t,i);return}en(t,s.up)?this.handleMove("up",t):en(t,s.down)&&this.handleMove("down",t),en(t,s.left)?this.handleMove("left",t):en(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:nr.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(zd);t?.disabled===!1&&(t.disable(),ye(this,dn).push(()=>{t.enable()}))}cleanup(){ye(this,dn).forEach(t=>t()),qe(this,dn,[])}destroy(){this.cleanup(),this.listeners.clear()}};dn=new WeakMap;Ds.configure=Ir(Ds);Ds.defaults=nr;var Wd=Ds;function en(e,t){return t.includes(e.code)}var Wt,Hp=class extends Kc{constructor(){super(...arguments),Ce(this,Wt)}onEvent(e){switch(e.type){case"pointerdown":qe(this,Wt,wn(e));break;case"pointermove":if(!ye(this,Wt))return;const{x:t,y:n}=wn(e),r={x:t-ye(this,Wt).x,y:n-ye(this,Wt).y},{tolerance:s}=this.options;if(s&&Wi(r,s)){this.abort();return}Wi(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){qe(this,Wt,void 0)}};Wt=new WeakMap;var un,Bt,Xp=class extends Kc{constructor(){super(...arguments),Ce(this,un),Ce(this,Bt)}onEvent(e){switch(e.type){case"pointerdown":qe(this,Bt,wn(e)),qe(this,un,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!ye(this,Bt))return;const{x:t,y:n}=wn(e),r={x:t-ye(this,Bt).x,y:n-ye(this,Bt).y};Wi(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){ye(this,un)&&(clearTimeout(ye(this,un)),qe(this,Bt,void 0),qe(this,un,void 0))}};un=new WeakMap;Bt=new WeakMap;var gn=class{};gn.Delay=Xp;gn.Distance=Hp;var io=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:s}=e;if(!(r==="mouse"&&Ut(s)&&(t.handle===s||(n=t.handle)!=null&&n.contains(s))))return r==="touch"?[new gn.Delay({value:250,tolerance:5})]:ip(s)&&!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||!Ut(r)||(n=t.handle)!=null&&n.contains(r))return!1;const s=Th(r);return s===t.element?!1:!!s}}),fn,As=class extends xn{constructor(t,n){super(t),this.manager=t,this.options=n,Ce(this,fn,new Set),this.listeners=new ld,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=io.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return st(()=>{var s;const i=new AbortController,{signal:o}=i,a=u=>{sp(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&&(Qp(u.ownerDocument.defaultView),u.addEventListener("pointerdown",a,{signal:o}));return()=>i.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!Ut(t.target)||n.disabled||Yp(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=io.preventActivation}=r??{};if(s?.(t,n))return;const{target:i}=t,o=Pt(i)&&i.draggable&&i.getAttribute("draggable")==="true",a=kn(n.element),{x:l,y:u}=wn(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 vh(c,v=>this.handleStart(n,v));d.signal.onabort=()=>this.handleCancel(t),d.onEvent(t),this.controller=d;const f=Ki(),p=this.listeners.bind(f,[{type:"pointermove",listener:v=>this.handlePointerMove(v,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:Ur,options:{capture:!0}}]),h=()=>{p(),this.initialCoordinates=void 0};ye(this,fn).add(h)}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=wn(t),o=kn(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,Ts.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=Mn(n.target).body;try{a.setPointerCapture(n.pointerId)}catch{this.handleCancel(n);return}const l=Ut(n.target)?[n.target,a]:a,u=this.listeners.bind(l,[{type:"touchmove",listener:Ur,options:{passive:!1}},{type:"click",listener:Ur},{type:"contextmenu",listener:Ur},{type:"keydown",listener:this.handleKeyDown}]);ye(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},ye(this,fn).forEach(n=>n()),ye(this,fn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};fn=new WeakMap;As.configure=Ir(As);As.defaults=io;var oo=As;function Yp(e){return"sensor"in e}function Ur(e){e.preventDefault()}function Zp(){}var rl=new WeakSet;function Qp(e){!e||rl.has(e)||(e.addEventListener("touchmove",Zp,{capture:!1,passive:!1}),rl.add(e))}var vn={modifiers:[],plugins:[kp,zd,$p,aa,Vp],sensors:[oo,Wd]},Bd=class extends xh{constructor(e={}){const t=lt(e.plugins,vn.plugins),n=lt(e.sensors,vn.sensors),r=lt(e.modifiers,vn.modifiers);super(ra(yr({},e),{plugins:[Kp,Mr,Vs,...t],sensors:n,modifiers:r}))}},Gd,qd,ao,Ct,ua,fa,Hs=class extends(ao=ht,qd=[fe],Gd=[fe],ao){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:i}=n,o=wd(n,["element","effects","handle"]);super(yr({effects:()=>[...s(),()=>{var a,l;const{manager:u}=this;if(!u)return;const d=((l=(a=this.sensors)==null?void 0:a.map(pr))!=null?l:[...u.sensors]).map(f=>{const p=f instanceof xn?f:u.registry.register(f.plugin),h=f instanceof xn?void 0:f.options;return p.bind(this,h)});return function(){d.forEach(p=>p())}}]},o),t),Ce(this,ua,Me(Ct,8,this)),Me(Ct,11,this),Ce(this,fa,Me(Ct,12,this)),Me(Ct,15,this),this.element=r,this.handle=i}};Ct=Rn(ao);ua=new WeakMap;fa=new WeakMap;it(Ct,4,"handle",qd,Hs,ua);it(Ct,4,"element",Gd,Hs,fa);Qt(Ct,Hs);var Kd,Ud,lo,It,ha,hi,Vd,Hd,hr,pa,Xs=class extends(lo=pt,Ud=[fe],Kd=[fe],lo){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,i=wd(n,["element","effects"]);const{collisionDetector:o=vd}=i,a=u=>{const{manager:c,element:d}=this;if(!d||u===null){this.shape=void 0;return}if(!c)return;const f=new ut(d),p=ue(()=>this.shape);return f&&p?.equals(f)?p:(this.shape=f,f)},l=Tn(!1);super(ra(yr({},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 Rh(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),Ce(this,hr),Ce(this,ha,Me(It,8,this)),Me(It,11,this),Ce(this,pa,Me(It,12,this)),Me(It,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){qe(this,hr,e,Hd)}get element(){var e;return(e=this.proxy)!=null?e:ye(this,hr,Vd)}};It=Rn(lo);ha=new WeakMap;hr=new WeakSet;pa=new WeakMap;hi=it(It,20,"#element",Ud,hr,ha),Vd=hi.get,Hd=hi.set;it(It,4,"proxy",Kd,Xs,pa);Qt(It,Xs);function Jp(e){return e!=null&&typeof e=="object"&&"current"in e}function bn(e){var t;if(e!=null)return Jp(e)?(t=e.current)!=null?t:void 0:e}var eg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ln=eg?k.useLayoutEffect:k.useEffect;function tg(){const e=k.useState(0)[1];return k.useCallback(()=>{e(t=>t+1)},[e])}function Xd(e,t){const n=k.useRef(new Map),r=tg();return Ln(()=>{if(!e){n.current.clear();return}return st(()=>{var s;let i=!1,o=!1;for(const a of n.current){const[l]=a,u=ue(()=>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]),k.useMemo(()=>e&&new Proxy(e,{get(s,i){const o=s[i];return n.current.set(i,o),o}}),[e])}function ng(e,t){e()}function tn(e){const t=k.useRef(e);return Ln(()=>{t.current=e},[e]),t}function Se(e,t,n=k.useEffect,r=Object.is){const s=k.useRef(e);n(()=>{const i=s.current;r(e,i)||(s.current=e,t(e,i))},[t,e])}function hs(e,t){const n=k.useRef(bn(e));Ln(()=>{const r=bn(e);r!==n.current&&(n.current=r,t(r))})}var rg=Object.defineProperty,sg=Object.defineProperties,ig=Object.getOwnPropertyDescriptors,Ps=Object.getOwnPropertySymbols,Yd=Object.prototype.hasOwnProperty,Zd=Object.prototype.propertyIsEnumerable,sl=(e,t,n)=>t in e?rg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,og=(e,t)=>{for(var n in t||(t={}))Yd.call(t,n)&&sl(e,n,t[n]);if(Ps)for(var n of Ps(t))Zd.call(t,n)&&sl(e,n,t[n]);return e},ag=(e,t)=>sg(e,ig(t)),lg=(e,t)=>{var n={};for(var r in e)Yd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ps)for(var r of Ps(e))t.indexOf(r)<0&&Zd.call(e,r)&&(n[r]=e[r]);return n},cg=new Bd,Qd=k.createContext(cg),dg=k.memo(k.forwardRef(({children:e},t)=>{const[n,r]=k.useState(0),s=k.useRef(null),i=k.useRef(null),o=k.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})),k.startTransition(()=>{a(),r(l=>l+1)})}}),[]);return Ln(()=>{var a;(a=i.current)==null||a.call(i),s.current=null},[e,n]),k.useImperativeHandle(t,()=>o),null})),pi=[void 0,ot];function ug(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:i,onDragMove:o,onDragOver:a,onDragEnd:l}=t,u=lg(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const c=k.useRef(null),{plugins:d,modifiers:f,sensors:p}=u,h=lt(d,vn.plugins),v=lt(p,vn.sensors),y=lt(f,vn.modifiers),w=tn(s),g=tn(i),m=tn(a),b=tn(o),_=tn(l),O=tn(r),E=fg(()=>{var I;return(I=u.manager)!=null?I:new Bd(u)});return k.useEffect(()=>{if(!c.current)throw new Error("Renderer not found");const{renderer:I,trackRendering:T}=c.current,{monitor:D}=E;E.renderer=I;const L=[D.addEventListener("beforedragstart",R=>{const z=w.current;z&&T(()=>z(R,E))}),D.addEventListener("dragstart",R=>{var z;return(z=g.current)==null?void 0:z.call(g,R,E)}),D.addEventListener("dragover",R=>{const z=m.current;z&&T(()=>z(R,E))}),D.addEventListener("dragmove",R=>{const z=b.current;z&&T(()=>z(R,E))}),D.addEventListener("dragend",R=>{const z=_.current;z&&T(()=>z(R,E))}),D.addEventListener("collision",R=>{var z;return(z=O.current)==null?void 0:z.call(O,R,E)})];return()=>L.forEach(R=>R())},[E]),Se(h,()=>E&&(E.plugins=h),...pi),Se(v,()=>E&&(E.sensors=v),...pi),Se(y,()=>E&&(E.modifiers=y),...pi),x.jsxs(Qd.Provider,{value:E,children:[x.jsx(dg,{ref:c,children:n}),n]})}function fg(e){const t=k.useRef(null);return t.current||(t.current=e()),k.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}function hg(){return k.useContext(Qd)}function Jd(e){var t;const n=(t=hg())!=null?t:void 0,[r]=k.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Ln(r.register,[n,r]),r}var pg=Object.create,eu=Object.defineProperty,gg=Object.getOwnPropertyDescriptor,tu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ys=e=>{throw TypeError(e)},mg=(e,t,n)=>t in e?eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vg=e=>{var t;return[,,,pg((t=e?.[tu("metadata")])!=null?t:null)]},nu=["class","method","getter","setter","accessor","field","value","get","set"],ru=e=>e!==void 0&&typeof e!="function"?Ys("Function expected"):e,bg=(e,t,n,r,s)=>({kind:nu[e],name:t,metadata:r,addInitializer:i=>n._?Ys("Already initialized"):s.push(ru(i||null))}),yg=(e,t)=>mg(t,tu("metadata"),e[3]),xg=(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},su=(e,t,n,r,s,i)=>{for(var o,a,l,u,c=t&7,d=!1,f=!1,p=2,h=nu[c+5],v=e[p]||(e[p]=[]),y=(s=s.prototype,gg(s,n)),w=r.length-1;w>=0;w--)l=bg(c,n,a={},e[3],v),l.static=d,l.private=f,u=l.access={has:g=>n in g},u.get=g=>g[n],o=(0,r[w])(y[h],l),a._=1,ru(o)&&(y[h]=o);return y&&eu(s,n,y),s},iu=(e,t,n)=>t.has(e)||Ys("Cannot "+n),wg=(e,t,n)=>(iu(e,t,"read from private field"),t.get(e)),_g=(e,t,n)=>t.has(e)?Ys("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),kg=(e,t,n,r)=>(iu(e,t,"write to private field"),t.set(e,n),n),qt=class co{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new co(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 co(t,n)}},ou,au,uo,ps,jr,ga=class extends(uo=Yt,au=[Ee],ou=[Ee],uo){constructor(e){const t=qt.from(e);super(t,(n,r)=>qt.equals(n,r)),xg(jr,5,this),_g(this,ps,0),this.velocity={x:0,y:0}}get delta(){return qt.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=qt.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),i=s-wg(this,ps),o=a=>Math.round(a/i*100);Te(()=>{kg(this,ps,s),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(qt.from(e)),this.velocity={x:0,y:0}}};jr=vg(uo);ps=new WeakMap;su(jr,2,"delta",au,ga);su(jr,2,"direction",ou,ga);yg(jr,ga);var lu=(e=>(e.Horizontal="x",e.Vertical="y",e))(lu||{});Object.values(lu);var Sg=({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=qt.distance(t.shape.center,n);return{id:r,value:1/s,type:Pn.PointerIntersection,priority:An.High}}return null},$g=({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=qt.distance(t.shape.center,s.current),a=r/(n.current.area+t.shape.area-r)/i;return{id:t.id,value:a,type:Pn.ShapeIntersection,priority:An.Normal}}return null},Tg=e=>{var t;return(t=Sg(e))!=null?t:$g(e)};function Og(e){const{collisionDetector:t,data:n,disabled:r,element:s,id:i,accept:o,type:a}=e,l=Jd(c=>new Xs(ag(og({},e),{register:!1,element:bn(s)}),c)),u=Xd(l);return Se(i,()=>l.id=i),hs(s,c=>l.element=c),Se(o,()=>l.accept=o,void 0,ot),Se(t,()=>l.collisionDetector=t??Tg),Se(n,()=>n&&(l.data=n)),Se(r,()=>l.disabled=r===!0),Se(a,()=>l.type=a),{droppable:u,get isDropTarget(){return u.isDropTarget},ref:k.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 il=`url("data:image/svg+xml;utf8,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg>')}")`,cu=(e,t="line")=>{const n=[":is(p, h1, h2, h3, h4, h5, h6):first-child::after","> * > span:only-child::after"],r=o=>n.map(a=>`${o} ${a}`).join(", "),s=t==="line"?"&::after":r("&"),i=t==="line"?"&:hover::after, &:focus-visible::after":`${r("&:hover")}, ${r("&:focus-visible")}`;return{cursor:"text",borderRadius:"2px",[s]:{content:'""',display:"inline-block",width:"0.8em",height:"0.8em",ml:"0.4em",verticalAlign:"-0.05em",backgroundColor:"currentColor",maskImage:il,WebkitMaskImage:il,maskSize:"contain",WebkitMaskSize:"contain",maskRepeat:"no-repeat",WebkitMaskRepeat:"no-repeat",opacity:.35,transition:`opacity ${C.MOTION_FAST}`,...C.reducedMotionSx,pointerEvents:"none"},[i]:{opacity:.8},"&:focus-visible":{outline:`2px solid ${e.accent}`,outlineOffset:2}}},du=k.createContext(void 0);function uu(e,t){const n=k.useContext(du),r=k.useRef(t);r.current=t,k.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=k.useRef(!1);k.useLayoutEffect(()=>{!e&&!s.current||(s.current=e,n?.setDirty(e))},[n,e]),k.useLayoutEffect(()=>()=>{s.current&&n?.setDirty(!1)},[n])}function fo({value:e,placeholder:t,ariaLabel:n,onCommit:r,faintWhenEmpty:s=!1}){const{theme:i}=Ke.usePublisherTheme(),[o,a]=k.useState(void 0),l=k.useRef(!1),u=()=>{l.current||o===void 0||(a(void 0),o!==e&&r(o))};uu(o!==void 0&&o!==e,()=>(u(),!0));const c=()=>{l.current=!1,a(e)};if(o===void 0){const d=e==="",f=d&&s;return x.jsx($.Box,{component:"button",type:"button",className:f?"builder-affordance":void 0,onClick:c,onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),c())},sx:[{all:"unset",boxSizing:"border-box",font:"inherit",color:"inherit",display:"inline-block",maxWidth:"100%",...d&&{fontStyle:"italic",opacity:f?0:.6}},cu(i)],children:d?t:e})}return x.jsx($.InputBase,{autoFocus:!0,fullWidth:!0,value:o,placeholder:t,inputProps:{"aria-label":n},onFocus:d=>d.target.select(),onChange:d=>a(d.target.value),onKeyDown:d=>{d.key==="Enter"&&!d.nativeEvent.isComposing?u():d.key==="Escape"&&(l.current=!0,a(void 0))},onBlur:u,sx:{font:"inherit",color:"inherit",p:0,"& input":{p:0}}})}const Eg=(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}),Cg=(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},fu=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),hu=e=>`gap.${e}`,Ig=(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:Fe(e[o-1]),colspan:t-r}),l&&(r=0),n.push(fu(i,o)),r+=a});const s=e.at(-1);return s&&r<t&&n.push({kind:"gap",after:Fe(s),colspan:t-r}),n};var Dg=Object.create,pu=Object.defineProperty,Ag=Object.defineProperties,Pg=Object.getOwnPropertyDescriptor,Mg=Object.getOwnPropertyDescriptors,Ms=Object.getOwnPropertySymbols,gu=Object.prototype.hasOwnProperty,mu=Object.prototype.propertyIsEnumerable,jg=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Rr=e=>{throw TypeError(e)},ho=(e,t,n)=>t in e?pu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gi=(e,t)=>{for(var n in t||(t={}))gu.call(t,n)&&ho(e,n,t[n]);if(Ms)for(var n of Ms(t))mu.call(t,n)&&ho(e,n,t[n]);return e},mi=(e,t)=>Ag(e,Mg(t)),Rg=(e,t)=>{var n={};for(var r in e)gu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ms)for(var r of Ms(e))t.indexOf(r)<0&&mu.call(e,r)&&(n[r]=e[r]);return n},Lg=e=>{var t;return[,,,Dg((t=void 0)!=null?t:null)]},vu=["class","method","getter","setter","accessor","field","value","get","set"],rr=e=>e!==void 0&&typeof e!="function"?Rr("Function expected"):e,Ng=(e,t,n,r,s)=>({kind:vu[e],name:t,metadata:r,addInitializer:i=>n._?Rr("Already initialized"):s.push(rr(i||null))}),Fg=(e,t)=>ho(t,jg("metadata"),e[3]),Vr=(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},bu=(e,t,n,r,s,i)=>{for(var o,a,l,u,c,d=t&7,f=!1,p=!1,h=e.length+1,v=vu[d+5],y=e[h-1]=[],w=e[h]||(e[h]=[]),g=(s=s.prototype,Pg({get[n](){return sr(this,i)},set[n](b){return Gt(this,i,b)}},n)),m=r.length-1;m>=0;m--)u=Ng(d,n,l={},e[3],w),u.static=f,u.private=p,c=u.access={has:b=>n in b},c.get=b=>b[n],c.set=(b,_)=>b[n]=_,a=(0,r[m])({get:g.get,set:g.set},u),l._=1,a===void 0?rr(a)&&(g[v]=a):typeof a!="object"||a===null?Rr("Object expected"):(rr(o=a.get)&&(g.get=o),rr(o=a.set)&&(g.set=o),rr(o=a.init)&&y.unshift(o));return g&&pu(s,n,g),s},yu=(e,t,n)=>t.has(e)||Rr("Cannot "+n),sr=(e,t,n)=>(yu(e,t,"read from private field"),t.get(e)),Gn=(e,t,n)=>t.has(e)?Rr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Gt=(e,t,n,r)=>(yu(e,t,"write to private field"),t.set(e,n),n);function Kt(e){return e instanceof ba||e instanceof ku}var Hr=10,zg=class extends We{constructor(e){super(e);const t=st(()=>{const{dragOperation:r}=e;if(br(r.activatorEvent)&&Kt(r.source)&&r.status.initialized){const s=e.registry.plugins.get(Mr);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(!br(r.nativeEvent)||!Kt(i.source)||!i.shape)return;const{actions:o,collisionObserver:a,registry:l}=s,{by:u}=r;if(!u)return;const c=Wg(u),{source:d,target:f}=i,{center:p}=i.shape.current,h=[],v=[];Te(()=>{for(const _ of l.droppables){const{id:O}=_;if(!_.accepts(d)||O===f?.id&&Kt(_)||!_.element)continue;let E=_.shape;const I=new ut(_.element,{getBoundingClientRect:T=>mr(T,void 0,.2)});!I.height||!I.width||(c=="down"&&p.y+Hr<I.center.y||c=="up"&&p.y-Hr>I.center.y||c=="left"&&p.x-Hr>I.center.x||c=="right"&&p.x+Hr<I.center.x)&&(h.push(_),_.shape=I,v.push(()=>_.shape=E))}}),r.preventDefault(),a.disable();const y=a.computeCollisions(h,lp);Te(()=>v.forEach(_=>_()));const[w]=y;if(!w)return;const{id:g}=w,{index:m,group:b}=d.sortable;o.setDropTarget(g).then(()=>{const{source:_,target:O,shape:E}=i;if(!_||!Kt(_)||!E)return;const{index:I,group:T,target:D}=_.sortable,L=m!==I||b!==T,R=L?D:O?.element;if(!R)return;gd(R);const z=new ut(R);if(!z)return;const K=ft.delta(z,ft.from(E.current.boundingRectangle),_.alignment);o.move({by:K}),L?o.setDropTarget(_.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function Wg(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 Bg=Object.defineProperty,Gg=Object.defineProperties,qg=Object.getOwnPropertyDescriptors,ol=Object.getOwnPropertySymbols,Kg=Object.prototype.hasOwnProperty,Ug=Object.prototype.propertyIsEnumerable,al=(e,t,n)=>t in e?Bg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nn=(e,t)=>{for(var n in t||(t={}))Kg.call(t,n)&&al(e,n,t[n]);if(ol)for(var n of ol(t))Ug.call(t,n)&&al(e,n,t[n]);return e},rn=(e,t)=>Gg(e,qg(t));function Vg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Xr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function vi(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Hg(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=(m,b)=>m===b||m!==null&&typeof m=="object"&&"id"in m&&m.id===b;if(Array.isArray(e)){const m=e.findIndex(_=>l(_,i.id)),b=e.findIndex(_=>l(_,o.id));if(m===-1||b===-1){if(vi(i)){const _=i.initialIndex,O=i.index;return _===O||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,O)}return e}if(!a&&"index"in i&&typeof i.index=="number"){const _=i.index;if(_!==m)return n(e,m,_)}return n(e,m,b)}const u=Object.entries(e);let c=-1,d,f=-1,p;for(const[m,b]of u)if(c===-1&&(c=b.findIndex(_=>l(_,i.id)),c!==-1&&(d=m)),f===-1&&(f=b.findIndex(_=>l(_,o.id)),f!==-1&&(p=m)),c!==-1&&f!==-1)break;if(c===-1&&vi(i)){const m=i.initialGroup==null?void 0:Xr(e,i.initialGroup),b=i.initialIndex,_=i.group==null?void 0:Xr(e,i.group),O=i.index;if(m==null||_==null||m===_&&b===O)return"preventDefault"in t&&t.preventDefault(),e;if(m===_)return rn(nn({},e),{[m]:n(e[m],b,O)});const E=e[m][b];return rn(nn({},e),{[m]:[...e[m].slice(0,b),...e[m].slice(b+1)],[_]:[...e[_].slice(0,O),E,...e[_].slice(O)]})}if(!i.manager)return e;const{dragOperation:h}=i.manager,v=(s=(r=h.shape)==null?void 0:r.current.center)!=null?s:h.position.current;if(p==null){const m=Xr(e,o.id);if(m!=null){const b=o.shape&&v.y>o.shape.center.y?e[m].length:0;p=m,f=b}}if(d==null||p==null||d===p&&c===f){if(d!=null&&d===p&&c===f&&vi(i)){const m=i.group==null?void 0:Xr(e,i.group),b=i.group!=null&&m!==d,_=i.index!==c;if(b||_){const O=i.group==null?d:m;if(O!=null){if(d===O)return rn(nn({},e),{[d]:n(e[d],c,i.index)});const E=e[d][c];return rn(nn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[O]:[...e[O].slice(0,i.index),E,...e[O].slice(i.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===p)return rn(nn({},e),{[d]:n(e[d],c,f)});const w=o.shape&&Math.round(v.y)>Math.round(o.shape.center.y)?1:0,g=e[d][c];return rn(nn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[p]:[...e[p].slice(0,f+w),g,...e[p].slice(f+w)]})}function Xg(e,t){return Hg(e,t,Vg)}function ll(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function cl(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 dl="__default__",Yg=class extends We{constructor(e){super(e);const t=()=>{const r=new Map;for(const s of e.registry.droppables)if(s instanceof ba){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(!Kt(o)||!Kt(a)||o.sortable===a.sortable)return;const l=t(),u=ll(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,h;const v=t();if(cl(u,l,v))return;const y=o.sortable.element,w=a.sortable.element;if(!w||!y||!c&&a.id===o.sortable.group)return;const g=Yr(d),m=c?g:Yr(f),b=(p=o.sortable.group)!=null?p:dl,_=(h=a.sortable.group)!=null?h:dl,O={[b]:g,[_]:m},E=Xg(O,r);if(O===E)return;const I=E[_].indexOf(o.sortable),T=E[_].indexOf(a.sortable);s.collisionObserver.disable(),ul(y,I,w,T),Te(()=>{for(const[D,L]of E[b].entries())L.index=D;if(!c)for(const[D,L]of E[_].entries())L.group=a.sortable.group,L.index=D}),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;Kt(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),l=ll(a),u=a.get(o.sortable.initialGroup);u&&s.renderer.rendering.then(()=>{const c=t();if(cl(l,a,c))return;const d=Yr(u),f=Yr(u,Qg),p=o.sortable.element,h=f.indexOf(o.sortable),v=d[h],y=v?.element;!v||!y||!p||(ul(p,v.index,y,o.index),Te(()=>{for(const w of a.values()){const g=Array.from(w).values();for(const m of g)m.index=m.initialIndex,m.group=m.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function ul(e,t,n,r){const s=r<t?"afterend":"beforebegin";n.insertAdjacentElement(s,e)}function Zg(e,t){return e.index-t.index}function Qg(e,t){return e.initialIndex-t.initialIndex}function Yr(e,t=Zg){return Array.from(e).sort(t)}var fl=[zg,Yg],xu={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function hl(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 Zr=new Kf,wu,_u,Dt,ma,ir,or,va,hn;_u=[fe],wu=[fe];var Zs=class{constructor(e,t){Gn(this,ma,Vr(Dt,8,this)),Vr(Dt,11,this),Gn(this,ir),Gn(this,or),Gn(this,va,Vr(Dt,12,this)),Vr(Dt,15,this),Gn(this,hn),this.register=()=>(Te(()=>{var h,v;(h=this.manager)==null||h.registry.register(this.droppable),(v=this.manager)==null||v.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{Te(()=>{var h,v;(h=this.manager)==null||h.registry.unregister(this.droppable),(v=this.manager)==null||v.registry.unregister(this.draggable)})},this.destroy=()=>{Te(()=>{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=Rg(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const f=lt(c,fl),p=hl(s);this.droppable=new ba(mi(gi({},d),{disabled:p.droppable}),t,this),this.draggable=new ku(mi(gi({},d),{disabled:p.draggable,plugins:f,effects:()=>[()=>{var h,v,y;const w=(h=this.manager)==null?void 0:h.dragOperation.status;w?.initializing&&this.id===((y=(v=this.manager)==null?void 0:v.dragOperation.source)==null?void 0:y.id)&&Zr.clear(this.manager),w?.dragging&&Zr.set(this.manager,this.id,ue(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:h,group:v,manager:y}=this,w=sr(this,or),g=sr(this,ir);(h!==w||v!==g)&&(Gt(this,or,h),Gt(this,ir,v),this.animate())},()=>{var h,v;const{target:y}=this,{isDragSource:w}=this.draggable;((v=(h=this.draggable.pluginConfig(aa))==null?void 0:h.feedback)!=null?v:"default")==="move"&&w&&(this.droppable.disabled=!y)},...r()],type:l,sensors:a}),t,this),Gt(this,hn,d.element),this.manager=t,this.index=o,Gt(this,or,o),this.group=i,Gt(this,ir,i),this.type=l,this.transition=u}get initialIndex(){var e,t;return(t=(e=Zr.get(this.manager,this.id))==null?void 0:e.initialIndex)!=null?t:this.index}get initialGroup(){var e,t;return(t=(e=Zr.get(this.manager,this.id))==null?void 0:e.initialGroup)!=null?t:this.group}animate(){ue(()=>{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}=gt(s),l=Xa(s,a,!1),u=Xa(s,a);if(o.x||o.y){const c=Jo(Qe(s))?mi(gi({},t),{duration:0}):t;md({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){Te(()=>{this.draggable.manager=e,this.droppable.manager=e})}set element(e){Te(()=>{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),Gt(this,hn,e)})}get element(){var e,t;const n=sr(this,hn);if(n)return(t=(e=Ui.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=lt(e,fl)}set disabled(e){const t=hl(e);Te(()=>{this.droppable.disabled=t.droppable,this.draggable.disabled=t.draggable})}set data(e){Te(()=>{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??vd}set alignment(e){this.draggable.alignment=e}get alignment(){return this.draggable.alignment}set type(e){Te(()=>{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)}};Dt=Lg();ma=new WeakMap;ir=new WeakMap;or=new WeakMap;va=new WeakMap;hn=new WeakMap;bu(Dt,4,"index",_u,Zs,ma);bu(Dt,4,"group",wu,Zs,va);Fg(Dt,Zs);var ku=class extends Hs{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}},ba=class extends Xs{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},Jg=Object.defineProperty,em=Object.defineProperties,tm=Object.getOwnPropertyDescriptors,pl=Object.getOwnPropertySymbols,nm=Object.prototype.hasOwnProperty,rm=Object.prototype.propertyIsEnumerable,gl=(e,t,n)=>t in e?Jg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bi=(e,t)=>{for(var n in t||(t={}))nm.call(t,n)&&gl(e,n,t[n]);if(pl)for(var n of pl(t))rm.call(t,n)&&gl(e,n,t[n]);return e},sm=(e,t)=>em(e,tm(t));function im(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:h,plugins:v}=e,y=bi(bi({},xu),e.transition),w=Jd(m=>new Zs(sm(bi({},e),{transition:y,register:!1,handle:bn(a),element:bn(o),target:bn(p)}),m)),g=Xd(w,om);return Se(s,()=>w.id=s),Ln(()=>{Te(()=>{w.group=u,w.index=l})},[w,u,l]),Se(h,()=>w.type=h),Se(t,()=>w.accept=t,void 0,ot),Se(i,()=>i&&(w.data=i)),Se(l,()=>{var m;(m=w.manager)!=null&&m.dragOperation.status.idle&&y?.idle&&w.refreshShape()},ng),hs(a,m=>w.handle=m),hs(o,m=>w.element=m),hs(p,m=>w.target=m),Se(c,()=>w.disabled=c??!1,void 0,ot),Se(f,()=>w.sensors=f,void 0,ot),Se(n,()=>w.collisionDetector=n),Se(r,()=>w.collisionPriority=r),Se(v,()=>w.plugins=v,void 0,ot),Se(y,()=>w.transition=y,void 0,ot),Se(d,()=>w.modifiers=d,void 0,ot),Se(e.alignment,()=>w.alignment=e.alignment),{sortable:g,get isDragging(){return g.isDragging},get isDropping(){return g.isDropping},get isDragSource(){return g.isDragSource},get isDropTarget(){return g.isDropTarget},handleRef:k.useCallback(m=>{w.handle=m??void 0},[w]),ref:k.useCallback(m=>{var b,_;!m&&((b=w.element)!=null&&b.isConnected)&&!((_=w.manager)!=null&&_.dragOperation.status.idle)||(w.element=m??void 0)},[w]),sourceRef:k.useCallback(m=>{var b,_;!m&&((b=w.source)!=null&&b.isConnected)&&!((_=w.manager)!=null&&_.dragOperation.status.idle)||(w.source=m??void 0)},[w]),targetRef:k.useCallback(m=>{var b,_;!m&&((b=w.target)!=null&&b.isConnected)&&!((_=w.manager)!=null&&_.dragOperation.status.idle)||(w.target=m??void 0)},[w])}}function om(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const po="tile",Su="gap",am=[oo.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>e.target instanceof Element&&e.target.closest(`[${$u}]`)!==null||(oo.defaults.preventActivation?.(e,t)??!1)}),Wd],$u="data-no-drag",lm=e=>[...e,aa.configure({feedback:"clone"})];function cm({id:e,index:t,children:n}){const{ref:r,handleRef:s,isDragSource:i}=im({id:e,index:t,type:po,accept:po,collisionDetector:ta,plugins:lm});return x.jsx(x.Fragment,{children:n({ref:r,handleRef:s,isDragSource:i})})}function dm({id:e,after:t,children:n}){const{ref:r,isDropTarget:s}=Og({id:e,type:Su,accept:po,collisionDetector:ta,data:{after:t}});return x.jsx(x.Fragment,{children:n({ref:r,isDropTarget:s})})}const Tu=["bar_chart","line_chart","scatter_chart","shape_map","segment_map","big_value","sparkline"],Ou=["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"],Qs=e=>Ou.includes(e),go=new Set([...Tu,"viz"]);function At(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(!go.has(o))return;r.push(o)}else{if(s!==void 0||!go.has(i))return;s=i}return{negated:r,...s!==void 0&&{pick:s}}}function kr(e){const t=e.trim();return!/^#[ \t]/.test(t)||At(t)?!1:(t.replace(/"(?:[^"\\]|\\.)*"/g,'""').match(/[A-Za-z_]+/g)??[]).some(r=>go.has(r))}function yn(e,t){return["#",...Ou.filter(r=>r!==e&&(t===void 0||t.includes(r))).map(r=>`-${r}`),"-viz",...e==="none"?[]:[e]].join(" ")}function um(e){return e.pick!==void 0?Qs(e.pick)?e.pick:"custom":e.negated.includes("viz")?"none":"custom"}function fm(e){if(e.length===0)return"default";if(e.length>1)return"custom";const t=At(e[0]);return t?um(t):"custom"}function hm(e){const t=e.filter(n=>At(n));return e.some(kr)?"custom":t.length===0?void 0:fm(t)}const pm=e=>e.filter(t=>At(t)||kr(t)),Eu=e=>e.ok===!1,De=(e,...t)=>t.every(n=>typeof e?.[n]=="function"),Lr=e=>e!==void 0&&e.ruleIndex!==void 0&&(e.childCount??0)>0,ke={sourceDefinition:e=>De(e,"sourceNameDef","isDefine","sqExplore"),exploreQueryDef:e=>De(e,"exploreQueryNameDef","isDefine","vExpr"),defExploreQuery:e=>De(e,"VIEW","subQueryDefList"),defDimension:e=>De(e,"defList","DIMENSION"),exploreProperties:e=>De(e,"exploreStatement","OCURLY","CCURLY"),queryProperties:e=>De(e,"queryStatement","OCURLY","CCURLY"),queryStatement:e=>De(e,"whereStatement","aggregateStatement","nestStatement"),whereStatement:e=>De(e,"WHERE","filterClauseList"),givenDef:e=>De(e,"givenNameDef"),givenStatement:e=>De(e,"GIVEN","givenDefList"),importStatement:e=>De(e,"IMPORT","importURL"),vArrow:e=>De(e,"ARROW","vExpr","segExpr"),segRefine:e=>De(e,"PLUS","segExpr"),segOps:e=>De(e,"queryProperties"),segField:e=>De(e,"fieldPath")&&!De(e,"segExpr"),segParen:e=>De(e,"OPAREN","CPAREN","vExpr"),compare:e=>De(e,"fieldExpr","compareOp"),givenRef:e=>De(e,"GIVEN_REF")};function gm(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 mm(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
68
|
+
`&&t.push(n+1);return t}class ya{constructor(t){this.text=t,this.map=gm(t),this.lineStarts=mm(t)}map;lineStarts;commentLines=new Set;proseLines=new Set;blocks=[];span(t){if(!Lr(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 Nr(e,t,n=[]){Lr(e)&&t(e)&&n.push(e);for(let r=0;r<(e.childCount??0);r++)Nr(e.getChild(r),t,n);return n}const vm=e=>De(e,"OCURLY","CCURLY");function Sr(e,t){const n=[],r=s=>{if(Lr(s)){if(t(s)){n.push(s);return}if(!vm(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 Ae=(e,t)=>e[t]?.call(e),Ht=(e,t)=>e[t]?.call(e)??[];function bm(e,t){if(!ke.compare(t)||(t.childCount??0)!==3)return;const n=t.getChild(2);if(!ke.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 Cu(e,t){const n=e.positioned(t);if(!n)return;const r=Ae(t,"filterClauseList"),s=[];for(const i of r?Ht(r,"fieldExpr"):[]){const o=e.positioned(i);if(!o)continue;const a=Nr(i,ke.givenRef).map(l=>e.text_(l)).filter(l=>l!==void 0).map(l=>l.replace(/^\$/,""));s.push({...o,givens:a,binding:bm(e,i)})}return{...n,clauses:s}}function mo(e,t){const n=e.span(t);if(!n)return;const r=[],s=[];for(const u of Sr(t,ke.queryStatement)){const c=e.positioned(u);c&&r.push(c);const d=Ae(u,"whereStatement");if(d&&ke.whereStatement(d)){const f=Cu(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 xa(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 ym(e,t){const n=Ae(t,"segExpr");if(!n)return{kind:"unsupported",why:"an unreadable expression"};const r=ke.vArrow(t);if(ke.segOps(n)){const s=Ae(n,"queryProperties"),i=s&&mo(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(ke.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(ke.segRefine(n)){const s=Ht(n,"segExpr"),i=s[0],o=s[s.length-1];let a=i;for(;ke.segRefine(a);){const f=Ht(a,"segExpr");if(f.some(p=>ke.segOps(p)||ke.segParen(p)))return{kind:"unsupported",why:"a chained refinement"};a=f[0]}if(a&&ke.segParen(a))return{kind:"unsupported",why:"a parenthesized expression"};if(!a||!ke.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(!ke.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=Ae(o,"queryProperties"),d=c&&mo(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 xm(e,t){const n=[];for(const r of Sr(t,ke.defExploreQuery)){const s=e.span(r),i=Ae(r,"subQueryDefList");if(!s||!i)continue;const o=Ht(i,"exploreQueryDef").filter(ke.exploreQueryDef),a=e.terminal(Ae(r,"VIEW"));for(const l of o){const u=e.span(l),c=Ae(l,"exploreQueryNameDef"),d=e.text_(c),f=Ae(l,"vExpr");!u||!d||!f||n.push({name:d,span:u,line:e.line(u.start),statement:s,tags:xa(e,s,a?.start??u.start),siblings:o.length,body:ym(e,f)})}}return n}function wm(e,t){const n=[];for(const r of Sr(t,ke.defDimension)){const s=e.span(r),i=Ae(r,"defList");if(!s||!i)continue;const o=e.terminal(Ae(r,"DIMENSION"));for(const a of Ht(i,"fieldDef")){const l=e.span(a),u=e.text_(Ae(a,"fieldNameDef"))?.trim(),c=e.text_(Ae(a,"fieldExpr"))?.trim();!l||!u||c===void 0||n.push({name:u,expression:c,span:l,line:e.line(l.start),statement:s,tags:xa(e,s,o?.start??l.start)})}}return n}function _m(e,t){const n=[];for(const r of Nr(t,ke.sourceDefinition)){const s=e.span(r),i=e.text_(Ae(r,"sourceNameDef")),o=Ae(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=Sr(o,ke.exploreProperties)[0],d=c&&mo(e,c),f={start:e.lineStarts[e.line(s.start)],end:s.end},p=[];if(c)for(const h of Sr(c,ke.whereStatement)){const v=Cu(e,h);v&&p.push(v)}n.push({name:i,base:u,span:s,line:e.line(s.start),statement:f,...d?{properties:d}:{},views:c?xm(e,c):[],dimensions:c?wm(e,c):[],wheres:p})}return n}function km(e,t){const n=[];for(const r of Nr(t,ke.givenStatement)){const s=e.terminal(Ae(r,"GIVEN")),i=Ae(r,"givenDefList"),o=s?e.line(s.start):void 0;for(const a of i?Ht(i,"givenDef"):[]){const l=e.span(a),u=e.span(Ae(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:xa(e,l,d.start),...o!==void 0&&o!==f?{blockHeader:o}:{}})}}return n}function Sm(e,t){const n=[];for(const r of Nr(t,ke.importStatement)){const s=e.span(r),i=e.text_(Ae(r,"importURL"));if(!s||i===void 0)continue;const o=Ae(r,"importSelect"),a=o?Ht(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 Iu(e){let t;try{t=await Js(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||!Lr(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 ya(e),l=wa(a,i);a.commentLines=l.lines;const u=e.split(`
|
|
70
|
+
`),c=f=>l.lines.has(f);a.proseLines=me.markdownLines(u,c),a.blocks=me.blockSpans(u,c).filter(([f])=>!u[f].trimStart().startsWith("##"));const d=_m(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:Sm(a,s),sources:d,givens:km(a,s),textBlocks:Tm(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=>$m(a,l.lines,f)}}}async function Js(e,t){const{MalloyTranslator:n}=await C.loadMalloy(),r=new n(t,null,{urls:{[t]:e}});return{problems:r.translate().problems??[],parse:r.parseStep?.response?.parse}}function wa(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 v=d;v<=f;v++)u(v).trim()===""&&r.add(v);const p=a.slice(e.lineStarts[d],c.start).trim(),h=a.slice(c.end,e.lineStarts[f+1]??a.length).trim();p!==""&&h===""&&n.set(f,c)}return{trailing:n,lines:r,all:s}}function $m(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 Tm(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=me.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,h=l.name===void 0&&l.rest?[`${l.rest}
|
|
72
|
+
`]:[];o.push({...l.name===void 0?{}:{name:l.name},route:l.route,body:[...h,...u].join("").replace(/\r\n?/g,`
|
|
73
|
+
`).replace(/\n$/,""),span:{start:e.lineStarts[f],end:p},line:f}),a=c}return o}function Du(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 _a(e){let t=0,n=0;for(let r=0;r<e.length;r++){const s=e[r];if(s==='"')r=Du(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 Om(e,r+i[0].length-1)}}}function Om(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=Du(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 Em(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
74
|
`)return e.length}return e.length}if(e.startsWith("<<<",t)){let r=t+3;for(;;){const s=e.indexOf(`
|
|
75
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
|
|
77
|
-
`&&t.push(n+1);return t}function
|
|
78
|
-
`})}function
|
|
76
|
+
`)return s}return e.length}return t}function Cm(e){const t=/^([ \t]*)f(['"])((?:\\.|(?!\2)[^\\])*)\2/;let n="",r=0;for(;r<e.length;){const s=Em(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 Au(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=Cm(i);return e([o]).log.length===0?o:i}),s=e(r);return{tag:s.tag,errors:s.log.map(i=>i.message)}}const $r=e=>e.ok===!1;function Fr(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 ml(e){const t=js(e),n=hm(t);return n===void 0?{}:n==="custom"?{chart:n,chartLines:pm(t)}:{chart:n}}function Im(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:me.readPath(s),given:o,...i==="~"?{}:{op:i}})}return t.length>0?t:void 0}function Dm(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(),...Am(n(js(Fr(e,t,s.line).tags)).tag)})}return r.length>0?r:void 0}function Am(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 yi(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 Pm=/^"((?:[^"\\]|\\.)+)"$/,Mm=/^([A-Za-z_][A-Za-z0-9_]*)\s*\{/;async function Tr(e,t,n=!1){try{return await jm(e,t,n)}catch(r){return{ok:!1,reason:`A value in this file's tags cannot be read (${r instanceof Error?r.message:String(r)}), so it cannot be opened in the builder.`}}}async function jm(e,t,n){const{parseAnnotation:r}=await C.loadMalloyTag(),s=me.splitSourceLines(e),i=await Iu(e);if(Eu(i))return{ok:!1,reason:i.reason,...i.line?{line:i.line}:{}};const o=i.parsed,a=me.descriptionNotes(s).text,l=me.artifactTag(s);if(l===void 0)return{ok:!1,reason:"No `## artifact { … }` tag, so this file is not a composite dashboard."};if(!me.artifactLeads(l.text))return{ok:!1,reason:me.ARTIFACT_NOT_FIRST,line:l.from+1};const{tag:u,errors:c}=Au(r,[me.tagAnnotation(l.text)]),d=u?.tag("artifact"),f=d?.text("kind"),p=d?.has("tiles")===!0||u?.tag("dashboard")!==void 0,h=f==="notebook"||f!=="dashboard"&&(n?!p:t?.startsWith("notebooks/"))?"notebook":void 0,v=_a(l.text);if(v===void 0)return c.length>0?{ok:!1,reason:`The \`## artifact\` tag does not parse: ${c[0]}`}:h==="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 y=o.imports.map(T=>T.names?{kind:"names",names:T.names,from:T.from}:{kind:"all",from:T.from}),w=[],g=[],m=new Map;for(const T of o.sources){const D={name:T.name,base:T.base};T.dimensions.length>0&&(D.dimensions=T.dimensions.map(R=>({name:R.name,expression:R.expression})));const L=new Set(T.wheres.flatMap(R=>R.clauses.flatMap(z=>z.givens)));L.size>0&&(D.scopedBy=Array.from(L)),w.push(D);for(const R of T.dimensions){const z=r(js(Fr(o,s,R.line).tags)).tag?.tag("drill");if(!z)continue;const K=z.textArray("to")??[z.text("to")??""];g.push({source:T.name,name:R.name,expression:R.expression,to:K.filter(Boolean),...z.text("given")?{given:z.text("given")}:{}})}m.set(T.name,new Map(T.views.map(R=>[R.name,R])))}const b=[];for(const{text:T}of v.entries){const D=Pm.exec(T),L=D?void 0:Mm.exec(T)?.[1];if(L!==void 0){const A=r([`# ${T}`]).tag?.tag(L);if(A?.text("kind")!=="text")return{ok:!1,reason:`The tile \`${T}\` is neither a quoted \`source -> view\` expression nor a \`${L} { kind=text }\` entry, which are the only forms the builder can lay out.`};if(b.some(N=>je(N)&&N.name===L))return{ok:!1,reason:`Two text tiles are named \`${L}\`, so the builder cannot tell them apart.`};const B=yi(A,"colspan");b.push({kind:"text",name:L,markdown:o.textBlocks.find(N=>N.name===L)?.body??"",...B===void 0?{}:{colspan:B},...A.has("break")?{break:!0}:{}});continue}const R=D?.[1]??T,z=D?me.tileSteps(R):void 0;if(!z)return{ok:!1,reason:`The tile \`${R}\` is not a \`source -> view\` expression, which is the only form the builder can lay out.`};const{source:K,view:G}=z,X=m.get(K)?.get(G);if(X===void 0){b.push({name:G,source:K,declaration:{kind:"inherited"}});continue}const Y=r(js(X.tags)).tag,se=X.body.kind==="reference"?{kind:"reference",from:X.body.from}:X.body.kind==="inline"?{kind:"inline"}:void 0;if(se===void 0){b.push({name:G,source:K,declaration:{kind:"opaque",why:X.body.kind==="unsupported"?X.body.why:"unreadable"},...Y?.text("label")?{label:Y.text("label")}:{},...Y?.text("subtitle")?{subtitle:Y.text("subtitle")}:{},...Y?.numeric("colspan")!==void 0?{colspan:Y.numeric("colspan")}:{},...ml(X.tags),...Y?.has("break")?{break:!0}:{},...Y?.has("borderless")?{borderless:!0}:{}});continue}const te=Im(X.body.kind==="reference"?X.body.refinement:X.body.kind==="inline"?X.body.stage:void 0);b.push({name:G,source:K,declaration:se,...te?{filters:te}:{},...Y?.text("label")?{label:Y.text("label")}:{},...Y?.text("subtitle")?{subtitle:Y.text("subtitle")}:{},...Y?.numeric("colspan")!==void 0?{colspan:Y.numeric("colspan")}:{},...ml(X.tags),...Y?.has("break")?{break:!0}:{},...Y?.has("borderless")?{borderless:!0}:{}})}const _=Dm(o,s,r),O={},E=d?.tag("givens");for(const T of Object.keys(E?.dict??{})){const D=E?.text(T);D!==void 0&&(O[T]=D)}const I=u?.tag("dashboard")?.has("columns")?yi(u.tag("dashboard"),"columns"):d?.array("tiles")?yi(d,"dashboard_columns"):void 0;return{ok:!0,document:{...h?{kind:h}:{},title:d?.text("title")??"",...a?{description:a}:{},...I===void 0?{}:{columns:I},...d?.has("autorun")?{autorun:d.isTrue("autorun")}:{},imports:y,sources:w,..._?{localGivens:_}:{},...Object.keys(O).length>0?{startingGivens:O}:{},...g.length>0?{drills:g}:{},tiles:b}}}const Rs=e=>e.ok===!1;async function vl(e){const{problems:t}=await Js(e,"file://splice-check.malloy");return t.filter(n=>n.code==="syntax-error").map(n=>n.message??"").sort()}function _e(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 Pu(e){return e.replace(/^(?:[ \t]*\r?\n)+/,"").trimEnd()}function Rm(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
77
|
+
`&&t.push(n+1);return t}function Lm(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 Mu=e=>e==="none"||Qs(e)?e:void 0;function ju(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=${bt(e.label)}`),e.subtitle!==void 0&&n.push(`# subtitle=${bt(e.subtitle)}`);const r=t?Mu(e.chart):void 0;return r!==void 0&&n.push(yn(r,e.chartCarried)),n}function gs(e){return/^#\s*([a-z_]+)/.exec(e)?.[1]}const Nm=new Set(["colspan","break","borderless","label","subtitle"]),Fm=new Set(["label","description","control","suggest","range_min","range_max"]),Xe=e=>e.kind??"dashboard";function bl(e){const t=[];if(e.label!==void 0&&t.push(`label=${bt(e.label)}`),e.description!==void 0&&t.push(`description=${bt(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=${bt(e.suggest.query)}`:void 0;t.push(`suggest { ${n?`${n} `:""}dimension=${bt(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 yl=e=>`given: ${e.name} :: ${e.type} is ${e.default}`;function zm(e,t,n){const r=e.sources.find(s=>s.name===t)?.views.find(s=>s.name===n);return r?r.line:-1}function xl(e){return`# drill { to=${e.to.length===1?e.to[0]:`[${e.to.map(n=>`"${n}"`).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const Ls=e=>`${e.source}.${e.name}`,bt=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,vo=e=>je(e)?_e(["text",e.name]):_e([e.name,e.source,e.declaration]),nt=vo,wl=e=>_e(e.tiles.map(nt));function Wm(e,t,n){if(Xe(e)!==Xe(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(nt)),s=new Set(t.tiles.map(nt)),i=e.tiles.filter(f=>!s.has(nt(f))),o=t.tiles.filter(f=>!r.has(nt(f))),l=i.length>0||o.length>0||wl(e)!==wl(t);for(const f of o)if(xe(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(h=>h.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=>xe(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 _l=(e,t)=>e.colspan!==t.colspan||!!e.break!=!!t.break;function Bm(e){let t="";for(let n=0;n<e.length;n++){if(e[n]!=='"'){t+=e[n];continue}const r=Or(e,n);t+="x".repeat(Math.min(r,e.length-1)-n+1),n=r}return t}function kl(e,t){if(t===void 0)return`${e.name} { kind=text${e.colspan===void 0?"":` colspan=${e.colspan}`}${e.break?" break":""} }`;const n=Bm(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 Gm(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(je).map(g=>[g.name,g])),c=s.tiles.filter(je).some(g=>{const m=u.get(g.name);return m!==void 0&&_l(m,g)});if(!i&&!c)return;const d=me.artifactTag(t);if(!d)return{ok:!1,reason:"Could not find the `## artifact` tag to reorder."};const f=d.text,p=_a(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 h=new Map;for(const{text:g}of p.entries){const m=/^"((?:[^"\\]|\\.)+)"$/.exec(g);if(m){const _=m[1].split("->").map(O=>O.trim());_.length===2&&h.set(`${_[0]}->${_[1]}`,g);continue}const b=/^([A-Za-z_][A-Za-z0-9_]*)\s*\{/.exec(g)?.[1];b!==void 0&&h.set(`text.${b}`,g)}const v=s.tiles.map(g=>{const m=!o.has(nt(g));if(je(g)){const b=h.get(`text.${g.name}`);return b!==void 0?u.has(g.name)&&!_l(u.get(g.name),g)?b:kl(g,b):m?kl(g):void 0}return h.get(`${g.source}->${g.name}`)??(m?`"${g.source} -> ${g.name}"`:void 0)});if(v.some(g=>g===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const y=f.slice(0,p.open).search(/tiles\s*=\s*$/),w=`${f.slice(0,y)}tiles=[${qm(f,p,v)}]${f.slice(p.close+1)}`;w!==f&&l.push({...Ru(n,d),text:`${w}
|
|
78
|
+
`})}function Ru(e,t){return{start:e(t.from).start,end:e(t.block?t.to-1:t.from).end}}function qm(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
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
|
|
81
|
-
${/\n([ \t]+)\S/.exec(
|
|
82
|
-
`:`${
|
|
83
|
-
${
|
|
84
|
-
)`);
|
|
80
|
+
`)?a:" "}`;return`${i}${n.join(l)}${o}`}function Sl(e,t){let n=0,r=0;for(let s=0;s<e.length;s++){const i=e[s];if(i==='"')s=Or(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]==='"'?Or(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 Km(e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(r==='"')n=Or(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=Or(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 Or(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 Um(e){const{lines:t,wholeLine:n,current:r,next:s,edits:i}=e;if(Xe(r)!==Xe(s)||r.title!==s.title||r.autorun!==s.autorun||r.columns!==s.columns||_e(r.startingGivens)!==_e(s.startingGivens)){const o=me.artifactTag(t);if(!o)return{ok:!1,reason:"Could not find the `## artifact` tag to change the page's settings."};const a=Ru(n,o),l=i.find(g=>g.start===a.start&&g.end===a.end);let u=l?l.text.replace(/\n$/,""):o.text;Xe(r)!==Xe(s)&&(u=Sl(u,"kind"));const c=u.indexOf("artifact"),d=u.indexOf("{",c);let f=0,p=-1;for(let g=d;g<u.length;g++)if(u[g]==="{")f++;else if(u[g]==="}"&&--f===0){p=g;break}if(d<0||p<0)return{ok:!1,reason:"Could not read the `## artifact { … }` tag."};let h=u.slice(d+1,p);const v=o.block?`
|
|
81
|
+
${/\n([ \t]+)\S/.exec(h)?.[1]??" "}`:" ",y=g=>o.block?`${h.trimEnd()}${v}${g}
|
|
82
|
+
`:`${h.trimEnd()} ${g} `,w=(g,m)=>{const b=new RegExp(`${o.block?"[ \\t]*":"\\s*"}\\b${g}=(?:"(?:[^"\\\\]|\\\\.)*"|[^\\s}]+)`);if(m===void 0){const _=new RegExp(`
|
|
83
|
+
${b.source}[ \\t]*(?=
|
|
84
|
+
)`);h=h.replace(o.block&&_.test(h)?_:b,"")}else b.test(h)?h=h.replace(b,_=>`${o.block?_.slice(0,_.length-_.trimStart().length):" "}${g}=${m}`):h=y(`${g}=${m}`)};if(Xe(r)!==Xe(s)&&Xe(s)==="notebook"?h=y("kind=notebook"):Xe(r)!==Xe(s)&&(e.explicitKind||!e.modelPath?.startsWith("dashboards/"))&&(h=y("kind=dashboard")),r.title!==s.title&&w("title",s.title?bt(s.title):void 0),r.autorun!==s.autorun&&w("autorun",s.autorun===void 0?void 0:String(s.autorun)),_e(r.startingGivens)!==_e(s.startingGivens)){h=h.replace(/\s*\bgivens\s*\{[^}]*\}/,"");const g=Object.entries(s.startingGivens??{});g.length>0&&(h=y(`givens { ${g.map(([m,b])=>`${m}=${bt(b)}`).join(" ")} }`))}o.block?u=`${u.slice(0,d+1)}${h}${u.slice(p)}`:(h=h.replace(/\s{2,}/g," "),u=`${u.slice(0,d+1)}${h.startsWith(" ")?h:` ${h}`}${h.endsWith(" ")?"":" "}${u.slice(p)}`),r.columns!==s.columns&&(u=Sl(u,"dashboard_columns"),u=Km(u),s.columns!==void 0&&(u=`${u.trimEnd()} dashboard { columns=${s.columns} }`)),l?l.text=`${u}
|
|
85
85
|
`:i.push({...a,text:`${u}
|
|
86
|
-
`})}if(r.description!==s.description){const{read:o,blankAbove:a,below:l,belowBlock:u,inBlock:c}=
|
|
87
|
-
`).map(
|
|
88
|
-
`),f=o.length>0&&o[0]<
|
|
89
|
-
`});else if(s.description!==void 0){const
|
|
90
|
-
`})}}}function
|
|
91
|
-
`).trim();o.push({start:n(
|
|
92
|
-
`:"")+`${
|
|
93
|
-
`})}for(const[p,
|
|
94
|
-
`:"")+`${
|
|
86
|
+
`})}if(r.description!==s.description){const{read:o,blankAbove:a,below:l,belowBlock:u,inBlock:c}=me.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=Pu(s.description??"").split(`
|
|
87
|
+
`).map(v=>v.trim()===""?'##"':`##" ${v.trim()}`).join(`
|
|
88
|
+
`),f=o.length>0&&o[0]<me.artifactLine(t),p=s.description===void 0,h=f?[...o.slice(1),...p?l:[]]:[...o,...a];for(const v of h)i.push({...n(v),text:""});if(f)i.push({...n(o[0]),text:s.description===void 0?"":`${d}
|
|
89
|
+
`});else if(s.description!==void 0){const v=n(me.artifactLine(t)).start;i.push({start:v,end:v,text:`${d}
|
|
90
|
+
`})}}}function Vm(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,h]of l){const v=u.get(p);if(v!==void 0&&_e(v)===_e(h))continue;const y=c.get(p);if(y===void 0)return{ok:!1,reason:`Could not find where the given \`${p}\` is declared.`};const{tags:w,prose:g}=Fr(a,t,y.line),b=[...(v===void 0?w:w.filter(D=>{const L=gs(D.text);return L!==void 0&&Fm.has(L)})).map(D=>D.line),...v===void 0?g:[]];for(const D of b)o.push({...n(D),text:""}),d.add(D);const _=_t(a,y.span.end-1);if(v===void 0){o.push({start:n(y.line).start,end:n(_).end,text:""});for(let G=y.line;G<=_;G++)d.add(G);const D=Math.min(y.line,...b),L=y.blockHeader??D,R=(t[_+1]??"x").trim()==="",z=L===0||t[L-1].trim()==="",K=y.blockHeader===void 0||![...c.values()].some(G=>G.blockHeader===y.blockHeader&&G.line>y.line&&u.has([...c.entries()].find(([,X])=>X===G)?.[0]??""));R&&z&&K&&!d.has(_+1)&&(o.push({...n(_+1),text:""}),d.add(_+1));continue}const O=r(y.line),E=bl(v),T=v.type!==h.type||v.default!==h.default?y.blockHeader===void 0?yl(v):`${v.name} :: ${v.type} is ${v.default}`:t.slice(y.line,_+1).join(`
|
|
91
|
+
`).trim();o.push({start:n(y.line).start,end:n(_).end,text:(E?`${O}${E}
|
|
92
|
+
`:"")+`${O}${T}
|
|
93
|
+
`})}for(const[p,h]of c){if(h.blockHeader===void 0||u.has(p))continue;![...c.values()].some(y=>y.blockHeader===h.blockHeader&&!d.has(y.line))&&!d.has(h.blockHeader)&&(o.push({...n(h.blockHeader),text:""}),d.add(h.blockHeader))}const f=[...u.values()].filter(p=>!l.has(p.name));if(f.length>0){const p=Math.max(-1,...[...c.values()].map(m=>m.line)),h=(()=>{let m=-1;for(let b=0;b<t.length;b++){const _=t[b].trim();(_.startsWith("import ")||m>=0&&/^}\s*from\s/.test(_))&&(m=b)}return m})(),v=p>=0?p:h,y=f.map(m=>{const b=bl(m);return(b?`${b}
|
|
94
|
+
`:"")+`${yl(m)}
|
|
95
95
|
`}).join(`
|
|
96
|
-
`),
|
|
97
|
-
${
|
|
98
|
-
`})}}const
|
|
99
|
-
`).join("")})}}function
|
|
100
|
-
`});else{const
|
|
101
|
-
`})}}}function
|
|
102
|
-
`)};let d=-1;for(const f of l.sources)d=Math.max(d,
|
|
103
|
-
`)+p.map(
|
|
96
|
+
`),w=v>=0?n(v).end:n(0).end;o.push({start:w,end:w,text:`
|
|
97
|
+
${y}`}),t.some(m=>m.trim().startsWith("##! experimental.givens"))||o.push({start:0,end:0,text:`##! experimental.givens
|
|
98
|
+
`})}}const $l=(e,t)=>`import { ${e.join(", ")} } from ${bt(t)}`;function Hm(e){const{parsed:t,current:n,next:r,edits:s,wholeLine:i}=e,o=d=>_e(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(_e(n.imports)===_e(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(xe).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(m=>!m.claimed&&m.from===f.from);p&&(p.claimed=!0);const h=p?.names??[],y=f.names.filter(m=>!h.includes(m)).find(m=>l.has(m));if(y!==void 0)return{ok:!1,reason:`\`${y}\` is still read by a tile, so its import cannot be removed.`};if(_e(h)===_e(f.names))continue;const w=h.length===0?ka(t,d.statement):d.statement,g=t.commentIn(w);if(g)return{ok:!1,reason:`Changing this import would also remove the comment inside it (\`${t.text.slice(g.start,g.end).trim()}\`), so nothing was written. Delete it in the file first.`};s.push({...w,text:h.length===0?"":$l(h,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(_t(t,d.statement.end-1)).end;s.push({start:f,end:f,text:c.map(p=>`${$l(p.names,p.from)}
|
|
99
|
+
`).join("")})}}function Xm(e){const{lines:t,wholeLine:n,indentOf:r,current:s,next:i,edits:o,parsed:a}=e,l=new Map((s.drills??[]).map(c=>[Ls(c),c])),u=new Map((i.drills??[]).map(c=>[Ls(c),c]));for(const c of new Set([...l.keys(),...u.keys()])){const d=l.get(c),f=u.get(c);if(d&&f&&_e(d)===_e(f))continue;const p=f??d;if(f&&f.to.length===0)return{ok:!1,reason:`The drill on \`${c}\` names no destination.`};const h=a.sources.find(g=>g.name===p.source)?.dimensions.find(g=>g.name===p.name);if(h===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:v}=Fr(a,t,h.line),y=v.find(g=>/^#\s*drill\b/.test(g.text)),w=r(h.line);if(f===void 0)y&&o.push({...n(y.line),text:""});else if(y)o.push({...n(y.line),text:`${w}${xl(f)}
|
|
100
|
+
`});else{const g=n(h.line).start;o.push({start:g,end:g,text:`${w}${xl(f)}
|
|
101
|
+
`})}}}function Ym(e){const{lines:t,wholeLine:n,removedTiles:r,edits:s,parsed:i}=e;for(const o of r){if(je(o)||o.declaration.kind==="inherited")continue;const a=Lu(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=_t(i,a.statement.start),u=_t(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({...ka(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 Zm(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(je(f))continue;const p=u.get(f.source)??[];p.push(f),u.set(f.source,p)}const c=(f,p)=>{const h=f.declaration.kind==="reference"?f.declaration.from:f.name,v=(f.filters??[]).map(y=>`where: ${me.malloyPath(y.field)} ${y.op??"~"} $${y.given}`).join(", ");return[...ju(f).map(y=>`${p}${y}`),`${p}view: ${f.name} is ${h}${v?` + { ${v} }`:""}`].join(`
|
|
102
|
+
`)};let d=-1;for(const f of l.sources)d=Math.max(d,_t(l,f.span.end-1));for(const[f,p]of u)if(o.has(f)){const h=l.sources.find(b=>b.name===f);if(!h)return{ok:!1,reason:`Could not find where the source \`${f}\` is declared.`};if(!h.properties)return{ok:!1,reason:`\`${f}\` never opens an \`extend { … }\` block, so a new tile cannot be added inside it.`};const v=h.line,y=_t(l,h.properties.closeStart);let w=" ";for(let b=v+1;b<y;b++){const _=/^(\s+)view:/.exec(n[b]);if(_){w=_[1];break}}const g=r(y).start,m=(n[y-1]??"").trim()==="";a.push({start:g,end:g,text:(m?"":`
|
|
103
|
+
`)+p.map(b=>c(b,w)).join(`
|
|
104
104
|
|
|
105
105
|
`)+`
|
|
106
|
-
`})}else{const
|
|
107
|
-
source: ${
|
|
108
|
-
`+p.map(
|
|
106
|
+
`})}else{const h=i.find(m=>m.name===f);if(!h)return{ok:!1,reason:`The tile's source \`${f}\` is not declared.`};const v=`
|
|
107
|
+
source: ${h.name} is ${h.base} extend {
|
|
108
|
+
`+p.map(m=>c(m," ")).join(`
|
|
109
109
|
|
|
110
110
|
`)+`
|
|
111
111
|
}
|
|
112
|
-
`;let
|
|
112
|
+
`;let y=d;if(y<0)for(let m=0;m<n.length;m++){const b=n[m].trim();(/^(import\s|given:|}\s*from\s)/.test(b)||/^[A-Z_]+\s*::/.test(b))&&(y=m)}const w=y>=0?r(y).end:t.length,g=w===t.length&&!t.endsWith(`
|
|
113
113
|
`)?`
|
|
114
|
-
`:"";a.push({start:
|
|
115
|
-
`}),
|
|
116
|
-
`})}const
|
|
117
|
-
`).join("")})}if(
|
|
114
|
+
`:"";a.push({start:w,end:w,text:g+v}),d=y}}function Qm(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=>[nt(c),c]));for(const c of o.tiles){const d=u.get(nt(c));if(d===void 0||je(c)||je(d)||_e(Ns(d))===_e(Ns(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=zm(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}=Fr(l,t,f),h=s(f),v=ju(c,!1),y=new Map(v.map(T=>[gs(T)??T,T])),w=new Set,g=Mu(c.chart),m=Tl(d)!==Tl(c);if(m){const T=p.filter(R=>kr(R.text)),D=p.filter(R=>At(R.text)),L=d.chart==="custom"?p.filter(R=>At(R.text)||kr(R.text)):T.length>0?T:D.length>1?D:[];if(L.length>0)return{ok:!1,reason:`\`${c.source} -> ${c.name}\` has a chart line the builder does not model (${L.map(R=>R.text).join(" and ")}), so its chart cannot be changed here.`}}let b=!1;for(const T of p){if(m&&At(T.text)){g===void 0?a.push({...r(T.line),text:""}):T.text!==yn(g,c.chartCarried)&&a.push({...r(T.line),text:`${h}${yn(g,c.chartCarried)}
|
|
115
|
+
`}),b=!0;continue}const D=gs(T.text);if(D===void 0||!Nm.has(D))continue;const L=y.get(D);if(L===void 0){a.push({...r(T.line),text:""});continue}w.add(D),L!==T.text&&a.push({...r(T.line),text:`${h}${L}
|
|
116
|
+
`})}const _=v.filter(T=>!w.has(gs(T)??T));if(m&&g!==void 0&&!b&&_.push(yn(g,c.chartCarried)),_.length>0){const T=n[f];a.push({start:T,end:T,text:_.map(D=>`${h}${D}
|
|
117
|
+
`).join("")})}if(_e(d.filters)===_e(c.filters))continue;const O=Lu(e,c);if(!O)return{ok:!1,reason:`Could not find \`${c.name}\`'s declaration to filter it.`};if(O.body.kind==="reference"){const T=iv(e,c,O);if(T)return T;continue}if(O.body.kind!=="inline")return{ok:!1,reason:`\`${c.name}\`'s body is ${O.body.why}, so there is no single first stage to write its filter into.`};const E=Nu(c.filters,O.body.stage);if(E)return Fu(c.name,E.given);const I=zu(e,c,O.body.stage);if(I)return I}}const Tl=e=>e.chart==="default"?void 0:e.chart,Ns=e=>{const{chartLines:t,chartCarried:n,...r}=e;if(r.chart!=="default")return r;const{chart:s,...i}=r;return i};function Jm(e,t){const n=new Map(e.tiles.map(r=>[nt(r),r]));return{...t,tiles:t.tiles.map(r=>{const s=n.get(nt(r));return xe(r)&&r.chart===void 0&&s&&xe(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 ev(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&&!me.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 xi=e=>`##|(markdown) ${e.name}
|
|
118
118
|
${e.markdown===""?"":`${e.markdown}
|
|
119
119
|
`}|##
|
|
120
|
-
`;function
|
|
120
|
+
`;function tv(e){const{sourceText:t,lines:n,wholeLine:r,current:s,next:i,parsed:o,edits:a}=e,l=new Map(s.tiles.filter(je).map(p=>[p.name,p])),u=i.tiles.filter(je),c=p=>o.textBlocks.find(h=>h.name===p),d=new Set(u.map(p=>p.name));for(const p of l.keys()){const h=d.has(p)?void 0:c(p);if(!h)continue;const v=_t(o,h.span.end-1);a.push({...h.span,text:""});const y=r(v+1),w=h.line===0||n[h.line-1].trim()==="";y.end>y.start&&n[v+1].trim()===""&&w?a.push({...y,text:""}):h.line>0&&w&&t.slice(h.span.end).trim()===""&&a.push({...r(h.line-1),text:""})}const f=[];for(const p of u){const h=l.get(p.name),v=c(p.name);if(h===void 0){if(v)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(xi(p))}else h.markdown!==p.markdown&&(v?a.push({...v.span,text:xi(p)}):f.push(xi(p)))}if(f.length>0){const p=o.textBlocks.filter(g=>g.name===void 0||d.has(g.name)),h=p[p.length-1],v=o.sources.find(g=>g.name.endsWith("_tiles"));if(h){const g=h.span.end,m=t.slice(g);a.push({start:g,end:g,text:`
|
|
121
121
|
${f.join(`
|
|
122
|
-
`)}${
|
|
122
|
+
`)}${m===""||m.startsWith(`
|
|
123
123
|
`)?"":`
|
|
124
|
-
`}`});return}if(
|
|
124
|
+
`}`});return}if(v){const g=e.starts[o.blockStart(v.line)],m=g===0||t.slice(0,g).endsWith(`
|
|
125
125
|
|
|
126
|
-
`);a.push({start:
|
|
126
|
+
`);a.push({start:g,end:g,text:`${m?"":`
|
|
127
127
|
`}${f.join(`
|
|
128
128
|
`)}
|
|
129
|
-
`});return}const
|
|
129
|
+
`});return}const y=t.length,w=t===""||t.endsWith(`
|
|
130
130
|
|
|
131
131
|
`)?"":t.endsWith(`
|
|
132
132
|
`)?`
|
|
133
133
|
`:`
|
|
134
134
|
|
|
135
|
-
`;a.push({start:
|
|
136
|
-
`)})}}const
|
|
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
|
|
138
|
-
${n.indent}${
|
|
139
|
-
`)&&!/(?<!\r)\n/.test(e)))return
|
|
140
|
-
`),t,n);return
|
|
141
|
-
`)}}async function
|
|
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.
|
|
144
|
-
`);
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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(`
|
|
135
|
+
`;a.push({start:y,end:y,text:w+f.join(`
|
|
136
|
+
`)})}}const Qr=(e,t=me.isBareName)=>t(e)?void 0:`The name ${JSON.stringify(e)} cannot be written as a Malloy name.`;function nv(e,t){const n=new Map(e.tiles.map(o=>[nt(o),o]));if(Xe(t)==="notebook"&&t.columns!==void 0&&(Xe(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(nt(o));if(je(o)){const d=ev(o,a&&je(a)?a:void 0,r);if(d)return d;continue}const l=a&&xe(a)?a:void 0;if(a&&!l)continue;const u=o.chart;if(u!==void 0&&u!=="default"&&u!=="none"&&!Qs(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=Qr(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=C.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=Qr(a);if(l)return l}if(t.description!==e.description)for(const o of(t.description??"").split(/\r?\n/)){const a=C.annotationTextProblem("description line",o);if(a)return a}if(t.title!==e.title){const o=C.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=Qr(o.name,me.isStrictName);if(u)return u}const l=o.suggest?.source;if(l!==void 0&&l!==a?.suggest?.source){const u=Qr(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=C.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=C.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=C.annotationTextProblem(`starting value for ${o}`,a);if(l)return l}}const _t=(e,t)=>e.lineStarts.findLastIndex(n=>n<=t);function Lu(e,t){return e.parsed.sources.find(n=>n.name===t.source)?.views.find(n=>n.name===t.name)}function Nu(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 Fu(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 vs=e=>`where: ${me.malloyPath(e.field)} ${e.op??"~"} $${e.given}`;function Ol(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 rv(e,t,n){const r=e.commentIn(n);if(r)return r;const s=e.trailingComment(_t(e,t.end-1));return s&&s.start>=t.end&&e.text.slice(t.end,s.start).trim()===""?s:void 0}function sv(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 ka(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 zu(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((v,y)=>({clause:v,index:y})).filter(({clause:v})=>v.binding!==void 0);if(p.length===0)continue;const h=p.filter(({clause:v})=>i.has(v.binding.given));for(const{clause:v}of p)o.add(v.binding.given);if(h.length===0&&p.length===f.clauses.length){const v=ka(r,f.span),y=rv(r,f.span,v);if(y)return Ol(t.name,r,y);s.push({...v,text:""});continue}h.length>0&&(a=f.span);for(let v=p.length-1;v>=0;v--){const{clause:y,index:w}=p[v],g=i.get(y.binding.given);if(!g){const b=sv(f.clauses,w),_=r.commentIn(b);if(_)return Ol(t.name,r,_);s.push({...b,text:""});continue}const m=vs(g).replace(/^where:\s*/,"");m!==r.text.slice(y.span.start,y.span.end)&&s.push({...y.span,text:m})}}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(_t(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(vs).join(", ")}`:l.map(f=>`
|
|
138
|
+
${n.indent}${vs(f)}`).join("");s.push({start:u,end:u,text:d})}function iv(e,t,n){if(n.body.kind!=="reference")return;const{edits:r}=e,{fromSpan:s,refinement:i}=n.body,o=Nu(t.filters,i);if(o)return Fu(t.name,o.given);const a=t.filters??[];if(!i){if(a.length===0)return;const c=` + { ${a.map(vs).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 zu(e,t,i)}async function Wu(e,t,n={}){if(!(e.includes(`\r
|
|
139
|
+
`)&&!/(?<!\r)\n/.test(e)))return El(e,t,n);const s=await El(e.replace(/\r\n/g,`
|
|
140
|
+
`),t,n);return Rs(s)?s:{...s,source:s.source.replace(/\n/g,`\r
|
|
141
|
+
`)}}async function El(e,t,n){const r=await Tr(e,n.modelPath);if($r(r))return{ok:!1,reason:`Cannot edit a file that will not open: ${r.reason}`};const s=r.document,i=Jm(s,t),o=Wm(s,i,n.changeKind===!0);if("reason"in o)return o;const a=nv(s,i);if(a)return{ok:!1,reason:a};const l=await Iu(e);if(Eu(l))return{ok:!1,reason:`Cannot edit a file that will not open: ${l.reason}`};const u=e.split(`
|
|
142
|
+
`),c=Rm(e),d=g=>({start:c[g],end:g+1<c.length?c[g+1]:e.length}),f=g=>/^\s*/.exec(u[g])?.[0]??"",p=[],h={...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}:{},...n.explicitKind?{explicitKind:!0}:{}};for(const g of[Gm,Um,Hm,Vm,Xm,Ym,Zm,Qm,tv]){const m=g(h);if(m)return m}const v=g=>{const{drills:m,localGivens:b,kind:_,description:O,...E}=g,I=g.tiles.map(T=>{if(je(T))return T;if(T.filters?.length)return Ns(T);const{filters:D,...L}=T;return Ns(L)});return{...E,...O===void 0?{}:{description:Pu(O)},..._==="notebook"?{kind:_}:{},tiles:I,...m?.length?{drills:[...m].sort((T,D)=>Ls(T).localeCompare(Ls(D)))}:{},...b?.length?{localGivens:b}:{}}};if(p.length===0)return _e(v(s))!==_e(v(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 y=Lm(e,p);if((await vl(e)).length===0){const g=await vl(y);if(g.length>0)return{ok:!1,reason:`The edit would have produced a file Malloy cannot parse, so it was not written (${g[0]}). Your changes are still here.`}}const w=await Tr(y,n.modelPath);return $r(w)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${w.reason}`}:_e(v(w.document))!==_e(v(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:y}}function Bu({markdown:e,placeholder:t,onCommit:n,variant:r="document"}){const{theme:s}=Ke.usePublisherTheme(),[i,o]=k.useState(!1),a=k.useMemo(()=>i?{text:e}:void 0,[i,e]),{draft:l,patch:u,close:c,discard:d}=Gl(a,i,m=>n(m.text),()=>o(!1)),f=i&&l!==void 0&&l.text!==e,p=l!==void 0&&l.text!==e?ms(l.text):void 0;uu(f,()=>p!==void 0?!1:(c(),!0));const h=k.useRef(null),v=k.useRef(!1);k.useEffect(()=>{i||(v.current=!1)},[i]);const y=k.useCallback(m=>{!m||v.current||(v.current=!0,m.setSelectionRange(m.value.length,m.value.length))},[]);if(!i||l===void 0){const m=e.trim()?ms(e):void 0;return x.jsxs($.Box,{role:"button",tabIndex:0,onClick:b=>{b.target.closest("a")?b.preventDefault():o(!0)},onKeyDown:b=>{b.target===b.currentTarget&&(b.key!=="Enter"&&b.key!==" "||(b.preventDefault(),o(!0)))},sx:[{minHeight:24},cu(s,"prose")],children:[e.trim()?x.jsx(C.Prose,{variant:r,children:e}):x.jsx($.Typography,{variant:"body2",sx:{color:s.tileTitle,opacity:.6,fontStyle:"italic"},children:t}),m&&x.jsx($.Typography,{variant:"caption",color:"error",role:"alert",children:m})]})}const w=l.text!==e?ms(l.text):void 0,g=()=>{w===void 0&&c()};return x.jsxs($.Stack,{spacing:1,children:[x.jsx($.TextField,{multiline:!0,autoFocus:!0,minRows:3,maxRows:14,fullWidth:!0,value:l.text,placeholder:t,error:w!==void 0,helperText:w,inputRef:y,inputProps:{"aria-label":"Markdown"},onChange:m=>u(b=>{b.text=m.target.value}),onKeyDown:m=>{m.key==="Escape"?g():m.key==="Enter"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),g())},onBlur:m=>{m.relatedTarget instanceof Node&&h.current?.contains(m.relatedTarget)||c()}}),x.jsxs($.Stack,{ref:h,direction:"row",spacing:1,children:[x.jsx($.Button,{size:"small",variant:"outlined",disabled:w!==void 0,onClick:g,children:"Done"}),x.jsx($.Button,{size:"small",onMouseDown:m=>m.preventDefault(),onClick:()=>{d(),o(!1)},children:"Cancel"})]})]})}const ov="Write markdown: # heading, **bold**, - list";function av({tile:e,onChange:t,chrome:n="card"}){return x.jsx(C.TileCard,{chrome:n,kind:"text",children:x.jsx(Bu,{markdown:e.markdown,placeholder:ov,onCommit:t})})}const Fs=e=>e.label??C.tileTitle(`${e.source} -> ${e.name}`);function lv({tile:e,index:t,selected:n,flash:r=!1,menuOpen:s,bare:i=!1,onInsertAfter:o,onSelect:a,onOpenMenu:l,resizing:u=!1,width:c,onResizeStart:d,onResizeMove:f,onResizeEnd:p,children:h}){const{theme:v}=Ke.usePublisherTheme();return x.jsx(cm,{id:Fe(e),index:t,children:({ref:y,handleRef:w})=>x.jsxs($.Box,{ref:y,onClick:a,onPointerDown:g=>{g.button===0&&a()},role:"group","aria-label":`Tile ${e.name}`,"aria-current":n,onFocus:a,"data-tile-key":Fe(e),"data-flash":r||void 0,sx:{position:"relative",display:"grid",minWidth:0,cursor:"grab",...Gu(v,{selected:n,flash:r,bare:i}),"&&[data-dnd-dragging]":{opacity:1,outline:"none",boxShadow:v.shadow.drag},"&&[data-dnd-placeholder]":{opacity:.45,outline:`2px dashed ${v.accent}`,boxShadow:"none"},"&:hover .builder-affordance, &:focus-within .builder-affordance":{opacity:1},"@media (hover: none)":{"& .builder-affordance":{opacity:1}}},children:[h,x.jsx($.Box,{ref:w,"aria-label":`Move ${Wr(e)}`,sx:{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"}}),x.jsx($.IconButton,{className:"builder-affordance",size:"small","aria-label":`Settings for ${Wr(e)}`,onClick:g=>{g.stopPropagation(),l(g.currentTarget)},sx:{position:"absolute",top:`${-((i?C.BARE_RING_OFFSET_PX+1:0)+12)}px`,right:i?0:"12px",border:v.cardBorder,borderRadius:1,width:28,height:24,zIndex:2,color:v.tileTitle,bgcolor:v.tile,opacity:n||s?.9:0,transition:`opacity ${C.MOTION_FAST}`,...C.reducedMotionSx,"&:hover":{opacity:1,bgcolor:v.tile}},children:x.jsx(fv,{})}),d&&x.jsx($.Box,{className:"builder-affordance",[$u]:"",role:"separator",tabIndex:c?0:-1,"aria-orientation":"vertical","aria-label":`Width of ${Wr(e)}`,...c?{"aria-valuenow":c.span,"aria-valuemin":1,"aria-valuemax":c.columns,"aria-valuetext":`${c.span} of ${c.columns} columns`}:{},onKeyDown:g=>{if(!c)return;const m=g.key==="ArrowRight"?c.span+1:g.key==="ArrowLeft"?c.span-1:g.key==="Home"?1:g.key==="End"?c.columns:void 0;m!==void 0&&(g.preventDefault(),g.stopPropagation(),c.onStep(Math.min(Math.max(m,1),c.columns)))},onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onClick:g=>g.stopPropagation(),sx:{position:"absolute",top:0,bottom:0,right:"-5px",width:"10px",cursor:"col-resize",touchAction:"none",zIndex:2,opacity:u||n?1:0,transition:`opacity ${C.MOTION_FAST}`,...C.reducedMotionSx,"&:hover":{opacity:1},"&:focus-visible":{opacity:1,outline:`2px solid ${v.accent}`,outlineOffset:1,borderRadius:"3px"},"&::after":{content:'""',position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"4px",height:"28px",borderRadius:"2px",bgcolor:v.accent}}}),o&&x.jsx($.IconButton,{className:"builder-affordance",size:"small","aria-label":`Insert tile after ${Wr(e)}`,onClick:g=>{g.stopPropagation(),o()},sx:{position:"absolute",bottom:`-${(i?C.NOTEBOOK_GAP_PX:C.GRID_GAP_PX)/2+12}px`,left:"50%",transform:"translateX(-50%)",width:24,height:24,zIndex:3,color:v.tileTitle,bgcolor:v.tile,border:v.cardBorder,opacity:0,transition:`opacity ${C.MOTION_FAST}`,...C.reducedMotionSx,"&:hover, &:focus-visible":{opacity:1,bgcolor:v.tile}},children:x.jsx(C.AddIcon,{sx:{fontSize:14}})})]})})}const wi=4,Gu=(e,{selected:t,flash:n=!1,bare:r=!1})=>{const s=t||n?e.accent:"transparent",i=t?e.accent:e.cardBorder.replace(/^1px solid /,""),o=`outline-color ${C.MOTION_FAST}, border-color ${C.MOTION_FAST}, opacity ${C.MOTION_FAST}, box-shadow ${C.MOTION_FAST}`;return r?{borderRadius:1,"&::before":{content:'""',position:"absolute",inset:`${-C.BARE_RING_OFFSET_PX}px`,borderRadius:1,border:`2px solid ${s}`,pointerEvents:"none",transition:o,...C.reducedMotionSx},"&:hover::before":{borderColor:i}}:{borderRadius:1,outline:`2px solid ${s}`,outlineOffset:2,...n&&{boxShadow:`0 0 0 6px color-mix(in srgb, ${e.accent} 25%, transparent)`},transition:o,...C.reducedMotionSx,"&:hover":{outlineColor:i,boxShadow:e.shadow.lift}}};function cv({tile:e,heading:t,note:n,chrome:r="card"}){const{theme:s}=Ke.usePublisherTheme();return x.jsxs(C.TileCard,{chrome:r,children:[x.jsx(C.TileHeading,{title:t?.title??Fs(e),subtitle:t?t.subtitle:e.subtitle}),n&&x.jsx($.Typography,{variant:"body2",sx:{color:s.tileTitle,py:2},children:n}),x.jsxs($.Typography,{variant:"caption",sx:{display:"block",color:s.tileTitle,opacity:.7},children:[e.source," → ",e.name]})]})}function dv({after:e}){const{theme:t}=Ke.usePublisherTheme();return x.jsx(dm,{id:hu(e),after:e,children:({ref:n,isDropTarget:r})=>x.jsx($.Box,{ref:n,"aria-hidden":!0,sx:{minHeight:48,borderRadius:1,border:`1px dashed ${t.accent}`,bgcolor:r?`color-mix(in srgb, ${t.accent} 12%, transparent)`:"transparent",opacity:r?.95:.4,transition:`opacity ${C.MOTION_FAST}, background-color ${C.MOTION_FAST}`,...C.reducedMotionSx}})})}function uv({columns:e}){const{theme:t}=Ke.usePublisherTheme();return x.jsx($.Box,{"aria-hidden":!0,sx:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3,display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,gap:`${C.GRID_GAP_PX}px`},children:Array.from({length:e},(n,r)=>x.jsx($.Box,{sx:{borderLeft:`1px dashed ${t.accent}`,borderRight:r===e-1?`1px dashed ${t.accent}`:"none",opacity:.35}},r))})}function fv(){return x.jsxs($.SvgIcon,{sx:{fontSize:18},viewBox:"0 0 24 24",children:[x.jsx("circle",{cx:"3.5",cy:"12",r:"2"}),x.jsx("circle",{cx:"12",cy:"12",r:"2"}),x.jsx("circle",{cx:"20.5",cy:"12",r:"2"})]})}function hv({editor:e,reorder:t,resizing:n,gridBox:r,columns:s,notebook:i,chrome:o,canAdd:a,selected:l,flash:u,menuIndex:c,onSelect:d,onOpenMenu:f,openAdd:p,editTile:h,renderTile:v}){const{dragging:y,preview:w,onDragStart:g,onDragOver:m,onDragEnd:b}=t,{resize:_,startResize:O,onResize:E,endResize:I}=n,T=_!==void 0?e.document.tiles.map((z,K)=>K===_.index?{...z,colspan:_.span}:z):w??e.document.tiles,D=e.document.tiles.length===0,L=y?Ig(T,s):T.map(fu),R=z=>pv(z,Fs(z),h);return x.jsxs(x.Fragment,{children:[x.jsx(ug,{sensors:am,onDragStart:g,onDragOver:m,onDragEnd:b,children:x.jsxs($.Box,{ref:r,sx:{position:"relative"},children:[!i&&(y||_!==void 0)&&x.jsx(uv,{columns:s}),x.jsx(C.DashboardGrid,{tiles:L,columns:s,rowGapPx:o==="none"?C.NOTEBOOK_GAP_PX:C.GRID_GAP_PX,keyOf:z=>z.kind==="gap"?hu(z.after):Fe(z.tile),renderTile:z=>{if(z.kind==="gap")return x.jsx(dv,{after:z.after});const{tile:K,index:G}=z;return x.jsx(lv,{tile:K,index:G,selected:G===l,flash:Fe(K)===u,menuOpen:c===G,bare:o==="none",...i&&a?{onInsertAfter:()=>p(G+1)}:{},...s>1&&gv(K)?{resizing:_?.index===G,width:{span:K.colspan??1,columns:s,onStep:X=>{X!==(K.colspan??1)&&e.update(Y=>{const se=Y.tiles[G];se&&(se.colspan=X)})}},onResizeStart:X=>O(X,G),onResizeMove:E,onResizeEnd:I}:{},onSelect:()=>d(G),onOpenMenu:X=>f(X,G),children:je(K)?x.jsx(av,{tile:K,chrome:o,onChange:X=>h(Fe(K),Y=>{je(Y)&&(Y.markdown=X)})}):v&&!e.pendingOpen?v(K,R(K),o):x.jsx(cv,{tile:K,chrome:o,heading:R(K),...e.pendingOpen?{note:"Preview appears after you Save"}:{}})})}})]})}),i&&a&&!D&&x.jsx($.Button,{size:"small",startIcon:x.jsx(C.AddIcon,{}),"aria-label":"Add tile at the end",onClick:()=>p(),sx:{alignSelf:"center"},children:"Add tile"})]})}const pv=(e,t,n)=>{if(e.declaration.kind==="inherited")return;const r=Fe(e),s=i=>o=>n(r,a=>{xe(a)&&(o===""?delete a[i]:a[i]=o)});return{title:x.jsx(fo,{value:e.label??"",placeholder:t,ariaLabel:"Tile title",onCommit:s("label")}),subtitle:x.jsx(fo,{value:e.subtitle??"",placeholder:"Add a subtitle",ariaLabel:"Tile subtitle",faintWhenEmpty:!0,onCommit:s("subtitle")})}},gv=e=>je(e)||e.declaration.kind!=="inherited";function mv({editor:e,notebook:t,documentSlug:n,chrome:r,actions:s,descriptionSelected:i,selectDescription:o}){const{theme:a}=Ke.usePublisherTheme();return x.jsxs(x.Fragment,{children:[x.jsxs($.Stack,{direction:"row",sx:{alignItems:"center",gap:2},children:[x.jsx($.Typography,{variant:"h5",sx:{flex:1,minWidth:0},children:x.jsx(fo,{value:e.document.title,placeholder:n??(t?"Untitled notebook":"Untitled dashboard"),ariaLabel:t?"Notebook title":"Dashboard title",onCommit:l=>e.update(u=>{u.title=l})})}),x.jsx($.Box,{sx:{my:"-4px"},children:s})]}),x.jsx($.Box,{role:"group","aria-label":"Description","aria-current":i,onPointerDown:o,onFocus:o,sx:r==="none"?{my:`${C.BARE_DESCRIPTION_MARGIN_PX}px`}:void 0,children:x.jsx(C.TileCard,{chrome:r,kind:"text",sx:{position:"relative",overflow:"visible",...Gu(a,{selected:i,bare:r==="none"})},children:x.jsx(Bu,{markdown:e.document.description??"",placeholder:"Add a description",onCommit:l=>e.update(u=>{l.trim()===""?delete u.description:u.description=l})})})})]})}const vv=({size:e,notebook:t,savesTo:n,onEvent:r})=>({size:e,saved:({size:s,structural:i,durationMs:o,fromOpen:a})=>r?.(t?{type:"notebook.saved",cells:s,structural:i,converted:a,where:n,durationMs:o}:{type:"dashboard.saved",tiles:s,structural:i,where:n,durationMs:o}),refused:s=>r?.({type:t?"notebook.save_refused":"dashboard.save_refused",reason:s}),undone:({size:s,structural:i,durationMs:o})=>r?.(t?{type:"notebook.save_undone",cells:s,structural:i,where:n,durationMs:o}:{type:"dashboard.save_undone",tiles:s,structural:i,where:n,durationMs:o}),undoRefused:s=>r?.({type:t?"notebook.save_undo_refused":"dashboard.save_undo_refused",reason:s})}),bv=C.createSvgIcon(x.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"})),yv=C.createSvgIcon(x.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"})),bo=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),_i=bo?"⌘":"Ctrl+",Cl=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"},ki=e=>e instanceof Element&&e.closest('[role="dialog"], .MuiPopover-root, .MuiDialog-root')!==null;function xv(e){const t=k.useRef(e);k.useEffect(()=>{t.current=e});const[n,r]=k.useState(!1);k.useEffect(()=>{n&&(r(!1),t.current.save?.())},[n]),k.useEffect(()=>{const s=i=>{const o=t.current;if(o.paused)return;const a=bo?i.metaKey:i.ctrlKey,l=i.key.toLowerCase();if(i.key==="Escape"){if(Cl(i.target)||ki(i.target))return;o.escape();return}if(Cl(i.target)){if(a&&l==="s"){if(i.preventDefault(),!o.save||ki(i.target))return;i.target.blur(),r(!0)}return}if(ki(i.target)){a&&l==="s"&&i.preventDefault();return}if(a&&l==="z"){i.preventDefault(),i.shiftKey?o.redo():o.undo();return}if(!bo&&a&&l==="y"){i.preventDefault(),o.redo();return}if(a&&l==="s"){i.preventDefault(),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 Il={package:"Saves to the package file",browser:"Saves in this browser",host:"Saves to the app this is embedded in"};function wv({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:s,saving:i,onSave:o,savesTo:a="package",saveLabel:l,saveButton:u,actions:c,onAddTile:d,onExit:f}){return x.jsxs($.Stack,{direction:"row","aria-label":"Builder actions",sx:{alignItems:"center",gap:.5,flexShrink:0,"& .MuiButton-root":{whiteSpace:"nowrap"}},children:[d&&x.jsx($.Button,{startIcon:x.jsx(C.AddIcon,{}),onClick:d,"aria-label":"Add tile",children:"Tile"}),d&&x.jsx($.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),x.jsx($.Tooltip,{title:`Undo (${_i}Z)`,children:x.jsx("span",{children:x.jsx($.IconButton,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:x.jsx(yv,{fontSize:"small"})})})}),x.jsx($.Tooltip,{title:`Redo (${_i}⇧Z)`,children:x.jsx("span",{children:x.jsx($.IconButton,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:x.jsx(bv,{fontSize:"small"})})})}),(c||o||f)&&x.jsx($.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),c,o?x.jsx($.Tooltip,{title:s?`Save (${_i}S) · ${l??Il[a]}`:l??Il[a],children:x.jsx("span",{children:x.jsx($.Button,{ref:u,variant:s?"contained":"outlined",disabled:!s||i,onClick:o,sx:{minWidth:124},children:i?"Saving…":s?"Save":"Saved"})})}):null,o&&x.jsx($.Box,{component:"span","aria-live":"polite",sx:{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},children:i?"Saving":s?"Unsaved changes":"All changes saved"}),f&&x.jsx(C.SecondaryButton,{label:"Close",icon:x.jsx(C.CheckIcon,{}),onClick:f})]})}const _v=C.createSvgIcon(x.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"})),kv=C.createSvgIcon(x.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function Sv({controls:e,tileCount:t,unknownFieldsOf:n,onEdit:r,onAdd:s,addDisabledReason:i,onRemove:o,children:a}){const{theme:l}=Ke.usePublisherTheme();return x.jsx(x.Fragment,{children:x.jsxs($.Stack,{sx:{gap:1,position:"sticky",top:0,zIndex:C.STICKY_CONTROLS_Z,bgcolor:"background.default",pb:1},children:[x.jsx($.Stack,{direction:"row",sx:{gap:2,alignItems:"center",minHeight:32},children:x.jsxs($.Stack,{direction:"row",role:"group","aria-label":"Filters",sx:{gap:1,alignItems:"center",flexWrap:"wrap",flex:1,minWidth:0},children:[x.jsx(kv,{sx:{fontSize:18,color:l.tileTitle,opacity:.7}}),x.jsx($.Typography,{variant:"subtitle2",sx:{color:l.tileTitle,mr:.5},children:"Filters"}),e.length===0&&x.jsx($.Typography,{variant:"body2",sx:{color:l.tileTitle,opacity:.8},children:"None yet."}),e.map(u=>{const c=n(u.name,u.type);return x.jsx($.Tooltip,{title:c.length>0?`$${u.name} · cannot filter on: ${c.join(", ")}`:`$${u.name} · ${u.origin==="dashboard"?"declared here":"from the model"} · ${u.boundTiles} of ${t} tiles`,children:x.jsx($.Chip,{size:"small",label:`${u.label??u.name}${u.boundTiles===0?" · unused":""}`,"aria-label":`Edit filter ${u.name}`,color:c.length>0?"warning":"default",variant:u.origin==="dashboard"?"filled":"outlined",onClick:()=>r(u),onDelete:()=>o(u.name),deleteIcon:x.jsx(_v,{"aria-label":`Remove filter ${u.name}`}),sx:{opacity:u.boundTiles===0?.6:1,cursor:"pointer",transition:`opacity ${C.MOTION_FAST}`,...C.reducedMotionSx}})},u.name)}),x.jsx($.Tooltip,{title:i??"",children:x.jsx("span",{children:x.jsx($.Chip,{component:"button",size:"small",variant:"outlined",icon:x.jsx(C.AddIcon,{}),label:"Filter","aria-label":"Add filter","aria-haspopup":"dialog",disabled:i!==void 0,onClick:()=>s(),sx:{cursor:"pointer",color:l.tileTitle,borderStyle:"dashed","& .MuiChip-icon":{color:"inherit",fontSize:16}}})})})]})}),a]})})}function $v(e,t){const n=new Map(e.tiles.map((r,s)=>[Fe(r),{tile:r,index:s}]));for(const[r,s]of t.tiles.entries()){const i=n.get(Fe(s));if(!i||i.index!==r||JSON.stringify(i.tile)!==JSON.stringify(s))return Fe(s)}}function Tv({editor:e,gridBox:t}){const[n,r]=k.useState(void 0),s=typeof n=="object"?n.tile:void 0,i=n==="description",o=k.useCallback(v=>r(y=>typeof y=="object"&&y.tile===v?y:{tile:v}),[]),a=k.useCallback(()=>r(v=>v==="description"?v:void 0),[]),l=k.useCallback(()=>r("description"),[]),u=k.useCallback(()=>r(void 0),[]),[c,d]=k.useState(void 0),f=k.useRef(!1),p=k.useRef(e.document);k.useEffect(()=>{const v=p.current;if(p.current=e.document,!f.current)return;f.current=!1;const y=$v(v,e.document);if(y===void 0)return;d(y),Array.from(t.current?.querySelectorAll("[data-tile-key]")??[]).find(g=>g.dataset.tileKey===y)?.scrollIntoView?.({block:"nearest",behavior:C.scrollBehavior()})},[e.document,t]),k.useEffect(()=>{if(c===void 0)return;const v=setTimeout(()=>d(void 0),1500);return()=>clearTimeout(v)},[c]);const h=k.useMemo(()=>({...e,undo:()=>{f.current=!0,e.undo()},redo:()=>{f.current=!0,e.redo()}}),[e]);return{selected:s,descriptionSelected:i,selectTile:o,deselectTile:a,selectDescription:l,clearSelection:u,flash:c,stepEditor:h}}function Ov({dirty:e,saving:t,canSave:n,save:r,onExit:s}){const[i,o]=k.useState("idle"),[a,l]=k.useState(!1),u=k.useRef(r);u.current=r;const c=k.useRef(s);c.current=s;const d=k.useRef(0),f=k.useCallback(async()=>{const h=++d.current;l(!1),o("saving");try{await u.current()}catch{d.current===h&&o("idle");return}d.current===h&&l(!0)},[]);return k.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:k.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 Ev({editor:e,onSave:t,onDirtyChange:n,onExit:r,onChange:s,extraDirty:i=!1,report:o,unit:a,prepare:l,shortcuts:u}){const[c,d]=k.useState(!1),[f,p]=k.useState(!1),h=k.useRef(null),v=k.useRef(o);v.current=o;const y=e.dirty||i,w=(e.edited??e.dirty)||i;k.useEffect(()=>{s?.(e.document)},[e.document,s]),k.useLayoutEffect(()=>{n?.(w)},[w,n]);const g=k.useRef(n);g.current=n,k.useEffect(()=>()=>g.current?.(!1),[]);const m=k.useRef(a);m.current=a,k.useEffect(()=>{p(!1)},[e.document]);const b=k.useCallback(()=>{d(!0),p(!1);const G=C.now(),{structural:X}=e,Y=e.pendingOpen??!1,se=v.current.size;return e.save().then(te=>{te.ok===!0?v.current.saved({size:se,structural:X,fromOpen:Y,durationMs:C.now()-G}):v.current.refused(te.reason)}).finally(()=>d(!1))},[e]),_=k.useRef(!1),O=k.useRef(!1);k.useEffect(()=>{!O.current||c||(O.current=!1,h.current?.focus())},[f,c]);const E=k.useCallback(()=>{if(!t||c||_.current||!e.canUndoSave)return;_.current=!0,d(!0);const G=C.now(),X=e.lastSave?.structural??!1,Y=v.current.size;return e.undoSave().then(se=>{se.ok===!0?(O.current=!0,p(!0),v.current.undone({size:Y,structural:X,fromOpen:!1,durationMs:C.now()-G})):v.current.undoRefused(se.reason)}).finally(()=>{_.current=!1,d(!1)})},[t,c,e]),I=k.useCallback(()=>{if(!(!t||!e.dirty||c))return b()},[t,e,c,b]),T=k.useRef(I);T.current=I;const D=k.useCallback(()=>{const G=()=>T.current();return l?l(G):G()},[l]),L=Ov({dirty:w,saving:c,canSave:!!t,save:D,onExit:()=>r?.()});xv(k.useMemo(()=>({...u,undo:e.undo,redo:e.redo,...t?{save:D}:{},paused:L.dialog.open}),[u,e,t,D,L.dialog.open]));const R=!!t&&!c&&e.canUndoSave,z=e.lastSave,K={canUndo:e.canUndo,canRedo:e.canRedo,onUndo:e.undo,onRedo:e.redo,dirty:y,saving:c,saveButton:h,...t?{onSave:D}:{},...r?{onExit:L.requestExit}:{}};return{saving:c,save:D,exitGuard:L,undoSave:E,canUndoSave:R,lastSave:z,toolbarProps:K}}function Jr(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function Dl(e){for(const t of e??[]){const n=/^#\s*(?:-[A-Za-z_]+\s+)*([a-z_]+)/.exec(t.trim())?.[1];if(n&&Tu.includes(n))return n}}const Cv=1;function qu(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(...qu(a,`${t}${i}.`,n-1))}}}return r}function Iv(e){const t=new Map;for(const n of Ku(e))t.set(n.name,qu(n.schema?.fields,"",Cv));return t}function Ku(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 Dv=e=>(e.annotations??[]).some(t=>{const n=t.value??"";return n.startsWith("#(malloy)")&&of.parseTag(n.slice(9)).tag?.has("calculation")===!0});function Av(e){const t=new Map;for(const n of Ku(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(Dv)&&r.add(s.name)}t.set(n.name,r)}return t}function Al(e,t){return!e||t===void 0?void 0:e.sources.find(r=>r.name===t)?.fields.filter(r=>r.kind==="dimension")}const Uu=e=>(e??"").startsWith("dashboards/"),Pv=e=>e.modelPath??e.path??"";function Vu(e){const t=[],n=new Set;for(const r of e){const s=Pv(r);if(Uu(s))continue;const i=Iv(r),o=Av(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,...Jr(a.annotations)?{description:Jr(a.annotations)}:{},views:(a.views??[]).filter(c=>typeof c.name=="string").map(c=>({name:c.name,...Jr(c.annotations)?{description:Jr(c.annotations)}:{},...Dl(c.annotations)?{chart:Dl(c.annotations)}:{},...o.get(l)?.has(c.name)?{aggregateOnly:!0}:{}})),givens:u,fields:i.get(l)??[]})}}return{sources:t}}function Mv({editor:e,opened:t,givens:n,catalog:r}){const[s,i]=k.useState(void 0),o=k.useMemo(()=>{const h=new Set((t.localGivens??[]).map(v=>v.name));return(n??[]).filter(v=>!h.has(v.name))},[t,n]),a=k.useMemo(()=>hf(e.document,o),[e.document,o]),l=k.useMemo(()=>new Map(e.document.sources.map(h=>[h.name,Al(r,h.base)])),[r,e.document.sources]),u=k.useCallback(h=>l.get(h.source)??Al(r,h.source),[l,r]),c=(h,v)=>{const y=[];for(const w of e.document.tiles){if(!xe(w))continue;const g=u(w);if(!g)continue;const m=new Map(g.map(b=>[b.name,b.type]));for(const b of w.filters??[])b.given===h&&(!m.has(b.field)||!rs(v,m.get(b.field)))&&y.push(`${b.field} on ${w.label??w.name} (${e.document.sources.find(_=>_.name===w.source)?.base??w.source})`)}return y},d=k.useMemo(()=>a.filter(h=>h.origin==="model"&&h.boundTiles===0),[a]);return{filterDialog:s,setFilterDialog:i,controlList:a,fieldsFor:u,unknownFieldsOf:c,available:d,applyFilter:(h,v,y)=>{i(void 0),e.update(w=>{y&&xf(w,y),yf(w,h,v)})},dropControl:h=>{i(void 0),e.update(v=>wf(v,h))}}}function jv({pendingOpen:e,prepare:t}){const[n,r]=k.useState(void 0),s=k.useRef(e);s.current=e;const i=k.useCallback(o=>s.current?new Promise(a=>r({go:()=>{r(void 0),a(t(o))},stop:()=>{r(void 0),a()}})):t(o),[t]);return{confirmConversion:n,prepareSave:i}}function Rv(e){const{splice:t,onSave:n,structural:r,clearsHistory:s,opensDirty:i=!1}=e,[o,a]=k.useState({stack:[e.document],index:0}),[l,u]=k.useState(e.source),[c,d]=k.useState(void 0),[f,p]=k.useState(e.document),[h,v]=k.useState(i),[y,w]=k.useState(e.replaces),[g,m]=k.useState(!1),b=o.stack[o.index],_=k.useRef(o);_.current=o;const O=k.useRef(!1),[E,I]=k.useState(!1),T=j=>{O.current=j,I(j)},[D,L]=k.useState(void 0),R=k.useCallback(j=>{d(void 0),a(q=>{const J=structuredClone(q.stack[q.index]);if(j(J),JSON.stringify(J)===JSON.stringify(q.stack[q.index]))return q;const H=[...q.stack.slice(0,q.index+1),J].slice(-100);return{stack:H,index:H.length-1}})},[]),z=k.useCallback(()=>{d(void 0),a(j=>j.index>0?{...j,index:j.index-1}:j)},[]),K=k.useCallback(()=>{d(void 0),a(j=>j.index<j.stack.length-1?{...j,index:j.index+1}:j)},[]),G=k.useCallback(async(j,q)=>{try{return await t(j,q)}catch(J){return{ok:!1,reason:`Could not build the file: ${J instanceof Error?J.message:String(J)}`}}},[t]),X=k.useCallback(async()=>{if(O.current)return{ok:!1,reason:"A save is still being written."};const j={source:l,saved:f,history:_.current,pendingOpen:h,replacing:y,unwritten:g},q=s?.(f,b)??!1,J=r?.(f,b)??!1;T(!0);try{const ee=await G(l,b);if(Rs(ee))return d(ee.reason),{ok:!1,reason:ee.reason};try{await n?.(ee.source,{purpose:"save",document:b})}catch(S){const P=`Could not save: ${S instanceof Error?S.message:String(S)}`;return d(P),{ok:!1,reason:P}}u(ee.source),p(b),v(!1),w(void 0),m(!1);const H=q?{stack:[b],index:0}:j.history;return a(S=>S===j.history?H:q?{stack:[S.stack[S.index]],index:0}:S),L(n?{before:j,after:H,lastSave:{before:y??l,after:ee.source,structural:J,clearsHistory:q}}:void 0),d(void 0),{ok:!0}}finally{T(!1)}},[b,G,n,l,f,h,y,g,s,r]),Y=k.useCallback(async()=>{if(O.current)return{ok:!1,reason:"A save is still being written."};if(!n||D===void 0||D.after!==_.current)return{ok:!1,reason:"There is no save to undo."};const{before:j}=D;T(!0);try{await n(j.replacing??j.source,{purpose:"undo",document:j.saved})}catch(q){const J=`Could not undo the save: ${q instanceof Error?q.message:String(q)}`;return d(J),{ok:!1,reason:J}}finally{T(!1)}return u(j.source),p(j.saved),v(j.pendingOpen),w(j.replacing),m(j.unwritten||j.replacing!==void 0),a(q=>q===D.after?j.history:q),L(void 0),d(void 0),{ok:!0}},[n,D]),se=k.useMemo(()=>g||JSON.stringify(b)!==JSON.stringify(f),[b,f,g]),te=k.useMemo(()=>r?.(f,b)??!1,[b,f,r]),A=k.useMemo(()=>s?.(f,b)??!1,[b,f,s]),B=D!==void 0&&D.after===o,N=k.useCallback(async()=>{const j=await G(l,b);return Rs(j)?{ok:!1,reason:j.reason}:{ok:!0,source:j.source}},[b,G,l]);return{document:b,saved:f,source:l,canUndo:o.index>0,canRedo:o.index<o.stack.length-1,dirty:se||h,edited:se,pendingOpen:h,...c===void 0?{}:{error:c},update:R,undo:z,redo:K,save:X,preview:N,structural:te,clearsHistory:A,canUndoSave:B&&!E&&n!==void 0,...B?{lastSave:D.lastSave}:{},undoSave:Y}}const Lv=(e,t)=>{const n=new Set(e.tiles.map(vo)),r=new Set(t.tiles.map(vo));return[...n].some(s=>!r.has(s))||[...r].some(s=>!n.has(s))};function Nv(e){const{conversion:t,modelPath:n,explicitKind:r,...s}=e,i=t?.from,o=t?.to,a=k.useCallback((l,u)=>Wu(i!==void 0&&l===i?o:l,u,{changeKind:!0,...n!==void 0?{modelPath:n}:{},...r?{explicitKind:r}:{}}),[i,o,n,r]);return Rv({...s,splice:a,structural:Lv,opensDirty:t!==void 0})}function Fv({editorDirty:e}){const[t,n]=k.useState(!1),r=k.useRef(void 0),s=k.useRef(void 0),i=k.useMemo(()=>({setDirty:n,commitRef:r}),[]),o=k.useCallback(a=>{if(!r.current)return a();if(r.current())return new Promise(l=>{s.current=()=>l(a())})},[]);return k.useEffect(()=>{if(t||!s.current)return;const a=s.current;s.current=void 0,a()},[t,e]),{draftDirty:t,openDraft:i,prepare:o}}const Hu="dashboards/document.malloy",Xu=e=>e.slice(0,e.lastIndexOf("/")+1),Yu=(e,t)=>new URL(e,`https://malloy.invalid/${Xu(t)}`).pathname.slice(1);function zv(e,t){const n=Xu(t).split("/").filter(Boolean),r=e.split("/");let s=0;for(;s<n.length&&s<r.length-1&&n[s]===r[s];)s++;const i=n.length-s;return`${i===0?"./":"../".repeat(i)}${r.slice(s).join("/")}`}function Wv(e,t,n,r=Hu){return e.sources.some(s=>s.base===t)?!0:e.imports.some(s=>s.kind==="names"?s.names.includes(t):Yu(s.from,r)===n)}function Bv(e,t,n,r=Hu){const{imports:s}=e;if(Wv(e,t,n,r))return s;const i=s.findIndex(o=>o.kind==="names"&&Yu(o.from,r)===n);return i<0?[...s,{kind:"names",names:[t],from:zv(n,r)}]:s.map((o,a)=>a===i&&o.kind==="names"?{...o,names:[...o.names,t]}:o)}function Gv({editor:e,notebook:t,columns:n,modelPath:r,selectTile:s,deselectTile:i}){const[o,a]=k.useState(void 0),[l,u]=k.useState(!1),[c,d]=k.useState(void 0);return{menu:o,setMenu:a,addingTile:l,openAdd:g=>{d(g),u(!0)},closeAdd:()=>u(!1),addTile:g=>{u(!1),e.update(m=>{g.modelPath&&(m.imports=Bv(m,g.base,g.modelPath,...r?[r]:[]));let b=m.sources.find(E=>E.base===g.base);if(!b){const E=new Set(m.sources.map(T=>T.name));let I=`${g.base}_tiles`;for(let T=2;E.has(I);T++)I=`${g.base}_tiles_${T}`;b={name:I,base:g.base},m.sources.push(b)}const _=new Set(m.tiles.filter(xe).filter(E=>E.source===b.name).map(E=>E.name));let O=`${g.view}_tile`;for(let E=2;_.has(O);E++)O=`${g.view}_tile_${E}`;m.tiles.splice(c??m.tiles.length,0,{name:O,source:b.name,declaration:{kind:"reference",from:g.view},...t?{}:{colspan:g.colspan},...g.label?{label:g.label}:{},...g.chart?{chart:g.chart}:{},...g.chartCarried?{chartCarried:g.chartCarried}:{}})}),s(c??e.document.tiles.length)},addText:()=>{u(!1),e.update(g=>{const m=new Set(g.tiles.filter(je).map(_=>_.name));let b=1;for(;m.has(`text_${b}`);)b++;g.tiles.splice(c??g.tiles.length,0,{kind:"text",name:`text_${b}`,markdown:"",...t?{}:{colspan:n}})}),s(c??e.document.tiles.length)},editTile:(g,m)=>e.update(b=>{const _=b.tiles.find(O=>Fe(O)===g);_&&m(_)}),removeTile:g=>{a(void 0),i(),e.update(m=>{m.tiles.splice(g,1)})}}}var qv=Object.defineProperty,Kv=Object.defineProperties,Uv=Object.getOwnPropertyDescriptors,Pl=Object.getOwnPropertySymbols,Vv=Object.prototype.hasOwnProperty,Hv=Object.prototype.propertyIsEnumerable,Ml=(e,t,n)=>t in e?qv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t)=>{for(var n in t||(t={}))Vv.call(t,n)&&Ml(e,n,t[n]);if(Pl)for(var n of Pl(t))Hv.call(t,n)&&Ml(e,n,t[n]);return e},on=(e,t)=>Kv(e,Uv(t));function Xv(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function es(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function Si(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Yv(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=(m,b)=>m===b||m!==null&&typeof m=="object"&&"id"in m&&m.id===b;if(Array.isArray(e)){const m=e.findIndex(_=>l(_,i.id)),b=e.findIndex(_=>l(_,o.id));if(m===-1||b===-1){if(Si(i)){const _=i.initialIndex,O=i.index;return _===O||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,O)}return e}if(!a&&"index"in i&&typeof i.index=="number"){const _=i.index;if(_!==m)return n(e,m,_)}return n(e,m,b)}const u=Object.entries(e);let c=-1,d,f=-1,p;for(const[m,b]of u)if(c===-1&&(c=b.findIndex(_=>l(_,i.id)),c!==-1&&(d=m)),f===-1&&(f=b.findIndex(_=>l(_,o.id)),f!==-1&&(p=m)),c!==-1&&f!==-1)break;if(c===-1&&Si(i)){const m=i.initialGroup==null?void 0:es(e,i.initialGroup),b=i.initialIndex,_=i.group==null?void 0:es(e,i.group),O=i.index;if(m==null||_==null||m===_&&b===O)return"preventDefault"in t&&t.preventDefault(),e;if(m===_)return on(sn({},e),{[m]:n(e[m],b,O)});const E=e[m][b];return on(sn({},e),{[m]:[...e[m].slice(0,b),...e[m].slice(b+1)],[_]:[...e[_].slice(0,O),E,...e[_].slice(O)]})}if(!i.manager)return e;const{dragOperation:h}=i.manager,v=(s=(r=h.shape)==null?void 0:r.current.center)!=null?s:h.position.current;if(p==null){const m=es(e,o.id);if(m!=null){const b=o.shape&&v.y>o.shape.center.y?e[m].length:0;p=m,f=b}}if(d==null||p==null||d===p&&c===f){if(d!=null&&d===p&&c===f&&Si(i)){const m=i.group==null?void 0:es(e,i.group),b=i.group!=null&&m!==d,_=i.index!==c;if(b||_){const O=i.group==null?d:m;if(O!=null){if(d===O)return on(sn({},e),{[d]:n(e[d],c,i.index)});const E=e[d][c];return on(sn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[O]:[...e[O].slice(0,i.index),E,...e[O].slice(i.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===p)return on(sn({},e),{[d]:n(e[d],c,f)});const w=o.shape&&Math.round(v.y)>Math.round(o.shape.center.y)?1:0,g=e[d][c];return on(sn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[p]:[...e[p].slice(0,f+w),g,...e[p].slice(f+w)]})}function Zv(e,t){return Yv(e,t,Xv)}function Qv({tiles:e,commit:t,onLanded:n}){const[r,s]=k.useState(void 0),i=k.useRef(void 0),[o,a]=k.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 h=i.current??e;let v;if(p.type===Su){const{after:y}=p.data,w=h.findIndex(b=>Fe(b)===f.id);if(w<0||y===f.id)return;const m=h.filter((b,_)=>_!==w).findIndex(b=>Fe(b)===y)+1;v=Cg(h,w,m)}else{const y=h.map(Fe),w=Zv(y,d);if(w.every((m,b)=>m===y[b]))return;const g=new Map(h.map(m=>[Fe(m),m]));v=Eg(w.map(m=>g.get(m)),e.map(m=>m.break??!1))}i.current=v,s(v)},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(h=>Fe(h)===d.operation.source?.id);p>=0&&n(p)}}}const $i=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function Jv({tiles:e,columns:t,gridBox:n,onStart:r,commit:s}){const[i,o]=k.useState(void 0),a=k.useRef(void 0),l=f=>{a.current=f,o(f)};return k.useEffect(()=>()=>$i(!1),[]),{resize:i,startResize:(f,p)=>{const h=n.current?.getBoundingClientRect(),v=f.currentTarget.parentElement?.getBoundingClientRect();if(!h||!v)return;f.stopPropagation(),f.preventDefault(),f.currentTarget.setPointerCapture(f.pointerId),$i(!0),r(p);const y=e[p]?.colspan??1;l({index:p,span:y,from:y,left:v.left,track:(h.width-C.GRID_GAP_PX*(t-1))/t})},onResize:f=>{const p=a.current;if(!p)return;const h=f.clientX-p.left,v=Math.round((h+C.GRID_GAP_PX)/(p.track+C.GRID_GAP_PX)),y=Math.min(Math.max(v,1),t);y!==p.span&&l({...p,span:y})},endResize:f=>{f.currentTarget.hasPointerCapture(f.pointerId)&&f.currentTarget.releasePointerCapture(f.pointerId),$i(!1);const p=a.current;if(!p)return;const{index:h,span:v,from:y}=p;l(void 0),!(f.type==="pointercancel"||v===y)&&s(h,v)}}}function Zu({source:e,document:t,onSave:n,onChange:r,onDirtyChange:s,onExit:i,renderTile:o,controls:a,givens:l,catalog:u,toolbar:c,dashboards:d,onEvent:f,conversion:p,savesTo:h="package",saveLabel:v,replaces:y,modelPath:w,explicitKind:g,addFilterDisabledReason:m}){const b=Nv({source:e,document:t,...n?{onSave:n}:{},...p?{conversion:p}:{},...y!==void 0?{replaces:y}:{},...w!==void 0?{modelPath:w}:{},...g?{explicitKind:g}:{}}),_=k.useRef(null),{selected:O,descriptionSelected:E,selectTile:I,deselectTile:T,selectDescription:D,clearSelection:L,flash:R,stepEditor:z}=Tv({editor:b,gridBox:_}),K=b.document.kind==="notebook",G=K?1:b.document.columns??C.DEFAULT_COLUMNS,X=K?"none":"card",Y=w?.split("/").at(-1)?.replace(/\.malloy$/,""),se=Qv({tiles:b.document.tiles,commit:ce=>b.update(pe=>{pe.tiles=ce}),onLanded:I}),{dragging:te}=se,A=Jv({tiles:b.document.tiles,columns:G,gridBox:_,onStart:I,commit:(ce,pe)=>b.update(M=>{const U=M.tiles[ce];U&&(U.colspan=pe)})}),B=Gv({editor:b,notebook:K,columns:G,modelPath:w,selectTile:I,deselectTile:T}),{menu:N,addingTile:j,openAdd:q}=B,J=Mv({editor:b,opened:t,givens:l,catalog:u}),{filterDialog:ee,setFilterDialog:H}=J,[S,P]=k.useState(void 0),{draftDirty:F,openDraft:V,prepare:ie}=Fv({editorDirty:b.dirty}),{confirmConversion:Z,prepareSave:oe}=jv({pendingOpen:b.pendingOpen,prepare:ie}),W=k.useMemo(()=>({escape:()=>{!N&&!ee&&!j&&S===void 0&&Z===void 0&&L()},nudge:ce=>{if(te||O===void 0||K)return;const pe=b.document.tiles[O];if(!pe||xe(pe)&&pe.declaration.kind==="inherited")return;const M=C.nudgedSpan(pe.colspan??1,ce,G);M!==(pe.colspan??1)&&b.update(U=>{U.tiles[O].colspan=M})}}),[b,N,ee,j,S,Z,L,O,G,K,te]),Q=Ev({editor:z,extraDirty:F,prepare:oe,unit:{name:"tile",count:ce=>ce.tiles.length},onSave:n,onDirtyChange:s,onExit:i,onChange:r,shortcuts:W,report:vv({size:b.document.tiles.length,notebook:K,savesTo:h,onEvent:f})}),ne=b.document.tiles.length===0,re=x.jsx(wv,{...Q.toolbarProps,...c?{actions:c}:{},...u?{onAddTile:()=>q()}:{},savesTo:h,...v?{saveLabel:v}:{}});return x.jsx(du.Provider,{value:V,children:x.jsx($.Stack,{sx:{gap:0,mx:`-${wi}px`},children:x.jsxs($.Stack,{sx:{gap:2,px:`${wi}px`,pb:`${wi}px`},children:[b.pendingOpen&&x.jsx($.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."}),x.jsx(mv,{editor:b,notebook:K,documentSlug:Y,chrome:X,actions:re,descriptionSelected:E,selectDescription:D}),ne?x.jsx(x.Fragment,{children:x.jsxs($.Stack,{sx:{alignItems:"flex-start",gap:1,py:3,px:2,border:1,borderStyle:"dashed",borderColor:"divider",borderRadius:1},children:[x.jsxs($.Typography,{variant:"body2",children:["This ",K?"notebook":"dashboard"," is not served until it has a tile."]}),u&&x.jsx($.Button,{size:"small",startIcon:x.jsx(C.AddIcon,{}),onClick:()=>q(),children:"Add tile"})]})}):x.jsx(Sv,{controls:J.controlList,tileCount:b.document.tiles.length,unknownFieldsOf:J.unknownFieldsOf,onEdit:ce=>H({control:ce}),onAdd:()=>H({}),...m?{addDisabledReason:m}:{},onRemove:J.dropControl,children:a}),b.error&&x.jsx($.Alert,{severity:"warning",children:b.error}),x.jsx(hv,{editor:b,reorder:se,resizing:A,gridBox:_,columns:G,notebook:K,chrome:X,canAdd:!!u,selected:O,flash:R,menuIndex:N?.index,onSelect:I,onOpenMenu:(ce,pe)=>{I(pe),B.setMenu({anchor:ce,index:pe})},openAdd:q,editTile:B.editTile,...o?{renderTile:o}:{}}),x.jsx(Ef,{editor:b,catalog:u,columns:G,dashboards:d,bindings:J,tiles:B,drillSource:S,setDrillSource:P,confirmConversion:Z,exitDialog:Q.exitGuard.dialog})]})})})}function eb(e,t){const n=new Set;for(const i of e.tiles)for(const o of xe(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 ts(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(v=>[v.name,v.type])),l=e.sources.find(v=>v.name===i)?.scopedBy??[],u=new Set([...l,...s??[]].filter(v=>n.has(v))),c=new Set([...l,...s??[]]),d=[];for(const v of t.filters??[]){const y=`where: ${me.malloyPath(v.field)} ${v.op??"~"}`;if(n.has(v.given)){u.add(v.given),c.add(v.given),d.push(`${y} $${v.given}`);continue}if(!a.has(v.given))continue;c.add(v.given);const w=C.malloyLiteral(r.get(v.given),a.get(v.given));w!==void 0&&d.push(`${y} ${w}`)}const f=d.join(", "),p=t.chart,h=p==="none"||Qs(p)?yn(p,t.chartCarried):p==="custom"&&t.chartLines?.length?t.chartLines.join(`
|
|
143
|
+
`):p==="default"&&nb(t.declaration)?yn("none"):void 0;return{...h?{annotation:h}:{},expression:`${i} -> ${o}`+(f?` + { ${f} }`:""),givenNames:Array.from(u),reads:s||c.size>0?Array.from(c):void 0}}const sb={};function ib({textSource:e,kind:t,modelGivens:n,environmentName:r,packageName:s,modelPath:i,slug:o,versionId:a,opened:l,replaces:u,onSave:c,onDirtyChange:d,onExit:f,onEvent:p,savesTo:h,saveLabel:v,note:y}){const{apiClients:w}=Ke.useServer(),g=t==="notebook",[m,b]=k.useState(l.document.tiles.length>0);k.useEffect(()=>b(l.document.tiles.length>0),[l.generation,l.document]);const{data:_,isSuccess:O,isError:E}=C.useQueryWithApiError({queryKey:["dashboard-editor-manifest",r,s,o,a,t],queryFn:async()=>{if(!g)return(await w.dashboards.getDashboard(r,s,o,a)).data;const W=(await w.notebooks.getNotebook(r,s,i,a)).data;return W.dashboard??{...W.startingGivens?{startingGivens:W.startingGivens}:{},...W.autorun===void 0?{}:{autorun:W.autorun}}},enabled:m&&!e}),I=e?.modelPath??i,T=C.useCompiledDocument({environmentName:r,packageName:s,modelPath:I,source:l.source,...e?.givens?{givens:e.givens}:{}},{enabled:e!==void 0}),D=T.data?.document,L=e?T.isSuccess?D?.manifest??sb:void 0:_,R=e?T.isSuccess:O,z=e?T.isError:E,K=e?C.documentPreamble(D?.cells):void 0,G=(T.data?.result.problems??[]).filter(W=>W.severity==="error"),X=k.useMemo(()=>new Set(e?.hiddenGivens??[]),[e]),Y=e?.givens,se=k.useMemo(()=>new Set((L?.tiles??[]).flatMap(W=>W.restricted&&W.query?[ts(W.query)]:[])),[L]),{data:te}=C.useQueryWithApiError({queryKey:["dashboards",r,s,a],staleTime:6e4,queryFn:()=>w.dashboards.listDashboards(r,s,a),enabled:!g}),A=k.useMemo(()=>(te?.data??[]).map(W=>W.name).filter(W=>!!W&&W!==o),[te,o]),{data:B}=C.useQueryWithApiError({queryKey:["dashboard-editor-catalog",r,s,a],queryFn:async()=>{const W=(await w.models.listModels(r,s,a)).data.filter(re=>re.path&&!re.error&&!Uu(re.path)&&!re.path.startsWith("notebooks/")),ne=(await Promise.allSettled(W.map(re=>w.models.getModel(r,s,re.path,a).then(ce=>ce.data)))).flatMap(re=>re.status==="fulfilled"?[re.value]:[]);return Vu(ne)}}),[N,j]=k.useState(l.document);k.useEffect(()=>j(l.document),[l.document]);const q=k.useMemo(()=>c&&h==="package"?async(W,Q)=>{await c(W),b(Q.document.tiles.length>0)}:c,[c,h]),J=k.useMemo(()=>(L?.givens??(l.conversion?n??[]:[])).filter(W=>!(e&&W.secure===!0)&&!(W.name!==void 0&&X.has(W.name))),[L,l.conversion,n,X,e]),ee=k.useMemo(()=>new Set([...J.map(W=>W.name).filter(W=>W!==void 0),...Object.keys(Y??{})]),[J,Y]),H=k.useMemo(()=>eb(N,J),[N,J]),{declaredTypes:S,applied:P,panel:F}=C.useDocumentControls({specs:H,loaded:R,startingValues:L?.startingGivens,documentKey:`${r}/${s}/${a??""}/${g?"notebook/":""}${o}/edit`,autorun:L?.autorun!==!1,environmentName:r,packageName:s,modelPath:e?I:L?.path,versionId:a,documentName:o,...K!==void 0?{preamble:K}:{},...Y?{hostGivens:Y}:{}}),V=k.useMemo(()=>Object.fromEntries(Object.entries(Y??{}).filter(([W])=>!S.has(W))),[Y,S]),ie=!m||R||z,Z=k.useMemo(()=>new Map((L?.tiles??[]).flatMap(W=>W.kind!=="text"&&W.query&&W.givenNames?[[ts(W.query),W.givenNames]]:[])),[L]),oe=k.useMemo(()=>function(Q,ne,re="card"){if(!ie)return x.jsxs(C.TileCard,{chrome:re,children:[x.jsx(C.TileHeading,{title:ne?.title??Fs(Q),subtitle:ne?ne.subtitle:Q.subtitle}),x.jsx(C.Loading,{text:"Running…"})]});const ce=rb(N,Q,ee,P,Z.get(ts(`${Q.source} -> ${Q.name}`)));return x.jsx(C.DashboardTile,{environmentName:r,packageName:s,versionId:a,modelPath:I,...K!==void 0?{preamble:K}:{},...se.has(ts(`${Q.source} -> ${Q.name}`))?{restricted:!0}:{},tile:ce.expression,...ce.annotation?{annotation:ce.annotation}:{},label:Fs(Q),chrome:re,subtitle:Q.subtitle,...ne?{heading:ne}:{},borderless:Q.borderless,givens:P,hostGivens:V,declaredTypes:S,givenNames:ce.givenNames,ignoredFilters:C.tileIgnoredFilterLabels(ce.reads,H),height:C.TILE_MAX_HEIGHT})},[N,ie,ee,Z,r,s,a,I,K,se,P,V,S,H]);return x.jsxs($.Stack,{sx:{gap:1},children:[e&&G.length>0&&x.jsxs($.Alert,{severity:"error",children:["The server could not compile this document:"," ",G.map(W=>W.message).join("; ")]}),e&&T.isError&&x.jsxs($.Alert,{severity:"error",children:["The server could not compile this document:"," ",T.error?.message]}),x.jsx(Zu,{...e?{addFilterDisabledReason:"This document holds no given: of its own. Bind a filter the model offers from its chip."}:{},source:l.source,document:l.document,renderTile:oe,givens:H.filter(W=>W.name!==void 0).map(W=>({name:W.name,...W.label?{label:W.label}:{},...W.type?{type:W.type}:{},...W.suggest?.dimension?{field:W.suggest.dimension}:{}})),onChange:j,onDirtyChange:d,...f?{onExit:f}:{},...l.conversion?{conversion:l.conversion}:{},...B?{catalog:B}:{},dashboards:A,...p?{onEvent:p}:{},controls:R?x.jsx(C.GivensPanel,{...F,layout:g?"panel":"bar"}):void 0,...q?{onSave:q}:{},savesTo:h,...v?{saveLabel:v}:{},...u!==void 0?{replaces:u}:{},modelPath:i,...e?{explicitKind:!0}:{}}),x.jsx($.Box,{sx:{px:.5},children:x.jsx($.Typography,{variant:"caption",sx:{opacity:.7},children:y})})]})}function ob({storage:e,kind:t,notebook:n,environmentName:r,packageName:s,modelPath:i}){const[o,a]=k.useState(void 0),[l,u]=k.useState(void 0),[c,d]=k.useState(e===void 0),[f,p]=k.useState(!1),[h,v]=k.useState(void 0);return k.useEffect(()=>{if(!e)return;let y=!1;return v(void 0),(async()=>{try{const w=C.chooseWorkspace(await e.listWorkspaces(!1));if(y)return;if(a(w),w!==void 0&&(!n||w.authoritative)){const g=await e.getDocument(C.locatorFor(t,w.name,r,s,i)).catch(m=>{if(!C.isDocumentNotFound(m))throw m});if(y)return;u(g),p(g!==void 0)}}catch(w){if(y)return;v(C.storageErrorMessage(w))}y||d(!0)})(),()=>{y=!0}},[e,t,n,r,s,i]),{workspace:o,draft:l,setDraft:u,draftChecked:c,offered:f,setOffered:p,readFailure:h}}const ab=e=>e.ok===!1,qn=(e,t)=>{const n=e[t];return typeof n=="function"?n.call(e):void 0},lb=[["runStatement","run"],["docAnnotations","notes"],["importStatement","definition"],["defineSourceStatement","definition"],["defineQuery","definition"],["defineGivenStatement","definition"],["defineUserTypeStatement","definition"],["exportStatement","definition"]],cb=/^[A-Za-z_][A-Za-z0-9_]*$/,db="file:///publisher-notebook-builder/notebook.malloy",ns=e=>e.replace(/\r\n?/g,`
|
|
144
|
+
`);async function ub(e){const t=(A,B)=>({ok:!1,refused:`Line ${A+1}: ${B}`,line:A+1}),n=/\r(?!\n)/.exec(e);if(n)return t(e.slice(0,n.index).split(`
|
|
145
|
+
`).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 Js(e,db),s=await C.loadMalloy()}catch(A){return t(0,`Malloy could not read this notebook: ${A}`)}const i=r.problems.find(A=>A.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=A=>l.getSymbolicName(A.type),d=A=>s.routeOf({value:A.trimStart()}),f=A=>s.payloadOf({value:A}),p=A=>A==="markdown"||A==='"'||A==="text",h=A=>ns(f(A)).replace(/\n$/,""),v=(A,B)=>{const N=f(A).trim(),j=d(A)!=='"'&&cb.test(N)?"":N;return ns([j&&`${j}
|
|
146
|
+
`,...B].join("")).replace(/\n$/,"")},y=new ya(e),w=wa(y,a),g=A=>e.slice(y.utf16(A.startIndex),y.utf16(A.stopIndex+1)),m=A=>{const B=A.start?.startIndex,N=A.stop?.stopIndex,j=y.span(A);if(B===void 0||N===void 0||!j)return;let q=j.end;for(;q>j.start&&(e[q-1]===`
|
|
147
|
+
`||e[q-1]==="\r");)q--;return{startCp:B,stopCp:N,...j,startLine:y.line(j.start),endLine:y.line(Math.max(j.start,q-1))}},b=A=>{let B=0,N=u.length;for(;B<N;){const j=B+N>>1;u[j].startIndex<A?B=j+1:N=j}return B},_=(A,B)=>{const N=[],j=[],q={lines:[],insertAt:y.utf16(A)};let J=-2;for(let ee=b(A);ee<u.length;ee++){const H=u[ee];if(H.startIndex>B)break;if(H.channel!==0)continue;const S=c(H);if(S!=="ANNOTATION"&&S!=="BLOCK_ANNOTATION_BEGIN"){q.insertAt=y.lineStarts[y.line(y.utf16(H.startIndex))];break}const P=ns(g(H)),F=[];if(S==="BLOCK_ANNOTATION_BEGIN"){for(;c(u[ee+1]??H)==="BLOCK_ANNOTATION_TEXT";)F.push(g(u[++ee]));c(u[ee+1]??H)==="BLOCK_ANNOTATION_END"&&ee++}if(p(d(P))){const V=y.utf16(H.startIndex),ie=y.lineStarts[y.line(V)],Z=/^[ \t]*$/.test(e.slice(ie,V));j.push({start:Z?ie:V,end:y.utf16(u[ee].stopIndex+1)})}if(S==="ANNOTATION"){const V=P.replace(/\n$/,"");if(At(V)){const ie=y.utf16(H.startIndex),Z=y.lineStarts[y.line(ie)];q.lines.push({span:{start:/^[ \t]*$/.test(e.slice(Z,ie))?Z:ie,end:y.utf16(H.stopIndex+1)},text:V})}else kr(V)&&q.unmodelled===void 0&&(q.unmodelled=V.trim())}if(d(P)!=="markdown")J=-2;else if(S==="BLOCK_ANNOTATION_BEGIN")N.push(v(P,F)),J=-2;else{const V=h(P);H.line===J+1?N[N.length-1]+=`
|
|
148
|
+
${V}`:N.push(V),J=H.line}}return{markdown:N.length>0?N.join(`
|
|
152
149
|
|
|
153
|
-
`):void 0,prose:
|
|
154
|
-
`)[0];return
|
|
155
|
-
`,1)[0],
|
|
156
|
-
${
|
|
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
|
|
150
|
+
`):void 0,prose:j,chart:q}},O=[],E=[],I=(A,B,N="remove it, or rewrite it as an import, source:, query:, given:, type: or export statement, a run:, or a `##(markdown)` / `##|(markdown)` prose note.")=>t(A,`${B}, which no notebook cell can hold, so the notebook cannot be edited here. Fix: ${N}`);for(let A=0;A<(o.childCount??0);A++){const B=o.getChild(A);if(!Lr(B)){const H=B?.symbol,S=H?c(H):void 0;if(H&&S==="EOF")continue;if(H&&S==="SEMI"){O.push([H.startIndex,H.stopIndex]);continue}return I((H?.line??1)-1,"a token outside any statement")}const N=m(B);if(!N)return I(0,"a statement with no readable range");const j=lb.find(([H])=>qn(B,H)!==void 0);if(!j&&qn(B,"ignoredObjectAnnotations"))return I(N.startLine,"a # tag that annotates no statement","move the tag directly above its run:, or write trailing prose as a `##(markdown)` note.");if(!j){const H=e.slice(N.start,N.end).split(`
|
|
151
|
+
`)[0];return I(N.startLine,`\`${H.trim()}\` is a statement the notebook reader does not recognize`)}O.push([N.startCp,N.stopCp]);const[q,J]=j;if(J!=="notes"){const{markdown:H,prose:S,chart:P}=_(N.startCp,N.stopCp);E.push({kind:"statement",run:J==="run",...H!==void 0&&{markdown:H},prose:S,chart:P,startLine:N.startLine,endLine:N.endLine});continue}const ee=qn(B,q);for(const H of qn(ee,"docAnnotation")??[]){const S=m(H);if(!S)return I(N.startLine,"a note with no readable range");const P=qn(H,"docBlockAnnotation")!==void 0,F=u.filter(Q=>Q.startIndex>=S.startCp&&Q.stopIndex<=S.stopCp),V=F.filter(Q=>c(Q)==="BLOCK_ANNOTATION_TEXT"),ie=V[V.length-1]??F[0],Z=ns(P&&ie?e.slice(S.start,y.utf16(ie.stopIndex+1)).replace(/\r?\n$/,""):e.slice(S.start,S.end)),oe=d(Z),W=p(oe)?P?v(Z.split(`
|
|
152
|
+
`,1)[0],V.map(g)):h(Z):void 0;E.push({kind:"note",note:{text:Z,route:oe,...W!==void 0&&{body:W},block:P,startLine:S.startLine,endLine:S.endLine}})}}for(const A of u){if(c(A)!=="BLOCK_ANNOTATION_END")continue;const B=g(A).trimStart().replace(/^\|#{1,2}/,"").trim();if(B)return t(A.line-1,`the text after a block's closer (\`${B}\`) 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 T=0;for(const A of u){if(A.channel!==0||c(A)==="EOF")continue;for(;T<O.length&&O[T][1]<A.startIndex;)T++;const[B,N]=O[T]??[1/0,-1/0];if(A.startIndex<B||A.stopIndex>N)return I(A.line-1,"a token outside any statement")}const D=E.findIndex(A=>A.kind==="note"&&me.setsArtifactProperty(A.note.text));if(D<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 L=E.findIndex((A,B)=>B<D&&A.kind==="statement");if(L>=0)return t(E[L].startLine,'a statement sits above the `## artifact` tag, where only `##!` flags, comments and `"` notes may. Fix: move it below the artifact tag.');for(let A=1;A<E.length;A++){const B=E[A-1],N=E[A],j=B.kind==="note"?B.note.endLine:B.endLine,q=N.kind==="note"?N.note.startLine:N.startLine;if(q<=j)return I(q,"a line holding two statements or notes","put each statement and note on its own line.")}const R=A=>y.lineStarts[A+1]??e.length,z=[];let K=-1,G=!0,X;E.forEach((A,B)=>{if(A.kind==="statement"){G=!1,X=void 0,z.push({cell:{kind:A.run?"query":"definition",...A.markdown!==void 0&&{markdown:A.markdown},...A.prose.length>0&&{prose:A.prose},...A.run&&{chart:A.chart},id:""},startLine:A.startLine,endLine:A.endLine});return}const{note:N}=A;if(!(B>D&&N.body!==void 0)){G&&(K=N.endLine),X=void 0;return}if(G=!1,!N.block&&X&&X.endLine+1===N.startLine){X.cell.markdown+=`
|
|
153
|
+
${N.body}`,X.endLine=N.endLine;return}const q={cell:{kind:"markdown",markdown:N.body,id:""},startLine:N.startLine,endLine:N.endLine};z.push(q),X=N.block?void 0:q});const Y={start:0,end:R(K)};let se=K;const te=z.map(({cell:A,startLine:B,endLine:N},j)=>{let q=B;for(;q-1>se&&w.lines.has(q-1);)q--;return se=N,{...A,span:{start:y.lineStarts[q],end:R(N)},id:String(j)}});for(const A of[Y,...te.map(B=>B.span)]){const B=w.all.find(N=>N.start<A.start&&N.end>A.start||N.start<A.end&&N.end>A.end);if(B)return I(y.line(B.start),"a comment that straddles a cell","start the comment on its own line.")}return{ok:!0,source:{text:e,header:Y,cells:te}}}const fb=e=>e.ok===!1,hb=/^[A-Za-z_][A-Za-z0-9_]*$/,jl=/^query\s*:\s*([A-Za-z_][A-Za-z0-9_]*)\s+is\s+/,Rl=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;function Ti(e){let t="",n=0;for(;n<e.length;){const r=e.slice(n,n+2);if(r==="//"||r==="--"){const s=e.indexOf(`
|
|
154
|
+
`,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 Ll(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 Nl(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 Fl(e,t){const n=t.split(`
|
|
158
155
|
`).map(r=>r.startsWith("|##")?` ${r}`:r).join(`
|
|
159
156
|
`);return`##|(markdown) ${e}
|
|
160
157
|
${n===""?"":`${n}
|
|
161
158
|
`}|##
|
|
162
|
-
`}function
|
|
163
|
-
`),o=
|
|
164
|
-
`),
|
|
165
|
-
`,1)[0])),...
|
|
166
|
-
`:" ";
|
|
167
|
-
`).join("");
|
|
168
|
-
`}if(
|
|
169
|
-
`).filter(
|
|
170
|
-
`)].filter(
|
|
171
|
-
`).map((
|
|
172
|
-
`);
|
|
173
|
-
`)),
|
|
159
|
+
`}function pb(e){return e.trim()===""?"":/^\s*(#|\/\/|--|\/\*)/.test(e)?` ${e.trimStart()}`:` ${e}`}function gb(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)&&me.isBareName(r)?r:void 0}async function mb(e){const t=await ub(e);if(ab(t))return{ok:!1,refused:t.refused,line:t.line};const{header:n,cells:r}=t.source,s=(S,P)=>({ok:!1,refused:`Line ${S+1}: ${P}`,line:S+1}),i=e.slice(n.start,n.end).split(`
|
|
160
|
+
`),o=me.artifactTag(i);if(o&&!me.artifactLeads(o.text))return s(o.from,me.ARTIFACT_NOT_FIRST);if(!o||_a(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 Js(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 C.loadMalloy(),{parseAnnotation:f}=await C.loadMalloyTag(),p=S=>u.getSymbolicName(S.type),h=new ya(e),v=wa(h,l),y=S=>e.slice(h.utf16(S.startIndex),h.utf16(S.stopIndex+1)),w=S=>d.routeOf({value:S.trimStart()}),g=S=>d.payloadOf({value:S}),m=S=>S.replace(/\r\n?/g,`
|
|
161
|
+
`),b=new Set(e.match(/[A-Za-z_][A-Za-z0-9_]*/g)),_=S=>{let P=S;for(let F=2;b.has(P);F++)P=`${S}_${F}`;return b.add(P),P},O=S=>{const P=c.filter(Q=>Q.channel===0&&h.utf16(Q.startIndex)>=S.span.start&&h.utf16(Q.stopIndex+1)<=S.span.end),F=[],V=[],ie=[];let Z;for(let Q=0;Q<P.length;Q++){const ne=p(P[Q]);if(ne!=="ANNOTATION"&&ne!=="BLOCK_ANNOTATION_BEGIN"){Z=P[Q];break}let re=Q;const ce=[];if(ne==="BLOCK_ANNOTATION_BEGIN"){for(;p(P[re+1]??P[Q])==="BLOCK_ANNOTATION_TEXT";)ce.push(y(P[++re]));p(P[re+1]??P[Q])==="BLOCK_ANNOTATION_END"&&re++}const pe=m(y(P[Q])),M=w(pe),U=h.utf16(P[Q].startIndex),de=h.lineStarts[h.line(U)],ve={start:/^[ \t]*$/.test(e.slice(de,U))?de:U,end:h.utf16(P[re].stopIndex+1)};M==="markdown"?F.push(ve):M==='"'&&(V.push(ve),ie.push(ne==="ANNOTATION"?m(g(pe)).replace(/\n$/,"").trim():[m(g(pe.split(`
|
|
162
|
+
`,1)[0])),...ce.map(m)].map(Re=>Re.trim()).filter(Boolean).join(" "))),Q=re}if(!Z)return;const oe=h.utf16(Z.startIndex),W=e.slice(S.span.start,S.span.end);return{cell:S,above:Nl(e.slice(S.span.start,oe),S.span.start,(S.kind==="query"?[...F,...V]:F).filter(Q=>Q.end<=oe)),statement:e.slice(oe,S.span.end).trimEnd(),kept:Nl(W,S.span.start,F),...S.kind==="query"&&ie.length>0&&{caption:ie.join(" ")},line:h.line(oe)}},E=new Map,I=new Map;for(const[S,P]of r.entries()){if(P.kind==="markdown")continue;const F=O(P);if(!F)return s(h.line(P.span.start),"a cell with no statement the converter can place.");I.set(S,F);const V=jl.exec(F.statement);P.kind==="definition"&&V&&E.set(V[1],{expression:F.statement.slice(V[0].length).trim(),cell:S})}const T=S=>{const P=/^run\s*:\s*/.exec(S.statement);if(!P)return s(S.line,"a run that is not `run: <query>`.");let F=S.statement.slice(P[0].length).trim();const V=[];for(let Q=0;Q<10;Q++){const ne=Ti(F),re=/^[A-Za-z_][A-Za-z0-9_]*/.exec(ne)?.[0],ce=re?E.get(re):void 0;if(!re||!ce)break;const pe=F.slice(re.length).trim(),M=ne.slice(re.length).trim();if(M!==""&&!M.startsWith("->")&&!M.startsWith("+"))break;if(M.startsWith("+")&&Ll(Ti(ce.expression)).length!==1)return s(S.line,`\`${re} + { … }\` refines a query with more than one stage, which cannot become one view.`);V.push(re);const U=/(\/\/|--)[^\n]*$/.test(ce.expression)?`
|
|
163
|
+
`:" ";F=`${ce.expression}${pe===""?"":`${U}${pe}`}`}const ie=Ti(F);if(E.has(/^[A-Za-z_][A-Za-z0-9_]*/.exec(ie)?.[0]??""))return s(S.line,"this run names a query defined through more than 10 other queries, which the converter does not follow.");const Z=Ll(ie);if(Z.length===0)return s(S.line,"this run is not `source -> view`, so it cannot become a tile. Fix: write it as `run: <source> -> <view>`.");const oe=F.slice(0,Z[0]).trim();if(/\bextend\b/.test(ie.slice(0,Z[0])))return s(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(!hb.test(oe)&&!/^`[^`]+`$/.test(oe))return s(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 W=F.slice(Z[0]+2).trim();return W===""?s(S.line,"this run has nothing after `->`."):{source:oe,body:W,used:V}},D=new Map,L=[],R=new Set,z=new Map;let K=0,G=0;const X=new Map;for(const S of I.values()){if(S.cell.kind!=="query")continue;const P=T(S);if("ok"in P)return P;for(const F of P.used)X.set(F,(X.get(F)??0)+1)}const Y=S=>X.get(S)===1&&(e.match(new RegExp(`\\b${S}\\b`,"g"))??[]).length===2,se=new Map;for(const[S,P]of r.entries()){if(P.kind==="markdown"){const M=_(`text_${++K}`);L.push(`${M} { kind=text }`);const U=v.all.filter(de=>de.start>=P.span.start&&de.end<=P.span.end).map(de=>`${e.slice(de.start,de.end)}
|
|
164
|
+
`).join("");z.set(S,U+Fl(M,P.markdown??""));continue}const F=I.get(S);let V="";if(P.markdown!==void 0){const M=_(`text_${++K}`);L.push(`${M} { kind=text }`),V=`${Fl(M,P.markdown)}
|
|
165
|
+
`}if(P.kind==="definition"){const M=jl.exec(F.statement)?.[1];if(M&&Y(M)){R.add(S),se.set(M,F.above.split(`
|
|
166
|
+
`).filter(U=>U.trim()!=="")),V&&z.set(S,V.replace(/\n$/,""));continue}z.set(S,`${V}${F.kept}`);continue}const ie=T(F),Z=ie.source.replace(/`/g,"").replace(/[^A-Za-z0-9_]+/g,"_").replace(/^(?=[0-9])/,"_");let oe=D.get(ie.source);oe||(oe={name:_(`${Z}_tiles`),base:ie.source,views:[]},D.set(ie.source,oe));const W=[...ie.used.flatMap(M=>se.get(M)??[]),...F.above.split(`
|
|
167
|
+
`)].filter(M=>M.trim()!==""),Q=W.filter(M=>/^\s*#(?!["(|])/.test(M)),ne=Q.length>0?Au(f,Q).tag:void 0,re=_(gb(ne?.text("label")??F.caption)??`tile_${G+1}`);G++,L.push(`"${oe.name} -> ${re}"`);const ce=W.map(pb);if(F.caption!==void 0){const M=C.annotationTextProblem("caption",F.caption)===void 0;M&&!ne?.has("label")?ce.push(` # label=${Rl(F.caption)}`):M&&!ne?.has("subtitle")?ce.push(` # subtitle=${Rl(F.caption)}`):ce.push(` #" ${F.caption}`)}const pe=ie.body.split(`
|
|
168
|
+
`).map((M,U)=>U===0||M.trim()===""?M:` ${M}`).join(`
|
|
169
|
+
`);oe.views.push([...ce,` view: ${re} is ${pe}`].join(`
|
|
170
|
+
`)),R.add(S),V&&z.set(S,V.replace(/\n$/,""))}const te=(()=>{let S=0;const P=o.text;for(let F=P.indexOf("{");F<P.length;F++)if(P[F]==='"')for(F++;F<P.length&&P[F]!=='"';F++)P[F]==="\\"&&F++;else if(P[F]==="{")S++;else if(P[F]==="}"&&--S===0)return F;return-1})();if(te<0)return s(o.from,"the `## artifact { … }` tag never closes.");const A=L.length===0?`
|
|
174
171
|
tiles=[]
|
|
175
172
|
`:`
|
|
176
173
|
tiles=[
|
|
177
|
-
${
|
|
174
|
+
${L.map(S=>` ${S}`).join(`,
|
|
178
175
|
`)}
|
|
179
176
|
]
|
|
180
|
-
`,
|
|
177
|
+
`,B=`${o.text.slice(0,te).trimEnd().replace(/^##(?!\|)/,"##|")}${A}${o.text.slice(te)}`;i.splice(o.from,o.block?o.to-o.from:1,...(o.block?B:`${B}
|
|
181
178
|
|##`).split(`
|
|
182
|
-
`));const
|
|
183
|
-
`),
|
|
184
|
-
`).join("")+
|
|
185
|
-
`),
|
|
186
|
-
`)?
|
|
187
|
-
`),
|
|
188
|
-
`+(
|
|
189
|
-
`;const
|
|
190
|
-
${
|
|
179
|
+
`));const N=S=>{const P=S.text.split(`
|
|
180
|
+
`),F=P.pop(),V=[];let ie=0;for(const Z of P){const oe=S.at[ie]??-1,W=v.all.some(Q=>oe>=Q.start&&oe<Q.end);(Z.trim()!==""||V.at(-1)?.trim()!==""||W)&&V.push(Z),ie+=Z.length+1}return V.map(Z=>`${Z}
|
|
181
|
+
`).join("")+F},j={text:"",at:[]},q=(S,P)=>{j.text+=e.slice(S,P);for(let F=S;F<P;F++)j.at.push(F)};let J=i.join(`
|
|
182
|
+
`),ee=n.end;for(const[S,P]of r.entries()){q(ee,P.span.start),ee=P.span.end;const F=z.get(S);F!==void 0&&(J+=N(j)+(F.endsWith(`
|
|
183
|
+
`)?F:`${F}
|
|
184
|
+
`),j.text="",j.at=[])}q(ee,e.length),J=`${J.trimEnd()}
|
|
185
|
+
`+(j.text.trim()===""?"":N(j)),J=`${J.trimEnd()}
|
|
186
|
+
`;const H=[...D.values()].map(S=>`source: ${S.name} is ${S.base} extend {
|
|
187
|
+
${S.views.join(`
|
|
191
188
|
|
|
192
189
|
`)}
|
|
193
190
|
}
|
|
194
|
-
`);return
|
|
195
|
-
${
|
|
191
|
+
`);return H.length>0&&(J+=`
|
|
192
|
+
${H.join(`
|
|
196
193
|
`)}`),e.includes(`\r
|
|
197
|
-
`)&&(
|
|
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;
|
|
194
|
+
`)&&(J=J.replace(/\r?\n/g,`\r
|
|
195
|
+
`)),{ok:!0,text:J,tiles:L.length}}const Oi=(e,t)=>t!==void 0&&!/\bline \d+/i.test(e)?`${e} (line ${t})`:e;async function vb(e,t,n=!1){const r=await Tr(e,t,n);if(!$r(r))return{ok:!0,document:r.document};if(!r.legacyNotebook)return{ok:!1,reason:Oi(r.reason,r.line)};const s=await mb(e);if(fb(s))return{ok:!1,reason:Oi(s.refused,s.line)};const i=await Tr(s.text,t,n);return $r(i)?{ok:!1,reason:`The converted notebook cannot be opened: ${Oi(i.reason,i.line)}`}:{ok:!0,document:i.document,conversion:{from:e,to:s.text}}}const zl="a .malloynb notebook is read, not edited. Fix: rewrite it as a `.malloy` notebook under notebooks/ to edit it here.",Wl="the server did not send this notebook's text, so there is nothing here to edit. Fix: edit the file in the package.";function bb({workspace:e,draft:t,draftChecked:n,readFailure:r,packageText:s,fetchedAt:i,packageSettled:o,modelPath:a,notebook:l,noun:u,refusedEvent:c,legacyFormat:d,textHeld:f,startedAt:p,onEventRef:h}){const v=e?.authoritative===!0,y=v&&r!==void 0,[w,g]=k.useState(void 0),m=(v||w===!0)&&t!==void 0,[b,_]=k.useState(void 0),[O,E]=k.useState(d?zl:void 0),I=k.useRef(void 0),T=k.useRef(void 0),[D,L]=k.useState(void 0),R=k.useRef(i);R.current=i;const z=D!==void 0&&D.onFetch===i?D.text:s,K=k.useRef(z);K.current=z;const G=m?t:z,[X,Y]=k.useState(!1),[se,te]=k.useState(void 0),[A,B]=k.useState(void 0),N=G!==void 0&&G!==A,j=b?.source,J=N&&(X||!v&&t!==void 0&&j===t&&t!==z)&&j!==void 0&&G!==se,ee=J?j:N?G:j??G,H=J?G:void 0,S=k.useRef(j);S.current=j;const P=k.useRef(G);P.current=G;const F=k.useRef("package");F.current=m?v?"record":"draft":"package",k.useEffect(()=>{if(ee===void 0||!n||y||ee===S.current)return;let oe=!1;const W=K.current,Q=P.current;return vb(ee,a,f).then(ne=>{if(!oe){if(ne.ok===!1){E(ne.reason),h.current?.({type:c,reason:ne.reason});return}E(void 0),I.current=void 0,T.current=W,L(void 0),te(void 0),B(Q),_(re=>({source:ee,document:ne.document,...ne.conversion?{conversion:ne.conversion}:{},...W!==void 0?{packageText:W}:{},generation:(re?.generation??0)+1})),h.current?.(l||ne.document.kind==="notebook"?{type:"notebook.opened",from:F.current==="package"?"package":"record",cells:ne.document.tiles.length,durationMs:C.now()-p.current}:{type:"dashboard.opened",from:F.current,tiles:ne.document.tiles.length,durationMs:C.now()-p.current})}}).catch(ne=>{if(oe)return;const re=`Could not read the ${u}: ${ne instanceof Error?ne.message:String(ne)}`;E(re),h.current?.({type:c,reason:re})}),()=>{oe=!0}},[ee,a,n,y,l,u,c,f,p,h]),k.useEffect(()=>{d&&h.current?.({type:"notebook.open_refused",reason:zl})},[d,h]),k.useEffect(()=>{!f||!n||b||r!==void 0||(v?t===void 0&&E("the host's storage has no document at this location."):E("a document held as text needs a storage whose workspace is authoritative. Fix: mark the workspace that keeps it `authoritative`."))},[f,n,b,r,v,t]);const V=l&&!f&&!b&&n&&!m&&o&&s===void 0;return k.useEffect(()=>{V&&(E(Wl),h.current?.({type:"notebook.open_refused",reason:Wl}))},[V,h]),{authoritative:v,blockedOnRecord:y,resume:w,setResume:g,fromDraft:m,opened:b,setOpened:_,openError:O,savedHashRef:I,packageBaseRef:T,setWrote:L,fetchedAtRef:R,setDirty:Y,setSeen:B,held:H,choose:oe=>{p.current=C.now(),te(oe?t:z),g(oe)},acceptHeld:()=>{p.current=C.now(),te(H)}}}function yb({storage:e,workspace:t,kind:n,notebook:r,environmentName:s,packageName:i,modelPath:o,versionId:a,apiClients:l,queryClient:u,mutable:c,textHeld:d,readFailure:f,authoritative:p,resume:h,setResume:v,setOpened:y,setDraft:w,setOffered:g,setSeen:m,setWrote:b,savedHashRef:_,packageBaseRef:O,fetchedAtRef:E}){const I=t===void 0?void 0:C.locatorFor(n,t.name,s,i,o),T=k.useCallback(async te=>{if(!e||!I)throw new Error("This host keeps no documents, so there is nowhere to save.");await e.saveDocument(I,te),y(A=>A&&{...A,source:te}),w(te),(p||h===!0)&&m(te),p||v(A=>A??!1)},[e,I,p,h,y,w,m,v]),[D,L]=k.useState(void 0),R=k.useCallback(async te=>{const A=await C.expectedHashFor(_.current,O.current);if(A===void 0)throw new Error("The package file is still loading; try again.");const B=["dashboard-editor-model",s,i,o,a,r];await C.writePackageFile({apiClients:l,queryClient:u,environmentName:s,packageName:i,modelPath:o,source:te,expectedHash:A,invalidateOnError:[B],afterWrite:async N=>{if(y(j=>j&&{...j,source:te}),b({text:te,onFetch:E.current}),m(te),_.current=N,L(void 0),e&&I)try{await e.deleteDocument(I),w(void 0),g(!1)}catch(j){C.isDocumentNotFound(j)?(w(void 0),g(!1)):L(C.storageErrorMessage(j))}v(!1)},invalidate:[{queryKey:B,wait:!0},{queryKey:C.modelResultsKey({environmentName:s,packageName:i,versionId:a,modelPath:o})},{queryKey:["dashboard-editor-manifest"]},{queryKey:["dashboards"]},{queryKey:["dashboard"]},...r?[{queryKey:[C.encodeResourceUri({environmentName:s,packageName:i,modelPath:o})]}]:[]]})},[l,s,i,o,a,r,e,I,u,_,O,E,y,b,m,w,g,v]),z=t?.writeable===!0,K=c===!0&&!d,{savesTo:G,pinnedPackageSave:X,writer:Y}=C.saveTarget({authoritative:p,mutable:K,...a!==void 0?{versionId:a}:{},canStore:!!e&&!!I&&z&&(!r||p),readFailed:f!==void 0});return{save:Y==="storage"?T:Y==="package"?R:void 0,savesTo:G,writer:Y,pinnedPackageSave:X,takesWrites:K,supersedeFailure:D}}function Qu(e){const{onEvent:t,onDirtyChange:n,onExit:r,kind:s="dashboard",path:i,textSource:o}=e,a=s==="notebook",l=o!==void 0,{environmentName:u,packageName:c,versionId:d,namesBoth:f}=C.resolveEditorTarget(e),p="resourceUri"in e?e.dashboard:e.dashboardName,h=a?"notebook":"dashboard",v=a?"notebook.open_refused":"dashboard.open_refused",{apiClients:y,mutable:w,isLoadingStatus:g}=Ke.useServer(),m=af.useQueryClient(),b=k.useRef(C.now()),_=k.useRef(t);_.current=t;const O=k.useRef(n);O.current=n;const E=C.useOptionalDocumentStorage()?.documentStorage,I=a&&/\.malloynb$/i.test(p),T=i??`${s}s/${p}.malloy`,D=C.useQueryWithApiError({queryKey:["dashboard-editor-model",u,c,T,d,a],queryFn:()=>y.models.getModel(u,c,T,d,a?!0:void 0),enabled:f&&!I&&!l}),L=D.data?.data?.sourceText,{workspace:R,draft:z,setDraft:K,draftChecked:G,offered:X,setOffered:Y,readFailure:se}=ob({storage:E,kind:s,notebook:a,environmentName:u,packageName:c,modelPath:T}),{authoritative:te,blockedOnRecord:A,resume:B,setResume:N,fromDraft:j,opened:q,setOpened:J,openError:ee,savedHashRef:H,packageBaseRef:S,setWrote:P,fetchedAtRef:F,setDirty:V,setSeen:ie,held:Z,choose:oe,acceptHeld:W}=bb({workspace:R,draft:z,draftChecked:G,readFailure:se,packageText:L,fetchedAt:D.dataUpdatedAt,packageSettled:D.isSuccess&&!D.isFetching,modelPath:T,notebook:a,noun:h,refusedEvent:v,legacyFormat:I,textHeld:l,startedAt:b,onEventRef:_}),{save:Q,savesTo:ne,writer:re,pinnedPackageSave:ce,takesWrites:pe,supersedeFailure:M}=yb({storage:E,workspace:R,kind:s,notebook:a,environmentName:u,packageName:c,modelPath:T,versionId:d,apiClients:y,queryClient:m,mutable:w,textHeld:l,readFailure:se,authoritative:te,resume:B,setResume:N,setOpened:J,setDraft:K,setOffered:Y,setSeen:ie,setWrote:P,savedHashRef:H,packageBaseRef:S,fetchedAtRef:F}),U=R?.name,de=k.useCallback(vt=>{_.current?.(C.withWorkspace(vt,U))},[U]),ve=k.useCallback(vt=>{V(vt),O.current?.(vt)},[V]),Re=ne==="host"&&R?.description?R.description:void 0,Nn=!te&&!l&&w===void 0?g?"Checking whether this server takes writes.":"This server did not say whether it takes writes, so Save is off.":C.saveCaption({authoritative:te,mutable:pe,pinnedPackageSave:ce,...R?{workspace:R}:{},...se!==void 0?{readFailure:se}:{},...d!==void 0?{versionId:d}:{}}),mt=Nn===Re?"":Nn;if(!f&&"resourceUri"in e)return x.jsxs($.Alert,{severity:"error",sx:{m:2},children:["A ",h," resource URI must name an environment and a package. Received: ",e.resourceUri]});if(ee)return x.jsxs($.Alert,{severity:"error",sx:{m:2},children:["This ",h," cannot be opened in the builder: ",ee]});if(D.isError&&!q)return x.jsx(C.ApiErrorDisplay,{error:D.error,context:`Opening the ${h}`});if(!q&&(!(l||L)||!G))return x.jsx(C.Loading,{text:`Opening the ${h}…`});if(A)return x.jsxs($.Alert,{severity:"error",sx:{m:2},children:["This ",h," cannot be opened: ",se]});const Fn=z!==void 0&&z!==L;return x.jsxs($.Stack,{sx:{gap:2},children:[D.isError&&x.jsxs($.Alert,{severity:"warning",children:["The ",h," could not be re-read from the server:"," ",D.error?.message,". Your edits are still here."]}),!a&&!te&&X&&Fn&&B===void 0&&x.jsx($.Alert,{severity:"info",action:x.jsxs($.Stack,{direction:"row",sx:{gap:1},children:[x.jsx($.Button,{size:"small",onClick:()=>oe(!0),children:"Resume"}),x.jsx($.Button,{size:"small",onClick:()=>oe(!1),children:"Start from the package"})]}),children:"You have edits to this dashboard saved in this browser that the package does not have."}),Z!==void 0&&x.jsx($.Alert,{severity:"warning",action:x.jsx($.Button,{size:"small",onClick:W,children:"Load it"}),children:ne==="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.":ne==="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."}),M!==void 0&&x.jsxs($.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:"," ",M]}),q&&x.jsx(ib,{kind:s,environmentName:u,packageName:c,modelPath:T,...o?{textSource:o}:{},slug:p,modelGivens:D.data?.data?.givens,...d!==void 0?{versionId:d}:{},opened:q,...j&&re==="package"&&q.packageText!==void 0?{replaces:q.packageText}:{},onSave:Q,onDirtyChange:ve,...r?{onExit:r}:{},savesTo:ne,...Re?{saveLabel:Re}:{},...t?{onEvent:de}:{},note:mt},q.generation)]})}function xb(e){const{onEvent:t,onDirtyChange:n,onExit:r,path:s}=e,i="resourceUri"in e?{resourceUri:e.resourceUri,dashboard:e.notebook}:{environmentName:e.environmentName,packageName:e.packageName,dashboardName:e.notebookName};return x.jsx(Qu,{...i,kind:"notebook",...t?{onEvent:t}:{},...n?{onDirtyChange:n}:{},...r?{onExit: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=C.MAX_SLUG_ATTEMPTS;exports.createDocument=C.createDocument;exports.createRoute=C.createRoute;exports.documentPathFor=C.documentPathFor;exports.documentPathForTitle=C.documentPathForTitle;exports.locatorFor=C.locatorFor;exports.newDashboardSource=C.newDashboardSource;exports.newDocumentProblem=C.newDocumentProblem;exports.newNotebookSource=C.newNotebookSource;exports.slugFor=C.slugFor;exports.slugOrFallback=C.slugOrFallback;exports.useDocumentChoices=C.useDocumentChoices;exports.DashboardBuilder=Zu;exports.DashboardEditor=Qu;exports.NotebookEditor=xb;exports.buildCatalog=Vu;exports.readDashboardDocument=Tr;exports.readFailed=$r;exports.spliceDashboardDocument=Wu;exports.spliceFailed=Rs;
|