@grapesjs/studio-sdk-plugins 1.0.19-rc.0 → 1.0.19

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 (70) hide show
  1. package/dist/accordionComponent/index.cjs.js +2 -2
  2. package/dist/accordionComponent/index.es.js +12 -12
  3. package/dist/accordionComponent/index.umd.js +2 -2
  4. package/dist/accordionComponent/shared.d.ts +3 -0
  5. package/dist/canvasEmptyState/index.cjs.js +1 -1
  6. package/dist/canvasEmptyState/index.es.js +25 -25
  7. package/dist/canvasEmptyState/index.umd.js +1 -1
  8. package/dist/canvasEmptyState/shared.d.ts +3 -0
  9. package/dist/canvasFullSize/index.cjs.js +2 -2
  10. package/dist/canvasFullSize/index.es.js +26 -26
  11. package/dist/canvasFullSize/index.umd.js +2 -2
  12. package/dist/canvasFullSize/shared.d.ts +3 -0
  13. package/dist/canvasGridMode/index.cjs.js +2 -2
  14. package/dist/canvasGridMode/index.es.js +42 -42
  15. package/dist/canvasGridMode/index.umd.js +2 -2
  16. package/dist/canvasGridMode/shared.d.ts +3 -0
  17. package/dist/canvasGridMode/utils.d.ts +0 -1
  18. package/dist/flexComponent/index.cjs.js +6 -6
  19. package/dist/flexComponent/index.es.js +40 -40
  20. package/dist/flexComponent/index.umd.js +6 -6
  21. package/dist/flexComponent/shared.d.ts +3 -0
  22. package/dist/fsLightboxComponent/index.cjs.js +2 -2
  23. package/dist/fsLightboxComponent/index.es.js +28 -28
  24. package/dist/fsLightboxComponent/index.umd.js +2 -2
  25. package/dist/fsLightboxComponent/shared.d.ts +3 -0
  26. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  27. package/dist/googleFontsAssetProvider/index.es.js +97 -77
  28. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  29. package/dist/googleFontsAssetProvider/utils.d.ts +1 -1
  30. package/dist/iconifyComponent/index.cjs.js +2 -2
  31. package/dist/iconifyComponent/index.es.js +149 -149
  32. package/dist/iconifyComponent/index.umd.js +2 -2
  33. package/dist/iconifyComponent/shared.d.ts +3 -0
  34. package/dist/index.cjs.js +35 -35
  35. package/dist/index.es.js +1667 -1644
  36. package/dist/index.umd.js +29 -29
  37. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  38. package/dist/layoutSidebarButtons/index.es.js +14 -14
  39. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  40. package/dist/layoutSidebarButtons/shared.d.ts +3 -0
  41. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  42. package/dist/lightGalleryComponent/index.es.js +45 -45
  43. package/dist/lightGalleryComponent/index.umd.js +1 -1
  44. package/dist/lightGalleryComponent/shared.d.ts +3 -0
  45. package/dist/listPagesComponent/index.cjs.js +3 -3
  46. package/dist/listPagesComponent/index.es.js +63 -62
  47. package/dist/listPagesComponent/index.umd.js +3 -3
  48. package/dist/listPagesComponent/shared.d.ts +3 -0
  49. package/dist/prosemirror/index.cjs.js +7 -7
  50. package/dist/prosemirror/index.es.js +437 -436
  51. package/dist/prosemirror/index.umd.js +1 -1
  52. package/dist/prosemirror/shared.d.ts +3 -0
  53. package/dist/rteTinyMce/index.cjs.js +2 -2
  54. package/dist/rteTinyMce/index.es.js +33 -33
  55. package/dist/rteTinyMce/index.umd.js +2 -2
  56. package/dist/rteTinyMce/shared.d.ts +3 -0
  57. package/dist/swiperComponent/index.cjs.js +1 -1
  58. package/dist/swiperComponent/index.es.js +4 -4
  59. package/dist/swiperComponent/index.umd.js +3 -3
  60. package/dist/swiperComponent/shared.d.ts +3 -0
  61. package/dist/tableComponent/index.cjs.js +1 -1
  62. package/dist/tableComponent/index.es.js +58 -57
  63. package/dist/tableComponent/index.umd.js +1 -1
  64. package/dist/tableComponent/shared.d.ts +3 -0
  65. package/dist/types.d.ts +2 -1
  66. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  67. package/dist/youtubeAssetProvider/index.es.js +63 -62
  68. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  69. package/dist/youtubeAssetProvider/shared.d.ts +3 -0
  70. package/package.json +1 -1
