@grapesjs/studio-sdk-plugins 1.0.36 → 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 (91) hide show
  1. package/dist/accordionComponent/index.cjs.js +4 -4
  2. package/dist/accordionComponent/index.es.js +83 -70
  3. package/dist/accordionComponent/index.umd.js +4 -4
  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 +70 -70
  8. package/dist/aiChat/index.es.js +8627 -8161
  9. package/dist/aiChat/index.js +70 -70
  10. package/dist/aiChat/index.umd.js +70 -70
  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 +55 -42
  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 +67 -54
  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 +59 -46
  20. package/dist/canvasEmptyState/index.umd.js +1 -1
  21. package/dist/canvasFullSize/index.cjs.js +4 -4
  22. package/dist/canvasFullSize/index.es.js +59 -46
  23. package/dist/canvasFullSize/index.umd.js +4 -4
  24. package/dist/canvasGridMode/index.cjs.js +2 -2
  25. package/dist/canvasGridMode/index.es.js +70 -57
  26. package/dist/canvasGridMode/index.umd.js +4 -4
  27. package/dist/canvasScreenshot/index.cjs.js +1 -1
  28. package/dist/canvasScreenshot/index.es.js +37 -24
  29. package/dist/canvasScreenshot/index.umd.js +1 -1
  30. package/dist/dataSourceEjs/index.cjs.js +3 -3
  31. package/dist/dataSourceEjs/index.es.js +51 -38
  32. package/dist/dataSourceEjs/index.umd.js +3 -3
  33. package/dist/dataSourceHandlebars/index.cjs.js +2 -2
  34. package/dist/dataSourceHandlebars/index.es.js +50 -37
  35. package/dist/dataSourceHandlebars/index.umd.js +6 -6
  36. package/dist/dialogComponent/index.cjs.js +9 -9
  37. package/dist/dialogComponent/index.es.js +58 -45
  38. package/dist/dialogComponent/index.umd.js +3 -3
  39. package/dist/flexComponent/index.cjs.js +6 -6
  40. package/dist/flexComponent/index.es.js +82 -69
  41. package/dist/flexComponent/index.umd.js +6 -6
  42. package/dist/fsLightboxComponent/index.cjs.js +2 -2
  43. package/dist/fsLightboxComponent/index.es.js +70 -57
  44. package/dist/fsLightboxComponent/index.umd.js +2 -2
  45. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  46. package/dist/googleFontsAssetProvider/index.es.js +84 -71
  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 +82 -69
  50. package/dist/iconifyComponent/index.umd.js +2 -2
  51. package/dist/index.cjs.js +36 -36
  52. package/dist/index.es.js +843 -830
  53. package/dist/index.umd.js +36 -36
  54. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  55. package/dist/layoutSidebarButtons/index.es.js +81 -68
  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 +86 -73
  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 +70 -57
  62. package/dist/linkImageComponent/index.umd.js +2 -2
  63. package/dist/listPagesComponent/index.cjs.js +3 -3
  64. package/dist/listPagesComponent/index.es.js +49 -36
  65. package/dist/listPagesComponent/index.umd.js +3 -3
  66. package/dist/presetPrintable/index.cjs.js +3 -3
  67. package/dist/presetPrintable/index.es.js +130 -117
  68. package/dist/presetPrintable/index.umd.js +3 -3
  69. package/dist/prosemirror/index.cjs.js +1 -1
  70. package/dist/prosemirror/index.es.js +96 -83
  71. package/dist/prosemirror/index.umd.js +1 -1
  72. package/dist/rendererReact/index.cjs.js +1 -1
  73. package/dist/rendererReact/index.es.js +143 -131
  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 +74 -61
  78. package/dist/rteTinyMce/index.umd.js +2 -2
  79. package/dist/shapeDividerComponent/index.cjs.js +3 -3
  80. package/dist/shapeDividerComponent/index.es.js +33 -20
  81. package/dist/shapeDividerComponent/index.umd.js +3 -3
  82. package/dist/swiperComponent/index.cjs.js +5 -5
  83. package/dist/swiperComponent/index.es.js +105 -92
  84. package/dist/swiperComponent/index.umd.js +5 -5
  85. package/dist/tableComponent/index.cjs.js +1 -1
  86. package/dist/tableComponent/index.es.js +163 -150
  87. package/dist/tableComponent/index.umd.js +1 -1
  88. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  89. package/dist/youtubeAssetProvider/index.es.js +36 -23
  90. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  91. package/package.json +2 -2
@@ -9,25 +9,38 @@ const re = "app.grapesjs.com", ce = "app-stage.grapesjs.com", ge = "app2.grapesj
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
+ ".claudemcpcontent.com",
15
+ // For Claude mcp app
16
+ ".web-sandbox.oaiusercontent.com"
17
+ // For OpenAI mcp app
14
18
  ], be = "license:check:end", de = () => typeof window < "u", ye = ({
15
19
  isDev: e,
16
20
  isStage: l,
17
21
  isPlatform: t
18
22
  }) => `${e ? "" : `https://${l ? ce : re}`}/${t ? "platform-api" : "api"}`, me = () => {
19
- const e = de() && window.location.hostname;
23
+ if (!de()) 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
+ }, ve = () => {
32
+ const e = me();
20
33
  return !!e && (ee.includes(e) || ee.some((l) => e.endsWith(l)));
21
34
  };
