@grapesjs/studio-sdk-plugins 1.0.35 → 1.0.37

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 (92) hide show
  1. package/dist/accordionComponent/index.cjs.js +7 -7
  2. package/dist/accordionComponent/index.es.js +185 -159
  3. package/dist/accordionComponent/index.umd.js +7 -7
  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 +75 -75
  8. package/dist/aiChat/index.es.js +9122 -8628
  9. package/dist/aiChat/index.js +75 -75
  10. package/dist/aiChat/index.umd.js +75 -75
  11. package/dist/aiChat/projectGeneration.d.ts +17 -0
  12. package/dist/animationComponent/index.cjs.js +3 -3
  13. package/dist/animationComponent/index.es.js +221 -195
  14. package/dist/animationComponent/index.umd.js +3 -3
  15. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  16. package/dist/canvasAbsoluteMode/index.es.js +199 -173
  17. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  18. package/dist/canvasEmptyState/index.cjs.js +1 -1
  19. package/dist/canvasEmptyState/index.es.js +149 -123
  20. package/dist/canvasEmptyState/index.umd.js +1 -1
  21. package/dist/canvasFullSize/index.cjs.js +9 -9
  22. package/dist/canvasFullSize/index.es.js +186 -160
  23. package/dist/canvasFullSize/index.umd.js +9 -9
  24. package/dist/canvasGridMode/index.cjs.js +5 -5
  25. package/dist/canvasGridMode/index.es.js +263 -237
  26. package/dist/canvasGridMode/index.umd.js +2 -2
  27. package/dist/canvasScreenshot/index.cjs.js +1 -1
  28. package/dist/canvasScreenshot/index.es.js +168 -142
  29. package/dist/canvasScreenshot/index.umd.js +1 -1
  30. package/dist/dataSourceEjs/index.cjs.js +9 -9
  31. package/dist/dataSourceEjs/index.es.js +271 -245
  32. package/dist/dataSourceEjs/index.umd.js +9 -9
  33. package/dist/dataSourceHandlebars/index.cjs.js +8 -8
  34. package/dist/dataSourceHandlebars/index.es.js +232 -206
  35. package/dist/dataSourceHandlebars/index.umd.js +8 -8
  36. package/dist/dialogComponent/index.cjs.js +14 -14
  37. package/dist/dialogComponent/index.es.js +157 -131
  38. package/dist/dialogComponent/index.umd.js +14 -14
  39. package/dist/flexComponent/index.cjs.js +13 -13
  40. package/dist/flexComponent/index.es.js +497 -471
  41. package/dist/flexComponent/index.umd.js +13 -13
  42. package/dist/fsLightboxComponent/index.cjs.js +3 -3
  43. package/dist/fsLightboxComponent/index.es.js +189 -163
  44. package/dist/fsLightboxComponent/index.umd.js +3 -3
  45. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  46. package/dist/googleFontsAssetProvider/index.es.js +175 -149
  47. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  48. package/dist/iconifyComponent/index.cjs.js +2 -2
  49. package/dist/iconifyComponent/index.es.js +207 -181
  50. package/dist/iconifyComponent/index.umd.js +2 -2
  51. package/dist/index.cjs.js +36 -36
  52. package/dist/index.es.js +917 -891
  53. package/dist/index.umd.js +36 -36
  54. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  55. package/dist/layoutSidebarButtons/index.es.js +192 -166
  56. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  57. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  58. package/dist/lightGalleryComponent/index.es.js +265 -239
  59. package/dist/lightGalleryComponent/index.umd.js +1 -1
  60. package/dist/linkImageComponent/index.cjs.js +2 -2
  61. package/dist/linkImageComponent/index.es.js +121 -95
  62. package/dist/linkImageComponent/index.umd.js +2 -2
  63. package/dist/listPagesComponent/index.cjs.js +5 -5
  64. package/dist/listPagesComponent/index.es.js +171 -145
  65. package/dist/listPagesComponent/index.umd.js +5 -5
  66. package/dist/presetPrintable/index.cjs.js +3 -3
  67. package/dist/presetPrintable/index.es.js +227 -201
  68. package/dist/presetPrintable/index.umd.js +3 -3
  69. package/dist/prosemirror/index.cjs.js +7 -7
  70. package/dist/prosemirror/index.es.js +457 -431
  71. package/dist/prosemirror/index.umd.js +8 -8
  72. package/dist/rendererReact/index.cjs.js +1 -1
  73. package/dist/rendererReact/index.es.js +248 -223
  74. package/dist/rendererReact/index.js +1 -1
  75. package/dist/rendererReact/index.umd.js +1 -1
  76. package/dist/rteTinyMce/index.cjs.js +2 -2
  77. package/dist/rteTinyMce/index.es.js +150 -124
  78. package/dist/rteTinyMce/index.umd.js +2 -2
  79. package/dist/shapeDividerComponent/index.cjs.js +4 -4
  80. package/dist/shapeDividerComponent/index.es.js +143 -117
  81. package/dist/shapeDividerComponent/index.umd.js +4 -4
  82. package/dist/swiperComponent/index.cjs.js +9 -9
  83. package/dist/swiperComponent/index.es.js +218 -192
  84. package/dist/swiperComponent/index.umd.js +7 -7
  85. package/dist/tableComponent/index.cjs.js +1 -1
  86. package/dist/tableComponent/index.es.js +275 -249
  87. package/dist/tableComponent/index.umd.js +1 -1
  88. package/dist/types.d.ts +1 -1
  89. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  90. package/dist/youtubeAssetProvider/index.es.js +134 -108
  91. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  92. package/package.json +2 -2
@@ -1,101 +1,127 @@
1
- const V = "app.grapesjs.com", H = "app-stage.grapesjs.com", j = "app2.grapesjs.com", F = "app-stage2.grapesjs.com", U = [
2
- V,
3
- j,
4
- H,
5
- F,
1
+ const K = "app.grapesjs.com", k = "app-stage.grapesjs.com", X = "app2.grapesjs.com", q = "app-stage2.grapesjs.com", W = [
2
+ K,
3
+ X,
4
+ k,
5
+ q,
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
- ], q = "license:check:start", J = "license:check:end", z = () => typeof window < "u", Q = ({
15
- isDev: t,
14
+ ".claudemcpcontent.com",
15
+ // For Claude mcp app
16
+ ".web-sandbox.oaiusercontent.com"
17
+ // For OpenAI mcp app
18
+ ], J = "license:check:end", z = () => typeof window < "u", Q = ({
19
+ isDev: e,
16
20
  isStage: a,
17
21
  isPlatform: u
18
- }) => `${t ? "" : `https://${a ? H : V}`}/${u ? "platform-api" : "api"}`, Z = () => {
19
- const t = z() && window.location.hostname;
20
- return !!t && (U.includes(t) || U.some((a) => t.endsWith(a)));
22
+ }) => `${e ? "" : `https://${a ? k : K}`}/${u ? "platform-api" : "api"}`, Z = () => {
23
+ if (!z()) return "";
24
+ const { hostname: e } = window.location;
25
+ if (e) return e;
26
+ try {
27
+ return window.parent.location.hostname || "";
28
+ } catch {
29
+ return "";
30
+ }
31
+ }, C = () => {
32
+ const e = Z();
33
+ return !!e && (W.includes(e) || W.some((a) => e.endsWith(a)));
21
34
  };
