@malloy-publisher/sdk 0.2.7 → 0.3.1

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