@grapesjs/studio-sdk-plugins 1.0.38 → 1.0.39-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 (158) hide show
  1. package/dist/accordionComponent/index.cjs.js +5 -5
  2. package/dist/accordionComponent/index.es.js +70 -67
  3. package/dist/accordionComponent/index.js +39 -0
  4. package/dist/accordionComponent/index.umd.js +4 -4
  5. package/dist/aiChat/components/AiChatHeader.d.ts +4 -5
  6. package/dist/aiChat/components/AiChatInput/index.d.ts +4 -5
  7. package/dist/aiChat/components/AiChatMessage.d.ts +7 -8
  8. package/dist/aiChat/components/index.d.ts +1 -1
  9. package/dist/aiChat/components/utils.d.ts +1 -1
  10. package/dist/aiChat/index.cjs.js +10 -376
  11. package/dist/aiChat/index.es.js +4569 -28851
  12. package/dist/aiChat/index.js +10 -376
  13. package/dist/aiChat/index.umd.js +11 -377
  14. package/dist/aiChat/server/index.cjs.d.ts +0 -1
  15. package/dist/aiChat/server/index.cjs.js +45 -45
  16. package/dist/aiChat/server/index.d.ts +0 -1
  17. package/dist/aiChat/server/index.es.d.ts +0 -1
  18. package/dist/aiChat/server/index.es.js +371 -427
  19. package/dist/aiChat/server/index.js +45 -45
  20. package/dist/aiChat/server/index.umd.js +41 -41
  21. package/dist/aiChat/server/stream.test.d.ts +1 -0
  22. package/dist/aiChat/types.d.ts +18 -4
  23. package/dist/aiChat/typesSchema.d.ts +13 -0
  24. package/dist/animationComponent/index.cjs.js +3 -3
  25. package/dist/animationComponent/index.es.js +49 -46
  26. package/dist/animationComponent/index.js +519 -0
  27. package/dist/animationComponent/index.umd.js +3 -3
  28. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  29. package/dist/canvasAbsoluteMode/index.es.js +115 -112
  30. package/dist/canvasAbsoluteMode/index.js +1 -0
  31. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  32. package/dist/canvasEmptyState/index.cjs.js +1 -1
  33. package/dist/canvasEmptyState/index.es.js +71 -68
  34. package/dist/canvasEmptyState/index.js +1 -0
  35. package/dist/canvasEmptyState/index.umd.js +1 -1
  36. package/dist/canvasFullSize/index.cjs.js +3 -3
  37. package/dist/canvasFullSize/index.es.js +69 -66
  38. package/dist/canvasFullSize/index.js +10 -0
  39. package/dist/canvasFullSize/index.umd.js +4 -4
  40. package/dist/canvasGridMode/index.cjs.js +7 -7
  41. package/dist/canvasGridMode/index.es.js +142 -139
  42. package/dist/canvasGridMode/index.js +26 -0
  43. package/dist/canvasGridMode/index.umd.js +7 -7
  44. package/dist/canvasScreenshot/index.cjs.js +1 -1
  45. package/dist/canvasScreenshot/index.es.js +78 -75
  46. package/dist/canvasScreenshot/index.js +1 -0
  47. package/dist/canvasScreenshot/index.umd.js +1 -1
  48. package/dist/dataSourceEjs/EjsExporter.d.ts +1 -1
  49. package/dist/dataSourceEjs/index.cjs.js +3 -3
  50. package/dist/dataSourceEjs/index.es.js +40 -37
  51. package/dist/dataSourceEjs/index.js +21 -0
  52. package/dist/dataSourceEjs/index.umd.js +3 -3
  53. package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +2 -2
  54. package/dist/dataSourceHandlebars/constants.d.ts +1 -1
  55. package/dist/dataSourceHandlebars/index.cjs.js +4 -4
  56. package/dist/dataSourceHandlebars/index.es.js +58 -55
  57. package/dist/dataSourceHandlebars/index.js +10 -0
  58. package/dist/dataSourceHandlebars/index.umd.js +2 -2
  59. package/dist/dialogComponent/index.cjs.js +11 -11
  60. package/dist/dialogComponent/index.es.js +72 -69
  61. package/dist/dialogComponent/index.js +59 -0
  62. package/dist/dialogComponent/index.umd.js +11 -11
  63. package/dist/flexComponent/index.cjs.js +6 -6
  64. package/dist/flexComponent/index.es.js +151 -142
  65. package/dist/flexComponent/index.js +33 -0
  66. package/dist/flexComponent/index.umd.js +8 -8
  67. package/dist/flexComponent/typesSchema.d.ts +1 -1
  68. package/dist/fsLightboxComponent/index.cjs.js +3 -3
  69. package/dist/fsLightboxComponent/index.es.js +93 -90
  70. package/dist/fsLightboxComponent/index.js +6 -0
  71. package/dist/fsLightboxComponent/index.umd.js +3 -3
  72. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  73. package/dist/googleFontsAssetProvider/index.es.js +112 -109
  74. package/dist/googleFontsAssetProvider/index.js +1 -0
  75. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  76. package/dist/googleFontsAssetProvider/utils.d.ts +1 -1
  77. package/dist/iconifyComponent/index.cjs.js +2 -2
  78. package/dist/iconifyComponent/index.es.js +80 -77
  79. package/dist/iconifyComponent/index.js +3 -0
  80. package/dist/iconifyComponent/index.umd.js +2 -2
  81. package/dist/index.cjs.d.ts +1 -0
  82. package/dist/index.cjs.js +970 -82
  83. package/dist/index.d.ts +1 -0
  84. package/dist/index.es.d.ts +1 -0
  85. package/dist/index.es.js +7422 -6145
  86. package/dist/index.umd.js +975 -87
  87. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  88. package/dist/layoutSidebarButtons/index.es.js +95 -92
  89. package/dist/layoutSidebarButtons/index.js +1 -0
  90. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  91. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  92. package/dist/lightGalleryComponent/index.es.js +164 -161
  93. package/dist/lightGalleryComponent/index.js +1 -0
  94. package/dist/lightGalleryComponent/index.umd.js +1 -1
  95. package/dist/lightGalleryComponent/utils.d.ts +1 -1
  96. package/dist/linkImageComponent/index.cjs.js +2 -2
  97. package/dist/linkImageComponent/index.es.js +60 -57
  98. package/dist/linkImageComponent/index.js +12 -0
  99. package/dist/linkImageComponent/index.umd.js +2 -2
  100. package/dist/listPagesComponent/index.cjs.js +4 -4
  101. package/dist/listPagesComponent/index.es.js +57 -54
  102. package/dist/listPagesComponent/index.js +11 -0
  103. package/dist/listPagesComponent/index.umd.js +4 -4
  104. package/dist/listPagesComponent/utils.d.ts +1 -1
  105. package/dist/presetBlockLibrary/blocks.d.ts +6 -0
  106. package/dist/presetBlockLibrary/blocks.test.d.ts +2 -0
  107. package/dist/presetBlockLibrary/emailBlocks.d.ts +53 -0
  108. package/dist/presetBlockLibrary/index.cjs.d.ts +3 -0
  109. package/dist/presetBlockLibrary/index.cjs.js +889 -0
  110. package/dist/presetBlockLibrary/index.d.ts +3 -0
  111. package/dist/presetBlockLibrary/index.es.d.ts +3 -0
  112. package/dist/presetBlockLibrary/index.es.js +1408 -0
  113. package/dist/presetBlockLibrary/index.js +889 -0
  114. package/dist/presetBlockLibrary/index.test.d.ts +1 -0
  115. package/dist/presetBlockLibrary/index.umd.js +889 -0
  116. package/dist/presetBlockLibrary/shared.d.ts +3 -0
  117. package/dist/presetBlockLibrary/types.d.ts +24 -0
  118. package/dist/presetBlockLibrary/typesSchema.d.ts +47 -0
  119. package/dist/presetPrintable/index.cjs.js +3 -3
  120. package/dist/presetPrintable/index.es.js +133 -130
  121. package/dist/presetPrintable/index.js +32 -0
  122. package/dist/presetPrintable/index.umd.js +4 -4
  123. package/dist/prosemirror/index.cjs.js +8 -8
  124. package/dist/prosemirror/index.es.js +552 -549
  125. package/dist/prosemirror/index.js +10 -0
  126. package/dist/prosemirror/index.umd.js +9 -9
  127. package/dist/prosemirror/toolbar.d.ts +2 -2
  128. package/dist/prosemirror/types.d.ts +5 -5
  129. package/dist/rendererReact/index.cjs.js +1 -1
  130. package/dist/rendererReact/index.es.js +137 -134
  131. package/dist/rendererReact/index.js +1 -1
  132. package/dist/rendererReact/index.umd.js +1 -1
  133. package/dist/rteTinyMce/index.cjs.js +2 -2
  134. package/dist/rteTinyMce/index.es.js +74 -71
  135. package/dist/rteTinyMce/index.js +104 -0
  136. package/dist/rteTinyMce/index.umd.js +2 -2
  137. package/dist/shapeDividerComponent/index.cjs.js +4 -4
  138. package/dist/shapeDividerComponent/index.es.js +91 -88
  139. package/dist/shapeDividerComponent/index.js +97 -0
  140. package/dist/shapeDividerComponent/index.umd.js +4 -4
  141. package/dist/swiperComponent/index.cjs.js +7 -7
  142. package/dist/swiperComponent/index.es.js +95 -92
  143. package/dist/swiperComponent/index.js +45 -0
  144. package/dist/swiperComponent/index.umd.js +5 -5
  145. package/dist/tableComponent/index.cjs.js +1 -1
  146. package/dist/tableComponent/index.es.js +181 -178
  147. package/dist/tableComponent/index.js +1 -0
  148. package/dist/tableComponent/index.umd.js +1 -1
  149. package/dist/tableComponent/types.d.ts +3 -3
  150. package/dist/types.d.ts +14 -14
  151. package/dist/utils.d.ts +3 -2
  152. package/dist/utilsDataSources.d.ts +1 -1
  153. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  154. package/dist/youtubeAssetProvider/index.es.js +90 -87
  155. package/dist/youtubeAssetProvider/index.js +1 -0
  156. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  157. package/package.json +182 -34
  158. package/dist/aiChat/server/models.d.ts +0 -15
