@nuraly/runtime 0.1.7 → 0.1.8

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 (349) hide show
  1. package/README.md +83 -765
  2. package/components/ui/components/Event/EventValue/EventValue.ts +13 -8
  3. package/components/ui/components/ToastContainer/ToastContainer.ts +1 -1
  4. package/components/ui/components/advanced/AIChat/AIChat.ts +1 -2
  5. package/components/ui/components/advanced/Collapse/Collapse.ts +5 -2
  6. package/components/ui/components/advanced/Collections/Collections.ts +2 -2
  7. package/components/ui/components/advanced/MicroApp/MicroApp.ts +3 -11
  8. package/components/ui/components/advanced/RefComponent/RefComponent.ts +2 -2
  9. package/components/ui/components/advanced/RichText/RichText.ts +5 -4
  10. package/components/ui/components/advanced/RichText/RichTextEditor.ts +0 -167
  11. package/components/ui/components/base/BaseElement/base-change-detection.ts +1 -5
  12. package/components/ui/components/base/BaseElement.ts +229 -610
  13. package/components/ui/components/base/FormRegisterable.ts +83 -0
  14. package/components/ui/components/base/controllers/DragDropController.ts +175 -0
  15. package/components/ui/components/base/controllers/ErrorController.ts +180 -0
  16. package/components/ui/components/base/controllers/EventController.ts +112 -0
  17. package/components/ui/components/base/controllers/InputHandlerController.ts +298 -0
  18. package/components/ui/components/base/controllers/SelectionController.ts +323 -0
  19. package/components/ui/components/base/controllers/StyleHandlerController.ts +286 -0
  20. package/components/ui/components/base/controllers/index.ts +11 -0
  21. package/components/ui/components/base/mixins/EditorModeMixin.ts +185 -0
  22. package/components/ui/components/base/mixins/index.ts +6 -0
  23. package/components/ui/components/base/types/base-element.types.ts +138 -0
  24. package/components/ui/components/base/types/index.ts +21 -0
  25. package/components/ui/components/base/utils/event-debouncer.ts +209 -0
  26. package/components/ui/components/base/utils/index.ts +11 -0
  27. package/components/ui/components/base/utils/style-cache.ts +94 -0
  28. package/components/ui/components/display/BoxModel/BoxModel.ts +177 -116
  29. package/components/ui/components/display/Code/Code.ts +40 -26
  30. package/components/ui/components/display/Divider/Divider.ts +2 -2
  31. package/components/ui/components/display/Icon/Icon.ts +2 -3
  32. package/components/ui/components/display/Image/Image.ts +72 -46
  33. package/components/ui/components/display/Tag/Tag.ts +2 -3
  34. package/components/ui/components/display/Video/Video.ts +91 -31
  35. package/components/ui/components/inputs/Button/Button.ts +2 -2
  36. package/components/ui/components/inputs/Checkbox/Checkbox.ts +14 -40
  37. package/components/ui/components/inputs/ColorPicker/colorpicker.ts +3 -4
  38. package/components/ui/components/inputs/DatePicker/DatePicker.ts +47 -25
  39. package/components/ui/components/inputs/Dropdown/Dropdown.ts +2 -2
  40. package/components/ui/components/inputs/Form/Form.style.ts +26 -0
  41. package/components/ui/components/inputs/Form/Form.ts +352 -0
  42. package/components/ui/components/inputs/IconPicker/IconPicker.ts +22 -18
  43. package/components/ui/components/inputs/InsertDropdown/InsertDropdown.ts +0 -20
  44. package/components/ui/components/inputs/NumberInput/NumberInput.ts +0 -4
  45. package/components/ui/components/inputs/RadioButton/Radio-button.ts +11 -13
  46. package/components/ui/components/inputs/Select/Select.ts +38 -24
  47. package/components/ui/components/inputs/TextInput/TextInput.ts +15 -9
  48. package/components/ui/components/inputs/Textarea/Textarea.ts +30 -30
  49. package/components/ui/components/inputs/UsersDropdown/UsersDropdown.ts +1 -1
  50. package/components/ui/components/layout/Card/Card.ts +112 -10
  51. package/components/ui/components/layout/Containers/Container.style.ts +18 -0
  52. package/components/ui/components/layout/Containers/Container.ts +11 -5
  53. package/components/ui/components/layout/Grid/Col.style.ts +27 -0
  54. package/components/ui/components/layout/Grid/Col.ts +209 -0
  55. package/components/ui/components/layout/Grid/Row.style.ts +73 -0
  56. package/components/ui/components/layout/Grid/Row.ts +166 -0
  57. package/components/ui/components/layout/Grid/index.ts +7 -0
  58. package/components/ui/components/layout/Panel/Panel.ts +2 -2
  59. package/components/ui/components/layout/Tabs/Tabs.ts +0 -1
  60. package/components/ui/components/navigation/EmbedURL/EmbedURL.ts +62 -26
  61. package/components/ui/components/navigation/Link/Link.ts +27 -16
  62. package/components/ui/components/navigation/Menu/Menu.ts +26 -48
  63. package/components/ui/components/runtime/MicroApp/MicroApp.ts +7 -147
  64. package/components/ui/components/runtime/MicroApp/MicroAppDataLoader.ts +6 -2
  65. package/components/ui/components/studio/FunctionsPanel/FunctionsPanel.ts +472 -0
  66. package/components/ui/components/studio/FunctionsPanel/index.ts +1 -0
  67. package/components/ui/components/utility/AccessRoles/AccessRoles.style.ts +242 -0
  68. package/components/ui/components/utility/AccessRoles/AccessRoles.ts +476 -0
  69. package/components/ui/components/utility/Border/Border.ts +0 -14
  70. package/components/ui/components/utility/BorderManager/BorderManager.style.ts +237 -0
  71. package/components/ui/components/utility/BorderManager/BorderManager.ts +503 -0
  72. package/components/ui/components/utility/BoxShadow/BoxShadow.ts +0 -16
  73. package/components/ui/components/utility/Document/Document.ts +54 -25
  74. package/components/ui/components/utility/Export-Import/Export-Import.ts +8 -7
  75. package/components/ui/components/utility/Handlers/Handlers.ts +14 -17
  76. package/components/ui/components/utility/ValidationRules/ValidationRules.ts +440 -0
  77. package/components/ui/components/wrappers/GenerikWrapper/DragWrapper/DragWrapper.ts +1 -0
  78. package/components/ui/components/wrappers/GenerikWrapper/GenerikWrapper.ts +1 -24
  79. package/components/ui/nuraly-ui/src/components/badge/badge.style.ts +4 -3
  80. package/components/ui/nuraly-ui/src/components/datepicker/datepicker.component.ts +2 -0
  81. package/components/ui/nuraly-ui/src/components/radio-group/radio-group.component.ts +12 -6
  82. package/components/ui/nuraly-ui/src/components/radio-group/radio-group.style.ts +23 -0
  83. package/dist/{index-B4yIOSMd.js → BaseElement-BNBn_IJk.js} +2920 -267
  84. package/dist/{CodeEditor-YsOapSut.js → CodeEditor-Bf4L2rO_.js} +84127 -76319
  85. package/dist/{CodeEditor-BiNku87K.js → CodeEditor-Cpph-xRc.js} +7 -7
  86. package/dist/{abap-B2diVmjb.js → abap-D0Neqhq6.js} +91 -1
  87. package/dist/{apex-3NuJ-nsI.js → apex-B5LhxkeG.js} +18 -1
  88. package/dist/assets/editor.worker-DcwbJ0PV.js +12 -0
  89. package/dist/assets/html.worker-BTMxskjR.js +461 -0
  90. package/dist/assets/json.worker-D3vTGdf_.js +49 -0
  91. package/dist/assets/ts.worker-BsM1BXac.js +51334 -0
  92. package/dist/{azcli-XGXuUsMB.js → azcli-BrBH0QTU.js} +1 -1
  93. package/dist/{bat-B8Vhm634.js → bat-BfzAov64.js} +12 -1
  94. package/dist/{bicep-Cc8X5S_k.js → bicep-C3bCSWel.js} +1 -1
  95. package/dist/{cameligo-Bo3wBh9T.js → cameligo-sFL5plcd.js} +13 -1
  96. package/dist/{clojure-CPoQlpIK.js → clojure-CfeExRz0.js} +14 -1
  97. package/dist/{coffee-BxvTGz39.js → coffee-Xws5K0WL.js} +11 -1
  98. package/dist/{cpp-5RpEV7vC.js → cpp-CqOUEpxN.js} +28 -23
  99. package/dist/{csharp-slXXP3fo.js → csharp-DVLiBOZb.js} +13 -1
  100. package/dist/{csp-B98p6-gH.js → csp-DVFp9bw5.js} +3 -1
  101. package/dist/{css-BDsDSAin.js → css-DwARn2R6.js} +8 -1
  102. package/dist/cssMode-DMsdy1N0.js +1577 -0
  103. package/dist/{cypher-Dc4IMouD.js → cypher-uY0Mffat.js} +8 -1
  104. package/dist/{dart-LhvE3yD2.js → dart-D27H-mX_.js} +18 -1
  105. package/dist/{dockerfile-CwzplJeZ.js → dockerfile-CmV85WZK.js} +5 -1
  106. package/dist/{ecl-DxW3FiJi.js → ecl--fKn7yzB.js} +9 -1
  107. package/dist/{elixir-BI40g7TU.js → elixir-DUhH17ON.js} +87 -1
  108. package/dist/{flow9-tR2v0bGz.js → flow9-B3Dx2LLe.js} +8 -1
  109. package/dist/{freemarker2-Bfqhwyij.js → freemarker2-D51H9HYi.js} +359 -7
  110. package/dist/{fsharp-BLAma0OT.js → fsharp-SyqBfUAR.js} +14 -1
  111. package/dist/{go-nYcD3y4Z.js → go-BbMR2tdT.js} +17 -1
  112. package/dist/{graphql-Dp1cHWmP.js → graphql-DDJE6tIl.js} +17 -1
  113. package/dist/{handlebars-DCgKNBmn.js → handlebars-CF6gdAX4.js} +38 -4
  114. package/dist/{hcl-6NT8Kbna.js → hcl-YBvpaUqf.js} +13 -1
  115. package/dist/{html-C6wR7sMB.js → html-c2n_zkM3.js} +37 -4
  116. package/dist/htmlMode-9IJTuZUh.js +1587 -0
  117. package/dist/{ini-BZCOLrEc.js → ini-Ct73dBtM.js} +10 -1
  118. package/dist/{java-DAMcfJbX.js → java-C_jlkwoG.js} +18 -1
  119. package/dist/{javascript-D1L5MTmg.js → javascript-DhEEBMxD.js} +3 -2
  120. package/dist/jsonMode-CB6k-4rp.js +2002 -0
  121. package/dist/{julia-CQ46G71H.js → julia-D8WE5U1e.js} +22 -1
  122. package/dist/{kotlin-CEjVo_6E.js → kotlin-Zy9aq5yB.js} +15 -1
  123. package/dist/{less-DreV99nP.js → less-sZ0iHtE8.js} +1 -1
  124. package/dist/{lexon-DBVJhqLb.js → lexon-CsdNL29A.js} +13 -1
  125. package/dist/{liquid-D_pDYIs1.js → liquid-CwtPiwnW.js} +12 -4
  126. package/dist/{lua-Dcc_j6L-.js → lua-C2YJo0zw.js} +12 -1
  127. package/dist/{m3-B9SlZL4n.js → m3-CPLP40SG.js} +7 -1
  128. package/dist/{markdown-CuGw9_MP.js → markdown-B1mf5e0R.js} +34 -1
  129. package/dist/{mdx-CKsJ3cF4.js → mdx-LewPRYF8.js} +2 -2
  130. package/dist/{micro-app-entry-xdTX5-ut.js → micro-app-entry-C3RDIukG.js} +8082 -9628
  131. package/dist/micro-app.bundle.js +3 -3
  132. package/dist/micro-app.js +3585 -6759
  133. package/dist/{mips-BUWqP-OH.js → mips-DA33BZX1.js} +11 -1
  134. package/dist/{msdax-DtkouYCg.js → msdax-CCYFIQsP.js} +5 -1
  135. package/dist/{mysql-IkAsWSmF.js → mysql-hjmIjL-D.js} +11 -3
  136. package/dist/{objective-c-B2-ronfg.js → objective-c-RRCpEmqC.js} +2 -1
  137. package/dist/{pascal-Bsnz2eJA.js → pascal-CeV8XfxB.js} +13 -1
  138. package/dist/{pascaligo-D_sMUn0Q.js → pascaligo-IEEGVJAJ.js} +13 -1
  139. package/dist/{perl-BPzHt9SS.js → perl-B5-QbHq_.js} +34 -1
  140. package/dist/{pgsql-DlTJB0PD.js → pgsql-s6kqEJmi.js} +14 -4
  141. package/dist/{php-Dmq5OjwK.js → php-CWWqzOo8.js} +36 -1
  142. package/dist/{pla-HJcccrBy.js → pla-FSvb_YP_.js} +13 -1
  143. package/dist/{postiats-OQn6DKv-.js → postiats-DQdscQXO.js} +370 -1
  144. package/dist/{powerquery-DKaMYC8w.js → powerquery-CtA5JA1I.js} +7 -1
  145. package/dist/{powershell-DWeJHik1.js → powershell-DglEq96N.js} +13 -1
  146. package/dist/{protobuf-CBn_IseU.js → protobuf-BSepub3e.js} +5 -1
  147. package/dist/{pug-BoRpCINl.js → pug-B1847F4G.js} +16 -1
  148. package/dist/{python-zPpZYwLF.js → python-h5Z2g-yl.js} +59 -11
  149. package/dist/{qsharp-4rGyVZOw.js → qsharp-D4i0Nqg9.js} +28 -3
  150. package/dist/{r-DsgLhBOb.js → r-cdRigKxa.js} +5 -1
  151. package/dist/{razor-B_fCUeGX.js → razor-D5ep1Doy.js} +48 -4
  152. package/dist/{redis-B2fdL4Bg.js → redis-D9MFxvE8.js} +16 -6
  153. package/dist/{redshift-DoaeyCkH.js → redshift-CmCnsvL-.js} +13 -4
  154. package/dist/{restructuredtext-D-6OFBY9.js → restructuredtext-CWy8J51t.js} +19 -1
  155. package/dist/{ruby-D1DD6baV.js → ruby-WP-c36m5.js} +76 -3
  156. package/dist/runtime.js +34 -45
  157. package/dist/{rust-DssUV39M.js → rust-Q9FLdYpu.js} +13 -1
  158. package/dist/{sb-Dmb6tAdv.js → sb-C54-JBGT.js} +12 -1
  159. package/dist/{scala-Co3ETaym.js → scala-CzbFImc5.js} +24 -1
  160. package/dist/{scheme-CMrqXTty.js → scheme-BhfDmYN3.js} +1 -1
  161. package/dist/{scss-DkGudv8Q.js → scss-CEmiBXpS.js} +25 -1
  162. package/dist/{shell-BHN2BI4L.js → shell-Bmc1VhG0.js} +4 -1
  163. package/dist/{solidity-b-R-raGB.js → solidity-C9Q2I8Hh.js} +23 -1
  164. package/dist/{sophia-Y4GjyxNB.js → sophia-jWa1UyKz.js} +16 -1
  165. package/dist/{sparql-CDAPZb88.js → sparql-CM7jctbc.js} +15 -1
  166. package/dist/{sql-DkkpPiUq.js → sql-WzihTkbg.js} +42 -1
  167. package/dist/{st-CSPV91Ej.js → st-6y7_3aup.js} +8 -1
  168. package/dist/style.css +1 -1
  169. package/dist/{swift-DdSC5O48.js → swift-k-0zxG_D.js} +4 -1
  170. package/dist/{systemverilog-CI03XpAv.js → systemverilog-Pnr5_rIP.js} +29 -3
  171. package/dist/{tcl-B8DayMSI.js → tcl-fNPXval8.js} +7 -1
  172. package/dist/tsMode-B_6LiBE1.js +976 -0
  173. package/dist/{twig-B1AUPVB_.js → twig-L2MkztkV.js} +76 -1
  174. package/dist/{typescript-DrlYcCUn.js → typescript-BBG0jH4p.js} +23 -2
  175. package/dist/typespec-Cqqo-3Pt.js +123 -0
  176. package/dist/{vb-BIC7ccdG.js → vb-B5YC2xN9.js} +15 -1
  177. package/dist/{wgsl-C9yjop46.js → wgsl-D9BRtftY.js} +26 -1
  178. package/dist/{xml-BzP9D0eZ.js → xml-DgLB7rE6.js} +8 -2
  179. package/dist/{yaml-CT7GOvXu.js → yaml-DiI4HpSv.js} +30 -2
  180. package/handlers/compiler.ts +196 -16
  181. package/handlers/context-setup.ts +10 -5
  182. package/handlers/handler-api-factory.ts +358 -0
  183. package/handlers/handler-api.ts +379 -0
  184. package/handlers/handler-executor.ts +25 -5
  185. package/handlers/handler-scope.ts +398 -0
  186. package/handlers/index.ts +34 -2
  187. package/handlers/runtime-api/component-properties.ts +0 -8
  188. package/handlers/runtime-api/index.ts +1 -1
  189. package/handlers/runtime-api/toast.ts +1 -1
  190. package/index.ts +14 -115
  191. package/micro-app/README.md +10 -10
  192. package/micro-app/state/MicroAppRuntimeContext.ts +1 -28
  193. package/micro-app-entry.ts +0 -5
  194. package/package.json +19 -1
  195. package/redux/actions/application/index.ts +0 -1
  196. package/redux/actions/component/addComponentAction.ts +15 -4
  197. package/redux/actions/component/moveDraggedComponent.ts +1 -2
  198. package/redux/actions/component/update-component-name.ts +1 -1
  199. package/redux/actions/component/updateComponentAttributes.ts +7 -2
  200. package/redux/handlers/functions/build-function-handler.ts +11 -3
  201. package/redux/handlers/functions/deploy-function-handler.ts +11 -3
  202. package/redux/handlers/functions/invoke-function-handler.ts +11 -3
  203. package/redux/handlers/functions/load-functions-handler.ts +2 -1
  204. package/redux/handlers/functions/update-function-handler.ts +2 -1
  205. package/redux/store/component/component.interface.ts +8 -2
  206. package/redux/store/component/store.ts +1 -4
  207. package/state/runtime-context.ts +1 -23
  208. package/utils/RuntimeContextHelpers.ts +221 -90
  209. package/utils/change-detection.ts +125 -1
  210. package/utils/clipboard-utils.ts +18 -8
  211. package/utils/component-registry.ts +118 -0
  212. package/utils/index.ts +14 -1
  213. package/utils/naming-generator.ts +3 -1
  214. package/utils/randomness.ts +3 -1
  215. package/utils/register-components.ts +21 -29
  216. package/utils/render-util.ts +27 -48
  217. package/utils/toast.ts +97 -0
  218. package/vite.config.ts +29 -12
  219. package/components/ui/components/Event/EventAttribute/EventAttribute.style.ts +0 -11
  220. package/components/ui/components/Event/EventAttribute/EventAttribute.ts +0 -28
  221. package/components/ui/components/base/BaseElement/calculateStyles.ts +0 -31
  222. package/components/ui/components/base/BaseElement/drag-events.helpers.ts +0 -71
  223. package/components/ui/components/base/BaseElement/execute-event.helpers.ts +0 -45
  224. package/components/ui/components/base/BaseElement/interactions.helpers.ts +0 -14
  225. package/components/ui/components/wrappers/ComponentTitle/ComponentTitle.ts +0 -95
  226. package/components/ui/components/wrappers/GenerikWrapper/ResizeWrapper/ResizeWrapper.style.ts +0 -102
  227. package/components/ui/components/wrappers/GenerikWrapper/ResizeWrapper/ResizeWrapper.ts +0 -258
  228. package/components/ui/components/wrappers/PreviewWrapper.ts +0 -28
  229. package/components/ui/components/wrappers/RectangleSelection/RectangleSelection.ts +0 -154
  230. package/components/ui/nuraly-ui/packages/common/dist/constants/index.d.ts +0 -2
  231. package/components/ui/nuraly-ui/packages/common/dist/constants/index.js +0 -2
  232. package/components/ui/nuraly-ui/packages/common/dist/constants.d.ts +0 -17
  233. package/components/ui/nuraly-ui/packages/common/dist/constants.js +0 -7
  234. package/components/ui/nuraly-ui/packages/common/dist/controllers/index.d.ts +0 -2
  235. package/components/ui/nuraly-ui/packages/common/dist/controllers/index.js +0 -2
  236. package/components/ui/nuraly-ui/packages/common/dist/controllers.d.ts +0 -21
  237. package/components/ui/nuraly-ui/packages/common/dist/controllers.js +0 -22
  238. package/components/ui/nuraly-ui/packages/common/dist/index.d.ts +0 -25
  239. package/components/ui/nuraly-ui/packages/common/dist/index.js +0 -27
  240. package/components/ui/nuraly-ui/packages/common/dist/mixins/index.d.ts +0 -2
  241. package/components/ui/nuraly-ui/packages/common/dist/mixins/index.js +0 -3
  242. package/components/ui/nuraly-ui/packages/common/dist/mixins.d.ts +0 -26
  243. package/components/ui/nuraly-ui/packages/common/dist/mixins.js +0 -29
  244. package/components/ui/nuraly-ui/packages/common/dist/shared/base-mixin.d.ts +0 -42
  245. package/components/ui/nuraly-ui/packages/common/dist/shared/base-mixin.js +0 -38
  246. package/components/ui/nuraly-ui/packages/common/dist/shared/constants.d.ts +0 -1
  247. package/components/ui/nuraly-ui/packages/common/dist/shared/constants.js +0 -2
  248. package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/dropdown.controller.d.ts +0 -77
  249. package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/dropdown.controller.js +0 -341
  250. package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/dropdown.interface.d.ts +0 -37
  251. package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/dropdown.interface.js +0 -2
  252. package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/index.d.ts +0 -4
  253. package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/index.js +0 -4
  254. package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/theme.controller.d.ts +0 -48
  255. package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/theme.controller.js +0 -133
  256. package/components/ui/nuraly-ui/packages/common/dist/shared/dependency-mixin.d.ts +0 -37
  257. package/components/ui/nuraly-ui/packages/common/dist/shared/dependency-mixin.js +0 -141
  258. package/components/ui/nuraly-ui/packages/common/dist/shared/event-handler-mixin.d.ts +0 -64
  259. package/components/ui/nuraly-ui/packages/common/dist/shared/event-handler-mixin.js +0 -95
  260. package/components/ui/nuraly-ui/packages/common/dist/shared/index.d.ts +0 -13
  261. package/components/ui/nuraly-ui/packages/common/dist/shared/index.js +0 -17
  262. package/components/ui/nuraly-ui/packages/common/dist/shared/theme-mixin.d.ts +0 -78
  263. package/components/ui/nuraly-ui/packages/common/dist/shared/theme-mixin.js +0 -194
  264. package/components/ui/nuraly-ui/packages/common/dist/shared/themes.d.ts +0 -44
  265. package/components/ui/nuraly-ui/packages/common/dist/shared/themes.js +0 -85
  266. package/components/ui/nuraly-ui/packages/common/dist/shared/utils.d.ts +0 -60
  267. package/components/ui/nuraly-ui/packages/common/dist/shared/utils.js +0 -85
  268. package/components/ui/nuraly-ui/packages/common/dist/shared/validation.types.d.ts +0 -108
  269. package/components/ui/nuraly-ui/packages/common/dist/shared/validation.types.js +0 -17
  270. package/components/ui/nuraly-ui/packages/common/dist/themes/index.d.ts +0 -2
  271. package/components/ui/nuraly-ui/packages/common/dist/themes/index.js +0 -2
  272. package/components/ui/nuraly-ui/packages/common/dist/themes.d.ts +0 -22
  273. package/components/ui/nuraly-ui/packages/common/dist/themes.js +0 -23
  274. package/components/ui/nuraly-ui/packages/common/dist/utils/index.d.ts +0 -2
  275. package/components/ui/nuraly-ui/packages/common/dist/utils/index.js +0 -2
  276. package/components/ui/nuraly-ui/packages/common/dist/utils.d.ts +0 -21
  277. package/components/ui/nuraly-ui/packages/common/dist/utils.js +0 -22
  278. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/LICENSE +0 -15
  279. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/README.md +0 -294
  280. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/copy/copy-sync.js +0 -171
  281. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/copy/copy.js +0 -175
  282. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/copy/index.js +0 -7
  283. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/empty/index.js +0 -39
  284. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/ensure/file.js +0 -66
  285. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/ensure/index.js +0 -23
  286. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/ensure/link.js +0 -64
  287. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/ensure/symlink-paths.js +0 -101
  288. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/ensure/symlink-type.js +0 -34
  289. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/ensure/symlink.js +0 -67
  290. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/fs/index.js +0 -146
  291. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/index.js +0 -16
  292. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/json/index.js +0 -16
  293. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/json/jsonfile.js +0 -11
  294. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/json/output-json-sync.js +0 -12
  295. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/json/output-json.js +0 -12
  296. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/mkdirs/index.js +0 -14
  297. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/mkdirs/make-dir.js +0 -27
  298. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/mkdirs/utils.js +0 -21
  299. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/move/index.js +0 -7
  300. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/move/move-sync.js +0 -55
  301. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/move/move.js +0 -59
  302. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/output-file/index.js +0 -31
  303. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/path-exists/index.js +0 -12
  304. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/remove/index.js +0 -17
  305. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/util/async.js +0 -29
  306. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/util/stat.js +0 -159
  307. package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/util/utimes.js +0 -36
  308. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/LICENSE +0 -15
  309. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/README.md +0 -294
  310. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/copy/copy-sync.js +0 -171
  311. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/copy/copy.js +0 -175
  312. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/copy/index.js +0 -7
  313. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/empty/index.js +0 -39
  314. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/ensure/file.js +0 -66
  315. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/ensure/index.js +0 -23
  316. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/ensure/link.js +0 -64
  317. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/ensure/symlink-paths.js +0 -101
  318. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/ensure/symlink-type.js +0 -34
  319. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/ensure/symlink.js +0 -67
  320. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/fs/index.js +0 -146
  321. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/index.js +0 -16
  322. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/json/index.js +0 -16
  323. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/json/jsonfile.js +0 -11
  324. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/json/output-json-sync.js +0 -12
  325. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/json/output-json.js +0 -12
  326. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/mkdirs/index.js +0 -14
  327. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/mkdirs/make-dir.js +0 -27
  328. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/mkdirs/utils.js +0 -21
  329. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/move/index.js +0 -7
  330. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/move/move-sync.js +0 -55
  331. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/move/move.js +0 -59
  332. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/output-file/index.js +0 -31
  333. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/path-exists/index.js +0 -12
  334. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/remove/index.js +0 -17
  335. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/util/async.js +0 -29
  336. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/util/stat.js +0 -159
  337. package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/util/utimes.js +0 -36
  338. package/dist/SmartAttributeHandler-C4EliaG0.js +0 -153
  339. package/dist/SmartAttributeHandler-u-ZHGueR.js +0 -193
  340. package/dist/assets/editor.worker-C_S4Avdt.js +0 -11
  341. package/dist/assets/html.worker-DfuQASUV.js +0 -458
  342. package/dist/assets/json.worker-Cucz4wxY.js +0 -42
  343. package/dist/assets/ts.worker-Dme6S0YK.js +0 -37021
  344. package/dist/cssMode-CqMQ6Xsa.js +0 -1443
  345. package/dist/htmlMode-KglxyZXm.js +0 -1453
  346. package/dist/jsonMode-B3rqxD-b.js +0 -1863
  347. package/dist/tsMode-DEiq8fQ0.js +0 -800
  348. package/redux/actions/application/loadApplicationPermissionAction.ts +0 -10
  349. package/utils/styleUtil.ts +0 -7
