@spiffcommerce/core 0.10.158 → 0.10.159

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.
package/dist/main.js CHANGED
@@ -1,4 +1,4 @@
1
- var A=require("lodash.clonedeep"),t=require("react/jsx-runtime"),e=require("react-dom/server"),n=require("opentype.js"),i=require("buffer"),a=require("axios"),s=require("https"),r=require("file-type"),o=require("util"),c=require("css"),g=require("canvas"),l=require("exif"),B=require("canvg"),w=require("swagger-client"),d=require("@apollo/client"),h=require("@apollo/client/link/context"),E=require("@apollo/client/link/error"),C=require("cross-fetch"),Q=require("react"),u=require("lodash.isequal"),I=require("lodash.debounce"),D=require("qrcode"),m=require("svg-path-bbox");function p(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function M(A){return A&&A.__esModule?A.default:A}function y(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}p(module.exports,"SpiffCommerceClient",(()=>La)),p(module.exports,"CommandContext",(()=>It)),p(module.exports,"spiffCoreConfiguration",(()=>je)),p(module.exports,"PromiseQueue",(()=>ri)),p(module.exports,"QueueablePromise",(()=>si)),p(module.exports,"MockWorkflowManager",(()=>Wa)),p(module.exports,"InformationMessageType",(()=>Aa)),p(module.exports,"StepHandle",(()=>aa)),p(module.exports,"TextStepHandle",(()=>Ba)),p(module.exports,"FrameStepHandle",(()=>_a)),p(module.exports,"ShapeStepHandle",(()=>la)),p(module.exports,"IllustrationStepHandle",(()=>sa)),p(module.exports,"MaterialStepHandle",(()=>ra)),p(module.exports,"ModelStepHandle",(()=>oa)),p(module.exports,"PictureStepHandle",(()=>ca)),p(module.exports,"QuestionStepHandle",(()=>ga)),p(module.exports,"OptionNotFoundError",(()=>xe)),p(module.exports,"LayoutNotFoundError",(()=>Ye)),p(module.exports,"AssetNotFoundError",(()=>ve)),p(module.exports,"ResourceNotFoundError",(()=>Ne)),p(module.exports,"MisconfigurationError",(()=>Se)),p(module.exports,"ParseError",(()=>He)),p(module.exports,"UnhandledBehaviorError",(()=>Re)),p(module.exports,"assetService",(()=>_e)),p(module.exports,"designService",(()=>Da)),p(module.exports,"createDesign",(()=>Qa)),p(module.exports,"optionService",(()=>tn)),p(module.exports,"server",(()=>Xe)),p(module.exports,"persistenceService",(()=>Oe)),p(module.exports,"graphQlManager",(()=>We)),p(module.exports,"toast",(()=>xi)),p(module.exports,"FrameService",(()=>li)),p(module.exports,"frameStepService",(()=>ui)),p(module.exports,"modelStepService",(()=>mi)),p(module.exports,"materialStepService",(()=>Di)),p(module.exports,"shapeStepService",(()=>yi)),p(module.exports,"questionStepService",(()=>Mi)),p(module.exports,"digitalContentStepService",(()=>Ci)),p(module.exports,"moduleStepService",(()=>pi)),p(module.exports,"pictureStepService",(()=>fi)),p(module.exports,"textStepService",(()=>Si)),p(module.exports,"illustrationStepService",(()=>Ii)),p(module.exports,"ProductCameraRig",(()=>hn)),p(module.exports,"FrameStep",(()=>qa)),p(module.exports,"AssetType",(()=>T)),p(module.exports,"BringForwardCommand",(()=>Wt)),p(module.exports,"CanvasCommand",(()=>Yt)),p(module.exports,"CreateElementCommand",(()=>Gt)),p(module.exports,"CreateLayoutCommand",(()=>Ht)),p(module.exports,"DeleteElementCommand",(()=>bt)),p(module.exports,"FontAlignmentCommand",(()=>Lt)),p(module.exports,"FontColorCommand",(()=>Jt)),p(module.exports,"FontSizeCommand",(()=>Ot)),p(module.exports,"FontSourceCommand",(()=>jt)),p(module.exports,"GroupCommand",(()=>Rt)),p(module.exports,"LayoutElementFactory",(()=>fe)),p(module.exports,"LayoutElementType",(()=>P)),p(module.exports,"MoveCommand",(()=>Nt)),p(module.exports,"ResizeCommand",(()=>Pt)),p(module.exports,"RotateCommand",(()=>St)),p(module.exports,"SendBackwardsCommand",(()=>Zt)),p(module.exports,"StepAspectType",(()=>W)),p(module.exports,"StepType",(()=>V)),p(module.exports,"TextChangeCommand",(()=>Kt)),p(module.exports,"UnitOfMeasurement",(()=>k)),p(module.exports,"dataUrlFromExternalUrl",(()=>UA)),p(module.exports,"findElement",(()=>Mt)),p(module.exports,"frameDataCache",(()=>se)),p(module.exports,"generate",(()=>Y)),p(module.exports,"getAxisAlignedBoundingBox",(()=>_)),p(module.exports,"generateSVGWithUnknownColors",(()=>Qt)),p(module.exports,"getAttributesFromArrayBuffer",(()=>ne)),p(module.exports,"rehydrateSerializedLayout",(()=>xt)),p(module.exports,"getFrameData",(()=>ge)),p(module.exports,"getSvgString",(()=>mt)),p(module.exports,"loadFontFromDataUrl",(()=>KA)),p(module.exports,"loadFontFromExternalUrl",(()=>TA)),p(module.exports,"determineCorrectFontSizeAndLines",(()=>Ce)),p(module.exports,"patternImageDataCache",(()=>ae)),p(module.exports,"generateCommands",(()=>Ra)),p(module.exports,"registerJSDOM",(()=>fA)),p(module.exports,"minZoom",(()=>Gn)),p(module.exports,"AdvancedEditor",(()=>jn)),p(module.exports,"TransformWrapper",(()=>As)),p(module.exports,"EditorCore",(()=>zn)),p(module.exports,"useLayouts",(()=>an)),p(module.exports,"useEditorState",(()=>dn)),p(module.exports,"useEditorInteraction",(()=>kn)),p(module.exports,"useShortcutCombination",(()=>Jn)),p(module.exports,"commandReducer",(()=>gn)),p(module.exports,"getDefaultState",(()=>cn)),p(module.exports,"CommandContextContext",(()=>en)),p(module.exports,"AdvancedEditorStateProvider",(()=>Bn)),p(module.exports,"AdvancedEditorContext",(()=>ln)),p(module.exports,"UICommand",(()=>wn)),p(module.exports,"EditorSubMenu",(()=>rn)),p(module.exports,"ElementEventType",(()=>Qn)),p(module.exports,"KeyEvent",(()=>In)),p(module.exports,"gatherVaryingStepAspects",(()=>$n));var F="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==f?f:{},x={};y(x,"CanvasCommand",(()=>Yt)),y(x,"UpdateWorkflowStateCommand",(()=>vt)),y(x,"MoveCommand",(()=>Nt)),y(x,"RotateCommand",(()=>St)),y(x,"ResizeCommand",(()=>Pt)),y(x,"GroupCommand",(()=>Rt)),y(x,"CreateLayoutCommand",(()=>Ht)),y(x,"ClearLayoutCommand",(()=>Ut)),y(x,"CreateElementCommand",(()=>Gt)),y(x,"DeleteElementCommand",(()=>bt)),y(x,"CloneElementCommand",(()=>kt)),y(x,"FontColorCommand",(()=>Jt)),y(x,"FontSizeCommand",(()=>Ot)),y(x,"FontAlgorithmCommand",(()=>zt)),y(x,"FontSourceCommand",(()=>jt)),y(x,"FontAlignmentCommand",(()=>Lt)),y(x,"UpdateFramePattern",(()=>Tt)),y(x,"TextChangeCommand",(()=>Kt)),y(x,"IllustrationColorCommand",(()=>Vt)),y(x,"IllustrationCacheCommand",(()=>Xt)),y(x,"BringForwardCommand",(()=>Wt)),y(x,"SendBackwardsCommand",(()=>Zt)),y(x,"LayerCommand",(()=>qt)),y({},"generate",(()=>Y));const Y=()=>{const A=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return A()+A()+"-"+A()+"-"+A()+"-"+A()+"-"+A()+A()+A()};var v={};y(v,"ElementNotFoundError",(()=>ft)),y(v,"findElement",(()=>Mt)),y(v,"findLayoutForElement",(()=>yt)),y(v,"updatedLayoutForElement",(()=>Ft)),y(v,"rehydrateSerializedLayout",(()=>xt));var N={};y(N,"CommandContext",(()=>It)),y(N,"elementFactory",(()=>Dt)),y(N,"getSvgString",(()=>mt)),y(N,"sortElementsByLayersWithIndex",(()=>pt)),y({},"SVGLayout",(()=>q));var S={};let P;var R;let H;var U;let G;var b;let k;var J;let O;var z;let j;var L;let T;var K;let V;var X;let W;var Z;y(S,"LayoutElementType",(()=>P)),y(S,"LayoutRenderingPurpose",(()=>H)),y(S,"TextAlgorithm",(()=>G)),y(S,"UnitOfMeasurement",(()=>k)),y(S,"ScaleAxis",(()=>O)),y(S,"MaterialEffectMode",(()=>j)),y(S,"AssetType",(()=>T)),y(S,"StepType",(()=>V)),y(S,"StepAspectType",(()=>W)),(R=P||(P={})).Frame="frame",R.Image="image",R.Illustration="illustration",R.Textbox="textbox",(U=H||(H={}))[U.ThreeD=0]="ThreeD",U[U.FreeDesign=1]="FreeDesign",U[U.Print=2]="Print",(b=G||(G={})).Autosize="Autosize",b.Traditional="Traditional",(J=k||(k={})).Pixel="px",J.Millimeter="mm",J.Centimeter="cm",(z=O||(O={}))[z.North=0]="North",z[z.Northeast=1]="Northeast",z[z.East=2]="East",z[z.Southeast=3]="Southeast",z[z.South=4]="South",z[z.Southwest=5]="Southwest",z[z.West=6]="West",z[z.Northwest=7]="Northwest",(L=j||(j={})).None="None",L.RemoveWhenSelected="RemoveWhenSelected",L.ApplyWhenSelected="ApplyWhenSelected",(K=T||(T={})).Font="Font",K.Frame="Frame",K.Illustration="Illustration",K.Image="Image",K.Model="Model",K.Material="Material",K.Color="Color",K.QuestionnaireCollateral="QuestionnaireCollateral",K.RequestCollateral="RequestCollateral",K.SignupCollateral="SignupCollateral",K.Video="Video",K.ColorProfile="ColorProfile",(X=V||(V={})).Bulk="Bulk",X.DigitalContent="DigitalContent",X.Finish="Finish",X.Frame="Frame",X.Illustration="Illustration",X.Introduction="Introduction",X.Material="Material",X.Model="Model",X.Module="Module",X.Picture="Picture",X.Photo="Photo",X.ProductOverlay="ProductOverlay",X.Question="Question",X.Shape="Shape",X.SilentIllustration="SilentIllustration",X.Text="Text",(Z=W||(W={})).Color="Color",Z.Colors="Colors",Z.Selection="Selection",Z.Selections="Selections",Z.Text="Text",Z.Upload="Upload";const q=({backgroundColor:A,borderRadius:e,configuration:n,elements:i,height:a,maxHeight:s,maxWidth:r,outlineArea:o,position:c,preserveAspectRatio:g,viewBox:l,width:B})=>{const w=e||0,d=2*(o?.scale||1),h=l||{x:0,y:0,width:B,height:a},E=`${h.x} ${h.y} ${h.width} ${h.height}`,C=Y(),Q=n.purpose===H.FreeDesign&&(0,t.jsx)("defs",{children:(0,t.jsx)("clipPath",{id:"viewboxClip",children:(0,t.jsx)("rect",{width:h.width,height:h.height,rx:w})})}),u=n.colorProfiles?.map(((A,e)=>(0,t.jsx)("color-profile",{name:A.name,xlinkHref:A.key,children:" "},e))),I=pt(i.map((A=>({...A,_renderingConfiguration:n,mask:o?`url(#viewmask-${C})`:void 0}))));return(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",preserveAspectRatio:g,width:B,height:a,style:{gridColumn:1,gridRow:1,maxWidth:r,maxHeight:s,position:c},viewBox:E,children:[u,Q,!!A&&(0,t.jsx)("rect",{id:"layout-background",width:h.width,height:h.height,fill:A,rx:w}),(0,t.jsx)("g",{id:"element-group",clipPath:n.purpose===H.FreeDesign?"url(#viewboxClip)":void 0,children:I.map((A=>Dt(A))).filter((A=>!!A))}),o&&(0,t.jsx)("rect",{x:o.x,y:o.y,width:o.width,height:o.height,fill:"none",stroke:o.hidden?"none":"#aaaaaa",strokeWidth:d/2,strokeDasharray:`${2*d} ${d}`}),o&&(0,t.jsxs)("mask",{id:`viewmask-${C}`,children:[(0,t.jsx)("rect",{x:h.x,y:h.y,width:h.width,height:h.height,fill:"black"}),(0,t.jsx)("rect",{x:o.x,y:o.y,width:o.width,height:o.height,fill:"white"})]})]})};y({},"Image",(()=>EA));var $={};y($,"getAxisAlignedBoundingBox",(()=>_)),y($,"degreesToRadians",(()=>tA)),y($,"findAngle",(()=>AA)),y($,"radiansToDegrees",(()=>eA)),y($,"isCloseToValue",(()=>nA)),y($,"getTrueCoordinates",(()=>iA)),y($,"getPointOfRotation",(()=>aA)),y($,"getNWPoint",(()=>sA)),y($,"getNEPoint",(()=>rA)),y($,"getSWPoint",(()=>oA)),y($,"getSEPoint",(()=>cA)),y($,"turnRightClockwise",(()=>gA)),y($,"currentDirection",(()=>lA)),y($,"getElementVertices",(()=>BA)),y($,"rotateAroundPoint",(()=>wA)),y($,"mmPerPixel",(()=>dA)),y($,"cmPerPixel",(()=>hA));const _=(A,t,e,n,i)=>{const a=tA(i),s=e/2,r=n/2,o=A+s,c=t+r,g=Math.sin(a),l=Math.cos(a),B=-r,w=s*l-B*g,d=s*l-r*g,h=s*g+B*l,E=s*g+r*l,C=Math.max(Math.abs(w),Math.abs(d)),Q=Math.max(Math.abs(h),Math.abs(E));return{minX:o-C,maxX:o+C,minY:c-Q,maxY:c+Q}},AA=(A,t,e)=>{const n=Math.sqrt(Math.pow(t.x-A.x,2)+Math.pow(t.y-A.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=Math.sqrt(Math.pow(e.x-A.x,2)+Math.pow(e.y-A.y,2));return Math.acos((i*i+n*n-a*a)/(2*i*n))*(180/Math.PI)},tA=A=>A*(Math.PI/180),eA=A=>A*(180/Math.PI),nA=(A,t,e)=>Math.abs(A-t)<e,iA=(A,t,e)=>{const n=Math.sin(tA(e)),i=Math.cos(tA(e));return{x:(A.x-t.x)*i-(A.y-t.y)*n+t.x,y:(A.x-t.x)*n+(A.y-t.y)*i+t.y}},aA=(A,t)=>({x:(A.x+t.x)/2,y:(A.y+t.y)/2}),sA=(A,t,e,n)=>({x:A.x+t?.x*e,y:A.y+t?.y*n}),rA=(A,t,e,n)=>({x:A.x+(t?.x+t?.width)*e,y:A.y+t?.y*n}),oA=(A,t,e,n)=>({x:A.x+t?.x*e,y:A.y+(t?.y+t?.height)*n}),cA=(A,t,e,n)=>({x:A.x+(t?.x+t?.width)*e,y:A.y+(t?.y+t?.height)*n}),gA=A=>{switch(A){case O.North:return O.East;case O.East:return O.South;case O.South:return O.West;case O.West:return O.North;case O.Northwest:return O.Northeast;case O.Northeast:return O.Southeast;case O.Southeast:return O.Southwest;case O.Southwest:return O.Northwest}},lA=(A,t)=>t>45&&t<=135?gA(A):t>135&&t<=225?gA(gA(A)):t>225&&t<=315?gA(gA(gA(A))):A,BA=(A,t={x:0,y:0},e={x:1,y:1})=>{const n=tA(A.rotation),i={x:t.x+A.x*e.x,y:t.x+A.y*e.y},a={x:A.x+A.width,y:A.y},s={x:t.x+(A.x+A.width)*e.x,y:t.y+(A.height+A.y)*e.y},r={x:t.x+A.x*e.x,y:t.y+(A.height+A.y)*e.y},o={x:(r.x+s.x)/2,y:r.y-A.height*e.y/2};return{a:wA(i,o,n),b:wA(a,o,n),c:wA(s,o,n),d:wA(r,o,n),center:o}},wA=(A,t,e)=>{const n=Math.sin(e),i=Math.cos(e);return{x:(A.x-t.x)*i-(A.y-t.y)*n+t.x,y:(A.x-t.x)*n+(A.y-t.y)*i+t.y}},dA=.352778,hA=.035277,EA=A=>{const e=A.rotation||0,n=tA(e),i=Math.cos(n),a=-Math.sin(n);return(0,t.jsx)("g",{mask:A.stepName||A.productOverlay?void 0:A.mask,children:(0,t.jsx)("g",{transform:`\n matrix(1, 0, 0, 1, ${A.x}, ${A.y})\n matrix(1, 0, 0, 1, ${A.width/2}, ${A.height/2})\n matrix(${i}, ${-a}, ${a}, ${i}, 0, 0)\n matrix(1, 0, 0, 1, ${-A.width/2}, ${-A.height/2})\n `,children:(0,t.jsx)("image",{xlinkHref:A.src,preserveAspectRatio:A.preserveAspectRatio,width:A.width,height:A.height})})})};y({},"Frame",(()=>CA));const CA=A=>{const e=`spiff-frame-${A.id}`,n=`spiff-frame-blur-${A.id}`,i=`spiff-frame-blur-edge-${A.id}`,a=`spiff-frame-focal-mask-${A.id}`,s=!!A.focalBlur&&!!A.pattern,r=A.rotation||0,o=tA(r),c=Math.cos(o),g=-Math.sin(o);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("defs",{children:(s=>{const r=A.pattern?.x||0,o=A.pattern?.y||0,c=A.pattern?A.pattern.width*A.pattern.scaleX+Math.abs(r):256,g=A.pattern?A.pattern.height*A.pattern.scaleY+Math.abs(o):256,l=A.pattern?A.pattern.width*A.pattern.scaleX:256,B=A.pattern?A.pattern.height*A.pattern.scaleY:256;return(0,t.jsxs)("g",{mask:A.stepName?void 0:A.mask,children:[(0,t.jsx)("pattern",{patternUnits:A.pattern?void 0:"userSpaceOnUse",x:0,y:0,width:A.pattern?1:c,height:A.pattern?1:g,"data-frame-width":A.pattern?c:void 0,"data-frame-height":A.pattern?g:void 0,id:e,children:(0,t.jsx)("image",{preserveAspectRatio:"none",x:r,y:o,width:l,height:B,xlinkHref:A.disablePlaceholder?"":A.pattern?A.pattern.src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAAAsSAAALEgHS3X78AAAZL0lEQVR4nO2diVIbSRZFq/GCsZBZjRea6fn/r+oZGrMYBBhkLGwzE1cmTSqVWXuqVFXnRHREG6OlpX43X771j5O/7/+XAEAvWeFrB+gvCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAECPQQAAGuLnz5+Nf/QIAEADyPhHl+fJ5/PTRj/+53z5AItFxn9y+in5Nvn2+3Xf7r5r5FvAAwBYID7jH4/Hyfcf3xv5GhAAgAXhM/5nK8+SD+8/Ji+ev2jka0AAABZAmvGvrr5q7CsgBgAQGZ/x68R/t/e+UeNPEACAuPiM/9Xqq+T9u4/Js2fPGv/0uQIARGLZjT/BAwCIw2TyLTk9O5mJ7i+b8ScIAED9yPiPTz4lPx+eKv2W0fgTrgAA9VKn8esKcXx8NH3OWCAAADUhd981frG9tVPK+BU/+Prt6/Q5Y4kAAgBQE0rtDQaDuSdTLKCIAbvBQwnKaHQR5WtCAABqRDX9b4ZvZp5QBpz3FA9lDvb23kf5mhAAgJpJE4G0mv8m0oYIAEAEQiJwdnbinQPQVM0AAgAQCZ8IyMBl6LYIyCtoqmAIAQAoyZeb68w2XonAK6fe3xYBxQWOjg4bqxZkOzBAQW7HN9OovIxfJ3zWMA+fe588Gvr3798bLRjCAwDIiQz59Ox4psT3y82XTC9Axiyj9nkCdRq/3l/ROYMIAEAOpq76p8Pkdnw788vq6R/f3mQ+QUgEDPIk9j8eVDJ+eRnnF2eFHk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EIHl069fW1qb/Ls/g7u5uzkOgqw8gPtF2A+bd7+ejSAcgAJQnmgAYfK59iOma7923yfpgyFcKsACiC0Dy6OZLCMbjsfdaIMPf3NgMxgcAIA4LEQAbpfkkCA8/fyYrjzX/9PEDNMPzRb+qjH2NLxtgKVj4YhAAWB4QAIAegwAA9BgEAKDHIAAAPQYBAOgxCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAEBfSZLk/xjo1hVZWiK0AAAAAElFTkSuQmCC"})}),s?(0,t.jsx)(QA,{path:A.path,width:A.width,height:A.height,focalBlurStrength:A.focalBlurStrength||1,focalBlurRadius:A.focalBlurRadius||10,blurFilterId:n,focalMaskId:a,blurEdgeClipId:i}):null]})})(s)}),(0,t.jsx)("g",{mask:A.stepName?void 0:A.mask,children:(0,t.jsxs)("g",{transform:`\n matrix(1, 0, 0, 1, ${A.x}, ${A.y})\n matrix(1, 0, 0, 1, ${A.width/2}, ${A.height/2})\n matrix(${c}, ${-g}, ${g}, ${c}, 0, 0)\n matrix(1, 0, 0, 1, ${-A.width/2}, ${-A.height/2})\n matrix(${A.scaleX}, 0, 0, ${A.scaleY}, 0, 0)\n `,children:[(0,t.jsx)("path",{filter:s?`url(#${n})`:void 0,mask:s?`url(#${i})`:void 0,d:A.path,style:{fill:`url(#${e})`,opacity:A.opacity}}),s?(0,t.jsx)("path",{mask:`url(#${a})`,d:A.path,style:{fill:`url(#${e})`,opacity:A.opacity}}):void 0]})})]})},QA=A=>{const{path:e,width:n,height:i,focalBlurStrength:a,focalBlurRadius:s,blurFilterId:r,focalMaskId:o,blurEdgeClipId:c}=A;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("filter",{id:r,children:(0,t.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,t.jsx)("mask",{id:o,children:(0,t.jsx)("circle",{cx:n/2,cy:i/2,r:s||0,fill:"white",filter:`url(#${r})`})}),(0,t.jsx)("mask",{id:c,children:(0,t.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};y({},"Textbox",(()=>gt));var uA={};y(uA,"fontSizeStep",(()=>qA)),y(uA,"textWidth",(()=>$A)),y(uA,"applyTextTransformations",(()=>At)),y(uA,"zip",(()=>tt)),y(uA,"getTextAlignment",(()=>et)),y(uA,"getAnchor",(()=>nt)),y(uA,"recomputeTextOnElement",(()=>it)),y(uA,"defaultLineHeightFactor",(()=>at)),y({},"calculateTextboxLines",(()=>ZA));var IA={};y(IA,"FontMetrics",(()=>jA)),y(IA,"loadFontFromExternalUrl",(()=>TA)),y(IA,"loadFontFromDataUrl",(()=>KA)),y(IA,"getFontMetrics",(()=>VA));var DA={};y(DA,"registerJSDOM",(()=>fA)),y(DA,"createElement",(()=>xA)),y(DA,"createElementNS",(()=>YA)),y(DA,"domParser",(()=>vA)),y(DA,"fetchAsArrayBuffer",(()=>NA)),y(DA,"fetchAsString",(()=>SA)),y(DA,"loadFontFaceSet",(()=>PA)),y(DA,"xmlSerializer",(()=>RA)),y(DA,"toBase64",(()=>HA)),y(DA,"dataUrlFromExternalUrl",(()=>UA)),y(DA,"arrayBufferToDataUrl",(()=>GA)),y(DA,"arrayBufferToBuffer",(()=>kA)),y(DA,"dataUrlToArrayBuffer",(()=>bA));var mA=i.Buffer;let pA;function fA(A){pA=A}function MA(){if(!pA)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new pA}if(void 0===F.TextEncoder){const{TextEncoder:A}=o;F.TextEncoder=A}if(void 0===F.TextDecoder){const{TextDecoder:A}=o;F.TextDecoder=A}const yA=new(M(s).Agent)({rejectUnauthorized:!0}),FA=A=>A.every((A=>"undefined"!==A)),xA=A=>FA([typeof document])?document.createElement(A):MA().window.document.createElement(A),YA=(A,t)=>{if(FA([typeof document]))return document.createElementNS(A,t);const e=MA().window.document.createElement(t);return e.setAttribute("xmlns",A),e},vA=()=>FA([typeof DOMParser])?new DOMParser:new(MA().window.DOMParser),NA=A=>{if(FA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.arrayBuffer())})).catch((A=>{e(A)}))}));{const t=A.replace("localhost","localstack");return new Promise(((A,e)=>{M(a).get(t,{responseType:"arraybuffer",httpsAgent:yA}).then((t=>{A(t.data)})).catch((A=>{e(A)}))}))}},SA=A=>{if(FA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.text())})).catch(e)}));{const t=A.replace("localhost","localstack");return new Promise(((A,e)=>{M(a).get(t,{responseType:"text",httpsAgent:yA}).then((t=>{A(t.data)})).catch(e)}))}},PA=async(A,t)=>{if(FA([typeof FontFace])){const e=A.names.fullName.en,n=new FontFace(e,`url(${t})`);return document.fonts.add(n),n.load()}},RA=()=>FA([typeof XMLSerializer])?new XMLSerializer:new(MA().window.XMLSerializer),HA=A=>FA([typeof btoa])?btoa(A):mA.from(A).toString("base64"),UA=async A=>{if(FA([typeof fetch,typeof Blob,typeof FileReader])){const t=await fetch(A),e=await t.blob();return await OA(e)}const t=(await M(a).get(A,{responseType:"arraybuffer"})).data;return GA(t)},GA=async A=>{const t=await(async A=>{const t=await(0,r.fromBuffer)(A);return t?t.mime:"image/svg+xml"})(A);return`data:${t};base64,${kA(A).toString("base64")}`},bA=A=>{const t=A.replace(/\r?\n/g,""),e=t.indexOf(",");if(-1===e||e<=4)throw new TypeError("malformed data: URI");const n=t.substring(5,e).split(";");let i=!1;for(let A=1;A<n.length;A++)"base64"===n[A]&&(i=!0);const a=i?"base64":"ascii",s=unescape(t.substring(e+1)),r=mA.from(s,a);return JA(r)},kA=A=>mA.from(A),JA=A=>{const t=new ArrayBuffer(A.byteLength),e=new Uint8Array(t);for(let t=0;t<A.length;++t)e[t]=A[t];return t},OA=A=>new Promise(((t,e)=>{const n=new FileReader;n.onload=function(A){const n=A.target;n&&n.result?t(n.result.toString()):e()},n.readAsDataURL(A)})),zA=new Map;class jA{constructor(A){this.font=A,this.glyphsFromText=new Map,this.kerningValues=new Map,this.height=this.calculateApproximateHeight()}getFont(){return this.font}getGlyphs(A){const t=this.glyphsFromText.get(A);if(t)return t;const e=this.font.stringToGlyphs(A);return this.glyphsFromText.set(A,e),e}getApproximateHeight(){return this.height}getExactHeight(A){const t=this.font.stringToGlyphs(A);let e=0,n=0;return t.forEach((A=>{const t=A.getMetrics();e=Math.max(e,t.yMax),n=Math.min(n,t.yMin)})),e-n}getKerningValue(A,t){let e=this.kerningValues.get(A.name);e||(e=new Map,this.kerningValues.set(A.name,e));let n=e.get(t.name);return n||(n=this.font.getKerningValue(A,t),e.set(t.name,n)),n}calculateApproximateHeight(){const A=this.font.stringToGlyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");let t=0,e=0;return A.forEach((A=>{const n=A.getMetrics();t=Math.max(t,n.yMax),e=Math.min(e,n.yMin)})),t-e}}const LA=A=>"data:"===A.substring(0,5).toLowerCase().trim(),TA=async A=>{const t=LA(A)?KA(A):KA(await UA(A));return XA(t,{assetUrl:LA(A)?A:await UA(A),name:t.names.fullName.en}),await PA(t,A),t},KA=A=>{const t=bA(A),e=M(n).parse(t);return XA(e,{assetUrl:A,name:e.names.fullName.en}),e},VA=A=>{const t=zA.get(A.name);if(t)return t;throw new Error("Font metrics unavailable for font")},XA=(A,t)=>{const e=new jA(A);return zA.set(t.name,e),e},WA=(A,t,e,n)=>{if($A(A,e,n)<=t)return[A];if(!(A.indexOf(" ")>-1)){if(A.length<=1)throw new Error(`Character ${A} is wider than region`);const t=Math.floor(A.length/2);return[A.slice(0,t),A.slice(t)]}const i=A.split(" "),a=[];let s=0;for(;s<i.length;){const A=i[s];if($A(A,e,n)>t)a.push(...WA(A,t,e,n)),s++;else{const r=[A];let o=s+1,c=!0;for(;o<i.length&&c;){const A=i[o];$A(`${r.join(" ")} ${A}`,e,n)<=t?(r.push(A),o++):c=!1}a.push(r.join(" ")),s=o}}return a},ZA=(A,t,e,n,i)=>{const a=VA(t),s=a.getFont();return((A,t,e,n,i,a)=>{const s=a||at,r=t.split("\n");try{const t=r.flatMap((t=>WA(t,A.width,n,i)));return{lines:t,requiredHeight:t.length*(e*s)}}catch(A){return console.error(A),{lines:[],requiredHeight:0}}})(e,At(n),A,A/s.unitsPerEm,a,i)},qA=1,$A=(A,t,e)=>{let n=0;const i=e.getGlyphs(A);return i.forEach(((A,t)=>{if(A.advanceWidth&&(n+=A.advanceWidth),t<i.length-1){const a=e.getKerningValue(A,i[t+1]);n+=a}})),n*=t,n},_A={stripControlCharacters:!0,vertical:!1,uppercase:!1},At=(A,t=_A)=>{const e={..._A,...t};let n=A;return e.stripControlCharacters&&(n=n.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),e.uppercase&&(n=n.toUpperCase()),e.vertical&&(n=n.split("").join("\n")),n},tt=(A,t)=>A.map(((A,e)=>[A,t[e]])),et=(A="center",t=!1)=>t?"center":A,nt=A=>"left"===A?"start":"right"===A?"end":"middle",it=(A,t)=>A.fontData?{...A,...(()=>{if(A.algorithm===G.Traditional){const e=ZA(A.fontSize,A.fontData,A,t,A.lineHeight);return{text:e.lines.join("\n"),height:e.requiredHeight,input:t}}return{text:t}})()}:A,at=1.1;var st={};y(st,"colorDefinitionPrintValue",(()=>rt)),y(st,"spotColorDefinitionString",(()=>ot)),y(st,"svgColorValueToDefinition",(()=>ct));const rt=A=>{const t=ot(A.spotColor);return t?`${A.browserValue} ${t}`:A.browserValue},ot=A=>{if(!A)return"";if(A.profileName.includes("/")&&A.profileName.includes(".icc")){const t=A.profileName.replace(/\s/g,"-"),e=t.lastIndexOf("/");return`icc-named-color(${t.slice(e+1).slice(0,-4)}, ${A.namedColor})`}return`icc-named-color(${A.profileName}, ${A.namedColor})`},ct=A=>{const t=A.split(/[ ](?=[^)]*?(?:\(|$))/);if(0===t.length)return{browserValue:"#000000"};if(1===t.length)return{browserValue:t[0]};const e=t[1].match(/\(([^)]+)\)/gm);if(!e)throw new Error("Unhandled state of color value in SVG");const n=e[0].replace(/[() ]/g,"").split(",");return{browserValue:t[0],spotColor:{profileName:n[0],namedColor:n[1]}}},gt=A=>{const e=(A.rotation||0)*Math.PI/180,n=Math.cos(e),i=-Math.sin(e),a=`text-path-${A.id}`,s=A.x+(A.curved?0:A.width/2),r=A.y+(A.curved?0:A.height/2),o=(A.text||"").split("\n");return A.curved&&!A.paths?null:A.fontData?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("defs",{children:[(0,t.jsx)("style",{type:"text/css",dangerouslySetInnerHTML:{__html:`\n @font-face {\n font-family: '${A.fontData.name}';\n src: url('${A.fontData.assetUrl}') format('truetype');\n }\n `}}),A.curved&&A.paths?(0,t.jsx)("path",{id:a,d:A.paths[0]}):void 0]}),A._renderingConfiguration?.debug?(0,t.jsx)("rect",{stroke:"blue",fill:"none",x:A.x,y:A.y,width:A.width,height:A.height}):void 0,(0,t.jsx)("g",{mask:A.stepName?void 0:A.mask,children:(0,t.jsx)("g",{transform:`matrix(${n}, ${-i}, ${i}, ${n}, ${s}, ${r})`,children:(0,t.jsx)("text",{xmlSpace:"preserve",fontFamily:`'${A.fontData.name}'`,fontSize:A.fontSize,fontStyle:"normal",fontWeight:"normal",fill:A._renderingConfiguration?.spotColors&&A.fillSpotColorDefinition?`${A.fill} ${ot(A.fillSpotColorDefinition)}`:A.fill,style:{whiteSpace:"pre",userSelect:"none"},children:A.curved?(0,t.jsx)(Bt,{text:A.text||"",curvedPathId:a,align:A.align}):o.map(((e,n)=>(0,t.jsx)(lt,{align:A.vertical?"center":A.align,fontSize:A.fontSize,thisLineIdx:n,amountLines:o.length,text:e,textboxHeight:A.height,textboxWidth:A.width,lineHeight:A.lineHeight,vertical:A.vertical,verticalAlign:A.verticalAlign},n)))})})})]}):null},lt=A=>(0,t.jsx)("tspan",{textAnchor:nt(A.align),x:"left"===A.align?-A.textboxWidth/2:"right"===A.align?A.textboxWidth/2:0,y:`${(()=>{const t=A.fontSize*(void 0!==A.lineHeight?A.lineHeight:at),e=A.textboxHeight/2;if("top"===A.verticalAlign)return-e+3*A.fontSize/4+A.thisLineIdx*t;if("bottom"===A.verticalAlign){const n=A.amountLines-1-A.thisLineIdx;return e-A.fontSize/4-n*t}const n=(A.amountLines-1)/2;return(A.thisLineIdx-n)*t+A.fontSize/4})()}px`,children:A.text}),Bt=A=>{const e=`#${A.curvedPathId}`;return(0,t.jsx)("textPath",{startOffset:"left"===A.align?"0%":"right"===A.align?"100%":"50%",textAnchor:nt(A.align),href:e,xlinkHref:e,children:A.text})};y({},"Illustration",(()=>ut));var wt={};y(wt,"traverse",(()=>ht)),y(wt,"sanitizeSvgTree",(()=>Et)),y(wt,"modifySVGWithElementProperties",(()=>Ct)),y(wt,"generateSVGWithUnknownColors",(()=>Qt));const dt=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],ht=(A,t)=>{t(A),A.children.length>0&&Array.from(A.children).forEach((A=>ht(A,t)))},Et=(A,t=!1)=>{!t&&A.setAttribute("preserveAspectRatio","none");const e=[];ht(A,(A=>{if("script"!==A.tagName)if("style"!==A.tagName);else try{(0,c.parse)(A.innerHTML).stylesheet?.rules.forEach((A=>{e.push(A)})),A.remove()}catch(A){console.error(A)}else A.remove()})),ht(A,(A=>{e.forEach((t=>{t.selectors?.forEach((e=>{((A,t)=>{try{return A.matches(t)}catch(e){return A.classList.contains(t.substring(1))}})(A,e)&&t.declarations?.forEach((t=>{t.property&&t.value&&A.setAttribute(t.property,t.value)}))}))}))}))},Ct=(A,t,e,n,i)=>{const a=(A=>vA().parseFromString(A,"image/svg+xml").firstElementChild)(A);if(!a)throw new Error("Failed to read SVG.");return((A,t,e)=>{A.setAttribute("height",`${e}px`),A.setAttribute("width",`${t}px`)})(a,t,e),((A,t,e)=>{ht(A,(A=>{const n=A.attributes.getNamedItem("fill");n&&"none"!==n.value&&A.classList.forEach((n=>{if(n.startsWith("spiff-fill")){const i=t[n];i&&A.setAttribute("fill",e?rt(i):i.browserValue)}}));const i=A.attributes.getNamedItem("stroke");i&&"none"!==i.value&&A.classList.forEach((n=>{if(n.startsWith("spiff-stroke")){const i=t[n];i&&A.setAttribute("stroke",e?rt(i):i.browserValue)}}))}))})(a,n,i),(A=>RA().serializeToString(A))(a)},Qt=async A=>{const t=A.match(/<svg.*?<\/svg>/s)||[],e=t?.length>0?t[0]:"",n=vA().parseFromString(e,"image/svg+xml").firstElementChild;if(!n)throw new Error("Failed to read SVG.");Et(n);const i={};ht(n,(A=>{dt.includes(A.tagName)&&!A.attributes.getNamedItem("fill")&&A.setAttribute("fill","black");const t=A.attributes.getNamedItem("fill");if(t&&"none"!==t.value){const e=ct(t.value),n=`spiff-fill-${e.browserValue.replace(/\W/g,"")}`;A.setAttribute("fill",e.browserValue),A.classList.add(n),i[n]=e}const e=A.attributes.getNamedItem("stroke");if(e&&"none"!==e.value){const t=ct(e.value),n=`spiff-stroke-${t.browserValue.replace(/\W/g,"")}`;A.classList.add(n),A.setAttribute("stroke",t.browserValue),i[n]=t}}));const a=RA().serializeToString(n);return{colors:i,svg:a}},ut=A=>{if(A.cachedObjectURL&&!A._renderingConfiguration?.omitCachedFields)return(0,t.jsx)(EA,{id:A.id,src:A.cachedObjectURL,x:A.x,y:A.y,width:A.width,height:A.height,rotation:A.rotation,preserveAspectRatio:"none",immutable:A.immutable,mask:A.stepName?void 0:A.mask});const e=A.rotation||0,n=tA(e),i=Math.cos(n),a=-Math.sin(n),s=`\n matrix(1, 0, 0, 1, ${A.x}, ${A.y})\n matrix(1, 0, 0, 1, ${A.width/2}, ${A.height/2})\n matrix(${i}, ${-a}, ${a}, ${i}, 0, 0)\n matrix(1, 0, 0, 1, ${-A.width/2}, ${-A.height/2})\n `;if(!A.svg)throw new Error(`Illustration element ${A.id} (stepName ${A.stepName}) lacked svg from src ${A.src} at render time.`);return(0,t.jsx)("g",{mask:A.stepName?void 0:A.mask,children:(0,t.jsx)("g",{transform:s,dangerouslySetInnerHTML:{__html:Ct(A.svg,A.width,A.height,A.colors,A._renderingConfiguration?.spotColors)}})})};class It{constructor(){this.id=Y(),this.stateCallbacks=[],this.prevCommands=[],this.nextCommands=[]}registerStateCallback(A){this.stateCallbacks.push(A)}unregisterStateCallback(A){this.stateCallbacks.filter((t=>t!==A))}getState(){return this.state}runStateCallbacks(){this.stateCallbacks.forEach((A=>A()))}apply(A,t){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);this.state=this.commandReducer(this.state,A),this.runStateCallbacks(),this.nextCommands=[],t||this.prevCommands.push(A)}undo(){if(!this.state)return;const A=this.prevCommands.pop();if(!A)return;const t=A.undo();A.varying?this.state={...this.state,variation:t}:this.state={...this.state,transaction:t},this.nextCommands.push(A),this.runStateCallbacks()}redo(){if(!this.state)return;const A=this.nextCommands.pop();A&&(this.state=this.commandReducer(this.state,A),this.runStateCallbacks(),this.prevCommands.push(A))}flattenSequence(A,t){const e=this.prevCommands.filter((t=>t.sequenceId===A)).pop();e&&(this.prevCommands=this.prevCommands.filter((t=>t.sequenceId!==A)),e?.overrideOldState(t),this.prevCommands.push(e))}getLayoutById(A){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const t=this.state.transaction?.layouts?.[A],e=this.state.variation?.layouts?.[A],n=t?.layout||e?.layout;if(!n)throw new Error(`No layout: ${A}`);const i=[...t?.elements||[],...e?.elements||[]];return this.getLayoutDataWithState(n,i)}getAllLayouts(){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const A=[...Object.keys(this.state.transaction?.layouts),...Object.keys(this.state.variation?.layouts||{})];return[...new Set(A)].map((A=>this.getLayoutById(A)))}getLayoutDataWithState(A,e){return{layoutState:{layout:A,elements:e},getComponentWithProps:n=>(0,t.jsx)(q,{backgroundColor:A.transparentBackground?void 0:"white",elements:e,width:A.width,height:A.height,viewBox:{x:0,y:0,width:A.width,height:A.height},...n})}}initialize(A,t){if(t)return void(this.state={transaction:t});let e={serializableWorkflow:{steps:[]},layouts:{}};A.forEach((A=>{e=new Ht(A).apply(e)})),this.runStateCallbacks(),this.state={transaction:e}}commandReducer(A,t){if(t.varying){const e={layouts:{},serializableWorkflow:{steps:[]},...A.variation};return{...A,variation:t.apply(e)}}{const e=A.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...A,transaction:t.apply(e)}}}}const Dt=A=>"image"===A.type?(0,t.jsx)(EA,{...A},A.id):"frame"===A.type?(0,t.jsx)(CA,{...A},A.id):"illustration"===A.type?(0,t.jsx)(ut,{...A},A.id):"textbox"===A.type?(0,t.jsx)(gt,{...A},A.id):null,mt=(A,n,i)=>{const a={backgroundColor:A.transparentBackground?void 0:"white"},s={width:i?.region?i.region.width:A.width,height:i?.region?i.region.height:A.height,viewBox:i?.region?{x:i.region.left,y:i.region.top,width:i.region.width,height:i.region.height}:{x:0,y:0,width:A.width,height:A.height}},r=i?.removeExcludedElements?n.filter((A=>!A.excludeFromExport)):n;try{return M(e).renderToStaticMarkup((0,t.jsx)(q,{preserveAspectRatio:"none",...a,...s,elements:r,configuration:i}))}catch(A){return console.error("Error rendering to static markup"),console.error(A),""}};function pt(A){return A.sort(((A,t)=>{const e=A.layer||0,n=t.layer||0;if(e<n)return-1;if(e>n)return 1;const i=A.layerIndex||0,a=t.layerIndex||0;return i<a?-1:i>a?1:0}))}class ft extends Error{constructor(A){super("No element found with ID: "+A),Object.setPrototypeOf(this,ft.prototype)}}const Mt=(A,t)=>yt(A,t).elements.find((t=>t.id===A)),yt=(A,t)=>{const e=Object.values(t).find((t=>t.elements.some((t=>t.id===A))));if(!e)throw new ft(A);return e},Ft=(A,t)=>{const e=pt([...t.elements.filter((t=>t.id!==A.id)),A]);return{layout:t.layout,elements:e,modificationID:Y()}},xt=async(A,t)=>{const e=[...Object.keys(A.layouts),...Object.keys(t?.layouts||{})],n=[...new Set(e)];for(let e=0;e<n.length;e++){const i=n[e],a=A.layouts[i],s=t?.layouts[i],r=(a||s).elements.filter((A=>"illustration"===A.type));for(let A=0;A<r.length;++A){const t=r[A];if(t.src&&!t.svg){const A=await SA(t.src),e=await Qt(A);t.svg=Ct(e.svg,t.width,t.height,t.colors)}}}};class Yt{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(A){this.oldState=A}}class vt extends Yt{constructor(A){super(),this.serializableWorkflow=A}apply(A){return this.oldState=A,{...A,serializableWorkflow:this.serializableWorkflow}}}class Nt extends Yt{constructor(A,t,e){super(),this.id=A,this.x=t,this.y=e}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,x:this.x,y:this.y},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class St extends Yt{constructor(A,t){super(),this.id=A,this.angle=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,rotation:this.angle},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Pt extends Yt{constructor(A,t,e){super(),this.id=A,this.width=Math.abs(t),this.height=Math.abs(e)}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,width:this.width,height:this.height};if("frame"===t.type){const A=e;A.scaleX=A.scaleX*this.width/t.width,A.scaleY=A.scaleY*this.height/t.height}const n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Rt extends Yt{constructor(A){super(),this.commands=A}apply(A){return this.oldState=A,this.commands.reduce(((A,t)=>t.apply(A)),A)}}class Ht extends Yt{constructor(A){super(),this.layout=A}apply(A){return this.oldState=A,{...A,layouts:{...A.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:Y()}}}}}class Ut extends Yt{constructor(A){super(),this.panelName=A}apply(A){this.oldState=A;const t=Object.values(A.layouts).map((A=>{const t=A.layout.panelId===this.panelName;return{...A,elements:t?[]:[...A.elements],modificationID:Y()}})),e={};return t.forEach((A=>{e[A.layout.id]=A})),{...A,layouts:e}}}class Gt extends Yt{constructor(A,t){super(),this.element=A,this.layout=t}apply(A){this.oldState=A,A.layouts[this.layout.id]||(A.layouts[this.layout.id]={layout:this.layout,elements:[],modificationID:""});const t=A.layouts[this.layout.id].elements;if(t.find((A=>A.id===this.element.id)))throw new Error(`Failed to apply new ${this.element.type} element because ID ${this.element.id} already taken`);if(this.element.productOverlay||0===t.length){const e=[...t,this.element];return void 0===this.element.layerIndex&&(this.element.layerIndex=this.assignIndex(this.element,e)),{...A,layouts:{...A.layouts,[this.layout.id]:{...A.layouts[this.layout.id],elements:e,modificationID:Y()}}}}const e=t[t.length-1],n=e.productOverlay?e:null;let i;if(n&&t.pop(),null!==this.element.layerIndex&&void 0!==this.element.layerIndex)i=[...t,this.element].sort(((A,t)=>void 0!==A.layerIndex&&void 0!==t.layerIndex?A.layerIndex-t.layerIndex:0));else{const A=this.assignIndex(this.element,t);this.element.layerIndex=void 0!==A?A:0,i=[...t,this.element]}return n&&i.push(n),{...A,layouts:{...A.layouts,[this.layout.id]:{...A.layouts[this.layout.id],elements:i,modificationID:Y()}}}}assignIndex(A,t){if(0===t.length)return 0;const e=t.filter((t=>(t.layer||0)===(A.layer||0))).sort(((A,t)=>(A.layerIndex||0)-(t.layerIndex||0)))[t.length-1]?.layerIndex;return void 0!==e?e+1:0}}class bt extends Yt{constructor(A){super(),this.id=A}apply(A){this.oldState=A;let t=!1;const e=Object.values(A.layouts).map((A=>(A.elements.filter((A=>A.id!==this.id)).length!==A.elements.length&&(t=!0),{...A,elements:A.elements.filter((A=>A.id!==this.id)),modificationID:Y()})));t||console.log(`Failed to delete element ${this.id}`);const n={};return e.forEach((A=>{n[A.layout.id]=A})),{...A,layouts:n}}}class kt extends Yt{constructor(t,e){super(),this.el=M(A)(t),this.layout=e,this.el.id=Y(),this.el.x+=5,this.el.y+=5}apply(A){return this.oldState=A,new Gt(this.el,this.layout).apply(A)}}class Jt extends Yt{constructor(A,t,e){super(),this.id=A,this.color=t,this.textFillSpotColor=e}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Ot extends Yt{constructor(A,t){super(),this.id=A,this.size=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,fontSize:this.size},n=yt(t.id,Object.values(A.layouts)),i=e.algorithm&&e.algorithm!==G.Autosize?e.input||"":e.text||"",a=Ft(it(e,i),n);return{...A,layouts:{...A.layouts,[n.layout.id]:a}}}}class zt extends Yt{constructor(A,t){super(),this.id=A,this.algorithm=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,algorithm:this.algorithm},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class jt extends Yt{constructor(A,t){super(),this.id=A,this.fontData=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,fontData:this.fontData},n=yt(t.id,Object.values(A.layouts)),i=Ft(it(e,e.input||""),n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Lt extends Yt{constructor(A,t){super(),this.id=A,this.align=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,align:this.align},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Tt extends Yt{constructor(A,t,e){super(),this.id=A,this.imageData=t,this.offsets=e}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts)),e=t.elements.findIndex((A=>A.id===this.id)),n=t.elements[e].pattern,i=[...t.elements];i.splice(e,1,{...t.elements[e],pattern:{...n,src:this.imageData.src,x:this.offsets.x,y:this.offsets.y,width:this.imageData.width,height:this.imageData.height,scaleX:this.offsets.zoom,scaleY:this.offsets.zoom}});const a={...t,elements:i,modificationID:Y()};return{...A,layouts:{...A.layouts,[t.layout.id]:a}}}}class Kt extends Yt{constructor(A,t){super(),this.id=A,this.text=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e=yt(t.id,Object.values(A.layouts)),n=Ft(it(t,this.text),e);return{...A,layouts:{...A.layouts,[e.layout.id]:n}}}}class Vt extends Yt{constructor(A,t,e){super(),this.id=A,this.className=t,this.fill=e}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e=t.colors||{},n=e[this.className];e[this.className]={browserValue:this.fill,spotColor:n?.spotColor};const i={...t,colors:e},a=yt(t.id,Object.values(A.layouts)),s=Ft(i,a);return{...A,layouts:{...A.layouts,[a.layout.id]:s}}}}class Xt extends Yt{constructor(A,t,e){super(),this.id=A,this.svgBody=t,this.objectURL=e}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,svg:this.svgBody,cachedObjectURL:this.objectURL},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Wt extends Yt{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!Mt(this.id,Object.values(A.layouts)).id)throw new ft(this.id);const t=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!t)throw new Error("Layout missing from state!");const e=t.elements.findIndex((A=>A.id===this.id)),n=e+1,i=[...t.elements],a=i.splice(e,1)[0];return i.splice(n,0,a),i.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[t.layout.id]:{...A.layouts[t.layout.id],elements:i,modificationID:Y()}}}}}class Zt extends Yt{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!Mt(this.id,Object.values(A.layouts)).id)throw new ft(this.id);const t=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!t)throw new Error("Layout missing from state!");const e=t.elements.findIndex((A=>A.id===this.id)),n=e-1,i=[...t.elements],a=i.splice(e,1)[0];return i.splice(n,0,a),i.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[t.layout.id]:{...A.layouts[t.layout.id],elements:i,modificationID:Y()}}}}}class qt extends Yt{constructor(A,t){super(),this.id=A,this.value=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!e)throw new Error("Layout missing from state!");return{...A,layouts:{...A.layouts,[e.layout.id]:Ft({...t,layer:this.value},e)}}}}var $t={};y($t,"patternImageDataCache",(()=>ae)),y($t,"frameDataCache",(()=>se)),y($t,"generateFrameSVG",(()=>re)),y($t,"generateDefaultRectangleFrameSvg",(()=>oe)),y($t,"getVariant",(()=>ce)),y($t,"getFrameData",(()=>ge)),y($t,"calculateOffsets",(()=>le)),y($t,"getPatternImageData",(()=>Be)),y($t,"GetSVGDimensions",(()=>we)),y($t,"svgStringDimensions",(()=>de));var _t={};y(_t,"getExifOrientation",(()=>te)),y(_t,"canvasDims",(()=>ee)),y(_t,"getAttributesFromArrayBuffer",(()=>ne));let Ae=null;const te=A=>new Promise((t=>{const e=kA(A);(0,r.fromBuffer)(A).then((A=>{const n=A?.mime;if("image/jpeg"!==n)return t(1);(new(0,l.ExifImage)).loadImage(e,((A,e)=>t(A?1:e.image.Orientation||1)))}))})),ee=A=>{const t=8192,e=A.naturalWidth/A.naturalHeight;return A.naturalHeight<=t&&A.naturalWidth<=t?[A.naturalWidth,A.naturalHeight]:A.naturalHeight>A.naturalWidth?[e*t,t]:[t,t/e]},ne=async A=>{const t=await(async A=>{const t=await GA(A),e=await(0,g.loadImage)(t),[n,i]=ee(e),a=await(async()=>{if(null!==Ae)return!Ae;const A=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return Ae=2===A.width&&3===A.height,!Ae})();if(!a){const A=(0,g.createCanvas)(n,i);return A.getContext("2d").drawImage(e,0,0,n,i),A}const s=await te(A),[r,o]=s>4?[i,n]:[n,i],c=(0,g.createCanvas)(r,o),l=c.getContext("2d");switch(s){case 2:l.translate(r,0),l.scale(-1,1);break;case 3:l.translate(r,o),l.rotate(Math.PI);break;case 4:l.translate(0,o),l.scale(1,-1);break;case 5:l.rotate(-.5*Math.PI),l.scale(-1,1);break;case 6:l.rotate(-.5*Math.PI),l.translate(-r,0);break;case 7:l.rotate(-.5*Math.PI),l.translate(-r,o),l.scale(1,-1);break;case 8:l.rotate(.5*Math.PI),l.translate(0,-o)}return l.drawImage(e,0,0,r,o),c})(A);return"image/jpeg"===(await(0,r.fromBuffer)(A))?.mime?{dataUrl:t.toDataURL("image/jpeg",1),height:t.height,width:t.width}:{dataUrl:t.toDataURL(),height:t.height,width:t.width}};y({},"getDefaultVariant",(()=>ie));const ie=A=>{const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0},ae=new Map,se=new Map,re=async(A,t)=>{if(!t){if(!A)throw new Error("No region or src supplied. Cannot construct frame!");return oe(A)}return SA(t)},oe=A=>{const t=A.width,e=t/A.height,n=Math.max(t,512),i=n/e;return`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${n} ${i}'>\n <path id="target-path" d='M0 0 h ${n} v ${i} h ${-n} Z' />\n </svg>\n `},ce=(A,t)=>{if(!t)return;const e=t.data.variants.find((t=>t.id===A.frameVariantId))||ie(t.data);if(!e)throw new Error(`No variant with ID: ${A.frameVariantId}`);if(!e.asset)throw new Error(`No asset for variant with ID: ${A.frameVariantId}`);return e},ge=async A=>{const t=vA().parseFromString(A,"image/svg+xml"),e=t.querySelector("svg");if(!e)throw new Error("Malformed frame SVG: <svg> tag not found");const n=e.getAttribute("viewBox");if(!n)throw new Error("SVG missing viewBox.");const i=n.split(" "),a=parseFloat(i[3])||1,s=parseFloat(i[2])||1,r=t.getElementById("target-path"),o=t.getElementsByClassName("st0").item(0);if(r){const A=r.getAttribute("d");if(!A)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const t={path:A,width:s,height:a};return se.set(A,t),t}if(o){const A=o.getAttribute("d");if(!A)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const t={path:A,width:s,height:a};return se.set(A,t),t}throw new Error("Malformed frame SVG")},le=(A,t,e)=>{const n=t.width>=t.height,i=A.width>=A.height,a=t.width/2,s=t.height/2,r=(n?t.height:t.width)/(i?A.height:A.width),o=e?.scale||r,c=a-A.width/2*o,g=e?.left||c,l=s-A.height/2*o;return{x:g,y:e?.top||l,zoom:o}},Be=async A=>{if(ae.has(A))return ae.get(A);if(A.endsWith("svg")){const t=await we(A),e=t.width,n=t.height,i={src:A,width:e,height:n,aspect:e/n};return ae.set(A,i),i}{const t=await NA(A),e=await ne(t),n={src:A,width:e.width,height:e.height,aspect:e.width/e.height};return ae.set(A,n),n}},we=async A=>{const t=await fetch(A),e=await t.text();return de(e)},de=A=>{const t=(new DOMParser).parseFromString(A,"image/svg+xml").querySelector("svg");if(!t)throw new Error("No svg tag found, this svg must be malformed!");const e=t.getAttribute("viewBox"),n=t.getAttribute("width"),i=t.getAttribute("height"),a=e?e?.split(" ").map((A=>Number(A))):[0,0,Number(n),Number(i)];if(!a)throw new Error("No viewbox or width/height values detected on SVG file!");return{width:a[2],height:a[3]}};var he={};y(he,"determineCorrectFontSizeAndLines",(()=>Ce)),y(he,"determineCorrectTextboxRegion",(()=>Qe));const Ee=(A,t,e,n,i)=>{let a=t.map((A=>A.split("\n"))).flat(),s=a.length,r=a.map((A=>$A(A,n,i)));const o=i.getApproximateHeight()*n;let c=!0;for(;c;){if(o+(s-1)*e>A.height)return[null,null];const t=Math.max(...r);if(t<=A.width)return[a,t];const g=r.reduce(((A,t,e,n)=>t>n[A]?e:A),0),l=a[g];let B=!1,w=l.length;for(;!B&&w>-1;){w=l.lastIndexOf(" ",w-1);const t=[l.slice(0,w),l.slice(w+1)],e=t.map((A=>$A(A,n,i)));e[0]<=A.width&&(a=[...a.slice(0,g),...t,...a.slice(g+1)],r=[...r.slice(0,g),...e,...r.slice(g+1)],s+=1,B=!0)}B||(c=!1)}return[null,null]},Ce=(A,t,e,n,i)=>{let a,s;const r=VA(t),o=r.getFont();if(i.size){const t=A/o.unitsPerEm;return[a,s]=Ee(e,n,A,t,r),[i.size,a,s]}let c=6-qA;if(n.length>0){let A=n,t=0;for(;(!i.maxSize||c<=i.maxSize)&&A;)c+=qA,t=c/o.unitsPerEm,[A,s]=Ee(e,n,c,t,r)}c>6&&(c-=qA),i.minSize&&c<i.minSize&&(c=i.minSize);const g=c/o.unitsPerEm;return[a,s]=Ee(e,n,c,g,r),[c,a,s]},Qe=(A,t,e,n,i)=>{let a={...A},s={...A},[r,o,c]=Ce(e,t,s,n,{size:0,minSize:e,maxSize:e});var g,l;return c&&c<a.width&&(s.width=c,"left"===i?(s.left+=Math.sin(a.rotation*Math.PI/360)*(a.width-c),s.top+=Math.sin(a.rotation*Math.PI/180)*(c-a.width)/2):s.left+="right"===i?a.width-c:(a.width-c)/2,[r,o]=Ce(e,t,s,n,{size:e}),r===e&&o&&(g=n,l=o,g.map(((A,t)=>[A,l[t]]))).every((([A,t])=>A===t))&&(a=s)),a};var ue={};y(ue,"svgObjectURL",(()=>me)),y(ue,"LayoutElementFactory",(()=>fe));const Ie=(A,t)=>{const e=A.layoutState.elements.filter((A=>A.layer===t)),n=Math.max(...e.map((A=>A.layerIndex)).filter((A=>void 0!==A)));return Math.max(n,0)+1},De=async A=>new Promise((t=>{fetch(A).then((A=>{t(A.text())})).catch((A=>console.error(A)))})),me=async A=>{const t=(new DOMParser).parseFromString(A,"image/svg+xml").firstElementChild;if(!t)throw new Error("Failed to read SVG");const e=(new XMLSerializer).serializeToString(t),n=document.createElement("canvas"),i=n.getContext("2d"),a=await B.Canvg.from(i,e,{anonymousCrossOrigin:!0,ignoreDimensions:!1}),s=t.getAttribute("width"),r=t.getAttribute("height"),o=2048;if(r&&s){const A=parseFloat(r),t=parseFloat(s)/A;t>1?a.resize(o,o/t):a.resize(o*t,o)}else a.resize(o,o);return await a.render(),await(async A=>new Promise(((t,e)=>{try{if(!URL||!URL.createObjectURL)throw new Error("Environment incapable of generating ObjectURL");A.toBlob((e=>{if(!e){if(0===A.width||0===A.height)throw new Error(`Canvas dimensions are invalid (${A.width},${A.height})`);if(A.width*A.height>=268435456)throw new Error(`Canvas dimensions exceed device limit (${A.width},${A.height})`);throw new Error("Couldn't generate object URL for Illustration, the blob was undefined!")}t(URL.createObjectURL(e))}))}catch(A){e(A)}})))(n)},pe=async(A,t,e)=>{const n=A.layoutState.layout.useEditableArea&&A.layoutState.layout.editableArea||{width:A.layoutState.layout.width,height:A.layoutState.layout.height,x:0,y:0},i=(n.width<n.height?n.width:n.height)/2,a={top:n.y+n.height/2-i/2,left:n.x+n.width/2-i/2,width:i,height:i,rotation:0,panelId:A.layoutState.layout.panelId};if(e&&t===P.Illustration){const A=await Qt(await De(e)),t=(new DOMParser).parseFromString(A.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!t)throw new Error("SVG missing viewBox.");const n=a.height,i=t.split(" "),s=(parseFloat(i[2])||1)/(parseFloat(i[3])||1);a.height=a.width/s,a.top+=(n-a.height)/2}if(e&&t===P.Image){const A=a.height,t=await fetch(e),n=await t.arrayBuffer(),i=await ne(n),s=i.width/i.height;a.height=a.width/s,a.top+=(A-a.height)/2}return a};class fe{static async getFrame(A,t){const e=await re(t.region,t.src),n=await ge(e),i=t.region||await pe(A,P.Frame);return{id:Y(),x:i.left,y:i.top,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||Ie(A,i.layer||0),rotation:i.rotation,scaleX:i.width/n.width,scaleY:i.height/n.height,path:n.path,type:P.Frame,disablePlaceholder:t.configuration.disablePlaceholder,focalBlur:t.configuration.focalBlur,focalBlurStrength:t.configuration.focalBlurStrength,focalBlurRadius:t.configuration.focalBlurRadius,pattern:void 0,immutable:i.immutable}}static async getImage(A,t){const e=t.region||await pe(A,P.Image,t.src);return{id:Y(),src:t.src,type:P.Image,y:e.top,x:e.left,rotation:e.rotation,width:e.width,height:e.height,layer:e.layer||0,layerIndex:e.layerIndex||Ie(A,e.layer||0),immutable:e.immutable,preserveAspectRatio:"none"}}static async getTextbox(A,t){const{configuration:e,fontSrc:n,designInputStep:i}=t,a=t.region||await pe(A,P.Textbox),s={assetUrl:n,name:(await TA(n)).names.fullName.en},r=i?.text||e.defaultText||"",o=e.replaceableText?e.replaceableText.replace("{{}}",r):r,c=At(o,{vertical:e.vertical,uppercase:e.uppercase}),g=it({id:Y(),type:P.Textbox,x:a.left,y:a.top,width:a.width,height:a.height,align:et(e.textAlign,e.vertical),curved:e.curved,fill:i?.color||e.colour||"#000000",fontData:s,layer:a.layer||0,layerIndex:a.layerIndex||Ie(A,a.layer||0),paths:e.paths,rotation:a.rotation,vertical:e.vertical,verticalAlign:e.verticalAlign||"middle",algorithm:G.Traditional,fontSize:e.size||Math.max(Math.round(.025*a.height),1),text:c,input:r},c),l=Qe({...a,height:g.height},s,g.fontSize,g?.text?.split("\n")||[],g.align);return{...g,x:l.left,y:l.top+(a.height-l.height)/2,width:l.width,height:l.height}}static async getShape(A,t){const e=`\n <svg\n xmlns="http://www.w3.org/2000/svg"\n xmlnsXlink="http://www.w3.org/1999/xlink"\n xmlSpace="preserve"\n preserveAspectRatio="none"\n version="1.1"\n width="1"\n height="1"\n viewBox="0 0 1 1"\n >\n <rect\n x="0"\n y="0"\n width="1"\n height="1"\n class="spiff-fill-shape"\n fill="${t.color}"\n />\n </svg>\n `,n={};n["spiff-fill-shape"]={browserValue:t.color};const i=t.region||await pe(A,P.Illustration),a=Y();return{stepRegion:t.region,colors:n,id:a,svg:e,type:P.Illustration,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||Ie(A,i.layer||0),immutable:i.immutable}}static async getIllustration(A,t){const e=t.region||await pe(A,P.Illustration,t.src),n=await Qt(await De(t.src)),i=await me(n.svg),a=Y();return{cachedObjectURL:i,stepRegion:t.region,colors:n.colors,id:a,svg:n.svg,type:P.Illustration,y:e.top,x:e.left,rotation:e.rotation,width:e.width,height:e.height,layer:e.layer||0,layerIndex:e.layerIndex||Ie(A,e.layer||0),immutable:e.immutable}}}function Me(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class ye extends Error{constructor(A){super(A),this.name=this.constructor.name}}class Fe extends ye{constructor(A){super(`ConfigurationError - ${A}`)}}class xe extends Fe{constructor(A){super(`Option not Configured: ${A.stepTitle}`),Me(this,"optionId",void 0),this.optionId=A?.optionId||"N/A"}}class Ye extends Fe{constructor(A){super(`Panel not Found: ${A.panelId}`),Me(this,"panelId",void 0),this.panelId=A?.panelId||"N/A"}}class ve extends Fe{constructor(A){super(`Asset not found for variant: ${A.name}`),Me(this,"variant",void 0),this.variant=A}}class Ne extends Fe{constructor(A){super(`Resource not found for asset: ${A.name}`),Me(this,"asset",void 0),this.asset=A}}class Se extends Fe{constructor(A,t){super(`Workflow Misconfiguration: ${A.stepName} - ${t}`),Me(this,"step",void 0),this.step=A}}class Pe extends ye{constructor(A){super(`ImplementationError - ${A}`)}}class Re extends Pe{constructor(A){super(`Unhandled Behavior Encountered: ${A}`)}}class He extends Pe{constructor(A){super(`Parsing Error: ${A}`)}}class Ue extends Pe{constructor(A){super(`Client Error: ${A}`)}}class Ge extends Pe{constructor(A){super(`Resource Generation Failed: ${A}`)}}function be(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class ke{get(A){return localStorage.getItem(A)||void 0}set(A,t){localStorage.setItem(A,t)}remove(A){localStorage.removeItem(A)}getMap(A){const t=this.get(A);if(t)return new Map(JSON.parse(t))}setMap(A,t){const e=JSON.stringify([...t.entries()]);this.set(A,e)}}class Je{constructor(){be(this,"storage",new Map)}get(A){return this.storage.get(A)||void 0}set(A,t){this.storage.set(A,t)}remove(A){this.storage.delete(A)}getMap(A){const t=this.get(A);if(t)return new Map(JSON.parse(t))}setMap(A,t){const e=JSON.stringify([...t.entries()]);this.set(A,e)}}const Oe=(()=>{try{return localStorage?new ke:new Je}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new Je}})();function ze(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const je=new class{constructor(){ze(this,"defaultServerUrl","https://api.spiff.com.au"),ze(this,"defaultServicesApiUrl","https://services.spiff.com.au"),ze(this,"defaultHubUrl","https://hub.spiff.com.au"),ze(this,"serverUrl",void 0),ze(this,"servicesApiUrl",void 0),ze(this,"hubUrl",void 0),ze(this,"serverUrlCallbacks",void 0),this.serverUrl=this.defaultServerUrl,this.servicesApiUrl=this.defaultServicesApiUrl,this.hubUrl=this.defaultHubUrl,this.serverUrlCallbacks=[]}getServerUrl(){return this.serverUrl}getServicesApiUrl(){return this.servicesApiUrl}getHubUrl(){return this.hubUrl}setServerUrl(A){this.serverUrl=A,this.serverUrlCallbacks.forEach((A=>A()))}setServicesApiUrl(A){this.servicesApiUrl=A}setHubUrl(A){this.hubUrl=A}addServerUrlCallback(A){this.serverUrlCallbacks.push(A)}};function Le(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let Te;const Ke=A=>{Te=A},Ve=async()=>{const A={transactionOwnerId:Te};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=je.getHubUrl();if(window.location.href.includes("localhost")||window.location.href.includes("ngrok"))return void A({});const e=n=>{n.origin===t&&(window.removeEventListener("message",e),A(n.data))};window.parent!==window&&(window.addEventListener("message",e,!1),window.parent.postMessage("ready",t))})),...A}:A};const Xe=new class{constructor(){Le(this,"client",void 0),Le(this,"uncachedOperations",[]),je.addServerUrlCallback((async()=>{this.client=void 0,this.client=await this.constructClient()}))}setUncachedOperations(A){this.uncachedOperations=A}async execute(A,t){const e=this.uncachedOperations.includes(A)?A+"_private":A;return new Promise(((A,n)=>{this.getClient().then((i=>{i.execute({operationId:e,parameters:t}).then((t=>A(t))).catch((A=>{A.response&&A.response.status&&A.response.status>=500||(!A.response&&n(new Error(A)),A.response&&n(new Error(`${A.response.status} ${A.response.url}`)))}))})).catch((A=>{n(A)}))}))}async syncAuth(A){const t=await Ve();if(t.bearer?A.authorizations={...A.authorizations,OAuth2:{token:{access_token:t.bearer,token_type:"Bearer"}}}:A.authorizations={...A.authorizations,OAuth2:{token:{access_token:"",token_type:"Bearer"}}},t.activeIntegration)A.authorizations={...A.authorizations,ActiveIntegration:t.activeIntegration};else{const t={...A.authorizations};delete t.ActiveIntegration,A.authorizations=t}if(t.partnerId)A.authorizations={...A.authorizations,PartnerId:t.partnerId};else{const t={...A.authorizations};delete t.PartnerId,A.authorizations=t}}async getClient(){return this.client||(this.client=await this.constructClient()),this.syncAuth(this.client),Promise.resolve(this.client)}async constructClient(){const A=await Ve(),t=je.getServerUrl()+"/v2/api-docs";return await M(w)(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const We=new class{constructor(){Le(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),je.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=(0,d.createHttpLink)({uri:`${je.getServerUrl()}/graphql`,fetch:C.fetch}),t=(0,h.setContext)((async(A,{headers:t})=>{const e=t||{},n=await Ve();return n.bearer&&(e.Authorization=`Bearer ${n.bearer}`),n.partnerId&&(e.partnerId=n.partnerId),n.activeIntegration&&(e.activeIntegration=n.activeIntegration),n.transactionOwnerId&&(e.transactionOwnerId=n.transactionOwnerId),{headers:e}})),e=(0,E.onError)((({operation:A,graphQLErrors:t,networkError:e})=>{(t||[]).forEach((({message:t,locations:e,path:n})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+A.operationName),console.log("Query:"+JSON.stringify(A.query)),console.log(`Message: ${t}, Location: ${JSON.stringify(e,null,2)}, Path: ${n}`),console.log("Variables:"+JSON.stringify(A.variables))})),e&&console.log("GraphQL Network error")}));const n=new(0,d.InMemoryCache)({typePolicies:{Transaction:{fields:{bulkEmailAddress:{read:(A=null)=>A},transactionOwnerId:{read:(A=null)=>A},customLogoLink:{read:(A=null)=>A},workflowFooterLogoLink:{read:(A=null)=>A},workflowState:{read:(A=null)=>A},bulkSourceUrl:{read:(A=null)=>A},externalDesignProductId:{read:(A=null)=>A},externalDesignProductVariantId:{read:(A=null)=>A},lastSyncedAt:{read:(A=null)=>A}}},Workflow:{fields:{isPresent:{read:(A=null)=>A}}},Product:{fields:{imageUrl:{read:(A=null)=>A},overlayImageUrl:{read:(A=null)=>A},preloadImageUrl:{read:(A=null)=>A},weight:{read:(A=null)=>A}}}}});return new(0,d.ApolloClient)({link:(0,d.from)([e,t,A]),cache:n,name:"Core"})}};function Ze(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const qe="persistentAssets";class $e{static add(A){const t=A?.links.find((A=>"cdn"===A.rel));if(!t)return void console.error("Failed to find cdn link on asset, cannot persist!");const e=new Map;e.set(A.data.key,t.href);const n=Oe.getMap(qe);n&&n.forEach(((A,t)=>{e.set(t,A)})),Oe.setMap(qe,e)}static remove(A){const t=Oe.getMap(qe);if(!t)return;const e=Array.from(t.entries()).find((t=>t[0]===A));e&&(t.delete(e[0]),Oe.setMap(qe,t))}static list(){const A=Oe.getMap(qe);return A?Array.from(A.entries()).map((A=>({assetKey:A[0],src:A[1]}))):[]}}const _e=new class{constructor(){Ze(this,"server",void 0),Ze(this,"cache",new Map),Ze(this,"materialCache",new Map),Ze(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await ne(t);return{name:A.name.substring(A.name.lastIndexOf("/")+1),blob:((A,t)=>{let e=atob(A.split(",")[1]),n=[];for(let A=0;A<e.length;A++)n.push(e.charCodeAt(A));return new Blob([new Uint8Array(n)],{type:t})})(e.dataUrl,A.type)}})),Ze(this,"getAssetFromVariant",(async A=>A.asset?A.asset:await _e.getLocalOrFromServer(A.assetKey))),Ze(this,"getMaterialFromVariant",(async A=>A.material?A.material:await _e.getMaterialLocalOrFromServer(A.materialId))),this.server=Xe}async getLocalOrFromServer(A){if(this.cache.has(A)){const t=this.cache.get(A);if(!t)throw new Re("Failed to get asset from cache!");return t}const t=(async()=>(await Xe.execute("getAssetByKeyV2",{assetKey:A.replace(/\//g,"_")})).body)();return this.cache.set(A,t),t}async getMaterialLocalOrFromServer(A){if(this.materialCache.has(A))return this.materialCache.get(A);const t=(async()=>(await Xe.execute("getMaterialV2",{id:A})).body)();return this.materialCache.set(A,t),t}async uploadAssetWithProgress(A,t,e,n,i){const a=await this.dispatchCreateAssetRequest(A,t,n,i);return await new Promise(((t,n)=>{var i=new XMLHttpRequest;i.open("PUT",a.assetResponse.uploadUrl,!0),i.setRequestHeader("Content-Type",a.mimeType),i.setRequestHeader("Cache-Control","public,max-age=31536000,immutable"),i.upload.onprogress=A=>{A.lengthComputable&&e(100*A.loaded/A.total)},i.onload=()=>{const A=a.assetResponse.asset;$e.add(a.assetResponse.asset),t(A)},i.onerror=n,i.send(A.blob)})),a.assetResponse.asset}async uploadFile(A,t){const e=!("image/svg+xml"===A.type||"application/pdf"===A.type),n=e?T.Image:T.Illustration;if(e){const e=await this.loadImageAsFileInfo(A);return await this.uploadAssetWithProgress(e,n,t,!0)}{const e={name:A.name,blob:new Blob([A],{type:A.type})};return await _e.uploadAssetWithProgress(e,n,t,!0)}}removePersistedAsset(A){$e.remove(A)}getPersistedAssets(){return $e.list()}async dispatchCreateAssetRequest(A,t,e,n){const i=A.blob.type?A.blob.type:this.guessMIME(A.name);return{assetResponse:(await this.server.execute("createAsset",{assetDetails:{name:A.name,type:t,mimeType:i,storageOwnerId:n,userAnonymous:!0}},e)).body,mimeType:i}}guessMIME(A){const t=A.split(".").pop();switch(t){case"glb":return"model/gltf-binary";case"ttf":return"font/ttf";case"mkv":return"video/x-matroska";default:throw new Re("Unexpected mimetype: "+t)}}};function An(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const tn=new class{constructor(){An(this,"cache",new Map),An(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),An(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),An(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[])),An(this,"getOptionFromStep",(async(A,t)=>{if(A.option){const t=A.option.data.id;return t&&!this.cache.has(t)&&this.cache.set(t,Promise.resolve(A.option)),A.option}return await tn.getOption(t,A.optionId)}))}async getOption(A,t){if(this.cache.has(t))return this.cache.get(t);const e=(async()=>{const e=await A.execute("getOptionV2",{id:t});if(e.body.data)return e.body})();return this.cache.set(t,e),e}async getAssetTileImageForVariant(A){if(A.thumbnailKey){const t=await _e.getLocalOrFromServer(A.thumbnailKey),e=t.links.find((A=>"thumbnail"===A.rel)),n=t.links.find((A=>"cdn"===A.rel));return e?.href||n?.href}const t=A.assetKey;if(t){const A=await _e.getLocalOrFromServer(t),e=A.links.find((A=>"thumbnail"===A.rel)),n=A.links.find((A=>"cdn"===A.rel));return e?.href||n?.href}return A.materialId?A.materialId:""}getDefaultVariant(A){const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0}},en=(0,Q.createContext)(new It),nn=function(){const[A,t]=(0,Q.useState)([]);return{addEvent:(0,Q.useCallback)((A=>{t((t=>[...t,A]))}),[]),updateEvent:(0,Q.useCallback)((A=>{t((t=>{const e=t.findIndex((t=>t.pointerId===A.pointerId));if(-1===e)return t;const n=[...t];return n[e]=A,n}))}),[]),removeEvent:(0,Q.useCallback)((A=>{t((t=>t.filter((t=>t.pointerId!==A.pointerId))))}),[]),eventCache:A,curActiveEvents:A.length}},an=()=>{const A=(0,Q.useContext)(en),[t,e]=(0,Q.useState)(new Date);(0,Q.useEffect)((()=>{const t=()=>{e(new Date)};return A.registerStateCallback(t),()=>{A.unregisterStateCallback(t)}}),[A]);return{commandDispatcher:(t,e)=>{A.apply(t,e)},getLayoutById:t=>A.getLayoutById(t),getAllLayouts:()=>A.getAllLayouts(),getReducerState:()=>{const t=A.getState();return t||{transaction:{layouts:{},serializableWorkflow:{steps:[]}}}},lastUpdated:t,flattenSequence:(t,e)=>{A.flattenSequence(t,e)}}};function sn(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let rn;var on;(on=rn||(rn={})).None="None",on.FrameAdjustment="FrameAdjustment",on.FinalizeDesign="FinalizeDesign",on.SavedDesigns="SavedDesigns",on.ThreeDPreview="ThreeDPreview",on.Panels="Panels";const cn=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,xTranslation:0,yTranslation:0,maxZoom:5,units:k.Pixel,subMenu:rn.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),gn=(A,t)=>M(u)(A,t.apply(A))?A:t.apply(A),ln=(0,Q.createContext)({}),Bn=A=>{const{getAllLayouts:e}=an(),[n,i]=(0,Q.useReducer)(gn,cn(e,A.defaultZoom||1)),a=(0,Q.useMemo)((()=>({state:n,uiDispatcher:i})),[n,i]);return(0,t.jsx)(ln.Provider,{value:a,children:A.children})};class wn{constructor(A){sn(this,"changes",void 0),this.changes=A}apply(A){return{...A,...this.changes}}}const dn=()=>(0,Q.useContext)(ln);let hn;var En;(En=hn||(hn={}))[En.Orbit=0]="Orbit",En[En.Pan=1]="Pan";const Cn=(A,e,n,i)=>{const a=e.layout.useEditableArea&&e.layout.editableArea||{width:e.layout.width,height:e.layout.height,x:0,y:0},s=e.elements.filter((t=>t.id!==A.id&&!t.immutable&&!t.productOverlay)),r=s.map((A=>_(A.x,A.y,A.width,A.height,A.rotation))),o=[],c=new Set;r.forEach((A=>c.add(A.minX))),r.forEach((A=>c.add(A.maxX))),[a.x,a.x+a.width/2,a.x+a.width].forEach((A=>c.add(A)));const g=new Set;r.forEach((A=>g.add(A.minY))),r.forEach((A=>g.add(A.maxY))),[a.y,a.y+a.height/2,a.y+a.height].forEach((A=>g.add(A)));const l=s.map((A=>A.y));for(let A=-315;A<=315;A+=45)l.push(A);const B=_(A.x,A.y,A.width,A.height,A.rotation),w=[{value:B.minX,anchor:-1},{value:B.minX+(B.maxX-B.minX)/2,anchor:0},{value:B.minX+(B.maxX-B.minX),anchor:1}],d=[{value:B.minY,anchor:-1},{value:B.minY+(B.maxY-B.minY)/2,anchor:0},{value:B.minY+(B.maxY-B.minY),anchor:1}],h=[{value:A.rotation,anchor:0}],E=(A,e,i,s)=>{const r=[];return e.forEach((e=>{const o=i.find((A=>nA(e,A.value,1.7*n))),[c,g]=((A,t)=>[{x:"x"===A?t:a.x,y:"x"===A?a.y:t},{x:"x"===A?t:a.x+a.width,y:"x"===A?a.y+a.height:t}])(A,e),l="rotation"===A?null:(0,t.jsx)("line",{x1:c.x,y1:c.y,x2:g.x,y2:g.y,stroke:s||"#D61B5C",strokeWidth:1.2*n},`${A}-${e}-${c.x}-${c.y}-${g.x}-${g.y}`);void 0!==o&&r.push({type:A,value:e,anchorPoint:o.anchor,svgNode:l,guidelineCoordinates:[c,g]})})),r};return o.push(...E("x",Array.from(c),w,i),...E("y",Array.from(g),d,i),...E("rotation",l,h,i)),o};let Qn;var un;let In;var Dn;(un=Qn||(Qn={})).Translate="Translate",un.Rotate="Rotate",un.Resize="Resize",(Dn=In||(In={})).ControlLeft="ControlLeft",Dn.ControlRight="ControlRight",Dn.Equal="Equal",Dn.MetaLeft="MetaLeft",Dn.MetaRight="MetaRight",Dn.Minus="Minus",Dn.ArrowLeft="ArrowLeft",Dn.ArrowRight="ArrowRight",Dn.ArrowUp="ArrowUp",Dn.ArrowDown="ArrowDown",Dn.AltLeft="AltLeft",Dn.AltRight="AltRight",Dn.Delete="Delete",Dn.Backspace="Backspace";const mn=(A,t,e,n)=>{const i=()=>{switch(e){case k.Pixel:return 1;case k.Millimeter:return dA;case k.Centimeter:return hA;default:throw new Re("Unknown unit of measurement")}};let a=t.x,s=t.y,r=t.x,o=t.y;switch(A){case In.ArrowLeft:r=t.x-1/i();break;case In.ArrowUp:o=t.y-1/i();break;case In.ArrowRight:r=t.x+1/i();break;case In.ArrowDown:o=t.y+1/i();break;default:throw new Re("Unhandled element interaction!")}const c=_(r,o,t.width,t.height,t.rotation);return(!n||c.minX>=n.left&&c.maxX<=n.left+n.width&&c.minY>=n.top&&c.maxY<=n.top+n.height)&&(a=r,s=o),new Nt(t.id,a,s)};var pn=0,fn=0,Mn=0;const yn=(A,t,e,n,i,a)=>{const s=_(A,t,e,n,i),r=s.maxX-s.minX,o=s.maxY-s.minY,c=.1;return!a||s.maxX-c*r>=a.left&&s.minX+c*r<=a.left+a.width&&s.maxY-c*o>=a.top&&s.minY+c*o<=a.top+a.height},Fn=(A,t,e,n,i,a,s)=>{const r=((A,t,e,n,i,a,s)=>{const r=n.width/t.width,o=n.height/t.height,c=A.mX/r,g=A.mY/o,l=e.rotation*Math.PI/180,B=Math.sin(l),w=Math.cos(l),d=e.type===P.Textbox?1:e.width/e.height;switch(i.type){case Qn.Resize:let t={top:e.y,left:e.x,width:e.width,height:e.height,rotation:e.rotation,fontSize:e.fontSize},h=t;switch(i.screenAxis){case O.North:{const A=-c*B+g*w,n=e.y+A,i=e.height-A,a=BA({...e}).center,s=BA({...e,y:n,height:i}).center,r=wA(s,a,l),o=r.x-e.width/2,d=r.y-i/2;h={...t,left:o,top:d,height:i}}break;case O.East:{const A=c*w+g*B,n=e.width+A;let i=e.height;if(e.type===P.Textbox){const A=e;i=ZA(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const a=BA({...e}).center,s=BA({...e,width:n,height:i}).center,r=wA(s,a,l),o=r.x-n/2,d=r.y-i/2;h={...t,left:o,top:d,width:n,height:i}}break;case O.West:{const A=c*w+g*B,n=e.x+A,i=e.width-A;let a=e.height;if(e.type===P.Textbox){const A=e;a=ZA(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const s=BA({...e}).center,r=BA({...e,width:i,height:a,x:n}).center,o=wA(r,s,l),d=o.x-i/2,E=o.y-a/2;h={...t,left:d,top:E,width:i,height:a}}break;case O.South:{const A=-c*B+g*w,n=e.height+A,i=BA({...e}).center,a=BA({...e,height:n}).center,s=wA(a,i,l),r=s.x-e.width/2,o=s.y-n/2;h={...t,left:r,top:o,height:n}}break;case O.Northeast:{const A=c*w+g*B,n=e.width+A;let i=e.height+A/d,a=e.y-A/d,s=e.fontSize;if(e.type===P.Textbox){const t=e;s=t.fontSize+A/8,i=ZA(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||at;a=e.y-A*n/8}const r=BA({...e}).center,o=BA({...e,width:n,height:i,y:a}).center,E=wA(o,r,l),C=E.x-n/2,Q=E.y-i/2;h={...t,left:C,top:Q,width:n,height:i,fontSize:s}}break;case O.Northwest:{const A=-c*w+-g*B,n=e.x-A,i=e.width+A;let a=e.y-A/d,s=e.height+A/d,r=e.fontSize;if(e.type===P.Textbox){const t=e;r=t.fontSize+A/8,s=ZA(r,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||at;a=e.y-A*n/8}const o=BA({...e}).center,E=BA({...e,x:n,y:a,width:i,height:s}).center,C=wA(E,o,l),Q=C.x-i/2,u=C.y-s/2;h={...t,left:Q,top:u,width:i,height:s,fontSize:r}}break;case O.Southeast:{const A=c*w+g*B,n=e.width+A;let i=e.height+A/d,a=e.fontSize;if(e.type===P.Textbox){const t=e;a=t.fontSize+A/8,i=ZA(a,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const s=BA({...e}).center,r=BA({...e,width:n,height:i}).center,o=wA(r,s,l),E=o.x-n/2,C=o.y-i/2;h={...t,left:E,top:C,width:n,height:i,fontSize:a}}break;case O.Southwest:{const A=-c*w+-g*B,n=e.width+A;let i=e.x-A,a=e.height+A/d,s=e.fontSize;if(e.type===P.Textbox){const t=e;s=t.fontSize+A/8,a=ZA(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const r=BA({...e}).center,o=BA({...e,width:n,height:a,x:i}).center,E=wA(o,r,l),C=E.x-n/2,Q=E.y-a/2;h={...t,left:C,top:Q,width:n,height:a,fontSize:s}}}return yn(h.left,h.top,h.width,h.height,h.rotation,s)&&(t=h),t;case Qn.Rotate:const E={x:A.clientX,y:A.clientY};let C,Q=e.rotation;const u=BA(e,n,{x:r,y:o}),I=AA(E,u.c,u.d),D=AA(E,u.d,u.c);if(0===a.filter((A=>"rotation"===A.type)).length)Mn=0,C=(e.rotation+I-D)%360;else{Mn+=Math.sqrt(c**2+g**2);const A=Math.abs(Mn)>2*window.devicePixelRatio/r;C=A?(e.rotation+I-D)%360:a.find((A=>"rotation"===A.type))?.value||0,A&&(Mn=0)}return yn(e.x,e.y,e.width,e.height,C,s)&&(Q=C),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:Q};case Qn.Translate:let m,p,f=e.x,M=e.y;if(0===a.filter((A=>"rotation"!==A.type)).length)pn=0,fn=0,m=e.x+c,p=e.y+g;else{const A=a.find((A=>"x"===A.type)),t=a.find((A=>"y"===A.type));A||(pn=0),t||(fn=0);const n=Math.abs(pn)>2*window.devicePixelRatio/r,i=Math.abs(fn)>2*window.devicePixelRatio/o,s=A=>{switch(A){case-1:return 0;case 0:return e.width/2;case 1:return e.width;default:return 0}},l=A=>{switch(A){case-1:return 0;case 0:return e.height/2;case 1:return e.height;default:return 0}};if(0!==e.rotation)m=A?n?e.x+pn:e.x:e.x+c,p=t?i?e.y+fn:e.y:e.y+g;else{if(A){const t=A.value-s(A.anchorPoint);m=n?t+pn:t}else m=e.x+c;if(t){const A=t.value-l(t.anchorPoint);p=i?A+fn:A}else p=e.y+g}pn=n?0:pn+c,fn=i?0:fn+g}return yn(m,p,e.width,e.height,e.rotation,s)&&(f=m,M=p),{top:M,left:f,width:e.width,height:e.height,rotation:e.rotation}}})(A,t,e,n,i,a,s),o=[];if(e.type===P.Textbox){const A=e;o.push(new Kt(A.id,A.input||""))}if(r.width>0&&r.height>0&&(o.push(new Nt(e.id,r.left,r.top),new Pt(e.id,r.width,r.height),new St(e.id,r.rotation)),e.type===P.Textbox)){const A=e;r.fontSize&&A.fontSize!==r.fontSize&&o.push(new Ot(A.id,r.fontSize))}return o},xn=A=>{const{onPointerDown:e,scaleFactor:n,elementWidth:i}=A,a=(0,Q.useCallback)((A=>{A.stopPropagation(),e&&e(A)}),[e]),s=13*n,r=30*n;return(0,t.jsxs)("g",{transform:`translate(${r})`,children:[(0,t.jsx)("circle",{cx:i/2,cy:-2.5*s,r:1.3*s,fill:"transparent",style:{cursor:"pointer"},onPointerDown:a}),(0,t.jsxs)("svg",{onPointerDown:a,x:i/2-s,y:-2.5*s-s,width:2*s,height:2*s,style:{cursor:"pointer"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,t.jsx)("path",{d:"M10.3246 4.31731C10.751 2.5609 13.249 2.5609 13.6754 4.31731C13.9508 5.45193 15.2507 5.99038 16.2478 5.38285C17.7913 4.44239 19.5576 6.2087 18.6172 7.75218C18.0096 8.74925 18.5481 10.0492 19.6827 10.3246C21.4391 10.751 21.4391 13.249 19.6827 13.6754C18.5481 13.9508 18.0096 15.2507 18.6172 16.2478C19.5576 17.7913 17.7913 19.5576 16.2478 18.6172C15.2507 18.0096 13.9508 18.5481 13.6754 19.6827C13.249 21.4391 10.751 21.4391 10.3246 19.6827C10.0492 18.5481 8.74926 18.0096 7.75219 18.6172C6.2087 19.5576 4.44239 17.7913 5.38285 16.2478C5.99038 15.2507 5.45193 13.9508 4.31731 13.6754C2.5609 13.249 2.5609 10.751 4.31731 10.3246C5.45193 10.0492 5.99037 8.74926 5.38285 7.75218C4.44239 6.2087 6.2087 4.44239 7.75219 5.38285C8.74926 5.99037 10.0492 5.45193 10.3246 4.31731Z",stroke:"#111827",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M15 12C15 13.6569 13.6569 15 12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9C13.6569 9 15 10.3431 15 12Z",stroke:"#111827",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]})},Yn="#ffffff",vn=A=>{const{isMobile:e,outerRadius:n,x:i,y:a,cursorStyle:s,onPointerDown:r,handleClass:o,cornerRadius:c,color:g,strokeWidth:l}=A,[B,w]=(0,Q.useState)(!1);(0,Q.useEffect)((()=>{const A=()=>{w(!1)};return document.addEventListener("pointerup",A),()=>{document.removeEventListener("pointerup",A)}}),[]);const d=(0,Q.useCallback)((A=>{w(!0),r(A)}),[r]);return e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("circle",{cx:i,cy:a,r:n,fill:B?"rgba(0,0,0,0.5)":"rgba(0,0,0,0)",style:{cursor:s},onPointerDown:d}),(0,t.jsx)("circle",{className:o,cx:i,cy:a,r:c,fill:Yn,style:{cursor:s,pointerEvents:"none"},stroke:g,strokeWidth:l})]}):(0,t.jsx)("circle",{className:o,cx:i,cy:a,r:c,fill:Yn,style:{cursor:s},stroke:g,strokeWidth:l,onPointerDown:r})},Nn=A=>{const{isMobile:e,outerRadius:n,outerWidth:i,outerHeight:a,x:s,y:r,width:o,height:c,cursorStyle:g,onPointerDown:l,edgeHandleRadius:B,color:w,strokeWidth:d}=A,[h,E]=(0,Q.useState)(!1);(0,Q.useEffect)((()=>{const A=()=>{E(!1)};return document.addEventListener("pointerup",A),()=>{document.removeEventListener("pointerup",A)}}),[]);const C=(0,Q.useCallback)((A=>{E(!0),l(A)}),[l]);return e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:s-(i-o)/2,y:r-(a-c)/2,width:i,height:a,rx:n,fill:h?"rgba(0,0,0,0.5)":"rgba(0,0,0,0)",style:{cursor:g},onPointerDown:C}),(0,t.jsx)("rect",{x:s,y:r,width:o,height:c,rx:B,fill:Yn,style:{cursor:g,pointerEvents:"none"},stroke:w,strokeWidth:d})]}):(0,t.jsx)("rect",{x:s,y:r,width:o,height:c,rx:B,fill:Yn,style:{cursor:g},stroke:w,strokeWidth:d,onPointerDown:l})},Sn=A=>{const{isMobile:e,color:n,elementHeight:i,elementWidth:a,onBeginResize:s,rotation:r,scaleFactor:o,disableX:c,disableY:g}=A,l=7.5*o,B=3*o,w=28*o,d=6*o,h=30*o,E=5*o,C=40*o,u=36*o,I=1.2*o,D=(0,Q.useCallback)(((A,t,e)=>{A.stopPropagation(),s(t,e)}),[s]),m=(0,Q.useCallback)((A=>D(A,lA(O.West,360-r),O.West)),[D,r]),p=(0,Q.useCallback)((A=>D(A,lA(O.East,360-r),O.East)),[D,r]),f=(0,Q.useCallback)((A=>D(A,lA(O.North,360-r),O.North)),[D,r]),M=(0,Q.useCallback)((A=>D(A,lA(O.South,360-r),O.South)),[D,r]),y=(0,Q.useCallback)((A=>D(A,O.Northwest,O.Northwest)),[D]),F=(0,Q.useCallback)((A=>D(A,O.Northeast,O.Northeast)),[D]),x=(0,Q.useCallback)((A=>D(A,O.Southwest,O.Southwest)),[D]),Y=(0,Q.useCallback)((A=>D(A,O.Northeast,O.Southeast)),[D]),v=(e?i-2*h-C:i-2*l-w)>0&&(e?a-2*h-C:a-2*l-w)>0;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(vn,{isMobile:e,outerRadius:h,x:0,y:0,cursorStyle:"nw-resize",onPointerDown:y,handleClass:"cornerNorthWest",cornerRadius:l,color:n,strokeWidth:I}),v?(0,t.jsx)(vn,{isMobile:e,outerRadius:h,x:a,y:0,cursorStyle:"ne-resize",onPointerDown:F,handleClass:"cornerNorthEast",cornerRadius:l,color:n,strokeWidth:I}):void 0,v?(0,t.jsx)(vn,{isMobile:e,outerRadius:h,x:a,y:i,cursorStyle:"se-resize",onPointerDown:Y,handleClass:"cornerSouthEast",cornerRadius:l,color:n,strokeWidth:I}):void 0,v?(0,t.jsx)(vn,{isMobile:e,outerRadius:h,x:0,y:i,cursorStyle:"sw-resize",onPointerDown:x,handleClass:"cornerSouthWest",cornerRadius:l,color:n,strokeWidth:I}):void 0,v&&!c?(0,t.jsx)(Nn,{isMobile:e,outerRadius:E,outerWidth:u,outerHeight:C,x:-d/2,y:i/2-w/2,width:d,height:w,onPointerDown:m,edgeHandleRadius:B,cursorStyle:"w-resize",color:n,strokeWidth:I}):void 0,v&&!g?(0,t.jsx)(Nn,{isMobile:e,outerRadius:E,outerWidth:C,outerHeight:u,x:a/2-w/2,y:i-d/2,width:w,height:d,onPointerDown:M,edgeHandleRadius:B,cursorStyle:"s-resize",color:n,strokeWidth:I}):void 0,c?void 0:(0,t.jsx)(Nn,{isMobile:e,outerRadius:E,outerWidth:u,outerHeight:C,x:a-d/2,y:i/2-Math.min(w,.8*i)/2,width:d,height:Math.min(w,.8*i),onPointerDown:p,edgeHandleRadius:B,cursorStyle:"e-resize",color:n,strokeWidth:I}),v&&!g?(0,t.jsx)(Nn,{isMobile:e,outerRadius:E,outerWidth:C,outerHeight:u,x:a/2-w/2,y:-d/2,width:w,height:d,onPointerDown:f,edgeHandleRadius:B,cursorStyle:"n-resize",color:n,strokeWidth:I}):void 0]})},Pn=A=>{const{isMobile:e,color:n,elementWidth:i,onBeginRotate:a,scaleFactor:s}=A,r=(0,Q.useCallback)((A=>{A.stopPropagation(),a()}),[a]),o=13*s,c=30*s;return(0,t.jsxs)("g",{transform:e?`translate(${-c})`:void 0,children:[(0,t.jsx)("circle",{cx:i/2,cy:-2.5*o,r:1.3*o,fill:"transparent",style:{cursor:"ew-resize"},onPointerDown:r}),(0,t.jsxs)("svg",{x:i/2-o,y:-2.5*o-o,xmlns:"http://www.w3.org/2000/svg",style:{cursor:"ew-resize"},height:2*o,viewBox:"0 0 24 24",width:2*o,stroke:n,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",onPointerDown:r,children:[" ",(0,t.jsx)("polyline",{points:"23 4 23 10 17 10"})," ",(0,t.jsx)("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})]})},Rn="spiffElementID",Hn=({color:A,height:e,highlighted:n,id:i,immutable:a,onBeginMove:s,onPointerEnter:r,onPointerLeave:o,onSelected:c,pressed:g,rotation:l,scaleFactor:B,selected:w,width:d,x:h,y:E})=>{const C=1.2*B,{addEvent:u,removeEvent:I,curActiveEvents:D}=nn(),m=(0,Q.useCallback)((A=>{u(A),A[Rn]=i;0===D&&0===A.button&&(c(i,A),s())}),[i,w,D,c,s]),p=(0,Q.useCallback)((A=>{I(A)}),[]),f=(0,Q.useCallback)((A=>{r(i)}),[i,D,r]),M=(0,Q.useCallback)((A=>{I(A),o(i)}),[i,D,o]),y=a?void 0:w?g?"grabbing":"grab":"pointer",F=a?"none":"visibleFill";return(0,t.jsx)("g",{transform:`translate(${h}, ${E}) rotate(${l} ${d/2} ${e/2})`,children:(0,t.jsx)("rect",{className:"interactableInnerRect",width:d,height:e,stroke:w||n?A:"none",pointerEvents:F,fill:"none",strokeWidth:C,style:{cursor:y},onPointerDown:a?void 0:m,onPointerUp:a?void 0:p,onPointerEnter:a?void 0:f,onPointerLeave:a?void 0:M})})},Un=A=>{const{isMobile:e,color:n,height:i,onBeginResize:a,onBeginRotate:s,onContextMenuHandlePointerDown:r,rotation:o,scaleFactor:c,width:g,x:l,y:B,disableX:w,disableY:d}=A;return(0,t.jsxs)("g",{transform:`translate(${l}, ${B}) rotate(${o} ${g/2} ${i/2})`,children:[(0,t.jsx)(Pn,{isMobile:e&&!!r,color:n,elementWidth:g,onBeginRotate:s,scaleFactor:c}),e&&r&&(0,t.jsx)(xn,{onPointerDown:r,elementWidth:g,scaleFactor:c}),(0,t.jsx)(Sn,{isMobile:e,color:n,elementHeight:i,elementWidth:g,rotation:o,scaleFactor:c,onBeginResize:a,disableX:w,disableY:d})]})},Gn=.5,bn=["TEXTAREA","INPUT"],kn=(A,t,e,n,i,a,s,r)=>{const{state:o,uiDispatcher:c}=(0,Q.useContext)(ln),{getLayoutById:g,getReducerState:l,flattenSequence:B}=an(),[w,d]=(0,Q.useState)(void 0),[h,E]=(0,Q.useState)(void 0),[C,u]=(0,Q.useState)(void 0),I=g(o.layoutId);(0,Q.useEffect)((()=>{if("adjustment"===i&&A?.current&&n){if(n<Gn)return void c(new wn({zoom:Gn}));if(n>o.maxZoom)return void c(new wn({zoom:o.maxZoom}));c(new wn({zoom:n}))}}),[n,c,A,i,o.maxZoom]);const D=(0,Q.useCallback)(((A,n)=>{c(new wn({zoom:n}));const a=t?.current?.scrollWidth-t?.current?.clientWidth!=0,s=t?.current?.scrollHeight-t?.current?.clientHeight!=0;t.current&&e.current&&!o.scrolledMovement&&"advanced"===i&&(s&&(t.current.scrollTop=e.current.offsetTop+(t.current.scrollHeight-t.current.clientHeight)/2),a&&(t.current.scrollLeft=(e.current.offsetLeft+t.current.scrollWidth-t.current.clientWidth)/2))}),[c,t,e,o.scrolledMovement,i]);(0,Q.useEffect)((()=>{o.zoom<=1&&c(new wn({scrolledMovement:!1}))}),[c,o.zoom]);const m=t?.current?.getBoundingClientRect(),p=((m?.width||1)+(m?.height||1))/2,f=(I.layoutState.layout.width+I.layoutState.layout.height)/2/p/o.zoom,M=(0,Q.useMemo)((()=>{const A=o.activeModifierKeys,t=o.elementEvent,e=A.includes(In.ControlLeft)||A.includes(In.MetaLeft)||A.includes(In.ControlRight)||A.includes(In.MetaRight);if(!o.selectedElement||!t||e)return[];const n=t&&t.type===Qn.Translate,i=t&&t.type===Qn.Rotate,a=I.layoutState.elements.find((A=>A.id===o.selectedElement));return(n||i)&&a?Cn(a,I.layoutState,f,s):[]}),[o.selectedElement,o.elementEvent,o.activeModifierKeys,I.layoutState,f]),y=(0,Q.useCallback)((()=>{const A=Y();d(A),E(l().transaction)}),[l]),F=(0,Q.useCallback)((A=>{A[Rn]||o.selectedElement&&c(new wn({selectedElement:void 0}))}),[o,c]),x=(0,Q.useCallback)((()=>{c(new wn({scrolledMovement:!0}))}),[c]),v=(0,Q.useCallback)(((e,n)=>{const i=I.layoutState.elements.find((A=>A.id===o.selectedElement));if(!(o.elementEvent&&A.current&&t.current&&o.selectedElement&&i&&e.isPrimary))return void(t.current.hasPointerCapture(e.pointerId)&&t.current.releasePointerCapture(e.pointerId));t.current.hasPointerCapture(e.pointerId)||t.current.setPointerCapture(e.pointerId);const s=A.current.getBoundingClientRect(),r=new Rt(Fn({mX:C?e.screenX-C.screenX:0,mY:C?e.screenY-C.screenY:0,clientX:e.clientX,clientY:e.clientY},I.layoutState.layout,i,s,o.elementEvent,M,n));r.sequenceId=w,a(r,!1),u({screenX:e.screenX,screenY:e.screenY})}),[I.layoutState.elements,I.layoutState.layout,o.elementEvent,A,o.selectedElement,t,M,a,C]),N=(0,Q.useCallback)((A=>{c(new wn({elementEvent:A}))}),[c]),S=(0,Q.useCallback)((()=>{N(void 0),w&&h&&(B(w,h),d(void 0),E(void 0),r&&r()),u(void 0)}),[N,w,h,B,r]),P=(0,Q.useCallback)(((A,t)=>{let e=o.zoom;const n=o.maxZoom,s=o.selectedElement,r=o.activeModifierKeys;if((r.includes(In.AltLeft)||r.includes(In.AltRight))&&(A.code===In.Equal||A.code===In.Minus)){const t=.05*n;A.code===In.Equal?c(new wn({zoom:e+t<=n?e+=t:e})):c(new wn({zoom:e-t>=Gn?e-t:e}))}const g=I.layoutState.elements.find((A=>A.id===s));if(s&&g){if(A.code===In.MetaLeft||A.code===In.ControlLeft||A.code===In.MetaRight||A.code===In.ControlRight){const t=A.code,e=o.activeModifierKeys;if(!e.includes(t))return c(new wn({activeModifierKeys:e.concat(t)}))}if(A.code===In.ArrowDown||A.code===In.ArrowUp||A.code===In.ArrowLeft||A.code===In.ArrowRight){c(new wn({elementEvent:{type:Qn.Translate}}));const e=mn(A.code,g,o.units,t);a(e,!1),c(new wn({elementEvent:void 0}))}A.code!==In.Delete&&A.code!==In.Backspace||"advanced"!==i||(c(new wn({selectedElement:void 0})),a(new bt(g.id),!1))}}),[a,c,I.layoutState.elements,i,o.activeModifierKeys,o.maxZoom,o.selectedElement,o.units,o.zoom]),R=(0,Q.useCallback)((A=>{if(A.code===In.MetaLeft||A.code===In.ControlLeft||A.code===In.MetaRight||A.code===In.ControlRight){const t=o.activeModifierKeys,e=A.code;c(new wn({activeModifierKeys:t.filter((A=>A!==e))}))}}),[c,o.activeModifierKeys]);return{guidelines:M,scale:f,zoomableElementRef:e,setElementEvent:N,handleZoom:D,handleKeyDown:P,handleKeyUp:R,handlePointerPressedBackground:F,handlePointerReleased:S,handlePointerMove:v,handleScroll:x,handleSequenceStart:y}},Jn=(A,t,e)=>{const n=(0,Q.useMemo)((()=>[...new Set(A)].map((A=>String(A).toLowerCase()))),[]),i=(0,Q.useRef)([]),a=(0,Q.useCallback)((()=>{const A=n.every((A=>i.current.includes(A))),t=i.current.length===n.length;return A&&t}),[]),s=(0,Q.useCallback)((A=>{const e=String(A.key).toLowerCase();if(A.repeat||"meta"===e)return;const n=A.target;return!(bn.indexOf(n.tagName)>=0)&&(i.current=[...new Set([...i.current,e])],a()&&t(),A.preventDefault())}),[a,n,t,A]),r=(0,Q.useCallback)((A=>{const t=String(A.key).toLowerCase(),n=a();i.current=i.current.filter((A=>A!==t));const s=a();e&&n&&!s&&e()}),[n]);(0,Q.useEffect)((()=>(window.addEventListener("keydown",s),window.addEventListener("keyup",r),()=>{window.removeEventListener("keydown",s),window.removeEventListener("keyup",r)})),[s,r])},On=A=>{const{isMobile:e,primaryColor:n,customViewbox:i,editorRef:a,elementEvent:s,guidelines:r,layoutHeight:o,layoutWidth:c,targetedElements:g,scale:l,selectedElement:B,onElementEvent:w,onElementSelected:d,onSequenceStart:h,onMouseMove:E,onContextMenuHandlePointerDown:C}=A,{state:u}=dn(),{getLayoutById:I}=an(),D=I(u.layoutId),[m,p]=(0,Q.useState)(void 0),f=(0,Q.useCallback)((A=>{p(A)}),[]),M=(0,Q.useCallback)((A=>{m===A&&p(void 0)}),[m]),y=(0,Q.useCallback)((()=>{h(),w({type:Qn.Translate})}),[w]),F=(0,Q.useCallback)(((A,t)=>{h(),w({type:Qn.Resize,relativeAxis:A,screenAxis:t})}),[w]),x=(0,Q.useCallback)((()=>{h(),w({type:Qn.Rotate})}),[w]),Y=i||{x:0,y:0,width:c,height:o},v=D.layoutState.elements,N=v.find((A=>A.id===B));return(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",style:{touchAction:"none",position:"absolute",maxWidth:"100%",maxHeight:"100%",overflow:"visible"},width:"auto",height:"auto",viewBox:`${Y.x} ${Y.y} ${Y.width} ${Y.height}`,children:[(0,t.jsx)("rect",{onMouseMove:E,style:{pointerEvents:"all"},fill:"none",stroke:"none",ref:a,width:c,height:o}),r.map((A=>A.svgNode)),v.map((A=>{const e=void 0!==B&&A.id===B,i=e&&void 0!==s,a=void 0!==m&&A.id===m;return(0,t.jsx)(Hn,{color:n,id:A.id,selected:e,highlighted:a,pressed:i,x:A.x,y:A.y,width:A.width,height:A.height,rotation:A.rotation,immutable:A.immutable||g&&!g.includes(A.id),onSelected:d,onBeginMove:y,onPointerEnter:f,onPointerLeave:M,scaleFactor:l},A.id)})),N&&(0,t.jsx)(Un,{isMobile:e,color:n,x:N.x,y:N.y,disableX:N.type===P.Frame||N.type===P.Image,disableY:N.type===P.Textbox||N.type===P.Frame||N.type===P.Image,width:N.width,height:N.height,rotation:N.rotation,onBeginResize:F,onBeginRotate:x,scaleFactor:l,onContextMenuHandlePointerDown:C})]})},zn=A=>{const{isMobile:e,color:n,editorRef:i,zoomableElementRef:a,interactionElementRef:s,guidelines:r,isMakingAdjustments:o,outlineArea:c,visibleLayoutId:g,xTranslation:l,yTranslation:B,targetedElements:w,borderRadius:d,canvasFilter:h,handleContextMenu:E,onMouseMove:C,onContextMenuHandlePointerDown:u,handleKeyDown:I,handleKeyUp:D,handlePointerMove:m,handlePointerPressedBackground:p,handlePointerReleased:f,handleScroll:M,onSequenceStart:y,setElementEvent:F,onElementSelected:x}=A,{getLayoutById:Y}=an(),v=Y(g),N=v.layoutState,{state:S}=dn(),P=(0,Q.useCallback)((A=>{if(c){const t={left:c.x||0,top:c.y||0,width:c.width||1,height:c.height||1,panelId:"",rotation:0};return I(A,t)}return I(A)}),[I,c]),R=(0,Q.useCallback)((A=>{if(c){const t={left:c.x||0,top:c.y||0,width:c.width||1,height:c.height||1,panelId:"",rotation:0};return m(A,t)}return m(A)}),[m,c]),U=(0,Q.useMemo)((()=>{return{justifyContent:"center",position:"relative",height:"100%",width:"100%",scrollbarWidth:"none",outline:(A=window.chrome,t=window.navigator,e=t.vendor,n=void 0!==window.opr,t.userAgent.match("CriOS")||null==A||"Google Inc."!==e||!1!==n?void 0:"none")};var A,t,e,n}),[]),G=(0,Q.useMemo)((()=>({height:"100%",transform:`scale(${S.zoom}) translate(${l}px, ${B}px)`,display:"flex",justifyContent:"center",alignItems:"center",filter:h||"drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.2))",overflow:"visible"})),[S.zoom,S.xTranslation,S.yTranslation]),b=10/S.zoom,k=N.layout.width,J=N.layout.height,O=a.current?.offsetHeight||1024,z=a.current?.offsetWidth||1024,j=b*(Math.sqrt(k*J)/1e3)*(100/Math.sqrt(O*z))*Math.sqrt((L=z/O,Math.exp(Math.abs(Math.log(L)))));var L;const T=(0,Q.useMemo)((()=>({configuration:{purpose:H.FreeDesign},height:o?"100%":"auto",width:o?"100%":"auto",maxHeight:"100%",maxWidth:"100%",position:"absolute",outlineArea:c?{...c,scale:j}:void 0,borderRadius:d})),[o,j]);return(0,t.jsx)("div",{style:U,onContextMenu:E,onKeyDown:P,onKeyUp:D,onPointerDown:p,onMouseLeave:f,onPointerMoveCapture:R,onPointerUp:f,onWheelCapture:M,ref:s,tabIndex:-1,children:(0,t.jsxs)("div",{ref:a,style:G,children:[A.children,v.getComponentWithProps(T),(0,t.jsx)(On,{isMobile:e,primaryColor:n,editorRef:i,elementEvent:S.elementEvent,guidelines:r,layoutHeight:N.layout.height,layoutWidth:N.layout.width,onElementEvent:F,onSequenceStart:y,onElementSelected:x,scale:j,selectedElement:S.selectedElement,targetedElements:w,onMouseMove:C,onContextMenuHandlePointerDown:u})]})})},jn=({isMobile:A,color:e,borderRadius:n,guidelineColor:i,canvasFilter:a,hideEditableAreaRect:s,handleContextMenu:r,onMouseMove:o,onContextMenuHandlePointerDown:c,onElementSelected:g,onDragEnd:l})=>{const{commandDispatcher:B,getLayoutById:w}=an(),{state:d,uiDispatcher:h}=dn(),E=(0,Q.useRef)(null),C=(0,Q.useRef)(null),u=(0,Q.useRef)(null),{guidelines:I,handleKeyDown:D,handleKeyUp:m,handlePointerMove:p,handlePointerPressedBackground:f,handlePointerReleased:M,handleScroll:y,handleSequenceStart:F,setElementEvent:x}=kn(E,C,u,void 0,"advanced",B,i,l),Y=(0,Q.useMemo)((()=>w(d.layoutId)),[w,d.layoutId]),v=(0,Q.useCallback)(((A,t)=>{const e=Y.layoutState.elements.find((t=>t.id===A));if(A&&e&&e.type===P.Textbox){const t=e.algorithm;(!t||t===G.Autosize)&&B(new zt(A,G.Traditional),!0)}g&&g(A,t),h(new wn({selectedElement:A}))}),[B,w,d.layoutId,h]),N=(0,Q.useMemo)((()=>{if(Y.layoutState.layout.useEditableArea)return{...Y.layoutState.layout.editableArea,hidden:s}}),[Y.layoutState.layout.useEditableArea,Y.layoutState.layout.editableArea,s]);return(0,t.jsx)(zn,{outlineArea:N,isMobile:A,color:e,editorRef:E,interactionElementRef:C,zoomableElementRef:u,guidelines:I,visibleLayoutId:d.layoutId,xTranslation:d.xTranslation,yTranslation:d.yTranslation,borderRadius:n,canvasFilter:a,handleContextMenu:r,onMouseMove:o,onContextMenuHandlePointerDown:c,handleKeyDown:D,handleKeyUp:m,handlePointerMove:p,handlePointerPressedBackground:f,handlePointerReleased:M,handleScroll:y,onSequenceStart:F,setElementEvent:x,onElementSelected:v})},Ln=d.gql`
1
+ var A=require("lodash.clonedeep"),t=require("react/jsx-runtime"),e=require("react-dom/server"),n=require("opentype.js"),i=require("buffer"),a=require("axios"),s=require("https"),r=require("file-type"),o=require("util"),c=require("css"),g=require("canvas"),l=require("exif"),B=require("canvg"),w=require("swagger-client"),d=require("@apollo/client"),h=require("@apollo/client/link/context"),E=require("@apollo/client/link/error"),C=require("cross-fetch"),Q=require("react"),u=require("lodash.isequal"),I=require("lodash.debounce"),D=require("qrcode"),m=require("svg-path-bbox");function p(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function M(A){return A&&A.__esModule?A.default:A}function y(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}p(module.exports,"SpiffCommerceClient",(()=>La)),p(module.exports,"CommandContext",(()=>It)),p(module.exports,"spiffCoreConfiguration",(()=>je)),p(module.exports,"PromiseQueue",(()=>ri)),p(module.exports,"QueueablePromise",(()=>si)),p(module.exports,"MockWorkflowManager",(()=>Wa)),p(module.exports,"InformationMessageType",(()=>Aa)),p(module.exports,"StepHandle",(()=>aa)),p(module.exports,"TextStepHandle",(()=>Ba)),p(module.exports,"FrameStepHandle",(()=>_a)),p(module.exports,"ShapeStepHandle",(()=>la)),p(module.exports,"IllustrationStepHandle",(()=>sa)),p(module.exports,"MaterialStepHandle",(()=>ra)),p(module.exports,"ModelStepHandle",(()=>oa)),p(module.exports,"PictureStepHandle",(()=>ca)),p(module.exports,"QuestionStepHandle",(()=>ga)),p(module.exports,"OptionNotFoundError",(()=>xe)),p(module.exports,"LayoutNotFoundError",(()=>Ye)),p(module.exports,"AssetNotFoundError",(()=>ve)),p(module.exports,"ResourceNotFoundError",(()=>Ne)),p(module.exports,"MisconfigurationError",(()=>Se)),p(module.exports,"ParseError",(()=>He)),p(module.exports,"UnhandledBehaviorError",(()=>Re)),p(module.exports,"assetService",(()=>_e)),p(module.exports,"designService",(()=>Da)),p(module.exports,"createDesign",(()=>Qa)),p(module.exports,"optionService",(()=>tn)),p(module.exports,"server",(()=>Xe)),p(module.exports,"persistenceService",(()=>Oe)),p(module.exports,"graphQlManager",(()=>We)),p(module.exports,"toast",(()=>xi)),p(module.exports,"FrameService",(()=>li)),p(module.exports,"frameStepService",(()=>ui)),p(module.exports,"modelStepService",(()=>mi)),p(module.exports,"materialStepService",(()=>Di)),p(module.exports,"shapeStepService",(()=>yi)),p(module.exports,"questionStepService",(()=>Mi)),p(module.exports,"digitalContentStepService",(()=>Ci)),p(module.exports,"moduleStepService",(()=>pi)),p(module.exports,"pictureStepService",(()=>fi)),p(module.exports,"textStepService",(()=>Si)),p(module.exports,"illustrationStepService",(()=>Ii)),p(module.exports,"ProductCameraRig",(()=>hn)),p(module.exports,"FrameStep",(()=>qa)),p(module.exports,"AssetType",(()=>T)),p(module.exports,"BringForwardCommand",(()=>Wt)),p(module.exports,"CanvasCommand",(()=>Yt)),p(module.exports,"CreateElementCommand",(()=>Gt)),p(module.exports,"CreateLayoutCommand",(()=>Ht)),p(module.exports,"DeleteElementCommand",(()=>bt)),p(module.exports,"FontAlignmentCommand",(()=>Lt)),p(module.exports,"FontColorCommand",(()=>Jt)),p(module.exports,"FontSizeCommand",(()=>Ot)),p(module.exports,"FontSourceCommand",(()=>jt)),p(module.exports,"GroupCommand",(()=>Rt)),p(module.exports,"LayoutElementFactory",(()=>fe)),p(module.exports,"LayoutElementType",(()=>P)),p(module.exports,"MoveCommand",(()=>Nt)),p(module.exports,"ResizeCommand",(()=>Pt)),p(module.exports,"RotateCommand",(()=>St)),p(module.exports,"SendBackwardsCommand",(()=>Zt)),p(module.exports,"StepAspectType",(()=>W)),p(module.exports,"StepType",(()=>V)),p(module.exports,"TextChangeCommand",(()=>Kt)),p(module.exports,"UnitOfMeasurement",(()=>k)),p(module.exports,"dataUrlFromExternalUrl",(()=>UA)),p(module.exports,"findElement",(()=>Mt)),p(module.exports,"frameDataCache",(()=>se)),p(module.exports,"generate",(()=>Y)),p(module.exports,"getAxisAlignedBoundingBox",(()=>_)),p(module.exports,"generateSVGWithUnknownColors",(()=>Qt)),p(module.exports,"getAttributesFromArrayBuffer",(()=>ne)),p(module.exports,"rehydrateSerializedLayout",(()=>xt)),p(module.exports,"getFrameData",(()=>ge)),p(module.exports,"getSvgString",(()=>mt)),p(module.exports,"loadFontFromDataUrl",(()=>KA)),p(module.exports,"loadFontFromExternalUrl",(()=>TA)),p(module.exports,"determineCorrectFontSizeAndLines",(()=>Ce)),p(module.exports,"patternImageDataCache",(()=>ae)),p(module.exports,"generateCommands",(()=>Ra)),p(module.exports,"registerJSDOM",(()=>fA)),p(module.exports,"minZoom",(()=>Gn)),p(module.exports,"AdvancedEditor",(()=>jn)),p(module.exports,"TransformWrapper",(()=>As)),p(module.exports,"EditorCore",(()=>zn)),p(module.exports,"useLayouts",(()=>an)),p(module.exports,"useEditorState",(()=>dn)),p(module.exports,"useEditorInteraction",(()=>kn)),p(module.exports,"useShortcutCombination",(()=>Jn)),p(module.exports,"commandReducer",(()=>gn)),p(module.exports,"getDefaultState",(()=>cn)),p(module.exports,"CommandContextContext",(()=>en)),p(module.exports,"AdvancedEditorStateProvider",(()=>Bn)),p(module.exports,"AdvancedEditorContext",(()=>ln)),p(module.exports,"UICommand",(()=>wn)),p(module.exports,"EditorSubMenu",(()=>rn)),p(module.exports,"ElementEventType",(()=>Qn)),p(module.exports,"KeyEvent",(()=>In)),p(module.exports,"gatherVaryingStepAspects",(()=>$n));var F="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==f?f:{},x={};y(x,"CanvasCommand",(()=>Yt)),y(x,"UpdateWorkflowStateCommand",(()=>vt)),y(x,"MoveCommand",(()=>Nt)),y(x,"RotateCommand",(()=>St)),y(x,"ResizeCommand",(()=>Pt)),y(x,"GroupCommand",(()=>Rt)),y(x,"CreateLayoutCommand",(()=>Ht)),y(x,"ClearLayoutCommand",(()=>Ut)),y(x,"CreateElementCommand",(()=>Gt)),y(x,"DeleteElementCommand",(()=>bt)),y(x,"CloneElementCommand",(()=>kt)),y(x,"FontColorCommand",(()=>Jt)),y(x,"FontSizeCommand",(()=>Ot)),y(x,"FontAlgorithmCommand",(()=>zt)),y(x,"FontSourceCommand",(()=>jt)),y(x,"FontAlignmentCommand",(()=>Lt)),y(x,"UpdateFramePattern",(()=>Tt)),y(x,"TextChangeCommand",(()=>Kt)),y(x,"IllustrationColorCommand",(()=>Vt)),y(x,"IllustrationCacheCommand",(()=>Xt)),y(x,"BringForwardCommand",(()=>Wt)),y(x,"SendBackwardsCommand",(()=>Zt)),y(x,"LayerCommand",(()=>qt)),y({},"generate",(()=>Y));const Y=()=>{const A=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return A()+A()+"-"+A()+"-"+A()+"-"+A()+"-"+A()+A()+A()};var v={};y(v,"ElementNotFoundError",(()=>ft)),y(v,"findElement",(()=>Mt)),y(v,"findLayoutForElement",(()=>yt)),y(v,"updatedLayoutForElement",(()=>Ft)),y(v,"rehydrateSerializedLayout",(()=>xt));var N={};y(N,"CommandContext",(()=>It)),y(N,"elementFactory",(()=>Dt)),y(N,"getSvgString",(()=>mt)),y(N,"sortElementsByLayersWithIndex",(()=>pt)),y({},"SVGLayout",(()=>q));var S={};let P;var R;let H;var U;let G;var b;let k;var J;let O;var z;let j;var L;let T;var K;let V;var X;let W;var Z;y(S,"LayoutElementType",(()=>P)),y(S,"LayoutRenderingPurpose",(()=>H)),y(S,"TextAlgorithm",(()=>G)),y(S,"UnitOfMeasurement",(()=>k)),y(S,"ScaleAxis",(()=>O)),y(S,"MaterialEffectMode",(()=>j)),y(S,"AssetType",(()=>T)),y(S,"StepType",(()=>V)),y(S,"StepAspectType",(()=>W)),(R=P||(P={})).Frame="frame",R.Image="image",R.Illustration="illustration",R.Textbox="textbox",(U=H||(H={}))[U.ThreeD=0]="ThreeD",U[U.FreeDesign=1]="FreeDesign",U[U.Print=2]="Print",(b=G||(G={})).Autosize="Autosize",b.Traditional="Traditional",(J=k||(k={})).Pixel="px",J.Millimeter="mm",J.Centimeter="cm",(z=O||(O={}))[z.North=0]="North",z[z.Northeast=1]="Northeast",z[z.East=2]="East",z[z.Southeast=3]="Southeast",z[z.South=4]="South",z[z.Southwest=5]="Southwest",z[z.West=6]="West",z[z.Northwest=7]="Northwest",(L=j||(j={})).None="None",L.RemoveWhenSelected="RemoveWhenSelected",L.ApplyWhenSelected="ApplyWhenSelected",(K=T||(T={})).Font="Font",K.Frame="Frame",K.Illustration="Illustration",K.Image="Image",K.Model="Model",K.Material="Material",K.Color="Color",K.QuestionnaireCollateral="QuestionnaireCollateral",K.RequestCollateral="RequestCollateral",K.SignupCollateral="SignupCollateral",K.Video="Video",K.ColorProfile="ColorProfile",(X=V||(V={})).Bulk="Bulk",X.DigitalContent="DigitalContent",X.Finish="Finish",X.Frame="Frame",X.Illustration="Illustration",X.Introduction="Introduction",X.Material="Material",X.Model="Model",X.Module="Module",X.Picture="Picture",X.Photo="Photo",X.ProductOverlay="ProductOverlay",X.Question="Question",X.Shape="Shape",X.SilentIllustration="SilentIllustration",X.Text="Text",(Z=W||(W={})).Color="Color",Z.Colors="Colors",Z.Selection="Selection",Z.Selections="Selections",Z.Text="Text",Z.Upload="Upload";const q=({backgroundColor:A,borderRadius:e,configuration:n,elements:i,height:a,maxHeight:s,maxWidth:r,outlineArea:o,position:c,preserveAspectRatio:g,viewBox:l,width:B})=>{const w=e||0,d=2*(o?.scale||1),h=l||{x:0,y:0,width:B,height:a},E=`${h.x} ${h.y} ${h.width} ${h.height}`,C=Y(),Q=n.purpose===H.FreeDesign&&(0,t.jsx)("defs",{children:(0,t.jsx)("clipPath",{id:"viewboxClip",children:(0,t.jsx)("rect",{width:h.width,height:h.height,rx:w})})}),u=n.colorProfiles?.map(((A,e)=>(0,t.jsx)("color-profile",{name:A.name,xlinkHref:A.key,children:" "},e))),I=pt(i.map((A=>({...A,_renderingConfiguration:n,mask:o?`url(#viewmask-${C})`:void 0}))));return(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",preserveAspectRatio:g,width:B,height:a,style:{gridColumn:1,gridRow:1,maxWidth:r,maxHeight:s,position:c},viewBox:E,children:[u,Q,!!A&&(0,t.jsx)("rect",{id:"layout-background",width:h.width,height:h.height,fill:A,rx:w}),(0,t.jsx)("g",{id:"element-group",clipPath:n.purpose===H.FreeDesign?"url(#viewboxClip)":void 0,children:I.map((A=>Dt(A))).filter((A=>!!A))}),o&&(0,t.jsx)("rect",{x:o.x,y:o.y,width:o.width,height:o.height,fill:"none",stroke:o.hidden?"none":"#aaaaaa",strokeWidth:d/2,strokeDasharray:`${2*d} ${d}`}),o&&(0,t.jsxs)("mask",{id:`viewmask-${C}`,children:[(0,t.jsx)("rect",{x:h.x,y:h.y,width:h.width,height:h.height,fill:"black"}),(0,t.jsx)("rect",{x:o.x,y:o.y,width:o.width,height:o.height,fill:"white"})]})]})};y({},"Image",(()=>EA));var $={};y($,"getAxisAlignedBoundingBox",(()=>_)),y($,"degreesToRadians",(()=>tA)),y($,"findAngle",(()=>AA)),y($,"radiansToDegrees",(()=>eA)),y($,"isCloseToValue",(()=>nA)),y($,"getTrueCoordinates",(()=>iA)),y($,"getPointOfRotation",(()=>aA)),y($,"getNWPoint",(()=>sA)),y($,"getNEPoint",(()=>rA)),y($,"getSWPoint",(()=>oA)),y($,"getSEPoint",(()=>cA)),y($,"turnRightClockwise",(()=>gA)),y($,"currentDirection",(()=>lA)),y($,"getElementVertices",(()=>BA)),y($,"rotateAroundPoint",(()=>wA)),y($,"mmPerPixel",(()=>dA)),y($,"cmPerPixel",(()=>hA));const _=(A,t,e,n,i)=>{const a=tA(i),s=e/2,r=n/2,o=A+s,c=t+r,g=Math.sin(a),l=Math.cos(a),B=-r,w=s*l-B*g,d=s*l-r*g,h=s*g+B*l,E=s*g+r*l,C=Math.max(Math.abs(w),Math.abs(d)),Q=Math.max(Math.abs(h),Math.abs(E));return{minX:o-C,maxX:o+C,minY:c-Q,maxY:c+Q}},AA=(A,t,e)=>{const n=Math.sqrt(Math.pow(t.x-A.x,2)+Math.pow(t.y-A.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=Math.sqrt(Math.pow(e.x-A.x,2)+Math.pow(e.y-A.y,2));return Math.acos((i*i+n*n-a*a)/(2*i*n))*(180/Math.PI)},tA=A=>A*(Math.PI/180),eA=A=>A*(180/Math.PI),nA=(A,t,e)=>Math.abs(A-t)<e,iA=(A,t,e)=>{const n=Math.sin(tA(e)),i=Math.cos(tA(e));return{x:(A.x-t.x)*i-(A.y-t.y)*n+t.x,y:(A.x-t.x)*n+(A.y-t.y)*i+t.y}},aA=(A,t)=>({x:(A.x+t.x)/2,y:(A.y+t.y)/2}),sA=(A,t,e,n)=>({x:A.x+t?.x*e,y:A.y+t?.y*n}),rA=(A,t,e,n)=>({x:A.x+(t?.x+t?.width)*e,y:A.y+t?.y*n}),oA=(A,t,e,n)=>({x:A.x+t?.x*e,y:A.y+(t?.y+t?.height)*n}),cA=(A,t,e,n)=>({x:A.x+(t?.x+t?.width)*e,y:A.y+(t?.y+t?.height)*n}),gA=A=>{switch(A){case O.North:return O.East;case O.East:return O.South;case O.South:return O.West;case O.West:return O.North;case O.Northwest:return O.Northeast;case O.Northeast:return O.Southeast;case O.Southeast:return O.Southwest;case O.Southwest:return O.Northwest}},lA=(A,t)=>t>45&&t<=135?gA(A):t>135&&t<=225?gA(gA(A)):t>225&&t<=315?gA(gA(gA(A))):A,BA=(A,t={x:0,y:0},e={x:1,y:1})=>{const n=tA(A.rotation),i={x:t.x+A.x*e.x,y:t.x+A.y*e.y},a={x:A.x+A.width,y:A.y},s={x:t.x+(A.x+A.width)*e.x,y:t.y+(A.height+A.y)*e.y},r={x:t.x+A.x*e.x,y:t.y+(A.height+A.y)*e.y},o={x:(r.x+s.x)/2,y:r.y-A.height*e.y/2};return{a:wA(i,o,n),b:wA(a,o,n),c:wA(s,o,n),d:wA(r,o,n),center:o}},wA=(A,t,e)=>{const n=Math.sin(e),i=Math.cos(e);return{x:(A.x-t.x)*i-(A.y-t.y)*n+t.x,y:(A.x-t.x)*n+(A.y-t.y)*i+t.y}},dA=.352778,hA=.035277,EA=A=>{const e=A.rotation||0,n=tA(e),i=Math.cos(n),a=-Math.sin(n);return(0,t.jsx)("g",{mask:A.stepName||A.productOverlay?void 0:A.mask,children:(0,t.jsx)("g",{transform:`\n matrix(1, 0, 0, 1, ${A.x}, ${A.y})\n matrix(1, 0, 0, 1, ${A.width/2}, ${A.height/2})\n matrix(${i}, ${-a}, ${a}, ${i}, 0, 0)\n matrix(1, 0, 0, 1, ${-A.width/2}, ${-A.height/2})\n `,children:(0,t.jsx)("image",{xlinkHref:A.src,preserveAspectRatio:A.preserveAspectRatio,width:A.width,height:A.height})})})};y({},"Frame",(()=>CA));const CA=A=>{const e=`spiff-frame-${A.id}`,n=`spiff-frame-blur-${A.id}`,i=`spiff-frame-blur-edge-${A.id}`,a=`spiff-frame-focal-mask-${A.id}`,s=!!A.focalBlur&&!!A.pattern,r=A.rotation||0,o=tA(r),c=Math.cos(o),g=-Math.sin(o);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("defs",{children:(s=>{const r=A.pattern?.x||0,o=A.pattern?.y||0,c=A.pattern?A.pattern.width*A.pattern.scaleX+Math.abs(r):256,g=A.pattern?A.pattern.height*A.pattern.scaleY+Math.abs(o):256,l=A.pattern?A.pattern.width*A.pattern.scaleX:256,B=A.pattern?A.pattern.height*A.pattern.scaleY:256;return(0,t.jsxs)("g",{mask:A.stepName?void 0:A.mask,children:[(0,t.jsx)("pattern",{patternUnits:A.pattern?void 0:"userSpaceOnUse",x:0,y:0,width:A.pattern?1:c,height:A.pattern?1:g,"data-frame-width":A.pattern?c:void 0,"data-frame-height":A.pattern?g:void 0,id:e,children:(0,t.jsx)("image",{preserveAspectRatio:"none",x:r,y:o,width:l,height:B,xlinkHref:A.disablePlaceholder?"":A.pattern?A.pattern.src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAAAsSAAALEgHS3X78AAAZL0lEQVR4nO2diVIbSRZFq/GCsZBZjRea6fn/r+oZGrMYBBhkLGwzE1cmTSqVWXuqVFXnRHREG6OlpX43X771j5O/7/+XAEAvWeFrB+gvCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAECP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YJoIZFX8lR3kAQDpLLQU2FfsIxHIs7ADEQCon4X3AlTZ2pN3kAcA5GPhApBV7FNWBJjPD1Cc3AJQ59z7OkQgNMgDEQDITy4BMCOx65zWkyYCagXOIjTIAxEAyE+mANgjsese2RUSga/fvuYK7IUGeeTpOwCADAEwRm/GY5UZ2ZVFqNhHgT0tDMkiNMiDjj6AbFIFQEU4WsNtE0MEQsU+WhiSJ/bAIA+AcuTqBrR7+w0xmnHktmuAiE3a+m/f4zn5AfKTKwhYx/DOPMh4tRzERi3FeTMQGD9AMXKnASUCmo1vk3d4ZxGGw4254R7jr7d8rQARKFQItLuzVzp3nxcFBV1vg4g+QBwKCUDVAp68DJ3hnpPJhK8fIAKFS4EXIQJ6DfsaUGecAQCeKNULsAgRYMgnQHxKNwPFFgH71NfMfwCon0rdgEYE3NNaIlBlZJeM3xaA1dXV2v/DAaCGdmCJwLtAKW/ZQR1XV6OZPw+c9CMA1EMt8wDSBnWcnh0Xug64S0Xk/jP9FyAOtQ0ECYnA7fj291afLNRfcOq0Am9v72Q+DgDKUftmINM+bDoIbVTmqxy/rg0ucvsvLi9mfqoGnzoWfgKAnyirwdJEIHl069fW1qb/Ls/g7u5uzkOgqw8gPtF2A+bd7+ejSAcgAJQnmgAYfK59iOma7923yfpgyFcKsACiC0Dy6OZLCMbjsfdaIMPf3NgMxgcAIA4LEQAbpfkkCA8/fyYrjzX/9PEDNMPzRb+qjH2NLxtgKVj4YhAAWB4QAIAegwAA9BgEAKDHIAAAPQYBAOgxCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAEBfSZLk/xjo1hVZWiK0AAAAAElFTkSuQmCC"})}),s?(0,t.jsx)(QA,{path:A.path,width:A.width,height:A.height,focalBlurStrength:A.focalBlurStrength||1,focalBlurRadius:A.focalBlurRadius||10,blurFilterId:n,focalMaskId:a,blurEdgeClipId:i}):null]})})(s)}),(0,t.jsx)("g",{mask:A.stepName?void 0:A.mask,children:(0,t.jsxs)("g",{transform:`\n matrix(1, 0, 0, 1, ${A.x}, ${A.y})\n matrix(1, 0, 0, 1, ${A.width/2}, ${A.height/2})\n matrix(${c}, ${-g}, ${g}, ${c}, 0, 0)\n matrix(1, 0, 0, 1, ${-A.width/2}, ${-A.height/2})\n matrix(${A.scaleX}, 0, 0, ${A.scaleY}, 0, 0)\n `,children:[(0,t.jsx)("path",{filter:s?`url(#${n})`:void 0,mask:s?`url(#${i})`:void 0,d:A.path,style:{fill:`url(#${e})`,opacity:A.opacity}}),s?(0,t.jsx)("path",{mask:`url(#${a})`,d:A.path,style:{fill:`url(#${e})`,opacity:A.opacity}}):void 0]})})]})},QA=A=>{const{path:e,width:n,height:i,focalBlurStrength:a,focalBlurRadius:s,blurFilterId:r,focalMaskId:o,blurEdgeClipId:c}=A;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("filter",{id:r,children:(0,t.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,t.jsx)("mask",{id:o,children:(0,t.jsx)("circle",{cx:n/2,cy:i/2,r:s||0,fill:"white",filter:`url(#${r})`})}),(0,t.jsx)("mask",{id:c,children:(0,t.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};y({},"Textbox",(()=>gt));var uA={};y(uA,"fontSizeStep",(()=>qA)),y(uA,"textWidth",(()=>$A)),y(uA,"applyTextTransformations",(()=>At)),y(uA,"zip",(()=>tt)),y(uA,"getTextAlignment",(()=>et)),y(uA,"getAnchor",(()=>nt)),y(uA,"recomputeTextOnElement",(()=>it)),y(uA,"defaultLineHeightFactor",(()=>at)),y({},"calculateTextboxLines",(()=>ZA));var IA={};y(IA,"FontMetrics",(()=>jA)),y(IA,"loadFontFromExternalUrl",(()=>TA)),y(IA,"loadFontFromDataUrl",(()=>KA)),y(IA,"getFontMetrics",(()=>VA));var DA={};y(DA,"registerJSDOM",(()=>fA)),y(DA,"createElement",(()=>xA)),y(DA,"createElementNS",(()=>YA)),y(DA,"domParser",(()=>vA)),y(DA,"fetchAsArrayBuffer",(()=>NA)),y(DA,"fetchAsString",(()=>SA)),y(DA,"loadFontFaceSet",(()=>PA)),y(DA,"xmlSerializer",(()=>RA)),y(DA,"toBase64",(()=>HA)),y(DA,"dataUrlFromExternalUrl",(()=>UA)),y(DA,"arrayBufferToDataUrl",(()=>GA)),y(DA,"arrayBufferToBuffer",(()=>kA)),y(DA,"dataUrlToArrayBuffer",(()=>bA));var mA=i.Buffer;let pA;function fA(A){pA=A}function MA(){if(!pA)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new pA}if(void 0===F.TextEncoder){const{TextEncoder:A}=o;F.TextEncoder=A}if(void 0===F.TextDecoder){const{TextDecoder:A}=o;F.TextDecoder=A}const yA=new(M(s).Agent)({rejectUnauthorized:!0}),FA=A=>A.every((A=>"undefined"!==A)),xA=A=>FA([typeof document])?document.createElement(A):MA().window.document.createElement(A),YA=(A,t)=>{if(FA([typeof document]))return document.createElementNS(A,t);const e=MA().window.document.createElement(t);return e.setAttribute("xmlns",A),e},vA=()=>FA([typeof DOMParser])?new DOMParser:new(MA().window.DOMParser),NA=A=>{if(FA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.arrayBuffer())})).catch((A=>{e(A)}))}));{const t=A.replace("localhost","localstack");return new Promise(((A,e)=>{M(a).get(t,{responseType:"arraybuffer",httpsAgent:yA}).then((t=>{A(t.data)})).catch((A=>{e(A)}))}))}},SA=A=>{if(FA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.text())})).catch(e)}));{const t=A.replace("localhost","localstack");return new Promise(((A,e)=>{M(a).get(t,{responseType:"text",httpsAgent:yA}).then((t=>{A(t.data)})).catch(e)}))}},PA=async(A,t)=>{if(FA([typeof FontFace])){const e=A.names.fullName.en,n=new FontFace(e,`url(${t})`);return document.fonts.add(n),n.load()}},RA=()=>FA([typeof XMLSerializer])?new XMLSerializer:new(MA().window.XMLSerializer),HA=A=>FA([typeof btoa])?btoa(A):mA.from(A).toString("base64"),UA=async A=>{if(FA([typeof fetch,typeof Blob,typeof FileReader])){const t=await fetch(A),e=await t.blob();return await OA(e)}const t=(await M(a).get(A,{responseType:"arraybuffer"})).data;return GA(t)},GA=async A=>{const t=await(async A=>{const t=await(0,r.fromBuffer)(A);return t?t.mime:"image/svg+xml"})(A);return`data:${t};base64,${kA(A).toString("base64")}`},bA=A=>{const t=A.replace(/\r?\n/g,""),e=t.indexOf(",");if(-1===e||e<=4)throw new TypeError("malformed data: URI");const n=t.substring(5,e).split(";");let i=!1;for(let A=1;A<n.length;A++)"base64"===n[A]&&(i=!0);const a=i?"base64":"ascii",s=unescape(t.substring(e+1)),r=mA.from(s,a);return JA(r)},kA=A=>mA.from(A),JA=A=>{const t=new ArrayBuffer(A.byteLength),e=new Uint8Array(t);for(let t=0;t<A.length;++t)e[t]=A[t];return t},OA=A=>new Promise(((t,e)=>{const n=new FileReader;n.onload=function(A){const n=A.target;n&&n.result?t(n.result.toString()):e()},n.readAsDataURL(A)})),zA=new Map;class jA{constructor(A){this.font=A,this.glyphsFromText=new Map,this.kerningValues=new Map,this.height=this.calculateApproximateHeight()}getFont(){return this.font}getGlyphs(A){const t=this.glyphsFromText.get(A);if(t)return t;const e=this.font.stringToGlyphs(A);return this.glyphsFromText.set(A,e),e}getApproximateHeight(){return this.height}getExactHeight(A){const t=this.font.stringToGlyphs(A);let e=0,n=0;return t.forEach((A=>{const t=A.getMetrics();e=Math.max(e,t.yMax),n=Math.min(n,t.yMin)})),e-n}getKerningValue(A,t){let e=this.kerningValues.get(A.name);e||(e=new Map,this.kerningValues.set(A.name,e));let n=e.get(t.name);return n||(n=this.font.getKerningValue(A,t),e.set(t.name,n)),n}calculateApproximateHeight(){const A=this.font.stringToGlyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");let t=0,e=0;return A.forEach((A=>{const n=A.getMetrics();t=Math.max(t,n.yMax),e=Math.min(e,n.yMin)})),t-e}}const LA=A=>"data:"===A.substring(0,5).toLowerCase().trim(),TA=async A=>{const t=LA(A)?KA(A):KA(await UA(A));return XA(t,{assetUrl:LA(A)?A:await UA(A),name:t.names.fullName.en}),await PA(t,A),t},KA=A=>{const t=bA(A),e=M(n).parse(t);return XA(e,{assetUrl:A,name:e.names.fullName.en}),e},VA=A=>{const t=zA.get(A.name);if(t)return t;throw new Error("Font metrics unavailable for font")},XA=(A,t)=>{const e=new jA(A);return zA.set(t.name,e),e},WA=(A,t,e,n)=>{const i=$A(A,e,n);if(i<=t)return{lines:[A],width:i};if(!(A.indexOf(" ")>-1)){if(A.length<=1)throw new Error(`Character ${A} is wider than region`);const i=Math.floor(A.length/2),a=WA(A.slice(0,i),t,e,n),s=WA(A.slice(i),t,e,n);return{lines:[...a.lines,...s.lines],width:Math.max(a.width,s.width)}}const a=A.split(" "),s=[];let r=-1/0,o=0;for(;o<a.length;){const A=a[o];if($A(A,e,n)>t){const i=WA(A,t,e,n);s.push(...i.lines),r=Math.max(r,i.width),o++}else{const i=[A];r=Math.max(r,$A(A,e,n));let c=o+1,g=!0;for(;c<a.length&&g;){const A=a[c],s=$A(`${i.join(" ")} ${A}`,e,n);s<=t?(i.push(A),r=Math.max(r,s),c++):g=!1}s.push(i.join(" ")),o=c}}if(r<0)throw new Error(`No max width calculated for text: ${s}.`);return{lines:s,width:r}},ZA=(A,t,e,n,i)=>{const a=VA(t),s=a.getFont();return((A,t,e,n,i,a)=>{const s=a||at,r=t.split("\n");try{const t=r.flatMap((t=>WA(t,A.width,n,i)));return{lines:t.flatMap((A=>A.lines)),requiredHeight:t.flatMap((A=>A.lines)).length*(e*s),requiredWidth:Math.max(...t.map((A=>A.width)))}}catch(A){return{lines:[],requiredHeight:NaN,requiredWidth:NaN}}})(e,At(n),A,A/s.unitsPerEm,a,i)},qA=1,$A=(A,t,e)=>{let n=0;const i=e.getGlyphs(A);return i.forEach(((A,t)=>{if(A.advanceWidth&&(n+=A.advanceWidth),t<i.length-1){const a=e.getKerningValue(A,i[t+1]);n+=a}})),n*=t,n},_A={stripControlCharacters:!0,vertical:!1,uppercase:!1},At=(A,t=_A)=>{const e={..._A,...t};let n=A;return e.stripControlCharacters&&(n=n.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),e.uppercase&&(n=n.toUpperCase()),e.vertical&&(n=n.split("").join("\n")),n},tt=(A,t)=>A.map(((A,e)=>[A,t[e]])),et=(A="center",t=!1)=>t?"center":A,nt=A=>"left"===A?"start":"right"===A?"end":"middle",it=(A,t)=>A.fontData?{...A,...(()=>{if(A.algorithm===G.Traditional){const e=ZA(A.fontSize,A.fontData,A,t,A.lineHeight);return{text:e.lines.join("\n"),height:e.requiredHeight,input:t}}return{text:t}})()}:A,at=1.1;var st={};y(st,"colorDefinitionPrintValue",(()=>rt)),y(st,"spotColorDefinitionString",(()=>ot)),y(st,"svgColorValueToDefinition",(()=>ct));const rt=A=>{const t=ot(A.spotColor);return t?`${A.browserValue} ${t}`:A.browserValue},ot=A=>{if(!A)return"";if(A.profileName.includes("/")&&A.profileName.includes(".icc")){const t=A.profileName.replace(/\s/g,"-"),e=t.lastIndexOf("/");return`icc-named-color(${t.slice(e+1).slice(0,-4)}, ${A.namedColor})`}return`icc-named-color(${A.profileName}, ${A.namedColor})`},ct=A=>{const t=A.split(/[ ](?=[^)]*?(?:\(|$))/);if(0===t.length)return{browserValue:"#000000"};if(1===t.length)return{browserValue:t[0]};const e=t[1].match(/\(([^)]+)\)/gm);if(!e)throw new Error("Unhandled state of color value in SVG");const n=e[0].replace(/[() ]/g,"").split(",");return{browserValue:t[0],spotColor:{profileName:n[0],namedColor:n[1]}}},gt=A=>{const e=(A.rotation||0)*Math.PI/180,n=Math.cos(e),i=-Math.sin(e),a=`text-path-${A.id}`,s=A.x+(A.curved?0:A.width/2),r=A.y+(A.curved?0:A.height/2),o=(A.text||"").split("\n");return A.curved&&!A.paths?null:A.fontData?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("defs",{children:[(0,t.jsx)("style",{type:"text/css",dangerouslySetInnerHTML:{__html:`\n @font-face {\n font-family: '${A.fontData.name}';\n src: url('${A.fontData.assetUrl}') format('truetype');\n }\n `}}),A.curved&&A.paths?(0,t.jsx)("path",{id:a,d:A.paths[0]}):void 0]}),A._renderingConfiguration?.debug?(0,t.jsx)("rect",{stroke:"blue",fill:"none",x:A.x,y:A.y,width:A.width,height:A.height}):void 0,(0,t.jsx)("g",{mask:A.stepName?void 0:A.mask,children:(0,t.jsx)("g",{transform:`matrix(${n}, ${-i}, ${i}, ${n}, ${s}, ${r})`,children:(0,t.jsx)("text",{xmlSpace:"preserve",fontFamily:`'${A.fontData.name}'`,fontSize:A.fontSize,fontStyle:"normal",fontWeight:"normal",fill:A._renderingConfiguration?.spotColors&&A.fillSpotColorDefinition?`${A.fill} ${ot(A.fillSpotColorDefinition)}`:A.fill,style:{whiteSpace:"pre",userSelect:"none"},children:A.curved?(0,t.jsx)(Bt,{text:A.text||"",curvedPathId:a,align:A.align}):o.map(((e,n)=>(0,t.jsx)(lt,{align:A.vertical?"center":A.align,fontSize:A.fontSize,thisLineIdx:n,amountLines:o.length,text:e,textboxHeight:A.height,textboxWidth:A.width,lineHeight:A.lineHeight,vertical:A.vertical,verticalAlign:A.verticalAlign},n)))})})})]}):null},lt=A=>(0,t.jsx)("tspan",{textAnchor:nt(A.align),x:"left"===A.align?-A.textboxWidth/2:"right"===A.align?A.textboxWidth/2:0,y:`${(()=>{const t=A.fontSize*(void 0!==A.lineHeight?A.lineHeight:at),e=A.textboxHeight/2;if("top"===A.verticalAlign)return-e+3*A.fontSize/4+A.thisLineIdx*t;if("bottom"===A.verticalAlign){const n=A.amountLines-1-A.thisLineIdx;return e-A.fontSize/4-n*t}const n=(A.amountLines-1)/2;return(A.thisLineIdx-n)*t+A.fontSize/4})()}px`,children:A.text}),Bt=A=>{const e=`#${A.curvedPathId}`;return(0,t.jsx)("textPath",{startOffset:"left"===A.align?"0%":"right"===A.align?"100%":"50%",textAnchor:nt(A.align),href:e,xlinkHref:e,children:A.text})};y({},"Illustration",(()=>ut));var wt={};y(wt,"traverse",(()=>ht)),y(wt,"sanitizeSvgTree",(()=>Et)),y(wt,"modifySVGWithElementProperties",(()=>Ct)),y(wt,"generateSVGWithUnknownColors",(()=>Qt));const dt=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],ht=(A,t)=>{t(A),A.children.length>0&&Array.from(A.children).forEach((A=>ht(A,t)))},Et=(A,t=!1)=>{!t&&A.setAttribute("preserveAspectRatio","none");const e=[];ht(A,(A=>{if("script"!==A.tagName)if("style"!==A.tagName);else try{(0,c.parse)(A.innerHTML).stylesheet?.rules.forEach((A=>{e.push(A)})),A.remove()}catch(A){console.error(A)}else A.remove()})),ht(A,(A=>{e.forEach((t=>{t.selectors?.forEach((e=>{((A,t)=>{try{return A.matches(t)}catch(e){return A.classList.contains(t.substring(1))}})(A,e)&&t.declarations?.forEach((t=>{t.property&&t.value&&A.setAttribute(t.property,t.value)}))}))}))}))},Ct=(A,t,e,n,i)=>{const a=(A=>vA().parseFromString(A,"image/svg+xml").firstElementChild)(A);if(!a)throw new Error("Failed to read SVG.");return((A,t,e)=>{A.setAttribute("height",`${e}px`),A.setAttribute("width",`${t}px`)})(a,t,e),((A,t,e)=>{ht(A,(A=>{const n=A.attributes.getNamedItem("fill");n&&"none"!==n.value&&A.classList.forEach((n=>{if(n.startsWith("spiff-fill")){const i=t[n];i&&A.setAttribute("fill",e?rt(i):i.browserValue)}}));const i=A.attributes.getNamedItem("stroke");i&&"none"!==i.value&&A.classList.forEach((n=>{if(n.startsWith("spiff-stroke")){const i=t[n];i&&A.setAttribute("stroke",e?rt(i):i.browserValue)}}))}))})(a,n,i),(A=>RA().serializeToString(A))(a)},Qt=async A=>{const t=A.match(/<svg.*?<\/svg>/s)||[],e=t?.length>0?t[0]:"",n=vA().parseFromString(e,"image/svg+xml").firstElementChild;if(!n)throw new Error("Failed to read SVG.");Et(n);const i={};ht(n,(A=>{dt.includes(A.tagName)&&!A.attributes.getNamedItem("fill")&&A.setAttribute("fill","black");const t=A.attributes.getNamedItem("fill");if(t&&"none"!==t.value){const e=ct(t.value),n=`spiff-fill-${e.browserValue.replace(/\W/g,"")}`;A.setAttribute("fill",e.browserValue),A.classList.add(n),i[n]=e}const e=A.attributes.getNamedItem("stroke");if(e&&"none"!==e.value){const t=ct(e.value),n=`spiff-stroke-${t.browserValue.replace(/\W/g,"")}`;A.classList.add(n),A.setAttribute("stroke",t.browserValue),i[n]=t}}));const a=RA().serializeToString(n);return{colors:i,svg:a}},ut=A=>{if(A.cachedObjectURL&&!A._renderingConfiguration?.omitCachedFields)return(0,t.jsx)(EA,{id:A.id,src:A.cachedObjectURL,x:A.x,y:A.y,width:A.width,height:A.height,rotation:A.rotation,preserveAspectRatio:"none",immutable:A.immutable,mask:A.stepName?void 0:A.mask});const e=A.rotation||0,n=tA(e),i=Math.cos(n),a=-Math.sin(n),s=`\n matrix(1, 0, 0, 1, ${A.x}, ${A.y})\n matrix(1, 0, 0, 1, ${A.width/2}, ${A.height/2})\n matrix(${i}, ${-a}, ${a}, ${i}, 0, 0)\n matrix(1, 0, 0, 1, ${-A.width/2}, ${-A.height/2})\n `;if(!A.svg)throw new Error(`Illustration element ${A.id} (stepName ${A.stepName}) lacked svg from src ${A.src} at render time.`);return(0,t.jsx)("g",{mask:A.stepName?void 0:A.mask,children:(0,t.jsx)("g",{transform:s,dangerouslySetInnerHTML:{__html:Ct(A.svg,A.width,A.height,A.colors,A._renderingConfiguration?.spotColors)}})})};class It{constructor(){this.id=Y(),this.stateCallbacks=[],this.prevCommands=[],this.nextCommands=[]}registerStateCallback(A){this.stateCallbacks.push(A)}unregisterStateCallback(A){this.stateCallbacks.filter((t=>t!==A))}getState(){return this.state}runStateCallbacks(){this.stateCallbacks.forEach((A=>A()))}apply(A,t){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);this.state=this.commandReducer(this.state,A),this.runStateCallbacks(),this.nextCommands=[],t||this.prevCommands.push(A)}undo(){if(!this.state)return;const A=this.prevCommands.pop();if(!A)return;const t=A.undo();A.varying?this.state={...this.state,variation:t}:this.state={...this.state,transaction:t},this.nextCommands.push(A),this.runStateCallbacks()}redo(){if(!this.state)return;const A=this.nextCommands.pop();A&&(this.state=this.commandReducer(this.state,A),this.runStateCallbacks(),this.prevCommands.push(A))}flattenSequence(A,t){const e=this.prevCommands.filter((t=>t.sequenceId===A)).pop();e&&(this.prevCommands=this.prevCommands.filter((t=>t.sequenceId!==A)),e?.overrideOldState(t),this.prevCommands.push(e))}getLayoutById(A){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const t=this.state.transaction?.layouts?.[A],e=this.state.variation?.layouts?.[A],n=t?.layout||e?.layout;if(!n)throw new Error(`No layout: ${A}`);const i=[...t?.elements||[],...e?.elements||[]];return this.getLayoutDataWithState(n,i)}getAllLayouts(){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const A=[...Object.keys(this.state.transaction?.layouts),...Object.keys(this.state.variation?.layouts||{})];return[...new Set(A)].map((A=>this.getLayoutById(A)))}getLayoutDataWithState(A,e){return{layoutState:{layout:A,elements:e},getComponentWithProps:n=>(0,t.jsx)(q,{backgroundColor:A.transparentBackground?void 0:"white",elements:e,width:A.width,height:A.height,viewBox:{x:0,y:0,width:A.width,height:A.height},...n})}}initialize(A,t){if(t)return void(this.state={transaction:t});let e={serializableWorkflow:{steps:[]},layouts:{}};A.forEach((A=>{e=new Ht(A).apply(e)})),this.runStateCallbacks(),this.state={transaction:e}}commandReducer(A,t){if(t.varying){const e={layouts:{},serializableWorkflow:{steps:[]},...A.variation};return{...A,variation:t.apply(e)}}{const e=A.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...A,transaction:t.apply(e)}}}}const Dt=A=>"image"===A.type?(0,t.jsx)(EA,{...A},A.id):"frame"===A.type?(0,t.jsx)(CA,{...A},A.id):"illustration"===A.type?(0,t.jsx)(ut,{...A},A.id):"textbox"===A.type?(0,t.jsx)(gt,{...A},A.id):null,mt=(A,n,i)=>{const a={backgroundColor:A.transparentBackground?void 0:"white"},s={width:i?.region?i.region.width:A.width,height:i?.region?i.region.height:A.height,viewBox:i?.region?{x:i.region.left,y:i.region.top,width:i.region.width,height:i.region.height}:{x:0,y:0,width:A.width,height:A.height}},r=i?.removeExcludedElements?n.filter((A=>!A.excludeFromExport)):n;try{return M(e).renderToStaticMarkup((0,t.jsx)(q,{preserveAspectRatio:"none",...a,...s,elements:r,configuration:i}))}catch(A){return console.error("Error rendering to static markup"),console.error(A),""}};function pt(A){return A.sort(((A,t)=>{const e=A.layer||0,n=t.layer||0;if(e<n)return-1;if(e>n)return 1;const i=A.layerIndex||0,a=t.layerIndex||0;return i<a?-1:i>a?1:0}))}class ft extends Error{constructor(A){super("No element found with ID: "+A),Object.setPrototypeOf(this,ft.prototype)}}const Mt=(A,t)=>yt(A,t).elements.find((t=>t.id===A)),yt=(A,t)=>{const e=Object.values(t).find((t=>t.elements.some((t=>t.id===A))));if(!e)throw new ft(A);return e},Ft=(A,t)=>{const e=pt([...t.elements.filter((t=>t.id!==A.id)),A]);return{layout:t.layout,elements:e,modificationID:Y()}},xt=async(A,t)=>{const e=[...Object.keys(A.layouts),...Object.keys(t?.layouts||{})],n=[...new Set(e)];for(let e=0;e<n.length;e++){const i=n[e],a=A.layouts[i],s=t?.layouts[i],r=(a||s).elements.filter((A=>"illustration"===A.type));for(let A=0;A<r.length;++A){const t=r[A];if(t.src&&!t.svg){const A=await SA(t.src),e=await Qt(A);t.svg=Ct(e.svg,t.width,t.height,t.colors)}}}};class Yt{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(A){this.oldState=A}}class vt extends Yt{constructor(A){super(),this.serializableWorkflow=A}apply(A){return this.oldState=A,{...A,serializableWorkflow:this.serializableWorkflow}}}class Nt extends Yt{constructor(A,t,e){super(),this.id=A,this.x=t,this.y=e}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,x:this.x,y:this.y},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class St extends Yt{constructor(A,t){super(),this.id=A,this.angle=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,rotation:this.angle},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Pt extends Yt{constructor(A,t,e){super(),this.id=A,this.width=Math.abs(t),this.height=Math.abs(e)}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,width:this.width,height:this.height};if("frame"===t.type){const A=e;A.scaleX=A.scaleX*this.width/t.width,A.scaleY=A.scaleY*this.height/t.height}const n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Rt extends Yt{constructor(A){super(),this.commands=A}apply(A){return this.oldState=A,this.commands.reduce(((A,t)=>t.apply(A)),A)}}class Ht extends Yt{constructor(A){super(),this.layout=A}apply(A){return this.oldState=A,{...A,layouts:{...A.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:Y()}}}}}class Ut extends Yt{constructor(A){super(),this.panelName=A}apply(A){this.oldState=A;const t=Object.values(A.layouts).map((A=>{const t=A.layout.panelId===this.panelName;return{...A,elements:t?[]:[...A.elements],modificationID:Y()}})),e={};return t.forEach((A=>{e[A.layout.id]=A})),{...A,layouts:e}}}class Gt extends Yt{constructor(A,t){super(),this.element=A,this.layout=t}apply(A){this.oldState=A,A.layouts[this.layout.id]||(A.layouts[this.layout.id]={layout:this.layout,elements:[],modificationID:""});const t=A.layouts[this.layout.id].elements;if(t.find((A=>A.id===this.element.id)))throw new Error(`Failed to apply new ${this.element.type} element because ID ${this.element.id} already taken`);if(this.element.productOverlay||0===t.length){const e=[...t,this.element];return void 0===this.element.layerIndex&&(this.element.layerIndex=this.assignIndex(this.element,e)),{...A,layouts:{...A.layouts,[this.layout.id]:{...A.layouts[this.layout.id],elements:e,modificationID:Y()}}}}const e=t[t.length-1],n=e.productOverlay?e:null;let i;if(n&&t.pop(),null!==this.element.layerIndex&&void 0!==this.element.layerIndex)i=[...t,this.element].sort(((A,t)=>void 0!==A.layerIndex&&void 0!==t.layerIndex?A.layerIndex-t.layerIndex:0));else{const A=this.assignIndex(this.element,t);this.element.layerIndex=void 0!==A?A:0,i=[...t,this.element]}return n&&i.push(n),{...A,layouts:{...A.layouts,[this.layout.id]:{...A.layouts[this.layout.id],elements:i,modificationID:Y()}}}}assignIndex(A,t){if(0===t.length)return 0;const e=t.filter((t=>(t.layer||0)===(A.layer||0))).sort(((A,t)=>(A.layerIndex||0)-(t.layerIndex||0)))[t.length-1]?.layerIndex;return void 0!==e?e+1:0}}class bt extends Yt{constructor(A){super(),this.id=A}apply(A){this.oldState=A;let t=!1;const e=Object.values(A.layouts).map((A=>(A.elements.filter((A=>A.id!==this.id)).length!==A.elements.length&&(t=!0),{...A,elements:A.elements.filter((A=>A.id!==this.id)),modificationID:Y()})));t||console.log(`Failed to delete element ${this.id}`);const n={};return e.forEach((A=>{n[A.layout.id]=A})),{...A,layouts:n}}}class kt extends Yt{constructor(t,e){super(),this.el=M(A)(t),this.layout=e,this.el.id=Y(),this.el.x+=5,this.el.y+=5}apply(A){return this.oldState=A,new Gt(this.el,this.layout).apply(A)}}class Jt extends Yt{constructor(A,t,e){super(),this.id=A,this.color=t,this.textFillSpotColor=e}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Ot extends Yt{constructor(A,t){super(),this.id=A,this.size=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,fontSize:this.size},n=yt(t.id,Object.values(A.layouts)),i=e.algorithm&&e.algorithm!==G.Autosize?e.input||"":e.text||"",a=Ft(it(e,i),n);return{...A,layouts:{...A.layouts,[n.layout.id]:a}}}}class zt extends Yt{constructor(A,t){super(),this.id=A,this.algorithm=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,algorithm:this.algorithm},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class jt extends Yt{constructor(A,t){super(),this.id=A,this.fontData=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,fontData:this.fontData},n=yt(t.id,Object.values(A.layouts)),i=Ft(it(e,e.input||""),n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Lt extends Yt{constructor(A,t){super(),this.id=A,this.align=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,align:this.align},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Tt extends Yt{constructor(A,t,e){super(),this.id=A,this.imageData=t,this.offsets=e}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts)),e=t.elements.findIndex((A=>A.id===this.id)),n=t.elements[e].pattern,i=[...t.elements];i.splice(e,1,{...t.elements[e],pattern:{...n,src:this.imageData.src,x:this.offsets.x,y:this.offsets.y,width:this.imageData.width,height:this.imageData.height,scaleX:this.offsets.zoom,scaleY:this.offsets.zoom}});const a={...t,elements:i,modificationID:Y()};return{...A,layouts:{...A.layouts,[t.layout.id]:a}}}}class Kt extends Yt{constructor(A,t){super(),this.id=A,this.text=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e=yt(t.id,Object.values(A.layouts)),n=Ft(it(t,this.text),e);return{...A,layouts:{...A.layouts,[e.layout.id]:n}}}}class Vt extends Yt{constructor(A,t,e){super(),this.id=A,this.className=t,this.fill=e}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e=t.colors||{},n=e[this.className];e[this.className]={browserValue:this.fill,spotColor:n?.spotColor};const i={...t,colors:e},a=yt(t.id,Object.values(A.layouts)),s=Ft(i,a);return{...A,layouts:{...A.layouts,[a.layout.id]:s}}}}class Xt extends Yt{constructor(A,t,e){super(),this.id=A,this.svgBody=t,this.objectURL=e}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,svg:this.svgBody,cachedObjectURL:this.objectURL},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Wt extends Yt{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!Mt(this.id,Object.values(A.layouts)).id)throw new ft(this.id);const t=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!t)throw new Error("Layout missing from state!");const e=t.elements.findIndex((A=>A.id===this.id)),n=e+1,i=[...t.elements],a=i.splice(e,1)[0];return i.splice(n,0,a),i.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[t.layout.id]:{...A.layouts[t.layout.id],elements:i,modificationID:Y()}}}}}class Zt extends Yt{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!Mt(this.id,Object.values(A.layouts)).id)throw new ft(this.id);const t=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!t)throw new Error("Layout missing from state!");const e=t.elements.findIndex((A=>A.id===this.id)),n=e-1,i=[...t.elements],a=i.splice(e,1)[0];return i.splice(n,0,a),i.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[t.layout.id]:{...A.layouts[t.layout.id],elements:i,modificationID:Y()}}}}}class qt extends Yt{constructor(A,t){super(),this.id=A,this.value=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!e)throw new Error("Layout missing from state!");return{...A,layouts:{...A.layouts,[e.layout.id]:Ft({...t,layer:this.value},e)}}}}var $t={};y($t,"patternImageDataCache",(()=>ae)),y($t,"frameDataCache",(()=>se)),y($t,"generateFrameSVG",(()=>re)),y($t,"generateDefaultRectangleFrameSvg",(()=>oe)),y($t,"getVariant",(()=>ce)),y($t,"getFrameData",(()=>ge)),y($t,"calculateOffsets",(()=>le)),y($t,"getPatternImageData",(()=>Be)),y($t,"GetSVGDimensions",(()=>we)),y($t,"svgStringDimensions",(()=>de));var _t={};y(_t,"getExifOrientation",(()=>te)),y(_t,"canvasDims",(()=>ee)),y(_t,"getAttributesFromArrayBuffer",(()=>ne));let Ae=null;const te=A=>new Promise((t=>{const e=kA(A);(0,r.fromBuffer)(A).then((A=>{const n=A?.mime;if("image/jpeg"!==n)return t(1);(new(0,l.ExifImage)).loadImage(e,((A,e)=>t(A?1:e.image.Orientation||1)))}))})),ee=A=>{const t=8192,e=A.naturalWidth/A.naturalHeight;return A.naturalHeight<=t&&A.naturalWidth<=t?[A.naturalWidth,A.naturalHeight]:A.naturalHeight>A.naturalWidth?[e*t,t]:[t,t/e]},ne=async A=>{const t=await(async A=>{const t=await GA(A),e=await(0,g.loadImage)(t),[n,i]=ee(e),a=await(async()=>{if(null!==Ae)return!Ae;const A=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return Ae=2===A.width&&3===A.height,!Ae})();if(!a){const A=(0,g.createCanvas)(n,i);return A.getContext("2d").drawImage(e,0,0,n,i),A}const s=await te(A),[r,o]=s>4?[i,n]:[n,i],c=(0,g.createCanvas)(r,o),l=c.getContext("2d");switch(s){case 2:l.translate(r,0),l.scale(-1,1);break;case 3:l.translate(r,o),l.rotate(Math.PI);break;case 4:l.translate(0,o),l.scale(1,-1);break;case 5:l.rotate(-.5*Math.PI),l.scale(-1,1);break;case 6:l.rotate(-.5*Math.PI),l.translate(-r,0);break;case 7:l.rotate(-.5*Math.PI),l.translate(-r,o),l.scale(1,-1);break;case 8:l.rotate(.5*Math.PI),l.translate(0,-o)}return l.drawImage(e,0,0,r,o),c})(A);return"image/jpeg"===(await(0,r.fromBuffer)(A))?.mime?{dataUrl:t.toDataURL("image/jpeg",1),height:t.height,width:t.width}:{dataUrl:t.toDataURL(),height:t.height,width:t.width}};y({},"getDefaultVariant",(()=>ie));const ie=A=>{const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0},ae=new Map,se=new Map,re=async(A,t)=>{if(!t){if(!A)throw new Error("No region or src supplied. Cannot construct frame!");return oe(A)}return SA(t)},oe=A=>{const t=A.width,e=t/A.height,n=Math.max(t,512),i=n/e;return`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${n} ${i}'>\n <path id="target-path" d='M0 0 h ${n} v ${i} h ${-n} Z' />\n </svg>\n `},ce=(A,t)=>{if(!t)return;const e=t.data.variants.find((t=>t.id===A.frameVariantId))||ie(t.data);if(!e)throw new Error(`No variant with ID: ${A.frameVariantId}`);if(!e.asset)throw new Error(`No asset for variant with ID: ${A.frameVariantId}`);return e},ge=async A=>{const t=vA().parseFromString(A,"image/svg+xml"),e=t.querySelector("svg");if(!e)throw new Error("Malformed frame SVG: <svg> tag not found");const n=e.getAttribute("viewBox");if(!n)throw new Error("SVG missing viewBox.");const i=n.split(" "),a=parseFloat(i[3])||1,s=parseFloat(i[2])||1,r=t.getElementById("target-path"),o=t.getElementsByClassName("st0").item(0);if(r){const A=r.getAttribute("d");if(!A)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const t={path:A,width:s,height:a};return se.set(A,t),t}if(o){const A=o.getAttribute("d");if(!A)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const t={path:A,width:s,height:a};return se.set(A,t),t}throw new Error("Malformed frame SVG")},le=(A,t,e)=>{const n=t.width>=t.height,i=A.width>=A.height,a=t.width/2,s=t.height/2,r=(n?t.height:t.width)/(i?A.height:A.width),o=e?.scale||r,c=a-A.width/2*o,g=e?.left||c,l=s-A.height/2*o;return{x:g,y:e?.top||l,zoom:o}},Be=async A=>{if(ae.has(A))return ae.get(A);if(A.endsWith("svg")){const t=await we(A),e=t.width,n=t.height,i={src:A,width:e,height:n,aspect:e/n};return ae.set(A,i),i}{const t=await NA(A),e=await ne(t),n={src:A,width:e.width,height:e.height,aspect:e.width/e.height};return ae.set(A,n),n}},we=async A=>{const t=await fetch(A),e=await t.text();return de(e)},de=A=>{const t=(new DOMParser).parseFromString(A,"image/svg+xml").querySelector("svg");if(!t)throw new Error("No svg tag found, this svg must be malformed!");const e=t.getAttribute("viewBox"),n=t.getAttribute("width"),i=t.getAttribute("height"),a=e?e?.split(" ").map((A=>Number(A))):[0,0,Number(n),Number(i)];if(!a)throw new Error("No viewbox or width/height values detected on SVG file!");return{width:a[2],height:a[3]}};var he={};y(he,"determineCorrectFontSizeAndLines",(()=>Ce)),y(he,"determineCorrectTextboxRegion",(()=>Qe));const Ee=(A,t,e,n,i)=>{let a=t.map((A=>A.split("\n"))).flat(),s=a.length,r=a.map((A=>$A(A,n,i)));const o=i.getApproximateHeight()*n;let c=!0;for(;c;){if(o+(s-1)*e>A.height)return[null,null];const t=Math.max(...r);if(t<=A.width)return[a,t];const g=r.reduce(((A,t,e,n)=>t>n[A]?e:A),0),l=a[g];let B=!1,w=l.length;for(;!B&&w>-1;){w=l.lastIndexOf(" ",w-1);const t=[l.slice(0,w),l.slice(w+1)],e=t.map((A=>$A(A,n,i)));e[0]<=A.width&&(a=[...a.slice(0,g),...t,...a.slice(g+1)],r=[...r.slice(0,g),...e,...r.slice(g+1)],s+=1,B=!0)}B||(c=!1)}return[null,null]},Ce=(A,t,e,n,i)=>{let a,s;const r=VA(t),o=r.getFont();if(i.size){const t=A/o.unitsPerEm;return[a,s]=Ee(e,n,A,t,r),[i.size,a,s]}let c=6-qA;if(n.length>0){let A=n,t=0;for(;(!i.maxSize||c<=i.maxSize)&&A;)c+=qA,t=c/o.unitsPerEm,[A,s]=Ee(e,n,c,t,r)}c>6&&(c-=qA),i.minSize&&c<i.minSize&&(c=i.minSize);const g=c/o.unitsPerEm;return[a,s]=Ee(e,n,c,g,r),[c,a,s]},Qe=(A,t,e,n,i)=>{let a={...A},s={...A},[r,o,c]=Ce(e,t,s,n,{size:0,minSize:e,maxSize:e});var g,l;return c&&c<a.width&&(s.width=c,"left"===i?(s.left+=Math.sin(a.rotation*Math.PI/360)*(a.width-c),s.top+=Math.sin(a.rotation*Math.PI/180)*(c-a.width)/2):s.left+="right"===i?a.width-c:(a.width-c)/2,[r,o]=Ce(e,t,s,n,{size:e}),r===e&&o&&(g=n,l=o,g.map(((A,t)=>[A,l[t]]))).every((([A,t])=>A===t))&&(a=s)),a};var ue={};y(ue,"svgObjectURL",(()=>me)),y(ue,"LayoutElementFactory",(()=>fe));const Ie=(A,t)=>{const e=A.layoutState.elements.filter((A=>A.layer===t)),n=Math.max(...e.map((A=>A.layerIndex)).filter((A=>void 0!==A)));return Math.max(n,0)+1},De=async A=>new Promise((t=>{fetch(A).then((A=>{t(A.text())})).catch((A=>console.error(A)))})),me=async A=>{const t=(new DOMParser).parseFromString(A,"image/svg+xml").firstElementChild;if(!t)throw new Error("Failed to read SVG");const e=(new XMLSerializer).serializeToString(t),n=document.createElement("canvas"),i=n.getContext("2d"),a=await B.Canvg.from(i,e,{anonymousCrossOrigin:!0,ignoreDimensions:!1}),s=t.getAttribute("width"),r=t.getAttribute("height"),o=2048;if(r&&s){const A=parseFloat(r),t=parseFloat(s)/A;t>1?a.resize(o,o/t):a.resize(o*t,o)}else a.resize(o,o);return await a.render(),await(async A=>new Promise(((t,e)=>{try{if(!URL||!URL.createObjectURL)throw new Error("Environment incapable of generating ObjectURL");A.toBlob((e=>{if(!e){if(0===A.width||0===A.height)throw new Error(`Canvas dimensions are invalid (${A.width},${A.height})`);if(A.width*A.height>=268435456)throw new Error(`Canvas dimensions exceed device limit (${A.width},${A.height})`);throw new Error("Couldn't generate object URL for Illustration, the blob was undefined!")}t(URL.createObjectURL(e))}))}catch(A){e(A)}})))(n)},pe=async(A,t,e)=>{const n=A.layoutState.layout.useEditableArea&&A.layoutState.layout.editableArea||{width:A.layoutState.layout.width,height:A.layoutState.layout.height,x:0,y:0},i=(n.width<n.height?n.width:n.height)/2,a={top:n.y+n.height/2-i/2,left:n.x+n.width/2-i/2,width:i,height:i,rotation:0,panelId:A.layoutState.layout.panelId};if(e&&t===P.Illustration){const A=await Qt(await De(e)),t=(new DOMParser).parseFromString(A.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!t)throw new Error("SVG missing viewBox.");const n=a.height,i=t.split(" "),s=(parseFloat(i[2])||1)/(parseFloat(i[3])||1);a.height=a.width/s,a.top+=(n-a.height)/2}if(e&&t===P.Image){const A=a.height,t=await fetch(e),n=await t.arrayBuffer(),i=await ne(n),s=i.width/i.height;a.height=a.width/s,a.top+=(A-a.height)/2}return a};class fe{static async getFrame(A,t){const e=await re(t.region,t.src),n=await ge(e),i=t.region||await pe(A,P.Frame);return{id:Y(),x:i.left,y:i.top,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||Ie(A,i.layer||0),rotation:i.rotation,scaleX:i.width/n.width,scaleY:i.height/n.height,path:n.path,type:P.Frame,disablePlaceholder:t.configuration.disablePlaceholder,focalBlur:t.configuration.focalBlur,focalBlurStrength:t.configuration.focalBlurStrength,focalBlurRadius:t.configuration.focalBlurRadius,pattern:void 0,immutable:i.immutable}}static async getImage(A,t){const e=t.region||await pe(A,P.Image,t.src);return{id:Y(),src:t.src,type:P.Image,y:e.top,x:e.left,rotation:e.rotation,width:e.width,height:e.height,layer:e.layer||0,layerIndex:e.layerIndex||Ie(A,e.layer||0),immutable:e.immutable,preserveAspectRatio:"none"}}static async getTextbox(A,t){const{configuration:e,fontSrc:n,designInputStep:i}=t,a=t.region||await pe(A,P.Textbox),s={assetUrl:n,name:(await TA(n)).names.fullName.en},r=i?.text||e.defaultText||"",o=e.replaceableText?e.replaceableText.replace("{{}}",r):r,c=At(o,{vertical:e.vertical,uppercase:e.uppercase}),g=it({id:Y(),type:P.Textbox,x:a.left,y:a.top,width:a.width,height:a.height,align:et(e.textAlign,e.vertical),curved:e.curved,fill:i?.color||e.colour||"#000000",fontData:s,layer:a.layer||0,layerIndex:a.layerIndex||Ie(A,a.layer||0),paths:e.paths,rotation:a.rotation,vertical:e.vertical,verticalAlign:e.verticalAlign||"middle",algorithm:G.Traditional,fontSize:e.size||Math.max(Math.round(.025*a.height),1),text:c,input:r},c),l=Qe({...a,height:g.height},s,g.fontSize,g?.text?.split("\n")||[],g.align);return{...g,x:l.left,y:l.top+(a.height-l.height)/2,width:l.width,height:l.height}}static async getShape(A,t){const e=`\n <svg\n xmlns="http://www.w3.org/2000/svg"\n xmlnsXlink="http://www.w3.org/1999/xlink"\n xmlSpace="preserve"\n preserveAspectRatio="none"\n version="1.1"\n width="1"\n height="1"\n viewBox="0 0 1 1"\n >\n <rect\n x="0"\n y="0"\n width="1"\n height="1"\n class="spiff-fill-shape"\n fill="${t.color}"\n />\n </svg>\n `,n={};n["spiff-fill-shape"]={browserValue:t.color};const i=t.region||await pe(A,P.Illustration),a=Y();return{stepRegion:t.region,colors:n,id:a,svg:e,type:P.Illustration,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||Ie(A,i.layer||0),immutable:i.immutable}}static async getIllustration(A,t){const e=t.region||await pe(A,P.Illustration,t.src),n=await Qt(await De(t.src)),i=await me(n.svg),a=Y();return{cachedObjectURL:i,stepRegion:t.region,colors:n.colors,id:a,svg:n.svg,type:P.Illustration,y:e.top,x:e.left,rotation:e.rotation,width:e.width,height:e.height,layer:e.layer||0,layerIndex:e.layerIndex||Ie(A,e.layer||0),immutable:e.immutable}}}function Me(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class ye extends Error{constructor(A){super(A),this.name=this.constructor.name}}class Fe extends ye{constructor(A){super(`ConfigurationError - ${A}`)}}class xe extends Fe{constructor(A){super(`Option not Configured: ${A.stepTitle}`),Me(this,"optionId",void 0),this.optionId=A?.optionId||"N/A"}}class Ye extends Fe{constructor(A){super(`Panel not Found: ${A.panelId}`),Me(this,"panelId",void 0),this.panelId=A?.panelId||"N/A"}}class ve extends Fe{constructor(A){super(`Asset not found for variant: ${A.name}`),Me(this,"variant",void 0),this.variant=A}}class Ne extends Fe{constructor(A){super(`Resource not found for asset: ${A.name}`),Me(this,"asset",void 0),this.asset=A}}class Se extends Fe{constructor(A,t){super(`Workflow Misconfiguration: ${A.stepName} - ${t}`),Me(this,"step",void 0),this.step=A}}class Pe extends ye{constructor(A){super(`ImplementationError - ${A}`)}}class Re extends Pe{constructor(A){super(`Unhandled Behavior Encountered: ${A}`)}}class He extends Pe{constructor(A){super(`Parsing Error: ${A}`)}}class Ue extends Pe{constructor(A){super(`Client Error: ${A}`)}}class Ge extends Pe{constructor(A){super(`Resource Generation Failed: ${A}`)}}function be(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class ke{get(A){return localStorage.getItem(A)||void 0}set(A,t){localStorage.setItem(A,t)}remove(A){localStorage.removeItem(A)}getMap(A){const t=this.get(A);if(t)return new Map(JSON.parse(t))}setMap(A,t){const e=JSON.stringify([...t.entries()]);this.set(A,e)}}class Je{constructor(){be(this,"storage",new Map)}get(A){return this.storage.get(A)||void 0}set(A,t){this.storage.set(A,t)}remove(A){this.storage.delete(A)}getMap(A){const t=this.get(A);if(t)return new Map(JSON.parse(t))}setMap(A,t){const e=JSON.stringify([...t.entries()]);this.set(A,e)}}const Oe=(()=>{try{return localStorage?new ke:new Je}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new Je}})();function ze(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const je=new class{constructor(){ze(this,"defaultServerUrl","https://api.spiff.com.au"),ze(this,"defaultServicesApiUrl","https://services.spiff.com.au"),ze(this,"defaultHubUrl","https://hub.spiff.com.au"),ze(this,"serverUrl",void 0),ze(this,"servicesApiUrl",void 0),ze(this,"hubUrl",void 0),ze(this,"serverUrlCallbacks",void 0),this.serverUrl=this.defaultServerUrl,this.servicesApiUrl=this.defaultServicesApiUrl,this.hubUrl=this.defaultHubUrl,this.serverUrlCallbacks=[]}getServerUrl(){return this.serverUrl}getServicesApiUrl(){return this.servicesApiUrl}getHubUrl(){return this.hubUrl}setServerUrl(A){this.serverUrl=A,this.serverUrlCallbacks.forEach((A=>A()))}setServicesApiUrl(A){this.servicesApiUrl=A}setHubUrl(A){this.hubUrl=A}addServerUrlCallback(A){this.serverUrlCallbacks.push(A)}};function Le(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let Te;const Ke=A=>{Te=A},Ve=async()=>{const A={transactionOwnerId:Te};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=je.getHubUrl();if(window.location.href.includes("localhost")||window.location.href.includes("ngrok"))return void A({});const e=n=>{n.origin===t&&(window.removeEventListener("message",e),A(n.data))};window.parent!==window&&(window.addEventListener("message",e,!1),window.parent.postMessage("ready",t))})),...A}:A};const Xe=new class{constructor(){Le(this,"client",void 0),Le(this,"uncachedOperations",[]),je.addServerUrlCallback((async()=>{this.client=void 0,this.client=await this.constructClient()}))}setUncachedOperations(A){this.uncachedOperations=A}async execute(A,t){const e=this.uncachedOperations.includes(A)?A+"_private":A;return new Promise(((A,n)=>{this.getClient().then((i=>{i.execute({operationId:e,parameters:t}).then((t=>A(t))).catch((A=>{A.response&&A.response.status&&A.response.status>=500||(!A.response&&n(new Error(A)),A.response&&n(new Error(`${A.response.status} ${A.response.url}`)))}))})).catch((A=>{n(A)}))}))}async syncAuth(A){const t=await Ve();if(t.bearer?A.authorizations={...A.authorizations,OAuth2:{token:{access_token:t.bearer,token_type:"Bearer"}}}:A.authorizations={...A.authorizations,OAuth2:{token:{access_token:"",token_type:"Bearer"}}},t.activeIntegration)A.authorizations={...A.authorizations,ActiveIntegration:t.activeIntegration};else{const t={...A.authorizations};delete t.ActiveIntegration,A.authorizations=t}if(t.partnerId)A.authorizations={...A.authorizations,PartnerId:t.partnerId};else{const t={...A.authorizations};delete t.PartnerId,A.authorizations=t}}async getClient(){return this.client||(this.client=await this.constructClient()),this.syncAuth(this.client),Promise.resolve(this.client)}async constructClient(){const A=await Ve(),t=je.getServerUrl()+"/v2/api-docs";return await M(w)(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const We=new class{constructor(){Le(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),je.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=(0,d.createHttpLink)({uri:`${je.getServerUrl()}/graphql`,fetch:C.fetch}),t=(0,h.setContext)((async(A,{headers:t})=>{const e=t||{},n=await Ve();return n.bearer&&(e.Authorization=`Bearer ${n.bearer}`),n.partnerId&&(e.partnerId=n.partnerId),n.activeIntegration&&(e.activeIntegration=n.activeIntegration),n.transactionOwnerId&&(e.transactionOwnerId=n.transactionOwnerId),{headers:e}})),e=(0,E.onError)((({operation:A,graphQLErrors:t,networkError:e})=>{(t||[]).forEach((({message:t,locations:e,path:n})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+A.operationName),console.log("Query:"+JSON.stringify(A.query)),console.log(`Message: ${t}, Location: ${JSON.stringify(e,null,2)}, Path: ${n}`),console.log("Variables:"+JSON.stringify(A.variables))})),e&&console.log("GraphQL Network error")}));const n=new(0,d.InMemoryCache)({typePolicies:{Transaction:{fields:{bulkEmailAddress:{read:(A=null)=>A},transactionOwnerId:{read:(A=null)=>A},customLogoLink:{read:(A=null)=>A},workflowFooterLogoLink:{read:(A=null)=>A},workflowState:{read:(A=null)=>A},bulkSourceUrl:{read:(A=null)=>A},externalDesignProductId:{read:(A=null)=>A},externalDesignProductVariantId:{read:(A=null)=>A},lastSyncedAt:{read:(A=null)=>A}}},Workflow:{fields:{isPresent:{read:(A=null)=>A}}},Product:{fields:{imageUrl:{read:(A=null)=>A},overlayImageUrl:{read:(A=null)=>A},preloadImageUrl:{read:(A=null)=>A},weight:{read:(A=null)=>A}}}}});return new(0,d.ApolloClient)({link:(0,d.from)([e,t,A]),cache:n,name:"Core"})}};function Ze(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const qe="persistentAssets";class $e{static add(A){const t=A?.links.find((A=>"cdn"===A.rel));if(!t)return void console.error("Failed to find cdn link on asset, cannot persist!");const e=new Map;e.set(A.data.key,t.href);const n=Oe.getMap(qe);n&&n.forEach(((A,t)=>{e.set(t,A)})),Oe.setMap(qe,e)}static remove(A){const t=Oe.getMap(qe);if(!t)return;const e=Array.from(t.entries()).find((t=>t[0]===A));e&&(t.delete(e[0]),Oe.setMap(qe,t))}static list(){const A=Oe.getMap(qe);return A?Array.from(A.entries()).map((A=>({assetKey:A[0],src:A[1]}))):[]}}const _e=new class{constructor(){Ze(this,"server",void 0),Ze(this,"cache",new Map),Ze(this,"materialCache",new Map),Ze(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await ne(t);return{name:A.name.substring(A.name.lastIndexOf("/")+1),blob:((A,t)=>{let e=atob(A.split(",")[1]),n=[];for(let A=0;A<e.length;A++)n.push(e.charCodeAt(A));return new Blob([new Uint8Array(n)],{type:t})})(e.dataUrl,A.type)}})),Ze(this,"getAssetFromVariant",(async A=>A.asset?A.asset:await _e.getLocalOrFromServer(A.assetKey))),Ze(this,"getMaterialFromVariant",(async A=>A.material?A.material:await _e.getMaterialLocalOrFromServer(A.materialId))),this.server=Xe}async getLocalOrFromServer(A){if(this.cache.has(A)){const t=this.cache.get(A);if(!t)throw new Re("Failed to get asset from cache!");return t}const t=(async()=>(await Xe.execute("getAssetByKeyV2",{assetKey:A.replace(/\//g,"_")})).body)();return this.cache.set(A,t),t}async getMaterialLocalOrFromServer(A){if(this.materialCache.has(A))return this.materialCache.get(A);const t=(async()=>(await Xe.execute("getMaterialV2",{id:A})).body)();return this.materialCache.set(A,t),t}async uploadAssetWithProgress(A,t,e,n,i){const a=await this.dispatchCreateAssetRequest(A,t,n,i);return await new Promise(((t,n)=>{var i=new XMLHttpRequest;i.open("PUT",a.assetResponse.uploadUrl,!0),i.setRequestHeader("Content-Type",a.mimeType),i.setRequestHeader("Cache-Control","public,max-age=31536000,immutable"),i.upload.onprogress=A=>{A.lengthComputable&&e(100*A.loaded/A.total)},i.onload=()=>{const A=a.assetResponse.asset;$e.add(a.assetResponse.asset),t(A)},i.onerror=n,i.send(A.blob)})),a.assetResponse.asset}async uploadFile(A,t){const e=!("image/svg+xml"===A.type||"application/pdf"===A.type),n=e?T.Image:T.Illustration;if(e){const e=await this.loadImageAsFileInfo(A);return await this.uploadAssetWithProgress(e,n,t,!0)}{const e={name:A.name,blob:new Blob([A],{type:A.type})};return await _e.uploadAssetWithProgress(e,n,t,!0)}}removePersistedAsset(A){$e.remove(A)}getPersistedAssets(){return $e.list()}async dispatchCreateAssetRequest(A,t,e,n){const i=A.blob.type?A.blob.type:this.guessMIME(A.name);return{assetResponse:(await this.server.execute("createAsset",{assetDetails:{name:A.name,type:t,mimeType:i,storageOwnerId:n,userAnonymous:!0}},e)).body,mimeType:i}}guessMIME(A){const t=A.split(".").pop();switch(t){case"glb":return"model/gltf-binary";case"ttf":return"font/ttf";case"mkv":return"video/x-matroska";default:throw new Re("Unexpected mimetype: "+t)}}};function An(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const tn=new class{constructor(){An(this,"cache",new Map),An(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),An(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),An(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[])),An(this,"getOptionFromStep",(async(A,t)=>{if(A.option){const t=A.option.data.id;return t&&!this.cache.has(t)&&this.cache.set(t,Promise.resolve(A.option)),A.option}return await tn.getOption(t,A.optionId)}))}async getOption(A,t){if(this.cache.has(t))return this.cache.get(t);const e=(async()=>{const e=await A.execute("getOptionV2",{id:t});if(e.body.data)return e.body})();return this.cache.set(t,e),e}async getAssetTileImageForVariant(A){if(A.thumbnailKey){const t=await _e.getLocalOrFromServer(A.thumbnailKey),e=t.links.find((A=>"thumbnail"===A.rel)),n=t.links.find((A=>"cdn"===A.rel));return e?.href||n?.href}const t=A.assetKey;if(t){const A=await _e.getLocalOrFromServer(t),e=A.links.find((A=>"thumbnail"===A.rel)),n=A.links.find((A=>"cdn"===A.rel));return e?.href||n?.href}return A.materialId?A.materialId:""}getDefaultVariant(A){const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0}},en=(0,Q.createContext)(new It),nn=function(){const[A,t]=(0,Q.useState)([]);return{addEvent:(0,Q.useCallback)((A=>{t((t=>[...t,A]))}),[]),updateEvent:(0,Q.useCallback)((A=>{t((t=>{const e=t.findIndex((t=>t.pointerId===A.pointerId));if(-1===e)return t;const n=[...t];return n[e]=A,n}))}),[]),removeEvent:(0,Q.useCallback)((A=>{t((t=>t.filter((t=>t.pointerId!==A.pointerId))))}),[]),eventCache:A,curActiveEvents:A.length}},an=()=>{const A=(0,Q.useContext)(en),[t,e]=(0,Q.useState)(new Date);(0,Q.useEffect)((()=>{const t=()=>{e(new Date)};return A.registerStateCallback(t),()=>{A.unregisterStateCallback(t)}}),[A]);return{commandDispatcher:(t,e)=>{A.apply(t,e)},getLayoutById:t=>A.getLayoutById(t),getAllLayouts:()=>A.getAllLayouts(),getReducerState:()=>{const t=A.getState();return t||{transaction:{layouts:{},serializableWorkflow:{steps:[]}}}},lastUpdated:t,flattenSequence:(t,e)=>{A.flattenSequence(t,e)}}};function sn(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let rn;var on;(on=rn||(rn={})).None="None",on.FrameAdjustment="FrameAdjustment",on.FinalizeDesign="FinalizeDesign",on.SavedDesigns="SavedDesigns",on.ThreeDPreview="ThreeDPreview",on.Panels="Panels";const cn=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,xTranslation:0,yTranslation:0,maxZoom:5,units:k.Pixel,subMenu:rn.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),gn=(A,t)=>M(u)(A,t.apply(A))?A:t.apply(A),ln=(0,Q.createContext)({}),Bn=A=>{const{getAllLayouts:e}=an(),[n,i]=(0,Q.useReducer)(gn,cn(e,A.defaultZoom||1)),a=(0,Q.useMemo)((()=>({state:n,uiDispatcher:i})),[n,i]);return(0,t.jsx)(ln.Provider,{value:a,children:A.children})};class wn{constructor(A){sn(this,"changes",void 0),this.changes=A}apply(A){return{...A,...this.changes}}}const dn=()=>(0,Q.useContext)(ln);let hn;var En;(En=hn||(hn={}))[En.Orbit=0]="Orbit",En[En.Pan=1]="Pan";const Cn=(A,e,n,i)=>{const a=e.layout.useEditableArea&&e.layout.editableArea||{width:e.layout.width,height:e.layout.height,x:0,y:0},s=e.elements.filter((t=>t.id!==A.id&&!t.immutable&&!t.productOverlay)),r=s.map((A=>_(A.x,A.y,A.width,A.height,A.rotation))),o=[],c=new Set;r.forEach((A=>c.add(A.minX))),r.forEach((A=>c.add(A.maxX))),[a.x,a.x+a.width/2,a.x+a.width].forEach((A=>c.add(A)));const g=new Set;r.forEach((A=>g.add(A.minY))),r.forEach((A=>g.add(A.maxY))),[a.y,a.y+a.height/2,a.y+a.height].forEach((A=>g.add(A)));const l=s.map((A=>A.y));for(let A=-315;A<=315;A+=45)l.push(A);const B=_(A.x,A.y,A.width,A.height,A.rotation),w=[{value:B.minX,anchor:-1},{value:B.minX+(B.maxX-B.minX)/2,anchor:0},{value:B.minX+(B.maxX-B.minX),anchor:1}],d=[{value:B.minY,anchor:-1},{value:B.minY+(B.maxY-B.minY)/2,anchor:0},{value:B.minY+(B.maxY-B.minY),anchor:1}],h=[{value:A.rotation,anchor:0}],E=(A,e,i,s)=>{const r=[];return e.forEach((e=>{const o=i.find((A=>nA(e,A.value,1.7*n))),[c,g]=((A,t)=>[{x:"x"===A?t:a.x,y:"x"===A?a.y:t},{x:"x"===A?t:a.x+a.width,y:"x"===A?a.y+a.height:t}])(A,e),l="rotation"===A?null:(0,t.jsx)("line",{x1:c.x,y1:c.y,x2:g.x,y2:g.y,stroke:s||"#D61B5C",strokeWidth:1.2*n},`${A}-${e}-${c.x}-${c.y}-${g.x}-${g.y}`);void 0!==o&&r.push({type:A,value:e,anchorPoint:o.anchor,svgNode:l,guidelineCoordinates:[c,g]})})),r};return o.push(...E("x",Array.from(c),w,i),...E("y",Array.from(g),d,i),...E("rotation",l,h,i)),o};let Qn;var un;let In;var Dn;(un=Qn||(Qn={})).Translate="Translate",un.Rotate="Rotate",un.Resize="Resize",(Dn=In||(In={})).ControlLeft="ControlLeft",Dn.ControlRight="ControlRight",Dn.Equal="Equal",Dn.MetaLeft="MetaLeft",Dn.MetaRight="MetaRight",Dn.Minus="Minus",Dn.ArrowLeft="ArrowLeft",Dn.ArrowRight="ArrowRight",Dn.ArrowUp="ArrowUp",Dn.ArrowDown="ArrowDown",Dn.AltLeft="AltLeft",Dn.AltRight="AltRight",Dn.Delete="Delete",Dn.Backspace="Backspace";const mn=(A,t,e,n)=>{const i=()=>{switch(e){case k.Pixel:return 1;case k.Millimeter:return dA;case k.Centimeter:return hA;default:throw new Re("Unknown unit of measurement")}};let a=t.x,s=t.y,r=t.x,o=t.y;switch(A){case In.ArrowLeft:r=t.x-1/i();break;case In.ArrowUp:o=t.y-1/i();break;case In.ArrowRight:r=t.x+1/i();break;case In.ArrowDown:o=t.y+1/i();break;default:throw new Re("Unhandled element interaction!")}const c=_(r,o,t.width,t.height,t.rotation);return(!n||c.minX>=n.left&&c.maxX<=n.left+n.width&&c.minY>=n.top&&c.maxY<=n.top+n.height)&&(a=r,s=o),new Nt(t.id,a,s)};var pn=0,fn=0,Mn=0;const yn=(A,t,e,n,i,a)=>{const s=_(A,t,e,n,i),r=s.maxX-s.minX,o=s.maxY-s.minY,c=.1;return!a||s.maxX-c*r>=a.left&&s.minX+c*r<=a.left+a.width&&s.maxY-c*o>=a.top&&s.minY+c*o<=a.top+a.height},Fn=(A,t,e,n,i,a,s)=>{const r=((A,t,e,n,i,a,s)=>{const r=n.width/t.width,o=n.height/t.height,c=A.mX/r,g=A.mY/o,l=e.rotation*Math.PI/180,B=Math.sin(l),w=Math.cos(l),d=e.type===P.Textbox?1:e.width/e.height;switch(i.type){case Qn.Resize:let t={top:e.y,left:e.x,width:e.width,height:e.height,rotation:e.rotation,fontSize:e.fontSize},h=t;switch(i.screenAxis){case O.North:{const A=-c*B+g*w,n=e.y+A,i=e.height-A,a=BA({...e}).center,s=BA({...e,y:n,height:i}).center,r=wA(s,a,l),o=r.x-e.width/2,d=r.y-i/2;h={...t,left:o,top:d,height:i}}break;case O.East:{const A=c*w+g*B,n=e.width+A;let i=e.height;if(e.type===P.Textbox){const A=e,a=ZA(A.fontSize,A.fontData,{...A,width:n},A.input||A.text||"",A.lineHeight);if(i=a.requiredHeight,!i||!a.requiredWidth)return t}const a=BA({...e}).center,s=BA({...e,width:n,height:i}).center,r=wA(s,a,l),o=r.x-n/2,d=r.y-i/2;h={...t,left:o,top:d,width:n,height:i}}break;case O.West:{const A=c*w+g*B,n=e.x+A,i=e.width-A;let a=e.height;if(e.type===P.Textbox){const A=e,n=ZA(A.fontSize,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);if(a=n.requiredHeight,!a||!n.requiredWidth)return t}const s=BA({...e}).center,r=BA({...e,width:i,height:a,x:n}).center,o=wA(r,s,l),d=o.x-i/2,E=o.y-a/2;h={...t,left:d,top:E,width:i,height:a}}break;case O.South:{const A=-c*B+g*w,n=e.height+A,i=BA({...e}).center,a=BA({...e,height:n}).center,s=wA(a,i,l),r=s.x-e.width/2,o=s.y-n/2;h={...t,left:r,top:o,height:n}}break;case O.Northeast:{const A=c*w+g*B,n=e.width+A;let i=e.height+A/d,a=e.y-A/d,s=e.fontSize;if(e.type===P.Textbox){const r=e;s=r.fontSize+A/8;const o=ZA(s,r.fontData,{...r,width:n},r.input||r.text||"",r.lineHeight);i=o.requiredHeight;const c=r.lineHeight||at;if(a=e.y-A*c/8,!i||!o.requiredWidth)return t}const r=BA({...e}).center,o=BA({...e,width:n,height:i,y:a}).center,E=wA(o,r,l),C=E.x-n/2,Q=E.y-i/2;h={...t,left:C,top:Q,width:n,height:i,fontSize:s}}break;case O.Northwest:{const A=-c*w+-g*B,n=e.x-A,i=e.width+A;let a=e.y-A/d,s=e.height+A/d,r=e.fontSize;if(e.type===P.Textbox){const n=e;r=n.fontSize+A/8;const o=ZA(r,n.fontData,{...n,width:i},n.input||n.text||"",n.lineHeight);s=o.requiredHeight;const c=n.lineHeight||at;if(a=e.y-A*c/8,!s||!o.requiredWidth)return t}const o=BA({...e}).center,E=BA({...e,x:n,y:a,width:i,height:s}).center,C=wA(E,o,l),Q=C.x-i/2,u=C.y-s/2;h={...t,left:Q,top:u,width:i,height:s,fontSize:r}}break;case O.Southeast:{const A=c*w+g*B,n=e.width+A;let i=e.height+A/d,a=e.fontSize;if(e.type===P.Textbox){const s=e;a=s.fontSize+A/8;const r=ZA(a,s.fontData,{...s,width:n},s.input||s.text||"",s.lineHeight);if(i=r.requiredHeight,!i||!r.requiredWidth)return t}const s=BA({...e}).center,r=BA({...e,width:n,height:i}).center,o=wA(r,s,l),E=o.x-n/2,C=o.y-i/2;h={...t,left:E,top:C,width:n,height:i,fontSize:a}}break;case O.Southwest:{const A=-c*w+-g*B,n=e.width+A;let i=e.x-A,a=e.height+A/d,s=e.fontSize;if(e.type===P.Textbox){const i=e;s=i.fontSize+A/8;const r=ZA(s,i.fontData,{...i,width:n},i.input||i.text||"",i.lineHeight);if(a=r.requiredHeight,!a||!r.requiredWidth)return t}const r=BA({...e}).center,o=BA({...e,width:n,height:a,x:i}).center,E=wA(o,r,l),C=E.x-n/2,Q=E.y-a/2;h={...t,left:C,top:Q,width:n,height:a,fontSize:s}}}return yn(h.left,h.top,h.width,h.height,h.rotation,s)&&(t=h),t;case Qn.Rotate:const E={x:A.clientX,y:A.clientY};let C,Q=e.rotation;const u=BA(e,n,{x:r,y:o}),I=AA(E,u.c,u.d),D=AA(E,u.d,u.c);if(0===a.filter((A=>"rotation"===A.type)).length)Mn=0,C=(e.rotation+I-D)%360;else{Mn+=Math.sqrt(c**2+g**2);const A=Math.abs(Mn)>2*window.devicePixelRatio/r;C=A?(e.rotation+I-D)%360:a.find((A=>"rotation"===A.type))?.value||0,A&&(Mn=0)}return yn(e.x,e.y,e.width,e.height,C,s)&&(Q=C),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:Q};case Qn.Translate:let m,p,f=e.x,M=e.y;if(0===a.filter((A=>"rotation"!==A.type)).length)pn=0,fn=0,m=e.x+c,p=e.y+g;else{const A=a.find((A=>"x"===A.type)),t=a.find((A=>"y"===A.type));A||(pn=0),t||(fn=0);const n=Math.abs(pn)>2*window.devicePixelRatio/r,i=Math.abs(fn)>2*window.devicePixelRatio/o,s=A=>{switch(A){case-1:return 0;case 0:return e.width/2;case 1:return e.width;default:return 0}},l=A=>{switch(A){case-1:return 0;case 0:return e.height/2;case 1:return e.height;default:return 0}};if(0!==e.rotation)m=A?n?e.x+pn:e.x:e.x+c,p=t?i?e.y+fn:e.y:e.y+g;else{if(A){const t=A.value-s(A.anchorPoint);m=n?t+pn:t}else m=e.x+c;if(t){const A=t.value-l(t.anchorPoint);p=i?A+fn:A}else p=e.y+g}pn=n?0:pn+c,fn=i?0:fn+g}return yn(m,p,e.width,e.height,e.rotation,s)&&(f=m,M=p),{top:M,left:f,width:e.width,height:e.height,rotation:e.rotation}}})(A,t,e,n,i,a,s),o=[];if(e.type===P.Textbox){const A=e;o.push(new Kt(A.id,A.input||""))}if(r.width>0&&r.height>0&&(o.push(new Nt(e.id,r.left,r.top),new Pt(e.id,r.width,r.height),new St(e.id,r.rotation)),e.type===P.Textbox)){const A=e;r.fontSize&&A.fontSize!==r.fontSize&&o.push(new Ot(A.id,r.fontSize))}return o},xn=A=>{const{onPointerDown:e,scaleFactor:n,elementWidth:i}=A,a=(0,Q.useCallback)((A=>{A.stopPropagation(),e&&e(A)}),[e]),s=13*n,r=30*n;return(0,t.jsxs)("g",{transform:`translate(${r})`,children:[(0,t.jsx)("circle",{cx:i/2,cy:-2.5*s,r:1.3*s,fill:"transparent",style:{cursor:"pointer"},onPointerDown:a}),(0,t.jsxs)("svg",{onPointerDown:a,x:i/2-s,y:-2.5*s-s,width:2*s,height:2*s,style:{cursor:"pointer"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,t.jsx)("path",{d:"M10.3246 4.31731C10.751 2.5609 13.249 2.5609 13.6754 4.31731C13.9508 5.45193 15.2507 5.99038 16.2478 5.38285C17.7913 4.44239 19.5576 6.2087 18.6172 7.75218C18.0096 8.74925 18.5481 10.0492 19.6827 10.3246C21.4391 10.751 21.4391 13.249 19.6827 13.6754C18.5481 13.9508 18.0096 15.2507 18.6172 16.2478C19.5576 17.7913 17.7913 19.5576 16.2478 18.6172C15.2507 18.0096 13.9508 18.5481 13.6754 19.6827C13.249 21.4391 10.751 21.4391 10.3246 19.6827C10.0492 18.5481 8.74926 18.0096 7.75219 18.6172C6.2087 19.5576 4.44239 17.7913 5.38285 16.2478C5.99038 15.2507 5.45193 13.9508 4.31731 13.6754C2.5609 13.249 2.5609 10.751 4.31731 10.3246C5.45193 10.0492 5.99037 8.74926 5.38285 7.75218C4.44239 6.2087 6.2087 4.44239 7.75219 5.38285C8.74926 5.99037 10.0492 5.45193 10.3246 4.31731Z",stroke:"#111827",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M15 12C15 13.6569 13.6569 15 12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9C13.6569 9 15 10.3431 15 12Z",stroke:"#111827",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]})},Yn="#ffffff",vn=A=>{const{isMobile:e,outerRadius:n,x:i,y:a,cursorStyle:s,onPointerDown:r,handleClass:o,cornerRadius:c,color:g,strokeWidth:l}=A,[B,w]=(0,Q.useState)(!1);(0,Q.useEffect)((()=>{const A=()=>{w(!1)};return document.addEventListener("pointerup",A),()=>{document.removeEventListener("pointerup",A)}}),[]);const d=(0,Q.useCallback)((A=>{w(!0),r(A)}),[r]);return e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("circle",{cx:i,cy:a,r:n,fill:B?"rgba(0,0,0,0.5)":"rgba(0,0,0,0)",style:{cursor:s},onPointerDown:d}),(0,t.jsx)("circle",{className:o,cx:i,cy:a,r:c,fill:Yn,style:{cursor:s,pointerEvents:"none"},stroke:g,strokeWidth:l})]}):(0,t.jsx)("circle",{className:o,cx:i,cy:a,r:c,fill:Yn,style:{cursor:s},stroke:g,strokeWidth:l,onPointerDown:r})},Nn=A=>{const{isMobile:e,outerRadius:n,outerWidth:i,outerHeight:a,x:s,y:r,width:o,height:c,cursorStyle:g,onPointerDown:l,edgeHandleRadius:B,color:w,strokeWidth:d}=A,[h,E]=(0,Q.useState)(!1);(0,Q.useEffect)((()=>{const A=()=>{E(!1)};return document.addEventListener("pointerup",A),()=>{document.removeEventListener("pointerup",A)}}),[]);const C=(0,Q.useCallback)((A=>{E(!0),l(A)}),[l]);return e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:s-(i-o)/2,y:r-(a-c)/2,width:i,height:a,rx:n,fill:h?"rgba(0,0,0,0.5)":"rgba(0,0,0,0)",style:{cursor:g},onPointerDown:C}),(0,t.jsx)("rect",{x:s,y:r,width:o,height:c,rx:B,fill:Yn,style:{cursor:g,pointerEvents:"none"},stroke:w,strokeWidth:d})]}):(0,t.jsx)("rect",{x:s,y:r,width:o,height:c,rx:B,fill:Yn,style:{cursor:g},stroke:w,strokeWidth:d,onPointerDown:l})},Sn=A=>{const{isMobile:e,color:n,elementHeight:i,elementWidth:a,onBeginResize:s,rotation:r,scaleFactor:o,disableX:c,disableY:g}=A,l=7.5*o,B=3*o,w=28*o,d=6*o,h=30*o,E=5*o,C=40*o,u=36*o,I=1.2*o,D=(0,Q.useCallback)(((A,t,e)=>{A.stopPropagation(),s(t,e)}),[s]),m=(0,Q.useCallback)((A=>D(A,lA(O.West,360-r),O.West)),[D,r]),p=(0,Q.useCallback)((A=>D(A,lA(O.East,360-r),O.East)),[D,r]),f=(0,Q.useCallback)((A=>D(A,lA(O.North,360-r),O.North)),[D,r]),M=(0,Q.useCallback)((A=>D(A,lA(O.South,360-r),O.South)),[D,r]),y=(0,Q.useCallback)((A=>D(A,O.Northwest,O.Northwest)),[D]),F=(0,Q.useCallback)((A=>D(A,O.Northeast,O.Northeast)),[D]),x=(0,Q.useCallback)((A=>D(A,O.Southwest,O.Southwest)),[D]),Y=(0,Q.useCallback)((A=>D(A,O.Northeast,O.Southeast)),[D]),v=(e?i-2*h-C:i-2*l-w)>0&&(e?a-2*h-C:a-2*l-w)>0;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(vn,{isMobile:e,outerRadius:h,x:0,y:0,cursorStyle:"nw-resize",onPointerDown:y,handleClass:"cornerNorthWest",cornerRadius:l,color:n,strokeWidth:I}),v?(0,t.jsx)(vn,{isMobile:e,outerRadius:h,x:a,y:0,cursorStyle:"ne-resize",onPointerDown:F,handleClass:"cornerNorthEast",cornerRadius:l,color:n,strokeWidth:I}):void 0,v?(0,t.jsx)(vn,{isMobile:e,outerRadius:h,x:a,y:i,cursorStyle:"se-resize",onPointerDown:Y,handleClass:"cornerSouthEast",cornerRadius:l,color:n,strokeWidth:I}):void 0,v?(0,t.jsx)(vn,{isMobile:e,outerRadius:h,x:0,y:i,cursorStyle:"sw-resize",onPointerDown:x,handleClass:"cornerSouthWest",cornerRadius:l,color:n,strokeWidth:I}):void 0,v&&!c?(0,t.jsx)(Nn,{isMobile:e,outerRadius:E,outerWidth:u,outerHeight:C,x:-d/2,y:i/2-w/2,width:d,height:w,onPointerDown:m,edgeHandleRadius:B,cursorStyle:"w-resize",color:n,strokeWidth:I}):void 0,v&&!g?(0,t.jsx)(Nn,{isMobile:e,outerRadius:E,outerWidth:C,outerHeight:u,x:a/2-w/2,y:i-d/2,width:w,height:d,onPointerDown:M,edgeHandleRadius:B,cursorStyle:"s-resize",color:n,strokeWidth:I}):void 0,c?void 0:(0,t.jsx)(Nn,{isMobile:e,outerRadius:E,outerWidth:u,outerHeight:C,x:a-d/2,y:i/2-Math.min(w,.8*i)/2,width:d,height:Math.min(w,.8*i),onPointerDown:p,edgeHandleRadius:B,cursorStyle:"e-resize",color:n,strokeWidth:I}),v&&!g?(0,t.jsx)(Nn,{isMobile:e,outerRadius:E,outerWidth:C,outerHeight:u,x:a/2-w/2,y:-d/2,width:w,height:d,onPointerDown:f,edgeHandleRadius:B,cursorStyle:"n-resize",color:n,strokeWidth:I}):void 0]})},Pn=A=>{const{isMobile:e,color:n,elementWidth:i,onBeginRotate:a,scaleFactor:s}=A,r=(0,Q.useCallback)((A=>{A.stopPropagation(),a()}),[a]),o=13*s,c=30*s;return(0,t.jsxs)("g",{transform:e?`translate(${-c})`:void 0,children:[(0,t.jsx)("circle",{cx:i/2,cy:-2.5*o,r:1.3*o,fill:"transparent",style:{cursor:"ew-resize"},onPointerDown:r}),(0,t.jsxs)("svg",{x:i/2-o,y:-2.5*o-o,xmlns:"http://www.w3.org/2000/svg",style:{cursor:"ew-resize"},height:2*o,viewBox:"0 0 24 24",width:2*o,stroke:n,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",onPointerDown:r,children:[" ",(0,t.jsx)("polyline",{points:"23 4 23 10 17 10"})," ",(0,t.jsx)("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})]})},Rn="spiffElementID",Hn=({color:A,height:e,highlighted:n,id:i,immutable:a,onBeginMove:s,onPointerEnter:r,onPointerLeave:o,onSelected:c,pressed:g,rotation:l,scaleFactor:B,selected:w,width:d,x:h,y:E})=>{const C=1.2*B,{addEvent:u,removeEvent:I,curActiveEvents:D}=nn(),m=(0,Q.useCallback)((A=>{u(A),A[Rn]=i;0===D&&0===A.button&&(c(i,A),s())}),[i,w,D,c,s]),p=(0,Q.useCallback)((A=>{I(A)}),[]),f=(0,Q.useCallback)((A=>{r(i)}),[i,D,r]),M=(0,Q.useCallback)((A=>{I(A),o(i)}),[i,D,o]),y=a?void 0:w?g?"grabbing":"grab":"pointer",F=a?"none":"visibleFill";return(0,t.jsx)("g",{transform:`translate(${h}, ${E}) rotate(${l} ${d/2} ${e/2})`,children:(0,t.jsx)("rect",{className:"interactableInnerRect",width:d,height:e,stroke:w||n?A:"none",pointerEvents:F,fill:"none",strokeWidth:C,style:{cursor:y},onPointerDown:a?void 0:m,onPointerUp:a?void 0:p,onPointerEnter:a?void 0:f,onPointerLeave:a?void 0:M})})},Un=A=>{const{isMobile:e,color:n,height:i,onBeginResize:a,onBeginRotate:s,onContextMenuHandlePointerDown:r,rotation:o,scaleFactor:c,width:g,x:l,y:B,disableX:w,disableY:d}=A;return(0,t.jsxs)("g",{transform:`translate(${l}, ${B}) rotate(${o} ${g/2} ${i/2})`,children:[(0,t.jsx)(Pn,{isMobile:e&&!!r,color:n,elementWidth:g,onBeginRotate:s,scaleFactor:c}),e&&r&&(0,t.jsx)(xn,{onPointerDown:r,elementWidth:g,scaleFactor:c}),(0,t.jsx)(Sn,{isMobile:e,color:n,elementHeight:i,elementWidth:g,rotation:o,scaleFactor:c,onBeginResize:a,disableX:w,disableY:d})]})},Gn=.5,bn=["TEXTAREA","INPUT"],kn=(A,t,e,n,i,a,s,r)=>{const{state:o,uiDispatcher:c}=(0,Q.useContext)(ln),{getLayoutById:g,getReducerState:l,flattenSequence:B}=an(),[w,d]=(0,Q.useState)(void 0),[h,E]=(0,Q.useState)(void 0),[C,u]=(0,Q.useState)(void 0),I=g(o.layoutId);(0,Q.useEffect)((()=>{if("adjustment"===i&&A?.current&&n){if(n<Gn)return void c(new wn({zoom:Gn}));if(n>o.maxZoom)return void c(new wn({zoom:o.maxZoom}));c(new wn({zoom:n}))}}),[n,c,A,i,o.maxZoom]);const D=(0,Q.useCallback)(((A,n)=>{c(new wn({zoom:n}));const a=t?.current?.scrollWidth-t?.current?.clientWidth!=0,s=t?.current?.scrollHeight-t?.current?.clientHeight!=0;t.current&&e.current&&!o.scrolledMovement&&"advanced"===i&&(s&&(t.current.scrollTop=e.current.offsetTop+(t.current.scrollHeight-t.current.clientHeight)/2),a&&(t.current.scrollLeft=(e.current.offsetLeft+t.current.scrollWidth-t.current.clientWidth)/2))}),[c,t,e,o.scrolledMovement,i]);(0,Q.useEffect)((()=>{o.zoom<=1&&c(new wn({scrolledMovement:!1}))}),[c,o.zoom]);const m=t?.current?.getBoundingClientRect(),p=((m?.width||1)+(m?.height||1))/2,f=(I.layoutState.layout.width+I.layoutState.layout.height)/2/p/o.zoom,M=(0,Q.useMemo)((()=>{const A=o.activeModifierKeys,t=o.elementEvent,e=A.includes(In.ControlLeft)||A.includes(In.MetaLeft)||A.includes(In.ControlRight)||A.includes(In.MetaRight);if(!o.selectedElement||!t||e)return[];const n=t&&t.type===Qn.Translate,i=t&&t.type===Qn.Rotate,a=I.layoutState.elements.find((A=>A.id===o.selectedElement));return(n||i)&&a?Cn(a,I.layoutState,f,s):[]}),[o.selectedElement,o.elementEvent,o.activeModifierKeys,I.layoutState,f]),y=(0,Q.useCallback)((()=>{const A=Y();d(A),E(l().transaction)}),[l]),F=(0,Q.useCallback)((A=>{A[Rn]||o.selectedElement&&c(new wn({selectedElement:void 0}))}),[o,c]),x=(0,Q.useCallback)((()=>{c(new wn({scrolledMovement:!0}))}),[c]),v=(0,Q.useCallback)(((e,n)=>{const i=I.layoutState.elements.find((A=>A.id===o.selectedElement));if(!(o.elementEvent&&A.current&&t.current&&o.selectedElement&&i&&e.isPrimary))return void(t.current.hasPointerCapture(e.pointerId)&&t.current.releasePointerCapture(e.pointerId));t.current.hasPointerCapture(e.pointerId)||t.current.setPointerCapture(e.pointerId);const s=A.current.getBoundingClientRect(),r=new Rt(Fn({mX:C?e.screenX-C.screenX:0,mY:C?e.screenY-C.screenY:0,clientX:e.clientX,clientY:e.clientY},I.layoutState.layout,i,s,o.elementEvent,M,n));r.sequenceId=w,a(r,!1),u({screenX:e.screenX,screenY:e.screenY})}),[I.layoutState.elements,I.layoutState.layout,o.elementEvent,A,o.selectedElement,t,M,a,C]),N=(0,Q.useCallback)((A=>{c(new wn({elementEvent:A}))}),[c]),S=(0,Q.useCallback)((()=>{N(void 0),w&&h&&(B(w,h),d(void 0),E(void 0),r&&r()),u(void 0)}),[N,w,h,B,r]),P=(0,Q.useCallback)(((A,t)=>{let e=o.zoom;const n=o.maxZoom,s=o.selectedElement,r=o.activeModifierKeys;if((r.includes(In.AltLeft)||r.includes(In.AltRight))&&(A.code===In.Equal||A.code===In.Minus)){const t=.05*n;A.code===In.Equal?c(new wn({zoom:e+t<=n?e+=t:e})):c(new wn({zoom:e-t>=Gn?e-t:e}))}const g=I.layoutState.elements.find((A=>A.id===s));if(s&&g){if(A.code===In.MetaLeft||A.code===In.ControlLeft||A.code===In.MetaRight||A.code===In.ControlRight){const t=A.code,e=o.activeModifierKeys;if(!e.includes(t))return c(new wn({activeModifierKeys:e.concat(t)}))}if(A.code===In.ArrowDown||A.code===In.ArrowUp||A.code===In.ArrowLeft||A.code===In.ArrowRight){c(new wn({elementEvent:{type:Qn.Translate}}));const e=mn(A.code,g,o.units,t);a(e,!1),c(new wn({elementEvent:void 0}))}A.code!==In.Delete&&A.code!==In.Backspace||"advanced"!==i||(c(new wn({selectedElement:void 0})),a(new bt(g.id),!1))}}),[a,c,I.layoutState.elements,i,o.activeModifierKeys,o.maxZoom,o.selectedElement,o.units,o.zoom]),R=(0,Q.useCallback)((A=>{if(A.code===In.MetaLeft||A.code===In.ControlLeft||A.code===In.MetaRight||A.code===In.ControlRight){const t=o.activeModifierKeys,e=A.code;c(new wn({activeModifierKeys:t.filter((A=>A!==e))}))}}),[c,o.activeModifierKeys]);return{guidelines:M,scale:f,zoomableElementRef:e,setElementEvent:N,handleZoom:D,handleKeyDown:P,handleKeyUp:R,handlePointerPressedBackground:F,handlePointerReleased:S,handlePointerMove:v,handleScroll:x,handleSequenceStart:y}},Jn=(A,t,e)=>{const n=(0,Q.useMemo)((()=>[...new Set(A)].map((A=>String(A).toLowerCase()))),[]),i=(0,Q.useRef)([]),a=(0,Q.useCallback)((()=>{const A=n.every((A=>i.current.includes(A))),t=i.current.length===n.length;return A&&t}),[]),s=(0,Q.useCallback)((A=>{const e=String(A.key).toLowerCase();if(A.repeat||"meta"===e)return;const n=A.target;return!(bn.indexOf(n.tagName)>=0)&&(i.current=[...new Set([...i.current,e])],a()&&t(),A.preventDefault())}),[a,n,t,A]),r=(0,Q.useCallback)((A=>{const t=String(A.key).toLowerCase(),n=a();i.current=i.current.filter((A=>A!==t));const s=a();e&&n&&!s&&e()}),[n]);(0,Q.useEffect)((()=>(window.addEventListener("keydown",s),window.addEventListener("keyup",r),()=>{window.removeEventListener("keydown",s),window.removeEventListener("keyup",r)})),[s,r])},On=A=>{const{isMobile:e,primaryColor:n,customViewbox:i,editorRef:a,elementEvent:s,guidelines:r,layoutHeight:o,layoutWidth:c,targetedElements:g,scale:l,selectedElement:B,onElementEvent:w,onElementSelected:d,onSequenceStart:h,onMouseMove:E,onContextMenuHandlePointerDown:C}=A,{state:u}=dn(),{getLayoutById:I}=an(),D=I(u.layoutId),[m,p]=(0,Q.useState)(void 0),f=(0,Q.useCallback)((A=>{p(A)}),[]),M=(0,Q.useCallback)((A=>{m===A&&p(void 0)}),[m]),y=(0,Q.useCallback)((()=>{h(),w({type:Qn.Translate})}),[w]),F=(0,Q.useCallback)(((A,t)=>{h(),w({type:Qn.Resize,relativeAxis:A,screenAxis:t})}),[w]),x=(0,Q.useCallback)((()=>{h(),w({type:Qn.Rotate})}),[w]),Y=i||{x:0,y:0,width:c,height:o},v=D.layoutState.elements,N=v.find((A=>A.id===B));return(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",style:{touchAction:"none",position:"absolute",maxWidth:"100%",maxHeight:"100%",overflow:"visible"},width:"auto",height:"auto",viewBox:`${Y.x} ${Y.y} ${Y.width} ${Y.height}`,children:[(0,t.jsx)("rect",{onMouseMove:E,style:{pointerEvents:"all"},fill:"none",stroke:"none",ref:a,width:c,height:o}),r.map((A=>A.svgNode)),v.map((A=>{const e=void 0!==B&&A.id===B,i=e&&void 0!==s,a=void 0!==m&&A.id===m;return(0,t.jsx)(Hn,{color:n,id:A.id,selected:e,highlighted:a,pressed:i,x:A.x,y:A.y,width:A.width,height:A.height,rotation:A.rotation,immutable:A.immutable||g&&!g.includes(A.id),onSelected:d,onBeginMove:y,onPointerEnter:f,onPointerLeave:M,scaleFactor:l},A.id)})),N&&(0,t.jsx)(Un,{isMobile:e,color:n,x:N.x,y:N.y,disableX:N.type===P.Frame||N.type===P.Image,disableY:N.type===P.Textbox||N.type===P.Frame||N.type===P.Image,width:N.width,height:N.height,rotation:N.rotation,onBeginResize:F,onBeginRotate:x,scaleFactor:l,onContextMenuHandlePointerDown:C})]})},zn=A=>{const{isMobile:e,color:n,editorRef:i,zoomableElementRef:a,interactionElementRef:s,guidelines:r,isMakingAdjustments:o,outlineArea:c,visibleLayoutId:g,xTranslation:l,yTranslation:B,targetedElements:w,borderRadius:d,canvasFilter:h,handleContextMenu:E,onMouseMove:C,onContextMenuHandlePointerDown:u,handleKeyDown:I,handleKeyUp:D,handlePointerMove:m,handlePointerPressedBackground:p,handlePointerReleased:f,handleScroll:M,onSequenceStart:y,setElementEvent:F,onElementSelected:x}=A,{getLayoutById:Y}=an(),v=Y(g),N=v.layoutState,{state:S}=dn(),P=(0,Q.useCallback)((A=>{if(c){const t={left:c.x||0,top:c.y||0,width:c.width||1,height:c.height||1,panelId:"",rotation:0};return I(A,t)}return I(A)}),[I,c]),R=(0,Q.useCallback)((A=>{if(c){const t={left:c.x||0,top:c.y||0,width:c.width||1,height:c.height||1,panelId:"",rotation:0};return m(A,t)}return m(A)}),[m,c]),U=(0,Q.useMemo)((()=>{return{justifyContent:"center",position:"relative",height:"100%",width:"100%",scrollbarWidth:"none",outline:(A=window.chrome,t=window.navigator,e=t.vendor,n=void 0!==window.opr,t.userAgent.match("CriOS")||null==A||"Google Inc."!==e||!1!==n?void 0:"none")};var A,t,e,n}),[]),G=(0,Q.useMemo)((()=>({height:"100%",transform:`scale(${S.zoom}) translate(${l}px, ${B}px)`,display:"flex",justifyContent:"center",alignItems:"center",filter:h||"drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.2))",overflow:"visible"})),[S.zoom,S.xTranslation,S.yTranslation]),b=10/S.zoom,k=N.layout.width,J=N.layout.height,O=a.current?.offsetHeight||1024,z=a.current?.offsetWidth||1024,j=b*(Math.sqrt(k*J)/1e3)*(100/Math.sqrt(O*z))*Math.sqrt((L=z/O,Math.exp(Math.abs(Math.log(L)))));var L;const T=(0,Q.useMemo)((()=>({configuration:{purpose:H.FreeDesign},height:o?"100%":"auto",width:o?"100%":"auto",maxHeight:"100%",maxWidth:"100%",position:"absolute",outlineArea:c?{...c,scale:j}:void 0,borderRadius:d})),[o,j]);return(0,t.jsx)("div",{style:U,onContextMenu:E,onKeyDown:P,onKeyUp:D,onPointerDown:p,onMouseLeave:f,onPointerMoveCapture:R,onPointerUp:f,onWheelCapture:M,ref:s,tabIndex:-1,children:(0,t.jsxs)("div",{ref:a,style:G,children:[A.children,v.getComponentWithProps(T),(0,t.jsx)(On,{isMobile:e,primaryColor:n,editorRef:i,elementEvent:S.elementEvent,guidelines:r,layoutHeight:N.layout.height,layoutWidth:N.layout.width,onElementEvent:F,onSequenceStart:y,onElementSelected:x,scale:j,selectedElement:S.selectedElement,targetedElements:w,onMouseMove:C,onContextMenuHandlePointerDown:u})]})})},jn=({isMobile:A,color:e,borderRadius:n,guidelineColor:i,canvasFilter:a,hideEditableAreaRect:s,handleContextMenu:r,onMouseMove:o,onContextMenuHandlePointerDown:c,onElementSelected:g,onDragEnd:l})=>{const{commandDispatcher:B,getLayoutById:w}=an(),{state:d,uiDispatcher:h}=dn(),E=(0,Q.useRef)(null),C=(0,Q.useRef)(null),u=(0,Q.useRef)(null),{guidelines:I,handleKeyDown:D,handleKeyUp:m,handlePointerMove:p,handlePointerPressedBackground:f,handlePointerReleased:M,handleScroll:y,handleSequenceStart:F,setElementEvent:x}=kn(E,C,u,void 0,"advanced",B,i,l),Y=(0,Q.useMemo)((()=>w(d.layoutId)),[w,d.layoutId]),v=(0,Q.useCallback)(((A,t)=>{const e=Y.layoutState.elements.find((t=>t.id===A));if(A&&e&&e.type===P.Textbox){const t=e.algorithm;(!t||t===G.Autosize)&&B(new zt(A,G.Traditional),!0)}g&&g(A,t),h(new wn({selectedElement:A}))}),[B,w,d.layoutId,h]),N=(0,Q.useMemo)((()=>{if(Y.layoutState.layout.useEditableArea)return{...Y.layoutState.layout.editableArea,hidden:s}}),[Y.layoutState.layout.useEditableArea,Y.layoutState.layout.editableArea,s]);return(0,t.jsx)(zn,{outlineArea:N,isMobile:A,color:e,editorRef:E,interactionElementRef:C,zoomableElementRef:u,guidelines:I,visibleLayoutId:d.layoutId,xTranslation:d.xTranslation,yTranslation:d.yTranslation,borderRadius:n,canvasFilter:a,handleContextMenu:r,onMouseMove:o,onContextMenuHandlePointerDown:c,handleKeyDown:D,handleKeyUp:m,handlePointerMove:p,handlePointerPressedBackground:f,handlePointerReleased:M,handleScroll:y,onSequenceStart:F,setElementEvent:x,onElementSelected:v})},Ln=d.gql`
2
2
  mutation CreateTransaction($integrationProductId: String!, $bulk: Boolean) {
3
3
  transactionCreate(integrationProductId: $integrationProductId, bulk: $bulk) {
4
4
  id