22
- async function ve({
35
+ async function fe({
23
36
  path: e,
24
37
  baseApiUrl: l,
25
38
  method: t = "GET",
26
39
  headers: o = {},
27
- params: i,
40
+ params: n,
28
41
  body: g
29
42
  }) {
30
- const n = `${l || ye({ isDev: !1, isStage: !1 })}${e}`, u = {
43
+ const i = `${l || ye({ isDev: !1, isStage: !1 })}${e}`, u = {
31
44
  method: t,
32
45
  headers: {
33
46
  "Content-Type": "application/json",
@@ -35,7 +48,7 @@ async function ve({
35
48
  }
36
49
  };
37
50
  g && (u.body = JSON.stringify(g));
38
- const p = i ? new URLSearchParams(i).toString() : "", b = p ? `?${p}` : "", r = await fetch(`${n}${b}`, u);
51
+ const p = n ? new URLSearchParams(n).toString() : "", b = p ? `?${p}` : "", r = await fetch(`${i}${b}`, u);
39
52
  if (!r.ok)
40
53
  throw new Error(`HTTP error! status: ${r.status}`);
41
54
  return r.json();
@@ -47,20 +60,20 @@ const te = {
47
60
  [E.business]: 20,
48
61
  [E.enterprise]: 30
49
62
  };
50
- function fe(e) {
63
+ function Te(e) {
51
64
  const l = e;
52
65
  return l.init = (t) => (o) => e(o, t), l;
53
66
  }
54
- const Te = (e) => /* @__PURE__ */ fe(e);
55
- async function we({
67
+ const we = (e) => /* @__PURE__ */ Te(e);
68
+ async function xe({
56
69
  editor: e,
57
70
  plan: l,
58
71
  pluginName: t,
59
72
  licenseKey: o,
60
- onLicenseCheckResponse: i,
73
+ onLicenseCheckResponse: n,
61
74
  cleanup: g
62
75
  }) {
63
- let c = "", n;
76
+ let c = "", i;
64
77
  const u = (r) => {
65
78
  console.warn("Cleanup plugin:", t, "Reason:", r), g();
66
79
  }, p = (r = {}) => {
@@ -73,38 +86,38 @@ async function we({
73
86
  M > _ && u({ pluginRequiredPlan: l, licensePlan: T });
74
87
  }
75
88
  };
76
- e.Commands.has(Z.settings) && (n = e.runCommand(Z.settings), c = (n == null ? void 0 : n.baseUrl) || "");
89
+ e.Commands.has(Z.settings) && (i = e.runCommand(Z.settings), c = (i == null ? void 0 : i.baseUrl) || "");
77
90
  const b = (r) => {
78
- i == null || i(r), r && p(r);
91
+ n == null || n(r), r && p(r);
79
92
  };
80
- if (!n) {
93
+ if (!i) {
81
94
  e.onReady(async () => {
82
- if (!me())
95
+ if (!ve())
83
96
  if (o) {
84
- const r = await Pe({ licenseKey: o, pluginName: t, baseApiUrl: c });
97
+ const r = await Ae({ licenseKey: o, pluginName: t, baseApiUrl: c });
85
98
  b(r);
86
99
  } else
87
100
  u("The `licenseKey` option not provided");
88
101
  });
89
102
  return;
90
103
  }
91
- if (n.licensePlan || n.licenseError) {
92
- const r = xe(n);
104
+ if (i.licensePlan || i.licenseError) {
105
+ const r = Pe(i);
93
106
  b(r);
94
107
  return;
95
108
  }
96
109
  e.on(be, (r) => b(r));
97
110
  }
98
- const xe = (e) => ({
111
+ const Pe = (e) => ({
99
112
  sdkLicense: e.license,
100
113
  license: e.license,
101
114
  error: e.licenseError,
102
115
  plan: e.licensePlan
103
116
  });
104
- async function Pe(e) {
117
+ async function Ae(e) {
105
118
  const { licenseKey: l, pluginName: t, baseApiUrl: o } = e;
106
119
  try {
107
- return (await ve({
120
+ return (await fe({
108
121
  baseApiUrl: o,
109
122
  path: `/sdk/${l || "na"}`,
110
123
  method: "POST",
@@ -113,14 +126,14 @@ async function Pe(e) {
113
126
  pn: t
114
127
  }
115
128
  })).result || {};
116
- } catch (i) {
117
- return console.error("Error during SDK license check:", i), !1;
129
+ } catch (n) {
130
+ return console.error("Error during SDK license check:", n), !1;
118
131
  }
119
132
  }
120
133
  const z = (e, l) => {
121
134
  var t;
122
135
  return !!((t = e == null ? void 0 : e.hasAttribute) != null && t.call(e, l));
123
- }, Ae = "lightGalleryComponent", Le = E.startup;
136
+ }, Le = "lightGalleryComponent", Ie = E.startup;
124
137
  var S = /* @__PURE__ */ ((e) => (e.image = "image", e.video = "video", e.external = "external", e))(S || {});
125
138
  const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-item`, N = "toggle", L = {
126
139
  image: '<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',
@@ -130,14 +143,14 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
130
143
  external: '<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',
131
144
  eye: '<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'
132
145
  }, F = { propKeys: [], props: {}, traits: [] }, V = (e, l = {}) => {
133
- var i;
146
+ var n;
134
147
  const t = {}, o = [];
135
148
  for (const g in e) {
136
- const { value: c, ...n } = e[g];
137
- o.push({ id: g, name: g, changeProp: !0, category: l.category, ...n }), t[g] = c;
138
- const { subTraits: u = {} } = n;
139
- for (const p in n.subTraits)
140
- (i = u[p]) == null || i.forEach((b) => {
149
+ const { value: c, ...i } = e[g];
150
+ o.push({ id: g, name: g, changeProp: !0, category: l.category, ...i }), t[g] = c;
151
+ const { subTraits: u = {} } = i;
152
+ for (const p in i.subTraits)
153
+ (n = u[p]) == null || n.forEach((b) => {
141
154
  const r = b.id || b.name;
142
155
  t[r] = b.value;
143
156
  });
@@ -148,27 +161,27 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
148
161
  traits: o
149
162
  };
150
163
  }, q = (e, l) => {
151
- const t = e.getTrait(l), o = t.get("category"), i = t.get("subTraits") || {}, c = (Object.values(i).flat() || []).map((p) => p.id || p.name);
164
+ const t = e.getTrait(l), o = t.get("category"), n = t.get("subTraits") || {}, c = (Object.values(n).flat() || []).map((p) => p.id || p.name);
152
165
  e.removeTrait(c);
153
- const n = i[t.getValue()], u = e.getTraitIndex(l) + 1;
154
- n && e.addTrait(
155
- n.map((p) => ({ category: o, ...p })),
166
+ const i = n[t.getValue()], u = e.getTraitIndex(l) + 1;
167
+ i && e.addTrait(
168
+ i.map((p) => ({ category: o, ...p })),
156
169
  { at: u }
157
170
  );
158
171
  }, W = (e, l) => {
159
172
  l.forEach((t) => {
160
173
  const o = e.getTrait(t);
161
174
  if (!o || !o.get("subTraits")) return;
162
- const i = o.changeProp ? `change:${t}` : `change:attributes:${t}`;
163
- e.on(i, () => q(e, t)), q(e, t);
175
+ const n = o.changeProp ? `change:${t}` : `change:attributes:${t}`;
176
+ e.on(n, () => q(e, t)), q(e, t);
164
177
  });
165
- }, Ie = (e, l, t) => {
166
- const i = e.getTrait(l).get("subTraits") || {}, c = (Object.values(i).flat() || []).map((u) => {
178
+ }, Ge = (e, l, t) => {
179
+ const n = e.getTrait(l).get("subTraits") || {}, c = (Object.values(n).flat() || []).map((u) => {
167
180
  const p = u.name || u.id;
168
181
  return u.changeProp ? `change:${p}` : `change:attributes:${p}`;
169
- }), n = Array.from(new Set(c));
170
- n.length && e.on(n.join(" "), t);
171
- }, Ge = {
182
+ }), i = Array.from(new Set(c));
183
+ i.length && e.on(i.join(" "), t);
184
+ }, ke = {
172
185
  // startAnimationDuration: {
173
186
  // type: 'number',
174
187
  // label: 'Start duration',
@@ -282,7 +295,7 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
282
295
  visible: ({ component: e }) => !!e.getTrait("closable").getValue(),
283
296
  value: !0
284
297
  }
285
- }, ke = {
298
+ }, Se = {
286
299
  thumbnail: {
287
300
  category: { id: "thumbnail-options", label: "Thumbnail Options" },
288
301
  type: "checkbox",
@@ -384,7 +397,7 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
384
397
  ]
385
398
  }
386
399
  }
387
- }, Se = {
400
+ }, Ee = {
388
401
  autoplay: {
389
402
  category: { id: "autoplay-options", label: "Autoplay options" },
390
403
  type: "checkbox",
@@ -438,7 +451,7 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
438
451
  ]
439
452
  }
440
453
  }
441
- }, Ee = {
454
+ }, Oe = {
442
455
  zoom: {
443
456
  category: { id: "zoom-options", label: "Zoom options" },
444
457
  type: "checkbox",
@@ -494,7 +507,7 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
494
507
  name: "href",
495
508
  type: "file",
496
509
  label: "Image Source"
497
- }, K = {
510
+ }, H = {
498
511
  name: "data-src",
499
512
  label: "Video Source",
500
513
  placeholder: "https://www.youtube.com/watch?v=..."
@@ -511,16 +524,16 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
511
524
  name: "data-sub-html",
512
525
  placeholder: "My caption",
513
526
  changeProp: !1
514
- }, Oe = {
527
+ }, Me = {
515
528
  [N]: {
516
529
  type: "button",
517
530
  label: "Toggle Gallery",
518
531
  command: (e, l) => {
519
- var i, g;
520
- const t = l.target, o = (i = t == null ? void 0 : t.closestType(A)) == null ? void 0 : i.getView();
532
+ var n, g;
533
+ const t = l.target, o = (n = t == null ? void 0 : t.closestType(A)) == null ? void 0 : n.getView();
521
534
  if (o && t) {
522
- const c = ((g = o.getLightGallery()) == null ? void 0 : g.items) || [], n = Array.from(c).indexOf(t.getEl());
523
- n >= 0 && o.toggleGallery(n);
535
+ const c = ((g = o.getLightGallery()) == null ? void 0 : g.items) || [], i = Array.from(c).indexOf(t.getEl());
536
+ i >= 0 && o.toggleGallery(i);
524
537
  }
525
538
  }
526
539
  },
@@ -531,25 +544,25 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
531
544
  value: "image",
532
545
  subTraits: {
533
546
  image: [J],
534
- video: [K, C],
547
+ video: [H, C],
535
548
  external: [le]
536
549
  },
537
550
  options: [
538
551
  { id: "image", label: J.label || "", icon: L.image },
539
- { id: "video", label: K.label || "", icon: L.video },
552
+ { id: "video", label: H.label || "", icon: L.video },
540
553
  { id: "external", label: le.label || "", icon: L.external }
541
554
  ]
542
555
  },
543
556
  subHtml: pe
544
557
  // This unfortuntaly breaks other thumbnails
545
558
  // customThumb: traitCustomThumb
546
- }, se = "lgThumbnail", Me = "lgVideo", ie = "lgAutoplay", ne = "lgZoom", k = "https://cdn.jsdelivr.net/npm/lightgallery@2.8.2", De = function(e, l = {}) {
547
- const { Blocks: t, Components: o } = e, i = "LightGallery", g = "LightGallery Item", c = {
559
+ }, se = "lgThumbnail", De = "lgVideo", ne = "lgAutoplay", ie = "lgZoom", k = "https://cdn.jsdelivr.net/npm/lightgallery@2.8.2", Ve = function(e, l = {}) {
560
+ const { Blocks: t, Components: o } = e, n = "LightGallery", g = "LightGallery Item", c = {
548
561
  toolbarIconOpen: L.eye,
549
562
  block: {},
550
563
  lgLicenseKey: "92DE1DB8-7986-4F02-B908-514F97678D28",
551
564
  defaultSrc: "https://placehold.co/200/777/white.png?text=Image",
552
- plugins: [se, Me, ie, ne],
565
+ plugins: [se, De, ne, ie],
553
566
  cdnScript: [
554
567
  `${k}/lightgallery.min.js`,
555
568
  `${k}/plugins/thumbnail/lg-thumbnail.min.js`,
@@ -559,7 +572,7 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
559
572
  ],
560
573
  cdnStyle: `${k}/css/lightgallery-bundle.min.css`,
561
574
  ...l
562
- }, { block: n, toolbarIconOpen: u, defaultSrc: p } = c, b = function(a) {
575
+ }, { block: i, toolbarIconOpen: u, defaultSrc: p } = c, b = function(a) {
563
576
  const s = this, h = window, { plugins: y, cdnScript: w, cdnStyle: D, inline: Q, lgLicenseKey: ue, ...m } = a || {}, x = (d) => isNaN(d) ? void 0 : parseInt(d, 10), X = () => {
564
577
  var B;
565
578
  const d = {
@@ -575,13 +588,13 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
575
588
  plugins: (y || []).map(($) => h[$])
576
589
  };
577
590
  Q && (d.container = s, d.closable = !1);
578
- const H = (B = h.lightGallery) == null ? void 0 : B.call(h, s, d);
579
- Q && H.openGallery();
591
+ const K = (B = h.lightGallery) == null ? void 0 : B.call(h, s, d);
592
+ Q && K.openGallery();
580
593
  };
581
594
  if (h.lightGallery)
582
595
  X();
583
596
  else {
584
- const { head: d } = document, H = Array.isArray(w) ? [...w] : [w], B = Array.isArray(D) ? [...D] : [D], $ = (P) => {
597
+ const { head: d } = document, K = Array.isArray(w) ? [...w] : [w], B = Array.isArray(D) ? [...D] : [D], $ = (P) => {
585
598
  if (P.length) {
586
599
  const v = document.createElement("link");
587
600
  v.href = P.shift(), v.rel = "stylesheet", d.appendChild(v), $(P);
@@ -593,7 +606,7 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
593
606
  } else
594
607
  X();
595
608
  };
596
- $(B), Y(H);
609
+ $(B), Y(K);
597
610
  }
598
611
  }, r = (a) => {
599
612
  const s = a.getTrait(N);
@@ -606,10 +619,10 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
606
619
  !h.find((D) => D.id === y.id) && (h == null || h.unshift(y));
607
620
  };
608
621
  let I = [];
609
- const O = c.plugins || [], T = V(Ge), R = O.includes(se) ? V(ke) : F, G = O.includes(ie) ? V(Se) : F, M = O.includes(ne) ? V(Ee) : F;
622
+ const O = c.plugins || [], T = V(ke), R = O.includes(se) ? V(Se) : F, G = O.includes(ne) ? V(Ee) : F, M = O.includes(ie) ? V(Oe) : F;
610
623
  o.addType(A, {
611
- block: n && {
612
- label: i,
624
+ block: i && {
625
+ label: n,
613
626
  media: L.gallery,
614
627
  category: "Extra",
615
628
  select: !0,
@@ -619,7 +632,7 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
619
632
  extendFn: ["init", "initToolbar"],
620
633
  model: {
621
634
  defaults: {
622
- name: i,
635
+ name: n,
623
636
  icon: L.gallery,
624
637
  draggable: (a, s) => !s.is(A),
625
638
  attributes: { [j]: !0 },
@@ -701,7 +714,7 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
701
714
  }
702
715
  }
703
716
  });
704
- const _ = V(Oe);
717
+ const _ = V(Me);
705
718
  o.addType(ae, {
706
719
  isComponent: (a) => z(a, oe) || a.tagName === "A" && z(a.parentElement, j),
707
720
  extendFn: ["init", "initToolbar"],
@@ -717,7 +730,7 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
717
730
  },
718
731
  init() {
719
732
  const a = [f].map((s) => `change:${s}`).join(" ");
720
- this.initSourceType(), this.on(a, this.updateTraits), this.updateTraits({ init: !0 }), this.initScriptUpdate(), Ie(this, f, this.triggerGalleryUpdate);
733
+ this.initSourceType(), this.on(a, this.updateTraits), this.updateTraits({ init: !0 }), this.initScriptUpdate(), Ge(this, f, this.triggerGalleryUpdate);
721
734
  },
722
735
  initToolbar() {
723
736
  r(this);
@@ -736,7 +749,7 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
736
749
  q(this, f);
737
750
  const y = this.getTrait(f).getValue();
738
751
  if (y === S.image) {
739
- this.removeAttributes([K.name, C.name, U]);
752
+ this.removeAttributes([H.name, C.name, U]);
740
753
  const w = this.getTrait(J.name);
741
754
  w.setValue(w.getValue() || p);
742
755
  } else y === S.video ? this.removeAttributes([U]) : y === S.external && this.addAttributes({ [U]: !0 });
@@ -744,19 +757,19 @@ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-
744
757
  },
745
758
  initSourceType() {
746
759
  const a = this.getAttributes({ noClass: !0, noStyle: !0 });
747
- a[U] ? this.set(f, S.external) : (a[K.name] || a[C.name]) && this.set(f, S.video);
760
+ a[U] ? this.set(f, S.external) : (a[H.name] || a[C.name]) && this.set(f, S.video);
748
761
  }
749
762
  }
750
- }), we({
763
+ }), xe({
751
764
  editor: e,
752
- plan: Le,
765
+ plan: Ie,
753
766
  licenseKey: c.licenseKey,
754
- pluginName: Ae,
767
+ pluginName: Le,
755
768
  cleanup: () => {
756
769
  t.remove(A), o.removeType(A);
757
770
  }
758
771
  });
759
- }, Ve = Te(De);
772
+ }, Re = we(Ve);
760
773
  export {
761
- Ve as default
774
+ Re as default
762
775
  };
@@ -1 +1 @@
1
- (function(L,G){typeof exports=="object"&&typeof module<"u"?module.exports=G():typeof define=="function"&&define.amd?define(G):(L=typeof globalThis<"u"?globalThis:L||self,L.StudioSdkPlugins_lightGalleryComponent=G())})(this,function(){"use strict";const L="app.grapesjs.com",G="app-stage.grapesjs.com",Y=[L,"app2.grapesjs.com",G,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ue="license:check:end",ge=()=>typeof window<"u",he=({isDev:e,isStage:l,isPlatform:t})=>`${e?"":`https://${l?G:L}`}/${t?"platform-api":"api"}`,be=()=>{const e=ge()&&window.location.hostname;return!!e&&(Y.includes(e)||Y.some(l=>e.endsWith(l)))};async function de({path:e,baseApiUrl:l,method:t="GET",headers:o={},params:i,body:g}){const n=`${l||he({isDev:!1,isStage:!1})}${e}`,u={method:t,headers:{"Content-Type":"application/json",...o}};g&&(u.body=JSON.stringify(g));const p=i?new URLSearchParams(i).toString():"",b=p?`?${p}`:"",r=await fetch(`${n}${b}`,u);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}var k=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(k||{}),F=(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))(F||{});const ee={[k.free]:0,[k.startup]:10,[k.business]:20,[k.enterprise]:30};function ye(e){const l=e;return l.init=t=>o=>e(o,t),l}const me=e=>ye(e);async function fe({editor:e,plan:l,pluginName:t,licenseKey:o,onLicenseCheckResponse:i,cleanup:g}){let c="",n;const u=r=>{console.warn("Cleanup plugin:",t,"Reason:",r),g()},p=(r={})=>{var M;const{error:O,sdkLicense:V}=r,x=(M=r.plan)==null?void 0:M.category;if(!(V||r.license)||O)u(O||"Invalid license");else if(x){const R=ee[l],K=ee[x];R>K&&u({pluginRequiredPlan:l,licensePlan:x})}};e.Commands.has(F.settings)&&(n=e.runCommand(F.settings),c=(n==null?void 0:n.baseUrl)||"");const b=r=>{i==null||i(r),r&&p(r)};if(!n){e.onReady(async()=>{if(!be())if(o){const r=await Te({licenseKey:o,pluginName:t,baseApiUrl:c});b(r)}else u("The `licenseKey` option not provided")});return}if(n.licensePlan||n.licenseError){const r=ve(n);b(r);return}e.on(ue,r=>b(r))}const ve=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function Te(e){const{licenseKey:l,pluginName:t,baseApiUrl:o}=e;try{return(await de({baseApiUrl:o,path:`/sdk/${l||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const W=(e,l)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,l))},we="lightGalleryComponent",xe=k.startup;var S=(e=>(e.image="image",e.video="video",e.external="external",e))(S||{});const T="lightGallery",te=`${T}-item`,B="data-lightgallery",ae=`${B}-item`,$="toggle",w={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},Z={propKeys:[],props:{},traits:[]},D=(e,l={})=>{var i;const t={},o=[];for(const g in e){const{value:c,...n}=e[g];o.push({id:g,name:g,changeProp:!0,category:l.category,...n}),t[g]=c;const{subTraits:u={}}=n;for(const p in n.subTraits)(i=u[p])==null||i.forEach(b=>{const r=b.id||b.name;t[r]=b.value})}return{propKeys:Object.keys(t),props:t,traits:o}},q=(e,l)=>{const t=e.getTrait(l),o=t.get("category"),i=t.get("subTraits")||{},c=(Object.values(i).flat()||[]).map(p=>p.id||p.name);e.removeTrait(c);const n=i[t.getValue()],u=e.getTraitIndex(l)+1;n&&e.addTrait(n.map(p=>({category:o,...p})),{at:u})},C=(e,l)=>{l.forEach(t=>{const o=e.getTrait(t);if(!o||!o.get("subTraits"))return;const i=o.changeProp?`change:${t}`:`change:attributes:${t}`;e.on(i,()=>q(e,t)),q(e,t)})},Pe=(e,l,t)=>{const i=e.getTrait(l).get("subTraits")||{},c=(Object.values(i).flat()||[]).map(u=>{const p=u.name||u.id;return u.changeProp?`change:${p}`:`change:attributes:${p}`}),n=Array.from(new Set(c));n.length&&e.on(n.join(" "),t)},Ae={[$]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var t,o;return(o=(t=l.target)==null?void 0:t.getView())==null?void 0:o.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0}},Ie={thumbnail:{category:{id:"thumbnail-options",label:"Thumbnail Options"},type:"checkbox",label:"Thumbnails",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"enableThumbDrag",label:"Thumbnail drag",tip:"Enable thumbnail drag on desktop",changeProp:!0,value:!0},{type:"checkbox",name:"enableThumbSwipe",label:"Thumbnail swipe",tip:"Enable thumbnail swipe on mobile devices",changeProp:!0,value:!0},{type:"select",name:"alignThumbnails",tip:"Position of thumbnails when the width of all thumbnails combined is less than the gallery's width",label:"Align Thumbnails",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"select",name:"currentPagerPosition",label:"Select thumbnail position",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"number",name:"thumbMargin",label:"Thumb margin",tip:"Spacing between each thumbnails",changeProp:!0,min:0,value:"5"},{type:"number",name:"thumbWidth",label:"Thumb width",tip:"Width of each thumbnails",changeProp:!0,min:0,value:"100"}]}}},Le={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},Ge={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},y="sourceType",N="data-iframe",J={name:"href",type:"file",label:"Image Source"},j={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},Q={name:"data-poster",label:"Video Poster",type:"file"},oe={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},le={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},ke={[$]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var i,g;const t=l.target,o=(i=t==null?void 0:t.closestType(T))==null?void 0:i.getView();if(o&&t){const c=((g=o.getLightGallery())==null?void 0:g.items)||[],n=Array.from(c).indexOf(t.getEl());n>=0&&o.toggleGallery(n)}}},[y]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[J],video:[j,Q],external:[oe]},options:[{id:"image",label:J.label||"",icon:w.image},{id:"video",label:j.label||"",icon:w.video},{id:"external",label:oe.label||"",icon:w.external}]},subHtml:le},se="lgThumbnail",Se="lgVideo",ie="lgAutoplay",ne="lgZoom",E="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2";return me(function(e,l={}){const{Blocks:t,Components:o}=e,i="LightGallery",g="LightGallery Item",c={toolbarIconOpen:w.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[se,Se,ie,ne],cdnScript:[`${E}/lightgallery.min.js`,`${E}/plugins/thumbnail/lg-thumbnail.min.js`,`${E}/plugins/video/lg-video.min.js`,`${E}/plugins/autoplay/lg-autoplay.min.js`,`${E}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${E}/css/lightgallery-bundle.min.css`,...l},{block:n,toolbarIconOpen:u,defaultSrc:p}=c,b=function(a){const s=this,h=window,{plugins:m,cdnScript:P,cdnStyle:_,inline:re,lgLicenseKey:Ee,...f}=a||{},A=d=>isNaN(d)?void 0:parseInt(d,10),ce=()=>{var H;const d={...f,licenseKey:Ee,speed:A(f.speed),startAnimationDuration:A(f.startAnimationDuration),thumbMargin:A(f.thumbMargin),thumbWidth:A(f.thumbWidth),slideShowInterval:A(f.slideShowInterval),scale:A(f.scale),enableZoomAfter:A(f.enableZoomAfter),plugins:(m||[]).map(z=>h[z])};re&&(d.container=s,d.closable=!1);const X=(H=h.lightGallery)==null?void 0:H.call(h,s,d);re&&X.openGallery()};if(h.lightGallery)ce();else{const{head:d}=document,X=Array.isArray(P)?[...P]:[P],H=Array.isArray(_)?[..._]:[_],z=I=>{if(I.length){const v=document.createElement("link");v.href=I.shift(),v.rel="stylesheet",d.appendChild(v),z(I)}},pe=I=>{if(I.length){const v=document.createElement("script");v.src=I.shift(),v.onerror=v.onload=pe.bind(null,I),d.appendChild(v)}else ce()};z(H),pe(X)}},r=a=>{const s=a.getTrait($);if(!u||!s)return;const{toolbar:h}=a,m={id:$,label:u,command:()=>setTimeout(()=>s.runCommand(),100)};!h.find(_=>_.id===m.id)&&(h==null||h.unshift(m))};let O=[];const V=c.plugins||[],x=D(Ae),U=V.includes(se)?D(Ie):Z,M=V.includes(ie)?D(Le):Z,R=V.includes(ne)?D(Ge):Z;o.addType(T,{block:n&&{label:i,media:w.gallery,category:"Extra",select:!0,...c.block},isComponent:a=>W(a,B),extendFn:["init","initToolbar"],model:{defaults:{name:i,icon:w.gallery,draggable:(a,s)=>!s.is(T),attributes:{[B]:!0},components:{type:te},script:b,selector:"",exThumbImage:"",cdnScript:c.cdnScript,cdnStyle:c.cdnStyle,plugins:c.plugins,lgLicenseKey:c.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...x.propKeys,...U.propKeys,...M.propKeys,...R.propKeys],...x.props,...U.props,...M.props,...R.props,traits:[...x.traits,...U.traits,...M.traits,...R.traits]},init(){C(this,["thumbnail"]),C(this,["autoplay"]),C(this,["zoom"])},initToolbar(){r(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,o.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const a=this.getLightGallery();a==null||a.destroy()},disableLgInCanvas(){const a=this.getLightGallery();a.lgOpened=!0},isInlineGallery(){var s;const a=this.getLightGallery();return((s=a==null?void 0:a.settings)==null?void 0:s.container)===this.el},onLgInit(a){this.el.__lg=a.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:a}=this,{Canvas:s}=a,h=this.getLightGallery();O=s.getSpots(),setTimeout(()=>s.removeSpots()),h.__lgOpened=!0},onLgClose(){const a=this.getLightGallery();O.forEach(s=>this.em.Canvas.addSpot(s.attributes)),O=[],a.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(a){const s=this.getLightGallery();if(s.__lgOpened)return s.closeGallery(!0);s.lgOpened=!1,s.openGallery(a)}}});const K=D(ke);o.addType(te,{isComponent:a=>W(a,ae)||a.tagName==="A"&&W(a.parentElement,B),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:g,icon:w.galleryItem,attributes:{[ae]:!0,href:p},components:{type:"image",attributes:{alt:"Image",src:p}},...K.props,traits:[...K.traits]},init(){const a=[y].map(s=>`change:${s}`).join(" ");this.initSourceType(),this.on(a,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Pe(this,y,this.triggerGalleryUpdate)},initToolbar(){r(this)},initScriptUpdate(){const a=[le.name].map(s=>`change:attributes:${s}`).join(" ");this.on(a,this.triggerGalleryUpdate)},triggerGalleryUpdate(...a){var s;(s=this.closestType(T))==null||s.__scriptPropsChange(...a)},updateTraits(a={}){const{changed:s}=this,{init:h}=a;if(s[y]||h){q(this,y);const m=this.getTrait(y).getValue();if(m===S.image){this.removeAttributes([j.name,Q.name,N]);const P=this.getTrait(J.name);P.setValue(P.getValue()||p)}else m===S.video?this.removeAttributes([N]):m===S.external&&this.addAttributes({[N]:!0})}},initSourceType(){const a=this.getAttributes({noClass:!0,noStyle:!0});a[N]?this.set(y,S.external):(a[j.name]||a[Q.name])&&this.set(y,S.video)}}}),fe({editor:e,plan:xe,licenseKey:c.licenseKey,pluginName:we,cleanup:()=>{t.remove(T),o.removeType(T)}})})});
1
+ (function(L,G){typeof exports=="object"&&typeof module<"u"?module.exports=G():typeof define=="function"&&define.amd?define(G):(L=typeof globalThis<"u"?globalThis:L||self,L.StudioSdkPlugins_lightGalleryComponent=G())})(this,function(){"use strict";const L="app.grapesjs.com",G="app-stage.grapesjs.com",Y=[L,"app2.grapesjs.com",G,"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"],ue="license:check:end",ge=()=>typeof window<"u",he=({isDev:e,isStage:l,isPlatform:t})=>`${e?"":`https://${l?G:L}`}/${t?"platform-api":"api"}`,be=()=>{if(!ge())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},de=()=>{const e=be();return!!e&&(Y.includes(e)||Y.some(l=>e.endsWith(l)))};async function ye({path:e,baseApiUrl:l,method:t="GET",headers:o={},params:n,body:g}){const i=`${l||he({isDev:!1,isStage:!1})}${e}`,u={method:t,headers:{"Content-Type":"application/json",...o}};g&&(u.body=JSON.stringify(g));const p=n?new URLSearchParams(n).toString():"",b=p?`?${p}`:"",r=await fetch(`${i}${b}`,u);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}var k=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(k||{}),F=(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))(F||{});const ee={[k.free]:0,[k.startup]:10,[k.business]:20,[k.enterprise]:30};function me(e){const l=e;return l.init=t=>o=>e(o,t),l}const fe=e=>me(e);async function ve({editor:e,plan:l,pluginName:t,licenseKey:o,onLicenseCheckResponse:n,cleanup:g}){let c="",i;const u=r=>{console.warn("Cleanup plugin:",t,"Reason:",r),g()},p=(r={})=>{var M;const{error:O,sdkLicense:V}=r,x=(M=r.plan)==null?void 0:M.category;if(!(V||r.license)||O)u(O||"Invalid license");else if(x){const R=ee[l],H=ee[x];R>H&&u({pluginRequiredPlan:l,licensePlan:x})}};e.Commands.has(F.settings)&&(i=e.runCommand(F.settings),c=(i==null?void 0:i.baseUrl)||"");const b=r=>{n==null||n(r),r&&p(r)};if(!i){e.onReady(async()=>{if(!de())if(o){const r=await we({licenseKey:o,pluginName:t,baseApiUrl:c});b(r)}else u("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const r=Te(i);b(r);return}e.on(ue,r=>b(r))}const Te=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function we(e){const{licenseKey:l,pluginName:t,baseApiUrl:o}=e;try{return(await ye({baseApiUrl:o,path:`/sdk/${l||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const W=(e,l)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,l))},xe="lightGalleryComponent",Pe=k.startup;var S=(e=>(e.image="image",e.video="video",e.external="external",e))(S||{});const T="lightGallery",te=`${T}-item`,B="data-lightgallery",ae=`${B}-item`,$="toggle",w={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},Z={propKeys:[],props:{},traits:[]},D=(e,l={})=>{var n;const t={},o=[];for(const g in e){const{value:c,...i}=e[g];o.push({id:g,name:g,changeProp:!0,category:l.category,...i}),t[g]=c;const{subTraits:u={}}=i;for(const p in i.subTraits)(n=u[p])==null||n.forEach(b=>{const r=b.id||b.name;t[r]=b.value})}return{propKeys:Object.keys(t),props:t,traits:o}},q=(e,l)=>{const t=e.getTrait(l),o=t.get("category"),n=t.get("subTraits")||{},c=(Object.values(n).flat()||[]).map(p=>p.id||p.name);e.removeTrait(c);const i=n[t.getValue()],u=e.getTraitIndex(l)+1;i&&e.addTrait(i.map(p=>({category:o,...p})),{at:u})},C=(e,l)=>{l.forEach(t=>{const o=e.getTrait(t);if(!o||!o.get("subTraits"))return;const n=o.changeProp?`change:${t}`:`change:attributes:${t}`;e.on(n,()=>q(e,t)),q(e,t)})},Ae=(e,l,t)=>{const n=e.getTrait(l).get("subTraits")||{},c=(Object.values(n).flat()||[]).map(u=>{const p=u.name||u.id;return u.changeProp?`change:${p}`:`change:attributes:${p}`}),i=Array.from(new Set(c));i.length&&e.on(i.join(" "),t)},Ie={[$]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var t,o;return(o=(t=l.target)==null?void 0:t.getView())==null?void 0:o.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0}},Le={thumbnail:{category:{id:"thumbnail-options",label:"Thumbnail Options"},type:"checkbox",label:"Thumbnails",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"enableThumbDrag",label:"Thumbnail drag",tip:"Enable thumbnail drag on desktop",changeProp:!0,value:!0},{type:"checkbox",name:"enableThumbSwipe",label:"Thumbnail swipe",tip:"Enable thumbnail swipe on mobile devices",changeProp:!0,value:!0},{type:"select",name:"alignThumbnails",tip:"Position of thumbnails when the width of all thumbnails combined is less than the gallery's width",label:"Align Thumbnails",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"select",name:"currentPagerPosition",label:"Select thumbnail position",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"number",name:"thumbMargin",label:"Thumb margin",tip:"Spacing between each thumbnails",changeProp:!0,min:0,value:"5"},{type:"number",name:"thumbWidth",label:"Thumb width",tip:"Width of each thumbnails",changeProp:!0,min:0,value:"100"}]}}},Ge={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},ke={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},y="sourceType",N="data-iframe",J={name:"href",type:"file",label:"Image Source"},j={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},Q={name:"data-poster",label:"Video Poster",type:"file"},oe={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},le={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Se={[$]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var n,g;const t=l.target,o=(n=t==null?void 0:t.closestType(T))==null?void 0:n.getView();if(o&&t){const c=((g=o.getLightGallery())==null?void 0:g.items)||[],i=Array.from(c).indexOf(t.getEl());i>=0&&o.toggleGallery(i)}}},[y]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[J],video:[j,Q],external:[oe]},options:[{id:"image",label:J.label||"",icon:w.image},{id:"video",label:j.label||"",icon:w.video},{id:"external",label:oe.label||"",icon:w.external}]},subHtml:le},se="lgThumbnail",Ee="lgVideo",ne="lgAutoplay",ie="lgZoom",E="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2";return fe(function(e,l={}){const{Blocks:t,Components:o}=e,n="LightGallery",g="LightGallery Item",c={toolbarIconOpen:w.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[se,Ee,ne,ie],cdnScript:[`${E}/lightgallery.min.js`,`${E}/plugins/thumbnail/lg-thumbnail.min.js`,`${E}/plugins/video/lg-video.min.js`,`${E}/plugins/autoplay/lg-autoplay.min.js`,`${E}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${E}/css/lightgallery-bundle.min.css`,...l},{block:i,toolbarIconOpen:u,defaultSrc:p}=c,b=function(a){const s=this,h=window,{plugins:m,cdnScript:P,cdnStyle:_,inline:re,lgLicenseKey:Oe,...f}=a||{},A=d=>isNaN(d)?void 0:parseInt(d,10),ce=()=>{var K;const d={...f,licenseKey:Oe,speed:A(f.speed),startAnimationDuration:A(f.startAnimationDuration),thumbMargin:A(f.thumbMargin),thumbWidth:A(f.thumbWidth),slideShowInterval:A(f.slideShowInterval),scale:A(f.scale),enableZoomAfter:A(f.enableZoomAfter),plugins:(m||[]).map(z=>h[z])};re&&(d.container=s,d.closable=!1);const X=(K=h.lightGallery)==null?void 0:K.call(h,s,d);re&&X.openGallery()};if(h.lightGallery)ce();else{const{head:d}=document,X=Array.isArray(P)?[...P]:[P],K=Array.isArray(_)?[..._]:[_],z=I=>{if(I.length){const v=document.createElement("link");v.href=I.shift(),v.rel="stylesheet",d.appendChild(v),z(I)}},pe=I=>{if(I.length){const v=document.createElement("script");v.src=I.shift(),v.onerror=v.onload=pe.bind(null,I),d.appendChild(v)}else ce()};z(K),pe(X)}},r=a=>{const s=a.getTrait($);if(!u||!s)return;const{toolbar:h}=a,m={id:$,label:u,command:()=>setTimeout(()=>s.runCommand(),100)};!h.find(_=>_.id===m.id)&&(h==null||h.unshift(m))};let O=[];const V=c.plugins||[],x=D(Ie),U=V.includes(se)?D(Le):Z,M=V.includes(ne)?D(Ge):Z,R=V.includes(ie)?D(ke):Z;o.addType(T,{block:i&&{label:n,media:w.gallery,category:"Extra",select:!0,...c.block},isComponent:a=>W(a,B),extendFn:["init","initToolbar"],model:{defaults:{name:n,icon:w.gallery,draggable:(a,s)=>!s.is(T),attributes:{[B]:!0},components:{type:te},script:b,selector:"",exThumbImage:"",cdnScript:c.cdnScript,cdnStyle:c.cdnStyle,plugins:c.plugins,lgLicenseKey:c.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...x.propKeys,...U.propKeys,...M.propKeys,...R.propKeys],...x.props,...U.props,...M.props,...R.props,traits:[...x.traits,...U.traits,...M.traits,...R.traits]},init(){C(this,["thumbnail"]),C(this,["autoplay"]),C(this,["zoom"])},initToolbar(){r(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,o.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const a=this.getLightGallery();a==null||a.destroy()},disableLgInCanvas(){const a=this.getLightGallery();a.lgOpened=!0},isInlineGallery(){var s;const a=this.getLightGallery();return((s=a==null?void 0:a.settings)==null?void 0:s.container)===this.el},onLgInit(a){this.el.__lg=a.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:a}=this,{Canvas:s}=a,h=this.getLightGallery();O=s.getSpots(),setTimeout(()=>s.removeSpots()),h.__lgOpened=!0},onLgClose(){const a=this.getLightGallery();O.forEach(s=>this.em.Canvas.addSpot(s.attributes)),O=[],a.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(a){const s=this.getLightGallery();if(s.__lgOpened)return s.closeGallery(!0);s.lgOpened=!1,s.openGallery(a)}}});const H=D(Se);o.addType(te,{isComponent:a=>W(a,ae)||a.tagName==="A"&&W(a.parentElement,B),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:g,icon:w.galleryItem,attributes:{[ae]:!0,href:p},components:{type:"image",attributes:{alt:"Image",src:p}},...H.props,traits:[...H.traits]},init(){const a=[y].map(s=>`change:${s}`).join(" ");this.initSourceType(),this.on(a,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Ae(this,y,this.triggerGalleryUpdate)},initToolbar(){r(this)},initScriptUpdate(){const a=[le.name].map(s=>`change:attributes:${s}`).join(" ");this.on(a,this.triggerGalleryUpdate)},triggerGalleryUpdate(...a){var s;(s=this.closestType(T))==null||s.__scriptPropsChange(...a)},updateTraits(a={}){const{changed:s}=this,{init:h}=a;if(s[y]||h){q(this,y);const m=this.getTrait(y).getValue();if(m===S.image){this.removeAttributes([j.name,Q.name,N]);const P=this.getTrait(J.name);P.setValue(P.getValue()||p)}else m===S.video?this.removeAttributes([N]):m===S.external&&this.addAttributes({[N]:!0})}},initSourceType(){const a=this.getAttributes({noClass:!0,noStyle:!0});a[N]?this.set(y,S.external):(a[j.name]||a[Q.name])&&this.set(y,S.video)}}}),ve({editor:e,plan:Pe,licenseKey:c.licenseKey,pluginName:xe,cleanup:()=>{t.remove(T),o.removeType(T)}})})});
@@ -1,4 +1,4 @@
1
- "use strict";const w="app.grapesjs.com",D="app-stage.grapesjs.com",G="app2.grapesjs.com",k="app-stage2.grapesjs.com",P=[w,G,D,k,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],I="license:check:end",L=()=>typeof window<"u",x=({isDev:e,isStage:o,isPlatform:a})=>`${e?"":`https://${o?D:w}`}/${a?"platform-api":"api"}`,E=()=>{const e=L()&&window.location.hostname;return!!e&&(P.includes(e)||P.some(o=>e.endsWith(o)))};async function M({path:e,baseApiUrl:o,method:a="GET",headers:r={},params:i,body:g}){const n=`${o||x({isDev:!1,isStage:!1})}${e}`,c={method:a,headers:{"Content-Type":"application/json",...r}};g&&(c.body=JSON.stringify(g));const d=i?new URLSearchParams(i).toString():"",u=d?`?${d}`:"",s=await fetch(`${n}${u}`,c);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return s.json()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{}),T=(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))(T||{});const A={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function N(e){const o=e;return o.init=a=>r=>e(r,a),o}const O=e=>N(e);async function B({editor:e,plan:o,pluginName:a,licenseKey:r,onLicenseCheckResponse:i,cleanup:g}){let p="",n;const c=s=>{console.warn("Cleanup plugin:",a,"Reason:",s),g()},d=(s={})=>{var y;const{error:f,sdkLicense:t}=s,l=(y=s.plan)==null?void 0:y.category;if(!(t||s.license)||f)c(f||"Invalid license");else if(l){const v=A[o],R=A[l];v>R&&c({pluginRequiredPlan:o,licensePlan:l})}};e.Commands.has(T.settings)&&(n=e.runCommand(T.settings),p=(n==null?void 0:n.baseUrl)||"");const u=s=>{i==null||i(s),s&&d(s)};if(!n){e.onReady(async()=>{if(!E())if(r){const s=await $({licenseKey:r,pluginName:a,baseApiUrl:p});u(s)}else c("The `licenseKey` option not provided")});return}if(n.licensePlan||n.licenseError){const s=U(n);u(s);return}e.on(I,s=>u(s))}const U=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function $(e){const{licenseKey:o,pluginName:a,baseApiUrl:r}=e;try{return(await M({baseApiUrl:r,path:`/sdk/${o||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const j="linkImageComponent",_=b.startup,F=function(e,o={}){const{Components:a,Blocks:r}=e,i="link-image",g="Link Image",p="link-image",{model:n,view:c}=e.Components.getType("image"),d=a.getType("link").model.getDefaults().traits,u=n.getDefaults().traits,s=d.filter(t=>t!=="title"),f=u.filter(t=>t.name!=="customAttributes").map(t=>typeof t=="string"?{name:t}:t).map(t=>({...t,getValue({component:l}){var h;return(h=l.components().at(0).getTrait(t.name))==null?void 0:h.getValue()},setValue({component:l,value:h,options:y}){var v;(v=l.components().at(0).getTrait(t.name))==null||v.setValue(h,y)}}));a.addType(i,{isComponent:t=>{var l;return t.tagName==="A"&&((l=t.children)==null?void 0:l.length)===1&&t.children[0].tagName==="IMG"},block:{label:g,media:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M2 6.3A2.3 2.3 0 0 1 4.3 4h15.4A2.3 2.3 0 0 1 22 6.3v7a4.7 4.7 0 0 0-2.8-.8h-3.4a4.8 4.8 0 0 0-4 7.5H4.3A2.3 2.3 0 0 1 2 17.7zm21 11a3.8 3.8 0 0 0-3.8-3.8.8.8 0 0 0 0 1.5h.2a2.3 2.3 0 0 1-.1 4.5H19a.8.8 0 0 0 .2 1.5h.2a3.8 3.8 0 0 0 3.5-3.8m-6.5-3a.8.8 0 0 0-.8-.7h-.1a3.8 3.8 0 0 0 .2 7.5.8.8 0 0 0 0-1.5h-.2a2.3 2.3 0 0 1 .2-4.5.8.8 0 0 0 .7-.7m3.5 3a.8.8 0 0 0-.8-.8h-3.6a.8.8 0 0 0 .2 1.5h3.6a.8.8 0 0 0 .6-.8"/></svg>'},extend:"link",extendFn:["init"],model:{defaults:{name:g,classes:p,resizable:{ratioDefault:!0},traits:[...f,...s],droppable:!1,stylable:["width","min-width","max-width","height","min-height","max-height","padding","margin","position","border-radius","border-width","border-style","border-color","opacity","box-shadow","filter","transform"],components:{type:"image"},styles:`
1
+ "use strict";const w="app.grapesjs.com",D="app-stage.grapesjs.com",G="app2.grapesjs.com",k="app-stage2.grapesjs.com",P=[w,G,D,k,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],I="license:check:end",L=()=>typeof window<"u",x=({isDev:e,isStage:s,isPlatform:a})=>`${e?"":`https://${s?D:w}`}/${a?"platform-api":"api"}`,E=()=>{if(!L())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},M=()=>{const e=E();return!!e&&(P.includes(e)||P.some(s=>e.endsWith(s)))};async function N({path:e,baseApiUrl:s,method:a="GET",headers:r={},params:n,body:g}){const i=`${s||x({isDev:!1,isStage:!1})}${e}`,c={method:a,headers:{"Content-Type":"application/json",...r}};g&&(c.body=JSON.stringify(g));const d=n?new URLSearchParams(n).toString():"",u=d?`?${d}`:"",o=await fetch(`${i}${u}`,c);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{}),T=(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))(T||{});const A={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function O(e){const s=e;return s.init=a=>r=>e(r,a),s}const B=e=>O(e);async function U({editor:e,plan:s,pluginName:a,licenseKey:r,onLicenseCheckResponse:n,cleanup:g}){let p="",i;const c=o=>{console.warn("Cleanup plugin:",a,"Reason:",o),g()},d=(o={})=>{var y;const{error:f,sdkLicense:t}=o,l=(y=o.plan)==null?void 0:y.category;if(!(t||o.license)||f)c(f||"Invalid license");else if(l){const v=A[s],R=A[l];v>R&&c({pluginRequiredPlan:s,licensePlan:l})}};e.Commands.has(T.settings)&&(i=e.runCommand(T.settings),p=(i==null?void 0:i.baseUrl)||"");const u=o=>{n==null||n(o),o&&d(o)};if(!i){e.onReady(async()=>{if(!M())if(r){const o=await j({licenseKey:r,pluginName:a,baseApiUrl:p});u(o)}else c("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const o=$(i);u(o);return}e.on(I,o=>u(o))}const $=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function j(e){const{licenseKey:s,pluginName:a,baseApiUrl:r}=e;try{return(await N({baseApiUrl:r,path:`/sdk/${s||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const _="linkImageComponent",F=b.startup,W=function(e,s={}){const{Components:a,Blocks:r}=e,n="link-image",g="Link Image",p="link-image",{model:i,view:c}=e.Components.getType("image"),d=a.getType("link").model.getDefaults().traits,u=i.getDefaults().traits,o=d.filter(t=>t!=="title"),f=u.filter(t=>t.name!=="customAttributes").map(t=>typeof t=="string"?{name:t}:t).map(t=>({...t,getValue({component:l}){var h;return(h=l.components().at(0).getTrait(t.name))==null?void 0:h.getValue()},setValue({component:l,value:h,options:y}){var v;(v=l.components().at(0).getTrait(t.name))==null||v.setValue(h,y)}}));a.addType(n,{isComponent:t=>{var l;return t.tagName==="A"&&((l=t.children)==null?void 0:l.length)===1&&t.children[0].tagName==="IMG"},block:{label:g,media:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M2 6.3A2.3 2.3 0 0 1 4.3 4h15.4A2.3 2.3 0 0 1 22 6.3v7a4.7 4.7 0 0 0-2.8-.8h-3.4a4.8 4.8 0 0 0-4 7.5H4.3A2.3 2.3 0 0 1 2 17.7zm21 11a3.8 3.8 0 0 0-3.8-3.8.8.8 0 0 0 0 1.5h.2a2.3 2.3 0 0 1-.1 4.5H19a.8.8 0 0 0 .2 1.5h.2a3.8 3.8 0 0 0 3.5-3.8m-6.5-3a.8.8 0 0 0-.8-.7h-.1a3.8 3.8 0 0 0 .2 7.5.8.8 0 0 0 0-1.5h-.2a2.3 2.3 0 0 1 .2-4.5.8.8 0 0 0 .7-.7m3.5 3a.8.8 0 0 0-.8-.8h-3.6a.8.8 0 0 0 .2 1.5h3.6a.8.8 0 0 0 .6-.8"/></svg>'},extend:"link",extendFn:["init"],model:{defaults:{name:g,classes:p,resizable:{ratioDefault:!0},traits:[...f,...o],droppable:!1,stylable:["width","min-width","max-width","height","min-height","max-height","padding","margin","position","border-radius","border-width","border-style","border-color","opacity","box-shadow","filter","transform"],components:{type:"image"},styles:`
2
2
  .${p} {
3
3
  display: inline-block;
4
4
  overflow: hidden;
@@ -9,4 +9,4 @@
9
9
  width: 100%;
10
10
  height: 100%;
11
11
  }
12
- `},init(){const t=this.components().at(0);t==null||t.set({layerable:!1,locked:!0})}},view:{onActive(t){c.prototype.onActive.call(this,t)}}}),B({editor:e,licenseKey:o.licenseKey,plan:_,pluginName:j,cleanup:()=>{a.removeType(i),r.remove(i)}})},W=O(F);module.exports=W;
12
+ `},init(){const t=this.components().at(0);t==null||t.set({layerable:!1,locked:!0})}},view:{onActive(t){c.prototype.onActive.call(this,t)}}}),U({editor:e,licenseKey:s.licenseKey,plan:F,pluginName:_,cleanup:()=>{a.removeType(n),r.remove(n)}})},H=B(W);module.exports=H;