22
- function k(t) {
23
- return typeof t == "function";
35
+ function ee(e) {
36
+ return typeof e == "function";
24
37
  }
25
- async function tt({
26
- path: t,
38
+ async function te({
39
+ path: e,
27
40
  baseApiUrl: a,
28
41
  method: u = "GET",
29
- headers: l = {},
30
- params: i,
31
- body: o
42
+ headers: c = {},
43
+ params: l,
44
+ body: s
32
45
  }) {
33
- const n = `${a || Q({ isDev: !1, isStage: !1 })}${t}`, g = {
46
+ const t = `${a || Q({ isDev: !1, isStage: !1 })}${e}`, h = {
34
47
  method: u,
35
48
  headers: {
36
49
  "Content-Type": "application/json",
37
- ...l
50
+ ...c
38
51
  }
39
52
  };
40
- o && (g.body = JSON.stringify(o));
41
- const d = i ? new URLSearchParams(i).toString() : "", c = d ? `?${d}` : "", e = await fetch(`${n}${c}`, g);
42
- if (!e.ok)
43
- throw new Error(`HTTP error! status: ${e.status}`);
44
- return e.json();
53
+ s && (h.body = JSON.stringify(s));
54
+ const d = l ? new URLSearchParams(l).toString() : "", i = d ? `?${d}` : "", o = await fetch(`${t}${i}`, h);
55
+ if (!o.ok)
56
+ throw new Error(`HTTP error! status: ${o.status}`);
57
+ return o.json();
45
58
  }
46
- var G = /* @__PURE__ */ ((t) => (t.free = "free", t.startup = "startup", t.business = "business", t.enterprise = "enterprise", t))(G || {});
47
- const W = {
48
- [G.free]: 0,
49
- [G.startup]: 10,
50
- [G.business]: 20,
51
- [G.enterprise]: 30
59
+ var m = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(m || {}), U = /* @__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))(U || {});
60
+ const V = {
61
+ [m.free]: 0,
62
+ [m.startup]: 10,
63
+ [m.business]: 20,
64
+ [m.enterprise]: 30
52
65
  };
53
- function et(t) {
54
- const a = t;
55
- return a.init = (u) => (l) => t(l, u), a;
66
+ function oe(e) {
67
+ const a = e;
68
+ return a.init = (u) => (c) => e(c, u), a;
56
69
  }
57
- const nt = (t) => /* @__PURE__ */ et(t);
58
- async function ot({
59
- editor: t,
70
+ const se = (e) => /* @__PURE__ */ oe(e);
71
+ async function ne({
72
+ editor: e,
60
73
  plan: a,
61
74
  pluginName: u,
62
- licenseKey: l,
63
- onLicenseCheckResponse: i,
64
- cleanup: o
75
+ licenseKey: c,
76
+ onLicenseCheckResponse: l,
77
+ cleanup: s
65
78
  }) {
66
- let s = "", n = !1;
67
- const g = Z(), d = (e) => {
68
- console.warn("Cleanup plugin:", u, "Reason:", e), o();
69
- }, c = (e = {}) => {
70
- var b;
71
- const { error: r, sdkLicense: f } = e, y = (b = e.plan) == null ? void 0 : b.category;
72
- if (!(f || e.license) || r)
73
- d(r || "Invalid license");
74
- else if (y) {
75
- const v = W[a], E = W[y];
76
- v > E && d({ pluginRequiredPlan: a, licensePlan: y });
79
+ let n = "", t;
80
+ const h = (o) => {
81
+ console.warn("Cleanup plugin:", u, "Reason:", o), s();
82
+ }, d = (o = {}) => {
83
+ var A;
84
+ const { error: p, sdkLicense: r } = o, b = (A = o.plan) == null ? void 0 : A.category;
85
+ if (!(r || o.license) || p)
86
+ h(p || "Invalid license");
87
+ else if (b) {
88
+ const R = V[a], E = V[b];
89
+ R > E && h({ pluginRequiredPlan: a, licensePlan: b });
77
90
  }
78
91
  };
79
- t.on(q, (e) => {
80
- s = e == null ? void 0 : e.baseApiUrl, n = !0;
81
- }), t.on(J, (e) => {
82
- i == null || i(e), c(e);
83
- }), setTimeout(async () => {
84
- if (!n) {
85
- if (g) return;
86
- if (l) {
87
- const e = await st({ licenseKey: l, pluginName: u, baseApiUrl: s });
88
- i == null || i(e), e && c(e);
89
- } else
90
- d("The `licenseKey` option not provided");
91
- }
92
- }, 2e3);
92
+ e.Commands.has(U.settings) && (t = e.runCommand(U.settings), n = (t == null ? void 0 : t.baseUrl) || "");
93
+ const i = (o) => {
94
+ l == null || l(o), o && d(o);
95
+ };
96
+ if (!t) {
97
+ e.onReady(async () => {
98
+ if (!C())
99
+ if (c) {
100
+ const o = await ae({ licenseKey: c, pluginName: u, baseApiUrl: n });
101
+ i(o);
102
+ } else
103
+ h("The `licenseKey` option not provided");
104
+ });
105
+ return;
106
+ }
107
+ if (t.licensePlan || t.licenseError) {
108
+ const o = ie(t);
109
+ i(o);
110
+ return;
111
+ }
112
+ e.on(J, (o) => i(o));
93
113
  }
94
- async function st(t) {
95
- const { licenseKey: a, pluginName: u, baseApiUrl: l } = t;
114
+ const ie = (e) => ({
115
+ sdkLicense: e.license,
116
+ license: e.license,
117
+ error: e.licenseError,
118
+ plan: e.licensePlan
119
+ });
120
+ async function ae(e) {
121
+ const { licenseKey: a, pluginName: u, baseApiUrl: c } = e;
96
122
  try {
97
- return (await tt({
98
- baseApiUrl: l,
123
+ return (await te({
124
+ baseApiUrl: c,
99
125
  path: `/sdk/${a || "na"}`,
100
126
  method: "POST",
101
127
  params: {
@@ -103,152 +129,152 @@ async function st(t) {
103
129
  pn: u
104
130
  }
105
131
  })).result || {};
106
- } catch (i) {
107
- return console.error("Error during SDK license check:", i), !1;
132
+ } catch (l) {
133
+ return console.error("Error during SDK license check:", l), !1;
108
134
  }
109
135
  }
110
- const it = "canvasAbsoluteMode", ct = G.startup, at = (t, a, u) => {
111
- var d, c;
112
- const l = u.enableAbsolute ?? ((e) => e.hasAbsolute), o = (Array.isArray(a) ? a : a ? [a] : [...t.getSelectedAll()])[0], s = ((c = (d = o == null ? void 0 : o.delegate) == null ? void 0 : d.move) == null ? void 0 : c.call(d, o)) || o;
113
- if (!s) return;
114
- const n = s.getEl();
136
+ const le = "canvasAbsoluteMode", ce = m.startup, re = (e, a, u) => {
137
+ var d, i;
138
+ const c = u.enableAbsolute ?? ((o) => o.hasAbsolute), s = (Array.isArray(a) ? a : a ? [a] : [...e.getSelectedAll()])[0], n = ((i = (d = s == null ? void 0 : s.delegate) == null ? void 0 : d.move) == null ? void 0 : i.call(d, s)) || s;
139
+ if (!n) return;
140
+ const t = n.getEl();
115
141
  return {
116
- result: k(l) ? l({ component: s, hasAbsolute: !!n && getComputedStyle(n).position === "absolute" }) : !1,
117
- component: s,
118
- dmode: s.get("dmode")
142
+ result: ee(c) ? c({ component: n, hasAbsolute: !!t && getComputedStyle(t).position === "absolute" }) : !1,
143
+ component: n,
144
+ dmode: n.get("dmode")
119
145
  };
120
146
  };
121
- function B({
122
- guideMatched: t,
147
+ function I({
148
+ guideMatched: e,
123
149
  canvasView: a
124
150
  }) {
125
- var C;
126
- const u = t.guide.x === void 0 ? "y" : "x";
127
- let l = 0, i = 0, o = 0, s = 0;
128
- const { guide: n, matched: g } = t, d = a.getElBoxRect(n.componentView.el), c = a.getElBoxRect(((C = g.componentView) == null ? void 0 : C.el) || g.componentEl), e = d.y, r = d.y + d.height, f = d.x, y = d.x + d.width, S = c.y, b = c.y + c.height, v = c.x, E = c.x + c.width, x = Math.max(0, e - b), m = Math.max(0, S - r), w = Math.max(0, f - E), M = Math.max(0, v - y), p = x > m, h = w > M, _ = n.type;
129
- return u === "x" && (_ === "l" ? (l = f, p ? (i = b, o = x) : (i = r, o = m)) : _ === "r" ? (l = y, p ? (i = b, o = x) : (i = r, o = m)) : _ === "x" && (l = f - (f - y) / 2, p ? (i = b, o = x) : (i = r, o = m))), u === "y" && (_ === "t" ? (i = e, h ? (l = E, s = w) : (l = y, s = M)) : _ === "b" ? (i = r, h ? (l = E, s = w) : (l = y, s = M)) : _ === "y" && (i = e - (e - r) / 2, h ? (l = E, s = w) : (l = y, s = M))), { axis: u, x: l, y: i, width: s, height: o };
151
+ var L;
152
+ const u = e.guide.x === void 0 ? "y" : "x";
153
+ let c = 0, l = 0, s = 0, n = 0;
154
+ const { guide: t, matched: h } = e, d = a.getElBoxRect(t.componentView.el), i = a.getElBoxRect(((L = h.componentView) == null ? void 0 : L.el) || h.componentEl), o = d.y, p = d.y + d.height, r = d.x, b = d.x + d.width, v = i.y, A = i.y + i.height, R = i.x, E = i.x + i.width, T = Math.max(0, o - A), g = Math.max(0, v - p), G = Math.max(0, r - E), D = Math.max(0, R - b), f = T > g, y = G > D, x = t.type;
155
+ return u === "x" && (x === "l" ? (c = r, f ? (l = A, s = T) : (l = p, s = g)) : x === "r" ? (c = b, f ? (l = A, s = T) : (l = p, s = g)) : x === "x" && (c = r - (r - b) / 2, f ? (l = A, s = T) : (l = p, s = g))), u === "y" && (x === "t" ? (l = o, y ? (c = E, n = G) : (c = b, n = D)) : x === "b" ? (l = p, y ? (c = E, n = G) : (c = b, n = D)) : x === "y" && (l = o - (o - p) / 2, y ? (c = E, n = G) : (c = b, n = D))), { axis: u, x: c, y: l, width: n, height: s };
130
156
  }
131
- function lt({
132
- guideMatched: t,
157
+ function de({
158
+ guideMatched: e,
133
159
  component: a,
134
160
  canvasView: u
135
161
  }) {
136
- const l = t.guide.x === void 0 ? "x" : "y", { guide: i, matched: o } = t, s = i.type, n = o.type, g = u.getElementPos(i.componentView.el).rect, d = u.getElementPos(o.componentView.el).rect;
137
- if (l === "x") {
138
- const c = g.height, e = d.top, r = d.top + d.height;
139
- let f = 0;
140
- s === "t" ? n === "t" ? f = e - c : n === "b" ? f = r - c : n === "y" && (f = e - c - (e - r) / 2) : s === "b" ? n === "t" ? f = e - c * 2 : n === "b" ? f = r - c * 2 : n === "y" && (f = e - c * 2 - (e - r) / 2) : s === "y" && (n === "t" ? f = e - c * 1.5 : n === "b" ? f = r - c * 1.5 : n === "y" && (f = e - c * 1.5 - (e - r) / 2)), a.addStyle({ top: `${f - 5}px` }, { partial: !0 });
162
+ const c = e.guide.x === void 0 ? "x" : "y", { guide: l, matched: s } = e, n = l.type, t = s.type, h = u.getElementPos(l.componentView.el).rect, d = u.getElementPos(s.componentView.el).rect;
163
+ if (c === "x") {
164
+ const i = h.height, o = d.top, p = d.top + d.height;
165
+ let r = 0;
166
+ n === "t" ? t === "t" ? r = o - i : t === "b" ? r = p - i : t === "y" && (r = o - i - (o - p) / 2) : n === "b" ? t === "t" ? r = o - i * 2 : t === "b" ? r = p - i * 2 : t === "y" && (r = o - i * 2 - (o - p) / 2) : n === "y" && (t === "t" ? r = o - i * 1.5 : t === "b" ? r = p - i * 1.5 : t === "y" && (r = o - i * 1.5 - (o - p) / 2)), a.addStyle({ top: `${r - 5}px` }, { partial: !0 });
141
167
  }
142
- if (l === "y") {
143
- const c = g.width, e = d.left, r = d.left + d.width;
144
- let f = 0;
145
- s === "l" ? n === "l" ? f = e : n === "r" ? f = r : n === "x" && (f = e - (e - r) / 2) : s === "r" ? n === "l" ? f = e - c : n === "r" ? f = r - c : n === "x" && (f = e - c - (e - r) / 2) : s === "x" && (n === "l" ? f = e - c / 2 : n === "r" && (f = r - c / 2)), a.addStyle({ left: `${f}px` }, { partial: !0 });
168
+ if (c === "y") {
169
+ const i = h.width, o = d.left, p = d.left + d.width;
170
+ let r = 0;
171
+ n === "l" ? t === "l" ? r = o : t === "r" ? r = p : t === "x" && (r = o - (o - p) / 2) : n === "r" ? t === "l" ? r = o - i : t === "r" ? r = p - i : t === "x" && (r = o - i - (o - p) / 2) : n === "x" && (t === "l" ? r = o - i / 2 : t === "r" && (r = p - i / 2)), a.addStyle({ left: `${r}px` }, { partial: !0 });
146
172
  }
147
173
  }
148
- function X({
149
- snapping: t,
174
+ function H({
175
+ snapping: e,
150
176
  editor: a,
151
177
  props: u
152
178
  }) {
153
- var N, P;
154
- const { command: l, guidesMatched: i } = u, o = u.component, s = o.getEl(), n = a.Canvas.getCanvasView(), { x: g, y: d } = t ?? { x: 10, y: 10 }, c = l.opts.event, e = c.clientX, r = c.clientY;
155
- if (!o.__lastSnappedPosition) {
156
- const A = n.getElBoxRect(s), D = e - A.x, T = r - A.y;
157
- o.__lastSnappedPosition = { left: A.x, top: A.y }, o.__dragOffset = { x: D, y: T };
179
+ var B, w;
180
+ const { command: c, guidesMatched: l } = u, s = u.component, n = s.getEl(), t = a.Canvas.getCanvasView(), { x: h, y: d } = e ?? { x: 10, y: 10 }, i = c.opts.event, o = i.clientX, p = i.clientY;
181
+ if (!s.__lastSnappedPosition) {
182
+ const P = t.getElBoxRect(n), _ = o - P.x, M = p - P.y;
183
+ s.__lastSnappedPosition = { left: P.x, top: P.y }, s.__dragOffset = { x: _, y: M };
158
184
  }
159
- const f = ((N = o.__dragOffset) == null ? void 0 : N.x) || 0, y = ((P = o.__dragOffset) == null ? void 0 : P.y) || 0, S = o.__lastSnappedPosition, b = e - S.left - f, v = r - S.top - y;
160
- let E = S.left, x = S.top;
161
- const m = i == null ? void 0 : i[0], w = (m == null ? void 0 : m.guide.type) === "l", M = (m == null ? void 0 : m.guide.type) === "x", p = (m == null ? void 0 : m.guide.type) === "r", h = (m == null ? void 0 : m.guide.type) === "t", _ = (m == null ? void 0 : m.guide.type) === "b", C = (m == null ? void 0 : m.guide.type) === "y";
162
- if (m) {
163
- const { x: A, y: D } = B({ guideMatched: m, canvasView: n }), T = s.offsetWidth, L = s.offsetHeight;
164
- w ? E = A : p ? E = A - T : M ? E = A - T / 2 : h ? x = D : _ ? x = D - L : C && (x = D - L / 2), o.__lastSnappedGuideMatched = m;
185
+ const r = ((B = s.__dragOffset) == null ? void 0 : B.x) || 0, b = ((w = s.__dragOffset) == null ? void 0 : w.y) || 0, v = s.__lastSnappedPosition, A = o - v.left - r, R = p - v.top - b;
186
+ let E = v.left, T = v.top;
187
+ const g = l == null ? void 0 : l[0], G = (g == null ? void 0 : g.guide.type) === "l", D = (g == null ? void 0 : g.guide.type) === "x", f = (g == null ? void 0 : g.guide.type) === "r", y = (g == null ? void 0 : g.guide.type) === "t", x = (g == null ? void 0 : g.guide.type) === "b", L = (g == null ? void 0 : g.guide.type) === "y";
188
+ if (g) {
189
+ const { x: P, y: _ } = I({ guideMatched: g, canvasView: t }), M = n.offsetWidth, S = n.offsetHeight;
190
+ G ? E = P : f ? E = P - M : D ? E = P - M / 2 : y ? T = _ : x ? T = _ - S : L && (T = _ - S / 2), s.__lastSnappedGuideMatched = g;
165
191
  } else
166
- Math.abs(b) >= g && (E = Math.round((S.left + b) / g) * g, o.__lastSnappedGuideMatched = null), Math.abs(v) >= d && (x = Math.round((S.top + v) / d) * d, o.__lastSnappedGuideMatched = null);
167
- return o.addStyle({ left: `${E}px`, top: `${x}px` }, { partial: !0 }), o.__lastSnappedPosition = { left: E, top: x }, { x: E, y: x, guideMatched: o.__lastSnappedGuideMatched };
192
+ Math.abs(A) >= h && (E = Math.round((v.left + A) / h) * h, s.__lastSnappedGuideMatched = null), Math.abs(R) >= d && (T = Math.round((v.top + R) / d) * d, s.__lastSnappedGuideMatched = null);
193
+ return s.addStyle({ left: `${E}px`, top: `${T}px` }, { partial: !0 }), s.__lastSnappedPosition = { left: E, top: T }, { x: E, y: T, guideMatched: s.__lastSnappedGuideMatched };
168
194
  }
169
- function dt({
170
- snapping: t,
195
+ function pe({
196
+ snapping: e,
171
197
  props: a,
172
198
  editor: u
173
199
  }) {
174
- const { x: l, y: i } = X({ snapping: t, props: a, editor: u }), o = a.component;
175
- o.addStyle({ left: `${l}px`, top: `${i}px` }), delete o.__lastSnappedPosition, delete o.__lastSnappedGuideMatched;
200
+ const { x: c, y: l } = H({ snapping: e, props: a, editor: u }), s = a.component;
201
+ s.addStyle({ left: `${c}px`, top: `${l}px` }), delete s.__lastSnappedPosition, delete s.__lastSnappedGuideMatched;
176
202
  }
177
- const ft = "core:component-drag", rt = "studio:setDragAbsolute", pt = "dmode:start", Y = "dmode:move", K = "dmode:end", $ = "dragAbsolute", ut = "select", mt = "hover", ht = "spacing", gt = function(t, a = {}) {
178
- const { Commands: u } = t, l = u.events, i = u.getConfig().defaultOptions ?? {}, o = `${l.runBeforeCommand}tlb-move`;
179
- i[ft] = {
180
- run: (p) => ({
181
- ...p,
203
+ const fe = "core:component-drag", ue = "studio:setDragAbsolute", ge = "dmode:start", j = "dmode:move", F = "dmode:end", $ = "dragAbsolute", he = "select", ye = "hover", be = "spacing", Ee = function(e, a = {}) {
204
+ const { Commands: u } = e, c = u.events, l = u.getConfig().defaultOptions ?? {}, s = `${c.runBeforeCommand}tlb-move`;
205
+ l[fe] = {
206
+ run: (f) => ({
207
+ ...f,
182
208
  skipGuidesRender: !0
183
209
  })
184
210
  };
185
- const { snapping: s, locking: n, globalAbsolute: g = !0 } = a;
186
- g && t.setDragMode("absolute");
187
- const d = !!(s != null && s.x || s != null && s.y), c = !!(n != null && n.x || n != null && n.y), { Canvas: e } = t;
188
- let r = null;
189
- const f = (p) => {
190
- const { component: h, guidesMatched: _, command: C } = p, N = h.view, P = t.Canvas.getCanvasView(), A = h.getEl();
191
- let D = _.map((O) => O.matched.componentEl), T = _.map((O) => B({ guideMatched: O, canvasView: P }));
211
+ const { snapping: n, locking: t, globalAbsolute: h = !0 } = a;
212
+ h && e.setDragMode("absolute");
213
+ const d = !!(n != null && n.x || n != null && n.y), i = !!(t != null && t.x || t != null && t.y), { Canvas: o } = e;
214
+ let p = null;
215
+ const r = (f) => {
216
+ const { component: y, guidesMatched: x, command: L } = f, B = y.view, w = e.Canvas.getCanvasView(), P = y.getEl();
217
+ let _ = x.map((O) => O.matched.componentEl), M = x.map((O) => I({ guideMatched: O, canvasView: w }));
192
218
  if (d) {
193
- const { guideMatched: O } = X({ snapping: s, props: p, editor: t });
194
- O ? (D = [O.matched.componentEl], T = [B({ guideMatched: O, canvasView: P })]) : (D = [], T = []);
219
+ const { guideMatched: O } = H({ snapping: n, props: f, editor: e });
220
+ O ? (_ = [O.matched.componentEl], M = [I({ guideMatched: O, canvasView: w })]) : (_ = [], M = []);
195
221
  }
196
- if (c)
197
- if (C.opts.event.shiftKey)
198
- if (!r)
199
- r = _[0];
222
+ if (i)
223
+ if (L.opts.event.shiftKey)
224
+ if (!p)
225
+ p = x[0];
200
226
  else {
201
- const R = r, I = R.guide.x === void 0 ? "x" : "y";
202
- (I === "x" && (n == null ? void 0 : n.x) || I === "y" && (n == null ? void 0 : n.y)) && (lt({ guideMatched: R, component: h, canvasView: P }), D = [R.matched.componentEl], T = [B({ guideMatched: R, canvasView: P })]);
227
+ const N = p, Y = N.guide.x === void 0 ? "x" : "y";
228
+ (Y === "x" && (t == null ? void 0 : t.x) || Y === "y" && (t == null ? void 0 : t.y)) && (de({ guideMatched: N, component: y, canvasView: w }), _ = [N.matched.componentEl], M = [I({ guideMatched: N, canvasView: w })]);
203
229
  }
204
230
  else
205
- r = null;
206
- const L = {
231
+ p = null;
232
+ const S = {
207
233
  id: $,
208
234
  type: $,
209
- component: h,
210
- componentView: N,
211
- originComponent: A,
212
- matchedComponents: D,
213
- originMatchedDistances: T
235
+ component: y,
236
+ componentView: B,
237
+ originComponent: P,
238
+ matchedComponents: _,
239
+ originMatchedDistances: M
214
240
  };
215
- e.addSpot(L);
216
- }, y = ({ enabled: p }) => {
217
- t.runCommand(rt, { enabled: p });
218
- }, S = ({ type: p }) => {
219
- e.removeSpots({ type: p });
220
- }, b = () => {
221
- S({ type: ut }), S({ type: mt }), S({ type: ht });
222
- }, v = (p) => {
223
- y({ enabled: !0 }), f(p), b();
224
- }, E = (p) => {
225
- f(p), b();
226
- }, x = (p) => {
227
- S({ type: $ }), d && dt({ snapping: s, props: p, editor: t }), y({ enabled: !1 });
228
- }, M = [
229
- [pt, (p) => {
230
- v(p), t.on(Y, E);
231
- const h = () => {
232
- x(p), t.off(Y, E), t.off(K, h);
241
+ o.addSpot(S);
242
+ }, b = ({ enabled: f }) => {
243
+ e.runCommand(ue, { enabled: f });
244
+ }, v = ({ type: f }) => {
245
+ o.removeSpots({ type: f });
246
+ }, A = () => {
247
+ v({ type: he }), v({ type: ye }), v({ type: be });
248
+ }, R = (f) => {
249
+ b({ enabled: !0 }), r(f), A();
250
+ }, E = (f) => {
251
+ r(f), A();
252
+ }, T = (f) => {
253
+ v({ type: $ }), d && pe({ snapping: n, props: f, editor: e }), b({ enabled: !1 });
254
+ }, D = [
255
+ [ge, (f) => {
256
+ R(f), e.on(j, E);
257
+ const y = () => {
258
+ T(f), e.off(j, E), e.off(F, y);
233
259
  };
234
- t.on(K, h);
260
+ e.on(F, y);
235
261
  }],
236
- [o, (p) => {
237
- if (g) return;
238
- const h = p.options.target, _ = at(t, h, a);
239
- _ != null && _.result && !_.dmode && (p.options.mode = "absolute");
262
+ [s, (f) => {
263
+ if (h) return;
264
+ const y = f.options.target, x = re(e, y, a);
265
+ x != null && x.result && !x.dmode && (f.options.mode = "absolute");
240
266
  }]
241
267
  ];
242
- M.forEach(([p, h]) => t.on(p, h)), ot({
243
- editor: t,
268
+ D.forEach(([f, y]) => e.on(f, y)), ne({
269
+ editor: e,
244
270
  licenseKey: a.licenseKey,
245
- plan: ct,
246
- pluginName: it,
271
+ plan: ce,
272
+ pluginName: le,
247
273
  cleanup: () => {
248
- y({ enabled: !1 }), M.forEach(([p, h]) => t.off(p, h));
274
+ b({ enabled: !1 }), D.forEach(([f, y]) => e.off(f, y));
249
275
  }
250
276
  });
251
- }, Et = nt(gt);
277
+ }, ve = se(Ee);
252
278
  export {
253
- Et as default
279
+ ve as default
254
280
  };
@@ -1 +1 @@
1
- (function(C,N){typeof exports=="object"&&typeof module<"u"?module.exports=N():typeof define=="function"&&define.amd?define(N):(C=typeof globalThis<"u"?globalThis:C||self,C.StudioSdkPlugins_canvasAbsoluteMode=N())})(this,function(){"use strict";const C="app.grapesjs.com",N="app-stage.grapesjs.com",W=[C,"app2.grapesjs.com",N,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],X="license:check:start",F="license:check:end",q=()=>typeof window<"u",J=({isDev:t,isStage:a,isPlatform:u})=>`${t?"":`https://${a?N:C}`}/${u?"platform-api":"api"}`,k=()=>{const t=q()&&window.location.hostname;return!!t&&(W.includes(t)||W.some(a=>t.endsWith(a)))};function z(t){return typeof t=="function"}async function Q({path:t,baseApiUrl:a,method:u="GET",headers:l={},params:i,body:o}){const n=`${a||J({isDev:!1,isStage:!1})}${t}`,g={method:u,headers:{"Content-Type":"application/json",...l}};o&&(g.body=JSON.stringify(o));const d=i?new URLSearchParams(i).toString():"",c=d?`?${d}`:"",e=await fetch(`${n}${c}`,g);if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.json()}var G=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(G||{});const Y={[G.free]:0,[G.startup]:10,[G.business]:20,[G.enterprise]:30};function Z(t){const a=t;return a.init=u=>l=>t(l,u),a}const tt=t=>Z(t);async function et({editor:t,plan:a,pluginName:u,licenseKey:l,onLicenseCheckResponse:i,cleanup:o}){let s="",n=!1;const g=k(),d=e=>{console.warn("Cleanup plugin:",u,"Reason:",e),o()},c=(e={})=>{var b;const{error:r,sdkLicense:f}=e,y=(b=e.plan)==null?void 0:b.category;if(!(f||e.license)||r)d(r||"Invalid license");else if(y){const v=Y[a],E=Y[y];v>E&&d({pluginRequiredPlan:a,licensePlan:y})}};t.on(X,e=>{s=e==null?void 0:e.baseApiUrl,n=!0}),t.on(F,e=>{i==null||i(e),c(e)}),setTimeout(async()=>{if(!n){if(g)return;if(l){const e=await nt({licenseKey:l,pluginName:u,baseApiUrl:s});i==null||i(e),e&&c(e)}else d("The `licenseKey` option not provided")}},2e3)}async function nt(t){const{licenseKey:a,pluginName:u,baseApiUrl:l}=t;try{return(await Q({baseApiUrl:l,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:u}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const ot="canvasAbsoluteMode",st=G.startup,it=(t,a,u)=>{var d,c;const l=u.enableAbsolute??(e=>e.hasAbsolute),o=(Array.isArray(a)?a:a?[a]:[...t.getSelectedAll()])[0],s=((c=(d=o==null?void 0:o.delegate)==null?void 0:d.move)==null?void 0:c.call(d,o))||o;if(!s)return;const n=s.getEl();return{result:z(l)?l({component:s,hasAbsolute:!!n&&getComputedStyle(n).position==="absolute"}):!1,component:s,dmode:s.get("dmode")}};function L({guideMatched:t,canvasView:a}){var R;const u=t.guide.x===void 0?"y":"x";let l=0,i=0,o=0,s=0;const{guide:n,matched:g}=t,d=a.getElBoxRect(n.componentView.el),c=a.getElBoxRect(((R=g.componentView)==null?void 0:R.el)||g.componentEl),e=d.y,r=d.y+d.height,f=d.x,y=d.x+d.width,S=c.y,b=c.y+c.height,v=c.x,E=c.x+c.width,x=Math.max(0,e-b),m=Math.max(0,S-r),w=Math.max(0,f-E),M=Math.max(0,v-y),p=x>m,h=w>M,_=n.type;return u==="x"&&(_==="l"?(l=f,p?(i=b,o=x):(i=r,o=m)):_==="r"?(l=y,p?(i=b,o=x):(i=r,o=m)):_==="x"&&(l=f-(f-y)/2,p?(i=b,o=x):(i=r,o=m))),u==="y"&&(_==="t"?(i=e,h?(l=E,s=w):(l=y,s=M)):_==="b"?(i=r,h?(l=E,s=w):(l=y,s=M)):_==="y"&&(i=e-(e-r)/2,h?(l=E,s=w):(l=y,s=M))),{axis:u,x:l,y:i,width:s,height:o}}function ct({guideMatched:t,component:a,canvasView:u}){const l=t.guide.x===void 0?"x":"y",{guide:i,matched:o}=t,s=i.type,n=o.type,g=u.getElementPos(i.componentView.el).rect,d=u.getElementPos(o.componentView.el).rect;if(l==="x"){const c=g.height,e=d.top,r=d.top+d.height;let f=0;s==="t"?n==="t"?f=e-c:n==="b"?f=r-c:n==="y"&&(f=e-c-(e-r)/2):s==="b"?n==="t"?f=e-c*2:n==="b"?f=r-c*2:n==="y"&&(f=e-c*2-(e-r)/2):s==="y"&&(n==="t"?f=e-c*1.5:n==="b"?f=r-c*1.5:n==="y"&&(f=e-c*1.5-(e-r)/2)),a.addStyle({top:`${f-5}px`},{partial:!0})}if(l==="y"){const c=g.width,e=d.left,r=d.left+d.width;let f=0;s==="l"?n==="l"?f=e:n==="r"?f=r:n==="x"&&(f=e-(e-r)/2):s==="r"?n==="l"?f=e-c:n==="r"?f=r-c:n==="x"&&(f=e-c-(e-r)/2):s==="x"&&(n==="l"?f=e-c/2:n==="r"&&(f=r-c/2)),a.addStyle({left:`${f}px`},{partial:!0})}}function K({snapping:t,editor:a,props:u}){var B,P;const{command:l,guidesMatched:i}=u,o=u.component,s=o.getEl(),n=a.Canvas.getCanvasView(),{x:g,y:d}=t??{x:10,y:10},c=l.opts.event,e=c.clientX,r=c.clientY;if(!o.__lastSnappedPosition){const A=n.getElBoxRect(s),D=e-A.x,T=r-A.y;o.__lastSnappedPosition={left:A.x,top:A.y},o.__dragOffset={x:D,y:T}}const f=((B=o.__dragOffset)==null?void 0:B.x)||0,y=((P=o.__dragOffset)==null?void 0:P.y)||0,S=o.__lastSnappedPosition,b=e-S.left-f,v=r-S.top-y;let E=S.left,x=S.top;const m=i==null?void 0:i[0],w=(m==null?void 0:m.guide.type)==="l",M=(m==null?void 0:m.guide.type)==="x",p=(m==null?void 0:m.guide.type)==="r",h=(m==null?void 0:m.guide.type)==="t",_=(m==null?void 0:m.guide.type)==="b",R=(m==null?void 0:m.guide.type)==="y";if(m){const{x:A,y:D}=L({guideMatched:m,canvasView:n}),T=s.offsetWidth,I=s.offsetHeight;w?E=A:p?E=A-T:M?E=A-T/2:h?x=D:_?x=D-I:R&&(x=D-I/2),o.__lastSnappedGuideMatched=m}else Math.abs(b)>=g&&(E=Math.round((S.left+b)/g)*g,o.__lastSnappedGuideMatched=null),Math.abs(v)>=d&&(x=Math.round((S.top+v)/d)*d,o.__lastSnappedGuideMatched=null);return o.addStyle({left:`${E}px`,top:`${x}px`},{partial:!0}),o.__lastSnappedPosition={left:E,top:x},{x:E,y:x,guideMatched:o.__lastSnappedGuideMatched}}function at({snapping:t,props:a,editor:u}){const{x:l,y:i}=K({snapping:t,props:a,editor:u}),o=a.component;o.addStyle({left:`${l}px`,top:`${i}px`}),delete o.__lastSnappedPosition,delete o.__lastSnappedGuideMatched}const lt="core:component-drag",dt="studio:setDragAbsolute",ft="dmode:start",V="dmode:move",j="dmode:end",U="dragAbsolute",rt="select",pt="hover",ut="spacing";return tt(function(t,a={}){const{Commands:u}=t,l=u.events,i=u.getConfig().defaultOptions??{},o=`${l.runBeforeCommand}tlb-move`;i[lt]={run:p=>({...p,skipGuidesRender:!0})};const{snapping:s,locking:n,globalAbsolute:g=!0}=a;g&&t.setDragMode("absolute");const d=!!(s!=null&&s.x||s!=null&&s.y),c=!!(n!=null&&n.x||n!=null&&n.y),{Canvas:e}=t;let r=null;const f=p=>{const{component:h,guidesMatched:_,command:R}=p,B=h.view,P=t.Canvas.getCanvasView(),A=h.getEl();let D=_.map(O=>O.matched.componentEl),T=_.map(O=>L({guideMatched:O,canvasView:P}));if(d){const{guideMatched:O}=K({snapping:s,props:p,editor:t});O?(D=[O.matched.componentEl],T=[L({guideMatched:O,canvasView:P})]):(D=[],T=[])}if(c)if(R.opts.event.shiftKey)if(!r)r=_[0];else{const $=r,H=$.guide.x===void 0?"x":"y";(H==="x"&&(n==null?void 0:n.x)||H==="y"&&(n==null?void 0:n.y))&&(ct({guideMatched:$,component:h,canvasView:P}),D=[$.matched.componentEl],T=[L({guideMatched:$,canvasView:P})])}else r=null;const I={id:U,type:U,component:h,componentView:B,originComponent:A,matchedComponents:D,originMatchedDistances:T};e.addSpot(I)},y=({enabled:p})=>{t.runCommand(dt,{enabled:p})},S=({type:p})=>{e.removeSpots({type:p})},b=()=>{S({type:rt}),S({type:pt}),S({type:ut})},v=p=>{y({enabled:!0}),f(p),b()},E=p=>{f(p),b()},x=p=>{S({type:U}),d&&at({snapping:s,props:p,editor:t}),y({enabled:!1})},M=[[ft,p=>{v(p),t.on(V,E);const h=()=>{x(p),t.off(V,E),t.off(j,h)};t.on(j,h)}],[o,p=>{if(g)return;const h=p.options.target,_=it(t,h,a);_!=null&&_.result&&!_.dmode&&(p.options.mode="absolute")}]];M.forEach(([p,h])=>t.on(p,h)),et({editor:t,licenseKey:a.licenseKey,plan:st,pluginName:ot,cleanup:()=>{y({enabled:!1}),M.forEach(([p,h])=>t.off(p,h))}})})});
1
+ (function(L,m){typeof exports=="object"&&typeof module<"u"?module.exports=m():typeof define=="function"&&define.amd?define(m):(L=typeof globalThis<"u"?globalThis:L||self,L.StudioSdkPlugins_canvasAbsoluteMode=m())})(this,function(){"use strict";const L="app.grapesjs.com",m="app-stage.grapesjs.com",j=[L,"app2.grapesjs.com",m,"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"],X="license:check:end",q=()=>typeof window<"u",J=({isDev:e,isStage:a,isPlatform:u})=>`${e?"":`https://${a?m:L}`}/${u?"platform-api":"api"}`,z=()=>{if(!q())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},Q=()=>{const e=z();return!!e&&(j.includes(e)||j.some(a=>e.endsWith(a)))};function Z(e){return typeof e=="function"}async function C({path:e,baseApiUrl:a,method:u="GET",headers:c={},params:l,body:s}){const t=`${a||J({isDev:!1,isStage:!1})}${e}`,h={method:u,headers:{"Content-Type":"application/json",...c}};s&&(h.body=JSON.stringify(s));const d=l?new URLSearchParams(l).toString():"",i=d?`?${d}`:"",o=await fetch(`${t}${i}`,h);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}var S=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(S||{}),Y=(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))(Y||{});const V={[S.free]:0,[S.startup]:10,[S.business]:20,[S.enterprise]:30};function ee(e){const a=e;return a.init=u=>c=>e(c,u),a}const te=e=>ee(e);async function oe({editor:e,plan:a,pluginName:u,licenseKey:c,onLicenseCheckResponse:l,cleanup:s}){let n="",t;const h=o=>{console.warn("Cleanup plugin:",u,"Reason:",o),s()},d=(o={})=>{var T;const{error:p,sdkLicense:r}=o,b=(T=o.plan)==null?void 0:T.category;if(!(r||o.license)||p)h(p||"Invalid license");else if(b){const R=V[a],E=V[b];R>E&&h({pluginRequiredPlan:a,licensePlan:b})}};e.Commands.has(Y.settings)&&(t=e.runCommand(Y.settings),n=(t==null?void 0:t.baseUrl)||"");const i=o=>{l==null||l(o),o&&d(o)};if(!t){e.onReady(async()=>{if(!Q())if(c){const o=await ne({licenseKey:c,pluginName:u,baseApiUrl:n});i(o)}else h("The `licenseKey` option not provided")});return}if(t.licensePlan||t.licenseError){const o=se(t);i(o);return}e.on(X,o=>i(o))}const se=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function ne(e){const{licenseKey:a,pluginName:u,baseApiUrl:c}=e;try{return(await C({baseApiUrl:c,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:u}})).result||{}}catch(l){return console.error("Error during SDK license check:",l),!1}}const ie="canvasAbsoluteMode",ae=S.startup,le=(e,a,u)=>{var d,i;const c=u.enableAbsolute??(o=>o.hasAbsolute),s=(Array.isArray(a)?a:a?[a]:[...e.getSelectedAll()])[0],n=((i=(d=s==null?void 0:s.delegate)==null?void 0:d.move)==null?void 0:i.call(d,s))||s;if(!n)return;const t=n.getEl();return{result:Z(c)?c({component:n,hasAbsolute:!!t&&getComputedStyle(t).position==="absolute"}):!1,component:n,dmode:n.get("dmode")}};function N({guideMatched:e,canvasView:a}){var B;const u=e.guide.x===void 0?"y":"x";let c=0,l=0,s=0,n=0;const{guide:t,matched:h}=e,d=a.getElBoxRect(t.componentView.el),i=a.getElBoxRect(((B=h.componentView)==null?void 0:B.el)||h.componentEl),o=d.y,p=d.y+d.height,r=d.x,b=d.x+d.width,v=i.y,T=i.y+i.height,R=i.x,E=i.x+i.width,A=Math.max(0,o-T),g=Math.max(0,v-p),G=Math.max(0,r-E),D=Math.max(0,R-b),f=A>g,y=G>D,x=t.type;return u==="x"&&(x==="l"?(c=r,f?(l=T,s=A):(l=p,s=g)):x==="r"?(c=b,f?(l=T,s=A):(l=p,s=g)):x==="x"&&(c=r-(r-b)/2,f?(l=T,s=A):(l=p,s=g))),u==="y"&&(x==="t"?(l=o,y?(c=E,n=G):(c=b,n=D)):x==="b"?(l=p,y?(c=E,n=G):(c=b,n=D)):x==="y"&&(l=o-(o-p)/2,y?(c=E,n=G):(c=b,n=D))),{axis:u,x:c,y:l,width:n,height:s}}function ce({guideMatched:e,component:a,canvasView:u}){const c=e.guide.x===void 0?"x":"y",{guide:l,matched:s}=e,n=l.type,t=s.type,h=u.getElementPos(l.componentView.el).rect,d=u.getElementPos(s.componentView.el).rect;if(c==="x"){const i=h.height,o=d.top,p=d.top+d.height;let r=0;n==="t"?t==="t"?r=o-i:t==="b"?r=p-i:t==="y"&&(r=o-i-(o-p)/2):n==="b"?t==="t"?r=o-i*2:t==="b"?r=p-i*2:t==="y"&&(r=o-i*2-(o-p)/2):n==="y"&&(t==="t"?r=o-i*1.5:t==="b"?r=p-i*1.5:t==="y"&&(r=o-i*1.5-(o-p)/2)),a.addStyle({top:`${r-5}px`},{partial:!0})}if(c==="y"){const i=h.width,o=d.left,p=d.left+d.width;let r=0;n==="l"?t==="l"?r=o:t==="r"?r=p:t==="x"&&(r=o-(o-p)/2):n==="r"?t==="l"?r=o-i:t==="r"?r=p-i:t==="x"&&(r=o-i-(o-p)/2):n==="x"&&(t==="l"?r=o-i/2:t==="r"&&(r=p-i/2)),a.addStyle({left:`${r}px`},{partial:!0})}}function k({snapping:e,editor:a,props:u}){var I,w;const{command:c,guidesMatched:l}=u,s=u.component,n=s.getEl(),t=a.Canvas.getCanvasView(),{x:h,y:d}=e??{x:10,y:10},i=c.opts.event,o=i.clientX,p=i.clientY;if(!s.__lastSnappedPosition){const _=t.getElBoxRect(n),P=o-_.x,M=p-_.y;s.__lastSnappedPosition={left:_.x,top:_.y},s.__dragOffset={x:P,y:M}}const r=((I=s.__dragOffset)==null?void 0:I.x)||0,b=((w=s.__dragOffset)==null?void 0:w.y)||0,v=s.__lastSnappedPosition,T=o-v.left-r,R=p-v.top-b;let E=v.left,A=v.top;const g=l==null?void 0:l[0],G=(g==null?void 0:g.guide.type)==="l",D=(g==null?void 0:g.guide.type)==="x",f=(g==null?void 0:g.guide.type)==="r",y=(g==null?void 0:g.guide.type)==="t",x=(g==null?void 0:g.guide.type)==="b",B=(g==null?void 0:g.guide.type)==="y";if(g){const{x:_,y:P}=N({guideMatched:g,canvasView:t}),M=n.offsetWidth,$=n.offsetHeight;G?E=_:f?E=_-M:D?E=_-M/2:y?A=P:x?A=P-$:B&&(A=P-$/2),s.__lastSnappedGuideMatched=g}else Math.abs(T)>=h&&(E=Math.round((v.left+T)/h)*h,s.__lastSnappedGuideMatched=null),Math.abs(R)>=d&&(A=Math.round((v.top+R)/d)*d,s.__lastSnappedGuideMatched=null);return s.addStyle({left:`${E}px`,top:`${A}px`},{partial:!0}),s.__lastSnappedPosition={left:E,top:A},{x:E,y:A,guideMatched:s.__lastSnappedGuideMatched}}function re({snapping:e,props:a,editor:u}){const{x:c,y:l}=k({snapping:e,props:a,editor:u}),s=a.component;s.addStyle({left:`${c}px`,top:`${l}px`}),delete s.__lastSnappedPosition,delete s.__lastSnappedGuideMatched}const de="core:component-drag",pe="studio:setDragAbsolute",fe="dmode:start",F="dmode:move",K="dmode:end",W="dragAbsolute",ue="select",ge="hover",he="spacing";return te(function(e,a={}){const{Commands:u}=e,c=u.events,l=u.getConfig().defaultOptions??{},s=`${c.runBeforeCommand}tlb-move`;l[de]={run:f=>({...f,skipGuidesRender:!0})};const{snapping:n,locking:t,globalAbsolute:h=!0}=a;h&&e.setDragMode("absolute");const d=!!(n!=null&&n.x||n!=null&&n.y),i=!!(t!=null&&t.x||t!=null&&t.y),{Canvas:o}=e;let p=null;const r=f=>{const{component:y,guidesMatched:x,command:B}=f,I=y.view,w=e.Canvas.getCanvasView(),_=y.getEl();let P=x.map(O=>O.matched.componentEl),M=x.map(O=>N({guideMatched:O,canvasView:w}));if(d){const{guideMatched:O}=k({snapping:n,props:f,editor:e});O?(P=[O.matched.componentEl],M=[N({guideMatched:O,canvasView:w})]):(P=[],M=[])}if(i)if(B.opts.event.shiftKey)if(!p)p=x[0];else{const U=p,H=U.guide.x===void 0?"x":"y";(H==="x"&&(t==null?void 0:t.x)||H==="y"&&(t==null?void 0:t.y))&&(ce({guideMatched:U,component:y,canvasView:w}),P=[U.matched.componentEl],M=[N({guideMatched:U,canvasView:w})])}else p=null;const $={id:W,type:W,component:y,componentView:I,originComponent:_,matchedComponents:P,originMatchedDistances:M};o.addSpot($)},b=({enabled:f})=>{e.runCommand(pe,{enabled:f})},v=({type:f})=>{o.removeSpots({type:f})},T=()=>{v({type:ue}),v({type:ge}),v({type:he})},R=f=>{b({enabled:!0}),r(f),T()},E=f=>{r(f),T()},A=f=>{v({type:W}),d&&re({snapping:n,props:f,editor:e}),b({enabled:!1})},D=[[fe,f=>{R(f),e.on(F,E);const y=()=>{A(f),e.off(F,E),e.off(K,y)};e.on(K,y)}],[s,f=>{if(h)return;const y=f.options.target,x=le(e,y,a);x!=null&&x.result&&!x.dmode&&(f.options.mode="absolute")}]];D.forEach(([f,y])=>e.on(f,y)),oe({editor:e,licenseKey:a.licenseKey,plan:ae,pluginName:ie,cleanup:()=>{b({enabled:!1}),D.forEach(([f,y])=>e.off(f,y))}})})});
@@ -1 +1 @@
1
- "use strict";const W="app.grapesjs.com",D="app-stage.grapesjs.com",P="app2.grapesjs.com",$="app-stage2.grapesjs.com",U=[W,P,D,$,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],_="license:check:start",L="license:check:end",O=()=>typeof window<"u",j=({isDev:t,isStage:a,isPlatform:o})=>`${t?"":`https://${a?D:W}`}/${o?"platform-api":"api"}`,K=()=>{const t=O()&&window.location.hostname;return!!t&&(U.includes(t)||U.some(a=>t.endsWith(a)))};function G(t){return typeof t=="function"}async function k({path:t,baseApiUrl:a,method:o="GET",headers:i={},params:s,body:f}){const d=`${a||j({isDev:!1,isStage:!1})}${t}`,g={method:o,headers:{"Content-Type":"application/json",...i}};f&&(g.body=JSON.stringify(f));const l=s?new URLSearchParams(s).toString():"",h=l?`?${l}`:"",n=await fetch(`${d}${h}`,g);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return n.json()}var w=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(w||{});const M={[w.free]:0,[w.startup]:10,[w.business]:20,[w.enterprise]:30};function x(t){const a=t;return a.init=o=>i=>t(i,o),a}const F=t=>x(t);async function H({editor:t,plan:a,pluginName:o,licenseKey:i,onLicenseCheckResponse:s,cleanup:f}){let p="",d=!1;const g=K(),l=n=>{console.warn("Cleanup plugin:",o,"Reason:",n),f()},h=(n={})=>{var T;const{error:E,sdkLicense:S}=n,y=(T=n.plan)==null?void 0:T.category;if(!(S||n.license)||E)l(E||"Invalid license");else if(y){const b=M[a],A=M[y];b>A&&l({pluginRequiredPlan:a,licensePlan:y})}};t.on(_,n=>{p=n==null?void 0:n.baseApiUrl,d=!0}),t.on(L,n=>{s==null||s(n),h(n)}),setTimeout(async()=>{if(!d){if(g)return;if(i){const n=await q({licenseKey:i,pluginName:o,baseApiUrl:p});s==null||s(n),n&&h(n)}else l("The `licenseKey` option not provided")}},2e3)}async function q(t){const{licenseKey:a,pluginName:o,baseApiUrl:i}=t;try{return(await k({baseApiUrl:i,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}const B="canvasEmptyState",J=w.startup,z=function(t,a={}){const o=new WeakMap,i=new WeakMap,s=new WeakMap,f=new Set,p=new WeakMap,d={emptyStates:[],...a},g=(e,c)=>{let m=!1;const{isValid:u}=c;return Array.isArray(u)?m=u.some(r=>e.is(r)):G(u)?m=u({component:e,editor:t}):m=e.is(u),m},l=e=>{const c=o.get(e);o.delete(e),c==null||c()},h=e=>{e.views.forEach(c=>l(c)),s.delete(e)},n=e=>{if(!(!e||f.has(e)))try{f.add(e);const c=e.components().length>0,m=s.get(e);if(c&&m)h(e);else if(!c&&!m){const u=p.has(e)?p.get(e):d.emptyStates.find(r=>g(e,r));if(p.set(e,u),!u)return;e.views.forEach(r=>{const I=u.render({editor:t,component:e,componentView:r,mount:v=>{i.set(r,v),s.set(e,!0);const N=r.getChildrenContainer();N==null||N.appendChild(v)},unmount:()=>l(r)});o.set(r,()=>{I==null||I();const v=i.get(r);v==null||v.remove()})})}}finally{f.delete(e)}},E=e=>{s.has(e)&&h(e)},S=({model:e})=>{n(e.getComponent())},y=t.Components.events,C=`${y.update}:components`,T="component:mount",b=t.Canvas.events.frameLoadBody,A=y.removed;t.on(C,n),t.on(T,n),t.on(A,E),t.on(b,S),H({editor:t,licenseKey:d.licenseKey,plan:J,pluginName:B,cleanup:()=>{t.off(C,n),t.off(T,n),t.off(A,E),t.off(b,S)}})},Q=F(z);module.exports=Q;
1
+ "use strict";const x="app.grapesjs.com",O="app-stage.grapesjs.com",k="app2.grapesjs.com",B="app-stage2.grapesjs.com",I=[x,k,O,B,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],N="license:check:end",W=()=>typeof window<"u",$=({isDev:e,isStage:o,isPlatform:a})=>`${e?"":`https://${o?O:x}`}/${a?"platform-api":"api"}`,j=()=>{if(!W())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},F=()=>{const e=j();return!!e&&(I.includes(e)||I.some(o=>e.endsWith(o)))};function _(e){return typeof e=="function"}async function K({path:e,baseApiUrl:o,method:a="GET",headers:i={},params:n,body:g}){const r=`${o||$({isDev:!1,isStage:!1})}${e}`,p={method:a,headers:{"Content-Type":"application/json",...i}};g&&(p.body=JSON.stringify(g));const y=n?new URLSearchParams(n).toString():"",f=y?`?${y}`:"",s=await fetch(`${r}${f}`,p);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return s.json()}var P=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(P||{}),M=(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))(M||{});const U={[P.free]:0,[P.startup]:10,[P.business]:20,[P.enterprise]:30};function H(e){const o=e;return o.init=a=>i=>e(i,a),o}const q=e=>H(e);async function J({editor:e,plan:o,pluginName:a,licenseKey:i,onLicenseCheckResponse:n,cleanup:g}){let d="",r;const p=s=>{console.warn("Cleanup plugin:",a,"Reason:",s),g()},y=(s={})=>{var A;const{error:T,sdkLicense:R}=s,h=(A=s.plan)==null?void 0:A.category;if(!(R||s.license)||T)p(T||"Invalid license");else if(h){const w=U[o],E=U[h];w>E&&p({pluginRequiredPlan:o,licensePlan:h})}};e.Commands.has(M.settings)&&(r=e.runCommand(M.settings),d=(r==null?void 0:r.baseUrl)||"");const f=s=>{n==null||n(s),s&&y(s)};if(!r){e.onReady(async()=>{if(!F())if(i){const s=await Q({licenseKey:i,pluginName:a,baseApiUrl:d});f(s)}else p("The `licenseKey` option not provided")});return}if(r.licensePlan||r.licenseError){const s=z(r);f(s);return}e.on(N,s=>f(s))}const z=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function Q(e){const{licenseKey:o,pluginName:a,baseApiUrl:i}=e;try{return(await K({baseApiUrl:i,path:`/sdk/${o||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const X="canvasEmptyState",Y=P.startup,Z=function(e,o={}){const a=new WeakMap,i=new WeakMap,n=new WeakMap,g=new Set,d=new WeakMap,r={emptyStates:[],...o},p=(t,l)=>{let b=!1;const{isValid:u}=l;return Array.isArray(u)?b=u.some(c=>t.is(c)):_(u)?b=u({component:t,editor:e}):b=t.is(u),b},y=t=>{const l=a.get(t);a.delete(t),l==null||l()},f=t=>{t.views.forEach(l=>y(l)),n.delete(t)},s=t=>{if(!(!t||g.has(t)))try{g.add(t);const l=t.components().length>0,b=n.get(t);if(l&&b)f(t);else if(!l&&!b){const u=d.has(t)?d.get(t):r.emptyStates.find(c=>p(t,c));if(d.set(t,u),!u)return;t.views.forEach(c=>{const D=u.render({editor:e,component:t,componentView:c,mount:v=>{i.set(c,v),n.set(t,!0);const G=c.getChildrenContainer();G==null||G.appendChild(v)},unmount:()=>y(c)});a.set(c,()=>{D==null||D();const v=i.get(c);v==null||v.remove()})})}}finally{g.delete(t)}},T=t=>{n.has(t)&&f(t)},R=({model:t})=>{s(t.getComponent())},h=e.Components.events,L=`${h.update}:components`,A="component:mount",w=e.Canvas.events.frameLoadBody,E=h.removed;e.on(L,s),e.on(A,s),e.on(E,T),e.on(w,R),J({editor:e,licenseKey:r.licenseKey,plan:Y,pluginName:X,cleanup:()=>{e.off(L,s),e.off(A,s),e.off(E,T),e.off(w,R)}})},V=q(Z);module.exports=V;