@malloy-publisher/sdk 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/README.md +22 -9
  2. package/dist/DocumentStorageProvider-CyOJ0hqf.es.js +24443 -0
  3. package/dist/DocumentStorageProvider-DGPQEd_l.cjs.js +134 -0
  4. package/dist/RenderedResult-BnPzJ9Jf.es.js +549 -0
  5. package/dist/RenderedResult-Dp22kZsQ.cjs.js +115 -0
  6. package/dist/{ServerProvider-DSK9rfSY.es.js → ServerProvider-BWOEKg0O.es.js} +1256 -1318
  7. package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
  8. package/dist/builder/index.cjs.js +105 -0
  9. package/dist/builder/index.d.ts +2 -0
  10. package/dist/builder/index.es.js +9482 -0
  11. package/dist/builder-entry.d.ts +8 -0
  12. package/dist/client/api.d.ts +100 -42
  13. package/dist/client/index.cjs.js +1 -1
  14. package/dist/client/index.es.js +1 -1
  15. package/dist/components/AppDialog.d.ts +30 -0
  16. package/dist/components/BackLink.d.ts +32 -0
  17. package/dist/components/Dashboard/Dashboard.d.ts +19 -14
  18. package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
  19. package/dist/components/Dashboard/DashboardGrid.d.ts +67 -0
  20. package/dist/components/Dashboard/DashboardTile.d.ts +6 -1
  21. package/dist/components/Dashboard/ExploreDialog.d.ts +18 -0
  22. package/dist/components/Dashboard/RowsDialog.d.ts +47 -0
  23. package/dist/components/Dashboard/TileCard.d.ts +44 -0
  24. package/dist/components/Dashboard/index.d.ts +2 -0
  25. package/dist/components/Dashboard/promoteMeasureRow.d.ts +7 -3
  26. package/dist/components/Dashboard/telemetry.d.ts +48 -0
  27. package/dist/components/DashboardBuilder/AddTileDialog.d.ts +35 -0
  28. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +31 -0
  29. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +118 -0
  30. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +30 -0
  31. package/dist/components/DashboardBuilder/DiffDialog.d.ts +15 -0
  32. package/dist/components/DashboardBuilder/DrillDialog.d.ts +15 -0
  33. package/dist/components/DashboardBuilder/FilterDialog.d.ts +54 -0
  34. package/dist/components/DashboardBuilder/FilterStrip.d.ts +17 -0
  35. package/dist/components/DashboardBuilder/SettingsPopover.d.ts +20 -0
  36. package/dist/components/DashboardBuilder/TileFrame.d.ts +42 -0
  37. package/dist/components/DashboardBuilder/TileMenu.d.ts +24 -0
  38. package/dist/components/DashboardBuilder/catalog.d.ts +62 -0
  39. package/dist/components/DashboardBuilder/controls.d.ts +157 -0
  40. package/dist/components/DashboardBuilder/diff.d.ts +35 -0
  41. package/dist/components/DashboardBuilder/document.d.ts +218 -0
  42. package/dist/components/DashboardBuilder/layout.d.ts +71 -0
  43. package/dist/components/DashboardBuilder/malloyText.d.ts +45 -0
  44. package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
  45. package/dist/components/DashboardBuilder/preview.d.ts +60 -0
  46. package/dist/components/DashboardBuilder/readDocument.d.ts +106 -0
  47. package/dist/components/DashboardBuilder/sortable.d.ts +51 -0
  48. package/dist/components/DashboardBuilder/spliceDocument.d.ts +53 -0
  49. package/dist/components/DashboardBuilder/testing/fixtures.d.ts +10 -0
  50. package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +22 -0
  51. package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +63 -0
  52. package/dist/components/DashboardBuilder/useDraft.d.ts +13 -0
  53. package/dist/components/DashboardBuilder/useFilterForm.d.ts +65 -0
  54. package/dist/components/DashboardBuilder/useTileReorder.d.ts +22 -0
  55. package/dist/components/DashboardBuilder/useTileResize.d.ts +29 -0
  56. package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +7 -0
  57. package/dist/components/DocumentStorage/index.d.ts +1 -1
  58. package/dist/components/FloatingIconButton.d.ts +16 -0
  59. package/dist/components/ItemRow.d.ts +38 -0
  60. package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
  61. package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
  62. package/dist/components/Materializations/Materializations.d.ts +7 -3
  63. package/dist/components/Materializations/ScopeButton.d.ts +18 -0
  64. package/dist/components/Materializations/SectionLabel.d.ts +7 -4
  65. package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
  66. package/dist/components/Materializations/index.d.ts +0 -1
  67. package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
  68. package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
  69. package/dist/components/Package/index.d.ts +0 -1
  70. package/dist/components/PackageSection.d.ts +23 -0
  71. package/dist/components/Prose.d.ts +46 -0
  72. package/dist/components/RenderedResult/ResultPanel.d.ts +30 -0
  73. package/dist/components/RenderedResult/index.d.ts +1 -0
  74. package/dist/components/buttons.d.ts +53 -0
  75. package/dist/components/drill/index.d.ts +1 -1
  76. package/dist/components/drill/resolveDrill.d.ts +22 -0
  77. package/dist/components/drill/useDrill.d.ts +11 -2
  78. package/dist/components/index.d.ts +6 -0
  79. package/dist/components/styles.d.ts +49 -44
  80. package/dist/hooks/index.d.ts +2 -0
  81. package/dist/hooks/useCrudMutation.d.ts +42 -0
  82. package/dist/hooks/useDocumentControls.d.ts +70 -0
  83. package/dist/hooks/useQueryResult.d.ts +40 -0
  84. package/dist/index.cjs.js +22 -273
  85. package/dist/index.d.ts +1 -0
  86. package/dist/index.es.js +16888 -44451
  87. package/dist/telemetry/consoleEvents.d.ts +60 -0
  88. package/dist/utils/malloyLiteral.d.ts +11 -0
  89. package/dist/utils/sha256.d.ts +2 -0
  90. package/package.json +24 -9
  91. package/src/builder-entry.ts +55 -0
  92. package/src/components/AppDialog.tsx +115 -0
  93. package/src/components/BackLink.tsx +83 -0
  94. package/src/components/Connections/AddConnectionDialog.tsx +50 -70
  95. package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
  96. package/src/components/Connections/EditConnectionDialog.tsx +54 -73
  97. package/src/components/Dashboard/Dashboard.spec.tsx +7 -10
  98. package/src/components/Dashboard/Dashboard.tsx +165 -175
  99. package/src/components/Dashboard/DashboardBar.tsx +88 -0
  100. package/src/components/Dashboard/DashboardGrid.tsx +124 -0
  101. package/src/components/Dashboard/DashboardTile.spec.tsx +30 -6
  102. package/src/components/Dashboard/DashboardTile.tsx +66 -123
  103. package/src/components/Dashboard/ExploreDialog.tsx +84 -0
  104. package/src/components/Dashboard/RowsDialog.spec.ts +42 -0
  105. package/src/components/Dashboard/RowsDialog.tsx +234 -0
  106. package/src/components/Dashboard/TileCard.tsx +120 -0
  107. package/src/components/Dashboard/index.ts +2 -0
  108. package/src/components/Dashboard/promoteMeasureRow.spec.ts +70 -0
  109. package/src/components/Dashboard/promoteMeasureRow.ts +33 -2
  110. package/src/components/Dashboard/telemetry.ts +51 -0
  111. package/src/components/Dashboard/tileGridColumn.spec.ts +1 -1
  112. package/src/components/DashboardBuilder/AddTileDialog.tsx +247 -0
  113. package/src/components/DashboardBuilder/BuilderToolbar.tsx +162 -0
  114. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +852 -0
  115. package/src/components/DashboardBuilder/DashboardBuilder.tsx +666 -0
  116. package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
  117. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +188 -0
  118. package/src/components/DashboardBuilder/DashboardEditor.tsx +567 -0
  119. package/src/components/DashboardBuilder/DiffDialog.tsx +122 -0
  120. package/src/components/DashboardBuilder/DrillDialog.tsx +269 -0
  121. package/src/components/DashboardBuilder/FilterDialog.tsx +562 -0
  122. package/src/components/DashboardBuilder/FilterStrip.tsx +126 -0
  123. package/src/components/DashboardBuilder/SettingsPopover.tsx +168 -0
  124. package/src/components/DashboardBuilder/TileFrame.tsx +380 -0
  125. package/src/components/DashboardBuilder/TileMenu.tsx +188 -0
  126. package/src/components/DashboardBuilder/catalog.spec.ts +215 -0
  127. package/src/components/DashboardBuilder/catalog.ts +225 -0
  128. package/src/components/DashboardBuilder/controls.spec.ts +243 -0
  129. package/src/components/DashboardBuilder/controls.ts +398 -0
  130. package/src/components/DashboardBuilder/diff.spec.ts +44 -0
  131. package/src/components/DashboardBuilder/diff.ts +93 -0
  132. package/src/components/DashboardBuilder/document.ts +209 -0
  133. package/src/components/DashboardBuilder/keepRowStructure.spec.ts +84 -0
  134. package/src/components/DashboardBuilder/layout.ts +143 -0
  135. package/src/components/DashboardBuilder/malloyText.spec.ts +84 -0
  136. package/src/components/DashboardBuilder/malloyText.ts +151 -0
  137. package/src/components/DashboardBuilder/moveIntoGap.spec.ts +90 -0
  138. package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
  139. package/src/components/DashboardBuilder/newDashboard.ts +48 -0
  140. package/src/components/DashboardBuilder/preview.spec.ts +149 -0
  141. package/src/components/DashboardBuilder/preview.ts +172 -0
  142. package/src/components/DashboardBuilder/readDocument.spec.ts +375 -0
  143. package/src/components/DashboardBuilder/readDocument.ts +467 -0
  144. package/src/components/DashboardBuilder/sortable.tsx +151 -0
  145. package/src/components/DashboardBuilder/spliceDocument.spec.ts +1161 -0
  146. package/src/components/DashboardBuilder/spliceDocument.ts +1135 -0
  147. package/src/components/DashboardBuilder/testing/fixtures.ts +48 -0
  148. package/src/components/DashboardBuilder/useBuilderShortcuts.ts +88 -0
  149. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +311 -0
  150. package/src/components/DashboardBuilder/useDashboardEditor.ts +201 -0
  151. package/src/components/DashboardBuilder/useDraft.ts +43 -0
  152. package/src/components/DashboardBuilder/useFilterForm.spec.tsx +144 -0
  153. package/src/components/DashboardBuilder/useFilterForm.ts +352 -0
  154. package/src/components/DashboardBuilder/useTileReorder.spec.tsx +97 -0
  155. package/src/components/DashboardBuilder/useTileReorder.ts +115 -0
  156. package/src/components/DashboardBuilder/useTileResize.spec.tsx +121 -0
  157. package/src/components/DashboardBuilder/useTileResize.ts +110 -0
  158. package/src/components/DashboardBuilder/withGaps.spec.ts +96 -0
  159. package/src/components/DocumentStorage/DocumentStorageProvider.tsx +12 -0
  160. package/src/components/DocumentStorage/index.ts +1 -0
  161. package/src/components/Environment/About.tsx +16 -62
  162. package/src/components/Environment/AddPackageDialog.tsx +85 -154
  163. package/src/components/Environment/Connections.tsx +125 -205
  164. package/src/components/Environment/DeletePackageDialog.tsx +32 -77
  165. package/src/components/Environment/EditPackageDialog.tsx +46 -58
  166. package/src/components/Environment/Environment.tsx +34 -36
  167. package/src/components/Environment/Packages.tsx +63 -128
  168. package/src/components/FloatingIconButton.tsx +41 -0
  169. package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
  170. package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
  171. package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
  172. package/src/components/Home/Home.tsx +101 -214
  173. package/src/components/ItemRow.tsx +165 -0
  174. package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
  175. package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
  176. package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
  177. package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
  178. package/src/components/Materializations/Materializations.tsx +137 -140
  179. package/src/components/Materializations/ScopeButton.tsx +85 -0
  180. package/src/components/Materializations/SectionLabel.tsx +7 -4
  181. package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
  182. package/src/components/Materializations/TriggerLabel.tsx +36 -0
  183. package/src/components/Materializations/cron.spec.ts +113 -0
  184. package/src/components/Materializations/index.ts +0 -1
  185. package/src/components/Materializations/utils.spec.ts +182 -0
  186. package/src/components/Model/Model.tsx +6 -23
  187. package/src/components/Model/ModelCell.tsx +33 -72
  188. package/src/components/Notebook/Notebook.tsx +25 -88
  189. package/src/components/Notebook/NotebookCell.tsx +35 -183
  190. package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
  191. package/src/components/Package/ContentTypeIcon.tsx +10 -12
  192. package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
  193. package/src/components/Package/NewDashboardDialog.tsx +265 -0
  194. package/src/components/Package/Package.tsx +179 -238
  195. package/src/components/Package/index.ts +0 -1
  196. package/src/components/PackageSection.tsx +85 -0
  197. package/src/components/Prose.spec.tsx +85 -0
  198. package/src/components/Prose.tsx +179 -0
  199. package/src/components/QueryResult/QueryResult.tsx +15 -43
  200. package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
  201. package/src/components/RenderedResult/RenderedResult.tsx +22 -8
  202. package/src/components/RenderedResult/ResultContainer.tsx +4 -12
  203. package/src/components/RenderedResult/ResultPanel.spec.tsx +49 -0
  204. package/src/components/RenderedResult/ResultPanel.tsx +73 -0
  205. package/src/components/RenderedResult/index.ts +1 -0
  206. package/src/components/ResultsDialog.tsx +8 -32
  207. package/src/components/buttons.tsx +114 -0
  208. package/src/components/designSystem.spec.tsx +316 -0
  209. package/src/components/drill/index.ts +1 -0
  210. package/src/components/drill/resolveDrill.ts +22 -1
  211. package/src/components/drill/useDrill.spec.tsx +94 -0
  212. package/src/components/drill/useDrill.tsx +52 -12
  213. package/src/components/given/GivensPanel.tsx +1 -1
  214. package/src/components/given/paramCodec.spec.ts +1 -1
  215. package/src/components/index.ts +16 -0
  216. package/src/components/styles.ts +49 -122
  217. package/src/hooks/index.ts +13 -0
  218. package/src/hooks/useCrudMutation.spec.tsx +119 -0
  219. package/src/hooks/useCrudMutation.tsx +85 -0
  220. package/src/hooks/useDocumentControls.ts +170 -0
  221. package/src/hooks/useQueryResult.ts +82 -0
  222. package/src/index.ts +9 -0
  223. package/src/telemetry/consoleEvents.spec.ts +130 -0
  224. package/src/telemetry/consoleEvents.ts +124 -0
  225. package/src/theme/defaults.ts +34 -23
  226. package/src/theme/resolveTheme.spec.ts +9 -4
  227. package/src/theme/resolveTheme.ts +12 -8
  228. package/src/utils/malloyLiteral.spec.ts +43 -0
  229. package/src/utils/malloyLiteral.ts +76 -0
  230. package/src/utils/sha256.ts +13 -0
  231. package/test/README.md +1 -1
  232. package/test/serverProvider.tsx +5 -2
  233. package/vite.config.ts +5 -0
  234. package/dist/ServerProvider-CGnLjzag.cjs.js +0 -1
  235. package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
  236. package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
  237. package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
  238. package/dist/components/Materializations/TriggerChip.d.ts +0 -10
  239. package/dist/components/Package/Models.d.ts +0 -6
  240. package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
  241. package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
  242. package/src/components/Materializations/ScheduleCard.tsx +0 -231
  243. package/src/components/Materializations/TriggerChip.tsx +0 -44
  244. package/src/components/Package/Models.tsx +0 -71
