@spiffcommerce/core 10.1.5 → 10.1.6
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 +1 -1
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/jsx-runtime"),i=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"),B=require("rgbcolor"),w=require("svg-pathdata"),E=require("stackblur-canvas"),p=require("@apollo/client/link/context"),m=require("@apollo/client/link/error"),C=require("cross-fetch"),f=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");function M(t,e,A,i){Object.defineProperty(t,e,{get:A,set:i,enumerable:!0,configurable:!0})}var v="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",(()=>Vo)),M(module.exports,"CommandContext",(()=>ki)),M(module.exports,"spiffCoreConfiguration",(()=>la)),M(module.exports,"PromiseQueue",(()=>Yr)),M(module.exports,"QueueablePromise",(()=>Sr)),M(module.exports,"MockWorkflowManager",(()=>Wo)),M(module.exports,"InformationMessageType",(()=>so)),M(module.exports,"StepHandle",(()=>Bo)),M(module.exports,"TextStepHandle",(()=>xo)),M(module.exports,"FrameStepHandle",(()=>$o)),M(module.exports,"BulkStepHandle",(()=>mo)),M(module.exports,"ShapeStepHandle",(()=>Io)),M(module.exports,"IllustrationStepHandle",(()=>Co)),M(module.exports,"MaterialStepHandle",(()=>fo)),M(module.exports,"ModelStepHandle",(()=>Qo)),M(module.exports,"PictureStepHandle",(()=>yo)),M(module.exports,"QuestionStepHandle",(()=>Do)),M(module.exports,"BulkPriceCalculationStrategy",(()=>La)),M(module.exports,"Variant",(()=>ho)),M(module.exports,"OptionNotFoundError",(()=>Xn)),M(module.exports,"LayoutNotFoundError",(()=>qn)),M(module.exports,"AssetNotFoundError",(()=>Zn)),M(module.exports,"ResourceNotFoundError",(()=>$n)),M(module.exports,"MisconfigurationError",(()=>_n)),M(module.exports,"ParseError",(()=>Aa)),M(module.exports,"UnhandledBehaviorError",(()=>ea)),M(module.exports,"assetService",(()=>Da)),M(module.exports,"designService",(()=>Ho)),M(module.exports,"createDesign",(()=>Po)),M(module.exports,"optionService",(()=>va)),M(module.exports,"persistenceService",(()=>oa)),M(module.exports,"graphQlManager",(()=>ua)),M(module.exports,"toast",(()=>to)),M(module.exports,"FrameService",(()=>ks)),M(module.exports,"getBoundedOffsets",(()=>Rs)),M(module.exports,"frameStepService",(()=>js)),M(module.exports,"modelStepService",(()=>Ws)),M(module.exports,"materialStepService",(()=>Ks)),M(module.exports,"shapeStepService",(()=>$s)),M(module.exports,"questionStepService",(()=>Zs)),M(module.exports,"digitalContentStepService",(()=>Ls)),M(module.exports,"moduleStepService",(()=>Xs)),M(module.exports,"pictureStepService",(()=>qs)),M(module.exports,"textStepService",(()=>ao)),M(module.exports,"illustrationStepService",(()=>Vs)),M(module.exports,"ProductCameraRig",(()=>Oa)),M(module.exports,"FrameStep",(()=>qo)),M(module.exports,"ConversionLocation",(()=>ja)),M(module.exports,"ConversionDataType",(()=>Ka)),M(module.exports,"getWorkflow",(()=>zo)),M(module.exports,"AssetType",(()=>eA)),M(module.exports,"BringForwardCommand",(()=>wn)),M(module.exports,"BringToFrontCommand",(()=>un)),M(module.exports,"BringToBackCommand",(()=>Bn)),M(module.exports,"CanvasCommand",(()=>Vi)),M(module.exports,"CreateElementCommand",(()=>tn)),M(module.exports,"CreateLayoutCommand",(()=>$i)),M(module.exports,"DeleteElementCommand",(()=>en)),M(module.exports,"FontAlignmentCommand",(()=>cn)),M(module.exports,"FontColorCommand",(()=>nn)),M(module.exports,"FontSizeCommand",(()=>rn)),M(module.exports,"FontSourceCommand",(()=>on)),M(module.exports,"GroupCommand",(()=>Zi)),M(module.exports,"LayoutElementFactory",(()=>jn)),M(module.exports,"LayoutElementType",(()=>Le)),M(module.exports,"MoveCommand",(()=>Wi)),M(module.exports,"ResizeCommand",(()=>qi)),M(module.exports,"RotateCommand",(()=>Xi)),M(module.exports,"SendBackwardsCommand",(()=>En)),M(module.exports,"StepAspectType",(()=>aA)),M(module.exports,"StepType",(()=>iA)),M(module.exports,"TextChangeCommand",(()=>gn)),M(module.exports,"UnitOfMeasurement",(()=>Xe)),M(module.exports,"dataUrlFromExternalUrl",(()=>KA)),M(module.exports,"findElement",(()=>Ji)),M(module.exports,"frameDataCache",(()=>Mn)),M(module.exports,"generate",(()=>Ge)),M(module.exports,"getAxisAlignedBoundingBox",(()=>cA)),M(module.exports,"generateSVGWithUnknownColors",(()=>Ri)),M(module.exports,"getAttributesFromArrayBuffer",(()=>Dn)),M(module.exports,"rehydrateSerializedLayout",(()=>ji)),M(module.exports,"getFrameData",(()=>Yn)),M(module.exports,"getSvgElement",(()=>Gi)),M(module.exports,"loadFontFromDataUrl",(()=>ii)),M(module.exports,"loadFontFromExternalUrl",(()=>Ai)),M(module.exports,"determineCorrectFontSizeAndLines",(()=>Un)),M(module.exports,"patternImageDataCache",(()=>xn)),M(module.exports,"generateCommands",(()=>os)),M(module.exports,"registerJSDOM",(()=>RA)),M(module.exports,"minZoom",(()=>Dr)),M(module.exports,"AdvancedEditor",(()=>ps)),M(module.exports,"TransformWrapper",(()=>_o)),M(module.exports,"EditorCore",(()=>Es)),M(module.exports,"useLayouts",(()=>Ya)),M(module.exports,"useEditorState",(()=>Ta)),M(module.exports,"useEditorInteraction",(()=>xr)),M(module.exports,"useShortcutCombination",(()=>Mr)),M(module.exports,"commandReducer",(()=>Ha)),M(module.exports,"getDefaultState",(()=>Ra)),M(module.exports,"CommandContextContext",(()=>Fa)),M(module.exports,"AdvancedEditorStateProvider",(()=>Ua)),M(module.exports,"AdvancedEditorContext",(()=>ka)),M(module.exports,"UICommand",(()=>Ga)),M(module.exports,"EditorSubMenu",(()=>Pa)),M(module.exports,"ElementEventType",(()=>_a)),M(module.exports,"KeyEvent",(()=>er)),M(module.exports,"gatherVaryingStepAspects",(()=>Ms));function S(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 b=/^[A-Z-]+$/;function P(t){const e=/url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(t);return e&&(e[2]||e[3]||e[4])||""}const N=/(\[[^\]]+\])/g,R=/(#[^\s+>~.[:]+)/g,H=/(\.[^\s+>~.[:]+)/g,k=/(::[^\s+>~.[:]+|:first-line|:first-letter|:before|:after)/gi,U=/(:[\w-]+\([^)]*\))/gi,G=/(:[^\s+>~.[:]+)/g,T=/([^\s+>~.[:]+)/g;function O(t,e){const A=e.exec(t);return A?[t.replace(e," "),A.length]:[t,0]}const J=1e-8;function L(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))}function z(t,e){return(t[0]*e[0]+t[1]*e[1])/(L(t)*L(e))}function j(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(z(t,e))}function V(t){return t*t*t}function K(t){return 3*t*t*(1-t)}function W(t){return 3*t*(1-t)*(1-t)}function X(t){return(1-t)*(1-t)*(1-t)}function q(t){return t*t}function Z(t){return 2*t*(1-t)}function $(t){return(1-t)*(1-t)}function _(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class tt{static empty(t){return new tt(t,"EMPTY","")}split(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:" ";const{document:e,name:A}=this;return S(this.getString()).trim().split(t).map((t=>new tt(e,A,t)))}hasValue(t){const e=this.value;return null!==e&&""!==e&&(t||0!==e)&&void 0!==e}isString(t){const{value:e}=this,A="string"==typeof e;return A&&t?t.test(e):A}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 A=parseFloat(e);return this.isString(/%$/)&&(A/=100),A}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,A)=>e--&&A?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[A,i]="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(/%$/)&&i:return this.getNumber()*this.getEm();case this.isString(/%$/):return this.getNumber()*n.computeSize(A);default:{const t=this.getNumber();return e&&t<1?t*n.computeSize(A):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),A=(null==e?void 0:e[1])||t;return this.document.definitions[A]}getFillStyleDefinition(t,e){let A=this.getDefinition();if(!A)return null;if("function"==typeof A.createGradient&&"getBoundingBox"in t)return A.createGradient(this.document.ctx,t,e);if("function"==typeof A.createPattern){if(A.getHrefAttribute().hasValue()){const t=A.getAttribute("patternTransform");A=A.getHrefAttribute().getDefinition(),A&&t.hasValue()&&A.getAttribute("patternTransform",!0).setValue(t.value)}if(A)return A.createPattern(this.document.ctx,t,e)}return null}getTextBaseline(){if(!this.hasValue())return null;const t=this.getString();return tt.textBaselineMapping[t]||null}addOpacity(t){let e=this.getColor();const A=e.length;let i=0;for(let t=0;t<A&&(","===e[t]&&i++,3!==i);t++);if(t.hasValue()&&this.isString()&&3!==i){const A=new(F(B))(e);A.ok&&(A.alpha=t.getNumber(),e=A.toRGBA())}return new tt(this.document,this.name,e)}constructor(t,e,A){_(this,"document",void 0),_(this,"name",void 0),_(this,"value",void 0),_(this,"isNormalizedColor",void 0),this.document=t,this.name=e,this.value=A,this.isNormalizedColor=!1}}function et(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}_(tt,"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||it()}getCurrent(){const{viewPorts:t}=this,e=t[t.length-1];return e||it()}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(){et(this,"viewPorts",[])}}function it(){return{width:At.DEFAULT_VIEWPORT_WIDTH,height:At.DEFAULT_VIEWPORT_HEIGHT}}function nt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}et(At,"DEFAULT_VIEWPORT_WIDTH",800),et(At,"DEFAULT_VIEWPORT_HEIGHT",600);class at{static parse(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const[A=e,i=e]=Y(t);return new at(A,i)}static parseScale(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const[A=e,i=A]=Y(t);return new at(A,i)}static parsePath(t){const e=Y(t),A=e.length,i=[];for(let t=0;t<A;t+=2)i.push(new at(e[t],e[t+1]));return i}angleTo(t){return Math.atan2(t.y-this.y,t.x-this.x)}applyTransform(t){const{x:e,y:A}=this,i=e*t[0]+A*t[2]+t[4],n=e*t[1]+A*t[3]+t[5];this.x=i,this.y=n}constructor(t,e){nt(this,"x",void 0),nt(this,"y",void 0),this.x=t,this.y=e}}function rt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class st{isWorking(){return this.working}start(){if(this.working)return;const{screen:t,onClick:e,onMouseMove:A}=this,i=t.ctx.canvas;i.onclick=e,i.onmousemove=A,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:A}=this,{style:i}=t.ctx.canvas;let n;i&&(i.cursor=""),e.forEach(((t,e)=>{let{run:i}=t;for(n=A[e];n;)i(n),n=n.parent})),this.events=[],this.eventElements=[]}checkPath(t,e){if(!this.working||!e)return;const{events:A,eventElements:i}=this;A.forEach(((A,n)=>{let{x:a,y:r}=A;!i[n]&&e.isPointInPath&&e.isPointInPath(a,r)&&(i[n]=t)}))}checkBoundingBox(t,e){if(!this.working||!e)return;const{events:A,eventElements:i}=this;A.forEach(((A,n)=>{let{x:a,y:r}=A;!i[n]&&e.isPointInBox(a,r)&&(i[n]=t)}))}mapXY(t,e){const{window:A,ctx:i}=this.screen,n=new at(t,e);let a=i.canvas;for(;a;)n.x-=a.offsetLeft,n.y-=a.offsetTop,a=a.offsetParent;return(null==A?void 0:A.scrollX)&&(n.x+=A.scrollX),(null==A?void 0:A.scrollY)&&(n.y+=A.scrollY),n}onClick(t){const{x:e,y:A}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onclick",x:e,y:A,run(t){t.onClick&&t.onClick()}})}onMouseMove(t){const{x:e,y:A}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onmousemove",x:e,y:A,run(t){t.onMouseMove&&t.onMouseMove()}})}constructor(t){rt(this,"screen",void 0),rt(this,"working",void 0),rt(this,"events",void 0),rt(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 ot(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const ct="undefined"!=typeof window?window:null,lt="undefined"!=typeof fetch?fetch.bind(void 0):void 0;class gt{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:A,aspectRatio:i,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 B=S(i).replace(/^defer\s/,""),[w,E]=B.split(" "),p=w||"xMidYMid",m=E||"meet",C=n/a,f=r/s,Q=Math.min(C,f),y=Math.max(C,f);let D=a,I=s;"meet"===m&&(D*=Q,I*=Q),"slice"===m&&(D*=y,I*=y);const x=new tt(e,"refX",l),M=new tt(e,"refY",g),v=x.hasValue()&&M.hasValue();if(v&&A.translate(-Q*x.getPixels("x"),-Q*M.getPixels("y")),h){const t=Q*d,e=Q*u;A.beginPath(),A.moveTo(t,e),A.lineTo(n,e),A.lineTo(n,r),A.lineTo(t,r),A.closePath(),A.clip()}if(!v){const t="meet"===m&&Q===f,e="slice"===m&&y===f,i="meet"===m&&Q===C,a="slice"===m&&y===C;p.startsWith("xMid")&&(t||e)&&A.translate(n/2-D/2,0),p.endsWith("YMid")&&(i||a)&&A.translate(0,r/2-I/2),p.startsWith("xMax")&&(t||e)&&A.translate(n-D,0),p.endsWith("YMax")&&(i||a)&&A.translate(0,r-I)}switch(!0){case"none"===p:A.scale(C,f);break;case"meet"===m:A.scale(Q,Q);break;case"slice"===m:A.scale(y,y)}A.translate(-o,-c)}start(t){let{enableRedraw:e=!1,ignoreMouse:A=!1,ignoreAnimation:i=!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/gt.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(),B=d,w=0;const E=()=>{d=Date.now(),w=d-B,w>=h&&(B=d-w%h,this.shouldUpdate(i,r)&&(this.render(t,n,a,s,o,c,l),g.runEvents())),this.intervalId=F(u)(E)};A||g.start(),this.intervalId=F(u)(E)}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,A)=>A.update(t)||e),!1))return!0}return!("function"!=typeof e||!e())||(!(this.isReadyLock||!this.isReady())||!!this.mouse.hasEvents())}render(t,e,A,i,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 i&&"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 i||"number"==typeof n){const e=Y(t.getAttribute("viewBox").getString());let A=0,a=0;if("number"==typeof i){const n=t.getStyle("width");n.hasValue()?A=n.getPixels("x")/i:e[2]&&!isNaN(e[2])&&(A=e[2]/i)}if("number"==typeof n){const A=t.getStyle("height");A.hasValue()?a=A.getPixels("y")/n:e[3]&&!isNaN(e[3])&&(a=e[3]/n)}A||(A=a),a||(a=A),t.getAttribute("width",!0).setValue(i),t.getAttribute("height",!0).setValue(n);const r=t.getStyle("transform",!0,!0);r.setValue(`${r.getString()} scale(${1/A}, ${1/a})`)}A||o.clearRect(0,0,d,u),t.render(o),c&&(this.isFirstRender=!1)}constructor(t,{fetch:e=lt,window:A=ct}={}){if(ot(this,"ctx",void 0),ot(this,"window",void 0),ot(this,"fetch",void 0),ot(this,"viewPort",void 0),ot(this,"mouse",void 0),ot(this,"animations",void 0),ot(this,"readyPromise",void 0),ot(this,"resolveReady",void 0),ot(this,"waits",void 0),ot(this,"frameDuration",void 0),ot(this,"isReadyLock",void 0),ot(this,"isFirstRender",void 0),ot(this,"intervalId",void 0),this.ctx=t,this.viewPort=new At,this.mouse=new st(this),this.animations=[],this.waits=[],this.frameDuration=0,this.isReadyLock=!1,this.isFirstRender=!0,this.intervalId=null,this.window=A,!e)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");this.fetch=e}}function ht(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}ot(gt,"defaultWindow",ct),ot(gt,"defaultFetch",lt),ot(gt,"FRAMERATE",30),ot(gt,"MAX_VIRTUAL_PIXELS",3e4);const{defaultFetch:dt}=gt,ut="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(A){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),A=await e.text();return this.parseFromString(A)}constructor({fetch:t=dt,DOMParser:e=ut}={}){if(ht(this,"fetch",void 0),ht(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 wt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function Et(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function pt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function mt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Ct{apply(t){const{originX:e,originY:A,matrix:i}=this,n=e.getPixels("x"),a=A.getPixels("y");t.translate(n,a),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),t.translate(-n,-a)}unapply(t){const{originX:e,originY:A,matrix:i}=this,n=i[0],a=i[2],r=i[4],s=i[1],o=i[3],c=i[5],l=1/(n*(1*o-0*c)-a*(1*s-0*c)+r*(0*s-0*o)),g=e.getPixels("x"),h=A.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,A){mt(this,"type","matrix"),mt(this,"matrix",void 0),mt(this,"originX",void 0),mt(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=A[0],this.originY=A[1]}}function ft(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Qt extends Ct{constructor(t,e,A){super(t,e,A),ft(this,"type","skew"),ft(this,"angle",void 0),this.angle=new tt(t,"angle",e)}}function yt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Dt{static fromElement(t,e){const A=e.getStyle("transform",!1,!0);if(A.hasValue()){const[i,n=i]=e.getStyle("transform-origin",!1,!0).split();if(i&&n){const e=[i,n];return new Dt(t,A.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,A){yt(this,"document",void 0),yt(this,"transforms",void 0),this.document=t,this.transforms=[];const i=function(t){return S(t).trim().replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)}(e);i.forEach((t=>{if("none"===t)return;const[e,i]=function(t){const[e="",A=""]=t.split("(");return[e.trim(),A.trim().replace(")","")]}(t),n=Dt.transformTypes[e];n&&this.transforms.push(new n(this.document,i,A))}))}}function It(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}yt(Dt,"transformTypes",{translate:class{apply(t){const{x:e,y:A}=this.point;t.translate(e||0,A||0)}unapply(t){const{x:e,y:A}=this.point;t.translate(-1*e||0,-1*A||0)}applyToPoint(t){const{x:e,y:A}=this.point;t.applyTransform([1,0,0,1,e||0,A||0])}constructor(t,e){wt(this,"type","translate"),wt(this,"point",void 0),this.point=at.parse(e)}},rotate:class{apply(t){const{cx:e,cy:A,originX:i,originY:n,angle:a}=this,r=e+i.getPixels("x"),s=A+n.getPixels("y");t.translate(r,s),t.rotate(a.getRadians()),t.translate(-r,-s)}unapply(t){const{cx:e,cy:A,originX:i,originY:n,angle:a}=this,r=e+i.getPixels("x"),s=A+n.getPixels("y");t.translate(r,s),t.rotate(-1*a.getRadians()),t.translate(-r,-s)}applyToPoint(t){const{cx:e,cy:A,angle:i}=this,n=i.getRadians();t.applyTransform([1,0,0,1,e||0,A||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,-A||0])}constructor(t,e,A){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 i=Y(e);this.angle=new tt(t,"angle",i[0]),this.originX=A[0],this.originY=A[1],this.cx=i[1]||0,this.cy=i[2]||0}},scale:class{apply(t){const{scale:{x:e,y:A},originX:i,originY:n}=this,a=i.getPixels("x"),r=n.getPixels("y");t.translate(a,r),t.scale(e,A||e),t.translate(-a,-r)}unapply(t){const{scale:{x:e,y:A},originX:i,originY:n}=this,a=i.getPixels("x"),r=n.getPixels("y");t.translate(a,r),t.scale(1/e,1/A||e),t.translate(-a,-r)}applyToPoint(t){const{x:e,y:A}=this.scale;t.applyTransform([e||0,0,0,A||0,0,0])}constructor(t,e,A){pt(this,"type","scale"),pt(this,"scale",void 0),pt(this,"originX",void 0),pt(this,"originY",void 0);const i=at.parseScale(e);0!==i.x&&0!==i.y||(i.x=J,i.y=J),this.scale=i,this.originX=A[0],this.originY=A[1]}},matrix:Ct,skewX:class extends Qt{constructor(t,e,A){var i,n,a;super(t,e,A),a="skewX",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.matrix=[1,0,Math.tan(this.angle.getRadians()),1,0,0]}},skewY:class extends Qt{constructor(t,e,A){var i,n,a;super(t,e,A),a="skewY",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.matrix=[1,Math.tan(this.angle.getRadians()),0,1,0,0]}}});class xt{getAttribute(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const A=this.attributes[t];if(!A&&e){const e=new tt(this.document,t,"");return this.attributes[t]=e,e}return A||tt.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||tt.empty(this.document)}getStyle(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],A=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=this.styles[t];if(i)return i;const n=this.getAttribute(t);if(n.hasValue())return this.styles[t]=n,n;if(!A){const{parent:e}=this;if(e){const A=e.getStyle(t);if(A.hasValue())return A}}if(e){const e=new tt(this.document,t,"");return this.styles[t]=e,e}return tt.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=Dt.fromElement(this.document,this);e&&e.apply(t);const A=this.getStyle("clip-path",!1,!0);if(A.hasValue()){const e=A.getDefinition();e&&e.apply(t)}}clearContext(t){}renderChildren(t){this.children.forEach((e=>{e.render(t)}))}addChild(t){const e=t instanceof xt?t:this.document.createElement(t);e.parent=this,xt.ignoreChildTypes.includes(e.type)||this.children.push(e)}matchesSelector(t){var e;const{node:A}=this;if(!A)return!1;if("function"==typeof A.matches)return A.matches(t);const i=null===(e=A.getAttribute)||void 0===e?void 0:e.call(A,"class");return!(!i||""===i)&&i.split(" ").some((e=>`.${e}`===t))}addStylesFromStyleDefinition(){const{styles:t,stylesSpecificity:e}=this.document;let A;for(const i in t)if(!i.startsWith("@")&&this.matchesSelector(i)){const n=t[i],a=e[i];if(n)for(const t in n){let e=this.stylesSpecificity[t];void 0===e&&(e="000"),a&&a>=e&&(A=n[t],A&&(this.styles[t]=A),this.stylesSpecificity[t]=a)}}}removeStyles(t,e){return e.reduce(((e,A)=>{const i=t.getStyle(A);if(!i.hasValue())return e;const n=i.getString();return i.setValue(""),[...e,[A,n]]}),[])}restoreStyles(t,e){e.forEach((e=>{let[A,i]=e;t.getStyle(A,!0).setValue(i)}))}isFirstChild(){var t;return 0===(null===(t=this.parent)||void 0===t?void 0:t.children.indexOf(this))}constructor(t,e,A=!1){if(It(this,"document",void 0),It(this,"node",void 0),It(this,"captureTextNodes",void 0),It(this,"type",void 0),It(this,"attributes",void 0),It(this,"styles",void 0),It(this,"stylesSpecificity",void 0),It(this,"animationFrozen",void 0),It(this,"animationFrozenValue",void 0),It(this,"parent",void 0),It(this,"children",void 0),this.document=t,this.node=e,this.captureTextNodes=A,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 A=(i=e.nodeName,b.test(i)?i.toLowerCase():i);var i;this.attributes[A]=new tt(t,A,e.value)})),this.addStylesFromStyleDefinition(),this.getAttribute("style").hasValue()){this.getAttribute("style").getString().split(";").map((t=>t.trim())).forEach((e=>{if(!e)return;const[A,i]=e.split(":").map((t=>t.trim()));A&&(this.styles[A]=new tt(t,A,i))}))}const{definitions:i}=t,n=this.getAttribute("id");n.hasValue()&&(i[n.getString()]||(i[n.getString()]=this)),Array.from(e.childNodes).forEach((e=>{if(1===e.nodeType)this.addChild(e);else if(A&&(3===e.nodeType||4===e.nodeType)){const A=t.createTextNode(e);A.getText().length>0&&this.addChild(A)}}))}}It(xt,"ignoreChildTypes",["title"]);class Mt extends xt{constructor(t,e,A){super(t,e,A)}}function vt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function Ft(t){const e=t.trim();return/^('|")/.test(e)?e:`"${e}"`}function St(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 bt{static parse(){let t=arguments.length>1?arguments[1]:void 0,e="",A="",i="",n="",a="";const r=S(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&&bt.styles.includes(t):"inherit"!==t&&(e=t),s.fontStyle=!0;break;case!s.fontVariant&&bt.variants.includes(t):"inherit"!==t&&(A=t),s.fontStyle=!0,s.fontVariant=!0;break;case!s.fontWeight&&bt.weights.includes(t):"inherit"!==t&&(i=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 bt(e,A,i,n,a,t)}toString(){return[St(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,A,i,n,a){vt(this,"fontFamily",void 0),vt(this,"fontSize",void 0),vt(this,"fontStyle",void 0),vt(this,"fontWeight",void 0),vt(this,"fontVariant",void 0);const r=a?"string"==typeof a?bt.parse(a):a:{};this.fontFamily=n||r.fontFamily,this.fontSize=i||r.fontSize,this.fontStyle=t||r.fontStyle,this.fontWeight=A||r.fontWeight,this.fontVariant=e||r.fontVariant}}function Pt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}vt(bt,"styles","normal|italic|oblique|inherit"),vt(bt,"variants","normal|small-caps|inherit"),vt(bt,"weights","normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit");class Nt{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:A,x2:i,y2:n}=t;this.addPoint(e,A),this.addPoint(i,n)}sumCubic(t,e,A,i,n){return Math.pow(1-t,3)*e+3*Math.pow(1-t,2)*t*A+3*(1-t)*Math.pow(t,2)*i+Math.pow(t,3)*n}bezierCurveAdd(t,e,A,i,n){const a=6*e-12*A+6*i,r=-3*e+9*A-9*i+3*n,s=3*A-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,A,i,n)):this.addY(this.sumCubic(r,e,A,i,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,A,i,n)):this.addY(this.sumCubic(c,e,A,i,n)));const l=(-a-Math.sqrt(o))/(2*r);0<l&&l<1&&(t?this.addX(this.sumCubic(l,e,A,i,n)):this.addY(this.sumCubic(l,e,A,i,n)))}addBezierCurve(t,e,A,i,n,a,r,s){this.addPoint(t,e),this.addPoint(r,s),this.bezierCurveAdd(!0,t,A,n,r),this.bezierCurveAdd(!1,e,i,a,s)}addQuadraticCurve(t,e,A,i,n,a){const r=t+2/3*(A-t),s=e+2/3*(i-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:A,y1:i,x2:n,y2:a}=this;return A<=t&&t<=n&&i<=e&&e<=a}constructor(t=Number.NaN,e=Number.NaN,A=Number.NaN,i=Number.NaN){Pt(this,"x1",void 0),Pt(this,"y1",void 0),Pt(this,"x2",void 0),Pt(this,"y2",void 0),this.x1=t,this.y1=e,this.x2=A,this.y2=i,this.addPoint(t,e),this.addPoint(A,i)}}class Rt extends xt{calculateOpacity(){let t=1,e=this;for(;e;){const A=e.getStyle("opacity",!1,!0);A.hasValue(!0)&&(t*=A.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"),A=this.getStyle("fill-opacity"),i=this.getStyle("stroke"),n=this.getStyle("stroke-opacity");if(e.isUrlDefinition()){const i=e.getFillStyleDefinition(this,A);i&&(t.fillStyle=i)}else if(e.hasValue()){"currentColor"===e.getString()&&e.setValue(this.getStyle("color").getColor());const A=e.getColor();"inherit"!==A&&(t.fillStyle="none"===A?"rgba(0,0,0,0)":A)}if(A.hasValue()){const e=new tt(this.document,"fill",t.fillStyle).addOpacity(A).getColor();t.fillStyle=e}if(i.isUrlDefinition()){const e=i.getFillStyleDefinition(this,n);e&&(t.strokeStyle=e)}else if(i.hasValue()){"currentColor"===i.getString()&&i.setValue(this.getStyle("color").getColor());const e=i.getString();"inherit"!==e&&(t.strokeStyle="none"===e?"rgba(0,0,0,0)":e)}if(n.hasValue()){const e=new tt(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||J}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 A=l.getPixels();void 0!==t.lineDashOffset?t.lineDashOffset=A:void 0!==t.webkitLineDashOffset?t.webkitLineDashOffset=A:void 0!==t.mozDashOffset&&(t.mozDashOffset=A)}}if(this.modifiedEmSizeStack=!1,void 0!==t.font){const e=this.getStyle("font"),A=this.getStyle("font-style"),i=this.getStyle("font-variant"),n=this.getStyle("font-weight"),a=this.getStyle("font-size"),r=this.getStyle("font-family"),s=new bt(A.getString(),i.getString(),n.getString(),a.hasValue()?`${a.getPixels(!0)}px`:"",r.getString(),bt.parse(e.getString(),t.font));A.setValue(s.fontStyle),i.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,A,i;super(...t),i=!1,(A="modifiedEmSizeStack")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function Ht(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class kt extends Rt{setContext(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];super.setContext(t,e);const A=this.getStyle("dominant-baseline").getTextBaseline()||this.getStyle("alignment-baseline").getTextBaseline();A&&(t.textBaseline=A)}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(((A,i)=>{const n=this.getChildBoundingBox(t,this,this,i);e?e.addBoundingBox(n):e=n})),e}getFontSize(){const{document:t,parent:e}=this,A=bt.parse(t.ctx.font).fontSize;return e.getStyle("font-size").getNumber(A)}getTElementBoundingBox(t){const e=this.getFontSize();return new Nt(this.x,this.y-e,this.x+this.measureText(t),this.y)}getGlyph(t,e,A){const i=e[A];let n;if(t.isArabic){var a;const r=e.length,s=e[A-1],o=e[A+1];let c="isolated";(0===A||" "===s)&&A<r-1&&" "!==o&&(c="terminal"),A>0&&" "!==s&&A<r-1&&" "!==o&&(c="medial"),A>0&&" "!==s&&(A===r-1||" "===o)&&(c="initial"),n=(null===(a=t.arabicGlyphs[i])||void 0===a?void 0:a[c])||t.glyphs[i]}else n=t.glyphs[i];return n||(n=t.missingGlyph),n}getText(){return""}getTextFromNode(t){const e=t||this.node,A=Array.from(e.parentNode.childNodes),i=A.indexOf(e),n=A.length-1;let a=S(e.textContent||"");return 0===i&&(a=a.replace(/^[\n \t]+/,"")),i===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,A)=>{this.renderChild(t,this,this,A)}));const{mouse:e}=this.document.screen;e.isWorking()&&e.checkBoundingBox(this,this.getBoundingBox(t))}renderTElementChildren(t){const{document:e,parent:A}=this,i=this.getText(),n=A.getStyle("font-family").getDefinition();if(null==n?void 0:n.fontFace){const{unitsPerEm:a}=n.fontFace,r=bt.parse(e.ctx.font),s=A.getStyle("font-size").getNumber(r.fontSize),o=A.getStyle("font-style").getString(r.fontStyle),c=s/a,l=n.isRTL?i.split("").reverse().join(""):i,g=Y(A.getAttribute("dx").getString()),h=l.length;for(let e=0;e<h;e++){const A=this.getGlyph(n,l,e);t.translate(this.x,this.y),t.scale(c,-c);const i=t.lineWidth;t.lineWidth=t.lineWidth*a/s,"italic"===o&&t.transform(1,0,.4,1,0,0),A.render(t),"italic"===o&&t.transform(1,0,-.4,1,0,0),t.lineWidth=i,t.scale(1/c,-1/c),t.translate(-this.x,-this.y),this.x+=s*(A.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(i,a,r),t.strokeStyle&&t.strokeText(i,a,r)}applyAnchoring(){if(this.textChunkStart>=this.leafTexts.length)return;const t=this.leafTexts[this.textChunkStart],e=t.getStyle("text-anchor").getString("start");let A=0;A="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+=A;this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.textChunkStart=this.leafTexts.length}adjustChildCoordinatesRecursive(t){this.children.forEach(((e,A)=>{this.adjustChildCoordinatesRecursiveCore(t,this,this,A)})),this.applyAnchoring()}adjustChildCoordinatesRecursiveCore(t,e,A,i){const n=A.children[i];n.children.length>0?n.children.forEach(((A,i)=>{e.adjustChildCoordinatesRecursiveCore(t,e,n,i)})):this.adjustChildCoordinates(t,e,A,i)}adjustChildCoordinates(t,e,A,i){const n=A.children[i];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===i&&(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,A,i){const n=A.children[i];if("function"!=typeof n.getBoundingBox)return null;const a=n.getBoundingBox(t);return a&&n.children.forEach(((A,i)=>{const r=e.getChildBoundingBox(t,e,n,i);a.addBoundingBox(r)})),a}renderChild(t,e,A,i){const n=A.children[i];n.render(t),n.children.forEach(((A,i)=>{e.renderChild(t,e,n,i)}))}measureText(t){const{measureCache:e}=this;if(~e)return e;const A=this.getText(),i=this.measureTargetText(t,A);return this.measureCache=i,i}measureTargetText(t,e){if(!e.length)return 0;const{parent:A}=this,i=A.getStyle("font-family").getDefinition();if(i){const t=this.getFontSize(),n=i.isRTL?e.split("").reverse().join(""):e,a=Y(A.getAttribute("dx").getString()),r=n.length;let s=0;for(let e=0;e<r;e++){s+=(this.getGlyph(i,n,e).horizAdvX||i.horizAdvX)*t/i.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 kt&&e.isFirstChild()&&e.parent;){const A=e.parent.getAttribute(t);if(A.hasValue(!0))return A.getString("0");e=e.parent}return null}constructor(t,e,A){super(t,e,new.target===kt||A),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 Ut(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Gt extends kt{getText(){return this.text}constructor(t,e,A){super(t,e,new.target===Gt||A),Ut(this,"type","tspan"),Ut(this,"text",void 0),this.text=this.children.length>0?"":this.getTextFromNode()}}class Tt extends Gt{constructor(...t){var e,A,i;super(...t),i="textNode",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function Ot(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Jt extends w.SVGPathData{reset(){this.i=-1,this.command=null,this.previousCommand=null,this.start=new at(0,0),this.control=new at(0,0),this.current=new at(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 A=new at(this.command[t],this.command[e]);return this.makeAbsolute(A)}getAsControlPoint(t,e){const A=this.getPoint(t,e);return this.control=A,A}getAsCurrentPoint(t,e){const A=this.getPoint(t,e);return this.current=A,A}getReflectedControlPoint(){const t=this.previousCommand.type;if(t!==w.SVGPathData.CURVE_TO&&t!==w.SVGPathData.SMOOTH_CURVE_TO&&t!==w.SVGPathData.QUAD_TO&&t!==w.SVGPathData.SMOOTH_QUAD_TO)return this.current;const{current:{x:e,y:A},control:{x:i,y:n}}=this;return new at(2*e-i,2*A-n)}makeAbsolute(t){if(this.command.relative){const{x:e,y:A}=this.current;t.x+=e,t.y+=A}return t}addMarker(t,e,A){const{points:i,angles:n}=this;A&&n.length>0&&!n[n.length-1]&&(n[n.length-1]=i[i.length-1].angleTo(A)),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 A=0;A<e;A++)if(!t[A])for(let i=A+1;i<e;i++)if(t[i]){t[A]=t[i];break}return t}constructor(t){super(t.replace(/([+\-.])\s+/gm,"$1").replace(/[^MmZzLlHhVvCcSsQqTtAae\d\s.,+-].*/g,"")),Ot(this,"control",new at(0,0)),Ot(this,"start",new at(0,0)),Ot(this,"current",new at(0,0)),Ot(this,"command",null),Ot(this,"commands",this.commands),Ot(this,"i",-1),Ot(this,"previousCommand",null),Ot(this,"points",[]),Ot(this,"angles",[])}}function Lt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class zt extends Rt{path(t){const{pathParser:e}=this,A=new Nt;for(e.reset(),t&&t.beginPath();!e.isEnd();)switch(e.next().type){case Jt.MOVE_TO:this.pathM(t,A);break;case Jt.LINE_TO:this.pathL(t,A);break;case Jt.HORIZ_LINE_TO:this.pathH(t,A);break;case Jt.VERT_LINE_TO:this.pathV(t,A);break;case Jt.CURVE_TO:this.pathC(t,A);break;case Jt.SMOOTH_CURVE_TO:this.pathS(t,A);break;case Jt.QUAD_TO:this.pathQ(t,A);break;case Jt.SMOOTH_QUAD_TO:this.pathT(t,A);break;case Jt.ARC:this.pathA(t,A);break;case Jt.CLOSE_PATH:this.pathZ(t,A)}return A}getBoundingBox(t){return this.path()}getMarkers(){const{pathParser:t}=this,e=t.getMarkerPoints(),A=t.getMarkerAngles();if(!e||!A)return null;return e.map(((t,e)=>[t,A[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 A=this.getMarkers();if(A){const e=A.length-1,i=this.getStyle("marker-start"),n=this.getStyle("marker-mid"),a=this.getStyle("marker-end");if(i.isUrlDefinition()){const e=i.getDefinition(),[n,a]=A[0];e&&e.render(t,n,null===a?void 0:a)}if(n.isUrlDefinition()){const i=n.getDefinition();for(let n=1;n<e;n++){const[e,a]=A[n];i&&i.render(t,e,null===a?void 0:a)}}if(a.isUrlDefinition()){const i=a.getDefinition(),[n,r]=A[e];i&&i.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:A}=this,{point:i}=zt.pathM(A),{x:n,y:a}=i;A.addMarker(i),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:A}=this,{current:i,point:n}=zt.pathL(A),{x:a,y:r}=n;A.addMarker(n,i),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathH(t){const{current:e,command:A}=t,i=new at(((null==A?void 0:A.relative)?e.x:0)+A.x,e.y);return t.current=i,{current:e,point:i}}pathH(t,e){const{pathParser:A}=this,{current:i,point:n}=zt.pathH(A),{x:a,y:r}=n;A.addMarker(n,i),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathV(t){const{current:e,command:A}=t,i=new at(e.x,(A.relative?e.y:0)+A.y);return t.current=i,{current:e,point:i}}pathV(t,e){const{pathParser:A}=this,{current:i,point:n}=zt.pathV(A),{x:a,y:r}=n;A.addMarker(n,i),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:A}=this,{current:i,point:n,controlPoint:a,currentPoint:r}=zt.pathC(A);A.addMarker(r,a,n),e.addBezierCurve(i.x,i.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:A}=this,{current:i,point:n,controlPoint:a,currentPoint:r}=zt.pathS(A);A.addMarker(r,a,n),e.addBezierCurve(i.x,i.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:A}=this,{current:i,controlPoint:n,currentPoint:a}=zt.pathQ(A);A.addMarker(a,n,n),e.addQuadraticCurve(i.x,i.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,A=t.getReflectedControlPoint();t.control=A;return{current:e,controlPoint:A,currentPoint:t.getAsCurrentPoint()}}pathT(t,e){const{pathParser:A}=this,{current:i,controlPoint:n,currentPoint:a}=zt.pathT(A);A.addMarker(a,n,n),e.addQuadraticCurve(i.x,i.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:A}=t;let{rX:i,rY:n,xRot:a,lArcFlag:r,sweepFlag:s}=A;const o=a*(Math.PI/180),c=t.getAsCurrentPoint(),l=new at(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(i,2)+Math.pow(l.y,2)/Math.pow(n,2);g>1&&(i*=Math.sqrt(g),n*=Math.sqrt(g));let h=(r===s?-1:1)*Math.sqrt((Math.pow(i,2)*Math.pow(n,2)-Math.pow(i,2)*Math.pow(l.y,2)-Math.pow(n,2)*Math.pow(l.x,2))/(Math.pow(i,2)*Math.pow(l.y,2)+Math.pow(n,2)*Math.pow(l.x,2)));isNaN(h)&&(h=0);const d=new at(h*i*l.y/n,h*-n*l.x/i),u=new at((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),B=j([1,0],[(l.x-d.x)/i,(l.y-d.y)/n]),w=[(l.x-d.x)/i,(l.y-d.y)/n],E=[(-l.x-d.x)/i,(-l.y-d.y)/n];let p=j(w,E);return z(w,E)<=-1&&(p=Math.PI),z(w,E)>=1&&(p=0),{currentPoint:c,rX:i,rY:n,sweepFlag:s,xAxisRotation:o,centp:u,a1:B,ad:p}}pathA(t,e){const{pathParser:A}=this,{currentPoint:i,rX:n,rY:a,sweepFlag:r,xAxisRotation:s,centp:o,a1:c,ad:l}=zt.pathA(A),g=1-r?1:-1,h=c+g*(l/2),d=new at(o.x+n*Math.cos(h),o.y+a*Math.sin(h));if(A.addMarkerAngle(d,h-g*Math.PI/2),A.addMarkerAngle(i,h-g*Math.PI),e.addPoint(i.x,i.y),t&&!isNaN(c)&&!isNaN(l)){const e=n>a?n:a,A=n>a?1:n/a,i=n>a?a/n:1;t.translate(o.x,o.y),t.rotate(s),t.scale(A,i),t.arc(0,0,e,c,c+l,Boolean(1-r)),t.scale(1/A,1/i),t.rotate(-s),t.translate(-o.x,-o.y)}}static pathZ(t){t.current=t.start}pathZ(t,e){zt.pathZ(this.pathParser),t&&e.x1!==e.x2&&e.y1!==e.y2&&t.closePath()}constructor(t,e,A){super(t,e,A),Lt(this,"type","path"),Lt(this,"pathParser",void 0),this.pathParser=new Jt(this.getAttribute("d").getString())}}function jt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Vt extends Rt{setContext(t){var e;const{document:A}=this,{screen:i,window:n}=A,a=t.canvas;if(i.setDefaults(t),"style"in a&&void 0!==t.font&&n&&void 0!==n.getComputedStyle){t.font=n.getComputedStyle(a).getPropertyValue("font");const e=new tt(A,"fontSize",bt.parse(t.font).fontSize);e.hasValue()&&(A.rootEmSize=e.getPixels("y"),A.emSize=A.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}=i.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,B=0,w=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&&(B=d,w=u,d=0,u=0)),i.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]),A.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:i.viewPort.width,desiredWidth:r,height:i.viewPort.height,desiredHeight:s,minX:d,minY:u,refX:o.getValue(),refY:c.getValue(),clip:h,clipX:B,clipY:w}),g&&(i.viewPort.removeCurrent(),i.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,A=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=this.getAttribute("width",!0),n=this.getAttribute("height",!0),a=this.getAttribute("viewBox"),r=this.getAttribute("style"),s=i.getNumber(0),o=n.getNumber(0);if(A)if("string"==typeof A)this.getAttribute("preserveAspectRatio",!0).setValue(A);else{const t=this.getAttribute("preserveAspectRatio");t.hasValue()&&t.setValue(t.getString().replace(/^\s*(\S.*\S)\s*$/,"$1"))}if(i.setValue(t),n.setValue(e),a.hasValue()||a.setValue(`0 0 ${s||t} ${o||e}`),r.hasValue()){const A=this.getStyle("width"),i=this.getStyle("height");A.hasValue()&&A.setValue(`${t}px`),i.hasValue()&&i.setValue(`${e}px`)}}constructor(...t){super(...t),jt(this,"type","svg"),jt(this,"root",!1)}}class Kt extends zt{path(t){const e=this.getAttribute("x").getPixels("x"),A=this.getAttribute("y").getPixels("y"),i=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,i/2),o=Math.min(o,n/2),t){const a=(Math.sqrt(2)-1)/3*4;t.beginPath(),n>0&&i>0&&(t.moveTo(e+s,A),t.lineTo(e+i-s,A),t.bezierCurveTo(e+i-s+a*s,A,e+i,A+o-a*o,e+i,A+o),t.lineTo(e+i,A+n-o),t.bezierCurveTo(e+i,A+n-o+a*o,e+i-s+a*s,A+n,e+i-s,A+n),t.lineTo(e+s,A+n),t.bezierCurveTo(e+s-a*s,A+n,e,A+n-o+a*o,e,A+n-o),t.lineTo(e,A+o),t.bezierCurveTo(e,A+o-a*o,e+s-a*s,A,e+s,A),t.closePath())}return new Nt(e,A,e+i,A+n)}getMarkers(){return null}constructor(...t){var e,A,i;super(...t),i="rect",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function Wt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Xt extends zt{path(t){const{points:e}=this,[{x:A,y:i}]=e,n=new Nt(A,i);return t&&(t.beginPath(),t.moveTo(A,i)),e.forEach((e=>{let{x:A,y:i}=e;n.addPoint(A,i),t&&t.lineTo(A,i)})),n}getMarkers(){const{points:t}=this,e=t.length-1,A=[];return t.forEach(((i,n)=>{n!==e&&A.push([i,i.angleTo(t[n+1])])})),A.length>0&&A.push([t[t.length-1],A[A.length-1][1]]),A}constructor(t,e,A){super(t,e,A),Wt(this,"type","polyline"),Wt(this,"points",[]),this.points=at.parsePath(this.getAttribute("points").getString())}}class qt extends Rt{getBoundingBox(t){const e=new Nt;return this.children.forEach((A=>{A instanceof zt&&e.addBoundingBox(A.getBoundingBox(t))})),e}constructor(...t){var e,A,i;super(...t),i="g",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function Zt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class $t extends xt{getGradientUnits(){return this.getAttribute("gradientUnits").getString("objectBoundingBox")}createGradient(t,e,A){let i=this;this.getHrefAttribute().hasValue()&&(i=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(i));const{stops:n}=i,a=this.getGradient(t,e);if(!a)return this.addParentOpacity(A,n[n.length-1].color);if(n.forEach((t=>{a.addColorStop(t.offset,this.addParentOpacity(A,t.color))})),this.getAttribute("gradientTransform").hasValue()){const{document:t}=this,{MAX_VIRTUAL_PIXELS:e}=gt,{viewPort:A}=t.screen,i=A.getRoot(),n=new Kt(t);n.attributes.x=new tt(t,"x",-e/3),n.attributes.y=new tt(t,"y",-e/3),n.attributes.width=new tt(t,"width",e),n.attributes.height=new tt(t,"height",e);const r=new qt(t);r.attributes.transform=new tt(t,"transform",this.getAttribute("gradientTransform").getValue()),r.children=[n];const s=new Vt(t);s.attributes.x=new tt(t,"x",0),s.attributes.y=new tt(t,"y",0),s.attributes.width=new tt(t,"width",i.width),s.attributes.height=new tt(t,"height",i.height),s.children=[r];const o=t.createCanvas(i.width,i.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 tt(this.document,"color",e).addOpacity(t).getColor()}return e}constructor(t,e,A){super(t,e,A),Zt(this,"attributesToInherit",["gradientUnits"]),Zt(this,"stops",[]);const{stops:i,children:n}=this;n.forEach((t=>{"stop"===t.type&&i.push(t)}))}}function _t(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function te(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ee extends xt{getProperty(){var t;const e=this.getAttribute("attributeType").getString(),A=this.getAttribute("attributeName").getString();var i;return"CSS"===e?null===(i=this.parent)||void 0===i?void 0:i.getStyle(A,!0):null===(t=this.parent)||void 0===t?void 0:t.getAttribute(A,!0)}calcValue(){const{initialUnits:t}=this,{progress:e,from:A,to:i}=this.getProgress();let n=A.getNumber()+(i.getNumber()-A.getNumber())*e;return"%"===t&&(n*=100),`${n}${t}`}update(t){const{parent:e}=this,A=this.getProperty();if(!A)return!1;if(this.initialValue||(this.initialValue=A.getString(),this.initialUnits=A.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&&A&&A.setValue(e.animationFrozen?e.animationFrozenValue:this.initialValue),!0}else this.frozen=!0,e&&A&&(e.animationFrozen=!0,e.animationFrozenValue=A.getString());return!1}this.duration+=t;let i=!1;if(this.begin<this.duration){let t=this.calcValue();const e=this.getAttribute("type");if(e.hasValue()){t=`${e.getString()}(${t})`}A.setValue(t),i=!0}return i}getProgress(){const{document:t,values:e}=this;let A,i,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],A=new tt(t,"from",o?parseFloat(o):0),o=e.getValue()[s],i=new tt(t,"to",o?parseFloat(o):0),n=(a-r)/(s-r)}else A=this.from,i=this.to;return{progress:n,from:A,to:i}}constructor(t,e,A){super(t,e,A),te(this,"type","animate"),te(this,"begin",void 0),te(this,"maxDuration",void 0),te(this,"from",void 0),te(this,"to",void 0),te(this,"values",void 0),te(this,"duration",0),te(this,"initialValue",void 0),te(this,"initialUnits",""),te(this,"removed",!1),te(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 tt(t,"values",null);const i=this.getAttribute("values");i.hasValue()&&this.values.setValue(i.getString().split(";"))}}function Ae(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ie extends xt{constructor(t,e,A){super(t,e,A),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 ne(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ae extends zt{constructor(t,e,A){super(t,e,A),ne(this,"type","glyph"),ne(this,"horizAdvX",void 0),ne(this,"unicode",void 0),ne(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 re(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class se extends ae{constructor(...t){super(...t),re(this,"type","missing-glyph"),re(this,"horizAdvX",0)}}function oe(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function ce(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function le(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function ge(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const he=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*)$/i;function de(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ue{async load(t,e){try{const{document:A}=this,i=(await A.pith.parser.load(e)).getElementsByTagName("font");Array.from(i).forEach((e=>{const i=A.createElement(e);A.definitions[t]=i}))}catch(t){console.error(`Error while loading font "${e}":`,t)}this.loaded=!0}constructor(t){de(this,"document",void 0),de(this,"loaded",void 0),this.document=t,this.loaded=!1,t.fonts.push(this)}}function Be(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class we extends xt{constructor(t,e,A){super(t,e,A),Be(this,"type","style");S(Array.from(e.childNodes).map((t=>t.textContent)).join("").replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"").replace(/@import.*;/g,"")).split("}").forEach((e=>{const A=e.trim();if(!A)return;const i=A.split("{"),n=i[0].split(","),a=i[1].split(";");n.forEach((e=>{const A=e.trim();if(!A)return;const i=t.styles[A]||{};if(a.forEach((e=>{const A=e.indexOf(":"),n=e.substr(0,A).trim(),a=e.substr(A+1,e.length-A).trim();n&&a&&(i[n]=new tt(t,n,a))})),t.styles[A]=i,t.stylesSpecificity[A]=function(t){const e=[0,0,0];let A=t.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),i=0;return[A,i]=O(A,N),e[1]+=i,[A,i]=O(A,R),e[0]+=i,[A,i]=O(A,H),e[1]+=i,[A,i]=O(A,k),e[2]+=i,[A,i]=O(A,U),e[1]+=i,[A,i]=O(A,G),e[1]+=i,A=A.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),[A,i]=O(A,T),e[2]+=i,e.join("")}(A),"@font-face"===A){const e=i["font-family"].getString().replace(/"|'/g,"");i.src.getString().split(",").forEach((A=>{if(A.indexOf('format("svg")')>0){const i=P(A);i&&new ue(t).load(e,i)}}))}}))}))}}function Ee(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}Be(we,"parseExternalUrl",P);function pe(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function me(t,e,A,i,n,a){return t[A*i*4+4*e+a]}function Ce(t,e,A,i,n,a,r){t[A*i*4+4*e+a]=r}function fe(t,e,A){return t[e]*A}function Qe(t,e,A,i){return e+Math.cos(t)*A+Math.sin(t)*i}class ye extends xt{apply(t,e,A,i,n){const{includeOpacity:a,matrix:r}=this,s=t.getImageData(0,0,i,n);for(let t=0;t<n;t++)for(let e=0;e<i;e++){const A=me(s.data,e,t,i,0,0),n=me(s.data,e,t,i,0,1),o=me(s.data,e,t,i,0,2),c=me(s.data,e,t,i,0,3);let l=fe(r,0,A)+fe(r,1,n)+fe(r,2,o)+fe(r,3,c)+fe(r,4,1),g=fe(r,5,A)+fe(r,6,n)+fe(r,7,o)+fe(r,8,c)+fe(r,9,1),h=fe(r,10,A)+fe(r,11,n)+fe(r,12,o)+fe(r,13,c)+fe(r,14,1),d=fe(r,15,A)+fe(r,16,n)+fe(r,17,o)+fe(r,18,c)+fe(r,19,1);a&&(l=0,g=0,h=0,d*=c/255),Ce(s.data,e,t,i,0,0,l),Ce(s.data,e,t,i,0,1,g),Ce(s.data,e,t,i,0,2,h),Ce(s.data,e,t,i,0,3,d)}t.clearRect(0,0,i,n),t.putImageData(s,0,0)}constructor(t,e,A){super(t,e,A),pe(this,"type","feColorMatrix"),pe(this,"matrix",void 0),pe(this,"includeOpacity",void 0);let i=Y(this.getAttribute("values").getString());switch(this.getAttribute("type").getString("matrix")){case"saturate":{const t=i[0];i=[.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=i[0]*Math.PI/180;i=[Qe(t,.213,.787,-.213),Qe(t,.715,-.715,-.715),Qe(t,.072,-.072,.928),0,0,Qe(t,.213,-.213,.143),Qe(t,.715,.285,.14),Qe(t,.072,-.072,-.283),0,0,Qe(t,.213,-.213,-.787),Qe(t,.715,-.715,.715),Qe(t,.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break}case"luminanceToAlpha":i=[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=i,this.includeOpacity=this.getAttribute("includeOpacity").hasValue()}}function De(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Ie extends xt{apply(t,e){const{document:A}=this;let i=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 Nt;this.children.forEach((A=>{A instanceof zt&&e.addBoundingBox(A.getBoundingBox(t))})),i=Math.floor(e.x1),n=Math.floor(e.y1),a=Math.floor(e.width),r=Math.floor(e.height)}const s=this.removeStyles(e,Ie.ignoreStyles),o=A.createCanvas(i+a,n+r),c=o.getContext("2d");A.screen.setDefaults(c),this.renderChildren(c),new ye(A,{nodeType:1,childNodes:[],attributes:[{nodeName:"type",value:"luminanceToAlpha"},{nodeName:"includeOpacity",value:"true"}]}).apply(c,0,0,i+a,n+r);const l=A.createCanvas(i+a,n+r),g=l.getContext("2d");A.screen.setDefaults(g),e.render(g),g.globalCompositeOperation="destination-in",g.fillStyle=c.createPattern(o,"no-repeat"),g.fillRect(0,0,i+a,n+r),t.fillStyle=g.createPattern(l,"no-repeat"),t.fillRect(0,0,i+a,n+r),this.restoreStyles(e,s)}render(t){}constructor(...t){super(...t),De(this,"type","mask")}}De(Ie,"ignoreStyles",["mask","transform","clip-path"]);const xe=()=>{};function Me(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ve extends xt{apply(t,e,A,i,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,E.canvasRGBA)(o,e,A,i,n,r),s&&s.removeChild(o)}constructor(t,e,A){super(t,e,A),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,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Se extends xt{apply(t,e){const{document:A,children:i}=this,n="getBoundingBox"in e?e.getBoundingBox(t):null;if(!n)return;let a=0,r=0;i.forEach((t=>{if(!(t instanceof ve))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,Se.ignoreStyles),u=A.createCanvas(c,l),B=u.getContext("2d");A.screen.setDefaults(B),B.translate(-g+a,-h+r),e.render(B),i.forEach((t=>{t instanceof ve&&"function"==typeof t.apply&&t.apply(B,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(Se,"ignoreStyles",["filter","transform","clip-path"]);const Ye={svg:Vt,rect:Kt,circle:class extends zt{path(t){const e=this.getAttribute("cx").getPixels("x"),A=this.getAttribute("cy").getPixels("y"),i=this.getAttribute("r").getPixels();return t&&i>0&&(t.beginPath(),t.arc(e,A,i,0,2*Math.PI,!1),t.closePath()),new Nt(e-i,A-i,e+i,A+i)}getMarkers(){return null}constructor(...t){var e,A,i;super(...t),i="circle",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},ellipse:class extends zt{path(t){const e=(Math.sqrt(2)-1)/3*4,A=this.getAttribute("rx").getPixels("x"),i=this.getAttribute("ry").getPixels("y"),n=this.getAttribute("cx").getPixels("x"),a=this.getAttribute("cy").getPixels("y");return t&&A>0&&i>0&&(t.beginPath(),t.moveTo(n+A,a),t.bezierCurveTo(n+A,a+e*i,n+e*A,a+i,n,a+i),t.bezierCurveTo(n-e*A,a+i,n-A,a+e*i,n-A,a),t.bezierCurveTo(n-A,a-e*i,n-e*A,a-i,n,a-i),t.bezierCurveTo(n+e*A,a-i,n+A,a-e*i,n+A,a),t.closePath()),new Nt(n-A,a-i,n+A,a+i)}getMarkers(){return null}constructor(...t){var e,A,i;super(...t),i="ellipse",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},line:class extends zt{getPoints(){return[new at(this.getAttribute("x1").getPixels("x"),this.getAttribute("y1").getPixels("y")),new at(this.getAttribute("x2").getPixels("x"),this.getAttribute("y2").getPixels("y"))]}path(t){const[{x:e,y:A},{x:i,y:n}]=this.getPoints();return t&&(t.beginPath(),t.moveTo(e,A),t.lineTo(i,n)),new Nt(e,A,i,n)}getMarkers(){const[t,e]=this.getPoints(),A=t.angleTo(e);return[[t,A],[e,A]]}constructor(...t){var e,A,i;super(...t),i="line",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},polyline:Xt,polygon:class extends Xt{path(t){const e=super.path(t),[{x:A,y:i}]=this.points;return t&&(t.lineTo(A,i),t.closePath()),e}constructor(...t){var e,A,i;super(...t),i="polygon",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},path:zt,pattern:class extends xt{createPattern(t,e,A){const i=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):i,o=r.hasValue()?r.getPixels("y",!0):n,c=a.hasValue()&&r.hasValue(),l=new Vt(this.document,void 0);l.attributes.viewBox=new tt(this.document,"viewBox",this.getAttribute("viewBox").getValue()),l.attributes.width=new tt(this.document,"width",`${s}px`),l.attributes.height=new tt(this.document,"height",`${o}px`),l.attributes.transform=new tt(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)),A.hasValue()?this.styles["fill-opacity"]=A: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 tt(this.document,"x",t*g.width),l.attributes.y=new tt(this.document,"y",e*g.height),l.render(h),h.restore();return t.createPattern(g,c?"no-repeat":"repeat")}constructor(...t){var e,A,i;super(...t),i="pattern",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},marker:class extends xt{render(t,e,A){if(!e)return;const{x:i,y:n}=e,a=this.getAttribute("orient").getString("auto"),r=this.getAttribute("markerUnits").getString("strokeWidth");t.translate(i,n),"auto"===a&&A&&t.rotate(A),"strokeWidth"===r&&t.scale(t.lineWidth,t.lineWidth),t.save();const s=new Vt(this.document);s.type=this.type,s.attributes.viewBox=new tt(this.document,"viewBox",this.getAttribute("viewBox").getValue()),s.attributes.refX=new tt(this.document,"refX",this.getAttribute("refX").getValue()),s.attributes.refY=new tt(this.document,"refY",this.getAttribute("refY").getValue()),s.attributes.width=new tt(this.document,"width",this.getAttribute("markerWidth").getValue()),s.attributes.height=new tt(this.document,"height",this.getAttribute("markerHeight").getValue()),s.attributes.overflow=new tt(this.document,"overflow",this.getAttribute("overflow").getValue()),s.attributes.fill=new tt(this.document,"fill",this.getAttribute("fill").getColor("black")),s.attributes.stroke=new tt(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&&A&&t.rotate(-A),t.translate(-i,-n)}constructor(...t){var e,A,i;super(...t),i="marker",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},defs:class extends xt{render(){}constructor(...t){var e,A,i;super(...t),i="defs",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},linearGradient:class extends $t{getGradient(t,e){const A="objectBoundingBox"===this.getGradientUnits(),i=A?e.getBoundingBox(t):null;if(A||!i)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=A?i.x+i.width*this.getAttribute("x1").getNumber():this.getAttribute("x1").getPixels("x"),a=A?i.y+i.height*this.getAttribute("y1").getNumber():this.getAttribute("y1").getPixels("y"),r=A?i.x+i.width*this.getAttribute("x2").getNumber():this.getAttribute("x2").getPixels("x"),s=A?i.y+i.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,A){var i,n,a;super(t,e,A),a="linearGradient",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.attributesToInherit.push("x1","y1","x2","y2")}},radialGradient:class extends $t{getGradient(t,e){const A="objectBoundingBox"===this.getGradientUnits(),i=e.getBoundingBox(t);if(A&&!i)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=A?i.x+i.width*this.getAttribute("cx").getNumber():this.getAttribute("cx").getPixels("x"),a=A?i.y+i.height*this.getAttribute("cy").getNumber():this.getAttribute("cy").getPixels("y");let r=n,s=a;this.getAttribute("fx").hasValue()&&(r=A?i.x+i.width*this.getAttribute("fx").getNumber():this.getAttribute("fx").getPixels("x")),this.getAttribute("fy").hasValue()&&(s=A?i.y+i.height*this.getAttribute("fy").getNumber():this.getAttribute("fy").getPixels("y"));const o=A?(i.width+i.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,A){var i,n,a;super(t,e,A),a="radialGradient",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.attributesToInherit.push("cx","cy","r","fx","fy","fr")}},stop:class extends xt{constructor(t,e,A){super(t,e,A),_t(this,"type","stop"),_t(this,"offset",void 0),_t(this,"color",void 0);const i=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=i,this.color=a.getColor()}},animate:ee,animateColor:class extends ee{calcValue(){const{progress:t,from:e,to:A}=this.getProgress(),i=new(F(B))(e.getColor()),n=new(F(B))(A.getColor());if(i.ok&&n.ok){const e=i.r+(n.r-i.r)*t,A=i.g+(n.g-i.g)*t,a=i.b+(n.b-i.b)*t;return`rgb(${Math.floor(e)}, ${Math.floor(A)}, ${Math.floor(a)})`}return this.getAttribute("from").getColor()}constructor(...t){var e,A,i;super(...t),i="animateColor",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},animateTransform:class extends ee{calcValue(){const{progress:t,from:e,to:A}=this.getProgress(),i=Y(e.getString()),n=Y(A.getString()),a=i.map(((e,A)=>e+(n[A]-e)*t)).join(" ");return a}constructor(...t){var e,A,i;super(...t),i="animateTransform",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},font:class extends xt{render(){}constructor(t,e,A){super(t,e,A),oe(this,"type","font"),oe(this,"isArabic",!1),oe(this,"missingGlyph",void 0),oe(this,"glyphs",{}),oe(this,"arabicGlyphs",{}),oe(this,"horizAdvX",void 0),oe(this,"isRTL",!1),oe(this,"fontFace",void 0),this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber();const{definitions:i}=t,{children:n}=this;for(const t of n)if(t instanceof ie){this.fontFace=t;const e=t.getStyle("font-family");e.hasValue()&&(i[e.getString()]=this)}else if(t instanceof se)this.missingGlyph=t;else if(t instanceof ae)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":ie,"missing-glyph":se,glyph:ae,text:kt,tspan:Gt,tref:class extends kt{getText(){const t=this.getHrefAttribute().getDefinition();if(t){const e=t.children[0];if(e)return e.getText()}return""}constructor(...t){var e,A,i;super(...t),i="tref",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},a:class extends kt{getText(){return this.text}renderChildren(t){if(this.hasText){super.renderChildren(t);const{document:e,x:A,y:i}=this,{mouse:n}=e.screen,a=new tt(e,"fontSize",bt.parse(e.ctx.font).fontSize);n.isWorking()&&n.checkBoundingBox(this,new Nt(A,i-a.getPixels("y"),A+this.measureText(t),i))}else if(this.children.length>0){const e=new qt(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,A){super(t,e,A),ce(this,"type","a"),ce(this,"hasText",void 0),ce(this,"text",void 0);const{childNodes:i}=e,n=i[0],a=i.length>0&&Array.from(i).every((t=>3===t.nodeType));this.hasText=a,this.text=a?this.getTextFromNode(n):""}},textPath:class extends kt{getText(){return this.text}path(t){const{dataArray:e}=this;t&&t.beginPath(),e.forEach((e=>{let{type:A,points:i}=e;switch(A){case Jt.LINE_TO:t&&t.lineTo(i[0],i[1]);break;case Jt.MOVE_TO:t&&t.moveTo(i[0],i[1]);break;case Jt.CURVE_TO:t&&t.bezierCurveTo(i[0],i[1],i[2],i[3],i[4],i[5]);break;case Jt.QUAD_TO:t&&t.quadraticCurveTo(i[0],i[1],i[2],i[3]);break;case Jt.ARC:{const[e,A,n,a,r,s,o,c]=i,l=n>a?n:a,g=n>a?1:n/a,h=n>a?a/n:1;t&&(t.translate(e,A),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,-A));break}case Jt.CLOSE_PATH:t&&t.closePath()}}))}renderChildren(t){var e;this.setTextData(t),t.save();const A=null===(e=this.parent)||void 0===e?void 0:e.getStyle("text-decoration").getString(),i=this.getFontSize(),{glyphInfo:n}=this,a=t.fillStyle;"underline"===A&&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"===A&&(0===n&&t.moveTo(a.x,a.y+i/8),t.lineTo(r.x,r.y+i/5))})),"underline"===A&&(t.lineWidth=i/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,A,i,n,a,r,s,o){let c=a,l=this.measureText(t,s);" "===s&&"justify"===e&&A<i&&(l+=(i-A)/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},B=h&&d?Math.atan2(d.y-h.y,d.x-h.x):0;if(r){const t=Math.cos(Math.PI/2+B)*r,e=Math.cos(-B)*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:B}}measureText(t,e){const{measuresCache:A}=this,i=e||this.getText();if(A.has(i))return A.get(i);const n=this.measureTargetText(t,i);return A.set(i,n),n}setTextData(t){var e,A,i;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===(A=this.parent)||void 0===A?void 0:A.getAttribute("dy").getPixels("y"),c=this.getAttribute("text-anchor").getString("start"),l=this.getStyle("letter-spacing"),g=null===(i=this.parent)||void 0===i?void 0:i.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 B=d.reduce(((t,e,A)=>0===A?0:t+e||0),0),w=this.measureText(t),E=Math.max(w+B,0);this.textWidth=w,this.textHeight=this.getFontSize(),this.glyphInfo=[];const p=this.getPathLength(),m=this.getAttribute("startOffset").getNumber(0)*p;let C=0;"middle"!==c&&"center"!==c||(C=-E/2),"end"!==c&&"right"!==c||(C=-E),C+=m,a.forEach(((e,A)=>{const{offset:i,segment:n,rotation:s}=this.findSegmentToFitChar(t,c,E,p,r,C,o,e,A);C=i,n.p0&&n.p1&&this.glyphInfo.push({text:a[A],p0:n.p0,p1:n.p1,rotation:s})}))}parsePathData(t){if(this.pathLength=-1,!t)return[];const e=[],{pathParser:A}=t;for(A.reset();!A.isEnd();){const{current:t}=A,i=t?t.x:0,n=t?t.y:0,a=A.next();let r=a.type,s=[];switch(a.type){case Jt.MOVE_TO:this.pathM(A,s);break;case Jt.LINE_TO:r=this.pathL(A,s);break;case Jt.HORIZ_LINE_TO:r=this.pathH(A,s);break;case Jt.VERT_LINE_TO:r=this.pathV(A,s);break;case Jt.CURVE_TO:this.pathC(A,s);break;case Jt.SMOOTH_CURVE_TO:r=this.pathS(A,s);break;case Jt.QUAD_TO:this.pathQ(A,s);break;case Jt.SMOOTH_QUAD_TO:r=this.pathT(A,s);break;case Jt.ARC:s=this.pathA(A);break;case Jt.CLOSE_PATH:zt.pathZ(A)}a.type!==Jt.CLOSE_PATH?e.push({type:r,points:s,start:{x:i,y:n},pathLength:this.calcLength(i,n,r,s)}):e.push({type:Jt.CLOSE_PATH,points:[],pathLength:0})}return e}pathM(t,e){const{x:A,y:i}=zt.pathM(t).point;e.push(A,i)}pathL(t,e){const{x:A,y:i}=zt.pathL(t).point;return e.push(A,i),Jt.LINE_TO}pathH(t,e){const{x:A,y:i}=zt.pathH(t).point;return e.push(A,i),Jt.LINE_TO}pathV(t,e){const{x:A,y:i}=zt.pathV(t).point;return e.push(A,i),Jt.LINE_TO}pathC(t,e){const{point:A,controlPoint:i,currentPoint:n}=zt.pathC(t);e.push(A.x,A.y,i.x,i.y,n.x,n.y)}pathS(t,e){const{point:A,controlPoint:i,currentPoint:n}=zt.pathS(t);return e.push(A.x,A.y,i.x,i.y,n.x,n.y),Jt.CURVE_TO}pathQ(t,e){const{controlPoint:A,currentPoint:i}=zt.pathQ(t);e.push(A.x,A.y,i.x,i.y)}pathT(t,e){const{controlPoint:A,currentPoint:i}=zt.pathT(t);return e.push(A.x,A.y,i.x,i.y),Jt.QUAD_TO}pathA(t){let{rX:e,rY:A,sweepFlag:i,xAxisRotation:n,centp:a,a1:r,ad:s}=zt.pathA(t);return 0===i&&s>0&&(s-=2*Math.PI),1===i&&s<0&&(s+=2*Math.PI),[a.x,a.y,e,A,r,s,n,i]}calcLength(t,e,A,i){let n=0,a=null,r=null,s=0;switch(A){case Jt.LINE_TO:return this.getLineLength(t,e,i[0],i[1]);case Jt.CURVE_TO:for(n=0,a=this.getPointOnCubicBezier(0,t,e,i[0],i[1],i[2],i[3],i[4],i[5]),s=.01;s<=1;s+=.01)r=this.getPointOnCubicBezier(s,t,e,i[0],i[1],i[2],i[3],i[4],i[5]),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return n;case Jt.QUAD_TO:for(n=0,a=this.getPointOnQuadraticBezier(0,t,e,i[0],i[1],i[2],i[3]),s=.01;s<=1;s+=.01)r=this.getPointOnQuadraticBezier(s,t,e,i[0],i[1],i[2],i[3]),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return n;case Jt.ARC:{n=0;const t=i[4],e=i[5],A=i[4]+e;let o=Math.PI/180;if(Math.abs(t-A)<o&&(o=Math.abs(t-A)),a=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],t,0),e<0)for(s=t-o;s>A;s-=o)r=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],s,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;else for(s=t+o;s<A;s+=o)r=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],s,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return r=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],A,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),n}}return 0}getPointOnLine(t,e,A,i,n){let a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:A;const s=(n-A)/(i-e+J);let o=Math.sqrt(t*t/(1+s*s));i<e&&(o*=-1);let c=s*o,l=null;if(i===e)l={x:a,y:r+c};else if((r-A)/(a-e+J)===s)l={x:a+o,y:r+c};else{let g=0,h=0;const d=this.getLineLength(e,A,i,n);if(d<J)return null;let u=(a-e)*(i-e)+(r-A)*(n-A);u/=d*d,g=e+u*(i-e),h=A+u*(n-A);const B=this.getLineLength(a,r,g,h),w=Math.sqrt(t*t-B*B);o=Math.sqrt(w*w/(1+s*s)),i<e&&(o*=-1),c=s*o,l={x:g+o,y:h+c}}return l}getPointOnPath(t){const e=this.getPathLength();let A=0,i=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||A+e.pathLength+5e-5<t)){A+=e.pathLength;continue}const n=t-A;let a=0;switch(e.type){case Jt.LINE_TO:i=this.getPointOnLine(n,e.start.x,e.start.y,e.points[0],e.points[1],e.start.x,e.start.y);break;case Jt.ARC:{const t=e.points[4],A=e.points[5],r=e.points[4]+A;if(a=t+n/e.pathLength*A,A<0&&a<r||A>=0&&a>r)break;i=this.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],a,e.points[6]);break}case Jt.CURVE_TO:a=n/e.pathLength,a>1&&(a=1),i=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 Jt.QUAD_TO:a=n/e.pathLength,a>1&&(a=1),i=this.getPointOnQuadraticBezier(a,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3])}if(i)return i;break}return null}getLineLength(t,e,A,i){return Math.sqrt((A-t)*(A-t)+(i-e)*(i-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,A,i,n,a,r,s,o){return{x:s*V(t)+a*K(t)+i*W(t)+e*X(t),y:o*V(t)+r*K(t)+n*W(t)+A*X(t)}}getPointOnQuadraticBezier(t,e,A,i,n,a,r){return{x:a*q(t)+i*Z(t)+e*$(t),y:r*q(t)+n*Z(t)+A*$(t)}}getPointOnEllipticalArc(t,e,A,i,n,a){const r=Math.cos(a),s=Math.sin(a),o=A*Math.cos(n),c=i*Math.sin(n);return{x:t+(o*r-c*s),y:e+(o*s+c*r)}}buildEquidistantCache(t,e){const A=this.getPathLength(),i=e||.25,n=t||A/100;if(!this.equidistantCache||this.equidistantCache.step!==n||this.equidistantCache.precision!==i){this.equidistantCache={step:n,precision:i,points:[]};let t=0;for(let e=0;e<=A;e+=i){const A=this.getPointOnPath(e),a=this.getPointOnPath(e+i);A&&a&&(t+=this.getLineLength(A.x,A.y,a.x,a.y),t>=n&&(this.equidistantCache.points.push({x:A.x,y:A.y,distance:e}),t-=n))}}}getEquidistantPointOnPath(t,e,A){if(this.buildEquidistantCache(e,A),t<0||t-this.getPathLength()>5e-5)return null;const i=Math.round(t/this.getPathLength()*(this.equidistantCache.points.length-1));return this.equidistantCache.points[i]||null}constructor(t,e,A){super(t,e,A),le(this,"type","textPath"),le(this,"textWidth",0),le(this,"textHeight",0),le(this,"pathLength",-1),le(this,"glyphInfo",null),le(this,"text",void 0),le(this,"dataArray",void 0),le(this,"letterSpacingCache",[]),le(this,"equidistantCache",null),le(this,"measuresCache",new Map([["",0]]));const i=this.getHrefAttribute().getDefinition();this.text=this.getTextFromNode(),this.dataArray=this.parsePathData(i)}},image:class extends Rt{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=he.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),A=await e.text();this.image=A}catch(e){console.error(`Error while loading image "${t}":`,e)}this.loaded=!0}renderChildren(t){const{document:e,image:A,loaded:i}=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(i&&A&&r&&s){if(t.save(),t.translate(n,a),"string"==typeof A){const i=e.pith.forkString(t,A,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:0,offsetY:0,scaleWidth:r,scaleHeight:s}),{documentElement:n}=i.document;n&&(n.parent=this),i.resize(r,s,this.getAttribute("preserveAspectRatio").getString()),i.render()}else e.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:r,desiredWidth:A.width,height:s,desiredHeight:A.height}),this.loaded&&("complete"in A&&!A.complete||t.drawImage(A,0,0));t.restore()}}getBoundingBox(){const t=this.getAttribute("x").getPixels("x"),e=this.getAttribute("y").getPixels("y"),A=this.getStyle("width").getPixels("x"),i=this.getStyle("height").getPixels("y");return new Nt(t,e,t+A,e+i)}constructor(t,e,A){super(t,e,A),ge(this,"type","image"),ge(this,"loaded",!1),ge(this,"image",void 0);const i=this.getHrefAttribute().getString();if(!i)return;const n=i.endsWith(".svg")||/^\s*data:image\/svg\+xml/i.test(i);t.images.push(this),n?this.loadSvg(i):this.loadImage(i)}},g:qt,symbol:class extends Rt{render(t){}constructor(...t){var e,A,i;super(...t),i="symbol",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},style:we,use:class extends Rt{setContext(t){super.setContext(t);const e=this.getAttribute("x"),A=this.getAttribute("y");e.hasValue()&&t.translate(e.getPixels("x"),0),A.hasValue()&&t.translate(0,A.getPixels("y"))}path(t){const{element:e}=this;e&&e.path(t)}renderChildren(t){const{document:e,element:A}=this;if(A){let i=A;if("symbol"===A.type&&(i=new Vt(e),i.attributes.viewBox=new tt(e,"viewBox",A.getAttribute("viewBox").getString()),i.attributes.preserveAspectRatio=new tt(e,"preserveAspectRatio",A.getAttribute("preserveAspectRatio").getString()),i.attributes.overflow=new tt(e,"overflow",A.getAttribute("overflow").getString()),i.children=A.children,A.styles.opacity=new tt(e,"opacity",this.calculateOpacity())),"svg"===i.type){const t=this.getStyle("width",!1,!0),A=this.getStyle("height",!1,!0);t.hasValue()&&(i.attributes.width=new tt(e,"width",t.getString())),A.hasValue()&&(i.attributes.height=new tt(e,"height",A.getString()))}const n=i.parent;i.parent=this,i.render(t),i.parent=n}}getBoundingBox(t){const{element:e}=this;return e?e.getBoundingBox(t):null}elementTransform(){const{document:t,element:e}=this;return e?Dt.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:Ie,clipPath:class extends xt{apply(t){const{document:e}=this,A=Reflect.getPrototypeOf(t),{beginPath:i,closePath:n}=t;A&&(A.beginPath=xe,A.closePath=xe),Reflect.apply(i,t,[]),this.children.forEach((i=>{if(!("path"in i))return;let a="elementTransform"in i?i.elementTransform():null;a||(a=Dt.fromElement(e,i)),a&&a.apply(t),i.path(t),A&&(A.closePath=n),a&&a.unapply(t)})),Reflect.apply(n,t,[]),t.clip(),A&&(A.beginPath=i,A.closePath=n)}render(t){}constructor(...t){var e,A,i;super(...t),i="clipPath",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},filter:Se,feDropShadow:class extends xt{apply(t,e,A,i,n){}constructor(t,e,A){var i,n,a;super(t,e,A),a="feDropShadow",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.addStylesFromStyleDefinition()}},feMorphology:class extends xt{apply(t,e,A,i,n){}constructor(...t){var e,A,i;super(...t),i="feMorphology",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},feComposite:class extends xt{apply(t,e,A,i,n){}constructor(...t){var e,A,i;super(...t),i="feComposite",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},feColorMatrix:ye,feGaussianBlur:ve,title:class extends xt{constructor(...t){var e,A,i;super(...t),i="title",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},desc:class extends xt{constructor(...t){var e,A,i;super(...t),i="desc",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}};function be(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Pe{bindCreateImage(t,e){return"boolean"==typeof e?(A,i)=>t(A,"boolean"==typeof i?i: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(/^[^:]+:/,""),A=Pe.elementTypes[e];return A?new A(this,t):new Mt(this,t)}createTextNode(t){return new Tt(this,t)}setViewBox(t){this.screen.setViewBox({document:this,...t})}constructor(t,{rootEmSize:e=12,emSize:A=12,createCanvas:i=Pe.createCanvas,createImage:n=Pe.createImage,anonymousCrossOrigin:a}={}){be(this,"pith",void 0),be(this,"rootEmSize",void 0),be(this,"documentElement",void 0),be(this,"screen",void 0),be(this,"createCanvas",void 0),be(this,"createImage",void 0),be(this,"definitions",void 0),be(this,"styles",void 0),be(this,"stylesSpecificity",void 0),be(this,"images",void 0),be(this,"fonts",void 0),be(this,"emSizeStack",void 0),be(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=A,this.createCanvas=i,this.createImage=this.bindCreateImage(n,a),this.screen.wait((()=>this.isImagesLoaded())),this.screen.wait((()=>this.isFontsLoaded()))}}function Ne(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}be(Pe,"createCanvas",(function(t,e){const A=document.createElement("canvas");return A.width=t,A.height=e,A})),be(Pe,"createImage",(async function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const A=document.createElement("img");return e&&(A.crossOrigin="Anonymous"),new Promise(((e,i)=>{A.onload=()=>{e(A)},A.onerror=(t,e,A,n,a)=>{i(a)},A.src=t}))})),be(Pe,"elementTypes",Ye);class Re{static async from(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=new Bt(A),n=await i.parse(e);return new Re(t,n,A)}static fromString(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=new Bt(A).parseFromString(e);return new Re(t,i,A)}fork(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Re.from(t,e,{...this.options,...A})}forkString(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Re.fromString(t,e,{...this.options,...A})}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:A,options:i}=this;A.start(e,{enableRedraw:!0,...i,...t})}stop(){this.screen.stop()}resize(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,A=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.documentElement.resize(t,e,A)}constructor(t,e,A={}){Ne(this,"parser",void 0),Ne(this,"screen",void 0),Ne(this,"document",void 0),Ne(this,"documentElement",void 0),Ne(this,"options",void 0),this.parser=new Bt(A),this.screen=new gt(t,A),this.options=A;const i=new Pe(this,A),n=i.createDocumentElement(e);this.document=i,this.documentElement=n}}function He(t,e,A,i){Object.defineProperty(t,e,{get:A,set:i,enumerable:!0,configurable:!0})}var ke="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==v?v:{},Ue={};He(Ue,"CanvasCommand",(()=>Vi)),He(Ue,"UpdateWorkflowStateCommand",(()=>Ki)),He(Ue,"MoveCommand",(()=>Wi)),He(Ue,"RotateCommand",(()=>Xi)),He(Ue,"ResizeCommand",(()=>qi)),He(Ue,"GroupCommand",(()=>Zi)),He(Ue,"CreateLayoutCommand",(()=>$i)),He(Ue,"ClearLayoutCommand",(()=>_i)),He(Ue,"CreateElementCommand",(()=>tn)),He(Ue,"DeleteElementCommand",(()=>en)),He(Ue,"CloneElementCommand",(()=>An)),He(Ue,"FontColorCommand",(()=>nn)),He(Ue,"FontImageFillCommand",(()=>an)),He(Ue,"FontSizeCommand",(()=>rn)),He(Ue,"FontAlgorithmCommand",(()=>sn)),He(Ue,"FontSourceCommand",(()=>on)),He(Ue,"FontAlignmentCommand",(()=>cn)),He(Ue,"UpdateFramePattern",(()=>ln)),He(Ue,"TextChangeCommand",(()=>gn)),He(Ue,"IllustrationColorCommand",(()=>hn)),He(Ue,"IllustrationCacheCommand",(()=>dn)),He(Ue,"BringToFrontCommand",(()=>un)),He(Ue,"BringToBackCommand",(()=>Bn)),He(Ue,"BringForwardCommand",(()=>wn)),He(Ue,"SendBackwardsCommand",(()=>En)),He(Ue,"LayerCommand",(()=>pn)),He({},"generate",(()=>Ge));const Ge=()=>{const t=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()};var Te={};He(Te,"ElementNotFoundError",(()=>Oi)),He(Te,"findElement",(()=>Ji)),He(Te,"findLayoutForElement",(()=>Li)),He(Te,"updatedLayoutForElement",(()=>zi)),He(Te,"rehydrateSerializedLayout",(()=>ji));var Oe={};He(Oe,"CommandContext",(()=>ki)),He(Oe,"getSvgElement",(()=>Gi)),He(Oe,"elementFactory",(()=>Ui)),He(Oe,"sortElementsByLayersWithIndex",(()=>Ti)),He({},"SVGLayout",(()=>sA));var Je={};let Le;var ze;let je;var Ve;let Ke;var We;let Xe;var qe;let Ze;var $e;let _e;var tA;let eA;var AA;let iA;var nA;let aA;var rA;He(Je,"LayoutElementType",(()=>Le)),He(Je,"LayoutRenderingPurpose",(()=>je)),He(Je,"TextAlgorithm",(()=>Ke)),He(Je,"UnitOfMeasurement",(()=>Xe)),He(Je,"ScaleAxis",(()=>Ze)),He(Je,"MaterialEffectMode",(()=>_e)),He(Je,"AssetType",(()=>eA)),He(Je,"StepType",(()=>iA)),He(Je,"StepAspectType",(()=>aA)),(ze=Le||(Le={})).Frame="frame",ze.Image="image",ze.Illustration="illustration",ze.Textbox="textbox",(Ve=je||(je={})).ThreeD="ThreeD",Ve.FreeDesign="FreeDesign",Ve.Print="Print",(We=Ke||(Ke={})).Autosize="Autosize",We.Traditional="Traditional",(qe=Xe||(Xe={})).Pixel="px",qe.Millimeter="mm",qe.Centimeter="cm",($e=Ze||(Ze={}))[$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",(tA=_e||(_e={})).None="None",tA.RemoveWhenSelected="RemoveWhenSelected",tA.ApplyWhenSelected="ApplyWhenSelected",(AA=eA||(eA={})).Font="Font",AA.Frame="Frame",AA.Illustration="Illustration",AA.Image="Image",AA.Model="Model",AA.Material="Material",AA.Color="Color",AA.QuestionnaireCollateral="QuestionnaireCollateral",AA.RequestCollateral="RequestCollateral",AA.SignupCollateral="SignupCollateral",AA.Video="Video",AA.ColorProfile="ColorProfile",(nA=iA||(iA={})).Bulk="Bulk",nA.DigitalContent="DigitalContent",nA.Finish="Finish",nA.Frame="Frame",nA.Illustration="Illustration",nA.Introduction="Introduction",nA.Material="Material",nA.Model="Model",nA.Module="Module",nA.Picture="Picture",nA.Photo="Photo",nA.ProductOverlay="ProductOverlay",nA.Question="Question",nA.Shape="Shape",nA.SilentIllustration="SilentIllustration",nA.Text="Text",(rA=aA||(aA={})).Color="Color",rA.Colors="Colors",rA.Selection="Selection",rA.Selections="Selections",rA.Text="Text",rA.Upload="Upload";const sA=({backgroundColor:t,outlineColor:e,borderRadius:i,configuration:n,elements:a,height:r,maxHeight:s,maxWidth:o,outlineArea:c,position:l,preserveAspectRatio:g,viewBox:h,width:d})=>{const u=i||0,B=2*(c?.scale||1),w=h||{x:0,y:0,width:d,height:r},E=`${w.x} ${w.y} ${w.width} ${w.height}`,p=Ge(),m=n.purpose===je.FreeDesign&&(0,A.jsx)("defs",{children:(0,A.jsx)("clipPath",{id:"viewboxClip",children:(0,A.jsx)("rect",{width:w.width,height:w.height,rx:u})})}),C=n.colorProfiles?.map(((t,e)=>(0,A.jsx)("color-profile",{name:t.name,xlinkHref:t.key,children:" "},e))),f=Ti(a.map((t=>({...t,_renderingConfiguration:n,mask:c?`url(#viewmask-${p})`:void 0}))));return(0,A.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:E,children:[C,m,!!t&&(0,A.jsx)("rect",{id:"layout-background",width:w.width,height:w.height,fill:t,rx:u}),(0,A.jsx)("g",{id:"element-group",clipPath:n.purpose===je.FreeDesign?"url(#viewboxClip)":void 0,children:f.map((t=>Ui(t))).filter((t=>!!t))}),c&&(0,A.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"none",stroke:c.hidden?"none":e||"#aaaaaa",strokeWidth:B/2,strokeDasharray:`${2*B} ${B}`}),c&&(0,A.jsxs)("mask",{id:`viewmask-${p}`,children:[(0,A.jsx)("rect",{x:w.x,y:w.y,width:w.width,height:w.height,fill:"black"}),(0,A.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"white"})]})]})};He({},"Image",(()=>xA));var oA={};He(oA,"getAxisAlignedBoundingBox",(()=>cA)),He(oA,"degreesToRadians",(()=>gA)),He(oA,"findAngle",(()=>lA)),He(oA,"radiansToDegrees",(()=>hA)),He(oA,"isCloseToValue",(()=>dA)),He(oA,"getTrueCoordinates",(()=>uA)),He(oA,"getPointOfRotation",(()=>BA)),He(oA,"getNWPoint",(()=>wA)),He(oA,"getNEPoint",(()=>EA)),He(oA,"getSWPoint",(()=>pA)),He(oA,"getSEPoint",(()=>mA)),He(oA,"turnRightClockwise",(()=>CA)),He(oA,"currentDirection",(()=>fA)),He(oA,"getElementVertices",(()=>QA)),He(oA,"rotateAroundPoint",(()=>yA)),He(oA,"mmPerPixel",(()=>DA)),He(oA,"cmPerPixel",(()=>IA));const cA=(t,e,A,i,n)=>{const a=gA(n),r=A/2,s=i/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,B=r*l+h*g,w=r*l+s*g,E=Math.max(Math.abs(d),Math.abs(u)),p=Math.max(Math.abs(B),Math.abs(w));return{minX:o-E,maxX:o+E,minY:c-p,maxY:c+p}},lA=(t,e,A)=>{const i=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),n=Math.sqrt(Math.pow(e.x-A.x,2)+Math.pow(e.y-A.y,2)),a=Math.sqrt(Math.pow(A.x-t.x,2)+Math.pow(A.y-t.y,2));return Math.acos((n*n+i*i-a*a)/(2*n*i))*(180/Math.PI)},gA=t=>t*(Math.PI/180),hA=t=>t*(180/Math.PI),dA=(t,e,A)=>Math.abs(t-e)<A,uA=(t,e,A)=>{const i=Math.sin(gA(A)),n=Math.cos(gA(A));return{x:(t.x-e.x)*n-(t.y-e.y)*i+e.x,y:(t.x-e.x)*i+(t.y-e.y)*n+e.y}},BA=(t,e)=>({x:(t.x+e.x)/2,y:(t.y+e.y)/2}),wA=(t,e,A,i)=>({x:t.x+e?.x*A,y:t.y+e?.y*i}),EA=(t,e,A,i)=>({x:t.x+(e?.x+e?.width)*A,y:t.y+e?.y*i}),pA=(t,e,A,i)=>({x:t.x+e?.x*A,y:t.y+(e?.y+e?.height)*i}),mA=(t,e,A,i)=>({x:t.x+(e?.x+e?.width)*A,y:t.y+(e?.y+e?.height)*i}),CA=t=>{switch(t){case Ze.North:return Ze.East;case Ze.East:return Ze.South;case Ze.South:return Ze.West;case Ze.West:return Ze.North;case Ze.Northwest:return Ze.Northeast;case Ze.Northeast:return Ze.Southeast;case Ze.Southeast:return Ze.Southwest;case Ze.Southwest:return Ze.Northwest}},fA=(t,e)=>e>45&&e<=135?CA(t):e>135&&e<=225?CA(CA(t)):e>225&&e<=315?CA(CA(CA(t))):t,QA=(t,e={x:0,y:0},A={x:1,y:1})=>{const i=gA(t.rotation),n={x:e.x+t.x*A.x,y:e.x+t.y*A.y},a={x:t.x+t.width,y:t.y},r={x:e.x+(t.x+t.width)*A.x,y:e.y+(t.height+t.y)*A.y},s={x:e.x+t.x*A.x,y:e.y+(t.height+t.y)*A.y},o={x:(s.x+r.x)/2,y:s.y-t.height*A.y/2};return{a:yA(n,o,i),b:yA(a,o,i),c:yA(r,o,i),d:yA(s,o,i),center:o}},yA=(t,e,A)=>{const i=Math.sin(A),n=Math.cos(A);return{x:(t.x-e.x)*n-(t.y-e.y)*i+e.x,y:(t.x-e.x)*i+(t.y-e.y)*n+e.y}},DA=.352778,IA=.035277,xA=t=>{const e=t.rotation||0,i=gA(e),n=Math.cos(i),a=-Math.sin(i);return(0,A.jsx)("g",{mask:t.stepName||t.productOverlay?void 0:t.mask,children:(0,A.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,A.jsx)("image",{xlinkHref:t.src,preserveAspectRatio:t.preserveAspectRatio,width:t.width,height:t.height})})})};He({},"Frame",(()=>MA));const MA=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,A.jsx)(F(i).Fragment,{});const o=!!t.focalBlur&&!!t.pattern,c=t.rotation||0,l=gA(c),g=Math.cos(l),h=-Math.sin(l);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("defs",{children:(i=>{const o=t.pattern?.x||0,c=t.pattern?.y||0,l=t.pattern?t.pattern.width*t.pattern.scaleX+Math.abs(o):256,g=t.pattern?t.pattern.height*t.pattern.scaleY+Math.abs(c):256,h=t.pattern?t.pattern.width*t.pattern.scaleX:256,d=t.pattern?t.pattern.height*t.pattern.scaleY:256;return(0,A.jsxs)("g",{mask:t.stepName?void 0:t.mask,children:[(0,A.jsx)("pattern",{patternUnits:t.pattern?void 0:"userSpaceOnUse",x:0,y:0,width:t.pattern?1:l,height:t.pattern?1:g,"data-frame-width":t.pattern?l:void 0,"data-frame-height":t.pattern?g:void 0,id:e,children:(0,A.jsx)("image",{preserveAspectRatio:"none",x:o,y:c,width:h,height:d,xlinkHref:s()})}),i?(0,A.jsx)(vA,{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,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.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,A.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,A.jsx)("path",{mask:`url(#${r})`,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}):void 0]})})]})},vA=t=>{const{path:e,width:i,height:n,focalBlurStrength:a,focalBlurRadius:r,blurFilterId:s,focalMaskId:o,blurEdgeClipId:c}=t;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("filter",{id:s,children:(0,A.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,A.jsx)("mask",{id:o,children:(0,A.jsx)("circle",{cx:i/2,cy:n/2,r:r||0,fill:"white",filter:`url(#${s})`})}),(0,A.jsx)("mask",{id:c,children:(0,A.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};He({},"Textbox",(()=>Mi));var FA={};He(FA,"fontSizeStep",(()=>hi)),He(FA,"textWidth",(()=>di)),He(FA,"charWidth",(()=>ui)),He(FA,"lineWidth",(()=>Bi)),He(FA,"applyTextTransformations",(()=>Ei)),He(FA,"zip",(()=>pi)),He(FA,"getTextAlignment",(()=>mi)),He(FA,"getAnchor",(()=>Ci)),He(FA,"recomputeTextOnElement",(()=>fi)),He(FA,"defaultLineHeightFactor",(()=>Qi));var SA={};He(SA,"refitTextbox",(()=>li)),He(SA,"recalculateTextboxRegion",(()=>gi));var YA={};He(YA,"FontMetrics",(()=>ti)),He(YA,"loadFontFromExternalUrl",(()=>Ai)),He(YA,"loadFontFromDataUrl",(()=>ii)),He(YA,"getFontMetrics",(()=>ni));var bA={};He(bA,"registerJSDOM",(()=>RA)),He(bA,"createElement",(()=>GA)),He(bA,"createElementNS",(()=>TA)),He(bA,"domParser",(()=>OA)),He(bA,"fetchAsArrayBuffer",(()=>JA)),He(bA,"fetchAsString",(()=>LA)),He(bA,"loadFontFaceSet",(()=>zA)),He(bA,"xmlSerializer",(()=>jA)),He(bA,"toBase64",(()=>VA)),He(bA,"dataUrlFromExternalUrl",(()=>KA)),He(bA,"arrayBufferToDataUrl",(()=>WA)),He(bA,"arrayBufferToBuffer",(()=>qA)),He(bA,"dataUrlToArrayBuffer",(()=>XA));var PA=a.Buffer;let NA;function RA(t){NA=t}function HA(){if(!NA)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new NA}if(void 0===ke.TextEncoder){const{TextEncoder:t}=c;ke.TextEncoder=t}if(void 0===ke.TextDecoder){const{TextDecoder:t}=c;ke.TextDecoder=t}const kA=new(F(s).Agent)({rejectUnauthorized:!0}),UA=t=>t.every((t=>"undefined"!==t)),GA=t=>UA([typeof document])?document.createElement(t):HA().window.document.createElement(t),TA=(t,e)=>{if(UA([typeof document]))return document.createElementNS(t,e);const A=HA().window.document.createElement(e);return A.setAttribute("xmlns",t),A},OA=()=>UA([typeof DOMParser])?new DOMParser:new(HA().window.DOMParser),JA=t=>{if(UA([typeof fetch]))return new Promise(((e,A)=>{fetch(t).then((t=>{e(t.arrayBuffer())})).catch((t=>{A(t)}))}));{const e=t.replace("localhost","localstack");return new Promise(((t,A)=>{F(r).get(e,{responseType:"arraybuffer",httpsAgent:kA}).then((e=>{t(e.data)})).catch((t=>{A(t)}))}))}},LA=t=>{if(UA([typeof fetch]))return new Promise(((e,A)=>{fetch(t).then((t=>{e(t.text())})).catch(A)}));{const e=t.replace("localhost","localstack");return new Promise(((t,A)=>{F(r).get(e,{responseType:"text",httpsAgent:kA}).then((e=>{t(e.data)})).catch(A)}))}},zA=async(t,e)=>{if(UA([typeof FontFace])){const A=t.names.fullName.en,i=new FontFace(A,`url(${e})`);return document.fonts.add(i),i.load()}},jA=()=>UA([typeof XMLSerializer])?new XMLSerializer:new(HA().window.XMLSerializer),VA=t=>UA([typeof btoa])?btoa(t):PA.from(t).toString("base64"),KA=async t=>{if(UA([typeof fetch,typeof Blob,typeof FileReader])){const e=await fetch(t),A=await e.blob();return await $A(A)}const e=(await F(r).get(t,{responseType:"arraybuffer"})).data;return WA(e)},WA=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,${qA(t).toString("base64")}`},XA=t=>{const e=t.replace(/\r?\n/g,""),A=e.indexOf(",");if(-1===A||A<=4)throw new TypeError("malformed data: URI");const i=e.substring(5,A).split(";");let n=!1;for(let t=1;t<i.length;t++)"base64"===i[t]&&(n=!0);const a=n?"base64":"ascii",r=unescape(e.substring(A+1)),s=PA.from(r,a);return ZA(s)},qA=t=>PA.from(t),ZA=t=>{const e=new ArrayBuffer(t.byteLength),A=new Uint8Array(e);for(let e=0;e<t.length;++e)A[e]=t[e];return e},$A=t=>new Promise(((e,A)=>{const i=new FileReader;i.onload=function(t){const i=t.target;i&&i.result?e(i.result.toString()):A()},i.readAsDataURL(t)})),_A=new Map;class ti{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 A=this.font.stringToGlyphs(t);return this.glyphsFromText.set(t,A),A}getApproximateHeight(){return this.height}getExactHeight(t){const e=this.font.stringToGlyphs(t);let A=0,i=0;return e.forEach((t=>{const e=t.getMetrics();A=Math.max(A,e.yMax),i=Math.min(i,e.yMin)})),A-i}getKerningValue(t,e){let A=this.kerningValues.get(t.name);A||(A=new Map,this.kerningValues.set(t.name,A));let i=A.get(e.name);return i||(i=this.font.getKerningValue(t,e),A.set(e.name,i)),i}calculateApproximateHeight(){const t=this.font.stringToGlyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");let e=0,A=0;return t.forEach((t=>{const i=t.getMetrics();e=Math.max(e,i.yMax),A=Math.min(A,i.yMin)})),e-A}}const ei=t=>"data:"===t.substring(0,5).toLowerCase().trim(),Ai=async t=>{const e=ei(t)?ii(t):ii(await KA(t));return ai(e,{assetUrl:ei(t)?t:await KA(t),name:e.names.fullName.en}),await zA(e,t),e},ii=t=>{const e=XA(t),A=F(n).parse(e);return ai(A,{assetUrl:t,name:A.names.fullName.en}),A},ni=t=>{const e=_A.get(t.name);if(e)return e;throw new Error("Font metrics unavailable for font")},ai=(t,e)=>{const A=new ti(t);return _A.set(e.name,A),A},ri=(t,e,A,i)=>Math.max(ui(t.join("\n"),A,i),e),si=(t,e,A,i,n,a)=>{const r=(a||Qi)*n.getApproximateHeight(),s=e.split("\n");try{const e=s.flatMap((e=>oi(e,t.width,i,n))),a=e.flatMap((t=>t.lines));return{lines:a,requiredHeight:e.flatMap((t=>t.lines)).length*(i*r),fontSize:A,requiredWidth:ri(a,t.width,i,n)}}catch(a){const s=e.split("");return{lines:s,requiredHeight:s.length*(i*r),fontSize:A,requiredWidth:ri(s,t.width,i,n)}}},oi=(t,e,A,i)=>{const n=di(t,A,i);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=oi(t.slice(0,n),e,A,i),r=oi(t.slice(n),e,A,i);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(di(t,A,i)>e){const n=oi(t,e,A,i);r.push(...n.lines),s=Math.max(s,n.width),o++}else{const n=[t];s=Math.max(s,di(t,A,i));let c=o+1,l=!0;for(;c<a.length&&l;){const t=a[c],r=di(`${n.join(" ")} ${t}`,A,i);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}},ci=(t,e,A,i,n,a)=>{const r=(a??Qi)*e.getApproximateHeight(),s=1/A.unitsPerEm,o=i/Bi(t,s,e),c=n/(t.length*r*s);return Math.min(c,o)},li=(t,e,A,i)=>{const n=ni(e.fontData),a=n.getFont(),r=e.fontSize/a.unitsPerEm;if(!A)return si(e,t,e.fontSize,r,n,i);let s;if(s=e.text?e.text.split("\n"):e.input?.split("\n")??[""],A.input===t&&e.width===A.width&&e.height===A.height&&e.lineHeight===A.lineHeight)return{lines:s,requiredHeight:e.height,requiredWidth:ri(s,e.width,r,n),fontSize:e.fontSize};const o=e.width!==A.width!=(e.height!==A.height);return e.lineHeight!==A.lineHeight||o||A.input!==t?si(e,t,e.fontSize,r,n,i):{lines:s,requiredHeight:e.height,requiredWidth:ri(s,e.width,r,n),fontSize:ci(s,n,a,e.width,e.height,i)}},gi=(t,e,A,i,n)=>{const a=ni(e).getFont();let r={...t},s={...t},o=Bi(i,A/a.unitsPerEm,ni(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,i&&pi(i,i).every((([t,e])=>t===e))&&(r=s)),r},hi=1,di=(t,e,A)=>{let i=0;const n=A.getGlyphs(t);return n.forEach(((t,e)=>{if(t.advanceWidth&&(i+=t.advanceWidth),e<n.length-1){const a=A.getKerningValue(t,n[e+1]);i+=a}})),i*=e,i},ui=(t,e,A)=>{let i=0;const n=A.getGlyphs(t);return n.forEach(((t,e)=>{if(t.advanceWidth&&(i=Math.max(i,t.advanceWidth)),e<n.length-1){const a=A.getKerningValue(t,n[e+1]);i=Math.max(i,a)}})),i*=e,i},Bi=(t,e,A)=>{let i=0;return t.forEach((t=>{i=Math.max(i,di(t,e,A))})),i},wi={stripControlCharacters:!0,vertical:!1,uppercase:!1},Ei=(t,e=wi)=>{const A={...wi,...e};let i=t||"";return A.stripControlCharacters&&(i=i.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),A.uppercase&&(i=i.toUpperCase()),A.vertical&&(i=i.split("").join("\n")),i},pi=(t,e)=>t.map(((t,A)=>[t,e[A]])),mi=(t="center",e=!1)=>e?"center":t,Ci=t=>"left"===t?"start":"right"===t?"end":"middle",fi=(t,e,A)=>t.fontData?{...t,...(()=>{if(t.algorithm===Ke.Traditional){const i=li(e,t,A,t.lineHeight);return{text:i.lines.join("\n"),height:i.requiredHeight,width:i.requiredWidth,fontSize:i.fontSize,input:e}}return{text:e}})()}:t,Qi=1.1;var yi={};He(yi,"colorDefinitionPrintValue",(()=>Di)),He(yi,"spotColorDefinitionString",(()=>Ii)),He(yi,"svgColorValueToDefinition",(()=>xi));const Di=t=>{const e=Ii(t.spotColor);return e?`${t.browserValue} ${e}`:t.browserValue},Ii=t=>{if(!t)return"";if(t.profileName.includes("/")&&t.profileName.includes(".icc")){const e=t.profileName.replace(/\s/g,"-"),A=e.lastIndexOf("/");return`icc-named-color(${e.slice(A+1).slice(0,-4)}, ${t.namedColor})`}return`icc-named-color(${t.profileName}, ${t.namedColor})`},xi=t=>{const e=t.split(/[ ](?=[^)]*?(?:\(|$))/);if(0===e.length)return{browserValue:"#000000"};if(1===e.length)return{browserValue:e[0]};const A=e[1].match(/\(([^)]+)\)/gm);if(!A)throw new Error("Unhandled state of color value in SVG");const i=A[0].replace(/[() ]/g,"").split(",");return{browserValue:e[0],spotColor:{profileName:i[0],namedColor:i[1]}}},Mi=t=>{const e=(t.rotation||0)*Math.PI/180,i=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,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("defs",{children:[t.textFillImage&&(0,A.jsx)("pattern",{id:r,patternUnits:"userSpaceOnUse",width:t.textFillImage.scale*t.textFillImage.width,height:t.textFillImage.scale*t.textFillImage.height,x:t.textFillImage.width/2,y:t.textFillImage.height/2,children:(0,A.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,A.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,A.jsx)("path",{id:a,d:t.paths[0]}):void 0]}),t._renderingConfiguration?.debug?(0,A.jsx)("rect",{stroke:"blue",fill:"none",x:t.x,y:t.y,width:t.width,height:t.height}):void 0,(0,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsx)("g",{transform:`matrix(${i}, ${-n}, ${n}, ${i}, ${s}, ${o})`,children:(0,A.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} ${Ii(t.fillSpotColorDefinition)}`:t.fill,style:{whiteSpace:"pre",userSelect:"none"},children:t.curved?(0,A.jsx)(Fi,{text:t.text||"",curvedPathId:a,align:t.align}):c.map(((e,i)=>(0,A.jsx)(vi,{align:t.vertical?"center":t.align,fontSize:t.fontSize,thisLineIdx:i,amountLines:c.length,text:e,textboxHeight:t.height,textboxWidth:t.width,lineHeight:t.lineHeight,vertical:t.vertical,verticalAlign:t.verticalAlign},i)))})})})]}):null},vi=t=>(0,A.jsx)("tspan",{textAnchor:Ci(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:Qi),A=t.textboxHeight/2;if("top"===t.verticalAlign)return-A+3*t.fontSize/4+t.thisLineIdx*e;if("bottom"===t.verticalAlign){const i=t.amountLines-1-t.thisLineIdx;return A-t.fontSize/4-i*e}const i=(t.amountLines-1)/2;return(t.thisLineIdx-i)*e+t.fontSize/4})()}px`,children:t.text}),Fi=t=>{const e=`#${t.curvedPathId}`;return(0,A.jsx)("textPath",{startOffset:"left"===t.align?"0%":"right"===t.align?"100%":"50%",textAnchor:Ci(t.align),href:e,xlinkHref:e,children:t.text})};He({},"Illustration",(()=>Hi));var Si={};He(Si,"traverse",(()=>bi)),He(Si,"sanitizeSvgTree",(()=>Pi)),He(Si,"modifySVGWithElementProperties",(()=>Ni)),He(Si,"generateSVGWithUnknownColors",(()=>Ri));const Yi=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],bi=(t,e)=>{e(t),t.children.length>0&&Array.from(t.children).forEach((t=>bi(t,e)))},Pi=(t,e=!1)=>{!e&&t.setAttribute("preserveAspectRatio","none");const A=[];bi(t,(t=>{if("script"!==t.tagName)if("style"!==t.tagName);else try{(0,l.parse)(t.innerHTML).stylesheet?.rules.forEach((t=>{A.push(t)})),t.remove()}catch(t){console.error(t)}else t.remove()})),bi(t,(t=>{A.forEach((e=>{e.selectors?.forEach((A=>{((t,e)=>{try{return t.matches(e)}catch(A){return t.classList.contains(e.substring(1))}})(t,A)&&e.declarations?.forEach((e=>{e.property&&e.value&&t.setAttribute(e.property,e.value)}))}))}))}))},Ni=(t,e,A,i,n)=>{const a=(t=>OA().parseFromString(t,"image/svg+xml").firstElementChild)(t);if(!a)throw new Error("Failed to read SVG.");return((t,e,A)=>{t.setAttribute("height",`${A}px`),t.setAttribute("width",`${e}px`)})(a,e,A),((t,e,A)=>{bi(t,(t=>{const i=t.attributes.getNamedItem("fill");i&&"none"!==i.value&&t.classList.forEach((i=>{if(i.startsWith("spiff-fill")){const n=e[i];n&&t.setAttribute("fill",A?Di(n):n.browserValue)}}));const n=t.attributes.getNamedItem("stroke");n&&"none"!==n.value&&t.classList.forEach((i=>{if(i.startsWith("spiff-stroke")){const n=e[i];n&&t.setAttribute("stroke",A?Di(n):n.browserValue)}}))}))})(a,i,n),(t=>jA().serializeToString(t))(a)},Ri=async t=>{const e=t.match(/<svg.*?<\/svg>/s)||[],A=e?.length>0?e[0]:"",i=OA().parseFromString(A,"image/svg+xml").firstElementChild;if(!i)throw new Error("Failed to read SVG.");Pi(i);const n={};bi(i,(t=>{Yi.includes(t.tagName)&&!t.attributes.getNamedItem("fill")&&t.setAttribute("fill","black");const e=t.attributes.getNamedItem("fill");if(e&&"none"!==e.value){const A=xi(e.value),i=`spiff-fill-${A.browserValue.replace(/\W/g,"")}`;t.setAttribute("fill",A.browserValue),t.classList.add(i),n[i]=A}const A=t.attributes.getNamedItem("stroke");if(A&&"none"!==A.value){const e=xi(A.value),i=`spiff-stroke-${e.browserValue.replace(/\W/g,"")}`;t.classList.add(i),t.setAttribute("stroke",e.browserValue),n[i]=e}}));const a=jA().serializeToString(i);return{colors:n,svg:a}},Hi=t=>{if(t.cachedObjectURL&&!t._renderingConfiguration?.omitCachedFields)return(0,A.jsx)(xA,{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,i=gA(e),n=Math.cos(i),a=-Math.sin(i),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,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsx)("g",{transform:r,dangerouslySetInnerHTML:{__html:Ni(t.svg,t.width,t.height,t.colors,t._renderingConfiguration?.spotColors)}})})};class ki{constructor(){this.id=Ge(),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 A=this.prevCommands.filter((e=>e.sequenceId===t)).pop();A&&(this.prevCommands=this.prevCommands.filter((e=>e.sequenceId!==t)),A?.overrideOldState(e),this.prevCommands.push(A))}getLayoutById(t){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const e=this.state.transaction?.layouts?.[t],A=this.state.variation?.layouts?.[t],i=e?.layout||A?.layout;if(!i)throw new Error(`No layout: ${t}`);const n=[...e?.elements||[],...A?.elements||[]];return this.getLayoutDataWithState(i,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:A=>Gi(t,e,A)}}initialize(t,e){if(e)return void(this.state={transaction:e});let A={serializableWorkflow:{steps:[]},layouts:{}};t.forEach((t=>{A=new $i(t).apply(A)})),this.runStateCallbacks(),this.state={transaction:A}}commandReducer(t,e){if(e.varying){const A={layouts:{},serializableWorkflow:{steps:[]},...t.variation};return{...t,variation:e.apply(A)}}{const A=t.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...t,transaction:e.apply(A)}}}}const Ui=t=>"image"===t.type?(0,A.jsx)(xA,{...t},t.id):"frame"===t.type?(0,A.jsx)(MA,{...t},t.id):"illustration"===t.type?(0,A.jsx)(Hi,{...t},t.id):"textbox"===t.type?(0,A.jsx)(Mi,{...t},t.id):null,Gi=(t,e,i)=>{const n=i.renderingConfiguration,a=n?.removeExcludedElements?e.filter((t=>!t.excludeFromExport)):e;return(0,A.jsx)(sA,{preserveAspectRatio:void 0,elements:a,backgroundColor:t.transparentBackground?void 0:"white",width:i.width||t.width,height:i.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:i.outlineArea,maxHeight:i.maxHeight,maxWidth:i.maxWidth,position:i.position,borderRadius:i.borderRadius,outlineColor:i.outlineColor})};function Ti(t){return t.sort(((t,e)=>{const A=t.layer||0,i=e.layer||0;if(A<i)return-1;if(A>i)return 1;const n=t.layerIndex||0,a=e.layerIndex||0;return n<a?-1:n>a?1:0}))}class Oi extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,Oi.prototype)}}const Ji=(t,e)=>Li(t,e).elements.find((e=>e.id===t)),Li=(t,e)=>{const A=Object.values(e).find((e=>e.elements.some((e=>e.id===t))));if(!A)throw new Oi;return A},zi=(t,e)=>{const A=Ti([...e.elements.filter((e=>e.id!==t.id)),t]);return{layout:e.layout,elements:A,modificationID:Ge()}},ji=async(t,e)=>{const A=[...Object.keys(t.layouts),...Object.keys(e?.layouts||{})],i=[...new Set(A)];for(let A=0;A<i.length;A++){const n=i[A],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 LA(e.src),A=await Ri(t);e.svg=Ni(A.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 Vi{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(t){this.oldState=t}}class Ki extends Vi{constructor(t){super(),this.serializableWorkflow=t}apply(t){return this.oldState=t,{...t,serializableWorkflow:this.serializableWorkflow}}}class Wi extends Vi{constructor(t,e,A){super(),this.id=t,this.x=e,this.y=A}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,x:this.x,y:this.y},i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class Xi extends Vi{constructor(t,e){super(),this.id=t,this.angle=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,rotation:this.angle},i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class qi extends Vi{constructor(t,e,A){super(),this.id=t,this.width=Math.abs(e),this.height=Math.abs(A)}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;let A={...e,width:this.width,height:this.height};if("frame"===e.type){const t=A;t.scaleX=t.scaleX*this.width/e.width,t.scaleY=t.scaleY*this.height/e.height}else if("textbox"===e.type){const t=A,i=(t.algorithm&&t.algorithm!==Ke.Autosize?t.input:t.text)??"";A=fi(t,i,e)}const i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class Zi extends Vi{constructor(t){super(),this.commands=t}apply(t){return this.oldState=t,this.commands.reduce(((t,e)=>e.apply(t)),t)}}class $i extends Vi{constructor(t){super(),this.layout=t}apply(t){return this.oldState=t,{...t,layouts:{...t.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:Ge()}}}}}class _i extends Vi{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:Ge()}})),A={};return e.forEach((t=>{A[t.layout.id]=t})),{...t,layouts:A}}}class tn extends Vi{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 A=[...e,this.element];return void 0===this.element.layerIndex&&(this.element.layerIndex=this.assignIndex(this.element,A)),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:A,modificationID:Ge()}}}}const A=e[e.length-1],i=A.productOverlay?A:null;let n;if(i&&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 i&&n.push(i),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:n,modificationID:Ge()}}}}assignIndex(t,e){if(0===e.length)return 0;const A=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!==A?A+1:0}}class en extends Vi{constructor(t){super(),this.id=t}apply(t){this.oldState=t;let e=!1;const A=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:Ge()})));e||console.log(`Failed to delete element ${this.id}`);const i={};return A.forEach((t=>{i[t.layout.id]=t})),{...t,layouts:i}}}class An extends Vi{constructor(t,A){super(),this.el=F(e)(t),this.layout=A,this.el.id=Ge(),this.el.x+=5,this.el.y+=5}apply(t){return this.oldState=t,new tn(this.el,this.layout).apply(t)}}class nn extends Vi{constructor(t,e,A){super(),this.id=t,this.color=e,this.textFillSpotColor=A}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor,textFillImage:void 0},i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class an extends Vi{constructor(t,e){super(),this.id=t,this.imageFill=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,textFillImage:this.imageFill},i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class rn extends Vi{constructor(t,e){super(),this.id=t,this.size=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,fontSize:this.size},i=Li(e.id,Object.values(t.layouts)),n=(e.algorithm&&e.algorithm!==Ke.Autosize?e.input:e.text)??"",a=zi(fi(A,n),i);return{...t,layouts:{...t.layouts,[i.layout.id]:a}}}}class sn extends Vi{constructor(t,e){super(),this.id=t,this.algorithm=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,algorithm:this.algorithm},i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class on extends Vi{constructor(t,e){super(),this.id=t,this.fontData=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,fontData:this.fontData},i=Li(e.id,Object.values(t.layouts)),n=(e.algorithm&&e.algorithm!==Ke.Autosize?e.input:e.text)??"",a=zi(fi(A,n),i);return{...t,layouts:{...t.layouts,[i.layout.id]:a}}}}class cn extends Vi{constructor(t,e){super(),this.id=t,this.align=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,align:this.align},i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class ln extends Vi{constructor(t,e,A){super(),this.id=t,this.imageData=e,this.offsets=A}apply(t){this.oldState=t;const e=Li(this.id,Object.values(t.layouts)),A=e.elements.findIndex((t=>t.id===this.id)),i=e.elements[A].pattern,n=[...e.elements];n.splice(A,1,{...e.elements[A],pattern:{...i,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:Ge()};return{...t,layouts:{...t.layouts,[e.layout.id]:a}}}}class gn extends Vi{constructor(t,e){super(),this.id=t,this.text=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A=Li(e.id,Object.values(t.layouts)),i=zi(fi(e,this.text,e),A);return{...t,layouts:{...t.layouts,[A.layout.id]:i}}}}class hn extends Vi{constructor(t,e,A){super(),this.id=t,this.className=e,this.fill=A}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A=e.colors||{},i=A[this.className];A[this.className]={browserValue:this.fill,spotColor:i?.spotColor};const n={...e,colors:A},a=Li(e.id,Object.values(t.layouts)),r=zi(n,a);return{...t,layouts:{...t.layouts,[a.layout.id]:r}}}}class dn extends Vi{constructor(t,e,A){super(),this.id=t,this.svgBody=e,this.objectURL=A}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,svg:this.svgBody,cachedObjectURL:this.objectURL},i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class un extends Vi{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Ji(this.id,Object.values(t.layouts)).id)throw new Oi;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 A=e.elements.findIndex((t=>t.id===this.id));e.elements.push(e.elements.splice(A,1)[0]);const i=[...e.elements];return i.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:i,modificationID:Ge()}}}}}class Bn extends Vi{constructor(t){super(),this.id=t}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!A)throw new Error("Layout missing from state!");const i=A.elements.findIndex((t=>t.id===this.id));A.elements.splice(i,1),A.elements.unshift(e);const n=[...A.elements],a=n.splice(i,1)[0];return n.splice(i,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[A.layout.id]:{...t.layouts[A.layout.id],elements:n,modificationID:Ge()}}}}}class wn extends Vi{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Ji(this.id,Object.values(t.layouts)).id)throw new Oi;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 A=e.elements.findIndex((t=>t.id===this.id)),i=A+1,n=[...e.elements],a=n.splice(A,1)[0];return n.splice(i,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:n,modificationID:Ge()}}}}}class En extends Vi{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Ji(this.id,Object.values(t.layouts)).id)throw new Oi;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 A=e.elements.findIndex((t=>t.id===this.id)),i=A-1,n=[...e.elements],a=n.splice(A,1)[0];return n.splice(i,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:n,modificationID:Ge()}}}}}class pn extends Vi{constructor(t,e){super(),this.id=t,this.value=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!A)throw new Error("Layout missing from state!");return{...t,layouts:{...t.layouts,[A.layout.id]:zi({...e,layer:this.value},A)}}}}var mn={};He(mn,"patternImageDataCache",(()=>xn)),He(mn,"frameDataCache",(()=>Mn)),He(mn,"generateFrameSVG",(()=>vn)),He(mn,"generateDefaultRectangleFrameSvg",(()=>Fn)),He(mn,"getVariant",(()=>Sn)),He(mn,"getFrameData",(()=>Yn)),He(mn,"calculateOffsets",(()=>bn)),He(mn,"getPatternImageData",(()=>Pn)),He(mn,"GetSVGDimensions",(()=>Nn)),He(mn,"svgStringDimensions",(()=>Rn));var Cn={};He(Cn,"getExifOrientation",(()=>Qn)),He(Cn,"canvasDims",(()=>yn)),He(Cn,"getAttributesFromArrayBuffer",(()=>Dn));let fn=null;const Qn=t=>new Promise((e=>{const A=qA(t);(0,o.fromBuffer)(t).then((t=>{const i=t?.mime;if("image/jpeg"!==i)return e(1);(new(0,h.ExifImage)).loadImage(A,((t,A)=>e(t?1:A.image.Orientation||1)))}))})),yn=t=>{const e=8192,A=t.naturalWidth/t.naturalHeight;return t.naturalHeight<=e&&t.naturalWidth<=e?[t.naturalWidth,t.naturalHeight]:t.naturalHeight>t.naturalWidth?[A*e,e]:[e,e/A]},Dn=async t=>{const e=await(async t=>{const e=await WA(t),A=await(0,g.loadImage)(e),[i,n]=yn(A),a=await(async()=>{if(null!==fn)return!fn;const t=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return fn=2===t.width&&3===t.height,!fn})();if(!a){const t=(0,g.createCanvas)(i,n);return t.getContext("2d").drawImage(A,0,0,i,n),t}const r=await Qn(t),[s,o]=r>4?[n,i]:[i,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(A,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",(()=>In));const In=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))}},xn=new Map,Mn=new Map,vn=async(t,e)=>{if(!e){if(!t)throw new Error("No region or src supplied. Cannot construct frame!");return Fn(t)}return LA(e)},Fn=t=>{const e=t.width,A=e/t.height,i=Math.max(e,512),n=i/A;return`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${i} ${n}'>\n <path id="target-path" d='M0 0 h ${i} v ${n} h ${-i} Z' />\n </svg>\n `},Sn=(t,e)=>{if(!e)return;const A=e.variants?.find((e=>e.id===t.frameVariantId))||In(e);if(!A)throw new Error(`No variant with ID: ${t.frameVariantId}`);if(!A.asset)throw new Error(`No asset for variant with ID: ${t.frameVariantId}`);return A},Yn=async t=>{const e=OA().parseFromString(t,"image/svg+xml"),A=e.querySelector("svg");if(!A)throw new Error("Malformed frame SVG: <svg> tag not found");const i=A.getAttribute("viewBox");if(!i)throw new Error("SVG missing viewBox.");const n=i.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 Mn.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 Mn.set(t,e),e}throw new Error("Malformed frame SVG")},bn=(t,e,A)=>{const i=e.width>=e.height,n=t.width>=t.height,a=e.width/2,r=e.height/2,s=(i?e.height:e.width)/(n?t.width:t.height),o=A?.scale||s,c=a-t.width/2*o,l=A?.left||c,g=r-t.height/2*o;return{x:l,y:A?.top||g,zoom:o}},Pn=async t=>{if(xn.has(t))return xn.get(t);if(t.endsWith("svg")){const e=await Nn(t),A=e.width,i=e.height,n={src:t,width:A,height:i,aspect:A/i};return xn.set(t,n),n}{const e=await JA(t),A=await Dn(e),i={src:t,width:A.width,height:A.height,aspect:A.width/A.height};return xn.set(t,i),i}},Nn=async t=>{const e=await LA(t);return Rn(e)},Rn=t=>{const e=OA().parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)throw new Error("No svg tag found, this svg must be malformed!");const A=e.getAttribute("viewBox"),i=e.getAttribute("width"),n=e.getAttribute("height"),a=A?A?.split(" ").map((t=>Number(t))):[0,0,Number(i),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 Hn={};He(Hn,"determineCorrectFontSizeAndLines",(()=>Un)),He(Hn,"determineCorrectTextboxRegion",(()=>Gn));const kn=(t,e,A,i,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=>di(t,i,n)));const o=n.getApproximateHeight()*i;let c=!0;for(;c;){if(o+(r-1)*A>t.height)return[null,null];const e=Math.max(...s);if(e<=t.width)return[a,e];const l=s.reduce(((t,e,A,i)=>e>i[t]?A: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)],A=e.map((t=>di(t,i,n)));A[0]<=t.width&&(a=[...a.slice(0,l),...e,...a.slice(l+1)],s=[...s.slice(0,l),...A,...s.slice(l+1)],r+=1,h=!0)}h||(c=!1)}return[null,null]},Un=(t,e,A,i,n)=>{let a,r;const s=ni(e),o=s.getFont();if(n.size){const e=t/o.unitsPerEm;return[a,r]=kn(A,i,t,e,s),[n.size,a,r]}let c=6-hi;if(i.length>0){let t=i,e=0;for(;(!n.maxSize||c<=n.maxSize)&&t;)c+=hi,e=c/o.unitsPerEm,[t,r]=kn(A,i,c,e,s)}c>6&&(c-=hi),n.minSize&&c<n.minSize&&(c=n.minSize);const l=c/o.unitsPerEm;return[a,r]=kn(A,i,c,l,s),[c,a,r]},Gn=(t,e,A,i,n)=>{let a={...t},r={...t},[s,o,c]=Un(A,e,r,i,{size:0,minSize:A,maxSize:A});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]=Un(A,e,r,i,{size:A}),s===A&&o&&(l=i,g=o,l.map(((t,e)=>[t,g[e]]))).every((([t,e])=>t===e))&&(a=r)),a};var Tn={};He(Tn,"svgObjectURL",(()=>Ln)),He(Tn,"LayoutElementFactory",(()=>jn));const On=(t,e)=>{const A=t.layoutState.elements.filter((t=>t.layer===e)),i=Math.max(...A.map((t=>t.layerIndex)).filter((t=>void 0!==t)));return Math.max(i,0)+1},Jn=async t=>new Promise((e=>{LA(t).then((t=>{e(t)})).catch((t=>console.error(t)))})),Ln=async t=>{const e=OA().parseFromString(t,"image/svg+xml").firstElementChild;if(!e)throw new Error("Failed to read SVG");const A=(new XMLSerializer).serializeToString(e),i=document.createElement("canvas"),n=i.getContext("2d"),a=await Re.from(n,A,{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,A)=>{try{if(!URL||!URL.createObjectURL)throw new Error("Environment incapable of generating ObjectURL");t.toBlob((A=>{if(!A){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(A))}))}catch(t){A(t)}})))(i)},zn=async(t,e,A,i)=>{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(A&&e===Le.Illustration){const t=await Ri(await Jn(A)),e=OA().parseFromString(t.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!e)throw new Error("SVG missing viewBox.");const i=s.height,n=e.split(" "),a=(parseFloat(n[2])||1)/(parseFloat(n[3])||1);s.height=s.width/a,s.top+=(i-s.height)/2}if(A&&e===Le.Image){const t=s.height,e=await JA(A),i=await Dn(e),n=i.width/i.height;s.height=s.width/n,s.top+=(t-s.height)/2}if(A&&e===Le.Textbox&&i?.text&&i?.fontScale){const t={assetUrl:A,name:(await Ai(A)).names.fullName.en},e=ni(t),a=di(i.text,i?.fontScale,e);s.width=Math.min(a,.85*n.width),s.left=n.x+n.width/2-s.width/2}return s};class jn{static async getFrame(t,e){const A=await vn(e.region,e.src),i=await Yn(A),n=e.region||await zn(t,Le.Frame);return{id:Ge(),x:n.left,y:n.top,width:n.width,height:n.height,layer:n.layer||0,layerIndex:n.layerIndex||On(t,n.layer||0),rotation:n.rotation,scaleX:n.width/i.width,scaleY:n.height/i.height,path:i.path,type:Le.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 A=e.region||await zn(t,Le.Image,e.src);return{id:Ge(),src:e.src,type:Le.Image,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer||0,layerIndex:A.layerIndex||On(t,A.layer||0),immutable:A.immutable,preserveAspectRatio:"none"}}static async getTextbox(t,e){const{configuration:A,fontSrc:i,designInputStep:n}=e,a=await Ai(i),r={assetUrl:i,name:a.names.fullName.en},s=n?.text||A.defaultText||"",o=A.replaceableText?A.replaceableText.replace("{{}}",s):s,c=Ei(o,{vertical:A.vertical,uppercase:A.uppercase}),l=e.region||await zn(t,Le.Textbox,i,{text:c,fontScale:A.size?A.size/a.unitsPerEm:void 0}),g=fi({id:Ge(),type:Le.Textbox,x:l.left,y:l.top,width:l.width,height:l.height,align:mi(A.textAlign,A.vertical),curved:A.curved,fill:n?.color||A.colour||"#000000",fontData:r,layer:l.layer||0,layerIndex:l.layerIndex||On(t,l.layer||0),paths:A.paths,rotation:l.rotation,vertical:A.vertical,verticalAlign:A.verticalAlign||"middle",algorithm:Ke.Traditional,fontSize:A.size||Math.max(Math.round(.025*l.height),1),text:c,input:s},c),h=gi({...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 A=`\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 `,i={};i["spiff-fill-shape"]={browserValue:e.color};const n=e.region||await zn(t,Le.Illustration),a=Ge();return{stepRegion:e.region,colors:i,id:a,svg:A,type:Le.Illustration,y:n.top,x:n.left,rotation:n.rotation,width:n.width,height:n.height,layer:n.layer||0,layerIndex:n.layerIndex||On(t,n.layer||0),immutable:n.immutable}}static async getIllustration(t,e){const A=e.region||await zn(t,Le.Illustration,e.src),i=await Ri(await Jn(e.src)),n=await Ln(i.svg),a=Ge();return{cachedObjectURL:n,stepRegion:e.region,colors:i.colors,id:a,src:e.src,svg:i.svg,type:Le.Illustration,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer||0,layerIndex:A.layerIndex||On(t,A.layer||0),immutable:A.immutable}}}function Vn(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Kn extends Error{constructor(t){super(t),this.name=this.constructor.name}}class Wn extends Kn{constructor(t){super(`ConfigurationError - ${t}`)}}class Xn extends Wn{constructor(t){super(`Option not Configured: ${t.stepTitle}`),Vn(this,"optionId",void 0),this.optionId=t?.optionId||"N/A"}}class qn extends Wn{constructor(t){super(`Panel not Found: ${t.panelId}`),Vn(this,"panelId",void 0),this.panelId=t?.panelId||"N/A"}}class Zn extends Wn{constructor(t){super(`Asset not found for variant: ${t.name}`),Vn(this,"variant",void 0),this.variant=t}}class $n extends Wn{constructor(t){super(`Resource not found for asset: ${t.name}`),Vn(this,"asset",void 0),this.asset=t}}class _n extends Wn{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),Vn(this,"step",void 0),this.step=t}}class ta extends Kn{constructor(t){super(`ImplementationError - ${t}`)}}class ea extends ta{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class Aa extends ta{constructor(t){super(`Parsing Error: ${t}`)}}class ia extends ta{constructor(t){super(`Client Error: ${t}`)}}class na extends ta{constructor(t){super(`Resource Generation Failed: ${t}`)}}function aa(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ra{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 A=JSON.stringify([...e.entries()]);this.set(t,A)}}class sa{constructor(){aa(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 A=JSON.stringify([...e.entries()]);this.set(t,A)}}const oa=(()=>{try{return localStorage?new ra:new sa}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new sa}})();function ca(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const la=new class{constructor(){ca(this,"defaultServerUrl","https://api.spiff.com.au"),ca(this,"defaultServicesApiUrl","https://services.spiff.com.au"),ca(this,"defaultHubUrl","https://hub.spiff.com.au"),ca(this,"serverUrl",void 0),ca(this,"servicesApiUrl",void 0),ca(this,"hubUrl",void 0),ca(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 ga(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let ha;const da=t=>{ha=t};const ua=new class{constructor(){ga(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),la.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const e=(0,t.createHttpLink)({uri:`${la.getServerUrl()}/graphql`,fetch:C.fetch}),A=(0,p.setContext)((async(t,{headers:e})=>{const A=e||{},i=await(async()=>{const t={transactionOwnerId:ha};return"undefined"!=typeof window&&window.location.href.includes("/workflows/product/")?{...await new Promise((t=>{const e=la.getHubUrl();if(window.location.href.includes("localhost")||window.location.href.includes("ngrok"))return void t({});const A=i=>{i.origin===e&&(window.removeEventListener("message",A),t(i.data))};window.parent!==window&&(window.addEventListener("message",A,!1),window.parent.postMessage("ready",e))})),...t}:t})();return i.bearer&&(A.Authorization=`Bearer ${i.bearer}`),i.partnerId&&(A.partnerId=i.partnerId),i.activeIntegration&&(A.activeIntegration=i.activeIntegration),i.transactionOwnerId&&(A.transactionOwnerId=i.transactionOwnerId),{headers:A}})),i=(0,m.onError)((({operation:t,graphQLErrors:e,networkError:A})=>{(e||[]).forEach((({message:e,locations:A,path:i})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+t.operationName),console.log("Query:"+JSON.stringify(t.query)),console.log(`Message: ${e}, Location: ${JSON.stringify(A,null,2)}, Path: ${i}`),console.log("Variables:"+JSON.stringify(t.variables))})),A&&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)([i,A,e]),cache:n,name:"Core"})}};function Ba(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const wa=t.gql`
|
|
1
|
+
var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/jsx-runtime"),i=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"),B=require("rgbcolor"),w=require("svg-pathdata"),E=require("stackblur-canvas"),p=require("@apollo/client/link/context"),m=require("@apollo/client/link/error"),C=require("cross-fetch"),f=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");function M(t,e,A,i){Object.defineProperty(t,e,{get:A,set:i,enumerable:!0,configurable:!0})}var v="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",(()=>Vo)),M(module.exports,"CommandContext",(()=>ki)),M(module.exports,"spiffCoreConfiguration",(()=>la)),M(module.exports,"PromiseQueue",(()=>Yr)),M(module.exports,"QueueablePromise",(()=>Sr)),M(module.exports,"MockWorkflowManager",(()=>Wo)),M(module.exports,"InformationMessageType",(()=>so)),M(module.exports,"StepHandle",(()=>Bo)),M(module.exports,"TextStepHandle",(()=>xo)),M(module.exports,"FrameStepHandle",(()=>$o)),M(module.exports,"BulkStepHandle",(()=>mo)),M(module.exports,"ShapeStepHandle",(()=>Io)),M(module.exports,"IllustrationStepHandle",(()=>Co)),M(module.exports,"MaterialStepHandle",(()=>fo)),M(module.exports,"ModelStepHandle",(()=>Qo)),M(module.exports,"PictureStepHandle",(()=>yo)),M(module.exports,"QuestionStepHandle",(()=>Do)),M(module.exports,"BulkPriceCalculationStrategy",(()=>La)),M(module.exports,"Variant",(()=>ho)),M(module.exports,"OptionNotFoundError",(()=>Xn)),M(module.exports,"LayoutNotFoundError",(()=>qn)),M(module.exports,"AssetNotFoundError",(()=>Zn)),M(module.exports,"ResourceNotFoundError",(()=>$n)),M(module.exports,"MisconfigurationError",(()=>_n)),M(module.exports,"ParseError",(()=>Aa)),M(module.exports,"UnhandledBehaviorError",(()=>ea)),M(module.exports,"assetService",(()=>Da)),M(module.exports,"designService",(()=>Ho)),M(module.exports,"createDesign",(()=>Po)),M(module.exports,"optionService",(()=>va)),M(module.exports,"persistenceService",(()=>oa)),M(module.exports,"graphQlManager",(()=>ua)),M(module.exports,"toast",(()=>to)),M(module.exports,"FrameService",(()=>ks)),M(module.exports,"getBoundedOffsets",(()=>Rs)),M(module.exports,"frameStepService",(()=>js)),M(module.exports,"modelStepService",(()=>Ws)),M(module.exports,"materialStepService",(()=>Ks)),M(module.exports,"shapeStepService",(()=>$s)),M(module.exports,"questionStepService",(()=>Zs)),M(module.exports,"digitalContentStepService",(()=>Ls)),M(module.exports,"moduleStepService",(()=>Xs)),M(module.exports,"pictureStepService",(()=>qs)),M(module.exports,"textStepService",(()=>ao)),M(module.exports,"illustrationStepService",(()=>Vs)),M(module.exports,"ProductCameraRig",(()=>Oa)),M(module.exports,"FrameStep",(()=>qo)),M(module.exports,"ConversionLocation",(()=>ja)),M(module.exports,"ConversionDataType",(()=>Ka)),M(module.exports,"getWorkflow",(()=>zo)),M(module.exports,"AssetType",(()=>eA)),M(module.exports,"BringForwardCommand",(()=>wn)),M(module.exports,"BringToFrontCommand",(()=>un)),M(module.exports,"BringToBackCommand",(()=>Bn)),M(module.exports,"CanvasCommand",(()=>Vi)),M(module.exports,"CreateElementCommand",(()=>tn)),M(module.exports,"CreateLayoutCommand",(()=>$i)),M(module.exports,"DeleteElementCommand",(()=>en)),M(module.exports,"FontAlignmentCommand",(()=>cn)),M(module.exports,"FontColorCommand",(()=>nn)),M(module.exports,"FontSizeCommand",(()=>rn)),M(module.exports,"FontSourceCommand",(()=>on)),M(module.exports,"GroupCommand",(()=>Zi)),M(module.exports,"LayoutElementFactory",(()=>jn)),M(module.exports,"LayoutElementType",(()=>Le)),M(module.exports,"MoveCommand",(()=>Wi)),M(module.exports,"ResizeCommand",(()=>qi)),M(module.exports,"RotateCommand",(()=>Xi)),M(module.exports,"SendBackwardsCommand",(()=>En)),M(module.exports,"StepAspectType",(()=>aA)),M(module.exports,"StepType",(()=>iA)),M(module.exports,"TextChangeCommand",(()=>gn)),M(module.exports,"UnitOfMeasurement",(()=>Xe)),M(module.exports,"dataUrlFromExternalUrl",(()=>KA)),M(module.exports,"findElement",(()=>Ji)),M(module.exports,"frameDataCache",(()=>Mn)),M(module.exports,"generate",(()=>Ge)),M(module.exports,"getAxisAlignedBoundingBox",(()=>cA)),M(module.exports,"generateSVGWithUnknownColors",(()=>Ri)),M(module.exports,"getAttributesFromArrayBuffer",(()=>Dn)),M(module.exports,"rehydrateSerializedLayout",(()=>ji)),M(module.exports,"getFrameData",(()=>Yn)),M(module.exports,"getSvgElement",(()=>Gi)),M(module.exports,"loadFontFromDataUrl",(()=>ii)),M(module.exports,"loadFontFromExternalUrl",(()=>Ai)),M(module.exports,"determineCorrectFontSizeAndLines",(()=>Un)),M(module.exports,"patternImageDataCache",(()=>xn)),M(module.exports,"generateCommands",(()=>os)),M(module.exports,"registerJSDOM",(()=>RA)),M(module.exports,"minZoom",(()=>Dr)),M(module.exports,"AdvancedEditor",(()=>ps)),M(module.exports,"TransformWrapper",(()=>_o)),M(module.exports,"EditorCore",(()=>Es)),M(module.exports,"useLayouts",(()=>Ya)),M(module.exports,"useEditorState",(()=>Ta)),M(module.exports,"useEditorInteraction",(()=>xr)),M(module.exports,"useShortcutCombination",(()=>Mr)),M(module.exports,"commandReducer",(()=>Ha)),M(module.exports,"getDefaultState",(()=>Ra)),M(module.exports,"CommandContextContext",(()=>Fa)),M(module.exports,"AdvancedEditorStateProvider",(()=>Ua)),M(module.exports,"AdvancedEditorContext",(()=>ka)),M(module.exports,"UICommand",(()=>Ga)),M(module.exports,"EditorSubMenu",(()=>Pa)),M(module.exports,"ElementEventType",(()=>_a)),M(module.exports,"KeyEvent",(()=>er)),M(module.exports,"gatherVaryingStepAspects",(()=>Ms));function S(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 b=/^[A-Z-]+$/;function P(t){const e=/url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(t);return e&&(e[2]||e[3]||e[4])||""}const N=/(\[[^\]]+\])/g,R=/(#[^\s+>~.[:]+)/g,H=/(\.[^\s+>~.[:]+)/g,k=/(::[^\s+>~.[:]+|:first-line|:first-letter|:before|:after)/gi,U=/(:[\w-]+\([^)]*\))/gi,G=/(:[^\s+>~.[:]+)/g,T=/([^\s+>~.[:]+)/g;function O(t,e){const A=e.exec(t);return A?[t.replace(e," "),A.length]:[t,0]}const J=1e-8;function L(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))}function z(t,e){return(t[0]*e[0]+t[1]*e[1])/(L(t)*L(e))}function j(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(z(t,e))}function V(t){return t*t*t}function K(t){return 3*t*t*(1-t)}function W(t){return 3*t*(1-t)*(1-t)}function X(t){return(1-t)*(1-t)*(1-t)}function q(t){return t*t}function Z(t){return 2*t*(1-t)}function $(t){return(1-t)*(1-t)}function _(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class tt{static empty(t){return new tt(t,"EMPTY","")}split(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:" ";const{document:e,name:A}=this;return S(this.getString()).trim().split(t).map((t=>new tt(e,A,t)))}hasValue(t){const e=this.value;return null!==e&&""!==e&&(t||0!==e)&&void 0!==e}isString(t){const{value:e}=this,A="string"==typeof e;return A&&t?t.test(e):A}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 A=parseFloat(e);return this.isString(/%$/)&&(A/=100),A}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,A)=>e--&&A?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[A,i]="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(/%$/)&&i:return this.getNumber()*this.getEm();case this.isString(/%$/):return this.getNumber()*n.computeSize(A);default:{const t=this.getNumber();return e&&t<1?t*n.computeSize(A):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),A=(null==e?void 0:e[1])||t;return this.document.definitions[A]}getFillStyleDefinition(t,e){let A=this.getDefinition();if(!A)return null;if("function"==typeof A.createGradient&&"getBoundingBox"in t)return A.createGradient(this.document.ctx,t,e);if("function"==typeof A.createPattern){if(A.getHrefAttribute().hasValue()){const t=A.getAttribute("patternTransform");A=A.getHrefAttribute().getDefinition(),A&&t.hasValue()&&A.getAttribute("patternTransform",!0).setValue(t.value)}if(A)return A.createPattern(this.document.ctx,t,e)}return null}getTextBaseline(){if(!this.hasValue())return null;const t=this.getString();return tt.textBaselineMapping[t]||null}addOpacity(t){let e=this.getColor();const A=e.length;let i=0;for(let t=0;t<A&&(","===e[t]&&i++,3!==i);t++);if(t.hasValue()&&this.isString()&&3!==i){const A=new(F(B))(e);A.ok&&(A.alpha=t.getNumber(),e=A.toRGBA())}return new tt(this.document,this.name,e)}constructor(t,e,A){_(this,"document",void 0),_(this,"name",void 0),_(this,"value",void 0),_(this,"isNormalizedColor",void 0),this.document=t,this.name=e,this.value=A,this.isNormalizedColor=!1}}function et(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}_(tt,"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||it()}getCurrent(){const{viewPorts:t}=this,e=t[t.length-1];return e||it()}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(){et(this,"viewPorts",[])}}function it(){return{width:At.DEFAULT_VIEWPORT_WIDTH,height:At.DEFAULT_VIEWPORT_HEIGHT}}function nt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}et(At,"DEFAULT_VIEWPORT_WIDTH",800),et(At,"DEFAULT_VIEWPORT_HEIGHT",600);class at{static parse(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const[A=e,i=e]=Y(t);return new at(A,i)}static parseScale(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const[A=e,i=A]=Y(t);return new at(A,i)}static parsePath(t){const e=Y(t),A=e.length,i=[];for(let t=0;t<A;t+=2)i.push(new at(e[t],e[t+1]));return i}angleTo(t){return Math.atan2(t.y-this.y,t.x-this.x)}applyTransform(t){const{x:e,y:A}=this,i=e*t[0]+A*t[2]+t[4],n=e*t[1]+A*t[3]+t[5];this.x=i,this.y=n}constructor(t,e){nt(this,"x",void 0),nt(this,"y",void 0),this.x=t,this.y=e}}function rt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class st{isWorking(){return this.working}start(){if(this.working)return;const{screen:t,onClick:e,onMouseMove:A}=this,i=t.ctx.canvas;i.onclick=e,i.onmousemove=A,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:A}=this,{style:i}=t.ctx.canvas;let n;i&&(i.cursor=""),e.forEach(((t,e)=>{let{run:i}=t;for(n=A[e];n;)i(n),n=n.parent})),this.events=[],this.eventElements=[]}checkPath(t,e){if(!this.working||!e)return;const{events:A,eventElements:i}=this;A.forEach(((A,n)=>{let{x:a,y:r}=A;!i[n]&&e.isPointInPath&&e.isPointInPath(a,r)&&(i[n]=t)}))}checkBoundingBox(t,e){if(!this.working||!e)return;const{events:A,eventElements:i}=this;A.forEach(((A,n)=>{let{x:a,y:r}=A;!i[n]&&e.isPointInBox(a,r)&&(i[n]=t)}))}mapXY(t,e){const{window:A,ctx:i}=this.screen,n=new at(t,e);let a=i.canvas;for(;a;)n.x-=a.offsetLeft,n.y-=a.offsetTop,a=a.offsetParent;return(null==A?void 0:A.scrollX)&&(n.x+=A.scrollX),(null==A?void 0:A.scrollY)&&(n.y+=A.scrollY),n}onClick(t){const{x:e,y:A}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onclick",x:e,y:A,run(t){t.onClick&&t.onClick()}})}onMouseMove(t){const{x:e,y:A}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onmousemove",x:e,y:A,run(t){t.onMouseMove&&t.onMouseMove()}})}constructor(t){rt(this,"screen",void 0),rt(this,"working",void 0),rt(this,"events",void 0),rt(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 ot(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const ct="undefined"!=typeof window?window:null,lt="undefined"!=typeof fetch?fetch.bind(void 0):void 0;class gt{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:A,aspectRatio:i,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 B=S(i).replace(/^defer\s/,""),[w,E]=B.split(" "),p=w||"xMidYMid",m=E||"meet",C=n/a,f=r/s,Q=Math.min(C,f),y=Math.max(C,f);let D=a,I=s;"meet"===m&&(D*=Q,I*=Q),"slice"===m&&(D*=y,I*=y);const x=new tt(e,"refX",l),M=new tt(e,"refY",g),v=x.hasValue()&&M.hasValue();if(v&&A.translate(-Q*x.getPixels("x"),-Q*M.getPixels("y")),h){const t=Q*d,e=Q*u;A.beginPath(),A.moveTo(t,e),A.lineTo(n,e),A.lineTo(n,r),A.lineTo(t,r),A.closePath(),A.clip()}if(!v){const t="meet"===m&&Q===f,e="slice"===m&&y===f,i="meet"===m&&Q===C,a="slice"===m&&y===C;p.startsWith("xMid")&&(t||e)&&A.translate(n/2-D/2,0),p.endsWith("YMid")&&(i||a)&&A.translate(0,r/2-I/2),p.startsWith("xMax")&&(t||e)&&A.translate(n-D,0),p.endsWith("YMax")&&(i||a)&&A.translate(0,r-I)}switch(!0){case"none"===p:A.scale(C,f);break;case"meet"===m:A.scale(Q,Q);break;case"slice"===m:A.scale(y,y)}A.translate(-o,-c)}start(t){let{enableRedraw:e=!1,ignoreMouse:A=!1,ignoreAnimation:i=!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/gt.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(),B=d,w=0;const E=()=>{d=Date.now(),w=d-B,w>=h&&(B=d-w%h,this.shouldUpdate(i,r)&&(this.render(t,n,a,s,o,c,l),g.runEvents())),this.intervalId=F(u)(E)};A||g.start(),this.intervalId=F(u)(E)}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,A)=>A.update(t)||e),!1))return!0}return!("function"!=typeof e||!e())||(!(this.isReadyLock||!this.isReady())||!!this.mouse.hasEvents())}render(t,e,A,i,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 i&&"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 i||"number"==typeof n){const e=Y(t.getAttribute("viewBox").getString());let A=0,a=0;if("number"==typeof i){const n=t.getStyle("width");n.hasValue()?A=n.getPixels("x")/i:e[2]&&!isNaN(e[2])&&(A=e[2]/i)}if("number"==typeof n){const A=t.getStyle("height");A.hasValue()?a=A.getPixels("y")/n:e[3]&&!isNaN(e[3])&&(a=e[3]/n)}A||(A=a),a||(a=A),t.getAttribute("width",!0).setValue(i),t.getAttribute("height",!0).setValue(n);const r=t.getStyle("transform",!0,!0);r.setValue(`${r.getString()} scale(${1/A}, ${1/a})`)}A||o.clearRect(0,0,d,u),t.render(o),c&&(this.isFirstRender=!1)}constructor(t,{fetch:e=lt,window:A=ct}={}){if(ot(this,"ctx",void 0),ot(this,"window",void 0),ot(this,"fetch",void 0),ot(this,"viewPort",void 0),ot(this,"mouse",void 0),ot(this,"animations",void 0),ot(this,"readyPromise",void 0),ot(this,"resolveReady",void 0),ot(this,"waits",void 0),ot(this,"frameDuration",void 0),ot(this,"isReadyLock",void 0),ot(this,"isFirstRender",void 0),ot(this,"intervalId",void 0),this.ctx=t,this.viewPort=new At,this.mouse=new st(this),this.animations=[],this.waits=[],this.frameDuration=0,this.isReadyLock=!1,this.isFirstRender=!0,this.intervalId=null,this.window=A,!e)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");this.fetch=e}}function ht(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}ot(gt,"defaultWindow",ct),ot(gt,"defaultFetch",lt),ot(gt,"FRAMERATE",30),ot(gt,"MAX_VIRTUAL_PIXELS",3e4);const{defaultFetch:dt}=gt,ut="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(A){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),A=await e.text();return this.parseFromString(A)}constructor({fetch:t=dt,DOMParser:e=ut}={}){if(ht(this,"fetch",void 0),ht(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 wt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function Et(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function pt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function mt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Ct{apply(t){const{originX:e,originY:A,matrix:i}=this,n=e.getPixels("x"),a=A.getPixels("y");t.translate(n,a),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),t.translate(-n,-a)}unapply(t){const{originX:e,originY:A,matrix:i}=this,n=i[0],a=i[2],r=i[4],s=i[1],o=i[3],c=i[5],l=1/(n*(1*o-0*c)-a*(1*s-0*c)+r*(0*s-0*o)),g=e.getPixels("x"),h=A.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,A){mt(this,"type","matrix"),mt(this,"matrix",void 0),mt(this,"originX",void 0),mt(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=A[0],this.originY=A[1]}}function ft(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Qt extends Ct{constructor(t,e,A){super(t,e,A),ft(this,"type","skew"),ft(this,"angle",void 0),this.angle=new tt(t,"angle",e)}}function yt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Dt{static fromElement(t,e){const A=e.getStyle("transform",!1,!0);if(A.hasValue()){const[i,n=i]=e.getStyle("transform-origin",!1,!0).split();if(i&&n){const e=[i,n];return new Dt(t,A.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,A){yt(this,"document",void 0),yt(this,"transforms",void 0),this.document=t,this.transforms=[];const i=function(t){return S(t).trim().replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)}(e);i.forEach((t=>{if("none"===t)return;const[e,i]=function(t){const[e="",A=""]=t.split("(");return[e.trim(),A.trim().replace(")","")]}(t),n=Dt.transformTypes[e];n&&this.transforms.push(new n(this.document,i,A))}))}}function It(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}yt(Dt,"transformTypes",{translate:class{apply(t){const{x:e,y:A}=this.point;t.translate(e||0,A||0)}unapply(t){const{x:e,y:A}=this.point;t.translate(-1*e||0,-1*A||0)}applyToPoint(t){const{x:e,y:A}=this.point;t.applyTransform([1,0,0,1,e||0,A||0])}constructor(t,e){wt(this,"type","translate"),wt(this,"point",void 0),this.point=at.parse(e)}},rotate:class{apply(t){const{cx:e,cy:A,originX:i,originY:n,angle:a}=this,r=e+i.getPixels("x"),s=A+n.getPixels("y");t.translate(r,s),t.rotate(a.getRadians()),t.translate(-r,-s)}unapply(t){const{cx:e,cy:A,originX:i,originY:n,angle:a}=this,r=e+i.getPixels("x"),s=A+n.getPixels("y");t.translate(r,s),t.rotate(-1*a.getRadians()),t.translate(-r,-s)}applyToPoint(t){const{cx:e,cy:A,angle:i}=this,n=i.getRadians();t.applyTransform([1,0,0,1,e||0,A||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,-A||0])}constructor(t,e,A){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 i=Y(e);this.angle=new tt(t,"angle",i[0]),this.originX=A[0],this.originY=A[1],this.cx=i[1]||0,this.cy=i[2]||0}},scale:class{apply(t){const{scale:{x:e,y:A},originX:i,originY:n}=this,a=i.getPixels("x"),r=n.getPixels("y");t.translate(a,r),t.scale(e,A||e),t.translate(-a,-r)}unapply(t){const{scale:{x:e,y:A},originX:i,originY:n}=this,a=i.getPixels("x"),r=n.getPixels("y");t.translate(a,r),t.scale(1/e,1/A||e),t.translate(-a,-r)}applyToPoint(t){const{x:e,y:A}=this.scale;t.applyTransform([e||0,0,0,A||0,0,0])}constructor(t,e,A){pt(this,"type","scale"),pt(this,"scale",void 0),pt(this,"originX",void 0),pt(this,"originY",void 0);const i=at.parseScale(e);0!==i.x&&0!==i.y||(i.x=J,i.y=J),this.scale=i,this.originX=A[0],this.originY=A[1]}},matrix:Ct,skewX:class extends Qt{constructor(t,e,A){var i,n,a;super(t,e,A),a="skewX",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.matrix=[1,0,Math.tan(this.angle.getRadians()),1,0,0]}},skewY:class extends Qt{constructor(t,e,A){var i,n,a;super(t,e,A),a="skewY",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.matrix=[1,Math.tan(this.angle.getRadians()),0,1,0,0]}}});class xt{getAttribute(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const A=this.attributes[t];if(!A&&e){const e=new tt(this.document,t,"");return this.attributes[t]=e,e}return A||tt.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||tt.empty(this.document)}getStyle(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],A=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=this.styles[t];if(i)return i;const n=this.getAttribute(t);if(n.hasValue())return this.styles[t]=n,n;if(!A){const{parent:e}=this;if(e){const A=e.getStyle(t);if(A.hasValue())return A}}if(e){const e=new tt(this.document,t,"");return this.styles[t]=e,e}return tt.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=Dt.fromElement(this.document,this);e&&e.apply(t);const A=this.getStyle("clip-path",!1,!0);if(A.hasValue()){const e=A.getDefinition();e&&e.apply(t)}}clearContext(t){}renderChildren(t){this.children.forEach((e=>{e.render(t)}))}addChild(t){const e=t instanceof xt?t:this.document.createElement(t);e.parent=this,xt.ignoreChildTypes.includes(e.type)||this.children.push(e)}matchesSelector(t){var e;const{node:A}=this;if(!A)return!1;if("function"==typeof A.matches)return A.matches(t);const i=null===(e=A.getAttribute)||void 0===e?void 0:e.call(A,"class");return!(!i||""===i)&&i.split(" ").some((e=>`.${e}`===t))}addStylesFromStyleDefinition(){const{styles:t,stylesSpecificity:e}=this.document;let A;for(const i in t)if(!i.startsWith("@")&&this.matchesSelector(i)){const n=t[i],a=e[i];if(n)for(const t in n){let e=this.stylesSpecificity[t];void 0===e&&(e="000"),a&&a>=e&&(A=n[t],A&&(this.styles[t]=A),this.stylesSpecificity[t]=a)}}}removeStyles(t,e){return e.reduce(((e,A)=>{const i=t.getStyle(A);if(!i.hasValue())return e;const n=i.getString();return i.setValue(""),[...e,[A,n]]}),[])}restoreStyles(t,e){e.forEach((e=>{let[A,i]=e;t.getStyle(A,!0).setValue(i)}))}isFirstChild(){var t;return 0===(null===(t=this.parent)||void 0===t?void 0:t.children.indexOf(this))}constructor(t,e,A=!1){if(It(this,"document",void 0),It(this,"node",void 0),It(this,"captureTextNodes",void 0),It(this,"type",void 0),It(this,"attributes",void 0),It(this,"styles",void 0),It(this,"stylesSpecificity",void 0),It(this,"animationFrozen",void 0),It(this,"animationFrozenValue",void 0),It(this,"parent",void 0),It(this,"children",void 0),this.document=t,this.node=e,this.captureTextNodes=A,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 A=(i=e.nodeName,b.test(i)?i.toLowerCase():i);var i;this.attributes[A]=new tt(t,A,e.value)})),this.addStylesFromStyleDefinition(),this.getAttribute("style").hasValue()){this.getAttribute("style").getString().split(";").map((t=>t.trim())).forEach((e=>{if(!e)return;const[A,i]=e.split(":").map((t=>t.trim()));A&&(this.styles[A]=new tt(t,A,i))}))}const{definitions:i}=t,n=this.getAttribute("id");n.hasValue()&&(i[n.getString()]||(i[n.getString()]=this)),Array.from(e.childNodes).forEach((e=>{if(1===e.nodeType)this.addChild(e);else if(A&&(3===e.nodeType||4===e.nodeType)){const A=t.createTextNode(e);A.getText().length>0&&this.addChild(A)}}))}}It(xt,"ignoreChildTypes",["title"]);class Mt extends xt{constructor(t,e,A){super(t,e,A)}}function vt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function Ft(t){const e=t.trim();return/^('|")/.test(e)?e:`"${e}"`}function St(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 bt{static parse(){let t=arguments.length>1?arguments[1]:void 0,e="",A="",i="",n="",a="";const r=S(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&&bt.styles.includes(t):"inherit"!==t&&(e=t),s.fontStyle=!0;break;case!s.fontVariant&&bt.variants.includes(t):"inherit"!==t&&(A=t),s.fontStyle=!0,s.fontVariant=!0;break;case!s.fontWeight&&bt.weights.includes(t):"inherit"!==t&&(i=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 bt(e,A,i,n,a,t)}toString(){return[St(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,A,i,n,a){vt(this,"fontFamily",void 0),vt(this,"fontSize",void 0),vt(this,"fontStyle",void 0),vt(this,"fontWeight",void 0),vt(this,"fontVariant",void 0);const r=a?"string"==typeof a?bt.parse(a):a:{};this.fontFamily=n||r.fontFamily,this.fontSize=i||r.fontSize,this.fontStyle=t||r.fontStyle,this.fontWeight=A||r.fontWeight,this.fontVariant=e||r.fontVariant}}function Pt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}vt(bt,"styles","normal|italic|oblique|inherit"),vt(bt,"variants","normal|small-caps|inherit"),vt(bt,"weights","normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit");class Nt{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:A,x2:i,y2:n}=t;this.addPoint(e,A),this.addPoint(i,n)}sumCubic(t,e,A,i,n){return Math.pow(1-t,3)*e+3*Math.pow(1-t,2)*t*A+3*(1-t)*Math.pow(t,2)*i+Math.pow(t,3)*n}bezierCurveAdd(t,e,A,i,n){const a=6*e-12*A+6*i,r=-3*e+9*A-9*i+3*n,s=3*A-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,A,i,n)):this.addY(this.sumCubic(r,e,A,i,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,A,i,n)):this.addY(this.sumCubic(c,e,A,i,n)));const l=(-a-Math.sqrt(o))/(2*r);0<l&&l<1&&(t?this.addX(this.sumCubic(l,e,A,i,n)):this.addY(this.sumCubic(l,e,A,i,n)))}addBezierCurve(t,e,A,i,n,a,r,s){this.addPoint(t,e),this.addPoint(r,s),this.bezierCurveAdd(!0,t,A,n,r),this.bezierCurveAdd(!1,e,i,a,s)}addQuadraticCurve(t,e,A,i,n,a){const r=t+2/3*(A-t),s=e+2/3*(i-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:A,y1:i,x2:n,y2:a}=this;return A<=t&&t<=n&&i<=e&&e<=a}constructor(t=Number.NaN,e=Number.NaN,A=Number.NaN,i=Number.NaN){Pt(this,"x1",void 0),Pt(this,"y1",void 0),Pt(this,"x2",void 0),Pt(this,"y2",void 0),this.x1=t,this.y1=e,this.x2=A,this.y2=i,this.addPoint(t,e),this.addPoint(A,i)}}class Rt extends xt{calculateOpacity(){let t=1,e=this;for(;e;){const A=e.getStyle("opacity",!1,!0);A.hasValue(!0)&&(t*=A.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"),A=this.getStyle("fill-opacity"),i=this.getStyle("stroke"),n=this.getStyle("stroke-opacity");if(e.isUrlDefinition()){const i=e.getFillStyleDefinition(this,A);i&&(t.fillStyle=i)}else if(e.hasValue()){"currentColor"===e.getString()&&e.setValue(this.getStyle("color").getColor());const A=e.getColor();"inherit"!==A&&(t.fillStyle="none"===A?"rgba(0,0,0,0)":A)}if(A.hasValue()){const e=new tt(this.document,"fill",t.fillStyle).addOpacity(A).getColor();t.fillStyle=e}if(i.isUrlDefinition()){const e=i.getFillStyleDefinition(this,n);e&&(t.strokeStyle=e)}else if(i.hasValue()){"currentColor"===i.getString()&&i.setValue(this.getStyle("color").getColor());const e=i.getString();"inherit"!==e&&(t.strokeStyle="none"===e?"rgba(0,0,0,0)":e)}if(n.hasValue()){const e=new tt(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||J}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 A=l.getPixels();void 0!==t.lineDashOffset?t.lineDashOffset=A:void 0!==t.webkitLineDashOffset?t.webkitLineDashOffset=A:void 0!==t.mozDashOffset&&(t.mozDashOffset=A)}}if(this.modifiedEmSizeStack=!1,void 0!==t.font){const e=this.getStyle("font"),A=this.getStyle("font-style"),i=this.getStyle("font-variant"),n=this.getStyle("font-weight"),a=this.getStyle("font-size"),r=this.getStyle("font-family"),s=new bt(A.getString(),i.getString(),n.getString(),a.hasValue()?`${a.getPixels(!0)}px`:"",r.getString(),bt.parse(e.getString(),t.font));A.setValue(s.fontStyle),i.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,A,i;super(...t),i=!1,(A="modifiedEmSizeStack")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function Ht(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class kt extends Rt{setContext(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];super.setContext(t,e);const A=this.getStyle("dominant-baseline").getTextBaseline()||this.getStyle("alignment-baseline").getTextBaseline();A&&(t.textBaseline=A)}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(((A,i)=>{const n=this.getChildBoundingBox(t,this,this,i);e?e.addBoundingBox(n):e=n})),e}getFontSize(){const{document:t,parent:e}=this,A=bt.parse(t.ctx.font).fontSize;return e.getStyle("font-size").getNumber(A)}getTElementBoundingBox(t){const e=this.getFontSize();return new Nt(this.x,this.y-e,this.x+this.measureText(t),this.y)}getGlyph(t,e,A){const i=e[A];let n;if(t.isArabic){var a;const r=e.length,s=e[A-1],o=e[A+1];let c="isolated";(0===A||" "===s)&&A<r-1&&" "!==o&&(c="terminal"),A>0&&" "!==s&&A<r-1&&" "!==o&&(c="medial"),A>0&&" "!==s&&(A===r-1||" "===o)&&(c="initial"),n=(null===(a=t.arabicGlyphs[i])||void 0===a?void 0:a[c])||t.glyphs[i]}else n=t.glyphs[i];return n||(n=t.missingGlyph),n}getText(){return""}getTextFromNode(t){const e=t||this.node,A=Array.from(e.parentNode.childNodes),i=A.indexOf(e),n=A.length-1;let a=S(e.textContent||"");return 0===i&&(a=a.replace(/^[\n \t]+/,"")),i===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,A)=>{this.renderChild(t,this,this,A)}));const{mouse:e}=this.document.screen;e.isWorking()&&e.checkBoundingBox(this,this.getBoundingBox(t))}renderTElementChildren(t){const{document:e,parent:A}=this,i=this.getText(),n=A.getStyle("font-family").getDefinition();if(null==n?void 0:n.fontFace){const{unitsPerEm:a}=n.fontFace,r=bt.parse(e.ctx.font),s=A.getStyle("font-size").getNumber(r.fontSize),o=A.getStyle("font-style").getString(r.fontStyle),c=s/a,l=n.isRTL?i.split("").reverse().join(""):i,g=Y(A.getAttribute("dx").getString()),h=l.length;for(let e=0;e<h;e++){const A=this.getGlyph(n,l,e);t.translate(this.x,this.y),t.scale(c,-c);const i=t.lineWidth;t.lineWidth=t.lineWidth*a/s,"italic"===o&&t.transform(1,0,.4,1,0,0),A.render(t),"italic"===o&&t.transform(1,0,-.4,1,0,0),t.lineWidth=i,t.scale(1/c,-1/c),t.translate(-this.x,-this.y),this.x+=s*(A.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(i,a,r),t.strokeStyle&&t.strokeText(i,a,r)}applyAnchoring(){if(this.textChunkStart>=this.leafTexts.length)return;const t=this.leafTexts[this.textChunkStart],e=t.getStyle("text-anchor").getString("start");let A=0;A="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+=A;this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.textChunkStart=this.leafTexts.length}adjustChildCoordinatesRecursive(t){this.children.forEach(((e,A)=>{this.adjustChildCoordinatesRecursiveCore(t,this,this,A)})),this.applyAnchoring()}adjustChildCoordinatesRecursiveCore(t,e,A,i){const n=A.children[i];n.children.length>0?n.children.forEach(((A,i)=>{e.adjustChildCoordinatesRecursiveCore(t,e,n,i)})):this.adjustChildCoordinates(t,e,A,i)}adjustChildCoordinates(t,e,A,i){const n=A.children[i];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===i&&(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,A,i){const n=A.children[i];if("function"!=typeof n.getBoundingBox)return null;const a=n.getBoundingBox(t);return a&&n.children.forEach(((A,i)=>{const r=e.getChildBoundingBox(t,e,n,i);a.addBoundingBox(r)})),a}renderChild(t,e,A,i){const n=A.children[i];n.render(t),n.children.forEach(((A,i)=>{e.renderChild(t,e,n,i)}))}measureText(t){const{measureCache:e}=this;if(~e)return e;const A=this.getText(),i=this.measureTargetText(t,A);return this.measureCache=i,i}measureTargetText(t,e){if(!e.length)return 0;const{parent:A}=this,i=A.getStyle("font-family").getDefinition();if(i){const t=this.getFontSize(),n=i.isRTL?e.split("").reverse().join(""):e,a=Y(A.getAttribute("dx").getString()),r=n.length;let s=0;for(let e=0;e<r;e++){s+=(this.getGlyph(i,n,e).horizAdvX||i.horizAdvX)*t/i.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 kt&&e.isFirstChild()&&e.parent;){const A=e.parent.getAttribute(t);if(A.hasValue(!0))return A.getString("0");e=e.parent}return null}constructor(t,e,A){super(t,e,new.target===kt||A),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 Ut(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Gt extends kt{getText(){return this.text}constructor(t,e,A){super(t,e,new.target===Gt||A),Ut(this,"type","tspan"),Ut(this,"text",void 0),this.text=this.children.length>0?"":this.getTextFromNode()}}class Tt extends Gt{constructor(...t){var e,A,i;super(...t),i="textNode",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function Ot(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Jt extends w.SVGPathData{reset(){this.i=-1,this.command=null,this.previousCommand=null,this.start=new at(0,0),this.control=new at(0,0),this.current=new at(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 A=new at(this.command[t],this.command[e]);return this.makeAbsolute(A)}getAsControlPoint(t,e){const A=this.getPoint(t,e);return this.control=A,A}getAsCurrentPoint(t,e){const A=this.getPoint(t,e);return this.current=A,A}getReflectedControlPoint(){const t=this.previousCommand.type;if(t!==w.SVGPathData.CURVE_TO&&t!==w.SVGPathData.SMOOTH_CURVE_TO&&t!==w.SVGPathData.QUAD_TO&&t!==w.SVGPathData.SMOOTH_QUAD_TO)return this.current;const{current:{x:e,y:A},control:{x:i,y:n}}=this;return new at(2*e-i,2*A-n)}makeAbsolute(t){if(this.command.relative){const{x:e,y:A}=this.current;t.x+=e,t.y+=A}return t}addMarker(t,e,A){const{points:i,angles:n}=this;A&&n.length>0&&!n[n.length-1]&&(n[n.length-1]=i[i.length-1].angleTo(A)),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 A=0;A<e;A++)if(!t[A])for(let i=A+1;i<e;i++)if(t[i]){t[A]=t[i];break}return t}constructor(t){super(t.replace(/([+\-.])\s+/gm,"$1").replace(/[^MmZzLlHhVvCcSsQqTtAae\d\s.,+-].*/g,"")),Ot(this,"control",new at(0,0)),Ot(this,"start",new at(0,0)),Ot(this,"current",new at(0,0)),Ot(this,"command",null),Ot(this,"commands",this.commands),Ot(this,"i",-1),Ot(this,"previousCommand",null),Ot(this,"points",[]),Ot(this,"angles",[])}}function Lt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class zt extends Rt{path(t){const{pathParser:e}=this,A=new Nt;for(e.reset(),t&&t.beginPath();!e.isEnd();)switch(e.next().type){case Jt.MOVE_TO:this.pathM(t,A);break;case Jt.LINE_TO:this.pathL(t,A);break;case Jt.HORIZ_LINE_TO:this.pathH(t,A);break;case Jt.VERT_LINE_TO:this.pathV(t,A);break;case Jt.CURVE_TO:this.pathC(t,A);break;case Jt.SMOOTH_CURVE_TO:this.pathS(t,A);break;case Jt.QUAD_TO:this.pathQ(t,A);break;case Jt.SMOOTH_QUAD_TO:this.pathT(t,A);break;case Jt.ARC:this.pathA(t,A);break;case Jt.CLOSE_PATH:this.pathZ(t,A)}return A}getBoundingBox(t){return this.path()}getMarkers(){const{pathParser:t}=this,e=t.getMarkerPoints(),A=t.getMarkerAngles();if(!e||!A)return null;return e.map(((t,e)=>[t,A[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 A=this.getMarkers();if(A){const e=A.length-1,i=this.getStyle("marker-start"),n=this.getStyle("marker-mid"),a=this.getStyle("marker-end");if(i.isUrlDefinition()){const e=i.getDefinition(),[n,a]=A[0];e&&e.render(t,n,null===a?void 0:a)}if(n.isUrlDefinition()){const i=n.getDefinition();for(let n=1;n<e;n++){const[e,a]=A[n];i&&i.render(t,e,null===a?void 0:a)}}if(a.isUrlDefinition()){const i=a.getDefinition(),[n,r]=A[e];i&&i.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:A}=this,{point:i}=zt.pathM(A),{x:n,y:a}=i;A.addMarker(i),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:A}=this,{current:i,point:n}=zt.pathL(A),{x:a,y:r}=n;A.addMarker(n,i),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathH(t){const{current:e,command:A}=t,i=new at(((null==A?void 0:A.relative)?e.x:0)+A.x,e.y);return t.current=i,{current:e,point:i}}pathH(t,e){const{pathParser:A}=this,{current:i,point:n}=zt.pathH(A),{x:a,y:r}=n;A.addMarker(n,i),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathV(t){const{current:e,command:A}=t,i=new at(e.x,(A.relative?e.y:0)+A.y);return t.current=i,{current:e,point:i}}pathV(t,e){const{pathParser:A}=this,{current:i,point:n}=zt.pathV(A),{x:a,y:r}=n;A.addMarker(n,i),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:A}=this,{current:i,point:n,controlPoint:a,currentPoint:r}=zt.pathC(A);A.addMarker(r,a,n),e.addBezierCurve(i.x,i.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:A}=this,{current:i,point:n,controlPoint:a,currentPoint:r}=zt.pathS(A);A.addMarker(r,a,n),e.addBezierCurve(i.x,i.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:A}=this,{current:i,controlPoint:n,currentPoint:a}=zt.pathQ(A);A.addMarker(a,n,n),e.addQuadraticCurve(i.x,i.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,A=t.getReflectedControlPoint();t.control=A;return{current:e,controlPoint:A,currentPoint:t.getAsCurrentPoint()}}pathT(t,e){const{pathParser:A}=this,{current:i,controlPoint:n,currentPoint:a}=zt.pathT(A);A.addMarker(a,n,n),e.addQuadraticCurve(i.x,i.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:A}=t;let{rX:i,rY:n,xRot:a,lArcFlag:r,sweepFlag:s}=A;const o=a*(Math.PI/180),c=t.getAsCurrentPoint(),l=new at(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(i,2)+Math.pow(l.y,2)/Math.pow(n,2);g>1&&(i*=Math.sqrt(g),n*=Math.sqrt(g));let h=(r===s?-1:1)*Math.sqrt((Math.pow(i,2)*Math.pow(n,2)-Math.pow(i,2)*Math.pow(l.y,2)-Math.pow(n,2)*Math.pow(l.x,2))/(Math.pow(i,2)*Math.pow(l.y,2)+Math.pow(n,2)*Math.pow(l.x,2)));isNaN(h)&&(h=0);const d=new at(h*i*l.y/n,h*-n*l.x/i),u=new at((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),B=j([1,0],[(l.x-d.x)/i,(l.y-d.y)/n]),w=[(l.x-d.x)/i,(l.y-d.y)/n],E=[(-l.x-d.x)/i,(-l.y-d.y)/n];let p=j(w,E);return z(w,E)<=-1&&(p=Math.PI),z(w,E)>=1&&(p=0),{currentPoint:c,rX:i,rY:n,sweepFlag:s,xAxisRotation:o,centp:u,a1:B,ad:p}}pathA(t,e){const{pathParser:A}=this,{currentPoint:i,rX:n,rY:a,sweepFlag:r,xAxisRotation:s,centp:o,a1:c,ad:l}=zt.pathA(A),g=1-r?1:-1,h=c+g*(l/2),d=new at(o.x+n*Math.cos(h),o.y+a*Math.sin(h));if(A.addMarkerAngle(d,h-g*Math.PI/2),A.addMarkerAngle(i,h-g*Math.PI),e.addPoint(i.x,i.y),t&&!isNaN(c)&&!isNaN(l)){const e=n>a?n:a,A=n>a?1:n/a,i=n>a?a/n:1;t.translate(o.x,o.y),t.rotate(s),t.scale(A,i),t.arc(0,0,e,c,c+l,Boolean(1-r)),t.scale(1/A,1/i),t.rotate(-s),t.translate(-o.x,-o.y)}}static pathZ(t){t.current=t.start}pathZ(t,e){zt.pathZ(this.pathParser),t&&e.x1!==e.x2&&e.y1!==e.y2&&t.closePath()}constructor(t,e,A){super(t,e,A),Lt(this,"type","path"),Lt(this,"pathParser",void 0),this.pathParser=new Jt(this.getAttribute("d").getString())}}function jt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Vt extends Rt{setContext(t){var e;const{document:A}=this,{screen:i,window:n}=A,a=t.canvas;if(i.setDefaults(t),"style"in a&&void 0!==t.font&&n&&void 0!==n.getComputedStyle){t.font=n.getComputedStyle(a).getPropertyValue("font");const e=new tt(A,"fontSize",bt.parse(t.font).fontSize);e.hasValue()&&(A.rootEmSize=e.getPixels("y"),A.emSize=A.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}=i.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,B=0,w=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&&(B=d,w=u,d=0,u=0)),i.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]),A.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:i.viewPort.width,desiredWidth:r,height:i.viewPort.height,desiredHeight:s,minX:d,minY:u,refX:o.getValue(),refY:c.getValue(),clip:h,clipX:B,clipY:w}),g&&(i.viewPort.removeCurrent(),i.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,A=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=this.getAttribute("width",!0),n=this.getAttribute("height",!0),a=this.getAttribute("viewBox"),r=this.getAttribute("style"),s=i.getNumber(0),o=n.getNumber(0);if(A)if("string"==typeof A)this.getAttribute("preserveAspectRatio",!0).setValue(A);else{const t=this.getAttribute("preserveAspectRatio");t.hasValue()&&t.setValue(t.getString().replace(/^\s*(\S.*\S)\s*$/,"$1"))}if(i.setValue(t),n.setValue(e),a.hasValue()||a.setValue(`0 0 ${s||t} ${o||e}`),r.hasValue()){const A=this.getStyle("width"),i=this.getStyle("height");A.hasValue()&&A.setValue(`${t}px`),i.hasValue()&&i.setValue(`${e}px`)}}constructor(...t){super(...t),jt(this,"type","svg"),jt(this,"root",!1)}}class Kt extends zt{path(t){const e=this.getAttribute("x").getPixels("x"),A=this.getAttribute("y").getPixels("y"),i=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,i/2),o=Math.min(o,n/2),t){const a=(Math.sqrt(2)-1)/3*4;t.beginPath(),n>0&&i>0&&(t.moveTo(e+s,A),t.lineTo(e+i-s,A),t.bezierCurveTo(e+i-s+a*s,A,e+i,A+o-a*o,e+i,A+o),t.lineTo(e+i,A+n-o),t.bezierCurveTo(e+i,A+n-o+a*o,e+i-s+a*s,A+n,e+i-s,A+n),t.lineTo(e+s,A+n),t.bezierCurveTo(e+s-a*s,A+n,e,A+n-o+a*o,e,A+n-o),t.lineTo(e,A+o),t.bezierCurveTo(e,A+o-a*o,e+s-a*s,A,e+s,A),t.closePath())}return new Nt(e,A,e+i,A+n)}getMarkers(){return null}constructor(...t){var e,A,i;super(...t),i="rect",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function Wt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Xt extends zt{path(t){const{points:e}=this,[{x:A,y:i}]=e,n=new Nt(A,i);return t&&(t.beginPath(),t.moveTo(A,i)),e.forEach((e=>{let{x:A,y:i}=e;n.addPoint(A,i),t&&t.lineTo(A,i)})),n}getMarkers(){const{points:t}=this,e=t.length-1,A=[];return t.forEach(((i,n)=>{n!==e&&A.push([i,i.angleTo(t[n+1])])})),A.length>0&&A.push([t[t.length-1],A[A.length-1][1]]),A}constructor(t,e,A){super(t,e,A),Wt(this,"type","polyline"),Wt(this,"points",[]),this.points=at.parsePath(this.getAttribute("points").getString())}}class qt extends Rt{getBoundingBox(t){const e=new Nt;return this.children.forEach((A=>{A instanceof zt&&e.addBoundingBox(A.getBoundingBox(t))})),e}constructor(...t){var e,A,i;super(...t),i="g",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function Zt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class $t extends xt{getGradientUnits(){return this.getAttribute("gradientUnits").getString("objectBoundingBox")}createGradient(t,e,A){let i=this;this.getHrefAttribute().hasValue()&&(i=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(i));const{stops:n}=i,a=this.getGradient(t,e);if(!a)return this.addParentOpacity(A,n[n.length-1].color);if(n.forEach((t=>{a.addColorStop(t.offset,this.addParentOpacity(A,t.color))})),this.getAttribute("gradientTransform").hasValue()){const{document:t}=this,{MAX_VIRTUAL_PIXELS:e}=gt,{viewPort:A}=t.screen,i=A.getRoot(),n=new Kt(t);n.attributes.x=new tt(t,"x",-e/3),n.attributes.y=new tt(t,"y",-e/3),n.attributes.width=new tt(t,"width",e),n.attributes.height=new tt(t,"height",e);const r=new qt(t);r.attributes.transform=new tt(t,"transform",this.getAttribute("gradientTransform").getValue()),r.children=[n];const s=new Vt(t);s.attributes.x=new tt(t,"x",0),s.attributes.y=new tt(t,"y",0),s.attributes.width=new tt(t,"width",i.width),s.attributes.height=new tt(t,"height",i.height),s.children=[r];const o=t.createCanvas(i.width,i.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 tt(this.document,"color",e).addOpacity(t).getColor()}return e}constructor(t,e,A){super(t,e,A),Zt(this,"attributesToInherit",["gradientUnits"]),Zt(this,"stops",[]);const{stops:i,children:n}=this;n.forEach((t=>{"stop"===t.type&&i.push(t)}))}}function _t(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function te(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ee extends xt{getProperty(){var t;const e=this.getAttribute("attributeType").getString(),A=this.getAttribute("attributeName").getString();var i;return"CSS"===e?null===(i=this.parent)||void 0===i?void 0:i.getStyle(A,!0):null===(t=this.parent)||void 0===t?void 0:t.getAttribute(A,!0)}calcValue(){const{initialUnits:t}=this,{progress:e,from:A,to:i}=this.getProgress();let n=A.getNumber()+(i.getNumber()-A.getNumber())*e;return"%"===t&&(n*=100),`${n}${t}`}update(t){const{parent:e}=this,A=this.getProperty();if(!A)return!1;if(this.initialValue||(this.initialValue=A.getString(),this.initialUnits=A.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&&A&&A.setValue(e.animationFrozen?e.animationFrozenValue:this.initialValue),!0}else this.frozen=!0,e&&A&&(e.animationFrozen=!0,e.animationFrozenValue=A.getString());return!1}this.duration+=t;let i=!1;if(this.begin<this.duration){let t=this.calcValue();const e=this.getAttribute("type");if(e.hasValue()){t=`${e.getString()}(${t})`}A.setValue(t),i=!0}return i}getProgress(){const{document:t,values:e}=this;let A,i,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],A=new tt(t,"from",o?parseFloat(o):0),o=e.getValue()[s],i=new tt(t,"to",o?parseFloat(o):0),n=(a-r)/(s-r)}else A=this.from,i=this.to;return{progress:n,from:A,to:i}}constructor(t,e,A){super(t,e,A),te(this,"type","animate"),te(this,"begin",void 0),te(this,"maxDuration",void 0),te(this,"from",void 0),te(this,"to",void 0),te(this,"values",void 0),te(this,"duration",0),te(this,"initialValue",void 0),te(this,"initialUnits",""),te(this,"removed",!1),te(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 tt(t,"values",null);const i=this.getAttribute("values");i.hasValue()&&this.values.setValue(i.getString().split(";"))}}function Ae(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ie extends xt{constructor(t,e,A){super(t,e,A),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 ne(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ae extends zt{constructor(t,e,A){super(t,e,A),ne(this,"type","glyph"),ne(this,"horizAdvX",void 0),ne(this,"unicode",void 0),ne(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 re(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class se extends ae{constructor(...t){super(...t),re(this,"type","missing-glyph"),re(this,"horizAdvX",0)}}function oe(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function ce(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function le(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function ge(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const he=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*)$/i;function de(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ue{async load(t,e){try{const{document:A}=this,i=(await A.pith.parser.load(e)).getElementsByTagName("font");Array.from(i).forEach((e=>{const i=A.createElement(e);A.definitions[t]=i}))}catch(t){console.error(`Error while loading font "${e}":`,t)}this.loaded=!0}constructor(t){de(this,"document",void 0),de(this,"loaded",void 0),this.document=t,this.loaded=!1,t.fonts.push(this)}}function Be(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class we extends xt{constructor(t,e,A){super(t,e,A),Be(this,"type","style");S(Array.from(e.childNodes).map((t=>t.textContent)).join("").replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"").replace(/@import.*;/g,"")).split("}").forEach((e=>{const A=e.trim();if(!A)return;const i=A.split("{"),n=i[0].split(","),a=i[1].split(";");n.forEach((e=>{const A=e.trim();if(!A)return;const i=t.styles[A]||{};if(a.forEach((e=>{const A=e.indexOf(":"),n=e.substr(0,A).trim(),a=e.substr(A+1,e.length-A).trim();n&&a&&(i[n]=new tt(t,n,a))})),t.styles[A]=i,t.stylesSpecificity[A]=function(t){const e=[0,0,0];let A=t.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),i=0;return[A,i]=O(A,N),e[1]+=i,[A,i]=O(A,R),e[0]+=i,[A,i]=O(A,H),e[1]+=i,[A,i]=O(A,k),e[2]+=i,[A,i]=O(A,U),e[1]+=i,[A,i]=O(A,G),e[1]+=i,A=A.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),[A,i]=O(A,T),e[2]+=i,e.join("")}(A),"@font-face"===A){const e=i["font-family"].getString().replace(/"|'/g,"");i.src.getString().split(",").forEach((A=>{if(A.indexOf('format("svg")')>0){const i=P(A);i&&new ue(t).load(e,i)}}))}}))}))}}function Ee(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}Be(we,"parseExternalUrl",P);function pe(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function me(t,e,A,i,n,a){return t[A*i*4+4*e+a]}function Ce(t,e,A,i,n,a,r){t[A*i*4+4*e+a]=r}function fe(t,e,A){return t[e]*A}function Qe(t,e,A,i){return e+Math.cos(t)*A+Math.sin(t)*i}class ye extends xt{apply(t,e,A,i,n){const{includeOpacity:a,matrix:r}=this,s=t.getImageData(0,0,i,n);for(let t=0;t<n;t++)for(let e=0;e<i;e++){const A=me(s.data,e,t,i,0,0),n=me(s.data,e,t,i,0,1),o=me(s.data,e,t,i,0,2),c=me(s.data,e,t,i,0,3);let l=fe(r,0,A)+fe(r,1,n)+fe(r,2,o)+fe(r,3,c)+fe(r,4,1),g=fe(r,5,A)+fe(r,6,n)+fe(r,7,o)+fe(r,8,c)+fe(r,9,1),h=fe(r,10,A)+fe(r,11,n)+fe(r,12,o)+fe(r,13,c)+fe(r,14,1),d=fe(r,15,A)+fe(r,16,n)+fe(r,17,o)+fe(r,18,c)+fe(r,19,1);a&&(l=0,g=0,h=0,d*=c/255),Ce(s.data,e,t,i,0,0,l),Ce(s.data,e,t,i,0,1,g),Ce(s.data,e,t,i,0,2,h),Ce(s.data,e,t,i,0,3,d)}t.clearRect(0,0,i,n),t.putImageData(s,0,0)}constructor(t,e,A){super(t,e,A),pe(this,"type","feColorMatrix"),pe(this,"matrix",void 0),pe(this,"includeOpacity",void 0);let i=Y(this.getAttribute("values").getString());switch(this.getAttribute("type").getString("matrix")){case"saturate":{const t=i[0];i=[.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=i[0]*Math.PI/180;i=[Qe(t,.213,.787,-.213),Qe(t,.715,-.715,-.715),Qe(t,.072,-.072,.928),0,0,Qe(t,.213,-.213,.143),Qe(t,.715,.285,.14),Qe(t,.072,-.072,-.283),0,0,Qe(t,.213,-.213,-.787),Qe(t,.715,-.715,.715),Qe(t,.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break}case"luminanceToAlpha":i=[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=i,this.includeOpacity=this.getAttribute("includeOpacity").hasValue()}}function De(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Ie extends xt{apply(t,e){const{document:A}=this;let i=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 Nt;this.children.forEach((A=>{A instanceof zt&&e.addBoundingBox(A.getBoundingBox(t))})),i=Math.floor(e.x1),n=Math.floor(e.y1),a=Math.floor(e.width),r=Math.floor(e.height)}const s=this.removeStyles(e,Ie.ignoreStyles),o=A.createCanvas(i+a,n+r),c=o.getContext("2d");A.screen.setDefaults(c),this.renderChildren(c),new ye(A,{nodeType:1,childNodes:[],attributes:[{nodeName:"type",value:"luminanceToAlpha"},{nodeName:"includeOpacity",value:"true"}]}).apply(c,0,0,i+a,n+r);const l=A.createCanvas(i+a,n+r),g=l.getContext("2d");A.screen.setDefaults(g),e.render(g),g.globalCompositeOperation="destination-in",g.fillStyle=c.createPattern(o,"no-repeat"),g.fillRect(0,0,i+a,n+r),t.fillStyle=g.createPattern(l,"no-repeat"),t.fillRect(0,0,i+a,n+r),this.restoreStyles(e,s)}render(t){}constructor(...t){super(...t),De(this,"type","mask")}}De(Ie,"ignoreStyles",["mask","transform","clip-path"]);const xe=()=>{};function Me(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ve extends xt{apply(t,e,A,i,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,E.canvasRGBA)(o,e,A,i,n,r),s&&s.removeChild(o)}constructor(t,e,A){super(t,e,A),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,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Se extends xt{apply(t,e){const{document:A,children:i}=this,n="getBoundingBox"in e?e.getBoundingBox(t):null;if(!n)return;let a=0,r=0;i.forEach((t=>{if(!(t instanceof ve))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,Se.ignoreStyles),u=A.createCanvas(c,l),B=u.getContext("2d");A.screen.setDefaults(B),B.translate(-g+a,-h+r),e.render(B),i.forEach((t=>{t instanceof ve&&"function"==typeof t.apply&&t.apply(B,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(Se,"ignoreStyles",["filter","transform","clip-path"]);const Ye={svg:Vt,rect:Kt,circle:class extends zt{path(t){const e=this.getAttribute("cx").getPixels("x"),A=this.getAttribute("cy").getPixels("y"),i=this.getAttribute("r").getPixels();return t&&i>0&&(t.beginPath(),t.arc(e,A,i,0,2*Math.PI,!1),t.closePath()),new Nt(e-i,A-i,e+i,A+i)}getMarkers(){return null}constructor(...t){var e,A,i;super(...t),i="circle",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},ellipse:class extends zt{path(t){const e=(Math.sqrt(2)-1)/3*4,A=this.getAttribute("rx").getPixels("x"),i=this.getAttribute("ry").getPixels("y"),n=this.getAttribute("cx").getPixels("x"),a=this.getAttribute("cy").getPixels("y");return t&&A>0&&i>0&&(t.beginPath(),t.moveTo(n+A,a),t.bezierCurveTo(n+A,a+e*i,n+e*A,a+i,n,a+i),t.bezierCurveTo(n-e*A,a+i,n-A,a+e*i,n-A,a),t.bezierCurveTo(n-A,a-e*i,n-e*A,a-i,n,a-i),t.bezierCurveTo(n+e*A,a-i,n+A,a-e*i,n+A,a),t.closePath()),new Nt(n-A,a-i,n+A,a+i)}getMarkers(){return null}constructor(...t){var e,A,i;super(...t),i="ellipse",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},line:class extends zt{getPoints(){return[new at(this.getAttribute("x1").getPixels("x"),this.getAttribute("y1").getPixels("y")),new at(this.getAttribute("x2").getPixels("x"),this.getAttribute("y2").getPixels("y"))]}path(t){const[{x:e,y:A},{x:i,y:n}]=this.getPoints();return t&&(t.beginPath(),t.moveTo(e,A),t.lineTo(i,n)),new Nt(e,A,i,n)}getMarkers(){const[t,e]=this.getPoints(),A=t.angleTo(e);return[[t,A],[e,A]]}constructor(...t){var e,A,i;super(...t),i="line",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},polyline:Xt,polygon:class extends Xt{path(t){const e=super.path(t),[{x:A,y:i}]=this.points;return t&&(t.lineTo(A,i),t.closePath()),e}constructor(...t){var e,A,i;super(...t),i="polygon",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},path:zt,pattern:class extends xt{createPattern(t,e,A){const i=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):i,o=r.hasValue()?r.getPixels("y",!0):n,c=a.hasValue()&&r.hasValue(),l=new Vt(this.document,void 0);l.attributes.viewBox=new tt(this.document,"viewBox",this.getAttribute("viewBox").getValue()),l.attributes.width=new tt(this.document,"width",`${s}px`),l.attributes.height=new tt(this.document,"height",`${o}px`),l.attributes.transform=new tt(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)),A.hasValue()?this.styles["fill-opacity"]=A: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 tt(this.document,"x",t*g.width),l.attributes.y=new tt(this.document,"y",e*g.height),l.render(h),h.restore();return t.createPattern(g,c?"no-repeat":"repeat")}constructor(...t){var e,A,i;super(...t),i="pattern",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},marker:class extends xt{render(t,e,A){if(!e)return;const{x:i,y:n}=e,a=this.getAttribute("orient").getString("auto"),r=this.getAttribute("markerUnits").getString("strokeWidth");t.translate(i,n),"auto"===a&&A&&t.rotate(A),"strokeWidth"===r&&t.scale(t.lineWidth,t.lineWidth),t.save();const s=new Vt(this.document);s.type=this.type,s.attributes.viewBox=new tt(this.document,"viewBox",this.getAttribute("viewBox").getValue()),s.attributes.refX=new tt(this.document,"refX",this.getAttribute("refX").getValue()),s.attributes.refY=new tt(this.document,"refY",this.getAttribute("refY").getValue()),s.attributes.width=new tt(this.document,"width",this.getAttribute("markerWidth").getValue()),s.attributes.height=new tt(this.document,"height",this.getAttribute("markerHeight").getValue()),s.attributes.overflow=new tt(this.document,"overflow",this.getAttribute("overflow").getValue()),s.attributes.fill=new tt(this.document,"fill",this.getAttribute("fill").getColor("black")),s.attributes.stroke=new tt(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&&A&&t.rotate(-A),t.translate(-i,-n)}constructor(...t){var e,A,i;super(...t),i="marker",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},defs:class extends xt{render(){}constructor(...t){var e,A,i;super(...t),i="defs",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},linearGradient:class extends $t{getGradient(t,e){const A="objectBoundingBox"===this.getGradientUnits(),i=A?e.getBoundingBox(t):null;if(A||!i)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=A?i.x+i.width*this.getAttribute("x1").getNumber():this.getAttribute("x1").getPixels("x"),a=A?i.y+i.height*this.getAttribute("y1").getNumber():this.getAttribute("y1").getPixels("y"),r=A?i.x+i.width*this.getAttribute("x2").getNumber():this.getAttribute("x2").getPixels("x"),s=A?i.y+i.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,A){var i,n,a;super(t,e,A),a="linearGradient",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.attributesToInherit.push("x1","y1","x2","y2")}},radialGradient:class extends $t{getGradient(t,e){const A="objectBoundingBox"===this.getGradientUnits(),i=e.getBoundingBox(t);if(A&&!i)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=A?i.x+i.width*this.getAttribute("cx").getNumber():this.getAttribute("cx").getPixels("x"),a=A?i.y+i.height*this.getAttribute("cy").getNumber():this.getAttribute("cy").getPixels("y");let r=n,s=a;this.getAttribute("fx").hasValue()&&(r=A?i.x+i.width*this.getAttribute("fx").getNumber():this.getAttribute("fx").getPixels("x")),this.getAttribute("fy").hasValue()&&(s=A?i.y+i.height*this.getAttribute("fy").getNumber():this.getAttribute("fy").getPixels("y"));const o=A?(i.width+i.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,A){var i,n,a;super(t,e,A),a="radialGradient",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.attributesToInherit.push("cx","cy","r","fx","fy","fr")}},stop:class extends xt{constructor(t,e,A){super(t,e,A),_t(this,"type","stop"),_t(this,"offset",void 0),_t(this,"color",void 0);const i=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=i,this.color=a.getColor()}},animate:ee,animateColor:class extends ee{calcValue(){const{progress:t,from:e,to:A}=this.getProgress(),i=new(F(B))(e.getColor()),n=new(F(B))(A.getColor());if(i.ok&&n.ok){const e=i.r+(n.r-i.r)*t,A=i.g+(n.g-i.g)*t,a=i.b+(n.b-i.b)*t;return`rgb(${Math.floor(e)}, ${Math.floor(A)}, ${Math.floor(a)})`}return this.getAttribute("from").getColor()}constructor(...t){var e,A,i;super(...t),i="animateColor",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},animateTransform:class extends ee{calcValue(){const{progress:t,from:e,to:A}=this.getProgress(),i=Y(e.getString()),n=Y(A.getString()),a=i.map(((e,A)=>e+(n[A]-e)*t)).join(" ");return a}constructor(...t){var e,A,i;super(...t),i="animateTransform",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},font:class extends xt{render(){}constructor(t,e,A){super(t,e,A),oe(this,"type","font"),oe(this,"isArabic",!1),oe(this,"missingGlyph",void 0),oe(this,"glyphs",{}),oe(this,"arabicGlyphs",{}),oe(this,"horizAdvX",void 0),oe(this,"isRTL",!1),oe(this,"fontFace",void 0),this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber();const{definitions:i}=t,{children:n}=this;for(const t of n)if(t instanceof ie){this.fontFace=t;const e=t.getStyle("font-family");e.hasValue()&&(i[e.getString()]=this)}else if(t instanceof se)this.missingGlyph=t;else if(t instanceof ae)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":ie,"missing-glyph":se,glyph:ae,text:kt,tspan:Gt,tref:class extends kt{getText(){const t=this.getHrefAttribute().getDefinition();if(t){const e=t.children[0];if(e)return e.getText()}return""}constructor(...t){var e,A,i;super(...t),i="tref",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},a:class extends kt{getText(){return this.text}renderChildren(t){if(this.hasText){super.renderChildren(t);const{document:e,x:A,y:i}=this,{mouse:n}=e.screen,a=new tt(e,"fontSize",bt.parse(e.ctx.font).fontSize);n.isWorking()&&n.checkBoundingBox(this,new Nt(A,i-a.getPixels("y"),A+this.measureText(t),i))}else if(this.children.length>0){const e=new qt(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,A){super(t,e,A),ce(this,"type","a"),ce(this,"hasText",void 0),ce(this,"text",void 0);const{childNodes:i}=e,n=i[0],a=i.length>0&&Array.from(i).every((t=>3===t.nodeType));this.hasText=a,this.text=a?this.getTextFromNode(n):""}},textPath:class extends kt{getText(){return this.text}path(t){const{dataArray:e}=this;t&&t.beginPath(),e.forEach((e=>{let{type:A,points:i}=e;switch(A){case Jt.LINE_TO:t&&t.lineTo(i[0],i[1]);break;case Jt.MOVE_TO:t&&t.moveTo(i[0],i[1]);break;case Jt.CURVE_TO:t&&t.bezierCurveTo(i[0],i[1],i[2],i[3],i[4],i[5]);break;case Jt.QUAD_TO:t&&t.quadraticCurveTo(i[0],i[1],i[2],i[3]);break;case Jt.ARC:{const[e,A,n,a,r,s,o,c]=i,l=n>a?n:a,g=n>a?1:n/a,h=n>a?a/n:1;t&&(t.translate(e,A),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,-A));break}case Jt.CLOSE_PATH:t&&t.closePath()}}))}renderChildren(t){var e;this.setTextData(t),t.save();const A=null===(e=this.parent)||void 0===e?void 0:e.getStyle("text-decoration").getString(),i=this.getFontSize(),{glyphInfo:n}=this,a=t.fillStyle;"underline"===A&&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"===A&&(0===n&&t.moveTo(a.x,a.y+i/8),t.lineTo(r.x,r.y+i/5))})),"underline"===A&&(t.lineWidth=i/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,A,i,n,a,r,s,o){let c=a,l=this.measureText(t,s);" "===s&&"justify"===e&&A<i&&(l+=(i-A)/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},B=h&&d?Math.atan2(d.y-h.y,d.x-h.x):0;if(r){const t=Math.cos(Math.PI/2+B)*r,e=Math.cos(-B)*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:B}}measureText(t,e){const{measuresCache:A}=this,i=e||this.getText();if(A.has(i))return A.get(i);const n=this.measureTargetText(t,i);return A.set(i,n),n}setTextData(t){var e,A,i;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===(A=this.parent)||void 0===A?void 0:A.getAttribute("dy").getPixels("y"),c=this.getAttribute("text-anchor").getString("start"),l=this.getStyle("letter-spacing"),g=null===(i=this.parent)||void 0===i?void 0:i.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 B=d.reduce(((t,e,A)=>0===A?0:t+e||0),0),w=this.measureText(t),E=Math.max(w+B,0);this.textWidth=w,this.textHeight=this.getFontSize(),this.glyphInfo=[];const p=this.getPathLength(),m=this.getAttribute("startOffset").getNumber(0)*p;let C=0;"middle"!==c&&"center"!==c||(C=-E/2),"end"!==c&&"right"!==c||(C=-E),C+=m,a.forEach(((e,A)=>{const{offset:i,segment:n,rotation:s}=this.findSegmentToFitChar(t,c,E,p,r,C,o,e,A);C=i,n.p0&&n.p1&&this.glyphInfo.push({text:a[A],p0:n.p0,p1:n.p1,rotation:s})}))}parsePathData(t){if(this.pathLength=-1,!t)return[];const e=[],{pathParser:A}=t;for(A.reset();!A.isEnd();){const{current:t}=A,i=t?t.x:0,n=t?t.y:0,a=A.next();let r=a.type,s=[];switch(a.type){case Jt.MOVE_TO:this.pathM(A,s);break;case Jt.LINE_TO:r=this.pathL(A,s);break;case Jt.HORIZ_LINE_TO:r=this.pathH(A,s);break;case Jt.VERT_LINE_TO:r=this.pathV(A,s);break;case Jt.CURVE_TO:this.pathC(A,s);break;case Jt.SMOOTH_CURVE_TO:r=this.pathS(A,s);break;case Jt.QUAD_TO:this.pathQ(A,s);break;case Jt.SMOOTH_QUAD_TO:r=this.pathT(A,s);break;case Jt.ARC:s=this.pathA(A);break;case Jt.CLOSE_PATH:zt.pathZ(A)}a.type!==Jt.CLOSE_PATH?e.push({type:r,points:s,start:{x:i,y:n},pathLength:this.calcLength(i,n,r,s)}):e.push({type:Jt.CLOSE_PATH,points:[],pathLength:0})}return e}pathM(t,e){const{x:A,y:i}=zt.pathM(t).point;e.push(A,i)}pathL(t,e){const{x:A,y:i}=zt.pathL(t).point;return e.push(A,i),Jt.LINE_TO}pathH(t,e){const{x:A,y:i}=zt.pathH(t).point;return e.push(A,i),Jt.LINE_TO}pathV(t,e){const{x:A,y:i}=zt.pathV(t).point;return e.push(A,i),Jt.LINE_TO}pathC(t,e){const{point:A,controlPoint:i,currentPoint:n}=zt.pathC(t);e.push(A.x,A.y,i.x,i.y,n.x,n.y)}pathS(t,e){const{point:A,controlPoint:i,currentPoint:n}=zt.pathS(t);return e.push(A.x,A.y,i.x,i.y,n.x,n.y),Jt.CURVE_TO}pathQ(t,e){const{controlPoint:A,currentPoint:i}=zt.pathQ(t);e.push(A.x,A.y,i.x,i.y)}pathT(t,e){const{controlPoint:A,currentPoint:i}=zt.pathT(t);return e.push(A.x,A.y,i.x,i.y),Jt.QUAD_TO}pathA(t){let{rX:e,rY:A,sweepFlag:i,xAxisRotation:n,centp:a,a1:r,ad:s}=zt.pathA(t);return 0===i&&s>0&&(s-=2*Math.PI),1===i&&s<0&&(s+=2*Math.PI),[a.x,a.y,e,A,r,s,n,i]}calcLength(t,e,A,i){let n=0,a=null,r=null,s=0;switch(A){case Jt.LINE_TO:return this.getLineLength(t,e,i[0],i[1]);case Jt.CURVE_TO:for(n=0,a=this.getPointOnCubicBezier(0,t,e,i[0],i[1],i[2],i[3],i[4],i[5]),s=.01;s<=1;s+=.01)r=this.getPointOnCubicBezier(s,t,e,i[0],i[1],i[2],i[3],i[4],i[5]),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return n;case Jt.QUAD_TO:for(n=0,a=this.getPointOnQuadraticBezier(0,t,e,i[0],i[1],i[2],i[3]),s=.01;s<=1;s+=.01)r=this.getPointOnQuadraticBezier(s,t,e,i[0],i[1],i[2],i[3]),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return n;case Jt.ARC:{n=0;const t=i[4],e=i[5],A=i[4]+e;let o=Math.PI/180;if(Math.abs(t-A)<o&&(o=Math.abs(t-A)),a=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],t,0),e<0)for(s=t-o;s>A;s-=o)r=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],s,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;else for(s=t+o;s<A;s+=o)r=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],s,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return r=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],A,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),n}}return 0}getPointOnLine(t,e,A,i,n){let a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:A;const s=(n-A)/(i-e+J);let o=Math.sqrt(t*t/(1+s*s));i<e&&(o*=-1);let c=s*o,l=null;if(i===e)l={x:a,y:r+c};else if((r-A)/(a-e+J)===s)l={x:a+o,y:r+c};else{let g=0,h=0;const d=this.getLineLength(e,A,i,n);if(d<J)return null;let u=(a-e)*(i-e)+(r-A)*(n-A);u/=d*d,g=e+u*(i-e),h=A+u*(n-A);const B=this.getLineLength(a,r,g,h),w=Math.sqrt(t*t-B*B);o=Math.sqrt(w*w/(1+s*s)),i<e&&(o*=-1),c=s*o,l={x:g+o,y:h+c}}return l}getPointOnPath(t){const e=this.getPathLength();let A=0,i=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||A+e.pathLength+5e-5<t)){A+=e.pathLength;continue}const n=t-A;let a=0;switch(e.type){case Jt.LINE_TO:i=this.getPointOnLine(n,e.start.x,e.start.y,e.points[0],e.points[1],e.start.x,e.start.y);break;case Jt.ARC:{const t=e.points[4],A=e.points[5],r=e.points[4]+A;if(a=t+n/e.pathLength*A,A<0&&a<r||A>=0&&a>r)break;i=this.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],a,e.points[6]);break}case Jt.CURVE_TO:a=n/e.pathLength,a>1&&(a=1),i=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 Jt.QUAD_TO:a=n/e.pathLength,a>1&&(a=1),i=this.getPointOnQuadraticBezier(a,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3])}if(i)return i;break}return null}getLineLength(t,e,A,i){return Math.sqrt((A-t)*(A-t)+(i-e)*(i-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,A,i,n,a,r,s,o){return{x:s*V(t)+a*K(t)+i*W(t)+e*X(t),y:o*V(t)+r*K(t)+n*W(t)+A*X(t)}}getPointOnQuadraticBezier(t,e,A,i,n,a,r){return{x:a*q(t)+i*Z(t)+e*$(t),y:r*q(t)+n*Z(t)+A*$(t)}}getPointOnEllipticalArc(t,e,A,i,n,a){const r=Math.cos(a),s=Math.sin(a),o=A*Math.cos(n),c=i*Math.sin(n);return{x:t+(o*r-c*s),y:e+(o*s+c*r)}}buildEquidistantCache(t,e){const A=this.getPathLength(),i=e||.25,n=t||A/100;if(!this.equidistantCache||this.equidistantCache.step!==n||this.equidistantCache.precision!==i){this.equidistantCache={step:n,precision:i,points:[]};let t=0;for(let e=0;e<=A;e+=i){const A=this.getPointOnPath(e),a=this.getPointOnPath(e+i);A&&a&&(t+=this.getLineLength(A.x,A.y,a.x,a.y),t>=n&&(this.equidistantCache.points.push({x:A.x,y:A.y,distance:e}),t-=n))}}}getEquidistantPointOnPath(t,e,A){if(this.buildEquidistantCache(e,A),t<0||t-this.getPathLength()>5e-5)return null;const i=Math.round(t/this.getPathLength()*(this.equidistantCache.points.length-1));return this.equidistantCache.points[i]||null}constructor(t,e,A){super(t,e,A),le(this,"type","textPath"),le(this,"textWidth",0),le(this,"textHeight",0),le(this,"pathLength",-1),le(this,"glyphInfo",null),le(this,"text",void 0),le(this,"dataArray",void 0),le(this,"letterSpacingCache",[]),le(this,"equidistantCache",null),le(this,"measuresCache",new Map([["",0]]));const i=this.getHrefAttribute().getDefinition();this.text=this.getTextFromNode(),this.dataArray=this.parsePathData(i)}},image:class extends Rt{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=he.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),A=await e.text();this.image=A}catch(e){console.error(`Error while loading image "${t}":`,e)}this.loaded=!0}renderChildren(t){const{document:e,image:A,loaded:i}=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(i&&A&&r&&s){if(t.save(),t.translate(n,a),"string"==typeof A){const i=e.pith.forkString(t,A,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:0,offsetY:0,scaleWidth:r,scaleHeight:s}),{documentElement:n}=i.document;n&&(n.parent=this),i.resize(r,s,this.getAttribute("preserveAspectRatio").getString()),i.render()}else e.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:r,desiredWidth:A.width,height:s,desiredHeight:A.height}),this.loaded&&("complete"in A&&!A.complete||t.drawImage(A,0,0));t.restore()}}getBoundingBox(){const t=this.getAttribute("x").getPixels("x"),e=this.getAttribute("y").getPixels("y"),A=this.getStyle("width").getPixels("x"),i=this.getStyle("height").getPixels("y");return new Nt(t,e,t+A,e+i)}constructor(t,e,A){super(t,e,A),ge(this,"type","image"),ge(this,"loaded",!1),ge(this,"image",void 0);const i=this.getHrefAttribute().getString();if(!i)return;const n=i.endsWith(".svg")||/^\s*data:image\/svg\+xml/i.test(i);t.images.push(this),n?this.loadSvg(i):this.loadImage(i)}},g:qt,symbol:class extends Rt{render(t){}constructor(...t){var e,A,i;super(...t),i="symbol",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},style:we,use:class extends Rt{setContext(t){super.setContext(t);const e=this.getAttribute("x"),A=this.getAttribute("y");e.hasValue()&&t.translate(e.getPixels("x"),0),A.hasValue()&&t.translate(0,A.getPixels("y"))}path(t){const{element:e}=this;e&&e.path(t)}renderChildren(t){const{document:e,element:A}=this;if(A){let i=A;if("symbol"===A.type&&(i=new Vt(e),i.attributes.viewBox=new tt(e,"viewBox",A.getAttribute("viewBox").getString()),i.attributes.preserveAspectRatio=new tt(e,"preserveAspectRatio",A.getAttribute("preserveAspectRatio").getString()),i.attributes.overflow=new tt(e,"overflow",A.getAttribute("overflow").getString()),i.children=A.children,A.styles.opacity=new tt(e,"opacity",this.calculateOpacity())),"svg"===i.type){const t=this.getStyle("width",!1,!0),A=this.getStyle("height",!1,!0);t.hasValue()&&(i.attributes.width=new tt(e,"width",t.getString())),A.hasValue()&&(i.attributes.height=new tt(e,"height",A.getString()))}const n=i.parent;i.parent=this,i.render(t),i.parent=n}}getBoundingBox(t){const{element:e}=this;return e?e.getBoundingBox(t):null}elementTransform(){const{document:t,element:e}=this;return e?Dt.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:Ie,clipPath:class extends xt{apply(t){const{document:e}=this,A=Reflect.getPrototypeOf(t),{beginPath:i,closePath:n}=t;A&&(A.beginPath=xe,A.closePath=xe),Reflect.apply(i,t,[]),this.children.forEach((i=>{if(!("path"in i))return;let a="elementTransform"in i?i.elementTransform():null;a||(a=Dt.fromElement(e,i)),a&&a.apply(t),i.path(t),A&&(A.closePath=n),a&&a.unapply(t)})),Reflect.apply(n,t,[]),t.clip(),A&&(A.beginPath=i,A.closePath=n)}render(t){}constructor(...t){var e,A,i;super(...t),i="clipPath",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},filter:Se,feDropShadow:class extends xt{apply(t,e,A,i,n){}constructor(t,e,A){var i,n,a;super(t,e,A),a="feDropShadow",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.addStylesFromStyleDefinition()}},feMorphology:class extends xt{apply(t,e,A,i,n){}constructor(...t){var e,A,i;super(...t),i="feMorphology",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},feComposite:class extends xt{apply(t,e,A,i,n){}constructor(...t){var e,A,i;super(...t),i="feComposite",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},feColorMatrix:ye,feGaussianBlur:ve,title:class extends xt{constructor(...t){var e,A,i;super(...t),i="title",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},desc:class extends xt{constructor(...t){var e,A,i;super(...t),i="desc",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}};function be(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Pe{bindCreateImage(t,e){return"boolean"==typeof e?(A,i)=>t(A,"boolean"==typeof i?i: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(/^[^:]+:/,""),A=Pe.elementTypes[e];return A?new A(this,t):new Mt(this,t)}createTextNode(t){return new Tt(this,t)}setViewBox(t){this.screen.setViewBox({document:this,...t})}constructor(t,{rootEmSize:e=12,emSize:A=12,createCanvas:i=Pe.createCanvas,createImage:n=Pe.createImage,anonymousCrossOrigin:a}={}){be(this,"pith",void 0),be(this,"rootEmSize",void 0),be(this,"documentElement",void 0),be(this,"screen",void 0),be(this,"createCanvas",void 0),be(this,"createImage",void 0),be(this,"definitions",void 0),be(this,"styles",void 0),be(this,"stylesSpecificity",void 0),be(this,"images",void 0),be(this,"fonts",void 0),be(this,"emSizeStack",void 0),be(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=A,this.createCanvas=i,this.createImage=this.bindCreateImage(n,a),this.screen.wait((()=>this.isImagesLoaded())),this.screen.wait((()=>this.isFontsLoaded()))}}function Ne(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}be(Pe,"createCanvas",(function(t,e){const A=document.createElement("canvas");return A.width=t,A.height=e,A})),be(Pe,"createImage",(async function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const A=document.createElement("img");return e&&(A.crossOrigin="Anonymous"),new Promise(((e,i)=>{A.onload=()=>{e(A)},A.onerror=(t,e,A,n,a)=>{i(a)},A.src=t}))})),be(Pe,"elementTypes",Ye);class Re{static async from(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=new Bt(A),n=await i.parse(e);return new Re(t,n,A)}static fromString(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=new Bt(A).parseFromString(e);return new Re(t,i,A)}fork(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Re.from(t,e,{...this.options,...A})}forkString(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Re.fromString(t,e,{...this.options,...A})}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:A,options:i}=this;A.start(e,{enableRedraw:!0,...i,...t})}stop(){this.screen.stop()}resize(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,A=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.documentElement.resize(t,e,A)}constructor(t,e,A={}){Ne(this,"parser",void 0),Ne(this,"screen",void 0),Ne(this,"document",void 0),Ne(this,"documentElement",void 0),Ne(this,"options",void 0),this.parser=new Bt(A),this.screen=new gt(t,A),this.options=A;const i=new Pe(this,A),n=i.createDocumentElement(e);this.document=i,this.documentElement=n}}function He(t,e,A,i){Object.defineProperty(t,e,{get:A,set:i,enumerable:!0,configurable:!0})}var ke="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==v?v:{},Ue={};He(Ue,"CanvasCommand",(()=>Vi)),He(Ue,"UpdateWorkflowStateCommand",(()=>Ki)),He(Ue,"MoveCommand",(()=>Wi)),He(Ue,"RotateCommand",(()=>Xi)),He(Ue,"ResizeCommand",(()=>qi)),He(Ue,"GroupCommand",(()=>Zi)),He(Ue,"CreateLayoutCommand",(()=>$i)),He(Ue,"ClearLayoutCommand",(()=>_i)),He(Ue,"CreateElementCommand",(()=>tn)),He(Ue,"DeleteElementCommand",(()=>en)),He(Ue,"CloneElementCommand",(()=>An)),He(Ue,"FontColorCommand",(()=>nn)),He(Ue,"FontImageFillCommand",(()=>an)),He(Ue,"FontSizeCommand",(()=>rn)),He(Ue,"FontAlgorithmCommand",(()=>sn)),He(Ue,"FontSourceCommand",(()=>on)),He(Ue,"FontAlignmentCommand",(()=>cn)),He(Ue,"UpdateFramePattern",(()=>ln)),He(Ue,"TextChangeCommand",(()=>gn)),He(Ue,"IllustrationColorCommand",(()=>hn)),He(Ue,"IllustrationCacheCommand",(()=>dn)),He(Ue,"BringToFrontCommand",(()=>un)),He(Ue,"BringToBackCommand",(()=>Bn)),He(Ue,"BringForwardCommand",(()=>wn)),He(Ue,"SendBackwardsCommand",(()=>En)),He(Ue,"LayerCommand",(()=>pn)),He({},"generate",(()=>Ge));const Ge=()=>{const t=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()};var Te={};He(Te,"ElementNotFoundError",(()=>Oi)),He(Te,"findElement",(()=>Ji)),He(Te,"findLayoutForElement",(()=>Li)),He(Te,"updatedLayoutForElement",(()=>zi)),He(Te,"rehydrateSerializedLayout",(()=>ji));var Oe={};He(Oe,"CommandContext",(()=>ki)),He(Oe,"getSvgElement",(()=>Gi)),He(Oe,"elementFactory",(()=>Ui)),He(Oe,"sortElementsByLayersWithIndex",(()=>Ti)),He({},"SVGLayout",(()=>sA));var Je={};let Le;var ze;let je;var Ve;let Ke;var We;let Xe;var qe;let Ze;var $e;let _e;var tA;let eA;var AA;let iA;var nA;let aA;var rA;He(Je,"LayoutElementType",(()=>Le)),He(Je,"LayoutRenderingPurpose",(()=>je)),He(Je,"TextAlgorithm",(()=>Ke)),He(Je,"UnitOfMeasurement",(()=>Xe)),He(Je,"ScaleAxis",(()=>Ze)),He(Je,"MaterialEffectMode",(()=>_e)),He(Je,"AssetType",(()=>eA)),He(Je,"StepType",(()=>iA)),He(Je,"StepAspectType",(()=>aA)),(ze=Le||(Le={})).Frame="frame",ze.Image="image",ze.Illustration="illustration",ze.Textbox="textbox",(Ve=je||(je={})).ThreeD="ThreeD",Ve.FreeDesign="FreeDesign",Ve.Print="Print",(We=Ke||(Ke={})).Autosize="Autosize",We.Traditional="Traditional",(qe=Xe||(Xe={})).Pixel="px",qe.Millimeter="mm",qe.Centimeter="cm",($e=Ze||(Ze={}))[$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",(tA=_e||(_e={})).None="None",tA.RemoveWhenSelected="RemoveWhenSelected",tA.ApplyWhenSelected="ApplyWhenSelected",(AA=eA||(eA={})).Font="Font",AA.Frame="Frame",AA.Illustration="Illustration",AA.Image="Image",AA.Model="Model",AA.Material="Material",AA.Color="Color",AA.QuestionnaireCollateral="QuestionnaireCollateral",AA.RequestCollateral="RequestCollateral",AA.SignupCollateral="SignupCollateral",AA.Video="Video",AA.ColorProfile="ColorProfile",(nA=iA||(iA={})).Bulk="Bulk",nA.DigitalContent="DigitalContent",nA.Finish="Finish",nA.Frame="Frame",nA.Illustration="Illustration",nA.Introduction="Introduction",nA.Material="Material",nA.Model="Model",nA.Module="Module",nA.Picture="Picture",nA.Photo="Photo",nA.ProductOverlay="ProductOverlay",nA.Question="Question",nA.Shape="Shape",nA.SilentIllustration="SilentIllustration",nA.Text="Text",(rA=aA||(aA={})).Color="Color",rA.Colors="Colors",rA.Selection="Selection",rA.Selections="Selections",rA.Text="Text",rA.Upload="Upload";const sA=({backgroundColor:t,outlineColor:e,borderRadius:i,configuration:n,elements:a,height:r,maxHeight:s,maxWidth:o,outlineArea:c,position:l,preserveAspectRatio:g,viewBox:h,width:d})=>{const u=i||0,B=2*(c?.scale||1),w=h||{x:0,y:0,width:d,height:r},E=`${w.x} ${w.y} ${w.width} ${w.height}`,p=Ge(),m=n.purpose===je.FreeDesign&&(0,A.jsx)("defs",{children:(0,A.jsx)("clipPath",{id:"viewboxClip",children:(0,A.jsx)("rect",{width:w.width,height:w.height,rx:u})})}),C=n.colorProfiles?.map(((t,e)=>(0,A.jsx)("color-profile",{name:t.name,xlinkHref:t.key,children:" "},e))),f=Ti(a.map((t=>({...t,_renderingConfiguration:n,mask:c?`url(#viewmask-${p})`:void 0}))));return(0,A.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:E,children:[C,m,!!t&&(0,A.jsx)("rect",{id:"layout-background",width:w.width,height:w.height,fill:t,rx:u}),(0,A.jsx)("g",{id:"element-group",clipPath:n.purpose===je.FreeDesign?"url(#viewboxClip)":void 0,children:f.map((t=>Ui(t))).filter((t=>!!t))}),c&&(0,A.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"none",stroke:c.hidden?"none":e||"#aaaaaa",strokeWidth:B/2,strokeDasharray:`${2*B} ${B}`}),c&&(0,A.jsxs)("mask",{id:`viewmask-${p}`,children:[(0,A.jsx)("rect",{x:w.x,y:w.y,width:w.width,height:w.height,fill:"black"}),(0,A.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"white"})]})]})};He({},"Image",(()=>xA));var oA={};He(oA,"getAxisAlignedBoundingBox",(()=>cA)),He(oA,"degreesToRadians",(()=>gA)),He(oA,"findAngle",(()=>lA)),He(oA,"radiansToDegrees",(()=>hA)),He(oA,"isCloseToValue",(()=>dA)),He(oA,"getTrueCoordinates",(()=>uA)),He(oA,"getPointOfRotation",(()=>BA)),He(oA,"getNWPoint",(()=>wA)),He(oA,"getNEPoint",(()=>EA)),He(oA,"getSWPoint",(()=>pA)),He(oA,"getSEPoint",(()=>mA)),He(oA,"turnRightClockwise",(()=>CA)),He(oA,"currentDirection",(()=>fA)),He(oA,"getElementVertices",(()=>QA)),He(oA,"rotateAroundPoint",(()=>yA)),He(oA,"mmPerPixel",(()=>DA)),He(oA,"cmPerPixel",(()=>IA));const cA=(t,e,A,i,n)=>{const a=gA(n),r=A/2,s=i/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,B=r*l+h*g,w=r*l+s*g,E=Math.max(Math.abs(d),Math.abs(u)),p=Math.max(Math.abs(B),Math.abs(w));return{minX:o-E,maxX:o+E,minY:c-p,maxY:c+p}},lA=(t,e,A)=>{const i=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),n=Math.sqrt(Math.pow(e.x-A.x,2)+Math.pow(e.y-A.y,2)),a=Math.sqrt(Math.pow(A.x-t.x,2)+Math.pow(A.y-t.y,2));return Math.acos((n*n+i*i-a*a)/(2*n*i))*(180/Math.PI)},gA=t=>t*(Math.PI/180),hA=t=>t*(180/Math.PI),dA=(t,e,A)=>Math.abs(t-e)<A,uA=(t,e,A)=>{const i=Math.sin(gA(A)),n=Math.cos(gA(A));return{x:(t.x-e.x)*n-(t.y-e.y)*i+e.x,y:(t.x-e.x)*i+(t.y-e.y)*n+e.y}},BA=(t,e)=>({x:(t.x+e.x)/2,y:(t.y+e.y)/2}),wA=(t,e,A,i)=>({x:t.x+e?.x*A,y:t.y+e?.y*i}),EA=(t,e,A,i)=>({x:t.x+(e?.x+e?.width)*A,y:t.y+e?.y*i}),pA=(t,e,A,i)=>({x:t.x+e?.x*A,y:t.y+(e?.y+e?.height)*i}),mA=(t,e,A,i)=>({x:t.x+(e?.x+e?.width)*A,y:t.y+(e?.y+e?.height)*i}),CA=t=>{switch(t){case Ze.North:return Ze.East;case Ze.East:return Ze.South;case Ze.South:return Ze.West;case Ze.West:return Ze.North;case Ze.Northwest:return Ze.Northeast;case Ze.Northeast:return Ze.Southeast;case Ze.Southeast:return Ze.Southwest;case Ze.Southwest:return Ze.Northwest}},fA=(t,e)=>e>45&&e<=135?CA(t):e>135&&e<=225?CA(CA(t)):e>225&&e<=315?CA(CA(CA(t))):t,QA=(t,e={x:0,y:0},A={x:1,y:1})=>{const i=gA(t.rotation),n={x:e.x+t.x*A.x,y:e.x+t.y*A.y},a={x:t.x+t.width,y:t.y},r={x:e.x+(t.x+t.width)*A.x,y:e.y+(t.height+t.y)*A.y},s={x:e.x+t.x*A.x,y:e.y+(t.height+t.y)*A.y},o={x:(s.x+r.x)/2,y:s.y-t.height*A.y/2};return{a:yA(n,o,i),b:yA(a,o,i),c:yA(r,o,i),d:yA(s,o,i),center:o}},yA=(t,e,A)=>{const i=Math.sin(A),n=Math.cos(A);return{x:(t.x-e.x)*n-(t.y-e.y)*i+e.x,y:(t.x-e.x)*i+(t.y-e.y)*n+e.y}},DA=.352778,IA=.035277,xA=t=>{const e=t.rotation||0,i=gA(e),n=Math.cos(i),a=-Math.sin(i);return(0,A.jsx)("g",{mask:t.stepName||t.productOverlay?void 0:t.mask,children:(0,A.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,A.jsx)("image",{xlinkHref:t.src,preserveAspectRatio:t.preserveAspectRatio,width:t.width,height:t.height})})})};He({},"Frame",(()=>MA));const MA=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,A.jsx)(F(i).Fragment,{});const o=!!t.focalBlur&&!!t.pattern,c=t.rotation||0,l=gA(c),g=Math.cos(l),h=-Math.sin(l);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("defs",{children:(i=>{const o=t.pattern?.x||0,c=t.pattern?.y||0,l=t.pattern?t.pattern.width*t.pattern.scaleX+Math.abs(o):256,g=t.pattern?t.pattern.height*t.pattern.scaleY+Math.abs(c):256,h=t.pattern?t.pattern.width*t.pattern.scaleX:256,d=t.pattern?t.pattern.height*t.pattern.scaleY:256;return(0,A.jsxs)("g",{mask:t.stepName?void 0:t.mask,children:[(0,A.jsx)("pattern",{patternUnits:t.pattern?void 0:"userSpaceOnUse",x:0,y:0,width:t.pattern?1:l,height:t.pattern?1:g,"data-frame-width":t.pattern?l:void 0,"data-frame-height":t.pattern?g:void 0,id:e,children:(0,A.jsx)("image",{preserveAspectRatio:"none",x:o,y:c,width:h,height:d,xlinkHref:s()})}),i?(0,A.jsx)(vA,{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,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.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,A.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,A.jsx)("path",{mask:`url(#${r})`,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}):void 0]})})]})},vA=t=>{const{path:e,width:i,height:n,focalBlurStrength:a,focalBlurRadius:r,blurFilterId:s,focalMaskId:o,blurEdgeClipId:c}=t;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("filter",{id:s,children:(0,A.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,A.jsx)("mask",{id:o,children:(0,A.jsx)("circle",{cx:i/2,cy:n/2,r:r||0,fill:"white",filter:`url(#${s})`})}),(0,A.jsx)("mask",{id:c,children:(0,A.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};He({},"Textbox",(()=>Mi));var FA={};He(FA,"fontSizeStep",(()=>hi)),He(FA,"textWidth",(()=>di)),He(FA,"charWidth",(()=>ui)),He(FA,"lineWidth",(()=>Bi)),He(FA,"applyTextTransformations",(()=>Ei)),He(FA,"zip",(()=>pi)),He(FA,"getTextAlignment",(()=>mi)),He(FA,"getAnchor",(()=>Ci)),He(FA,"recomputeTextOnElement",(()=>fi)),He(FA,"defaultLineHeightFactor",(()=>Qi));var SA={};He(SA,"refitTextbox",(()=>li)),He(SA,"recalculateTextboxRegion",(()=>gi));var YA={};He(YA,"FontMetrics",(()=>ti)),He(YA,"loadFontFromExternalUrl",(()=>Ai)),He(YA,"loadFontFromDataUrl",(()=>ii)),He(YA,"getFontMetrics",(()=>ni));var bA={};He(bA,"registerJSDOM",(()=>RA)),He(bA,"createElement",(()=>GA)),He(bA,"createElementNS",(()=>TA)),He(bA,"domParser",(()=>OA)),He(bA,"fetchAsArrayBuffer",(()=>JA)),He(bA,"fetchAsString",(()=>LA)),He(bA,"loadFontFaceSet",(()=>zA)),He(bA,"xmlSerializer",(()=>jA)),He(bA,"toBase64",(()=>VA)),He(bA,"dataUrlFromExternalUrl",(()=>KA)),He(bA,"arrayBufferToDataUrl",(()=>WA)),He(bA,"arrayBufferToBuffer",(()=>qA)),He(bA,"dataUrlToArrayBuffer",(()=>XA));var PA=a.Buffer;let NA;function RA(t){NA=t}function HA(){if(!NA)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new NA}if(void 0===ke.TextEncoder){const{TextEncoder:t}=c;ke.TextEncoder=t}if(void 0===ke.TextDecoder){const{TextDecoder:t}=c;ke.TextDecoder=t}const kA=new(F(s).Agent)({rejectUnauthorized:!0}),UA=t=>t.every((t=>"undefined"!==t)),GA=t=>UA([typeof document])?document.createElement(t):HA().window.document.createElement(t),TA=(t,e)=>{if(UA([typeof document]))return document.createElementNS(t,e);const A=HA().window.document.createElement(e);return A.setAttribute("xmlns",t),A},OA=()=>UA([typeof DOMParser])?new DOMParser:new(HA().window.DOMParser),JA=t=>{if(UA([typeof fetch]))return new Promise(((e,A)=>{fetch(t).then((t=>{e(t.arrayBuffer())})).catch((t=>{A(t)}))}));{const e=t.replace("localhost","localstack");return new Promise(((t,A)=>{F(r).get(e,{responseType:"arraybuffer",httpsAgent:kA}).then((e=>{t(e.data)})).catch((t=>{A(t)}))}))}},LA=t=>{if(UA([typeof fetch]))return new Promise(((e,A)=>{fetch(t).then((t=>{e(t.text())})).catch(A)}));{const e=t.replace("localhost","localstack");return new Promise(((t,A)=>{F(r).get(e,{responseType:"text",httpsAgent:kA}).then((e=>{t(e.data)})).catch(A)}))}},zA=async(t,e)=>{if(UA([typeof FontFace])){const A=t.names.fullName.en,i=new FontFace(A,`url(${e})`);return document.fonts.add(i),i.load()}},jA=()=>UA([typeof XMLSerializer])?new XMLSerializer:new(HA().window.XMLSerializer),VA=t=>UA([typeof btoa])?btoa(t):PA.from(t).toString("base64"),KA=async t=>{if(UA([typeof fetch,typeof Blob,typeof FileReader])){const e=await fetch(t),A=await e.blob();return await $A(A)}const e=(await F(r).get(t,{responseType:"arraybuffer"})).data;return WA(e)},WA=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,${qA(t).toString("base64")}`},XA=t=>{const e=t.replace(/\r?\n/g,""),A=e.indexOf(",");if(-1===A||A<=4)throw new TypeError("malformed data: URI");const i=e.substring(5,A).split(";");let n=!1;for(let t=1;t<i.length;t++)"base64"===i[t]&&(n=!0);const a=n?"base64":"ascii",r=unescape(e.substring(A+1)),s=PA.from(r,a);return ZA(s)},qA=t=>PA.from(t),ZA=t=>{const e=new ArrayBuffer(t.byteLength),A=new Uint8Array(e);for(let e=0;e<t.length;++e)A[e]=t[e];return e},$A=t=>new Promise(((e,A)=>{const i=new FileReader;i.onload=function(t){const i=t.target;i&&i.result?e(i.result.toString()):A()},i.readAsDataURL(t)})),_A=new Map;class ti{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 A=this.font.stringToGlyphs(t);return this.glyphsFromText.set(t,A),A}getApproximateHeight(){return this.height}getExactHeight(t){const e=this.font.stringToGlyphs(t);let A=0,i=0;return e.forEach((t=>{const e=t.getMetrics();A=Math.max(A,e.yMax),i=Math.min(i,e.yMin)})),A-i}getKerningValue(t,e){let A=this.kerningValues.get(t.name);A||(A=new Map,this.kerningValues.set(t.name,A));let i=A.get(e.name);return i||(i=this.font.getKerningValue(t,e),A.set(e.name,i)),i}calculateApproximateHeight(){const t=this.font.stringToGlyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");let e=0,A=0;return t.forEach((t=>{const i=t.getMetrics();e=Math.max(e,i.yMax),A=Math.min(A,i.yMin)})),e-A}}const ei=t=>"data:"===t.substring(0,5).toLowerCase().trim(),Ai=async t=>{const e=ei(t)?ii(t):ii(await KA(t));return ai(e,{assetUrl:ei(t)?t:await KA(t),name:e.names.fullName.en}),await zA(e,t),e},ii=t=>{const e=XA(t),A=F(n).parse(e);return ai(A,{assetUrl:t,name:A.names.fullName.en}),A},ni=t=>{const e=_A.get(t.name);if(e)return e;throw new Error("Font metrics unavailable for font")},ai=(t,e)=>{const A=new ti(t);return _A.set(e.name,A),A},ri=(t,e,A,i)=>Math.max(ui(t.join("\n"),A,i),e),si=(t,e,A,i,n,a)=>{const r=(a||Qi)*n.getApproximateHeight(),s=e.split("\n");try{const e=s.flatMap((e=>oi(e,t.width,i,n))),a=e.flatMap((t=>t.lines));return{lines:a,requiredHeight:e.flatMap((t=>t.lines)).length*(i*r),fontSize:A,requiredWidth:ri(a,t.width,i,n)}}catch(a){const s=e.split("");return{lines:s,requiredHeight:s.length*(i*r),fontSize:A,requiredWidth:ri(s,t.width,i,n)}}},oi=(t,e,A,i)=>{const n=di(t,A,i);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=oi(t.slice(0,n),e,A,i),r=oi(t.slice(n),e,A,i);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(di(t,A,i)>e){const n=oi(t,e,A,i);r.push(...n.lines),s=Math.max(s,n.width),o++}else{const n=[t];s=Math.max(s,di(t,A,i));let c=o+1,l=!0;for(;c<a.length&&l;){const t=a[c],r=di(`${n.join(" ")} ${t}`,A,i);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}},ci=(t,e,A,i,n,a)=>{const r=(a??Qi)*e.getApproximateHeight(),s=1/A.unitsPerEm,o=i/Bi(t,s,e),c=n/(t.length*r*s);return Math.min(c,o)},li=(t,e,A,i)=>{const n=ni(e.fontData),a=n.getFont(),r=e.fontSize/a.unitsPerEm;if(!A)return si(e,t,e.fontSize,r,n,i);let s;if(s=e.text?e.text.split("\n"):e.input?.split("\n")??[""],A.input===t&&e.width===A.width&&e.height===A.height&&e.lineHeight===A.lineHeight)return{lines:s,requiredHeight:e.height,requiredWidth:ri(s,e.width,r,n),fontSize:e.fontSize};const o=e.width!==A.width!=(e.height!==A.height);return e.lineHeight!==A.lineHeight||o||A.input!==t?si(e,t,e.fontSize,r,n,i):{lines:s,requiredHeight:e.height,requiredWidth:ri(s,e.width,r,n),fontSize:ci(s,n,a,e.width,e.height,i)}},gi=(t,e,A,i,n)=>{const a=ni(e).getFont();let r={...t},s={...t},o=Bi(i,A/a.unitsPerEm,ni(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,i&&pi(i,i).every((([t,e])=>t===e))&&(r=s)),r},hi=1,di=(t,e,A)=>{let i=0;const n=A.getGlyphs(t);return n.forEach(((t,e)=>{if(t.advanceWidth&&(i+=t.advanceWidth),e<n.length-1){const a=A.getKerningValue(t,n[e+1]);i+=a}})),i*=e,i},ui=(t,e,A)=>{let i=0;const n=A.getGlyphs(t);return n.forEach(((t,e)=>{if(t.advanceWidth&&(i=Math.max(i,t.advanceWidth)),e<n.length-1){const a=A.getKerningValue(t,n[e+1]);i=Math.max(i,a)}})),i*=e,i},Bi=(t,e,A)=>{let i=0;return t.forEach((t=>{i=Math.max(i,di(t,e,A))})),i},wi={stripControlCharacters:!0,vertical:!1,uppercase:!1},Ei=(t,e=wi)=>{const A={...wi,...e};let i=t||"";return A.stripControlCharacters&&(i=i.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),A.uppercase&&(i=i.toUpperCase()),A.vertical&&(i=i.split("").join("\n")),i},pi=(t,e)=>t.map(((t,A)=>[t,e[A]])),mi=(t="center",e=!1)=>e?"center":t,Ci=t=>"left"===t?"start":"right"===t?"end":"middle",fi=(t,e,A)=>t.fontData?{...t,...(()=>{if(t.algorithm===Ke.Traditional){const i=li(e,t,A,t.lineHeight);return{text:i.lines.join("\n"),height:i.requiredHeight,width:i.requiredWidth,fontSize:i.fontSize,input:e}}return{text:e}})()}:t,Qi=1.1;var yi={};He(yi,"colorDefinitionPrintValue",(()=>Di)),He(yi,"spotColorDefinitionString",(()=>Ii)),He(yi,"svgColorValueToDefinition",(()=>xi));const Di=t=>{const e=Ii(t.spotColor);return e?`${t.browserValue} ${e}`:t.browserValue},Ii=t=>{if(!t)return"";if(t.profileName.includes("/")&&t.profileName.includes(".icc")){const e=t.profileName.replace(/\s/g,"-"),A=e.lastIndexOf("/");return`icc-named-color(${e.slice(A+1).slice(0,-4)}, ${t.namedColor})`}return`icc-named-color(${t.profileName}, ${t.namedColor})`},xi=t=>{const e=t.split(/[ ](?=[^)]*?(?:\(|$))/);if(0===e.length)return{browserValue:"#000000"};if(1===e.length)return{browserValue:e[0]};const A=e[1].match(/\(([^)]+)\)/gm);if(!A)throw new Error("Unhandled state of color value in SVG");const i=A[0].replace(/[() ]/g,"").split(",");return{browserValue:e[0],spotColor:{profileName:i[0],namedColor:i[1]}}},Mi=t=>{const e=(t.rotation||0)*Math.PI/180,i=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,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("defs",{children:[t.textFillImage&&(0,A.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,A.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,A.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,A.jsx)("path",{id:a,d:t.paths[0]}):void 0]}),t._renderingConfiguration?.debug?(0,A.jsx)("rect",{stroke:"blue",fill:"none",x:t.x,y:t.y,width:t.width,height:t.height}):void 0,(0,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsx)("g",{transform:`matrix(${i}, ${-n}, ${n}, ${i}, ${s}, ${o})`,children:(0,A.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} ${Ii(t.fillSpotColorDefinition)}`:t.fill,style:{whiteSpace:"pre",userSelect:"none"},children:t.curved?(0,A.jsx)(Fi,{text:t.text||"",curvedPathId:a,align:t.align}):c.map(((e,i)=>(0,A.jsx)(vi,{align:t.vertical?"center":t.align,fontSize:t.fontSize,thisLineIdx:i,amountLines:c.length,text:e,textboxHeight:t.height,textboxWidth:t.width,lineHeight:t.lineHeight,vertical:t.vertical,verticalAlign:t.verticalAlign},i)))})})})]}):null},vi=t=>(0,A.jsx)("tspan",{textAnchor:Ci(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:Qi),A=t.textboxHeight/2;if("top"===t.verticalAlign)return-A+3*t.fontSize/4+t.thisLineIdx*e;if("bottom"===t.verticalAlign){const i=t.amountLines-1-t.thisLineIdx;return A-t.fontSize/4-i*e}const i=(t.amountLines-1)/2;return(t.thisLineIdx-i)*e+t.fontSize/4})()}px`,children:t.text}),Fi=t=>{const e=`#${t.curvedPathId}`;return(0,A.jsx)("textPath",{startOffset:"left"===t.align?"0%":"right"===t.align?"100%":"50%",textAnchor:Ci(t.align),href:e,xlinkHref:e,children:t.text})};He({},"Illustration",(()=>Hi));var Si={};He(Si,"traverse",(()=>bi)),He(Si,"sanitizeSvgTree",(()=>Pi)),He(Si,"modifySVGWithElementProperties",(()=>Ni)),He(Si,"generateSVGWithUnknownColors",(()=>Ri));const Yi=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],bi=(t,e)=>{e(t),t.children.length>0&&Array.from(t.children).forEach((t=>bi(t,e)))},Pi=(t,e=!1)=>{!e&&t.setAttribute("preserveAspectRatio","none");const A=[];bi(t,(t=>{if("script"!==t.tagName)if("style"!==t.tagName);else try{(0,l.parse)(t.innerHTML).stylesheet?.rules.forEach((t=>{A.push(t)})),t.remove()}catch(t){console.error(t)}else t.remove()})),bi(t,(t=>{A.forEach((e=>{e.selectors?.forEach((A=>{((t,e)=>{try{return t.matches(e)}catch(A){return t.classList.contains(e.substring(1))}})(t,A)&&e.declarations?.forEach((e=>{e.property&&e.value&&t.setAttribute(e.property,e.value)}))}))}))}))},Ni=(t,e,A,i,n)=>{const a=(t=>OA().parseFromString(t,"image/svg+xml").firstElementChild)(t);if(!a)throw new Error("Failed to read SVG.");return((t,e,A)=>{t.setAttribute("height",`${A}px`),t.setAttribute("width",`${e}px`)})(a,e,A),((t,e,A)=>{bi(t,(t=>{const i=t.attributes.getNamedItem("fill");i&&"none"!==i.value&&t.classList.forEach((i=>{if(i.startsWith("spiff-fill")){const n=e[i];n&&t.setAttribute("fill",A?Di(n):n.browserValue)}}));const n=t.attributes.getNamedItem("stroke");n&&"none"!==n.value&&t.classList.forEach((i=>{if(i.startsWith("spiff-stroke")){const n=e[i];n&&t.setAttribute("stroke",A?Di(n):n.browserValue)}}))}))})(a,i,n),(t=>jA().serializeToString(t))(a)},Ri=async t=>{const e=t.match(/<svg.*?<\/svg>/s)||[],A=e?.length>0?e[0]:"",i=OA().parseFromString(A,"image/svg+xml").firstElementChild;if(!i)throw new Error("Failed to read SVG.");Pi(i);const n={};bi(i,(t=>{Yi.includes(t.tagName)&&!t.attributes.getNamedItem("fill")&&t.setAttribute("fill","black");const e=t.attributes.getNamedItem("fill");if(e&&"none"!==e.value){const A=xi(e.value),i=`spiff-fill-${A.browserValue.replace(/\W/g,"")}`;t.setAttribute("fill",A.browserValue),t.classList.add(i),n[i]=A}const A=t.attributes.getNamedItem("stroke");if(A&&"none"!==A.value){const e=xi(A.value),i=`spiff-stroke-${e.browserValue.replace(/\W/g,"")}`;t.classList.add(i),t.setAttribute("stroke",e.browserValue),n[i]=e}}));const a=jA().serializeToString(i);return{colors:n,svg:a}},Hi=t=>{if(t.cachedObjectURL&&!t._renderingConfiguration?.omitCachedFields)return(0,A.jsx)(xA,{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,i=gA(e),n=Math.cos(i),a=-Math.sin(i),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,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsx)("g",{transform:r,dangerouslySetInnerHTML:{__html:Ni(t.svg,t.width,t.height,t.colors,t._renderingConfiguration?.spotColors)}})})};class ki{constructor(){this.id=Ge(),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 A=this.prevCommands.filter((e=>e.sequenceId===t)).pop();A&&(this.prevCommands=this.prevCommands.filter((e=>e.sequenceId!==t)),A?.overrideOldState(e),this.prevCommands.push(A))}getLayoutById(t){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const e=this.state.transaction?.layouts?.[t],A=this.state.variation?.layouts?.[t],i=e?.layout||A?.layout;if(!i)throw new Error(`No layout: ${t}`);const n=[...e?.elements||[],...A?.elements||[]];return this.getLayoutDataWithState(i,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:A=>Gi(t,e,A)}}initialize(t,e){if(e)return void(this.state={transaction:e});let A={serializableWorkflow:{steps:[]},layouts:{}};t.forEach((t=>{A=new $i(t).apply(A)})),this.runStateCallbacks(),this.state={transaction:A}}commandReducer(t,e){if(e.varying){const A={layouts:{},serializableWorkflow:{steps:[]},...t.variation};return{...t,variation:e.apply(A)}}{const A=t.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...t,transaction:e.apply(A)}}}}const Ui=t=>"image"===t.type?(0,A.jsx)(xA,{...t},t.id):"frame"===t.type?(0,A.jsx)(MA,{...t},t.id):"illustration"===t.type?(0,A.jsx)(Hi,{...t},t.id):"textbox"===t.type?(0,A.jsx)(Mi,{...t},t.id):null,Gi=(t,e,i)=>{const n=i.renderingConfiguration,a=n?.removeExcludedElements?e.filter((t=>!t.excludeFromExport)):e;return(0,A.jsx)(sA,{preserveAspectRatio:void 0,elements:a,backgroundColor:t.transparentBackground?void 0:"white",width:i.width||t.width,height:i.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:i.outlineArea,maxHeight:i.maxHeight,maxWidth:i.maxWidth,position:i.position,borderRadius:i.borderRadius,outlineColor:i.outlineColor})};function Ti(t){return t.sort(((t,e)=>{const A=t.layer||0,i=e.layer||0;if(A<i)return-1;if(A>i)return 1;const n=t.layerIndex||0,a=e.layerIndex||0;return n<a?-1:n>a?1:0}))}class Oi extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,Oi.prototype)}}const Ji=(t,e)=>Li(t,e).elements.find((e=>e.id===t)),Li=(t,e)=>{const A=Object.values(e).find((e=>e.elements.some((e=>e.id===t))));if(!A)throw new Oi;return A},zi=(t,e)=>{const A=Ti([...e.elements.filter((e=>e.id!==t.id)),t]);return{layout:e.layout,elements:A,modificationID:Ge()}},ji=async(t,e)=>{const A=[...Object.keys(t.layouts),...Object.keys(e?.layouts||{})],i=[...new Set(A)];for(let A=0;A<i.length;A++){const n=i[A],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 LA(e.src),A=await Ri(t);e.svg=Ni(A.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 Vi{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(t){this.oldState=t}}class Ki extends Vi{constructor(t){super(),this.serializableWorkflow=t}apply(t){return this.oldState=t,{...t,serializableWorkflow:this.serializableWorkflow}}}class Wi extends Vi{constructor(t,e,A){super(),this.id=t,this.x=e,this.y=A}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,x:this.x,y:this.y},i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class Xi extends Vi{constructor(t,e){super(),this.id=t,this.angle=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,rotation:this.angle},i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class qi extends Vi{constructor(t,e,A){super(),this.id=t,this.width=Math.abs(e),this.height=Math.abs(A)}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;let A={...e,width:this.width,height:this.height};if("frame"===e.type){const t=A;t.scaleX=t.scaleX*this.width/e.width,t.scaleY=t.scaleY*this.height/e.height}else if("textbox"===e.type){const t=A,i=(t.algorithm&&t.algorithm!==Ke.Autosize?t.input:t.text)??"";A=fi(t,i,e)}const i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class Zi extends Vi{constructor(t){super(),this.commands=t}apply(t){return this.oldState=t,this.commands.reduce(((t,e)=>e.apply(t)),t)}}class $i extends Vi{constructor(t){super(),this.layout=t}apply(t){return this.oldState=t,{...t,layouts:{...t.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:Ge()}}}}}class _i extends Vi{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:Ge()}})),A={};return e.forEach((t=>{A[t.layout.id]=t})),{...t,layouts:A}}}class tn extends Vi{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 A=[...e,this.element];return void 0===this.element.layerIndex&&(this.element.layerIndex=this.assignIndex(this.element,A)),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:A,modificationID:Ge()}}}}const A=e[e.length-1],i=A.productOverlay?A:null;let n;if(i&&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 i&&n.push(i),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:n,modificationID:Ge()}}}}assignIndex(t,e){if(0===e.length)return 0;const A=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!==A?A+1:0}}class en extends Vi{constructor(t){super(),this.id=t}apply(t){this.oldState=t;let e=!1;const A=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:Ge()})));e||console.log(`Failed to delete element ${this.id}`);const i={};return A.forEach((t=>{i[t.layout.id]=t})),{...t,layouts:i}}}class An extends Vi{constructor(t,A){super(),this.el=F(e)(t),this.layout=A,this.el.id=Ge(),this.el.x+=5,this.el.y+=5}apply(t){return this.oldState=t,new tn(this.el,this.layout).apply(t)}}class nn extends Vi{constructor(t,e,A){super(),this.id=t,this.color=e,this.textFillSpotColor=A}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor,textFillImage:void 0},i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class an extends Vi{constructor(t,e){super(),this.id=t,this.imageFill=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,textFillImage:this.imageFill},i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class rn extends Vi{constructor(t,e){super(),this.id=t,this.size=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,fontSize:this.size},i=Li(e.id,Object.values(t.layouts)),n=(e.algorithm&&e.algorithm!==Ke.Autosize?e.input:e.text)??"",a=zi(fi(A,n),i);return{...t,layouts:{...t.layouts,[i.layout.id]:a}}}}class sn extends Vi{constructor(t,e){super(),this.id=t,this.algorithm=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,algorithm:this.algorithm},i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class on extends Vi{constructor(t,e){super(),this.id=t,this.fontData=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,fontData:this.fontData},i=Li(e.id,Object.values(t.layouts)),n=(e.algorithm&&e.algorithm!==Ke.Autosize?e.input:e.text)??"",a=zi(fi(A,n),i);return{...t,layouts:{...t.layouts,[i.layout.id]:a}}}}class cn extends Vi{constructor(t,e){super(),this.id=t,this.align=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,align:this.align},i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class ln extends Vi{constructor(t,e,A){super(),this.id=t,this.imageData=e,this.offsets=A}apply(t){this.oldState=t;const e=Li(this.id,Object.values(t.layouts)),A=e.elements.findIndex((t=>t.id===this.id)),i=e.elements[A].pattern,n=[...e.elements];n.splice(A,1,{...e.elements[A],pattern:{...i,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:Ge()};return{...t,layouts:{...t.layouts,[e.layout.id]:a}}}}class gn extends Vi{constructor(t,e){super(),this.id=t,this.text=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A=Li(e.id,Object.values(t.layouts)),i=zi(fi(e,this.text,e),A);return{...t,layouts:{...t.layouts,[A.layout.id]:i}}}}class hn extends Vi{constructor(t,e,A){super(),this.id=t,this.className=e,this.fill=A}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A=e.colors||{},i=A[this.className];A[this.className]={browserValue:this.fill,spotColor:i?.spotColor};const n={...e,colors:A},a=Li(e.id,Object.values(t.layouts)),r=zi(n,a);return{...t,layouts:{...t.layouts,[a.layout.id]:r}}}}class dn extends Vi{constructor(t,e,A){super(),this.id=t,this.svgBody=e,this.objectURL=A}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A={...e,svg:this.svgBody,cachedObjectURL:this.objectURL},i=Li(e.id,Object.values(t.layouts)),n=zi(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class un extends Vi{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Ji(this.id,Object.values(t.layouts)).id)throw new Oi;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 A=e.elements.findIndex((t=>t.id===this.id));e.elements.push(e.elements.splice(A,1)[0]);const i=[...e.elements];return i.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:i,modificationID:Ge()}}}}}class Bn extends Vi{constructor(t){super(),this.id=t}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!A)throw new Error("Layout missing from state!");const i=A.elements.findIndex((t=>t.id===this.id));A.elements.splice(i,1),A.elements.unshift(e);const n=[...A.elements],a=n.splice(i,1)[0];return n.splice(i,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[A.layout.id]:{...t.layouts[A.layout.id],elements:n,modificationID:Ge()}}}}}class wn extends Vi{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Ji(this.id,Object.values(t.layouts)).id)throw new Oi;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 A=e.elements.findIndex((t=>t.id===this.id)),i=A+1,n=[...e.elements],a=n.splice(A,1)[0];return n.splice(i,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:n,modificationID:Ge()}}}}}class En extends Vi{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Ji(this.id,Object.values(t.layouts)).id)throw new Oi;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 A=e.elements.findIndex((t=>t.id===this.id)),i=A-1,n=[...e.elements],a=n.splice(A,1)[0];return n.splice(i,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:n,modificationID:Ge()}}}}}class pn extends Vi{constructor(t,e){super(),this.id=t,this.value=e}apply(t){this.oldState=t;const e=Ji(this.id,Object.values(t.layouts));if(!e.id)throw new Oi;const A=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!A)throw new Error("Layout missing from state!");return{...t,layouts:{...t.layouts,[A.layout.id]:zi({...e,layer:this.value},A)}}}}var mn={};He(mn,"patternImageDataCache",(()=>xn)),He(mn,"frameDataCache",(()=>Mn)),He(mn,"generateFrameSVG",(()=>vn)),He(mn,"generateDefaultRectangleFrameSvg",(()=>Fn)),He(mn,"getVariant",(()=>Sn)),He(mn,"getFrameData",(()=>Yn)),He(mn,"calculateOffsets",(()=>bn)),He(mn,"getPatternImageData",(()=>Pn)),He(mn,"GetSVGDimensions",(()=>Nn)),He(mn,"svgStringDimensions",(()=>Rn));var Cn={};He(Cn,"getExifOrientation",(()=>Qn)),He(Cn,"canvasDims",(()=>yn)),He(Cn,"getAttributesFromArrayBuffer",(()=>Dn));let fn=null;const Qn=t=>new Promise((e=>{const A=qA(t);(0,o.fromBuffer)(t).then((t=>{const i=t?.mime;if("image/jpeg"!==i)return e(1);(new(0,h.ExifImage)).loadImage(A,((t,A)=>e(t?1:A.image.Orientation||1)))}))})),yn=t=>{const e=8192,A=t.naturalWidth/t.naturalHeight;return t.naturalHeight<=e&&t.naturalWidth<=e?[t.naturalWidth,t.naturalHeight]:t.naturalHeight>t.naturalWidth?[A*e,e]:[e,e/A]},Dn=async t=>{const e=await(async t=>{const e=await WA(t),A=await(0,g.loadImage)(e),[i,n]=yn(A),a=await(async()=>{if(null!==fn)return!fn;const t=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return fn=2===t.width&&3===t.height,!fn})();if(!a){const t=(0,g.createCanvas)(i,n);return t.getContext("2d").drawImage(A,0,0,i,n),t}const r=await Qn(t),[s,o]=r>4?[n,i]:[i,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(A,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",(()=>In));const In=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))}},xn=new Map,Mn=new Map,vn=async(t,e)=>{if(!e){if(!t)throw new Error("No region or src supplied. Cannot construct frame!");return Fn(t)}return LA(e)},Fn=t=>{const e=t.width,A=e/t.height,i=Math.max(e,512),n=i/A;return`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${i} ${n}'>\n <path id="target-path" d='M0 0 h ${i} v ${n} h ${-i} Z' />\n </svg>\n `},Sn=(t,e)=>{if(!e)return;const A=e.variants?.find((e=>e.id===t.frameVariantId))||In(e);if(!A)throw new Error(`No variant with ID: ${t.frameVariantId}`);if(!A.asset)throw new Error(`No asset for variant with ID: ${t.frameVariantId}`);return A},Yn=async t=>{const e=OA().parseFromString(t,"image/svg+xml"),A=e.querySelector("svg");if(!A)throw new Error("Malformed frame SVG: <svg> tag not found");const i=A.getAttribute("viewBox");if(!i)throw new Error("SVG missing viewBox.");const n=i.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 Mn.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 Mn.set(t,e),e}throw new Error("Malformed frame SVG")},bn=(t,e,A)=>{const i=e.width>=e.height,n=t.width>=t.height,a=e.width/2,r=e.height/2,s=(i?e.height:e.width)/(n?t.width:t.height),o=A?.scale||s,c=a-t.width/2*o,l=A?.left||c,g=r-t.height/2*o;return{x:l,y:A?.top||g,zoom:o}},Pn=async t=>{if(xn.has(t))return xn.get(t);if(t.endsWith("svg")){const e=await Nn(t),A=e.width,i=e.height,n={src:t,width:A,height:i,aspect:A/i};return xn.set(t,n),n}{const e=await JA(t),A=await Dn(e),i={src:t,width:A.width,height:A.height,aspect:A.width/A.height};return xn.set(t,i),i}},Nn=async t=>{const e=await LA(t);return Rn(e)},Rn=t=>{const e=OA().parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)throw new Error("No svg tag found, this svg must be malformed!");const A=e.getAttribute("viewBox"),i=e.getAttribute("width"),n=e.getAttribute("height"),a=A?A?.split(" ").map((t=>Number(t))):[0,0,Number(i),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 Hn={};He(Hn,"determineCorrectFontSizeAndLines",(()=>Un)),He(Hn,"determineCorrectTextboxRegion",(()=>Gn));const kn=(t,e,A,i,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=>di(t,i,n)));const o=n.getApproximateHeight()*i;let c=!0;for(;c;){if(o+(r-1)*A>t.height)return[null,null];const e=Math.max(...s);if(e<=t.width)return[a,e];const l=s.reduce(((t,e,A,i)=>e>i[t]?A: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)],A=e.map((t=>di(t,i,n)));A[0]<=t.width&&(a=[...a.slice(0,l),...e,...a.slice(l+1)],s=[...s.slice(0,l),...A,...s.slice(l+1)],r+=1,h=!0)}h||(c=!1)}return[null,null]},Un=(t,e,A,i,n)=>{let a,r;const s=ni(e),o=s.getFont();if(n.size){const e=t/o.unitsPerEm;return[a,r]=kn(A,i,t,e,s),[n.size,a,r]}let c=6-hi;if(i.length>0){let t=i,e=0;for(;(!n.maxSize||c<=n.maxSize)&&t;)c+=hi,e=c/o.unitsPerEm,[t,r]=kn(A,i,c,e,s)}c>6&&(c-=hi),n.minSize&&c<n.minSize&&(c=n.minSize);const l=c/o.unitsPerEm;return[a,r]=kn(A,i,c,l,s),[c,a,r]},Gn=(t,e,A,i,n)=>{let a={...t},r={...t},[s,o,c]=Un(A,e,r,i,{size:0,minSize:A,maxSize:A});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]=Un(A,e,r,i,{size:A}),s===A&&o&&(l=i,g=o,l.map(((t,e)=>[t,g[e]]))).every((([t,e])=>t===e))&&(a=r)),a};var Tn={};He(Tn,"svgObjectURL",(()=>Ln)),He(Tn,"LayoutElementFactory",(()=>jn));const On=(t,e)=>{const A=t.layoutState.elements.filter((t=>t.layer===e)),i=Math.max(...A.map((t=>t.layerIndex)).filter((t=>void 0!==t)));return Math.max(i,0)+1},Jn=async t=>new Promise((e=>{LA(t).then((t=>{e(t)})).catch((t=>console.error(t)))})),Ln=async t=>{const e=OA().parseFromString(t,"image/svg+xml").firstElementChild;if(!e)throw new Error("Failed to read SVG");const A=(new XMLSerializer).serializeToString(e),i=document.createElement("canvas"),n=i.getContext("2d"),a=await Re.from(n,A,{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,A)=>{try{if(!URL||!URL.createObjectURL)throw new Error("Environment incapable of generating ObjectURL");t.toBlob((A=>{if(!A){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(A))}))}catch(t){A(t)}})))(i)},zn=async(t,e,A,i)=>{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(A&&e===Le.Illustration){const t=await Ri(await Jn(A)),e=OA().parseFromString(t.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!e)throw new Error("SVG missing viewBox.");const i=s.height,n=e.split(" "),a=(parseFloat(n[2])||1)/(parseFloat(n[3])||1);s.height=s.width/a,s.top+=(i-s.height)/2}if(A&&e===Le.Image){const t=s.height,e=await JA(A),i=await Dn(e),n=i.width/i.height;s.height=s.width/n,s.top+=(t-s.height)/2}if(A&&e===Le.Textbox&&i?.text&&i?.fontScale){const t={assetUrl:A,name:(await Ai(A)).names.fullName.en},e=ni(t),a=di(i.text,i?.fontScale,e);s.width=Math.min(a,.85*n.width),s.left=n.x+n.width/2-s.width/2}return s};class jn{static async getFrame(t,e){const A=await vn(e.region,e.src),i=await Yn(A),n=e.region||await zn(t,Le.Frame);return{id:Ge(),x:n.left,y:n.top,width:n.width,height:n.height,layer:n.layer||0,layerIndex:n.layerIndex||On(t,n.layer||0),rotation:n.rotation,scaleX:n.width/i.width,scaleY:n.height/i.height,path:i.path,type:Le.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 A=e.region||await zn(t,Le.Image,e.src);return{id:Ge(),src:e.src,type:Le.Image,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer||0,layerIndex:A.layerIndex||On(t,A.layer||0),immutable:A.immutable,preserveAspectRatio:"none"}}static async getTextbox(t,e){const{configuration:A,fontSrc:i,designInputStep:n}=e,a=await Ai(i),r={assetUrl:i,name:a.names.fullName.en},s=n?.text||A.defaultText||"",o=A.replaceableText?A.replaceableText.replace("{{}}",s):s,c=Ei(o,{vertical:A.vertical,uppercase:A.uppercase}),l=e.region||await zn(t,Le.Textbox,i,{text:c,fontScale:A.size?A.size/a.unitsPerEm:void 0}),g=fi({id:Ge(),type:Le.Textbox,x:l.left,y:l.top,width:l.width,height:l.height,align:mi(A.textAlign,A.vertical),curved:A.curved,fill:n?.color||A.colour||"#000000",fontData:r,layer:l.layer||0,layerIndex:l.layerIndex||On(t,l.layer||0),paths:A.paths,rotation:l.rotation,vertical:A.vertical,verticalAlign:A.verticalAlign||"middle",algorithm:Ke.Traditional,fontSize:A.size||Math.max(Math.round(.025*l.height),1),text:c,input:s},c),h=gi({...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 A=`\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 `,i={};i["spiff-fill-shape"]={browserValue:e.color};const n=e.region||await zn(t,Le.Illustration),a=Ge();return{stepRegion:e.region,colors:i,id:a,svg:A,type:Le.Illustration,y:n.top,x:n.left,rotation:n.rotation,width:n.width,height:n.height,layer:n.layer||0,layerIndex:n.layerIndex||On(t,n.layer||0),immutable:n.immutable}}static async getIllustration(t,e){const A=e.region||await zn(t,Le.Illustration,e.src),i=await Ri(await Jn(e.src)),n=await Ln(i.svg),a=Ge();return{cachedObjectURL:n,stepRegion:e.region,colors:i.colors,id:a,src:e.src,svg:i.svg,type:Le.Illustration,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer||0,layerIndex:A.layerIndex||On(t,A.layer||0),immutable:A.immutable}}}function Vn(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Kn extends Error{constructor(t){super(t),this.name=this.constructor.name}}class Wn extends Kn{constructor(t){super(`ConfigurationError - ${t}`)}}class Xn extends Wn{constructor(t){super(`Option not Configured: ${t.stepTitle}`),Vn(this,"optionId",void 0),this.optionId=t?.optionId||"N/A"}}class qn extends Wn{constructor(t){super(`Panel not Found: ${t.panelId}`),Vn(this,"panelId",void 0),this.panelId=t?.panelId||"N/A"}}class Zn extends Wn{constructor(t){super(`Asset not found for variant: ${t.name}`),Vn(this,"variant",void 0),this.variant=t}}class $n extends Wn{constructor(t){super(`Resource not found for asset: ${t.name}`),Vn(this,"asset",void 0),this.asset=t}}class _n extends Wn{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),Vn(this,"step",void 0),this.step=t}}class ta extends Kn{constructor(t){super(`ImplementationError - ${t}`)}}class ea extends ta{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class Aa extends ta{constructor(t){super(`Parsing Error: ${t}`)}}class ia extends ta{constructor(t){super(`Client Error: ${t}`)}}class na extends ta{constructor(t){super(`Resource Generation Failed: ${t}`)}}function aa(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ra{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 A=JSON.stringify([...e.entries()]);this.set(t,A)}}class sa{constructor(){aa(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 A=JSON.stringify([...e.entries()]);this.set(t,A)}}const oa=(()=>{try{return localStorage?new ra:new sa}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new sa}})();function ca(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const la=new class{constructor(){ca(this,"defaultServerUrl","https://api.spiff.com.au"),ca(this,"defaultServicesApiUrl","https://services.spiff.com.au"),ca(this,"defaultHubUrl","https://hub.spiff.com.au"),ca(this,"serverUrl",void 0),ca(this,"servicesApiUrl",void 0),ca(this,"hubUrl",void 0),ca(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 ga(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let ha;const da=t=>{ha=t};const ua=new class{constructor(){ga(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),la.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const e=(0,t.createHttpLink)({uri:`${la.getServerUrl()}/graphql`,fetch:C.fetch}),A=(0,p.setContext)((async(t,{headers:e})=>{const A=e||{},i=await(async()=>{const t={transactionOwnerId:ha};return"undefined"!=typeof window&&window.location.href.includes("/workflows/product/")?{...await new Promise((t=>{const e=la.getHubUrl();if(window.location.href.includes("localhost")||window.location.href.includes("ngrok"))return void t({});const A=i=>{i.origin===e&&(window.removeEventListener("message",A),t(i.data))};window.parent!==window&&(window.addEventListener("message",A,!1),window.parent.postMessage("ready",e))})),...t}:t})();return i.bearer&&(A.Authorization=`Bearer ${i.bearer}`),i.partnerId&&(A.partnerId=i.partnerId),i.activeIntegration&&(A.activeIntegration=i.activeIntegration),i.transactionOwnerId&&(A.transactionOwnerId=i.transactionOwnerId),{headers:A}})),i=(0,m.onError)((({operation:t,graphQLErrors:e,networkError:A})=>{(e||[]).forEach((({message:e,locations:A,path:i})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+t.operationName),console.log("Query:"+JSON.stringify(t.query)),console.log(`Message: ${e}, Location: ${JSON.stringify(A,null,2)}, Path: ${i}`),console.log("Variables:"+JSON.stringify(t.variables))})),A&&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)([i,A,e]),cache:n,name:"Core"})}};function Ba(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const wa=t.gql`
|
|
2
2
|
fragment AssetFields on Asset {
|
|
3
3
|
name
|
|
4
4
|
key
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spiffcommerce/core",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.6",
|
|
4
4
|
"description": "Core client API for interacting with the Spiff Commerce backend.",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@apollo/client": "^3.7.0",
|
|
90
|
-
"@spiffcommerce/papyrus": "^2.0.
|
|
90
|
+
"@spiffcommerce/papyrus": "^2.0.3",
|
|
91
91
|
"cross-fetch": "^3.1.5",
|
|
92
92
|
"graphql": "^16.6.0",
|
|
93
93
|
"lodash.clonedeep": "^4.5.0",
|