@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,8 +1,8 @@
1
1
  import T from "handlebars/dist/cjs/handlebars";
2
- const $ = "app.grapesjs.com", x = "app-stage.grapesjs.com", k = "app2.grapesjs.com", A = "app-stage2.grapesjs.com", b = [
3
- $,
4
- k,
2
+ const x = "app.grapesjs.com", $ = "app-stage.grapesjs.com", k = "app2.grapesjs.com", A = "app-stage2.grapesjs.com", P = [
5
3
  x,
4
+ k,
5
+ $,
6
6
  A,
7
7
  "localhost",
8
8
  "127.0.0.1",
@@ -10,29 +10,42 @@ const $ = "app.grapesjs.com", x = "app-stage.grapesjs.com", k = "app2.grapesjs.c
10
10
  // For stackblitz.com demos
11
11
  ".local.webcontainer.io",
12
12
  // For stackblitz.com demos
13
- "-sandpack.codesandbox.io"
13
+ "-sandpack.codesandbox.io",
14
14
  // For Sandpack demos
15
+ ".claudemcpcontent.com",
16
+ // For Claude mcp app
17
+ ".web-sandbox.oaiusercontent.com"
18
+ // For OpenAI mcp app
15
19
  ], L = "license:check:end", N = () => typeof window < "u", R = ({
16
20
  isDev: e,
17
21
  isStage: t,
18
- isPlatform: s
19
- }) => `${e ? "" : `https://${t ? x : $}`}/${s ? "platform-api" : "api"}`, O = () => {
20
- const e = N() && window.location.hostname;
21
- return !!e && (b.includes(e) || b.some((t) => e.endsWith(t)));
22
+ isPlatform: n
23
+ }) => `${e ? "" : `https://${t ? $ : x}`}/${n ? "platform-api" : "api"}`, O = () => {
24
+ if (!N()) return "";
25
+ const { hostname: e } = window.location;
26
+ if (e) return e;
27
+ try {
28
+ return window.parent.location.hostname || "";
29
+ } catch {
30
+ return "";
31
+ }
32
+ }, _ = () => {
33
+ const e = O();
34
+ return !!e && (P.includes(e) || P.some((t) => e.endsWith(t)));
22
35
  };
