@spiffcommerce/core 14.8.0 → 14.8.1

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 t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/jsx-runtime"),A=require("react"),n=require("opentype.js"),a=require("buffer"),r=require("axios"),s=require("https"),o=require("file-type"),c=require("util"),l=require("css"),g=require("canvas"),h=require("exif"),d=require("process"),u=require("raf"),w=require("rgbcolor"),B=require("svg-pathdata"),p=require("stackblur-canvas"),E=require("@apollo/client/link/context"),m=require("@apollo/client/link/error"),f=require("cross-fetch"),C=require("lodash.isequal"),Q=require("react-dom/server"),y=require("qrcode"),D=require("svg-path-bbox"),I=require("lodash.debounce"),x=require("unicode-default-word-boundary"),v=require("@apollo/client/core");function M(t,e,i,A){Object.defineProperty(t,e,{get:i,set:A,enumerable:!0,configurable:!0})}var S="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function F(t){return t&&t.__esModule?t.default:t}M(module.exports,"SpiffCommerceClient",(()=>jc)),M(module.exports,"CommandContext",(()=>JA)),M(module.exports,"spiffCoreConfiguration",(()=>wa)),M(module.exports,"PromiseQueue",(()=>Lr)),M(module.exports,"QueueablePromise",(()=>Jr)),M(module.exports,"MockWorkflowManager",(()=>Kc)),M(module.exports,"InformationMessageType",(()=>Eo)),M(module.exports,"StepHandle",(()=>Io)),M(module.exports,"TextStepHandle",(()=>ko)),M(module.exports,"FrameStepHandle",(()=>Zc)),M(module.exports,"BulkStepHandle",(()=>So)),M(module.exports,"ShapeStepHandle",(()=>Ro)),M(module.exports,"IllustrationStepHandle",(()=>Fo)),M(module.exports,"MaterialStepHandle",(()=>bo)),M(module.exports,"ModelStepHandle",(()=>Yo)),M(module.exports,"PictureStepHandle",(()=>Po)),M(module.exports,"QuestionStepHandle",(()=>No)),M(module.exports,"BulkPriceCalculationStrategy",(()=>_a)),M(module.exports,"Variant",(()=>yo)),M(module.exports,"WorkflowExperienceImpl",(()=>Wo)),M(module.exports,"OptionNotFoundError",(()=>ta)),M(module.exports,"LayoutNotFoundError",(()=>ea)),M(module.exports,"AssetNotFoundError",(()=>ia)),M(module.exports,"ResourceNotFoundError",(()=>Aa)),M(module.exports,"MisconfigurationError",(()=>na)),M(module.exports,"ParseError",(()=>sa)),M(module.exports,"UnhandledBehaviorError",(()=>ra)),M(module.exports,"assetService",(()=>Na)),M(module.exports,"designService",(()=>Vo)),M(module.exports,"createDesign",(()=>Lo)),M(module.exports,"optionService",(()=>Ua)),M(module.exports,"persistenceService",(()=>da)),M(module.exports,"graphQlManager",(()=>Da)),M(module.exports,"toast",(()=>cr)),M(module.exports,"FrameService",(()=>Xs)),M(module.exports,"getBoundedOffsets",(()=>Ks)),M(module.exports,"frameStepService",(()=>Ao)),M(module.exports,"modelStepService",(()=>ro)),M(module.exports,"materialStepService",(()=>ao)),M(module.exports,"shapeStepService",(()=>lo)),M(module.exports,"questionStepService",(()=>co)),M(module.exports,"digitalContentStepService",(()=>eo)),M(module.exports,"moduleStepService",(()=>so)),M(module.exports,"pictureStepService",(()=>oo)),M(module.exports,"textStepService",(()=>Bo)),M(module.exports,"illustrationStepService",(()=>no)),M(module.exports,"ProductCameraRig",(()=>Za)),M(module.exports,"FrameStep",(()=>Xc)),M(module.exports,"ConversionLocation",(()=>er)),M(module.exports,"ConversionDataType",(()=>Ar)),M(module.exports,"getWorkflow",(()=>Lc)),M(module.exports,"shortenUrl",(()=>$s)),M(module.exports,"ObjectInput",(()=>Mc)),M(module.exports,"TextInput",(()=>Sc)),M(module.exports,"ObjectInputType",(()=>xc)),M(module.exports,"AssetType",(()=>ai)),M(module.exports,"BringForwardCommand",(()=>Cn)),M(module.exports,"BringToFrontCommand",(()=>mn)),M(module.exports,"BringToBackCommand",(()=>fn)),M(module.exports,"CanvasCommand",(()=>ZA)),M(module.exports,"CreateElementCommand",(()=>rn)),M(module.exports,"CreateLayoutCommand",(()=>nn)),M(module.exports,"DeleteElementCommand",(()=>sn)),M(module.exports,"FontAlignmentCommand",(()=>un)),M(module.exports,"FontColorCommand",(()=>cn)),M(module.exports,"FontSizeCommand",(()=>gn)),M(module.exports,"FontSourceCommand",(()=>dn)),M(module.exports,"GroupCommand",(()=>An)),M(module.exports,"LayoutElementFactory",(()=>qn)),M(module.exports,"LayoutElementType",(()=>ze)),M(module.exports,"MoveCommand",(()=>_A)),M(module.exports,"ResizeCommand",(()=>en)),M(module.exports,"RotateCommand",(()=>tn)),M(module.exports,"SendBackwardsCommand",(()=>Qn)),M(module.exports,"StakeholderType",(()=>ar)),M(module.exports,"StepAspectType",(()=>ci)),M(module.exports,"StepType",(()=>si)),M(module.exports,"TextChangeCommand",(()=>Bn)),M(module.exports,"UnitOfMeasurement",(()=>qe)),M(module.exports,"dataUrlFromExternalUrl",(()=>$i)),M(module.exports,"findElement",(()=>KA)),M(module.exports,"frameDataCache",(()=>Yn)),M(module.exports,"generate",(()=>Te)),M(module.exports,"getAxisAlignedBoundingBox",(()=>di)),M(module.exports,"generateSVGWithUnknownColors",(()=>TA)),M(module.exports,"getAttributesFromArrayBuffer",(()=>Sn)),M(module.exports,"rehydrateSerializedLayout",(()=>qA)),M(module.exports,"getFrameData",(()=>kn)),M(module.exports,"getSvgElement",(()=>zA)),M(module.exports,"loadFontFromDataUrl",(()=>oA)),M(module.exports,"loadFontFromExternalUrl",(()=>sA)),M(module.exports,"determineCorrectFontSizeAndLines",(()=>Ln)),M(module.exports,"patternImageDataCache",(()=>bn)),M(module.exports,"generateCommands",(()=>fs)),M(module.exports,"registerJSDOM",(()=>Ti)),M(module.exports,"minZoom",(()=>kr)),M(module.exports,"AdvancedEditor",(()=>Fs)),M(module.exports,"TransformWrapper",(()=>$c)),M(module.exports,"EditorCore",(()=>Ss)),M(module.exports,"useLayouts",(()=>Oa)),M(module.exports,"useEditorState",(()=>qa)),M(module.exports,"useEditorInteraction",(()=>Ur)),M(module.exports,"useShortcutCombination",(()=>Gr)),M(module.exports,"commandReducer",(()=>Va)),M(module.exports,"getDefaultState",(()=>ja)),M(module.exports,"CommandContextContext",(()=>Ga)),M(module.exports,"AdvancedEditorStateProvider",(()=>Wa)),M(module.exports,"AdvancedEditorContext",(()=>Ka)),M(module.exports,"UICommand",(()=>Xa)),M(module.exports,"EditorSubMenu",(()=>La)),M(module.exports,"ElementEventType",(()=>lr)),M(module.exports,"KeyEvent",(()=>hr)),M(module.exports,"gatherVaryingStepAspects",(()=>Gs));function b(t){return t.replace(/(?!\u3000)\s+/gm," ")}function Y(t){const e=t.match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm);return e?e.map(parseFloat):[]}const P=/^[A-Z-]+$/;function N(t){const e=/url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(t);return e&&(e[2]||e[3]||e[4])||""}const R=/(\[[^\]]+\])/g,k=/(#[^\s+>~.[:]+)/g,H=/(\.[^\s+>~.[:]+)/g,U=/(::[^\s+>~.[:]+|:first-line|:first-letter|:before|:after)/gi,G=/(:[\w-]+\([^)]*\))/gi,T=/(:[^\s+>~.[:]+)/g,O=/([^\s+>~.[:]+)/g;function J(t,e){const i=e.exec(t);return i?[t.replace(e," "),i.length]:[t,0]}const L=1e-8;function z(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))}function j(t,e){return(t[0]*e[0]+t[1]*e[1])/(z(t)*z(e))}function V(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(j(t,e))}function K(t){return t*t*t}function W(t){return 3*t*t*(1-t)}function X(t){return 3*t*(1-t)*(1-t)}function q(t){return(1-t)*(1-t)*(1-t)}function Z(t){return t*t}function $(t){return 2*t*(1-t)}function _(t){return(1-t)*(1-t)}function tt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class et{static empty(t){return new et(t,"EMPTY","")}split(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:" ";const{document:e,name:i}=this;return b(this.getString()).trim().split(t).map((t=>new et(e,i,t)))}hasValue(t){const e=this.value;return null!==e&&""!==e&&(t||0!==e)&&void 0!==e}isString(t){const{value:e}=this,i="string"==typeof e;return i&&t?t.test(e):i}isUrlDefinition(){return this.isString(/^url\(/)}isPixels(){if(!this.hasValue())return!1;const t=this.getString();switch(!0){case t.endsWith("px"):case/^[0-9]+$/.test(t):return!0;default:return!1}}setValue(t){return this.value=t,this}getValue(t){return void 0===t||this.hasValue()?this.value:t}getNumber(t){if(!this.hasValue())return void 0===t?0:parseFloat(t);const{value:e}=this;let i=parseFloat(e);return this.isString(/%$/)&&(i/=100),i}getString(t){return void 0===t||this.hasValue()?void 0===this.value?"":String(this.value):String(t)}getColor(t){let e=this.getString(t);return this.isNormalizedColor||(this.isNormalizedColor=!0,e=function(t){if(!t.startsWith("rgb"))return t;let e=3;return t.replace(/\d+(\.\d+)?/g,((t,i)=>e--&&i?String(Math.round(parseFloat(t))):t))}(e),this.value=e),e}getDpi(){return 96}getRem(){return this.document.rootEmSize}getEm(){return this.document.emSize}getUnits(){return this.getString().replace(/[0-9.-]/g,"")}getPixels(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.hasValue())return 0;const[i,A]="boolean"==typeof t?[void 0,t]:[t],{viewPort:n}=this.document.screen;switch(!0){case this.isString(/vmin$/):return this.getNumber()/100*Math.min(n.computeSize("x"),n.computeSize("y"));case this.isString(/vmax$/):return this.getNumber()/100*Math.max(n.computeSize("x"),n.computeSize("y"));case this.isString(/vw$/):return this.getNumber()/100*n.computeSize("x");case this.isString(/vh$/):return this.getNumber()/100*n.computeSize("y");case this.isString(/rem$/):return this.getNumber()*this.getRem();case this.isString(/em$/):return this.getNumber()*this.getEm();case this.isString(/ex$/):return this.getNumber()*this.getEm()/2;case this.isString(/px$/):return this.getNumber();case this.isString(/pt$/):return this.getNumber()*this.getDpi()*(1/72);case this.isString(/pc$/):return 15*this.getNumber();case this.isString(/cm$/):return this.getNumber()*this.getDpi()/2.54;case this.isString(/mm$/):return this.getNumber()*this.getDpi()/25.4;case this.isString(/in$/):return this.getNumber()*this.getDpi();case this.isString(/%$/)&&A:return this.getNumber()*this.getEm();case this.isString(/%$/):return this.getNumber()*n.computeSize(i);default:{const t=this.getNumber();return e&&t<1?t*n.computeSize(i):t}}}getMilliseconds(){return this.hasValue()?this.isString(/ms$/)?this.getNumber():1e3*this.getNumber():0}getRadians(){if(!this.hasValue())return 0;switch(!0){case this.isString(/deg$/):return this.getNumber()*(Math.PI/180);case this.isString(/grad$/):return this.getNumber()*(Math.PI/200);case this.isString(/rad$/):return this.getNumber();default:return this.getNumber()*(Math.PI/180)}}getDefinition(){const t=this.getString(),e=/#([^)'"]+)/.exec(t),i=(null==e?void 0:e[1])||t;return this.document.definitions[i]}getFillStyleDefinition(t,e){let i=this.getDefinition();if(!i)return null;if("function"==typeof i.createGradient&&"getBoundingBox"in t)return i.createGradient(this.document.ctx,t,e);if("function"==typeof i.createPattern){if(i.getHrefAttribute().hasValue()){const t=i.getAttribute("patternTransform");i=i.getHrefAttribute().getDefinition(),i&&t.hasValue()&&i.getAttribute("patternTransform",!0).setValue(t.value)}if(i)return i.createPattern(this.document.ctx,t,e)}return null}getTextBaseline(){if(!this.hasValue())return null;const t=this.getString();return et.textBaselineMapping[t]||null}addOpacity(t){let e=this.getColor();const i=e.length;let A=0;for(let t=0;t<i&&(","===e[t]&&A++,3!==A);t++);if(t.hasValue()&&this.isString()&&3!==A){const i=new(F(w))(e);i.ok&&(i.alpha=t.getNumber(),e=i.toRGBA())}return new et(this.document,this.name,e)}constructor(t,e,i){tt(this,"document",void 0),tt(this,"name",void 0),tt(this,"value",void 0),tt(this,"isNormalizedColor",void 0),this.document=t,this.name=e,this.value=i,this.isNormalizedColor=!1}}function it(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}tt(et,"textBaselineMapping",{baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"});class At{clear(){this.viewPorts=[]}setCurrent(t,e){this.viewPorts.push({width:t,height:e})}removeCurrent(){this.viewPorts.pop()}getRoot(){const[t]=this.viewPorts;return t||nt()}getCurrent(){const{viewPorts:t}=this,e=t[t.length-1];return e||nt()}get width(){return this.getCurrent().width}get height(){return this.getCurrent().height}computeSize(t){return"number"==typeof t?t:"x"===t?this.width:"y"===t?this.height:Math.sqrt(Math.pow(this.width,2)+Math.pow(this.height,2))/Math.sqrt(2)}constructor(){it(this,"viewPorts",[])}}function nt(){return{width:At.DEFAULT_VIEWPORT_WIDTH,height:At.DEFAULT_VIEWPORT_HEIGHT}}function at(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}it(At,"DEFAULT_VIEWPORT_WIDTH",800),it(At,"DEFAULT_VIEWPORT_HEIGHT",600);class rt{static parse(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const[i=e,A=e]=Y(t);return new rt(i,A)}static parseScale(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const[i=e,A=i]=Y(t);return new rt(i,A)}static parsePath(t){const e=Y(t),i=e.length,A=[];for(let t=0;t<i;t+=2)A.push(new rt(e[t],e[t+1]));return A}angleTo(t){return Math.atan2(t.y-this.y,t.x-this.x)}applyTransform(t){const{x:e,y:i}=this,A=e*t[0]+i*t[2]+t[4],n=e*t[1]+i*t[3]+t[5];this.x=A,this.y=n}constructor(t,e){at(this,"x",void 0),at(this,"y",void 0),this.x=t,this.y=e}}function st(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ot{isWorking(){return this.working}start(){if(this.working)return;const{screen:t,onClick:e,onMouseMove:i}=this,A=t.ctx.canvas;A.onclick=e,A.onmousemove=i,this.working=!0}stop(){if(!this.working)return;const t=this.screen.ctx.canvas;this.working=!1,t.onclick=null,t.onmousemove=null}hasEvents(){return this.working&&this.events.length>0}runEvents(){if(!this.working)return;const{screen:t,events:e,eventElements:i}=this,{style:A}=t.ctx.canvas;let n;A&&(A.cursor=""),e.forEach(((t,e)=>{let{run:A}=t;for(n=i[e];n;)A(n),n=n.parent})),this.events=[],this.eventElements=[]}checkPath(t,e){if(!this.working||!e)return;const{events:i,eventElements:A}=this;i.forEach(((i,n)=>{let{x:a,y:r}=i;!A[n]&&e.isPointInPath&&e.isPointInPath(a,r)&&(A[n]=t)}))}checkBoundingBox(t,e){if(!this.working||!e)return;const{events:i,eventElements:A}=this;i.forEach(((i,n)=>{let{x:a,y:r}=i;!A[n]&&e.isPointInBox(a,r)&&(A[n]=t)}))}mapXY(t,e){const{window:i,ctx:A}=this.screen,n=new rt(t,e);let a=A.canvas;for(;a;)n.x-=a.offsetLeft,n.y-=a.offsetTop,a=a.offsetParent;return(null==i?void 0:i.scrollX)&&(n.x+=i.scrollX),(null==i?void 0:i.scrollY)&&(n.y+=i.scrollY),n}onClick(t){const{x:e,y:i}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onclick",x:e,y:i,run(t){t.onClick&&t.onClick()}})}onMouseMove(t){const{x:e,y:i}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onmousemove",x:e,y:i,run(t){t.onMouseMove&&t.onMouseMove()}})}constructor(t){st(this,"screen",void 0),st(this,"working",void 0),st(this,"events",void 0),st(this,"eventElements",void 0),this.screen=t,this.working=!1,this.events=[],this.eventElements=[],this.onClick=this.onClick.bind(this),this.onMouseMove=this.onMouseMove.bind(this)}}function ct(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const lt="undefined"!=typeof window?window:null,gt="undefined"!=typeof fetch?fetch.bind(void 0):void 0;class ht{wait(t){this.waits.push(t)}ready(){return this.readyPromise?this.readyPromise:Promise.resolve()}isReady(){if(this.isReadyLock)return!0;const t=this.waits.every((t=>t()));return t&&(this.waits=[],this.resolveReady&&this.resolveReady()),this.isReadyLock=t,t}setDefaults(t){t.strokeStyle="rgba(0,0,0,0)",t.lineCap="butt",t.lineJoin="miter",t.miterLimit=4}setViewBox(t){let{document:e,ctx:i,aspectRatio:A,width:n,desiredWidth:a,height:r,desiredHeight:s,minX:o=0,minY:c=0,refX:l,refY:g,clip:h=!1,clipX:d=0,clipY:u=0}=t;const w=b(A).replace(/^defer\s/,""),[B,p]=w.split(" "),E=B||"xMidYMid",m=p||"meet",f=n/a,C=r/s,Q=Math.min(f,C),y=Math.max(f,C);let D=a,I=s;"meet"===m&&(D*=Q,I*=Q),"slice"===m&&(D*=y,I*=y);const x=new et(e,"refX",l),v=new et(e,"refY",g),M=x.hasValue()&&v.hasValue();if(M&&i.translate(-Q*x.getPixels("x"),-Q*v.getPixels("y")),h){const t=Q*d,e=Q*u;i.beginPath(),i.moveTo(t,e),i.lineTo(n,e),i.lineTo(n,r),i.lineTo(t,r),i.closePath(),i.clip()}if(!M){const t="meet"===m&&Q===C,e="slice"===m&&y===C,A="meet"===m&&Q===f,a="slice"===m&&y===f;E.startsWith("xMid")&&(t||e)&&i.translate(n/2-D/2,0),E.endsWith("YMid")&&(A||a)&&i.translate(0,r/2-I/2),E.startsWith("xMax")&&(t||e)&&i.translate(n-D,0),E.endsWith("YMax")&&(A||a)&&i.translate(0,r-I)}switch(!0){case"none"===E:i.scale(f,C);break;case"meet"===m:i.scale(Q,Q);break;case"slice"===m:i.scale(y,y)}i.translate(-o,-c)}start(t){let{enableRedraw:e=!1,ignoreMouse:i=!1,ignoreAnimation:A=!1,ignoreDimensions:n=!1,ignoreClear:a=!1,forceRedraw:r,scaleWidth:s,scaleHeight:o,offsetX:c,offsetY:l}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{mouse:g}=this,h=1e3/ht.FRAMERATE;if(this.isReadyLock=!1,this.frameDuration=h,this.readyPromise=new Promise((t=>{this.resolveReady=t})),this.isReady()&&this.render(t,n,a,s,o,c,l),!e)return;let d=Date.now(),w=d,B=0;const p=()=>{d=Date.now(),B=d-w,B>=h&&(w=d-B%h,this.shouldUpdate(A,r)&&(this.render(t,n,a,s,o,c,l),g.runEvents())),this.intervalId=F(u)(p)};i||g.start(),this.intervalId=F(u)(p)}stop(){this.intervalId&&(F(u).cancel(this.intervalId),this.intervalId=null),this.mouse.stop()}shouldUpdate(t,e){if(!t){const{frameDuration:t}=this;if(this.animations.reduce(((e,i)=>i.update(t)||e),!1))return!0}return!("function"!=typeof e||!e())||(!(this.isReadyLock||!this.isReady())||!!this.mouse.hasEvents())}render(t,e,i,A,n,a,r){const{viewPort:s,ctx:o,isFirstRender:c}=this,l=o.canvas;s.clear(),l.width&&l.height&&s.setCurrent(l.width,l.height);const g=t.getStyle("width"),h=t.getStyle("height");!e&&(c||"number"!=typeof A&&"number"!=typeof n)&&(g.hasValue()&&(l.width=g.getPixels("x"),l.style&&(l.style.width=`${l.width}px`)),h.hasValue()&&(l.height=h.getPixels("y"),l.style&&(l.style.height=`${l.height}px`)));let d=l.clientWidth||l.width,u=l.clientHeight||l.height;if(e&&g.hasValue()&&h.hasValue()&&(d=g.getPixels("x"),u=h.getPixels("y")),s.setCurrent(d,u),"number"==typeof a&&t.getAttribute("x",!0).setValue(a),"number"==typeof r&&t.getAttribute("y",!0).setValue(r),"number"==typeof A||"number"==typeof n){const e=Y(t.getAttribute("viewBox").getString());let i=0,a=0;if("number"==typeof A){const n=t.getStyle("width");n.hasValue()?i=n.getPixels("x")/A:e[2]&&!isNaN(e[2])&&(i=e[2]/A)}if("number"==typeof n){const i=t.getStyle("height");i.hasValue()?a=i.getPixels("y")/n:e[3]&&!isNaN(e[3])&&(a=e[3]/n)}i||(i=a),a||(a=i),t.getAttribute("width",!0).setValue(A),t.getAttribute("height",!0).setValue(n);const r=t.getStyle("transform",!0,!0);r.setValue(`${r.getString()} scale(${1/i}, ${1/a})`)}i||o.clearRect(0,0,d,u),t.render(o),c&&(this.isFirstRender=!1)}constructor(t,{fetch:e=gt,window:i=lt}={}){if(ct(this,"ctx",void 0),ct(this,"window",void 0),ct(this,"fetch",void 0),ct(this,"viewPort",void 0),ct(this,"mouse",void 0),ct(this,"animations",void 0),ct(this,"readyPromise",void 0),ct(this,"resolveReady",void 0),ct(this,"waits",void 0),ct(this,"frameDuration",void 0),ct(this,"isReadyLock",void 0),ct(this,"isFirstRender",void 0),ct(this,"intervalId",void 0),this.ctx=t,this.viewPort=new At,this.mouse=new ot(this),this.animations=[],this.waits=[],this.frameDuration=0,this.isReadyLock=!1,this.isFirstRender=!0,this.intervalId=null,this.window=i,!e)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");this.fetch=e}}function dt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}ct(ht,"defaultWindow",lt),ct(ht,"defaultFetch",gt),ct(ht,"FRAMERATE",30),ct(ht,"MAX_VIRTUAL_PIXELS",3e4);const{defaultFetch:ut}=ht,wt="undefined"!=typeof DOMParser?DOMParser:void 0;class Bt{async parse(t){return t.startsWith("<")?this.parseFromString(t):this.load(t)}parseFromString(t){const e=new this.DOMParser;try{return this.checkDocument(e.parseFromString(t,"image/svg+xml"))}catch(i){return this.checkDocument(e.parseFromString(t,"text/xml"))}}checkDocument(t){const e=t.getElementsByTagName("parsererror")[0];if(e)throw new Error(e.textContent||"Unknown parse error");return t}async load(t){const e=await this.fetch(t),i=await e.text();return this.parseFromString(i)}constructor({fetch:t=ut,DOMParser:e=wt}={}){if(dt(this,"fetch",void 0),dt(this,"DOMParser",void 0),!t)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");if(!e)throw new Error("Can't find 'DOMParser' in 'globalThis', please provide it via options");this.fetch=t,this.DOMParser=e}}function pt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Et(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function mt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ft(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Ct{apply(t){const{originX:e,originY:i,matrix:A}=this,n=e.getPixels("x"),a=i.getPixels("y");t.translate(n,a),t.transform(A[0],A[1],A[2],A[3],A[4],A[5]),t.translate(-n,-a)}unapply(t){const{originX:e,originY:i,matrix:A}=this,n=A[0],a=A[2],r=A[4],s=A[1],o=A[3],c=A[5],l=1/(n*(1*o-0*c)-a*(1*s-0*c)+r*(0*s-0*o)),g=e.getPixels("x"),h=i.getPixels("y");t.translate(g,h),t.transform(l*(1*o-0*c),l*(0*c-1*s),l*(0*r-1*a),l*(1*n-0*r),l*(a*c-r*o),l*(r*s-n*c)),t.translate(-g,-h)}applyToPoint(t){t.applyTransform(this.matrix)}constructor(t,e,i){ft(this,"type","matrix"),ft(this,"matrix",void 0),ft(this,"originX",void 0),ft(this,"originY",void 0),this.matrix=function(t){const e=Y(t);return[e[0]||0,e[1]||0,e[2]||0,e[3]||0,e[4]||0,e[5]||0]}(e),this.originX=i[0],this.originY=i[1]}}function Qt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class yt extends Ct{constructor(t,e,i){super(t,e,i),Qt(this,"type","skew"),Qt(this,"angle",void 0),this.angle=new et(t,"angle",e)}}function Dt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class It{static fromElement(t,e){const i=e.getStyle("transform",!1,!0);if(i.hasValue()){const[A,n=A]=e.getStyle("transform-origin",!1,!0).split();if(A&&n){const e=[A,n];return new It(t,i.getString(),e)}}return null}apply(t){this.transforms.forEach((e=>e.apply(t)))}unapply(t){this.transforms.forEach((e=>e.unapply(t)))}applyToPoint(t){this.transforms.forEach((e=>e.applyToPoint(t)))}constructor(t,e,i){Dt(this,"document",void 0),Dt(this,"transforms",void 0),this.document=t,this.transforms=[];const A=function(t){return b(t).trim().replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)}(e);A.forEach((t=>{if("none"===t)return;const[e,A]=function(t){const[e="",i=""]=t.split("(");return[e.trim(),i.trim().replace(")","")]}(t),n=It.transformTypes[e];n&&this.transforms.push(new n(this.document,A,i))}))}}function xt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}Dt(It,"transformTypes",{translate:class{apply(t){const{x:e,y:i}=this.point;t.translate(e||0,i||0)}unapply(t){const{x:e,y:i}=this.point;t.translate(-1*e||0,-1*i||0)}applyToPoint(t){const{x:e,y:i}=this.point;t.applyTransform([1,0,0,1,e||0,i||0])}constructor(t,e){pt(this,"type","translate"),pt(this,"point",void 0),this.point=rt.parse(e)}},rotate:class{apply(t){const{cx:e,cy:i,originX:A,originY:n,angle:a}=this,r=e+A.getPixels("x"),s=i+n.getPixels("y");t.translate(r,s),t.rotate(a.getRadians()),t.translate(-r,-s)}unapply(t){const{cx:e,cy:i,originX:A,originY:n,angle:a}=this,r=e+A.getPixels("x"),s=i+n.getPixels("y");t.translate(r,s),t.rotate(-1*a.getRadians()),t.translate(-r,-s)}applyToPoint(t){const{cx:e,cy:i,angle:A}=this,n=A.getRadians();t.applyTransform([1,0,0,1,e||0,i||0]),t.applyTransform([Math.cos(n),Math.sin(n),-Math.sin(n),Math.cos(n),0,0]),t.applyTransform([1,0,0,1,-e||0,-i||0])}constructor(t,e,i){Et(this,"type","rotate"),Et(this,"angle",void 0),Et(this,"originX",void 0),Et(this,"originY",void 0),Et(this,"cx",void 0),Et(this,"cy",void 0);const A=Y(e);this.angle=new et(t,"angle",A[0]),this.originX=i[0],this.originY=i[1],this.cx=A[1]||0,this.cy=A[2]||0}},scale:class{apply(t){const{scale:{x:e,y:i},originX:A,originY:n}=this,a=A.getPixels("x"),r=n.getPixels("y");t.translate(a,r),t.scale(e,i||e),t.translate(-a,-r)}unapply(t){const{scale:{x:e,y:i},originX:A,originY:n}=this,a=A.getPixels("x"),r=n.getPixels("y");t.translate(a,r),t.scale(1/e,1/i||e),t.translate(-a,-r)}applyToPoint(t){const{x:e,y:i}=this.scale;t.applyTransform([e||0,0,0,i||0,0,0])}constructor(t,e,i){mt(this,"type","scale"),mt(this,"scale",void 0),mt(this,"originX",void 0),mt(this,"originY",void 0);const A=rt.parseScale(e);0!==A.x&&0!==A.y||(A.x=L,A.y=L),this.scale=A,this.originX=i[0],this.originY=i[1]}},matrix:Ct,skewX:class extends yt{constructor(t,e,i){var A,n,a;super(t,e,i),a="skewX",(n="type")in(A=this)?Object.defineProperty(A,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):A[n]=a,this.matrix=[1,0,Math.tan(this.angle.getRadians()),1,0,0]}},skewY:class extends yt{constructor(t,e,i){var A,n,a;super(t,e,i),a="skewY",(n="type")in(A=this)?Object.defineProperty(A,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):A[n]=a,this.matrix=[1,Math.tan(this.angle.getRadians()),0,1,0,0]}}});class vt{getAttribute(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.attributes[t];if(!i&&e){const e=new et(this.document,t,"");return this.attributes[t]=e,e}return i||et.empty(this.document)}getHrefAttribute(){let t;for(const e in this.attributes)if("href"===e||e.endsWith(":href")){t=this.attributes[e];break}return t||et.empty(this.document)}getStyle(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const A=this.styles[t];if(A)return A;const n=this.getAttribute(t);if(n.hasValue())return this.styles[t]=n,n;if(!i){const{parent:e}=this;if(e){const i=e.getStyle(t);if(i.hasValue())return i}}if(e){const e=new et(this.document,t,"");return this.styles[t]=e,e}return et.empty(this.document)}render(t){if("none"!==this.getStyle("display").getString()&&"hidden"!==this.getStyle("visibility").getString()){if(t.save(),this.getStyle("mask").hasValue()){const e=this.getStyle("mask").getDefinition();e&&(this.applyEffects(t),e.apply(t,this))}else if("none"!==this.getStyle("filter").getValue("none")){const e=this.getStyle("filter").getDefinition();e&&(this.applyEffects(t),e.apply(t,this))}else this.setContext(t),this.renderChildren(t),this.clearContext(t);t.restore()}}setContext(t){}applyEffects(t){const e=It.fromElement(this.document,this);e&&e.apply(t);const i=this.getStyle("clip-path",!1,!0);if(i.hasValue()){const e=i.getDefinition();e&&e.apply(t)}}clearContext(t){}renderChildren(t){this.children.forEach((e=>{e.render(t)}))}addChild(t){const e=t instanceof vt?t:this.document.createElement(t);e.parent=this,vt.ignoreChildTypes.includes(e.type)||this.children.push(e)}matchesSelector(t){var e;const{node:i}=this;if(!i)return!1;if("function"==typeof i.matches)return i.matches(t);const A=null===(e=i.getAttribute)||void 0===e?void 0:e.call(i,"class");return!(!A||""===A)&&A.split(" ").some((e=>`.${e}`===t))}addStylesFromStyleDefinition(){const{styles:t,stylesSpecificity:e}=this.document;let i;for(const A in t)if(!A.startsWith("@")&&this.matchesSelector(A)){const n=t[A],a=e[A];if(n)for(const t in n){let e=this.stylesSpecificity[t];void 0===e&&(e="000"),a&&a>=e&&(i=n[t],i&&(this.styles[t]=i),this.stylesSpecificity[t]=a)}}}removeStyles(t,e){return e.reduce(((e,i)=>{const A=t.getStyle(i);if(!A.hasValue())return e;const n=A.getString();return A.setValue(""),[...e,[i,n]]}),[])}restoreStyles(t,e){e.forEach((e=>{let[i,A]=e;t.getStyle(i,!0).setValue(A)}))}isFirstChild(){var t;return 0===(null===(t=this.parent)||void 0===t?void 0:t.children.indexOf(this))}constructor(t,e,i=!1){if(xt(this,"document",void 0),xt(this,"node",void 0),xt(this,"captureTextNodes",void 0),xt(this,"type",void 0),xt(this,"attributes",void 0),xt(this,"styles",void 0),xt(this,"stylesSpecificity",void 0),xt(this,"animationFrozen",void 0),xt(this,"animationFrozenValue",void 0),xt(this,"parent",void 0),xt(this,"children",void 0),this.document=t,this.node=e,this.captureTextNodes=i,this.type="",this.attributes={},this.styles={},this.stylesSpecificity={},this.animationFrozen=!1,this.animationFrozenValue="",this.parent=null,this.children=[],!e||1!==e.nodeType)return;if(Array.from(e.attributes).forEach((e=>{const i=(A=e.nodeName,P.test(A)?A.toLowerCase():A);var A;this.attributes[i]=new et(t,i,e.value)})),this.addStylesFromStyleDefinition(),this.getAttribute("style").hasValue()){this.getAttribute("style").getString().split(";").map((t=>t.trim())).forEach((e=>{if(!e)return;const[i,A]=e.split(":").map((t=>t.trim()));i&&(this.styles[i]=new et(t,i,A))}))}const{definitions:A}=t,n=this.getAttribute("id");n.hasValue()&&(A[n.getString()]||(A[n.getString()]=this)),Array.from(e.childNodes).forEach((e=>{if(1===e.nodeType)this.addChild(e);else if(i&&(3===e.nodeType||4===e.nodeType)){const i=t.createTextNode(e);i.getText().length>0&&this.addChild(i)}}))}}xt(vt,"ignoreChildTypes",["title"]);class Mt extends vt{constructor(t,e,i){super(t,e,i)}}function St(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Ft(t){const e=t.trim();return/^('|")/.test(e)?e:`"${e}"`}function bt(t){if(!t)return"";const e=t.trim().toLowerCase();switch(e){case"normal":case"italic":case"oblique":case"inherit":case"initial":case"unset":return e;default:return/^oblique\s+(-|)\d+deg$/.test(e)?e:""}}function Yt(t){if(!t)return"";const e=t.trim().toLowerCase();switch(e){case"normal":case"bold":case"lighter":case"bolder":case"inherit":case"initial":case"unset":return e;default:return/^[\d.]+$/.test(e)?e:""}}class Pt{static parse(){let t=arguments.length>1?arguments[1]:void 0,e="",i="",A="",n="",a="";const r=b(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").trim().split(" "),s={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1};return r.forEach((t=>{switch(!0){case!s.fontStyle&&Pt.styles.includes(t):"inherit"!==t&&(e=t),s.fontStyle=!0;break;case!s.fontVariant&&Pt.variants.includes(t):"inherit"!==t&&(i=t),s.fontStyle=!0,s.fontVariant=!0;break;case!s.fontWeight&&Pt.weights.includes(t):"inherit"!==t&&(A=t),s.fontStyle=!0,s.fontVariant=!0,s.fontWeight=!0;break;case!s.fontSize:"inherit"!==t&&(n=t.split("/")[0]||""),s.fontStyle=!0,s.fontVariant=!0,s.fontWeight=!0,s.fontSize=!0;break;default:"inherit"!==t&&(a+=t)}})),new Pt(e,i,A,n,a,t)}toString(){return[bt(this.fontStyle),this.fontVariant,Yt(this.fontWeight),this.fontSize,(t=this.fontFamily,void 0===d?t:t.trim().split(",").map(Ft).join(","))].join(" ").trim();var t}constructor(t,e,i,A,n,a){St(this,"fontFamily",void 0),St(this,"fontSize",void 0),St(this,"fontStyle",void 0),St(this,"fontWeight",void 0),St(this,"fontVariant",void 0);const r=a?"string"==typeof a?Pt.parse(a):a:{};this.fontFamily=n||r.fontFamily,this.fontSize=A||r.fontSize,this.fontStyle=t||r.fontStyle,this.fontWeight=i||r.fontWeight,this.fontVariant=e||r.fontVariant}}function Nt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}St(Pt,"styles","normal|italic|oblique|inherit"),St(Pt,"variants","normal|small-caps|inherit"),St(Pt,"weights","normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit");class Rt{get x(){return this.x1}get y(){return this.y1}get width(){return this.x2-this.x1}get height(){return this.y2-this.y1}addPoint(t,e){void 0!==t&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),t<this.x1&&(this.x1=t),t>this.x2&&(this.x2=t)),void 0!==e&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))}addX(t){this.addPoint(t,0)}addY(t){this.addPoint(0,t)}addBoundingBox(t){if(!t)return;const{x1:e,y1:i,x2:A,y2:n}=t;this.addPoint(e,i),this.addPoint(A,n)}sumCubic(t,e,i,A,n){return Math.pow(1-t,3)*e+3*Math.pow(1-t,2)*t*i+3*(1-t)*Math.pow(t,2)*A+Math.pow(t,3)*n}bezierCurveAdd(t,e,i,A,n){const a=6*e-12*i+6*A,r=-3*e+9*i-9*A+3*n,s=3*i-3*e;if(0===r){if(0===a)return;const r=-s/a;return void(0<r&&r<1&&(t?this.addX(this.sumCubic(r,e,i,A,n)):this.addY(this.sumCubic(r,e,i,A,n))))}const o=Math.pow(a,2)-4*s*r;if(o<0)return;const c=(-a+Math.sqrt(o))/(2*r);0<c&&c<1&&(t?this.addX(this.sumCubic(c,e,i,A,n)):this.addY(this.sumCubic(c,e,i,A,n)));const l=(-a-Math.sqrt(o))/(2*r);0<l&&l<1&&(t?this.addX(this.sumCubic(l,e,i,A,n)):this.addY(this.sumCubic(l,e,i,A,n)))}addBezierCurve(t,e,i,A,n,a,r,s){this.addPoint(t,e),this.addPoint(r,s),this.bezierCurveAdd(!0,t,i,n,r),this.bezierCurveAdd(!1,e,A,a,s)}addQuadraticCurve(t,e,i,A,n,a){const r=t+2/3*(i-t),s=e+2/3*(A-e),o=r+1/3*(n-t),c=s+1/3*(a-e);this.addBezierCurve(t,e,r,o,s,c,n,a)}isPointInBox(t,e){const{x1:i,y1:A,x2:n,y2:a}=this;return i<=t&&t<=n&&A<=e&&e<=a}constructor(t=Number.NaN,e=Number.NaN,i=Number.NaN,A=Number.NaN){Nt(this,"x1",void 0),Nt(this,"y1",void 0),Nt(this,"x2",void 0),Nt(this,"y2",void 0),this.x1=t,this.y1=e,this.x2=i,this.y2=A,this.addPoint(t,e),this.addPoint(i,A)}}class kt extends vt{calculateOpacity(){let t=1,e=this;for(;e;){const i=e.getStyle("opacity",!1,!0);i.hasValue(!0)&&(t*=i.getNumber()),e=e.parent}return t}setContext(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e){const e=this.getStyle("fill"),i=this.getStyle("fill-opacity"),A=this.getStyle("stroke"),n=this.getStyle("stroke-opacity");if(e.isUrlDefinition()){const A=e.getFillStyleDefinition(this,i);A&&(t.fillStyle=A)}else if(e.hasValue()){"currentColor"===e.getString()&&e.setValue(this.getStyle("color").getColor());const i=e.getColor();"inherit"!==i&&(t.fillStyle="none"===i?"rgba(0,0,0,0)":i)}if(i.hasValue()){const e=new et(this.document,"fill",t.fillStyle).addOpacity(i).getColor();t.fillStyle=e}if(A.isUrlDefinition()){const e=A.getFillStyleDefinition(this,n);e&&(t.strokeStyle=e)}else if(A.hasValue()){"currentColor"===A.getString()&&A.setValue(this.getStyle("color").getColor());const e=A.getString();"inherit"!==e&&(t.strokeStyle="none"===e?"rgba(0,0,0,0)":e)}if(n.hasValue()){const e=new et(this.document,"stroke",t.strokeStyle).addOpacity(n).getString();t.strokeStyle=e}const a=this.getStyle("stroke-width");if(a.hasValue()){const e=a.getPixels();t.lineWidth=e||L}const r=this.getStyle("stroke-linecap"),s=this.getStyle("stroke-linejoin"),o=this.getStyle("stroke-miterlimit"),c=this.getStyle("stroke-dasharray"),l=this.getStyle("stroke-dashoffset");if(r.hasValue()&&(t.lineCap=r.getString()),s.hasValue()&&(t.lineJoin=s.getString()),o.hasValue()&&(t.miterLimit=o.getNumber()),c.hasValue()&&"none"!==c.getString()){const e=Y(c.getString());void 0!==t.setLineDash?t.setLineDash(e):void 0!==t.webkitLineDash?t.webkitLineDash=e:void 0===t.mozDash||1===e.length&&0===e[0]||(t.mozDash=e);const i=l.getPixels();void 0!==t.lineDashOffset?t.lineDashOffset=i:void 0!==t.webkitLineDashOffset?t.webkitLineDashOffset=i:void 0!==t.mozDashOffset&&(t.mozDashOffset=i)}}if(this.modifiedEmSizeStack=!1,void 0!==t.font){const e=this.getStyle("font"),i=this.getStyle("font-style"),A=this.getStyle("font-variant"),n=this.getStyle("font-weight"),a=this.getStyle("font-size"),r=this.getStyle("font-family"),s=new Pt(i.getString(),A.getString(),n.getString(),a.hasValue()?`${a.getPixels(!0)}px`:"",r.getString(),Pt.parse(e.getString(),t.font));i.setValue(s.fontStyle),A.setValue(s.fontVariant),n.setValue(s.fontWeight),a.setValue(s.fontSize),r.setValue(s.fontFamily),t.font=s.toString(),a.isPixels()&&(this.document.emSize=a.getPixels(),this.modifiedEmSizeStack=!0)}e||(this.applyEffects(t),t.globalAlpha=this.calculateOpacity())}clearContext(t){super.clearContext(t),this.modifiedEmSizeStack&&this.document.popEmSize()}constructor(...t){var e,i,A;super(...t),A=!1,(i="modifiedEmSizeStack")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}}function Ht(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Ut extends kt{setContext(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];super.setContext(t,e);const i=this.getStyle("dominant-baseline").getTextBaseline()||this.getStyle("alignment-baseline").getTextBaseline();i&&(t.textBaseline=i)}initializeCoordinates(){this.x=0,this.y=0,this.leafTexts=[],this.textChunkStart=0,this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY}getBoundingBox(t){if("text"!==this.type)return this.getTElementBoundingBox(t);this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(t);let e=null;return this.children.forEach(((i,A)=>{const n=this.getChildBoundingBox(t,this,this,A);e?e.addBoundingBox(n):e=n})),e}getFontSize(){const{document:t,parent:e}=this,i=Pt.parse(t.ctx.font).fontSize;return e.getStyle("font-size").getNumber(i)}getTElementBoundingBox(t){const e=this.getFontSize();return new Rt(this.x,this.y-e,this.x+this.measureText(t),this.y)}getGlyph(t,e,i){const A=e[i];let n;if(t.isArabic){var a;const r=e.length,s=e[i-1],o=e[i+1];let c="isolated";(0===i||" "===s)&&i<r-1&&" "!==o&&(c="terminal"),i>0&&" "!==s&&i<r-1&&" "!==o&&(c="medial"),i>0&&" "!==s&&(i===r-1||" "===o)&&(c="initial"),n=(null===(a=t.arabicGlyphs[A])||void 0===a?void 0:a[c])||t.glyphs[A]}else n=t.glyphs[A];return n||(n=t.missingGlyph),n}getText(){return""}getTextFromNode(t){const e=t||this.node,i=Array.from(e.parentNode.childNodes),A=i.indexOf(e),n=i.length-1;let a=b(e.textContent||"");return 0===A&&(a=a.replace(/^[\n \t]+/,"")),A===n&&(a=function(t){return t.replace(/[\n \t]+$/,"")}(a)),a}renderChildren(t){if("text"!==this.type)return void this.renderTElementChildren(t);this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(t),this.children.forEach(((e,i)=>{this.renderChild(t,this,this,i)}));const{mouse:e}=this.document.screen;e.isWorking()&&e.checkBoundingBox(this,this.getBoundingBox(t))}renderTElementChildren(t){const{document:e,parent:i}=this,A=this.getText(),n=i.getStyle("font-family").getDefinition();if(null==n?void 0:n.fontFace){const{unitsPerEm:a}=n.fontFace,r=Pt.parse(e.ctx.font),s=i.getStyle("font-size").getNumber(r.fontSize),o=i.getStyle("font-style").getString(r.fontStyle),c=s/a,l=n.isRTL?A.split("").reverse().join(""):A,g=Y(i.getAttribute("dx").getString()),h=l.length;for(let e=0;e<h;e++){const i=this.getGlyph(n,l,e);t.translate(this.x,this.y),t.scale(c,-c);const A=t.lineWidth;t.lineWidth=t.lineWidth*a/s,"italic"===o&&t.transform(1,0,.4,1,0,0),i.render(t),"italic"===o&&t.transform(1,0,-.4,1,0,0),t.lineWidth=A,t.scale(1/c,-1/c),t.translate(-this.x,-this.y),this.x+=s*(i.horizAdvX||n.horizAdvX)/a,void 0===g[e]||isNaN(g[e])||(this.x+=g[e])}return}const{x:a,y:r}=this;t.fillStyle&&t.fillText(A,a,r),t.strokeStyle&&t.strokeText(A,a,r)}applyAnchoring(){if(this.textChunkStart>=this.leafTexts.length)return;const t=this.leafTexts[this.textChunkStart],e=t.getStyle("text-anchor").getString("start");let i=0;i="start"===e?t.x-this.minX:"end"===e?t.x-this.maxX:t.x-(this.minX+this.maxX)/2;for(let t=this.textChunkStart;t<this.leafTexts.length;t++)this.leafTexts[t].x+=i;this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.textChunkStart=this.leafTexts.length}adjustChildCoordinatesRecursive(t){this.children.forEach(((e,i)=>{this.adjustChildCoordinatesRecursiveCore(t,this,this,i)})),this.applyAnchoring()}adjustChildCoordinatesRecursiveCore(t,e,i,A){const n=i.children[A];n.children.length>0?n.children.forEach(((i,A)=>{e.adjustChildCoordinatesRecursiveCore(t,e,n,A)})):this.adjustChildCoordinates(t,e,i,A)}adjustChildCoordinates(t,e,i,A){const n=i.children[A];if("function"!=typeof n.measureText)return n;t.save(),n.setContext(t,!0);const a=n.getAttribute("x"),r=n.getAttribute("y"),s=n.getAttribute("dx"),o=n.getAttribute("dy"),c=n.getStyle("font-family").getDefinition(),l=Boolean(null==c?void 0:c.isRTL);0===A&&(a.hasValue()||a.setValue(n.getInheritedAttribute("x")),r.hasValue()||r.setValue(n.getInheritedAttribute("y")),s.hasValue()||s.setValue(n.getInheritedAttribute("dx")),o.hasValue()||o.setValue(n.getInheritedAttribute("dy")));const g=n.measureText(t);return l&&(e.x-=g),a.hasValue()?(e.applyAnchoring(),n.x=a.getPixels("x"),s.hasValue()&&(n.x+=s.getPixels("x"))):(s.hasValue()&&(e.x+=s.getPixels("x")),n.x=e.x),e.x=n.x,l||(e.x+=g),r.hasValue()?(n.y=r.getPixels("y"),o.hasValue()&&(n.y+=o.getPixels("y"))):(o.hasValue()&&(e.y+=o.getPixels("y")),n.y=e.y),e.y=n.y,e.leafTexts.push(n),e.minX=Math.min(e.minX,n.x,n.x+g),e.maxX=Math.max(e.maxX,n.x,n.x+g),n.clearContext(t),t.restore(),n}getChildBoundingBox(t,e,i,A){const n=i.children[A];if("function"!=typeof n.getBoundingBox)return null;const a=n.getBoundingBox(t);return a&&n.children.forEach(((i,A)=>{const r=e.getChildBoundingBox(t,e,n,A);a.addBoundingBox(r)})),a}renderChild(t,e,i,A){const n=i.children[A];n.render(t),n.children.forEach(((i,A)=>{e.renderChild(t,e,n,A)}))}measureText(t){const{measureCache:e}=this;if(~e)return e;const i=this.getText(),A=this.measureTargetText(t,i);return this.measureCache=A,A}measureTargetText(t,e){if(!e.length)return 0;const{parent:i}=this,A=i.getStyle("font-family").getDefinition();if(A){const t=this.getFontSize(),n=A.isRTL?e.split("").reverse().join(""):e,a=Y(i.getAttribute("dx").getString()),r=n.length;let s=0;for(let e=0;e<r;e++){s+=(this.getGlyph(A,n,e).horizAdvX||A.horizAdvX)*t/A.fontFace.unitsPerEm,void 0===a[e]||isNaN(a[e])||(s+=a[e])}return s}if(!t.measureText)return 10*e.length;t.save(),this.setContext(t,!0);const{width:n}=t.measureText(e);return this.clearContext(t),t.restore(),n}getInheritedAttribute(t){let e=this;for(;e instanceof Ut&&e.isFirstChild()&&e.parent;){const i=e.parent.getAttribute(t);if(i.hasValue(!0))return i.getString("0");e=e.parent}return null}constructor(t,e,i){super(t,e,new.target===Ut||i),Ht(this,"type","text"),Ht(this,"x",0),Ht(this,"y",0),Ht(this,"leafTexts",[]),Ht(this,"textChunkStart",0),Ht(this,"minX",Number.POSITIVE_INFINITY),Ht(this,"maxX",Number.NEGATIVE_INFINITY),Ht(this,"measureCache",-1)}}function Gt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Tt extends Ut{getText(){return this.text}constructor(t,e,i){super(t,e,new.target===Tt||i),Gt(this,"type","tspan"),Gt(this,"text",void 0),this.text=this.children.length>0?"":this.getTextFromNode()}}class Ot extends Tt{constructor(...t){var e,i,A;super(...t),A="textNode",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}}function Jt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Lt extends B.SVGPathData{reset(){this.i=-1,this.command=null,this.previousCommand=null,this.start=new rt(0,0),this.control=new rt(0,0),this.current=new rt(0,0),this.points=[],this.angles=[]}isEnd(){const{i:t,commands:e}=this;return t>=e.length-1}next(){const t=this.commands[++this.i];return this.previousCommand=this.command,this.command=t,t}getPoint(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"x",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y";const i=new rt(this.command[t],this.command[e]);return this.makeAbsolute(i)}getAsControlPoint(t,e){const i=this.getPoint(t,e);return this.control=i,i}getAsCurrentPoint(t,e){const i=this.getPoint(t,e);return this.current=i,i}getReflectedControlPoint(){const t=this.previousCommand.type;if(t!==B.SVGPathData.CURVE_TO&&t!==B.SVGPathData.SMOOTH_CURVE_TO&&t!==B.SVGPathData.QUAD_TO&&t!==B.SVGPathData.SMOOTH_QUAD_TO)return this.current;const{current:{x:e,y:i},control:{x:A,y:n}}=this;return new rt(2*e-A,2*i-n)}makeAbsolute(t){if(this.command.relative){const{x:e,y:i}=this.current;t.x+=e,t.y+=i}return t}addMarker(t,e,i){const{points:A,angles:n}=this;i&&n.length>0&&!n[n.length-1]&&(n[n.length-1]=A[A.length-1].angleTo(i)),this.addMarkerAngle(t,e?e.angleTo(t):null)}addMarkerAngle(t,e){this.points.push(t),this.angles.push(e)}getMarkerPoints(){return this.points}getMarkerAngles(){const{angles:t}=this,e=t.length;for(let i=0;i<e;i++)if(!t[i])for(let A=i+1;A<e;A++)if(t[A]){t[i]=t[A];break}return t}constructor(t){super(t.replace(/([+\-.])\s+/gm,"$1").replace(/[^MmZzLlHhVvCcSsQqTtAae\d\s.,+-].*/g,"")),Jt(this,"control",new rt(0,0)),Jt(this,"start",new rt(0,0)),Jt(this,"current",new rt(0,0)),Jt(this,"command",null),Jt(this,"commands",this.commands),Jt(this,"i",-1),Jt(this,"previousCommand",null),Jt(this,"points",[]),Jt(this,"angles",[])}}function zt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class jt extends kt{path(t){const{pathParser:e}=this,i=new Rt;for(e.reset(),t&&t.beginPath();!e.isEnd();)switch(e.next().type){case Lt.MOVE_TO:this.pathM(t,i);break;case Lt.LINE_TO:this.pathL(t,i);break;case Lt.HORIZ_LINE_TO:this.pathH(t,i);break;case Lt.VERT_LINE_TO:this.pathV(t,i);break;case Lt.CURVE_TO:this.pathC(t,i);break;case Lt.SMOOTH_CURVE_TO:this.pathS(t,i);break;case Lt.QUAD_TO:this.pathQ(t,i);break;case Lt.SMOOTH_QUAD_TO:this.pathT(t,i);break;case Lt.ARC:this.pathA(t,i);break;case Lt.CLOSE_PATH:this.pathZ(t,i)}return i}getBoundingBox(t){return this.path()}getMarkers(){const{pathParser:t}=this,e=t.getMarkerPoints(),i=t.getMarkerAngles();if(!e||!i)return null;return e.map(((t,e)=>[t,i[e]]))}renderChildren(t){this.path(t),this.document.screen.mouse.checkPath(this,t);const e=this.getStyle("fill-rule");""!==t.fillStyle&&("inherit"!==e.getString("inherit")?t.fill(e.getString()):t.fill()),""!==t.strokeStyle&&("non-scaling-stroke"===this.getAttribute("vector-effect").getString()?(t.save(),t.setTransform(1,0,0,1,0,0),t.stroke(),t.restore()):t.stroke());const i=this.getMarkers();if(i){const e=i.length-1,A=this.getStyle("marker-start"),n=this.getStyle("marker-mid"),a=this.getStyle("marker-end");if(A.isUrlDefinition()){const e=A.getDefinition(),[n,a]=i[0];e&&e.render(t,n,null===a?void 0:a)}if(n.isUrlDefinition()){const A=n.getDefinition();for(let n=1;n<e;n++){const[e,a]=i[n];A&&A.render(t,e,null===a?void 0:a)}}if(a.isUrlDefinition()){const A=a.getDefinition(),[n,r]=i[e];A&&A.render(t,n,null===r?void 0:r)}}}static pathM(t){const e=t.getAsCurrentPoint();return t.start=t.current,{point:e}}pathM(t,e){const{pathParser:i}=this,{point:A}=jt.pathM(i),{x:n,y:a}=A;i.addMarker(A),e.addPoint(n,a),t&&t.moveTo(n,a)}static pathL(t){const{current:e}=t;return{current:e,point:t.getAsCurrentPoint()}}pathL(t,e){const{pathParser:i}=this,{current:A,point:n}=jt.pathL(i),{x:a,y:r}=n;i.addMarker(n,A),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathH(t){const{current:e,command:i}=t,A=new rt(((null==i?void 0:i.relative)?e.x:0)+i.x,e.y);return t.current=A,{current:e,point:A}}pathH(t,e){const{pathParser:i}=this,{current:A,point:n}=jt.pathH(i),{x:a,y:r}=n;i.addMarker(n,A),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathV(t){const{current:e,command:i}=t,A=new rt(e.x,(i.relative?e.y:0)+i.y);return t.current=A,{current:e,point:A}}pathV(t,e){const{pathParser:i}=this,{current:A,point:n}=jt.pathV(i),{x:a,y:r}=n;i.addMarker(n,A),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathC(t){const{current:e}=t;return{current:e,point:t.getPoint("x1","y1"),controlPoint:t.getAsControlPoint("x2","y2"),currentPoint:t.getAsCurrentPoint()}}pathC(t,e){const{pathParser:i}=this,{current:A,point:n,controlPoint:a,currentPoint:r}=jt.pathC(i);i.addMarker(r,a,n),e.addBezierCurve(A.x,A.y,n.x,n.y,a.x,a.y,r.x,r.y),t&&t.bezierCurveTo(n.x,n.y,a.x,a.y,r.x,r.y)}static pathS(t){const{current:e}=t;return{current:e,point:t.getReflectedControlPoint(),controlPoint:t.getAsControlPoint("x2","y2"),currentPoint:t.getAsCurrentPoint()}}pathS(t,e){const{pathParser:i}=this,{current:A,point:n,controlPoint:a,currentPoint:r}=jt.pathS(i);i.addMarker(r,a,n),e.addBezierCurve(A.x,A.y,n.x,n.y,a.x,a.y,r.x,r.y),t&&t.bezierCurveTo(n.x,n.y,a.x,a.y,r.x,r.y)}static pathQ(t){const{current:e}=t;return{current:e,controlPoint:t.getAsControlPoint("x1","y1"),currentPoint:t.getAsCurrentPoint()}}pathQ(t,e){const{pathParser:i}=this,{current:A,controlPoint:n,currentPoint:a}=jt.pathQ(i);i.addMarker(a,n,n),e.addQuadraticCurve(A.x,A.y,n.x,n.y,a.x,a.y),t&&t.quadraticCurveTo(n.x,n.y,a.x,a.y)}static pathT(t){const{current:e}=t,i=t.getReflectedControlPoint();t.control=i;return{current:e,controlPoint:i,currentPoint:t.getAsCurrentPoint()}}pathT(t,e){const{pathParser:i}=this,{current:A,controlPoint:n,currentPoint:a}=jt.pathT(i);i.addMarker(a,n,n),e.addQuadraticCurve(A.x,A.y,n.x,n.y,a.x,a.y),t&&t.quadraticCurveTo(n.x,n.y,a.x,a.y)}static pathA(t){const{current:e,command:i}=t;let{rX:A,rY:n,xRot:a,lArcFlag:r,sweepFlag:s}=i;const o=a*(Math.PI/180),c=t.getAsCurrentPoint(),l=new rt(Math.cos(o)*(e.x-c.x)/2+Math.sin(o)*(e.y-c.y)/2,-Math.sin(o)*(e.x-c.x)/2+Math.cos(o)*(e.y-c.y)/2),g=Math.pow(l.x,2)/Math.pow(A,2)+Math.pow(l.y,2)/Math.pow(n,2);g>1&&(A*=Math.sqrt(g),n*=Math.sqrt(g));let h=(r===s?-1:1)*Math.sqrt((Math.pow(A,2)*Math.pow(n,2)-Math.pow(A,2)*Math.pow(l.y,2)-Math.pow(n,2)*Math.pow(l.x,2))/(Math.pow(A,2)*Math.pow(l.y,2)+Math.pow(n,2)*Math.pow(l.x,2)));isNaN(h)&&(h=0);const d=new rt(h*A*l.y/n,h*-n*l.x/A),u=new rt((e.x+c.x)/2+Math.cos(o)*d.x-Math.sin(o)*d.y,(e.y+c.y)/2+Math.sin(o)*d.x+Math.cos(o)*d.y),w=V([1,0],[(l.x-d.x)/A,(l.y-d.y)/n]),B=[(l.x-d.x)/A,(l.y-d.y)/n],p=[(-l.x-d.x)/A,(-l.y-d.y)/n];let E=V(B,p);return j(B,p)<=-1&&(E=Math.PI),j(B,p)>=1&&(E=0),{currentPoint:c,rX:A,rY:n,sweepFlag:s,xAxisRotation:o,centp:u,a1:w,ad:E}}pathA(t,e){const{pathParser:i}=this,{currentPoint:A,rX:n,rY:a,sweepFlag:r,xAxisRotation:s,centp:o,a1:c,ad:l}=jt.pathA(i),g=1-r?1:-1,h=c+g*(l/2),d=new rt(o.x+n*Math.cos(h),o.y+a*Math.sin(h));if(i.addMarkerAngle(d,h-g*Math.PI/2),i.addMarkerAngle(A,h-g*Math.PI),e.addPoint(A.x,A.y),t&&!isNaN(c)&&!isNaN(l)){const e=n>a?n:a,i=n>a?1:n/a,A=n>a?a/n:1;t.translate(o.x,o.y),t.rotate(s),t.scale(i,A),t.arc(0,0,e,c,c+l,Boolean(1-r)),t.scale(1/i,1/A),t.rotate(-s),t.translate(-o.x,-o.y)}}static pathZ(t){t.current=t.start}pathZ(t,e){jt.pathZ(this.pathParser),t&&e.x1!==e.x2&&e.y1!==e.y2&&t.closePath()}constructor(t,e,i){super(t,e,i),zt(this,"type","path"),zt(this,"pathParser",void 0),this.pathParser=new Lt(this.getAttribute("d").getString())}}function Vt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Kt extends kt{setContext(t){var e;const{document:i}=this,{screen:A,window:n}=i,a=t.canvas;if(A.setDefaults(t),"style"in a&&void 0!==t.font&&n&&void 0!==n.getComputedStyle){t.font=n.getComputedStyle(a).getPropertyValue("font");const e=new et(i,"fontSize",Pt.parse(t.font).fontSize);e.hasValue()&&(i.rootEmSize=e.getPixels("y"),i.emSize=i.rootEmSize)}this.getAttribute("x").hasValue()||this.getAttribute("x",!0).setValue(0),this.getAttribute("y").hasValue()||this.getAttribute("y",!0).setValue(0);let{width:r,height:s}=A.viewPort;this.getStyle("width").hasValue()||this.getStyle("width",!0).setValue("100%"),this.getStyle("height").hasValue()||this.getStyle("height",!0).setValue("100%"),this.getStyle("color").hasValue()||this.getStyle("color",!0).setValue("black");const o=this.getAttribute("refX"),c=this.getAttribute("refY"),l=this.getAttribute("viewBox"),g=l.hasValue()?Y(l.getString()):null,h=!this.root&&"visible"!==this.getStyle("overflow").getValue("hidden");let d=0,u=0,w=0,B=0;g&&(d=g[0],u=g[1]),this.root||(r=this.getStyle("width").getPixels("x"),s=this.getStyle("height").getPixels("y"),"marker"===this.type&&(w=d,B=u,d=0,u=0)),A.viewPort.setCurrent(r,s),!this.node||this.parent&&"foreignObject"!==(null===(e=this.node.parentNode)||void 0===e?void 0:e.nodeName)||!this.getStyle("transform",!1,!0).hasValue()||this.getStyle("transform-origin",!1,!0).hasValue()||this.getStyle("transform-origin",!0,!0).setValue("50% 50%"),super.setContext(t),t.translate(this.getAttribute("x").getPixels("x"),this.getAttribute("y").getPixels("y")),g&&(r=g[2],s=g[3]),i.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:A.viewPort.width,desiredWidth:r,height:A.viewPort.height,desiredHeight:s,minX:d,minY:u,refX:o.getValue(),refY:c.getValue(),clip:h,clipX:w,clipY:B}),g&&(A.viewPort.removeCurrent(),A.viewPort.setCurrent(r,s))}clearContext(t){super.clearContext(t),this.document.screen.viewPort.removeCurrent()}resize(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const A=this.getAttribute("width",!0),n=this.getAttribute("height",!0),a=this.getAttribute("viewBox"),r=this.getAttribute("style"),s=A.getNumber(0),o=n.getNumber(0);if(i)if("string"==typeof i)this.getAttribute("preserveAspectRatio",!0).setValue(i);else{const t=this.getAttribute("preserveAspectRatio");t.hasValue()&&t.setValue(t.getString().replace(/^\s*(\S.*\S)\s*$/,"$1"))}if(A.setValue(t),n.setValue(e),a.hasValue()||a.setValue(`0 0 ${s||t} ${o||e}`),r.hasValue()){const i=this.getStyle("width"),A=this.getStyle("height");i.hasValue()&&i.setValue(`${t}px`),A.hasValue()&&A.setValue(`${e}px`)}}constructor(...t){super(...t),Vt(this,"type","svg"),Vt(this,"root",!1)}}class Wt extends jt{path(t){const e=this.getAttribute("x").getPixels("x"),i=this.getAttribute("y").getPixels("y"),A=this.getStyle("width",!1,!0).getPixels("x"),n=this.getStyle("height",!1,!0).getPixels("y"),a=this.getAttribute("rx"),r=this.getAttribute("ry");let s=a.getPixels("x"),o=r.getPixels("y");if(a.hasValue()&&!r.hasValue()&&(o=s),r.hasValue()&&!a.hasValue()&&(s=o),s=Math.min(s,A/2),o=Math.min(o,n/2),t){const a=(Math.sqrt(2)-1)/3*4;t.beginPath(),n>0&&A>0&&(t.moveTo(e+s,i),t.lineTo(e+A-s,i),t.bezierCurveTo(e+A-s+a*s,i,e+A,i+o-a*o,e+A,i+o),t.lineTo(e+A,i+n-o),t.bezierCurveTo(e+A,i+n-o+a*o,e+A-s+a*s,i+n,e+A-s,i+n),t.lineTo(e+s,i+n),t.bezierCurveTo(e+s-a*s,i+n,e,i+n-o+a*o,e,i+n-o),t.lineTo(e,i+o),t.bezierCurveTo(e,i+o-a*o,e+s-a*s,i,e+s,i),t.closePath())}return new Rt(e,i,e+A,i+n)}getMarkers(){return null}constructor(...t){var e,i,A;super(...t),A="rect",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}}function Xt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class qt extends jt{path(t){const{points:e}=this,[{x:i,y:A}]=e,n=new Rt(i,A);return t&&(t.beginPath(),t.moveTo(i,A)),e.forEach((e=>{let{x:i,y:A}=e;n.addPoint(i,A),t&&t.lineTo(i,A)})),n}getMarkers(){const{points:t}=this,e=t.length-1,i=[];return t.forEach(((A,n)=>{n!==e&&i.push([A,A.angleTo(t[n+1])])})),i.length>0&&i.push([t[t.length-1],i[i.length-1][1]]),i}constructor(t,e,i){super(t,e,i),Xt(this,"type","polyline"),Xt(this,"points",[]),this.points=rt.parsePath(this.getAttribute("points").getString())}}class Zt extends kt{getBoundingBox(t){const e=new Rt;return this.children.forEach((i=>{i instanceof jt&&e.addBoundingBox(i.getBoundingBox(t))})),e}constructor(...t){var e,i,A;super(...t),A="g",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}}function $t(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class _t extends vt{getGradientUnits(){return this.getAttribute("gradientUnits").getString("objectBoundingBox")}createGradient(t,e,i){let A=this;this.getHrefAttribute().hasValue()&&(A=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(A));const{stops:n}=A,a=this.getGradient(t,e);if(!a)return this.addParentOpacity(i,n[n.length-1].color);if(n.forEach((t=>{a.addColorStop(t.offset,this.addParentOpacity(i,t.color))})),this.getAttribute("gradientTransform").hasValue()){const{document:t}=this,{MAX_VIRTUAL_PIXELS:e}=ht,{viewPort:i}=t.screen,A=i.getRoot(),n=new Wt(t);n.attributes.x=new et(t,"x",-e/3),n.attributes.y=new et(t,"y",-e/3),n.attributes.width=new et(t,"width",e),n.attributes.height=new et(t,"height",e);const r=new Zt(t);r.attributes.transform=new et(t,"transform",this.getAttribute("gradientTransform").getValue()),r.children=[n];const s=new Kt(t);s.attributes.x=new et(t,"x",0),s.attributes.y=new et(t,"y",0),s.attributes.width=new et(t,"width",A.width),s.attributes.height=new et(t,"height",A.height),s.children=[r];const o=t.createCanvas(A.width,A.height),c=o.getContext("2d");return c.fillStyle=a,s.render(c),c.createPattern(o,"no-repeat")}return a}inheritStopContainer(t){this.attributesToInherit.forEach((e=>{!this.getAttribute(e).hasValue()&&t.getAttribute(e).hasValue()&&this.getAttribute(e,!0).setValue(t.getAttribute(e).getValue())}))}addParentOpacity(t,e){if(t.hasValue()){return new et(this.document,"color",e).addOpacity(t).getColor()}return e}constructor(t,e,i){super(t,e,i),$t(this,"attributesToInherit",["gradientUnits"]),$t(this,"stops",[]);const{stops:A,children:n}=this;n.forEach((t=>{"stop"===t.type&&A.push(t)}))}}function te(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ee(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ie extends vt{getProperty(){var t;const e=this.getAttribute("attributeType").getString(),i=this.getAttribute("attributeName").getString();var A;return"CSS"===e?null===(A=this.parent)||void 0===A?void 0:A.getStyle(i,!0):null===(t=this.parent)||void 0===t?void 0:t.getAttribute(i,!0)}calcValue(){const{initialUnits:t}=this,{progress:e,from:i,to:A}=this.getProgress();let n=i.getNumber()+(A.getNumber()-i.getNumber())*e;return"%"===t&&(n*=100),`${n}${t}`}update(t){const{parent:e}=this,i=this.getProperty();if(!i)return!1;if(this.initialValue||(this.initialValue=i.getString(),this.initialUnits=i.getUnits()),this.duration>this.maxDuration){const t=this.getAttribute("fill").getString("remove");if("indefinite"===this.getAttribute("repeatCount").getString()||"indefinite"===this.getAttribute("repeatDur").getString())this.duration=0;else if("freeze"!==t||this.frozen){if("remove"===t&&!this.removed)return this.removed=!0,e&&i&&i.setValue(e.animationFrozen?e.animationFrozenValue:this.initialValue),!0}else this.frozen=!0,e&&i&&(e.animationFrozen=!0,e.animationFrozenValue=i.getString());return!1}this.duration+=t;let A=!1;if(this.begin<this.duration){let t=this.calcValue();const e=this.getAttribute("type");if(e.hasValue()){t=`${e.getString()}(${t})`}i.setValue(t),A=!0}return A}getProgress(){const{document:t,values:e}=this;let i,A,n=(this.duration-this.begin)/(this.maxDuration-this.begin);if(e.hasValue()){const a=n*(e.getValue().length-1),r=Math.floor(a),s=Math.ceil(a);let o;o=e.getValue()[r],i=new et(t,"from",o?parseFloat(o):0),o=e.getValue()[s],A=new et(t,"to",o?parseFloat(o):0),n=(a-r)/(s-r)}else i=this.from,A=this.to;return{progress:n,from:i,to:A}}constructor(t,e,i){super(t,e,i),ee(this,"type","animate"),ee(this,"begin",void 0),ee(this,"maxDuration",void 0),ee(this,"from",void 0),ee(this,"to",void 0),ee(this,"values",void 0),ee(this,"duration",0),ee(this,"initialValue",void 0),ee(this,"initialUnits",""),ee(this,"removed",!1),ee(this,"frozen",!1),t.screen.animations.push(this),this.begin=this.getAttribute("begin").getMilliseconds(),this.maxDuration=this.begin+this.getAttribute("dur").getMilliseconds(),this.from=this.getAttribute("from"),this.to=this.getAttribute("to"),this.values=new et(t,"values",null);const A=this.getAttribute("values");A.hasValue()&&this.values.setValue(A.getString().split(";"))}}function Ae(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ne extends vt{constructor(t,e,i){super(t,e,i),Ae(this,"type","font-face"),Ae(this,"ascent",void 0),Ae(this,"descent",void 0),Ae(this,"unitsPerEm",void 0),this.ascent=this.getAttribute("ascent").getNumber(),this.descent=this.getAttribute("descent").getNumber(),this.unitsPerEm=this.getAttribute("units-per-em").getNumber()}}function ae(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class re extends jt{constructor(t,e,i){super(t,e,i),ae(this,"type","glyph"),ae(this,"horizAdvX",void 0),ae(this,"unicode",void 0),ae(this,"arabicForm",void 0),this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber(),this.unicode=this.getAttribute("unicode").getString(),this.arabicForm=this.getAttribute("arabic-form").getString()}}function se(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class oe extends re{constructor(...t){super(...t),se(this,"type","missing-glyph"),se(this,"horizAdvX",0)}}function ce(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function le(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ge(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function he(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const de=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*)$/i;function ue(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class we{async load(t,e){try{const{document:i}=this,A=(await i.pith.parser.load(e)).getElementsByTagName("font");Array.from(A).forEach((e=>{const A=i.createElement(e);i.definitions[t]=A}))}catch(t){console.error(`Error while loading font "${e}":`,t)}this.loaded=!0}constructor(t){ue(this,"document",void 0),ue(this,"loaded",void 0),this.document=t,this.loaded=!1,t.fonts.push(this)}}function Be(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class pe extends vt{constructor(t,e,i){super(t,e,i),Be(this,"type","style");b(Array.from(e.childNodes).map((t=>t.textContent)).join("").replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"").replace(/@import.*;/g,"")).split("}").forEach((e=>{const i=e.trim();if(!i)return;const A=i.split("{"),n=A[0].split(","),a=A[1].split(";");n.forEach((e=>{const i=e.trim();if(!i)return;const A=t.styles[i]||{};if(a.forEach((e=>{const i=e.indexOf(":"),n=e.substr(0,i).trim(),a=e.substr(i+1,e.length-i).trim();n&&a&&(A[n]=new et(t,n,a))})),t.styles[i]=A,t.stylesSpecificity[i]=function(t){const e=[0,0,0];let i=t.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),A=0;return[i,A]=J(i,R),e[1]+=A,[i,A]=J(i,k),e[0]+=A,[i,A]=J(i,H),e[1]+=A,[i,A]=J(i,U),e[2]+=A,[i,A]=J(i,G),e[1]+=A,[i,A]=J(i,T),e[1]+=A,i=i.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),[i,A]=J(i,O),e[2]+=A,e.join("")}(i),"@font-face"===i){const e=A["font-family"].getString().replace(/"|'/g,"");A.src.getString().split(",").forEach((i=>{if(i.indexOf('format("svg")')>0){const A=N(i);A&&new we(t).load(e,A)}}))}}))}))}}function Ee(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}Be(pe,"parseExternalUrl",N);function me(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function fe(t,e,i,A,n,a){return t[i*A*4+4*e+a]}function Ce(t,e,i,A,n,a,r){t[i*A*4+4*e+a]=r}function Qe(t,e,i){return t[e]*i}function ye(t,e,i,A){return e+Math.cos(t)*i+Math.sin(t)*A}class De extends vt{apply(t,e,i,A,n){const{includeOpacity:a,matrix:r}=this,s=t.getImageData(0,0,A,n);for(let t=0;t<n;t++)for(let e=0;e<A;e++){const i=fe(s.data,e,t,A,0,0),n=fe(s.data,e,t,A,0,1),o=fe(s.data,e,t,A,0,2),c=fe(s.data,e,t,A,0,3);let l=Qe(r,0,i)+Qe(r,1,n)+Qe(r,2,o)+Qe(r,3,c)+Qe(r,4,1),g=Qe(r,5,i)+Qe(r,6,n)+Qe(r,7,o)+Qe(r,8,c)+Qe(r,9,1),h=Qe(r,10,i)+Qe(r,11,n)+Qe(r,12,o)+Qe(r,13,c)+Qe(r,14,1),d=Qe(r,15,i)+Qe(r,16,n)+Qe(r,17,o)+Qe(r,18,c)+Qe(r,19,1);a&&(l=0,g=0,h=0,d*=c/255),Ce(s.data,e,t,A,0,0,l),Ce(s.data,e,t,A,0,1,g),Ce(s.data,e,t,A,0,2,h),Ce(s.data,e,t,A,0,3,d)}t.clearRect(0,0,A,n),t.putImageData(s,0,0)}constructor(t,e,i){super(t,e,i),me(this,"type","feColorMatrix"),me(this,"matrix",void 0),me(this,"includeOpacity",void 0);let A=Y(this.getAttribute("values").getString());switch(this.getAttribute("type").getString("matrix")){case"saturate":{const t=A[0];A=[.213+.787*t,.715-.715*t,.072-.072*t,0,0,.213-.213*t,.715+.285*t,.072-.072*t,0,0,.213-.213*t,.715-.715*t,.072+.928*t,0,0,0,0,0,1,0,0,0,0,0,1];break}case"hueRotate":{const t=A[0]*Math.PI/180;A=[ye(t,.213,.787,-.213),ye(t,.715,-.715,-.715),ye(t,.072,-.072,.928),0,0,ye(t,.213,-.213,.143),ye(t,.715,.285,.14),ye(t,.072,-.072,-.283),0,0,ye(t,.213,-.213,-.787),ye(t,.715,-.715,.715),ye(t,.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break}case"luminanceToAlpha":A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.2125,.7154,.0721,0,0,0,0,0,0,1]}this.matrix=A,this.includeOpacity=this.getAttribute("includeOpacity").hasValue()}}function Ie(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class xe extends vt{apply(t,e){const{document:i}=this;let A=this.getAttribute("x").getPixels("x"),n=this.getAttribute("y").getPixels("y"),a=this.getStyle("width").getPixels("x"),r=this.getStyle("height").getPixels("y");if(!a&&!r){const e=new Rt;this.children.forEach((i=>{i instanceof jt&&e.addBoundingBox(i.getBoundingBox(t))})),A=Math.floor(e.x1),n=Math.floor(e.y1),a=Math.floor(e.width),r=Math.floor(e.height)}const s=this.removeStyles(e,xe.ignoreStyles),o=i.createCanvas(A+a,n+r),c=o.getContext("2d");i.screen.setDefaults(c),this.renderChildren(c),new De(i,{nodeType:1,childNodes:[],attributes:[{nodeName:"type",value:"luminanceToAlpha"},{nodeName:"includeOpacity",value:"true"}]}).apply(c,0,0,A+a,n+r);const l=i.createCanvas(A+a,n+r),g=l.getContext("2d");i.screen.setDefaults(g),e.render(g),g.globalCompositeOperation="destination-in",g.fillStyle=c.createPattern(o,"no-repeat"),g.fillRect(0,0,A+a,n+r),t.fillStyle=g.createPattern(l,"no-repeat"),t.fillRect(0,0,A+a,n+r),this.restoreStyles(e,s)}render(t){}constructor(...t){super(...t),Ie(this,"type","mask")}}Ie(xe,"ignoreStyles",["mask","transform","clip-path"]);const ve=()=>{};function Me(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Se extends vt{apply(t,e,i,A,n){const{document:a,blurRadius:r}=this,s=a.window?a.window.document.body:null,o=t.canvas;o.id=a.getUniqueId(),s&&(o.style.display="none",s.appendChild(o)),(0,p.canvasRGBA)(o,e,i,A,n,r),s&&s.removeChild(o)}constructor(t,e,i){super(t,e,i),Me(this,"type","feGaussianBlur"),Me(this,"extraFilterDistance",void 0),Me(this,"blurRadius",void 0),this.blurRadius=Math.floor(this.getAttribute("stdDeviation").getNumber()),this.extraFilterDistance=this.blurRadius}}function Fe(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class be extends vt{apply(t,e){const{document:i,children:A}=this,n="getBoundingBox"in e?e.getBoundingBox(t):null;if(!n)return;let a=0,r=0;A.forEach((t=>{if(!(t instanceof Se))return;const e=t.extraFilterDistance||0;a=Math.max(a,e),r=Math.max(r,e)}));const s=Math.floor(n.width),o=Math.floor(n.height),c=s+2*a,l=o+2*r;if(Number.isNaN(c)||Number.isNaN(l)||c<1||l<1)return;const g=Math.floor(n.x),h=Math.floor(n.y),d=this.removeStyles(e,be.ignoreStyles),u=i.createCanvas(c,l),w=u.getContext("2d");i.screen.setDefaults(w),w.translate(-g+a,-h+r),e.render(w),A.forEach((t=>{t instanceof Se&&"function"==typeof t.apply&&t.apply(w,0,0,c,l)})),t.drawImage(u,0,0,c,l,g-a,h-r,c,l),this.restoreStyles(e,d)}render(t){}constructor(...t){super(...t),Fe(this,"type","filter")}}Fe(be,"ignoreStyles",["filter","transform","clip-path"]);const Ye={svg:Kt,rect:Wt,circle:class extends jt{path(t){const e=this.getAttribute("cx").getPixels("x"),i=this.getAttribute("cy").getPixels("y"),A=this.getAttribute("r").getPixels();return t&&A>0&&(t.beginPath(),t.arc(e,i,A,0,2*Math.PI,!1),t.closePath()),new Rt(e-A,i-A,e+A,i+A)}getMarkers(){return null}constructor(...t){var e,i,A;super(...t),A="circle",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},ellipse:class extends jt{path(t){const e=(Math.sqrt(2)-1)/3*4,i=this.getAttribute("rx").getPixels("x"),A=this.getAttribute("ry").getPixels("y"),n=this.getAttribute("cx").getPixels("x"),a=this.getAttribute("cy").getPixels("y");return t&&i>0&&A>0&&(t.beginPath(),t.moveTo(n+i,a),t.bezierCurveTo(n+i,a+e*A,n+e*i,a+A,n,a+A),t.bezierCurveTo(n-e*i,a+A,n-i,a+e*A,n-i,a),t.bezierCurveTo(n-i,a-e*A,n-e*i,a-A,n,a-A),t.bezierCurveTo(n+e*i,a-A,n+i,a-e*A,n+i,a),t.closePath()),new Rt(n-i,a-A,n+i,a+A)}getMarkers(){return null}constructor(...t){var e,i,A;super(...t),A="ellipse",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},line:class extends jt{getPoints(){return[new rt(this.getAttribute("x1").getPixels("x"),this.getAttribute("y1").getPixels("y")),new rt(this.getAttribute("x2").getPixels("x"),this.getAttribute("y2").getPixels("y"))]}path(t){const[{x:e,y:i},{x:A,y:n}]=this.getPoints();return t&&(t.beginPath(),t.moveTo(e,i),t.lineTo(A,n)),new Rt(e,i,A,n)}getMarkers(){const[t,e]=this.getPoints(),i=t.angleTo(e);return[[t,i],[e,i]]}constructor(...t){var e,i,A;super(...t),A="line",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},polyline:qt,polygon:class extends qt{path(t){const e=super.path(t),[{x:i,y:A}]=this.points;return t&&(t.lineTo(i,A),t.closePath()),e}constructor(...t){var e,i,A;super(...t),A="polygon",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},path:jt,pattern:class extends vt{createPattern(t,e,i){const A=this.getStyle("width").getPixels("x",!0),n=this.getStyle("height").getPixels("y",!0),a=this.getAttribute("data-frame-width"),r=this.getAttribute("data-frame-height"),s=a.hasValue()?a.getPixels("x",!0):A,o=r.hasValue()?r.getPixels("y",!0):n,c=a.hasValue()&&r.hasValue(),l=new Kt(this.document,void 0);l.attributes.viewBox=new et(this.document,"viewBox",this.getAttribute("viewBox").getValue()),l.attributes.width=new et(this.document,"width",`${s}px`),l.attributes.height=new et(this.document,"height",`${o}px`),l.attributes.transform=new et(this.document,"transform",this.getAttribute("patternTransform").getValue()),l.children=this.children;const g=this.document.createCanvas(s,o),h=g.getContext("2d");h.imageSmoothingEnabled=!0,h.imageSmoothingQuality="high";const d=this.getAttribute("x"),u=this.getAttribute("y");d.hasValue()&&u.hasValue()&&h.translate(d.getPixels("x",!0),u.getPixels("y",!0)),i.hasValue()?this.styles["fill-opacity"]=i:Reflect.deleteProperty(this.styles,"fill-opacity");for(let t=-1;t<=1;t++)for(let e=-1;e<=1;e++)h.save(),l.attributes.x=new et(this.document,"x",t*g.width),l.attributes.y=new et(this.document,"y",e*g.height),l.render(h),h.restore();return t.createPattern(g,c?"no-repeat":"repeat")}constructor(...t){var e,i,A;super(...t),A="pattern",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},marker:class extends vt{render(t,e,i){if(!e)return;const{x:A,y:n}=e,a=this.getAttribute("orient").getString("auto"),r=this.getAttribute("markerUnits").getString("strokeWidth");t.translate(A,n),"auto"===a&&i&&t.rotate(i),"strokeWidth"===r&&t.scale(t.lineWidth,t.lineWidth),t.save();const s=new Kt(this.document);s.type=this.type,s.attributes.viewBox=new et(this.document,"viewBox",this.getAttribute("viewBox").getValue()),s.attributes.refX=new et(this.document,"refX",this.getAttribute("refX").getValue()),s.attributes.refY=new et(this.document,"refY",this.getAttribute("refY").getValue()),s.attributes.width=new et(this.document,"width",this.getAttribute("markerWidth").getValue()),s.attributes.height=new et(this.document,"height",this.getAttribute("markerHeight").getValue()),s.attributes.overflow=new et(this.document,"overflow",this.getAttribute("overflow").getValue()),s.attributes.fill=new et(this.document,"fill",this.getAttribute("fill").getColor("black")),s.attributes.stroke=new et(this.document,"stroke",this.getAttribute("stroke").getValue("none")),s.children=this.children,s.render(t),t.restore(),"strokeWidth"===r&&t.scale(1/t.lineWidth,1/t.lineWidth),"auto"===a&&i&&t.rotate(-i),t.translate(-A,-n)}constructor(...t){var e,i,A;super(...t),A="marker",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},defs:class extends vt{render(){}constructor(...t){var e,i,A;super(...t),A="defs",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},linearGradient:class extends _t{getGradient(t,e){const i="objectBoundingBox"===this.getGradientUnits(),A=i?e.getBoundingBox(t):null;if(i||!A)return null;this.getAttribute("x1").hasValue()||this.getAttribute("y1").hasValue()||this.getAttribute("x2").hasValue()||this.getAttribute("y2").hasValue()||(this.getAttribute("x1",!0).setValue(0),this.getAttribute("y1",!0).setValue(0),this.getAttribute("x2",!0).setValue(1),this.getAttribute("y2",!0).setValue(0));const n=i?A.x+A.width*this.getAttribute("x1").getNumber():this.getAttribute("x1").getPixels("x"),a=i?A.y+A.height*this.getAttribute("y1").getNumber():this.getAttribute("y1").getPixels("y"),r=i?A.x+A.width*this.getAttribute("x2").getNumber():this.getAttribute("x2").getPixels("x"),s=i?A.y+A.height*this.getAttribute("y2").getNumber():this.getAttribute("y2").getPixels("y");return n===r&&a===s?null:t.createLinearGradient(n,a,r,s)}constructor(t,e,i){var A,n,a;super(t,e,i),a="linearGradient",(n="type")in(A=this)?Object.defineProperty(A,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):A[n]=a,this.attributesToInherit.push("x1","y1","x2","y2")}},radialGradient:class extends _t{getGradient(t,e){const i="objectBoundingBox"===this.getGradientUnits(),A=e.getBoundingBox(t);if(i&&!A)return null;this.getAttribute("cx").hasValue()||this.getAttribute("cx",!0).setValue("50%"),this.getAttribute("cy").hasValue()||this.getAttribute("cy",!0).setValue("50%"),this.getAttribute("r").hasValue()||this.getAttribute("r",!0).setValue("50%");const n=i?A.x+A.width*this.getAttribute("cx").getNumber():this.getAttribute("cx").getPixels("x"),a=i?A.y+A.height*this.getAttribute("cy").getNumber():this.getAttribute("cy").getPixels("y");let r=n,s=a;this.getAttribute("fx").hasValue()&&(r=i?A.x+A.width*this.getAttribute("fx").getNumber():this.getAttribute("fx").getPixels("x")),this.getAttribute("fy").hasValue()&&(s=i?A.y+A.height*this.getAttribute("fy").getNumber():this.getAttribute("fy").getPixels("y"));const o=i?(A.width+A.height)/2*this.getAttribute("r").getNumber():this.getAttribute("r").getPixels(),c=this.getAttribute("fr").getPixels();return t.createRadialGradient(r,s,c,n,a,o)}constructor(t,e,i){var A,n,a;super(t,e,i),a="radialGradient",(n="type")in(A=this)?Object.defineProperty(A,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):A[n]=a,this.attributesToInherit.push("cx","cy","r","fx","fy","fr")}},stop:class extends vt{constructor(t,e,i){super(t,e,i),te(this,"type","stop"),te(this,"offset",void 0),te(this,"color",void 0);const A=Math.max(0,Math.min(1,this.getAttribute("offset").getNumber())),n=this.getStyle("stop-opacity");let a=this.getStyle("stop-color",!0);""===a.getString()&&a.setValue("#000"),n.hasValue()&&(a=a.addOpacity(n)),this.offset=A,this.color=a.getColor()}},animate:ie,animateColor:class extends ie{calcValue(){const{progress:t,from:e,to:i}=this.getProgress(),A=new(F(w))(e.getColor()),n=new(F(w))(i.getColor());if(A.ok&&n.ok){const e=A.r+(n.r-A.r)*t,i=A.g+(n.g-A.g)*t,a=A.b+(n.b-A.b)*t;return`rgb(${Math.floor(e)}, ${Math.floor(i)}, ${Math.floor(a)})`}return this.getAttribute("from").getColor()}constructor(...t){var e,i,A;super(...t),A="animateColor",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},animateTransform:class extends ie{calcValue(){const{progress:t,from:e,to:i}=this.getProgress(),A=Y(e.getString()),n=Y(i.getString()),a=A.map(((e,i)=>e+(n[i]-e)*t)).join(" ");return a}constructor(...t){var e,i,A;super(...t),A="animateTransform",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},font:class extends vt{render(){}constructor(t,e,i){super(t,e,i),ce(this,"type","font"),ce(this,"isArabic",!1),ce(this,"missingGlyph",void 0),ce(this,"glyphs",{}),ce(this,"arabicGlyphs",{}),ce(this,"horizAdvX",void 0),ce(this,"isRTL",!1),ce(this,"fontFace",void 0),this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber();const{definitions:A}=t,{children:n}=this;for(const t of n)if(t instanceof ne){this.fontFace=t;const e=t.getStyle("font-family");e.hasValue()&&(A[e.getString()]=this)}else if(t instanceof oe)this.missingGlyph=t;else if(t instanceof re)if(t.arabicForm){this.isRTL=!0,this.isArabic=!0;const e=this.arabicGlyphs[t.unicode];void 0===e?this.arabicGlyphs[t.unicode]={[t.arabicForm]:t}:e[t.arabicForm]=t}else this.glyphs[t.unicode]=t}},"font-face":ne,"missing-glyph":oe,glyph:re,text:Ut,tspan:Tt,tref:class extends Ut{getText(){const t=this.getHrefAttribute().getDefinition();if(t){const e=t.children[0];if(e)return e.getText()}return""}constructor(...t){var e,i,A;super(...t),A="tref",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},a:class extends Ut{getText(){return this.text}renderChildren(t){if(this.hasText){super.renderChildren(t);const{document:e,x:i,y:A}=this,{mouse:n}=e.screen,a=new et(e,"fontSize",Pt.parse(e.ctx.font).fontSize);n.isWorking()&&n.checkBoundingBox(this,new Rt(i,A-a.getPixels("y"),i+this.measureText(t),A))}else if(this.children.length>0){const e=new Zt(this.document);e.children=this.children,e.parent=this,e.render(t)}}onClick(){const{window:t}=this.document;t&&t.open(this.getHrefAttribute().getString())}onMouseMove(){this.document.ctx.canvas.style.cursor="pointer"}constructor(t,e,i){super(t,e,i),le(this,"type","a"),le(this,"hasText",void 0),le(this,"text",void 0);const{childNodes:A}=e,n=A[0],a=A.length>0&&Array.from(A).every((t=>3===t.nodeType));this.hasText=a,this.text=a?this.getTextFromNode(n):""}},textPath:class extends Ut{getText(){return this.text}path(t){const{dataArray:e}=this;t&&t.beginPath(),e.forEach((e=>{let{type:i,points:A}=e;switch(i){case Lt.LINE_TO:t&&t.lineTo(A[0],A[1]);break;case Lt.MOVE_TO:t&&t.moveTo(A[0],A[1]);break;case Lt.CURVE_TO:t&&t.bezierCurveTo(A[0],A[1],A[2],A[3],A[4],A[5]);break;case Lt.QUAD_TO:t&&t.quadraticCurveTo(A[0],A[1],A[2],A[3]);break;case Lt.ARC:{const[e,i,n,a,r,s,o,c]=A,l=n>a?n:a,g=n>a?1:n/a,h=n>a?a/n:1;t&&(t.translate(e,i),t.rotate(o),t.scale(g,h),t.arc(0,0,l,r,r+s,Boolean(1-c)),t.scale(1/g,1/h),t.rotate(-o),t.translate(-e,-i));break}case Lt.CLOSE_PATH:t&&t.closePath()}}))}renderChildren(t){var e;this.setTextData(t),t.save();const i=null===(e=this.parent)||void 0===e?void 0:e.getStyle("text-decoration").getString(),A=this.getFontSize(),{glyphInfo:n}=this,a=t.fillStyle;"underline"===i&&t.beginPath(),n.forEach(((e,n)=>{const{p0:a,p1:r,rotation:s,text:o}=e;t.save(),t.translate(a.x,a.y),t.rotate(s),t.fillStyle&&t.fillText(o,0,0),t.strokeStyle&&t.strokeText(o,0,0),t.restore(),"underline"===i&&(0===n&&t.moveTo(a.x,a.y+A/8),t.lineTo(r.x,r.y+A/5))})),"underline"===i&&(t.lineWidth=A/20,t.strokeStyle=a,t.stroke(),t.closePath()),t.restore()}getLetterSpacingAt(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.letterSpacingCache[t]||0}findSegmentToFitChar(t,e,i,A,n,a,r,s,o){let c=a,l=this.measureText(t,s);" "===s&&"justify"===e&&i<A&&(l+=(A-i)/n),o>-1&&(c+=this.getLetterSpacingAt(o));const g=this.textHeight/20,h=this.getEquidistantPointOnPath(c,g,0),d=this.getEquidistantPointOnPath(c+l,g,0),u={p0:h,p1:d},w=h&&d?Math.atan2(d.y-h.y,d.x-h.x):0;if(r){const t=Math.cos(Math.PI/2+w)*r,e=Math.cos(-w)*r;u.p0={...h,distance:h.distance||0,x:h.x+t,y:h.y+e},u.p1={...d,distance:d.distance||0,x:d.x+t,y:d.y+e}}return c+=l,{offset:c,segment:u,rotation:w}}measureText(t,e){const{measuresCache:i}=this,A=e||this.getText();if(i.has(A))return i.get(A);const n=this.measureTargetText(t,A);return i.set(A,n),n}setTextData(t){var e,i,A;if(this.glyphInfo)return;const n=this.getText(),a=n.split(""),r=n.split(" ").length-1,s=null===(e=this.parent)||void 0===e?void 0:e.getAttribute("dx").split().map((t=>t.getPixels("x"))),o=null===(i=this.parent)||void 0===i?void 0:i.getAttribute("dy").getPixels("y"),c=this.getAttribute("text-anchor").getString("start"),l=this.getStyle("letter-spacing"),g=null===(A=this.parent)||void 0===A?void 0:A.getStyle("letter-spacing");let h=0;l.hasValue()&&"inherit"!==l.getValue()?l.hasValue()&&"initial"!==l.getValue()&&"unset"!==l.getValue()&&(h=l.getPixels()):h=g.getPixels();const d=[],u=n.length;this.letterSpacingCache=d;for(let t=0;t<u;t++)d.push(void 0!==s[t]?s[t]:h);const w=d.reduce(((t,e,i)=>0===i?0:t+e||0),0),B=this.measureText(t),p=Math.max(B+w,0);this.textWidth=B,this.textHeight=this.getFontSize(),this.glyphInfo=[];const E=this.getPathLength(),m=this.getAttribute("startOffset").getNumber(0)*E;let f=0;"middle"!==c&&"center"!==c||(f=-p/2),"end"!==c&&"right"!==c||(f=-p),f+=m,a.forEach(((e,i)=>{const{offset:A,segment:n,rotation:s}=this.findSegmentToFitChar(t,c,p,E,r,f,o,e,i);f=A,n.p0&&n.p1&&this.glyphInfo.push({text:a[i],p0:n.p0,p1:n.p1,rotation:s})}))}parsePathData(t){if(this.pathLength=-1,!t)return[];const e=[],{pathParser:i}=t;for(i.reset();!i.isEnd();){const{current:t}=i,A=t?t.x:0,n=t?t.y:0,a=i.next();let r=a.type,s=[];switch(a.type){case Lt.MOVE_TO:this.pathM(i,s);break;case Lt.LINE_TO:r=this.pathL(i,s);break;case Lt.HORIZ_LINE_TO:r=this.pathH(i,s);break;case Lt.VERT_LINE_TO:r=this.pathV(i,s);break;case Lt.CURVE_TO:this.pathC(i,s);break;case Lt.SMOOTH_CURVE_TO:r=this.pathS(i,s);break;case Lt.QUAD_TO:this.pathQ(i,s);break;case Lt.SMOOTH_QUAD_TO:r=this.pathT(i,s);break;case Lt.ARC:s=this.pathA(i);break;case Lt.CLOSE_PATH:jt.pathZ(i)}a.type!==Lt.CLOSE_PATH?e.push({type:r,points:s,start:{x:A,y:n},pathLength:this.calcLength(A,n,r,s)}):e.push({type:Lt.CLOSE_PATH,points:[],pathLength:0})}return e}pathM(t,e){const{x:i,y:A}=jt.pathM(t).point;e.push(i,A)}pathL(t,e){const{x:i,y:A}=jt.pathL(t).point;return e.push(i,A),Lt.LINE_TO}pathH(t,e){const{x:i,y:A}=jt.pathH(t).point;return e.push(i,A),Lt.LINE_TO}pathV(t,e){const{x:i,y:A}=jt.pathV(t).point;return e.push(i,A),Lt.LINE_TO}pathC(t,e){const{point:i,controlPoint:A,currentPoint:n}=jt.pathC(t);e.push(i.x,i.y,A.x,A.y,n.x,n.y)}pathS(t,e){const{point:i,controlPoint:A,currentPoint:n}=jt.pathS(t);return e.push(i.x,i.y,A.x,A.y,n.x,n.y),Lt.CURVE_TO}pathQ(t,e){const{controlPoint:i,currentPoint:A}=jt.pathQ(t);e.push(i.x,i.y,A.x,A.y)}pathT(t,e){const{controlPoint:i,currentPoint:A}=jt.pathT(t);return e.push(i.x,i.y,A.x,A.y),Lt.QUAD_TO}pathA(t){let{rX:e,rY:i,sweepFlag:A,xAxisRotation:n,centp:a,a1:r,ad:s}=jt.pathA(t);return 0===A&&s>0&&(s-=2*Math.PI),1===A&&s<0&&(s+=2*Math.PI),[a.x,a.y,e,i,r,s,n,A]}calcLength(t,e,i,A){let n=0,a=null,r=null,s=0;switch(i){case Lt.LINE_TO:return this.getLineLength(t,e,A[0],A[1]);case Lt.CURVE_TO:for(n=0,a=this.getPointOnCubicBezier(0,t,e,A[0],A[1],A[2],A[3],A[4],A[5]),s=.01;s<=1;s+=.01)r=this.getPointOnCubicBezier(s,t,e,A[0],A[1],A[2],A[3],A[4],A[5]),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return n;case Lt.QUAD_TO:for(n=0,a=this.getPointOnQuadraticBezier(0,t,e,A[0],A[1],A[2],A[3]),s=.01;s<=1;s+=.01)r=this.getPointOnQuadraticBezier(s,t,e,A[0],A[1],A[2],A[3]),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return n;case Lt.ARC:{n=0;const t=A[4],e=A[5],i=A[4]+e;let o=Math.PI/180;if(Math.abs(t-i)<o&&(o=Math.abs(t-i)),a=this.getPointOnEllipticalArc(A[0],A[1],A[2],A[3],t,0),e<0)for(s=t-o;s>i;s-=o)r=this.getPointOnEllipticalArc(A[0],A[1],A[2],A[3],s,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;else for(s=t+o;s<i;s+=o)r=this.getPointOnEllipticalArc(A[0],A[1],A[2],A[3],s,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return r=this.getPointOnEllipticalArc(A[0],A[1],A[2],A[3],i,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),n}}return 0}getPointOnLine(t,e,i,A,n){let a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:i;const s=(n-i)/(A-e+L);let o=Math.sqrt(t*t/(1+s*s));A<e&&(o*=-1);let c=s*o,l=null;if(A===e)l={x:a,y:r+c};else if((r-i)/(a-e+L)===s)l={x:a+o,y:r+c};else{let g=0,h=0;const d=this.getLineLength(e,i,A,n);if(d<L)return null;let u=(a-e)*(A-e)+(r-i)*(n-i);u/=d*d,g=e+u*(A-e),h=i+u*(n-i);const w=this.getLineLength(a,r,g,h),B=Math.sqrt(t*t-w*w);o=Math.sqrt(B*B/(1+s*s)),A<e&&(o*=-1),c=s*o,l={x:g+o,y:h+c}}return l}getPointOnPath(t){const e=this.getPathLength();let i=0,A=null;if(t<-5e-5||t-5e-5>e)return null;const{dataArray:n}=this;for(const e of n){if(e&&(e.pathLength<5e-5||i+e.pathLength+5e-5<t)){i+=e.pathLength;continue}const n=t-i;let a=0;switch(e.type){case Lt.LINE_TO:A=this.getPointOnLine(n,e.start.x,e.start.y,e.points[0],e.points[1],e.start.x,e.start.y);break;case Lt.ARC:{const t=e.points[4],i=e.points[5],r=e.points[4]+i;if(a=t+n/e.pathLength*i,i<0&&a<r||i>=0&&a>r)break;A=this.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],a,e.points[6]);break}case Lt.CURVE_TO:a=n/e.pathLength,a>1&&(a=1),A=this.getPointOnCubicBezier(a,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);break;case Lt.QUAD_TO:a=n/e.pathLength,a>1&&(a=1),A=this.getPointOnQuadraticBezier(a,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3])}if(A)return A;break}return null}getLineLength(t,e,i,A){return Math.sqrt((i-t)*(i-t)+(A-e)*(A-e))}getPathLength(){return-1===this.pathLength&&(this.pathLength=this.dataArray.reduce(((t,e)=>e.pathLength>0?t+e.pathLength:t),0)),this.pathLength}getPointOnCubicBezier(t,e,i,A,n,a,r,s,o){return{x:s*K(t)+a*W(t)+A*X(t)+e*q(t),y:o*K(t)+r*W(t)+n*X(t)+i*q(t)}}getPointOnQuadraticBezier(t,e,i,A,n,a,r){return{x:a*Z(t)+A*$(t)+e*_(t),y:r*Z(t)+n*$(t)+i*_(t)}}getPointOnEllipticalArc(t,e,i,A,n,a){const r=Math.cos(a),s=Math.sin(a),o=i*Math.cos(n),c=A*Math.sin(n);return{x:t+(o*r-c*s),y:e+(o*s+c*r)}}buildEquidistantCache(t,e){const i=this.getPathLength(),A=e||.25,n=t||i/100;if(!this.equidistantCache||this.equidistantCache.step!==n||this.equidistantCache.precision!==A){this.equidistantCache={step:n,precision:A,points:[]};let t=0;for(let e=0;e<=i;e+=A){const i=this.getPointOnPath(e),a=this.getPointOnPath(e+A);i&&a&&(t+=this.getLineLength(i.x,i.y,a.x,a.y),t>=n&&(this.equidistantCache.points.push({x:i.x,y:i.y,distance:e}),t-=n))}}}getEquidistantPointOnPath(t,e,i){if(this.buildEquidistantCache(e,i),t<0||t-this.getPathLength()>5e-5)return null;const A=Math.round(t/this.getPathLength()*(this.equidistantCache.points.length-1));return this.equidistantCache.points[A]||null}constructor(t,e,i){super(t,e,i),ge(this,"type","textPath"),ge(this,"textWidth",0),ge(this,"textHeight",0),ge(this,"pathLength",-1),ge(this,"glyphInfo",null),ge(this,"text",void 0),ge(this,"dataArray",void 0),ge(this,"letterSpacingCache",[]),ge(this,"equidistantCache",null),ge(this,"measuresCache",new Map([["",0]]));const A=this.getHrefAttribute().getDefinition();this.text=this.getTextFromNode(),this.dataArray=this.parsePathData(A)}},image:class extends kt{async loadImage(t){try{const e=await this.document.createImage(t);this.image=e}catch(e){console.error(`Error while loading image "${t}":`,e)}this.loaded=!0}async loadSvg(t){const e=de.exec(t);if(e){const t=e[5];t&&("base64"===e[4]?this.image=atob(t):this.image=decodeURIComponent(t))}else try{const e=await this.document.fetch(t),i=await e.text();this.image=i}catch(e){console.error(`Error while loading image "${t}":`,e)}this.loaded=!0}renderChildren(t){const{document:e,image:i,loaded:A}=this,n=this.getAttribute("x").getPixels("x"),a=this.getAttribute("y").getPixels("y"),r=this.getStyle("width").getPixels("x"),s=this.getStyle("height").getPixels("y");if(A&&i&&r&&s){if(t.save(),t.translate(n,a),"string"==typeof i){const A=e.pith.forkString(t,i,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:0,offsetY:0,scaleWidth:r,scaleHeight:s}),{documentElement:n}=A.document;n&&(n.parent=this),A.resize(r,s,this.getAttribute("preserveAspectRatio").getString()),A.render()}else e.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:r,desiredWidth:i.width,height:s,desiredHeight:i.height}),this.loaded&&("complete"in i&&!i.complete||t.drawImage(i,0,0));t.restore()}}getBoundingBox(){const t=this.getAttribute("x").getPixels("x"),e=this.getAttribute("y").getPixels("y"),i=this.getStyle("width").getPixels("x"),A=this.getStyle("height").getPixels("y");return new Rt(t,e,t+i,e+A)}constructor(t,e,i){super(t,e,i),he(this,"type","image"),he(this,"loaded",!1),he(this,"image",void 0);const A=this.getHrefAttribute().getString();if(!A)return;const n=A.endsWith(".svg")||/^\s*data:image\/svg\+xml/i.test(A);t.images.push(this),n?this.loadSvg(A):this.loadImage(A)}},g:Zt,symbol:class extends kt{render(t){}constructor(...t){var e,i,A;super(...t),A="symbol",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},style:pe,use:class extends kt{setContext(t){super.setContext(t);const e=this.getAttribute("x"),i=this.getAttribute("y");e.hasValue()&&t.translate(e.getPixels("x"),0),i.hasValue()&&t.translate(0,i.getPixels("y"))}path(t){const{element:e}=this;e&&e.path(t)}renderChildren(t){const{document:e,element:i}=this;if(i){let A=i;if("symbol"===i.type&&(A=new Kt(e),A.attributes.viewBox=new et(e,"viewBox",i.getAttribute("viewBox").getString()),A.attributes.preserveAspectRatio=new et(e,"preserveAspectRatio",i.getAttribute("preserveAspectRatio").getString()),A.attributes.overflow=new et(e,"overflow",i.getAttribute("overflow").getString()),A.children=i.children,i.styles.opacity=new et(e,"opacity",this.calculateOpacity())),"svg"===A.type){const t=this.getStyle("width",!1,!0),i=this.getStyle("height",!1,!0);t.hasValue()&&(A.attributes.width=new et(e,"width",t.getString())),i.hasValue()&&(A.attributes.height=new et(e,"height",i.getString()))}const n=A.parent;A.parent=this,A.render(t),A.parent=n}}getBoundingBox(t){const{element:e}=this;return e?e.getBoundingBox(t):null}elementTransform(){const{document:t,element:e}=this;return e?It.fromElement(t,e):null}get element(){return this.cachedElement||(this.cachedElement=this.getHrefAttribute().getDefinition()),this.cachedElement}constructor(...t){super(...t),Ee(this,"type","use"),Ee(this,"cachedElement",void 0)}},mask:xe,clipPath:class extends vt{apply(t){const{document:e}=this,i=Reflect.getPrototypeOf(t),{beginPath:A,closePath:n}=t;i&&(i.beginPath=ve,i.closePath=ve),Reflect.apply(A,t,[]),this.children.forEach((A=>{if(!("path"in A))return;let a="elementTransform"in A?A.elementTransform():null;a||(a=It.fromElement(e,A)),a&&a.apply(t),A.path(t),i&&(i.closePath=n),a&&a.unapply(t)})),Reflect.apply(n,t,[]),t.clip(),i&&(i.beginPath=A,i.closePath=n)}render(t){}constructor(...t){var e,i,A;super(...t),A="clipPath",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},filter:be,feDropShadow:class extends vt{apply(t,e,i,A,n){}constructor(t,e,i){var A,n,a;super(t,e,i),a="feDropShadow",(n="type")in(A=this)?Object.defineProperty(A,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):A[n]=a,this.addStylesFromStyleDefinition()}},feMorphology:class extends vt{apply(t,e,i,A,n){}constructor(...t){var e,i,A;super(...t),A="feMorphology",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},feComposite:class extends vt{apply(t,e,i,A,n){}constructor(...t){var e,i,A;super(...t),A="feComposite",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},feColorMatrix:De,feGaussianBlur:Se,title:class extends vt{constructor(...t){var e,i,A;super(...t),A="title",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},desc:class extends vt{constructor(...t){var e,i,A;super(...t),A="desc",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}}};function Pe(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Ne{bindCreateImage(t,e){return"boolean"==typeof e?(i,A)=>t(i,"boolean"==typeof A?A:e):t}get window(){return this.screen.window}get fetch(){return this.screen.fetch}get ctx(){return this.screen.ctx}get emSize(){const{emSizeStack:t}=this;return t[t.length-1]||12}set emSize(t){const{emSizeStack:e}=this;e.push(t)}popEmSize(){const{emSizeStack:t}=this;t.pop()}getUniqueId(){return"pith"+ ++this.uniqueId}isImagesLoaded(){return this.images.every((t=>t.loaded))}isFontsLoaded(){return this.fonts.every((t=>t.loaded))}createDocumentElement(t){const e=this.createElement(t.documentElement);return e.root=!0,e.addStylesFromStyleDefinition(),this.documentElement=e,e}createElement(t){const e=t.nodeName.replace(/^[^:]+:/,""),i=Ne.elementTypes[e];return i?new i(this,t):new Mt(this,t)}createTextNode(t){return new Ot(this,t)}setViewBox(t){this.screen.setViewBox({document:this,...t})}constructor(t,{rootEmSize:e=12,emSize:i=12,createCanvas:A=Ne.createCanvas,createImage:n=Ne.createImage,anonymousCrossOrigin:a}={}){Pe(this,"pith",void 0),Pe(this,"rootEmSize",void 0),Pe(this,"documentElement",void 0),Pe(this,"screen",void 0),Pe(this,"createCanvas",void 0),Pe(this,"createImage",void 0),Pe(this,"definitions",void 0),Pe(this,"styles",void 0),Pe(this,"stylesSpecificity",void 0),Pe(this,"images",void 0),Pe(this,"fonts",void 0),Pe(this,"emSizeStack",void 0),Pe(this,"uniqueId",void 0),this.pith=t,this.definitions={},this.styles={},this.stylesSpecificity={},this.images=[],this.fonts=[],this.emSizeStack=[],this.uniqueId=0,this.screen=t.screen,this.rootEmSize=e,this.emSize=i,this.createCanvas=A,this.createImage=this.bindCreateImage(n,a),this.screen.wait((()=>this.isImagesLoaded())),this.screen.wait((()=>this.isFontsLoaded()))}}function Re(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}Pe(Ne,"createCanvas",(function(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i})),Pe(Ne,"createImage",(async function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=document.createElement("img");return e&&(i.crossOrigin="Anonymous"),new Promise(((e,A)=>{i.onload=()=>{e(i)},i.onerror=(t,e,i,n,a)=>{A(a)},i.src=t}))})),Pe(Ne,"elementTypes",Ye);class ke{static async from(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const A=new Bt(i),n=await A.parse(e);return new ke(t,n,i)}static fromString(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const A=new Bt(i).parseFromString(e);return new ke(t,A,i)}fork(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return ke.from(t,e,{...this.options,...i})}forkString(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return ke.fromString(t,e,{...this.options,...i})}ready(){return this.screen.ready()}isReady(){return this.screen.isReady()}async render(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.start({enableRedraw:!0,ignoreAnimation:!0,ignoreMouse:!0,...t}),await this.ready(),this.stop()}start(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{documentElement:e,screen:i,options:A}=this;i.start(e,{enableRedraw:!0,...A,...t})}stop(){this.screen.stop()}resize(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.documentElement.resize(t,e,i)}constructor(t,e,i={}){Re(this,"parser",void 0),Re(this,"screen",void 0),Re(this,"document",void 0),Re(this,"documentElement",void 0),Re(this,"options",void 0),this.parser=new Bt(i),this.screen=new ht(t,i),this.options=i;const A=new Ne(this,i),n=A.createDocumentElement(e);this.document=A,this.documentElement=n}}function He(t,e,i,A){Object.defineProperty(t,e,{get:i,set:A,enumerable:!0,configurable:!0})}var Ue="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==S?S:{},Ge={};He(Ge,"CanvasCommand",(()=>ZA)),He(Ge,"UpdateWorkflowStateCommand",(()=>$A)),He(Ge,"MoveCommand",(()=>_A)),He(Ge,"RotateCommand",(()=>tn)),He(Ge,"ResizeCommand",(()=>en)),He(Ge,"GroupCommand",(()=>An)),He(Ge,"CreateLayoutCommand",(()=>nn)),He(Ge,"ClearLayoutCommand",(()=>an)),He(Ge,"CreateElementCommand",(()=>rn)),He(Ge,"DeleteElementCommand",(()=>sn)),He(Ge,"CloneElementCommand",(()=>on)),He(Ge,"FontColorCommand",(()=>cn)),He(Ge,"FontImageFillCommand",(()=>ln)),He(Ge,"FontSizeCommand",(()=>gn)),He(Ge,"FontAlgorithmCommand",(()=>hn)),He(Ge,"FontSourceCommand",(()=>dn)),He(Ge,"FontAlignmentCommand",(()=>un)),He(Ge,"UpdateFramePattern",(()=>wn)),He(Ge,"TextChangeCommand",(()=>Bn)),He(Ge,"IllustrationColorCommand",(()=>pn)),He(Ge,"IllustrationCacheCommand",(()=>En)),He(Ge,"BringToFrontCommand",(()=>mn)),He(Ge,"BringToBackCommand",(()=>fn)),He(Ge,"BringForwardCommand",(()=>Cn)),He(Ge,"SendBackwardsCommand",(()=>Qn)),He(Ge,"LayerCommand",(()=>yn)),He({},"generate",(()=>Te));const Te=()=>{const t=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()};var Oe={};He(Oe,"ElementNotFoundError",(()=>VA)),He(Oe,"findElement",(()=>KA)),He(Oe,"findLayoutForElement",(()=>WA)),He(Oe,"updatedLayoutForElement",(()=>XA)),He(Oe,"rehydrateSerializedLayout",(()=>qA));var Je={};He(Je,"CommandContext",(()=>JA)),He(Je,"getSvgElement",(()=>zA)),He(Je,"elementFactory",(()=>LA)),He(Je,"sortElementsByLayersWithIndex",(()=>jA)),He({},"SVGLayout",(()=>gi));var Le={};let ze;var je;let Ve;var Ke;let We;var Xe;let qe;var Ze;let $e;var _e;let ti,ei;var ii;let Ai;var ni;let ai;var ri;let si;var oi;let ci;var li;He(Le,"LayoutElementType",(()=>ze)),He(Le,"LayoutRenderingPurpose",(()=>Ve)),He(Le,"TextAlgorithm",(()=>We)),He(Le,"UnitOfMeasurement",(()=>qe)),He(Le,"ScaleAxis",(()=>$e)),He(Le,"AspectConditionAction",(()=>ti)),He(Le,"AspectType",(()=>ei)),He(Le,"MaterialEffectMode",(()=>Ai)),He(Le,"AssetType",(()=>ai)),He(Le,"StepType",(()=>si)),He(Le,"StepAspectType",(()=>ci)),(je=ze||(ze={})).Frame="frame",je.Image="image",je.Illustration="illustration",je.Textbox="textbox",(Ke=Ve||(Ve={})).ThreeD="ThreeD",Ke.FreeDesign="FreeDesign",Ke.Print="Print",(Xe=We||(We={})).Autosize="Autosize",Xe.Traditional="Traditional",(Ze=qe||(qe={})).Pixel="px",Ze.Millimeter="mm",Ze.Centimeter="cm",(_e=$e||($e={}))[_e.North=0]="North",_e[_e.Northeast=1]="Northeast",_e[_e.East=2]="East",_e[_e.Southeast=3]="Southeast",_e[_e.South=4]="South",_e[_e.Southwest=5]="Southwest",_e[_e.West=6]="West",_e[_e.Northwest=7]="Northwest",(ti||(ti={})).Show="Show",(ii=ei||(ei={})).FileUpload="FileUpload",ii.Option="Option",ii.Text="Text",(ni=Ai||(Ai={})).None="None",ni.RemoveWhenSelected="RemoveWhenSelected",ni.ApplyWhenSelected="ApplyWhenSelected",(ri=ai||(ai={})).Font="Font",ri.Frame="Frame",ri.Illustration="Illustration",ri.Image="Image",ri.Model="Model",ri.Material="Material",ri.Color="Color",ri.QuestionnaireCollateral="QuestionnaireCollateral",ri.RequestCollateral="RequestCollateral",ri.SignupCollateral="SignupCollateral",ri.Video="Video",ri.ColorProfile="ColorProfile",(oi=si||(si={})).Bulk="Bulk",oi.DigitalContent="DigitalContent",oi.Finish="Finish",oi.Frame="Frame",oi.Illustration="Illustration",oi.Introduction="Introduction",oi.Material="Material",oi.Model="Model",oi.Module="Module",oi.Picture="Picture",oi.Photo="Photo",oi.ProductOverlay="ProductOverlay",oi.Question="Question",oi.Shape="Shape",oi.SilentIllustration="SilentIllustration",oi.Text="Text",(li=ci||(ci={})).Color="Color",li.Colors="Colors",li.Selection="Selection",li.Selections="Selections",li.Text="Text",li.Upload="Upload";const gi=({backgroundColor:t,outlineColor:e,borderRadius:A,configuration:n,elements:a,height:r,maxHeight:s,maxWidth:o,outlineArea:c,position:l,preserveAspectRatio:g,viewBox:h,width:d})=>{const u=A||0,w=2*(c?.scale||1),B=h||{x:0,y:0,width:d,height:r},p=`${B.x} ${B.y} ${B.width} ${B.height}`,E=Te(),m=n.purpose===Ve.FreeDesign&&(0,i.jsx)("defs",{children:(0,i.jsx)("clipPath",{id:"viewboxClip",children:(0,i.jsx)("rect",{width:B.width,height:B.height,rx:u})})}),f=n.colorProfiles?.map(((t,e)=>(0,i.jsx)("color-profile",{name:t.name,xlinkHref:t.key,children:" "},e))),C=jA(a.map((t=>({...t,_renderingConfiguration:n,mask:c?`url(#viewmask-${E})`:void 0}))));return(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",preserveAspectRatio:g,width:d,height:r,style:{gridColumn:1,gridRow:1,maxWidth:o,maxHeight:s,position:l},viewBox:p,children:[f,m,!!t&&(0,i.jsx)("rect",{id:"layout-background",width:B.width,height:B.height,fill:t,rx:u}),(0,i.jsx)("g",{id:"element-group",clipPath:n.purpose===Ve.FreeDesign?"url(#viewboxClip)":void 0,children:C.map((t=>LA(t))).filter((t=>!!t))}),c&&(0,i.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"none",stroke:c.hidden?"none":e||"#aaaaaa",strokeWidth:w/2,strokeDasharray:`${2*w} ${w}`}),c&&(0,i.jsxs)("mask",{id:`viewmask-${E}`,children:[(0,i.jsx)("rect",{x:B.x,y:B.y,width:B.width,height:B.height,fill:"black"}),(0,i.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"white"})]})]})};He({},"Image",(()=>Fi));var hi={};He(hi,"getAxisAlignedBoundingBox",(()=>di)),He(hi,"degreesToRadians",(()=>wi)),He(hi,"findAngle",(()=>ui)),He(hi,"radiansToDegrees",(()=>Bi)),He(hi,"isCloseToValue",(()=>pi)),He(hi,"getTrueCoordinates",(()=>Ei)),He(hi,"getPointOfRotation",(()=>mi)),He(hi,"getNWPoint",(()=>fi)),He(hi,"getNEPoint",(()=>Ci)),He(hi,"getSWPoint",(()=>Qi)),He(hi,"getSEPoint",(()=>yi)),He(hi,"turnRightClockwise",(()=>Di)),He(hi,"currentDirection",(()=>Ii)),He(hi,"getElementVertices",(()=>xi)),He(hi,"rotateAroundPoint",(()=>vi)),He(hi,"mmPerPixel",(()=>Mi)),He(hi,"cmPerPixel",(()=>Si));const di=(t,e,i,A,n)=>{const a=wi(n),r=i/2,s=A/2,o=t+r,c=e+s,l=Math.sin(a),g=Math.cos(a),h=-s,d=r*g-h*l,u=r*g-s*l,w=r*l+h*g,B=r*l+s*g,p=Math.max(Math.abs(d),Math.abs(u)),E=Math.max(Math.abs(w),Math.abs(B));return{minX:o-p,maxX:o+p,minY:c-E,maxY:c+E}},ui=(t,e,i)=>{const A=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),n=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),a=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2));return Math.acos((n*n+A*A-a*a)/(2*n*A))*(180/Math.PI)},wi=t=>t*(Math.PI/180),Bi=t=>t*(180/Math.PI),pi=(t,e,i)=>Math.abs(t-e)<i,Ei=(t,e,i)=>{const A=Math.sin(wi(i)),n=Math.cos(wi(i));return{x:(t.x-e.x)*n-(t.y-e.y)*A+e.x,y:(t.x-e.x)*A+(t.y-e.y)*n+e.y}},mi=(t,e)=>({x:(t.x+e.x)/2,y:(t.y+e.y)/2}),fi=(t,e,i,A)=>({x:t.x+e?.x*i,y:t.y+e?.y*A}),Ci=(t,e,i,A)=>({x:t.x+(e?.x+e?.width)*i,y:t.y+e?.y*A}),Qi=(t,e,i,A)=>({x:t.x+e?.x*i,y:t.y+(e?.y+e?.height)*A}),yi=(t,e,i,A)=>({x:t.x+(e?.x+e?.width)*i,y:t.y+(e?.y+e?.height)*A}),Di=t=>{switch(t){case $e.North:return $e.East;case $e.East:return $e.South;case $e.South:return $e.West;case $e.West:return $e.North;case $e.Northwest:return $e.Northeast;case $e.Northeast:return $e.Southeast;case $e.Southeast:return $e.Southwest;case $e.Southwest:return $e.Northwest}},Ii=(t,e)=>e>45&&e<=135?Di(t):e>135&&e<=225?Di(Di(t)):e>225&&e<=315?Di(Di(Di(t))):t,xi=(t,e={x:0,y:0},i={x:1,y:1})=>{const A=wi(t.rotation),n={x:e.x+t.x*i.x,y:e.x+t.y*i.y},a={x:t.x+t.width,y:t.y},r={x:e.x+(t.x+t.width)*i.x,y:e.y+(t.height+t.y)*i.y},s={x:e.x+t.x*i.x,y:e.y+(t.height+t.y)*i.y},o={x:(s.x+r.x)/2,y:s.y-t.height*i.y/2};return{a:vi(n,o,A),b:vi(a,o,A),c:vi(r,o,A),d:vi(s,o,A),center:o}},vi=(t,e,i)=>{const A=Math.sin(i),n=Math.cos(i);return{x:(t.x-e.x)*n-(t.y-e.y)*A+e.x,y:(t.x-e.x)*A+(t.y-e.y)*n+e.y}},Mi=.352778,Si=.035277,Fi=t=>{const e=t.rotation||0,A=wi(e),n=Math.cos(A),a=-Math.sin(A);return(0,i.jsx)("g",{mask:t.stepName||t.productOverlay?void 0:t.mask,children:(0,i.jsx)("g",{transform:`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${n}, ${-a}, ${a}, ${n}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n `,children:(0,i.jsx)("image",{xlinkHref:t.src,preserveAspectRatio:t.preserveAspectRatio,width:t.width,height:t.height})})})};He({},"Frame",(()=>Yi));const bi=256,Yi=t=>{const e=`spiff-frame-${t.id}`,n=`spiff-frame-blur-${t.id}`,a=`spiff-frame-blur-edge-${t.id}`,r=`spiff-frame-focal-mask-${t.id}`,s=()=>t.disablePlaceholder&&!t.pattern?"":t.pattern?t.pattern.src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAAAsSAAALEgHS3X78AAAZL0lEQVR4nO2diVIbSRZFq/GCsZBZjRea6fn/r+oZGrMYBBhkLGwzE1cmTSqVWXuqVFXnRHREG6OlpX43X771j5O/7/+XAEAvWeFrB+gvCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAECPQQAAGuLnz5+Nf/QIAEADyPhHl+fJ5/PTRj/+53z5AItFxn9y+in5Nvn2+3Xf7r5r5FvAAwBYID7jH4/Hyfcf3xv5GhAAgAXhM/5nK8+SD+8/Ji+ev2jka0AAABZAmvGvrr5q7CsgBgAQGZ/x68R/t/e+UeNPEACAuPiM/9Xqq+T9u4/Js2fPGv/0uQIARGLZjT/BAwCIw2TyLTk9O5mJ7i+b8ScIAED9yPiPTz4lPx+eKv2W0fgTrgAA9VKn8esKcXx8NH3OWCAAADUhd981frG9tVPK+BU/+Prt6/Q5Y4kAAgBQE0rtDQaDuSdTLKCIAbvBQwnKaHQR5WtCAABqRDX9b4ZvZp5QBpz3FA9lDvb23kf5mhAAgJpJE4G0mv8m0oYIAEAEQiJwdnbinQPQVM0AAgAQCZ8IyMBl6LYIyCtoqmAIAQAoyZeb68w2XonAK6fe3xYBxQWOjg4bqxZkOzBAQW7HN9OovIxfJ3zWMA+fe588Gvr3798bLRjCAwDIiQz59Ox4psT3y82XTC9Axiyj9nkCdRq/3l/ROYMIAEAOpq76p8Pkdnw788vq6R/f3mQ+QUgEDPIk9j8eVDJ+eRnnF2eFHkcvAEAGvvJesbO1kwyHG7mN1oiA7zpQhZkrxiRJVs5Pc88YxAMASCFU2//nx4Nkc3O78Ikd8gR0lSgzIdgXX7i/v899FUAAAAL4jF+uugy4yiQfiYAq+3R9sCkqAnXUDiAAAB5kXOcXn+eMX651HRF69Q1oHmBZETAxiarpQwQAwMP19eWMceVJ9xVFXkQZETCeSR3DRhAAAIe7u6/J5fXl7x/KuLa3dit9TKE7eVERqHvYCAIA4HB1dTnzg92dt5XcflUMHv7zn2A3YJoI6LGGGJOGEAAACxmZhnAY5PpXCfjJgD+fn02NdhpTKOgJ6LF6jlhjxhAAAIuxU+jzZrhR+uMxxm/wNQLZSATeefr+9Ryu8a8P1mspGUYAACzsSj9F6sue/q7xG7JEYG3tdfJ2d2/u52424t3eh1qyEQgAwCOKqtuR9bW1tVIfzdXVyGv8hiwRkNfhE4EkQjYCAQB45Mf32aaeMgs7Fbm/uHya36c7vaoG88wFsPGJQIxUJAIA8Ihb618UGb8i9wZ7+acM9/Wr1zPPWEQEYhh/ggAAPOF6AEVwjdi3+Vflv76W4NHlefCVJAIf3+9HMf4EAQB4wg34PTw85P50FJAzI8BCa7/LNgIpMBgLBAAgwN23u8IfjSoG03b+190NWBUEAOAR96SVe5417cdFBp6VOkwTgdEofB2IAQIAYOEG6pTSi4ERATfTsLKyWJNEAAAs3Nx/npl/ZXn438PMc0sMhhUqD8uAAABYTEd8OfX4WuYRA9fd394uvkS0KggAgIUMcHNjc+ZnigXUHaDT1cIuO1Zt//pguPCvAgGATqA8vN06WwWfF+C25lZBz2NXC8r1393xl/7GBgGA1mNm46n+/r+Hf1c2VHkBoa68qkFBt0lIQqPXWrTrb2AzELSa0NYdnaq6U1dxq2Xs9kltkLuuE7uI0ep9quLPLhVOpqvD9iq1HFcFAYDWEjJ+G6X1Nje3SlfTufX9Bp3cihXk2QugU19ThtxsQtPGnyAA0GYkABq1ZZp4ZJShhp4qQhASAfOag8FgWvwjr+P5ixfTngK9j/vJZBro86URl8H4EwQA2o5rnDKsm5svQa+grBCErgNFkUjozl9lzFidIADQanS6KvBnkIF/+LA/Ndir66tUj2D37V6hnn/N5dNcv7JrvdQopF6BpgJ+PhAAaD2uF6D2WZ3wuiLcOCk3FxmlVnwVEYLQnT6EgoZy92N29ZUFAYDWE/ICDPp7eQShe3xSUgjkEWiI6GQySSb3k9/exq9ZgqvJ6svVZLA+LDVZaFEgANAJjo+PZsZ5Gy/AJpYQtBkEADqBtvl8Ojn6/Z+iVlvt2/eRRwiKrv5uKwgAdIY8XoCNREN3efsxNkVy/W2FUmDoDErv2bgrvlwkDooVuDMADLrTK4CoWgN5DHl37rcJBAA6gwzavrvrZNcpn4YyCCEPwNBlIUAAoFO4XkBaY5CbPlTc4F8H/062Nra8v28LQV2dgU2DAMBSYRZhlkX5dtsLCJXi+ozfjOja3t6dCoG7zMMgITCdh7fjm1b/D4QAwNJgWmW1CDPLdU9jPhbw1MIr9/3o06HX+O1An4RAY77ThEBjw9ueLkQAYCnQiWz65HXCKqVX1s0evF6fGehh5vr5ugezVmyHhCA0+79tkAaExknrtivbNec278h47+/vZ4y/TF+/PBMJ0+bGVuuNXzxfgvcAEERewcPPn9PqvCIod283A7kCU3bXnjINy1jTXxauANA4rnG7CzN0khcdyqlTPXR3j7Vos40gANA4umfbxTgrf6zMGW+Z1VnDN/NXB7n9GP8TCAAsBcM3TwavwhzN8vOJwOnZce5CHAlLyAuAXyAAsBTI4O2Umsp4zbZdG+X103bqu7jXi1BdQF9BAGBpsPP38gJUEOQTAUXy84qAREVuv02sfX9tBAGApWE+f/+rDiBNBPJUDbppxJj7/toGAgBLgxu5tw01JAKqGswSAaXtFrX1t20gALBUuJF721B9IqA8fx4RmG8SwgtIEABYNtzIvWuoEgFN67ExIpBWOiwvwK0vuPnSjY6+KiAAsHS467zGt7Mdd4rsq0TYxnTopYnA0JNW7OKQjyIgALB0uKf1tKTXMVQF9lwRSB5Lh0Mi4LYKSzRuOtLXXxYEAGpDRqpqvSqtvAb7tA4ZqhEBd5W3RGA0Ovc+rxsLUEtvn0EAoBYUhDN99mrl1YDOKkLgntahbkH9ntpyXRG4vL70lg6/sXb/Tzf1bO/2+n8ABAAqM3lMx9nBOhXyVBUCOxio5w659mrL9YlAqH9Ak35pCPoF8wCgEjLMo6PD4A4+Q5mlnO72X3fjj4sRIve96HF7e+9/9/3rebs+7z8veABQCbnpa2trM0+hk9gdlVXGI5CRavW2/Rxp+X55Agd//jWX7tPj7NJhjP8JBAAqo6k6ttHpBJYouPn6pIQQuM08WWPCZNwa8eWKQJH+gT6BAEBlZHRTF9uZw6cIu2bp+RZv5BWCrMIgHyERUGaB038WBABqQYaqQJyNIvEybt3btabLN0E3jxC4XoBbGOTDiIDEQ8Kk1y8zW7DrEASEWjGjvW3swZ76+9HoIhg0lLew+3ZvTizswaEyaN31857miht0YYBnDPAAIBd5784ydHezjgzeBO/09zJexQfctF3y6BFo4YYM3nb1bS9A4jH+epv7i8P4wyAAkIkp8sm7sUfFNfYQDrdjTye3DDpNCHTaK71odvG5sYCsxZ+QDwQAUrGLfPK03Rp8mYHzi88znoQRgv39A+/sPrOLT+KjFVy2F6D30/a1XMsAMQAI4ivyKbIRx/d4icL+x4Pg7+vED5X9Kj6w8mxlOtcvyVEYBNngAUAQud12IU5SYABHEsgMKB8fGu+dtY9P8QFj/EmOwiDIBgGAVKpM4UkeA3Bu265O+FC3XmIJwZ8fD7w1BLPPxVCPKiAAkEmaCOQZq+XLDKhGIMt4p00+jzUEISFgqEc1EADIRUgEzs5OchmgmxlIHvv283gRaiAKCcEbqvsqQRAQCuHb5Ju1YtvgW89dZs22KgZHlxfJy5cvaemtCAIAhVFa7ptzcucVgVBmIM9joX64AkBhqnTbhTIDukrA4kEAoDBVW259mQGl9Ipu/4XqIABQiqoi4MsMKLbAxp7FggBAadJEYHQZzvMbfJkBlf5S4rs4EACoREgEQgM5XdyeAXF+/pkKvwWBAEBlfBOBkpwi4HusKTKiwCc+CADUgonulxEBX2aArT2LAQGA2ig6n9/GzQyows8dBQb1QyEQ1E5oPn+eZRxqEtLjqPBbDAgARCEkAvZ8QGgeBKDjKJB2fz+Zi6o/f/EiWXv1Omr5LSKw/CAAHUW59PH4dmaAhg911w3W16MZpBp3NPbbBRFYDhCAjmE65dxmnSyUi9/deRtlgq5vVHiCCCwFCEBHkKt/fX05HbRRBU3pjRF9D4mAevyLLAyFennO59l+1GKrbjrfqa+TffB6dq7f5H6S3N3deZdzqBRXz1d3FN6c9LYIKCuA8TcLAtByfIE25eG1A3+wPvSu4zLoVNZ8fXeslxn4EVME2M+/HHAFaDE+4w+t1gqhq4Mad3yjuGMZqeIUnPzLAQLQUnzGX+X+TqCun1AK3EJ8xi9DrRK8k5G7QzqSx71+eSb/QjtBAFpGyPjrOKV9IjBd6fV53jOAboAAtAjd12MZv0HP5Y7/1riu0O5+aDcIQEswI7Vt45ehxrifb2/tzgUR2cbbTRCAlqBIvZvnXx8Mo7z5X1t7Z+f1yQsgFtA9EIAWc3p2Em10ljwL1wsY3zKrr2sgAC2h6pLOMrivpwpC6BYIQIuouqSzKG6xzo8fP/r3oXccBKBlVF3SWQS3M7BohyEsPwhAC/GJQN6FHEXJW1IM7QQBaCkSgbJbeYrw8PDw+7fdYZ/QfhCAFlNlNVde7LqD1Zerff/IOwcC0GKq7ufLws0urK2t9f0j7xwIQMuJKQJu+S8tvN0DAWgAGeWXGrfeVF3SGcKeEaBgYIx5gdAsCMCCMTX96r3/7+HftQlB1SWdLnpfdm2BWxoM3QABWCDG+E0+XQZmhKCOldhVlnTaTKcEjS5+/0SnP0NBugkCsCBc47eREKiu//j4qHLbbZUlnYbzi7O5lmPoJgjAAvn+/cml9uXU1XGnJRpVhaDKkk79vb1MZGtji+Bfh0EAFoTc88HgaTz3rwWYe3N39qQmISgjArr324E/vbeNDe7+XQYBWCDuzL7x7W2y//FgOswzyyMo0+yTJgJu8FFbee2hoHrMNJ4QcXcgNA9TgReMTl/7lDWbcRQjuLm5ni7mCGF25hetz89a0um+Jxm/hIO0X/dBABaMTnJF/Q2a4//hw/7vP+vvr65G3jn9hjJCEFrSqeewvQuMv18gAA0gl17uvcG3Hy+GEIRm/xsw/v6BADSAexor2KZYgI88QqAYwnC4keu+HhKBmNuBYXlBABoijxdgI9HQZF77MTZmH2AeIXBFQMavKkICfv2DLEBDuKW1WWO3JQ6KFShm4EMBPgUQD//5z9RjSGsCsheA6BqB8fcXtgM3hAzaDsCZ5RtpXoCi9SEPwGCE4Or6KtUjMFN/KfLpN3gADeJ6AWmNQW6qTm77vw7+Pa3U82F7BKHnxfiBGEDDKCVop+Fk1G5U32f8ttueJ1Co59ze3om2TATaCR5Aw8zHAka//133+KNPh6nGnzwat2YESjzcYaEGzfZjwCe4IAANM3i9PlOqK2PXie7rHsyK1oeEgPw+hOAKsATo1LdLgGW89/f3M8a/PlhPdnf2CkXrFVTU/X9zYwvjBy8IQAl0Qqu+/sf32Qad5y9eJGuvXhdOqem0V7DOrdU3SBB0sgPUDWnAAug0VQdfVipOrvqwwOpuCYaM/PJ6vhYA44eYIAA50Gl/fvE592os/Z7+UXGPgnx5hGD4ZmNOAOT2Y/wQE4KAGejU/+fTYam9eGbm3+nZceZ47l9z9/wRfIBY4AGk4ObfDSrHdZdk3N3dBa8GGrGlv8+KxKuzz349PW77x3fSdxANgoAB3Mh8kqP91gz1MKk8lzzpOHkL9kw+YgAQE64AHpQ+s41fhvtu7/3UENNOYwXzJBBmzJeL2eXvrtyyceMFITEBqAMEwEGnuDsbT6d2kRJaIwRq8XXn8RkRCBm16vPdjj+7OhCgThAAhxt3I87GZukiGhnzwZ9/zU3+lQicnZ0EHzffJIQXAHFAABzcunt3km9R0vb2hU52CYf7+zdf6tslCGBAACy0nss+aYc1peVCK7sUZwid7O5rS5jq2vkPYEAALNzSXjXq1IWCh7u7b+eeLeQFmIEdBl0bbmrcKAyQIACzKFdvU/eYLAUS3WKftPu9GwtQSy9AnSAAAUKz96riiymMb/2bgeUFmGuDhGN7ezfmfzL0EATAwq7ky2r4KYuv5Hf8dRx8NmUhKAaCWCAAFnPpukhBN7fYJ63PYDid4IvxQxwQAIuVP2Y/jrtIXoDqCtyKwlB1IOO6ISYIgMXq6urMn6vs6M/CFQACfNAECIDFS0cAYube3W5CgCZAACzWPJF/cu/QZRAACzOay0bVemnde2WZ3E9mHsmSDmgCBMDBl6fXOLC6rwKTyZMAuNkHgEWBADj48vRK040uz2t7DXkUdvXf2iviAdAMCICH7a3ducYdBQQ1IqwO3F19GggK0ASdEYA6XXTFAnyNO3WIwK9lHU8tx/I2mPkHTdEJAZBLrR16dQbr1Ljj27wr480z5deH3t+pNQhEXkbVeQMAVWi9AMiozIitrHl7RVHzjW9Ut4Z2pq3d9qFZA3p/9vYfbevl9IcmafVUYBn90dHhjFHFWIQZGg+eWEHDwfrQa8wy/JsvX+aai2jwgWWg9WPBfcYZQwR8Y8JdJAC2CCjX79v3h/HDstCJvQCLEgEF8DQxuOyATr0nuf15dwYCxKYzi0FCIrC/f1D7PVvewNX1VXCbrw8NGNl9u8edH5aKTm0G8omAquw0lbfutlplAcZfb6degUaJ+cRAxq4Fn4PBOvv5YSnp3GqwRYqAja4F9lDRly9X6eWHpaeTuwGPPNt8FyECAG2jNXUAcrnlbucJwIUWcZycfmK2PoDFUnsAMnZtxFHhjW34Cu4NBoPMTb0y+JiegF4DjwLazFIKgAzr+voyuby+zPxdleuGxmXHFAHz3NrgQ1oP2srSXQEmj656HuMX+r1Qg07aXr4q7b22sKguoEhJMMAysVQCYOr63RNbbr7y6PrHbdNNMrr0QiJQtrPP51XcsLcPWsrSXAF0itp7+ZPH4hmtx3LHZel3R6OLudz7u733wT3+vr6BpGBZrs/4yS5Am1kKD0ANM67x72ztJB8+7Htn5enOrTJf1xuQKISQF+F7TF5PwLQcY/zQJRoXABnW+fnnmZ+93d3L7JNXZZ0M2kanfNp93DymqAjYLccGjB+6QKMCYAzLdstl/Hmj6jJot18/ax5AURHwvUeMH7pCYwKg+/R02q5lWHL7i6bU3N//8f1H5mPSRMD2IDB+6DqNCcD5xdlctL/MbPyyTTYhETBpPYwf+kBjArCyMv/SdY/0ykIioMyBi0TANX519WH80DUaEwCl3tz7uwyuqAi4vQFFd+7J61DcwcU2fr3Pd3sfMH7oHI0GAdNEIO/UHXeDb5krwZvpDv55EUgY3wUdp/E0YEgEzs5OMqvr9PdXV08lw8r1l92x5xMBjB+6TnQByLNj3ycCedp3Vc9vewqqGqyCLQIYP/SBqAKgvPqnk6NczTIytiI9/HpOe/KPyobr6MrTc3x8v4/xQy+IJgD2aK68HXN5B3m4fQNK5WngZl2wqhv6QhQBcPffJY8ikHUdSGvflQjI3ZewuMavfD7TdgGKE60bcDQ6n+vpzzurPzTIwyXG7H+APhHtCuDbq5c3zx/yBGZ+B+MHqEzUIGCVYp80EZDxH/z5F8YPUJHoacCqIrC3936uXl+PrzLSCwB+sZBCoCoiUHWQBwCEWVglYJoIZFX8lR3kAQDpLLQU2FfsIxHIs7ADEQCon4X3AlTZ2pN3kAcA5GPhApBV7FNWBJjPD1Cc3AJQ59z7OkQgNMgDEQDITy4BMCOx65zWkyYCagXOIjTIAxEAyE+mANgjsese2RUSga/fvuYK7IUGeeTpOwCADAEwRm/GY5UZ2ZVFqNhHgT0tDMkiNMiDjj6AbFIFQEU4WsNtE0MEQsU+WhiSJ/bAIA+AcuTqBrR7+w0xmnHktmuAiE3a+m/f4zn5AfKTKwhYx/DOPMh4tRzERi3FeTMQGD9AMXKnASUCmo1vk3d4ZxGGw4254R7jr7d8rQARKFQItLuzVzp3nxcFBV1vg4g+QBwKCUDVAp68DJ3hnpPJhK8fIAKFS4EXIQJ6DfsaUGecAQCeKNULsAgRYMgnQHxKNwPFFgH71NfMfwCon0rdgEYE3NNaIlBlZJeM3xaA1dXV2v/DAaCGdmCJwLtAKW/ZQR1XV6OZPw+c9CMA1EMt8wDSBnWcnh0Xug64S0Xk/jP9FyAOtQ0ECYnA7fj291afLNRfcOq0Am9v72Q+DgDKUftmINM+bDoIbVTmqxy/rg0ucvsvLi9mfqoGnzoWfgKAnyirwdJEIHl069fW1qb/Ls/g7u5uzkOgqw8gPtF2A+bd7+ejSAcgAJQnmgAYfK59iOma7923yfpgyFcKsACiC0Dy6OZLCMbjsfdaIMPf3NgMxgcAIA4LEQAbpfkkCA8/fyYrjzX/9PEDNMPzRb+qjH2NLxtgKVj4YhAAWB4QAIAegwAA9BgEAKDHIAAAPQYBAOgxCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAEBfSZLk/xjo1hVZWiK0AAAAAElFTkSuQmCC";if(!s())return(0,i.jsx)(F(A).Fragment,{});const o=!!t.focalBlur&&!!t.pattern,c=t.rotation||0,l=wi(c),g=Math.cos(l),h=-Math.sin(l);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("defs",{children:(A=>{const o=t.pattern?.x||0,c=t.pattern?.y||0,l=t.pattern?t.pattern.width*t.pattern.scaleX+Math.abs(o):0,g=t.pattern?t.pattern.height*t.pattern.scaleY+Math.abs(c):0,h=t.dataWidth||l||bi,d=t.dataHeight||g||256,u=t.pattern?t.pattern.width*t.pattern.scaleX:bi,w=t.pattern?t.pattern.height*t.pattern.scaleY:256;return(0,i.jsxs)("g",{mask:t.stepName?void 0:t.mask,children:[(0,i.jsx)("pattern",{patternUnits:t.pattern?void 0:"userSpaceOnUse",x:0,y:0,width:t.pattern?1:bi,height:t.pattern?1:bi,"data-frame-width":t.pattern?h:void 0,"data-frame-height":t.pattern?d:void 0,id:e,children:(0,i.jsx)("image",{preserveAspectRatio:"none",x:o,y:c,width:u,height:w,xlinkHref:s()})}),A?(0,i.jsx)(Pi,{path:t.path,width:t.width,height:t.height,focalBlurStrength:t.focalBlurStrength||1,focalBlurRadius:t.focalBlurRadius||10,blurFilterId:n,focalMaskId:r,blurEdgeClipId:a}):null]})})(o)}),(0,i.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,i.jsxs)("g",{transform:`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${g}, ${-h}, ${h}, ${g}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n matrix(${t.scaleX}, 0, 0, ${t.scaleY}, 0, 0)\n `,children:[(0,i.jsx)("path",{filter:o?`url(#${n})`:void 0,mask:o?`url(#${a})`:void 0,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}),o?(0,i.jsx)("path",{mask:`url(#${r})`,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}):void 0]})})]})},Pi=t=>{const{path:e,width:A,height:n,focalBlurStrength:a,focalBlurRadius:r,blurFilterId:s,focalMaskId:o,blurEdgeClipId:c}=t;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("filter",{id:s,children:(0,i.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,i.jsx)("mask",{id:o,children:(0,i.jsx)("circle",{cx:A/2,cy:n/2,r:r||0,fill:"white",filter:`url(#${s})`})}),(0,i.jsx)("mask",{id:c,children:(0,i.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};He({},"Textbox",(()=>YA));var Ni={};He(Ni,"fontSizeStep",(()=>pA)),He(Ni,"textWidth",(()=>EA)),He(Ni,"charWidth",(()=>mA)),He(Ni,"lineWidth",(()=>fA)),He(Ni,"applyTextTransformations",(()=>QA)),He(Ni,"zip",(()=>yA)),He(Ni,"getTextAlignment",(()=>DA)),He(Ni,"getAnchor",(()=>IA)),He(Ni,"recomputeTextOnElement",(()=>xA)),He(Ni,"defaultLineHeightFactor",(()=>vA));var Ri={};He(Ri,"refitTextbox",(()=>wA)),He(Ri,"recalculateTextboxRegion",(()=>BA));var ki={};He(ki,"FontMetrics",(()=>aA)),He(ki,"loadFontFromExternalUrl",(()=>sA)),He(ki,"loadFontFromDataUrl",(()=>oA)),He(ki,"getFontMetrics",(()=>cA));var Hi={};He(Hi,"registerJSDOM",(()=>Ti)),He(Hi,"createElement",(()=>zi)),He(Hi,"createElementNS",(()=>ji)),He(Hi,"domParser",(()=>Vi)),He(Hi,"fetchAsArrayBuffer",(()=>Ki)),He(Hi,"fetchAsString",(()=>Wi)),He(Hi,"loadFontFaceSet",(()=>Xi)),He(Hi,"xmlSerializer",(()=>qi)),He(Hi,"toBase64",(()=>Zi)),He(Hi,"dataUrlFromExternalUrl",(()=>$i)),He(Hi,"arrayBufferToDataUrl",(()=>_i)),He(Hi,"arrayBufferToBuffer",(()=>eA)),He(Hi,"dataUrlToArrayBuffer",(()=>tA));var Ui=a.Buffer;let Gi;function Ti(t){Gi=t}function Oi(){if(!Gi)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new Gi}if(void 0===Ue.TextEncoder){const{TextEncoder:t}=c;Ue.TextEncoder=t}if(void 0===Ue.TextDecoder){const{TextDecoder:t}=c;Ue.TextDecoder=t}const Ji=new(F(s).Agent)({rejectUnauthorized:!("local"===Ue.process?.env?.ENVIRONMENT)}),Li=t=>t.every((t=>"undefined"!==t)),zi=t=>Li([typeof document])?document.createElement(t):Oi().window.document.createElement(t),ji=(t,e)=>{if(Li([typeof document]))return document.createElementNS(t,e);const i=Oi().window.document.createElement(e);return i.setAttribute("xmlns",t),i},Vi=()=>Li([typeof DOMParser])?new DOMParser:new(Oi().window.DOMParser),Ki=t=>{if(Li([typeof fetch]))return new Promise(((e,i)=>{fetch(t).then((t=>{e(t.arrayBuffer())})).catch((t=>{i(t)}))}));{const e=t.replace("localhost","localstack");return new Promise(((t,i)=>{F(r).get(e,{responseType:"arraybuffer",httpsAgent:Ji}).then((e=>{t(e.data)})).catch((t=>{i(t)}))}))}},Wi=t=>{if(Li([typeof fetch]))return new Promise(((e,i)=>{fetch(t).then((t=>{e(t.text())})).catch(i)}));{const e=t.replace("localhost","localstack");return new Promise(((t,i)=>{F(r).get(e,{responseType:"text",httpsAgent:Ji}).then((e=>{t(e.data)})).catch(i)}))}},Xi=async(t,e)=>{if(Li([typeof FontFace])){const i=t.names.fullName.en,A=new FontFace(i,`url(${e})`);return document.fonts.add(A),A.load()}},qi=()=>Li([typeof XMLSerializer])?new XMLSerializer:new(Oi().window.XMLSerializer),Zi=t=>Li([typeof btoa])?btoa(t):Ui.from(t).toString("base64"),$i=async t=>{if(Li([typeof fetch,typeof Blob,typeof FileReader])){const e=await fetch(t),i=await e.blob();return await AA(i)}const e=(await F(r).get(t,{responseType:"arraybuffer"})).data;return _i(e)},_i=async t=>{const e=await(async t=>{const e=await(0,o.fromBuffer)(t);return e?e.mime:"image/svg+xml"})(t);return`data:${e};base64,${eA(t).toString("base64")}`},tA=t=>{const e=t.replace(/\r?\n/g,""),i=e.indexOf(",");if(-1===i||i<=4)throw new TypeError("malformed data: URI");const A=e.substring(5,i).split(";");let n=!1;for(let t=1;t<A.length;t++)"base64"===A[t]&&(n=!0);const a=n?"base64":"ascii",r=unescape(e.substring(i+1)),s=Ui.from(r,a);return iA(s)},eA=t=>Ui.from(t),iA=t=>{const e=new ArrayBuffer(t.byteLength),i=new Uint8Array(e);for(let e=0;e<t.length;++e)i[e]=t[e];return e},AA=t=>new Promise(((e,i)=>{const A=new FileReader;A.onload=function(t){const A=t.target;A&&A.result?e(A.result.toString()):i()},A.readAsDataURL(t)})),nA=new Map;class aA{constructor(t){this.font=t,this.glyphsFromText=new Map,this.kerningValues=new Map,this.height=this.calculateApproximateHeight()}getFont(){return this.font}getGlyphs(t){const e=this.glyphsFromText.get(t);if(e)return e;const i=this.font.stringToGlyphs(t);return this.glyphsFromText.set(t,i),i}getApproximateHeight(){return this.height}getExactHeight(t){const e=this.font.stringToGlyphs(t);let i=0,A=0;return e.forEach((t=>{const e=t.getMetrics();i=Math.max(i,e.yMax),A=Math.min(A,e.yMin)})),i-A}getKerningValue(t,e){let i=this.kerningValues.get(t.name);i||(i=new Map,this.kerningValues.set(t.name,i));let A=i.get(e.name);return A||(A=this.font.getKerningValue(t,e),i.set(e.name,A)),A}calculateApproximateHeight(){const t=this.font.stringToGlyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");let e=0,i=0;return t.forEach((t=>{const A=t.getMetrics();e=Math.max(e,A.yMax),i=Math.min(i,A.yMin)})),e-i}}const rA=t=>"data:"===t.substring(0,5).toLowerCase().trim(),sA=async t=>{const e=rA(t)?oA(t):oA(await $i(t));return lA(e,{assetUrl:rA(t)?t:await $i(t),name:e.names.fullName.en}),await Xi(e,t),e},oA=t=>{const e=tA(t),i=F(n).parse(e);return lA(i,{assetUrl:t,name:i.names.fullName.en}),i},cA=t=>{const e=nA.get(t.name);if(e)return e;throw new Error("Font metrics unavailable for font")},lA=(t,e)=>{const i=new aA(t);return nA.set(e.name,i),i},gA=(t,e,i,A)=>Math.max(mA(t.join("\n"),i,A),e),hA=(t,e,i,A,n,a)=>{const r=(a||vA)*n.getApproximateHeight(),s=e.split("\n");try{const e=s.flatMap((e=>dA(e,t.width,A,n))),a=e.flatMap((t=>t.lines));return{lines:a,requiredHeight:e.flatMap((t=>t.lines)).length*(A*r),fontSize:i,requiredWidth:gA(a,t.width,A,n)}}catch(a){const s=e.split("");return{lines:s,requiredHeight:s.length*(A*r),fontSize:i,requiredWidth:gA(s,t.width,A,n)}}},dA=(t,e,i,A)=>{const n=EA(t,i,A);if(n<=e)return{lines:[t],width:n};if(!(t.indexOf(" ")>-1)){if(t.length<=1)throw new Error(`Character ${t} is wider than region`);const n=Math.floor(t.length/2),a=dA(t.slice(0,n),e,i,A),r=dA(t.slice(n),e,i,A);return{lines:[...a.lines,...r.lines],width:Math.max(a.width,r.width)}}const a=t.split(" "),r=[];let s=-1/0,o=0;for(;o<a.length;){const t=a[o];if(EA(t,i,A)>e){const n=dA(t,e,i,A);r.push(...n.lines),s=Math.max(s,n.width),o++}else{const n=[t];s=Math.max(s,EA(t,i,A));let c=o+1,l=!0;for(;c<a.length&&l;){const t=a[c],r=EA(`${n.join(" ")} ${t}`,i,A);r<=e?(n.push(t),s=Math.max(s,r),c++):l=!1}r.push(n.join(" ")),o=c}}if(s<0)throw new Error(`No max width calculated for text: ${r}.`);return{lines:r,width:s}},uA=(t,e,i,A,n,a)=>{const r=(a??vA)*e.getApproximateHeight(),s=1/i.unitsPerEm,o=A/fA(t,s,e),c=n/(t.length*r*s);return Math.min(c,o)},wA=(t,e,i,A)=>{const n=cA(e.fontData),a=n.getFont(),r=e.fontSize/a.unitsPerEm;if(!i)return hA(e,t,e.fontSize,r,n,A);let s;if(s=e.text?e.text.split("\n"):e.input?.split("\n")??[""],i.input===t&&e.width===i.width&&e.height===i.height&&e.lineHeight===i.lineHeight)return{lines:s,requiredHeight:e.height,requiredWidth:gA(s,e.width,r,n),fontSize:e.fontSize};const o=e.width!==i.width!=(e.height!==i.height);return e.lineHeight!==i.lineHeight||o||i.input!==t?hA(e,t,e.fontSize,r,n,A):{lines:s,requiredHeight:e.height,requiredWidth:gA(s,e.width,r,n),fontSize:uA(s,n,a,e.width,e.height,A)}},BA=(t,e,i,A,n)=>{const a=cA(e).getFont();let r={...t},s={...t},o=fA(A,i/a.unitsPerEm,cA(e));return o&&o<r.width&&(s.width=o,"left"===n?(s.left+=Math.sin(r.rotation*Math.PI/360)*(r.width-o),s.top+=Math.sin(r.rotation*Math.PI/180)*(o-r.width)/2):s.left+="right"===n?r.width-o:(r.width-o)/2,A&&yA(A,A).every((([t,e])=>t===e))&&(r=s)),r},pA=1,EA=(t,e,i)=>{let A=0;const n=i.getGlyphs(t);return n.forEach(((t,e)=>{if(t.advanceWidth&&(A+=t.advanceWidth),e<n.length-1){const a=i.getKerningValue(t,n[e+1]);A+=a}})),A*=e,A},mA=(t,e,i)=>{let A=0;const n=i.getGlyphs(t);return n.forEach(((t,e)=>{if(t.advanceWidth&&(A=Math.max(A,t.advanceWidth)),e<n.length-1){const a=i.getKerningValue(t,n[e+1]);A=Math.max(A,a)}})),A*=e,A},fA=(t,e,i)=>{let A=0;return t.forEach((t=>{A=Math.max(A,EA(t,e,i))})),A},CA={stripControlCharacters:!0,vertical:!1,uppercase:!1},QA=(t,e=CA)=>{const i={...CA,...e};let A=t||"";return i.stripControlCharacters&&(A=A.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),i.uppercase&&(A=A.toUpperCase()),i.vertical&&(A=A.split("").join("\n")),A},yA=(t,e)=>t.map(((t,i)=>[t,e[i]])),DA=(t="center",e=!1)=>e?"center":t,IA=t=>"left"===t?"start":"right"===t?"end":"middle",xA=(t,e,i)=>t.fontData?{...t,...(()=>{if(t.algorithm===We.Traditional){const A=wA(e,t,i,t.lineHeight);return{text:A.lines.join("\n"),height:A.requiredHeight,width:A.requiredWidth,fontSize:A.fontSize,input:e}}return{text:e}})()}:t,vA=1.1;var MA={};He(MA,"colorDefinitionPrintValue",(()=>SA)),He(MA,"spotColorDefinitionString",(()=>FA)),He(MA,"svgColorValueToDefinition",(()=>bA));const SA=t=>{const e=FA(t.spotColor);return e?`${t.browserValue} ${e}`:t.browserValue},FA=t=>{if(!t)return"";if(t.profileName.includes("/")&&t.profileName.includes(".icc")){const e=t.profileName.replace(/\s/g,"-"),i=e.lastIndexOf("/");return`icc-named-color(${e.slice(i+1).slice(0,-4)}, ${t.namedColor})`}return`icc-named-color(${t.profileName}, ${t.namedColor})`},bA=t=>{const e=t.split(/[ ](?=[^)]*?(?:\(|$))/);if(0===e.length)return{browserValue:"#000000"};if(1===e.length)return{browserValue:e[0]};const i=e[1].match(/\(([^)]+)\)/gm);if(!i)throw new Error("Unhandled state of color value in SVG");const A=i[0].replace(/[() ]/g,"").split(",");return{browserValue:e[0],spotColor:{profileName:A[0],namedColor:A[1]}}},YA=t=>{const e=(t.rotation||0)*Math.PI/180,A=Math.cos(e),n=-Math.sin(e),a=`text-path-${t.id}`,r=`text-fill-${t.id}`,s=t.x+(t.curved?0:t.width/2),o=t.y+(t.curved?0:t.height/2),c=(t.text||"").split("\n");return t.curved&&!t.paths?null:t.fontData?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("defs",{children:[t.textFillImage&&(0,i.jsx)("pattern",{id:r,patternUnits:"userSpaceOnUse",width:t.textFillImage.scale*t.textFillImage.width,height:t.textFillImage.scale*t.textFillImage.height,x:0,y:0,children:(0,i.jsx)("image",{href:t.textFillImage.src,xlinkHref:t.textFillImage.src,width:t.textFillImage.scale*t.textFillImage.width,height:t.textFillImage.scale*t.textFillImage.height})}),(0,i.jsx)("style",{type:"text/css",dangerouslySetInnerHTML:{__html:`\n @font-face {\n font-family: '${t.fontData.name}';\n src: url('${t.fontData.assetUrl}') format('truetype');\n }\n `}}),t.curved&&t.paths?(0,i.jsx)("path",{id:a,d:t.paths[0]}):void 0]}),t._renderingConfiguration?.debug?(0,i.jsx)("rect",{stroke:"blue",fill:"none",x:t.x,y:t.y,width:t.width,height:t.height}):void 0,(0,i.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,i.jsx)("g",{transform:`matrix(${A}, ${-n}, ${n}, ${A}, ${s}, ${o})`,children:(0,i.jsx)("text",{xmlSpace:"preserve",fontFamily:`'${t.fontData.name}'`,fontSize:t.fontSize,fontStyle:"normal",fontWeight:"normal",fill:t.textFillImage?`url("#${r}")`:t._renderingConfiguration?.spotColors&&t.fillSpotColorDefinition?`${t.fill} ${FA(t.fillSpotColorDefinition)}`:t.fill,style:{whiteSpace:"pre",userSelect:"none"},children:t.curved?(0,i.jsx)(NA,{text:t.text||"",curvedPathId:a,align:t.align}):c.map(((e,A)=>(0,i.jsx)(PA,{align:t.vertical?"center":t.align,fontSize:t.fontSize,thisLineIdx:A,amountLines:c.length,text:e,textboxHeight:t.height,textboxWidth:t.width,lineHeight:t.lineHeight,vertical:t.vertical,verticalAlign:t.verticalAlign},A)))})})})]}):null},PA=t=>(0,i.jsx)("tspan",{textAnchor:IA(t.align),x:"left"===t.align?-t.textboxWidth/2:"right"===t.align?t.textboxWidth/2:0,y:`${(()=>{const e=t.fontSize*(void 0!==t.lineHeight?t.lineHeight:vA),i=t.textboxHeight/2;if("top"===t.verticalAlign)return-i+3*t.fontSize/4+t.thisLineIdx*e;if("bottom"===t.verticalAlign){const A=t.amountLines-1-t.thisLineIdx;return i-t.fontSize/4-A*e}const A=(t.amountLines-1)/2;return(t.thisLineIdx-A)*e+t.fontSize/4})()}px`,children:t.text}),NA=t=>{const e=`#${t.curvedPathId}`;return(0,i.jsx)("textPath",{startOffset:"left"===t.align?"0%":"right"===t.align?"100%":"50%",textAnchor:IA(t.align),href:e,xlinkHref:e,children:t.text})};He({},"Illustration",(()=>OA));var RA={};He(RA,"traverse",(()=>HA)),He(RA,"sanitizeSvgTree",(()=>UA)),He(RA,"modifySVGWithElementProperties",(()=>GA)),He(RA,"generateSVGWithUnknownColors",(()=>TA));const kA=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],HA=(t,e)=>{e(t),t.children.length>0&&Array.from(t.children).forEach((t=>HA(t,e)))},UA=(t,e=!1)=>{!e&&t.setAttribute("preserveAspectRatio","none");const i=[];HA(t,(t=>{if("script"!==t.tagName)if("style"!==t.tagName);else try{(0,l.parse)(t.innerHTML).stylesheet?.rules.forEach((t=>{i.push(t)})),t.remove()}catch(t){console.error(t)}else t.remove()})),HA(t,(t=>{i.forEach((e=>{e.selectors?.forEach((i=>{((t,e)=>{try{return t.matches(e)}catch(i){return t.classList.contains(e.substring(1))}})(t,i)&&e.declarations?.forEach((e=>{e.property&&e.value&&t.setAttribute(e.property,e.value)}))}))}))}))},GA=(t,e,i,A,n)=>{const a=(t=>Vi().parseFromString(t,"image/svg+xml").firstElementChild)(t);if(!a)throw new Error("Failed to read SVG.");return((t,e,i)=>{t.setAttribute("height",`${i}px`),t.setAttribute("width",`${e}px`)})(a,e,i),((t,e,i)=>{HA(t,(t=>{const A=t.attributes.getNamedItem("fill");A&&"none"!==A.value&&t.classList.forEach((A=>{if(A.startsWith("spiff-fill")){const n=e[A];n&&t.setAttribute("fill",i?SA(n):n.browserValue)}}));const n=t.attributes.getNamedItem("stroke");n&&"none"!==n.value&&t.classList.forEach((A=>{if(A.startsWith("spiff-stroke")){const n=e[A];n&&t.setAttribute("stroke",i?SA(n):n.browserValue)}}))}))})(a,A,n),(t=>qi().serializeToString(t))(a)},TA=async t=>{const e=t.match(/<svg.*?<\/svg>/s)||[],i=e?.length>0?e[0]:"",A=Vi().parseFromString(i,"image/svg+xml").firstElementChild;if(!A)throw new Error("Failed to read SVG.");UA(A);const n={};HA(A,(t=>{kA.includes(t.tagName)&&!t.attributes.getNamedItem("fill")&&t.setAttribute("fill","black");const e=t.attributes.getNamedItem("fill");if(e&&"none"!==e.value){const i=bA(e.value),A=`spiff-fill-${i.browserValue.replace(/\W/g,"")}`;t.setAttribute("fill",i.browserValue),t.classList.add(A),n[A]=i}const i=t.attributes.getNamedItem("stroke");if(i&&"none"!==i.value){const e=bA(i.value),A=`spiff-stroke-${e.browserValue.replace(/\W/g,"")}`;t.classList.add(A),t.setAttribute("stroke",e.browserValue),n[A]=e}}));const a=qi().serializeToString(A);return{colors:n,svg:a}},OA=t=>{if(t.cachedObjectURL&&!t._renderingConfiguration?.omitCachedFields)return(0,i.jsx)(Fi,{id:t.id,src:t.cachedObjectURL,x:t.x,y:t.y,width:t.width,height:t.height,rotation:t.rotation,preserveAspectRatio:"none",immutable:t.immutable,mask:t.stepName?void 0:t.mask});const e=t.rotation||0,A=wi(e),n=Math.cos(A),a=-Math.sin(A),r=`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${n}, ${-a}, ${a}, ${n}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n `;if(!t.svg)throw new Error(`Illustration element ${t.id} (stepName ${t.stepName}) lacked svg from src ${t.src} at render time.`);return(0,i.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,i.jsx)("g",{transform:r,dangerouslySetInnerHTML:{__html:GA(t.svg,t.width,t.height,t.colors,t._renderingConfiguration?.spotColors)}})})};class JA{constructor(){this.id=Te(),this.stateCallbacks=[],this.prevCommands=[],this.nextCommands=[]}registerStateCallback(t){this.stateCallbacks.push(t)}unregisterStateCallback(t){this.stateCallbacks.filter((e=>e!==t))}getState(){return this.state}runStateCallbacks(){this.stateCallbacks.forEach((t=>t()))}apply(t,e){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);this.state=this.commandReducer(this.state,t),this.runStateCallbacks(),this.nextCommands=[],e||this.prevCommands.push(t)}undo(){if(!this.state)return;const t=this.prevCommands.pop();if(!t)return;const e=t.undo();t.varying?this.state={...this.state,variation:e}:this.state={...this.state,transaction:e},this.nextCommands.push(t),this.runStateCallbacks()}redo(){if(!this.state)return;const t=this.nextCommands.pop();t&&(this.state=this.commandReducer(this.state,t),this.runStateCallbacks(),this.prevCommands.push(t))}flattenSequence(t,e){const i=this.prevCommands.filter((e=>e.sequenceId===t)).pop();i&&(this.prevCommands=this.prevCommands.filter((e=>e.sequenceId!==t)),i?.overrideOldState(e),this.prevCommands.push(i))}getLayoutById(t){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const e=this.state.transaction?.layouts?.[t],i=this.state.variation?.layouts?.[t],A=e?.layout||i?.layout;if(!A)throw new Error(`No layout: ${t}`);const n=[...e?.elements||[],...i?.elements||[]];return this.getLayoutDataWithState(A,n)}getAllLayouts(){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const t=[...Object.keys(this.state.transaction?.layouts),...Object.keys(this.state.variation?.layouts||{})];return[...new Set(t)].map((t=>this.getLayoutById(t)))}getLayoutDataWithState(t,e){return{layoutState:{layout:t,elements:e},getComponentWithProps:i=>zA(t,e,i)}}initialize(t,e){if(e)return void(this.state={transaction:e});let i={serializableWorkflow:{steps:[]},layouts:{}};t.forEach((t=>{i=new nn(t).apply(i)})),this.runStateCallbacks(),this.state={transaction:i}}commandReducer(t,e){if(e.varying){const i={layouts:{},serializableWorkflow:{steps:[]},...t.variation};return{...t,variation:e.apply(i)}}{const i=t.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...t,transaction:e.apply(i)}}}}const LA=t=>"image"===t.type?(0,i.jsx)(Fi,{...t},t.id):"frame"===t.type?(0,i.jsx)(Yi,{...t},t.id):"illustration"===t.type?(0,i.jsx)(OA,{...t},t.id):"textbox"===t.type?(0,i.jsx)(YA,{...t},t.id):null,zA=(t,e,A)=>{const n=A.renderingConfiguration,a=n?.removeExcludedElements?e.filter((t=>!t.excludeFromExport)):e;return(0,i.jsx)(gi,{preserveAspectRatio:void 0,elements:a,backgroundColor:t.transparentBackground?void 0:"white",width:A.width||t.width,height:A.height||t.height,viewBox:n?.region?{x:n.region.left,y:n.region.top,width:n.region.width,height:n.region.height}:{x:0,y:0,width:t.width,height:t.height},configuration:n,outlineArea:A.outlineArea,maxHeight:A.maxHeight,maxWidth:A.maxWidth,position:A.position,borderRadius:A.borderRadius,outlineColor:A.outlineColor})};function jA(t){return t.sort(((t,e)=>{const i=t.layer||0,A=e.layer||0;if(i<A)return-1;if(i>A)return 1;const n=t.layerIndex||0,a=e.layerIndex||0;return n<a?-1:n>a?1:0}))}class VA extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,VA.prototype)}}const KA=(t,e)=>WA(t,e).elements.find((e=>e.id===t)),WA=(t,e)=>{const i=Object.values(e).find((e=>e.elements.some((e=>e.id===t))));if(!i)throw new VA;return i},XA=(t,e)=>{const i=jA([...e.elements.filter((e=>e.id!==t.id)),t]);return{layout:e.layout,elements:i,modificationID:Te()}},qA=async(t,e)=>{const i=[...Object.keys(t.layouts),...Object.keys(e?.layouts||{})],A=[...new Set(i)];for(let i=0;i<A.length;i++){const n=A[i],a=t.layouts[n],r=e?.layouts[n],s=a||r;await Promise.all(s.elements.map((async t=>{if("illustration"===t.type){const e=t;if(e.src&&!e.svg){const t=await Wi(e.src),i=await TA(t);e.svg=GA(i.svg,e.width,e.height,e.colors)}}isNaN(t.x)&&(t.x=0),isNaN(t.y)&&(t.y=0),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),isNaN(t.rotation)&&(t.rotation=0)})))}};class ZA{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(t){this.oldState=t}}class $A extends ZA{constructor(t){super(),this.serializableWorkflow=t}apply(t){return this.oldState=t,{...t,serializableWorkflow:this.serializableWorkflow}}}class _A extends ZA{constructor(t,e,i){super(),this.id=t,this.x=e,this.y=i}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,x:this.x,y:this.y},A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class tn extends ZA{constructor(t,e){super(),this.id=t,this.angle=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,rotation:this.angle},A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class en extends ZA{constructor(t,e,i){super(),this.id=t,this.width=Math.abs(e),this.height=Math.abs(i)}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;let i={...e,width:this.width,height:this.height};if("frame"===e.type){const t=i;t.scaleX=t.scaleX*this.width/e.width,t.scaleY=t.scaleY*this.height/e.height}else if("textbox"===e.type){const t=i,A=(t.algorithm&&t.algorithm!==We.Autosize?t.input:t.text)??"";i=xA(t,A,e)}const A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class An extends ZA{constructor(t){super(),this.commands=t}apply(t){return this.oldState=t,this.commands.reduce(((t,e)=>e.apply(t)),t)}}class nn extends ZA{constructor(t){super(),this.layout=t}apply(t){return this.oldState=t,{...t,layouts:{...t.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:Te()}}}}}class an extends ZA{constructor(t){super(),this.panelName=t}apply(t){this.oldState=t;const e=Object.values(t.layouts).map((t=>{const e=t.layout.panelId===this.panelName;return{...t,elements:e?[]:[...t.elements],modificationID:Te()}})),i={};return e.forEach((t=>{i[t.layout.id]=t})),{...t,layouts:i}}}class rn extends ZA{constructor(t,e){super(),this.element=t,this.layout=e}apply(t){this.oldState=t,t.layouts[this.layout.id]||(t.layouts[this.layout.id]={layout:this.layout,elements:[],modificationID:""});const e=t.layouts[this.layout.id].elements;if(e.find((t=>t.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===e.length){const i=[...e,this.element];return void 0===this.element.layerIndex&&(this.element.layerIndex=this.assignIndex(this.element,i)),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:i,modificationID:Te()}}}}const i=e[e.length-1],A=i.productOverlay?i:null;let n;if(A&&e.pop(),null!==this.element.layerIndex&&void 0!==this.element.layerIndex)n=[...e,this.element].sort(((t,e)=>void 0!==t.layerIndex&&void 0!==e.layerIndex?t.layerIndex-e.layerIndex:0));else{const t=this.assignIndex(this.element,e);this.element.layerIndex=void 0!==t?t:0,n=[...e,this.element]}return A&&n.push(A),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:n,modificationID:Te()}}}}assignIndex(t,e){if(0===e.length)return 0;const i=e.filter((e=>(e.layer||0)===(t.layer||0))).sort(((t,e)=>(t.layerIndex||0)-(e.layerIndex||0)))[e.length-1]?.layerIndex;return void 0!==i?i+1:0}}class sn extends ZA{constructor(t){super(),this.id=t}apply(t){this.oldState=t;let e=!1;const i=Object.values(t.layouts).map((t=>(t.elements.filter((t=>t.id!==this.id)).length!==t.elements.length&&(e=!0),{...t,elements:t.elements.filter((t=>t.id!==this.id)),modificationID:Te()})));e||console.log(`Failed to delete element ${this.id}`);const A={};return i.forEach((t=>{A[t.layout.id]=t})),{...t,layouts:A}}}class on extends ZA{constructor(t,i){super(),this.el=F(e)(t),this.layout=i,this.el.id=Te(),this.el.x+=5,this.el.y+=5}apply(t){return this.oldState=t,new rn(this.el,this.layout).apply(t)}}class cn extends ZA{constructor(t,e,i){super(),this.id=t,this.color=e,this.textFillSpotColor=i}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor,textFillImage:void 0},A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class ln extends ZA{constructor(t,e){super(),this.id=t,this.imageFill=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,textFillImage:this.imageFill},A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class gn extends ZA{constructor(t,e){super(),this.id=t,this.size=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,fontSize:this.size},A=WA(e.id,Object.values(t.layouts)),n=(e.algorithm&&e.algorithm!==We.Autosize?e.input:e.text)??"",a=XA(xA(i,n),A);return{...t,layouts:{...t.layouts,[A.layout.id]:a}}}}class hn extends ZA{constructor(t,e){super(),this.id=t,this.algorithm=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,algorithm:this.algorithm},A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class dn extends ZA{constructor(t,e){super(),this.id=t,this.fontData=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,fontData:this.fontData},A=WA(e.id,Object.values(t.layouts)),n=(e.algorithm&&e.algorithm!==We.Autosize?e.input:e.text)??"",a=XA(xA(i,n),A);return{...t,layouts:{...t.layouts,[A.layout.id]:a}}}}class un extends ZA{constructor(t,e){super(),this.id=t,this.align=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,align:this.align},A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class wn extends ZA{constructor(t,e,i){super(),this.id=t,this.imageData=e,this.offsets=i}apply(t){this.oldState=t;const e=WA(this.id,Object.values(t.layouts)),i=e.elements.findIndex((t=>t.id===this.id)),A=e.elements[i].pattern,n=[...e.elements];n.splice(i,1,{...e.elements[i],pattern:{...A,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={...e,elements:n,modificationID:Te()};return{...t,layouts:{...t.layouts,[e.layout.id]:a}}}}class Bn extends ZA{constructor(t,e){super(),this.id=t,this.text=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i=WA(e.id,Object.values(t.layouts)),A=XA(xA(e,this.text,e),i);return{...t,layouts:{...t.layouts,[i.layout.id]:A}}}}class pn extends ZA{constructor(t,e,i){super(),this.id=t,this.className=e,this.fill=i}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i=e.colors||{},A=i[this.className];i[this.className]={browserValue:this.fill,spotColor:A?.spotColor};const n={...e,colors:i},a=WA(e.id,Object.values(t.layouts)),r=XA(n,a);return{...t,layouts:{...t.layouts,[a.layout.id]:r}}}}class En extends ZA{constructor(t,e,i){super(),this.id=t,this.svgBody=e,this.objectURL=i}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,svg:this.svgBody,cachedObjectURL:this.objectURL},A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class mn extends ZA{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!KA(this.id,Object.values(t.layouts)).id)throw new VA;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const i=e.elements.findIndex((t=>t.id===this.id));e.elements.push(e.elements.splice(i,1)[0]);const A=[...e.elements];return A.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:A,modificationID:Te()}}}}}class fn extends ZA{constructor(t){super(),this.id=t}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!i)throw new Error("Layout missing from state!");const A=i.elements.findIndex((t=>t.id===this.id));i.elements.splice(A,1),i.elements.unshift(e);const n=[...i.elements],a=n.splice(A,1)[0];return n.splice(A,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[i.layout.id]:{...t.layouts[i.layout.id],elements:n,modificationID:Te()}}}}}class Cn extends ZA{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!KA(this.id,Object.values(t.layouts)).id)throw new VA;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const i=e.elements.findIndex((t=>t.id===this.id)),A=i+1,n=[...e.elements],a=n.splice(i,1)[0];return n.splice(A,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:n,modificationID:Te()}}}}}class Qn extends ZA{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!KA(this.id,Object.values(t.layouts)).id)throw new VA;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const i=e.elements.findIndex((t=>t.id===this.id)),A=i-1,n=[...e.elements],a=n.splice(i,1)[0];return n.splice(A,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:n,modificationID:Te()}}}}}class yn extends ZA{constructor(t,e){super(),this.id=t,this.value=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!i)throw new Error("Layout missing from state!");return{...t,layouts:{...t.layouts,[i.layout.id]:XA({...e,layer:this.value},i)}}}}var Dn={};He(Dn,"patternImageDataCache",(()=>bn)),He(Dn,"frameDataCache",(()=>Yn)),He(Dn,"generateFrameSVG",(()=>Pn)),He(Dn,"generateDefaultRectangleFrameSvg",(()=>Nn)),He(Dn,"getVariant",(()=>Rn)),He(Dn,"getFrameData",(()=>kn)),He(Dn,"calculateOffsets",(()=>Hn)),He(Dn,"getPatternImageData",(()=>Un)),He(Dn,"GetSVGDimensions",(()=>Gn)),He(Dn,"svgStringDimensions",(()=>Tn));var In={};He(In,"getExifOrientation",(()=>vn)),He(In,"canvasDims",(()=>Mn)),He(In,"getAttributesFromArrayBuffer",(()=>Sn));let xn=null;const vn=t=>new Promise((e=>{const i=eA(t);(0,o.fromBuffer)(t).then((t=>{const A=t?.mime;if("image/jpeg"!==A)return e(1);(new(0,h.ExifImage)).loadImage(i,((t,i)=>e(t?1:i.image.Orientation||1)))}))})),Mn=t=>{const e=8192,i=t.naturalWidth/t.naturalHeight;return t.naturalHeight<=e&&t.naturalWidth<=e?[t.naturalWidth,t.naturalHeight]:t.naturalHeight>t.naturalWidth?[i*e,e]:[e,e/i]},Sn=async t=>{const e=await(async t=>{const e=await _i(t),i=await(0,g.loadImage)(e),[A,n]=Mn(i),a=await(async()=>{if(null!==xn)return!xn;const t=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return xn=2===t.width&&3===t.height,!xn})();if(!a){const t=(0,g.createCanvas)(A,n);return t.getContext("2d").drawImage(i,0,0,A,n),t}const r=await vn(t),[s,o]=r>4?[n,A]:[A,n],c=(0,g.createCanvas)(s,o),l=c.getContext("2d");switch(r){case 2:l.translate(s,0),l.scale(-1,1);break;case 3:l.translate(s,o),l.rotate(Math.PI);break;case 4:l.translate(0,o),l.scale(1,-1);break;case 5:l.rotate(-.5*Math.PI),l.scale(-1,1);break;case 6:l.rotate(-.5*Math.PI),l.translate(-s,0);break;case 7:l.rotate(-.5*Math.PI),l.translate(-s,o),l.scale(1,-1);break;case 8:l.rotate(.5*Math.PI),l.translate(0,-o)}return l.drawImage(i,0,0,s,o),c})(t);return"image/jpeg"===(await(0,o.fromBuffer)(t))?.mime?{dataUrl:e.toDataURL("image/jpeg",1),height:e.height,width:e.width}:{dataUrl:e.toDataURL(),height:e.height,width:e.width}};He({},"getDefaultVariant",(()=>Fn));const Fn=t=>{const e=t.variants;if(e){if(1===e.length)return e[0];if(void 0!==t.defaultVariant)return e.find((e=>e.id===t.defaultVariant))}},bn=new Map,Yn=new Map,Pn=async(t,e)=>{if(!e){if(!t)throw new Error("No region or src supplied. Cannot construct frame!");return Nn(t)}return Wi(e)},Nn=t=>{const e=t.width,i=e/t.height,A=Math.max(e,512),n=A/i;return`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${A} ${n}'>\n <path id="target-path" d='M0 0 h ${A} v ${n} h ${-A} Z' />\n </svg>\n `},Rn=(t,e)=>{if(!e)return;const i=e.variants?.find((e=>e.id===t.frameVariantId))||Fn(e);if(!i)throw new Error(`No variant with ID: ${t.frameVariantId}`);if(!i.asset)throw new Error(`No asset for variant with ID: ${t.frameVariantId}`);return i},kn=async t=>{const e=Vi().parseFromString(t,"image/svg+xml"),i=e.querySelector("svg");if(!i)throw new Error("Malformed frame SVG: <svg> tag not found");const A=i.getAttribute("viewBox");if(!A)throw new Error("SVG missing viewBox.");const n=A.split(" "),a=parseFloat(n[3])||1,r=parseFloat(n[2])||1,s=e.getElementById("target-path"),o=e.getElementsByClassName("st0").item(0);if(s){const t=s.getAttribute("d");if(!t)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const e={path:t,width:r,height:a};return Yn.set(t,e),e}if(o){const t=o.getAttribute("d");if(!t)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const e={path:t,width:r,height:a};return Yn.set(t,e),e}throw new Error("Malformed frame SVG")},Hn=(t,e,i)=>{const A=e.width>=e.height,n=t.width>=t.height,a=e.width/2,r=e.height/2,s=(A?e.height:e.width)/(n?t.width:t.height),o=i?.scale||s,c=a-t.width/2*o,l=i?.left||c,g=r-t.height/2*o;return{x:l,y:i?.top||g,zoom:o}},Un=async t=>{if(bn.has(t))return bn.get(t);if(t.endsWith("svg")){const e=await Gn(t),i=e.width,A=e.height,n={src:t,width:i,height:A,aspect:i/A};return bn.set(t,n),n}{const e=await Ki(t),i=await Sn(e),A={src:t,width:i.width,height:i.height,aspect:i.width/i.height};return bn.set(t,A),A}},Gn=async t=>{const e=await Wi(t);return Tn(e)},Tn=t=>{const e=Vi().parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)throw new Error("No svg tag found, this svg must be malformed!");const i=e.getAttribute("viewBox"),A=e.getAttribute("width"),n=e.getAttribute("height"),a=i?i?.split(" ").map((t=>Number(t))):[0,0,Number(A),Number(n)];if(!a)throw new Error("No viewbox or width/height values detected on SVG file!");return{width:a[2],height:a[3]}};var On={};He(On,"determineCorrectFontSizeAndLines",(()=>Ln)),He(On,"determineCorrectTextboxRegion",(()=>zn));const Jn=(t,e,i,A,n)=>{if(e.some((t=>null==t)))throw new Error(`Failed to autosize lines: ${e.join(", ")}`);let a=e.map((t=>t.split("\n"))).flat(),r=a.length,s=a.map((t=>EA(t,A,n)));const o=n.getApproximateHeight()*A;let c=!0;for(;c;){if(o+(r-1)*i>t.height)return[null,null];const e=Math.max(...s);if(e<=t.width)return[a,e];const l=s.reduce(((t,e,i,A)=>e>A[t]?i:t),0),g=a[l];let h=!1,d=g.length;for(;!h&&d>-1;){d=g.lastIndexOf(" ",d-1);const e=[g.slice(0,d),g.slice(d+1)],i=e.map((t=>EA(t,A,n)));i[0]<=t.width&&(a=[...a.slice(0,l),...e,...a.slice(l+1)],s=[...s.slice(0,l),...i,...s.slice(l+1)],r+=1,h=!0)}h||(c=!1)}return[null,null]},Ln=(t,e,i,A,n)=>{let a,r;const s=cA(e),o=s.getFont();if(n.size){const e=t/o.unitsPerEm;return[a,r]=Jn(i,A,t,e,s),[n.size,a,r]}let c=6-pA;if(A.length>0){let t=A,e=0;for(;(!n.maxSize||c<=n.maxSize)&&t;)c+=pA,e=c/o.unitsPerEm,[t,r]=Jn(i,A,c,e,s)}c>6&&(c-=pA),n.minSize&&c<n.minSize&&(c=n.minSize);const l=c/o.unitsPerEm;return[a,r]=Jn(i,A,c,l,s),[c,a,r]},zn=(t,e,i,A,n)=>{let a={...t},r={...t},[s,o,c]=Ln(i,e,r,A,{size:0,minSize:i,maxSize:i});var l,g;return c&&c<a.width&&(r.width=c,"left"===n?(r.left+=Math.sin(a.rotation*Math.PI/360)*(a.width-c),r.top+=Math.sin(a.rotation*Math.PI/180)*(c-a.width)/2):r.left+="right"===n?a.width-c:(a.width-c)/2,[s,o]=Ln(i,e,r,A,{size:i}),s===i&&o&&(l=A,g=o,l.map(((t,e)=>[t,g[e]]))).every((([t,e])=>t===e))&&(a=r)),a};var jn={};He(jn,"svgObjectURL",(()=>Wn)),He(jn,"LayoutElementFactory",(()=>qn));const Vn=(t,e)=>{const i=t.layoutState.elements.filter((t=>t.layer===e)),A=Math.max(...i.map((t=>t.layerIndex)).filter((t=>void 0!==t)));return Math.max(A,0)+1},Kn=async t=>new Promise((e=>{Wi(t).then((t=>{e(t)})).catch((t=>console.error(t)))})),Wn=async t=>{const e=Vi().parseFromString(t,"image/svg+xml").firstElementChild;if(!e)throw new Error("Failed to read SVG");const i=(new XMLSerializer).serializeToString(e),A=document.createElement("canvas"),n=A.getContext("2d"),a=await ke.from(n,i,{anonymousCrossOrigin:!0,ignoreDimensions:!1}),r=e.getAttribute("width"),s=e.getAttribute("height"),o=2048;if(s&&r){const t=parseFloat(s),e=parseFloat(r)/t;e>1?a.resize(o,o/e):a.resize(o*e,o)}else a.resize(o,o);return await a.render(),await(async t=>new Promise(((e,i)=>{try{if(!URL||!URL.createObjectURL)throw new Error("Environment incapable of generating ObjectURL");t.toBlob((i=>{if(!i){if(0===t.width||0===t.height)throw new Error(`Canvas dimensions are invalid (${t.width},${t.height})`);if(t.width*t.height>=268435456)throw new Error(`Canvas dimensions exceed device limit (${t.width},${t.height})`);throw new Error("Couldn't generate object URL for Illustration, the blob was undefined!")}e(URL.createObjectURL(i))}))}catch(t){i(t)}})))(A)},Xn=async(t,e,i,A)=>{const n=t.layoutState.layout.useEditableArea&&t.layoutState.layout.editableArea||{width:t.layoutState.layout.width,height:t.layoutState.layout.height,x:0,y:0},a=n.width<n.height?n.width:n.height,r=t.layoutState.layout.useEditableArea?a/1.3:a/2,s={top:n.y+n.height/2-r/2,left:n.x+n.width/2-r/2,width:r,height:r,rotation:0,panelId:t.layoutState.layout.panelId};if(i&&e===ze.Illustration){const t=await TA(await Kn(i)),e=Vi().parseFromString(t.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!e)throw new Error("SVG missing viewBox.");const A=s.height,n=e.split(" "),a=(parseFloat(n[2])||1)/(parseFloat(n[3])||1);s.height=s.width/a,s.top+=(A-s.height)/2}if(i&&e===ze.Image){const t=s.height,e=await Ki(i),A=await Sn(e),n=A.width/A.height;s.height=s.width/n,s.top+=(t-s.height)/2}if(i&&e===ze.Textbox&&A?.text&&A?.fontScale){const t={assetUrl:i,name:(await sA(i)).names.fullName.en},e=cA(t),a=EA(A.text,A?.fontScale,e);s.width=Math.min(a,.85*n.width),s.left=n.x+n.width/2-s.width/2}return s};class qn{static async getFrame(t,e){const i=await Pn(e.region,e.src),A=await kn(i),n=e.region||await Xn(t,ze.Frame);return{id:Te(),x:n.left,y:n.top,width:n.width,height:n.height,layer:n.layer||0,layerIndex:n.layerIndex||Vn(t,n.layer||0),rotation:n.rotation,scaleX:n.width/A.width,scaleY:n.height/A.height,path:A.path,dataWidth:A.width,dataHeight:A.height,type:ze.Frame,disablePlaceholder:e.configuration.disablePlaceholder,focalBlur:e.configuration.focalBlur,focalBlurStrength:e.configuration.focalBlurStrength,focalBlurRadius:e.configuration.focalBlurRadius,forceImageCover:e.configuration.forceImageCover,pattern:void 0,immutable:n.immutable}}static async getImage(t,e){const i=e.region||await Xn(t,ze.Image,e.src);return{id:Te(),src:e.src,type:ze.Image,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||Vn(t,i.layer||0),immutable:i.immutable,preserveAspectRatio:"none"}}static async getTextbox(t,e){const{configuration:i,fontSrc:A,designInputStep:n}=e,a=await sA(A),r={assetUrl:A,name:a.names.fullName.en},s=n?.text||i.defaultText||"",o=i.replaceableText?i.replaceableText.replace("{{}}",s):s,c=QA(o,{vertical:i.vertical,uppercase:i.uppercase}),l=e.region||await Xn(t,ze.Textbox,A,{text:c,fontScale:i.size?i.size/a.unitsPerEm:void 0}),g=xA({id:Te(),type:ze.Textbox,x:l.left,y:l.top,width:l.width,height:l.height,align:DA(i.textAlign,i.vertical),curved:i.curved,fill:n?.color||i.colour||"#000000",fontData:r,layer:l.layer||0,layerIndex:l.layerIndex||Vn(t,l.layer||0),paths:i.paths,rotation:l.rotation,vertical:i.vertical,verticalAlign:i.verticalAlign||"middle",algorithm:We.Traditional,fontSize:i.size||Math.max(Math.round(.025*l.height),1),text:c,input:s},c),h=BA({...l,height:g.height},r,g.fontSize,g?.text?.split("\n")||[],g.align);return{...g,x:h.left,y:h.top+(l.height-h.height)/2,width:h.width,height:h.height}}static async getShape(t,e){const i=`\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="${e.color}"\n />\n </svg>\n `,A={};A["spiff-fill-shape"]={browserValue:e.color};const n=e.region||await Xn(t,ze.Illustration),a=Te();return{stepRegion:e.region,colors:A,id:a,svg:i,type:ze.Illustration,y:n.top,x:n.left,rotation:n.rotation,width:n.width,height:n.height,layer:n.layer||0,layerIndex:n.layerIndex||Vn(t,n.layer||0),immutable:n.immutable}}static async getIllustration(t,e){const i=e.region||await Xn(t,ze.Illustration,e.src),A=await TA(await Kn(e.src)),n=await Wn(A.svg),a=Te();return{cachedObjectURL:n,stepRegion:e.region,colors:A.colors,id:a,src:e.src,svg:A.svg,type:ze.Illustration,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||Vn(t,i.layer||0),immutable:i.immutable}}}function Zn(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class $n extends Error{constructor(t){super(t),this.name=this.constructor.name}}class _n extends $n{constructor(t){super(`ConfigurationError - ${t}`)}}class ta extends _n{constructor(t){super(`Option not Configured: ${t.stepTitle}`),Zn(this,"optionId",void 0),this.optionId=t?.optionId||"N/A"}}class ea extends _n{constructor(t){super(`Panel not Found: ${t.panelId}`),Zn(this,"panelId",void 0),this.panelId=t?.panelId||"N/A"}}class ia extends _n{constructor(t){super(`Asset not found for variant: ${t.name}`),Zn(this,"variant",void 0),this.variant=t}}class Aa extends _n{constructor(t){super(`Resource not found for asset: ${t.name}`),Zn(this,"asset",void 0),this.asset=t}}class na extends _n{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),Zn(this,"step",void 0),this.step=t}}class aa extends $n{constructor(t){super(`ImplementationError - ${t}`)}}class ra extends aa{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class sa extends aa{constructor(t){super(`Parsing Error: ${t}`)}}class oa extends aa{constructor(t){super(`Client Error: ${t}`)}}class ca extends aa{constructor(t){super(`Resource Generation Failed: ${t}`)}}function la(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ga{get(t){return localStorage.getItem(t)||void 0}set(t,e){localStorage.setItem(t,e)}remove(t){localStorage.removeItem(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const i=JSON.stringify([...e.entries()]);this.set(t,i)}}class ha{constructor(){la(this,"storage",new Map)}get(t){return this.storage.get(t)||void 0}set(t,e){this.storage.set(t,e)}remove(t){this.storage.delete(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const i=JSON.stringify([...e.entries()]);this.set(t,i)}}const da=(()=>{try{return localStorage?new ga:new ha}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new ha}})();function ua(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const wa=new class{constructor(){ua(this,"defaultServerUrl","https://api.spiff.com.au"),ua(this,"defaultServicesApiUrl","https://services.spiff.com.au"),ua(this,"defaultHubUrl","https://hub.spiff.com.au"),ua(this,"serverUrl",void 0),ua(this,"servicesApiUrl",void 0),ua(this,"hubUrl",void 0),ua(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(t){this.serverUrl=t,this.serverUrlCallbacks.forEach((t=>t()))}setServicesApiUrl(t){this.servicesApiUrl=t}setHubUrl(t){this.hubUrl=t}addServerUrlCallback(t){this.serverUrlCallbacks.push(t)}};function Ba(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let pa;const Ea=t=>{pa=t};let ma;const fa=t=>{ma=t};let Ca;const Qa=t=>{Ca=t};let ya;const Da=new class{constructor(){Ba(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),wa.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const e=(0,t.createHttpLink)({uri:`${wa.getServerUrl()}/graphql`,fetch:f.fetch}),i=(0,E.setContext)((async(t,e)=>{const{headers:i}=e,A=i||{},n=await(async()=>{const t={applicationKey:ya,bundleOwnerId:ma,customerToken:Ca,transactionOwnerId:pa};return"undefined"!=typeof window&&(window.location.href.includes("/workflows/product/")||window.location.href.includes("hub=true"))?{...await new Promise((t=>{const e=wa.getHubUrl(),i=A=>{A.origin===e&&(window.removeEventListener("message",i),t(A.data))};window.parent!==window&&(window.addEventListener("message",i,!1),window.parent.postMessage("ready",e))})),...t}:t})(),a=e.bearer??n.bearer,r=e.partnerId??n.partnerId,s=e.activeIntegration??n.activeIntegration,o=e.transactionOwnerId??n.transactionOwnerId,c=e.customerToken??n.customerToken,l=e.applicationKey??n.applicationKey,g=e.bundleOwnerId??n.bundleOwnerId;return a&&(A.Authorization=`Bearer ${a}`),r&&(A.partnerId=r),s&&(A.activeIntegration=s),o&&(A.transactionOwnerId=o),c&&(A.customerToken=c),l&&(A["X-Application-Key"]=l),g&&(A.bundleOwnerId=g),{headers:A}})),A=(0,m.onError)((({operation:t,graphQLErrors:e,networkError:i})=>{(e||[]).forEach((({message:e,locations:i,path:A})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+t.operationName),console.log("Query:"+JSON.stringify(t.query)),console.log(`Message: ${e}, Location: ${JSON.stringify(i,null,2)}, Path: ${A}`),console.log("Variables:"+JSON.stringify(t.variables))})),i&&console.log("GraphQL Network error")}));const n=new(0,t.InMemoryCache)({addTypename:!1,typePolicies:{Transaction:{fields:{bulkEmailAddress:{read:(t=null)=>t,merge:(t,e)=>e||t||null},transactionOwnerId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},customLogoLink:{read:(t=null)=>t,merge:(t,e)=>e||t||null},workflowFooterLogoLink:{read:(t=null)=>t,merge:(t,e)=>e||t||null},workflowState:{read:(t=null)=>t,merge:(t,e)=>e||t||null},bulkSourceUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalDesignProductId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalDesignProductVariantId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalCartProductId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalCartProductVariantId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},lastSyncedAt:{read:(t=null)=>t,merge:(t,e)=>e||t||null},lineItem:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}},WorkflowProduct:{fields:{isPresent:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}},Product:{fields:{imageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},overlayImageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},preloadImageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},weight:{read:(t=null)=>t,merge:(t,e)=>e||t||null},conversionConfiguration:{read:(t=null)=>t,merge:(t,e)=>e||t||null},bulkConfiguration:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}}}});return new(0,t.ApolloClient)({link:(0,t.from)([A,i,e]),cache:n,name:"Core"})}};function Ia(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const xa=t.gql`
1
+ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/jsx-runtime"),A=require("react"),n=require("opentype.js"),a=require("buffer"),r=require("axios"),s=require("https"),o=require("file-type"),c=require("util"),l=require("css"),g=require("canvas"),h=require("exif"),d=require("process"),u=require("raf"),w=require("rgbcolor"),B=require("svg-pathdata"),p=require("stackblur-canvas"),E=require("@apollo/client/link/context"),m=require("@apollo/client/link/error"),f=require("cross-fetch"),C=require("lodash.isequal"),Q=require("react-dom/server"),y=require("qrcode"),D=require("svg-path-bbox"),I=require("lodash.debounce"),x=require("unicode-default-word-boundary"),v=require("@apollo/client/core");function M(t,e,i,A){Object.defineProperty(t,e,{get:i,set:A,enumerable:!0,configurable:!0})}var S="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function F(t){return t&&t.__esModule?t.default:t}M(module.exports,"SpiffCommerceClient",(()=>Kc)),M(module.exports,"CommandContext",(()=>JA)),M(module.exports,"spiffCoreConfiguration",(()=>wa)),M(module.exports,"PromiseQueue",(()=>Lr)),M(module.exports,"QueueablePromise",(()=>Jr)),M(module.exports,"MockWorkflowManager",(()=>Xc)),M(module.exports,"InformationMessageType",(()=>Eo)),M(module.exports,"StepHandle",(()=>Io)),M(module.exports,"TextStepHandle",(()=>ko)),M(module.exports,"FrameStepHandle",(()=>_c)),M(module.exports,"BulkStepHandle",(()=>So)),M(module.exports,"ShapeStepHandle",(()=>Ro)),M(module.exports,"IllustrationStepHandle",(()=>Fo)),M(module.exports,"MaterialStepHandle",(()=>bo)),M(module.exports,"ModelStepHandle",(()=>Yo)),M(module.exports,"PictureStepHandle",(()=>Po)),M(module.exports,"QuestionStepHandle",(()=>No)),M(module.exports,"BulkPriceCalculationStrategy",(()=>_a)),M(module.exports,"Variant",(()=>yo)),M(module.exports,"WorkflowExperienceImpl",(()=>Wo)),M(module.exports,"OptionNotFoundError",(()=>ta)),M(module.exports,"LayoutNotFoundError",(()=>ea)),M(module.exports,"AssetNotFoundError",(()=>ia)),M(module.exports,"ResourceNotFoundError",(()=>Aa)),M(module.exports,"MisconfigurationError",(()=>na)),M(module.exports,"ParseError",(()=>sa)),M(module.exports,"UnhandledBehaviorError",(()=>ra)),M(module.exports,"assetService",(()=>Na)),M(module.exports,"designService",(()=>Vo)),M(module.exports,"createDesign",(()=>Lo)),M(module.exports,"optionService",(()=>Ua)),M(module.exports,"persistenceService",(()=>da)),M(module.exports,"graphQlManager",(()=>Da)),M(module.exports,"toast",(()=>cr)),M(module.exports,"FrameService",(()=>Xs)),M(module.exports,"getBoundedOffsets",(()=>Ks)),M(module.exports,"frameStepService",(()=>Ao)),M(module.exports,"modelStepService",(()=>ro)),M(module.exports,"materialStepService",(()=>ao)),M(module.exports,"shapeStepService",(()=>lo)),M(module.exports,"questionStepService",(()=>co)),M(module.exports,"digitalContentStepService",(()=>eo)),M(module.exports,"moduleStepService",(()=>so)),M(module.exports,"pictureStepService",(()=>oo)),M(module.exports,"textStepService",(()=>Bo)),M(module.exports,"illustrationStepService",(()=>no)),M(module.exports,"ProductCameraRig",(()=>Za)),M(module.exports,"FrameStep",(()=>Zc)),M(module.exports,"ConversionLocation",(()=>er)),M(module.exports,"ConversionDataType",(()=>Ar)),M(module.exports,"getWorkflow",(()=>jc)),M(module.exports,"shortenUrl",(()=>$s)),M(module.exports,"ObjectInput",(()=>Mc)),M(module.exports,"TextInput",(()=>Sc)),M(module.exports,"ObjectInputType",(()=>xc)),M(module.exports,"AssetType",(()=>ai)),M(module.exports,"BringForwardCommand",(()=>Cn)),M(module.exports,"BringToFrontCommand",(()=>mn)),M(module.exports,"BringToBackCommand",(()=>fn)),M(module.exports,"CanvasCommand",(()=>ZA)),M(module.exports,"CreateElementCommand",(()=>rn)),M(module.exports,"CreateLayoutCommand",(()=>nn)),M(module.exports,"DeleteElementCommand",(()=>sn)),M(module.exports,"FontAlignmentCommand",(()=>un)),M(module.exports,"FontColorCommand",(()=>cn)),M(module.exports,"FontSizeCommand",(()=>gn)),M(module.exports,"FontSourceCommand",(()=>dn)),M(module.exports,"GroupCommand",(()=>An)),M(module.exports,"LayoutElementFactory",(()=>qn)),M(module.exports,"LayoutElementType",(()=>ze)),M(module.exports,"MoveCommand",(()=>_A)),M(module.exports,"ResizeCommand",(()=>en)),M(module.exports,"RotateCommand",(()=>tn)),M(module.exports,"SendBackwardsCommand",(()=>Qn)),M(module.exports,"StakeholderType",(()=>ar)),M(module.exports,"StepAspectType",(()=>ci)),M(module.exports,"StepType",(()=>si)),M(module.exports,"TextChangeCommand",(()=>Bn)),M(module.exports,"UnitOfMeasurement",(()=>qe)),M(module.exports,"dataUrlFromExternalUrl",(()=>$i)),M(module.exports,"findElement",(()=>KA)),M(module.exports,"frameDataCache",(()=>Yn)),M(module.exports,"generate",(()=>Te)),M(module.exports,"getAxisAlignedBoundingBox",(()=>di)),M(module.exports,"generateSVGWithUnknownColors",(()=>TA)),M(module.exports,"getAttributesFromArrayBuffer",(()=>Sn)),M(module.exports,"rehydrateSerializedLayout",(()=>qA)),M(module.exports,"getFrameData",(()=>kn)),M(module.exports,"getSvgElement",(()=>zA)),M(module.exports,"loadFontFromDataUrl",(()=>oA)),M(module.exports,"loadFontFromExternalUrl",(()=>sA)),M(module.exports,"determineCorrectFontSizeAndLines",(()=>Ln)),M(module.exports,"patternImageDataCache",(()=>bn)),M(module.exports,"generateCommands",(()=>fs)),M(module.exports,"registerJSDOM",(()=>Ti)),M(module.exports,"minZoom",(()=>kr)),M(module.exports,"AdvancedEditor",(()=>Fs)),M(module.exports,"TransformWrapper",(()=>tl)),M(module.exports,"EditorCore",(()=>Ss)),M(module.exports,"useLayouts",(()=>Oa)),M(module.exports,"useEditorState",(()=>qa)),M(module.exports,"useEditorInteraction",(()=>Ur)),M(module.exports,"useShortcutCombination",(()=>Gr)),M(module.exports,"commandReducer",(()=>Va)),M(module.exports,"getDefaultState",(()=>ja)),M(module.exports,"CommandContextContext",(()=>Ga)),M(module.exports,"AdvancedEditorStateProvider",(()=>Wa)),M(module.exports,"AdvancedEditorContext",(()=>Ka)),M(module.exports,"UICommand",(()=>Xa)),M(module.exports,"EditorSubMenu",(()=>La)),M(module.exports,"ElementEventType",(()=>lr)),M(module.exports,"KeyEvent",(()=>hr)),M(module.exports,"gatherVaryingStepAspects",(()=>Gs));function b(t){return t.replace(/(?!\u3000)\s+/gm," ")}function Y(t){const e=t.match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm);return e?e.map(parseFloat):[]}const P=/^[A-Z-]+$/;function N(t){const e=/url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(t);return e&&(e[2]||e[3]||e[4])||""}const R=/(\[[^\]]+\])/g,k=/(#[^\s+>~.[:]+)/g,H=/(\.[^\s+>~.[:]+)/g,U=/(::[^\s+>~.[:]+|:first-line|:first-letter|:before|:after)/gi,G=/(:[\w-]+\([^)]*\))/gi,T=/(:[^\s+>~.[:]+)/g,O=/([^\s+>~.[:]+)/g;function J(t,e){const i=e.exec(t);return i?[t.replace(e," "),i.length]:[t,0]}const L=1e-8;function z(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))}function j(t,e){return(t[0]*e[0]+t[1]*e[1])/(z(t)*z(e))}function V(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(j(t,e))}function K(t){return t*t*t}function W(t){return 3*t*t*(1-t)}function X(t){return 3*t*(1-t)*(1-t)}function q(t){return(1-t)*(1-t)*(1-t)}function Z(t){return t*t}function $(t){return 2*t*(1-t)}function _(t){return(1-t)*(1-t)}function tt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class et{static empty(t){return new et(t,"EMPTY","")}split(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:" ";const{document:e,name:i}=this;return b(this.getString()).trim().split(t).map((t=>new et(e,i,t)))}hasValue(t){const e=this.value;return null!==e&&""!==e&&(t||0!==e)&&void 0!==e}isString(t){const{value:e}=this,i="string"==typeof e;return i&&t?t.test(e):i}isUrlDefinition(){return this.isString(/^url\(/)}isPixels(){if(!this.hasValue())return!1;const t=this.getString();switch(!0){case t.endsWith("px"):case/^[0-9]+$/.test(t):return!0;default:return!1}}setValue(t){return this.value=t,this}getValue(t){return void 0===t||this.hasValue()?this.value:t}getNumber(t){if(!this.hasValue())return void 0===t?0:parseFloat(t);const{value:e}=this;let i=parseFloat(e);return this.isString(/%$/)&&(i/=100),i}getString(t){return void 0===t||this.hasValue()?void 0===this.value?"":String(this.value):String(t)}getColor(t){let e=this.getString(t);return this.isNormalizedColor||(this.isNormalizedColor=!0,e=function(t){if(!t.startsWith("rgb"))return t;let e=3;return t.replace(/\d+(\.\d+)?/g,((t,i)=>e--&&i?String(Math.round(parseFloat(t))):t))}(e),this.value=e),e}getDpi(){return 96}getRem(){return this.document.rootEmSize}getEm(){return this.document.emSize}getUnits(){return this.getString().replace(/[0-9.-]/g,"")}getPixels(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.hasValue())return 0;const[i,A]="boolean"==typeof t?[void 0,t]:[t],{viewPort:n}=this.document.screen;switch(!0){case this.isString(/vmin$/):return this.getNumber()/100*Math.min(n.computeSize("x"),n.computeSize("y"));case this.isString(/vmax$/):return this.getNumber()/100*Math.max(n.computeSize("x"),n.computeSize("y"));case this.isString(/vw$/):return this.getNumber()/100*n.computeSize("x");case this.isString(/vh$/):return this.getNumber()/100*n.computeSize("y");case this.isString(/rem$/):return this.getNumber()*this.getRem();case this.isString(/em$/):return this.getNumber()*this.getEm();case this.isString(/ex$/):return this.getNumber()*this.getEm()/2;case this.isString(/px$/):return this.getNumber();case this.isString(/pt$/):return this.getNumber()*this.getDpi()*(1/72);case this.isString(/pc$/):return 15*this.getNumber();case this.isString(/cm$/):return this.getNumber()*this.getDpi()/2.54;case this.isString(/mm$/):return this.getNumber()*this.getDpi()/25.4;case this.isString(/in$/):return this.getNumber()*this.getDpi();case this.isString(/%$/)&&A:return this.getNumber()*this.getEm();case this.isString(/%$/):return this.getNumber()*n.computeSize(i);default:{const t=this.getNumber();return e&&t<1?t*n.computeSize(i):t}}}getMilliseconds(){return this.hasValue()?this.isString(/ms$/)?this.getNumber():1e3*this.getNumber():0}getRadians(){if(!this.hasValue())return 0;switch(!0){case this.isString(/deg$/):return this.getNumber()*(Math.PI/180);case this.isString(/grad$/):return this.getNumber()*(Math.PI/200);case this.isString(/rad$/):return this.getNumber();default:return this.getNumber()*(Math.PI/180)}}getDefinition(){const t=this.getString(),e=/#([^)'"]+)/.exec(t),i=(null==e?void 0:e[1])||t;return this.document.definitions[i]}getFillStyleDefinition(t,e){let i=this.getDefinition();if(!i)return null;if("function"==typeof i.createGradient&&"getBoundingBox"in t)return i.createGradient(this.document.ctx,t,e);if("function"==typeof i.createPattern){if(i.getHrefAttribute().hasValue()){const t=i.getAttribute("patternTransform");i=i.getHrefAttribute().getDefinition(),i&&t.hasValue()&&i.getAttribute("patternTransform",!0).setValue(t.value)}if(i)return i.createPattern(this.document.ctx,t,e)}return null}getTextBaseline(){if(!this.hasValue())return null;const t=this.getString();return et.textBaselineMapping[t]||null}addOpacity(t){let e=this.getColor();const i=e.length;let A=0;for(let t=0;t<i&&(","===e[t]&&A++,3!==A);t++);if(t.hasValue()&&this.isString()&&3!==A){const i=new(F(w))(e);i.ok&&(i.alpha=t.getNumber(),e=i.toRGBA())}return new et(this.document,this.name,e)}constructor(t,e,i){tt(this,"document",void 0),tt(this,"name",void 0),tt(this,"value",void 0),tt(this,"isNormalizedColor",void 0),this.document=t,this.name=e,this.value=i,this.isNormalizedColor=!1}}function it(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}tt(et,"textBaselineMapping",{baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"});class At{clear(){this.viewPorts=[]}setCurrent(t,e){this.viewPorts.push({width:t,height:e})}removeCurrent(){this.viewPorts.pop()}getRoot(){const[t]=this.viewPorts;return t||nt()}getCurrent(){const{viewPorts:t}=this,e=t[t.length-1];return e||nt()}get width(){return this.getCurrent().width}get height(){return this.getCurrent().height}computeSize(t){return"number"==typeof t?t:"x"===t?this.width:"y"===t?this.height:Math.sqrt(Math.pow(this.width,2)+Math.pow(this.height,2))/Math.sqrt(2)}constructor(){it(this,"viewPorts",[])}}function nt(){return{width:At.DEFAULT_VIEWPORT_WIDTH,height:At.DEFAULT_VIEWPORT_HEIGHT}}function at(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}it(At,"DEFAULT_VIEWPORT_WIDTH",800),it(At,"DEFAULT_VIEWPORT_HEIGHT",600);class rt{static parse(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const[i=e,A=e]=Y(t);return new rt(i,A)}static parseScale(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const[i=e,A=i]=Y(t);return new rt(i,A)}static parsePath(t){const e=Y(t),i=e.length,A=[];for(let t=0;t<i;t+=2)A.push(new rt(e[t],e[t+1]));return A}angleTo(t){return Math.atan2(t.y-this.y,t.x-this.x)}applyTransform(t){const{x:e,y:i}=this,A=e*t[0]+i*t[2]+t[4],n=e*t[1]+i*t[3]+t[5];this.x=A,this.y=n}constructor(t,e){at(this,"x",void 0),at(this,"y",void 0),this.x=t,this.y=e}}function st(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ot{isWorking(){return this.working}start(){if(this.working)return;const{screen:t,onClick:e,onMouseMove:i}=this,A=t.ctx.canvas;A.onclick=e,A.onmousemove=i,this.working=!0}stop(){if(!this.working)return;const t=this.screen.ctx.canvas;this.working=!1,t.onclick=null,t.onmousemove=null}hasEvents(){return this.working&&this.events.length>0}runEvents(){if(!this.working)return;const{screen:t,events:e,eventElements:i}=this,{style:A}=t.ctx.canvas;let n;A&&(A.cursor=""),e.forEach(((t,e)=>{let{run:A}=t;for(n=i[e];n;)A(n),n=n.parent})),this.events=[],this.eventElements=[]}checkPath(t,e){if(!this.working||!e)return;const{events:i,eventElements:A}=this;i.forEach(((i,n)=>{let{x:a,y:r}=i;!A[n]&&e.isPointInPath&&e.isPointInPath(a,r)&&(A[n]=t)}))}checkBoundingBox(t,e){if(!this.working||!e)return;const{events:i,eventElements:A}=this;i.forEach(((i,n)=>{let{x:a,y:r}=i;!A[n]&&e.isPointInBox(a,r)&&(A[n]=t)}))}mapXY(t,e){const{window:i,ctx:A}=this.screen,n=new rt(t,e);let a=A.canvas;for(;a;)n.x-=a.offsetLeft,n.y-=a.offsetTop,a=a.offsetParent;return(null==i?void 0:i.scrollX)&&(n.x+=i.scrollX),(null==i?void 0:i.scrollY)&&(n.y+=i.scrollY),n}onClick(t){const{x:e,y:i}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onclick",x:e,y:i,run(t){t.onClick&&t.onClick()}})}onMouseMove(t){const{x:e,y:i}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onmousemove",x:e,y:i,run(t){t.onMouseMove&&t.onMouseMove()}})}constructor(t){st(this,"screen",void 0),st(this,"working",void 0),st(this,"events",void 0),st(this,"eventElements",void 0),this.screen=t,this.working=!1,this.events=[],this.eventElements=[],this.onClick=this.onClick.bind(this),this.onMouseMove=this.onMouseMove.bind(this)}}function ct(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const lt="undefined"!=typeof window?window:null,gt="undefined"!=typeof fetch?fetch.bind(void 0):void 0;class ht{wait(t){this.waits.push(t)}ready(){return this.readyPromise?this.readyPromise:Promise.resolve()}isReady(){if(this.isReadyLock)return!0;const t=this.waits.every((t=>t()));return t&&(this.waits=[],this.resolveReady&&this.resolveReady()),this.isReadyLock=t,t}setDefaults(t){t.strokeStyle="rgba(0,0,0,0)",t.lineCap="butt",t.lineJoin="miter",t.miterLimit=4}setViewBox(t){let{document:e,ctx:i,aspectRatio:A,width:n,desiredWidth:a,height:r,desiredHeight:s,minX:o=0,minY:c=0,refX:l,refY:g,clip:h=!1,clipX:d=0,clipY:u=0}=t;const w=b(A).replace(/^defer\s/,""),[B,p]=w.split(" "),E=B||"xMidYMid",m=p||"meet",f=n/a,C=r/s,Q=Math.min(f,C),y=Math.max(f,C);let D=a,I=s;"meet"===m&&(D*=Q,I*=Q),"slice"===m&&(D*=y,I*=y);const x=new et(e,"refX",l),v=new et(e,"refY",g),M=x.hasValue()&&v.hasValue();if(M&&i.translate(-Q*x.getPixels("x"),-Q*v.getPixels("y")),h){const t=Q*d,e=Q*u;i.beginPath(),i.moveTo(t,e),i.lineTo(n,e),i.lineTo(n,r),i.lineTo(t,r),i.closePath(),i.clip()}if(!M){const t="meet"===m&&Q===C,e="slice"===m&&y===C,A="meet"===m&&Q===f,a="slice"===m&&y===f;E.startsWith("xMid")&&(t||e)&&i.translate(n/2-D/2,0),E.endsWith("YMid")&&(A||a)&&i.translate(0,r/2-I/2),E.startsWith("xMax")&&(t||e)&&i.translate(n-D,0),E.endsWith("YMax")&&(A||a)&&i.translate(0,r-I)}switch(!0){case"none"===E:i.scale(f,C);break;case"meet"===m:i.scale(Q,Q);break;case"slice"===m:i.scale(y,y)}i.translate(-o,-c)}start(t){let{enableRedraw:e=!1,ignoreMouse:i=!1,ignoreAnimation:A=!1,ignoreDimensions:n=!1,ignoreClear:a=!1,forceRedraw:r,scaleWidth:s,scaleHeight:o,offsetX:c,offsetY:l}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{mouse:g}=this,h=1e3/ht.FRAMERATE;if(this.isReadyLock=!1,this.frameDuration=h,this.readyPromise=new Promise((t=>{this.resolveReady=t})),this.isReady()&&this.render(t,n,a,s,o,c,l),!e)return;let d=Date.now(),w=d,B=0;const p=()=>{d=Date.now(),B=d-w,B>=h&&(w=d-B%h,this.shouldUpdate(A,r)&&(this.render(t,n,a,s,o,c,l),g.runEvents())),this.intervalId=F(u)(p)};i||g.start(),this.intervalId=F(u)(p)}stop(){this.intervalId&&(F(u).cancel(this.intervalId),this.intervalId=null),this.mouse.stop()}shouldUpdate(t,e){if(!t){const{frameDuration:t}=this;if(this.animations.reduce(((e,i)=>i.update(t)||e),!1))return!0}return!("function"!=typeof e||!e())||(!(this.isReadyLock||!this.isReady())||!!this.mouse.hasEvents())}render(t,e,i,A,n,a,r){const{viewPort:s,ctx:o,isFirstRender:c}=this,l=o.canvas;s.clear(),l.width&&l.height&&s.setCurrent(l.width,l.height);const g=t.getStyle("width"),h=t.getStyle("height");!e&&(c||"number"!=typeof A&&"number"!=typeof n)&&(g.hasValue()&&(l.width=g.getPixels("x"),l.style&&(l.style.width=`${l.width}px`)),h.hasValue()&&(l.height=h.getPixels("y"),l.style&&(l.style.height=`${l.height}px`)));let d=l.clientWidth||l.width,u=l.clientHeight||l.height;if(e&&g.hasValue()&&h.hasValue()&&(d=g.getPixels("x"),u=h.getPixels("y")),s.setCurrent(d,u),"number"==typeof a&&t.getAttribute("x",!0).setValue(a),"number"==typeof r&&t.getAttribute("y",!0).setValue(r),"number"==typeof A||"number"==typeof n){const e=Y(t.getAttribute("viewBox").getString());let i=0,a=0;if("number"==typeof A){const n=t.getStyle("width");n.hasValue()?i=n.getPixels("x")/A:e[2]&&!isNaN(e[2])&&(i=e[2]/A)}if("number"==typeof n){const i=t.getStyle("height");i.hasValue()?a=i.getPixels("y")/n:e[3]&&!isNaN(e[3])&&(a=e[3]/n)}i||(i=a),a||(a=i),t.getAttribute("width",!0).setValue(A),t.getAttribute("height",!0).setValue(n);const r=t.getStyle("transform",!0,!0);r.setValue(`${r.getString()} scale(${1/i}, ${1/a})`)}i||o.clearRect(0,0,d,u),t.render(o),c&&(this.isFirstRender=!1)}constructor(t,{fetch:e=gt,window:i=lt}={}){if(ct(this,"ctx",void 0),ct(this,"window",void 0),ct(this,"fetch",void 0),ct(this,"viewPort",void 0),ct(this,"mouse",void 0),ct(this,"animations",void 0),ct(this,"readyPromise",void 0),ct(this,"resolveReady",void 0),ct(this,"waits",void 0),ct(this,"frameDuration",void 0),ct(this,"isReadyLock",void 0),ct(this,"isFirstRender",void 0),ct(this,"intervalId",void 0),this.ctx=t,this.viewPort=new At,this.mouse=new ot(this),this.animations=[],this.waits=[],this.frameDuration=0,this.isReadyLock=!1,this.isFirstRender=!0,this.intervalId=null,this.window=i,!e)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");this.fetch=e}}function dt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}ct(ht,"defaultWindow",lt),ct(ht,"defaultFetch",gt),ct(ht,"FRAMERATE",30),ct(ht,"MAX_VIRTUAL_PIXELS",3e4);const{defaultFetch:ut}=ht,wt="undefined"!=typeof DOMParser?DOMParser:void 0;class Bt{async parse(t){return t.startsWith("<")?this.parseFromString(t):this.load(t)}parseFromString(t){const e=new this.DOMParser;try{return this.checkDocument(e.parseFromString(t,"image/svg+xml"))}catch(i){return this.checkDocument(e.parseFromString(t,"text/xml"))}}checkDocument(t){const e=t.getElementsByTagName("parsererror")[0];if(e)throw new Error(e.textContent||"Unknown parse error");return t}async load(t){const e=await this.fetch(t),i=await e.text();return this.parseFromString(i)}constructor({fetch:t=ut,DOMParser:e=wt}={}){if(dt(this,"fetch",void 0),dt(this,"DOMParser",void 0),!t)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");if(!e)throw new Error("Can't find 'DOMParser' in 'globalThis', please provide it via options");this.fetch=t,this.DOMParser=e}}function pt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Et(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function mt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ft(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Ct{apply(t){const{originX:e,originY:i,matrix:A}=this,n=e.getPixels("x"),a=i.getPixels("y");t.translate(n,a),t.transform(A[0],A[1],A[2],A[3],A[4],A[5]),t.translate(-n,-a)}unapply(t){const{originX:e,originY:i,matrix:A}=this,n=A[0],a=A[2],r=A[4],s=A[1],o=A[3],c=A[5],l=1/(n*(1*o-0*c)-a*(1*s-0*c)+r*(0*s-0*o)),g=e.getPixels("x"),h=i.getPixels("y");t.translate(g,h),t.transform(l*(1*o-0*c),l*(0*c-1*s),l*(0*r-1*a),l*(1*n-0*r),l*(a*c-r*o),l*(r*s-n*c)),t.translate(-g,-h)}applyToPoint(t){t.applyTransform(this.matrix)}constructor(t,e,i){ft(this,"type","matrix"),ft(this,"matrix",void 0),ft(this,"originX",void 0),ft(this,"originY",void 0),this.matrix=function(t){const e=Y(t);return[e[0]||0,e[1]||0,e[2]||0,e[3]||0,e[4]||0,e[5]||0]}(e),this.originX=i[0],this.originY=i[1]}}function Qt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class yt extends Ct{constructor(t,e,i){super(t,e,i),Qt(this,"type","skew"),Qt(this,"angle",void 0),this.angle=new et(t,"angle",e)}}function Dt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class It{static fromElement(t,e){const i=e.getStyle("transform",!1,!0);if(i.hasValue()){const[A,n=A]=e.getStyle("transform-origin",!1,!0).split();if(A&&n){const e=[A,n];return new It(t,i.getString(),e)}}return null}apply(t){this.transforms.forEach((e=>e.apply(t)))}unapply(t){this.transforms.forEach((e=>e.unapply(t)))}applyToPoint(t){this.transforms.forEach((e=>e.applyToPoint(t)))}constructor(t,e,i){Dt(this,"document",void 0),Dt(this,"transforms",void 0),this.document=t,this.transforms=[];const A=function(t){return b(t).trim().replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)}(e);A.forEach((t=>{if("none"===t)return;const[e,A]=function(t){const[e="",i=""]=t.split("(");return[e.trim(),i.trim().replace(")","")]}(t),n=It.transformTypes[e];n&&this.transforms.push(new n(this.document,A,i))}))}}function xt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}Dt(It,"transformTypes",{translate:class{apply(t){const{x:e,y:i}=this.point;t.translate(e||0,i||0)}unapply(t){const{x:e,y:i}=this.point;t.translate(-1*e||0,-1*i||0)}applyToPoint(t){const{x:e,y:i}=this.point;t.applyTransform([1,0,0,1,e||0,i||0])}constructor(t,e){pt(this,"type","translate"),pt(this,"point",void 0),this.point=rt.parse(e)}},rotate:class{apply(t){const{cx:e,cy:i,originX:A,originY:n,angle:a}=this,r=e+A.getPixels("x"),s=i+n.getPixels("y");t.translate(r,s),t.rotate(a.getRadians()),t.translate(-r,-s)}unapply(t){const{cx:e,cy:i,originX:A,originY:n,angle:a}=this,r=e+A.getPixels("x"),s=i+n.getPixels("y");t.translate(r,s),t.rotate(-1*a.getRadians()),t.translate(-r,-s)}applyToPoint(t){const{cx:e,cy:i,angle:A}=this,n=A.getRadians();t.applyTransform([1,0,0,1,e||0,i||0]),t.applyTransform([Math.cos(n),Math.sin(n),-Math.sin(n),Math.cos(n),0,0]),t.applyTransform([1,0,0,1,-e||0,-i||0])}constructor(t,e,i){Et(this,"type","rotate"),Et(this,"angle",void 0),Et(this,"originX",void 0),Et(this,"originY",void 0),Et(this,"cx",void 0),Et(this,"cy",void 0);const A=Y(e);this.angle=new et(t,"angle",A[0]),this.originX=i[0],this.originY=i[1],this.cx=A[1]||0,this.cy=A[2]||0}},scale:class{apply(t){const{scale:{x:e,y:i},originX:A,originY:n}=this,a=A.getPixels("x"),r=n.getPixels("y");t.translate(a,r),t.scale(e,i||e),t.translate(-a,-r)}unapply(t){const{scale:{x:e,y:i},originX:A,originY:n}=this,a=A.getPixels("x"),r=n.getPixels("y");t.translate(a,r),t.scale(1/e,1/i||e),t.translate(-a,-r)}applyToPoint(t){const{x:e,y:i}=this.scale;t.applyTransform([e||0,0,0,i||0,0,0])}constructor(t,e,i){mt(this,"type","scale"),mt(this,"scale",void 0),mt(this,"originX",void 0),mt(this,"originY",void 0);const A=rt.parseScale(e);0!==A.x&&0!==A.y||(A.x=L,A.y=L),this.scale=A,this.originX=i[0],this.originY=i[1]}},matrix:Ct,skewX:class extends yt{constructor(t,e,i){var A,n,a;super(t,e,i),a="skewX",(n="type")in(A=this)?Object.defineProperty(A,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):A[n]=a,this.matrix=[1,0,Math.tan(this.angle.getRadians()),1,0,0]}},skewY:class extends yt{constructor(t,e,i){var A,n,a;super(t,e,i),a="skewY",(n="type")in(A=this)?Object.defineProperty(A,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):A[n]=a,this.matrix=[1,Math.tan(this.angle.getRadians()),0,1,0,0]}}});class vt{getAttribute(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.attributes[t];if(!i&&e){const e=new et(this.document,t,"");return this.attributes[t]=e,e}return i||et.empty(this.document)}getHrefAttribute(){let t;for(const e in this.attributes)if("href"===e||e.endsWith(":href")){t=this.attributes[e];break}return t||et.empty(this.document)}getStyle(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const A=this.styles[t];if(A)return A;const n=this.getAttribute(t);if(n.hasValue())return this.styles[t]=n,n;if(!i){const{parent:e}=this;if(e){const i=e.getStyle(t);if(i.hasValue())return i}}if(e){const e=new et(this.document,t,"");return this.styles[t]=e,e}return et.empty(this.document)}render(t){if("none"!==this.getStyle("display").getString()&&"hidden"!==this.getStyle("visibility").getString()){if(t.save(),this.getStyle("mask").hasValue()){const e=this.getStyle("mask").getDefinition();e&&(this.applyEffects(t),e.apply(t,this))}else if("none"!==this.getStyle("filter").getValue("none")){const e=this.getStyle("filter").getDefinition();e&&(this.applyEffects(t),e.apply(t,this))}else this.setContext(t),this.renderChildren(t),this.clearContext(t);t.restore()}}setContext(t){}applyEffects(t){const e=It.fromElement(this.document,this);e&&e.apply(t);const i=this.getStyle("clip-path",!1,!0);if(i.hasValue()){const e=i.getDefinition();e&&e.apply(t)}}clearContext(t){}renderChildren(t){this.children.forEach((e=>{e.render(t)}))}addChild(t){const e=t instanceof vt?t:this.document.createElement(t);e.parent=this,vt.ignoreChildTypes.includes(e.type)||this.children.push(e)}matchesSelector(t){var e;const{node:i}=this;if(!i)return!1;if("function"==typeof i.matches)return i.matches(t);const A=null===(e=i.getAttribute)||void 0===e?void 0:e.call(i,"class");return!(!A||""===A)&&A.split(" ").some((e=>`.${e}`===t))}addStylesFromStyleDefinition(){const{styles:t,stylesSpecificity:e}=this.document;let i;for(const A in t)if(!A.startsWith("@")&&this.matchesSelector(A)){const n=t[A],a=e[A];if(n)for(const t in n){let e=this.stylesSpecificity[t];void 0===e&&(e="000"),a&&a>=e&&(i=n[t],i&&(this.styles[t]=i),this.stylesSpecificity[t]=a)}}}removeStyles(t,e){return e.reduce(((e,i)=>{const A=t.getStyle(i);if(!A.hasValue())return e;const n=A.getString();return A.setValue(""),[...e,[i,n]]}),[])}restoreStyles(t,e){e.forEach((e=>{let[i,A]=e;t.getStyle(i,!0).setValue(A)}))}isFirstChild(){var t;return 0===(null===(t=this.parent)||void 0===t?void 0:t.children.indexOf(this))}constructor(t,e,i=!1){if(xt(this,"document",void 0),xt(this,"node",void 0),xt(this,"captureTextNodes",void 0),xt(this,"type",void 0),xt(this,"attributes",void 0),xt(this,"styles",void 0),xt(this,"stylesSpecificity",void 0),xt(this,"animationFrozen",void 0),xt(this,"animationFrozenValue",void 0),xt(this,"parent",void 0),xt(this,"children",void 0),this.document=t,this.node=e,this.captureTextNodes=i,this.type="",this.attributes={},this.styles={},this.stylesSpecificity={},this.animationFrozen=!1,this.animationFrozenValue="",this.parent=null,this.children=[],!e||1!==e.nodeType)return;if(Array.from(e.attributes).forEach((e=>{const i=(A=e.nodeName,P.test(A)?A.toLowerCase():A);var A;this.attributes[i]=new et(t,i,e.value)})),this.addStylesFromStyleDefinition(),this.getAttribute("style").hasValue()){this.getAttribute("style").getString().split(";").map((t=>t.trim())).forEach((e=>{if(!e)return;const[i,A]=e.split(":").map((t=>t.trim()));i&&(this.styles[i]=new et(t,i,A))}))}const{definitions:A}=t,n=this.getAttribute("id");n.hasValue()&&(A[n.getString()]||(A[n.getString()]=this)),Array.from(e.childNodes).forEach((e=>{if(1===e.nodeType)this.addChild(e);else if(i&&(3===e.nodeType||4===e.nodeType)){const i=t.createTextNode(e);i.getText().length>0&&this.addChild(i)}}))}}xt(vt,"ignoreChildTypes",["title"]);class Mt extends vt{constructor(t,e,i){super(t,e,i)}}function St(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Ft(t){const e=t.trim();return/^('|")/.test(e)?e:`"${e}"`}function bt(t){if(!t)return"";const e=t.trim().toLowerCase();switch(e){case"normal":case"italic":case"oblique":case"inherit":case"initial":case"unset":return e;default:return/^oblique\s+(-|)\d+deg$/.test(e)?e:""}}function Yt(t){if(!t)return"";const e=t.trim().toLowerCase();switch(e){case"normal":case"bold":case"lighter":case"bolder":case"inherit":case"initial":case"unset":return e;default:return/^[\d.]+$/.test(e)?e:""}}class Pt{static parse(){let t=arguments.length>1?arguments[1]:void 0,e="",i="",A="",n="",a="";const r=b(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").trim().split(" "),s={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1};return r.forEach((t=>{switch(!0){case!s.fontStyle&&Pt.styles.includes(t):"inherit"!==t&&(e=t),s.fontStyle=!0;break;case!s.fontVariant&&Pt.variants.includes(t):"inherit"!==t&&(i=t),s.fontStyle=!0,s.fontVariant=!0;break;case!s.fontWeight&&Pt.weights.includes(t):"inherit"!==t&&(A=t),s.fontStyle=!0,s.fontVariant=!0,s.fontWeight=!0;break;case!s.fontSize:"inherit"!==t&&(n=t.split("/")[0]||""),s.fontStyle=!0,s.fontVariant=!0,s.fontWeight=!0,s.fontSize=!0;break;default:"inherit"!==t&&(a+=t)}})),new Pt(e,i,A,n,a,t)}toString(){return[bt(this.fontStyle),this.fontVariant,Yt(this.fontWeight),this.fontSize,(t=this.fontFamily,void 0===d?t:t.trim().split(",").map(Ft).join(","))].join(" ").trim();var t}constructor(t,e,i,A,n,a){St(this,"fontFamily",void 0),St(this,"fontSize",void 0),St(this,"fontStyle",void 0),St(this,"fontWeight",void 0),St(this,"fontVariant",void 0);const r=a?"string"==typeof a?Pt.parse(a):a:{};this.fontFamily=n||r.fontFamily,this.fontSize=A||r.fontSize,this.fontStyle=t||r.fontStyle,this.fontWeight=i||r.fontWeight,this.fontVariant=e||r.fontVariant}}function Nt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}St(Pt,"styles","normal|italic|oblique|inherit"),St(Pt,"variants","normal|small-caps|inherit"),St(Pt,"weights","normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit");class Rt{get x(){return this.x1}get y(){return this.y1}get width(){return this.x2-this.x1}get height(){return this.y2-this.y1}addPoint(t,e){void 0!==t&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),t<this.x1&&(this.x1=t),t>this.x2&&(this.x2=t)),void 0!==e&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))}addX(t){this.addPoint(t,0)}addY(t){this.addPoint(0,t)}addBoundingBox(t){if(!t)return;const{x1:e,y1:i,x2:A,y2:n}=t;this.addPoint(e,i),this.addPoint(A,n)}sumCubic(t,e,i,A,n){return Math.pow(1-t,3)*e+3*Math.pow(1-t,2)*t*i+3*(1-t)*Math.pow(t,2)*A+Math.pow(t,3)*n}bezierCurveAdd(t,e,i,A,n){const a=6*e-12*i+6*A,r=-3*e+9*i-9*A+3*n,s=3*i-3*e;if(0===r){if(0===a)return;const r=-s/a;return void(0<r&&r<1&&(t?this.addX(this.sumCubic(r,e,i,A,n)):this.addY(this.sumCubic(r,e,i,A,n))))}const o=Math.pow(a,2)-4*s*r;if(o<0)return;const c=(-a+Math.sqrt(o))/(2*r);0<c&&c<1&&(t?this.addX(this.sumCubic(c,e,i,A,n)):this.addY(this.sumCubic(c,e,i,A,n)));const l=(-a-Math.sqrt(o))/(2*r);0<l&&l<1&&(t?this.addX(this.sumCubic(l,e,i,A,n)):this.addY(this.sumCubic(l,e,i,A,n)))}addBezierCurve(t,e,i,A,n,a,r,s){this.addPoint(t,e),this.addPoint(r,s),this.bezierCurveAdd(!0,t,i,n,r),this.bezierCurveAdd(!1,e,A,a,s)}addQuadraticCurve(t,e,i,A,n,a){const r=t+2/3*(i-t),s=e+2/3*(A-e),o=r+1/3*(n-t),c=s+1/3*(a-e);this.addBezierCurve(t,e,r,o,s,c,n,a)}isPointInBox(t,e){const{x1:i,y1:A,x2:n,y2:a}=this;return i<=t&&t<=n&&A<=e&&e<=a}constructor(t=Number.NaN,e=Number.NaN,i=Number.NaN,A=Number.NaN){Nt(this,"x1",void 0),Nt(this,"y1",void 0),Nt(this,"x2",void 0),Nt(this,"y2",void 0),this.x1=t,this.y1=e,this.x2=i,this.y2=A,this.addPoint(t,e),this.addPoint(i,A)}}class kt extends vt{calculateOpacity(){let t=1,e=this;for(;e;){const i=e.getStyle("opacity",!1,!0);i.hasValue(!0)&&(t*=i.getNumber()),e=e.parent}return t}setContext(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e){const e=this.getStyle("fill"),i=this.getStyle("fill-opacity"),A=this.getStyle("stroke"),n=this.getStyle("stroke-opacity");if(e.isUrlDefinition()){const A=e.getFillStyleDefinition(this,i);A&&(t.fillStyle=A)}else if(e.hasValue()){"currentColor"===e.getString()&&e.setValue(this.getStyle("color").getColor());const i=e.getColor();"inherit"!==i&&(t.fillStyle="none"===i?"rgba(0,0,0,0)":i)}if(i.hasValue()){const e=new et(this.document,"fill",t.fillStyle).addOpacity(i).getColor();t.fillStyle=e}if(A.isUrlDefinition()){const e=A.getFillStyleDefinition(this,n);e&&(t.strokeStyle=e)}else if(A.hasValue()){"currentColor"===A.getString()&&A.setValue(this.getStyle("color").getColor());const e=A.getString();"inherit"!==e&&(t.strokeStyle="none"===e?"rgba(0,0,0,0)":e)}if(n.hasValue()){const e=new et(this.document,"stroke",t.strokeStyle).addOpacity(n).getString();t.strokeStyle=e}const a=this.getStyle("stroke-width");if(a.hasValue()){const e=a.getPixels();t.lineWidth=e||L}const r=this.getStyle("stroke-linecap"),s=this.getStyle("stroke-linejoin"),o=this.getStyle("stroke-miterlimit"),c=this.getStyle("stroke-dasharray"),l=this.getStyle("stroke-dashoffset");if(r.hasValue()&&(t.lineCap=r.getString()),s.hasValue()&&(t.lineJoin=s.getString()),o.hasValue()&&(t.miterLimit=o.getNumber()),c.hasValue()&&"none"!==c.getString()){const e=Y(c.getString());void 0!==t.setLineDash?t.setLineDash(e):void 0!==t.webkitLineDash?t.webkitLineDash=e:void 0===t.mozDash||1===e.length&&0===e[0]||(t.mozDash=e);const i=l.getPixels();void 0!==t.lineDashOffset?t.lineDashOffset=i:void 0!==t.webkitLineDashOffset?t.webkitLineDashOffset=i:void 0!==t.mozDashOffset&&(t.mozDashOffset=i)}}if(this.modifiedEmSizeStack=!1,void 0!==t.font){const e=this.getStyle("font"),i=this.getStyle("font-style"),A=this.getStyle("font-variant"),n=this.getStyle("font-weight"),a=this.getStyle("font-size"),r=this.getStyle("font-family"),s=new Pt(i.getString(),A.getString(),n.getString(),a.hasValue()?`${a.getPixels(!0)}px`:"",r.getString(),Pt.parse(e.getString(),t.font));i.setValue(s.fontStyle),A.setValue(s.fontVariant),n.setValue(s.fontWeight),a.setValue(s.fontSize),r.setValue(s.fontFamily),t.font=s.toString(),a.isPixels()&&(this.document.emSize=a.getPixels(),this.modifiedEmSizeStack=!0)}e||(this.applyEffects(t),t.globalAlpha=this.calculateOpacity())}clearContext(t){super.clearContext(t),this.modifiedEmSizeStack&&this.document.popEmSize()}constructor(...t){var e,i,A;super(...t),A=!1,(i="modifiedEmSizeStack")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}}function Ht(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Ut extends kt{setContext(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];super.setContext(t,e);const i=this.getStyle("dominant-baseline").getTextBaseline()||this.getStyle("alignment-baseline").getTextBaseline();i&&(t.textBaseline=i)}initializeCoordinates(){this.x=0,this.y=0,this.leafTexts=[],this.textChunkStart=0,this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY}getBoundingBox(t){if("text"!==this.type)return this.getTElementBoundingBox(t);this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(t);let e=null;return this.children.forEach(((i,A)=>{const n=this.getChildBoundingBox(t,this,this,A);e?e.addBoundingBox(n):e=n})),e}getFontSize(){const{document:t,parent:e}=this,i=Pt.parse(t.ctx.font).fontSize;return e.getStyle("font-size").getNumber(i)}getTElementBoundingBox(t){const e=this.getFontSize();return new Rt(this.x,this.y-e,this.x+this.measureText(t),this.y)}getGlyph(t,e,i){const A=e[i];let n;if(t.isArabic){var a;const r=e.length,s=e[i-1],o=e[i+1];let c="isolated";(0===i||" "===s)&&i<r-1&&" "!==o&&(c="terminal"),i>0&&" "!==s&&i<r-1&&" "!==o&&(c="medial"),i>0&&" "!==s&&(i===r-1||" "===o)&&(c="initial"),n=(null===(a=t.arabicGlyphs[A])||void 0===a?void 0:a[c])||t.glyphs[A]}else n=t.glyphs[A];return n||(n=t.missingGlyph),n}getText(){return""}getTextFromNode(t){const e=t||this.node,i=Array.from(e.parentNode.childNodes),A=i.indexOf(e),n=i.length-1;let a=b(e.textContent||"");return 0===A&&(a=a.replace(/^[\n \t]+/,"")),A===n&&(a=function(t){return t.replace(/[\n \t]+$/,"")}(a)),a}renderChildren(t){if("text"!==this.type)return void this.renderTElementChildren(t);this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(t),this.children.forEach(((e,i)=>{this.renderChild(t,this,this,i)}));const{mouse:e}=this.document.screen;e.isWorking()&&e.checkBoundingBox(this,this.getBoundingBox(t))}renderTElementChildren(t){const{document:e,parent:i}=this,A=this.getText(),n=i.getStyle("font-family").getDefinition();if(null==n?void 0:n.fontFace){const{unitsPerEm:a}=n.fontFace,r=Pt.parse(e.ctx.font),s=i.getStyle("font-size").getNumber(r.fontSize),o=i.getStyle("font-style").getString(r.fontStyle),c=s/a,l=n.isRTL?A.split("").reverse().join(""):A,g=Y(i.getAttribute("dx").getString()),h=l.length;for(let e=0;e<h;e++){const i=this.getGlyph(n,l,e);t.translate(this.x,this.y),t.scale(c,-c);const A=t.lineWidth;t.lineWidth=t.lineWidth*a/s,"italic"===o&&t.transform(1,0,.4,1,0,0),i.render(t),"italic"===o&&t.transform(1,0,-.4,1,0,0),t.lineWidth=A,t.scale(1/c,-1/c),t.translate(-this.x,-this.y),this.x+=s*(i.horizAdvX||n.horizAdvX)/a,void 0===g[e]||isNaN(g[e])||(this.x+=g[e])}return}const{x:a,y:r}=this;t.fillStyle&&t.fillText(A,a,r),t.strokeStyle&&t.strokeText(A,a,r)}applyAnchoring(){if(this.textChunkStart>=this.leafTexts.length)return;const t=this.leafTexts[this.textChunkStart],e=t.getStyle("text-anchor").getString("start");let i=0;i="start"===e?t.x-this.minX:"end"===e?t.x-this.maxX:t.x-(this.minX+this.maxX)/2;for(let t=this.textChunkStart;t<this.leafTexts.length;t++)this.leafTexts[t].x+=i;this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.textChunkStart=this.leafTexts.length}adjustChildCoordinatesRecursive(t){this.children.forEach(((e,i)=>{this.adjustChildCoordinatesRecursiveCore(t,this,this,i)})),this.applyAnchoring()}adjustChildCoordinatesRecursiveCore(t,e,i,A){const n=i.children[A];n.children.length>0?n.children.forEach(((i,A)=>{e.adjustChildCoordinatesRecursiveCore(t,e,n,A)})):this.adjustChildCoordinates(t,e,i,A)}adjustChildCoordinates(t,e,i,A){const n=i.children[A];if("function"!=typeof n.measureText)return n;t.save(),n.setContext(t,!0);const a=n.getAttribute("x"),r=n.getAttribute("y"),s=n.getAttribute("dx"),o=n.getAttribute("dy"),c=n.getStyle("font-family").getDefinition(),l=Boolean(null==c?void 0:c.isRTL);0===A&&(a.hasValue()||a.setValue(n.getInheritedAttribute("x")),r.hasValue()||r.setValue(n.getInheritedAttribute("y")),s.hasValue()||s.setValue(n.getInheritedAttribute("dx")),o.hasValue()||o.setValue(n.getInheritedAttribute("dy")));const g=n.measureText(t);return l&&(e.x-=g),a.hasValue()?(e.applyAnchoring(),n.x=a.getPixels("x"),s.hasValue()&&(n.x+=s.getPixels("x"))):(s.hasValue()&&(e.x+=s.getPixels("x")),n.x=e.x),e.x=n.x,l||(e.x+=g),r.hasValue()?(n.y=r.getPixels("y"),o.hasValue()&&(n.y+=o.getPixels("y"))):(o.hasValue()&&(e.y+=o.getPixels("y")),n.y=e.y),e.y=n.y,e.leafTexts.push(n),e.minX=Math.min(e.minX,n.x,n.x+g),e.maxX=Math.max(e.maxX,n.x,n.x+g),n.clearContext(t),t.restore(),n}getChildBoundingBox(t,e,i,A){const n=i.children[A];if("function"!=typeof n.getBoundingBox)return null;const a=n.getBoundingBox(t);return a&&n.children.forEach(((i,A)=>{const r=e.getChildBoundingBox(t,e,n,A);a.addBoundingBox(r)})),a}renderChild(t,e,i,A){const n=i.children[A];n.render(t),n.children.forEach(((i,A)=>{e.renderChild(t,e,n,A)}))}measureText(t){const{measureCache:e}=this;if(~e)return e;const i=this.getText(),A=this.measureTargetText(t,i);return this.measureCache=A,A}measureTargetText(t,e){if(!e.length)return 0;const{parent:i}=this,A=i.getStyle("font-family").getDefinition();if(A){const t=this.getFontSize(),n=A.isRTL?e.split("").reverse().join(""):e,a=Y(i.getAttribute("dx").getString()),r=n.length;let s=0;for(let e=0;e<r;e++){s+=(this.getGlyph(A,n,e).horizAdvX||A.horizAdvX)*t/A.fontFace.unitsPerEm,void 0===a[e]||isNaN(a[e])||(s+=a[e])}return s}if(!t.measureText)return 10*e.length;t.save(),this.setContext(t,!0);const{width:n}=t.measureText(e);return this.clearContext(t),t.restore(),n}getInheritedAttribute(t){let e=this;for(;e instanceof Ut&&e.isFirstChild()&&e.parent;){const i=e.parent.getAttribute(t);if(i.hasValue(!0))return i.getString("0");e=e.parent}return null}constructor(t,e,i){super(t,e,new.target===Ut||i),Ht(this,"type","text"),Ht(this,"x",0),Ht(this,"y",0),Ht(this,"leafTexts",[]),Ht(this,"textChunkStart",0),Ht(this,"minX",Number.POSITIVE_INFINITY),Ht(this,"maxX",Number.NEGATIVE_INFINITY),Ht(this,"measureCache",-1)}}function Gt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Tt extends Ut{getText(){return this.text}constructor(t,e,i){super(t,e,new.target===Tt||i),Gt(this,"type","tspan"),Gt(this,"text",void 0),this.text=this.children.length>0?"":this.getTextFromNode()}}class Ot extends Tt{constructor(...t){var e,i,A;super(...t),A="textNode",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}}function Jt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Lt extends B.SVGPathData{reset(){this.i=-1,this.command=null,this.previousCommand=null,this.start=new rt(0,0),this.control=new rt(0,0),this.current=new rt(0,0),this.points=[],this.angles=[]}isEnd(){const{i:t,commands:e}=this;return t>=e.length-1}next(){const t=this.commands[++this.i];return this.previousCommand=this.command,this.command=t,t}getPoint(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"x",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y";const i=new rt(this.command[t],this.command[e]);return this.makeAbsolute(i)}getAsControlPoint(t,e){const i=this.getPoint(t,e);return this.control=i,i}getAsCurrentPoint(t,e){const i=this.getPoint(t,e);return this.current=i,i}getReflectedControlPoint(){const t=this.previousCommand.type;if(t!==B.SVGPathData.CURVE_TO&&t!==B.SVGPathData.SMOOTH_CURVE_TO&&t!==B.SVGPathData.QUAD_TO&&t!==B.SVGPathData.SMOOTH_QUAD_TO)return this.current;const{current:{x:e,y:i},control:{x:A,y:n}}=this;return new rt(2*e-A,2*i-n)}makeAbsolute(t){if(this.command.relative){const{x:e,y:i}=this.current;t.x+=e,t.y+=i}return t}addMarker(t,e,i){const{points:A,angles:n}=this;i&&n.length>0&&!n[n.length-1]&&(n[n.length-1]=A[A.length-1].angleTo(i)),this.addMarkerAngle(t,e?e.angleTo(t):null)}addMarkerAngle(t,e){this.points.push(t),this.angles.push(e)}getMarkerPoints(){return this.points}getMarkerAngles(){const{angles:t}=this,e=t.length;for(let i=0;i<e;i++)if(!t[i])for(let A=i+1;A<e;A++)if(t[A]){t[i]=t[A];break}return t}constructor(t){super(t.replace(/([+\-.])\s+/gm,"$1").replace(/[^MmZzLlHhVvCcSsQqTtAae\d\s.,+-].*/g,"")),Jt(this,"control",new rt(0,0)),Jt(this,"start",new rt(0,0)),Jt(this,"current",new rt(0,0)),Jt(this,"command",null),Jt(this,"commands",this.commands),Jt(this,"i",-1),Jt(this,"previousCommand",null),Jt(this,"points",[]),Jt(this,"angles",[])}}function zt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class jt extends kt{path(t){const{pathParser:e}=this,i=new Rt;for(e.reset(),t&&t.beginPath();!e.isEnd();)switch(e.next().type){case Lt.MOVE_TO:this.pathM(t,i);break;case Lt.LINE_TO:this.pathL(t,i);break;case Lt.HORIZ_LINE_TO:this.pathH(t,i);break;case Lt.VERT_LINE_TO:this.pathV(t,i);break;case Lt.CURVE_TO:this.pathC(t,i);break;case Lt.SMOOTH_CURVE_TO:this.pathS(t,i);break;case Lt.QUAD_TO:this.pathQ(t,i);break;case Lt.SMOOTH_QUAD_TO:this.pathT(t,i);break;case Lt.ARC:this.pathA(t,i);break;case Lt.CLOSE_PATH:this.pathZ(t,i)}return i}getBoundingBox(t){return this.path()}getMarkers(){const{pathParser:t}=this,e=t.getMarkerPoints(),i=t.getMarkerAngles();if(!e||!i)return null;return e.map(((t,e)=>[t,i[e]]))}renderChildren(t){this.path(t),this.document.screen.mouse.checkPath(this,t);const e=this.getStyle("fill-rule");""!==t.fillStyle&&("inherit"!==e.getString("inherit")?t.fill(e.getString()):t.fill()),""!==t.strokeStyle&&("non-scaling-stroke"===this.getAttribute("vector-effect").getString()?(t.save(),t.setTransform(1,0,0,1,0,0),t.stroke(),t.restore()):t.stroke());const i=this.getMarkers();if(i){const e=i.length-1,A=this.getStyle("marker-start"),n=this.getStyle("marker-mid"),a=this.getStyle("marker-end");if(A.isUrlDefinition()){const e=A.getDefinition(),[n,a]=i[0];e&&e.render(t,n,null===a?void 0:a)}if(n.isUrlDefinition()){const A=n.getDefinition();for(let n=1;n<e;n++){const[e,a]=i[n];A&&A.render(t,e,null===a?void 0:a)}}if(a.isUrlDefinition()){const A=a.getDefinition(),[n,r]=i[e];A&&A.render(t,n,null===r?void 0:r)}}}static pathM(t){const e=t.getAsCurrentPoint();return t.start=t.current,{point:e}}pathM(t,e){const{pathParser:i}=this,{point:A}=jt.pathM(i),{x:n,y:a}=A;i.addMarker(A),e.addPoint(n,a),t&&t.moveTo(n,a)}static pathL(t){const{current:e}=t;return{current:e,point:t.getAsCurrentPoint()}}pathL(t,e){const{pathParser:i}=this,{current:A,point:n}=jt.pathL(i),{x:a,y:r}=n;i.addMarker(n,A),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathH(t){const{current:e,command:i}=t,A=new rt(((null==i?void 0:i.relative)?e.x:0)+i.x,e.y);return t.current=A,{current:e,point:A}}pathH(t,e){const{pathParser:i}=this,{current:A,point:n}=jt.pathH(i),{x:a,y:r}=n;i.addMarker(n,A),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathV(t){const{current:e,command:i}=t,A=new rt(e.x,(i.relative?e.y:0)+i.y);return t.current=A,{current:e,point:A}}pathV(t,e){const{pathParser:i}=this,{current:A,point:n}=jt.pathV(i),{x:a,y:r}=n;i.addMarker(n,A),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathC(t){const{current:e}=t;return{current:e,point:t.getPoint("x1","y1"),controlPoint:t.getAsControlPoint("x2","y2"),currentPoint:t.getAsCurrentPoint()}}pathC(t,e){const{pathParser:i}=this,{current:A,point:n,controlPoint:a,currentPoint:r}=jt.pathC(i);i.addMarker(r,a,n),e.addBezierCurve(A.x,A.y,n.x,n.y,a.x,a.y,r.x,r.y),t&&t.bezierCurveTo(n.x,n.y,a.x,a.y,r.x,r.y)}static pathS(t){const{current:e}=t;return{current:e,point:t.getReflectedControlPoint(),controlPoint:t.getAsControlPoint("x2","y2"),currentPoint:t.getAsCurrentPoint()}}pathS(t,e){const{pathParser:i}=this,{current:A,point:n,controlPoint:a,currentPoint:r}=jt.pathS(i);i.addMarker(r,a,n),e.addBezierCurve(A.x,A.y,n.x,n.y,a.x,a.y,r.x,r.y),t&&t.bezierCurveTo(n.x,n.y,a.x,a.y,r.x,r.y)}static pathQ(t){const{current:e}=t;return{current:e,controlPoint:t.getAsControlPoint("x1","y1"),currentPoint:t.getAsCurrentPoint()}}pathQ(t,e){const{pathParser:i}=this,{current:A,controlPoint:n,currentPoint:a}=jt.pathQ(i);i.addMarker(a,n,n),e.addQuadraticCurve(A.x,A.y,n.x,n.y,a.x,a.y),t&&t.quadraticCurveTo(n.x,n.y,a.x,a.y)}static pathT(t){const{current:e}=t,i=t.getReflectedControlPoint();t.control=i;return{current:e,controlPoint:i,currentPoint:t.getAsCurrentPoint()}}pathT(t,e){const{pathParser:i}=this,{current:A,controlPoint:n,currentPoint:a}=jt.pathT(i);i.addMarker(a,n,n),e.addQuadraticCurve(A.x,A.y,n.x,n.y,a.x,a.y),t&&t.quadraticCurveTo(n.x,n.y,a.x,a.y)}static pathA(t){const{current:e,command:i}=t;let{rX:A,rY:n,xRot:a,lArcFlag:r,sweepFlag:s}=i;const o=a*(Math.PI/180),c=t.getAsCurrentPoint(),l=new rt(Math.cos(o)*(e.x-c.x)/2+Math.sin(o)*(e.y-c.y)/2,-Math.sin(o)*(e.x-c.x)/2+Math.cos(o)*(e.y-c.y)/2),g=Math.pow(l.x,2)/Math.pow(A,2)+Math.pow(l.y,2)/Math.pow(n,2);g>1&&(A*=Math.sqrt(g),n*=Math.sqrt(g));let h=(r===s?-1:1)*Math.sqrt((Math.pow(A,2)*Math.pow(n,2)-Math.pow(A,2)*Math.pow(l.y,2)-Math.pow(n,2)*Math.pow(l.x,2))/(Math.pow(A,2)*Math.pow(l.y,2)+Math.pow(n,2)*Math.pow(l.x,2)));isNaN(h)&&(h=0);const d=new rt(h*A*l.y/n,h*-n*l.x/A),u=new rt((e.x+c.x)/2+Math.cos(o)*d.x-Math.sin(o)*d.y,(e.y+c.y)/2+Math.sin(o)*d.x+Math.cos(o)*d.y),w=V([1,0],[(l.x-d.x)/A,(l.y-d.y)/n]),B=[(l.x-d.x)/A,(l.y-d.y)/n],p=[(-l.x-d.x)/A,(-l.y-d.y)/n];let E=V(B,p);return j(B,p)<=-1&&(E=Math.PI),j(B,p)>=1&&(E=0),{currentPoint:c,rX:A,rY:n,sweepFlag:s,xAxisRotation:o,centp:u,a1:w,ad:E}}pathA(t,e){const{pathParser:i}=this,{currentPoint:A,rX:n,rY:a,sweepFlag:r,xAxisRotation:s,centp:o,a1:c,ad:l}=jt.pathA(i),g=1-r?1:-1,h=c+g*(l/2),d=new rt(o.x+n*Math.cos(h),o.y+a*Math.sin(h));if(i.addMarkerAngle(d,h-g*Math.PI/2),i.addMarkerAngle(A,h-g*Math.PI),e.addPoint(A.x,A.y),t&&!isNaN(c)&&!isNaN(l)){const e=n>a?n:a,i=n>a?1:n/a,A=n>a?a/n:1;t.translate(o.x,o.y),t.rotate(s),t.scale(i,A),t.arc(0,0,e,c,c+l,Boolean(1-r)),t.scale(1/i,1/A),t.rotate(-s),t.translate(-o.x,-o.y)}}static pathZ(t){t.current=t.start}pathZ(t,e){jt.pathZ(this.pathParser),t&&e.x1!==e.x2&&e.y1!==e.y2&&t.closePath()}constructor(t,e,i){super(t,e,i),zt(this,"type","path"),zt(this,"pathParser",void 0),this.pathParser=new Lt(this.getAttribute("d").getString())}}function Vt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Kt extends kt{setContext(t){var e;const{document:i}=this,{screen:A,window:n}=i,a=t.canvas;if(A.setDefaults(t),"style"in a&&void 0!==t.font&&n&&void 0!==n.getComputedStyle){t.font=n.getComputedStyle(a).getPropertyValue("font");const e=new et(i,"fontSize",Pt.parse(t.font).fontSize);e.hasValue()&&(i.rootEmSize=e.getPixels("y"),i.emSize=i.rootEmSize)}this.getAttribute("x").hasValue()||this.getAttribute("x",!0).setValue(0),this.getAttribute("y").hasValue()||this.getAttribute("y",!0).setValue(0);let{width:r,height:s}=A.viewPort;this.getStyle("width").hasValue()||this.getStyle("width",!0).setValue("100%"),this.getStyle("height").hasValue()||this.getStyle("height",!0).setValue("100%"),this.getStyle("color").hasValue()||this.getStyle("color",!0).setValue("black");const o=this.getAttribute("refX"),c=this.getAttribute("refY"),l=this.getAttribute("viewBox"),g=l.hasValue()?Y(l.getString()):null,h=!this.root&&"visible"!==this.getStyle("overflow").getValue("hidden");let d=0,u=0,w=0,B=0;g&&(d=g[0],u=g[1]),this.root||(r=this.getStyle("width").getPixels("x"),s=this.getStyle("height").getPixels("y"),"marker"===this.type&&(w=d,B=u,d=0,u=0)),A.viewPort.setCurrent(r,s),!this.node||this.parent&&"foreignObject"!==(null===(e=this.node.parentNode)||void 0===e?void 0:e.nodeName)||!this.getStyle("transform",!1,!0).hasValue()||this.getStyle("transform-origin",!1,!0).hasValue()||this.getStyle("transform-origin",!0,!0).setValue("50% 50%"),super.setContext(t),t.translate(this.getAttribute("x").getPixels("x"),this.getAttribute("y").getPixels("y")),g&&(r=g[2],s=g[3]),i.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:A.viewPort.width,desiredWidth:r,height:A.viewPort.height,desiredHeight:s,minX:d,minY:u,refX:o.getValue(),refY:c.getValue(),clip:h,clipX:w,clipY:B}),g&&(A.viewPort.removeCurrent(),A.viewPort.setCurrent(r,s))}clearContext(t){super.clearContext(t),this.document.screen.viewPort.removeCurrent()}resize(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const A=this.getAttribute("width",!0),n=this.getAttribute("height",!0),a=this.getAttribute("viewBox"),r=this.getAttribute("style"),s=A.getNumber(0),o=n.getNumber(0);if(i)if("string"==typeof i)this.getAttribute("preserveAspectRatio",!0).setValue(i);else{const t=this.getAttribute("preserveAspectRatio");t.hasValue()&&t.setValue(t.getString().replace(/^\s*(\S.*\S)\s*$/,"$1"))}if(A.setValue(t),n.setValue(e),a.hasValue()||a.setValue(`0 0 ${s||t} ${o||e}`),r.hasValue()){const i=this.getStyle("width"),A=this.getStyle("height");i.hasValue()&&i.setValue(`${t}px`),A.hasValue()&&A.setValue(`${e}px`)}}constructor(...t){super(...t),Vt(this,"type","svg"),Vt(this,"root",!1)}}class Wt extends jt{path(t){const e=this.getAttribute("x").getPixels("x"),i=this.getAttribute("y").getPixels("y"),A=this.getStyle("width",!1,!0).getPixels("x"),n=this.getStyle("height",!1,!0).getPixels("y"),a=this.getAttribute("rx"),r=this.getAttribute("ry");let s=a.getPixels("x"),o=r.getPixels("y");if(a.hasValue()&&!r.hasValue()&&(o=s),r.hasValue()&&!a.hasValue()&&(s=o),s=Math.min(s,A/2),o=Math.min(o,n/2),t){const a=(Math.sqrt(2)-1)/3*4;t.beginPath(),n>0&&A>0&&(t.moveTo(e+s,i),t.lineTo(e+A-s,i),t.bezierCurveTo(e+A-s+a*s,i,e+A,i+o-a*o,e+A,i+o),t.lineTo(e+A,i+n-o),t.bezierCurveTo(e+A,i+n-o+a*o,e+A-s+a*s,i+n,e+A-s,i+n),t.lineTo(e+s,i+n),t.bezierCurveTo(e+s-a*s,i+n,e,i+n-o+a*o,e,i+n-o),t.lineTo(e,i+o),t.bezierCurveTo(e,i+o-a*o,e+s-a*s,i,e+s,i),t.closePath())}return new Rt(e,i,e+A,i+n)}getMarkers(){return null}constructor(...t){var e,i,A;super(...t),A="rect",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}}function Xt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class qt extends jt{path(t){const{points:e}=this,[{x:i,y:A}]=e,n=new Rt(i,A);return t&&(t.beginPath(),t.moveTo(i,A)),e.forEach((e=>{let{x:i,y:A}=e;n.addPoint(i,A),t&&t.lineTo(i,A)})),n}getMarkers(){const{points:t}=this,e=t.length-1,i=[];return t.forEach(((A,n)=>{n!==e&&i.push([A,A.angleTo(t[n+1])])})),i.length>0&&i.push([t[t.length-1],i[i.length-1][1]]),i}constructor(t,e,i){super(t,e,i),Xt(this,"type","polyline"),Xt(this,"points",[]),this.points=rt.parsePath(this.getAttribute("points").getString())}}class Zt extends kt{getBoundingBox(t){const e=new Rt;return this.children.forEach((i=>{i instanceof jt&&e.addBoundingBox(i.getBoundingBox(t))})),e}constructor(...t){var e,i,A;super(...t),A="g",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}}function $t(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class _t extends vt{getGradientUnits(){return this.getAttribute("gradientUnits").getString("objectBoundingBox")}createGradient(t,e,i){let A=this;this.getHrefAttribute().hasValue()&&(A=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(A));const{stops:n}=A,a=this.getGradient(t,e);if(!a)return this.addParentOpacity(i,n[n.length-1].color);if(n.forEach((t=>{a.addColorStop(t.offset,this.addParentOpacity(i,t.color))})),this.getAttribute("gradientTransform").hasValue()){const{document:t}=this,{MAX_VIRTUAL_PIXELS:e}=ht,{viewPort:i}=t.screen,A=i.getRoot(),n=new Wt(t);n.attributes.x=new et(t,"x",-e/3),n.attributes.y=new et(t,"y",-e/3),n.attributes.width=new et(t,"width",e),n.attributes.height=new et(t,"height",e);const r=new Zt(t);r.attributes.transform=new et(t,"transform",this.getAttribute("gradientTransform").getValue()),r.children=[n];const s=new Kt(t);s.attributes.x=new et(t,"x",0),s.attributes.y=new et(t,"y",0),s.attributes.width=new et(t,"width",A.width),s.attributes.height=new et(t,"height",A.height),s.children=[r];const o=t.createCanvas(A.width,A.height),c=o.getContext("2d");return c.fillStyle=a,s.render(c),c.createPattern(o,"no-repeat")}return a}inheritStopContainer(t){this.attributesToInherit.forEach((e=>{!this.getAttribute(e).hasValue()&&t.getAttribute(e).hasValue()&&this.getAttribute(e,!0).setValue(t.getAttribute(e).getValue())}))}addParentOpacity(t,e){if(t.hasValue()){return new et(this.document,"color",e).addOpacity(t).getColor()}return e}constructor(t,e,i){super(t,e,i),$t(this,"attributesToInherit",["gradientUnits"]),$t(this,"stops",[]);const{stops:A,children:n}=this;n.forEach((t=>{"stop"===t.type&&A.push(t)}))}}function te(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ee(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ie extends vt{getProperty(){var t;const e=this.getAttribute("attributeType").getString(),i=this.getAttribute("attributeName").getString();var A;return"CSS"===e?null===(A=this.parent)||void 0===A?void 0:A.getStyle(i,!0):null===(t=this.parent)||void 0===t?void 0:t.getAttribute(i,!0)}calcValue(){const{initialUnits:t}=this,{progress:e,from:i,to:A}=this.getProgress();let n=i.getNumber()+(A.getNumber()-i.getNumber())*e;return"%"===t&&(n*=100),`${n}${t}`}update(t){const{parent:e}=this,i=this.getProperty();if(!i)return!1;if(this.initialValue||(this.initialValue=i.getString(),this.initialUnits=i.getUnits()),this.duration>this.maxDuration){const t=this.getAttribute("fill").getString("remove");if("indefinite"===this.getAttribute("repeatCount").getString()||"indefinite"===this.getAttribute("repeatDur").getString())this.duration=0;else if("freeze"!==t||this.frozen){if("remove"===t&&!this.removed)return this.removed=!0,e&&i&&i.setValue(e.animationFrozen?e.animationFrozenValue:this.initialValue),!0}else this.frozen=!0,e&&i&&(e.animationFrozen=!0,e.animationFrozenValue=i.getString());return!1}this.duration+=t;let A=!1;if(this.begin<this.duration){let t=this.calcValue();const e=this.getAttribute("type");if(e.hasValue()){t=`${e.getString()}(${t})`}i.setValue(t),A=!0}return A}getProgress(){const{document:t,values:e}=this;let i,A,n=(this.duration-this.begin)/(this.maxDuration-this.begin);if(e.hasValue()){const a=n*(e.getValue().length-1),r=Math.floor(a),s=Math.ceil(a);let o;o=e.getValue()[r],i=new et(t,"from",o?parseFloat(o):0),o=e.getValue()[s],A=new et(t,"to",o?parseFloat(o):0),n=(a-r)/(s-r)}else i=this.from,A=this.to;return{progress:n,from:i,to:A}}constructor(t,e,i){super(t,e,i),ee(this,"type","animate"),ee(this,"begin",void 0),ee(this,"maxDuration",void 0),ee(this,"from",void 0),ee(this,"to",void 0),ee(this,"values",void 0),ee(this,"duration",0),ee(this,"initialValue",void 0),ee(this,"initialUnits",""),ee(this,"removed",!1),ee(this,"frozen",!1),t.screen.animations.push(this),this.begin=this.getAttribute("begin").getMilliseconds(),this.maxDuration=this.begin+this.getAttribute("dur").getMilliseconds(),this.from=this.getAttribute("from"),this.to=this.getAttribute("to"),this.values=new et(t,"values",null);const A=this.getAttribute("values");A.hasValue()&&this.values.setValue(A.getString().split(";"))}}function Ae(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ne extends vt{constructor(t,e,i){super(t,e,i),Ae(this,"type","font-face"),Ae(this,"ascent",void 0),Ae(this,"descent",void 0),Ae(this,"unitsPerEm",void 0),this.ascent=this.getAttribute("ascent").getNumber(),this.descent=this.getAttribute("descent").getNumber(),this.unitsPerEm=this.getAttribute("units-per-em").getNumber()}}function ae(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class re extends jt{constructor(t,e,i){super(t,e,i),ae(this,"type","glyph"),ae(this,"horizAdvX",void 0),ae(this,"unicode",void 0),ae(this,"arabicForm",void 0),this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber(),this.unicode=this.getAttribute("unicode").getString(),this.arabicForm=this.getAttribute("arabic-form").getString()}}function se(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class oe extends re{constructor(...t){super(...t),se(this,"type","missing-glyph"),se(this,"horizAdvX",0)}}function ce(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function le(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ge(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function he(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const de=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*)$/i;function ue(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class we{async load(t,e){try{const{document:i}=this,A=(await i.pith.parser.load(e)).getElementsByTagName("font");Array.from(A).forEach((e=>{const A=i.createElement(e);i.definitions[t]=A}))}catch(t){console.error(`Error while loading font "${e}":`,t)}this.loaded=!0}constructor(t){ue(this,"document",void 0),ue(this,"loaded",void 0),this.document=t,this.loaded=!1,t.fonts.push(this)}}function Be(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class pe extends vt{constructor(t,e,i){super(t,e,i),Be(this,"type","style");b(Array.from(e.childNodes).map((t=>t.textContent)).join("").replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"").replace(/@import.*;/g,"")).split("}").forEach((e=>{const i=e.trim();if(!i)return;const A=i.split("{"),n=A[0].split(","),a=A[1].split(";");n.forEach((e=>{const i=e.trim();if(!i)return;const A=t.styles[i]||{};if(a.forEach((e=>{const i=e.indexOf(":"),n=e.substr(0,i).trim(),a=e.substr(i+1,e.length-i).trim();n&&a&&(A[n]=new et(t,n,a))})),t.styles[i]=A,t.stylesSpecificity[i]=function(t){const e=[0,0,0];let i=t.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),A=0;return[i,A]=J(i,R),e[1]+=A,[i,A]=J(i,k),e[0]+=A,[i,A]=J(i,H),e[1]+=A,[i,A]=J(i,U),e[2]+=A,[i,A]=J(i,G),e[1]+=A,[i,A]=J(i,T),e[1]+=A,i=i.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),[i,A]=J(i,O),e[2]+=A,e.join("")}(i),"@font-face"===i){const e=A["font-family"].getString().replace(/"|'/g,"");A.src.getString().split(",").forEach((i=>{if(i.indexOf('format("svg")')>0){const A=N(i);A&&new we(t).load(e,A)}}))}}))}))}}function Ee(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}Be(pe,"parseExternalUrl",N);function me(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function fe(t,e,i,A,n,a){return t[i*A*4+4*e+a]}function Ce(t,e,i,A,n,a,r){t[i*A*4+4*e+a]=r}function Qe(t,e,i){return t[e]*i}function ye(t,e,i,A){return e+Math.cos(t)*i+Math.sin(t)*A}class De extends vt{apply(t,e,i,A,n){const{includeOpacity:a,matrix:r}=this,s=t.getImageData(0,0,A,n);for(let t=0;t<n;t++)for(let e=0;e<A;e++){const i=fe(s.data,e,t,A,0,0),n=fe(s.data,e,t,A,0,1),o=fe(s.data,e,t,A,0,2),c=fe(s.data,e,t,A,0,3);let l=Qe(r,0,i)+Qe(r,1,n)+Qe(r,2,o)+Qe(r,3,c)+Qe(r,4,1),g=Qe(r,5,i)+Qe(r,6,n)+Qe(r,7,o)+Qe(r,8,c)+Qe(r,9,1),h=Qe(r,10,i)+Qe(r,11,n)+Qe(r,12,o)+Qe(r,13,c)+Qe(r,14,1),d=Qe(r,15,i)+Qe(r,16,n)+Qe(r,17,o)+Qe(r,18,c)+Qe(r,19,1);a&&(l=0,g=0,h=0,d*=c/255),Ce(s.data,e,t,A,0,0,l),Ce(s.data,e,t,A,0,1,g),Ce(s.data,e,t,A,0,2,h),Ce(s.data,e,t,A,0,3,d)}t.clearRect(0,0,A,n),t.putImageData(s,0,0)}constructor(t,e,i){super(t,e,i),me(this,"type","feColorMatrix"),me(this,"matrix",void 0),me(this,"includeOpacity",void 0);let A=Y(this.getAttribute("values").getString());switch(this.getAttribute("type").getString("matrix")){case"saturate":{const t=A[0];A=[.213+.787*t,.715-.715*t,.072-.072*t,0,0,.213-.213*t,.715+.285*t,.072-.072*t,0,0,.213-.213*t,.715-.715*t,.072+.928*t,0,0,0,0,0,1,0,0,0,0,0,1];break}case"hueRotate":{const t=A[0]*Math.PI/180;A=[ye(t,.213,.787,-.213),ye(t,.715,-.715,-.715),ye(t,.072,-.072,.928),0,0,ye(t,.213,-.213,.143),ye(t,.715,.285,.14),ye(t,.072,-.072,-.283),0,0,ye(t,.213,-.213,-.787),ye(t,.715,-.715,.715),ye(t,.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break}case"luminanceToAlpha":A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.2125,.7154,.0721,0,0,0,0,0,0,1]}this.matrix=A,this.includeOpacity=this.getAttribute("includeOpacity").hasValue()}}function Ie(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class xe extends vt{apply(t,e){const{document:i}=this;let A=this.getAttribute("x").getPixels("x"),n=this.getAttribute("y").getPixels("y"),a=this.getStyle("width").getPixels("x"),r=this.getStyle("height").getPixels("y");if(!a&&!r){const e=new Rt;this.children.forEach((i=>{i instanceof jt&&e.addBoundingBox(i.getBoundingBox(t))})),A=Math.floor(e.x1),n=Math.floor(e.y1),a=Math.floor(e.width),r=Math.floor(e.height)}const s=this.removeStyles(e,xe.ignoreStyles),o=i.createCanvas(A+a,n+r),c=o.getContext("2d");i.screen.setDefaults(c),this.renderChildren(c),new De(i,{nodeType:1,childNodes:[],attributes:[{nodeName:"type",value:"luminanceToAlpha"},{nodeName:"includeOpacity",value:"true"}]}).apply(c,0,0,A+a,n+r);const l=i.createCanvas(A+a,n+r),g=l.getContext("2d");i.screen.setDefaults(g),e.render(g),g.globalCompositeOperation="destination-in",g.fillStyle=c.createPattern(o,"no-repeat"),g.fillRect(0,0,A+a,n+r),t.fillStyle=g.createPattern(l,"no-repeat"),t.fillRect(0,0,A+a,n+r),this.restoreStyles(e,s)}render(t){}constructor(...t){super(...t),Ie(this,"type","mask")}}Ie(xe,"ignoreStyles",["mask","transform","clip-path"]);const ve=()=>{};function Me(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Se extends vt{apply(t,e,i,A,n){const{document:a,blurRadius:r}=this,s=a.window?a.window.document.body:null,o=t.canvas;o.id=a.getUniqueId(),s&&(o.style.display="none",s.appendChild(o)),(0,p.canvasRGBA)(o,e,i,A,n,r),s&&s.removeChild(o)}constructor(t,e,i){super(t,e,i),Me(this,"type","feGaussianBlur"),Me(this,"extraFilterDistance",void 0),Me(this,"blurRadius",void 0),this.blurRadius=Math.floor(this.getAttribute("stdDeviation").getNumber()),this.extraFilterDistance=this.blurRadius}}function Fe(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class be extends vt{apply(t,e){const{document:i,children:A}=this,n="getBoundingBox"in e?e.getBoundingBox(t):null;if(!n)return;let a=0,r=0;A.forEach((t=>{if(!(t instanceof Se))return;const e=t.extraFilterDistance||0;a=Math.max(a,e),r=Math.max(r,e)}));const s=Math.floor(n.width),o=Math.floor(n.height),c=s+2*a,l=o+2*r;if(Number.isNaN(c)||Number.isNaN(l)||c<1||l<1)return;const g=Math.floor(n.x),h=Math.floor(n.y),d=this.removeStyles(e,be.ignoreStyles),u=i.createCanvas(c,l),w=u.getContext("2d");i.screen.setDefaults(w),w.translate(-g+a,-h+r),e.render(w),A.forEach((t=>{t instanceof Se&&"function"==typeof t.apply&&t.apply(w,0,0,c,l)})),t.drawImage(u,0,0,c,l,g-a,h-r,c,l),this.restoreStyles(e,d)}render(t){}constructor(...t){super(...t),Fe(this,"type","filter")}}Fe(be,"ignoreStyles",["filter","transform","clip-path"]);const Ye={svg:Kt,rect:Wt,circle:class extends jt{path(t){const e=this.getAttribute("cx").getPixels("x"),i=this.getAttribute("cy").getPixels("y"),A=this.getAttribute("r").getPixels();return t&&A>0&&(t.beginPath(),t.arc(e,i,A,0,2*Math.PI,!1),t.closePath()),new Rt(e-A,i-A,e+A,i+A)}getMarkers(){return null}constructor(...t){var e,i,A;super(...t),A="circle",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},ellipse:class extends jt{path(t){const e=(Math.sqrt(2)-1)/3*4,i=this.getAttribute("rx").getPixels("x"),A=this.getAttribute("ry").getPixels("y"),n=this.getAttribute("cx").getPixels("x"),a=this.getAttribute("cy").getPixels("y");return t&&i>0&&A>0&&(t.beginPath(),t.moveTo(n+i,a),t.bezierCurveTo(n+i,a+e*A,n+e*i,a+A,n,a+A),t.bezierCurveTo(n-e*i,a+A,n-i,a+e*A,n-i,a),t.bezierCurveTo(n-i,a-e*A,n-e*i,a-A,n,a-A),t.bezierCurveTo(n+e*i,a-A,n+i,a-e*A,n+i,a),t.closePath()),new Rt(n-i,a-A,n+i,a+A)}getMarkers(){return null}constructor(...t){var e,i,A;super(...t),A="ellipse",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},line:class extends jt{getPoints(){return[new rt(this.getAttribute("x1").getPixels("x"),this.getAttribute("y1").getPixels("y")),new rt(this.getAttribute("x2").getPixels("x"),this.getAttribute("y2").getPixels("y"))]}path(t){const[{x:e,y:i},{x:A,y:n}]=this.getPoints();return t&&(t.beginPath(),t.moveTo(e,i),t.lineTo(A,n)),new Rt(e,i,A,n)}getMarkers(){const[t,e]=this.getPoints(),i=t.angleTo(e);return[[t,i],[e,i]]}constructor(...t){var e,i,A;super(...t),A="line",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},polyline:qt,polygon:class extends qt{path(t){const e=super.path(t),[{x:i,y:A}]=this.points;return t&&(t.lineTo(i,A),t.closePath()),e}constructor(...t){var e,i,A;super(...t),A="polygon",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},path:jt,pattern:class extends vt{createPattern(t,e,i){const A=this.getStyle("width").getPixels("x",!0),n=this.getStyle("height").getPixels("y",!0),a=this.getAttribute("data-frame-width"),r=this.getAttribute("data-frame-height"),s=a.hasValue()?a.getPixels("x",!0):A,o=r.hasValue()?r.getPixels("y",!0):n,c=a.hasValue()&&r.hasValue(),l=new Kt(this.document,void 0);l.attributes.viewBox=new et(this.document,"viewBox",this.getAttribute("viewBox").getValue()),l.attributes.width=new et(this.document,"width",`${s}px`),l.attributes.height=new et(this.document,"height",`${o}px`),l.attributes.transform=new et(this.document,"transform",this.getAttribute("patternTransform").getValue()),l.children=this.children;const g=this.document.createCanvas(s,o),h=g.getContext("2d");h.imageSmoothingEnabled=!0,h.imageSmoothingQuality="high";const d=this.getAttribute("x"),u=this.getAttribute("y");d.hasValue()&&u.hasValue()&&h.translate(d.getPixels("x",!0),u.getPixels("y",!0)),i.hasValue()?this.styles["fill-opacity"]=i:Reflect.deleteProperty(this.styles,"fill-opacity");for(let t=-1;t<=1;t++)for(let e=-1;e<=1;e++)h.save(),l.attributes.x=new et(this.document,"x",t*g.width),l.attributes.y=new et(this.document,"y",e*g.height),l.render(h),h.restore();return t.createPattern(g,c?"no-repeat":"repeat")}constructor(...t){var e,i,A;super(...t),A="pattern",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},marker:class extends vt{render(t,e,i){if(!e)return;const{x:A,y:n}=e,a=this.getAttribute("orient").getString("auto"),r=this.getAttribute("markerUnits").getString("strokeWidth");t.translate(A,n),"auto"===a&&i&&t.rotate(i),"strokeWidth"===r&&t.scale(t.lineWidth,t.lineWidth),t.save();const s=new Kt(this.document);s.type=this.type,s.attributes.viewBox=new et(this.document,"viewBox",this.getAttribute("viewBox").getValue()),s.attributes.refX=new et(this.document,"refX",this.getAttribute("refX").getValue()),s.attributes.refY=new et(this.document,"refY",this.getAttribute("refY").getValue()),s.attributes.width=new et(this.document,"width",this.getAttribute("markerWidth").getValue()),s.attributes.height=new et(this.document,"height",this.getAttribute("markerHeight").getValue()),s.attributes.overflow=new et(this.document,"overflow",this.getAttribute("overflow").getValue()),s.attributes.fill=new et(this.document,"fill",this.getAttribute("fill").getColor("black")),s.attributes.stroke=new et(this.document,"stroke",this.getAttribute("stroke").getValue("none")),s.children=this.children,s.render(t),t.restore(),"strokeWidth"===r&&t.scale(1/t.lineWidth,1/t.lineWidth),"auto"===a&&i&&t.rotate(-i),t.translate(-A,-n)}constructor(...t){var e,i,A;super(...t),A="marker",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},defs:class extends vt{render(){}constructor(...t){var e,i,A;super(...t),A="defs",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},linearGradient:class extends _t{getGradient(t,e){const i="objectBoundingBox"===this.getGradientUnits(),A=i?e.getBoundingBox(t):null;if(i||!A)return null;this.getAttribute("x1").hasValue()||this.getAttribute("y1").hasValue()||this.getAttribute("x2").hasValue()||this.getAttribute("y2").hasValue()||(this.getAttribute("x1",!0).setValue(0),this.getAttribute("y1",!0).setValue(0),this.getAttribute("x2",!0).setValue(1),this.getAttribute("y2",!0).setValue(0));const n=i?A.x+A.width*this.getAttribute("x1").getNumber():this.getAttribute("x1").getPixels("x"),a=i?A.y+A.height*this.getAttribute("y1").getNumber():this.getAttribute("y1").getPixels("y"),r=i?A.x+A.width*this.getAttribute("x2").getNumber():this.getAttribute("x2").getPixels("x"),s=i?A.y+A.height*this.getAttribute("y2").getNumber():this.getAttribute("y2").getPixels("y");return n===r&&a===s?null:t.createLinearGradient(n,a,r,s)}constructor(t,e,i){var A,n,a;super(t,e,i),a="linearGradient",(n="type")in(A=this)?Object.defineProperty(A,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):A[n]=a,this.attributesToInherit.push("x1","y1","x2","y2")}},radialGradient:class extends _t{getGradient(t,e){const i="objectBoundingBox"===this.getGradientUnits(),A=e.getBoundingBox(t);if(i&&!A)return null;this.getAttribute("cx").hasValue()||this.getAttribute("cx",!0).setValue("50%"),this.getAttribute("cy").hasValue()||this.getAttribute("cy",!0).setValue("50%"),this.getAttribute("r").hasValue()||this.getAttribute("r",!0).setValue("50%");const n=i?A.x+A.width*this.getAttribute("cx").getNumber():this.getAttribute("cx").getPixels("x"),a=i?A.y+A.height*this.getAttribute("cy").getNumber():this.getAttribute("cy").getPixels("y");let r=n,s=a;this.getAttribute("fx").hasValue()&&(r=i?A.x+A.width*this.getAttribute("fx").getNumber():this.getAttribute("fx").getPixels("x")),this.getAttribute("fy").hasValue()&&(s=i?A.y+A.height*this.getAttribute("fy").getNumber():this.getAttribute("fy").getPixels("y"));const o=i?(A.width+A.height)/2*this.getAttribute("r").getNumber():this.getAttribute("r").getPixels(),c=this.getAttribute("fr").getPixels();return t.createRadialGradient(r,s,c,n,a,o)}constructor(t,e,i){var A,n,a;super(t,e,i),a="radialGradient",(n="type")in(A=this)?Object.defineProperty(A,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):A[n]=a,this.attributesToInherit.push("cx","cy","r","fx","fy","fr")}},stop:class extends vt{constructor(t,e,i){super(t,e,i),te(this,"type","stop"),te(this,"offset",void 0),te(this,"color",void 0);const A=Math.max(0,Math.min(1,this.getAttribute("offset").getNumber())),n=this.getStyle("stop-opacity");let a=this.getStyle("stop-color",!0);""===a.getString()&&a.setValue("#000"),n.hasValue()&&(a=a.addOpacity(n)),this.offset=A,this.color=a.getColor()}},animate:ie,animateColor:class extends ie{calcValue(){const{progress:t,from:e,to:i}=this.getProgress(),A=new(F(w))(e.getColor()),n=new(F(w))(i.getColor());if(A.ok&&n.ok){const e=A.r+(n.r-A.r)*t,i=A.g+(n.g-A.g)*t,a=A.b+(n.b-A.b)*t;return`rgb(${Math.floor(e)}, ${Math.floor(i)}, ${Math.floor(a)})`}return this.getAttribute("from").getColor()}constructor(...t){var e,i,A;super(...t),A="animateColor",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},animateTransform:class extends ie{calcValue(){const{progress:t,from:e,to:i}=this.getProgress(),A=Y(e.getString()),n=Y(i.getString()),a=A.map(((e,i)=>e+(n[i]-e)*t)).join(" ");return a}constructor(...t){var e,i,A;super(...t),A="animateTransform",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},font:class extends vt{render(){}constructor(t,e,i){super(t,e,i),ce(this,"type","font"),ce(this,"isArabic",!1),ce(this,"missingGlyph",void 0),ce(this,"glyphs",{}),ce(this,"arabicGlyphs",{}),ce(this,"horizAdvX",void 0),ce(this,"isRTL",!1),ce(this,"fontFace",void 0),this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber();const{definitions:A}=t,{children:n}=this;for(const t of n)if(t instanceof ne){this.fontFace=t;const e=t.getStyle("font-family");e.hasValue()&&(A[e.getString()]=this)}else if(t instanceof oe)this.missingGlyph=t;else if(t instanceof re)if(t.arabicForm){this.isRTL=!0,this.isArabic=!0;const e=this.arabicGlyphs[t.unicode];void 0===e?this.arabicGlyphs[t.unicode]={[t.arabicForm]:t}:e[t.arabicForm]=t}else this.glyphs[t.unicode]=t}},"font-face":ne,"missing-glyph":oe,glyph:re,text:Ut,tspan:Tt,tref:class extends Ut{getText(){const t=this.getHrefAttribute().getDefinition();if(t){const e=t.children[0];if(e)return e.getText()}return""}constructor(...t){var e,i,A;super(...t),A="tref",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},a:class extends Ut{getText(){return this.text}renderChildren(t){if(this.hasText){super.renderChildren(t);const{document:e,x:i,y:A}=this,{mouse:n}=e.screen,a=new et(e,"fontSize",Pt.parse(e.ctx.font).fontSize);n.isWorking()&&n.checkBoundingBox(this,new Rt(i,A-a.getPixels("y"),i+this.measureText(t),A))}else if(this.children.length>0){const e=new Zt(this.document);e.children=this.children,e.parent=this,e.render(t)}}onClick(){const{window:t}=this.document;t&&t.open(this.getHrefAttribute().getString())}onMouseMove(){this.document.ctx.canvas.style.cursor="pointer"}constructor(t,e,i){super(t,e,i),le(this,"type","a"),le(this,"hasText",void 0),le(this,"text",void 0);const{childNodes:A}=e,n=A[0],a=A.length>0&&Array.from(A).every((t=>3===t.nodeType));this.hasText=a,this.text=a?this.getTextFromNode(n):""}},textPath:class extends Ut{getText(){return this.text}path(t){const{dataArray:e}=this;t&&t.beginPath(),e.forEach((e=>{let{type:i,points:A}=e;switch(i){case Lt.LINE_TO:t&&t.lineTo(A[0],A[1]);break;case Lt.MOVE_TO:t&&t.moveTo(A[0],A[1]);break;case Lt.CURVE_TO:t&&t.bezierCurveTo(A[0],A[1],A[2],A[3],A[4],A[5]);break;case Lt.QUAD_TO:t&&t.quadraticCurveTo(A[0],A[1],A[2],A[3]);break;case Lt.ARC:{const[e,i,n,a,r,s,o,c]=A,l=n>a?n:a,g=n>a?1:n/a,h=n>a?a/n:1;t&&(t.translate(e,i),t.rotate(o),t.scale(g,h),t.arc(0,0,l,r,r+s,Boolean(1-c)),t.scale(1/g,1/h),t.rotate(-o),t.translate(-e,-i));break}case Lt.CLOSE_PATH:t&&t.closePath()}}))}renderChildren(t){var e;this.setTextData(t),t.save();const i=null===(e=this.parent)||void 0===e?void 0:e.getStyle("text-decoration").getString(),A=this.getFontSize(),{glyphInfo:n}=this,a=t.fillStyle;"underline"===i&&t.beginPath(),n.forEach(((e,n)=>{const{p0:a,p1:r,rotation:s,text:o}=e;t.save(),t.translate(a.x,a.y),t.rotate(s),t.fillStyle&&t.fillText(o,0,0),t.strokeStyle&&t.strokeText(o,0,0),t.restore(),"underline"===i&&(0===n&&t.moveTo(a.x,a.y+A/8),t.lineTo(r.x,r.y+A/5))})),"underline"===i&&(t.lineWidth=A/20,t.strokeStyle=a,t.stroke(),t.closePath()),t.restore()}getLetterSpacingAt(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.letterSpacingCache[t]||0}findSegmentToFitChar(t,e,i,A,n,a,r,s,o){let c=a,l=this.measureText(t,s);" "===s&&"justify"===e&&i<A&&(l+=(A-i)/n),o>-1&&(c+=this.getLetterSpacingAt(o));const g=this.textHeight/20,h=this.getEquidistantPointOnPath(c,g,0),d=this.getEquidistantPointOnPath(c+l,g,0),u={p0:h,p1:d},w=h&&d?Math.atan2(d.y-h.y,d.x-h.x):0;if(r){const t=Math.cos(Math.PI/2+w)*r,e=Math.cos(-w)*r;u.p0={...h,distance:h.distance||0,x:h.x+t,y:h.y+e},u.p1={...d,distance:d.distance||0,x:d.x+t,y:d.y+e}}return c+=l,{offset:c,segment:u,rotation:w}}measureText(t,e){const{measuresCache:i}=this,A=e||this.getText();if(i.has(A))return i.get(A);const n=this.measureTargetText(t,A);return i.set(A,n),n}setTextData(t){var e,i,A;if(this.glyphInfo)return;const n=this.getText(),a=n.split(""),r=n.split(" ").length-1,s=null===(e=this.parent)||void 0===e?void 0:e.getAttribute("dx").split().map((t=>t.getPixels("x"))),o=null===(i=this.parent)||void 0===i?void 0:i.getAttribute("dy").getPixels("y"),c=this.getAttribute("text-anchor").getString("start"),l=this.getStyle("letter-spacing"),g=null===(A=this.parent)||void 0===A?void 0:A.getStyle("letter-spacing");let h=0;l.hasValue()&&"inherit"!==l.getValue()?l.hasValue()&&"initial"!==l.getValue()&&"unset"!==l.getValue()&&(h=l.getPixels()):h=g.getPixels();const d=[],u=n.length;this.letterSpacingCache=d;for(let t=0;t<u;t++)d.push(void 0!==s[t]?s[t]:h);const w=d.reduce(((t,e,i)=>0===i?0:t+e||0),0),B=this.measureText(t),p=Math.max(B+w,0);this.textWidth=B,this.textHeight=this.getFontSize(),this.glyphInfo=[];const E=this.getPathLength(),m=this.getAttribute("startOffset").getNumber(0)*E;let f=0;"middle"!==c&&"center"!==c||(f=-p/2),"end"!==c&&"right"!==c||(f=-p),f+=m,a.forEach(((e,i)=>{const{offset:A,segment:n,rotation:s}=this.findSegmentToFitChar(t,c,p,E,r,f,o,e,i);f=A,n.p0&&n.p1&&this.glyphInfo.push({text:a[i],p0:n.p0,p1:n.p1,rotation:s})}))}parsePathData(t){if(this.pathLength=-1,!t)return[];const e=[],{pathParser:i}=t;for(i.reset();!i.isEnd();){const{current:t}=i,A=t?t.x:0,n=t?t.y:0,a=i.next();let r=a.type,s=[];switch(a.type){case Lt.MOVE_TO:this.pathM(i,s);break;case Lt.LINE_TO:r=this.pathL(i,s);break;case Lt.HORIZ_LINE_TO:r=this.pathH(i,s);break;case Lt.VERT_LINE_TO:r=this.pathV(i,s);break;case Lt.CURVE_TO:this.pathC(i,s);break;case Lt.SMOOTH_CURVE_TO:r=this.pathS(i,s);break;case Lt.QUAD_TO:this.pathQ(i,s);break;case Lt.SMOOTH_QUAD_TO:r=this.pathT(i,s);break;case Lt.ARC:s=this.pathA(i);break;case Lt.CLOSE_PATH:jt.pathZ(i)}a.type!==Lt.CLOSE_PATH?e.push({type:r,points:s,start:{x:A,y:n},pathLength:this.calcLength(A,n,r,s)}):e.push({type:Lt.CLOSE_PATH,points:[],pathLength:0})}return e}pathM(t,e){const{x:i,y:A}=jt.pathM(t).point;e.push(i,A)}pathL(t,e){const{x:i,y:A}=jt.pathL(t).point;return e.push(i,A),Lt.LINE_TO}pathH(t,e){const{x:i,y:A}=jt.pathH(t).point;return e.push(i,A),Lt.LINE_TO}pathV(t,e){const{x:i,y:A}=jt.pathV(t).point;return e.push(i,A),Lt.LINE_TO}pathC(t,e){const{point:i,controlPoint:A,currentPoint:n}=jt.pathC(t);e.push(i.x,i.y,A.x,A.y,n.x,n.y)}pathS(t,e){const{point:i,controlPoint:A,currentPoint:n}=jt.pathS(t);return e.push(i.x,i.y,A.x,A.y,n.x,n.y),Lt.CURVE_TO}pathQ(t,e){const{controlPoint:i,currentPoint:A}=jt.pathQ(t);e.push(i.x,i.y,A.x,A.y)}pathT(t,e){const{controlPoint:i,currentPoint:A}=jt.pathT(t);return e.push(i.x,i.y,A.x,A.y),Lt.QUAD_TO}pathA(t){let{rX:e,rY:i,sweepFlag:A,xAxisRotation:n,centp:a,a1:r,ad:s}=jt.pathA(t);return 0===A&&s>0&&(s-=2*Math.PI),1===A&&s<0&&(s+=2*Math.PI),[a.x,a.y,e,i,r,s,n,A]}calcLength(t,e,i,A){let n=0,a=null,r=null,s=0;switch(i){case Lt.LINE_TO:return this.getLineLength(t,e,A[0],A[1]);case Lt.CURVE_TO:for(n=0,a=this.getPointOnCubicBezier(0,t,e,A[0],A[1],A[2],A[3],A[4],A[5]),s=.01;s<=1;s+=.01)r=this.getPointOnCubicBezier(s,t,e,A[0],A[1],A[2],A[3],A[4],A[5]),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return n;case Lt.QUAD_TO:for(n=0,a=this.getPointOnQuadraticBezier(0,t,e,A[0],A[1],A[2],A[3]),s=.01;s<=1;s+=.01)r=this.getPointOnQuadraticBezier(s,t,e,A[0],A[1],A[2],A[3]),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return n;case Lt.ARC:{n=0;const t=A[4],e=A[5],i=A[4]+e;let o=Math.PI/180;if(Math.abs(t-i)<o&&(o=Math.abs(t-i)),a=this.getPointOnEllipticalArc(A[0],A[1],A[2],A[3],t,0),e<0)for(s=t-o;s>i;s-=o)r=this.getPointOnEllipticalArc(A[0],A[1],A[2],A[3],s,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;else for(s=t+o;s<i;s+=o)r=this.getPointOnEllipticalArc(A[0],A[1],A[2],A[3],s,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return r=this.getPointOnEllipticalArc(A[0],A[1],A[2],A[3],i,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),n}}return 0}getPointOnLine(t,e,i,A,n){let a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:i;const s=(n-i)/(A-e+L);let o=Math.sqrt(t*t/(1+s*s));A<e&&(o*=-1);let c=s*o,l=null;if(A===e)l={x:a,y:r+c};else if((r-i)/(a-e+L)===s)l={x:a+o,y:r+c};else{let g=0,h=0;const d=this.getLineLength(e,i,A,n);if(d<L)return null;let u=(a-e)*(A-e)+(r-i)*(n-i);u/=d*d,g=e+u*(A-e),h=i+u*(n-i);const w=this.getLineLength(a,r,g,h),B=Math.sqrt(t*t-w*w);o=Math.sqrt(B*B/(1+s*s)),A<e&&(o*=-1),c=s*o,l={x:g+o,y:h+c}}return l}getPointOnPath(t){const e=this.getPathLength();let i=0,A=null;if(t<-5e-5||t-5e-5>e)return null;const{dataArray:n}=this;for(const e of n){if(e&&(e.pathLength<5e-5||i+e.pathLength+5e-5<t)){i+=e.pathLength;continue}const n=t-i;let a=0;switch(e.type){case Lt.LINE_TO:A=this.getPointOnLine(n,e.start.x,e.start.y,e.points[0],e.points[1],e.start.x,e.start.y);break;case Lt.ARC:{const t=e.points[4],i=e.points[5],r=e.points[4]+i;if(a=t+n/e.pathLength*i,i<0&&a<r||i>=0&&a>r)break;A=this.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],a,e.points[6]);break}case Lt.CURVE_TO:a=n/e.pathLength,a>1&&(a=1),A=this.getPointOnCubicBezier(a,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);break;case Lt.QUAD_TO:a=n/e.pathLength,a>1&&(a=1),A=this.getPointOnQuadraticBezier(a,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3])}if(A)return A;break}return null}getLineLength(t,e,i,A){return Math.sqrt((i-t)*(i-t)+(A-e)*(A-e))}getPathLength(){return-1===this.pathLength&&(this.pathLength=this.dataArray.reduce(((t,e)=>e.pathLength>0?t+e.pathLength:t),0)),this.pathLength}getPointOnCubicBezier(t,e,i,A,n,a,r,s,o){return{x:s*K(t)+a*W(t)+A*X(t)+e*q(t),y:o*K(t)+r*W(t)+n*X(t)+i*q(t)}}getPointOnQuadraticBezier(t,e,i,A,n,a,r){return{x:a*Z(t)+A*$(t)+e*_(t),y:r*Z(t)+n*$(t)+i*_(t)}}getPointOnEllipticalArc(t,e,i,A,n,a){const r=Math.cos(a),s=Math.sin(a),o=i*Math.cos(n),c=A*Math.sin(n);return{x:t+(o*r-c*s),y:e+(o*s+c*r)}}buildEquidistantCache(t,e){const i=this.getPathLength(),A=e||.25,n=t||i/100;if(!this.equidistantCache||this.equidistantCache.step!==n||this.equidistantCache.precision!==A){this.equidistantCache={step:n,precision:A,points:[]};let t=0;for(let e=0;e<=i;e+=A){const i=this.getPointOnPath(e),a=this.getPointOnPath(e+A);i&&a&&(t+=this.getLineLength(i.x,i.y,a.x,a.y),t>=n&&(this.equidistantCache.points.push({x:i.x,y:i.y,distance:e}),t-=n))}}}getEquidistantPointOnPath(t,e,i){if(this.buildEquidistantCache(e,i),t<0||t-this.getPathLength()>5e-5)return null;const A=Math.round(t/this.getPathLength()*(this.equidistantCache.points.length-1));return this.equidistantCache.points[A]||null}constructor(t,e,i){super(t,e,i),ge(this,"type","textPath"),ge(this,"textWidth",0),ge(this,"textHeight",0),ge(this,"pathLength",-1),ge(this,"glyphInfo",null),ge(this,"text",void 0),ge(this,"dataArray",void 0),ge(this,"letterSpacingCache",[]),ge(this,"equidistantCache",null),ge(this,"measuresCache",new Map([["",0]]));const A=this.getHrefAttribute().getDefinition();this.text=this.getTextFromNode(),this.dataArray=this.parsePathData(A)}},image:class extends kt{async loadImage(t){try{const e=await this.document.createImage(t);this.image=e}catch(e){console.error(`Error while loading image "${t}":`,e)}this.loaded=!0}async loadSvg(t){const e=de.exec(t);if(e){const t=e[5];t&&("base64"===e[4]?this.image=atob(t):this.image=decodeURIComponent(t))}else try{const e=await this.document.fetch(t),i=await e.text();this.image=i}catch(e){console.error(`Error while loading image "${t}":`,e)}this.loaded=!0}renderChildren(t){const{document:e,image:i,loaded:A}=this,n=this.getAttribute("x").getPixels("x"),a=this.getAttribute("y").getPixels("y"),r=this.getStyle("width").getPixels("x"),s=this.getStyle("height").getPixels("y");if(A&&i&&r&&s){if(t.save(),t.translate(n,a),"string"==typeof i){const A=e.pith.forkString(t,i,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:0,offsetY:0,scaleWidth:r,scaleHeight:s}),{documentElement:n}=A.document;n&&(n.parent=this),A.resize(r,s,this.getAttribute("preserveAspectRatio").getString()),A.render()}else e.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:r,desiredWidth:i.width,height:s,desiredHeight:i.height}),this.loaded&&("complete"in i&&!i.complete||t.drawImage(i,0,0));t.restore()}}getBoundingBox(){const t=this.getAttribute("x").getPixels("x"),e=this.getAttribute("y").getPixels("y"),i=this.getStyle("width").getPixels("x"),A=this.getStyle("height").getPixels("y");return new Rt(t,e,t+i,e+A)}constructor(t,e,i){super(t,e,i),he(this,"type","image"),he(this,"loaded",!1),he(this,"image",void 0);const A=this.getHrefAttribute().getString();if(!A)return;const n=A.endsWith(".svg")||/^\s*data:image\/svg\+xml/i.test(A);t.images.push(this),n?this.loadSvg(A):this.loadImage(A)}},g:Zt,symbol:class extends kt{render(t){}constructor(...t){var e,i,A;super(...t),A="symbol",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},style:pe,use:class extends kt{setContext(t){super.setContext(t);const e=this.getAttribute("x"),i=this.getAttribute("y");e.hasValue()&&t.translate(e.getPixels("x"),0),i.hasValue()&&t.translate(0,i.getPixels("y"))}path(t){const{element:e}=this;e&&e.path(t)}renderChildren(t){const{document:e,element:i}=this;if(i){let A=i;if("symbol"===i.type&&(A=new Kt(e),A.attributes.viewBox=new et(e,"viewBox",i.getAttribute("viewBox").getString()),A.attributes.preserveAspectRatio=new et(e,"preserveAspectRatio",i.getAttribute("preserveAspectRatio").getString()),A.attributes.overflow=new et(e,"overflow",i.getAttribute("overflow").getString()),A.children=i.children,i.styles.opacity=new et(e,"opacity",this.calculateOpacity())),"svg"===A.type){const t=this.getStyle("width",!1,!0),i=this.getStyle("height",!1,!0);t.hasValue()&&(A.attributes.width=new et(e,"width",t.getString())),i.hasValue()&&(A.attributes.height=new et(e,"height",i.getString()))}const n=A.parent;A.parent=this,A.render(t),A.parent=n}}getBoundingBox(t){const{element:e}=this;return e?e.getBoundingBox(t):null}elementTransform(){const{document:t,element:e}=this;return e?It.fromElement(t,e):null}get element(){return this.cachedElement||(this.cachedElement=this.getHrefAttribute().getDefinition()),this.cachedElement}constructor(...t){super(...t),Ee(this,"type","use"),Ee(this,"cachedElement",void 0)}},mask:xe,clipPath:class extends vt{apply(t){const{document:e}=this,i=Reflect.getPrototypeOf(t),{beginPath:A,closePath:n}=t;i&&(i.beginPath=ve,i.closePath=ve),Reflect.apply(A,t,[]),this.children.forEach((A=>{if(!("path"in A))return;let a="elementTransform"in A?A.elementTransform():null;a||(a=It.fromElement(e,A)),a&&a.apply(t),A.path(t),i&&(i.closePath=n),a&&a.unapply(t)})),Reflect.apply(n,t,[]),t.clip(),i&&(i.beginPath=A,i.closePath=n)}render(t){}constructor(...t){var e,i,A;super(...t),A="clipPath",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},filter:be,feDropShadow:class extends vt{apply(t,e,i,A,n){}constructor(t,e,i){var A,n,a;super(t,e,i),a="feDropShadow",(n="type")in(A=this)?Object.defineProperty(A,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):A[n]=a,this.addStylesFromStyleDefinition()}},feMorphology:class extends vt{apply(t,e,i,A,n){}constructor(...t){var e,i,A;super(...t),A="feMorphology",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},feComposite:class extends vt{apply(t,e,i,A,n){}constructor(...t){var e,i,A;super(...t),A="feComposite",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},feColorMatrix:De,feGaussianBlur:Se,title:class extends vt{constructor(...t){var e,i,A;super(...t),A="title",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}},desc:class extends vt{constructor(...t){var e,i,A;super(...t),A="desc",(i="type")in(e=this)?Object.defineProperty(e,i,{value:A,enumerable:!0,configurable:!0,writable:!0}):e[i]=A}}};function Pe(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Ne{bindCreateImage(t,e){return"boolean"==typeof e?(i,A)=>t(i,"boolean"==typeof A?A:e):t}get window(){return this.screen.window}get fetch(){return this.screen.fetch}get ctx(){return this.screen.ctx}get emSize(){const{emSizeStack:t}=this;return t[t.length-1]||12}set emSize(t){const{emSizeStack:e}=this;e.push(t)}popEmSize(){const{emSizeStack:t}=this;t.pop()}getUniqueId(){return"pith"+ ++this.uniqueId}isImagesLoaded(){return this.images.every((t=>t.loaded))}isFontsLoaded(){return this.fonts.every((t=>t.loaded))}createDocumentElement(t){const e=this.createElement(t.documentElement);return e.root=!0,e.addStylesFromStyleDefinition(),this.documentElement=e,e}createElement(t){const e=t.nodeName.replace(/^[^:]+:/,""),i=Ne.elementTypes[e];return i?new i(this,t):new Mt(this,t)}createTextNode(t){return new Ot(this,t)}setViewBox(t){this.screen.setViewBox({document:this,...t})}constructor(t,{rootEmSize:e=12,emSize:i=12,createCanvas:A=Ne.createCanvas,createImage:n=Ne.createImage,anonymousCrossOrigin:a}={}){Pe(this,"pith",void 0),Pe(this,"rootEmSize",void 0),Pe(this,"documentElement",void 0),Pe(this,"screen",void 0),Pe(this,"createCanvas",void 0),Pe(this,"createImage",void 0),Pe(this,"definitions",void 0),Pe(this,"styles",void 0),Pe(this,"stylesSpecificity",void 0),Pe(this,"images",void 0),Pe(this,"fonts",void 0),Pe(this,"emSizeStack",void 0),Pe(this,"uniqueId",void 0),this.pith=t,this.definitions={},this.styles={},this.stylesSpecificity={},this.images=[],this.fonts=[],this.emSizeStack=[],this.uniqueId=0,this.screen=t.screen,this.rootEmSize=e,this.emSize=i,this.createCanvas=A,this.createImage=this.bindCreateImage(n,a),this.screen.wait((()=>this.isImagesLoaded())),this.screen.wait((()=>this.isFontsLoaded()))}}function Re(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}Pe(Ne,"createCanvas",(function(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i})),Pe(Ne,"createImage",(async function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=document.createElement("img");return e&&(i.crossOrigin="Anonymous"),new Promise(((e,A)=>{i.onload=()=>{e(i)},i.onerror=(t,e,i,n,a)=>{A(a)},i.src=t}))})),Pe(Ne,"elementTypes",Ye);class ke{static async from(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const A=new Bt(i),n=await A.parse(e);return new ke(t,n,i)}static fromString(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const A=new Bt(i).parseFromString(e);return new ke(t,A,i)}fork(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return ke.from(t,e,{...this.options,...i})}forkString(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return ke.fromString(t,e,{...this.options,...i})}ready(){return this.screen.ready()}isReady(){return this.screen.isReady()}async render(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.start({enableRedraw:!0,ignoreAnimation:!0,ignoreMouse:!0,...t}),await this.ready(),this.stop()}start(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{documentElement:e,screen:i,options:A}=this;i.start(e,{enableRedraw:!0,...A,...t})}stop(){this.screen.stop()}resize(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.documentElement.resize(t,e,i)}constructor(t,e,i={}){Re(this,"parser",void 0),Re(this,"screen",void 0),Re(this,"document",void 0),Re(this,"documentElement",void 0),Re(this,"options",void 0),this.parser=new Bt(i),this.screen=new ht(t,i),this.options=i;const A=new Ne(this,i),n=A.createDocumentElement(e);this.document=A,this.documentElement=n}}function He(t,e,i,A){Object.defineProperty(t,e,{get:i,set:A,enumerable:!0,configurable:!0})}var Ue="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==S?S:{},Ge={};He(Ge,"CanvasCommand",(()=>ZA)),He(Ge,"UpdateWorkflowStateCommand",(()=>$A)),He(Ge,"MoveCommand",(()=>_A)),He(Ge,"RotateCommand",(()=>tn)),He(Ge,"ResizeCommand",(()=>en)),He(Ge,"GroupCommand",(()=>An)),He(Ge,"CreateLayoutCommand",(()=>nn)),He(Ge,"ClearLayoutCommand",(()=>an)),He(Ge,"CreateElementCommand",(()=>rn)),He(Ge,"DeleteElementCommand",(()=>sn)),He(Ge,"CloneElementCommand",(()=>on)),He(Ge,"FontColorCommand",(()=>cn)),He(Ge,"FontImageFillCommand",(()=>ln)),He(Ge,"FontSizeCommand",(()=>gn)),He(Ge,"FontAlgorithmCommand",(()=>hn)),He(Ge,"FontSourceCommand",(()=>dn)),He(Ge,"FontAlignmentCommand",(()=>un)),He(Ge,"UpdateFramePattern",(()=>wn)),He(Ge,"TextChangeCommand",(()=>Bn)),He(Ge,"IllustrationColorCommand",(()=>pn)),He(Ge,"IllustrationCacheCommand",(()=>En)),He(Ge,"BringToFrontCommand",(()=>mn)),He(Ge,"BringToBackCommand",(()=>fn)),He(Ge,"BringForwardCommand",(()=>Cn)),He(Ge,"SendBackwardsCommand",(()=>Qn)),He(Ge,"LayerCommand",(()=>yn)),He({},"generate",(()=>Te));const Te=()=>{const t=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()};var Oe={};He(Oe,"ElementNotFoundError",(()=>VA)),He(Oe,"findElement",(()=>KA)),He(Oe,"findLayoutForElement",(()=>WA)),He(Oe,"updatedLayoutForElement",(()=>XA)),He(Oe,"rehydrateSerializedLayout",(()=>qA));var Je={};He(Je,"CommandContext",(()=>JA)),He(Je,"getSvgElement",(()=>zA)),He(Je,"elementFactory",(()=>LA)),He(Je,"sortElementsByLayersWithIndex",(()=>jA)),He({},"SVGLayout",(()=>gi));var Le={};let ze;var je;let Ve;var Ke;let We;var Xe;let qe;var Ze;let $e;var _e;let ti,ei;var ii;let Ai;var ni;let ai;var ri;let si;var oi;let ci;var li;He(Le,"LayoutElementType",(()=>ze)),He(Le,"LayoutRenderingPurpose",(()=>Ve)),He(Le,"TextAlgorithm",(()=>We)),He(Le,"UnitOfMeasurement",(()=>qe)),He(Le,"ScaleAxis",(()=>$e)),He(Le,"AspectConditionAction",(()=>ti)),He(Le,"AspectType",(()=>ei)),He(Le,"MaterialEffectMode",(()=>Ai)),He(Le,"AssetType",(()=>ai)),He(Le,"StepType",(()=>si)),He(Le,"StepAspectType",(()=>ci)),(je=ze||(ze={})).Frame="frame",je.Image="image",je.Illustration="illustration",je.Textbox="textbox",(Ke=Ve||(Ve={})).ThreeD="ThreeD",Ke.FreeDesign="FreeDesign",Ke.Print="Print",(Xe=We||(We={})).Autosize="Autosize",Xe.Traditional="Traditional",(Ze=qe||(qe={})).Pixel="px",Ze.Millimeter="mm",Ze.Centimeter="cm",(_e=$e||($e={}))[_e.North=0]="North",_e[_e.Northeast=1]="Northeast",_e[_e.East=2]="East",_e[_e.Southeast=3]="Southeast",_e[_e.South=4]="South",_e[_e.Southwest=5]="Southwest",_e[_e.West=6]="West",_e[_e.Northwest=7]="Northwest",(ti||(ti={})).Show="Show",(ii=ei||(ei={})).FileUpload="FileUpload",ii.Option="Option",ii.Text="Text",(ni=Ai||(Ai={})).None="None",ni.RemoveWhenSelected="RemoveWhenSelected",ni.ApplyWhenSelected="ApplyWhenSelected",(ri=ai||(ai={})).Font="Font",ri.Frame="Frame",ri.Illustration="Illustration",ri.Image="Image",ri.Model="Model",ri.Material="Material",ri.Color="Color",ri.QuestionnaireCollateral="QuestionnaireCollateral",ri.RequestCollateral="RequestCollateral",ri.SignupCollateral="SignupCollateral",ri.Video="Video",ri.ColorProfile="ColorProfile",(oi=si||(si={})).Bulk="Bulk",oi.DigitalContent="DigitalContent",oi.Finish="Finish",oi.Frame="Frame",oi.Illustration="Illustration",oi.Introduction="Introduction",oi.Material="Material",oi.Model="Model",oi.Module="Module",oi.Picture="Picture",oi.Photo="Photo",oi.ProductOverlay="ProductOverlay",oi.Question="Question",oi.Shape="Shape",oi.SilentIllustration="SilentIllustration",oi.Text="Text",(li=ci||(ci={})).Color="Color",li.Colors="Colors",li.Selection="Selection",li.Selections="Selections",li.Text="Text",li.Upload="Upload";const gi=({backgroundColor:t,outlineColor:e,borderRadius:A,configuration:n,elements:a,height:r,maxHeight:s,maxWidth:o,outlineArea:c,position:l,preserveAspectRatio:g,viewBox:h,width:d})=>{const u=A||0,w=2*(c?.scale||1),B=h||{x:0,y:0,width:d,height:r},p=`${B.x} ${B.y} ${B.width} ${B.height}`,E=Te(),m=n.purpose===Ve.FreeDesign&&(0,i.jsx)("defs",{children:(0,i.jsx)("clipPath",{id:"viewboxClip",children:(0,i.jsx)("rect",{width:B.width,height:B.height,rx:u})})}),f=n.colorProfiles?.map(((t,e)=>(0,i.jsx)("color-profile",{name:t.name,xlinkHref:t.key,children:" "},e))),C=jA(a.map((t=>({...t,_renderingConfiguration:n,mask:c?`url(#viewmask-${E})`:void 0}))));return(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",preserveAspectRatio:g,width:d,height:r,style:{gridColumn:1,gridRow:1,maxWidth:o,maxHeight:s,position:l},viewBox:p,children:[f,m,!!t&&(0,i.jsx)("rect",{id:"layout-background",width:B.width,height:B.height,fill:t,rx:u}),(0,i.jsx)("g",{id:"element-group",clipPath:n.purpose===Ve.FreeDesign?"url(#viewboxClip)":void 0,children:C.map((t=>LA(t))).filter((t=>!!t))}),c&&(0,i.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"none",stroke:c.hidden?"none":e||"#aaaaaa",strokeWidth:w/2,strokeDasharray:`${2*w} ${w}`}),c&&(0,i.jsxs)("mask",{id:`viewmask-${E}`,children:[(0,i.jsx)("rect",{x:B.x,y:B.y,width:B.width,height:B.height,fill:"black"}),(0,i.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"white"})]})]})};He({},"Image",(()=>Fi));var hi={};He(hi,"getAxisAlignedBoundingBox",(()=>di)),He(hi,"degreesToRadians",(()=>wi)),He(hi,"findAngle",(()=>ui)),He(hi,"radiansToDegrees",(()=>Bi)),He(hi,"isCloseToValue",(()=>pi)),He(hi,"getTrueCoordinates",(()=>Ei)),He(hi,"getPointOfRotation",(()=>mi)),He(hi,"getNWPoint",(()=>fi)),He(hi,"getNEPoint",(()=>Ci)),He(hi,"getSWPoint",(()=>Qi)),He(hi,"getSEPoint",(()=>yi)),He(hi,"turnRightClockwise",(()=>Di)),He(hi,"currentDirection",(()=>Ii)),He(hi,"getElementVertices",(()=>xi)),He(hi,"rotateAroundPoint",(()=>vi)),He(hi,"mmPerPixel",(()=>Mi)),He(hi,"cmPerPixel",(()=>Si));const di=(t,e,i,A,n)=>{const a=wi(n),r=i/2,s=A/2,o=t+r,c=e+s,l=Math.sin(a),g=Math.cos(a),h=-s,d=r*g-h*l,u=r*g-s*l,w=r*l+h*g,B=r*l+s*g,p=Math.max(Math.abs(d),Math.abs(u)),E=Math.max(Math.abs(w),Math.abs(B));return{minX:o-p,maxX:o+p,minY:c-E,maxY:c+E}},ui=(t,e,i)=>{const A=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),n=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),a=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2));return Math.acos((n*n+A*A-a*a)/(2*n*A))*(180/Math.PI)},wi=t=>t*(Math.PI/180),Bi=t=>t*(180/Math.PI),pi=(t,e,i)=>Math.abs(t-e)<i,Ei=(t,e,i)=>{const A=Math.sin(wi(i)),n=Math.cos(wi(i));return{x:(t.x-e.x)*n-(t.y-e.y)*A+e.x,y:(t.x-e.x)*A+(t.y-e.y)*n+e.y}},mi=(t,e)=>({x:(t.x+e.x)/2,y:(t.y+e.y)/2}),fi=(t,e,i,A)=>({x:t.x+e?.x*i,y:t.y+e?.y*A}),Ci=(t,e,i,A)=>({x:t.x+(e?.x+e?.width)*i,y:t.y+e?.y*A}),Qi=(t,e,i,A)=>({x:t.x+e?.x*i,y:t.y+(e?.y+e?.height)*A}),yi=(t,e,i,A)=>({x:t.x+(e?.x+e?.width)*i,y:t.y+(e?.y+e?.height)*A}),Di=t=>{switch(t){case $e.North:return $e.East;case $e.East:return $e.South;case $e.South:return $e.West;case $e.West:return $e.North;case $e.Northwest:return $e.Northeast;case $e.Northeast:return $e.Southeast;case $e.Southeast:return $e.Southwest;case $e.Southwest:return $e.Northwest}},Ii=(t,e)=>e>45&&e<=135?Di(t):e>135&&e<=225?Di(Di(t)):e>225&&e<=315?Di(Di(Di(t))):t,xi=(t,e={x:0,y:0},i={x:1,y:1})=>{const A=wi(t.rotation),n={x:e.x+t.x*i.x,y:e.x+t.y*i.y},a={x:t.x+t.width,y:t.y},r={x:e.x+(t.x+t.width)*i.x,y:e.y+(t.height+t.y)*i.y},s={x:e.x+t.x*i.x,y:e.y+(t.height+t.y)*i.y},o={x:(s.x+r.x)/2,y:s.y-t.height*i.y/2};return{a:vi(n,o,A),b:vi(a,o,A),c:vi(r,o,A),d:vi(s,o,A),center:o}},vi=(t,e,i)=>{const A=Math.sin(i),n=Math.cos(i);return{x:(t.x-e.x)*n-(t.y-e.y)*A+e.x,y:(t.x-e.x)*A+(t.y-e.y)*n+e.y}},Mi=.352778,Si=.035277,Fi=t=>{const e=t.rotation||0,A=wi(e),n=Math.cos(A),a=-Math.sin(A);return(0,i.jsx)("g",{mask:t.stepName||t.productOverlay?void 0:t.mask,children:(0,i.jsx)("g",{transform:`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${n}, ${-a}, ${a}, ${n}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n `,children:(0,i.jsx)("image",{xlinkHref:t.src,preserveAspectRatio:t.preserveAspectRatio,width:t.width,height:t.height})})})};He({},"Frame",(()=>Yi));const bi=256,Yi=t=>{const e=`spiff-frame-${t.id}`,n=`spiff-frame-blur-${t.id}`,a=`spiff-frame-blur-edge-${t.id}`,r=`spiff-frame-focal-mask-${t.id}`,s=()=>t.disablePlaceholder&&!t.pattern?"":t.pattern?t.pattern.src:"data:image/png;base64,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";if(!s())return(0,i.jsx)(F(A).Fragment,{});const o=!!t.focalBlur&&!!t.pattern,c=t.rotation||0,l=wi(c),g=Math.cos(l),h=-Math.sin(l);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("defs",{children:(A=>{const o=t.pattern?.x||0,c=t.pattern?.y||0,l=t.pattern?t.pattern.width*t.pattern.scaleX+Math.abs(o):0,g=t.pattern?t.pattern.height*t.pattern.scaleY+Math.abs(c):0,h=t.dataWidth||l||bi,d=t.dataHeight||g||256,u=t.pattern?t.pattern.width*t.pattern.scaleX:bi,w=t.pattern?t.pattern.height*t.pattern.scaleY:256;return(0,i.jsxs)("g",{mask:t.stepName?void 0:t.mask,children:[(0,i.jsx)("pattern",{patternUnits:t.pattern?void 0:"userSpaceOnUse",x:0,y:0,width:t.pattern?1:bi,height:t.pattern?1:bi,"data-frame-width":t.pattern?h:void 0,"data-frame-height":t.pattern?d:void 0,id:e,children:(0,i.jsx)("image",{preserveAspectRatio:"none",x:o,y:c,width:u,height:w,xlinkHref:s()})}),A?(0,i.jsx)(Pi,{path:t.path,width:t.width,height:t.height,focalBlurStrength:t.focalBlurStrength||1,focalBlurRadius:t.focalBlurRadius||10,blurFilterId:n,focalMaskId:r,blurEdgeClipId:a}):null]})})(o)}),(0,i.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,i.jsxs)("g",{transform:`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${g}, ${-h}, ${h}, ${g}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n matrix(${t.scaleX}, 0, 0, ${t.scaleY}, 0, 0)\n `,children:[(0,i.jsx)("path",{filter:o?`url(#${n})`:void 0,mask:o?`url(#${a})`:void 0,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}),o?(0,i.jsx)("path",{mask:`url(#${r})`,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}):void 0]})})]})},Pi=t=>{const{path:e,width:A,height:n,focalBlurStrength:a,focalBlurRadius:r,blurFilterId:s,focalMaskId:o,blurEdgeClipId:c}=t;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("filter",{id:s,children:(0,i.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,i.jsx)("mask",{id:o,children:(0,i.jsx)("circle",{cx:A/2,cy:n/2,r:r||0,fill:"white",filter:`url(#${s})`})}),(0,i.jsx)("mask",{id:c,children:(0,i.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};He({},"Textbox",(()=>YA));var Ni={};He(Ni,"fontSizeStep",(()=>pA)),He(Ni,"textWidth",(()=>EA)),He(Ni,"charWidth",(()=>mA)),He(Ni,"lineWidth",(()=>fA)),He(Ni,"applyTextTransformations",(()=>QA)),He(Ni,"zip",(()=>yA)),He(Ni,"getTextAlignment",(()=>DA)),He(Ni,"getAnchor",(()=>IA)),He(Ni,"recomputeTextOnElement",(()=>xA)),He(Ni,"defaultLineHeightFactor",(()=>vA));var Ri={};He(Ri,"refitTextbox",(()=>wA)),He(Ri,"recalculateTextboxRegion",(()=>BA));var ki={};He(ki,"FontMetrics",(()=>aA)),He(ki,"loadFontFromExternalUrl",(()=>sA)),He(ki,"loadFontFromDataUrl",(()=>oA)),He(ki,"getFontMetrics",(()=>cA));var Hi={};He(Hi,"registerJSDOM",(()=>Ti)),He(Hi,"createElement",(()=>zi)),He(Hi,"createElementNS",(()=>ji)),He(Hi,"domParser",(()=>Vi)),He(Hi,"fetchAsArrayBuffer",(()=>Ki)),He(Hi,"fetchAsString",(()=>Wi)),He(Hi,"loadFontFaceSet",(()=>Xi)),He(Hi,"xmlSerializer",(()=>qi)),He(Hi,"toBase64",(()=>Zi)),He(Hi,"dataUrlFromExternalUrl",(()=>$i)),He(Hi,"arrayBufferToDataUrl",(()=>_i)),He(Hi,"arrayBufferToBuffer",(()=>eA)),He(Hi,"dataUrlToArrayBuffer",(()=>tA));var Ui=a.Buffer;let Gi;function Ti(t){Gi=t}function Oi(){if(!Gi)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new Gi}if(void 0===Ue.TextEncoder){const{TextEncoder:t}=c;Ue.TextEncoder=t}if(void 0===Ue.TextDecoder){const{TextDecoder:t}=c;Ue.TextDecoder=t}const Ji=new(F(s).Agent)({rejectUnauthorized:!("local"===Ue.process?.env?.ENVIRONMENT)}),Li=t=>t.every((t=>"undefined"!==t)),zi=t=>Li([typeof document])?document.createElement(t):Oi().window.document.createElement(t),ji=(t,e)=>{if(Li([typeof document]))return document.createElementNS(t,e);const i=Oi().window.document.createElement(e);return i.setAttribute("xmlns",t),i},Vi=()=>Li([typeof DOMParser])?new DOMParser:new(Oi().window.DOMParser),Ki=t=>{if(Li([typeof fetch]))return new Promise(((e,i)=>{fetch(t).then((t=>{e(t.arrayBuffer())})).catch((t=>{i(t)}))}));{const e=t.replace("localhost","localstack");return new Promise(((t,i)=>{F(r).get(e,{responseType:"arraybuffer",httpsAgent:Ji}).then((e=>{t(e.data)})).catch((t=>{i(t)}))}))}},Wi=t=>{if(Li([typeof fetch]))return new Promise(((e,i)=>{fetch(t).then((t=>{e(t.text())})).catch(i)}));{const e=t.replace("localhost","localstack");return new Promise(((t,i)=>{F(r).get(e,{responseType:"text",httpsAgent:Ji}).then((e=>{t(e.data)})).catch(i)}))}},Xi=async(t,e)=>{if(Li([typeof FontFace])){const i=t.names.fullName.en,A=new FontFace(i,`url(${e})`);return document.fonts.add(A),A.load()}},qi=()=>Li([typeof XMLSerializer])?new XMLSerializer:new(Oi().window.XMLSerializer),Zi=t=>Li([typeof btoa])?btoa(t):Ui.from(t).toString("base64"),$i=async t=>{if(Li([typeof fetch,typeof Blob,typeof FileReader])){const e=await fetch(t),i=await e.blob();return await AA(i)}const e=(await F(r).get(t,{responseType:"arraybuffer"})).data;return _i(e)},_i=async t=>{const e=await(async t=>{const e=await(0,o.fromBuffer)(t);return e?e.mime:"image/svg+xml"})(t);return`data:${e};base64,${eA(t).toString("base64")}`},tA=t=>{const e=t.replace(/\r?\n/g,""),i=e.indexOf(",");if(-1===i||i<=4)throw new TypeError("malformed data: URI");const A=e.substring(5,i).split(";");let n=!1;for(let t=1;t<A.length;t++)"base64"===A[t]&&(n=!0);const a=n?"base64":"ascii",r=unescape(e.substring(i+1)),s=Ui.from(r,a);return iA(s)},eA=t=>Ui.from(t),iA=t=>{const e=new ArrayBuffer(t.byteLength),i=new Uint8Array(e);for(let e=0;e<t.length;++e)i[e]=t[e];return e},AA=t=>new Promise(((e,i)=>{const A=new FileReader;A.onload=function(t){const A=t.target;A&&A.result?e(A.result.toString()):i()},A.readAsDataURL(t)})),nA=new Map;class aA{constructor(t){this.font=t,this.glyphsFromText=new Map,this.kerningValues=new Map,this.height=this.calculateApproximateHeight()}getFont(){return this.font}getGlyphs(t){const e=this.glyphsFromText.get(t);if(e)return e;const i=this.font.stringToGlyphs(t);return this.glyphsFromText.set(t,i),i}getApproximateHeight(){return this.height}getExactHeight(t){const e=this.font.stringToGlyphs(t);let i=0,A=0;return e.forEach((t=>{const e=t.getMetrics();i=Math.max(i,e.yMax),A=Math.min(A,e.yMin)})),i-A}getKerningValue(t,e){let i=this.kerningValues.get(t.name);i||(i=new Map,this.kerningValues.set(t.name,i));let A=i.get(e.name);return A||(A=this.font.getKerningValue(t,e),i.set(e.name,A)),A}calculateApproximateHeight(){const t=this.font.stringToGlyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");let e=0,i=0;return t.forEach((t=>{const A=t.getMetrics();e=Math.max(e,A.yMax),i=Math.min(i,A.yMin)})),e-i}}const rA=t=>"data:"===t.substring(0,5).toLowerCase().trim(),sA=async t=>{const e=rA(t)?oA(t):oA(await $i(t));return lA(e,{assetUrl:rA(t)?t:await $i(t),name:e.names.fullName.en}),await Xi(e,t),e},oA=t=>{const e=tA(t),i=F(n).parse(e);return lA(i,{assetUrl:t,name:i.names.fullName.en}),i},cA=t=>{const e=nA.get(t.name);if(e)return e;throw new Error("Font metrics unavailable for font")},lA=(t,e)=>{const i=new aA(t);return nA.set(e.name,i),i},gA=(t,e,i,A)=>Math.max(mA(t.join("\n"),i,A),e),hA=(t,e,i,A,n,a)=>{const r=(a||vA)*n.getApproximateHeight(),s=e.split("\n");try{const e=s.flatMap((e=>dA(e,t.width,A,n))),a=e.flatMap((t=>t.lines));return{lines:a,requiredHeight:e.flatMap((t=>t.lines)).length*(A*r),fontSize:i,requiredWidth:gA(a,t.width,A,n)}}catch(a){const s=e.split("");return{lines:s,requiredHeight:s.length*(A*r),fontSize:i,requiredWidth:gA(s,t.width,A,n)}}},dA=(t,e,i,A)=>{const n=EA(t,i,A);if(n<=e)return{lines:[t],width:n};if(!(t.indexOf(" ")>-1)){if(t.length<=1)throw new Error(`Character ${t} is wider than region`);const n=Math.floor(t.length/2),a=dA(t.slice(0,n),e,i,A),r=dA(t.slice(n),e,i,A);return{lines:[...a.lines,...r.lines],width:Math.max(a.width,r.width)}}const a=t.split(" "),r=[];let s=-1/0,o=0;for(;o<a.length;){const t=a[o];if(EA(t,i,A)>e){const n=dA(t,e,i,A);r.push(...n.lines),s=Math.max(s,n.width),o++}else{const n=[t];s=Math.max(s,EA(t,i,A));let c=o+1,l=!0;for(;c<a.length&&l;){const t=a[c],r=EA(`${n.join(" ")} ${t}`,i,A);r<=e?(n.push(t),s=Math.max(s,r),c++):l=!1}r.push(n.join(" ")),o=c}}if(s<0)throw new Error(`No max width calculated for text: ${r}.`);return{lines:r,width:s}},uA=(t,e,i,A,n,a)=>{const r=(a??vA)*e.getApproximateHeight(),s=1/i.unitsPerEm,o=A/fA(t,s,e),c=n/(t.length*r*s);return Math.min(c,o)},wA=(t,e,i,A)=>{const n=cA(e.fontData),a=n.getFont(),r=e.fontSize/a.unitsPerEm;if(!i)return hA(e,t,e.fontSize,r,n,A);let s;if(s=e.text?e.text.split("\n"):e.input?.split("\n")??[""],i.input===t&&e.width===i.width&&e.height===i.height&&e.lineHeight===i.lineHeight)return{lines:s,requiredHeight:e.height,requiredWidth:gA(s,e.width,r,n),fontSize:e.fontSize};const o=e.width!==i.width!=(e.height!==i.height);return e.lineHeight!==i.lineHeight||o||i.input!==t?hA(e,t,e.fontSize,r,n,A):{lines:s,requiredHeight:e.height,requiredWidth:gA(s,e.width,r,n),fontSize:uA(s,n,a,e.width,e.height,A)}},BA=(t,e,i,A,n)=>{const a=cA(e).getFont();let r={...t},s={...t},o=fA(A,i/a.unitsPerEm,cA(e));return o&&o<r.width&&(s.width=o,"left"===n?(s.left+=Math.sin(r.rotation*Math.PI/360)*(r.width-o),s.top+=Math.sin(r.rotation*Math.PI/180)*(o-r.width)/2):s.left+="right"===n?r.width-o:(r.width-o)/2,A&&yA(A,A).every((([t,e])=>t===e))&&(r=s)),r},pA=1,EA=(t,e,i)=>{let A=0;const n=i.getGlyphs(t);return n.forEach(((t,e)=>{if(t.advanceWidth&&(A+=t.advanceWidth),e<n.length-1){const a=i.getKerningValue(t,n[e+1]);A+=a}})),A*=e,A},mA=(t,e,i)=>{let A=0;const n=i.getGlyphs(t);return n.forEach(((t,e)=>{if(t.advanceWidth&&(A=Math.max(A,t.advanceWidth)),e<n.length-1){const a=i.getKerningValue(t,n[e+1]);A=Math.max(A,a)}})),A*=e,A},fA=(t,e,i)=>{let A=0;return t.forEach((t=>{A=Math.max(A,EA(t,e,i))})),A},CA={stripControlCharacters:!0,vertical:!1,uppercase:!1},QA=(t,e=CA)=>{const i={...CA,...e};let A=t||"";return i.stripControlCharacters&&(A=A.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),i.uppercase&&(A=A.toUpperCase()),i.vertical&&(A=A.split("").join("\n")),A},yA=(t,e)=>t.map(((t,i)=>[t,e[i]])),DA=(t="center",e=!1)=>e?"center":t,IA=t=>"left"===t?"start":"right"===t?"end":"middle",xA=(t,e,i)=>t.fontData?{...t,...(()=>{if(t.algorithm===We.Traditional){const A=wA(e,t,i,t.lineHeight);return{text:A.lines.join("\n"),height:A.requiredHeight,width:A.requiredWidth,fontSize:A.fontSize,input:e}}return{text:e}})()}:t,vA=1.1;var MA={};He(MA,"colorDefinitionPrintValue",(()=>SA)),He(MA,"spotColorDefinitionString",(()=>FA)),He(MA,"svgColorValueToDefinition",(()=>bA));const SA=t=>{const e=FA(t.spotColor);return e?`${t.browserValue} ${e}`:t.browserValue},FA=t=>{if(!t)return"";if(t.profileName.includes("/")&&t.profileName.includes(".icc")){const e=t.profileName.replace(/\s/g,"-"),i=e.lastIndexOf("/");return`icc-named-color(${e.slice(i+1).slice(0,-4)}, ${t.namedColor})`}return`icc-named-color(${t.profileName}, ${t.namedColor})`},bA=t=>{const e=t.split(/[ ](?=[^)]*?(?:\(|$))/);if(0===e.length)return{browserValue:"#000000"};if(1===e.length)return{browserValue:e[0]};const i=e[1].match(/\(([^)]+)\)/gm);if(!i)throw new Error("Unhandled state of color value in SVG");const A=i[0].replace(/[() ]/g,"").split(",");return{browserValue:e[0],spotColor:{profileName:A[0],namedColor:A[1]}}},YA=t=>{const e=(t.rotation||0)*Math.PI/180,A=Math.cos(e),n=-Math.sin(e),a=`text-path-${t.id}`,r=`text-fill-${t.id}`,s=t.x+(t.curved?0:t.width/2),o=t.y+(t.curved?0:t.height/2),c=(t.text||"").split("\n");return t.curved&&!t.paths?null:t.fontData?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("defs",{children:[t.textFillImage&&(0,i.jsx)("pattern",{id:r,patternUnits:"userSpaceOnUse",width:t.textFillImage.scale*t.textFillImage.width,height:t.textFillImage.scale*t.textFillImage.height,x:0,y:0,children:(0,i.jsx)("image",{href:t.textFillImage.src,xlinkHref:t.textFillImage.src,width:t.textFillImage.scale*t.textFillImage.width,height:t.textFillImage.scale*t.textFillImage.height})}),(0,i.jsx)("style",{type:"text/css",dangerouslySetInnerHTML:{__html:`\n @font-face {\n font-family: '${t.fontData.name}';\n src: url('${t.fontData.assetUrl}') format('truetype');\n }\n `}}),t.curved&&t.paths?(0,i.jsx)("path",{id:a,d:t.paths[0]}):void 0]}),t._renderingConfiguration?.debug?(0,i.jsx)("rect",{stroke:"blue",fill:"none",x:t.x,y:t.y,width:t.width,height:t.height}):void 0,(0,i.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,i.jsx)("g",{transform:`matrix(${A}, ${-n}, ${n}, ${A}, ${s}, ${o})`,children:(0,i.jsx)("text",{xmlSpace:"preserve",fontFamily:`'${t.fontData.name}'`,fontSize:t.fontSize,fontStyle:"normal",fontWeight:"normal",fill:t.textFillImage?`url("#${r}")`:t._renderingConfiguration?.spotColors&&t.fillSpotColorDefinition?`${t.fill} ${FA(t.fillSpotColorDefinition)}`:t.fill,style:{whiteSpace:"pre",userSelect:"none"},children:t.curved?(0,i.jsx)(NA,{text:t.text||"",curvedPathId:a,align:t.align}):c.map(((e,A)=>(0,i.jsx)(PA,{align:t.vertical?"center":t.align,fontSize:t.fontSize,thisLineIdx:A,amountLines:c.length,text:e,textboxHeight:t.height,textboxWidth:t.width,lineHeight:t.lineHeight,vertical:t.vertical,verticalAlign:t.verticalAlign},A)))})})})]}):null},PA=t=>(0,i.jsx)("tspan",{textAnchor:IA(t.align),x:"left"===t.align?-t.textboxWidth/2:"right"===t.align?t.textboxWidth/2:0,y:`${(()=>{const e=t.fontSize*(void 0!==t.lineHeight?t.lineHeight:vA),i=t.textboxHeight/2;if("top"===t.verticalAlign)return-i+3*t.fontSize/4+t.thisLineIdx*e;if("bottom"===t.verticalAlign){const A=t.amountLines-1-t.thisLineIdx;return i-t.fontSize/4-A*e}const A=(t.amountLines-1)/2;return(t.thisLineIdx-A)*e+t.fontSize/4})()}px`,children:t.text}),NA=t=>{const e=`#${t.curvedPathId}`;return(0,i.jsx)("textPath",{startOffset:"left"===t.align?"0%":"right"===t.align?"100%":"50%",textAnchor:IA(t.align),href:e,xlinkHref:e,children:t.text})};He({},"Illustration",(()=>OA));var RA={};He(RA,"traverse",(()=>HA)),He(RA,"sanitizeSvgTree",(()=>UA)),He(RA,"modifySVGWithElementProperties",(()=>GA)),He(RA,"generateSVGWithUnknownColors",(()=>TA));const kA=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],HA=(t,e)=>{e(t),t.children.length>0&&Array.from(t.children).forEach((t=>HA(t,e)))},UA=(t,e=!1)=>{!e&&t.setAttribute("preserveAspectRatio","none");const i=[];HA(t,(t=>{if("script"!==t.tagName)if("style"!==t.tagName);else try{(0,l.parse)(t.innerHTML).stylesheet?.rules.forEach((t=>{i.push(t)})),t.remove()}catch(t){console.error(t)}else t.remove()})),HA(t,(t=>{i.forEach((e=>{e.selectors?.forEach((i=>{((t,e)=>{try{return t.matches(e)}catch(i){return t.classList.contains(e.substring(1))}})(t,i)&&e.declarations?.forEach((e=>{e.property&&e.value&&t.setAttribute(e.property,e.value)}))}))}))}))},GA=(t,e,i,A,n)=>{const a=(t=>Vi().parseFromString(t,"image/svg+xml").firstElementChild)(t);if(!a)throw new Error("Failed to read SVG.");return((t,e,i)=>{t.setAttribute("height",`${i}px`),t.setAttribute("width",`${e}px`)})(a,e,i),((t,e,i)=>{HA(t,(t=>{const A=t.attributes.getNamedItem("fill");A&&"none"!==A.value&&t.classList.forEach((A=>{if(A.startsWith("spiff-fill")){const n=e[A];n&&t.setAttribute("fill",i?SA(n):n.browserValue)}}));const n=t.attributes.getNamedItem("stroke");n&&"none"!==n.value&&t.classList.forEach((A=>{if(A.startsWith("spiff-stroke")){const n=e[A];n&&t.setAttribute("stroke",i?SA(n):n.browserValue)}}))}))})(a,A,n),(t=>qi().serializeToString(t))(a)},TA=async t=>{const e=t.match(/<svg.*?<\/svg>/s)||[],i=e?.length>0?e[0]:"",A=Vi().parseFromString(i,"image/svg+xml").firstElementChild;if(!A)throw new Error("Failed to read SVG.");UA(A);const n={};HA(A,(t=>{kA.includes(t.tagName)&&!t.attributes.getNamedItem("fill")&&t.setAttribute("fill","black");const e=t.attributes.getNamedItem("fill");if(e&&"none"!==e.value){const i=bA(e.value),A=`spiff-fill-${i.browserValue.replace(/\W/g,"")}`;t.setAttribute("fill",i.browserValue),t.classList.add(A),n[A]=i}const i=t.attributes.getNamedItem("stroke");if(i&&"none"!==i.value){const e=bA(i.value),A=`spiff-stroke-${e.browserValue.replace(/\W/g,"")}`;t.classList.add(A),t.setAttribute("stroke",e.browserValue),n[A]=e}}));const a=qi().serializeToString(A);return{colors:n,svg:a}},OA=t=>{if(t.cachedObjectURL&&!t._renderingConfiguration?.omitCachedFields)return(0,i.jsx)(Fi,{id:t.id,src:t.cachedObjectURL,x:t.x,y:t.y,width:t.width,height:t.height,rotation:t.rotation,preserveAspectRatio:"none",immutable:t.immutable,mask:t.stepName?void 0:t.mask});const e=t.rotation||0,A=wi(e),n=Math.cos(A),a=-Math.sin(A),r=`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${n}, ${-a}, ${a}, ${n}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n `;if(!t.svg)throw new Error(`Illustration element ${t.id} (stepName ${t.stepName}) lacked svg from src ${t.src} at render time.`);return(0,i.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,i.jsx)("g",{transform:r,dangerouslySetInnerHTML:{__html:GA(t.svg,t.width,t.height,t.colors,t._renderingConfiguration?.spotColors)}})})};class JA{constructor(){this.id=Te(),this.stateCallbacks=[],this.prevCommands=[],this.nextCommands=[]}registerStateCallback(t){this.stateCallbacks.push(t)}unregisterStateCallback(t){this.stateCallbacks.filter((e=>e!==t))}getState(){return this.state}runStateCallbacks(){this.stateCallbacks.forEach((t=>t()))}apply(t,e){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);this.state=this.commandReducer(this.state,t),this.runStateCallbacks(),this.nextCommands=[],e||this.prevCommands.push(t)}undo(){if(!this.state)return;const t=this.prevCommands.pop();if(!t)return;const e=t.undo();t.varying?this.state={...this.state,variation:e}:this.state={...this.state,transaction:e},this.nextCommands.push(t),this.runStateCallbacks()}redo(){if(!this.state)return;const t=this.nextCommands.pop();t&&(this.state=this.commandReducer(this.state,t),this.runStateCallbacks(),this.prevCommands.push(t))}flattenSequence(t,e){const i=this.prevCommands.filter((e=>e.sequenceId===t)).pop();i&&(this.prevCommands=this.prevCommands.filter((e=>e.sequenceId!==t)),i?.overrideOldState(e),this.prevCommands.push(i))}getLayoutById(t){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const e=this.state.transaction?.layouts?.[t],i=this.state.variation?.layouts?.[t],A=e?.layout||i?.layout;if(!A)throw new Error(`No layout: ${t}`);const n=[...e?.elements||[],...i?.elements||[]];return this.getLayoutDataWithState(A,n)}getAllLayouts(){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const t=[...Object.keys(this.state.transaction?.layouts),...Object.keys(this.state.variation?.layouts||{})];return[...new Set(t)].map((t=>this.getLayoutById(t)))}getLayoutDataWithState(t,e){return{layoutState:{layout:t,elements:e},getComponentWithProps:i=>zA(t,e,i)}}initialize(t,e){if(e)return void(this.state={transaction:e});let i={serializableWorkflow:{steps:[]},layouts:{}};t.forEach((t=>{i=new nn(t).apply(i)})),this.runStateCallbacks(),this.state={transaction:i}}commandReducer(t,e){if(e.varying){const i={layouts:{},serializableWorkflow:{steps:[]},...t.variation};return{...t,variation:e.apply(i)}}{const i=t.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...t,transaction:e.apply(i)}}}}const LA=t=>"image"===t.type?(0,i.jsx)(Fi,{...t},t.id):"frame"===t.type?(0,i.jsx)(Yi,{...t},t.id):"illustration"===t.type?(0,i.jsx)(OA,{...t},t.id):"textbox"===t.type?(0,i.jsx)(YA,{...t},t.id):null,zA=(t,e,A)=>{const n=A.renderingConfiguration,a=n?.removeExcludedElements?e.filter((t=>!t.excludeFromExport)):e;return(0,i.jsx)(gi,{preserveAspectRatio:void 0,elements:a,backgroundColor:t.transparentBackground?void 0:"white",width:A.width||t.width,height:A.height||t.height,viewBox:n?.region?{x:n.region.left,y:n.region.top,width:n.region.width,height:n.region.height}:{x:0,y:0,width:t.width,height:t.height},configuration:n,outlineArea:A.outlineArea,maxHeight:A.maxHeight,maxWidth:A.maxWidth,position:A.position,borderRadius:A.borderRadius,outlineColor:A.outlineColor})};function jA(t){return t.sort(((t,e)=>{const i=t.layer||0,A=e.layer||0;if(i<A)return-1;if(i>A)return 1;const n=t.layerIndex||0,a=e.layerIndex||0;return n<a?-1:n>a?1:0}))}class VA extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,VA.prototype)}}const KA=(t,e)=>WA(t,e).elements.find((e=>e.id===t)),WA=(t,e)=>{const i=Object.values(e).find((e=>e.elements.some((e=>e.id===t))));if(!i)throw new VA;return i},XA=(t,e)=>{const i=jA([...e.elements.filter((e=>e.id!==t.id)),t]);return{layout:e.layout,elements:i,modificationID:Te()}},qA=async(t,e)=>{const i=[...Object.keys(t.layouts),...Object.keys(e?.layouts||{})],A=[...new Set(i)];for(let i=0;i<A.length;i++){const n=A[i],a=t.layouts[n],r=e?.layouts[n],s=a||r;await Promise.all(s.elements.map((async t=>{if("illustration"===t.type){const e=t;if(e.src&&!e.svg){const t=await Wi(e.src),i=await TA(t);e.svg=GA(i.svg,e.width,e.height,e.colors)}}isNaN(t.x)&&(t.x=0),isNaN(t.y)&&(t.y=0),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),isNaN(t.rotation)&&(t.rotation=0)})))}};class ZA{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(t){this.oldState=t}}class $A extends ZA{constructor(t){super(),this.serializableWorkflow=t}apply(t){return this.oldState=t,{...t,serializableWorkflow:this.serializableWorkflow}}}class _A extends ZA{constructor(t,e,i){super(),this.id=t,this.x=e,this.y=i}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,x:this.x,y:this.y},A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class tn extends ZA{constructor(t,e){super(),this.id=t,this.angle=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,rotation:this.angle},A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class en extends ZA{constructor(t,e,i){super(),this.id=t,this.width=Math.abs(e),this.height=Math.abs(i)}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;let i={...e,width:this.width,height:this.height};if("frame"===e.type){const t=i;t.scaleX=t.scaleX*this.width/e.width,t.scaleY=t.scaleY*this.height/e.height}else if("textbox"===e.type){const t=i,A=(t.algorithm&&t.algorithm!==We.Autosize?t.input:t.text)??"";i=xA(t,A,e)}const A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class An extends ZA{constructor(t){super(),this.commands=t}apply(t){return this.oldState=t,this.commands.reduce(((t,e)=>e.apply(t)),t)}}class nn extends ZA{constructor(t){super(),this.layout=t}apply(t){return this.oldState=t,{...t,layouts:{...t.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:Te()}}}}}class an extends ZA{constructor(t){super(),this.panelName=t}apply(t){this.oldState=t;const e=Object.values(t.layouts).map((t=>{const e=t.layout.panelId===this.panelName;return{...t,elements:e?[]:[...t.elements],modificationID:Te()}})),i={};return e.forEach((t=>{i[t.layout.id]=t})),{...t,layouts:i}}}class rn extends ZA{constructor(t,e){super(),this.element=t,this.layout=e}apply(t){this.oldState=t,t.layouts[this.layout.id]||(t.layouts[this.layout.id]={layout:this.layout,elements:[],modificationID:""});const e=t.layouts[this.layout.id].elements;if(e.find((t=>t.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===e.length){const i=[...e,this.element];return void 0===this.element.layerIndex&&(this.element.layerIndex=this.assignIndex(this.element,i)),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:i,modificationID:Te()}}}}const i=e[e.length-1],A=i.productOverlay?i:null;let n;if(A&&e.pop(),null!==this.element.layerIndex&&void 0!==this.element.layerIndex)n=[...e,this.element].sort(((t,e)=>void 0!==t.layerIndex&&void 0!==e.layerIndex?t.layerIndex-e.layerIndex:0));else{const t=this.assignIndex(this.element,e);this.element.layerIndex=void 0!==t?t:0,n=[...e,this.element]}return A&&n.push(A),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:n,modificationID:Te()}}}}assignIndex(t,e){if(0===e.length)return 0;const i=e.filter((e=>(e.layer||0)===(t.layer||0))).sort(((t,e)=>(t.layerIndex||0)-(e.layerIndex||0)))[e.length-1]?.layerIndex;return void 0!==i?i+1:0}}class sn extends ZA{constructor(t){super(),this.id=t}apply(t){this.oldState=t;let e=!1;const i=Object.values(t.layouts).map((t=>(t.elements.filter((t=>t.id!==this.id)).length!==t.elements.length&&(e=!0),{...t,elements:t.elements.filter((t=>t.id!==this.id)),modificationID:Te()})));e||console.log(`Failed to delete element ${this.id}`);const A={};return i.forEach((t=>{A[t.layout.id]=t})),{...t,layouts:A}}}class on extends ZA{constructor(t,i){super(),this.el=F(e)(t),this.layout=i,this.el.id=Te(),this.el.x+=5,this.el.y+=5}apply(t){return this.oldState=t,new rn(this.el,this.layout).apply(t)}}class cn extends ZA{constructor(t,e,i){super(),this.id=t,this.color=e,this.textFillSpotColor=i}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor,textFillImage:void 0},A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class ln extends ZA{constructor(t,e){super(),this.id=t,this.imageFill=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,textFillImage:this.imageFill},A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class gn extends ZA{constructor(t,e){super(),this.id=t,this.size=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,fontSize:this.size},A=WA(e.id,Object.values(t.layouts)),n=(e.algorithm&&e.algorithm!==We.Autosize?e.input:e.text)??"",a=XA(xA(i,n),A);return{...t,layouts:{...t.layouts,[A.layout.id]:a}}}}class hn extends ZA{constructor(t,e){super(),this.id=t,this.algorithm=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,algorithm:this.algorithm},A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class dn extends ZA{constructor(t,e){super(),this.id=t,this.fontData=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,fontData:this.fontData},A=WA(e.id,Object.values(t.layouts)),n=(e.algorithm&&e.algorithm!==We.Autosize?e.input:e.text)??"",a=XA(xA(i,n),A);return{...t,layouts:{...t.layouts,[A.layout.id]:a}}}}class un extends ZA{constructor(t,e){super(),this.id=t,this.align=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,align:this.align},A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class wn extends ZA{constructor(t,e,i){super(),this.id=t,this.imageData=e,this.offsets=i}apply(t){this.oldState=t;const e=WA(this.id,Object.values(t.layouts)),i=e.elements.findIndex((t=>t.id===this.id)),A=e.elements[i].pattern,n=[...e.elements];n.splice(i,1,{...e.elements[i],pattern:{...A,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={...e,elements:n,modificationID:Te()};return{...t,layouts:{...t.layouts,[e.layout.id]:a}}}}class Bn extends ZA{constructor(t,e){super(),this.id=t,this.text=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i=WA(e.id,Object.values(t.layouts)),A=XA(xA(e,this.text,e),i);return{...t,layouts:{...t.layouts,[i.layout.id]:A}}}}class pn extends ZA{constructor(t,e,i){super(),this.id=t,this.className=e,this.fill=i}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i=e.colors||{},A=i[this.className];i[this.className]={browserValue:this.fill,spotColor:A?.spotColor};const n={...e,colors:i},a=WA(e.id,Object.values(t.layouts)),r=XA(n,a);return{...t,layouts:{...t.layouts,[a.layout.id]:r}}}}class En extends ZA{constructor(t,e,i){super(),this.id=t,this.svgBody=e,this.objectURL=i}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i={...e,svg:this.svgBody,cachedObjectURL:this.objectURL},A=WA(e.id,Object.values(t.layouts)),n=XA(i,A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class mn extends ZA{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!KA(this.id,Object.values(t.layouts)).id)throw new VA;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const i=e.elements.findIndex((t=>t.id===this.id));e.elements.push(e.elements.splice(i,1)[0]);const A=[...e.elements];return A.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:A,modificationID:Te()}}}}}class fn extends ZA{constructor(t){super(),this.id=t}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!i)throw new Error("Layout missing from state!");const A=i.elements.findIndex((t=>t.id===this.id));i.elements.splice(A,1),i.elements.unshift(e);const n=[...i.elements],a=n.splice(A,1)[0];return n.splice(A,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[i.layout.id]:{...t.layouts[i.layout.id],elements:n,modificationID:Te()}}}}}class Cn extends ZA{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!KA(this.id,Object.values(t.layouts)).id)throw new VA;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const i=e.elements.findIndex((t=>t.id===this.id)),A=i+1,n=[...e.elements],a=n.splice(i,1)[0];return n.splice(A,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:n,modificationID:Te()}}}}}class Qn extends ZA{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!KA(this.id,Object.values(t.layouts)).id)throw new VA;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const i=e.elements.findIndex((t=>t.id===this.id)),A=i-1,n=[...e.elements],a=n.splice(i,1)[0];return n.splice(A,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:n,modificationID:Te()}}}}}class yn extends ZA{constructor(t,e){super(),this.id=t,this.value=e}apply(t){this.oldState=t;const e=KA(this.id,Object.values(t.layouts));if(!e.id)throw new VA;const i=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!i)throw new Error("Layout missing from state!");return{...t,layouts:{...t.layouts,[i.layout.id]:XA({...e,layer:this.value},i)}}}}var Dn={};He(Dn,"patternImageDataCache",(()=>bn)),He(Dn,"frameDataCache",(()=>Yn)),He(Dn,"generateFrameSVG",(()=>Pn)),He(Dn,"generateDefaultRectangleFrameSvg",(()=>Nn)),He(Dn,"getVariant",(()=>Rn)),He(Dn,"getFrameData",(()=>kn)),He(Dn,"calculateOffsets",(()=>Hn)),He(Dn,"getPatternImageData",(()=>Un)),He(Dn,"GetSVGDimensions",(()=>Gn)),He(Dn,"svgStringDimensions",(()=>Tn));var In={};He(In,"getExifOrientation",(()=>vn)),He(In,"canvasDims",(()=>Mn)),He(In,"getAttributesFromArrayBuffer",(()=>Sn));let xn=null;const vn=t=>new Promise((e=>{const i=eA(t);(0,o.fromBuffer)(t).then((t=>{const A=t?.mime;if("image/jpeg"!==A)return e(1);(new(0,h.ExifImage)).loadImage(i,((t,i)=>e(t?1:i.image.Orientation||1)))}))})),Mn=t=>{const e=8192,i=t.naturalWidth/t.naturalHeight;return t.naturalHeight<=e&&t.naturalWidth<=e?[t.naturalWidth,t.naturalHeight]:t.naturalHeight>t.naturalWidth?[i*e,e]:[e,e/i]},Sn=async t=>{const e=await(async t=>{const e=await _i(t),i=await(0,g.loadImage)(e),[A,n]=Mn(i),a=await(async()=>{if(null!==xn)return!xn;const t=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return xn=2===t.width&&3===t.height,!xn})();if(!a){const t=(0,g.createCanvas)(A,n);return t.getContext("2d").drawImage(i,0,0,A,n),t}const r=await vn(t),[s,o]=r>4?[n,A]:[A,n],c=(0,g.createCanvas)(s,o),l=c.getContext("2d");switch(r){case 2:l.translate(s,0),l.scale(-1,1);break;case 3:l.translate(s,o),l.rotate(Math.PI);break;case 4:l.translate(0,o),l.scale(1,-1);break;case 5:l.rotate(-.5*Math.PI),l.scale(-1,1);break;case 6:l.rotate(-.5*Math.PI),l.translate(-s,0);break;case 7:l.rotate(-.5*Math.PI),l.translate(-s,o),l.scale(1,-1);break;case 8:l.rotate(.5*Math.PI),l.translate(0,-o)}return l.drawImage(i,0,0,s,o),c})(t);return"image/jpeg"===(await(0,o.fromBuffer)(t))?.mime?{dataUrl:e.toDataURL("image/jpeg",1),height:e.height,width:e.width}:{dataUrl:e.toDataURL(),height:e.height,width:e.width}};He({},"getDefaultVariant",(()=>Fn));const Fn=t=>{const e=t.variants;if(e){if(1===e.length)return e[0];if(void 0!==t.defaultVariant)return e.find((e=>e.id===t.defaultVariant))}},bn=new Map,Yn=new Map,Pn=async(t,e)=>{if(!e){if(!t)throw new Error("No region or src supplied. Cannot construct frame!");return Nn(t)}return Wi(e)},Nn=t=>{const e=t.width,i=e/t.height,A=Math.max(e,512),n=A/i;return`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${A} ${n}'>\n <path id="target-path" d='M0 0 h ${A} v ${n} h ${-A} Z' />\n </svg>\n `},Rn=(t,e)=>{if(!e)return;const i=e.variants?.find((e=>e.id===t.frameVariantId))||Fn(e);if(!i)throw new Error(`No variant with ID: ${t.frameVariantId}`);if(!i.asset)throw new Error(`No asset for variant with ID: ${t.frameVariantId}`);return i},kn=async t=>{const e=Vi().parseFromString(t,"image/svg+xml"),i=e.querySelector("svg");if(!i)throw new Error("Malformed frame SVG: <svg> tag not found");const A=i.getAttribute("viewBox");if(!A)throw new Error("SVG missing viewBox.");const n=A.split(" "),a=parseFloat(n[3])||1,r=parseFloat(n[2])||1,s=e.getElementById("target-path"),o=e.getElementsByClassName("st0").item(0);if(s){const t=s.getAttribute("d");if(!t)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const e={path:t,width:r,height:a};return Yn.set(t,e),e}if(o){const t=o.getAttribute("d");if(!t)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const e={path:t,width:r,height:a};return Yn.set(t,e),e}throw new Error("Malformed frame SVG")},Hn=(t,e,i)=>{const A=e.width>=e.height,n=t.width>=t.height,a=e.width/2,r=e.height/2,s=(A?e.height:e.width)/(n?t.width:t.height),o=i?.scale||s,c=a-t.width/2*o,l=i?.left||c,g=r-t.height/2*o;return{x:l,y:i?.top||g,zoom:o}},Un=async t=>{if(bn.has(t))return bn.get(t);if(t.endsWith("svg")){const e=await Gn(t),i=e.width,A=e.height,n={src:t,width:i,height:A,aspect:i/A};return bn.set(t,n),n}{const e=await Ki(t),i=await Sn(e),A={src:t,width:i.width,height:i.height,aspect:i.width/i.height};return bn.set(t,A),A}},Gn=async t=>{const e=await Wi(t);return Tn(e)},Tn=t=>{const e=Vi().parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)throw new Error("No svg tag found, this svg must be malformed!");const i=e.getAttribute("viewBox"),A=e.getAttribute("width"),n=e.getAttribute("height"),a=i?i?.split(" ").map((t=>Number(t))):[0,0,Number(A),Number(n)];if(!a)throw new Error("No viewbox or width/height values detected on SVG file!");return{width:a[2],height:a[3]}};var On={};He(On,"determineCorrectFontSizeAndLines",(()=>Ln)),He(On,"determineCorrectTextboxRegion",(()=>zn));const Jn=(t,e,i,A,n)=>{if(e.some((t=>null==t)))throw new Error(`Failed to autosize lines: ${e.join(", ")}`);let a=e.map((t=>t.split("\n"))).flat(),r=a.length,s=a.map((t=>EA(t,A,n)));const o=n.getApproximateHeight()*A;let c=!0;for(;c;){if(o+(r-1)*i>t.height)return[null,null];const e=Math.max(...s);if(e<=t.width)return[a,e];const l=s.reduce(((t,e,i,A)=>e>A[t]?i:t),0),g=a[l];let h=!1,d=g.length;for(;!h&&d>-1;){d=g.lastIndexOf(" ",d-1);const e=[g.slice(0,d),g.slice(d+1)],i=e.map((t=>EA(t,A,n)));i[0]<=t.width&&(a=[...a.slice(0,l),...e,...a.slice(l+1)],s=[...s.slice(0,l),...i,...s.slice(l+1)],r+=1,h=!0)}h||(c=!1)}return[null,null]},Ln=(t,e,i,A,n)=>{let a,r;const s=cA(e),o=s.getFont();if(n.size){const e=t/o.unitsPerEm;return[a,r]=Jn(i,A,t,e,s),[n.size,a,r]}let c=6-pA;if(A.length>0){let t=A,e=0;for(;(!n.maxSize||c<=n.maxSize)&&t;)c+=pA,e=c/o.unitsPerEm,[t,r]=Jn(i,A,c,e,s)}c>6&&(c-=pA),n.minSize&&c<n.minSize&&(c=n.minSize);const l=c/o.unitsPerEm;return[a,r]=Jn(i,A,c,l,s),[c,a,r]},zn=(t,e,i,A,n)=>{let a={...t},r={...t},[s,o,c]=Ln(i,e,r,A,{size:0,minSize:i,maxSize:i});var l,g;return c&&c<a.width&&(r.width=c,"left"===n?(r.left+=Math.sin(a.rotation*Math.PI/360)*(a.width-c),r.top+=Math.sin(a.rotation*Math.PI/180)*(c-a.width)/2):r.left+="right"===n?a.width-c:(a.width-c)/2,[s,o]=Ln(i,e,r,A,{size:i}),s===i&&o&&(l=A,g=o,l.map(((t,e)=>[t,g[e]]))).every((([t,e])=>t===e))&&(a=r)),a};var jn={};He(jn,"svgObjectURL",(()=>Wn)),He(jn,"LayoutElementFactory",(()=>qn));const Vn=(t,e)=>{const i=t.layoutState.elements.filter((t=>t.layer===e)),A=Math.max(...i.map((t=>t.layerIndex)).filter((t=>void 0!==t)));return Math.max(A,0)+1},Kn=async t=>new Promise((e=>{Wi(t).then((t=>{e(t)})).catch((t=>console.error(t)))})),Wn=async t=>{const e=Vi().parseFromString(t,"image/svg+xml").firstElementChild;if(!e)throw new Error("Failed to read SVG");const i=(new XMLSerializer).serializeToString(e),A=document.createElement("canvas"),n=A.getContext("2d"),a=await ke.from(n,i,{anonymousCrossOrigin:!0,ignoreDimensions:!1}),r=e.getAttribute("width"),s=e.getAttribute("height"),o=2048;if(s&&r){const t=parseFloat(s),e=parseFloat(r)/t;e>1?a.resize(o,o/e):a.resize(o*e,o)}else a.resize(o,o);return await a.render(),await(async t=>new Promise(((e,i)=>{try{if(!URL||!URL.createObjectURL)throw new Error("Environment incapable of generating ObjectURL");t.toBlob((i=>{if(!i){if(0===t.width||0===t.height)throw new Error(`Canvas dimensions are invalid (${t.width},${t.height})`);if(t.width*t.height>=268435456)throw new Error(`Canvas dimensions exceed device limit (${t.width},${t.height})`);throw new Error("Couldn't generate object URL for Illustration, the blob was undefined!")}e(URL.createObjectURL(i))}))}catch(t){i(t)}})))(A)},Xn=async(t,e,i,A)=>{const n=t.layoutState.layout.useEditableArea&&t.layoutState.layout.editableArea||{width:t.layoutState.layout.width,height:t.layoutState.layout.height,x:0,y:0},a=n.width<n.height?n.width:n.height,r=t.layoutState.layout.useEditableArea?a/1.3:a/2,s={top:n.y+n.height/2-r/2,left:n.x+n.width/2-r/2,width:r,height:r,rotation:0,panelId:t.layoutState.layout.panelId};if(i&&e===ze.Illustration){const t=await TA(await Kn(i)),e=Vi().parseFromString(t.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!e)throw new Error("SVG missing viewBox.");const A=s.height,n=e.split(" "),a=(parseFloat(n[2])||1)/(parseFloat(n[3])||1);s.height=s.width/a,s.top+=(A-s.height)/2}if(i&&e===ze.Image){const t=s.height,e=await Ki(i),A=await Sn(e),n=A.width/A.height;s.height=s.width/n,s.top+=(t-s.height)/2}if(i&&e===ze.Textbox&&A?.text&&A?.fontScale){const t={assetUrl:i,name:(await sA(i)).names.fullName.en},e=cA(t),a=EA(A.text,A?.fontScale,e);s.width=Math.min(a,.85*n.width),s.left=n.x+n.width/2-s.width/2}return s};class qn{static async getFrame(t,e){const i=await Pn(e.region,e.src),A=await kn(i),n=e.region||await Xn(t,ze.Frame);return{id:Te(),x:n.left,y:n.top,width:n.width,height:n.height,layer:n.layer||0,layerIndex:n.layerIndex||Vn(t,n.layer||0),rotation:n.rotation,scaleX:n.width/A.width,scaleY:n.height/A.height,path:A.path,dataWidth:A.width,dataHeight:A.height,type:ze.Frame,disablePlaceholder:e.configuration.disablePlaceholder,focalBlur:e.configuration.focalBlur,focalBlurStrength:e.configuration.focalBlurStrength,focalBlurRadius:e.configuration.focalBlurRadius,forceImageCover:e.configuration.forceImageCover,pattern:void 0,immutable:n.immutable}}static async getImage(t,e){const i=e.region||await Xn(t,ze.Image,e.src);return{id:Te(),src:e.src,type:ze.Image,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||Vn(t,i.layer||0),immutable:i.immutable,preserveAspectRatio:"none"}}static async getTextbox(t,e){const{configuration:i,fontSrc:A,designInputStep:n}=e,a=await sA(A),r={assetUrl:A,name:a.names.fullName.en},s=n?.text||i.defaultText||"",o=i.replaceableText?i.replaceableText.replace("{{}}",s):s,c=QA(o,{vertical:i.vertical,uppercase:i.uppercase}),l=e.region||await Xn(t,ze.Textbox,A,{text:c,fontScale:i.size?i.size/a.unitsPerEm:void 0}),g=xA({id:Te(),type:ze.Textbox,x:l.left,y:l.top,width:l.width,height:l.height,align:DA(i.textAlign,i.vertical),curved:i.curved,fill:n?.color||i.colour||"#000000",fontData:r,layer:l.layer||0,layerIndex:l.layerIndex||Vn(t,l.layer||0),paths:i.paths,rotation:l.rotation,vertical:i.vertical,verticalAlign:i.verticalAlign||"middle",algorithm:We.Traditional,fontSize:i.size||Math.max(Math.round(.025*l.height),1),text:c,input:s},c),h=BA({...l,height:g.height},r,g.fontSize,g?.text?.split("\n")||[],g.align);return{...g,x:h.left,y:h.top+(l.height-h.height)/2,width:h.width,height:h.height}}static async getShape(t,e){const i=`\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="${e.color}"\n />\n </svg>\n `,A={};A["spiff-fill-shape"]={browserValue:e.color};const n=e.region||await Xn(t,ze.Illustration),a=Te();return{stepRegion:e.region,colors:A,id:a,svg:i,type:ze.Illustration,y:n.top,x:n.left,rotation:n.rotation,width:n.width,height:n.height,layer:n.layer||0,layerIndex:n.layerIndex||Vn(t,n.layer||0),immutable:n.immutable}}static async getIllustration(t,e){const i=e.region||await Xn(t,ze.Illustration,e.src),A=await TA(await Kn(e.src)),n=await Wn(A.svg),a=Te();return{cachedObjectURL:n,stepRegion:e.region,colors:A.colors,id:a,src:e.src,svg:A.svg,type:ze.Illustration,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||Vn(t,i.layer||0),immutable:i.immutable}}}function Zn(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class $n extends Error{constructor(t){super(t),this.name=this.constructor.name}}class _n extends $n{constructor(t){super(`ConfigurationError - ${t}`)}}class ta extends _n{constructor(t){super(`Option not Configured: ${t.stepTitle}`),Zn(this,"optionId",void 0),this.optionId=t?.optionId||"N/A"}}class ea extends _n{constructor(t){super(`Panel not Found: ${t.panelId}`),Zn(this,"panelId",void 0),this.panelId=t?.panelId||"N/A"}}class ia extends _n{constructor(t){super(`Asset not found for variant: ${t.name}`),Zn(this,"variant",void 0),this.variant=t}}class Aa extends _n{constructor(t){super(`Resource not found for asset: ${t.name}`),Zn(this,"asset",void 0),this.asset=t}}class na extends _n{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),Zn(this,"step",void 0),this.step=t}}class aa extends $n{constructor(t){super(`ImplementationError - ${t}`)}}class ra extends aa{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class sa extends aa{constructor(t){super(`Parsing Error: ${t}`)}}class oa extends aa{constructor(t){super(`Client Error: ${t}`)}}class ca extends aa{constructor(t){super(`Resource Generation Failed: ${t}`)}}function la(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ga{get(t){return localStorage.getItem(t)||void 0}set(t,e){localStorage.setItem(t,e)}remove(t){localStorage.removeItem(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const i=JSON.stringify([...e.entries()]);this.set(t,i)}}class ha{constructor(){la(this,"storage",new Map)}get(t){return this.storage.get(t)||void 0}set(t,e){this.storage.set(t,e)}remove(t){this.storage.delete(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const i=JSON.stringify([...e.entries()]);this.set(t,i)}}const da=(()=>{try{return localStorage?new ga:new ha}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new ha}})();function ua(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const wa=new class{constructor(){ua(this,"defaultServerUrl","https://api.spiff.com.au"),ua(this,"defaultServicesApiUrl","https://services.spiff.com.au"),ua(this,"defaultHubUrl","https://hub.spiff.com.au"),ua(this,"serverUrl",void 0),ua(this,"servicesApiUrl",void 0),ua(this,"hubUrl",void 0),ua(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(t){this.serverUrl=t,this.serverUrlCallbacks.forEach((t=>t()))}setServicesApiUrl(t){this.servicesApiUrl=t}setHubUrl(t){this.hubUrl=t}addServerUrlCallback(t){this.serverUrlCallbacks.push(t)}};function Ba(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let pa;const Ea=t=>{pa=t};let ma;const fa=t=>{ma=t};let Ca;const Qa=t=>{Ca=t};let ya;const Da=new class{constructor(){Ba(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),wa.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const e=(0,t.createHttpLink)({uri:`${wa.getServerUrl()}/graphql`,fetch:f.fetch}),i=(0,E.setContext)((async(t,e)=>{const{headers:i}=e,A=i||{},n=await(async()=>{const t={applicationKey:ya,bundleOwnerId:ma,customerToken:Ca,transactionOwnerId:pa};return"undefined"!=typeof window&&(window.location.href.includes("/workflows/product/")||window.location.href.includes("hub=true"))?{...await new Promise((t=>{const e=wa.getHubUrl(),i=A=>{A.origin===e&&(window.removeEventListener("message",i),t(A.data))};window.parent!==window&&(window.addEventListener("message",i,!1),window.parent.postMessage("ready",e))})),...t}:t})(),a=e.bearer??n.bearer,r=e.partnerId??n.partnerId,s=e.activeIntegration??n.activeIntegration,o=e.transactionOwnerId??n.transactionOwnerId,c=e.customerToken??n.customerToken,l=e.applicationKey??n.applicationKey,g=e.bundleOwnerId??n.bundleOwnerId;return a&&(A.Authorization=`Bearer ${a}`),r&&(A.partnerId=r),s&&(A.activeIntegration=s),o&&(A.transactionOwnerId=o),c&&(A.customerToken=c),l&&(A["X-Application-Key"]=l),g&&(A.bundleOwnerId=g),{headers:A}})),A=(0,m.onError)((({operation:t,graphQLErrors:e,networkError:i})=>{(e||[]).forEach((({message:e,locations:i,path:A})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+t.operationName),console.log("Query:"+JSON.stringify(t.query)),console.log(`Message: ${e}, Location: ${JSON.stringify(i,null,2)}, Path: ${A}`),console.log("Variables:"+JSON.stringify(t.variables))})),i&&console.log("GraphQL Network error")}));const n=new(0,t.InMemoryCache)({addTypename:!1,typePolicies:{Transaction:{fields:{bulkEmailAddress:{read:(t=null)=>t,merge:(t,e)=>e||t||null},transactionOwnerId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},customLogoLink:{read:(t=null)=>t,merge:(t,e)=>e||t||null},workflowFooterLogoLink:{read:(t=null)=>t,merge:(t,e)=>e||t||null},workflowState:{read:(t=null)=>t,merge:(t,e)=>e||t||null},bulkSourceUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalDesignProductId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalDesignProductVariantId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalCartProductId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalCartProductVariantId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},lastSyncedAt:{read:(t=null)=>t,merge:(t,e)=>e||t||null},lineItem:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}},WorkflowProduct:{fields:{isPresent:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}},Product:{fields:{imageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},overlayImageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},preloadImageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},weight:{read:(t=null)=>t,merge:(t,e)=>e||t||null},conversionConfiguration:{read:(t=null)=>t,merge:(t,e)=>e||t||null},bulkConfiguration:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}}}});return new(0,t.ApolloClient)({link:(0,t.from)([A,i,e]),cache:n,name:"Core"})}};function Ia(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const xa=t.gql`
2
2
  fragment AssetFields on Asset {
3
3
  name
4
4
  key
@@ -487,7 +487,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
487
487
  id
488
488
  }
489
489
  }
490
- `;class So extends Io{constructor(t,e){super(t,e),xo(this,"transaction",this.manager.getTransaction())}selectVariant(){throw new Error("Bulk step does not support variants.")}async setDesignName(t){await Da.getShadowGraphqlClient().mutate({mutation:Mo,variables:{transactionId:this.manager.getTransaction().id,designName:t}});const e=this.manager.getTransaction();this.manager.setTransaction({...e,designName:t})}addVariationRecord(){const t=this.manager.addVariationRecord({transactionId:this.transaction.id,values:[]});return this.manager.setCurrentVariationRecord(t),t}updateBulkIsConnected(t){this.manager.updateStorage(this.getId(),{bulkIsConnected:t})}openBulkSourceUrl(){window.open(this.transaction.bulkSourceUrl,"_blank")}async sendGoogleSheetLinkToEmail(t){await Da.getShadowGraphqlClient().mutate({mutation:vo,variables:{id:this.transaction.id,details:{emailAddress:t},type:"Owner"}}),this.openBulkSourceUrl()}deleteVariationRecord(t){this.manager.removeVariationRecord(t)}getAspects(){return this.step.data.aspects}}class Fo extends Io{constructor(t,e){super(t,e)}async selectVariant(t){if(this.getCurrentVariant()!==t)return no.selectVariant(this.step,t.getResource(),this.manager.getRegionElements(this.step.stepName)||[],(t=>this.setUpdateState(t)),this.manager)}getColors(){const t=this.manager.getRegionElements(this.step.stepName)||[];if(0!==t.length)try{return KA(t[0].id,this.manager.getAllLayoutData()).colors}catch(t){console.error(t)}}setColor(t,e){const i=new Map;return i.set(t,e),no.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,(()=>this.manager.getCommandContext().getAllLayouts()),i)}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?no.availableColors(this.step,this.manager):Promise.resolve([])}hasVaryingSelection(){return this.step.data.varySelection}hasVaryingColors(){return this.step.data.varyColors}isColorPickerEnabled(){return this.step.data.colorPickerEnabled}}class bo extends Io{constructor(t,e){super(t,e)}selectVariant(t){return ao.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Yo extends Io{constructor(t,e){super(t,e)}selectVariant(t){return ro.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Po extends Io{constructor(t,e){super(t,e)}selectVariant(t){return oo.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class No extends Io{constructor(t,e){super(t,e)}async selectVariant(t){if(!t.getId())throw new Error("Unable to select variant with a null ID");await co.selectVariant(this.step,t.getId(),this.manager)}getDisplayType(){return this.step.option?.displayType}}class Ro extends Io{constructor(t,e){super(t,e)}selectVariant(t){const e=t.getResource();return lo.selectVariant(this.step,{fill:e.color,stroke:e.color,variant:e},this.manager.getRegionElements(this.step.stepName)||[],this.manager)}setColor(t){return lo.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return lo.availableColours(this.step)}}class ko extends Io{constructor(t,e){super(t,e)}async selectVariant(t){Bo.selectVariant(this.step,t.getResource(),this.manager,(t=>{if(t)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occured with test",messageType:Eo.Error,stepID:this.step.stepName}]);else{const t=this.manager.getInformationResults().filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}}),(t=>{}))}getAvailableFillColors(){return this.step.data.colorPickerEnabled?Bo.availableFillColors(this.step):[]}async setFillColor(t){const e=this.manager.getRegionElements(this.step.stepName);await Bo.changeFillColor(this.step,t,e,this.manager)}getFillColor(){return this.manager.getStepStorage(this.step.stepName)?.color||"#000000"}getAvailableFillImages(){return Bo.availableFillImages(this.step)}async setFillImage(t){const e=this.manager.getRegionElements(this.step.stepName);await Bo.changeFillImage(this.step,t,e,this.manager)}getFillImage(){return this.manager.getStepStorage(this.step.stepName)?.fillImage}setFullTextCustomization(t){const e=this.manager.getStepStorage(this.step.stepName)?.inputText||"",i=void 0!==this.step.data.replaceableText?this.step.data.replaceableText.replace("{{}}",e):e,A=t?i:this.step.data.defaultText;this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:A,defaultCleared:!1});return this.setText(A)}setText(t){const e={input:t},i=Bo.findLayoutElements(this.manager,this.step),A=Bo.filterUnsupportedCharacters(t,i[0]?.fontData);!!this.step.data&&!!this.step.data.maxLength&&A.length>this.step.data.maxLength||(e.input=A);const n=i.length<=0,a=n?{inputText:A,text:A}:{inputText:A};if(this.manager.updateStorage(this.step.stepName,a),this.manager.updateMetadata(this.step.stepName,{text:A}),n)return e;const{command:r,errors:s,helperText:o}=Bo.updateInputText(A,i,this.step,this.manager);r&&this.manager.getCommandDispatcher()(r);const c=this.manager.getInformationResults(),l=s[0]?.localizationKey;if(l)this.manager.setInformationResults([...c,{message:`${l} - ${this.step.stepTitle}`,messageType:Eo.Error,stepID:this.step.stepName}]);else{const t=c.filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}return e.helperText=l||o,e.errorText=l,e}getText(){const t=this.step.data.defaultText;return this.manager.getStepStorage(this.step.stepName)?.text||t||""}isReplaceable(){return this.step.data.userCanReplaceText}clearDefaultTextIfNecessary(){if(!this.manager.getStepStorage(this.step.stepName)?.defaultCleared&&this.step.data.deleteDefaultOnFocus){const t=this.setText("");return this.manager.updateStorage(this.step.stepName,{defaultCleared:!0,inputText:""}),t}}hasVaryingText(){return this.step.data.varyText}hasVaryingColor(){return this.step.data.varyColor}hasVaryingSelection(){return this.step.data.varySelection}hasColorPicker(){return this.step.data.colorPickerEnabled}getRegions(){return this.step.data.regions}getCharacterLimit(){return this.step.data.maxLength}getCharactersRemaining(){const t=this.step.data.maxLength;if(void 0===t)return;return t-this.getText().length}}class Ho{static get(t,e){switch(e.type){case si.Question:return new No(t,e);case si.Text:return new ko(t,e);case si.Illustration:return new Fo(t,e);case si.Picture:return new Po(t,e);case si.Shape:return new Ro(t,e);case si.Material:return new bo(t,e);case si.Model:return new Yo(t,e);case si.Frame:return new Zc(t,e);case si.Bulk:return new So(t,e);default:throw new ra(`Step type ${e.type} not yet supported in Core SDK`)}}}function Uo(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const Go=t.gql`
490
+ `;class So extends Io{constructor(t,e){super(t,e),xo(this,"transaction",this.manager.getTransaction())}selectVariant(){throw new Error("Bulk step does not support variants.")}async setDesignName(t){await Da.getShadowGraphqlClient().mutate({mutation:Mo,variables:{transactionId:this.manager.getTransaction().id,designName:t}});const e=this.manager.getTransaction();this.manager.setTransaction({...e,designName:t})}addVariationRecord(){const t=this.manager.addVariationRecord({transactionId:this.transaction.id,values:[]});return this.manager.setCurrentVariationRecord(t),t}updateBulkIsConnected(t){this.manager.updateStorage(this.getId(),{bulkIsConnected:t})}openBulkSourceUrl(){window.open(this.transaction.bulkSourceUrl,"_blank")}async sendGoogleSheetLinkToEmail(t){await Da.getShadowGraphqlClient().mutate({mutation:vo,variables:{id:this.transaction.id,details:{emailAddress:t},type:"Owner"}}),this.openBulkSourceUrl()}deleteVariationRecord(t){this.manager.removeVariationRecord(t)}getAspects(){return this.step.data.aspects}}class Fo extends Io{constructor(t,e){super(t,e)}async selectVariant(t){if(this.getCurrentVariant()!==t)return no.selectVariant(this.step,t.getResource(),this.manager.getRegionElements(this.step.stepName)||[],(t=>this.setUpdateState(t)),this.manager)}getColors(){const t=this.manager.getRegionElements(this.step.stepName)||[];if(0!==t.length)try{return KA(t[0].id,this.manager.getAllLayoutData()).colors}catch(t){console.error(t)}}setColor(t,e){const i=new Map;return i.set(t,e),no.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,(()=>this.manager.getCommandContext().getAllLayouts()),i)}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?no.availableColors(this.step,this.manager):Promise.resolve([])}hasVaryingSelection(){return this.step.data.varySelection}hasVaryingColors(){return this.step.data.varyColors}isColorPickerEnabled(){return this.step.data.colorPickerEnabled}}class bo extends Io{constructor(t,e){super(t,e)}selectVariant(t){return ao.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Yo extends Io{constructor(t,e){super(t,e)}selectVariant(t){return ro.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Po extends Io{constructor(t,e){super(t,e)}selectVariant(t){return oo.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class No extends Io{constructor(t,e){super(t,e)}async selectVariant(t){if(!t.getId())throw new Error("Unable to select variant with a null ID");await co.selectVariant(this.step,t.getId(),this.manager)}getDisplayType(){return this.step.option?.displayType}}class Ro extends Io{constructor(t,e){super(t,e)}selectVariant(t){const e=t.getResource();return lo.selectVariant(this.step,{fill:e.color,stroke:e.color,variant:e},this.manager.getRegionElements(this.step.stepName)||[],this.manager)}setColor(t){return lo.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return lo.availableColours(this.step)}}class ko extends Io{constructor(t,e){super(t,e)}async selectVariant(t){Bo.selectVariant(this.step,t.getResource(),this.manager,(t=>{if(t)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occured with test",messageType:Eo.Error,stepID:this.step.stepName}]);else{const t=this.manager.getInformationResults().filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}}),(t=>{}))}getAvailableFillColors(){return this.step.data.colorPickerEnabled?Bo.availableFillColors(this.step):[]}async setFillColor(t){const e=this.manager.getRegionElements(this.step.stepName);await Bo.changeFillColor(this.step,t,e,this.manager)}getFillColor(){return this.manager.getStepStorage(this.step.stepName)?.color||"#000000"}getAvailableFillImages(){return Bo.availableFillImages(this.step)}async setFillImage(t){const e=this.manager.getRegionElements(this.step.stepName);await Bo.changeFillImage(this.step,t,e,this.manager)}getFillImage(){return this.manager.getStepStorage(this.step.stepName)?.fillImage}setFullTextCustomization(t){const e=this.manager.getStepStorage(this.step.stepName)?.inputText||"",i=void 0!==this.step.data.replaceableText?this.step.data.replaceableText.replace("{{}}",e):e,A=t?i:this.step.data.defaultText;this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:A,defaultCleared:!1});return this.setText(A)}setText(t){const e={input:t},i=Bo.findLayoutElements(this.manager,this.step),A=Bo.filterUnsupportedCharacters(t,i[0]?.fontData);!!this.step.data&&!!this.step.data.maxLength&&A.length>this.step.data.maxLength||(e.input=A);const n=i.length<=0,a=n?{inputText:A,text:A}:{inputText:A};if(this.manager.updateStorage(this.step.stepName,a),this.manager.updateMetadata(this.step.stepName,{text:A}),n)return e;const{command:r,errors:s,helperText:o}=Bo.updateInputText(A,i,this.step,this.manager);r&&this.manager.getCommandDispatcher()(r);const c=this.manager.getInformationResults(),l=s[0]?.localizationKey;if(l)this.manager.setInformationResults([...c,{message:`${l} - ${this.step.stepTitle}`,messageType:Eo.Error,stepID:this.step.stepName}]);else{const t=c.filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}return e.helperText=l||o,e.errorText=l,e}getText(){const t=this.step.data.defaultText;return this.manager.getStepStorage(this.step.stepName)?.text||t||""}isReplaceable(){return this.step.data.userCanReplaceText}clearDefaultTextIfNecessary(){if(!this.manager.getStepStorage(this.step.stepName)?.defaultCleared&&this.step.data.deleteDefaultOnFocus){const t=this.setText("");return this.manager.updateStorage(this.step.stepName,{defaultCleared:!0,inputText:""}),t}}hasVaryingText(){return this.step.data.varyText}hasVaryingColor(){return this.step.data.varyColor}hasVaryingSelection(){return this.step.data.varySelection}hasColorPicker(){return this.step.data.colorPickerEnabled}getRegions(){return this.step.data.regions}getCharacterLimit(){return this.step.data.maxLength}getCharactersRemaining(){const t=this.step.data.maxLength;if(void 0===t)return;return t-this.getText().length}}class Ho{static get(t,e){switch(e.type){case si.Question:return new No(t,e);case si.Text:return new ko(t,e);case si.Illustration:return new Fo(t,e);case si.Picture:return new Po(t,e);case si.Shape:return new Ro(t,e);case si.Material:return new bo(t,e);case si.Model:return new Yo(t,e);case si.Frame:return new _c(t,e);case si.Bulk:return new So(t,e);default:throw new ra(`Step type ${e.type} not yet supported in Core SDK`)}}}function Uo(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const Go=t.gql`
491
491
  mutation CreateDesign(
492
492
  $name: String!
493
493
  $layouts: [LayoutInput]!
@@ -519,7 +519,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
519
519
  }
520
520
  }
521
521
  }
522
- `,To=(t,e,i)=>{const A={};return e.steps.forEach((e=>{Object.assign(A,(e=>{const A={};if("Frame"===e.type){const n=t[e.stepName],a=e.data;if(!n||a.hideImageInCart&&i)return A;A[`${e.stepTitle} image`]=n.image}if("Illustration"===e.type){const n=t[e.stepName],a=e.data;if(!n||a.hideColorsInCart&&i||!n.colors)return A;if(n.colors.length>0){const t=n.colors.join(", ").toUpperCase();A[`${e.stepTitle} colors`]=t}}if("Module"===e.type){const n=t[e.stepName],a=e.data;if(!n||a.hideTextInCart&&i)return A;A[`${e.stepTitle} text`]=n.text}if("Text"===e.type){const n=t[e.stepName];if(!n)return A;const a=e.data;a.hideTextInCart&&i||(A[`${e.stepTitle} text`]=n.text),!n.color||a.hideColorInCart&&i||(A[`${e.stepTitle} color`]=n.color)}return A})(e))})),A},Oo=(t,e,i,A,n,a,r,s,o,c)=>{const l=(da.getMap("transactionOwnerIds")||new Map).get(t.id),g={baseCost:i,designProductId:t.externalDesignProductId,designProductVariantId:t.externalDesignProductVariantId,event:"onComplete",exportedData:a,externalCartProductId:t.externalCartProductId,externalCartProductVariantId:t.externalCartProductVariantId,lineItemImageUrl:r||"",optionsCost:A,processExecutionId:c,transactionId:t.id,transactionOwnerId:l,weight:e.weight,workflowViewerLink:t.workflowViewerLink||"",workflowViewerReadOnlyLink:t.workflowViewerReadOnlyLink||""};return n&&(g.metadata=n),s&&(g.selectedVariants=s),o&&(g.sku=o),g},Jo=async(t,e,i,A,n,a,r,s)=>{const o=t.product?.basePrice||0,c=t.priceModifierTotal||0,l=((t,e,i,A)=>{const n={};let a;if(i){a=To(i,e,!1);for(const t of Object.keys(a))n[t]={value:a[t],priceModifier:0}}else if(A){a=A;for(const t of Object.keys(a))n[t]={value:a[t],priceModifier:0}}for(const i of Object.keys(t)){const A=t[i],a=e.steps.find((t=>t.stepTitle===i));if(1===A.length)n[`${a?.stepTitle} selection`]={value:A[0].name,priceModifier:A[0].priceModifier};else if(A.length>1)for(let t=0;t<A.length;t++)n[`${a?.stepTitle} selection ${t+1}`]={value:A[t].name,priceModifier:A[t].priceModifier}}return n})(A,i,void 0,a);return Oo(t,e,o,c,a,l,r,A,n,s)},Lo=async(t,e,i,A,n,a,r,s,o,c,l,g,h)=>{o("workflow.steps.finish.finalize.buildingLayouts"),await t.outstandingRequestsPromise();const d=Da.getShadowGraphqlClient(),u=await d.query({query:Us,variables:{id:a.id},fetchPolicy:"no-cache",errorPolicy:"all"}),w=u.data?.transactions[0].workflowState;!u.errors&&w||(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(A())),u.errors&&u.errors.forEach((t=>{u.errors&&console.log("Server Error:",t.message)})),await t.updateStateWithServerImmediate(A),console.log("Server state is undefined @ Workflow completion"));const B=t.getPreviewService(),p=e?.finalizeStepConfig?.lookAtAnimation,E=B&&100===B.getSceneInitializationProgress()&&e.showModelOnFinishStep&&!!p,m=h&&To(h,e,!0),f=h&&To(h,e,!1),C=async t=>{const i={};let A=0;if(Object.keys(r).length>0)for(const n of Object.keys(r)){const a=r[n],s=e.steps.find((t=>t.stepName===n));for(let e=0;e<a.selections.length;++e){const n=a.selections[e];if(s&&(!t||s.option&&(s.option.variants||[]).length>1&&!s.data.hideSelectionInCart&&!s.data.hideSelectionsInCart)){const t=s.stepTitle;i[t]?i[t].push({id:n.id||"",name:n.name,priceModifier:n.priceModifier}):i[t]=[{id:n.id||"",name:n.name,priceModifier:n.priceModifier}]}A+=n.priceModifier}}return[i,A]},[Q]=await C(!0),y=Object.fromEntries(Object.keys(Q).map((t=>[t,Q[t].map((t=>t.id))]))),[D]=await C(!1),I=Object.fromEntries(Object.keys(D).map((t=>[t,D[t].map((t=>t.id))]))),x=await g(E);o("workflow.steps.finish.finalize.creatingDesign"),a.bulk&&await c(l);const v=await(async t=>(await Da.getShadowGraphqlClient().mutate({mutation:Go,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:t.name,layouts:t.layouts,workflowId:t.workflowId,transactionId:t.transactionId,previewImage:t.previewImage,useThreeDimPreview:t.useThreeDimPreview,metadata:t.metadata,selectedVariants:t.selectedVariants}})).data?.designCreate)((()=>{const t={name:s,layouts:i.map((t=>({index:t.index,panelId:t.panelId}))),workflowId:e.id,transactionId:a.id,useThreeDimPreview:!!E,previewImage:x};if(f){const e=[];for(const[t,i]of Object.entries(f))e.push({key:t,value:i});t.metadata=e}if(y){const e=[];for(const[t,i]of Object.entries(I))e.push({key:t,ids:i});t.selectedVariants=e}return t})()),M=v?.transaction?.previewImageLink;o("workflow.steps.finish.finalize.updatingTransaction");const S=(await Da.getShadowGraphqlClient().query({query:Hs,variables:{id:a.id}})).data.transactions[0];return a.bulk?((t,e,i,A)=>{const n=(t.product?.basePrice||0)*(t.variationsCount||0),a=t.priceModifierTotal||0,r={items:{value:t.variationsCount?`${t.variationsCount}`:"0",priceModifier:0}};return Oo(t,e,n,a,void 0,r,i,void 0,void 0,A)})(S,n,M,v?.processExecution?.id):await Jo(S,n,e,Q,v?.sku,m,M,v?.processExecution?.id)};let zo;var jo;(jo=zo||(zo={})).Local="Local",jo.Remote="Remote";const Vo=new class{constructor(){Uo(this,"localPersistenceKey","designTransactions"),Uo(this,"storageMethod",zo.Local),Uo(this,"designSavedListeners",[])}attachSaveListener(t){this.designSavedListeners.push(t)}detachSaveListener(t){this.designSavedListeners=this.designSavedListeners.filter((e=>e!==t))}async getSavedDesigns(){if(this.storageMethod===zo.Local){const t=da.get(this.localPersistenceKey);return t?JSON.parse(t):[]}throw new ra("Unexpected storage method requested")}async getSavedDesignByTransaction(t){return(await this.getSavedDesigns()).find((e=>e.transactionId===t))}async addDesign(t){const e=(await this.getSavedDesigns()).filter((e=>e.transactionId!==t.transactionId));e.unshift(t),await this.setDesigns(e),this.designSavedListeners.forEach((e=>e(t)))}async renameDesign(t,e){const i=await this.getSavedDesigns(),A=i.find((e=>e.transactionId===t));if(!A)throw new Error(`No saved design for transaction ${t}.`);A.title=e,await this.setDesigns(i)}async removeDesign(t){const e=await this.getSavedDesigns();await this.setDesigns(e.filter((e=>e.transactionId!==t)))}async setDesigns(t){if(this.storageMethod!==zo.Local)throw new ra("Unexpected storage method requested");da.set(this.localPersistenceKey,JSON.stringify(t))}};function Ko(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Wo{constructor(t,e){if(Ko(this,"client",void 0),Ko(this,"commandContext",void 0),Ko(this,"workflowManager",void 0),Ko(this,"isReadOnly",void 0),Ko(this,"renderableScenes",[]),Ko(this,"renderableSceneCallbacks",[]),Ko(this,"debouncedSavedDesignUpdate",F(I)((async()=>{await Vo.getSavedDesignByTransaction(this.getWorkflowManager().getTransaction().id)&&this.save()}),2500)),Ko(this,"getCanvasObjectURLAsync",(async t=>new Promise(((e,i)=>{try{t.toBlob((t=>{if(t){const i=URL.createObjectURL(t);e(i)}}))}catch(t){i(t)}})))),!e.workflow)throw new Error("No Workflow ID provided.");this.client=t;const i=e.layouts;this.commandContext=new JA,this.commandContext.initialize(i,e.reloadedState),this.isReadOnly=e.transaction.isOrdered||!!e.readOnly,this.workflowManager=new Co(e.workflow,e.product.profanities?.map((t=>t.word))||[],i,this.commandContext,(t=>{try{this.debouncedSavedDesignUpdate()}catch{console.error("Failed to update saved design details.")}return e.stateMutationFunc(t)}),e.transaction,e.product,e.previewService,e.renderableContextService,e.reloadedState,e.readOnly,e.modelContainer,e.isReloadedTransaction),this.workflowManager.addSelectionCallback((t=>{const e=t.traversableScenes.map((t=>{const e=t.renderableSteps.map((t=>t.stepName));return{id:t.name,title:t.title,renderableSteps:e}}));this.renderableScenes=e,this.renderableSceneCallbacks.forEach((t=>t(e)))}))}getClient(){return this.client}getIsReadOnly(){return this.isReadOnly}getCommandContext(){return this.commandContext}getWorkflowManager(){return this.workflowManager}async updateVariationRecords(t){await Da.getShadowGraphqlClient().mutate({mutation:ks,variables:{transactionId:this.workflowManager.getTransaction().id,updates:t.map((t=>({recordNumber:t.recordNumber,values:t.values.map((t=>({aspect:t.aspect,stepName:t.stepName,value:t.value})))})))}})}async createPreviewImage(t,e){const i=this.workflowManager.getWorkflow(),A=i?.finalizeStepConfig?.lookAtAnimation;if(t){if(!A)throw new Error("Failed to generate cart preview image!");return await(this.workflowManager.getPreviewService()?.renderSceneScreenshot(512,A))||""}const n=document.createElement("canvas");let a=2048;e&&e<=2048&&(a=e),n.width=a,n.height=a;const r=this.commandContext.getAllLayouts(),s=i.defaultPreviewPanelIndex||0,o=i.panels[s],c=r.find((t=>t.layoutState?.layout.panelId===o?.name))||r[0],l=c.layoutState.layout.previewRegion?{x:c.layoutState.layout.previewRegion.left,y:c.layoutState.layout.previewRegion.top,width:c.layoutState.layout.previewRegion.width,height:c.layoutState.layout.previewRegion.height}:{x:0,y:0,width:c.layoutState.layout.width,height:c.layoutState.layout.height},g=this.commandContext.getLayoutById(c.layoutState.layout.id),h=n.getContext("2d");if(!h)throw new ca("Failed to obtain 2D context for preview image creation");const d=zA(g.layoutState.layout,g.layoutState.elements,{renderingConfiguration:{purpose:Ve.Print,region:{left:l.x,top:l.y,width:l.width,height:l.height}}}),u=F(Q).renderToStaticMarkup(d),w=await ke.from(h,u,{anonymousCrossOrigin:!0,ignoreDimensions:!1});await w.render();const B=await this.getCanvasObjectURLAsync(n);return n.toDataURL(B)}getStepById(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepName===t));if(e&&this.stepHasHandle(e))return Ho.get(this.getWorkflowManager(),e)}getSteps(){return this.getScenes().flatMap((t=>this.getStepsByScene(t)))}getScenes(){return this.getWorkflowManager().getWorkflow().stepGroups.map((t=>({id:t.id,name:t.name,stepIds:t.stepNames})))}getSelectionPriceSubunits(){const t=this.getWorkflowManager().getWorkflowSelections();let e=0;return Object.values(t).forEach((t=>{e+=t.selections.map((t=>t.priceModifier)).reduce(((t,e)=>t+e))})),e}getBasePriceSubunits(){return this.getWorkflowManager().getProduct().basePrice||0}getTotalPriceSubunits(){return this.getBasePriceSubunits()+this.getSelectionPriceSubunits()}getBulkStep(){if(this.getWorkflowManager().getTransaction().bulk){const t=this.getWorkflowManager().getProduct().bulkConfiguration,e={type:si.Bulk,stepName:"Bulk",stepTitle:t?.stepTitle??"workflow.steps.bulk.title",helpText:t?.helpText,data:{aspects:Gs(this.getWorkflowManager().getWorkflow())},conditions:[]};return Ho.get(this.getWorkflowManager(),e)}}getStepByName(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepTitle===t));if(e&&this.stepHasHandle(e))return Ho.get(this.getWorkflowManager(),e)}getStepsByType(t){return this.getWorkflowManager().getWorkflow().steps.filter((e=>e.type===t)).map((t=>Ho.get(this.getWorkflowManager(),t)))}getStepsByScene(t){if(!this.getWorkflowManager().getWorkflow().stepGroups.find((e=>e.name===t.name)))throw new Error("Given scene is not present on workflow! Be careful when persisting scenes that you only use them with the relevant workflow.");return t.stepIds.map((t=>this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepName===t)))).filter((t=>this.stepHasHandle(t))).map((t=>Ho.get(this.getWorkflowManager(),t)))}async attachCustomerDetails(t){return this.assignCustomerDetails({emailAddress:t.email})}async assignCustomerDetails(t){const e=(await Da.getShadowGraphqlClient().mutate({mutation:vo,variables:{id:this.getWorkflowManager().getTransaction().id,details:t,type:"Owner"}})).data?.transactionAddStakeholder?.stakeholders?.find((e=>e.customer?.emailAddress===t.emailAddress));if(e?.customer){this.getWorkflowManager().setTransactionCustomer(e.customer);const t=da.getMap("transactionCustomerIds")||new Map;t.set(this.getWorkflowManager().getTransaction().id,e.customer.id),da.setMap("transactionCustomerIds",t)}}attachRenderableSceneListener(t){this.renderableSceneCallbacks.push(t),t(this.renderableScenes)}detachRenderableSceneListener(t){this.renderableSceneCallbacks=this.renderableSceneCallbacks.filter((e=>e!==t))}async save(t){if(!this.getCommandContext().getState())throw new ra("State undefined!");const e={title:await(async()=>{if(t)return t;const e=this.getWorkflowManager().getTransaction().id,i=(await Vo.getSavedDesigns()).find((t=>t.transactionId===e))?.title;return i||"My design"})(),thumbnail:await this.createPreviewImage(!1,256),transactionId:this.getWorkflowManager().getTransaction().id,productId:this.getWorkflowManager().getProduct().id,integrationProductId:this.getWorkflowManager().getTransaction().integrationProduct.id,workflowName:this.getWorkflowManager().getWorkflow().name,workflowId:this.getWorkflowManager().getWorkflow().id,lastEdited:new Date};return await Vo.addDesign(e),e}async copy(){const t=F(e)(this.getCommandContext().getState());if(!t)throw new ra("Internal state is undefined! Cannot copy experience!");const i=JSON.stringify(t.transaction),A=this.getWorkflowManager().getWorkflow(),n=new jc({}),a=this.getWorkflowManager().getTransaction().integrationProduct?.id;if(!a)throw new ra("Integration product id is undefined!");await n.initFromIntegrationProduct(a);return await n.getWorkflowExperience(A.id,i,void 0)}async onDesignFinished(t){return Lo(this.workflowManager,this.workflowManager.getWorkflow(),this.workflowManager.getLayouts(),(()=>this.commandContext.getState()),this.workflowManager.getProduct(),this.workflowManager.getTransaction(),this.workflowManager.getWorkflowSelections(),this.workflowManager.getWorkflow().name,t||(()=>{}),(t=>this.updateVariationRecords(t)),this.workflowManager.getVariationRecords(),(t=>this.createPreviewImage(t)),this.workflowManager.getWorkflowMetadata())}stepHasHandle(t){return t.type!==si.SilentIllustration&&t.type!==si.ProductOverlay}getExportedData(){const t=new Map,e=this.getWorkflowManager().getWorkflowMetadata(),i=this.getWorkflowManager().getWorkflowSelections();return Object.keys(e).forEach((i=>{const A=this.workflowManager.getWorkflow().steps.find((t=>t.stepName===i));if(!A)return;t.has(A.stepTitle)||t.set(A.stepTitle,{});const n=e[i];Object.keys(n).forEach((e=>{t.get(A.stepTitle)[e]=n[e]}))})),Object.keys(i)?.forEach((e=>{const A=this.workflowManager.getWorkflow().steps.find((t=>t.stepName===e));A&&(t.has(A.stepTitle)||t.set(A.stepTitle,{}),t.get(A.stepTitle).selection=i[e].selections[0].name)})),t}}const Xo=v.gql`
522
+ `,To=(t,e,i)=>{const A={};return e.steps.forEach((e=>{Object.assign(A,(e=>{const A={};if("Frame"===e.type){const n=t[e.stepName],a=e.data;if(!n||a.hideImageInCart&&i)return A;A[`${e.stepTitle} image`]=n.image}if("Illustration"===e.type){const n=t[e.stepName],a=e.data;if(!n||a.hideColorsInCart&&i||!n.colors)return A;if(n.colors.length>0){const t=n.colors.join(", ").toUpperCase();A[`${e.stepTitle} colors`]=t}}if("Module"===e.type){const n=t[e.stepName],a=e.data;if(!n||a.hideTextInCart&&i)return A;A[`${e.stepTitle} text`]=n.text}if("Text"===e.type){const n=t[e.stepName];if(!n)return A;const a=e.data;a.hideTextInCart&&i||(A[`${e.stepTitle} text`]=n.text),!n.color||a.hideColorInCart&&i||(A[`${e.stepTitle} color`]=n.color)}return A})(e))})),A},Oo=(t,e,i,A,n,a,r,s,o,c)=>{const l=(da.getMap("transactionOwnerIds")||new Map).get(t.id),g={baseCost:i,designProductId:t.externalDesignProductId,designProductVariantId:t.externalDesignProductVariantId,event:"onComplete",exportedData:a,externalCartProductId:t.externalCartProductId,externalCartProductVariantId:t.externalCartProductVariantId,lineItemImageUrl:r||"",optionsCost:A,processExecutionId:c,transactionId:t.id,transactionOwnerId:l,weight:e.weight,workflowViewerLink:t.workflowViewerLink||"",workflowViewerReadOnlyLink:t.workflowViewerReadOnlyLink||""};return n&&(g.metadata=n),s&&(g.selectedVariants=s),o&&(g.sku=o),g},Jo=async(t,e,i,A,n,a,r,s)=>{const o=t.product?.basePrice||0,c=t.priceModifierTotal||0,l=((t,e,i,A)=>{const n={};let a;if(i){a=To(i,e,!1);for(const t of Object.keys(a))n[t]={value:a[t],priceModifier:0}}else if(A){a=A;for(const t of Object.keys(a))n[t]={value:a[t],priceModifier:0}}for(const i of Object.keys(t)){const A=t[i],a=e.steps.find((t=>t.stepTitle===i));if(1===A.length)n[`${a?.stepTitle} selection`]={value:A[0].name,priceModifier:A[0].priceModifier};else if(A.length>1)for(let t=0;t<A.length;t++)n[`${a?.stepTitle} selection ${t+1}`]={value:A[t].name,priceModifier:A[t].priceModifier}}return n})(A,i,void 0,a);return Oo(t,e,o,c,a,l,r,A,n,s)},Lo=async(t,e,i,A,n,a,r,s,o,c,l,g,h)=>{o("workflow.steps.finish.finalize.buildingLayouts"),await t.outstandingRequestsPromise();const d=Da.getShadowGraphqlClient(),u=await d.query({query:Us,variables:{id:a.id},fetchPolicy:"no-cache",errorPolicy:"all"}),w=u.data?.transactions[0].workflowState;!u.errors&&w||(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(A())),u.errors&&u.errors.forEach((t=>{u.errors&&console.log("Server Error:",t.message)})),await t.updateStateWithServerImmediate(A),console.log("Server state is undefined @ Workflow completion"));const B=t.getPreviewService(),p=e?.finalizeStepConfig?.lookAtAnimation,E=B&&100===B.getSceneInitializationProgress()&&e.showModelOnFinishStep&&!!p,m=h&&To(h,e,!0),f=h&&To(h,e,!1),C=async t=>{const i={};let A=0;if(Object.keys(r).length>0)for(const n of Object.keys(r)){const a=r[n],s=e.steps.find((t=>t.stepName===n));for(let e=0;e<a.selections.length;++e){const n=a.selections[e];if(s&&(!t||s.option&&(s.option.variants||[]).length>1&&!s.data.hideSelectionInCart&&!s.data.hideSelectionsInCart)){const t=s.stepTitle;i[t]?i[t].push({id:n.id||"",name:n.name,priceModifier:n.priceModifier}):i[t]=[{id:n.id||"",name:n.name,priceModifier:n.priceModifier}]}A+=n.priceModifier}}return[i,A]},[Q]=await C(!0),y=Object.fromEntries(Object.keys(Q).map((t=>[t,Q[t].map((t=>t.id))]))),[D]=await C(!1),I=Object.fromEntries(Object.keys(D).map((t=>[t,D[t].map((t=>t.id))]))),x=await g(E);o("workflow.steps.finish.finalize.creatingDesign"),a.bulk&&await c(l);const v=await(async t=>(await Da.getShadowGraphqlClient().mutate({mutation:Go,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:t.name,layouts:t.layouts,workflowId:t.workflowId,transactionId:t.transactionId,previewImage:t.previewImage,useThreeDimPreview:t.useThreeDimPreview,metadata:t.metadata,selectedVariants:t.selectedVariants}})).data?.designCreate)((()=>{const t={name:s,layouts:i.map((t=>({index:t.index,panelId:t.panelId}))),workflowId:e.id,transactionId:a.id,useThreeDimPreview:!!E,previewImage:x};if(f){const e=[];for(const[t,i]of Object.entries(f))e.push({key:t,value:i});t.metadata=e}if(y){const e=[];for(const[t,i]of Object.entries(I))e.push({key:t,ids:i});t.selectedVariants=e}return t})()),M=v?.transaction?.previewImageLink;o("workflow.steps.finish.finalize.updatingTransaction");const S=(await Da.getShadowGraphqlClient().query({query:Hs,variables:{id:a.id}})).data.transactions[0];return a.bulk?((t,e,i,A)=>{const n=(t.product?.basePrice||0)*(t.variationsCount||0),a=t.priceModifierTotal||0,r={items:{value:t.variationsCount?`${t.variationsCount}`:"0",priceModifier:0}};return Oo(t,e,n,a,void 0,r,i,void 0,void 0,A)})(S,n,M,v?.processExecution?.id):await Jo(S,n,e,Q,v?.sku,m,M,v?.processExecution?.id)};let zo;var jo;(jo=zo||(zo={})).Local="Local",jo.Remote="Remote";const Vo=new class{constructor(){Uo(this,"localPersistenceKey","designTransactions"),Uo(this,"storageMethod",zo.Local),Uo(this,"designSavedListeners",[])}attachSaveListener(t){this.designSavedListeners.push(t)}detachSaveListener(t){this.designSavedListeners=this.designSavedListeners.filter((e=>e!==t))}async getSavedDesigns(){if(this.storageMethod===zo.Local){const t=da.get(this.localPersistenceKey);return t?JSON.parse(t):[]}throw new ra("Unexpected storage method requested")}async getSavedDesignByTransaction(t){return(await this.getSavedDesigns()).find((e=>e.transactionId===t))}async addDesign(t){const e=(await this.getSavedDesigns()).filter((e=>e.transactionId!==t.transactionId));e.unshift(t),await this.setDesigns(e),this.designSavedListeners.forEach((e=>e(t)))}async renameDesign(t,e){const i=await this.getSavedDesigns(),A=i.find((e=>e.transactionId===t));if(!A)throw new Error(`No saved design for transaction ${t}.`);A.title=e,await this.setDesigns(i)}async removeDesign(t){const e=await this.getSavedDesigns();await this.setDesigns(e.filter((e=>e.transactionId!==t)))}async setDesigns(t){if(this.storageMethod!==zo.Local)throw new ra("Unexpected storage method requested");da.set(this.localPersistenceKey,JSON.stringify(t))}};function Ko(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Wo{constructor(t,e){if(Ko(this,"client",void 0),Ko(this,"commandContext",void 0),Ko(this,"workflowManager",void 0),Ko(this,"isReadOnly",void 0),Ko(this,"renderableScenes",[]),Ko(this,"renderableSceneCallbacks",[]),Ko(this,"debouncedSavedDesignUpdate",F(I)((async()=>{await Vo.getSavedDesignByTransaction(this.getWorkflowManager().getTransaction().id)&&this.save()}),2500)),Ko(this,"getCanvasObjectURLAsync",(async t=>new Promise(((e,i)=>{try{t.toBlob((t=>{if(t){const i=URL.createObjectURL(t);e(i)}}))}catch(t){i(t)}})))),!e.workflow)throw new Error("No Workflow ID provided.");this.client=t;const i=e.layouts;this.commandContext=new JA,this.commandContext.initialize(i,e.reloadedState),this.isReadOnly=e.transaction.isOrdered||!!e.readOnly,this.workflowManager=new Co(e.workflow,e.product.profanities?.map((t=>t.word))||[],i,this.commandContext,(t=>{try{this.debouncedSavedDesignUpdate()}catch{console.error("Failed to update saved design details.")}return e.stateMutationFunc(t)}),e.transaction,e.product,e.previewService,e.renderableContextService,e.reloadedState,e.readOnly,e.modelContainer,e.isReloadedTransaction),this.workflowManager.addSelectionCallback((t=>{const e=t.traversableScenes.map((t=>{const e=t.renderableSteps.map((t=>t.stepName));return{id:t.name,title:t.title,renderableSteps:e}}));this.renderableScenes=e,this.renderableSceneCallbacks.forEach((t=>t(e)))}))}getClient(){return this.client}getIsReadOnly(){return this.isReadOnly}getCommandContext(){return this.commandContext}getWorkflowManager(){return this.workflowManager}async updateVariationRecords(t){await Da.getShadowGraphqlClient().mutate({mutation:ks,variables:{transactionId:this.workflowManager.getTransaction().id,updates:t.map((t=>({recordNumber:t.recordNumber,values:t.values.map((t=>({aspect:t.aspect,stepName:t.stepName,value:t.value})))})))}})}async createPreviewImage(t,e){const i=this.workflowManager.getWorkflow(),A=i?.finalizeStepConfig?.lookAtAnimation;if(t){if(!A)throw new Error("Failed to generate cart preview image!");return await(this.workflowManager.getPreviewService()?.renderSceneScreenshot(512,A))||""}const n=document.createElement("canvas");let a=2048;e&&e<=2048&&(a=e),n.width=a,n.height=a;const r=this.commandContext.getAllLayouts(),s=i.defaultPreviewPanelIndex||0,o=i.panels[s],c=r.find((t=>t.layoutState?.layout.panelId===o?.name))||r[0],l=c.layoutState.layout.previewRegion?{x:c.layoutState.layout.previewRegion.left,y:c.layoutState.layout.previewRegion.top,width:c.layoutState.layout.previewRegion.width,height:c.layoutState.layout.previewRegion.height}:{x:0,y:0,width:c.layoutState.layout.width,height:c.layoutState.layout.height},g=this.commandContext.getLayoutById(c.layoutState.layout.id),h=n.getContext("2d");if(!h)throw new ca("Failed to obtain 2D context for preview image creation");const d=zA(g.layoutState.layout,g.layoutState.elements,{renderingConfiguration:{purpose:Ve.Print,region:{left:l.x,top:l.y,width:l.width,height:l.height}}}),u=F(Q).renderToStaticMarkup(d),w=await ke.from(h,u,{anonymousCrossOrigin:!0,ignoreDimensions:!1});await w.render();const B=await this.getCanvasObjectURLAsync(n);return n.toDataURL(B)}getStepById(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepName===t));if(e&&this.stepHasHandle(e))return Ho.get(this.getWorkflowManager(),e)}getSteps(){return this.getScenes().flatMap((t=>this.getStepsByScene(t)))}getScenes(){return this.getWorkflowManager().getWorkflow().stepGroups.map((t=>({id:t.id,name:t.name,stepIds:t.stepNames})))}getSelectionPriceSubunits(){const t=this.getWorkflowManager().getWorkflowSelections();let e=0;return Object.values(t).forEach((t=>{e+=t.selections.map((t=>t.priceModifier)).reduce(((t,e)=>t+e))})),e}getBasePriceSubunits(){return this.getWorkflowManager().getProduct().basePrice||0}getTotalPriceSubunits(){return this.getBasePriceSubunits()+this.getSelectionPriceSubunits()}getBulkStep(){if(this.getWorkflowManager().getTransaction().bulk){const t=this.getWorkflowManager().getProduct().bulkConfiguration,e={type:si.Bulk,stepName:"Bulk",stepTitle:t?.stepTitle??"workflow.steps.bulk.title",helpText:t?.helpText,data:{aspects:Gs(this.getWorkflowManager().getWorkflow())},conditions:[]};return Ho.get(this.getWorkflowManager(),e)}}getStepByName(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepTitle===t));if(e&&this.stepHasHandle(e))return Ho.get(this.getWorkflowManager(),e)}getStepsByType(t){return this.getWorkflowManager().getWorkflow().steps.filter((e=>e.type===t)).map((t=>Ho.get(this.getWorkflowManager(),t)))}getStepsByScene(t){if(!this.getWorkflowManager().getWorkflow().stepGroups.find((e=>e.name===t.name)))throw new Error("Given scene is not present on workflow! Be careful when persisting scenes that you only use them with the relevant workflow.");return t.stepIds.map((t=>this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepName===t)))).filter((t=>this.stepHasHandle(t))).map((t=>Ho.get(this.getWorkflowManager(),t)))}async attachCustomerDetails(t){return this.assignCustomerDetails({emailAddress:t.email})}async assignCustomerDetails(t){const e=(await Da.getShadowGraphqlClient().mutate({mutation:vo,variables:{id:this.getWorkflowManager().getTransaction().id,details:t,type:"Owner"}})).data?.transactionAddStakeholder?.stakeholders?.find((e=>e.customer?.emailAddress===t.emailAddress));if(e?.customer){this.getWorkflowManager().setTransactionCustomer(e.customer);const t=da.getMap("transactionCustomerIds")||new Map;t.set(this.getWorkflowManager().getTransaction().id,e.customer.id),da.setMap("transactionCustomerIds",t)}}attachRenderableSceneListener(t){this.renderableSceneCallbacks.push(t),t(this.renderableScenes)}detachRenderableSceneListener(t){this.renderableSceneCallbacks=this.renderableSceneCallbacks.filter((e=>e!==t))}async save(t){if(!this.getCommandContext().getState())throw new ra("State undefined!");const e={title:await(async()=>{if(t)return t;const e=this.getWorkflowManager().getTransaction().id,i=(await Vo.getSavedDesigns()).find((t=>t.transactionId===e))?.title;return i||"My design"})(),thumbnail:await this.createPreviewImage(!1,256),transactionId:this.getWorkflowManager().getTransaction().id,productId:this.getWorkflowManager().getProduct().id,integrationProductId:this.getWorkflowManager().getTransaction().integrationProduct.id,workflowName:this.getWorkflowManager().getWorkflow().name,workflowId:this.getWorkflowManager().getWorkflow().id,lastEdited:new Date};return await Vo.addDesign(e),e}async copy(){const t=F(e)(this.getCommandContext().getState());if(!t)throw new ra("Internal state is undefined! Cannot copy experience!");const i=JSON.stringify(t.transaction),A=this.getWorkflowManager().getWorkflow(),n=new Kc({}),a=this.getWorkflowManager().getTransaction().integrationProduct?.id;if(!a)throw new ra("Integration product id is undefined!");await n.initFromIntegrationProduct(a);return await n.getWorkflowExperience(A.id,i,void 0)}async onDesignFinished(t){return Lo(this.workflowManager,this.workflowManager.getWorkflow(),this.workflowManager.getLayouts(),(()=>this.commandContext.getState()),this.workflowManager.getProduct(),this.workflowManager.getTransaction(),this.workflowManager.getWorkflowSelections(),this.workflowManager.getWorkflow().name,t||(()=>{}),(t=>this.updateVariationRecords(t)),this.workflowManager.getVariationRecords(),(t=>this.createPreviewImage(t)),this.workflowManager.getWorkflowMetadata())}stepHasHandle(t){return t.type!==si.SilentIllustration&&t.type!==si.ProductOverlay}getExportedData(){const t=new Map,e=this.getWorkflowManager().getWorkflowMetadata(),i=this.getWorkflowManager().getWorkflowSelections();return Object.keys(e).forEach((i=>{const A=this.workflowManager.getWorkflow().steps.find((t=>t.stepName===i));if(!A)return;t.has(A.stepTitle)||t.set(A.stepTitle,{});const n=e[i];Object.keys(n).forEach((e=>{t.get(A.stepTitle)[e]=n[e]}))})),Object.keys(i)?.forEach((e=>{const A=this.workflowManager.getWorkflow().steps.find((t=>t.stepName===e));A&&(t.has(A.stepTitle)||t.set(A.stepTitle,{}),t.get(A.stepTitle).selection=i[e].selections[0].name)})),t}}const Xo=v.gql`
523
523
  fragment ProductCollectionProductFields on Product {
524
524
  id
525
525
  basePrice
@@ -767,7 +767,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
767
767
  }
768
768
  }
769
769
  }
770
- `,variables:{ids:[e]}}),!a||!a.data?.getProcessFlowExecution)throw new Error("Failed to retrieve server response for execution.");const i=a.data?.getProcessFlowExecution?.completedAt;if(i){r=!0;break}if(a.data?.getProcessFlowExecution?.failedAt)throw new Error("Execution has failed to complete. See Executions tab in partner account on SpiffCommerce Hub.");if(s+=1,s>=5)throw new Error("Maximum wait time exceeded for execution result.")}return Promise.resolve(a.data?.getProcessFlowExecution)}}class Ic{constructor(t){Qc(this,"value",void 0),this.value=t}getRaw(){return this.value}getValueForTransmission(){const t=this.value;return t.startsWith("[")?JSON.stringify(JSON.parse(t)):JSON.stringify(t)}}let xc;var vc;(vc=xc||(xc={})).Transaction="Transaction",vc.Bundle="Bundle",vc.Product="Product",vc.Variant="Variant",vc.Option="Option",vc.LineItem="LineItem",vc.Asset="Asset";class Mc extends Ic{constructor(t,e){if("Asset"!==e&&!Mc.validUUID(t))throw new Error("Invalid ID, must be a valid v4 UUID. https://www.uuidgenerator.net/");super(`{"isSpiffObject": true, "id": "${t}", "type": "${e}"}`)}static validUUID(t){return t.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)}}class Sc extends Ic{constructor(t){super(t)}}function Fc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const bc=t.gql`
770
+ `,variables:{ids:[e]}}),!a||!a.data?.getProcessFlowExecution)throw new Error("Failed to retrieve server response for execution.");const i=a.data?.getProcessFlowExecution?.completedAt;if(i){r=!0;break}if(a.data?.getProcessFlowExecution?.failedAt)throw new Error("Execution has failed to complete. See Executions tab in partner account on SpiffCommerce Hub.");if(s+=1,s>=5)throw new Error("Maximum wait time exceeded for execution result.")}return Promise.resolve(a.data?.getProcessFlowExecution)}}class Ic{constructor(t){Qc(this,"value",void 0),this.value=t}getRaw(){return this.value}getValueForTransmission(){const t=this.value;return t.startsWith("[")?JSON.stringify(JSON.parse(t)):JSON.stringify(t)}}let xc;var vc;(vc=xc||(xc={})).Transaction="Transaction",vc.Bundle="Bundle",vc.Product="Product",vc.Variant="Variant",vc.Option="Option",vc.LineItem="LineItem",vc.Asset="Asset";class Mc extends Ic{constructor(t,e){if("Asset"!==e&&!Mc.validUUID(t))throw new Error("Invalid ID, must be a valid v4 UUID. https://www.uuidgenerator.net/");super(`{"isSpiffObject": true, "id": "${t}", "type": "${e}"}`)}static validUUID(t){return t.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)}}class Sc extends Ic{constructor(t){super(t)}}function Fc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var bc=new class{constructor(){Fc(this,"cache",{})}get(t){return this.cache[t]}has(t){return t in this.cache}set(t,e){return this.cache[t]=e,e}delete(t){delete this.cache[t]}};function Yc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const Pc=t.gql`
771
771
  fragment RegionFields on Region {
772
772
  width
773
773
  top
@@ -785,7 +785,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
785
785
  height
786
786
  }
787
787
  }
788
- `,Yc=t.gql`
788
+ `,Nc=t.gql`
789
789
  fragment LookAtAnimationFields on LookAtAnimation {
790
790
  latDeg
791
791
  lonDeg
@@ -796,7 +796,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
796
796
  z
797
797
  }
798
798
  }
799
- `,Pc=t.gql`
799
+ `,Rc=t.gql`
800
800
  fragment RenderingPipelineConfigurationFields on RenderingPipelineConfiguration {
801
801
  antiAliasing {
802
802
  samples
@@ -880,21 +880,21 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
880
880
  weight
881
881
  }
882
882
  }
883
- `,Nc=t.gql`
883
+ `,kc=t.gql`
884
884
  fragment ModelAnimationFields on ModelAnimation {
885
885
  from
886
886
  to
887
887
  loop
888
888
  name
889
889
  }
890
- `,Rc=t.gql`
890
+ `,Hc=t.gql`
891
891
  ${xa}
892
892
  ${Ma}
893
893
  ${ka}
894
- ${bc}
895
- ${Yc}
896
894
  ${Pc}
897
895
  ${Nc}
896
+ ${Rc}
897
+ ${kc}
898
898
  query GetWorkflow($id: String!) {
899
899
  workflow(id: $id) {
900
900
  allowProofDownload
@@ -1272,7 +1272,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
1272
1272
  }
1273
1273
  }
1274
1274
  }
1275
- `,kc=t.gql`
1275
+ `,Uc=t.gql`
1276
1276
  query GetTransactionForPartner($id: String!) {
1277
1277
  transactions(ids: [$id]) {
1278
1278
  id
@@ -1289,7 +1289,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
1289
1289
  }
1290
1290
  }
1291
1291
  }
1292
- `,Hc=t.gql`
1292
+ `,Gc=t.gql`
1293
1293
  ${xa}
1294
1294
  query GetWorkflowForTheme($id: String!) {
1295
1295
  workflow(id: $id) {
@@ -1311,21 +1311,21 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
1311
1311
  }
1312
1312
  }
1313
1313
  }
1314
- `,Uc=t.gql`
1314
+ `,Tc=t.gql`
1315
1315
  query GetCustomer($emailAddress: String!) {
1316
1316
  customer(emailAddress: $emailAddress) {
1317
1317
  id
1318
1318
  emailAddress
1319
1319
  }
1320
1320
  }
1321
- `,Gc=t.gql`
1321
+ `,Oc=t.gql`
1322
1322
  mutation CustomerCreate($details: CustomerDetailsInput!) {
1323
1323
  customerCreate(details: $details) {
1324
1324
  id
1325
1325
  emailAddress
1326
1326
  }
1327
1327
  }
1328
- `,Tc=t.gql`
1328
+ `,Jc=t.gql`
1329
1329
  mutation CustomerAuthenticate($loginToken: String!) {
1330
1330
  customerAuthenticate(loginToken: $loginToken) {
1331
1331
  id
@@ -1349,11 +1349,11 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
1349
1349
  }
1350
1350
  }
1351
1351
  }
1352
- `,Oc=t.gql`
1352
+ `,Lc=t.gql`
1353
1353
  mutation CustomerGenerateVerificationCode($emailAddress: String!) {
1354
1354
  customerGenerateVerificationCode(emailAddress: $emailAddress)
1355
1355
  }
1356
- `,Jc=t.gql`
1356
+ `,zc=t.gql`
1357
1357
  mutation CustomerVerifyCode($emailAddress: String!, $verificationCode: String!) {
1358
1358
  customerVerifyCode(emailAddress: $emailAddress, verificationCode: $verificationCode) {
1359
1359
  id
@@ -1381,5 +1381,5 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
1381
1381
  }
1382
1382
  }
1383
1383
  }
1384
- `,Lc=async t=>{const e=(await Da.getShadowGraphqlClient().query({query:Rc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return e.steps.forEach((t=>{delete t.data.__typename})),e},zc=(t,e)=>{const i=t.workflowState,A=i?JSON.parse(i):void 0;return A?Object.values(A.layouts).map((t=>t.layout)):e.panels.sort(((t,e)=>t.index-e.index)).map((t=>({id:Te(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})))};class jc{constructor(t){var e;Fc(this,"options",void 0),Fc(this,"initialized",void 0),Fc(this,"currencyCode",void 0),Fc(this,"customer",void 0),Fc(this,"experienceOptions",void 0),Fc(this,"updateTransactionState",(async t=>{try{return Da.getShadowGraphqlClient().mutate({...t,mutation:Ns})}catch(t){throw console.error(t),new oa("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,ya=e)}getAssetManager(){return Na}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!this.options.applicationKey)throw new Error("Application key required to use Flow Service.");return new Dc}async authenticateBundleFromLocalStorage(t){const e=da.getMap("bundleOwnerIds");if(e?.has(t)){const i=e.get(t);return fa(i),Promise.resolve({success:!0,stakeholderType:ar.Owner})}const i=da.getMap("bundleCustomerIds");if(i?.has(t)){const e=i.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const e=Da.getShadowGraphqlClient(),i=await e.query({query:kc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!i.data.transactions||0===i.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const A=i.data.transactions[0],n=A.product?.partner?.id;if(!n)throw new Error(`Unable to read transaction: ${t}`);if(A.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const a=da.getMap("transactionOwnerIds");if(a?.has(t)){const e=a.get(t);return Ea(e),Promise.resolve({success:!0,stakeholderType:ar.Owner})}const r=da.getMap("transactionCustomerIds");if(r?.has(t)){const e=r.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.transactions?.some((e=>e.id===t))))||this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}const s=(await e.query({query:Hc,errorPolicy:"all",variables:{id:A.workflowId}})).data.workflow;if(!s)throw new Error(`Unable to read workflow: ${A.workflowId}`);return Promise.resolve({success:!1,theme:s.overrideTheme,customLogoLink:A.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=da.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),da.setMap("transactionCustomerIds",e))}getStakeholderTypeForTransaction(t){const e=this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return e.type}async getOrCreateCustomer(t){this.customer=void 0;const e=Da.getShadowGraphqlClient(),i=(await e.query({query:Uc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!i.id){const i=(await e.mutate({mutation:Gc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!i)throw new Error("Unable to create customer.");return this.customer=i,{customer:i,isAuthenticated:!1}}const A=await this.authenticateCustomerId(i.id);return{customer:this.customer||i,isAuthenticated:A}}async authenticateCustomerId(t){const e=Da.getShadowGraphqlClient(),i=da.getMap("customerTokens");if(!i?.has(t))return!1;const A=i.get(t);if(!A)return!1;const n=(await e.mutate({mutation:Tc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:A}})).data?.customerAuthenticate;return!!n&&(Qa(A),this.customer=n,!0)}async generateVerificationCode(t){await Da.getShadowGraphqlClient().mutate({mutation:Oc,variables:{emailAddress:t}})}async verifyCode(t,e){const i=(await Da.getShadowGraphqlClient().mutate({mutation:Jc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data?.customerVerifyCode;if(i?.loginToken){if(!i.partner?.id)throw new Error(`Unable to find customer: ${t}`);const e=da.getMap("customerTokens")||new Map;return e.set(i.id,i.loginToken),da.setMap("customerTokens",e),Qa(i.loginToken),this.customer={...i,loginToken:void 0},!0}return!1}async getNewBundle(t){const e=(await Da.getShadowGraphqlClient().mutate({mutation:tc,variables:{collectionId:t},fetchPolicy:"no-cache"})).data?.bundleCreate;if(!e)throw new Error("Unable to create bundle");fa(e.bundleOwnerId);const i=da.getMap("bundleOwnerIds")||new Map;return i.set(e.id,e.bundleOwnerId),da.setMap("bundleOwnerIds",i),new Cc(this,e)}async getExistingBundle(t,e){const i=da.getMap("bundleOwnerIds")?.get(t);i&&fa(i);const A=await Da.getShadowGraphqlClient().query({query:Zo,variables:{id:t},fetchPolicy:"no-cache"});if(!A.data?.bundles||0===A.data?.bundles.length||!A.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const n=A.data?.bundles[0],a=new Cc(this,n,e);return await a.getInitializationPromise(),a}async getBundleStakeholders(){if(!this.customer)throw new Error("Customer not authenticated.");const t=await Da.getShadowGraphqlClient().query({query:_o,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!t.data?.customers||0===t.data.customers.length)throw new Error("Unable to find customer.");return t.data.customers[0].bundleStakeholders||[]}async getWorkflowExperience(t,e,i,A){if(!A)return await this.getWorkflowExperienceDeprecated(t,e,i);const n=async t=>{for(const e in t.layouts){const i=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<i.length;++t){const e=i[t];e.src&&e.svg&&(e.cachedObjectURL=await Wn(e.svg))}const A=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<A.length;++t){const e=A[t];e.fontData?.assetUrl&&sA(e.fontData.assetUrl)}}},{transaction:a,workflow:r,readOnly:s}=await(async()=>{const t=Da.getShadowGraphqlClient();if("transaction"===A.type){const{transactionId:e,readOnly:i}=A,n=await t.query({query:Ps,variables:{id:e},errorPolicy:"all",fetchPolicy:"no-cache"});if(!n.data?.transactions||0===n.data.transactions.length)throw new oa("Existing transaction not found.");const a=n.data?.transactions[0];if(!a.workflowId)throw new oa("Existing transaction has no workflow ID.");const r=await Lc(a.workflowId);if(!a.product)throw new oa("Failed to load transaction, product not available.");return{transaction:a,workflow:r,readOnly:i}}if("integration"===A.type||"external"===A.type){const e=async()=>{const e="integration"===A.type?{integrationProductId:A.integrationProductId}:{externalIntegrationId:A.externalIntegrationId,externalProductId:A.externalProductId},i=await t.mutate({mutation:bs,variables:{...e,bulk:A.bulk,workflowId:A.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!i.data||!i.data.transactionCreate)throw new oa("Failed to create transaction!");const n=i.data.transactionCreate;if(!n.product)throw new oa("Failed to create transaction, product not available.");return n},i=Lc(A.workflowId),[n,a]=await Promise.all([e(),i]);return{transaction:n,workflow:a}}throw new oa("No workflow ID provided.")})();this.currencyCode=a.product.partner?.currencyCode;const o={product:a.product,transaction:a,layouts:[],stateMutationFunc:s?async()=>{throw new ra("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:s,workflow:r};if("transaction"===A.type&&a.workflowState){const t=JSON.parse(a.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await qA(t),await n(t),o.reloadedState=t}else if(!s&&A.workflowState){const t=JSON.parse(A.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await qA(t),await n(t),o.reloadedState=t}else o.layouts=zc(o.transaction,o.workflow);if(o.renderableContextService=new Qs(o.layouts),A.previewService?(o.previewService=A.previewService,o.product?.modelUrl&&(o.modelContainer=o.previewService.loadModel({model:o.product.modelUrl,contextService:o.renderableContextService}))):(o.previewService=i&&i(r),o.product?.modelUrl&&(o.previewService?.initialize({model:o.product.modelUrl,contextService:o.renderableContextService}),o.modelContainer=o.previewService?.getAllModels()[0])),"transaction"!==A.type){const t=da.getMap("transactionOwnerIds")||new Map;t.set(a.id,a.transactionOwnerId),Ea(a.transactionOwnerId||""),da.setMap("transactionOwnerIds",t)}else{const t=(da.getMap("transactionOwnerIds")||new Map).get(a.id);t&&Ea(t),o.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=o;const c=new Wo(this,o);return await c.getWorkflowManager().getInitializationPromise(),"transaction"!==A.type&&this.customer&&await c.attachCustomerDetails({email:this.customer.emailAddress}),c}async initFromIntegrationProduct(t){if(""===t)throw new oa("No integration product ID provided.");const e=Da.getShadowGraphqlClient(),i=await e.mutate({mutation:bs,variables:{integrationProductId:t,bulk:this.options.bulk||!1,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!i.data||!i.data.transactionCreate)throw new oa("Failed to create transaction!");const A=i.data.transactionCreate;if(!A.product)throw new oa("Failed to create transaction, product not available.");this.currencyCode=A.product.partner?.currencyCode;const n=da.getMap("transactionOwnerIds")||new Map;n.set(A.id,A.transactionOwnerId),Ea(A.transactionOwnerId||""),da.setMap("transactionOwnerIds",n),this.experienceOptions={product:A.product,transaction:A,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new oa("No transaction ID provided.");const i=Da.getShadowGraphqlClient();if(e)return await(async()=>{const A=(await i.query({query:Ps,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!A)throw new oa("Failed to read transaction.");if(!A.product)throw new oa("Failed to load transaction, product not available.");this.currencyCode=A.product.partner?.currencyCode,this.experienceOptions={product:A.product,transaction:A,layouts:[],stateMutationFunc:async()=>{throw new ra("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const A=da.getMap("transactionOwnerIds")||new Map,n=A.get(t);if(n){Ea(n);const A=(await i.query({query:Ps,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!A)throw new oa("Failed to read transaction.");if(!A.product)throw new oa("Failed to load transaction, product not available.");return this.currencyCode=A.product.partner?.currencyCode,this.experienceOptions={product:A.product,transaction:A,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const n=(await i.mutate({mutation:Ys,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!n)throw new oa("Failed to read transaction.");if(!n.product)throw new oa("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,n.transactionOwnerId&&(A.set(n.id,n.transactionOwnerId),Ea(n.transactionOwnerId),da.setMap("transactionOwnerIds",A)),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new oa("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,i){if(!this.initialized||!this.experienceOptions)throw new oa("Cannot launch experience: Not initialized.");const A=async t=>{for(const e in t.layouts){const i=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<i.length;++t){const e=i[t];e.src&&e.svg&&(e.cachedObjectURL=await Wn(e.svg))}const A=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<A.length;++t){const e=A[t];e.fontData?.assetUrl&&sA(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await Lc(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=t,this.experienceOptions.transaction.workflowState){const t=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await qA(t),await A(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=i&&i(t),this.experienceOptions.renderableContextService=new Qs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const e=new Wo(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const n=Da.getShadowGraphqlClient().mutate({mutation:Rs,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),a=Lc(t);if(await Promise.all([n,a]),this.experienceOptions.workflow=await a,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await qA(t),await A(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=zc(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=i&&i(await a),this.experienceOptions.renderableContextService=new Qs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const r=new Wo(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}throw new oa("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new oa("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new oa("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function Vc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Kc{constructor(){Vc(this,"getProduct",void 0),Vc(this,"getCommandContext",void 0),Vc(this,"getAllLayoutData",void 0),Vc(this,"getMetadata",void 0),Vc(this,"getWorkflowMetadata",void 0),Vc(this,"getStepStorage",void 0),Vc(this,"setModelContainer",void 0),Vc(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(t){}addVariationRecord(t){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(t){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addCurrentVariationCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(t){}setCurrentVariationRecord(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,i){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function Wc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let Xc;var qc;(qc=Xc||(Xc={})).SelectFrame="SelectFrame",qc.SelectImage="SelectImage",qc.Position="Position";class Zc extends Io{constructor(t,e){super(t,e),Wc(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return Ao.selectVariant(this.step,t.getResource(),e,this.manager,(t=>this.setUpdateState(t)))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged((e=>{e&&t(e)}))}selectImage(t){return Ao.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,i,A){return A&&A.length>1&&void 0===t?Xc.SelectFrame:e||i||this.getImageData()?Xc.Position:Xc.SelectImage}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}hasVaryingUpload(){return this.step.data.varyUpload}hasVaryingSelection(){return this.step.data.varySelection}}const $c=t=>{const e=(0,A.useRef)(null),n=(0,A.useRef)(void 0),[a,r]=(0,A.useState)(void 0),{addEvent:s,removeEvent:o,updateEvent:c,eventCache:l}=Ta(),[g,h]=(0,A.useState)(!1),[d,u]=(0,A.useState)(!1),{state:w,uiDispatcher:B}=qa(),p=(0,A.useCallback)((t=>{const e=t;B(new Xa({zoom:Math.max(.1,Math.min(e,w.maxZoom))}))}),[B,w.maxZoom]),E=(0,A.useCallback)((t=>{o(t),1===l.length&&(n.current=void 0),2===l.length&&r(void 0);"touch"===t.pointerType&&l.length>1&&l.length-1==1&&(u(!1),h(!1))}),[o,l.length]),m=(0,A.useCallback)((t=>{s(t);"touch"===t.pointerType&&1===l.length&&(B(new Xa({selectedElement:void 0})),u(!0),h(!0))}),[s,l.length,B]),f=(0,A.useCallback)((t=>{c(t);const e=1===l.length&&"touch"!==l[0].pointerType,i=2===l.length&&"touch"===l[0].pointerType;if(g&&i){const[t,e]=l,i=Math.abs(t.clientX-e.clientX),A=a;A&&p(w.zoom-.0055*(A-i)),r(i)}if(d&&(e||i)&&t.isPrimary){const e=(n?.current?.x||t.screenX)-t.screenX,i=(n?.current?.y||t.screenY)-t.screenY;B(new Xa({selectedElement:void 0,xTranslation:w.xTranslation-e/w.zoom,yTranslation:w.yTranslation-i/w.zoom}))}t.isPrimary&&(n.current={x:t.screenX,y:t.screenY})}),[c,l,g,d,a,p,w.zoom,w.xTranslation,w.yTranslation,B]),C=(0,A.useCallback)((t=>{g&&p(w.zoom-.035*Math.sign(t.deltaY))}),[p,w.zoom,g]);(0,A.useEffect)((()=>{if(!e.current||0===l.length)return;const t=l[0].pointerId,i=e.current.hasPointerCapture(t);d&&!i&&e.current.setPointerCapture(t),!d&&i&&e.current.releasePointerCapture(t)}),[e,d,l]),Gr([" "],(()=>{u(!0),B(new Xa({selectedElement:void 0}))}),(()=>u(!1))),Gr(["Control"],(()=>h(!0)),(()=>h(!1)));const Q=(0,A.useMemo)((()=>({cursor:d&&0===l.length?"grab":d&&1===l.length?"grabbing":g?"zoom-in":void 0,width:"100%",height:"100%",overflow:"clip"})),[d,g,l]);return(0,i.jsx)("div",{ref:e,className:"transform-wrapper",onWheel:C,onPointerDown:m,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:f,style:Q,children:t.children})};
1384
+ `,jc=async t=>{const e=bc.get(t);return e||bc.set(t,(async t=>{const e=(await Da.getShadowGraphqlClient().query({query:Hc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return e.steps.forEach((t=>{delete t.data.__typename})),e})(t))},Vc=(t,e)=>{const i=t.workflowState,A=i?JSON.parse(i):void 0;return A?Object.values(A.layouts).map((t=>t.layout)):e.panels.sort(((t,e)=>t.index-e.index)).map((t=>({id:Te(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})))};class Kc{constructor(t){var e;Yc(this,"options",void 0),Yc(this,"initialized",void 0),Yc(this,"currencyCode",void 0),Yc(this,"customer",void 0),Yc(this,"experienceOptions",void 0),Yc(this,"updateTransactionState",(async t=>{try{return Da.getShadowGraphqlClient().mutate({...t,mutation:Ns})}catch(t){throw console.error(t),new oa("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,ya=e)}getAssetManager(){return Na}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!this.options.applicationKey)throw new Error("Application key required to use Flow Service.");return new Dc}async authenticateBundleFromLocalStorage(t){const e=da.getMap("bundleOwnerIds");if(e?.has(t)){const i=e.get(t);return fa(i),Promise.resolve({success:!0,stakeholderType:ar.Owner})}const i=da.getMap("bundleCustomerIds");if(i?.has(t)){const e=i.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const e=Da.getShadowGraphqlClient(),i=await e.query({query:Uc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!i.data.transactions||0===i.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const A=i.data.transactions[0],n=A.product?.partner?.id;if(!n)throw new Error(`Unable to read transaction: ${t}`);if(A.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const a=da.getMap("transactionOwnerIds");if(a?.has(t)){const e=a.get(t);return Ea(e),Promise.resolve({success:!0,stakeholderType:ar.Owner})}const r=da.getMap("transactionCustomerIds");if(r?.has(t)){const e=r.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.transactions?.some((e=>e.id===t))))||this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}const s=(await e.query({query:Gc,errorPolicy:"all",variables:{id:A.workflowId}})).data.workflow;if(!s)throw new Error(`Unable to read workflow: ${A.workflowId}`);return Promise.resolve({success:!1,theme:s.overrideTheme,customLogoLink:A.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=da.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),da.setMap("transactionCustomerIds",e))}getStakeholderTypeForTransaction(t){const e=this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return e.type}async getOrCreateCustomer(t){this.customer=void 0;const e=Da.getShadowGraphqlClient(),i=(await e.query({query:Tc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!i.id){const i=(await e.mutate({mutation:Oc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!i)throw new Error("Unable to create customer.");return this.customer=i,{customer:i,isAuthenticated:!1}}const A=await this.authenticateCustomerId(i.id);return{customer:this.customer||i,isAuthenticated:A}}async authenticateCustomerId(t){const e=Da.getShadowGraphqlClient(),i=da.getMap("customerTokens");if(!i?.has(t))return!1;const A=i.get(t);if(!A)return!1;const n=(await e.mutate({mutation:Jc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:A}})).data?.customerAuthenticate;return!!n&&(Qa(A),this.customer=n,!0)}async generateVerificationCode(t){await Da.getShadowGraphqlClient().mutate({mutation:Lc,variables:{emailAddress:t}})}async verifyCode(t,e){const i=(await Da.getShadowGraphqlClient().mutate({mutation:zc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data?.customerVerifyCode;if(i?.loginToken){if(!i.partner?.id)throw new Error(`Unable to find customer: ${t}`);const e=da.getMap("customerTokens")||new Map;return e.set(i.id,i.loginToken),da.setMap("customerTokens",e),Qa(i.loginToken),this.customer={...i,loginToken:void 0},!0}return!1}async getNewBundle(t){const e=(await Da.getShadowGraphqlClient().mutate({mutation:tc,variables:{collectionId:t},fetchPolicy:"no-cache"})).data?.bundleCreate;if(!e)throw new Error("Unable to create bundle");fa(e.bundleOwnerId);const i=da.getMap("bundleOwnerIds")||new Map;return i.set(e.id,e.bundleOwnerId),da.setMap("bundleOwnerIds",i),new Cc(this,e)}async getExistingBundle(t,e){const i=da.getMap("bundleOwnerIds")?.get(t);i&&fa(i);const A=await Da.getShadowGraphqlClient().query({query:Zo,variables:{id:t},fetchPolicy:"no-cache"});if(!A.data?.bundles||0===A.data?.bundles.length||!A.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const n=A.data?.bundles[0],a=new Cc(this,n,e);return await a.getInitializationPromise(),a}async getBundleStakeholders(){if(!this.customer)throw new Error("Customer not authenticated.");const t=await Da.getShadowGraphqlClient().query({query:_o,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!t.data?.customers||0===t.data.customers.length)throw new Error("Unable to find customer.");return t.data.customers[0].bundleStakeholders||[]}async getWorkflowExperience(t,e,i,A){if(!A)return await this.getWorkflowExperienceDeprecated(t,e,i);const n=async t=>{for(const e in t.layouts){const i=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<i.length;++t){const e=i[t];e.src&&e.svg&&(e.cachedObjectURL=await Wn(e.svg))}const A=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<A.length;++t){const e=A[t];e.fontData?.assetUrl&&sA(e.fontData.assetUrl)}}},{transaction:a,workflow:r,readOnly:s}=await(async()=>{const t=Da.getShadowGraphqlClient();if("transaction"===A.type){const{transactionId:e,readOnly:i}=A,n=await t.query({query:Ps,variables:{id:e},errorPolicy:"all",fetchPolicy:"no-cache"});if(!n.data?.transactions||0===n.data.transactions.length)throw new oa("Existing transaction not found.");const a=n.data?.transactions[0];if(!a.workflowId)throw new oa("Existing transaction has no workflow ID.");const r=await jc(a.workflowId);if(!a.product)throw new oa("Failed to load transaction, product not available.");return{transaction:a,workflow:r,readOnly:i}}if("integration"===A.type||"external"===A.type){const e=async()=>{const e="integration"===A.type?{integrationProductId:A.integrationProductId}:{externalIntegrationId:A.externalIntegrationId,externalProductId:A.externalProductId},i=await t.mutate({mutation:bs,variables:{...e,bulk:A.bulk,workflowId:A.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!i.data||!i.data.transactionCreate)throw new oa("Failed to create transaction!");const n=i.data.transactionCreate;if(!n.product)throw new oa("Failed to create transaction, product not available.");return n},i=jc(A.workflowId),[n,a]=await Promise.all([e(),i]);return{transaction:n,workflow:a}}throw new oa("No workflow ID provided.")})();this.currencyCode=a.product.partner?.currencyCode;const o={product:a.product,transaction:a,layouts:[],stateMutationFunc:s?async()=>{throw new ra("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:s,workflow:r};if("transaction"===A.type&&a.workflowState){const t=JSON.parse(a.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await qA(t),await n(t),o.reloadedState=t}else if(!s&&A.workflowState){const t=JSON.parse(A.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await qA(t),await n(t),o.reloadedState=t}else o.layouts=Vc(o.transaction,o.workflow);if(o.renderableContextService=new Qs(o.layouts),A.previewService?(o.previewService=A.previewService,o.product?.modelUrl&&(o.modelContainer=o.previewService.loadModel({model:o.product.modelUrl,contextService:o.renderableContextService}))):(o.previewService=i&&i(r),o.product?.modelUrl&&(o.previewService?.initialize({model:o.product.modelUrl,contextService:o.renderableContextService}),o.modelContainer=o.previewService?.getAllModels()[0])),"transaction"!==A.type){const t=da.getMap("transactionOwnerIds")||new Map;t.set(a.id,a.transactionOwnerId),Ea(a.transactionOwnerId||""),da.setMap("transactionOwnerIds",t)}else{const t=(da.getMap("transactionOwnerIds")||new Map).get(a.id);t&&Ea(t),o.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=o;const c=new Wo(this,o);return await c.getWorkflowManager().getInitializationPromise(),"transaction"!==A.type&&this.customer&&await c.attachCustomerDetails({email:this.customer.emailAddress}),c}async initFromIntegrationProduct(t){if(""===t)throw new oa("No integration product ID provided.");const e=Da.getShadowGraphqlClient(),i=await e.mutate({mutation:bs,variables:{integrationProductId:t,bulk:this.options.bulk||!1,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!i.data||!i.data.transactionCreate)throw new oa("Failed to create transaction!");const A=i.data.transactionCreate;if(!A.product)throw new oa("Failed to create transaction, product not available.");this.currencyCode=A.product.partner?.currencyCode;const n=da.getMap("transactionOwnerIds")||new Map;n.set(A.id,A.transactionOwnerId),Ea(A.transactionOwnerId||""),da.setMap("transactionOwnerIds",n),this.experienceOptions={product:A.product,transaction:A,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new oa("No transaction ID provided.");const i=Da.getShadowGraphqlClient();if(e)return await(async()=>{const A=(await i.query({query:Ps,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!A)throw new oa("Failed to read transaction.");if(!A.product)throw new oa("Failed to load transaction, product not available.");this.currencyCode=A.product.partner?.currencyCode,this.experienceOptions={product:A.product,transaction:A,layouts:[],stateMutationFunc:async()=>{throw new ra("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const A=da.getMap("transactionOwnerIds")||new Map,n=A.get(t);if(n){Ea(n);const A=(await i.query({query:Ps,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!A)throw new oa("Failed to read transaction.");if(!A.product)throw new oa("Failed to load transaction, product not available.");return this.currencyCode=A.product.partner?.currencyCode,this.experienceOptions={product:A.product,transaction:A,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const n=(await i.mutate({mutation:Ys,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!n)throw new oa("Failed to read transaction.");if(!n.product)throw new oa("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,n.transactionOwnerId&&(A.set(n.id,n.transactionOwnerId),Ea(n.transactionOwnerId),da.setMap("transactionOwnerIds",A)),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new oa("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,i){if(!this.initialized||!this.experienceOptions)throw new oa("Cannot launch experience: Not initialized.");const A=async t=>{for(const e in t.layouts){const i=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<i.length;++t){const e=i[t];e.src&&e.svg&&(e.cachedObjectURL=await Wn(e.svg))}const A=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<A.length;++t){const e=A[t];e.fontData?.assetUrl&&sA(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await jc(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=t,this.experienceOptions.transaction.workflowState){const t=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await qA(t),await A(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=i&&i(t),this.experienceOptions.renderableContextService=new Qs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const e=new Wo(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const n=Da.getShadowGraphqlClient().mutate({mutation:Rs,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),a=jc(t);if(await Promise.all([n,a]),this.experienceOptions.workflow=await a,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await qA(t),await A(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=Vc(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=i&&i(await a),this.experienceOptions.renderableContextService=new Qs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const r=new Wo(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}throw new oa("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new oa("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new oa("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function Wc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Xc{constructor(){Wc(this,"getProduct",void 0),Wc(this,"getCommandContext",void 0),Wc(this,"getAllLayoutData",void 0),Wc(this,"getMetadata",void 0),Wc(this,"getWorkflowMetadata",void 0),Wc(this,"getStepStorage",void 0),Wc(this,"setModelContainer",void 0),Wc(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(t){}addVariationRecord(t){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(t){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addCurrentVariationCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(t){}setCurrentVariationRecord(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,i){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function qc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let Zc;var $c;($c=Zc||(Zc={})).SelectFrame="SelectFrame",$c.SelectImage="SelectImage",$c.Position="Position";class _c extends Io{constructor(t,e){super(t,e),qc(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return Ao.selectVariant(this.step,t.getResource(),e,this.manager,(t=>this.setUpdateState(t)))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged((e=>{e&&t(e)}))}selectImage(t){return Ao.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,i,A){return A&&A.length>1&&void 0===t?Zc.SelectFrame:e||i||this.getImageData()?Zc.Position:Zc.SelectImage}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}hasVaryingUpload(){return this.step.data.varyUpload}hasVaryingSelection(){return this.step.data.varySelection}}const tl=t=>{const e=(0,A.useRef)(null),n=(0,A.useRef)(void 0),[a,r]=(0,A.useState)(void 0),{addEvent:s,removeEvent:o,updateEvent:c,eventCache:l}=Ta(),[g,h]=(0,A.useState)(!1),[d,u]=(0,A.useState)(!1),{state:w,uiDispatcher:B}=qa(),p=(0,A.useCallback)((t=>{const e=t;B(new Xa({zoom:Math.max(.1,Math.min(e,w.maxZoom))}))}),[B,w.maxZoom]),E=(0,A.useCallback)((t=>{o(t),1===l.length&&(n.current=void 0),2===l.length&&r(void 0);"touch"===t.pointerType&&l.length>1&&l.length-1==1&&(u(!1),h(!1))}),[o,l.length]),m=(0,A.useCallback)((t=>{s(t);"touch"===t.pointerType&&1===l.length&&(B(new Xa({selectedElement:void 0})),u(!0),h(!0))}),[s,l.length,B]),f=(0,A.useCallback)((t=>{c(t);const e=1===l.length&&"touch"!==l[0].pointerType,i=2===l.length&&"touch"===l[0].pointerType;if(g&&i){const[t,e]=l,i=Math.abs(t.clientX-e.clientX),A=a;A&&p(w.zoom-.0055*(A-i)),r(i)}if(d&&(e||i)&&t.isPrimary){const e=(n?.current?.x||t.screenX)-t.screenX,i=(n?.current?.y||t.screenY)-t.screenY;B(new Xa({selectedElement:void 0,xTranslation:w.xTranslation-e/w.zoom,yTranslation:w.yTranslation-i/w.zoom}))}t.isPrimary&&(n.current={x:t.screenX,y:t.screenY})}),[c,l,g,d,a,p,w.zoom,w.xTranslation,w.yTranslation,B]),C=(0,A.useCallback)((t=>{g&&p(w.zoom-.035*Math.sign(t.deltaY))}),[p,w.zoom,g]);(0,A.useEffect)((()=>{if(!e.current||0===l.length)return;const t=l[0].pointerId,i=e.current.hasPointerCapture(t);d&&!i&&e.current.setPointerCapture(t),!d&&i&&e.current.releasePointerCapture(t)}),[e,d,l]),Gr([" "],(()=>{u(!0),B(new Xa({selectedElement:void 0}))}),(()=>u(!1))),Gr(["Control"],(()=>h(!0)),(()=>h(!1)));const Q=(0,A.useMemo)((()=>({cursor:d&&0===l.length?"grab":d&&1===l.length?"grabbing":g?"zoom-in":void 0,width:"100%",height:"100%",overflow:"clip"})),[d,g,l]);return(0,i.jsx)("div",{ref:e,className:"transform-wrapper",onWheel:C,onPointerDown:m,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:f,style:Q,children:t.children})};
1385
1385
  //# sourceMappingURL=main.js.map