@spiffcommerce/core 0.9.3 → 0.9.4

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("axios"),e=require("https"),n=require("file-type"),i=require("buffer"),a=require("util"),o=require("css"),s=require("opentype.js"),r=require("react/jsx-runtime"),c=require("react-dom/server"),g=require("canvas"),B=require("exif"),l=require("swagger-client"),w=require("@apollo/client"),E=require("@apollo/client/link/context"),h=require("@apollo/client/link/error"),d=require("cross-fetch"),Q=require("react"),C=require("lodash.isequal"),u=require("canvg"),D=require("lodash.debounce"),I=require("qrcode"),p=require("svg-path-bbox");function f(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}var m="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 F(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}f(module.exports,"Client",(()=>na)),f(module.exports,"CommandContext",(()=>Qt)),f(module.exports,"spiffCoreConfiguration",(()=>De)),f(module.exports,"PromiseQueue",(()=>Gn)),f(module.exports,"QueueablePromise",(()=>Un)),f(module.exports,"MockWorkflowManager",(()=>aa)),f(module.exports,"InformationMessageType",(()=>ui)),f(module.exports,"assetService",(()=>Ye)),f(module.exports,"optionService",(()=>Ne)),f(module.exports,"server",(()=>Me)),f(module.exports,"persistenceService",(()=>ln)),f(module.exports,"graphQlManager",(()=>Fe)),f(module.exports,"toast",(()=>mi)),f(module.exports,"FrameService",(()=>bn)),f(module.exports,"frameStepService",(()=>Vn)),f(module.exports,"modelStepService",(()=>Wn)),f(module.exports,"materialStepService",(()=>Xn)),f(module.exports,"patchworkStepService",(()=>_n)),f(module.exports,"shapeStepService",(()=>ti)),f(module.exports,"questionStepService",(()=>fn)),f(module.exports,"digitalContentStepService",(()=>Kn)),f(module.exports,"moduleStepService",(()=>qn)),f(module.exports,"pictureStepService",(()=>Ai)),f(module.exports,"textStepService",(()=>Yi)),f(module.exports,"illustrationStepService",(()=>pn)),f(module.exports,"svgObjectURL",(()=>In)),f(module.exports,"ProductCameraRig",(()=>Oe)),f(module.exports,"AssetType",(()=>T)),f(module.exports,"BringForwardCommand",(()=>Vt)),f(module.exports,"CanvasCommand",(()=>Ft)),f(module.exports,"CreateElementCommand",(()=>vt)),f(module.exports,"CreateLayoutCommand",(()=>St)),f(module.exports,"DeleteElementCommand",(()=>Ut)),f(module.exports,"FontAlignmentCommand",(()=>Ot)),f(module.exports,"FontColorCommand",(()=>Pt)),f(module.exports,"FontSizeCommand",(()=>kt)),f(module.exports,"FontSourceCommand",(()=>bt)),f(module.exports,"GroupCommand",(()=>Ht)),f(module.exports,"LayoutElementFactory",(()=>Qe)),f(module.exports,"LayoutElementType",(()=>U)),f(module.exports,"MoveCommand",(()=>Yt)),f(module.exports,"ResizeCommand",(()=>Nt)),f(module.exports,"RotateCommand",(()=>xt)),f(module.exports,"SendBackwardsCommand",(()=>Xt)),f(module.exports,"StepAspectType",(()=>W)),f(module.exports,"StepType",(()=>V)),f(module.exports,"TextChangeCommand",(()=>zt)),f(module.exports,"UnitOfMeasurement",(()=>J)),f(module.exports,"dataUrlFromExternalUrl",(()=>vA)),f(module.exports,"findElement",(()=>pt)),f(module.exports,"frameDataCache",(()=>ie)),f(module.exports,"generate",(()=>x)),f(module.exports,"generateSVGWithUnknownColors",(()=>Et)),f(module.exports,"getAttributesFromArrayBuffer",(()=>te)),f(module.exports,"rehydrateSerializedLayout",(()=>Mt)),f(module.exports,"getFrameData",(()=>re)),f(module.exports,"getSvgString",(()=>ut)),f(module.exports,"loadFontFromDataUrl",(()=>zA)),f(module.exports,"loadFontFromExternalUrl",(()=>LA)),f(module.exports,"determineCorrectFontSizeAndLines",(()=>he)),f(module.exports,"patternImageDataCache",(()=>ne)),f(module.exports,"generateCommands",(()=>Ki)),f(module.exports,"registerJSDOM",(()=>pA)),f(module.exports,"minZoom",(()=>_e)),f(module.exports,"AdvancedEditor",(()=>cn)),f(module.exports,"EditorCore",(()=>rn)),f(module.exports,"useLayouts",(()=>Se)),f(module.exports,"useEditorState",(()=>be)),f(module.exports,"useEditorInteraction",(()=>An)),f(module.exports,"commandReducer",(()=>Ge)),f(module.exports,"getDefaultState",(()=>Ue)),f(module.exports,"CommandContextContext",(()=>He)),f(module.exports,"AdvancedEditorStateProvider",(()=>ke)),f(module.exports,"AdvancedEditorContext",(()=>Pe)),f(module.exports,"UICommand",(()=>Je)),f(module.exports,"EditorSubMenu",(()=>Re)),f(module.exports,"ElementEventType",(()=>je)),f(module.exports,"KeyEvent",(()=>Ke)),f(module.exports,"gatherVaryingStepAspects",(()=>Fn));var y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==m?m:{},Y={};F(Y,"CanvasCommand",(()=>Ft)),F(Y,"UpdateWorkflowStateCommand",(()=>yt)),F(Y,"MoveCommand",(()=>Yt)),F(Y,"RotateCommand",(()=>xt)),F(Y,"ResizeCommand",(()=>Nt)),F(Y,"GroupCommand",(()=>Ht)),F(Y,"CreateLayoutCommand",(()=>St)),F(Y,"ClearLayoutCommand",(()=>Rt)),F(Y,"CreateElementCommand",(()=>vt)),F(Y,"DeleteElementCommand",(()=>Ut)),F(Y,"CloneElementCommand",(()=>Gt)),F(Y,"FontColorCommand",(()=>Pt)),F(Y,"FontSizeCommand",(()=>kt)),F(Y,"FontAlgorithmCommand",(()=>Jt)),F(Y,"FontSourceCommand",(()=>bt)),F(Y,"FontAlignmentCommand",(()=>Ot)),F(Y,"UpdateFramePattern",(()=>Lt)),F(Y,"TextChangeCommand",(()=>zt)),F(Y,"IllustrationColorCommand",(()=>jt)),F(Y,"IllustrationCacheCommand",(()=>Tt)),F(Y,"ShiftPatchworkCommand",(()=>Kt)),F(Y,"BringForwardCommand",(()=>Vt)),F(Y,"SendBackwardsCommand",(()=>Xt)),F(Y,"LayerCommand",(()=>Wt)),F({},"generate",(()=>x));const x=()=>{const A=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return A()+A()+"-"+A()+"-"+A()+"-"+A()+"-"+A()+A()+A()};var N={};F(N,"ElementNotFoundError",(()=>It)),F(N,"findElement",(()=>pt)),F(N,"findLayoutForElement",(()=>ft)),F(N,"updatedLayoutForElement",(()=>mt)),F(N,"rehydrateSerializedLayout",(()=>Mt));var H={};F(H,"CommandContext",(()=>Qt)),F(H,"sortElementsByLayersWithIndex",(()=>Dt)),F(H,"getSvgString",(()=>ut)),F({},"SVGLayout",(()=>S));const S=({viewmask:A,viewBox:t,width:e,height:n,position:i,maxWidth:a,maxHeight:o,elements:s,preserveAspectRatio:c,backgroundColor:g,omitBoundClipping:B,borderRadius:l,colorProfiles:w})=>{const E=x(),h=A?`url(#viewmask-${E})`:void 0,d=t||{x:0,y:0,width:e,height:n},Q=`${d.x} ${d.y} ${d.width} ${d.height}`,C=l||0,u=B?void 0:(0,r.jsxs)("defs",{children:[(0,r.jsx)("clipPath",{id:"viewboxClip",children:(0,r.jsx)("rect",{width:d.width,height:d.height,rx:C})}),A&&(0,r.jsxs)("mask",{id:`viewmask-${E}`,children:[(0,r.jsx)("rect",{x:d.x,y:d.y,width:d.width,height:d.height,fill:"black"}),(0,r.jsx)("rect",{x:A.x,y:A.y,width:A.width,height:A.height,fill:"white"})]})]}),D=w?.map(((A,t)=>(0,r.jsx)("color-profile",{name:A.name,xlinkHref:A.key,children:" "},t)));return(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",preserveAspectRatio:c,width:e,height:n,style:{gridColumn:1,gridRow:1,maxWidth:a,maxHeight:o,position:i},viewBox:Q,children:[D,u,!!g&&(0,r.jsx)("rect",{id:"layout-background",width:d.width,height:d.height,fill:g,mask:h,rx:C}),(0,r.jsx)("g",{id:"element-group",clipPath:B?void 0:"url(#viewboxClip)",mask:h,children:s})]})};F({},"Image",(()=>EA));var R={};F(R,"getAxisAlignedBoundingBox",(()=>Z)),F(R,"degreesToRadians",(()=>_)),F(R,"findAngle",(()=>$)),F(R,"radiansToDegrees",(()=>AA)),F(R,"isCloseToValue",(()=>tA)),F(R,"getTrueCoordinates",(()=>eA)),F(R,"getPointOfRotation",(()=>nA)),F(R,"getNWPoint",(()=>iA)),F(R,"getNEPoint",(()=>aA)),F(R,"getSWPoint",(()=>oA)),F(R,"getSEPoint",(()=>sA)),F(R,"turnRightClockwise",(()=>rA)),F(R,"currentDirection",(()=>cA)),F(R,"getElementVertices",(()=>gA)),F(R,"rotateAroundPoint",(()=>BA)),F(R,"mmPerPixel",(()=>lA)),F(R,"cmPerPixel",(()=>wA));var v={};let U;var G;let P;var k;let J;var b;let O;var L;let z;var j;let T;var K;let V;var X;let W;var q;F(v,"LayoutElementType",(()=>U)),F(v,"TextAlgorithm",(()=>P)),F(v,"UnitOfMeasurement",(()=>J)),F(v,"ScaleAxis",(()=>O)),F(v,"MaterialEffectMode",(()=>z)),F(v,"AssetType",(()=>T)),F(v,"StepType",(()=>V)),F(v,"StepAspectType",(()=>W)),(G=U||(U={})).Frame="frame",G.Image="image",G.Illustration="illustration",G.Textbox="textbox",G.Patchwork="patchwork",(k=P||(P={})).Autosize="Autosize",k.Traditional="Traditional",(b=J||(J={})).Pixel="px",b.Millimeter="mm",b.Centimeter="cm",(L=O||(O={}))[L.North=0]="North",L[L.Northeast=1]="Northeast",L[L.East=2]="East",L[L.Southeast=3]="Southeast",L[L.South=4]="South",L[L.Southwest=5]="Southwest",L[L.West=6]="West",L[L.Northwest=7]="Northwest",(j=z||(z={})).None="None",j.RemoveWhenSelected="RemoveWhenSelected",j.ApplyWhenSelected="ApplyWhenSelected",(K=T||(T={})).Font="Font",K.Frame="Frame",K.Illustration="Illustration",K.Image="Image",K.Model="Model",K.Material="Material",K.Patchwork="Patchwork",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.Patchwork="Patchwork",X.Picture="Picture",X.Photo="Photo",X.ProductOverlay="ProductOverlay",X.Question="Question",X.Shape="Shape",X.SilentIllustration="SilentIllustration",X.Text="Text",(q=W||(W={})).Color="Color",q.Colors="Colors",q.Selection="Selection",q.Selections="Selections",q.Text="Text",q.Upload="Upload";const Z=(A,t,e,n,i)=>{const a=_(i),o=e/2,s=n/2,r=A+o,c=t+s,g=Math.sin(a),B=Math.cos(a),l=-s,w=o*B-l*g,E=o*B-s*g,h=o*g+l*B,d=o*g+s*B,Q=Math.max(Math.abs(w),Math.abs(E)),C=Math.max(Math.abs(h),Math.abs(d));return{minX:r-Q,maxX:r+Q,minY:c-C,maxY:c+C}},$=(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)},_=A=>A*(Math.PI/180),AA=A=>A*(180/Math.PI),tA=(A,t,e)=>Math.abs(A-t)<e,eA=(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}},nA=(A,t)=>({x:(A.x+t.x)/2,y:(A.y+t.y)/2}),iA=(A,t,e,n)=>({x:A.x+t?.x*e,y:A.y+t?.y*n}),aA=(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}),sA=(A,t,e,n)=>({x:A.x+(t?.x+t?.width)*e,y:A.y+(t?.y+t?.height)*n}),rA=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}},cA=(A,t)=>t>45&&t<=135?rA(A):t>135&&t<=225?rA(rA(A)):t>225&&t<=315?rA(rA(rA(A))):A,gA=(A,t={x:0,y:0},e={x:1,y:1})=>{const n=_(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},o={x:t.x+(A.x+A.width)*e.x,y:t.y+(A.height+A.y)*e.y},s={x:t.x+A.x*e.x,y:t.y+(A.height+A.y)*e.y},r={x:(s.x+o.x)/2,y:s.y-A.height*e.y/2};return{a:BA(i,r,n),b:BA(a,r,n),c:BA(o,r,n),d:BA(s,r,n),center:r}},BA=(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}},lA=.352778,wA=.035277,EA=A=>{const t=A.rotation||0,e=_(t),n=Math.cos(e),i=-Math.sin(e);return(0,r.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(${n}, ${-i}, ${i}, ${n}, 0, 0)\n matrix(1, 0, 0, 1, ${-A.width/2}, ${-A.height/2})\n `,children:(0,r.jsx)("image",{xlinkHref:A.src,preserveAspectRatio:A.preserveAspectRatio,width:A.width,height:A.height})})};F({},"Frame",(()=>hA));const hA=A=>{const t=`spiff-frame-${A.id}`,e=`spiff-frame-blur-${A.id}`,n=`spiff-frame-blur-edge-${A.id}`,i=`spiff-frame-focal-mask-${A.id}`,a=!!A.focalBlur&&!!A.pattern,o=A.rotation||0,s=_(o),c=Math.cos(s),g=-Math.sin(s);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("defs",{children:(a=>{const o=A.pattern?.x||0,s=A.pattern?.y||0,c=A.pattern?A.pattern.width*A.pattern.scaleX+Math.abs(o):256,g=A.pattern?A.pattern.height*A.pattern.scaleY+Math.abs(s):256,B=A.pattern?A.pattern.width*A.pattern.scaleX:256,l=A.pattern?A.pattern.height*A.pattern.scaleY:256;return(0,r.jsxs)(r.Fragment,{children:[(0,r.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:t,children:(0,r.jsx)("image",{preserveAspectRatio:"none",x:o,y:s,width:B,height:l,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/Q5Y4kAAgBQE0rtDQaDuSdTLKCIAbvBQwnKa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3nxcFBV1vg4g+QBwKCUDVAp68DJ3hnpPJhK8fIAKFS4EXIQJ6DfsaUGecAQCeKNULsAgRYMgnQHxKNwPFFgH71NfMfwCon0rdgEYE3NNaIlBlZJeM3xaA1dXV2v/DAaCGdmCJwLtAKW/ZQR1XV6OZPw+c9CMA1EMt8wDSBnWcnh0Xug64S0Xk/jP9FyAOtQ0ECYnA7fj291afLNRfcOq0Am9v72Q+DgDKUftmINM+bDoIbVTmqxy/rg0ucvsvLi9mfqoGnzoWfgKAnyirwdJEIHl069fW1qb/Ls/g7u5uzkOgqw8gPtF2A+bd7+ejSAcgAJQnmgAYfK59iOma7923yfpgyFcKsACiC0Dy6OZLCMbjsfdaIMPf3NgMxgcAIA4LEQAbpfkkCA8/fyYrjzX/9PEDNMPzRb+qjH2NLxtgKVj4YhAAWB4QAIAegwAA9BgEAKDHIAAAPQYBAOgxCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAEBfSZLk/xjo1hVZWiK0AAAAAElFTkSuQmCC"})}),a?(0,r.jsx)(dA,{path:A.path,width:A.width,height:A.height,focalBlurStrength:A.focalBlurStrength||1,focalBlurRadius:A.focalBlurRadius||10,blurFilterId:e,focalMaskId:i,blurEdgeClipId:n}):null]})})(a)}),(0,r.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,r.jsx)("path",{filter:a?`url(#${e})`:void 0,mask:a?`url(#${n})`:void 0,d:A.path,style:{fill:`url(#${t})`,opacity:A.opacity}}),a?(0,r.jsx)("path",{mask:`url(#${i})`,d:A.path,style:{fill:`url(#${t})`,opacity:A.opacity}}):void 0]})]})},dA=A=>{const{path:t,width:e,height:n,focalBlurStrength:i,focalBlurRadius:a,blurFilterId:o,focalMaskId:s,blurEdgeClipId:c}=A;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("filter",{id:o,children:(0,r.jsx)("feGaussianBlur",{stdDeviation:i||0})}),(0,r.jsx)("mask",{id:s,children:(0,r.jsx)("circle",{cx:e/2,cy:n/2,r:a||0,fill:"white",filter:`url(#${o})`})}),(0,r.jsx)("mask",{id:c,children:(0,r.jsx)("path",{d:t,style:{fill:"white",opacity:1}})})]})};F({},"Textbox",(()=>ot));var QA={};F(QA,"fontSizeStep",(()=>VA)),F(QA,"textWidth",(()=>XA)),F(QA,"applyTextTransformations",(()=>qA)),F(QA,"zip",(()=>ZA)),F(QA,"getTextAlignment",(()=>$A)),F(QA,"getAnchor",(()=>_A)),F(QA,"recomputeTextOnElement",(()=>At)),F(QA,"defaultLineHeightFactor",(()=>tt)),F({},"calculateTextboxLines",(()=>KA));var CA={};F(CA,"FontMetrics",(()=>OA)),F(CA,"loadFontFromExternalUrl",(()=>LA)),F(CA,"loadFontFromDataUrl",(()=>zA)),F(CA,"getFontMetrics",(()=>jA));var uA={};F(uA,"registerJSDOM",(()=>pA)),F(uA,"createElement",(()=>FA)),F(uA,"createElementNS",(()=>yA)),F(uA,"domParser",(()=>YA)),F(uA,"fetchAsArrayBuffer",(()=>xA)),F(uA,"fetchAsString",(()=>NA)),F(uA,"loadFontFaceSet",(()=>HA)),F(uA,"xmlSerializer",(()=>SA)),F(uA,"toBase64",(()=>RA)),F(uA,"dataUrlFromExternalUrl",(()=>vA)),F(uA,"arrayBufferToDataUrl",(()=>UA)),F(uA,"arrayBufferToBuffer",(()=>PA)),F(uA,"dataUrlToArrayBuffer",(()=>GA));var DA=i.Buffer;let IA;function pA(A){IA=A}function fA(){if(!IA)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new IA}if(void 0===y.TextEncoder){const{TextEncoder:A}=a;y.TextEncoder=A}if(void 0===y.TextDecoder){const{TextDecoder:A}=a;y.TextDecoder=A}const mA=new(M(e).Agent)({rejectUnauthorized:!0}),MA=A=>A.every((A=>"undefined"!==A)),FA=A=>MA([typeof document])?document.createElement(A):fA().window.document.createElement(A),yA=(A,t)=>{if(MA([typeof document]))return document.createElementNS(A,t);const e=fA().window.document.createElement(t);return e.setAttribute("xmlns",A),e},YA=()=>MA([typeof DOMParser])?new DOMParser:new(fA().window.DOMParser),xA=A=>{if(MA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.arrayBuffer())})).catch((A=>{e(A)}))}));{const e=A.replace("localhost","localstack");return new Promise(((A,n)=>{M(t).get(e,{responseType:"arraybuffer",httpsAgent:mA}).then((t=>{A(t.data)})).catch((A=>{n(A)}))}))}},NA=A=>{if(MA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.text())})).catch(e)}));{const e=A.replace("localhost","localstack");return new Promise(((A,n)=>{M(t).get(e,{responseType:"text",httpsAgent:mA}).then((t=>{A(t.data)})).catch(n)}))}},HA=async(A,t)=>{if(MA([typeof FontFace])){const e=A.names.fullName.en,n=new FontFace(e,`url(${t})`);return document.fonts.add(n),n.load()}},SA=()=>MA([typeof XMLSerializer])?new XMLSerializer:new(fA().window.XMLSerializer),RA=A=>MA([typeof btoa])?btoa(A):DA.from(A).toString("base64"),vA=async A=>{if(MA([typeof fetch,typeof Blob,typeof FileReader])){const t=await fetch(A),e=await t.blob();return await JA(e)}const e=(await M(t).get(A,{responseType:"arraybuffer"})).data;return UA(e)},UA=async A=>{const t=await(async A=>{const t=await(0,n.fromBuffer)(A);return t?t.mime:"image/svg+xml"})(A);return`data:${t};base64,${PA(A).toString("base64")}`},GA=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",o=unescape(t.substring(e+1)),s=DA.from(o,a);return kA(s)},PA=A=>DA.from(A),kA=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},JA=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)})),bA=new Map;class OA{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=async A=>{const t=await vA(A),e=zA(t);return TA(e,{assetUrl:t,name:e.names.fullName.en}),await HA(e,A),e},zA=A=>{const t=GA(A),e=M(s).parse(t);return TA(e,{assetUrl:A,name:e.names.fullName.en}),e},jA=A=>{const t=bA.get(A.name);if(t)return t;throw new Error("Font metrics unavailable for font")},TA=(A,t)=>{const e=new OA(A);return bA.set(t.name,e),e},KA=(A,t,e,n,i)=>{const a=jA(t),o=a.getFont();return((A,t,e,n,i,a)=>{const o=a||tt;let s=t.split("\n"),r=s.length,c=s.map((A=>XA(A,n,i))),g=!0;for(;g;){const t=r*(e*o);if(Math.max(...c)<=A.width)return{lines:s,requiredHeight:t};const a=c.reduce(((A,t,e,n)=>t>n[A]?e:A),0),B=s[a];let l=!1,w=B.length;for(;!l&&w>-1;){if(w=B.lastIndexOf(" ",w-1),-1===w){g=!1;break}const t=[B.slice(0,w),B.slice(w+1)],e=t.map((A=>XA(A,n,i)));e[0]<=A.width&&(s=[...s.slice(0,a),...t,...s.slice(a+1)],c=[...c.slice(0,a),...e,...c.slice(a+1)],r+=1,l=!0)}l||(g=!1)}return{lines:s,requiredHeight:r*(e*o)}})(e,qA(n),A,A/o.unitsPerEm,a,i)},VA=1,XA=(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},WA={stripControlCharacters:!0,vertical:!1,uppercase:!1},qA=(A,t=WA)=>{const e={...WA,...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},ZA=(A,t)=>A.map(((A,e)=>[A,t[e]])),$A=(A="center",t=!1)=>t?"center":A,_A=A=>"left"===A?"start":"right"===A?"end":"middle",At=(A,t)=>A.fontData?{...A,...(()=>{if(A.algorithm===P.Traditional){const e=KA(A.fontSize,A.fontData,A,t,A.lineHeight);return{text:e.lines.join("\n"),height:e.requiredHeight,input:t}}return{text:t}})()}:A,tt=1.1;var et={};F(et,"colorDefinitionPrintValue",(()=>nt)),F(et,"spotColorDefinitionString",(()=>it)),F(et,"svgColorValueToDefinition",(()=>at));const nt=A=>`${A.browserValue} ${it(A.spotColor)}`,it=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})`},at=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]}}},ot=A=>{const t=(A.rotation||0)*Math.PI/180,e=Math.cos(t),n=-Math.sin(t),i=`text-path-${A.id}`,a=A.x+(A.curved?0:A.width/2),o=A.y+(A.curved?0:A.height/2),s=(A.text||"").split("\n");return A.curved&&!A.paths?null:A.fontData?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("defs",{children:[(0,r.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,r.jsx)("path",{id:i,d:A.paths[0]}):void 0]}),A._renderingConfiguration?.debug?(0,r.jsx)("rect",{stroke:"blue",fill:"none",x:A.x,y:A.y,width:A.width,height:A.height}):void 0,(0,r.jsx)("g",{transform:`matrix(${e}, ${-n}, ${n}, ${e}, ${a}, ${o})`,children:(0,r.jsx)("text",{xmlSpace:"preserve",fontFamily:`'${A.fontData.name}'`,fontSize:A.fontSize,fontStyle:"normal",fontWeight:"normal",fill:A._renderingConfiguration?.spotColors&&A.fillSpotColorDefinition?`${A.fill} ${it(A.fillSpotColorDefinition)}`:A.fill,style:{whiteSpace:"pre",userSelect:"none"},children:A.curved?(0,r.jsx)(rt,{text:A.text||"",curvedPathId:i,align:A.align}):s.map(((t,e)=>(0,r.jsx)(st,{align:A.vertical?"center":A.align,fontSize:A.fontSize,thisLineIdx:e,amountLines:s.length,text:t,textboxHeight:A.height,textboxWidth:A.width,lineHeight:A.lineHeight,vertical:A.vertical,verticalAlign:A.verticalAlign},e)))})})]}):null},st=A=>(0,r.jsx)("tspan",{textAnchor:_A(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:tt),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}),rt=A=>{const t=`#${A.curvedPathId}`;return(0,r.jsx)("textPath",{startOffset:"left"===A.align?"0%":"right"===A.align?"100%":"50%",textAnchor:_A(A.align),href:t,xlinkHref:t,children:A.text})};F({},"Illustration",(()=>ht));var ct={};F(ct,"traverse",(()=>Bt)),F(ct,"sanitizeSvgTree",(()=>lt)),F(ct,"modifySVGWithElementProperties",(()=>wt)),F(ct,"generateSVGWithUnknownColors",(()=>Et));const gt=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],Bt=(A,t)=>{t(A),A.children.length>0&&Array.from(A.children).forEach((A=>Bt(A,t)))},lt=(A,t=!1)=>{!t&&A.setAttribute("preserveAspectRatio","none");const e=[];Bt(A,(A=>{if("script"!==A.tagName)if("style"!==A.tagName);else try{(0,o.parse)(A.innerHTML).stylesheet?.rules.forEach((A=>{e.push(A)})),A.remove()}catch(A){console.error(A)}else A.remove()})),Bt(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)}))}))}))}))},wt=(A,t,e,n,i)=>{const a=(A=>YA().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)=>{Bt(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?nt(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?nt(i):i.browserValue)}}))}))})(a,n,i),(A=>SA().serializeToString(A))(a)},Et=async A=>{const t=A.match(/<svg.*?<\/svg>/s)||[],e=t?.length>0?t[0]:"",n=YA().parseFromString(e,"image/svg+xml").firstElementChild;if(!n)throw new Error("Failed to read SVG.");lt(n);const i={};Bt(n,(A=>{gt.includes(A.tagName)&&!A.attributes.getNamedItem("fill")&&A.setAttribute("fill","black");const t=A.attributes.getNamedItem("fill");if(t&&"none"!==t.value){const e=at(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=at(e.value),n=`spiff-stroke-${t.browserValue.replace(/\W/g,"")}`;A.classList.add(n),A.setAttribute("stroke",t.browserValue),i[n]=t}}));const a=SA().serializeToString(n);return{colors:i,svg:a}},ht=A=>{if(A.cachedObjectURL&&!A._renderingConfiguration?.omitCachedFields)return(0,r.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});const t=A.rotation||0,e=_(t),n=Math.cos(e),i=-Math.sin(e),a=`\n matrix(1, 0, 0, 1, ${A.x}, ${A.y})\n matrix(1, 0, 0, 1, ${A.width/2}, ${A.height/2})\n matrix(${n}, ${-i}, ${i}, ${n}, 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,r.jsx)("g",{transform:a,dangerouslySetInnerHTML:{__html:wt(A.svg,A.width,A.height,A.colors,A._renderingConfiguration?.spotColors)}})};F({},"Patchwork",(()=>dt));const dt=A=>{const{id:t,x:e,y:n,width:i,height:a,rotation:o,patchX:s,patchY:c,patchScale:g}=A,B=`patchwork-clip-${t}`;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("defs",{children:(0,r.jsx)("clipPath",{id:B,children:(0,r.jsx)("rect",{x:0,y:0,height:a,width:i})})}),(0,r.jsx)("g",{className:`region-${t}`,transform:`\n translate(${e}, ${n})\n rotate(${o})\n `,clipPath:`url(#${B})`,children:(0,r.jsx)("image",{className:`patchwork-slice-${t}`,width:i,height:a,transform:`\n translate(${s}, ${c})\n scale(${g})\n `,xlinkHref:`data:image/svg+xml;utf8,${encodeURIComponent(A.svg)}`})})]})};class Qt{constructor(){this.id=x(),this.stateCallbacks=[],this.prevCommands=[],this.nextCommands=[]}registerStateCallback(A){A(),this.stateCallbacks.push(A)}getState(){return this.state}runStateCallbacks(){this.stateCallbacks.forEach((A=>A()))}apply(A){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);this.state=this.commandReducer(this.state,A),this.runStateCallbacks(),this.nextCommands=[],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,t){const e=Dt([...t]).map((A=>Ct(A))),n={width:A.width,height:A.height,viewBox:{x:0,y:0,width:A.width,height:A.height}},i={backgroundColor:A.transparentBackground?void 0:"white",elements:e};return{layoutState:{layout:A,elements:t},Component:(0,r.jsx)(S,{...i,...n}),getComponentWithProps:A=>(0,r.jsx)(S,{...i,...n,...A})}}initialize(A,t){if(t)return void(this.state={transaction:t});let e={serializableWorkflow:{steps:[]},layouts:{}};A.forEach((A=>{e=new St(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 Ct=A=>"image"===A.type?(0,r.jsx)(EA,{...A},A.id):"frame"===A.type?(0,r.jsx)(hA,{...A},A.id):"illustration"===A.type?(0,r.jsx)(ht,{...A},A.id):"patchwork"===A.type?(0,r.jsx)(dt,{...A},A.id):"textbox"===A.type?(0,r.jsx)(ot,{...A},A.id):null,ut=(A,t,e)=>{const n={backgroundColor:A.transparentBackground?void 0:"white"},i={width:e?.region?e.region.width:A.width,height:e?.region?e.region.height:A.height,viewBox:e?.region?{x:e.region.left,y:e.region.top,width:e.region.width,height:e.region.height}:{x:0,y:0,width:A.width,height:A.height}},a=Dt((e?.removeExcludedElements?t.filter((A=>!A.excludeFromExport)):t).map((A=>({...A,_renderingConfiguration:e}))));try{return M(c).renderToStaticMarkup((0,r.jsx)(S,{preserveAspectRatio:"none",...n,...i,elements:a.map((A=>Ct(A))).filter((A=>!!A)),omitBoundClipping:e?.omitClipMask,colorProfiles:e?.colorProfiles?e.colorProfiles:void 0}))}catch(A){return console.error("Error rendering to static markup"),console.error(A),""}};function Dt(A){return A.sort(((A,t)=>(A.layer||0)-(t.layer||0)||(A.layerIndex||0)-(t.layerIndex||0)))}class It extends Error{constructor(A){super("No element found with ID: "+A),Object.setPrototypeOf(this,It.prototype)}}const pt=(A,t)=>ft(A,t).elements.find((t=>t.id===A)),ft=(A,t)=>{const e=Object.values(t).find((t=>t.elements.some((t=>t.id===A))));if(!e)throw new It(A);return e},mt=(A,t)=>{const e=Dt([...t.elements.filter((t=>t.id!==A.id)),A]);return{layout:t.layout,elements:e,modificationID:x()}},Mt=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],o=t?.layouts[i],s=(a||o).elements.filter((A=>"illustration"===A.type));for(let A=0;A<s.length;++A){const t=s[A];if(t.src&&!t.svg){const A=await NA(t.src),e=await Et(A);t.svg=wt(e.svg,t.width,t.height,t.colors)}}}};class Ft{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(A){this.oldState=A}}class yt extends Ft{constructor(A){super(),this.serializableWorkflow=A}apply(A){return this.oldState=A,{...A,serializableWorkflow:this.serializableWorkflow}}}class Yt extends Ft{constructor(A,t,e){super(),this.id=A,this.x=t,this.y=e}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,x:this.x,y:this.y},n=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class xt extends Ft{constructor(A,t){super(),this.id=A,this.angle=t}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,rotation:this.angle},n=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Nt extends Ft{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=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(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=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Ht extends Ft{constructor(A){super(),this.commands=A}apply(A){return this.oldState=A,this.commands.reduce(((A,t)=>t.apply(A)),A)}}class St extends Ft{constructor(A){super(),this.layout=A}apply(A){return this.oldState=A,{...A,layouts:{...A.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:x()}}}}}class Rt extends Ft{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:x()}})),e={};return t.forEach((A=>{e[A.layout.id]=A})),{...A,layouts:e}}}class vt extends Ft{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(e)),{...A,layouts:{...A.layouts,[this.layout.id]:{...A.layouts[this.layout.id],elements:e,modificationID:x()}}}}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(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:x()}}}}assignIndex(A){if(0===A.length)return;const t=A[A.length-1]?.layerIndex;return void 0!==t?t+1:this.assignIndex(A.slice(0,A.length-1))}}class Ut extends Ft{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=>{const t=A.cachedObjectURL;return A.id===this.id&&t&&URL.revokeObjectURL(t),A.id!==this.id})),modificationID:x()})));t||console.log(`Failed to delete element ${this.id}`);const n={};return e.forEach((A=>{n[A.layout.id]=A})),{...A,layouts:n}}}class Gt extends Ft{constructor(t,e){super(),this.el=M(A)(t),this.layout=e,this.el.id=x(),this.el.x+=5,this.el.y+=5}apply(A){return this.oldState=A,new vt(this.el,this.layout).apply(A)}}class Pt extends Ft{constructor(A,t,e){super(),this.id=A,this.color=t,this.textFillSpotColor=e}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor},n=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class kt extends Ft{constructor(A,t){super(),this.id=A,this.size=t}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,fontSize:this.size},n=ft(t.id,Object.values(A.layouts)),i=e.algorithm&&e.algorithm!==P.Autosize?e.input||"":e.text||"",a=mt(At(e,i),n);return{...A,layouts:{...A.layouts,[n.layout.id]:a}}}}class Jt extends Ft{constructor(A,t){super(),this.id=A,this.algorithm=t}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,algorithm:this.algorithm},n=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class bt extends Ft{constructor(A,t){super(),this.id=A,this.fontData=t}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,fontData:this.fontData},n=ft(t.id,Object.values(A.layouts)),i=mt(At(e,e.text||""),n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Ot extends Ft{constructor(A,t){super(),this.id=A,this.align=t}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,align:this.align},n=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Lt extends Ft{constructor(A,t,e){super(),this.id=A,this.imageData=t,this.offsets=e}apply(A){this.oldState=A;const t=ft(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:x()};return{...A,layouts:{...A.layouts,[t.layout.id]:a}}}}class zt extends Ft{constructor(A,t){super(),this.id=A,this.text=t}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e=ft(t.id,Object.values(A.layouts)),n=mt(At(t,this.text),e);return{...A,layouts:{...A.layouts,[e.layout.id]:n}}}}class jt extends Ft{constructor(A,t,e){super(),this.id=A,this.className=t,this.fill=e}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(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=ft(t.id,Object.values(A.layouts)),o=mt(i,a);return{...A,layouts:{...A.layouts,[a.layout.id]:o}}}}class Tt extends Ft{constructor(A,t,e){super(),this.id=A,this.svgBody=t,this.objectURL=e}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,svg:this.svgBody,cachedObjectURL:this.objectURL},n=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Kt extends Ft{constructor(A,t,e,n){super(),this.id=A,this.scale=t,this.leftOffset=e,this.topOffset=n}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,patchX:this.leftOffset,patchY:this.topOffset,patchScale:this.scale},n=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Vt extends Ft{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!pt(this.id,Object.values(A.layouts)).id)throw new It(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:x()}}}}}class Xt extends Ft{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!pt(this.id,Object.values(A.layouts)).id)throw new It(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:x()}}}}}class Wt extends Ft{constructor(A,t){super(),this.id=A,this.value=t}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(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]:mt({...t,layer:this.value},e)}}}}var qt={};F(qt,"patternImageDataCache",(()=>ne)),F(qt,"frameDataCache",(()=>ie)),F(qt,"generateFrameSVG",(()=>ae)),F(qt,"generateDefaultRectangleFrameSvg",(()=>oe)),F(qt,"getVariant",(()=>se)),F(qt,"getFrameData",(()=>re)),F(qt,"calculateOffsets",(()=>ce)),F(qt,"getPatternImageData",(()=>ge)),F(qt,"GetSVGDimensions",(()=>Be)),F(qt,"svgStringDimensions",(()=>le));var Zt={};F(Zt,"getExifOrientation",(()=>_t)),F(Zt,"canvasDims",(()=>Ae)),F(Zt,"getAttributesFromArrayBuffer",(()=>te));let $t=null;const _t=A=>new Promise((t=>{const e=PA(A);(0,n.fromBuffer)(A).then((A=>{const n=A?.mime;if("image/jpeg"!==n)return t(1);(new(0,B.ExifImage)).loadImage(e,((A,e)=>t(A?1:e.image.Orientation||1)))}))})),Ae=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]},te=async A=>{const t=await(async A=>{const t=await UA(A),e=await(0,g.loadImage)(t),[n,i]=Ae(e),a=await(async()=>{if(null!==$t)return!$t;const A=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return $t=2===A.width&&3===A.height,!$t})();if(!a){const A=(0,g.createCanvas)(n,i);return A.getContext("2d").drawImage(e,0,0,n,i),A}const o=await _t(A),[s,r]=o>4?[i,n]:[n,i],c=(0,g.createCanvas)(s,r),B=c.getContext("2d");switch(o){case 2:B.translate(s,0),B.scale(-1,1);break;case 3:B.translate(s,r),B.rotate(Math.PI);break;case 4:B.translate(0,r),B.scale(1,-1);break;case 5:B.rotate(-.5*Math.PI),B.scale(-1,1);break;case 6:B.rotate(-.5*Math.PI),B.translate(-s,0);break;case 7:B.rotate(-.5*Math.PI),B.translate(-s,r),B.scale(1,-1);break;case 8:B.rotate(.5*Math.PI),B.translate(0,-r)}return B.drawImage(e,0,0,s,r),c})(A);return"image/jpeg"===(await(0,n.fromBuffer)(A))?.mime?{dataUrl:t.toDataURL("image/jpeg",1),height:t.height,width:t.width}:{dataUrl:t.toDataURL(),height:t.height,width:t.width}};F({},"getDefaultVariant",(()=>ee));const ee=A=>{const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0},ne=new Map,ie=new Map,ae=async(A,t)=>{if(!t){if(!A)throw new Error("No region or src supplied. Cannot construct frame!");return oe(A)}return NA(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 `},se=(A,t)=>{if(!t)return;const e=t.data.variants.find((t=>t.id===A.frameVariantId))||ee(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},re=async A=>{const t=YA().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,o=parseFloat(i[2])||1,s=t.getElementById("target-path"),r=t.getElementsByClassName("st0").item(0);if(s){const A=s.getAttribute("d");if(!A)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const t={path:A,width:o,height:a};return ie.set(A,t),t}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:o,height:a};return ie.set(A,t),t}throw new Error("Malformed frame SVG")},ce=(A,t,e)=>{const n=t.width>=t.height,i=A.width>=A.height,a=t.width/2,o=t.height/2,s=(n?t.height:t.width)/(i?A.height:A.width),r=e?.scale||s,c=a-A.width/2*r,g=e?.left||c,B=o-A.height/2*r;return{x:g,y:e?.top||B,zoom:r}},ge=async A=>{if(ne.has(A))return ne.get(A);if(A.endsWith("svg")){const t=await Be(A),e=t.width,n=t.height,i={src:A,width:e,height:n,aspect:e/n};return ne.set(A,i),i}{const t=await xA(A),e=await te(t),n={src:A,width:e.width,height:e.height,aspect:e.width/e.height};return ne.set(A,n),n}},Be=async A=>{const t=await fetch(A),e=await t.text();return le(e)},le=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 we={};F(we,"determineCorrectFontSizeAndLines",(()=>he)),F(we,"determineCorrectTextboxRegion",(()=>de));const Ee=(A,t,e,n,i)=>{let a=t.split("\n"),o=a.length,s=a.map((A=>XA(A,n,i)));const r=i.getApproximateHeight()*n;let c=!0;for(;c;){if(r+(o-1)*e>A.height)return[null,null];const t=Math.max(...s);if(t<=A.width)return[a,t];const g=s.reduce(((A,t,e,n)=>t>n[A]?e:A),0),B=a[g];let l=!1,w=B.length;for(;!l&&w>-1;){w=B.lastIndexOf(" ",w-1);const t=[B.slice(0,w),B.slice(w+1)],e=t.map((A=>XA(A,n,i)));e[0]<=A.width&&(a=[...a.slice(0,g),...t,...a.slice(g+1)],s=[...s.slice(0,g),...e,...s.slice(g+1)],o+=1,l=!0)}l||(c=!1)}return[null,null]},he=(A,t,e,n,i)=>{let a,o;const s=jA(t),r=s.getFont();if(i.size){const t=A/r.unitsPerEm;return[a,o]=Ee(e,n,A,t,s),[i.size,a,o]}let c=6-VA;if(""!==n){let A=[n],t=0;for(;(!i.maxSize||c<=i.maxSize)&&A;)c+=VA,t=c/r.unitsPerEm,[A,o]=Ee(e,n,c,t,s)}c>6&&(c-=VA),i.minSize&&c<i.minSize&&(c=i.minSize);const g=c/r.unitsPerEm;return[a,o]=Ee(e,n,c,g,s),[c,a,o]},de=(A,t,e,n,i)=>{let a={...A},o={...A};const s=n.join(" ");let[r,c,g]=he(e,t,o,s,{size:0,minSize:e,maxSize:e});var B,l;return g&&g<a.width&&(o.width=g,"left"===i?(o.left+=Math.sin(a.rotation*Math.PI/360)*(a.width-g),o.top+=Math.sin(a.rotation*Math.PI/180)*(g-a.width)/2):o.left+="right"===i?a.width-g:(a.width-g)/2,[r,c]=he(e,t,o,s,{size:e}),r===e&&c&&(B=n,l=c,B.map(((A,t)=>[A,l[t]]))).every((([A,t])=>A===t))&&(a=o)),a};F({},"LayoutElementFactory",(()=>Qe));class Qe{static async getFrame(A){const t=await ae(A.region,A.src),e=await re(t);return{id:x(),x:A.region.left,y:A.region.top,width:A.region.width,height:A.region.height,layer:A.region.layer||0,layerIndex:A.region.layerIndex,rotation:A.region.rotation,scaleX:A.region.width/e.width,scaleY:A.region.height/e.height,path:e.path,type:U.Frame,disablePlaceholder:A.configuration.disablePlaceholder,focalBlur:A.configuration.focalBlur,focalBlurStrength:A.configuration.focalBlurStrength,focalBlurRadius:A.configuration.focalBlurRadius,pattern:void 0,immutable:A.region.immutable}}static async getImage(A){let t;if(A.layout){const e=Ce(A.layout),n=e.height,i=await fetch(A.src),a=await i.arrayBuffer(),o=await te(a),s=o.width/o.height;e.height=e.width/s,e.top+=(n-e.height)/2,t=e}else t=A.region;return t||(t={left:0,top:0,width:100,height:100,layer:0,layerIndex:1,rotation:0,panelId:"",immutable:!1}),{id:x(),src:A.src,type:U.Image,y:t.top,x:t.left,rotation:t.rotation,width:t.width,height:t.height,layer:t.layer||0,layerIndex:t.layerIndex,immutable:t.immutable,preserveAspectRatio:"none"}}static async getTextbox(A){const{region:t,configuration:e,fontSrc:n,designInputStep:i}=A,a={assetUrl:n,name:(await LA(n)).names.fullName.en},o=i?.text||e.defaultText||"",s=e.replaceableText?e.replaceableText.replace("{{}}",o):o,r=qA(s,{vertical:e.vertical,uppercase:e.uppercase});return At({id:x(),type:U.Textbox,x:t.left,y:t.top,width:t.width,height:t.height,align:$A(e.textAlign,e.vertical),curved:e.curved,fill:i?.color||e.colour||"#000000",fontData:a,layer:t.layer||0,layerIndex:t.layerIndex,paths:e.paths,rotation:t.rotation,vertical:e.vertical,verticalAlign:e.verticalAlign||"middle",algorithm:P.Traditional,fontSize:e.size||18,text:r,input:o},r)}static async getShape(A){const t=`\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="${A.color}"\n />\n </svg>\n `,e={};e["spiff-fill-shape"]={browserValue:A.color};const n=x();return{stepRegion:A.region,colors:e,id:n,svg:t,type:"illustration",y:A.region.top,x:A.region.left,rotation:A.region.rotation,width:A.region.width,height:A.region.height,layer:A.region.layer||0,layerIndex:A.region.layerIndex,immutable:A.region.immutable}}}const Ce=A=>{const t=(A.layoutState.layout.width<A.layoutState.layout.height?A.layoutState.layout.width:A.layoutState.layout.height)/2;return{top:A.layoutState.layout.height/2-t/2,left:A.layoutState.layout.width/2-t/2,width:t,height:t,rotation:0,panelId:A.layoutState.layout.panelId}};function ue(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const De=new class{constructor(){ue(this,"defaultServerUrl","https://api.spiff.com.au"),ue(this,"defaultServicesApiUrl","https://services.spiff.com.au"),ue(this,"defaultHubUrl","https://hub.spiff.com.au"),ue(this,"serverUrl",void 0),ue(this,"servicesApiUrl",void 0),ue(this,"hubUrl",void 0),ue(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 Ie(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let pe;const fe=A=>{pe=A},me=async()=>{const A={transactionOwnerId:pe};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=De.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 Me=new class{constructor(){Ie(this,"client",void 0),Ie(this,"uncachedOperations",[]),De.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 me();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 me(),t=De.getServerUrl()+"/v2/api-docs";return await M(l)(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const Fe=new class{constructor(){Ie(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),De.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=(0,w.createHttpLink)({uri:`${De.getServerUrl()}/graphql`,fetch:d.fetch}),t=(0,E.setContext)((async(A,{headers:t})=>{const e=t||{},n=await me();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,h.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,w.InMemoryCache)({typePolicies:{Transaction:{fields:{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}}}}});return new(0,w.ApolloClient)({link:(0,w.from)([e,t,A]),cache:n,name:"Core"})}};function ye(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const Ye=new class{constructor(){ye(this,"server",void 0),ye(this,"cache",new Map),ye(this,"materialCache",new Map),ye(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await te(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)}})),this.server=Me}async getLocalOrFromServer(A){if(this.cache.has(A))return this.cache.get(A);const t=(async()=>(await Me.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 Me.execute("getMaterialV2",{id:A})).body)();return this.materialCache.set(A,t),t}async uploadAssetWithProgress(A,t,e,n,i,a){const o=await this.dispatchCreateAssetRequest(A,t,i,a);var s=new XMLHttpRequest;return s.open("PUT",o.assetResponse.uploadUrl,!0),s.setRequestHeader("Content-Type",o.mimeType),s.setRequestHeader("Cache-Control","public,max-age=31536000,immutable"),s.upload.onprogress=A=>{A.lengthComputable&&e(100*A.loaded/A.total)},s.onload=()=>{const A=o.assetResponse.asset;n(A)},s.onerror=()=>{console.warn("Asset upload failed")},s.send(A.blob),o.assetResponse.asset}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 Error("Unexpected mimetype: "+t)}}};function xe(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const Ne=new class{constructor(){xe(this,"cache",new Map),xe(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),xe(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),xe(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[]))}async cacheRequiredOptions(A){const t=A.steps.map((A=>A.optionId)).filter((A=>void 0!==A)),e=A.steps.map((A=>A.data.colourOptionId)).filter((A=>void 0!==A)),n=[...new Set([...t,...e])].map((async A=>{const t=await Ne.getLocalOrFromServer(Me,A);"Font"===t.data.type&&t.data.variants.forEach((async A=>{if(A.assetKey){const t=(await Ye.getLocalOrFromServer(A.assetKey)).links.find((A=>"cdn"===A.rel))?.href;t&&await LA(t)}}))}));await Promise.allSettled([...n])}async getLocalOrFromServer(A,t){if(this.cache.has(t))return this.cache.get(t);const e=(await A.execute("getOptionV2",{id:t})).body;return this.cache.set(t,e),e}getLocalOrUndefined(A){if(A)return this.cache.get(A)}async getAssetTileImageForVariant(A){if(A.thumbnailKey){const t=await Ye.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 Ye.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}},He=(0,Q.createContext)(new Qt),Se=()=>{const A=(0,Q.useContext)(He);(0,Q.useEffect)((()=>{A.registerStateCallback((()=>{e(new Date)}))}),[A]);const[t,e]=(0,Q.useState)(new Date);return{commandDispatcher:t=>{A.apply(t)},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)}}};let Re;var ve;(ve=Re||(Re={})).None="None",ve.FrameAdjustment="FrameAdjustment",ve.FinalizeDesign="FinalizeDesign";const Ue=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,maxZoom:5,units:J.Pixel,subMenu:Re.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),Ge=(A,t)=>M(C)(A,t.apply(A))?A:t.apply(A),Pe=(0,Q.createContext)({}),ke=A=>{const{getAllLayouts:t}=Se(),[e,n]=(0,Q.useReducer)(Ge,Ue(t,A.defaultZoom||1)),i=(0,Q.useMemo)((()=>({state:e,uiDispatcher:n})),[e,n]);return(0,r.jsx)(Pe.Provider,{value:i,children:A.children})};class Je{constructor(A){var t,e,n;n=void 0,(e="changes")in(t=this)?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,this.changes=A}apply(A){return{...A,...this.changes}}}const be=()=>(0,Q.useContext)(Pe);let Oe;var Le;(Le=Oe||(Oe={}))[Le.Orbit=0]="Orbit",Le[Le.Pan=1]="Pan";const ze=(A,t,e,n)=>{const i=t.layout.width,a=t.layout.height,o=t.elements.filter((t=>t.id!==A.id&&!t.immutable&&!t.productOverlay)),s=o.map((A=>Z(A.x,A.y,A.width,A.height,A.rotation))),c=[],g=new Set;s.forEach((A=>g.add(A.minX))),s.forEach((A=>g.add(A.maxX))),[0,i/2,i].forEach((A=>g.add(A)));const B=new Set;s.forEach((A=>B.add(A.minY))),s.forEach((A=>B.add(A.maxY))),[0,a/2,a].forEach((A=>B.add(A)));const l=o.map((A=>A.y));for(let A=-315;A<=315;A+=45)l.push(A);const w=Z(A.x,A.y,A.width,A.height,A.rotation),E=[{value:w.minX,anchor:-1},{value:w.minX+(w.maxX-w.minX)/2,anchor:0},{value:w.minX+(w.maxX-w.minX),anchor:1}],h=[{value:w.minY,anchor:-1},{value:w.minY+(w.maxY-w.minY)/2,anchor:0},{value:w.minY+(w.maxY-w.minY),anchor:1}],d=[{value:A.rotation,anchor:0}],Q=(A,t,n,o)=>{const s=[];return t.forEach((t=>{const c=n.find((A=>tA(t,A.value,2*e))),[g,B]=((A,t)=>[{x:"x"===A?t:0,y:"x"===A?0:t},{x:"x"===A?t:i,y:"x"===A?a:t}])(A,t),l="rotation"===A?null:(0,r.jsx)("line",{x1:g.x,y1:g.y,x2:B.x,y2:B.y,stroke:o||"#D61B5C",strokeDasharray:5*e,strokeWidth:1.2*e,overflow:"overlay"},`${A}-${t}-${g.x}-${g.y}-${B.x}-${B.y}`);void 0!==c&&s.push({type:A,value:t,anchorPoint:c.anchor,svgNode:l,guidelineCoordinates:[g,B]})})),s};return c.push(...Q("x",Array.from(g),E,n)),c.push(...Q("y",Array.from(B),h,n)),c.push(...Q("rotation",l,d,n)),c};let je;var Te;let Ke;var Ve;(Te=je||(je={})).Translate="Translate",Te.Rotate="Rotate",Te.Resize="Resize",(Ve=Ke||(Ke={})).ControlLeft="ControlLeft",Ve.ControlRight="ControlRight",Ve.Equal="Equal",Ve.MetaLeft="MetaLeft",Ve.MetaRight="MetaRight",Ve.Minus="Minus",Ve.ArrowLeft="ArrowLeft",Ve.ArrowRight="ArrowRight",Ve.ArrowUp="ArrowUp",Ve.ArrowDown="ArrowDown",Ve.AltLeft="AltLeft",Ve.AltRight="AltRight",Ve.Delete="Delete",Ve.Backspace="Backspace";const Xe=(A,t,e,n)=>{const i=()=>{switch(e){case J.Pixel:return 1;case J.Millimeter:return lA;case J.Centimeter:return wA;default:throw new Error("Unknown unit of measurement")}};let a=t.x,o=t.y,s=t.x,r=t.y;switch(A){case Ke.ArrowLeft:s=t.x-1/i();break;case Ke.ArrowUp:r=t.y-1/i();break;case Ke.ArrowRight:s=t.x+1/i();break;case Ke.ArrowDown:r=t.y+1/i();break;default:throw new Error("Unhandled element interaction!")}const c=Z(s,r,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=s,o=r),new Yt(t.id,a,o)};var We=0,qe=0,Ze=0;const $e=(A,t,e,n,i,a,o)=>{const s=((A,t,e,n,i,a,o)=>{const s=n.width/t.width,r=n.height/t.height,c=A.movementX/s,g=A.movementY/r,B=e.rotation*Math.PI/180,l=Math.sin(B),w=Math.cos(B);let E;switch(i.type){case je.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*l+g*w,n=e.y+A,i=e.height-A,a=gA({...e}).center,o=gA({...e,y:n,height:i}).center,s=BA(o,a,B),r=s.x-e.width/2,E=s.y-i/2;h={...t,left:r,top:E,height:i}}break;case O.East:{const A=c*w+g*l,n=e.width+A;let i=e.height;if(e.type===U.Textbox){const A=e;i=KA(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const a=gA({...e}).center,o=gA({...e,width:n,height:i}).center,s=BA(o,a,B),r=s.x-n/2,E=s.y-i/2;h={...t,left:r,top:E,width:n,height:i}}break;case O.West:{const A=c*w+g*l,n=e.x+A,i=e.width-A;let a=e.height;if(e.type===U.Textbox){const A=e;a=KA(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const o=gA({...e}).center,s=gA({...e,width:i,height:a,x:n}).center,r=BA(s,o,B),E=r.x-i/2,d=r.y-a/2;h={...t,left:E,top:d,width:i,height:a}}break;case O.South:{const A=-c*l+g*w,n=e.height+A,i=gA({...e}).center,a=gA({...e,height:n}).center,o=BA(a,i,B),s=o.x-e.width/2,r=o.y-n/2;h={...t,left:s,top:r,height:n}}break;case O.Northeast:{const A=c*w+g*l,n=e.width+A;let i=e.height+A,a=e.y-A,o=e.fontSize;if(e.type===U.Textbox){const t=e;o=t.fontSize+A/8,i=KA(o,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||tt;a=e.y-A*n/8}const s=gA({...e}).center,r=gA({...e,width:n,height:i,y:a}).center,E=BA(r,s,B),d=E.x-n/2,Q=E.y-i/2;h={...t,left:d,top:Q,width:n,height:i,fontSize:o}}break;case O.Northwest:{const A=-c*w+-g*l,n=e.x-A,i=e.width+A;let a=e.y-A,o=e.height+A,s=e.fontSize;if(e.type===U.Textbox){const t=e;s=t.fontSize+A/8,o=KA(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||tt;a=e.y-A*n/8}const r=gA({...e}).center,E=gA({...e,x:n,y:a,width:i,height:o}).center,d=BA(E,r,B),Q=d.x-i/2,C=d.y-o/2;h={...t,left:Q,top:C,width:i,height:o,fontSize:s}}break;case O.Southeast:{const A=c*w+g*l,n=e.width+A;let i=e.height+A,a=e.fontSize;if(e.type===U.Textbox){const t=e;a=t.fontSize+A/8,i=KA(a,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const o=gA({...e}).center,s=gA({...e,width:n,height:i}).center,r=BA(s,o,B),E=r.x-n/2,d=r.y-i/2;h={...t,left:E,top:d,width:n,height:i,fontSize:a}}break;case O.Southwest:{const A=-c*w+-g*l,n=e.width+A;let i=e.x-A,a=e.height+A,o=e.fontSize;if(e.type===U.Textbox){const t=e;o=t.fontSize+A/8,a=KA(o,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const s=gA({...e}).center,r=gA({...e,width:n,height:a,x:i}).center,E=BA(r,s,B),d=E.x-n/2,Q=E.y-a/2;h={...t,left:d,top:Q,width:n,height:a,fontSize:o}}}return E=Z(h.left,h.top,h.width,h.height,h.rotation),(!o||E.minX>=o.left&&E.maxX<=o.left+o.width&&E.minY>=o.top&&E.maxY<=o.top+o.height)&&(t=h),t;case je.Rotate:const d={x:A.clientX,y:A.clientY};let Q,C=e.rotation;const u=gA(e,n,{x:s,y:r}),D=$(d,u.c,u.d),I=$(d,u.d,u.c);if(0===a.filter((A=>"rotation"===A.type)).length)Ze=0,Q=(e.rotation+D-I)%360;else{Ze+=Math.sqrt(c**2+g**2);const A=Math.abs(Ze)>7*window.devicePixelRatio/s;Q=A?(e.rotation+D-I)%360:a.find((A=>"rotation"===A.type))?.value||0,A&&(Ze=0)}return E=Z(e.x,e.y,e.width,e.height,Q),(!o||E.minX>=o.left&&E.maxX<=o.left+o.width&&E.minY>=o.top&&E.maxY<=o.top+o.height)&&(C=Q),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:C};case je.Translate:let p,f,m=e.x,M=e.y;if(0===a.filter((A=>"rotation"!==A.type)).length)We=0,qe=0,p=e.x+c,f=e.y+g;else{const A=a.find((A=>"x"===A.type)),t=a.find((A=>"y"===A.type));A||(We=0),t||(qe=0);const n=Math.abs(We)>7*window.devicePixelRatio/s,i=Math.abs(qe)>7*window.devicePixelRatio/r;p=A?n?e.x+We:e.x:e.x+c,f=t?i?e.y+qe:e.y:e.y+g,We=n?0:We+c,qe=i?0:qe+g}return E=Z(p,f,e.width,e.height,e.rotation),(!o||E.minX>=o.left&&E.maxX<=o.left+o.width&&E.minY>=o.top&&E.maxY<=o.top+o.height)&&(m=p,M=f),{top:M,left:m,width:e.width,height:e.height,rotation:e.rotation}}})(A,t,e,n,i,a,o),r=[];if(e.type===U.Textbox){const A=e;r.push(new zt(A.id,A.text||A.input||""))}if(r.push(new Yt(e.id,s.left,s.top),new Nt(e.id,s.width,s.height),new xt(e.id,s.rotation)),e.type===U.Textbox){const A=e;s.fontSize&&A.fontSize!==s.fontSize&&r.push(new kt(A.id,s.fontSize))}return r},_e=.5,An=(A,t,e,n,i,a,o)=>{const{state:s,uiDispatcher:r}=(0,Q.useContext)(Pe),{getLayoutById:c,getReducerState:g,flattenSequence:B}=Se(),[l,w]=(0,Q.useState)(void 0),[E,h]=(0,Q.useState)(void 0),d=c(s.layoutId);(0,Q.useEffect)((()=>{if("adjustment"===i&&A?.current&&n){if(n<_e)return void r(new Je({zoom:_e}));if(n>s.maxZoom)return void r(new Je({zoom:s.maxZoom}));r(new Je({zoom:n}))}}),[n,r,A,i,s.maxZoom]);const C=(0,Q.useCallback)(((A,n)=>{r(new Je({zoom:n}));const a=t?.current?.scrollWidth-t?.current?.clientWidth!=0,o=t?.current?.scrollHeight-t?.current?.clientHeight!=0;t.current&&e.current&&!s.scrolledMovement&&"advanced"===i&&(o&&(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))}),[r,t,e,s.scrolledMovement,i]);(0,Q.useEffect)((()=>{s.zoom<=1&&r(new Je({scrolledMovement:!1}))}),[r,s.zoom]);const u=t?.current?.getBoundingClientRect(),D=((u?.width||1)+(u?.height||1))/2,I=(d.layoutState.layout.width+d.layoutState.layout.height)/2/D/s.zoom,p=(0,Q.useMemo)((()=>{const A=s.activeModifierKeys,t=s.elementEvent,e=A.includes(Ke.ControlLeft)||A.includes(Ke.MetaLeft)||A.includes(Ke.ControlRight)||A.includes(Ke.MetaRight);if(!s.selectedElement||!t||e)return[];const n=t&&t.type===je.Translate,i=t&&t.type===je.Rotate,a=d.layoutState.elements.find((A=>A.id===s.selectedElement));return(n||i)&&a?ze(a,d.layoutState,I,o):[]}),[s.selectedElement,s.elementEvent,s.activeModifierKeys,d.layoutState,I]),f=(0,Q.useCallback)((()=>{const A=x();w(A),h(g().transaction)}),[g]),m=(0,Q.useCallback)((()=>{r(new Je({selectedElement:void 0}))}),[r]),M=(0,Q.useCallback)((()=>{r(new Je({scrolledMovement:!0}))}),[r]),F=(0,Q.useCallback)(((e,n)=>{const i=d.layoutState.elements.find((A=>A.id===s.selectedElement));if(!(s.elementEvent&&A.current&&t.current&&s.selectedElement&&i))return;t.current.hasPointerCapture(e.pointerId)||t.current.setPointerCapture(e.pointerId);const o=A.current.getBoundingClientRect(),r=new Ht($e(e,d.layoutState.layout,i,o,s.elementEvent,p,n));r.sequenceId=l,a(r)}),[d.layoutState.elements,d.layoutState.layout,s.elementEvent,A,s.selectedElement,t,p,a]),y=(0,Q.useCallback)((A=>{r(new Je({elementEvent:A}))}),[r]),Y=(0,Q.useCallback)((()=>{r(new Je({elementEvent:void 0})),l&&E&&(B(l,E),w(void 0),h(void 0))}),[r,l,E,B]),N=(0,Q.useCallback)(((A,t)=>{let e=s.zoom;const n=s.maxZoom,o=s.selectedElement,c=s.activeModifierKeys;if((c.includes(Ke.AltLeft)||c.includes(Ke.AltRight))&&(A.code===Ke.Equal||A.code===Ke.Minus)){const t=.05*n;A.code===Ke.Equal?r(new Je({zoom:e+t<=n?e+=t:e})):r(new Je({zoom:e-t>=_e?e-t:e}))}const g=d.layoutState.elements.find((A=>A.id===o));if(o&&g){if(A.code===Ke.MetaLeft||A.code===Ke.ControlLeft||A.code===Ke.MetaRight||A.code===Ke.ControlRight){const t=A.code,e=s.activeModifierKeys;if(!e.includes(t))return r(new Je({activeModifierKeys:e.concat(t)}))}if(A.code===Ke.ArrowDown||A.code===Ke.ArrowUp||A.code===Ke.ArrowLeft||A.code===Ke.ArrowRight){r(new Je({elementEvent:{type:je.Translate}}));const e=Xe(A.code,g,s.units,t);a(e),r(new Je({elementEvent:void 0}))}A.code!==Ke.Delete&&A.code!==Ke.Backspace||"advanced"!==i||(r(new Je({selectedElement:void 0})),a(new Ut(g.id)))}}),[a,r,d.layoutState.elements,i,s.activeModifierKeys,s.maxZoom,s.selectedElement,s.units,s.zoom]),H=(0,Q.useCallback)((A=>{if(A.code===Ke.MetaLeft||A.code===Ke.ControlLeft||A.code===Ke.MetaRight||A.code===Ke.ControlRight){const t=s.activeModifierKeys,e=A.code;r(new Je({activeModifierKeys:t.filter((A=>A!==e))}))}}),[r,s.activeModifierKeys]);return{guidelines:p,scale:I,zoomableElementRef:e,setElementEvent:y,handleZoom:C,handleKeyDown:N,handleKeyUp:H,handlePointerPressedBackground:m,handlePointerReleased:Y,handlePointerMove:F,handleScroll:M,handleSequenceStart:f}},tn=A=>{const{x:t,y:e,cursorStyle:n,onPointerDown:i,handleClass:a,cornerRadius:o,color:s,strokeWidth:c}=A;return(0,r.jsx)("circle",{className:a,cx:t,cy:e,r:o,fill:"#ffffff",style:{cursor:n},stroke:s,strokeWidth:c,onPointerDown:i})},en=A=>{const{x:t,y:e,width:n,height:i,cursorStyle:a,onPointerDown:o,edgeHandleRadius:s,color:c,strokeWidth:g}=A;return(0,r.jsx)("rect",{x:t,y:e,width:n,height:i,rx:s,fill:"#ffffff",style:{cursor:a},stroke:c,strokeWidth:g,onPointerDown:o})},nn=A=>{const{color:t,elementHeight:e,elementWidth:n,onBeginResize:i,rotation:a,scaleFactor:o,disableX:s,disableY:c}=A,g=7.5*o,B=3*o,l=28*o,w=6*o,E=1.2*o,h=e-2*g,d=(0,Q.useCallback)(((A,t,e)=>{A.stopPropagation(),i(t,e)}),[i]),C=(0,Q.useCallback)((A=>d(A,cA(O.West,360-a),O.West)),[d,a]),u=(0,Q.useCallback)((A=>d(A,cA(O.East,360-a),O.East)),[d,a]),D=(0,Q.useCallback)((A=>d(A,cA(O.North,360-a),O.North)),[d,a]),I=(0,Q.useCallback)((A=>d(A,cA(O.South,360-a),O.South)),[d,a]),p=(0,Q.useCallback)((A=>d(A,O.Northwest,O.Northwest)),[d]),f=(0,Q.useCallback)((A=>d(A,O.Northeast,O.Northeast)),[d]),m=(0,Q.useCallback)((A=>d(A,O.Southwest,O.Southwest)),[d]),M=(0,Q.useCallback)((A=>d(A,O.Northeast,O.Southeast)),[d]),F=l<=h;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tn,{x:0,y:0,cursorStyle:"nwse-resize",onPointerDown:p,handleClass:"cornerNorthWest",cornerRadius:g,color:t,strokeWidth:E}),F?(0,r.jsx)(tn,{x:n,y:0,cursorStyle:"nesw-resize",onPointerDown:f,handleClass:"cornerNorthEast",cornerRadius:g,color:t,strokeWidth:E}):void 0,F?(0,r.jsx)(tn,{x:n,y:e,cursorStyle:"nwse-resize",onPointerDown:M,handleClass:"cornerSouthEast",cornerRadius:g,color:t,strokeWidth:E}):void 0,F?(0,r.jsx)(tn,{x:0,y:e,cursorStyle:"nesw-resize",onPointerDown:m,handleClass:"cornerSouthWest",cornerRadius:g,color:t,strokeWidth:E}):void 0,F&&!s?(0,r.jsx)(en,{x:-w/2,y:e/2-l/2,width:w,height:l,onPointerDown:C,edgeHandleRadius:B,cursorStyle:"ew-resize",color:t,strokeWidth:E}):void 0,F&&!c?(0,r.jsx)(en,{x:n/2-l/2,y:e-w/2,width:l,height:w,onPointerDown:I,edgeHandleRadius:B,cursorStyle:"ns-resize",color:t,strokeWidth:E}):void 0,s?void 0:(0,r.jsx)(en,{x:n-w/2,y:e/2-Math.min(l,.8*e)/2,width:w,height:Math.min(l,.8*e),onPointerDown:u,edgeHandleRadius:B,cursorStyle:"ew-resize",color:t,strokeWidth:E}),F&&!c?(0,r.jsx)(en,{x:n/2-l/2,y:-w/2,width:l,height:w,onPointerDown:D,edgeHandleRadius:B,cursorStyle:"ns-resize",color:t,strokeWidth:E}):void 0]})},an=A=>{const{color:t,elementWidth:e,onBeginRotate:n,scaleFactor:i}=A,a=(0,Q.useCallback)((A=>{A.stopPropagation(),n()}),[n]),o=10*i,s=1.2*i;return(0,r.jsxs)("g",{children:[(0,r.jsx)("circle",{cx:e/2,cy:-2.5*o,r:1.3*o,fill:"rgba(0, 0, 0, 0.5)",opacity:.4,style:{cursor:"ew-resize"},onPointerDown:a}),(0,r.jsx)("circle",{cx:e/2,cy:-2.5*o,r:o,fill:"#fff",style:{cursor:"ew-resize"},stroke:t,strokeWidth:s,onPointerDown:a}),(0,r.jsxs)("svg",{x:e/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,fill:t,onPointerDown:a,children:[(0,r.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z"})]})]})},on=A=>{const{color:t,height:e,highlighted:n,id:i,immutable:a,onBeginMove:o,onBeginResize:s,onBeginRotate:c,onPointerEnter:g,onPointerLeave:B,onSelected:l,pressed:w,rotation:E,scaleFactor:h,selected:d,width:C,x:u,y:D,disableX:I,disableY:p}=A,f=1.2*h,m=(0,Q.useCallback)((A=>{2===A.button&&(A.stopPropagation(),l(i,A)),0===A.button&&(A.stopPropagation(),!d&&l(i,A),o())}),[i,d,l,o]),M=(0,Q.useCallback)((()=>{g(i)}),[i,g]),F=(0,Q.useCallback)((()=>{B(i)}),[i,B]),y=a?void 0:d?w?"grabbing":"grab":"pointer",Y=a?"none":"visibleFill";return(0,r.jsxs)("g",{transform:`translate(${u}, ${D}) rotate(${E} ${C/2} ${e/2})`,children:[(0,r.jsx)("rect",{className:"interactableInnerRect",width:C,height:e,stroke:d||n?t:"none",pointerEvents:Y,fill:"none",strokeWidth:f,strokeDasharray:n&&!d?f:void 0,style:{cursor:y},onPointerDown:a?void 0:m,onPointerEnter:a?void 0:M,onPointerLeave:a?void 0:F}),d&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(an,{color:t,elementWidth:C,onBeginRotate:c,scaleFactor:h}),(0,r.jsx)(nn,{color:t,elementHeight:e,elementWidth:C,rotation:E,scaleFactor:h,onBeginResize:s,disableX:I,disableY:p})]})]})},sn=({primaryColor:A,containerHeight:t,containerWidth:e,customViewbox:n,editorRef:i,elementEvent:a,guidelines:o,layoutHeight:s,layoutWidth:c,targetedElements:g,scale:B,selectedElement:l,onElementEvent:w,onElementSelected:E,onSequenceStart:h})=>{const{state:d}=be(),{getLayoutById:C}=Se(),u=C(d.layoutId),[D,I]=(0,Q.useState)(void 0),p=(0,Q.useCallback)((A=>{I(A)}),[]),f=(0,Q.useCallback)((A=>{D===A&&I(void 0)}),[D]),m=(0,Q.useCallback)((()=>{h(),w({type:je.Translate})}),[w]),M=(0,Q.useCallback)(((A,t)=>{h(),w({type:je.Resize,relativeAxis:A,screenAxis:t})}),[w]),F=(0,Q.useCallback)((()=>{h(),w({type:je.Rotate})}),[w]),y=n||{x:0,y:0,width:c,height:s},Y=B*(Math.sqrt(y.width*y.height)/1e3)*(100/Math.sqrt(t*e))*Math.sqrt((x=e/t,Math.exp(Math.abs(Math.log(x)))));var x;const N=u.layoutState.elements.findIndex((({id:A})=>A===l)),H=[...u.layoutState.elements];return N>=0&&H.push(H.splice(N,1)[0]),(0,r.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%"},width:"100%",height:"100%",viewBox:`${y.x} ${y.y} ${y.width} ${y.height}`,overflow:"overlay",children:[(0,r.jsx)("rect",{fill:"none",stroke:"none",ref:i,width:c,height:s}),o.map((A=>A.svgNode)),H.map((t=>{const e=void 0!==l&&t.id===l,n=e&&void 0!==a,i=void 0!==D&&t.id===D;return(0,r.jsx)(on,{color:A,id:t.id,selected:e,highlighted:i,pressed:n,x:t.x,y:t.y,disableX:t.type===U.Frame,disableY:t.type===U.Textbox||t.type===U.Frame,width:t.width,height:t.height,rotation:t.rotation,immutable:t.immutable||g&&!g.includes(t.id),onSelected:E,onBeginMove:m,onBeginResize:M,onBeginRotate:F,onPointerEnter:p,onPointerLeave:f,scaleFactor:Y},t.id)}))]})},rn=A=>{const{color:t,editorRef:e,zoomableElementRef:n,interactionElementRef:i,guidelines:a,isMakingAdjustments:o,viewmask:s,visibleLayoutId:c,xTranslation:g,yTranslation:B,targetedElements:l,borderRadius:w,handleContextMenu:E,handleKeyDown:h,handleKeyUp:d,handlePointerMove:C,handlePointerPressedBackground:u,handlePointerReleased:D,handleScroll:I,onSequenceStart:p,setElementEvent:f,onElementSelected:m}=A,{getLayoutById:M}=Se(),F=M(c),y=F.layoutState,{state:Y}=be(),x=(0,Q.useCallback)((A=>{if(s){const t={left:s.x,top:s.y,width:s.width,height:s.height,panelId:"",rotation:0};return h(A,t)}return h(A)}),[h,s]),N=(0,Q.useCallback)((A=>{if(s){const t={left:s.x,top:s.y,width:s.width,height:s.height,panelId:"",rotation:0};return C(A,t)}return C(A)}),[C,s]);return(0,r.jsx)("div",{style:{justifyContent:"center",position:"relative",height:"100%",width:"100%",scrollbarWidth:"none",outline:"none"},onContextMenu:E,onKeyDown:x,onKeyUp:d,onPointerDown:u,onPointerMoveCapture:N,onPointerUp:D,onWheelCapture:I,ref:i,tabIndex:-1,children:(0,r.jsxs)("div",{ref:n,style:{height:"100%",transform:`scale(${Y.zoom}) translate(${g}px, ${B}px)`,display:"grid",filter:"drop-shadow(rgba(0, 0, 0, 0.2) 0px 0px 6px)"},children:[A.children,F.getComponentWithProps({height:o?"100%":"auto",maxHeight:"100%",maxWidth:"100%",position:"absolute",viewmask:s,width:o?"100%":"auto",borderRadius:w}),(0,r.jsx)(sn,{primaryColor:t,containerHeight:n.current?.offsetHeight||1024,containerWidth:n.current?.offsetWidth||1024,editorRef:e,elementEvent:Y.elementEvent,guidelines:a,layoutHeight:y.layout.height,layoutWidth:y.layout.width,onElementEvent:f,onSequenceStart:p,onElementSelected:m,scale:10/Y.zoom,selectedElement:Y.selectedElement,targetedElements:l})]})})},cn=({color:A,borderRadius:t,guidelineColor:e,handleContextMenu:n,onElementSelected:i})=>{const{commandDispatcher:a,getLayoutById:o}=Se(),{state:s,uiDispatcher:c}=be(),g=(0,Q.useRef)(null),B=(0,Q.useRef)(null),l=(0,Q.useRef)(null),{guidelines:w,handleKeyDown:E,handleKeyUp:h,handlePointerMove:d,handlePointerPressedBackground:C,handlePointerReleased:u,handleScroll:D,handleSequenceStart:I,setElementEvent:p}=An(g,B,l,void 0,"advanced",a,e),f=(0,Q.useCallback)(((A,t)=>{const e=o(s.layoutId).layoutState.elements.find((t=>t.id===A));if(A&&e&&e.type===U.Textbox){const t=e.algorithm;(!t||t===P.Autosize)&&a(new Jt(A,P.Traditional))}i&&i(A,t),c(new Je({selectedElement:A}))}),[a,o,s.layoutId,c]);return(0,r.jsx)(rn,{color:A,editorRef:g,interactionElementRef:B,zoomableElementRef:l,guidelines:w,visibleLayoutId:s.layoutId,xTranslation:0,yTranslation:0,borderRadius:t,handleContextMenu:n,handleKeyDown:E,handleKeyUp:h,handlePointerMove:d,handlePointerPressedBackground:C,handlePointerReleased:u,handleScroll:D,onSequenceStart:I,setElementEvent:p,onElementSelected:f})};class gn{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 Bn{constructor(){var A,t,e;A=this,t="storage",e=new Map,t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e}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 ln=(()=>{try{return localStorage?new gn:new Bn}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new Bn}})(),wn=w.gql`
1
+ var A=require("lodash.clonedeep"),t=require("axios"),e=require("https"),n=require("file-type"),i=require("buffer"),a=require("util"),o=require("css"),s=require("opentype.js"),r=require("react/jsx-runtime"),c=require("react-dom/server"),g=require("canvas"),B=require("exif"),l=require("swagger-client"),w=require("@apollo/client"),E=require("@apollo/client/link/context"),h=require("@apollo/client/link/error"),d=require("cross-fetch"),Q=require("react"),C=require("lodash.isequal"),u=require("canvg"),D=require("lodash.debounce"),I=require("qrcode"),p=require("svg-path-bbox");function f(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}var m="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 F(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}f(module.exports,"Client",(()=>na)),f(module.exports,"CommandContext",(()=>Qt)),f(module.exports,"spiffCoreConfiguration",(()=>De)),f(module.exports,"PromiseQueue",(()=>Gn)),f(module.exports,"QueueablePromise",(()=>Un)),f(module.exports,"MockWorkflowManager",(()=>aa)),f(module.exports,"InformationMessageType",(()=>ui)),f(module.exports,"assetService",(()=>Ye)),f(module.exports,"optionService",(()=>Ne)),f(module.exports,"server",(()=>Me)),f(module.exports,"persistenceService",(()=>ln)),f(module.exports,"graphQlManager",(()=>Fe)),f(module.exports,"toast",(()=>mi)),f(module.exports,"FrameService",(()=>bn)),f(module.exports,"frameStepService",(()=>Vn)),f(module.exports,"modelStepService",(()=>Wn)),f(module.exports,"materialStepService",(()=>Xn)),f(module.exports,"patchworkStepService",(()=>_n)),f(module.exports,"shapeStepService",(()=>ti)),f(module.exports,"questionStepService",(()=>fn)),f(module.exports,"digitalContentStepService",(()=>Kn)),f(module.exports,"moduleStepService",(()=>qn)),f(module.exports,"pictureStepService",(()=>Ai)),f(module.exports,"textStepService",(()=>Yi)),f(module.exports,"illustrationStepService",(()=>pn)),f(module.exports,"svgObjectURL",(()=>In)),f(module.exports,"ProductCameraRig",(()=>Oe)),f(module.exports,"AssetType",(()=>T)),f(module.exports,"BringForwardCommand",(()=>Vt)),f(module.exports,"CanvasCommand",(()=>Ft)),f(module.exports,"CreateElementCommand",(()=>vt)),f(module.exports,"CreateLayoutCommand",(()=>St)),f(module.exports,"DeleteElementCommand",(()=>Ut)),f(module.exports,"FontAlignmentCommand",(()=>Ot)),f(module.exports,"FontColorCommand",(()=>Pt)),f(module.exports,"FontSizeCommand",(()=>kt)),f(module.exports,"FontSourceCommand",(()=>bt)),f(module.exports,"GroupCommand",(()=>Ht)),f(module.exports,"LayoutElementFactory",(()=>Qe)),f(module.exports,"LayoutElementType",(()=>U)),f(module.exports,"MoveCommand",(()=>Yt)),f(module.exports,"ResizeCommand",(()=>Nt)),f(module.exports,"RotateCommand",(()=>xt)),f(module.exports,"SendBackwardsCommand",(()=>Xt)),f(module.exports,"StepAspectType",(()=>W)),f(module.exports,"StepType",(()=>V)),f(module.exports,"TextChangeCommand",(()=>zt)),f(module.exports,"UnitOfMeasurement",(()=>J)),f(module.exports,"dataUrlFromExternalUrl",(()=>vA)),f(module.exports,"findElement",(()=>pt)),f(module.exports,"frameDataCache",(()=>ie)),f(module.exports,"generate",(()=>x)),f(module.exports,"generateSVGWithUnknownColors",(()=>Et)),f(module.exports,"getAttributesFromArrayBuffer",(()=>te)),f(module.exports,"rehydrateSerializedLayout",(()=>Mt)),f(module.exports,"getFrameData",(()=>re)),f(module.exports,"getSvgString",(()=>ut)),f(module.exports,"loadFontFromDataUrl",(()=>zA)),f(module.exports,"loadFontFromExternalUrl",(()=>LA)),f(module.exports,"determineCorrectFontSizeAndLines",(()=>he)),f(module.exports,"patternImageDataCache",(()=>ne)),f(module.exports,"generateCommands",(()=>Ki)),f(module.exports,"registerJSDOM",(()=>pA)),f(module.exports,"minZoom",(()=>_e)),f(module.exports,"AdvancedEditor",(()=>cn)),f(module.exports,"EditorCore",(()=>rn)),f(module.exports,"useLayouts",(()=>Se)),f(module.exports,"useEditorState",(()=>be)),f(module.exports,"useEditorInteraction",(()=>An)),f(module.exports,"commandReducer",(()=>Ge)),f(module.exports,"getDefaultState",(()=>Ue)),f(module.exports,"CommandContextContext",(()=>He)),f(module.exports,"AdvancedEditorStateProvider",(()=>ke)),f(module.exports,"AdvancedEditorContext",(()=>Pe)),f(module.exports,"UICommand",(()=>Je)),f(module.exports,"EditorSubMenu",(()=>Re)),f(module.exports,"ElementEventType",(()=>je)),f(module.exports,"KeyEvent",(()=>Ke)),f(module.exports,"gatherVaryingStepAspects",(()=>Fn));var y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==m?m:{},Y={};F(Y,"CanvasCommand",(()=>Ft)),F(Y,"UpdateWorkflowStateCommand",(()=>yt)),F(Y,"MoveCommand",(()=>Yt)),F(Y,"RotateCommand",(()=>xt)),F(Y,"ResizeCommand",(()=>Nt)),F(Y,"GroupCommand",(()=>Ht)),F(Y,"CreateLayoutCommand",(()=>St)),F(Y,"ClearLayoutCommand",(()=>Rt)),F(Y,"CreateElementCommand",(()=>vt)),F(Y,"DeleteElementCommand",(()=>Ut)),F(Y,"CloneElementCommand",(()=>Gt)),F(Y,"FontColorCommand",(()=>Pt)),F(Y,"FontSizeCommand",(()=>kt)),F(Y,"FontAlgorithmCommand",(()=>Jt)),F(Y,"FontSourceCommand",(()=>bt)),F(Y,"FontAlignmentCommand",(()=>Ot)),F(Y,"UpdateFramePattern",(()=>Lt)),F(Y,"TextChangeCommand",(()=>zt)),F(Y,"IllustrationColorCommand",(()=>jt)),F(Y,"IllustrationCacheCommand",(()=>Tt)),F(Y,"ShiftPatchworkCommand",(()=>Kt)),F(Y,"BringForwardCommand",(()=>Vt)),F(Y,"SendBackwardsCommand",(()=>Xt)),F(Y,"LayerCommand",(()=>Wt)),F({},"generate",(()=>x));const x=()=>{const A=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return A()+A()+"-"+A()+"-"+A()+"-"+A()+"-"+A()+A()+A()};var N={};F(N,"ElementNotFoundError",(()=>It)),F(N,"findElement",(()=>pt)),F(N,"findLayoutForElement",(()=>ft)),F(N,"updatedLayoutForElement",(()=>mt)),F(N,"rehydrateSerializedLayout",(()=>Mt));var H={};F(H,"CommandContext",(()=>Qt)),F(H,"sortElementsByLayersWithIndex",(()=>Dt)),F(H,"getSvgString",(()=>ut)),F({},"SVGLayout",(()=>S));const S=({viewmask:A,viewBox:t,width:e,height:n,position:i,maxWidth:a,maxHeight:o,elements:s,preserveAspectRatio:c,backgroundColor:g,omitBoundClipping:B,borderRadius:l,colorProfiles:w})=>{const E=x(),h=A?`url(#viewmask-${E})`:void 0,d=t||{x:0,y:0,width:e,height:n},Q=`${d.x} ${d.y} ${d.width} ${d.height}`,C=l||0,u=B?void 0:(0,r.jsxs)("defs",{children:[(0,r.jsx)("clipPath",{id:"viewboxClip",children:(0,r.jsx)("rect",{width:d.width,height:d.height,rx:C})}),A&&(0,r.jsxs)("mask",{id:`viewmask-${E}`,children:[(0,r.jsx)("rect",{x:d.x,y:d.y,width:d.width,height:d.height,fill:"black"}),(0,r.jsx)("rect",{x:A.x,y:A.y,width:A.width,height:A.height,fill:"white"})]})]}),D=w?.map(((A,t)=>(0,r.jsx)("color-profile",{name:A.name,xlinkHref:A.key,children:" "},t)));return(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",preserveAspectRatio:c,width:e,height:n,style:{gridColumn:1,gridRow:1,maxWidth:a,maxHeight:o,position:i},viewBox:Q,children:[D,u,!!g&&(0,r.jsx)("rect",{id:"layout-background",width:d.width,height:d.height,fill:g,mask:h,rx:C}),(0,r.jsx)("g",{id:"element-group",clipPath:B?void 0:"url(#viewboxClip)",mask:h,children:s})]})};F({},"Image",(()=>EA));var R={};F(R,"getAxisAlignedBoundingBox",(()=>Z)),F(R,"degreesToRadians",(()=>_)),F(R,"findAngle",(()=>$)),F(R,"radiansToDegrees",(()=>AA)),F(R,"isCloseToValue",(()=>tA)),F(R,"getTrueCoordinates",(()=>eA)),F(R,"getPointOfRotation",(()=>nA)),F(R,"getNWPoint",(()=>iA)),F(R,"getNEPoint",(()=>aA)),F(R,"getSWPoint",(()=>oA)),F(R,"getSEPoint",(()=>sA)),F(R,"turnRightClockwise",(()=>rA)),F(R,"currentDirection",(()=>cA)),F(R,"getElementVertices",(()=>gA)),F(R,"rotateAroundPoint",(()=>BA)),F(R,"mmPerPixel",(()=>lA)),F(R,"cmPerPixel",(()=>wA));var v={};let U;var G;let P;var k;let J;var b;let O;var L;let z;var j;let T;var K;let V;var X;let W;var q;F(v,"LayoutElementType",(()=>U)),F(v,"TextAlgorithm",(()=>P)),F(v,"UnitOfMeasurement",(()=>J)),F(v,"ScaleAxis",(()=>O)),F(v,"MaterialEffectMode",(()=>z)),F(v,"AssetType",(()=>T)),F(v,"StepType",(()=>V)),F(v,"StepAspectType",(()=>W)),(G=U||(U={})).Frame="frame",G.Image="image",G.Illustration="illustration",G.Textbox="textbox",G.Patchwork="patchwork",(k=P||(P={})).Autosize="Autosize",k.Traditional="Traditional",(b=J||(J={})).Pixel="px",b.Millimeter="mm",b.Centimeter="cm",(L=O||(O={}))[L.North=0]="North",L[L.Northeast=1]="Northeast",L[L.East=2]="East",L[L.Southeast=3]="Southeast",L[L.South=4]="South",L[L.Southwest=5]="Southwest",L[L.West=6]="West",L[L.Northwest=7]="Northwest",(j=z||(z={})).None="None",j.RemoveWhenSelected="RemoveWhenSelected",j.ApplyWhenSelected="ApplyWhenSelected",(K=T||(T={})).Font="Font",K.Frame="Frame",K.Illustration="Illustration",K.Image="Image",K.Model="Model",K.Material="Material",K.Patchwork="Patchwork",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.Patchwork="Patchwork",X.Picture="Picture",X.Photo="Photo",X.ProductOverlay="ProductOverlay",X.Question="Question",X.Shape="Shape",X.SilentIllustration="SilentIllustration",X.Text="Text",(q=W||(W={})).Color="Color",q.Colors="Colors",q.Selection="Selection",q.Selections="Selections",q.Text="Text",q.Upload="Upload";const Z=(A,t,e,n,i)=>{const a=_(i),o=e/2,s=n/2,r=A+o,c=t+s,g=Math.sin(a),B=Math.cos(a),l=-s,w=o*B-l*g,E=o*B-s*g,h=o*g+l*B,d=o*g+s*B,Q=Math.max(Math.abs(w),Math.abs(E)),C=Math.max(Math.abs(h),Math.abs(d));return{minX:r-Q,maxX:r+Q,minY:c-C,maxY:c+C}},$=(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)},_=A=>A*(Math.PI/180),AA=A=>A*(180/Math.PI),tA=(A,t,e)=>Math.abs(A-t)<e,eA=(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}},nA=(A,t)=>({x:(A.x+t.x)/2,y:(A.y+t.y)/2}),iA=(A,t,e,n)=>({x:A.x+t?.x*e,y:A.y+t?.y*n}),aA=(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}),sA=(A,t,e,n)=>({x:A.x+(t?.x+t?.width)*e,y:A.y+(t?.y+t?.height)*n}),rA=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}},cA=(A,t)=>t>45&&t<=135?rA(A):t>135&&t<=225?rA(rA(A)):t>225&&t<=315?rA(rA(rA(A))):A,gA=(A,t={x:0,y:0},e={x:1,y:1})=>{const n=_(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},o={x:t.x+(A.x+A.width)*e.x,y:t.y+(A.height+A.y)*e.y},s={x:t.x+A.x*e.x,y:t.y+(A.height+A.y)*e.y},r={x:(s.x+o.x)/2,y:s.y-A.height*e.y/2};return{a:BA(i,r,n),b:BA(a,r,n),c:BA(o,r,n),d:BA(s,r,n),center:r}},BA=(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}},lA=.352778,wA=.035277,EA=A=>{const t=A.rotation||0,e=_(t),n=Math.cos(e),i=-Math.sin(e);return(0,r.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(${n}, ${-i}, ${i}, ${n}, 0, 0)\n matrix(1, 0, 0, 1, ${-A.width/2}, ${-A.height/2})\n `,children:(0,r.jsx)("image",{xlinkHref:A.src,preserveAspectRatio:A.preserveAspectRatio,width:A.width,height:A.height})})};F({},"Frame",(()=>hA));const hA=A=>{const t=`spiff-frame-${A.id}`,e=`spiff-frame-blur-${A.id}`,n=`spiff-frame-blur-edge-${A.id}`,i=`spiff-frame-focal-mask-${A.id}`,a=!!A.focalBlur&&!!A.pattern,o=A.rotation||0,s=_(o),c=Math.cos(s),g=-Math.sin(s);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("defs",{children:(a=>{const o=A.pattern?.x||0,s=A.pattern?.y||0,c=A.pattern?A.pattern.width*A.pattern.scaleX+Math.abs(o):256,g=A.pattern?A.pattern.height*A.pattern.scaleY+Math.abs(s):256,B=A.pattern?A.pattern.width*A.pattern.scaleX:256,l=A.pattern?A.pattern.height*A.pattern.scaleY:256;return(0,r.jsxs)(r.Fragment,{children:[(0,r.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:t,children:(0,r.jsx)("image",{preserveAspectRatio:"none",x:o,y:s,width:B,height:l,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/Q5Y4kAAgBQE0rtDQaDuSdTLKCIAbvBQwnKaHQR5WtCAABqRDX9b4ZvZp5QBpz3FA9lDvb23kf5m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KFS4EXIQJ6DfsaUGecAQCeKNULsAgRYMgnQHxKNwPFFgH71NfMfwCon0rdgEYE3NNaIlBlZJeM3xaA1dXV2v/DAaCGdmCJwLtAKW/ZQR1XV6OZPw+c9CMA1EMt8wDSBnWcnh0Xug64S0Xk/jP9FyAOtQ0ECYnA7fj291afLNRfcOq0Am9v72Q+DgDKUftmINM+bDoIbVTmqxy/rg0ucvsvLi9mfqoGnzoWfgKAnyirwdJEIHl069fW1qb/Ls/g7u5uzkOgqw8gPtF2A+bd7+ejSAcgAJQnmgAYfK59iOma7923yfpgyFcKsACiC0Dy6OZLCMbjsfdaIMPf3NgMxgcAIA4LEQAbpfkkCA8/fyYrjzX/9PEDNMPzRb+qjH2NLxtgKVj4YhAAWB4QAIAegwAA9BgEAKDHIAAAPQYBAOgxCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAEBfSZLk/xjo1hVZWiK0AAAAAElFTkSuQmCC"})}),a?(0,r.jsx)(dA,{path:A.path,width:A.width,height:A.height,focalBlurStrength:A.focalBlurStrength||1,focalBlurRadius:A.focalBlurRadius||10,blurFilterId:e,focalMaskId:i,blurEdgeClipId:n}):null]})})(a)}),(0,r.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,r.jsx)("path",{filter:a?`url(#${e})`:void 0,mask:a?`url(#${n})`:void 0,d:A.path,style:{fill:`url(#${t})`,opacity:A.opacity}}),a?(0,r.jsx)("path",{mask:`url(#${i})`,d:A.path,style:{fill:`url(#${t})`,opacity:A.opacity}}):void 0]})]})},dA=A=>{const{path:t,width:e,height:n,focalBlurStrength:i,focalBlurRadius:a,blurFilterId:o,focalMaskId:s,blurEdgeClipId:c}=A;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("filter",{id:o,children:(0,r.jsx)("feGaussianBlur",{stdDeviation:i||0})}),(0,r.jsx)("mask",{id:s,children:(0,r.jsx)("circle",{cx:e/2,cy:n/2,r:a||0,fill:"white",filter:`url(#${o})`})}),(0,r.jsx)("mask",{id:c,children:(0,r.jsx)("path",{d:t,style:{fill:"white",opacity:1}})})]})};F({},"Textbox",(()=>ot));var QA={};F(QA,"fontSizeStep",(()=>VA)),F(QA,"textWidth",(()=>XA)),F(QA,"applyTextTransformations",(()=>qA)),F(QA,"zip",(()=>ZA)),F(QA,"getTextAlignment",(()=>$A)),F(QA,"getAnchor",(()=>_A)),F(QA,"recomputeTextOnElement",(()=>At)),F(QA,"defaultLineHeightFactor",(()=>tt)),F({},"calculateTextboxLines",(()=>KA));var CA={};F(CA,"FontMetrics",(()=>OA)),F(CA,"loadFontFromExternalUrl",(()=>LA)),F(CA,"loadFontFromDataUrl",(()=>zA)),F(CA,"getFontMetrics",(()=>jA));var uA={};F(uA,"registerJSDOM",(()=>pA)),F(uA,"createElement",(()=>FA)),F(uA,"createElementNS",(()=>yA)),F(uA,"domParser",(()=>YA)),F(uA,"fetchAsArrayBuffer",(()=>xA)),F(uA,"fetchAsString",(()=>NA)),F(uA,"loadFontFaceSet",(()=>HA)),F(uA,"xmlSerializer",(()=>SA)),F(uA,"toBase64",(()=>RA)),F(uA,"dataUrlFromExternalUrl",(()=>vA)),F(uA,"arrayBufferToDataUrl",(()=>UA)),F(uA,"arrayBufferToBuffer",(()=>PA)),F(uA,"dataUrlToArrayBuffer",(()=>GA));var DA=i.Buffer;let IA;function pA(A){IA=A}function fA(){if(!IA)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new IA}if(void 0===y.TextEncoder){const{TextEncoder:A}=a;y.TextEncoder=A}if(void 0===y.TextDecoder){const{TextDecoder:A}=a;y.TextDecoder=A}const mA=new(M(e).Agent)({rejectUnauthorized:!0}),MA=A=>A.every((A=>"undefined"!==A)),FA=A=>MA([typeof document])?document.createElement(A):fA().window.document.createElement(A),yA=(A,t)=>{if(MA([typeof document]))return document.createElementNS(A,t);const e=fA().window.document.createElement(t);return e.setAttribute("xmlns",A),e},YA=()=>MA([typeof DOMParser])?new DOMParser:new(fA().window.DOMParser),xA=A=>{if(MA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.arrayBuffer())})).catch((A=>{e(A)}))}));{const e=A.replace("localhost","localstack");return new Promise(((A,n)=>{M(t).get(e,{responseType:"arraybuffer",httpsAgent:mA}).then((t=>{A(t.data)})).catch((A=>{n(A)}))}))}},NA=A=>{if(MA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.text())})).catch(e)}));{const e=A.replace("localhost","localstack");return new Promise(((A,n)=>{M(t).get(e,{responseType:"text",httpsAgent:mA}).then((t=>{A(t.data)})).catch(n)}))}},HA=async(A,t)=>{if(MA([typeof FontFace])){const e=A.names.fullName.en,n=new FontFace(e,`url(${t})`);return document.fonts.add(n),n.load()}},SA=()=>MA([typeof XMLSerializer])?new XMLSerializer:new(fA().window.XMLSerializer),RA=A=>MA([typeof btoa])?btoa(A):DA.from(A).toString("base64"),vA=async A=>{if(MA([typeof fetch,typeof Blob,typeof FileReader])){const t=await fetch(A),e=await t.blob();return await JA(e)}const e=(await M(t).get(A,{responseType:"arraybuffer"})).data;return UA(e)},UA=async A=>{const t=await(async A=>{const t=await(0,n.fromBuffer)(A);return t?t.mime:"image/svg+xml"})(A);return`data:${t};base64,${PA(A).toString("base64")}`},GA=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",o=unescape(t.substring(e+1)),s=DA.from(o,a);return kA(s)},PA=A=>DA.from(A),kA=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},JA=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)})),bA=new Map;class OA{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=async A=>{const t=await vA(A),e=zA(t);return TA(e,{assetUrl:t,name:e.names.fullName.en}),await HA(e,A),e},zA=A=>{const t=GA(A),e=M(s).parse(t);return TA(e,{assetUrl:A,name:e.names.fullName.en}),e},jA=A=>{const t=bA.get(A.name);if(t)return t;throw new Error("Font metrics unavailable for font")},TA=(A,t)=>{const e=new OA(A);return bA.set(t.name,e),e},KA=(A,t,e,n,i)=>{const a=jA(t),o=a.getFont();return((A,t,e,n,i,a)=>{const o=a||tt;let s=t.split("\n"),r=s.length,c=s.map((A=>XA(A,n,i))),g=!0;for(;g;){const t=r*(e*o);if(Math.max(...c)<=A.width)return{lines:s,requiredHeight:t};const a=c.reduce(((A,t,e,n)=>t>n[A]?e:A),0),B=s[a];let l=!1,w=B.length;for(;!l&&w>-1;){if(w=B.lastIndexOf(" ",w-1),-1===w){g=!1;break}const t=[B.slice(0,w),B.slice(w+1)],e=t.map((A=>XA(A,n,i)));e[0]<=A.width&&(s=[...s.slice(0,a),...t,...s.slice(a+1)],c=[...c.slice(0,a),...e,...c.slice(a+1)],r+=1,l=!0)}l||(g=!1)}return{lines:s,requiredHeight:r*(e*o)}})(e,qA(n),A,A/o.unitsPerEm,a,i)},VA=1,XA=(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},WA={stripControlCharacters:!0,vertical:!1,uppercase:!1},qA=(A,t=WA)=>{const e={...WA,...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},ZA=(A,t)=>A.map(((A,e)=>[A,t[e]])),$A=(A="center",t=!1)=>t?"center":A,_A=A=>"left"===A?"start":"right"===A?"end":"middle",At=(A,t)=>A.fontData?{...A,...(()=>{if(A.algorithm===P.Traditional){const e=KA(A.fontSize,A.fontData,A,t,A.lineHeight);return{text:e.lines.join("\n"),height:e.requiredHeight,input:t}}return{text:t}})()}:A,tt=1.1;var et={};F(et,"colorDefinitionPrintValue",(()=>nt)),F(et,"spotColorDefinitionString",(()=>it)),F(et,"svgColorValueToDefinition",(()=>at));const nt=A=>`${A.browserValue} ${it(A.spotColor)}`,it=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})`},at=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]}}},ot=A=>{const t=(A.rotation||0)*Math.PI/180,e=Math.cos(t),n=-Math.sin(t),i=`text-path-${A.id}`,a=A.x+(A.curved?0:A.width/2),o=A.y+(A.curved?0:A.height/2),s=(A.text||"").split("\n");return A.curved&&!A.paths?null:A.fontData?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("defs",{children:[(0,r.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,r.jsx)("path",{id:i,d:A.paths[0]}):void 0]}),A._renderingConfiguration?.debug?(0,r.jsx)("rect",{stroke:"blue",fill:"none",x:A.x,y:A.y,width:A.width,height:A.height}):void 0,(0,r.jsx)("g",{transform:`matrix(${e}, ${-n}, ${n}, ${e}, ${a}, ${o})`,children:(0,r.jsx)("text",{xmlSpace:"preserve",fontFamily:`'${A.fontData.name}'`,fontSize:A.fontSize,fontStyle:"normal",fontWeight:"normal",fill:A._renderingConfiguration?.spotColors&&A.fillSpotColorDefinition?`${A.fill} ${it(A.fillSpotColorDefinition)}`:A.fill,style:{whiteSpace:"pre",userSelect:"none"},children:A.curved?(0,r.jsx)(rt,{text:A.text||"",curvedPathId:i,align:A.align}):s.map(((t,e)=>(0,r.jsx)(st,{align:A.vertical?"center":A.align,fontSize:A.fontSize,thisLineIdx:e,amountLines:s.length,text:t,textboxHeight:A.height,textboxWidth:A.width,lineHeight:A.lineHeight,vertical:A.vertical,verticalAlign:A.verticalAlign},e)))})})]}):null},st=A=>(0,r.jsx)("tspan",{textAnchor:_A(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:tt),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}),rt=A=>{const t=`#${A.curvedPathId}`;return(0,r.jsx)("textPath",{startOffset:"left"===A.align?"0%":"right"===A.align?"100%":"50%",textAnchor:_A(A.align),href:t,xlinkHref:t,children:A.text})};F({},"Illustration",(()=>ht));var ct={};F(ct,"traverse",(()=>Bt)),F(ct,"sanitizeSvgTree",(()=>lt)),F(ct,"modifySVGWithElementProperties",(()=>wt)),F(ct,"generateSVGWithUnknownColors",(()=>Et));const gt=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],Bt=(A,t)=>{t(A),A.children.length>0&&Array.from(A.children).forEach((A=>Bt(A,t)))},lt=(A,t=!1)=>{!t&&A.setAttribute("preserveAspectRatio","none");const e=[];Bt(A,(A=>{if("script"!==A.tagName)if("style"!==A.tagName);else try{(0,o.parse)(A.innerHTML).stylesheet?.rules.forEach((A=>{e.push(A)})),A.remove()}catch(A){console.error(A)}else A.remove()})),Bt(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)}))}))}))}))},wt=(A,t,e,n,i)=>{const a=(A=>YA().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)=>{Bt(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?nt(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?nt(i):i.browserValue)}}))}))})(a,n,i),(A=>SA().serializeToString(A))(a)},Et=async A=>{const t=A.match(/<svg.*?<\/svg>/s)||[],e=t?.length>0?t[0]:"",n=YA().parseFromString(e,"image/svg+xml").firstElementChild;if(!n)throw new Error("Failed to read SVG.");lt(n);const i={};Bt(n,(A=>{gt.includes(A.tagName)&&!A.attributes.getNamedItem("fill")&&A.setAttribute("fill","black");const t=A.attributes.getNamedItem("fill");if(t&&"none"!==t.value){const e=at(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=at(e.value),n=`spiff-stroke-${t.browserValue.replace(/\W/g,"")}`;A.classList.add(n),A.setAttribute("stroke",t.browserValue),i[n]=t}}));const a=SA().serializeToString(n);return{colors:i,svg:a}},ht=A=>{if(A.cachedObjectURL&&!A._renderingConfiguration?.omitCachedFields)return(0,r.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});const t=A.rotation||0,e=_(t),n=Math.cos(e),i=-Math.sin(e),a=`\n matrix(1, 0, 0, 1, ${A.x}, ${A.y})\n matrix(1, 0, 0, 1, ${A.width/2}, ${A.height/2})\n matrix(${n}, ${-i}, ${i}, ${n}, 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,r.jsx)("g",{transform:a,dangerouslySetInnerHTML:{__html:wt(A.svg,A.width,A.height,A.colors,A._renderingConfiguration?.spotColors)}})};F({},"Patchwork",(()=>dt));const dt=A=>{const{id:t,x:e,y:n,width:i,height:a,rotation:o,patchX:s,patchY:c,patchScale:g}=A,B=`patchwork-clip-${t}`;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("defs",{children:(0,r.jsx)("clipPath",{id:B,children:(0,r.jsx)("rect",{x:0,y:0,height:a,width:i})})}),(0,r.jsx)("g",{className:`region-${t}`,transform:`\n translate(${e}, ${n})\n rotate(${o})\n `,clipPath:`url(#${B})`,children:(0,r.jsx)("image",{className:`patchwork-slice-${t}`,width:i,height:a,transform:`\n translate(${s}, ${c})\n scale(${g})\n `,xlinkHref:`data:image/svg+xml;utf8,${encodeURIComponent(A.svg)}`})})]})};class Qt{constructor(){this.id=x(),this.stateCallbacks=[],this.prevCommands=[],this.nextCommands=[]}registerStateCallback(A){A(),this.stateCallbacks.push(A)}getState(){return this.state}runStateCallbacks(){this.stateCallbacks.forEach((A=>A()))}apply(A){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);this.state=this.commandReducer(this.state,A),this.runStateCallbacks(),this.nextCommands=[],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,t){const e=Dt([...t]).map((A=>Ct(A))),n={width:A.width,height:A.height,viewBox:{x:0,y:0,width:A.width,height:A.height}},i={backgroundColor:A.transparentBackground?void 0:"white",elements:e};return{layoutState:{layout:A,elements:t},Component:(0,r.jsx)(S,{...i,...n}),getComponentWithProps:A=>(0,r.jsx)(S,{...i,...n,...A})}}initialize(A,t){if(t)return void(this.state={transaction:t});let e={serializableWorkflow:{steps:[]},layouts:{}};A.forEach((A=>{e=new St(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 Ct=A=>"image"===A.type?(0,r.jsx)(EA,{...A},A.id):"frame"===A.type?(0,r.jsx)(hA,{...A},A.id):"illustration"===A.type?(0,r.jsx)(ht,{...A},A.id):"patchwork"===A.type?(0,r.jsx)(dt,{...A},A.id):"textbox"===A.type?(0,r.jsx)(ot,{...A},A.id):null,ut=(A,t,e)=>{const n={backgroundColor:A.transparentBackground?void 0:"white"},i={width:e?.region?e.region.width:A.width,height:e?.region?e.region.height:A.height,viewBox:e?.region?{x:e.region.left,y:e.region.top,width:e.region.width,height:e.region.height}:{x:0,y:0,width:A.width,height:A.height}},a=Dt((e?.removeExcludedElements?t.filter((A=>!A.excludeFromExport)):t).map((A=>({...A,_renderingConfiguration:e}))));try{return M(c).renderToStaticMarkup((0,r.jsx)(S,{preserveAspectRatio:"none",...n,...i,elements:a.map((A=>Ct(A))).filter((A=>!!A)),omitBoundClipping:e?.omitClipMask,colorProfiles:e?.colorProfiles?e.colorProfiles:void 0}))}catch(A){return console.error("Error rendering to static markup"),console.error(A),""}};function Dt(A){return A.sort(((A,t)=>(A.layer||0)-(t.layer||0)||(A.layerIndex||0)-(t.layerIndex||0)))}class It extends Error{constructor(A){super("No element found with ID: "+A),Object.setPrototypeOf(this,It.prototype)}}const pt=(A,t)=>ft(A,t).elements.find((t=>t.id===A)),ft=(A,t)=>{const e=Object.values(t).find((t=>t.elements.some((t=>t.id===A))));if(!e)throw new It(A);return e},mt=(A,t)=>{const e=Dt([...t.elements.filter((t=>t.id!==A.id)),A]);return{layout:t.layout,elements:e,modificationID:x()}},Mt=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],o=t?.layouts[i],s=(a||o).elements.filter((A=>"illustration"===A.type));for(let A=0;A<s.length;++A){const t=s[A];if(t.src&&!t.svg){const A=await NA(t.src),e=await Et(A);t.svg=wt(e.svg,t.width,t.height,t.colors)}}}};class Ft{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(A){this.oldState=A}}class yt extends Ft{constructor(A){super(),this.serializableWorkflow=A}apply(A){return this.oldState=A,{...A,serializableWorkflow:this.serializableWorkflow}}}class Yt extends Ft{constructor(A,t,e){super(),this.id=A,this.x=t,this.y=e}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,x:this.x,y:this.y},n=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class xt extends Ft{constructor(A,t){super(),this.id=A,this.angle=t}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,rotation:this.angle},n=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Nt extends Ft{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=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(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=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Ht extends Ft{constructor(A){super(),this.commands=A}apply(A){return this.oldState=A,this.commands.reduce(((A,t)=>t.apply(A)),A)}}class St extends Ft{constructor(A){super(),this.layout=A}apply(A){return this.oldState=A,{...A,layouts:{...A.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:x()}}}}}class Rt extends Ft{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:x()}})),e={};return t.forEach((A=>{e[A.layout.id]=A})),{...A,layouts:e}}}class vt extends Ft{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(e)),{...A,layouts:{...A.layouts,[this.layout.id]:{...A.layouts[this.layout.id],elements:e,modificationID:x()}}}}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(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:x()}}}}assignIndex(A){if(0===A.length)return;const t=A[A.length-1]?.layerIndex;return void 0!==t?t+1:this.assignIndex(A.slice(0,A.length-1))}}class Ut extends Ft{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=>{const t=A.cachedObjectURL;return A.id===this.id&&t&&URL.revokeObjectURL(t),A.id!==this.id})),modificationID:x()})));t||console.log(`Failed to delete element ${this.id}`);const n={};return e.forEach((A=>{n[A.layout.id]=A})),{...A,layouts:n}}}class Gt extends Ft{constructor(t,e){super(),this.el=M(A)(t),this.layout=e,this.el.id=x(),this.el.x+=5,this.el.y+=5}apply(A){return this.oldState=A,new vt(this.el,this.layout).apply(A)}}class Pt extends Ft{constructor(A,t,e){super(),this.id=A,this.color=t,this.textFillSpotColor=e}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor},n=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class kt extends Ft{constructor(A,t){super(),this.id=A,this.size=t}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,fontSize:this.size},n=ft(t.id,Object.values(A.layouts)),i=e.algorithm&&e.algorithm!==P.Autosize?e.input||"":e.text||"",a=mt(At(e,i),n);return{...A,layouts:{...A.layouts,[n.layout.id]:a}}}}class Jt extends Ft{constructor(A,t){super(),this.id=A,this.algorithm=t}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,algorithm:this.algorithm},n=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class bt extends Ft{constructor(A,t){super(),this.id=A,this.fontData=t}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,fontData:this.fontData},n=ft(t.id,Object.values(A.layouts)),i=mt(At(e,e.text||""),n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Ot extends Ft{constructor(A,t){super(),this.id=A,this.align=t}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,align:this.align},n=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Lt extends Ft{constructor(A,t,e){super(),this.id=A,this.imageData=t,this.offsets=e}apply(A){this.oldState=A;const t=ft(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:x()};return{...A,layouts:{...A.layouts,[t.layout.id]:a}}}}class zt extends Ft{constructor(A,t){super(),this.id=A,this.text=t}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e=ft(t.id,Object.values(A.layouts)),n=mt(At(t,this.text),e);return{...A,layouts:{...A.layouts,[e.layout.id]:n}}}}class jt extends Ft{constructor(A,t,e){super(),this.id=A,this.className=t,this.fill=e}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(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=ft(t.id,Object.values(A.layouts)),o=mt(i,a);return{...A,layouts:{...A.layouts,[a.layout.id]:o}}}}class Tt extends Ft{constructor(A,t,e){super(),this.id=A,this.svgBody=t,this.objectURL=e}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,svg:this.svgBody,cachedObjectURL:this.objectURL},n=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Kt extends Ft{constructor(A,t,e,n){super(),this.id=A,this.scale=t,this.leftOffset=e,this.topOffset=n}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(this.id);const e={...t,patchX:this.leftOffset,patchY:this.topOffset,patchScale:this.scale},n=ft(t.id,Object.values(A.layouts)),i=mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Vt extends Ft{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!pt(this.id,Object.values(A.layouts)).id)throw new It(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:x()}}}}}class Xt extends Ft{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!pt(this.id,Object.values(A.layouts)).id)throw new It(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:x()}}}}}class Wt extends Ft{constructor(A,t){super(),this.id=A,this.value=t}apply(A){this.oldState=A;const t=pt(this.id,Object.values(A.layouts));if(!t.id)throw new It(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]:mt({...t,layer:this.value},e)}}}}var qt={};F(qt,"patternImageDataCache",(()=>ne)),F(qt,"frameDataCache",(()=>ie)),F(qt,"generateFrameSVG",(()=>ae)),F(qt,"generateDefaultRectangleFrameSvg",(()=>oe)),F(qt,"getVariant",(()=>se)),F(qt,"getFrameData",(()=>re)),F(qt,"calculateOffsets",(()=>ce)),F(qt,"getPatternImageData",(()=>ge)),F(qt,"GetSVGDimensions",(()=>Be)),F(qt,"svgStringDimensions",(()=>le));var Zt={};F(Zt,"getExifOrientation",(()=>_t)),F(Zt,"canvasDims",(()=>Ae)),F(Zt,"getAttributesFromArrayBuffer",(()=>te));let $t=null;const _t=A=>new Promise((t=>{const e=PA(A);(0,n.fromBuffer)(A).then((A=>{const n=A?.mime;if("image/jpeg"!==n)return t(1);(new(0,B.ExifImage)).loadImage(e,((A,e)=>t(A?1:e.image.Orientation||1)))}))})),Ae=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]},te=async A=>{const t=await(async A=>{const t=await UA(A),e=await(0,g.loadImage)(t),[n,i]=Ae(e),a=await(async()=>{if(null!==$t)return!$t;const A=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return $t=2===A.width&&3===A.height,!$t})();if(!a){const A=(0,g.createCanvas)(n,i);return A.getContext("2d").drawImage(e,0,0,n,i),A}const o=await _t(A),[s,r]=o>4?[i,n]:[n,i],c=(0,g.createCanvas)(s,r),B=c.getContext("2d");switch(o){case 2:B.translate(s,0),B.scale(-1,1);break;case 3:B.translate(s,r),B.rotate(Math.PI);break;case 4:B.translate(0,r),B.scale(1,-1);break;case 5:B.rotate(-.5*Math.PI),B.scale(-1,1);break;case 6:B.rotate(-.5*Math.PI),B.translate(-s,0);break;case 7:B.rotate(-.5*Math.PI),B.translate(-s,r),B.scale(1,-1);break;case 8:B.rotate(.5*Math.PI),B.translate(0,-r)}return B.drawImage(e,0,0,s,r),c})(A);return"image/jpeg"===(await(0,n.fromBuffer)(A))?.mime?{dataUrl:t.toDataURL("image/jpeg",1),height:t.height,width:t.width}:{dataUrl:t.toDataURL(),height:t.height,width:t.width}};F({},"getDefaultVariant",(()=>ee));const ee=A=>{const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0},ne=new Map,ie=new Map,ae=async(A,t)=>{if(!t){if(!A)throw new Error("No region or src supplied. Cannot construct frame!");return oe(A)}return NA(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 `},se=(A,t)=>{if(!t)return;const e=t.data.variants.find((t=>t.id===A.frameVariantId))||ee(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},re=async A=>{const t=YA().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,o=parseFloat(i[2])||1,s=t.getElementById("target-path"),r=t.getElementsByClassName("st0").item(0);if(s){const A=s.getAttribute("d");if(!A)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const t={path:A,width:o,height:a};return ie.set(A,t),t}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:o,height:a};return ie.set(A,t),t}throw new Error("Malformed frame SVG")},ce=(A,t,e)=>{const n=t.width>=t.height,i=A.width>=A.height,a=t.width/2,o=t.height/2,s=(n?t.height:t.width)/(i?A.height:A.width),r=e?.scale||s,c=a-A.width/2*r,g=e?.left||c,B=o-A.height/2*r;return{x:g,y:e?.top||B,zoom:r}},ge=async A=>{if(ne.has(A))return ne.get(A);if(A.endsWith("svg")){const t=await Be(A),e=t.width,n=t.height,i={src:A,width:e,height:n,aspect:e/n};return ne.set(A,i),i}{const t=await xA(A),e=await te(t),n={src:A,width:e.width,height:e.height,aspect:e.width/e.height};return ne.set(A,n),n}},Be=async A=>{const t=await fetch(A),e=await t.text();return le(e)},le=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 we={};F(we,"determineCorrectFontSizeAndLines",(()=>he)),F(we,"determineCorrectTextboxRegion",(()=>de));const Ee=(A,t,e,n,i)=>{let a=t.split("\n"),o=a.length,s=a.map((A=>XA(A,n,i)));const r=i.getApproximateHeight()*n;let c=!0;for(;c;){if(r+(o-1)*e>A.height)return[null,null];const t=Math.max(...s);if(t<=A.width)return[a,t];const g=s.reduce(((A,t,e,n)=>t>n[A]?e:A),0),B=a[g];let l=!1,w=B.length;for(;!l&&w>-1;){w=B.lastIndexOf(" ",w-1);const t=[B.slice(0,w),B.slice(w+1)],e=t.map((A=>XA(A,n,i)));e[0]<=A.width&&(a=[...a.slice(0,g),...t,...a.slice(g+1)],s=[...s.slice(0,g),...e,...s.slice(g+1)],o+=1,l=!0)}l||(c=!1)}return[null,null]},he=(A,t,e,n,i)=>{let a,o;const s=jA(t),r=s.getFont();if(i.size){const t=A/r.unitsPerEm;return[a,o]=Ee(e,n,A,t,s),[i.size,a,o]}let c=6-VA;if(""!==n){let A=[n],t=0;for(;(!i.maxSize||c<=i.maxSize)&&A;)c+=VA,t=c/r.unitsPerEm,[A,o]=Ee(e,n,c,t,s)}c>6&&(c-=VA),i.minSize&&c<i.minSize&&(c=i.minSize);const g=c/r.unitsPerEm;return[a,o]=Ee(e,n,c,g,s),[c,a,o]},de=(A,t,e,n,i)=>{let a={...A},o={...A};const s=n.join(" ");let[r,c,g]=he(e,t,o,s,{size:0,minSize:e,maxSize:e});var B,l;return g&&g<a.width&&(o.width=g,"left"===i?(o.left+=Math.sin(a.rotation*Math.PI/360)*(a.width-g),o.top+=Math.sin(a.rotation*Math.PI/180)*(g-a.width)/2):o.left+="right"===i?a.width-g:(a.width-g)/2,[r,c]=he(e,t,o,s,{size:e}),r===e&&c&&(B=n,l=c,B.map(((A,t)=>[A,l[t]]))).every((([A,t])=>A===t))&&(a=o)),a};F({},"LayoutElementFactory",(()=>Qe));class Qe{static async getFrame(A){const t=await ae(A.region,A.src),e=await re(t);return{id:x(),x:A.region.left,y:A.region.top,width:A.region.width,height:A.region.height,layer:A.region.layer||0,layerIndex:A.region.layerIndex,rotation:A.region.rotation,scaleX:A.region.width/e.width,scaleY:A.region.height/e.height,path:e.path,type:U.Frame,disablePlaceholder:A.configuration.disablePlaceholder,focalBlur:A.configuration.focalBlur,focalBlurStrength:A.configuration.focalBlurStrength,focalBlurRadius:A.configuration.focalBlurRadius,pattern:void 0,immutable:A.region.immutable}}static async getImage(A){let t;if(A.layout){const e=Ce(A.layout),n=e.height,i=await fetch(A.src),a=await i.arrayBuffer(),o=await te(a),s=o.width/o.height;e.height=e.width/s,e.top+=(n-e.height)/2,t=e}else t=A.region;return t||(t={left:0,top:0,width:100,height:100,layer:0,layerIndex:1,rotation:0,panelId:"",immutable:!1}),{id:x(),src:A.src,type:U.Image,y:t.top,x:t.left,rotation:t.rotation,width:t.width,height:t.height,layer:t.layer||0,layerIndex:t.layerIndex,immutable:t.immutable,preserveAspectRatio:"none"}}static async getTextbox(A){const{region:t,configuration:e,fontSrc:n,designInputStep:i}=A,a={assetUrl:n,name:(await LA(n)).names.fullName.en},o=i?.text||e.defaultText||"",s=e.replaceableText?e.replaceableText.replace("{{}}",o):o,r=qA(s,{vertical:e.vertical,uppercase:e.uppercase});return At({id:x(),type:U.Textbox,x:t.left,y:t.top,width:t.width,height:t.height,align:$A(e.textAlign,e.vertical),curved:e.curved,fill:i?.color||e.colour||"#000000",fontData:a,layer:t.layer||0,layerIndex:t.layerIndex,paths:e.paths,rotation:t.rotation,vertical:e.vertical,verticalAlign:e.verticalAlign||"middle",algorithm:P.Traditional,fontSize:e.size||18,text:r,input:o},r)}static async getShape(A){const t=`\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="${A.color}"\n />\n </svg>\n `,e={};e["spiff-fill-shape"]={browserValue:A.color};const n=x();return{stepRegion:A.region,colors:e,id:n,svg:t,type:"illustration",y:A.region.top,x:A.region.left,rotation:A.region.rotation,width:A.region.width,height:A.region.height,layer:A.region.layer||0,layerIndex:A.region.layerIndex,immutable:A.region.immutable}}}const Ce=A=>{const t=(A.layoutState.layout.width<A.layoutState.layout.height?A.layoutState.layout.width:A.layoutState.layout.height)/2;return{top:A.layoutState.layout.height/2-t/2,left:A.layoutState.layout.width/2-t/2,width:t,height:t,rotation:0,panelId:A.layoutState.layout.panelId}};function ue(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const De=new class{constructor(){ue(this,"defaultServerUrl","https://api.spiff.com.au"),ue(this,"defaultServicesApiUrl","https://services.spiff.com.au"),ue(this,"defaultHubUrl","https://hub.spiff.com.au"),ue(this,"serverUrl",void 0),ue(this,"servicesApiUrl",void 0),ue(this,"hubUrl",void 0),ue(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 Ie(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let pe;const fe=A=>{pe=A},me=async()=>{const A={transactionOwnerId:pe};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=De.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 Me=new class{constructor(){Ie(this,"client",void 0),Ie(this,"uncachedOperations",[]),De.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 me();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 me(),t=De.getServerUrl()+"/v2/api-docs";return await M(l)(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const Fe=new class{constructor(){Ie(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),De.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=(0,w.createHttpLink)({uri:`${De.getServerUrl()}/graphql`,fetch:d.fetch}),t=(0,E.setContext)((async(A,{headers:t})=>{const e=t||{},n=await me();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,h.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,w.InMemoryCache)({typePolicies:{Transaction:{fields:{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}}}}});return new(0,w.ApolloClient)({link:(0,w.from)([e,t,A]),cache:n,name:"Core"})}};function ye(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const Ye=new class{constructor(){ye(this,"server",void 0),ye(this,"cache",new Map),ye(this,"materialCache",new Map),ye(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await te(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)}})),this.server=Me}async getLocalOrFromServer(A){if(this.cache.has(A))return this.cache.get(A);const t=(async()=>(await Me.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 Me.execute("getMaterialV2",{id:A})).body)();return this.materialCache.set(A,t),t}async uploadAssetWithProgress(A,t,e,n,i,a){const o=await this.dispatchCreateAssetRequest(A,t,i,a);var s=new XMLHttpRequest;return s.open("PUT",o.assetResponse.uploadUrl,!0),s.setRequestHeader("Content-Type",o.mimeType),s.setRequestHeader("Cache-Control","public,max-age=31536000,immutable"),s.upload.onprogress=A=>{A.lengthComputable&&e(100*A.loaded/A.total)},s.onload=()=>{const A=o.assetResponse.asset;n(A)},s.onerror=()=>{console.warn("Asset upload failed")},s.send(A.blob),o.assetResponse.asset}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 Error("Unexpected mimetype: "+t)}}};function xe(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const Ne=new class{constructor(){xe(this,"cache",new Map),xe(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),xe(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),xe(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[]))}async cacheRequiredOptions(A){const t=A.steps.map((A=>A.optionId)).filter((A=>void 0!==A)),e=A.steps.map((A=>A.data.colourOptionId)).filter((A=>void 0!==A)),n=[...new Set([...t,...e])].map((async A=>{const t=await Ne.getLocalOrFromServer(Me,A);"Font"===t.data.type&&t.data.variants.forEach((async A=>{if(A.assetKey){const t=(await Ye.getLocalOrFromServer(A.assetKey)).links.find((A=>"cdn"===A.rel))?.href;t&&await LA(t)}}))}));await Promise.allSettled([...n])}async getLocalOrFromServer(A,t){if(this.cache.has(t))return this.cache.get(t);const e=(await A.execute("getOptionV2",{id:t})).body;return this.cache.set(t,e),e}getLocalOrUndefined(A){if(A)return this.cache.get(A)}async getAssetTileImageForVariant(A){if(A.thumbnailKey){const t=await Ye.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 Ye.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}},He=(0,Q.createContext)(new Qt),Se=()=>{const A=(0,Q.useContext)(He);(0,Q.useEffect)((()=>{A.registerStateCallback((()=>{e(new Date)}))}),[A]);const[t,e]=(0,Q.useState)(new Date);return{commandDispatcher:t=>{A.apply(t)},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)}}};let Re;var ve;(ve=Re||(Re={})).None="None",ve.FrameAdjustment="FrameAdjustment",ve.FinalizeDesign="FinalizeDesign";const Ue=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,maxZoom:5,units:J.Pixel,subMenu:Re.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),Ge=(A,t)=>M(C)(A,t.apply(A))?A:t.apply(A),Pe=(0,Q.createContext)({}),ke=A=>{const{getAllLayouts:t}=Se(),[e,n]=(0,Q.useReducer)(Ge,Ue(t,A.defaultZoom||1)),i=(0,Q.useMemo)((()=>({state:e,uiDispatcher:n})),[e,n]);return(0,r.jsx)(Pe.Provider,{value:i,children:A.children})};class Je{constructor(A){var t,e,n;n=void 0,(e="changes")in(t=this)?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,this.changes=A}apply(A){return{...A,...this.changes}}}const be=()=>(0,Q.useContext)(Pe);let Oe;var Le;(Le=Oe||(Oe={}))[Le.Orbit=0]="Orbit",Le[Le.Pan=1]="Pan";const ze=(A,t,e,n)=>{const i=t.layout.width,a=t.layout.height,o=t.elements.filter((t=>t.id!==A.id&&!t.immutable&&!t.productOverlay)),s=o.map((A=>Z(A.x,A.y,A.width,A.height,A.rotation))),c=[],g=new Set;s.forEach((A=>g.add(A.minX))),s.forEach((A=>g.add(A.maxX))),[0,i/2,i].forEach((A=>g.add(A)));const B=new Set;s.forEach((A=>B.add(A.minY))),s.forEach((A=>B.add(A.maxY))),[0,a/2,a].forEach((A=>B.add(A)));const l=o.map((A=>A.y));for(let A=-315;A<=315;A+=45)l.push(A);const w=Z(A.x,A.y,A.width,A.height,A.rotation),E=[{value:w.minX,anchor:-1},{value:w.minX+(w.maxX-w.minX)/2,anchor:0},{value:w.minX+(w.maxX-w.minX),anchor:1}],h=[{value:w.minY,anchor:-1},{value:w.minY+(w.maxY-w.minY)/2,anchor:0},{value:w.minY+(w.maxY-w.minY),anchor:1}],d=[{value:A.rotation,anchor:0}],Q=(A,t,n,o)=>{const s=[];return t.forEach((t=>{const c=n.find((A=>tA(t,A.value,2*e))),[g,B]=((A,t)=>[{x:"x"===A?t:0,y:"x"===A?0:t},{x:"x"===A?t:i,y:"x"===A?a:t}])(A,t),l="rotation"===A?null:(0,r.jsx)("line",{x1:g.x,y1:g.y,x2:B.x,y2:B.y,stroke:o||"#D61B5C",strokeDasharray:5*e,strokeWidth:1.2*e,overflow:"overlay"},`${A}-${t}-${g.x}-${g.y}-${B.x}-${B.y}`);void 0!==c&&s.push({type:A,value:t,anchorPoint:c.anchor,svgNode:l,guidelineCoordinates:[g,B]})})),s};return c.push(...Q("x",Array.from(g),E,n)),c.push(...Q("y",Array.from(B),h,n)),c.push(...Q("rotation",l,d,n)),c};let je;var Te;let Ke;var Ve;(Te=je||(je={})).Translate="Translate",Te.Rotate="Rotate",Te.Resize="Resize",(Ve=Ke||(Ke={})).ControlLeft="ControlLeft",Ve.ControlRight="ControlRight",Ve.Equal="Equal",Ve.MetaLeft="MetaLeft",Ve.MetaRight="MetaRight",Ve.Minus="Minus",Ve.ArrowLeft="ArrowLeft",Ve.ArrowRight="ArrowRight",Ve.ArrowUp="ArrowUp",Ve.ArrowDown="ArrowDown",Ve.AltLeft="AltLeft",Ve.AltRight="AltRight",Ve.Delete="Delete",Ve.Backspace="Backspace";const Xe=(A,t,e,n)=>{const i=()=>{switch(e){case J.Pixel:return 1;case J.Millimeter:return lA;case J.Centimeter:return wA;default:throw new Error("Unknown unit of measurement")}};let a=t.x,o=t.y,s=t.x,r=t.y;switch(A){case Ke.ArrowLeft:s=t.x-1/i();break;case Ke.ArrowUp:r=t.y-1/i();break;case Ke.ArrowRight:s=t.x+1/i();break;case Ke.ArrowDown:r=t.y+1/i();break;default:throw new Error("Unhandled element interaction!")}const c=Z(s,r,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=s,o=r),new Yt(t.id,a,o)};var We=0,qe=0,Ze=0;const $e=(A,t,e,n,i,a,o)=>{const s=((A,t,e,n,i,a,o)=>{const s=n.width/t.width,r=n.height/t.height,c=A.movementX/s,g=A.movementY/r,B=e.rotation*Math.PI/180,l=Math.sin(B),w=Math.cos(B);let E;switch(i.type){case je.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*l+g*w,n=e.y+A,i=e.height-A,a=gA({...e}).center,o=gA({...e,y:n,height:i}).center,s=BA(o,a,B),r=s.x-e.width/2,E=s.y-i/2;h={...t,left:r,top:E,height:i}}break;case O.East:{const A=c*w+g*l,n=e.width+A;let i=e.height;if(e.type===U.Textbox){const A=e;i=KA(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const a=gA({...e}).center,o=gA({...e,width:n,height:i}).center,s=BA(o,a,B),r=s.x-n/2,E=s.y-i/2;h={...t,left:r,top:E,width:n,height:i}}break;case O.West:{const A=c*w+g*l,n=e.x+A,i=e.width-A;let a=e.height;if(e.type===U.Textbox){const A=e;a=KA(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const o=gA({...e}).center,s=gA({...e,width:i,height:a,x:n}).center,r=BA(s,o,B),E=r.x-i/2,d=r.y-a/2;h={...t,left:E,top:d,width:i,height:a}}break;case O.South:{const A=-c*l+g*w,n=e.height+A,i=gA({...e}).center,a=gA({...e,height:n}).center,o=BA(a,i,B),s=o.x-e.width/2,r=o.y-n/2;h={...t,left:s,top:r,height:n}}break;case O.Northeast:{const A=c*w+g*l,n=e.width+A;let i=e.height+A,a=e.y-A,o=e.fontSize;if(e.type===U.Textbox){const t=e;o=t.fontSize+A/8,i=KA(o,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||tt;a=e.y-A*n/8}const s=gA({...e}).center,r=gA({...e,width:n,height:i,y:a}).center,E=BA(r,s,B),d=E.x-n/2,Q=E.y-i/2;h={...t,left:d,top:Q,width:n,height:i,fontSize:o}}break;case O.Northwest:{const A=-c*w+-g*l,n=e.x-A,i=e.width+A;let a=e.y-A,o=e.height+A,s=e.fontSize;if(e.type===U.Textbox){const t=e;s=t.fontSize+A/8,o=KA(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||tt;a=e.y-A*n/8}const r=gA({...e}).center,E=gA({...e,x:n,y:a,width:i,height:o}).center,d=BA(E,r,B),Q=d.x-i/2,C=d.y-o/2;h={...t,left:Q,top:C,width:i,height:o,fontSize:s}}break;case O.Southeast:{const A=c*w+g*l,n=e.width+A;let i=e.height+A,a=e.fontSize;if(e.type===U.Textbox){const t=e;a=t.fontSize+A/8,i=KA(a,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const o=gA({...e}).center,s=gA({...e,width:n,height:i}).center,r=BA(s,o,B),E=r.x-n/2,d=r.y-i/2;h={...t,left:E,top:d,width:n,height:i,fontSize:a}}break;case O.Southwest:{const A=-c*w+-g*l,n=e.width+A;let i=e.x-A,a=e.height+A,o=e.fontSize;if(e.type===U.Textbox){const t=e;o=t.fontSize+A/8,a=KA(o,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const s=gA({...e}).center,r=gA({...e,width:n,height:a,x:i}).center,E=BA(r,s,B),d=E.x-n/2,Q=E.y-a/2;h={...t,left:d,top:Q,width:n,height:a,fontSize:o}}}return E=Z(h.left,h.top,h.width,h.height,h.rotation),(!o||E.minX>=o.left&&E.maxX<=o.left+o.width&&E.minY>=o.top&&E.maxY<=o.top+o.height)&&(t=h),t;case je.Rotate:const d={x:A.clientX,y:A.clientY};let Q,C=e.rotation;const u=gA(e,n,{x:s,y:r}),D=$(d,u.c,u.d),I=$(d,u.d,u.c);if(0===a.filter((A=>"rotation"===A.type)).length)Ze=0,Q=(e.rotation+D-I)%360;else{Ze+=Math.sqrt(c**2+g**2);const A=Math.abs(Ze)>7*window.devicePixelRatio/s;Q=A?(e.rotation+D-I)%360:a.find((A=>"rotation"===A.type))?.value||0,A&&(Ze=0)}return E=Z(e.x,e.y,e.width,e.height,Q),(!o||E.minX>=o.left&&E.maxX<=o.left+o.width&&E.minY>=o.top&&E.maxY<=o.top+o.height)&&(C=Q),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:C};case je.Translate:let p,f,m=e.x,M=e.y;if(0===a.filter((A=>"rotation"!==A.type)).length)We=0,qe=0,p=e.x+c,f=e.y+g;else{const A=a.find((A=>"x"===A.type)),t=a.find((A=>"y"===A.type));A||(We=0),t||(qe=0);const n=Math.abs(We)>7*window.devicePixelRatio/s,i=Math.abs(qe)>7*window.devicePixelRatio/r;p=A?n?e.x+We:e.x:e.x+c,f=t?i?e.y+qe:e.y:e.y+g,We=n?0:We+c,qe=i?0:qe+g}return E=Z(p,f,e.width,e.height,e.rotation),(!o||E.minX>=o.left&&E.maxX<=o.left+o.width&&E.minY>=o.top&&E.maxY<=o.top+o.height)&&(m=p,M=f),{top:M,left:m,width:e.width,height:e.height,rotation:e.rotation}}})(A,t,e,n,i,a,o),r=[];if(e.type===U.Textbox){const A=e;r.push(new zt(A.id,A.text||A.input||""))}if(r.push(new Yt(e.id,s.left,s.top),new Nt(e.id,s.width,s.height),new xt(e.id,s.rotation)),e.type===U.Textbox){const A=e;s.fontSize&&A.fontSize!==s.fontSize&&r.push(new kt(A.id,s.fontSize))}return r},_e=.5,An=(A,t,e,n,i,a,o)=>{const{state:s,uiDispatcher:r}=(0,Q.useContext)(Pe),{getLayoutById:c,getReducerState:g,flattenSequence:B}=Se(),[l,w]=(0,Q.useState)(void 0),[E,h]=(0,Q.useState)(void 0),d=c(s.layoutId);(0,Q.useEffect)((()=>{if("adjustment"===i&&A?.current&&n){if(n<_e)return void r(new Je({zoom:_e}));if(n>s.maxZoom)return void r(new Je({zoom:s.maxZoom}));r(new Je({zoom:n}))}}),[n,r,A,i,s.maxZoom]);const C=(0,Q.useCallback)(((A,n)=>{r(new Je({zoom:n}));const a=t?.current?.scrollWidth-t?.current?.clientWidth!=0,o=t?.current?.scrollHeight-t?.current?.clientHeight!=0;t.current&&e.current&&!s.scrolledMovement&&"advanced"===i&&(o&&(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))}),[r,t,e,s.scrolledMovement,i]);(0,Q.useEffect)((()=>{s.zoom<=1&&r(new Je({scrolledMovement:!1}))}),[r,s.zoom]);const u=t?.current?.getBoundingClientRect(),D=((u?.width||1)+(u?.height||1))/2,I=(d.layoutState.layout.width+d.layoutState.layout.height)/2/D/s.zoom,p=(0,Q.useMemo)((()=>{const A=s.activeModifierKeys,t=s.elementEvent,e=A.includes(Ke.ControlLeft)||A.includes(Ke.MetaLeft)||A.includes(Ke.ControlRight)||A.includes(Ke.MetaRight);if(!s.selectedElement||!t||e)return[];const n=t&&t.type===je.Translate,i=t&&t.type===je.Rotate,a=d.layoutState.elements.find((A=>A.id===s.selectedElement));return(n||i)&&a?ze(a,d.layoutState,I,o):[]}),[s.selectedElement,s.elementEvent,s.activeModifierKeys,d.layoutState,I]),f=(0,Q.useCallback)((()=>{const A=x();w(A),h(g().transaction)}),[g]),m=(0,Q.useCallback)((()=>{r(new Je({selectedElement:void 0}))}),[r]),M=(0,Q.useCallback)((()=>{r(new Je({scrolledMovement:!0}))}),[r]),F=(0,Q.useCallback)(((e,n)=>{const i=d.layoutState.elements.find((A=>A.id===s.selectedElement));if(!(s.elementEvent&&A.current&&t.current&&s.selectedElement&&i))return;t.current.hasPointerCapture(e.pointerId)||t.current.setPointerCapture(e.pointerId);const o=A.current.getBoundingClientRect(),r=new Ht($e(e,d.layoutState.layout,i,o,s.elementEvent,p,n));r.sequenceId=l,a(r)}),[d.layoutState.elements,d.layoutState.layout,s.elementEvent,A,s.selectedElement,t,p,a]),y=(0,Q.useCallback)((A=>{r(new Je({elementEvent:A}))}),[r]),Y=(0,Q.useCallback)((()=>{r(new Je({elementEvent:void 0})),l&&E&&(B(l,E),w(void 0),h(void 0))}),[r,l,E,B]),N=(0,Q.useCallback)(((A,t)=>{let e=s.zoom;const n=s.maxZoom,o=s.selectedElement,c=s.activeModifierKeys;if((c.includes(Ke.AltLeft)||c.includes(Ke.AltRight))&&(A.code===Ke.Equal||A.code===Ke.Minus)){const t=.05*n;A.code===Ke.Equal?r(new Je({zoom:e+t<=n?e+=t:e})):r(new Je({zoom:e-t>=_e?e-t:e}))}const g=d.layoutState.elements.find((A=>A.id===o));if(o&&g){if(A.code===Ke.MetaLeft||A.code===Ke.ControlLeft||A.code===Ke.MetaRight||A.code===Ke.ControlRight){const t=A.code,e=s.activeModifierKeys;if(!e.includes(t))return r(new Je({activeModifierKeys:e.concat(t)}))}if(A.code===Ke.ArrowDown||A.code===Ke.ArrowUp||A.code===Ke.ArrowLeft||A.code===Ke.ArrowRight){r(new Je({elementEvent:{type:je.Translate}}));const e=Xe(A.code,g,s.units,t);a(e),r(new Je({elementEvent:void 0}))}A.code!==Ke.Delete&&A.code!==Ke.Backspace||"advanced"!==i||(r(new Je({selectedElement:void 0})),a(new Ut(g.id)))}}),[a,r,d.layoutState.elements,i,s.activeModifierKeys,s.maxZoom,s.selectedElement,s.units,s.zoom]),H=(0,Q.useCallback)((A=>{if(A.code===Ke.MetaLeft||A.code===Ke.ControlLeft||A.code===Ke.MetaRight||A.code===Ke.ControlRight){const t=s.activeModifierKeys,e=A.code;r(new Je({activeModifierKeys:t.filter((A=>A!==e))}))}}),[r,s.activeModifierKeys]);return{guidelines:p,scale:I,zoomableElementRef:e,setElementEvent:y,handleZoom:C,handleKeyDown:N,handleKeyUp:H,handlePointerPressedBackground:m,handlePointerReleased:Y,handlePointerMove:F,handleScroll:M,handleSequenceStart:f}},tn=A=>{const{x:t,y:e,cursorStyle:n,onPointerDown:i,handleClass:a,cornerRadius:o,color:s,strokeWidth:c}=A;return(0,r.jsx)("circle",{className:a,cx:t,cy:e,r:o,fill:"#ffffff",style:{cursor:n},stroke:s,strokeWidth:c,onPointerDown:i})},en=A=>{const{x:t,y:e,width:n,height:i,cursorStyle:a,onPointerDown:o,edgeHandleRadius:s,color:c,strokeWidth:g}=A;return(0,r.jsx)("rect",{x:t,y:e,width:n,height:i,rx:s,fill:"#ffffff",style:{cursor:a},stroke:c,strokeWidth:g,onPointerDown:o})},nn=A=>{const{color:t,elementHeight:e,elementWidth:n,onBeginResize:i,rotation:a,scaleFactor:o,disableX:s,disableY:c}=A,g=7.5*o,B=3*o,l=28*o,w=6*o,E=1.2*o,h=e-2*g,d=(0,Q.useCallback)(((A,t,e)=>{A.stopPropagation(),i(t,e)}),[i]),C=(0,Q.useCallback)((A=>d(A,cA(O.West,360-a),O.West)),[d,a]),u=(0,Q.useCallback)((A=>d(A,cA(O.East,360-a),O.East)),[d,a]),D=(0,Q.useCallback)((A=>d(A,cA(O.North,360-a),O.North)),[d,a]),I=(0,Q.useCallback)((A=>d(A,cA(O.South,360-a),O.South)),[d,a]),p=(0,Q.useCallback)((A=>d(A,O.Northwest,O.Northwest)),[d]),f=(0,Q.useCallback)((A=>d(A,O.Northeast,O.Northeast)),[d]),m=(0,Q.useCallback)((A=>d(A,O.Southwest,O.Southwest)),[d]),M=(0,Q.useCallback)((A=>d(A,O.Northeast,O.Southeast)),[d]),F=l<=h;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tn,{x:0,y:0,cursorStyle:"nwse-resize",onPointerDown:p,handleClass:"cornerNorthWest",cornerRadius:g,color:t,strokeWidth:E}),F?(0,r.jsx)(tn,{x:n,y:0,cursorStyle:"nesw-resize",onPointerDown:f,handleClass:"cornerNorthEast",cornerRadius:g,color:t,strokeWidth:E}):void 0,F?(0,r.jsx)(tn,{x:n,y:e,cursorStyle:"nwse-resize",onPointerDown:M,handleClass:"cornerSouthEast",cornerRadius:g,color:t,strokeWidth:E}):void 0,F?(0,r.jsx)(tn,{x:0,y:e,cursorStyle:"nesw-resize",onPointerDown:m,handleClass:"cornerSouthWest",cornerRadius:g,color:t,strokeWidth:E}):void 0,F&&!s?(0,r.jsx)(en,{x:-w/2,y:e/2-l/2,width:w,height:l,onPointerDown:C,edgeHandleRadius:B,cursorStyle:"ew-resize",color:t,strokeWidth:E}):void 0,F&&!c?(0,r.jsx)(en,{x:n/2-l/2,y:e-w/2,width:l,height:w,onPointerDown:I,edgeHandleRadius:B,cursorStyle:"ns-resize",color:t,strokeWidth:E}):void 0,s?void 0:(0,r.jsx)(en,{x:n-w/2,y:e/2-Math.min(l,.8*e)/2,width:w,height:Math.min(l,.8*e),onPointerDown:u,edgeHandleRadius:B,cursorStyle:"ew-resize",color:t,strokeWidth:E}),F&&!c?(0,r.jsx)(en,{x:n/2-l/2,y:-w/2,width:l,height:w,onPointerDown:D,edgeHandleRadius:B,cursorStyle:"ns-resize",color:t,strokeWidth:E}):void 0]})},an=A=>{const{color:t,elementWidth:e,onBeginRotate:n,scaleFactor:i}=A,a=(0,Q.useCallback)((A=>{A.stopPropagation(),n()}),[n]),o=10*i,s=1.2*i;return(0,r.jsxs)("g",{children:[(0,r.jsx)("circle",{cx:e/2,cy:-2.5*o,r:1.3*o,fill:"rgba(0, 0, 0, 0.5)",opacity:.4,style:{cursor:"ew-resize"},onPointerDown:a}),(0,r.jsx)("circle",{cx:e/2,cy:-2.5*o,r:o,fill:"#fff",style:{cursor:"ew-resize"},stroke:t,strokeWidth:s,onPointerDown:a}),(0,r.jsxs)("svg",{x:e/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,fill:t,onPointerDown:a,children:[(0,r.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,r.jsx)("path",{d:"M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z"})]})]})},on=A=>{const{color:t,height:e,highlighted:n,id:i,immutable:a,onBeginMove:o,onBeginResize:s,onBeginRotate:c,onPointerEnter:g,onPointerLeave:B,onSelected:l,pressed:w,rotation:E,scaleFactor:h,selected:d,width:C,x:u,y:D,disableX:I,disableY:p}=A,f=1.2*h,m=(0,Q.useCallback)((A=>{2===A.button&&(A.stopPropagation(),l(i,A)),0===A.button&&(A.stopPropagation(),!d&&l(i,A),o())}),[i,d,l,o]),M=(0,Q.useCallback)((()=>{g(i)}),[i,g]),F=(0,Q.useCallback)((()=>{B(i)}),[i,B]),y=a?void 0:d?w?"grabbing":"grab":"pointer",Y=a?"none":"visibleFill";return(0,r.jsxs)("g",{transform:`translate(${u}, ${D}) rotate(${E} ${C/2} ${e/2})`,children:[(0,r.jsx)("rect",{className:"interactableInnerRect",width:C,height:e,stroke:d||n?t:"none",pointerEvents:Y,fill:"none",strokeWidth:f,style:{cursor:y},onPointerDown:a?void 0:m,onPointerEnter:a?void 0:M,onPointerLeave:a?void 0:F}),d&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(an,{color:t,elementWidth:C,onBeginRotate:c,scaleFactor:h}),(0,r.jsx)(nn,{color:t,elementHeight:e,elementWidth:C,rotation:E,scaleFactor:h,onBeginResize:s,disableX:I,disableY:p})]})]})},sn=({primaryColor:A,containerHeight:t,containerWidth:e,customViewbox:n,editorRef:i,elementEvent:a,guidelines:o,layoutHeight:s,layoutWidth:c,targetedElements:g,scale:B,selectedElement:l,onElementEvent:w,onElementSelected:E,onSequenceStart:h})=>{const{state:d}=be(),{getLayoutById:C}=Se(),u=C(d.layoutId),[D,I]=(0,Q.useState)(void 0),p=(0,Q.useCallback)((A=>{I(A)}),[]),f=(0,Q.useCallback)((A=>{D===A&&I(void 0)}),[D]),m=(0,Q.useCallback)((()=>{h(),w({type:je.Translate})}),[w]),M=(0,Q.useCallback)(((A,t)=>{h(),w({type:je.Resize,relativeAxis:A,screenAxis:t})}),[w]),F=(0,Q.useCallback)((()=>{h(),w({type:je.Rotate})}),[w]),y=n||{x:0,y:0,width:c,height:s},Y=B*(Math.sqrt(y.width*y.height)/1e3)*(100/Math.sqrt(t*e))*Math.sqrt((x=e/t,Math.exp(Math.abs(Math.log(x)))));var x;const N=u.layoutState.elements.findIndex((({id:A})=>A===l)),H=[...u.layoutState.elements];return N>=0&&H.push(H.splice(N,1)[0]),(0,r.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%"},width:"100%",height:"100%",viewBox:`${y.x} ${y.y} ${y.width} ${y.height}`,overflow:"overlay",children:[(0,r.jsx)("rect",{fill:"none",stroke:"none",ref:i,width:c,height:s}),o.map((A=>A.svgNode)),H.map((t=>{const e=void 0!==l&&t.id===l,n=e&&void 0!==a,i=void 0!==D&&t.id===D;return(0,r.jsx)(on,{color:A,id:t.id,selected:e,highlighted:i,pressed:n,x:t.x,y:t.y,disableX:t.type===U.Frame,disableY:t.type===U.Textbox||t.type===U.Frame,width:t.width,height:t.height,rotation:t.rotation,immutable:t.immutable||g&&!g.includes(t.id),onSelected:E,onBeginMove:m,onBeginResize:M,onBeginRotate:F,onPointerEnter:p,onPointerLeave:f,scaleFactor:Y},t.id)}))]})},rn=A=>{const{color:t,editorRef:e,zoomableElementRef:n,interactionElementRef:i,guidelines:a,isMakingAdjustments:o,viewmask:s,visibleLayoutId:c,xTranslation:g,yTranslation:B,targetedElements:l,borderRadius:w,handleContextMenu:E,handleKeyDown:h,handleKeyUp:d,handlePointerMove:C,handlePointerPressedBackground:u,handlePointerReleased:D,handleScroll:I,onSequenceStart:p,setElementEvent:f,onElementSelected:m}=A,{getLayoutById:M}=Se(),F=M(c),y=F.layoutState,{state:Y}=be(),x=(0,Q.useCallback)((A=>{if(s){const t={left:s.x,top:s.y,width:s.width,height:s.height,panelId:"",rotation:0};return h(A,t)}return h(A)}),[h,s]),N=(0,Q.useCallback)((A=>{if(s){const t={left:s.x,top:s.y,width:s.width,height:s.height,panelId:"",rotation:0};return C(A,t)}return C(A)}),[C,s]);return(0,r.jsx)("div",{style:{justifyContent:"center",position:"relative",height:"100%",width:"100%",scrollbarWidth:"none",outline:"none"},onContextMenu:E,onKeyDown:x,onKeyUp:d,onPointerDown:u,onPointerMoveCapture:N,onPointerUp:D,onWheelCapture:I,ref:i,tabIndex:-1,children:(0,r.jsxs)("div",{ref:n,style:{height:"100%",transform:`scale(${Y.zoom}) translate(${g}px, ${B}px)`,display:"grid",filter:"drop-shadow(rgba(0, 0, 0, 0.2) 0px 0px 6px)"},children:[A.children,F.getComponentWithProps({height:o?"100%":"auto",maxHeight:"100%",maxWidth:"100%",position:"absolute",viewmask:s,width:o?"100%":"auto",borderRadius:w}),(0,r.jsx)(sn,{primaryColor:t,containerHeight:n.current?.offsetHeight||1024,containerWidth:n.current?.offsetWidth||1024,editorRef:e,elementEvent:Y.elementEvent,guidelines:a,layoutHeight:y.layout.height,layoutWidth:y.layout.width,onElementEvent:f,onSequenceStart:p,onElementSelected:m,scale:10/Y.zoom,selectedElement:Y.selectedElement,targetedElements:l})]})})},cn=({color:A,borderRadius:t,guidelineColor:e,handleContextMenu:n,onElementSelected:i})=>{const{commandDispatcher:a,getLayoutById:o}=Se(),{state:s,uiDispatcher:c}=be(),g=(0,Q.useRef)(null),B=(0,Q.useRef)(null),l=(0,Q.useRef)(null),{guidelines:w,handleKeyDown:E,handleKeyUp:h,handlePointerMove:d,handlePointerPressedBackground:C,handlePointerReleased:u,handleScroll:D,handleSequenceStart:I,setElementEvent:p}=An(g,B,l,void 0,"advanced",a,e),f=(0,Q.useCallback)(((A,t)=>{const e=o(s.layoutId).layoutState.elements.find((t=>t.id===A));if(A&&e&&e.type===U.Textbox){const t=e.algorithm;(!t||t===P.Autosize)&&a(new Jt(A,P.Traditional))}i&&i(A,t),c(new Je({selectedElement:A}))}),[a,o,s.layoutId,c]);return(0,r.jsx)(rn,{color:A,editorRef:g,interactionElementRef:B,zoomableElementRef:l,guidelines:w,visibleLayoutId:s.layoutId,xTranslation:0,yTranslation:0,borderRadius:t,handleContextMenu:n,handleKeyDown:E,handleKeyUp:h,handlePointerMove:d,handlePointerPressedBackground:C,handlePointerReleased:u,handleScroll:D,onSequenceStart:I,setElementEvent:p,onElementSelected:f})};class gn{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 Bn{constructor(){var A,t,e;A=this,t="storage",e=new Map,t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e}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 ln=(()=>{try{return localStorage?new gn:new Bn}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new Bn}})(),wn=w.gql`
2
2
  mutation CreateTransaction($integrationProductId: String!, $bulk: Boolean) {
3
3
  transactionCreate(integrationProductId: $integrationProductId, bulk: $bulk) {
4
4
  id
package/dist/module.js CHANGED
@@ -1,4 +1,4 @@
1
- import{CommandContext as A,AssetType as t,BringForwardCommand as e,CanvasCommand as n,CreateElementCommand as a,CreateLayoutCommand as i,DeleteElementCommand as s,FontAlignmentCommand as o,FontColorCommand as c,FontSizeCommand as r,FontSourceCommand as g,GroupCommand as B,LayoutElementFactory as w,LayoutElementType as E,MoveCommand as l,ResizeCommand as Q,RotateCommand as C,SendBackwardsCommand as h,StepAspectType as d,StepType as D,TextChangeCommand as I,UnitOfMeasurement as u,dataUrlFromExternalUrl as p,findElement as f,frameDataCache as m,generate as M,generateSVGWithUnknownColors as F,getAttributesFromArrayBuffer as Y,rehydrateSerializedLayout as y,getFrameData as N,getSvgString as x,loadFontFromDataUrl as H,loadFontFromExternalUrl as R,determineCorrectFontSizeAndLines as U,patternImageDataCache as S,registerJSDOM as G,TextAlgorithm as v,FontAlgorithmCommand as P,getAxisAlignedBoundingBox as J,isCloseToValue as k,mmPerPixel as L,cmPerPixel as O,ScaleAxis as b,getElementVertices as z,rotateAroundPoint as T,calculateTextboxLines as K,defaultLineHeightFactor as j,findAngle as V,currentDirection as W,modifySVGWithElementProperties as X,IllustrationColorCommand as q,IllustrationCacheCommand as Z,getFontMetrics as $,applyTextTransformations as _,UpdateWorkflowStateCommand as AA,calculateOffsets as tA,UpdateFramePattern as eA,generateDefaultRectangleFrameSvg as nA,fetchAsString as aA,GetSVGDimensions as iA,ShiftPatchworkCommand as sA,Patchwork as oA,sanitizeSvgTree as cA,createElementNS as rA,createElement as gA,sortElementsByLayersWithIndex as BA,toBase64 as wA,getPatternImageData as EA,getVariant as lA,generateFrameSVG as QA,getDefaultVariant as CA,domParser as hA,traverse as dA,xmlSerializer as DA,fetchAsArrayBuffer as IA,arrayBufferToDataUrl as uA,loadFontFaceSet as pA}from"@spiffcommerce/papyrus";import fA from"swagger-client";import{createHttpLink as mA,InMemoryCache as MA,ApolloClient as FA,from as YA,gql as yA}from"@apollo/client";import{setContext as NA}from"@apollo/client/link/context";import{onError as xA}from"@apollo/client/link/error";import{fetch as HA}from"cross-fetch";import{createContext as RA,useContext as UA,useEffect as SA,useState as GA,useReducer as vA,useMemo as PA,useRef as JA,useCallback as kA}from"react";import{jsx as LA,jsxs as OA,Fragment as bA}from"react/jsx-runtime";import zA from"lodash.isequal";import{Canvg as TA}from"canvg";import KA from"lodash.clonedeep";import jA from"lodash.debounce";import{toString as VA}from"qrcode";import WA from"react-dom/server";import XA from"svg-path-bbox";function qA(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const ZA=new class{constructor(){qA(this,"defaultServerUrl","https://api.spiff.com.au"),qA(this,"defaultServicesApiUrl","https://services.spiff.com.au"),qA(this,"defaultHubUrl","https://hub.spiff.com.au"),qA(this,"serverUrl",void 0),qA(this,"servicesApiUrl",void 0),qA(this,"hubUrl",void 0),qA(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 $A(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let _A;const At=A=>{_A=A},tt=async()=>{const A={transactionOwnerId:_A};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=ZA.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 et=new class{constructor(){$A(this,"client",void 0),$A(this,"uncachedOperations",[]),ZA.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((a=>{a.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 tt();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 tt(),t=ZA.getServerUrl()+"/v2/api-docs";return await fA(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const nt=new class{constructor(){$A(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),ZA.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=mA({uri:`${ZA.getServerUrl()}/graphql`,fetch:HA}),t=NA((async(A,{headers:t})=>{const e=t||{},n=await tt();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=xA((({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 MA({typePolicies:{Transaction:{fields:{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}}}}});return new FA({link:YA([e,t,A]),cache:n,name:"Core"})}};function at(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const it=new class{constructor(){at(this,"server",void 0),at(this,"cache",new Map),at(this,"materialCache",new Map),at(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await Y(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)}})),this.server=et}async getLocalOrFromServer(A){if(this.cache.has(A))return this.cache.get(A);const t=(async()=>(await et.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 et.execute("getMaterialV2",{id:A})).body)();return this.materialCache.set(A,t),t}async uploadAssetWithProgress(A,t,e,n,a,i){const s=await this.dispatchCreateAssetRequest(A,t,a,i);var o=new XMLHttpRequest;return o.open("PUT",s.assetResponse.uploadUrl,!0),o.setRequestHeader("Content-Type",s.mimeType),o.setRequestHeader("Cache-Control","public,max-age=31536000,immutable"),o.upload.onprogress=A=>{A.lengthComputable&&e(100*A.loaded/A.total)},o.onload=()=>{const A=s.assetResponse.asset;n(A)},o.onerror=()=>{console.warn("Asset upload failed")},o.send(A.blob),s.assetResponse.asset}async dispatchCreateAssetRequest(A,t,e,n){const a=A.blob.type?A.blob.type:this.guessMIME(A.name);return{assetResponse:(await this.server.execute("createAsset",{assetDetails:{name:A.name,type:t,mimeType:a,storageOwnerId:n,userAnonymous:!0}},e)).body,mimeType:a}}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 Error("Unexpected mimetype: "+t)}}};function st(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const ot=new class{constructor(){st(this,"cache",new Map),st(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),st(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),st(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[]))}async cacheRequiredOptions(A){const t=A.steps.map((A=>A.optionId)).filter((A=>void 0!==A)),e=A.steps.map((A=>A.data.colourOptionId)).filter((A=>void 0!==A)),n=[...new Set([...t,...e])].map((async A=>{const t=await ot.getLocalOrFromServer(et,A);"Font"===t.data.type&&t.data.variants.forEach((async A=>{if(A.assetKey){const t=(await it.getLocalOrFromServer(A.assetKey)).links.find((A=>"cdn"===A.rel))?.href;t&&await R(t)}}))}));await Promise.allSettled([...n])}async getLocalOrFromServer(A,t){if(this.cache.has(t))return this.cache.get(t);const e=(await A.execute("getOptionV2",{id:t})).body;return this.cache.set(t,e),e}getLocalOrUndefined(A){if(A)return this.cache.get(A)}async getAssetTileImageForVariant(A){if(A.thumbnailKey){const t=await it.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 it.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}},ct=RA(new A),rt=()=>{const A=UA(ct);SA((()=>{A.registerStateCallback((()=>{e(new Date)}))}),[A]);const[t,e]=GA(new Date);return{commandDispatcher:t=>{A.apply(t)},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)}}};let gt;var Bt;(Bt=gt||(gt={})).None="None",Bt.FrameAdjustment="FrameAdjustment",Bt.FinalizeDesign="FinalizeDesign";const wt=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,maxZoom:5,units:u.Pixel,subMenu:gt.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),Et=(A,t)=>zA(A,t.apply(A))?A:t.apply(A),lt=RA({}),Qt=A=>{const{getAllLayouts:t}=rt(),[e,n]=vA(Et,wt(t,A.defaultZoom||1)),a=PA((()=>({state:e,uiDispatcher:n})),[e,n]);return LA(lt.Provider,{value:a,children:A.children})};class Ct{constructor(A){var t,e,n;n=void 0,(e="changes")in(t=this)?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,this.changes=A}apply(A){return{...A,...this.changes}}}const ht=()=>UA(lt);let dt;var Dt;(Dt=dt||(dt={}))[Dt.Orbit=0]="Orbit",Dt[Dt.Pan=1]="Pan";const It=(A,t,e,n)=>{const a=t.layout.width,i=t.layout.height,s=t.elements.filter((t=>t.id!==A.id&&!t.immutable&&!t.productOverlay)),o=s.map((A=>J(A.x,A.y,A.width,A.height,A.rotation))),c=[],r=new Set;o.forEach((A=>r.add(A.minX))),o.forEach((A=>r.add(A.maxX))),[0,a/2,a].forEach((A=>r.add(A)));const g=new Set;o.forEach((A=>g.add(A.minY))),o.forEach((A=>g.add(A.maxY))),[0,i/2,i].forEach((A=>g.add(A)));const B=s.map((A=>A.y));for(let A=-315;A<=315;A+=45)B.push(A);const w=J(A.x,A.y,A.width,A.height,A.rotation),E=[{value:w.minX,anchor:-1},{value:w.minX+(w.maxX-w.minX)/2,anchor:0},{value:w.minX+(w.maxX-w.minX),anchor:1}],l=[{value:w.minY,anchor:-1},{value:w.minY+(w.maxY-w.minY)/2,anchor:0},{value:w.minY+(w.maxY-w.minY),anchor:1}],Q=[{value:A.rotation,anchor:0}],C=(A,t,n,s)=>{const o=[];return t.forEach((t=>{const c=n.find((A=>k(t,A.value,2*e))),[r,g]=((A,t)=>[{x:"x"===A?t:0,y:"x"===A?0:t},{x:"x"===A?t:a,y:"x"===A?i:t}])(A,t),B="rotation"===A?null:LA("line",{x1:r.x,y1:r.y,x2:g.x,y2:g.y,stroke:s||"#D61B5C",strokeDasharray:5*e,strokeWidth:1.2*e,overflow:"overlay"},`${A}-${t}-${r.x}-${r.y}-${g.x}-${g.y}`);void 0!==c&&o.push({type:A,value:t,anchorPoint:c.anchor,svgNode:B,guidelineCoordinates:[r,g]})})),o};return c.push(...C("x",Array.from(r),E,n)),c.push(...C("y",Array.from(g),l,n)),c.push(...C("rotation",B,Q,n)),c};let ut;var pt;let ft;var mt;(pt=ut||(ut={})).Translate="Translate",pt.Rotate="Rotate",pt.Resize="Resize",(mt=ft||(ft={})).ControlLeft="ControlLeft",mt.ControlRight="ControlRight",mt.Equal="Equal",mt.MetaLeft="MetaLeft",mt.MetaRight="MetaRight",mt.Minus="Minus",mt.ArrowLeft="ArrowLeft",mt.ArrowRight="ArrowRight",mt.ArrowUp="ArrowUp",mt.ArrowDown="ArrowDown",mt.AltLeft="AltLeft",mt.AltRight="AltRight",mt.Delete="Delete",mt.Backspace="Backspace";const Mt=(A,t,e,n)=>{const a=()=>{switch(e){case u.Pixel:return 1;case u.Millimeter:return L;case u.Centimeter:return O;default:throw new Error("Unknown unit of measurement")}};let i=t.x,s=t.y,o=t.x,c=t.y;switch(A){case ft.ArrowLeft:o=t.x-1/a();break;case ft.ArrowUp:c=t.y-1/a();break;case ft.ArrowRight:o=t.x+1/a();break;case ft.ArrowDown:c=t.y+1/a();break;default:throw new Error("Unhandled element interaction!")}const r=J(o,c,t.width,t.height,t.rotation);return(!n||r.minX>=n.left&&r.maxX<=n.left+n.width&&r.minY>=n.top&&r.maxY<=n.top+n.height)&&(i=o,s=c),new l(t.id,i,s)};var Ft=0,Yt=0,yt=0;const Nt=(A,t,e,n,a,i,s)=>{const o=((A,t,e,n,a,i,s)=>{const o=n.width/t.width,c=n.height/t.height,r=A.movementX/o,g=A.movementY/c,B=e.rotation*Math.PI/180,w=Math.sin(B),l=Math.cos(B);let Q;switch(a.type){case ut.Resize:let t={top:e.y,left:e.x,width:e.width,height:e.height,rotation:e.rotation,fontSize:e.fontSize},C=t;switch(a.screenAxis){case b.North:{const A=-r*w+g*l,n=e.y+A,a=e.height-A,i=z({...e}).center,s=z({...e,y:n,height:a}).center,o=T(s,i,B),c=o.x-e.width/2,E=o.y-a/2;C={...t,left:c,top:E,height:a}}break;case b.East:{const A=r*l+g*w,n=e.width+A;let a=e.height;if(e.type===E.Textbox){const A=e;a=K(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const i=z({...e}).center,s=z({...e,width:n,height:a}).center,o=T(s,i,B),c=o.x-n/2,Q=o.y-a/2;C={...t,left:c,top:Q,width:n,height:a}}break;case b.West:{const A=r*l+g*w,n=e.x+A,a=e.width-A;let i=e.height;if(e.type===E.Textbox){const A=e;i=K(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const s=z({...e}).center,o=z({...e,width:a,height:i,x:n}).center,c=T(o,s,B),Q=c.x-a/2,h=c.y-i/2;C={...t,left:Q,top:h,width:a,height:i}}break;case b.South:{const A=-r*w+g*l,n=e.height+A,a=z({...e}).center,i=z({...e,height:n}).center,s=T(i,a,B),o=s.x-e.width/2,c=s.y-n/2;C={...t,left:o,top:c,height:n}}break;case b.Northeast:{const A=r*l+g*w,n=e.width+A;let a=e.height+A,i=e.y-A,s=e.fontSize;if(e.type===E.Textbox){const t=e;s=t.fontSize+A/8,a=K(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||j;i=e.y-A*n/8}const o=z({...e}).center,c=z({...e,width:n,height:a,y:i}).center,Q=T(c,o,B),h=Q.x-n/2,d=Q.y-a/2;C={...t,left:h,top:d,width:n,height:a,fontSize:s}}break;case b.Northwest:{const A=-r*l+-g*w,n=e.x-A,a=e.width+A;let i=e.y-A,s=e.height+A,o=e.fontSize;if(e.type===E.Textbox){const t=e;o=t.fontSize+A/8,s=K(o,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||j;i=e.y-A*n/8}const c=z({...e}).center,Q=z({...e,x:n,y:i,width:a,height:s}).center,h=T(Q,c,B),d=h.x-a/2,D=h.y-s/2;C={...t,left:d,top:D,width:a,height:s,fontSize:o}}break;case b.Southeast:{const A=r*l+g*w,n=e.width+A;let a=e.height+A,i=e.fontSize;if(e.type===E.Textbox){const t=e;i=t.fontSize+A/8,a=K(i,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const s=z({...e}).center,o=z({...e,width:n,height:a}).center,c=T(o,s,B),Q=c.x-n/2,h=c.y-a/2;C={...t,left:Q,top:h,width:n,height:a,fontSize:i}}break;case b.Southwest:{const A=-r*l+-g*w,n=e.width+A;let a=e.x-A,i=e.height+A,s=e.fontSize;if(e.type===E.Textbox){const t=e;s=t.fontSize+A/8,i=K(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const o=z({...e}).center,c=z({...e,width:n,height:i,x:a}).center,Q=T(c,o,B),h=Q.x-n/2,d=Q.y-i/2;C={...t,left:h,top:d,width:n,height:i,fontSize:s}}}return Q=J(C.left,C.top,C.width,C.height,C.rotation),(!s||Q.minX>=s.left&&Q.maxX<=s.left+s.width&&Q.minY>=s.top&&Q.maxY<=s.top+s.height)&&(t=C),t;case ut.Rotate:const h={x:A.clientX,y:A.clientY};let d,D=e.rotation;const I=z(e,n,{x:o,y:c}),u=V(h,I.c,I.d),p=V(h,I.d,I.c);if(0===i.filter((A=>"rotation"===A.type)).length)yt=0,d=(e.rotation+u-p)%360;else{yt+=Math.sqrt(r**2+g**2);const A=Math.abs(yt)>7*window.devicePixelRatio/o;d=A?(e.rotation+u-p)%360:i.find((A=>"rotation"===A.type))?.value||0,A&&(yt=0)}return Q=J(e.x,e.y,e.width,e.height,d),(!s||Q.minX>=s.left&&Q.maxX<=s.left+s.width&&Q.minY>=s.top&&Q.maxY<=s.top+s.height)&&(D=d),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:D};case ut.Translate:let f,m,M=e.x,F=e.y;if(0===i.filter((A=>"rotation"!==A.type)).length)Ft=0,Yt=0,f=e.x+r,m=e.y+g;else{const A=i.find((A=>"x"===A.type)),t=i.find((A=>"y"===A.type));A||(Ft=0),t||(Yt=0);const n=Math.abs(Ft)>7*window.devicePixelRatio/o,a=Math.abs(Yt)>7*window.devicePixelRatio/c;f=A?n?e.x+Ft:e.x:e.x+r,m=t?a?e.y+Yt:e.y:e.y+g,Ft=n?0:Ft+r,Yt=a?0:Yt+g}return Q=J(f,m,e.width,e.height,e.rotation),(!s||Q.minX>=s.left&&Q.maxX<=s.left+s.width&&Q.minY>=s.top&&Q.maxY<=s.top+s.height)&&(M=f,F=m),{top:F,left:M,width:e.width,height:e.height,rotation:e.rotation}}})(A,t,e,n,a,i,s),c=[];if(e.type===E.Textbox){const A=e;c.push(new I(A.id,A.text||A.input||""))}if(c.push(new l(e.id,o.left,o.top),new Q(e.id,o.width,o.height),new C(e.id,o.rotation)),e.type===E.Textbox){const A=e;o.fontSize&&A.fontSize!==o.fontSize&&c.push(new r(A.id,o.fontSize))}return c},xt=.5,Ht=(A,t,e,n,a,i,o)=>{const{state:c,uiDispatcher:r}=UA(lt),{getLayoutById:g,getReducerState:w,flattenSequence:E}=rt(),[l,Q]=GA(void 0),[C,h]=GA(void 0),d=g(c.layoutId);SA((()=>{if("adjustment"===a&&A?.current&&n){if(n<.5)return void r(new Ct({zoom:.5}));if(n>c.maxZoom)return void r(new Ct({zoom:c.maxZoom}));r(new Ct({zoom:n}))}}),[n,r,A,a,c.maxZoom]);const D=kA(((A,n)=>{r(new Ct({zoom:n}));const i=t?.current?.scrollWidth-t?.current?.clientWidth!=0,s=t?.current?.scrollHeight-t?.current?.clientHeight!=0;t.current&&e.current&&!c.scrolledMovement&&"advanced"===a&&(s&&(t.current.scrollTop=e.current.offsetTop+(t.current.scrollHeight-t.current.clientHeight)/2),i&&(t.current.scrollLeft=(e.current.offsetLeft+t.current.scrollWidth-t.current.clientWidth)/2))}),[r,t,e,c.scrolledMovement,a]);SA((()=>{c.zoom<=1&&r(new Ct({scrolledMovement:!1}))}),[r,c.zoom]);const I=t?.current?.getBoundingClientRect(),u=((I?.width||1)+(I?.height||1))/2,p=(d.layoutState.layout.width+d.layoutState.layout.height)/2/u/c.zoom,f=PA((()=>{const A=c.activeModifierKeys,t=c.elementEvent,e=A.includes(ft.ControlLeft)||A.includes(ft.MetaLeft)||A.includes(ft.ControlRight)||A.includes(ft.MetaRight);if(!c.selectedElement||!t||e)return[];const n=t&&t.type===ut.Translate,a=t&&t.type===ut.Rotate,i=d.layoutState.elements.find((A=>A.id===c.selectedElement));return(n||a)&&i?It(i,d.layoutState,p,o):[]}),[c.selectedElement,c.elementEvent,c.activeModifierKeys,d.layoutState,p]),m=kA((()=>{const A=M();Q(A),h(w().transaction)}),[w]),F=kA((()=>{r(new Ct({selectedElement:void 0}))}),[r]),Y=kA((()=>{r(new Ct({scrolledMovement:!0}))}),[r]),y=kA(((e,n)=>{const a=d.layoutState.elements.find((A=>A.id===c.selectedElement));if(!(c.elementEvent&&A.current&&t.current&&c.selectedElement&&a))return;t.current.hasPointerCapture(e.pointerId)||t.current.setPointerCapture(e.pointerId);const s=A.current.getBoundingClientRect(),o=new B(Nt(e,d.layoutState.layout,a,s,c.elementEvent,f,n));o.sequenceId=l,i(o)}),[d.layoutState.elements,d.layoutState.layout,c.elementEvent,A,c.selectedElement,t,f,i]),N=kA((A=>{r(new Ct({elementEvent:A}))}),[r]),x=kA((()=>{r(new Ct({elementEvent:void 0})),l&&C&&(E(l,C),Q(void 0),h(void 0))}),[r,l,C,E]),H=kA(((A,t)=>{let e=c.zoom;const n=c.maxZoom,o=c.selectedElement,g=c.activeModifierKeys;if((g.includes(ft.AltLeft)||g.includes(ft.AltRight))&&(A.code===ft.Equal||A.code===ft.Minus)){const t=.05*n;A.code===ft.Equal?r(new Ct({zoom:e+t<=n?e+=t:e})):r(new Ct({zoom:e-t>=.5?e-t:e}))}const B=d.layoutState.elements.find((A=>A.id===o));if(o&&B){if(A.code===ft.MetaLeft||A.code===ft.ControlLeft||A.code===ft.MetaRight||A.code===ft.ControlRight){const t=A.code,e=c.activeModifierKeys;if(!e.includes(t))return r(new Ct({activeModifierKeys:e.concat(t)}))}if(A.code===ft.ArrowDown||A.code===ft.ArrowUp||A.code===ft.ArrowLeft||A.code===ft.ArrowRight){r(new Ct({elementEvent:{type:ut.Translate}}));const e=Mt(A.code,B,c.units,t);i(e),r(new Ct({elementEvent:void 0}))}A.code!==ft.Delete&&A.code!==ft.Backspace||"advanced"!==a||(r(new Ct({selectedElement:void 0})),i(new s(B.id)))}}),[i,r,d.layoutState.elements,a,c.activeModifierKeys,c.maxZoom,c.selectedElement,c.units,c.zoom]),R=kA((A=>{if(A.code===ft.MetaLeft||A.code===ft.ControlLeft||A.code===ft.MetaRight||A.code===ft.ControlRight){const t=c.activeModifierKeys,e=A.code;r(new Ct({activeModifierKeys:t.filter((A=>A!==e))}))}}),[r,c.activeModifierKeys]);return{guidelines:f,scale:p,zoomableElementRef:e,setElementEvent:N,handleZoom:D,handleKeyDown:H,handleKeyUp:R,handlePointerPressedBackground:F,handlePointerReleased:x,handlePointerMove:y,handleScroll:Y,handleSequenceStart:m}},Rt=A=>{const{x:t,y:e,cursorStyle:n,onPointerDown:a,handleClass:i,cornerRadius:s,color:o,strokeWidth:c}=A;return LA("circle",{className:i,cx:t,cy:e,r:s,fill:"#ffffff",style:{cursor:n},stroke:o,strokeWidth:c,onPointerDown:a})},Ut=A=>{const{x:t,y:e,width:n,height:a,cursorStyle:i,onPointerDown:s,edgeHandleRadius:o,color:c,strokeWidth:r}=A;return LA("rect",{x:t,y:e,width:n,height:a,rx:o,fill:"#ffffff",style:{cursor:i},stroke:c,strokeWidth:r,onPointerDown:s})},St=A=>{const{color:t,elementHeight:e,elementWidth:n,onBeginResize:a,rotation:i,scaleFactor:s,disableX:o,disableY:c}=A,r=7.5*s,g=3*s,B=28*s,w=6*s,E=1.2*s,l=e-2*r,Q=kA(((A,t,e)=>{A.stopPropagation(),a(t,e)}),[a]),C=kA((A=>Q(A,W(b.West,360-i),b.West)),[Q,i]),h=kA((A=>Q(A,W(b.East,360-i),b.East)),[Q,i]),d=kA((A=>Q(A,W(b.North,360-i),b.North)),[Q,i]),D=kA((A=>Q(A,W(b.South,360-i),b.South)),[Q,i]),I=kA((A=>Q(A,b.Northwest,b.Northwest)),[Q]),u=kA((A=>Q(A,b.Northeast,b.Northeast)),[Q]),p=kA((A=>Q(A,b.Southwest,b.Southwest)),[Q]),f=kA((A=>Q(A,b.Northeast,b.Southeast)),[Q]),m=B<=l;return OA(bA,{children:[LA(Rt,{x:0,y:0,cursorStyle:"nwse-resize",onPointerDown:I,handleClass:"cornerNorthWest",cornerRadius:r,color:t,strokeWidth:E}),m?LA(Rt,{x:n,y:0,cursorStyle:"nesw-resize",onPointerDown:u,handleClass:"cornerNorthEast",cornerRadius:r,color:t,strokeWidth:E}):void 0,m?LA(Rt,{x:n,y:e,cursorStyle:"nwse-resize",onPointerDown:f,handleClass:"cornerSouthEast",cornerRadius:r,color:t,strokeWidth:E}):void 0,m?LA(Rt,{x:0,y:e,cursorStyle:"nesw-resize",onPointerDown:p,handleClass:"cornerSouthWest",cornerRadius:r,color:t,strokeWidth:E}):void 0,m&&!o?LA(Ut,{x:-w/2,y:e/2-B/2,width:w,height:B,onPointerDown:C,edgeHandleRadius:g,cursorStyle:"ew-resize",color:t,strokeWidth:E}):void 0,m&&!c?LA(Ut,{x:n/2-B/2,y:e-w/2,width:B,height:w,onPointerDown:D,edgeHandleRadius:g,cursorStyle:"ns-resize",color:t,strokeWidth:E}):void 0,o?void 0:LA(Ut,{x:n-w/2,y:e/2-Math.min(B,.8*e)/2,width:w,height:Math.min(B,.8*e),onPointerDown:h,edgeHandleRadius:g,cursorStyle:"ew-resize",color:t,strokeWidth:E}),m&&!c?LA(Ut,{x:n/2-B/2,y:-w/2,width:B,height:w,onPointerDown:d,edgeHandleRadius:g,cursorStyle:"ns-resize",color:t,strokeWidth:E}):void 0]})},Gt=A=>{const{color:t,elementWidth:e,onBeginRotate:n,scaleFactor:a}=A,i=kA((A=>{A.stopPropagation(),n()}),[n]),s=10*a,o=1.2*a;return OA("g",{children:[LA("circle",{cx:e/2,cy:-2.5*s,r:1.3*s,fill:"rgba(0, 0, 0, 0.5)",opacity:.4,style:{cursor:"ew-resize"},onPointerDown:i}),LA("circle",{cx:e/2,cy:-2.5*s,r:s,fill:"#fff",style:{cursor:"ew-resize"},stroke:t,strokeWidth:o,onPointerDown:i}),OA("svg",{x:e/2-s,y:-2.5*s-s,xmlns:"http://www.w3.org/2000/svg",style:{cursor:"ew-resize"},height:2*s,viewBox:"0 0 24 24",width:2*s,fill:t,onPointerDown:i,children:[LA("path",{d:"M0 0h24v24H0z",fill:"none"}),LA("path",{d:"M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z"})]})]})},vt=A=>{const{color:t,height:e,highlighted:n,id:a,immutable:i,onBeginMove:s,onBeginResize:o,onBeginRotate:c,onPointerEnter:r,onPointerLeave:g,onSelected:B,pressed:w,rotation:E,scaleFactor:l,selected:Q,width:C,x:h,y:d,disableX:D,disableY:I}=A,u=1.2*l,p=kA((A=>{2===A.button&&(A.stopPropagation(),B(a,A)),0===A.button&&(A.stopPropagation(),!Q&&B(a,A),s())}),[a,Q,B,s]),f=kA((()=>{r(a)}),[a,r]),m=kA((()=>{g(a)}),[a,g]);return OA("g",{transform:`translate(${h}, ${d}) rotate(${E} ${C/2} ${e/2})`,children:[LA("rect",{className:"interactableInnerRect",width:C,height:e,stroke:Q||n?t:"none",pointerEvents:i?"none":"visibleFill",fill:"none",strokeWidth:u,strokeDasharray:n&&!Q?u:void 0,style:{cursor:i?void 0:Q?w?"grabbing":"grab":"pointer"},onPointerDown:i?void 0:p,onPointerEnter:i?void 0:f,onPointerLeave:i?void 0:m}),Q&&OA(bA,{children:[LA(Gt,{color:t,elementWidth:C,onBeginRotate:c,scaleFactor:l}),LA(St,{color:t,elementHeight:e,elementWidth:C,rotation:E,scaleFactor:l,onBeginResize:o,disableX:D,disableY:I})]})]})},Pt=({primaryColor:A,containerHeight:t,containerWidth:e,customViewbox:n,editorRef:a,elementEvent:i,guidelines:s,layoutHeight:o,layoutWidth:c,targetedElements:r,scale:g,selectedElement:B,onElementEvent:w,onElementSelected:l,onSequenceStart:Q})=>{const{state:C}=ht(),{getLayoutById:h}=rt(),d=h(C.layoutId),[D,I]=GA(void 0),u=kA((A=>{I(A)}),[]),p=kA((A=>{D===A&&I(void 0)}),[D]),f=kA((()=>{Q(),w({type:ut.Translate})}),[w]),m=kA(((A,t)=>{Q(),w({type:ut.Resize,relativeAxis:A,screenAxis:t})}),[w]),M=kA((()=>{Q(),w({type:ut.Rotate})}),[w]),F=n||{x:0,y:0,width:c,height:o},Y=g*(Math.sqrt(F.width*F.height)/1e3)*(100/Math.sqrt(t*e))*Math.sqrt((y=e/t,Math.exp(Math.abs(Math.log(y)))));var y;const N=d.layoutState.elements.findIndex((({id:A})=>A===B)),x=[...d.layoutState.elements];return N>=0&&x.push(x.splice(N,1)[0]),OA("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%"},width:"100%",height:"100%",viewBox:`${F.x} ${F.y} ${F.width} ${F.height}`,overflow:"overlay",children:[LA("rect",{fill:"none",stroke:"none",ref:a,width:c,height:o}),s.map((A=>A.svgNode)),x.map((t=>{const e=void 0!==B&&t.id===B,n=e&&void 0!==i,a=void 0!==D&&t.id===D;return LA(vt,{color:A,id:t.id,selected:e,highlighted:a,pressed:n,x:t.x,y:t.y,disableX:t.type===E.Frame,disableY:t.type===E.Textbox||t.type===E.Frame,width:t.width,height:t.height,rotation:t.rotation,immutable:t.immutable||r&&!r.includes(t.id),onSelected:l,onBeginMove:f,onBeginResize:m,onBeginRotate:M,onPointerEnter:u,onPointerLeave:p,scaleFactor:Y},t.id)}))]})},Jt=A=>{const{color:t,editorRef:e,zoomableElementRef:n,interactionElementRef:a,guidelines:i,isMakingAdjustments:s,viewmask:o,visibleLayoutId:c,xTranslation:r,yTranslation:g,targetedElements:B,borderRadius:w,handleContextMenu:E,handleKeyDown:l,handleKeyUp:Q,handlePointerMove:C,handlePointerPressedBackground:h,handlePointerReleased:d,handleScroll:D,onSequenceStart:I,setElementEvent:u,onElementSelected:p}=A,{getLayoutById:f}=rt(),m=f(c),M=m.layoutState,{state:F}=ht(),Y=kA((A=>{if(o){const t={left:o.x,top:o.y,width:o.width,height:o.height,panelId:"",rotation:0};return l(A,t)}return l(A)}),[l,o]),y=kA((A=>{if(o){const t={left:o.x,top:o.y,width:o.width,height:o.height,panelId:"",rotation:0};return C(A,t)}return C(A)}),[C,o]);return LA("div",{style:{justifyContent:"center",position:"relative",height:"100%",width:"100%",scrollbarWidth:"none",outline:"none"},onContextMenu:E,onKeyDown:Y,onKeyUp:Q,onPointerDown:h,onPointerMoveCapture:y,onPointerUp:d,onWheelCapture:D,ref:a,tabIndex:-1,children:OA("div",{ref:n,style:{height:"100%",transform:`scale(${F.zoom}) translate(${r}px, ${g}px)`,display:"grid",filter:"drop-shadow(rgba(0, 0, 0, 0.2) 0px 0px 6px)"},children:[A.children,m.getComponentWithProps({height:s?"100%":"auto",maxHeight:"100%",maxWidth:"100%",position:"absolute",viewmask:o,width:s?"100%":"auto",borderRadius:w}),LA(Pt,{primaryColor:t,containerHeight:n.current?.offsetHeight||1024,containerWidth:n.current?.offsetWidth||1024,editorRef:e,elementEvent:F.elementEvent,guidelines:i,layoutHeight:M.layout.height,layoutWidth:M.layout.width,onElementEvent:u,onSequenceStart:I,onElementSelected:p,scale:10/F.zoom,selectedElement:F.selectedElement,targetedElements:B})]})})},kt=({color:A,borderRadius:t,guidelineColor:e,handleContextMenu:n,onElementSelected:a})=>{const{commandDispatcher:i,getLayoutById:s}=rt(),{state:o,uiDispatcher:c}=ht(),r=JA(null),g=JA(null),B=JA(null),{guidelines:w,handleKeyDown:l,handleKeyUp:Q,handlePointerMove:C,handlePointerPressedBackground:h,handlePointerReleased:d,handleScroll:D,handleSequenceStart:I,setElementEvent:u}=Ht(r,g,B,void 0,"advanced",i,e),p=kA(((A,t)=>{const e=s(o.layoutId).layoutState.elements.find((t=>t.id===A));if(A&&e&&e.type===E.Textbox){const t=e.algorithm;(!t||t===v.Autosize)&&i(new P(A,v.Traditional))}a&&a(A,t),c(new Ct({selectedElement:A}))}),[i,s,o.layoutId,c]);return LA(Jt,{color:A,editorRef:r,interactionElementRef:g,zoomableElementRef:B,guidelines:w,visibleLayoutId:o.layoutId,xTranslation:0,yTranslation:0,borderRadius:t,handleContextMenu:n,handleKeyDown:l,handleKeyUp:Q,handlePointerMove:C,handlePointerPressedBackground:h,handlePointerReleased:d,handleScroll:D,onSequenceStart:I,setElementEvent:u,onElementSelected:p})};class Lt{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 Ot{constructor(){var A,t,e;A=this,t="storage",e=new Map,t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e}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 bt=(()=>{try{return localStorage?new Lt:new Ot}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new Ot}})(),zt=yA`
1
+ import{CommandContext as A,AssetType as t,BringForwardCommand as e,CanvasCommand as n,CreateElementCommand as a,CreateLayoutCommand as i,DeleteElementCommand as s,FontAlignmentCommand as o,FontColorCommand as c,FontSizeCommand as r,FontSourceCommand as g,GroupCommand as B,LayoutElementFactory as w,LayoutElementType as E,MoveCommand as l,ResizeCommand as Q,RotateCommand as C,SendBackwardsCommand as h,StepAspectType as d,StepType as D,TextChangeCommand as I,UnitOfMeasurement as u,dataUrlFromExternalUrl as p,findElement as f,frameDataCache as m,generate as M,generateSVGWithUnknownColors as F,getAttributesFromArrayBuffer as Y,rehydrateSerializedLayout as y,getFrameData as N,getSvgString as x,loadFontFromDataUrl as H,loadFontFromExternalUrl as R,determineCorrectFontSizeAndLines as U,patternImageDataCache as S,registerJSDOM as G,TextAlgorithm as v,FontAlgorithmCommand as P,getAxisAlignedBoundingBox as J,isCloseToValue as k,mmPerPixel as L,cmPerPixel as O,ScaleAxis as b,getElementVertices as z,rotateAroundPoint as T,calculateTextboxLines as K,defaultLineHeightFactor as j,findAngle as V,currentDirection as W,modifySVGWithElementProperties as X,IllustrationColorCommand as q,IllustrationCacheCommand as Z,getFontMetrics as $,applyTextTransformations as _,UpdateWorkflowStateCommand as AA,calculateOffsets as tA,UpdateFramePattern as eA,generateDefaultRectangleFrameSvg as nA,fetchAsString as aA,GetSVGDimensions as iA,ShiftPatchworkCommand as sA,Patchwork as oA,sanitizeSvgTree as cA,createElementNS as rA,createElement as gA,sortElementsByLayersWithIndex as BA,toBase64 as wA,getPatternImageData as EA,getVariant as lA,generateFrameSVG as QA,getDefaultVariant as CA,domParser as hA,traverse as dA,xmlSerializer as DA,fetchAsArrayBuffer as IA,arrayBufferToDataUrl as uA,loadFontFaceSet as pA}from"@spiffcommerce/papyrus";import fA from"swagger-client";import{createHttpLink as mA,InMemoryCache as MA,ApolloClient as FA,from as YA,gql as yA}from"@apollo/client";import{setContext as NA}from"@apollo/client/link/context";import{onError as xA}from"@apollo/client/link/error";import{fetch as HA}from"cross-fetch";import{createContext as RA,useContext as UA,useEffect as SA,useState as GA,useReducer as vA,useMemo as PA,useRef as JA,useCallback as kA}from"react";import{jsx as LA,jsxs as OA,Fragment as bA}from"react/jsx-runtime";import zA from"lodash.isequal";import{Canvg as TA}from"canvg";import KA from"lodash.clonedeep";import jA from"lodash.debounce";import{toString as VA}from"qrcode";import WA from"react-dom/server";import XA from"svg-path-bbox";function qA(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const ZA=new class{constructor(){qA(this,"defaultServerUrl","https://api.spiff.com.au"),qA(this,"defaultServicesApiUrl","https://services.spiff.com.au"),qA(this,"defaultHubUrl","https://hub.spiff.com.au"),qA(this,"serverUrl",void 0),qA(this,"servicesApiUrl",void 0),qA(this,"hubUrl",void 0),qA(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 $A(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let _A;const At=A=>{_A=A},tt=async()=>{const A={transactionOwnerId:_A};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=ZA.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 et=new class{constructor(){$A(this,"client",void 0),$A(this,"uncachedOperations",[]),ZA.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((a=>{a.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 tt();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 tt(),t=ZA.getServerUrl()+"/v2/api-docs";return await fA(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const nt=new class{constructor(){$A(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),ZA.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=mA({uri:`${ZA.getServerUrl()}/graphql`,fetch:HA}),t=NA((async(A,{headers:t})=>{const e=t||{},n=await tt();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=xA((({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 MA({typePolicies:{Transaction:{fields:{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}}}}});return new FA({link:YA([e,t,A]),cache:n,name:"Core"})}};function at(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const it=new class{constructor(){at(this,"server",void 0),at(this,"cache",new Map),at(this,"materialCache",new Map),at(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await Y(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)}})),this.server=et}async getLocalOrFromServer(A){if(this.cache.has(A))return this.cache.get(A);const t=(async()=>(await et.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 et.execute("getMaterialV2",{id:A})).body)();return this.materialCache.set(A,t),t}async uploadAssetWithProgress(A,t,e,n,a,i){const s=await this.dispatchCreateAssetRequest(A,t,a,i);var o=new XMLHttpRequest;return o.open("PUT",s.assetResponse.uploadUrl,!0),o.setRequestHeader("Content-Type",s.mimeType),o.setRequestHeader("Cache-Control","public,max-age=31536000,immutable"),o.upload.onprogress=A=>{A.lengthComputable&&e(100*A.loaded/A.total)},o.onload=()=>{const A=s.assetResponse.asset;n(A)},o.onerror=()=>{console.warn("Asset upload failed")},o.send(A.blob),s.assetResponse.asset}async dispatchCreateAssetRequest(A,t,e,n){const a=A.blob.type?A.blob.type:this.guessMIME(A.name);return{assetResponse:(await this.server.execute("createAsset",{assetDetails:{name:A.name,type:t,mimeType:a,storageOwnerId:n,userAnonymous:!0}},e)).body,mimeType:a}}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 Error("Unexpected mimetype: "+t)}}};function st(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const ot=new class{constructor(){st(this,"cache",new Map),st(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),st(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),st(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[]))}async cacheRequiredOptions(A){const t=A.steps.map((A=>A.optionId)).filter((A=>void 0!==A)),e=A.steps.map((A=>A.data.colourOptionId)).filter((A=>void 0!==A)),n=[...new Set([...t,...e])].map((async A=>{const t=await ot.getLocalOrFromServer(et,A);"Font"===t.data.type&&t.data.variants.forEach((async A=>{if(A.assetKey){const t=(await it.getLocalOrFromServer(A.assetKey)).links.find((A=>"cdn"===A.rel))?.href;t&&await R(t)}}))}));await Promise.allSettled([...n])}async getLocalOrFromServer(A,t){if(this.cache.has(t))return this.cache.get(t);const e=(await A.execute("getOptionV2",{id:t})).body;return this.cache.set(t,e),e}getLocalOrUndefined(A){if(A)return this.cache.get(A)}async getAssetTileImageForVariant(A){if(A.thumbnailKey){const t=await it.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 it.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}},ct=RA(new A),rt=()=>{const A=UA(ct);SA((()=>{A.registerStateCallback((()=>{e(new Date)}))}),[A]);const[t,e]=GA(new Date);return{commandDispatcher:t=>{A.apply(t)},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)}}};let gt;var Bt;(Bt=gt||(gt={})).None="None",Bt.FrameAdjustment="FrameAdjustment",Bt.FinalizeDesign="FinalizeDesign";const wt=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,maxZoom:5,units:u.Pixel,subMenu:gt.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),Et=(A,t)=>zA(A,t.apply(A))?A:t.apply(A),lt=RA({}),Qt=A=>{const{getAllLayouts:t}=rt(),[e,n]=vA(Et,wt(t,A.defaultZoom||1)),a=PA((()=>({state:e,uiDispatcher:n})),[e,n]);return LA(lt.Provider,{value:a,children:A.children})};class Ct{constructor(A){var t,e,n;n=void 0,(e="changes")in(t=this)?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,this.changes=A}apply(A){return{...A,...this.changes}}}const ht=()=>UA(lt);let dt;var Dt;(Dt=dt||(dt={}))[Dt.Orbit=0]="Orbit",Dt[Dt.Pan=1]="Pan";const It=(A,t,e,n)=>{const a=t.layout.width,i=t.layout.height,s=t.elements.filter((t=>t.id!==A.id&&!t.immutable&&!t.productOverlay)),o=s.map((A=>J(A.x,A.y,A.width,A.height,A.rotation))),c=[],r=new Set;o.forEach((A=>r.add(A.minX))),o.forEach((A=>r.add(A.maxX))),[0,a/2,a].forEach((A=>r.add(A)));const g=new Set;o.forEach((A=>g.add(A.minY))),o.forEach((A=>g.add(A.maxY))),[0,i/2,i].forEach((A=>g.add(A)));const B=s.map((A=>A.y));for(let A=-315;A<=315;A+=45)B.push(A);const w=J(A.x,A.y,A.width,A.height,A.rotation),E=[{value:w.minX,anchor:-1},{value:w.minX+(w.maxX-w.minX)/2,anchor:0},{value:w.minX+(w.maxX-w.minX),anchor:1}],l=[{value:w.minY,anchor:-1},{value:w.minY+(w.maxY-w.minY)/2,anchor:0},{value:w.minY+(w.maxY-w.minY),anchor:1}],Q=[{value:A.rotation,anchor:0}],C=(A,t,n,s)=>{const o=[];return t.forEach((t=>{const c=n.find((A=>k(t,A.value,2*e))),[r,g]=((A,t)=>[{x:"x"===A?t:0,y:"x"===A?0:t},{x:"x"===A?t:a,y:"x"===A?i:t}])(A,t),B="rotation"===A?null:LA("line",{x1:r.x,y1:r.y,x2:g.x,y2:g.y,stroke:s||"#D61B5C",strokeDasharray:5*e,strokeWidth:1.2*e,overflow:"overlay"},`${A}-${t}-${r.x}-${r.y}-${g.x}-${g.y}`);void 0!==c&&o.push({type:A,value:t,anchorPoint:c.anchor,svgNode:B,guidelineCoordinates:[r,g]})})),o};return c.push(...C("x",Array.from(r),E,n)),c.push(...C("y",Array.from(g),l,n)),c.push(...C("rotation",B,Q,n)),c};let ut;var pt;let ft;var mt;(pt=ut||(ut={})).Translate="Translate",pt.Rotate="Rotate",pt.Resize="Resize",(mt=ft||(ft={})).ControlLeft="ControlLeft",mt.ControlRight="ControlRight",mt.Equal="Equal",mt.MetaLeft="MetaLeft",mt.MetaRight="MetaRight",mt.Minus="Minus",mt.ArrowLeft="ArrowLeft",mt.ArrowRight="ArrowRight",mt.ArrowUp="ArrowUp",mt.ArrowDown="ArrowDown",mt.AltLeft="AltLeft",mt.AltRight="AltRight",mt.Delete="Delete",mt.Backspace="Backspace";const Mt=(A,t,e,n)=>{const a=()=>{switch(e){case u.Pixel:return 1;case u.Millimeter:return L;case u.Centimeter:return O;default:throw new Error("Unknown unit of measurement")}};let i=t.x,s=t.y,o=t.x,c=t.y;switch(A){case ft.ArrowLeft:o=t.x-1/a();break;case ft.ArrowUp:c=t.y-1/a();break;case ft.ArrowRight:o=t.x+1/a();break;case ft.ArrowDown:c=t.y+1/a();break;default:throw new Error("Unhandled element interaction!")}const r=J(o,c,t.width,t.height,t.rotation);return(!n||r.minX>=n.left&&r.maxX<=n.left+n.width&&r.minY>=n.top&&r.maxY<=n.top+n.height)&&(i=o,s=c),new l(t.id,i,s)};var Ft=0,Yt=0,yt=0;const Nt=(A,t,e,n,a,i,s)=>{const o=((A,t,e,n,a,i,s)=>{const o=n.width/t.width,c=n.height/t.height,r=A.movementX/o,g=A.movementY/c,B=e.rotation*Math.PI/180,w=Math.sin(B),l=Math.cos(B);let Q;switch(a.type){case ut.Resize:let t={top:e.y,left:e.x,width:e.width,height:e.height,rotation:e.rotation,fontSize:e.fontSize},C=t;switch(a.screenAxis){case b.North:{const A=-r*w+g*l,n=e.y+A,a=e.height-A,i=z({...e}).center,s=z({...e,y:n,height:a}).center,o=T(s,i,B),c=o.x-e.width/2,E=o.y-a/2;C={...t,left:c,top:E,height:a}}break;case b.East:{const A=r*l+g*w,n=e.width+A;let a=e.height;if(e.type===E.Textbox){const A=e;a=K(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const i=z({...e}).center,s=z({...e,width:n,height:a}).center,o=T(s,i,B),c=o.x-n/2,Q=o.y-a/2;C={...t,left:c,top:Q,width:n,height:a}}break;case b.West:{const A=r*l+g*w,n=e.x+A,a=e.width-A;let i=e.height;if(e.type===E.Textbox){const A=e;i=K(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const s=z({...e}).center,o=z({...e,width:a,height:i,x:n}).center,c=T(o,s,B),Q=c.x-a/2,h=c.y-i/2;C={...t,left:Q,top:h,width:a,height:i}}break;case b.South:{const A=-r*w+g*l,n=e.height+A,a=z({...e}).center,i=z({...e,height:n}).center,s=T(i,a,B),o=s.x-e.width/2,c=s.y-n/2;C={...t,left:o,top:c,height:n}}break;case b.Northeast:{const A=r*l+g*w,n=e.width+A;let a=e.height+A,i=e.y-A,s=e.fontSize;if(e.type===E.Textbox){const t=e;s=t.fontSize+A/8,a=K(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||j;i=e.y-A*n/8}const o=z({...e}).center,c=z({...e,width:n,height:a,y:i}).center,Q=T(c,o,B),h=Q.x-n/2,d=Q.y-a/2;C={...t,left:h,top:d,width:n,height:a,fontSize:s}}break;case b.Northwest:{const A=-r*l+-g*w,n=e.x-A,a=e.width+A;let i=e.y-A,s=e.height+A,o=e.fontSize;if(e.type===E.Textbox){const t=e;o=t.fontSize+A/8,s=K(o,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||j;i=e.y-A*n/8}const c=z({...e}).center,Q=z({...e,x:n,y:i,width:a,height:s}).center,h=T(Q,c,B),d=h.x-a/2,D=h.y-s/2;C={...t,left:d,top:D,width:a,height:s,fontSize:o}}break;case b.Southeast:{const A=r*l+g*w,n=e.width+A;let a=e.height+A,i=e.fontSize;if(e.type===E.Textbox){const t=e;i=t.fontSize+A/8,a=K(i,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const s=z({...e}).center,o=z({...e,width:n,height:a}).center,c=T(o,s,B),Q=c.x-n/2,h=c.y-a/2;C={...t,left:Q,top:h,width:n,height:a,fontSize:i}}break;case b.Southwest:{const A=-r*l+-g*w,n=e.width+A;let a=e.x-A,i=e.height+A,s=e.fontSize;if(e.type===E.Textbox){const t=e;s=t.fontSize+A/8,i=K(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const o=z({...e}).center,c=z({...e,width:n,height:i,x:a}).center,Q=T(c,o,B),h=Q.x-n/2,d=Q.y-i/2;C={...t,left:h,top:d,width:n,height:i,fontSize:s}}}return Q=J(C.left,C.top,C.width,C.height,C.rotation),(!s||Q.minX>=s.left&&Q.maxX<=s.left+s.width&&Q.minY>=s.top&&Q.maxY<=s.top+s.height)&&(t=C),t;case ut.Rotate:const h={x:A.clientX,y:A.clientY};let d,D=e.rotation;const I=z(e,n,{x:o,y:c}),u=V(h,I.c,I.d),p=V(h,I.d,I.c);if(0===i.filter((A=>"rotation"===A.type)).length)yt=0,d=(e.rotation+u-p)%360;else{yt+=Math.sqrt(r**2+g**2);const A=Math.abs(yt)>7*window.devicePixelRatio/o;d=A?(e.rotation+u-p)%360:i.find((A=>"rotation"===A.type))?.value||0,A&&(yt=0)}return Q=J(e.x,e.y,e.width,e.height,d),(!s||Q.minX>=s.left&&Q.maxX<=s.left+s.width&&Q.minY>=s.top&&Q.maxY<=s.top+s.height)&&(D=d),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:D};case ut.Translate:let f,m,M=e.x,F=e.y;if(0===i.filter((A=>"rotation"!==A.type)).length)Ft=0,Yt=0,f=e.x+r,m=e.y+g;else{const A=i.find((A=>"x"===A.type)),t=i.find((A=>"y"===A.type));A||(Ft=0),t||(Yt=0);const n=Math.abs(Ft)>7*window.devicePixelRatio/o,a=Math.abs(Yt)>7*window.devicePixelRatio/c;f=A?n?e.x+Ft:e.x:e.x+r,m=t?a?e.y+Yt:e.y:e.y+g,Ft=n?0:Ft+r,Yt=a?0:Yt+g}return Q=J(f,m,e.width,e.height,e.rotation),(!s||Q.minX>=s.left&&Q.maxX<=s.left+s.width&&Q.minY>=s.top&&Q.maxY<=s.top+s.height)&&(M=f,F=m),{top:F,left:M,width:e.width,height:e.height,rotation:e.rotation}}})(A,t,e,n,a,i,s),c=[];if(e.type===E.Textbox){const A=e;c.push(new I(A.id,A.text||A.input||""))}if(c.push(new l(e.id,o.left,o.top),new Q(e.id,o.width,o.height),new C(e.id,o.rotation)),e.type===E.Textbox){const A=e;o.fontSize&&A.fontSize!==o.fontSize&&c.push(new r(A.id,o.fontSize))}return c},xt=.5,Ht=(A,t,e,n,a,i,o)=>{const{state:c,uiDispatcher:r}=UA(lt),{getLayoutById:g,getReducerState:w,flattenSequence:E}=rt(),[l,Q]=GA(void 0),[C,h]=GA(void 0),d=g(c.layoutId);SA((()=>{if("adjustment"===a&&A?.current&&n){if(n<.5)return void r(new Ct({zoom:.5}));if(n>c.maxZoom)return void r(new Ct({zoom:c.maxZoom}));r(new Ct({zoom:n}))}}),[n,r,A,a,c.maxZoom]);const D=kA(((A,n)=>{r(new Ct({zoom:n}));const i=t?.current?.scrollWidth-t?.current?.clientWidth!=0,s=t?.current?.scrollHeight-t?.current?.clientHeight!=0;t.current&&e.current&&!c.scrolledMovement&&"advanced"===a&&(s&&(t.current.scrollTop=e.current.offsetTop+(t.current.scrollHeight-t.current.clientHeight)/2),i&&(t.current.scrollLeft=(e.current.offsetLeft+t.current.scrollWidth-t.current.clientWidth)/2))}),[r,t,e,c.scrolledMovement,a]);SA((()=>{c.zoom<=1&&r(new Ct({scrolledMovement:!1}))}),[r,c.zoom]);const I=t?.current?.getBoundingClientRect(),u=((I?.width||1)+(I?.height||1))/2,p=(d.layoutState.layout.width+d.layoutState.layout.height)/2/u/c.zoom,f=PA((()=>{const A=c.activeModifierKeys,t=c.elementEvent,e=A.includes(ft.ControlLeft)||A.includes(ft.MetaLeft)||A.includes(ft.ControlRight)||A.includes(ft.MetaRight);if(!c.selectedElement||!t||e)return[];const n=t&&t.type===ut.Translate,a=t&&t.type===ut.Rotate,i=d.layoutState.elements.find((A=>A.id===c.selectedElement));return(n||a)&&i?It(i,d.layoutState,p,o):[]}),[c.selectedElement,c.elementEvent,c.activeModifierKeys,d.layoutState,p]),m=kA((()=>{const A=M();Q(A),h(w().transaction)}),[w]),F=kA((()=>{r(new Ct({selectedElement:void 0}))}),[r]),Y=kA((()=>{r(new Ct({scrolledMovement:!0}))}),[r]),y=kA(((e,n)=>{const a=d.layoutState.elements.find((A=>A.id===c.selectedElement));if(!(c.elementEvent&&A.current&&t.current&&c.selectedElement&&a))return;t.current.hasPointerCapture(e.pointerId)||t.current.setPointerCapture(e.pointerId);const s=A.current.getBoundingClientRect(),o=new B(Nt(e,d.layoutState.layout,a,s,c.elementEvent,f,n));o.sequenceId=l,i(o)}),[d.layoutState.elements,d.layoutState.layout,c.elementEvent,A,c.selectedElement,t,f,i]),N=kA((A=>{r(new Ct({elementEvent:A}))}),[r]),x=kA((()=>{r(new Ct({elementEvent:void 0})),l&&C&&(E(l,C),Q(void 0),h(void 0))}),[r,l,C,E]),H=kA(((A,t)=>{let e=c.zoom;const n=c.maxZoom,o=c.selectedElement,g=c.activeModifierKeys;if((g.includes(ft.AltLeft)||g.includes(ft.AltRight))&&(A.code===ft.Equal||A.code===ft.Minus)){const t=.05*n;A.code===ft.Equal?r(new Ct({zoom:e+t<=n?e+=t:e})):r(new Ct({zoom:e-t>=.5?e-t:e}))}const B=d.layoutState.elements.find((A=>A.id===o));if(o&&B){if(A.code===ft.MetaLeft||A.code===ft.ControlLeft||A.code===ft.MetaRight||A.code===ft.ControlRight){const t=A.code,e=c.activeModifierKeys;if(!e.includes(t))return r(new Ct({activeModifierKeys:e.concat(t)}))}if(A.code===ft.ArrowDown||A.code===ft.ArrowUp||A.code===ft.ArrowLeft||A.code===ft.ArrowRight){r(new Ct({elementEvent:{type:ut.Translate}}));const e=Mt(A.code,B,c.units,t);i(e),r(new Ct({elementEvent:void 0}))}A.code!==ft.Delete&&A.code!==ft.Backspace||"advanced"!==a||(r(new Ct({selectedElement:void 0})),i(new s(B.id)))}}),[i,r,d.layoutState.elements,a,c.activeModifierKeys,c.maxZoom,c.selectedElement,c.units,c.zoom]),R=kA((A=>{if(A.code===ft.MetaLeft||A.code===ft.ControlLeft||A.code===ft.MetaRight||A.code===ft.ControlRight){const t=c.activeModifierKeys,e=A.code;r(new Ct({activeModifierKeys:t.filter((A=>A!==e))}))}}),[r,c.activeModifierKeys]);return{guidelines:f,scale:p,zoomableElementRef:e,setElementEvent:N,handleZoom:D,handleKeyDown:H,handleKeyUp:R,handlePointerPressedBackground:F,handlePointerReleased:x,handlePointerMove:y,handleScroll:Y,handleSequenceStart:m}},Rt=A=>{const{x:t,y:e,cursorStyle:n,onPointerDown:a,handleClass:i,cornerRadius:s,color:o,strokeWidth:c}=A;return LA("circle",{className:i,cx:t,cy:e,r:s,fill:"#ffffff",style:{cursor:n},stroke:o,strokeWidth:c,onPointerDown:a})},Ut=A=>{const{x:t,y:e,width:n,height:a,cursorStyle:i,onPointerDown:s,edgeHandleRadius:o,color:c,strokeWidth:r}=A;return LA("rect",{x:t,y:e,width:n,height:a,rx:o,fill:"#ffffff",style:{cursor:i},stroke:c,strokeWidth:r,onPointerDown:s})},St=A=>{const{color:t,elementHeight:e,elementWidth:n,onBeginResize:a,rotation:i,scaleFactor:s,disableX:o,disableY:c}=A,r=7.5*s,g=3*s,B=28*s,w=6*s,E=1.2*s,l=e-2*r,Q=kA(((A,t,e)=>{A.stopPropagation(),a(t,e)}),[a]),C=kA((A=>Q(A,W(b.West,360-i),b.West)),[Q,i]),h=kA((A=>Q(A,W(b.East,360-i),b.East)),[Q,i]),d=kA((A=>Q(A,W(b.North,360-i),b.North)),[Q,i]),D=kA((A=>Q(A,W(b.South,360-i),b.South)),[Q,i]),I=kA((A=>Q(A,b.Northwest,b.Northwest)),[Q]),u=kA((A=>Q(A,b.Northeast,b.Northeast)),[Q]),p=kA((A=>Q(A,b.Southwest,b.Southwest)),[Q]),f=kA((A=>Q(A,b.Northeast,b.Southeast)),[Q]),m=B<=l;return OA(bA,{children:[LA(Rt,{x:0,y:0,cursorStyle:"nwse-resize",onPointerDown:I,handleClass:"cornerNorthWest",cornerRadius:r,color:t,strokeWidth:E}),m?LA(Rt,{x:n,y:0,cursorStyle:"nesw-resize",onPointerDown:u,handleClass:"cornerNorthEast",cornerRadius:r,color:t,strokeWidth:E}):void 0,m?LA(Rt,{x:n,y:e,cursorStyle:"nwse-resize",onPointerDown:f,handleClass:"cornerSouthEast",cornerRadius:r,color:t,strokeWidth:E}):void 0,m?LA(Rt,{x:0,y:e,cursorStyle:"nesw-resize",onPointerDown:p,handleClass:"cornerSouthWest",cornerRadius:r,color:t,strokeWidth:E}):void 0,m&&!o?LA(Ut,{x:-w/2,y:e/2-B/2,width:w,height:B,onPointerDown:C,edgeHandleRadius:g,cursorStyle:"ew-resize",color:t,strokeWidth:E}):void 0,m&&!c?LA(Ut,{x:n/2-B/2,y:e-w/2,width:B,height:w,onPointerDown:D,edgeHandleRadius:g,cursorStyle:"ns-resize",color:t,strokeWidth:E}):void 0,o?void 0:LA(Ut,{x:n-w/2,y:e/2-Math.min(B,.8*e)/2,width:w,height:Math.min(B,.8*e),onPointerDown:h,edgeHandleRadius:g,cursorStyle:"ew-resize",color:t,strokeWidth:E}),m&&!c?LA(Ut,{x:n/2-B/2,y:-w/2,width:B,height:w,onPointerDown:d,edgeHandleRadius:g,cursorStyle:"ns-resize",color:t,strokeWidth:E}):void 0]})},Gt=A=>{const{color:t,elementWidth:e,onBeginRotate:n,scaleFactor:a}=A,i=kA((A=>{A.stopPropagation(),n()}),[n]),s=10*a,o=1.2*a;return OA("g",{children:[LA("circle",{cx:e/2,cy:-2.5*s,r:1.3*s,fill:"rgba(0, 0, 0, 0.5)",opacity:.4,style:{cursor:"ew-resize"},onPointerDown:i}),LA("circle",{cx:e/2,cy:-2.5*s,r:s,fill:"#fff",style:{cursor:"ew-resize"},stroke:t,strokeWidth:o,onPointerDown:i}),OA("svg",{x:e/2-s,y:-2.5*s-s,xmlns:"http://www.w3.org/2000/svg",style:{cursor:"ew-resize"},height:2*s,viewBox:"0 0 24 24",width:2*s,fill:t,onPointerDown:i,children:[LA("path",{d:"M0 0h24v24H0z",fill:"none"}),LA("path",{d:"M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z"})]})]})},vt=A=>{const{color:t,height:e,highlighted:n,id:a,immutable:i,onBeginMove:s,onBeginResize:o,onBeginRotate:c,onPointerEnter:r,onPointerLeave:g,onSelected:B,pressed:w,rotation:E,scaleFactor:l,selected:Q,width:C,x:h,y:d,disableX:D,disableY:I}=A,u=1.2*l,p=kA((A=>{2===A.button&&(A.stopPropagation(),B(a,A)),0===A.button&&(A.stopPropagation(),!Q&&B(a,A),s())}),[a,Q,B,s]),f=kA((()=>{r(a)}),[a,r]),m=kA((()=>{g(a)}),[a,g]);return OA("g",{transform:`translate(${h}, ${d}) rotate(${E} ${C/2} ${e/2})`,children:[LA("rect",{className:"interactableInnerRect",width:C,height:e,stroke:Q||n?t:"none",pointerEvents:i?"none":"visibleFill",fill:"none",strokeWidth:u,style:{cursor:i?void 0:Q?w?"grabbing":"grab":"pointer"},onPointerDown:i?void 0:p,onPointerEnter:i?void 0:f,onPointerLeave:i?void 0:m}),Q&&OA(bA,{children:[LA(Gt,{color:t,elementWidth:C,onBeginRotate:c,scaleFactor:l}),LA(St,{color:t,elementHeight:e,elementWidth:C,rotation:E,scaleFactor:l,onBeginResize:o,disableX:D,disableY:I})]})]})},Pt=({primaryColor:A,containerHeight:t,containerWidth:e,customViewbox:n,editorRef:a,elementEvent:i,guidelines:s,layoutHeight:o,layoutWidth:c,targetedElements:r,scale:g,selectedElement:B,onElementEvent:w,onElementSelected:l,onSequenceStart:Q})=>{const{state:C}=ht(),{getLayoutById:h}=rt(),d=h(C.layoutId),[D,I]=GA(void 0),u=kA((A=>{I(A)}),[]),p=kA((A=>{D===A&&I(void 0)}),[D]),f=kA((()=>{Q(),w({type:ut.Translate})}),[w]),m=kA(((A,t)=>{Q(),w({type:ut.Resize,relativeAxis:A,screenAxis:t})}),[w]),M=kA((()=>{Q(),w({type:ut.Rotate})}),[w]),F=n||{x:0,y:0,width:c,height:o},Y=g*(Math.sqrt(F.width*F.height)/1e3)*(100/Math.sqrt(t*e))*Math.sqrt((y=e/t,Math.exp(Math.abs(Math.log(y)))));var y;const N=d.layoutState.elements.findIndex((({id:A})=>A===B)),x=[...d.layoutState.elements];return N>=0&&x.push(x.splice(N,1)[0]),OA("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%"},width:"100%",height:"100%",viewBox:`${F.x} ${F.y} ${F.width} ${F.height}`,overflow:"overlay",children:[LA("rect",{fill:"none",stroke:"none",ref:a,width:c,height:o}),s.map((A=>A.svgNode)),x.map((t=>{const e=void 0!==B&&t.id===B,n=e&&void 0!==i,a=void 0!==D&&t.id===D;return LA(vt,{color:A,id:t.id,selected:e,highlighted:a,pressed:n,x:t.x,y:t.y,disableX:t.type===E.Frame,disableY:t.type===E.Textbox||t.type===E.Frame,width:t.width,height:t.height,rotation:t.rotation,immutable:t.immutable||r&&!r.includes(t.id),onSelected:l,onBeginMove:f,onBeginResize:m,onBeginRotate:M,onPointerEnter:u,onPointerLeave:p,scaleFactor:Y},t.id)}))]})},Jt=A=>{const{color:t,editorRef:e,zoomableElementRef:n,interactionElementRef:a,guidelines:i,isMakingAdjustments:s,viewmask:o,visibleLayoutId:c,xTranslation:r,yTranslation:g,targetedElements:B,borderRadius:w,handleContextMenu:E,handleKeyDown:l,handleKeyUp:Q,handlePointerMove:C,handlePointerPressedBackground:h,handlePointerReleased:d,handleScroll:D,onSequenceStart:I,setElementEvent:u,onElementSelected:p}=A,{getLayoutById:f}=rt(),m=f(c),M=m.layoutState,{state:F}=ht(),Y=kA((A=>{if(o){const t={left:o.x,top:o.y,width:o.width,height:o.height,panelId:"",rotation:0};return l(A,t)}return l(A)}),[l,o]),y=kA((A=>{if(o){const t={left:o.x,top:o.y,width:o.width,height:o.height,panelId:"",rotation:0};return C(A,t)}return C(A)}),[C,o]);return LA("div",{style:{justifyContent:"center",position:"relative",height:"100%",width:"100%",scrollbarWidth:"none",outline:"none"},onContextMenu:E,onKeyDown:Y,onKeyUp:Q,onPointerDown:h,onPointerMoveCapture:y,onPointerUp:d,onWheelCapture:D,ref:a,tabIndex:-1,children:OA("div",{ref:n,style:{height:"100%",transform:`scale(${F.zoom}) translate(${r}px, ${g}px)`,display:"grid",filter:"drop-shadow(rgba(0, 0, 0, 0.2) 0px 0px 6px)"},children:[A.children,m.getComponentWithProps({height:s?"100%":"auto",maxHeight:"100%",maxWidth:"100%",position:"absolute",viewmask:o,width:s?"100%":"auto",borderRadius:w}),LA(Pt,{primaryColor:t,containerHeight:n.current?.offsetHeight||1024,containerWidth:n.current?.offsetWidth||1024,editorRef:e,elementEvent:F.elementEvent,guidelines:i,layoutHeight:M.layout.height,layoutWidth:M.layout.width,onElementEvent:u,onSequenceStart:I,onElementSelected:p,scale:10/F.zoom,selectedElement:F.selectedElement,targetedElements:B})]})})},kt=({color:A,borderRadius:t,guidelineColor:e,handleContextMenu:n,onElementSelected:a})=>{const{commandDispatcher:i,getLayoutById:s}=rt(),{state:o,uiDispatcher:c}=ht(),r=JA(null),g=JA(null),B=JA(null),{guidelines:w,handleKeyDown:l,handleKeyUp:Q,handlePointerMove:C,handlePointerPressedBackground:h,handlePointerReleased:d,handleScroll:D,handleSequenceStart:I,setElementEvent:u}=Ht(r,g,B,void 0,"advanced",i,e),p=kA(((A,t)=>{const e=s(o.layoutId).layoutState.elements.find((t=>t.id===A));if(A&&e&&e.type===E.Textbox){const t=e.algorithm;(!t||t===v.Autosize)&&i(new P(A,v.Traditional))}a&&a(A,t),c(new Ct({selectedElement:A}))}),[i,s,o.layoutId,c]);return LA(Jt,{color:A,editorRef:r,interactionElementRef:g,zoomableElementRef:B,guidelines:w,visibleLayoutId:o.layoutId,xTranslation:0,yTranslation:0,borderRadius:t,handleContextMenu:n,handleKeyDown:l,handleKeyUp:Q,handlePointerMove:C,handlePointerPressedBackground:h,handlePointerReleased:d,handleScroll:D,onSequenceStart:I,setElementEvent:u,onElementSelected:p})};class Lt{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 Ot{constructor(){var A,t,e;A=this,t="storage",e=new Map,t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e}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 bt=(()=>{try{return localStorage?new Lt:new Ot}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new Ot}})(),zt=yA`
2
2
  mutation CreateTransaction($integrationProductId: String!, $bulk: Boolean) {
3
3
  transactionCreate(integrationProductId: $integrationProductId, bulk: $bulk) {
4
4
  id
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/core",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "description": "Core client API for interacting with the Spiff Commerce backend.",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/main.js",