23
- async function _({
36
+ async function w({
24
37
  path: e,
25
38
  baseApiUrl: t,
26
- method: s = "GET",
27
- headers: n = {},
39
+ method: n = "GET",
40
+ headers: s = {},
28
41
  params: a,
29
42
  body: r
30
43
  }) {
31
44
  const i = `${t || R({ isDev: !1, isStage: !1 })}${e}`, c = {
32
- method: s,
45
+ method: n,
33
46
  headers: {
34
47
  "Content-Type": "application/json",
35
- ...n
48
+ ...s
36
49
  }
37
50
  };
38
51
  r && (c.body = JSON.stringify(r));
@@ -41,32 +54,32 @@ async function _({
41
54
  throw new Error(`HTTP error! status: ${l.status}`);
42
55
  return l.json();
43
56
  }
44
- var p = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(p || {}), d = /* @__PURE__ */ ((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 || {});
57
+ var p = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(p || {}), d = /* @__PURE__ */ ((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 || {});
45
58
  const m = {
46
59
  [p.free]: 0,
47
60
  [p.startup]: 10,
48
61
  [p.business]: 20,
49
62
  [p.enterprise]: 30
50
63
  };
51
- function w(e) {
64
+ function D(e) {
52
65
  const t = e;
53
- return t.init = (s) => (n) => e(n, s), t;
66
+ return t.init = (n) => (s) => e(s, n), t;
54
67
  }
55
- const D = (e) => /* @__PURE__ */ w(e);
56
- async function G({
68
+ const G = (e) => /* @__PURE__ */ D(e);
69
+ async function M({
57
70
  editor: e,
58
71
  plan: t,
59
- pluginName: s,
60
- licenseKey: n,
72
+ pluginName: n,
73
+ licenseKey: s,
61
74
  onLicenseCheckResponse: a,
62
75
  cleanup: r
63
76
  }) {
64
77
  let o = "", i;
65
78
  const c = (l) => {
66
- console.warn("Cleanup plugin:", s, "Reason:", l), r();
79
+ console.warn("Cleanup plugin:", n, "Reason:", l), r();
67
80
  }, u = (l = {}) => {
68
- var P;
69
- const { error: y, sdkLicense: E } = l, g = (P = l.plan) == null ? void 0 : P.category;
81
+ var b;
82
+ const { error: y, sdkLicense: E } = l, g = (b = l.plan) == null ? void 0 : b.category;
70
83
  if (!(E || l.license) || y)
71
84
  c(y || "Invalid license");
72
85
  else if (g) {
@@ -80,9 +93,9 @@ async function G({
80
93
  };
81
94
  if (!i) {
82
95
  e.onReady(async () => {
83
- if (!O())
84
- if (n) {
85
- const l = await B({ licenseKey: n, pluginName: s, baseApiUrl: o });
96
+ if (!_())
97
+ if (s) {
98
+ const l = await j({ licenseKey: s, pluginName: n, baseApiUrl: o });
86
99
  h(l);
87
100
  } else
88
101
  c("The `licenseKey` option not provided");
@@ -90,46 +103,46 @@ async function G({
90
103
  return;
91
104
  }
92
105
  if (i.licensePlan || i.licenseError) {
93
- const l = M(i);
106
+ const l = B(i);
94
107
  h(l);
95
108
  return;
96
109
  }
97
110
  e.on(L, (l) => h(l));
98
111
  }
99
- const M = (e) => ({
112
+ const B = (e) => ({
100
113
  sdkLicense: e.license,
101
114
  license: e.license,
102
115
  error: e.licenseError,
103
116
  plan: e.licensePlan
104
117
  });
105
- async function B(e) {
106
- const { licenseKey: t, pluginName: s, baseApiUrl: n } = e;
118
+ async function j(e) {
119
+ const { licenseKey: t, pluginName: n, baseApiUrl: s } = e;
107
120
  try {
108
- return (await _({
109
- baseApiUrl: n,
121
+ return (await w({
122
+ baseApiUrl: s,
110
123
  path: `/sdk/${t || "na"}`,
111
124
  method: "POST",
112
125
  params: {
113
126
  d: window.location.hostname,
114
- pn: s
127
+ pn: n
115
128
  }
116
129
  })).result || {};
117
130
  } catch (a) {
118
131
  return console.error("Error during SDK license check:", a), !1;
119
132
  }
120
133
  }
121
- const j = (e, t) => (e.config.optsHtml = {
134
+ const U = (e, t) => (e.config.optsHtml = {
122
135
  ...e.config.optsHtml,
123
136
  exporter: t
124
137
  }, () => {
125
138
  e.config.optsHtml.exporter = void 0;
126
- }), U = (e, t) => {
127
- const s = (a) => {
139
+ }), H = (e, t) => {
140
+ const n = (a) => {
128
141
  const { input: r } = a, { contains: o } = t;
129
142
  (!o || r.includes(o)) && (a.input = t.importer.import(r));
130
- }, n = e.Parser.events.htmlBefore;
131
- return e.on(n, s), () => {
132
- e.off(n, s);
143
+ }, s = e.Parser.events.htmlBefore;
144
+ return e.on(s, n), () => {
145
+ e.off(s, n);
133
146
  };
134
147
  }, v = {
135
148
  equals: "equals",
@@ -144,72 +157,72 @@ const j = (e, t) => (e.config.optsHtml = {
144
157
  isNumber: "isNumber",
145
158
  isBoolean: "isBoolean",
146
159
  isDefaultValue: "isDefaultValue"
147
- }, H = {
160
+ }, W = {
148
161
  ">": "numGt",
149
162
  "<": "numLt",
150
163
  ">=": "numGte",
151
164
  "<=": "numLte",
152
165
  "=": "numEq",
153
166
  "!=": "numNeq"
154
- }, W = {
167
+ }, V = {
155
168
  contains: "strContains",
156
169
  startsWith: "strStartsWith",
157
170
  endsWith: "strEndsWith",
158
171
  equalsIgnoreCase: "strEqualsIgnoreCase",
159
172
  trimEquals: "strTrimEquals"
160
- }, V = {
173
+ }, F = {
161
174
  ...v,
162
- ...H,
163
- ...W
175
+ ...W,
176
+ ...V
164
177
  };
165
- class F {
178
+ class C {
166
179
  getHelperId(t) {
167
- return V[t] || t;
180
+ return F[t] || t;
168
181
  }
169
- getFullPath({ collectionId: t, path: s }) {
170
- let n = s;
171
- return t && (n = [this._sanitizeVariableName(t), s].filter(Boolean).join(".")), n || "";
182
+ getFullPath({ collectionId: t, path: n }) {
183
+ let s = n;
184
+ return t && (s = [this._sanitizeVariableName(t), n].filter(Boolean).join(".")), s || "";
172
185
  }
173
186
  getVariableSyntax({ dataResolver: t }) {
174
- const { defaultValue: s } = t, n = this.getFullPath(t);
175
- return s ? `{{#if ${n}}}{{{${n}}}}{{else}}${s}{{/if}}` : `{{{${n}}}}`;
187
+ const { defaultValue: n } = t, s = this.getFullPath(t);
188
+ return n ? `{{#if ${s}}}{{{${s}}}}{{else}}${n}{{/if}}` : `{{{${s}}}}`;
176
189
  }
177
190
  getCollectionStartSyntax({ dataResolver: t }) {
178
- const { collectionId: s, dataSource: n } = t, a = n == null ? void 0 : n.path;
191
+ const { collectionId: n, dataSource: s } = t, a = s == null ? void 0 : s.path;
179
192
  let r = "";
180
193
  if (t.startIndex !== void 0 || t.endIndex !== void 0) {
181
194
  const u = t.startIndex ?? 0, h = t.endIndex !== void 0 ? t.endIndex : "";
182
195
  h !== "" ? r = ` (slice ${a} ${u} ${h})` : r = ` (slice ${a} ${u})`;
183
196
  }
184
- const i = ` as |${this._sanitizeVariableName(s)}|`;
197
+ const i = ` as |${this._sanitizeVariableName(n)}|`;
185
198
  return `{{#each ${r || a}${i}}}`;
186
199
  }
187
200
  getCollectionEndSyntax() {
188
201
  return "{{/each}}";
189
202
  }
190
203
  getConditionalStartSyntax({ dataResolver: t }) {
191
- const s = t.condition;
192
- if (!s) return "";
193
- const n = s, a = s;
204
+ const n = t.condition;
205
+ if (!n) return "";
206
+ const s = n, a = n;
194
207
  if (a.statements && a.logicalOperator === "and" || a.logicalOperator === "or") {
195
208
  const { statements: r } = a, o = a.logicalOperator, i = r.map((u) => this._parseCondition(u)).join(" ");
196
209
  return `{{#if ${r.length > 1 ? `(${o} ${i})` : i}}}`;
197
210
  } else
198
- return `{{#if ${this._parseCondition(n)}}}`;
211
+ return `{{#if ${this._parseCondition(s)}}}`;
199
212
  }
200
213
  _parseCondition(t) {
201
214
  if (!t) return "";
202
- const s = t, n = t;
203
- if (n.statements && n.logicalOperator === "and" || n.logicalOperator === "or") {
204
- const { statements: a } = n, r = n.logicalOperator, o = n.statements.map((i) => this._parseCondition(i)).join(" ");
215
+ const n = t, s = t;
216
+ if (s.statements && s.logicalOperator === "and" || s.logicalOperator === "or") {
217
+ const { statements: a } = s, r = s.logicalOperator, o = s.statements.map((i) => this._parseCondition(i)).join(" ");
205
218
  return a.length > 1 ? `(${r} ${o})` : o;
206
219
  } else {
207
- const a = s.operator, r = this.getHelperId(a), o = this._parseValue(s.left), i = this._parseValue(s.right);
220
+ const a = n.operator, r = this.getHelperId(a), o = this._parseValue(n.left), i = this._parseValue(n.right);
208
221
  return this.getExpressionStr(r, o, i);
209
222
  }
210
223
  }
211
- getExpressionStr(t, s, n) {
212
- return v[t] ? t === "isTruthy" ? s : t === "isFalsy" ? `!${s}` : `${t} ${s}` : `(${t} ${s} ${n})`;
224
+ getExpressionStr(t, n, s) {
225
+ return v[t] ? t === "isTruthy" ? n : t === "isFalsy" ? `!${n}` : `${t} ${n}` : `(${t} ${n} ${s})`;
213
226
  }
214
227
  _parseValue(t) {
215
228
  return typeof t == "object" ? this.getFullPath(t) : typeof t == "string" ? `'${t.replace(/'/g, "\\'")}'` : String(t);
@@ -224,24 +237,24 @@ class F {
224
237
  return "{{/if}}";
225
238
  }
226
239
  }
227
- class C {
240
+ class q {
228
241
  constructor() {
229
242
  this.messages = [], this.collectionStack = [];
230
243
  }
231
244
  import(t) {
232
245
  this.messages = [], this.collectionStack = [];
233
- const s = this.parse(t);
234
- return this.astToGrapesJS(s);
246
+ const n = this.parse(t);
247
+ return this.astToGrapesJS(n);
235
248
  }
236
249
  parse(t) {
237
250
  try {
238
251
  return T.parse(t);
239
- } catch (s) {
240
- if (s instanceof Error && s.message.includes("Parse error")) {
241
- 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;
242
- throw new Error(`Handlebars syntax error at line ${a}, column ${o}: ${s.message}`);
252
+ } catch (n) {
253
+ if (n instanceof Error && n.message.includes("Parse error")) {
254
+ const s = n.message.match(/line (\d+)/), a = s ? parseInt(s[1]) : 0, r = n.message.match(/column (\d+)/), o = r ? parseInt(r[1]) : 0;
255
+ throw new Error(`Handlebars syntax error at line ${a}, column ${o}: ${n.message}`);
243
256
  }
244
- throw s;
257
+ throw n;
245
258
  }
246
259
  }
247
260
  astToGrapesJS(t) {
@@ -267,87 +280,87 @@ class C {
267
280
  }
268
281
  }
269
282
  handleProgram(t) {
270
- let s = "";
283
+ let n = "";
271
284
  if (t.body)
272
- for (const n of t.body)
273
- s += this.astToGrapesJS(n);
274
- return s;
285
+ for (const s of t.body)
286
+ n += this.astToGrapesJS(s);
287
+ return n;
275
288
  }
276
289
  handleContentStatement(t) {
277
290
  return t.value || "";
278
291
  }
279
- handleMustacheStatement(t, s = {}) {
280
- const n = this.getExpressionString(t.path), a = { ...s };
281
- return this.collectionStack.length > 0 ? this.processPathWithCollectionContext(n, a) : a.path = n, `<data-variable data-gjs-data-resolver='${JSON.stringify(a)}'></data-variable>`;
292
+ handleMustacheStatement(t, n = {}) {
293
+ const s = this.getExpressionString(t.path), a = { ...n };
294
+ return this.collectionStack.length > 0 ? this.processPathWithCollectionContext(s, a) : a.path = s, `<data-variable data-gjs-data-resolver='${JSON.stringify(a)}'></data-variable>`;
282
295
  }
283
- processPathWithCollectionContext(t, s) {
284
- t.startsWith("@") ? this.handleDirectCollectionReference(t, s) : this.handleRelativePathReference(t, s);
296
+ processPathWithCollectionContext(t, n) {
297
+ t.startsWith("@") ? this.handleDirectCollectionReference(t, n) : this.handleRelativePathReference(t, n);
285
298
  }
286
- handleDirectCollectionReference(t, s) {
299
+ handleDirectCollectionReference(t, n) {
287
300
  if (this.isSpecialIterationVariable(t)) {
288
- this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length - 1], t, s);
301
+ this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length - 1], t, n);
289
302
  return;
290
303
  }
291
- const [n, ...a] = t.substring(1).split("/"), r = a.join(".");
292
- this.collectionStack.includes(n) ? this.setCurrentItemResolver(n, r, s) : this.handleParentReferenceFallback(t, s);
304
+ const [s, ...a] = t.substring(1).split("/"), r = a.join(".");
305
+ this.collectionStack.includes(s) ? this.setCurrentItemResolver(s, r, n) : this.handleParentReferenceFallback(t, n);
293
306
  }
294
307
  isSpecialIterationVariable(t) {
295
308
  return ["index", "@index", "key", "@key"].includes(t);
296
309
  }
297
- setSpecialVariableResolver(t, s, n) {
298
- n.collectionId = t;
310
+ setSpecialVariableResolver(t, n, s) {
311
+ s.collectionId = t;
299
312
  const a = {
300
313
  index: "currentIndex",
301
314
  "@index": "currentIndex",
302
315
  key: "currentKey",
303
316
  "@key": "currentKey"
304
317
  };
305
- n.variableType = a[s];
318
+ s.variableType = a[n];
306
319
  }
307
- setCurrentItemResolver(t, s, n) {
308
- n.collectionId = t, n.variableType = "currentItem", s && (n.path = s);
320
+ setCurrentItemResolver(t, n, s) {
321
+ s.collectionId = t, s.variableType = "currentItem", n && (s.path = n);
309
322
  }
310
- handleRelativePathReference(t, s) {
311
- const n = f(t), { parentLevel: a, remainingPathParts: r } = this.calculateParentLevel(n), o = r.join("."), i = this.collectionStack.length - 1 - a;
312
- i >= 0 && i < this.collectionStack.length ? this.resolveRelativePath(o, i, s) : s.path = r.join(".");
323
+ handleRelativePathReference(t, n) {
324
+ const s = f(t), { parentLevel: a, remainingPathParts: r } = this.calculateParentLevel(s), o = r.join("."), i = this.collectionStack.length - 1 - a;
325
+ i >= 0 && i < this.collectionStack.length ? this.resolveRelativePath(o, i, n) : n.path = r.join(".");
313
326
  }
314
327
  calculateParentLevel(t) {
315
- const s = this.collectionStack.findLastIndex((r) => r === t[0]);
316
- if (s !== -1)
317
- return { parentLevel: this.collectionStack.length - 1 - s, remainingPathParts: t.slice(1) };
318
- let n = 0;
328
+ const n = this.collectionStack.findLastIndex((r) => r === t[0]);
329
+ if (n !== -1)
330
+ return { parentLevel: this.collectionStack.length - 1 - n, remainingPathParts: t.slice(1) };
331
+ let s = 0;
319
332
  const a = [...t];
320
333
  for (; a[0] === ".."; )
321
- n++, a.shift();
322
- return { parentLevel: n, remainingPathParts: a };
334
+ s++, a.shift();
335
+ return { parentLevel: s, remainingPathParts: a };
323
336
  }
324
- resolveRelativePath(t, s, n) {
325
- const a = this.collectionStack[s];
326
- n.collectionId = a, n.variableType = "currentItem", t !== "this" && (n.path = t.startsWith("this.") ? t.split(".").slice(1).join(".") : t);
337
+ resolveRelativePath(t, n, s) {
338
+ const a = this.collectionStack[n];
339
+ s.collectionId = a, s.variableType = "currentItem", t !== "this" && (s.path = t.startsWith("this.") ? t.split(".").slice(1).join(".") : t);
327
340
  }
328
- handleParentReferenceFallback(t, s) {
329
- const n = f(t), { parentLevel: a, remainingPathParts: r } = this.calculateParentLevel(n), o = r.join("."), i = this.collectionStack.length - 1 - a;
330
- i >= 0 && i < this.collectionStack.length ? this.resolveRelativePath(o, i, s) : s.path = r.join(".");
341
+ handleParentReferenceFallback(t, n) {
342
+ const s = f(t), { parentLevel: a, remainingPathParts: r } = this.calculateParentLevel(s), o = r.join("."), i = this.collectionStack.length - 1 - a;
343
+ i >= 0 && i < this.collectionStack.length ? this.resolveRelativePath(o, i, n) : n.path = r.join(".");
331
344
  }
332
345
  handleBlockStatement(t) {
333
- const s = t.path.original;
334
- switch (s) {
346
+ const n = t.path.original;
347
+ switch (n) {
335
348
  case "if":
336
349
  case "unless":
337
- return this.handleConditionalBlock(t, s);
350
+ return this.handleConditionalBlock(t, n);
338
351
  case "each":
339
352
  return this.handleEachBlock(t);
340
353
  default:
341
- return this.addMessage("warning", `Unsupported block helper: ${s}`, t.loc), this.handleGenericBlock(t);
354
+ return this.addMessage("warning", `Unsupported block helper: ${n}`, t.loc), this.handleGenericBlock(t);
342
355
  }
343
356
  }
344
- handleConditionalBlock(t, s) {
357
+ handleConditionalBlock(t, n) {
345
358
  const r = {
346
359
  logicalOperator: "and",
347
360
  statements: [
348
361
  {
349
362
  left: { type: "data-variable", path: this.getExpressionString(t.params[0]) },
350
- operator: s === "unless" ? "isFalsy" : "isTruthy"
363
+ operator: n === "unless" ? "isFalsy" : "isTruthy"
351
364
  }
352
365
  ]
353
366
  }, o = this.handleProgram(t.program), i = t.inverse ? this.handleProgram(t.inverse) : "";
@@ -360,14 +373,14 @@ class C {
360
373
  }
361
374
  handleEachBlock(t) {
362
375
  var r, o, i;
363
- const s = this.getExpressionString(t.params[0]);
364
- let n;
365
- t.params.length >= 3 && t.params[1] === "as" && ((r = t.params[2]) == null ? void 0 : r.type) === "PathExpression" ? n = t.params[2].original : (i = (o = t.program) == null ? void 0 : o.blockParams) != null && i.length ? n = t.program.blockParams[0] : n = `collection-${Math.random().toString(36).substring(2, 10)}`, this.collectionStack.push(n);
376
+ const n = this.getExpressionString(t.params[0]);
377
+ let s;
378
+ t.params.length >= 3 && t.params[1] === "as" && ((r = t.params[2]) == null ? void 0 : r.type) === "PathExpression" ? s = t.params[2].original : (i = (o = t.program) == null ? void 0 : o.blockParams) != null && i.length ? s = t.program.blockParams[0] : s = `collection-${Math.random().toString(36).substring(2, 10)}`, this.collectionStack.push(s);
366
379
  const a = this.handleProgram(t.program);
367
380
  return this.collectionStack.pop(), `
368
381
  <data-collection data-gjs-data-resolver='${JSON.stringify({
369
- dataSource: { type: "data-variable", path: s },
370
- collectionId: n
382
+ dataSource: { type: "data-variable", path: n },
383
+ collectionId: s
371
384
  })}'>
372
385
  <data-collection-item>${a}</data-collection-item>
373
386
  </data-collection>
@@ -377,15 +390,15 @@ class C {
377
390
  return `<!--${t.value}-->`;
378
391
  }
379
392
  handleElementNode(t) {
380
- let s = "";
393
+ let n = "";
381
394
  if (t.attributes)
382
395
  for (const a of t.attributes)
383
- 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)}"`);
384
- let n = "";
396
+ a.value.type === "TextNode" ? n += ` ${a.name}="${a.value.chars}"` : (this.addMessage("warning", `Complex attribute values not fully supported: ${a.name}`, t.loc), n += ` ${a.name}="${this.getExpressionString(a.value)}"`);
397
+ let s = "";
385
398
  if (t.children)
386
399
  for (const a of t.children)
387
- n += this.astToGrapesJS(a);
388
- return `<${t.tag}${s}>${n}</${t.tag}>`;
400
+ s += this.astToGrapesJS(a);
401
+ return `<${t.tag}${n}>${s}</${t.tag}>`;
389
402
  }
390
403
  handleTextNode(t) {
391
404
  return t.chars || "";
@@ -394,17 +407,17 @@ class C {
394
407
  return this.addMessage("warning", `Partials are not fully supported: ${t.name.original}`, t.loc), `{{> ${t.name.original}}}`;
395
408
  }
396
409
  handleGenericBlock(t) {
397
- const s = this.handleProgram(t.program);
398
- return `<!-- Unsupported block: ${t.path.original} -->${s}`;
410
+ const n = this.handleProgram(t.program);
411
+ return `<!-- Unsupported block: ${t.path.original} -->${n}`;
399
412
  }
400
413
  getExpressionString(t) {
401
- 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), "");
414
+ 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((s) => `${s.key}=${this.getExpressionString(s.value)}`).join(", ")}}` : (this.addMessage("warning", `Complex expression type not fully supported: ${t.type}`, t.loc), "");
402
415
  }
403
- addMessage(t, s, n) {
416
+ addMessage(t, n, s) {
404
417
  this.messages.push({
405
418
  type: t,
406
- message: s,
407
- location: n ? { line: n.start.line, column: n.start.column } : void 0
419
+ message: n,
420
+ location: s ? { line: s.start.line, column: s.start.column } : void 0
408
421
  });
409
422
  }
410
423
  }
@@ -420,15 +433,15 @@ const f = (e) => {
420
433
  return ["..", ...f(o)];
421
434
  }
422
435
  const t = [];
423
- let s = 0, n = e.replace(
436
+ let n = 0, s = e.replace(
424
437
  /\[(?:(['"])(.*?)\1|([^\]]*))\]/g,
425
438
  (o, i, c, u) => {
426
439
  const h = c !== void 0 ? c : u || "";
427
- return t[s] = h, `__HANDLEBARS_PLACEHOLDER_${s++}__`;
440
+ return t[n] = h, `__HANDLEBARS_PLACEHOLDER_${n++}__`;
428
441
  }
429
442
  );
430
- n = n.replace(/\//g, ".");
431
- const a = n.split("."), r = [];
443
+ s = s.replace(/\//g, ".");
444
+ const a = s.split("."), r = [];
432
445
  for (const o of a) {
433
446
  const i = /^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(o);
434
447
  if (i) {
@@ -437,21 +450,21 @@ const f = (e) => {
437
450
  } else o !== "" && r.push(o);
438
451
  }
439
452
  return r;
440
- }, q = "dataSourceHandlebars", J = p.startup, z = function(e, t = {}) {
441
- const s = j(e, new F()), n = U(e, {
453
+ }, J = "dataSourceHandlebars", z = p.startup, K = function(e, t = {}) {
454
+ const n = U(e, new C()), s = H(e, {
442
455
  contains: "{{",
443
- importer: new C()
456
+ importer: new q()
444
457
  });
445
- G({
458
+ M({
446
459
  editor: e,
447
460
  licenseKey: t.licenseKey,
448
- plan: J,
449
- pluginName: q,
461
+ plan: z,
462
+ pluginName: J,
450
463
  cleanup: () => {
451
- s(), n();
464
+ n(), s();
452
465
  }
453
466
  });
454
- }, Z = D(z);
467
+ }, Q = G(K);
455
468
  export {
456
- Z as default
469
+ Q as default
457
470
  };