@chili-publish/studio-sdk 1.32.0 → 1.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/_bundles/main.es.js +615 -577
  2. package/_bundles/main.es.js.map +1 -1
  3. package/_bundles/main.js +2 -2
  4. package/_bundles/main.js.map +1 -1
  5. package/lib/editor-engine.json +1 -1
  6. package/lib/package.json +1 -1
  7. package/lib/src/controllers/FrameController.d.ts +61 -5
  8. package/lib/src/controllers/FrameController.js +99 -1
  9. package/lib/src/controllers/FrameController.js.map +1 -1
  10. package/lib/src/controllers/LayoutController.d.ts +10 -2
  11. package/lib/src/controllers/LayoutController.js +18 -2
  12. package/lib/src/controllers/LayoutController.js.map +1 -1
  13. package/lib/src/index.d.ts +3 -2
  14. package/lib/src/index.js +1 -0
  15. package/lib/src/index.js.map +1 -1
  16. package/lib/src/tests/controllers/FrameConstraintController.test.js +167 -0
  17. package/lib/src/tests/controllers/FrameConstraintController.test.js.map +1 -0
  18. package/lib/src/tests/controllers/FrameController.test.js +7 -0
  19. package/lib/src/tests/controllers/FrameController.test.js.map +1 -1
  20. package/lib/src/tests/controllers/LayoutController.test.js +14 -4
  21. package/lib/src/tests/controllers/LayoutController.test.js.map +1 -1
  22. package/lib/src/types/ConfigurationTypes.d.ts +17 -0
  23. package/lib/src/types/ConfigurationTypes.js +14 -0
  24. package/lib/src/types/ConfigurationTypes.js.map +1 -1
  25. package/lib/src/types/FrameTypes.d.ts +37 -0
  26. package/lib/src/types/FrameTypes.js.map +1 -1
  27. package/lib/src/types/LayoutTypes.d.ts +8 -0
  28. package/lib/src/types/ParagraphStyleTypes.d.ts +43 -0
  29. package/lib/src/types/ParagraphStyleTypes.js +16 -1
  30. package/lib/src/types/ParagraphStyleTypes.js.map +1 -1
  31. package/lib/src/utils/Enums.d.ts +5 -1
  32. package/lib/src/utils/Enums.js +4 -0
  33. package/lib/src/utils/Enums.js.map +1 -1
  34. package/package.json +1 -1