@@ -1,13 +1,15 @@
1
- import { Subject, Observable } from 'rxjs';
2
- import Database from '@nuraly/dbclient';
3
- import * as acorn from 'acorn';
4
- import * as walk from 'acorn-walk';
1
+ import { css, LitElement, html, nothing } from 'lit';
2
+ import { customElement, property, state } from 'lit/decorators.js';
3
+ import { createRef } from 'lit/directives/ref.js';
5
4
  import { v4 } from 'uuid';
6
- import deepEqual from 'fast-deep-equal';
7
- import { atom, deepMap, keepMount, onMount, computed, onNotify } from 'nanostores';
8
- import { persistentAtom } from '/Users/aymen/Desktop/projects/nuraly/stack/services/studio/node_modules/@nanostores/persistent/index.js';
9
- import { html } from 'lit';
5
+ import { Subject, Observable, Subscription } from 'rxjs';
10
6
  import { share } from 'rxjs/operators';
7
+ import { atom, deepMap, keepMount, onMount, computed, onNotify } from 'nanostores';
8
+ import { persistentAtom } from '/home/runner/work/runtime/runtime/node_modules/@nanostores/persistent/index.js';
9
+ import deepEqual from 'fast-deep-equal';
10
+ import * as acorn from 'acorn';
11
+ import * as walk from 'acorn-walk';
12
+ import { styleMap } from 'lit/directives/style-map.js';
11
13
 
12
14
  const isServer$4 = typeof window === "undefined";