@@ -103,13 +103,13 @@ async function Ee(n) {
103
103
  const ge = (n) => (e) => {
104
104
  var t;
105
105
  return ((t = e.getAttribute) == null ? void 0 : t.call(e, ne)) === n;
106
- }, Ge = (...n) => (e) => n.some((t) => e.is(t)), Te = (...n) => (e, t) => n.some((s) => t.is(s)), fe = "gjs-plg-", ne = "data-type-role", j = class j {
106
+ }, Ge = (...n) => (e) => n.some((t) => e.is(t)), Te = (...n) => (e, t) => n.some((s) => t.is(s)), fe = "gjs-plg-", ne = "data-type-role", N = class N {
107
107
  constructor(e) {
108
108
  this.config = e;
109
109
  }
110
110
  getSize(e) {
111
111
  var t;
112
- return (t = this.config) != null && t.getSize ? this.config.getSize(e) : se(e.componentColumn, j.CSS_FLEX_BASIS);
112
+ return (t = this.config) != null && t.getSize ? this.config.getSize(e) : se(e.componentColumn, N.CSS_FLEX_BASIS);
113
113
  }
114
114
  setSize(e) {
115
115
  var t;
@@ -117,13 +117,13 @@ const ge = (n) => (e) => {
117
117
  this.config.setSize(e);
118
118
  else {
119
119
  const { componentColumn: s, sizeValue: i, partial: a } = e;
120
- s.addStyle({ [j.CSS_FLEX_BASIS]: i }, { partial: a });
120
+ s.addStyle({ [N.CSS_FLEX_BASIS]: i }, { partial: a });
121
121
  }
122
122
  }
123
123
  };
124
- j.CSS_FLEX_BASIS = "flex-basis";
125
- let K = j;
126
- const N = class N {
124
+ N.CSS_FLEX_BASIS = "flex-basis";
125
+ let K = N;
126
+ const j = class j {
127
127
  constructor(e) {
128
128
  this.config = e;
129
129
  }
@@ -132,7 +132,7 @@ const N = class N {
132
132
  }
133
133
  getGap(e) {
134
134
  var t;
135
- return (t = this.config) != null && t.getGap ? this.config.getGap(e) : se(e.componentRow, N.CSS_GAP);
135
+ return (t = this.config) != null && t.getGap ? this.config.getGap(e) : se(e.componentRow, j.CSS_GAP);
136
136
  }
137
137
  setGap(e) {
138
138
  var t;
@@ -140,12 +140,12 @@ const N = class N {
140
140
  this.config.setGap(e);
141
141
  else {
142
142
  const { componentRow: s, gapValue: i, partial: a } = e;
143
- s.addStyle({ [N.CSS_GAP]: i }, { partial: a });
143
+ s.addStyle({ [j.CSS_GAP]: i }, { partial: a });
144
144
  }
145
145
  }
146
146
  };
147
- N.CSS_GAP = "gap";
148
- let J = N;
147
+ j.CSS_GAP = "gap";
148
+ let J = j;
149
149
  const Y = class Y {
150
150
  constructor(e) {
151
151
  this.config = e;
@@ -240,16 +240,16 @@ class Le {
240
240
  return (t = this.config) != null && t.isParentVertical ? this.config.isParentVertical(e) : !1;
241
241
  }
242
242
  }
243
- class H {
243
+ class A {
244
244
  constructor() {
245
245
  this.handlerCache = /* @__PURE__ */ new Map();
246
246
  }
247
247
  static getInstance() {
248
- return H.instance || (H.instance = new H()), H.instance;
248
+ return A.instance || (A.instance = new A()), A.instance;
249
249
  }
250
250
  getHandlers(e) {
251
251
  const t = `${e.projectType}-${e.disableGapHandler ? "nogap" : "gap"}`;
252
- return this.handlerCache.has(t) || (A(e) ? this.handlerCache.set(t, {
252
+ return this.handlerCache.has(t) || (H(e) ? this.handlerCache.set(t, {
253
253
  sizeHandler: new Z(e),
254
254
  gapHandler: new Q(e),
255
255
  parentSizeHandler: new Le(e)
@@ -261,19 +261,19 @@ class H {
261
261
  }
262
262
  }
263
263
  function G(n) {
264
- return H.getInstance().getHandlers(n);
264
+ return A.getInstance().getHandlers(n);
265
265
  }
266
266
  const oe = (n) => {
267
267
  n.style.display = "none";
268
268
  }, re = (n) => {
269
269
  n.style.display = "block";
270
- }, V = (n) => +parseFloat(`${n}`).toFixed(2), A = (n) => n.projectType === he.email, k = (n, e) => {
270
+ }, V = (n) => +parseFloat(`${n}`).toFixed(2), H = (n) => n.projectType === he.email, k = (n, e) => {
271
271
  const t = n.Canvas.getFramesEl();
272
272
  t && (t.style.pointerEvents = e ? "none" : "");
273
- }, $e = (n) => n ? ["top", "bottom"] : ["left", "right"], He = (n) => {
273
+ }, $e = (n) => n ? ["top", "bottom"] : ["left", "right"], Ae = (n) => {
274
274
  const e = n.parent();
275
275
  return e ? e.components().models.indexOf(n) === 0 : !1;
276
- }, Ae = (n) => {
276
+ }, He = (n) => {
277
277
  const e = n.parent();
278
278
  if (!e) return !1;
279
279
  const t = e.components().models;
@@ -286,7 +286,7 @@ const oe = (n) => {
286
286
  }, Me = (n, e, t, s) => {
287
287
  const a = n + (t ? e === "top" ? -1 : e === "bottom" ? 1 : 0 : e === "left" ? -1 : e === "right" ? 1 : 0);
288
288
  return a >= 0 && a < s ? a : -1;
289
- }, O = (n) => n === "top" || n === "bottom", je = (n, e) => !!(He(n) && (e === "left" || e === "top") || Ae(n) && (e === "right" || e === "bottom")), Ne = (n) => {
289
+ }, O = (n) => n === "top" || n === "bottom", Ne = (n, e) => !!(Ae(n) && (e === "left" || e === "top") || He(n) && (e === "right" || e === "bottom")), je = (n) => {
290
290
  const e = n.parent();
291
291
  return e ? e.components().models.length > 1 : !1;
292
292
  }, ce = (n, e) => n === "right" || n === "bottom" ? e > 0 : e < 0, se = (n, e, t = !1) => {
@@ -325,7 +325,7 @@ const oe = (n) => {
325
325
  };
326
326
  function Fe(n, e) {
327
327
  const { Blocks: t } = n, { typeColumn: s, typeRow: i, blocks: a } = e;
328
- if (a === !1 || A(e)) return;
328
+ if (a === !1 || H(e)) return;
329
329
  const o = (u) => ({
330
330
  type: i,
331
331
  components: u.map((f) => ({
@@ -361,7 +361,7 @@ function Fe(n, e) {
361
361
  }
362
362
  const Be = (n, e) => {
363
363
  const { Components: t } = n, { typeRow: s, typeColumn: i, extendTypeColumn: a } = e, o = `${fe}${i}`, c = !!i && !!t.getType(i) && !a;
364
- if (!(!i || c || A(e)))
364
+ if (!(!i || c || H(e)))
365
365
  return t.addType(i, {
366
366
  isComponent: ge(i),
367
367
  model: {
@@ -385,7 +385,7 @@ const Be = (n, e) => {
385
385
  };
386
386
  }, De = (n, e) => {
387
387
  const { Components: t } = n, { typeRow: s, typeColumn: i, extendTypeRow: a } = e, o = `${fe}${s}`, c = !!s && !!t.getType(s) && !a;
388
- if (!(!s || c || A(e)))
388
+ if (!(!s || c || H(e)))
389
389
  return t.addType(s, {
390
390
  isComponent: ge(s),
391
391
  model: {
@@ -453,8 +453,8 @@ const Be = (n, e) => {
453
453
  }), () => {
454
454
  t.removeType(s);
455
455
  };
456
- };
457
- class ke {
456
+ }, ke = "flexComponent", Oe = $.startup;
457
+ class Xe {
458
458
  constructor() {
459
459
  this.resizableChildTypes = /* @__PURE__ */ new Set(), this.gapAdjustableParentTypes = /* @__PURE__ */ new Set(), this.typeRelationships = /* @__PURE__ */ new Map();
460
460
  }
@@ -478,7 +478,7 @@ class ke {
478
478
  return this.typeRelationships.has(s) ? this.typeRelationships.get(s).has(i) : !1;
479
479
  }
480
480
  }
481
- class Oe {
481
+ class Ye {
482
482
  constructor(e, t, s) {
483
483
  this.editor = e, this.registry = t, this.opts = s, this.resizeState = /* @__PURE__ */ new WeakMap();
484
484
  }
@@ -534,7 +534,7 @@ class Oe {
534
534
  } else z >= b && x >= b && (i.lastSnappedPercent = void 0);
535
535
  }
536
536
  }
537
- class Xe {
537
+ class Ue {
538
538
  constructor(e, t, s) {
539
539
  this.editor = e, this.registry = t, this.opts = s;
540
540
  }
@@ -556,9 +556,9 @@ class Xe {
556
556
  _e(e, this.opts);
557
557
  }
558
558
  }
559
- class Ye {
559
+ class We {
560
560
  constructor(e, t, s) {
561
- this.editor = e, this.registry = t, this.opts = s, this.resizeHandler = new Oe(e, t, s), this.gapHandler = new Xe(e, t, s);
561
+ this.editor = e, this.registry = t, this.opts = s, this.resizeHandler = new Ye(e, t, s), this.gapHandler = new Ue(e, t, s);
562
562
  }
563
563
  startResize(e, t, s) {
564
564
  this.resizeHandler.startResize(e, t, s);
@@ -583,11 +583,11 @@ class Ye {
583
583
  return this.registry.isGapAdjustableParent(e);
584
584
  }
585
585
  }
586
- const X = "gs-flex-spots", pe = `${X}__handle-size`, Ue = `${X}__handle-gap`;
587
- function We(n, e) {
586
+ const X = "gs-flex-spots", pe = `${X}__handle-size`, Ke = `${X}__handle-gap`;
587
+ function Je(n, e) {
588
588
  const { Canvas: t } = n, s = "flex-resize-spot";
589
589
  let i, a, o, l, c = null, g = null;
590
- const p = new ke(), u = new Ye(n, p, e), f = () => {
590
+ const p = new Xe(), u = new We(n, p, e), f = () => {
591
591
  var r;
592
592
  i = document.createElement("div"), i.className = X, i.style.display = "none", a = document.createElement("div"), a.className = `${X}__handles`, a.style.position = "absolute", a.style.pointerEvents = "none", a.style.zIndex = "21", o = {
593
593
  left: document.createElement("div"),
@@ -607,7 +607,7 @@ function We(n, e) {
607
607
  ${y === "top" ? "top: 0px;" : ""}
608
608
  ${y === "bottom" ? "bottom: 0px;" : ""}
609
609
  `, m.addEventListener("pointerdown", v(y)), a.appendChild(m);
610
- }), !e.disableGapHandler && !A(e) && (l = document.createElement("div"), l.className = Ue, l.style.cssText = `
610
+ }), !e.disableGapHandler && !H(e) && (l = document.createElement("div"), l.className = Ke, l.style.cssText = `
611
611
  position: absolute;
612
612
  background-color: var(--gs-theme-cl-cmp-bg1, #3b97e3);
613
613
  border-width: 2px;
@@ -652,10 +652,10 @@ function We(n, e) {
652
652
  a && Object.assign(a.style, y);
653
653
  const h = F(m, e), w = $e(h);
654
654
  if (Object.values(o).forEach(oe), w.forEach((E) => {
655
- if (je(d, E)) return;
655
+ if (Ne(d, E)) return;
656
656
  const L = o[E];
657
657
  re(L);
658
- }), G(e).gapHandler.isGapSupported() && l && Ne(d)) {
658
+ }), G(e).gapHandler.isGapSupported() && l && je(d)) {
659
659
  const E = ee({ componentRow: m, isVertical: h }, e);
660
660
  I(E, h, Ve(d));
661
661
  }
@@ -683,14 +683,14 @@ function We(n, e) {
683
683
  p.registerTypeRelationship(r, d);
684
684
  };
685
685
  n.onReady(() => {
686
- f(), A(e) ? b("mj-section", "mj-column") : b(e.typeRow, e.typeColumn);
686
+ f(), H(e) ? b("mj-section", "mj-column") : b(e.typeRow, e.typeColumn);
687
687
  });
688
688
  const C = "component:toggled";
689
689
  return n.on(t.events.spot, x), n.on(C, z), () => {
690
690
  n.off(t.events.spot, x), n.off(C, z);
691
691
  };
692
692
  }
693
- const Ke = "flexComponent", Je = function(n, e = {}) {
693
+ const qe = function(n, e = {}) {
694
694
  const t = {
695
695
  typeRow: "flex-row",
696
696
  typeColumn: "flex-column",
@@ -698,17 +698,17 @@ const Ke = "flexComponent", Je = function(n, e = {}) {
698
698
  snapDivisions: 12,
699
699
  minItemPercent: 5,
700
700
  ...e
701
- }, s = [De(n, t), Be(n, t)], i = We(n, t), a = Fe(n, t);
701
+ }, s = [De(n, t), Be(n, t)], i = Je(n, t), a = Fe(n, t);
702
702
  Re({
703
703
  editor: n,
704
704
  licenseKey: t.licenseKey,
705
- plan: $.startup,
706
- pluginName: Ke,
705
+ plan: Oe,
706
+ pluginName: ke,
707
707
  cleanup: () => {
708
708
  s.forEach((o) => o == null ? void 0 : o()), i(), a == null || a();
709
709
  }
710
710
  });
711
- }, qe = Ie(Je);
711
+ }, Ze = Ie(qe);
712
712
  export {
713
- qe as default
713
+ Ze as default
714
714
  };
@@ -1,16 +1,16 @@
1
- (function(T,L){typeof exports=="object"&&typeof module<"u"?module.exports=L():typeof define=="function"&&define.amd?define(L):(T=typeof globalThis<"u"?globalThis:T||self,T.StudioSdkPlugins_flexComponent=L())})(this,function(){"use strict";const T="app.grapesjs.com",L="app-stage.grapesjs.com",oe=[T,L,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Se="license:check:start",be="license:check:end",Ce=()=>typeof window<"u",Pe=({isDev:n,isStage:e})=>`${n?"":`https://${e?L:T}`}/api`,ze=()=>{const n=Ce()&&window.location.hostname;return!!n&&(oe.includes(n)||oe.some(e=>n.endsWith(e)))};function xe(n){return typeof n=="function"}async function we({path:n,baseApiUrl:e,method:t="GET",headers:s={},params:i,body:a}){const l=`${e||Pe({isDev:!1,isStage:!1})}${n}`,c={method:t,headers:{"Content-Type":"application/json",...s}};a&&(c.body=JSON.stringify(a));const f=i?new URLSearchParams(i).toString():"",p=f?`?${f}`:"",u=await fetch(`${l}${p}`,c);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}var $=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))($||{}),re=(n=>(n.web="web",n.email="email",n))(re||{});const ce={[$.free]:0,[$.startup]:10,[$.business]:20,[$.enterprise]:30};function ve(n){const e=n;return e.init=t=>s=>n(s,t),e}const Ie=n=>ve(n);async function Re({editor:n,plan:e,pluginName:t,licenseKey:s,cleanup:i}){let a="",o=!1;const l=ze(),c=p=>{console.warn("Cleanup plugin:",t,"Reason:",p),i()},f=(p={})=>{var S;const{error:u,sdkLicense:g}=p,v=(S=p.plan)==null?void 0:S.category;if(!(g||p.license)||u)c(u||"Invalid license");else if(v){const I=ce[e],R=ce[v];I>R&&c({pluginRequiredPlan:e,licensePlan:v})}};n.on(Se,p=>{a=p==null?void 0:p.baseApiUrl,o=!0}),n.on(be,p=>{f(p)}),setTimeout(async()=>{if(!o){if(l)return;if(s){const p=await Ee({licenseKey:s,pluginName:t,baseApiUrl:a});p&&f(p)}else c("The `licenseKey` option not provided")}},2e3)}async function Ee(n){const{licenseKey:e,pluginName:t,baseApiUrl:s}=n;try{return(await we({baseApiUrl:s,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const le=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,J))===n},Ge=(...n)=>e=>n.some(t=>e.is(t)),Te=(...n)=>(e,t)=>n.some(s=>t.is(s)),pe="gjs-plg-",J="data-type-role",B=class B{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):ne(e.componentColumn,B.CSS_FLEX_BASIS)}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:i,partial:a}=e;s.addStyle({[B.CSS_FLEX_BASIS]:i},{partial:a})}}};B.CSS_FLEX_BASIS="flex-basis";let q=B;const D=class D{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):ne(e.componentRow,D.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:s,gapValue:i,partial:a}=e;s.addStyle({[D.CSS_GAP]:i},{partial:a})}}};D.CSS_GAP="gap";let Z=D;const U=class U{constructor(e){this.config=e}getParentSize(e){var a;if((a=this.config)!=null&&a.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,i=t.getEl();return i?s?i.clientHeight:i.clientWidth:0}isLayoutVertical(e){var s;if((s=this.config)!=null&&s.isParentVertical)return this.config.isParentVertical(e);const t=ne(e.componentRow,U.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};U.CSS_FLEX_DIRECTION="flex-direction";let Q=U;const k=class k{constructor(e){this.config=e}getSize(e){var s;if((s=this.config)!=null&&s.getSize)return this.config.getSize(e);const t=e.componentColumn;if(t.is(k.MJML_COLUMN_TYPE)){const a=t.getAttributes().width;if(a&&(a.includes("%")||!isNaN(parseFloat(a))))return parseFloat(a);const o=t.parent();return 100/(o?o.components().length:1)}return 0}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:i,partial:a}=e;s.is(k.MJML_COLUMN_TYPE)&&s.addAttributes({width:`${parseFloat(i)}%`},{partial:a})}}};k.MJML_COLUMN_TYPE="mj-column";let ee=k;const W=class W{constructor(e){this.config=e}isGapSupported(){return!1}getGap(e){var s;if((s=this.config)!=null&&s.getGap)return this.config.getGap(e);const{componentRow:t}=e;if(t.is(W.MJML_SECTION_TYPE)){const i=t.getAttributes();if(i&&i.padding)return parseInt(i.padding,10)||0}return 0}setGap(e){var t,s;(s=(t=this.config)==null?void 0:t.setGap)==null||s.call(t,e)}};W.MJML_SECTION_TYPE="mj-section";let te=W;class Le{constructor(e){this.config=e}getParentSize(e){var o;if((o=this.config)!=null&&o.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,i=t.getEl();if(!i)return 0;let a=i;if(i.tagName!=="TABLE"){const l=i.querySelectorAll("table");l.length&&(a=l[0])}return s?a.clientHeight:a.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class H{constructor(){this.handlerCache=new Map}static getInstance(){return H.instance||(H.instance=new H),H.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(A(e)?this.handlerCache.set(t,{sizeHandler:new ee(e),gapHandler:new te(e),parentSizeHandler:new Le(e)}):this.handlerCache.set(t,{sizeHandler:new q(e),gapHandler:new Z(e),parentSizeHandler:new Q(e)})),this.handlerCache.get(t)}}function G(n){return H.getInstance().getHandlers(n)}const de=n=>{n.style.display="none"},ue=n=>{n.style.display="block"},j=n=>+parseFloat(`${n}`).toFixed(2),A=n=>n.projectType===re.email,O=(n,e)=>{const t=n.Canvas.getFramesEl();t&&(t.style.pointerEvents=e?"none":"")},$e=n=>n?["top","bottom"]:["left","right"],He=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},Ae=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},Ve=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},Me=(n,e,t,s)=>{const a=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return a>=0&&a<s?a:-1},X=n=>n==="top"||n==="bottom",je=(n,e)=>!!(He(n)&&(e==="left"||e==="top")||Ae(n)&&(e==="right"||e==="bottom")),Ne=n=>{const e=n.parent();return e?e.components().models.length>1:!1},he=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,ne=(n,e,t=!1)=>{const s=!t,i=n.getEl();if(!i)return s?0:"";const o=window.getComputedStyle(i)[e]||"";if(s){let l;return typeof o=="string"?(l=parseFloat(o.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(o)||0,l}return o},fe=(n,e,t)=>{const s=se({componentRow:n,isVertical:e},t),i=n.components().models;return s*(i.length-1)},N=(n,e)=>G(e).parentSizeHandler.isLayoutVertical({componentRow:n}),_=(n,e)=>G(e).sizeHandler.getSize(n),se=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:s}=G(e);if(!t.isGapSupported())return 0;const i=t.getGap(n),a=s.getParentSize(n);return i/100*a},ie=(n,e)=>G(e).parentSizeHandler.getParentSize(n),F=(n,e)=>{G(e).sizeHandler.setSize(n)},ge=(n,e)=>{const t=_(n,e);F({...n,sizeValue:`${t}%`,partial:!1},e)},me=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=G(e);t.isGapSupported()&&t.setGap(n)},_e=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const s=n.components().models,i={componentRow:n,isVertical:N(n,e)};s.map(a=>ge({...i,componentColumn:a},e)),me({...i,gapValue:String(t),partial:!1},e)};function Fe(n,e){const{Blocks:t}=n,{typeColumn:s,typeRow:i,blocks:a}=e;if(a===!1||A(e))return;const o=u=>({type:i,components:u.map(g=>({type:s,style:{"flex-basis":`${g}%`}}))}),l=u=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
1
+ (function(T,L){typeof exports=="object"&&typeof module<"u"?module.exports=L():typeof define=="function"&&define.amd?define(L):(T=typeof globalThis<"u"?globalThis:T||self,T.StudioSdkPlugins_flexComponent=L())})(this,function(){"use strict";const T="app.grapesjs.com",L="app-stage.grapesjs.com",oe=[T,L,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Se="license:check:start",be="license:check:end",Ce=()=>typeof window<"u",Pe=({isDev:n,isStage:e})=>`${n?"":`https://${e?L:T}`}/api`,ze=()=>{const n=Ce()&&window.location.hostname;return!!n&&(oe.includes(n)||oe.some(e=>n.endsWith(e)))};function xe(n){return typeof n=="function"}async function we({path:n,baseApiUrl:e,method:t="GET",headers:s={},params:i,body:a}){const l=`${e||Pe({isDev:!1,isStage:!1})}${n}`,c={method:t,headers:{"Content-Type":"application/json",...s}};a&&(c.body=JSON.stringify(a));const f=i?new URLSearchParams(i).toString():"",p=f?`?${f}`:"",u=await fetch(`${l}${p}`,c);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}var $=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))($||{}),re=(n=>(n.web="web",n.email="email",n))(re||{});const ce={[$.free]:0,[$.startup]:10,[$.business]:20,[$.enterprise]:30};function ve(n){const e=n;return e.init=t=>s=>n(s,t),e}const Ie=n=>ve(n);async function Re({editor:n,plan:e,pluginName:t,licenseKey:s,cleanup:i}){let a="",o=!1;const l=ze(),c=p=>{console.warn("Cleanup plugin:",t,"Reason:",p),i()},f=(p={})=>{var S;const{error:u,sdkLicense:g}=p,v=(S=p.plan)==null?void 0:S.category;if(!(g||p.license)||u)c(u||"Invalid license");else if(v){const I=ce[e],R=ce[v];I>R&&c({pluginRequiredPlan:e,licensePlan:v})}};n.on(Se,p=>{a=p==null?void 0:p.baseApiUrl,o=!0}),n.on(be,p=>{f(p)}),setTimeout(async()=>{if(!o){if(l)return;if(s){const p=await Ee({licenseKey:s,pluginName:t,baseApiUrl:a});p&&f(p)}else c("The `licenseKey` option not provided")}},2e3)}async function Ee(n){const{licenseKey:e,pluginName:t,baseApiUrl:s}=n;try{return(await we({baseApiUrl:s,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const le=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,J))===n},Ge=(...n)=>e=>n.some(t=>e.is(t)),Te=(...n)=>(e,t)=>n.some(s=>t.is(s)),pe="gjs-plg-",J="data-type-role",B=class B{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):ne(e.componentColumn,B.CSS_FLEX_BASIS)}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:i,partial:a}=e;s.addStyle({[B.CSS_FLEX_BASIS]:i},{partial:a})}}};B.CSS_FLEX_BASIS="flex-basis";let q=B;const D=class D{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):ne(e.componentRow,D.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:s,gapValue:i,partial:a}=e;s.addStyle({[D.CSS_GAP]:i},{partial:a})}}};D.CSS_GAP="gap";let Z=D;const U=class U{constructor(e){this.config=e}getParentSize(e){var a;if((a=this.config)!=null&&a.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,i=t.getEl();return i?s?i.clientHeight:i.clientWidth:0}isLayoutVertical(e){var s;if((s=this.config)!=null&&s.isParentVertical)return this.config.isParentVertical(e);const t=ne(e.componentRow,U.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};U.CSS_FLEX_DIRECTION="flex-direction";let Q=U;const k=class k{constructor(e){this.config=e}getSize(e){var s;if((s=this.config)!=null&&s.getSize)return this.config.getSize(e);const t=e.componentColumn;if(t.is(k.MJML_COLUMN_TYPE)){const a=t.getAttributes().width;if(a&&(a.includes("%")||!isNaN(parseFloat(a))))return parseFloat(a);const o=t.parent();return 100/(o?o.components().length:1)}return 0}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:i,partial:a}=e;s.is(k.MJML_COLUMN_TYPE)&&s.addAttributes({width:`${parseFloat(i)}%`},{partial:a})}}};k.MJML_COLUMN_TYPE="mj-column";let ee=k;const W=class W{constructor(e){this.config=e}isGapSupported(){return!1}getGap(e){var s;if((s=this.config)!=null&&s.getGap)return this.config.getGap(e);const{componentRow:t}=e;if(t.is(W.MJML_SECTION_TYPE)){const i=t.getAttributes();if(i&&i.padding)return parseInt(i.padding,10)||0}return 0}setGap(e){var t,s;(s=(t=this.config)==null?void 0:t.setGap)==null||s.call(t,e)}};W.MJML_SECTION_TYPE="mj-section";let te=W;class Le{constructor(e){this.config=e}getParentSize(e){var o;if((o=this.config)!=null&&o.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,i=t.getEl();if(!i)return 0;let a=i;if(i.tagName!=="TABLE"){const l=i.querySelectorAll("table");l.length&&(a=l[0])}return s?a.clientHeight:a.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class A{constructor(){this.handlerCache=new Map}static getInstance(){return A.instance||(A.instance=new A),A.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(H(e)?this.handlerCache.set(t,{sizeHandler:new ee(e),gapHandler:new te(e),parentSizeHandler:new Le(e)}):this.handlerCache.set(t,{sizeHandler:new q(e),gapHandler:new Z(e),parentSizeHandler:new Q(e)})),this.handlerCache.get(t)}}function G(n){return A.getInstance().getHandlers(n)}const de=n=>{n.style.display="none"},ue=n=>{n.style.display="block"},j=n=>+parseFloat(`${n}`).toFixed(2),H=n=>n.projectType===re.email,O=(n,e)=>{const t=n.Canvas.getFramesEl();t&&(t.style.pointerEvents=e?"none":"")},$e=n=>n?["top","bottom"]:["left","right"],Ae=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},He=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},Ve=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},Me=(n,e,t,s)=>{const a=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return a>=0&&a<s?a:-1},X=n=>n==="top"||n==="bottom",je=(n,e)=>!!(Ae(n)&&(e==="left"||e==="top")||He(n)&&(e==="right"||e==="bottom")),Ne=n=>{const e=n.parent();return e?e.components().models.length>1:!1},he=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,ne=(n,e,t=!1)=>{const s=!t,i=n.getEl();if(!i)return s?0:"";const o=window.getComputedStyle(i)[e]||"";if(s){let l;return typeof o=="string"?(l=parseFloat(o.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(o)||0,l}return o},fe=(n,e,t)=>{const s=se({componentRow:n,isVertical:e},t),i=n.components().models;return s*(i.length-1)},N=(n,e)=>G(e).parentSizeHandler.isLayoutVertical({componentRow:n}),_=(n,e)=>G(e).sizeHandler.getSize(n),se=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:s}=G(e);if(!t.isGapSupported())return 0;const i=t.getGap(n),a=s.getParentSize(n);return i/100*a},ie=(n,e)=>G(e).parentSizeHandler.getParentSize(n),F=(n,e)=>{G(e).sizeHandler.setSize(n)},ge=(n,e)=>{const t=_(n,e);F({...n,sizeValue:`${t}%`,partial:!1},e)},me=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=G(e);t.isGapSupported()&&t.setGap(n)},_e=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const s=n.components().models,i={componentRow:n,isVertical:N(n,e)};s.map(a=>ge({...i,componentColumn:a},e)),me({...i,gapValue:String(t),partial:!1},e)};function Fe(n,e){const{Blocks:t}=n,{typeColumn:s,typeRow:i,blocks:a}=e;if(a===!1||H(e))return;const o=u=>({type:i,components:u.map(g=>({type:s,style:{"flex-basis":`${g}%`}}))}),l=u=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
2
2
  ${u.map(g=>`<div style="flex-basis: ${g}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
3
- </div>`,c=(u,g)=>({id:`flex-row-${g.join("-")}`,label:u,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(g),content:o(g)}),f=[c("1 Column",[100]),c("2 Columns 50/50",[50,50]),c("2 Columns 25/75",[25,75]),c("2 Columns 75/25",[75,25]),c("3 Columns",[33.33,33.33,33.33]),c("3 Columns 50/25/25",[50,25,25]),c("3 Columns 25/50/25",[25,50,25]),c("3 Columns 25/25/50",[25,25,50]),c("4 Columns",[25,25,25,25]),c("5 Columns",[20,20,20,20,20])],p=xe(a)?a({blocks:f}):f;return p.forEach(u=>t.add(u.id,u)),()=>{p.forEach(u=>t.remove(u.id))}}const Be=(n,e)=>{const{Components:t}=n,{typeRow:s,typeColumn:i,extendTypeColumn:a}=e,o=`${pe}${i}`,c=!!i&&!!t.getType(i)&&!a;if(!(!i||c||A(e)))return t.addType(i,{isComponent:le(i),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:o,icon:'<svg viewBox="0 0 24 24"><path d="M14.5 2.3A1.8 1.8 0 0 0 12.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8zm-8 0A1.8 1.8 0 0 0 4.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',draggable:Te(s),attributes:{[J]:i},styles:`
3
+ </div>`,c=(u,g)=>({id:`flex-row-${g.join("-")}`,label:u,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(g),content:o(g)}),f=[c("1 Column",[100]),c("2 Columns 50/50",[50,50]),c("2 Columns 25/75",[25,75]),c("2 Columns 75/25",[75,25]),c("3 Columns",[33.33,33.33,33.33]),c("3 Columns 50/25/25",[50,25,25]),c("3 Columns 25/50/25",[25,50,25]),c("3 Columns 25/25/50",[25,25,50]),c("4 Columns",[25,25,25,25]),c("5 Columns",[20,20,20,20,20])],p=xe(a)?a({blocks:f}):f;return p.forEach(u=>t.add(u.id,u)),()=>{p.forEach(u=>t.remove(u.id))}}const Be=(n,e)=>{const{Components:t}=n,{typeRow:s,typeColumn:i,extendTypeColumn:a}=e,o=`${pe}${i}`,c=!!i&&!!t.getType(i)&&!a;if(!(!i||c||H(e)))return t.addType(i,{isComponent:le(i),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:o,icon:'<svg viewBox="0 0 24 24"><path d="M14.5 2.3A1.8 1.8 0 0 0 12.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8zm-8 0A1.8 1.8 0 0 0 4.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',draggable:Te(s),attributes:{[J]:i},styles:`
4
4
  .${o} {
5
5
  flex-grow: 1;
6
6
  }
7
- `}}}),()=>{t.removeType(i)}},De=(n,e)=>{const{Components:t}=n,{typeRow:s,typeColumn:i,extendTypeRow:a}=e,o=`${pe}${s}`,c=!!s&&!!t.getType(s)&&!a;if(!(!s||c||A(e)))return t.addType(s,{isComponent:le(s),model:{defaults:{name:"Row",classes:o,icon:'<svg viewBox="0 0 24 24"><path d="M4 4.8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3A1.8 1.8 0 0 0 20 4.7zm0 8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',emptyState:{styleIn:"width: 100%"},attributes:{[J]:s},droppable:Ge(i),traits:[{type:"checkbox",name:"snap",label:"Enable Snap",default:e.snapEnabled,changeProp:!0},{type:"number",name:"snap-divisions",label:"Snap Divisions",min:1,max:12,step:1,default:e.snapDivisions,changeProp:!0}],resizable:{tl:0,tc:0,tr:0,cl:0,bl:0,br:0},styles:`
7
+ `}}}),()=>{t.removeType(i)}},De=(n,e)=>{const{Components:t}=n,{typeRow:s,typeColumn:i,extendTypeRow:a}=e,o=`${pe}${s}`,c=!!s&&!!t.getType(s)&&!a;if(!(!s||c||H(e)))return t.addType(s,{isComponent:le(s),model:{defaults:{name:"Row",classes:o,icon:'<svg viewBox="0 0 24 24"><path d="M4 4.8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3A1.8 1.8 0 0 0 20 4.7zm0 8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',emptyState:{styleIn:"width: 100%"},attributes:{[J]:s},droppable:Ge(i),traits:[{type:"checkbox",name:"snap",label:"Enable Snap",default:e.snapEnabled,changeProp:!0},{type:"number",name:"snap-divisions",label:"Snap Divisions",min:1,max:12,step:1,default:e.snapDivisions,changeProp:!0}],resizable:{tl:0,tc:0,tr:0,cl:0,bl:0,br:0},styles:`
8
8
  .${o} {
9
9
  display: flex;
10
10
  align-items: stretch;
11
11
  flex-wrap: nowrap;
12
12
  }
13
- `}}}),()=>{t.removeType(s)}};class ke{constructor(){this.resizableChildTypes=new Set,this.gapAdjustableParentTypes=new Set,this.typeRelationships=new Map}registerResizableChild(e){this.resizableChildTypes.add(e)}registerGapAdjustableParent(e){this.gapAdjustableParentTypes.add(e)}registerTypeRelationship(e,t){this.typeRelationships.has(e)||this.typeRelationships.set(e,new Set),this.typeRelationships.get(e).add(t),this.registerResizableChild(t),this.registerGapAdjustableParent(e)}isResizableChild(e){return this.resizableChildTypes.has(e.get("type"))}isGapAdjustableParent(e){return this.gapAdjustableParentTypes.has(e.get("type"))}isValidRelationship(e,t){const s=e.get("type"),i=t.get("type");return this.typeRelationships.has(s)?this.typeRelationships.get(s).has(i):!1}}class Oe{constructor(e,t,s){this.editor=e,this.registry=t,this.opts=s,this.resizeState=new WeakMap}getState(e){return this.resizeState.has(e)||this.resizeState.set(e,{}),this.resizeState.get(e)}clearState(e){return this.resizeState.delete(e)}startResize(e,t,s){const{opts:i}=this,a=this.getState(e);a.direction=t,a.startX=s.clientX,a.startY=s.clientY,a.resizing=!0,a.lastSnappedPercent=void 0;const o=e.parent();if(!o||!this.registry.isValidRelationship(o,e))return;a.snapEnabled=o.get("snap")??i.snapEnabled,a.snapDivisions=o.get("snap-divisions")??i.snapDivisions??12;const l=o.components().models,c=l.findIndex(g=>g.cid===e.cid),f=N(o,i),p=Me(c,t,f,l.length);p!==-1&&(a.adjacentIdx=p);const u={componentColumn:e,componentRow:o,isVertical:f};if(a.startPercent=_(u,i),typeof a.adjacentIdx<"u"){const g=l[a.adjacentIdx];a.neighborStartPercent=_({...u,componentColumn:g},i)}}updateResizeByDelta(e,t,s){const i=this.getState(e),a=e.parent();!i.resizing||!a||(i.snapEnabled?this.updateSnapResize(e,t,s):this.updateContinuesResize(e,t,s))}finishResize(e){const t=e.parent(),s=t==null?void 0:t.components().models,i={componentRow:t,isVertical:!!t&&N(t,this.opts)};s==null||s.forEach(a=>ge({...i,componentColumn:a},this.opts)),this.clearState(e)}updateContinuesResize(e,t,s){const i=this.getState(e),a=e.parent(),{opts:o}=this;if(!a)return;const l=o.minItemPercent??0,c=X(t),f=ie({componentRow:a,isVertical:c},o),p=fe(a,c,this.opts),g=100-p/f*100,v=s/(f-p)*g,{startPercent:P=0,neighborStartPercent:S=0}=i,I={componentRow:a,isVertical:c,componentColumn:e,partial:!0},R=he(t,s)?P+Math.abs(v):P-Math.abs(v);if(typeof i.adjacentIdx<"u"){const z=a.components().models[i.adjacentIdx],x=P+S,b=x-l,r=Math.min(b,Math.max(l,R)),d=x-r;F({...I,sizeValue:`${j(r)}%`},o),F({...I,componentColumn:z,sizeValue:`${j(d)}%`},o)}else{const z=Math.max(l,Math.min(g,R));F({...I,sizeValue:`${j(z)}%`},o)}}updateSnapResize(e,t,s){const i=this.getState(e),a=e.parent(),o=X(t),l=ie({componentRow:a,isVertical:o},this.opts),c=fe(a,o,this.opts),f=l-c,p=s/f*100,u=he(t,s),{startPercent:g=0,snapDivisions:v=12}=i,P=u?g+Math.abs(p):g-Math.abs(p),S=100/v,I=Math.floor(P/S)*S,R=Math.ceil(P/S)*S,z=Math.abs(R-P),x=Math.abs(P-I),b=S*.2,C=z<x?R:I;if(C>0&&C<100&&(z<b||x<b)&&i.lastSnappedPercent!==C){i.lastSnappedPercent=C;let m=Math.abs(C-g)/100*f;(u&&(t==="left"||t==="top")||!u&&(t==="right"||t==="bottom"))&&(m=-m),this.updateContinuesResize(e,t,m)}else z>=b&&x>=b&&(i.lastSnappedPercent=void 0)}}class Xe{constructor(e,t,s){this.editor=e,this.registry=t,this.opts=s}updateGapByDelta(e,t,s,i){if(!this.registry.isGapAdjustableParent(e))return;const{opts:a}=this,o=Math.max(0,s+t),l=ie({componentRow:e,isVertical:i},a),c=o/l*100,f=e.components().models,p=f.length-1,u={componentRow:e,isVertical:i},g=f.reduce((b,C)=>b+_({...u,componentColumn:C},a),0),P=100-c*p,S=a.minItemPercent||5;if(P<S*f.length)return;const R=100-p*c,z=g-R,x={componentRow:e,isVertical:i,partial:!0};f.map(b=>{const C=_({...u,componentColumn:b},a),r=C-C/g*z;F({...x,componentColumn:b,sizeValue:`${j(r)}%`},a)}),me({...x,gapValue:`${j(c)}%`},a)}finishGapAdjust(e){_e(e,this.opts)}}class Ye{constructor(e,t,s){this.editor=e,this.registry=t,this.opts=s,this.resizeHandler=new Oe(e,t,s),this.gapHandler=new Xe(e,t,s)}startResize(e,t,s){this.resizeHandler.startResize(e,t,s)}updateResizeByDelta(e,t,s){this.resizeHandler.updateResizeByDelta(e,t,s)}finishResize(e){this.resizeHandler.finishResize(e)}updateGapByDelta(e,t,s,i){this.gapHandler.updateGapByDelta(e,t,s,i)}finishGapAdjust(e){this.gapHandler.finishGapAdjust(e)}canResize(e){const t=e.parent();return t?this.registry.isValidRelationship(t,e):!1}canAdjustGap(e){return this.registry.isGapAdjustableParent(e)}}const Y="gs-flex-spots",ye=`${Y}__handle-size`,Ue=`${Y}__handle-gap`;function We(n,e){const{Canvas:t}=n,s="flex-resize-spot";let i,a,o,l,c=null,f=null;const p=new ke,u=new Ye(n,p,e),g=()=>{var r;i=document.createElement("div"),i.className=Y,i.style.display="none",a=document.createElement("div"),a.className=`${Y}__handles`,a.style.position="absolute",a.style.pointerEvents="none",a.style.zIndex="21",o={left:document.createElement("div"),right:document.createElement("div"),top:document.createElement("div"),bottom:document.createElement("div")},Object.entries(o).forEach(([d,m])=>{const y=d,h=X(y);m.className=`${ye} ${ye}-${y} gjs-resizer-h gjs-cv-unscale`,m.style.cssText=`
13
+ `}}}),()=>{t.removeType(s)}},ke="flexComponent",Oe=$.startup;class Xe{constructor(){this.resizableChildTypes=new Set,this.gapAdjustableParentTypes=new Set,this.typeRelationships=new Map}registerResizableChild(e){this.resizableChildTypes.add(e)}registerGapAdjustableParent(e){this.gapAdjustableParentTypes.add(e)}registerTypeRelationship(e,t){this.typeRelationships.has(e)||this.typeRelationships.set(e,new Set),this.typeRelationships.get(e).add(t),this.registerResizableChild(t),this.registerGapAdjustableParent(e)}isResizableChild(e){return this.resizableChildTypes.has(e.get("type"))}isGapAdjustableParent(e){return this.gapAdjustableParentTypes.has(e.get("type"))}isValidRelationship(e,t){const s=e.get("type"),i=t.get("type");return this.typeRelationships.has(s)?this.typeRelationships.get(s).has(i):!1}}class Ye{constructor(e,t,s){this.editor=e,this.registry=t,this.opts=s,this.resizeState=new WeakMap}getState(e){return this.resizeState.has(e)||this.resizeState.set(e,{}),this.resizeState.get(e)}clearState(e){return this.resizeState.delete(e)}startResize(e,t,s){const{opts:i}=this,a=this.getState(e);a.direction=t,a.startX=s.clientX,a.startY=s.clientY,a.resizing=!0,a.lastSnappedPercent=void 0;const o=e.parent();if(!o||!this.registry.isValidRelationship(o,e))return;a.snapEnabled=o.get("snap")??i.snapEnabled,a.snapDivisions=o.get("snap-divisions")??i.snapDivisions??12;const l=o.components().models,c=l.findIndex(g=>g.cid===e.cid),f=N(o,i),p=Me(c,t,f,l.length);p!==-1&&(a.adjacentIdx=p);const u={componentColumn:e,componentRow:o,isVertical:f};if(a.startPercent=_(u,i),typeof a.adjacentIdx<"u"){const g=l[a.adjacentIdx];a.neighborStartPercent=_({...u,componentColumn:g},i)}}updateResizeByDelta(e,t,s){const i=this.getState(e),a=e.parent();!i.resizing||!a||(i.snapEnabled?this.updateSnapResize(e,t,s):this.updateContinuesResize(e,t,s))}finishResize(e){const t=e.parent(),s=t==null?void 0:t.components().models,i={componentRow:t,isVertical:!!t&&N(t,this.opts)};s==null||s.forEach(a=>ge({...i,componentColumn:a},this.opts)),this.clearState(e)}updateContinuesResize(e,t,s){const i=this.getState(e),a=e.parent(),{opts:o}=this;if(!a)return;const l=o.minItemPercent??0,c=X(t),f=ie({componentRow:a,isVertical:c},o),p=fe(a,c,this.opts),g=100-p/f*100,v=s/(f-p)*g,{startPercent:P=0,neighborStartPercent:S=0}=i,I={componentRow:a,isVertical:c,componentColumn:e,partial:!0},R=he(t,s)?P+Math.abs(v):P-Math.abs(v);if(typeof i.adjacentIdx<"u"){const z=a.components().models[i.adjacentIdx],x=P+S,b=x-l,r=Math.min(b,Math.max(l,R)),d=x-r;F({...I,sizeValue:`${j(r)}%`},o),F({...I,componentColumn:z,sizeValue:`${j(d)}%`},o)}else{const z=Math.max(l,Math.min(g,R));F({...I,sizeValue:`${j(z)}%`},o)}}updateSnapResize(e,t,s){const i=this.getState(e),a=e.parent(),o=X(t),l=ie({componentRow:a,isVertical:o},this.opts),c=fe(a,o,this.opts),f=l-c,p=s/f*100,u=he(t,s),{startPercent:g=0,snapDivisions:v=12}=i,P=u?g+Math.abs(p):g-Math.abs(p),S=100/v,I=Math.floor(P/S)*S,R=Math.ceil(P/S)*S,z=Math.abs(R-P),x=Math.abs(P-I),b=S*.2,C=z<x?R:I;if(C>0&&C<100&&(z<b||x<b)&&i.lastSnappedPercent!==C){i.lastSnappedPercent=C;let m=Math.abs(C-g)/100*f;(u&&(t==="left"||t==="top")||!u&&(t==="right"||t==="bottom"))&&(m=-m),this.updateContinuesResize(e,t,m)}else z>=b&&x>=b&&(i.lastSnappedPercent=void 0)}}class Ue{constructor(e,t,s){this.editor=e,this.registry=t,this.opts=s}updateGapByDelta(e,t,s,i){if(!this.registry.isGapAdjustableParent(e))return;const{opts:a}=this,o=Math.max(0,s+t),l=ie({componentRow:e,isVertical:i},a),c=o/l*100,f=e.components().models,p=f.length-1,u={componentRow:e,isVertical:i},g=f.reduce((b,C)=>b+_({...u,componentColumn:C},a),0),P=100-c*p,S=a.minItemPercent||5;if(P<S*f.length)return;const R=100-p*c,z=g-R,x={componentRow:e,isVertical:i,partial:!0};f.map(b=>{const C=_({...u,componentColumn:b},a),r=C-C/g*z;F({...x,componentColumn:b,sizeValue:`${j(r)}%`},a)}),me({...x,gapValue:`${j(c)}%`},a)}finishGapAdjust(e){_e(e,this.opts)}}class We{constructor(e,t,s){this.editor=e,this.registry=t,this.opts=s,this.resizeHandler=new Ye(e,t,s),this.gapHandler=new Ue(e,t,s)}startResize(e,t,s){this.resizeHandler.startResize(e,t,s)}updateResizeByDelta(e,t,s){this.resizeHandler.updateResizeByDelta(e,t,s)}finishResize(e){this.resizeHandler.finishResize(e)}updateGapByDelta(e,t,s,i){this.gapHandler.updateGapByDelta(e,t,s,i)}finishGapAdjust(e){this.gapHandler.finishGapAdjust(e)}canResize(e){const t=e.parent();return t?this.registry.isValidRelationship(t,e):!1}canAdjustGap(e){return this.registry.isGapAdjustableParent(e)}}const Y="gs-flex-spots",ye=`${Y}__handle-size`,Ke=`${Y}__handle-gap`;function Je(n,e){const{Canvas:t}=n,s="flex-resize-spot";let i,a,o,l,c=null,f=null;const p=new Xe,u=new We(n,p,e),g=()=>{var r;i=document.createElement("div"),i.className=Y,i.style.display="none",a=document.createElement("div"),a.className=`${Y}__handles`,a.style.position="absolute",a.style.pointerEvents="none",a.style.zIndex="21",o={left:document.createElement("div"),right:document.createElement("div"),top:document.createElement("div"),bottom:document.createElement("div")},Object.entries(o).forEach(([d,m])=>{const y=d,h=X(y);m.className=`${ye} ${ye}-${y} gjs-resizer-h gjs-cv-unscale`,m.style.cssText=`
14
14
  pointer-events: all;
15
15
  position: absolute;
16
16
  z-index: 1;
@@ -20,7 +20,7 @@
20
20
  ${y==="right"?"right: 0px;":""}
21
21
  ${y==="top"?"top: 0px;":""}
22
22
  ${y==="bottom"?"bottom: 0px;":""}
23
- `,m.addEventListener("pointerdown",v(y)),a.appendChild(m)}),!e.disableGapHandler&&!A(e)&&(l=document.createElement("div"),l.className=Ue,l.style.cssText=`
23
+ `,m.addEventListener("pointerdown",v(y)),a.appendChild(m)}),!e.disableGapHandler&&!H(e)&&(l=document.createElement("div"),l.className=Ke,l.style.cssText=`
24
24
  position: absolute;
25
25
  background-color: var(--gs-theme-cl-cmp-bg1, #3b97e3);
26
26
  border-width: 2px;
@@ -30,4 +30,4 @@
30
30
  pointer-events: all;
31
31
  max-width: 3rem;
32
32
  max-height: 3rem;
33
- `,l.addEventListener("pointerdown",P()),a.appendChild(l)),i.append(a),(r=t.getSpotsEl())==null||r.appendChild(i)},v=r=>d=>{if(!c)return;O(n,!0),d.stopPropagation(),d.preventDefault(),u.startResize(c,r,d);const m=d.clientX,y=d.clientY;d.target.setPointerCapture(d.pointerId);const h=V=>{const E=n.Canvas.getZoomMultiplier(),M=(V.clientX-m)*E,K=(V.clientY-y)*E,ae=X(r)?K:M;u.updateResizeByDelta(c,r,ae)},w=()=>{O(n,!1),u.finishResize(c),d.target.releasePointerCapture(d.pointerId),document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",w)};document.addEventListener("pointermove",h),document.addEventListener("pointerup",w)},P=()=>r=>{if(!f)return;const d=f;O(n,!0),r.stopPropagation(),r.preventDefault();const m=N(d,e),y=se({componentRow:d,isVertical:m},e),h=r.clientX,w=r.clientY;r.target.setPointerCapture(r.pointerId);const V=M=>{const K=n.Canvas.getZoomMultiplier(),ae=m?(M.clientY-w)*K:(M.clientX-h)*K;u.updateGapByDelta(d,ae,y,m)},E=()=>{O(n,!1),u.finishGapAdjust(d),r.target.releasePointerCapture(r.pointerId),document.removeEventListener("pointermove",V),document.removeEventListener("pointerup",E)};document.addEventListener("pointermove",V),document.addEventListener("pointerup",E)},S=r=>{const d=r.component;if(!d||!i||(c=d,f=d.parent(),!f))return;const m=f;ue(i);const y=r.getStyle();a&&Object.assign(a.style,y);const h=N(m,e),w=$e(h);if(Object.values(o).forEach(de),w.forEach(E=>{if(je(d,E))return;const M=o[E];ue(M)}),G(e).gapHandler.isGapSupported()&&l&&Ne(d)){const E=se({componentRow:m,isVertical:h},e);I(E,h,Ve(d))}},I=(r,d,m=!1)=>{const y=e.gapHandleSize,h=l.style;if(d){h.height=`${y}px`;const w=l.offsetHeight;m?(h.top=`-${(r+w)/2}px`,h.bottom=""):(h.bottom=`-${(r+w)/2}px`,h.top=""),h.width="50%",h.left="50%",h.transform="translateX(-50%)",h.cursor="row-resize"}else{h.width=`${y}px`;const w=l.offsetWidth;m?(h.left=`-${(r+w)/2}px`,h.right=""):(h.right=`-${(r+w)/2}px`,h.left=""),h.height="50%",h.top="50%",h.transform="translateY(-50%)",h.cursor="col-resize"}},R=()=>{i&&(de(i),c=null,f=null)},z=()=>{t.removeSpots({type:s});const r=n.getSelected(),d=r==null?void 0:r.parent();r&&d&&p.isValidRelationship(d,r)?t.addSpot({type:s,component:r}):R()},x=()=>{const r=t.getSpots().filter(d=>d.type===s)[0];r&&S(r)},b=(r,d)=>{p.registerTypeRelationship(r,d)};n.onReady(()=>{g(),A(e)?b("mj-section","mj-column"):b(e.typeRow,e.typeColumn)});const C="component:toggled";return n.on(t.events.spot,x),n.on(C,z),()=>{n.off(t.events.spot,x),n.off(C,z)}}const Ke="flexComponent";return Ie(function(n,e={}){const t={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...e},s=[De(n,t),Be(n,t)],i=We(n,t),a=Fe(n,t);Re({editor:n,licenseKey:t.licenseKey,plan:$.startup,pluginName:Ke,cleanup:()=>{s.forEach(o=>o==null?void 0:o()),i(),a==null||a()}})})});
33
+ `,l.addEventListener("pointerdown",P()),a.appendChild(l)),i.append(a),(r=t.getSpotsEl())==null||r.appendChild(i)},v=r=>d=>{if(!c)return;O(n,!0),d.stopPropagation(),d.preventDefault(),u.startResize(c,r,d);const m=d.clientX,y=d.clientY;d.target.setPointerCapture(d.pointerId);const h=V=>{const E=n.Canvas.getZoomMultiplier(),M=(V.clientX-m)*E,K=(V.clientY-y)*E,ae=X(r)?K:M;u.updateResizeByDelta(c,r,ae)},w=()=>{O(n,!1),u.finishResize(c),d.target.releasePointerCapture(d.pointerId),document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",w)};document.addEventListener("pointermove",h),document.addEventListener("pointerup",w)},P=()=>r=>{if(!f)return;const d=f;O(n,!0),r.stopPropagation(),r.preventDefault();const m=N(d,e),y=se({componentRow:d,isVertical:m},e),h=r.clientX,w=r.clientY;r.target.setPointerCapture(r.pointerId);const V=M=>{const K=n.Canvas.getZoomMultiplier(),ae=m?(M.clientY-w)*K:(M.clientX-h)*K;u.updateGapByDelta(d,ae,y,m)},E=()=>{O(n,!1),u.finishGapAdjust(d),r.target.releasePointerCapture(r.pointerId),document.removeEventListener("pointermove",V),document.removeEventListener("pointerup",E)};document.addEventListener("pointermove",V),document.addEventListener("pointerup",E)},S=r=>{const d=r.component;if(!d||!i||(c=d,f=d.parent(),!f))return;const m=f;ue(i);const y=r.getStyle();a&&Object.assign(a.style,y);const h=N(m,e),w=$e(h);if(Object.values(o).forEach(de),w.forEach(E=>{if(je(d,E))return;const M=o[E];ue(M)}),G(e).gapHandler.isGapSupported()&&l&&Ne(d)){const E=se({componentRow:m,isVertical:h},e);I(E,h,Ve(d))}},I=(r,d,m=!1)=>{const y=e.gapHandleSize,h=l.style;if(d){h.height=`${y}px`;const w=l.offsetHeight;m?(h.top=`-${(r+w)/2}px`,h.bottom=""):(h.bottom=`-${(r+w)/2}px`,h.top=""),h.width="50%",h.left="50%",h.transform="translateX(-50%)",h.cursor="row-resize"}else{h.width=`${y}px`;const w=l.offsetWidth;m?(h.left=`-${(r+w)/2}px`,h.right=""):(h.right=`-${(r+w)/2}px`,h.left=""),h.height="50%",h.top="50%",h.transform="translateY(-50%)",h.cursor="col-resize"}},R=()=>{i&&(de(i),c=null,f=null)},z=()=>{t.removeSpots({type:s});const r=n.getSelected(),d=r==null?void 0:r.parent();r&&d&&p.isValidRelationship(d,r)?t.addSpot({type:s,component:r}):R()},x=()=>{const r=t.getSpots().filter(d=>d.type===s)[0];r&&S(r)},b=(r,d)=>{p.registerTypeRelationship(r,d)};n.onReady(()=>{g(),H(e)?b("mj-section","mj-column"):b(e.typeRow,e.typeColumn)});const C="component:toggled";return n.on(t.events.spot,x),n.on(C,z),()=>{n.off(t.events.spot,x),n.off(C,z)}}return Ie(function(n,e={}){const t={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...e},s=[De(n,t),Be(n,t)],i=Je(n,t),a=Fe(n,t);Re({editor:n,licenseKey:t.licenseKey,plan:Oe,pluginName:ke,cleanup:()=>{s.forEach(o=>o==null?void 0:o()),i(),a==null||a()}})})});
@@ -0,0 +1,3 @@
1
+ import { SdkPlanCategories } from '../utils';
2
+ export declare const PLUGIN_NAME = "flexComponent";
3
+ export declare const PLUGIN_PLAN = SdkPlanCategories.startup;
@@ -1,6 +1,6 @@
1
- "use strict";const P="app.grapesjs.com",B="app-stage.grapesjs.com",N=[P,B,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],D="license:check:start",U="license:check:end",R=()=>typeof window<"u",W=({isDev:t,isStage:a})=>`${t?"":`https://${a?B:P}`}/api`,F=()=>{const t=R()&&window.location.hostname;return!!t&&(N.includes(t)||N.some(a=>t.endsWith(a)))};async function K({path:t,baseApiUrl:a,method:r="GET",headers:c={},params:p,body:h}){const w=`${a||W({isDev:!1,isStage:!1})}${t}`,d={method:r,headers:{"Content-Type":"application/json",...c}};h&&(d.body=JSON.stringify(h));const m=p?new URLSearchParams(p).toString():"",n=m?`?${m}`:"",b=await fetch(`${w}${n}`,d);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}var x=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(x||{});const O={[x.free]:0,[x.startup]:10,[x.business]:20,[x.enterprise]:30};function G(t){const a=t;return a.init=r=>c=>t(c,r),a}const Z=t=>G(t);async function q({editor:t,plan:a,pluginName:r,licenseKey:c,cleanup:p}){let h="",g=!1;const w=F(),d=n=>{console.warn("Cleanup plugin:",r,"Reason:",n),p()},m=(n={})=>{var A;const{error:b,sdkLicense:l}=n,v=(A=n.plan)==null?void 0:A.category;if(!(l||n.license)||b)d(b||"Invalid license");else if(v){const E=O[a],$=O[v];E>$&&d({pluginRequiredPlan:a,licensePlan:v})}};t.on(D,n=>{h=n==null?void 0:n.baseApiUrl,g=!0}),t.on(U,n=>{m(n)}),setTimeout(async()=>{if(!g){if(w)return;if(c){const n=await z({licenseKey:c,pluginName:r,baseApiUrl:h});n&&m(n)}else d("The `licenseKey` option not provided")}},2e3)}async function z(t){const{licenseKey:a,pluginName:r,baseApiUrl:c}=t;try{return(await K({baseApiUrl:c,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(p){return console.error("Error during SDK license check:",p),!1}}const J="gjs-plg-",X="fsLightboxComponent",k="data-fslightbox",C="data-type",Y="fslightbox-open",T="fslightbox",S={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>',imageLightbox:'<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>',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>'},Q=function(t,a={}){const{Blocks:r,Components:c}=t,p="Lightbox",h=`${J}${T}`,g={toolbarIconOpen:S.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...a},{block:w,toolbarIconOpen:d,defaultSrc:m}=g,n=function(s){const e=this,i="data-fslightbox",o=window,f=()=>{var H;const u=o.refreshFsLightbox;u==null||u();const j=e.getAttribute(i);if((H=o.fsLightboxInstances)==null||H[j],!o._isEditor)return;Array.from(document.querySelectorAll(`[${i}]`)).forEach(y=>{const L=y.onclick;y.onclick=function(I){I.preventDefault();const M=y;!M.__skipLb&&(L==null||L(I)),M.__skipLb=!0}})};if(o.refreshFsLightbox)f();else{const u=document.createElement("script");u.src=s.cdnScript,u.onload=f,document.head.appendChild(u)}},b=s=>({id:`${T}-open-lb`,label:d,command:()=>{const e=s.getView();e==null||e.toggleLightbox()}}),l="source-type",v={type:"radio",name:l,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:S.image},{id:"video",label:"Video",icon:S.video},{id:"el",label:"Custom Element",icon:S.external}],labelToTitle:!0},V={id:"href-image",name:"href",type:"file",label:"Source Image"},A={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},E={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},$={image:[V],video:[A],el:[E]};c.addType(T,{block:w&&{label:p,media:S.imageLightbox,category:"Extra",select:!0,...g.block},isComponent:s=>{var e;return(e=s.hasAttribute)==null?void 0:e.call(s,k)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:p,icon:S.imageLightbox,classes:h,draggable:(s,e)=>!e.is(T),attributes:{[k]:"lightbox",[C]:"image",href:m},components:{type:"image",src:m},script:n,cdnScript:g.cdnScript,"script-props":["attributes","cdnScript"],[l]:"image",traits:[v,{name:k,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(s,e){var o;const i=(o=e.target)==null?void 0:o.getView();i==null||i.toggleLightbox()}}],styles:`
1
+ "use strict";const O="app.grapesjs.com",U="app-stage.grapesjs.com",P=[O,U,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],B="license:check:start",D="license:check:end",R=()=>typeof window<"u",W=({isDev:t,isStage:a})=>`${t?"":`https://${a?U:O}`}/api`,F=()=>{const t=R()&&window.location.hostname;return!!t&&(P.includes(t)||P.some(a=>t.endsWith(a)))};async function K({path:t,baseApiUrl:a,method:r="GET",headers:c={},params:p,body:h}){const w=`${a||W({isDev:!1,isStage:!1})}${t}`,d={method:r,headers:{"Content-Type":"application/json",...c}};h&&(d.body=JSON.stringify(h));const m=p?new URLSearchParams(p).toString():"",n=m?`?${m}`:"",b=await fetch(`${w}${n}`,d);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}var x=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(x||{});const M={[x.free]:0,[x.startup]:10,[x.business]:20,[x.enterprise]:30};function G(t){const a=t;return a.init=r=>c=>t(c,r),a}const Z=t=>G(t);async function q({editor:t,plan:a,pluginName:r,licenseKey:c,cleanup:p}){let h="",g=!1;const w=F(),d=n=>{console.warn("Cleanup plugin:",r,"Reason:",n),p()},m=(n={})=>{var A;const{error:b,sdkLicense:l}=n,v=(A=n.plan)==null?void 0:A.category;if(!(l||n.license)||b)d(b||"Invalid license");else if(v){const E=M[a],$=M[v];E>$&&d({pluginRequiredPlan:a,licensePlan:v})}};t.on(B,n=>{h=n==null?void 0:n.baseApiUrl,g=!0}),t.on(D,n=>{m(n)}),setTimeout(async()=>{if(!g){if(w)return;if(c){const n=await z({licenseKey:c,pluginName:r,baseApiUrl:h});n&&m(n)}else d("The `licenseKey` option not provided")}},2e3)}async function z(t){const{licenseKey:a,pluginName:r,baseApiUrl:c}=t;try{return(await K({baseApiUrl:c,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(p){return console.error("Error during SDK license check:",p),!1}}const J="gjs-plg-",X="fsLightboxComponent",Y=x.startup,k="data-fslightbox",C="data-type",Q="fslightbox-open",T="fslightbox",S={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>',imageLightbox:'<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>',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>'},ee=function(t,a={}){const{Blocks:r,Components:c}=t,p="Lightbox",h=`${J}${T}`,g={toolbarIconOpen:S.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...a},{block:w,toolbarIconOpen:d,defaultSrc:m}=g,n=function(s){const e=this,i="data-fslightbox",o=window,f=()=>{var j;const u=o.refreshFsLightbox;u==null||u();const N=e.getAttribute(i);if((j=o.fsLightboxInstances)==null||j[N],!o._isEditor)return;Array.from(document.querySelectorAll(`[${i}]`)).forEach(L=>{const y=L.onclick;L.onclick=function(I){I.preventDefault();const H=L;!H.__skipLb&&(y==null||y(I)),H.__skipLb=!0}})};if(o.refreshFsLightbox)f();else{const u=document.createElement("script");u.src=s.cdnScript,u.onload=f,document.head.appendChild(u)}},b=s=>({id:`${T}-open-lb`,label:d,command:()=>{const e=s.getView();e==null||e.toggleLightbox()}}),l="source-type",v={type:"radio",name:l,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:S.image},{id:"video",label:"Video",icon:S.video},{id:"el",label:"Custom Element",icon:S.external}],labelToTitle:!0},V={id:"href-image",name:"href",type:"file",label:"Source Image"},A={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},E={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},$={image:[V],video:[A],el:[E]};c.addType(T,{block:w&&{label:p,media:S.imageLightbox,category:"Extra",select:!0,...g.block},isComponent:s=>{var e;return(e=s.hasAttribute)==null?void 0:e.call(s,k)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:p,icon:S.imageLightbox,classes:h,draggable:(s,e)=>!e.is(T),attributes:{[k]:"lightbox",[C]:"image",href:m},components:{type:"image",src:m},script:n,cdnScript:g.cdnScript,"script-props":["attributes","cdnScript"],[l]:"image",traits:[v,{name:k,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(s,e){var o;const i=(o=e.target)==null?void 0:o.getView();i==null||i.toggleLightbox()}}],styles:`
2
2
  .${h} {
3
3
  display: inline-block;
4
4
  padding: 10px;
5
5
  }
6
- `},init(){const s=[l].map(e=>`change:${e}`).join(" ");this.on(s,this.updateTraits),this.on(`change:${l}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(s,e,i){if(i.adjust)return;const f=this.get(l)==="video"?"video":"image";this.addAttributes({[C]:f,href:""})},adjustSourceType(){const s=this.get(l),e=this.getAttributes().href||"",i={adjust:!0};if(s==="video"){const o=e.includes("youtube.com")?"youtube":"video";this.addAttributes({[C]:o},i)}else s!=="el"&&e.startsWith("#")?this.set(l,"el",i):s==="image"&&this.addAttributes({[C]:"image"},i)},updateTraits(s={}){const{changed:e}=this,{init:i}=s;if(e[v.name]||i){this.removeTrait([V.name,A.name,E.name]);const o=this.get(l)||"image",f=this.getTraitIndex(l)+1;this.addTrait($[o],{at:f})}},initToolbar(){if(!d)return;const{toolbar:s}=this,e=b(this);!s.find(o=>o.id===e.id)&&(s==null||s.unshift(e))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var y;const{em:s,el:e,model:i}=this,{Canvas:o}=s,f=i.getAttributes()[k],{defaultView:u,documentElement:j}=e.ownerDocument,_=(y=u.fsLightboxInstances)==null?void 0:y[f];if(j.classList.contains(Y))_.close();else{e.__skipLb=!1;let L;_.props.onOpen=()=>{L=o.getSpots(),setTimeout(()=>o.removeSpots())},_.props.onClose=()=>{L.forEach(I=>o.addSpot(I.attributes))},e.click()}}}}),q({editor:t,plan:x.startup,licenseKey:g.licenseKey,pluginName:X,cleanup:()=>{r.remove(T),c.removeType(T)}})},ee=Z(Q);module.exports=ee;
6
+ `},init(){const s=[l].map(e=>`change:${e}`).join(" ");this.on(s,this.updateTraits),this.on(`change:${l}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(s,e,i){if(i.adjust)return;const f=this.get(l)==="video"?"video":"image";this.addAttributes({[C]:f,href:""})},adjustSourceType(){const s=this.get(l),e=this.getAttributes().href||"",i={adjust:!0};if(s==="video"){const o=e.includes("youtube.com")?"youtube":"video";this.addAttributes({[C]:o},i)}else s!=="el"&&e.startsWith("#")?this.set(l,"el",i):s==="image"&&this.addAttributes({[C]:"image"},i)},updateTraits(s={}){const{changed:e}=this,{init:i}=s;if(e[v.name]||i){this.removeTrait([V.name,A.name,E.name]);const o=this.get(l)||"image",f=this.getTraitIndex(l)+1;this.addTrait($[o],{at:f})}},initToolbar(){if(!d)return;const{toolbar:s}=this,e=b(this);!s.find(o=>o.id===e.id)&&(s==null||s.unshift(e))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var L;const{em:s,el:e,model:i}=this,{Canvas:o}=s,f=i.getAttributes()[k],{defaultView:u,documentElement:N}=e.ownerDocument,_=(L=u.fsLightboxInstances)==null?void 0:L[f];if(N.classList.contains(Q))_.close();else{e.__skipLb=!1;let y;_.props.onOpen=()=>{y=o.getSpots(),setTimeout(()=>o.removeSpots())},_.props.onClose=()=>{y.forEach(I=>o.addSpot(I.attributes))},e.click()}}}}),q({editor:t,plan:Y,licenseKey:g.licenseKey,pluginName:X,cleanup:()=>{r.remove(T),c.removeType(T)}})},te=Z(ee);module.exports=te;
@@ -1,6 +1,6 @@
1
- const P = "app.grapesjs.com", B = "app-stage.grapesjs.com", N = [
2
- P,
3
- B,
1
+ const O = "app.grapesjs.com", U = "app-stage.grapesjs.com", P = [
2
+ O,
3
+ U,
4
4
  "localhost",
5
5
  "127.0.0.1",
6
6
  ".local-credentialless.webcontainer.io",
@@ -9,9 +9,9 @@ const P = "app.grapesjs.com", B = "app-stage.grapesjs.com", N = [
9
9
  // For stackblitz.com demos
10
10
  "-sandpack.codesandbox.io"
11
11
  // For Sandpack demos
12
- ], D = "license:check:start", U = "license:check:end", R = () => typeof window < "u", W = ({ isDev: t, isStage: a }) => `${t ? "" : `https://${a ? B : P}`}/api`, F = () => {
12
+ ], B = "license:check:start", D = "license:check:end", R = () => typeof window < "u", W = ({ isDev: t, isStage: a }) => `${t ? "" : `https://${a ? U : O}`}/api`, F = () => {
13
13
  const t = R() && window.location.hostname;
14
- return !!t && (N.includes(t) || N.some((a) => t.endsWith(a)));
14
+ return !!t && (P.includes(t) || P.some((a) => t.endsWith(a)));
15
15
  };
16
16
  async function K({
17
17
  path: t,
@@ -35,7 +35,7 @@ async function K({
35
35
  return b.json();
36
36
  }
37
37
  var x = /* @__PURE__ */ ((t) => (t.free = "free", t.startup = "startup", t.business = "business", t.enterprise = "enterprise", t))(x || {});
38
- const O = {
38
+ const M = {
39
39
  [x.free]: 0,
40
40
  [x.startup]: 10,
41
41
  [x.business]: 20,
@@ -62,13 +62,13 @@ async function q({
62
62
  if (!(l || n.license) || b)
63
63
  d(b || "Invalid license");
64
64
  else if (v) {
65
- const E = O[a], $ = O[v];
65
+ const E = M[a], $ = M[v];
66
66
  E > $ && d({ pluginRequiredPlan: a, licensePlan: v });
67
67
  }
68
68
  };
69
- t.on(D, (n) => {
69
+ t.on(B, (n) => {
70
70
  h = n == null ? void 0 : n.baseApiUrl, g = !0;
71
- }), t.on(U, (n) => {
71
+ }), t.on(D, (n) => {
72
72
  m(n);
73
73
  }), setTimeout(async () => {
74
74
  if (!g) {
@@ -97,13 +97,13 @@ async function z(t) {
97
97
  return console.error("Error during SDK license check:", p), !1;
98
98
  }
99
99
  }
100
- const J = "gjs-plg-", X = "fsLightboxComponent", k = "data-fslightbox", C = "data-type", Y = "fslightbox-open", T = "fslightbox", S = {
100
+ const J = "gjs-plg-", X = "fsLightboxComponent", Y = x.startup, k = "data-fslightbox", C = "data-type", Q = "fslightbox-open", T = "fslightbox", S = {
101
101
  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>',
102
102
  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>',
103
103
  imageLightbox: '<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>',
104
104
  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>',
105
105
  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>'
106
- }, Q = function(t, a = {}) {
106
+ }, ee = function(t, a = {}) {
107
107
  const { Blocks: r, Components: c } = t, p = "Lightbox", h = `${J}${T}`, g = {
108
108
  toolbarIconOpen: S.eye,
109
109
  block: {},
@@ -112,17 +112,17 @@ const J = "gjs-plg-", X = "fsLightboxComponent", k = "data-fslightbox", C = "dat
112
112
  ...a
113
113
  }, { block: w, toolbarIconOpen: d, defaultSrc: m } = g, n = function(s) {
114
114
  const e = this, i = "data-fslightbox", o = window, f = () => {
115
- var H;
115
+ var j;
116
116
  const u = o.refreshFsLightbox;
117
117
  u == null || u();
118
- const j = e.getAttribute(i);
119
- if ((H = o.fsLightboxInstances) == null || H[j], !o._isEditor) return;
120
- Array.from(document.querySelectorAll(`[${i}]`)).forEach((y) => {
121
- const L = y.onclick;
122
- y.onclick = function(I) {
118
+ const N = e.getAttribute(i);
119
+ if ((j = o.fsLightboxInstances) == null || j[N], !o._isEditor) return;
120
+ Array.from(document.querySelectorAll(`[${i}]`)).forEach((L) => {
121
+ const y = L.onclick;
122
+ L.onclick = function(I) {
123
123
  I.preventDefault();
124
- const M = y;
125
- !M.__skipLb && (L == null || L(I)), M.__skipLb = !0;
124
+ const H = L;
125
+ !H.__skipLb && (y == null || y(I)), H.__skipLb = !0;
126
126
  };
127
127
  });
128
128
  };
@@ -259,31 +259,31 @@ const J = "gjs-plg-", X = "fsLightboxComponent", k = "data-fslightbox", C = "dat
259
259
  this.el.__skipLb = !0;
260
260
  },
261
261
  toggleLightbox() {
262
- var y;
263
- const { em: s, el: e, model: i } = this, { Canvas: o } = s, f = i.getAttributes()[k], { defaultView: u, documentElement: j } = e.ownerDocument, _ = (y = u.fsLightboxInstances) == null ? void 0 : y[f];
264
- if (j.classList.contains(Y))
262
+ var L;
263
+ const { em: s, el: e, model: i } = this, { Canvas: o } = s, f = i.getAttributes()[k], { defaultView: u, documentElement: N } = e.ownerDocument, _ = (L = u.fsLightboxInstances) == null ? void 0 : L[f];
264
+ if (N.classList.contains(Q))
265
265
  _.close();
266
266
  else {
267
267
  e.__skipLb = !1;
268
- let L;
268
+ let y;
269
269
  _.props.onOpen = () => {
270
- L = o.getSpots(), setTimeout(() => o.removeSpots());
270
+ y = o.getSpots(), setTimeout(() => o.removeSpots());
271
271
  }, _.props.onClose = () => {
272
- L.forEach((I) => o.addSpot(I.attributes));
272
+ y.forEach((I) => o.addSpot(I.attributes));
273
273
  }, e.click();
274
274
  }
275
275
  }
276
276
  }
277
277
  }), q({
278
278
  editor: t,
279
- plan: x.startup,
279
+ plan: Y,
280
280
  licenseKey: g.licenseKey,
281
281
  pluginName: X,
282
282
  cleanup: () => {
283
283
  r.remove(T), c.removeType(T);
284
284
  }
285
285
  });
286
- }, ee = Z(Q);
286
+ }, te = Z(ee);
287
287
  export {
288
- ee as default
288
+ te as default
289
289
  };
@@ -1,6 +1,6 @@
1
- (function(v,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(v=typeof globalThis<"u"?globalThis:v||self,v.StudioSdkPlugins_fsLightboxComponent=y())})(this,function(){"use strict";const v="app.grapesjs.com",y="app-stage.grapesjs.com",O=[v,y,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],D="license:check:start",U="license:check:end",R=()=>typeof window<"u",W=({isDev:t,isStage:a})=>`${t?"":`https://${a?y:v}`}/api`,F=()=>{const t=R()&&window.location.hostname;return!!t&&(O.includes(t)||O.some(a=>t.endsWith(a)))};async function K({path:t,baseApiUrl:a,method:r="GET",headers:c={},params:d,body:h}){const E=`${a||W({isDev:!1,isStage:!1})}${t}`,p={method:r,headers:{"Content-Type":"application/json",...c}};h&&(p.body=JSON.stringify(h));const m=d?new URLSearchParams(d).toString():"",s=m?`?${m}`:"",b=await fetch(`${E}${s}`,p);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}var T=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(T||{});const P={[T.free]:0,[T.startup]:10,[T.business]:20,[T.enterprise]:30};function G(t){const a=t;return a.init=r=>c=>t(c,r),a}const Z=t=>G(t);async function q({editor:t,plan:a,pluginName:r,licenseKey:c,cleanup:d}){let h="",g=!1;const E=F(),p=s=>{console.warn("Cleanup plugin:",r,"Reason:",s),d()},m=(s={})=>{var _;const{error:b,sdkLicense:l}=s,x=(_=s.plan)==null?void 0:_.category;if(!(l||s.license)||b)p(b||"Invalid license");else if(x){const C=P[a],H=P[x];C>H&&p({pluginRequiredPlan:a,licensePlan:x})}};t.on(D,s=>{h=s==null?void 0:s.baseApiUrl,g=!0}),t.on(U,s=>{m(s)}),setTimeout(async()=>{if(!g){if(E)return;if(c){const s=await z({licenseKey:c,pluginName:r,baseApiUrl:h});s&&m(s)}else p("The `licenseKey` option not provided")}},2e3)}async function z(t){const{licenseKey:a,pluginName:r,baseApiUrl:c}=t;try{return(await K({baseApiUrl:c,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(d){return console.error("Error during SDK license check:",d),!1}}const J="gjs-plg-",X="fsLightboxComponent",k="data-fslightbox",I="data-type",Y="fslightbox-open",L="fslightbox",S={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>',imageLightbox:'<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>',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>'};return Z(function(t,a={}){const{Blocks:r,Components:c}=t,d="Lightbox",h=`${J}${L}`,g={toolbarIconOpen:S.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...a},{block:E,toolbarIconOpen:p,defaultSrc:m}=g,s=function(n){const e=this,i="data-fslightbox",o=window,f=()=>{var N;const u=o.refreshFsLightbox;u==null||u();const M=e.getAttribute(i);if((N=o.fsLightboxInstances)==null||N[M],!o._isEditor)return;Array.from(document.querySelectorAll(`[${i}]`)).forEach(w=>{const A=w.onclick;w.onclick=function($){$.preventDefault();const B=w;!B.__skipLb&&(A==null||A($)),B.__skipLb=!0}})};if(o.refreshFsLightbox)f();else{const u=document.createElement("script");u.src=n.cdnScript,u.onload=f,document.head.appendChild(u)}},b=n=>({id:`${L}-open-lb`,label:p,command:()=>{const e=n.getView();e==null||e.toggleLightbox()}}),l="source-type",x={type:"radio",name:l,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:S.image},{id:"video",label:"Video",icon:S.video},{id:"el",label:"Custom Element",icon:S.external}],labelToTitle:!0},j={id:"href-image",name:"href",type:"file",label:"Source Image"},_={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},C={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},H={image:[j],video:[_],el:[C]};c.addType(L,{block:E&&{label:d,media:S.imageLightbox,category:"Extra",select:!0,...g.block},isComponent:n=>{var e;return(e=n.hasAttribute)==null?void 0:e.call(n,k)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:d,icon:S.imageLightbox,classes:h,draggable:(n,e)=>!e.is(L),attributes:{[k]:"lightbox",[I]:"image",href:m},components:{type:"image",src:m},script:s,cdnScript:g.cdnScript,"script-props":["attributes","cdnScript"],[l]:"image",traits:[x,{name:k,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(n,e){var o;const i=(o=e.target)==null?void 0:o.getView();i==null||i.toggleLightbox()}}],styles:`
1
+ (function(v,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(v=typeof globalThis<"u"?globalThis:v||self,v.StudioSdkPlugins_fsLightboxComponent=y())})(this,function(){"use strict";const v="app.grapesjs.com",y="app-stage.grapesjs.com",M=[v,y,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],B="license:check:start",D="license:check:end",R=()=>typeof window<"u",W=({isDev:t,isStage:a})=>`${t?"":`https://${a?y:v}`}/api`,F=()=>{const t=R()&&window.location.hostname;return!!t&&(M.includes(t)||M.some(a=>t.endsWith(a)))};async function K({path:t,baseApiUrl:a,method:r="GET",headers:c={},params:d,body:h}){const E=`${a||W({isDev:!1,isStage:!1})}${t}`,p={method:r,headers:{"Content-Type":"application/json",...c}};h&&(p.body=JSON.stringify(h));const m=d?new URLSearchParams(d).toString():"",s=m?`?${m}`:"",b=await fetch(`${E}${s}`,p);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}var L=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(L||{});const O={[L.free]:0,[L.startup]:10,[L.business]:20,[L.enterprise]:30};function G(t){const a=t;return a.init=r=>c=>t(c,r),a}const Z=t=>G(t);async function q({editor:t,plan:a,pluginName:r,licenseKey:c,cleanup:d}){let h="",g=!1;const E=F(),p=s=>{console.warn("Cleanup plugin:",r,"Reason:",s),d()},m=(s={})=>{var _;const{error:b,sdkLicense:l}=s,x=(_=s.plan)==null?void 0:_.category;if(!(l||s.license)||b)p(b||"Invalid license");else if(x){const C=O[a],N=O[x];C>N&&p({pluginRequiredPlan:a,licensePlan:x})}};t.on(B,s=>{h=s==null?void 0:s.baseApiUrl,g=!0}),t.on(D,s=>{m(s)}),setTimeout(async()=>{if(!g){if(E)return;if(c){const s=await z({licenseKey:c,pluginName:r,baseApiUrl:h});s&&m(s)}else p("The `licenseKey` option not provided")}},2e3)}async function z(t){const{licenseKey:a,pluginName:r,baseApiUrl:c}=t;try{return(await K({baseApiUrl:c,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(d){return console.error("Error during SDK license check:",d),!1}}const J="gjs-plg-",X="fsLightboxComponent",Y=L.startup,I="data-fslightbox",k="data-type",Q="fslightbox-open",T="fslightbox",S={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>',imageLightbox:'<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>',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>'};return Z(function(t,a={}){const{Blocks:r,Components:c}=t,d="Lightbox",h=`${J}${T}`,g={toolbarIconOpen:S.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...a},{block:E,toolbarIconOpen:p,defaultSrc:m}=g,s=function(n){const e=this,i="data-fslightbox",o=window,f=()=>{var H;const u=o.refreshFsLightbox;u==null||u();const P=e.getAttribute(i);if((H=o.fsLightboxInstances)==null||H[P],!o._isEditor)return;Array.from(document.querySelectorAll(`[${i}]`)).forEach(w=>{const A=w.onclick;w.onclick=function($){$.preventDefault();const U=w;!U.__skipLb&&(A==null||A($)),U.__skipLb=!0}})};if(o.refreshFsLightbox)f();else{const u=document.createElement("script");u.src=n.cdnScript,u.onload=f,document.head.appendChild(u)}},b=n=>({id:`${T}-open-lb`,label:p,command:()=>{const e=n.getView();e==null||e.toggleLightbox()}}),l="source-type",x={type:"radio",name:l,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:S.image},{id:"video",label:"Video",icon:S.video},{id:"el",label:"Custom Element",icon:S.external}],labelToTitle:!0},j={id:"href-image",name:"href",type:"file",label:"Source Image"},_={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},C={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},N={image:[j],video:[_],el:[C]};c.addType(T,{block:E&&{label:d,media:S.imageLightbox,category:"Extra",select:!0,...g.block},isComponent:n=>{var e;return(e=n.hasAttribute)==null?void 0:e.call(n,I)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:d,icon:S.imageLightbox,classes:h,draggable:(n,e)=>!e.is(T),attributes:{[I]:"lightbox",[k]:"image",href:m},components:{type:"image",src:m},script:s,cdnScript:g.cdnScript,"script-props":["attributes","cdnScript"],[l]:"image",traits:[x,{name:I,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(n,e){var o;const i=(o=e.target)==null?void 0:o.getView();i==null||i.toggleLightbox()}}],styles:`
2
2
  .${h} {
3
3
  display: inline-block;
4
4
  padding: 10px;
5
5
  }
6
- `},init(){const n=[l].map(e=>`change:${e}`).join(" ");this.on(n,this.updateTraits),this.on(`change:${l}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(n,e,i){if(i.adjust)return;const f=this.get(l)==="video"?"video":"image";this.addAttributes({[I]:f,href:""})},adjustSourceType(){const n=this.get(l),e=this.getAttributes().href||"",i={adjust:!0};if(n==="video"){const o=e.includes("youtube.com")?"youtube":"video";this.addAttributes({[I]:o},i)}else n!=="el"&&e.startsWith("#")?this.set(l,"el",i):n==="image"&&this.addAttributes({[I]:"image"},i)},updateTraits(n={}){const{changed:e}=this,{init:i}=n;if(e[x.name]||i){this.removeTrait([j.name,_.name,C.name]);const o=this.get(l)||"image",f=this.getTraitIndex(l)+1;this.addTrait(H[o],{at:f})}},initToolbar(){if(!p)return;const{toolbar:n}=this,e=b(this);!n.find(o=>o.id===e.id)&&(n==null||n.unshift(e))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var w;const{em:n,el:e,model:i}=this,{Canvas:o}=n,f=i.getAttributes()[k],{defaultView:u,documentElement:M}=e.ownerDocument,V=(w=u.fsLightboxInstances)==null?void 0:w[f];if(M.classList.contains(Y))V.close();else{e.__skipLb=!1;let A;V.props.onOpen=()=>{A=o.getSpots(),setTimeout(()=>o.removeSpots())},V.props.onClose=()=>{A.forEach($=>o.addSpot($.attributes))},e.click()}}}}),q({editor:t,plan:T.startup,licenseKey:g.licenseKey,pluginName:X,cleanup:()=>{r.remove(L),c.removeType(L)}})})});
6
+ `},init(){const n=[l].map(e=>`change:${e}`).join(" ");this.on(n,this.updateTraits),this.on(`change:${l}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(n,e,i){if(i.adjust)return;const f=this.get(l)==="video"?"video":"image";this.addAttributes({[k]:f,href:""})},adjustSourceType(){const n=this.get(l),e=this.getAttributes().href||"",i={adjust:!0};if(n==="video"){const o=e.includes("youtube.com")?"youtube":"video";this.addAttributes({[k]:o},i)}else n!=="el"&&e.startsWith("#")?this.set(l,"el",i):n==="image"&&this.addAttributes({[k]:"image"},i)},updateTraits(n={}){const{changed:e}=this,{init:i}=n;if(e[x.name]||i){this.removeTrait([j.name,_.name,C.name]);const o=this.get(l)||"image",f=this.getTraitIndex(l)+1;this.addTrait(N[o],{at:f})}},initToolbar(){if(!p)return;const{toolbar:n}=this,e=b(this);!n.find(o=>o.id===e.id)&&(n==null||n.unshift(e))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var w;const{em:n,el:e,model:i}=this,{Canvas:o}=n,f=i.getAttributes()[I],{defaultView:u,documentElement:P}=e.ownerDocument,V=(w=u.fsLightboxInstances)==null?void 0:w[f];if(P.classList.contains(Q))V.close();else{e.__skipLb=!1;let A;V.props.onOpen=()=>{A=o.getSpots(),setTimeout(()=>o.removeSpots())},V.props.onClose=()=>{A.forEach($=>o.addSpot($.attributes))},e.click()}}}}),q({editor:t,plan:Y,licenseKey:g.licenseKey,pluginName:X,cleanup:()=>{r.remove(T),c.removeType(T)}})})});
@@ -0,0 +1,3 @@
1
+ import { SdkPlanCategories } from '../utils';
2
+ export declare const PLUGIN_NAME = "fsLightboxComponent";
3
+ export declare const PLUGIN_PLAN = SdkPlanCategories.startup;