@@ -0,0 +1,105 @@
1
+ "use strict";var Cd=Object.create;var Ho=Object.defineProperty;var Id=Object.getOwnPropertyDescriptor;var jd=Object.getOwnPropertyNames;var Ad=Object.getPrototypeOf,Rd=Object.prototype.hasOwnProperty;var Ld=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of jd(t))!Rd.call(e,i)&&i!==n&&Ho(e,i,{get:()=>t[i],enumerable:!(r=Id(t,i))||r.enumerable});return e};var Ko=(e,t,n)=>(n=e!=null?Cd(Ad(e)):{},Ld(t||!e||!e.__esModule?Ho(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),S=require("react"),zd=require("react-dom"),k=require("@mui/material"),j=require("../DocumentStorageProvider-DGPQEd_l.cjs.js"),Pe=require("../ServerProvider-Cc489A3f.cjs.js"),Wd=require("@tanstack/react-query");var Fd=Symbol.for("preact-signals");function hi(){if(lt>1)lt--;else{var e,t=!1;for((function(){var i=qr;for(qr=void 0;i!==void 0;){var s=i.S;if(s.v===i.v)for(var o=s.t;o!==void 0;o=o.x)o.i===i.i&&(o.i=s.i);i=i.o}})();Xn!==void 0;){var n=Xn;for(Xn=void 0,Kr++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ga(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(Kr=0,lt--,t)throw e}}function oe(e){if(lt>0)return e();Ui=++Bd,lt++;try{return e()}finally{hi()}}var Un,te=void 0;function N(e){var t=te,n=Un;te=void 0,Un=void 0;try{return e()}finally{te=t,Un=n}}var Xn=void 0,lt=0,Kr=0,Bd=0,Ui=0,qr=void 0,Ur=0;function Na(e){if(te!==void 0){var t=e.n;if(t===void 0||t.t!==te)return t={i:0,S:e,p:te.s,n:void 0,t:te,e:void 0,x:void 0,r:t},te.s!==void 0&&(te.s.n=t),te.s=t,e.n=t,32&te.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=te.s,t.n=void 0,te.s.n=t,te.s=t),t}}function Oe(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}Oe.prototype.brand=Fd;Oe.prototype.h=function(){return!0};Oe.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:N(function(){var r;(r=t.W)==null||r.call(t)}))};Oe.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&&N(function(){var i;(i=t.Z)==null||i.call(t)}))}};Oe.prototype.subscribe=function(e){var t=this;return Be(function(){var n=t.value;N(function(){return e(n)})},{name:"sub"})};Oe.prototype.valueOf=function(){return this.value};Oe.prototype.toString=function(){return this.value+""};Oe.prototype.toJSON=function(){return this.value};Oe.prototype.peek=function(){var e=this;return N(function(){return e.value})};Object.defineProperty(Oe.prototype,"value",{get:function(){var e=Na(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Kr>100)throw new Error("Cycle detected");(function(n){lt!==0&&Kr===0&&n.l!==Ui&&(n.l=Ui,qr={S:n,v:n.v,i:n.i,o:qr})})(this),this.v=e,this.i++,Ur++,lt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{hi()}}}});function vn(e,t){return new Oe(e,t)}function Ga(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 Va(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 Ha(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 zt(e,t){Oe.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Ur-1,this.f=4}zt.prototype=new Oe;zt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Ur))return!0;if(this.g=Ur,this.f|=1,this.i>0&&!Ga(this))return this.f&=-2,!0;var e=te;try{Va(this),te=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 te=e,Ha(this),this.f&=-2,!0};zt.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)}Oe.prototype.S.call(this,e)};zt.prototype.U=function(e){if(this.t!==void 0&&(Oe.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)}};zt.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(zt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Na(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function qo(e,t){return new zt(e,t)}function Ka(e){var t=e.m;if(e.m=void 0,typeof t=="function"){lt++;var n=te;te=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Ls(e),r}finally{te=n,hi()}}}function Ls(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Ka(e)}function Nd(e){if(te!==this)throw new Error("Out-of-order effect");Ha(this),te=e,this.f&=-2,8&this.f&&Ls(this),hi()}function mn(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Un&&Un.push(this)}mn.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()}};mn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Ka(this),Va(this),lt++;var e=te;return te=this,Nd.bind(this,e)};mn.prototype.N=function(){2&this.f||(this.f|=2,this.u=Xn,Xn=this)};mn.prototype.d=function(){this.f|=8,1&this.f||Ls(this)};mn.prototype.dispose=function(){this.d()};function Be(e,t){var n=new mn(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Gd=Object.create,zs=Object.defineProperty,Vd=Object.defineProperties,Hd=Object.getOwnPropertyDescriptor,Kd=Object.getOwnPropertyDescriptors,Uo=Object.getOwnPropertySymbols,qd=Object.prototype.hasOwnProperty,Ud=Object.prototype.propertyIsEnumerable,Xd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),yn=e=>{throw TypeError(e)},Xi=(e,t,n)=>t in e?zs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Yd=(e,t)=>{for(var n in t||(t={}))qd.call(t,n)&&Xi(e,n,t[n]);if(Uo)for(var n of Uo(t))Ud.call(t,n)&&Xi(e,n,t[n]);return e},Zd=(e,t)=>Vd(e,Kd(t)),Xo=(e,t)=>zs(e,"name",{value:t,configurable:!0}),Jd=e=>{var t;return[,,,Gd((t=void 0)!=null?t:null)]},qa=["class","method","getter","setter","accessor","field","value","get","set"],Cn=e=>e!==void 0&&typeof e!="function"?yn("Function expected"):e,Qd=(e,t,n,r,i)=>({kind:qa[e],name:t,metadata:r,addInitializer:s=>n._?yn("Already initialized"):i.push(Cn(s||null))}),Ua=(e,t)=>Xi(t,Xd("metadata"),e[3]),St=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},bn=(e,t,n,r,i,s)=>{var o,a,c,d,u,l=t&7,f=!!(t&8),g=!!(t&16),h=l>3?e.length+1:l?f?1:2:0,m=qa[l+5],w=l>3&&(e[h-1]=[]),b=e[h]||(e[h]=[]),v=l&&(!g&&!f&&(i=i.prototype),l<5&&(l>3||!g)&&Hd(l<4?i:{get[n](){return Le(this,s)},set[n](x){return vt(this,s,x)}},n));l?g&&l<4&&Xo(s,(l>2?"set ":l>1?"get ":"")+n):Xo(i,n);for(var p=r.length-1;p>=0;p--)d=Qd(l,n,c={},e[3],b),l&&(d.static=f,d.private=g,u=d.access={has:g?x=>eu(i,x):x=>n in x},l^3&&(u.get=g?x=>(l^1?Le:tu)(x,i,l^4?s:v.get):x=>x[n]),l>2&&(u.set=g?(x,_)=>vt(x,i,_,l^4?s:v.set):(x,_)=>x[n]=_)),a=(0,r[p])(l?l<4?g?s:v[m]:l>4?void 0:{get:v.get,set:v.set}:i,d),c._=1,l^4||a===void 0?Cn(a)&&(l>4?w.unshift(a):l?g?s=a:v[m]=a:i=a):typeof a!="object"||a===null?yn("Object expected"):(Cn(o=a.get)&&(v.get=o),Cn(o=a.set)&&(v.set=o),Cn(o=a.init)&&w.unshift(o));return l||Ua(e,i),v&&zs(i,n,v),g?l^4?s:v:i},Ws=(e,t,n)=>t.has(e)||yn("Cannot "+n),eu=(e,t)=>Object(t)!==t?yn('Cannot use the "in" operator on this value'):e.has(t),Le=(e,t,n)=>(Ws(e,t,"read from private field"),n?n.call(e):t.get(e)),In=(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),vt=(e,t,n,r)=>(Ws(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),tu=(e,t,n)=>(Ws(e,t,"access private method"),n);function Yi(e,t){if(t){let n;return qo(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return qo(e)}function Ke(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((r,i)=>!Ke(r,t[i]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(s=>!Ke(e[s],t[s]))}return!1}function G({get:e},t){return{init(n){return vn(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function le(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Yi(e.bind(this)),n.set(this,r)),r.value}}function Pi(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),i=Object.getOwnPropertyDescriptor(r,n.name);i&&Object.defineProperty(r,n.name,Zd(Yd({},i),{enumerable:e}))})}}function dr(...e){const t=e.map(n=>Be(n));return()=>t.forEach(n=>n())}var Xa,Ya,Za,Ja,Qa,el,ke,Fs,Mi,Zi,Ji,be,Bs,Ci,tl,Qi,Ns,Ii,es,ts;el=[G],Qa=[G],Ja=[G],Za=[Pi()],Ya=[Pi()],Xa=[Pi()];var Wt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,St(ke,5,this),In(this,be),In(this,Fs,St(ke,8,this)),St(ke,11,this),In(this,Bs,St(ke,12,this)),St(ke,15,this),In(this,Ns,St(ke,16,this)),St(ke,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Le(this,be,es)}get initial(){return Le(this,be,Zi)}get previous(){return Le(this,be,tl)}set current(e){const t=N(()=>Le(this,be,es));e&&t&&this.equals(t,e)||oe(()=>{Le(this,be,Zi)||vt(this,be,e,Ji),vt(this,be,t,Qi),vt(this,be,e,ts)})}reset(e=this.defaultValue){oe(()=>{vt(this,be,void 0,Qi),vt(this,be,e,Ji),vt(this,be,e,ts)})}};ke=Jd();Fs=new WeakMap;be=new WeakSet;Bs=new WeakMap;Ns=new WeakMap;Mi=bn(ke,20,"#initial",el,be,Fs),Zi=Mi.get,Ji=Mi.set;Ci=bn(ke,20,"#previous",Qa,be,Bs),tl=Ci.get,Qi=Ci.set;Ii=bn(ke,20,"#current",Ja,be,Ns),es=Ii.get,ts=Ii.set;bn(ke,2,"current",Za,Wt);bn(ke,2,"initial",Ya,Wt);bn(ke,2,"previous",Xa,Wt);Ua(ke,Wt);function ji(e){return N(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var $t,nu=class{constructor(){In(this,$t,new WeakMap)}get(e,t){var n;return e?(n=Le(this,$t).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Le(this,$t).has(e)||Le(this,$t).set(e,new Map),(r=Le(this,$t).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Le(this,$t).get(e))==null?void 0:t.clear():void 0}};$t=new WeakMap;var ru=Object.create,nl=Object.defineProperty,iu=Object.getOwnPropertyDescriptor,Yo=Object.getOwnPropertySymbols,su=Object.prototype.hasOwnProperty,ou=Object.prototype.propertyIsEnumerable,rl=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),pi=e=>{throw TypeError(e)},Zo=Math.pow,ns=(e,t,n)=>t in e?nl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,au=(e,t)=>{for(var n in t||(t={}))su.call(t,n)&&ns(e,n,t[n]);if(Yo)for(var n of Yo(t))ou.call(t,n)&&ns(e,n,t[n]);return e},lu=e=>{var t;return[,,,ru((t=e?.[rl("metadata")])!=null?t:null)]},il=["class","method","getter","setter","accessor","field","value","get","set"],sl=e=>e!==void 0&&typeof e!="function"?pi("Function expected"):e,cu=(e,t,n,r,i)=>({kind:il[e],name:t,metadata:r,addInitializer:s=>n._?pi("Already initialized"):i.push(sl(s||null))}),du=(e,t)=>ns(t,rl("metadata"),e[3]),uu=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)s[i].call(n);return r},ol=(e,t,n,r,i,s)=>{for(var o,a,c,d,u=t&7,l=!1,f=!1,g=2,h=il[u+5],m=e[g]||(e[g]=[]),w=(i=i.prototype,iu(i,n)),b=r.length-1;b>=0;b--)c=cu(u,n,a={},e[3],m),c.static=l,c.private=f,d=c.access={has:v=>n in v},d.get=v=>v[n],o=(0,r[b])(w[h],c),a._=1,sl(o)&&(w[h]=o);return w&&nl(i,n,w),i},al=(e,t,n)=>t.has(e)||pi("Cannot "+n),fu=(e,t,n)=>(al(e,t,"read from private field"),t.get(e)),hu=(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),pu=(e,t,n,r)=>(al(e,t,"write to private field"),t.set(e,n),n),ze=class rs{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new rs(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 rs(t,n)}},tt=class Ot{constructor(t,n,r,i){this.left=t,this.top=n,this.width=r,this.height=i,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:i,width:s,height:o,scale:a}=this,c=new Ot(i+t,r+n,s,o);return c.scale=au({},a),c}get boundingRectangle(){const{width:t,height:n,left:r,top:i,right:s,bottom:o}=this;return{width:t,height:n,left:r,top:i,right:s,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:i}=this;return new ze((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Ot))return!1;const{left:n,top:r,width:i,height:s}=this;return n===t.left&&r===t.top&&i===t.width&&s===t.height}containsPoint(t){const{top:n,left:r,bottom:i,right:s}=this;return n<=t.y&&t.y<=i&&r<=t.x&&t.x<=s}intersectionArea(t){return t instanceof Ot?gu(this,t):0}intersectionRatio(t){const{area:n}=this,r=this.intersectionArea(t);return r/(t.area+n-r)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}get aspectRatio(){const{width:t,height:n}=this;return t/n}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:i}){return new Ot(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],c=o==="x"?s.left:s.top,d=o==="x"?s.width:s.height;return a=="start"?c:a=="end"?c+d:c+d/2};return ze.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return Ot.from(t).intersectionRatio(Ot.from(n))}};function gu(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),o=i-r,a=s-n;return r<i&&n<s?o*a:0}var ll,cl,is,Ir,ur,gi=class extends(is=Wt,cl=[le],ll=[le],is){constructor(t){const n=ze.from(t);super(n,(r,i)=>ze.equals(r,i)),uu(ur,5,this),hu(this,Ir,0),this.velocity={x:0,y:0}}get delta(){return ze.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=ze.from(t),i={x:r.x-n.x,y:r.y-n.y},s=Date.now(),o=s-fu(this,Ir),a=c=>Math.round(c/o*100);oe(()=>{pu(this,Ir,s),this.velocity={x:a(i.x),y:a(i.y)},super.current=r})}reset(t=this.defaultValue){super.reset(ze.from(t)),this.velocity={x:0,y:0}}};ur=lu(is);Ir=new WeakMap;ol(ur,2,"delta",cl,gi);ol(ur,2,"direction",ll,gi);du(ur,gi);function ss({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(Zo(r,2)+Zo(i,2))>n:"x"in n&&"y"in n?r>n.x&&i>n.y:"x"in n?r>n.x:"y"in n?i>n.y:!1}var dl=(e=>(e.Horizontal="x",e.Vertical="y",e))(dl||{}),ul=Object.values(dl),vu=Object.create,Gs=Object.defineProperty,mu=Object.defineProperties,yu=Object.getOwnPropertyDescriptor,bu=Object.getOwnPropertyDescriptors,Xr=Object.getOwnPropertySymbols,fl=Object.prototype.hasOwnProperty,hl=Object.prototype.propertyIsEnumerable,pl=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),xn=e=>{throw TypeError(e)},os=(e,t,n)=>t in e?Gs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Vs=(e,t)=>{for(var n in t||(t={}))fl.call(t,n)&&os(e,n,t[n]);if(Xr)for(var n of Xr(t))hl.call(t,n)&&os(e,n,t[n]);return e},Hs=(e,t)=>mu(e,bu(t)),Jo=(e,t)=>Gs(e,"name",{value:t,configurable:!0}),gl=(e,t)=>{var n={};for(var r in e)fl.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Xr)for(var r of Xr(e))t.indexOf(r)<0&&hl.call(e,r)&&(n[r]=e[r]);return n},_n=e=>{var t;return[,,,vu((t=e?.[pl("metadata")])!=null?t:null)]},vl=["class","method","getter","setter","accessor","field","value","get","set"],jn=e=>e!==void 0&&typeof e!="function"?xn("Function expected"):e,xu=(e,t,n,r,i)=>({kind:vl[e],name:t,metadata:r,addInitializer:s=>n._?xn("Already initialized"):i.push(jn(s||null))}),Ft=(e,t)=>os(t,pl("metadata"),e[3]),B=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},V=(e,t,n,r,i,s)=>{var o,a,c,d,u,l=t&7,f=!!(t&8),g=!!(t&16),h=l>3?e.length+1:l?f?1:2:0,m=vl[l+5],w=l>3&&(e[h-1]=[]),b=e[h]||(e[h]=[]),v=l&&(!g&&!f&&(i=i.prototype),l<5&&(l>3||!g)&&yu(l<4?i:{get[n](){return ae(this,s)},set[n](x){return Ae(this,s,x)}},n));l?g&&l<4&&Jo(s,(l>2?"set ":l>1?"get ":"")+n):Jo(i,n);for(var p=r.length-1;p>=0;p--)d=xu(l,n,c={},e[3],b),l&&(d.static=f,d.private=g,u=d.access={has:g?x=>_u(i,x):x=>n in x},l^3&&(u.get=g?x=>(l^1?ae:ml)(x,i,l^4?s:v.get):x=>x[n]),l>2&&(u.set=g?(x,_)=>Ae(x,i,_,l^4?s:v.set):(x,_)=>x[n]=_)),a=(0,r[p])(l?l<4?g?s:v[m]:l>4?void 0:{get:v.get,set:v.set}:i,d),c._=1,l^4||a===void 0?jn(a)&&(l>4?w.unshift(a):l?g?s=a:v[m]=a:i=a):typeof a!="object"||a===null?xn("Object expected"):(jn(o=a.get)&&(v.get=o),jn(o=a.set)&&(v.set=o),jn(o=a.init)&&w.unshift(o));return l||Ft(e,i),v&&Gs(i,n,v),g?l^4?s:v:i},Ks=(e,t,n)=>t.has(e)||xn("Cannot "+n),_u=(e,t)=>Object(t)!==t?xn('Cannot use the "in" operator on this value'):e.has(t),ae=(e,t,n)=>(Ks(e,t,"read from private field"),n?n.call(e):t.get(e)),q=(e,t,n)=>t.has(e)?xn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ae=(e,t,n,r)=>(Ks(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ml=(e,t,n)=>(Ks(e,t,"access private method"),n);function yl(e,t){return{plugin:e,options:t}}function fr(e){return t=>yl(e,t)}function tr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var bl,nr,qs,jr;bl=[G];var xe=class{constructor(e,t){this.manager=e,this.options=t,q(this,qs,B(nr,8,this,!1)),B(nr,11,this),q(this,jr,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return N(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=Be(e.bind(this));return ae(this,jr).add(t),t}destroy(){ae(this,jr).forEach(e=>e())}static configure(e){return yl(this,e)}};nr=_n(null);qs=new WeakMap;jr=new WeakMap;V(nr,4,"disabled",bl,xe,qs);Ft(nr,xe);var hr=class extends xe{},Ar,Ai=class{constructor(e){this.manager=e,this.instances=new Map,q(this,Ar,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(tr).reduce((r,i)=>{const s=r.find(({plugin:o})=>o===i.plugin);return s?(s.options=i.options,r):[...r,i]},[]),n=t.map(({plugin:r})=>r);for(const r of ae(this,Ar))if(!n.includes(r)){if(r.prototype instanceof hr)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);Ae(this,Ar,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()}};Ar=new WeakMap;function wu(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var _r=[],Yt,Zt,ku=class extends xe{constructor(e){super(e),q(this,Yt),q(this,Zt),this.computeCollisions=this.computeCollisions.bind(this),Ae(this,Zt,vn(_r)),this.destroy=dr(()=>{const t=this.computeCollisions(),n=N(()=>this.manager.dragOperation.position.current);if(t!==_r){const r=ae(this,Yt);if(Ae(this,Yt,n),r&&n.x==r.x&&n.y==r.y)return}else Ae(this,Yt,void 0);ae(this,Zt).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){N(()=>{e?ae(this,Zt).value=this.computeCollisions():Ae(this,Yt,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return _r;const a=[],c=[];for(const d of e??n.droppables){if(d.disabled||i&&!d.accepts(i))continue;const u=t??d.collisionDetector;if(!u)continue;c.push(d),d.shape;const l=N(()=>u({droppable:d,dragOperation:r}));l&&(d.collisionPriority!=null&&(l.priority=d.collisionPriority),a.push(l))}return c.length===0?_r:(a.sort(wu),a)}get collisions(){return ae(this,Zt).value}};Yt=new WeakMap;Zt=new WeakMap;var xl,_l,wl,Us,kl,qe,Xs,rn,Ys,Zs;wl=[G],_l=[G],xl=[G];var dt=class Tt{constructor(t,n){q(this,Xs,B(qe,8,this)),B(qe,11,this),q(this,rn),q(this,Ys,B(qe,12,this)),B(qe,15,this),q(this,Zs,B(qe,16,this)),B(qe,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let c=i;Ae(this,rn,vn(i)),this.manager=n,this.data=s,this.disabled=o,this.effects=()=>{var d;return[()=>{const{id:u,manager:l}=this;if(u!==c)return c=u,l?.registry.register(this),()=>l?.registry.unregister(this)},...(d=r?.())!=null?d:[]]},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=ae(this,rn).value;return(n=(t=Tt.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=Tt.pendingIdChanges)==null?void 0:n.get(this))!=null?r:ae(this,rn).peek();t!==i&&(Tt.pendingIdChanges||(Tt.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return ml(s=Tt,Us,kl).call(s)})),Tt.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)}};qe=_n(null);Us=new WeakSet;kl=function(){const e=dt.pendingIdChanges;dt.pendingIdChanges=null,e&&oe(()=>{for(const[t,n]of e)ae(t,rn).value=n})};Xs=new WeakMap;rn=new WeakMap;Ys=new WeakMap;Zs=new WeakMap;V(qe,4,"manager",wl,dt,Xs);V(qe,4,"data",_l,dt,Ys);V(qe,4,"disabled",xl,dt,Zs);q(dt,Us);Ft(qe,dt);dt.pendingIdChanges=null;var vi=dt,Qo=class{constructor(){this.map=vn(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;if(r&&r.id===e){const a=this.cleanupFunctions.get(r);a?.(),this.cleanupFunctions.delete(r)}const s=new Map(n);for(const[a,c]of n)if(c===t&&a!==e){s.delete(a);break}s.set(e,t),this.map.value=s;const o=dr(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;const r=this.cleanupFunctions.get(t);r?.(),this.cleanupFunctions.delete(t);const i=new Map(n);i.delete(e),this.map.value=i}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this){const t=this.cleanupFunctions.get(e);t?.(),e.destroy()}this.map.value=new Map}},Sl,$l,Ol,Tl,Dl,El,as,Se,Js,Qs,eo,nt=class extends(as=vi,El=[G],Dl=[G],Tl=[G],Ol=[le],$l=[le],Sl=[le],as){constructor(t,n){var r=t,{modifiers:i,type:s,sensors:o,plugins:a,effects:c}=r,d=gl(r,["modifiers","type","sensors","plugins","effects"]);super(Hs(Vs({},d),{effects:()=>{var u;return[...(u=c?.())!=null?u:[],()=>{const{manager:l,plugins:f}=this;if(!(!l||!f))for(const g of f){const{plugin:h}=tr(g);l.registry.plugins.register(h)}}]}}),n),B(Se,5,this),q(this,Js,B(Se,8,this)),B(Se,11,this),q(this,Qs,B(Se,12,this)),B(Se,15,this),q(this,eo,B(Se,16,this,this.isDragSource?"dragging":"idle")),B(Se,19,this),this.type=s,this.sensors=o,this.modifiers=i,this.alignment=d.alignment,this.plugins=a}pluginConfig(t){if(this.plugins)for(const n of this.plugins){const r=tr(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}};Se=_n(as);Js=new WeakMap;Qs=new WeakMap;eo=new WeakMap;V(Se,4,"type",El,nt,Js);V(Se,4,"modifiers",Dl,nt,Qs);V(Se,4,"status",Tl,nt,eo);V(Se,2,"isDropping",Ol,nt);V(Se,2,"isDragging",$l,nt);V(Se,2,"isDragSource",Sl,nt);Ft(Se,nt);var Pl,Ml,Cl,Il,jl,Al,ls,ue,to,no,ro,io,so,rt=class extends(ls=vi,Al=[G],jl=[G],Il=[G],Cl=[G],Ml=[G],Pl=[le],ls){constructor(t,n){var r=t,{accept:i,collisionDetector:s,collisionPriority:o,type:a}=r,c=gl(r,["accept","collisionDetector","collisionPriority","type"]);super(c,n),B(ue,5,this),q(this,to,B(ue,8,this)),B(ue,11,this),q(this,no,B(ue,12,this)),B(ue,15,this),q(this,ro,B(ue,16,this)),B(ue,19,this),q(this,io,B(ue,20,this)),B(ue,23,this),q(this,so,B(ue,24,this)),B(ue,27,this),this.accept=i,this.collisionDetector=s,this.collisionPriority=o,this.type=a}accepts(t){const{accept:n}=this;return n?typeof n=="function"?n(t):t.type?Array.isArray(n)?n.includes(t.type):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}};ue=_n(ls);to=new WeakMap;no=new WeakMap;ro=new WeakMap;io=new WeakMap;so=new WeakMap;V(ue,4,"accept",Al,rt,to);V(ue,4,"type",jl,rt,no);V(ue,4,"collisionDetector",Il,rt,ro);V(ue,4,"collisionPriority",Cl,rt,io);V(ue,4,"shape",Ml,rt,so);V(ue,2,"isDropTarget",Pl,rt);Ft(ue,rt);var Su=class{constructor(){this.registry=new Map}addEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){const{registry:n}=this,r=n.get(e);if(r)for(const i of r)i(...t)}},$u=class extends Su{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function Rr(e,t=!0){let n=!1;return Hs(Vs({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Ou=class extends hr{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=dr(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||vi.pendingIdChanges)return;const o=Rr({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;N(()=>{var c;a?.id!==((c=e.dragOperation.target)==null?void 0:c.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},wn=(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))(wn||{}),kn=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(kn||{}),Rl,Ll,zl,Wl,Fl,Bl,Nl,Fe,oo;Nl=[G],Bl=[le],Fl=[le],Wl=[le],zl=[le],Ll=[le],Rl=[le];var ut=class{constructor(){B(Fe,5,this),q(this,oo,B(Fe,8,this,"idle")),B(Fe,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}};Fe=_n(null);oo=new WeakMap;V(Fe,4,"value",Nl,ut,oo);V(Fe,2,"current",Bl,ut);V(Fe,2,"idle",Fl,ut);V(Fe,2,"initializing",Wl,ut);V(Fe,2,"initialized",zl,ut);V(Fe,2,"dragging",Ll,ut);V(Fe,2,"dropped",Rl,ut);Ft(Fe,ut);var Tu=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 N(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=Rr({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return N(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const r=new AbortController,{event:i,coordinates:s}=e;oe(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=i??null,t.position.reset(s)});const o=Rr({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"&&oe(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:i,operation:t.snapshot(),cancelable:!1})})}),r)})}move(e){return N(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=Rr({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,c,d,u,l;if(o.defaultPrevented)return;const f=(l=e.to)!=null?l:{x:r.position.current.x+((c=(a=e.by)==null?void 0:a.x)!=null?c:0),y:r.position.current.y+((u=(d=e.by)==null?void 0:d.y)!=null?u:0)};r.position.current=f})})}stop(e={}){return N(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:i}=r;if(!i||i.signal.aborted)return;let s;const o=()=>{const c={resume:()=>{},abort:()=>{}};return s=new Promise((d,u)=>{c.resume=d,c.abort=u}),c};i.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const c=N(()=>{var u;return((u=r.source)==null?void 0:u.status)==="dropping"}),d=()=>{r.controller===i&&(r.controller=void 0),r.reset()};if(c){const{source:u}=r,l=Be(()=>{u?.status==="idle"&&(l(),d())})}else this.manager.renderer.rendering.then(d)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),s?s.then(a).catch(()=>r.reset()):a()})}},cn=class extends xe{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Du=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)}},Lr,Gl=class{constructor(e){this.options=e,q(this,Lr)}set controller(e){Ae(this,Lr,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=ae(this,Lr))==null||t.activate(e)}};Lr=new WeakMap;var ea=class extends xe{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Eu=class{constructor(e){this.draggables=new Qo,this.droppables=new Qo,this.plugins=new Ai(e),this.sensors=new Ai(e),this.modifiers=new Ai(e)}register(e,t){if(e instanceof nt)return this.draggables.register(e.id,e);if(e instanceof rt)return this.droppables.register(e.id,e);if(e.prototype instanceof ea)return this.modifiers.register(e,t);if(e.prototype instanceof cn)return this.sensors.register(e,t);if(e.prototype instanceof xe)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof vi)return e instanceof nt?this.draggables.unregister(e.id,e):e instanceof rt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof ea)return this.modifiers.unregister(e);if(e.prototype instanceof cn)return this.sensors.unregister(e);if(e.prototype instanceof xe)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()}},Vl,Hl,Kl,ql,Ul,Xl,Yl,Zl,Jl,An,zr,Jt,se,ao,lo,co,uo,fo,Rn;Jl=[le],Zl=[G],Yl=[G],Xl=[G],Ul=[G],ql=[G],Kl=[le],Hl=[le],Vl=[le];var Xe=class{constructor(e){B(se,5,this),q(this,An),q(this,zr),q(this,Jt,new Wt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new ut,q(this,ao,B(se,8,this,!1)),B(se,11,this),q(this,lo,B(se,12,this,null)),B(se,15,this),q(this,co,B(se,16,this,null)),B(se,19,this),q(this,uo,B(se,20,this,null)),B(se,23,this),q(this,fo,B(se,24,this,[])),B(se,27,this),this.position=new gi({x:0,y:0}),q(this,Rn,{x:0,y:0}),Ae(this,An,e)}get shape(){const{current:e,initial:t,previous:n}=ae(this,Jt);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?ae(this,Jt).current=e:ae(this,Jt).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=ae(this,An).registry.draggables.get(t);return n&&Ae(this,zr,n),(e=n??ae(this,zr))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=ae(this,An).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(Hs(Vs({},this.snapshot()),{transform:n}));return Ae(this,Rn,n),n}snapshot(){return N(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:ae(this,Rn),shape:this.shape?ji(this.shape):null,position:ji(this.position),status:ji(this.status),canceled:this.canceled}))}reset(){oe(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,ae(this,Jt).reset(),this.position.reset({x:0,y:0}),Ae(this,Rn,{x:0,y:0}),this.modifiers=[]})}};se=_n(null);An=new WeakMap;zr=new WeakMap;Jt=new WeakMap;ao=new WeakMap;lo=new WeakMap;co=new WeakMap;uo=new WeakMap;fo=new WeakMap;Rn=new WeakMap;V(se,2,"shape",Jl,Xe);V(se,4,"canceled",Zl,Xe,ao);V(se,4,"activatorEvent",Yl,Xe,lo);V(se,4,"sourceIdentifier",Xl,Xe,co);V(se,4,"targetIdentifier",Ul,Xe,uo);V(se,4,"modifiers",ql,Xe,fo);V(se,2,"source",Kl,Xe);V(se,2,"target",Hl,Xe);V(se,2,"transform",Vl,Xe);Ft(se,Xe);var Pu={get rendering(){return Promise.resolve()}};function Ue(e,t){return typeof e=="function"?e(t):e??t}var Mu=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??{},i=Ue(r.plugins,[]),s=Ue(r.sensors,[]),o=Ue(r.modifiers,[]),a=(n=r.renderer)!=null?n:Pu,c=new $u(this),d=new Eu(this);this.registry=d,this.monitor=c,this.renderer=a,this.actions=new Tu(this),this.dragOperation=new Xe(this),this.collisionObserver=new ku(this),this.plugins=[Ou,...i],this.modifiers=o,this.sensors=s;const{destroy:u}=this,l=dr(()=>{var f,g,h;const m=N(()=>this.dragOperation.modifiers),w=this.modifiers;for(const b of m)w.includes(b)||b.destroy();this.dragOperation.modifiers=(h=(g=(f=this.dragOperation.source)==null?void 0:f.modifiers)==null?void 0:g.map(b=>{const{plugin:v,options:p}=tr(b);return new v(this,p)}))!=null?h:w});this.destroy=()=>{l(),u()}}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}},Ql=e=>{throw TypeError(e)},ho=(e,t,n)=>t.has(e)||Ql("Cannot "+n),F=(e,t,n)=>(ho(e,t,"read from private field"),t.get(e)),Ee=(e,t,n)=>t.has(e)?Ql("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),je=(e,t,n,r)=>(ho(e,t,"write to private field"),t.set(e,n),n),ec=(e,t,n)=>(ho(e,t,"access private method"),n);function mi(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function tc(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,a=(mi(s)?s.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],i])}return r}function yi(e){const{width:t,height:n,top:r,left:i,bottom:s,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:i,bottom:s,right:o}}function po(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function pr(e){return"nodeType"in e}function Re(e){var t,n,r;return e?po(e)?e:pr(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 go(e){const{Document:t}=Re(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function _t(e){return!e||po(e)?!1:e instanceof Re(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function nc(e){return e instanceof Re(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function Sn(e){return e?po(e)?e.document:pr(e)?go(e)?e:_t(e)||nc(e)?e.ownerDocument:document:document:document}function Cu(e){var t,n,r,i;const{documentElement:s}=Sn(e),o=Re(e).visualViewport,a=(t=o?.width)!=null?t:s.clientWidth,c=(n=o?.height)!=null?n:s.clientHeight,d=(r=o?.offsetTop)!=null?r:0,u=(i=o?.offsetLeft)!=null?i:0;return{top:d,left:u,right:u+a,bottom:d+c,width:a,height:c}}function Iu(e,t){if(ju(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function ju(e){return e.tagName==="DETAILS"}function rr(e,t=e.getBoundingClientRect(),n=0){var r,i,s,o,a;let c=t;const{ownerDocument:d}=e,u=(r=d.defaultView)!=null?r:window;let l=e.parentElement;for(;l&&l!==d.documentElement;){if(!Iu(l)){const p=l.getBoundingClientRect(),x=n*(p.bottom-p.top),_=n*(p.right-p.left),$=n*(p.bottom-p.top),T=n*(p.right-p.left);c={top:Math.max(c.top,p.top-x),right:Math.min(c.right,p.right+_),bottom:Math.min(c.bottom,p.bottom+$),left:Math.max(c.left,p.left-T),width:0,height:0},c.width=c.right-c.left,c.height=c.bottom-c.top}l=l.parentElement}const f=u.visualViewport,g=(i=f?.offsetTop)!=null?i:0,h=(s=f?.offsetLeft)!=null?s:0,m=(o=f?.width)!=null?o:u.innerWidth,w=(a=f?.height)!=null?a:u.innerHeight,b=n*w,v=n*m;return c={top:Math.max(c.top,g-b),right:Math.min(c.right,h+m+v),bottom:Math.min(c.bottom,g+w+b),left:Math.max(c.left,h-v),width:0,height:0},c.width=c.right-c.left,c.height=c.bottom-c.top,c.width<0&&(c.width=0),c.height<0&&(c.height=0),c}function dn(e){return{x:e.clientX,y:e.clientY}}var rc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function cs(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const i=r.contentDocument;i&&!t.has(i)&&n.push(...cs(i,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const i=r.parent;i&&i.document&&i.document!==e&&n.push(...cs(i.document,t))}}catch{}return n}function vo(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function ic(){var e,t;const n=vo()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function mo(e){return!e||!pr(e)?!1:e instanceof Re(e).ShadowRoot}function Yr(e){if(e&&pr(e)){let t=e.getRootNode();if(mo(t))return t;if(t instanceof Document)return t}return Sn(e)}function yo(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Au(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((s,o)=>{const a=r[o];if(ta(s)&&ta(a)&&(s.type!=="file"&&(s.value=a.value),s.type==="radio"&&s.name&&(s.name=`Cloned__${s.name}`)),na(s)&&na(a)&&a.width>0&&a.height>0){const c=s.getContext("2d");c?.drawImage(a,0,0)}}),n}function ta(e){return"value"in e}function na(e){return e.tagName==="CANVAS"}function sc(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(Ru(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return sc(i,{x:t-s,y:n-o})}}return r}function Ru(e){return e?.tagName==="IFRAME"}var ds=new WeakMap;function Lu(e){return e.closest(`
2
+ input:not([disabled]),
3
+ select:not([disabled]),
4
+ textarea:not([disabled]),
5
+ button:not([disabled]),
6
+ a[href],
7
+ [contenteditable]:not([contenteditable="false"])
8
+ `)}var oc=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:i}]=e;t.removeEventListener(n,r,i)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],i=[];for(const o of n)for(const a of r){const{type:c,listener:d,options:u}=a,l=[o,a];o.addEventListener(c,d,u),this.entries.add(l),i.push(l)}const s=this.entries;return function(){for(const a of i){const[c,{type:d,listener:u,options:l}]=a;c.removeEventListener(d,u,l),s.delete(a)}}}};function un(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function zu(e){const t=new Set;let n=un(e);for(;n;)t.add(n),n=un(n);return t}function Wu(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function ac(e,t){const n=()=>performance.now();let r,i;return function(...s){const o=this;i?(r?.(),r=Wu(()=>{e.apply(o,s),i=n()},t-(n()-i))):(e.apply(o,s),i=n())}}function Fu(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 Bu(e,t=e.getBoundingClientRect()){const{width:n,height:r}=rr(e,t);return n>0&&r>0}var Nu=rc?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},Wr,Gu=class extends Nu{constructor(e){super(t=>{if(!F(this,Wr)){je(this,Wr,!0);return}e(t,this)}),Ee(this,Wr,!1)}};Wr=new WeakMap;var ra=Array.from({length:100},(e,t)=>t/100),lc=75,Dt,Zr,pt,Et,Ln,ve,Yn,zn,Jr,cc,dc,uc=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,Ee(this,Jr),this.disconnect=()=>{var s,o,a;je(this,Yn,!0),(s=F(this,pt))==null||s.disconnect(),(o=F(this,Et))==null||o.disconnect(),F(this,Ln).disconnect(),(a=F(this,ve))==null||a.remove()},Ee(this,Dt,!0),Ee(this,Zr),Ee(this,pt),Ee(this,Et),Ee(this,Ln),Ee(this,ve),Ee(this,Yn,!1),Ee(this,zn,ac(()=>{var s,o,a;const{element:c}=this;if((s=F(this,Et))==null||s.disconnect(),F(this,Yn)||!F(this,Dt)||!c.isConnected)return;const d=(o=c.ownerDocument)!=null?o:document,{innerHeight:u,innerWidth:l}=(a=d.defaultView)!=null?a:window,f=c.getBoundingClientRect(),g=rr(c,f),{top:h,left:m,bottom:w,right:b}=g,v=-Math.floor(h),p=-Math.floor(m),x=-Math.floor(l-b),_=-Math.floor(u-w),$=`${v}px ${x}px ${_}px ${p}px`;this.boundingClientRect=f,je(this,Et,new IntersectionObserver(T=>{const[D]=T,{intersectionRect:I}=D;(D.intersectionRatio!==1?D.intersectionRatio:tt.intersectionRatio(I,rr(c)))!==1&&F(this,zn).call(this)},{threshold:ra,rootMargin:$,root:d})),F(this,Et).observe(c),ec(this,Jr,cc).call(this)},lc)),this.boundingClientRect=e.getBoundingClientRect(),je(this,Dt,Bu(e,this.boundingClientRect));let r=!0;this.callback=s=>{r&&(r=!1,n.skipInitial)||t(s)};const i=e.ownerDocument;n?.debug&&(je(this,ve,document.createElement("div")),F(this,ve).style.background="rgba(0,0,0,0.15)",F(this,ve).style.position="fixed",F(this,ve).style.pointerEvents="none",i.body.appendChild(F(this,ve))),je(this,Ln,new IntersectionObserver(s=>{var o,a;const c=s[s.length-1],{boundingClientRect:d,isIntersecting:u}=c,{width:l,height:f}=d,g=F(this,Dt);je(this,Dt,u),!(!l&&!f)&&(g&&!u?((o=F(this,Et))==null||o.disconnect(),this.callback(null),(a=F(this,pt))==null||a.disconnect(),je(this,pt,void 0),F(this,ve)&&(F(this,ve).style.visibility="hidden")):F(this,zn).call(this),u&&!F(this,pt)&&(je(this,pt,new Gu(F(this,zn))),F(this,pt).observe(e)))},{threshold:ra,root:i})),F(this,Dt)&&!n.skipInitial&&this.callback(this.boundingClientRect),F(this,Ln).observe(e)}};Dt=new WeakMap;Zr=new WeakMap;pt=new WeakMap;Et=new WeakMap;Ln=new WeakMap;ve=new WeakMap;Yn=new WeakMap;zn=new WeakMap;Jr=new WeakSet;cc=function(){F(this,Yn)||(ec(this,Jr,dc).call(this),!Fu(this.boundingClientRect,F(this,Zr))&&(this.callback(this.boundingClientRect),je(this,Zr,this.boundingClientRect)))};dc=function(){if(F(this,ve)){const{top:e,left:t,width:n,height:r}=rr(this.element);F(this,ve).style.overflow="hidden",F(this,ve).style.visibility="visible",F(this,ve).style.top=`${Math.floor(e)}px`,F(this,ve).style.left=`${Math.floor(t)}px`,F(this,ve).style.width=`${Math.floor(n)}px`,F(this,ve).style.height=`${Math.floor(r)}px`}};var wr=new WeakMap,kr=new WeakMap;function Vu(e,t){let n=wr.get(e);return n||(n={disconnect:new uc(e,i=>{const s=wr.get(e);s&&s.callbacks.forEach(o=>o(i))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),wr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(wr.delete(e),n.disconnect())}}function Hu(e,t){const n=new Set;for(const r of e){const i=Vu(r,t);n.add(i)}return()=>n.forEach(r=>r())}function Ku(e,t){var n;const r=e.ownerDocument;if(!kr.has(r)){const o=new AbortController,a=new Set;document.addEventListener("scroll",c=>a.forEach(d=>d(c)),{capture:!0,passive:!0,signal:o.signal}),kr.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:i,disconnect:s}=(n=kr.get(r))!=null?n:{};return!i||!s?()=>{}:(i.add(t),()=>{i.delete(t),i.size===0&&(s(),kr.delete(r))})}var Wn,Fn,Fr,us,qu=class{constructor(e,t,n){this.callback=t,Ee(this,Wn),Ee(this,Fn,!1),Ee(this,Fr),Ee(this,us,ac(o=>{if(!F(this,Fn)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of F(this,Fr))if(o.target.contains(a)){this.callback(F(this,Wn).boundingClientRect);break}}},lc));const r=zu(e),i=Hu(r,t),s=Ku(e,F(this,us));je(this,Fr,r),je(this,Wn,new uc(e,t,n)),this.disconnect=()=>{F(this,Fn)||(je(this,Fn,!0),i(),s(),F(this,Wn).disconnect())}}};Wn=new WeakMap;Fn=new WeakMap;Fr=new WeakMap;us=new WeakMap;function fs(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function on(e){try{fs(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function ia(e){return!rc||!e?!1:e===Sn(e).scrollingElement}function fc(e){var t,n;const r=Re(e),i=ia(e)?Cu(e):yi(e),s=r.visualViewport,o=ia(e)?{height:(t=s?.height)!=null?t:r.innerHeight,width:(n=s?.width)!=null?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-o.width,y:e.scrollHeight-o.height}},c=a.current.y<=0,d=a.current.x<=0,u=a.current.y>=a.max.y,l=a.current.x>=a.max.x;return{rect:i,position:a,isTop:c,isLeft:d,isBottom:u,isRight:l}}function Uu(e,t){const{isTop:n,isBottom:r,isLeft:i,isRight:s,position:o}=fc(e),{x:a,y:c}=t??{x:0,y:0},d=!n&&o.current.y+c>0,u=!r&&o.current.y+c<o.max.y,l=!i&&o.current.x+a>0,f=!s&&o.current.x+a<o.max.x;return{top:d,bottom:u,left:l,right:f,x:l||f,y:d||u}}var bo=class{constructor(t){this.scheduler=t,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:n,resolvers:r}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const i of n)i();for(const i of r)i()}}schedule(t){return this.tasks.add(t),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(n=>this.resolvers.add(n))}},Qr=new bo(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Xu=new bo(e=>setTimeout(e,50)),ei=new Map,Yu=ei.clear.bind(ei);function it(e,t=!1){if(!t)return sa(e);let n=ei.get(e);return n||(n=sa(e),ei.set(e,n),Xu.schedule(Yu),n)}function sa(e){return Re(e).getComputedStyle(e)}function Zu(e,t=it(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Ju(e,t=it(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const s=t[i];return typeof s=="string"?n.test(s):!1})}var Qu={excludeElement:!0,escapeShadowDOM:!0};function hs(e,t=Qu){const{limit:n,excludeElement:r,escapeShadowDOM:i}=t,s=new Set;function o(a){if(n!=null&&s.size>=n||!a)return s;if(go(a)&&a.scrollingElement!=null&&!s.has(a.scrollingElement))return s.add(a.scrollingElement),s;if(i&&mo(a))return o(a.host);if(!_t(a))return nc(a)?o(a.parentElement):s;if(s.has(a))return s;const c=it(a,!0);if(r&&a===e||Ju(a,c)&&s.add(a),Zu(a,c)){const{scrollingElement:d}=a.ownerDocument;return d&&s.add(d),s}return o(a.parentNode)}return e?o(e):s}function fn(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=un(e);for(;r;){if(r===t)return n;const i=yi(r),{x:s,y:o}=ef(r,i);n.x=n.x+i.left,n.y=n.y+i.top,n.scaleX=n.scaleX*s,n.scaleY=n.scaleY*o,r=un(r)}return n}function ef(e,t=yi(e)){const n=Math.round(t.width),r=Math.round(t.height);if(_t(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const i=it(e,!0);return{x:(parseFloat(i.width)||n)/n,y:(parseFloat(i.height)||r)/r}}function tf(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 ir(e){if(!e||e==="none")return null;const[t,n,r="0"]=e.split(" "),i={x:parseFloat(t),y:parseFloat(n),z:parseInt(r,10)};return isNaN(i.x)&&isNaN(i.y)?null:{x:isNaN(i.x)?0:i.x,y:isNaN(i.y)?0:i.y,z:isNaN(i.z)?0:i.z}}function bi(e){var t,n,r,i,s,o,a,c,d;const{scale:u,transform:l,translate:f}=e,g=tf(u),h=ir(f),m=nf(l);if(!m&&!g&&!h)return null;const w={x:(t=g?.x)!=null?t:1,y:(n=g?.y)!=null?n:1},b={x:(r=h?.x)!=null?r:0,y:(i=h?.y)!=null?i:0},v={x:(s=m?.x)!=null?s:0,y:(o=m?.y)!=null?o:0,scaleX:(a=m?.scaleX)!=null?a:1,scaleY:(c=m?.scaleY)!=null?c:1};return{x:b.x+v.x,y:b.y+v.y,z:(d=h?.z)!=null?d:0,scaleX:w.x*v.scaleX,scaleY:w.y*v.scaleY}}function nf(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 We=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(We||{}),rf={x:.2,y:.2},sf={x:10,y:10};function of(e,t,n,r=25,i=rf,s=sf){const{x:o,y:a}=t,{rect:c,isTop:d,isBottom:u,isLeft:l,isRight:f}=fc(e),g=fn(e),h=it(e,!0),m=bi(h),w=m!==null?m?.scaleX<0:!1,b=m!==null?m?.scaleY<0:!1,v=new tt(c.left*g.scaleX+g.x,c.top*g.scaleY+g.y,c.width*g.scaleX,c.height*g.scaleY),p={x:0,y:0},x={x:0,y:0},_={height:v.height*i.y,width:v.width*i.x};return _.height>0&&(!d||b&&!u)&&a<=v.top+_.height&&n?.y!==1&&o>=v.left-s.x&&o<=v.right+s.x?(p.y=b?1:-1,x.y=r*Math.abs((v.top+_.height-a)/_.height)):_.height>0&&(!u||b&&!d)&&a>=v.bottom-_.height&&n?.y!==-1&&o>=v.left-s.x&&o<=v.right+s.x&&(p.y=b?-1:1,x.y=r*Math.abs((v.bottom-_.height-a)/_.height)),_.width>0&&(!f||w&&!l)&&o>=v.right-_.width&&n?.x!==-1&&a>=v.top-s.y&&a<=v.bottom+s.y?(p.x=w?-1:1,x.x=r*Math.abs((v.right-_.width-o)/_.width)):_.width>0&&(!l||w&&!f)&&o<=v.left+_.width&&n?.x!==1&&a>=v.top-s.y&&a<=v.bottom+s.y&&(p.x=w?1:-1,x.x=r*Math.abs((v.left+_.width-o)/_.width)),{direction:p,speed:x}}function hc(e,{block:t="nearest",inline:n="nearest"}={}){if(!_t(e))return;const r=hs(e),i=[];for(const s of r){if(!_t(s))continue;const{top:o,left:a}=af(e,s);let c=o,d=a;for(const u of i)c-=u.scrollTop,d-=u.scrollLeft;if(t!=="none"){const u=c<s.scrollTop,l=c+e.offsetHeight>s.scrollTop+s.clientHeight;u!==l&&(t==="center"?s.scrollTop=c-s.clientHeight/2+e.offsetHeight/2:u?s.scrollTop=c:s.scrollTop=c+e.offsetHeight-s.clientHeight)}if(n!=="none"){const u=d<s.scrollLeft,l=d+e.offsetWidth>s.scrollLeft+s.clientWidth;u!==l&&(n==="center"?s.scrollLeft=d-s.clientWidth/2+e.offsetWidth/2:u?s.scrollLeft=d:s.scrollLeft=d+e.offsetWidth-s.clientWidth)}i.push(s)}}function oa(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const i=r.offsetParent;if(!_t(i))break;t+=i.clientTop,n+=i.clientLeft,r=i}return{top:t,left:n}}function af(e,t){const n=oa(e),r=oa(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function lf(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left+s+(1-r)*parseFloat(n),c=e.top+o+(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),d=r?e.width*r:e.width,u=i?e.height*i:e.height;return{width:d,height:u,top:c,right:a+d,bottom:c+u,left:a}}function cf(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left-s-(1-r)*parseFloat(n),c=e.top-o-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),d=r?e.width/r:e.width,u=i?e.height/i:e.height;return{width:d,height:u,top:c,right:a+d,bottom:c+u,left:a}}function pc({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function aa(e,t=it(e).translate,n=!0){if(n){const r=tc(e,i=>"translate"in i);if(r){const{translate:i=""}=r[0];if(typeof i=="string"){const s=ir(i);if(s)return s}}}if(t){const r=ir(t);if(r)return r}return{x:0,y:0,z:0}}var df=new bo(e=>setTimeout(e,0)),Zn=new Map,uf=Zn.clear.bind(Zn);function ff(e){const t=e.ownerDocument;let n=Zn.get(t);if(n)return n;n=t.getAnimations(),Zn.set(t,n),df.schedule(uf);const r=n.filter(i=>mi(i.effect)&&i.effect.target===e);return Zn.set(e,r),n}function hf(e,t){const n=ff(e).filter(r=>{var i,s;if(mi(r.effect)){const{target:o}=r.effect;if((s=o&&((i=t.isValidTarget)==null?void 0:i.call(t,o)))!=null?s:!0)return r.effect.getKeyframes().some(c=>{for(const d of t.properties)if(c[d])return!0})}}).map(r=>{const{effect:i,currentTime:s}=r,o=i?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof o=="number"&&typeof s=="number"&&s<o)return r.currentTime=o,()=>{r.currentTime=s}});if(n.length>0)return()=>n.forEach(r=>r?.())}var et=class extends tt{constructor(e,t={}){var n,r,i,s;const{frameTransform:o=fn(e),ignoreTransforms:a,getBoundingClientRect:c=yi}=t,d=hf(e,{properties:["transform","translate","scale","width","height"],isValidTarget:_=>(_!==e||vo())&&_.contains(e)}),u=c(e);let{top:l,left:f,width:g,height:h}=u,m;const w=it(e),b=bi(w),v={x:(n=b?.scaleX)!=null?n:1,y:(r=b?.scaleY)!=null?r:1},p=pf(e,w);d?.(),b&&(m=cf(u,b,w.transformOrigin),(a||p)&&(l=m.top,f=m.left,g=m.width,h=m.height));const x={width:(i=m?.width)!=null?i:g,height:(s=m?.height)!=null?s:h};if(p&&!a&&m){const _=lf(m,p,w.transformOrigin);l=_.top,f=_.left,g=_.width,h=_.height,v.x=p.scaleX,v.y=p.scaleY}o&&(a||(f*=o.scaleX,g*=o.scaleX,l*=o.scaleY,h*=o.scaleY),f+=o.x,l+=o.y),super(f,l,g,h),this.scale=v,this.intrinsicWidth=x.width,this.intrinsicHeight=x.height}};function pf(e,t){const n=e.getAnimations();if(!n.length)return null;let r,i,s,o=!1;for(const a of n){if(a.playState!=="running")continue;const c=mi(a.effect)?a.effect.getKeyframes():[],d=c[c.length-1];if(!d)continue;const{transform:u,translate:l,scale:f}=d;typeof u=="string"&&u&&(r=u,o=!0),typeof l=="string"&&l&&(i=l,o=!0),typeof f=="string"&&f&&(s=f,o=!0)}return o?bi({transform:r??t.transform,translate:i??t.translate,scale:s??t.scale}):null}function Jn(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 gf=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(Jn(n))for(const[r,i]of Object.entries(e)){const s=`${t}${r}`;this.initial.has(s)||this.initial.set(s,n.style.getPropertyValue(s)),n.style.setProperty(s,typeof i=="string"?i:`${i}px`)}}remove(e,t=""){const{element:n}=this;if(Jn(n))for(const r of e){const i=`${t}${r}`;n.style.removeProperty(i)}}reset(){const{element:e}=this;if(Jn(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function At(e){return e?e instanceof Re(e).Element||pr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function sr(e){if(!e)return!1;const{KeyboardEvent:t}=Re(e.target);return e instanceof t}function vf(e){if(!e)return!1;const{PointerEvent:t}=Re(e.target);return e instanceof t}function mf(e){if(!At(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||yf(e)}function yf(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var Ri={};function ps(e){const t=Ri[e]==null?0:Ri[e]+1;return Ri[e]=t,`${e}-${t}`}var xo=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const i=ze.distance(t.shape.center,n);return{id:r,value:1/i,type:kn.PointerIntersection,priority:wn.High}}return null},bf=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:i}=e,s=ze.distance(t.shape.center,i.current),a=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:a,type:kn.ShapeIntersection,priority:wn.Normal}}return null},gc=e=>{var t;return(t=xo(e))!=null?t:bf(e)},xf=e=>{const{dragOperation:t,droppable:n}=e,{shape:r,position:i}=t;if(!n.shape)return null;const s=r?tt.from(r.current.boundingRectangle).corners:void 0,a=tt.from(n.shape.boundingRectangle).corners.reduce((c,d,u)=>{var l;return c+ze.distance(ze.from(d),(l=s?.[u])!=null?l:i.current)},0)/4;return{id:n.id,value:1/a,type:kn.Collision,priority:wn.Normal}},_f=Object.create,_o=Object.defineProperty,wf=Object.defineProperties,kf=Object.getOwnPropertyDescriptor,Sf=Object.getOwnPropertyDescriptors,ti=Object.getOwnPropertySymbols,vc=Object.prototype.hasOwnProperty,mc=Object.prototype.propertyIsEnumerable,yc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),$n=e=>{throw TypeError(e)},gs=(e,t,n)=>t in e?_o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,or=(e,t)=>{for(var n in t||(t={}))vc.call(t,n)&&gs(e,n,t[n]);if(ti)for(var n of ti(t))mc.call(t,n)&&gs(e,n,t[n]);return e},wo=(e,t)=>wf(e,Sf(t)),la=(e,t)=>_o(e,"name",{value:t,configurable:!0}),bc=(e,t)=>{var n={};for(var r in e)vc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ti)for(var r of ti(e))t.indexOf(r)<0&&mc.call(e,r)&&(n[r]=e[r]);return n},On=e=>{var t;return[,,,_f((t=e?.[yc("metadata")])!=null?t:null)]},xc=["class","method","getter","setter","accessor","field","value","get","set"],Bn=e=>e!==void 0&&typeof e!="function"?$n("Function expected"):e,$f=(e,t,n,r,i)=>({kind:xc[e],name:t,metadata:r,addInitializer:s=>n._?$n("Already initialized"):i.push(Bn(s||null))}),Bt=(e,t)=>gs(t,yc("metadata"),e[3]),fe=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},Ne=(e,t,n,r,i,s)=>{var o,a,c,d,u,l=t&7,f=!!(t&8),g=!!(t&16),h=l>3?e.length+1:l?f?1:2:0,m=xc[l+5],w=l>3&&(e[h-1]=[]),b=e[h]||(e[h]=[]),v=l&&(!g&&!f&&(i=i.prototype),l<5&&(l>3||!g)&&kf(l<4?i:{get[n](){return Q(this,s)},set[n](x){return $e(this,s,x)}},n));l?g&&l<4&&la(s,(l>2?"set ":l>1?"get ":"")+n):la(i,n);for(var p=r.length-1;p>=0;p--)d=$f(l,n,c={},e[3],b),l&&(d.static=f,d.private=g,u=d.access={has:g?x=>Of(i,x):x=>n in x},l^3&&(u.get=g?x=>(l^1?Q:Rt)(x,i,l^4?s:v.get):x=>x[n]),l>2&&(u.set=g?(x,_)=>$e(x,i,_,l^4?s:v.set):(x,_)=>x[n]=_)),a=(0,r[p])(l?l<4?g?s:v[m]:l>4?void 0:{get:v.get,set:v.set}:i,d),c._=1,l^4||a===void 0?Bn(a)&&(l>4?w.unshift(a):l?g?s=a:v[m]=a:i=a):typeof a!="object"||a===null?$n("Object expected"):(Bn(o=a.get)&&(v.get=o),Bn(o=a.set)&&(v.set=o),Bn(o=a.init)&&w.unshift(o));return l||Bt(e,i),v&&_o(i,n,v),g?l^4?s:v:i},ko=(e,t,n)=>t.has(e)||$n("Cannot "+n),Of=(e,t)=>Object(t)!==t?$n('Cannot use the "in" operator on this value'):e.has(t),Q=(e,t,n)=>(ko(e,t,"read from private field"),n?n.call(e):t.get(e)),ce=(e,t,n)=>t.has(e)?$n("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),$e=(e,t,n,r)=>(ko(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Rt=(e,t,n)=>(ko(e,t,"access private method"),n),ca={role:"button",roleDescription:"draggable"},Tf="dnd-kit-description",Df="dnd-kit-announcement",Ef={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."},Pf={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 Mf(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function Cf(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function If(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 jf=["dragover","dragmove"],Af=class extends xe{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=Tf,announcement:i=Df}={},announcements:s=Pf,screenReaderInstructions:o=Ef,debounce:a=500}=t??{},c=n?`${r}-${n}`:ps(r),d=n?`${i}-${n}`:ps(i);let u,l,f,g;const h=(_=g)=>{!f||!_||f?.nodeValue!==_&&(f.nodeValue=_)},m=()=>Qr.schedule(h),w=Rf(m,a),b=Object.entries(s).map(([_,$])=>this.manager.monitor.addEventListener(_,(T,D)=>{const I=f;if(!I)return;const C=$?.(T,D);C&&I.nodeValue!==C&&(g=C,jf.includes(_)?w():(m(),w.cancel()))})),v=()=>{let _=[];u?.isConnected||(u=Cf(c,o.draggable),_.push(u)),l?.isConnected||(l=If(d),f=document.createTextNode(""),l.appendChild(f),_.push(l)),_.length>0&&document.body.append(..._)},p=new Set;function x(){for(const _ of p)_()}this.registerEffect(()=>{var _;p.clear();for(const $ of this.manager.registry.draggables.value){const T=(_=$.handle)!=null?_:$.element;if(T){(!u||!l)&&p.add(v),(!Mf(T)||vo())&&!T.hasAttribute("tabindex")&&p.add(()=>T.setAttribute("tabindex","0")),!T.hasAttribute("role")&&T.tagName.toLowerCase()!=="button"&&p.add(()=>T.setAttribute("role",ca.role)),T.hasAttribute("aria-roledescription")||p.add(()=>T.setAttribute("aria-roledescription",ca.roleDescription)),T.hasAttribute("aria-describedby")||p.add(()=>T.setAttribute("aria-describedby",c));for(const I of["aria-pressed","aria-grabbed"]){const C=String($.isDragging);T.getAttribute(I)!==C&&p.add(()=>T.setAttribute(I,C))}const D=String($.disabled);T.getAttribute("aria-disabled")!==D&&p.add(()=>T.setAttribute("aria-disabled",D))}}p.size>0&&Qr.schedule(x)}),this.destroy=()=>{super.destroy(),u?.remove(),l?.remove(),b.forEach(_=>_())}}};function Rf(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var ni=new Map,_c,wc,kc,Sc,vs,Qn,ct,So,hn,$c,Oc,Tc,Dc,wt=class extends(vs=hr,Sc=[G],kc=[le],wc=[le],_c=[le],vs){constructor(t,n){super(t,n),fe(ct,5,this),ce(this,hn),ce(this,Qn,new Set),ce(this,So,fe(ct,8,this,new Set)),fe(ct,11,this),this.registerEffect(Rt(this,hn,$c))}register(t){return Q(this,Qn).add(t),()=>{Q(this,Qn).delete(t)}}addRoot(t){return N(()=>{const n=new Set(this.additionalRoots);n.add(t),this.additionalRoots=n}),()=>{N(()=>{const n=new Set(this.additionalRoots);n.delete(t),this.additionalRoots=n})}}get sourceRoot(){var t;const{source:n}=this.manager.dragOperation;return Yr((t=n?.element)!=null?t:null)}get targetRoot(){var t;const{target:n}=this.manager.dragOperation;return Yr((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}};ct=On(vs);Qn=new WeakMap;So=new WeakMap;hn=new WeakSet;$c=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of Q(this,Qn))t.push(Rt(this,hn,Oc).call(this,n,r));return()=>{for(const n of t)n()}};Oc=function(e,t){let n=ni.get(e);n||(n=new Map,ni.set(e,n));let r=n.get(t);if(!r){const s=go(e)?Rt(this,hn,Tc).call(this,e,n,t):Rt(this,hn,Dc).call(this,e,n,t);if(!s)return()=>{};r=s,n.set(t,r)}r.refCount++;let i=!1;return()=>{i||(i=!0,r.refCount--,r.refCount===0&&r.cleanup())}};Tc=function(e,t,n){var r;const i=e.createElement("style"),{nonce:s}=(r=this.options)!=null?r:{};s&&i.setAttribute("nonce",s),i.textContent=n,e.head.prepend(i);const o=new MutationObserver(a=>{for(const c of a)for(const d of Array.from(c.removedNodes))if(d===i){e.head.prepend(i);return}});return o.observe(e.head,{childList:!0}),{refCount:0,cleanup:()=>{o.disconnect(),i.remove(),t.delete(n),t.size===0&&ni.delete(e)}}};Dc=function(e,t,n){"adoptedStyleSheets"in e&&Array.isArray(e.adoptedStyleSheets);const r=e.ownerDocument.defaultView,{CSSStyleSheet:i}=r??{};if(!i)return null;const s=new i;return s.replaceSync(n),e.adoptedStyleSheets.push(s),{refCount:0,cleanup:()=>{var o;if(mo(e)&&((o=e.host)!=null&&o.isConnected)){const a=e.adoptedStyleSheets.indexOf(s);a!==-1&&e.adoptedStyleSheets.splice(a,1)}t.delete(n),t.size===0&&ni.delete(e)}}};Ne(ct,4,"additionalRoots",Sc,wt,So);Ne(ct,2,"sourceRoot",kc,wt);Ne(ct,2,"targetRoot",wc,wt);Ne(ct,2,"roots",_c,wt);Bt(ct,wt);wt.configure=fr(wt);var xi=wt,Lf=class extends xe{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(xi),i=r?.register(`* { cursor: ${n} !important; }`);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}}},gr="data-dnd-",ms=`${gr}dropping`,ge="--dnd-",Qe=`${gr}dragging`,ri=`${gr}placeholder`,zf=[Qe,ri,"popover","aria-pressed","aria-grabbing"],Wf=["view-transition-name"],Ff=`
9
+ :is(:root,:host) [${Qe}] {
10
+ position: fixed !important;
11
+ pointer-events: none !important;
12
+ touch-action: none;
13
+ z-index: calc(infinity);
14
+ will-change: translate;
15
+ top: var(${ge}top, 0px) !important;
16
+ left: var(${ge}left, 0px) !important;
17
+ right: unset !important;
18
+ bottom: unset !important;
19
+ width: var(${ge}width, auto);
20
+ max-width: var(${ge}width, auto);
21
+ height: var(${ge}height, auto);
22
+ max-height: var(${ge}height, auto);
23
+ transform: var(${ge}transform, none) !important;
24
+ transition: var(${ge}transition) !important;
25
+ }
26
+
27
+ :is(:root,:host) [${ri}] {
28
+ transition: none;
29
+ }
30
+
31
+ :is(:root,:host) [${ri}='hidden'] {
32
+ visibility: hidden;
33
+ }
34
+
35
+ [${Qe}] * {
36
+ pointer-events: none !important;
37
+ }
38
+
39
+ [${Qe}]:not([${ms}]) {
40
+ translate: var(${ge}translate) !important;
41
+ }
42
+
43
+ [${Qe}][style*='${ge}scale'] {
44
+ scale: var(${ge}scale) !important;
45
+ transform-origin: var(${ge}transform-origin) !important;
46
+ }
47
+
48
+ @layer dnd-kit {
49
+ :where([${Qe}][popover]) {
50
+ overflow: visible;
51
+ background: unset;
52
+ border: unset;
53
+ margin: unset;
54
+ padding: unset;
55
+ color: inherit;
56
+
57
+ &:is(input, button) {
58
+ border: revert;
59
+ background: revert;
60
+ }
61
+ }
62
+ }
63
+ [${Qe}]::backdrop, [${gr}overlay]:not([${Qe}]) {
64
+ display: none;
65
+ visibility: hidden;
66
+ }
67
+ `.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Bf(e,t="hidden"){return N(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const i=Nf(n,r.registry.droppables),s=[],o=Au(n),{remove:a}=o;return Gf(i,o,s),Vf(o,t),o.remove=()=>{s.forEach(c=>c()),a.call(o)},o})}function Nf(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const i=`${gr}${ps("dom-id")}`;r.element.setAttribute(i,""),n.set(r,i)}return n}function Gf(e,t,n){for(const[r,i]of e){if(!r.element)continue;const s=`[${i}]`,o=t.matches(s)?t:t.querySelector(s);if(r.element.removeAttribute(i),!o)continue;const a=r.element;r.proxy=o,o.removeAttribute(i),ds.set(a,o),n.push(()=>{ds.delete(a),r.proxy=void 0})}}function Vf(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(ri,t)}function Ec(e,t){return e===t?!0:un(e)===un(t)}function da(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&At(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>on(t))}function ys(e){return e.tagName==="TR"}function Hf(e,t,n){const r=new MutationObserver(i=>{let s=!1;for(const o of i){if(o.target!==e){s=!0;continue}if(o.type!=="attributes")continue;const a=o.attributeName;if(a.startsWith("aria-")||zf.includes(a))continue;const c=e.getAttribute(a);if(a==="style"){if(Jn(e)&&Jn(t)){const d=e.style;for(const u of Array.from(t.style))d.getPropertyValue(u)===""&&t.style.removeProperty(u);for(const u of Array.from(d)){if(Wf.includes(u)||u.startsWith(ge))continue;const l=d.getPropertyValue(u);t.style.setProperty(u,l)}}}else c!==null?t.setAttribute(a,c):t.removeAttribute(a)}s&&n&&t.replaceChildren(...e.cloneNode(!0).childNodes)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function Kf(e,t,n){const r=new MutationObserver(i=>{for(const s of i)if(s.addedNodes.length!==0)for(const o of Array.from(s.addedNodes)){if(o.contains(e)&&e.nextElementSibling!==t){e.insertAdjacentElement("afterend",t),on(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),on(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement("afterend",t),on(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function qf(e){return new ResizeObserver(()=>{var t,n,r;const i=new et(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},o=(e.width-i.width)*s.x+e.delta.x,a=(e.height-i.height)*s.y+e.delta.y,c=ic();if(e.styles.set({width:i.width-e.widthOffset,height:i.height-e.heightOffset,top:e.top+a+c.y,left:e.left+o+c.x},ge),(n=e.getElementMutationObserver())==null||n.takeRecords(),ys(e.element)&&ys(e.placeholder)){const m=Array.from(e.element.cells),w=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(m.map(b=>b.style.width));for(const[b,v]of m.entries()){const p=w[b];v.style.width=`${p.getBoundingClientRect().width}px`}}const d=(r=e.getTranslate())!=null?r:{x:0,y:0},u=e.left+o+c.x+d.x,l=e.top+a+c.y+d.y,f=i.width-e.widthOffset,g=i.height-e.heightOffset,h=e.frameTransform;e.dragOperation.shape=new tt(u*h.scaleX+h.x,l*h.scaleY+h.y,f*h.scaleX,g*h.scaleY)})}var Uf=250,Xf="ease";function Yf(e){var t,n,r,i;const{animation:s}=e;if(typeof s=="function"){const v=s({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(v).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=Uf,easing:a=Xf}=s??{};on(e.feedbackElement);const[,c]=(t=tc(e.feedbackElement,v=>"translate"in v))!=null?t:[];c?.pause();const d=(n=e.placeholder)!=null?n:e.element,u={frameTransform:Ec(e.feedbackElement,d)?null:void 0},l=new et(e.feedbackElement,u),f=(r=ir(it(e.feedbackElement).translate))!=null?r:e.translate,g=new et(d,u),h=tt.delta(l,g,e.alignment),m={x:f.x-h.x,y:f.y-h.y},w=Math.round(l.intrinsicHeight)!==Math.round(g.intrinsicHeight)?{minHeight:[`${l.intrinsicHeight}px`,`${g.intrinsicHeight}px`],maxHeight:[`${l.intrinsicHeight}px`,`${g.intrinsicHeight}px`]}:{},b=Math.round(l.intrinsicWidth)!==Math.round(g.intrinsicWidth)?{minWidth:[`${l.intrinsicWidth}px`,`${g.intrinsicWidth}px`],maxWidth:[`${l.intrinsicWidth}px`,`${g.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},ge),e.feedbackElement.setAttribute(ms,""),(i=e.getElementMutationObserver())==null||i.takeRecords(),pc({element:e.feedbackElement,keyframes:wo(or(or({},w),b),{translate:[`${f.x}px ${f.y}px 0`,`${m.x}px ${m.y}px 0`]}),options:{duration:yo(Re(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(ms),c?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Pc,bs,ar,$o,Br,Mc,Cc,pn=class extends(bs=xe,Pc=[G],bs){constructor(t,n){super(t,n),ce(this,Br),ce(this,$o,fe(ar,8,this)),fe(ar,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(xi),i=r?.register(Ff);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}this.registerEffect(Rt(this,Br,Mc).bind(this,r)),this.registerEffect(Rt(this,Br,Cc))}};ar=On(bs);$o=new WeakMap;Br=new WeakSet;Mc=function(e){const{overlay:t}=this;if(!t||!e)return;const n=Yr(t);if(n)return e.addRoot(n)};Cc=function(){var e,t,n,r,i,s,o;const{state:a,manager:c,options:d}=this,{dragOperation:u}=c,{position:l,source:f,status:g}=u;if(g.idle){a.current={},a.initial={};return}if(!f)return;const{element:h}=f,m=f.pluginConfig(pn),w=(t=(e=m?.feedback)!=null?e:d?.feedback)!=null?t:"default",b=typeof w=="function"?w(f,c):w;if(!h||b==="none"||!g.initialized||g.initializing)return;const{initial:v}=a,p=(n=this.overlay)!=null?n:h,x=fn(p),_=fn(h),$=!Ec(h,p),T=new et(h,{frameTransform:$?_:null,ignoreTransforms:!$}),D={x:_.scaleX/x.scaleX,y:_.scaleY/x.scaleY};let{width:I,height:C,top:P,left:A}=T;$&&(I=I/D.x,C=C/D.y);const R=new gf(p),U=it(h),{transition:Te,translate:De,boxSizing:me,paddingBlockStart:X,paddingBlockEnd:Ye,paddingInlineStart:Ze,paddingInlineEnd:ye,borderInlineStartWidth:Me,borderInlineEndWidth:Ge,borderBlockStartWidth:Y,borderBlockEndWidth:ee}=U,H=Te.split(",").filter(Z=>!/^\s*(transform|translate|scale)\b/.test(Z)).join(","),he=bi(U),W=U.transform,K=b==="clone",_e=me==="content-box",ne=_e?parseInt(Ze)+parseInt(ye)+parseInt(Me)+parseInt(Ge):0,Ve=_e?parseInt(X)+parseInt(Ye)+parseInt(Y)+parseInt(ee):0,re=b!=="move"&&!this.overlay?Bf(f,K?"clone":"hidden"):null,ft=N(()=>sr(c.dragOperation.activatorEvent));if(!v.translate){if(this.overlay&&he)v.translate={x:he.x,y:he.y};else if(De!=="none"){const Z=ir(De);Z&&(v.translate=Z)}}if(!v.transformOrigin){const Z=N(()=>l.current),de=A+((r=he?.x)!=null?r:0),Ie=P+((i=he?.y)!=null?i:0);v.transformOrigin={x:(Z.x-de*x.scaleX-x.x)/(I*x.scaleX),y:(Z.y-Ie*x.scaleY-x.y)/(C*x.scaleY)}}const{transformOrigin:Je}=v,Nt=P*x.scaleY+x.y,M=A*x.scaleX+x.x;if(!v.coordinates&&(v.coordinates={x:M,y:Nt},D.x!==1||D.y!==1)){const{scaleX:Z,scaleY:de}=_,{x:Ie,y:ht}=Je;v.coordinates.x+=(I*Z-I)*Ie,v.coordinates.y+=(C*de-C)*ht}v.dimensions||(v.dimensions={width:I,height:C}),v.frameTransform||(v.frameTransform=x);const L={x:v.coordinates.x-M,y:v.coordinates.y-Nt},O={width:(v.dimensions.width*v.frameTransform.scaleX-I*x.scaleX)*Je.x,height:(v.dimensions.height*v.frameTransform.scaleY-C*x.scaleY)*Je.y},E={x:L.x/x.scaleX+O.width,y:L.y/x.scaleY+O.height},z={left:A+E.x,top:P+E.y};p.setAttribute(Qe,"true");const J=N(()=>u.transform),He=(s=v.translate)!=null?s:{x:0,y:0},we=J.x*x.scaleX+He.x,Ce=J.y*x.scaleY+He.y,st=ic();R.set({width:I-ne,height:C-Ve,top:z.top+st.y,left:z.left+st.x,translate:`${we}px ${Ce}px 0`,transform:this.overlay?"none":W,transition:H?`${H}, translate 0ms linear`:"translate 0ms linear",scale:$?`${D.x} ${D.y}`:"","transform-origin":`${Je.x*100}% ${Je.y*100}%`},ge),re&&(h.insertAdjacentElement("afterend",re),d?.rootElement&&(typeof d.rootElement=="function"?d.rootElement(f):d.rootElement).appendChild(h)),fs(p)&&(p.hasAttribute("popover")||p.setAttribute("popover","manual"),on(p),p.addEventListener("beforetoggle",da));let kt,$i,br;const zo=qf({placeholder:re,element:h,feedbackElement:p,frameTransform:x,transformOrigin:Je,width:I,height:C,top:P,left:A,widthOffset:ne,heightOffset:Ve,delta:E,styles:R,dragOperation:u,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>kt,getSavedCellWidths:()=>br,setSavedCellWidths:Z=>{br=Z}}),Wo=new et(p);N(()=>u.shape=Wo);const Oi=Re(p),Fo=Z=>{this.manager.actions.stop({event:Z})},Td=yo(Oi);ft&&Oi.addEventListener("resize",Fo),N(()=>f.status)==="idle"&&requestAnimationFrame(()=>f.status="dragging"),re&&(zo.observe(re),kt=Hf(h,re,K),$i=Kf(h,re,p));const Bo=(o=c.dragOperation.source)==null?void 0:o.id,Dd=()=>{var Z;if(!ft||Bo==null)return;const de=c.registry.draggables.get(Bo),Ie=(Z=de?.handle)!=null?Z:de?.element;_t(Ie)&&Ie.focus()},Ti=()=>{kt?.disconnect(),$i?.disconnect(),zo.disconnect(),Oi.removeEventListener("resize",Fo),fs(p)&&(p.removeEventListener("beforetoggle",da),p.removeAttribute("popover")),p.removeAttribute(Qe),R.reset();const Z=()=>{var de;if(br&&ys(h)){const Di=Array.from(h.cells);for(const[xr,Gt]of Di.entries())Gt.style.width=(de=br[xr])!=null?de:""}f.status="idle";const Ie=a.current.translate!=null,ht=u.status.dragging;re&&(!ht&&Ie||re.parentElement!==p.parentElement)&&p.isConnected&&re.replaceWith(p),re?.remove()};p===this.overlay?setTimeout(Z,0):Z()},Ed=d?.dropAnimation,No=this,Pd=dr(()=>{var Z,de,Ie;const{transform:ht,status:Di}=u;if(!(!ht.x&&!ht.y&&!a.current.translate)&&Di.dragging){const xr=(Z=v.translate)!=null?Z:{x:0,y:0},Gt={x:ht.x/x.scaleX+xr.x,y:ht.y/x.scaleY+xr.y},Go=a.current.translate,Md=N(()=>u.modifiers),Ei=N(()=>{var En;return(En=u.shape)==null?void 0:En.current}),Dn=d?.keyboardTransition,Vo=ft&&!Td&&Dn!==null?`${(de=Dn?.duration)!=null?de:250}ms ${(Ie=Dn?.easing)!=null?Ie:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(R.set({transition:H?`${H}, translate ${Vo}`:`translate ${Vo}`,translate:`${Gt.x}px ${Gt.y}px 0`},ge),kt?.takeRecords(),Ei&&Ei!==Wo&&Go&&!Md.length){const En=ze.delta(Gt,Go);u.shape=tt.from(Ei.boundingRectangle).translate(En.x*x.scaleX,En.y*x.scaleY)}else u.shape=new et(p);a.current.translate=Gt}},function(){if(u.status.dropped){this.dispose(),f.status="dropping";const Z=m?.dropAnimation!==void 0?m.dropAnimation:No.dropAnimation!==void 0?No.dropAnimation:Ed;let de=a.current.translate;const Ie=de!=null;if(!de&&h!==p&&(de={x:0,y:0}),!de||Z===null){Ti();return}c.renderer.rendering.then(()=>{Yf({source:f,element:h,feedbackElement:p,placeholder:re,translate:de,moved:Ie,transition:Te,alignment:f.alignment,styles:R,animation:Z??void 0,getElementMutationObserver:()=>kt,cleanup:Ti,restoreFocus:Dd})})}});return()=>{Ti(),Pd()}};Ne(ar,4,"overlay",Pc,pn,$o);Bt(ar,pn);pn.configure=fr(pn);var Oo=pn,Pn=!0,Zf=!1,Ic,jc,Ac,Rc,mt,To,Do;Rc=(Ac=[G],We.Forward),jc=(Ic=[G],We.Reverse);var lr=class{constructor(){ce(this,To,fe(mt,8,this,Pn)),fe(mt,11,this),ce(this,Do,fe(mt,12,this,Pn)),fe(mt,15,this)}isLocked(e){return e===We.Idle?!1:e==null?this[We.Forward]===Pn&&this[We.Reverse]===Pn:this[e]===Pn}unlock(e){e!==We.Idle&&(this[e]=Zf)}};mt=On(null);To=new WeakMap;Do=new WeakMap;Ne(mt,4,Rc,Ac,lr,To);Ne(mt,4,jc,Ic,lr,Do);Bt(mt,lr);var Jf=[We.Forward,We.Reverse],ua=class{constructor(){this.x=new lr,this.y=new lr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},Qf=class extends xe{constructor(e){super(e);const t=vn(new ua);let n=null;this.signal=t,Be(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new ua;return}const{delta:i}=e.dragOperation.position;if(n){const s={x:fa(i.x,n.x),y:fa(i.y,n.y)},o=t.peek();oe(()=>{for(const a of ul)for(const c of Jf)s[a]===c&&o[a].unlock(c);t.value=o})}n=i})}get current(){return this.signal.peek()}};function fa(e,t){return Math.sign(e-t)}var Lc,xs,cr,Eo,gt,_s,vr=class extends(xs=hr,Lc=[G],xs){constructor(e){super(e),ce(this,Eo,fe(cr,8,this,!1)),fe(cr,11,this),ce(this,gt),ce(this,_s,()=>{if(!Q(this,gt))return;const{element:s,by:o}=Q(this,gt);o.y&&(s.scrollTop+=o.y),o.x&&(s.scrollLeft+=o.x)}),this.scroll=(s,o)=>{var a;if(this.disabled)return!1;const c=this.getScrollableElements();if(!c)return $e(this,gt,void 0),!1;const{position:d}=this.manager.dragOperation,u=d?.current;if(u){const{by:l}=s??{},f=l?{x:ha(l.x),y:ha(l.y)}:void 0,g=f?void 0:this.scrollIntentTracker.current;if(g?.isLocked())return!1;for(const h of c){const m=Uu(h,l);if(m.x||m.y){const{speed:w,direction:b}=of(h,u,f,o?.acceleration,o?.threshold);if(g)for(const v of ul)g[v].isLocked(b[v])&&(w[v]=0,b[v]=0);if(b.x||b.y){const{x:v,y:p}=l??b,x=v*w.x,_=p*w.y;if(x||_){const $=(a=Q(this,gt))==null?void 0:a.by;if(this.autoScrolling&&$&&($.x&&!x||$.y&&!_))continue;return $e(this,gt,{element:h,by:{x,y:_}}),Qr.schedule(Q(this,_s)),!0}}}}}return $e(this,gt,void 0),!1};let t=null,n=null;const r=Yi(()=>{const{position:s,source:o}=e.dragOperation;if(!s)return null;const a=sc(Yr(o?.element),s.current);return a&&(t=a),a??t}),i=Yi(()=>{const s=r.value,{documentElement:o}=Sn(s);if(!s||s===o){const{target:a}=e.dragOperation,c=a?.element;if(c){const d=hs(c,{excludeElement:!1});return n=d,d}}if(s){const a=hs(s,{excludeElement:!1});return this.autoScrolling&&n&&a.size<n?.size?n:(n=a,a)}return n=null,null},Ke);this.getScrollableElements=()=>i.value,this.scrollIntentTracker=new Qf(e),this.destroy=e.monitor.addEventListener("dragmove",s=>{this.disabled||s.defaultPrevented||!sr(e.dragOperation.activatorEvent)||!s.by||this.scroll({by:s.by})&&s.preventDefault()})}};cr=On(xs);Eo=new WeakMap;gt=new WeakMap;_s=new WeakMap;Ne(cr,4,"autoScrolling",Lc,vr,Eo);Bt(cr,vr);function ha(e){return e>0?We.Forward:e<0?We.Reverse:We.Idle}var eh=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))}},th=new eh(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),nh=10,ws=class extends xe{constructor(t,n){super(t,n);const r=t.registry.plugins.get(vr);if(!r)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=Be(()=>{var i,s,o;if(this.disabled)return;const{position:a,status:c}=t.dragOperation;if(c.dragging){const d={acceleration:(i=this.options)==null?void 0:i.acceleration,threshold:typeof((s=this.options)==null?void 0:s.threshold)=="number"?{x:this.options.threshold,y:this.options.threshold}:(o=this.options)==null?void 0:o.threshold};if(r.scroll(void 0,d)){r.autoScrolling=!0;const l=setInterval(()=>th.schedule(()=>r.scroll(void 0,d)),nh);return()=>{clearInterval(l)}}else r.autoScrolling=!1}})}};ws.configure=fr(ws);var zc=ws,pa={capture:!0,passive:!0},Nn,rh=class extends hr{constructor(e){super(e),ce(this,Nn),this.handleScroll=()=>{Q(this,Nn)==null&&$e(this,Nn,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),$e(this,Nn,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=Be(()=>{var n,r,i;if(t.status.dragging){const o=(i=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?i:document;return o.addEventListener("scroll",this.handleScroll,pa),()=>{o.removeEventListener("scroll",this.handleScroll,pa)}}})}};Nn=new WeakMap;var ih="* { user-select: none !important; -webkit-user-select: none !important; }",sh=class extends xe{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(xi),n=t?.register(ih);if(this.destroy=Be(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return Li(),document.addEventListener("selectionchange",Li,{capture:!0}),()=>{document.removeEventListener("selectionchange",Li,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function Li(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var Gn=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}}),Qt,ii=class extends cn{constructor(t,n){super(t),this.manager=t,this.options=n,ce(this,Qt,[]),this.listeners=new oc,this.handleSourceKeyDown=(r,i,s)=>{if(this.disabled||r.defaultPrevented||!At(r.target)||i.disabled)return;const{keyboardCodes:o=Gn.keyboardCodes,preventActivation:a=Gn.preventActivation}=s??{};o.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(a?.(r,i)||this.handleStart(r,i,s))}}bind(t,n=this.options){return Be(()=>{var i;const s=(i=t.handle)!=null?i:t.element,o=a=>{sr(a)&&this.handleSourceKeyDown(a,t,n)};if(s)return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}})}handleStart(t,n,r){const{element:i}=n;if(!i)throw new Error("Source draggable does not have an associated element");t.preventDefault(),t.stopImmediatePropagation(),hc(i);const{center:s}=new et(i);if(this.manager.actions.start({event:t,coordinates:{x:s.x,y:s.y},source:n}).signal.aborted)return this.cleanup();this.sideEffects();const a=Sn(i),c=[this.listeners.bind(a,[{type:"keydown",listener:d=>this.handleKeyDown(d,n,r),options:{capture:!0}}])];Q(this,Qt).push(...c)}handleKeyDown(t,n,r){const{keyboardCodes:i=Gn.keyboardCodes}=r??{};if(Vt(t,[...i.end,...i.cancel])){t.preventDefault();const s=Vt(t,i.cancel);this.handleEnd(t,s);return}Vt(t,i.up)?this.handleMove("up",t):Vt(t,i.down)&&this.handleMove("down",t),Vt(t,i.left)?this.handleMove("left",t):Vt(t,i.right)&&this.handleMove("right",t)}handleEnd(t,n){this.manager.actions.stop({event:t,canceled:n}),this.cleanup()}handleMove(t,n){var r,i;const{shape:s}=this.manager.dragOperation,o=n.shiftKey?5:1;let a={x:0,y:0},c=(i=(r=this.options)==null?void 0:r.offset)!=null?i:Gn.offset;if(typeof c=="number"&&(c={x:c,y:c}),!!s){switch(t){case"up":a={x:0,y:-c.y*o};break;case"down":a={x:0,y:c.y*o};break;case"left":a={x:-c.x*o,y:0};break;case"right":a={x:c.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(zc);t?.disabled===!1&&(t.disable(),Q(this,Qt).push(()=>{t.enable()}))}cleanup(){Q(this,Qt).forEach(t=>t()),$e(this,Qt,[])}destroy(){this.cleanup(),this.listeners.clear()}};Qt=new WeakMap;ii.configure=fr(ii);ii.defaults=Gn;var Wc=ii;function Vt(e,t){return t.includes(e.code)}var Pt,oh=class extends Gl{constructor(){super(...arguments),ce(this,Pt)}onEvent(e){switch(e.type){case"pointerdown":$e(this,Pt,dn(e));break;case"pointermove":if(!Q(this,Pt))return;const{x:t,y:n}=dn(e),r={x:t-Q(this,Pt).x,y:n-Q(this,Pt).y},{tolerance:i}=this.options;if(i&&ss(r,i)){this.abort();return}ss(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){$e(this,Pt,void 0)}};Pt=new WeakMap;var en,Mt,ah=class extends Gl{constructor(){super(...arguments),ce(this,en),ce(this,Mt)}onEvent(e){switch(e.type){case"pointerdown":$e(this,Mt,dn(e)),$e(this,en,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!Q(this,Mt))return;const{x:t,y:n}=dn(e),r={x:t-Q(this,Mt).x,y:n-Q(this,Mt).y};ss(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){Q(this,en)&&(clearTimeout(Q(this,en)),$e(this,Mt,void 0),$e(this,en,void 0))}};en=new WeakMap;Mt=new WeakMap;var sn=class{};sn.Delay=ah;sn.Distance=oh;var ks=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:i}=e;if(!(r==="mouse"&&At(i)&&(t.handle===i||(n=t.handle)!=null&&n.contains(i))))return r==="touch"?[new sn.Delay({value:250,tolerance:5})]:mf(i)&&!e.defaultPrevented?[new sn.Delay({value:200,tolerance:0})]:[new sn.Delay({value:200,tolerance:10}),new sn.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;if(r===t.element||r===t.handle||!At(r)||(n=t.handle)!=null&&n.contains(r))return!1;const i=Lu(r);return i===t.element?!1:!!i}}),tn,si=class extends cn{constructor(t,n){super(t),this.manager=t,this.options=n,ce(this,tn,new Set),this.listeners=new oc,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:r,coordinates:i}=this.latest;!r||!i||this.manager.actions.move({event:r,to:i})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(t,n,r=this.options){const{activationConstraints:i=ks.activationConstraints}=r??{};return typeof i=="function"?i(t,n):i}bind(t,n=this.options){return Be(()=>{var i;const s=new AbortController,{signal:o}=s,a=d=>{vf(d)&&this.handlePointerDown(d,t,n)};let c=[(i=t.handle)!=null?i:t.element];n?.activatorElements&&(Array.isArray(n.activatorElements)?c=n.activatorElements:c=n.activatorElements(t));for(const d of c)d&&(dh(d.ownerDocument.defaultView),d.addEventListener("pointerdown",a,{signal:o}));return()=>s.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!At(t.target)||n.disabled||lh(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:i=ks.preventActivation}=r??{};if(i?.(t,n))return;const{target:s}=t,o=_t(s)&&s.draggable&&s.getAttribute("draggable")==="true",a=fn(n.element),{x:c,y:d}=dn(t);this.initialCoordinates={x:c*a.scaleX+a.x,y:d*a.scaleY+a.y};const u=this.activationConstraints(t,n,r);t.sensor=this;const l=new Du(u,m=>this.handleStart(n,m));l.signal.onabort=()=>this.handleCancel(t),l.onEvent(t),this.controller=l;const f=cs(),g=this.listeners.bind(f,[{type:"pointermove",listener:m=>this.handlePointerMove(m,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:Sr,options:{capture:!0}}]),h=()=>{g(),this.initialCoordinates=void 0};Q(this,tn).add(h)}handlePointerMove(t,n){var r,i;if(((r=this.controller)==null?void 0:r.activated)===!1){(i=this.controller)==null||i.onEvent(t);return}if(this.manager.dragOperation.status.dragging){const s=dn(t),o=fn(n.element);s.x=s.x*o.scaleX+o.x,s.y=s.y*o.scaleY+o.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=s,Qr.schedule(this.handleMove)}}handlePointerUp(t){const{status:n}=this.manager.dragOperation;if(!n.idle){t.preventDefault(),t.stopPropagation();const r=!n.initialized;this.manager.actions.stop({event:t,canceled:r})}this.cleanup()}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel(t))}handleStart(t,n){const{manager:r,initialCoordinates:i}=this;if(!i||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:i,event:n,source:t}).signal.aborted)return this.cleanup();n.preventDefault();const a=Sn(n.target).body;try{a.setPointerCapture(n.pointerId)}catch{this.handleCancel(n);return}const c=At(n.target)?[n.target,a]:a,d=this.listeners.bind(c,[{type:"touchmove",listener:Sr,options:{passive:!1}},{type:"click",listener:Sr},{type:"contextmenu",listener:Sr},{type:"keydown",listener:this.handleKeyDown}]);Q(this,tn).add(d)}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},Q(this,tn).forEach(n=>n()),Q(this,tn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};tn=new WeakMap;si.configure=fr(si);si.defaults=ks;var Ss=si;function lh(e){return"sensor"in e}function Sr(e){e.preventDefault()}function ch(){}var ga=new WeakSet;function dh(e){!e||ga.has(e)||(e.addEventListener("touchmove",ch,{capture:!1,passive:!1}),ga.add(e))}var an={modifiers:[],plugins:[Af,zc,Lf,Oo,sh],sensors:[Ss,Wc]},Fc=class extends Mu{constructor(e={}){const t=Ue(e.plugins,an.plugins),n=Ue(e.sensors,an.sensors),r=Ue(e.modifiers,an.modifiers);super(wo(or({},e),{plugins:[rh,vr,xi,...t],sensors:n,modifiers:r}))}},Bc,Nc,$s,yt,Po,Mo,_i=class extends($s=nt,Nc=[G],Bc=[G],$s){constructor(e,t){var n=e,{element:r,effects:i=()=>[],handle:s}=n,o=bc(n,["element","effects","handle"]);super(or({effects:()=>[...i(),()=>{var a,c;const{manager:d}=this;if(!d)return;const l=((c=(a=this.sensors)==null?void 0:a.map(tr))!=null?c:[...d.sensors]).map(f=>{const g=f instanceof cn?f:d.registry.register(f.plugin),h=f instanceof cn?void 0:f.options;return g.bind(this,h)});return function(){l.forEach(g=>g())}}]},o),t),ce(this,Po,fe(yt,8,this)),fe(yt,11,this),ce(this,Mo,fe(yt,12,this)),fe(yt,15,this),this.element=r,this.handle=s}};yt=On($s);Po=new WeakMap;Mo=new WeakMap;Ne(yt,4,"handle",Nc,_i,Po);Ne(yt,4,"element",Bc,_i,Mo);Bt(yt,_i);var Gc,Vc,Os,bt,Co,zi,Hc,Kc,er,Io,wi=class extends(Os=rt,Vc=[G],Gc=[G],Os){constructor(e,t){var n=e,{element:r,effects:i=()=>[]}=n,s=bc(n,["element","effects"]);const{collisionDetector:o=gc}=s,a=d=>{const{manager:u,element:l}=this;if(!l||d===null){this.shape=void 0;return}if(!u)return;const f=new et(l),g=N(()=>this.shape);return f&&g?.equals(f)?g:(this.shape=f,f)},c=vn(!1);super(wo(or({},s),{collisionDetector:o,effects:()=>[...i(),()=>{const{element:d,manager:u}=this;if(!u)return;const{dragOperation:l}=u,{source:f}=l;c.value=!!(f&&l.status.initialized&&d&&!this.disabled&&this.accepts(f))},()=>{const{element:d}=this;if(c.value&&d){const u=new qu(d,a);return()=>{u.disconnect(),this.shape=void 0}}},()=>{var d;if((d=this.manager)!=null&&d.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),ce(this,er),ce(this,Co,fe(bt,8,this)),fe(bt,11,this),ce(this,Io,fe(bt,12,this)),fe(bt,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){$e(this,er,e,Kc)}get element(){var e;return(e=this.proxy)!=null?e:Q(this,er,Hc)}};bt=On(Os);Co=new WeakMap;er=new WeakSet;Io=new WeakMap;zi=Ne(bt,20,"#element",Vc,er,Co),Hc=zi.get,Kc=zi.set;Ne(bt,4,"proxy",Gc,wi,Io);Bt(bt,wi);function uh(e){return e!=null&&typeof e=="object"&&"current"in e}function ln(e){var t;if(e!=null)return uh(e)?(t=e.current)!=null?t:void 0:e}var fh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Tn=fh?S.useLayoutEffect:S.useEffect;function hh(){const e=S.useState(0)[1];return S.useCallback(()=>{e(t=>t+1)},[e])}function qc(e,t){const n=S.useRef(new Map),r=hh();return Tn(()=>{if(!e){n.current.clear();return}return Be(()=>{var i;let s=!1,o=!1;for(const a of n.current){const[c]=a,d=N(()=>a[1]),u=e[c];d!==u&&(s=!0,n.current.set(c,u),o=(i=t?.(c,d,u))!=null?i:!1)}s&&(o?queueMicrotask(()=>zd.flushSync(r)):r())})},[e]),S.useMemo(()=>e&&new Proxy(e,{get(i,s){const o=i[s];return n.current.set(s,o),o}}),[e])}function ph(e,t){e()}function Ht(e){const t=S.useRef(e);return Tn(()=>{t.current=e},[e]),t}function ie(e,t,n=S.useEffect,r=Object.is){const i=S.useRef(e);n(()=>{const s=i.current;r(e,s)||(i.current=e,t(e,s))},[t,e])}function Nr(e,t){const n=S.useRef(ln(e));Tn(()=>{const r=ln(e);r!==n.current&&(n.current=r,t(r))})}var gh=Object.defineProperty,vh=Object.defineProperties,mh=Object.getOwnPropertyDescriptors,oi=Object.getOwnPropertySymbols,Uc=Object.prototype.hasOwnProperty,Xc=Object.prototype.propertyIsEnumerable,va=(e,t,n)=>t in e?gh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yh=(e,t)=>{for(var n in t||(t={}))Uc.call(t,n)&&va(e,n,t[n]);if(oi)for(var n of oi(t))Xc.call(t,n)&&va(e,n,t[n]);return e},bh=(e,t)=>vh(e,mh(t)),xh=(e,t)=>{var n={};for(var r in e)Uc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&oi)for(var r of oi(e))t.indexOf(r)<0&&Xc.call(e,r)&&(n[r]=e[r]);return n},_h=new Fc,Yc=S.createContext(_h),wh=S.memo(S.forwardRef(({children:e},t)=>{const[n,r]=S.useState(0),i=S.useRef(null),s=S.useRef(null),o=S.useMemo(()=>({renderer:{get rendering(){var a;return(a=i.current)!=null?a:Promise.resolve()}},trackRendering(a){i.current||(i.current=new Promise(c=>{s.current=c})),S.startTransition(()=>{a(),r(c=>c+1)})}}),[]);return Tn(()=>{var a;(a=s.current)==null||a.call(s),i.current=null},[e,n]),S.useImperativeHandle(t,()=>o),null})),Wi=[void 0,Ke];function kh(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:i,onDragStart:s,onDragMove:o,onDragOver:a,onDragEnd:c}=t,d=xh(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const u=S.useRef(null),{plugins:l,modifiers:f,sensors:g}=d,h=Ue(l,an.plugins),m=Ue(g,an.sensors),w=Ue(f,an.modifiers),b=Ht(i),v=Ht(s),p=Ht(a),x=Ht(o),_=Ht(c),$=Ht(r),T=Sh(()=>{var D;return(D=d.manager)!=null?D:new Fc(d)});return S.useEffect(()=>{if(!u.current)throw new Error("Renderer not found");const{renderer:D,trackRendering:I}=u.current,{monitor:C}=T;T.renderer=D;const P=[C.addEventListener("beforedragstart",A=>{const R=b.current;R&&I(()=>R(A,T))}),C.addEventListener("dragstart",A=>{var R;return(R=v.current)==null?void 0:R.call(v,A,T)}),C.addEventListener("dragover",A=>{const R=p.current;R&&I(()=>R(A,T))}),C.addEventListener("dragmove",A=>{const R=x.current;R&&I(()=>R(A,T))}),C.addEventListener("dragend",A=>{const R=_.current;R&&I(()=>R(A,T))}),C.addEventListener("collision",A=>{var R;return(R=$.current)==null?void 0:R.call($,A,T)})];return()=>P.forEach(A=>A())},[T]),ie(h,()=>T&&(T.plugins=h),...Wi),ie(m,()=>T&&(T.sensors=m),...Wi),ie(w,()=>T&&(T.modifiers=w),...Wi),y.jsxs(Yc.Provider,{value:T,children:[y.jsx(wh,{ref:u,children:n}),n]})}function Sh(e){const t=S.useRef(null);return t.current||(t.current=e()),S.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}function $h(){return S.useContext(Yc)}function Zc(e){var t;const n=(t=$h())!=null?t:void 0,[r]=S.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Tn(r.register,[n,r]),r}var Oh=Object.create,Jc=Object.defineProperty,Th=Object.getOwnPropertyDescriptor,Qc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ki=e=>{throw TypeError(e)},Dh=(e,t,n)=>t in e?Jc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Eh=e=>{var t;return[,,,Oh((t=e?.[Qc("metadata")])!=null?t:null)]},ed=["class","method","getter","setter","accessor","field","value","get","set"],td=e=>e!==void 0&&typeof e!="function"?ki("Function expected"):e,Ph=(e,t,n,r,i)=>({kind:ed[e],name:t,metadata:r,addInitializer:s=>n._?ki("Already initialized"):i.push(td(s||null))}),Mh=(e,t)=>Dh(t,Qc("metadata"),e[3]),Ch=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)s[i].call(n);return r},nd=(e,t,n,r,i,s)=>{for(var o,a,c,d,u=t&7,l=!1,f=!1,g=2,h=ed[u+5],m=e[g]||(e[g]=[]),w=(i=i.prototype,Th(i,n)),b=r.length-1;b>=0;b--)c=Ph(u,n,a={},e[3],m),c.static=l,c.private=f,d=c.access={has:v=>n in v},d.get=v=>v[n],o=(0,r[b])(w[h],c),a._=1,td(o)&&(w[h]=o);return w&&Jc(i,n,w),i},rd=(e,t,n)=>t.has(e)||ki("Cannot "+n),Ih=(e,t,n)=>(rd(e,t,"read from private field"),t.get(e)),jh=(e,t,n)=>t.has(e)?ki("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ah=(e,t,n,r)=>(rd(e,t,"write to private field"),t.set(e,n),n),It=class Ts{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Ts(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 Ts(t,n)}},id,sd,Ds,Gr,mr,jo=class extends(Ds=Wt,sd=[le],id=[le],Ds){constructor(e){const t=It.from(e);super(t,(n,r)=>It.equals(n,r)),Ch(mr,5,this),jh(this,Gr,0),this.velocity={x:0,y:0}}get delta(){return It.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=It.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-Ih(this,Gr),o=a=>Math.round(a/s*100);oe(()=>{Ah(this,Gr,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(It.from(e)),this.velocity={x:0,y:0}}};mr=Eh(Ds);Gr=new WeakMap;nd(mr,2,"delta",sd,jo);nd(mr,2,"direction",id,jo);Mh(mr,jo);var od=(e=>(e.Horizontal="x",e.Vertical="y",e))(od||{});Object.values(od);var Rh=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const i=It.distance(t.shape.center,n);return{id:r,value:1/i,type:kn.PointerIntersection,priority:wn.High}}return null},Lh=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:i}=e,s=It.distance(t.shape.center,i.current),a=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:a,type:kn.ShapeIntersection,priority:wn.Normal}}return null},zh=e=>{var t;return(t=Rh(e))!=null?t:Lh(e)};function Wh(e){const{collisionDetector:t,data:n,disabled:r,element:i,id:s,accept:o,type:a}=e,c=Zc(u=>new wi(bh(yh({},e),{register:!1,element:ln(i)}),u)),d=qc(c);return ie(s,()=>c.id=s),Nr(i,u=>c.element=u),ie(o,()=>c.accept=o,void 0,Ke),ie(t,()=>c.collisionDetector=t??zh),ie(n,()=>n&&(c.data=n)),ie(r,()=>c.disabled=r===!0),ie(a,()=>c.type=a),{droppable:d,get isDropTarget(){return d.isDropTarget},ref:S.useCallback(u=>{var l,f;!u&&((l=c.element)!=null&&l.isConnected)&&!((f=c.manager)!=null&&f.dragOperation.status.idle)||(c.element=u??void 0)},[c])}}function Fh(e,t=[]){const n=new Map;for(const s of e.tiles)for(const o of s.filters??[])n.set(o.given,(n.get(o.given)??0)+1);const r=[],i=new Set;for(const s of e.localGivens??[])i.add(s.name),r.push({name:s.name,...s.label===void 0?{}:{label:s.label},type:s.type,...s.suggest?{field:s.suggest.dimension}:{},origin:"dashboard",local:s,boundTiles:n.get(s.name)??0});for(const s of t)i.has(s.name)||(i.add(s.name),r.push({...s,origin:"model",boundTiles:n.get(s.name)??0}));for(const[s,o]of n)i.has(s)||r.push({name:s,origin:"model",boundTiles:o});return r}function ai(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function Bh(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function Vr(e,t){const n=Bh(e),r=t?.replace(/_type$/,"");if(!n||!r)return!0;const i=new Set(["date","timestamp"]);return i.has(n)?i.has(r):n===r}function ma(e){switch(e?.replace(/_type$/,"")){case"string":return"text";case"number":return"a number";case"date":return"a date";case"timestamp":return"a timestamp";case"boolean":return"true or false";default:return e??"an unknown type"}}function Nh(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const Gh=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function Vh(e,t){const r=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",i=/^[A-Z_]/.test(r)?r:`F_${r}`,s=new Set(t);if(!s.has(i))return i;for(let o=2;;o++)if(!s.has(`${i}_${o}`))return`${i}_${o}`}const ya=[{kind:"select",label:"Pick one",hint:"A dropdown of the field's values"},{kind:"multiselect",label:"Pick several",hint:"The same, taking more than one"},{kind:"text",label:"Text",hint:"A box taking Malloy filter syntax"},{kind:"number",label:"Number range",hint:"A slider over the field's values"},{kind:"date",label:"Since a date",hint:"A date picker; tiles keep rows on or after it"}];function $r(e){const t=e.label.trim()||e.name,n=e.field.split(".").at(-1)??e.field;switch(e.kind){case"select":case"multiselect":return{name:e.name,type:"filter<string>",default:"f''",label:t,control:e.kind,...e.source?{suggest:{source:e.source,dimension:n}}:{}};case"text":return{name:e.name,type:"filter<string>",default:"f''",label:t};case"number":return{name:e.name,type:"filter<number>",default:"f''",label:t,...e.range?{rangeMin:e.range.min,rangeMax:e.range.max}:{}};case"date":return{name:e.name,type:"date",default:`@${e.dateDefault??new Date().toISOString().slice(0,10)}`,label:t}}}const Es=e=>e.declaration.kind==="reference";function Hh(e,t){return e.tiles.map(n=>{const r=(n.filters??[]).find(i=>i.given===t.name);return{include:r!==void 0,field:r?.field??t.field??t.name.toLowerCase(),...r?.op!==void 0?{op:r.op}:ai(t.type)!==void 0?{op:ai(t.type)}:{}}})}function Kh(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!Es(s))return;const o=(s.filters??[]).filter(c=>c.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?s.filters=a:delete s.filters})}function qh(e,t){const n=(e.localGivens??[]).filter(s=>s.name!==t.name),r=(e.localGivens??[]).findIndex(s=>s.name===t.name),i=[...n];i.splice(r>=0?r:i.length,0,t),e.localGivens=i}function Uh(e,t){for(const r of e.tiles){const i=(r.filters??[]).filter(s=>s.given!==t);i.length>0?r.filters=i:delete r.filters}const n=(e.localGivens??[]).filter(r=>r.name!==t);n.length>0?e.localGivens=n:delete e.localGivens}const Xh=j.createSvgIcon(y.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"})),Yh=j.createSvgIcon(y.jsx("path",{d:"m14.06 9.02.92.92L5.92 19H5v-.92zM17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29m-3.6 3.19L3 17.25V21h3.75L17.81 9.94z"})),Zh=j.createSvgIcon(y.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"})),Jh=j.createSvgIcon(y.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"})),Ps=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),Fi=Ps?"⌘":"Ctrl+",Qh=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"};function ep(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e}),S.useEffect(()=>{const n=r=>{const i=t.current,s=Ps?r.metaKey:r.ctrlKey,o=r.key.toLowerCase();if(r.key==="Escape"){i.escape();return}if(!Qh(r.target)){if(s&&o==="z"){r.preventDefault(),r.shiftKey?i.redo():i.undo();return}if(!Ps&&s&&o==="y"){r.preventDefault(),i.redo();return}if(s&&o==="s"){r.preventDefault(),i.save?.();return}!s&&!r.altKey&&!r.shiftKey&&(r.key==="ArrowLeft"||r.key==="ArrowRight")&&(r.preventDefault(),i.nudge(r.key==="ArrowRight"?1:-1))}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[])}function tp({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:i,saving:s,onSave:o,actions:a,onAddTile:c,onSettings:d}){const{theme:u}=Pe.usePublisherTheme();return y.jsxs(j.DashboardBar,{left:y.jsx(k.Chip,{size:"medium",variant:"outlined",icon:y.jsx(Yh,{sx:{fontSize:20}}),label:"Editing",sx:{height:37,fontSize:"0.875rem",fontWeight:500,border:u.border,color:u.tileTitle,"& .MuiChip-icon":{color:"inherit"},"& .MuiChip-label":{fontSize:"0.875rem"}}}),children:[c&&y.jsx(k.Button,{startIcon:y.jsx(j.AddIcon,{}),onClick:c,"aria-label":"Add tile",children:"Tile"}),y.jsx(k.Button,{startIcon:y.jsx(Xh,{}),onClick:l=>d(l.currentTarget),children:"Settings"}),y.jsx(k.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),y.jsx(k.Tooltip,{title:`Undo (${Fi}Z)`,children:y.jsx("span",{children:y.jsx(k.IconButton,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:y.jsx(Jh,{fontSize:"small"})})})}),y.jsx(k.Tooltip,{title:`Redo (${Fi}⇧Z)`,children:y.jsx("span",{children:y.jsx(k.IconButton,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:y.jsx(Zh,{fontSize:"small"})})})}),o&&y.jsx(y.Fragment,{children:y.jsx(k.Tooltip,{title:i?`Save (${Fi}S)`:"",children:y.jsx("span",{children:y.jsx(k.Button,{variant:i?"contained":"outlined",disabled:!i||s,onClick:o,startIcon:!i&&!s?y.jsx(j.CheckIcon,{}):void 0,sx:{minWidth:124},children:s?"Saving…":i?"Save changes":"Saved"})})})}),a&&y.jsxs(y.Fragment,{children:[y.jsx(k.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),a]})]})}const np=["bar_chart","line_chart","scatter_chart","shape_map","segment_map","big_value","sparkline"];function Or(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function ba(e){for(const t of e??[]){const n=/^#\s*([a-z_]+)/.exec(t.trim())?.[1];if(n&&np.includes(n))return n}}const rp=1;function ad(e,t,n){const r=[];for(const i of e??[]){const s=i.name,o=i.kind;if(typeof s=="string"){if(o==="dimension"||o==="measure"){const a=i.type?.kind;r.push({name:t+s,kind:o,...a?{type:a}:{}})}else if(o==="join"&&n>0){const a=i.schema?.fields;r.push(...ad(a,`${t}${s}.`,n-1))}}}return r}function ip(e){const t=new Map;for(const n of e.sourceInfos??[]){let r;try{r=typeof n=="string"?JSON.parse(n):n}catch{continue}const i=r;i?.name&&t.set(i.name,ad(i.schema?.fields,"",rp))}return t}function xa(e,t){return!e||t===void 0?void 0:e.sources.find(r=>r.name===t)?.fields.filter(r=>r.kind==="dimension")}const sp=e=>(e??"").startsWith("dashboards/"),op=e=>e.modelPath??e.path??"";function ld(e){const t=[],n=new Set;for(const r of e){const i=op(r);if(sp(i))continue;const s=ip(r);for(const o of r.sources??[]){const a=o.name;if(!a||n.has(a))continue;n.add(a);const c=(o.givens??[]).map(d=>d.name).filter(d=>typeof d=="string");t.push({name:a,modelPath:i,...Or(o.annotations)?{description:Or(o.annotations)}:{},views:(o.views??[]).filter(d=>typeof d.name=="string").map(d=>({name:d.name,...Or(d.annotations)?{description:Or(d.annotations)}:{},...ba(d.annotations)?{chart:ba(d.annotations)}:{}})),givens:c,fields:s.get(a)??[]})}}return{sources:t}}const ot=e=>`${e.source}.${e.name}`;function ap(e,t){if(!t)return[];const n=new Set;for(const r of e.sources)n.add(r.base);for(const r of e.imports)if(r.kind==="names")for(const i of r.names)n.add(i);return t.sources.filter(r=>n.has(r.name))}function lp({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s}){const{theme:o}=Pe.usePublisherTheme(),a=S.useMemo(()=>ap(t,n),[t,n]),[c,d]=S.useState(""),[u,l]=S.useState(""),[f,g]=S.useState(""),[h,m]=S.useState(Math.ceil(r/2));S.useEffect(()=>{e&&(d(t.sources[0]?.base??a[0]?.name??""),l(""),g(""),m(Math.ceil(r/2)))},[e,t,a,r]);const w=a.find(v=>v.name===c),b=c!==""&&u!=="";return y.jsx(j.AppDialog,{open:e,onClose:i,title:"Add a tile",description:"A tile shows one view of one source this dashboard imports.",actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:i,children:"Cancel"}),y.jsx(k.Button,{variant:"contained",disabled:!b,onClick:()=>s({base:c,view:u,...f.trim()?{label:f.trim()}:{},colspan:h}),children:"Add tile"})]}),children:y.jsx(k.Stack,{sx:{gap:2,pt:1},children:a.length===0?y.jsx(k.Typography,{variant:"body2",sx:{color:o.tileTitle},children:n?"This dashboard imports no source by name, so there is nothing to put a tile on. Import a source in the file first.":"The package's sources are still loading."}):y.jsxs(y.Fragment,{children:[y.jsx(k.TextField,{select:!0,size:"small",label:"Source",value:c,onChange:v=>{d(v.target.value),l("")},inputProps:{"aria-label":"Source"},children:a.map(v=>y.jsxs(k.MenuItem,{value:v.name,children:[v.name,v.description&&y.jsx(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:v.description})]},v.name))}),y.jsxs(k.Box,{children:[y.jsx(k.Typography,{variant:"subtitle2",sx:{mb:.5},children:"View"}),y.jsxs(k.List,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:280,overflowY:"auto",border:o.border,borderRadius:1},children:[(w?.views??[]).map(v=>y.jsxs(k.ListItemButton,{selected:u===v.name,onClick:()=>l(v.name),"aria-label":`View ${v.name}`,children:[y.jsx(k.ListItemText,{primary:v.name,secondary:v.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),v.chart&&y.jsx(k.Chip,{size:"small",variant:"outlined",label:v.chart.replace(/_chart$/,"")})]},v.name)),w&&w.views.length===0&&y.jsx(k.Typography,{variant:"body2",sx:{p:1.5,color:o.tileTitle},children:"This source declares no views."})]})]}),y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5},children:[y.jsx(k.TextField,{size:"small",label:"Title",placeholder:"Uses the view's name",value:f,onChange:v=>g(v.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}}),y.jsx(k.TextField,{size:"small",type:"number",label:`Width (of ${r})`,value:h,onChange:v=>m(Math.min(Math.max(Number(v.target.value)||1,1),r)),inputProps:{min:1,max:r,"aria-label":"Tile width"},sx:{width:140}})]})]})})})}const _a=4e3;function cp(e,t){const n=e.split(`
68
+ `),r=t.split(`
69
+ `);if(n.length>_a||r.length>_a)return[...n.map(c=>({kind:"del",text:c})),...r.map(c=>({kind:"add",text:c}))];const i=Array.from({length:n.length+1},()=>new Uint32Array(r.length+1));for(let c=n.length-1;c>=0;c--)for(let d=r.length-1;d>=0;d--)i[c][d]=n[c]===r[d]?i[c+1][d+1]+1:Math.max(i[c+1][d],i[c][d+1]);const s=[];let o=0,a=0;for(;o<n.length&&a<r.length;)n[o]===r[a]?(s.push({kind:"same",text:n[o]}),o++,a++):i[o+1][a]>=i[o][a+1]?s.push({kind:"del",text:n[o++]}):s.push({kind:"add",text:r[a++]});for(;o<n.length;)s.push({kind:"del",text:n[o++]});for(;a<r.length;)s.push({kind:"add",text:r[a++]});return s}function dp(e,t=3){const n=new Array(e.length).fill(!1);e.forEach((s,o)=>{if(s.kind!=="same")for(let a=Math.max(0,o-t);a<=Math.min(e.length-1,o+t);a++)n[a]=!0});const r=[];let i=0;return e.forEach((s,o)=>{n[o]?(i>0&&r.push({kind:"fold",count:i}),i=0,r.push(s)):i++}),i>0&&r.push({kind:"fold",count:i}),r}function up({open:e,before:t,after:n,onConfirm:r,onClose:i}){const{theme:s}=Pe.usePublisherTheme(),o=S.useMemo(()=>e?dp(cp(t,n)):[],[e,t,n]),a=o.filter(d=>d.kind==="add").length,c=o.filter(d=>d.kind==="del").length;return y.jsx(j.AppDialog,{open:e,onClose:i,maxWidth:"md",title:"Review the change to the file",description:y.jsxs(y.Fragment,{children:["A tile was added or removed, which moves declarations. Lines the builder does not own — comments, other Malloy — are left where they were; check they still read right."," ",y.jsxs(k.Box,{component:"span",sx:{fontVariantNumeric:"tabular-nums"},children:["+",a," −",c]})]}),actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:i,children:"Keep editing"}),y.jsx(k.Button,{variant:"contained",onClick:r,children:"Save this"})]}),children:y.jsx(k.Box,{component:"pre","aria-label":"File changes",sx:{m:0,px:2,py:1,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,lineHeight:1.6,overflowX:"auto",bgcolor:s.background,color:s.foreground},children:o.map((d,u)=>d.kind==="fold"?y.jsx(k.Box,{component:"span",sx:{display:"block",opacity:.55,py:.25},children:`⋯ ${d.count} unchanged line${d.count===1?"":"s"}`},u):y.jsxs(k.Box,{component:"span",sx:{display:"block",mx:-2,px:2,whiteSpace:"pre",bgcolor:d.kind==="add"?"rgba(46, 125, 91, 0.16)":d.kind==="del"?"rgba(168, 41, 31, 0.14)":"transparent",textDecoration:d.kind==="del"?"line-through":"none",opacity:d.kind==="del"?.8:1},children:[d.kind==="add"?"+ ":d.kind==="del"?"− ":" ",d.text]},u))})})}const Bi="self";function fp({open:e,document:t,source:n,givenNames:r,dashboards:i,onClose:s,onApply:o}){const{theme:a}=Pe.usePublisherTheme(),[c,d]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const h=(t.drills??[]).filter(m=>m.source===n.name);d((n.dimensions??[]).map(m=>{const w=h.find(b=>b.name===m.name);return{name:m.name,expression:m.expression,to:w?.to??[],given:w?.given??""}}))},[e,n,t]);const u=(h,m)=>d(w=>w.map((b,v)=>{if(v!==h)return b;const p={...b};return m(p),p})),l=[Bi,...i.filter(h=>h!==Bi)],f=h=>h===Bi?"This dashboard":h,g=()=>{n&&(o(c.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}:{}}))),s())};return y.jsx(j.AppDialog,{open:e,onClose:s,title:"Clickable cells",description:"A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the dashboard it opens.",actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:s,children:"Cancel"}),y.jsx(k.Button,{variant:"contained",onClick:g,disabled:c.length===0,children:"Apply"})]}),children:y.jsx(k.Stack,{sx:{gap:2,pt:1},children:c.length===0?y.jsx(k.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?y.jsxs(y.Fragment,{children:[y.jsx(k.Box,{component:"code",children:n.name})," declares no dimensions of its own in this file. A drill is a tag on the dimension's declaration, so a dimension the model declares is made clickable in the model; to make one clickable here, declare it in"," ",y.jsx(k.Box,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):c.map((h,m)=>y.jsxs(k.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[y.jsxs(k.Box,{sx:{minWidth:0,pt:.75},children:[y.jsx(k.Typography,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:h.name}),y.jsxs(k.Typography,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:h.expression,children:["is ",h.expression]})]}),y.jsx(k.TextField,{select:!0,size:"small",label:"Clicks go to",value:h.to,inputProps:{"aria-label":`Where ${h.name} goes`},SelectProps:{multiple:!0,renderValue:w=>w.length===0?"Not clickable":w.map(f).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:w=>u(m,b=>{const v=w.target.value;b.to=Array.isArray(v)?v:String(v).split(",").filter(Boolean)}),children:l.map(w=>y.jsxs(k.MenuItem,{value:w,children:[y.jsx(k.Checkbox,{size:"small",checked:h.to.includes(w),sx:{p:0,mr:1}}),y.jsx(k.ListItemText,{primary:f(w)})]},w))}),y.jsxs(k.TextField,{select:!0,size:"small",label:"Sets the control",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:w=>u(m,b=>{b.given=w.target.value}),children:[y.jsx(k.MenuItem,{value:"",children:y.jsx("em",{children:"Same name as the dimension"})}),r.map(w=>y.jsx(k.MenuItem,{value:w,children:w},w))]})]},h.name))})})}const cd=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function hp({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:s}){const o=S.useRef(n);e&&(o.current=n);const a=e?n:o.current,c=a!==void 0,[d,u]=S.useState({kind:"new"}),[l,f]=S.useState(""),[g,h]=S.useState("select"),[m,w]=S.useState(""),[b,v]=S.useState(""),[p,x]=S.useState([]),[_,$]=S.useState(!1),T=M=>t.sources.find(L=>L.name===M.source)?.base??M.source;S.useEffect(()=>{if(e)if(n){u({kind:"existing",name:n.name}),f(n.label??"");const M=Hh(t,n);x(M);const L=M.filter(E=>E.include),O=new Set(L.map(E=>E.field));v(O.size===1?L[0].field:n.field??""),$(O.size>1)}else u({kind:"new"}),f(""),h("select"),v(""),w(new Date().toISOString().slice(0,10)),x(t.tiles.map(M=>({include:Es(M),field:""}))),$(!1)},[e,n,t]);const D=S.useMemo(()=>[...(t.localGivens??[]).map(M=>M.name),...r.map(M=>M.name)],[t,r]),I=S.useMemo(()=>b.trim()?Vh(b.trim(),D):"",[b,D]),C=d.kind==="existing"?n??r.find(M=>M.name===d.name):I?{name:I,type:$r({name:I,label:l,kind:g,field:b}).type}:void 0,P=C?.type!==void 0&&!C.type.startsWith("filter<"),A=p.find(M=>M.include)?.op??ai(C?.type),R=(M,L)=>x(O=>O.map((E,z)=>z===M?{...E,...L}:E)),U=M=>x(L=>L.map(O=>({...O,op:M}))),Te=M=>{const L=ai(M);x(O=>O.map(({op:E,...z})=>L?{...z,op:L}:z))},De=M=>{u({kind:"existing",name:M.name}),v(M.field??""),Te(M.type)},me=M=>{h(M),Te($r({name:"X",label:l,kind:M,field:b}).type)},X=t.tiles.map(Es),Ye=X.filter(Boolean).length,Ze=p.filter((M,L)=>M.include&&X[L]).length,ye=t.tiles.filter((M,L)=>(p[L]?.include??!1)&&X[L]),Me=ye.length>0?ye:t.tiles.filter((M,L)=>X[L]),Ge=S.useMemo(()=>{const M=new Map;let L=!1;for(const O of Me){const E=i?.(O);if(E){L=!0;for(const z of E)M.has(z.name)||M.set(z.name,z)}}return L?[...M.values()]:void 0},[p,t.tiles,i]),Y=(()=>{const M=b.trim();for(const L of ye){const O=i?.(L);if(!O||O.some(E=>E.name===M))return T(L)}return ye[0]?T(ye[0]):t.sources[0]?.base})(),ee=M=>x(L=>L.map((O,E)=>({...O,include:M&&X[E]}))),H=S.useMemo(()=>_?p:p.map(M=>({...M,field:b})),[_,p,b]),he=M=>{for(const L of Me){const O=i?.(L)?.find(E=>E.name===M.trim());if(O?.type)return O.type}},W=M=>Vr(C?.type,M.type),K=(M,L)=>{if(M.trim()==="")return"Pick the field this filter compares.";const O=L?i?.(L):void 0;if(!O)return;const E=O.find(z=>z.name===M.trim());if(!E)return`Not a field of ${L?T(L):"the tiles' source"}.`;if(E.type&&!Vr(C?.type,E.type))return`${M.trim()} is ${ma(E.type)}; this filter compares ${ma(C?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},_e=M=>{if(v(M),c||d.kind!=="new")return;const L=he(M),O=$r({name:"X",label:l,kind:g,field:M}).type;L&&!Vr(O,L)&&me(Nh(L))},ne=H.map((M,L)=>M.include&&X[L]?K(M.field,t.tiles[L]):void 0),Ve=ne.every(M=>M===void 0),re=!_&&Ze>0?ye.map(M=>K(b,M)).find(Boolean):void 0,ft=C!==void 0&&Ve&&(d.kind==="existing"||b.trim()!==""&&I!==""),Je=()=>{if(!(!C||!ft))if(d.kind==="new")s(C.name,H,$r({name:C.name,label:l.trim()||cd(C.name),kind:g,field:b.trim(),...Y?{source:Y}:{},...m?{dateDefault:m}:{}}));else if(n?.origin==="dashboard"&&n.local){const M=l.trim(),L=M!==(n.local.label??"");s(C.name,H,L?{...n.local,...M?{label:M}:{}}:void 0)}else s(C.name,H)},Nt=c&&a.origin==="model";return{editing:c,shown:a,fromModel:Nt,source:d,setSource:u,label:l,setLabel:f,kind:g,dateDefault:m,setDateDefault:w,field:b,rows:p,setRows:x,perTile:_,setPerTile:$,newName:I,target:C,valueTyped:P,commonOp:A,setRow:R,setCommonOp:U,pickExisting:De,pickKind:me,bindable:X,bindableCount:Ye,included:Ze,commonFields:Ge,setAll:ee,accepts:W,pickField:_e,rowProblems:ne,commonProblem:re,canApply:ft,apply:Je}}function wa({value:e,onChange:t,fields:n,accepts:r,label:i,ariaLabel:s,error:o,helperText:a,disabled:c,autoFocus:d,placeholder:u,sx:l}){const f=S.useMemo(()=>(n??[]).filter(h=>r?.(h)??!0).map(h=>h.name),[n,r]),g=S.useMemo(()=>new Map((n??[]).map(h=>[h.name,h.type])),[n]);return y.jsx(k.Autocomplete,{freeSolo:!0,size:"small",options:f,inputValue:e,onInputChange:(h,m)=>t(m),value:e,onChange:(h,m)=>t(typeof m=="string"?m:""),disabled:c,disableClearable:!0,renderOption:(h,m)=>S.createElement("li",{...h,key:m},y.jsx(k.Typography,{variant:"body2",sx:{flex:1},children:m}),g.get(m)&&y.jsx(k.Typography,{variant:"caption",sx:{opacity:.6},children:g.get(m)?.replace(/_type$/,"")})),renderInput:h=>y.jsx(k.TextField,{...h,label:i,placeholder:u,autoFocus:d,error:o,helperText:a,inputProps:{...h.inputProps,"aria-label":s}}),sx:l})}function pp({open:e,document:t,control:n,available:r,fieldsFor:i,onClose:s,onApply:o,onRemove:a}){const{theme:c}=Pe.usePublisherTheme(),{editing:d,shown:u,fromModel:l,source:f,setSource:g,label:h,setLabel:m,kind:w,dateDefault:b,setDateDefault:v,field:p,rows:x,setRows:_,perTile:$,setPerTile:T,newName:D,target:I,valueTyped:C,commonOp:P,setRow:A,setCommonOp:R,pickExisting:U,pickKind:Te,bindable:De,bindableCount:me,included:X,commonFields:Ye,setAll:Ze,accepts:ye,pickField:Me,rowProblems:Ge,commonProblem:Y,canApply:ee,apply:H}=hp({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:o}),he=(W,K,_e)=>y.jsx(k.TextField,{select:!0,size:"small",label:"Compares",value:W??">=",onChange:ne=>K(ne.target.value),inputProps:{"aria-label":_e},sx:{width:130},children:Gh.filter(ne=>ne.op!=="~").map(ne=>y.jsx(k.MenuItem,{value:ne.op,children:ne.label},ne.op))});return y.jsx(j.AppDialog,{open:e,onClose:s,title:d?u.label??u.name:"Add a filter",description:d?y.jsxs(y.Fragment,{children:[y.jsxs(k.Box,{component:"span",sx:{fontFamily:"ui-monospace, monospace"},children:["$",u.name]}),l?" · declared in the model, so its label and options are set there":" · declared in this dashboard"]}):"A control on the page, and the tiles it filters.",actions:y.jsxs(y.Fragment,{children:[d&&y.jsx(k.Button,{color:"error",onClick:()=>a(u.name),"aria-label":`Remove control ${u.name}`,sx:{mr:"auto"},children:"Remove from dashboard"}),y.jsx(k.Button,{onClick:s,children:"Cancel"}),y.jsx(k.Tooltip,{title:ee||I===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:y.jsx("span",{children:y.jsx(k.Button,{variant:"contained",onClick:H,disabled:!ee,children:d?"Apply":"Add filter"})})})]}),children:y.jsxs(k.Stack,{sx:{gap:2.5,pt:1},children:[!d&&r.length>0&&y.jsxs(k.ToggleButtonGroup,{exclusive:!0,size:"small",value:f.kind,onChange:(W,K)=>{K==="new"?g({kind:"new"}):K==="existing"&&r[0]&&U(r[0])},"aria-label":"Where the filter comes from",children:[y.jsx(k.ToggleButton,{value:"new",children:"New in this dashboard"}),y.jsx(k.ToggleButton,{value:"existing",children:"From the model"})]}),!d&&f.kind==="existing"?y.jsx(k.TextField,{select:!0,size:"small",label:"Control",value:f.name,onChange:W=>{const K=r.find(_e=>_e.name===W.target.value);K&&U(K)},children:r.map(W=>y.jsxs(k.MenuItem,{value:W.name,children:[W.label??W.name,y.jsxs(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",W.name]})]},W.name))}):null,y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!$&&y.jsx(wa,{value:p,onChange:Me,fields:Ye,accepts:ye,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!d,error:Y!==void 0,helperText:Y??(!d&&D?`Declared as $${D}`:void 0),sx:{flex:1,minWidth:200}}),!l&&y.jsx(k.TextField,{size:"small",label:"Label",placeholder:D?cd(D):"",value:h,onChange:W=>m(W.target.value),inputProps:{"aria-label":"Control label"},sx:{flex:1,minWidth:160}}),C&&!$&&he(P,R,"Comparison")]}),!d&&f.kind==="new"&&y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5},children:[y.jsx(k.TextField,{select:!0,size:"small",label:"Control",value:w,onChange:W=>Te(W.target.value),inputProps:{"aria-label":"Kind of control"},slotProps:{select:{renderValue:W=>ya.find(K=>K.kind===W)?.label??String(W)}},sx:{flex:1},children:ya.map(W=>y.jsxs(k.MenuItem,{value:W.kind,children:[W.label,y.jsx(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:W.hint})]},W.kind))}),w==="date"&&y.jsx(k.TextField,{size:"small",type:"date",label:"Starts at",value:b,onChange:W=>v(W.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),y.jsxs(k.Box,{children:[y.jsxs(k.Stack,{direction:"row",sx:{alignItems:"center",gap:.5},children:[y.jsx(k.Checkbox,{size:"small",checked:me>0&&X===me,indeterminate:X>0&&X<me,disabled:me===0,onChange:W=>Ze(W.target.checked),inputProps:{"aria-label":"All tiles"}}),y.jsxs(k.Typography,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",X," of ",t.tiles.length," tiles"]}),y.jsx(k.Button,{size:"small",onClick:()=>{$||_(W=>W.map(K=>({...K,field:p}))),T(W=>!W)},children:$?"Same field for all":"Adjust per tile"})]}),y.jsx(k.Stack,{sx:{gap:$?1:0},children:t.tiles.map((W,K)=>{const _e=x[K],ne=W.label??W.name,Ve=$?Ge[K]:void 0;return y.jsxs(k.Stack,{direction:"row",sx:{gap:1,alignItems:$?"flex-start":"center",opacity:De[K]?1:.6},children:[y.jsx(k.Checkbox,{size:"small",disabled:!De[K],checked:(_e?.include??!1)&&De[K],inputProps:{"aria-label":`Filter ${ne}`},onChange:re=>A(K,{include:re.target.checked})}),y.jsx(k.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:$?1:0},noWrap:!0,children:ne}),De[K]?$&&y.jsxs(y.Fragment,{children:[C&&he(_e?.op,re=>A(K,{op:re}),`Comparison for ${ne}`),y.jsx(wa,{value:_e?.field??"",onChange:re=>A(K,{field:re}),fields:i?.(W),accepts:ye,label:"Field",ariaLabel:`Field for ${ne}`,disabled:!_e?.include,error:Ve!==void 0,helperText:Ve,sx:{width:220}})]}):y.jsx(k.Tooltip,{title:W.declaration.kind==="inherited"?"Declared on its source, which this dashboard does not write.":"Its query is written out here rather than named, so a filter cannot be added to it.",children:y.jsx(k.Typography,{variant:"caption",sx:{color:c.tileTitle},children:W.declaration.kind==="inherited"?"From the model":"Inline query"})})]},`${W.source}.${W.name}`)})}),X===0&&y.jsx(k.Typography,{variant:"caption",sx:{color:"warning.main",display:"block",mt:1},children:"No tile is ticked, so this control will not appear on the dashboard."})]})]})})}function dd(e,t,n,r){const[i,s]=S.useState(void 0);return S.useEffect(()=>{t&&e!==void 0&&s(structuredClone(e))},[t,e]),{draft:i,patch:d=>s(u=>{if(u===void 0)return u;const l=structuredClone(u);return d(l),l}),close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const gp=e=>({title:e.title,...e.description===void 0?{}:{description:e.description},...e.columns===void 0?{}:{columns:e.columns},...e.autorun===void 0?{}:{autorun:e.autorun}}),Ni=[2,3,4,6,8,12,16,24];function vp({anchor:e,settings:t,onClose:n,onCommit:r}){const{theme:i}=Pe.usePublisherTheme(),{draft:s,patch:o,close:a}=dd(t,e!==null,r,n),c=s?.columns!==void 0&&!Ni.includes(s.columns)?[...Ni,s.columns].sort((d,u)=>d-u):Ni;return y.jsx(k.Popover,{open:e!==null&&s!==void 0,anchorEl:e,onClose:a,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:380,p:2}}},children:s&&y.jsxs(k.Stack,{sx:{gap:1.5},children:[y.jsx(k.Typography,{variant:"overline",sx:{color:i.tileTitle,lineHeight:1.5},children:"Dashboard"}),y.jsx(k.TextField,{size:"small",label:"Title",value:s.title,autoFocus:!0,inputProps:{"aria-label":"Dashboard title"},onChange:d=>o(u=>{u.title=d.target.value})}),y.jsx(k.TextField,{size:"small",label:"Description",multiline:!0,minRows:3,maxRows:10,value:s.description??"",helperText:"Markdown. A blank line starts a new paragraph.",inputProps:{"aria-label":"Dashboard description"},onChange:d=>o(u=>{const l=d.target.value;l.trim()===""?delete u.description:u.description=l})}),y.jsxs(k.TextField,{select:!0,size:"small",label:"Grid width",value:s.columns??"",helperText:"Columns across the page. Tiles are placed in these.",inputProps:{"aria-label":"Grid width"},onChange:d=>o(u=>{const l=Number(d.target.value);l?u.columns=l:delete u.columns}),children:[y.jsx(k.MenuItem,{value:"",children:"Default (2)"}),c.map(d=>y.jsx(k.MenuItem,{value:d,children:d},d))]}),y.jsx(k.FormControlLabel,{control:y.jsx(k.Switch,{size:"small",checked:s.autorun!==!1,slotProps:{input:{"aria-label":"Run as controls change"}},onChange:d=>o(u=>{d.target.checked?delete u.autorun:u.autorun=!1})}),label:y.jsxs(k.Typography,{variant:"body2",children:["Run as controls change",y.jsx(k.Typography,{component:"span",variant:"caption",sx:{display:"block",opacity:.7},children:"Off, readers press Apply. For a page whose queries are slow."})]})})]})})}const mp=j.createSvgIcon(y.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function yp({controls:e,tileCount:t,unknownFieldsOf:n,onEdit:r,onAdd:i,children:s}){const{theme:o}=Pe.usePublisherTheme();return y.jsx(y.Fragment,{children:y.jsxs(k.Stack,{sx:{gap:1},children:[y.jsxs(k.Stack,{direction:"row","aria-label":"Filters",sx:{gap:1,alignItems:"center",flexWrap:"wrap",minHeight:32},children:[y.jsx(mp,{sx:{fontSize:18,color:o.tileTitle,opacity:.7}}),y.jsx(k.Typography,{variant:"subtitle2",sx:{color:o.tileTitle,mr:.5},children:"Filters"}),e.length===0&&y.jsx(k.Typography,{variant:"body2",sx:{color:o.tileTitle,opacity:.8},children:"None yet."}),e.map(a=>{const c=n(a.name,a.type);return y.jsx(k.Tooltip,{title:c.length>0?`$${a.name} · cannot filter on: ${c.join(", ")}`:`$${a.name} · ${a.origin==="dashboard"?"declared here":"from the model"} · ${a.boundTiles} of ${t} tiles`,children:y.jsx(k.Chip,{size:"small",label:a.label??a.name,"aria-label":`Edit filter ${a.name}`,color:c.length>0?"warning":"default",variant:a.origin==="dashboard"?"filled":"outlined",onClick:()=>r(a),sx:{opacity:a.boundTiles===0?.6:1,cursor:"pointer",transition:"opacity 120ms"}})},a.name)}),y.jsx(k.Box,{sx:{ml:"auto"},children:y.jsx(j.SecondaryButton,{label:"Filter",icon:y.jsx(j.AddIcon,{}),onClick:()=>i(),ariaLabel:"Add filter",ariaHasPopup:"dialog"})})]}),s]})})}const bp=(e,t)=>e.map((n,r)=>{const i=t[r]??!1;if(i===(n.break??!1))return n;const s={...n};return i?s.break=!0:delete s.break,s}),xp=(e,t,n)=>{const r=[...e],[i]=r.splice(t,1);if(!i)return[...e];const s=r[t];i.break&&s&&!s.break&&(r[t]={...s,break:!0});const o={...i};return delete o.break,r.splice(n,0,o),r},ud=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),fd=e=>`gap.${e}`,_p=(e,t)=>{const n=[];let r=0;e.forEach((s,o)=>{const a=Math.min(s.colspan??1,t),c=o===0||s.break===!0||r+a>t;c&&o>0&&r<t&&n.push({kind:"gap",after:ot(e[o-1]),colspan:t-r}),c&&(r=0),n.push(ud(s,o)),r+=a});const i=e.at(-1);return i&&r<t&&n.push({kind:"gap",after:ot(i),colspan:t-r}),n};var wp=Object.create,hd=Object.defineProperty,kp=Object.defineProperties,Sp=Object.getOwnPropertyDescriptor,$p=Object.getOwnPropertyDescriptors,li=Object.getOwnPropertySymbols,pd=Object.prototype.hasOwnProperty,gd=Object.prototype.propertyIsEnumerable,Op=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),yr=e=>{throw TypeError(e)},Ms=(e,t,n)=>t in e?hd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gi=(e,t)=>{for(var n in t||(t={}))pd.call(t,n)&&Ms(e,n,t[n]);if(li)for(var n of li(t))gd.call(t,n)&&Ms(e,n,t[n]);return e},Vi=(e,t)=>kp(e,$p(t)),Tp=(e,t)=>{var n={};for(var r in e)pd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&li)for(var r of li(e))t.indexOf(r)<0&&gd.call(e,r)&&(n[r]=e[r]);return n},Dp=e=>{var t;return[,,,wp((t=void 0)!=null?t:null)]},vd=["class","method","getter","setter","accessor","field","value","get","set"],Vn=e=>e!==void 0&&typeof e!="function"?yr("Function expected"):e,Ep=(e,t,n,r,i)=>({kind:vd[e],name:t,metadata:r,addInitializer:s=>n._?yr("Already initialized"):i.push(Vn(s||null))}),Pp=(e,t)=>Ms(t,Op("metadata"),e[3]),Tr=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},md=(e,t,n,r,i,s)=>{for(var o,a,c,d,u,l=t&7,f=!1,g=!1,h=e.length+1,m=vd[l+5],w=e[h-1]=[],b=e[h]||(e[h]=[]),v=(i=i.prototype,Sp({get[n](){return Hn(this,s)},set[n](x){return Ct(this,s,x)}},n)),p=r.length-1;p>=0;p--)d=Ep(l,n,c={},e[3],b),d.static=f,d.private=g,u=d.access={has:x=>n in x},u.get=x=>x[n],u.set=(x,_)=>x[n]=_,a=(0,r[p])({get:v.get,set:v.set},d),c._=1,a===void 0?Vn(a)&&(v[m]=a):typeof a!="object"||a===null?yr("Object expected"):(Vn(o=a.get)&&(v.get=o),Vn(o=a.set)&&(v.set=o),Vn(o=a.init)&&w.unshift(o));return v&&hd(i,n,v),i},yd=(e,t,n)=>t.has(e)||yr("Cannot "+n),Hn=(e,t,n)=>(yd(e,t,"read from private field"),t.get(e)),Mn=(e,t,n)=>t.has(e)?yr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ct=(e,t,n,r)=>(yd(e,t,"write to private field"),t.set(e,n),n);function jt(e){return e instanceof Lo||e instanceof wd}var Dr=10,Mp=class extends xe{constructor(e){super(e);const t=Be(()=>{const{dragOperation:r}=e;if(sr(r.activatorEvent)&&jt(r.source)&&r.status.initialized){const i=e.registry.plugins.get(vr);if(i)return i.disable(),()=>i.enable()}}),n=e.monitor.addEventListener("dragmove",(r,i)=>{queueMicrotask(()=>{if(this.disabled||r.defaultPrevented||!r.nativeEvent)return;const{dragOperation:s}=i;if(!sr(r.nativeEvent)||!jt(s.source)||!s.shape)return;const{actions:o,collisionObserver:a,registry:c}=i,{by:d}=r;if(!d)return;const u=Cp(d),{source:l,target:f}=s,{center:g}=s.shape.current,h=[],m=[];oe(()=>{for(const _ of c.droppables){const{id:$}=_;if(!_.accepts(l)||$===f?.id&&jt(_)||!_.element)continue;let T=_.shape;const D=new et(_.element,{getBoundingClientRect:I=>rr(I,void 0,.2)});!D.height||!D.width||(u=="down"&&g.y+Dr<D.center.y||u=="up"&&g.y-Dr>D.center.y||u=="left"&&g.x-Dr>D.center.x||u=="right"&&g.x+Dr<D.center.x)&&(h.push(_),_.shape=D,m.push(()=>_.shape=T))}}),r.preventDefault(),a.disable();const w=a.computeCollisions(h,xf);oe(()=>m.forEach(_=>_()));const[b]=w;if(!b)return;const{id:v}=b,{index:p,group:x}=l.sortable;o.setDropTarget(v).then(()=>{const{source:_,target:$,shape:T}=s;if(!_||!jt(_)||!T)return;const{index:D,group:I,target:C}=_.sortable,P=p!==D||x!==I,A=P?C:$?.element;if(!A)return;hc(A);const R=new et(A);if(!R)return;const U=tt.delta(R,tt.from(T.current.boundingRectangle),_.alignment);o.move({by:U}),P?o.setDropTarget(_.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function Cp(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 Ip=Object.defineProperty,jp=Object.defineProperties,Ap=Object.getOwnPropertyDescriptors,ka=Object.getOwnPropertySymbols,Rp=Object.prototype.hasOwnProperty,Lp=Object.prototype.propertyIsEnumerable,Sa=(e,t,n)=>t in e?Ip(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Kt=(e,t)=>{for(var n in t||(t={}))Rp.call(t,n)&&Sa(e,n,t[n]);if(ka)for(var n of ka(t))Lp.call(t,n)&&Sa(e,n,t[n]);return e},qt=(e,t)=>jp(e,Ap(t));function zp(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Er(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function Hi(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Wp(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const c=(p,x)=>p===x||p!==null&&typeof p=="object"&&"id"in p&&p.id===x;if(Array.isArray(e)){const p=e.findIndex(_=>c(_,s.id)),x=e.findIndex(_=>c(_,o.id));if(p===-1||x===-1){if(Hi(s)){const _=s.initialIndex,$=s.index;return _===$||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,$)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const _=s.index;if(_!==p)return n(e,p,_)}return n(e,p,x)}const d=Object.entries(e);let u=-1,l,f=-1,g;for(const[p,x]of d)if(u===-1&&(u=x.findIndex(_=>c(_,s.id)),u!==-1&&(l=p)),f===-1&&(f=x.findIndex(_=>c(_,o.id)),f!==-1&&(g=p)),u!==-1&&f!==-1)break;if(u===-1&&Hi(s)){const p=s.initialGroup==null?void 0:Er(e,s.initialGroup),x=s.initialIndex,_=s.group==null?void 0:Er(e,s.group),$=s.index;if(p==null||_==null||p===_&&x===$)return"preventDefault"in t&&t.preventDefault(),e;if(p===_)return qt(Kt({},e),{[p]:n(e[p],x,$)});const T=e[p][x];return qt(Kt({},e),{[p]:[...e[p].slice(0,x),...e[p].slice(x+1)],[_]:[...e[_].slice(0,$),T,...e[_].slice($)]})}if(!s.manager)return e;const{dragOperation:h}=s.manager,m=(i=(r=h.shape)==null?void 0:r.current.center)!=null?i:h.position.current;if(g==null){const p=Er(e,o.id);if(p!=null){const x=o.shape&&m.y>o.shape.center.y?e[p].length:0;g=p,f=x}}if(l==null||g==null||l===g&&u===f){if(l!=null&&l===g&&u===f&&Hi(s)){const p=s.group==null?void 0:Er(e,s.group),x=s.group!=null&&p!==l,_=s.index!==u;if(x||_){const $=s.group==null?l:p;if($!=null){if(l===$)return qt(Kt({},e),{[l]:n(e[l],u,s.index)});const T=e[l][u];return qt(Kt({},e),{[l]:[...e[l].slice(0,u),...e[l].slice(u+1)],[$]:[...e[$].slice(0,s.index),T,...e[$].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(l===g)return qt(Kt({},e),{[l]:n(e[l],u,f)});const b=o.shape&&Math.round(m.y)>Math.round(o.shape.center.y)?1:0,v=e[l][u];return qt(Kt({},e),{[l]:[...e[l].slice(0,u),...e[l].slice(u+1)],[g]:[...e[g].slice(0,f+b),v,...e[g].slice(f+b)]})}function Fp(e,t){return Wp(e,t,zp)}function $a(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function Oa(e,t,n){var r;for(const[i,s]of t)for(const o of s){const a=e.get(o.id);if(o.index!==a||o.group!==i||!((r=n.get(i))!=null&&r.has(o)))return!0}return!1}var Ta="__default__",Bp=class extends xe{constructor(e){super(e);const t=()=>{const r=new Map;for(const i of e.registry.droppables)if(i instanceof Lo){const{sortable:s}=i,{group:o}=s;let a=r.get(o);a||(a=new Set,r.set(o,a)),a.add(s)}return r},n=[e.monitor.addEventListener("dragover",(r,i)=>{if(this.disabled)return;const{dragOperation:s}=i,{source:o,target:a}=s;if(!jt(o)||!jt(a)||o.sortable===a.sortable)return;const c=t(),d=$a(c),u=o.sortable.group===a.sortable.group,l=c.get(o.sortable.group),f=u?l:c.get(a.sortable.group);!l||!f||queueMicrotask(()=>{r.defaultPrevented||i.renderer.rendering.then(()=>{var g,h;const m=t();if(Oa(d,c,m))return;const w=o.sortable.element,b=a.sortable.element;if(!b||!w||!u&&a.id===o.sortable.group)return;const v=Pr(l),p=u?v:Pr(f),x=(g=o.sortable.group)!=null?g:Ta,_=(h=a.sortable.group)!=null?h:Ta,$={[x]:v,[_]:p},T=Fp($,r);if($===T)return;const D=T[_].indexOf(o.sortable),I=T[_].indexOf(a.sortable);i.collisionObserver.disable(),Da(w,D,b,I),oe(()=>{for(const[C,P]of T[x].entries())P.index=C;if(!u)for(const[C,P]of T[_].entries())P.group=a.sortable.group,P.index=C}),i.actions.setDropTarget(o.id).then(()=>i.collisionObserver.enable())})})}),e.monitor.addEventListener("dragend",(r,i)=>{if(!r.canceled)return;const{dragOperation:s}=i,{source:o}=s;jt(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),c=$a(a),d=a.get(o.sortable.initialGroup);d&&i.renderer.rendering.then(()=>{const u=t();if(Oa(c,a,u))return;const l=Pr(d),f=Pr(d,Gp),g=o.sortable.element,h=f.indexOf(o.sortable),m=l[h],w=m?.element;!m||!w||!g||(Da(g,m.index,w,o.index),oe(()=>{for(const b of a.values()){const v=Array.from(b).values();for(const p of v)p.index=p.initialIndex,p.group=p.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function Da(e,t,n,r){const i=r<t?"afterend":"beforebegin";n.insertAdjacentElement(i,e)}function Np(e,t){return e.index-t.index}function Gp(e,t){return e.initialIndex-t.initialIndex}function Pr(e,t=Np){return Array.from(e).sort(t)}var Ea=[Mp,Bp],bd={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function Pa(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 Mr=new nu,xd,_d,xt,Ao,Kn,qn,Ro,nn;_d=[G],xd=[G];var Si=class{constructor(e,t){Mn(this,Ao,Tr(xt,8,this)),Tr(xt,11,this),Mn(this,Kn),Mn(this,qn),Mn(this,Ro,Tr(xt,12,this)),Tr(xt,15,this),Mn(this,nn),this.register=()=>(oe(()=>{var h,m;(h=this.manager)==null||h.registry.register(this.droppable),(m=this.manager)==null||m.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{oe(()=>{var h,m;(h=this.manager)==null||h.registry.unregister(this.droppable),(m=this.manager)==null||m.registry.unregister(this.draggable)})},this.destroy=()=>{oe(()=>{this.droppable.destroy(),this.draggable.destroy()})};var n=e,{effects:r=()=>[],disabled:i,group:s,index:o,sensors:a,type:c,transition:d=bd,plugins:u}=n,l=Tp(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const f=Ue(u,Ea),g=Pa(i);this.droppable=new Lo(Vi(Gi({},l),{disabled:g.droppable}),t,this),this.draggable=new wd(Vi(Gi({},l),{disabled:g.draggable,plugins:f,effects:()=>[()=>{var h,m,w;const b=(h=this.manager)==null?void 0:h.dragOperation.status;b?.initializing&&this.id===((w=(m=this.manager)==null?void 0:m.dragOperation.source)==null?void 0:w.id)&&Mr.clear(this.manager),b?.dragging&&Mr.set(this.manager,this.id,N(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:h,group:m,manager:w}=this,b=Hn(this,qn),v=Hn(this,Kn);(h!==b||m!==v)&&(Ct(this,qn,h),Ct(this,Kn,m),this.animate())},()=>{var h,m;const{target:w}=this,{isDragSource:b}=this.draggable;((m=(h=this.draggable.pluginConfig(Oo))==null?void 0:h.feedback)!=null?m:"default")==="move"&&b&&(this.droppable.disabled=!w)},...r()],type:c,sensors:a}),t,this),Ct(this,nn,l.element),this.manager=t,this.index=o,Ct(this,qn,o),this.group=s,Ct(this,Kn,s),this.type=c,this.transition=d}get initialIndex(){var e,t;return(t=(e=Mr.get(this.manager,this.id))==null?void 0:e.initialIndex)!=null?t:this.index}get initialGroup(){var e,t;return(t=(e=Mr.get(this.manager,this.id))==null?void 0:e.initialGroup)!=null?t:this.group}animate(){N(()=>{const{manager:e,transition:t}=this,{shape:n}=this.droppable;if(!e)return;const{idle:r}=e.dragOperation.status;!n||!t||r&&!t.idle||e.renderer.rendering.then(()=>{const{element:i}=this;if(!i)return;for(const u of i.getAnimations())"transitionProperty"in u&&(u.transitionProperty==="transform"||u.transitionProperty==="translate"||u.transitionProperty==="scale")&&u.cancel();const s=this.refreshShape();if(!s)return;const o={x:n.boundingRectangle.left-s.boundingRectangle.left,y:n.boundingRectangle.top-s.boundingRectangle.top},{translate:a}=it(i),c=aa(i,a,!1),d=aa(i,a);if(o.x||o.y){const u=yo(Re(i))?Vi(Gi({},t),{duration:0}):t;pc({element:i,keyframes:{translate:[`${c.x+o.x}px ${c.y+o.y}px ${c.z}`,`${d.x}px ${d.y}px ${d.z}`]},options:u}).then(()=>{e.dragOperation.status.dragging||(this.droppable.shape=void 0)})}})})}get manager(){return this.draggable.manager}set manager(e){oe(()=>{this.draggable.manager=e,this.droppable.manager=e})}set element(e){oe(()=>{const t=Hn(this,nn),n=this.droppable.element,r=this.draggable.element;(!n||n===t)&&(this.droppable.element=e),(!r||r===t)&&(this.draggable.element=e),Ct(this,nn,e)})}get element(){var e,t;const n=Hn(this,nn);if(n)return(t=(e=ds.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=Ue(e,Ea)}set disabled(e){const t=Pa(e);oe(()=>{this.droppable.disabled=t.droppable,this.draggable.disabled=t.draggable})}set data(e){oe(()=>{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??gc}set alignment(e){this.draggable.alignment=e}get alignment(){return this.draggable.alignment}set type(e){oe(()=>{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)}};xt=Dp();Ao=new WeakMap;Kn=new WeakMap;qn=new WeakMap;Ro=new WeakMap;nn=new WeakMap;md(xt,4,"index",_d,Si,Ao);md(xt,4,"group",xd,Si,Ro);Pp(xt,Si);var wd=class extends _i{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}},Lo=class extends wi{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},Vp=Object.defineProperty,Hp=Object.defineProperties,Kp=Object.getOwnPropertyDescriptors,Ma=Object.getOwnPropertySymbols,qp=Object.prototype.hasOwnProperty,Up=Object.prototype.propertyIsEnumerable,Ca=(e,t,n)=>t in e?Vp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ki=(e,t)=>{for(var n in t||(t={}))qp.call(t,n)&&Ca(e,n,t[n]);if(Ma)for(var n of Ma(t))Up.call(t,n)&&Ca(e,n,t[n]);return e},Xp=(e,t)=>Hp(e,Kp(t));function Yp(e){const{accept:t,collisionDetector:n,collisionPriority:r,id:i,data:s,element:o,handle:a,index:c,group:d,disabled:u,modifiers:l,sensors:f,target:g,type:h,plugins:m}=e,w=Ki(Ki({},bd),e.transition),b=Zc(p=>new Si(Xp(Ki({},e),{transition:w,register:!1,handle:ln(a),element:ln(o),target:ln(g)}),p)),v=qc(b,Zp);return ie(i,()=>b.id=i),Tn(()=>{oe(()=>{b.group=d,b.index=c})},[b,d,c]),ie(h,()=>b.type=h),ie(t,()=>b.accept=t,void 0,Ke),ie(s,()=>s&&(b.data=s)),ie(c,()=>{var p;(p=b.manager)!=null&&p.dragOperation.status.idle&&w?.idle&&b.refreshShape()},ph),Nr(a,p=>b.handle=p),Nr(o,p=>b.element=p),Nr(g,p=>b.target=p),ie(u,()=>b.disabled=u??!1,void 0,Ke),ie(f,()=>b.sensors=f,void 0,Ke),ie(n,()=>b.collisionDetector=n),ie(r,()=>b.collisionPriority=r),ie(m,()=>b.plugins=m,void 0,Ke),ie(w,()=>b.transition=w,void 0,Ke),ie(l,()=>b.modifiers=l,void 0,Ke),ie(e.alignment,()=>b.alignment=e.alignment),{sortable:v,get isDragging(){return v.isDragging},get isDropping(){return v.isDropping},get isDragSource(){return v.isDragSource},get isDropTarget(){return v.isDropTarget},handleRef:S.useCallback(p=>{b.handle=p??void 0},[b]),ref:S.useCallback(p=>{var x,_;!p&&((x=b.element)!=null&&x.isConnected)&&!((_=b.manager)!=null&&_.dragOperation.status.idle)||(b.element=p??void 0)},[b]),sourceRef:S.useCallback(p=>{var x,_;!p&&((x=b.source)!=null&&x.isConnected)&&!((_=b.manager)!=null&&_.dragOperation.status.idle)||(b.source=p??void 0)},[b]),targetRef:S.useCallback(p=>{var x,_;!p&&((x=b.target)!=null&&x.isConnected)&&!((_=b.manager)!=null&&_.dragOperation.status.idle)||(b.target=p??void 0)},[b])}}function Zp(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const Cs="tile",kd="gap",Jp='[role="separator"]',Qp=[Ss.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>(Ss.defaults.preventActivation?.(e,t)??!1)||e.target instanceof Element&&e.target.closest(Jp)!==null}),Wc],eg=e=>[...e,Oo.configure({feedback:"clone"})];function tg({id:e,index:t,children:n}){const{ref:r,handleRef:i,isDragSource:s}=Yp({id:e,index:t,type:Cs,accept:Cs,collisionDetector:xo,plugins:eg});return y.jsx(y.Fragment,{children:n({ref:r,handleRef:i,isDragSource:s})})}function ng({id:e,after:t,children:n}){const{ref:r,isDropTarget:i}=Wh({id:e,type:kd,accept:Cs,collisionDetector:xo,data:{after:t}});return y.jsx(y.Fragment,{children:n({ref:r,isDropTarget:i})})}const rg=j.createSvgIcon(y.jsx("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"})),ig=j.createSvgIcon(y.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}));function sg({tile:e,index:t,selected:n,menuOpen:r,resizeSpan:i,columns:s,onSelect:o,onOpenMenu:a,onResizeStart:c,onResizeMove:d,onResizeEnd:u,children:l}){const{theme:f}=Pe.usePublisherTheme();return y.jsx(tg,{id:ot(e),index:t,children:({ref:g,handleRef:h,isDragSource:m})=>y.jsxs(k.Box,{ref:g,onClick:o,onPointerDown:w=>{w.button===0&&o()},"aria-label":`Tile ${e.name}`,"aria-current":n,sx:{position:"relative",display:"grid",minWidth:0,cursor:"grab",borderRadius:1,outline:n?`2px solid ${f.drillLink}`:"2px solid transparent",outlineOffset:2,transition:"outline-color 120ms, opacity 120ms, box-shadow 120ms","&&[data-dnd-dragging]":{opacity:1,outline:"none",boxShadow:"0 12px 32px rgba(0, 0, 0, 0.22)"},"&&[data-dnd-placeholder]":{opacity:.45,outline:`2px dashed ${f.drillLink}`,boxShadow:"none"},"&:hover .builder-affordance, &:focus-within .builder-affordance":{opacity:1},"&:hover":{outlineColor:n?f.drillLink:f.border,boxShadow:"0 2px 10px rgba(0, 0, 0, 0.10)"}},children:[l,y.jsx(k.Box,{ref:h,className:"builder-affordance","aria-label":`Move ${e.label??e.name}`,sx:{position:"absolute",top:"2px",left:"2px",display:"grid",placeItems:"center",width:"22px",height:"22px",borderRadius:"4px",cursor:"grab",touchAction:"none",zIndex:2,color:f.tileTitle,bgcolor:f.tile,opacity:m||n?.9:0,transition:"opacity 120ms","&:hover":{opacity:1},"&:active":{cursor:"grabbing"},"&:focus-visible":{opacity:1,outline:`2px solid ${f.drillLink}`,outlineOffset:1}},children:y.jsx(rg,{sx:{fontSize:16}})}),i===void 0&&y.jsx(k.IconButton,{className:"builder-affordance",size:"small","aria-label":`Settings for ${e.label??e.name}`,onClick:w=>{w.stopPropagation(),a(w.currentTarget)},sx:{position:"absolute",top:"2px",right:"2px",width:22,height:22,zIndex:2,color:f.tileTitle,bgcolor:f.tile,opacity:n||r?.9:0,transition:"opacity 120ms","&:hover":{opacity:1,bgcolor:f.tile}},children:y.jsx(ig,{sx:{fontSize:16}})}),i!==void 0&&y.jsxs(k.Box,{"aria-hidden":!0,sx:{position:"absolute",top:"6px",right:"6px",px:.75,py:.25,borderRadius:"4px",bgcolor:f.drillLink,color:f.tile,fontSize:11,fontVariantNumeric:"tabular-nums",zIndex:4,pointerEvents:"none"},children:[i," of ",s," ·"," ",Math.round(i/s*100),"%"]}),e.declaration.kind!=="inherited"&&y.jsx(k.Box,{className:"builder-affordance",role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label??e.name}`,onPointerDown:c,onPointerMove:d,onPointerUp:u,onPointerCancel:u,sx:{position:"absolute",top:0,bottom:0,right:"-5px",width:"10px",cursor:"col-resize",touchAction:"none",zIndex:1,opacity:i!==void 0||n?1:0,transition:"opacity 120ms","&:hover":{opacity:1},"&::after":{content:'""',position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"4px",height:"28px",borderRadius:"2px",bgcolor:f.drillLink}}})]})})}function og({tile:e}){const{theme:t}=Pe.usePublisherTheme();return y.jsxs(j.TileCard,{sx:{minHeight:140},children:[y.jsx(j.TileHeading,{title:e.label??e.name,subtitle:e.subtitle}),y.jsxs(k.Typography,{variant:"caption",sx:{display:"block",color:t.tileTitle,opacity:.7},children:[e.source," → ",e.name]})]})}function ag({after:e}){const{theme:t}=Pe.usePublisherTheme();return y.jsx(ng,{id:fd(e),after:e,children:({ref:n,isDropTarget:r})=>y.jsx(k.Box,{ref:n,"aria-hidden":!0,sx:{minHeight:48,borderRadius:1,border:`1px dashed ${t.drillLink}`,bgcolor:r?t.tile:"transparent",opacity:r?.95:.4,transition:"opacity 120ms, background-color 120ms"}})})}function lg({columns:e}){const{theme:t}=Pe.usePublisherTheme();return y.jsx(k.Box,{"aria-hidden":!0,sx:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3,display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,gap:`${j.GRID_GAP_PX}px`},children:Array.from({length:e},(n,r)=>y.jsx(k.Box,{sx:{borderLeft:`1px dashed ${t.drillLink}`,borderRight:r===e-1?`1px dashed ${t.drillLink}`:"none",opacity:.35}},r))})}var cg=Object.defineProperty,dg=Object.defineProperties,ug=Object.getOwnPropertyDescriptors,Ia=Object.getOwnPropertySymbols,fg=Object.prototype.hasOwnProperty,hg=Object.prototype.propertyIsEnumerable,ja=(e,t,n)=>t in e?cg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ut=(e,t)=>{for(var n in t||(t={}))fg.call(t,n)&&ja(e,n,t[n]);if(Ia)for(var n of Ia(t))hg.call(t,n)&&ja(e,n,t[n]);return e},Xt=(e,t)=>dg(e,ug(t));function pg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Cr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function qi(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function gg(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const c=(p,x)=>p===x||p!==null&&typeof p=="object"&&"id"in p&&p.id===x;if(Array.isArray(e)){const p=e.findIndex(_=>c(_,s.id)),x=e.findIndex(_=>c(_,o.id));if(p===-1||x===-1){if(qi(s)){const _=s.initialIndex,$=s.index;return _===$||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,$)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const _=s.index;if(_!==p)return n(e,p,_)}return n(e,p,x)}const d=Object.entries(e);let u=-1,l,f=-1,g;for(const[p,x]of d)if(u===-1&&(u=x.findIndex(_=>c(_,s.id)),u!==-1&&(l=p)),f===-1&&(f=x.findIndex(_=>c(_,o.id)),f!==-1&&(g=p)),u!==-1&&f!==-1)break;if(u===-1&&qi(s)){const p=s.initialGroup==null?void 0:Cr(e,s.initialGroup),x=s.initialIndex,_=s.group==null?void 0:Cr(e,s.group),$=s.index;if(p==null||_==null||p===_&&x===$)return"preventDefault"in t&&t.preventDefault(),e;if(p===_)return Xt(Ut({},e),{[p]:n(e[p],x,$)});const T=e[p][x];return Xt(Ut({},e),{[p]:[...e[p].slice(0,x),...e[p].slice(x+1)],[_]:[...e[_].slice(0,$),T,...e[_].slice($)]})}if(!s.manager)return e;const{dragOperation:h}=s.manager,m=(i=(r=h.shape)==null?void 0:r.current.center)!=null?i:h.position.current;if(g==null){const p=Cr(e,o.id);if(p!=null){const x=o.shape&&m.y>o.shape.center.y?e[p].length:0;g=p,f=x}}if(l==null||g==null||l===g&&u===f){if(l!=null&&l===g&&u===f&&qi(s)){const p=s.group==null?void 0:Cr(e,s.group),x=s.group!=null&&p!==l,_=s.index!==u;if(x||_){const $=s.group==null?l:p;if($!=null){if(l===$)return Xt(Ut({},e),{[l]:n(e[l],u,s.index)});const T=e[l][u];return Xt(Ut({},e),{[l]:[...e[l].slice(0,u),...e[l].slice(u+1)],[$]:[...e[$].slice(0,s.index),T,...e[$].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(l===g)return Xt(Ut({},e),{[l]:n(e[l],u,f)});const b=o.shape&&Math.round(m.y)>Math.round(o.shape.center.y)?1:0,v=e[l][u];return Xt(Ut({},e),{[l]:[...e[l].slice(0,u),...e[l].slice(u+1)],[g]:[...e[g].slice(0,f+b),v,...e[g].slice(f+b)]})}function vg(e,t){return gg(e,t,pg)}function mg({tiles:e,commit:t,onLanded:n}){const[r,i]=S.useState(void 0),s=S.useRef(void 0),[o,a]=S.useState(!1);return{dragging:o,preview:r,onDragStart:()=>{a(!0),s.current=e},onDragOver:l=>{const{source:f,target:g}=l.operation;if(!f||!g)return;const h=s.current??e;let m;if(g.type===kd){const{after:w}=g.data,b=h.findIndex(x=>ot(x)===f.id);if(b<0||w===f.id)return;const p=h.filter((x,_)=>_!==b).findIndex(x=>ot(x)===w)+1;m=xp(h,b,p)}else{const w=h.map(ot),b=vg(w,l);if(b.every((p,x)=>p===w[x]))return;const v=new Map(h.map(p=>[ot(p),p]));m=bp(b.map(p=>v.get(p)),e.map(p=>p.break??!1))}s.current=m,i(m)},onDragEnd:l=>{a(!1);const f=s.current;if(s.current=void 0,i(void 0),l.canceled||!f)return;t(f);const g=f.findIndex(h=>ot(h)===l.operation.source?.id);g>=0&&n(g)}}}const Aa=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function yg({tiles:e,columns:t,onStart:n,commit:r}){const[i,s]=S.useState(void 0),o=S.useRef(null);return{resize:i,gridBox:o,startResize:(u,l)=>{const f=o.current?.getBoundingClientRect(),g=u.currentTarget.parentElement?.getBoundingClientRect();!f||!g||(u.stopPropagation(),u.preventDefault(),u.currentTarget.setPointerCapture(u.pointerId),Aa(!0),n(l),s({index:l,span:e[l]?.colspan??1,left:g.left,track:(f.width-j.GRID_GAP_PX*(t-1))/t}))},onResize:u=>{if(!i)return;const l=u.clientX-i.left,f=Math.round((l+j.GRID_GAP_PX)/(i.track+j.GRID_GAP_PX)),g=Math.min(Math.max(f,1),t);g!==i.span&&s({...i,span:g})},endResize:u=>{if(u.currentTarget.hasPointerCapture(u.pointerId)&&u.currentTarget.releasePointerCapture(u.pointerId),Aa(!1),!i)return;const{index:l,span:f}=i;s(void 0),r(l,f)}}}function bg({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:i,columns:s,onDrills:o}){const{theme:a}=Pe.usePublisherTheme(),{draft:c,patch:d,close:u,discard:l}=dd(t,e!==null,r,n),f=c!==void 0&&c.declaration.kind!=="inherited";return y.jsx(k.Popover,{open:e!==null&&c!==void 0,anchorEl:e,onClose:u,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:c&&y.jsxs(k.Stack,{sx:{gap:1.5},children:[y.jsxs(k.Typography,{variant:"overline",sx:{color:a.tileTitle,lineHeight:1.5},children:[c.source," → ",c.name]}),f?y.jsxs(y.Fragment,{children:[y.jsx(k.TextField,{size:"small",label:"Title",value:c.label??"",autoFocus:!0,inputProps:{"aria-label":"Tile title"},onChange:g=>d(h=>{const m=g.target.value;m===""?delete h.label:h.label=m})}),y.jsx(k.TextField,{size:"small",label:"Subtitle",value:c.subtitle??"",inputProps:{"aria-label":"Tile subtitle"},onChange:g=>d(h=>{const m=g.target.value;m===""?delete h.subtitle:h.subtitle=m})}),y.jsxs(k.Stack,{direction:"row",sx:{gap:.5,alignItems:"center"},children:[y.jsx(k.Typography,{variant:"caption",sx:{color:a.tileTitle,mr:.5},children:"Width"}),[["Full",1],["½",2],["⅓",3],["¼",4]].map(([g,h])=>{const m=Math.max(1,Math.round(s/h)),w=(c.colspan??1)===m;return y.jsx(k.Button,{size:"small",variant:w?"contained":"outlined","aria-label":`Width ${g}`,"aria-pressed":w,onClick:()=>d(b=>{b.colspan=m}),sx:{minWidth:40,px:1},children:g},g)})]})]}):y.jsx(k.Typography,{variant:"body2",sx:{color:a.tileTitle},children:"Declared on its source, so its title and layout are set in the model. It can still be moved."}),y.jsx(k.Divider,{}),y.jsxs(k.Stack,{direction:"row",sx:{justifyContent:"space-between"},children:[f?y.jsx(k.Button,{size:"small",onClick:()=>{u(),o()},children:"Clickable cells…"}):y.jsx("span",{}),y.jsx(k.Button,{color:"error",size:"small",onClick:()=>{l(),i()},children:"Remove tile"})]})]})})}const ci=e=>e.ok===!1;function Lt(e,t){let n=t;for(let i=t-1;i>=0;i--){const s=e[i].trim();if(s==="")break;if(s.startsWith("#")||s.startsWith("//"))n=i;else break}const r=[];for(let i=n;i<t;i++){const s=e[i].trim();s.startsWith("#")&&!s.startsWith("##")&&r.push({line:i,text:s})}return{start:n,tags:r}}const Is=e=>e.map(t=>t.text);function xg(e){const t=[],n=[];for(const r of e){const i=r.trim();if(i.startsWith('##"'))t.push(i.slice(3).trim());else{if(i.startsWith("##!"))continue;i.startsWith("##")&&n.push(i)}}return{description:t.length>0?t.join(`
70
+ `):void 0,artifact:n}}function _g(e,t){return new RegExp(`source:\\s*${t}\\s+is\\s+([A-Za-z_][A-Za-z0-9_.]*)`).exec(e)?.[1]}function wg(e,t){const n=new RegExp(`view:\\s*${t}\\s+is\\s+([A-Za-z_][A-Za-z0-9_.]*)\\s*(\\+\\s*\\{[\\s\\S]*\\})?`).exec(e);if(n)return{kind:"reference",from:n[1],refinement:n[2]?.trim()};if(new RegExp(`view:\\s*${t}\\s+is\\s*\\{`).test(e))return{kind:"inline"}}const Sd=/where:\s*([A-Za-z_][A-Za-z0-9_.]*)\s*(~|>=|<=|!=|=|>|<)\s*\$([A-Za-z_][A-Za-z0-9_]*)/g;function kg(e){if(!e)return;const t=[];for(const n of e.matchAll(Sd))t.push({field:n[1],given:n[3],...n[2]==="~"?{}:{op:n[2]}});return t.length>0?t:void 0}function Sg(e,t){const n=[];for(const r of j.givenDeclarations(e).values()){const i=/^([A-Z_][A-Z0-9_]*)\s*::\s*(\S+)\s+is\s+(.+)$/.exec(r.declaration);i&&n.push({name:i[1],type:i[2],default:i[3].trim(),...$g(t(Is(Lt(e,r.line).tags)).tag)})}return n.length>0?n:void 0}function $g(e){if(!e)return{};const t=e.tag("suggest"),n=t?.text("dimension"),r=e.numeric("range_min"),i=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},...i===void 0?{}:{rangeMax:i}}}function Og(e){const t=e.search(/tiles\s*=\s*\[/);if(t<0)return[];const n=e.indexOf("[",t),r=e.indexOf("]",n);return r<0?[]:[...e.slice(n+1,r).matchAll(/"([^"]+)"/g)].map(s=>s[1])}async function di(e){const{Malloy:t}=await import("@malloydata/malloy"),{parseAnnotation:n}=await import("@malloydata/malloy-tag"),r=e.split(`
71
+ `);let i;try{i=t.parse({source:e}).symbols}catch(x){return{ok:!1,reason:`This file is not valid Malloy: ${x}`}}const{description:s,artifact:o}=xg(r),a=o.find(x=>x.includes("artifact"));if(a===void 0)return{ok:!1,reason:"No `## artifact { … }` tag, so this file is not a composite dashboard."};const c=n([a.replace(/^##\s*/,"# ")]).tag,d=c?.tag("artifact"),u=Og(a);if(u.length===0)return{ok:!1,reason:"The `## artifact` tag names no tiles, so there is nothing to lay out."};const l=[],f=[],g=[],h=new Map;for(const x of i){if(x.type==="import"){const C=(x.children??[]).filter(P=>P.type==="import_item").map(P=>String(P.name));l.push(C.length>0?{kind:"names",names:C,from:String(x.name)}:{kind:"all",from:String(x.name)});continue}if(x.type!=="explore")continue;const _=String(x.name),$=r[x.range.start.line]??"",T=_g($,_);if(T===void 0)return{ok:!1,reason:`Could not read what source \`${_}\` extends.`,line:x.range.start.line+1};f.push({name:_,base:T});const D=j.declarationsUnder(r,_,"view"),I=j.declarationsUnder(r,_,"dimension");I.size>0&&(f[f.length-1].dimensions=[...I].map(([C,P])=>({name:C,expression:P.rest})));for(const[C,P]of I){const{tags:A}=Lt(r,P.line),R=n(Is(A)).tag?.tag("drill");if(!R)continue;const U=R.textArray("to")??[R.text("to")??""];g.push({source:_,name:C,expression:P.rest,to:U.filter(Boolean),...R.text("given")?{given:R.text("given")}:{}})}h.set(_,D)}const m=[];for(const x of u){const _=j.tileSteps(x);if(!_)return{ok:!1,reason:`The tile \`${x}\` is not a \`source -> view\` expression, which is the only form the builder can lay out.`};const{source:$,view:T}=_,D=h.get($)?.get(T)?.line;if(D===void 0){m.push({name:T,source:$,declaration:{kind:"inherited"}});continue}const I=wg(r[D],T);if(I===void 0)return{ok:!1,reason:`Could not read what view \`${T}\` is declared from.`,line:D+1};const{tags:C}=Lt(r,D),P=n(Is(C)).tag,A=I.kind==="reference"?kg(I.refinement):void 0;m.push({name:T,source:$,declaration:I.kind==="reference"?{kind:"reference",from:I.from}:{kind:"inline"},...A?{filters:A}:{},...P?.text("label")?{label:P.text("label")}:{},...P?.text("subtitle")?{subtitle:P.text("subtitle")}:{},...P?.numeric("colspan")!==void 0?{colspan:P.numeric("colspan")}:{},...P?.has("break")?{break:!0}:{},...P?.has("borderless")?{borderless:!0}:{}})}const w=Sg(r,n),b={},v=d?.tag("givens");for(const x of Object.keys(v?.dict??{})){const _=v?.text(x);_!==void 0&&(b[x]=_)}const p=c?.tag("dashboard")?.numeric("columns");return{ok:!0,document:{title:d?.text("title")??"",...s?{description:s}:{},...p===void 0?{}:{columns:p},...d?.has("autorun")?{autorun:d.isTrue("autorun")}:{},imports:l,sources:f,...w?{localGivens:w}:{},...Object.keys(b).length>0?{startingGivens:b}:{},...g.length>0?{drills:g}:{},tiles:m}}}const js=e=>e.ok===!1;function pe(e){const t=n=>{if(Array.isArray(n))return n.map(t);if(n&&typeof n=="object"){const r={};for(const i of Object.keys(n).sort())r[i]=t(n[i]);return r}return n};return JSON.stringify(t(e))}function Tg(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
72
+ `&&t.push(n+1);return t}function Dg(e,t){let n=e;for(const r of[...t].sort((i,s)=>s.start-i.start))n=n.slice(0,r.start)+r.text+n.slice(r.end);return n}function $d(e){const t=[];return e.colspan!==void 0&&t.push(`# colspan=${e.colspan}`),e.break&&t.push("# break"),e.borderless&&t.push("# borderless"),e.label!==void 0&&t.push(`# label=${gn(e.label)}`),e.subtitle!==void 0&&t.push(`# subtitle=${gn(e.subtitle)}`),t}function Hr(e){return/^#\s*([a-z_]+)/.exec(e)?.[1]}const Eg=new Set(["colspan","break","borderless","label","subtitle"]),Pg=new Set(["label","description","control","suggest","range_min","range_max"]),Mg=(e,t)=>pe(e.imports)===pe(t.imports);function Ra(e){const t=[];if(e.label!==void 0&&t.push(`label=${gn(e.label)}`),e.description!==void 0&&t.push(`description=${gn(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=${e.suggest.query}`:void 0;t.push(`suggest { ${n?`${n} `:""}dimension=${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 La=e=>`given: ${e.name} :: ${e.type} is ${e.default}`;function ui(e,t){let n=0,r=!1;for(let i=t;i<e.length;i++){for(const s of e[i])s==="{"?(n++,r=!0):s==="}"&&n--;if(r&&n<=0||!r&&i===t)return i}return e.length-1}const za=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Cg(e,t,n){const r=e.findIndex(o=>new RegExp(`\\bsource:\\s*${za(t)}\\s+is\\b`).test(o));if(r<0)return-1;const i=ui(e,r),s=new RegExp(`\\bview:\\s*${za(n)}\\s+is\\b`);for(let o=r;o<=i;o++)if(s.test(e[o]))return o;return-1}function Wa(e){return`# drill { to=${e.to.length===1?e.to[0]:`[${e.to.map(n=>`"${n}"`).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const fi=e=>`${e.source}.${e.name}`,gn=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,As=e=>pe([e.name,e.source,e.declaration]),at=As,Fa=e=>pe(e.tiles.map(at));function Ig(e,t){const n=new Set(e.tiles.map(at)),r=new Set(t.tiles.map(at)),i=e.tiles.filter(l=>!r.has(at(l))),s=t.tiles.filter(l=>!n.has(at(l))),a=i.length>0||s.length>0||Fa(e)!==Fa(t);for(const l of s)if(l.declaration.kind!=="reference")return{ok:!1,reason:`A new tile names a view of a source; \`${l.name}\` is ${l.declaration.kind==="inline"?"an inline query":"not declared here"}, which the builder cannot write.`};const c=new Map(e.sources.map(l=>[l.name,l])),d=new Set(e.imports.flatMap(l=>l.kind==="names"?l.names:[]));for(const l of e.sources)d.add(l.base);const u=t.sources.filter(l=>!c.has(l.name));for(const l of e.sources){const f=t.sources.find(g=>g.name===l.name);if(!f||f.base!==l.base)return{ok:!1,reason:`The source \`${l.name}\` cannot be changed or removed here.`}}for(const l of u){if(!s.some(f=>f.source===l.name))return{ok:!1,reason:`A new source \`${l.name}\` needs a tile on it.`};if(!d.has(l.base))return{ok:!1,reason:`\`${l.base}\` is not imported by name in this file, so a tile cannot be put on it. The builder does not add imports: import { ${l.base} } from the model first.`}}return Mg(e,t)?{currentKeys:n,nextKeys:r,removedTiles:i,addedTiles:s,newSources:u,currentSources:c,reordered:a}:{ok:!1,reason:"The dashboard's imports cannot be changed here."}}function jg(e){const{lines:t,wholeLine:n,next:r,reordered:i,currentKeys:s,nextKeys:o,edits:a}=e;if(i){const c=j.artifactLine(t);if(c<0)return{ok:!1,reason:"Could not find the `## artifact` tag to reorder."};const d=[...t[c].matchAll(/"([^"]+)"/g)].map(h=>h[1]),u=new Map;for(const h of d){const m=h.split("->").map(w=>w.trim());m.length===2&&u.set(`${m[0]}->${m[1]}`,h)}const l=r.tiles.map(h=>u.get(`${h.source}->${h.name}`)??(o.has(at(h))&&!s.has(at(h))?`${h.source} -> ${h.name}`:void 0));if(l.some(h=>h===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const f=`tiles=[${l.map(h=>`"${h}"`).join(", ")}]`,g=t[c].replace(/tiles\s*=\s*\[[\s\S]*?\]/,f);g!==t[c]&&a.push({...n(c),text:`${g}
73
+ `})}}function Ag(e){const{lines:t,wholeLine:n,current:r,next:i,edits:s}=e;if(r.title!==i.title||r.autorun!==i.autorun||r.columns!==i.columns||pe(r.startingGivens)!==pe(i.startingGivens)){const o=j.artifactLine(t);if(o<0)return{ok:!1,reason:"Could not find the `## artifact` tag to change the page's settings."};const a=s.find(m=>m.start===n(o).start&&m.end===n(o).end);let c=a?a.text.replace(/\n$/,""):t[o];const d=c.indexOf("artifact"),u=c.indexOf("{",d);let l=0,f=-1;for(let m=u;m<c.length;m++)if(c[m]==="{")l++;else if(c[m]==="}"&&--l===0){f=m;break}if(u<0||f<0)return{ok:!1,reason:"Could not read the `## artifact { … }` tag."};let g=c.slice(u+1,f);const h=(m,w)=>{const b=new RegExp(`\\s*\\b${m}=(?:"(?:[^"\\\\]|\\\\.)*"|[^\\s}]+)`);w===void 0?g=g.replace(b,""):b.test(g)?g=g.replace(b,` ${m}=${w}`):g=`${g.replace(/\s+$/,"")} ${m}=${w} `};if(r.title!==i.title&&h("title",i.title?gn(i.title):void 0),r.autorun!==i.autorun&&h("autorun",i.autorun===void 0?void 0:String(i.autorun)),pe(r.startingGivens)!==pe(i.startingGivens)){g=g.replace(/\s*\bgivens\s*\{[^}]*\}/,"");const m=Object.entries(i.startingGivens??{});m.length>0&&(g=`${g.replace(/\s+$/,"")} givens { ${m.map(([w,b])=>`${w}=${gn(b)}`).join(" ")} }`)}g=g.replace(/\s{2,}/g," "),c=`${c.slice(0,u+1)}${g.startsWith(" ")?g:` ${g}`}${g.endsWith(" ")?"":" "}${c.slice(f)}`,r.columns!==i.columns&&(c=c.replace(/\s*dashboard\s*\{[^}]*\}/,""),i.columns!==void 0&&(c=`${c.trimEnd()} dashboard { columns=${i.columns} }`)),a?a.text=`${c}
74
+ `:s.push({...n(o),text:`${c}
75
+ `})}if(r.description!==i.description){const o=t.map((c,d)=>c.trim().startsWith('##"')?d:-1).filter(c=>c>=0),a=(i.description??"").split(`
76
+ `).map(c=>c.trim()===""?'##"':`##" ${c.trim()}`).join(`
77
+ `);if(o.length>0){const c=o[0],d=o[o.length-1];s.push({start:n(c).start,end:n(d).end,text:i.description===void 0?"":`${a}
78
+ `})}else if(i.description!==void 0){const c=j.artifactLine(t),d=n(c).start;s.push({start:d,end:d,text:`${a}
79
+ `})}}}function Rg(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o}=e,a=new Map((i.localGivens??[]).map(f=>[f.name,f])),c=new Map((s.localGivens??[]).map(f=>[f.name,f])),d=j.givenDeclarations(t),u=new Set;for(const[f,g]of a){const h=c.get(f);if(h!==void 0&&pe(h)===pe(g))continue;const m=d.get(f);if(m===void 0)return{ok:!1,reason:`Could not find where the given \`${f}\` is declared.`};const{tags:w}=Lt(t,m.line),b=h===void 0?w:w.filter($=>{const T=Hr($.text);return T!==void 0&&Pg.has(T)});for(const $ of b)o.push({...n($.line),text:""}),u.add($.line);if(h===void 0){o.push({...n(m.line),text:""}),u.add(m.line);const $=Math.min(m.line,...w.map(P=>P.line)),T=m.blockHeader??$,D=(t[m.line+1]??"x").trim()==="",I=T===0||t[T-1].trim()==="",C=m.blockHeader===void 0||![...d.values()].some(P=>P.blockHeader===m.blockHeader&&P.line>m.line&&c.has([...d.entries()].find(([,A])=>A===P)?.[0]??""));D&&I&&C&&!u.has(m.line+1)&&(o.push({...n(m.line+1),text:""}),u.add(m.line+1));continue}const v=r(m.line),p=Ra(h),_=h.type!==g.type||h.default!==g.default?m.blockHeader===void 0?La(h):`${h.name} :: ${h.type} is ${h.default}`:t[m.line].trim();o.push({...n(m.line),text:(p?`${v}${p}
80
+ `:"")+`${v}${_}
81
+ `})}for(const[f,g]of d){if(g.blockHeader===void 0||c.has(f))continue;![...d.values()].some(m=>m.blockHeader===g.blockHeader&&!u.has(m.line))&&!u.has(g.blockHeader)&&(o.push({...n(g.blockHeader),text:""}),u.add(g.blockHeader))}const l=[...c.values()].filter(f=>!a.has(f.name));if(l.length>0){const f=Math.max(-1,...[...d.values()].map(v=>v.line)),g=(()=>{let v=-1;for(let p=0;p<t.length;p++){const x=t[p].trim();(x.startsWith("import ")||v>=0&&/^}\s*from\s/.test(x))&&(v=p)}return v})(),h=f>=0?f:g,m=l.map(v=>{const p=Ra(v);return(p?`${p}
82
+ `:"")+`${La(v)}
83
+ `}).join(`
84
+ `),w=h>=0?n(h).end:n(0).end;o.push({start:w,end:w,text:`
85
+ ${m}`}),t.some(v=>v.trim().startsWith("##! experimental.givens"))||o.push({start:0,end:0,text:`##! experimental.givens
86
+ `})}}function Lg(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o}=e,a=new Map((i.drills??[]).map(d=>[fi(d),d])),c=new Map((s.drills??[]).map(d=>[fi(d),d]));for(const d of new Set([...a.keys(),...c.keys()])){const u=a.get(d),l=c.get(d);if(u&&l&&pe(u)===pe(l))continue;const f=l??u;if(l&&l.to.length===0)return{ok:!1,reason:`The drill on \`${d}\` names no destination.`};const g=j.declarationsUnder(t,f.source,"dimension").get(f.name);if(g===void 0)return{ok:!1,reason:`\`${f.name}\` is not a dimension \`${f.source}\` declares in this file, so a drill cannot be put on it here.`};const{tags:h}=Lt(t,g.line),m=h.find(b=>/^#\s*drill\b/.test(b.text)),w=r(g.line);if(l===void 0)m&&o.push({...n(m.line),text:""});else if(m)o.push({...n(m.line),text:`${w}${Wa(l)}
87
+ `});else{const b=n(g.line).start;o.push({start:b,end:b,text:`${w}${Wa(l)}
88
+ `})}}}function zg(e){const{lines:t,wholeLine:n,removedTiles:r,edits:i}=e;for(const s of r){if(s.declaration.kind==="inherited")continue;const o=j.declarationLine(t,"view",s.name);if(o<0)return{ok:!1,reason:`Could not find where \`${s.name}\` is declared.`};const a=ui(t,o),{tags:c}=Lt(t,o),d=Math.min(o,...c.map(l=>l.line));for(const l of c)i.push({...n(l.line),text:""});i.push({start:n(o).start,end:n(a).end,text:""});const u=d===0?"":t[d-1].trim();(t[a+1]??"x").trim()===""&&(d===0||u===""||u.endsWith("{"))&&i.push({...n(a+1),text:""})}}function Wg(e){const{sourceText:t,lines:n,wholeLine:r,current:i,addedTiles:s,newSources:o,currentSources:a,edits:c}=e,d=new Map;for(const f of s){const g=d.get(f.source)??[];g.push(f),d.set(f.source,g)}const u=(f,g)=>{const h=f.declaration.kind==="reference"?f.declaration.from:f.name,m=(f.filters??[]).map(w=>`where: ${w.field} ${w.op??"~"} $${w.given}`).join(", ");return[...$d(f).map(w=>`${g}${w}`),`${g}view: ${f.name} is ${h}${m?` + { ${m} }`:""}`].join(`
89
+ `)};let l=-1;for(const f of i.sources){const g=j.declarationLine(n,"source",f.name);g>=0&&(l=Math.max(l,ui(n,g)))}for(const[f,g]of d)if(a.has(f)){const h=j.declarationLine(n,"source",f);if(h<0)return{ok:!1,reason:`Could not find where the source \`${f}\` is declared.`};const m=ui(n,h);let w=" ";for(let p=h+1;p<m;p++){const x=/^(\s+)view:/.exec(n[p]);if(x){w=x[1];break}}const b=r(m).start,v=(n[m-1]??"").trim()==="";c.push({start:b,end:b,text:(v?"":`
90
+ `)+g.map(p=>u(p,w)).join(`
91
+
92
+ `)+`
93
+ `})}else{const h=o.find(p=>p.name===f);if(!h)return{ok:!1,reason:`The tile's source \`${f}\` is not declared.`};const m=`
94
+ source: ${h.name} is ${h.base} extend {
95
+ `+g.map(p=>u(p," ")).join(`
96
+
97
+ `)+`
98
+ }
99
+ `;let w=l;if(w<0)for(let p=0;p<n.length;p++){const x=n[p].trim();(/^(import\s|given:|}\s*from\s)/.test(x)||/^[A-Z_]+\s*::/.test(x))&&(w=p)}const b=w>=0?r(w).end:t.length,v=b===t.length&&!t.endsWith(`
100
+ `)?`
101
+ `:"";c.push({start:b,end:b,text:v+m}),l=w}}function Fg(e){const{lines:t,starts:n,wholeLine:r,indentOf:i,current:s,next:o,edits:a}=e,c=new Map(s.tiles.map(d=>[at(d),d]));for(const d of o.tiles){const u=c.get(at(d));if(u===void 0||pe(u)===pe(d))continue;if(d.declaration.kind==="inherited")return{ok:!1,reason:`\`${d.source} -> ${d.name}\` is declared on its source, not in this dashboard, so its presentation cannot be changed here.`};const l=Cg(t,d.source,d.name);if(l<0)return{ok:!1,reason:`Could not find where \`${d.name}\` is declared inside \`${d.source}\`.`};const{tags:f}=Lt(t,l),g=i(l),h=$d(d),m=new Map(h.map(D=>[Hr(D)??D,D])),w=new Set;for(const D of f){const I=Hr(D.text);if(I===void 0||!Eg.has(I))continue;const C=m.get(I);if(C===void 0){a.push({...r(D.line),text:""});continue}w.add(I),C!==D.text&&a.push({...r(D.line),text:`${g}${C}
102
+ `})}const b=h.filter(D=>!w.has(Hr(D)??D));if(b.length>0){const D=n[l];a.push({start:D,end:D,text:b.map(I=>`${g}${I}
103
+ `).join("")})}const p=(/\+\s*\{([\s\S]*)\}\s*$/.exec(t[l])?.[1]??"").replace(Sd,"").replace(/\s*,\s*,\s*/g,", ").replace(/^[\s,;]+|[\s,;]+$/g,""),x=(d.filters??[]).map(D=>`where: ${D.field} ${D.op??"~"} $${D.given}`),_=[...p?[p]:[],...x],$=t[l].replace(/\s*\+\s*\{[\s\S]*\}\s*$/,""),T=_.length===0?$:`${$} + { ${_.join(", ")} }`;T!==t[l]&&a.push({...r(l),text:`${T}
104
+ `})}}async function Rs(e,t){const n=await di(e);if(ci(n))return{ok:!1,reason:`Cannot edit a file that will not open: ${n.reason}`};const r=n.document,i=Ig(r,t);if("reason"in i)return i;const s=e.split(`
105
+ `),o=Tg(e),a=h=>({start:o[h],end:h+1<o.length?o[h+1]:e.length}),c=h=>/^\s*/.exec(s[h])?.[0]??"",d=[],u={...i,sourceText:e,lines:s,starts:o,wholeLine:a,indentOf:c,current:r,next:t,edits:d};for(const h of[jg,Ag,Rg,Lg,zg,Wg,Fg]){const m=h(u);if(m)return m}const l=h=>{const{drills:m,localGivens:w,...b}=h,v=h.tiles.map(p=>{if(p.filters?.length)return p;const{filters:x,..._}=p;return _});return{...b,tiles:v,...m?.length?{drills:[...m].sort((p,x)=>fi(p).localeCompare(fi(x)))}:{},...w?.length?{localGivens:w}:{}}};if(d.length===0)return pe(l(r))!==pe(l(t))?{ok:!1,reason:"The edit did not produce the dashboard that was asked for, so it was not written. Your changes are still here."}:{ok:!0,source:e};const f=Dg(e,d),g=await di(f);return ci(g)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${g.reason}`}:pe(l(g.document))!==pe(l(t))?{ok:!1,reason:"The edit did not produce the dashboard that was asked for, so it was not written. Your changes are still here."}:{ok:!0,source:f}}function Bg(e){const[t,n]=S.useState({stack:[e.document],index:0}),[r,i]=S.useState(e.source),[s,o]=S.useState(void 0),[a,c]=S.useState(e.document),d=t.stack[t.index],u=S.useCallback(b=>{o(void 0),n(v=>{const p=structuredClone(v.stack[v.index]);if(b(p),JSON.stringify(p)===JSON.stringify(v.stack[v.index]))return v;const _=[...v.stack.slice(0,v.index+1),p].slice(-100);return{stack:_,index:_.length-1}})},[]),l=S.useCallback(()=>{o(void 0),n(b=>b.index>0?{...b,index:b.index-1}:b)},[]),f=S.useCallback(()=>{o(void 0),n(b=>b.index<b.stack.length-1?{...b,index:b.index+1}:b)},[]),g=S.useCallback(async()=>{const b=await Rs(r,d);if(js(b))return o(b.reason),{ok:!1,reason:b.reason};try{await e.onSave?.(b.source)}catch(v){const p=`Could not save: ${v}`;return o(p),{ok:!1,reason:p}}return i(b.source),c(d),o(void 0),{ok:!0}},[d,e,r]),h=S.useMemo(()=>JSON.stringify(d)!==JSON.stringify(a),[d,a]),m=S.useMemo(()=>{const b=new Set(a.tiles.map(As)),v=new Set(d.tiles.map(As));return[...b].some(p=>!v.has(p))||[...v].some(p=>!b.has(p))},[d,a]),w=S.useCallback(async()=>{const b=await Rs(r,d);return js(b)?{ok:!1,reason:b.reason}:{ok:!0,source:b.source}},[d,r]);return{document:d,source:r,canUndo:t.index>0,canRedo:t.index<t.stack.length-1,dirty:h,...s===void 0?{}:{error:s},update:u,undo:l,redo:f,save:g,preview:w,structural:m}}function Od({source:e,document:t,onSave:n,onChange:r,renderTile:i,controls:s,givens:o,catalog:a,toolbar:c,dashboards:d,onEvent:u,savesTo:l="package"}){const f=Bg({source:e,document:t,...n?{onSave:n}:{}}),[g,h]=S.useState(void 0),[m,w]=S.useState(!1),b=f.document.columns??j.DEFAULT_COLUMNS,{resize:v,gridBox:p,startResize:x,onResize:_,endResize:$}=yg({tiles:f.document.tiles,columns:b,onStart:h,commit:(O,E)=>f.update(z=>{z.tiles[O].colspan=E})}),{dragging:T,preview:D,onDragStart:I,onDragOver:C,onDragEnd:P}=mg({tiles:f.document.tiles,commit:O=>f.update(E=>{E.tiles=O}),onLanded:h}),[A,R]=S.useState(void 0),[U,Te]=S.useState(void 0),[De,me]=S.useState(!1),[X,Ye]=S.useState(void 0),[Ze,ye]=S.useState(null),[Me,Ge]=S.useState(void 0);S.useEffect(()=>{r?.(f.document)},[f.document,r]);const Y=S.useMemo(()=>gp(f.document),[f.document]),ee=S.useMemo(()=>{const O=new Set((t.localGivens??[]).map(E=>E.name));return(o??[]).filter(E=>!O.has(E.name))},[t,o]),H=S.useMemo(()=>Fh(f.document,ee),[f.document,ee]),he=S.useMemo(()=>new Map(f.document.sources.map(O=>[O.name,xa(a,O.base)])),[a,f.document.sources]),W=S.useCallback(O=>he.get(O.source)??xa(a,O.source),[he,a]),K=(O,E)=>{const z=[];for(const J of f.document.tiles){const He=W(J);if(!He)continue;const we=new Map(He.map(Ce=>[Ce.name,Ce.type]));for(const Ce of J.filters??[])Ce.given===O&&(!we.has(Ce.field)||!Vr(E,we.get(Ce.field)))&&z.push(`${Ce.field} on ${J.label??J.name} (${f.document.sources.find(st=>st.name===J.source)?.base??J.source})`)}return z},_e=S.useMemo(()=>H.filter(O=>O.origin==="model"&&O.boundTiles===0),[H]),ne=S.useCallback(()=>{Ge(void 0),w(!0);const O=j.now(),{structural:E}=f,z=f.document.tiles.length;f.save().then(J=>{J.ok===!0?u?.({type:"dashboard.saved",tiles:z,structural:E,where:l,durationMs:j.now()-O}):u?.({type:"dashboard.save_refused",reason:J.reason})}).finally(()=>w(!1))},[f,u,l]),Ve=S.useCallback(()=>{if(!(!n||!f.dirty||m)){if(!f.structural){ne();return}f.preview().then(O=>{O.ok?Ge({before:f.source,after:O.source}):ne()})}},[n,f,m,ne]),re=O=>{me(!1),f.update(E=>{let z=E.sources.find(we=>we.base===O.base);if(!z){const we=new Set(E.sources.map(st=>st.name));let Ce=`${O.base}_tiles`;for(let st=2;we.has(Ce);st++)Ce=`${O.base}_tiles_${st}`;z={name:Ce,base:O.base},E.sources.push(z)}const J=new Set(E.tiles.filter(we=>we.source===z.name).map(we=>we.name));let He=`${O.view}_tile`;for(let we=2;J.has(He);we++)He=`${O.view}_tile_${we}`;E.tiles.push({name:He,source:z.name,declaration:{kind:"reference",from:O.view},colspan:O.colspan,...O.label?{label:O.label}:{}})}),h(f.document.tiles.length)},ft=O=>{Te(void 0),h(void 0),f.update(E=>{E.tiles.splice(O,1)})};ep(S.useMemo(()=>({undo:f.undo,redo:f.redo,...n?{save:Ve}:{},escape:()=>{!U&&!A&&h(void 0)},nudge:O=>{if(g===void 0)return;const E=f.document.tiles[g];if(!E||E.declaration.kind==="inherited")return;const z=Math.min(Math.max((E.colspan??1)+O,1),b);z!==(E.colspan??1)&&f.update(J=>{J.tiles[g].colspan=z})}}),[f,n,Ve,U,A,g,b]));const Je=(O,E,z)=>{R(void 0),f.update(J=>{z&&qh(J,z),Kh(J,O,E)})},Nt=O=>{R(void 0),f.update(E=>Uh(E,O))},M=(()=>{const O=f.document.tiles;return v!==void 0?O.map((E,z)=>z===v.index?{...E,colspan:v.span}:E):D??O})(),L=T?_p(M,b):M.map(ud);return y.jsxs(k.Stack,{sx:{gap:0},children:[y.jsx(tp,{canUndo:f.canUndo,canRedo:f.canRedo,onUndo:f.undo,onRedo:f.redo,dirty:f.dirty,saving:m,...n?{onSave:Ve}:{},...c?{actions:c}:{},...a?{onAddTile:()=>me(!0)}:{},onSettings:ye}),y.jsxs(k.Stack,{sx:{gap:2,px:"4px",pb:"4px"},children:[y.jsx(j.DashboardProse,{title:f.document.title||"Untitled dashboard",...f.document.description?{description:f.document.description}:{}}),y.jsx(yp,{controls:H,tileCount:f.document.tiles.length,unknownFieldsOf:K,onEdit:O=>R({control:O}),onAdd:()=>R({}),children:s}),f.error&&y.jsx(k.Alert,{severity:"warning",children:f.error}),y.jsx(kh,{sensors:Qp,onDragStart:I,onDragOver:C,onDragEnd:P,children:y.jsxs(k.Box,{ref:p,sx:{position:"relative"},children:[(v!==void 0||T)&&y.jsx(lg,{columns:b}),y.jsx(j.DashboardGrid,{tiles:L,columns:b,keyOf:O=>O.kind==="gap"?fd(O.after):ot(O.tile),renderTile:O=>{if(O.kind==="gap")return y.jsx(ag,{after:O.after});const{tile:E,index:z}=O;return y.jsx(sg,{tile:E,index:z,selected:z===g,menuOpen:U?.index===z,resizeSpan:v?.index===z?v.span:void 0,columns:b,onSelect:()=>h(z),onOpenMenu:J=>{h(z),Te({anchor:J,index:z})},onResizeStart:J=>x(J,z),onResizeMove:_,onResizeEnd:$,children:i?i(E):y.jsx(og,{tile:E})})}})]})}),y.jsx(pp,{open:A!==void 0,document:f.document,...A?.control?{control:A.control}:{},available:_e,...a?{fieldsFor:W}:{},onClose:()=>R(void 0),onApply:Je,onRemove:Nt}),y.jsx(bg,{anchor:U?.anchor??null,tile:U===void 0?void 0:f.document.tiles[U.index],onClose:()=>Te(void 0),onCommit:O=>{const E=U?.index;E!==void 0&&f.update(z=>{z.tiles[E]=O})},onRemove:()=>{U!==void 0&&ft(U.index)},columns:b,onDrills:()=>{U!==void 0&&Ye(f.document.tiles[U.index]?.source)}}),y.jsx(fp,{open:X!==void 0,document:f.document,source:f.document.sources.find(O=>O.name===X),givenNames:H.map(O=>O.name),dashboards:d??[],onClose:()=>Ye(void 0),onApply:O=>f.update(E=>{const J=[...(E.drills??[]).filter(He=>He.source!==X),...O];J.length===0?delete E.drills:E.drills=J})}),y.jsx(vp,{anchor:Ze,settings:Y,onClose:()=>ye(null),onCommit:O=>f.update(E=>{E.title=O.title,O.description===void 0?delete E.description:E.description=O.description,O.columns===void 0?delete E.columns:E.columns=O.columns,O.autorun===void 0?delete E.autorun:E.autorun=O.autorun})}),y.jsx(lp,{open:De,document:f.document,catalog:a,columns:b,onClose:()=>me(!1),onAdd:re}),y.jsx(up,{open:Me!==void 0,before:Me?.before??"",after:Me?.after??"",onConfirm:ne,onClose:()=>Ge(void 0)})]})]})}function Ng(e,t){const n=new Set;for(const s of e.tiles)for(const o of s.filters??[])n.add(o.given);const r=[],i=new Set;for(const s of e.localGivens??[])n.has(s.name)&&(i.add(s.name),r.push(Gg(s)));for(const s of t)s.name===void 0||i.has(s.name)||!n.has(s.name)||(i.add(s.name),r.push(s));return r}function Gg(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 Vg(e,t,n,r=new Map){if(t.declaration.kind!=="reference")return{expression:`${t.source} -> ${t.name}`,givenNames:t.declaration.kind==="inherited"?void 0:[]};const i=t.source,s=new Map((e.localGivens??[]).map(d=>[d.name,d.type])),o=[],a=[];for(const d of t.filters??[]){const u=`where: ${d.field} ${d.op??"~"}`;if(n.has(d.given)){o.push(d.given),a.push(`${u} $${d.given}`);continue}if(!s.has(d.given))continue;const l=j.malloyLiteral(r.get(d.given),s.get(d.given));l!==void 0&&a.push(`${u} ${l}`)}const c=a.join(", ");return{expression:`${i} -> ${t.declaration.from}`+(c?` + { ${c} }`:""),givenNames:o}}async function Hg(e){const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t),n=>n.toString(16).padStart(2,"0")).join("")}const Ba=(e,t,n,r)=>({workspace:e,type:"dashboard",path:`${t}/${n}/${r}`});function Kg({environmentName:e,packageName:t,dashboardName:n,onExit:r,onEvent:i}){const{apiClients:s,mutable:o}=Pe.useServer(),a=Wd.useQueryClient(),c=S.useRef(j.now()),d=S.useRef(i);d.current=i;const u=j.useOptionalDocumentStorage()?.documentStorage,l=`dashboards/${n}.malloy`,f=j.useQueryWithApiError({queryKey:["dashboard-editor-model",e,t,l],queryFn:()=>s.models.getModel(e,t,l)}),g=f.data?.data?.sourceText,[h,m]=S.useState(void 0);S.useEffect(()=>{if(g===void 0)return;let Y=!1;return Hg(g).then(ee=>{Y||m(ee)}),()=>{Y=!0}},[g]);const[w,b]=S.useState(void 0),[v,p]=S.useState(void 0),[x,_]=S.useState(u===void 0),[$,T]=S.useState(!1);S.useEffect(()=>{if(!u)return;let Y=!1;return(async()=>{const H=(await u.listWorkspaces(!0))[0]?.name;if(Y)return;if(b(H),H===void 0){_(!0);return}const he=await u.getDocument(Ba(H,e,t,l)).catch(()=>{});Y||(p(he),T(he!==void 0),_(!0))})(),()=>{Y=!0}},[u,e,t,l]);const[D,I]=S.useState(void 0),C=D===!0&&v!==void 0,P=C?v:g,A=S.useRef("package");A.current=C?"draft":"package";const[R,U]=S.useState(void 0),[Te,De]=S.useState(void 0),me=S.useRef(void 0);S.useEffect(()=>{if(P===void 0||P===me.current)return;let Y=!1;return di(P).then(ee=>{if(!Y){if(ci(ee)){const H=ee.line?`${ee.reason} (line ${ee.line})`:ee.reason;De(H),d.current?.({type:"dashboard.open_refused",reason:H});return}De(void 0),U(H=>({source:P,document:ee.document,generation:(H?.generation??0)+1})),d.current?.({type:"dashboard.opened",from:A.current,tiles:ee.document.tiles.length,durationMs:j.now()-c.current})}}),()=>{Y=!0}},[P]);const X=w===void 0?void 0:Ba(w,e,t,l),Ye=S.useCallback(async Y=>{if(!u||!X)throw new Error("This host keeps no documents, so there is nowhere to save.");await u.saveDocument(X,Y),p(Y),I(ee=>ee??!1)},[u,X]),Ze=S.useCallback(async Y=>{if(h===void 0)throw new Error("The package file is still loading; try again.");let ee;try{ee=await s.models.updateModelSource(e,t,l,{source:Y,expectedHash:h})}catch(H){throw new Error(Ug(H))}me.current=Y,m(ee.data.contentHash),u&&X&&(await u.deleteDocument(X).catch(()=>{}),p(void 0),T(!1)),I(H=>H??!1),await a.invalidateQueries({queryKey:["dashboard-editor-model",e,t,l]});for(const H of["dashboard-editor-manifest","dashboards","dashboard"])a.invalidateQueries({queryKey:[H]})},[s,e,t,l,h,u,X,a]),ye=o?Ze:u&&X?Ye:void 0,Me=Y=>{c.current=j.now(),I(Y)};if(f.isError)return y.jsx(j.ApiErrorDisplay,{error:f.error,context:"Opening the dashboard"});if(!g||!x)return y.jsxs(k.Stack,{sx:{gap:2},children:[y.jsx(j.DashboardBar,{}),y.jsx(j.Loading,{text:"Opening the dashboard…"})]});if(Te)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened in the builder: ",Te]});const Ge=v!==void 0&&v!==g;return y.jsxs(k.Stack,{sx:{gap:2},children:[$&&Ge&&D===void 0&&y.jsx(k.Alert,{severity:"info",action:y.jsxs(k.Stack,{direction:"row",sx:{gap:1},children:[y.jsx(k.Button,{size:"small",onClick:()=>Me(!0),children:"Resume"}),y.jsx(k.Button,{size:"small",onClick:()=>Me(!1),children:"Start from the package"})]}),children:"You have edits to this dashboard saved in this browser that the package does not have."}),R&&y.jsx(qg,{environmentName:e,packageName:t,modelPath:l,slug:n,opened:R,onSave:ye,savesTo:o?"package":"browser",...i?{onEvent:i}:{},toolbar:r&&y.jsx(j.SecondaryButton,{label:"Done editing",icon:y.jsx(j.CheckIcon,{}),onClick:r}),note:o?"Save writes the file into the package.":u?"Saved in this browser: this server does not take writes.":"This server does not take writes."},R.generation)]})}function qg({environmentName:e,packageName:t,modelPath:n,slug:r,opened:i,onSave:s,onEvent:o,savesTo:a,toolbar:c,note:d}){const{apiClients:u}=Pe.useServer(),{data:l,isSuccess:f}=j.useQueryWithApiError({queryKey:["dashboard-editor-manifest",e,t,r],queryFn:()=>u.dashboards.getDashboard(e,t,r,void 0)}),g=l?.data,{data:h}=j.useQueryWithApiError({queryKey:["dashboard-editor-dashboards",e,t],queryFn:()=>u.dashboards.listDashboards(e,t,void 0)}),m=S.useMemo(()=>(h?.data??[]).map(P=>P.name).filter(P=>!!P&&P!==r),[h,r]),w=S.useMemo(()=>{const P=n.slice(0,n.lastIndexOf("/")+1),A=new Set;for(const R of i.document.imports){const U=new URL(R.from,`https://malloy.invalid/${P}`);A.add(U.pathname.slice(1))}return[...A]},[i.document.imports,n]),{data:b}=j.useQueryWithApiError({queryKey:["dashboard-editor-catalog",e,t,...w],queryFn:async()=>{const P=await Promise.all(w.map(A=>u.models.getModel(e,t,A).then(R=>R.data)));return ld(P)},enabled:w.length>0}),[v,p]=S.useState(i.document);S.useEffect(()=>p(i.document),[i.document]);const x=S.useMemo(()=>g?.givens??[],[g]),_=S.useMemo(()=>new Set(x.map(P=>P.name).filter(P=>P!==void 0)),[x]),$=S.useMemo(()=>Ng(v,x),[v,x]),{declaredTypes:T,applied:D,panel:I}=j.useDocumentControls({specs:$,loaded:f,startingValues:g?.startingGivens,documentKey:`${e}/${t}/${r}/edit`,autorun:g?.autorun!==!1,environmentName:e,packageName:t,modelPath:g?.path,documentName:r}),C=S.useMemo(()=>function(A){const R=Vg(v,A,_,D);return y.jsx(j.DashboardTile,{environmentName:e,packageName:t,modelPath:n,tile:R.expression,label:A.label??j.tileTitle(`${A.source} -> ${A.name}`),subtitle:A.subtitle,borderless:A.borderless,givens:D,declaredTypes:T,givenNames:R.givenNames,height:j.TILE_MAX_HEIGHT})},[v,_,e,t,n,D,T]);return y.jsxs(k.Stack,{sx:{gap:1},children:[y.jsx(Od,{source:i.source,document:i.document,renderTile:C,givens:$.filter(P=>P.name!==void 0).map(P=>({name:P.name,...P.label?{label:P.label}:{},...P.type?{type:P.type}:{},...P.suggest?.dimension?{field:P.suggest.dimension}:{}})),onChange:p,...b?{catalog:b}:{},dashboards:m,...o?{onEvent:o}:{},toolbar:c,controls:f?y.jsx(j.GivensPanel,{...I,layout:"bar"}):void 0,...s?{onSave:s}:{},savesTo:a}),y.jsx(k.Box,{sx:{px:.5},children:y.jsx(k.Typography,{variant:"caption",sx:{opacity:.7},children:d})})]})}function Ug(e){const t=e.response?.data;return t?.message?t.message:e instanceof Error?e.message:String(e)}typeof globalThis.process>"u"?globalThis.process={env:{}}:globalThis.process.env===void 0&&(globalThis.process.env={});exports.DashboardBuilder=Od;exports.DashboardEditor=Kg;exports.buildCatalog=ld;exports.readDashboardDocument=di;exports.readFailed=ci;exports.spliceDashboardDocument=Rs;exports.spliceFailed=js;
@@ -0,0 +1,2 @@
1
+ export * from '../builder-entry'
2
+ export {}