@grapesjs/studio-sdk-plugins 1.0.35 → 1.0.36

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 (88) hide show
  1. package/dist/accordionComponent/index.cjs.js +7 -7
  2. package/dist/accordionComponent/index.es.js +175 -162
  3. package/dist/accordionComponent/index.umd.js +7 -7
  4. package/dist/aiChat/index.cjs.js +64 -64
  5. package/dist/aiChat/index.es.js +5785 -5757
  6. package/dist/aiChat/index.js +64 -64
  7. package/dist/aiChat/index.umd.js +63 -63
  8. package/dist/animationComponent/index.cjs.js +3 -3
  9. package/dist/animationComponent/index.es.js +204 -191
  10. package/dist/animationComponent/index.umd.js +3 -3
  11. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  12. package/dist/canvasAbsoluteMode/index.es.js +183 -170
  13. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  14. package/dist/canvasEmptyState/index.cjs.js +1 -1
  15. package/dist/canvasEmptyState/index.es.js +134 -121
  16. package/dist/canvasEmptyState/index.umd.js +1 -1
  17. package/dist/canvasFullSize/index.cjs.js +9 -9
  18. package/dist/canvasFullSize/index.es.js +165 -152
  19. package/dist/canvasFullSize/index.umd.js +9 -9
  20. package/dist/canvasGridMode/index.cjs.js +5 -5
  21. package/dist/canvasGridMode/index.es.js +245 -232
  22. package/dist/canvasGridMode/index.umd.js +4 -4
  23. package/dist/canvasScreenshot/index.cjs.js +1 -1
  24. package/dist/canvasScreenshot/index.es.js +155 -142
  25. package/dist/canvasScreenshot/index.umd.js +1 -1
  26. package/dist/dataSourceEjs/index.cjs.js +9 -9
  27. package/dist/dataSourceEjs/index.es.js +257 -244
  28. package/dist/dataSourceEjs/index.umd.js +9 -9
  29. package/dist/dataSourceHandlebars/index.cjs.js +8 -8
  30. package/dist/dataSourceHandlebars/index.es.js +216 -203
  31. package/dist/dataSourceHandlebars/index.umd.js +7 -7
  32. package/dist/dialogComponent/index.cjs.js +14 -14
  33. package/dist/dialogComponent/index.es.js +141 -128
  34. package/dist/dialogComponent/index.umd.js +14 -14
  35. package/dist/flexComponent/index.cjs.js +13 -13
  36. package/dist/flexComponent/index.es.js +484 -471
  37. package/dist/flexComponent/index.umd.js +13 -13
  38. package/dist/fsLightboxComponent/index.cjs.js +3 -3
  39. package/dist/fsLightboxComponent/index.es.js +173 -160
  40. package/dist/fsLightboxComponent/index.umd.js +3 -3
  41. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  42. package/dist/googleFontsAssetProvider/index.es.js +160 -147
  43. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  44. package/dist/iconifyComponent/index.cjs.js +2 -2
  45. package/dist/iconifyComponent/index.es.js +196 -183
  46. package/dist/iconifyComponent/index.umd.js +2 -2
  47. package/dist/index.cjs.js +25 -25
  48. package/dist/index.es.js +121 -108
  49. package/dist/index.umd.js +18 -18
  50. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  51. package/dist/layoutSidebarButtons/index.es.js +157 -144
  52. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  53. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  54. package/dist/lightGalleryComponent/index.es.js +245 -232
  55. package/dist/lightGalleryComponent/index.umd.js +1 -1
  56. package/dist/linkImageComponent/index.cjs.js +2 -2
  57. package/dist/linkImageComponent/index.es.js +106 -93
  58. package/dist/linkImageComponent/index.umd.js +2 -2
  59. package/dist/listPagesComponent/index.cjs.js +5 -5
  60. package/dist/listPagesComponent/index.es.js +157 -144
  61. package/dist/listPagesComponent/index.umd.js +5 -5
  62. package/dist/presetPrintable/index.cjs.js +3 -3
  63. package/dist/presetPrintable/index.es.js +181 -168
  64. package/dist/presetPrintable/index.umd.js +3 -3
  65. package/dist/prosemirror/index.cjs.js +7 -7
  66. package/dist/prosemirror/index.es.js +385 -372
  67. package/dist/prosemirror/index.umd.js +8 -8
  68. package/dist/rendererReact/index.cjs.js +1 -1
  69. package/dist/rendererReact/index.es.js +200 -187
  70. package/dist/rendererReact/index.js +1 -1
  71. package/dist/rendererReact/index.umd.js +1 -1
  72. package/dist/rteTinyMce/index.cjs.js +2 -2
  73. package/dist/rteTinyMce/index.es.js +118 -105
  74. package/dist/rteTinyMce/index.umd.js +2 -2
  75. package/dist/shapeDividerComponent/index.cjs.js +4 -4
  76. package/dist/shapeDividerComponent/index.es.js +129 -116
  77. package/dist/shapeDividerComponent/index.umd.js +4 -4
  78. package/dist/swiperComponent/index.cjs.js +9 -9
  79. package/dist/swiperComponent/index.es.js +203 -190
  80. package/dist/swiperComponent/index.umd.js +7 -7
  81. package/dist/tableComponent/index.cjs.js +1 -1
  82. package/dist/tableComponent/index.es.js +257 -244
  83. package/dist/tableComponent/index.umd.js +1 -1
  84. package/dist/types.d.ts +1 -1
  85. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  86. package/dist/youtubeAssetProvider/index.es.js +121 -108
  87. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  88. package/package.json +1 -1
