@grapesjs/studio-sdk-plugins 1.0.36 → 1.0.38-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/accordionComponent/index.cjs.js +4 -4
  2. package/dist/accordionComponent/index.es.js +83 -70
  3. package/dist/accordionComponent/index.umd.js +5 -5
  4. package/dist/aiChat/clientToolsProcessors.d.ts +1 -2
  5. package/dist/aiChat/components/utils.d.ts +1 -0
  6. package/dist/aiChat/components/utilsTw.d.ts +11 -0
  7. package/dist/aiChat/index.cjs.js +85 -85
  8. package/dist/aiChat/index.es.js +11151 -10258
  9. package/dist/aiChat/index.js +85 -85
  10. package/dist/aiChat/index.umd.js +86 -86
  11. package/dist/aiChat/locales/en.d.ts +11 -0
  12. package/dist/aiChat/projectGeneration.d.ts +17 -0
  13. package/dist/aiChat/server/index.cjs.js +1 -1
  14. package/dist/aiChat/server/index.es.js +1 -1
  15. package/dist/aiChat/server/index.js +1 -1
  16. package/dist/aiChat/server/index.umd.js +1 -1
  17. package/dist/aiChat/types.d.ts +1 -1
  18. package/dist/animationComponent/index.cjs.js +3 -3
  19. package/dist/animationComponent/index.es.js +57 -44
  20. package/dist/animationComponent/index.umd.js +3 -3
  21. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  22. package/dist/canvasAbsoluteMode/index.es.js +63 -50
  23. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  24. package/dist/canvasEmptyState/index.cjs.js +1 -1
  25. package/dist/canvasEmptyState/index.es.js +60 -47
  26. package/dist/canvasEmptyState/index.umd.js +1 -1
  27. package/dist/canvasFullSize/index.cjs.js +3 -3
  28. package/dist/canvasFullSize/index.es.js +49 -36
  29. package/dist/canvasFullSize/index.umd.js +5 -5
  30. package/dist/canvasGridMode/index.cjs.js +2 -2
  31. package/dist/canvasGridMode/index.es.js +251 -233
  32. package/dist/canvasGridMode/index.umd.js +4 -4
  33. package/dist/canvasScreenshot/index.cjs.js +1 -1
  34. package/dist/canvasScreenshot/index.es.js +42 -29
  35. package/dist/canvasScreenshot/index.umd.js +1 -1
  36. package/dist/dataSourceEjs/index.cjs.js +3 -3
  37. package/dist/dataSourceEjs/index.es.js +51 -38
  38. package/dist/dataSourceEjs/index.umd.js +3 -3
  39. package/dist/dataSourceHandlebars/index.cjs.js +2 -2
  40. package/dist/dataSourceHandlebars/index.es.js +152 -139
  41. package/dist/dataSourceHandlebars/index.umd.js +4 -4
  42. package/dist/dialogComponent/index.cjs.js +9 -9
  43. package/dist/dialogComponent/index.es.js +73 -60
  44. package/dist/dialogComponent/index.umd.js +3 -3
  45. package/dist/flexComponent/index.cjs.js +6 -6
  46. package/dist/flexComponent/index.es.js +83 -70
  47. package/dist/flexComponent/index.umd.js +6 -6
  48. package/dist/fsLightboxComponent/index.cjs.js +2 -2
  49. package/dist/fsLightboxComponent/index.es.js +67 -54
  50. package/dist/fsLightboxComponent/index.umd.js +2 -2
  51. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  52. package/dist/googleFontsAssetProvider/index.es.js +92 -79
  53. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  54. package/dist/iconifyComponent/index.cjs.js +2 -2
  55. package/dist/iconifyComponent/index.es.js +52 -39
  56. package/dist/iconifyComponent/index.umd.js +2 -2
  57. package/dist/index.cjs.js +42 -42
  58. package/dist/index.es.js +1167 -1149
  59. package/dist/index.umd.js +42 -42
  60. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  61. package/dist/layoutSidebarButtons/index.es.js +82 -69
  62. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  63. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  64. package/dist/lightGalleryComponent/index.es.js +98 -85
  65. package/dist/lightGalleryComponent/index.umd.js +1 -1
  66. package/dist/linkImageComponent/index.cjs.js +2 -2
  67. package/dist/linkImageComponent/index.es.js +71 -58
  68. package/dist/linkImageComponent/index.umd.js +2 -2
  69. package/dist/listPagesComponent/index.cjs.js +3 -3
  70. package/dist/listPagesComponent/index.es.js +49 -36
  71. package/dist/listPagesComponent/index.umd.js +3 -3
  72. package/dist/presetPrintable/index.cjs.js +5 -5
  73. package/dist/presetPrintable/index.es.js +126 -113
  74. package/dist/presetPrintable/index.umd.js +4 -4
  75. package/dist/prosemirror/index.cjs.js +1 -1
  76. package/dist/prosemirror/index.es.js +97 -84
  77. package/dist/prosemirror/index.umd.js +1 -1
  78. package/dist/rendererReact/index.cjs.js +1 -1
  79. package/dist/rendererReact/index.es.js +149 -137
  80. package/dist/rendererReact/index.js +1 -1
  81. package/dist/rendererReact/index.umd.js +1 -1
  82. package/dist/rteTinyMce/index.cjs.js +2 -2
  83. package/dist/rteTinyMce/index.es.js +92 -79
  84. package/dist/rteTinyMce/index.umd.js +2 -2
  85. package/dist/shapeDividerComponent/index.cjs.js +3 -3
  86. package/dist/shapeDividerComponent/index.es.js +38 -25
  87. package/dist/shapeDividerComponent/index.umd.js +3 -3
  88. package/dist/swiperComponent/index.cjs.js +5 -5
  89. package/dist/swiperComponent/index.es.js +106 -93
  90. package/dist/swiperComponent/index.umd.js +5 -5
  91. package/dist/tableComponent/index.cjs.js +1 -1
  92. package/dist/tableComponent/index.es.js +167 -154
  93. package/dist/tableComponent/index.umd.js +1 -1
  94. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  95. package/dist/youtubeAssetProvider/index.es.js +35 -22
  96. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  97. package/package.json +2 -2
@@ -1,25 +1,38 @@
1
- const I = "app.grapesjs.com", m = "app-stage.grapesjs.com", v = "app2.grapesjs.com", O = "app-stage2.grapesjs.com", $ = [
2
- I,
3
- v,
1
+ const m = "app.grapesjs.com", I = "app-stage.grapesjs.com", v = "app2.grapesjs.com", w = "app-stage2.grapesjs.com", $ = [
4
2
  m,
5
- O,
3
+ v,
4
+ I,
5
+ w,
6
6
  "localhost",
7
7
  "127.0.0.1",
8
8
  ".local-credentialless.webcontainer.io",
9
9
  // For stackblitz.com demos
10
10
  ".local.webcontainer.io",
11
11
  // For stackblitz.com demos
12
- "-sandpack.codesandbox.io"
12
+ "-sandpack.codesandbox.io",
13
13
  // For Sandpack demos
14
- ], w = "license:check:end", T = () => typeof window < "u", L = ({
14
+ ".claudemcpcontent.com",
15
+ // For Claude mcp app
16
+ ".web-sandbox.oaiusercontent.com"
17
+ // For OpenAI mcp app
18
+ ], O = "license:check:end", T = () => typeof window < "u", L = ({
15
19
  isDev: s,
16
20
  isStage: t,
17
21
  isPlatform: e
18
- }) => `${s ? "" : `https://${t ? m : I}`}/${e ? "platform-api" : "api"}`, k = () => {
19
- const s = T() && window.location.hostname;
22
+ }) => `${s ? "" : `https://${t ? I : m}`}/${e ? "platform-api" : "api"}`, k = () => {
23
+ if (!T()) return "";
24
+ const { hostname: s } = window.location;
25
+ if (s) return s;
26
+ try {
27
+ return window.parent.location.hostname || "";
28
+ } catch {
29
+ return "";
30
+ }
31
+ }, A = () => {
32
+ const s = k();
20
33
  return !!s && ($.includes(s) || $.some((t) => s.endsWith(t)));
21
34
  };