@@ -1,11 +1,11 @@
1
1
  import { jsx as y } from "react/jsx-runtime";
2
- import { useState as O, useEffect as C, createElement as F, Fragment as D } from "react";
3
- import { createRoot as W } from "react-dom/client";
4
- const U = "app.grapesjs.com", _ = "app-stage.grapesjs.com", $ = "app2.grapesjs.com", K = "app-stage2.grapesjs.com", N = [
2
+ import { useState as O, useEffect as C, createElement as W, Fragment as D } from "react";
3
+ import { createRoot as $ } from "react-dom/client";
4
+ const U = "app.grapesjs.com", _ = "app-stage.grapesjs.com", K = "app2.grapesjs.com", V = "app-stage2.grapesjs.com", N = [
5
5
  U,
6
- $,
7
- _,
8
6
  K,
7
+ _,
8
+ V,
9
9
  "localhost",
10
10
  "127.0.0.1",
11
11
  ".local-credentialless.webcontainer.io",
@@ -18,12 +18,12 @@ const U = "app.grapesjs.com", _ = "app-stage.grapesjs.com", $ = "app2.grapesjs.c
18
18
  // For Claude mcp app
19
19
  ".web-sandbox.oaiusercontent.com"
20
20
  // For OpenAI mcp app
21
- ], V = "license:check:end", z = () => typeof window < "u", S = ({
21
+ ], z = "license:check:end", S = () => typeof window < "u", J = ({
22
22
  isDev: e,
23
23
  isStage: t,
24
24
  isPlatform: o
25
- }) => `${e ? "" : `https://${t ? _ : U}`}/${o ? "platform-api" : "api"}`, J = () => {
26
- if (!z()) return "";
25
+ }) => `${e ? "" : `https://${t ? _ : U}`}/${o ? "platform-api" : "api"}`, q = () => {
26
+ if (!S()) return "";
27
27
  const { hostname: e } = window.location;
28
28
  if (e) return e;
29
29
  try {
@@ -31,22 +31,22 @@ const U = "app.grapesjs.com", _ = "app-stage.grapesjs.com", $ = "app2.grapesjs.c
31
31
  } catch {
32
32
  return "";
33
33
  }
34
- }, q = () => {
35
- const e = J();
34
+ }, H = () => {
35
+ const e = q();
36
36
  return !!e && (N.includes(e) || N.some((t) => e.endsWith(t)));
37
- }, H = (e) => e.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (t, o) => (o ? "-" : "") + t.toLowerCase()), L = (e) => typeof e == "string";
38
- function Z(e) {
37
+ }, Z = (e) => e.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (t, o) => (o ? "-" : "") + t.toLowerCase()), L = (e) => typeof e == "string";
38
+ function Q(e) {
39
39
  return typeof e == "function";
40
40
  }