@@ -1 +1 @@
1
- (function(C,N){typeof exports=="object"&&typeof module<"u"?module.exports=N():typeof define=="function"&&define.amd?define(N):(C=typeof globalThis<"u"?globalThis:C||self,C.StudioSdkPlugins_canvasAbsoluteMode=N())})(this,function(){"use strict";const C="app.grapesjs.com",N="app-stage.grapesjs.com",W=[C,"app2.grapesjs.com",N,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],X="license:check:start",F="license:check:end",q=()=>typeof window<"u",J=({isDev:t,isStage:a,isPlatform:u})=>`${t?"":`https://${a?N:C}`}/${u?"platform-api":"api"}`,k=()=>{const t=q()&&window.location.hostname;return!!t&&(W.includes(t)||W.some(a=>t.endsWith(a)))};function z(t){return typeof t=="function"}async function Q({path:t,baseApiUrl:a,method:u="GET",headers:l={},params:i,body:o}){const n=`${a||J({isDev:!1,isStage:!1})}${t}`,g={method:u,headers:{"Content-Type":"application/json",...l}};o&&(g.body=JSON.stringify(o));const d=i?new URLSearchParams(i).toString():"",c=d?`?${d}`:"",e=await fetch(`${n}${c}`,g);if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.json()}var G=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(G||{});const Y={[G.free]:0,[G.startup]:10,[G.business]:20,[G.enterprise]:30};function Z(t){const a=t;return a.init=u=>l=>t(l,u),a}const tt=t=>Z(t);async function et({editor:t,plan:a,pluginName:u,licenseKey:l,onLicenseCheckResponse:i,cleanup:o}){let s="",n=!1;const g=k(),d=e=>{console.warn("Cleanup plugin:",u,"Reason:",e),o()},c=(e={})=>{var b;const{error:r,sdkLicense:f}=e,y=(b=e.plan)==null?void 0:b.category;if(!(f||e.license)||r)d(r||"Invalid license");else if(y){const v=Y[a],E=Y[y];v>E&&d({pluginRequiredPlan:a,licensePlan:y})}};t.on(X,e=>{s=e==null?void 0:e.baseApiUrl,n=!0}),t.on(F,e=>{i==null||i(e),c(e)}),setTimeout(async()=>{if(!n){if(g)return;if(l){const e=await nt({licenseKey:l,pluginName:u,baseApiUrl:s});i==null||i(e),e&&c(e)}else d("The `licenseKey` option not provided")}},2e3)}async function nt(t){const{licenseKey:a,pluginName:u,baseApiUrl:l}=t;try{return(await Q({baseApiUrl:l,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:u}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const ot="canvasAbsoluteMode",st=G.startup,it=(t,a,u)=>{var d,c;const l=u.enableAbsolute??(e=>e.hasAbsolute),o=(Array.isArray(a)?a:a?[a]:[...t.getSelectedAll()])[0],s=((c=(d=o==null?void 0:o.delegate)==null?void 0:d.move)==null?void 0:c.call(d,o))||o;if(!s)return;const n=s.getEl();return{result:z(l)?l({component:s,hasAbsolute:!!n&&getComputedStyle(n).position==="absolute"}):!1,component:s,dmode:s.get("dmode")}};function L({guideMatched:t,canvasView:a}){var R;const u=t.guide.x===void 0?"y":"x";let l=0,i=0,o=0,s=0;const{guide:n,matched:g}=t,d=a.getElBoxRect(n.componentView.el),c=a.getElBoxRect(((R=g.componentView)==null?void 0:R.el)||g.componentEl),e=d.y,r=d.y+d.height,f=d.x,y=d.x+d.width,S=c.y,b=c.y+c.height,v=c.x,E=c.x+c.width,x=Math.max(0,e-b),m=Math.max(0,S-r),w=Math.max(0,f-E),M=Math.max(0,v-y),p=x>m,h=w>M,_=n.type;return u==="x"&&(_==="l"?(l=f,p?(i=b,o=x):(i=r,o=m)):_==="r"?(l=y,p?(i=b,o=x):(i=r,o=m)):_==="x"&&(l=f-(f-y)/2,p?(i=b,o=x):(i=r,o=m))),u==="y"&&(_==="t"?(i=e,h?(l=E,s=w):(l=y,s=M)):_==="b"?(i=r,h?(l=E,s=w):(l=y,s=M)):_==="y"&&(i=e-(e-r)/2,h?(l=E,s=w):(l=y,s=M))),{axis:u,x:l,y:i,width:s,height:o}}function ct({guideMatched:t,component:a,canvasView:u}){const l=t.guide.x===void 0?"x":"y",{guide:i,matched:o}=t,s=i.type,n=o.type,g=u.getElementPos(i.componentView.el).rect,d=u.getElementPos(o.componentView.el).rect;if(l==="x"){const c=g.height,e=d.top,r=d.top+d.height;let f=0;s==="t"?n==="t"?f=e-c:n==="b"?f=r-c:n==="y"&&(f=e-c-(e-r)/2):s==="b"?n==="t"?f=e-c*2:n==="b"?f=r-c*2:n==="y"&&(f=e-c*2-(e-r)/2):s==="y"&&(n==="t"?f=e-c*1.5:n==="b"?f=r-c*1.5:n==="y"&&(f=e-c*1.5-(e-r)/2)),a.addStyle({top:`${f-5}px`},{partial:!0})}if(l==="y"){const c=g.width,e=d.left,r=d.left+d.width;let f=0;s==="l"?n==="l"?f=e:n==="r"?f=r:n==="x"&&(f=e-(e-r)/2):s==="r"?n==="l"?f=e-c:n==="r"?f=r-c:n==="x"&&(f=e-c-(e-r)/2):s==="x"&&(n==="l"?f=e-c/2:n==="r"&&(f=r-c/2)),a.addStyle({left:`${f}px`},{partial:!0})}}function K({snapping:t,editor:a,props:u}){var B,P;const{command:l,guidesMatched:i}=u,o=u.component,s=o.getEl(),n=a.Canvas.getCanvasView(),{x:g,y:d}=t??{x:10,y:10},c=l.opts.event,e=c.clientX,r=c.clientY;if(!o.__lastSnappedPosition){const A=n.getElBoxRect(s),D=e-A.x,T=r-A.y;o.__lastSnappedPosition={left:A.x,top:A.y},o.__dragOffset={x:D,y:T}}const f=((B=o.__dragOffset)==null?void 0:B.x)||0,y=((P=o.__dragOffset)==null?void 0:P.y)||0,S=o.__lastSnappedPosition,b=e-S.left-f,v=r-S.top-y;let E=S.left,x=S.top;const m=i==null?void 0:i[0],w=(m==null?void 0:m.guide.type)==="l",M=(m==null?void 0:m.guide.type)==="x",p=(m==null?void 0:m.guide.type)==="r",h=(m==null?void 0:m.guide.type)==="t",_=(m==null?void 0:m.guide.type)==="b",R=(m==null?void 0:m.guide.type)==="y";if(m){const{x:A,y:D}=L({guideMatched:m,canvasView:n}),T=s.offsetWidth,I=s.offsetHeight;w?E=A:p?E=A-T:M?E=A-T/2:h?x=D:_?x=D-I:R&&(x=D-I/2),o.__lastSnappedGuideMatched=m}else Math.abs(b)>=g&&(E=Math.round((S.left+b)/g)*g,o.__lastSnappedGuideMatched=null),Math.abs(v)>=d&&(x=Math.round((S.top+v)/d)*d,o.__lastSnappedGuideMatched=null);return o.addStyle({left:`${E}px`,top:`${x}px`},{partial:!0}),o.__lastSnappedPosition={left:E,top:x},{x:E,y:x,guideMatched:o.__lastSnappedGuideMatched}}function at({snapping:t,props:a,editor:u}){const{x:l,y:i}=K({snapping:t,props:a,editor:u}),o=a.component;o.addStyle({left:`${l}px`,top:`${i}px`}),delete o.__lastSnappedPosition,delete o.__lastSnappedGuideMatched}const lt="core:component-drag",dt="studio:setDragAbsolute",ft="dmode:start",V="dmode:move",j="dmode:end",U="dragAbsolute",rt="select",pt="hover",ut="spacing";return tt(function(t,a={}){const{Commands:u}=t,l=u.events,i=u.getConfig().defaultOptions??{},o=`${l.runBeforeCommand}tlb-move`;i[lt]={run:p=>({...p,skipGuidesRender:!0})};const{snapping:s,locking:n,globalAbsolute:g=!0}=a;g&&t.setDragMode("absolute");const d=!!(s!=null&&s.x||s!=null&&s.y),c=!!(n!=null&&n.x||n!=null&&n.y),{Canvas:e}=t;let r=null;const f=p=>{const{component:h,guidesMatched:_,command:R}=p,B=h.view,P=t.Canvas.getCanvasView(),A=h.getEl();let D=_.map(O=>O.matched.componentEl),T=_.map(O=>L({guideMatched:O,canvasView:P}));if(d){const{guideMatched:O}=K({snapping:s,props:p,editor:t});O?(D=[O.matched.componentEl],T=[L({guideMatched:O,canvasView:P})]):(D=[],T=[])}if(c)if(R.opts.event.shiftKey)if(!r)r=_[0];else{const $=r,H=$.guide.x===void 0?"x":"y";(H==="x"&&(n==null?void 0:n.x)||H==="y"&&(n==null?void 0:n.y))&&(ct({guideMatched:$,component:h,canvasView:P}),D=[$.matched.componentEl],T=[L({guideMatched:$,canvasView:P})])}else r=null;const I={id:U,type:U,component:h,componentView:B,originComponent:A,matchedComponents:D,originMatchedDistances:T};e.addSpot(I)},y=({enabled:p})=>{t.runCommand(dt,{enabled:p})},S=({type:p})=>{e.removeSpots({type:p})},b=()=>{S({type:rt}),S({type:pt}),S({type:ut})},v=p=>{y({enabled:!0}),f(p),b()},E=p=>{f(p),b()},x=p=>{S({type:U}),d&&at({snapping:s,props:p,editor:t}),y({enabled:!1})},M=[[ft,p=>{v(p),t.on(V,E);const h=()=>{x(p),t.off(V,E),t.off(j,h)};t.on(j,h)}],[o,p=>{if(g)return;const h=p.options.target,_=it(t,h,a);_!=null&&_.result&&!_.dmode&&(p.options.mode="absolute")}]];M.forEach(([p,h])=>t.on(p,h)),et({editor:t,licenseKey:a.licenseKey,plan:st,pluginName:ot,cleanup:()=>{y({enabled:!1}),M.forEach(([p,h])=>t.off(p,h))}})})});
1
+ (function(w,S){typeof exports=="object"&&typeof module<"u"?module.exports=S():typeof define=="function"&&define.amd?define(S):(w=typeof globalThis<"u"?globalThis:w||self,w.StudioSdkPlugins_canvasAbsoluteMode=S())})(this,function(){"use strict";const w="app.grapesjs.com",S="app-stage.grapesjs.com",j=[w,"app2.grapesjs.com",S,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],H="license:check:end",q=()=>typeof window<"u",J=({isDev:e,isStage:a,isPlatform:u})=>`${e?"":`https://${a?S:w}`}/${u?"platform-api":"api"}`,z=()=>{const e=q()&&window.location.hostname;return!!e&&(j.includes(e)||j.some(a=>e.endsWith(a)))};function Q(e){return typeof e=="function"}async function Z({path:e,baseApiUrl:a,method:u="GET",headers:c={},params:l,body:s}){const t=`${a||J({isDev:!1,isStage:!1})}${e}`,h={method:u,headers:{"Content-Type":"application/json",...c}};s&&(h.body=JSON.stringify(s));const d=l?new URLSearchParams(l).toString():"",i=d?`?${d}`:"",o=await fetch(`${t}${i}`,h);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}var B=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(B||{}),Y=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(Y||{});const V={[B.free]:0,[B.startup]:10,[B.business]:20,[B.enterprise]:30};function C(e){const a=e;return a.init=u=>c=>e(c,u),a}const ee=e=>C(e);async function te({editor:e,plan:a,pluginName:u,licenseKey:c,onLicenseCheckResponse:l,cleanup:s}){let n="",t;const h=o=>{console.warn("Cleanup plugin:",u,"Reason:",o),s()},d=(o={})=>{var T;const{error:p,sdkLicense:r}=o,b=(T=o.plan)==null?void 0:T.category;if(!(r||o.license)||p)h(p||"Invalid license");else if(b){const R=V[a],E=V[b];R>E&&h({pluginRequiredPlan:a,licensePlan:b})}};e.Commands.has(Y.settings)&&(t=e.runCommand(Y.settings),n=(t==null?void 0:t.baseUrl)||"");const i=o=>{l==null||l(o),o&&d(o)};if(!t){e.onReady(async()=>{if(!z())if(c){const o=await se({licenseKey:c,pluginName:u,baseApiUrl:n});i(o)}else h("The `licenseKey` option not provided")});return}if(t.licensePlan||t.licenseError){const o=oe(t);i(o);return}e.on(H,o=>i(o))}const oe=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function se(e){const{licenseKey:a,pluginName:u,baseApiUrl:c}=e;try{return(await Z({baseApiUrl:c,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:u}})).result||{}}catch(l){return console.error("Error during SDK license check:",l),!1}}const ne="canvasAbsoluteMode",ie=B.startup,ae=(e,a,u)=>{var d,i;const c=u.enableAbsolute??(o=>o.hasAbsolute),s=(Array.isArray(a)?a:a?[a]:[...e.getSelectedAll()])[0],n=((i=(d=s==null?void 0:s.delegate)==null?void 0:d.move)==null?void 0:i.call(d,s))||s;if(!n)return;const t=n.getEl();return{result:Q(c)?c({component:n,hasAbsolute:!!t&&getComputedStyle(t).position==="absolute"}):!1,component:n,dmode:n.get("dmode")}};function N({guideMatched:e,canvasView:a}){var m;const u=e.guide.x===void 0?"y":"x";let c=0,l=0,s=0,n=0;const{guide:t,matched:h}=e,d=a.getElBoxRect(t.componentView.el),i=a.getElBoxRect(((m=h.componentView)==null?void 0:m.el)||h.componentEl),o=d.y,p=d.y+d.height,r=d.x,b=d.x+d.width,v=i.y,T=i.y+i.height,R=i.x,E=i.x+i.width,A=Math.max(0,o-T),g=Math.max(0,v-p),G=Math.max(0,r-E),D=Math.max(0,R-b),f=A>g,y=G>D,x=t.type;return u==="x"&&(x==="l"?(c=r,f?(l=T,s=A):(l=p,s=g)):x==="r"?(c=b,f?(l=T,s=A):(l=p,s=g)):x==="x"&&(c=r-(r-b)/2,f?(l=T,s=A):(l=p,s=g))),u==="y"&&(x==="t"?(l=o,y?(c=E,n=G):(c=b,n=D)):x==="b"?(l=p,y?(c=E,n=G):(c=b,n=D)):x==="y"&&(l=o-(o-p)/2,y?(c=E,n=G):(c=b,n=D))),{axis:u,x:c,y:l,width:n,height:s}}function le({guideMatched:e,component:a,canvasView:u}){const c=e.guide.x===void 0?"x":"y",{guide:l,matched:s}=e,n=l.type,t=s.type,h=u.getElementPos(l.componentView.el).rect,d=u.getElementPos(s.componentView.el).rect;if(c==="x"){const i=h.height,o=d.top,p=d.top+d.height;let r=0;n==="t"?t==="t"?r=o-i:t==="b"?r=p-i:t==="y"&&(r=o-i-(o-p)/2):n==="b"?t==="t"?r=o-i*2:t==="b"?r=p-i*2:t==="y"&&(r=o-i*2-(o-p)/2):n==="y"&&(t==="t"?r=o-i*1.5:t==="b"?r=p-i*1.5:t==="y"&&(r=o-i*1.5-(o-p)/2)),a.addStyle({top:`${r-5}px`},{partial:!0})}if(c==="y"){const i=h.width,o=d.left,p=d.left+d.width;let r=0;n==="l"?t==="l"?r=o:t==="r"?r=p:t==="x"&&(r=o-(o-p)/2):n==="r"?t==="l"?r=o-i:t==="r"?r=p-i:t==="x"&&(r=o-i-(o-p)/2):n==="x"&&(t==="l"?r=o-i/2:t==="r"&&(r=p-i/2)),a.addStyle({left:`${r}px`},{partial:!0})}}function k({snapping:e,editor:a,props:u}){var I,L;const{command:c,guidesMatched:l}=u,s=u.component,n=s.getEl(),t=a.Canvas.getCanvasView(),{x:h,y:d}=e??{x:10,y:10},i=c.opts.event,o=i.clientX,p=i.clientY;if(!s.__lastSnappedPosition){const _=t.getElBoxRect(n),P=o-_.x,M=p-_.y;s.__lastSnappedPosition={left:_.x,top:_.y},s.__dragOffset={x:P,y:M}}const r=((I=s.__dragOffset)==null?void 0:I.x)||0,b=((L=s.__dragOffset)==null?void 0:L.y)||0,v=s.__lastSnappedPosition,T=o-v.left-r,R=p-v.top-b;let E=v.left,A=v.top;const g=l==null?void 0:l[0],G=(g==null?void 0:g.guide.type)==="l",D=(g==null?void 0:g.guide.type)==="x",f=(g==null?void 0:g.guide.type)==="r",y=(g==null?void 0:g.guide.type)==="t",x=(g==null?void 0:g.guide.type)==="b",m=(g==null?void 0:g.guide.type)==="y";if(g){const{x:_,y:P}=N({guideMatched:g,canvasView:t}),M=n.offsetWidth,$=n.offsetHeight;G?E=_:f?E=_-M:D?E=_-M/2:y?A=P:x?A=P-$:m&&(A=P-$/2),s.__lastSnappedGuideMatched=g}else Math.abs(T)>=h&&(E=Math.round((v.left+T)/h)*h,s.__lastSnappedGuideMatched=null),Math.abs(R)>=d&&(A=Math.round((v.top+R)/d)*d,s.__lastSnappedGuideMatched=null);return s.addStyle({left:`${E}px`,top:`${A}px`},{partial:!0}),s.__lastSnappedPosition={left:E,top:A},{x:E,y:A,guideMatched:s.__lastSnappedGuideMatched}}function ce({snapping:e,props:a,editor:u}){const{x:c,y:l}=k({snapping:e,props:a,editor:u}),s=a.component;s.addStyle({left:`${c}px`,top:`${l}px`}),delete s.__lastSnappedPosition,delete s.__lastSnappedGuideMatched}const re="core:component-drag",de="studio:setDragAbsolute",pe="dmode:start",F="dmode:move",K="dmode:end",W="dragAbsolute",fe="select",ue="hover",ge="spacing";return ee(function(e,a={}){const{Commands:u}=e,c=u.events,l=u.getConfig().defaultOptions??{},s=`${c.runBeforeCommand}tlb-move`;l[re]={run:f=>({...f,skipGuidesRender:!0})};const{snapping:n,locking:t,globalAbsolute:h=!0}=a;h&&e.setDragMode("absolute");const d=!!(n!=null&&n.x||n!=null&&n.y),i=!!(t!=null&&t.x||t!=null&&t.y),{Canvas:o}=e;let p=null;const r=f=>{const{component:y,guidesMatched:x,command:m}=f,I=y.view,L=e.Canvas.getCanvasView(),_=y.getEl();let P=x.map(O=>O.matched.componentEl),M=x.map(O=>N({guideMatched:O,canvasView:L}));if(d){const{guideMatched:O}=k({snapping:n,props:f,editor:e});O?(P=[O.matched.componentEl],M=[N({guideMatched:O,canvasView:L})]):(P=[],M=[])}if(i)if(m.opts.event.shiftKey)if(!p)p=x[0];else{const U=p,X=U.guide.x===void 0?"x":"y";(X==="x"&&(t==null?void 0:t.x)||X==="y"&&(t==null?void 0:t.y))&&(le({guideMatched:U,component:y,canvasView:L}),P=[U.matched.componentEl],M=[N({guideMatched:U,canvasView:L})])}else p=null;const $={id:W,type:W,component:y,componentView:I,originComponent:_,matchedComponents:P,originMatchedDistances:M};o.addSpot($)},b=({enabled:f})=>{e.runCommand(de,{enabled:f})},v=({type:f})=>{o.removeSpots({type:f})},T=()=>{v({type:fe}),v({type:ue}),v({type:ge})},R=f=>{b({enabled:!0}),r(f),T()},E=f=>{r(f),T()},A=f=>{v({type:W}),d&&ce({snapping:n,props:f,editor:e}),b({enabled:!1})},D=[[pe,f=>{R(f),e.on(F,E);const y=()=>{A(f),e.off(F,E),e.off(K,y)};e.on(K,y)}],[s,f=>{if(h)return;const y=f.options.target,x=ae(e,y,a);x!=null&&x.result&&!x.dmode&&(f.options.mode="absolute")}]];D.forEach(([f,y])=>e.on(f,y)),te({editor:e,licenseKey:a.licenseKey,plan:ie,pluginName:ne,cleanup:()=>{b({enabled:!1}),D.forEach(([f,y])=>e.off(f,y))}})})});
@@ -1 +1 @@
1
- "use strict";const W="app.grapesjs.com",D="app-stage.grapesjs.com",P="app2.grapesjs.com",$="app-stage2.grapesjs.com",U=[W,P,D,$,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],_="license:check:start",L="license:check:end",O=()=>typeof window<"u",j=({isDev:t,isStage:a,isPlatform:o})=>`${t?"":`https://${a?D:W}`}/${o?"platform-api":"api"}`,K=()=>{const t=O()&&window.location.hostname;return!!t&&(U.includes(t)||U.some(a=>t.endsWith(a)))};function G(t){return typeof t=="function"}async function k({path:t,baseApiUrl:a,method:o="GET",headers:i={},params:s,body:f}){const d=`${a||j({isDev:!1,isStage:!1})}${t}`,g={method:o,headers:{"Content-Type":"application/json",...i}};f&&(g.body=JSON.stringify(f));const l=s?new URLSearchParams(s).toString():"",h=l?`?${l}`:"",n=await fetch(`${d}${h}`,g);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return n.json()}var w=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(w||{});const M={[w.free]:0,[w.startup]:10,[w.business]:20,[w.enterprise]:30};function x(t){const a=t;return a.init=o=>i=>t(i,o),a}const F=t=>x(t);async function H({editor:t,plan:a,pluginName:o,licenseKey:i,onLicenseCheckResponse:s,cleanup:f}){let p="",d=!1;const g=K(),l=n=>{console.warn("Cleanup plugin:",o,"Reason:",n),f()},h=(n={})=>{var T;const{error:E,sdkLicense:S}=n,y=(T=n.plan)==null?void 0:T.category;if(!(S||n.license)||E)l(E||"Invalid license");else if(y){const b=M[a],A=M[y];b>A&&l({pluginRequiredPlan:a,licensePlan:y})}};t.on(_,n=>{p=n==null?void 0:n.baseApiUrl,d=!0}),t.on(L,n=>{s==null||s(n),h(n)}),setTimeout(async()=>{if(!d){if(g)return;if(i){const n=await q({licenseKey:i,pluginName:o,baseApiUrl:p});s==null||s(n),n&&h(n)}else l("The `licenseKey` option not provided")}},2e3)}async function q(t){const{licenseKey:a,pluginName:o,baseApiUrl:i}=t;try{return(await k({baseApiUrl:i,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}const B="canvasEmptyState",J=w.startup,z=function(t,a={}){const o=new WeakMap,i=new WeakMap,s=new WeakMap,f=new Set,p=new WeakMap,d={emptyStates:[],...a},g=(e,c)=>{let m=!1;const{isValid:u}=c;return Array.isArray(u)?m=u.some(r=>e.is(r)):G(u)?m=u({component:e,editor:t}):m=e.is(u),m},l=e=>{const c=o.get(e);o.delete(e),c==null||c()},h=e=>{e.views.forEach(c=>l(c)),s.delete(e)},n=e=>{if(!(!e||f.has(e)))try{f.add(e);const c=e.components().length>0,m=s.get(e);if(c&&m)h(e);else if(!c&&!m){const u=p.has(e)?p.get(e):d.emptyStates.find(r=>g(e,r));if(p.set(e,u),!u)return;e.views.forEach(r=>{const I=u.render({editor:t,component:e,componentView:r,mount:v=>{i.set(r,v),s.set(e,!0);const N=r.getChildrenContainer();N==null||N.appendChild(v)},unmount:()=>l(r)});o.set(r,()=>{I==null||I();const v=i.get(r);v==null||v.remove()})})}}finally{f.delete(e)}},E=e=>{s.has(e)&&h(e)},S=({model:e})=>{n(e.getComponent())},y=t.Components.events,C=`${y.update}:components`,T="component:mount",b=t.Canvas.events.frameLoadBody,A=y.removed;t.on(C,n),t.on(T,n),t.on(A,E),t.on(b,S),H({editor:t,licenseKey:d.licenseKey,plan:J,pluginName:B,cleanup:()=>{t.off(C,n),t.off(T,n),t.off(A,E),t.off(b,S)}})},Q=F(z);module.exports=Q;
1
+ "use strict";const O="app.grapesjs.com",x="app-stage.grapesjs.com",k="app2.grapesjs.com",B="app-stage2.grapesjs.com",I=[O,k,x,B,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],N="license:check:end",W=()=>typeof window<"u",$=({isDev:e,isStage:o,isPlatform:n})=>`${e?"":`https://${o?x:O}`}/${n?"platform-api":"api"}`,j=()=>{const e=W()&&window.location.hostname;return!!e&&(I.includes(e)||I.some(o=>e.endsWith(o)))};function F(e){return typeof e=="function"}async function _({path:e,baseApiUrl:o,method:n="GET",headers:i={},params:a,body:g}){const r=`${o||$({isDev:!1,isStage:!1})}${e}`,p={method:n,headers:{"Content-Type":"application/json",...i}};g&&(p.body=JSON.stringify(g));const y=a?new URLSearchParams(a).toString():"",f=y?`?${y}`:"",s=await fetch(`${r}${f}`,p);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return s.json()}var P=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(P||{}),M=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(M||{});const U={[P.free]:0,[P.startup]:10,[P.business]:20,[P.enterprise]:30};function K(e){const o=e;return o.init=n=>i=>e(i,n),o}const q=e=>K(e);async function H({editor:e,plan:o,pluginName:n,licenseKey:i,onLicenseCheckResponse:a,cleanup:g}){let d="",r;const p=s=>{console.warn("Cleanup plugin:",n,"Reason:",s),g()},y=(s={})=>{var A;const{error:T,sdkLicense:R}=s,h=(A=s.plan)==null?void 0:A.category;if(!(R||s.license)||T)p(T||"Invalid license");else if(h){const w=U[o],E=U[h];w>E&&p({pluginRequiredPlan:o,licensePlan:h})}};e.Commands.has(M.settings)&&(r=e.runCommand(M.settings),d=(r==null?void 0:r.baseUrl)||"");const f=s=>{a==null||a(s),s&&y(s)};if(!r){e.onReady(async()=>{if(!j())if(i){const s=await z({licenseKey:i,pluginName:n,baseApiUrl:d});f(s)}else p("The `licenseKey` option not provided")});return}if(r.licensePlan||r.licenseError){const s=J(r);f(s);return}e.on(N,s=>f(s))}const J=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function z(e){const{licenseKey:o,pluginName:n,baseApiUrl:i}=e;try{return(await _({baseApiUrl:i,path:`/sdk/${o||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const Q="canvasEmptyState",X=P.startup,Y=function(e,o={}){const n=new WeakMap,i=new WeakMap,a=new WeakMap,g=new Set,d=new WeakMap,r={emptyStates:[],...o},p=(t,l)=>{let b=!1;const{isValid:u}=l;return Array.isArray(u)?b=u.some(c=>t.is(c)):F(u)?b=u({component:t,editor:e}):b=t.is(u),b},y=t=>{const l=n.get(t);n.delete(t),l==null||l()},f=t=>{t.views.forEach(l=>y(l)),a.delete(t)},s=t=>{if(!(!t||g.has(t)))try{g.add(t);const l=t.components().length>0,b=a.get(t);if(l&&b)f(t);else if(!l&&!b){const u=d.has(t)?d.get(t):r.emptyStates.find(c=>p(t,c));if(d.set(t,u),!u)return;t.views.forEach(c=>{const D=u.render({editor:e,component:t,componentView:c,mount:v=>{i.set(c,v),a.set(t,!0);const G=c.getChildrenContainer();G==null||G.appendChild(v)},unmount:()=>y(c)});n.set(c,()=>{D==null||D();const v=i.get(c);v==null||v.remove()})})}}finally{g.delete(t)}},T=t=>{a.has(t)&&f(t)},R=({model:t})=>{s(t.getComponent())},h=e.Components.events,L=`${h.update}:components`,A="component:mount",w=e.Canvas.events.frameLoadBody,E=h.removed;e.on(L,s),e.on(A,s),e.on(E,T),e.on(w,R),H({editor:e,licenseKey:r.licenseKey,plan:X,pluginName:Q,cleanup:()=>{e.off(L,s),e.off(A,s),e.off(E,T),e.off(w,R)}})},Z=q(Y);module.exports=Z;
@@ -1,8 +1,8 @@
1
- const W = "app.grapesjs.com", D = "app-stage.grapesjs.com", P = "app2.grapesjs.com", $ = "app-stage2.grapesjs.com", U = [
2
- W,
3
- P,
4
- D,
5
- $,
1
+ const O = "app.grapesjs.com", x = "app-stage.grapesjs.com", k = "app2.grapesjs.com", B = "app-stage2.grapesjs.com", I = [
2
+ O,
3
+ k,
4
+ x,
5
+ B,
6
6
  "localhost",
7
7
  "127.0.0.1",
8
8
  ".local-credentialless.webcontainer.io",
@@ -11,162 +11,175 @@ const W = "app.grapesjs.com", D = "app-stage.grapesjs.com", P = "app2.grapesjs.c
11
11
  // For stackblitz.com demos
12
12
  "-sandpack.codesandbox.io"
13
13
  // For Sandpack demos
14
- ], _ = "license:check:start", L = "license:check:end", O = () => typeof window < "u", j = ({
15
- isDev: t,
16
- isStage: a,
17
- isPlatform: o
18
- }) => `${t ? "" : `https://${a ? D : W}`}/${o ? "platform-api" : "api"}`, K = () => {
19
- const t = O() && window.location.hostname;
20
- return !!t && (U.includes(t) || U.some((a) => t.endsWith(a)));
14
+ ], N = "license:check:end", W = () => typeof window < "u", $ = ({
15
+ isDev: e,
16
+ isStage: o,
17
+ isPlatform: n
18
+ }) => `${e ? "" : `https://${o ? x : O}`}/${n ? "platform-api" : "api"}`, j = () => {
19
+ const e = W() && window.location.hostname;
20
+ return !!e && (I.includes(e) || I.some((o) => e.endsWith(o)));
21
21
  };
22
- function G(t) {
23
- return typeof t == "function";
22
+ function F(e) {
23
+ return typeof e == "function";
24
24
  }
25
- async function k({
26
- path: t,
27
- baseApiUrl: a,
28
- method: o = "GET",
25
+ async function _({
26
+ path: e,
27
+ baseApiUrl: o,
28
+ method: n = "GET",
29
29
  headers: i = {},
30
- params: s,
31
- body: f
30
+ params: a,
31
+ body: g
32
32
  }) {
33
- const d = `${a || j({ isDev: !1, isStage: !1 })}${t}`, g = {
34
- method: o,
33
+ const r = `${o || $({ isDev: !1, isStage: !1 })}${e}`, p = {
34
+ method: n,
35
35
  headers: {
36
36
  "Content-Type": "application/json",
37
37
  ...i
38
38
  }
39
39
  };
40
- f && (g.body = JSON.stringify(f));
41
- const l = s ? new URLSearchParams(s).toString() : "", h = l ? `?${l}` : "", n = await fetch(`${d}${h}`, g);
42
- if (!n.ok)
43
- throw new Error(`HTTP error! status: ${n.status}`);
44
- return n.json();
40
+ g && (p.body = JSON.stringify(g));
41
+ const y = a ? new URLSearchParams(a).toString() : "", f = y ? `?${y}` : "", s = await fetch(`${r}${f}`, p);
42
+ if (!s.ok)
43
+ throw new Error(`HTTP error! status: ${s.status}`);
44
+ return s.json();
45
45
  }
46
- var w = /* @__PURE__ */ ((t) => (t.free = "free", t.startup = "startup", t.business = "business", t.enterprise = "enterprise", t))(w || {});
47
- const M = {
48
- [w.free]: 0,
49
- [w.startup]: 10,
50
- [w.business]: 20,
51
- [w.enterprise]: 30
46
+ var P = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(P || {}), M = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.toastRemove = "studio:toastRemove", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.dialogExportCode = "studio:dialogExportCode", e.dialogImportCode = "studio:dialogImportCode", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.clearPage = "studio:clearPage", e.projectFiles = "studio:projectFiles", e.validateCode = "studio:validateCode", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.layoutComponentAdd = "studio:layoutComponentAdd", e.layoutComponentGet = "studio:layoutComponentGet", e.layoutComponentRemove = "studio:layoutComponentRemove", e.layoutComponentRender = "studio:layoutComponentRender", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.settings = "studio:settings", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.fontManagerOpen = "studio:fontManagerOpen", e.menuFontLoad = "studio:menuFontLoad", e.toggleStateDataSource = "studio:toggleStateDataSource", e.getStateDataSource = "studio:getStateDataSource", e.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", e.dataSourceSetImporter = "studio:dataSourceSetImporter", e.dataSourceSetExporter = "studio:dataSourceSetExporter", e.setDragAbsolute = "studio:setDragAbsolute", e))(M || {});
47
+ const U = {
48
+ [P.free]: 0,
49
+ [P.startup]: 10,
50
+ [P.business]: 20,
51
+ [P.enterprise]: 30
52
52
  };
53
- function x(t) {
54
- const a = t;
55
- return a.init = (o) => (i) => t(i, o), a;
53
+ function K(e) {
54
+ const o = e;
55
+ return o.init = (n) => (i) => e(i, n), o;
56
56
  }
57
- const F = (t) => /* @__PURE__ */ x(t);
57
+ const q = (e) => /* @__PURE__ */ K(e);
58
58
  async function H({
59
- editor: t,
60
- plan: a,
61
- pluginName: o,
59
+ editor: e,
60
+ plan: o,
61
+ pluginName: n,
62
62
  licenseKey: i,
63
- onLicenseCheckResponse: s,
64
- cleanup: f
63
+ onLicenseCheckResponse: a,
64
+ cleanup: g
65
65
  }) {
66
- let p = "", d = !1;
67
- const g = K(), l = (n) => {
68
- console.warn("Cleanup plugin:", o, "Reason:", n), f();
69
- }, h = (n = {}) => {
70
- var T;
71
- const { error: E, sdkLicense: S } = n, y = (T = n.plan) == null ? void 0 : T.category;
72
- if (!(S || n.license) || E)
73
- l(E || "Invalid license");
74
- else if (y) {
75
- const b = M[a], A = M[y];
76
- b > A && l({ pluginRequiredPlan: a, licensePlan: y });
66
+ let d = "", r;
67
+ const p = (s) => {
68
+ console.warn("Cleanup plugin:", n, "Reason:", s), g();
69
+ }, y = (s = {}) => {
70
+ var A;
71
+ const { error: T, sdkLicense: R } = s, h = (A = s.plan) == null ? void 0 : A.category;
72
+ if (!(R || s.license) || T)
73
+ p(T || "Invalid license");
74
+ else if (h) {
75
+ const w = U[o], E = U[h];
76
+ w > E && p({ pluginRequiredPlan: o, licensePlan: h });
77
77
  }
78
78
  };
79
- t.on(_, (n) => {
80
- p = n == null ? void 0 : n.baseApiUrl, d = !0;
81
- }), t.on(L, (n) => {
82
- s == null || s(n), h(n);
83
- }), setTimeout(async () => {
84
- if (!d) {
85
- if (g) return;
86
- if (i) {
87
- const n = await q({ licenseKey: i, pluginName: o, baseApiUrl: p });
88
- s == null || s(n), n && h(n);
89
- } else
90
- l("The `licenseKey` option not provided");
91
- }
92
- }, 2e3);
79
+ e.Commands.has(M.settings) && (r = e.runCommand(M.settings), d = (r == null ? void 0 : r.baseUrl) || "");
80
+ const f = (s) => {
81
+ a == null || a(s), s && y(s);
82
+ };
83
+ if (!r) {
84
+ e.onReady(async () => {
85
+ if (!j())
86
+ if (i) {
87
+ const s = await z({ licenseKey: i, pluginName: n, baseApiUrl: d });
88
+ f(s);
89
+ } else
90
+ p("The `licenseKey` option not provided");
91
+ });
92
+ return;
93
+ }
94
+ if (r.licensePlan || r.licenseError) {
95
+ const s = J(r);
96
+ f(s);
97
+ return;
98
+ }
99
+ e.on(N, (s) => f(s));
93
100
  }
94
- async function q(t) {
95
- const { licenseKey: a, pluginName: o, baseApiUrl: i } = t;
101
+ const J = (e) => ({
102
+ sdkLicense: e.license,
103
+ license: e.license,
104
+ error: e.licenseError,
105
+ plan: e.licensePlan
106
+ });
107
+ async function z(e) {
108
+ const { licenseKey: o, pluginName: n, baseApiUrl: i } = e;
96
109
  try {
97
- return (await k({
110
+ return (await _({
98
111
  baseApiUrl: i,
99
- path: `/sdk/${a || "na"}`,
112
+ path: `/sdk/${o || "na"}`,
100
113
  method: "POST",
101
114
  params: {
102
115
  d: window.location.hostname,
103
- pn: o
116
+ pn: n
104
117
  }
105
118
  })).result || {};
106
- } catch (s) {
107
- return console.error("Error during SDK license check:", s), !1;
119
+ } catch (a) {
120
+ return console.error("Error during SDK license check:", a), !1;
108
121
  }
109
122
  }
110
- const B = "canvasEmptyState", J = w.startup, z = function(t, a = {}) {
111
- const o = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), s = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new WeakMap(), d = {
123
+ const Q = "canvasEmptyState", X = P.startup, Y = function(e, o = {}) {
124
+ const n = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new WeakMap(), r = {
112
125
  emptyStates: [],
113
- ...a
114
- }, g = (e, c) => {
115
- let m = !1;
116
- const { isValid: u } = c;
117
- return Array.isArray(u) ? m = u.some((r) => e.is(r)) : G(u) ? m = u({ component: e, editor: t }) : m = e.is(u), m;
118
- }, l = (e) => {
119
- const c = o.get(e);
120
- o.delete(e), c == null || c();
121
- }, h = (e) => {
122
- e.views.forEach((c) => l(c)), s.delete(e);
123
- }, n = (e) => {
124
- if (!(!e || f.has(e)))
126
+ ...o
127
+ }, p = (t, l) => {
128
+ let b = !1;
129
+ const { isValid: u } = l;
130
+ return Array.isArray(u) ? b = u.some((c) => t.is(c)) : F(u) ? b = u({ component: t, editor: e }) : b = t.is(u), b;
131
+ }, y = (t) => {
132
+ const l = n.get(t);
133
+ n.delete(t), l == null || l();
134
+ }, f = (t) => {
135
+ t.views.forEach((l) => y(l)), a.delete(t);
136
+ }, s = (t) => {
137
+ if (!(!t || g.has(t)))
125
138
  try {
126
- f.add(e);
127
- const c = e.components().length > 0, m = s.get(e);
128
- if (c && m)
129
- h(e);
130
- else if (!c && !m) {
131
- const u = p.has(e) ? p.get(e) : d.emptyStates.find((r) => g(e, r));
132
- if (p.set(e, u), !u) return;
133
- e.views.forEach((r) => {
134
- const I = u.render({
135
- editor: t,
136
- component: e,
137
- componentView: r,
139
+ g.add(t);
140
+ const l = t.components().length > 0, b = a.get(t);
141
+ if (l && b)
142
+ f(t);
143
+ else if (!l && !b) {
144
+ const u = d.has(t) ? d.get(t) : r.emptyStates.find((c) => p(t, c));
145
+ if (d.set(t, u), !u) return;
146
+ t.views.forEach((c) => {
147
+ const D = u.render({
148
+ editor: e,
149
+ component: t,
150
+ componentView: c,
138
151
  mount: (v) => {
139
- i.set(r, v), s.set(e, !0);
140
- const N = r.getChildrenContainer();
141
- N == null || N.appendChild(v);
152
+ i.set(c, v), a.set(t, !0);
153
+ const G = c.getChildrenContainer();
154
+ G == null || G.appendChild(v);
142
155
  },
143
- unmount: () => l(r)
156
+ unmount: () => y(c)
144
157
  });
145
- o.set(r, () => {
146
- I == null || I();
147
- const v = i.get(r);
158
+ n.set(c, () => {
159
+ D == null || D();
160
+ const v = i.get(c);
148
161
  v == null || v.remove();
149
162
  });
150
163
  });
151
164
  }
152
165
  } finally {
153
- f.delete(e);
166
+ g.delete(t);
154
167
  }
155
- }, E = (e) => {
156
- s.has(e) && h(e);
157
- }, S = ({ model: e }) => {
158
- n(e.getComponent());
159
- }, y = t.Components.events, C = `${y.update}:components`, T = "component:mount", b = t.Canvas.events.frameLoadBody, A = y.removed;
160
- t.on(C, n), t.on(T, n), t.on(A, E), t.on(b, S), H({
161
- editor: t,
162
- licenseKey: d.licenseKey,
163
- plan: J,
164
- pluginName: B,
168
+ }, T = (t) => {
169
+ a.has(t) && f(t);
170
+ }, R = ({ model: t }) => {
171
+ s(t.getComponent());
172
+ }, h = e.Components.events, L = `${h.update}:components`, A = "component:mount", w = e.Canvas.events.frameLoadBody, E = h.removed;
173
+ e.on(L, s), e.on(A, s), e.on(E, T), e.on(w, R), H({
174
+ editor: e,
175
+ licenseKey: r.licenseKey,
176
+ plan: X,
177
+ pluginName: Q,
165
178
  cleanup: () => {
166
- t.off(C, n), t.off(T, n), t.off(A, E), t.off(b, S);
179
+ e.off(L, s), e.off(A, s), e.off(E, T), e.off(w, R);
167
180
  }
168
181
  });
169
- }, Q = F(z);
182
+ }, Z = q(Y);
170
183
  export {
171
- Q as default
184
+ Z as default
172
185
  };
@@ -1 +1 @@
1
- (function(y,g){typeof exports=="object"&&typeof module<"u"?module.exports=g():typeof define=="function"&&define.amd?define(g):(y=typeof globalThis<"u"?globalThis:y||self,y.StudioSdkPlugins_canvasEmptyState=g())})(this,function(){"use strict";const y="app.grapesjs.com",g="app-stage.grapesjs.com",P=[y,"app2.grapesjs.com",g,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],_="license:check:start",W="license:check:end",O=()=>typeof window<"u",$=({isDev:t,isStage:a,isPlatform:o})=>`${t?"":`https://${a?g:y}`}/${o?"platform-api":"api"}`,L=()=>{const t=O()&&window.location.hostname;return!!t&&(P.includes(t)||P.some(a=>t.endsWith(a)))};function j(t){return typeof t=="function"}async function G({path:t,baseApiUrl:a,method:o="GET",headers:i={},params:s,body:f}){const p=`${a||$({isDev:!1,isStage:!1})}${t}`,w={method:o,headers:{"Content-Type":"application/json",...i}};f&&(w.body=JSON.stringify(f));const l=s?new URLSearchParams(s).toString():"",h=l?`?${l}`:"",n=await fetch(`${p}${h}`,w);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return n.json()}var v=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(v||{});const U={[v.free]:0,[v.startup]:10,[v.business]:20,[v.enterprise]:30};function K(t){const a=t;return a.init=o=>i=>t(i,o),a}const k=t=>K(t);async function x({editor:t,plan:a,pluginName:o,licenseKey:i,onLicenseCheckResponse:s,cleanup:f}){let d="",p=!1;const w=L(),l=n=>{console.warn("Cleanup plugin:",o,"Reason:",n),f()},h=(n={})=>{var A;const{error:T,sdkLicense:b}=n,E=(A=n.plan)==null?void 0:A.category;if(!(b||n.license)||T)l(T||"Invalid license");else if(E){const I=U[a],N=U[E];I>N&&l({pluginRequiredPlan:a,licensePlan:E})}};t.on(_,n=>{d=n==null?void 0:n.baseApiUrl,p=!0}),t.on(W,n=>{s==null||s(n),h(n)}),setTimeout(async()=>{if(!p){if(w)return;if(i){const n=await F({licenseKey:i,pluginName:o,baseApiUrl:d});s==null||s(n),n&&h(n)}else l("The `licenseKey` option not provided")}},2e3)}async function F(t){const{licenseKey:a,pluginName:o,baseApiUrl:i}=t;try{return(await G({baseApiUrl:i,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}const H="canvasEmptyState",q=v.startup;return k(function(t,a={}){const o=new WeakMap,i=new WeakMap,s=new WeakMap,f=new Set,d=new WeakMap,p={emptyStates:[],...a},w=(e,c)=>{let m=!1;const{isValid:u}=c;return Array.isArray(u)?m=u.some(r=>e.is(r)):j(u)?m=u({component:e,editor:t}):m=e.is(u),m},l=e=>{const c=o.get(e);o.delete(e),c==null||c()},h=e=>{e.views.forEach(c=>l(c)),s.delete(e)},n=e=>{if(!(!e||f.has(e)))try{f.add(e);const c=e.components().length>0,m=s.get(e);if(c&&m)h(e);else if(!c&&!m){const u=d.has(e)?d.get(e):p.emptyStates.find(r=>w(e,r));if(d.set(e,u),!u)return;e.views.forEach(r=>{const M=u.render({editor:t,component:e,componentView:r,mount:S=>{i.set(r,S),s.set(e,!0);const C=r.getChildrenContainer();C==null||C.appendChild(S)},unmount:()=>l(r)});o.set(r,()=>{M==null||M();const S=i.get(r);S==null||S.remove()})})}}finally{f.delete(e)}},T=e=>{s.has(e)&&h(e)},b=({model:e})=>{n(e.getComponent())},E=t.Components.events,D=`${E.update}:components`,A="component:mount",I=t.Canvas.events.frameLoadBody,N=E.removed;t.on(D,n),t.on(A,n),t.on(N,T),t.on(I,b),x({editor:t,licenseKey:p.licenseKey,plan:q,pluginName:H,cleanup:()=>{t.off(D,n),t.off(A,n),t.off(N,T),t.off(I,b)}})})});
1
+ (function(h,v){typeof exports=="object"&&typeof module<"u"?module.exports=v():typeof define=="function"&&define.amd?define(v):(h=typeof globalThis<"u"?globalThis:h||self,h.StudioSdkPlugins_canvasEmptyState=v())})(this,function(){"use strict";const h="app.grapesjs.com",v="app-stage.grapesjs.com",x=[h,"app2.grapesjs.com",v,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],N="license:check:end",k=()=>typeof window<"u",B=({isDev:e,isStage:o,isPlatform:a})=>`${e?"":`https://${o?v:h}`}/${a?"platform-api":"api"}`,W=()=>{const e=k()&&window.location.hostname;return!!e&&(x.includes(e)||x.some(o=>e.endsWith(o)))};function _(e){return typeof e=="function"}async function $({path:e,baseApiUrl:o,method:a="GET",headers:r={},params:n,body:g}){const i=`${o||B({isDev:!1,isStage:!1})}${e}`,p={method:a,headers:{"Content-Type":"application/json",...r}};g&&(p.body=JSON.stringify(g));const y=n?new URLSearchParams(n).toString():"",f=y?`?${y}`:"",s=await fetch(`${i}${f}`,p);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return s.json()}var P=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(P||{}),L=(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))(L||{});const U={[P.free]:0,[P.startup]:10,[P.business]:20,[P.enterprise]:30};function j(e){const o=e;return o.init=a=>r=>e(r,a),o}const F=e=>j(e);async function K({editor:e,plan:o,pluginName:a,licenseKey:r,onLicenseCheckResponse:n,cleanup:g}){let d="",i;const p=s=>{console.warn("Cleanup plugin:",a,"Reason:",s),g()},y=(s={})=>{var D;const{error:R,sdkLicense:E}=s,T=(D=s.plan)==null?void 0:D.category;if(!(E||s.license)||R)p(R||"Invalid license");else if(T){const w=U[o],G=U[T];w>G&&p({pluginRequiredPlan:o,licensePlan:T})}};e.Commands.has(L.settings)&&(i=e.runCommand(L.settings),d=(i==null?void 0:i.baseUrl)||"");const f=s=>{n==null||n(s),s&&y(s)};if(!i){e.onReady(async()=>{if(!W())if(r){const s=await H({licenseKey:r,pluginName:a,baseApiUrl:d});f(s)}else p("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const s=q(i);f(s);return}e.on(N,s=>f(s))}const q=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function H(e){const{licenseKey:o,pluginName:a,baseApiUrl:r}=e;try{return(await $({baseApiUrl:r,path:`/sdk/${o||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const J="canvasEmptyState",z=P.startup;return F(function(e,o={}){const a=new WeakMap,r=new WeakMap,n=new WeakMap,g=new Set,d=new WeakMap,i={emptyStates:[],...o},p=(t,l)=>{let b=!1;const{isValid:u}=l;return Array.isArray(u)?b=u.some(c=>t.is(c)):_(u)?b=u({component:t,editor:e}):b=t.is(u),b},y=t=>{const l=a.get(t);a.delete(t),l==null||l()},f=t=>{t.views.forEach(l=>y(l)),n.delete(t)},s=t=>{if(!(!t||g.has(t)))try{g.add(t);const l=t.components().length>0,b=n.get(t);if(l&&b)f(t);else if(!l&&!b){const u=d.has(t)?d.get(t):i.emptyStates.find(c=>p(t,c));if(d.set(t,u),!u)return;t.views.forEach(c=>{const I=u.render({editor:e,component:t,componentView:c,mount:A=>{r.set(c,A),n.set(t,!0);const O=c.getChildrenContainer();O==null||O.appendChild(A)},unmount:()=>y(c)});a.set(c,()=>{I==null||I();const A=r.get(c);A==null||A.remove()})})}}finally{g.delete(t)}},R=t=>{n.has(t)&&f(t)},E=({model:t})=>{s(t.getComponent())},T=e.Components.events,M=`${T.update}:components`,D="component:mount",w=e.Canvas.events.frameLoadBody,G=T.removed;e.on(M,s),e.on(D,s),e.on(G,R),e.on(w,E),K({editor:e,licenseKey:i.licenseKey,plan:z,pluginName:J,cleanup:()=>{e.off(M,s),e.off(D,s),e.off(G,R),e.off(w,E)}})})});
@@ -1,10 +1,10 @@
1
- "use strict";function Y(t,i,e){let a,s,r,m,c;const d=i;function l(){const o=Date.now()-m;o<d&&o>=0?a=setTimeout(l,d-o):(a=null,c=t.apply(r,s),r=s=null)}const h=function(){return r=this,s=arguments,m=Date.now(),a||(a=setTimeout(l,d)),c};return h.clear=function(){a&&(clearTimeout(a),a=null)},h.flush=function(){a&&(c=t.apply(r,s),r=s=null,clearTimeout(a),a=null)},h}const L="app.grapesjs.com",F="app-stage.grapesjs.com",k="app2.grapesjs.com",J="app-stage2.grapesjs.com",O=[L,k,F,J,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Q="license:check:start",tt="license:check:end",et=()=>typeof window<"u",nt=({isDev:t,isStage:i,isPlatform:e})=>`${t?"":`https://${i?F:L}`}/${e?"platform-api":"api"}`,st=()=>{const t=et()&&window.location.hostname;return!!t&&(O.includes(t)||O.some(i=>t.endsWith(i)))};async function ot({path:t,baseApiUrl:i,method:e="GET",headers:a={},params:s,body:r}){const c=`${i||nt({isDev:!1,isStage:!1})}${t}`,d={method:e,headers:{"Content-Type":"application/json",...a}};r&&(d.body=JSON.stringify(r));const l=s?new URLSearchParams(s).toString():"",h=l?`?${l}`:"",o=await fetch(`${c}${h}`,d);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}var v=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(v||{});const U={[v.free]:0,[v.startup]:10,[v.business]:20,[v.enterprise]:30};function at(t){const i=t;return i.init=e=>a=>t(a,e),i}const it=t=>at(t);async function rt({editor:t,plan:i,pluginName:e,licenseKey:a,onLicenseCheckResponse:s,cleanup:r}){let m="",c=!1;const d=st(),l=o=>{console.warn("Cleanup plugin:",e,"Reason:",o),r()},h=(o={})=>{var b;const{error:g,sdkLicense:E}=o,w=(b=o.plan)==null?void 0:b.category;if(!(E||o.license)||g)l(g||"Invalid license");else if(w){const T=U[i],x=U[w];T>x&&l({pluginRequiredPlan:i,licensePlan:w})}};t.on(Q,o=>{m=o==null?void 0:o.baseApiUrl,c=!0}),t.on(tt,o=>{s==null||s(o),h(o)}),setTimeout(async()=>{if(!c){if(d)return;if(a){const o=await ct({licenseKey:a,pluginName:e,baseApiUrl:m});s==null||s(o),o&&h(o)}else l("The `licenseKey` option not provided")}},2e3)}async function ct(t){const{licenseKey:i,pluginName:e,baseApiUrl:a}=t;try{return(await ot({baseApiUrl:a,path:`/sdk/${i||"na"}`,method:"POST",params:{d:window.location.hostname,pn:e}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}const W="data-gs-plg-",z="canvasFullSize",lt=v.startup,ut=(t,i)=>{const{rule:e,ruleView:a}=i,{style:s}=e.attributes;if(s&&s[t]){const r=s[t],m=/([0-9.]+)(vh|dvh|lvh|svh)/g,c=m.test(r),d=a.frameView.model;if(c&&d.hasAutoHeight()){const l=r.replace(m,(o,g)=>`${window.innerHeight*(parseFloat(g)/100)}px`),h=e.toCSS({style:{...s,[t]:l}});i.css=h}}},pt=t=>{["height","min-height","max-height"].forEach(i=>ut(i,t))},mt=function(t,i={}){const{Canvas:e,Commands:a,Devices:s,Css:r}=t,m={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...i},{canvasOffsetY:c,canvasOffsetX:d,canvasTransition:l,deviceMaxWidth:h,deviceMinHeigth:o,deviceFixedHeight:g,frameBorderRadius:E,frameTransition:w}=m,y=`${o}px`,b=e.events,T="core:preview",x=`${a.events.stopCommand}${T}`,H=e.getConfig(),_=`${z}:disable`,K=s.getAll().map(n=>({...n.attributes})),G=l*1e3,M={x:d,y:c};let S={},P,$;H.scrollableCanvas=!g,s.getAll().map(n=>{!n.get("width")&&n.set("width",`${h}px`),!n.get("height")&&n.set("height",g?"100vh":"auto"),!n.get("minHeight")&&n.set("minHeight",y)});const V=n=>{const u=`${W}canvas-full-size`,p=document.querySelector(`style[${u}]`);if(n&&p)return p.remove();const f=p||document.createElement("style"),D=e.getZoomMultiplier();f.setAttribute(u,"true"),f.innerHTML=`
2
- .gjs-frame-wrapper { transition: width ${w}s !important; }
3
- .gjs-frame-wrapper__bottom { height: ${c*D}px }
4
- .gjs-frame { border-radius: ${E}px }
5
- `,!p&&document.body.appendChild(f)};t.on(b.frameLoadHead,n=>{if(!H.scrollableCanvas)return;const{window:u}=n,p=u.document,f=p.head,D=`${W}canvas-full-size-wrappers`,C=f.querySelector(`style[${D}]`)||p.createElement("style");C.setAttribute(D,"true"),C.innerHTML=`
1
+ "use strict";function J(e,i,t){let o,n,l,d,r;const c=i;function f(){const a=Date.now()-d;a<c&&a>=0?o=setTimeout(f,c-a):(o=null,r=e.apply(l,n),l=n=null)}const p=function(){return l=this,n=arguments,d=Date.now(),o||(o=setTimeout(f,c)),r};return p.clear=function(){o&&(clearTimeout(o),o=null)},p.flush=function(){o&&(r=e.apply(l,n),l=n=null,clearTimeout(o),o=null)},p}const k="app.grapesjs.com",z="app-stage.grapesjs.com",Q="app2.grapesjs.com",C="app-stage2.grapesjs.com",B=[k,Q,z,C,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ee="license:check:end",te=()=>typeof window<"u",se=({isDev:e,isStage:i,isPlatform:t})=>`${e?"":`https://${i?z:k}`}/${t?"platform-api":"api"}`,oe=()=>{const e=te()&&window.location.hostname;return!!e&&(B.includes(e)||B.some(i=>e.endsWith(i)))};async function ne({path:e,baseApiUrl:i,method:t="GET",headers:o={},params:n,body:l}){const r=`${i||se({isDev:!1,isStage:!1})}${e}`,c={method:t,headers:{"Content-Type":"application/json",...o}};l&&(c.body=JSON.stringify(l));const f=n?new URLSearchParams(n).toString():"",p=f?`?${f}`:"",a=await fetch(`${r}${p}`,c);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return a.json()}var y=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(y||{}),H=(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))(H||{});const F={[y.free]:0,[y.startup]:10,[y.business]:20,[y.enterprise]:30};function ae(e){const i=e;return i.init=t=>o=>e(o,t),i}const ie=e=>ae(e);async function re({editor:e,plan:i,pluginName:t,licenseKey:o,onLicenseCheckResponse:n,cleanup:l}){let d="",r;const c=a=>{console.warn("Cleanup plugin:",t,"Reason:",a),l()},f=(a={})=>{var T;const{error:v,sdkLicense:R}=a,b=(T=a.plan)==null?void 0:T.category;if(!(R||a.license)||v)c(v||"Invalid license");else if(b){const D=F[i],M=F[b];D>M&&c({pluginRequiredPlan:i,licensePlan:b})}};e.Commands.has(H.settings)&&(r=e.runCommand(H.settings),d=(r==null?void 0:r.baseUrl)||"");const p=a=>{n==null||n(a),a&&f(a)};if(!r){e.onReady(async()=>{if(!oe())if(o){const a=await ce({licenseKey:o,pluginName:t,baseApiUrl:d});p(a)}else c("The `licenseKey` option not provided")});return}if(r.licensePlan||r.licenseError){const a=le(r);p(a);return}e.on(ee,a=>p(a))}const le=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function ce(e){const{licenseKey:i,pluginName:t,baseApiUrl:o}=e;try{return(await ne({baseApiUrl:o,path:`/sdk/${i||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const N="data-gs-plg-",_="canvasFullSize",ue=y.startup,ge=(e,i)=>{const{rule:t,ruleView:o}=i,{style:n}=t.attributes;if(n&&n[e]){const l=n[e],d=/([0-9.]+)(vh|dvh|lvh|svh)/g,r=d.test(l),c=o.frameView.model;if(r&&c.hasAutoHeight()){const f=l.replace(d,(a,v)=>`${window.innerHeight*(parseFloat(v)/100)}px`),p=t.toCSS({style:{...n,[e]:f}});i.css=p}}},pe=e=>{["height","min-height","max-height"].forEach(i=>ge(i,e))},de=function(e,i={}){const{Canvas:t,Commands:o,Devices:n,Css:l}=e,d={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...i},{canvasOffsetY:r,canvasOffsetX:c,canvasTransition:f,deviceMaxWidth:p,deviceMinHeigth:a,deviceFixedHeight:v,frameBorderRadius:R,frameTransition:b}=d,w=`${a}px`,T=t.events,D="core:preview",M=`${o.events.stopCommand}${D}`,L=t.getConfig(),I=`${_}:disable`,W=n.getAll().map(s=>({...s.attributes})),K=f*1e3,m={x:c,y:r};let P={},G,A;L.scrollableCanvas=!v,n.getAll().map(s=>{!s.get("width")&&s.set("width",`${p}px`),!s.get("height")&&s.set("height",v?"100vh":"auto"),!s.get("minHeight")&&s.set("minHeight",w)});const O=s=>{const u=`${N}canvas-full-size`,g=document.querySelector(`style[${u}]`);if(s&&g)return g.remove();const h=g||document.createElement("style"),x=t.getZoomMultiplier();h.setAttribute(u,"true"),h.innerHTML=`
2
+ .gjs-frame-wrapper { transition: width ${b}s !important; }
3
+ .gjs-frame-wrapper__bottom { height: ${r*x}px }
4
+ .gjs-frame { border-radius: ${R}px }
5
+ `,!g&&document.body.appendChild(h)};e.on(T.frameLoadHead,s=>{if(!L.scrollableCanvas)return;const{window:u}=s,g=u.document,h=g.head,x=`${N}canvas-full-size-wrappers`,$=h.querySelector(`style[${x}]`)||g.createElement("style");$.setAttribute(x,"true"),$.innerHTML=`
6
6
  body { height: auto !important; }
7
- [data-gjs-type="wrapper"] { min-height: ${y} !important; }
8
- [data-gjs-type="mjml"] { min-height: ${y} !important; }
9
- [data-gjs-type="mj-body"] { min-height: ${y} !important; }
10
- `,!f.contains(C)&&f.appendChild(C)});const j=()=>P.style.display="none",R=()=>P.style.display="",Z=()=>{var f;if(!g)return;const n=e.getZoomMultiplier(),p=e.getRect().height*n-c*2;(f=s.getSelected())==null||f.set("height",`${Math.max(p,o)}px`),e.fitViewport({zoom:e.getZoom(),gap:M})},A=Y(()=>{e.fitViewport({zoom:n=>n>100?100:n,ignoreHeight:!0,gap:M}),Z(),V(),setTimeout(()=>{var u,p;const{em:n}=t;n.destroyed||((p=(u=t.getSelected())==null?void 0:u.getEl())==null||p.scrollIntoView({block:"nearest"}),t.refresh({tools:!0}),R(),a.isActive(T)?n.stopDefault():n.runDefault())},G)},100),q=(n={})=>{n.options&&n.options.from!=="fitViewport"&&e.fitViewport({zoom:e.getZoom(),ignoreHeight:!0,gap:M})},B=()=>{j(),A()},X=()=>{S.overflowX="hidden",S.overflowY="auto"},I=()=>{$==null||$.disconnect(),A.clear()},N=[[s.events.select,B],[b.zoom,q],[x,X],[t.events.destroy,I],[r.events.mountBefore,pt]];a.add(_,()=>{s.devices.reset(K),H.scrollableCanvas=!1,e.getModel().updateDevice(),e.setZoom(100),e.setCoords(0,0),S.overflowY="hidden",V(!0),N.forEach(([n,u])=>t.off(n,u)),I(),a.run("studio:canvasReload")}),N.forEach(([n,u])=>t.on(n,u)),t.onReady(()=>{const n=e.getElement(),u=e.getFramesEl(),p=e.getCanvasView();P=e.getSpotsEl(),S=n.style,S.overflowX="hidden",u.style.transition=`transform ${l}s`,document.removeEventListener("keypress",p.onKeyPress),V(),$=new ResizeObserver(()=>{j(),A()}),$.observe(n.parentElement),A()}),rt({editor:t,licenseKey:m.licenseKey,plan:lt,pluginName:z,cleanup:()=>{t.runCommand(_)}})},dt=it(mt);module.exports=dt;
7
+ [data-gjs-type="wrapper"] { min-height: ${w} !important; }
8
+ [data-gjs-type="mjml"] { min-height: ${w} !important; }
9
+ [data-gjs-type="mj-body"] { min-height: ${w} !important; }
10
+ `,!h.contains($)&&h.appendChild($)});const j=()=>G.style.display="none",Z=()=>G.style.display="",q=()=>{var h;if(!v)return;const s=t.getZoomMultiplier(),g=t.getRect().height*s-r*2;(h=n.getSelected())==null||h.set("height",`${Math.max(g,a)}px`),t.fitViewport({zoom:t.getZoom(),gap:m})},E=J(()=>{t.fitViewport({zoom:s=>s>100?100:s,ignoreHeight:!0,gap:m}),q(),O(),setTimeout(()=>{var u,g;const{em:s}=e;s.destroyed||((g=(u=e.getSelected())==null?void 0:u.getEl())==null||g.scrollIntoView({block:"nearest"}),e.refresh({tools:!0}),Z(),o.isActive(D)?s.stopDefault():s.runDefault())},K)},100),X=(s={})=>{s.options&&s.options.from!=="fitViewport"&&t.fitViewport({zoom:t.getZoom(),ignoreHeight:!0,gap:m})},Y=()=>{j(),E()},S=()=>{P.overflowX="hidden",P.overflowY="auto"},U=()=>{A==null||A.disconnect(),E.clear()},V=[[n.events.select,Y],[T.zoom,X],[M,S],[e.events.destroy,U],[l.events.mountBefore,pe]];o.add(I,()=>{n.devices.reset(W),L.scrollableCanvas=!1,t.getModel().updateDevice(),t.setZoom(100),t.setCoords(0,0),P.overflowY="hidden",O(!0),V.forEach(([s,u])=>e.off(s,u)),U(),o.run("studio:canvasReload")}),V.forEach(([s,u])=>e.on(s,u)),e.onReady(()=>{const s=t.getElement(),u=t.getFramesEl(),g=t.getCanvasView();G=t.getSpotsEl(),P=s.style,P.overflowX="hidden",u.style.transition=`transform ${f}s`,document.removeEventListener("keypress",g.onKeyPress),O(),A=new ResizeObserver(()=>{j(),E()}),A.observe(s.parentElement),E()}),re({editor:e,licenseKey:d.licenseKey,plan:ue,pluginName:_,cleanup:()=>{e.runCommand(I)}})},fe=ie(de);module.exports=fe;