package/_bundles/main.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(h,D){typeof exports=="object"&&typeof module<"u"?D(exports):typeof define=="function"&&define.amd?define(["exports"],D):(h=typeof globalThis<"u"?globalThis:h||self,D(h.StudioSDK=h.StudioSDK||{}))})(this,function(h){"use strict";var Rr=h=>{throw TypeError(h)};var Vr=(h,D,R)=>D.has(h)||Rr("Cannot "+R);var a=(h,D,R)=>(Vr(h,D,"read from private field"),R?R.call(h):D.get(h)),g=(h,D,R)=>D.has(h)?Rr("Cannot add the same private member more than once"):D instanceof WeakSet?D.add(h):D.set(h,R),y=(h,D,R,ie)=>(Vr(h,D,"write to private field"),ie?ie.call(h,R):D.set(h,R),R);var V,M,z,N,at,B,it,_t,G,J,Et,Ct,pr,mt,wt,ot,xt,ct,Ht,ht,ft,k,lt,Dt,E,Lt,d,f,Kt,Q,$t,L,zt,Cr,U,St,Ot,X,W,Wt,dt,jt,Mt,qt,Yt,w,Nt,Rt,mr,ut,tt,bt,Vt,ae,gt,Tt,_;const R={current:"2.15.latest"},fe={version:"1.32.0"};var j;(function(s){s.Call="call",s.Reply="reply",s.Syn="syn",s.SynAck="synAck",s.Ack="ack"})(j||(j={}));var yt;(function(s){s.Fulfilled="fulfilled",s.Rejected="rejected"})(yt||(yt={}));var Jt;(function(s){s.ConnectionDestroyed="ConnectionDestroyed",s.ConnectionTimeout="ConnectionTimeout",s.NoIframeSrc="NoIframeSrc"})(Jt||(Jt={}));var oe;(function(s){s.DataCloneError="DataCloneError"})(oe||(oe={}));var rt;(function(s){s.Message="message"})(rt||(rt={}));const Tr=(s,o)=>{const t=[];let e=!1;return{destroy(r){e||(e=!0,o(`${s}: Destroying connection`),t.forEach(n=>{n(r)}))},onDestroy(r){e?r():t.push(r)}}},Br=s=>(...o)=>{s&&console.log("[Penpal]",...o)},Gr={"http:":"80","https:":"443"},Jr=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,kr=["file:","data:"],Ur=s=>{if(s&&kr.find(u=>s.startsWith(u)))return"null";const o=document.location,t=Jr.exec(s);let e,r,n;t?(e=t[1]?t[1]:o.protocol,r=t[2],n=t[4]):(e=o.protocol,r=o.hostname,n=o.port);const c=n&&n!==Gr[e]?`:${n}`:"";return`${e}//${r}${c}`},Se=({name:s,message:o,stack:t})=>({name:s,message:o,stack:t}),_r=s=>{const o=new Error;return Object.keys(s).forEach(t=>o[t]=s[t]),o},xr=(s,o,t)=>{const{localName:e,local:r,remote:n,originForSending:c,originForReceiving:u}=s;let l=!1;const C=p=>{if(p.source!==n||p.data.penpal!==j.Call)return;if(p.origin!==u){t(`${e} received message from origin ${p.origin} which did not match expected origin ${u}`);return}const v=p.data,{methodName:b,args:I,id:P}=v;t(`${e}: Received ${b}() call`);const A=S=>x=>{if(t(`${e}: Sending ${b}() reply`),l){t(`${e}: Unable to send ${b}() reply due to destroyed connection`);return}const O={penpal:j.Reply,id:P,resolution:S,returnValue:x};S===yt.Rejected&&x instanceof Error&&(O.returnValue=Se(x),O.returnValueIsError=!0);try{n.postMessage(O,c)}catch(F){if(F.name===oe.DataCloneError){const et={penpal:j.Reply,id:P,resolution:yt.Rejected,returnValue:Se(F),returnValueIsError:!0};n.postMessage(et,c)}throw F}};new Promise(S=>S(o[b].apply(o,I))).then(A(yt.Fulfilled),A(yt.Rejected))};return r.addEventListener(rt.Message,C),()=>{l=!0,r.removeEventListener(rt.Message,C)}};let Hr=0;const Kr=()=>++Hr,be=".",Ie=s=>s?s.split(be):[],$r=s=>s.join(be),zr=(s,o)=>{const t=Ie(o||"");return t.push(s),$r(t)},Wr=(s,o,t)=>{const e=Ie(o);return e.reduce((r,n,c)=>(typeof r[n]>"u"&&(r[n]={}),c===e.length-1&&(r[n]=t),r[n]),s),s},ve=(s,o)=>{const t={};return Object.keys(s).forEach(e=>{const r=s[e],n=zr(e,o);typeof r=="object"&&Object.assign(t,ve(r,n)),typeof r=="function"&&(t[n]=r)}),t},jr=s=>{const o={};for(const t in s)Wr(o,t,s[t]);return o},qr=(s,o,t,e,r)=>{const{localName:n,local:c,remote:u,originForSending:l,originForReceiving:C}=o;let p=!1;r(`${n}: Connecting call sender`);const v=I=>(...P)=>{r(`${n}: Sending ${I}() call`);let A;try{u.closed&&(A=!0)}catch{A=!0}if(A&&e(),p){const S=new Error(`Unable to send ${I}() call due to destroyed connection`);throw S.code=Jt.ConnectionDestroyed,S}return new Promise((S,x)=>{const O=Kr(),F=st=>{if(st.source!==u||st.data.penpal!==j.Reply||st.data.id!==O)return;if(st.origin!==C){r(`${n} received message from origin ${st.origin} which did not match expected origin ${C}`);return}const Bt=st.data;r(`${n}: Received ${I}() reply`),c.removeEventListener(rt.Message,F);let Gt=Bt.returnValue;Bt.returnValueIsError&&(Gt=_r(Gt)),(Bt.resolution===yt.Fulfilled?S:x)(Gt)};c.addEventListener(rt.Message,F);const et={penpal:j.Call,id:O,methodName:I,args:P};u.postMessage(et,l)})},b=t.reduce((I,P)=>(I[P]=v(P),I),{});return Object.assign(s,jr(b)),()=>{p=!0}},Yr=(s,o,t,e,r)=>{const{destroy:n,onDestroy:c}=e;let u,l;const C={};return p=>{if(p.origin!==o){r(`Parent: Handshake - Received ACK message from origin ${p.origin} which did not match expected origin ${o}`);return}r("Parent: Handshake - Received ACK");const v={localName:"Parent",local:window,remote:p.source,originForSending:t,originForReceiving:o};u&&u(),u=xr(v,s,r),c(u),l&&l.forEach(I=>{delete C[I]}),l=p.data.methodNames;const b=qr(C,v,l,n,r);return c(b),C}},Zr=(s,o,t,e)=>r=>{if(r.origin!==t){s(`Parent: Handshake - Received SYN message from origin ${r.origin} which did not match expected origin ${t}`);return}s("Parent: Handshake - Received SYN, responding with SYN-ACK");const n={penpal:j.SynAck,methodNames:Object.keys(o)};r.source.postMessage(n,e)},Qr=6e4,Xr=(s,o)=>{const{destroy:t,onDestroy:e}=o,r=setInterval(()=>{s.isConnected||(clearInterval(r),t())},Qr);e(()=>{clearInterval(r)})},tn=(s,o)=>{let t;return s!==void 0&&(t=window.setTimeout(()=>{const e=new Error(`Connection timed out after ${s}ms`);e.code=Jt.ConnectionTimeout,o(e)},s)),()=>{clearTimeout(t)}},en=s=>{if(!s.src&&!s.srcdoc){const o=new Error("Iframe must have src or srcdoc property defined.");throw o.code=Jt.NoIframeSrc,o}},sn=s=>{let{iframe:o,methods:t={},childOrigin:e,timeout:r,debug:n=!1}=s;const c=Br(n),u=Tr("Parent",c),{onDestroy:l,destroy:C}=u;e||(en(o),e=Ur(o.src));const p=e==="null"?"*":e,v=ve(t),b=Zr(c,v,e,p),I=Yr(v,e,p,u,c);return{promise:new Promise((A,S)=>{const x=tn(r,C),O=F=>{if(!(F.source!==o.contentWindow||!F.data)){if(F.data.penpal===j.Syn){b(F);return}if(F.data.penpal===j.Ack){const et=I(F);et&&(x(),A(et));return}}};window.addEventListener(rt.Message,O),c("Parent: Awaiting handshake"),Xr(o,u),l(F=>{window.removeEventListener(rt.Message,O),F&&S(F)})}),destroy(){C()}}},rn=s=>{const o=new RegExp(/^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w.-]+)+[\w]+\/$/);let t="";return o.test(s)?t=s:s.indexOf("/index.html")>-1?t=s.replace("/index.html","/"):s.charAt(-1)!=="/"&&(t=`${s}/`),t},nn=(s,o,t)=>{const e=rn(o),n=`<html>
1
+ (function(h,D){typeof exports=="object"&&typeof module<"u"?D(exports):typeof define=="function"&&define.amd?define(["exports"],D):(h=typeof globalThis<"u"?globalThis:h||self,D(h.StudioSDK=h.StudioSDK||{}))})(this,function(h){"use strict";var Br=h=>{throw TypeError(h)};var Gr=(h,D,R)=>D.has(h)||Br("Cannot "+R);var a=(h,D,R)=>(Gr(h,D,"read from private field"),R?R.call(h):D.get(h)),g=(h,D,R)=>D.has(h)?Br("Cannot add the same private member more than once"):D instanceof WeakSet?D.add(h):D.set(h,R),y=(h,D,R,oe)=>(Gr(h,D,"write to private field"),oe?oe.call(h,R):D.set(h,R),R);var V,M,z,N,it,B,ot,xt,G,J,Dt,mt,wr,wt,ft,ct,Ht,ht,Kt,lt,St,U,dt,Ot,E,Lt,d,Q,f,$t,X,zt,O,Wt,fr,k,bt,Mt,tt,W,jt,ut,qt,Nt,Yt,Zt,w,Rt,Vt,Sr,gt,et,vt,Tt,ie,yt,Bt,_;const R={current:"2.17.latest"},Se={version:"1.34.0"};var j;(function(s){s.Call="call",s.Reply="reply",s.Syn="syn",s.SynAck="synAck",s.Ack="ack"})(j||(j={}));var pt;(function(s){s.Fulfilled="fulfilled",s.Rejected="rejected"})(pt||(pt={}));var Ut;(function(s){s.ConnectionDestroyed="ConnectionDestroyed",s.ConnectionTimeout="ConnectionTimeout",s.NoIframeSrc="NoIframeSrc"})(Ut||(Ut={}));var ce;(function(s){s.DataCloneError="DataCloneError"})(ce||(ce={}));var nt;(function(s){s.Message="message"})(nt||(nt={}));const Jr=(s,o)=>{const t=[];let e=!1;return{destroy(r){e||(e=!0,o(`${s}: Destroying connection`),t.forEach(n=>{n(r)}))},onDestroy(r){e?r():t.push(r)}}},Ur=s=>(...o)=>{s&&console.log("[Penpal]",...o)},kr={"http:":"80","https:":"443"},_r=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,xr=["file:","data:"],Hr=s=>{if(s&&xr.find(u=>s.startsWith(u)))return"null";const o=document.location,t=_r.exec(s);let e,r,n;t?(e=t[1]?t[1]:o.protocol,r=t[2],n=t[4]):(e=o.protocol,r=o.hostname,n=o.port);const c=n&&n!==kr[e]?`:${n}`:"";return`${e}//${r}${c}`},be=({name:s,message:o,stack:t})=>({name:s,message:o,stack:t}),Kr=s=>{const o=new Error;return Object.keys(s).forEach(t=>o[t]=s[t]),o},$r=(s,o,t)=>{const{localName:e,local:r,remote:n,originForSending:c,originForReceiving:u}=s;let l=!1;const C=p=>{if(p.source!==n||p.data.penpal!==j.Call)return;if(p.origin!==u){t(`${e} received message from origin ${p.origin} which did not match expected origin ${u}`);return}const I=p.data,{methodName:b,args:v,id:P}=I;t(`${e}: Received ${b}() call`);const A=S=>x=>{if(t(`${e}: Sending ${b}() reply`),l){t(`${e}: Unable to send ${b}() reply due to destroyed connection`);return}const L={penpal:j.Reply,id:P,resolution:S,returnValue:x};S===pt.Rejected&&x instanceof Error&&(L.returnValue=be(x),L.returnValueIsError=!0);try{n.postMessage(L,c)}catch(F){if(F.name===ce.DataCloneError){const st={penpal:j.Reply,id:P,resolution:pt.Rejected,returnValue:be(F),returnValueIsError:!0};n.postMessage(st,c)}throw F}};new Promise(S=>S(o[b].apply(o,v))).then(A(pt.Fulfilled),A(pt.Rejected))};return r.addEventListener(nt.Message,C),()=>{l=!0,r.removeEventListener(nt.Message,C)}};let zr=0;const Wr=()=>++zr,ve=".",Ie=s=>s?s.split(ve):[],jr=s=>s.join(ve),qr=(s,o)=>{const t=Ie(o||"");return t.push(s),jr(t)},Yr=(s,o,t)=>{const e=Ie(o);return e.reduce((r,n,c)=>(typeof r[n]>"u"&&(r[n]={}),c===e.length-1&&(r[n]=t),r[n]),s),s},Ae=(s,o)=>{const t={};return Object.keys(s).forEach(e=>{const r=s[e],n=qr(e,o);typeof r=="object"&&Object.assign(t,Ae(r,n)),typeof r=="function"&&(t[n]=r)}),t},Zr=s=>{const o={};for(const t in s)Yr(o,t,s[t]);return o},Qr=(s,o,t,e,r)=>{const{localName:n,local:c,remote:u,originForSending:l,originForReceiving:C}=o;let p=!1;r(`${n}: Connecting call sender`);const I=v=>(...P)=>{r(`${n}: Sending ${v}() call`);let A;try{u.closed&&(A=!0)}catch{A=!0}if(A&&e(),p){const S=new Error(`Unable to send ${v}() call due to destroyed connection`);throw S.code=Ut.ConnectionDestroyed,S}return new Promise((S,x)=>{const L=Wr(),F=rt=>{if(rt.source!==u||rt.data.penpal!==j.Reply||rt.data.id!==L)return;if(rt.origin!==C){r(`${n} received message from origin ${rt.origin} which did not match expected origin ${C}`);return}const Gt=rt.data;r(`${n}: Received ${v}() reply`),c.removeEventListener(nt.Message,F);let Jt=Gt.returnValue;Gt.returnValueIsError&&(Jt=Kr(Jt)),(Gt.resolution===pt.Fulfilled?S:x)(Jt)};c.addEventListener(nt.Message,F);const st={penpal:j.Call,id:L,methodName:v,args:P};u.postMessage(st,l)})},b=t.reduce((v,P)=>(v[P]=I(P),v),{});return Object.assign(s,Zr(b)),()=>{p=!0}},Xr=(s,o,t,e,r)=>{const{destroy:n,onDestroy:c}=e;let u,l;const C={};return p=>{if(p.origin!==o){r(`Parent: Handshake - Received ACK message from origin ${p.origin} which did not match expected origin ${o}`);return}r("Parent: Handshake - Received ACK");const I={localName:"Parent",local:window,remote:p.source,originForSending:t,originForReceiving:o};u&&u(),u=$r(I,s,r),c(u),l&&l.forEach(v=>{delete C[v]}),l=p.data.methodNames;const b=Qr(C,I,l,n,r);return c(b),C}},tn=(s,o,t,e)=>r=>{if(r.origin!==t){s(`Parent: Handshake - Received SYN message from origin ${r.origin} which did not match expected origin ${t}`);return}s("Parent: Handshake - Received SYN, responding with SYN-ACK");const n={penpal:j.SynAck,methodNames:Object.keys(o)};r.source.postMessage(n,e)},en=6e4,sn=(s,o)=>{const{destroy:t,onDestroy:e}=o,r=setInterval(()=>{s.isConnected||(clearInterval(r),t())},en);e(()=>{clearInterval(r)})},rn=(s,o)=>{let t;return s!==void 0&&(t=window.setTimeout(()=>{const e=new Error(`Connection timed out after ${s}ms`);e.code=Ut.ConnectionTimeout,o(e)},s)),()=>{clearTimeout(t)}},nn=s=>{if(!s.src&&!s.srcdoc){const o=new Error("Iframe must have src or srcdoc property defined.");throw o.code=Ut.NoIframeSrc,o}},an=s=>{let{iframe:o,methods:t={},childOrigin:e,timeout:r,debug:n=!1}=s;const c=Ur(n),u=Jr("Parent",c),{onDestroy:l,destroy:C}=u;e||(nn(o),e=Hr(o.src));const p=e==="null"?"*":e,I=Ae(t),b=tn(c,I,e,p),v=Xr(I,e,p,u,c);return{promise:new Promise((A,S)=>{const x=rn(r,C),L=F=>{if(!(F.source!==o.contentWindow||!F.data)){if(F.data.penpal===j.Syn){b(F);return}if(F.data.penpal===j.Ack){const st=v(F);st&&(x(),A(st));return}}};window.addEventListener(nt.Message,L),c("Parent: Awaiting handshake"),sn(o,u),l(F=>{window.removeEventListener(nt.Message,L),F&&S(F)})}),destroy(){C()}}},on=s=>{const o=new RegExp(/^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w.-]+)+[\w]+\/$/);let t="";return o.test(s)?t=s:s.indexOf("/index.html")>-1?t=s.replace("/index.html","/"):s.charAt(-1)!=="/"&&(t=`${s}/`),t},cn=(s,o,t)=>{const e=on(o),n=`<html>
2
2
  <head>
3
3
  <base href="/" />
4
4
  <meta charset="UTF-8"/>
@@ -17,5 +17,5 @@
17
17
  <\/script>
18
18
  </body>
19
19
  </html>
20
- `;s.srcdoc=n},an=(s,o,t,e="chili-editor",r)=>{const n=`#${e}`,c=document.createElement("iframe");c.setAttribute("srcdoc"," "),c.setAttribute("title","Chili-Editor"),c.setAttribute("style","width: 100%; height: 100%;"),c.setAttribute("frameBorder","0"),c.setAttribute("referrerpolicy","origin");const u=()=>{const l=document.querySelector(n);l&&(l==null||l.appendChild(c),nn(c,s,r))};document.readyState==="complete"||document.readyState==="interactive"?u():document.addEventListener("DOMContentLoaded",()=>{u()}),t(sn({iframe:c,methods:{actionsChanged:o.onActionsChanged,stateChanged:o.onStateChanged,documentLoaded:o.onDocumentLoaded,authExpired:o.onAuthExpired,viewportRequested:o.onViewportRequested,selectedFramesContent:o.onSelectedFramesContentChanged,selectedFramesLayout:o.onSelectedFramesLayoutChanged,allFramesLayout:o.onFramesLayoutChanged,selectedLayoutProperties:o.onSelectedLayoutPropertiesChanged,openLayoutPropertiesPanel:o.onPageSelectionChanged,selectedLayoutUnit:o.onSelectedLayoutUnitChanged,scrubberPositionChanged:o.onScrubberPositionChanged,frameAnimationsChanged:o.onFrameAnimationsChanged,selectedToolChanged:o.onSelectedToolChanged,variableListChanged:o.onVariableListChanged,undoStackStateChanged:o.onUndoStateChanged,selectedLayoutFramesChanged:o.onSelectedLayoutFramesChanged,selectedTextStyleChanged:o.onSelectedTextStyleChanged,colorsChanged:o.onColorsChanged,paragraphStylesChanged:o.onParagraphStylesChanged,characterStylesChanged:o.onCharacterStylesChanged,fontFamiliesChanged:o.onFontFamiliesChanged,selectedLayoutId:o.onSelectedLayoutIdChanged,layoutListChanged:o.onLayoutsChanged,connectorEvent:o.onConnectorEvent,connectorsChanged:o.onConnectorsChanged,zoomChanged:o.onZoomChanged,pageSnapshotInvalidated:o.onPageSnapshotInvalidated,pagesChanged:o.onPagesChanged,pageSizeChanged:o.onPageSizeChanged,shapeCornerRadiusChanged:o.onShapeCornerRadiusChanged,cropActiveFrameIdChanged:o.onCropActiveFrameIdChanged,asyncError:o.onAsyncError,viewModeChanged:o.onViewModeChanged,barcodeValidationChanged:o.onBarcodeValidationChanged,selectedPageIdChanged:o.onSelectedPageIdChanged,dataSourceIdChanged:o.onDataSourceIdChanged,documentIssueListChanged:o.onDocumentIssueListChanged,customUndoDataChanged:o.onCustomUndoDataChanged,engineEditingModeChanged:o.onEngineEditModeChanged,brandKitMediaChanged:o.onBrandKitMediaChanged}}))};var q=(s=>(s.GraFxStudioEnvironmentApiUrl="ENVIRONMENT_API",s.GraFxStudioSdkVersion="SDK_VERSION",s.GraFxStudioDocumentType="DOCUMENT_TYPE",s.GraFxStudioTemplateId="TEMPLATE_ID",s.GraFxStudioAuthToken="GRAFX_AUTH_TOKEN",s.QueryCallCacheEnabled="ENABLE_QUERY_CALL_CACHE",s))(q||{});const on={shortcutOptions:{debugPanel:{enabled:!1},ellipse:{enabled:!1},hand:{enabled:!1},image:{enabled:!1},polygon:{enabled:!1},rectangle:{enabled:!1},select:{enabled:!1},text:{enabled:!1},zoom:{enabled:!1},copyPaste:{enabled:!1},viewMode:{enabled:!1}}};var Ae=(s=>(s.overflow="overflow",s.fontLoading="fontLoading",s.actionRegister="actionRegister",s.actionExecution="actionExecution",s.actionCircular="actionCircular",s))(Ae||{}),ce=(s=>(s.project="project",s.template="template",s.component="component",s))(ce||{});const cn=404075;function Pe(s){const o=s.error??"Yikes, something went wrong",t={cause:{name:String(s.status),message:s.error??"Yikes, something went wrong"}};if(s.status===cn){const r=JSON.parse(s.data).statusCode;throw new Fe(r,o,t)}else throw new Error(o,t)}function i(s,o=!0){try{s.success||Pe(s);const t=s.data&&o;return{...s,parsedData:t?JSON.parse(s.data):s.data}}catch(t){throw console.error(t),t}}class Fe extends Error{constructor(o,t,e){super(t,e),this.statusCode=o}}class Ee{constructor(o){g(this,V);this.getAll=async()=>(await a(this,V)).getActions().then(e=>i(e)),this.getById=async t=>(await a(this,V)).getActionById(t).then(r=>i(r)),this.create=async()=>(await a(this,V)).createAction().then(e=>i(e)),this.duplicate=async t=>(await a(this,V)).duplicateAction(t).then(r=>i(r)),this.remove=async t=>(await a(this,V)).removeAction(t).then(r=>i(r)),this.update=async(t,e)=>(await a(this,V)).updateAction(t,JSON.stringify(e)).then(n=>i(n)),this.rename=async(t,e)=>this.update(t,{name:e}),this.updateScript=async(t,e)=>this.update(t,{script:e}),this.updateTriggers=async(t,e)=>this.update(t,{triggers:e}),this.move=async(t,e)=>(await a(this,V)).moveActions(t,e).then(n=>i(n)),this.setTypeError=async(t,e)=>this.update(t,{hasTypeError:e}),this.disable=async()=>(await a(this,V)).disableActions().then(e=>i(e)),this.enable=async()=>(await a(this,V)).enableActions().then(e=>i(e)),y(this,V,o)}}V=new WeakMap;class De{constructor(o){g(this,M);this.getAllOnSelectedLayout=async()=>(await a(this,M)).getAnimationsOnSelectedLayout().then(e=>i(e)),this.getByFrameId=async(t,e)=>(await a(this,M)).getAnimationByFrameId(t,e).then(n=>i(n)),this.getByLayoutId=async t=>(await a(this,M)).getAnimationsByLayoutId(t).then(r=>i(r)),this.setFrameAnimation=async t=>(await a(this,M)).setFrameAnimation(JSON.stringify(t)).then(r=>i({...r,data:JSON.stringify(t)})),this.play=async()=>(await a(this,M)).playAnimation().then(e=>i(e)),this.pause=async()=>(await a(this,M)).pauseAnimation().then(e=>i(e)),this.setScrubberPosition=async t=>(await a(this,M)).setScrubberPosition(t).then(r=>i(r)),this.setDuration=async t=>(await a(this,M)).setAnimationDuration(t).then(r=>i(r)),this.resetFrameAnimation=async t=>(await a(this,M)).resetFrameAnimation(t).then(r=>i(r)),this.reset=async()=>(await a(this,M)).resetAnimation().then(e=>i(e)),y(this,M,o)}}M=new WeakMap;var H=(s=>(s.code39="code39",s.code93="code93",s.code128="code128",s.dataMatrix="dataMatrix",s.ean13="ean13",s.ean8="ean8",s.qr="qr",s.upca="upca",s.upce="upce",s.gs1128="gs1128",s))(H||{}),It=(s=>(s.low="low",s.medium="medium",s.quartile="quartile",s.high="high",s))(It||{}),pt=(s=>(s.utf8="utf8",s.iso8859_1="iso8859_1",s.code128a="code128a",s.code128b="code128b",s.code128c="code128c",s))(pt||{}),Le=(s=>(s.success="success",s.empty="empty",s.invalidLength="invalidLength",s.invalidCharacters="invalidCharacters",s.invalidChecksum="invalidChecksum",s.invalidUPCE="invalidUPCE",s.otherError="otherError",s))(Le||{}),Y=(s=>(s.top="top",s.right="right",s.bottom="bottom",s.left="left",s))(Y||{}),Oe=(s=>(s.top="top",s.child="child",s))(Oe||{}),Me=(s=>(s.px="px",s.mm="mm",s.cm="cm",s.inch="inch",s.pt="pt",s))(Me||{}),Ne=(s=>(s.print="print",s.digitalStatic="digitalStatic",s.digitalAnimated="digitalAnimated",s))(Ne||{}),Re=(s=>(s.locked="locked",s.range="range",s.none="none",s))(Re||{});class Ve{constructor(o){g(this,z);this.setBarcodeProperties=async(t,e)=>(await a(this,z)).setBarcodeProperties(t,JSON.stringify(e)).then(n=>i(n)),this.setEnableBackground=async(t,e)=>{const r={enableBackground:e};return this.setBarcodeProperties(t,r)},this.setBackgroundColor=async(t,e)=>{const r={backgroundColor:e};return this.setBarcodeProperties(t,r)},this.setEnableBars=async(t,e)=>{const r={enableBars:e};return this.setBarcodeProperties(t,r)},this.setBarColor=async(t,e)=>{const r={barColor:e};return this.setBarcodeProperties(t,r)},this.setBarcodeSource=async(t,e)=>(await a(this,z)).setBarcodeSource(t,JSON.stringify(e)).then(n=>i(n)),this.removeBarcodeSource=async t=>(await a(this,z)).setBarcodeSource(t,null).then(r=>i(r)),this.setEnableText=async(t,e)=>{const r={enableText:e};return this.setBarcodeProperties(t,r)},this.setBarHeight=async(t,e)=>{const r={barHeight:e};return this.setBarcodeProperties(t,r)},this.setMagnification=async(t,e)=>{const r={magnification:e};return this.setBarcodeProperties(t,r)},this.setQuietZoneValue=async(t,e,r)=>{const n=r?{left:r===Y.left?e:void 0,top:r===Y.top?e:void 0,right:r===Y.right?e:void 0,bottom:r===Y.bottom?e:void 0}:{left:e,top:e,right:e,bottom:e};return(await a(this,z)).setBarcodeProperties(t,JSON.stringify({quietZone:n})).then(u=>i(u))},this.setAreQuietZoneValuesCombined=async(t,e)=>{const r={areQuietZoneValuesCombined:e};return(await a(this,z)).setBarcodeProperties(t,JSON.stringify({quietZone:r})).then(c=>i(c))},this.setErrorCorrectionLevel=async(t,e)=>(await a(this,z)).setBarcodeProperties(t,JSON.stringify({errorCorrectionLevel:e})).then(n=>i(n)),this.setCharacterSet=async(t,e)=>(await a(this,z)).setBarcodeProperties(t,JSON.stringify({characterSet:e})).then(n=>i(n)),this.setDrawLightMarginIndicator=async(t,e)=>{const r={drawStartStopChars:e};return this.setBarcodeProperties(t,r)},this.setDrawStartStopChars=async(t,e)=>{const r={drawStartStopChars:e};return this.setBarcodeProperties(t,r)},this.getBarcodeConfigationOptions=t=>{let e=!0,r=!0,n=!0,c,u,l=!1,C=!1,p=!1;switch(t){case H.qr:c=[pt.iso8859_1,pt.utf8],u=[It.low,It.medium,It.quartile,It.high];case H.dataMatrix:e=!1,r=!1,n=!1,l=!0;break;case H.ean13:e=!1,C=!0;break;case H.ean8:C=!0;case H.upca:case H.upce:e=!1;break;case H.code128:case H.gs1128:c=[pt.code128a,pt.code128b,pt.code128c];break;case H.code39:p=!0;break}return{allowEnableMagnification:n,allowBarHeight:r,allowQuietZone:!0,allowedCharacterSets:c,allowedErrorCorrectionLevels:u,allowToggleText:e,quietZoneAlwaysCombined:l,allowToggleLightMarginIndicator:C,allowToggleDrawStartAndEndChar:p}},y(this,z,o)}}z=new WeakMap;var K=(s=>(s.rgb="rgb",s.hex="hex",s.cmyk="cmyk",s.spotCmyk="spotCmyk",s.spotRgb="spotRgb",s.spotHex="spotHex",s))(K||{}),Z=(s=>(s.rgb="rgb",s.hex="hex",s.cmyk="cmyk",s.gray="gray",s.hsl="hsl",s.spot="spot",s.spotCMYK="spotCMYK",s.spotRGB="spotRGB",s.spotHEX="spotHEX",s))(Z||{}),Qt=(s=>(s.local="local",s.brandKit="brandKit",s.stylekit="brandKit",s))(Qt||{});const Te=s=>s.type===K.hex,he=s=>s.type===K.spotHex,hn=s=>s.type===K.spotRgb,ln=s=>s.type===K.spotCmyk,dn=s=>hn(s)||ln(s)||he(s),un=s=>{const o=gn(s.type);return dn(s)?{...he(s)&&{value:s.displayValue},...!he(s)&&{...s.displayValue},spotName:s.value,type:o}:{...Te(s)&&{value:s.value},...!Te(s)&&{...s.value},type:o}},Be=(s,o,t,e)=>{const{brandKitColorGuid:r,brandKitFontFamilyGuid:n,fontStyleId:c,textStrokeColorGuid:u,textStrokeColorApplied:l,textStrokeWidth:C,...p}=s;return{...Object.keys(p).reduce((b,I)=>({...b,[I]:{value:s[I]}}),{}),...o&&{color:{value:{id:o.id,color:o.color,type:Qt.brandKit,isApplied:p.fillColorApplied}}},...t&&{strokeColor:{value:{id:t.id,color:t.color,type:Qt.brandKit,isApplied:l||!1}},strokeColorApplied:{value:l||!1},strokeWidth:{value:C!=null?C.toString():C}},fontKey:{value:e??null}}},gn=s=>{switch(s){case K.rgb:return Z.rgb;case K.cmyk:return Z.cmyk;case K.hex:return Z.hex;case K.spotRgb:return Z.spotRGB;case K.spotCmyk:return Z.spotCMYK;case K.spotHex:return Z.spotHEX}},Xt=(s,o)=>{if(!(s===null||o===void 0))return(s||[]).find(t=>t.id===o)},Ge=(s,o,t)=>{var e,r;if(!(s===null||o===void 0||t===void 0))return(r=(e=(s||[]).find(n=>n.id===o))==null?void 0:e.fontStyles.find(n=>n.fontStyleId===t))==null?void 0:r.id};class Je{constructor(o,t){g(this,N);this.getId=async()=>(await a(this,N)).getBrandKitId().then(r=>i(r)),this.getVersion=async()=>(await a(this,N)).getBrandKitVersion().then(r=>i(r)),this.getName=async()=>(await a(this,N)).getBrandKitName().then(r=>i(r)),this.rename=async e=>(await a(this,N)).renameBrandKit(e).then(n=>i(n)),this.updateIdAndVersion=async(e,r)=>(await a(this,N)).updateBrandKitIdAndVersion(e,r).then(c=>i(c)),this.get=async()=>{const e=await this.getId(),r=await this.getVersion(),n=await this.getName(),c=this.colorStyleController.getAll(),u=this.gradientStyleController.getAll(),l=this.fontController.getFontFamilies(),C=this.characterStyleController.getAll(),p=this.paragraphStyleController.getAll(),v=this.getAllMedia(),[b,I,P,A,S,x]=await Promise.all([c,u,l,p,C,v]),O={id:e.parsedData,brandKit:{id:e.parsedData,name:n.parsedData,lastModifiedDate:r.parsedData,colors:b.parsedData,gradients:I.parsedData,fonts:P.parsedData,paragraphStyles:A.parsedData,characterStyles:S.parsedData,media:x.parsedData}},F={success:!0,data:JSON.stringify(O),parsedData:O,status:200};return i(F)},this.getAllMedia=async()=>(await a(this,N)).getAllBrandKitMedia().then(r=>i(r)),this.addMedia=async(e,r,n)=>(await a(this,N)).addBrandKitMedia(e,r,n).then(u=>i(u)),this.updateMedia=async(e,r,n)=>(await a(this,N)).updateBrandKitMedia(e,r,n).then(u=>i(u)),this.renameMedia=async(e,r)=>(await a(this,N)).renameBrandKitMedia(e,r).then(c=>i(c)),this.removeMedia=async e=>(await a(this,N)).removeBrandKitMedia(e).then(n=>i(n)),this.remove=async()=>{const r=(await this.colorStyleController.getAll()).parsedData||[],c=(await this.gradientStyleController.getAll()).parsedData||[],l=(await this.paragraphStyleController.getAll()).parsedData||[],p=(await this.characterStyleController.getAll()).parsedData||[],b=(await this.fontController.getFontFamilies()).parsedData||[],P=(await this.getAllMedia()).parsedData||[];await this.undoManagerController.record("brandKit.remove",async A=>{for(const S of r)await A.colorStyle.remove(S.id);for(const S of c)await A.gradientStyle.remove(S.id);for(const S of l)await A.paragraphStyle.remove(S.id);for(const S of p)await A.characterStyle.remove(S.id);for(const S of b)await A.font.removeFontFamily(S.id);for(const S of P)await this.removeMedia(S.name)})},this.set=async e=>{let r={success:!0,status:200,parsedData:{id:e.id,version:e.brandKit.lastModifiedDate,name:e.brandKit.name,colors:[],gradients:[],fonts:[],paragraphStyles:[],characterStyles:[],media:[]}};return await this.undoManagerController.record("brandKit.set",async n=>{const c=await this.setColors(e,n);await this.setGradients(e,n);const u=await this.setFonts(e,n),{parsedData:l=[]}=await n.colorStyle.getAll(),{parsedData:C=[]}=await n.gradientStyle.getAll(),{parsedData:p}=await n.font.getFontFamilies();await this.setParagraphStyles(e,n,{localColors:l,localFonts:p,localColorGuidMap:c,localFontGuidMap:u}),await this.setCharacterStyles(e,n,{localColors:l,localFonts:p,localColorGuidMap:c,localFontGuidMap:u}),await this.setMedia(e);const{parsedData:v}=await n.paragraphStyle.getAll(),{parsedData:b}=await n.characterStyle.getAll(),{parsedData:I}=await this.getAllMedia();await n.brandKit.updateIdAndVersion(e.id,e.brandKit.lastModifiedDate),await n.brandKit.rename(e.brandKit.name),r={success:!0,status:200,parsedData:{id:e.id,version:e.brandKit.lastModifiedDate,name:e.brandKit.name,colors:l||[],gradients:C||[],fonts:p||[],paragraphStyles:v||[],characterStyles:b||[],media:I||[]}}}),r},y(this,N,o),this.colorStyleController=t.colorStyle,this.gradientStyleController=t.gradientStyle,this.fontController=t.font,this.mediaController=t.mediaConnector,this.paragraphStyleController=t.paragraphStyle,this.characterStyleController=t.characterStyle,this.undoManagerController=t.undoManager}async setColors(o,t){const e=new Map;for(const r of o.brandKit.colors||[]){const{parsedData:n}=await t.colorStyle.create();if(!n)continue;e.set(r.guid,n);const c=un(r);await t.colorStyle.rename(n,r.name),await t.colorStyle.update(n,c)}return e}async setGradients(o,t){return new Map}async setFonts(o,t){const e=o.fontConnectorId,r=new Map;for(const n of o.brandKit.fonts||[]){const{parsedData:c=[]}=await t.fontConnector.detail(e,n.fontFamilyId);if(!(c!=null&&c[0]))throw new Error(`No font styles for family ID: ${n.fontFamilyId}`);const{parsedData:u}=await t.font.addFontFamily(e,{name:c[0].familyName,fontFamilyId:n.fontFamilyId});u&&r.set(n.fontFamilyBrandKitGuid,u)}return r}async setParagraphStyles(o,t,e){const{localColors:r,localFonts:n,localColorGuidMap:c,localFontGuidMap:u}=e;for(const l of o.brandKit.paragraphStyles||[]){const C=c.get(l.brandKitColorGuid),p=c.get(l.textStrokeColorGuid),v=u.get(l.brandKitFontFamilyGuid),b=Ge(n,v,l.fontStyleId);if(!v||!b)throw new Error(`Paragraph style could not be created with an empty font family: ${l.name}`);const I=Xt(r,C),P=Xt(r,p);if(!I)throw new Error(`Paragraph style could not be created with an empty color: ${l.name}`);const{parsedData:A}=await t.paragraphStyle.create(),S=Be(l,I,P,`${b}`);await t.paragraphStyle.rename(A,l.name),await t.paragraphStyle.update(A,S)}}async setCharacterStyles(o,t,e){const{localColors:r,localFonts:n,localColorGuidMap:c,localFontGuidMap:u}=e;for(const l of o.brandKit.characterStyles||[]){const C=l.brandKitColorGuid?c.get(l.brandKitColorGuid):void 0,p=l.textStrokeColorGuid?c.get(l.textStrokeColorGuid):void 0,v=l.brandKitFontFamilyGuid?u.get(l.brandKitFontFamilyGuid):void 0,b=Xt(r,C),I=Xt(r,p),P=Ge(n,v,l.fontStyleId),{parsedData:A}=await t.characterStyle.create(),S=Be(l,b,I,P);await t.characterStyle.rename(A,l.name),await t.characterStyle.update(A,S)}}async setMedia(o){for(const t of o.brandKit.media||[])await this.addMedia(t.name,t.mediaConnectorId,t.mediaId)}}N=new WeakMap;class le{constructor(o){g(this,at);this.zoomToPage=async(t,e,r,n,c)=>(t!==void 0&&console.warn("id has no effect and will be deprecated in the future"),(await a(this,at)).zoomToPage(e,r,n,c).then(l=>i(l))),this.getZoomPercentage=async()=>(await a(this,at)).getZoomPercentage().then(e=>i(e)),this.setZoomPercentage=async t=>(await a(this,at)).setZoomPercentage(t).then(r=>i(r)),this.setViewMode=async t=>(await a(this,at)).setViewMode(t).then(r=>i(r)),y(this,at,o)}}at=new WeakMap;class ke{constructor(o){g(this,B);this.getAll=async()=>(await a(this,B)).getCharacterStyles().then(e=>i(e)),this.getById=async t=>(await a(this,B)).getCharacterStyleById(t).then(r=>i(r)),this.create=async()=>(await a(this,B)).createCharacterStyle().then(e=>i(e)),this.update=async(t,e)=>(await a(this,B)).updateCharacterStyle(t,JSON.stringify(e)).then(n=>i(n)),this.remove=async t=>(await a(this,B)).removeCharacterStyle(t).then(r=>i(r)),this.duplicate=async t=>(await a(this,B)).duplicateCharacterStyle(t).then(r=>i(r)),this.rename=async(t,e)=>(await a(this,B)).renameCharacterStyle(t,e).then(n=>i(n)),this.move=async(t,e)=>(await a(this,B)).moveCharacterStyles(t,e).then(n=>i(n)),y(this,B,o)}}B=new WeakMap;class Ue{constructor(o){g(this,it);this.copyFrames=async t=>{const r=await(await a(this,it)).copyFrames(t);return r.data&&await navigator.clipboard.writeText(r.data),i(r)},this.cutFrames=async t=>{const r=await(await a(this,it)).cutFrames(t);return r.data&&await navigator.clipboard.writeText(r.data),i(r)},this.pasteFrames=async()=>{const t=await a(this,it),e=await navigator.clipboard.readText(),r=await t.pasteFrames(e);return i(r)},this.getContentType=async()=>{const t=await a(this,it),e=await navigator.clipboard.readText(),r=await t.getClipboardContentType(e);return i(r)},y(this,it,o)}}it=new WeakMap;class _e{constructor(o){g(this,_t);this.convertToRgb=async t=>(await a(this,_t)).colorToRgb(JSON.stringify(t)).then(r=>i(r)),y(this,_t,o)}}_t=new WeakMap;class xe{constructor(o){g(this,G);this.getAll=async()=>(await a(this,G)).getColors().then(e=>i(e)),this.getById=async t=>(await a(this,G)).getColorById(t).then(r=>i(r)),this.create=async()=>(await a(this,G)).createColor().then(e=>i(e)),this.duplicate=async t=>(await a(this,G)).duplicateColor(t).then(r=>i(r)),this.move=async(t,e)=>(await a(this,G)).moveColors(t,e).then(n=>i(n)),this.rename=async(t,e)=>(await a(this,G)).renameColor(t,e).then(n=>i(n)),this.update=async(t,e)=>{const r=await a(this,G),n=e;return n.type===Z.spot&&(n.type=Z.spotCMYK),r.updateColor(t,JSON.stringify(n)).then(c=>i(c))},this.remove=async t=>(await a(this,G)).removeColor(t).then(r=>i(r)),y(this,G,o)}}G=new WeakMap;var vt=(s=>(s[s.file=0]="file",s[s.collection=1]="collection",s))(vt||{}),te=(s=>(s.LowResolutionWeb="lowresWeb",s.HighResolutionWeb="highresWeb",s))(te||{}),At=(s=>(s.file="file",s.collection="collection",s))(At||{}),He=(s=>(s.media="media",s.fonts="fonts",s.data="data",s))(He||{}),Ke=(s=>(s.name="name",s.path="relativePath",s.id="id",s))(Ke||{}),$e=(s=>(s.ascending="asc",s.descending="desc",s))($e||{}),ze=(s=>(s.text="text",s.boolean="boolean",s))(ze||{}),We=(s=>(s.query="query",s.upload="upload",s))(We||{}),Pt=(s=>(s.url="url",s.grafx="grafx",s.local="local",s))(Pt||{});class yn{constructor(o,t,e,r="engineToConnector"){this.direction="engineToConnector",this.name=o,this.direction=r,t==="var"?this.value=`${t}.${e}`:this.value=e}}var je=(s=>(s.variable="var",s.value="value",s))(je||{}),qe=(s=>(s.engineToConnector="engineToConnector",s.connectorToEngine="connectorToEngine",s))(qe||{}),ee=(s=>(s.loading="loading",s.loaded="loaded",s.running="running",s.ready="ready",s.error="error",s))(ee||{}),Ye=(s=>(s.stateChanged="stateChanged",s.authChanged="authChanged",s.reloadRequired="reloadRequired",s.unloaded="unloaded",s))(Ye||{});const pn={url:"grafx-media.json",source:"local"};class Cn{constructor(o){this.type="grafxToken",this.token=o}}class mn{constructor(){this.type="refreshed"}}var Ze=(s=>(s.grafxToken="grafxToken",s.refreshed="refreshed",s))(Ze||{}),Qe=(s=>(s.grafxToken="grafxToken",s.any="any",s))(Qe||{}),de=(s=>(s.minDimension="minDimension",s))(de||{});class Xe extends Error{constructor(o,t){super(o),this.type=t}}class ue{constructor(){this.makeConnectorSourceForwardsCompatible=o=>{if(o.source!=Pt.grafx||this.isSourceMigrated(o))return o;let t=o.url;for(;t.endsWith("/");)t=t.substring(0,t.length-1);const e=t.split("/");return{id:e[e.length-1],source:Pt.grafx}},this.makeMultipleConnectorsBackwardsCompatible=(o,t)=>o.map(e=>this.makeSingleConnectorBackwardsCompatible(e,t)),this.makeSingleConnectorBackwardsCompatible=(o,t)=>o.source.source!=Pt.grafx?o:{id:o.id,name:o.name,iconUrl:o.iconUrl,source:this.makeConnectorSourceBackwardsCompatible(o.source,t)},this.makeConnectorSourceBackwardsCompatible=(o,t)=>{let e=t;for(;e!=null&&e.endsWith("/");)e=e.substring(0,e.length-1);return{url:`${e}/connectors/${o.id}`,source:Pt.grafx}},this.isSourceMigrated=o=>"id"in o}}let ts=(pr=class{constructor(o,t){g(this,J);g(this,Et);g(this,Ct);this.getById=async e=>(await a(this,J)).getConnectorById(e).then(n=>i(n)).then(n=>{const c={...n,parsedData:null};return n.parsedData&&(c.parsedData=a(this,Ct).makeSingleConnectorBackwardsCompatible(n.parsedData,a(this,Et).get(q.GraFxStudioEnvironmentApiUrl))),c}),this.getAllByType=async e=>(await a(this,J)).getConnectors(e).then(n=>i(n)).then(n=>{const c={...n,parsedData:null};return n.parsedData&&(c.parsedData=a(this,Ct).makeMultipleConnectorsBackwardsCompatible(n.parsedData,a(this,Et).get(q.GraFxStudioEnvironmentApiUrl))),c}),this.register=async e=>{const r=await a(this,J),n=a(this,Ct).makeConnectorSourceForwardsCompatible(e);return r.registerConnector(JSON.stringify(n)).then(c=>i(c))},this.unregister=async e=>(await a(this,J)).unregisterConnector(e).then(n=>i(n)),this.configure=async(e,r)=>{const n=await a(this,J);return await this.waitToBeReady(e),await r(new wn(e,n)),n.updateConnectorConfiguration(e).then(c=>i(c))},this.getState=async e=>(await a(this,J)).getConnectorState(e).then(n=>i(n)),this.getOptions=async e=>(await a(this,J)).getConnectorOptions(e).then(n=>i(n)),this.waitToBeReady=async(e,r=2e3)=>{let n=Math.max(r,500);n=Math.min(n,5e3);const c=100;let u=0;try{for(;u*c<n;){const l=await this.getState(e);if(l.success&&l.parsedData&&(l.parsedData.type===ee.running||l.parsedData.type===ee.ready))return i({data:null,success:!0,error:void 0,status:0,parsedData:void 0},!1);await new Promise(C=>setTimeout(C,c)),u++}}catch(l){return i({data:null,success:!1,error:`Error while getting connector state ${l}`,status:5e4,parsedData:void 0},!1)}return i({data:null,success:!1,error:"Timed out waiting for connector",status:5e4,parsedData:void 0},!1)},this.updateMappings=async(e,r)=>await this.configure(e,async n=>{const{parsedData:c}=await this.getMappings(e),u=(c==null?void 0:c.filter(p=>!r.some(v=>v.name===p.name&&v.direction===p.direction)))??[],l=r.filter(p=>p.name!==""&&p.value!==""),C=[...u,...l];await n.setMappings(C)}),y(this,J,o),y(this,Et,t),y(this,Ct,new ue)}async getMappings(o,t){return(await a(this,J)).getConnectorMappings(o).then(r=>i(r)).then(r=>{var n;return t?{...r,parsedData:(n=r.parsedData)==null?void 0:n.filter(c=>c.direction===t)}:r})}},J=new WeakMap,Et=new WeakMap,Ct=new WeakMap,pr);class wn{constructor(o,t){g(this,mt);g(this,wt);this.setOptions=async e=>a(this,wt).setConnectorOptions(a(this,mt),JSON.stringify(e)).then(r=>i(r)),this.setMappings=async e=>{const r=await a(this,wt).setConnectorMappings(a(this,mt),e.map(function(n){return JSON.stringify(n)}));return i(r)},this.setHttpHeader=async(e,r)=>a(this,wt).connectorAuthenticationSetHttpHeader(a(this,mt),e,r).then(n=>i(n)),y(this,mt,o),y(this,wt,t)}}mt=new WeakMap,wt=new WeakMap;class es{constructor(o,t){g(this,ot);g(this,xt);this.getPage=async(e,r,n={})=>(await a(this,ot)).dataConnectorGetPage(e,JSON.stringify(r),JSON.stringify(n)).then(u=>i(u)).then(u=>{const l={...u,parsedData:null};return u.parsedData&&(l.parsedData={data:u.parsedData.data.map(C=>a(this,xt).mapEngineToDataItem(C)),continuationToken:u.parsedData.continuationToken}),l}),this.getModel=async(e,r={})=>(await a(this,ot)).dataConnectorGetModel(e,JSON.stringify(r)).then(c=>i(c)),this.getConfigurationOptions=async e=>(await a(this,ot)).dataConnectorGetConfigurationOptions(e).then(n=>i(n)),this.getCapabilities=async e=>(await a(this,ot)).dataConnectorGetCapabilities(e).then(n=>i(n)),y(this,ot,o),y(this,xt,t)}}ot=new WeakMap,xt=new WeakMap;class ss{constructor(o,t){g(this,ct);g(this,Ht);this.setDataSource=async e=>(await a(this,ct)).setDataSource(e).then(n=>i(n)),this.getDataSource=async()=>(await a(this,ct)).getDataSource().then(r=>i(r)),this.removeDataSource=async()=>(await a(this,ct)).removeDataSource().then(r=>i(r)),this.setDataRow=async e=>{const r=await a(this,ct),n=a(this,Ht).mapDataItemToEngine(e);return r.setDataRow(JSON.stringify(n)).then(c=>i(c))},y(this,ct,o),y(this,Ht,t)}}ct=new WeakMap,Ht=new WeakMap;class rs{constructor(o){g(this,ht);this.getAllLogs=async()=>(await a(this,ht)).getLogs().then(e=>i(e)),this.toggleDebugPanel=async()=>(await a(this,ht)).toggleDebugPanel().then(e=>i(e)),this.enableDebug=async()=>(await a(this,ht)).enableDebug().then(e=>i(e)),this.disableDebug=async()=>(await a(this,ht)).disableDebug().then(e=>i(e)),y(this,ht,o)}}ht=new WeakMap;class ns{constructor(o){g(this,ft);this.getCurrentState=async()=>(await a(this,ft)).getCurrentDocumentState().then(e=>i(e)),this.load=async(t,e={keepConnectors:!1})=>{const r=await a(this,ft),n=typeof t!="string"?JSON.stringify(t):t;return r.loadDocument(n,JSON.stringify(e)).then(c=>i(c))},this.createAndLoad=async t=>{const e=await a(this,ft),r=JSON.stringify(t);return e.createAndLoadDocument(r).then(n=>i(n))},y(this,ft,o)}}ft=new WeakMap;var as=(s=>(s.top="top",s.bottom="bottom",s.left="left",s.right="right",s))(as||{}),kt=(s=>(s.url="url",s.variable="variable",s.connector="connector",s.brandKitMedia="brandKitMedia",s))(kt||{}),is=(s=>(s.text="text",s.image="image",s.shape="shape",s.barcode="barcode",s))(is||{}),os=(s=>(s.variable="variable",s.text="text",s))(os||{}),cs=(s=>(s.leftToRight="leftToRight",s.rightToLeft="rightToLeft",s.weak="weak",s))(cs||{}),hs=(s=>(s.horizontal="horizontal",s.vertical="vertical",s.onPath="onPath",s))(hs||{}),ls=(s=>(s.top="top",s.bottom="bottom",s.middle="middle",s.justify="justify",s))(ls||{}),ds=(s=>(s.normal="normal",s.screen="screen",s.overlay="overlay",s.darken="darken",s.lighten="lighten",s.colorDodge="colorDodge",s.colorBurn="colorBurn",s.hardLight="hardLight",s.softLight="softLight",s.difference="difference",s.exclusion="exclusion",s.multiply="multiply",s.hue="hue",s.saturation="saturation",s.color="color",s.luminosity="luminosity",s))(ds||{}),us=(s=>(s.fill="fill",s.fit="fit",s.smartCrop="smartCrop",s.manualCrop="manualCrop",s))(us||{}),gs=(s=>(s.topLeft="topLeft",s.topCenter="topCenter",s.topRight="topRight",s.centerLeft="centerLeft",s.center="center",s.centerRight="centerRight",s.bottomLeft="bottomLeft",s.bottomCenter="bottomCenter",s.bottomRight="bottomRight",s))(gs||{}),ys=(s=>(s.bringToFront="bringToFront",s.sendToBack="sendToBack",s.bringForward="bringForward",s.sendBackward="sendBackward",s))(ys||{}),ps=(s=>(s.relative="relative",s.start="start",s.end="end",s.startAndEnd="startAndEnd",s.center="center",s))(ps||{}),Cs=(s=>(s.page="page",s.frame="frame",s))(Cs||{}),ms=(s=>(s.start="start",s.end="end",s.center="center",s))(ms||{});class fn{constructor(){this.type="page"}}class Sn{constructor(o,t){this.type="frame",this.frameId=o,this.edge=t}}var ge=(s=>(s.frameCrop="frameCrop",s.assetCrop="assetCrop",s))(ge||{});class ws{constructor(o){g(this,k);this.insertImageVariableToFrame=async(t,e)=>{const r=await a(this,k),n={id:e,type:kt.variable};return r.setImageSource(t,JSON.stringify(n)).then(c=>i(c))},this.insertTextVariable=async t=>(await a(this,k)).insertTextVariable(t).then(r=>i(r)),this.enterTextEditMode=async t=>(await a(this,k)).enterTextEditMode(t).then(r=>i(r)),this.exitTextEditMode=async()=>(await a(this,k)).exitTextEditMode().then(e=>i(e)),this.getText=async(t,e)=>(await a(this,k)).getTextByFrameId(t,e).then(n=>i(n)),this.setText=async(t,e)=>(await a(this,k)).setTextByFrameId(t,e).then(n=>i(n)),this.selectText=async(t,e,r)=>(await a(this,k)).selectTextById(t,e,r).then(c=>i(c)),this.addCustomUndoData=async(t,e,r)=>(await a(this,k)).setCustomUndoData(t,e,r??!1).then(c=>i(c)),y(this,k,o)}}k=new WeakMap;class fs{constructor(o){g(this,lt);g(this,Dt);this.query=async(t,e,r={})=>(await a(this,lt)).fontConnectorQuery(t,JSON.stringify(e),JSON.stringify(r)).then(c=>i(c)),this.detail=async(t,e,r={})=>(await a(this,lt)).fontConnectorDetail(t,e,JSON.stringify(r)).then(c=>i(c)),this.download=async(t,e,r={})=>(await a(this,Dt)).fontConnectorDownload(t,e,JSON.stringify(r)).then(c=>c??c),this.preview=async(t,e,r,n={})=>(await a(this,Dt)).fontConnectorPreview(t,e,r,JSON.stringify(n)).then(u=>u??u),this.getConfigurationOptions=async t=>(await a(this,lt)).fontConnectorGetConfigurationOptions(t).then(r=>i(r)),this.getCapabilities=async t=>(await a(this,lt)).fontConnectorGetCapabilities(t).then(r=>i(r)),this.parseDeprecatedFontType=t=>{if(t===vt.file)return At.file;if(t===vt.collection)return At.collection},y(this,lt,o),y(this,Dt,o)}}lt=new WeakMap,Dt=new WeakMap;class Ss{constructor(o){g(this,E);this.addFontFamily=async(t,e)=>(await a(this,E)).addFontFamily(t,JSON.stringify(e)).then(n=>i(n)),this.removeFontFamily=async t=>(await a(this,E)).removeFontFamily(t).then(r=>i(r)),this.addFontStyle=async(t,e)=>(await a(this,E)).addFontStyle(t,JSON.stringify(e)).then(n=>i(n)),this.removeFontStyle=async t=>(await a(this,E)).removeFontStyle(t).then(r=>i(r)),this.getFontFamilies=async()=>(await a(this,E)).getFontFamilies().then(e=>i(e)),this.getFontStyles=async t=>(await a(this,E)).getFontStyles(t).then(r=>i(r)),this.getFontFamilyById=async t=>(await a(this,E)).getFontFamilyById(t).then(r=>i(r)),this.getFontStyleById=async t=>(await a(this,E)).getFontStyleById(t).then(r=>i(r)),this.getDefaultFontStyle=async()=>(await a(this,E)).getDefaultFontStyle().then(e=>i(e)),this.getDefaultFontFamily=async()=>(await a(this,E)).getDefaultFontFamily().then(e=>i(e)),this.isFontFamilyUsed=async t=>(await a(this,E)).isFontFamilyUsed(t).then(r=>i(r)),this.isFontStyleUsed=async t=>(await a(this,E)).isFontStyleUsed(t).then(r=>i(r)),this.moveFontFamilies=async(t,e)=>(await a(this,E)).moveFontFamilies(t,e).then(n=>i(n)),this.getPreviewsOfCharacterStrings=async(t,e)=>(await a(this,E)).getPreviewsOfCharacterStrings(t,JSON.stringify(e)).then(n=>i(n)),y(this,E,o)}}E=new WeakMap;class ye{constructor(o){g(this,Lt);this.setShapeProperties=async(t,e)=>(await a(this,Lt)).setShapeProperties(t,JSON.stringify(e)).then(n=>i(n)),this.setEnableFill=async(t,e)=>{const r={enableFill:e};return this.setShapeProperties(t,r)},this.setFillColor=async(t,e)=>{const r={fillColor:e};return this.setShapeProperties(t,r)},this.setEnableStroke=async(t,e)=>{const r={enableStroke:e};return this.setShapeProperties(t,r)},this.setStrokeColor=async(t,e)=>{const r={strokeColor:e};return this.setShapeProperties(t,r)},this.setStrokeWeight=async(t,e)=>{const r={strokeWeight:e};return this.setShapeProperties(t,r)},this.setFlagAllCornersSame=async(t,e)=>{const r={allCornersSame:e};return this.setShapeProperties(t,r)},this.setShapeCorners=async(t,e)=>(await a(this,Lt)).setShapeCorners(t,JSON.stringify(e)).then(n=>i(n)),this.setRadiusAll=async(t,e)=>{const r={radiusAll:e};return this.setShapeCorners(t,r)},this.setRadiusTopLeft=async(t,e)=>{const r={topLeft:e};return this.setShapeCorners(t,r)},this.setRadiusBottomLeft=async(t,e)=>{const r={bottomLeft:e};return this.setShapeCorners(t,r)},this.setRadiusTopRight=async(t,e)=>{const r={topRight:e};return this.setShapeCorners(t,r)},this.setRadiusBottomRight=async(t,e)=>{const r={bottomRight:e};return this.setShapeCorners(t,r)},y(this,Lt,o)}}Lt=new WeakMap;class bs{constructor(o){g(this,d);this.getAll=async()=>(await a(this,d)).getFrames().then(e=>i(e)),this.getSelected=async()=>(await a(this,d)).getSelectedFrames().then(e=>i(e)),this.getAllByPageId=async t=>(await a(this,d)).getFramesByPageId(t).then(r=>i(r)),this.getByName=async t=>(await a(this,d)).getFrameByName(t).then(r=>i(r)),this.getById=async t=>(await a(this,d)).getFrameById(t).then(r=>i(r)),this.getPropertiesOnSelectedLayout=async()=>(await a(this,d)).getFramePropertiesOnSelectedLayout().then(e=>i(e)),this.getLayoutProperties=async(t,e)=>(await a(this,d)).getFramePropertiesByFrameId(t,e).then(n=>i(n)),this.getAllLayoutProperties=async t=>(await a(this,d)).getFramesProperties(t).then(r=>i(r)),this.resetTransformation=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.resetSize=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.select=async t=>(await a(this,d)).selectFrames([t]).then(r=>i(r)),this.selectMultiple=async t=>(await a(this,d)).selectFrames(t).then(r=>i(r)),this.deselectAll=async()=>(await a(this,d)).deselectFrames().then(e=>i(e)),this.reorderFrames=async(t,e)=>(await a(this,d)).reorderFrames(t,e).then(n=>i(n)),this.setZIndex=async(t,e)=>(await a(this,d)).setFrameZIndex(t,e).then(n=>i(n)),this.setHeight=async(t,e)=>(await a(this,d)).setFrameHeight(t,e).then(n=>i(n)),this.setRotation=async(t,e)=>(await a(this,d)).setFrameRotation(t,e).then(n=>i(n)),this.setWidth=async(t,e)=>(await a(this,d)).setFrameWidth(t,e).then(n=>i(n)),this.setX=async(t,e)=>(await a(this,d)).setFrameX(t,e).then(n=>i(n)),this.setY=async(t,e)=>(await a(this,d)).setFrameY(t,e).then(n=>i(n)),this.rename=async(t,e)=>(await a(this,d)).renameFrame(t,e).then(n=>i(n)),this.reset=async t=>(await a(this,d)).resetFrame(t).then(r=>i(r)),this.resetX=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.resetY=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.resetRotation=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.resetWidth=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.resetHeight=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.resetImageFrameFitMode=async t=>(await a(this,d)).resetImageFrameFitMode(t).then(r=>i(r)),this.setVisibility=async(t,e)=>(await a(this,d)).setFrameIsVisible(t,e).then(n=>i(n)),this.setIsVisible=async(t,e)=>(await a(this,d)).setFrameIsVisible(t,e).then(n=>i(n)),this.remove=async t=>(await a(this,d)).removeFrames([t]).then(r=>i(r)),this.removeFrames=async t=>(await a(this,d)).removeFrames(t).then(r=>i(r)),this.create=async(t,e,r,n,c)=>(await a(this,d)).addFrame(t,e,r,n,c).then(l=>i(l)),this.createShapeFrame=async(t,e,r,n,c)=>(await a(this,d)).addFrame(t,e,r,n,c).then(l=>i(l)),this.createBarcodeFrame=async(t,e)=>(await a(this,d)).addBarcodeFrame(t,e==null?void 0:e.x,e==null?void 0:e.y).then(n=>i(n)),this.duplicateFrames=async t=>(await a(this,d)).duplicateFrames(t).then(r=>i(r)),this.updateImageSource=async(t,e)=>{const r=await a(this,d),n=e!==null?JSON.stringify(e):null;return r.setImageSource(t,n).then(c=>i(c))},this.removeImageSource=async t=>this.updateImageSource(t,null),this.setImageFromConnector=async(t,e,r)=>{const n={id:e,assetId:r,type:kt.connector};return this.updateImageSource(t,n)},this.setImageFromUrl=async(t,e)=>{const r={url:e,type:kt.url};return this.updateImageSource(t,r)},this.setImageFrameFitMode=async(t,e)=>(await a(this,d)).setImageFrameFitMode(t,e).then(n=>i(n)),this.setImageFrameFitModePosition=async(t,e)=>(await a(this,d)).setImageFrameFitModePosition(t,e).then(n=>i(n)),this.setFrameConstrainProportions=async(t,e)=>(console.error("setFrameConstrainProportions is not supported anymore"),i({success:!1,status:0,error:"setFrameConstrainProportions is not supported anymore",parsedData:null})),this.setVerticalAlign=async(t,e)=>(await a(this,d)).setVerticalAlignment(t,e).then(n=>i(n)),this.setMinCopyfitting=async(t,e)=>(await a(this,d)).setMinCopyfitting(t,e).then(n=>i(n)),this.setMaxCopyfitting=async(t,e)=>(await a(this,d)).setMaxCopyfitting(t,e).then(n=>i(n)),this.setEnableCopyfitting=async(t,e)=>(await a(this,d)).setEnableCopyfitting(t,e).then(n=>i(n)),this.resetMinCopyfitting=async t=>(await a(this,d)).resetMinCopyfitting(t).then(r=>i(r)),this.resetMaxCopyfitting=async t=>(await a(this,d)).resetMaxCopyfitting(t).then(r=>i(r)),this.resetEnableCopyfitting=async t=>(await a(this,d)).resetEnableCopyfitting(t).then(r=>i(r)),this.setShapeFrameEnableFill=async(t,e)=>this.shapeController.setEnableFill(t,e),this.setShapeFrameFillColor=async(t,e)=>this.shapeController.setFillColor(t,e),this.setShapeFrameEnableStroke=async(t,e)=>this.shapeController.setEnableStroke(t,e),this.setShapeFrameStrokeColor=async(t,e)=>this.shapeController.setStrokeColor(t,e),this.setShapeFrameStrokeWeight=async(t,e)=>this.shapeController.setStrokeWeight(t,e),this.setBlendMode=async(t,e)=>(await a(this,d)).setFrameBlendMode(t,e).then(n=>i(n)),this.enterCropMode=async(t,e=ge.frameCrop)=>(await a(this,d)).enterCropMode(t,e).then(n=>i(n)),this.applyCropMode=async()=>(await a(this,d)).applyCropMode().then(e=>i(e)),this.exitCropMode=async()=>(await a(this,d)).cancelCropMode().then(e=>i(e)),this.enterSubjectMode=async t=>(await a(this,d)).enterSubjectMode(t).then(r=>i(r)),this.applySubjectMode=async()=>(await a(this,d)).applySubjectMode().then(e=>i(e)),this.exitSubjectMode=async()=>(await a(this,d)).cancelSubjectMode().then(e=>i(e)),this.enterGradientMode=async t=>(await a(this,d)).enterGradientMode(t).then(r=>i(r)),this.applyGradientMode=async()=>(await a(this,d)).applyGradientMode().then(e=>i(e)),this.cancelGradientMode=async()=>(await a(this,d)).cancelGradientMode().then(e=>i(e)),this.resetCropMode=async t=>(console.error("resetCropMode is not supported anymore"),i({success:!1,status:0,error:"resetCropMode is not supported anymore",parsedData:null})),this.setEnableAutoGrow=async(t,e)=>{const r={enabled:{value:e}};return(await a(this,d)).updateAutoGrowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setAutoGrowMinWidth=async(t,e)=>{const r={minWidth:{value:e}};return(await a(this,d)).updateAutoGrowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setAutoGrowMaxWidth=async(t,e)=>{const r={maxWidth:{value:e}};return(await a(this,d)).updateAutoGrowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setAutoGrowMinHeight=async(t,e)=>{const r={minHeight:{value:e}};return(await a(this,d)).updateAutoGrowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setAutoGrowMaxHeight=async(t,e)=>{const r={maxHeight:{value:e}};return(await a(this,d)).updateAutoGrowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setAutoGrowDirections=async(t,e)=>{const r={directions:{value:e}};return(await a(this,d)).updateAutoGrowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.resetAutoGrowSettingsEnabled=async t=>(console.error("resetAutoGrowSettingsEnabled is not supported anymore"),i({success:!1,status:0,error:"resetAutoGrowSettingsEnabled is not supported anymore",parsedData:null})),this.resetAutoGrowMinWidth=async t=>(console.error("resetAutoGrowMinWidth is not supported anymore"),i({success:!1,status:0,error:"resetAutoGrowMinWidth is not supported anymore",parsedData:null})),this.resetAutoGrowMaxWidth=async t=>(console.error("resetAutoGrowMaxWidth is not supported anymore"),i({success:!1,status:0,error:"resetAutoGrowMaxWidth is not supported anymore",parsedData:null})),this.resetAutoGrowMinHeight=async t=>(console.error("resetAutoGrowMinHeight is not supported anymore"),i({success:!1,status:0,error:"resetAutoGrowMinHeight is not supported anymore",parsedData:null})),this.resetAutoGrowMaxHeight=async t=>(console.error("resetAutoGrowMaxHeight is not supported anymore"),i({success:!1,status:0,error:"resetAutoGrowMaxHeight is not supported anymore",parsedData:null})),this.resetAutoGrowDirections=async t=>(console.error("resetAutoGrowDirections is not supported anymore"),i({success:!1,status:0,error:"resetAutoGrowDirections is not supported anymore",parsedData:null})),this.resetAutoGrow=async t=>(console.error("resetAutoGrow is not supported anymore"),i({success:!1,status:0,error:"resetAutoGrow is not supported anymore",parsedData:null})),this.setShadowEnabled=async(t,e)=>{const r={enabled:{value:e}};return(await a(this,d)).updateFrameShadowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setShadowDistance=async(t,e)=>{const r={distance:{value:e}};return(await a(this,d)).updateFrameShadowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setShadowAngleDegrees=async(t,e)=>{const r={angleDegrees:{value:e}};return(await a(this,d)).updateFrameShadowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setShadowBlurRadius=async(t,e)=>{const r={blurRadius:{value:e}};return(await a(this,d)).updateFrameShadowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setShadowColor=async(t,e)=>{const r={color:{value:e}};return(await a(this,d)).updateFrameShadowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setAnchor=async(t,e,r,n,c)=>{const u={horizontal:e,type:r,target:n,endTarget:c};return(await a(this,d)).setAnchorProperties(t,JSON.stringify(u)).then(C=>i(C))},this.setVerticalAnchor=async(t,e,r,n)=>this.setAnchor(t,!1,e,r,n),this.setHorizontalAnchor=async(t,e,r,n)=>this.setAnchor(t,!0,e,r,n),this.resetAnchoring=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.resetVisibility=async t=>(await a(this,d)).setFrameIsVisible(t,null).then(r=>i(r)),this.getConfiguration=async t=>(await a(this,d)).getFrameConfiguration(t).then(r=>i(r)),this.resetAssetCropOverride=async t=>(await a(this,d)).resetAssetCropOverride(t).then(r=>i(r)),this.resetAllAssetCropOverrides=async t=>(await a(this,d)).resetAllAssetCropOverrides(t).then(r=>i(r)),this.setGradientApplied=async(t,e)=>{const r={isApplied:e};return(await a(this,d)).updateFrameGradientSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setLocalGradient=async(t,e)=>{const r={gradient:e};return(await a(this,d)).updateFrameGradientSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setBrandKitGradient=async(t,e)=>{const r={id:e};return(await a(this,d)).updateFrameGradientSettings(t,JSON.stringify(r)).then(c=>i(c))},y(this,d,o),this.shapeController=new ye(a(this,d))}}d=new WeakMap;class Is{constructor(){this.currentEngineVersion=R.current,this.currentSDKVersion=fe.version}}class vs{constructor(o){g(this,f);g(this,Kt);this.getAll=async()=>(await a(this,f)).getLayouts().then(e=>i(e)),this.getById=async t=>(await a(this,f)).getLayoutById(t).then(r=>i(r)),this.getByName=async t=>(await a(this,f)).getLayoutByName(t).then(r=>i(r)),this.getSelected=async()=>(await a(this,f)).getSelectedLayout().then(e=>i(e)),this.remove=async t=>(await a(this,f)).removeLayout(t).then(r=>i(r)),this.create=async(t,e)=>{const r=await a(this,f);return e!=null&&e.length?r.addLayouts(t,JSON.stringify(e)).then(n=>i(n)):r.addLayout(t).then(n=>i(n))},this.rename=async(t,e)=>(await a(this,f)).renameLayout(t,e).then(n=>i(n)),this.select=async t=>(await a(this,f)).selectLayout(t).then(r=>i(r)),this.duplicate=async t=>(await a(this,f)).duplicateLayout(t).then(r=>i(r)),this.reset=async t=>(await a(this,f)).resetLayout(t).then(r=>i(r)),this.setHeight=async(t,e)=>(await a(this,f)).setLayoutHeight(t,e).then(n=>i(n)),this.setWidth=async(t,e)=>(await a(this,f)).setLayoutWidth(t,e).then(n=>i(n)),this.setUnit=async(t,e)=>(await a(this,f)).setLayoutUnit(t,e).then(n=>i(n)),this.resetHeight=async t=>(await a(this,f)).resetLayoutHeight(t).then(r=>i(r)),this.resetWidth=async t=>(await a(this,f)).resetLayoutWidth(t).then(r=>i(r)),this.resetUnit=async t=>(await a(this,f)).resetLayoutUnit(t).then(r=>i(r)),this.getSelectedSnapshot=async()=>(await a(this,Kt)).getPageSnapshot().then(e=>e??e),this.setIntent=async(t,e)=>(await a(this,f)).setLayoutIntent(t,e).then(n=>i(n)),this.resetIntent=async t=>(await a(this,f)).resetLayoutIntent(t).then(r=>i(r)),this.setFillColor=async(t,e)=>(await a(this,f)).setLayoutFillColor(t,JSON.stringify(e)).then(n=>i(n)),this.setFillColorEnabled=async(t,e)=>(await a(this,f)).setLayoutFillColorEnabled(t,e).then(n=>i(n)),this.resetFillColor=async t=>(await a(this,f)).resetLayoutFillColor(t).then(r=>i(r)),this.setBleedValue=async(t,e,r)=>{const n=r?{left:r===Y.left?e:void 0,top:r===Y.top?e:void 0,right:r===Y.right?e:void 0,bottom:r===Y.bottom?e:void 0}:{left:e,top:e,right:e,bottom:e};return(await a(this,f)).updateLayoutBleed(t,JSON.stringify(n)).then(u=>i(u))},this.setAreBleedValuesCombined=async(t,e)=>{const r={areBleedValuesCombined:e};return(await a(this,f)).updateLayoutBleed(t,JSON.stringify(r)).then(c=>i(c))},this.resetBleedValues=async t=>(await a(this,f)).updateLayoutBleed(t,null).then(r=>i(r)),this.setPrivateData=async(t,e)=>(await a(this,f)).setLayoutPrivateData(t,JSON.stringify(e)).then(n=>i(n)),this.getPrivateData=async t=>(await a(this,f)).getLayoutPrivateData(t).then(r=>i(r)),this.setDisplayName=async(t,e)=>(await a(this,f)).setLayoutDisplayName(t,e).then(n=>i(n)),this.getDisplayName=async t=>(await a(this,f)).getLayoutDisplayName(t).then(r=>i(r)),this.resetDisplayName=async t=>(await a(this,f)).setLayoutDisplayName(t,null).then(r=>i(r)),this.setAvailableForUser=async(t,e)=>(await a(this,f)).setLayoutAvailableForUser(t,e).then(n=>i(n)),this.setSelectedByUser=async(t,e)=>(await a(this,f)).setLayoutSelectedByUser(t,e).then(n=>i(n)),this.setResizableByUser=async(t,e)=>(await a(this,f)).setLayoutResizableByUser(t,JSON.stringify(e)).then(n=>i(n)),y(this,f,o),y(this,Kt,o)}}f=new WeakMap,Kt=new WeakMap;var se=(s=>(s.thumbnail="thumbnail",s.mediumres="mediumres",s.highres="highres",s.original="original",s))(se||{}),pe=(s=>(s.web="web",s.print="print",s.animation="animation",s))(pe||{});class As{constructor(o){g(this,Q);g(this,$t);this.query=async(t,e,r={})=>(await a(this,Q)).mediaConnectorQuery(t,JSON.stringify(e),JSON.stringify(r)).then(c=>i(c)),this.detail=async(t,e,r={})=>(await a(this,Q)).mediaConnectorDetail(t,e,JSON.stringify(r)).then(c=>i(c)),this.download=async(t,e,r,n={})=>{const c=this.parseDeprecatedMediaDownloadType(r);return(await a(this,$t)).mediaConnectorDownload(t,e,c,pe.web,JSON.stringify(n)).then(l=>{if(l instanceof Uint8Array)return l;throw typeof l=="object"&&l!==null&&"success"in l&&!l.success&&Pe(l),new Error(`Unexpected response type: ${typeof l}.`)})},this.getConfigurationOptions=async t=>(await a(this,Q)).mediaConnectorGetConfigurationOptions(t).then(r=>i(r)),this.getCapabilities=async t=>(await a(this,Q)).mediaConnectorGetCapabilities(t).then(r=>i(r)),this.parseDeprecatedMediaType=t=>{if(t===vt.file)return At.file;if(t===vt.collection)return At.collection},this.upload=async(t,e,r={})=>(await a(this,Q)).mediaConnectorUpload(t,JSON.stringify(e),JSON.stringify(r)).then(c=>i(c)),y(this,Q,o),y(this,$t,o)}parseDeprecatedMediaDownloadType(o){switch(o){case te.HighResolutionWeb:return se.highres;case te.LowResolutionWeb:return se.thumbnail;default:return o}}}Q=new WeakMap,$t=new WeakMap;let Ps=(Cr=class{constructor(o){g(this,L);g(this,zt);this.add=async()=>(await a(this,L)).addPage().then(e=>i(e)),this.remove=async t=>(await a(this,L)).removePage(t).then(r=>i(r)),this.select=async t=>(await a(this,L)).selectPage(t).then(r=>i(r)),this.setVisibility=async(t,e)=>(await a(this,L)).setPageIsVisible(t,e).then(n=>i(n)),this.duplicate=async t=>(await a(this,L)).duplicatePage(t).then(r=>i(r)),this.getAll=async()=>(await a(this,L)).getPages().then(e=>i(e)),this.getById=async t=>(await a(this,L)).getPageById(t).then(r=>i(r)),this.getSnapshot=async(t,e)=>(await a(this,zt)).getPageSnapshotWithSettings(t,e==null?null:JSON.stringify(e)).then(n=>n??n),this.setWidth=async(t,e)=>(t!==void 0&&console.warn("pageId has no effect since all pages are being updated simultaneously."),(await a(this,L)).setPageWidth(e).then(n=>i(n))),this.setHeight=async(t,e)=>(t!==void 0&&console.warn("pageId has no effect since all pages are being updated simultaneously."),(await a(this,L)).setPageHeight(e).then(n=>i(n))),this.setSize=async(t,e)=>(await a(this,L)).setPageSize(t,e).then(n=>i(n)),this.move=async(t,e)=>(await a(this,L)).reorderPages(t,e).then(n=>i(n)),y(this,L,o),y(this,zt,o)}},L=new WeakMap,zt=new WeakMap,Cr);class Fs{constructor(o){g(this,U);this.getAll=async()=>(await a(this,U)).getParagraphStyles().then(e=>i(e)),this.getById=async t=>(await a(this,U)).getParagraphStyleById(t).then(r=>i(r)),this.create=async()=>(await a(this,U)).createParagraphStyle().then(e=>i(e)),this.duplicate=async t=>(await a(this,U)).duplicateParagraphStyle(t).then(r=>i(r)),this.update=async(t,e)=>(await a(this,U)).updateParagraphStyle(t,JSON.stringify(e)).then(n=>i(n)),this.rename=async(t,e)=>(await a(this,U)).renameParagraphStyle(t,e).then(n=>i(n)),this.remove=async t=>(await a(this,U)).removeParagraphStyle(t).then(r=>i(r)),this.move=async(t,e)=>(await a(this,U)).moveParagraphStyles(t,e).then(n=>i(n)),y(this,U,o)}}U=new WeakMap;var T=(s=>(s.info="info",s.warn="warn",s.error="error",s))(T||{}),Es=(s=>(s.general="general",s.connector="connector",s.event="event",s.engine="engine",s))(Es||{}),Ut=(s=>(s.throw="throw",s.log="log",s))(Ut||{});class Ds{constructor(o,t,e,r){this.type="action",this.message=o,this.id=t,this.event=e,this.eventChain=r}}class Ls{constructor(o,t,e){this.type="dataRow",this.count=o,this.message=t,this.exceptions=e}}var re=(s=>(s.shortText="shortText",s.longText="longText",s.image="image",s.list="list",s.boolean="boolean",s.group="group",s.number="number",s.date="date",s))(re||{}),Os=(s=>(s.Monday="monday",s.Tuesday="tuesday",s.Wednesday="wednesday",s.Thursday="thursday",s.Friday="friday",s.Saturday="saturday",s.Sunday="sunday",s))(Os||{}),Ms=(s=>(s.en_US="en_US",s.cs="cs",s.da="da",s.nl="nl",s.fi="fi",s.fr="fr",s.de="de",s.it="it",s.no="no",s.pl="pl",s.pt_PT="pt_PT",s.es_ES="es_ES",s.sv="sv",s))(Ms||{}),Ft=(s=>(s.visible="visible",s.invisible="invisible",s.conditional="conditional",s))(Ft||{}),Ns=(s=>(s.boolean="boolean",s.text="text",s.number="number",s))(Ns||{}),Rs=(s=>(s.equals="=",s.notEquals="!=",s.greaterThan=">",s.greaterThanOrEquals=">=",s.lessThan="<",s.lessThanOrEquals="<=",s))(Rs||{});let bn=class{constructor(o,t){this.onActionsChanged=e=>{this.config.events.onActionsChanged.trigger(JSON.parse(e))},this.onAnimationChanged=e=>{this.config.events.onFrameAnimationsChanged.trigger(JSON.parse(e))},this.onAnimationPlaybackChanged=e=>{this.config.events.onScrubberPositionChanged.trigger(JSON.parse(e))},this.onSelectedLayoutPropertiesChanged=e=>{this.config.events.onSelectedLayoutPropertiesChanged.trigger(JSON.parse(e))},this.onSelectedLayoutUnitChanged=e=>{this.config.events.onSelectedLayoutUnitChanged.trigger(e)},this.onFramesLayoutChanged=e=>{const r=JSON.parse(e);this.config.events.onFramesLayoutChanged.trigger(r)},this.onSelectedFramesLayoutChanged=e=>{const r=JSON.parse(e);this.config.events.onSelectedFramesLayoutChanged.trigger(r);const n=this.config.onSelectedFrameLayoutChanged;n&&n(r.length>1?void 0:r[0])},this.onSelectedFramesContentChanged=e=>{const r=JSON.parse(e);this.config.events.onSelectedFramesContentChanged.trigger(r);const n=this.config.onSelectedFrameContentChanged;n&&n(r.length>1?null:r[0])},this.onStateChanged=()=>{this.config.events.onStateChanged.trigger()},this.onAuthExpired=async e=>{const r=await this.config.handlers.onAuthExpired.trigger(JSON.parse(e));return r!=null?JSON.stringify(r):null},this.onViewportRequested=()=>{const e=this.config.handlers.onViewportRequested.trigger();return e!=null?JSON.stringify(e):null},this.onDocumentLoaded=()=>{this.config.events.onDocumentLoaded.trigger()},this.onPageSelectionChanged=e=>{this.config.events.onPageSelectionChanged.trigger(e)},this.onVariableListChanged=e=>{const n=JSON.parse(e).map(c=>{var u;return c.type===re.list?{...c,items:c.items.map(l=>l.value),selected:(u=c.selected)==null?void 0:u.value}:c});this.config.events.onVariableListChanged.trigger(n)},this.onSelectedToolChanged=e=>{this.config.events.onSelectedToolChanged.trigger(e)},this.onUndoStateChanged=e=>{this.config.events.onUndoStackStateChanged.trigger(JSON.parse(e))},this.onCustomUndoDataChanged=e=>{this.config.events.onCustomUndoDataChanged.trigger(JSON.parse(e))},this.onSelectedLayoutFramesChanged=e=>{this.config.events.onSelectedLayoutFramesChanged.trigger(JSON.parse(e))},this.onSelectedTextStyleChanged=e=>{this.config.events.onSelectedTextStyleChanged.trigger(JSON.parse(e))},this.onColorsChanged=e=>{this.config.events.onColorsChanged.trigger(JSON.parse(e))},this.onParagraphStylesChanged=e=>{this.config.events.onParagraphStylesChanged.trigger(JSON.parse(e))},this.onCharacterStylesChanged=e=>{this.config.events.onCharacterStylesChanged.trigger(JSON.parse(e))},this.onFontFamiliesChanged=e=>{this.config.events.onFontFamiliesChanged.trigger(JSON.parse(e))},this.onSelectedLayoutIdChanged=e=>{this.config.events.onSelectedLayoutIdChanged.trigger(e)},this.onLayoutsChanged=e=>{this.config.events.onLayoutsChanged.trigger(JSON.parse(e))},this.onZoomChanged=e=>{this.config.events.onZoomChanged.trigger(JSON.parse(e))},this.onConnectorEvent=e=>{this.config.events.onConnectorEvent.trigger(JSON.parse(e))},this.onConnectorsChanged=e=>{const n=new ue().makeMultipleConnectorsBackwardsCompatible(JSON.parse(e),this.localConfig.get(q.GraFxStudioEnvironmentApiUrl));this.config.events.onConnectorsChanged.trigger(n)},this.onSelectedPageIdChanged=e=>{this.config.events.onSelectedPageIdChanged.trigger(e)},this.onPagesChanged=e=>{this.config.events.onPagesChanged.trigger(JSON.parse(e))},this.onPageSnapshotInvalidated=e=>{this.config.events.onPageSnapshotInvalidated.trigger(e)},this.onPageSizeChanged=e=>{this.config.events.onPageSizeChanged.trigger(JSON.parse(e))},this.onShapeCornerRadiusChanged=e=>{this.config.events.onShapeCornerRadiusChanged.trigger(JSON.parse(e))},this.onCropActiveFrameIdChanged=e=>{this.config.events.onCropActiveFrameIdChanged.trigger(e)},this.onAsyncError=e=>{const r=JSON.parse(e);if((r==null?void 0:r.type)==="dataRow"){const n=new Ls(r.count,r.message,r.exceptions);this.config.events.onAsyncError.trigger(n)}else if((r==null?void 0:r.type)==="action"){const n=new Ds(r.message,r.id,r.event,r.eventChain);this.config.events.onAsyncError.trigger(n)}else this.config.events.onAsyncError.trigger(r)},this.onViewModeChanged=e=>{this.config.events.onViewModeChanged.trigger(e)},this.onBarcodeValidationChanged=e=>{this.config.events.onBarcodeValidationChanged.trigger(JSON.parse(e))},this.onDataSourceIdChanged=e=>{this.config.events.onDataSourceIdChanged.trigger(e)},this.onDocumentIssueListChanged=e=>{this.config.events.onDocumentIssueListChanged.trigger(JSON.parse(e))},this.onEngineEditModeChanged=e=>{this.config.events.onEngineEditModeChanged.trigger(JSON.parse(e))},this.onBrandKitMediaChanged=e=>{this.config.events.onBrandKitMediaChanged.trigger(JSON.parse(e))},this.config=o,this.localConfig=t}};class Vs{constructor(o){g(this,St);this.set=async t=>(await a(this,St)).selectedTextStyleDeltaUpdate(JSON.stringify(t)).then(r=>i(r)),this.removeSelected=async()=>(await a(this,St)).selectedTextStyleClean().then(e=>i(e)),this.getSelected=async()=>(await a(this,St)).getSelectedTextStyle().then(e=>i(e)),y(this,St,o)}}St=new WeakMap;var Ts=(s=>(s.FRAME_X="frameX",s.FRAME_Y="frameY",s.WIDTH="width",s.HEIGHT="height",s.FRAME_ROTATION="frameRotation",s))(Ts||{}),Bs=(s=>(s.LAYOUT_HEIGHT="layoutHeight",s.LAYOUT_WIDTH="layoutWidth",s.BLEED_TOP="bleedTop",s.BLEED_BOTTOM="bleedBottom",s.BLEED_LEFT="bleedLeft",s.BLEED_RIGHT="bleedRight",s.BLEED_VALUES_COMBINED="areBleedValuesCombined",s))(Bs||{}),$=(s=>(s.SELECT="select",s.ZOOM="zoom",s.HAND="hand",s.IMAGE_FRAME="imageFrame",s.TEXT_FRAME="textFrame",s.SHAPE_RECT="rect",s.SHAPE_ELLIPSE="ellipse",s.SHAPE_POLYGON="polygon",s))($||{}),Gs=(s=>(s.MP4="mp4",s.GIF="gif",s.PNG="png",s.JPG="jpg",s.PDF="pdf",s))(Gs||{}),ne=(s=>(s.SANDBOX="sandbox",s.PRODUCTION="online",s))(ne||{});class Js{constructor(o){g(this,Ot);this.setTool=async t=>(await a(this,Ot)).setTool(t).then(r=>i(r)),this.getSelected=async()=>(await a(this,Ot)).getSelectedTool().then(e=>i(e)),this.setPointer=async()=>this.setTool($.SELECT),this.setSelect=async()=>this.setTool($.SELECT),this.setHand=async()=>this.setTool($.HAND),this.setZoom=async()=>this.setTool($.ZOOM),this.setTextFrame=async()=>this.setTool($.TEXT_FRAME),this.setImageFrame=async()=>this.setTool($.IMAGE_FRAME),this.setShapeRect=async()=>this.setTool($.SHAPE_RECT),this.setShapeEllipse=async()=>this.setTool($.SHAPE_ELLIPSE),this.setShapePolygon=async()=>this.setTool($.SHAPE_POLYGON),y(this,Ot,o)}}Ot=new WeakMap;class ks{constructor(o,t){g(this,X);g(this,W);g(this,Wt);this.undo=async()=>(await a(this,X)).undo().then(r=>i(r)),this.redo=async()=>(await a(this,X)).redo().then(r=>i(r)),this.addCustomData=async(e,r)=>(await a(this,X)).setCustomUndoData(e,r,!1).then(c=>i(c)),this.record=async(e,r)=>{try{await a(this,W).beginIfNoneActive(e),await r(a(this,Wt)),await a(this,W).end()}catch(n){throw await a(this,W).abort(),n}},this.pause=async()=>(await a(this,X)).pause().then(r=>i(r)),this.resume=async()=>(await a(this,X)).resume().then(r=>i(r)),this.advanced={begin:async e=>a(this,W).begin(e),beginIfNoneActive:async e=>a(this,W).beginIfNoneActive(e),end:async()=>a(this,W).end(),abort:async()=>a(this,W).abort()},y(this,X,o),y(this,Wt,t),y(this,W,new In(o))}}X=new WeakMap,W=new WeakMap,Wt=new WeakMap;class In{constructor(o){g(this,dt);this.begin=async t=>(await a(this,dt)).begin(t).then(r=>i(r)),this.beginIfNoneActive=async t=>(await a(this,dt)).beginIfNoneActive(t).then(r=>i(r)),this.end=async()=>(await a(this,dt)).end().then(e=>i(e)),this.abort=async()=>(await a(this,dt)).abort().then(e=>i(e)),y(this,dt,o)}}dt=new WeakMap;const vn=(s,o=2)=>{const t=Math.pow(10,o);return Math.round(s*t)/t};class Us{constructor(o,t){g(this,jt);g(this,Mt);this.round=(e,r)=>i({data:String(vn(e,r)),success:!0,status:200,parsedData:null}),this.createEnvironmentBaseURL=e=>{const{type:r=ne.SANDBOX,environment:n="ft-nostress",version:c="1"}=e,u=r==ne.SANDBOX?"chili-publish-sandbox":"chili-publish";return`https://${n}.${u}.online/grafx/api/v${c}/environment/${n}`},this.stageFiles=async(e,r,n)=>{const c=a(this,Mt).get(q.GraFxStudioEnvironmentApiUrl);if(!c)throw new Error("GraFx Studio Environment API URL is not set");const u=`${c}connectors/${r}/stage`,l=a(this,Mt).get(q.GraFxStudioAuthToken);if(!l)throw new Error("GraFx Studio Auth Token is not set");const C=new FormData;e.forEach((b,I)=>{const P=b instanceof File?b.name:`blob-${I}`;C.append("files",b,P)}),n&&C.append("validationJson",JSON.stringify({allowedMimeTypes:n.mimeTypes,minDimensions:{width:n.minWidthPixels,height:n.minHeightPixels}}));const p=await fetch(u,{method:"POST",body:C,headers:{Authorization:`Bearer ${l}`}});if(p.status===422){const b=await p.json();throw new Xe(b.message,de.minDimension)}if(!p.ok)throw new Error("Failed to stage files");return await p.json()},this.unitEvaluate=async(e,r)=>(await a(this,jt)).unitEvaluate(e,r).then(c=>i(c)),y(this,jt,o),y(this,Mt,t)}}jt=new WeakMap,Mt=new WeakMap;class An{constructor(o){g(this,qt);this.setMinimum=async(t,e)=>{const r={minValue:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setMaximum=async(t,e)=>{const r={maxValue:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setShowStepper=async(t,e)=>{const r={showStepper:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setStepSize=async(t,e)=>{const r={stepSize:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setThousandsSeparator=async(t,e)=>{const r={thousandsSeparator:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setDecimalSeparator=async(t,e)=>{const r={decimalSeparator:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setDecimalCharacterStyle=async(t,e)=>{const r={decimalCharacterStyleId:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setNumberOfDecimals=async(t,e)=>{const r={numberOfDecimals:{value:e}};return this.applyPropertiesUpdate(t,r)},y(this,qt,o)}async applyPropertiesUpdate(o,t){const r=await(await a(this,qt)).updateNumberVariableProperties(o,JSON.stringify(t));return i(r)}}qt=new WeakMap;class Pn{constructor(o){g(this,Yt);this.setDisplayFormat=async(t,e)=>{const r={displayFormat:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setLocale=async(t,e)=>{const r={locale:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setStartDate=async(t,e)=>{const r={startDate:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setEndDate=async(t,e)=>{const r={endDate:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setExcludedDays=async(t,e)=>{const r={excludedDays:{value:e}};return this.applyPropertiesUpdate(t,r)},y(this,Yt,o)}async applyPropertiesUpdate(o,t){const r=await(await a(this,Yt)).updateDateVariableProperties(o,JSON.stringify(t));return i(r)}}Yt=new WeakMap;let _s=(mr=class{constructor(o){g(this,w);g(this,Nt);g(this,Rt);this.getAll=async()=>(await a(this,w)).getVariables().then(e=>i(e)).then(e=>{const r=e;return r.parsedData&&(r.parsedData=this.makeVariablesBackwardsCompatible(r.parsedData)),r}),this.getById=async t=>(await a(this,w)).getVariableById(t).then(r=>i(r)).then(r=>{const n=r;return n.parsedData&&(n.parsedData=this.makeVariableBackwardsCompatible(n.parsedData)),n}),this.getByName=async t=>(await a(this,w)).getVariableByName(t).then(r=>i(r)).then(r=>{const n=r;return n.parsedData&&(n.parsedData=this.makeVariableBackwardsCompatible(n.parsedData)),n}),this.create=async(t,e)=>(await a(this,w)).addVariable(t,e).then(n=>i(n)),this.remove=async t=>(await a(this,w)).removeVariables(t).then(r=>i(r)),this.rename=async(t,e)=>(await a(this,w)).setVariableName(t,e).then(n=>i(n)),this.setLabel=async(t,e)=>(await a(this,w)).setVariableLabel(t,e).then(n=>i(n)),y(this,Nt,async(t,e)=>(await a(this,w)).setVariablePlaceholder(t,e).then(n=>i(n))),this.setPlaceholder=async(t,e)=>a(this,Nt).call(this,t,e),this.resetPlaceholder=async t=>a(this,Nt).call(this,t,null),y(this,Rt,async(t,e)=>(await a(this,w)).setVariableHelpText(t,e).then(n=>i(n))),this.setHelpText=async(t,e)=>a(this,Rt).call(this,t,e),this.resetHelpText=async t=>a(this,Rt).call(this,t,null),this.setType=async(t,e)=>(await a(this,w)).setVariableType(t,e).then(n=>i(n)),this.setListVariable=async(t,e)=>(await a(this,w)).setListVariableItems(t,e.map(n=>JSON.stringify({value:n}))).then(n=>i(n)),this.setValue=async(t,e)=>(await a(this,w)).setVariableValue(t,e).then(n=>i(n)),this.duplicate=async t=>(await a(this,w)).duplicateVariable(t).then(r=>i(r)),this.groupVariables=async(t,e)=>(await a(this,w)).groupVariables(t,e).then(n=>i(n)),this.ungroupVariables=async t=>(await a(this,w)).ungroupVariable(t).then(r=>i(r)),this.move=async(t,e,r)=>(await a(this,w)).moveVariable(e,r,t).then(c=>i(c)),this.moveVariables=async(t,e,r)=>(await a(this,w)).moveVariables(e,r,t).then(c=>i(c)),this.setIsVisible=async(t,e)=>{const r=e?{type:Ft.visible}:{type:Ft.invisible};return this.setVariableVisibility(t,r)},this.setIsHidden=async(t,e)=>{const r=e?{type:Ft.invisible}:{type:Ft.visible};return this.setVariableVisibility(t,r)},this.setVariableVisibility=async(t,e)=>(await a(this,w)).setVariableVisibility(t,JSON.stringify(e)).then(n=>i(n)),this.setLayoutsForVariableVisibility=async t=>(await a(this,w)).setLayoutsForVariableVisibility(t?JSON.stringify(t):null).then(r=>i(r)),this.setIsRequired=async(t,e)=>(await a(this,w)).setVariableIsRequired(t,e).then(n=>i(n)),this.setRemoveParagraphIfEmpty=async(t,e)=>(await a(this,w)).setVariableRemoveParagraphIfEmpty(t,e).then(n=>i(n)),this.setIsReadonly=async(t,e)=>(await a(this,w)).setVariableIsReadonly(t,e).then(n=>i(n)),this.getImageVariableConnectorId=async t=>(await a(this,w)).getImageVariableConnectorId(t).then(r=>i(r)),this.setImageVariableConnector=async(t,e)=>{const r=await a(this,w),c=new ue().makeConnectorSourceForwardsCompatible(e);return r.setImageVariableConnector(t,JSON.stringify(c)).then(u=>i(u))},this.setImageVariableValueWithContext=async(t,e,r)=>(await a(this,w)).setImageVariableValueWithContext(t,e,JSON.stringify(r)).then(c=>i(c)),this.removeSource=async t=>this.setValue(t,null),this.setPrefix=async(t,e)=>{const r={prefix:{value:e}};return this.applyPrefixSuffixDeltaUpdate(t,r)},this.setSuffix=async(t,e)=>{const r={suffix:{value:e}};return this.applyPrefixSuffixDeltaUpdate(t,r)},this.setPrefixCharacterStyle=async(t,e)=>{const r={prefixCharacterStyleId:{value:e}};return this.applyPrefixSuffixDeltaUpdate(t,r)},this.setSuffixCharacterStyle=async(t,e)=>{const r={suffixCharacterStyleId:{value:e}};return this.applyPrefixSuffixDeltaUpdate(t,r)},this.setPrivateData=async(t,e)=>(await a(this,w)).setVariablePrivateData(t,JSON.stringify(e)).then(n=>i(n)),this.getPrivateData=async t=>(await a(this,w)).getVariablePrivateData(t).then(r=>i(r)),this.setAllowImageQuery=async(t,e)=>(await a(this,w)).setImageVariableAllowQuery(t,e).then(n=>i(n)),this.setAllowImageUpload=async(t,e)=>(await a(this,w)).setImageVariableAllowUpload(t,e).then(n=>i(n)),this.setMinImageUploadSize=async(t,e,r)=>(await a(this,w)).setImageVariableUploadMinSize(t,e,r).then(c=>i(c)),this.setIsDontBreak=async(t,e)=>(await a(this,w)).setVariableIsDontBreak(t,e).then(n=>i(n)),y(this,w,o),this.number=new An(a(this,w)),this.date=new Pn(a(this,w))}makeVariablesBackwardsCompatible(o){return o.map(t=>this.makeVariableBackwardsCompatible(t))}makeVariableBackwardsCompatible(o){return o.type!==re.list?o:this.makeListVariableBackwardsCompatible(o)}makeListVariableBackwardsCompatible(o){const t=o,e=o.items,r=o.selected,n=e.map(c=>c.value);return t.items=n,t.selected=r==null?void 0:r.value,t}async applyPrefixSuffixDeltaUpdate(o,t){const r=await(await a(this,w)).updateVariablePrefixSuffixProperties(o,JSON.stringify(t));return i(r)}},w=new WeakMap,Nt=new WeakMap,Rt=new WeakMap,mr);class Fn{constructor(o){this.onVariableListChanged=t=>{this.config.events.onVariableListChanged.trigger(JSON.parse(t))},this.onConnectorsChanged=t=>{this.config.events.onConnectorsChanged.trigger(JSON.parse(t))},this.onPageSizeChanged=t=>{this.config.events.onPageSizeChanged.trigger(JSON.parse(t))},this.onEngineEditModeChanged=t=>{this.config.events.onEngineEditModeChanged.trigger(JSON.parse(t))},this.config=o}}class En{constructor(o){g(this,ut);this.getAll=async()=>(await a(this,ut)).getVariables().then(e=>i(e)),this.getById=async t=>(await a(this,ut)).getVariableById(t).then(r=>i(r)),this.getByName=async t=>(await a(this,ut)).getVariableByName(t).then(r=>i(r)),this.setListVariable=async(t,e)=>(await a(this,ut)).setListVariableItems(t,e.map(n=>JSON.stringify(n))).then(n=>i(n)),y(this,ut,o),this.image=new Dn(o)}}ut=new WeakMap;class Dn{constructor(o){g(this,tt);this.setAllowQuery=async(t,e)=>(await a(this,tt)).setImageVariableAllowQuery(t,e).then(n=>i(n)),this.setAllowUpload=async(t,e)=>(await a(this,tt)).setImageVariableAllowUpload(t,e).then(n=>i(n)),this.setMinUploadSize=async(t,e,r)=>(await a(this,tt)).setImageVariableUploadMinSize(t,e,r).then(c=>i(c)),this.setConnector=async(t,e)=>(await a(this,tt)).setImageVariableConnector(t,JSON.stringify(e)).then(n=>i(n)),this.setConnectorContext=async(t,e)=>(await a(this,tt)).setImageVariableConnectorContext(t,JSON.stringify(e)).then(n=>i(n)),y(this,tt,o)}}tt=new WeakMap;class Ln{constructor(o){g(this,bt);this.register=async t=>(await a(this,bt)).registerConnector(JSON.stringify(t)).then(r=>i(r)),this.getById=async t=>(await a(this,bt)).getConnectorById(t).then(r=>i(r)),this.getAllByType=async t=>(await a(this,bt)).getConnectors(t).then(r=>i(r)),y(this,bt,o)}}bt=new WeakMap;class On{constructor(o){g(this,Vt);g(this,ae);this.setWidth=async t=>(await a(this,Vt)).setPageWidth(t).then(r=>i(r)),this.setHeight=async t=>(await a(this,Vt)).setPageHeight(t).then(r=>i(r)),y(this,Vt,o),y(this,ae,o)}}Vt=new WeakMap,ae=new WeakMap;class xs{constructor(o,t,e){this.config=o,this.connection=t,this.editorAPI=e,this.subscriber=new Fn(o),this.variable=new En(this.editorAPI),this.connector=new Ln(this.editorAPI),this.page=new On(this.editorAPI),this.canvas=new le(this.editorAPI)}}class Hs{constructor(o){this.logger=o}createEventHandlerFn(o,t){return(...r)=>{try{const n=o(...r);return n instanceof Promise?n.catch(c=>this.handleError(c,t,o.name)):n}catch(n){this.handleError(n,t,o.name)}}}handleError(o,t,e){var r;if(t===Ut.log)(r=this.logger)==null||r.call(this,T.error,Es.event,`Error in callback ${e}: ${o}`);else throw o}}class Ks extends Hs{constructor(o,t){super(t),this.handler=o}trigger(...o){const t=this.handler();if(t)return this.createEventHandlerFn(t,Ut.throw)(...o)}}class m extends Hs{constructor(o,t){super(t),this.legacyHandler=o,this.subscriptions=new Set}trigger(...o){const t=this.legacyHandler();t&&this.createEventHandlerFn(t,Ut.log)(...o);for(const e of this.subscriptions)e(...o)}registerCallback(o,t=Ut.log){const e=this.createEventHandlerFn(o,t);return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}}class Ce{static createRuntimeConfig(o){var e,r,n,c,u,l,C,p,v,b,I,P,A,S,x,O,F,et,st,Bt,Gt,wr,fr,Sr,br,Ir,vr,Ar,Pr,Fr,Er,Dr,Lr,Or,Mr;const t={...o};return t.logging={logLevel:((e=o.logging)==null?void 0:e.logLevel)||T.error,logger:((r=o.logging)==null?void 0:r.logger)||((Zt,me,we)=>{var Nr;if(Ce.isLoggingEnabled(Zt,((Nr=t.logging)==null?void 0:Nr.logLevel)??T.error))switch(Zt){case T.error:console.error(`[${me}] [${Zt}] ${we}`);break;case T.warn:console.warn(`[${me}] [${Zt}] ${we}`);break;default:console.log(`[${me}] [${Zt}] ${we}`)}})},t.handlers={onAuthExpired:new Ks(()=>t.onAuthExpired,(n=t.logging)==null?void 0:n.logger),onViewportRequested:new Ks(()=>t.onViewportRequested,(c=t.logging)==null?void 0:c.logger)},t.events={onActionsChanged:new m(()=>t.onActionsChanged,(u=t.logging)==null?void 0:u.logger),onStateChanged:new m(()=>t.onStateChanged,(l=t.logging)==null?void 0:l.logger),onDocumentLoaded:new m(()=>t.onDocumentLoaded,(C=t.logging)==null?void 0:C.logger),onSelectedFramesLayoutChanged:new m(()=>t.onSelectedFramesLayoutChanged,(p=t.logging)==null?void 0:p.logger),onFramesLayoutChanged:new m(()=>t.onFramesLayoutChanged,(v=t.logging)==null?void 0:v.logger),onSelectedFramesContentChanged:new m(()=>t.onSelectedFramesContentChanged,(b=t.logging)==null?void 0:b.logger),onPageSelectionChanged:new m(()=>t.onPageSelectionChanged,(I=t.logging)==null?void 0:I.logger),onSelectedLayoutPropertiesChanged:new m(()=>t.onSelectedLayoutPropertiesChanged,(P=t.logging)==null?void 0:P.logger),onSelectedLayoutUnitChanged:new m(()=>t.onSelectedLayoutUnitChanged,(A=t.logging)==null?void 0:A.logger),onScrubberPositionChanged:new m(()=>t.onScrubberPositionChanged,(S=t.logging)==null?void 0:S.logger),onFrameAnimationsChanged:new m(()=>t.onFrameAnimationsChanged,(x=t.logging)==null?void 0:x.logger),onVariableListChanged:new m(()=>t.onVariableListChanged,(O=t.logging)==null?void 0:O.logger),onSelectedToolChanged:new m(()=>t.onSelectedToolChanged,(F=t.logging)==null?void 0:F.logger),onUndoStackStateChanged:new m(()=>t.onUndoStackStateChanged,(et=t.logging)==null?void 0:et.logger),onSelectedLayoutFramesChanged:new m(()=>t.onSelectedLayoutFramesChanged,(st=t.logging)==null?void 0:st.logger),onSelectedTextStyleChanged:new m(()=>t.onSelectedTextStyleChanged,(Bt=t.logging)==null?void 0:Bt.logger),onColorsChanged:new m(()=>t.onColorsChanged,(Gt=t.logging)==null?void 0:Gt.logger),onParagraphStylesChanged:new m(()=>t.onParagraphStylesChanged,(wr=t.logging)==null?void 0:wr.logger),onCharacterStylesChanged:new m(()=>t.onCharacterStylesChanged,(fr=t.logging)==null?void 0:fr.logger),onFontFamiliesChanged:new m(()=>t.onFontFamiliesChanged,(Sr=t.logging)==null?void 0:Sr.logger),onSelectedLayoutIdChanged:new m(()=>t.onSelectedLayoutIdChanged,(br=t.logging)==null?void 0:br.logger),onLayoutsChanged:new m(()=>t.onLayoutsChanged,(Ir=t.logging)==null?void 0:Ir.logger),onConnectorEvent:new m(()=>t.onConnectorEvent,(vr=t.logging)==null?void 0:vr.logger),onConnectorsChanged:new m(()=>t.onConnectorsChanged,(Ar=t.logging)==null?void 0:Ar.logger),onZoomChanged:new m(()=>t.onZoomChanged,(Pr=t.logging)==null?void 0:Pr.logger),onSelectedPageIdChanged:new m(()=>t.onSelectedPageIdChanged,t.logging.logger),onPagesChanged:new m(()=>t.onPagesChanged,t.logging.logger),onPageSnapshotInvalidated:new m(()=>t.onPageSnapshotInvalidated,t.logging.logger),onPageSizeChanged:new m(()=>t.onPageSizeChanged,(Fr=t.logging)==null?void 0:Fr.logger),onShapeCornerRadiusChanged:new m(()=>t.onShapeCornerRadiusChanged,(Er=t.logging)==null?void 0:Er.logger),onCropActiveFrameIdChanged:new m(()=>t.onCropActiveFrameIdChanged,(Dr=t.logging)==null?void 0:Dr.logger),onAsyncError:new m(()=>t.onAsyncError,(Lr=t.logging)==null?void 0:Lr.logger),onViewModeChanged:new m(()=>t.onViewModeChanged,(Or=t.logging)==null?void 0:Or.logger),onBarcodeValidationChanged:new m(()=>t.onBarcodeValidationChanged,(Mr=t.logging)==null?void 0:Mr.logger),onDataSourceIdChanged:new m(()=>t.onDataSourceIdChanged,t.logging.logger),onDocumentIssueListChanged:new m(()=>t.onDocumentIssueListChanged,t.logging.logger),onCustomUndoDataChanged:new m(()=>t.onCustomUndoDataChanged,t.logging.logger),onEngineEditModeChanged:new m(()=>t.onEngineEditModeChanged,t.logging.logger),onBrandKitMediaChanged:new m(()=>t.onBrandKitMediaChanged,t.logging.logger)},t}static isLoggingEnabled(o,t){return t==T.info||t==T.warn&&(o==T.warn||o==T.error)?!0:t==T.error&&o==T.error}}class Mn{isDatePropertyWrapper(o){return typeof o=="object"&&(o==null?void 0:o.type)==="date"}isDateObject(o){return o instanceof Date}mapEngineToDataItem(o){const t={};return Object.entries(o).forEach(([e,r])=>{t[e]=this.isDatePropertyWrapper(r)?new Date(r.value):r}),t}mapDataItemToEngine(o){const t={};return Object.entries(o).forEach(([e,r])=>{t[e]=this.isDateObject(r)?{value:r.getTime(),type:"date"}:r}),t}}class Nn{constructor(o){g(this,gt);y(this,gt,o)}async getValue(o){return(await a(this,gt)).getConfigValue(o).then(e=>i(e))}async setValue(o,t){return(await a(this,gt)).setConfigValue(o,t).then(r=>i(r))}async updateStudioOptions(o){return(await a(this,gt)).updateStudioOptions(JSON.stringify(o)).then(e=>i(e))}async getEngineSessionId(){return(await a(this,gt)).getEngineSessionId().then(t=>i(t))}}gt=new WeakMap;class $s extends Nn{constructor(t,e){super(t);g(this,Tt);y(this,Tt,e)}async getValue(t){const e=a(this,Tt).get(t);return e!=null?i({status:200,success:!0,parsedData:e,data:e},!1):super.getValue(t)}async setValue(t,e){const r=super.setValue(t,e);return a(this,Tt).set(t,e),r}}Tt=new WeakMap;class zs{constructor(o){g(this,_);this.getAll=async()=>(await a(this,_)).getGradients().then(e=>i(e)),this.getById=async t=>(await a(this,_)).getGradientById(t).then(r=>i(r)),this.create=async()=>(await a(this,_)).createGradient().then(e=>i(e)),this.duplicate=async t=>(await a(this,_)).duplicateGradient(t).then(r=>i(r)),this.move=async(t,e)=>(await a(this,_)).moveGradients(t,e).then(n=>i(n)),this.rename=async(t,e)=>(await a(this,_)).renameGradient(t,e).then(n=>i(n)),this.update=async(t,e)=>{const r=await a(this,_),n=e;return r.updateGradient(t,JSON.stringify(n)).then(c=>i(c))},this.remove=async t=>(await a(this,_)).removeGradient(t).then(r=>i(r)),y(this,_,o)}}_=new WeakMap;const Rn=`https://studio-cdn.chiligrafx.com/editor/${R.current}/web`;let nt;class Vn{constructor(o){this.localConfig=new Map,this.dataItemMappingTools=new Mn,this.loadEditor=()=>{var t;an(this.config.editorLink||Rn,{onActionsChanged:this.subscriber.onActionsChanged,onStateChanged:this.subscriber.onStateChanged,onAuthExpired:this.subscriber.onAuthExpired,onViewportRequested:this.subscriber.onViewportRequested,onDocumentLoaded:this.subscriber.onDocumentLoaded,onSelectedFramesContentChanged:this.subscriber.onSelectedFramesContentChanged,onSelectedFramesLayoutChanged:this.subscriber.onSelectedFramesLayoutChanged,onFramesLayoutChanged:this.subscriber.onFramesLayoutChanged,onSelectedLayoutPropertiesChanged:this.subscriber.onSelectedLayoutPropertiesChanged,onSelectedLayoutUnitChanged:this.subscriber.onSelectedLayoutUnitChanged,onPageSelectionChanged:this.subscriber.onPageSelectionChanged,onScrubberPositionChanged:this.subscriber.onAnimationPlaybackChanged,onFrameAnimationsChanged:this.subscriber.onAnimationChanged,onVariableListChanged:e=>{var r;(r=this.enabledNextSubscribers)!=null&&r.onVariableListChanged?this.next.subscriber.onVariableListChanged(e):this.subscriber.onVariableListChanged(e)},onSelectedToolChanged:this.subscriber.onSelectedToolChanged,onUndoStateChanged:this.subscriber.onUndoStateChanged,onSelectedLayoutFramesChanged:this.subscriber.onSelectedLayoutFramesChanged,onSelectedTextStyleChanged:this.subscriber.onSelectedTextStyleChanged,onColorsChanged:this.subscriber.onColorsChanged,onParagraphStylesChanged:this.subscriber.onParagraphStylesChanged,onCharacterStylesChanged:this.subscriber.onCharacterStylesChanged,onFontFamiliesChanged:this.subscriber.onFontFamiliesChanged,onSelectedLayoutIdChanged:this.subscriber.onSelectedLayoutIdChanged,onLayoutsChanged:this.subscriber.onLayoutsChanged,onConnectorEvent:this.subscriber.onConnectorEvent,onConnectorsChanged:e=>{var r;(r=this.enabledNextSubscribers)!=null&&r.onConnectorsChanged?this.next.subscriber.onConnectorsChanged(e):this.subscriber.onConnectorsChanged(e)},onZoomChanged:this.subscriber.onZoomChanged,onSelectedPageIdChanged:this.subscriber.onSelectedPageIdChanged,onPagesChanged:this.subscriber.onPagesChanged,onPageSnapshotInvalidated:this.subscriber.onPageSnapshotInvalidated,onPageSizeChanged:e=>{var r;(r=this.enabledNextSubscribers)!=null&&r.onPageSizeChanged?this.next.subscriber.onPageSizeChanged(e):this.subscriber.onPageSizeChanged(e)},onShapeCornerRadiusChanged:this.subscriber.onShapeCornerRadiusChanged,onCropActiveFrameIdChanged:this.subscriber.onCropActiveFrameIdChanged,onAsyncError:this.subscriber.onAsyncError,onViewModeChanged:this.subscriber.onViewModeChanged,onBarcodeValidationChanged:this.subscriber.onBarcodeValidationChanged,onDataSourceIdChanged:this.subscriber.onDataSourceIdChanged,onDocumentIssueListChanged:this.subscriber.onDocumentIssueListChanged,onCustomUndoDataChanged:this.subscriber.onCustomUndoDataChanged,onEngineEditModeChanged:this.subscriber.onEngineEditModeChanged,onBrandKitMediaChanged:this.subscriber.onBrandKitMediaChanged},this.setConnection,this.config.editorId,this.config.studioStyling),this.editorAPI=nt==null?void 0:nt.promise.then(e=>e),this.action=new Ee(this.editorAPI),this.layout=new vs(this.editorAPI),this.frame=new bs(this.editorAPI),this.barcode=new Ve(this.editorAPI),this.animation=new De(this.editorAPI),this.document=new ns(this.editorAPI),this.configuration=new $s(this.editorAPI,this.localConfig),this.utils=new Us(this.editorAPI,this.localConfig),this.tool=new Js(this.editorAPI),this.page=new Ps(this.editorAPI),this.debug=new rs(this.editorAPI),this.undoManager=new ks(this.editorAPI,this),this.textSelection=new Vs(this.editorAPI),this.colorStyle=new xe(this.editorAPI),this.gradientStyle=new zs(this.editorAPI),this.paragraphStyle=new Fs(this.editorAPI),this.characterStyle=new ke(this.editorAPI),this.mediaConnector=new As(this.editorAPI),this.fontConnector=new fs(this.editorAPI),this.dataConnector=new es(this.editorAPI,this.dataItemMappingTools),this.dataSource=new ss(this.editorAPI,this.dataItemMappingTools),this.connector=new ts(this.editorAPI,this.localConfig),this.variable=new _s(this.editorAPI),this.font=new Ss(this.editorAPI),this.experiment=new ws(this.editorAPI),this.canvas=new le(this.editorAPI),this.shape=new ye(this.editorAPI),this.colorConversion=new _e(this.editorAPI),this.info=new Is,this.clipboard=new Ue(this.editorAPI),this.brandKit=new Je(this.editorAPI,this),this.next=new xs(this.config,this.connection,this.editorAPI),this.configuration.setValue(q.GraFxStudioSdkVersion,fe.version),this.configuration.setValue(q.GraFxStudioDocumentType,this.config.documentType||ce.template),this.configuration.updateStudioOptions(this.config.studioOptions||on),this.configuration.setValue(q.QueryCallCacheEnabled,((t=this.config.enableQueryCallCache)==null?void 0:t.toString())||"false")},this.setConnection=t=>{nt=t},this.config=Ce.createRuntimeConfig(o),this.connection=nt,this.editorAPI=nt==null?void 0:nt.promise.then(t=>t),this.action=new Ee(this.editorAPI),this.layout=new vs(this.editorAPI),this.frame=new bs(this.editorAPI),this.shape=new ye(this.editorAPI),this.barcode=new Ve(this.editorAPI),this.undoManager=new ks(this.editorAPI,this),this.connector=new ts(this.editorAPI,this.localConfig),this.mediaConnector=new As(this.editorAPI),this.fontConnector=new fs(this.editorAPI),this.dataConnector=new es(this.editorAPI,this.dataItemMappingTools),this.dataSource=new ss(this.editorAPI,this.dataItemMappingTools),this.animation=new De(this.editorAPI),this.document=new ns(this.editorAPI),this.configuration=new $s(this.editorAPI,this.localConfig),this.variable=new _s(this.editorAPI),this.utils=new Us(this.editorAPI,this.localConfig),this.subscriber=new bn(this.config,this.localConfig),this.tool=new Js(this.editorAPI),this.page=new Ps(this.editorAPI),this.debug=new rs(this.editorAPI),this.textSelection=new Vs(this.editorAPI),this.colorStyle=new xe(this.editorAPI),this.gradientStyle=new zs(this.editorAPI),this.paragraphStyle=new Fs(this.editorAPI),this.characterStyle=new ke(this.editorAPI),this.font=new Ss(this.editorAPI),this.experiment=new ws(this.editorAPI),this.canvas=new le(this.editorAPI),this.colorConversion=new _e(this.editorAPI),this.info=new Is,this.clipboard=new Ue(this.editorAPI),this.next=new xs(this.config,this.connection,this.editorAPI),this.enabledNextSubscribers=this.config.enableNextSubscribers,this.brandKit=new Je(this.editorAPI,this)}}var Ws=(s=>(s.top="top",s.left="left",s.right="right",s.bottom="bottom",s.topLeft="topLeft",s.topRight="topRight",s.bottomLeft="bottomLeft",s.bottomRight="bottomRight",s))(Ws||{}),js=(s=>(s.horizontal="horizontal",s.vertical="vertical",s))(js||{}),qs=(s=>(s.easeIn="easeIn",s.easeOut="easeOut",s.easeInOut="easeInOut",s))(qs||{}),Ys=(s=>(s.quadratic="Quadratic",s.cubic="Cubic",s.quartic="Quartic",s.quintic="Quintic",s.sine="Sine",s.exponential="Exponential",s.circular="Circular",s.elastic="Elastic",s.bounce="Bounce",s.back="Back",s))(Ys||{}),Zs=(s=>(s.bounce="bounce",s.flash="flash",s.headshake="headShake",s.heartbeat="heartbeat",s.pulse="pulse",s.rubberBand="rubberBand",s.vertical="vertical",s.horizontal="horizontal",s.swing="swing",s.tada="tada",s))(Zs||{}),Qs=(s=>(s.preview="preview",s.normal="normal",s))(Qs||{}),Xs=(s=>(s.linear="linear",s))(Xs||{}),tr=(s=>(s.local="linearLocal",s.linearBrandKit="linearBrandKit",s))(tr||{}),er=(s=>(s.Square="square",s.Line="line",s))(er||{}),sr=(s=>(s.BOLD="Bold",s.ITALIC="Italic",s.REGULAR="Regular",s))(sr||{}),rr=(s=>(s.LEFT="left",s.CENTER="center",s.RIGHT="right",s.JUSTIFY="justify",s))(rr||{}),nr=(s=>(s.TOP="top",s.CENTER="center",s.BOTTOM="bottom",s))(nr||{}),ar=(s=>(s.TO_LOWER_CASE="lowercase",s.TO_UPPER_CASE="uppercase",s.NORMAL="normal",s))(ar||{}),ir=(s=>(s.SUPERSCRIPT="superscript",s.SUBSCRIPT="subscript",s.NORMAL="normal",s))(ir||{}),or=(s=>(s.none="none",s.bullet="bullet",s.number="number",s))(or||{}),cr=(s=>(s.STYLE="textStyle",s.PROPERTIES="textProperties",s.APPEARANCE="appearance",s))(cr||{}),hr=(s=>(s.PARAGRAPH="paragraphStyleId",s.CHARACTER="characterStyleId",s.FONT_FAMILY="fontKey",s.FONT_STYLE="fontStyle",s.FONT_SIZE="fontSize",s.LETTER_SPACING="letterSpacing",s.LINE_HEIGHT="lineHeight",s.TEXT_ALIGN="textAlign",s.VERTICAL_ALIGN="verticalAlign",s.TYPOGRAPHIC_CASE="typographicCase",s.SUB_SUPER_SCRIPT="subSuperScript",s.UNDERLINE="underline",s.LINE_THROUGH="lineThrough",s.FILL_COLOR="fillColor",s.COLOR="color",s.FILL_COLOR_APPLIED="fillColorApplied",s.STROKE_COLOR="strokeColor",s.STROKE_COLOR_APPLIED="strokeColorApplied",s.DROP_SHADOW_COLOR="dropShadowColor",s.BLEND_MODE="blendMode",s.OPACITY="opacity",s.TRACKING_RIGHT="trackingRight",s.BASELINE_SHIFT="baselineShiftValue",s.STROKE_WIDTH="strokeWidth",s.MARKED_LIST_TYPE="markedListType",s.MARKED_LIST_GROUP="markedListGroup",s.MARKED_LIST_LEVEL="markedListLevel",s))(hr||{}),lr=(s=>(s.selectedLayoutChanged="selectedLayoutChanged",s.frameMoved="frameMoved",s.pageSizeChanged="pageSizeChanged",s.documentLoaded="documentLoaded",s.variableValueChanged="variableValueChanged",s))(lr||{}),dr=(s=>(s.ellipse="ellipse",s.rectangle="rectangle",s.polygon="polygon",s))(dr||{}),ur=(s=>(s.all="all",s.only="only",s.none="none",s))(ur||{}),gr=(s=>(s.normal="normal",s.textEdit="textEdit",s.customCrop="customCrop",s.frameSubjectArea="frameSubjectArea",s.perAssetCrop="perAssetCrop",s.gradient="gradient",s))(gr||{}),yr=(s=>(s.url="url",s.grafx="grafx",s.local="local",s))(yr||{});const Tn=Object.freeze(Object.defineProperty({__proto__:null,ConnectorRegistrationSource:yr},Symbol.toStringTag,{value:"Module"}));h.ActionAsyncError=Ds,h.ActionEditorEvent=lr,h.Alignment=rr,h.AnchorTargetEdgeType=ms,h.AnchorTargetType=Cs,h.AuthCredentialsTypeEnum=Ze,h.AuthRefreshTypeEnum=Qe,h.AutoGrowDirection=as,h.BarcodeCharacterSet=pt,h.BarcodeErrorCorrectionLevel=It,h.BarcodeSourceTypeEnum=os,h.BarcodeType=H,h.BarcodeValidationResult=Le,h.BasicAnimationsEmphasisStyles=Zs,h.BlendMode=ds,h.Case=ar,h.ColorType=Z,h.ColorUsageType=Qt,h.ConnectorConfigContextType=We,h.ConnectorConfigValueType=ze,h.ConnectorEventType=Ye,h.ConnectorHttpError=Fe,h.ConnectorMapping=yn,h.ConnectorMappingDirection=qe,h.ConnectorMappingSource=je,h.ConnectorRegistrationSource=Pt,h.ConnectorStateType=ee,h.ConnectorType=He,h.ConstraintMode=Re,h.CornerRadiusType=ur,h.CropType=ge,h.DataRowAsyncError=Ls,h.Day=Os,h.DeprecatedMediaConnectorDownloadType=te,h.DeprecatedMediaType=vt,h.DocumentIssueTypeEnum=Ae,h.DocumentType=ce,h.DownloadFormats=Gs,h.EaseTypes=qs,h.EngineEditModeType=gr,h.EnvironmentType=ne,h.FitMode=us,h.FitModePosition=gs,h.FlowDirection=hs,h.FontPreviewFormat=er,h.FontWeights=sr,h.FrameAnchorTarget=Sn,h.FrameAnchorType=ps,h.FramePropertyNames=Ts,h.FrameTypeEnum=is,h.GradientType=Xs,h.GradientUsageType=tr,h.GrafxTokenAuthCredentials=Cn,h.ImageSourceTypeEnum=kt,h.LayoutIntent=Ne,h.LayoutPropertyNames=Bs,h.LayoutType=Oe,h.Locale=Ms,h.MarkedListType=or,h.MeasurementUnit=Me,h.MediaDownloadIntent=pe,h.MediaDownloadType=se,h.MediaType=At,h.Next=Tn,h.PageAnchorTarget=fn,h.PositionEnum=Y,h.RefreshedAuthCredendentials=mn,h.Scripting=ir,h.SelectedTextStyleSections=cr,h.SelectedTextStyles=hr,h.ShakeDirections=js,h.ShapeType=dr,h.SlideDirections=Ws,h.SortBy=Ke,h.SortOrder=$e,h.TextDirection=cs,h.TextPosition=nr,h.ToolType=$,h.TweenTypes=Ys,h.UpdateZIndexMethod=ys,h.UploadAssetValidationError=Xe,h.UploadAssetValidationErrorType=de,h.VariableType=re,h.VariableVisibilityOperator=Rs,h.VariableVisibilityTargetType=Ns,h.VariableVisibilityType=Ft,h.VerticalAlign=ls,h.ViewMode=Qs,h.WellKnownConfigurationKeys=q,h.default=Vn,h.grafxMediaConnectorRegistration=pn,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
20
+ `;s.srcdoc=n},hn=(s,o,t,e="chili-editor",r)=>{const n=`#${e}`,c=document.createElement("iframe");c.setAttribute("srcdoc"," "),c.setAttribute("title","Chili-Editor"),c.setAttribute("style","width: 100%; height: 100%;"),c.setAttribute("frameBorder","0"),c.setAttribute("referrerpolicy","origin");const u=()=>{const l=document.querySelector(n);l&&(l==null||l.appendChild(c),cn(c,s,r))};document.readyState==="complete"||document.readyState==="interactive"?u():document.addEventListener("DOMContentLoaded",()=>{u()}),t(an({iframe:c,methods:{actionsChanged:o.onActionsChanged,stateChanged:o.onStateChanged,documentLoaded:o.onDocumentLoaded,authExpired:o.onAuthExpired,viewportRequested:o.onViewportRequested,selectedFramesContent:o.onSelectedFramesContentChanged,selectedFramesLayout:o.onSelectedFramesLayoutChanged,allFramesLayout:o.onFramesLayoutChanged,selectedLayoutProperties:o.onSelectedLayoutPropertiesChanged,openLayoutPropertiesPanel:o.onPageSelectionChanged,selectedLayoutUnit:o.onSelectedLayoutUnitChanged,scrubberPositionChanged:o.onScrubberPositionChanged,frameAnimationsChanged:o.onFrameAnimationsChanged,selectedToolChanged:o.onSelectedToolChanged,variableListChanged:o.onVariableListChanged,undoStackStateChanged:o.onUndoStateChanged,selectedLayoutFramesChanged:o.onSelectedLayoutFramesChanged,selectedTextStyleChanged:o.onSelectedTextStyleChanged,colorsChanged:o.onColorsChanged,paragraphStylesChanged:o.onParagraphStylesChanged,characterStylesChanged:o.onCharacterStylesChanged,fontFamiliesChanged:o.onFontFamiliesChanged,selectedLayoutId:o.onSelectedLayoutIdChanged,layoutListChanged:o.onLayoutsChanged,connectorEvent:o.onConnectorEvent,connectorsChanged:o.onConnectorsChanged,zoomChanged:o.onZoomChanged,pageSnapshotInvalidated:o.onPageSnapshotInvalidated,pagesChanged:o.onPagesChanged,pageSizeChanged:o.onPageSizeChanged,shapeCornerRadiusChanged:o.onShapeCornerRadiusChanged,cropActiveFrameIdChanged:o.onCropActiveFrameIdChanged,asyncError:o.onAsyncError,viewModeChanged:o.onViewModeChanged,barcodeValidationChanged:o.onBarcodeValidationChanged,selectedPageIdChanged:o.onSelectedPageIdChanged,dataSourceIdChanged:o.onDataSourceIdChanged,documentIssueListChanged:o.onDocumentIssueListChanged,customUndoDataChanged:o.onCustomUndoDataChanged,engineEditingModeChanged:o.onEngineEditModeChanged,brandKitMediaChanged:o.onBrandKitMediaChanged}}))};var q=(s=>(s.GraFxStudioEnvironmentApiUrl="ENVIRONMENT_API",s.GraFxStudioSdkVersion="SDK_VERSION",s.GraFxStudioDocumentType="DOCUMENT_TYPE",s.GraFxStudioTemplateId="TEMPLATE_ID",s.GraFxStudioAuthToken="GRAFX_AUTH_TOKEN",s.QueryCallCacheEnabled="ENABLE_QUERY_CALL_CACHE",s))(q||{});const ln={shortcutOptions:{debugPanel:{enabled:!1},ellipse:{enabled:!1},hand:{enabled:!1},image:{enabled:!1},polygon:{enabled:!1},rectangle:{enabled:!1},select:{enabled:!1},text:{enabled:!1},zoom:{enabled:!1},copyPaste:{enabled:!1},viewMode:{enabled:!1}},frameEditingMode:0};var Pe=(s=>(s.overflow="overflow",s.fontLoading="fontLoading",s.actionRegister="actionRegister",s.actionExecution="actionExecution",s.actionCircular="actionCircular",s))(Pe||{}),he=(s=>(s.project="project",s.template="template",s.component="component",s))(he||{});const dn=404075;function Fe(s){const o=s.error??"Yikes, something went wrong",t={cause:{name:String(s.status),message:s.error??"Yikes, something went wrong"}};if(s.status===dn){const r=JSON.parse(s.data).statusCode;throw new Ee(r,o,t)}else throw new Error(o,t)}function i(s,o=!0){try{s.success||Fe(s);const t=s.data&&o;return{...s,parsedData:t?JSON.parse(s.data):s.data}}catch(t){throw console.error(t),t}}class Ee extends Error{constructor(o,t,e){super(t,e),this.statusCode=o}}class De{constructor(o){g(this,V);this.getAll=async()=>(await a(this,V)).getActions().then(e=>i(e)),this.getById=async t=>(await a(this,V)).getActionById(t).then(r=>i(r)),this.create=async()=>(await a(this,V)).createAction().then(e=>i(e)),this.duplicate=async t=>(await a(this,V)).duplicateAction(t).then(r=>i(r)),this.remove=async t=>(await a(this,V)).removeAction(t).then(r=>i(r)),this.update=async(t,e)=>(await a(this,V)).updateAction(t,JSON.stringify(e)).then(n=>i(n)),this.rename=async(t,e)=>this.update(t,{name:e}),this.updateScript=async(t,e)=>this.update(t,{script:e}),this.updateTriggers=async(t,e)=>this.update(t,{triggers:e}),this.move=async(t,e)=>(await a(this,V)).moveActions(t,e).then(n=>i(n)),this.setTypeError=async(t,e)=>this.update(t,{hasTypeError:e}),this.disable=async()=>(await a(this,V)).disableActions().then(e=>i(e)),this.enable=async()=>(await a(this,V)).enableActions().then(e=>i(e)),y(this,V,o)}}V=new WeakMap;class Oe{constructor(o){g(this,M);this.getAllOnSelectedLayout=async()=>(await a(this,M)).getAnimationsOnSelectedLayout().then(e=>i(e)),this.getByFrameId=async(t,e)=>(await a(this,M)).getAnimationByFrameId(t,e).then(n=>i(n)),this.getByLayoutId=async t=>(await a(this,M)).getAnimationsByLayoutId(t).then(r=>i(r)),this.setFrameAnimation=async t=>(await a(this,M)).setFrameAnimation(JSON.stringify(t)).then(r=>i({...r,data:JSON.stringify(t)})),this.play=async()=>(await a(this,M)).playAnimation().then(e=>i(e)),this.pause=async()=>(await a(this,M)).pauseAnimation().then(e=>i(e)),this.setScrubberPosition=async t=>(await a(this,M)).setScrubberPosition(t).then(r=>i(r)),this.setDuration=async t=>(await a(this,M)).setAnimationDuration(t).then(r=>i(r)),this.resetFrameAnimation=async t=>(await a(this,M)).resetFrameAnimation(t).then(r=>i(r)),this.reset=async()=>(await a(this,M)).resetAnimation().then(e=>i(e)),y(this,M,o)}}M=new WeakMap;var H=(s=>(s.code39="code39",s.code93="code93",s.code128="code128",s.dataMatrix="dataMatrix",s.ean13="ean13",s.ean8="ean8",s.qr="qr",s.upca="upca",s.upce="upce",s.gs1128="gs1128",s))(H||{}),It=(s=>(s.low="low",s.medium="medium",s.quartile="quartile",s.high="high",s))(It||{}),Ct=(s=>(s.utf8="utf8",s.iso8859_1="iso8859_1",s.code128a="code128a",s.code128b="code128b",s.code128c="code128c",s))(Ct||{}),Le=(s=>(s.success="success",s.empty="empty",s.invalidLength="invalidLength",s.invalidCharacters="invalidCharacters",s.invalidChecksum="invalidChecksum",s.invalidUPCE="invalidUPCE",s.otherError="otherError",s))(Le||{}),Y=(s=>(s.top="top",s.right="right",s.bottom="bottom",s.left="left",s))(Y||{}),Me=(s=>(s.top="top",s.child="child",s))(Me||{}),Ne=(s=>(s.px="px",s.mm="mm",s.cm="cm",s.inch="inch",s.pt="pt",s))(Ne||{}),Re=(s=>(s.print="print",s.digitalStatic="digitalStatic",s.digitalAnimated="digitalAnimated",s))(Re||{}),Ve=(s=>(s.locked="locked",s.range="range",s.none="none",s))(Ve||{});class Te{constructor(o){g(this,z);this.setBarcodeProperties=async(t,e)=>(await a(this,z)).setBarcodeProperties(t,JSON.stringify(e)).then(n=>i(n)),this.setEnableBackground=async(t,e)=>{const r={enableBackground:e};return this.setBarcodeProperties(t,r)},this.setBackgroundColor=async(t,e)=>{const r={backgroundColor:e};return this.setBarcodeProperties(t,r)},this.setEnableBars=async(t,e)=>{const r={enableBars:e};return this.setBarcodeProperties(t,r)},this.setBarColor=async(t,e)=>{const r={barColor:e};return this.setBarcodeProperties(t,r)},this.setBarcodeSource=async(t,e)=>(await a(this,z)).setBarcodeSource(t,JSON.stringify(e)).then(n=>i(n)),this.removeBarcodeSource=async t=>(await a(this,z)).setBarcodeSource(t,null).then(r=>i(r)),this.setEnableText=async(t,e)=>{const r={enableText:e};return this.setBarcodeProperties(t,r)},this.setBarHeight=async(t,e)=>{const r={barHeight:e};return this.setBarcodeProperties(t,r)},this.setMagnification=async(t,e)=>{const r={magnification:e};return this.setBarcodeProperties(t,r)},this.setQuietZoneValue=async(t,e,r)=>{const n=r?{left:r===Y.left?e:void 0,top:r===Y.top?e:void 0,right:r===Y.right?e:void 0,bottom:r===Y.bottom?e:void 0}:{left:e,top:e,right:e,bottom:e};return(await a(this,z)).setBarcodeProperties(t,JSON.stringify({quietZone:n})).then(u=>i(u))},this.setAreQuietZoneValuesCombined=async(t,e)=>{const r={areQuietZoneValuesCombined:e};return(await a(this,z)).setBarcodeProperties(t,JSON.stringify({quietZone:r})).then(c=>i(c))},this.setErrorCorrectionLevel=async(t,e)=>(await a(this,z)).setBarcodeProperties(t,JSON.stringify({errorCorrectionLevel:e})).then(n=>i(n)),this.setCharacterSet=async(t,e)=>(await a(this,z)).setBarcodeProperties(t,JSON.stringify({characterSet:e})).then(n=>i(n)),this.setDrawLightMarginIndicator=async(t,e)=>{const r={drawStartStopChars:e};return this.setBarcodeProperties(t,r)},this.setDrawStartStopChars=async(t,e)=>{const r={drawStartStopChars:e};return this.setBarcodeProperties(t,r)},this.getBarcodeConfigationOptions=t=>{let e=!0,r=!0,n=!0,c,u,l=!1,C=!1,p=!1;switch(t){case H.qr:c=[Ct.iso8859_1,Ct.utf8],u=[It.low,It.medium,It.quartile,It.high];case H.dataMatrix:e=!1,r=!1,n=!1,l=!0;break;case H.ean13:e=!1,C=!0;break;case H.ean8:C=!0;case H.upca:case H.upce:e=!1;break;case H.code128:case H.gs1128:c=[Ct.code128a,Ct.code128b,Ct.code128c];break;case H.code39:p=!0;break}return{allowEnableMagnification:n,allowBarHeight:r,allowQuietZone:!0,allowedCharacterSets:c,allowedErrorCorrectionLevels:u,allowToggleText:e,quietZoneAlwaysCombined:l,allowToggleLightMarginIndicator:C,allowToggleDrawStartAndEndChar:p}},y(this,z,o)}}z=new WeakMap;var K=(s=>(s.rgb="rgb",s.hex="hex",s.cmyk="cmyk",s.spotCmyk="spotCmyk",s.spotRgb="spotRgb",s.spotHex="spotHex",s))(K||{}),Z=(s=>(s.rgb="rgb",s.hex="hex",s.cmyk="cmyk",s.gray="gray",s.hsl="hsl",s.spot="spot",s.spotCMYK="spotCMYK",s.spotRGB="spotRGB",s.spotHEX="spotHEX",s))(Z||{}),Xt=(s=>(s.local="local",s.brandKit="brandKit",s.stylekit="brandKit",s))(Xt||{});const Be=s=>s.type===K.hex,le=s=>s.type===K.spotHex,un=s=>s.type===K.spotRgb,gn=s=>s.type===K.spotCmyk,yn=s=>un(s)||gn(s)||le(s),pn=s=>{const o=Cn(s.type);return yn(s)?{...le(s)&&{value:s.displayValue},...!le(s)&&{...s.displayValue},spotName:s.value,type:o}:{...Be(s)&&{value:s.value},...!Be(s)&&{...s.value},type:o}},Ge=(s,o,t,e)=>{const{brandKitColorGuid:r,brandKitFontFamilyGuid:n,fontStyleId:c,textStrokeColorGuid:u,textStrokeColorApplied:l,textStrokeWidth:C,...p}=s;return{...Object.keys(p).reduce((b,v)=>({...b,[v]:{value:s[v]}}),{}),...o&&{color:{value:{id:o.id,color:o.color,type:Xt.brandKit,isApplied:p.fillColorApplied}}},...t&&{strokeColor:{value:{id:t.id,color:t.color,type:Xt.brandKit,isApplied:l||!1}},strokeColorApplied:{value:l||!1},strokeWidth:{value:C!=null?C.toString():C}},fontKey:{value:e??null}}},Cn=s=>{switch(s){case K.rgb:return Z.rgb;case K.cmyk:return Z.cmyk;case K.hex:return Z.hex;case K.spotRgb:return Z.spotRGB;case K.spotCmyk:return Z.spotCMYK;case K.spotHex:return Z.spotHEX}},te=(s,o)=>{if(!(s===null||o===void 0))return(s||[]).find(t=>t.id===o)},Je=(s,o,t)=>{var e,r;if(!(s===null||o===void 0||t===void 0))return(r=(e=(s||[]).find(n=>n.id===o))==null?void 0:e.fontStyles.find(n=>n.fontStyleId===t))==null?void 0:r.id};class Ue{constructor(o,t){g(this,N);this.getId=async()=>(await a(this,N)).getBrandKitId().then(r=>i(r)),this.getVersion=async()=>(await a(this,N)).getBrandKitVersion().then(r=>i(r)),this.getName=async()=>(await a(this,N)).getBrandKitName().then(r=>i(r)),this.rename=async e=>(await a(this,N)).renameBrandKit(e).then(n=>i(n)),this.updateIdAndVersion=async(e,r)=>(await a(this,N)).updateBrandKitIdAndVersion(e,r).then(c=>i(c)),this.get=async()=>{const e=await this.getId(),r=await this.getVersion(),n=await this.getName(),c=this.colorStyleController.getAll(),u=this.gradientStyleController.getAll(),l=this.fontController.getFontFamilies(),C=this.characterStyleController.getAll(),p=this.paragraphStyleController.getAll(),I=this.getAllMedia(),[b,v,P,A,S,x]=await Promise.all([c,u,l,p,C,I]),L={id:e.parsedData,brandKit:{id:e.parsedData,name:n.parsedData,lastModifiedDate:r.parsedData,colors:b.parsedData,gradients:v.parsedData,fonts:P.parsedData,paragraphStyles:A.parsedData,characterStyles:S.parsedData,media:x.parsedData}},F={success:!0,data:JSON.stringify(L),parsedData:L,status:200};return i(F)},this.getAllMedia=async()=>(await a(this,N)).getAllBrandKitMedia().then(r=>i(r)),this.addMedia=async(e,r,n)=>(await a(this,N)).addBrandKitMedia(e,r,n).then(u=>i(u)),this.updateMedia=async(e,r,n)=>(await a(this,N)).updateBrandKitMedia(e,r,n).then(u=>i(u)),this.renameMedia=async(e,r)=>(await a(this,N)).renameBrandKitMedia(e,r).then(c=>i(c)),this.removeMedia=async e=>(await a(this,N)).removeBrandKitMedia(e).then(n=>i(n)),this.remove=async()=>{const r=(await this.colorStyleController.getAll()).parsedData||[],c=(await this.gradientStyleController.getAll()).parsedData||[],l=(await this.paragraphStyleController.getAll()).parsedData||[],p=(await this.characterStyleController.getAll()).parsedData||[],b=(await this.fontController.getFontFamilies()).parsedData||[],P=(await this.getAllMedia()).parsedData||[];await this.undoManagerController.record("brandKit.remove",async A=>{for(const S of r)await A.colorStyle.remove(S.id);for(const S of c)await A.gradientStyle.remove(S.id);for(const S of l)await A.paragraphStyle.remove(S.id);for(const S of p)await A.characterStyle.remove(S.id);for(const S of b)await A.font.removeFontFamily(S.id);for(const S of P)await this.removeMedia(S.name)})},this.set=async e=>{let r={success:!0,status:200,parsedData:{id:e.id,version:e.brandKit.lastModifiedDate,name:e.brandKit.name,colors:[],gradients:[],fonts:[],paragraphStyles:[],characterStyles:[],media:[]}};return await this.undoManagerController.record("brandKit.set",async n=>{const c=await this.setColors(e,n);await this.setGradients(e,n);const u=await this.setFonts(e,n),{parsedData:l=[]}=await n.colorStyle.getAll(),{parsedData:C=[]}=await n.gradientStyle.getAll(),{parsedData:p}=await n.font.getFontFamilies();await this.setParagraphStyles(e,n,{localColors:l,localFonts:p,localColorGuidMap:c,localFontGuidMap:u}),await this.setCharacterStyles(e,n,{localColors:l,localFonts:p,localColorGuidMap:c,localFontGuidMap:u}),await this.setMedia(e);const{parsedData:I}=await n.paragraphStyle.getAll(),{parsedData:b}=await n.characterStyle.getAll(),{parsedData:v}=await this.getAllMedia();await n.brandKit.updateIdAndVersion(e.id,e.brandKit.lastModifiedDate),await n.brandKit.rename(e.brandKit.name),r={success:!0,status:200,parsedData:{id:e.id,version:e.brandKit.lastModifiedDate,name:e.brandKit.name,colors:l||[],gradients:C||[],fonts:p||[],paragraphStyles:I||[],characterStyles:b||[],media:v||[]}}}),r},y(this,N,o),this.colorStyleController=t.colorStyle,this.gradientStyleController=t.gradientStyle,this.fontController=t.font,this.mediaController=t.mediaConnector,this.paragraphStyleController=t.paragraphStyle,this.characterStyleController=t.characterStyle,this.undoManagerController=t.undoManager}async setColors(o,t){const e=new Map;for(const r of o.brandKit.colors||[]){const{parsedData:n}=await t.colorStyle.create();if(!n)continue;e.set(r.guid,n);const c=pn(r);await t.colorStyle.rename(n,r.name),await t.colorStyle.update(n,c)}return e}async setGradients(o,t){return new Map}async setFonts(o,t){const e=o.fontConnectorId,r=new Map;for(const n of o.brandKit.fonts||[]){const{parsedData:c=[]}=await t.fontConnector.detail(e,n.fontFamilyId);if(!(c!=null&&c[0]))throw new Error(`No font styles for family ID: ${n.fontFamilyId}`);const{parsedData:u}=await t.font.addFontFamily(e,{name:c[0].familyName,fontFamilyId:n.fontFamilyId});u&&r.set(n.fontFamilyBrandKitGuid,u)}return r}async setParagraphStyles(o,t,e){const{localColors:r,localFonts:n,localColorGuidMap:c,localFontGuidMap:u}=e;for(const l of o.brandKit.paragraphStyles||[]){const C=c.get(l.brandKitColorGuid),p=c.get(l.textStrokeColorGuid),I=u.get(l.brandKitFontFamilyGuid),b=Je(n,I,l.fontStyleId);if(!I||!b)throw new Error(`Paragraph style could not be created with an empty font family: ${l.name}`);const v=te(r,C),P=te(r,p);if(!v)throw new Error(`Paragraph style could not be created with an empty color: ${l.name}`);const{parsedData:A}=await t.paragraphStyle.create(),S=Ge(l,v,P,`${b}`);await t.paragraphStyle.rename(A,l.name),await t.paragraphStyle.update(A,S)}}async setCharacterStyles(o,t,e){const{localColors:r,localFonts:n,localColorGuidMap:c,localFontGuidMap:u}=e;for(const l of o.brandKit.characterStyles||[]){const C=l.brandKitColorGuid?c.get(l.brandKitColorGuid):void 0,p=l.textStrokeColorGuid?c.get(l.textStrokeColorGuid):void 0,I=l.brandKitFontFamilyGuid?u.get(l.brandKitFontFamilyGuid):void 0,b=te(r,C),v=te(r,p),P=Je(n,I,l.fontStyleId),{parsedData:A}=await t.characterStyle.create(),S=Ge(l,b,v,P);await t.characterStyle.rename(A,l.name),await t.characterStyle.update(A,S)}}async setMedia(o){for(const t of o.brandKit.media||[])await this.addMedia(t.name,t.mediaConnectorId,t.mediaId)}}N=new WeakMap;class de{constructor(o){g(this,it);this.zoomToPage=async(t,e,r,n,c)=>(t!==void 0&&console.warn("id has no effect and will be deprecated in the future"),(await a(this,it)).zoomToPage(e,r,n,c).then(l=>i(l))),this.getZoomPercentage=async()=>(await a(this,it)).getZoomPercentage().then(e=>i(e)),this.setZoomPercentage=async t=>(await a(this,it)).setZoomPercentage(t).then(r=>i(r)),this.setViewMode=async t=>(await a(this,it)).setViewMode(t).then(r=>i(r)),y(this,it,o)}}it=new WeakMap;class ke{constructor(o){g(this,B);this.getAll=async()=>(await a(this,B)).getCharacterStyles().then(e=>i(e)),this.getById=async t=>(await a(this,B)).getCharacterStyleById(t).then(r=>i(r)),this.create=async()=>(await a(this,B)).createCharacterStyle().then(e=>i(e)),this.update=async(t,e)=>(await a(this,B)).updateCharacterStyle(t,JSON.stringify(e)).then(n=>i(n)),this.remove=async t=>(await a(this,B)).removeCharacterStyle(t).then(r=>i(r)),this.duplicate=async t=>(await a(this,B)).duplicateCharacterStyle(t).then(r=>i(r)),this.rename=async(t,e)=>(await a(this,B)).renameCharacterStyle(t,e).then(n=>i(n)),this.move=async(t,e)=>(await a(this,B)).moveCharacterStyles(t,e).then(n=>i(n)),y(this,B,o)}}B=new WeakMap;class _e{constructor(o){g(this,ot);this.copyFrames=async t=>{const r=await(await a(this,ot)).copyFrames(t);return r.data&&await navigator.clipboard.writeText(r.data),i(r)},this.cutFrames=async t=>{const r=await(await a(this,ot)).cutFrames(t);return r.data&&await navigator.clipboard.writeText(r.data),i(r)},this.pasteFrames=async()=>{const t=await a(this,ot),e=await navigator.clipboard.readText(),r=await t.pasteFrames(e);return i(r)},this.getContentType=async()=>{const t=await a(this,ot),e=await navigator.clipboard.readText(),r=await t.getClipboardContentType(e);return i(r)},y(this,ot,o)}}ot=new WeakMap;class xe{constructor(o){g(this,xt);this.convertToRgb=async t=>(await a(this,xt)).colorToRgb(JSON.stringify(t)).then(r=>i(r)),y(this,xt,o)}}xt=new WeakMap;class He{constructor(o){g(this,G);this.getAll=async()=>(await a(this,G)).getColors().then(e=>i(e)),this.getById=async t=>(await a(this,G)).getColorById(t).then(r=>i(r)),this.create=async()=>(await a(this,G)).createColor().then(e=>i(e)),this.duplicate=async t=>(await a(this,G)).duplicateColor(t).then(r=>i(r)),this.move=async(t,e)=>(await a(this,G)).moveColors(t,e).then(n=>i(n)),this.rename=async(t,e)=>(await a(this,G)).renameColor(t,e).then(n=>i(n)),this.update=async(t,e)=>{const r=await a(this,G),n=e;return n.type===Z.spot&&(n.type=Z.spotCMYK),r.updateColor(t,JSON.stringify(n)).then(c=>i(c))},this.remove=async t=>(await a(this,G)).removeColor(t).then(r=>i(r)),y(this,G,o)}}G=new WeakMap;var At=(s=>(s[s.file=0]="file",s[s.collection=1]="collection",s))(At||{}),ee=(s=>(s.LowResolutionWeb="lowresWeb",s.HighResolutionWeb="highresWeb",s))(ee||{}),Pt=(s=>(s.file="file",s.collection="collection",s))(Pt||{}),Ke=(s=>(s.media="media",s.fonts="fonts",s.data="data",s))(Ke||{}),$e=(s=>(s.name="name",s.path="relativePath",s.id="id",s))($e||{}),ze=(s=>(s.ascending="asc",s.descending="desc",s))(ze||{}),We=(s=>(s.text="text",s.boolean="boolean",s))(We||{}),je=(s=>(s.query="query",s.upload="upload",s))(je||{}),Ft=(s=>(s.url="url",s.grafx="grafx",s.local="local",s))(Ft||{});class mn{constructor(o,t,e,r="engineToConnector"){this.direction="engineToConnector",this.name=o,this.direction=r,t==="var"?this.value=`${t}.${e}`:this.value=e}}var qe=(s=>(s.variable="var",s.value="value",s))(qe||{}),Ye=(s=>(s.engineToConnector="engineToConnector",s.connectorToEngine="connectorToEngine",s))(Ye||{}),se=(s=>(s.loading="loading",s.loaded="loaded",s.running="running",s.ready="ready",s.error="error",s))(se||{}),Ze=(s=>(s.stateChanged="stateChanged",s.authChanged="authChanged",s.reloadRequired="reloadRequired",s.unloaded="unloaded",s))(Ze||{});const wn={url:"grafx-media.json",source:"local"};class fn{constructor(o){this.type="grafxToken",this.token=o}}class Sn{constructor(){this.type="refreshed"}}var Qe=(s=>(s.grafxToken="grafxToken",s.refreshed="refreshed",s))(Qe||{}),Xe=(s=>(s.grafxToken="grafxToken",s.any="any",s))(Xe||{}),ue=(s=>(s.minDimension="minDimension",s))(ue||{});class ts extends Error{constructor(o,t){super(o),this.type=t}}class ge{constructor(){this.makeConnectorSourceForwardsCompatible=o=>{if(o.source!=Ft.grafx||this.isSourceMigrated(o))return o;let t=o.url;for(;t.endsWith("/");)t=t.substring(0,t.length-1);const e=t.split("/");return{id:e[e.length-1],source:Ft.grafx}},this.makeMultipleConnectorsBackwardsCompatible=(o,t)=>o.map(e=>this.makeSingleConnectorBackwardsCompatible(e,t)),this.makeSingleConnectorBackwardsCompatible=(o,t)=>o.source.source!=Ft.grafx?o:{id:o.id,name:o.name,iconUrl:o.iconUrl,source:this.makeConnectorSourceBackwardsCompatible(o.source,t)},this.makeConnectorSourceBackwardsCompatible=(o,t)=>{let e=t;for(;e!=null&&e.endsWith("/");)e=e.substring(0,e.length-1);return{url:`${e}/connectors/${o.id}`,source:Ft.grafx}},this.isSourceMigrated=o=>"id"in o}}let es=(wr=class{constructor(o,t){g(this,J);g(this,Dt);g(this,mt);this.getById=async e=>(await a(this,J)).getConnectorById(e).then(n=>i(n)).then(n=>{const c={...n,parsedData:null};return n.parsedData&&(c.parsedData=a(this,mt).makeSingleConnectorBackwardsCompatible(n.parsedData,a(this,Dt).get(q.GraFxStudioEnvironmentApiUrl))),c}),this.getAllByType=async e=>(await a(this,J)).getConnectors(e).then(n=>i(n)).then(n=>{const c={...n,parsedData:null};return n.parsedData&&(c.parsedData=a(this,mt).makeMultipleConnectorsBackwardsCompatible(n.parsedData,a(this,Dt).get(q.GraFxStudioEnvironmentApiUrl))),c}),this.register=async e=>{const r=await a(this,J),n=a(this,mt).makeConnectorSourceForwardsCompatible(e);return r.registerConnector(JSON.stringify(n)).then(c=>i(c))},this.unregister=async e=>(await a(this,J)).unregisterConnector(e).then(n=>i(n)),this.configure=async(e,r)=>{const n=await a(this,J);return await this.waitToBeReady(e),await r(new bn(e,n)),n.updateConnectorConfiguration(e).then(c=>i(c))},this.getState=async e=>(await a(this,J)).getConnectorState(e).then(n=>i(n)),this.getOptions=async e=>(await a(this,J)).getConnectorOptions(e).then(n=>i(n)),this.waitToBeReady=async(e,r=2e3)=>{let n=Math.max(r,500);n=Math.min(n,5e3);const c=100;let u=0;try{for(;u*c<n;){const l=await this.getState(e);if(l.success&&l.parsedData&&(l.parsedData.type===se.running||l.parsedData.type===se.ready))return i({data:null,success:!0,error:void 0,status:0,parsedData:void 0},!1);await new Promise(C=>setTimeout(C,c)),u++}}catch(l){return i({data:null,success:!1,error:`Error while getting connector state ${l}`,status:5e4,parsedData:void 0},!1)}return i({data:null,success:!1,error:"Timed out waiting for connector",status:5e4,parsedData:void 0},!1)},this.updateMappings=async(e,r)=>await this.configure(e,async n=>{const{parsedData:c}=await this.getMappings(e),u=(c==null?void 0:c.filter(p=>!r.some(I=>I.name===p.name&&I.direction===p.direction)))??[],l=r.filter(p=>p.name!==""&&p.value!==""),C=[...u,...l];await n.setMappings(C)}),y(this,J,o),y(this,Dt,t),y(this,mt,new ge)}async getMappings(o,t){return(await a(this,J)).getConnectorMappings(o).then(r=>i(r)).then(r=>{var n;return t?{...r,parsedData:(n=r.parsedData)==null?void 0:n.filter(c=>c.direction===t)}:r})}},J=new WeakMap,Dt=new WeakMap,mt=new WeakMap,wr);class bn{constructor(o,t){g(this,wt);g(this,ft);this.setOptions=async e=>a(this,ft).setConnectorOptions(a(this,wt),JSON.stringify(e)).then(r=>i(r)),this.setMappings=async e=>{const r=await a(this,ft).setConnectorMappings(a(this,wt),e.map(function(n){return JSON.stringify(n)}));return i(r)},this.setHttpHeader=async(e,r)=>a(this,ft).connectorAuthenticationSetHttpHeader(a(this,wt),e,r).then(n=>i(n)),y(this,wt,o),y(this,ft,t)}}wt=new WeakMap,ft=new WeakMap;class ss{constructor(o,t){g(this,ct);g(this,Ht);this.getPage=async(e,r,n={})=>(await a(this,ct)).dataConnectorGetPage(e,JSON.stringify(r),JSON.stringify(n)).then(u=>i(u)).then(u=>{const l={...u,parsedData:null};return u.parsedData&&(l.parsedData={data:u.parsedData.data.map(C=>a(this,Ht).mapEngineToDataItem(C)),continuationToken:u.parsedData.continuationToken}),l}),this.getModel=async(e,r={})=>(await a(this,ct)).dataConnectorGetModel(e,JSON.stringify(r)).then(c=>i(c)),this.getConfigurationOptions=async e=>(await a(this,ct)).dataConnectorGetConfigurationOptions(e).then(n=>i(n)),this.getCapabilities=async e=>(await a(this,ct)).dataConnectorGetCapabilities(e).then(n=>i(n)),y(this,ct,o),y(this,Ht,t)}}ct=new WeakMap,Ht=new WeakMap;class rs{constructor(o,t){g(this,ht);g(this,Kt);this.setDataSource=async e=>(await a(this,ht)).setDataSource(e).then(n=>i(n)),this.getDataSource=async()=>(await a(this,ht)).getDataSource().then(r=>i(r)),this.removeDataSource=async()=>(await a(this,ht)).removeDataSource().then(r=>i(r)),this.setDataRow=async e=>{const r=await a(this,ht),n=a(this,Kt).mapDataItemToEngine(e);return r.setDataRow(JSON.stringify(n)).then(c=>i(c))},y(this,ht,o),y(this,Kt,t)}}ht=new WeakMap,Kt=new WeakMap;class ns{constructor(o){g(this,lt);this.getAllLogs=async()=>(await a(this,lt)).getLogs().then(e=>i(e)),this.toggleDebugPanel=async()=>(await a(this,lt)).toggleDebugPanel().then(e=>i(e)),this.enableDebug=async()=>(await a(this,lt)).enableDebug().then(e=>i(e)),this.disableDebug=async()=>(await a(this,lt)).disableDebug().then(e=>i(e)),y(this,lt,o)}}lt=new WeakMap;class as{constructor(o){g(this,St);this.getCurrentState=async()=>(await a(this,St)).getCurrentDocumentState().then(e=>i(e)),this.load=async(t,e={keepConnectors:!1})=>{const r=await a(this,St),n=typeof t!="string"?JSON.stringify(t):t;return r.loadDocument(n,JSON.stringify(e)).then(c=>i(c))},this.createAndLoad=async t=>{const e=await a(this,St),r=JSON.stringify(t);return e.createAndLoadDocument(r).then(n=>i(n))},y(this,St,o)}}St=new WeakMap;var is=(s=>(s.top="top",s.bottom="bottom",s.left="left",s.right="right",s))(is||{}),kt=(s=>(s.url="url",s.variable="variable",s.connector="connector",s.brandKitMedia="brandKitMedia",s))(kt||{}),os=(s=>(s.text="text",s.image="image",s.shape="shape",s.barcode="barcode",s))(os||{}),cs=(s=>(s.variable="variable",s.text="text",s))(cs||{}),hs=(s=>(s.leftToRight="leftToRight",s.rightToLeft="rightToLeft",s.weak="weak",s))(hs||{}),ls=(s=>(s.horizontal="horizontal",s.vertical="vertical",s.onPath="onPath",s))(ls||{}),ds=(s=>(s.top="top",s.bottom="bottom",s.middle="middle",s.justify="justify",s))(ds||{}),us=(s=>(s.normal="normal",s.screen="screen",s.overlay="overlay",s.darken="darken",s.lighten="lighten",s.colorDodge="colorDodge",s.colorBurn="colorBurn",s.hardLight="hardLight",s.softLight="softLight",s.difference="difference",s.exclusion="exclusion",s.multiply="multiply",s.hue="hue",s.saturation="saturation",s.color="color",s.luminosity="luminosity",s))(us||{}),gs=(s=>(s.fill="fill",s.fit="fit",s.smartCrop="smartCrop",s.manualCrop="manualCrop",s))(gs||{}),ys=(s=>(s.topLeft="topLeft",s.topCenter="topCenter",s.topRight="topRight",s.centerLeft="centerLeft",s.center="center",s.centerRight="centerRight",s.bottomLeft="bottomLeft",s.bottomCenter="bottomCenter",s.bottomRight="bottomRight",s))(ys||{}),ps=(s=>(s.bringToFront="bringToFront",s.sendToBack="sendToBack",s.bringForward="bringForward",s.sendBackward="sendBackward",s))(ps||{}),Cs=(s=>(s.relative="relative",s.start="start",s.end="end",s.startAndEnd="startAndEnd",s.center="center",s))(Cs||{}),ms=(s=>(s.page="page",s.frame="frame",s))(ms||{}),ws=(s=>(s.start="start",s.end="end",s.center="center",s))(ws||{});class vn{constructor(){this.type="page"}}class In{constructor(o,t){this.type="frame",this.frameId=o,this.edge=t}}var ye=(s=>(s.frameCrop="frameCrop",s.assetCrop="assetCrop",s))(ye||{});class fs{constructor(o){g(this,U);this.insertImageVariableToFrame=async(t,e)=>{const r=await a(this,U),n={id:e,type:kt.variable};return r.setImageSource(t,JSON.stringify(n)).then(c=>i(c))},this.insertTextVariable=async t=>(await a(this,U)).insertTextVariable(t).then(r=>i(r)),this.enterTextEditMode=async t=>(await a(this,U)).enterTextEditMode(t).then(r=>i(r)),this.exitTextEditMode=async()=>(await a(this,U)).exitTextEditMode().then(e=>i(e)),this.getText=async(t,e)=>(await a(this,U)).getTextByFrameId(t,e).then(n=>i(n)),this.setText=async(t,e)=>(await a(this,U)).setTextByFrameId(t,e).then(n=>i(n)),this.selectText=async(t,e,r)=>(await a(this,U)).selectTextById(t,e,r).then(c=>i(c)),this.addCustomUndoData=async(t,e,r)=>(await a(this,U)).setCustomUndoData(t,e,r??!1).then(c=>i(c)),y(this,U,o)}}U=new WeakMap;class Ss{constructor(o){g(this,dt);g(this,Ot);this.query=async(t,e,r={})=>(await a(this,dt)).fontConnectorQuery(t,JSON.stringify(e),JSON.stringify(r)).then(c=>i(c)),this.detail=async(t,e,r={})=>(await a(this,dt)).fontConnectorDetail(t,e,JSON.stringify(r)).then(c=>i(c)),this.download=async(t,e,r={})=>(await a(this,Ot)).fontConnectorDownload(t,e,JSON.stringify(r)).then(c=>c??c),this.preview=async(t,e,r,n={})=>(await a(this,Ot)).fontConnectorPreview(t,e,r,JSON.stringify(n)).then(u=>u??u),this.getConfigurationOptions=async t=>(await a(this,dt)).fontConnectorGetConfigurationOptions(t).then(r=>i(r)),this.getCapabilities=async t=>(await a(this,dt)).fontConnectorGetCapabilities(t).then(r=>i(r)),this.parseDeprecatedFontType=t=>{if(t===At.file)return Pt.file;if(t===At.collection)return Pt.collection},y(this,dt,o),y(this,Ot,o)}}dt=new WeakMap,Ot=new WeakMap;class bs{constructor(o){g(this,E);this.addFontFamily=async(t,e)=>(await a(this,E)).addFontFamily(t,JSON.stringify(e)).then(n=>i(n)),this.removeFontFamily=async t=>(await a(this,E)).removeFontFamily(t).then(r=>i(r)),this.addFontStyle=async(t,e)=>(await a(this,E)).addFontStyle(t,JSON.stringify(e)).then(n=>i(n)),this.removeFontStyle=async t=>(await a(this,E)).removeFontStyle(t).then(r=>i(r)),this.getFontFamilies=async()=>(await a(this,E)).getFontFamilies().then(e=>i(e)),this.getFontStyles=async t=>(await a(this,E)).getFontStyles(t).then(r=>i(r)),this.getFontFamilyById=async t=>(await a(this,E)).getFontFamilyById(t).then(r=>i(r)),this.getFontStyleById=async t=>(await a(this,E)).getFontStyleById(t).then(r=>i(r)),this.getDefaultFontStyle=async()=>(await a(this,E)).getDefaultFontStyle().then(e=>i(e)),this.getDefaultFontFamily=async()=>(await a(this,E)).getDefaultFontFamily().then(e=>i(e)),this.isFontFamilyUsed=async t=>(await a(this,E)).isFontFamilyUsed(t).then(r=>i(r)),this.isFontStyleUsed=async t=>(await a(this,E)).isFontStyleUsed(t).then(r=>i(r)),this.moveFontFamilies=async(t,e)=>(await a(this,E)).moveFontFamilies(t,e).then(n=>i(n)),this.getPreviewsOfCharacterStrings=async(t,e)=>(await a(this,E)).getPreviewsOfCharacterStrings(t,JSON.stringify(e)).then(n=>i(n)),y(this,E,o)}}E=new WeakMap;class pe{constructor(o){g(this,Lt);this.setShapeProperties=async(t,e)=>(await a(this,Lt)).setShapeProperties(t,JSON.stringify(e)).then(n=>i(n)),this.setEnableFill=async(t,e)=>{const r={enableFill:e};return this.setShapeProperties(t,r)},this.setFillColor=async(t,e)=>{const r={fillColor:e};return this.setShapeProperties(t,r)},this.setEnableStroke=async(t,e)=>{const r={enableStroke:e};return this.setShapeProperties(t,r)},this.setStrokeColor=async(t,e)=>{const r={strokeColor:e};return this.setShapeProperties(t,r)},this.setStrokeWeight=async(t,e)=>{const r={strokeWeight:e};return this.setShapeProperties(t,r)},this.setFlagAllCornersSame=async(t,e)=>{const r={allCornersSame:e};return this.setShapeProperties(t,r)},this.setShapeCorners=async(t,e)=>(await a(this,Lt)).setShapeCorners(t,JSON.stringify(e)).then(n=>i(n)),this.setRadiusAll=async(t,e)=>{const r={radiusAll:e};return this.setShapeCorners(t,r)},this.setRadiusTopLeft=async(t,e)=>{const r={topLeft:e};return this.setShapeCorners(t,r)},this.setRadiusBottomLeft=async(t,e)=>{const r={bottomLeft:e};return this.setShapeCorners(t,r)},this.setRadiusTopRight=async(t,e)=>{const r={topRight:e};return this.setShapeCorners(t,r)},this.setRadiusBottomRight=async(t,e)=>{const r={bottomRight:e};return this.setShapeCorners(t,r)},y(this,Lt,o)}}Lt=new WeakMap;class vs{constructor(o){g(this,d);this.getAll=async()=>(await a(this,d)).getFrames().then(e=>i(e)),this.getSelected=async()=>(await a(this,d)).getSelectedFrames().then(e=>i(e)),this.getAllByPageId=async t=>(await a(this,d)).getFramesByPageId(t).then(r=>i(r)),this.getByName=async t=>(await a(this,d)).getFrameByName(t).then(r=>i(r)),this.getById=async t=>(await a(this,d)).getFrameById(t).then(r=>i(r)),this.getPropertiesOnSelectedLayout=async()=>(await a(this,d)).getFramePropertiesOnSelectedLayout().then(e=>i(e)),this.getLayoutProperties=async(t,e)=>(await a(this,d)).getFramePropertiesByFrameId(t,e).then(n=>i(n)),this.getAllLayoutProperties=async t=>(await a(this,d)).getFramesProperties(t).then(r=>i(r)),this.resetTransformation=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.resetSize=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.select=async t=>(await a(this,d)).selectFrames([t]).then(r=>i(r)),this.selectMultiple=async t=>(await a(this,d)).selectFrames(t).then(r=>i(r)),this.deselectAll=async()=>(await a(this,d)).deselectFrames().then(e=>i(e)),this.reorderFrames=async(t,e)=>(await a(this,d)).reorderFrames(t,e).then(n=>i(n)),this.setZIndex=async(t,e)=>(await a(this,d)).setFrameZIndex(t,e).then(n=>i(n)),this.setHeight=async(t,e)=>(await a(this,d)).setFrameHeight(t,e).then(n=>i(n)),this.setRotation=async(t,e)=>(await a(this,d)).setFrameRotation(t,e).then(n=>i(n)),this.setWidth=async(t,e)=>(await a(this,d)).setFrameWidth(t,e).then(n=>i(n)),this.setX=async(t,e)=>(await a(this,d)).setFrameX(t,e).then(n=>i(n)),this.setY=async(t,e)=>(await a(this,d)).setFrameY(t,e).then(n=>i(n)),this.setOpacity=async(t,e)=>(await a(this,d)).setFrameOpacity(t,e).then(n=>i(n)),this.rename=async(t,e)=>(await a(this,d)).renameFrame(t,e).then(n=>i(n)),this.reset=async t=>(await a(this,d)).resetFrame(t).then(r=>i(r)),this.resetX=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.resetY=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.resetRotation=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.resetWidth=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.resetHeight=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.resetImageFrameFitMode=async t=>(await a(this,d)).resetImageFrameFitMode(t).then(r=>i(r)),this.setVisibility=async(t,e)=>(await a(this,d)).setFrameIsVisible(t,e).then(n=>i(n)),this.setIsVisible=async(t,e)=>(await a(this,d)).setFrameIsVisible(t,e).then(n=>i(n)),this.remove=async t=>(await a(this,d)).removeFrames([t]).then(r=>i(r)),this.removeFrames=async t=>(await a(this,d)).removeFrames(t).then(r=>i(r)),this.create=async(t,e,r,n,c)=>(await a(this,d)).addFrame(t,e,r,n,c).then(l=>i(l)),this.createShapeFrame=async(t,e,r,n,c)=>(await a(this,d)).addFrame(t,e,r,n,c).then(l=>i(l)),this.createBarcodeFrame=async(t,e)=>(await a(this,d)).addBarcodeFrame(t,e==null?void 0:e.x,e==null?void 0:e.y).then(n=>i(n)),this.duplicateFrames=async t=>(await a(this,d)).duplicateFrames(t).then(r=>i(r)),this.updateImageSource=async(t,e)=>{const r=await a(this,d),n=e!==null?JSON.stringify(e):null;return r.setImageSource(t,n).then(c=>i(c))},this.removeImageSource=async t=>this.updateImageSource(t,null),this.setImageFromConnector=async(t,e,r)=>{const n={id:e,assetId:r,type:kt.connector};return this.updateImageSource(t,n)},this.setImageFromUrl=async(t,e)=>{const r={url:e,type:kt.url};return this.updateImageSource(t,r)},this.setImageFrameFitMode=async(t,e)=>(await a(this,d)).setImageFrameFitMode(t,e).then(n=>i(n)),this.setImageFrameFitModePosition=async(t,e)=>(await a(this,d)).setImageFrameFitModePosition(t,e).then(n=>i(n)),this.setFrameConstrainProportions=async(t,e)=>(console.error("setFrameConstrainProportions is not supported anymore"),i({success:!1,status:0,error:"setFrameConstrainProportions is not supported anymore",parsedData:null})),this.setVerticalAlign=async(t,e)=>(await a(this,d)).setVerticalAlignment(t,e).then(n=>i(n)),this.setMinCopyfitting=async(t,e)=>(await a(this,d)).setMinCopyfitting(t,e).then(n=>i(n)),this.setMaxCopyfitting=async(t,e)=>(await a(this,d)).setMaxCopyfitting(t,e).then(n=>i(n)),this.setEnableCopyfitting=async(t,e)=>(await a(this,d)).setEnableCopyfitting(t,e).then(n=>i(n)),this.resetMinCopyfitting=async t=>(await a(this,d)).resetMinCopyfitting(t).then(r=>i(r)),this.resetMaxCopyfitting=async t=>(await a(this,d)).resetMaxCopyfitting(t).then(r=>i(r)),this.resetEnableCopyfitting=async t=>(await a(this,d)).resetEnableCopyfitting(t).then(r=>i(r)),this.setShapeFrameEnableFill=async(t,e)=>this.shapeController.setEnableFill(t,e),this.setShapeFrameFillColor=async(t,e)=>this.shapeController.setFillColor(t,e),this.setShapeFrameEnableStroke=async(t,e)=>this.shapeController.setEnableStroke(t,e),this.setShapeFrameStrokeColor=async(t,e)=>this.shapeController.setStrokeColor(t,e),this.setShapeFrameStrokeWeight=async(t,e)=>this.shapeController.setStrokeWeight(t,e),this.setBlendMode=async(t,e)=>(await a(this,d)).setFrameBlendMode(t,e).then(n=>i(n)),this.enterCropMode=async(t,e=ye.frameCrop)=>(await a(this,d)).enterCropMode(t,e).then(n=>i(n)),this.applyCropMode=async()=>(await a(this,d)).applyCropMode().then(e=>i(e)),this.exitCropMode=async()=>(await a(this,d)).cancelCropMode().then(e=>i(e)),this.enterSubjectMode=async t=>(await a(this,d)).enterSubjectMode(t).then(r=>i(r)),this.applySubjectMode=async()=>(await a(this,d)).applySubjectMode().then(e=>i(e)),this.exitSubjectMode=async()=>(await a(this,d)).cancelSubjectMode().then(e=>i(e)),this.enterGradientMode=async t=>(await a(this,d)).enterGradientMode(t).then(r=>i(r)),this.applyGradientMode=async()=>(await a(this,d)).applyGradientMode().then(e=>i(e)),this.cancelGradientMode=async()=>(await a(this,d)).cancelGradientMode().then(e=>i(e)),this.resetCropMode=async t=>(console.error("resetCropMode is not supported anymore"),i({success:!1,status:0,error:"resetCropMode is not supported anymore",parsedData:null})),this.setEnableAutoGrow=async(t,e)=>{const r={enabled:{value:e}};return(await a(this,d)).updateAutoGrowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setAutoGrowMinWidth=async(t,e)=>{const r={minWidth:{value:e}};return(await a(this,d)).updateAutoGrowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setAutoGrowMaxWidth=async(t,e)=>{const r={maxWidth:{value:e}};return(await a(this,d)).updateAutoGrowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setAutoGrowMinHeight=async(t,e)=>{const r={minHeight:{value:e}};return(await a(this,d)).updateAutoGrowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setAutoGrowMaxHeight=async(t,e)=>{const r={maxHeight:{value:e}};return(await a(this,d)).updateAutoGrowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setAutoGrowDirections=async(t,e)=>{const r={directions:{value:e}};return(await a(this,d)).updateAutoGrowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.resetAutoGrowSettingsEnabled=async t=>(console.error("resetAutoGrowSettingsEnabled is not supported anymore"),i({success:!1,status:0,error:"resetAutoGrowSettingsEnabled is not supported anymore",parsedData:null})),this.resetAutoGrowMinWidth=async t=>(console.error("resetAutoGrowMinWidth is not supported anymore"),i({success:!1,status:0,error:"resetAutoGrowMinWidth is not supported anymore",parsedData:null})),this.resetAutoGrowMaxWidth=async t=>(console.error("resetAutoGrowMaxWidth is not supported anymore"),i({success:!1,status:0,error:"resetAutoGrowMaxWidth is not supported anymore",parsedData:null})),this.resetAutoGrowMinHeight=async t=>(console.error("resetAutoGrowMinHeight is not supported anymore"),i({success:!1,status:0,error:"resetAutoGrowMinHeight is not supported anymore",parsedData:null})),this.resetAutoGrowMaxHeight=async t=>(console.error("resetAutoGrowMaxHeight is not supported anymore"),i({success:!1,status:0,error:"resetAutoGrowMaxHeight is not supported anymore",parsedData:null})),this.resetAutoGrowDirections=async t=>(console.error("resetAutoGrowDirections is not supported anymore"),i({success:!1,status:0,error:"resetAutoGrowDirections is not supported anymore",parsedData:null})),this.resetAutoGrow=async t=>(console.error("resetAutoGrow is not supported anymore"),i({success:!1,status:0,error:"resetAutoGrow is not supported anymore",parsedData:null})),this.setShadowEnabled=async(t,e)=>{const r={enabled:{value:e}};return(await a(this,d)).updateFrameShadowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setShadowDistance=async(t,e)=>{const r={distance:{value:e}};return(await a(this,d)).updateFrameShadowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setShadowAngleDegrees=async(t,e)=>{const r={angleDegrees:{value:e}};return(await a(this,d)).updateFrameShadowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setShadowBlurRadius=async(t,e)=>{const r={blurRadius:{value:e}};return(await a(this,d)).updateFrameShadowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setShadowColor=async(t,e)=>{const r={color:{value:e}};return(await a(this,d)).updateFrameShadowSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setAnchor=async(t,e,r,n,c)=>{const u={horizontal:e,type:r,target:n,endTarget:c};return(await a(this,d)).setAnchorProperties(t,JSON.stringify(u)).then(C=>i(C))},this.setVerticalAnchor=async(t,e,r,n)=>this.setAnchor(t,!1,e,r,n),this.setHorizontalAnchor=async(t,e,r,n)=>this.setAnchor(t,!0,e,r,n),this.resetAnchoring=async t=>(await a(this,d)).resetFrameTransformation(t).then(r=>i(r)),this.resetVisibility=async t=>(await a(this,d)).setFrameIsVisible(t,null).then(r=>i(r)),this.getConfiguration=async t=>(await a(this,d)).getFrameConfiguration(t).then(r=>i(r)),this.resetAssetCropOverride=async t=>(await a(this,d)).resetAssetCropOverride(t).then(r=>i(r)),this.resetAllAssetCropOverrides=async t=>(await a(this,d)).resetAllAssetCropOverrides(t).then(r=>i(r)),this.setGradientApplied=async(t,e)=>{const r={isApplied:e};return(await a(this,d)).updateFrameGradientSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setLocalGradient=async(t,e)=>{const r={gradient:e};return(await a(this,d)).updateFrameGradientSettings(t,JSON.stringify(r)).then(c=>i(c))},this.setBrandKitGradient=async(t,e)=>{const r={id:e};return(await a(this,d)).updateFrameGradientSettings(t,JSON.stringify(r)).then(c=>i(c))},y(this,d,o),this.shapeController=new pe(a(this,d)),this.constraints=new An(a(this,d))}}d=new WeakMap;class An{constructor(o){g(this,Q);this.get=async t=>(await a(this,Q)).getFrameConstraints(t).then(r=>i(r)),this.setSelectable=async(t,e)=>{const r={selectable:{value:e}};return(await a(this,Q)).updateFrameConstraints(t,JSON.stringify(r)).then(c=>i(c))},this.setHorizontalMovement=async(t,e)=>{const r={horizontalMovementAllowed:{value:e}};return(await a(this,Q)).updateFrameConstraints(t,JSON.stringify(r)).then(c=>i(c))},this.setVerticalMovement=async(t,e)=>{const r={verticalMovementAllowed:{value:e}};return(await a(this,Q)).updateFrameConstraints(t,JSON.stringify(r)).then(c=>i(c))},this.setRotation=async(t,e)=>{const r={rotationAllowed:{value:e}};return(await a(this,Q)).updateFrameConstraints(t,JSON.stringify(r)).then(c=>i(c))},this.setResize=async(t,e)=>{const r={resizeAllowed:{value:e}};return(await a(this,Q)).updateFrameConstraints(t,JSON.stringify(r)).then(c=>i(c))},y(this,Q,o)}}Q=new WeakMap;class Is{constructor(){this.currentEngineVersion=R.current,this.currentSDKVersion=Se.version}}class As{constructor(o){g(this,f);g(this,$t);this.getAll=async()=>(await a(this,f)).getLayouts().then(e=>i(e)),this.getById=async t=>(await a(this,f)).getLayoutById(t).then(r=>i(r)),this.getByName=async t=>(await a(this,f)).getLayoutByName(t).then(r=>i(r)),this.getSelected=async()=>(await a(this,f)).getSelectedLayout().then(e=>i(e)),this.remove=async t=>(await a(this,f)).removeLayout(t).then(r=>i(r)),this.create=async(t,e)=>{const r=await a(this,f);return e!=null&&e.length?r.addLayouts(t,JSON.stringify(e)).then(n=>i(n)):r.addLayout(t).then(n=>i(n))},this.rename=async(t,e)=>(await a(this,f)).renameLayout(t,e).then(n=>i(n)),this.select=async t=>(await a(this,f)).selectLayoutWithOptions(t,null).then(r=>i(r)),this.selectWithPageSize=async(t,e)=>{const r=await a(this,f),n={pageSize:e};return r.selectLayoutWithOptions(t,JSON.stringify(n)).then(c=>i(c))},this.duplicate=async t=>(await a(this,f)).duplicateLayout(t).then(r=>i(r)),this.reset=async t=>(await a(this,f)).resetLayout(t).then(r=>i(r)),this.setHeight=async(t,e)=>(await a(this,f)).setLayoutHeight(t,e).then(n=>i(n)),this.setWidth=async(t,e)=>(await a(this,f)).setLayoutWidth(t,e).then(n=>i(n)),this.setUnit=async(t,e)=>(await a(this,f)).setLayoutUnit(t,e).then(n=>i(n)),this.resetHeight=async t=>(await a(this,f)).resetLayoutHeight(t).then(r=>i(r)),this.resetWidth=async t=>(await a(this,f)).resetLayoutWidth(t).then(r=>i(r)),this.resetUnit=async t=>(await a(this,f)).resetLayoutUnit(t).then(r=>i(r)),this.getSelectedSnapshot=async()=>(await a(this,$t)).getPageSnapshot().then(e=>e??e),this.setIntent=async(t,e)=>(await a(this,f)).setLayoutIntent(t,e).then(n=>i(n)),this.resetIntent=async t=>(await a(this,f)).resetLayoutIntent(t).then(r=>i(r)),this.setFillColor=async(t,e)=>(await a(this,f)).setLayoutFillColor(t,JSON.stringify(e)).then(n=>i(n)),this.setFillColorEnabled=async(t,e)=>(await a(this,f)).setLayoutFillColorEnabled(t,e).then(n=>i(n)),this.resetFillColor=async t=>(await a(this,f)).resetLayoutFillColor(t).then(r=>i(r)),this.setBleedValue=async(t,e,r)=>{const n=r?{left:r===Y.left?e:void 0,top:r===Y.top?e:void 0,right:r===Y.right?e:void 0,bottom:r===Y.bottom?e:void 0}:{left:e,top:e,right:e,bottom:e};return(await a(this,f)).updateLayoutBleed(t,JSON.stringify(n)).then(u=>i(u))},this.setAreBleedValuesCombined=async(t,e)=>{const r={areBleedValuesCombined:e};return(await a(this,f)).updateLayoutBleed(t,JSON.stringify(r)).then(c=>i(c))},this.resetBleedValues=async t=>(await a(this,f)).updateLayoutBleed(t,null).then(r=>i(r)),this.setPrivateData=async(t,e)=>(await a(this,f)).setLayoutPrivateData(t,JSON.stringify(e)).then(n=>i(n)),this.getPrivateData=async t=>(await a(this,f)).getLayoutPrivateData(t).then(r=>i(r)),this.setDisplayName=async(t,e)=>(await a(this,f)).setLayoutDisplayName(t,e).then(n=>i(n)),this.getDisplayName=async t=>(await a(this,f)).getLayoutDisplayName(t).then(r=>i(r)),this.resetDisplayName=async t=>(await a(this,f)).setLayoutDisplayName(t,null).then(r=>i(r)),this.setAvailableForUser=async(t,e)=>(await a(this,f)).setLayoutAvailableForUser(t,e).then(n=>i(n)),this.setSelectedByUser=async(t,e)=>(await a(this,f)).setLayoutSelectedByUser(t,e).then(n=>i(n)),this.setResizableByUser=async(t,e)=>(await a(this,f)).setLayoutResizableByUser(t,JSON.stringify(e)).then(n=>i(n)),y(this,f,o),y(this,$t,o)}}f=new WeakMap,$t=new WeakMap;var re=(s=>(s.thumbnail="thumbnail",s.mediumres="mediumres",s.highres="highres",s.original="original",s))(re||{}),Ce=(s=>(s.web="web",s.print="print",s.animation="animation",s))(Ce||{});class Ps{constructor(o){g(this,X);g(this,zt);this.query=async(t,e,r={})=>(await a(this,X)).mediaConnectorQuery(t,JSON.stringify(e),JSON.stringify(r)).then(c=>i(c)),this.detail=async(t,e,r={})=>(await a(this,X)).mediaConnectorDetail(t,e,JSON.stringify(r)).then(c=>i(c)),this.download=async(t,e,r,n={})=>{const c=this.parseDeprecatedMediaDownloadType(r);return(await a(this,zt)).mediaConnectorDownload(t,e,c,Ce.web,JSON.stringify(n)).then(l=>{if(l instanceof Uint8Array)return l;throw typeof l=="object"&&l!==null&&"success"in l&&!l.success&&Fe(l),new Error(`Unexpected response type: ${typeof l}.`)})},this.getConfigurationOptions=async t=>(await a(this,X)).mediaConnectorGetConfigurationOptions(t).then(r=>i(r)),this.getCapabilities=async t=>(await a(this,X)).mediaConnectorGetCapabilities(t).then(r=>i(r)),this.parseDeprecatedMediaType=t=>{if(t===At.file)return Pt.file;if(t===At.collection)return Pt.collection},this.upload=async(t,e,r={})=>(await a(this,X)).mediaConnectorUpload(t,JSON.stringify(e),JSON.stringify(r)).then(c=>i(c)),y(this,X,o),y(this,zt,o)}parseDeprecatedMediaDownloadType(o){switch(o){case ee.HighResolutionWeb:return re.highres;case ee.LowResolutionWeb:return re.thumbnail;default:return o}}}X=new WeakMap,zt=new WeakMap;let Fs=(fr=class{constructor(o){g(this,O);g(this,Wt);this.add=async()=>(await a(this,O)).addPage().then(e=>i(e)),this.remove=async t=>(await a(this,O)).removePage(t).then(r=>i(r)),this.select=async t=>(await a(this,O)).selectPage(t).then(r=>i(r)),this.setVisibility=async(t,e)=>(await a(this,O)).setPageIsVisible(t,e).then(n=>i(n)),this.duplicate=async t=>(await a(this,O)).duplicatePage(t).then(r=>i(r)),this.getAll=async()=>(await a(this,O)).getPages().then(e=>i(e)),this.getById=async t=>(await a(this,O)).getPageById(t).then(r=>i(r)),this.getSnapshot=async(t,e)=>(await a(this,Wt)).getPageSnapshotWithSettings(t,e==null?null:JSON.stringify(e)).then(n=>n??n),this.setWidth=async(t,e)=>(t!==void 0&&console.warn("pageId has no effect since all pages are being updated simultaneously."),(await a(this,O)).setPageWidth(e).then(n=>i(n))),this.setHeight=async(t,e)=>(t!==void 0&&console.warn("pageId has no effect since all pages are being updated simultaneously."),(await a(this,O)).setPageHeight(e).then(n=>i(n))),this.setSize=async(t,e)=>(await a(this,O)).setPageSize(t,e).then(n=>i(n)),this.move=async(t,e)=>(await a(this,O)).reorderPages(t,e).then(n=>i(n)),y(this,O,o),y(this,Wt,o)}},O=new WeakMap,Wt=new WeakMap,fr);class Es{constructor(o){g(this,k);this.getAll=async()=>(await a(this,k)).getParagraphStyles().then(e=>i(e)),this.getById=async t=>(await a(this,k)).getParagraphStyleById(t).then(r=>i(r)),this.create=async()=>(await a(this,k)).createParagraphStyle().then(e=>i(e)),this.duplicate=async t=>(await a(this,k)).duplicateParagraphStyle(t).then(r=>i(r)),this.update=async(t,e)=>(await a(this,k)).updateParagraphStyle(t,JSON.stringify(e)).then(n=>i(n)),this.rename=async(t,e)=>(await a(this,k)).renameParagraphStyle(t,e).then(n=>i(n)),this.remove=async t=>(await a(this,k)).removeParagraphStyle(t).then(r=>i(r)),this.move=async(t,e)=>(await a(this,k)).moveParagraphStyles(t,e).then(n=>i(n)),y(this,k,o)}}k=new WeakMap;var T=(s=>(s.info="info",s.warn="warn",s.error="error",s))(T||{}),Ds=(s=>(s.general="general",s.connector="connector",s.event="event",s.engine="engine",s))(Ds||{}),_t=(s=>(s.throw="throw",s.log="log",s))(_t||{});class Os{constructor(o,t,e,r){this.type="action",this.message=o,this.id=t,this.event=e,this.eventChain=r}}class Ls{constructor(o,t,e){this.type="dataRow",this.count=o,this.message=t,this.exceptions=e}}var ne=(s=>(s.shortText="shortText",s.longText="longText",s.image="image",s.list="list",s.boolean="boolean",s.group="group",s.number="number",s.date="date",s))(ne||{}),Ms=(s=>(s.Monday="monday",s.Tuesday="tuesday",s.Wednesday="wednesday",s.Thursday="thursday",s.Friday="friday",s.Saturday="saturday",s.Sunday="sunday",s))(Ms||{}),Ns=(s=>(s.en_US="en_US",s.cs="cs",s.da="da",s.nl="nl",s.fi="fi",s.fr="fr",s.de="de",s.it="it",s.no="no",s.pl="pl",s.pt_PT="pt_PT",s.es_ES="es_ES",s.sv="sv",s))(Ns||{}),Et=(s=>(s.visible="visible",s.invisible="invisible",s.conditional="conditional",s))(Et||{}),Rs=(s=>(s.boolean="boolean",s.text="text",s.number="number",s))(Rs||{}),Vs=(s=>(s.equals="=",s.notEquals="!=",s.greaterThan=">",s.greaterThanOrEquals=">=",s.lessThan="<",s.lessThanOrEquals="<=",s))(Vs||{});let Pn=class{constructor(o,t){this.onActionsChanged=e=>{this.config.events.onActionsChanged.trigger(JSON.parse(e))},this.onAnimationChanged=e=>{this.config.events.onFrameAnimationsChanged.trigger(JSON.parse(e))},this.onAnimationPlaybackChanged=e=>{this.config.events.onScrubberPositionChanged.trigger(JSON.parse(e))},this.onSelectedLayoutPropertiesChanged=e=>{this.config.events.onSelectedLayoutPropertiesChanged.trigger(JSON.parse(e))},this.onSelectedLayoutUnitChanged=e=>{this.config.events.onSelectedLayoutUnitChanged.trigger(e)},this.onFramesLayoutChanged=e=>{const r=JSON.parse(e);this.config.events.onFramesLayoutChanged.trigger(r)},this.onSelectedFramesLayoutChanged=e=>{const r=JSON.parse(e);this.config.events.onSelectedFramesLayoutChanged.trigger(r);const n=this.config.onSelectedFrameLayoutChanged;n&&n(r.length>1?void 0:r[0])},this.onSelectedFramesContentChanged=e=>{const r=JSON.parse(e);this.config.events.onSelectedFramesContentChanged.trigger(r);const n=this.config.onSelectedFrameContentChanged;n&&n(r.length>1?null:r[0])},this.onStateChanged=()=>{this.config.events.onStateChanged.trigger()},this.onAuthExpired=async e=>{const r=await this.config.handlers.onAuthExpired.trigger(JSON.parse(e));return r!=null?JSON.stringify(r):null},this.onViewportRequested=()=>{const e=this.config.handlers.onViewportRequested.trigger();return e!=null?JSON.stringify(e):null},this.onDocumentLoaded=()=>{this.config.events.onDocumentLoaded.trigger()},this.onPageSelectionChanged=e=>{this.config.events.onPageSelectionChanged.trigger(e)},this.onVariableListChanged=e=>{const n=JSON.parse(e).map(c=>{var u;return c.type===ne.list?{...c,items:c.items.map(l=>l.value),selected:(u=c.selected)==null?void 0:u.value}:c});this.config.events.onVariableListChanged.trigger(n)},this.onSelectedToolChanged=e=>{this.config.events.onSelectedToolChanged.trigger(e)},this.onUndoStateChanged=e=>{this.config.events.onUndoStackStateChanged.trigger(JSON.parse(e))},this.onCustomUndoDataChanged=e=>{this.config.events.onCustomUndoDataChanged.trigger(JSON.parse(e))},this.onSelectedLayoutFramesChanged=e=>{this.config.events.onSelectedLayoutFramesChanged.trigger(JSON.parse(e))},this.onSelectedTextStyleChanged=e=>{this.config.events.onSelectedTextStyleChanged.trigger(JSON.parse(e))},this.onColorsChanged=e=>{this.config.events.onColorsChanged.trigger(JSON.parse(e))},this.onParagraphStylesChanged=e=>{this.config.events.onParagraphStylesChanged.trigger(JSON.parse(e))},this.onCharacterStylesChanged=e=>{this.config.events.onCharacterStylesChanged.trigger(JSON.parse(e))},this.onFontFamiliesChanged=e=>{this.config.events.onFontFamiliesChanged.trigger(JSON.parse(e))},this.onSelectedLayoutIdChanged=e=>{this.config.events.onSelectedLayoutIdChanged.trigger(e)},this.onLayoutsChanged=e=>{this.config.events.onLayoutsChanged.trigger(JSON.parse(e))},this.onZoomChanged=e=>{this.config.events.onZoomChanged.trigger(JSON.parse(e))},this.onConnectorEvent=e=>{this.config.events.onConnectorEvent.trigger(JSON.parse(e))},this.onConnectorsChanged=e=>{const n=new ge().makeMultipleConnectorsBackwardsCompatible(JSON.parse(e),this.localConfig.get(q.GraFxStudioEnvironmentApiUrl));this.config.events.onConnectorsChanged.trigger(n)},this.onSelectedPageIdChanged=e=>{this.config.events.onSelectedPageIdChanged.trigger(e)},this.onPagesChanged=e=>{this.config.events.onPagesChanged.trigger(JSON.parse(e))},this.onPageSnapshotInvalidated=e=>{this.config.events.onPageSnapshotInvalidated.trigger(e)},this.onPageSizeChanged=e=>{this.config.events.onPageSizeChanged.trigger(JSON.parse(e))},this.onShapeCornerRadiusChanged=e=>{this.config.events.onShapeCornerRadiusChanged.trigger(JSON.parse(e))},this.onCropActiveFrameIdChanged=e=>{this.config.events.onCropActiveFrameIdChanged.trigger(e)},this.onAsyncError=e=>{const r=JSON.parse(e);if((r==null?void 0:r.type)==="dataRow"){const n=new Ls(r.count,r.message,r.exceptions);this.config.events.onAsyncError.trigger(n)}else if((r==null?void 0:r.type)==="action"){const n=new Os(r.message,r.id,r.event,r.eventChain);this.config.events.onAsyncError.trigger(n)}else this.config.events.onAsyncError.trigger(r)},this.onViewModeChanged=e=>{this.config.events.onViewModeChanged.trigger(e)},this.onBarcodeValidationChanged=e=>{this.config.events.onBarcodeValidationChanged.trigger(JSON.parse(e))},this.onDataSourceIdChanged=e=>{this.config.events.onDataSourceIdChanged.trigger(e)},this.onDocumentIssueListChanged=e=>{this.config.events.onDocumentIssueListChanged.trigger(JSON.parse(e))},this.onEngineEditModeChanged=e=>{this.config.events.onEngineEditModeChanged.trigger(JSON.parse(e))},this.onBrandKitMediaChanged=e=>{this.config.events.onBrandKitMediaChanged.trigger(JSON.parse(e))},this.config=o,this.localConfig=t}};class Ts{constructor(o){g(this,bt);this.set=async t=>(await a(this,bt)).selectedTextStyleDeltaUpdate(JSON.stringify(t)).then(r=>i(r)),this.removeSelected=async()=>(await a(this,bt)).selectedTextStyleClean().then(e=>i(e)),this.getSelected=async()=>(await a(this,bt)).getSelectedTextStyle().then(e=>i(e)),y(this,bt,o)}}bt=new WeakMap;var Bs=(s=>(s.FRAME_X="frameX",s.FRAME_Y="frameY",s.WIDTH="width",s.HEIGHT="height",s.FRAME_ROTATION="frameRotation",s))(Bs||{}),Gs=(s=>(s.LAYOUT_HEIGHT="layoutHeight",s.LAYOUT_WIDTH="layoutWidth",s.BLEED_TOP="bleedTop",s.BLEED_BOTTOM="bleedBottom",s.BLEED_LEFT="bleedLeft",s.BLEED_RIGHT="bleedRight",s.BLEED_VALUES_COMBINED="areBleedValuesCombined",s))(Gs||{}),$=(s=>(s.SELECT="select",s.ZOOM="zoom",s.HAND="hand",s.IMAGE_FRAME="imageFrame",s.TEXT_FRAME="textFrame",s.SHAPE_RECT="rect",s.SHAPE_ELLIPSE="ellipse",s.SHAPE_POLYGON="polygon",s))($||{}),Js=(s=>(s.MP4="mp4",s.GIF="gif",s.PNG="png",s.JPG="jpg",s.PDF="pdf",s.HTML="html",s))(Js||{}),ae=(s=>(s.SANDBOX="sandbox",s.PRODUCTION="online",s))(ae||{});class Us{constructor(o){g(this,Mt);this.setTool=async t=>(await a(this,Mt)).setTool(t).then(r=>i(r)),this.getSelected=async()=>(await a(this,Mt)).getSelectedTool().then(e=>i(e)),this.setPointer=async()=>this.setTool($.SELECT),this.setSelect=async()=>this.setTool($.SELECT),this.setHand=async()=>this.setTool($.HAND),this.setZoom=async()=>this.setTool($.ZOOM),this.setTextFrame=async()=>this.setTool($.TEXT_FRAME),this.setImageFrame=async()=>this.setTool($.IMAGE_FRAME),this.setShapeRect=async()=>this.setTool($.SHAPE_RECT),this.setShapeEllipse=async()=>this.setTool($.SHAPE_ELLIPSE),this.setShapePolygon=async()=>this.setTool($.SHAPE_POLYGON),y(this,Mt,o)}}Mt=new WeakMap;class ks{constructor(o,t){g(this,tt);g(this,W);g(this,jt);this.undo=async()=>(await a(this,tt)).undo().then(r=>i(r)),this.redo=async()=>(await a(this,tt)).redo().then(r=>i(r)),this.addCustomData=async(e,r)=>(await a(this,tt)).setCustomUndoData(e,r,!1).then(c=>i(c)),this.record=async(e,r)=>{try{await a(this,W).beginIfNoneActive(e),await r(a(this,jt)),await a(this,W).end()}catch(n){throw await a(this,W).abort(),n}},this.pause=async()=>(await a(this,tt)).pause().then(r=>i(r)),this.resume=async()=>(await a(this,tt)).resume().then(r=>i(r)),this.advanced={begin:async e=>a(this,W).begin(e),beginIfNoneActive:async e=>a(this,W).beginIfNoneActive(e),end:async()=>a(this,W).end(),abort:async()=>a(this,W).abort()},y(this,tt,o),y(this,jt,t),y(this,W,new Fn(o))}}tt=new WeakMap,W=new WeakMap,jt=new WeakMap;class Fn{constructor(o){g(this,ut);this.begin=async t=>(await a(this,ut)).begin(t).then(r=>i(r)),this.beginIfNoneActive=async t=>(await a(this,ut)).beginIfNoneActive(t).then(r=>i(r)),this.end=async()=>(await a(this,ut)).end().then(e=>i(e)),this.abort=async()=>(await a(this,ut)).abort().then(e=>i(e)),y(this,ut,o)}}ut=new WeakMap;const En=(s,o=2)=>{const t=Math.pow(10,o);return Math.round(s*t)/t};class _s{constructor(o,t){g(this,qt);g(this,Nt);this.round=(e,r)=>i({data:String(En(e,r)),success:!0,status:200,parsedData:null}),this.createEnvironmentBaseURL=e=>{const{type:r=ae.SANDBOX,environment:n="ft-nostress",version:c="1"}=e,u=r==ae.SANDBOX?"chili-publish-sandbox":"chili-publish";return`https://${n}.${u}.online/grafx/api/v${c}/environment/${n}`},this.stageFiles=async(e,r,n)=>{const c=a(this,Nt).get(q.GraFxStudioEnvironmentApiUrl);if(!c)throw new Error("GraFx Studio Environment API URL is not set");const u=`${c}connectors/${r}/stage`,l=a(this,Nt).get(q.GraFxStudioAuthToken);if(!l)throw new Error("GraFx Studio Auth Token is not set");const C=new FormData;e.forEach((b,v)=>{const P=b instanceof File?b.name:`blob-${v}`;C.append("files",b,P)}),n&&C.append("validationJson",JSON.stringify({allowedMimeTypes:n.mimeTypes,minDimensions:{width:n.minWidthPixels,height:n.minHeightPixels}}));const p=await fetch(u,{method:"POST",body:C,headers:{Authorization:`Bearer ${l}`}});if(p.status===422){const b=await p.json();throw new ts(b.message,ue.minDimension)}if(!p.ok)throw new Error("Failed to stage files");return await p.json()},this.unitEvaluate=async(e,r)=>(await a(this,qt)).unitEvaluate(e,r).then(c=>i(c)),y(this,qt,o),y(this,Nt,t)}}qt=new WeakMap,Nt=new WeakMap;class Dn{constructor(o){g(this,Yt);this.setMinimum=async(t,e)=>{const r={minValue:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setMaximum=async(t,e)=>{const r={maxValue:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setShowStepper=async(t,e)=>{const r={showStepper:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setStepSize=async(t,e)=>{const r={stepSize:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setThousandsSeparator=async(t,e)=>{const r={thousandsSeparator:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setDecimalSeparator=async(t,e)=>{const r={decimalSeparator:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setDecimalCharacterStyle=async(t,e)=>{const r={decimalCharacterStyleId:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setNumberOfDecimals=async(t,e)=>{const r={numberOfDecimals:{value:e}};return this.applyPropertiesUpdate(t,r)},y(this,Yt,o)}async applyPropertiesUpdate(o,t){const r=await(await a(this,Yt)).updateNumberVariableProperties(o,JSON.stringify(t));return i(r)}}Yt=new WeakMap;class On{constructor(o){g(this,Zt);this.setDisplayFormat=async(t,e)=>{const r={displayFormat:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setLocale=async(t,e)=>{const r={locale:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setStartDate=async(t,e)=>{const r={startDate:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setEndDate=async(t,e)=>{const r={endDate:{value:e}};return this.applyPropertiesUpdate(t,r)},this.setExcludedDays=async(t,e)=>{const r={excludedDays:{value:e}};return this.applyPropertiesUpdate(t,r)},y(this,Zt,o)}async applyPropertiesUpdate(o,t){const r=await(await a(this,Zt)).updateDateVariableProperties(o,JSON.stringify(t));return i(r)}}Zt=new WeakMap;let xs=(Sr=class{constructor(o){g(this,w);g(this,Rt);g(this,Vt);this.getAll=async()=>(await a(this,w)).getVariables().then(e=>i(e)).then(e=>{const r=e;return r.parsedData&&(r.parsedData=this.makeVariablesBackwardsCompatible(r.parsedData)),r}),this.getById=async t=>(await a(this,w)).getVariableById(t).then(r=>i(r)).then(r=>{const n=r;return n.parsedData&&(n.parsedData=this.makeVariableBackwardsCompatible(n.parsedData)),n}),this.getByName=async t=>(await a(this,w)).getVariableByName(t).then(r=>i(r)).then(r=>{const n=r;return n.parsedData&&(n.parsedData=this.makeVariableBackwardsCompatible(n.parsedData)),n}),this.create=async(t,e)=>(await a(this,w)).addVariable(t,e).then(n=>i(n)),this.remove=async t=>(await a(this,w)).removeVariables(t).then(r=>i(r)),this.rename=async(t,e)=>(await a(this,w)).setVariableName(t,e).then(n=>i(n)),this.setLabel=async(t,e)=>(await a(this,w)).setVariableLabel(t,e).then(n=>i(n)),y(this,Rt,async(t,e)=>(await a(this,w)).setVariablePlaceholder(t,e).then(n=>i(n))),this.setPlaceholder=async(t,e)=>a(this,Rt).call(this,t,e),this.resetPlaceholder=async t=>a(this,Rt).call(this,t,null),y(this,Vt,async(t,e)=>(await a(this,w)).setVariableHelpText(t,e).then(n=>i(n))),this.setHelpText=async(t,e)=>a(this,Vt).call(this,t,e),this.resetHelpText=async t=>a(this,Vt).call(this,t,null),this.setType=async(t,e)=>(await a(this,w)).setVariableType(t,e).then(n=>i(n)),this.setListVariable=async(t,e)=>(await a(this,w)).setListVariableItems(t,e.map(n=>JSON.stringify({value:n}))).then(n=>i(n)),this.setValue=async(t,e)=>(await a(this,w)).setVariableValue(t,e).then(n=>i(n)),this.duplicate=async t=>(await a(this,w)).duplicateVariable(t).then(r=>i(r)),this.groupVariables=async(t,e)=>(await a(this,w)).groupVariables(t,e).then(n=>i(n)),this.ungroupVariables=async t=>(await a(this,w)).ungroupVariable(t).then(r=>i(r)),this.move=async(t,e,r)=>(await a(this,w)).moveVariable(e,r,t).then(c=>i(c)),this.moveVariables=async(t,e,r)=>(await a(this,w)).moveVariables(e,r,t).then(c=>i(c)),this.setIsVisible=async(t,e)=>{const r=e?{type:Et.visible}:{type:Et.invisible};return this.setVariableVisibility(t,r)},this.setIsHidden=async(t,e)=>{const r=e?{type:Et.invisible}:{type:Et.visible};return this.setVariableVisibility(t,r)},this.setVariableVisibility=async(t,e)=>(await a(this,w)).setVariableVisibility(t,JSON.stringify(e)).then(n=>i(n)),this.setLayoutsForVariableVisibility=async t=>(await a(this,w)).setLayoutsForVariableVisibility(t?JSON.stringify(t):null).then(r=>i(r)),this.setIsRequired=async(t,e)=>(await a(this,w)).setVariableIsRequired(t,e).then(n=>i(n)),this.setRemoveParagraphIfEmpty=async(t,e)=>(await a(this,w)).setVariableRemoveParagraphIfEmpty(t,e).then(n=>i(n)),this.setIsReadonly=async(t,e)=>(await a(this,w)).setVariableIsReadonly(t,e).then(n=>i(n)),this.getImageVariableConnectorId=async t=>(await a(this,w)).getImageVariableConnectorId(t).then(r=>i(r)),this.setImageVariableConnector=async(t,e)=>{const r=await a(this,w),c=new ge().makeConnectorSourceForwardsCompatible(e);return r.setImageVariableConnector(t,JSON.stringify(c)).then(u=>i(u))},this.setImageVariableValueWithContext=async(t,e,r)=>(await a(this,w)).setImageVariableValueWithContext(t,e,JSON.stringify(r)).then(c=>i(c)),this.removeSource=async t=>this.setValue(t,null),this.setPrefix=async(t,e)=>{const r={prefix:{value:e}};return this.applyPrefixSuffixDeltaUpdate(t,r)},this.setSuffix=async(t,e)=>{const r={suffix:{value:e}};return this.applyPrefixSuffixDeltaUpdate(t,r)},this.setPrefixCharacterStyle=async(t,e)=>{const r={prefixCharacterStyleId:{value:e}};return this.applyPrefixSuffixDeltaUpdate(t,r)},this.setSuffixCharacterStyle=async(t,e)=>{const r={suffixCharacterStyleId:{value:e}};return this.applyPrefixSuffixDeltaUpdate(t,r)},this.setPrivateData=async(t,e)=>(await a(this,w)).setVariablePrivateData(t,JSON.stringify(e)).then(n=>i(n)),this.getPrivateData=async t=>(await a(this,w)).getVariablePrivateData(t).then(r=>i(r)),this.setAllowImageQuery=async(t,e)=>(await a(this,w)).setImageVariableAllowQuery(t,e).then(n=>i(n)),this.setAllowImageUpload=async(t,e)=>(await a(this,w)).setImageVariableAllowUpload(t,e).then(n=>i(n)),this.setMinImageUploadSize=async(t,e,r)=>(await a(this,w)).setImageVariableUploadMinSize(t,e,r).then(c=>i(c)),this.setIsDontBreak=async(t,e)=>(await a(this,w)).setVariableIsDontBreak(t,e).then(n=>i(n)),y(this,w,o),this.number=new Dn(a(this,w)),this.date=new On(a(this,w))}makeVariablesBackwardsCompatible(o){return o.map(t=>this.makeVariableBackwardsCompatible(t))}makeVariableBackwardsCompatible(o){return o.type!==ne.list?o:this.makeListVariableBackwardsCompatible(o)}makeListVariableBackwardsCompatible(o){const t=o,e=o.items,r=o.selected,n=e.map(c=>c.value);return t.items=n,t.selected=r==null?void 0:r.value,t}async applyPrefixSuffixDeltaUpdate(o,t){const r=await(await a(this,w)).updateVariablePrefixSuffixProperties(o,JSON.stringify(t));return i(r)}},w=new WeakMap,Rt=new WeakMap,Vt=new WeakMap,Sr);class Ln{constructor(o){this.onVariableListChanged=t=>{this.config.events.onVariableListChanged.trigger(JSON.parse(t))},this.onConnectorsChanged=t=>{this.config.events.onConnectorsChanged.trigger(JSON.parse(t))},this.onPageSizeChanged=t=>{this.config.events.onPageSizeChanged.trigger(JSON.parse(t))},this.onEngineEditModeChanged=t=>{this.config.events.onEngineEditModeChanged.trigger(JSON.parse(t))},this.config=o}}class Mn{constructor(o){g(this,gt);this.getAll=async()=>(await a(this,gt)).getVariables().then(e=>i(e)),this.getById=async t=>(await a(this,gt)).getVariableById(t).then(r=>i(r)),this.getByName=async t=>(await a(this,gt)).getVariableByName(t).then(r=>i(r)),this.setListVariable=async(t,e)=>(await a(this,gt)).setListVariableItems(t,e.map(n=>JSON.stringify(n))).then(n=>i(n)),y(this,gt,o),this.image=new Nn(o)}}gt=new WeakMap;class Nn{constructor(o){g(this,et);this.setAllowQuery=async(t,e)=>(await a(this,et)).setImageVariableAllowQuery(t,e).then(n=>i(n)),this.setAllowUpload=async(t,e)=>(await a(this,et)).setImageVariableAllowUpload(t,e).then(n=>i(n)),this.setMinUploadSize=async(t,e,r)=>(await a(this,et)).setImageVariableUploadMinSize(t,e,r).then(c=>i(c)),this.setConnector=async(t,e)=>(await a(this,et)).setImageVariableConnector(t,JSON.stringify(e)).then(n=>i(n)),this.setConnectorContext=async(t,e)=>(await a(this,et)).setImageVariableConnectorContext(t,JSON.stringify(e)).then(n=>i(n)),y(this,et,o)}}et=new WeakMap;class Rn{constructor(o){g(this,vt);this.register=async t=>(await a(this,vt)).registerConnector(JSON.stringify(t)).then(r=>i(r)),this.getById=async t=>(await a(this,vt)).getConnectorById(t).then(r=>i(r)),this.getAllByType=async t=>(await a(this,vt)).getConnectors(t).then(r=>i(r)),y(this,vt,o)}}vt=new WeakMap;class Vn{constructor(o){g(this,Tt);g(this,ie);this.setWidth=async t=>(await a(this,Tt)).setPageWidth(t).then(r=>i(r)),this.setHeight=async t=>(await a(this,Tt)).setPageHeight(t).then(r=>i(r)),y(this,Tt,o),y(this,ie,o)}}Tt=new WeakMap,ie=new WeakMap;class Hs{constructor(o,t,e){this.config=o,this.connection=t,this.editorAPI=e,this.subscriber=new Ln(o),this.variable=new Mn(this.editorAPI),this.connector=new Rn(this.editorAPI),this.page=new Vn(this.editorAPI),this.canvas=new de(this.editorAPI)}}class Ks{constructor(o){this.logger=o}createEventHandlerFn(o,t){return(...r)=>{try{const n=o(...r);return n instanceof Promise?n.catch(c=>this.handleError(c,t,o.name)):n}catch(n){this.handleError(n,t,o.name)}}}handleError(o,t,e){var r;if(t===_t.log)(r=this.logger)==null||r.call(this,T.error,Ds.event,`Error in callback ${e}: ${o}`);else throw o}}class $s extends Ks{constructor(o,t){super(t),this.handler=o}trigger(...o){const t=this.handler();if(t)return this.createEventHandlerFn(t,_t.throw)(...o)}}class m extends Ks{constructor(o,t){super(t),this.legacyHandler=o,this.subscriptions=new Set}trigger(...o){const t=this.legacyHandler();t&&this.createEventHandlerFn(t,_t.log)(...o);for(const e of this.subscriptions)e(...o)}registerCallback(o,t=_t.log){const e=this.createEventHandlerFn(o,t);return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}}class me{static createRuntimeConfig(o){var e,r,n,c,u,l,C,p,I,b,v,P,A,S,x,L,F,st,rt,Gt,Jt,br,vr,Ir,Ar,Pr,Fr,Er,Dr,Or,Lr,Mr,Nr,Rr,Vr;const t={...o};return t.logging={logLevel:((e=o.logging)==null?void 0:e.logLevel)||T.error,logger:((r=o.logging)==null?void 0:r.logger)||((Qt,we,fe)=>{var Tr;if(me.isLoggingEnabled(Qt,((Tr=t.logging)==null?void 0:Tr.logLevel)??T.error))switch(Qt){case T.error:console.error(`[${we}] [${Qt}] ${fe}`);break;case T.warn:console.warn(`[${we}] [${Qt}] ${fe}`);break;default:console.log(`[${we}] [${Qt}] ${fe}`)}})},t.handlers={onAuthExpired:new $s(()=>t.onAuthExpired,(n=t.logging)==null?void 0:n.logger),onViewportRequested:new $s(()=>t.onViewportRequested,(c=t.logging)==null?void 0:c.logger)},t.events={onActionsChanged:new m(()=>t.onActionsChanged,(u=t.logging)==null?void 0:u.logger),onStateChanged:new m(()=>t.onStateChanged,(l=t.logging)==null?void 0:l.logger),onDocumentLoaded:new m(()=>t.onDocumentLoaded,(C=t.logging)==null?void 0:C.logger),onSelectedFramesLayoutChanged:new m(()=>t.onSelectedFramesLayoutChanged,(p=t.logging)==null?void 0:p.logger),onFramesLayoutChanged:new m(()=>t.onFramesLayoutChanged,(I=t.logging)==null?void 0:I.logger),onSelectedFramesContentChanged:new m(()=>t.onSelectedFramesContentChanged,(b=t.logging)==null?void 0:b.logger),onPageSelectionChanged:new m(()=>t.onPageSelectionChanged,(v=t.logging)==null?void 0:v.logger),onSelectedLayoutPropertiesChanged:new m(()=>t.onSelectedLayoutPropertiesChanged,(P=t.logging)==null?void 0:P.logger),onSelectedLayoutUnitChanged:new m(()=>t.onSelectedLayoutUnitChanged,(A=t.logging)==null?void 0:A.logger),onScrubberPositionChanged:new m(()=>t.onScrubberPositionChanged,(S=t.logging)==null?void 0:S.logger),onFrameAnimationsChanged:new m(()=>t.onFrameAnimationsChanged,(x=t.logging)==null?void 0:x.logger),onVariableListChanged:new m(()=>t.onVariableListChanged,(L=t.logging)==null?void 0:L.logger),onSelectedToolChanged:new m(()=>t.onSelectedToolChanged,(F=t.logging)==null?void 0:F.logger),onUndoStackStateChanged:new m(()=>t.onUndoStackStateChanged,(st=t.logging)==null?void 0:st.logger),onSelectedLayoutFramesChanged:new m(()=>t.onSelectedLayoutFramesChanged,(rt=t.logging)==null?void 0:rt.logger),onSelectedTextStyleChanged:new m(()=>t.onSelectedTextStyleChanged,(Gt=t.logging)==null?void 0:Gt.logger),onColorsChanged:new m(()=>t.onColorsChanged,(Jt=t.logging)==null?void 0:Jt.logger),onParagraphStylesChanged:new m(()=>t.onParagraphStylesChanged,(br=t.logging)==null?void 0:br.logger),onCharacterStylesChanged:new m(()=>t.onCharacterStylesChanged,(vr=t.logging)==null?void 0:vr.logger),onFontFamiliesChanged:new m(()=>t.onFontFamiliesChanged,(Ir=t.logging)==null?void 0:Ir.logger),onSelectedLayoutIdChanged:new m(()=>t.onSelectedLayoutIdChanged,(Ar=t.logging)==null?void 0:Ar.logger),onLayoutsChanged:new m(()=>t.onLayoutsChanged,(Pr=t.logging)==null?void 0:Pr.logger),onConnectorEvent:new m(()=>t.onConnectorEvent,(Fr=t.logging)==null?void 0:Fr.logger),onConnectorsChanged:new m(()=>t.onConnectorsChanged,(Er=t.logging)==null?void 0:Er.logger),onZoomChanged:new m(()=>t.onZoomChanged,(Dr=t.logging)==null?void 0:Dr.logger),onSelectedPageIdChanged:new m(()=>t.onSelectedPageIdChanged,t.logging.logger),onPagesChanged:new m(()=>t.onPagesChanged,t.logging.logger),onPageSnapshotInvalidated:new m(()=>t.onPageSnapshotInvalidated,t.logging.logger),onPageSizeChanged:new m(()=>t.onPageSizeChanged,(Or=t.logging)==null?void 0:Or.logger),onShapeCornerRadiusChanged:new m(()=>t.onShapeCornerRadiusChanged,(Lr=t.logging)==null?void 0:Lr.logger),onCropActiveFrameIdChanged:new m(()=>t.onCropActiveFrameIdChanged,(Mr=t.logging)==null?void 0:Mr.logger),onAsyncError:new m(()=>t.onAsyncError,(Nr=t.logging)==null?void 0:Nr.logger),onViewModeChanged:new m(()=>t.onViewModeChanged,(Rr=t.logging)==null?void 0:Rr.logger),onBarcodeValidationChanged:new m(()=>t.onBarcodeValidationChanged,(Vr=t.logging)==null?void 0:Vr.logger),onDataSourceIdChanged:new m(()=>t.onDataSourceIdChanged,t.logging.logger),onDocumentIssueListChanged:new m(()=>t.onDocumentIssueListChanged,t.logging.logger),onCustomUndoDataChanged:new m(()=>t.onCustomUndoDataChanged,t.logging.logger),onEngineEditModeChanged:new m(()=>t.onEngineEditModeChanged,t.logging.logger),onBrandKitMediaChanged:new m(()=>t.onBrandKitMediaChanged,t.logging.logger)},t}static isLoggingEnabled(o,t){return t==T.info||t==T.warn&&(o==T.warn||o==T.error)?!0:t==T.error&&o==T.error}}class Tn{isDatePropertyWrapper(o){return typeof o=="object"&&(o==null?void 0:o.type)==="date"}isDateObject(o){return o instanceof Date}mapEngineToDataItem(o){const t={};return Object.entries(o).forEach(([e,r])=>{t[e]=this.isDatePropertyWrapper(r)?new Date(r.value):r}),t}mapDataItemToEngine(o){const t={};return Object.entries(o).forEach(([e,r])=>{t[e]=this.isDateObject(r)?{value:r.getTime(),type:"date"}:r}),t}}class Bn{constructor(o){g(this,yt);y(this,yt,o)}async getValue(o){return(await a(this,yt)).getConfigValue(o).then(e=>i(e))}async setValue(o,t){return(await a(this,yt)).setConfigValue(o,t).then(r=>i(r))}async updateStudioOptions(o){return(await a(this,yt)).updateStudioOptions(JSON.stringify(o)).then(e=>i(e))}async getEngineSessionId(){return(await a(this,yt)).getEngineSessionId().then(t=>i(t))}}yt=new WeakMap;class zs extends Bn{constructor(t,e){super(t);g(this,Bt);y(this,Bt,e)}async getValue(t){const e=a(this,Bt).get(t);return e!=null?i({status:200,success:!0,parsedData:e,data:e},!1):super.getValue(t)}async setValue(t,e){const r=super.setValue(t,e);return a(this,Bt).set(t,e),r}}Bt=new WeakMap;class Ws{constructor(o){g(this,_);this.getAll=async()=>(await a(this,_)).getGradients().then(e=>i(e)),this.getById=async t=>(await a(this,_)).getGradientById(t).then(r=>i(r)),this.create=async()=>(await a(this,_)).createGradient().then(e=>i(e)),this.duplicate=async t=>(await a(this,_)).duplicateGradient(t).then(r=>i(r)),this.move=async(t,e)=>(await a(this,_)).moveGradients(t,e).then(n=>i(n)),this.rename=async(t,e)=>(await a(this,_)).renameGradient(t,e).then(n=>i(n)),this.update=async(t,e)=>{const r=await a(this,_),n=e;return r.updateGradient(t,JSON.stringify(n)).then(c=>i(c))},this.remove=async t=>(await a(this,_)).removeGradient(t).then(r=>i(r)),y(this,_,o)}}_=new WeakMap;const Gn=`https://studio-cdn.chiligrafx.com/editor/${R.current}/web`;let at;class Jn{constructor(o){this.localConfig=new Map,this.dataItemMappingTools=new Tn,this.loadEditor=()=>{var t;hn(this.config.editorLink||Gn,{onActionsChanged:this.subscriber.onActionsChanged,onStateChanged:this.subscriber.onStateChanged,onAuthExpired:this.subscriber.onAuthExpired,onViewportRequested:this.subscriber.onViewportRequested,onDocumentLoaded:this.subscriber.onDocumentLoaded,onSelectedFramesContentChanged:this.subscriber.onSelectedFramesContentChanged,onSelectedFramesLayoutChanged:this.subscriber.onSelectedFramesLayoutChanged,onFramesLayoutChanged:this.subscriber.onFramesLayoutChanged,onSelectedLayoutPropertiesChanged:this.subscriber.onSelectedLayoutPropertiesChanged,onSelectedLayoutUnitChanged:this.subscriber.onSelectedLayoutUnitChanged,onPageSelectionChanged:this.subscriber.onPageSelectionChanged,onScrubberPositionChanged:this.subscriber.onAnimationPlaybackChanged,onFrameAnimationsChanged:this.subscriber.onAnimationChanged,onVariableListChanged:e=>{var r;(r=this.enabledNextSubscribers)!=null&&r.onVariableListChanged?this.next.subscriber.onVariableListChanged(e):this.subscriber.onVariableListChanged(e)},onSelectedToolChanged:this.subscriber.onSelectedToolChanged,onUndoStateChanged:this.subscriber.onUndoStateChanged,onSelectedLayoutFramesChanged:this.subscriber.onSelectedLayoutFramesChanged,onSelectedTextStyleChanged:this.subscriber.onSelectedTextStyleChanged,onColorsChanged:this.subscriber.onColorsChanged,onParagraphStylesChanged:this.subscriber.onParagraphStylesChanged,onCharacterStylesChanged:this.subscriber.onCharacterStylesChanged,onFontFamiliesChanged:this.subscriber.onFontFamiliesChanged,onSelectedLayoutIdChanged:this.subscriber.onSelectedLayoutIdChanged,onLayoutsChanged:this.subscriber.onLayoutsChanged,onConnectorEvent:this.subscriber.onConnectorEvent,onConnectorsChanged:e=>{var r;(r=this.enabledNextSubscribers)!=null&&r.onConnectorsChanged?this.next.subscriber.onConnectorsChanged(e):this.subscriber.onConnectorsChanged(e)},onZoomChanged:this.subscriber.onZoomChanged,onSelectedPageIdChanged:this.subscriber.onSelectedPageIdChanged,onPagesChanged:this.subscriber.onPagesChanged,onPageSnapshotInvalidated:this.subscriber.onPageSnapshotInvalidated,onPageSizeChanged:e=>{var r;(r=this.enabledNextSubscribers)!=null&&r.onPageSizeChanged?this.next.subscriber.onPageSizeChanged(e):this.subscriber.onPageSizeChanged(e)},onShapeCornerRadiusChanged:this.subscriber.onShapeCornerRadiusChanged,onCropActiveFrameIdChanged:this.subscriber.onCropActiveFrameIdChanged,onAsyncError:this.subscriber.onAsyncError,onViewModeChanged:this.subscriber.onViewModeChanged,onBarcodeValidationChanged:this.subscriber.onBarcodeValidationChanged,onDataSourceIdChanged:this.subscriber.onDataSourceIdChanged,onDocumentIssueListChanged:this.subscriber.onDocumentIssueListChanged,onCustomUndoDataChanged:this.subscriber.onCustomUndoDataChanged,onEngineEditModeChanged:this.subscriber.onEngineEditModeChanged,onBrandKitMediaChanged:this.subscriber.onBrandKitMediaChanged},this.setConnection,this.config.editorId,this.config.studioStyling),this.editorAPI=at==null?void 0:at.promise.then(e=>e),this.action=new De(this.editorAPI),this.layout=new As(this.editorAPI),this.frame=new vs(this.editorAPI),this.barcode=new Te(this.editorAPI),this.animation=new Oe(this.editorAPI),this.document=new as(this.editorAPI),this.configuration=new zs(this.editorAPI,this.localConfig),this.utils=new _s(this.editorAPI,this.localConfig),this.tool=new Us(this.editorAPI),this.page=new Fs(this.editorAPI),this.debug=new ns(this.editorAPI),this.undoManager=new ks(this.editorAPI,this),this.textSelection=new Ts(this.editorAPI),this.colorStyle=new He(this.editorAPI),this.gradientStyle=new Ws(this.editorAPI),this.paragraphStyle=new Es(this.editorAPI),this.characterStyle=new ke(this.editorAPI),this.mediaConnector=new Ps(this.editorAPI),this.fontConnector=new Ss(this.editorAPI),this.dataConnector=new ss(this.editorAPI,this.dataItemMappingTools),this.dataSource=new rs(this.editorAPI,this.dataItemMappingTools),this.connector=new es(this.editorAPI,this.localConfig),this.variable=new xs(this.editorAPI),this.font=new bs(this.editorAPI),this.experiment=new fs(this.editorAPI),this.canvas=new de(this.editorAPI),this.shape=new pe(this.editorAPI),this.colorConversion=new xe(this.editorAPI),this.info=new Is,this.clipboard=new _e(this.editorAPI),this.brandKit=new Ue(this.editorAPI,this),this.next=new Hs(this.config,this.connection,this.editorAPI),this.configuration.setValue(q.GraFxStudioSdkVersion,Se.version),this.configuration.setValue(q.GraFxStudioDocumentType,this.config.documentType||he.template),this.configuration.updateStudioOptions(this.config.studioOptions||ln),this.configuration.setValue(q.QueryCallCacheEnabled,((t=this.config.enableQueryCallCache)==null?void 0:t.toString())||"false")},this.setConnection=t=>{at=t},this.config=me.createRuntimeConfig(o),this.connection=at,this.editorAPI=at==null?void 0:at.promise.then(t=>t),this.action=new De(this.editorAPI),this.layout=new As(this.editorAPI),this.frame=new vs(this.editorAPI),this.shape=new pe(this.editorAPI),this.barcode=new Te(this.editorAPI),this.undoManager=new ks(this.editorAPI,this),this.connector=new es(this.editorAPI,this.localConfig),this.mediaConnector=new Ps(this.editorAPI),this.fontConnector=new Ss(this.editorAPI),this.dataConnector=new ss(this.editorAPI,this.dataItemMappingTools),this.dataSource=new rs(this.editorAPI,this.dataItemMappingTools),this.animation=new Oe(this.editorAPI),this.document=new as(this.editorAPI),this.configuration=new zs(this.editorAPI,this.localConfig),this.variable=new xs(this.editorAPI),this.utils=new _s(this.editorAPI,this.localConfig),this.subscriber=new Pn(this.config,this.localConfig),this.tool=new Us(this.editorAPI),this.page=new Fs(this.editorAPI),this.debug=new ns(this.editorAPI),this.textSelection=new Ts(this.editorAPI),this.colorStyle=new He(this.editorAPI),this.gradientStyle=new Ws(this.editorAPI),this.paragraphStyle=new Es(this.editorAPI),this.characterStyle=new ke(this.editorAPI),this.font=new bs(this.editorAPI),this.experiment=new fs(this.editorAPI),this.canvas=new de(this.editorAPI),this.colorConversion=new xe(this.editorAPI),this.info=new Is,this.clipboard=new _e(this.editorAPI),this.next=new Hs(this.config,this.connection,this.editorAPI),this.enabledNextSubscribers=this.config.enableNextSubscribers,this.brandKit=new Ue(this.editorAPI,this)}}var js=(s=>(s.top="top",s.left="left",s.right="right",s.bottom="bottom",s.topLeft="topLeft",s.topRight="topRight",s.bottomLeft="bottomLeft",s.bottomRight="bottomRight",s))(js||{}),qs=(s=>(s.horizontal="horizontal",s.vertical="vertical",s))(qs||{}),Ys=(s=>(s.easeIn="easeIn",s.easeOut="easeOut",s.easeInOut="easeInOut",s))(Ys||{}),Zs=(s=>(s.quadratic="Quadratic",s.cubic="Cubic",s.quartic="Quartic",s.quintic="Quintic",s.sine="Sine",s.exponential="Exponential",s.circular="Circular",s.elastic="Elastic",s.bounce="Bounce",s.back="Back",s))(Zs||{}),Qs=(s=>(s.bounce="bounce",s.flash="flash",s.headshake="headShake",s.heartbeat="heartbeat",s.pulse="pulse",s.rubberBand="rubberBand",s.vertical="vertical",s.horizontal="horizontal",s.swing="swing",s.tada="tada",s))(Qs||{}),Xs=(s=>(s.preview="preview",s.normal="normal",s))(Xs||{}),tr=(s=>(s.linear="linear",s))(tr||{}),er=(s=>(s.local="linearLocal",s.linearBrandKit="linearBrandKit",s))(er||{}),sr=(s=>(s.Square="square",s.Line="line",s))(sr||{}),rr=(s=>(s.BOLD="Bold",s.ITALIC="Italic",s.REGULAR="Regular",s))(rr||{}),nr=(s=>(s.LEFT="left",s.CENTER="center",s.RIGHT="right",s.JUSTIFY="justify",s))(nr||{}),ar=(s=>(s.TOP="top",s.CENTER="center",s.BOTTOM="bottom",s))(ar||{}),ir=(s=>(s.TO_LOWER_CASE="lowercase",s.TO_UPPER_CASE="uppercase",s.NORMAL="normal",s))(ir||{}),or=(s=>(s.SUPERSCRIPT="superscript",s.SUBSCRIPT="subscript",s.NORMAL="normal",s))(or||{}),cr=(s=>(s.none="none",s.bullet="bullet",s.number="number",s))(cr||{}),hr=(s=>(s.STYLE="textStyle",s.PROPERTIES="textProperties",s.APPEARANCE="appearance",s))(hr||{}),lr=(s=>(s.PARAGRAPH="paragraphStyleId",s.CHARACTER="characterStyleId",s.FONT_FAMILY="fontKey",s.FONT_STYLE="fontStyle",s.FONT_SIZE="fontSize",s.LETTER_SPACING="letterSpacing",s.LINE_HEIGHT="lineHeight",s.TEXT_ALIGN="textAlign",s.VERTICAL_ALIGN="verticalAlign",s.TYPOGRAPHIC_CASE="typographicCase",s.SUB_SUPER_SCRIPT="subSuperScript",s.UNDERLINE="underline",s.LINE_THROUGH="lineThrough",s.FILL_COLOR="fillColor",s.COLOR="color",s.FILL_COLOR_APPLIED="fillColorApplied",s.STROKE_COLOR="strokeColor",s.STROKE_COLOR_APPLIED="strokeColorApplied",s.DROP_SHADOW_COLOR="dropShadowColor",s.BLEND_MODE="blendMode",s.OPACITY="opacity",s.TRACKING_RIGHT="trackingRight",s.BASELINE_SHIFT="baselineShiftValue",s.STROKE_WIDTH="strokeWidth",s.MARKED_LIST_TYPE="markedListType",s.MARKED_LIST_GROUP="markedListGroup",s.MARKED_LIST_LEVEL="markedListLevel",s))(lr||{}),dr=(s=>(s.arabic="arabic",s.romanUpperCase="romanUpperCase",s.romanLowerCase="romanLowerCase",s.latinUpperCase="latinUpperCase",s.latinLowerCase="latinLowerCase",s))(dr||{}),ur=(s=>(s.none="none",s.dash="dash",s.dot="dot",s.colon="colon",s.roundBracket="roundBracket",s))(ur||{}),gr=(s=>(s.selectedLayoutChanged="selectedLayoutChanged",s.frameMoved="frameMoved",s.pageSizeChanged="pageSizeChanged",s.documentLoaded="documentLoaded",s.variableValueChanged="variableValueChanged",s))(gr||{}),yr=(s=>(s.ellipse="ellipse",s.rectangle="rectangle",s.polygon="polygon",s))(yr||{}),pr=(s=>(s.all="all",s.only="only",s.none="none",s))(pr||{}),Cr=(s=>(s.normal="normal",s.textEdit="textEdit",s.customCrop="customCrop",s.frameSubjectArea="frameSubjectArea",s.perAssetCrop="perAssetCrop",s.gradient="gradient",s))(Cr||{}),mr=(s=>(s.url="url",s.grafx="grafx",s.local="local",s))(mr||{});const Un=Object.freeze(Object.defineProperty({__proto__:null,ConnectorRegistrationSource:mr},Symbol.toStringTag,{value:"Module"}));h.ActionAsyncError=Os,h.ActionEditorEvent=gr,h.Alignment=nr,h.AnchorTargetEdgeType=ws,h.AnchorTargetType=ms,h.AuthCredentialsTypeEnum=Qe,h.AuthRefreshTypeEnum=Xe,h.AutoGrowDirection=is,h.BarcodeCharacterSet=Ct,h.BarcodeErrorCorrectionLevel=It,h.BarcodeSourceTypeEnum=cs,h.BarcodeType=H,h.BarcodeValidationResult=Le,h.BasicAnimationsEmphasisStyles=Qs,h.BlendMode=us,h.Case=ir,h.ColorType=Z,h.ColorUsageType=Xt,h.ConnectorConfigContextType=je,h.ConnectorConfigValueType=We,h.ConnectorEventType=Ze,h.ConnectorHttpError=Ee,h.ConnectorMapping=mn,h.ConnectorMappingDirection=Ye,h.ConnectorMappingSource=qe,h.ConnectorRegistrationSource=Ft,h.ConnectorStateType=se,h.ConnectorType=Ke,h.ConstraintMode=Ve,h.CornerRadiusType=pr,h.CropType=ye,h.DataRowAsyncError=Ls,h.Day=Ms,h.DeprecatedMediaConnectorDownloadType=ee,h.DeprecatedMediaType=At,h.DocumentIssueTypeEnum=Pe,h.DocumentType=he,h.DownloadFormats=Js,h.EaseTypes=Ys,h.EngineEditModeType=Cr,h.EnvironmentType=ae,h.FitMode=gs,h.FitModePosition=ys,h.FlowDirection=ls,h.FontPreviewFormat=sr,h.FontWeights=rr,h.FrameAnchorTarget=In,h.FrameAnchorType=Cs,h.FramePropertyNames=Bs,h.FrameTypeEnum=os,h.GradientType=tr,h.GradientUsageType=er,h.GrafxTokenAuthCredentials=fn,h.ImageSourceTypeEnum=kt,h.LayoutIntent=Re,h.LayoutPropertyNames=Gs,h.LayoutType=Me,h.Locale=Ns,h.MarkedListType=cr,h.MeasurementUnit=Ne,h.MediaDownloadIntent=Ce,h.MediaDownloadType=re,h.MediaType=Pt,h.Next=Un,h.NumberListFormat=dr,h.NumberListSeparatorSymbol=ur,h.PageAnchorTarget=vn,h.PositionEnum=Y,h.RefreshedAuthCredendentials=Sn,h.Scripting=or,h.SelectedTextStyleSections=hr,h.SelectedTextStyles=lr,h.ShakeDirections=qs,h.ShapeType=yr,h.SlideDirections=js,h.SortBy=$e,h.SortOrder=ze,h.TextDirection=hs,h.TextPosition=ar,h.ToolType=$,h.TweenTypes=Zs,h.UpdateZIndexMethod=ps,h.UploadAssetValidationError=ts,h.UploadAssetValidationErrorType=ue,h.VariableType=ne,h.VariableVisibilityOperator=Vs,h.VariableVisibilityTargetType=Rs,h.VariableVisibilityType=Et,h.VerticalAlign=ds,h.ViewMode=Xs,h.WellKnownConfigurationKeys=q,h.default=Jn,h.grafxMediaConnectorRegistration=wn,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
21
21
  //# sourceMappingURL=main.js.map