13
15
  if (!isServer$4) {
@@ -157,6 +159,19 @@ class EventDispatcher {
157
159
  this.subjects = {};
158
160
  this.subscriptions = {};
159
161
  this.globalEventSubject = new Subject();
162
+ // Batching state
163
+ this.pendingEvents = /* @__PURE__ */ new Map();
164
+ this.batchScheduled = false;
165
+ this.batchingEnabled = true;
166
+ // Events that should always be batched (high-frequency property changes)
167
+ this.batchableEventPatterns = [
168
+ /^component-property-changed:/,
169
+ /^microapp:.*:component-property-changed:/,
170
+ /^Vars:/,
171
+ /^microapp:.*:Vars:/,
172
+ /^component:value:set:/,
173
+ /^microapp:.*:component-instance-changed:/
174
+ ];
160
175
  this.allEvents$ = this.globalEventSubject.asObservable().pipe(share());
161
176
  }
162
177
  static getInstance() {
@@ -190,16 +205,97 @@ class EventDispatcher {
190
205
  this.subscriptions[event].delete(listener);
191
206
  }
192
207
  }
193
- emit(event, data) {
208
+ /**
209
+ * Check if an event should be batched based on patterns
210
+ */
211
+ shouldBatch(event) {
212
+ if (!this.batchingEnabled) return false;
213
+ return this.batchableEventPatterns.some((pattern) => pattern.test(event));
214
+ }
215
+ /**
216
+ * Flush all pending batched events
217
+ */
218
+ flushBatch() {
219
+ const events = Array.from(this.pendingEvents.values());
220
+ this.pendingEvents.clear();
221
+ for (const { event, data } of events) {
222
+ this.emitImmediate(event, data);
223
+ }
224
+ this.batchScheduled = false;
225
+ if (this.pendingEvents.size > 0) {
226
+ this.batchScheduled = true;
227
+ queueMicrotask(() => this.flushBatch());
228
+ }
229
+ }
230
+ /**
231
+ * Emit an event immediately without batching
232
+ */
233
+ emitImmediate(event, data) {
194
234
  this.getSubject(event).next(data);
195
235
  this.globalEventSubject.next({ eventName: event, data });
196
236
  }
237
+ /**
238
+ * Emit an event, with automatic batching for high-frequency events.
239
+ *
240
+ * For events matching batchable patterns (property changes, variable updates),
241
+ * multiple rapid emissions are coalesced into a single microtask.
242
+ *
243
+ * This prevents UI jank when many properties are updated in quick succession.
244
+ *
245
+ * @param event - Event name
246
+ * @param data - Event data
247
+ */
248
+ emit(event, data) {
249
+ if (this.shouldBatch(event)) {
250
+ this.pendingEvents.set(event, { event, data });
251
+ if (!this.batchScheduled) {
252
+ this.batchScheduled = true;
253
+ queueMicrotask(() => this.flushBatch());
254
+ }
255
+ } else {
256
+ this.emitImmediate(event, data);
257
+ }
258
+ }
259
+ /**
260
+ * Force immediate emission, bypassing batching.
261
+ * Use this when you need synchronous event delivery.
262
+ *
263
+ * @param event - Event name
264
+ * @param data - Event data
265
+ */
266
+ emitSync(event, data) {
267
+ this.emitImmediate(event, data);
268
+ }
269
+ /**
270
+ * Enable or disable batching globally.
271
+ * Useful for debugging or when synchronous updates are required.
272
+ *
273
+ * @param enabled - Whether batching should be enabled
274
+ */
275
+ setBatchingEnabled(enabled) {
276
+ this.batchingEnabled = enabled;
277
+ }
278
+ /**
279
+ * Check if batching is currently enabled
280
+ */
281
+ isBatchingEnabled() {
282
+ return this.batchingEnabled;
283
+ }
284
+ /**
285
+ * Manually flush any pending batched events.
286
+ * Useful when you need to force updates before an operation.
287
+ */
288
+ flushPendingEvents() {
289
+ if (this.pendingEvents.size > 0) {
290
+ this.flushBatch();
291
+ }
292
+ }
197
293
  }
198
294
  const eventDispatcher = EventDispatcher.getInstance();
199
295
 
200
296
  const isServer$1 = typeof window === "undefined";
201
297
  const initialStates = isServer$1 ? [] : JSON.parse(window["__INITIAL_COMPONENT_STATE__"] ?? "[]");
202
- const initialState$1 = isServer$1 ? {} : {};
298
+ const initialState$1 = {};
203
299
  if (currentLoadedApplication) {
204
300
  initialState$1[currentLoadedApplication.uuid] = initialStates;
205
301
  }
@@ -264,14 +360,11 @@ const setComponentRuntimeValue = (componentId, key, value) => {
264
360
  if (!componentId) {
265
361
  console.error("Cannot set runtime value: componentId is undefined");
266
362
  return;
267
- } else {
268
- console.log("setComponentRuntimeValue", componentId, key, value);
269
363
  }
270
364
  $runtimeValues.setKey(componentId, {
271
365
  ...$runtimeValues.get()[componentId],
272
366
  [key]: value
273
367
  });
274
- console.log($runtimeValues.get()[componentId]);
275
368
  eventDispatcher.emit("component:value:change", {
276
369
  componentId,
277
370
  key,
@@ -993,9 +1086,321 @@ function validateComponentHandlers(component) {
993
1086
  };
994
1087
  }
995
1088
 
1089
+ const RESERVED_NAMES = /* @__PURE__ */ new Set([
1090
+ // Core runtime parameters
1091
+ "eventHandler",
1092
+ "Components",
1093
+ "Editor",
1094
+ "Event",
1095
+ "Item",
1096
+ "Current",
1097
+ "currentPlatform",
1098
+ "Values",
1099
+ "Apps",
1100
+ "Vars",
1101
+ "Instance",
1102
+ // Namespaced APIs (new clean API)
1103
+ "Nav",
1104
+ "UI",
1105
+ "Component",
1106
+ "Data",
1107
+ "Page",
1108
+ "App",
1109
+ "Var",
1110
+ // Variable functions
1111
+ "SetVar",
1112
+ "GetContextVar",
1113
+ "GetVar",
1114
+ "SetContextVar",
1115
+ // Component functions
1116
+ "GetComponent",
1117
+ "GetComponents",
1118
+ "AddComponent",
1119
+ "DeleteComponentAction",
1120
+ "CopyComponentToClipboard",
1121
+ "PasteComponentFromClipboard",
1122
+ // Application functions
1123
+ "UpdateApplication",
1124
+ "context",
1125
+ "applications",
1126
+ // Page functions
1127
+ "AddPage",
1128
+ "UpdatePage",
1129
+ "deletePage",
1130
+ // Navigation functions
1131
+ "NavigateToUrl",
1132
+ "NavigateToHash",
1133
+ "NavigateToPage",
1134
+ // Property update functions
1135
+ "updateInput",
1136
+ "updateName",
1137
+ "updateEvent",
1138
+ "updateStyle",
1139
+ "updateStyleHandlers",
1140
+ // Editor functions
1141
+ "openEditorTab",
1142
+ "setCurrentEditorTab",
1143
+ "TraitCompoentFromSchema",
1144
+ // Other functions
1145
+ "InvokeFunction",
1146
+ "Utils",
1147
+ "console",
1148
+ "UploadFile",
1149
+ "BrowseFiles",
1150
+ "EventData",
1151
+ // Toast functions
1152
+ "ShowToast",
1153
+ "ShowSuccessToast",
1154
+ "ShowErrorToast",
1155
+ "ShowWarningToast",
1156
+ "ShowInfoToast",
1157
+ "HideToast",
1158
+ "ClearAllToasts",
1159
+ // JavaScript built-ins that must be preserved
1160
+ "undefined",
1161
+ "null",
1162
+ "true",
1163
+ "false",
1164
+ "NaN",
1165
+ "Infinity",
1166
+ "globalThis",
1167
+ "window",
1168
+ "self",
1169
+ // Common globals
1170
+ "Math",
1171
+ "JSON",
1172
+ "Date",
1173
+ "Array",
1174
+ "Object",
1175
+ "String",
1176
+ "Number",
1177
+ "Boolean",
1178
+ "RegExp",
1179
+ "Error",
1180
+ "TypeError",
1181
+ "ReferenceError",
1182
+ "SyntaxError",
1183
+ "Promise",
1184
+ "Map",
1185
+ "Set",
1186
+ "WeakMap",
1187
+ "WeakSet",
1188
+ "Symbol",
1189
+ "Proxy",
1190
+ "Reflect",
1191
+ "parseInt",
1192
+ "parseFloat",
1193
+ "isNaN",
1194
+ "isFinite",
1195
+ "encodeURI",
1196
+ "decodeURI",
1197
+ "encodeURIComponent",
1198
+ "decodeURIComponent",
1199
+ "setTimeout",
1200
+ "setInterval",
1201
+ "clearTimeout",
1202
+ "clearInterval",
1203
+ "fetch",
1204
+ "Request",
1205
+ "Response",
1206
+ "Headers",
1207
+ "URL",
1208
+ "URLSearchParams",
1209
+ "FormData",
1210
+ "Blob",
1211
+ "File",
1212
+ "FileReader",
1213
+ "atob",
1214
+ "btoa",
1215
+ "crypto",
1216
+ "performance",
1217
+ "queueMicrotask",
1218
+ "requestAnimationFrame",
1219
+ "cancelAnimationFrame",
1220
+ // Control flow keywords (not variables but good to have)
1221
+ "arguments",
1222
+ "this"
1223
+ ]);
1224
+ function isReactiveVar(prop) {
1225
+ return prop.startsWith("$") && prop.length > 1;
1226
+ }
1227
+ function stripPrefix(prop) {
1228
+ return prop.slice(1);
1229
+ }
1230
+ function createHandlerScope(config) {
1231
+ const { VarsProxy, parameters } = config;
1232
+ return new Proxy(parameters, {
1233
+ /**
1234
+ * The `has` trap is critical for `with` statement behavior.
1235
+ * We claim to have:
1236
+ * - All reserved names (handler parameters)
1237
+ * - All $-prefixed names (reactive variables)
1238
+ */
1239
+ has(target, prop) {
1240
+ const propStr = String(prop);
1241
+ if (RESERVED_NAMES.has(propStr)) {
1242
+ return true;
1243
+ }
1244
+ if (isReactiveVar(propStr)) {
1245
+ return true;
1246
+ }
1247
+ if (propStr in target) {
1248
+ return true;
1249
+ }
1250
+ return false;
1251
+ },
1252
+ /**
1253
+ * Get property value.
1254
+ * - Reserved names get their actual values
1255
+ * - $-prefixed names get from VarsProxy (without the $ prefix)
1256
+ * - Other names shouldn't reach here (has() returns false)
1257
+ */
1258
+ get(target, prop, receiver) {
1259
+ const propStr = String(prop);
1260
+ if (typeof prop === "symbol") {
1261
+ return target[prop];
1262
+ }
1263
+ if (isReactiveVar(propStr)) {
1264
+ const varName = stripPrefix(propStr);
1265
+ return VarsProxy[varName];
1266
+ }
1267
+ if (RESERVED_NAMES.has(propStr)) {
1268
+ if (propStr in target) {
1269
+ return target[propStr];
1270
+ }
1271
+ if (propStr in globalThis) {
1272
+ const value = globalThis[propStr];
1273
+ if (typeof value === "function" && ["fetch", "setTimeout", "setInterval", "clearTimeout", "clearInterval", "requestAnimationFrame", "cancelAnimationFrame", "queueMicrotask"].includes(propStr)) {
1274
+ return value.bind(globalThis);
1275
+ }
1276
+ return value;
1277
+ }
1278
+ return void 0;
1279
+ }
1280
+ if (propStr in target) {
1281
+ return target[propStr];
1282
+ }
1283
+ return void 0;
1284
+ },
1285
+ /**
1286
+ * Set property value.
1287
+ * - $-prefixed names set to VarsProxy (without the $ prefix)
1288
+ * - Reserved names update actual values
1289
+ * - Other names shouldn't reach here
1290
+ */
1291
+ set(target, prop, value, receiver) {
1292
+ const propStr = String(prop);
1293
+ if (typeof prop === "symbol") {
1294
+ target[prop] = value;
1295
+ return true;
1296
+ }
1297
+ if (isReactiveVar(propStr)) {
1298
+ const varName = stripPrefix(propStr);
1299
+ VarsProxy[varName] = value;
1300
+ return true;
1301
+ }
1302
+ if (RESERVED_NAMES.has(propStr) && propStr in globalThis) {
1303
+ if (propStr in target) {
1304
+ target[propStr] = value;
1305
+ return true;
1306
+ }
1307
+ return true;
1308
+ }
1309
+ if (propStr in target && RESERVED_NAMES.has(propStr)) {
1310
+ target[propStr] = value;
1311
+ return true;
1312
+ }
1313
+ target[propStr] = value;
1314
+ return true;
1315
+ },
1316
+ /**
1317
+ * Property descriptor for iteration support
1318
+ */
1319
+ getOwnPropertyDescriptor(target, prop) {
1320
+ const propStr = String(prop);
1321
+ if (isReactiveVar(propStr)) {
1322
+ const varName = stripPrefix(propStr);
1323
+ if (varName in VarsProxy) {
1324
+ return {
1325
+ configurable: true,
1326
+ enumerable: true,
1327
+ value: VarsProxy[varName],
1328
+ writable: true
1329
+ };
1330
+ }
1331
+ return {
1332
+ configurable: true,
1333
+ enumerable: true,
1334
+ value: void 0,
1335
+ writable: true
1336
+ };
1337
+ }
1338
+ if (propStr in target) {
1339
+ return Object.getOwnPropertyDescriptor(target, propStr);
1340
+ }
1341
+ return void 0;
1342
+ }
1343
+ });
1344
+ }
1345
+
1346
+ const CONTROL_FLOW_TYPES = /* @__PURE__ */ new Set([
1347
+ "IfStatement",
1348
+ "ForStatement",
1349
+ "ForInStatement",
1350
+ "ForOfStatement",
1351
+ "WhileStatement",
1352
+ "DoWhileStatement",
1353
+ "SwitchStatement",
1354
+ "TryStatement",
1355
+ "ThrowStatement"
1356
+ ]);
1357
+ function analyzeCode(code) {
1358
+ const trimmed = code.trim();
1359
+ if (!trimmed) {
1360
+ return { hasTopLevelReturn: false, hasControlFlow: false, isMultiStatement: false };
1361
+ }
1362
+ try {
1363
+ const wrappedCode = `(function() { ${trimmed} })`;
1364
+ const ast = acorn.parse(wrappedCode, {
1365
+ ecmaVersion: "latest",
1366
+ sourceType: "script"
1367
+ });
1368
+ const funcExpr = ast.body[0].expression;
1369
+ const bodyStatements = funcExpr.body.body;
1370
+ let hasTopLevelReturn = false;
1371
+ let hasControlFlow = false;
1372
+ const isMultiStatement = bodyStatements.length > 1;
1373
+ for (const stmt of bodyStatements) {
1374
+ if (stmt.type === "ReturnStatement") {
1375
+ hasTopLevelReturn = true;
1376
+ }
1377
+ if (CONTROL_FLOW_TYPES.has(stmt.type)) {
1378
+ hasControlFlow = true;
1379
+ }
1380
+ }
1381
+ return { hasTopLevelReturn, hasControlFlow, isMultiStatement };
1382
+ } catch {
1383
+ return { hasTopLevelReturn: true, hasControlFlow: false, isMultiStatement: false };
1384
+ }
1385
+ }
1386
+ function needsImplicitReturn(code) {
1387
+ const trimmed = code.trim();
1388
+ if (!trimmed) return false;
1389
+ const analysis = analyzeCode(trimmed);
1390
+ if (analysis.hasTopLevelReturn) return false;
1391
+ if (analysis.hasControlFlow) return false;
1392
+ if (analysis.isMultiStatement) return false;
1393
+ return true;
1394
+ }
1395
+ function wrapWithImplicitReturn(code) {
1396
+ if (needsImplicitReturn(code)) {
1397
+ const trimmed = code.trim().replace(/;$/, "");
1398
+ return `return (${trimmed});`;
1399
+ }
1400
+ return code;
1401
+ }
996
1402
  const handlerFunctionCache = {};
997
1403
  const HANDLER_PARAMETERS = [
998
- "Database",
999
1404
  "eventHandler",
1000
1405
  "Components",
1001
1406
  "Editor",
@@ -1023,7 +1428,6 @@ const HANDLER_PARAMETERS = [
1023
1428
  "context",
1024
1429
  "applications",
1025
1430
  "updateInput",
1026
- "updateInputHandlers",
1027
1431
  "deletePage",
1028
1432
  "CopyComponentToClipboard",
1029
1433
  "PasteComponentFromClipboard",
@@ -1047,20 +1451,55 @@ const HANDLER_PARAMETERS = [
1047
1451
  "ShowWarningToast",
1048
1452
  "ShowInfoToast",
1049
1453
  "HideToast",
1050
- "ClearAllToasts"
1454
+ "ClearAllToasts",
1455
+ "__createScope__",
1456
+ // For transparent variable access
1457
+ // Namespaced API object (new clean API)
1458
+ "Nav",
1459
+ "UI",
1460
+ "Component",
1461
+ "Data",
1462
+ "Page",
1463
+ "App",
1464
+ "Var"
1051
1465
  ];
1052
1466
  function compileHandlerFunction(code) {
1053
- if (!handlerFunctionCache[code]) {
1467
+ const cacheKey = `scope:${code}` ;
1468
+ if (!handlerFunctionCache[cacheKey]) {
1054
1469
  const validationResult = validateHandlerCode(code);
1055
1470
  if (!validationResult.valid) {
1056
1471
  throw new Error(`Handler validation failed: ${validationResult.errors[0]?.message || "Unknown error"}`);
1057
1472
  }
1058
- handlerFunctionCache[code] = new Function(
1059
- ...HANDLER_PARAMETERS,
1060
- `return (function() { ${code} }).apply(this);`
1061
- );
1473
+ const processedCode = wrapWithImplicitReturn(code);
1474
+ {
1475
+ handlerFunctionCache[cacheKey] = new Function(
1476
+ ...HANDLER_PARAMETERS,
1477
+ `
1478
+ var __scope__ = __createScope__({
1479
+ VarsProxy: Vars,
1480
+ parameters: {
1481
+ eventHandler: eventHandler, Components, Editor, Event, Item,
1482
+ Current, currentPlatform, Values, Apps, Vars, SetVar, GetContextVar,
1483
+ UpdateApplication, GetVar, GetComponent, GetComponents, AddComponent,
1484
+ SetContextVar, AddPage, TraitCompoentFromSchema, NavigateToUrl,
1485
+ NavigateToHash, NavigateToPage, UpdatePage, context, applications,
1486
+ updateInput, deletePage, CopyComponentToClipboard, PasteComponentFromClipboard,
1487
+ DeleteComponentAction, updateName, updateEvent, updateStyleHandlers,
1488
+ EventData, updateStyle, openEditorTab, setCurrentEditorTab, InvokeFunction,
1489
+ Utils, console, UploadFile, BrowseFiles, Instance, ShowToast,
1490
+ ShowSuccessToast, ShowErrorToast, ShowWarningToast, ShowInfoToast,
1491
+ HideToast, ClearAllToasts,
1492
+ Nav, UI, Component, Data, Page, App, Var
1493
+ }
1494
+ });
1495
+ with (__scope__) {
1496
+ return (function() { ${processedCode} }).apply(this);
1497
+ }
1498
+ `
1499
+ );
1500
+ }
1062
1501
  }
1063
- return handlerFunctionCache[code];
1502
+ return handlerFunctionCache[cacheKey];
1064
1503
  }
1065
1504
 
1066
1505
  const observe = (o, f) => new Proxy(o, {
@@ -1089,18 +1528,19 @@ function setupRuntimeContext(context, component, EventData = {}) {
1089
1528
  }
1090
1529
  context.Event = EventData.event;
1091
1530
  context.Current.style = context.Current.style ?? {};
1092
- if (!context.styleProxyCache.has(context.Current.style)) {
1093
- const newProxy = observe(context.Current.style, (target, prop, value) => {
1531
+ const originalStyle = context.Current.style;
1532
+ if (context.styleProxyCache.has(originalStyle)) {
1533
+ context.Current.style = context.styleProxyCache.get(originalStyle);
1534
+ } else {
1535
+ const newProxy = observe(originalStyle, (target, prop, value) => {
1094
1536
  context.setComponentRuntimeStyleAttribute(
1095
1537
  context.Current.uniqueUUID,
1096
1538
  prop,
1097
1539
  value
1098
1540
  );
1099
1541
  });
1542
+ context.styleProxyCache.set(originalStyle, newProxy);
1100
1543
  context.Current.style = newProxy;
1101
- context.styleProxyCache.set(context.Current.style, newProxy);
1102
- } else {
1103
- context.Current.style = context.styleProxyCache.get(context.Current.style);
1104
1544
  }
1105
1545
  }
1106
1546
  function extractRuntimeContext(context) {
@@ -1461,6 +1901,13 @@ var ComponentType = /* @__PURE__ */ ((ComponentType2) => {
1461
1901
  ComponentType2["Modal"] = "Modal";
1462
1902
  ComponentType2["Toast"] = "Toast";
1463
1903
  ComponentType2["Panel"] = "Panel";
1904
+ ComponentType2["GridRow"] = "grid-row-block";
1905
+ ComponentType2["GridCol"] = "grid-col-block";
1906
+ ComponentType2["Form"] = "form";
1907
+ ComponentType2["ValidationRules"] = "validation_rules";
1908
+ ComponentType2["BorderManager"] = "border_manager";
1909
+ ComponentType2["AccessRoles"] = "access_roles";
1910
+ ComponentType2["FunctionsPanel"] = "FunctionsPanel";
1464
1911
  return ComponentType2;
1465
1912
  })(ComponentType || {});
1466
1913
 
@@ -1719,11 +2166,19 @@ const addComponentAction = (component, pageUUID, currentApplicationId, updatePar
1719
2166
  childrenIds: component.childrenIds ?? []
1720
2167
  // Initialize childrenIds if necessary
1721
2168
  };
1722
- if (!currentComponentId || currentComponent?.component_type !== ComponentType.Container && currentComponent?.component_type !== ComponentType.Collection && currentComponent?.component_type !== ComponentType.Link) {
2169
+ const containerTypes = [
2170
+ ComponentType.Container,
2171
+ ComponentType.Collection,
2172
+ ComponentType.Link,
2173
+ ComponentType.GridRow,
2174
+ ComponentType.GridCol,
2175
+ ComponentType.Form
2176
+ ];
2177
+ if (!currentComponentId || !containerTypes.includes(currentComponent?.component_type)) {
1723
2178
  newComponent.root = true;
1724
2179
  }
1725
2180
  if (currentComponentId) {
1726
- if (currentComponent?.component_type === ComponentType.Container || currentComponent?.component_type === ComponentType.Dropdown || currentComponent?.component_type === ComponentType.Link || currentComponent?.component_type === ComponentType.Collection) {
2181
+ if (currentComponent?.component_type === ComponentType.Container || currentComponent?.component_type === ComponentType.Dropdown || currentComponent?.component_type === ComponentType.Link || currentComponent?.component_type === ComponentType.Collection || currentComponent?.component_type === ComponentType.GridRow || currentComponent?.component_type === ComponentType.GridCol || currentComponent?.component_type === ComponentType.Form) {
1727
2182
  if (updateParent) {
1728
2183
  const parentComponent = components.find((comp) => comp.uuid === currentComponentId);
1729
2184
  if (parentComponent) {
@@ -1922,7 +2377,6 @@ function moveDraggedComponent(dropInComponentId, draggedComponentId, position =
1922
2377
  updatePageAction(page, appUUID);
1923
2378
  updatePageHandler(page);
1924
2379
  eventDispatcher.emit("component:refresh");
1925
- console.log(`Moved ${draggedComponent.uuid} to ${position} ${dropInComponentId}`, draggedComponent);
1926
2380
  }
1927
2381
 
1928
2382
  function setCurrentComponentIdAction(componentId) {
@@ -1939,10 +2393,6 @@ function setDraggingComponentInfo(draggingComponentInfo) {
1939
2393
  }
1940
2394
  }
1941
2395
 
1942
- function setHoveredComponentAction(component) {
1943
- $hoveredComponent.set(component);
1944
- }
1945
-
1946
2396
  function updateComponentName(application_id, componentId, updatedName, save = true) {
1947
2397
  const componentsStore = $components.get();
1948
2398
  const applicationComponents = componentsStore[application_id] || [];
@@ -1965,7 +2415,7 @@ function updateComponentName(application_id, componentId, updatedName, save = tr
1965
2415
  setVar(key, `${key}.appPages`, pagesStore[key]);
1966
2416
  ExecuteInstance.VarsProxy[`${key}.appPages`] = [...pagesStore[key]];
1967
2417
  });
1968
- eventDispatcher.emit("component:updated");
2418
+ eventDispatcher.emit("component:updated", { uuid: componentId });
1969
2419
  refreshPageStoreVar();
1970
2420
  }
1971
2421
  }
@@ -1984,9 +2434,7 @@ ${errors.map(
1984
2434
 
1985
2435
  function updateComponentAttributes(application_id, componentId, updateType, updatedAttributes, save = true) {
1986
2436
  const currentPlatform = ExecuteInstance.Vars.currentPlatform ?? {
1987
- platform: "desktop",
1988
- isMobile: false
1989
- };
2437
+ platform: "desktop"};
1990
2438
  const componentsStore = $components.get();
1991
2439
  const applicationComponents = componentsStore[application_id] || [];
1992
2440
  const componentIndex = applicationComponents.findIndex(
@@ -2025,7 +2473,8 @@ function updateComponentAttributes(application_id, componentId, updateType, upda
2025
2473
  hasUpdateType: hasOriginalUpdateType,
2026
2474
  hasBreakpoints: hasOriginalBreakpoints
2027
2475
  };
2028
- if ((updateType === "style" || updateType === "input" && updatedAttributes.type !== "handler") && currentPlatform.platform !== "desktop") {
2476
+ const hasHandlerAttribute = updateType === "input" && Object.values(updatedAttributes).some((attr) => attr && typeof attr === "object" && attr.type === "handler");
2477
+ if ((updateType === "style" || updateType === "input" && !hasHandlerAttribute) && currentPlatform.platform !== "desktop") {
2029
2478
  componentToUpdate.breakpoints = componentToUpdate.breakpoints || {};
2030
2479
  componentToUpdate.breakpoints[currentPlatform.width] = componentToUpdate.breakpoints[currentPlatform.width] || {};
2031
2480
  for (const [key, value] of Object.entries(updatedAttributes)) {
@@ -2091,7 +2540,7 @@ function updateComponentAttributes(application_id, componentId, updateType, upda
2091
2540
  if (index !== -1) {
2092
2541
  ExecuteInstance.VarsProxy.selectedComponents[index] = componentToUpdate;
2093
2542
  }
2094
- eventDispatcher.emit("component:updated");
2543
+ eventDispatcher.emit("component:updated", { uuid: componentId });
2095
2544
  eventDispatcher.emit(`component-updated:${String(componentId)}`);
2096
2545
  }
2097
2546
  }
@@ -2161,10 +2610,14 @@ function generateNuralyClipboardStructure(component, childrenComponents) {
2161
2610
  function transformSchemaWithNewUUIDs(schema) {
2162
2611
  const uuidMap = /* @__PURE__ */ new Map();
2163
2612
  function generateUUID() {
2164
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
2165
- const r = Math.random() * 16 | 0, v = c === "x" ? r : r & 3 | 8;
2166
- return v.toString(16);
2167
- });
2613
+ if (crypto.randomUUID) {
2614
+ return crypto.randomUUID();
2615
+ }
2616
+ const bytes = crypto.getRandomValues(new Uint8Array(16));
2617
+ bytes[6] = bytes[6] & 15 | 64;
2618
+ bytes[8] = bytes[8] & 63 | 128;
2619
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
2620
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
2168
2621
  }
2169
2622
  schema.components.forEach((component) => {
2170
2623
  const newUUID = generateUUID();
@@ -2173,7 +2626,9 @@ function transformSchemaWithNewUUIDs(schema) {
2173
2626
  });
2174
2627
  schema.components.forEach((component) => {
2175
2628
  component.childrenIds = component.childrenIds.map((oldUUID) => uuidMap.get(oldUUID) || oldUUID);
2176
- component.name += `_${Math.random().toString(36).substring(2, 6)}`;
2629
+ const randomBytes = crypto.getRandomValues(new Uint8Array(2));
2630
+ const suffix = Array.from(randomBytes, (byte) => byte.toString(36)).join("").substring(0, 4);
2631
+ component.name += `_${suffix}`;
2177
2632
  });
2178
2633
  return schema;
2179
2634
  }
@@ -2186,7 +2641,8 @@ function findRootAndChildren(data) {
2186
2641
  }
2187
2642
 
2188
2643
  const GenerateName = (componentType) => {
2189
- const randomNumber = Math.floor(Math.random() * 1e4);
2644
+ const randomBytes = crypto.getRandomValues(new Uint32Array(1));
2645
+ const randomNumber = randomBytes[0] % 1e4;
2190
2646
  return `${componentType}_${randomNumber}`;
2191
2647
  };
2192
2648
 
@@ -2251,13 +2707,6 @@ function createComponentPropertyFunctions() {
2251
2707
  const eventData = { [inputName]: { type: handlerType, value: handlerValue } };
2252
2708
  updateComponentAttributes(component.application_id, component.uuid, "input", eventData);
2253
2709
  },
2254
- /**
2255
- * Updates component input handlers
2256
- */
2257
- updateInputHandlers: (component, inputName, value) => {
2258
- const eventData = { [inputName]: value };
2259
- updateComponentAttributes(component.application_id, component.uuid, "inputHandlers", eventData);
2260
- },
2261
2710
  /**
2262
2711
  * Updates component event handler
2263
2712
  */
@@ -2380,47 +2829,6 @@ function addTempApplication(uuid, components) {
2380
2829
  });
2381
2830
  }
2382
2831
 
2383
- const API_BASE = typeof window === "undefined" ? `http://${process.env.NURALY_SERVICES_HOST || "gateway"}` : "";
2384
- const APIS_URL = {
2385
- getApplication: (id) => `${API_BASE}/api/applications/${id}`,
2386
- getApplicationComponents: (id) => `${API_BASE}/api/components/application/${id}`,
2387
- fetchAllApplications: () => `${API_BASE}/api/applications`,
2388
- getApplicationPages: (uuid) => `${API_BASE}/api/pages/application/${uuid}`,
2389
- getPageComponents: (uuid) => `${API_BASE}/api/pages/${uuid}/components`,
2390
- getApplicationPermission: (application_id, resource_id) => `${API_BASE}/api/permissions/${application_id}/${resource_id}`
2391
- };
2392
-
2393
- const $toasts = deepMap({
2394
- toasts: []
2395
- });
2396
-
2397
- function showToast(options) {
2398
- const id = `toast-${v4()}`;
2399
- const toast = {
2400
- id,
2401
- type: "info",
2402
- duration: 3e3,
2403
- closable: true,
2404
- ...options
2405
- };
2406
- const current = $toasts.get();
2407
- $toasts.setKey("toasts", [...current.toasts, toast]);
2408
- eventDispatcher.emit("toast:show", toast);
2409
- if (toast.duration && toast.duration > 0) {
2410
- setTimeout(() => hideToast(id), toast.duration);
2411
- }
2412
- return id;
2413
- }
2414
- function hideToast(id) {
2415
- const current = $toasts.get();
2416
- $toasts.setKey("toasts", current.toasts.filter((t) => t.id !== id));
2417
- eventDispatcher.emit("toast:hide", { id });
2418
- }
2419
- function clearAllToasts() {
2420
- $toasts.setKey("toasts", []);
2421
- eventDispatcher.emit("toast:clear");
2422
- }
2423
-
2424
2832
  function setApplication(apps) {
2425
2833
  $applications.set(apps);
2426
2834
  }
@@ -2629,16 +3037,22 @@ function createStorageFunctions() {
2629
3037
  };
2630
3038
  }
2631
3039
 
2632
- const invokeFunctionHandler = (functionId, data) => {
2633
- return fetch(`${FRONT_API_URLS.FUNCTIONS}/invoke/${functionId}`, {
3040
+ const invokeFunctionHandler = async (functionId, data) => {
3041
+ const response = await fetch(`${FRONT_API_URLS.FUNCTIONS}/invoke/${functionId}`, {
2634
3042
  method: "POST",
2635
3043
  headers: {
2636
3044
  "Content-Type": "application/json"
2637
3045
  },
3046
+ credentials: "include",
2638
3047
  body: JSON.stringify({
2639
3048
  data
2640
3049
  })
2641
3050
  });
3051
+ if (!response.ok) {
3052
+ const errorText = await response.text();
3053
+ throw new Error(errorText || `Invoke failed with status ${response.status}`);
3054
+ }
3055
+ return response;
2642
3056
  };
2643
3057
 
2644
3058
  const loadFunctionsHandler = async () => {
@@ -2646,7 +3060,8 @@ const loadFunctionsHandler = async () => {
2646
3060
  method: "GET",
2647
3061
  headers: {
2648
3062
  "Content-Type": "application/json"
2649
- }
3063
+ },
3064
+ credentials: "include"
2650
3065
  }).then((res) => res.json());
2651
3066
  };
2652
3067
 
@@ -2730,45 +3145,204 @@ function createEditorFunctions() {
2730
3145
  };
2731
3146
  }
2732
3147
 
2733
- function createToastFunctions() {
2734
- return {
2735
- /**
2736
- * Shows a toast notification
2737
- * @param message - The message to display
2738
- * @param type - Toast type: 'success', 'error', 'warning', 'info' (default: 'info')
2739
- * @param options - Additional options (duration, closable)
2740
- * @returns Toast ID for programmatic control
2741
- *
2742
- * @example
2743
- * ShowToast('File saved successfully!', 'success');
2744
- * ShowToast('Error occurred', 'error', { duration: 5000 });
2745
- * ShowToast('Processing...', 'info', { duration: 0 }); // No auto-hide
2746
- */
2747
- ShowToast: (message, type = "info", options) => {
2748
- return showToast({
2749
- message,
2750
- type,
2751
- ...options
2752
- });
2753
- },
2754
- /**
2755
- * Shows a success toast (convenience function)
2756
- * @param message - Success message
2757
- * @param duration - Display duration in milliseconds (default: 3000)
2758
- * @returns Toast ID
2759
- *
2760
- * @example
2761
- * ShowSuccessToast('Operation completed!');
2762
- */
2763
- ShowSuccessToast: (message, duration = 3e3) => {
2764
- return showToast({ message, type: "success", duration });
2765
- },
2766
- /**
2767
- * Shows an error toast (convenience function)
2768
- * @param message - Error message
2769
- * @param duration - Display duration in milliseconds (default: 5000)
2770
- * @returns Toast ID
2771
- *
3148
+ const $toasts = deepMap({
3149
+ toasts: []
3150
+ });
3151
+
3152
+ var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
3153
+ var __decorateClass$4 = (decorators, target, key, kind) => {
3154
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
3155
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
3156
+ if (decorator = decorators[i])
3157
+ result = (decorator(result)) || result;
3158
+ return result;
3159
+ };
3160
+ try {
3161
+ await import('@nuralyui/toast');
3162
+ } catch (error) {
3163
+ console.warn("[@nuralyui/toast] Package not found or failed to load. Toast functionality may be limited.");
3164
+ }
3165
+ let toastContainerInstance = null;
3166
+ let ToastContainer = class extends LitElement {
3167
+ constructor() {
3168
+ super(...arguments);
3169
+ this.toastElement = null;
3170
+ this.shownToastIds = /* @__PURE__ */ new Set();
3171
+ }
3172
+ /**
3173
+ * Gets or creates the singleton instance
3174
+ * Call this to ensure toast container exists in the DOM
3175
+ */
3176
+ static getInstance() {
3177
+ if (!toastContainerInstance) {
3178
+ toastContainerInstance = new ToastContainer();
3179
+ document.body.appendChild(toastContainerInstance);
3180
+ }
3181
+ return toastContainerInstance;
3182
+ }
3183
+ /**
3184
+ * Checks if container instance exists
3185
+ */
3186
+ static hasInstance() {
3187
+ return toastContainerInstance !== null;
3188
+ }
3189
+ connectedCallback() {
3190
+ super.connectedCallback();
3191
+ if (toastContainerInstance && toastContainerInstance !== this) {
3192
+ console.warn("ToastContainer singleton already exists. Removing duplicate instance.");
3193
+ this.remove();
3194
+ return;
3195
+ }
3196
+ toastContainerInstance = this;
3197
+ this.unsubscribe = $toasts.subscribe((state) => {
3198
+ this.processToastUpdates(state.toasts);
3199
+ });
3200
+ }
3201
+ disconnectedCallback() {
3202
+ super.disconnectedCallback();
3203
+ if (toastContainerInstance === this) {
3204
+ toastContainerInstance = null;
3205
+ }
3206
+ this.unsubscribe?.();
3207
+ }
3208
+ processToastUpdates(toasts) {
3209
+ if (!this.toastElement && this.shadowRoot) {
3210
+ this.toastElement = this.shadowRoot.querySelector("nr-toast");
3211
+ }
3212
+ if (!this.toastElement) {
3213
+ return;
3214
+ }
3215
+ toasts.forEach((toast) => {
3216
+ if (!this.shownToastIds.has(toast.id)) {
3217
+ this.shownToastIds.add(toast.id);
3218
+ this.toastElement.show({
3219
+ text: toast.message,
3220
+ type: toast.type || "info",
3221
+ duration: toast.duration,
3222
+ autoDismiss: toast.duration ? toast.duration > 0 : true,
3223
+ closable: toast.closable !== false,
3224
+ onClose: () => {
3225
+ hideToast(toast.id);
3226
+ this.shownToastIds.delete(toast.id);
3227
+ }
3228
+ });
3229
+ }
3230
+ });
3231
+ }
3232
+ firstUpdated() {
3233
+ this.toastElement = this.shadowRoot?.querySelector("nr-toast");
3234
+ }
3235
+ render() {
3236
+ return html`
3237
+ <nr-toast
3238
+ position="top-right"
3239
+ stack
3240
+ max-toasts="5"
3241
+ ></nr-toast>
3242
+ `;
3243
+ }
3244
+ };
3245
+ ToastContainer.styles = css`
3246
+ :host {
3247
+ --nuraly-z-index-toast: 10000;
3248
+ }
3249
+ `;
3250
+ ToastContainer = __decorateClass$4([
3251
+ customElement("toast-container")
3252
+ ], ToastContainer);
3253
+
3254
+ let toastIdCounter = 0;
3255
+ function generateToastId() {
3256
+ return `toast-${Date.now()}-${++toastIdCounter}`;
3257
+ }
3258
+ let initialized = false;
3259
+ function ensureToastContainer() {
3260
+ if (!initialized && typeof window !== "undefined") {
3261
+ initialized = true;
3262
+ setTimeout(() => {
3263
+ ToastContainer.getInstance();
3264
+ }, 0);
3265
+ }
3266
+ }
3267
+ function showToast(options) {
3268
+ ensureToastContainer();
3269
+ const id = generateToastId();
3270
+ const toast = {
3271
+ id,
3272
+ type: "info",
3273
+ duration: 3e3,
3274
+ closable: true,
3275
+ ...options
3276
+ };
3277
+ const current = $toasts.get();
3278
+ $toasts.setKey("toasts", [...current.toasts, toast]);
3279
+ eventDispatcher.emit("toast:show", toast);
3280
+ if (toast.duration && toast.duration > 0) {
3281
+ setTimeout(() => hideToast(id), toast.duration);
3282
+ }
3283
+ return id;
3284
+ }
3285
+ function hideToast(id) {
3286
+ const current = $toasts.get();
3287
+ $toasts.setKey("toasts", current.toasts.filter((t) => t.id !== id));
3288
+ eventDispatcher.emit("toast:hide", { id });
3289
+ }
3290
+ function clearAllToasts() {
3291
+ $toasts.setKey("toasts", []);
3292
+ eventDispatcher.emit("toast:clear");
3293
+ }
3294
+ function showSuccess(message, duration = 3e3) {
3295
+ return showToast({ message, type: "success", duration });
3296
+ }
3297
+ function showError(message, duration = 5e3) {
3298
+ return showToast({ message, type: "error", duration });
3299
+ }
3300
+ function showWarning(message, duration = 4e3) {
3301
+ return showToast({ message, type: "warning", duration });
3302
+ }
3303
+ function showInfo(message, duration = 3e3) {
3304
+ return showToast({ message, type: "info", duration });
3305
+ }
3306
+
3307
+ function createToastFunctions() {
3308
+ return {
3309
+ /**
3310
+ * Shows a toast notification
3311
+ * @param message - The message to display
3312
+ * @param type - Toast type: 'success', 'error', 'warning', 'info' (default: 'info')
3313
+ * @param options - Additional options (duration, closable)
3314
+ * @returns Toast ID for programmatic control
3315
+ *
3316
+ * @example
3317
+ * ShowToast('File saved successfully!', 'success');
3318
+ * ShowToast('Error occurred', 'error', { duration: 5000 });
3319
+ * ShowToast('Processing...', 'info', { duration: 0 }); // No auto-hide
3320
+ */
3321
+ ShowToast: (message, type = "info", options) => {
3322
+ return showToast({
3323
+ message,
3324
+ type,
3325
+ ...options
3326
+ });
3327
+ },
3328
+ /**
3329
+ * Shows a success toast (convenience function)
3330
+ * @param message - Success message
3331
+ * @param duration - Display duration in milliseconds (default: 3000)
3332
+ * @returns Toast ID
3333
+ *
3334
+ * @example
3335
+ * ShowSuccessToast('Operation completed!');
3336
+ */
3337
+ ShowSuccessToast: (message, duration = 3e3) => {
3338
+ return showToast({ message, type: "success", duration });
3339
+ },
3340
+ /**
3341
+ * Shows an error toast (convenience function)
3342
+ * @param message - Error message
3343
+ * @param duration - Display duration in milliseconds (default: 5000)
3344
+ * @returns Toast ID
3345
+ *
2772
3346
  * @example
2773
3347
  * ShowErrorToast('Failed to save file');
2774
3348
  */
@@ -2838,6 +3412,121 @@ function createGlobalHandlerFunctions(runtimeContext) {
2838
3412
  };
2839
3413
  }
2840
3414
 
3415
+ function createNavAPI(globalFunctions) {
3416
+ return {
3417
+ toPage: globalFunctions.NavigateToPage,
3418
+ toUrl: (url, target) => {
3419
+ globalFunctions.NavigateToUrl(url, target);
3420
+ },
3421
+ toHash: globalFunctions.NavigateToHash
3422
+ };
3423
+ }
3424
+ function createUIAPI(globalFunctions) {
3425
+ return {
3426
+ toast: (message, type = "default", duration) => {
3427
+ switch (type) {
3428
+ case "success":
3429
+ globalFunctions.ShowSuccessToast(message, duration);
3430
+ break;
3431
+ case "error":
3432
+ globalFunctions.ShowErrorToast(message, duration);
3433
+ break;
3434
+ case "warning":
3435
+ globalFunctions.ShowWarningToast(message, duration);
3436
+ break;
3437
+ case "info":
3438
+ globalFunctions.ShowInfoToast(message, duration);
3439
+ break;
3440
+ default:
3441
+ globalFunctions.ShowToast(message, duration);
3442
+ }
3443
+ },
3444
+ success: (message, duration) => globalFunctions.ShowSuccessToast(message, duration),
3445
+ error: (message, duration) => globalFunctions.ShowErrorToast(message, duration),
3446
+ warning: (message, duration) => globalFunctions.ShowWarningToast(message, duration),
3447
+ info: (message, duration) => globalFunctions.ShowInfoToast(message, duration),
3448
+ hideToast: globalFunctions.HideToast,
3449
+ clearToasts: globalFunctions.ClearAllToasts
3450
+ };
3451
+ }
3452
+ function createComponentAPI(globalFunctions) {
3453
+ return {
3454
+ get: globalFunctions.GetComponent,
3455
+ getAll: globalFunctions.GetComponents,
3456
+ add: globalFunctions.AddComponent,
3457
+ delete: globalFunctions.DeleteComponentAction,
3458
+ copy: globalFunctions.CopyComponentToClipboard,
3459
+ paste: globalFunctions.PasteComponentFromClipboard,
3460
+ updateInput: globalFunctions.updateInput,
3461
+ updateName: globalFunctions.updateName,
3462
+ updateEvent: globalFunctions.updateEvent,
3463
+ updateStyle: globalFunctions.updateStyle,
3464
+ updateStyleHandlers: globalFunctions.updateStyleHandlers
3465
+ };
3466
+ }
3467
+ function createDataAPI(globalFunctions) {
3468
+ return {
3469
+ invoke: globalFunctions.InvokeFunction,
3470
+ upload: globalFunctions.UploadFile,
3471
+ browse: globalFunctions.BrowseFiles
3472
+ };
3473
+ }
3474
+ function createPageAPI(globalFunctions) {
3475
+ return {
3476
+ add: globalFunctions.AddPage,
3477
+ update: globalFunctions.UpdatePage,
3478
+ delete: globalFunctions.deletePage
3479
+ };
3480
+ }
3481
+ function createAppAPI(globalFunctions, runtimeContext) {
3482
+ return {
3483
+ update: globalFunctions.UpdateApplication,
3484
+ all: runtimeContext.applications,
3485
+ context: runtimeContext.context
3486
+ };
3487
+ }
3488
+ function createEditorAPI(globalFunctions, customConsole) {
3489
+ return {
3490
+ openTab: globalFunctions.openEditorTab,
3491
+ setTab: globalFunctions.setCurrentEditorTab,
3492
+ traitFromSchema: globalFunctions.TraitCompoentFromSchema,
3493
+ console: customConsole
3494
+ };
3495
+ }
3496
+ function createVarAPI(globalFunctions) {
3497
+ return {
3498
+ get: globalFunctions.GetVar,
3499
+ set: globalFunctions.SetVar,
3500
+ getContext: globalFunctions.GetContextVar,
3501
+ setContext: globalFunctions.SetContextVar
3502
+ };
3503
+ }
3504
+ function createHandlerAPI(runtimeContext, globalFunctions, component, eventData, item, customConsole, eventDispatcher, utils) {
3505
+ return {
3506
+ // Namespaced APIs
3507
+ Nav: createNavAPI(globalFunctions),
3508
+ UI: createUIAPI(globalFunctions),
3509
+ Component: createComponentAPI(globalFunctions),
3510
+ Data: createDataAPI(globalFunctions),
3511
+ Page: createPageAPI(globalFunctions),
3512
+ App: createAppAPI(globalFunctions, runtimeContext),
3513
+ Editor: createEditorAPI(globalFunctions, customConsole),
3514
+ Var: createVarAPI(globalFunctions),
3515
+ // Direct access (commonly used values)
3516
+ Current: runtimeContext.Current,
3517
+ Event: runtimeContext.Event,
3518
+ Item: item,
3519
+ Instance: component.Instance || {},
3520
+ Vars: runtimeContext.VarsProxy,
3521
+ Values: runtimeContext.Values,
3522
+ Apps: runtimeContext.Apps,
3523
+ Platform: runtimeContext.currentPlatform,
3524
+ Events: eventDispatcher,
3525
+ Utils: utils,
3526
+ console: customConsole
3527
+ };
3528
+ }
3529
+
2841
3530
  function getContextFromComponent(component) {
2842
3531
  return component?.__microAppContext?.runtimeContext || ExecuteInstance;
2843
3532
  }
@@ -2866,8 +3555,17 @@ function executeHandler(component, code, EventData = {}, item = {}) {
2866
3555
  info: EditorInstance.Console.info,
2867
3556
  debug: EditorInstance.Console.debug
2868
3557
  };
3558
+ const handlerAPI = createHandlerAPI(
3559
+ runtimeContext,
3560
+ globalFunctions,
3561
+ component,
3562
+ EventData,
3563
+ item,
3564
+ customConsole,
3565
+ eventDispatcher,
3566
+ RuntimeHelpers
3567
+ );
2869
3568
  return compiledFunction(
2870
- Database,
2871
3569
  eventDispatcher,
2872
3570
  runtimeContext.PropertiesProxy,
2873
3571
  EditorInstance,
@@ -2895,7 +3593,6 @@ function executeHandler(component, code, EventData = {}, item = {}) {
2895
3593
  runtimeContext.context,
2896
3594
  runtimeContext.applications,
2897
3595
  globalFunctions.updateInput,
2898
- globalFunctions.updateInputHandlers,
2899
3596
  globalFunctions.deletePage,
2900
3597
  globalFunctions.CopyComponentToClipboard,
2901
3598
  globalFunctions.PasteComponentFromClipboard,
@@ -2921,10 +3618,41 @@ function executeHandler(component, code, EventData = {}, item = {}) {
2921
3618
  globalFunctions.ShowWarningToast,
2922
3619
  globalFunctions.ShowInfoToast,
2923
3620
  globalFunctions.HideToast,
2924
- globalFunctions.ClearAllToasts
3621
+ globalFunctions.ClearAllToasts,
3622
+ createHandlerScope,
3623
+ // Namespaced APIs (new clean API)
3624
+ handlerAPI.Nav,
3625
+ handlerAPI.UI,
3626
+ handlerAPI.Component,
3627
+ handlerAPI.Data,
3628
+ handlerAPI.Page,
3629
+ handlerAPI.App,
3630
+ handlerAPI.Var
2925
3631
  );
2926
3632
  }
2927
3633
 
3634
+ function safeDeepEqual(oldValue, newValue) {
3635
+ try {
3636
+ return deepEqual(oldValue, newValue);
3637
+ } catch {
3638
+ return false;
3639
+ }
3640
+ }
3641
+ function buildEventName(eventPrefix, eventType, suffix) {
3642
+ const base = eventPrefix ? `${eventPrefix}:${eventType}` : eventType;
3643
+ return suffix ? `${base}:${suffix}` : base;
3644
+ }
3645
+ function emitToListeners(listeners, eventPrefix, prop, data) {
3646
+ listeners.forEach((componentName) => {
3647
+ const eventName = buildEventName(eventPrefix, "component-property-changed", componentName);
3648
+ eventDispatcher.emit(eventName, { prop, ...data });
3649
+ });
3650
+ }
3651
+ function emitScopeEvent(scope, eventPrefix, propPath, data) {
3652
+ if (!scope) return;
3653
+ const eventName = buildEventName(eventPrefix, scope, propPath);
3654
+ eventDispatcher.emit(eventName, data);
3655
+ }
2928
3656
  class RuntimeContextHelpers {
2929
3657
  /**
2930
3658
  * Create a reactive proxy for an object with configurable event dispatching.
@@ -2952,16 +3680,12 @@ class RuntimeContextHelpers {
2952
3680
  * ```
2953
3681
  */
2954
3682
  static createReactiveProxy(target, config) {
2955
- const { eventPrefix, scope, listeners, current, onPropertyChange, debug = false } = config;
3683
+ const { eventPrefix, scope, listeners, current, onPropertyChange } = config;
2956
3684
  if (typeof target !== "object" || target === null) {
2957
3685
  return target;
2958
3686
  }
2959
3687
  return new Proxy(target, {
2960
3688
  get(proxyTarget, prop, receiver) {
2961
- if (debug) {
2962
- const prefix = eventPrefix ? `[${eventPrefix}]` : "[Global]";
2963
- console.log(`${prefix} Accessing property '${String(prop)}'`);
2964
- }
2965
3689
  const value = Reflect.get(proxyTarget, prop, receiver);
2966
3690
  if (!listeners[String(prop)]) {
2967
3691
  listeners[String(prop)] = /* @__PURE__ */ new Set();
@@ -2969,43 +3693,29 @@ class RuntimeContextHelpers {
2969
3693
  if (current.name) {
2970
3694
  listeners[String(prop)].add(current.name);
2971
3695
  }
2972
- if (typeof value === "object" && value !== null) {
3696
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
2973
3697
  return RuntimeContextHelpers.createNestedProxy(value, {
2974
3698
  ...config,
2975
3699
  parentProp: String(prop)
2976
3700
  });
2977
3701
  }
3702
+ if (Array.isArray(value)) {
3703
+ return RuntimeContextHelpers.createArrayProxy(value, {
3704
+ ...config,
3705
+ parentProp: String(prop)
3706
+ });
3707
+ }
2978
3708
  return value;
2979
3709
  },
2980
3710
  set(proxyTarget, prop, value, receiver) {
2981
3711
  const oldValue = proxyTarget[prop];
2982
- let valuesEqual = false;
2983
- try {
2984
- valuesEqual = deepEqual(oldValue, value);
2985
- } catch (e) {
2986
- valuesEqual = false;
2987
- }
2988
- if (valuesEqual) {
3712
+ if (safeDeepEqual(oldValue, value)) {
2989
3713
  return true;
2990
3714
  }
2991
3715
  const result = Reflect.set(proxyTarget, prop, value, receiver);
2992
- if (debug) {
2993
- const prefix = eventPrefix ? `[${eventPrefix}]` : "[Global]";
2994
- console.log(`${prefix} Setting property '${String(prop)}' to '${value}'`);
2995
- }
2996
3716
  const propListeners = listeners[String(prop)] || /* @__PURE__ */ new Set();
2997
3717
  onPropertyChange(String(prop), value, propListeners);
2998
- if (scope) {
2999
- const eventName = eventPrefix ? `${eventPrefix}:${scope}:${String(prop)}` : `${scope}:${String(prop)}`;
3000
- if (debug || scope === "Vars" && String(prop) === "selectedComponents") {
3001
- console.log(`[RuntimeContextHelpers] Emitting event: ${eventName}`, { value, ctx: current });
3002
- }
3003
- eventDispatcher.emit(eventName, {
3004
- value,
3005
- ctx: current
3006
- // IMPORTANT: Include ctx for scope events (e.g., Vars:selectedComponents)
3007
- });
3008
- }
3718
+ emitScopeEvent(scope, eventPrefix, String(prop), { value, ctx: current });
3009
3719
  return result;
3010
3720
  }
3011
3721
  });
@@ -3021,60 +3731,141 @@ class RuntimeContextHelpers {
3021
3731
  * @returns Reactive proxy for nested object
3022
3732
  */
3023
3733
  static createNestedProxy(target, config) {
3024
- const { eventPrefix, scope, listeners, current, parentProp, debug = false } = config;
3734
+ const { eventPrefix, scope, listeners, current, parentProp } = config;
3025
3735
  return new Proxy(target, {
3736
+ get(proxyTarget, prop, receiver) {
3737
+ const value = Reflect.get(proxyTarget, prop, receiver);
3738
+ const nestedPropKey = `${parentProp}.${String(prop)}`;
3739
+ if (!listeners[nestedPropKey]) {
3740
+ listeners[nestedPropKey] = /* @__PURE__ */ new Set();
3741
+ }
3742
+ if (current.name) {
3743
+ listeners[nestedPropKey].add(current.name);
3744
+ if (!listeners[parentProp]) {
3745
+ listeners[parentProp] = /* @__PURE__ */ new Set();
3746
+ }
3747
+ listeners[parentProp].add(current.name);
3748
+ }
3749
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
3750
+ return RuntimeContextHelpers.createNestedProxy(value, {
3751
+ ...config,
3752
+ parentProp: nestedPropKey
3753
+ });
3754
+ }
3755
+ if (Array.isArray(value)) {
3756
+ return RuntimeContextHelpers.createArrayProxy(value, {
3757
+ ...config,
3758
+ parentProp: nestedPropKey
3759
+ });
3760
+ }
3761
+ return value;
3762
+ },
3026
3763
  set(proxyTarget, prop, value, receiver) {
3027
3764
  const oldValue = proxyTarget[prop];
3028
3765
  const result = Reflect.set(proxyTarget, prop, value, receiver);
3029
- if (debug) {
3030
- const prefix = eventPrefix ? `[${eventPrefix}]` : "[Global]";
3031
- console.log(
3032
- `${prefix} Updated nested property '${String(prop)}' from '${oldValue}' to '${value}'`
3033
- );
3034
- }
3035
- let valuesEqual = false;
3036
- try {
3037
- valuesEqual = deepEqual(oldValue, value);
3038
- } catch (e) {
3039
- valuesEqual = false;
3766
+ if (!safeDeepEqual(oldValue, value)) {
3767
+ const parentListeners = listeners[parentProp] || /* @__PURE__ */ new Set();
3768
+ emitToListeners(parentListeners, eventPrefix, parentProp, { value, ctx: current });
3769
+ emitScopeEvent(scope, eventPrefix, `${parentProp}.${String(prop)}`, {
3770
+ prop,
3771
+ value,
3772
+ oldValue,
3773
+ parent: parentProp
3774
+ });
3040
3775
  }
3041
- if (!valuesEqual) {
3776
+ return result;
3777
+ },
3778
+ deleteProperty(proxyTarget, prop) {
3779
+ const result = Reflect.deleteProperty(proxyTarget, prop);
3780
+ if (result) {
3042
3781
  const parentListeners = listeners[parentProp] || /* @__PURE__ */ new Set();
3043
- parentListeners.forEach((componentName) => {
3044
- const eventName = eventPrefix ? `${eventPrefix}:component-property-changed:${componentName}` : `component-property-changed:${componentName}`;
3045
- eventDispatcher.emit(eventName, {
3046
- prop: parentProp,
3047
- value,
3782
+ emitToListeners(parentListeners, eventPrefix, parentProp, { ctx: current });
3783
+ }
3784
+ return result;
3785
+ }
3786
+ });
3787
+ }
3788
+ /**
3789
+ * Create a proxy for arrays that tracks mutation methods.
3790
+ *
3791
+ * Arrays need special handling because methods like push, pop, splice
3792
+ * mutate the array without triggering the set trap.
3793
+ *
3794
+ * @param target - Array to wrap
3795
+ * @param config - Configuration including parent property name
3796
+ * @returns Reactive proxy for array
3797
+ */
3798
+ static createArrayProxy(target, config) {
3799
+ const { eventPrefix, scope, listeners, current, parentProp } = config;
3800
+ const mutationMethods = /* @__PURE__ */ new Set(["push", "pop", "shift", "unshift", "splice", "sort", "reverse", "fill", "copyWithin"]);
3801
+ return new Proxy(target, {
3802
+ get(proxyTarget, prop, receiver) {
3803
+ const value = Reflect.get(proxyTarget, prop, receiver);
3804
+ if (current.name) {
3805
+ if (!listeners[parentProp]) {
3806
+ listeners[parentProp] = /* @__PURE__ */ new Set();
3807
+ }
3808
+ listeners[parentProp].add(current.name);
3809
+ }
3810
+ if (typeof prop === "string" && mutationMethods.has(prop) && typeof value === "function") {
3811
+ return function(...args) {
3812
+ const oldArray = [...proxyTarget];
3813
+ const result = value.apply(proxyTarget, args);
3814
+ const parentListeners = listeners[parentProp] || /* @__PURE__ */ new Set();
3815
+ emitToListeners(parentListeners, eventPrefix, parentProp, {
3816
+ value: proxyTarget,
3817
+ oldValue: oldArray,
3818
+ mutation: prop,
3048
3819
  ctx: current
3049
3820
  });
3050
- });
3051
- if (scope) {
3052
- const eventName = eventPrefix ? `${eventPrefix}:${scope}:${parentProp}.${String(prop)}` : `${scope}:${parentProp}.${String(prop)}`;
3053
- eventDispatcher.emit(eventName, {
3054
- prop,
3055
- value,
3056
- oldValue,
3057
- parent: parentProp
3821
+ emitScopeEvent(scope, eventPrefix, parentProp, {
3822
+ prop: parentProp,
3823
+ value: proxyTarget,
3824
+ oldValue: oldArray,
3825
+ mutation: prop
3826
+ });
3827
+ return result;
3828
+ };
3829
+ }
3830
+ if (typeof value === "object" && value !== null) {
3831
+ const indexKey = `${parentProp}[${String(prop)}]`;
3832
+ if (Array.isArray(value)) {
3833
+ return RuntimeContextHelpers.createArrayProxy(value, {
3834
+ ...config,
3835
+ parentProp: indexKey
3058
3836
  });
3059
3837
  }
3838
+ return RuntimeContextHelpers.createNestedProxy(value, {
3839
+ ...config,
3840
+ parentProp: indexKey
3841
+ });
3842
+ }
3843
+ return value;
3844
+ },
3845
+ set(proxyTarget, prop, value, receiver) {
3846
+ const oldValue = proxyTarget[prop];
3847
+ const result = Reflect.set(proxyTarget, prop, value, receiver);
3848
+ if (!safeDeepEqual(oldValue, value)) {
3849
+ const parentListeners = listeners[parentProp] || /* @__PURE__ */ new Set();
3850
+ emitToListeners(parentListeners, eventPrefix, parentProp, {
3851
+ value: proxyTarget,
3852
+ index: prop,
3853
+ ctx: current
3854
+ });
3855
+ emitScopeEvent(scope, eventPrefix, parentProp, {
3856
+ prop: parentProp,
3857
+ value: proxyTarget,
3858
+ index: prop,
3859
+ oldValue
3860
+ });
3060
3861
  }
3061
3862
  return result;
3062
3863
  },
3063
3864
  deleteProperty(proxyTarget, prop) {
3064
- if (debug) {
3065
- const prefix = eventPrefix ? `[${eventPrefix}]` : "[Global]";
3066
- console.log(`${prefix} Deleting nested property '${String(prop)}'`);
3067
- }
3068
3865
  const result = Reflect.deleteProperty(proxyTarget, prop);
3069
3866
  if (result) {
3070
3867
  const parentListeners = listeners[parentProp] || /* @__PURE__ */ new Set();
3071
- parentListeners.forEach((componentName) => {
3072
- const eventName = eventPrefix ? `${eventPrefix}:component-property-changed:${componentName}` : `component-property-changed:${componentName}`;
3073
- eventDispatcher.emit(eventName, {
3074
- prop: parentProp,
3075
- ctx: current
3076
- });
3077
- });
3868
+ emitToListeners(parentListeners, eventPrefix, parentProp, { ctx: current });
3078
3869
  }
3079
3870
  return result;
3080
3871
  }
@@ -3207,7 +3998,6 @@ class RuntimeContextHelpers {
3207
3998
  }
3208
3999
  }
3209
4000
 
3210
- const DEBUG = false;
3211
4001
  class RuntimeContext {
3212
4002
  /**
3213
4003
  * Private constructor to enforce singleton pattern.
@@ -3294,8 +4084,7 @@ class RuntimeContext {
3294
4084
  // Global context doesn't track oldValue
3295
4085
  });
3296
4086
  }
3297
- },
3298
- debug: DEBUG
4087
+ }
3299
4088
  });
3300
4089
  }
3301
4090
  /**
@@ -3366,7 +4155,6 @@ class RuntimeContext {
3366
4155
  const proxy = new Proxy(target, {
3367
4156
  set(obj, prop, value) {
3368
4157
  if (obj[prop] !== value) {
3369
- console.log(`Style property changed: ${prop} = ${value}`);
3370
4158
  callback(prop, value);
3371
4159
  }
3372
4160
  obj[prop] = value;
@@ -3562,10 +4350,6 @@ function setContextMenuEvent(e) {
3562
4350
  $contextMenuEvent.set(e);
3563
4351
  }
3564
4352
 
3565
- function setResizing(isResizing) {
3566
- $resizing.set(isResizing);
3567
- }
3568
-
3569
4353
  function addGeneratedComponents(structureComponent) {
3570
4354
  structureComponent.forEach((component) => {
3571
4355
  addComponentAction(
@@ -3605,41 +4389,97 @@ const setupChangeDetection = () => {
3605
4389
  eventDispatcher.onAny((eventName, { ctx } = {}) => {
3606
4390
  if (eventName.startsWith("ccomponent-property-changed")) {
3607
4391
  const chdilrensComponent = getAllChildrenRecursive(ctx.application_id, ctx.uuid).get();
3608
- chdilrensComponent.forEach((component) => {
4392
+ chdilrensComponent.forEach(() => {
3609
4393
  });
3610
4394
  }
3611
4395
  });
3612
4396
  };
3613
4397
 
3614
- const selectTemplate = (props, isViewMode) => html`<select-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></select-block>`;
3615
- const iconButtonTemplate = (props, isViewMode) => html`<icon-button-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></icon-button-block>`;
3616
- const colorPickerTemplate = (props, isViewMode) => html`<color-picker-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></color-picker-block>`;
3617
- const numberInputTemplate = (props, isViewMode) => html`<number-input-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></number-input-block>`;
3618
- const shadowBoxTemplate = (props, isViewMode) => html`<attribute-box-shadow-value .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></attribute-box-shadow-value>`;
3619
- const borderRadiusTemplate = (props, isViewMode) => html`<attribute-border-value .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></attribute-border-value>`;
3620
- const boxModelTemplate = (props, isViewMode) => html`<box-model-display .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></box-model-display>`;
3621
- const eventTemplate = (props, isViewMode) => html`<parameter-event-handler .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></parameter-event-handler>`;
3622
- const tableTemplate = (props, isViewMode) => html`<table-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></table-block>`;
3623
- const textInputTemplate = (props, isViewMode) => html`<text-input-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></text-input-block>`;
3624
- const textLabelTemplate = (props, isViewMode) => html`<text-label-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></text-label-block>`;
3625
- const buttonTemplate = (props, isViewMode) => html`<button-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></button-block>`;
3626
- const tabsTemplate = (props, isViewMode) => html`<tabs-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></tabs-block>`;
3627
- const menuTemplate = (props, isViewMode) => html`<menu-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></menu-block>`;
3628
- const verticalContainerTemplate = (props, isViewMode) => html`<vertical-container-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></vertical-container-block>`;
3629
- const collectionViewerTemplate = (props, isViewMode) => html`<collection-viewer .isViewMode=${isViewMode} .parentcomponent=${props.parent} .component=${props.component}></collection-viewer>`;
3630
- const checkboxTemplate = (props, isViewMode) => html`<checkbox-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></checkbox-block>`;
3631
- const datePickerTemplate = (props, isViewMode) => html`<date-picker-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></date-picker-block>`;
3632
- const iconTemplate = (props, isViewMode) => html`<icon-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></icon-block>`;
3633
- const imageTemplate = (props, isViewMode) => html`<image-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></image-block>`;
3634
- const radioButtonTemplate = (props, isViewMode) => html`<radio-button-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></radio-button-block>`;
3635
- const aiTemplate = (props, isViewMode) => html`<ai-chat-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></ai-chat-block>`;
3636
- const iconPickerTemplate = (props, isViewMode) => html`<icon-picker-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></icon-picker-block>`;
3637
- const usersDropdownTemplate = (props, isViewMode) => html`<users-dropdown-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></users-dropdown-block>`;
3638
- const insertDropdownTemplate = (props, isViewMode) => html`<insert-dropdown-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></insert-dropdown-block>`;
3639
- const microAppTemplate = (props, isViewMode) => html`<micro-app-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></micro-app-block>`;
4398
+ class ComponentRegistryImpl {
4399
+ constructor() {
4400
+ this.registry = /* @__PURE__ */ new Map();
4401
+ }
4402
+ register(options) {
4403
+ const { type, tagName, componentClass, template } = options;
4404
+ if (this.registry.has(type)) {
4405
+ console.warn(`[ComponentRegistry] Component type "${type}" is already registered. Skipping.`);
4406
+ return;
4407
+ }
4408
+ if (componentClass && !customElements.get(tagName)) {
4409
+ customElements.define(tagName, componentClass);
4410
+ }
4411
+ const componentTemplate = template ?? this.createDefaultTemplate(tagName);
4412
+ this.registry.set(type, {
4413
+ type,
4414
+ tagName,
4415
+ template: componentTemplate,
4416
+ displayName: options.displayName,
4417
+ category: options.category,
4418
+ icon: options.icon,
4419
+ defaultInputs: options.defaultInputs
4420
+ });
4421
+ }
4422
+ unregister(type) {
4423
+ return this.registry.delete(type);
4424
+ }
4425
+ getTemplate(type) {
4426
+ return this.registry.get(type)?.template;
4427
+ }
4428
+ get(type) {
4429
+ return this.registry.get(type);
4430
+ }
4431
+ has(type) {
4432
+ return this.registry.has(type);
4433
+ }
4434
+ getAll() {
4435
+ return Array.from(this.registry.values());
4436
+ }
4437
+ getByCategory(category) {
4438
+ return this.getAll().filter((c) => c.category === category);
4439
+ }
4440
+ clear() {
4441
+ this.registry.clear();
4442
+ }
4443
+ createDefaultTemplate(tagName) {
4444
+ return (props, isViewMode) => {
4445
+ const el = document.createElement(tagName);
4446
+ el.isViewMode = isViewMode;
4447
+ el.parentcomponent = props.parent;
4448
+ el.item = props.item;
4449
+ el.component = props.component;
4450
+ return html`${el}`;
4451
+ };
4452
+ }
4453
+ }
4454
+ const ComponentRegistry = new ComponentRegistryImpl();
4455
+ function registerComponent(type, tagName, componentClass) {
4456
+ ComponentRegistry.register({ type, tagName, componentClass });
4457
+ }
4458
+ function registerComponents(components) {
4459
+ components.forEach((options) => ComponentRegistry.register(options));
4460
+ }
4461
+
4462
+ const selectTemplate = (props, isViewMode) => html`<select-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></select-block>`;
4463
+ const iconButtonTemplate = (props, isViewMode) => html`<icon-button-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></icon-button-block>`;
4464
+ const colorPickerTemplate = (props, isViewMode) => html`<color-picker-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></color-picker-block>`;
4465
+ const numberInputTemplate = (props, isViewMode) => html`<number-input-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></number-input-block>`;
4466
+ const tableTemplate = (props, isViewMode) => html`<table-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></table-block>`;
4467
+ const textInputTemplate = (props, isViewMode) => html`<text-input-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></text-input-block>`;
4468
+ const textLabelTemplate = (props, isViewMode) => html`<text-label-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></text-label-block>`;
4469
+ const buttonTemplate = (props, isViewMode) => html`<button-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></button-block>`;
4470
+ const tabsTemplate = (props, isViewMode) => html`<tabs-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></tabs-block>`;
4471
+ const menuTemplate = (props, isViewMode) => html`<menu-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></menu-block>`;
4472
+ const verticalContainerTemplate = (props, isViewMode) => html`<vertical-container-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></vertical-container-block>`;
4473
+ const collectionViewerTemplate = (props, isViewMode) => html`<collection-viewer .isViewMode=${isViewMode} .parentcomponent=${props.parent} .component=${props.component}></collection-viewer>`;
4474
+ const checkboxTemplate = (props, isViewMode) => html`<checkbox-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></checkbox-block>`;
4475
+ const datePickerTemplate = (props, isViewMode) => html`<date-picker-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></date-picker-block>`;
4476
+ const iconTemplate = (props, isViewMode) => html`<icon-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></icon-block>`;
4477
+ const imageTemplate = (props, isViewMode) => html`<image-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></image-block>`;
4478
+ const radioButtonTemplate = (props, isViewMode) => html`<radio-button-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></radio-button-block>`;
4479
+ const aiTemplate = (props, isViewMode) => html`<ai-chat-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></ai-chat-block>`;
4480
+ const microAppTemplate = (props, isViewMode) => html`<micro-app-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></micro-app-block>`;
3640
4481
  const collapseTemplate = (props, isViewMode) => html`<collapse-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></collapse-block>`;
3641
4482
  const dividerTemplate = (props, isViewMode) => html`<divider-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></divider-block>`;
3642
- const handlersTemplate = (props, isViewMode) => html`<handler-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></handler-block>`;
3643
4483
  const dropDownTemplate = (props, isViewMode) => html`<dropdown-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></dropdown-block>`;
3644
4484
  const refComponentTemplate = (props, isViewMode) => html`<ref-component-container-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></ref-component-container-block>`;
3645
4485
  const codeTemplate = (props, isViewMode) => html`<code-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></code-block>`;
@@ -3655,26 +4495,15 @@ const cardTemplate = (props, isViewMode) => html`<card-block .isViewMode=${isVie
3655
4495
  const tagTemplate = (props, isViewMode) => html`<tag-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></tag-block>`;
3656
4496
  const sliderTemplate = (props, isViewMode) => html`<slider-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></slider-block>`;
3657
4497
  const panelTemplate = (props, isViewMode) => html`<panel-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></panel-block>`;
3658
- const invokeFunctionTemplate = (props, isViewMode) => html`
3659
- <invoke-function-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></invoke-function-block>
3660
- `;
3661
- const importExportTemplate = (props, isViewMode) => html`
3662
- <export-import-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></export-import-block>
3663
- `;
4498
+ const gridRowTemplate = (props, isViewMode) => html`<grid-row-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></grid-row-block>`;
4499
+ const gridColTemplate = (props, isViewMode) => html`<grid-col-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></grid-col-block>`;
4500
+ const formTemplate = (props, isViewMode) => html`<form-block .isViewMode=${isViewMode} .parentcomponent=${props.parent} .item=${props.item} .component=${props.component}></form-block>`;
3664
4501
  function renderComponentElement(component, commonProps, isViewMode) {
3665
4502
  const template = getComponentTemplate(component, commonProps, isViewMode);
3666
4503
  return html`${template}`;
3667
4504
  }
3668
4505
  function getComponentTemplate(component, commonProps, isViewMode) {
3669
4506
  switch (component?.component_type) {
3670
- case ComponentType.Event:
3671
- return eventTemplate(commonProps, isViewMode);
3672
- case ComponentType.BorderRadius:
3673
- return borderRadiusTemplate(commonProps, isViewMode);
3674
- case ComponentType.BoxModel:
3675
- return boxModelTemplate(commonProps, isViewMode);
3676
- case ComponentType.ShadowBox:
3677
- return shadowBoxTemplate(commonProps, isViewMode);
3678
4507
  case ComponentType.Select:
3679
4508
  return selectTemplate(commonProps, isViewMode);
3680
4509
  case ComponentType.IconButton:
@@ -3713,22 +4542,10 @@ function getComponentTemplate(component, commonProps, isViewMode) {
3713
4542
  return radioButtonTemplate(commonProps, isViewMode);
3714
4543
  case ComponentType.AI:
3715
4544
  return aiTemplate(commonProps, isViewMode);
3716
- case ComponentType.IconPicker:
3717
- return iconPickerTemplate(commonProps, isViewMode);
3718
4545
  case ComponentType.MicroApp:
3719
4546
  return microAppTemplate(commonProps, isViewMode);
3720
- case ComponentType.UsersDropdown:
3721
- return usersDropdownTemplate(commonProps, isViewMode);
3722
- case ComponentType.InsertDropdown:
3723
- return insertDropdownTemplate(commonProps, isViewMode);
3724
4547
  case ComponentType.Collapse:
3725
4548
  return collapseTemplate(commonProps, isViewMode);
3726
- case ComponentType.Handlers:
3727
- return handlersTemplate(commonProps, isViewMode);
3728
- case ComponentType.ExportImport:
3729
- return importExportTemplate(commonProps, isViewMode);
3730
- case ComponentType.InvokeFunction:
3731
- return invokeFunctionTemplate(commonProps, isViewMode);
3732
4549
  case ComponentType.Dropdown:
3733
4550
  return dropDownTemplate(commonProps, isViewMode);
3734
4551
  case ComponentType.RefComponent:
@@ -3759,7 +4576,22 @@ function getComponentTemplate(component, commonProps, isViewMode) {
3759
4576
  return sliderTemplate(commonProps, isViewMode);
3760
4577
  case ComponentType.Panel:
3761
4578
  return panelTemplate(commonProps, isViewMode);
4579
+ case ComponentType.GridRow:
4580
+ return gridRowTemplate(commonProps, isViewMode);
4581
+ case ComponentType.GridCol:
4582
+ return gridColTemplate(commonProps, isViewMode);
4583
+ case ComponentType.Form:
4584
+ return formTemplate(commonProps, isViewMode);
3762
4585
  default:
4586
+ const registeredTemplate = ComponentRegistry.getTemplate(component?.component_type);
4587
+ if (registeredTemplate) {
4588
+ const renderProps = {
4589
+ component: commonProps.component,
4590
+ parent: commonProps.parent,
4591
+ item: commonProps.item
4592
+ };
4593
+ return registeredTemplate(renderProps, isViewMode ?? false);
4594
+ }
3763
4595
  return html``;
3764
4596
  }
3765
4597
  }
@@ -3844,4 +4676,1825 @@ const EMPTY_STRING = "";
3844
4676
 
3845
4677
  setupChangeDetection();
3846
4678
 
3847
- export { $components as $, APIS_URL as A, $runtimeStyles as B, $runtimeValues as C, $componentRuntimeValuesById as D, ExecuteInstance as E, FRONT_API_URLS as F, $componentRuntimeValueByKey as G, $componentsByUUIDs as H, $runtimeStylescomponentStyleByID as I, getAllChildrenRecursive as J, getDirectChildren as K, $componentById as L, setComponentRuntimeValue as M, setComponentRuntimeValues as N, setcomponentRuntimeStyleAttribute as O, clearComponentRuntimeValues as P, clearComponentRuntimeValue as Q, RuntimeInstance as R, clearAllRuntimeValues as S, clearComponentRuntimeStyleAttributes as T, fillComponentChildren as U, fillApplicationComponents as V, extractChildresIds as W, extractAllChildrenIds as X, $applications as Y, $resizing as Z, $currentPage as _, $hoveredComponentId as a, isForbiddenProperty as a$, $contextMenuEvent as a0, $microAppCurrentPage as a1, $applicationPages as a2, refreshPageStoreVar as a3, $context as a4, ViewMode as a5, $toasts as a6, $debug as a7, $providers as a8, executeHandler as a9, addComponentHandler as aA, deleteComponentActionHandler as aB, validateAndEmitErrors as aC, updatePageHandler as aD, deletePageHandler as aE, refreshPagesActionHandler as aF, loadOrRefreshApplications as aG, createApplicationAction as aH, deleteApplicationAction as aI, addPermission as aJ, invokeFunctionHandler as aK, loadFunctionsHandler as aL, renderComponent as aM, log as aN, setLogLevel as aO, enableLogging as aP, enableBenchmarking as aQ, LOG_LEVELS as aR, eventDispatcher as aS, copyCpmponentToClipboard as aT, pasteComponentFromClipboard as aU, traitCompoentFromSchema as aV, generateNuralyClipboardStructure as aW, RuntimeContextHelpers as aX, validateHandlerCode as aY, validateComponentHandlers as aZ, isForbiddenGlobal as a_, getContextFromComponent as aa, compileHandlerFunction as ab, addComponentAction as ac, addComponentToCurrentPageAction as ad, deleteComponentAction as ae, moveDraggedComponent as af, setCurrentComponentIdAction as ag, setDraggingComponentInfo as ah, setHoveredComponentAction as ai, updateComponentName as aj, updateComponentAttributes as ak, deletePageAction as al, setContextMenuEvent as am, setResizing as an, updatePageAction as ao, addPageToApplicationAction as ap, addTempApplication as aq, setApplication as ar, setPermissionMessage as as, updateApplication as at, closeCreateApplicationModalAction as au, openEditorTab as av, setCurrentEditorTab as aw, addGeneratedComponents as ax, addlogDebug as ay, resetComponentDebug as az, $showShareApplicationModal as b, isAllowedGlobal as b0, isForbiddenFunction as b1, getErrorMessage as b2, FORBIDDEN_GLOBALS as b3, FORBIDDEN_PROPERTIES as b4, FORBIDDEN_FUNCTIONS as b5, VALIDATION_ERROR_MESSAGES as b6, formatValidationErrors as b7, getNestedAttribute as b8, hasOnlyEmptyObjects as b9, GenerateName as ba, NO_EVENT_LISTENER as bb, EMPTY_STRING as bc, isServer$2 as bd, getInitPlatform as be, ComponentType as bf, getVar as bg, setVar as bh, hideToast as bi, $applicationPermission as c, $permissionsState as d, $currentApplication as e, updateApplicationActionHandler as f, $showCreateApplicationModal as g, $editorState as h, $environment as i, addPageHandler as j, $currentPageId as k, $currentPageViewPort as l, $showBorder as m, $pageSize as n, $pages as o, $pageZoom as p, EditorInstance as q, removeComponentToCurrentPageAction as r, RuntimeHelpers as s, $applicationComponents as t, updateComponentHandler as u, $selectedComponent as v, $currentComponentId as w, $hoveredComponent as x, $draggingComponentInfo as y, $componentWithChildren as z };
4679
+ class EventDebouncer {
4680
+ constructor(defaultDelay = 16) {
4681
+ this.timers = /* @__PURE__ */ new Map();
4682
+ this.defaultDelay = defaultDelay;
4683
+ }
4684
+ /**
4685
+ * Debounce a callback by key
4686
+ * If called multiple times with same key, only the last call executes
4687
+ */
4688
+ debounce(key, callback, delay) {
4689
+ const existingTimer = this.timers.get(key);
4690
+ if (existingTimer) {
4691
+ clearTimeout(existingTimer);
4692
+ }
4693
+ const timer = setTimeout(() => {
4694
+ this.timers.delete(key);
4695
+ callback();
4696
+ }, delay ?? this.defaultDelay);
4697
+ this.timers.set(key, timer);
4698
+ }
4699
+ /**
4700
+ * Cancel a pending debounced callback
4701
+ */
4702
+ cancel(key) {
4703
+ const timer = this.timers.get(key);
4704
+ if (timer) {
4705
+ clearTimeout(timer);
4706
+ this.timers.delete(key);
4707
+ }
4708
+ }
4709
+ /**
4710
+ * Cancel all pending callbacks
4711
+ */
4712
+ cancelAll() {
4713
+ for (const timer of this.timers.values()) {
4714
+ clearTimeout(timer);
4715
+ }
4716
+ this.timers.clear();
4717
+ }
4718
+ /**
4719
+ * Check if a key has a pending callback
4720
+ */
4721
+ isPending(key) {
4722
+ return this.timers.has(key);
4723
+ }
4724
+ /**
4725
+ * Get count of pending callbacks
4726
+ */
4727
+ get pendingCount() {
4728
+ return this.timers.size;
4729
+ }
4730
+ }
4731
+ class ChildRefreshBatcher {
4732
+ constructor(emitter, delay = 32) {
4733
+ this.pendingChildren = /* @__PURE__ */ new Set();
4734
+ this.timer = null;
4735
+ this.emitter = emitter;
4736
+ this.delay = delay;
4737
+ }
4738
+ /**
4739
+ * Queue a child for refresh
4740
+ */
4741
+ queueChild(childId) {
4742
+ this.pendingChildren.add(childId);
4743
+ this.scheduleFlush();
4744
+ }
4745
+ /**
4746
+ * Queue multiple children for refresh
4747
+ */
4748
+ queueChildren(childIds) {
4749
+ for (const id of childIds) {
4750
+ this.pendingChildren.add(id);
4751
+ }
4752
+ this.scheduleFlush();
4753
+ }
4754
+ scheduleFlush() {
4755
+ if (this.timer) return;
4756
+ this.timer = setTimeout(() => {
4757
+ this.flush();
4758
+ }, this.delay);
4759
+ }
4760
+ /**
4761
+ * Immediately flush all pending children
4762
+ */
4763
+ flush() {
4764
+ if (this.timer) {
4765
+ clearTimeout(this.timer);
4766
+ this.timer = null;
4767
+ }
4768
+ const children = Array.from(this.pendingChildren);
4769
+ this.pendingChildren.clear();
4770
+ requestAnimationFrame(() => {
4771
+ for (const childId of children) {
4772
+ this.emitter(childId);
4773
+ }
4774
+ });
4775
+ }
4776
+ /**
4777
+ * Cancel all pending refreshes
4778
+ */
4779
+ cancel() {
4780
+ if (this.timer) {
4781
+ clearTimeout(this.timer);
4782
+ this.timer = null;
4783
+ }
4784
+ this.pendingChildren.clear();
4785
+ }
4786
+ /**
4787
+ * Get count of pending children
4788
+ */
4789
+ get pendingCount() {
4790
+ return this.pendingChildren.size;
4791
+ }
4792
+ }
4793
+ class ExecutionGuard {
4794
+ constructor() {
4795
+ this.executing = /* @__PURE__ */ new Set();
4796
+ }
4797
+ /**
4798
+ * Try to acquire execution lock
4799
+ * Returns true if lock acquired, false if already executing
4800
+ */
4801
+ tryAcquire(key) {
4802
+ if (this.executing.has(key)) {
4803
+ return false;
4804
+ }
4805
+ this.executing.add(key);
4806
+ return true;
4807
+ }
4808
+ /**
4809
+ * Release execution lock
4810
+ */
4811
+ release(key) {
4812
+ this.executing.delete(key);
4813
+ }
4814
+ /**
4815
+ * Execute callback with guard
4816
+ * Prevents re-entrant execution of same key
4817
+ */
4818
+ async guard(key, callback) {
4819
+ if (!this.tryAcquire(key)) {
4820
+ return void 0;
4821
+ }
4822
+ try {
4823
+ return await callback();
4824
+ } finally {
4825
+ this.release(key);
4826
+ }
4827
+ }
4828
+ /**
4829
+ * Check if key is currently executing
4830
+ */
4831
+ isExecuting(key) {
4832
+ return this.executing.has(key);
4833
+ }
4834
+ /**
4835
+ * Clear all locks
4836
+ */
4837
+ clear() {
4838
+ this.executing.clear();
4839
+ }
4840
+ }
4841
+
4842
+ class InputHandlerController {
4843
+ constructor(host) {
4844
+ this.subscription = new Subscription();
4845
+ this.debouncer = new EventDebouncer(16);
4846
+ this.executionGuard = new ExecutionGuard();
4847
+ this.isConnected = false;
4848
+ this.host = host;
4849
+ host.addController(this);
4850
+ this.childRefreshBatcher = new ChildRefreshBatcher((childId) => {
4851
+ eventDispatcher.emit(`component:request:refresh:${childId}`);
4852
+ });
4853
+ }
4854
+ hostConnected() {
4855
+ this.isConnected = true;
4856
+ this.setupEventListeners();
4857
+ }
4858
+ hostDisconnected() {
4859
+ this.isConnected = false;
4860
+ this.dispose();
4861
+ }
4862
+ /**
4863
+ * Set up all event listeners for input refresh triggers
4864
+ */
4865
+ setupEventListeners() {
4866
+ const { component, uniqueUUID } = this.host;
4867
+ this.subscription.add(
4868
+ eventDispatcher.on("Vars:currentPlatform", () => {
4869
+ this.processInputsDebounced();
4870
+ })
4871
+ );
4872
+ this.subscription.add(
4873
+ eventDispatcher.on(
4874
+ `component-input-refresh-request:${component.uuid}`,
4875
+ () => {
4876
+ this.processInputsDebounced();
4877
+ }
4878
+ )
4879
+ );
4880
+ this.subscription.add(
4881
+ eventDispatcher.on(`component:value:set:${uniqueUUID}`, () => {
4882
+ this.processInputsDebounced();
4883
+ this.queueChildRefresh();
4884
+ })
4885
+ );
4886
+ this.subscription.add(
4887
+ eventDispatcher.on(`component:request:refresh:${component.uuid}`, () => {
4888
+ this.processInputsDebounced();
4889
+ this.queueChildRefresh();
4890
+ })
4891
+ );
4892
+ this.subscription.add(
4893
+ eventDispatcher.on(
4894
+ `component-property-changed:${String(component.name)}`,
4895
+ () => {
4896
+ this.processInputsDebounced();
4897
+ this.queueChildRefresh();
4898
+ }
4899
+ )
4900
+ );
4901
+ this.subscription.add(
4902
+ eventDispatcher.on(`component-updated:${String(component.uuid)}`, () => {
4903
+ this.debouncer.debounce("component-updated", () => {
4904
+ this.processInputs();
4905
+ }, 0);
4906
+ })
4907
+ );
4908
+ this.subscription.add(
4909
+ eventDispatcher.on("Vars:currentEditingMode", () => {
4910
+ this.executeOnInit();
4911
+ })
4912
+ );
4913
+ }
4914
+ /**
4915
+ * Queue child refresh with batching to prevent event storms
4916
+ */
4917
+ queueChildRefresh() {
4918
+ const childIds = this.host.component.childrenIds;
4919
+ if (childIds?.length) {
4920
+ this.childRefreshBatcher.queueChildren(childIds);
4921
+ }
4922
+ }
4923
+ /**
4924
+ * Execute onInit handler if present
4925
+ */
4926
+ executeOnInit() {
4927
+ const code = getNestedAttribute(this.host.component, "event.onInit");
4928
+ if (code) {
4929
+ executeHandler(this.host.component, code, {}, { ...this.host.item });
4930
+ }
4931
+ }
4932
+ /**
4933
+ * Process inputs with debouncing
4934
+ */
4935
+ processInputsDebounced() {
4936
+ this.debouncer.debounce("process-inputs", () => {
4937
+ this.processInputs();
4938
+ });
4939
+ }
4940
+ /**
4941
+ * Process all component inputs
4942
+ */
4943
+ async processInputs() {
4944
+ if (isServer$2 || !this.isConnected) return;
4945
+ this.host.errors = {};
4946
+ const inputs = EditorInstance.getComponentBreakpointInputs(this.host.component);
4947
+ if (!inputs) return;
4948
+ await Promise.all(
4949
+ Object.keys(inputs).map(
4950
+ (name) => this.processInput(inputs[name], name)
4951
+ )
4952
+ );
4953
+ addlogDebug({
4954
+ errors: {
4955
+ component: {
4956
+ ...this.host.component,
4957
+ errors: { ...this.host.errors }
4958
+ }
4959
+ }
4960
+ });
4961
+ this.host.requestUpdate();
4962
+ }
4963
+ /**
4964
+ * Process a single input handler
4965
+ */
4966
+ async processInput(input, inputName) {
4967
+ if (!input) return;
4968
+ const { component, item, inputHandlersValue, callbacks, errors, uniqueUUID } = this.host;
4969
+ const handlerKey = `${component.uuid || component.name}:${inputName}`;
4970
+ const result = await this.executionGuard.guard(handlerKey, async () => {
4971
+ return this.executeInputHandler(input, inputName);
4972
+ });
4973
+ if (result === void 0) {
4974
+ return;
4975
+ }
4976
+ if (inputHandlersValue[inputName] !== result.value) {
4977
+ inputHandlersValue[inputName] = result.value;
4978
+ const proxy = this.host.ExecuteInstance.PropertiesProxy[component.name] ??= {};
4979
+ proxy[inputName] = result.value;
4980
+ callbacks[inputName]?.(result.value);
4981
+ }
4982
+ if (result.error) {
4983
+ errors[inputName] = { error: result.error.message };
4984
+ }
4985
+ }
4986
+ /**
4987
+ * Execute input handler and return result
4988
+ */
4989
+ async executeInputHandler(input, inputName) {
4990
+ const { component, item, uniqueUUID } = this.host;
4991
+ if (input.type === "handler") {
4992
+ try {
4993
+ const code = input.value;
4994
+ if (code) {
4995
+ const fn = executeHandler(
4996
+ { ...component, uniqueUUID },
4997
+ code,
4998
+ void 0,
4999
+ { ...item }
5000
+ );
5001
+ const result = RuntimeHelpers.isPromise(fn) ? await fn : fn;
5002
+ return { value: result };
5003
+ }
5004
+ return { value: void 0 };
5005
+ } catch (error) {
5006
+ this.logHandlerError(inputName, input.value, error, "input");
5007
+ return { value: void 0, error: { message: error.message } };
5008
+ }
5009
+ }
5010
+ return { value: input.value };
5011
+ }
5012
+ /**
5013
+ * Log handler execution error to console
5014
+ */
5015
+ logHandlerError(inputName, code, error, source) {
5016
+ try {
5017
+ const { component } = this.host;
5018
+ EditorInstance.Console.log(
5019
+ `<i style="cursor:pointer" data-uuid="${component.uuid}" data-application_uuid="${component.application_id}"><b>${component.name}</b></i> > ${source} > ${inputName} | component uuid > ${component.uuid}`
5020
+ );
5021
+ EditorInstance.Console.log(this.formatCodeWithError(code, error));
5022
+ } catch (logError) {
5023
+ console.error("Error logging handler error:", logError);
5024
+ }
5025
+ }
5026
+ /**
5027
+ * Format code with error highlighting
5028
+ */
5029
+ formatCodeWithError(code, error) {
5030
+ const lines = code?.split("\n") || [];
5031
+ let result = "Code:\n";
5032
+ lines.forEach((line, i) => {
5033
+ result += `${(i + 1).toString().padStart(3, " ")}| ${line}
5034
+ `;
5035
+ });
5036
+ result += `
5037
+ Error: ${error.name}: ${error.message}`;
5038
+ return result;
5039
+ }
5040
+ /**
5041
+ * Clean up all resources
5042
+ */
5043
+ dispose() {
5044
+ this.subscription.unsubscribe();
5045
+ this.subscription = new Subscription();
5046
+ this.debouncer.cancelAll();
5047
+ this.executionGuard.clear();
5048
+ this.childRefreshBatcher.cancel();
5049
+ }
5050
+ }
5051
+
5052
+ class StyleCache {
5053
+ constructor(maxSize = 100) {
5054
+ this.cache = /* @__PURE__ */ new Map();
5055
+ this.maxSize = maxSize;
5056
+ }
5057
+ /**
5058
+ * Get cached CSS string or generate and cache it
5059
+ */
5060
+ getOrGenerate(key, generator) {
5061
+ if (this.cache.has(key)) {
5062
+ const value2 = this.cache.get(key);
5063
+ this.cache.delete(key);
5064
+ this.cache.set(key, value2);
5065
+ return value2;
5066
+ }
5067
+ const value = generator();
5068
+ this.set(key, value);
5069
+ return value;
5070
+ }
5071
+ /**
5072
+ * Set a cached value
5073
+ */
5074
+ set(key, value) {
5075
+ if (this.cache.size >= this.maxSize) {
5076
+ const firstKey = this.cache.keys().next().value;
5077
+ if (firstKey !== void 0) {
5078
+ this.cache.delete(firstKey);
5079
+ }
5080
+ }
5081
+ this.cache.set(key, value);
5082
+ }
5083
+ /**
5084
+ * Check if key exists in cache
5085
+ */
5086
+ has(key) {
5087
+ return this.cache.has(key);
5088
+ }
5089
+ /**
5090
+ * Get value from cache
5091
+ */
5092
+ get(key) {
5093
+ return this.cache.get(key);
5094
+ }
5095
+ /**
5096
+ * Clear the entire cache
5097
+ */
5098
+ clear() {
5099
+ this.cache.clear();
5100
+ }
5101
+ /**
5102
+ * Remove a specific key from cache
5103
+ */
5104
+ delete(key) {
5105
+ return this.cache.delete(key);
5106
+ }
5107
+ /**
5108
+ * Get current cache size
5109
+ */
5110
+ get size() {
5111
+ return this.cache.size;
5112
+ }
5113
+ }
5114
+ function generateStyleCacheKey(componentUuid, styles) {
5115
+ return `${componentUuid}:${JSON.stringify(styles)}`;
5116
+ }
5117
+
5118
+ const PSEUDO_STATES = [":hover", ":focus", ":active", ":disabled"];
5119
+ class StyleHandlerController {
5120
+ constructor(host) {
5121
+ this.subscription = new Subscription();
5122
+ this.runtimeStyles = {};
5123
+ this.pseudoStyleCache = new StyleCache(100);
5124
+ this.isConnected = false;
5125
+ this.host = host;
5126
+ host.addController(this);
5127
+ }
5128
+ hostConnected() {
5129
+ this.isConnected = true;
5130
+ this.setupSubscriptions();
5131
+ }
5132
+ hostDisconnected() {
5133
+ this.isConnected = false;
5134
+ this.dispose();
5135
+ }
5136
+ /**
5137
+ * Set up subscriptions for runtime style updates
5138
+ */
5139
+ setupSubscriptions() {
5140
+ this.subscription.add(
5141
+ $runtimeStylescomponentStyleByID(this.host.uniqueUUID).subscribe(
5142
+ (styles) => {
5143
+ this.runtimeStyles = styles || {};
5144
+ this.host.requestUpdate();
5145
+ }
5146
+ )
5147
+ );
5148
+ }
5149
+ /**
5150
+ * Process all style handlers for the component
5151
+ */
5152
+ async processStyles() {
5153
+ if (isServer$2 || !this.isConnected) return;
5154
+ const { component } = this.host;
5155
+ if (!component?.styleHandlers) {
5156
+ this.calculateStyles();
5157
+ return;
5158
+ }
5159
+ this.host.stylesHandlersValue = {};
5160
+ await Promise.all(
5161
+ Object.entries(component.styleHandlers).map(
5162
+ ([name, style]) => this.processStyleHandler(style, name)
5163
+ )
5164
+ );
5165
+ this.calculateStyles();
5166
+ this.host.requestUpdate();
5167
+ }
5168
+ /**
5169
+ * Process a single style handler
5170
+ */
5171
+ async processStyleHandler(style, styleName) {
5172
+ if (!style) return;
5173
+ try {
5174
+ const value = style.startsWith("return ") ? executeHandler(this.host.component, style) : style;
5175
+ if (value && this.host.stylesHandlersValue[styleName] !== value) {
5176
+ this.host.stylesHandlersValue[styleName] = value;
5177
+ }
5178
+ } catch (error) {
5179
+ console.error(`Error processing style handler "${styleName}":`, error);
5180
+ }
5181
+ }
5182
+ /**
5183
+ * Calculate and apply styles to the host element
5184
+ */
5185
+ calculateStyles() {
5186
+ const { component, inputHandlersValue } = this.host;
5187
+ this.host.calculatedStyles = {
5188
+ ...EditorInstance.getComponentStyles(component),
5189
+ ...this.host.calculatedStyles
5190
+ };
5191
+ const { innerAlignment } = inputHandlersValue;
5192
+ const hostStyle = this.host.style;
5193
+ hostStyle.removeProperty("align-self");
5194
+ hostStyle.removeProperty("margin");
5195
+ hostStyle.removeProperty("margin-left");
5196
+ if (innerAlignment === "end") {
5197
+ hostStyle.marginLeft = "auto";
5198
+ } else if (innerAlignment === "middle") {
5199
+ hostStyle.alignSelf = "center";
5200
+ hostStyle.margin = "auto";
5201
+ }
5202
+ const { width, flex, cursor } = this.host.calculatedStyles;
5203
+ if (width && RuntimeHelpers.extractUnit(width) === "%") {
5204
+ hostStyle.width = width;
5205
+ }
5206
+ if (flex) {
5207
+ hostStyle.flex = flex;
5208
+ }
5209
+ if (cursor) {
5210
+ hostStyle.cursor = cursor;
5211
+ }
5212
+ }
5213
+ /**
5214
+ * Get computed styles for the component
5215
+ * Merges multiple style sources: editor styles, handler values, runtime styles
5216
+ */
5217
+ getComputedStyles() {
5218
+ const { component } = this.host;
5219
+ const width = EditorInstance.getComponentStyle(component, "width");
5220
+ const allStyles = EditorInstance.getComponentStyles(component);
5221
+ const regularStyles = this.filterPseudoStates(allStyles);
5222
+ const computedWidth = width === "auto" ? "auto" : RuntimeHelpers.extractUnit(width) === "%" ? "100%" : width ?? "auto";
5223
+ return {
5224
+ ...regularStyles,
5225
+ ...this.host.stylesHandlersValue,
5226
+ width: computedWidth,
5227
+ ...this.runtimeStyles
5228
+ };
5229
+ }
5230
+ /**
5231
+ * Filter out pseudo-state keys from styles object
5232
+ */
5233
+ filterPseudoStates(styles) {
5234
+ return Object.keys(styles).filter((key) => !PSEUDO_STATES.includes(key)).reduce((obj, key) => {
5235
+ obj[key] = styles[key];
5236
+ return obj;
5237
+ }, {});
5238
+ }
5239
+ /**
5240
+ * Generate CSS string for pseudo-state styles
5241
+ * Uses caching to avoid regeneration on every render
5242
+ */
5243
+ generatePseudoStateCSS() {
5244
+ const componentStyles = EditorInstance.getComponentStyles(this.host.component);
5245
+ const cacheKey = generateStyleCacheKey(
5246
+ this.host.component.uuid,
5247
+ componentStyles
5248
+ );
5249
+ return this.pseudoStyleCache.getOrGenerate(
5250
+ cacheKey,
5251
+ () => this.buildPseudoStateCSS(componentStyles)
5252
+ );
5253
+ }
5254
+ /**
5255
+ * Build CSS string for pseudo-state styles
5256
+ */
5257
+ buildPseudoStateCSS(componentStyles) {
5258
+ const uuid = this.host.component.uuid;
5259
+ let cssString = "";
5260
+ const regularStyles = this.filterPseudoStates(componentStyles);
5261
+ const baseRules = this.stylesToCSS(regularStyles);
5262
+ if (baseRules) {
5263
+ cssString += `.drop-${uuid} {
5264
+ ${baseRules}}
5265
+ `;
5266
+ }
5267
+ for (const pseudoState of PSEUDO_STATES) {
5268
+ const stateStyles = componentStyles[pseudoState];
5269
+ if (stateStyles && typeof stateStyles === "object") {
5270
+ const stateRules = this.stylesToCSS(stateStyles);
5271
+ if (stateRules) {
5272
+ cssString += `.drop-${uuid}${pseudoState} {
5273
+ ${stateRules}}
5274
+ `;
5275
+ }
5276
+ }
5277
+ }
5278
+ return cssString;
5279
+ }
5280
+ /**
5281
+ * Convert styles object to CSS rule string
5282
+ */
5283
+ stylesToCSS(styles) {
5284
+ return Object.entries(styles).filter(([_, value]) => value !== void 0 && value !== null).map(([property, value]) => ` ${property}: ${value};`).join("\n");
5285
+ }
5286
+ /**
5287
+ * Check if component has any pseudo-state styles
5288
+ */
5289
+ hasPseudoStateStyles() {
5290
+ const componentStyles = EditorInstance.getComponentStyles(this.host.component);
5291
+ return PSEUDO_STATES.some(
5292
+ (state) => componentStyles[state] && typeof componentStyles[state] === "object" && Object.keys(componentStyles[state]).length > 0
5293
+ );
5294
+ }
5295
+ /**
5296
+ * Invalidate cached styles for this component
5297
+ */
5298
+ invalidateCache() {
5299
+ const componentStyles = EditorInstance.getComponentStyles(this.host.component);
5300
+ const cacheKey = generateStyleCacheKey(
5301
+ this.host.component.uuid,
5302
+ componentStyles
5303
+ );
5304
+ this.pseudoStyleCache.delete(cacheKey);
5305
+ }
5306
+ /**
5307
+ * Clean up all resources
5308
+ */
5309
+ dispose() {
5310
+ this.subscription.unsubscribe();
5311
+ this.subscription = new Subscription();
5312
+ this.pseudoStyleCache.clear();
5313
+ this.runtimeStyles = {};
5314
+ }
5315
+ }
5316
+
5317
+ class EventController {
5318
+ constructor(host) {
5319
+ this.isConnected = false;
5320
+ this.host = host;
5321
+ host.addController(this);
5322
+ }
5323
+ hostConnected() {
5324
+ this.isConnected = true;
5325
+ this.executeOnInit();
5326
+ }
5327
+ hostDisconnected() {
5328
+ this.isConnected = false;
5329
+ }
5330
+ /**
5331
+ * Execute the onInit event handler if present
5332
+ */
5333
+ executeOnInit() {
5334
+ const code = getNestedAttribute(this.host.component, "event.onInit");
5335
+ if (code) {
5336
+ try {
5337
+ executeHandler(
5338
+ this.host.component,
5339
+ code,
5340
+ {},
5341
+ { ...this.host.item }
5342
+ );
5343
+ } catch (error) {
5344
+ console.error("Error executing onInit handler:", error);
5345
+ }
5346
+ }
5347
+ }
5348
+ /**
5349
+ * Execute a component event handler
5350
+ */
5351
+ execute(eventName, event, data = {}) {
5352
+ if (!this.isConnected) return;
5353
+ const { component, item, uniqueUUID } = this.host;
5354
+ const code = component.event?.[eventName];
5355
+ if (!code) return;
5356
+ try {
5357
+ const eventData = {
5358
+ ...data,
5359
+ event
5360
+ };
5361
+ executeHandler(
5362
+ { ...component, uniqueUUID },
5363
+ getNestedAttribute(component, `event.${eventName}`),
5364
+ eventData,
5365
+ item
5366
+ );
5367
+ } catch (error) {
5368
+ console.error(`Error executing event "${eventName}":`, error);
5369
+ }
5370
+ }
5371
+ /**
5372
+ * Execute multiple events in sequence
5373
+ */
5374
+ executeMultiple(events) {
5375
+ for (const { eventName, event, data } of events) {
5376
+ this.execute(eventName, event, data);
5377
+ }
5378
+ }
5379
+ /**
5380
+ * Check if component has a specific event handler
5381
+ */
5382
+ hasEventHandler(eventName) {
5383
+ return !!this.host.component.event?.[eventName];
5384
+ }
5385
+ /**
5386
+ * Get list of all event handler names
5387
+ */
5388
+ getEventHandlerNames() {
5389
+ const events = this.host.component.event;
5390
+ if (!events) return [];
5391
+ return Object.keys(events).filter((key) => !!events[key]);
5392
+ }
5393
+ /**
5394
+ * Clean up resources
5395
+ */
5396
+ dispose() {
5397
+ this.isConnected = false;
5398
+ }
5399
+ }
5400
+
5401
+ class SelectionController {
5402
+ constructor(host) {
5403
+ this.subscription = new Subscription();
5404
+ this.isActive = false;
5405
+ this.hoveredComponent = null;
5406
+ this.isEditable = false;
5407
+ this.host = host;
5408
+ host.addController(this);
5409
+ this.boundMouseEnter = this.handleMouseEnter.bind(this);
5410
+ this.boundMouseLeave = this.handleMouseLeave.bind(this);
5411
+ this.boundClick = this.handleClick.bind(this);
5412
+ this.boundContextMenu = this.handleContextMenu.bind(this);
5413
+ }
5414
+ hostConnected() {
5415
+ }
5416
+ hostDisconnected() {
5417
+ this.deactivate();
5418
+ }
5419
+ /**
5420
+ * Activate selection controller (editor mode only)
5421
+ */
5422
+ activate() {
5423
+ if (this.isActive || this.host.isViewMode) return;
5424
+ this.isActive = true;
5425
+ this.host.addEventListener("mouseenter", this.boundMouseEnter);
5426
+ this.host.addEventListener("mouseleave", this.boundMouseLeave);
5427
+ this.host.addEventListener("click", this.boundClick);
5428
+ this.host.addEventListener("contextmenu", this.boundContextMenu);
5429
+ this.setupSubscriptions();
5430
+ }
5431
+ /**
5432
+ * Deactivate selection controller
5433
+ */
5434
+ deactivate() {
5435
+ if (!this.isActive) return;
5436
+ this.isActive = false;
5437
+ this.host.removeEventListener("mouseenter", this.boundMouseEnter);
5438
+ this.host.removeEventListener("mouseleave", this.boundMouseLeave);
5439
+ this.host.removeEventListener("click", this.boundClick);
5440
+ this.host.removeEventListener("contextmenu", this.boundContextMenu);
5441
+ this.subscription.unsubscribe();
5442
+ this.subscription = new Subscription();
5443
+ }
5444
+ /**
5445
+ * Set up store subscriptions
5446
+ */
5447
+ setupSubscriptions() {
5448
+ this.subscription.add(
5449
+ RuntimeHelpers.createStoreObservable($hoveredComponent).subscribe(
5450
+ (hoveredComponent) => {
5451
+ this.hoveredComponent = hoveredComponent;
5452
+ }
5453
+ )
5454
+ );
5455
+ this.subscription.add(
5456
+ eventDispatcher.on("Vars:selectedComponents", () => {
5457
+ this.handleSelectionChange();
5458
+ })
5459
+ );
5460
+ this.subscription.add(
5461
+ eventDispatcher.on("keydown", ({ key, selectedComponents }) => {
5462
+ this.handleKeydown(key, selectedComponents);
5463
+ })
5464
+ );
5465
+ }
5466
+ /**
5467
+ * Handle selection change events
5468
+ */
5469
+ handleSelectionChange() {
5470
+ const selectedComponents = ExecuteInstance.Vars.selectedComponents;
5471
+ this.host.currentSelection = Array.from(selectedComponents).map(
5472
+ (component) => component.uuid
5473
+ );
5474
+ EditorInstance.currentSelection = this.host.currentSelection;
5475
+ const isSelected = selectedComponents.length === 1 && selectedComponents[0]?.uuid === this.host.component.uuid;
5476
+ if (isSelected) {
5477
+ this.scrollIntoViewIfNeeded();
5478
+ this.emitSelectionEvent();
5479
+ }
5480
+ }
5481
+ /**
5482
+ * Scroll component into view if not visible
5483
+ */
5484
+ scrollIntoViewIfNeeded() {
5485
+ requestAnimationFrame(() => {
5486
+ const element = this.host.inputRef.value;
5487
+ if (!element) return;
5488
+ const rect = element.getBoundingClientRect();
5489
+ const isInViewport = rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
5490
+ if (!isInViewport) {
5491
+ element.scrollIntoView({
5492
+ behavior: "smooth",
5493
+ block: "center",
5494
+ inline: "nearest"
5495
+ });
5496
+ }
5497
+ });
5498
+ }
5499
+ /**
5500
+ * Emit component selected custom event
5501
+ */
5502
+ emitSelectionEvent() {
5503
+ requestAnimationFrame(() => {
5504
+ this.host.dispatchEvent(
5505
+ new CustomEvent("component-selected", {
5506
+ detail: {
5507
+ component: this.host.component,
5508
+ elementRef: this.host.inputRef
5509
+ },
5510
+ bubbles: true,
5511
+ composed: true
5512
+ })
5513
+ );
5514
+ });
5515
+ }
5516
+ /**
5517
+ * Handle keydown events
5518
+ */
5519
+ handleKeydown(key, selectedComponents) {
5520
+ if (key === "Enter" && selectedComponents.length === 1 && this.host.component.uuid === selectedComponents[0]) {
5521
+ this.isEditable = true;
5522
+ }
5523
+ }
5524
+ /**
5525
+ * Handle mouse enter event
5526
+ */
5527
+ handleMouseEnter(_e) {
5528
+ if ($resizing.get()) return;
5529
+ this.host.dispatchEvent(
5530
+ new CustomEvent("component-hovered", {
5531
+ detail: {
5532
+ component: this.host.component,
5533
+ elementRef: this.host.inputRef
5534
+ },
5535
+ bubbles: true,
5536
+ composed: true
5537
+ })
5538
+ );
5539
+ }
5540
+ /**
5541
+ * Handle mouse leave event
5542
+ */
5543
+ handleMouseLeave(_e) {
5544
+ if ($resizing.get()) return;
5545
+ this.host.dispatchEvent(
5546
+ new CustomEvent("component-hovered", {
5547
+ detail: {
5548
+ component: null,
5549
+ elementRef: null
5550
+ },
5551
+ bubbles: true,
5552
+ composed: true
5553
+ })
5554
+ );
5555
+ }
5556
+ /**
5557
+ * Handle click event for selection
5558
+ */
5559
+ handleClick(e) {
5560
+ e.preventDefault();
5561
+ e.stopPropagation();
5562
+ this.select(e);
5563
+ }
5564
+ /**
5565
+ * Handle context menu event
5566
+ */
5567
+ handleContextMenu(e) {
5568
+ e.preventDefault();
5569
+ e.stopPropagation();
5570
+ this.select(e);
5571
+ const rect = this.host.inputRef.value?.getBoundingClientRect();
5572
+ if (rect) {
5573
+ Object.assign(e, {
5574
+ ComponentTop: rect.top,
5575
+ ComponentLeft: rect.left,
5576
+ ComponentBottom: rect.bottom,
5577
+ ComponentHeight: rect.height
5578
+ });
5579
+ setContextMenuEvent(e);
5580
+ }
5581
+ }
5582
+ /**
5583
+ * Select this component
5584
+ */
5585
+ select(_e) {
5586
+ const { component } = this.host;
5587
+ this.host.currentSelection = [component.uuid];
5588
+ EditorInstance.currentSelection = [component.uuid];
5589
+ ExecuteInstance.VarsProxy.selectedComponents = [component];
5590
+ this.host.dispatchEvent(
5591
+ new CustomEvent("component-selected", {
5592
+ detail: {
5593
+ component,
5594
+ elementRef: this.host.inputRef
5595
+ },
5596
+ bubbles: true,
5597
+ composed: true
5598
+ })
5599
+ );
5600
+ }
5601
+ /**
5602
+ * Check if this component is currently selected
5603
+ */
5604
+ isSelected() {
5605
+ return this.host.currentSelection.includes(this.host.component.uuid);
5606
+ }
5607
+ /**
5608
+ * Check if this component is currently hovered
5609
+ */
5610
+ isHovered() {
5611
+ return this.hoveredComponent?.uuid === this.host.component.uuid;
5612
+ }
5613
+ /**
5614
+ * Check if component is in editable mode
5615
+ */
5616
+ getIsEditable() {
5617
+ return this.isEditable;
5618
+ }
5619
+ /**
5620
+ * Set editable mode
5621
+ */
5622
+ setEditable(editable) {
5623
+ this.isEditable = editable;
5624
+ }
5625
+ /**
5626
+ * Clean up all resources
5627
+ */
5628
+ dispose() {
5629
+ this.deactivate();
5630
+ }
5631
+ }
5632
+
5633
+ var __defProp$3 = Object.defineProperty;
5634
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
5635
+ var __decorateClass$3 = (decorators, target, key, kind) => {
5636
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
5637
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
5638
+ if (decorator = decorators[i])
5639
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
5640
+ if (kind && result) __defProp$3(target, key, result);
5641
+ return result;
5642
+ };
5643
+ let DragWrapper = class extends LitElement {
5644
+ constructor() {
5645
+ super(...arguments);
5646
+ this.slotRef = createRef();
5647
+ this.dropBeforePlaceHolderStyle = {
5648
+ opacity: "0",
5649
+ height: "0px",
5650
+ width: "0px",
5651
+ border: "0",
5652
+ margin: "0",
5653
+ backgroundColor: "transparent",
5654
+ position: "relative"
5655
+ };
5656
+ this.dropAfterPlaceHolderStyle = {
5657
+ opacity: "0",
5658
+ height: "0px",
5659
+ width: "0px",
5660
+ border: "0",
5661
+ margin: "0",
5662
+ backgroundColor: "transparent",
5663
+ position: "relative"
5664
+ };
5665
+ this.pendingLeaveTimeout = null;
5666
+ }
5667
+ updated(changedProperties) {
5668
+ changedProperties.forEach((_oldValue, propName) => {
5669
+ if (propName === "draggingComponentInfo") {
5670
+ this.isDragging = Object.keys(this.draggingComponentInfo || {}).length > 0;
5671
+ }
5672
+ });
5673
+ }
5674
+ connectedCallback() {
5675
+ super.connectedCallback();
5676
+ this.addEventListener("drag-over-component", this.handleDragOver.bind(this));
5677
+ this.addEventListener("drag-leave-component", this.handleDragLeave.bind(this));
5678
+ $draggingComponentInfo.subscribe((draggingComponentInfo) => {
5679
+ if (draggingComponentInfo) {
5680
+ this.draggingComponentInfo = draggingComponentInfo;
5681
+ this.draggingSituation = true;
5682
+ if (this.draggingComponentInfo?.componentId === this.component?.uuid) {
5683
+ if (this.draggingComponentInfo?.blockInfo && !this.draggingComponentInfo?.blockInfo?.height) {
5684
+ const rect = this.inputRef.value?.getBoundingClientRect();
5685
+ this.draggingComponentInfo.blockInfo.height = `${rect.height}px`;
5686
+ setDraggingComponentInfo({
5687
+ componentId: this.draggingComponentInfo?.componentId,
5688
+ blockInfo: { ...this.draggingComponentInfo.blockInfo }
5689
+ });
5690
+ }
5691
+ }
5692
+ } else {
5693
+ this.draggingSituation = false;
5694
+ this.draggingComponentInfo = null;
5695
+ this.resetDropZones();
5696
+ }
5697
+ });
5698
+ }
5699
+ handleDragLeave(e) {
5700
+ this.resetDropZones();
5701
+ }
5702
+ resetDropZones() {
5703
+ this.dropBeforePlaceHolderStyle = {
5704
+ opacity: "0",
5705
+ height: "0px",
5706
+ width: "0",
5707
+ border: "0",
5708
+ margin: "0",
5709
+ backgroundColor: "transparent",
5710
+ position: "relative"
5711
+ };
5712
+ this.dropAfterPlaceHolderStyle = {
5713
+ opacity: "0",
5714
+ height: "0px",
5715
+ width: "0",
5716
+ border: "0",
5717
+ margin: "0",
5718
+ backgroundColor: "transparent",
5719
+ position: "relative"
5720
+ };
5721
+ }
5722
+ handleDragOver(e) {
5723
+ e.preventDefault();
5724
+ e.stopPropagation();
5725
+ if (this.pendingLeaveTimeout) {
5726
+ clearTimeout(this.pendingLeaveTimeout);
5727
+ this.pendingLeaveTimeout = null;
5728
+ }
5729
+ const rect = this.getBoundingClientRect();
5730
+ e.clientY - rect.top;
5731
+ rect.height / 2;
5732
+ this.draggingComponentInfo?.blockInfo?.width ? `${this.draggingComponentInfo.blockInfo.width}` : "100%";
5733
+ const activeStyle = {
5734
+ zIndex: "900",
5735
+ opacity: "1",
5736
+ height: "40px",
5737
+ border: "2px dashed #3b82f6",
5738
+ margin: "0",
5739
+ backgroundColor: "#eff6ff",
5740
+ position: "relative"
5741
+ };
5742
+ this.dropBeforePlaceHolderStyle = activeStyle;
5743
+ }
5744
+ handleDropBefore(e) {
5745
+ if (!["before", "after", "inside"].includes(this.where)) {
5746
+ this.where = "before";
5747
+ }
5748
+ if (!this.draggingComponentInfo?.componentId) return;
5749
+ moveDraggedComponent(this.component.uuid, this.draggingComponentInfo.componentId, this.where);
5750
+ setDraggingComponentInfo(null);
5751
+ this.resetDropZones();
5752
+ e.preventDefault();
5753
+ e.stopPropagation();
5754
+ }
5755
+ render() {
5756
+ const isDragInitiator = this.component.uuid === this.draggingComponentInfo?.componentId;
5757
+ const beforeActive = this.dropBeforePlaceHolderStyle.opacity === "1";
5758
+ return html`
5759
+ ${!isDragInitiator ? html`<div
5760
+ @dragenter=${(e) => {
5761
+ e.preventDefault();
5762
+ }}
5763
+
5764
+ class="drop-zone ${beforeActive ? "active target" : ""} drop-${this.component.uuid}"
5765
+ style=${styleMap(this.dropBeforePlaceHolderStyle)}
5766
+ @drop=${this.handleDropBefore}
5767
+ ><div class="message">${this.message ?? "Drop here"}</div></div>` : nothing}
5768
+ `;
5769
+ }
5770
+ };
5771
+ DragWrapper.styles = [
5772
+ css`
5773
+ .drop-zone {
5774
+ position: relative;
5775
+ opacity: 0;
5776
+ height: 100px;
5777
+ margin: 0;
5778
+ border: 0;
5779
+ border-radius: 4px;
5780
+ transition: all 0.1s ease;
5781
+ position: relative;
5782
+ background-color: transparent;
5783
+ pointer-events: auto;
5784
+ max-width: 100%;
5785
+ }
5786
+ .message {
5787
+ display: flex;
5788
+ justify-content: center;
5789
+ align-items: center;
5790
+ width: 100%;
5791
+ height: 100%;
5792
+ color : #3b82f6;
5793
+ }
5794
+
5795
+ .drop-zone.active {
5796
+ opacity: 1;
5797
+ height: 40px;
5798
+ margin: 2px auto;
5799
+ border: 2px dashed #3b82f6;
5800
+ background-color: #eff6ff;
5801
+ }
5802
+
5803
+ .drop-zone.active.target::before {
5804
+ color: #3b82f6;
5805
+ opacity: 1;
5806
+ }
5807
+ `
5808
+ ];
5809
+ __decorateClass$3([
5810
+ property({ type: Object })
5811
+ ], DragWrapper.prototype, "component", 2);
5812
+ __decorateClass$3([
5813
+ property({ type: String })
5814
+ ], DragWrapper.prototype, "message", 2);
5815
+ __decorateClass$3([
5816
+ state()
5817
+ ], DragWrapper.prototype, "draggingComponentInfo", 2);
5818
+ __decorateClass$3([
5819
+ state()
5820
+ ], DragWrapper.prototype, "isDragging", 2);
5821
+ __decorateClass$3([
5822
+ state()
5823
+ ], DragWrapper.prototype, "dropBeforePlaceHolderStyle", 2);
5824
+ __decorateClass$3([
5825
+ state()
5826
+ ], DragWrapper.prototype, "dropAfterPlaceHolderStyle", 2);
5827
+ __decorateClass$3([
5828
+ property({ type: Object })
5829
+ ], DragWrapper.prototype, "inputRef", 2);
5830
+ __decorateClass$3([
5831
+ property({ type: String })
5832
+ ], DragWrapper.prototype, "where", 2);
5833
+ DragWrapper = __decorateClass$3([
5834
+ customElement("drag-wrapper")
5835
+ ], DragWrapper);
5836
+
5837
+ class DragDropController {
5838
+ constructor(host) {
5839
+ this.isActive = false;
5840
+ this.host = host;
5841
+ host.addController(this);
5842
+ this.boundDragEnter = this.handleDragEnter.bind(this);
5843
+ this.boundDrop = this.handleDrop.bind(this);
5844
+ this.boundDragLeave = this.handleDragLeave.bind(this);
5845
+ }
5846
+ hostConnected() {
5847
+ }
5848
+ hostDisconnected() {
5849
+ this.deactivate();
5850
+ }
5851
+ /**
5852
+ * Activate drag-drop controller (editor mode only)
5853
+ */
5854
+ activate() {
5855
+ if (this.isActive || this.host.isViewMode) return;
5856
+ this.isActive = true;
5857
+ this.host.closestGenericComponentWrapper = this.host.closest?.(
5858
+ "generik-component-wrapper"
5859
+ );
5860
+ this.host.addEventListener("dragenter", this.boundDragEnter);
5861
+ this.host.addEventListener("drop", this.boundDrop);
5862
+ this.host.addEventListener("dragleave", this.boundDragLeave);
5863
+ }
5864
+ /**
5865
+ * Deactivate drag-drop controller
5866
+ */
5867
+ deactivate() {
5868
+ if (!this.isActive) return;
5869
+ this.isActive = false;
5870
+ this.host.removeEventListener("dragenter", this.boundDragEnter);
5871
+ this.host.removeEventListener("drop", this.boundDrop);
5872
+ this.host.removeEventListener("dragleave", this.boundDragLeave);
5873
+ }
5874
+ /**
5875
+ * Handle drag enter event
5876
+ */
5877
+ handleDragEnter(_e) {
5878
+ this.notifyDragWrappers("drag-over-component");
5879
+ }
5880
+ /**
5881
+ * Handle drop event
5882
+ */
5883
+ handleDrop(_e) {
5884
+ this.notifyDragWrappers("drag-leave-component");
5885
+ }
5886
+ /**
5887
+ * Handle drag leave event
5888
+ */
5889
+ handleDragLeave(_e) {
5890
+ this.notifyDragWrappers("drag-leave-component");
5891
+ }
5892
+ /**
5893
+ * Notify drag wrappers of drag events
5894
+ */
5895
+ notifyDragWrappers(eventType) {
5896
+ const wrappers = this.host.shadowRoot?.querySelectorAll("drag-wrapper");
5897
+ wrappers?.forEach((wrapper) => {
5898
+ wrapper.dispatchEvent(
5899
+ new CustomEvent(eventType, {
5900
+ bubbles: true,
5901
+ composed: true
5902
+ })
5903
+ );
5904
+ });
5905
+ }
5906
+ /**
5907
+ * Render drag wrappers for editor mode
5908
+ */
5909
+ renderWrappers(itemIndex) {
5910
+ if (!this.isActive) return nothing;
5911
+ const { component, inputRef, isDragInitiator } = this.host;
5912
+ const componentData = { ...component };
5913
+ return html`
5914
+ ${[0, void 0].includes(itemIndex) ? html`
5915
+ <drag-wrapper
5916
+ .where=${"before"}
5917
+ .message=${"Drop before"}
5918
+ .component=${componentData}
5919
+ .inputRef=${inputRef}
5920
+ .isDragInitiator=${isDragInitiator}
5921
+ ></drag-wrapper>
5922
+ ` : nothing}
5923
+ `;
5924
+ }
5925
+ /**
5926
+ * Render after drag wrapper
5927
+ */
5928
+ renderAfterWrapper() {
5929
+ if (!this.isActive) return nothing;
5930
+ const { component, inputRef, isDragInitiator } = this.host;
5931
+ return html`
5932
+ <drag-wrapper
5933
+ .where=${"after"}
5934
+ .message=${"Drop after"}
5935
+ .component=${{ ...component }}
5936
+ .inputRef=${inputRef}
5937
+ .isDragInitiator=${isDragInitiator}
5938
+ ></drag-wrapper>
5939
+ `;
5940
+ }
5941
+ /**
5942
+ * Set drag initiator state
5943
+ */
5944
+ setDragInitiator(isInitiator) {
5945
+ this.host.isDragInitiator = isInitiator;
5946
+ }
5947
+ /**
5948
+ * Check if this component is the drag initiator
5949
+ */
5950
+ isDragInitiator() {
5951
+ return this.host.isDragInitiator;
5952
+ }
5953
+ /**
5954
+ * Clean up all resources
5955
+ */
5956
+ dispose() {
5957
+ this.deactivate();
5958
+ }
5959
+ }
5960
+
5961
+ var __defProp$2 = Object.defineProperty;
5962
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5963
+ var __decorateClass$2 = (decorators, target, key, kind) => {
5964
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5965
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
5966
+ if (decorator = decorators[i])
5967
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
5968
+ if (kind && result) __defProp$2(target, key, result);
5969
+ return result;
5970
+ };
5971
+ let HandlerComponentError = class extends LitElement {
5972
+ render() {
5973
+ return html`
5974
+ <div style="
5975
+ margin-top: 20px;
5976
+ position: absolute;
5977
+ z-index: 1001;
5978
+ background: white;
5979
+ padding: 5px;
5980
+ border-radius: 4px;
5981
+ font-weight: 400;
5982
+ font-size: 14px;
5983
+ color: #c33d3d;
5984
+ border-radius: 18px;
5985
+ border: 1px solid;
5986
+ font-size: 12px;
5987
+ ">
5988
+ <pre>${JSON.stringify(this.error, null, 2)}</pre>
5989
+ </div>
5990
+ `;
5991
+ }
5992
+ };
5993
+ __decorateClass$2([
5994
+ property({ type: Object })
5995
+ ], HandlerComponentError.prototype, "error", 2);
5996
+ HandlerComponentError = __decorateClass$2([
5997
+ customElement("handler-component-error-block")
5998
+ ], HandlerComponentError);
5999
+
6000
+ class ErrorController {
6001
+ constructor(host) {
6002
+ this.isActive = false;
6003
+ this.host = host;
6004
+ host.addController(this);
6005
+ }
6006
+ hostConnected() {
6007
+ }
6008
+ hostDisconnected() {
6009
+ this.deactivate();
6010
+ }
6011
+ /**
6012
+ * Activate error controller (editor mode only)
6013
+ */
6014
+ activate() {
6015
+ if (this.isActive || this.host.isViewMode) return;
6016
+ this.isActive = true;
6017
+ }
6018
+ /**
6019
+ * Deactivate error controller
6020
+ */
6021
+ deactivate() {
6022
+ if (!this.isActive) return;
6023
+ this.isActive = false;
6024
+ this.host.displayErrorPanel = false;
6025
+ }
6026
+ /**
6027
+ * Get current component errors from debug store
6028
+ */
6029
+ getErrors() {
6030
+ const debugState = $debug.get();
6031
+ return debugState?.error?.components?.[this.host.component.uuid]?.errors ?? null;
6032
+ }
6033
+ /**
6034
+ * Check if component has any errors
6035
+ */
6036
+ hasErrors() {
6037
+ const errors = this.getErrors();
6038
+ return errors !== null && !hasOnlyEmptyObjects(errors);
6039
+ }
6040
+ /**
6041
+ * Show error panel
6042
+ */
6043
+ showPanel() {
6044
+ this.host.displayErrorPanel = true;
6045
+ this.host.requestUpdate();
6046
+ }
6047
+ /**
6048
+ * Hide error panel
6049
+ */
6050
+ hidePanel() {
6051
+ this.host.displayErrorPanel = false;
6052
+ this.host.requestUpdate();
6053
+ }
6054
+ /**
6055
+ * Toggle error panel visibility
6056
+ */
6057
+ togglePanel() {
6058
+ this.host.displayErrorPanel = !this.host.displayErrorPanel;
6059
+ this.host.requestUpdate();
6060
+ }
6061
+ /**
6062
+ * Render error indicator and panel
6063
+ */
6064
+ renderError() {
6065
+ if (!this.isActive) return nothing;
6066
+ const errors = this.getErrors();
6067
+ if (!errors || hasOnlyEmptyObjects(errors)) return nothing;
6068
+ return html`
6069
+ <div
6070
+ @mouseenter=${() => this.showPanel()}
6071
+ @mouseleave=${() => this.hidePanel()}
6072
+ style="position: absolute; z-index: 1000;"
6073
+ >
6074
+ <nr-icon
6075
+ name="info-circle"
6076
+ style="
6077
+ z-index: 1000;
6078
+ --nuraly-icon-width: 20px;
6079
+ --nuraly-icon-height: 25px;
6080
+ --nuraly-icon-color: red;
6081
+ position: absolute;
6082
+ cursor: pointer;
6083
+ "
6084
+ >
6085
+ Error
6086
+ </nr-icon>
6087
+ ${this.host.displayErrorPanel ? html`
6088
+ <handler-component-error-block
6089
+ .error=${errors}
6090
+ ></handler-component-error-block>
6091
+ ` : nothing}
6092
+ </div>
6093
+ `;
6094
+ }
6095
+ /**
6096
+ * Get error summary for display
6097
+ */
6098
+ getErrorSummary() {
6099
+ const errors = this.getErrors();
6100
+ if (!errors) return { count: 0, messages: [] };
6101
+ const messages = [];
6102
+ let count = 0;
6103
+ for (const [key, value] of Object.entries(errors)) {
6104
+ if (value && typeof value === "object" && "error" in value) {
6105
+ count++;
6106
+ messages.push(`${key}: ${value.error}`);
6107
+ }
6108
+ }
6109
+ return { count, messages };
6110
+ }
6111
+ /**
6112
+ * Clear all errors for this component
6113
+ */
6114
+ clearErrors() {
6115
+ this.host.errors = {};
6116
+ }
6117
+ /**
6118
+ * Add an error for a specific input
6119
+ */
6120
+ addError(inputName, message) {
6121
+ this.host.errors[inputName] = { error: message };
6122
+ }
6123
+ /**
6124
+ * Remove an error for a specific input
6125
+ */
6126
+ removeError(inputName) {
6127
+ delete this.host.errors[inputName];
6128
+ }
6129
+ /**
6130
+ * Clean up all resources
6131
+ */
6132
+ dispose() {
6133
+ this.deactivate();
6134
+ }
6135
+ }
6136
+
6137
+ var __defProp$1 = Object.defineProperty;
6138
+ var __decorateClass$1 = (decorators, target, key, kind) => {
6139
+ var result = void 0 ;
6140
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6141
+ if (decorator = decorators[i])
6142
+ result = (decorator(target, key, result) ) || result;
6143
+ if (result) __defProp$1(target, key, result);
6144
+ return result;
6145
+ };
6146
+ function EditorModeMixin(superClass) {
6147
+ class EditorModeElement extends superClass {
6148
+ constructor(...args) {
6149
+ super(...args);
6150
+ this.currentSelection = [];
6151
+ this.isDragInitiator = false;
6152
+ this.displayErrorPanel = false;
6153
+ this.isEditable = false;
6154
+ this.hoveredComponent = null;
6155
+ this.closestGenericComponentWrapper = null;
6156
+ }
6157
+ connectedCallback() {
6158
+ super.connectedCallback();
6159
+ if (!this.isViewMode) {
6160
+ if (!this.selectionController) {
6161
+ this.selectionController = new SelectionController(this);
6162
+ }
6163
+ if (!this.dragDropController) {
6164
+ this.dragDropController = new DragDropController(this);
6165
+ }
6166
+ if (!this.errorController) {
6167
+ this.errorController = new ErrorController(this);
6168
+ }
6169
+ this.selectionController.activate();
6170
+ this.dragDropController.activate();
6171
+ this.errorController.activate();
6172
+ }
6173
+ }
6174
+ disconnectedCallback() {
6175
+ if (!this.isViewMode) {
6176
+ this.selectionController?.deactivate();
6177
+ this.dragDropController?.deactivate();
6178
+ this.errorController?.deactivate();
6179
+ }
6180
+ super.disconnectedCallback();
6181
+ }
6182
+ /**
6183
+ * Select this component in the editor
6184
+ */
6185
+ selectComponent(event) {
6186
+ if (!this.isViewMode && this.selectionController) {
6187
+ this.selectionController.select(event);
6188
+ }
6189
+ }
6190
+ /**
6191
+ * Check if this component is currently selected
6192
+ */
6193
+ isSelected() {
6194
+ return this.selectionController?.isSelected() ?? false;
6195
+ }
6196
+ /**
6197
+ * Check if this component is currently hovered
6198
+ */
6199
+ isHovered() {
6200
+ return this.selectionController?.isHovered() ?? false;
6201
+ }
6202
+ /**
6203
+ * Render error indicator (editor only)
6204
+ */
6205
+ renderEditorError() {
6206
+ if (this.isViewMode) return nothing;
6207
+ return this.errorController?.renderError() ?? nothing;
6208
+ }
6209
+ /**
6210
+ * Render drag wrappers before content (editor only)
6211
+ */
6212
+ renderBeforeDragWrapper() {
6213
+ if (this.isViewMode) return nothing;
6214
+ const itemIndex = this.item?.index;
6215
+ return this.dragDropController?.renderWrappers(itemIndex) ?? nothing;
6216
+ }
6217
+ /**
6218
+ * Render drag wrapper after content (editor only)
6219
+ */
6220
+ renderAfterDragWrapper() {
6221
+ if (this.isViewMode) return nothing;
6222
+ return this.dragDropController?.renderAfterWrapper() ?? nothing;
6223
+ }
6224
+ /**
6225
+ * Render full editor overlay (error + drag wrappers)
6226
+ */
6227
+ renderEditorOverlay() {
6228
+ if (this.isViewMode) return nothing;
6229
+ const itemIndex = this.item?.index;
6230
+ return html`
6231
+ ${this.renderEditorError()}
6232
+ ${[0, void 0].includes(itemIndex) ? this.renderBeforeDragWrapper() : nothing}
6233
+ `;
6234
+ }
6235
+ /**
6236
+ * Check if component has errors
6237
+ */
6238
+ hasErrors() {
6239
+ return this.errorController?.hasErrors() ?? false;
6240
+ }
6241
+ /**
6242
+ * Get error summary
6243
+ */
6244
+ getErrorSummary() {
6245
+ return this.errorController?.getErrorSummary() ?? { count: 0, messages: [] };
6246
+ }
6247
+ }
6248
+ __decorateClass$1([
6249
+ state()
6250
+ ], EditorModeElement.prototype, "currentSelection");
6251
+ __decorateClass$1([
6252
+ state()
6253
+ ], EditorModeElement.prototype, "isDragInitiator");
6254
+ __decorateClass$1([
6255
+ state()
6256
+ ], EditorModeElement.prototype, "displayErrorPanel");
6257
+ __decorateClass$1([
6258
+ state()
6259
+ ], EditorModeElement.prototype, "isEditable");
6260
+ __decorateClass$1([
6261
+ state()
6262
+ ], EditorModeElement.prototype, "hoveredComponent");
6263
+ __decorateClass$1([
6264
+ state()
6265
+ ], EditorModeElement.prototype, "closestGenericComponentWrapper");
6266
+ return EditorModeElement;
6267
+ }
6268
+
6269
+ function scrollToTarget(ref) {
6270
+ ref.value?.scrollIntoView({ behavior: "smooth" });
6271
+ }
6272
+ function setupHashScroll(ref, id, scrollFn) {
6273
+ const handler = () => {
6274
+ const hash = window.location.hash.slice(1);
6275
+ if (hash && id === hash) scrollFn();
6276
+ };
6277
+ handler();
6278
+ window.addEventListener("hashchange", handler);
6279
+ }
6280
+
6281
+ var __defProp = Object.defineProperty;
6282
+ var __decorateClass = (decorators, target, key, kind) => {
6283
+ var result = void 0 ;
6284
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6285
+ if (decorator = decorators[i])
6286
+ result = (decorator(target, key, result) ) || result;
6287
+ if (result) __defProp(target, key, result);
6288
+ return result;
6289
+ };
6290
+ class BaseElementCore extends LitElement {
6291
+ // ═══════════════════════════════════════════════════════════════════════════
6292
+ // CONSTRUCTOR
6293
+ // ═══════════════════════════════════════════════════════════════════════════
6294
+ constructor() {
6295
+ super();
6296
+ this.isViewMode = false;
6297
+ this.inputHandlersValue = {};
6298
+ this.stylesHandlersValue = {};
6299
+ this.calculatedStyles = {};
6300
+ this.errors = {};
6301
+ // ═══════════════════════════════════════════════════════════════════════════
6302
+ // REFS & IDENTIFIERS
6303
+ // ═══════════════════════════════════════════════════════════════════════════
6304
+ /** Reference to the main rendered element */
6305
+ this.inputRef = createRef();
6306
+ /** Unique instance ID for this component instance */
6307
+ this.uniqueUUID = v4();
6308
+ // ═══════════════════════════════════════════════════════════════════════════
6309
+ // CALLBACKS & EXTERNAL INTEGRATION
6310
+ // ═══════════════════════════════════════════════════════════════════════════
6311
+ /** Registry for input value callbacks */
6312
+ this.callbacks = {};
6313
+ /** Execution instance for runtime context */
6314
+ this.ExecuteInstance = ExecuteInstance;
6315
+ /** Component style definitions */
6316
+ this.componentStyles = {};
6317
+ this.currentPlatform = ExecuteInstance.Vars.currentPlatform ?? getInitPlatform();
6318
+ this.inputController = new InputHandlerController(this);
6319
+ this.styleController = new StyleHandlerController(this);
6320
+ this.eventController = new EventController(this);
6321
+ this.handleHash = () => setupHashScroll(
6322
+ this.inputRef,
6323
+ this.id,
6324
+ () => scrollToTarget(this.inputRef)
6325
+ );
6326
+ }
6327
+ // ═══════════════════════════════════════════════════════════════════════════
6328
+ // CALLBACK REGISTRATION (for child components to react to input changes)
6329
+ // ═══════════════════════════════════════════════════════════════════════════
6330
+ /**
6331
+ * Register a callback to be invoked when an input value changes
6332
+ * @param inputName - Name of the input to watch
6333
+ * @param callback - Function to call with new value
6334
+ */
6335
+ registerCallback(inputName, callback) {
6336
+ this.callbacks[inputName] = callback;
6337
+ }
6338
+ /**
6339
+ * Unregister a previously registered callback
6340
+ * @param inputName - Name of the input callback to remove
6341
+ */
6342
+ unregisterCallback(inputName) {
6343
+ delete this.callbacks[inputName];
6344
+ }
6345
+ // ═══════════════════════════════════════════════════════════════════════════
6346
+ // LIFECYCLE METHODS
6347
+ // ═══════════════════════════════════════════════════════════════════════════
6348
+ connectedCallback() {
6349
+ super.connectedCallback();
6350
+ if (this.component?.uuid) {
6351
+ this.classList.add(`component-${this.component.uuid}`);
6352
+ this.dataset.componentUuid = this.component.uuid;
6353
+ }
6354
+ if (this.component) {
6355
+ this.component.uniqueUUID = this.uniqueUUID;
6356
+ this.component.parent = this.parentcomponent;
6357
+ }
6358
+ }
6359
+ firstUpdated(_changedProperties) {
6360
+ super.firstUpdated(_changedProperties);
6361
+ this.inputController.processInputs();
6362
+ this.styleController.processStyles();
6363
+ this.handleHash();
6364
+ window.addEventListener("hashchange", this.handleHash);
6365
+ }
6366
+ disconnectedCallback() {
6367
+ window.removeEventListener("hashchange", this.handleHash);
6368
+ super.disconnectedCallback();
6369
+ }
6370
+ update(changedProperties) {
6371
+ super.update(changedProperties);
6372
+ if (changedProperties.has("component")) {
6373
+ const prev = changedProperties.get("component");
6374
+ const curr = this.component;
6375
+ if (prev?.event?.onInit !== curr?.event?.onInit) {
6376
+ this.eventController.executeOnInit();
6377
+ }
6378
+ if (curr) {
6379
+ curr.uniqueUUID = this.uniqueUUID;
6380
+ curr.parent = this.parentcomponent;
6381
+ if (curr.uuid) {
6382
+ this.dataset.componentUuid = curr.uuid;
6383
+ }
6384
+ }
6385
+ this.inputController.processInputsDebounced();
6386
+ this.styleController.processStyles();
6387
+ }
6388
+ }
6389
+ // ═══════════════════════════════════════════════════════════════════════════
6390
+ // PUBLIC API
6391
+ // ═══════════════════════════════════════════════════════════════════════════
6392
+ /**
6393
+ * Execute a component event handler
6394
+ * @param eventName - Name of the event (onClick, onChange, etc.)
6395
+ * @param event - Optional DOM event that triggered this
6396
+ * @param data - Additional data to pass to the handler
6397
+ */
6398
+ executeEvent(eventName, event, data = {}) {
6399
+ this.eventController.execute(eventName, event, data);
6400
+ }
6401
+ /**
6402
+ * Get computed styles for the component
6403
+ * Merges editor styles, handler values, and runtime styles
6404
+ */
6405
+ getStyles() {
6406
+ return this.styleController.getComputedStyles();
6407
+ }
6408
+ /**
6409
+ * Force reprocessing of input handlers
6410
+ */
6411
+ refreshInputs() {
6412
+ this.inputController.processInputs();
6413
+ }
6414
+ /**
6415
+ * Force reprocessing of style handlers
6416
+ */
6417
+ refreshStyles() {
6418
+ this.styleController.processStyles();
6419
+ }
6420
+ // ═══════════════════════════════════════════════════════════════════════════
6421
+ // RENDERING
6422
+ // ═══════════════════════════════════════════════════════════════════════════
6423
+ /**
6424
+ * Whether component should be displayed based on display input
6425
+ */
6426
+ get shouldDisplay() {
6427
+ return this.inputHandlersValue?.display !== false;
6428
+ }
6429
+ /**
6430
+ * Render the component content - to be implemented by child classes
6431
+ */
6432
+ renderComponent() {
6433
+ return nothing;
6434
+ }
6435
+ /**
6436
+ * Render pseudo-state styles (hover, focus, active, disabled)
6437
+ */
6438
+ renderPseudoStateStyles() {
6439
+ const cssString = this.styleController.generatePseudoStateCSS();
6440
+ if (!cssString) return nothing;
6441
+ return html`<style>${cssString}</style>`;
6442
+ }
6443
+ render() {
6444
+ if (!this.shouldDisplay) return nothing;
6445
+ this.componentStyles = this.calculatedStyles || {};
6446
+ const labelStyleHandlers = this.component?.styleHandlers ? Object.fromEntries(
6447
+ Object.entries(this.component.styleHandlers).filter(([_, value]) => value)
6448
+ ) : {};
6449
+ this.componentStyles = { ...this.componentStyles, ...labelStyleHandlers };
6450
+ return html`
6451
+ ${this.renderPseudoStateStyles()}
6452
+ ${this.renderComponent()}
6453
+ `;
6454
+ }
6455
+ }
6456
+ __decorateClass([
6457
+ property({ type: Object })
6458
+ ], BaseElementCore.prototype, "component");
6459
+ __decorateClass([
6460
+ property({ type: Object, reflect: true })
6461
+ ], BaseElementCore.prototype, "item");
6462
+ __decorateClass([
6463
+ property({ type: Object })
6464
+ ], BaseElementCore.prototype, "parentcomponent");
6465
+ __decorateClass([
6466
+ property({ type: Boolean })
6467
+ ], BaseElementCore.prototype, "isViewMode");
6468
+ __decorateClass([
6469
+ state()
6470
+ ], BaseElementCore.prototype, "inputHandlersValue");
6471
+ __decorateClass([
6472
+ state()
6473
+ ], BaseElementCore.prototype, "stylesHandlersValue");
6474
+ __decorateClass([
6475
+ state()
6476
+ ], BaseElementCore.prototype, "calculatedStyles");
6477
+ __decorateClass([
6478
+ state()
6479
+ ], BaseElementCore.prototype, "errors");
6480
+ class BaseElementBlock extends EditorModeMixin(BaseElementCore) {
6481
+ /**
6482
+ * Override render to include editor overlays
6483
+ */
6484
+ render() {
6485
+ if (!this.shouldDisplay) return nothing;
6486
+ this.componentStyles = this.calculatedStyles || {};
6487
+ const labelStyleHandlers = this.component?.styleHandlers ? Object.fromEntries(
6488
+ Object.entries(this.component.styleHandlers).filter(([_, value]) => value)
6489
+ ) : {};
6490
+ this.componentStyles = { ...this.componentStyles, ...labelStyleHandlers };
6491
+ return html`
6492
+ ${this.renderPseudoStateStyles()}
6493
+ ${this.renderEditorOverlay()}
6494
+ ${this.renderComponent()}
6495
+ ${this.renderAfterDragWrapper()}
6496
+ `;
6497
+ }
6498
+ }
6499
+
6500
+ export { $components as $, $componentWithChildren as A, $runtimeStyles as B, $runtimeValues as C, $componentRuntimeValuesById as D, ExecuteInstance as E, FRONT_API_URLS as F, $componentRuntimeValueByKey as G, $componentsByUUIDs as H, $runtimeStylescomponentStyleByID as I, getAllChildrenRecursive as J, getDirectChildren as K, $componentById as L, setComponentRuntimeValue as M, setComponentRuntimeValues as N, setcomponentRuntimeStyleAttribute as O, clearComponentRuntimeValues as P, clearComponentRuntimeValue as Q, RuntimeInstance as R, clearAllRuntimeValues as S, clearComponentRuntimeStyleAttributes as T, fillComponentChildren as U, fillApplicationComponents as V, extractChildresIds as W, extractAllChildrenIds as X, $applications as Y, $currentPage as Z, $contextMenuEvent as _, $hoveredComponent as a, validateComponentHandlers as a$, $microAppCurrentPage as a0, $applicationPages as a1, refreshPageStoreVar as a2, $context as a3, ViewMode as a4, $toasts as a5, $debug as a6, $providers as a7, executeHandler as a8, getContextFromComponent as a9, addlogDebug as aA, resetComponentDebug as aB, addComponentHandler as aC, deleteComponentActionHandler as aD, validateAndEmitErrors as aE, updatePageHandler as aF, deletePageHandler as aG, refreshPagesActionHandler as aH, loadOrRefreshApplications as aI, createApplicationAction as aJ, deleteApplicationAction as aK, addPermission as aL, invokeFunctionHandler as aM, loadFunctionsHandler as aN, renderComponent as aO, log as aP, setLogLevel as aQ, enableLogging as aR, enableBenchmarking as aS, LOG_LEVELS as aT, eventDispatcher as aU, copyCpmponentToClipboard as aV, pasteComponentFromClipboard as aW, traitCompoentFromSchema as aX, generateNuralyClipboardStructure as aY, RuntimeContextHelpers as aZ, validateHandlerCode as a_, compileHandlerFunction as aa, ComponentRegistry as ab, registerComponent as ac, registerComponents as ad, BaseElementBlock as ae, BaseElementCore as af, addComponentAction as ag, addComponentToCurrentPageAction as ah, deleteComponentAction as ai, moveDraggedComponent as aj, setCurrentComponentIdAction as ak, setDraggingComponentInfo as al, updateComponentName as am, updateComponentAttributes as an, deletePageAction as ao, setContextMenuEvent as ap, updatePageAction as aq, addPageToApplicationAction as ar, addTempApplication as as, setApplication as at, setPermissionMessage as au, updateApplication as av, closeCreateApplicationModalAction as aw, openEditorTab as ax, setCurrentEditorTab as ay, addGeneratedComponents as az, $hoveredComponentId as b, isForbiddenGlobal as b0, isForbiddenProperty as b1, isAllowedGlobal as b2, isForbiddenFunction as b3, getErrorMessage as b4, FORBIDDEN_GLOBALS as b5, FORBIDDEN_PROPERTIES as b6, FORBIDDEN_FUNCTIONS as b7, VALIDATION_ERROR_MESSAGES as b8, formatValidationErrors as b9, getNestedAttribute as ba, hasOnlyEmptyObjects as bb, GenerateName as bc, showToast as bd, hideToast as be, clearAllToasts as bf, showSuccess as bg, showError as bh, showWarning as bi, showInfo as bj, NO_EVENT_LISTENER as bk, EMPTY_STRING as bl, ToastContainer as bm, getInitPlatform as bn, $showShareApplicationModal as c, $permissionsState as d, $applicationPermission as e, $currentApplication as f, updateApplicationActionHandler as g, $showCreateApplicationModal as h, $editorState as i, $environment as j, addPageHandler as k, $currentPageId as l, $currentPageViewPort as m, $resizing as n, $showBorder as o, $pageSize as p, $pages as q, removeComponentToCurrentPageAction as r, $pageZoom as s, EditorInstance as t, updateComponentHandler as u, RuntimeHelpers as v, $applicationComponents as w, $selectedComponent as x, $currentComponentId as y, $draggingComponentInfo as z };