polotno-node 2.10.6 → 2.10.7
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.
|
@@ -297,7 +297,7 @@ https://polotno.com/docs/server-api`;t.URLS={unsplashList:({query:d,page:m=1})=>
|
|
|
297
297
|
`).join("<br />")}));return h("div",{style:{position:"relative",width:"100%",height:"100%"}},U,M)},O=({element:S,type:E})=>{const P={"stroke-width":S.height,stroke:S.color,"line-cap":"round","stroke-linejoin":"round",opacity:S.opacity};return E==="arrow"||E==="triangle"?h("polyline",Object.assign({points:`${3*S.height},${2*-S.height} 0,0 ${3*S.height},${2*S.height}`},P)):E==="bar"?h("polyline",Object.assign({points:`0,${2*-S.height} 0,${2*S.height}`},P)):E==="circle"?h("circle",Object.assign({r:S.height},P)):E==="square"?h("polyline",Object.assign({points:`${-S.height},${-S.height} ${-S.height},${S.height} ${S.height},${S.height} ${S.height},${-S.height}`},P)):null},g=async({element:S,page:E,store:P})=>h("svg",{style:{width:"100%",height:"100%",contain:"layout style size",overflow:"visible"}},h("rect",{x:0,y:0,width:S.width,height:S.height,fill:S.color}),h("g",{transform:`translate(0 ${S.height/2})`},O({element:S,type:S.startHead})),h("g",{transform:`translate(${S.width} ${S.height/2}) rotate(180)`},O({element:S,type:S.endHead}))),b=async({element:S,page:E,store:P,elementHook:T})=>{const N=await Promise.all(S.children.map(G=>d({element:G,page:E,store:P,elementHook:T}))),U=h("div",{style:{"transform-origin":"top left",opacity:S.opacity}},...N);return T&&T({dom:U,element:S})||U},p=async({element:S,page:E,store:P,elementHook:T})=>{const N=(0,s.figureToSvg)(S),U=h("div",{innerHTML:N});return T&&T({dom:U,element:S})||U},y={image:w,svg:w,text:v,line:g,figure:p,group:b};async function d({element:S,page:E,store:P,elementHook:T}){let N=await y[S.type];N||(N=()=>h("div",{}),console.error(`HTML export does not support ${S.type} type...`));const U=await N({element:S,page:E,store:P}),G=[];S.blurEnabled&&G.push(`blur(${S.blurRadius/2}px)`),S.brightnessEnabled&&G.push(`brightness(${100*S.brightness+100}%)`),S.sepiaEnabled&&G.push("sepia()"),S.grayscaleEnabled&&G.push("grayscale()"),S.shadowEnabled&&G.push(`drop-shadow(${S.shadowOffsetX}px ${S.shadowOffsetY}px ${S.shadowBlur}px ${S.shadowColor})`);const Z=h("div",{id:S.id,style:{position:"absolute",left:S.x+"px",top:S.y+"px",width:S.width+"px",height:S.height+"px",transform:`rotate(${S.rotation}deg)`,"transform-origin":"top left",opacity:S.opacity,display:S.visible&&S.showInExport?"block":"none",filter:G.join(" ")||"none"}},U);return T&&T({dom:Z,element:S})||Z}async function m({page:S,store:E,elementHook:P}){const T=await Promise.all(S.children.map(Z=>d({element:Z,page:S,store:E,elementHook:P}))),N=S.width==="auto"?E.width:S.width,U=S.height==="auto"?E.height:S.height;let G={};if(S.background.indexOf("url")>=0||S.background.indexOf("http")>=0||S.background.indexOf(".jpg")>=0||S.background.indexOf(".png")>=0||S.background.indexOf(".jpeg")>=0){const{width:Z,height:W}=await(0,l.loadImage)(S.background),H=await w({element:Object.assign({x:0,y:0,width:Z,height:W,src:S.background,cornerRadius:0},(0,o.getCrop)({width:Z,height:W},{width:Z,height:W})),page:S,store:E});T.unshift(H)}else G=Object.assign(Object.assign({},G),{"background-color":S.background});return h("div",{className:"page",id:S.id,style:Object.assign(Object.assign({},G),{width:N+"px",height:U+"px",border:"1px solid grey",overflow:"hidden",position:"relative"})},...T)}async function _({json:S,elementHook:E}){const P=await Promise.all(S.pages.map(U=>m({page:U,store:S,elementHook:E}))),T=[];S.pages.forEach(U=>{U.children.forEach(G=>{G.type==="text"&&T.indexOf(G.fontFamily)===-1&&T.push(G.fontFamily)})});const N=T.map(U=>S.fonts.find(G=>G.fontFamily===U)?h("style",{},""):h("link",{href:`https://fonts.googleapis.com/css?family=${U}`,rel:"stylesheet"}));return h("div",{className:"design"},...N,...P)}const A=(S,E)=>typeof E=="object"?`${S}="${Object.keys(E).map(P=>`${P}:${E[P]};`).join(" ")}"`:`${S}="${E}"`,C=({dom:S})=>{if(typeof S=="string")return S;if(!S)return"";const E=S.props,{innerHTML:P}=E,T=i(E,["innerHTML"]);return`<${S.type} ${Object.keys(T).map(N=>A(N,S.props[N])).join(" ")}>${P||S.children.map(N=>C({dom:N})).join("")}</${S.type}>`};async function R({json:S,elementHook:E}){const P=await _({json:S,elementHook:E});return C({dom:P})}})(xS);var PS={};(function(t){var e=_e&&_e.__createBinding||(Object.create?function(S,E,P,T){T===void 0&&(T=P);var N=Object.getOwnPropertyDescriptor(E,P);N&&!("get"in N?!E.__esModule:N.writable||N.configurable)||(N={enumerable:!0,get:function(){return E[P]}}),Object.defineProperty(S,T,N)}:function(S,E,P,T){T===void 0&&(T=P),S[T]=E[P]}),n=_e&&_e.__setModuleDefault||(Object.create?function(S,E){Object.defineProperty(S,"default",{enumerable:!0,value:E})}:function(S,E){S.default=E}),r=_e&&_e.__importStar||function(S){if(S&&S.__esModule)return S;var E={};if(S!=null)for(var P in S)P!=="default"&&Object.prototype.hasOwnProperty.call(S,P)&&e(E,S,P);return n(E,S),E},i=_e&&_e.__rest||function(S,E){var P={};for(var T in S)Object.prototype.hasOwnProperty.call(S,T)&&E.indexOf(T)<0&&(P[T]=S[T]);if(S!=null&&typeof Object.getOwnPropertySymbols=="function"){var N=0;for(T=Object.getOwnPropertySymbols(S);N<T.length;N++)E.indexOf(T[N])<0&&Object.prototype.propertyIsEnumerable.call(S,T[N])&&(P[T[N]]=S[T[N]])}return P};Object.defineProperty(t,"__esModule",{value:!0}),t.fixRatio=h,t.jsonToDOM=_,t.jsonToSVG=R;const o=Mc,a=r(au),l=Mc,s=Jp,f=(S,E,...P)=>({type:S,props:E,children:P||[]});function h(S){var E=new DOMParser().parseFromString(S,"image/svg+xml");return E.documentElement.setAttribute("preserveAspectRatio","none"),new XMLSerializer().serializeToString(E)}const x=async({element:S,page:E,store:P})=>{let{src:T}=S;if(S.type==="svg"){const Q=await a.urlToString(T);T=a.replaceColors(Q,new Map(Object.entries(S.colorsReplace)))}let N="";S.flipX&&(N+="scaleX(-1)"),S.flipY&&(N+="scaleY(-1)"),S.clipSrc&&await a.urlToBase64(S.clipSrc);const U=await(0,l.loadImage)(T),G=U.width*S.cropWidth,Z=U.height*S.cropHeight,W=S.width/S.height;let H,L;const M=G/Z;S.type==="svg"?(H=G,L=Z):W>=M?(H=G,L=G/W):(H=Z*W,L=Z);const D=H/U.width,B=L/U.height,V=H/L>S.width/S.height?S.height/L:S.width/H,Y=H*V/D,F=L*V/B,$=S.cropX*U.width*V,z=S.cropY*U.height*V,K=`clip-${S.id}`,X=T.replace(/&/g,"&");return f("g",{style:{transform:N}},f("defs",{},f("clipPath",{id:K},f("rect",{x:0,y:0,width:S.width,height:S.height}))),f("image",{"xlink:href":X,x:-$,y:-z,width:Y,height:F,preserveAspectRatio:"none","clip-path":`url(#${K})`}))},w=async({element:S,page:E,store:P})=>{const T=(W,H,L,M,D)=>{const B=document.createElement("canvas").getContext("2d");return B.font=`${D} ${M} ${H}px ${L}`,B.measureText(W).width},N=((W,H,L,M,D,B)=>{const V=[];return W.split(`
|
|
298
298
|
`).forEach(Y=>{const F=Y.split(" ");let $="";for(let z=0;z<F.length;z++){const K=$+F[z]+" ";T(K,L,M,D,B)>H+.5&&z>0?(V.push($.trim()),$=F[z]+" "):$=K}V.push($.trim())}),V})(S.text,S.width,S.fontSize,S.fontFamily,S.fontWeight,S.fontStyle),U=S.fontSize*S.lineHeight,G=S.align==="center"?"middle":S.align==="right"?"end":"start",Z=N.map((W,H)=>f("tspan",{x:S.align==="center"?S.width/2:S.align==="right"?S.width:0,dy:H===0?0:U,innerHTML:W}));return f("g",{},f("text",{fill:S.fill,y:S.fontSize,"font-size":S.fontSize+"px","text-anchor":G,"font-family":S.fontFamily,"font-style":S.fontStyle,"font-weight":S.fontWeight,"text-decoration":S.textDecoration,"line-height":S.lineHeight,"letter-spacing":S.letterSpacing+"em","stroke-width":S.strokeWidth,stroke:S.stroke},...Z))},v=({element:S,type:E})=>{const P={"stroke-width":S.height,stroke:S.color,"line-cap":"round","stroke-linejoin":"round",opacity:S.opacity};return E==="arrow"||E==="triangle"?f("polyline",Object.assign({points:`${3*S.height},${2*-S.height} 0,0 ${3*S.height},${2*S.height}`},P)):E==="bar"?f("polyline",Object.assign({points:`0,${2*-S.height} 0,${2*S.height}`},P)):E==="circle"?f("circle",Object.assign({r:S.height},P)):E==="square"?f("polyline",Object.assign({points:`${-S.height},${-S.height} ${-S.height},${S.height} ${S.height},${S.height} ${S.height},${-S.height}`},P)):null},O=async({element:S,page:E,store:P})=>f("g",{},f("line",{x1:0,y1:S.height/2,x2:S.width,y2:S.height/2,stroke:S.color,"stroke-width":S.height}),f("g",{transform:`translate(0 ${S.height/2})`},v({element:S,type:S.startHead})),f("g",{transform:`translate(${S.width} ${S.height/2}) rotate(180)`},v({element:S,type:S.endHead}))),g=async({element:S,page:E,store:P,elementHook:T})=>{const N=await Promise.all(S.children.map(G=>d({element:G,page:E,store:P,elementHook:T}))),U=f("g",{opacity:S.opacity,transform:`translate(${S.x}, ${S.y}) rotate(${S.rotation})`,style:{"transform-origin":"top left"}},...N);return T&&T({dom:U,element:S})||U};function b(S){let E=S.replace(/<svg[^>]*>/,"");return E=E.replace(/<\/svg>/,""),E}const p=async({element:S,page:E,store:P,elementHook:T})=>{const N=b((0,s.figureToSvg)(S)),U=f("g",{innerHTML:N});return T&&T({dom:U,element:S})||U},y={image:x,svg:x,text:w,line:O,figure:p,group:g};async function d({element:S,page:E,store:P,elementHook:T}){let N=await y[S.type];N||(N=()=>f("g",{}),console.error(`SVG export does not support ${S.type} type...`));const U=await N({element:S,page:E,store:P}),G=[];S.blurEnabled&&G.push(`blur(${S.blurRadius/2}px)`),S.brightnessEnabled&&G.push(`brightness(${100*S.brightness+100}%)`),S.sepiaEnabled&&G.push("sepia()"),S.grayscaleEnabled&&G.push("grayscale()"),S.shadowEnabled&&G.push(`drop-shadow(${S.shadowOffsetX}px ${S.shadowOffsetY}px ${S.shadowBlur}px ${S.shadowColor})`);const Z=f("g",{className:"element",id:S.id,transform:`translate(${S.x}, ${S.y}) rotate(${S.rotation})`,display:S.visible?void 0:"none",style:{"transform-origin":"top left",filter:G.join(" ")}},U);return T&&T({dom:Z,element:S})||Z}async function m({page:S,store:E,elementHook:P}){const T=await Promise.all(S.children.map(G=>d({element:G,page:S,store:E,elementHook:P}))),N=S.background.indexOf("url")>=0||S.background.indexOf("http")>=0||S.background.indexOf(".jpg")>=0||S.background.indexOf(".png")>=0||S.background.indexOf(".jpeg")>=0;let U;if(N){const G=await(0,l.loadImage)(S.background);U=await(0,l.cropImage)(S.background,Object.assign({width:E.width,height:E.height,x:0,y:0},(0,o.getCrop)({width:E.width,height:E.height},{width:G.width,height:G.height})))}return f("g",{className:"page",style:{}},N?f("image",{"xlink:href":U,x:0,y:0,width:E.width,height:E.height,preserveAspectRatio:"none"}):f("rect",{x:0,y:0,width:E.width,height:E.height,fill:N?void 0:S.background}),...T)}async function _({json:S,elementHook:E}){const P=await Promise.all(S.pages.map(U=>m({page:U,store:S,elementHook:E}))),T=[];S.pages.forEach(U=>{U.children.forEach(G=>{G.type==="text"&&T.indexOf(G.fontFamily)===-1&&T.push(G.fontFamily)})});const N=T.map(U=>S.fonts.find(G=>G.fontFamily===U)?f("style",{},""):f("defs",{},f("style",{type:"text/css",innerHTML:`@import url('https://fonts.googleapis.com/css?family=${U}:bi,normal,i,b');`.replace(/&/g,"&")})));return f("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:`0 0 ${S.width} ${S.height}`,width:S.width,height:S.height},...N,...P)}const A=(S,E)=>typeof E=="object"?`${S}="${Object.keys(E).map(P=>`${P}:${E[P]};`).join(" ")}"`:E==null||E===""?"":`${S}="${E}"`,C=({dom:S,nestLevel:E=0})=>{if(typeof S=="string")return S;if(!S)return"";const P=S.props,{innerHTML:T}=P,N=i(P,["innerHTML"]),U=" ".repeat(E);return`${U}<${S.type} ${Object.keys(N).map(G=>A(G,N[G])).join(" ")}>${T||`
|
|
299
299
|
`+S.children.map(G=>C({dom:G,nestLevel:E+1})).join("")}${U}</${S.type}>
|
|
300
|
-
`};async function R({json:S,elementHook:E}){const P=await _({json:S,elementHook:E});return C({dom:P})}})(PS);var Yg={},O_;function CS(){return O_||(O_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Page=void 0;const e=ni,n=t0,r=Lc(),i=x2(),o=Lc(),a=su;t.Page=e.types.model("Page",{id:e.types.identifier,children:e.types.array(e.types.late(()=>r.ElementTypes)),width:e.types.optional(e.types.union(e.types.number,e.types.literal("auto")),"auto"),height:e.types.optional(e.types.union(e.types.number,e.types.literal("auto")),"auto"),background:"white",bleed:0,custom:e.types.frozen(),duration:5e3,_exporting:!1,_rendering:!1,_forceMount:!1}).postProcessSnapshot(l=>{const s=Object.assign({},l),f={};for(var h in s)h[0]!=="_"&&(f[h]=l[h]);return f}).views(l=>({get store(){return(0,e.getParentOfType)(l,i.Store)}})).views(l=>({get startTime(){let s=0;for(const f of l.store.pages){if(f.id===l.id)return s;s+=f.duration}return s},get _exportingOrRendering(){return l._exporting||l._rendering}})).views(l=>({get computedWidth(){return l.width==="auto"?l.store.width:l.width},get computedHeight(){return l.height==="auto"?l.store.height:l.height}})).actions(l=>({toJSON:()=>JSON.parse(JSON.stringify((0,e.getSnapshot)(l))),_forEachElementUp(s,f){const h=s.map(x=>({id:x,index:l.children.findIndex(w=>w.id===x)}));h.sort((x,w)=>w.index-x.index);for(const{index:x}of h){if(x==-1)continue;const w=x<l.children.length-1&&l.children[x+1],v=s.indexOf(w==null?void 0:w.id)>=0;x===l.children.length-1||v||f(x)}},_forEachElementDown(s,f){const h=s.map(x=>({id:x,index:l.children.findIndex(w=>w.id===x)}));h.sort((x,w)=>x.index-w.index);for(const{index:x}of h){if(x==-1)continue;const w=x>0&&l.children[x-1],v=s.indexOf(w==null?void 0:w.id)>=0;x===0||v||f(x)}return!1}})).actions(l=>({clone(s={}){const f=l.toJSON();f.children.forEach(v=>{v.id=(0,n.nanoid)(10),(0,o.forEveryChild)(v,O=>{O.id=(0,n.nanoid)(10)})});const h=Object.assign(Object.assign(Object.assign({},f),{id:(0,n.nanoid)(10)}),s),x=l.store.addPage(h),w=l.store.pages.indexOf(l);x.setZIndex(w+1),x.select()},setZIndex(s){l.store.setPageZIndex(l.id,s)},set(s){Object.assign(l,s)},select(){l.store.selectPage(l.id)},addElement(s,{skipSelect:f=!1}={}){const h=o.TYPES_MAP[s.type];if(!h)return void console.error("Can not find model with type "+s.type);"children"in s&&Array.isArray(s.children)&&s.children.forEach(w=>{w.id=(0,n.nanoid)(10)});const x=h.create(Object.assign({id:(0,n.nanoid)(10)},s));return l.children.push(x),x.selectable&&!f&&l.store.selectElements([x.id]),x},canMoveElementsUp(s){let f=!1;return l._forEachElementUp(s,()=>{f=f||!0}),f},moveElementsUp(s){l._forEachElementUp(s,f=>{const h=l.children[f];(0,e.detach)(h),l.children.splice(f+1,0,h)})},canMoveElementsTop(s){return this.canMoveElementsUp(s)},moveElementsTop(s){const f=[],h=[];l.children.forEach(x=>{s.indexOf(x.id)>=0?f.push(x):h.push(x)}),l.children.replace(h.concat(f))},canMoveElementsDown(s){let f=!1;return l._forEachElementDown(s,()=>{f=f||!0}),f},moveElementsDown(s){l._forEachElementDown(s,f=>{const h=l.children[f];(0,e.detach)(h),l.children.splice(f-1,0,h)})},canMoveElementsBottom(s){return this.canMoveElementsDown(s)},moveElementsBottom(s){const f=[],h=[];l.children.forEach(x=>{s.indexOf(x.id)>=0?f.push(x):h.push(x)}),l.children.replace(f.concat(h))},setElementZIndex(s,f){const h=l.children.find(x=>x.id===s);h&&((0,e.detach)(h),l.children.remove(h),l.children.splice(f,0,h))},setSize({width:s,height:f,useMagic:h,softChange:x}){if(h){const w=[],v=N=>N.type==="image"&&N.x<1&&N.y<1&&N.width>=l.computedWidth-2&&N.height>=l.computedHeight-2;(0,o.forEveryChild)(l,N=>{N.type!=="group"&&(v(N)||w.push(N))});const O=w.length?(0,a.getTotalClientRect)(w):{x:0,y:0,width:l.computedWidth,height:l.computedHeight},g=1/4,b=Math.max(0,Math.min(O.x,l.computedWidth-O.x-O.width)),p=l.computedWidth*g,y=Math.max(0,b-p),d=Math.max(0,Math.min(O.y,l.computedHeight-O.y-O.height)),m=l.computedHeight*g,_=Math.max(0,d-m),A=l.computedWidth-2*y,C=l.computedHeight-2*_,R=s/A,S=f/C,E=Math.min(R,S),P=(s-A*E)/2-y*E,T=(f-C*E)/2-_*E;(0,o.forEveryChild)(l,N=>{N.type!=="group"&&(v(N)?N.set({x:N.x*E,y:N.y*E,width:N.width*R,height:N.height*S,cropX:0,cropY:0,cropWidth:1,cropHeight:1}):(N.set({x:P+N.x*E,y:T+N.y*E,width:N.width*E,height:N.height*E}),N.type==="text"?N.set({fontSize:N.fontSize*E}):N.type==="figure"&&N.set({strokeWidth:N.strokeWidth*E})))})}x||(l.width=s),x||(l.height=f)}})).actions(l=>({moveElementUp(s){console.warn("page.moveElementUp(id) is deprecated. Please use page.moveElementsUp([id1, id2]) instead."),l.moveElementsUp([s])},moveElementDown(s){console.warn("page.moveElementDown(id) is deprecated. Please use page.moveElementsDown([id1, id2]) instead."),l.moveElementsDown([s])},moveElementTop(s){console.warn("page.moveElementTop(id) is deprecated. Please use page.moveElementsTop([id1, id2]) instead."),l.moveElementsTop([s])},moveElementBottom(s){console.warn("page.moveElementBottom(id) is deprecated. Please use page.moveElementsBottom([id1, id2]) instead."),l.moveElementsBottom([s])},play(){l.store.play({startTime:l.startTime,endTime:l.startTime+l.duration})}}))}(Yg)),Yg}var kS={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Audio=void 0;const e=ni;t.Audio=e.types.model("Audio",{id:e.types.identifier,src:"",duration:0,startTime:0,endTime:1,volume:1,delay:0}).actions(n=>({toJSON:()=>Object.assign({},(0,e.getSnapshot)(n))})).actions(n=>({set(r){Object.assign(n,r)}}))})(kS);var x_;function x2(){return x_||(x_=1,function(t){var e=_e&&_e.__createBinding||(Object.create?function(S,E,P,T){T===void 0&&(T=P);var N=Object.getOwnPropertyDescriptor(E,P);N&&!("get"in N?!E.__esModule:N.writable||N.configurable)||(N={enumerable:!0,get:function(){return E[P]}}),Object.defineProperty(S,T,N)}:function(S,E,P,T){T===void 0&&(T=P),S[T]=E[P]}),n=_e&&_e.__setModuleDefault||(Object.create?function(S,E){Object.defineProperty(S,"default",{enumerable:!0,value:E})}:function(S,E){S.default=E}),r=_e&&_e.__importStar||function(S){if(S&&S.__esModule)return S;var E={};if(S!=null)for(var P in S)P!=="default"&&Object.prototype.hasOwnProperty.call(S,P)&&e(E,S,P);return n(E,S),E},i=_e&&_e.__rest||function(S,E){var P={};for(var T in S)Object.prototype.hasOwnProperty.call(S,T)&&E.indexOf(T)<0&&(P[T]=S[T]);if(S!=null&&typeof Object.getOwnPropertySymbols=="function"){var N=0;for(T=Object.getOwnPropertySymbols(S);N<T.length;N++)E.indexOf(T[N])<0&&Object.prototype.propertyIsEnumerable.call(S,T[N])&&(P[T[N]]=S[T[N]])}return P},o=_e&&_e.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(t,"__esModule",{value:!0}),t.Store=t.Font=void 0,t.createStore=R;const a=ni,l=_S,s=t0,f=o(ki),h=wS,x=SS,w=ES,v=E2(),O=r(iu),g=Yi,b=e0,p=O2,y=OS,d=xS,m=PS,_=CS(),A=Lc(),C=kS;function R({key:S,showCredit:E}={key:"",showCredit:!1}){return t.Store.create({_forceShowCredit:E,_key:S})}(0,a.setLivelinessChecking)("ignore"),t.Font=a.types.model("Font",{fontFamily:a.types.string,url:a.types.optional(a.types.string,""),styles:a.types.frozen()}).preProcessSnapshot(S=>Object.assign(Object.assign({},S),{fontFamily:S.fontFamily||S.name})),t.Store=a.types.model("Store",{role:"",pages:a.types.array(_.Page),fonts:a.types.array(t.Font),audios:a.types.array(C.Audio),width:1080,height:1080,currentTime:0,isPlaying:!1,scale:1,scaleToFit:1,unit:"px",dpi:72,bleedVisible:!1,rulesVisible:!1,openedSidePanel:"",previousOpenedSidePanel:"",custom:a.types.frozen(),selectedElementsIds:a.types.array(a.types.string),animatedElementsIds:a.types.array(a.types.string),history:a.types.optional(l.UndoManager,{targetPath:"../pages"}),_elementsPixelRatio:Math.min(2,window.devicePixelRatio||1),_activePageId:"",_forceShowCredit:!1,_key:"",_validated:!1}).views(S=>({get _bleedVisible(){return console.warn("store._bleedVisible is deprecated. Please use store.bleedVisible instead."),S.bleedVisible},get selectedElements(){return S.selectedElementsIds.map(E=>{for(const P of S.pages)for(const T of P.children)if(T.id===E)return T}).filter(E=>!!E)},get children(){return S.pages},get selectedShapes(){const E=[];return(0,A.forEveryChild)({children:S.selectedElements},P=>{P.type!=="group"&&E.push(P)}),E},get activePage(){return S.pages.slice().find(E=>E.id===S._activePageId)||(S.pages.length?S.pages[0]:null)},get duration(){let E=0;return S.pages.forEach(P=>{E+=P.duration}),E},get _hasCroppedImages(){return S.find(E=>E.type==="image"&&E._cropModeEnabled)},find(E){let P;return(0,A.forEveryChild)({children:S.pages},T=>{if(!P&&E(T))return P=T,!0}),P},getElementById:E=>S.find(P=>P.id===E)})).actions(S=>{let E=0,P=null,T=!1;return{afterCreate(){S.history.canUndo},setCurrentTime(N){S.currentTime=N},play({animatedElementsIds:N=[],startTime:U=0,currentTime:G=0,endTime:Z=S.duration,repeat:W=!1}={}){G&&(console.warn("currentTime property of store.play() is deprecated. Please use startTime instead."),U=G),S.animatedElementsIds=(0,a.cast)(N),S.currentTime=U,S.isPlaying=!0,E=Date.now(),P=Z,T=W,requestAnimationFrame(S.seek)},checkActivePage(){let N=0;for(const U of S.pages){if(S.currentTime>=U.startTime&&S.currentTime<U.startTime+U.duration){S.selectPage(U.id);break}N+=U.duration}},seek(){if(!S.isPlaying)return;const N=Date.now(),U=N-E;E=N,S.currentTime+=U,S.checkActivePage();const G=P||S.duration;S.isPlaying&&S.currentTime<G?requestAnimationFrame(S.seek):S.isPlaying&&T?(S.currentTime=0,requestAnimationFrame(S.seek)):S.stop()},stop(){S.isPlaying=!1,S.currentTime=0,S.animatedElementsIds=(0,a.cast)([]),S.checkActivePage()}}}).actions(S=>({__(){S._validated||((0,v.validateKey)(S._key,S._forceShowCredit),S._validated=!0)},set(E){Object.assign(S,E)},setUnit({unit:E,dpi:P}){S.unit=E||S.unit,S.dpi=P||S.dpi},setRole(E){S.role=E},addPage(E){const P=_.Page.create(Object.assign({id:(0,s.nanoid)(10)},E));return S.pages.push(P),S._activePageId=P.id,P},selectPage(E){S._activePageId=E},selectElements(E){const P=E.map(T=>S.getElementById(T)).sort((T,N)=>T.page.children.indexOf(T)-T.page.children.indexOf(N)).filter(T=>!!T).map(T=>T.id);S.selectedElementsIds=(0,a.cast)(P)},toggleBleed(E){S.bleedVisible=E??!S.bleedVisible},toggleRulers(E){S.rulesVisible=E??!S.rulesVisible},openSidePanel(E){S.openedSidePanel!==E&&(S.previousOpenedSidePanel=S.openedSidePanel,S.openedSidePanel=E)},setScale(E){S.scale=E},_setScaleToFit(E){S.scaleToFit=E},setElementsPixelRatio(E){S._elementsPixelRatio=E},setSize(E,P,T){S.pages.forEach(N=>{N.setSize({width:E,height:P,useMagic:T,softChange:!0})}),S.width=E,S.height=P},setPageZIndex(E,P){const T=S.pages.find(N=>N.id===E);T&&((0,a.detach)(T),S.pages.remove(T),S.pages.splice(P,0,T))},deletePages(E){const P=S.pages.indexOf(S.activePage);E.forEach(U=>{const G=S.pages.find(Z=>Z.id===U);(0,a.destroy)(G)});const T=Math.min(S.pages.length-1,P),N=S.pages[T];N&&(S._activePageId=N.id),S.selectedElementsIds=(0,a.cast)(S.selectedElementsIds.filter(U=>S.getElementById(U)))},groupElements(E){const P=E.map(U=>S.getElementById(U));P.forEach(U=>{U&&(0,a.detach)(U)});const T=S.activePage,N={id:(0,s.nanoid)(10),children:P,type:"group"};return T.children.push(N),S.selectedElementsIds=(0,a.cast)([N.id]),N},ungroupElements(E){const P=E.map(N=>S.getElementById(N)),T=[];P.forEach(N=>{if(N&&N.type==="group"){const U=N.page,G=U.children.indexOf(N);N.children.forEach(Z=>{T.push(Z.id)}),N.children.forEach(Z=>{(0,a.detach)(Z),U.children.push(Z)}),U.children.splice(G,1)}}),S.selectedElementsIds=(0,a.cast)(T)},deleteElements(E){const P=[];S.find(T=>(E.includes(T.id)&&P.push(T),!1)),P.forEach(T=>{(0,a.destroy)(T)}),S.selectedElementsIds=(0,a.cast)(S.selectedElementsIds.filter(T=>S.getElementById(T)))},on(E,P){if(E==="change"){let T=S.toJSON();return(0,a.onSnapshot)(S,N=>{const U=S.toJSON();!(0,p.deepEqual)(T,U)&&(T=U,P(U))})}},async _toCanvas({pixelRatio:E,ignoreBackground:P,pageId:T,mimeType:N,includeBleed:U,_skipTimeout:G,quickMode:Z=!1}={}){var W;const H=E||1;T=T||((W=S.pages[0])===null||W===void 0?void 0:W.id);const L=S.pages.find(me=>me.id===T);if(!L)throw new Error(`No page for export with id ${T}`);Z?L==null||L.set({_forceMount:!0}):L==null||L.set({_exporting:!0});const M=await(0,y.waitTillAvailable)(()=>f.default.stages.find(me=>me.getAttr("pageId")===T));if(!M)throw L==null||L.set({_forceMount:!1,_exporting:!1}),new Error(`Export is failed. Can not find stage for page ${T}. Looks like <Workspace /> component is not mounted, but it is required in order to process the export.`);const D=!!M.findOne(".page-container"),B=S._elementsPixelRatio;H>S._elementsPixelRatio&&S.setElementsPixelRatio(H),await S.waitLoading({_skipTimeout:G});const V=M.findOne(".page-container");if(!V)throw S.setElementsPixelRatio(B),L==null||L.set({_forceMount:!1,_exporting:!1}),new Error(`Export is failed. Can't find page container. ${D}`);M.find("Transformer").forEach(me=>me.visible(!1)),V.find(".page-background").forEach(me=>me.shadowEnabled(!1)),V.find(".page-background").forEach(me=>me.strokeEnabled(!1)),V.find(".highlighter").forEach(me=>me.visible(!1));const Y=V.findOne(".page-background-group"),F=Y.clip();Y.clip({x:null,y:null,width:null,height:null});const $=V.findOne(".elements-container"),z=$.clip();$.clip({x:null,y:null,width:null,height:null});const K=V.find(me=>me.getAttr("hideInExport"));K.forEach(me=>{me.setAttr("oldVisible",me.visible()),me.hide()});const X=V.find(me=>!me.visible()&&me.getAttr("editModeEnabled"));X.forEach(me=>{me.setAttr("oldVisible",me.visible()),me.show()}),P&&V.find(".page-background").forEach(me=>me.hide());const Q=U?L.bleed:0;let J=Q;!S.bleedVisible&&U||(S.bleedVisible||U?S.bleedVisible&&U?J=0:S.bleedVisible&&!U&&(J=-L.bleed):J=0);const ne=document.createElement("canvas");ne.width=Math.round((L.computedWidth+2*Q)*H),ne.height=Math.round((L.computedHeight+2*Q)*H);const ie=ne.getContext("2d");N==="image/jpeg"&&(ie.fillStyle="white",ie.fillRect(0,0,ne.width,ne.height));const ae=V.scale();V.scale({x:1,y:1});const he=V.toCanvas({x:V.x()-J,y:V.y()-J,width:L.computedWidth+2*Q,height:L.computedHeight+2*Q,pixelRatio:H});return V.scale(ae),ie.drawImage(he,0,0,ne.width,ne.height),f.default.Util.releaseCanvas(he),P&&V.find(".page-background").forEach(me=>me.show()),K.forEach(me=>{me.visible(me.getAttr("oldVisible"))}),X.forEach(me=>{me.visible(me.getAttr("oldVisible"))}),V.find(".page-background").forEach(me=>me.shadowEnabled(!0)),V.find(".page-background").forEach(me=>me.strokeEnabled(!0)),M.find("Transformer").forEach(me=>me.visible(!0)),V.find(".highlighter").forEach(me=>me.visible(!0)),Y.clip(F),$.clip(z),S.setElementsPixelRatio(B),L==null||L.set({_exporting:!1,_forceMount:!1}),ne},async toDataURL(E={}){var{mimeType:P,quality:T}=E,N=i(E,["mimeType","quality"]);const U=await S._toCanvas(Object.assign({mimeType:P},N)),G=U.toDataURL(P,T);return f.default.Util.releaseCanvas(U),G},async toBlob(E={}){var{mimeType:P,quality:T}=E,N=i(E,["mimeType","quality"]);const U=await S._toCanvas(Object.assign({mimeType:P},N)),G=await new Promise(Z=>{U.toBlob(Z,P,T)});return f.default.Util.releaseCanvas(U),G},async saveAsImage(E={}){var{fileName:P}=E,T=i(E,["fileName"]);const N=T.mimeType||"image/png",U=N.split("/")[1];(0,h.downloadFile)(await S.toDataURL(T),P||"polotno."+U,N)},async _toPDF(E){const P=E.dpi||S.dpi,T=E.parallel||1,N=E.unit||(S.unit==="px"?"mm":S.unit),U=E.pixelRatio||1,G=E.pageIds||S.pages.map(K=>K.id),Z=S.pages.filter(K=>G.includes(K.id)),W=await(0,x.getJsPDF)(),H=K=>(0,b.pxToUnit)({px:K,unit:N,dpi:P}),L=E.cropMarkSize||0,M=H(L),D=Z[0]||{},B=E.includeBleed?D.bleed:0,V=H(D.computedWidth+2*B+2*M),Y=H(D.computedHeight+2*B+2*M);var F=new W({unit:N,orientation:V>Y?"landscape":"portrait",format:[V,Y],compress:!0,putOnlyUsedFonts:!0});F.deletePage(1);const $=((K,X)=>{for(var Q=[],J=0;J<K.length;J+=X)Q.push(K.slice(J,J+X));return Q})(Z,T);let z=0;for(const K of $){const X=K.map(async Q=>{const J=E.includeBleed?Q.bleed:0,ne=Q.computedWidth+2*J+2*L,ie=Q.computedHeight+2*J+2*L,ae=H(ne),he=H(ie);let me=0,Ce=U;for(;me<10;){me+=1,me===2&&console.error("Polotno can not export PDF with current settings. Quality is automatically reduced.");const re=await S.toDataURL(Object.assign(Object.assign({},E),{pageId:Q.id,pixelRatio:Ce}));if(re.length>20)return E.onProgress&&E.onProgress(++z/G.length*.9),{url:re,width:ae,height:he,widthPx:ne,heightPx:ie};Ce*=.8}});(await Promise.all(X)).forEach(({url:Q,width:J,height:ne,widthPx:ie,heightPx:ae})=>{F.addPage([J,ne],J>ne?"landscape":"portrait");const he=F.getCurrentPageInfo();he.pageContext.cropBox={bottomLeftX:L,bottomLeftY:L,topRightX:ie-L,topRightY:ae-L},he.pageContext.bleedBox={bottomLeftX:L+B,bottomLeftY:L+B,topRightX:ie-L-B,topRightY:ae-L-B},M&&(F.setLineWidth(H(1)),F.line(2*M,0,2*M,M),F.line(0,2*M,M,2*M),F.line(J-2*M,0,J-2*M,M),F.line(J,2*M,J-M,2*M),F.line(0,ne-2*M,M,ne-2*M),F.line(2*M,ne,2*M,ne-M),F.line(J,ne-2*M,J-M,ne-2*M),F.line(J-2*M,ne,J-2*M,ne-M)),F.addImage(Q,M,M,J-2*M,ne-2*M,void 0,"FAST")})}return F},toPDFDataURL:async E=>(await S._toPDF(Object.assign({mimeType:"image/jpeg"},E))).output("datauristring"),async toGIFDataURL(E={}){const P=E.pixelRatio||1,T=await(0,w.createGIF)({width:S.width*P,height:S.height*P}),N=1e3/(E.fps||10),U=S.duration/N;for(let G=0;G<U-1;G++){const Z=G*N||1;S.setCurrentTime(Z);let W=0,H="";for(const M of S.pages)if(W+=M.duration,M.set({_rendering:W>Z}),W>Z){H=M.id;break}const L=await S._toCanvas({pixelRatio:P,pageId:H,_skipTimeout:!0});T.addFrame(L.getContext("2d"),{delay:N,copy:!0})}for(const G of S.pages)G.set({_rendering:!1});return S.stop(),T.render(),new Promise(G=>{T.on("finished",function(Z){(function(W,H){var L=new FileReader;L.onload=function(M){H(M.target.result)},L.readAsDataURL(W)})(Z,G)})})},async saveAsGIF(E={}){var{fileName:P}=E,T=i(E,["fileName"]);const N=await S.toGIFDataURL(T);(0,h.downloadFile)(N,P||"polotno.gif")},async toHTML({elementHook:E}={elementHook:void 0}){const P=S.toJSON();return(0,d.jsonToHTML)({json:P,elementHook:E})},async saveAsHTML({fileName:E}={}){const P=await S.toHTML(),T="data:text/html;base64,"+window.btoa(unescape(encodeURIComponent(P)));(0,h.downloadFile)(T,E||"polotno.html")},async toSVG({elementHook:E,pageId:P}={elementHook:void 0,pageId:void 0}){var T;const N=S.toJSON();P=P||((T=N.pages[0])===null||T===void 0?void 0:T.id);const U=N.pages.find(G=>G.id===P);return(0,m.jsonToSVG)({json:Object.assign(Object.assign({},N),{pages:U?[U]:[]}),elementHook:E})},async saveAsSVG({fileName:E,elementHook:P,pageId:T}={}){const N=await S.toSVG({elementHook:P,pageId:T}),U="data:text/svg;base64,"+window.btoa(unescape(encodeURIComponent(N)));(0,h.downloadFile)(U,E||"polotno.svg")},async saveAsPDF(E={}){var{fileName:P}=E,T=i(E,["fileName"]);(await S._toPDF(Object.assign({mimeType:"image/jpeg"},T))).save(P||"polotno.pdf")},async waitLoading({_skipTimeout:E=!1}={}){E||await new Promise(P=>setTimeout(P,50)),await(0,g.whenLoaded)()},toJSON:()=>({width:S.width,height:S.height,fonts:(0,a.getSnapshot)(S.fonts),pages:(0,a.getSnapshot)(S.pages),audios:(0,a.getSnapshot)(S.audios),unit:S.unit,dpi:S.dpi,custom:S.custom}),loadJSON(E,P=!1){var T;const N=Object.assign({},E),U=S.pages.indexOf(S.activePage);let G=(T=N.pages[U]||N.pages[0])===null||T===void 0?void 0:T.id;N._activePageId=G;const Z=Object.assign({},(0,a.getSnapshot)(S));Object.assign(Z,N),Z.history=P?S.history.toJSON():{history:[],undoIdx:-1},(0,a.applySnapshot)(S,Z)},clear({keepHistory:E=!1}={}){const P=S.pages.map(T=>T.id);S.deletePages(P),E||S.history.clear()},addFont(E){S.removeFont(E.fontFamily),S.fonts.push(E),S.loadFont(E.fontFamily)},removeFont(E){S.fonts.filter(P=>P.fontFamily===E).forEach(P=>(0,a.destroy)(P))},addAudio(E){const P=C.Audio.create(Object.assign({id:(0,s.nanoid)(10)},E));S.audios.push(P)},removeAudio(E){const P=S.audios.find(T=>T.id===E);P&&S.audios.remove(P)},async loadFont(E){const P=S.fonts.find(N=>N.fontFamily===E)||O.globalFonts.find(N=>N.fontFamily===E);let T=[{fontStyle:"normal",fontWeight:"normal"}];return P?(P.styles&&(T=P.styles.map(N=>({fontStyle:N.fontStyle||"normal",fontWeight:N.fontWeight||"normal"}))),O.injectCustomFont(P)):O.injectGoogleFont(E),Promise.all(T.map(N=>O.loadFont(E,N.fontStyle,N.fontWeight)))},validate:E=>t.Store.validate(E,[{path:"",type:t.Store}]).map(P=>({path:"store"+P.context.map(T=>T.path).join("."),message:P.message}))})),t.default=R}(Wg)),Wg}var P_;function TS(){return P_||(P_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Node=void 0;const e=ni,n=t0,r=x2(),i=CS(),o=Lc();t.Node=e.types.model("Node",{id:e.types.identifier,type:"none",name:"",opacity:1,custom:e.types.frozen(),visible:!0,selectable:!0,removable:!0,alwaysOnTop:!1,showInExport:!0}).preProcessSnapshot(a=>{for(var l in a)a[l]===null&&(a[l]=void 0);return a}).postProcessSnapshot(a=>{const l=Object.assign({},a),s={};for(var f in l)f[0]!=="_"&&(s[f]=a[f]);return s}).views(a=>({get locked(){return!(a.draggable||a.contentEditable||a.styleEditable||a.resizable)},get page(){return(0,e.getParentOfType)(a,i.Page)},get store(){return(0,e.getParentOfType)(a,r.Store)},get top(){let l=a;for(;;){if(!(0,e.hasParentOfType)(l,o.GroupElement))return l;l=(0,e.getParentOfType)(l,o.GroupElement)}},get parent(){return(0,e.hasParentOfType)(a,o.GroupElement)?(0,e.getParentOfType)(a,o.GroupElement):(0,e.hasParentOfType)(a,i.Page)?(0,e.getParentOfType)(a,i.Page):(0,e.hasParentOfType)(a,r.Store)?(0,e.getParentOfType)(a,r.Store):null},get zIndex(){return a.parent.children.indexOf(a)}})).actions(a=>({toJSON:()=>Object.assign({},(0,e.getSnapshot)(a))})).actions(a=>({clone(l={},{skipSelect:s=!1}={}){const f=JSON.parse(JSON.stringify(a.toJSON()));return l.id=l.id||(0,n.nanoid)(10),(0,o.forEveryChild)(f,h=>{h.id=(0,n.nanoid)(10)}),Object.assign(f,l),a.page.addElement(f,{skipSelect:s})},set(l){Object.assign(a,l)},moveUp(){a.page.moveElementsUp([a.id])},moveTop(){a.page.moveElementsTop([a.id])},moveDown(){a.page.moveElementsDown([a.id])},moveBottom(){a.page.moveElementsBottom([a.id])},setZIndex(l){a.parent.setElementZIndex(a.id,l)},beforeDestroy(){}}))}(qg)),qg}var Kg={},AS={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.registerAnimation=t.animate=t.animations=void 0;const e=su,n={right:{from:{x:-200},to:{x:0}},left:{from:{x:200},to:{x:0}},up:{from:{y:200},to:{y:0}},down:{from:{y:-200},to:{y:0}},"bottom-right":{from:{x:-200,y:-200},to:{x:0,y:0}},"bottom-left":{from:{x:200,y:-200},to:{x:0,y:0}},"top-right":{from:{x:-200,y:200},to:{x:0,y:0}},"top-left":{from:{x:200,y:200},to:{x:0,y:0}}};t.animations={fade:({dTime:o,element:a,animation:l})=>{const s=o/l.duration;return l.type==="enter"?{opacity:s*a.opacity}:{opacity:(1-s)*a.opacity}},rotate:({dTime:o,element:a,animation:l})=>{const s=o/l.duration*360;return(0,e.rotateAroundCenter)({x:a.x,y:a.y,width:a.width,height:a.height,rotation:a.rotation},s)},blink:({dTime:o,element:a,animation:l})=>{const s=l.duration,f=o%s/(s/2),h=f<=1?f:2-f;return{opacity:a.opacity*h}},bounce:({dTime:o,element:a,animation:l})=>{const s=l.duration,f=s/2,h={},x={x:a.x+a.width/3,y:a.y+a.height/3,width:a.width/3,height:a.height/3,fontSize:a.fontSize/3},w={x:a.x,y:a.y,width:a.width,height:a.height,fontSize:a.fontSize},v=o%s/f,O=v<=1?v:2-v;for(let g in x){const b=x[g],p=w[g]-b;h[g]=b+O*p}return h},move:({dTime:o,element:a,animation:l})=>{const s=n[l.data.direction]||n.right,f={};for(var h in s.from){let x=s.from[h],w=s.to[h];l.type==="exit"&&(x=s.to[h],w=-s.from[h]);const v=a[h]+x,O=a[h]+w-v;f[h]=v+o/l.duration*O}return f},zoom:({dTime:o,element:a,animation:l})=>{const s={},f={x:a.x+a.width/3,y:a.y+a.height/3,width:a.width/3,height:a.height/3,fontSize:a.fontSize/3},h={x:a.x,y:a.y,width:a.width,height:a.height,fontSize:a.fontSize};for(var x in f){let w=f[x],v=h[x];if(l.type==="exit"){const g=w;w=v,v=g}const O=v-w;s[x]=w+o/l.duration*O}return s}};const r=({element:o,dTime:a,animation:l})=>{const s=t.animations[l.name];return s?s({element:o,dTime:a,animation:l}):(console.error("Can not find animation type: "+l.name),{})};t.animate=r;const i=(o,a)=>{};t.registerAnimation=i})(AS);var C_;function uu(){return C_||(C_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.Animation=void 0;const e=ni,n=AS,r=Qi,i=TS();t.Animation=e.types.model("Animation",{delay:0,duration:500,enabled:!0,type:e.types.enumeration("Type",["enter","exit","loop"]),name:"none",data:e.types.frozen({})}),t.Shape=i.Node.named("Shape").props({x:0,y:0,width:100,height:100,rotation:0,opacity:1,animations:e.types.array(t.Animation),blurEnabled:!1,blurRadius:10,brightnessEnabled:!1,brightness:0,sepiaEnabled:!1,grayscaleEnabled:!1,shadowEnabled:!1,shadowBlur:5,shadowOffsetX:0,shadowOffsetY:0,shadowColor:"black",shadowOpacity:1,visible:!0,draggable:!0,resizable:!0,selectable:!0,contentEditable:!0,styleEditable:!0,alwaysOnTop:!1,showInExport:!0}).preProcessSnapshot(o=>{const a=Object.assign(Object.assign({},o),{x:o.x||0,y:o.y||0});return"width"in o&&(a.width=a.width||1),"height"in o&&(a.height=a.height||1),o.locked&&(a.draggable=!1,a.contentEditable=!1,a.styleEditable=!1,a.resizable=!1,a.removable=!1),a}).views(o=>{const a=(0,r.observable)({x:o.x,y:o.y,width:o.width,height:o.height,rotation:o.rotation,opacity:o.opacity,color:o.color,fontSize:o.fontSize}),l=(0,r.action)(s=>{Object.assign(a,s)});return{get a(){const{currentTime:s}=o.store;if(l({x:o.x,y:o.y,width:o.width,height:o.height,rotation:o.rotation,opacity:o.opacity,color:o.color,fontSize:o.fontSize}),s===0)return a;const f=s-o.page.startTime;if(f>o.page.duration||f<0)return a;const h=o.store.animatedElementsIds;if(h.length&&!h.includes(o.id))return a;const x=o.animations.find(O=>O.type==="enter");if(x!=null&&x.enabled&&f<x.delay&&l({opacity:0}),x!=null&&x.enabled&&f>=x.delay&&f<=x.delay+x.duration){const O=f-x.delay,g=(0,n.animate)({element:o,animation:x,dTime:O});l(g)}const w=o.animations.find(O=>O.type==="exit");if(w!=null&&w.enabled&&f>=o.page.duration-w.duration-w.delay&&f<=o.page.duration-w.delay){const O=f-(o.page.duration-w.duration-w.delay),g=(0,n.animate)({element:o,animation:w,dTime:O});l(g)}w!=null&&w.enabled&&f>=o.page.duration-w.delay&&l({opacity:0});const v=o.animations.find(O=>O.type==="loop");if(v!=null&&v.enabled){const O=f,g=(0,n.animate)({element:o,animation:v,dTime:O});l(g)}return a},animated:s=>o.a[s]}}).actions(o=>({setAnimation(a,l){const s=o.animations.find(f=>f.type===a);s?Object.assign(s,l):o.animations.push(Object.assign({type:a},l))}}))}(Kg)),Kg}var Xg={},k_;function vj(){return k_||(k_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.TextElement=void 0;const e=ni,n=uu();t.TextElement=n.Shape.named("Text").props({type:"text",text:"",placeholder:"",fontSize:14,fontFamily:"Roboto",fontStyle:"normal",fontWeight:"normal",textDecoration:"",fill:"black",align:"center",width:100,height:0,verticalAlign:"top",strokeWidth:0,stroke:"black",lineHeight:e.types.optional(e.types.union(e.types.number,e.types.string),1.2),letterSpacing:0,_editModeEnabled:!1,backgroundEnabled:!1,backgroundColor:"#7ED321",backgroundOpacity:1,backgroundCornerRadius:.5,backgroundPadding:.5}).preProcessSnapshot(r=>Object.assign({},r)).actions(r=>({toggleEditMode(i){r._editModeEnabled=i??!r._editModeEnabled,r._editModeEnabled?r.store.history.startTransaction():r.store.history.endTransaction()}}))}(Xg)),Xg}var Zg={},T_;function RS(){return T_||(T_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ImageElement=void 0;const e=uu();t.ImageElement=e.Shape.named("Image").props({type:"image",width:100,height:100,src:"",cropX:0,cropY:0,cropWidth:1,cropHeight:1,cornerRadius:0,flipX:!1,flipY:!1,clipSrc:"",borderColor:"black",borderSize:0,keepRatio:!1,_cropModeEnabled:!1}).actions(n=>({toggleCropMode(r){n._cropModeEnabled=r??!n._cropModeEnabled,n._cropModeEnabled?n.store.history.startTransaction():n.store.history.endTransaction()},beforeDestroy(){n._cropModeEnabled&&n.store.history.endTransaction()}}))}(Zg)),Zg}var Qg={},A_;function mj(){return A_||(A_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.VideoElement=void 0;const e=RS();t.VideoElement=e.ImageElement.named("Video").props({type:"video",duration:0,startTime:0,endTime:1,volume:1})}(Qg)),Qg}var Jg={},R_;function yj(){return R_||(R_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.LineElement=void 0;const e=ni,n=uu();t.LineElement=n.Shape.named("Line").props({type:"line",width:400,height:10,color:"black",dash:e.types.array(e.types.number),startHead:"",endHead:""}).actions(r=>({}))}(Jg)),Jg}var ev={},M_;function bj(){return M_||(M_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.SVGElement=void 0;const e=ni,n=uu();t.SVGElement=n.Shape.named("SVG").props({type:"svg",src:"",maskSrc:"",cropX:0,cropY:0,cropWidth:1,cropHeight:1,keepRatio:!0,flipX:!1,flipY:!1,width:100,height:100,borderColor:"black",borderSize:0,cornerRadius:0,colorsReplace:e.types.map(e.types.string)}).preProcessSnapshot(r=>Object.assign(Object.assign({},r),{src:r.src||r.svgSource})).actions(r=>({replaceColor(i,o){r.colorsReplace.set(i,o)}}))}(ev)),ev}var tv={},L_;function _j(){return L_||(L_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.FigureElement=void 0;const e=ni,n=uu();t.FigureElement=n.Shape.named("Figure").props({type:"figure",subType:"rect",fill:"rgb(0, 161, 255)",dash:e.types.array(e.types.number),strokeWidth:0,stroke:"rgba(98, 197, 255, 1)",cornerRadius:0})}(tv)),tv}var N_;function Lc(){return N_||(N_=1,function(t){var e=_e&&_e.__rest||function(b,p){var y={};for(var d in b)Object.prototype.hasOwnProperty.call(b,d)&&p.indexOf(d)<0&&(y[d]=b[d]);if(b!=null&&typeof Object.getOwnPropertySymbols=="function"){var m=0;for(d=Object.getOwnPropertySymbols(b);m<d.length;m++)p.indexOf(d[m])<0&&Object.prototype.propertyIsEnumerable.call(b,d[m])&&(y[d[m]]=b[d[m]])}return y};Object.defineProperty(t,"__esModule",{value:!0}),t.TYPES_MAP=t.GroupElement=t.ElementTypes=t.forEveryChild=void 0,t.registerShapeModel=g;const n=ni,r=t0,i=TS(),o=uu(),a=vj(),l=RS(),s=mj(),f=yj(),h=bj(),x=_j(),w=(b,p)=>{if(b.children)for(const y of b.children){if(p(y)===!0)break;(0,t.forEveryChild)(y,p)}};t.forEveryChild=w;const v=[...new Array(20)].map((b,p)=>n.types.late(()=>O[p]));t.ElementTypes=n.types.union({dispatcher:b=>{const p=t.TYPES_MAP[b.type];if(!p)throw new Error(`Unknown element type: "${b.type}"`);return p}},h.SVGElement,a.TextElement,l.ImageElement,f.LineElement,s.VideoElement,x.FigureElement,n.types.late(()=>t.GroupElement),...v),t.GroupElement=i.Node.named("Group").props({type:"group",children:n.types.array(t.ElementTypes)}).views(b=>({get draggable(){let p=!0;return(0,t.forEveryChild)(b,y=>{y.draggable||(p=!1)}),p},get resizable(){let p=!0;return(0,t.forEveryChild)(b,y=>{y.resizable||(p=!1)}),p},get contentEditable(){let p=!0;return(0,t.forEveryChild)(b,y=>{y.contentEditable||(p=!1)}),p},get styleEditable(){let p=!0;return(0,t.forEveryChild)(b,y=>{y.styleEditable||(p=!1)}),p},get locked(){let p=!0;return(0,t.forEveryChild)(b,y=>{y.locked||(p=!1)}),p}})).actions(b=>({set(p){var{draggable:y,contentEditable:d,styleEditable:m,resizable:_}=p,A=e(p,["draggable","contentEditable","styleEditable","resizable"]);y!==void 0&&(0,t.forEveryChild)(b,C=>{C.set({draggable:y})}),d!==void 0&&(0,t.forEveryChild)(b,C=>{C.set({contentEditable:d})}),m!==void 0&&(0,t.forEveryChild)(b,C=>{C.set({styleEditable:m})}),_!==void 0&&(0,t.forEveryChild)(b,C=>{C.set({resizable:_})}),Object.assign(b,A)},addElement(p,{skipSelect:y=!1}={}){const d=t.TYPES_MAP[p.type];if(!d)return void console.error("Can not find model with type "+p.type);p.children&&p.children.forEach(_=>{_.id=(0,r.nanoid)(10)});const m=d.create(Object.assign({id:(0,r.nanoid)(10)},p));return b.children.push(m),m.selectable&&!y&&b.store.selectElements([m.id]),m},setElementZIndex(p,y){const d=b.children.find(m=>m.id===p);d&&((0,n.detach)(d),b.children.remove(d),b.children.splice(y,0,d))}}));const O=[];function g(b,p){const y=b.type;if(!y)throw new Error('You must pass "type" attribute to custom model.');let d=o.Shape.named(y).props(b);p&&(d=p(d)),t.TYPES_MAP[y]=d,O.push(d)}t.TYPES_MAP={svg:h.SVGElement,text:a.TextElement,image:l.ImageElement,group:t.GroupElement,line:f.LineElement,video:s.VideoElement,figure:x.FigureElement}}(Vg)),Vg}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.handleHotkey=l;const e=Lc();let n=[],r="";const i="polotno_clipboard",o=s=>{n=JSON.parse(JSON.stringify(s));try{localStorage.setItem(i,JSON.stringify(s))}catch{}},a=()=>{try{const s=localStorage.getItem(i);if(s)return JSON.parse(s)}catch{}return n};function l(s,f){var h,x,w,v,O,g,b,p;if(((h=document.activeElement)===null||h===void 0?void 0:h.tagName)==="INPUT"||((x=document.activeElement)===null||x===void 0?void 0:x.tagName)==="TEXTAREA"||((w=document.activeElement)===null||w===void 0?void 0:w.contentEditable)==="true")return;const y=f.selectedElements.filter(A=>A.removable),d=y.map(A=>A.id);s.keyCode!==46&&s.keyCode!==8||f.deleteElements(d);const m=s.ctrlKey||s.metaKey,_=s.shiftKey;if(m&&!_&&s.code==="KeyZ"&&(s.preventDefault(),f.history.undo()),m&&_&&s.code==="KeyZ"&&(s.preventDefault(),f.history.redo()),m&&s.code==="KeyA"){s.preventDefault();const A=(v=f.activePage)===null||v===void 0?void 0:v.children.filter(R=>R.selectable),C=(A==null?void 0:A.map(R=>R.id))||[];f.selectElements(C)}if(m&&s.code==="KeyC"&&(s.preventDefault(),r=(O=f.activePage)===null||O===void 0?void 0:O.id,o(f.selectedElements.map(A=>A.toJSON()))),m&&s.code==="KeyX"&&(s.preventDefault(),r=(g=f.activePage)===null||g===void 0?void 0:g.id,o(f.selectedElements.map(A=>A.toJSON())),f.deleteElements(y)),m&&s.code==="KeyV"){s.preventDefault();let A=0;r===((b=f.activePage)===null||b===void 0?void 0:b.id)&&(A=f.width/20),r=(p=f.activePage)===null||p===void 0?void 0:p.id,f.history.transaction(()=>{const C=[],R=a();(0,e.forEveryChild)({children:R},S=>{delete S.id,S.type!=="group"&&(S.x+=A,S.y+=A)}),R.forEach(S=>{var E;const P=(E=f.activePage)===null||E===void 0?void 0:E.addElement(S);P&&C.push(P.id)}),o(R),f.selectElements(C)})}s.code==="ArrowDown"&&(s.preventDefault(),f.selectedElements.forEach(A=>{A.draggable&&A.set({y:A.y+1})})),s.code==="ArrowUp"&&(s.preventDefault(),f.selectedElements.forEach(A=>{A.draggable&&A.set({y:A.y-1})})),s.code==="ArrowLeft"&&(s.preventDefault(),f.selectedElements.forEach(A=>{A.draggable&&A.set({x:A.x-1})})),s.code==="ArrowRight"&&(s.preventDefault(),f.selectedElements.forEach(A=>{A.draggable&&A.set({x:A.x+1})}))}})(mS);var MS={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.t=t.getTranslations=t.setTranslations=void 0;const e=Qi,n=(0,e.observable)({toolbar:{duration:"Duration",opacity:"Opacity",effects:"Effects",blur:"Blur",textBackground:"Background",backgroundCornerRadius:"Corner radius",backgroundOpacity:"Opacity",backgroundPadding:"Padding",brightness:"Brightness",sepia:"Sepia",grayscale:"Grayscale",textStroke:"Text Stroke",shadow:"Shadow",border:"Border",cornerRadius:"Corner Radius",position:"Position",layering:"Layering",toForward:"To forward",up:"Up",down:"Down",toBottom:"To bottom",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignTop:"Align top",alignMiddle:"Align middle",alignBottom:"Align bottom",flip:"Flip",flipHorizontally:"Flip horizontally",flipVertically:"Flip vertically",fitToBackground:"Fit to page",removeBackground:"Remove background",removeBackgroundTitle:"Remove background from image",cancelRemoveBackground:"Cancel",confirmRemoveBackground:"Confirm",crop:"Crop",cropDone:"Done",cropCancel:"Cancel",clip:"Apply mask",removeClip:"Remove mask",removeMask:"Remove mask",transparency:"Transparency",lockedDescription:"Object is locked. Unlock it to allow changes from canvas.",unlockedDescription:"Object is unlocked. Lock it to prevent changes from canvas.",removeElements:"Remove elements",duplicateElements:"Duplicate elements",download:"Download",saveAsImage:"Save as image",saveAsPDF:"Save as PDF",lineHeight:"Line height",letterSpacing:"Letter spacing",offsetX:"Offset X",offsetY:"Offset Y",color:"Color",selectable:"Selectable",draggable:"Draggable",removable:"Removable",resizable:"Resizable",contentEditable:"Can change content",styleEditable:"Can change style",alwaysOnTop:"Always on top",showInExport:"Show in export",ungroupElements:"Ungroup",groupElements:"Group",lineSize:"Line size",fade:"Fade",move:"Move",zoom:"Zoom",animate:"Animate",rotate:"Rotate",none:"None",bounce:"Bounce",blink:"Blink",spaceEvenly:"Space evenly",horizontalDistribution:"Horizontally",verticalDistribution:"Vertically",strokeWidth:"Stroke Width",colorPicker:{solid:"Solid",linear:"Linear"},aiText:{aiWrite:"AI write",rewrite:"Rewrite",shorten:"Shorten",continue:"Continue writing",proofread:"Proofread",tones:"Tones",friendly:"Friendly",professional:"Professional",humorous:"Humorous",formal:"Formal"}},workspace:{noPages:"There are no pages yet...",addPage:"Add page",removePage:"Remove page",duplicatePage:"Duplicate page",moveUp:"Move up",moveDown:"Move down"},scale:{reset:"Reset"},error:{removeBackground:"Ops! Something went wrong. Background can not be removed."},sidePanel:{templates:"Templates",searchTemplatesWithSameSize:"Show templates with the same size",searchPlaceholder:"Search...",otherFormats:"Other formats",noResults:"No results",error:"Loading is failed...",text:"Text",uploadFont:"Upload font",myFonts:"My fonts",photos:"Photos",videos:"Videos",animations:"Animations",effects:"Effects",elements:"Elements",shapes:"Shapes",lines:"Lines",upload:"Upload",uploadImage:"Upload Image",uploadTip:"Do you want to upload your own images?",background:"Background",resize:"Resize",layers:"Layers",layerTypes:{image:"Image",text:"Text",svg:"SVG",line:"Line",figure:"Figure",group:"Group"},layersTip:"Elements on your active page:",noLayers:"No elements on the page...",namePlaceholder:"Type element name...",useMagicResize:"Use magic resize",clipImage:"Mask image",width:"Width",height:"Height",magicResizeDescription:"Magic resize will automatically resize and move all elements on the canvas",headerText:"Header",createHeader:"Create header",subHeaderText:"Sub Header",createSubHeader:"Create sub header",bodyText:"Body text",createBody:"Create body text"},pagesTimeline:{pages:"Pages",removePage:"Remove page",addPage:"Add page",duplicatePage:"Duplicate page",removeAudio:"Remove audio"}});function r(h,x){var w,v=x.split("."),O=h;for(w=0;w<v.length;++w){if(O[v[w]]==null)return;O=O[v[w]]}return O}const i=h=>h&&typeof h=="object";function o(h,x){Object.keys(x).forEach(w=>{const v=h[w],O=x[w];i(O)&&i(v)?o(v,O):h[w]=O})}function a(h,x,w=""){Object.keys(x).forEach(v=>{const O=x[v],g=w?`${w}.${v}`:v;i(O)?i(h[v])?a(h[v],O,g):console.warn(`Missing nested translation object at '${g}'`):h[v]===void 0&&console.warn(`Missing translation '${g}'`)})}t.setTranslations=(0,e.action)((h,{validate:x=!1}={})=>{x&&a(h,n),o(n,h)});const l=()=>(0,e.toJS)(n);t.getTranslations=l;const s={},f=h=>{const x=r(n,h);if(x!==void 0)return x;s[h]||(s[h]=!0,console.warn(`Missing translation '${h}'`));const w=h.split("."),v=w[w.length-1]||" ";return v.charAt(0).toUpperCase()+v.slice(1)};t.t=f})(MS);(function(t){var e=_e&&_e.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(t,"__esModule",{value:!0}),t.WorkspaceCanvas=void 0;const n=e(Ze),r=ti,i=e(n9),o=gS,a=vS,l=mS,s=MS,f=`Polotno warning: <Workspace /> component can not automatically detect its size.
|
|
300
|
+
`};async function R({json:S,elementHook:E}){const P=await _({json:S,elementHook:E});return C({dom:P})}})(PS);var Yg={},O_;function CS(){return O_||(O_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Page=void 0;const e=ni,n=t0,r=Lc(),i=x2(),o=Lc(),a=su;t.Page=e.types.model("Page",{id:e.types.identifier,children:e.types.array(e.types.late(()=>r.ElementTypes)),width:e.types.optional(e.types.union(e.types.number,e.types.literal("auto")),"auto"),height:e.types.optional(e.types.union(e.types.number,e.types.literal("auto")),"auto"),background:"white",bleed:0,custom:e.types.frozen(),duration:5e3,_exporting:!1,_rendering:!1,_forceMount:!1}).postProcessSnapshot(l=>{const s=Object.assign({},l),f={};for(var h in s)h[0]!=="_"&&(f[h]=l[h]);return f}).views(l=>({get store(){return(0,e.getParentOfType)(l,i.Store)}})).views(l=>({get startTime(){let s=0;for(const f of l.store.pages){if(f.id===l.id)return s;s+=f.duration}return s},get _exportingOrRendering(){return l._exporting||l._rendering}})).views(l=>({get computedWidth(){return l.width==="auto"?l.store.width:l.width},get computedHeight(){return l.height==="auto"?l.store.height:l.height}})).actions(l=>({toJSON:()=>JSON.parse(JSON.stringify((0,e.getSnapshot)(l))),_forEachElementUp(s,f){const h=s.map(x=>({id:x,index:l.children.findIndex(w=>w.id===x)}));h.sort((x,w)=>w.index-x.index);for(const{index:x}of h){if(x==-1)continue;const w=x<l.children.length-1&&l.children[x+1],v=s.indexOf(w==null?void 0:w.id)>=0;x===l.children.length-1||v||f(x)}},_forEachElementDown(s,f){const h=s.map(x=>({id:x,index:l.children.findIndex(w=>w.id===x)}));h.sort((x,w)=>x.index-w.index);for(const{index:x}of h){if(x==-1)continue;const w=x>0&&l.children[x-1],v=s.indexOf(w==null?void 0:w.id)>=0;x===0||v||f(x)}return!1}})).actions(l=>({clone(s={}){const f=l.toJSON();f.children.forEach(v=>{v.id=(0,n.nanoid)(10),(0,o.forEveryChild)(v,O=>{O.id=(0,n.nanoid)(10)})});const h=Object.assign(Object.assign(Object.assign({},f),{id:(0,n.nanoid)(10)}),s),x=l.store.addPage(h),w=l.store.pages.indexOf(l);x.setZIndex(w+1),x.select()},setZIndex(s){l.store.setPageZIndex(l.id,s)},set(s){Object.assign(l,s)},select(){l.store.selectPage(l.id)},addElement(s,{skipSelect:f=!1}={}){const h=o.TYPES_MAP[s.type];if(!h)return void console.error("Can not find model with type "+s.type);"children"in s&&Array.isArray(s.children)&&s.children.forEach(w=>{w.id=(0,n.nanoid)(10)});const x=h.create(Object.assign({id:(0,n.nanoid)(10)},s));return l.children.push(x),x.selectable&&!f&&l.store.selectElements([x.id]),x},canMoveElementsUp(s){let f=!1;return l._forEachElementUp(s,()=>{f=f||!0}),f},moveElementsUp(s){l._forEachElementUp(s,f=>{const h=l.children[f];(0,e.detach)(h),l.children.splice(f+1,0,h)})},canMoveElementsTop(s){return this.canMoveElementsUp(s)},moveElementsTop(s){const f=[],h=[];l.children.forEach(x=>{s.indexOf(x.id)>=0?f.push(x):h.push(x)}),l.children.replace(h.concat(f))},canMoveElementsDown(s){let f=!1;return l._forEachElementDown(s,()=>{f=f||!0}),f},moveElementsDown(s){l._forEachElementDown(s,f=>{const h=l.children[f];(0,e.detach)(h),l.children.splice(f-1,0,h)})},canMoveElementsBottom(s){return this.canMoveElementsDown(s)},moveElementsBottom(s){const f=[],h=[];l.children.forEach(x=>{s.indexOf(x.id)>=0?f.push(x):h.push(x)}),l.children.replace(f.concat(h))},setElementZIndex(s,f){const h=l.children.find(x=>x.id===s);h&&((0,e.detach)(h),l.children.remove(h),l.children.splice(f,0,h))},setSize({width:s,height:f,useMagic:h,softChange:x}){if(h){const w=[],v=N=>N.type==="image"&&N.x<1&&N.y<1&&N.width>=l.computedWidth-2&&N.height>=l.computedHeight-2;(0,o.forEveryChild)(l,N=>{N.type!=="group"&&(v(N)||w.push(N))});const O=w.length?(0,a.getTotalClientRect)(w):{x:0,y:0,width:l.computedWidth,height:l.computedHeight},g=1/4,b=Math.max(0,Math.min(O.x,l.computedWidth-O.x-O.width)),p=l.computedWidth*g,y=Math.max(0,b-p),d=Math.max(0,Math.min(O.y,l.computedHeight-O.y-O.height)),m=l.computedHeight*g,_=Math.max(0,d-m),A=l.computedWidth-2*y,C=l.computedHeight-2*_,R=s/A,S=f/C,E=Math.min(R,S),P=(s-A*E)/2-y*E,T=(f-C*E)/2-_*E;(0,o.forEveryChild)(l,N=>{N.type!=="group"&&(v(N)?N.set({x:N.x*E,y:N.y*E,width:N.width*R,height:N.height*S,cropX:0,cropY:0,cropWidth:1,cropHeight:1}):(N.set({x:P+N.x*E,y:T+N.y*E,width:N.width*E,height:N.height*E}),N.type==="text"?N.set({fontSize:N.fontSize*E}):N.type==="figure"&&N.set({strokeWidth:N.strokeWidth*E})))})}x||(l.width=s),x||(l.height=f)}})).actions(l=>({moveElementUp(s){console.warn("page.moveElementUp(id) is deprecated. Please use page.moveElementsUp([id1, id2]) instead."),l.moveElementsUp([s])},moveElementDown(s){console.warn("page.moveElementDown(id) is deprecated. Please use page.moveElementsDown([id1, id2]) instead."),l.moveElementsDown([s])},moveElementTop(s){console.warn("page.moveElementTop(id) is deprecated. Please use page.moveElementsTop([id1, id2]) instead."),l.moveElementsTop([s])},moveElementBottom(s){console.warn("page.moveElementBottom(id) is deprecated. Please use page.moveElementsBottom([id1, id2]) instead."),l.moveElementsBottom([s])},play(){l.store.play({startTime:l.startTime,endTime:l.startTime+l.duration})}}))}(Yg)),Yg}var kS={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Audio=void 0;const e=ni;t.Audio=e.types.model("Audio",{id:e.types.identifier,src:"",duration:0,startTime:0,endTime:1,volume:1,delay:0}).actions(n=>({toJSON:()=>Object.assign({},(0,e.getSnapshot)(n))})).actions(n=>({set(r){Object.assign(n,r)}}))})(kS);var x_;function x2(){return x_||(x_=1,function(t){var e=_e&&_e.__createBinding||(Object.create?function(S,E,P,T){T===void 0&&(T=P);var N=Object.getOwnPropertyDescriptor(E,P);N&&!("get"in N?!E.__esModule:N.writable||N.configurable)||(N={enumerable:!0,get:function(){return E[P]}}),Object.defineProperty(S,T,N)}:function(S,E,P,T){T===void 0&&(T=P),S[T]=E[P]}),n=_e&&_e.__setModuleDefault||(Object.create?function(S,E){Object.defineProperty(S,"default",{enumerable:!0,value:E})}:function(S,E){S.default=E}),r=_e&&_e.__importStar||function(S){if(S&&S.__esModule)return S;var E={};if(S!=null)for(var P in S)P!=="default"&&Object.prototype.hasOwnProperty.call(S,P)&&e(E,S,P);return n(E,S),E},i=_e&&_e.__rest||function(S,E){var P={};for(var T in S)Object.prototype.hasOwnProperty.call(S,T)&&E.indexOf(T)<0&&(P[T]=S[T]);if(S!=null&&typeof Object.getOwnPropertySymbols=="function"){var N=0;for(T=Object.getOwnPropertySymbols(S);N<T.length;N++)E.indexOf(T[N])<0&&Object.prototype.propertyIsEnumerable.call(S,T[N])&&(P[T[N]]=S[T[N]])}return P},o=_e&&_e.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(t,"__esModule",{value:!0}),t.Store=t.Font=void 0,t.createStore=R;const a=ni,l=_S,s=t0,f=o(ki),h=wS,x=SS,w=ES,v=E2(),O=r(iu),g=Yi,b=e0,p=O2,y=OS,d=xS,m=PS,_=CS(),A=Lc(),C=kS;function R({key:S,showCredit:E}={key:"",showCredit:!1}){return t.Store.create({_forceShowCredit:E,_key:S})}(0,a.setLivelinessChecking)("ignore"),t.Font=a.types.model("Font",{fontFamily:a.types.string,url:a.types.optional(a.types.string,""),styles:a.types.frozen()}).preProcessSnapshot(S=>Object.assign(Object.assign({},S),{fontFamily:S.fontFamily||S.name})),t.Store=a.types.model("Store",{role:"",pages:a.types.array(_.Page),fonts:a.types.array(t.Font),audios:a.types.array(C.Audio),width:1080,height:1080,currentTime:0,isPlaying:!1,scale:1,scaleToFit:1,unit:"px",dpi:72,bleedVisible:!1,rulesVisible:!1,openedSidePanel:"",previousOpenedSidePanel:"",custom:a.types.frozen(),selectedElementsIds:a.types.array(a.types.string),animatedElementsIds:a.types.array(a.types.string),history:a.types.optional(l.UndoManager,{targetPath:"../pages"}),_elementsPixelRatio:Math.min(2,window.devicePixelRatio||1),_activePageId:"",_forceShowCredit:!1,_key:"",_validated:!1}).views(S=>({get _bleedVisible(){return console.warn("store._bleedVisible is deprecated. Please use store.bleedVisible instead."),S.bleedVisible},get selectedElements(){return S.selectedElementsIds.map(E=>{for(const P of S.pages)for(const T of P.children)if(T.id===E)return T}).filter(E=>!!E)},get children(){return S.pages},get selectedShapes(){const E=[];return(0,A.forEveryChild)({children:S.selectedElements},P=>{P.type!=="group"&&E.push(P)}),E},get activePage(){return S.pages.slice().find(E=>E.id===S._activePageId)||(S.pages.length?S.pages[0]:null)},get duration(){let E=0;return S.pages.forEach(P=>{E+=P.duration}),E},get _hasCroppedImages(){return S.find(E=>E.type==="image"&&E._cropModeEnabled)},find(E){let P;return(0,A.forEveryChild)({children:S.pages},T=>{if(!P&&E(T))return P=T,!0}),P},getElementById:E=>S.find(P=>P.id===E)})).actions(S=>{let E=0,P=null,T=!1;return{afterCreate(){S.history.canUndo},setCurrentTime(N){S.currentTime=N},_togglePlaying(N=!S.isPlaying){S.isPlaying=N},play({animatedElementsIds:N=[],startTime:U=0,currentTime:G=0,endTime:Z=S.duration,repeat:W=!1}={}){G&&(console.warn("currentTime property of store.play() is deprecated. Please use startTime instead."),U=G),S.animatedElementsIds=(0,a.cast)(N),S.currentTime=U,S.isPlaying=!0,E=Date.now(),P=Z,T=W,requestAnimationFrame(S.seek)},checkActivePage(){let N=0;for(const U of S.pages){if(S.currentTime>=U.startTime&&S.currentTime<U.startTime+U.duration){S.selectPage(U.id);break}N+=U.duration}},seek(){if(!S.isPlaying)return;const N=Date.now(),U=N-E;E=N,S.currentTime+=U,S.checkActivePage();const G=P||S.duration;S.isPlaying&&S.currentTime<G?requestAnimationFrame(S.seek):S.isPlaying&&T?(S.currentTime=0,requestAnimationFrame(S.seek)):S.stop()},stop(){S.isPlaying=!1,S.currentTime=0,S.animatedElementsIds=(0,a.cast)([]),S.checkActivePage()}}}).actions(S=>({__(){S._validated||((0,v.validateKey)(S._key,S._forceShowCredit),S._validated=!0)},set(E){Object.assign(S,E)},setUnit({unit:E,dpi:P}){S.unit=E||S.unit,S.dpi=P||S.dpi},setRole(E){S.role=E},addPage(E){const P=_.Page.create(Object.assign({id:(0,s.nanoid)(10)},E));return S.pages.push(P),S._activePageId=P.id,P},selectPage(E){S._activePageId=E},selectElements(E){const P=E.map(T=>S.getElementById(T)).sort((T,N)=>T.page.children.indexOf(T)-T.page.children.indexOf(N)).filter(T=>!!T).map(T=>T.id);S.selectedElementsIds=(0,a.cast)(P)},toggleBleed(E){S.bleedVisible=E??!S.bleedVisible},toggleRulers(E){S.rulesVisible=E??!S.rulesVisible},openSidePanel(E){S.openedSidePanel!==E&&(S.previousOpenedSidePanel=S.openedSidePanel,S.openedSidePanel=E)},setScale(E){S.scale=E},_setScaleToFit(E){S.scaleToFit=E},setElementsPixelRatio(E){S._elementsPixelRatio=E},setSize(E,P,T){S.pages.forEach(N=>{N.setSize({width:E,height:P,useMagic:T,softChange:!0})}),S.width=E,S.height=P},setPageZIndex(E,P){const T=S.pages.find(N=>N.id===E);T&&((0,a.detach)(T),S.pages.remove(T),S.pages.splice(P,0,T))},deletePages(E){const P=S.pages.indexOf(S.activePage);E.forEach(U=>{const G=S.pages.find(Z=>Z.id===U);(0,a.destroy)(G)});const T=Math.min(S.pages.length-1,P),N=S.pages[T];N&&(S._activePageId=N.id),S.selectedElementsIds=(0,a.cast)(S.selectedElementsIds.filter(U=>S.getElementById(U)))},groupElements(E){const P=E.map(U=>S.getElementById(U));P.forEach(U=>{U&&(0,a.detach)(U)});const T=S.activePage,N={id:(0,s.nanoid)(10),children:P,type:"group"};return T.children.push(N),S.selectedElementsIds=(0,a.cast)([N.id]),N},ungroupElements(E){const P=E.map(N=>S.getElementById(N)),T=[];P.forEach(N=>{if(N&&N.type==="group"){const U=N.page,G=U.children.indexOf(N);N.children.forEach(Z=>{T.push(Z.id)}),N.children.forEach(Z=>{(0,a.detach)(Z),U.children.push(Z)}),U.children.splice(G,1)}}),S.selectedElementsIds=(0,a.cast)(T)},deleteElements(E){const P=[];S.find(T=>(E.includes(T.id)&&P.push(T),!1)),P.forEach(T=>{(0,a.destroy)(T)}),S.selectedElementsIds=(0,a.cast)(S.selectedElementsIds.filter(T=>S.getElementById(T)))},on(E,P){if(E==="change"){let T=S.toJSON();return(0,a.onSnapshot)(S,N=>{const U=S.toJSON();!(0,p.deepEqual)(T,U)&&(T=U,P(U))})}},async _toCanvas({pixelRatio:E,ignoreBackground:P,pageId:T,mimeType:N,includeBleed:U,_skipTimeout:G,quickMode:Z=!1}={}){var W;const H=E||1;T=T||((W=S.pages[0])===null||W===void 0?void 0:W.id);const L=S.pages.find(me=>me.id===T);if(!L)throw new Error(`No page for export with id ${T}`);Z?L==null||L.set({_forceMount:!0}):L==null||L.set({_exporting:!0});const M=await(0,y.waitTillAvailable)(()=>f.default.stages.find(me=>me.getAttr("pageId")===T));if(!M)throw L==null||L.set({_forceMount:!1,_exporting:!1}),new Error(`Export is failed. Can not find stage for page ${T}. Looks like <Workspace /> component is not mounted, but it is required in order to process the export.`);const D=!!M.findOne(".page-container"),B=S._elementsPixelRatio;H>S._elementsPixelRatio&&S.setElementsPixelRatio(H),await S.waitLoading({_skipTimeout:G});const V=M.findOne(".page-container");if(!V)throw S.setElementsPixelRatio(B),L==null||L.set({_forceMount:!1,_exporting:!1}),new Error(`Export is failed. Can't find page container. ${D}`);M.find("Transformer").forEach(me=>me.visible(!1)),V.find(".page-background").forEach(me=>me.shadowEnabled(!1)),V.find(".page-background").forEach(me=>me.strokeEnabled(!1)),V.find(".highlighter").forEach(me=>me.visible(!1));const Y=V.findOne(".page-background-group"),F=Y.clip();Y.clip({x:null,y:null,width:null,height:null});const $=V.findOne(".elements-container"),z=$.clip();$.clip({x:null,y:null,width:null,height:null});const K=V.find(me=>me.getAttr("hideInExport"));K.forEach(me=>{me.setAttr("oldVisible",me.visible()),me.hide()});const X=V.find(me=>!me.visible()&&me.getAttr("editModeEnabled"));X.forEach(me=>{me.setAttr("oldVisible",me.visible()),me.show()}),P&&V.find(".page-background").forEach(me=>me.hide());const Q=U?L.bleed:0;let J=Q;!S.bleedVisible&&U||(S.bleedVisible||U?S.bleedVisible&&U?J=0:S.bleedVisible&&!U&&(J=-L.bleed):J=0);const ne=document.createElement("canvas");ne.width=Math.round((L.computedWidth+2*Q)*H),ne.height=Math.round((L.computedHeight+2*Q)*H);const ie=ne.getContext("2d");N==="image/jpeg"&&(ie.fillStyle="white",ie.fillRect(0,0,ne.width,ne.height));const ae=V.scale();V.scale({x:1,y:1});const he=V.toCanvas({x:V.x()-J,y:V.y()-J,width:L.computedWidth+2*Q,height:L.computedHeight+2*Q,pixelRatio:H});return V.scale(ae),ie.drawImage(he,0,0,ne.width,ne.height),f.default.Util.releaseCanvas(he),P&&V.find(".page-background").forEach(me=>me.show()),K.forEach(me=>{me.visible(me.getAttr("oldVisible"))}),X.forEach(me=>{me.visible(me.getAttr("oldVisible"))}),V.find(".page-background").forEach(me=>me.shadowEnabled(!0)),V.find(".page-background").forEach(me=>me.strokeEnabled(!0)),M.find("Transformer").forEach(me=>me.visible(!0)),V.find(".highlighter").forEach(me=>me.visible(!0)),Y.clip(F),$.clip(z),S.setElementsPixelRatio(B),L==null||L.set({_exporting:!1,_forceMount:!1}),ne},async toDataURL(E={}){var{mimeType:P,quality:T}=E,N=i(E,["mimeType","quality"]);const U=await S._toCanvas(Object.assign({mimeType:P},N)),G=U.toDataURL(P,T);return f.default.Util.releaseCanvas(U),G},async toBlob(E={}){var{mimeType:P,quality:T}=E,N=i(E,["mimeType","quality"]);const U=await S._toCanvas(Object.assign({mimeType:P},N)),G=await new Promise(Z=>{U.toBlob(Z,P,T)});return f.default.Util.releaseCanvas(U),G},async saveAsImage(E={}){var{fileName:P}=E,T=i(E,["fileName"]);const N=T.mimeType||"image/png",U=N.split("/")[1];(0,h.downloadFile)(await S.toDataURL(T),P||"polotno."+U,N)},async _toPDF(E){const P=E.dpi||S.dpi,T=E.parallel||1,N=E.unit||(S.unit==="px"?"mm":S.unit),U=E.pixelRatio||1,G=E.pageIds||S.pages.map(K=>K.id),Z=S.pages.filter(K=>G.includes(K.id)),W=await(0,x.getJsPDF)(),H=K=>(0,b.pxToUnit)({px:K,unit:N,dpi:P}),L=E.cropMarkSize||0,M=H(L),D=Z[0]||{},B=E.includeBleed?D.bleed:0,V=H(D.computedWidth+2*B+2*M),Y=H(D.computedHeight+2*B+2*M);var F=new W({unit:N,orientation:V>Y?"landscape":"portrait",format:[V,Y],compress:!0,putOnlyUsedFonts:!0});F.deletePage(1);const $=((K,X)=>{for(var Q=[],J=0;J<K.length;J+=X)Q.push(K.slice(J,J+X));return Q})(Z,T);let z=0;for(const K of $){const X=K.map(async Q=>{const J=E.includeBleed?Q.bleed:0,ne=Q.computedWidth+2*J+2*L,ie=Q.computedHeight+2*J+2*L,ae=H(ne),he=H(ie);let me=0,Ce=U;for(;me<10;){me+=1,me===2&&console.error("Polotno can not export PDF with current settings. Quality is automatically reduced.");const re=await S.toDataURL(Object.assign(Object.assign({},E),{pageId:Q.id,pixelRatio:Ce}));if(re.length>20)return E.onProgress&&E.onProgress(++z/G.length*.9),{url:re,width:ae,height:he,widthPx:ne,heightPx:ie};Ce*=.8}});(await Promise.all(X)).forEach(({url:Q,width:J,height:ne,widthPx:ie,heightPx:ae})=>{F.addPage([J,ne],J>ne?"landscape":"portrait");const he=F.getCurrentPageInfo();he.pageContext.cropBox={bottomLeftX:L,bottomLeftY:L,topRightX:ie-L,topRightY:ae-L},he.pageContext.bleedBox={bottomLeftX:L+B,bottomLeftY:L+B,topRightX:ie-L-B,topRightY:ae-L-B},M&&(F.setLineWidth(H(1)),F.line(2*M,0,2*M,M),F.line(0,2*M,M,2*M),F.line(J-2*M,0,J-2*M,M),F.line(J,2*M,J-M,2*M),F.line(0,ne-2*M,M,ne-2*M),F.line(2*M,ne,2*M,ne-M),F.line(J,ne-2*M,J-M,ne-2*M),F.line(J-2*M,ne,J-2*M,ne-M)),F.addImage(Q,M,M,J-2*M,ne-2*M,void 0,"FAST")})}return F},toPDFDataURL:async E=>(await S._toPDF(Object.assign({mimeType:"image/jpeg"},E))).output("datauristring"),async toGIFDataURL(E={}){const P=E.pixelRatio||1,T=await(0,w.createGIF)({width:S.width*P,height:S.height*P}),N=1e3/(E.fps||10),U=S.duration/N;for(let G=0;G<U-1;G++){const Z=G*N||1;S.setCurrentTime(Z);let W=0,H="";for(const M of S.pages)if(W+=M.duration,M.set({_rendering:W>Z}),W>Z){H=M.id;break}const L=await S._toCanvas({pixelRatio:P,pageId:H,_skipTimeout:!0});T.addFrame(L.getContext("2d"),{delay:N,copy:!0})}for(const G of S.pages)G.set({_rendering:!1});return S.stop(),T.render(),new Promise(G=>{T.on("finished",function(Z){(function(W,H){var L=new FileReader;L.onload=function(M){H(M.target.result)},L.readAsDataURL(W)})(Z,G)})})},async saveAsGIF(E={}){var{fileName:P}=E,T=i(E,["fileName"]);const N=await S.toGIFDataURL(T);(0,h.downloadFile)(N,P||"polotno.gif")},async toHTML({elementHook:E}={elementHook:void 0}){const P=S.toJSON();return(0,d.jsonToHTML)({json:P,elementHook:E})},async saveAsHTML({fileName:E}={}){const P=await S.toHTML(),T="data:text/html;base64,"+window.btoa(unescape(encodeURIComponent(P)));(0,h.downloadFile)(T,E||"polotno.html")},async toSVG({elementHook:E,pageId:P}={elementHook:void 0,pageId:void 0}){var T;const N=S.toJSON();P=P||((T=N.pages[0])===null||T===void 0?void 0:T.id);const U=N.pages.find(G=>G.id===P);return(0,m.jsonToSVG)({json:Object.assign(Object.assign({},N),{pages:U?[U]:[]}),elementHook:E})},async saveAsSVG({fileName:E,elementHook:P,pageId:T}={}){const N=await S.toSVG({elementHook:P,pageId:T}),U="data:text/svg;base64,"+window.btoa(unescape(encodeURIComponent(N)));(0,h.downloadFile)(U,E||"polotno.svg")},async saveAsPDF(E={}){var{fileName:P}=E,T=i(E,["fileName"]);(await S._toPDF(Object.assign({mimeType:"image/jpeg"},T))).save(P||"polotno.pdf")},async waitLoading({_skipTimeout:E=!1}={}){E||await new Promise(P=>setTimeout(P,50)),await(0,g.whenLoaded)()},toJSON:()=>({width:S.width,height:S.height,fonts:(0,a.getSnapshot)(S.fonts),pages:(0,a.getSnapshot)(S.pages),audios:(0,a.getSnapshot)(S.audios),unit:S.unit,dpi:S.dpi,custom:S.custom}),loadJSON(E,P=!1){var T;const N=Object.assign({},E),U=S.pages.indexOf(S.activePage);let G=(T=N.pages[U]||N.pages[0])===null||T===void 0?void 0:T.id;N._activePageId=G;const Z=Object.assign({},(0,a.getSnapshot)(S));Object.assign(Z,N),Z.history=P?S.history.toJSON():{history:[],undoIdx:-1},(0,a.applySnapshot)(S,Z)},clear({keepHistory:E=!1}={}){const P=S.pages.map(T=>T.id);S.deletePages(P),E||S.history.clear()},addFont(E){S.removeFont(E.fontFamily),S.fonts.push(E),S.loadFont(E.fontFamily)},removeFont(E){S.fonts.filter(P=>P.fontFamily===E).forEach(P=>(0,a.destroy)(P))},addAudio(E){const P=C.Audio.create(Object.assign({id:(0,s.nanoid)(10)},E));S.audios.push(P)},removeAudio(E){const P=S.audios.find(T=>T.id===E);P&&S.audios.remove(P)},async loadFont(E){const P=S.fonts.find(N=>N.fontFamily===E)||O.globalFonts.find(N=>N.fontFamily===E);let T=[{fontStyle:"normal",fontWeight:"normal"}];return P?(P.styles&&(T=P.styles.map(N=>({fontStyle:N.fontStyle||"normal",fontWeight:N.fontWeight||"normal"}))),O.injectCustomFont(P)):O.injectGoogleFont(E),Promise.all(T.map(N=>O.loadFont(E,N.fontStyle,N.fontWeight)))},validate:E=>t.Store.validate(E,[{path:"",type:t.Store}]).map(P=>({path:"store"+P.context.map(T=>T.path).join("."),message:P.message}))})),t.default=R}(Wg)),Wg}var P_;function TS(){return P_||(P_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Node=void 0;const e=ni,n=t0,r=x2(),i=CS(),o=Lc();t.Node=e.types.model("Node",{id:e.types.identifier,type:"none",name:"",opacity:1,custom:e.types.frozen(),visible:!0,selectable:!0,removable:!0,alwaysOnTop:!1,showInExport:!0}).preProcessSnapshot(a=>{for(var l in a)a[l]===null&&(a[l]=void 0);return a}).postProcessSnapshot(a=>{const l=Object.assign({},a),s={};for(var f in l)f[0]!=="_"&&(s[f]=a[f]);return s}).views(a=>({get locked(){return!(a.draggable||a.contentEditable||a.styleEditable||a.resizable)},get page(){return(0,e.getParentOfType)(a,i.Page)},get store(){return(0,e.getParentOfType)(a,r.Store)},get top(){let l=a;for(;;){if(!(0,e.hasParentOfType)(l,o.GroupElement))return l;l=(0,e.getParentOfType)(l,o.GroupElement)}},get parent(){return(0,e.hasParentOfType)(a,o.GroupElement)?(0,e.getParentOfType)(a,o.GroupElement):(0,e.hasParentOfType)(a,i.Page)?(0,e.getParentOfType)(a,i.Page):(0,e.hasParentOfType)(a,r.Store)?(0,e.getParentOfType)(a,r.Store):null},get zIndex(){return a.parent.children.indexOf(a)}})).actions(a=>({toJSON:()=>Object.assign({},(0,e.getSnapshot)(a))})).actions(a=>({clone(l={},{skipSelect:s=!1}={}){const f=JSON.parse(JSON.stringify(a.toJSON()));return l.id=l.id||(0,n.nanoid)(10),(0,o.forEveryChild)(f,h=>{h.id=(0,n.nanoid)(10)}),Object.assign(f,l),a.page.addElement(f,{skipSelect:s})},set(l){Object.assign(a,l)},moveUp(){a.page.moveElementsUp([a.id])},moveTop(){a.page.moveElementsTop([a.id])},moveDown(){a.page.moveElementsDown([a.id])},moveBottom(){a.page.moveElementsBottom([a.id])},setZIndex(l){a.parent.setElementZIndex(a.id,l)},beforeDestroy(){}}))}(qg)),qg}var Kg={},AS={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.registerAnimation=t.animate=t.animations=void 0;const e=su,n={right:{from:{x:-200},to:{x:0}},left:{from:{x:200},to:{x:0}},up:{from:{y:200},to:{y:0}},down:{from:{y:-200},to:{y:0}},"bottom-right":{from:{x:-200,y:-200},to:{x:0,y:0}},"bottom-left":{from:{x:200,y:-200},to:{x:0,y:0}},"top-right":{from:{x:-200,y:200},to:{x:0,y:0}},"top-left":{from:{x:200,y:200},to:{x:0,y:0}}};t.animations={fade:({dTime:o,element:a,animation:l})=>{const s=o/l.duration;return l.type==="enter"?{opacity:s*a.opacity}:{opacity:(1-s)*a.opacity}},rotate:({dTime:o,element:a,animation:l})=>{const s=o/l.duration*360;return(0,e.rotateAroundCenter)({x:a.x,y:a.y,width:a.width,height:a.height,rotation:a.rotation},s)},blink:({dTime:o,element:a,animation:l})=>{const s=l.duration,f=o%s/(s/2),h=f<=1?f:2-f;return{opacity:a.opacity*h}},bounce:({dTime:o,element:a,animation:l})=>{const s=l.duration,f=s/2,h={},x={x:a.x+a.width/3,y:a.y+a.height/3,width:a.width/3,height:a.height/3,fontSize:a.fontSize/3},w={x:a.x,y:a.y,width:a.width,height:a.height,fontSize:a.fontSize},v=o%s/f,O=v<=1?v:2-v;for(let g in x){const b=x[g],p=w[g]-b;h[g]=b+O*p}return h},move:({dTime:o,element:a,animation:l})=>{const s=n[l.data.direction]||n.right,f={};for(var h in s.from){let x=s.from[h],w=s.to[h];l.type==="exit"&&(x=s.to[h],w=-s.from[h]);const v=a[h]+x,O=a[h]+w-v;f[h]=v+o/l.duration*O}return f},zoom:({dTime:o,element:a,animation:l})=>{const s={},f={x:a.x+a.width/3,y:a.y+a.height/3,width:a.width/3,height:a.height/3,fontSize:a.fontSize/3},h={x:a.x,y:a.y,width:a.width,height:a.height,fontSize:a.fontSize};for(var x in f){let w=f[x],v=h[x];if(l.type==="exit"){const g=w;w=v,v=g}const O=v-w;s[x]=w+o/l.duration*O}return s}};const r=({element:o,dTime:a,animation:l})=>{const s=t.animations[l.name];return s?s({element:o,dTime:a,animation:l}):(console.error("Can not find animation type: "+l.name),{})};t.animate=r;const i=(o,a)=>{};t.registerAnimation=i})(AS);var C_;function uu(){return C_||(C_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Shape=t.Animation=void 0;const e=ni,n=AS,r=Qi,i=TS();t.Animation=e.types.model("Animation",{delay:0,duration:500,enabled:!0,type:e.types.enumeration("Type",["enter","exit","loop"]),name:"none",data:e.types.frozen({})}),t.Shape=i.Node.named("Shape").props({x:0,y:0,width:100,height:100,rotation:0,opacity:1,animations:e.types.array(t.Animation),blurEnabled:!1,blurRadius:10,brightnessEnabled:!1,brightness:0,sepiaEnabled:!1,grayscaleEnabled:!1,shadowEnabled:!1,shadowBlur:5,shadowOffsetX:0,shadowOffsetY:0,shadowColor:"black",shadowOpacity:1,visible:!0,draggable:!0,resizable:!0,selectable:!0,contentEditable:!0,styleEditable:!0,alwaysOnTop:!1,showInExport:!0}).preProcessSnapshot(o=>{const a=Object.assign(Object.assign({},o),{x:o.x||0,y:o.y||0});return"width"in o&&(a.width=a.width||1),"height"in o&&(a.height=a.height||1),o.locked&&(a.draggable=!1,a.contentEditable=!1,a.styleEditable=!1,a.resizable=!1,a.removable=!1),a}).views(o=>{const a=(0,r.observable)({x:o.x,y:o.y,width:o.width,height:o.height,rotation:o.rotation,opacity:o.opacity,color:o.color,fontSize:o.fontSize}),l=(0,r.action)(s=>{Object.assign(a,s)});return{get a(){const{currentTime:s}=o.store;if(l({x:o.x,y:o.y,width:o.width,height:o.height,rotation:o.rotation,opacity:o.opacity,color:o.color,fontSize:o.fontSize}),s===0)return a;const f=s-o.page.startTime;if(f>o.page.duration||f<0)return a;const h=o.store.animatedElementsIds;if(h.length&&!h.includes(o.id))return a;const x=o.animations.find(O=>O.type==="enter");if(x!=null&&x.enabled&&f<x.delay&&l({opacity:0}),x!=null&&x.enabled&&f>=x.delay&&f<=x.delay+x.duration){const O=f-x.delay,g=(0,n.animate)({element:o,animation:x,dTime:O});l(g)}const w=o.animations.find(O=>O.type==="exit");if(w!=null&&w.enabled&&f>=o.page.duration-w.duration-w.delay&&f<=o.page.duration-w.delay){const O=f-(o.page.duration-w.duration-w.delay),g=(0,n.animate)({element:o,animation:w,dTime:O});l(g)}w!=null&&w.enabled&&f>=o.page.duration-w.delay&&l({opacity:0});const v=o.animations.find(O=>O.type==="loop");if(v!=null&&v.enabled){const O=f,g=(0,n.animate)({element:o,animation:v,dTime:O});l(g)}return a},animated:s=>o.a[s]}}).actions(o=>({setAnimation(a,l){const s=o.animations.find(f=>f.type===a);s?Object.assign(s,l):o.animations.push(Object.assign({type:a},l))}}))}(Kg)),Kg}var Xg={},k_;function vj(){return k_||(k_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.TextElement=void 0;const e=ni,n=uu();t.TextElement=n.Shape.named("Text").props({type:"text",text:"",placeholder:"",fontSize:14,fontFamily:"Roboto",fontStyle:"normal",fontWeight:"normal",textDecoration:"",fill:"black",align:"center",width:100,height:0,verticalAlign:"top",strokeWidth:0,stroke:"black",lineHeight:e.types.optional(e.types.union(e.types.number,e.types.string),1.2),letterSpacing:0,_editModeEnabled:!1,backgroundEnabled:!1,backgroundColor:"#7ED321",backgroundOpacity:1,backgroundCornerRadius:.5,backgroundPadding:.5}).preProcessSnapshot(r=>Object.assign({},r)).actions(r=>({toggleEditMode(i){r._editModeEnabled=i??!r._editModeEnabled,r._editModeEnabled?r.store.history.startTransaction():r.store.history.endTransaction()}}))}(Xg)),Xg}var Zg={},T_;function RS(){return T_||(T_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ImageElement=void 0;const e=uu();t.ImageElement=e.Shape.named("Image").props({type:"image",width:100,height:100,src:"",cropX:0,cropY:0,cropWidth:1,cropHeight:1,cornerRadius:0,flipX:!1,flipY:!1,clipSrc:"",borderColor:"black",borderSize:0,keepRatio:!1,_cropModeEnabled:!1}).actions(n=>({toggleCropMode(r){n._cropModeEnabled=r??!n._cropModeEnabled,n._cropModeEnabled?n.store.history.startTransaction():n.store.history.endTransaction()},beforeDestroy(){n._cropModeEnabled&&n.store.history.endTransaction()}}))}(Zg)),Zg}var Qg={},A_;function mj(){return A_||(A_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.VideoElement=void 0;const e=RS();t.VideoElement=e.ImageElement.named("Video").props({type:"video",duration:0,startTime:0,endTime:1,volume:1})}(Qg)),Qg}var Jg={},R_;function yj(){return R_||(R_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.LineElement=void 0;const e=ni,n=uu();t.LineElement=n.Shape.named("Line").props({type:"line",width:400,height:10,color:"black",dash:e.types.array(e.types.number),startHead:"",endHead:""}).actions(r=>({}))}(Jg)),Jg}var ev={},M_;function bj(){return M_||(M_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.SVGElement=void 0;const e=ni,n=uu();t.SVGElement=n.Shape.named("SVG").props({type:"svg",src:"",maskSrc:"",cropX:0,cropY:0,cropWidth:1,cropHeight:1,keepRatio:!0,flipX:!1,flipY:!1,width:100,height:100,borderColor:"black",borderSize:0,cornerRadius:0,colorsReplace:e.types.map(e.types.string)}).preProcessSnapshot(r=>Object.assign(Object.assign({},r),{src:r.src||r.svgSource})).actions(r=>({replaceColor(i,o){r.colorsReplace.set(i,o)}}))}(ev)),ev}var tv={},L_;function _j(){return L_||(L_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.FigureElement=void 0;const e=ni,n=uu();t.FigureElement=n.Shape.named("Figure").props({type:"figure",subType:"rect",fill:"rgb(0, 161, 255)",dash:e.types.array(e.types.number),strokeWidth:0,stroke:"rgba(98, 197, 255, 1)",cornerRadius:0})}(tv)),tv}var N_;function Lc(){return N_||(N_=1,function(t){var e=_e&&_e.__rest||function(b,p){var y={};for(var d in b)Object.prototype.hasOwnProperty.call(b,d)&&p.indexOf(d)<0&&(y[d]=b[d]);if(b!=null&&typeof Object.getOwnPropertySymbols=="function"){var m=0;for(d=Object.getOwnPropertySymbols(b);m<d.length;m++)p.indexOf(d[m])<0&&Object.prototype.propertyIsEnumerable.call(b,d[m])&&(y[d[m]]=b[d[m]])}return y};Object.defineProperty(t,"__esModule",{value:!0}),t.TYPES_MAP=t.GroupElement=t.ElementTypes=t.forEveryChild=void 0,t.registerShapeModel=g;const n=ni,r=t0,i=TS(),o=uu(),a=vj(),l=RS(),s=mj(),f=yj(),h=bj(),x=_j(),w=(b,p)=>{if(b.children)for(const y of b.children){if(p(y)===!0)break;(0,t.forEveryChild)(y,p)}};t.forEveryChild=w;const v=[...new Array(20)].map((b,p)=>n.types.late(()=>O[p]));t.ElementTypes=n.types.union({dispatcher:b=>{const p=t.TYPES_MAP[b.type];if(!p)throw new Error(`Unknown element type: "${b.type}"`);return p}},h.SVGElement,a.TextElement,l.ImageElement,f.LineElement,s.VideoElement,x.FigureElement,n.types.late(()=>t.GroupElement),...v),t.GroupElement=i.Node.named("Group").props({type:"group",children:n.types.array(t.ElementTypes)}).views(b=>({get draggable(){let p=!0;return(0,t.forEveryChild)(b,y=>{y.draggable||(p=!1)}),p},get resizable(){let p=!0;return(0,t.forEveryChild)(b,y=>{y.resizable||(p=!1)}),p},get contentEditable(){let p=!0;return(0,t.forEveryChild)(b,y=>{y.contentEditable||(p=!1)}),p},get styleEditable(){let p=!0;return(0,t.forEveryChild)(b,y=>{y.styleEditable||(p=!1)}),p},get locked(){let p=!0;return(0,t.forEveryChild)(b,y=>{y.locked||(p=!1)}),p}})).actions(b=>({set(p){var{draggable:y,contentEditable:d,styleEditable:m,resizable:_}=p,A=e(p,["draggable","contentEditable","styleEditable","resizable"]);y!==void 0&&(0,t.forEveryChild)(b,C=>{C.set({draggable:y})}),d!==void 0&&(0,t.forEveryChild)(b,C=>{C.set({contentEditable:d})}),m!==void 0&&(0,t.forEveryChild)(b,C=>{C.set({styleEditable:m})}),_!==void 0&&(0,t.forEveryChild)(b,C=>{C.set({resizable:_})}),Object.assign(b,A)},addElement(p,{skipSelect:y=!1}={}){const d=t.TYPES_MAP[p.type];if(!d)return void console.error("Can not find model with type "+p.type);p.children&&p.children.forEach(_=>{_.id=(0,r.nanoid)(10)});const m=d.create(Object.assign({id:(0,r.nanoid)(10)},p));return b.children.push(m),m.selectable&&!y&&b.store.selectElements([m.id]),m},setElementZIndex(p,y){const d=b.children.find(m=>m.id===p);d&&((0,n.detach)(d),b.children.remove(d),b.children.splice(y,0,d))}}));const O=[];function g(b,p){const y=b.type;if(!y)throw new Error('You must pass "type" attribute to custom model.');let d=o.Shape.named(y).props(b);p&&(d=p(d)),t.TYPES_MAP[y]=d,O.push(d)}t.TYPES_MAP={svg:h.SVGElement,text:a.TextElement,image:l.ImageElement,group:t.GroupElement,line:f.LineElement,video:s.VideoElement,figure:x.FigureElement}}(Vg)),Vg}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.handleHotkey=l;const e=Lc();let n=[],r="";const i="polotno_clipboard",o=s=>{n=JSON.parse(JSON.stringify(s));try{localStorage.setItem(i,JSON.stringify(s))}catch{}},a=()=>{try{const s=localStorage.getItem(i);if(s)return JSON.parse(s)}catch{}return n};function l(s,f){var h,x,w,v,O,g,b,p;if(((h=document.activeElement)===null||h===void 0?void 0:h.tagName)==="INPUT"||((x=document.activeElement)===null||x===void 0?void 0:x.tagName)==="TEXTAREA"||((w=document.activeElement)===null||w===void 0?void 0:w.contentEditable)==="true")return;const y=f.selectedElements.filter(A=>A.removable),d=y.map(A=>A.id);s.keyCode!==46&&s.keyCode!==8||f.deleteElements(d);const m=s.ctrlKey||s.metaKey,_=s.shiftKey;if(m&&!_&&s.code==="KeyZ"&&(s.preventDefault(),f.history.undo()),m&&_&&s.code==="KeyZ"&&(s.preventDefault(),f.history.redo()),m&&s.code==="KeyA"){s.preventDefault();const A=(v=f.activePage)===null||v===void 0?void 0:v.children.filter(R=>R.selectable),C=(A==null?void 0:A.map(R=>R.id))||[];f.selectElements(C)}if(m&&s.code==="KeyC"&&(s.preventDefault(),r=(O=f.activePage)===null||O===void 0?void 0:O.id,o(f.selectedElements.map(A=>A.toJSON()))),m&&s.code==="KeyX"&&(s.preventDefault(),r=(g=f.activePage)===null||g===void 0?void 0:g.id,o(f.selectedElements.map(A=>A.toJSON())),f.deleteElements(y)),m&&s.code==="KeyV"){s.preventDefault();let A=0;r===((b=f.activePage)===null||b===void 0?void 0:b.id)&&(A=f.width/20),r=(p=f.activePage)===null||p===void 0?void 0:p.id,f.history.transaction(()=>{const C=[],R=a();(0,e.forEveryChild)({children:R},S=>{delete S.id,S.type!=="group"&&(S.x+=A,S.y+=A)}),R.forEach(S=>{var E;const P=(E=f.activePage)===null||E===void 0?void 0:E.addElement(S);P&&C.push(P.id)}),o(R),f.selectElements(C)})}s.code==="ArrowDown"&&(s.preventDefault(),f.selectedElements.forEach(A=>{A.draggable&&A.set({y:A.y+1})})),s.code==="ArrowUp"&&(s.preventDefault(),f.selectedElements.forEach(A=>{A.draggable&&A.set({y:A.y-1})})),s.code==="ArrowLeft"&&(s.preventDefault(),f.selectedElements.forEach(A=>{A.draggable&&A.set({x:A.x-1})})),s.code==="ArrowRight"&&(s.preventDefault(),f.selectedElements.forEach(A=>{A.draggable&&A.set({x:A.x+1})}))}})(mS);var MS={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.t=t.getTranslations=t.setTranslations=void 0;const e=Qi,n=(0,e.observable)({toolbar:{duration:"Duration",opacity:"Opacity",effects:"Effects",blur:"Blur",textBackground:"Background",backgroundCornerRadius:"Corner radius",backgroundOpacity:"Opacity",backgroundPadding:"Padding",brightness:"Brightness",sepia:"Sepia",grayscale:"Grayscale",textStroke:"Text Stroke",shadow:"Shadow",border:"Border",cornerRadius:"Corner Radius",position:"Position",layering:"Layering",toForward:"To forward",up:"Up",down:"Down",toBottom:"To bottom",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignTop:"Align top",alignMiddle:"Align middle",alignBottom:"Align bottom",flip:"Flip",flipHorizontally:"Flip horizontally",flipVertically:"Flip vertically",fitToBackground:"Fit to page",removeBackground:"Remove background",removeBackgroundTitle:"Remove background from image",cancelRemoveBackground:"Cancel",confirmRemoveBackground:"Confirm",crop:"Crop",cropDone:"Done",cropCancel:"Cancel",clip:"Apply mask",removeClip:"Remove mask",removeMask:"Remove mask",transparency:"Transparency",lockedDescription:"Object is locked. Unlock it to allow changes from canvas.",unlockedDescription:"Object is unlocked. Lock it to prevent changes from canvas.",removeElements:"Remove elements",duplicateElements:"Duplicate elements",download:"Download",saveAsImage:"Save as image",saveAsPDF:"Save as PDF",lineHeight:"Line height",letterSpacing:"Letter spacing",offsetX:"Offset X",offsetY:"Offset Y",color:"Color",selectable:"Selectable",draggable:"Draggable",removable:"Removable",resizable:"Resizable",contentEditable:"Can change content",styleEditable:"Can change style",alwaysOnTop:"Always on top",showInExport:"Show in export",ungroupElements:"Ungroup",groupElements:"Group",lineSize:"Line size",fade:"Fade",move:"Move",zoom:"Zoom",animate:"Animate",rotate:"Rotate",none:"None",bounce:"Bounce",blink:"Blink",spaceEvenly:"Space evenly",horizontalDistribution:"Horizontally",verticalDistribution:"Vertically",strokeWidth:"Stroke Width",colorPicker:{solid:"Solid",linear:"Linear"},aiText:{aiWrite:"AI write",rewrite:"Rewrite",shorten:"Shorten",continue:"Continue writing",proofread:"Proofread",tones:"Tones",friendly:"Friendly",professional:"Professional",humorous:"Humorous",formal:"Formal"}},workspace:{noPages:"There are no pages yet...",addPage:"Add page",removePage:"Remove page",duplicatePage:"Duplicate page",moveUp:"Move up",moveDown:"Move down"},scale:{reset:"Reset"},error:{removeBackground:"Ops! Something went wrong. Background can not be removed."},sidePanel:{templates:"Templates",searchTemplatesWithSameSize:"Show templates with the same size",searchPlaceholder:"Search...",otherFormats:"Other formats",noResults:"No results",error:"Loading is failed...",text:"Text",uploadFont:"Upload font",myFonts:"My fonts",photos:"Photos",videos:"Videos",animations:"Animations",effects:"Effects",elements:"Elements",shapes:"Shapes",lines:"Lines",upload:"Upload",uploadImage:"Upload Image",uploadTip:"Do you want to upload your own images?",background:"Background",resize:"Resize",layers:"Layers",layerTypes:{image:"Image",text:"Text",svg:"SVG",line:"Line",figure:"Figure",group:"Group"},layersTip:"Elements on your active page:",noLayers:"No elements on the page...",namePlaceholder:"Type element name...",useMagicResize:"Use magic resize",clipImage:"Mask image",width:"Width",height:"Height",magicResizeDescription:"Magic resize will automatically resize and move all elements on the canvas",headerText:"Header",createHeader:"Create header",subHeaderText:"Sub Header",createSubHeader:"Create sub header",bodyText:"Body text",createBody:"Create body text"},pagesTimeline:{pages:"Pages",removePage:"Remove page",addPage:"Add page",duplicatePage:"Duplicate page",removeAudio:"Remove audio"}});function r(h,x){var w,v=x.split("."),O=h;for(w=0;w<v.length;++w){if(O[v[w]]==null)return;O=O[v[w]]}return O}const i=h=>h&&typeof h=="object";function o(h,x){Object.keys(x).forEach(w=>{const v=h[w],O=x[w];i(O)&&i(v)?o(v,O):h[w]=O})}function a(h,x,w=""){Object.keys(x).forEach(v=>{const O=x[v],g=w?`${w}.${v}`:v;i(O)?i(h[v])?a(h[v],O,g):console.warn(`Missing nested translation object at '${g}'`):h[v]===void 0&&console.warn(`Missing translation '${g}'`)})}t.setTranslations=(0,e.action)((h,{validate:x=!1}={})=>{x&&a(h,n),o(n,h)});const l=()=>(0,e.toJS)(n);t.getTranslations=l;const s={},f=h=>{const x=r(n,h);if(x!==void 0)return x;s[h]||(s[h]=!0,console.warn(`Missing translation '${h}'`));const w=h.split("."),v=w[w.length-1]||" ";return v.charAt(0).toUpperCase()+v.slice(1)};t.t=f})(MS);(function(t){var e=_e&&_e.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(t,"__esModule",{value:!0}),t.WorkspaceCanvas=void 0;const n=e(Ze),r=ti,i=e(n9),o=gS,a=vS,l=mS,s=MS,f=`Polotno warning: <Workspace /> component can not automatically detect its size.
|
|
301
301
|
Width or height of parent elements is equal 0.
|
|
302
302
|
Please make sure it has non-zero size. You may need to adjust it with your styles. <Workspace /> will automatically fit into parent container.
|
|
303
303
|
For simpler debugging here is the log of the parent element:`,h=(g,b,p,y,d,m)=>{const _=n.default.useRef({width:b,height:p}),A=n.default.useRef({top:0,left:0}),C=n.default.useRef(!1),R=n.default.useRef(d.pages.length);C.current=R.current!==d.pages.length,R.current=d.pages.length,n.default.useEffect(()=>{const S=g.current,E=P=>{A.current={top:S.scrollTop,left:S.scrollLeft}};return S.addEventListener("scroll",E),()=>{S.removeEventListener("scroll",E)}},[]),n.default.useLayoutEffect(()=>{if(!g.current||C.current)return;const S=g.current,E=(A.current.left+S.offsetWidth/2)/_.current.width,P=(A.current.top+S.offsetHeight/2)/_.current.height;m.current=!0,S.scrollLeft=E*b-S.offsetWidth/2,S.scrollTop=P*p-S.offsetHeight/2,_.current={width:b,height:p}},[y,b,p])},x=({element:g,scrollTop:b=0,duration:p=300,onFinish:y=()=>{}})=>{const d=g.scrollTop,m=b-d;let _=0,A=!1;if(p===0)return g.scrollTop=b,()=>{};const C=()=>{if(A)return;_+=20;const S=R(_,d,m,p);g.scrollTop=S,_<p?setTimeout(C,20):y()},R=(S,E,P,T)=>(S/=T/2)<1?P/2*S*S+E:-P/2*(--S*(S-2)-1)+E;return C(),()=>{A=!0}},w=(g,b,p,y,d,m)=>{const _=n.default.useRef(!1),A=n.default.useRef(null),C=n.default.useRef(!1);n.default.useEffect(()=>{const S=g.current,E=()=>{d.current};return S.addEventListener("scroll",E),()=>{S.removeEventListener("scroll",E)}},[]);const R=p.pages.indexOf(p.activePage);return n.default.useLayoutEffect(()=>{if(!p.activePage||!g.current||_.current)return;const S=g.current,E=p.pages.indexOf(p.activePage)*b;let P=()=>{};return(Math.abs(E-S.scrollTop)>.5*b||C.current)&&(C.current=!0,P=x({element:S,scrollTop:E,onFinish:()=>{C.current=!1},duration:p.isPlaying?0:300})),P},[p.activePage,R,p.isPlaying]),{handleScroll:S=>{if(m||C.current)return;_.current=!0,clearTimeout(A.current),A.current=setTimeout(()=>{_.current=!1},300);const E=S.currentTarget.childNodes[0].offsetHeight,P=S.currentTarget.scrollTop,T=Math.floor((P+y.height/3)/E),N=p.pages[T];N&&p.activePage!==N&&N.select()}}},v=({store:g})=>n.default.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center"}},n.default.createElement("p",null,(0,s.t)("workspace.noPages")),n.default.createElement("button",{onClick:()=>{g.addPage()}},(0,s.t)("workspace.addPage"))),O=({width:g,height:b,xPadding:p,yPadding:y,backgroundColor:d})=>n.default.createElement("div",{style:{width:g+"px",height:b+"px",backgroundColor:d,paddingLeft:p+"px",paddingRight:p+"px",paddingTop:y+"px",paddingBottom:y+"px"}},n.default.createElement("div",{style:{width:" 100%",height:"100%",backgroundColor:"white"}}));t.WorkspaceCanvas=(0,r.observer)(({store:g,pageControlsEnabled:b,backgroundColor:p,pageBorderColor:y,activePageBorderColor:d,bleedColor:m,components:_,onKeyDown:A,paddingX:C,paddingY:R,altCloneEnabled:S=!0,visiblePagesOffset:E,renderOnlyActivePage:P})=>{var T;const N=C??20,U=R??55,[G,Z]=n.default.useState({width:100,height:100}),W=n.default.useRef(G),H=n.default.useRef(null),L=n.default.useRef(null),M=g.bleedVisible?Math.max(0,...g.pages.map(re=>re.bleed)):0,D=Math.max(...g.pages.map(re=>re.computedWidth)),B=Math.max(...g.pages.map(re=>re.computedHeight)),V=((T=g.activePage)===null||T===void 0?void 0:T.computedHeight)||0,Y=D+2*M,F=(P?V:B)+2*M,$=async({skipTimeout:re}={skipTimeout:!1})=>{if(re||await new Promise(Ve=>setTimeout(Ve,50)),H.current===null)return;const oe=H.current.getBoundingClientRect();oe.width!==0&&oe.height!==0||(console.warn(f),console.log(H.current));const we=L.current.clientWidth||oe.width,be={width:we,height:oe.height};(W.current.width!==be.width||W.current.height!==be.height)&&(Z(be),W.current=be);const te=(we-2*N)/Y,fe=g.pages.length>1?3.1:2,de=(oe.height-U*fe)/F,Ee=Math.max(Math.min(te,de),.01);g.scaleToFit!==Ee&&(g.setScale(Ee),g._setScaleToFit(Ee))};n.default.useLayoutEffect(()=>{$({skipTimeout:!0})},[]),n.default.useEffect(()=>{$()},[Y,F]),n.default.useEffect(()=>{g.__()},[]),n.default.useEffect(()=>{const re=H.current;if(window.ResizeObserver){const oe=new ResizeObserver(()=>{$({skipTimeout:!0})});return oe.observe(re),()=>oe.unobserve(re)}{const oe=setInterval(()=>{$({skipTimeout:!0})},100);return()=>clearInterval(oe)}},[Y,F]);const z=Math.max(N,(G.width-Y*g.scale)/2),K=P?1:g.pages.length,X=F*g.scale*K,Q=Math.max(U,(G.height-X)/K/2);n.default.useEffect(()=>{const re=oe=>{(A||l.handleHotkey)(oe,g)};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[]),n.default.useEffect(()=>{var re;const oe=we=>{if(we.ctrlKey||we.metaKey){we.preventDefault();const de=Math.max(3,g.scaleToFit),Ee=Math.min(.1,g.scaleToFit),Ve=(be=we.deltaY<0?1.05*g.scale:g.scale/1.05,te=Ee,fe=de,Math.max(te,Math.min(fe,be)));g.setScale(Ve)}else var be,te,fe};return(re=L.current)===null||re===void 0||re.addEventListener("wheel",oe),()=>{var we;return(we=L.current)===null||we===void 0?void 0:we.removeEventListener("wheel",oe)}},[]);const J=n.default.useRef(!1);h(L,Y*g.scale+2*z,F*g.scale+2*Q,g.scale,g,J);const{handleScroll:ne}=w(L,F*g.scale+2*Q,g,G,J,P),ie=G.width>=Y*g.scale+2*z,ae=p||"rgba(232, 232, 232, 0.9)",he=g.pages.indexOf(g.activePage),me=(_==null?void 0:_.NoPages)||v,Ce=E??Math.min(3,Math.max(1,Math.ceil(G.height/2/(F*g.scale))));return n.default.createElement("div",{ref:H,style:{width:"100%",height:"100%",position:"relative",outline:"none",flex:1,backgroundColor:ae},tabIndex:0,className:"polotno-workspace-container"},n.default.createElement("div",{ref:L,onScroll:ne,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"auto",overflowX:ie?"hidden":"auto"},className:"polotno-workspace-inner"},g.pages.map((re,oe)=>{const we=re===g.activePage;if(P&&!we&&!re._exportingOrRendering&&!re._forceMount)return null;if(!(Math.abs(oe-he)<=Ce||re._exportingOrRendering||re._forceMount))return n.default.createElement(O,{key:re.id,width:Y*g.scale+2*z,height:F*g.scale+2*Q,backgroundColor:ae,xPadding:z,yPadding:Q});const be=n.default.createElement(i.default,{key:re.id,page:re,xPadding:z,yPadding:Q,width:Y*g.scale+2*z,height:F*g.scale+2*Q,store:g,pageControlsEnabled:b,backColor:ae,pageBorderColor:y||"lightgrey",activePageBorderColor:d||"rgb(0, 161, 255)",altCloneEnabled:S,bleedColor:m||"rgba(255, 0, 0, 0.1)",components:_});return(re._exportingOrRendering||re._forceMount)&&!we&&P?n.default.createElement("div",{style:{display:"none"},key:re.id},be):be}),g.rulesVisible&&n.default.createElement(o.TopRules,{store:g,xPadding:z,yPadding:Q,width:Y*g.scale+2*z,height:F*g.scale+2*Q}),g.pages.length===0&&n.default.createElement(me,{store:g}),g.audios.map(re=>n.default.createElement(a.AudioElement,{key:re.id,audio:re,store:g}))))}),t.default=t.WorkspaceCanvas})(qw);var wj=x2();Rl.toggleFadeInAnimation(!1);Qr.setTextOverflow("change-font-size");const Sj=new URLSearchParams(location.search).get("key"),LS=wj.createStore({key:Sj});window.store=LS;window.config={addGlobalFont:iu.addGlobalFont,unstable_useHtmlTextRender:Qr.useHtmlTextRender,unstable_setTextVerticalResizeEnabled:Qr.setTextVerticalResizeEnabled,unstable_setTextOverflow:Qr.setTextOverflow,onLoadError:Yi.onLoadError,setAssetLoadTimeout:Yi.setAssetLoadTimeout,setFontLoadTimeout:Yi.setFontLoadTimeout};const Ej=zd.createRoot(document.getElementById("root"));Ej.render(dt.createElement(qw.WorkspaceCanvas,{visiblePagesOffset:0,store:LS,components:{PageControls:()=>null,Tooltip:()=>null}}));
|
package/dist/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
}
|
|
9
9
|
</style>
|
|
10
10
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
11
|
-
<script type="module" crossorigin src="./assets/index-
|
|
11
|
+
<script type="module" crossorigin src="./assets/index-Bfr9h_d3.js"></script>
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
14
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polotno-node",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.7",
|
|
4
4
|
"description": "Polotno workflow from NodeJS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"fluent-ffmpeg": "^2.1.3",
|
|
24
24
|
"pixelmatch": "^6.0.0",
|
|
25
25
|
"pngjs": "^7.0.0",
|
|
26
|
-
"polotno": "^2.14.
|
|
26
|
+
"polotno": "^2.14.10",
|
|
27
27
|
"react": "^18.3.1",
|
|
28
28
|
"react-dom": "^18.3.1",
|
|
29
29
|
"vite": "^5.4.11"
|