22
- async function A({
35
+ async function B({
23
36
  path: s,
24
37
  baseApiUrl: t,
25
38
  method: e = "GET",
@@ -40,19 +53,19 @@ async function A({
40
53
  throw new Error(`HTTP error! status: ${p.status}`);
41
54
  return p.json();
42
55
  }
43
- var y = /* @__PURE__ */ ((s) => (s.free = "free", s.startup = "startup", s.business = "business", s.enterprise = "enterprise", s))(y || {}), b = /* @__PURE__ */ ((s) => (s.toastAdd = "studio:toastAdd", s.toastRemove = "studio:toastRemove", s.dialogOpen = "studio:dialogOpen", s.dialogClose = "studio:dialogClose", s.dialogExportCode = "studio:dialogExportCode", s.dialogImportCode = "studio:dialogImportCode", s.sidebarLeftSet = "studio:sidebarLeft:set", s.sidebarLeftGet = "studio:sidebarLeft:get", s.sidebarLeftToggle = "studio:sidebarLeft:toggle", s.sidebarRightSet = "studio:sidebarRight:set", s.sidebarRightGet = "studio:sidebarRight:get", s.sidebarRightToggle = "studio:sidebarRight:toggle", s.sidebarTopSet = "studio:sidebarTop:set", s.sidebarTopGet = "studio:sidebarTop:get", s.sidebarTopToggle = "studio:sidebarTop:toggle", s.sidebarBottomSet = "studio:sidebarBottom:set", s.sidebarBottomGet = "studio:sidebarBottom:get", s.sidebarBottomToggle = "studio:sidebarBottom:toggle", s.symbolAdd = "studio:symbolAdd", s.symbolDetach = "studio:symbolDetach", s.symbolOverride = "studio:symbolOverride", s.symbolPropagateStyles = "studio:propagateStyles", s.getPagesConfig = "studio:getPagesConfig", s.setPagesConfig = "studio:setPagesConfig", s.getPageSettings = "studio:getPageSettings", s.setPageSettings = "studio:setPageSettings", s.clearPage = "studio:clearPage", s.projectFiles = "studio:projectFiles", s.validateCode = "studio:validateCode", s.canvasReload = "studio:canvasReload", s.getBlocksPanel = "studio:getBlocksPanel", s.setBlocksPanel = "studio:setBlocksPanel", s.getStateContextMenu = "studio:getStateContextMenu", s.setStateContextMenu = "studio:setStateContextMenu", s.contextMenuComponent = "studio:contextMenuComponent", s.layoutAdd = "studio:layoutAdd", s.layoutRemove = "studio:layoutRemove", s.layoutToggle = "studio:layoutToggle", s.layoutUpdate = "studio:layoutUpdate", s.layoutGet = "studio:layoutGet", s.layoutConfigGet = "studio:layoutConfigGet", s.layoutConfigSet = "studio:layoutConfigSet", s.layoutComponentAdd = "studio:layoutComponentAdd", s.layoutComponentGet = "studio:layoutComponentGet", s.layoutComponentRemove = "studio:layoutComponentRemove", s.layoutComponentRender = "studio:layoutComponentRender", s.getStateTheme = "studio:getStateTheme", s.setStateTheme = "studio:setStateTheme", s.settings = "studio:settings", s.assetProviderGet = "studio:assetProviderGet", s.assetProviderAdd = "studio:assetProviderAdd", s.assetProviderRemove = "studio:assetProviderRemove", s.fontGet = "studio:fontGet", s.fontAdd = "studio:fontAdd", s.fontRemove = "studio:fontRemove", s.fontManagerOpen = "studio:fontManagerOpen", s.menuFontLoad = "studio:menuFontLoad", s.toggleStateDataSource = "studio:toggleStateDataSource", s.getStateDataSource = "studio:getStateDataSource", s.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", s.dataSourceSetImporter = "studio:dataSourceSetImporter", s.dataSourceSetExporter = "studio:dataSourceSetExporter", s.setDragAbsolute = "studio:setDragAbsolute", s))(b || {});
56
+ var y = /* @__PURE__ */ ((s) => (s.free = "free", s.startup = "startup", s.business = "business", s.enterprise = "enterprise", s))(y || {}), b = /* @__PURE__ */ ((s) => (s.toastAdd = "studio:toastAdd", s.toastRemove = "studio:toastRemove", s.dialogOpen = "studio:dialogOpen", s.dialogClose = "studio:dialogClose", s.dialogExportCode = "studio:dialogExportCode", s.dialogImportCode = "studio:dialogImportCode", s.openEditCode = "studio:openEditCode", s.sidebarLeftSet = "studio:sidebarLeft:set", s.sidebarLeftGet = "studio:sidebarLeft:get", s.sidebarLeftToggle = "studio:sidebarLeft:toggle", s.sidebarRightSet = "studio:sidebarRight:set", s.sidebarRightGet = "studio:sidebarRight:get", s.sidebarRightToggle = "studio:sidebarRight:toggle", s.sidebarTopSet = "studio:sidebarTop:set", s.sidebarTopGet = "studio:sidebarTop:get", s.sidebarTopToggle = "studio:sidebarTop:toggle", s.sidebarBottomSet = "studio:sidebarBottom:set", s.sidebarBottomGet = "studio:sidebarBottom:get", s.sidebarBottomToggle = "studio:sidebarBottom:toggle", s.symbolAdd = "studio:symbolAdd", s.symbolDetach = "studio:symbolDetach", s.symbolOverride = "studio:symbolOverride", s.symbolPropagateStyles = "studio:propagateStyles", s.getPagesConfig = "studio:getPagesConfig", s.setPagesConfig = "studio:setPagesConfig", s.getPageSettings = "studio:getPageSettings", s.setPageSettings = "studio:setPageSettings", s.clearPage = "studio:clearPage", s.projectFiles = "studio:projectFiles", s.validateCode = "studio:validateCode", s.canvasReload = "studio:canvasReload", s.getBlocksPanel = "studio:getBlocksPanel", s.setBlocksPanel = "studio:setBlocksPanel", s.getStateContextMenu = "studio:getStateContextMenu", s.setStateContextMenu = "studio:setStateContextMenu", s.contextMenuComponent = "studio:contextMenuComponent", s.layoutAdd = "studio:layoutAdd", s.layoutRemove = "studio:layoutRemove", s.layoutToggle = "studio:layoutToggle", s.layoutUpdate = "studio:layoutUpdate", s.layoutGet = "studio:layoutGet", s.layoutConfigGet = "studio:layoutConfigGet", s.layoutConfigSet = "studio:layoutConfigSet", s.layoutComponentAdd = "studio:layoutComponentAdd", s.layoutComponentGet = "studio:layoutComponentGet", s.layoutComponentRemove = "studio:layoutComponentRemove", s.layoutComponentRender = "studio:layoutComponentRender", s.getStateTheme = "studio:getStateTheme", s.setStateTheme = "studio:setStateTheme", s.settings = "studio:settings", s.assetProviderGet = "studio:assetProviderGet", s.assetProviderAdd = "studio:assetProviderAdd", s.assetProviderRemove = "studio:assetProviderRemove", s.fontGet = "studio:fontGet", s.fontAdd = "studio:fontAdd", s.fontRemove = "studio:fontRemove", s.fontManagerOpen = "studio:fontManagerOpen", s.menuFontLoad = "studio:menuFontLoad", s.toggleStateDataSource = "studio:toggleStateDataSource", s.getStateDataSource = "studio:getStateDataSource", s.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", s.dataSourceSetImporter = "studio:dataSourceSetImporter", s.dataSourceSetExporter = "studio:dataSourceSetExporter", s.setDragAbsolute = "studio:setDragAbsolute", s))(b || {});
44
57
  const S = {
45
58
  [y.free]: 0,
46
59
  [y.startup]: 10,
47
60
  [y.business]: 20,
48
61
  [y.enterprise]: 30
49
62
  };
50
- function B(s) {
63
+ function N(s) {
51
64
  const t = s;
52
65
  return t.init = (e) => (r) => s(r, e), t;
53
66
  }
54
- const N = (s) => /* @__PURE__ */ B(s);
55
- async function M({
67
+ const M = (s) => /* @__PURE__ */ N(s);
68
+ async function G({
56
69
  editor: s,
57
70
  plan: t,
58
71
  pluginName: e,
@@ -79,9 +92,9 @@ async function M({
79
92
  };
80
93
  if (!i) {
81
94
  s.onReady(async () => {
82
- if (!k())
95
+ if (!A())
83
96
  if (r) {
84
- const p = await j({ licenseKey: r, pluginName: e, baseApiUrl: o });
97
+ const p = await D({ licenseKey: r, pluginName: e, baseApiUrl: o });
85
98
  u(p);
86
99
  } else
87
100
  l("The `licenseKey` option not provided");
@@ -89,22 +102,22 @@ async function M({
89
102
  return;
90
103
  }
91
104
  if (i.licensePlan || i.licenseError) {
92
- const p = G(i);
105
+ const p = j(i);
93
106
  u(p);
94
107
  return;
95
108
  }
96
- s.on(w, (p) => u(p));
109
+ s.on(O, (p) => u(p));
97
110
  }
98
- const G = (s) => ({
111
+ const j = (s) => ({
99
112
  sdkLicense: s.license,
100
113
  license: s.license,
101
114
  error: s.licenseError,
102
115
  plan: s.licensePlan
103
116
  });
104
- async function j(s) {
117
+ async function D(s) {
105
118
  const { licenseKey: t, pluginName: e, baseApiUrl: r } = s;
106
119
  try {
107
- return (await A({
120
+ return (await B({
108
121
  baseApiUrl: r,
109
122
  path: `/sdk/${t || "na"}`,
110
123
  method: "POST",
@@ -117,15 +130,15 @@ async function j(s) {
117
130
  return console.error("Error during SDK license check:", n), !1;
118
131
  }
119
132
  }
120
- const D = (s) => {
133
+ const F = (s) => {
121
134
  const t = s;
122
135
  return t.logicalOperator === "and" || t.logicalOperator === "or";
123
- }, F = (s, t) => (s.config.optsHtml = {
136
+ }, J = (s, t) => (s.config.optsHtml = {
124
137
  ...s.config.optsHtml,
125
138
  exporter: t
126
139
  }, () => {
127
140
  s.config.optsHtml.exporter = void 0;
128
- }), J = (s, t) => {
141
+ }), W = (s, t) => {
129
142
  const e = (n) => {
130
143
  const { input: a } = n, { contains: o } = t;
131
144
  (!o || a.includes(o)) && (n.input = t.importer.import(a));
@@ -134,7 +147,7 @@ const D = (s) => {
134
147
  s.off(r, e);
135
148
  };
136
149
  };
137
- class W {
150
+ class _ {
138
151
  getVariableSyntax({ dataResolver: t }) {
139
152
  const { defaultValue: e } = t, r = this.getFullPath(t), n = e ? ` || \`${e}\`` : "";
140
153
  return `<%= ${r}${n} %>`;
@@ -171,8 +184,8 @@ const ${i}={ currentItem, currentIndex: startIndex + index, remainingItems: endI
171
184
  }
172
185
  _parseCondition(t) {
173
186
  if (!t) return "";
174
- if (D(t)) {
175
- const e = t.statements.map((a) => this._parseCondition(a)), r = _[t.logicalOperator];
187
+ if (F(t)) {
188
+ const e = t.statements.map((a) => this._parseCondition(a)), r = R[t.logicalOperator];
176
189
  let n = e.length > 1 ? `(${e.join(`)${r}(`)})` : e[0];
177
190
  return t.logicalOperator === "xor" && (n = `!!(${n})`), n;
178
191
  } else {
@@ -226,11 +239,11 @@ const ${i}={ currentItem, currentIndex: startIndex + index, remainingItems: endI
226
239
  return typeof t == "object" ? this.getFullPath(t) : typeof t == "string" ? `'${t.replace(/'/g, "\\'")}'` : String(t);
227
240
  }
228
241
  }
229
- const _ = {
242
+ const R = {
230
243
  and: "&&",
231
244
  or: "||",
232
245
  xor: "^"
233
- }, R = ["===", "==", "!==", "!=", "<=", ">=", "<", ">", "&&", "||"], U = {
246
+ }, U = ["===", "==", "!==", "!=", "<=", ">=", "<", ">", "&&", "||"], V = {
234
247
  "===": "=",
235
248
  "==": "=",
236
249
  "!==": "!=",
@@ -242,7 +255,7 @@ const _ = {
242
255
  "&&": "&&",
243
256
  "||": "||"
244
257
  };
245
- class V {
258
+ class q {
246
259
  constructor() {
247
260
  this.messages = [], this.collectionStack = [];
248
261
  }
@@ -472,12 +485,12 @@ class V {
472
485
  type: "Literal",
473
486
  value: t === "true"
474
487
  };
475
- for (const n of R) {
488
+ for (const n of U) {
476
489
  const a = t.lastIndexOf(n);
477
490
  if (a > 0 && t[a - 1] !== "!" && t[a - 1] !== "=" && t[a - 1] !== "<" && t[a - 1] !== ">")
478
491
  return {
479
492
  type: n === "&&" || n === "||" ? "LogicalExpression" : "BinaryExpression",
480
- operator: U[n],
493
+ operator: V[n],
481
494
  left: this.parseJsExpression(t.slice(0, a).trim()),
482
495
  right: this.parseJsExpression(t.slice(a + n.length).trim())
483
496
  };
@@ -717,21 +730,21 @@ class V {
717
730
  });
718
731
  }
719
732
  }
720
- const q = "dataSourceEjs", H = y.startup, K = function(s, t = {}) {
721
- const e = F(s, new W()), r = J(s, {
733
+ const H = "dataSourceEjs", C = y.startup, K = function(s, t = {}) {
734
+ const e = J(s, new _()), r = W(s, {
722
735
  contains: "<%",
723
- importer: new V()
736
+ importer: new q()
724
737
  });
725
- M({
738
+ G({
726
739
  editor: s,
727
740
  licenseKey: t.licenseKey,
728
- plan: H,
729
- pluginName: q,
741
+ plan: C,
742
+ pluginName: H,
730
743
  cleanup: () => {
731
744
  e(), r();
732
745
  }
733
746
  });
734
- }, z = N(K);
747
+ }, z = M(K);
735
748
  export {
736
749
  z as default
737
750
  };
@@ -1,7 +1,7 @@
1
- (function(f,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(f=typeof globalThis<"u"?globalThis:f||self,f.StudioSdkPlugins_dataSourceEjs=y())})(this,function(){"use strict";const f="app.grapesjs.com",y="app-stage.grapesjs.com",I=[f,"app2.grapesjs.com",y,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],P="license:check:end",v=()=>typeof window<"u",O=({isDev:s,isStage:t,isPlatform:e})=>`${s?"":`https://${t?y:f}`}/${e?"platform-api":"api"}`,T=()=>{const s=v()&&window.location.hostname;return!!s&&(I.includes(s)||I.some(t=>s.endsWith(t)))};async function w({path:s,baseApiUrl:t,method:e="GET",headers:r={},params:n,body:a}){const i=`${t||O({isDev:!1,isStage:!1})}${s}`,l={method:e,headers:{"Content-Type":"application/json",...r}};a&&(l.body=JSON.stringify(a));const c=n?new URLSearchParams(n).toString():"",u=c?`?${c}`:"",p=await fetch(`${i}${u}`,l);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var E=(s=>(s.free="free",s.startup="startup",s.business="business",s.enterprise="enterprise",s))(E||{}),S=(s=>(s.toastAdd="studio:toastAdd",s.toastRemove="studio:toastRemove",s.dialogOpen="studio:dialogOpen",s.dialogClose="studio:dialogClose",s.dialogExportCode="studio:dialogExportCode",s.dialogImportCode="studio:dialogImportCode",s.sidebarLeftSet="studio:sidebarLeft:set",s.sidebarLeftGet="studio:sidebarLeft:get",s.sidebarLeftToggle="studio:sidebarLeft:toggle",s.sidebarRightSet="studio:sidebarRight:set",s.sidebarRightGet="studio:sidebarRight:get",s.sidebarRightToggle="studio:sidebarRight:toggle",s.sidebarTopSet="studio:sidebarTop:set",s.sidebarTopGet="studio:sidebarTop:get",s.sidebarTopToggle="studio:sidebarTop:toggle",s.sidebarBottomSet="studio:sidebarBottom:set",s.sidebarBottomGet="studio:sidebarBottom:get",s.sidebarBottomToggle="studio:sidebarBottom:toggle",s.symbolAdd="studio:symbolAdd",s.symbolDetach="studio:symbolDetach",s.symbolOverride="studio:symbolOverride",s.symbolPropagateStyles="studio:propagateStyles",s.getPagesConfig="studio:getPagesConfig",s.setPagesConfig="studio:setPagesConfig",s.getPageSettings="studio:getPageSettings",s.setPageSettings="studio:setPageSettings",s.clearPage="studio:clearPage",s.projectFiles="studio:projectFiles",s.validateCode="studio:validateCode",s.canvasReload="studio:canvasReload",s.getBlocksPanel="studio:getBlocksPanel",s.setBlocksPanel="studio:setBlocksPanel",s.getStateContextMenu="studio:getStateContextMenu",s.setStateContextMenu="studio:setStateContextMenu",s.contextMenuComponent="studio:contextMenuComponent",s.layoutAdd="studio:layoutAdd",s.layoutRemove="studio:layoutRemove",s.layoutToggle="studio:layoutToggle",s.layoutUpdate="studio:layoutUpdate",s.layoutGet="studio:layoutGet",s.layoutConfigGet="studio:layoutConfigGet",s.layoutConfigSet="studio:layoutConfigSet",s.layoutComponentAdd="studio:layoutComponentAdd",s.layoutComponentGet="studio:layoutComponentGet",s.layoutComponentRemove="studio:layoutComponentRemove",s.layoutComponentRender="studio:layoutComponentRender",s.getStateTheme="studio:getStateTheme",s.setStateTheme="studio:setStateTheme",s.settings="studio:settings",s.assetProviderGet="studio:assetProviderGet",s.assetProviderAdd="studio:assetProviderAdd",s.assetProviderRemove="studio:assetProviderRemove",s.fontGet="studio:fontGet",s.fontAdd="studio:fontAdd",s.fontRemove="studio:fontRemove",s.fontManagerOpen="studio:fontManagerOpen",s.menuFontLoad="studio:menuFontLoad",s.toggleStateDataSource="studio:toggleStateDataSource",s.getStateDataSource="studio:getStateDataSource",s.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",s.dataSourceSetImporter="studio:dataSourceSetImporter",s.dataSourceSetExporter="studio:dataSourceSetExporter",s.setDragAbsolute="studio:setDragAbsolute",s))(S||{});const m={[E.free]:0,[E.startup]:10,[E.business]:20,[E.enterprise]:30};function L(s){const t=s;return t.init=e=>r=>s(r,e),t}const k=s=>L(s);async function A({editor:s,plan:t,pluginName:e,licenseKey:r,onLicenseCheckResponse:n,cleanup:a}){let o="",i;const l=p=>{console.warn("Cleanup plugin:",e,"Reason:",p),a()},c=(p={})=>{var x;const{error:h,sdkLicense:b}=p,d=(x=p.plan)==null?void 0:x.category;if(!(b||p.license)||h)l(h||"Invalid license");else if(d){const $=m[t],V=m[d];$>V&&l({pluginRequiredPlan:t,licensePlan:d})}};s.Commands.has(S.settings)&&(i=s.runCommand(S.settings),o=(i==null?void 0:i.baseUrl)||"");const u=p=>{n==null||n(p),p&&c(p)};if(!i){s.onReady(async()=>{if(!T())if(r){const p=await B({licenseKey:r,pluginName:e,baseApiUrl:o});u(p)}else l("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const p=N(i);u(p);return}s.on(P,p=>u(p))}const N=s=>({sdkLicense:s.license,license:s.license,error:s.licenseError,plan:s.licensePlan});async function B(s){const{licenseKey:t,pluginName:e,baseApiUrl:r}=s;try{return(await w({baseApiUrl:r,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:e}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const M=s=>{const t=s;return t.logicalOperator==="and"||t.logicalOperator==="or"},j=(s,t)=>(s.config.optsHtml={...s.config.optsHtml,exporter:t},()=>{s.config.optsHtml.exporter=void 0}),D=(s,t)=>{const e=n=>{const{input:a}=n,{contains:o}=t;(!o||a.includes(o))&&(n.input=t.importer.import(a))},r=s.Parser.events.htmlBefore;return s.on(r,e),()=>{s.off(r,e)}};class G{getVariableSyntax({dataResolver:t}){const{defaultValue:e}=t,r=this.getFullPath(t),n=e?` || \`${e}\``:"";return`<%= ${r}${n} %>`}getCollectionStartSyntax({dataResolver:t}){const{collectionId:e,dataSource:r,startIndex:n,endIndex:a}=t,o=(r==null?void 0:r.path)||e||"",i=this._sanitizeVariableName(e);let l="";if(n!==void 0||a!==void 0){const c=n??0,u=a!==void 0?a:"";l=`.slice(${c}${u!==""?`, ${u}`:""})`}return`<% ${o}${l}.forEach(function(currentItem, index, arr) {
1
+ (function(f,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(f=typeof globalThis<"u"?globalThis:f||self,f.StudioSdkPlugins_dataSourceEjs=y())})(this,function(){"use strict";const f="app.grapesjs.com",y="app-stage.grapesjs.com",m=[f,"app2.grapesjs.com",y,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],P="license:check:end",v=()=>typeof window<"u",O=({isDev:s,isStage:t,isPlatform:e})=>`${s?"":`https://${t?y:f}`}/${e?"platform-api":"api"}`,w=()=>{if(!v())return"";const{hostname:s}=window.location;if(s)return s;try{return window.parent.location.hostname||""}catch{return""}},T=()=>{const s=w();return!!s&&(m.includes(s)||m.some(t=>s.endsWith(t)))};async function L({path:s,baseApiUrl:t,method:e="GET",headers:r={},params:n,body:a}){const i=`${t||O({isDev:!1,isStage:!1})}${s}`,l={method:e,headers:{"Content-Type":"application/json",...r}};a&&(l.body=JSON.stringify(a));const c=n?new URLSearchParams(n).toString():"",u=c?`?${c}`:"",p=await fetch(`${i}${u}`,l);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var E=(s=>(s.free="free",s.startup="startup",s.business="business",s.enterprise="enterprise",s))(E||{}),S=(s=>(s.toastAdd="studio:toastAdd",s.toastRemove="studio:toastRemove",s.dialogOpen="studio:dialogOpen",s.dialogClose="studio:dialogClose",s.dialogExportCode="studio:dialogExportCode",s.dialogImportCode="studio:dialogImportCode",s.openEditCode="studio:openEditCode",s.sidebarLeftSet="studio:sidebarLeft:set",s.sidebarLeftGet="studio:sidebarLeft:get",s.sidebarLeftToggle="studio:sidebarLeft:toggle",s.sidebarRightSet="studio:sidebarRight:set",s.sidebarRightGet="studio:sidebarRight:get",s.sidebarRightToggle="studio:sidebarRight:toggle",s.sidebarTopSet="studio:sidebarTop:set",s.sidebarTopGet="studio:sidebarTop:get",s.sidebarTopToggle="studio:sidebarTop:toggle",s.sidebarBottomSet="studio:sidebarBottom:set",s.sidebarBottomGet="studio:sidebarBottom:get",s.sidebarBottomToggle="studio:sidebarBottom:toggle",s.symbolAdd="studio:symbolAdd",s.symbolDetach="studio:symbolDetach",s.symbolOverride="studio:symbolOverride",s.symbolPropagateStyles="studio:propagateStyles",s.getPagesConfig="studio:getPagesConfig",s.setPagesConfig="studio:setPagesConfig",s.getPageSettings="studio:getPageSettings",s.setPageSettings="studio:setPageSettings",s.clearPage="studio:clearPage",s.projectFiles="studio:projectFiles",s.validateCode="studio:validateCode",s.canvasReload="studio:canvasReload",s.getBlocksPanel="studio:getBlocksPanel",s.setBlocksPanel="studio:setBlocksPanel",s.getStateContextMenu="studio:getStateContextMenu",s.setStateContextMenu="studio:setStateContextMenu",s.contextMenuComponent="studio:contextMenuComponent",s.layoutAdd="studio:layoutAdd",s.layoutRemove="studio:layoutRemove",s.layoutToggle="studio:layoutToggle",s.layoutUpdate="studio:layoutUpdate",s.layoutGet="studio:layoutGet",s.layoutConfigGet="studio:layoutConfigGet",s.layoutConfigSet="studio:layoutConfigSet",s.layoutComponentAdd="studio:layoutComponentAdd",s.layoutComponentGet="studio:layoutComponentGet",s.layoutComponentRemove="studio:layoutComponentRemove",s.layoutComponentRender="studio:layoutComponentRender",s.getStateTheme="studio:getStateTheme",s.setStateTheme="studio:setStateTheme",s.settings="studio:settings",s.assetProviderGet="studio:assetProviderGet",s.assetProviderAdd="studio:assetProviderAdd",s.assetProviderRemove="studio:assetProviderRemove",s.fontGet="studio:fontGet",s.fontAdd="studio:fontAdd",s.fontRemove="studio:fontRemove",s.fontManagerOpen="studio:fontManagerOpen",s.menuFontLoad="studio:menuFontLoad",s.toggleStateDataSource="studio:toggleStateDataSource",s.getStateDataSource="studio:getStateDataSource",s.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",s.dataSourceSetImporter="studio:dataSourceSetImporter",s.dataSourceSetExporter="studio:dataSourceSetExporter",s.setDragAbsolute="studio:setDragAbsolute",s))(S||{});const I={[E.free]:0,[E.startup]:10,[E.business]:20,[E.enterprise]:30};function k(s){const t=s;return t.init=e=>r=>s(r,e),t}const A=s=>k(s);async function N({editor:s,plan:t,pluginName:e,licenseKey:r,onLicenseCheckResponse:n,cleanup:a}){let o="",i;const l=p=>{console.warn("Cleanup plugin:",e,"Reason:",p),a()},c=(p={})=>{var x;const{error:h,sdkLicense:b}=p,d=(x=p.plan)==null?void 0:x.category;if(!(b||p.license)||h)l(h||"Invalid license");else if(d){const $=I[t],q=I[d];$>q&&l({pluginRequiredPlan:t,licensePlan:d})}};s.Commands.has(S.settings)&&(i=s.runCommand(S.settings),o=(i==null?void 0:i.baseUrl)||"");const u=p=>{n==null||n(p),p&&c(p)};if(!i){s.onReady(async()=>{if(!T())if(r){const p=await M({licenseKey:r,pluginName:e,baseApiUrl:o});u(p)}else l("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const p=B(i);u(p);return}s.on(P,p=>u(p))}const B=s=>({sdkLicense:s.license,license:s.license,error:s.licenseError,plan:s.licensePlan});async function M(s){const{licenseKey:t,pluginName:e,baseApiUrl:r}=s;try{return(await L({baseApiUrl:r,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:e}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const j=s=>{const t=s;return t.logicalOperator==="and"||t.logicalOperator==="or"},D=(s,t)=>(s.config.optsHtml={...s.config.optsHtml,exporter:t},()=>{s.config.optsHtml.exporter=void 0}),G=(s,t)=>{const e=n=>{const{input:a}=n,{contains:o}=t;(!o||a.includes(o))&&(n.input=t.importer.import(a))},r=s.Parser.events.htmlBefore;return s.on(r,e),()=>{s.off(r,e)}};class F{getVariableSyntax({dataResolver:t}){const{defaultValue:e}=t,r=this.getFullPath(t),n=e?` || \`${e}\``:"";return`<%= ${r}${n} %>`}getCollectionStartSyntax({dataResolver:t}){const{collectionId:e,dataSource:r,startIndex:n,endIndex:a}=t,o=(r==null?void 0:r.path)||e||"",i=this._sanitizeVariableName(e);let l="";if(n!==void 0||a!==void 0){const c=n??0,u=a!==void 0?a:"";l=`.slice(${c}${u!==""?`, ${u}`:""})`}return`<% ${o}${l}.forEach(function(currentItem, index, arr) {
2
2
  const startIndex = parseInt(${n??0}, 10);
3
3
  const endIndex = startIndex + arr.length;
4
- const ${i}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`}_sanitizeVariableName(t){return t.replace(/[^a-zA-Z0-9_$]/g,"_")}getCollectionEndSyntax(){return"<% }) %>"}getConditionalStartSyntax({dataResolver:t}){return`<% if (${this._parseCondition(t.condition)}) { %>`}getConditionElseSyntax(){return"<% } else { %>"}getConditionalEndSyntax(){return"<% } %>"}getFullPath({collectionId:t,path:e,variableType:r}){return(t?[this._sanitizeVariableName(t),r,e].filter(Boolean).join("."):e)||""}_parseCondition(t){if(!t)return"";if(M(t)){const e=t.statements.map(a=>this._parseCondition(a)),r=F[t.logicalOperator];let n=e.length>1?`(${e.join(`)${r}(`)})`:e[0];return t.logicalOperator==="xor"&&(n=`!!(${n})`),n}else{const e=this._parseValue(t.left),r=this._parseValue(t.right);switch(t.operator){case"equals":return`${e} === ${r}`;case">":case"<":case">=":case"<=":case"=":case"!=":return`${e} ${t.operator} ${r}`;case"contains":return`${e}?.includes(${r})`;case"startsWith":return`${e}?.startsWith(${r})`;case"endsWith":return`${e}?.endsWith(${r})`;case"equalsIgnoreCase":return`${e}?.toLowerCase() === ${r}?.toLowerCase()`;case"trimEquals":return`${e}?.trim() === ${r}?.trim()`;case"isTruthy":return`!!${e}`;case"isFalsy":return`!${e}`;case"isDefined":return`${e} !== undefined`;case"isNull":return`${e} === null`;case"isUndefined":return`${e} === undefined`;case"isArray":return`Array.isArray(${e})`;case"isObject":return`typeof ${e} === 'object' && ${e} !== null && !Array.isArray(${e})`;case"isString":return`typeof ${e} === 'string'`;case"isNumber":return`typeof ${e} === 'number' && !isNaN(${e})`;case"isBoolean":return`typeof ${e} === 'boolean'`;default:return`${e} ${t.operator} ${r}`}}}_parseValue(t){return typeof t=="object"?this.getFullPath(t):typeof t=="string"?`'${t.replace(/'/g,"\\'")}'`:String(t)}}const F={and:"&&",or:"||",xor:"^"},_=["===","==","!==","!=","<=",">=","<",">","&&","||"],J={"===":"=","==":"=","!==":"!=","!=":"!=","<=":"<=",">=":">=","<":"<",">":">","&&":"&&","||":"||"};class W{constructor(){this.messages=[],this.collectionStack=[]}import(t){this.messages=[],this.collectionStack=[];try{const e=this.parseEjsTemplate(t);return this.astToGrapesJS(e)}catch(e){return console.error("Error during import:",e),this.addMessage("error",`Error during import: ${e instanceof Error?e.message:String(e)}`),""}}parseEjsTemplate(t){const e=[];let r=0;for(;r<t.length;){const n=t.indexOf("<%",r);if(n===-1){r<t.length&&e.push(this.createAppendLiteral(t.slice(r)));break}n>r&&e.push(this.createAppendLiteral(t.slice(r,n)));const a=t.indexOf("%>",n);if(a===-1)throw new Error("Unclosed EJS tag");const o=t.slice(n+2,a).trim();if(r=a+2,o.startsWith("=")||o.startsWith("-")){const i=o.slice(1).trim();e.push(this.createAppendExpression(i))}else{if(o.startsWith("#"))continue;if(o.startsWith("if")){const i=this.parseIfStatement(o,t,r);e.push(i),r=i.endPos||r}else if(o.startsWith("for")){const i=this.parseForStatement(o,t,r);e.push(i),r=i.endPos||r}else{const i=o.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);if(i){const l=i[1],c=i[2],u=this.parseForEachStatement(l,c,t,r);e.push(u),r=u.endPos||r}else this.addMessage("info",`Unsupported scriptlet content: ${o}`)}}}return{type:"Program",body:e}}createAppendLiteral(t){return{type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:"__append"},arguments:[{type:"Literal",value:t}]}}}createAppendExpression(t){return{type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:"__append"},arguments:[this.parseJsExpression(t)]}}}parseIfStatement(t,e,r){const n=t.match(/if\s*\((.*)\)\s*\{?/);if(!n)throw new Error("Invalid if statement syntax");const a=this.parseJsExpression(n[1]),{body:o,endPos:i}=this.parseTemplateBlock(e,r);let l=null,c=i;const u=e.indexOf("<%",c);if(u===c){const p=e.indexOf("%>",u);if(p!==-1){const h=e.slice(u+2,p).trim(),b=p+2-u;if(h.startsWith("} else if")){c=u+b;const d=h.substring(h.indexOf("if")).trim(),g=this.parseIfStatement(d,e,c);l={type:"IfStatement",test:g.test,consequent:g.consequent,alternate:g.alternate},c=g.endPos}else if(h.startsWith("} else")){c=u+b;const{body:d,endPos:g}=this.parseTemplateBlock(e,c);l={type:"BlockStatement",body:d},c=g;const x=e.indexOf("<%",c),$=e.indexOf("%>",x);x===c&&e.slice(x+2,$).trim()==="}"&&(c=$+2)}else h==="}"&&(c=u+b)}}return{type:"IfStatement",test:a,consequent:{type:"BlockStatement",body:o},alternate:l,endPos:c}}parseForStatement(t,e,r){const n=t.match(/for\s*\((.*)\)\s*\{?/);if(!n)throw new Error("Invalid for statement syntax");const a=n[1].split("of");if(a.length!==2)throw new Error("Only for...of loops are supported");const o=a[0].trim().replace(/^let\s+|^const\s+|^var\s+/,""),i=a[1].trim(),{body:l,endPos:c}=this.parseTemplateBlock(e,r);return{type:"ForStatement",init:{type:"VariableDeclaration",kind:"let",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:o},init:this.parseJsExpression(i)}]},test:null,update:null,body:{type:"BlockStatement",body:l},endPos:(()=>{const u=e.indexOf("<%",c),p=e.indexOf("%>",u);return u===c&&e.slice(u+2,p).trim()==="}"?p+2:c})()}}parseForEachStatement(t,e,r,n){const{body:a,endPos:o}=this.parseTemplateBlock(r,n);return{type:"ForEachStatement",collection:this.parseJsExpression(t),itemIdentifier:{type:"Identifier",name:e},body:{type:"BlockStatement",body:a},endPos:(()=>{const i=r.indexOf("<%",o),l=r.indexOf("%>",i);return i===o&&r.slice(i+2,l).trim()==="}"?l+2:o})()}}parseTemplateBlock(t,e){const r=[];let n=e;for(;n<t.length;){const a=t.indexOf("<%",n);if(a===-1){n<t.length&&r.push(this.createAppendLiteral(t.slice(n))),n=t.length;break}a>n&&r.push(this.createAppendLiteral(t.slice(n,a)));const o=t.indexOf("%>",a);if(o===-1)throw new Error("Unclosed EJS tag within block");const i=t.slice(a+2,o).trim();if(i==="}"||i.startsWith("} else")){n=a;break}if(n=o+2,i.startsWith("=")||i.startsWith("-")){const l=i.slice(1).trim();r.push(this.createAppendExpression(l))}else{if(i.startsWith("#"))continue;if(i.startsWith("if")){const l=this.parseIfStatement(i,t,n);r.push(l),n=l.endPos||n}else if(i.startsWith("for")){const l=this.parseForStatement(i,t,n);r.push(l),n=l.endPos||n}else{const l=i.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);if(l){const c=l[1],u=l[2],p=this.parseForEachStatement(c,u,t,n);r.push(p),n=p.endPos||n}else this.addMessage("info",`Unsupported scriptlet content within block: ${i}`)}}}return{body:r,endPos:n}}parseJsExpression(t){if(/^(['"]).*\1$/.test(t))return{type:"Literal",value:t.slice(1,-1)};if(/^-?\d+$/.test(t))return{type:"Literal",value:parseInt(t,10)};if(/^-?\d+\.\d+$/.test(t))return{type:"Literal",value:parseFloat(t)};if(t==="true"||t==="false")return{type:"Literal",value:t==="true"};for(const n of _){const a=t.lastIndexOf(n);if(a>0&&t[a-1]!=="!"&&t[a-1]!=="="&&t[a-1]!=="<"&&t[a-1]!==">")return{type:n==="&&"||n==="||"?"LogicalExpression":"BinaryExpression",operator:J[n],left:this.parseJsExpression(t.slice(0,a).trim()),right:this.parseJsExpression(t.slice(a+n.length).trim())}}const e=t.indexOf("."),r=t.indexOf("[");if(e>0&&(r===-1||e<r)||r>0&&(e===-1||r<e)){const n=e>0&&(r===-1||e<r)?e:r;let a,o,i=!1;if(n===e)a=t.slice(0,e),o={type:"Identifier",name:t.slice(e+1)},i=!1;else{a=t.slice(0,r);const l=t.indexOf("]",r);if(l===-1)throw new Error("Unclosed bracket in expression");const c=t.slice(r+1,l);o=/^(['"]).*\1$/.test(c)||/^-?\d+(\.\d+)?$/.test(c)?this.parseJsExpression(c):{type:"Identifier",name:c},i=!0}return{type:"MemberExpression",object:this.parseJsExpression(a),property:o,computed:i}}return{type:"Identifier",name:t}}astToGrapesJS(t){switch(t.type){case"Program":return this.handleProgram(t);case"VariableDeclaration":return this.handleVariableDeclaration(t);case"ExpressionStatement":return this.handleExpressionStatement(t);case"IfStatement":return this.handleIfStatement(t);case"ForStatement":return this.handleForStatement(t);case"ForEachStatement":return this.handleForEachStatement(t);case"BlockStatement":return this.handleBlockStatement(t);case"Literal":return this.handleLiteral(t);case"Identifier":return this.handleIdentifier(t);case"MemberExpression":return this.handleMemberExpression(t);case"BinaryExpression":return this.handleBinaryExpression(t);case"LogicalExpression":return this.handleLogicalExpression(t);case"CallExpression":return this.handleCallExpression(t);default:return this.addMessage("warning",`Unsupported node type: ${t.type}`),""}}handleProgram(t){let e="";for(const r of t.body)e+=this.astToGrapesJS(r);return e}handleVariableDeclaration(t){return""}handleExpressionStatement(t){return t.expression.type==="CallExpression"&&t.expression.callee.type==="Identifier"&&t.expression.callee.name==="__append"&&t.expression.arguments.length>0?this.astToGrapesJS(t.expression.arguments[0]):""}handleIfStatement(t){const e=this.getConditionExpression(t.test),r=this.astToGrapesJS(t.consequent);let n="";return t.alternate&&(n=this.astToGrapesJS(t.alternate)),`
4
+ const ${i}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`}_sanitizeVariableName(t){return t.replace(/[^a-zA-Z0-9_$]/g,"_")}getCollectionEndSyntax(){return"<% }) %>"}getConditionalStartSyntax({dataResolver:t}){return`<% if (${this._parseCondition(t.condition)}) { %>`}getConditionElseSyntax(){return"<% } else { %>"}getConditionalEndSyntax(){return"<% } %>"}getFullPath({collectionId:t,path:e,variableType:r}){return(t?[this._sanitizeVariableName(t),r,e].filter(Boolean).join("."):e)||""}_parseCondition(t){if(!t)return"";if(j(t)){const e=t.statements.map(a=>this._parseCondition(a)),r=_[t.logicalOperator];let n=e.length>1?`(${e.join(`)${r}(`)})`:e[0];return t.logicalOperator==="xor"&&(n=`!!(${n})`),n}else{const e=this._parseValue(t.left),r=this._parseValue(t.right);switch(t.operator){case"equals":return`${e} === ${r}`;case">":case"<":case">=":case"<=":case"=":case"!=":return`${e} ${t.operator} ${r}`;case"contains":return`${e}?.includes(${r})`;case"startsWith":return`${e}?.startsWith(${r})`;case"endsWith":return`${e}?.endsWith(${r})`;case"equalsIgnoreCase":return`${e}?.toLowerCase() === ${r}?.toLowerCase()`;case"trimEquals":return`${e}?.trim() === ${r}?.trim()`;case"isTruthy":return`!!${e}`;case"isFalsy":return`!${e}`;case"isDefined":return`${e} !== undefined`;case"isNull":return`${e} === null`;case"isUndefined":return`${e} === undefined`;case"isArray":return`Array.isArray(${e})`;case"isObject":return`typeof ${e} === 'object' && ${e} !== null && !Array.isArray(${e})`;case"isString":return`typeof ${e} === 'string'`;case"isNumber":return`typeof ${e} === 'number' && !isNaN(${e})`;case"isBoolean":return`typeof ${e} === 'boolean'`;default:return`${e} ${t.operator} ${r}`}}}_parseValue(t){return typeof t=="object"?this.getFullPath(t):typeof t=="string"?`'${t.replace(/'/g,"\\'")}'`:String(t)}}const _={and:"&&",or:"||",xor:"^"},J=["===","==","!==","!=","<=",">=","<",">","&&","||"],W={"===":"=","==":"=","!==":"!=","!=":"!=","<=":"<=",">=":">=","<":"<",">":">","&&":"&&","||":"||"};class R{constructor(){this.messages=[],this.collectionStack=[]}import(t){this.messages=[],this.collectionStack=[];try{const e=this.parseEjsTemplate(t);return this.astToGrapesJS(e)}catch(e){return console.error("Error during import:",e),this.addMessage("error",`Error during import: ${e instanceof Error?e.message:String(e)}`),""}}parseEjsTemplate(t){const e=[];let r=0;for(;r<t.length;){const n=t.indexOf("<%",r);if(n===-1){r<t.length&&e.push(this.createAppendLiteral(t.slice(r)));break}n>r&&e.push(this.createAppendLiteral(t.slice(r,n)));const a=t.indexOf("%>",n);if(a===-1)throw new Error("Unclosed EJS tag");const o=t.slice(n+2,a).trim();if(r=a+2,o.startsWith("=")||o.startsWith("-")){const i=o.slice(1).trim();e.push(this.createAppendExpression(i))}else{if(o.startsWith("#"))continue;if(o.startsWith("if")){const i=this.parseIfStatement(o,t,r);e.push(i),r=i.endPos||r}else if(o.startsWith("for")){const i=this.parseForStatement(o,t,r);e.push(i),r=i.endPos||r}else{const i=o.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);if(i){const l=i[1],c=i[2],u=this.parseForEachStatement(l,c,t,r);e.push(u),r=u.endPos||r}else this.addMessage("info",`Unsupported scriptlet content: ${o}`)}}}return{type:"Program",body:e}}createAppendLiteral(t){return{type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:"__append"},arguments:[{type:"Literal",value:t}]}}}createAppendExpression(t){return{type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:"__append"},arguments:[this.parseJsExpression(t)]}}}parseIfStatement(t,e,r){const n=t.match(/if\s*\((.*)\)\s*\{?/);if(!n)throw new Error("Invalid if statement syntax");const a=this.parseJsExpression(n[1]),{body:o,endPos:i}=this.parseTemplateBlock(e,r);let l=null,c=i;const u=e.indexOf("<%",c);if(u===c){const p=e.indexOf("%>",u);if(p!==-1){const h=e.slice(u+2,p).trim(),b=p+2-u;if(h.startsWith("} else if")){c=u+b;const d=h.substring(h.indexOf("if")).trim(),g=this.parseIfStatement(d,e,c);l={type:"IfStatement",test:g.test,consequent:g.consequent,alternate:g.alternate},c=g.endPos}else if(h.startsWith("} else")){c=u+b;const{body:d,endPos:g}=this.parseTemplateBlock(e,c);l={type:"BlockStatement",body:d},c=g;const x=e.indexOf("<%",c),$=e.indexOf("%>",x);x===c&&e.slice(x+2,$).trim()==="}"&&(c=$+2)}else h==="}"&&(c=u+b)}}return{type:"IfStatement",test:a,consequent:{type:"BlockStatement",body:o},alternate:l,endPos:c}}parseForStatement(t,e,r){const n=t.match(/for\s*\((.*)\)\s*\{?/);if(!n)throw new Error("Invalid for statement syntax");const a=n[1].split("of");if(a.length!==2)throw new Error("Only for...of loops are supported");const o=a[0].trim().replace(/^let\s+|^const\s+|^var\s+/,""),i=a[1].trim(),{body:l,endPos:c}=this.parseTemplateBlock(e,r);return{type:"ForStatement",init:{type:"VariableDeclaration",kind:"let",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:o},init:this.parseJsExpression(i)}]},test:null,update:null,body:{type:"BlockStatement",body:l},endPos:(()=>{const u=e.indexOf("<%",c),p=e.indexOf("%>",u);return u===c&&e.slice(u+2,p).trim()==="}"?p+2:c})()}}parseForEachStatement(t,e,r,n){const{body:a,endPos:o}=this.parseTemplateBlock(r,n);return{type:"ForEachStatement",collection:this.parseJsExpression(t),itemIdentifier:{type:"Identifier",name:e},body:{type:"BlockStatement",body:a},endPos:(()=>{const i=r.indexOf("<%",o),l=r.indexOf("%>",i);return i===o&&r.slice(i+2,l).trim()==="}"?l+2:o})()}}parseTemplateBlock(t,e){const r=[];let n=e;for(;n<t.length;){const a=t.indexOf("<%",n);if(a===-1){n<t.length&&r.push(this.createAppendLiteral(t.slice(n))),n=t.length;break}a>n&&r.push(this.createAppendLiteral(t.slice(n,a)));const o=t.indexOf("%>",a);if(o===-1)throw new Error("Unclosed EJS tag within block");const i=t.slice(a+2,o).trim();if(i==="}"||i.startsWith("} else")){n=a;break}if(n=o+2,i.startsWith("=")||i.startsWith("-")){const l=i.slice(1).trim();r.push(this.createAppendExpression(l))}else{if(i.startsWith("#"))continue;if(i.startsWith("if")){const l=this.parseIfStatement(i,t,n);r.push(l),n=l.endPos||n}else if(i.startsWith("for")){const l=this.parseForStatement(i,t,n);r.push(l),n=l.endPos||n}else{const l=i.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);if(l){const c=l[1],u=l[2],p=this.parseForEachStatement(c,u,t,n);r.push(p),n=p.endPos||n}else this.addMessage("info",`Unsupported scriptlet content within block: ${i}`)}}}return{body:r,endPos:n}}parseJsExpression(t){if(/^(['"]).*\1$/.test(t))return{type:"Literal",value:t.slice(1,-1)};if(/^-?\d+$/.test(t))return{type:"Literal",value:parseInt(t,10)};if(/^-?\d+\.\d+$/.test(t))return{type:"Literal",value:parseFloat(t)};if(t==="true"||t==="false")return{type:"Literal",value:t==="true"};for(const n of J){const a=t.lastIndexOf(n);if(a>0&&t[a-1]!=="!"&&t[a-1]!=="="&&t[a-1]!=="<"&&t[a-1]!==">")return{type:n==="&&"||n==="||"?"LogicalExpression":"BinaryExpression",operator:W[n],left:this.parseJsExpression(t.slice(0,a).trim()),right:this.parseJsExpression(t.slice(a+n.length).trim())}}const e=t.indexOf("."),r=t.indexOf("[");if(e>0&&(r===-1||e<r)||r>0&&(e===-1||r<e)){const n=e>0&&(r===-1||e<r)?e:r;let a,o,i=!1;if(n===e)a=t.slice(0,e),o={type:"Identifier",name:t.slice(e+1)},i=!1;else{a=t.slice(0,r);const l=t.indexOf("]",r);if(l===-1)throw new Error("Unclosed bracket in expression");const c=t.slice(r+1,l);o=/^(['"]).*\1$/.test(c)||/^-?\d+(\.\d+)?$/.test(c)?this.parseJsExpression(c):{type:"Identifier",name:c},i=!0}return{type:"MemberExpression",object:this.parseJsExpression(a),property:o,computed:i}}return{type:"Identifier",name:t}}astToGrapesJS(t){switch(t.type){case"Program":return this.handleProgram(t);case"VariableDeclaration":return this.handleVariableDeclaration(t);case"ExpressionStatement":return this.handleExpressionStatement(t);case"IfStatement":return this.handleIfStatement(t);case"ForStatement":return this.handleForStatement(t);case"ForEachStatement":return this.handleForEachStatement(t);case"BlockStatement":return this.handleBlockStatement(t);case"Literal":return this.handleLiteral(t);case"Identifier":return this.handleIdentifier(t);case"MemberExpression":return this.handleMemberExpression(t);case"BinaryExpression":return this.handleBinaryExpression(t);case"LogicalExpression":return this.handleLogicalExpression(t);case"CallExpression":return this.handleCallExpression(t);default:return this.addMessage("warning",`Unsupported node type: ${t.type}`),""}}handleProgram(t){let e="";for(const r of t.body)e+=this.astToGrapesJS(r);return e}handleVariableDeclaration(t){return""}handleExpressionStatement(t){return t.expression.type==="CallExpression"&&t.expression.callee.type==="Identifier"&&t.expression.callee.name==="__append"&&t.expression.arguments.length>0?this.astToGrapesJS(t.expression.arguments[0]):""}handleIfStatement(t){const e=this.getConditionExpression(t.test),r=this.astToGrapesJS(t.consequent);let n="";return t.alternate&&(n=this.astToGrapesJS(t.alternate)),`
5
5
  <data-condition data-gjs-data-resolver='${JSON.stringify({condition:e})}'>
6
6
  <data-condition-true-content>${r}</data-condition-true-content>
7
7
  <data-condition-false-content>${n}</data-condition-false-content>
@@ -18,4 +18,4 @@ const ${i}={ currentItem, currentIndex: startIndex + index, remainingItems: endI
18
18
  ${a}
19
19
  </data-collection-item>
20
20
  </data-collection>
21
- `}handleBlockStatement(t){let e="";for(const r of t.body)e+=this.astToGrapesJS(r);return e}handleLiteral(t){return String(t.value??"")}handleIdentifier(t){let e={path:t.name};if(this.collectionStack.length>0){const r=this.collectionStack[this.collectionStack.length-1];t.name===r&&(e={collectionId:r,variableType:"currentItem"})}return`<data-variable data-gjs-data-resolver='${JSON.stringify(e)}'></data-variable>`}handleMemberExpression(t,e={}){let n={path:this.getExpressionString(t),...e};if(this.collectionStack.length>0){const a=this.collectionStack[this.collectionStack.length-1];let o=t;const i=[];for(;o.type==="MemberExpression";)o.property.type==="Identifier"&&!o.computed?i.unshift(o.property.name):o.property.type==="Literal"&&o.computed?i.unshift(String(o.property.value)):i.unshift(this.getExpressionString(o.property)),o=o.object;if(o.type==="Identifier"&&o.name===a){const l=i.join(".");n={...e,collectionId:a,variableType:"currentItem",path:l}}}return`<data-variable data-gjs-data-resolver='${JSON.stringify(n)}'></data-variable>`}handleBinaryExpression(t){return`${this.getExpressionString(t.left)} ${t.operator} ${this.getExpressionString(t.right)}`}handleLogicalExpression(t){return t.operator==="||"&&t.right.type==="Literal"?this.handleMemberExpression(t.left,{defaultValue:t.right.value}):`${this.getExpressionString(t.left)} ${t.operator} ${this.getExpressionString(t.right)}`}handleCallExpression(t){var e;if(t.callee.type==="Identifier"&&t.callee.name==="include"){const r=((e=t.arguments[0])==null?void 0:e.type)==="Literal"?String(t.arguments[0].value):"";return this.addMessage("info",`Partial includes are not fully supported: ${r}`),""}return""}getConditionExpression(t){if(t.type==="Identifier")return{logicalOperator:"and",statements:[{left:{type:"data-variable",path:t.name},operator:"isTruthy"}]};if(t.type==="MemberExpression"){let e=this.getExpressionString(t),r="isTruthy";return e.startsWith("!!")?(r="isTruthy",e=e.slice(2)):e.startsWith("!")&&(r="isFalsy",e=e.slice(1)),{logicalOperator:"and",statements:[{left:{type:"data-variable",path:e},operator:r}]}}if(t.type==="BinaryExpression"||t.type==="LogicalExpression"){const e=this.getConditionExpression(t.left),r=this.getConditionExpression(t.right);return`${e} ${t.operator} ${r}`}return t.type==="Literal"?typeof t.value=="string"?`'${t.value}'`:String(t.value??""):this.getExpressionString(t)}getExpressionString(t){switch(t.type){case"Identifier":return t.name;case"Literal":return String(t.value??"");case"MemberExpression":{const e=this.getExpressionString(t.object),r=this.getExpressionString(t.property);return t.computed?`${e}[${r}]`:`${e}.${r}`}case"BinaryExpression":{const e=this.getExpressionString(t.left),r=this.getExpressionString(t.right);return`${e} ${t.operator} ${r}`}case"LogicalExpression":{const e=this.getExpressionString(t.left),r=this.getExpressionString(t.right);return`${e} ${t.operator} ${r}`}default:return this.addMessage("warning",`Unsupported expression type for getExpressionString: ${t.type}`),""}}addMessage(t,e){this.messages.push({type:t,message:e})}}const R="dataSourceEjs",U=E.startup;return k(function(s,t={}){const e=j(s,new G),r=D(s,{contains:"<%",importer:new W});A({editor:s,licenseKey:t.licenseKey,plan:U,pluginName:R,cleanup:()=>{e(),r()}})})});
21
+ `}handleBlockStatement(t){let e="";for(const r of t.body)e+=this.astToGrapesJS(r);return e}handleLiteral(t){return String(t.value??"")}handleIdentifier(t){let e={path:t.name};if(this.collectionStack.length>0){const r=this.collectionStack[this.collectionStack.length-1];t.name===r&&(e={collectionId:r,variableType:"currentItem"})}return`<data-variable data-gjs-data-resolver='${JSON.stringify(e)}'></data-variable>`}handleMemberExpression(t,e={}){let n={path:this.getExpressionString(t),...e};if(this.collectionStack.length>0){const a=this.collectionStack[this.collectionStack.length-1];let o=t;const i=[];for(;o.type==="MemberExpression";)o.property.type==="Identifier"&&!o.computed?i.unshift(o.property.name):o.property.type==="Literal"&&o.computed?i.unshift(String(o.property.value)):i.unshift(this.getExpressionString(o.property)),o=o.object;if(o.type==="Identifier"&&o.name===a){const l=i.join(".");n={...e,collectionId:a,variableType:"currentItem",path:l}}}return`<data-variable data-gjs-data-resolver='${JSON.stringify(n)}'></data-variable>`}handleBinaryExpression(t){return`${this.getExpressionString(t.left)} ${t.operator} ${this.getExpressionString(t.right)}`}handleLogicalExpression(t){return t.operator==="||"&&t.right.type==="Literal"?this.handleMemberExpression(t.left,{defaultValue:t.right.value}):`${this.getExpressionString(t.left)} ${t.operator} ${this.getExpressionString(t.right)}`}handleCallExpression(t){var e;if(t.callee.type==="Identifier"&&t.callee.name==="include"){const r=((e=t.arguments[0])==null?void 0:e.type)==="Literal"?String(t.arguments[0].value):"";return this.addMessage("info",`Partial includes are not fully supported: ${r}`),""}return""}getConditionExpression(t){if(t.type==="Identifier")return{logicalOperator:"and",statements:[{left:{type:"data-variable",path:t.name},operator:"isTruthy"}]};if(t.type==="MemberExpression"){let e=this.getExpressionString(t),r="isTruthy";return e.startsWith("!!")?(r="isTruthy",e=e.slice(2)):e.startsWith("!")&&(r="isFalsy",e=e.slice(1)),{logicalOperator:"and",statements:[{left:{type:"data-variable",path:e},operator:r}]}}if(t.type==="BinaryExpression"||t.type==="LogicalExpression"){const e=this.getConditionExpression(t.left),r=this.getConditionExpression(t.right);return`${e} ${t.operator} ${r}`}return t.type==="Literal"?typeof t.value=="string"?`'${t.value}'`:String(t.value??""):this.getExpressionString(t)}getExpressionString(t){switch(t.type){case"Identifier":return t.name;case"Literal":return String(t.value??"");case"MemberExpression":{const e=this.getExpressionString(t.object),r=this.getExpressionString(t.property);return t.computed?`${e}[${r}]`:`${e}.${r}`}case"BinaryExpression":{const e=this.getExpressionString(t.left),r=this.getExpressionString(t.right);return`${e} ${t.operator} ${r}`}case"LogicalExpression":{const e=this.getExpressionString(t.left),r=this.getExpressionString(t.right);return`${e} ${t.operator} ${r}`}default:return this.addMessage("warning",`Unsupported expression type for getExpressionString: ${t.type}`),""}}addMessage(t,e){this.messages.push({type:t,message:e})}}const U="dataSourceEjs",V=E.startup;return A(function(s,t={}){const e=D(s,new F),r=G(s,{contains:"<%",importer:new R});N({editor:s,licenseKey:t.licenseKey,plan:V,pluginName:U,cleanup:()=>{e(),r()}})})});
@@ -1,4 +1,4 @@
1
- "use strict";const T=require("handlebars/dist/cjs/handlebars"),$="app.grapesjs.com",x="app-stage.grapesjs.com",k="app2.grapesjs.com",A="app-stage2.grapesjs.com",b=[$,k,x,A,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],L="license:check:end",N=()=>typeof window<"u",R=({isDev:e,isStage:t,isPlatform:s})=>`${e?"":`https://${t?x:$}`}/${s?"platform-api":"api"}`,O=()=>{const e=N()&&window.location.hostname;return!!e&&(b.includes(e)||b.some(t=>e.endsWith(t)))};async function _({path:e,baseApiUrl:t,method:s="GET",headers:n={},params:a,body:r}){const i=`${t||R({isDev:!1,isStage:!1})}${e}`,c={method:s,headers:{"Content-Type":"application/json",...n}};r&&(c.body=JSON.stringify(r));const u=a?new URLSearchParams(a).toString():"",h=u?`?${u}`:"",l=await fetch(`${i}${h}`,c);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}var p=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(p||{}),d=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(d||{});const m={[p.free]:0,[p.startup]:10,[p.business]:20,[p.enterprise]:30};function w(e){const t=e;return t.init=s=>n=>e(n,s),t}const D=e=>w(e);async function G({editor:e,plan:t,pluginName:s,licenseKey:n,onLicenseCheckResponse:a,cleanup:r}){let o="",i;const c=l=>{console.warn("Cleanup plugin:",s,"Reason:",l),r()},u=(l={})=>{var P;const{error:y,sdkLicense:E}=l,g=(P=l.plan)==null?void 0:P.category;if(!(E||l.license)||y)c(y||"Invalid license");else if(g){const I=m[t],S=m[g];I>S&&c({pluginRequiredPlan:t,licensePlan:g})}};e.Commands.has(d.settings)&&(i=e.runCommand(d.settings),o=(i==null?void 0:i.baseUrl)||"");const h=l=>{a==null||a(l),l&&u(l)};if(!i){e.onReady(async()=>{if(!O())if(n){const l=await B({licenseKey:n,pluginName:s,baseApiUrl:o});h(l)}else c("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const l=M(i);h(l);return}e.on(L,l=>h(l))}const M=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function B(e){const{licenseKey:t,pluginName:s,baseApiUrl:n}=e;try{return(await _({baseApiUrl:n,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:s}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const j=(e,t)=>(e.config.optsHtml={...e.config.optsHtml,exporter:t},()=>{e.config.optsHtml.exporter=void 0}),U=(e,t)=>{const s=a=>{const{input:r}=a,{contains:o}=t;(!o||r.includes(o))&&(a.input=t.importer.import(r))},n=e.Parser.events.htmlBefore;return e.on(n,s),()=>{e.off(n,s)}},v={equals:"equals",isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue"},H={">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq"},W={contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"},V={...v,...H,...W};class F{getHelperId(t){return V[t]||t}getFullPath({collectionId:t,path:s}){let n=s;return t&&(n=[this._sanitizeVariableName(t),s].filter(Boolean).join(".")),n||""}getVariableSyntax({dataResolver:t}){const{defaultValue:s}=t,n=this.getFullPath(t);return s?`{{#if ${n}}}{{{${n}}}}{{else}}${s}{{/if}}`:`{{{${n}}}}`}getCollectionStartSyntax({dataResolver:t}){const{collectionId:s,dataSource:n}=t,a=n==null?void 0:n.path;let r="";if(t.startIndex!==void 0||t.endIndex!==void 0){const u=t.startIndex??0,h=t.endIndex!==void 0?t.endIndex:"";h!==""?r=` (slice ${a} ${u} ${h})`:r=` (slice ${a} ${u})`}const i=` as |${this._sanitizeVariableName(s)}|`;return`{{#each ${r||a}${i}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax({dataResolver:t}){const s=t.condition;if(!s)return"";const n=s,a=s;if(a.statements&&a.logicalOperator==="and"||a.logicalOperator==="or"){const{statements:r}=a,o=a.logicalOperator,i=r.map(u=>this._parseCondition(u)).join(" ");return`{{#if ${r.length>1?`(${o} ${i})`:i}}}`}else return`{{#if ${this._parseCondition(n)}}}`}_parseCondition(t){if(!t)return"";const s=t,n=t;if(n.statements&&n.logicalOperator==="and"||n.logicalOperator==="or"){const{statements:a}=n,r=n.logicalOperator,o=n.statements.map(i=>this._parseCondition(i)).join(" ");return a.length>1?`(${r} ${o})`:o}else{const a=s.operator,r=this.getHelperId(a),o=this._parseValue(s.left),i=this._parseValue(s.right);return this.getExpressionStr(r,o,i)}}getExpressionStr(t,s,n){return v[t]?t==="isTruthy"?s:t==="isFalsy"?`!${s}`:`${t} ${s}`:`(${t} ${s} ${n})`}_parseValue(t){return typeof t=="object"?this.getFullPath(t):typeof t=="string"?`'${t.replace(/'/g,"\\'")}'`:String(t)}_sanitizeVariableName(t){return t.replace(/[^a-zA-Z0-9_$]/g,"_")}getConditionElseSyntax(){return"{{else}}"}getConditionalEndSyntax(){return"{{/if}}"}}class C{constructor(){this.messages=[],this.collectionStack=[]}import(t){this.messages=[],this.collectionStack=[];const s=this.parse(t);return this.astToGrapesJS(s)}parse(t){try{return T.parse(t)}catch(s){if(s instanceof Error&&s.message.includes("Parse error")){const n=s.message.match(/line (\d+)/),a=n?parseInt(n[1]):0,r=s.message.match(/column (\d+)/),o=r?parseInt(r[1]):0;throw new Error(`Handlebars syntax error at line ${a}, column ${o}: ${s.message}`)}throw s}}astToGrapesJS(t){switch(t.type){case"Program":return this.handleProgram(t);case"ContentStatement":return this.handleContentStatement(t);case"MustacheStatement":return this.handleMustacheStatement(t);case"BlockStatement":return this.handleBlockStatement(t);case"PartialStatement":return this.handlePartialStatement(t);case"CommentStatement":return this.handleCommentStatement(t);case"ElementNode":return this.handleElementNode(t);case"TextNode":return this.handleTextNode(t);default:return this.addMessage("warning",`Unsupported node type: ${t.type}`,t.loc),""}}handleProgram(t){let s="";if(t.body)for(const n of t.body)s+=this.astToGrapesJS(n);return s}handleContentStatement(t){return t.value||""}handleMustacheStatement(t,s={}){const n=this.getExpressionString(t.path),a={...s};return this.collectionStack.length>0?this.processPathWithCollectionContext(n,a):a.path=n,`<data-variable data-gjs-data-resolver='${JSON.stringify(a)}'></data-variable>`}processPathWithCollectionContext(t,s){t.startsWith("@")?this.handleDirectCollectionReference(t,s):this.handleRelativePathReference(t,s)}handleDirectCollectionReference(t,s){if(this.isSpecialIterationVariable(t)){this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length-1],t,s);return}const[n,...a]=t.substring(1).split("/"),r=a.join(".");this.collectionStack.includes(n)?this.setCurrentItemResolver(n,r,s):this.handleParentReferenceFallback(t,s)}isSpecialIterationVariable(t){return["index","@index","key","@key"].includes(t)}setSpecialVariableResolver(t,s,n){n.collectionId=t;const a={index:"currentIndex","@index":"currentIndex",key:"currentKey","@key":"currentKey"};n.variableType=a[s]}setCurrentItemResolver(t,s,n){n.collectionId=t,n.variableType="currentItem",s&&(n.path=s)}handleRelativePathReference(t,s){const n=f(t),{parentLevel:a,remainingPathParts:r}=this.calculateParentLevel(n),o=r.join("."),i=this.collectionStack.length-1-a;i>=0&&i<this.collectionStack.length?this.resolveRelativePath(o,i,s):s.path=r.join(".")}calculateParentLevel(t){const s=this.collectionStack.findLastIndex(r=>r===t[0]);if(s!==-1)return{parentLevel:this.collectionStack.length-1-s,remainingPathParts:t.slice(1)};let n=0;const a=[...t];for(;a[0]==="..";)n++,a.shift();return{parentLevel:n,remainingPathParts:a}}resolveRelativePath(t,s,n){const a=this.collectionStack[s];n.collectionId=a,n.variableType="currentItem",t!=="this"&&(n.path=t.startsWith("this.")?t.split(".").slice(1).join("."):t)}handleParentReferenceFallback(t,s){const n=f(t),{parentLevel:a,remainingPathParts:r}=this.calculateParentLevel(n),o=r.join("."),i=this.collectionStack.length-1-a;i>=0&&i<this.collectionStack.length?this.resolveRelativePath(o,i,s):s.path=r.join(".")}handleBlockStatement(t){const s=t.path.original;switch(s){case"if":case"unless":return this.handleConditionalBlock(t,s);case"each":return this.handleEachBlock(t);default:return this.addMessage("warning",`Unsupported block helper: ${s}`,t.loc),this.handleGenericBlock(t)}}handleConditionalBlock(t,s){const r={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(t.params[0])},operator:s==="unless"?"isFalsy":"isTruthy"}]},o=this.handleProgram(t.program),i=t.inverse?this.handleProgram(t.inverse):"";return`
1
+ "use strict";const T=require("handlebars/dist/cjs/handlebars"),x="app.grapesjs.com",$="app-stage.grapesjs.com",k="app2.grapesjs.com",A="app-stage2.grapesjs.com",P=[x,k,$,A,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],L="license:check:end",N=()=>typeof window<"u",R=({isDev:e,isStage:t,isPlatform:s})=>`${e?"":`https://${t?$:x}`}/${s?"platform-api":"api"}`,O=()=>{if(!N())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},_=()=>{const e=O();return!!e&&(P.includes(e)||P.some(t=>e.endsWith(t)))};async function w({path:e,baseApiUrl:t,method:s="GET",headers:n={},params:a,body:r}){const i=`${t||R({isDev:!1,isStage:!1})}${e}`,c={method:s,headers:{"Content-Type":"application/json",...n}};r&&(c.body=JSON.stringify(r));const u=a?new URLSearchParams(a).toString():"",h=u?`?${u}`:"",l=await fetch(`${i}${h}`,c);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}var p=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(p||{}),d=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.openEditCode="studio:openEditCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(d||{});const m={[p.free]:0,[p.startup]:10,[p.business]:20,[p.enterprise]:30};function D(e){const t=e;return t.init=s=>n=>e(n,s),t}const G=e=>D(e);async function M({editor:e,plan:t,pluginName:s,licenseKey:n,onLicenseCheckResponse:a,cleanup:r}){let o="",i;const c=l=>{console.warn("Cleanup plugin:",s,"Reason:",l),r()},u=(l={})=>{var b;const{error:y,sdkLicense:E}=l,g=(b=l.plan)==null?void 0:b.category;if(!(E||l.license)||y)c(y||"Invalid license");else if(g){const I=m[t],S=m[g];I>S&&c({pluginRequiredPlan:t,licensePlan:g})}};e.Commands.has(d.settings)&&(i=e.runCommand(d.settings),o=(i==null?void 0:i.baseUrl)||"");const h=l=>{a==null||a(l),l&&u(l)};if(!i){e.onReady(async()=>{if(!_())if(n){const l=await j({licenseKey:n,pluginName:s,baseApiUrl:o});h(l)}else c("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const l=B(i);h(l);return}e.on(L,l=>h(l))}const B=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function j(e){const{licenseKey:t,pluginName:s,baseApiUrl:n}=e;try{return(await w({baseApiUrl:n,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:s}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const U=(e,t)=>(e.config.optsHtml={...e.config.optsHtml,exporter:t},()=>{e.config.optsHtml.exporter=void 0}),H=(e,t)=>{const s=a=>{const{input:r}=a,{contains:o}=t;(!o||r.includes(o))&&(a.input=t.importer.import(r))},n=e.Parser.events.htmlBefore;return e.on(n,s),()=>{e.off(n,s)}},v={equals:"equals",isTruthy:"isTruthy",isFalsy:"isFalsy",isDefined:"isDefined",isNull:"isNull",isUndefined:"isUndefined",isArray:"isArray",isObject:"isObject",isString:"isString",isNumber:"isNumber",isBoolean:"isBoolean",isDefaultValue:"isDefaultValue"},W={">":"numGt","<":"numLt",">=":"numGte","<=":"numLte","=":"numEq","!=":"numNeq"},V={contains:"strContains",startsWith:"strStartsWith",endsWith:"strEndsWith",equalsIgnoreCase:"strEqualsIgnoreCase",trimEquals:"strTrimEquals"},F={...v,...W,...V};class C{getHelperId(t){return F[t]||t}getFullPath({collectionId:t,path:s}){let n=s;return t&&(n=[this._sanitizeVariableName(t),s].filter(Boolean).join(".")),n||""}getVariableSyntax({dataResolver:t}){const{defaultValue:s}=t,n=this.getFullPath(t);return s?`{{#if ${n}}}{{{${n}}}}{{else}}${s}{{/if}}`:`{{{${n}}}}`}getCollectionStartSyntax({dataResolver:t}){const{collectionId:s,dataSource:n}=t,a=n==null?void 0:n.path;let r="";if(t.startIndex!==void 0||t.endIndex!==void 0){const u=t.startIndex??0,h=t.endIndex!==void 0?t.endIndex:"";h!==""?r=` (slice ${a} ${u} ${h})`:r=` (slice ${a} ${u})`}const i=` as |${this._sanitizeVariableName(s)}|`;return`{{#each ${r||a}${i}}}`}getCollectionEndSyntax(){return"{{/each}}"}getConditionalStartSyntax({dataResolver:t}){const s=t.condition;if(!s)return"";const n=s,a=s;if(a.statements&&a.logicalOperator==="and"||a.logicalOperator==="or"){const{statements:r}=a,o=a.logicalOperator,i=r.map(u=>this._parseCondition(u)).join(" ");return`{{#if ${r.length>1?`(${o} ${i})`:i}}}`}else return`{{#if ${this._parseCondition(n)}}}`}_parseCondition(t){if(!t)return"";const s=t,n=t;if(n.statements&&n.logicalOperator==="and"||n.logicalOperator==="or"){const{statements:a}=n,r=n.logicalOperator,o=n.statements.map(i=>this._parseCondition(i)).join(" ");return a.length>1?`(${r} ${o})`:o}else{const a=s.operator,r=this.getHelperId(a),o=this._parseValue(s.left),i=this._parseValue(s.right);return this.getExpressionStr(r,o,i)}}getExpressionStr(t,s,n){return v[t]?t==="isTruthy"?s:t==="isFalsy"?`!${s}`:`${t} ${s}`:`(${t} ${s} ${n})`}_parseValue(t){return typeof t=="object"?this.getFullPath(t):typeof t=="string"?`'${t.replace(/'/g,"\\'")}'`:String(t)}_sanitizeVariableName(t){return t.replace(/[^a-zA-Z0-9_$]/g,"_")}getConditionElseSyntax(){return"{{else}}"}getConditionalEndSyntax(){return"{{/if}}"}}class q{constructor(){this.messages=[],this.collectionStack=[]}import(t){this.messages=[],this.collectionStack=[];const s=this.parse(t);return this.astToGrapesJS(s)}parse(t){try{return T.parse(t)}catch(s){if(s instanceof Error&&s.message.includes("Parse error")){const n=s.message.match(/line (\d+)/),a=n?parseInt(n[1]):0,r=s.message.match(/column (\d+)/),o=r?parseInt(r[1]):0;throw new Error(`Handlebars syntax error at line ${a}, column ${o}: ${s.message}`)}throw s}}astToGrapesJS(t){switch(t.type){case"Program":return this.handleProgram(t);case"ContentStatement":return this.handleContentStatement(t);case"MustacheStatement":return this.handleMustacheStatement(t);case"BlockStatement":return this.handleBlockStatement(t);case"PartialStatement":return this.handlePartialStatement(t);case"CommentStatement":return this.handleCommentStatement(t);case"ElementNode":return this.handleElementNode(t);case"TextNode":return this.handleTextNode(t);default:return this.addMessage("warning",`Unsupported node type: ${t.type}`,t.loc),""}}handleProgram(t){let s="";if(t.body)for(const n of t.body)s+=this.astToGrapesJS(n);return s}handleContentStatement(t){return t.value||""}handleMustacheStatement(t,s={}){const n=this.getExpressionString(t.path),a={...s};return this.collectionStack.length>0?this.processPathWithCollectionContext(n,a):a.path=n,`<data-variable data-gjs-data-resolver='${JSON.stringify(a)}'></data-variable>`}processPathWithCollectionContext(t,s){t.startsWith("@")?this.handleDirectCollectionReference(t,s):this.handleRelativePathReference(t,s)}handleDirectCollectionReference(t,s){if(this.isSpecialIterationVariable(t)){this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length-1],t,s);return}const[n,...a]=t.substring(1).split("/"),r=a.join(".");this.collectionStack.includes(n)?this.setCurrentItemResolver(n,r,s):this.handleParentReferenceFallback(t,s)}isSpecialIterationVariable(t){return["index","@index","key","@key"].includes(t)}setSpecialVariableResolver(t,s,n){n.collectionId=t;const a={index:"currentIndex","@index":"currentIndex",key:"currentKey","@key":"currentKey"};n.variableType=a[s]}setCurrentItemResolver(t,s,n){n.collectionId=t,n.variableType="currentItem",s&&(n.path=s)}handleRelativePathReference(t,s){const n=f(t),{parentLevel:a,remainingPathParts:r}=this.calculateParentLevel(n),o=r.join("."),i=this.collectionStack.length-1-a;i>=0&&i<this.collectionStack.length?this.resolveRelativePath(o,i,s):s.path=r.join(".")}calculateParentLevel(t){const s=this.collectionStack.findLastIndex(r=>r===t[0]);if(s!==-1)return{parentLevel:this.collectionStack.length-1-s,remainingPathParts:t.slice(1)};let n=0;const a=[...t];for(;a[0]==="..";)n++,a.shift();return{parentLevel:n,remainingPathParts:a}}resolveRelativePath(t,s,n){const a=this.collectionStack[s];n.collectionId=a,n.variableType="currentItem",t!=="this"&&(n.path=t.startsWith("this.")?t.split(".").slice(1).join("."):t)}handleParentReferenceFallback(t,s){const n=f(t),{parentLevel:a,remainingPathParts:r}=this.calculateParentLevel(n),o=r.join("."),i=this.collectionStack.length-1-a;i>=0&&i<this.collectionStack.length?this.resolveRelativePath(o,i,s):s.path=r.join(".")}handleBlockStatement(t){const s=t.path.original;switch(s){case"if":case"unless":return this.handleConditionalBlock(t,s);case"each":return this.handleEachBlock(t);default:return this.addMessage("warning",`Unsupported block helper: ${s}`,t.loc),this.handleGenericBlock(t)}}handleConditionalBlock(t,s){const r={logicalOperator:"and",statements:[{left:{type:"data-variable",path:this.getExpressionString(t.params[0])},operator:s==="unless"?"isFalsy":"isTruthy"}]},o=this.handleProgram(t.program),i=t.inverse?this.handleProgram(t.inverse):"";return`
2
2
  <data-condition data-gjs-data-resolver='${JSON.stringify({condition:r})}'>
3
3
  <data-condition-true-content>${o}</data-condition-true-content>
4
4
  <data-condition-false-content>${i}</data-condition-false-content>
@@ -7,4 +7,4 @@
7
7
  <data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:s},collectionId:n})}'>
8
8
  <data-collection-item>${a}</data-collection-item>
9
9
  </data-collection>
10
- `}handleCommentStatement(t){return`<!--${t.value}-->`}handleElementNode(t){let s="";if(t.attributes)for(const a of t.attributes)a.value.type==="TextNode"?s+=` ${a.name}="${a.value.chars}"`:(this.addMessage("warning",`Complex attribute values not fully supported: ${a.name}`,t.loc),s+=` ${a.name}="${this.getExpressionString(a.value)}"`);let n="";if(t.children)for(const a of t.children)n+=this.astToGrapesJS(a);return`<${t.tag}${s}>${n}</${t.tag}>`}handleTextNode(t){return t.chars||""}handlePartialStatement(t){return this.addMessage("warning",`Partials are not fully supported: ${t.name.original}`,t.loc),`{{> ${t.name.original}}}`}handleGenericBlock(t){const s=this.handleProgram(t.program);return`<!-- Unsupported block: ${t.path.original} -->${s}`}getExpressionString(t){return t.type==="PathExpression"?t.original:t.type==="StringLiteral"?t.value:t.type==="NumberLiteral"?t.value.toString():t.type==="BooleanLiteral"?t.value?"true":"false":t.type==="SubExpression"?this.getExpressionString(t.params[0]):t.type==="Hash"?`{${t.pairs.map(n=>`${n.key}=${this.getExpressionString(n.value)}`).join(", ")}}`:(this.addMessage("warning",`Complex expression type not fully supported: ${t.type}`,t.loc),"")}addMessage(t,s,n){this.messages.push({type:t,message:s,location:n?{line:n.start.line,column:n.start.column}:void 0})}}const f=e=>{if(e==null||e==="")return[];if(e===".")return["this"];if(e===".."||e==="../")return[".."];if(e.startsWith("../")){const o=e.substring(3);return["..",...f(o)]}const t=[];let s=0,n=e.replace(/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,(o,i,c,u)=>{const h=c!==void 0?c:u||"";return t[s]=h,`__HANDLEBARS_PLACEHOLDER_${s++}__`});n=n.replace(/\//g,".");const a=n.split("."),r=[];for(const o of a){const i=/^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(o);if(i){const c=parseInt(i[1],10);r.push(t[c])}else o!==""&&r.push(o)}return r},q="dataSourceHandlebars",J=p.startup,z=function(e,t={}){const s=j(e,new F),n=U(e,{contains:"{{",importer:new C});G({editor:e,licenseKey:t.licenseKey,plan:J,pluginName:q,cleanup:()=>{s(),n()}})},K=D(z);module.exports=K;
10
+ `}handleCommentStatement(t){return`<!--${t.value}-->`}handleElementNode(t){let s="";if(t.attributes)for(const a of t.attributes)a.value.type==="TextNode"?s+=` ${a.name}="${a.value.chars}"`:(this.addMessage("warning",`Complex attribute values not fully supported: ${a.name}`,t.loc),s+=` ${a.name}="${this.getExpressionString(a.value)}"`);let n="";if(t.children)for(const a of t.children)n+=this.astToGrapesJS(a);return`<${t.tag}${s}>${n}</${t.tag}>`}handleTextNode(t){return t.chars||""}handlePartialStatement(t){return this.addMessage("warning",`Partials are not fully supported: ${t.name.original}`,t.loc),`{{> ${t.name.original}}}`}handleGenericBlock(t){const s=this.handleProgram(t.program);return`<!-- Unsupported block: ${t.path.original} -->${s}`}getExpressionString(t){return t.type==="PathExpression"?t.original:t.type==="StringLiteral"?t.value:t.type==="NumberLiteral"?t.value.toString():t.type==="BooleanLiteral"?t.value?"true":"false":t.type==="SubExpression"?this.getExpressionString(t.params[0]):t.type==="Hash"?`{${t.pairs.map(n=>`${n.key}=${this.getExpressionString(n.value)}`).join(", ")}}`:(this.addMessage("warning",`Complex expression type not fully supported: ${t.type}`,t.loc),"")}addMessage(t,s,n){this.messages.push({type:t,message:s,location:n?{line:n.start.line,column:n.start.column}:void 0})}}const f=e=>{if(e==null||e==="")return[];if(e===".")return["this"];if(e===".."||e==="../")return[".."];if(e.startsWith("../")){const o=e.substring(3);return["..",...f(o)]}const t=[];let s=0,n=e.replace(/\[(?:(['"])(.*?)\1|([^\]]*))\]/g,(o,i,c,u)=>{const h=c!==void 0?c:u||"";return t[s]=h,`__HANDLEBARS_PLACEHOLDER_${s++}__`});n=n.replace(/\//g,".");const a=n.split("."),r=[];for(const o of a){const i=/^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(o);if(i){const c=parseInt(i[1],10);r.push(t[c])}else o!==""&&r.push(o)}return r},J="dataSourceHandlebars",z=p.startup,K=function(e,t={}){const s=U(e,new C),n=H(e,{contains:"{{",importer:new q});M({editor:e,licenseKey:t.licenseKey,plan:z,pluginName:J,cleanup:()=>{s(),n()}})},Y=G(K);module.exports=Y;