41
- async function Q({
41
+ async function X({
42
42
  path: e,
43
43
  baseApiUrl: t,
44
44
  method: o = "GET",
45
45
  headers: s = {},
46
- params: a,
46
+ params: r,
47
47
  body: n
48
48
  }) {
49
- const r = `${t || S({ isDev: !1, isStage: !1 })}${e}`, c = {
49
+ const a = `${t || J({ isDev: !1, isStage: !1 })}${e}`, c = {
50
50
  method: o,
51
51
  headers: {
52
52
  "Content-Type": "application/json",
@@ -54,34 +54,37 @@ async function Q({
54
54
  }
55
55
  };
56
56
  n && (c.body = JSON.stringify(n));
57
- const u = a ? new URLSearchParams(a).toString() : "", d = u ? `?${u}` : "", p = await fetch(`${r}${d}`, c);
57
+ const u = r ? new URLSearchParams(r).toString() : "", d = u ? `?${u}` : "", p = await fetch(`${a}${d}`, c);
58
58
  if (!p.ok)
59
59
  throw new Error(`HTTP error! status: ${p.status}`);
60
60
  return p.json();
61
61
  }
62
- var v = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(v || {}), k = /* @__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))(k || {});
62
+ var v = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(v || {}), k = /* @__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.openBlocks = "studio:openBlocks", e.appendComponent = "studio:appendComponent", 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))(k || {});
63
63
  const B = {
64
64
  [v.free]: 0,
65
65
  [v.startup]: 10,
66
66
  [v.business]: 20,
67
67
  [v.enterprise]: 30
68
68
  };
69
- function X(e) {
70
- const t = e;
71
- return t.init = (o) => (s) => e(s, o), t;
69
+ function Y(e, t) {
70
+ const o = e;
71
+ return o.init = (s) => {
72
+ const r = (n) => e(n, s);
73
+ return r.__gjsPluginId = t, r;
74
+ }, o;
72
75
  }
73
- const Y = (e) => /* @__PURE__ */ X(e);
74
- async function ee({
76
+ const ee = (e, t) => /* @__PURE__ */ Y(e, t);
77
+ async function te({
75
78
  editor: e,
76
79
  plan: t,
77
80
  pluginName: o,
78
81
  licenseKey: s,
79
- onLicenseCheckResponse: a,
82
+ onLicenseCheckResponse: r,
80
83
  cleanup: n
81
84
  }) {
82
- let i = "", r;
85
+ let i = "", a;
83
86
  const c = (p) => {
84
- console.warn("Cleanup plugin:", o, "Reason:", p), n();
87
+ console.warn("Cleanup plugin:", o, "Reason:", p), n(e, o);
85
88
  }, u = (p = {}) => {
86
89
  var w;
87
90
  const { error: g, sdkLicense: f } = p, l = (w = p.plan) == null ? void 0 : w.category;
@@ -92,38 +95,38 @@ async function ee({
92
95
  m > R && c({ pluginRequiredPlan: t, licensePlan: l });
93
96
  }
94
97
  };
95
- e.Commands.has(k.settings) && (r = e.runCommand(k.settings), i = (r == null ? void 0 : r.baseUrl) || "");
98
+ e.Commands.has(k.settings) && (a = e.runCommand(k.settings), i = (a == null ? void 0 : a.baseUrl) || "");
96
99
  const d = (p) => {
97
- a == null || a(p), p && u(p);
100
+ r == null || r(p), p && u(p);
98
101
  };
99
- if (!r) {
102
+ if (!a) {
100
103
  e.onReady(async () => {
101
- if (!q())
104
+ if (!H())
102
105
  if (s) {
103
- const p = await oe({ licenseKey: s, pluginName: o, baseApiUrl: i });
106
+ const p = await ne({ licenseKey: s, pluginName: o, baseApiUrl: i });
104
107
  d(p);
105
108
  } else
106
109
  c("The `licenseKey` option not provided");
107
110
  });
108
111
  return;
109
112
  }
110
- if (r.licensePlan || r.licenseError) {
111
- const p = te(r);
113
+ if (a.licensePlan || a.licenseError) {
114
+ const p = oe(a);
112
115
  d(p);
113
116
  return;
114
117
  }
115
- e.on(V, (p) => d(p));
118
+ e.on(z, (p) => d(p));
116
119
  }
117
- const te = (e) => ({
120
+ const oe = (e) => ({
118
121
  sdkLicense: e.license,
119
122
  license: e.license,
120
123
  error: e.licenseError,
121
124
  plan: e.licensePlan
122
125
  });
123
- async function oe(e) {
126
+ async function ne(e) {
124
127
  const { licenseKey: t, pluginName: o, baseApiUrl: s } = e;
125
128
  try {
126
- return (await Q({
129
+ return (await X({
127
130
  baseApiUrl: s,
128
131
  path: `/sdk/${t || "na"}`,
129
132
  method: "POST",
@@ -132,64 +135,64 @@ async function oe(e) {
132
135
  pn: o
133
136
  }
134
137
  })).result || {};
135
- } catch (a) {
136
- return console.error("Error during SDK license check:", a), !1;
138
+ } catch (r) {
139
+ return console.error("Error during SDK license check:", r), !1;
137
140
  }
138
141
  }
139
- function ne(e) {
142
+ function se(e) {
140
143
  const t = {};
141
144
  for (const o in e)
142
145
  if (Object.prototype.hasOwnProperty.call(e, o)) {
143
- const s = H(o);
146
+ const s = Z(o);
144
147
  t[s] = e[o];
145
148
  }
146
149
  return t;
147
150
  }
148
- const se = (e, t) => {
151
+ const re = (e, t) => {
149
152
  const o = e.components || {};
150
153
  for (const s in o) {
151
- const a = o[s];
152
- if (a.component === t)
153
- return { cmpConfig: a, type: s };
154
+ const r = o[s];
155
+ if (r.component === t)
156
+ return { cmpConfig: r, type: s };
154
157
  }
155
158
  };
156
- function G(e) {
159
+ function I(e) {
157
160
  const t = {};
158
161
  let o = !1;
159
162
  for (const s in e)
160
163
  if (Object.prototype.hasOwnProperty.call(e, s)) {
161
- const a = e[s];
162
- if (typeof a == "string" || typeof a == "number") {
164
+ const r = e[s];
165
+ if (typeof r == "string" || typeof r == "number") {
163
166
  const n = s.includes("-") ? s.replace(/-([a-z])/g, (i) => i[1].toUpperCase()) : s;
164
- t[n] = a, o = !0;
167
+ t[n] = r, o = !0;
165
168
  }
166
169
  }
167
170
  return o ? t : void 0;
168
171
  }
169
- function re(e) {
172
+ function ae(e) {
170
173
  const t = {};
171
174
  return e.split(";").forEach((o) => {
172
175
  if (!o.trim()) return;
173
176
  const s = o.indexOf(":");
174
177
  if (s > 0) {
175
- const a = o.substring(0, s).trim(), n = o.substring(s + 1).trim();
176
- if (a && n) {
177
- const i = a.replace(/-([a-z])/g, (r) => r[1].toUpperCase());
178
+ const r = o.substring(0, s).trim(), n = o.substring(s + 1).trim();
179
+ if (r && n) {
180
+ const i = r.replace(/-([a-z])/g, (a) => a[1].toUpperCase());
178
181
  t[i] = n;
179
182
  }
180
183
  }
181
184
  }), Object.keys(t).length > 0 ? t : void 0;
182
185
  }
183
- function ae(e) {
186
+ function ie(e) {
184
187
  if (e) {
185
188
  if (typeof e == "object" && !Array.isArray(e))
186
- return G(e);
189
+ return I(e);
187
190
  if (typeof e == "string") {
188
- let t = re(e);
191
+ let t = ae(e);
189
192
  if (!t)
190
193
  try {
191
194
  const o = JSON.parse(e);
192
- typeof o == "object" && o !== null && !Array.isArray(o) && (t = G(o));
195
+ typeof o == "object" && o !== null && !Array.isArray(o) && (t = I(o));
193
196
  } catch (o) {
194
197
  console.error("Failed to parse style string as JSON", o);
195
198
  }
@@ -199,34 +202,34 @@ function ae(e) {
199
202
  const t = {};
200
203
  return e.forEach((o) => {
201
204
  if (typeof o == "object" && o !== null) {
202
- const s = o.name || o.property, a = o.value;
203
- if (typeof s == "string" && s && a !== void 0 && a !== "") {
205
+ const s = o.name || o.property, r = o.value;
206
+ if (typeof s == "string" && s && r !== void 0 && r !== "") {
204
207
  const n = s.replace(/-([a-z])/g, (i) => i[1].toUpperCase());
205
- t[n] = a;
208
+ t[n] = r;
206
209
  }
207
210
  }
208
211
  }), Object.keys(t).length > 0 ? t : void 0;
209
212
  }
210
213
  }
211
214
  }
212
- function ie(e) {
213
- return I[e] ? I[e] : e.includes("-") ? e.replace(/-([a-z])/g, (t, o) => o.toUpperCase()) : e;
214
- }
215
215
  function ce(e) {
216
+ return G[e] ? G[e] : e.includes("-") ? e.replace(/-([a-z])/g, (t, o) => o.toUpperCase()) : e;
217
+ }
218
+ function le(e) {
216
219
  var o;
217
220
  const t = {};
218
- for (const [s, a] of Object.entries(e))
221
+ for (const [s, r] of Object.entries(e))
219
222
  if (s === "style")
220
- t.style = ae(a);
223
+ t.style = ie(r);
221
224
  else if (s.startsWith("data-"))
222
- t[s] = a;
225
+ t[s] = r;
223
226
  else {
224
- const n = ie(s);
225
- ((o = e.xmlns) == null ? void 0 : o.includes("svg")) || e.viewBox !== void 0 || e.d !== void 0 || pe.has(n) || n.startsWith("svg") ? t[n] = a : !le.has(n) && !n.startsWith("on") && !n.startsWith("aria-") && !n.startsWith("data-") ? t[s] = a : t[n] = a;
227
+ const n = ce(s);
228
+ ((o = e.xmlns) == null ? void 0 : o.includes("svg")) || e.viewBox !== void 0 || e.d !== void 0 || ue.has(n) || n.startsWith("svg") ? t[n] = r : !pe.has(n) && !n.startsWith("on") && !n.startsWith("aria-") && !n.startsWith("data-") ? t[s] = r : t[n] = r;
226
229
  }
227
230
  return t;
228
231
  }
229
- const le = /* @__PURE__ */ new Set([
232
+ const pe = /* @__PURE__ */ new Set([
230
233
  "className",
231
234
  "id",
232
235
  "style",
@@ -267,7 +270,7 @@ const le = /* @__PURE__ */ new Set([
267
270
  "aria-labelledby",
268
271
  "aria-describedby",
269
272
  "role"
270
- ]), pe = /* @__PURE__ */ new Set([
273
+ ]), ue = /* @__PURE__ */ new Set([
271
274
  "x",
272
275
  "y",
273
276
  "d",
@@ -310,7 +313,7 @@ const le = /* @__PURE__ */ new Set([
310
313
  "clipPath",
311
314
  "overflow",
312
315
  "pointerEvents"
313
- ]), I = {
316
+ ]), G = {
314
317
  class: "className",
315
318
  for: "htmlFor",
316
319
  "http-equiv": "httpEquiv",
@@ -328,59 +331,59 @@ const le = /* @__PURE__ */ new Set([
328
331
  "font-size": "fontSize",
329
332
  "text-anchor": "textAnchor"
330
333
  }, E = (e) => (e == null ? void 0 : e.$$typeof) && typeof e.props == "object";
331
- function ue(e) {
334
+ function fe(e) {
332
335
  return (t) => {
333
336
  const o = t.getContent();
334
337
  E(o) && t.set({
335
- content: A({ ...e, model: o }),
338
+ content: P({ ...e, model: o }),
336
339
  reactContent: o
337
340
  });
338
341
  };
339
342
  }
340
- const fe = (e) => (t) => {
343
+ const de = (e) => (t) => {
341
344
  const o = t.component;
342
- E(o) && (t.component = { components: A({ ...e, model: o }) });
345
+ E(o) && (t.component = { components: P({ ...e, model: o }) });
343
346
  };
344
- function A(e) {
347
+ function P(e) {
345
348
  const { model: t, editor: o, config: s } = e;
346
349
  if (E(t)) {
347
- const a = t, n = {}, { type: i, props: r = {} } = a, { children: c, className: u, style: d, ...p } = r, g = (l) => ({ type: "textnode", content: l }), f = typeof i == "symbol";
348
- if (Z(i)) {
349
- const l = se(s, i);
350
+ const r = t, n = {}, { type: i, props: a = {} } = r, { children: c, className: u, style: d, ...p } = a, g = (l) => ({ type: "textnode", content: l }), f = typeof i == "symbol";
351
+ if (Q(i)) {
352
+ const l = re(s, i);
350
353
  n.type = l == null ? void 0 : l.type;
351
354
  } else o.Components.getType(i) ? n.type = i : f || (n.tagName = i);
352
- if (u && (n.classes = u), d && (n.style = ne(d)), Array.isArray(c) ? n.components = c.map((l) => L(l) ? g(l) : A({ ...e, model: l })).filter(Boolean) : L(c) && (n.components = g(c)), Object.keys(p).length) {
355
+ if (u && (n.classes = u), d && (n.style = se(d)), Array.isArray(c) ? n.components = c.map((l) => L(l) ? g(l) : P({ ...e, model: l })).filter(Boolean) : L(c) && (n.components = g(c)), Object.keys(p).length) {
353
356
  const l = o.Parser.parserHtml.splitPropsFromAttr(p);
354
357
  n.attributes = l.attrs, Object.assign(n, l.props);
355
358
  }
356
359
  return n;
357
360
  }
358
361
  }
359
- function de(e) {
360
- const { component: t } = e, [o, s] = O(0), [a, n] = O();
362
+ function ge(e) {
363
+ const { component: t } = e, [o, s] = O(0), [r, n] = O();
361
364
  return C(() => {
362
365
  if (!t) return () => {
363
366
  };
364
- const r = () => s((l) => l + 1), c = () => {
367
+ const a = () => s((l) => l + 1), c = () => {
365
368
  [...t.views].forEach((b) => b.remove()), n(void 0);
366
369
  }, { em: u } = t, d = u.Components.events, g = [...["components", "attributes", "classes"].map((l) => `${d.update}:${l}`), "rerender"].join(" "), f = [d.removed, "rerender"].join(" ");
367
- return t.on(g, r), t.on(f, c), () => {
368
- t.off(g, r), t.off(f, c), c();
370
+ return t.on(g, a), t.on(f, c), () => {
371
+ t.off(g, a), t.off(f, c), c();
369
372
  };
370
- }, [t]), { key: o, view: a, connectDom: (r) => {
371
- if (!r) return;
372
- const c = ge({ ...e, el: r });
373
+ }, [t]), { key: o, view: r, connectDom: (a) => {
374
+ if (!a) return;
375
+ const c = ye({ ...e, el: a });
373
376
  n(c);
374
377
  } };
375
378
  }
376
- function ge(e) {
379
+ function ye(e) {
377
380
  var c;
378
- const { editor: t, component: o, el: s, frameView: a } = e, { em: n, Components: i } = t;
379
- let r = o.getView(a.model);
380
- if ((r == null ? void 0 : r.el) === s)
381
- return r;
382
- if (!r) {
383
- const { ComponentView: u } = i, d = o.attributes.type || "default", p = ((c = i.getType(d)) == null ? void 0 : c.view) || u, g = { ...i.config, frameView: a, em: n }, f = p.extend({
381
+ const { editor: t, component: o, el: s, frameView: r } = e, { em: n, Components: i } = t;
382
+ let a = o.getView(r.model);
383
+ if ((a == null ? void 0 : a.el) === s)
384
+ return a;
385
+ if (!a) {
386
+ const { ComponentView: u } = i, d = o.attributes.type || "default", p = ((c = i.getType(d)) == null ? void 0 : c.view) || u, g = { ...i.config, frameView: r, em: n }, f = p.extend({
384
387
  initComponents() {
385
388
  },
386
389
  _createElement() {
@@ -395,34 +398,34 @@ function ge(e) {
395
398
  return this._ensureElement(), this._setData(), this.renderAttributes(), (l = this.updateSrc) == null || l.call(this), this;
396
399
  }
397
400
  });
398
- r = new f({ el: s, config: g, model: o });
401
+ a = new f({ el: s, config: g, model: o });
399
402
  }
400
- return r.el = s, r.render(), r;
403
+ return a.el = s, a.render(), a;
401
404
  }
402
- function ye(e, t) {
403
- const { Components: o } = e, s = ({ id: a, model: n }) => {
404
- n && o.addType(a, {
405
+ function he(e, t) {
406
+ const { Components: o } = e, s = ({ id: r, model: n }) => {
407
+ n && o.addType(r, {
405
408
  model: {
406
409
  toJSON(...i) {
407
- const r = n.prototype.toJSON.apply(this, i);
408
- return r.tagName = this.tagName, r;
410
+ const a = n.prototype.toJSON.apply(this, i);
411
+ return a.tagName = this.tagName, a;
409
412
  }
410
413
  }
411
414
  });
412
415
  };
413
- o.getTypes().forEach(s), e.on("component:type:add", s), Object.entries(t.components || {}).forEach(([a, n]) => {
416
+ o.getTypes().forEach(s), e.on("component:type:add", s), Object.entries(t.components || {}).forEach(([r, n]) => {
414
417
  var g, f;
415
- const { allowPropClassName: i, allowPropId: r, allowChildren: c } = n, u = !r && !i, d = () => ({
418
+ const { allowPropClassName: i, allowPropId: a, allowChildren: c } = n, u = !a && !i, d = () => ({
416
419
  disabled: u
417
420
  }), p = () => ({
418
421
  disableClasses: !i,
419
- disableComponent: !r
422
+ disableComponent: !a
420
423
  });
421
- o.addType(a, {
422
- isComponent: (l) => (l == null ? void 0 : l.tagName) === a,
424
+ o.addType(r, {
425
+ isComponent: (l) => (l == null ? void 0 : l.tagName) === r,
423
426
  model: {
424
427
  defaults: {
425
- type: a,
428
+ type: r,
426
429
  traits: ((g = n.props) == null ? void 0 : g.call(n)) || [],
427
430
  droppable: !!c,
428
431
  stylable: !u,
@@ -434,9 +437,9 @@ function ye(e, t) {
434
437
  });
435
438
  });
436
439
  }
437
- function M(e) {
440
+ function j(e) {
438
441
  var x;
439
- const { component: t, config: o, editor: s, frameView: a, onMount: n, tagName: i, children: r } = e, { key: c, view: u, connectDom: d } = de(e);
442
+ const { component: t, config: o, editor: s, frameView: r, onMount: n, tagName: i, children: a } = e, { key: c, view: u, connectDom: d } = ge(e);
440
443
  C(() => {
441
444
  if (!u && !n) return;
442
445
  const h = setTimeout(() => {
@@ -444,60 +447,60 @@ function M(e) {
444
447
  });
445
448
  return () => clearTimeout(h);
446
449
  }, [u]);
447
- const p = t.get("type") || "default", g = t.content, f = (x = o.components) == null ? void 0 : x[p], l = (f == null ? void 0 : f.component) || i || t.tagName || "div", b = t.components(), w = b.length ? b.map((h) => /* @__PURE__ */ y(M, { component: h, config: o, editor: s, frameView: a }, h.cid)) : [g || void 0], m = ce(t.getAttributes()), R = f == null ? void 0 : f.editorRender, T = [...w, r].filter((h) => h ?? !1), P = T.length ? T : null;
450
+ const p = t.get("type") || "default", g = t.content, f = (x = o.components) == null ? void 0 : x[p], l = (f == null ? void 0 : f.component) || i || t.tagName || "div", b = t.components(), w = b.length ? b.map((h) => /* @__PURE__ */ y(j, { component: h, config: o, editor: s, frameView: r }, h.cid)) : [g || void 0], m = le(t.getAttributes()), R = f == null ? void 0 : f.editorRender, T = [...w, a].filter((h) => h ?? !1), A = T.length ? T : null;
448
451
  if (R)
449
- return /* @__PURE__ */ y(R, { props: m, editor: s, component: t, connectDom: d, children: P });
452
+ return /* @__PURE__ */ y(R, { props: m, editor: s, component: t, connectDom: d, children: A });
450
453
  if (f != null && f.component)
451
- return /* @__PURE__ */ y("gjs-wrapper", { ref: d, style: f.wrapperStyle, children: /* @__PURE__ */ y(l, { ...m, children: P }) });
454
+ return /* @__PURE__ */ y("gjs-wrapper", { ref: d, style: f.wrapperStyle, children: /* @__PURE__ */ y(l, { ...m, children: A }) });
452
455
  if (t.isInstanceOf("textnode"))
453
456
  return g;
454
- const j = t.isInstanceOf("text") ? c : void 0;
455
- return /* @__PURE__ */ F(l, { ...m, ref: d, key: j }, t.get("void") ? null : P);
457
+ const F = t.isInstanceOf("text") ? c : void 0;
458
+ return /* @__PURE__ */ W(l, { ...m, ref: d, key: F }, t.get("void") ? null : A);
456
459
  }
457
- const he = (e) => {
458
- const { frame: t, window: o, onMount: s, editor: a } = e, n = a.Canvas.events, { root: i } = t;
460
+ const ve = (e) => {
461
+ const { frame: t, window: o, onMount: s, editor: r } = e, n = r.Canvas.events, { root: i } = t;
459
462
  try {
460
- const r = W(o.document.body);
461
- r.render(/* @__PURE__ */ y(ve, { ...e, component: i, onMount: s }));
462
- const c = () => r.unmount();
463
+ const a = $(o.document.body);
464
+ a.render(/* @__PURE__ */ y(be, { ...e, component: i, onMount: s }));
465
+ const c = () => a.unmount();
463
466
  t.once(n.frameUnload, c), o.addEventListener("unload", c);
464
- } catch (r) {
465
- console.warn(r);
467
+ } catch (a) {
468
+ console.warn(a);
466
469
  }
467
470
  return i.getView();
468
471
  };
469
- function ve(e) {
470
- const { editor: t, component: o, window: s, frameView: a, config: n, onMount: i } = e, r = s.document, c = n.rootComponent || D, u = n.rootComponent ? { editorProps: { doc: r, editor: t, frameView: a } } : {}, d = (n == null ? void 0 : n.bodyAfter) || D;
472
+ function be(e) {
473
+ const { editor: t, component: o, window: s, frameView: r, config: n, onMount: i } = e, a = s.document, c = n.rootComponent || D, u = n.rootComponent ? { editorProps: { doc: a, editor: t, frameView: r } } : {}, d = (n == null ? void 0 : n.bodyAfter) || D;
471
474
  return /* @__PURE__ */ y(c, { ...u, children: /* @__PURE__ */ y(
472
- M,
475
+ j,
473
476
  {
474
477
  tagName: "div",
475
478
  component: o,
476
479
  config: n,
477
480
  editor: t,
478
- frameView: a,
481
+ frameView: r,
479
482
  onMount: i,
480
483
  children: /* @__PURE__ */ y(d, { ...u })
481
484
  }
482
485
  ) });
483
486
  }
484
- const be = "rendererReact", me = v.startup, we = function(e, t = {}) {
485
- const { Blocks: o, Pages: s } = e, a = o.events, n = s.events;
486
- e.Canvas.config.customRenderer = (r) => he({ ...r, config: t }), e.Components.config.processor = (r) => A({ model: r, editor: e, config: t }), ye(e, t);
487
+ const M = "rendererReact", me = v.startup, we = function(e, t = {}) {
488
+ const { Blocks: o, Pages: s } = e, r = o.events, n = s.events;
489
+ e.Canvas.config.customRenderer = (a) => ve({ ...a, config: t }), e.Components.config.processor = (a) => P({ model: a, editor: e, config: t }), he(e, t);
487
490
  const i = [
488
- [a.add, ue({ editor: e, config: t })],
489
- [n.addBefore, fe({ editor: e, config: t })]
491
+ [r.add, fe({ editor: e, config: t })],
492
+ [n.addBefore, de({ editor: e, config: t })]
490
493
  ];
491
- i.forEach(([r, c]) => e.on(r, c)), ee({
494
+ i.forEach(([a, c]) => e.on(a, c)), te({
492
495
  editor: e,
493
496
  licenseKey: t.licenseKey,
494
497
  plan: me,
495
- pluginName: be,
498
+ pluginName: M,
496
499
  cleanup: () => {
497
- e.Canvas.config.customRenderer = void 0, e.Components.config.processor = void 0, i.forEach(([r, c]) => e.off(r, c));
500
+ e.Canvas.config.customRenderer = void 0, e.Components.config.processor = void 0, i.forEach(([a, c]) => e.off(a, c));
498
501
  }
499
502
  });
500
- }, ke = Y(we);
503
+ }, ke = ee(we, M);
501
504
  export {
502
505
  ke as default
503
506
  };
@@ -1 +1 @@
1
- "use strict";const y=require("react/jsx-runtime"),h=require("react"),_=require("react-dom/client"),G="app.grapesjs.com",I="app-stage.grapesjs.com",F="app2.grapesjs.com",M="app-stage2.grapesjs.com",D=[G,F,I,M,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],W="license:check:end",$=()=>typeof window<"u",K=({isDev:e,isStage:t,isPlatform:o})=>`${e?"":`https://${t?I:G}`}/${o?"platform-api":"api"}`,S=()=>{if(!$())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},V=()=>{const e=S();return!!e&&(D.includes(e)||D.some(t=>e.endsWith(t)))},z=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(t,o)=>(o?"-":"")+t.toLowerCase()),N=e=>typeof e=="string";function q(e){return typeof e=="function"}async function J({path:e,baseApiUrl:t,method:o="GET",headers:s={},params:a,body:n}){const r=`${t||K({isDev:!1,isStage:!1})}${e}`,c={method:o,headers:{"Content-Type":"application/json",...s}};n&&(c.body=JSON.stringify(n));const u=a?new URLSearchParams(a).toString():"",d=u?`?${u}`:"",p=await fetch(`${r}${d}`,c);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{}),x=(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))(x||{});const L={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function H(e){const t=e;return t.init=o=>s=>e(s,o),t}const Z=e=>H(e);async function Q({editor:e,plan:t,pluginName:o,licenseKey:s,onLicenseCheckResponse:a,cleanup:n}){let i="",r;const c=p=>{console.warn("Cleanup plugin:",o,"Reason:",p),n()},u=(p={})=>{var R;const{error:g,sdkLicense:f}=p,l=(R=p.plan)==null?void 0:R.category;if(!(f||p.license)||g)c(g||"Invalid license");else if(l){const w=L[t],A=L[l];w>A&&c({pluginRequiredPlan:t,licensePlan:l})}};e.Commands.has(x.settings)&&(r=e.runCommand(x.settings),i=(r==null?void 0:r.baseUrl)||"");const d=p=>{a==null||a(p),p&&u(p)};if(!r){e.onReady(async()=>{if(!V())if(s){const p=await Y({licenseKey:s,pluginName:o,baseApiUrl:i});d(p)}else c("The `licenseKey` option not provided")});return}if(r.licensePlan||r.licenseError){const p=X(r);d(p);return}e.on(W,p=>d(p))}const X=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function Y(e){const{licenseKey:t,pluginName:o,baseApiUrl:s}=e;try{return(await J({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}function ee(e){const t={};for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const s=z(o);t[s]=e[o]}return t}const te=(e,t)=>{const o=e.components||{};for(const s in o){const a=o[s];if(a.component===t)return{cmpConfig:a,type:s}}};function j(e){const t={};let o=!1;for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const a=e[s];if(typeof a=="string"||typeof a=="number"){const n=s.includes("-")?s.replace(/-([a-z])/g,i=>i[1].toUpperCase()):s;t[n]=a,o=!0}}return o?t:void 0}function oe(e){const t={};return e.split(";").forEach(o=>{if(!o.trim())return;const s=o.indexOf(":");if(s>0){const a=o.substring(0,s).trim(),n=o.substring(s+1).trim();if(a&&n){const i=a.replace(/-([a-z])/g,r=>r[1].toUpperCase());t[i]=n}}}),Object.keys(t).length>0?t:void 0}function ne(e){if(e){if(typeof e=="object"&&!Array.isArray(e))return j(e);if(typeof e=="string"){let t=oe(e);if(!t)try{const o=JSON.parse(e);typeof o=="object"&&o!==null&&!Array.isArray(o)&&(t=j(o))}catch(o){console.error("Failed to parse style string as JSON",o)}return t}if(Array.isArray(e)){const t={};return e.forEach(o=>{if(typeof o=="object"&&o!==null){const s=o.name||o.property,a=o.value;if(typeof s=="string"&&s&&a!==void 0&&a!==""){const n=s.replace(/-([a-z])/g,i=>i[1].toUpperCase());t[n]=a}}}),Object.keys(t).length>0?t:void 0}}}function se(e){return B[e]?B[e]:e.includes("-")?e.replace(/-([a-z])/g,(t,o)=>o.toUpperCase()):e}function re(e){var o;const t={};for(const[s,a]of Object.entries(e))if(s==="style")t.style=ne(a);else if(s.startsWith("data-"))t[s]=a;else{const n=se(s);((o=e.xmlns)==null?void 0:o.includes("svg"))||e.viewBox!==void 0||e.d!==void 0||ie.has(n)||n.startsWith("svg")?t[n]=a:!ae.has(n)&&!n.startsWith("on")&&!n.startsWith("aria-")&&!n.startsWith("data-")?t[s]=a:t[n]=a}return t}const ae=new Set(["className","id","style","href","src","alt","title","target","rel","type","name","value","placeholder","onClick","onChange","onSubmit","onBlur","onFocus","disabled","readOnly","checked","selected","multiple","width","height","maxLength","min","max","step","rows","cols","autoComplete","autoFocus","required","spellCheck","tabIndex","aria-label","aria-labelledby","aria-describedby","role"]),ie=new Set(["x","y","d","cx","cy","r","rx","ry","x1","x2","y1","y2","points","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeOpacity","fillOpacity","fillRule","clipRule","transform","viewBox","preserveAspectRatio","pathLength","vectorEffect","dominantBaseline","alignmentBaseline","textAnchor","fontFamily","fontSize","fontStyle","fontWeight","textDecoration","baselineShift","opacity","mask","clipPath","overflow","pointerEvents"]),B={class:"className",for:"htmlFor","http-equiv":"httpEquiv","accept-charset":"acceptCharset","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","fill-rule":"fillRule","clip-rule":"clipRule","stroke-miterlimit":"strokeMiterlimit","stroke-dasharray":"strokeDasharray","stroke-opacity":"strokeOpacity","fill-opacity":"fillOpacity","font-family":"fontFamily","font-size":"fontSize","text-anchor":"textAnchor"},E=e=>(e==null?void 0:e.$$typeof)&&typeof e.props=="object";function ce(e){return t=>{const o=t.getContent();E(o)&&t.set({content:P({...e,model:o}),reactContent:o})}}const le=e=>t=>{const o=t.component;E(o)&&(t.component={components:P({...e,model:o})})};function P(e){const{model:t,editor:o,config:s}=e;if(E(t)){const a=t,n={},{type:i,props:r={}}=a,{children:c,className:u,style:d,...p}=r,g=l=>({type:"textnode",content:l}),f=typeof i=="symbol";if(q(i)){const l=te(s,i);n.type=l==null?void 0:l.type}else o.Components.getType(i)?n.type=i:f||(n.tagName=i);if(u&&(n.classes=u),d&&(n.style=ee(d)),Array.isArray(c)?n.components=c.map(l=>N(l)?g(l):P({...e,model:l})).filter(Boolean):N(c)&&(n.components=g(c)),Object.keys(p).length){const l=o.Parser.parserHtml.splitPropsFromAttr(p);n.attributes=l.attrs,Object.assign(n,l.props)}return n}}function pe(e){const{component:t}=e,[o,s]=h.useState(0),[a,n]=h.useState();return h.useEffect(()=>{if(!t)return()=>{};const r=()=>s(l=>l+1),c=()=>{[...t.views].forEach(m=>m.remove()),n(void 0)},{em:u}=t,d=u.Components.events,g=[...["components","attributes","classes"].map(l=>`${d.update}:${l}`),"rerender"].join(" "),f=[d.removed,"rerender"].join(" ");return t.on(g,r),t.on(f,c),()=>{t.off(g,r),t.off(f,c),c()}},[t]),{key:o,view:a,connectDom:r=>{if(!r)return;const c=ue({...e,el:r});n(c)}}}function ue(e){var c;const{editor:t,component:o,el:s,frameView:a}=e,{em:n,Components:i}=t;let r=o.getView(a.model);if((r==null?void 0:r.el)===s)return r;if(!r){const{ComponentView:u}=i,d=o.attributes.type||"default",p=((c=i.getType(d))==null?void 0:c.view)||u,g={...i.config,frameView:a,em:n},f=p.extend({initComponents(){},_createElement(){return s},_removeElement(){},__clearAttributes(){},render(){var l;return this._ensureElement(),this._setData(),this.renderAttributes(),(l=this.updateSrc)==null||l.call(this),this}});r=new f({el:s,config:g,model:o})}return r.el=s,r.render(),r}function fe(e,t){const{Components:o}=e,s=({id:a,model:n})=>{n&&o.addType(a,{model:{toJSON(...i){const r=n.prototype.toJSON.apply(this,i);return r.tagName=this.tagName,r}}})};o.getTypes().forEach(s),e.on("component:type:add",s),Object.entries(t.components||{}).forEach(([a,n])=>{var g,f;const{allowPropClassName:i,allowPropId:r,allowChildren:c}=n,u=!r&&!i,d=()=>({disabled:u}),p=()=>({disableClasses:!i,disableComponent:!r});o.addType(a,{isComponent:l=>(l==null?void 0:l.tagName)===a,model:{defaults:{type:a,traits:((g=n.props)==null?void 0:g.call(n))||[],droppable:!!c,stylable:!u,styleManager:d,selectorManager:p,...((f=n.model)==null?void 0:f.defaults)||{}}}})})}function C(e){var O;const{component:t,config:o,editor:s,frameView:a,onMount:n,tagName:i,children:r}=e,{key:c,view:u,connectDom:d}=pe(e);h.useEffect(()=>{if(!u&&!n)return;const v=setTimeout(()=>{u&&(n==null||n(u),setTimeout(()=>u.postRender()))});return()=>clearTimeout(v)},[u]);const p=t.get("type")||"default",g=t.content,f=(O=o.components)==null?void 0:O[p],l=(f==null?void 0:f.component)||i||t.tagName||"div",m=t.components(),R=m.length?m.map(v=>y.jsx(C,{component:v,config:o,editor:s,frameView:a},v.cid)):[g||void 0],w=re(t.getAttributes()),A=f==null?void 0:f.editorRender,T=[...R,r].filter(v=>v??!1),k=T.length?T:null;if(A)return y.jsx(A,{props:w,editor:s,component:t,connectDom:d,children:k});if(f!=null&&f.component)return y.jsx("gjs-wrapper",{ref:d,style:f.wrapperStyle,children:y.jsx(l,{...w,children:k})});if(t.isInstanceOf("textnode"))return g;const U=t.isInstanceOf("text")?c:void 0;return h.createElement(l,{...w,ref:d,key:U},t.get("void")?null:k)}const de=e=>{const{frame:t,window:o,onMount:s,editor:a}=e,n=a.Canvas.events,{root:i}=t;try{const r=_.createRoot(o.document.body);r.render(y.jsx(ge,{...e,component:i,onMount:s}));const c=()=>r.unmount();t.once(n.frameUnload,c),o.addEventListener("unload",c)}catch(r){console.warn(r)}return i.getView()};function ge(e){const{editor:t,component:o,window:s,frameView:a,config:n,onMount:i}=e,r=s.document,c=n.rootComponent||h.Fragment,u=n.rootComponent?{editorProps:{doc:r,editor:t,frameView:a}}:{},d=(n==null?void 0:n.bodyAfter)||h.Fragment;return y.jsx(c,{...u,children:y.jsx(C,{tagName:"div",component:o,config:n,editor:t,frameView:a,onMount:i,children:y.jsx(d,{...u})})})}const ye="rendererReact",he=b.startup,ve=function(e,t={}){const{Blocks:o,Pages:s}=e,a=o.events,n=s.events;e.Canvas.config.customRenderer=r=>de({...r,config:t}),e.Components.config.processor=r=>P({model:r,editor:e,config:t}),fe(e,t);const i=[[a.add,ce({editor:e,config:t})],[n.addBefore,le({editor:e,config:t})]];i.forEach(([r,c])=>e.on(r,c)),Q({editor:e,licenseKey:t.licenseKey,plan:he,pluginName:ye,cleanup:()=>{e.Canvas.config.customRenderer=void 0,e.Components.config.processor=void 0,i.forEach(([r,c])=>e.off(r,c))}})},be=Z(ve);module.exports=be;
1
+ "use strict";const y=require("react/jsx-runtime"),h=require("react"),F=require("react-dom/client"),I="app.grapesjs.com",G="app-stage.grapesjs.com",M="app2.grapesjs.com",W="app-stage2.grapesjs.com",D=[I,M,G,W,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],$="license:check:end",K=()=>typeof window<"u",V=({isDev:e,isStage:t,isPlatform:o})=>`${e?"":`https://${t?G:I}`}/${o?"platform-api":"api"}`,z=()=>{if(!K())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},S=()=>{const e=z();return!!e&&(D.includes(e)||D.some(t=>e.endsWith(t)))},q=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(t,o)=>(o?"-":"")+t.toLowerCase()),N=e=>typeof e=="string";function J(e){return typeof e=="function"}async function H({path:e,baseApiUrl:t,method:o="GET",headers:s={},params:r,body:n}){const a=`${t||V({isDev:!1,isStage:!1})}${e}`,c={method:o,headers:{"Content-Type":"application/json",...s}};n&&(c.body=JSON.stringify(n));const u=r?new URLSearchParams(r).toString():"",d=u?`?${u}`:"",p=await fetch(`${a}${d}`,c);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{}),x=(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.openBlocks="studio:openBlocks",e.appendComponent="studio:appendComponent",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))(x||{});const L={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function Z(e,t){const o=e;return o.init=s=>{const r=n=>e(n,s);return r.__gjsPluginId=t,r},o}const Q=(e,t)=>Z(e,t);async function X({editor:e,plan:t,pluginName:o,licenseKey:s,onLicenseCheckResponse:r,cleanup:n}){let i="",a;const c=p=>{console.warn("Cleanup plugin:",o,"Reason:",p),n(e,o)},u=(p={})=>{var R;const{error:g,sdkLicense:f}=p,l=(R=p.plan)==null?void 0:R.category;if(!(f||p.license)||g)c(g||"Invalid license");else if(l){const w=L[t],P=L[l];w>P&&c({pluginRequiredPlan:t,licensePlan:l})}};e.Commands.has(x.settings)&&(a=e.runCommand(x.settings),i=(a==null?void 0:a.baseUrl)||"");const d=p=>{r==null||r(p),p&&u(p)};if(!a){e.onReady(async()=>{if(!S())if(s){const p=await ee({licenseKey:s,pluginName:o,baseApiUrl:i});d(p)}else c("The `licenseKey` option not provided")});return}if(a.licensePlan||a.licenseError){const p=Y(a);d(p);return}e.on($,p=>d(p))}const Y=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function ee(e){const{licenseKey:t,pluginName:o,baseApiUrl:s}=e;try{return(await H({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(r){return console.error("Error during SDK license check:",r),!1}}function te(e){const t={};for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const s=q(o);t[s]=e[o]}return t}const oe=(e,t)=>{const o=e.components||{};for(const s in o){const r=o[s];if(r.component===t)return{cmpConfig:r,type:s}}};function j(e){const t={};let o=!1;for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const r=e[s];if(typeof r=="string"||typeof r=="number"){const n=s.includes("-")?s.replace(/-([a-z])/g,i=>i[1].toUpperCase()):s;t[n]=r,o=!0}}return o?t:void 0}function ne(e){const t={};return e.split(";").forEach(o=>{if(!o.trim())return;const s=o.indexOf(":");if(s>0){const r=o.substring(0,s).trim(),n=o.substring(s+1).trim();if(r&&n){const i=r.replace(/-([a-z])/g,a=>a[1].toUpperCase());t[i]=n}}}),Object.keys(t).length>0?t:void 0}function se(e){if(e){if(typeof e=="object"&&!Array.isArray(e))return j(e);if(typeof e=="string"){let t=ne(e);if(!t)try{const o=JSON.parse(e);typeof o=="object"&&o!==null&&!Array.isArray(o)&&(t=j(o))}catch(o){console.error("Failed to parse style string as JSON",o)}return t}if(Array.isArray(e)){const t={};return e.forEach(o=>{if(typeof o=="object"&&o!==null){const s=o.name||o.property,r=o.value;if(typeof s=="string"&&s&&r!==void 0&&r!==""){const n=s.replace(/-([a-z])/g,i=>i[1].toUpperCase());t[n]=r}}}),Object.keys(t).length>0?t:void 0}}}function re(e){return B[e]?B[e]:e.includes("-")?e.replace(/-([a-z])/g,(t,o)=>o.toUpperCase()):e}function ae(e){var o;const t={};for(const[s,r]of Object.entries(e))if(s==="style")t.style=se(r);else if(s.startsWith("data-"))t[s]=r;else{const n=re(s);((o=e.xmlns)==null?void 0:o.includes("svg"))||e.viewBox!==void 0||e.d!==void 0||ce.has(n)||n.startsWith("svg")?t[n]=r:!ie.has(n)&&!n.startsWith("on")&&!n.startsWith("aria-")&&!n.startsWith("data-")?t[s]=r:t[n]=r}return t}const ie=new Set(["className","id","style","href","src","alt","title","target","rel","type","name","value","placeholder","onClick","onChange","onSubmit","onBlur","onFocus","disabled","readOnly","checked","selected","multiple","width","height","maxLength","min","max","step","rows","cols","autoComplete","autoFocus","required","spellCheck","tabIndex","aria-label","aria-labelledby","aria-describedby","role"]),ce=new Set(["x","y","d","cx","cy","r","rx","ry","x1","x2","y1","y2","points","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeOpacity","fillOpacity","fillRule","clipRule","transform","viewBox","preserveAspectRatio","pathLength","vectorEffect","dominantBaseline","alignmentBaseline","textAnchor","fontFamily","fontSize","fontStyle","fontWeight","textDecoration","baselineShift","opacity","mask","clipPath","overflow","pointerEvents"]),B={class:"className",for:"htmlFor","http-equiv":"httpEquiv","accept-charset":"acceptCharset","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","fill-rule":"fillRule","clip-rule":"clipRule","stroke-miterlimit":"strokeMiterlimit","stroke-dasharray":"strokeDasharray","stroke-opacity":"strokeOpacity","fill-opacity":"fillOpacity","font-family":"fontFamily","font-size":"fontSize","text-anchor":"textAnchor"},E=e=>(e==null?void 0:e.$$typeof)&&typeof e.props=="object";function le(e){return t=>{const o=t.getContent();E(o)&&t.set({content:A({...e,model:o}),reactContent:o})}}const pe=e=>t=>{const o=t.component;E(o)&&(t.component={components:A({...e,model:o})})};function A(e){const{model:t,editor:o,config:s}=e;if(E(t)){const r=t,n={},{type:i,props:a={}}=r,{children:c,className:u,style:d,...p}=a,g=l=>({type:"textnode",content:l}),f=typeof i=="symbol";if(J(i)){const l=oe(s,i);n.type=l==null?void 0:l.type}else o.Components.getType(i)?n.type=i:f||(n.tagName=i);if(u&&(n.classes=u),d&&(n.style=te(d)),Array.isArray(c)?n.components=c.map(l=>N(l)?g(l):A({...e,model:l})).filter(Boolean):N(c)&&(n.components=g(c)),Object.keys(p).length){const l=o.Parser.parserHtml.splitPropsFromAttr(p);n.attributes=l.attrs,Object.assign(n,l.props)}return n}}function ue(e){const{component:t}=e,[o,s]=h.useState(0),[r,n]=h.useState();return h.useEffect(()=>{if(!t)return()=>{};const a=()=>s(l=>l+1),c=()=>{[...t.views].forEach(m=>m.remove()),n(void 0)},{em:u}=t,d=u.Components.events,g=[...["components","attributes","classes"].map(l=>`${d.update}:${l}`),"rerender"].join(" "),f=[d.removed,"rerender"].join(" ");return t.on(g,a),t.on(f,c),()=>{t.off(g,a),t.off(f,c),c()}},[t]),{key:o,view:r,connectDom:a=>{if(!a)return;const c=fe({...e,el:a});n(c)}}}function fe(e){var c;const{editor:t,component:o,el:s,frameView:r}=e,{em:n,Components:i}=t;let a=o.getView(r.model);if((a==null?void 0:a.el)===s)return a;if(!a){const{ComponentView:u}=i,d=o.attributes.type||"default",p=((c=i.getType(d))==null?void 0:c.view)||u,g={...i.config,frameView:r,em:n},f=p.extend({initComponents(){},_createElement(){return s},_removeElement(){},__clearAttributes(){},render(){var l;return this._ensureElement(),this._setData(),this.renderAttributes(),(l=this.updateSrc)==null||l.call(this),this}});a=new f({el:s,config:g,model:o})}return a.el=s,a.render(),a}function de(e,t){const{Components:o}=e,s=({id:r,model:n})=>{n&&o.addType(r,{model:{toJSON(...i){const a=n.prototype.toJSON.apply(this,i);return a.tagName=this.tagName,a}}})};o.getTypes().forEach(s),e.on("component:type:add",s),Object.entries(t.components||{}).forEach(([r,n])=>{var g,f;const{allowPropClassName:i,allowPropId:a,allowChildren:c}=n,u=!a&&!i,d=()=>({disabled:u}),p=()=>({disableClasses:!i,disableComponent:!a});o.addType(r,{isComponent:l=>(l==null?void 0:l.tagName)===r,model:{defaults:{type:r,traits:((g=n.props)==null?void 0:g.call(n))||[],droppable:!!c,stylable:!u,styleManager:d,selectorManager:p,...((f=n.model)==null?void 0:f.defaults)||{}}}})})}function C(e){var O;const{component:t,config:o,editor:s,frameView:r,onMount:n,tagName:i,children:a}=e,{key:c,view:u,connectDom:d}=ue(e);h.useEffect(()=>{if(!u&&!n)return;const v=setTimeout(()=>{u&&(n==null||n(u),setTimeout(()=>u.postRender()))});return()=>clearTimeout(v)},[u]);const p=t.get("type")||"default",g=t.content,f=(O=o.components)==null?void 0:O[p],l=(f==null?void 0:f.component)||i||t.tagName||"div",m=t.components(),R=m.length?m.map(v=>y.jsx(C,{component:v,config:o,editor:s,frameView:r},v.cid)):[g||void 0],w=ae(t.getAttributes()),P=f==null?void 0:f.editorRender,T=[...R,a].filter(v=>v??!1),k=T.length?T:null;if(P)return y.jsx(P,{props:w,editor:s,component:t,connectDom:d,children:k});if(f!=null&&f.component)return y.jsx("gjs-wrapper",{ref:d,style:f.wrapperStyle,children:y.jsx(l,{...w,children:k})});if(t.isInstanceOf("textnode"))return g;const _=t.isInstanceOf("text")?c:void 0;return h.createElement(l,{...w,ref:d,key:_},t.get("void")?null:k)}const ge=e=>{const{frame:t,window:o,onMount:s,editor:r}=e,n=r.Canvas.events,{root:i}=t;try{const a=F.createRoot(o.document.body);a.render(y.jsx(ye,{...e,component:i,onMount:s}));const c=()=>a.unmount();t.once(n.frameUnload,c),o.addEventListener("unload",c)}catch(a){console.warn(a)}return i.getView()};function ye(e){const{editor:t,component:o,window:s,frameView:r,config:n,onMount:i}=e,a=s.document,c=n.rootComponent||h.Fragment,u=n.rootComponent?{editorProps:{doc:a,editor:t,frameView:r}}:{},d=(n==null?void 0:n.bodyAfter)||h.Fragment;return y.jsx(c,{...u,children:y.jsx(C,{tagName:"div",component:o,config:n,editor:t,frameView:r,onMount:i,children:y.jsx(d,{...u})})})}const U="rendererReact",he=b.startup,ve=function(e,t={}){const{Blocks:o,Pages:s}=e,r=o.events,n=s.events;e.Canvas.config.customRenderer=a=>ge({...a,config:t}),e.Components.config.processor=a=>A({model:a,editor:e,config:t}),de(e,t);const i=[[r.add,le({editor:e,config:t})],[n.addBefore,pe({editor:e,config:t})]];i.forEach(([a,c])=>e.on(a,c)),X({editor:e,licenseKey:t.licenseKey,plan:he,pluginName:U,cleanup:()=>{e.Canvas.config.customRenderer=void 0,e.Components.config.processor=void 0,i.forEach(([a,c])=>e.off(a,c))}})},be=Q(ve,U);module.exports=be;