@spiffcommerce/core 29.3.0 → 30.0.0-beta.15bd22f4-b37c-5ee8-90e3-706e225bff55

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("@apollo/client/core"),ni=require("@apollo/client/link/context"),ri=require("@apollo/client/link/error"),ii=require("preact-render-to-string"),si=require("@apollo/client/link/remove-typename"),oi=require("exifr/dist/mini.umd.cjs"),yn=require("css"),li=require("fuse.js"),Sa=require("pith"),Et=require("lodash.clonedeep"),Sn=require("qrcode"),ci=require("svg-path-bbox"),ra=require("opentype.js"),D=require("preact/jsx-runtime"),di=require("handlebars"),Ai=require("data-uri-to-buffer"),Ja=require("lodash.chunk"),pe=require("@aws-sdk/client-cognito-identity-provider"),ui=require("dinero.js"),hi=require("currency-codes"),vn=require("lodash.isequal"),ia=require("unicode-default-word-boundary"),En=require("lodash.debounce");require("fs");require("path");function gi(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const a=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,a.get?a:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const Ka=gi(hi);var Xt=(r=>(r.Data="Data",r.Font="Font",r.Frame="Frame",r.Illustration="Illustration",r.Image="Image",r.Model="Model",r.Material="Material",r.Color="Color",r.QuestionnaireCollateral="QuestionnaireCollateral",r.RequestCollateral="RequestCollateral",r.SignupCollateral="SignupCollateral",r.Video="Video",r.ColorProfile="ColorProfile",r.Environment="Environment",r))(Xt||{}),V=(r=>(r.FileUpload="FileUpload",r.Option="Option",r.ColorOption="ColorOption",r.Text="Text",r))(V||{}),I=(r=>(r.Information="Information",r.Bulk="Bulk",r.DigitalContent="DigitalContent",r.Finish="Finish",r.Frame="Frame",r.Illustration="Illustration",r.Introduction="Introduction",r.Material="Material",r.Model="Model",r.Module="Module",r.Picture="Picture",r.Photo="Photo",r.ProductOverlay="ProductOverlay",r.Question="Question",r.Shape="Shape",r.SilentIllustration="SilentIllustration",r.Text="Text",r))(I||{}),bn=(r=>(r.Color="Color",r.Colors="Colors",r.Selection="Selection",r.Selections="Selections",r.Text="Text",r.Upload="Upload",r))(bn||{}),Tt=(r=>(r.ThreeD="ThreeD",r.FreeDesign="FreeDesign",r.Print="Print",r))(Tt||{}),k=(r=>(r.Frame="frame",r.Group="group",r.Image="image",r.Pattern="pattern",r.Illustration="illustration",r.Textbox="textbox",r))(k||{}),Bn=(r=>(r.Default="Default",r.FirstTransaction="FirstTransaction",r.OneToOne="OneToOne",r))(Bn||{}),In=(r=>(r.Hyperlink="Hyperlink",r.Edit="Edit",r.Approve="Approve",r))(In||{}),Pn=(r=>(r.Hub="Hub",r.Shopify="Shopify",r))(Pn||{}),Me=(r=>(r.BackgroundRemover="BackgroundRemover",r.ConversionAccelerator="Conversion Accelerator",r.ProcessBuilder="ProcessBuilder",r))(Me||{}),Dn=(r=>(r[r.Orbit=0]="Orbit",r[r.Pan=1]="Pan",r))(Dn||{}),Zt=(r=>(r.Owner="Owner",r.Approver="Approver",r.Editor="Editor",r.Viewer="Viewer",r))(Zt||{}),Bt=(r=>(r.Autosize="Autosize",r.Traditional="Traditional",r))(Bt||{}),j=(r=>(r[r.North=0]="North",r[r.Northeast=1]="Northeast",r[r.East=2]="East",r[r.Southeast=3]="Southeast",r[r.South=4]="South",r[r.Southwest=5]="Southwest",r[r.West=6]="West",r[r.Northwest=7]="Northwest",r))(j||{}),xn=(r=>(r.Pixel="px",r.Millimeter="mm",r.Centimeter="cm",r))(xn||{});class Fn extends Error{constructor(t){super(t),this.name=this.constructor.name}}class ie extends Fn{constructor(t){super(`ConfigurationError - ${t}`)}}class te extends ie{constructor(t){super(`Option not Configured: ${t.stepTitle}`),this.optionId=(t==null?void 0:t.optionId)||"N/A"}}class Y extends ie{constructor(t){super(`Panel not Found: ${t.panelId}`),this.panelId=(t==null?void 0:t.panelId)||"N/A"}}class mt extends ie{constructor(t){super(`Asset not found for variant: ${t.name}`),this.variant=t}}class Nt extends ie{constructor(t){super(`Resource not found for asset: ${t.name}`),this.asset=t}}class ee extends ie{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),this.step=t}}class Te extends Fn{constructor(t){super(`ImplementationError - ${t}`)}}class z extends Te{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class St extends Te{constructor(t){super(`Parsing Error: ${t}`)}}class ht extends Te{constructor(t){super(`Client Error: ${t}`)}}class Ne extends Te{constructor(t){super(`Resource Generation Failed: ${t}`)}}class mi{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 _a{constructor(){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 pi=()=>{try{return localStorage?new mi:new _a}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new _a}},N=pi();class fi{constructor(){this.defaultServerUrl="https://api.au.spiffcommerce.com",this.defaultServicesApiUrl="https://services.au.spiffcommerce.com",this.defaultHubUrl="https://hub.au.spiffcommerce.com",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(e=>e())}setServicesApiUrl(t){this.servicesApiUrl=t}setHubUrl(t){this.hubUrl=t}addServerUrlCallback(t){this.serverUrlCallbacks.push(t)}}const At=new fi;let sa,oa;function Ci(r){sa=r}function wi(r){oa=r}function se(){return sa?new sa().window:(console.log("DOM constructor is not registered. Assuming browser environment. If not, please register DOM constructor before calling this function."),window)}function st(r,t){if(!oa){if(typeof window<"u"&&window.fetch)return window.fetch(r,t);if(typeof global<"u"&&global.fetch)return global.fetch(r,t);throw new Error("Fetch implementation is not registered. Please register it before calling this function.")}return oa(r,t)}const kn=new Map,Xa=new Map,Za=new Map,Mn=async r=>{const t=Xa.get(r);if(t)return t;const a=(async()=>{var i;const n=await st(r);return kn.set(r,((i=n.headers)==null?void 0:i.get("content-type"))||""),await n.arrayBuffer()})();return Xa.set(r,a),a},yi=async r=>{const t=Za.get(r);if(t)return t;const a=(async()=>await(await st(r)).text())();return Za.set(r,a),a},$t=r=>r.every(t=>t!=="undefined"),fe=r=>$t([typeof document])?document.createElement(r):se().document.createElement(r),Si=(r,t)=>{if($t([typeof document]))return document.createElementNS(r,t);const a=se().document.createElement(t);return a.setAttribute("xmlns",r),a},ct=()=>{if($t([typeof DOMParser]))return new DOMParser;const r=se();return new r.DOMParser},vi=()=>$t([typeof DOMParser])?DOMParser:se().DOMParser,Qe=(r,t)=>new Promise((e,a)=>{t?Mn(r).then(e).catch(a):st(r).then(n=>{n.arrayBuffer().then(e).catch(a)}).catch(n=>{a(n)})}),et=(r,t)=>new Promise((e,a)=>{t?yi(r).then(e).catch(a):st(r).then(n=>{n.text().then(e).catch(a)}).catch(a)}),Tn=r=>ii.renderToStaticMarkup(r),qe=new Map,Ei=async(r,t)=>{if($t([typeof FontFace])){if(qe.has(t))return qe.get(t);const e=r.names.fullName.en,a=new FontFace(e,`url(${t})`);document.fonts.add(a);const n=a.load();return qe.set(t,n),n}},wt=()=>{if($t([typeof XMLSerializer]))return new XMLSerializer;const r=se();return new r.XMLSerializer},tn=r=>btoa(r),Re=r=>{function t(){const a=new Uint8Array(r),n=4;if(a.length>=n){const i=new Array(n);for(let l=0;l<n;l++)i[l]=new Uint8Array(r)[l].toString(16);const s=i.join("").toUpperCase();switch(s){case"89504E47":return"image/png";case"47494638":return"image/gif";case"25504446":return"application/pdf";case"504B0304":return"application/zip"}switch(s.slice(0,4)){case"FFD8":return"image/jpeg"}}return null}const e=t();return e||"image/svg+xml"},bi=async r=>{const t=await Mn(r),e=kn.get(r)||Re(t);return await Pi(new Blob([t],{type:e}))},Bi=r=>{let t="";const e=r.byteLength;for(let a=0;a<e;a++)t+=String.fromCharCode(r[a]);return t},Ii=async r=>{const t=Re(r),e=new Uint8Array(r),a=Bi(e),n=btoa(a);return`data:${t};base64,${n}`},Oe=r=>`data:image/svg+xml;base64,${btoa(r)}`,Nn=r=>{const t=r.replace(/\r?\n/g,""),e=t.indexOf(",");if(e===-1||e<=4)throw new TypeError("malformed data: URI");const a=t.substring(5,e).split(";");let n=!1;for(let s=1;s<a.length;s++)a[s]==="base64"&&(n=!0);const i=decodeURI(t.substring(e+1));return n?new Uint8Array(atob(i).split("").map(o=>o.charCodeAt(0))).buffer:new Uint8Array(i.split("").map(o=>o.charCodeAt(0))).buffer},Pi=r=>new Promise((t,e)=>{const a=new FileReader;a.onload=function(n){const i=n.target;!i||!i.result?e():t(i.result.toString())},a.readAsDataURL(r)});let Di,va;const xi=r=>{va=r},Fi=()=>va;let Qn;const Rn=r=>{Qn=r},ki=()=>new Promise(r=>{const t=At.getHubUrl(),e=a=>{a.origin===t&&(window.removeEventListener("message",e),r(a.data))};window.parent!==window&&(window.addEventListener("message",e,!1),window.parent.postMessage("ready",t))}),Mi=async()=>{const r={applicationKey:va,customerToken:Di,bearer:Qn};return typeof window<"u"&&(window.location.href.includes("/workflows/product/")||window.location.href.includes("hub=true"))?{...await ki(),...r}:r};async function Ti(r,t){const e=At.getServerUrl(),a=e.includes(".aumelbdev.spiffcommerce.com")?"https://moonlight.aumelbdev.spiffcommerce.com":e.includes(".us.spiffcommerce.com")?"https://moonlight.us.spiffcommerce.com":"https://moonlight.au.spiffcommerce.com";let n=await st(r,{...t,redirect:"manual"});return n.type==="opaqueredirect"&&(typeof r!="string"&&"url"in r?n=await st({...r,url:`${a}/graphql`},t):n=await st(`${a}/graphql`,t)),n}class Ni{constructor(){this.shadowGraphqlClient=this.constructShadowGraphqlClient(),At.addServerUrlCallback(()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()})}setSpiffCommerceClient(t){this.spiffClient=t,this.shadowGraphqlClient=this.constructShadowGraphqlClient()}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const t=v.createHttpLink({uri:`${At.getServerUrl()}/graphql`,fetch:Ti}),e=ni.setContext(async(i,s)=>{const{headers:o}=s,l=o||{},c=await Mi();let d=s.bearer??c.bearer;if(this.spiffClient)try{d=await this.spiffClient.loggedInBearerToken()}catch{}const A=s.partnerId??c.partnerId,u=s.activeIntegration??c.activeIntegration,h=s.transactionOwnerId,g=s.customerToken??c.customerToken,m=s.applicationKey??c.applicationKey,p=s.bundleOwnerId;try{if(window&&window.__SENTRY__){const f=window.__SENTRY__.hub;if(f){const C=f.traceHeaders();Object.entries(C).forEach(([w,S])=>{l[w]=S})}}}catch{}return d&&(l.Authorization=`Bearer ${d}`),A&&(l.partnerId=A),u&&(l.activeIntegration=u),h&&(l.transactionOwnerId=h),g&&(l.customerToken=g),m&&(l["X-Application-Key"]=m),p&&(l.bundleOwnerId=p),l["Allow-Moonlight-Redirect"]="true",{headers:l}}),a=ri.onError(({operation:i,graphQLErrors:s,networkError:o})=>{var d,A;const l=s||[],c=i.getContext();o&&!((A=(d=c==null?void 0:c.fetchOptions)==null?void 0:d.signal)!=null&&A.aborted)&&console.log("GraphQL Network error"),l.forEach(()=>console.log("GraphQL Error: "+i.operationName))}),n=si.removeTypenameFromVariables();return new v.ApolloClient({link:v.from([n,a,e,t]),cache:new v.InMemoryCache,name:"Core"})}}const B=new Ni;let la,ca;const pt=(r,t,e)=>{if(la!==void 0)return la(r,t,e);try{const a=On(!0);return Ea(a),a.createCanvas(r,t,e)}catch{throw new Error("Canvas module not set")}},oe=(r,t)=>{if(ca!==void 0)return ca(r,t);try{const e=On(!0);return Ea(e),e.loadImage(r,t)}catch{throw new Error("Canvas module not set")}};function Ea(r){la=r==null?void 0:r.createCanvas,ca=r==null?void 0:r.loadImage}function On(r){try{if(document.createElement("canvas").getContext("2d"))return{createCanvas:(e,a,n)=>{const i=document.createElement("canvas");return e!=null&&(i.width=e),a!=null&&(i.height=a),i},loadImage:(e,a)=>new Promise((n,i)=>{const s=document.createElement("img");a!==!1&&(s.crossOrigin="Anonymous"),s.onload=()=>{n(s)},s.onerror=i,s.src=e})}}catch(t){if(r)throw t}}let We;function ba(){return We===void 0&&(We=vi()),We}let Ce=null;const Qi=r=>new Promise(t=>{if(Re(r)!=="image/jpeg")return t(1);oi.orientation(r).then(a=>t(a||1)).catch(()=>t(1))}),Ri=async()=>{if(Ce!==null)return!Ce;const t=await oe("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return Ce=t.width===2&&t.height===3,!Ce},Oi=r=>{const e=r.naturalWidth/r.naturalHeight;return r.naturalHeight<=8192&&r.naturalWidth<=8192?[r.naturalWidth,r.naturalHeight]:r.naturalHeight>r.naturalWidth?[e*8192,8192]:[8192,8192/e]},$i=async r=>{var A;const t=await Ii(r),e=await oe(t),[a,n]=Oi(e);if(!await Ri()){const u=pt(a,n);return(A=u.getContext("2d"))==null||A.drawImage(e,0,0,a,n),u}const s=await Qi(r),[o,l]=s>4?[n,a]:[a,n],c=pt(o,l),d=c.getContext("2d");switch(s){case 2:d.translate(o,0),d.scale(-1,1);break;case 3:d.translate(o,l),d.rotate(Math.PI);break;case 4:d.translate(0,l),d.scale(1,-1);break;case 5:d.rotate(-.5*Math.PI),d.scale(-1,1);break;case 6:d.rotate(-.5*Math.PI),d.translate(-o,0);break;case 7:d.rotate(-.5*Math.PI),d.translate(-o,l),d.scale(1,-1);break;case 8:d.rotate(.5*Math.PI),d.translate(0,-l);break}return d.drawImage(e,0,0,o,l),c},le=async r=>{const t=await $i(r);return Re(r)==="image/jpeg"?{dataUrl:t.toDataURL("image/jpeg",1),height:t.height,width:t.width}:{dataUrl:t.toDataURL(),height:t.height,width:t.width}},ae=["Yellow C","Yellow 012 C","Orange 021 C","Warm Red C","Red 032 C","Rubine Red C","Rhodamine Red C","Purple C","Violet C","Blue 072 C","Reflex Blue C","Process Blue C","Green C","Black C","Yellow 0131 C","Red 0331 C","Magenta 0521 C","Violet 0631 C","Blue 0821 C","Green 0921 C","Black 0961 C","801 C","802 C","803 C","804 C","805 C","806 C","807 C","871 C","872 C","873 C","874 C","875 C","876 C","877 C","Medium Yellow C","Bright Orange C","Bright Red C","Strong Red C","Pink C","Medium Purple C","Dark Blue C","Medium Blue C","Bright Green C","Neutral Black C","100 C","101 C","102 C","103 C","104 C","105 C","7401 C","7402 C","7403 C","7404 C","7405 C","7406 C","7407 C","106 C","107 C","108 C","109 C","110 C","111 C","112 C","113 C","114 C","115 C","116 C","117 C","118 C","119 C","127 C","128 C","129 C","130 C","131 C","132 C","133 C","1205 C","1215 C","1225 C","1235 C","1245 C","1255 C","1265 C","120 C","121 C","122 C","123 C","124 C","125 C","126 C","7548 C","7549 C","7550 C","7551 C","7552 C","7553 C","7554 C","7555 C","7556 C","7557 C","7558 C","7559 C","7560 C","7561 C","134 C","135 C","136 C","137 C","138 C","139 C","140 C","1345 C","1355 C","1365 C","1375 C","1385 C","1395 C","1405 C","141 C","142 C","143 C","144 C","145 C","146 C","147 C","7408 C","7409 C","7410 C","7411 C","7412 C","7413 C","7414 C","7562 C","7563 C","7564 C","7565 C","7566 C","7567 C","7568 C","7569 C","7570 C","7571 C","7572 C","7573 C","7574 C","7575 C","712 C","713 C","714 C","715 C","716 C","717 C","718 C","148 C","149 C","150 C","151 C","152 C","153 C","154 C","155 C","156 C","157 C","158 C","159 C","160 C","161 C","1485 C","1495 C","1505 C","1525 C","1535 C","1545 C","1555 C","1565 C","1575 C","1585 C","1595 C","1605 C","1615 C","162 C","163 C","164 C","165 C","166 C","167 C","168 C","7576 C","7577 C","7578 C","7579 C","7580 C","7581 C","7582 C","1625 C","1635 C","1645 C","1655 C","1665 C","1675 C","1685 C","169 C","170 C","171 C","172 C","173 C","174 C","175 C","7583 C","7584 C","7585 C","7586 C","7587 C","7588 C","7589 C","7590 C","7591 C","7592 C","7593 C","7594 C","7595 C","7596 C","7597 C","7598 C","7599 C","7600 C","7601 C","7602 C","7603 C","7604 C","7605 C","7606 C","7607 C","7608 C","7609 C","7610 C","7611 C","7612 C","7613 C","7614 C","7615 C","7616 C","7617 C","7520 C","7521 C","7522 C","7523 C","7524 C","7525 C","7526 C","489 C","488 C","487 C","486 C","485 C","484 C","483 C","176 C","177 C","178 C","179 C","180 C","181 C","1765 C","1775 C","1785 C","1788 C","1795 C","1805 C","1815 C","1767 C","1777 C","1787 C","1797 C","1807 C","1817 C","7618 C","7619 C","7620 C","7621 C","7622 C","7623 C","7624 C","7625 C","7626 C","7627 C","7628 C","7629 C","7630 C","7631 C","7415 C","7416 C","7417 C","7418 C","7419 C","7420 C","7421 C","182 C","183 C","184 C","185 C","186 C","187 C","188 C","196 C","197 C","198 C","199 C","200 C","201 C","202 C","189 C","190 C","191 C","192 C","193 C","194 C","195 C","1895 C","1905 C","1915 C","1925 C","1935 C","1945 C","1955 C","705 C","706 C","707 C","708 C","709 C","710 C","711 C","698 C","699 C","700 C","701 C","702 C","703 C","704 C","203 C","204 C","205 C","206 C","207 C","208 C","209 C","210 C","211 C","212 C","213 C","214 C","215 C","216 C","7422 C","7423 C","7424 C","7425 C","7426 C","7427 C","7428 C","7632 C","7633 C","7634 C","7635 C","7636 C","7637 C","7638 C","217 C","218 C","219 C","220 C","221 C","222 C","7639 C","7640 C","7641 C","7642 C","7643 C","7644 C","7645 C","223 C","224 C","225 C","226 C","227 C","228 C","229 C","230 C","231 C","232 C","233 C","234 C","235 C","670 C","671 C","672 C","673 C","674 C","675 C","676 C","677 C","678 C","679 C","680 C","681 C","682 C","683 C","684 C","685 C","686 C","687 C","688 C","689 C","690 C","510 C","509 C","508 C","507 C","506 C","505 C","504 C","7429 C","7430 C","7431 C","7432 C","7433 C","7434 C","7435 C","691 C","692 C","693 C","694 C","695 C","696 C","697 C","496 C","495 C","494 C","493 C","492 C","491 C","490 C","503 C","502 C","501 C","500 C","499 C","498 C","497 C","5035 C","5025 C","5015 C","5005 C","4995 C","4985 C","4975 C","236 C","237 C","238 C","239 C","240 C","241 C","242 C","2365 C","2375 C","2385 C","2395 C","2405 C","2415 C","2425 C","243 C","244 C","245 C","246 C","247 C","248 C","249 C","7646 C","7647 C","7648 C","7649 C","7650 C","7651 C","7652 C","250 C","251 C","252 C","253 C","254 C","255 C","517 C","516 C","515 C","514 C","513 C","512 C","511 C","7436 C","7437 C","7438 C","7439 C","7440 C","7441 C","7442 C","2562 C","2572 C","2582 C","2592 C","2602 C","2612 C","2622 C","7653 C","7654 C","7655 C","7656 C","7657 C","7658 C","7659 C","524 C","523 C","522 C","521 C","520 C","519 C","518 C","5245 C","5235 C","5225 C","5215 C","5205 C","5195 C","5185 C","5175 C","5165 C","5155 C","5145 C","5135 C","5125 C","5115 C","531 C","530 C","529 C","528 C","527 C","526 C","525 C","256 C","257 C","258 C","259 C","260 C","261 C","262 C","2563 C","2573 C","2583 C","2593 C","2603 C","2613 C","2623 C","7660 C","7661 C","7662 C","7663 C","7664 C","7665 C","7666 C","2567 C","2577 C","2587 C","2597 C","2607 C","2617 C","2627 C","263 C","264 C","265 C","266 C","267 C","268 C","269 C","2635 C","2645 C","2655 C","2665 C","2685 C","2695 C","270 C","271 C","272 C","273 C","274 C","275 C","276 C","2705 C","2715 C","2725 C","2735 C","2745 C","2755 C","2765 C","7667 C","7668 C","7669 C","7670 C","7671 C","7672 C","7673 C","7443 C","7444 C","7445 C","7446 C","7447 C","7448 C","7449 C","7674 C","7675 C","7676 C","7677 C","7678 C","7679 C","7680 C","663 C","664 C","665 C","666 C","667 C","668 C","669 C","5315 C","5305 C","5295 C","5285 C","5275 C","5265 C","5255 C","538 C","537 C","536 C","535 C","534 C","533 C","532 C","7541 C","7542 C","7543 C","7544 C","7545 C","7546 C","7547 C","552 C","551 C","550 C","549 C","548 C","547 C","546 C","5455 C","5445 C","5435 C","5425 C","5415 C","5405 C","5395 C","642 C","643 C","644 C","645 C","646 C","647 C","648 C","649 C","650 C","651 C","652 C","653 C","654 C","655 C","656 C","657 C","658 C","659 C","660 C","661 C","662 C","7450 C","7451 C","7452 C","7453 C","7454 C","7455 C","7456 C","2706 C","2716 C","2726 C","2736 C","2746 C","2756 C","2766 C","2708 C","2718 C","2728 C","2738 C","2748 C","2758 C","2768 C","2707 C","2717 C","2727 C","2747 C","2757 C","2767 C","277 C","278 C","279 C","280 C","281 C","282 C","283 C","284 C","285 C","286 C","287 C","288 C","289 C","7681 C","7682 C","7683 C","7684 C","7685 C","7686 C","7687 C","545 C","544 C","543 C","542 C","541 C","540 C","539 C","290 C","291 C","292 C","293 C","294 C","295 C","296 C","2905 C","2915 C","2925 C","2935 C","2945 C","2955 C","2965 C","297 C","298 C","299 C","300 C","301 C","302 C","303 C","7688 C","7689 C","7690 C","7691 C","7692 C","7693 C","7694 C","2975 C","2985 C","2995 C","3005 C","3015 C","3025 C","3035 C","7695 C","7696 C","7697 C","7698 C","7699 C","7700 C","7701 C","7457 C","7458 C","7459 C","7460 C","7461 C","7462 C","7463 C","304 C","305 C","306 C","307 C","308 C","309 C","635 C","636 C","637 C","638 C","639 C","640 C","641 C","7702 C","7703 C","7704 C","7705 C","7706 C","7707 C","7708 C","628 C","629 C","630 C","631 C","632 C","633 C","634 C","310 C","311 C","312 C","313 C","314 C","315 C","316 C","3105 C","3115 C","3125 C","3135 C","3145 C","3155 C","3165 C","7709 C","7710 C","7711 C","7712 C","7713 C","7714 C","7715 C","317 C","318 C","319 C","320 C","321 C","322 C","323 C","7464 C","7465 C","7466 C","7467 C","7468 C","7469 C","7470 C","7471 C","7472 C","7473 C","7474 C","7475 C","7476 C","7477 C","5523 C","5513 C","5503 C","5493 C","5483 C","5473 C","5463 C","7716 C","7717 C","7718 C","7719 C","7720 C","7721 C","7722 C","324 C","325 C","326 C","327 C","328 C","329 C","330 C","3242 C","3252 C","3262 C","3272 C","3282 C","3292 C","3302 C","3245 C","3255 C","3265 C","3275 C","3285 C","3295 C","3305 C","3248 C","3258 C","3268 C","3278 C","3288 C","3298 C","3308 C","566 C","565 C","564 C","563 C","562 C","561 C","560 C","573 C","572 C","571 C","570 C","569 C","568 C","567 C","559 C","558 C","557 C","556 C","555 C","554 C","553 C","5595 C","5585 C","5575 C","5565 C","5555 C","5545 C","5535 C","5665 C","5655 C","5645 C","5635 C","5625 C","5615 C","5605 C","5527 C","5517 C","5507 C","5497 C","5487 C","5477 C","5467 C","621 C","622 C","623 C","624 C","625 C","626 C","627 C","331 C","332 C","333 C","334 C","335 C","336 C","337 C","338 C","339 C","340 C","341 C","342 C","343 C","7723 C","7724 C","7725 C","7726 C","7727 C","7728 C","7729 C","3375 C","3385 C","3395 C","3405 C","3415 C","3425 C","3435 C","344 C","345 C","346 C","347 C","348 C","349 C","350 C","351 C","352 C","353 C","354 C","355 C","356 C","357 C","7478 C","7479 C","7480 C","7481 C","7482 C","7483 C","7484 C","7730 C","7731 C","7732 C","7733 C","7734 C","7735 C","7736 C","7737 C","7738 C","7739 C","7740 C","7741 C","7742 C","7743 C","358 C","359 C","360 C","361 C","362 C","363 C","364 C","7485 C","7486 C","7487 C","7488 C","7489 C","7490 C","7491 C","365 C","366 C","367 C","368 C","369 C","370 C","371 C","372 C","373 C","374 C","375 C","376 C","377 C","378 C","580 C","579 C","578 C","577 C","576 C","575 C","574 C","5807 C","5797 C","5787 C","5777 C","5767 C","5757 C","5747 C","5875 C","5865 C","5855 C","5845 C","5835 C","5825 C","5815 C","5803 C","5793 C","5783 C","5773 C","5763 C","5753 C","5743 C","7492 C","7493 C","7494 C","7495 C","7496 C","7497 C","7498 C","7744 C","7745 C","7746 C","7747 C","7748 C","7749 C","7750 C","379 C","380 C","381 C","382 C","383 C","384 C","385 C","386 C","387 C","388 C","389 C","390 C","391 C","392 C","587 C","586 C","585 C","584 C","583 C","582 C","581 C","393 C","394 C","395 C","396 C","397 C","398 C","399 C","3935 C","3945 C","3955 C","3965 C","3975 C","3985 C","3995 C","600 C","601 C","602 C","603 C","604 C","605 C","606 C","607 C","608 C","609 C","610 C","611 C","612 C","613 C","461 C","460 C","459 C","458 C","457 C","456 C","455 C","614 C","615 C","616 C","617 C","618 C","619 C","620 C","7751 C","7752 C","7753 C","7754 C","7755 C","7756 C","7757 C","7758 C","7759 C","7760 C","7761 C","7762 C","7763 C","7764 C","7765 C","7766 C","7767 C","7768 C","7769 C","7770 C","7771 C","4545 C","4535 C","4525 C","4515 C","4505 C","4495 C","4485 C","454 C","453 C","452 C","451 C","450 C","449 C","448 C","7499 C","7500 C","7501 C","7502 C","7503 C","7504 C","7505 C","468 C","467 C","466 C","465 C","464 C","463 C","462 C","7506 C","7507 C","7508 C","7509 C","7510 C","7511 C","7512 C","719 C","720 C","721 C","722 C","723 C","724 C","725 C","475 C","474 C","473 C","472 C","471 C","470 C","469 C","726 C","727 C","728 C","729 C","730 C","731 C","732 C","4685 C","4675 C","4665 C","4655 C","4645 C","4635 C","4625 C","7513 C","7514 C","7515 C","7516 C","7517 C","7518 C","7519 C","4755 C","4745 C","4735 C","4725 C","4715 C","4705 C","4695 C","482 C","481 C","480 C","479 C","478 C","477 C","476 C","7527 C","7528 C","7529 C","7530 C","7531 C","7532 C","7533 C","7534 C","7535 C","7536 C","7537 C","7538 C","7539 C","7540 C","427 C","428 C","429 C","430 C","431 C","432 C","433 C","420 C","421 C","422 C","423 C","424 C","425 C","426 C","441 C","442 C","443 C","444 C","445 C","446 C","447 C","413 C","414 C","415 C","416 C","417 C","418 C","419 C","400 C","401 C","402 C","403 C","404 C","405 C","406 C","407 C","408 C","409 C","410 C","411 C","412 C","434 C","435 C","436 C","437 C","438 C","439 C","440 C","Warm Gray 1 C","Warm Gray 2 C","Warm Gray 3 C","Warm Gray 4 C","Warm Gray 5 C","Warm Gray 6 C","Warm Gray 7 C","Warm Gray 8 C","Warm Gray 9 C","Warm Gray 10 C","Warm Gray 11 C","Cool Gray 1 C","Cool Gray 2 C","Cool Gray 3 C","Cool Gray 4 C","Cool Gray 5 C","Cool Gray 6 C","Cool Gray 7 C","Cool Gray 8 C","Cool Gray 9 C","Cool Gray 10 C","Cool Gray 11 C","Black 2 C","Black 3 C","Black 4 C","Black 5 C","Black 6 C","Black 7 C"],Qt=["FEDD00","FFD700","FE5000","F9423A","EF3340","CE0058","E10098","BB29BB","440099","10069F","001489","0085CA","00AB84","2D2926","F2F0A1","FCAEBB","F1B2DC","BF9BDE","74D1EA","9DE7D7","9E978E","009ACE","44D62C","FFE900","FFAA4D","FF7276","FF3EB5","EA27C2","84754E","85714D","866D4B","8B6F4E","87674F","8B634B","8A8D8F","FFD900","FF5E00","F93822","CE0056","D62598","4E008E","00239C","0084CA","00B08B","222223","F6EB61","F7EA48","FCE300","C5A900","AF9800","897A27","F5E1A4","ECD898","EED484","F4DA40","F2CD00","F1C400","CBA052","F9E547","FBE122","FEDB00","FFD100","DAAA00","AA8A00","9C8412","FAE053","FBDD40","FDDA24","FFCD00","C99700","AC8400","897322","F3DD6D","F3D54E","F3D03E","F2A900","CC8A00","A07400","6C571B","F8E08E","FBD872","FFC845","FFB81C","C69214","AD841F","886B25","FBDB65","FDD757","FED141","FFC72C","EAAA00","B58500","9A7611","FFC600","FFB500","D19000","B47E00","73531D","5A4522","4B3D2A","D29F13","B78B20","9F7D23","967126","8F6A2A","7D622E","6C5D34","FDD26E","FFC658","FFBF3F","FFA300","DE7C00","AF6D04","74531C","FDD086","FFC56E","FFB549","FF9E1B","D57800","996017","6E4C1E","F2C75C","F1BE48","F1B434","ED8B00","CF7F00","A76D11","715C2A","F6BE00","F0B323","FEAD77","E6A65D","D38235","DC8633","C16C18","BD9B60","D69A2D","DB8A06","CD7925","AD6433","89532F","775135","D78825","D3832B","C67D30","B67233","A7662B","9E6A38","835D32","FCC89B","FDBE87","FDAA63","F68D2E","EA7600","D45D00","BE4D00","FECB8B","FFC27B","FFB25B","FF8200","E57200","BE6A14","9B5A1A","EFD19F","EFBE7D","ECA154","E87722","CB6015","A1561C","603D20","FFAE62","FF8F1C","FF6900","B94700","94450B","653819","FFB990","FFA06A","FF7F32","FF6A13","D86018","A65523","8B4720","FFBE9F","FF9D6E","FF7F41","FF671F","E35205","BE531C","73381D","DB864E","E07E3C","DC6B2F","DC582A","C05131","864A33","674736","FFA38B","FF8D6D","FF6A39","FC4C02","DC4405","A9431E","833921","FFB3AB","FF8674","FF5C39","FA4616","CF4520","963821","6B3529","C4622D","BA5826","AF5C37","9E5330","924C2E","7B4D35","5C4738","D4B59E","C07D59","B15533","9D432C","7C3A2D","6B3D2E","5C3D31","D14124","BD472A","B33D26","8D3F2B","83412C","7B4931","674230","E4D5D3","E1BBB4","D6938A","C26E60","A4493D","823B34","683431","DDBCB0","CA9A8E","BC8A7E","A37F74","866761","6B4C4C","583D3E","EABEB0","C09C83","B46A55","AB5C57","A45248","9A6A4F","8A391B","ECC3B2","ECBAA8","EAA794","E8927C","DA291C","9A3324","653024","FFB1BB","FF808B","FF585D","E03C31","BE3A34","81312F","FFA3B5","FF8DA1","F8485E","EE2737","D22630","AF272F","7C2529","FCAFC0","FB637E","F4364C","CB333B","A4343A","643335","C66E4E","C04C36","B7312C","AB2328","93272C","8A2A2B","802F2D","E1523D","C63527","A72B2A","9E2A2B","6D3332","633231","572D2D","E6BAA8","E56A54","E04E39","CD545B","B04A5A","9B2242","651D32","FABBCB","FC9BB3","F65275","E4002B","C8102E","A6192E","76232F","ECC7CD","E89CAE","DF4661","D50032","BA0C2F","9D2235","862633","F8A3BC","F67599","EF426F","E40046","BF0D3E","9B2743","782F40","F5B6CD","F59BBB","EF4A81","E0004D","C5003E","A6093D","8A1538","F5DADF","F7CED7","F9B5C4","F890A5","EF6079","E03E52","CB2C30","F2D4D7","F4C3CC","F2ACB9","E68699","D25B73","B83A4B","9E2A2F","ECB3CB","E782A9","E0457B","CE0037","A50034","861F41","6F263D","F99FC9","F57EB6","F04E98","E31C79","CE0F69","AC145A","7D2248","F4CDD4","E06287","E24585","B52555","A4123F","971B2F","6A2C3E","D6C9CA","C4A4A7","C16784","C63663","BC204B","912F46","7E2D40","EABEDB","E56DB1","DA1884","A50050","910048","6C1D45","936D73","934054","8E2C48","732E4A","672E45","582D40","502B3A","EF95CF","EB6FBD","DF1995","D0006F","AA0061","890C58","672146","F4A6D7","F277C6","E93CAC","C6007E","A20067","840B55","EAD3E2","E6BCD8","DFA0C9","D986BA","C6579A","AE2573","960051","E5CEDB","E3C8D8","DEBED2","C996B6","B06C96","994878","7C2855","E4C6D4","DCB6C9","D0A1BA","BE84A3","A76389","893B67","612141","EBBECB","E8B3C3","E4A9BB","D592AA","84344E","6F2C3F","572932","E2BCCB","DCA9BF","C9809E","B55C80","A73A64","9B3259","872651","E9CDD0","E4BEC3","D7A3AB","C48490","B46B7A","984856","893C47","F2C6CF","F1BDC8","E9A2B2","DC8699","8F3237","7F3035","5D2A2C","E9C4C7","E5BAC1","DAA5AD","C6858F","7A3E3A","6A3735","512F2E","DFC2C3","DBB7BB","CCA1A6","B07C83","9C6169","874B52","3F2021","F1A7DC","EC86D0","E45DBF","DB3EB1","C5299B","AF1685","80225F","EFBAE1","E277CD","D539B5","C800A1","B0008E","9E007E","830065","EAB8E4","E59BDC","DD7FD3","C724B1","BB16A3","A51890","80276C","A56E87","A83D72","991E66","8A1B61","722257","6A2A5B","5E2751","E7BAE4","DD9CDF","C964CF","AD1AAC","981D97","72246C","EBC6DF","E6BEDD","E2ACD7","D48BC8","93328E","833177","612C51","EEDAEA","CCAED0","D59ED7","B288B9","A277A6","9F5CC0","963CBD","D7A9E3","C98BDB","AC4FC6","9B26B6","87189D","772583","653165","948794","A2789C","A15A95","8E3A80","6E2B62","6A3460","5D3754","D5C2D8","C9B1D0","BA9CC5","A57FB2","642F6C","59315F","4B3048","DBCDD3","D0BEC7","C6B0BC","AF95A6","86647A","66435A","4A3041","D8C8D1","D3C0CD","BFA5B8","9B7793","7E5475","693C5E","512A44","DFC8E7","D7B9E4","CAA2DD","B580D1","8031A7","702F8A","572C5F","D6BFDD","C6A1CF","8C4799","6D2077","642667","5D285F","51284F","CBA3D8","B884CB","A05EB5","84329B","702082","671E75","5F2167","9991A4","8D6E97","7A4183","6B3077","653279","5E366E","5C4E63","C1A0DA","A77BCA","8246AF","5C068C","500778","470A68","3C1053","D7C6E6","C1A7E2","9063CD","753BBD","5F259F","582C83","512D6D","C5B4E3","AD96DC","9678D3","7D55C7","330072","2E1A47","B4B5DF","9595D2","7474C1","24135F","211551","201747","221C35","A7A4E0","8B84D7","685BC7","2E008B","280071","250E62","201547","6E7CA0","686E9F","615E9B","565294","514689","4C4184","535486","DDDAE8","B6B8DC","A7A2C3","8986CA","5D4777","4B384C","41273B","878CB4","7C7FAB","7566A0","6F5091","68478D","563D82","523178","E5E1E6","E0DBE3","C6BCD0","A192B2","7C6992","614B79","3F2A56","D8D7DF","C6C4D2","B3B0C4","8D89A5","595478","403A60","1E1A34","C5CFDA","BBC7D6","A2B2C8","8E9FBC","1B365D","1F2A44","1C1F2A","D9E1E2","A4BCC2","98A4AE","768692","425563","253746","131E29","B9D3DC","A3C7D2","8DB9CA","6BA4B8","003D4C","00313C","072B31","BFCED6","B7C9D3","A6BBC8","7A99AC","5B7F95","4F758B","081F2C","D1DDE6","C6D6E3","9BB8D3","7DA1C4","5E8AB4","236192","002E5D","DBE2E9","CED9E5","A7BCD6","7D9BC1","326295","003A70","002554","DDE5ED","C8D8EB","B1C9E8","7BA4DB","407EC9","003594","001A70","BDC5DB","89ABE3","8094DD","7BA6DE","5F8FB4","3A5DAE","606EB2","CBD3EB","9FAEE5","485CC7","1E22AA","171C8F","151F6D","141B4D","B8CCEA","5C88DA","0047BB","06038D","001871","001E62","071D49","C3D7EE","A7C6ED","307FE2","001A72","001E60","13294B","ABCAE9","8BB8E8","418FDE","012169","00205B","041E42","92C1E9","6CACE4","0072CE","0033A0","003087","002D72","0C2340","94A9CB","6787B7","426DA9","385E9D","2C5697","1D4F91","1D428A","C6DAE7","BDD6E6","A4C8E1","7BAFD4","003C71","003057","00263A","B9D9EB","9BCBEB","69B3E7","003DA5","002F6C","002855","041C2C","8DC8E8","62B5E5","009CDE","0057B8","004C97","003865","00263E","71C5E8","41B6E6","00A3E0","005EB8","004B87","003B5C","002A3A","4698CB","298FC2","0076A8","006298","005587","004976","01426A","99D6EA","5BC2E7","00A9E0","0077C8","00629B","004F71","003E51","7BA7BC","6399AE","4E87A0","41748D","34657F","165C7D","005776","BBDDE6","71B2C9","4298B5","0086BF","007DBA","00558C","002B49","9ADBE8","59CBE8","00B5E2","006BA6","00587C","003B49","A4DBE8","8BD3E6","4EC3E0","00AFD7","0095C8","0082BA","0067A0","48A9C5","009CBD","0085AD","007096","006A8E","00617F","005670","B8DDE1","9BD3DD","77C5D5","3EB1C8","0093B2","007396","005F83","6AD1E3","05C3DE","00A9CE","0092BC","007FA3","00677F","004851","68D2DF","00C1D5","00AEC7","008EAA","00778B","006272","004F59","63B1BC","00A7B5","0097A9","00859B","007D8A","007680","006269","B1E4E3","88DBDF","2DCCD3","009CA6","008C95","007377","005F61","A0D1CA","40C1AC","00B0B9","00A3AD","007398","005F86","005A70","7EDDD3","5CB8B2","279989","007681","487A7B","0D5257","244C5A","B6CFD0","ABC7CA","94B7BB","7FA9AE","4F868E","115E67","07272D","00968F","00857D","007672","006D68","00635B","005E5D","005151","9CDBD9","64CCC9","00B2A9","008675","007367","00685E","00534C","71DBD4","2AD2C9","00BFB3","00A499","008578","00594F","004C45","7CE0D3","2CD5C4","00C7B1","00B398","009681","007864","004E42","6DCDB8","49C5B1","00AB8E","009B77","008264","006A52","034638","B9DCD2","A1D6CA","86C8BC","6BBBAE","006F62","00594C","1D3C34","B5E3D8","A5DFD3","98DBCE","6BCABA","00816D","006C5B","173F35","ADCAB8","9ABEAA","85B09A","6FA287","28724F","205C40","284734","BFCEC2","A7BDB1","92ACA0","7F9C90","5C7F71","43695B","183028","BAC5B9","B0BDB0","A3B2A4","94A596","708573","5E7461","22372B","BCC9C5","B1C0BC","9DB0AC","829995","5D7975","3E5D58","18332F","D1E0D7","B7CDC2","9AB9AD","789F90","507F70","285C4D","13322B","A7E6D7","8CE2D0","3CDBC0","009775","007B5F","00664F","8FD6BD","6ECEB2","00B388","00965E","007A53","006747","115740","50A684","00966C","008755","007B4B","006F44","006845","005844","7AE1BF","47D7AC","00C389","00AF66","007749","006341","154734","A0DAB3","91D6AC","71CC98","009A44","00843D","046A38","2C5234","A2E4B8","8FE2B0","80E0A7","00B140","009639","007A33","215732","9BE3BF","26D07C","00BF6F","00B74F","009F4D","275D38","00573F","4B9560","228848","007A3E","007041","286140","36573B","395542","6BA539","48A23F","319B42","3A913F","44883E","4A773C","44693D","ADDC91","A1D884","6CC24A","43B02A","509E2F","4C8C2B","4A7729","D0DEBB","BCE194","8EDD65","78D64B","74AA50","719949","79863C","C2E189","B7DD79","A4D65E","78BE20","64A70B","658D1B","546223","D4EB8E","CDEA80","C5E86C","97D700","84BD00","7A9A01","59621D","C4D6A4","BCD19B","B7CE95","A9C47F","789D4A","67823A","4E5B31","D0D1AB","C6C89B","BABD8B","A2A569","8A8D4A","6D712E","3D441E","D2CE9E","CBC793","C0BB87","AFA96E","A09958","89813D","555025","C3C6A8","B3B995","A3AA83","899064","737B4C","5E6738","3E4827","BFCC80","BBC592","9CAF88","8F993E","76881D","7A7256","5B6236","BABC16","ABAD23","999B30","888D30","7C8034","727337","656635","E2E868","DBE442","CEDC00","C4D600","A8AD00","949300","787121","E9EC6B","E3E935","E0E721","D0DF00","B5BD00","9A9500","827A04","E3E48D","E0E27C","DBDE70","D2D755","B7BF10","8E8C13","625D20","F0EC74","EDE939","ECE81A","E1E000","BFB800","ADA400","A09200","F3EA5D","F3E500","EFDF00","EEDC00","BBA600","9A8700","685C20","F1EB9C","F0E991","F0E87B","EDE04B","EADA24","E1CD00","CFB500","EBE49A","E9E186","E6DE77","E1D555","D7C826","C4B000","B39B00","E9DF97","E4D77E","DECD63","D9C756","B89D18","A28E2A","695B24","DCD59A","D6CF8D","D0C883","C0B561","AC9F3C","9F912A","8A7B19","CAB64B","CFB023","C1A01E","A08629","897630","736635","675E33","D4C304","C4B200","91852C","747136","5D6439","585C3B","535435","BBB323","B4A91F","AA9D2E","8F7E35","716135","635939","4E4934","D5CB9F","CFC493","C5B783","B3A369","998542","8C7732","614F25","CAC7A7","BFBB98","B0AA7E","9B945F","594A25","524727","4A412A","F1E6B2","DFD1A7","D9C89E","CEB888","A89968","94795D","816040","DDCBA4","D3BC8D","C6AA76","B9975B","8B5B29","744F28","5C462B","EFDBB2","FCD299","E1B87F","D6A461","C6893F","B77729","A6631B","EDC8A3","E7B78A","DDA46F","C88242","B36924","934D11","7D3F16","F3CFB3","F1C6A7","F0BF9B","E59E6D","B86125","A45A2A","693F23","E0C09F","D9B48F","CDA077","B58150","9E652E","774212","623412","E0C6AD","DCBFA6","CDA788","BF9474","AD7C59","946037","4F2C1D","E1B7A7","D5A286","C58B68","99552B","85431E","6D4F47","5E4B3C","D7C4B7","CDB5A7","C0A392","AE8A79","956C58","7C4D3A","5B3427","DBC8B6","D3BBA8","C6A992","AA8066","703F2A","623B2A","4E3629","D6D2C4","C5B9AC","B7A99A","A39382","7A6855","63513D","473729","D1CCBD","B7B09C","A69F88","A7ACA2","949A90","8E9089","4B4F54","D0D3D4","C1C6C8","A2AAAD","7C878E","5B6770","333F48","1D252D","C7C9C7","B2B4B2","9EA2A2","898D8D","707372","54585A","25282A","BEC6C4","A2ACAB","919D9D","717C7D","505759","3F4444","373A36","BABBB1","A8A99E","919388","7E7F74","65665C","51534A","212322","C4BFB6","AFA9A0","9D968D","8C857B","776E64","696158","C4BCB7","B2A8A2","978C87","857874","746661","5E514D","382F2D","D0C4C5","C1B2B6","AB989D","7B6469","584446","453536","382E2C","D7D2CB","CBC4BC","BFB8AF","B6ADA5","ACA39A","A59C94","968C83","8C8279","83786F","796E65","6E6259","D9D9D6","D0D0CE","C8C9C7","BBBCBC","B1B3B3","A7A8AA","97999B","888B8D","75787B","63666A","53565A","332F21","212721","31261D","3E2B2E","101820","3D3935"],je=Qt.map(r=>[parseInt(r.substring(0,2),16),parseInt(r.substring(2,4),16),parseInt(r.substring(4,6),16)]);function Ui(r){const t=ae.indexOf(r);return t>=0?Qt[t]:""}function $n(r){const t=Qt.indexOf(r);return t>=0?ae[t]:""}function Li(r,t=64){const e=[],a=[],n=$n(r);n&&e.push({pms:n,hex:r,distance:0});const i=parseInt(r.substring(0,2),16),s=parseInt(r.substring(2,4),16),o=parseInt(r.substring(4,6),16);let l,c,d;for(let A=0;A<Qt.length;A++){l=je[A][0],c=je[A][1],d=je[A][2];const u=Math.sqrt(Math.pow(i-l,2)+Math.pow(s-c,2)+Math.pow(o-d,2));a.push(u)}for(let A=0;A<a.length;A++)a[A]<=t&&!e.some(u=>u.pms===ae[A])&&e.push({pms:ae[A],hex:Qt[A],distance:a[A]});return e.sort((A,u)=>A.distance-u.distance)}const Vi=ae.map((r,t)=>({pms:r,hex:Qt[t]})),zi=new li(Vi,{keys:["pms"]});function Gi(r,t){return zi.search(r,t?{limit:t}:void 0)}let Lt=null;function Un(r){if(r.startsWith("#"))return en(r);if(!document)throw new Error("browserColorToHex is only supported on browsers");if(Lt||(Lt=document.createElement("canvas").getContext("2d")),!Lt)throw new Error("Failed to create canvas context required to convert colors");Lt.fillStyle=r;const t=en(Lt.fillStyle);return t||console.error(`Unknown browser color ${r}`),t}function en(r){const t=r.substring(1).toUpperCase();return t.length===6?t:t.length===3?`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`:""}const we=r=>{const t=Ln(r.spotColor);return t?`${r.browserValue} ${t}`:r.browserValue},Ln=r=>{if(!r)return"";if(r.profileName.includes("/")&&r.profileName.includes(".icc")){const t=r.profileName.replace(/\s/g,"-"),e=t.lastIndexOf("/");return`icc-named-color(${t.slice(e+1).slice(0,-4)}, ${r.namedColor})`}return`icc-named-color(${r.profileName}, ${r.namedColor})`},da=r=>{const t=r.split(/[ ](?=[^)]*?(?:\(|$))/);if(t.length===0)return{browserValue:"#000000"};if(t.length===1)return{browserValue:t[0]};const e=t[1].match(/\(([^)]+)\)/gm);if(!e)throw new Error("Unhandled state of color value in SVG");const a=e[0].replace(/[() ]/g,"").split(",");return{browserValue:t[0],spotColor:{profileName:a[0],namedColor:a[1]}}},qi=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],Wi=["fill","stroke"],Rt=(r,t)=>{t(r),r.children.length>0&&Array.from(r.children).forEach(e=>Rt(e,t))},ji=(r,t)=>{try{return r.matches(t)}catch{return r.classList.contains(t.substring(1))}},$e=(r,t=!1)=>{!t&&r.setAttribute("preserveAspectRatio","none");const e=[];Rt(r,a=>{var i,s,o;if(a.tagName==="script"){a.remove();return}if(a.tagName==="style"){try{(i=yn.parse(a.innerHTML).stylesheet)==null||i.rules.forEach(c=>{e.push(c)}),a.remove()}catch(l){console.error(l)}return}const n=(o=(s=a.attributes.getNamedItem("style"))==null?void 0:s.value)==null?void 0:o.trim();if(n){const l=[];n.split(";").forEach(d=>{const A=d.trim();if(A){const[u,h]=A.split(":"),g=u.toLowerCase();Wi.indexOf(g)>-1?a.setAttribute(g,h.trim()):l.push(A)}}),l.length>0?a.setAttribute("style",l.join(";")):a.removeAttribute("style")}}),Rt(r,a=>{e.forEach(n=>{var i;(i=n.selectors)==null||i.forEach(s=>{var o;ji(a,s)&&((o=n.declarations)==null||o.forEach(l=>{l.property&&l.value&&a.setAttribute(l.property,l.value)}))})})})},Hi=r=>{const t=/pt|pc|mm|cm|in/gm,e=r.getAttribute("viewBox"),a=r.getAttribute("width"),n=r.getAttribute("height");if(!e)throw new Error("viewBox not specified on SVG!");a&&r.setAttribute("width",a.replace(t,"")),n&&r.setAttribute("height",n.replace(t,""))},Vn=r=>ct().parseFromString(r,"image/svg+xml").firstElementChild,Yi=(r,t,e)=>{r.setAttribute("height",`${e}px`),r.setAttribute("width",`${t}px`)},zn=(r,t,e)=>{Rt(r,a=>{const n=a.attributes.getNamedItem("fill");n&&n.value!=="none"&&a.classList.forEach(s=>{if(s.startsWith("spiff-fill")){const o=t[s.replace("spiff-fill-","")];if(o)a.setAttribute("fill",e?we(o):o.browserValue);else{const l=t[s];l&&a.setAttribute("fill",e?we(l):l.browserValue)}}});const i=a.attributes.getNamedItem("stroke");i&&i.value!=="none"&&a.classList.forEach(s=>{if(s.startsWith("spiff-stroke")){const o=t[s.replace("spiff-stroke-","")];if(o)a.setAttribute("stroke",e?we(o):o.browserValue);else{const l=t[s];l&&a.setAttribute("fill",e?we(l):l.browserValue)}}})})},Gn=r=>wt().serializeToString(r),Ba=(r,t,e,a,n)=>{const i=Vn(r);if(!i)throw new Error("Failed to read SVG.");return Yi(i,t,e),zn(i,a,n),Gn(i)},Ue=(r,t,e)=>{const a=Vn(r);if(!a)throw new Error("Failed to read SVG.");return zn(a,t,e),Gn(a)},Ji=r=>{const t=/<svg.*<\/svg>/s,e=r.match(t)||[],a=(e==null?void 0:e.length)>0?e[0]:"";return ct().parseFromString(a,"image/svg+xml")},ot=async r=>{const e=Ji(r).firstElementChild;if(!e)throw new Error("Failed to read SVG.");$e(e);const a={};Rt(e,s=>{qi.includes(s.tagName)&&!s.attributes.getNamedItem("fill")&&s.setAttribute("fill","black");const o=s.attributes.getNamedItem("fill");if(o&&o.value!=="none"&&!o.value.startsWith("url(")){const c=da(o.value),d=c.browserValue.replace(/\W/g,""),A=`spiff-fill-${d}`;s.setAttribute("fill",c.browserValue),s.classList.add(A),a[d]=c}const l=s.attributes.getNamedItem("stroke");if(l&&l.value!=="none"&&!l.value.startsWith("url(")){const c=da(l.value),d=c.browserValue.replace(/\W/g,""),A=`spiff-stroke-${d}`;s.classList.add(A),s.setAttribute("stroke",c.browserValue),a[d]=c}});const i=wt().serializeToString(e);return{colors:a,svg:i}},Ki=v.gql`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("@apollo/client/core"),ni=require("@apollo/client/link/context"),ri=require("@apollo/client/link/error"),ii=require("preact-render-to-string"),si=require("@apollo/client/link/remove-typename"),oi=require("exifr/dist/mini.umd.cjs"),Sn=require("css"),li=require("fuse.js"),Sa=require("pith"),Et=require("lodash.clonedeep"),vn=require("qrcode"),ci=require("svg-path-bbox"),ra=require("opentype.js"),F=require("preact/jsx-runtime"),di=require("handlebars"),Ai=require("data-uri-to-buffer"),Ka=require("lodash.chunk"),pe=require("@aws-sdk/client-cognito-identity-provider"),ui=require("dinero.js"),hi=require("currency-codes"),En=require("lodash.isequal"),ia=require("unicode-default-word-boundary"),bn=require("lodash.debounce");require("fs");require("path");function gi(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const a=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,a.get?a:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const _a=gi(hi);var Xt=(r=>(r.Data="Data",r.Font="Font",r.Frame="Frame",r.Illustration="Illustration",r.Image="Image",r.Model="Model",r.Material="Material",r.Color="Color",r.QuestionnaireCollateral="QuestionnaireCollateral",r.RequestCollateral="RequestCollateral",r.SignupCollateral="SignupCollateral",r.Video="Video",r.ColorProfile="ColorProfile",r.Environment="Environment",r))(Xt||{}),V=(r=>(r.FileUpload="FileUpload",r.Option="Option",r.ColorOption="ColorOption",r.Text="Text",r))(V||{}),I=(r=>(r.Information="Information",r.Bulk="Bulk",r.DigitalContent="DigitalContent",r.Finish="Finish",r.Frame="Frame",r.Illustration="Illustration",r.Introduction="Introduction",r.Material="Material",r.Model="Model",r.Module="Module",r.Picture="Picture",r.Photo="Photo",r.ProductOverlay="ProductOverlay",r.Question="Question",r.Shape="Shape",r.SilentIllustration="SilentIllustration",r.Text="Text",r))(I||{}),Bn=(r=>(r.Color="Color",r.Colors="Colors",r.Selection="Selection",r.Selections="Selections",r.Text="Text",r.Upload="Upload",r))(Bn||{}),Tt=(r=>(r.ThreeD="ThreeD",r.FreeDesign="FreeDesign",r.Print="Print",r))(Tt||{}),M=(r=>(r.Frame="frame",r.Group="group",r.Image="image",r.Pattern="pattern",r.Illustration="illustration",r.Textbox="textbox",r))(M||{}),In=(r=>(r.Default="Default",r.FirstTransaction="FirstTransaction",r.OneToOne="OneToOne",r))(In||{}),Pn=(r=>(r.Hyperlink="Hyperlink",r.Edit="Edit",r.Approve="Approve",r))(Pn||{}),Fn=(r=>(r.Hub="Hub",r.Shopify="Shopify",r))(Fn||{}),Me=(r=>(r.BackgroundRemover="BackgroundRemover",r.ConversionAccelerator="Conversion Accelerator",r.ProcessBuilder="ProcessBuilder",r))(Me||{}),Dn=(r=>(r[r.Orbit=0]="Orbit",r[r.Pan=1]="Pan",r))(Dn||{}),Zt=(r=>(r.Owner="Owner",r.Approver="Approver",r.Editor="Editor",r.Viewer="Viewer",r))(Zt||{}),Bt=(r=>(r.Autosize="Autosize",r.Traditional="Traditional",r))(Bt||{}),j=(r=>(r[r.North=0]="North",r[r.Northeast=1]="Northeast",r[r.East=2]="East",r[r.Southeast=3]="Southeast",r[r.South=4]="South",r[r.Southwest=5]="Southwest",r[r.West=6]="West",r[r.Northwest=7]="Northwest",r))(j||{}),xn=(r=>(r.Pixel="px",r.Millimeter="mm",r.Centimeter="cm",r))(xn||{});class kn extends Error{constructor(t){super(t),this.name=this.constructor.name}}class ie extends kn{constructor(t){super(`ConfigurationError - ${t}`)}}class te extends ie{constructor(t){super(`Option not Configured: ${t.stepTitle}`),this.optionId=(t==null?void 0:t.optionId)||"N/A"}}class Y extends ie{constructor(t){super(`Panel not Found: ${t.panelId}`),this.panelId=(t==null?void 0:t.panelId)||"N/A"}}class mt extends ie{constructor(t){super(`Asset not found for variant: ${t.name}`),this.variant=t}}class Nt extends ie{constructor(t){super(`Resource not found for asset: ${t.name}`),this.asset=t}}class ee extends ie{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),this.step=t}}class Te extends kn{constructor(t){super(`ImplementationError - ${t}`)}}class z extends Te{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class St extends Te{constructor(t){super(`Parsing Error: ${t}`)}}class ht extends Te{constructor(t){super(`Client Error: ${t}`)}}class Ne extends Te{constructor(t){super(`Resource Generation Failed: ${t}`)}}class mi{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 Xa{constructor(){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 pi=()=>{try{return localStorage?new mi:new Xa}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new Xa}},T=pi();class fi{constructor(){this.defaultServerUrl="https://api.au.spiffcommerce.com",this.defaultServicesApiUrl="https://services.au.spiffcommerce.com",this.defaultHubUrl="https://hub.au.spiffcommerce.com",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(e=>e())}setServicesApiUrl(t){this.servicesApiUrl=t}setHubUrl(t){this.hubUrl=t}addServerUrlCallback(t){this.serverUrlCallbacks.push(t)}}const At=new fi;let sa,oa;function Ci(r){sa=r}function wi(r){oa=r}function se(){return sa?new sa().window:(console.log("DOM constructor is not registered. Assuming browser environment. If not, please register DOM constructor before calling this function."),window)}function st(r,t){if(!oa){if(typeof window<"u"&&window.fetch)return window.fetch(r,t);if(typeof global<"u"&&global.fetch)return global.fetch(r,t);throw new Error("Fetch implementation is not registered. Please register it before calling this function.")}return oa(r,t)}const Mn=new Map,Za=new Map,tn=new Map,Tn=async r=>{const t=Za.get(r);if(t)return t;const a=(async()=>{var i;const n=await st(r);return Mn.set(r,((i=n.headers)==null?void 0:i.get("content-type"))||""),await n.arrayBuffer()})();return Za.set(r,a),a},yi=async r=>{const t=tn.get(r);if(t)return t;const a=(async()=>await(await st(r)).text())();return tn.set(r,a),a},$t=r=>r.every(t=>t!=="undefined"),fe=r=>$t([typeof document])?document.createElement(r):se().document.createElement(r),Si=(r,t)=>{if($t([typeof document]))return document.createElementNS(r,t);const a=se().document.createElement(t);return a.setAttribute("xmlns",r),a},ct=()=>{if($t([typeof DOMParser]))return new DOMParser;const r=se();return new r.DOMParser},vi=()=>$t([typeof DOMParser])?DOMParser:se().DOMParser,Qe=(r,t)=>new Promise((e,a)=>{t?Tn(r).then(e).catch(a):st(r).then(n=>{n.arrayBuffer().then(e).catch(a)}).catch(n=>{a(n)})}),tt=(r,t)=>new Promise((e,a)=>{t?yi(r).then(e).catch(a):st(r).then(n=>{n.text().then(e).catch(a)}).catch(a)}),Nn=r=>ii.renderToStaticMarkup(r),Ge=new Map,Ei=async(r,t)=>{if($t([typeof FontFace])){if(Ge.has(t))return Ge.get(t);const e=r.names.fullName.en,a=new FontFace(e,`url(${t})`);document.fonts.add(a);const n=a.load();return Ge.set(t,n),n}},wt=()=>{if($t([typeof XMLSerializer]))return new XMLSerializer;const r=se();return new r.XMLSerializer},en=r=>btoa(r),Re=r=>{function t(){const a=new Uint8Array(r),n=4;if(a.length>=n){const i=new Array(n);for(let l=0;l<n;l++)i[l]=new Uint8Array(r)[l].toString(16);const s=i.join("").toUpperCase();switch(s){case"89504E47":return"image/png";case"47494638":return"image/gif";case"25504446":return"application/pdf";case"504B0304":return"application/zip"}switch(s.slice(0,4)){case"FFD8":return"image/jpeg"}}return null}const e=t();return e||"image/svg+xml"},bi=async r=>{const t=await Tn(r),e=Mn.get(r)||Re(t);return await Pi(new Blob([t],{type:e}))},Bi=r=>{let t="";const e=r.byteLength;for(let a=0;a<e;a++)t+=String.fromCharCode(r[a]);return t},Ii=async r=>{const t=Re(r),e=new Uint8Array(r),a=Bi(e),n=btoa(a);return`data:${t};base64,${n}`},Oe=r=>`data:image/svg+xml;base64,${btoa(r)}`,Qn=r=>{const t=r.replace(/\r?\n/g,""),e=t.indexOf(",");if(e===-1||e<=4)throw new TypeError("malformed data: URI");const a=t.substring(5,e).split(";");let n=!1;for(let s=1;s<a.length;s++)a[s]==="base64"&&(n=!0);const i=decodeURI(t.substring(e+1));return n?new Uint8Array(atob(i).split("").map(o=>o.charCodeAt(0))).buffer:new Uint8Array(i.split("").map(o=>o.charCodeAt(0))).buffer},Pi=r=>new Promise((t,e)=>{const a=new FileReader;a.onload=function(n){const i=n.target;!i||!i.result?e():t(i.result.toString())},a.readAsDataURL(r)});let Fi,va;const Di=r=>{va=r},xi=()=>va;let Rn;const On=r=>{Rn=r},ki=()=>new Promise(r=>{const t=At.getHubUrl(),e=a=>{a.origin===t&&(window.removeEventListener("message",e),r(a.data))};window.parent!==window&&(window.addEventListener("message",e,!1),window.parent.postMessage("ready",t))}),Mi=async()=>{const r={applicationKey:va,customerToken:Fi,bearer:Rn};return typeof window<"u"&&(window.location.href.includes("/workflows/product/")||window.location.href.includes("hub=true"))?{...await ki(),...r}:r};async function Ti(r,t){const e=At.getServerUrl(),a=e.includes(".aumelbdev.spiffcommerce.com")?"https://moonlight.aumelbdev.spiffcommerce.com":e.includes(".us.spiffcommerce.com")?"https://moonlight.us.spiffcommerce.com":"https://moonlight.au.spiffcommerce.com";let n=await st(r,{...t,redirect:"manual"});return n.type==="opaqueredirect"&&(typeof r!="string"&&"url"in r?n=await st({...r,url:`${a}/graphql`},t):n=await st(`${a}/graphql`,t)),n}class Ni{constructor(){this.shadowGraphqlClient=this.constructShadowGraphqlClient(),At.addServerUrlCallback(()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()})}setSpiffCommerceClient(t){this.spiffClient=t,this.shadowGraphqlClient=this.constructShadowGraphqlClient()}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const t=v.createHttpLink({uri:`${At.getServerUrl()}/graphql`,fetch:Ti}),e=ni.setContext(async(i,s)=>{const{headers:o}=s,l=o||{},c=await Mi();let d=s.bearer??c.bearer;if(this.spiffClient)try{d=await this.spiffClient.loggedInBearerToken()}catch{}const A=s.partnerId??c.partnerId,u=s.activeIntegration??c.activeIntegration,h=s.transactionOwnerId,g=s.customerToken??c.customerToken,m=s.applicationKey??c.applicationKey,p=s.bundleOwnerId;try{if(window&&window.__SENTRY__){const f=window.__SENTRY__.hub;if(f){const C=f.traceHeaders();Object.entries(C).forEach(([w,S])=>{l[w]=S})}}}catch{}return d&&(l.Authorization=`Bearer ${d}`),A&&(l.partnerId=A),u&&(l.activeIntegration=u),h&&(l.transactionOwnerId=h),g&&(l.customerToken=g),m&&(l["X-Application-Key"]=m),p&&(l.bundleOwnerId=p),l["Allow-Moonlight-Redirect"]="true",{headers:l}}),a=ri.onError(({operation:i,graphQLErrors:s,networkError:o})=>{var d,A;const l=s||[],c=i.getContext();o&&!((A=(d=c==null?void 0:c.fetchOptions)==null?void 0:d.signal)!=null&&A.aborted)&&console.log("GraphQL Network error"),l.forEach(()=>console.log("GraphQL Error: "+i.operationName))}),n=si.removeTypenameFromVariables();return new v.ApolloClient({link:v.from([n,a,e,t]),cache:new v.InMemoryCache,name:"Core"})}}const B=new Ni;let la,ca;const pt=(r,t,e)=>{if(la!==void 0)return la(r,t,e);try{const a=$n(!0);return Ea(a),a.createCanvas(r,t,e)}catch{throw new Error("Canvas module not set")}},oe=(r,t)=>{if(ca!==void 0)return ca(r,t);try{const e=$n(!0);return Ea(e),e.loadImage(r,t)}catch{throw new Error("Canvas module not set")}};function Ea(r){la=r==null?void 0:r.createCanvas,ca=r==null?void 0:r.loadImage}function $n(r){try{if(document.createElement("canvas").getContext("2d"))return{createCanvas:(e,a,n)=>{const i=document.createElement("canvas");return e!=null&&(i.width=e),a!=null&&(i.height=a),i},loadImage:(e,a)=>new Promise((n,i)=>{const s=document.createElement("img");a!==!1&&(s.crossOrigin="Anonymous"),s.onload=()=>{n(s)},s.onerror=i,s.src=e})}}catch(t){if(r)throw t}}let We;function ba(){return We===void 0&&(We=vi()),We}let Ce=null;const Qi=r=>new Promise(t=>{if(Re(r)!=="image/jpeg")return t(1);oi.orientation(r).then(a=>t(a||1)).catch(()=>t(1))}),Ri=async()=>{if(Ce!==null)return!Ce;const t=await oe("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return Ce=t.width===2&&t.height===3,!Ce},Oi=r=>{const e=r.naturalWidth/r.naturalHeight;return r.naturalHeight<=8192&&r.naturalWidth<=8192?[r.naturalWidth,r.naturalHeight]:r.naturalHeight>r.naturalWidth?[e*8192,8192]:[8192,8192/e]},$i=async r=>{var A;const t=await Ii(r),e=await oe(t),[a,n]=Oi(e);if(!await Ri()){const u=pt(a,n);return(A=u.getContext("2d"))==null||A.drawImage(e,0,0,a,n),u}const s=await Qi(r),[o,l]=s>4?[n,a]:[a,n],c=pt(o,l),d=c.getContext("2d");switch(s){case 2:d.translate(o,0),d.scale(-1,1);break;case 3:d.translate(o,l),d.rotate(Math.PI);break;case 4:d.translate(0,l),d.scale(1,-1);break;case 5:d.rotate(-.5*Math.PI),d.scale(-1,1);break;case 6:d.rotate(-.5*Math.PI),d.translate(-o,0);break;case 7:d.rotate(-.5*Math.PI),d.translate(-o,l),d.scale(1,-1);break;case 8:d.rotate(.5*Math.PI),d.translate(0,-l);break}return d.drawImage(e,0,0,o,l),c},le=async r=>{const t=await $i(r);return Re(r)==="image/jpeg"?{dataUrl:t.toDataURL("image/jpeg",1),height:t.height,width:t.width}:{dataUrl:t.toDataURL(),height:t.height,width:t.width}},ae=["Yellow C","Yellow 012 C","Orange 021 C","Warm Red C","Red 032 C","Rubine Red C","Rhodamine Red C","Purple C","Violet C","Blue 072 C","Reflex Blue C","Process Blue C","Green C","Black C","Yellow 0131 C","Red 0331 C","Magenta 0521 C","Violet 0631 C","Blue 0821 C","Green 0921 C","Black 0961 C","801 C","802 C","803 C","804 C","805 C","806 C","807 C","871 C","872 C","873 C","874 C","875 C","876 C","877 C","Medium Yellow C","Bright Orange C","Bright Red C","Strong Red C","Pink C","Medium Purple C","Dark Blue C","Medium Blue C","Bright Green C","Neutral Black C","100 C","101 C","102 C","103 C","104 C","105 C","7401 C","7402 C","7403 C","7404 C","7405 C","7406 C","7407 C","106 C","107 C","108 C","109 C","110 C","111 C","112 C","113 C","114 C","115 C","116 C","117 C","118 C","119 C","127 C","128 C","129 C","130 C","131 C","132 C","133 C","1205 C","1215 C","1225 C","1235 C","1245 C","1255 C","1265 C","120 C","121 C","122 C","123 C","124 C","125 C","126 C","7548 C","7549 C","7550 C","7551 C","7552 C","7553 C","7554 C","7555 C","7556 C","7557 C","7558 C","7559 C","7560 C","7561 C","134 C","135 C","136 C","137 C","138 C","139 C","140 C","1345 C","1355 C","1365 C","1375 C","1385 C","1395 C","1405 C","141 C","142 C","143 C","144 C","145 C","146 C","147 C","7408 C","7409 C","7410 C","7411 C","7412 C","7413 C","7414 C","7562 C","7563 C","7564 C","7565 C","7566 C","7567 C","7568 C","7569 C","7570 C","7571 C","7572 C","7573 C","7574 C","7575 C","712 C","713 C","714 C","715 C","716 C","717 C","718 C","148 C","149 C","150 C","151 C","152 C","153 C","154 C","155 C","156 C","157 C","158 C","159 C","160 C","161 C","1485 C","1495 C","1505 C","1525 C","1535 C","1545 C","1555 C","1565 C","1575 C","1585 C","1595 C","1605 C","1615 C","162 C","163 C","164 C","165 C","166 C","167 C","168 C","7576 C","7577 C","7578 C","7579 C","7580 C","7581 C","7582 C","1625 C","1635 C","1645 C","1655 C","1665 C","1675 C","1685 C","169 C","170 C","171 C","172 C","173 C","174 C","175 C","7583 C","7584 C","7585 C","7586 C","7587 C","7588 C","7589 C","7590 C","7591 C","7592 C","7593 C","7594 C","7595 C","7596 C","7597 C","7598 C","7599 C","7600 C","7601 C","7602 C","7603 C","7604 C","7605 C","7606 C","7607 C","7608 C","7609 C","7610 C","7611 C","7612 C","7613 C","7614 C","7615 C","7616 C","7617 C","7520 C","7521 C","7522 C","7523 C","7524 C","7525 C","7526 C","489 C","488 C","487 C","486 C","485 C","484 C","483 C","176 C","177 C","178 C","179 C","180 C","181 C","1765 C","1775 C","1785 C","1788 C","1795 C","1805 C","1815 C","1767 C","1777 C","1787 C","1797 C","1807 C","1817 C","7618 C","7619 C","7620 C","7621 C","7622 C","7623 C","7624 C","7625 C","7626 C","7627 C","7628 C","7629 C","7630 C","7631 C","7415 C","7416 C","7417 C","7418 C","7419 C","7420 C","7421 C","182 C","183 C","184 C","185 C","186 C","187 C","188 C","196 C","197 C","198 C","199 C","200 C","201 C","202 C","189 C","190 C","191 C","192 C","193 C","194 C","195 C","1895 C","1905 C","1915 C","1925 C","1935 C","1945 C","1955 C","705 C","706 C","707 C","708 C","709 C","710 C","711 C","698 C","699 C","700 C","701 C","702 C","703 C","704 C","203 C","204 C","205 C","206 C","207 C","208 C","209 C","210 C","211 C","212 C","213 C","214 C","215 C","216 C","7422 C","7423 C","7424 C","7425 C","7426 C","7427 C","7428 C","7632 C","7633 C","7634 C","7635 C","7636 C","7637 C","7638 C","217 C","218 C","219 C","220 C","221 C","222 C","7639 C","7640 C","7641 C","7642 C","7643 C","7644 C","7645 C","223 C","224 C","225 C","226 C","227 C","228 C","229 C","230 C","231 C","232 C","233 C","234 C","235 C","670 C","671 C","672 C","673 C","674 C","675 C","676 C","677 C","678 C","679 C","680 C","681 C","682 C","683 C","684 C","685 C","686 C","687 C","688 C","689 C","690 C","510 C","509 C","508 C","507 C","506 C","505 C","504 C","7429 C","7430 C","7431 C","7432 C","7433 C","7434 C","7435 C","691 C","692 C","693 C","694 C","695 C","696 C","697 C","496 C","495 C","494 C","493 C","492 C","491 C","490 C","503 C","502 C","501 C","500 C","499 C","498 C","497 C","5035 C","5025 C","5015 C","5005 C","4995 C","4985 C","4975 C","236 C","237 C","238 C","239 C","240 C","241 C","242 C","2365 C","2375 C","2385 C","2395 C","2405 C","2415 C","2425 C","243 C","244 C","245 C","246 C","247 C","248 C","249 C","7646 C","7647 C","7648 C","7649 C","7650 C","7651 C","7652 C","250 C","251 C","252 C","253 C","254 C","255 C","517 C","516 C","515 C","514 C","513 C","512 C","511 C","7436 C","7437 C","7438 C","7439 C","7440 C","7441 C","7442 C","2562 C","2572 C","2582 C","2592 C","2602 C","2612 C","2622 C","7653 C","7654 C","7655 C","7656 C","7657 C","7658 C","7659 C","524 C","523 C","522 C","521 C","520 C","519 C","518 C","5245 C","5235 C","5225 C","5215 C","5205 C","5195 C","5185 C","5175 C","5165 C","5155 C","5145 C","5135 C","5125 C","5115 C","531 C","530 C","529 C","528 C","527 C","526 C","525 C","256 C","257 C","258 C","259 C","260 C","261 C","262 C","2563 C","2573 C","2583 C","2593 C","2603 C","2613 C","2623 C","7660 C","7661 C","7662 C","7663 C","7664 C","7665 C","7666 C","2567 C","2577 C","2587 C","2597 C","2607 C","2617 C","2627 C","263 C","264 C","265 C","266 C","267 C","268 C","269 C","2635 C","2645 C","2655 C","2665 C","2685 C","2695 C","270 C","271 C","272 C","273 C","274 C","275 C","276 C","2705 C","2715 C","2725 C","2735 C","2745 C","2755 C","2765 C","7667 C","7668 C","7669 C","7670 C","7671 C","7672 C","7673 C","7443 C","7444 C","7445 C","7446 C","7447 C","7448 C","7449 C","7674 C","7675 C","7676 C","7677 C","7678 C","7679 C","7680 C","663 C","664 C","665 C","666 C","667 C","668 C","669 C","5315 C","5305 C","5295 C","5285 C","5275 C","5265 C","5255 C","538 C","537 C","536 C","535 C","534 C","533 C","532 C","7541 C","7542 C","7543 C","7544 C","7545 C","7546 C","7547 C","552 C","551 C","550 C","549 C","548 C","547 C","546 C","5455 C","5445 C","5435 C","5425 C","5415 C","5405 C","5395 C","642 C","643 C","644 C","645 C","646 C","647 C","648 C","649 C","650 C","651 C","652 C","653 C","654 C","655 C","656 C","657 C","658 C","659 C","660 C","661 C","662 C","7450 C","7451 C","7452 C","7453 C","7454 C","7455 C","7456 C","2706 C","2716 C","2726 C","2736 C","2746 C","2756 C","2766 C","2708 C","2718 C","2728 C","2738 C","2748 C","2758 C","2768 C","2707 C","2717 C","2727 C","2747 C","2757 C","2767 C","277 C","278 C","279 C","280 C","281 C","282 C","283 C","284 C","285 C","286 C","287 C","288 C","289 C","7681 C","7682 C","7683 C","7684 C","7685 C","7686 C","7687 C","545 C","544 C","543 C","542 C","541 C","540 C","539 C","290 C","291 C","292 C","293 C","294 C","295 C","296 C","2905 C","2915 C","2925 C","2935 C","2945 C","2955 C","2965 C","297 C","298 C","299 C","300 C","301 C","302 C","303 C","7688 C","7689 C","7690 C","7691 C","7692 C","7693 C","7694 C","2975 C","2985 C","2995 C","3005 C","3015 C","3025 C","3035 C","7695 C","7696 C","7697 C","7698 C","7699 C","7700 C","7701 C","7457 C","7458 C","7459 C","7460 C","7461 C","7462 C","7463 C","304 C","305 C","306 C","307 C","308 C","309 C","635 C","636 C","637 C","638 C","639 C","640 C","641 C","7702 C","7703 C","7704 C","7705 C","7706 C","7707 C","7708 C","628 C","629 C","630 C","631 C","632 C","633 C","634 C","310 C","311 C","312 C","313 C","314 C","315 C","316 C","3105 C","3115 C","3125 C","3135 C","3145 C","3155 C","3165 C","7709 C","7710 C","7711 C","7712 C","7713 C","7714 C","7715 C","317 C","318 C","319 C","320 C","321 C","322 C","323 C","7464 C","7465 C","7466 C","7467 C","7468 C","7469 C","7470 C","7471 C","7472 C","7473 C","7474 C","7475 C","7476 C","7477 C","5523 C","5513 C","5503 C","5493 C","5483 C","5473 C","5463 C","7716 C","7717 C","7718 C","7719 C","7720 C","7721 C","7722 C","324 C","325 C","326 C","327 C","328 C","329 C","330 C","3242 C","3252 C","3262 C","3272 C","3282 C","3292 C","3302 C","3245 C","3255 C","3265 C","3275 C","3285 C","3295 C","3305 C","3248 C","3258 C","3268 C","3278 C","3288 C","3298 C","3308 C","566 C","565 C","564 C","563 C","562 C","561 C","560 C","573 C","572 C","571 C","570 C","569 C","568 C","567 C","559 C","558 C","557 C","556 C","555 C","554 C","553 C","5595 C","5585 C","5575 C","5565 C","5555 C","5545 C","5535 C","5665 C","5655 C","5645 C","5635 C","5625 C","5615 C","5605 C","5527 C","5517 C","5507 C","5497 C","5487 C","5477 C","5467 C","621 C","622 C","623 C","624 C","625 C","626 C","627 C","331 C","332 C","333 C","334 C","335 C","336 C","337 C","338 C","339 C","340 C","341 C","342 C","343 C","7723 C","7724 C","7725 C","7726 C","7727 C","7728 C","7729 C","3375 C","3385 C","3395 C","3405 C","3415 C","3425 C","3435 C","344 C","345 C","346 C","347 C","348 C","349 C","350 C","351 C","352 C","353 C","354 C","355 C","356 C","357 C","7478 C","7479 C","7480 C","7481 C","7482 C","7483 C","7484 C","7730 C","7731 C","7732 C","7733 C","7734 C","7735 C","7736 C","7737 C","7738 C","7739 C","7740 C","7741 C","7742 C","7743 C","358 C","359 C","360 C","361 C","362 C","363 C","364 C","7485 C","7486 C","7487 C","7488 C","7489 C","7490 C","7491 C","365 C","366 C","367 C","368 C","369 C","370 C","371 C","372 C","373 C","374 C","375 C","376 C","377 C","378 C","580 C","579 C","578 C","577 C","576 C","575 C","574 C","5807 C","5797 C","5787 C","5777 C","5767 C","5757 C","5747 C","5875 C","5865 C","5855 C","5845 C","5835 C","5825 C","5815 C","5803 C","5793 C","5783 C","5773 C","5763 C","5753 C","5743 C","7492 C","7493 C","7494 C","7495 C","7496 C","7497 C","7498 C","7744 C","7745 C","7746 C","7747 C","7748 C","7749 C","7750 C","379 C","380 C","381 C","382 C","383 C","384 C","385 C","386 C","387 C","388 C","389 C","390 C","391 C","392 C","587 C","586 C","585 C","584 C","583 C","582 C","581 C","393 C","394 C","395 C","396 C","397 C","398 C","399 C","3935 C","3945 C","3955 C","3965 C","3975 C","3985 C","3995 C","600 C","601 C","602 C","603 C","604 C","605 C","606 C","607 C","608 C","609 C","610 C","611 C","612 C","613 C","461 C","460 C","459 C","458 C","457 C","456 C","455 C","614 C","615 C","616 C","617 C","618 C","619 C","620 C","7751 C","7752 C","7753 C","7754 C","7755 C","7756 C","7757 C","7758 C","7759 C","7760 C","7761 C","7762 C","7763 C","7764 C","7765 C","7766 C","7767 C","7768 C","7769 C","7770 C","7771 C","4545 C","4535 C","4525 C","4515 C","4505 C","4495 C","4485 C","454 C","453 C","452 C","451 C","450 C","449 C","448 C","7499 C","7500 C","7501 C","7502 C","7503 C","7504 C","7505 C","468 C","467 C","466 C","465 C","464 C","463 C","462 C","7506 C","7507 C","7508 C","7509 C","7510 C","7511 C","7512 C","719 C","720 C","721 C","722 C","723 C","724 C","725 C","475 C","474 C","473 C","472 C","471 C","470 C","469 C","726 C","727 C","728 C","729 C","730 C","731 C","732 C","4685 C","4675 C","4665 C","4655 C","4645 C","4635 C","4625 C","7513 C","7514 C","7515 C","7516 C","7517 C","7518 C","7519 C","4755 C","4745 C","4735 C","4725 C","4715 C","4705 C","4695 C","482 C","481 C","480 C","479 C","478 C","477 C","476 C","7527 C","7528 C","7529 C","7530 C","7531 C","7532 C","7533 C","7534 C","7535 C","7536 C","7537 C","7538 C","7539 C","7540 C","427 C","428 C","429 C","430 C","431 C","432 C","433 C","420 C","421 C","422 C","423 C","424 C","425 C","426 C","441 C","442 C","443 C","444 C","445 C","446 C","447 C","413 C","414 C","415 C","416 C","417 C","418 C","419 C","400 C","401 C","402 C","403 C","404 C","405 C","406 C","407 C","408 C","409 C","410 C","411 C","412 C","434 C","435 C","436 C","437 C","438 C","439 C","440 C","Warm Gray 1 C","Warm Gray 2 C","Warm Gray 3 C","Warm Gray 4 C","Warm Gray 5 C","Warm Gray 6 C","Warm Gray 7 C","Warm Gray 8 C","Warm Gray 9 C","Warm Gray 10 C","Warm Gray 11 C","Cool Gray 1 C","Cool Gray 2 C","Cool Gray 3 C","Cool Gray 4 C","Cool Gray 5 C","Cool Gray 6 C","Cool Gray 7 C","Cool Gray 8 C","Cool Gray 9 C","Cool Gray 10 C","Cool Gray 11 C","Black 2 C","Black 3 C","Black 4 C","Black 5 C","Black 6 C","Black 7 C"],Qt=["FEDD00","FFD700","FE5000","F9423A","EF3340","CE0058","E10098","BB29BB","440099","10069F","001489","0085CA","00AB84","2D2926","F2F0A1","FCAEBB","F1B2DC","BF9BDE","74D1EA","9DE7D7","9E978E","009ACE","44D62C","FFE900","FFAA4D","FF7276","FF3EB5","EA27C2","84754E","85714D","866D4B","8B6F4E","87674F","8B634B","8A8D8F","FFD900","FF5E00","F93822","CE0056","D62598","4E008E","00239C","0084CA","00B08B","222223","F6EB61","F7EA48","FCE300","C5A900","AF9800","897A27","F5E1A4","ECD898","EED484","F4DA40","F2CD00","F1C400","CBA052","F9E547","FBE122","FEDB00","FFD100","DAAA00","AA8A00","9C8412","FAE053","FBDD40","FDDA24","FFCD00","C99700","AC8400","897322","F3DD6D","F3D54E","F3D03E","F2A900","CC8A00","A07400","6C571B","F8E08E","FBD872","FFC845","FFB81C","C69214","AD841F","886B25","FBDB65","FDD757","FED141","FFC72C","EAAA00","B58500","9A7611","FFC600","FFB500","D19000","B47E00","73531D","5A4522","4B3D2A","D29F13","B78B20","9F7D23","967126","8F6A2A","7D622E","6C5D34","FDD26E","FFC658","FFBF3F","FFA300","DE7C00","AF6D04","74531C","FDD086","FFC56E","FFB549","FF9E1B","D57800","996017","6E4C1E","F2C75C","F1BE48","F1B434","ED8B00","CF7F00","A76D11","715C2A","F6BE00","F0B323","FEAD77","E6A65D","D38235","DC8633","C16C18","BD9B60","D69A2D","DB8A06","CD7925","AD6433","89532F","775135","D78825","D3832B","C67D30","B67233","A7662B","9E6A38","835D32","FCC89B","FDBE87","FDAA63","F68D2E","EA7600","D45D00","BE4D00","FECB8B","FFC27B","FFB25B","FF8200","E57200","BE6A14","9B5A1A","EFD19F","EFBE7D","ECA154","E87722","CB6015","A1561C","603D20","FFAE62","FF8F1C","FF6900","B94700","94450B","653819","FFB990","FFA06A","FF7F32","FF6A13","D86018","A65523","8B4720","FFBE9F","FF9D6E","FF7F41","FF671F","E35205","BE531C","73381D","DB864E","E07E3C","DC6B2F","DC582A","C05131","864A33","674736","FFA38B","FF8D6D","FF6A39","FC4C02","DC4405","A9431E","833921","FFB3AB","FF8674","FF5C39","FA4616","CF4520","963821","6B3529","C4622D","BA5826","AF5C37","9E5330","924C2E","7B4D35","5C4738","D4B59E","C07D59","B15533","9D432C","7C3A2D","6B3D2E","5C3D31","D14124","BD472A","B33D26","8D3F2B","83412C","7B4931","674230","E4D5D3","E1BBB4","D6938A","C26E60","A4493D","823B34","683431","DDBCB0","CA9A8E","BC8A7E","A37F74","866761","6B4C4C","583D3E","EABEB0","C09C83","B46A55","AB5C57","A45248","9A6A4F","8A391B","ECC3B2","ECBAA8","EAA794","E8927C","DA291C","9A3324","653024","FFB1BB","FF808B","FF585D","E03C31","BE3A34","81312F","FFA3B5","FF8DA1","F8485E","EE2737","D22630","AF272F","7C2529","FCAFC0","FB637E","F4364C","CB333B","A4343A","643335","C66E4E","C04C36","B7312C","AB2328","93272C","8A2A2B","802F2D","E1523D","C63527","A72B2A","9E2A2B","6D3332","633231","572D2D","E6BAA8","E56A54","E04E39","CD545B","B04A5A","9B2242","651D32","FABBCB","FC9BB3","F65275","E4002B","C8102E","A6192E","76232F","ECC7CD","E89CAE","DF4661","D50032","BA0C2F","9D2235","862633","F8A3BC","F67599","EF426F","E40046","BF0D3E","9B2743","782F40","F5B6CD","F59BBB","EF4A81","E0004D","C5003E","A6093D","8A1538","F5DADF","F7CED7","F9B5C4","F890A5","EF6079","E03E52","CB2C30","F2D4D7","F4C3CC","F2ACB9","E68699","D25B73","B83A4B","9E2A2F","ECB3CB","E782A9","E0457B","CE0037","A50034","861F41","6F263D","F99FC9","F57EB6","F04E98","E31C79","CE0F69","AC145A","7D2248","F4CDD4","E06287","E24585","B52555","A4123F","971B2F","6A2C3E","D6C9CA","C4A4A7","C16784","C63663","BC204B","912F46","7E2D40","EABEDB","E56DB1","DA1884","A50050","910048","6C1D45","936D73","934054","8E2C48","732E4A","672E45","582D40","502B3A","EF95CF","EB6FBD","DF1995","D0006F","AA0061","890C58","672146","F4A6D7","F277C6","E93CAC","C6007E","A20067","840B55","EAD3E2","E6BCD8","DFA0C9","D986BA","C6579A","AE2573","960051","E5CEDB","E3C8D8","DEBED2","C996B6","B06C96","994878","7C2855","E4C6D4","DCB6C9","D0A1BA","BE84A3","A76389","893B67","612141","EBBECB","E8B3C3","E4A9BB","D592AA","84344E","6F2C3F","572932","E2BCCB","DCA9BF","C9809E","B55C80","A73A64","9B3259","872651","E9CDD0","E4BEC3","D7A3AB","C48490","B46B7A","984856","893C47","F2C6CF","F1BDC8","E9A2B2","DC8699","8F3237","7F3035","5D2A2C","E9C4C7","E5BAC1","DAA5AD","C6858F","7A3E3A","6A3735","512F2E","DFC2C3","DBB7BB","CCA1A6","B07C83","9C6169","874B52","3F2021","F1A7DC","EC86D0","E45DBF","DB3EB1","C5299B","AF1685","80225F","EFBAE1","E277CD","D539B5","C800A1","B0008E","9E007E","830065","EAB8E4","E59BDC","DD7FD3","C724B1","BB16A3","A51890","80276C","A56E87","A83D72","991E66","8A1B61","722257","6A2A5B","5E2751","E7BAE4","DD9CDF","C964CF","AD1AAC","981D97","72246C","EBC6DF","E6BEDD","E2ACD7","D48BC8","93328E","833177","612C51","EEDAEA","CCAED0","D59ED7","B288B9","A277A6","9F5CC0","963CBD","D7A9E3","C98BDB","AC4FC6","9B26B6","87189D","772583","653165","948794","A2789C","A15A95","8E3A80","6E2B62","6A3460","5D3754","D5C2D8","C9B1D0","BA9CC5","A57FB2","642F6C","59315F","4B3048","DBCDD3","D0BEC7","C6B0BC","AF95A6","86647A","66435A","4A3041","D8C8D1","D3C0CD","BFA5B8","9B7793","7E5475","693C5E","512A44","DFC8E7","D7B9E4","CAA2DD","B580D1","8031A7","702F8A","572C5F","D6BFDD","C6A1CF","8C4799","6D2077","642667","5D285F","51284F","CBA3D8","B884CB","A05EB5","84329B","702082","671E75","5F2167","9991A4","8D6E97","7A4183","6B3077","653279","5E366E","5C4E63","C1A0DA","A77BCA","8246AF","5C068C","500778","470A68","3C1053","D7C6E6","C1A7E2","9063CD","753BBD","5F259F","582C83","512D6D","C5B4E3","AD96DC","9678D3","7D55C7","330072","2E1A47","B4B5DF","9595D2","7474C1","24135F","211551","201747","221C35","A7A4E0","8B84D7","685BC7","2E008B","280071","250E62","201547","6E7CA0","686E9F","615E9B","565294","514689","4C4184","535486","DDDAE8","B6B8DC","A7A2C3","8986CA","5D4777","4B384C","41273B","878CB4","7C7FAB","7566A0","6F5091","68478D","563D82","523178","E5E1E6","E0DBE3","C6BCD0","A192B2","7C6992","614B79","3F2A56","D8D7DF","C6C4D2","B3B0C4","8D89A5","595478","403A60","1E1A34","C5CFDA","BBC7D6","A2B2C8","8E9FBC","1B365D","1F2A44","1C1F2A","D9E1E2","A4BCC2","98A4AE","768692","425563","253746","131E29","B9D3DC","A3C7D2","8DB9CA","6BA4B8","003D4C","00313C","072B31","BFCED6","B7C9D3","A6BBC8","7A99AC","5B7F95","4F758B","081F2C","D1DDE6","C6D6E3","9BB8D3","7DA1C4","5E8AB4","236192","002E5D","DBE2E9","CED9E5","A7BCD6","7D9BC1","326295","003A70","002554","DDE5ED","C8D8EB","B1C9E8","7BA4DB","407EC9","003594","001A70","BDC5DB","89ABE3","8094DD","7BA6DE","5F8FB4","3A5DAE","606EB2","CBD3EB","9FAEE5","485CC7","1E22AA","171C8F","151F6D","141B4D","B8CCEA","5C88DA","0047BB","06038D","001871","001E62","071D49","C3D7EE","A7C6ED","307FE2","001A72","001E60","13294B","ABCAE9","8BB8E8","418FDE","012169","00205B","041E42","92C1E9","6CACE4","0072CE","0033A0","003087","002D72","0C2340","94A9CB","6787B7","426DA9","385E9D","2C5697","1D4F91","1D428A","C6DAE7","BDD6E6","A4C8E1","7BAFD4","003C71","003057","00263A","B9D9EB","9BCBEB","69B3E7","003DA5","002F6C","002855","041C2C","8DC8E8","62B5E5","009CDE","0057B8","004C97","003865","00263E","71C5E8","41B6E6","00A3E0","005EB8","004B87","003B5C","002A3A","4698CB","298FC2","0076A8","006298","005587","004976","01426A","99D6EA","5BC2E7","00A9E0","0077C8","00629B","004F71","003E51","7BA7BC","6399AE","4E87A0","41748D","34657F","165C7D","005776","BBDDE6","71B2C9","4298B5","0086BF","007DBA","00558C","002B49","9ADBE8","59CBE8","00B5E2","006BA6","00587C","003B49","A4DBE8","8BD3E6","4EC3E0","00AFD7","0095C8","0082BA","0067A0","48A9C5","009CBD","0085AD","007096","006A8E","00617F","005670","B8DDE1","9BD3DD","77C5D5","3EB1C8","0093B2","007396","005F83","6AD1E3","05C3DE","00A9CE","0092BC","007FA3","00677F","004851","68D2DF","00C1D5","00AEC7","008EAA","00778B","006272","004F59","63B1BC","00A7B5","0097A9","00859B","007D8A","007680","006269","B1E4E3","88DBDF","2DCCD3","009CA6","008C95","007377","005F61","A0D1CA","40C1AC","00B0B9","00A3AD","007398","005F86","005A70","7EDDD3","5CB8B2","279989","007681","487A7B","0D5257","244C5A","B6CFD0","ABC7CA","94B7BB","7FA9AE","4F868E","115E67","07272D","00968F","00857D","007672","006D68","00635B","005E5D","005151","9CDBD9","64CCC9","00B2A9","008675","007367","00685E","00534C","71DBD4","2AD2C9","00BFB3","00A499","008578","00594F","004C45","7CE0D3","2CD5C4","00C7B1","00B398","009681","007864","004E42","6DCDB8","49C5B1","00AB8E","009B77","008264","006A52","034638","B9DCD2","A1D6CA","86C8BC","6BBBAE","006F62","00594C","1D3C34","B5E3D8","A5DFD3","98DBCE","6BCABA","00816D","006C5B","173F35","ADCAB8","9ABEAA","85B09A","6FA287","28724F","205C40","284734","BFCEC2","A7BDB1","92ACA0","7F9C90","5C7F71","43695B","183028","BAC5B9","B0BDB0","A3B2A4","94A596","708573","5E7461","22372B","BCC9C5","B1C0BC","9DB0AC","829995","5D7975","3E5D58","18332F","D1E0D7","B7CDC2","9AB9AD","789F90","507F70","285C4D","13322B","A7E6D7","8CE2D0","3CDBC0","009775","007B5F","00664F","8FD6BD","6ECEB2","00B388","00965E","007A53","006747","115740","50A684","00966C","008755","007B4B","006F44","006845","005844","7AE1BF","47D7AC","00C389","00AF66","007749","006341","154734","A0DAB3","91D6AC","71CC98","009A44","00843D","046A38","2C5234","A2E4B8","8FE2B0","80E0A7","00B140","009639","007A33","215732","9BE3BF","26D07C","00BF6F","00B74F","009F4D","275D38","00573F","4B9560","228848","007A3E","007041","286140","36573B","395542","6BA539","48A23F","319B42","3A913F","44883E","4A773C","44693D","ADDC91","A1D884","6CC24A","43B02A","509E2F","4C8C2B","4A7729","D0DEBB","BCE194","8EDD65","78D64B","74AA50","719949","79863C","C2E189","B7DD79","A4D65E","78BE20","64A70B","658D1B","546223","D4EB8E","CDEA80","C5E86C","97D700","84BD00","7A9A01","59621D","C4D6A4","BCD19B","B7CE95","A9C47F","789D4A","67823A","4E5B31","D0D1AB","C6C89B","BABD8B","A2A569","8A8D4A","6D712E","3D441E","D2CE9E","CBC793","C0BB87","AFA96E","A09958","89813D","555025","C3C6A8","B3B995","A3AA83","899064","737B4C","5E6738","3E4827","BFCC80","BBC592","9CAF88","8F993E","76881D","7A7256","5B6236","BABC16","ABAD23","999B30","888D30","7C8034","727337","656635","E2E868","DBE442","CEDC00","C4D600","A8AD00","949300","787121","E9EC6B","E3E935","E0E721","D0DF00","B5BD00","9A9500","827A04","E3E48D","E0E27C","DBDE70","D2D755","B7BF10","8E8C13","625D20","F0EC74","EDE939","ECE81A","E1E000","BFB800","ADA400","A09200","F3EA5D","F3E500","EFDF00","EEDC00","BBA600","9A8700","685C20","F1EB9C","F0E991","F0E87B","EDE04B","EADA24","E1CD00","CFB500","EBE49A","E9E186","E6DE77","E1D555","D7C826","C4B000","B39B00","E9DF97","E4D77E","DECD63","D9C756","B89D18","A28E2A","695B24","DCD59A","D6CF8D","D0C883","C0B561","AC9F3C","9F912A","8A7B19","CAB64B","CFB023","C1A01E","A08629","897630","736635","675E33","D4C304","C4B200","91852C","747136","5D6439","585C3B","535435","BBB323","B4A91F","AA9D2E","8F7E35","716135","635939","4E4934","D5CB9F","CFC493","C5B783","B3A369","998542","8C7732","614F25","CAC7A7","BFBB98","B0AA7E","9B945F","594A25","524727","4A412A","F1E6B2","DFD1A7","D9C89E","CEB888","A89968","94795D","816040","DDCBA4","D3BC8D","C6AA76","B9975B","8B5B29","744F28","5C462B","EFDBB2","FCD299","E1B87F","D6A461","C6893F","B77729","A6631B","EDC8A3","E7B78A","DDA46F","C88242","B36924","934D11","7D3F16","F3CFB3","F1C6A7","F0BF9B","E59E6D","B86125","A45A2A","693F23","E0C09F","D9B48F","CDA077","B58150","9E652E","774212","623412","E0C6AD","DCBFA6","CDA788","BF9474","AD7C59","946037","4F2C1D","E1B7A7","D5A286","C58B68","99552B","85431E","6D4F47","5E4B3C","D7C4B7","CDB5A7","C0A392","AE8A79","956C58","7C4D3A","5B3427","DBC8B6","D3BBA8","C6A992","AA8066","703F2A","623B2A","4E3629","D6D2C4","C5B9AC","B7A99A","A39382","7A6855","63513D","473729","D1CCBD","B7B09C","A69F88","A7ACA2","949A90","8E9089","4B4F54","D0D3D4","C1C6C8","A2AAAD","7C878E","5B6770","333F48","1D252D","C7C9C7","B2B4B2","9EA2A2","898D8D","707372","54585A","25282A","BEC6C4","A2ACAB","919D9D","717C7D","505759","3F4444","373A36","BABBB1","A8A99E","919388","7E7F74","65665C","51534A","212322","C4BFB6","AFA9A0","9D968D","8C857B","776E64","696158","C4BCB7","B2A8A2","978C87","857874","746661","5E514D","382F2D","D0C4C5","C1B2B6","AB989D","7B6469","584446","453536","382E2C","D7D2CB","CBC4BC","BFB8AF","B6ADA5","ACA39A","A59C94","968C83","8C8279","83786F","796E65","6E6259","D9D9D6","D0D0CE","C8C9C7","BBBCBC","B1B3B3","A7A8AA","97999B","888B8D","75787B","63666A","53565A","332F21","212721","31261D","3E2B2E","101820","3D3935"],je=Qt.map(r=>[parseInt(r.substring(0,2),16),parseInt(r.substring(2,4),16),parseInt(r.substring(4,6),16)]);function Ui(r){const t=ae.indexOf(r);return t>=0?Qt[t]:""}function Un(r){const t=Qt.indexOf(r);return t>=0?ae[t]:""}function Li(r,t=64){const e=[],a=[],n=Un(r);n&&e.push({pms:n,hex:r,distance:0});const i=parseInt(r.substring(0,2),16),s=parseInt(r.substring(2,4),16),o=parseInt(r.substring(4,6),16);let l,c,d;for(let A=0;A<Qt.length;A++){l=je[A][0],c=je[A][1],d=je[A][2];const u=Math.sqrt(Math.pow(i-l,2)+Math.pow(s-c,2)+Math.pow(o-d,2));a.push(u)}for(let A=0;A<a.length;A++)a[A]<=t&&!e.some(u=>u.pms===ae[A])&&e.push({pms:ae[A],hex:Qt[A],distance:a[A]});return e.sort((A,u)=>A.distance-u.distance)}const Vi=ae.map((r,t)=>({pms:r,hex:Qt[t]})),zi=new li(Vi,{keys:["pms"]});function qi(r,t){return zi.search(r,t?{limit:t}:void 0)}let Lt=null;function Ln(r){if(r.startsWith("#"))return an(r);if(!document)throw new Error("browserColorToHex is only supported on browsers");if(Lt||(Lt=document.createElement("canvas").getContext("2d")),!Lt)throw new Error("Failed to create canvas context required to convert colors");Lt.fillStyle=r;const t=an(Lt.fillStyle);return t||console.error(`Unknown browser color ${r}`),t}function an(r){const t=r.substring(1).toUpperCase();return t.length===6?t:t.length===3?`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`:""}const we=r=>{const t=Vn(r.spotColor);return t?`${r.browserValue} ${t}`:r.browserValue},Vn=r=>{if(!r)return"";if(r.profileName.includes("/")&&r.profileName.includes(".icc")){const t=r.profileName.replace(/\s/g,"-"),e=t.lastIndexOf("/");return`icc-named-color(${t.slice(e+1).slice(0,-4)}, ${r.namedColor})`}return`icc-named-color(${r.profileName}, ${r.namedColor})`},da=r=>{const t=r.split(/[ ](?=[^)]*?(?:\(|$))/);if(t.length===0)return{browserValue:"#000000"};if(t.length===1)return{browserValue:t[0]};const e=t[1].match(/\(([^)]+)\)/gm);if(!e)throw new Error("Unhandled state of color value in SVG");const a=e[0].replace(/[() ]/g,"").split(",");return{browserValue:t[0],spotColor:{profileName:a[0],namedColor:a[1]}}},Gi=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],Wi=["fill","stroke"],Rt=(r,t)=>{t(r),r.children.length>0&&Array.from(r.children).forEach(e=>Rt(e,t))},ji=(r,t)=>{try{return r.matches(t)}catch{return r.classList.contains(t.substring(1))}},$e=(r,t=!1)=>{!t&&r.setAttribute("preserveAspectRatio","none");const e=[];Rt(r,a=>{var i,s,o;if(a.tagName==="script"){a.remove();return}if(a.tagName==="style"){try{(i=Sn.parse(a.innerHTML).stylesheet)==null||i.rules.forEach(c=>{e.push(c)}),a.remove()}catch(l){console.error(l)}return}const n=(o=(s=a.attributes.getNamedItem("style"))==null?void 0:s.value)==null?void 0:o.trim();if(n){const l=[];n.split(";").forEach(d=>{const A=d.trim();if(A){const[u,h]=A.split(":"),g=u.toLowerCase();Wi.indexOf(g)>-1?a.setAttribute(g,h.trim()):l.push(A)}}),l.length>0?a.setAttribute("style",l.join(";")):a.removeAttribute("style")}}),Rt(r,a=>{e.forEach(n=>{var i;(i=n.selectors)==null||i.forEach(s=>{var o;ji(a,s)&&((o=n.declarations)==null||o.forEach(l=>{l.property&&l.value&&a.setAttribute(l.property,l.value)}))})})})},Hi=r=>{const t=/pt|pc|mm|cm|in/gm,e=r.getAttribute("viewBox"),a=r.getAttribute("width"),n=r.getAttribute("height");if(!e)throw new Error("viewBox not specified on SVG!");a&&r.setAttribute("width",a.replace(t,"")),n&&r.setAttribute("height",n.replace(t,""))},zn=r=>ct().parseFromString(r,"image/svg+xml").firstElementChild,Yi=(r,t,e)=>{r.setAttribute("height",`${e}px`),r.setAttribute("width",`${t}px`)},qn=(r,t,e)=>{Rt(r,a=>{const n=a.attributes.getNamedItem("fill");n&&n.value!=="none"&&a.classList.forEach(s=>{if(s.startsWith("spiff-fill")){const o=t[s.replace("spiff-fill-","")];if(o)a.setAttribute("fill",e?we(o):o.browserValue);else{const l=t[s];l&&a.setAttribute("fill",e?we(l):l.browserValue)}}});const i=a.attributes.getNamedItem("stroke");i&&i.value!=="none"&&a.classList.forEach(s=>{if(s.startsWith("spiff-stroke")){const o=t[s.replace("spiff-stroke-","")];if(o)a.setAttribute("stroke",e?we(o):o.browserValue);else{const l=t[s];l&&a.setAttribute("fill",e?we(l):l.browserValue)}}})})},Gn=r=>wt().serializeToString(r),Ba=(r,t,e,a,n)=>{const i=zn(r);if(!i)throw new Error("Failed to read SVG.");return Yi(i,t,e),qn(i,a,n),Gn(i)},Ue=(r,t,e)=>{const a=zn(r);if(!a)throw new Error("Failed to read SVG.");return qn(a,t,e),Gn(a)},Ji=r=>{const t=/<svg.*<\/svg>/s,e=r.match(t)||[],a=(e==null?void 0:e.length)>0?e[0]:"";return ct().parseFromString(a,"image/svg+xml")},ot=async r=>{const e=Ji(r).firstElementChild;if(!e)throw new Error("Failed to read SVG.");$e(e);const a={};Rt(e,s=>{Gi.includes(s.tagName)&&!s.attributes.getNamedItem("fill")&&s.setAttribute("fill","black");const o=s.attributes.getNamedItem("fill");if(o&&o.value!=="none"&&!o.value.startsWith("url(")){const c=da(o.value),d=c.browserValue.replace(/\W/g,""),A=`spiff-fill-${d}`;s.setAttribute("fill",c.browserValue),s.classList.add(A),a[d]=c}const l=s.attributes.getNamedItem("stroke");if(l&&l.value!=="none"&&!l.value.startsWith("url(")){const c=da(l.value),d=c.browserValue.replace(/\W/g,""),A=`spiff-stroke-${d}`;s.classList.add(A),s.setAttribute("stroke",c.browserValue),a[d]=c}});const i=wt().serializeToString(e);return{colors:a,svg:i}},Ki=v.gql`
2
2
  fragment AssetMetadataFields on Asset {
3
3
  metadata {
4
4
  key
@@ -130,7 +130,7 @@
130
130
  ...AssetFields
131
131
  }
132
132
  }
133
- `,Ie=async r=>(await B.getShadowGraphqlClient().query({query:_i,errorPolicy:"all",fetchPolicy:"no-cache",variables:{keys:r}})).data.assets,es=async r=>(await B.getShadowGraphqlClient().query({query:Xi,errorPolicy:"all",variables:{ids:r}})).data.materials,as=async(r,t,e,a,n)=>{var s;return(s=(await B.getShadowGraphqlClient().mutate({mutation:Zi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:r,type:t,mimeType:e,anonymous:a,temporary:n}})).data)==null?void 0:s.assetCreate};class ns{constructor(){this.cache=new Map,this.bgrmProcessCache=new Map,this.materialCache=new Map,this.loadImageAsFileInfo=async t=>{const e=await t.arrayBuffer(),a=await le(e),n=(i,s)=>{const o=atob(i.split(",")[1]),l=[];for(let c=0;c<o.length;c++)l.push(o.charCodeAt(c));return new Blob([new Uint8Array(l)],{type:s})};return{name:t.name.substring(t.name.lastIndexOf("/")+1),blob:n(a.dataUrl,t.type)}}}async getLocalOrFromServer(t){if(this.cache.has(t)){const n=this.cache.get(t);if(!n)throw new z("Failed to get asset from cache!");return n}const a=(async()=>(await Ie([t]))[0])();return this.cache.set(t,a),a}async getFromServer(t){const a=(async()=>(await Ie([t]))[0])();return this.cache.set(t,a),a}keyFromURL(t){let e;try{e=new URL(t).pathname}catch{e=void 0}return e!==void 0&&e.startsWith("/")&&(e=e.replace("/","")),e==null?void 0:e.split("?")[0]}cacheAsset(t){if(!t.key)throw new z("Asset has no key!");this.cache.has(t.key)||this.cache.set(t.key,Promise.resolve(t))}cacheMaterial(t){if(!t.id)throw new z("Material has no id!");this.materialCache.has(t.id)||this.materialCache.set(t.id,Promise.resolve(t))}async getMaterialLocalOrFromServer(t){if(this.materialCache.has(t))return this.materialCache.get(t);const a=(async()=>(await es([t]))[0])();return this.materialCache.set(t,a),a}async uploadAssetWithProgress(t,e,a,n,i){const s=await this.dispatchCreateAssetRequest(t,e,n,i);if(!s)throw new Error("Failed to create asset.");return await new Promise((o,l)=>{const c=new XMLHttpRequest;c.open("PUT",s.assetResponse.uploadUrl,!0),c.setRequestHeader("Content-Type",s.mimeType),c.setRequestHeader("Cache-Control","public,max-age=31536000,immutable"),c.upload.onprogress=d=>{d.lengthComputable&&a(d.loaded*100/d.total)},c.onload=()=>{const d=s.assetResponse.asset;Pt.add(s.assetResponse.asset),o(d)},c.onerror=l,this.postProcessFileUpload(t,s.mimeType).then(d=>c.send(d.blob)).catch(l)}),this.cacheAsset(s.assetResponse.asset),s.assetResponse.asset}async uploadAsset(t,e,a,n){return this.uploadAssetWithProgress(t,e,()=>{},a,n)}async uploadFile(t,e){const n=this.isRaster(t)?Xt.Image:Xt.Illustration,i=await this.loadImageAsFileInfo(t);return await this.uploadAssetWithProgress(i,n,e,!0)}async removeBackgroundFromAsset(t){const e=t.key;if(this.bgrmProcessCache.has(e))return this.bgrmProcessCache.get(e);if(J.has(e)){const i=this.getLocalOrFromServer(J.get(e));return this.bgrmProcessCache.set(e,i),i}const n=(async()=>{var s,o;const i=await B.getShadowGraphqlClient().mutate({mutation:ts,fetchPolicy:"no-cache",errorPolicy:"all",variables:{key:e}});if(this.bgrmProcessCache.delete(e),!((o=(s=i.data)==null?void 0:s.assetRemoveBackground)!=null&&o.key))throw new Error("Failed to remove background from image");return Pt.add(i.data.assetRemoveBackground),J.add(e,i.data.assetRemoveBackground.key),this.cache.set(i.data.assetRemoveBackground.key,Promise.resolve(i.data.assetRemoveBackground)),i.data.assetRemoveBackground})();return this.bgrmProcessCache.set(e,n),n}removePersistedAsset(t){Pt.remove(t),J.delete(t),J.deleteForBgRemovedKey(t)}getPersistedAssets(){return Pt.list()}registerPersistedAssetListener(t){Pt.addCallback(t)}unRegisterPersistedAssetListener(t){Pt.removeCallback(t)}isRaster(t){return!(t.type==="image/svg+xml"||t.type==="application/pdf"||t.type==="application/postscript")}async postProcessFileUpload(t,e){if(e==="image/svg+xml"){const a=await t.blob.text(),s=new window.DOMParser().parseFromString(a,"image/svg+xml").documentElement;if(!s)throw new St("Failed to read SVG.");Hi(s);const l=wt().serializeToString(s);return{name:t.name,blob:new Blob([l],{type:"image/svg+xml"})}}return t}async dispatchCreateAssetRequest(t,e,a,n){const i=t.blob.type?t.blob.type:this.guessMIME(t.name),s=await as(t.name,e,i,a,n);if(s)return{assetResponse:s,mimeType:i}}guessMIME(t){const e=t.split(".").pop();switch(e){case"glb":return"model/gltf-binary";case"ttf":return"font/ttf";case"mkv":return"video/x-matroska";default:throw new z("Unexpected mimetype: "+e)}}}const Vt="persistentAssets",qn=class yt{static add(t){if(!t.fileLink){console.error("Failed to find cdn link on asset, cannot persist!");return}const e=new Map;e.set(t.key||"",t.fileLink);const a=N.getMap(Vt);a&&a.forEach((n,i)=>{e.set(i,n)}),N.setMap(Vt,e),yt.executeCallbacks()}static remove(t){const e=N.getMap(Vt);if(!e)return;const a=Array.from(e.entries()).find(n=>n[0]===t);a&&(e.delete(a[0]),N.setMap(Vt,e),yt.executeCallbacks())}static list(){const t=N.getMap(Vt);return t?Array.from(t.entries()).map(e=>({assetKey:e[0],src:e[1]})):[]}static addCallback(t){yt.callbacks.push(t)}static removeCallback(t){yt.callbacks=yt.callbacks.filter(e=>e!==t)}static executeCallbacks(){yt.callbacks.forEach(t=>t())}};qn.callbacks=[];let Pt=qn;const an="bgrmPersistentAssets";class J{static has(t){return J.getMap().has(t)}static get(t){return J.getMap().get(t)}static keys(){return J.getMap().keys()}static values(){return J.getMap().values()}static add(t,e){const a=J.getMap();a.set(t,e),J.setMap(a)}static delete(t){const e=J.getMap();e.delete(t),J.setMap(e)}static deleteForBgRemovedKey(t){const e=J.getMap(),a=Array.from(e.keys()).find(n=>e.get(n)===t);a&&(e.delete(a),J.setMap(e))}static getMap(){return N.getMap(an)||new Map}static setMap(t){N.setMap(an,t)}}const U=new ns;class rs{constructor(){this.cache={},this.disabled=!1}get(t){if(this.disabled)return;const e=JSON.stringify(t);return this.cache[e]}set(t,e){if(this.disabled)return e;const a=JSON.stringify(t);return this.cache[a]=e,e}disable(t){this.disabled=t}}const Ot=new rs,Wn=v.gql`
133
+ `,Ie=async r=>(await B.getShadowGraphqlClient().query({query:_i,errorPolicy:"all",fetchPolicy:"no-cache",variables:{keys:r}})).data.assets,es=async r=>(await B.getShadowGraphqlClient().query({query:Xi,errorPolicy:"all",variables:{ids:r}})).data.materials,as=async(r,t,e,a,n)=>{var s;return(s=(await B.getShadowGraphqlClient().mutate({mutation:Zi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:r,type:t,mimeType:e,anonymous:a,temporary:n}})).data)==null?void 0:s.assetCreate};class ns{constructor(){this.cache=new Map,this.bgrmProcessCache=new Map,this.materialCache=new Map,this.loadImageAsFileInfo=async t=>{const e=await t.arrayBuffer(),a=await le(e),n=(i,s)=>{const o=atob(i.split(",")[1]),l=[];for(let c=0;c<o.length;c++)l.push(o.charCodeAt(c));return new Blob([new Uint8Array(l)],{type:s})};return{name:t.name.substring(t.name.lastIndexOf("/")+1),blob:n(a.dataUrl,t.type)}}}async getLocalOrFromServer(t){if(this.cache.has(t)){const n=this.cache.get(t);if(!n)throw new z("Failed to get asset from cache!");return n}const a=(async()=>(await Ie([t]))[0])();return this.cache.set(t,a),a}async getFromServer(t){const a=(async()=>(await Ie([t]))[0])();return this.cache.set(t,a),a}keyFromURL(t){let e;try{e=new URL(t).pathname}catch{e=void 0}return e!==void 0&&e.startsWith("/")&&(e=e.replace("/","")),e==null?void 0:e.split("?")[0]}cacheAsset(t){if(!t.key)throw new z("Asset has no key!");this.cache.has(t.key)||this.cache.set(t.key,Promise.resolve(t))}cacheMaterial(t){if(!t.id)throw new z("Material has no id!");this.materialCache.has(t.id)||this.materialCache.set(t.id,Promise.resolve(t))}async getMaterialLocalOrFromServer(t){if(this.materialCache.has(t))return this.materialCache.get(t);const a=(async()=>(await es([t]))[0])();return this.materialCache.set(t,a),a}async uploadAssetWithProgress(t,e,a,n,i){const s=await this.dispatchCreateAssetRequest(t,e,n,i);if(!s)throw new Error("Failed to create asset.");return await new Promise((o,l)=>{const c=new XMLHttpRequest;c.open("PUT",s.assetResponse.uploadUrl,!0),c.setRequestHeader("Content-Type",s.mimeType),c.setRequestHeader("Cache-Control","public,max-age=31536000,immutable"),c.upload.onprogress=d=>{d.lengthComputable&&a(d.loaded*100/d.total)},c.onload=()=>{const d=s.assetResponse.asset;Pt.add(s.assetResponse.asset),o(d)},c.onerror=l,this.postProcessFileUpload(t,s.mimeType).then(d=>c.send(d.blob)).catch(l)}),this.cacheAsset(s.assetResponse.asset),s.assetResponse.asset}async uploadAsset(t,e,a,n){return this.uploadAssetWithProgress(t,e,()=>{},a,n)}async uploadFile(t,e){const n=this.isRaster(t)?Xt.Image:Xt.Illustration,i=await this.loadImageAsFileInfo(t);return await this.uploadAssetWithProgress(i,n,e,!0)}async removeBackgroundFromAsset(t){const e=t.key;if(this.bgrmProcessCache.has(e))return this.bgrmProcessCache.get(e);if(J.has(e)){const i=this.getLocalOrFromServer(J.get(e));return this.bgrmProcessCache.set(e,i),i}const n=(async()=>{var s,o;const i=await B.getShadowGraphqlClient().mutate({mutation:ts,fetchPolicy:"no-cache",errorPolicy:"all",variables:{key:e}});if(this.bgrmProcessCache.delete(e),!((o=(s=i.data)==null?void 0:s.assetRemoveBackground)!=null&&o.key))throw new Error("Failed to remove background from image");return Pt.add(i.data.assetRemoveBackground),J.add(e,i.data.assetRemoveBackground.key),this.cache.set(i.data.assetRemoveBackground.key,Promise.resolve(i.data.assetRemoveBackground)),i.data.assetRemoveBackground})();return this.bgrmProcessCache.set(e,n),n}removePersistedAsset(t){Pt.remove(t),J.delete(t),J.deleteForBgRemovedKey(t)}getPersistedAssets(){return Pt.list()}registerPersistedAssetListener(t){Pt.addCallback(t)}unRegisterPersistedAssetListener(t){Pt.removeCallback(t)}isRaster(t){return!(t.type==="image/svg+xml"||t.type==="application/pdf"||t.type==="application/postscript")}async postProcessFileUpload(t,e){if(e==="image/svg+xml"){const a=await t.blob.text(),s=new window.DOMParser().parseFromString(a,"image/svg+xml").documentElement;if(!s)throw new St("Failed to read SVG.");Hi(s);const l=wt().serializeToString(s);return{name:t.name,blob:new Blob([l],{type:"image/svg+xml"})}}return t}async dispatchCreateAssetRequest(t,e,a,n){const i=t.blob.type?t.blob.type:this.guessMIME(t.name),s=await as(t.name,e,i,a,n);if(s)return{assetResponse:s,mimeType:i}}guessMIME(t){const e=t.split(".").pop();switch(e){case"glb":return"model/gltf-binary";case"ttf":return"font/ttf";case"mkv":return"video/x-matroska";default:throw new z("Unexpected mimetype: "+e)}}}const Vt="persistentAssets",Wn=class yt{static add(t){if(!t.fileLink){console.error("Failed to find cdn link on asset, cannot persist!");return}const e=new Map;e.set(t.key||"",t.fileLink);const a=T.getMap(Vt);a&&a.forEach((n,i)=>{e.set(i,n)}),T.setMap(Vt,e),yt.executeCallbacks()}static remove(t){const e=T.getMap(Vt);if(!e)return;const a=Array.from(e.entries()).find(n=>n[0]===t);a&&(e.delete(a[0]),T.setMap(Vt,e),yt.executeCallbacks())}static list(){const t=T.getMap(Vt);return t?Array.from(t.entries()).map(e=>({assetKey:e[0],src:e[1]})):[]}static addCallback(t){yt.callbacks.push(t)}static removeCallback(t){yt.callbacks=yt.callbacks.filter(e=>e!==t)}static executeCallbacks(){yt.callbacks.forEach(t=>t())}};Wn.callbacks=[];let Pt=Wn;const nn="bgrmPersistentAssets";class J{static has(t){return J.getMap().has(t)}static get(t){return J.getMap().get(t)}static keys(){return J.getMap().keys()}static values(){return J.getMap().values()}static add(t,e){const a=J.getMap();a.set(t,e),J.setMap(a)}static delete(t){const e=J.getMap();e.delete(t),J.setMap(e)}static deleteForBgRemovedKey(t){const e=J.getMap(),a=Array.from(e.keys()).find(n=>e.get(n)===t);a&&(e.delete(a),J.setMap(e))}static getMap(){return T.getMap(nn)||new Map}static setMap(t){T.setMap(nn,t)}}const U=new ns;class rs{constructor(){this.cache={},this.disabled=!1}get(t){if(this.disabled)return;const e=JSON.stringify(t);return this.cache[e]}set(t,e){if(this.disabled)return e;const a=JSON.stringify(t);return this.cache[a]=e,e}disable(t){this.disabled=t}}const Ot=new rs,jn=v.gql`
134
134
  fragment OptionFields on Option {
135
135
  id
136
136
  name
@@ -170,13 +170,13 @@
170
170
  `,is=v.gql`
171
171
  ${ce(!1)}
172
172
  ${Ia}
173
- ${Wn}
173
+ ${jn}
174
174
  query GetOptions($ids: [String]!) {
175
175
  options(ids: $ids) {
176
176
  ...OptionFields
177
177
  }
178
178
  }
179
- `,ss=async r=>{const t=await B.getShadowGraphqlClient().query({query:is,errorPolicy:"all",variables:{ids:r}});return t.data.options.forEach(e=>{var a,n;(a=e.defaultVariant)!=null&&a.asset&&U.cacheAsset(e.defaultVariant.asset),e.colorProfile&&U.cacheAsset(e.colorProfile),(n=e.variants)==null||n.forEach(i=>{i.asset&&U.cacheAsset(i.asset),i.thumbnail&&U.cacheAsset(i.thumbnail),i.material&&U.cacheMaterial(i.material)})}),t.data.options},os=async(r,t)=>(await t).find(a=>a.id===r),ls=async r=>{const t=r.map(s=>Ot.get({id:s})),e=r.filter((s,o)=>t[o]===void 0);if(e.length===0)return Promise.all(t);const a=ss(e),n=e.map(s=>Ot.set({id:s},os(s,a))),i=t.filter(s=>s!==void 0);return await Promise.all(i.concat(n))};class cs{constructor(){this.getSelectedVariant=(t,e)=>{var a;if(!(!t||e.length===0))return(a=t.variants)==null?void 0:a.find(n=>n.id===e[0])}}async getOption(t){return(async()=>{const n=(await ls([t]))[0];if(n)return n})()}async getAssetTileImageForVariant(t){var n,i;const e=t.thumbnail;if(e){const s=(n=e.versions)==null?void 0:n.find(l=>l.name==="thumbnail"),o=e.fileLink;return(s==null?void 0:s.link)||o}const a=t.asset;if(a){const s=(i=a.versions)==null?void 0:i.find(l=>l.name==="thumbnail"),o=a.fileLink;return(s==null?void 0:s.link)||o}return t.material?t.material.id:""}getDefaultVariant(t){const e=t.variants;if(e){if(e.length===1)return e[0];if(t.defaultVariant!==void 0)return e.find(a=>{var n;return a.id===((n=t.defaultVariant)==null?void 0:n.id)})}}}const H=new cs,jn=v.gql`
179
+ `,ss=async r=>{const t=await B.getShadowGraphqlClient().query({query:is,errorPolicy:"all",variables:{ids:r}});return t.data.options.forEach(e=>{var a,n;(a=e.defaultVariant)!=null&&a.asset&&U.cacheAsset(e.defaultVariant.asset),e.colorProfile&&U.cacheAsset(e.colorProfile),(n=e.variants)==null||n.forEach(i=>{i.asset&&U.cacheAsset(i.asset),i.thumbnail&&U.cacheAsset(i.thumbnail),i.material&&U.cacheMaterial(i.material)})}),t.data.options},os=async(r,t)=>(await t).find(a=>a.id===r),ls=async r=>{const t=r.map(s=>Ot.get({id:s})),e=r.filter((s,o)=>t[o]===void 0);if(e.length===0)return Promise.all(t);const a=ss(e),n=e.map(s=>Ot.set({id:s},os(s,a))),i=t.filter(s=>s!==void 0);return await Promise.all(i.concat(n))};class cs{constructor(){this.getSelectedVariant=(t,e)=>{var a;if(!(!t||e.length===0))return(a=t.variants)==null?void 0:a.find(n=>n.id===e[0])}}async getOption(t){return(async()=>{const n=(await ls([t]))[0];if(n)return n})()}async getAssetTileImageForVariant(t){var n,i;const e=t.thumbnail;if(e){const s=(n=e.versions)==null?void 0:n.find(l=>l.name==="thumbnail"),o=e.fileLink;return(s==null?void 0:s.link)||o}const a=t.asset;if(a){const s=(i=a.versions)==null?void 0:i.find(l=>l.name==="thumbnail"),o=a.fileLink;return(s==null?void 0:s.link)||o}return t.material?t.material.id:""}getDefaultVariant(t){const e=t.variants;if(e){if(e.length===1)return e[0];if(t.defaultVariant!==void 0)return e.find(a=>{var n;return a.id===((n=t.defaultVariant)==null?void 0:n.id)})}}}const H=new cs,Hn=v.gql`
180
180
  fragment ActiveIntegrationFields on Integration {
181
181
  id
182
182
  logo
@@ -303,7 +303,7 @@
303
303
  }
304
304
  }
305
305
  }
306
- `,Hn=v.gql`
306
+ `,Yn=v.gql`
307
307
  fragment StakeholderFields on Stakeholder {
308
308
  id
309
309
  type
@@ -311,7 +311,7 @@
311
311
  authorizationNote
312
312
  authorizationStatus
313
313
  }
314
- `,Yn=v.gql`
314
+ `,Jn=v.gql`
315
315
  fragment TransactionShareActionFields on TransactionShareAction {
316
316
  id
317
317
  title
@@ -322,9 +322,9 @@
322
322
  }
323
323
  `,As=v.gql`
324
324
  ${Le}
325
- ${Hn}
326
325
  ${Yn}
327
- ${jn}
326
+ ${Jn}
327
+ ${Hn}
328
328
  query ReadTransactions($ids: [String]!) {
329
329
  transactions(ids: $ids) {
330
330
  customLogoLink
@@ -378,6 +378,13 @@
378
378
  country
379
379
  mobile
380
380
  company
381
+ apartment
382
+ customField1
383
+ customField2
384
+ customField3
385
+ customField4
386
+ customField5
387
+ conversionConfigurationId
381
388
  }
382
389
  product {
383
390
  id
@@ -491,6 +498,23 @@
491
498
  }
492
499
  }
493
500
  `,gs=v.gql`
501
+ query ReadConversionConfigurationQuery($id: String!) {
502
+ conversionConfiguration(id: $id) {
503
+ id
504
+ partnerId
505
+ name
506
+ locations
507
+ requestedData
508
+ requestedDataItems {
509
+ type
510
+ mandatory
511
+ title
512
+ uniqueIdentifier
513
+ }
514
+ mandatory
515
+ }
516
+ }
517
+ `,ms=v.gql`
494
518
  query ReadTransactionForDesignCreation($id: String!) {
495
519
  transactions(ids: [$id]) {
496
520
  id
@@ -559,8 +583,8 @@
559
583
  workflowViewerReadOnlyLink
560
584
  }
561
585
  }
562
- `,ms=v.gql`
563
- ${Yn}
586
+ `,ps=v.gql`
587
+ ${Jn}
564
588
  query ReadTransactionForShareActions($id: String!) {
565
589
  transactions(ids: [$id]) {
566
590
  id
@@ -570,14 +594,14 @@
570
594
  }
571
595
  }
572
596
  }
573
- `,Jn=v.gql`
597
+ `,Kn=v.gql`
574
598
  query ReadWorkflowStates($ids: [String]!) {
575
599
  transactions(ids: $ids) {
576
600
  id
577
601
  workflowState
578
602
  }
579
603
  }
580
- `,Kn=r=>v.gql`
604
+ `,_n=r=>v.gql`
581
605
  ${Le}
582
606
  fragment IntegrationProductFields on IntegrationProduct {
583
607
  id
@@ -660,15 +684,15 @@
660
684
  `:""}
661
685
  }
662
686
  }
663
- `,ps=r=>v.gql`
664
- ${Kn(r)}
687
+ `,fs=r=>v.gql`
688
+ ${_n(r)}
665
689
  query GetIntegrationProducts($ids: [String!]!) {
666
690
  integrationProducts(ids: $ids) {
667
691
  ...IntegrationProductFields
668
692
  }
669
693
  }
670
- `,fs=r=>v.gql`
671
- ${Kn(r)}
694
+ `,Cs=r=>v.gql`
695
+ ${_n(r)}
672
696
  query GetIntegrationProductFromExternalIds($externalIntegrationId: String!, $externalProductId: String!) {
673
697
  integrationProductFromExternalIds(
674
698
  externalIntegrationId: $externalIntegrationId
@@ -677,8 +701,8 @@
677
701
  ...IntegrationProductFields
678
702
  }
679
703
  }
680
- `,Cs=v.gql`
681
- ${Hn}
704
+ `,ws=v.gql`
705
+ ${Yn}
682
706
  query ReadTransactionForStakeholders($id: String!) {
683
707
  transactions(ids: [$id]) {
684
708
  stakeholders {
@@ -689,11 +713,11 @@
689
713
  }
690
714
  }
691
715
  }
692
- `,ws=v.gql`
716
+ `,ys=v.gql`
693
717
  mutation FinalizeUpdateTransaction($transactionId: String!) {
694
718
  transactionFinalizeUpdate(transactionId: $transactionId)
695
719
  }
696
- `,ys=v.gql`
720
+ `,Ss=v.gql`
697
721
  fragment RegionFields on Region {
698
722
  width
699
723
  top
@@ -711,7 +735,7 @@
711
735
  height
712
736
  }
713
737
  }
714
- `,Ss=v.gql`
738
+ `,vs=v.gql`
715
739
  fragment LookAtAnimationFields on LookAtAnimation {
716
740
  latDeg
717
741
  lonDeg
@@ -722,7 +746,7 @@
722
746
  z
723
747
  }
724
748
  }
725
- `,vs=v.gql`
749
+ `,Es=v.gql`
726
750
  fragment RenderingPipelineConfigurationFields on RenderingPipelineConfiguration {
727
751
  antiAliasing {
728
752
  samples
@@ -806,21 +830,21 @@
806
830
  weight
807
831
  }
808
832
  }
809
- `,Es=v.gql`
833
+ `,bs=v.gql`
810
834
  fragment ModelAnimationFields on ModelAnimation {
811
835
  from
812
836
  to
813
837
  loop
814
838
  name
815
839
  }
816
- `,bs=r=>v.gql`
840
+ `,Bs=r=>v.gql`
817
841
  ${ce(r)}
818
842
  ${Ia}
819
- ${Wn}
820
- ${ys}
843
+ ${jn}
821
844
  ${Ss}
822
845
  ${vs}
823
846
  ${Es}
847
+ ${bs}
824
848
  query GetWorkflows($ids: [String!]!) {
825
849
  workflows(ids: $ids) {
826
850
  partner {
@@ -1215,7 +1239,7 @@
1215
1239
  }
1216
1240
  }
1217
1241
  }
1218
- `,Bs=v.gql`
1242
+ `,Is=v.gql`
1219
1243
  query GetTransactionForPartner($id: String!) {
1220
1244
  transactions(ids: [$id]) {
1221
1245
  id
@@ -1233,7 +1257,7 @@
1233
1257
  }
1234
1258
  }
1235
1259
  }
1236
- `,Is=v.gql`
1260
+ `,Ps=v.gql`
1237
1261
  ${ce(!1)}
1238
1262
  query GetWorkflowForTheme($id: String!) {
1239
1263
  workflow(id: $id) {
@@ -1332,7 +1356,7 @@
1332
1356
  }
1333
1357
  }
1334
1358
  }
1335
- `,Ps=v.gql`
1359
+ `,Fs=v.gql`
1336
1360
  ${Ve}
1337
1361
  query GetMarketplaceThemeInstallConfiguration($themeConfigurationId: String!, $themeInstallId: String!) {
1338
1362
  marketplaceThemeInstallConfiguration(id: $themeConfigurationId, themeInstallId: $themeInstallId, raw: false) {
@@ -1340,7 +1364,7 @@
1340
1364
  }
1341
1365
  }
1342
1366
  `,Ds=v.gql`
1343
- ${jn}
1367
+ ${Hn}
1344
1368
  ${Ve}
1345
1369
  query GetCurrentIntegration($themeConfigurationId: String) {
1346
1370
  currentIntegration {
@@ -1361,7 +1385,7 @@
1361
1385
  }
1362
1386
  }
1363
1387
  }
1364
- `,Fs=v.gql`
1388
+ `,ks=v.gql`
1365
1389
  ${Ve}
1366
1390
  query ReadBundleForMarketplaceTheme($id: String!) {
1367
1391
  bundles(ids: [$id]) {
@@ -1370,14 +1394,14 @@
1370
1394
  }
1371
1395
  }
1372
1396
  }
1373
- `,ks=v.gql`
1397
+ `,Ms=v.gql`
1374
1398
  mutation CreateOrder($orderItems: [OrderItemInput]!) {
1375
1399
  orderCreate(orderItems: $orderItems, paid: false, generateInternalId: true) {
1376
1400
  id
1377
1401
  internalId
1378
1402
  }
1379
1403
  }
1380
- `,Ms=v.gql`
1404
+ `,Ts=v.gql`
1381
1405
  query CurrencyConversion($from: String!, $to: String!) {
1382
1406
  currencyConversion(from: $from, to: $to) {
1383
1407
  rateFrom
@@ -1385,48 +1409,48 @@
1385
1409
  timestamp
1386
1410
  }
1387
1411
  }
1388
- `,zt=[I.SilentIllustration,I.ProductOverlay],Ts=async r=>{const t=[];r.introduction&&t.push({name:"Introduction",title:r.name,renderableSteps:[{type:I.Introduction,stepName:"Introduction",stepTitle:r.name,helpText:r.introduction,data:{},conditions:[]}],silentSteps:[]});for(const a of r.steps){const n=Ns(a.stepName,r.stepGroups);if(!n)t.push({name:a.stepName,title:a.stepTitle,renderableSteps:zt.includes(a.type)?[]:[a],silentSteps:zt.includes(a.type)?[a]:[]});else{const i=t.find(s=>s.name===n.name);i?zt.includes(a.type)?i.silentSteps.push(a):i.renderableSteps.push(a):t.push({name:n.name,title:n.name,renderableSteps:zt.includes(a.type)?[]:[a],silentSteps:zt.includes(a.type)?[a]:[]})}}const e="workflow.steps.finish.confirmDesign";return t.push({name:"Finish",title:e,renderableSteps:[{type:I.Finish,stepName:"Finish",stepTitle:e,helpText:"",data:{modelAnimation:r.finalizeStepConfig?r.finalizeStepConfig.modelAnimation:void 0,lookAtAnimation:r.finalizeStepConfig?r.finalizeStepConfig.lookAtAnimation:void 0},conditions:[]}],silentSteps:[]}),t},Ns=(r,t)=>t.find(e=>e.stepNames.includes(r)),vt=(r,t)=>(r.conditions||[]).every(e=>{const a=t[e.targetStepName];if(a&&a.selectedVariants){const n=a.selectedVariants;return e.requiredVariantSelections.some(i=>n.find(s=>s.id===i)!==void 0)}return!1}),Qs=(r,t)=>{const e={name:r.name,title:r.title,renderableSteps:r.renderableSteps.filter(a=>vt(a,t)),silentSteps:r.silentSteps.filter(a=>vt(a,t))};return e.silentSteps.length===0&&e.renderableSteps.length===0?null:e},xt=(r,t)=>r.map(e=>Qs(e,t)).filter(e=>e!==null),Rs=async(r,t,e=!1)=>{var s;const a=xt(r,t),n=[];for(const o of a)for(const l of o.renderableSteps){const c=(((s=l.option)==null?void 0:s.variants)||[]).length;l.silent||(l.type===I.Model||l.type===I.Material||l.type===I.Picture||l.type===I.Shape?(c>1||e)&&n.push(l.stepName):n.push(l.stepName))}const i=a.filter(o=>o.renderableSteps.filter(c=>n.includes(c.stepName)).length>0);for(const o of i)o.renderableSteps=o.renderableSteps.filter(l=>n.includes(l.stepName));return i};class Pa{constructor(){this.timestamp=Date.now()}}class Da{constructor(t,e=!0){this.queue=[],this.activePromise=void 0,this.queueMaxSize=void 0,this.queueMaxSize=t,this.isEnabled=e}enqueue(t){if(this.queue.push(t),this.queueMaxSize!==void 0&&this.queue.length>this.queueMaxSize){const e=this.queue.length-1;for(let a=0;a<e;++a)this.queue.shift()}this.isEnabled&&(this.activePromise||(this.activePromise=this.dequeue()))}get enabled(){return this.isEnabled}set enabled(t){!this.isEnabled&&t&&!this.activePromise&&this.getRemainingQueueSize()>0&&(this.activePromise=this.dequeue()),this.isEnabled=t}hasActivePromise(){return!!this.activePromise}getRemainingQueueSize(){return this.queue.length}async finalize(){return this.activePromise?this.activePromise:Promise.resolve()}async dequeue(){const t=this.queue.shift();if(!t){this.activePromise=void 0;return}try{await t.execute()}catch(e){console.log(e)}finally{await this.dequeue()}}}const Q=()=>{const r=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()},Os=({backgroundColor:r,outlineColor:t,borderRadius:e,configuration:a,elements:n,height:i,maxHeight:s,maxWidth:o,outlineArea:l,position:c,preserveAspectRatio:d,viewBox:A,width:u})=>{var E;const h=e||0,g=2*((l==null?void 0:l.scale)||1),m=A||{x:0,y:0,width:u,height:i},p=`${m.x} ${m.y} ${m.width} ${m.height}`,f=Q(),C=a.purpose===Tt.FreeDesign&&D.jsx("defs",{children:D.jsx("clipPath",{id:"viewboxClip",children:D.jsx("rect",{width:m.width,height:m.height,rx:h})})}),w=(E=a.colorProfiles)==null?void 0:E.map((b,P)=>D.jsx("color-profile",{name:b.name,xlinkHref:b.key,children:" "},P)),S=n.map(b=>({...b,_renderingConfiguration:a,mask:l?`url(#viewmask-${f})`:void 0})),y=Fa(S);return D.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",preserveAspectRatio:d,width:u,height:i,style:{gridColumn:1,gridRow:1,maxWidth:o,maxHeight:s,position:c},viewBox:p,children:[w,C,!!r&&D.jsx("rect",{id:"layout-background",width:m.width,height:m.height,fill:r,rx:h}),D.jsx("g",{id:"element-group",clipPath:a.purpose===Tt.FreeDesign?"url(#viewboxClip)":void 0,children:y.map(b=>rr(b)).filter(b=>!!b)}),l&&D.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:l.hidden?"none":t||"#aaaaaa",strokeWidth:g/2,strokeDasharray:`${g*2} ${g}`}),l&&D.jsxs("mask",{id:`viewmask-${f}`,children:[D.jsx("rect",{x:m.x,y:m.y,width:m.width,height:m.height,fill:"black"}),D.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"white"})]})]})},$s=(r,t,e,a,n)=>{const i=ft(n),s=e/2,o=a/2,l=r+s,c=t+o,d=Math.sin(i),A=Math.cos(i),u=s,h=s,g=-o,m=o,p=u*A-g*d,f=h*A-m*d,C=u*d+g*A,w=h*d+m*A,S=Math.max(Math.abs(p),Math.abs(f)),y=Math.max(Math.abs(C),Math.abs(w));return{minX:l-S,maxX:l+S,minY:c-y,maxY:c+y}},Us=(r,t,e)=>{const a=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)),n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),i=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2));return Math.acos((n*n+a*a-i*i)/(2*n*a))*(180/Math.PI)},ft=r=>r*(Math.PI/180),Ls=(r,t,e)=>Math.abs(r-t)<e,Vs=(r,t,e)=>{const a=Math.sin(ft(e)),n=Math.cos(ft(e));return{x:(r.x-t.x)*n-(r.y-t.y)*a+t.x,y:(r.x-t.x)*a+(r.y-t.y)*n+t.y}},zs=(r,t)=>({x:(r.x+t.x)/2,y:(r.y+t.y)/2}),Gs=(r,t,e,a)=>({x:r.x+(t==null?void 0:t.x)*e,y:r.y+(t==null?void 0:t.y)*a}),qs=(r,t,e,a)=>({x:r.x+((t==null?void 0:t.x)+(t==null?void 0:t.width))*e,y:r.y+(t==null?void 0:t.y)*a}),Ws=(r,t,e,a)=>({x:r.x+((t==null?void 0:t.x)+(t==null?void 0:t.width))*e,y:r.y+((t==null?void 0:t.y)+(t==null?void 0:t.height))*a}),Dt=r=>{switch(r){case j.North:return j.East;case j.East:return j.South;case j.South:return j.West;case j.West:return j.North;case j.Northwest:return j.Northeast;case j.Northeast:return j.Southeast;case j.Southeast:return j.Southwest;case j.Southwest:return j.Northwest}},js=(r,t)=>t>45&&t<=135?Dt(r):t>135&&t<=225?Dt(Dt(r)):t>225&&t<=315?Dt(Dt(Dt(r))):r,Hs=(r,t={x:0,y:0},e={x:1,y:1})=>{const a=ft(r.rotation),n={x:t.x+r.x*e.x,y:t.x+r.y*e.y},i={x:r.x+r.width,y:r.y},s={x:t.x+(r.x+r.width)*e.x,y:t.y+(r.height+r.y)*e.y},o={x:t.x+r.x*e.x,y:t.y+(r.height+r.y)*e.y},l={x:(o.x+s.x)/2,y:o.y-r.height*e.y/2};return{a:jt(n,l,a),b:jt(i,l,a),c:jt(s,l,a),d:jt(o,l,a),center:l}},jt=(r,t,e)=>{const a=Math.sin(e),n=Math.cos(e);return{x:(r.x-t.x)*n-(r.y-t.y)*a+t.x,y:(r.x-t.x)*a+(r.y-t.y)*n+t.y}},Ys=.352778,Js=.035277,_n=r=>{const t=r.rotation||0,e=ft(t),a=Math.cos(e),n=-Math.sin(e);return D.jsx("g",{mask:r.stepName||r.productOverlay?void 0:r.mask,children:D.jsx("g",{transform:`
1412
+ `,zt=[I.SilentIllustration,I.ProductOverlay],Ns=async r=>{const t=[];r.introduction&&t.push({name:"Introduction",title:r.name,renderableSteps:[{type:I.Introduction,stepName:"Introduction",stepTitle:r.name,helpText:r.introduction,data:{},conditions:[]}],silentSteps:[]});for(const a of r.steps){const n=Qs(a.stepName,r.stepGroups);if(!n)t.push({name:a.stepName,title:a.stepTitle,renderableSteps:zt.includes(a.type)?[]:[a],silentSteps:zt.includes(a.type)?[a]:[]});else{const i=t.find(s=>s.name===n.name);i?zt.includes(a.type)?i.silentSteps.push(a):i.renderableSteps.push(a):t.push({name:n.name,title:n.name,renderableSteps:zt.includes(a.type)?[]:[a],silentSteps:zt.includes(a.type)?[a]:[]})}}const e="workflow.steps.finish.confirmDesign";return t.push({name:"Finish",title:e,renderableSteps:[{type:I.Finish,stepName:"Finish",stepTitle:e,helpText:"",data:{modelAnimation:r.finalizeStepConfig?r.finalizeStepConfig.modelAnimation:void 0,lookAtAnimation:r.finalizeStepConfig?r.finalizeStepConfig.lookAtAnimation:void 0},conditions:[]}],silentSteps:[]}),t},Qs=(r,t)=>t.find(e=>e.stepNames.includes(r)),vt=(r,t)=>(r.conditions||[]).every(e=>{const a=t[e.targetStepName];if(a&&a.selectedVariants){const n=a.selectedVariants;return e.requiredVariantSelections.some(i=>n.find(s=>s.id===i)!==void 0)}return!1}),Rs=(r,t)=>{const e={name:r.name,title:r.title,renderableSteps:r.renderableSteps.filter(a=>vt(a,t)),silentSteps:r.silentSteps.filter(a=>vt(a,t))};return e.silentSteps.length===0&&e.renderableSteps.length===0?null:e},Dt=(r,t)=>r.map(e=>Rs(e,t)).filter(e=>e!==null),Os=async(r,t,e=!1)=>{var s;const a=Dt(r,t),n=[];for(const o of a)for(const l of o.renderableSteps){const c=(((s=l.option)==null?void 0:s.variants)||[]).length;l.silent||(l.type===I.Model||l.type===I.Material||l.type===I.Picture||l.type===I.Shape?(c>1||e)&&n.push(l.stepName):n.push(l.stepName))}const i=a.filter(o=>o.renderableSteps.filter(c=>n.includes(c.stepName)).length>0);for(const o of i)o.renderableSteps=o.renderableSteps.filter(l=>n.includes(l.stepName));return i};class Pa{constructor(){this.timestamp=Date.now()}}class Fa{constructor(t,e=!0){this.queue=[],this.activePromise=void 0,this.queueMaxSize=void 0,this.queueMaxSize=t,this.isEnabled=e}enqueue(t){if(this.queue.push(t),this.queueMaxSize!==void 0&&this.queue.length>this.queueMaxSize){const e=this.queue.length-1;for(let a=0;a<e;++a)this.queue.shift()}this.isEnabled&&(this.activePromise||(this.activePromise=this.dequeue()))}get enabled(){return this.isEnabled}set enabled(t){!this.isEnabled&&t&&!this.activePromise&&this.getRemainingQueueSize()>0&&(this.activePromise=this.dequeue()),this.isEnabled=t}hasActivePromise(){return!!this.activePromise}getRemainingQueueSize(){return this.queue.length}async finalize(){return this.activePromise?this.activePromise:Promise.resolve()}async dequeue(){const t=this.queue.shift();if(!t){this.activePromise=void 0;return}try{await t.execute()}catch(e){console.log(e)}finally{await this.dequeue()}}}const Q=()=>{const r=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()},$s=({backgroundColor:r,outlineColor:t,borderRadius:e,configuration:a,elements:n,height:i,maxHeight:s,maxWidth:o,outlineArea:l,position:c,preserveAspectRatio:d,viewBox:A,width:u})=>{var E;const h=e||0,g=2*((l==null?void 0:l.scale)||1),m=A||{x:0,y:0,width:u,height:i},p=`${m.x} ${m.y} ${m.width} ${m.height}`,f=Q(),C=a.purpose===Tt.FreeDesign&&F.jsx("defs",{children:F.jsx("clipPath",{id:"viewboxClip",children:F.jsx("rect",{width:m.width,height:m.height,rx:h})})}),w=(E=a.colorProfiles)==null?void 0:E.map((b,P)=>F.jsx("color-profile",{name:b.name,xlinkHref:b.key,children:" "},P)),S=n.map(b=>({...b,_renderingConfiguration:a,mask:l?`url(#viewmask-${f})`:void 0})),y=xa(S);return F.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",preserveAspectRatio:d,width:u,height:i,style:{gridColumn:1,gridRow:1,maxWidth:o,maxHeight:s,position:c},viewBox:p,children:[w,C,!!r&&F.jsx("rect",{id:"layout-background",width:m.width,height:m.height,fill:r,rx:h}),F.jsx("g",{id:"element-group",clipPath:a.purpose===Tt.FreeDesign?"url(#viewboxClip)":void 0,children:y.map(b=>ir(b)).filter(b=>!!b)}),l&&F.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"none",stroke:l.hidden?"none":t||"#aaaaaa",strokeWidth:g/2,strokeDasharray:`${g*2} ${g}`}),l&&F.jsxs("mask",{id:`viewmask-${f}`,children:[F.jsx("rect",{x:m.x,y:m.y,width:m.width,height:m.height,fill:"black"}),F.jsx("rect",{x:l.x,y:l.y,width:l.width,height:l.height,fill:"white"})]})]})},Us=(r,t,e,a,n)=>{const i=ft(n),s=e/2,o=a/2,l=r+s,c=t+o,d=Math.sin(i),A=Math.cos(i),u=s,h=s,g=-o,m=o,p=u*A-g*d,f=h*A-m*d,C=u*d+g*A,w=h*d+m*A,S=Math.max(Math.abs(p),Math.abs(f)),y=Math.max(Math.abs(C),Math.abs(w));return{minX:l-S,maxX:l+S,minY:c-y,maxY:c+y}},Ls=(r,t,e)=>{const a=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)),n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),i=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2));return Math.acos((n*n+a*a-i*i)/(2*n*a))*(180/Math.PI)},ft=r=>r*(Math.PI/180),Vs=(r,t,e)=>Math.abs(r-t)<e,zs=(r,t,e)=>{const a=Math.sin(ft(e)),n=Math.cos(ft(e));return{x:(r.x-t.x)*n-(r.y-t.y)*a+t.x,y:(r.x-t.x)*a+(r.y-t.y)*n+t.y}},qs=(r,t)=>({x:(r.x+t.x)/2,y:(r.y+t.y)/2}),Gs=(r,t,e,a)=>({x:r.x+(t==null?void 0:t.x)*e,y:r.y+(t==null?void 0:t.y)*a}),Ws=(r,t,e,a)=>({x:r.x+((t==null?void 0:t.x)+(t==null?void 0:t.width))*e,y:r.y+(t==null?void 0:t.y)*a}),js=(r,t,e,a)=>({x:r.x+((t==null?void 0:t.x)+(t==null?void 0:t.width))*e,y:r.y+((t==null?void 0:t.y)+(t==null?void 0:t.height))*a}),Ft=r=>{switch(r){case j.North:return j.East;case j.East:return j.South;case j.South:return j.West;case j.West:return j.North;case j.Northwest:return j.Northeast;case j.Northeast:return j.Southeast;case j.Southeast:return j.Southwest;case j.Southwest:return j.Northwest}},Hs=(r,t)=>t>45&&t<=135?Ft(r):t>135&&t<=225?Ft(Ft(r)):t>225&&t<=315?Ft(Ft(Ft(r))):r,Ys=(r,t={x:0,y:0},e={x:1,y:1})=>{const a=ft(r.rotation),n={x:t.x+r.x*e.x,y:t.x+r.y*e.y},i={x:r.x+r.width,y:r.y},s={x:t.x+(r.x+r.width)*e.x,y:t.y+(r.height+r.y)*e.y},o={x:t.x+r.x*e.x,y:t.y+(r.height+r.y)*e.y},l={x:(o.x+s.x)/2,y:o.y-r.height*e.y/2};return{a:jt(n,l,a),b:jt(i,l,a),c:jt(s,l,a),d:jt(o,l,a),center:l}},jt=(r,t,e)=>{const a=Math.sin(e),n=Math.cos(e);return{x:(r.x-t.x)*n-(r.y-t.y)*a+t.x,y:(r.x-t.x)*a+(r.y-t.y)*n+t.y}},Js=.352778,Ks=.035277,Xn=r=>{const t=r.rotation||0,e=ft(t),a=Math.cos(e),n=-Math.sin(e);return F.jsx("g",{mask:r.stepName||r.productOverlay?void 0:r.mask,children:F.jsx("g",{transform:`
1389
1413
  matrix(1, 0, 0, 1, ${r.x}, ${r.y})
1390
1414
  matrix(1, 0, 0, 1, ${r.width/2}, ${r.height/2})
1391
1415
  matrix(${a}, ${-n}, ${n}, ${a}, 0, 0)
1392
1416
  matrix(1, 0, 0, 1, ${-r.width/2}, ${-r.height/2})
1393
- `,children:D.jsx("image",{xlinkHref:r.src,preserveAspectRatio:r.preserveAspectRatio,width:r.width,height:r.height})})})},Xn=r=>{var l;const t=`spiff-group-clip-${r.id}`,e=r.rotation||0,a=ft(e),n=Math.cos(a),i=-Math.sin(a),s=Fa(r.children),o=()=>D.jsx("clipPath",{id:t,preserveAspectRatio:"none",children:r.clipPath?D.jsx("path",{d:r.clipPath}):D.jsx("rect",{x:0,y:0,width:r.width,height:r.height})});return D.jsxs(D.Fragment,{children:[D.jsx("defs",{children:o()}),D.jsxs("g",{transform:`
1417
+ `,children:F.jsx("image",{xlinkHref:r.src,preserveAspectRatio:r.preserveAspectRatio,width:r.width,height:r.height})})})},Zn=r=>{var l;const t=`spiff-group-clip-${r.id}`,e=r.rotation||0,a=ft(e),n=Math.cos(a),i=-Math.sin(a),s=xa(r.children),o=()=>F.jsx("clipPath",{id:t,preserveAspectRatio:"none",children:r.clipPath?F.jsx("path",{d:r.clipPath}):F.jsx("rect",{x:0,y:0,width:r.width,height:r.height})});return F.jsxs(F.Fragment,{children:[F.jsx("defs",{children:o()}),F.jsxs("g",{transform:`
1394
1418
  matrix(1, 0, 0, 1, ${r.x}, ${r.y})
1395
1419
  matrix(1, 0, 0, 1, ${r.width/2}, ${r.height/2})
1396
1420
  matrix(${n}, ${-i}, ${i}, ${n}, 0, 0)
1397
1421
  matrix(1, 0, 0, 1, ${-r.width/2}, ${-r.height/2})
1398
- `,children:[(l=r._renderingConfiguration)!=null&&l.debug?D.jsx("rect",{stroke:"red",opacity:.3,fill:"none",x:0,y:0,width:r.width,height:r.height}):void 0,s.map(c=>rr(c)).filter(c=>!!c).map(c=>D.jsx("g",{clipPath:`url(#${t})`,children:c}))]})]})},Ks=r=>{const t=`spiff-frame-${r.id}`,e=`spiff-frame-threshold-${r.id}`,a=()=>{if(!r.pattern)return"";if(r.pattern.svg){const A=Ue(r.pattern.svg,r.pattern.colors||{},!1);return Oe(A)}return r.pattern.src};if(!a())return D.jsx(D.Fragment,{});const n=()=>r.threshold?r.invertThreshold?"1 ".repeat(r.threshold)+"0 ".repeat(256-r.threshold):"0 ".repeat(r.threshold)+"1 ".repeat(256-r.threshold):"",i=()=>D.jsx(D.Fragment,{children:r.useThreshold&&D.jsx("defs",{children:D.jsxs("filter",{id:e,"color-interpolation-filters":"sRGB",children:[D.jsx("feColorMatrix",{type:"matrix",values:`
1422
+ `,children:[(l=r._renderingConfiguration)!=null&&l.debug?F.jsx("rect",{stroke:"red",opacity:.3,fill:"none",x:0,y:0,width:r.width,height:r.height}):void 0,s.map(c=>ir(c)).filter(c=>!!c).map(c=>F.jsx("g",{clipPath:`url(#${t})`,children:c}))]})]})},_s=r=>{const t=`spiff-frame-${r.id}`,e=`spiff-frame-threshold-${r.id}`,a=()=>{if(!r.pattern)return"";if(r.pattern.svg){const A=Ue(r.pattern.svg,r.pattern.colors||{},!1);return Oe(A)}return r.pattern.src};if(!a())return F.jsx(F.Fragment,{});const n=()=>r.threshold?r.invertThreshold?"1 ".repeat(r.threshold)+"0 ".repeat(256-r.threshold):"0 ".repeat(r.threshold)+"1 ".repeat(256-r.threshold):"",i=()=>F.jsx(F.Fragment,{children:r.useThreshold&&F.jsx("defs",{children:F.jsxs("filter",{id:e,"color-interpolation-filters":"sRGB",children:[F.jsx("feColorMatrix",{type:"matrix",values:`
1399
1423
  ${r.thresholdSaturation} ${r.thresholdSaturation} ${r.thresholdSaturation} 0 0
1400
1424
  ${r.thresholdSaturation} ${r.thresholdSaturation} ${r.thresholdSaturation} 0 0
1401
1425
  ${r.thresholdSaturation} ${r.thresholdSaturation} ${r.thresholdSaturation} 0 0
1402
1426
  0 0 0 1 0
1403
- `,result:"greyscale"}),D.jsxs("feComponentTransfer",{in:"greyscale",children:[D.jsx("feFuncR",{type:"discrete",tableValues:n()}),D.jsx("feFuncG",{type:"discrete",tableValues:n()}),D.jsx("feFuncB",{type:"discrete",tableValues:n()})]})]})})}),s=r.rotation||0,o=ft(s),l=Math.cos(o),c=-Math.sin(o),d=()=>{var w,S,y,E,b,P,x,F,M,T;const A=((w=r.pattern)==null?void 0:w.x)||0,u=((S=r.pattern)==null?void 0:S.y)||0,h=((y=r.pattern)==null?void 0:y.width)||0,g=((E=r.pattern)==null?void 0:E.height)||0,m=((b=r.pattern)==null?void 0:b.scaleX)||1,p=((P=r.pattern)==null?void 0:P.scaleY)||1,f=((x=r.pattern)==null?void 0:x.rotation)||0;return[(F=r.pattern)!=null&&F.svg?{id:`${t}-contents`,type:k.Illustration,x:A,y:u,rotation:f,width:h*m,height:g*p,src:a(),svg:(M=r.pattern)==null?void 0:M.svg,colors:(T=r.pattern)==null?void 0:T.colors}:{id:`${t}-contents`,type:k.Image,x:A,y:u,rotation:f,width:h*m,height:g*p,src:a()}]};return D.jsxs(D.Fragment,{children:[i(),D.jsx("g",{opacity:r.opacity,mask:r.stepName?void 0:r.mask,filter:r.useThreshold?`url(#${e})`:void 0,children:D.jsx("g",{transform:`
1427
+ `,result:"greyscale"}),F.jsxs("feComponentTransfer",{in:"greyscale",children:[F.jsx("feFuncR",{type:"discrete",tableValues:n()}),F.jsx("feFuncG",{type:"discrete",tableValues:n()}),F.jsx("feFuncB",{type:"discrete",tableValues:n()})]})]})})}),s=r.rotation||0,o=ft(s),l=Math.cos(o),c=-Math.sin(o),d=()=>{var w,S,y,E,b,P,D,x,k,N;const A=((w=r.pattern)==null?void 0:w.x)||0,u=((S=r.pattern)==null?void 0:S.y)||0,h=((y=r.pattern)==null?void 0:y.width)||0,g=((E=r.pattern)==null?void 0:E.height)||0,m=((b=r.pattern)==null?void 0:b.scaleX)||1,p=((P=r.pattern)==null?void 0:P.scaleY)||1,f=((D=r.pattern)==null?void 0:D.rotation)||0;return[(x=r.pattern)!=null&&x.svg?{id:`${t}-contents`,type:M.Illustration,x:A,y:u,rotation:f,width:h*m,height:g*p,src:a(),svg:(k=r.pattern)==null?void 0:k.svg,colors:(N=r.pattern)==null?void 0:N.colors}:{id:`${t}-contents`,type:M.Image,x:A,y:u,rotation:f,width:h*m,height:g*p,src:a()}]};return F.jsxs(F.Fragment,{children:[i(),F.jsx("g",{opacity:r.opacity,mask:r.stepName?void 0:r.mask,filter:r.useThreshold?`url(#${e})`:void 0,children:F.jsx("g",{transform:`
1404
1428
  matrix(1, 0, 0, 1, ${r.x}, ${r.y})
1405
1429
  matrix(1, 0, 0, 1, ${r.width/2}, ${r.height/2})
1406
1430
  matrix(${l}, ${-c}, ${c}, ${l}, 0, 0)
1407
1431
  matrix(1, 0, 0, 1, ${-r.width/2}, ${-r.height/2})
1408
1432
  matrix(${r.scaleX}, 0, 0, ${r.scaleY}, 0, 0)
1409
- `,children:D.jsx(Xn,{id:t,x:0,y:0,rotation:0,width:r.width,height:r.height,clipPath:r.path,children:d()})})})]})},Zn=new Map;class _s{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,n=0;return e.forEach(i=>{const s=i.getMetrics();a=Math.max(a,s.yMax),n=Math.min(n,s.yMin)}),a-n}getKerningValue(t,e){if(!t.name||!e.name)return;let a=this.kerningValues.get(t.name);a||(a=new Map,this.kerningValues.set(t.name,a));let n=a.get(e.name);return n||(n=this.font.getKerningValue(t,e),a.set(e.name,n)),n}calculateApproximateHeight(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=this.font.stringToGlyphs(t);let a=0,n=0;return e.forEach(i=>{const s=i.getMetrics();a=Math.max(a,s.yMax),n=Math.min(n,s.yMin)}),a-n}}const Xs=r=>r.substring(0,5).toLowerCase().trim()==="data:",He=new Map,It=async r=>{if(He.has(r))return He.get(r);const e=(async()=>{try{return bt(r).getFont()}catch{if(Xs(r)){const a=Nn(r),n=ra.parse(a);return Aa(r,n),n}else{const a=await Qe(r,!0),n=ra.parse(a);return Aa(r,n),await Ei(n,r),n}}})();return He.set(r,e),e},Zs=r=>{const t=Nn(r),e=ra.parse(t);return Aa(r,e),e},bt=r=>{const t=Zn.get(r);if(t)return t;throw new Error("Font metrics unavailable for font")},Aa=(r,t)=>{const e=new _s(t);return Zn.set(r,e),e},to=async r=>{const t=ct(),e=t.parseFromString(r,"image/svg+xml"),a=e.firstElementChild,n=new Map;a.querySelectorAll("style").forEach(d=>{var u;(u=yn.parse(d.innerHTML).stylesheet)==null||u.rules.forEach(h=>{var g,m,p;if(h.type==="font-face"&&h.declarations){const f=(g=h.declarations.find(S=>S.property==="font-family"))==null?void 0:g.value,C=(m=h.declarations.find(S=>S.property==="src"))==null?void 0:m.value,w=(p=C==null?void 0:C.match(/'(https.*?)'/))==null?void 0:p[1];f&&w&&n.set(f,w)}})});const s=e.querySelectorAll("tspan");for(let d=0;d<s.length;d++){const A=s.item(d),u=A.closest("text"),h=A.closest("g"),g=u.getAttribute("font-family"),m=await It(n.get(g)),p=u.getAttribute("fill"),f=u.getAttribute("stroke"),C=u.getAttribute("stroke-width"),w=m.getPath(A.innerHTML,0,0,parseInt(u.getAttribute("font-size")??"72")),S=w.getBoundingBox().x2-w.getBoundingBox().x1;let y=0;const E=A.getAttribute("text-anchor");E==="middle"?y=S/2:E==="end"&&(y=S);const b=m.getPath(A.innerHTML,parseFloat(A.getAttribute("x")??"0")-y,parseFloat(A.getAttribute("y")??"0"),parseInt(u.getAttribute("font-size")??"72"));b.fill=p,b.stroke=f,b.strokeWidth=parseFloat(C??"0");const P=b.toSVG(2),F=t.parseFromString(P,"image/svg+xml").firstElementChild;h.appendChild(F)}return e.querySelectorAll("text").forEach(d=>d.remove()),wt().serializeToString(a)},Pe=(r,t,e,a)=>Math.max(ro(r.join(`
1410
- `),e,a),t),nn=(r,t,e,a,n,i)=>{const s=(i||xa)*n.getApproximateHeight(),o=t.split(`
1411
- `);try{const l=o.flatMap(d=>Ee(d,r.width,a,n)),c=l.flatMap(d=>d.lines);return{lines:c,requiredHeight:l.flatMap(d=>d.lines).length*(a*s),fontSize:e,requiredWidth:Pe(c,r.width,a,n)}}catch{const c=t.split("");return{lines:c,requiredHeight:c.length*(a*s),fontSize:e,requiredWidth:Pe(c,r.width,a,n)}}},Ee=(r,t,e,a)=>{const n=gt(r,e,a);if(n<=t)return{lines:[r],width:n};if(!(r.indexOf(" ")>-1)){if(r.length<=1)throw new Error(`Character ${r} is wider than region`);const d=Math.floor(r.length/2),A=Ee(r.slice(0,d),t,e,a),u=Ee(r.slice(d),t,e,a);return{lines:[...A.lines,...u.lines],width:Math.max(A.width,u.width)}}const s=r.split(" "),o=[];let l=-1/0,c=0;for(;c<s.length;){const d=s[c];if(gt(d,e,a)>t){const A=Ee(d,t,e,a);o.push(...A.lines),l=Math.max(l,A.width),c++}else{const A=[d];l=Math.max(l,gt(d,e,a));let u=c+1,h=!0;for(;u<s.length&&h;){const g=s[u],m=gt(`${A.join(" ")} ${g}`,e,a);m<=t?(A.push(g),l=Math.max(l,m),u++):h=!1}o.push(A.join(" ")),c=u}}if(l<0)throw new Error(`No max width calculated for text: ${o}.`);return{lines:o,width:l}},eo=(r,t,e,a,n,i)=>{const s=(i??xa)*t.getApproximateHeight(),o=1/e.unitsPerEm,l=tr(r,o,t),c=r.length*s*o,d=a/l,A=n/c;return Math.min(A,d)},ao=(r,t,e,a)=>{var c;const n=bt(t.fontData.assetUrl),i=n.getFont(),s=t.fontSize/i.unitsPerEm;if(!e)return nn(t,r,t.fontSize,s,n,a);let o;if(t.text?o=t.text.split(`
1433
+ `,children:F.jsx(Zn,{id:t,x:0,y:0,rotation:0,width:r.width,height:r.height,clipPath:r.path,children:d()})})})]})},tr=new Map;class Xs{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,n=0;return e.forEach(i=>{const s=i.getMetrics();a=Math.max(a,s.yMax),n=Math.min(n,s.yMin)}),a-n}getKerningValue(t,e){if(!t.name||!e.name)return;let a=this.kerningValues.get(t.name);a||(a=new Map,this.kerningValues.set(t.name,a));let n=a.get(e.name);return n||(n=this.font.getKerningValue(t,e),a.set(e.name,n)),n}calculateApproximateHeight(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=this.font.stringToGlyphs(t);let a=0,n=0;return e.forEach(i=>{const s=i.getMetrics();a=Math.max(a,s.yMax),n=Math.min(n,s.yMin)}),a-n}}const Zs=r=>r.substring(0,5).toLowerCase().trim()==="data:",He=new Map,It=async r=>{if(He.has(r))return He.get(r);const e=(async()=>{try{return bt(r).getFont()}catch{if(Zs(r)){const a=Qn(r),n=ra.parse(a);return Aa(r,n),n}else{const a=await Qe(r,!0),n=ra.parse(a);return Aa(r,n),await Ei(n,r),n}}})();return He.set(r,e),e},to=r=>{const t=Qn(r),e=ra.parse(t);return Aa(r,e),e},bt=r=>{const t=tr.get(r);if(t)return t;throw new Error("Font metrics unavailable for font")},Aa=(r,t)=>{const e=new Xs(t);return tr.set(r,e),e},eo=async r=>{const t=ct(),e=t.parseFromString(r,"image/svg+xml"),a=e.firstElementChild,n=new Map;a.querySelectorAll("style").forEach(d=>{var u;(u=Sn.parse(d.innerHTML).stylesheet)==null||u.rules.forEach(h=>{var g,m,p;if(h.type==="font-face"&&h.declarations){const f=(g=h.declarations.find(S=>S.property==="font-family"))==null?void 0:g.value,C=(m=h.declarations.find(S=>S.property==="src"))==null?void 0:m.value,w=(p=C==null?void 0:C.match(/'(https.*?)'/))==null?void 0:p[1];f&&w&&n.set(f,w)}})});const s=e.querySelectorAll("tspan");for(let d=0;d<s.length;d++){const A=s.item(d),u=A.closest("text"),h=A.closest("g"),g=u.getAttribute("font-family"),m=await It(n.get(g)),p=u.getAttribute("fill"),f=u.getAttribute("stroke"),C=u.getAttribute("stroke-width"),w=m.getPath(A.innerHTML,0,0,parseInt(u.getAttribute("font-size")??"72")),S=w.getBoundingBox().x2-w.getBoundingBox().x1;let y=0;const E=A.getAttribute("text-anchor");E==="middle"?y=S/2:E==="end"&&(y=S);const b=m.getPath(A.innerHTML,parseFloat(A.getAttribute("x")??"0")-y,parseFloat(A.getAttribute("y")??"0"),parseInt(u.getAttribute("font-size")??"72"));b.fill=p,b.stroke=f,b.strokeWidth=parseFloat(C??"0");const P=b.toSVG(2),x=t.parseFromString(P,"image/svg+xml").firstElementChild;h.appendChild(x)}return e.querySelectorAll("text").forEach(d=>d.remove()),wt().serializeToString(a)},Pe=(r,t,e,a)=>Math.max(io(r.join(`
1434
+ `),e,a),t),rn=(r,t,e,a,n,i)=>{const s=(i||Da)*n.getApproximateHeight(),o=t.split(`
1435
+ `);try{const l=o.flatMap(d=>Ee(d,r.width,a,n)),c=l.flatMap(d=>d.lines);return{lines:c,requiredHeight:l.flatMap(d=>d.lines).length*(a*s),fontSize:e,requiredWidth:Pe(c,r.width,a,n)}}catch{const c=t.split("");return{lines:c,requiredHeight:c.length*(a*s),fontSize:e,requiredWidth:Pe(c,r.width,a,n)}}},Ee=(r,t,e,a)=>{const n=gt(r,e,a);if(n<=t)return{lines:[r],width:n};if(!(r.indexOf(" ")>-1)){if(r.length<=1)throw new Error(`Character ${r} is wider than region`);const d=Math.floor(r.length/2),A=Ee(r.slice(0,d),t,e,a),u=Ee(r.slice(d),t,e,a);return{lines:[...A.lines,...u.lines],width:Math.max(A.width,u.width)}}const s=r.split(" "),o=[];let l=-1/0,c=0;for(;c<s.length;){const d=s[c];if(gt(d,e,a)>t){const A=Ee(d,t,e,a);o.push(...A.lines),l=Math.max(l,A.width),c++}else{const A=[d];l=Math.max(l,gt(d,e,a));let u=c+1,h=!0;for(;u<s.length&&h;){const g=s[u],m=gt(`${A.join(" ")} ${g}`,e,a);m<=t?(A.push(g),l=Math.max(l,m),u++):h=!1}o.push(A.join(" ")),c=u}}if(l<0)throw new Error(`No max width calculated for text: ${o}.`);return{lines:o,width:l}},ao=(r,t,e,a,n,i)=>{const s=(i??Da)*t.getApproximateHeight(),o=1/e.unitsPerEm,l=er(r,o,t),c=r.length*s*o,d=a/l,A=n/c;return Math.min(A,d)},no=(r,t,e,a)=>{var c;const n=bt(t.fontData.assetUrl),i=n.getFont(),s=t.fontSize/i.unitsPerEm;if(!e)return rn(t,r,t.fontSize,s,n,a);let o;if(t.text?o=t.text.split(`
1412
1436
  `):o=((c=t.input)==null?void 0:c.split(`
1413
- `))??[""],e.input===r&&t.width===e.width&&t.height===e.height&&t.lineHeight===e.lineHeight)return{lines:o,requiredHeight:t.height,requiredWidth:Pe(o,t.width,s,n),fontSize:t.fontSize};const l=t.width!==e.width!=(t.height!==e.height);return t.lineHeight===e.lineHeight&&!l&&e.input===r?{lines:o,requiredHeight:t.height,requiredWidth:Pe(o,t.width,s,n),fontSize:eo(o,n,i,t.width,t.height,a)}:nn(t,r,t.fontSize,s,n,a)},no=(r,t,e,a,n)=>{const s=bt(t.assetUrl).getFont();let o={...r};const l={...r},c=tr(a,e/s.unitsPerEm,bt(t.assetUrl));return c&&c<o.width&&(l.width=c,n==="left"?(l.left+=Math.sin(o.rotation*Math.PI/360)*(o.width-c),l.top+=Math.sin(o.rotation*Math.PI/180)*(c-o.width)/2):n==="right"?l.left+=o.width-c:l.left+=(o.width-c)/2,a&&io(a,a).every(([d,A])=>d===A)&&(o=l)),o},Ye=1,gt=(r,t,e)=>{let a=0;const n=e.getGlyphs(r);return n.forEach((i,s)=>{if(i.advanceWidth&&(a+=i.advanceWidth),s<n.length-1){const o=e.getKerningValue(i,n[s+1]);a+=o||0}}),a*=t,a},ro=(r,t,e)=>{let a=0;const n=e.getGlyphs(r);return n.forEach((i,s)=>{if(i.advanceWidth&&(a=Math.max(a,i.advanceWidth)),s<n.length-1){const o=e.getKerningValue(i,n[s+1]);a=Math.max(a,o||0)}}),a*=t,a},tr=(r,t,e)=>{let a=0;return r.forEach(n=>{a=Math.max(a,gt(n,t,e))}),a},rn={stripControlCharacters:!0,vertical:!1,uppercase:!1},De=(r,t=rn)=>{const e={...rn,...t};let a=r||"";return e.stripControlCharacters&&(a=a.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),e.uppercase&&(a=a.toUpperCase()),e.vertical&&(a=a.split("").join(`
1414
- `)),a},io=(r,t)=>r.map((e,a)=>[e,t[a]]),so=(r="center",t=!1)=>t?"center":r,er=r=>r==="left"?"start":r==="right"?"end":"middle",de=(r,t,e)=>r.fontData?{...r,...(()=>{if(r.algorithm===Bt.Traditional){const n=ao(t,r,e,r.lineHeight);return{text:n.lines.join(`
1415
- `),height:n.requiredHeight,width:n.requiredWidth,fontSize:n.fontSize,input:t}}else return{text:t}})()}:r,xa=1.1;function ne(r,t){return ar(r,t.getTemplatingContext())}function ar(r,t){try{r=di.compile(r)(t)}catch(e){console.error("failed to render templated text",e)}return r}const oo=r=>{var g,m,p,f,C;const e=(r.rotation||0)*Math.PI/180,a=Math.cos(e),n=-Math.sin(e),i=`text-path-${r.id}`,s=`text-fill-${r.id}`,o=r.x+(r.curved?0:r.width/2),l=r.y+(r.curved?0:r.height/2),c=ar(r.text||"",(g=r._renderingConfiguration)==null?void 0:g.templatingContext),d=c.split(`
1416
- `),A=(m=r.strokeColor)!=null&&m.browserValue&&r.strokeThickness?(p=r.strokeColor)==null?void 0:p.browserValue:void 0,u=(f=r.strokeColor)!=null&&f.browserValue&&r.strokeThickness?r.strokeThickness:void 0;if(r.curved&&!r.paths||!r.fontData)return null;const h=()=>{var w;return r.textFillImage?`url("#${s}")`:(w=r._renderingConfiguration)!=null&&w.spotColors&&r.fillSpotColorDefinition?`${r.fill} ${Ln(r.fillSpotColorDefinition)}`:r.fill};return D.jsxs(D.Fragment,{children:[D.jsxs("defs",{children:[r.textFillImage&&D.jsx("pattern",{id:s,patternUnits:"userSpaceOnUse",width:r.textFillImage.scale*r.textFillImage.width,height:r.textFillImage.scale*r.textFillImage.height,x:0,y:0,children:D.jsx("image",{href:r.textFillImage.src,xlinkHref:r.textFillImage.src,width:r.textFillImage.scale*r.textFillImage.width,height:r.textFillImage.scale*r.textFillImage.height})}),D.jsx("style",{type:"text/css",dangerouslySetInnerHTML:{__html:`
1437
+ `))??[""],e.input===r&&t.width===e.width&&t.height===e.height&&t.lineHeight===e.lineHeight)return{lines:o,requiredHeight:t.height,requiredWidth:Pe(o,t.width,s,n),fontSize:t.fontSize};const l=t.width!==e.width!=(t.height!==e.height);return t.lineHeight===e.lineHeight&&!l&&e.input===r?{lines:o,requiredHeight:t.height,requiredWidth:Pe(o,t.width,s,n),fontSize:ao(o,n,i,t.width,t.height,a)}:rn(t,r,t.fontSize,s,n,a)},ro=(r,t,e,a,n)=>{const s=bt(t.assetUrl).getFont();let o={...r};const l={...r},c=er(a,e/s.unitsPerEm,bt(t.assetUrl));return c&&c<o.width&&(l.width=c,n==="left"?(l.left+=Math.sin(o.rotation*Math.PI/360)*(o.width-c),l.top+=Math.sin(o.rotation*Math.PI/180)*(c-o.width)/2):n==="right"?l.left+=o.width-c:l.left+=(o.width-c)/2,a&&so(a,a).every(([d,A])=>d===A)&&(o=l)),o},Ye=1,gt=(r,t,e)=>{let a=0;const n=e.getGlyphs(r);return n.forEach((i,s)=>{if(i.advanceWidth&&(a+=i.advanceWidth),s<n.length-1){const o=e.getKerningValue(i,n[s+1]);a+=o||0}}),a*=t,a},io=(r,t,e)=>{let a=0;const n=e.getGlyphs(r);return n.forEach((i,s)=>{if(i.advanceWidth&&(a=Math.max(a,i.advanceWidth)),s<n.length-1){const o=e.getKerningValue(i,n[s+1]);a=Math.max(a,o||0)}}),a*=t,a},er=(r,t,e)=>{let a=0;return r.forEach(n=>{a=Math.max(a,gt(n,t,e))}),a},sn={stripControlCharacters:!0,vertical:!1,uppercase:!1},Fe=(r,t=sn)=>{const e={...sn,...t};let a=r||"";return e.stripControlCharacters&&(a=a.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),e.uppercase&&(a=a.toUpperCase()),e.vertical&&(a=a.split("").join(`
1438
+ `)),a},so=(r,t)=>r.map((e,a)=>[e,t[a]]),oo=(r="center",t=!1)=>t?"center":r,ar=r=>r==="left"?"start":r==="right"?"end":"middle",de=(r,t,e)=>r.fontData?{...r,...(()=>{if(r.algorithm===Bt.Traditional){const n=no(t,r,e,r.lineHeight);return{text:n.lines.join(`
1439
+ `),height:n.requiredHeight,width:n.requiredWidth,fontSize:n.fontSize,input:t}}else return{text:t}})()}:r,Da=1.1;function ne(r,t){return nr(r,t.getTemplatingContext())}function nr(r,t){try{r=di.compile(r)(t)}catch(e){console.error("failed to render templated text",e)}return r}const lo=r=>{var g,m,p,f,C;const e=(r.rotation||0)*Math.PI/180,a=Math.cos(e),n=-Math.sin(e),i=`text-path-${r.id}`,s=`text-fill-${r.id}`,o=r.x+(r.curved?0:r.width/2),l=r.y+(r.curved?0:r.height/2),c=nr(r.text||"",(g=r._renderingConfiguration)==null?void 0:g.templatingContext),d=c.split(`
1440
+ `),A=(m=r.strokeColor)!=null&&m.browserValue&&r.strokeThickness?(p=r.strokeColor)==null?void 0:p.browserValue:void 0,u=(f=r.strokeColor)!=null&&f.browserValue&&r.strokeThickness?r.strokeThickness:void 0;if(r.curved&&!r.paths||!r.fontData)return null;const h=()=>{var w;return r.textFillImage?`url("#${s}")`:(w=r._renderingConfiguration)!=null&&w.spotColors&&r.fillSpotColorDefinition?`${r.fill} ${Vn(r.fillSpotColorDefinition)}`:r.fill};return F.jsxs(F.Fragment,{children:[F.jsxs("defs",{children:[r.textFillImage&&F.jsx("pattern",{id:s,patternUnits:"userSpaceOnUse",width:r.textFillImage.scale*r.textFillImage.width,height:r.textFillImage.scale*r.textFillImage.height,x:0,y:0,children:F.jsx("image",{href:r.textFillImage.src,xlinkHref:r.textFillImage.src,width:r.textFillImage.scale*r.textFillImage.width,height:r.textFillImage.scale*r.textFillImage.height})}),F.jsx("style",{type:"text/css",dangerouslySetInnerHTML:{__html:`
1417
1441
  @font-face {
1418
1442
  font-family: '${r.fontData.name}';
1419
1443
  src: url('${r.fontData.assetUrl}') format('truetype');
1420
1444
  }
1421
- `}}),r.curved&&r.paths?D.jsx("path",{id:i,d:r.paths[0]}):void 0]}),(C=r._renderingConfiguration)!=null&&C.debug?D.jsx("rect",{stroke:"blue",fill:"none",x:r.x,y:r.y,width:r.width,height:r.height}):void 0,D.jsx("g",{mask:r.stepName?void 0:r.mask,children:D.jsx("g",{transform:`matrix(${a}, ${-n}, ${n}, ${a}, ${o}, ${l})`,children:D.jsx("text",{xmlSpace:"preserve",fontFamily:`'${r.fontData.name}'`,fontSize:r.fontSize,fontStyle:"normal",fontWeight:"normal",fill:h(),style:{whiteSpace:"pre",userSelect:"none"},stroke:A,strokeWidth:u,children:r.curved?D.jsx(co,{text:c,curvedPathId:i,align:r.align}):d.map((w,S)=>D.jsx(lo,{align:r.vertical?"center":r.align,fontSize:r.fontSize,thisLineIdx:S,amountLines:d.length,text:w,textboxHeight:r.height,textboxWidth:r.width,lineHeight:r.lineHeight,vertical:r.vertical,verticalAlign:r.verticalAlign},S))})})})]})},lo=r=>{const t=()=>r.lineHeight!==void 0?r.lineHeight:xa,e=()=>r.align==="left"?-r.textboxWidth/2:r.align==="right"?r.textboxWidth/2:0,a=()=>{const n=r.fontSize*t(),i=r.textboxHeight/2;if(r.verticalAlign==="top")return-i+r.fontSize*3/4+r.thisLineIdx*n;if(r.verticalAlign==="bottom"){const o=r.amountLines-1-r.thisLineIdx;return i-r.fontSize/4-o*n}const s=(r.amountLines-1)/2;return(r.thisLineIdx-s)*n+r.fontSize/4};return D.jsx("tspan",{textAnchor:er(r.align),x:e(),y:`${a()}px`,children:r.text})},co=r=>{const t=`#${r.curvedPathId}`,e=()=>r.align==="left"?"0%":r.align==="right"?"100%":"50%";return D.jsx("textPath",{startOffset:e(),textAnchor:er(r.align),href:t,xlinkHref:t,children:r.text})},Ao=r=>{var s,o;if(r.cachedObjectURL&&!((s=r._renderingConfiguration)!=null&&s.omitCachedFields))return D.jsx(_n,{id:r.id,src:r.cachedObjectURL,x:r.x,y:r.y,width:r.width,height:r.height,rotation:r.rotation,preserveAspectRatio:"none",immutable:r.immutable,mask:r.stepName?void 0:r.mask});const t=r.rotation||0,e=ft(t),a=Math.cos(e),n=-Math.sin(e),i=`
1445
+ `}}),r.curved&&r.paths?F.jsx("path",{id:i,d:r.paths[0]}):void 0]}),(C=r._renderingConfiguration)!=null&&C.debug?F.jsx("rect",{stroke:"blue",fill:"none",x:r.x,y:r.y,width:r.width,height:r.height}):void 0,F.jsx("g",{mask:r.stepName?void 0:r.mask,children:F.jsx("g",{transform:`matrix(${a}, ${-n}, ${n}, ${a}, ${o}, ${l})`,children:F.jsx("text",{xmlSpace:"preserve",fontFamily:`'${r.fontData.name}'`,fontSize:r.fontSize,fontStyle:"normal",fontWeight:"normal",fill:h(),style:{whiteSpace:"pre",userSelect:"none"},stroke:A,strokeWidth:u,children:r.curved?F.jsx(Ao,{text:c,curvedPathId:i,align:r.align}):d.map((w,S)=>F.jsx(co,{align:r.vertical?"center":r.align,fontSize:r.fontSize,thisLineIdx:S,amountLines:d.length,text:w,textboxHeight:r.height,textboxWidth:r.width,lineHeight:r.lineHeight,vertical:r.vertical,verticalAlign:r.verticalAlign},S))})})})]})},co=r=>{const t=()=>r.lineHeight!==void 0?r.lineHeight:Da,e=()=>r.align==="left"?-r.textboxWidth/2:r.align==="right"?r.textboxWidth/2:0,a=()=>{const n=r.fontSize*t(),i=r.textboxHeight/2;if(r.verticalAlign==="top")return-i+r.fontSize*3/4+r.thisLineIdx*n;if(r.verticalAlign==="bottom"){const o=r.amountLines-1-r.thisLineIdx;return i-r.fontSize/4-o*n}const s=(r.amountLines-1)/2;return(r.thisLineIdx-s)*n+r.fontSize/4};return F.jsx("tspan",{textAnchor:ar(r.align),x:e(),y:`${a()}px`,children:r.text})},Ao=r=>{const t=`#${r.curvedPathId}`,e=()=>r.align==="left"?"0%":r.align==="right"?"100%":"50%";return F.jsx("textPath",{startOffset:e(),textAnchor:ar(r.align),href:t,xlinkHref:t,children:r.text})},uo=r=>{var s,o;if(r.cachedObjectURL&&!((s=r._renderingConfiguration)!=null&&s.omitCachedFields))return F.jsx(Xn,{id:r.id,src:r.cachedObjectURL,x:r.x,y:r.y,width:r.width,height:r.height,rotation:r.rotation,preserveAspectRatio:"none",immutable:r.immutable,mask:r.stepName?void 0:r.mask});const t=r.rotation||0,e=ft(t),a=Math.cos(e),n=-Math.sin(e),i=`
1422
1446
  matrix(1, 0, 0, 1, ${r.x}, ${r.y})
1423
1447
  matrix(1, 0, 0, 1, ${r.width/2}, ${r.height/2})
1424
1448
  matrix(${a}, ${-n}, ${n}, ${a}, 0, 0)
1425
1449
  matrix(1, 0, 0, 1, ${-r.width/2}, ${-r.height/2})
1426
- `;if(!r.svg)throw new Error(`Illustration element ${r.id} (stepName ${r.stepName}) lacked svg from src ${r.src} at render time.`);return D.jsx("g",{mask:r.stepName?void 0:r.mask,children:D.jsx("g",{transform:i,dangerouslySetInnerHTML:{__html:Ba(r.svg,r.width,r.height,r.colors,(o=r._renderingConfiguration)==null?void 0:o.spotColors)}})})};class nr{constructor(){this.id=Q(),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();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 n=this.prevCommands.filter(i=>i.sequenceId===t).pop();n&&(this.prevCommands=this.prevCommands.filter(i=>i.sequenceId!==t),n==null||n.overrideOldState(e),this.prevCommands.push(n))}getLayoutById(t){var i,s;if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const e=(s=(i=this.state.transaction)==null?void 0:i.layouts)==null?void 0:s[t],a=e==null?void 0:e.layout;if(!a)throw new Error(`No layout: ${t}`);const n=[...(e==null?void 0:e.elements)||[]];return this.getLayoutDataWithState(a,n)}getAllLayouts(){var a;if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const t=[...Object.keys((a=this.state.transaction)==null?void 0:a.layouts)];return[...new Set(t)].map(n=>this.getLayoutById(n))}getLayoutDataWithState(t,e){return{layoutState:{layout:t,elements:e},getComponentWithProps:a=>ze(t,e,a)}}initialize(t,e){if(e){this.state={transaction:e};return}let a={serializableWorkflow:{steps:[]},layouts:{}};t.forEach(n=>{a=new Na(n).apply(a)}),this.runStateCallbacks(),this.state={transaction:a}}commandReducer(t,e){const a=t.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...t,transaction:e.apply(a)}}}const rr=r=>r.type===k.Image?D.jsx(_n,{...r},r.id):r.type===k.Frame?D.jsx(Ks,{...r},r.id):r.type===k.Illustration?D.jsx(Ao,{...r},r.id):r.type===k.Textbox?D.jsx(oo,{...r},r.id):r.type===k.Group?D.jsx(Xn,{...r},r.id):null,ze=(r,t,e)=>{const a=e.renderingConfiguration,n=a!=null&&a.removeExcludedElements?t.filter(i=>!i.excludeFromExport):t;return D.jsx(Os,{preserveAspectRatio:void 0,elements:n,backgroundColor:r.transparentBackground?void 0:e.backgroundColor?e.backgroundColor:"white",width:e.width||r.width,height:e.height||r.height,viewBox:a!=null&&a.region?{x:a.region.left,y:a.region.top,width:a.region.width,height:a.region.height}:{x:0,y:0,width:r.width,height:r.height},configuration:a,outlineArea:e.outlineArea,maxHeight:e.maxHeight,maxWidth:e.maxWidth,position:e.position,borderRadius:e.borderRadius,outlineColor:e.outlineColor})};function Fa(r){return r.sort((t,e)=>{const a=t.layer||0,n=e.layer||0;if(a<n)return-1;if(a>n)return 1;const i=t.layerIndex||0,s=e.layerIndex||0;return i<s?-1:i>s?1:0})}const Ae=r=>{const t=r.variants;if(t){if(t.length===1)return t[0];if(r.defaultVariant!==void 0)return t.find(e=>e.id===r.defaultVariant)}},dt=new Map,Ft=new Map,Je=new Map,ir=async(r,t)=>{if(!t){if(!r)throw new Error("No region or src supplied. Cannot construct frame!");return ua(r)}return et(t)},ua=r=>{const t=r.width,e=r.height;return`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${t} ${e}'>
1450
+ `;if(!r.svg)throw new Error(`Illustration element ${r.id} (stepName ${r.stepName}) lacked svg from src ${r.src} at render time.`);return F.jsx("g",{mask:r.stepName?void 0:r.mask,children:F.jsx("g",{transform:i,dangerouslySetInnerHTML:{__html:Ba(r.svg,r.width,r.height,r.colors,(o=r._renderingConfiguration)==null?void 0:o.spotColors)}})})};class rr{constructor(){this.id=Q(),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();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 n=this.prevCommands.filter(i=>i.sequenceId===t).pop();n&&(this.prevCommands=this.prevCommands.filter(i=>i.sequenceId!==t),n==null||n.overrideOldState(e),this.prevCommands.push(n))}getLayoutById(t){var i,s;if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const e=(s=(i=this.state.transaction)==null?void 0:i.layouts)==null?void 0:s[t],a=e==null?void 0:e.layout;if(!a)throw new Error(`No layout: ${t}`);const n=[...(e==null?void 0:e.elements)||[]];return this.getLayoutDataWithState(a,n)}getAllLayouts(){var a;if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const t=[...Object.keys((a=this.state.transaction)==null?void 0:a.layouts)];return[...new Set(t)].map(n=>this.getLayoutById(n))}getLayoutDataWithState(t,e){return{layoutState:{layout:t,elements:e},getComponentWithProps:a=>ze(t,e,a)}}initialize(t,e){if(e){this.state={transaction:e};return}let a={serializableWorkflow:{steps:[]},layouts:{}};t.forEach(n=>{a=new Na(n).apply(a)}),this.runStateCallbacks(),this.state={transaction:a}}commandReducer(t,e){const a=t.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...t,transaction:e.apply(a)}}}const ir=r=>r.type===M.Image?F.jsx(Xn,{...r},r.id):r.type===M.Frame?F.jsx(_s,{...r},r.id):r.type===M.Illustration?F.jsx(uo,{...r},r.id):r.type===M.Textbox?F.jsx(lo,{...r},r.id):r.type===M.Group?F.jsx(Zn,{...r},r.id):null,ze=(r,t,e)=>{const a=e.renderingConfiguration,n=a!=null&&a.removeExcludedElements?t.filter(i=>!i.excludeFromExport):t;return F.jsx($s,{preserveAspectRatio:void 0,elements:n,backgroundColor:r.transparentBackground?void 0:e.backgroundColor?e.backgroundColor:"white",width:e.width||r.width,height:e.height||r.height,viewBox:a!=null&&a.region?{x:a.region.left,y:a.region.top,width:a.region.width,height:a.region.height}:{x:0,y:0,width:r.width,height:r.height},configuration:a,outlineArea:e.outlineArea,maxHeight:e.maxHeight,maxWidth:e.maxWidth,position:e.position,borderRadius:e.borderRadius,outlineColor:e.outlineColor})};function xa(r){return r.sort((t,e)=>{const a=t.layer||0,n=e.layer||0;if(a<n)return-1;if(a>n)return 1;const i=t.layerIndex||0,s=e.layerIndex||0;return i<s?-1:i>s?1:0})}const Ae=r=>{const t=r.variants;if(t){if(t.length===1)return t[0];if(r.defaultVariant!==void 0)return t.find(e=>e.id===r.defaultVariant)}},dt=new Map,xt=new Map,Je=new Map,sr=async(r,t)=>{if(!t){if(!r)throw new Error("No region or src supplied. Cannot construct frame!");return ua(r)}return tt(t)},ua=r=>{const t=r.width,e=r.height;return`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${t} ${e}'>
1427
1451
  <path id="target-path" d='M0 0 h ${t} v ${e} h ${-t} Z' />
1428
1452
  </svg>
1429
- `},uo=(r,t)=>{var a;if(!t)return;const e=((a=t.variants)==null?void 0:a.find(n=>n.id===r.frameVariantId))||Ae(t);if(!e)throw new Error(`No variant with ID: ${r.frameVariantId}`);if(!e.asset)throw new Error(`No asset for variant with ID: ${r.frameVariantId}`);return e},ue=async r=>{if(Je.has(r))return Je.get(r);const e=(async()=>{if(Ft.has(r))return Ft.get(r);await new Promise(u=>setTimeout(u,0));const n=ct().parseFromString(r,"image/svg+xml"),i=n.querySelector("svg");if(!i)throw new Error("Malformed frame SVG: <svg> tag not found");const s=i.getAttribute("viewBox");if(!s)throw new Error("SVG missing viewBox.");const o=s.split(" "),l=parseFloat(o[3])||1,c=parseFloat(o[2])||1,d=n.getElementById("target-path"),A=n.getElementsByClassName("st0").item(0);if(d){const u=d.getAttribute("d");if(!u)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const h={path:u,width:c,height:l};return Ft.set(u,h),h}if(A){const u=A.getAttribute("d");if(!u)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const h={path:u,width:c,height:l};return Ft.set(u,h),h}throw new Error("Malformed frame SVG")})();return Je.set(r,e),e},ka=(r,t,e,a)=>{const n=t.width/t.height,i=r.width/r.height;let s;a?i>n?s=t.height/r.height:s=t.width/r.width:i>n?s=t.width/r.width:s=t.height/r.height,(e==null?void 0:e.scale)!==void 0&&(s*=e==null?void 0:e.scale);const o=t.width/2,l=t.height/2,c=o-r.width/2*s,d=(e==null?void 0:e.left)||c,A=l-r.height/2*s,u=(e==null?void 0:e.top)||A;return{x:d,y:u,zoom:s}},ha=async r=>{var e;if(dt.has(r))return dt.get(r);if(r.startsWith("data:image/svg+xml")){const a=Ai.dataUriToBuffer(r),n=new TextDecoder().decode(a.buffer),i=Ta(n),s={src:r,width:i.width,height:i.height,aspect:i.width/i.height};return dt.set(r,s),s}if((((e=r.split(".").pop())==null?void 0:e.toLowerCase())??"")==="svg"){const a=await Ma(r),n=a.width,i=a.height,s={src:r,width:n,height:i,aspect:n/i};return dt.set(r,s),s}else{const a=await Qe(r,!0),n=await le(a),i={src:r,width:n.width,height:n.height,aspect:n.width/n.height};return dt.set(r,i),i}},Ma=async r=>{const t=await et(r);return Ta(t)},sn=r=>r.endsWith("mm")?Number(r.replace("mm",""))*3.7795275591:r.endsWith("px")?Number(r.replace("px","")):Number(r),Ta=r=>{const a=ct().parseFromString(r,"image/svg+xml").querySelector("svg");if(!a)throw new Error("No svg tag found, this svg must be malformed!");const n=a.getAttribute("viewBox"),i=a.getAttribute("width"),s=a.getAttribute("height"),o=s&&i?[0,0,sn(i),sn(s)]:n==null?void 0:n.split(" ").map(l=>Number(l));if(!o)throw new Error("No viewbox or width/height values detected on SVG file!");return{width:o[2],height:o[3]}},Gt=(r,t)=>{const e=r.layoutState.elements.filter(n=>n.layer===t),a=Math.max(...e.map(n=>n.layerIndex).filter(n=>n!==void 0));return Math.max(a,0)+1},sr=async r=>new Promise(t=>{et(r).then(e=>{t(e)}).catch(e=>console.error(e))}),Ke=new Map,re=async r=>{if(Ke.has(r))return Ke.get(r);const t=async n=>new Promise((i,s)=>{try{if(!(!!URL&&!!URL.createObjectURL))throw new Error("Environment incapable of generating ObjectURL");n.toBlob(l=>{if(!l)throw n.width===0||n.height===0?new Error(`Canvas dimensions are invalid (${n.width},${n.height})`):n.width*n.height>=268435456?new Error(`Canvas dimensions exceed device limit (${n.width},${n.height})`):new Error("Couldn't generate object URL for Illustration, the blob was undefined!");i(URL.createObjectURL(l))})}catch(o){s(o)}}),a=(async()=>{const s=ct().parseFromString(r,"image/svg+xml").firstElementChild;if(!s)throw new Error("Failed to read SVG");const l=wt().serializeToString(s),c=pt(),d=c.getContext("2d"),A=await Sa.Pith.from(d,l,{anonymousCrossOrigin:!0,ignoreDimensions:!1,createCanvas:pt,createImage:oe,DOMParser:ba(),fetch:st}),u=s.getAttribute("width"),h=s.getAttribute("height"),g=2048;if(h&&u){const m=parseFloat(h),f=parseFloat(u)/m;f>1?A.resize(g,g/f):A.resize(g*f,g)}else A.resize(g,g);return await A.render(),await t(c)})();return Ke.set(r,a),a},qt=async(r,t,e,a)=>{const n=r.layoutState.layout.useEditableArea&&r.layoutState.layout.editableArea||{width:r.layoutState.layout.width,height:r.layoutState.layout.height,x:0,y:0},i=n.width<n.height?n.width:n.height,s=r.layoutState.layout.useEditableArea?i/1.3:i/2,o={top:n.y+n.height/2-s/2,left:n.x+n.width/2-s/2,width:s,height:s,rotation:0,panelId:r.layoutState.layout.panelId};if(e&&t===k.Illustration){const l=await ot(await sr(e)),u=ct().parseFromString(l.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!u)throw new Error("SVG missing viewBox.");const h=o.height,g=u.split(" "),m=parseFloat(g[2])||1,p=parseFloat(g[3])||1,f=m/p;o.height=o.width/f,o.top+=(h-o.height)/2}if(e&&t===k.Image){const l=o.height,c=await Qe(e),d=await le(c),A=d.width/d.height;o.height=o.width/A,o.top+=(l-o.height)/2}if(e&&t===k.Textbox&&(a!=null&&a.text)&&(a!=null&&a.fontScale)){await It(e);const l=bt(e),c=gt(a.text,a==null?void 0:a.fontScale,l);o.width=Math.min(c,n.width*.85),o.left=n.x+n.width/2-o.width/2}return o};class ho{static async getFrame(t,e){const a=await ir(e.region,e.src),n=await ue(a),i=e.region||await qt(t,k.Frame);return{id:Q(),x:i.left,y:i.top,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||Gt(t,i.layer||0),rotation:i.rotation,scaleX:i.width/n.width,scaleY:i.height/n.height,path:n.path,dataWidth:n.width,dataHeight:n.height,type:k.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:i.immutable}}static async getImage(t,e){const a=e.region||await qt(t,k.Image,e.src);return{id:Q(),src:e.src,type:k.Image,y:a.top,x:a.left,rotation:a.rotation,width:a.width,height:a.height,layer:a.layer||0,layerIndex:a.layerIndex||Gt(t,a.layer||0),immutable:a.immutable,preserveAspectRatio:"none"}}static async getTextbox(t,e){var g;const{configuration:a,fontSrc:n,designInputStep:i}=e,s=await It(n),o={assetUrl:n,name:s.names.fullName.en},l=(i==null?void 0:i.text)||a.defaultText||"",c=a.replaceableText?a.replaceableText.replace("{{}}",l):l,d=De(c,{vertical:a.vertical,uppercase:a.uppercase}),A=e.region||await qt(t,k.Textbox,n,{text:d,fontScale:a.size?a.size/s.unitsPerEm:void 0}),u=de({id:Q(),type:k.Textbox,x:A.left,y:A.top,width:A.width,height:A.height,align:so(a.textAlign,a.vertical),curved:a.curved,fill:(i==null?void 0:i.color)||a.colour||"#000000",fontData:o,layer:A.layer||0,layerIndex:A.layerIndex||Gt(t,A.layer||0),paths:a.paths,rotation:A.rotation,vertical:a.vertical,verticalAlign:a.verticalAlign||"middle",algorithm:Bt.Traditional,fontSize:a.size||Math.max(Math.round(A.height*.025),1),text:d,input:l},d),h=no({...A,height:u.height},o,u.fontSize,((g=u==null?void 0:u.text)==null?void 0:g.split(`
1453
+ `},ho=(r,t)=>{var a;if(!t)return;const e=((a=t.variants)==null?void 0:a.find(n=>n.id===r.frameVariantId))||Ae(t);if(!e)throw new Error(`No variant with ID: ${r.frameVariantId}`);if(!e.asset)throw new Error(`No asset for variant with ID: ${r.frameVariantId}`);return e},ue=async r=>{if(Je.has(r))return Je.get(r);const e=(async()=>{if(xt.has(r))return xt.get(r);await new Promise(u=>setTimeout(u,0));const n=ct().parseFromString(r,"image/svg+xml"),i=n.querySelector("svg");if(!i)throw new Error("Malformed frame SVG: <svg> tag not found");const s=i.getAttribute("viewBox");if(!s)throw new Error("SVG missing viewBox.");const o=s.split(" "),l=parseFloat(o[3])||1,c=parseFloat(o[2])||1,d=n.getElementById("target-path"),A=n.getElementsByClassName("st0").item(0);if(d){const u=d.getAttribute("d");if(!u)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const h={path:u,width:c,height:l};return xt.set(u,h),h}if(A){const u=A.getAttribute("d");if(!u)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const h={path:u,width:c,height:l};return xt.set(u,h),h}throw new Error("Malformed frame SVG")})();return Je.set(r,e),e},ka=(r,t,e,a)=>{const n=t.width/t.height,i=r.width/r.height;let s;a?i>n?s=t.height/r.height:s=t.width/r.width:i>n?s=t.width/r.width:s=t.height/r.height,(e==null?void 0:e.scale)!==void 0&&(s*=e==null?void 0:e.scale);const o=t.width/2,l=t.height/2,c=o-r.width/2*s,d=(e==null?void 0:e.left)||c,A=l-r.height/2*s,u=(e==null?void 0:e.top)||A;return{x:d,y:u,zoom:s}},ha=async r=>{var e;if(dt.has(r))return dt.get(r);if(r.startsWith("data:image/svg+xml")){const a=Ai.dataUriToBuffer(r),n=new TextDecoder().decode(a.buffer),i=Ta(n),s={src:r,width:i.width,height:i.height,aspect:i.width/i.height};return dt.set(r,s),s}if((((e=r.split(".").pop())==null?void 0:e.toLowerCase())??"")==="svg"){const a=await Ma(r),n=a.width,i=a.height,s={src:r,width:n,height:i,aspect:n/i};return dt.set(r,s),s}else{const a=await Qe(r,!0),n=await le(a),i={src:r,width:n.width,height:n.height,aspect:n.width/n.height};return dt.set(r,i),i}},Ma=async r=>{const t=await tt(r);return Ta(t)},on=r=>r.endsWith("mm")?Number(r.replace("mm",""))*3.7795275591:r.endsWith("px")?Number(r.replace("px","")):Number(r),Ta=r=>{const a=ct().parseFromString(r,"image/svg+xml").querySelector("svg");if(!a)throw new Error("No svg tag found, this svg must be malformed!");const n=a.getAttribute("viewBox"),i=a.getAttribute("width"),s=a.getAttribute("height"),o=s&&i?[0,0,on(i),on(s)]:n==null?void 0:n.split(" ").map(l=>Number(l));if(!o)throw new Error("No viewbox or width/height values detected on SVG file!");return{width:o[2],height:o[3]}},qt=(r,t)=>{const e=r.layoutState.elements.filter(n=>n.layer===t),a=Math.max(...e.map(n=>n.layerIndex).filter(n=>n!==void 0));return Math.max(a,0)+1},or=async r=>new Promise(t=>{tt(r).then(e=>{t(e)}).catch(e=>console.error(e))}),Ke=new Map,re=async r=>{if(Ke.has(r))return Ke.get(r);const t=async n=>new Promise((i,s)=>{try{if(!(!!URL&&!!URL.createObjectURL))throw new Error("Environment incapable of generating ObjectURL");n.toBlob(l=>{if(!l)throw n.width===0||n.height===0?new Error(`Canvas dimensions are invalid (${n.width},${n.height})`):n.width*n.height>=268435456?new Error(`Canvas dimensions exceed device limit (${n.width},${n.height})`):new Error("Couldn't generate object URL for Illustration, the blob was undefined!");i(URL.createObjectURL(l))})}catch(o){s(o)}}),a=(async()=>{const s=ct().parseFromString(r,"image/svg+xml").firstElementChild;if(!s)throw new Error("Failed to read SVG");const l=wt().serializeToString(s),c=pt(),d=c.getContext("2d"),A=await Sa.Pith.from(d,l,{anonymousCrossOrigin:!0,ignoreDimensions:!1,createCanvas:pt,createImage:oe,DOMParser:ba(),fetch:st}),u=s.getAttribute("width"),h=s.getAttribute("height"),g=2048;if(h&&u){const m=parseFloat(h),f=parseFloat(u)/m;f>1?A.resize(g,g/f):A.resize(g*f,g)}else A.resize(g,g);return await A.render(),await t(c)})();return Ke.set(r,a),a},Gt=async(r,t,e,a)=>{const n=r.layoutState.layout.useEditableArea&&r.layoutState.layout.editableArea||{width:r.layoutState.layout.width,height:r.layoutState.layout.height,x:0,y:0},i=n.width<n.height?n.width:n.height,s=r.layoutState.layout.useEditableArea?i/1.3:i/2,o={top:n.y+n.height/2-s/2,left:n.x+n.width/2-s/2,width:s,height:s,rotation:0,panelId:r.layoutState.layout.panelId};if(e&&t===M.Illustration){const l=await ot(await or(e)),u=ct().parseFromString(l.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!u)throw new Error("SVG missing viewBox.");const h=o.height,g=u.split(" "),m=parseFloat(g[2])||1,p=parseFloat(g[3])||1,f=m/p;o.height=o.width/f,o.top+=(h-o.height)/2}if(e&&t===M.Image){const l=o.height,c=await Qe(e),d=await le(c),A=d.width/d.height;o.height=o.width/A,o.top+=(l-o.height)/2}if(e&&t===M.Textbox&&(a!=null&&a.text)&&(a!=null&&a.fontScale)){await It(e);const l=bt(e),c=gt(a.text,a==null?void 0:a.fontScale,l);o.width=Math.min(c,n.width*.85),o.left=n.x+n.width/2-o.width/2}return o};class go{static async getFrame(t,e){const a=await sr(e.region,e.src),n=await ue(a),i=e.region||await Gt(t,M.Frame);return{id:Q(),x:i.left,y:i.top,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||qt(t,i.layer||0),rotation:i.rotation,scaleX:i.width/n.width,scaleY:i.height/n.height,path:n.path,dataWidth:n.width,dataHeight:n.height,type:M.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:i.immutable}}static async getImage(t,e){const a=e.region||await Gt(t,M.Image,e.src);return{id:Q(),src:e.src,type:M.Image,y:a.top,x:a.left,rotation:a.rotation,width:a.width,height:a.height,layer:a.layer||0,layerIndex:a.layerIndex||qt(t,a.layer||0),immutable:a.immutable,preserveAspectRatio:"none"}}static async getTextbox(t,e){var g;const{configuration:a,fontSrc:n,designInputStep:i}=e,s=await It(n),o={assetUrl:n,name:s.names.fullName.en},l=(i==null?void 0:i.text)||a.defaultText||"",c=a.replaceableText?a.replaceableText.replace("{{}}",l):l,d=Fe(c,{vertical:a.vertical,uppercase:a.uppercase}),A=e.region||await Gt(t,M.Textbox,n,{text:d,fontScale:a.size?a.size/s.unitsPerEm:void 0}),u=de({id:Q(),type:M.Textbox,x:A.left,y:A.top,width:A.width,height:A.height,align:oo(a.textAlign,a.vertical),curved:a.curved,fill:(i==null?void 0:i.color)||a.colour||"#000000",fontData:o,layer:A.layer||0,layerIndex:A.layerIndex||qt(t,A.layer||0),paths:a.paths,rotation:A.rotation,vertical:a.vertical,verticalAlign:a.verticalAlign||"middle",algorithm:Bt.Traditional,fontSize:a.size||Math.max(Math.round(A.height*.025),1),text:d,input:l},d),h=ro({...A,height:u.height},o,u.fontSize,((g=u==null?void 0:u.text)==null?void 0:g.split(`
1430
1454
  `))||[],u.align);return{...u,x:h.left,y:h.top+(A.height-h.height)/2,width:h.width,height:h.height}}static async getShape(t,e){const a=`
1431
1455
  <svg
1432
1456
  xmlns="http://www.w3.org/2000/svg"
@@ -1447,7 +1471,7 @@
1447
1471
  fill="${e.color}"
1448
1472
  />
1449
1473
  </svg>
1450
- `,n={};n["spiff-fill-shape"]={browserValue:e.color};const i=e.region||await qt(t,k.Illustration),s=Q();return{stepRegion:e.region,colors:n,id:s,svg:a,type:k.Illustration,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||Gt(t,i.layer||0),immutable:i.immutable}}static async getIllustration(t,e){const a=e.region||await qt(t,k.Illustration,e.src),n=await ot(await sr(e.src)),i=await re(n.svg),s=Q();return{cachedObjectURL:i,stepRegion:e.region,colors:n.colors,id:s,src:e.src,svg:n.svg,type:k.Illustration,y:a.top,x:a.left,rotation:a.rotation,width:a.width,height:a.height,layer:a.layer||0,layerIndex:a.layerIndex||Gt(t,a.layer||0),immutable:a.immutable}}}class G extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,G.prototype)}}const L=(r,t)=>_(r,t).elements.find(n=>n.id===r),_=(r,t)=>{const e=Object.values(t).find(a=>a.elements.some(n=>n.id===r));if(!e)throw new G;return e},X=(r,t)=>{const e=[...t.elements.filter(n=>n.id!==r.id),r],a=Fa(e);return{layout:t.layout,elements:a,modificationID:Q()}},or=async r=>{var a;const t=[...Object.keys(r.layouts)],e=[...new Set(t)];for(let n=0;n<e.length;n++){const i=e[n],s=r.layouts[i];await Promise.all(s.elements.map(async o=>{var l,c,d;if(o.type==="illustration"){const A=o;if(A.src&&!A.svg){const u=await et(A.src),h=await ot(u);A.svg=Ba(h.svg,A.width,A.height,A.colors)}}else if(o.type==="frame"){const A=o;if((l=A.pattern)!=null&&l.colors&&((c=A.pattern)!=null&&c.src)){const u=await et((d=A.pattern)==null?void 0:d.src),h=await ot(u);A.pattern.svg=h.svg}}isNaN(o.x)&&(o.x=0),isNaN(o.y)&&(o.y=0),isNaN(o.width)&&(o.width=0),isNaN(o.height)&&(o.height=0),isNaN(o.rotation)&&(o.rotation=0)}))}for(const n in r.layouts){const i=r.layouts[n].elements.filter(o=>o.type===k.Illustration);for(let o=0;o<i.length;++o){const l=i[o];if(l.src&&l.svg)try{l.cachedObjectURL=await re(l.svg)}catch(c){console.log(c)}}const s=r.layouts[n].elements.filter(o=>o.type===k.Textbox);for(let o=0;o<s.length;++o){const l=s[o];(a=l.fontData)!=null&&a.assetUrl&&await It(l.fontData.assetUrl)}}};class O{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(t){this.oldState=t}}class on extends O{constructor(t){super(),this.serializableWorkflow=t}apply(t){return this.oldState=t,{...t,serializableWorkflow:this.serializableWorkflow}}}class go extends O{constructor(t,e,a){super(),this.id=t,this.x=e,this.y=a}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new G;const a={...e,x:this.x,y:this.y},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class mo extends O{constructor(t,e){super(),this.id=t,this.angle=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new G;const a={...e,rotation:this.angle},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class po extends O{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=L(this.id,Object.values(t.layouts));if(!e.id)throw new G;let a={...e,width:this.width,height:this.height};if(e.type==="frame"){const s=a;s.scaleX=s.scaleX*this.width/e.width,s.scaleY=s.scaleY*this.height/e.height}else if(e.type==="textbox"){const s=a,o=(!s.algorithm||s.algorithm===Bt.Autosize?s.text:s.input)??"";a=de(s,o,e)}const n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class $ extends O{constructor(t){super(),this.commands=t}apply(t){return this.oldState=t,this.commands.reduce((e,a)=>a.apply(e),t)}}class Na extends O{constructor(t){super(),this.layout=t}apply(t){return this.oldState=t,{...t,layouts:{...t.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:Q()}}}}}class q extends O{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(o=>o.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||e.length===0){const o=[...e,this.element];return this.element.layerIndex===void 0&&(this.element.layerIndex=this.assignIndex(this.element,o)),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:o,modificationID:Q()}}}}const n=e[e.length-1],i=n.productOverlay?n:null;i&&e.pop();let s;if(this.element.layerIndex!==null&&this.element.layerIndex!==void 0)s=[...e,this.element].sort((o,l)=>o.layerIndex!==void 0&&l.layerIndex!==void 0?o.layerIndex-l.layerIndex:0);else{const o=this.assignIndex(this.element,e);this.element.layerIndex=o!==void 0?o:0,s=[...e,this.element]}return i&&s.push(i),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:s,modificationID:Q()}}}}assignIndex(t,e){var n;if(e.length===0)return 0;const a=(n=e.filter(i=>(i.layer||0)===(t.layer||0)).sort((i,s)=>(i.layerIndex||0)-(s.layerIndex||0))[e.length-1])==null?void 0:n.layerIndex;return a!==void 0?a+1:0}}class Ct extends O{constructor(t){super(),this.id=t}apply(t){this.oldState=t;let e=!1;const a=Object.values(t.layouts).map(i=>(i.elements.filter(o=>o.id!==this.id).length!==i.elements.length&&(e=!0),{...i,elements:i.elements.filter(o=>o.id!==this.id),modificationID:Q()}));e||console.log(`Failed to delete element ${this.id}`);const n={};return a.forEach(i=>{n[i.layout.id]=i}),{...t,layouts:n}}}class lr extends O{constructor(t,e,a){super(),this.id=t,this.color=e,this.textFillSpotColor=a}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new G;const a={...e,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor,textFillImage:void 0},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class _e extends O{constructor(t,e){super(),this.id=t,this.imageFill=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new G;const a={...e,textFillImage:this.imageFill},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class cr extends O{constructor(t,e){super(),this.id=t,this.size=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new G;const a={...e,fontSize:this.size},n=_(e.id,Object.values(t.layouts)),i=(!e.algorithm||e.algorithm===Bt.Autosize?e.text:e.input)??"",s=X(de(a,i),n);return{...t,layouts:{...t.layouts,[n.layout.id]:s}}}}class ga extends O{constructor(t,e){super(),this.id=t,this.fontData=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new G;const a={...e,fontData:this.fontData},n=_(e.id,Object.values(t.layouts)),i=(!e.algorithm||e.algorithm===Bt.Autosize?e.text:e.input)??"",s=X(de(a,i),n);return{...t,layouts:{...t.layouts,[n.layout.id]:s}}}}class dr extends O{constructor(t,e){super(),this.id=t,this.align=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new G;const a={...e,align:this.align},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class fo extends O{constructor(t,e,a){super(),this.id=t,this.imageData=e,this.offsets=a}apply(t){this.oldState=t;const e=_(this.id,Object.values(t.layouts)),a=e.elements.findIndex(o=>o.id===this.id),n=e.elements[a].pattern,i=[...e.elements];i.splice(a,1,{...e.elements[a],pattern:{...n,src:this.imageData.src,x:this.offsets.x,y:this.offsets.y,width:this.imageData.width,height:this.imageData.height,scaleX:this.offsets.zoom,scaleY:this.offsets.zoom,svg:this.imageData.svg,colors:this.imageData.colors}});const s={...e,elements:i,modificationID:Q()};return{...t,layouts:{...t.layouts,[e.layout.id]:s}}}}class Co extends O{constructor(t,e,a,n,i){super(),this.id=t,this.useThreshold=e,this.invertThreshold=a,this.threshold=n,this.thresholdSaturation=i}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new G;const a={...e,useThreshold:this.useThreshold,invertThreshold:this.invertThreshold,threshold:this.threshold,thresholdSaturation:this.thresholdSaturation},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class wo extends O{constructor(t,e){super(),this.id=t,this.src=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new G;const a={...e,src:this.src},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class Ar extends O{constructor(t,e){super(),this.id=t,this.text=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new G;const a=_(e.id,Object.values(t.layouts)),n=X(de(e,this.text,e),a);return{...t,layouts:{...t.layouts,[a.layout.id]:n}}}}class Xe extends O{constructor(t,e,a){super(),this.id=t,this.strokeColor=e,this.strokeThickness=a}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new G;const a={...e,strokeColor:this.strokeColor,strokeThickness:this.strokeThickness},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class ma extends O{constructor(t,e,a){super(),this.id=t,this.className=e,this.fill=a}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new G;const a=e.colors||{},n=a[this.className];typeof this.fill=="string"?a[this.className]={browserValue:this.fill,spotColor:n==null?void 0:n.spotColor,pmsValue:n==null?void 0:n.pmsValue}:a[this.className]={browserValue:this.fill.browserValue,spotColor:n==null?void 0:n.spotColor,pmsValue:this.fill.pmsValue};const i={...e,colors:a},s=_(e.id,Object.values(t.layouts)),o=X(i,s);return{...t,layouts:{...t.layouts,[s.layout.id]:o}}}}class yo extends O{constructor(t,e,a){super(),this.id=t,this.svgBody=e,this.objectURL=a}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new G;const a={...e,svg:this.svgBody,cachedObjectURL:this.objectURL},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class So extends O{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!L(this.id,Object.values(t.layouts)).id)throw new G;const a=Object.values(t.layouts).find(s=>s.elements.find(o=>o.id===this.id));if(!a)throw new Error("Layout missing from state!");const n=a.elements.findIndex(s=>s.id===this.id);a.elements.push(a.elements.splice(n,1)[0]);const i=[...a.elements];return i.forEach((s,o)=>s.layerIndex=o),{...t,layouts:{...t.layouts,[a.layout.id]:{...t.layouts[a.layout.id],elements:i,modificationID:Q()}}}}}class vo extends O{constructor(t){super(),this.id=t}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new G;const a=Object.values(t.layouts).find(o=>o.elements.find(l=>l.id===this.id));if(!a)throw new Error("Layout missing from state!");const n=a.elements.findIndex(o=>o.id===this.id);a.elements.splice(n,1),a.elements.unshift(e);const i=[...a.elements],s=i.splice(n,1)[0];return i.splice(n,0,s),i.forEach((o,l)=>o.layerIndex=l),{...t,layouts:{...t.layouts,[a.layout.id]:{...t.layouts[a.layout.id],elements:i,modificationID:Q()}}}}}class Eo extends O{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!L(this.id,Object.values(t.layouts)).id)throw new G;const a=Object.values(t.layouts).find(l=>l.elements.find(c=>c.id===this.id));if(!a)throw new Error("Layout missing from state!");const n=a.elements.findIndex(l=>l.id===this.id),i=n+1,s=[...a.elements],o=s.splice(n,1)[0];return s.splice(i,0,o),s.forEach((l,c)=>l.layerIndex=c),{...t,layouts:{...t.layouts,[a.layout.id]:{...t.layouts[a.layout.id],elements:s,modificationID:Q()}}}}}class bo extends O{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!L(this.id,Object.values(t.layouts)).id)throw new G;const a=Object.values(t.layouts).find(l=>l.elements.find(c=>c.id===this.id));if(!a)throw new Error("Layout missing from state!");const n=a.elements.findIndex(l=>l.id===this.id),i=n-1,s=[...a.elements],o=s.splice(n,1)[0];return s.splice(i,0,o),s.forEach((l,c)=>l.layerIndex=c),{...t,layouts:{...t.layouts,[a.layout.id]:{...t.layouts[a.layout.id],elements:s,modificationID:Q()}}}}}class ln{constructor(t,e,a){this.processRegion=async n=>{var l,c,d,A;const i=this.layouts.find(u=>u.panelId===n.panelId);if(!i)throw new Y(n);let s="";if(this.configuration.type===I.ProductOverlay){let u="";if((l=this.product)!=null&&l.overlayImageUrl&&(u=this.product.overlayImageUrl),s=u,!u)throw new ee(this.configuration,"Couldn't find an asset for product overlay step")}const o=this.evaluateAssetType();if(o===k.Image){const u=this.configuration.type===I.SilentIllustration?(c=this.configuration.data.asset)==null?void 0:c.fileLink:(d=this.product)==null?void 0:d.overlayImageUrl;if(!u)throw new Error("Undefined raster silent step source");const h={stepName:this.configuration.stepName,id:Q(),src:u,type:o,y:n.top,x:n.left,width:n.width,height:n.height,layer:n.layer,layerIndex:n.layerIndex,immutable:n.immutable,productOverlay:this.configuration.type===I.ProductOverlay?!0:void 0,rotation:n.rotation,excludeFromExport:this.configuration.data.excludeFromPrint,preserveAspectRatio:"none"};return{regionElement:{id:h.id,region:n},command:new q(h,i)}}else{const u=this.configuration.type===I.SilentIllustration?(A=this.configuration.data.asset)==null?void 0:A.fileLink:s,g=await ot(await(async()=>new Promise((p,f)=>{if(!u){f("Undefined vector silent step source");return}et(u,!0).then(C=>{p(C)}).catch(C=>console.error(C))}))()),m={stepName:this.configuration.stepName,id:Q(),cachedObjectURL:await re(g.svg),src:u,svg:g.svg,colors:g.colors,type:o,y:n.top,x:n.left,width:n.width,height:n.height,layer:n.layer,layerIndex:n.layerIndex,rotation:n.rotation,immutable:n.immutable,productOverlay:this.configuration.type===I.ProductOverlay?!0:void 0,excludeFromExport:this.configuration.data.excludeFromPrint};return{regionElement:{id:m.id,region:n},command:new q(m,i)}}},this.configuration=t,this.layouts=e,this.product=a||void 0}async trigger(){if(!this.configuration.data.regions)throw new ee(this.configuration,"Missing regions.");if(this.configuration.type===I.SilentIllustration){const t=this.configuration.data.regions.map(this.processRegion);return Promise.all(t)}else return this.configuration.type===I.ProductOverlay?Promise.all(this.configuration.data.regions.map(t=>{if(!this.layouts.find(a=>t.panelId===a.panelId))throw new Y(t);return this.processRegion(t)})):Promise.reject("Unknown silent step. This is a bug")}evaluateAssetType(){var e,a,n;const t=this.configuration.type===I.ProductOverlay&&((e=this.product)!=null&&e.overlayImageUrl)?this.product.overlayImageUrl.toLowerCase():(n=(a=this.configuration.data.asset)==null?void 0:a.fileLink)==null?void 0:n.toLowerCase().split("?")[0];return t!=null&&t.startsWith("data:image/png")||t!=null&&t.endsWith(".jpeg")||t!=null&&t.endsWith(".jpg")||t!=null&&t.endsWith(".png")?k.Image:(t!=null&&t.endsWith(".svg")||t!=null&&t.startsWith("image/svg+xml"),k.Illustration)}}const ur=async r=>{const t=`${At.getServicesApiUrl()}/shortener`;try{return(await(await st(t,{method:"POST",body:JSON.stringify({longUrl:r}),headers:{"Content-Type":"application/json"}})).json()).shortUrl}catch(e){throw console.error(e),new Ne("Failed to shorten URL, see console.")}};class hr{async poll(){try{if(await this.predicate()){this.onSuccess(),this.pollingId>-1&&window.clearInterval(this.pollingId);return}}catch{}this.attempts+=1,this.attempts<this.maxAttempts?this.pollingId=window.setTimeout(this.poll.bind(this),this.interval):this.onFailure()}constructor(t,e,a,n=3e3,i=10){this.onSuccess=e,this.onFailure=a,this.predicate=t,this.attempts=0,this.pollingId=-1,this.interval=n,this.maxAttempts=i,this.poll()}}class Bo{async init(t,e,a){return a&&await this.reload(t,e,a),null}async reload(t,e,a){const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),l=Object.values(a.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName).map(c=>({id:c.id,region:c.stepRegion}));await e.setSelectionsAndElements(t.stepName,[],l,async()=>{var A,u;const c=(A=n==null?void 0:n.storage)==null?void 0:A.videoShortUrl,d=(u=n==null?void 0:n.storage)==null?void 0:u.videoUrl;e.updateStorage(t.stepName,{videoShortUrl:c,videoUrl:d})})}async regenerateQRCode(t,e,a,n){const i=async()=>{var m,p;const h=(await Ie([e]))[0],g=(p=(m=h==null?void 0:h.versions)==null?void 0:m.find(f=>f.name==="mpeg4"))==null?void 0:p.link;return{asset:h,link:g}},s=await new Promise((h,g)=>{new hr(async()=>!!(await i()).link,async()=>{const m=await i();if(!m.link||!m.link)throw new Nt(m.asset);h({rel:"mpeg4",href:m.link})},()=>{g("Poller timed out with 40 attempts @ 3 second interval")},3e3,40)});t.forEach(h=>a.getCommandDispatcher()(new Ct(h.id)));const o=n.data.baseUrl.slice(0,4)==="http"?"":"https://",l=new URL(o+n.data.baseUrl);l.searchParams.append("video",btoa(JSON.stringify([s]))),l.pathname=l.pathname+(l.pathname.slice(-1)==="/"?"":"/");const c=l.toString();if(c.length>=2e3)throw new Ne("Cannot create QR code, URL too long.");const d=await ur(c);if(!n.data||!n.data.regions)throw new ee(n,"Missing regions.");const A=await this.regionElements(n),u=await this.command(d,A,a,n.stepName);return u&&(u.command&&a.getCommandDispatcher()(u.command),u.followup&&await u.followup()),await a.setSelectionsAndElements(n.stepName,[],A,async()=>{a.updateStorage(n.stepName,{videoShortUrl:d,videoUrl:s.href})}),d}async regionElements(t){const e=a=>({id:Q(),region:a});return t.data.regions.map(e)}async command(t,e,a,n){const i=a.getLayouts(),o=`data:image/svg+xml;base64,${btoa(await Sn.toString(t,{type:"svg"}))}`,l=e.map(c=>{const d=c.region,A=i.find(u=>u.panelId===(d==null?void 0:d.panelId));if(!A&&d)throw new Y(d);if(A&&!d)throw new Error("Region not found");if(!A||!d)throw new Error("Neither a region or layout found!");return new q({stepRegion:d,stepName:n,id:c.id,src:o,type:k.Image,y:d.top,x:d.left,width:d.width,height:d.height,rotation:0},A)});return{command:new $(l),followup:async()=>{}}}}const Qa=new Bo;class xe{constructor(){this.frameSourceSvg=async(t,e)=>{if(!t)return ua(e);const a=t.asset;if(!a)throw new mt(t);const n=a.fileLink;if(n)return et(n,!0);throw new Nt(a)}}async init(t,e,a){const n=a==null?void 0:a.serializableWorkflow.steps.find(o=>o.stepName===t.stepName);if(n!=null&&n.storage&&Object.keys(n.storage).length!==0||n!=null&&n.selectedVariants&&n.selectedVariants.length!==0)return await this.reload(t,e,a),null;t.mandatory&&e.setMandatoryFulfilled(t.stepName,!1),e.markStepsAsInitialised([t.stepName]);let i;const s=e.getWorkflowExperience().getBundle();if(s&&t.globalPropertyAspectConfigurations){const o=s.getGlobalPropertyStateManager(),l=t.globalPropertyAspectConfigurations[0],c=o.getAspectStorage(l.aspectName);c&&c.originalAssetKey&&(i=(await U.getLocalOrFromServer(c.originalAssetKey)).fileLink)}if(t.option&&t.option.variants&&t.option.variants.length>0){const o=t.option,l=H.getDefaultVariant(o);return l?this.selectVariantCommand(t,l,[],e,void 0,i||t.data.placeholderImageUrl):null}return this.selectVariantCommand(t,void 0,[],e,void 0,i||t.data.placeholderImageUrl)}async reload(t,e,a){var c;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),l=Object.values(a.layouts).map(d=>d.elements).flat().filter(d=>d.stepName===t.stepName).map(d=>({id:d.id,region:d.stepRegion}));if(!t.option||(t.option.variants||[]).length===0){const d=t.data.regions.map(A=>ua(A));e.updateStorage(t.stepName,{currentFrameSources:d})}if(n){const d=async()=>{var g,m,p,f,C;const A=(g=n.storage)==null?void 0:g.colors,u=(m=n.storage)==null?void 0:m.framePatternSrc,h=(p=n.storage)==null?void 0:p.frameOffsetsList;if(e.updateMetadata(t.stepName,{frameOffsetsList:h,framePatternSrc:u}),u){const w=(f=e.getWorkflowExperience().getStepById(t.stepName))==null?void 0:f.frameService;if(!w)throw new Error("Frame service unavailable, cannot load pattern!");await this.loadPatternFromString(u,w,!0,A),e.updateMetadata(t.stepName,{image:u}),e.updateStorage(t.stepName,{framePatternSrc:u}),this.validateColorCount(t,e)}if(h!=null&&h.some(w=>w.zoom)){const w=(C=e.getWorkflowExperience().getStepById(t.stepName))==null?void 0:C.frameService;if(!w)throw new Error("Frame service unavailable, cannot load pattern!");w.updateOffsets(h)}e.setMandatoryFulfilled(t.stepName,!0)};if(n.selectedVariants&&n.selectedVariants.length>0){const A=n.selectedVariants[0].id;if(t.option&&A){const u=(c=t.option.variants)==null?void 0:c.find(h=>h.id===A);u&&await e.setSelectionsAndElements(t.stepName,[u],l,async()=>{const h=await Promise.all(t.data.regions.map(g=>this.frameSourceSvg(u,g)));e.updateStorage(t.stepName,{currentFrameSources:h}),await d()})}}else await e.setSelectionsAndElements(t.stepName,[],l,d)}}async availableColors(t,e){var n;const a=t.data.colorOption;return((n=a==null?void 0:a.variants)==null?void 0:n.map(i=>({fill:i.color,stroke:i.color,variant:i,pmsValue:i.name})))??[]}selectImage(t,e,a,n=!0){var l;const i=xe.patternSource(e),s=(l=a.getStepStorage(t.stepName))==null?void 0:l.framePatternSrc;if(s&&s===i)return Promise.resolve();a.setEditedStatus(t.stepName,!0);const o=e.fileLink||"";return o.endsWith(".pdf")||o.endsWith(".eps")||o.endsWith(".ai")?new Promise(c=>{a.addPoller(new hr(async()=>{var h;const A=(h=(await U.getFromServer(e.key||"")).versions)==null?void 0:h.find(g=>g.name==="svg");return A?(await st(A.link)).status===200:!1},()=>{U.getLocalOrFromServer(e.key||"").then(d=>{this.loadPatternFromAsset(d,t,a,n).then(c)})},()=>{throw new Ne("Failed to resolve transcoded PDF")}))}):this.loadPatternFromAsset(e,t,a,n)}async selectVariant(t,e,a,n,i){const s=await this.selectVariantCommand(t,e,a,n,i);s&&(s.command&&n.getCommandDispatcher()(s.command),s.followup&&await s.followup())}getCreateElementCommand(t,e,a,n){return new q({id:t,type:k.Frame,x:e.left,y:e.top,width:e.width,height:e.height,layer:e.layer,layerIndex:e.layerIndex,rotation:e.rotation,scaleX:e.width/n.frameData.width,scaleY:e.height/n.frameData.height,path:n.frameData.path,dataWidth:n.frameData.width,dataHeight:n.frameData.height,stepRegion:e,stepName:n.stepName,disablePlaceholder:n.disablePlaceholder,pattern:n.pattern,immutable:e.immutable},a)}async loadPatternFromString(t,e,a=!0,n=void 0,i){if(t.endsWith("svg")){const s=await Ma(t),o=s.width,l=s.height,c=await et(t);if(i){const u=c.match(/<(image|linearGradient|radialGradient)(\s|>|\/>)/gim);if(u&&u.length>0)throw new Error("Vector files may not include images or gradients when a color limit is specified.")}const d=await ot(c),A={src:t,width:o,height:l,aspect:o/l,svg:d.svg,colors:n??d.colors};dt.set(t,A),e.setPatternData(A,a)}else{const s=await Qe(t,!0),o=await le(s),l={src:t,width:o.width,height:o.height,aspect:o.width/o.height,svg:void 0,colors:void 0};dt.set(t,l),e.setPatternData(l,a)}}changeColors(t,e,a){var s,o;const n=(s=e.getWorkflowExperience().getStepById(t.stepName))==null?void 0:s.frameService;if(!n||!((o=n.getImageData())!=null&&o.svg)){console.warn("changeColors was called without an SVG being assigned to a frame step");return}const i=this.calculateColorMetadata(n,t,a);e.updateMetadata(t.stepName,{colors:i.metadataColors}),e.updateStorage(t.stepName,{colors:i.storageColors}),n.setPatternData({...n.getImageData(),colors:i.newColors},!1),this.validateColorCount(t,e)}getUniqueColorCount(t,e){var s,o;const a=(s=e.getWorkflowExperience().getStepById(t.stepName))==null?void 0:s.frameService;if(!a)return 0;const n=((o=a.getImageData())==null?void 0:o.colors)??{},i=[];for(const l in n){const c=n[l];if(c.pmsValue){const d=c.pmsValue.trim().toLocaleLowerCase();i.includes(d)||i.push(d)}else if(c.browserValue){const d=Un(c.browserValue);i.includes(d)||i.push(d)}}return i.length}calculateColorMetadata(t,e,a){var l,c;if(!((l=t.getImageData())!=null&&l.svg))return{newColors:void 0,metadataColors:void 0,storageColors:void 0};const n={...t.getImageData().colors??{}},i={};Object.entries(n).forEach(([d,A])=>{const u={browserValue:A.browserValue};i[d]=u});for(const[d,A]of a.entries())n[d]={browserValue:A.browserValue,pmsValue:A.pmsValue},i[d]=A;let s=Array.from(Object.values(n)).map(d=>d.browserValue);const o=e.data.colorOption;return o&&((c=o.variants)==null||c.forEach(d=>{s=s.map(A=>{var u;return A.toLowerCase()===((u=d.color)==null?void 0:u.toLowerCase())?d.name:A})})),{newColors:n,metadataColors:s,storageColors:i}}validateColorCount(t,e){const a=t.data.colorPickerEnabled?t.data.maxColors??0:0;e.setStepError(t.stepName,"colors",a>0&&this.getUniqueColorCount(t,e)>a?"workflow.steps.frame.tooManyColors":void 0)}async selectVariantCommand(t,e,a,n,i,s){var h;const o=(h=n.getWorkflowExperience().getStepById(t.stepName))==null?void 0:h.frameService;if(!o)throw new Error("Frame service unavailable, cannot load pattern!");const l=await Promise.all(t.data.regions.map(g=>this.frameSourceSvg(e,g)));i&&i(!0);const c=t.data.initialZoomLevel,d=await Promise.all(t.data.regions.map(async(g,m)=>{const p=await ue(l[m]),f=o.getImageData(),C=a.map(P=>new Ct(P.id)),w=f?ka(f,p,c&&!t.data.forceImageCover?{scale:c}:void 0,t.data.forceImageCover):void 0,S=f?{id:Q(),src:f.src,x:(w==null?void 0:w.x)||0,y:(w==null?void 0:w.y)||0,width:f.width,height:f.height,scaleX:(w==null?void 0:w.zoom)||1,scaleY:(w==null?void 0:w.zoom)||1,rotation:0}:void 0,y=Q(),b=n.getLayouts().find(P=>P.panelId===g.panelId);if(!b)throw new Y(g);return{command:this.getCreateElementCommand(y,g,b,{frameData:p,pattern:S,disablePlaceholder:t.data.disablePlaceholder,stepName:t.stepName}),regionEl:{id:y,region:g},removeExistingCommands:C}})),A=d.map(g=>g.command),u=d.map(g=>g.removeExistingCommands).flat();return{command:new $([...A,...u]),followup:async()=>{i&&i(!1),await n.setSelectionsAndElements(t.stepName,e?[e]:[],[...d.map(g=>g.regionEl)],async()=>{var g;if(n.updateStorage(t.stepName,{currentFrameSources:l}),s){const m=(g=n.getWorkflowExperience().getStepById(t.stepName))==null?void 0:g.frameService;if(!m)throw new Error("Frame service unavailable, cannot load pattern!");await this.loadPatternFromString(s,m,!0)}})}}}static patternSource(t){var n;const e=(n=t.versions)==null?void 0:n.find(i=>i.name==="svg");if(e!=null&&e.link)return e.link;const a=t.fileLink;if(a)return a;throw new Nt(t)}async loadPatternFromAsset(t,e,a,n){var c,d;const i=xe.patternSource(t),s=a.markUpdatePending(),o=(c=a.getWorkflowExperience().getStepById(e.stepName))==null?void 0:c.frameService;if(!o)throw a.markUpdateCompleted(s),new Error("Frame service unavailable, cannot load pattern!");try{await this.loadPatternFromString(i,o,n,void 0,e.data.colorPickerEnabled&&!!e.data.maxColors&&e.data.maxColors>0)}catch(A){throw a.markUpdateCompleted(s),A}const l=this.calculateColorMetadata(o,e,new Map(Object.entries(((d=o.getImageData())==null?void 0:d.colors)??{})));a.updateMetadata(e.stepName,{image:i,colors:l.metadataColors}),a.updateStorage(e.stepName,{framePatternSrc:i,colors:l.storageColors}),a.markUpdateCompleted(s),a.setMandatoryFulfilled(e.stepName,!0),a.setInformationResults(a.getInformationResults().filter(A=>A.stepID===e.stepName)),this.validateColorCount(e,a)}}const ut=new xe;class Io{async getIllustrationBody(t){return new Promise(e=>{et(t,!0).then(a=>{e(a)}).catch(a=>console.error(a))})}getCreateElementCommand(t,e,a,n){return new q({stepRegion:e,stepName:n.stepName,colors:n.svg.colors,id:t,src:n.src,svg:n.svg.svg,cachedObjectURL:n.objectURL,type:k.Illustration,y:e.top,x:e.left,rotation:e.rotation,width:e.width,height:e.height,layer:e.layer,layerIndex:e.layerIndex,immutable:e.immutable},a)}getColors(t,e){const a=e.getRegionElements(t.stepName)||[];if(a.length===0)return[];try{return L(a[0].id,e.getAllLayoutData()).colors}catch{return[]}}async init(t,e,a){const n=t.option;if(!n)return null;if(a)return this.reload(t,e,a);{const i=H.getDefaultVariant(n);if(i)return await this.selectVariantCommand(t,i,[],()=>{},e)}return null}async reload(t,e,a){var c;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),o=Object.values(a.layouts).map(d=>d.elements).flat().filter(d=>d.stepName===t.stepName),l=t.option;if(n!=null&&n.selectedVariants){const d=n.selectedVariants[0].id;if(l&&d){const A=(c=l.variants)==null?void 0:c.find(u=>u.id===d);if(A){const u=o.map(h=>({id:h.id,region:h.stepRegion}));await e.setSelectionsAndElements(t.stepName,[A],u,async()=>{var h;e.updateMetadata(t.stepName,{colors:(h=n.storage)==null?void 0:h.colors}),e.setMandatoryFulfilled(t.stepName,!0)})}}else throw new Error("Required illustration variant no longer available")}return null}async availableColors(t,e){var n;const a=t.data.colorOption;return a?a?(n=a.variants)==null?void 0:n.map(i=>({fill:i.color,stroke:i.color,variant:i,pmsValue:i.name})):[]:[]}async changeColorsCommand(t,e,a,n,i){const s={};for(const[d,A]of i.entries())typeof A=="string"?s[d]={browserValue:A,spotColor:void 0,pmsValue:void 0}:s[d]={browserValue:A.browserValue,spotColor:A.spotColor,pmsValue:A.pmsValue};const o=Ba(t,e,a,s),l=await re(o),c=[];for(const d of n){for(const[A,u]of i.entries())c.push(new ma(d,A,u));c.push(new yo(d,o,l))}return new $(c)}async changeColors(t,e,a,n,i){var h,g;if(e.length===0)return;const s=L(e[0].id,n().map(m=>m.layoutState)),o={...s.colors},l={};Object.entries(o).forEach(([m,p])=>{const f={browserValue:p.browserValue,pmsValue:p.pmsValue},C=p.spotColor;C&&(f.spotColor={profileName:C.profileName,namedColor:C.namedColor}),l[m]=f});for(const[m,p]of i.entries()){const f=typeof p=="string"?p:p.browserValue,C=typeof p=="string"?void 0:p.pmsValue;o[m]={browserValue:f,spotColor:(h=o[m])==null?void 0:h.spotColor,pmsValue:C},l[m]={browserValue:f}}let c=Array.from(Object.values(o)).map(m=>m.browserValue);const d=t.data.colorOption;d&&((g=d.variants)==null||g.forEach(m=>{c=c.map(p=>{var f;return p.toLowerCase()===((f=m.color)==null?void 0:f.toLowerCase())?m.name:p})})),a.updateMetadata(t.stepName,{colors:c});const A=new Map;if(Object.entries(o).forEach(([m,p])=>{A.set(m,p)}),!s.svg)throw new Error("Colors changed before SVG loaded. This should never happen!");const u=await this.changeColorsCommand(s.svg,s.width,s.height,e.map(m=>m.id),A);a.updateStorage(t.stepName,{colors:l}),a.getCommandDispatcher()(u)}async selectVariant(t,e,a,n,i){const s=await this.selectVariantCommand(t,e,a,n,i);s&&(s.command&&i.getCommandDispatcher()(s.command),s.followup&&await s.followup())}async selectVariantCommand(t,e,a,n,i){var f;if(!t.data||!t.data.regions)throw new ee(t,"Missing regions.");n(!0);const s=a.map(C=>new Ct(C.id));t.mandatory&&i.setMandatoryFulfilled(t.stepName,!1);const o=e.asset;if(!o)throw new mt(e);const l=o.fileLink;if(!l)throw new Nt(o);const c=await ot(await this.getIllustrationBody(l)),d=await re(c.svg),A=C=>{const w=i.getLayouts().find(y=>y.panelId===C.panelId);if(!w)throw new Y(C);const S=Q();return{regionElement:{id:S,region:C},command:this.getCreateElementCommand(S,C,w,{stepName:t.stepName,src:l,objectURL:d,svg:c})}},u=t.data.regions.map(A),g=[...u.map(C=>C.command),...s];let m=Array.from(Object.values(c.colors)).map(C=>C.browserValue);const p=t.data.colorOption;return p&&((f=p.variants)==null||f.forEach(C=>{m=m.map(w=>{var S;return w.toLowerCase()===((S=C.color)==null?void 0:S.toLowerCase())?C.name:w})})),i.updateMetadata(t.stepName,{colors:m}),{command:new $(g),followup:async()=>{var w,S;await i.setSelectionsAndElements(t.stepName,[e],u.map(y=>y.regionElement),async()=>{i.setMandatoryFulfilled(t.stepName,!0),n(!1)});const C=((w=o.assetConfiguration)==null?void 0:w.defaultColorVariants)||[];if(C.length!==0){const y={};(((S=o.assetConfiguration)==null?void 0:S.channelNumbers)||[]).forEach(b=>{var x;const P=C.find(F=>F.channelNumber===b.number);P&&(y[`${b.id.replace(/\W/g,"")}`]={browserValue:((x=P==null?void 0:P.variant)==null?void 0:x.color)||""})}),await this.changeColors(t,u.map(b=>b.regionElement),i,()=>i.getCommandContext().getAllLayouts(),new Map(Object.entries(y)))}if(t.data.colorPickerEnabled){const y=await this.availableColors(t,i)||[],E=Object.keys(c.colors),b=y.length===1&&E.length===1;if(b){const P=y[0],x=E[0];await this.changeColors(t,u.map(F=>F.regionElement),i,()=>i.getCommandContext().getAllLayouts(),new Map([[x,P.variant.color]]))}!b&&C.length===0&&await this.changeColors(t,u.map(P=>P.regionElement),i,()=>i.getCommandContext().getAllLayouts(),new Map)}}}}}const Jt=new Io;class Po{async init(t,e,a){const n=t.option;if(!n)throw new te(t);if(a)await this.reload(t,e,a);else{const i=H.getDefaultVariant(n);if(i)return await this.selectVariantLambda(t,i,e,()=>{})}return null}async reload(t,e,a){var c;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),o=Object.values(a.layouts).map(d=>d.elements).flat().filter(d=>d.stepName===t.stepName),l=t.option;if(!l)throw new te(t);if(n!=null&&n.selectedVariants){const d=n.selectedVariants[0].id;if(d){const A=(c=l.variants)==null?void 0:c.find(u=>u.id===d);if(A){const u=A.material,h=o.map(g=>({id:g.id,region:g.stepRegion}));await e.setSelectionsAndElements(t.stepName,[A],h,async()=>{const g=e.getModelContainer();if(g){const m=t.data.targetMaterials.map(p=>g.applyMaterialVariant(p,l.id||"",u||{}));Promise.all(m).then(()=>e.setMandatoryFulfilled(t.stepName,!0))}})}}}}async selectVariant(t,e,a,n){const i=await this.selectVariantLambda(t,e,a,n);i&&(i.command&&a.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async selectVariantLambda(t,e,a,n){const i=a.getModelContainer();n(!0);const s=e.material;if(!s)throw n(!1),new mt(e);return{command:void 0,followup:async()=>{await a.setSelectionsAndElements(t.stepName,[e],[],async()=>{try{i&&t.data.targetMaterials.forEach(o=>{t.option&&i.applyMaterialVariant(o,t.option.id||"",s)}),a.setMandatoryFulfilled(t.stepName,!0)}finally{n(!1)}})}}}}const Ra=new Po;class Do{async init(t,e,a){const n=t.option;if(!n)throw new te(t);if(a)await this.reload(t,e,a);else{const i=H.getDefaultVariant(n);if(i)return await this.selectVariantLambda(t,i,e,()=>{})}return null}async reload(t,e,a){var c;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),o=Object.values(a.layouts).map(d=>d.elements).flat().filter(d=>d.stepName===t.stepName),l=t.option;if(n!=null&&n.selectedVariants){const d=n.selectedVariants[0].id;if(l&&d){const A=(c=l.variants)==null?void 0:c.find(u=>u.id===d);if(A){const u=o.map(h=>({id:h.id,region:h.stepRegion}));await e.setSelectionsAndElements(t.stepName,[A],u,async()=>{var g;const h=e.getModelContainer();if(h&&t.option){const m=(g=A.asset)==null?void 0:g.fileLink;if(!m)throw new mt(A);await h.applyModelVariant(t.stepName||"",{model:m,contextService:e.getLayoutPreviewService()},t.data.replaceProductModel||!1),e.setMandatoryFulfilled(t.stepName,!0)}})}}}}async selectVariant(t,e,a,n){const i=await this.selectVariantLambda(t,e,a,n);i&&(i.command&&a.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async selectVariantLambda(t,e,a,n){var s;n(!0);const i=(s=e.asset)==null?void 0:s.fileLink;if(!i)throw new mt(e);return{command:void 0,followup:async()=>{await a.setSelectionsAndElements(t.stepName,[e],[],async()=>{try{const o=a.getModelContainer();o&&await o.applyModelVariant(t.stepName,{model:i,contextService:a.getLayoutPreviewService()},t.data.replaceProductModel||!1),a.setMandatoryFulfilled(t.stepName,!0)}finally{n(!1)}})}}}}const Oa=new Do;class xo{async init(t,e,a){if(a)await this.reload(t,e,a);else return e.updateMetadata(t.stepName,{text:""}),this.changeTextCommand(t,"",e,()=>{});return null}async reload(t,e,a){const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),l=Object.values(a.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName).map(c=>({id:c.id,region:c.stepRegion}));await e.setSelectionsAndElements(t.stepName,[],l,async()=>{var c,d;e.updateStorage(t.stepName,{text:(c=n==null?void 0:n.storage)==null?void 0:c.text}),e.setMandatoryFulfilled(t.stepName,((d=n==null?void 0:n.storage)==null?void 0:d.text)!=="")})}async changeText(t,e,a,n){const i=await this.changeTextCommand(t,e,a,n);i&&(i.command&&a.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async changeTextCommand(t,e,a,n){var d;const i=a.getRegionElements(t.stepName),s=(d=a.getStepSpecificServices(t.stepName))==null?void 0:d.module;if(!s)return console.error("Missing module."),null;const o=a.getProfanities(),l=this.validateInput(t,e,o,n);if(l.errorData)return a.setMandatoryFulfilled(t.stepName,!1),l.errorData.blockedProfanity?console.error("Blocked profanity."):l.errorData.hitCharacterLimit?console.error("Too many characters."):l.errorData.unsupportedCharacters&&console.error("Unsupported characters."),null;if(a.setMandatoryFulfilled(t.stepName,e!==""),!t.data||!t.data.regions||t.data.regions.length<=0)return console.error("Missing configuration."),null;a.updateStorage(t.stepName,{text:e}),a.updateMetadata(t.stepName,{text:e});const c=(A,u,h)=>{const g=h||Q(),p=a.getLayouts().find(C=>C.panelId===u.panelId);if(!p)return console.error(`Can not find layout for region: ${u.panelId}`),null;const f=[];return h&&f.push(new Ct(g)),f.push(new q({stepRegion:u,stepName:t.stepName,colors:{},id:g,svg:A,type:k.Illustration,y:u.top,x:u.left,rotation:u.rotation,width:u.width,height:u.height,layer:u.layer,layerIndex:u.layerIndex,immutable:u.immutable},p)),{id:g,region:u,command:new $(f)}};if(i.length>0){const u=i.map(h=>{if(!h.region)return null;const g=s.svgPrint(e,h.region);return c(g,h.region,h.id)}).filter(h=>!!h).filter(h=>!!h).map(h=>h&&h.command);return{command:new $(u),followup:async()=>{}}}else{const A=t.data.regions.map(h=>c(s.svgPrint(e,h),h)),u=A.filter(h=>!!h).map(h=>h&&h.command);return{command:new $(u),followup:async()=>{const h=A.filter(g=>g).map(g=>g&&{id:g.id,region:g.region});await a.setSelectionsAndElements(t.stepName,[],h)}}}}validateInput(t,e,a,n){if(t.data&&t.data.maxLength){const s=t.data.maxLength;if(e.length>s)return n("Too many characters."),{input:e,helperData:{},errorData:{hitCharacterLimit:!0}}}if(!/^$|^[a-zA-Z0-9 ]+$/.test(e))return n("Unsupported characters."),{input:e,helperData:{},errorData:{unsupportedCharacters:!0}};const i=ia.split(e.toLowerCase());for(const s of i)for(const o in a){const l=a[o].toLowerCase().replace(/\s/g,"");if(s===l)return n("Blocked profanity."),{input:e,helperData:{},errorData:{blockedProfanity:!0}}}return n(""),{input:e,helperData:{}}}}const $a=new xo;class Fo{async init(t,e,a){const n=t.option;if(!n)return null;if(a)await this.reload(t,e,a);else if(n.defaultVariant)return e.markStepsAsInitialised([t.stepName]),this.selectVariantCommand(t,n.defaultVariant,e,()=>{});return e.markStepsAsInitialised([t.stepName]),null}async reload(t,e,a){var c;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),o=Object.values(a.layouts).map(d=>d.elements).flat().filter(d=>d.stepName===t.stepName),l=t.option;if(n!=null&&n.selectedVariants){const d=n.selectedVariants[0].id;if(l&&d){const A=(c=l.variants)==null?void 0:c.find(u=>u.id===d);if(A){const u=o.map(h=>({id:h.id,region:h.stepRegion}));await e.setSelectionsAndElements(t.stepName,[A],u,async()=>{e.setMandatoryFulfilled(t.stepName,!0)})}}}}async selectVariant(t,e,a,n){const i=await this.selectVariantCommand(t,e,a,n);i&&(i.command&&a.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async selectVariantCommand(t,e,a,n){const i=e.asset;if(!i)throw new mt(e);const s=i==null?void 0:i.fileLink;if(!s)return console.error("No URL for picture!"),null;n(!0),t.mandatory&&a.setMandatoryFulfilled(t.stepName,!1);const l=a.getRegionElements(t.stepName).map(A=>new Ct(A.id)),c=A=>{const h=a.getLayouts().find(m=>m.panelId===A.panelId);if(!h)throw new Y(A);const g=Q();return{regionElement:{id:g,region:A},command:new q({stepName:t.stepName,stepRegion:A,id:g,src:s,type:k.Image,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer,layerIndex:A.layerIndex,immutable:A.immutable,preserveAspectRatio:"none"},h)}},d=t.data.regions.map(c);return{command:new $([...l,...d.map(A=>A.command)]),followup:async()=>{await a.setSelectionsAndElements(t.stepName,[e],d.map(A=>A.regionElement),async()=>{a.setMandatoryFulfilled(t.stepName,!0),n(!1)})}}}}const Ua=new Fo;class ko{async init(t,e,a){const n=t.option;if(!n)return null;if(a)await this.reload(t,e,a);else{const i=n.variants;if(H.getDefaultVariant(n)){const o=i==null?void 0:i.find(l=>{var c;return l.id===((c=n.defaultVariant)==null?void 0:c.id)});return this.selectVariantLambda(t,(o==null?void 0:o.id)||"",e)}}return null}async reload(t,e,a){var s;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),i=t.option;if(n!=null&&n.selectedVariants){const o=n.selectedVariants[0].id;if(i&&o){const l=(s=i.variants)==null?void 0:s.find(c=>c.id===o);l&&await e.setSelectionsAndElements(t.stepName,[l],[])}}}async selectVariant(t,e,a){await a.getInitializationPromise();const n=await this.selectVariantLambda(t,e,a);n&&(n.command&&a.getCommandDispatcher()(n.command),n.followup&&await n.followup())}async selectVariantLambda(t,e,a){const n=t.option;if(!n)return null;const i=n.variants;if(!i)return null;const s=i.length>1?i.find(o=>o.id===e):i[0];if(!s)throw new Error(`Failed to find selected variant ${e} in option ${n.id} of step ${t.stepName} (${t.stepTitle})`);return{command:void 0,followup:async()=>{await a.setSelectionsAndElements(t.stepName,[s],[],async()=>{a.setMandatoryFulfilled(t.stepName,!0)})}}}}const La=new ko;class Mo{constructor(){this.shapeFillId="spiff-fill-shape"}async availableColours(t){var a;const e=t.option;return e?((a=e.variants)==null?void 0:a.map(n=>({fill:n.color,stroke:n.color,variant:n})))||[]:[]}setCustomColor(t,e,a){const n=a.getLayouts(),s=(a.getRegionElements(e.stepName)||[]).map(o=>{const l=o.region;if(!n.find(d=>d.panelId===(l==null?void 0:l.panelId)))throw new Y(l);return new ma(o.id,this.shapeFillId,t)}).filter(o=>!!o);a.getCommandDispatcher()(new $(s)),a.updateStorage(e.stepName,{colour:t})}async init(t,e,a){const n=t.option;if(!n)throw new te(t);if(a)await this.reload(t,e,a);else{const i=H.getDefaultVariant(n);return i?this.selectVariantCommand(t,{fill:i.color,stroke:i.color,variant:i},[],e):null}return null}async selectVariant(t,e,a,n){const i=await this.selectVariantCommand(t,e,a,n);i&&(i.command&&n.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async reload(t,e,a){var c;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),o=Object.values(a.layouts).map(d=>d.elements).flat().filter(d=>d.stepName===t.stepName),l=t.option;if(n!=null&&n.selectedVariants){const d=n.selectedVariants[0].id;if(l&&d){const A=(c=l.variants)==null?void 0:c.find(u=>u.id===d);if(A){const u=o.map(h=>({id:h.id,region:h.stepRegion}));await e.setSelectionsAndElements(t.stepName,[A],u,async()=>{var h;e.updateStorage(t.stepName,{colour:((h=n==null?void 0:n.storage)==null?void 0:h.colour)||""}),e.setMandatoryFulfilled(t.stepName,!0)})}}}}async selectVariantCommand(t,e,a,n){var l;const i=n.getLayouts(),s=(l=n.getStepStorage(t.stepName))==null?void 0:l.colour,o=()=>{var c,d;if(((c=e.variant)==null?void 0:c.color)==="#custom")return s||"#FFFFFF";if((d=e.variant)!=null&&d.color)return e.variant.color;throw new Error("Failed to resolve color for shape step.")};if(a.length>0){const c=A=>{const u=A.region;if(!i.find(m=>m.panelId===(u==null?void 0:u.panelId)))throw new Y(u);const g=o();return new ma(A.id,this.shapeFillId,g)},d=a.map(c).filter(A=>!!A);return{command:new $(d),followup:async()=>{await n.setSelectionsAndElements(t.stepName,e.variant?[e.variant]:[],a),n.updateStorage(t.stepName,{colour:o()})}}}else{const c=h=>{const g=i.find(w=>w.panelId===h.panelId);if(!g)throw new Y(h);const m=o(),p=`
1474
+ `,n={};n["spiff-fill-shape"]={browserValue:e.color};const i=e.region||await Gt(t,M.Illustration),s=Q();return{stepRegion:e.region,colors:n,id:s,svg:a,type:M.Illustration,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||qt(t,i.layer||0),immutable:i.immutable}}static async getIllustration(t,e){const a=e.region||await Gt(t,M.Illustration,e.src),n=await ot(await or(e.src)),i=await re(n.svg),s=Q();return{cachedObjectURL:i,stepRegion:e.region,colors:n.colors,id:s,src:e.src,svg:n.svg,type:M.Illustration,y:a.top,x:a.left,rotation:a.rotation,width:a.width,height:a.height,layer:a.layer||0,layerIndex:a.layerIndex||qt(t,a.layer||0),immutable:a.immutable}}}class q extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,q.prototype)}}const L=(r,t)=>_(r,t).elements.find(n=>n.id===r),_=(r,t)=>{const e=Object.values(t).find(a=>a.elements.some(n=>n.id===r));if(!e)throw new q;return e},X=(r,t)=>{const e=[...t.elements.filter(n=>n.id!==r.id),r],a=xa(e);return{layout:t.layout,elements:a,modificationID:Q()}},lr=async r=>{var a;const t=[...Object.keys(r.layouts)],e=[...new Set(t)];for(let n=0;n<e.length;n++){const i=e[n],s=r.layouts[i];await Promise.all(s.elements.map(async o=>{var l,c,d;if(o.type==="illustration"){const A=o;if(A.src&&!A.svg){const u=await tt(A.src),h=await ot(u);A.svg=Ba(h.svg,A.width,A.height,A.colors)}}else if(o.type==="frame"){const A=o;if((l=A.pattern)!=null&&l.colors&&((c=A.pattern)!=null&&c.src)){const u=await tt((d=A.pattern)==null?void 0:d.src),h=await ot(u);A.pattern.svg=h.svg}}isNaN(o.x)&&(o.x=0),isNaN(o.y)&&(o.y=0),isNaN(o.width)&&(o.width=0),isNaN(o.height)&&(o.height=0),isNaN(o.rotation)&&(o.rotation=0)}))}for(const n in r.layouts){const i=r.layouts[n].elements.filter(o=>o.type===M.Illustration);for(let o=0;o<i.length;++o){const l=i[o];if(l.src&&l.svg)try{l.cachedObjectURL=await re(l.svg)}catch(c){console.log(c)}}const s=r.layouts[n].elements.filter(o=>o.type===M.Textbox);for(let o=0;o<s.length;++o){const l=s[o];(a=l.fontData)!=null&&a.assetUrl&&await It(l.fontData.assetUrl)}}};class O{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(t){this.oldState=t}}class ln extends O{constructor(t){super(),this.serializableWorkflow=t}apply(t){return this.oldState=t,{...t,serializableWorkflow:this.serializableWorkflow}}}class mo extends O{constructor(t,e,a){super(),this.id=t,this.x=e,this.y=a}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,x:this.x,y:this.y},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class po extends O{constructor(t,e){super(),this.id=t,this.angle=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,rotation:this.angle},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class fo extends O{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=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;let a={...e,width:this.width,height:this.height};if(e.type==="frame"){const s=a;s.scaleX=s.scaleX*this.width/e.width,s.scaleY=s.scaleY*this.height/e.height}else if(e.type==="textbox"){const s=a,o=(!s.algorithm||s.algorithm===Bt.Autosize?s.text:s.input)??"";a=de(s,o,e)}const n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class $ extends O{constructor(t){super(),this.commands=t}apply(t){return this.oldState=t,this.commands.reduce((e,a)=>a.apply(e),t)}}class Na extends O{constructor(t){super(),this.layout=t}apply(t){return this.oldState=t,{...t,layouts:{...t.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:Q()}}}}}class G extends O{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(o=>o.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||e.length===0){const o=[...e,this.element];return this.element.layerIndex===void 0&&(this.element.layerIndex=this.assignIndex(this.element,o)),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:o,modificationID:Q()}}}}const n=e[e.length-1],i=n.productOverlay?n:null;i&&e.pop();let s;if(this.element.layerIndex!==null&&this.element.layerIndex!==void 0)s=[...e,this.element].sort((o,l)=>o.layerIndex!==void 0&&l.layerIndex!==void 0?o.layerIndex-l.layerIndex:0);else{const o=this.assignIndex(this.element,e);this.element.layerIndex=o!==void 0?o:0,s=[...e,this.element]}return i&&s.push(i),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:s,modificationID:Q()}}}}assignIndex(t,e){var n;if(e.length===0)return 0;const a=(n=e.filter(i=>(i.layer||0)===(t.layer||0)).sort((i,s)=>(i.layerIndex||0)-(s.layerIndex||0))[e.length-1])==null?void 0:n.layerIndex;return a!==void 0?a+1:0}}class Ct extends O{constructor(t){super(),this.id=t}apply(t){this.oldState=t;let e=!1;const a=Object.values(t.layouts).map(i=>(i.elements.filter(o=>o.id!==this.id).length!==i.elements.length&&(e=!0),{...i,elements:i.elements.filter(o=>o.id!==this.id),modificationID:Q()}));e||console.log(`Failed to delete element ${this.id}`);const n={};return a.forEach(i=>{n[i.layout.id]=i}),{...t,layouts:n}}}class cr extends O{constructor(t,e,a){super(),this.id=t,this.color=e,this.textFillSpotColor=a}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor,textFillImage:void 0},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class _e extends O{constructor(t,e){super(),this.id=t,this.imageFill=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,textFillImage:this.imageFill},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class dr extends O{constructor(t,e){super(),this.id=t,this.size=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,fontSize:this.size},n=_(e.id,Object.values(t.layouts)),i=(!e.algorithm||e.algorithm===Bt.Autosize?e.text:e.input)??"",s=X(de(a,i),n);return{...t,layouts:{...t.layouts,[n.layout.id]:s}}}}class ga extends O{constructor(t,e){super(),this.id=t,this.fontData=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,fontData:this.fontData},n=_(e.id,Object.values(t.layouts)),i=(!e.algorithm||e.algorithm===Bt.Autosize?e.text:e.input)??"",s=X(de(a,i),n);return{...t,layouts:{...t.layouts,[n.layout.id]:s}}}}class Ar extends O{constructor(t,e){super(),this.id=t,this.align=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,align:this.align},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class Co extends O{constructor(t,e,a){super(),this.id=t,this.imageData=e,this.offsets=a}apply(t){this.oldState=t;const e=_(this.id,Object.values(t.layouts)),a=e.elements.findIndex(o=>o.id===this.id),n=e.elements[a].pattern,i=[...e.elements];i.splice(a,1,{...e.elements[a],pattern:{...n,src:this.imageData.src,x:this.offsets.x,y:this.offsets.y,width:this.imageData.width,height:this.imageData.height,scaleX:this.offsets.zoom,scaleY:this.offsets.zoom,svg:this.imageData.svg,colors:this.imageData.colors}});const s={...e,elements:i,modificationID:Q()};return{...t,layouts:{...t.layouts,[e.layout.id]:s}}}}class wo extends O{constructor(t,e,a,n,i){super(),this.id=t,this.useThreshold=e,this.invertThreshold=a,this.threshold=n,this.thresholdSaturation=i}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,useThreshold:this.useThreshold,invertThreshold:this.invertThreshold,threshold:this.threshold,thresholdSaturation:this.thresholdSaturation},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class yo extends O{constructor(t,e){super(),this.id=t,this.src=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,src:this.src},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class ur extends O{constructor(t,e){super(),this.id=t,this.text=e}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a=_(e.id,Object.values(t.layouts)),n=X(de(e,this.text,e),a);return{...t,layouts:{...t.layouts,[a.layout.id]:n}}}}class Xe extends O{constructor(t,e,a){super(),this.id=t,this.strokeColor=e,this.strokeThickness=a}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,strokeColor:this.strokeColor,strokeThickness:this.strokeThickness},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class ma extends O{constructor(t,e,a){super(),this.id=t,this.className=e,this.fill=a}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a=e.colors||{},n=a[this.className];typeof this.fill=="string"?a[this.className]={browserValue:this.fill,spotColor:n==null?void 0:n.spotColor,pmsValue:n==null?void 0:n.pmsValue}:a[this.className]={browserValue:this.fill.browserValue,spotColor:n==null?void 0:n.spotColor,pmsValue:this.fill.pmsValue};const i={...e,colors:a},s=_(e.id,Object.values(t.layouts)),o=X(i,s);return{...t,layouts:{...t.layouts,[s.layout.id]:o}}}}class So extends O{constructor(t,e,a){super(),this.id=t,this.svgBody=e,this.objectURL=a}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a={...e,svg:this.svgBody,cachedObjectURL:this.objectURL},n=_(e.id,Object.values(t.layouts)),i=X(a,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class vo extends O{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!L(this.id,Object.values(t.layouts)).id)throw new q;const a=Object.values(t.layouts).find(s=>s.elements.find(o=>o.id===this.id));if(!a)throw new Error("Layout missing from state!");const n=a.elements.findIndex(s=>s.id===this.id);a.elements.push(a.elements.splice(n,1)[0]);const i=[...a.elements];return i.forEach((s,o)=>s.layerIndex=o),{...t,layouts:{...t.layouts,[a.layout.id]:{...t.layouts[a.layout.id],elements:i,modificationID:Q()}}}}}class Eo extends O{constructor(t){super(),this.id=t}apply(t){this.oldState=t;const e=L(this.id,Object.values(t.layouts));if(!e.id)throw new q;const a=Object.values(t.layouts).find(o=>o.elements.find(l=>l.id===this.id));if(!a)throw new Error("Layout missing from state!");const n=a.elements.findIndex(o=>o.id===this.id);a.elements.splice(n,1),a.elements.unshift(e);const i=[...a.elements],s=i.splice(n,1)[0];return i.splice(n,0,s),i.forEach((o,l)=>o.layerIndex=l),{...t,layouts:{...t.layouts,[a.layout.id]:{...t.layouts[a.layout.id],elements:i,modificationID:Q()}}}}}class bo extends O{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!L(this.id,Object.values(t.layouts)).id)throw new q;const a=Object.values(t.layouts).find(l=>l.elements.find(c=>c.id===this.id));if(!a)throw new Error("Layout missing from state!");const n=a.elements.findIndex(l=>l.id===this.id),i=n+1,s=[...a.elements],o=s.splice(n,1)[0];return s.splice(i,0,o),s.forEach((l,c)=>l.layerIndex=c),{...t,layouts:{...t.layouts,[a.layout.id]:{...t.layouts[a.layout.id],elements:s,modificationID:Q()}}}}}class Bo extends O{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!L(this.id,Object.values(t.layouts)).id)throw new q;const a=Object.values(t.layouts).find(l=>l.elements.find(c=>c.id===this.id));if(!a)throw new Error("Layout missing from state!");const n=a.elements.findIndex(l=>l.id===this.id),i=n-1,s=[...a.elements],o=s.splice(n,1)[0];return s.splice(i,0,o),s.forEach((l,c)=>l.layerIndex=c),{...t,layouts:{...t.layouts,[a.layout.id]:{...t.layouts[a.layout.id],elements:s,modificationID:Q()}}}}}class cn{constructor(t,e,a){this.processRegion=async n=>{var l,c,d,A;const i=this.layouts.find(u=>u.panelId===n.panelId);if(!i)throw new Y(n);let s="";if(this.configuration.type===I.ProductOverlay){let u="";if((l=this.product)!=null&&l.overlayImageUrl&&(u=this.product.overlayImageUrl),s=u,!u)throw new ee(this.configuration,"Couldn't find an asset for product overlay step")}const o=this.evaluateAssetType();if(o===M.Image){const u=this.configuration.type===I.SilentIllustration?(c=this.configuration.data.asset)==null?void 0:c.fileLink:(d=this.product)==null?void 0:d.overlayImageUrl;if(!u)throw new Error("Undefined raster silent step source");const h={stepName:this.configuration.stepName,id:Q(),src:u,type:o,y:n.top,x:n.left,width:n.width,height:n.height,layer:n.layer,layerIndex:n.layerIndex,immutable:n.immutable,productOverlay:this.configuration.type===I.ProductOverlay?!0:void 0,rotation:n.rotation,excludeFromExport:this.configuration.data.excludeFromPrint,preserveAspectRatio:"none"};return{regionElement:{id:h.id,region:n},command:new G(h,i)}}else{const u=this.configuration.type===I.SilentIllustration?(A=this.configuration.data.asset)==null?void 0:A.fileLink:s,g=await ot(await(async()=>new Promise((p,f)=>{if(!u){f("Undefined vector silent step source");return}tt(u,!0).then(C=>{p(C)}).catch(C=>console.error(C))}))()),m={stepName:this.configuration.stepName,id:Q(),cachedObjectURL:await re(g.svg),src:u,svg:g.svg,colors:g.colors,type:o,y:n.top,x:n.left,width:n.width,height:n.height,layer:n.layer,layerIndex:n.layerIndex,rotation:n.rotation,immutable:n.immutable,productOverlay:this.configuration.type===I.ProductOverlay?!0:void 0,excludeFromExport:this.configuration.data.excludeFromPrint};return{regionElement:{id:m.id,region:n},command:new G(m,i)}}},this.configuration=t,this.layouts=e,this.product=a||void 0}async trigger(){if(!this.configuration.data.regions)throw new ee(this.configuration,"Missing regions.");if(this.configuration.type===I.SilentIllustration){const t=this.configuration.data.regions.map(this.processRegion);return Promise.all(t)}else return this.configuration.type===I.ProductOverlay?Promise.all(this.configuration.data.regions.map(t=>{if(!this.layouts.find(a=>t.panelId===a.panelId))throw new Y(t);return this.processRegion(t)})):Promise.reject("Unknown silent step. This is a bug")}evaluateAssetType(){var e,a,n;const t=this.configuration.type===I.ProductOverlay&&((e=this.product)!=null&&e.overlayImageUrl)?this.product.overlayImageUrl.toLowerCase():(n=(a=this.configuration.data.asset)==null?void 0:a.fileLink)==null?void 0:n.toLowerCase().split("?")[0];return t!=null&&t.startsWith("data:image/png")||t!=null&&t.endsWith(".jpeg")||t!=null&&t.endsWith(".jpg")||t!=null&&t.endsWith(".png")?M.Image:(t!=null&&t.endsWith(".svg")||t!=null&&t.startsWith("image/svg+xml"),M.Illustration)}}const hr=async r=>{const t=`${At.getServicesApiUrl()}/shortener`;try{return(await(await st(t,{method:"POST",body:JSON.stringify({longUrl:r}),headers:{"Content-Type":"application/json"}})).json()).shortUrl}catch(e){throw console.error(e),new Ne("Failed to shorten URL, see console.")}};class gr{async poll(){try{if(await this.predicate()){this.onSuccess(),this.pollingId>-1&&window.clearInterval(this.pollingId);return}}catch{}this.attempts+=1,this.attempts<this.maxAttempts?this.pollingId=window.setTimeout(this.poll.bind(this),this.interval):this.onFailure()}constructor(t,e,a,n=3e3,i=10){this.onSuccess=e,this.onFailure=a,this.predicate=t,this.attempts=0,this.pollingId=-1,this.interval=n,this.maxAttempts=i,this.poll()}}class Io{async init(t,e,a){return a&&await this.reload(t,e,a),null}async reload(t,e,a){const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),l=Object.values(a.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName).map(c=>({id:c.id,region:c.stepRegion}));await e.setSelectionsAndElements(t.stepName,[],l,async()=>{var A,u;const c=(A=n==null?void 0:n.storage)==null?void 0:A.videoShortUrl,d=(u=n==null?void 0:n.storage)==null?void 0:u.videoUrl;e.updateStorage(t.stepName,{videoShortUrl:c,videoUrl:d})})}async regenerateQRCode(t,e,a,n){const i=async()=>{var m,p;const h=(await Ie([e]))[0],g=(p=(m=h==null?void 0:h.versions)==null?void 0:m.find(f=>f.name==="mpeg4"))==null?void 0:p.link;return{asset:h,link:g}},s=await new Promise((h,g)=>{new gr(async()=>!!(await i()).link,async()=>{const m=await i();if(!m.link||!m.link)throw new Nt(m.asset);h({rel:"mpeg4",href:m.link})},()=>{g("Poller timed out with 40 attempts @ 3 second interval")},3e3,40)});t.forEach(h=>a.getCommandDispatcher()(new Ct(h.id)));const o=n.data.baseUrl.slice(0,4)==="http"?"":"https://",l=new URL(o+n.data.baseUrl);l.searchParams.append("video",btoa(JSON.stringify([s]))),l.pathname=l.pathname+(l.pathname.slice(-1)==="/"?"":"/");const c=l.toString();if(c.length>=2e3)throw new Ne("Cannot create QR code, URL too long.");const d=await hr(c);if(!n.data||!n.data.regions)throw new ee(n,"Missing regions.");const A=await this.regionElements(n),u=await this.command(d,A,a,n.stepName);return u&&(u.command&&a.getCommandDispatcher()(u.command),u.followup&&await u.followup()),await a.setSelectionsAndElements(n.stepName,[],A,async()=>{a.updateStorage(n.stepName,{videoShortUrl:d,videoUrl:s.href})}),d}async regionElements(t){const e=a=>({id:Q(),region:a});return t.data.regions.map(e)}async command(t,e,a,n){const i=a.getLayouts(),o=`data:image/svg+xml;base64,${btoa(await vn.toString(t,{type:"svg"}))}`,l=e.map(c=>{const d=c.region,A=i.find(u=>u.panelId===(d==null?void 0:d.panelId));if(!A&&d)throw new Y(d);if(A&&!d)throw new Error("Region not found");if(!A||!d)throw new Error("Neither a region or layout found!");return new G({stepRegion:d,stepName:n,id:c.id,src:o,type:M.Image,y:d.top,x:d.left,width:d.width,height:d.height,rotation:0},A)});return{command:new $(l),followup:async()=>{}}}}const Qa=new Io;class De{constructor(){this.frameSourceSvg=async(t,e)=>{if(!t)return ua(e);const a=t.asset;if(!a)throw new mt(t);const n=a.fileLink;if(n)return tt(n,!0);throw new Nt(a)}}async init(t,e,a){const n=a==null?void 0:a.serializableWorkflow.steps.find(o=>o.stepName===t.stepName);if(n!=null&&n.storage&&Object.keys(n.storage).length!==0||n!=null&&n.selectedVariants&&n.selectedVariants.length!==0)return await this.reload(t,e,a),null;t.mandatory&&e.setMandatoryFulfilled(t.stepName,!1),e.markStepsAsInitialised([t.stepName]);let i;const s=e.getWorkflowExperience().getBundle();if(s&&t.globalPropertyAspectConfigurations){const o=s.getGlobalPropertyStateManager(),l=t.globalPropertyAspectConfigurations[0],c=o.getAspectStorage(l.aspectName);c&&c.originalAssetKey&&(i=(await U.getLocalOrFromServer(c.originalAssetKey)).fileLink)}if(t.option&&t.option.variants&&t.option.variants.length>0){const o=t.option,l=H.getDefaultVariant(o);return l?this.selectVariantCommand(t,l,[],e,void 0,i||t.data.placeholderImageUrl):null}return this.selectVariantCommand(t,void 0,[],e,void 0,i||t.data.placeholderImageUrl)}async reload(t,e,a){var c;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),l=Object.values(a.layouts).map(d=>d.elements).flat().filter(d=>d.stepName===t.stepName).map(d=>({id:d.id,region:d.stepRegion}));if(!t.option||(t.option.variants||[]).length===0){const d=t.data.regions.map(A=>ua(A));e.updateStorage(t.stepName,{currentFrameSources:d})}if(n){const d=async()=>{var g,m,p,f,C;const A=(g=n.storage)==null?void 0:g.colors,u=(m=n.storage)==null?void 0:m.framePatternSrc,h=(p=n.storage)==null?void 0:p.frameOffsetsList;if(e.updateMetadata(t.stepName,{frameOffsetsList:h,framePatternSrc:u}),u){const w=(f=e.getWorkflowExperience().getStepById(t.stepName))==null?void 0:f.frameService;if(!w)throw new Error("Frame service unavailable, cannot load pattern!");await this.loadPatternFromString(u,w,!0,A),e.updateMetadata(t.stepName,{image:u}),e.updateStorage(t.stepName,{framePatternSrc:u}),this.validateColorCount(t,e)}if(h!=null&&h.some(w=>w.zoom)){const w=(C=e.getWorkflowExperience().getStepById(t.stepName))==null?void 0:C.frameService;if(!w)throw new Error("Frame service unavailable, cannot load pattern!");w.updateOffsets(h)}e.setMandatoryFulfilled(t.stepName,!0)};if(n.selectedVariants&&n.selectedVariants.length>0){const A=n.selectedVariants[0].id;if(t.option&&A){const u=(c=t.option.variants)==null?void 0:c.find(h=>h.id===A);u&&await e.setSelectionsAndElements(t.stepName,[u],l,async()=>{const h=await Promise.all(t.data.regions.map(g=>this.frameSourceSvg(u,g)));e.updateStorage(t.stepName,{currentFrameSources:h}),await d()})}}else await e.setSelectionsAndElements(t.stepName,[],l,d)}}async availableColors(t,e){var n;const a=t.data.colorOption;return((n=a==null?void 0:a.variants)==null?void 0:n.map(i=>({fill:i.color,stroke:i.color,variant:i,pmsValue:i.name})))??[]}selectImage(t,e,a,n=!0){var l;const i=De.patternSource(e),s=(l=a.getStepStorage(t.stepName))==null?void 0:l.framePatternSrc;if(s&&s===i)return Promise.resolve();a.setEditedStatus(t.stepName,!0);const o=e.fileLink||"";return o.endsWith(".pdf")||o.endsWith(".eps")||o.endsWith(".ai")?new Promise(c=>{a.addPoller(new gr(async()=>{var h;const A=(h=(await U.getFromServer(e.key||"")).versions)==null?void 0:h.find(g=>g.name==="svg");return A?(await st(A.link)).status===200:!1},()=>{U.getLocalOrFromServer(e.key||"").then(d=>{this.loadPatternFromAsset(d,t,a,n).then(c)})},()=>{throw new Ne("Failed to resolve transcoded PDF")}))}):this.loadPatternFromAsset(e,t,a,n)}async selectVariant(t,e,a,n,i){const s=await this.selectVariantCommand(t,e,a,n,i);s&&(s.command&&n.getCommandDispatcher()(s.command),s.followup&&await s.followup())}getCreateElementCommand(t,e,a,n){return new G({id:t,type:M.Frame,x:e.left,y:e.top,width:e.width,height:e.height,layer:e.layer,layerIndex:e.layerIndex,rotation:e.rotation,scaleX:e.width/n.frameData.width,scaleY:e.height/n.frameData.height,path:n.frameData.path,dataWidth:n.frameData.width,dataHeight:n.frameData.height,stepRegion:e,stepName:n.stepName,disablePlaceholder:n.disablePlaceholder,pattern:n.pattern,immutable:e.immutable},a)}async loadPatternFromString(t,e,a=!0,n=void 0,i){if(t.endsWith("svg")){const s=await Ma(t),o=s.width,l=s.height,c=await tt(t);if(i){const u=c.match(/<(image|linearGradient|radialGradient)(\s|>|\/>)/gim);if(u&&u.length>0)throw new Error("Vector files may not include images or gradients when a color limit is specified.")}const d=await ot(c),A={src:t,width:o,height:l,aspect:o/l,svg:d.svg,colors:n??d.colors};dt.set(t,A),e.setPatternData(A,a)}else{const s=await Qe(t,!0),o=await le(s),l={src:t,width:o.width,height:o.height,aspect:o.width/o.height,svg:void 0,colors:void 0};dt.set(t,l),e.setPatternData(l,a)}}changeColors(t,e,a){var s,o;const n=(s=e.getWorkflowExperience().getStepById(t.stepName))==null?void 0:s.frameService;if(!n||!((o=n.getImageData())!=null&&o.svg)){console.warn("changeColors was called without an SVG being assigned to a frame step");return}const i=this.calculateColorMetadata(n,t,a);e.updateMetadata(t.stepName,{colors:i.metadataColors}),e.updateStorage(t.stepName,{colors:i.storageColors}),n.setPatternData({...n.getImageData(),colors:i.newColors},!1),this.validateColorCount(t,e)}getUniqueColorCount(t,e){var s,o;const a=(s=e.getWorkflowExperience().getStepById(t.stepName))==null?void 0:s.frameService;if(!a)return 0;const n=((o=a.getImageData())==null?void 0:o.colors)??{},i=[];for(const l in n){const c=n[l];if(c.pmsValue){const d=c.pmsValue.trim().toLocaleLowerCase();i.includes(d)||i.push(d)}else if(c.browserValue){const d=Ln(c.browserValue);i.includes(d)||i.push(d)}}return i.length}calculateColorMetadata(t,e,a){var l,c;if(!((l=t.getImageData())!=null&&l.svg))return{newColors:void 0,metadataColors:void 0,storageColors:void 0};const n={...t.getImageData().colors??{}},i={};Object.entries(n).forEach(([d,A])=>{const u={browserValue:A.browserValue};i[d]=u});for(const[d,A]of a.entries())n[d]={browserValue:A.browserValue,pmsValue:A.pmsValue},i[d]=A;let s=Array.from(Object.values(n)).map(d=>d.browserValue);const o=e.data.colorOption;return o&&((c=o.variants)==null||c.forEach(d=>{s=s.map(A=>{var u;return A.toLowerCase()===((u=d.color)==null?void 0:u.toLowerCase())?d.name:A})})),{newColors:n,metadataColors:s,storageColors:i}}validateColorCount(t,e){const a=t.data.colorPickerEnabled?t.data.maxColors??0:0;e.setStepError(t.stepName,"colors",a>0&&this.getUniqueColorCount(t,e)>a?"workflow.steps.frame.tooManyColors":void 0)}async selectVariantCommand(t,e,a,n,i,s){var h;const o=(h=n.getWorkflowExperience().getStepById(t.stepName))==null?void 0:h.frameService;if(!o)throw new Error("Frame service unavailable, cannot load pattern!");const l=await Promise.all(t.data.regions.map(g=>this.frameSourceSvg(e,g)));i&&i(!0);const c=t.data.initialZoomLevel,d=await Promise.all(t.data.regions.map(async(g,m)=>{const p=await ue(l[m]),f=o.getImageData(),C=a.map(P=>new Ct(P.id)),w=f?ka(f,p,c&&!t.data.forceImageCover?{scale:c}:void 0,t.data.forceImageCover):void 0,S=f?{id:Q(),src:f.src,x:(w==null?void 0:w.x)||0,y:(w==null?void 0:w.y)||0,width:f.width,height:f.height,scaleX:(w==null?void 0:w.zoom)||1,scaleY:(w==null?void 0:w.zoom)||1,rotation:0}:void 0,y=Q(),b=n.getLayouts().find(P=>P.panelId===g.panelId);if(!b)throw new Y(g);return{command:this.getCreateElementCommand(y,g,b,{frameData:p,pattern:S,disablePlaceholder:t.data.disablePlaceholder,stepName:t.stepName}),regionEl:{id:y,region:g},removeExistingCommands:C}})),A=d.map(g=>g.command),u=d.map(g=>g.removeExistingCommands).flat();return{command:new $([...A,...u]),followup:async()=>{i&&i(!1),await n.setSelectionsAndElements(t.stepName,e?[e]:[],[...d.map(g=>g.regionEl)],async()=>{var g;if(n.updateStorage(t.stepName,{currentFrameSources:l}),s){const m=(g=n.getWorkflowExperience().getStepById(t.stepName))==null?void 0:g.frameService;if(!m)throw new Error("Frame service unavailable, cannot load pattern!");await this.loadPatternFromString(s,m,!0)}})}}}static patternSource(t){var n;const e=(n=t.versions)==null?void 0:n.find(i=>i.name==="svg");if(e!=null&&e.link)return e.link;const a=t.fileLink;if(a)return a;throw new Nt(t)}async loadPatternFromAsset(t,e,a,n){var c,d;const i=De.patternSource(t),s=a.markUpdatePending(),o=(c=a.getWorkflowExperience().getStepById(e.stepName))==null?void 0:c.frameService;if(!o)throw a.markUpdateCompleted(s),new Error("Frame service unavailable, cannot load pattern!");try{await this.loadPatternFromString(i,o,n,void 0,e.data.colorPickerEnabled&&!!e.data.maxColors&&e.data.maxColors>0)}catch(A){throw a.markUpdateCompleted(s),A}const l=this.calculateColorMetadata(o,e,new Map(Object.entries(((d=o.getImageData())==null?void 0:d.colors)??{})));a.updateMetadata(e.stepName,{image:i,colors:l.metadataColors}),a.updateStorage(e.stepName,{framePatternSrc:i,colors:l.storageColors}),a.markUpdateCompleted(s),a.setMandatoryFulfilled(e.stepName,!0),a.setInformationResults(a.getInformationResults().filter(A=>A.stepID===e.stepName)),this.validateColorCount(e,a)}}const ut=new De;class Po{async getIllustrationBody(t){return new Promise(e=>{tt(t,!0).then(a=>{e(a)}).catch(a=>console.error(a))})}getCreateElementCommand(t,e,a,n){return new G({stepRegion:e,stepName:n.stepName,colors:n.svg.colors,id:t,src:n.src,svg:n.svg.svg,cachedObjectURL:n.objectURL,type:M.Illustration,y:e.top,x:e.left,rotation:e.rotation,width:e.width,height:e.height,layer:e.layer,layerIndex:e.layerIndex,immutable:e.immutable},a)}getColors(t,e){const a=e.getRegionElements(t.stepName)||[];if(a.length===0)return[];try{return L(a[0].id,e.getAllLayoutData()).colors}catch{return[]}}async init(t,e,a){const n=t.option;if(!n)return null;if(a)return this.reload(t,e,a);{const i=H.getDefaultVariant(n);if(i)return await this.selectVariantCommand(t,i,[],()=>{},e)}return null}async reload(t,e,a){var c;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),o=Object.values(a.layouts).map(d=>d.elements).flat().filter(d=>d.stepName===t.stepName),l=t.option;if(n!=null&&n.selectedVariants){const d=n.selectedVariants[0].id;if(l&&d){const A=(c=l.variants)==null?void 0:c.find(u=>u.id===d);if(A){const u=o.map(h=>({id:h.id,region:h.stepRegion}));await e.setSelectionsAndElements(t.stepName,[A],u,async()=>{var h;e.updateMetadata(t.stepName,{colors:(h=n.storage)==null?void 0:h.colors}),e.setMandatoryFulfilled(t.stepName,!0)})}}else throw new Error("Required illustration variant no longer available")}return null}async availableColors(t,e){var n;const a=t.data.colorOption;return a?a?(n=a.variants)==null?void 0:n.map(i=>({fill:i.color,stroke:i.color,variant:i,pmsValue:i.name})):[]:[]}async changeColorsCommand(t,e,a,n,i){const s={};for(const[d,A]of i.entries())typeof A=="string"?s[d]={browserValue:A,spotColor:void 0,pmsValue:void 0}:s[d]={browserValue:A.browserValue,spotColor:A.spotColor,pmsValue:A.pmsValue};const o=Ba(t,e,a,s),l=await re(o),c=[];for(const d of n){for(const[A,u]of i.entries())c.push(new ma(d,A,u));c.push(new So(d,o,l))}return new $(c)}async changeColors(t,e,a,n,i){var h,g;if(e.length===0)return;const s=L(e[0].id,n().map(m=>m.layoutState)),o={...s.colors},l={};Object.entries(o).forEach(([m,p])=>{const f={browserValue:p.browserValue,pmsValue:p.pmsValue},C=p.spotColor;C&&(f.spotColor={profileName:C.profileName,namedColor:C.namedColor}),l[m]=f});for(const[m,p]of i.entries()){const f=typeof p=="string"?p:p.browserValue,C=typeof p=="string"?void 0:p.pmsValue;o[m]={browserValue:f,spotColor:(h=o[m])==null?void 0:h.spotColor,pmsValue:C},l[m]={browserValue:f}}let c=Array.from(Object.values(o)).map(m=>m.browserValue);const d=t.data.colorOption;d&&((g=d.variants)==null||g.forEach(m=>{c=c.map(p=>{var f;return p.toLowerCase()===((f=m.color)==null?void 0:f.toLowerCase())?m.name:p})})),a.updateMetadata(t.stepName,{colors:c});const A=new Map;if(Object.entries(o).forEach(([m,p])=>{A.set(m,p)}),!s.svg)throw new Error("Colors changed before SVG loaded. This should never happen!");const u=await this.changeColorsCommand(s.svg,s.width,s.height,e.map(m=>m.id),A);a.updateStorage(t.stepName,{colors:l}),a.getCommandDispatcher()(u)}async selectVariant(t,e,a,n,i){const s=await this.selectVariantCommand(t,e,a,n,i);s&&(s.command&&i.getCommandDispatcher()(s.command),s.followup&&await s.followup())}async selectVariantCommand(t,e,a,n,i){var f;if(!t.data||!t.data.regions)throw new ee(t,"Missing regions.");n(!0);const s=a.map(C=>new Ct(C.id));t.mandatory&&i.setMandatoryFulfilled(t.stepName,!1);const o=e.asset;if(!o)throw new mt(e);const l=o.fileLink;if(!l)throw new Nt(o);const c=await ot(await this.getIllustrationBody(l)),d=await re(c.svg),A=C=>{const w=i.getLayouts().find(y=>y.panelId===C.panelId);if(!w)throw new Y(C);const S=Q();return{regionElement:{id:S,region:C},command:this.getCreateElementCommand(S,C,w,{stepName:t.stepName,src:l,objectURL:d,svg:c})}},u=t.data.regions.map(A),g=[...u.map(C=>C.command),...s];let m=Array.from(Object.values(c.colors)).map(C=>C.browserValue);const p=t.data.colorOption;return p&&((f=p.variants)==null||f.forEach(C=>{m=m.map(w=>{var S;return w.toLowerCase()===((S=C.color)==null?void 0:S.toLowerCase())?C.name:w})})),i.updateMetadata(t.stepName,{colors:m}),{command:new $(g),followup:async()=>{var w,S;await i.setSelectionsAndElements(t.stepName,[e],u.map(y=>y.regionElement),async()=>{i.setMandatoryFulfilled(t.stepName,!0),n(!1)});const C=((w=o.assetConfiguration)==null?void 0:w.defaultColorVariants)||[];if(C.length!==0){const y={};(((S=o.assetConfiguration)==null?void 0:S.channelNumbers)||[]).forEach(b=>{var D;const P=C.find(x=>x.channelNumber===b.number);P&&(y[`${b.id.replace(/\W/g,"")}`]={browserValue:((D=P==null?void 0:P.variant)==null?void 0:D.color)||""})}),await this.changeColors(t,u.map(b=>b.regionElement),i,()=>i.getCommandContext().getAllLayouts(),new Map(Object.entries(y)))}if(t.data.colorPickerEnabled){const y=await this.availableColors(t,i)||[],E=Object.keys(c.colors),b=y.length===1&&E.length===1;if(b){const P=y[0],D=E[0];await this.changeColors(t,u.map(x=>x.regionElement),i,()=>i.getCommandContext().getAllLayouts(),new Map([[D,P.variant.color]]))}!b&&C.length===0&&await this.changeColors(t,u.map(P=>P.regionElement),i,()=>i.getCommandContext().getAllLayouts(),new Map)}}}}}const Jt=new Po;class Fo{async init(t,e,a){const n=t.option;if(!n)throw new te(t);if(a)await this.reload(t,e,a);else{const i=H.getDefaultVariant(n);if(i)return await this.selectVariantLambda(t,i,e,()=>{})}return null}async reload(t,e,a){var c;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),o=Object.values(a.layouts).map(d=>d.elements).flat().filter(d=>d.stepName===t.stepName),l=t.option;if(!l)throw new te(t);if(n!=null&&n.selectedVariants){const d=n.selectedVariants[0].id;if(d){const A=(c=l.variants)==null?void 0:c.find(u=>u.id===d);if(A){const u=A.material,h=o.map(g=>({id:g.id,region:g.stepRegion}));await e.setSelectionsAndElements(t.stepName,[A],h,async()=>{const g=e.getModelContainer();if(g){const m=t.data.targetMaterials.map(p=>g.applyMaterialVariant(p,l.id||"",u||{}));Promise.all(m).then(()=>e.setMandatoryFulfilled(t.stepName,!0))}})}}}}async selectVariant(t,e,a,n){const i=await this.selectVariantLambda(t,e,a,n);i&&(i.command&&a.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async selectVariantLambda(t,e,a,n){const i=a.getModelContainer();n(!0);const s=e.material;if(!s)throw n(!1),new mt(e);return{command:void 0,followup:async()=>{await a.setSelectionsAndElements(t.stepName,[e],[],async()=>{try{i&&t.data.targetMaterials.forEach(o=>{t.option&&i.applyMaterialVariant(o,t.option.id||"",s)}),a.setMandatoryFulfilled(t.stepName,!0)}finally{n(!1)}})}}}}const Ra=new Fo;class Do{async init(t,e,a){const n=t.option;if(!n)throw new te(t);if(a)await this.reload(t,e,a);else{const i=H.getDefaultVariant(n);if(i)return await this.selectVariantLambda(t,i,e,()=>{})}return null}async reload(t,e,a){var c;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),o=Object.values(a.layouts).map(d=>d.elements).flat().filter(d=>d.stepName===t.stepName),l=t.option;if(n!=null&&n.selectedVariants){const d=n.selectedVariants[0].id;if(l&&d){const A=(c=l.variants)==null?void 0:c.find(u=>u.id===d);if(A){const u=o.map(h=>({id:h.id,region:h.stepRegion}));await e.setSelectionsAndElements(t.stepName,[A],u,async()=>{var g;const h=e.getModelContainer();if(h&&t.option){const m=(g=A.asset)==null?void 0:g.fileLink;if(!m)throw new mt(A);await h.applyModelVariant(t.stepName||"",{model:m,contextService:e.getLayoutPreviewService()},t.data.replaceProductModel||!1),e.setMandatoryFulfilled(t.stepName,!0)}})}}}}async selectVariant(t,e,a,n){const i=await this.selectVariantLambda(t,e,a,n);i&&(i.command&&a.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async selectVariantLambda(t,e,a,n){var s;n(!0);const i=(s=e.asset)==null?void 0:s.fileLink;if(!i)throw new mt(e);return{command:void 0,followup:async()=>{await a.setSelectionsAndElements(t.stepName,[e],[],async()=>{try{const o=a.getModelContainer();o&&await o.applyModelVariant(t.stepName,{model:i,contextService:a.getLayoutPreviewService()},t.data.replaceProductModel||!1),a.setMandatoryFulfilled(t.stepName,!0)}finally{n(!1)}})}}}}const Oa=new Do;class xo{async init(t,e,a){if(a)await this.reload(t,e,a);else return e.updateMetadata(t.stepName,{text:""}),this.changeTextCommand(t,"",e,()=>{});return null}async reload(t,e,a){const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),l=Object.values(a.layouts).map(c=>c.elements).flat().filter(c=>c.stepName===t.stepName).map(c=>({id:c.id,region:c.stepRegion}));await e.setSelectionsAndElements(t.stepName,[],l,async()=>{var c,d;e.updateStorage(t.stepName,{text:(c=n==null?void 0:n.storage)==null?void 0:c.text}),e.setMandatoryFulfilled(t.stepName,((d=n==null?void 0:n.storage)==null?void 0:d.text)!=="")})}async changeText(t,e,a,n){const i=await this.changeTextCommand(t,e,a,n);i&&(i.command&&a.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async changeTextCommand(t,e,a,n){var d;const i=a.getRegionElements(t.stepName),s=(d=a.getStepSpecificServices(t.stepName))==null?void 0:d.module;if(!s)return console.error("Missing module."),null;const o=a.getProfanities(),l=this.validateInput(t,e,o,n);if(l.errorData)return a.setMandatoryFulfilled(t.stepName,!1),l.errorData.blockedProfanity?console.error("Blocked profanity."):l.errorData.hitCharacterLimit?console.error("Too many characters."):l.errorData.unsupportedCharacters&&console.error("Unsupported characters."),null;if(a.setMandatoryFulfilled(t.stepName,e!==""),!t.data||!t.data.regions||t.data.regions.length<=0)return console.error("Missing configuration."),null;a.updateStorage(t.stepName,{text:e}),a.updateMetadata(t.stepName,{text:e});const c=(A,u,h)=>{const g=h||Q(),p=a.getLayouts().find(C=>C.panelId===u.panelId);if(!p)return console.error(`Can not find layout for region: ${u.panelId}`),null;const f=[];return h&&f.push(new Ct(g)),f.push(new G({stepRegion:u,stepName:t.stepName,colors:{},id:g,svg:A,type:M.Illustration,y:u.top,x:u.left,rotation:u.rotation,width:u.width,height:u.height,layer:u.layer,layerIndex:u.layerIndex,immutable:u.immutable},p)),{id:g,region:u,command:new $(f)}};if(i.length>0){const u=i.map(h=>{if(!h.region)return null;const g=s.svgPrint(e,h.region);return c(g,h.region,h.id)}).filter(h=>!!h).filter(h=>!!h).map(h=>h&&h.command);return{command:new $(u),followup:async()=>{}}}else{const A=t.data.regions.map(h=>c(s.svgPrint(e,h),h)),u=A.filter(h=>!!h).map(h=>h&&h.command);return{command:new $(u),followup:async()=>{const h=A.filter(g=>g).map(g=>g&&{id:g.id,region:g.region});await a.setSelectionsAndElements(t.stepName,[],h)}}}}validateInput(t,e,a,n){if(t.data&&t.data.maxLength){const s=t.data.maxLength;if(e.length>s)return n("Too many characters."),{input:e,helperData:{},errorData:{hitCharacterLimit:!0}}}if(!/^$|^[a-zA-Z0-9 ]+$/.test(e))return n("Unsupported characters."),{input:e,helperData:{},errorData:{unsupportedCharacters:!0}};const i=ia.split(e.toLowerCase());for(const s of i)for(const o in a){const l=a[o].toLowerCase().replace(/\s/g,"");if(s===l)return n("Blocked profanity."),{input:e,helperData:{},errorData:{blockedProfanity:!0}}}return n(""),{input:e,helperData:{}}}}const $a=new xo;class ko{async init(t,e,a){const n=t.option;if(!n)return null;if(a)await this.reload(t,e,a);else if(n.defaultVariant)return e.markStepsAsInitialised([t.stepName]),this.selectVariantCommand(t,n.defaultVariant,e,()=>{});return e.markStepsAsInitialised([t.stepName]),null}async reload(t,e,a){var c;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),o=Object.values(a.layouts).map(d=>d.elements).flat().filter(d=>d.stepName===t.stepName),l=t.option;if(n!=null&&n.selectedVariants){const d=n.selectedVariants[0].id;if(l&&d){const A=(c=l.variants)==null?void 0:c.find(u=>u.id===d);if(A){const u=o.map(h=>({id:h.id,region:h.stepRegion}));await e.setSelectionsAndElements(t.stepName,[A],u,async()=>{e.setMandatoryFulfilled(t.stepName,!0)})}}}}async selectVariant(t,e,a,n){const i=await this.selectVariantCommand(t,e,a,n);i&&(i.command&&a.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async selectVariantCommand(t,e,a,n){const i=e.asset;if(!i)throw new mt(e);const s=i==null?void 0:i.fileLink;if(!s)return console.error("No URL for picture!"),null;n(!0),t.mandatory&&a.setMandatoryFulfilled(t.stepName,!1);const l=a.getRegionElements(t.stepName).map(A=>new Ct(A.id)),c=A=>{const h=a.getLayouts().find(m=>m.panelId===A.panelId);if(!h)throw new Y(A);const g=Q();return{regionElement:{id:g,region:A},command:new G({stepName:t.stepName,stepRegion:A,id:g,src:s,type:M.Image,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer,layerIndex:A.layerIndex,immutable:A.immutable,preserveAspectRatio:"none"},h)}},d=t.data.regions.map(c);return{command:new $([...l,...d.map(A=>A.command)]),followup:async()=>{await a.setSelectionsAndElements(t.stepName,[e],d.map(A=>A.regionElement),async()=>{a.setMandatoryFulfilled(t.stepName,!0),n(!1)})}}}}const Ua=new ko;class Mo{async init(t,e,a){const n=t.option;if(!n)return null;if(a)await this.reload(t,e,a);else{const i=n.variants;if(H.getDefaultVariant(n)){const o=i==null?void 0:i.find(l=>{var c;return l.id===((c=n.defaultVariant)==null?void 0:c.id)});return this.selectVariantLambda(t,(o==null?void 0:o.id)||"",e)}}return null}async reload(t,e,a){var s;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),i=t.option;if(n!=null&&n.selectedVariants){const o=n.selectedVariants[0].id;if(i&&o){const l=(s=i.variants)==null?void 0:s.find(c=>c.id===o);l&&await e.setSelectionsAndElements(t.stepName,[l],[])}}}async selectVariant(t,e,a){await a.getInitializationPromise();const n=await this.selectVariantLambda(t,e,a);n&&(n.command&&a.getCommandDispatcher()(n.command),n.followup&&await n.followup())}async selectVariantLambda(t,e,a){const n=t.option;if(!n)return null;const i=n.variants;if(!i)return null;const s=i.length>1?i.find(o=>o.id===e):i[0];if(!s)throw new Error(`Failed to find selected variant ${e} in option ${n.id} of step ${t.stepName} (${t.stepTitle})`);return{command:void 0,followup:async()=>{await a.setSelectionsAndElements(t.stepName,[s],[],async()=>{a.setMandatoryFulfilled(t.stepName,!0)})}}}}const La=new Mo;class To{constructor(){this.shapeFillId="spiff-fill-shape"}async availableColours(t){var a;const e=t.option;return e?((a=e.variants)==null?void 0:a.map(n=>({fill:n.color,stroke:n.color,variant:n})))||[]:[]}setCustomColor(t,e,a){const n=a.getLayouts(),s=(a.getRegionElements(e.stepName)||[]).map(o=>{const l=o.region;if(!n.find(d=>d.panelId===(l==null?void 0:l.panelId)))throw new Y(l);return new ma(o.id,this.shapeFillId,t)}).filter(o=>!!o);a.getCommandDispatcher()(new $(s)),a.updateStorage(e.stepName,{colour:t})}async init(t,e,a){const n=t.option;if(!n)throw new te(t);if(a)await this.reload(t,e,a);else{const i=H.getDefaultVariant(n);return i?this.selectVariantCommand(t,{fill:i.color,stroke:i.color,variant:i},[],e):null}return null}async selectVariant(t,e,a,n){const i=await this.selectVariantCommand(t,e,a,n);i&&(i.command&&n.getCommandDispatcher()(i.command),i.followup&&await i.followup())}async reload(t,e,a){var c;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),o=Object.values(a.layouts).map(d=>d.elements).flat().filter(d=>d.stepName===t.stepName),l=t.option;if(n!=null&&n.selectedVariants){const d=n.selectedVariants[0].id;if(l&&d){const A=(c=l.variants)==null?void 0:c.find(u=>u.id===d);if(A){const u=o.map(h=>({id:h.id,region:h.stepRegion}));await e.setSelectionsAndElements(t.stepName,[A],u,async()=>{var h;e.updateStorage(t.stepName,{colour:((h=n==null?void 0:n.storage)==null?void 0:h.colour)||""}),e.setMandatoryFulfilled(t.stepName,!0)})}}}}async selectVariantCommand(t,e,a,n){var l;const i=n.getLayouts(),s=(l=n.getStepStorage(t.stepName))==null?void 0:l.colour,o=()=>{var c,d;if(((c=e.variant)==null?void 0:c.color)==="#custom")return s||"#FFFFFF";if((d=e.variant)!=null&&d.color)return e.variant.color;throw new Error("Failed to resolve color for shape step.")};if(a.length>0){const c=A=>{const u=A.region;if(!i.find(m=>m.panelId===(u==null?void 0:u.panelId)))throw new Y(u);const g=o();return new ma(A.id,this.shapeFillId,g)},d=a.map(c).filter(A=>!!A);return{command:new $(d),followup:async()=>{await n.setSelectionsAndElements(t.stepName,e.variant?[e.variant]:[],a),n.updateStorage(t.stepName,{colour:o()})}}}else{const c=h=>{const g=i.find(w=>w.panelId===h.panelId);if(!g)throw new Y(h);const m=o(),p=`
1451
1475
  <svg
1452
1476
  xmlns="http://www.w3.org/2000/svg"
1453
1477
  xmlnsXlink="http://www.w3.org/1999/xlink"
@@ -1467,14 +1491,14 @@
1467
1491
  fill="${m}"
1468
1492
  />
1469
1493
  </svg>
1470
- `,f={};f[this.shapeFillId]={browserValue:m};const C=Q();return{id:C,region:h,command:new q({stepRegion:h,stepName:t.stepName,colors:f,id:C,svg:p,type:k.Illustration,y:h.top,x:h.left,rotation:h.rotation,width:h.width,height:h.height,layer:h.layer,layerIndex:h.layerIndex,immutable:h.immutable,excludeFromExport:t.data.excludeFromPrint},g)}},d=t.data.regions.map(c),A=d.filter(h=>!!h).map(h=>h==null?void 0:h.command),u=d.filter(h=>!!h).map(h=>({id:h.id,region:h.region}));return{command:new $(A),followup:async()=>{await n.setSelectionsAndElements(t.stepName,e.variant?[e.variant]:[],u,async()=>{n.updateStorage(t.stepName,{colour:o()})})}}}}}const kt=new Mo;class To{constructor(){this.latestToast=null,this.toastType=null,this.toastCallbacks=[]}addToastCallback(t){t({toastMessage:this.latestToast,toastType:this.toastType}),this.toastCallbacks.push(t)}removeToastCallback(t){this.toastCallbacks=this.toastCallbacks.filter(e=>e!==t)}setLatestToast(t,e){this.latestToast=t,this.toastType=e,this.onToastChange()}onToastChange(){this.toastCallbacks.forEach(t=>t({toastMessage:this.latestToast,toastType:this.toastType}))}}const gr=new To,Ze=(r,t,e,a,n)=>{if(t.some(d=>d==null))throw new Error(`Failed to autosize lines: ${t.join(", ")}`);let i=t.map(d=>d.split(`
1471
- `)).flat(),s=i.length,o=i.map(d=>gt(d,a,n));const l=n.getApproximateHeight()*a;let c=!0;for(;c;){if(l+(s-1)*e>r.height)return[null,null];const A=Math.max(...o);if(A<=r.width)return[i,A];const u=o.reduce((p,f,C,w)=>f>w[p]?C:p,0),h=i[u];let g=!1,m=h.length;for(;!g&&m>-1;){m=h.lastIndexOf(" ",m-1);const p=[h.slice(0,m),h.slice(m+1)],f=p.map(w=>gt(w,a,n));f[0]<=r.width&&(i=[...i.slice(0,u),...p,...i.slice(u+1)],o=[...o.slice(0,u),...f,...o.slice(u+1)],s+=1,g=!0)}g||(c=!1)}return[null,null]},Kt=(r,t,e,a,n)=>{let i,s;const o=bt(t.assetUrl),l=o.getFont();if(n.size){const u=r/l.unitsPerEm;return[i,s]=Ze(e,a,r,u,o),[n.size,i,s]}const c=6;let d=c-Ye;if(a.length>0){let u=a,h=0;for(;(!n.maxSize||d<=n.maxSize)&&u;)d+=Ye,h=d/l.unitsPerEm,[u,s]=Ze(e,a,d,h,o)}d>c&&(d-=Ye),n.minSize&&d<n.minSize&&(d=n.minSize);const A=d/l.unitsPerEm;return[i,s]=Ze(e,a,d,A,o),[d,i,s]},ta=30;class Fe extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype),this.name=Fe.name}}const No=["‘","’","“","”",`
1472
- `];class ke extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype),this.name=ke.name}}class Qo{constructor(){this.cachedColors=new Map,this.cachedStrokeColors=new Map,this.filterUnsupportedCharacters=(t,e)=>{let a=t.replace(/(\r\n|\r|(\u2665|\u00a9|\u00ae|[\u2000-\u2017]|[\u201E-\u3300]]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]))/gm,"");const n=[],i=e?bt(e.assetUrl):void 0;if(i){const s=a.split("").filter(l=>!No.includes(l)).join(""),o=s.split("").map(l=>i.getFont().charToGlyph(l));for(let l=0;l<o.length;l++)o[l].name===".notdef"&&n.push(String.fromCharCode(s.charCodeAt(l)))}for(let s=0;s<n.length;s++)a=a.replaceAll(n[s],"");return a},this.textAlign=t=>t.vertical?"center":t.textAlign||"center",this.getErrorsForText=(t,e,a,n)=>{let i;a.data&&a.data.maxLength&&e.length>a.data.maxLength&&(i||(i={}),i.hitCharacterLimit=!0);const s=n.getProfanities(),o=ia.split(t.toLowerCase());for(const c of o)for(const d in s){const A=s[d].toLowerCase().replace(/\s/g,"");if(c===A){i||(i={}),i.blockedProfanity=!0;break}}return!a.data.allowNewlines&&(t.includes(`
1473
- `)||t.includes("\r"))&&(i||(i={}),i.illegalMultipleLines=!0),i}}async init(t,e,a){var i,s,o,l;const n=t.option;if(!n)return null;if(a)await this.reload(t,e,a);else{const c=this.getDefaultImageFillVariant(t.data),d=(i=c==null?void 0:c.asset)==null?void 0:i.fileLink,A=d?await ha(d):void 0,u=A?{src:A.src,height:A.height,width:A.width,scale:t.data.imageFillScale||1}:void 0,h=this.getDefaultStrokeColorVariant(t.data),g=t.data.strokeEnabled&&(h!=null&&h.color)?{browserValue:h.color,pmsValue:h.name}:void 0;let m=t.data.defaultText||"";const p=e.getWorkflowExperience().getBundle();if(p&&t.globalPropertyAspectConfigurations){const C=(s=p.getGlobalPropertyConfiguration())==null?void 0:s.aspects,w=C==null?void 0:C.find(S=>{var y;return S.type===V.Text&&((y=t.globalPropertyAspectConfigurations)==null?void 0:y.map(E=>E.aspectName).includes(S.name))});if(w){const y=p.getGlobalPropertyStateManager().getAspect(w.name);y&&(m=y)}}e.updateStorage(t.stepName,{text:m,inputText:t.data.defaultText||"",color:((o=this.getDefaultColorVariant(t.data))==null?void 0:o.color)||this.getDefaultColor(t.data),fillImage:u,strokeColor:g}),e.updateMetadata(t.stepName,{text:m,color:((l=this.getDefaultColorVariant(t.data))==null?void 0:l.name)||this.getDefaultColor(t.data),fillImage:c==null?void 0:c.name,strokeColor:t.data.strokeEnabled?h==null?void 0:h.color:void 0});const f=H.getDefaultVariant(n);if(f)return this.selectVariantCommand(t,f,{text:m},[],e,()=>{},()=>{},u,g)}return null}findLayoutElements(t,e){return t.getRegionElements(e.stepName).map(i=>L(i.id,t.getAllLayoutData()))}availableFillColors(t){var n;const e=this.cachedColors.get(t.stepName);if(e)return e;const a=t.data.colorOption;if(a){const i=((n=a.variants)==null?void 0:n.map(s=>({fill:s.color,stroke:s.color,variant:s})))||[];return this.cachedColors.set(t.stepName,i),i}return[]}changeAlignment(t,e,a,n){if(!t.data||!t.data.regions)return;const i=n.getCommandDispatcher();for(const s of a){const o=new dr(s.id,e);i(o)}}async changeFillColor(t,e,a,n){var l;if(!t.data||!t.data.regions)return;const i=n.getCommandDispatcher();e.variant?n.updateMetadata(t.stepName,{color:e.variant.name}):n.updateMetadata(t.stepName,{color:e.fill});const s=t.data.colorOption,o=s?this.createTextFillSpotColor(s,e.variant):void 0;s?n.updateStorage(t.stepName,{color:e.fill,colorProfileAssetKey:(l=s.colorProfile)==null?void 0:l.key}):n.updateStorage(t.stepName,{color:e.fill});for(const c of a){if(!e.fill)throw new Error("Fill not set on new color selection!");const d=new lr(c.id,e.fill,o);i(d)}}async availableFillImages(t){var a,n;const e=t.data.imageFillOption;if(e){const i=((n=(a=e.variants)==null?void 0:a.map(s=>{var o;return(o=s.asset)==null?void 0:o.fileLink}))==null?void 0:n.filter(s=>!!s))||[];return Promise.all(i.map(async s=>{const o=await ha(s);return{src:s,width:o.width,height:o.height,scale:t.data.imageFillScale||1}}))}return Promise.resolve([])}async changeFillImage(t,e,a,n){var o,l;if(!t.data||!t.data.regions)return;const i=n.getCommandDispatcher(),s=(l=(o=t.option)==null?void 0:o.variants)==null?void 0:l.find(c=>{var d;return((d=c.asset)==null?void 0:d.fileLink)===e.src});n.updateMetadata(t.stepName,{fillImage:s==null?void 0:s.name}),n.updateStorage(t.stepName,{fillImage:e});for(const c of a){const d=new _e(c.id,e);i(d)}}availableStrokeColors(t){var n;const e=this.cachedStrokeColors.get(t.stepName);if(e)return e;const a=t.data.strokeOption;if(a){const i=((n=a.variants)==null?void 0:n.map(s=>({fill:s.color,stroke:s.color,variant:s})))||[];return this.cachedStrokeColors.set(t.stepName,i),i}return[]}async changeStrokeColor(t,e,a,n){var o;if(!t.data||!t.data.regions)return;const i=n.getCommandDispatcher();e!=null&&e.variant?n.updateMetadata(t.stepName,{strokeColor:e.variant.name}):n.updateMetadata(t.stepName,{strokeColor:e==null?void 0:e.fill});const s=e?{browserValue:e.fill,pmsValue:e.pmsValue}:void 0;n.updateStorage(t.stepName,{strokeColor:s});for(const l of a){const c=new Xe(l.id,s,(o=t.data)==null?void 0:o.strokeThickness);i(c)}}getProcessedInput(t,e,a){const n=a?t:this.injectReplaceableText(t,e);return De(n,{vertical:e.vertical,uppercase:e.uppercase})}updateInputText(t,e,a,n){const i=n.getStepStorage(a.stepName),s=this.getProcessedInput(t,a.data,(i==null?void 0:i.customiseAllText)??!1),o=ne(t,n),l={command:void 0,helperData:{},errorData:this.getErrorsForText(t,o,a,n)};if(l.errorData)return l;l.helperData.charactersRemaining=a.data.maxLength-o.length;const c=[],d=new Map,A=new Map;for(const u of e){if(!u.fontData)throw new z("Failed to resolve font data for text.");const[h,g]=Kt(u.fontSize,u.fontData,{left:u.x,top:u.y,width:u.width,height:u.height,rotation:u.rotation,panelId:""},[s],{size:a.data.size,minSize:a.data.minSize,maxSize:a.data.maxSize});d.set(u.id,h),A.set(u.id,g);const m=a.data.curved?s:(g||[]).join(`
1474
- `);c.push(this.generateTextChangeCommandsForRegion(h,a.data,u.id,m))}return!a.data.curved&&e.length>0&&!Array.from(A.values()).every(h=>h)?(l.errorData||(l.errorData={}),l.errorData.doesNotFit=!0,l):(n.updateStorage(a.stepName,{text:t}),n.updateMetadata(a.stepName,{text:s}),(i!=null&&i.defaultCleared||!a.data.deleteDefaultOnFocus)&&s.trim()!==""&&n.setMandatoryFulfilled(a.stepName,!0),l.command=new $(c),l)}async selectVariant(t,e,a,n,i){const s=await this.selectVariantCommand(t,e,a.getStepStorage(t.stepName)||{},a.getRegionElements(t.stepName),a,n,i);s&&(s.command&&a.getCommandDispatcher()(s.command),s.followup&&await s.followup())}createTextFillSpotColor(t,e){const a=t.colorProfile;if(a){const n=(a.name||"").replace(/\s/g,"-"),i=n.lastIndexOf("/"),o=n.slice(i+1).slice(0,-4);if(!e.namedColor)throw new Error("variant named color not set!");return{profileName:o,namedColor:e.namedColor}}}async reload(t,e,a){var c,d,A,u,h;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),o=Object.values(a.layouts).map(g=>g.elements).flat().filter(g=>g.stepName===t.stepName),l=t.option;if(n!=null&&n.selectedVariants){const g=n.selectedVariants[0].id;if(l&&g){const m=(c=l.variants)==null?void 0:c.find(p=>p.id===g);if(m){const p=await this.fontDataFromVariant(m),f=o.map(y=>({id:y.id,region:y.stepRegion})),C=(d=n.storage)==null?void 0:d.color;let w=(A=n.storage)==null?void 0:A.text;const S=e.getWorkflowExperience().getBundle();if(S&&t.globalPropertyAspectConfigurations){const y=(u=S.getGlobalPropertyConfiguration())==null?void 0:u.aspects,E=y==null?void 0:y.find(b=>{var P;return b.type===V.Text&&((P=t.globalPropertyAspectConfigurations)==null?void 0:P.map(x=>x.aspectName).includes(b.name))});if(E){const P=S.getGlobalPropertyStateManager().getAspect(E.name);P&&(w=P)}}if(await e.setSelectionsAndElements(t.stepName,[m],f,async()=>{e.updateMetadata(t.stepName,{color:C,text:w}),e.updateStorage(t.stepName,{text:w,inputText:w});const y=o.map(b=>new ga(b.id,p)),E=new $(y);e.getCommandDispatcher()(E)}),o.length===0&&l){const y=H.getDefaultVariant(l);if(y){const E=await this.selectVariantCommand(t,y,{text:w},[],e,()=>{},()=>{});e.getCommandDispatcher()(E.command)}}else{const{command:y}=W.updateInputText(w||"",o,t,e);y&&e.getCommandDispatcher()(y)}}}}else{const g=e.getWorkflowExperience().getBundle();if(g&&t.globalPropertyAspectConfigurations){const m=(h=g.getGlobalPropertyConfiguration())==null?void 0:h.aspects,p=m==null?void 0:m.find(f=>{var C;return f.type===V.Text&&((C=t.globalPropertyAspectConfigurations)==null?void 0:C.map(w=>w.aspectName).includes(f.name))});if(p){const C=g.getGlobalPropertyStateManager().getAspect(p.name);if(C)if(o.length===0&&l){const w=H.getDefaultVariant(l);if(w){const S=await this.selectVariantCommand(t,w,{text:C},[],e,()=>{},()=>{});e.getCommandDispatcher()(S.command)}}else{const{command:w}=W.updateInputText(C,o,t,e);w&&e.getCommandDispatcher()(w)}}}}}getDefaultColorVariant(t){const e=t.colorOption;if(e)return H.getDefaultVariant(e)}getDefaultColor(t){const e=t.colorOption;if(!e)return;const a=H.getDefaultVariant(e);return a==null?void 0:a.color}getDefaultImageFillVariant(t){const e=t.imageFillOption;if(e)return H.getDefaultVariant(e)}getDefaultStrokeColorVariant(t){const e=t.strokeOption;if(e)return H.getDefaultVariant(e)}async fontDataFromVariant(t){const e=t.asset;if(!e)throw new mt(t);const a=e.fileLink;if(!a)throw new Nt(e);const n=await It(a);return{assetUrl:a,name:n.names.fullName.en}}async selectVariantCommand(t,e,a,n,i,s,o,l,c){var u;const d=i.markUpdatePending(),A=await this.fontDataFromVariant(e);if(n.length>0){const h=n.map(p=>new ga(p.id,A));if(l){const p=n.map(f=>new _e(f.id,l));h.push(...p)}if(c){const p=n.map(f=>new Xe(f.id,c,t.data.strokeThickness));h.push(...p)}const g=await this.changeInputTextWithRegion(t,t.data.size||ta,A,a.text||"",a,i,(a==null?void 0:a.customiseAllText)??!1,s,o);return g&&h.push(g),{command:new $(h),followup:async()=>{i.markUpdateCompleted(d),await i.setSelectionsAndElements(t.stepName,[e],n)}}}else{const h=await this.createTextboxRegions(t.stepName,e,t.data,A,a,i),g=await this.changeInputTextWithRegion(t,t.data.size||ta,A,((u=h[0])==null?void 0:u.newElement.input)||a.text||t.data.defaultText||"",a,i,(a==null?void 0:a.customiseAllText)??!1,s,o),m=h.flatMap(f=>f.commands);if(l){const f=h.map(C=>new _e(C.regionElement.id,l));m.push(...f)}if(c){const f=n.map(C=>new Xe(C.id,c,t.data.strokeThickness));m.push(...f)}return g&&m.push(g),{command:new $(m),followup:async()=>{i.markUpdateCompleted(d)}}}}injectReplaceableText(t,e){return e.replaceableText?e.replaceableText.replace("{{}}",t):t}async createTextboxRegions(t,e,a,n,i,s){if(!a||!a.regions)throw new Error("Step data not supplied");const o=i.text||a.defaultText||"",l=this.getProcessedInput(o,a,!1),c=async A=>{var m;const h=s.getLayouts().find(p=>p.panelId===A.panelId),g=Q();try{if(!h)throw new ke("Failed to find layout for region: "+A.panelId);const p=a.colorOption;let f;if(p&&p.variants){const T=p.variants.find(Z=>{var R;return Z.id===((R=p.defaultVariant)==null?void 0:R.id)})||p.variants[0];f=this.createTextFillSpotColor(p,T),s.updateStorage(t,{colorProfileAssetKey:(m=p.colorProfile)==null?void 0:m.key})}const C=await this.getDefaultColor(a),w=C||"#000000",S={stepRegion:A,stepName:t,align:this.textAlign(a),fill:i.color?i.color:w,fontSize:a.size||ta,fontData:n,id:g,layer:A.layer,layerIndex:A.layerIndex,rotation:A.rotation,text:l,input:o,type:k.Textbox,vertical:a.vertical,x:A.left,y:A.top,height:A.height,width:A.width,immutable:A.immutable,verticalAlign:a.verticalAlign||"middle",curved:a.curved,paths:a.paths,fillSpotColorDefinition:f},y=[],E=new Map,b=new Map;if(!S.fontData)throw new z("Failed to resolve font data for text.");const[P,x]=Kt(S.fontSize,S.fontData,{left:S.x,top:S.y,width:S.width,height:S.height,rotation:S.rotation,panelId:""},[l],{size:a.size,minSize:a.minSize,maxSize:a.maxSize});E.set(S.id,P),b.set(S.id,x);const F=a.curved||a.vertical?l:(x||[]).join(`
1475
- `);y.push(this.generateTextChangeCommandsForRegion(P,a,S.id,F));const M=new q(S,h);return{regionElement:{id:g,region:A},commands:[M,...y],newElement:S,fontData:n}}catch(p){throw console.log(p),new Fe("Error adding font to region")}},d=await Promise.all(a.regions.map(c)).catch(A=>{throw A instanceof Fe?(gr.setLatestToast("Failed to load font.",me.Error),A):A instanceof ke?A:new Error(A)});return await s.setSelectionsAndElements(t,[e],d.map(A=>A.regionElement),async()=>{s.updateMetadata(t,{text:o}),s.updateStorage(t,{text:o})}),d}generateTextChangeCommandsForRegion(t,e,a,n){const i=[],s=new Ar(a,n);if(i.push(s),!e.size){const l=new cr(a,t);i.push(l)}return new $(i)}async changeInputTextWithRegion(t,e,a,n,i,s,o,l,c,d){const A=(n||"").replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,""),u=this.getProcessedInput(A,t.data,o),h=s.getRegionElements(t.stepName),g=new Map,m=new Map;for(const S of h)if(S.region){const[y,E]=Kt(e,a,S.region,[u],{size:t.data.size,minSize:t.data.minSize,maxSize:t.data.maxSize});g.set(S.id,y),m.set(S.id,E)}const f=(()=>{const S=ne(u,s);if(t.data&&t.data.maxLength&&S.length>t.data.maxLength)return d&&d(!0),{info:"0"};const y=s.getProfanities(),E=ia.split(u.toLowerCase());for(const b of E)for(const P in y){const x=y[P].toLowerCase().replace(/\s/g,"");if(b===x)return l(!0),{error:"Blocked profanity."}}return!t.data.vertical&&!t.data.allowNewlines&&(u.includes(`
1494
+ `,f={};f[this.shapeFillId]={browserValue:m};const C=Q();return{id:C,region:h,command:new G({stepRegion:h,stepName:t.stepName,colors:f,id:C,svg:p,type:M.Illustration,y:h.top,x:h.left,rotation:h.rotation,width:h.width,height:h.height,layer:h.layer,layerIndex:h.layerIndex,immutable:h.immutable,excludeFromExport:t.data.excludeFromPrint},g)}},d=t.data.regions.map(c),A=d.filter(h=>!!h).map(h=>h==null?void 0:h.command),u=d.filter(h=>!!h).map(h=>({id:h.id,region:h.region}));return{command:new $(A),followup:async()=>{await n.setSelectionsAndElements(t.stepName,e.variant?[e.variant]:[],u,async()=>{n.updateStorage(t.stepName,{colour:o()})})}}}}}const kt=new To;class No{constructor(){this.latestToast=null,this.toastType=null,this.toastCallbacks=[]}addToastCallback(t){t({toastMessage:this.latestToast,toastType:this.toastType}),this.toastCallbacks.push(t)}removeToastCallback(t){this.toastCallbacks=this.toastCallbacks.filter(e=>e!==t)}setLatestToast(t,e){this.latestToast=t,this.toastType=e,this.onToastChange()}onToastChange(){this.toastCallbacks.forEach(t=>t({toastMessage:this.latestToast,toastType:this.toastType}))}}const mr=new No,Ze=(r,t,e,a,n)=>{if(t.some(d=>d==null))throw new Error(`Failed to autosize lines: ${t.join(", ")}`);let i=t.map(d=>d.split(`
1495
+ `)).flat(),s=i.length,o=i.map(d=>gt(d,a,n));const l=n.getApproximateHeight()*a;let c=!0;for(;c;){if(l+(s-1)*e>r.height)return[null,null];const A=Math.max(...o);if(A<=r.width)return[i,A];const u=o.reduce((p,f,C,w)=>f>w[p]?C:p,0),h=i[u];let g=!1,m=h.length;for(;!g&&m>-1;){m=h.lastIndexOf(" ",m-1);const p=[h.slice(0,m),h.slice(m+1)],f=p.map(w=>gt(w,a,n));f[0]<=r.width&&(i=[...i.slice(0,u),...p,...i.slice(u+1)],o=[...o.slice(0,u),...f,...o.slice(u+1)],s+=1,g=!0)}g||(c=!1)}return[null,null]},Kt=(r,t,e,a,n)=>{let i,s;const o=bt(t.assetUrl),l=o.getFont();if(n.size){const u=r/l.unitsPerEm;return[i,s]=Ze(e,a,r,u,o),[n.size,i,s]}const c=6;let d=c-Ye;if(a.length>0){let u=a,h=0;for(;(!n.maxSize||d<=n.maxSize)&&u;)d+=Ye,h=d/l.unitsPerEm,[u,s]=Ze(e,a,d,h,o)}d>c&&(d-=Ye),n.minSize&&d<n.minSize&&(d=n.minSize);const A=d/l.unitsPerEm;return[i,s]=Ze(e,a,d,A,o),[d,i,s]},ta=30;class xe extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype),this.name=xe.name}}const Qo=["‘","’","“","”",`
1496
+ `];class ke extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype),this.name=ke.name}}class Ro{constructor(){this.cachedColors=new Map,this.cachedStrokeColors=new Map,this.filterUnsupportedCharacters=(t,e)=>{let a=t.replace(/(\r\n|\r|(\u2665|\u00a9|\u00ae|[\u2000-\u2017]|[\u201E-\u3300]]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]))/gm,"");const n=[],i=e?bt(e.assetUrl):void 0;if(i){const s=a.split("").filter(l=>!Qo.includes(l)).join(""),o=s.split("").map(l=>i.getFont().charToGlyph(l));for(let l=0;l<o.length;l++)o[l].name===".notdef"&&n.push(String.fromCharCode(s.charCodeAt(l)))}for(let s=0;s<n.length;s++)a=a.replaceAll(n[s],"");return a},this.textAlign=t=>t.vertical?"center":t.textAlign||"center",this.getErrorsForText=(t,e,a,n)=>{let i;a.data&&a.data.maxLength&&e.length>a.data.maxLength&&(i||(i={}),i.hitCharacterLimit=!0);const s=n.getProfanities(),o=ia.split(t.toLowerCase());for(const c of o)for(const d in s){const A=s[d].toLowerCase().replace(/\s/g,"");if(c===A){i||(i={}),i.blockedProfanity=!0;break}}return!a.data.allowNewlines&&(t.includes(`
1497
+ `)||t.includes("\r"))&&(i||(i={}),i.illegalMultipleLines=!0),i}}async init(t,e,a){var i,s,o,l;const n=t.option;if(!n)return null;if(a)await this.reload(t,e,a);else{const c=this.getDefaultImageFillVariant(t.data),d=(i=c==null?void 0:c.asset)==null?void 0:i.fileLink,A=d?await ha(d):void 0,u=A?{src:A.src,height:A.height,width:A.width,scale:t.data.imageFillScale||1}:void 0,h=this.getDefaultStrokeColorVariant(t.data),g=t.data.strokeEnabled&&(h!=null&&h.color)?{browserValue:h.color,pmsValue:h.name}:void 0;let m=t.data.defaultText||"";const p=e.getWorkflowExperience().getBundle();if(p&&t.globalPropertyAspectConfigurations){const C=(s=p.getGlobalPropertyConfiguration())==null?void 0:s.aspects,w=C==null?void 0:C.find(S=>{var y;return S.type===V.Text&&((y=t.globalPropertyAspectConfigurations)==null?void 0:y.map(E=>E.aspectName).includes(S.name))});if(w){const y=p.getGlobalPropertyStateManager().getAspect(w.name);y&&(m=y)}}e.updateStorage(t.stepName,{text:m,inputText:t.data.defaultText||"",color:((o=this.getDefaultColorVariant(t.data))==null?void 0:o.color)||this.getDefaultColor(t.data),fillImage:u,strokeColor:g}),e.updateMetadata(t.stepName,{text:m,color:((l=this.getDefaultColorVariant(t.data))==null?void 0:l.name)||this.getDefaultColor(t.data),fillImage:c==null?void 0:c.name,strokeColor:t.data.strokeEnabled?h==null?void 0:h.color:void 0});const f=H.getDefaultVariant(n);if(f)return this.selectVariantCommand(t,f,{text:m},[],e,()=>{},()=>{},u,g)}return null}findLayoutElements(t,e){return t.getRegionElements(e.stepName).map(i=>L(i.id,t.getAllLayoutData()))}availableFillColors(t){var n;const e=this.cachedColors.get(t.stepName);if(e)return e;const a=t.data.colorOption;if(a){const i=((n=a.variants)==null?void 0:n.map(s=>({fill:s.color,stroke:s.color,variant:s})))||[];return this.cachedColors.set(t.stepName,i),i}return[]}changeAlignment(t,e,a,n){if(!t.data||!t.data.regions)return;const i=n.getCommandDispatcher();for(const s of a){const o=new Ar(s.id,e);i(o)}}async changeFillColor(t,e,a,n){var l;if(!t.data||!t.data.regions)return;const i=n.getCommandDispatcher();e.variant?n.updateMetadata(t.stepName,{color:e.variant.name}):n.updateMetadata(t.stepName,{color:e.fill});const s=t.data.colorOption,o=s?this.createTextFillSpotColor(s,e.variant):void 0;s?n.updateStorage(t.stepName,{color:e.fill,colorProfileAssetKey:(l=s.colorProfile)==null?void 0:l.key}):n.updateStorage(t.stepName,{color:e.fill});for(const c of a){if(!e.fill)throw new Error("Fill not set on new color selection!");const d=new cr(c.id,e.fill,o);i(d)}}async availableFillImages(t){var a,n;const e=t.data.imageFillOption;if(e){const i=((n=(a=e.variants)==null?void 0:a.map(s=>{var o;return(o=s.asset)==null?void 0:o.fileLink}))==null?void 0:n.filter(s=>!!s))||[];return Promise.all(i.map(async s=>{const o=await ha(s);return{src:s,width:o.width,height:o.height,scale:t.data.imageFillScale||1}}))}return Promise.resolve([])}async changeFillImage(t,e,a,n){var o,l;if(!t.data||!t.data.regions)return;const i=n.getCommandDispatcher(),s=(l=(o=t.option)==null?void 0:o.variants)==null?void 0:l.find(c=>{var d;return((d=c.asset)==null?void 0:d.fileLink)===e.src});n.updateMetadata(t.stepName,{fillImage:s==null?void 0:s.name}),n.updateStorage(t.stepName,{fillImage:e});for(const c of a){const d=new _e(c.id,e);i(d)}}availableStrokeColors(t){var n;const e=this.cachedStrokeColors.get(t.stepName);if(e)return e;const a=t.data.strokeOption;if(a){const i=((n=a.variants)==null?void 0:n.map(s=>({fill:s.color,stroke:s.color,variant:s})))||[];return this.cachedStrokeColors.set(t.stepName,i),i}return[]}async changeStrokeColor(t,e,a,n){var o;if(!t.data||!t.data.regions)return;const i=n.getCommandDispatcher();e!=null&&e.variant?n.updateMetadata(t.stepName,{strokeColor:e.variant.name}):n.updateMetadata(t.stepName,{strokeColor:e==null?void 0:e.fill});const s=e?{browserValue:e.fill,pmsValue:e.pmsValue}:void 0;n.updateStorage(t.stepName,{strokeColor:s});for(const l of a){const c=new Xe(l.id,s,(o=t.data)==null?void 0:o.strokeThickness);i(c)}}getProcessedInput(t,e,a){const n=a?t:this.injectReplaceableText(t,e);return Fe(n,{vertical:e.vertical,uppercase:e.uppercase})}updateInputText(t,e,a,n){const i=n.getStepStorage(a.stepName),s=this.getProcessedInput(t,a.data,(i==null?void 0:i.customiseAllText)??!1),o=ne(t,n),l={command:void 0,helperData:{},errorData:this.getErrorsForText(t,o,a,n)};if(l.errorData)return l;l.helperData.charactersRemaining=a.data.maxLength-o.length;const c=[],d=new Map,A=new Map;for(const u of e){if(!u.fontData)throw new z("Failed to resolve font data for text.");const[h,g]=Kt(u.fontSize,u.fontData,{left:u.x,top:u.y,width:u.width,height:u.height,rotation:u.rotation,panelId:""},[s],{size:a.data.size,minSize:a.data.minSize,maxSize:a.data.maxSize});d.set(u.id,h),A.set(u.id,g);const m=a.data.curved?s:(g||[]).join(`
1498
+ `);c.push(this.generateTextChangeCommandsForRegion(h,a.data,u.id,m))}return!a.data.curved&&e.length>0&&!Array.from(A.values()).every(h=>h)?(l.errorData||(l.errorData={}),l.errorData.doesNotFit=!0,l):(n.updateStorage(a.stepName,{text:t}),n.updateMetadata(a.stepName,{text:s}),(i!=null&&i.defaultCleared||!a.data.deleteDefaultOnFocus)&&s.trim()!==""&&n.setMandatoryFulfilled(a.stepName,!0),l.command=new $(c),l)}async selectVariant(t,e,a,n,i){const s=await this.selectVariantCommand(t,e,a.getStepStorage(t.stepName)||{},a.getRegionElements(t.stepName),a,n,i);s&&(s.command&&a.getCommandDispatcher()(s.command),s.followup&&await s.followup())}createTextFillSpotColor(t,e){const a=t.colorProfile;if(a){const n=(a.name||"").replace(/\s/g,"-"),i=n.lastIndexOf("/"),o=n.slice(i+1).slice(0,-4);if(!e.namedColor)throw new Error("variant named color not set!");return{profileName:o,namedColor:e.namedColor}}}async reload(t,e,a){var c,d,A,u,h;const n=e.getSerializedStep(t.stepName,a.serializableWorkflow.steps),o=Object.values(a.layouts).map(g=>g.elements).flat().filter(g=>g.stepName===t.stepName),l=t.option;if(n!=null&&n.selectedVariants){const g=n.selectedVariants[0].id;if(l&&g){const m=(c=l.variants)==null?void 0:c.find(p=>p.id===g);if(m){const p=await this.fontDataFromVariant(m),f=o.map(y=>({id:y.id,region:y.stepRegion})),C=(d=n.storage)==null?void 0:d.color;let w=(A=n.storage)==null?void 0:A.text;const S=e.getWorkflowExperience().getBundle();if(S&&t.globalPropertyAspectConfigurations){const y=(u=S.getGlobalPropertyConfiguration())==null?void 0:u.aspects,E=y==null?void 0:y.find(b=>{var P;return b.type===V.Text&&((P=t.globalPropertyAspectConfigurations)==null?void 0:P.map(D=>D.aspectName).includes(b.name))});if(E){const P=S.getGlobalPropertyStateManager().getAspect(E.name);P&&(w=P)}}if(await e.setSelectionsAndElements(t.stepName,[m],f,async()=>{e.updateMetadata(t.stepName,{color:C,text:w}),e.updateStorage(t.stepName,{text:w,inputText:w});const y=o.map(b=>new ga(b.id,p)),E=new $(y);e.getCommandDispatcher()(E)}),o.length===0&&l){const y=H.getDefaultVariant(l);if(y){const E=await this.selectVariantCommand(t,y,{text:w},[],e,()=>{},()=>{});e.getCommandDispatcher()(E.command)}}else{const{command:y}=W.updateInputText(w||"",o,t,e);y&&e.getCommandDispatcher()(y)}}}}else{const g=e.getWorkflowExperience().getBundle();if(g&&t.globalPropertyAspectConfigurations){const m=(h=g.getGlobalPropertyConfiguration())==null?void 0:h.aspects,p=m==null?void 0:m.find(f=>{var C;return f.type===V.Text&&((C=t.globalPropertyAspectConfigurations)==null?void 0:C.map(w=>w.aspectName).includes(f.name))});if(p){const C=g.getGlobalPropertyStateManager().getAspect(p.name);if(C)if(o.length===0&&l){const w=H.getDefaultVariant(l);if(w){const S=await this.selectVariantCommand(t,w,{text:C},[],e,()=>{},()=>{});e.getCommandDispatcher()(S.command)}}else{const{command:w}=W.updateInputText(C,o,t,e);w&&e.getCommandDispatcher()(w)}}}}}getDefaultColorVariant(t){const e=t.colorOption;if(e)return H.getDefaultVariant(e)}getDefaultColor(t){const e=t.colorOption;if(!e)return;const a=H.getDefaultVariant(e);return a==null?void 0:a.color}getDefaultImageFillVariant(t){const e=t.imageFillOption;if(e)return H.getDefaultVariant(e)}getDefaultStrokeColorVariant(t){const e=t.strokeOption;if(e)return H.getDefaultVariant(e)}async fontDataFromVariant(t){const e=t.asset;if(!e)throw new mt(t);const a=e.fileLink;if(!a)throw new Nt(e);const n=await It(a);return{assetUrl:a,name:n.names.fullName.en}}async selectVariantCommand(t,e,a,n,i,s,o,l,c){var u;const d=i.markUpdatePending(),A=await this.fontDataFromVariant(e);if(n.length>0){const h=n.map(p=>new ga(p.id,A));if(l){const p=n.map(f=>new _e(f.id,l));h.push(...p)}if(c){const p=n.map(f=>new Xe(f.id,c,t.data.strokeThickness));h.push(...p)}const g=await this.changeInputTextWithRegion(t,t.data.size||ta,A,a.text||"",a,i,(a==null?void 0:a.customiseAllText)??!1,s,o);return g&&h.push(g),{command:new $(h),followup:async()=>{i.markUpdateCompleted(d),await i.setSelectionsAndElements(t.stepName,[e],n)}}}else{const h=await this.createTextboxRegions(t.stepName,e,t.data,A,a,i),g=await this.changeInputTextWithRegion(t,t.data.size||ta,A,((u=h[0])==null?void 0:u.newElement.input)||a.text||t.data.defaultText||"",a,i,(a==null?void 0:a.customiseAllText)??!1,s,o),m=h.flatMap(f=>f.commands);if(l){const f=h.map(C=>new _e(C.regionElement.id,l));m.push(...f)}if(c){const f=n.map(C=>new Xe(C.id,c,t.data.strokeThickness));m.push(...f)}return g&&m.push(g),{command:new $(m),followup:async()=>{i.markUpdateCompleted(d)}}}}injectReplaceableText(t,e){return e.replaceableText?e.replaceableText.replace("{{}}",t):t}async createTextboxRegions(t,e,a,n,i,s){if(!a||!a.regions)throw new Error("Step data not supplied");const o=i.text||a.defaultText||"",l=this.getProcessedInput(o,a,!1),c=async A=>{var m;const h=s.getLayouts().find(p=>p.panelId===A.panelId),g=Q();try{if(!h)throw new ke("Failed to find layout for region: "+A.panelId);const p=a.colorOption;let f;if(p&&p.variants){const N=p.variants.find(rt=>{var R;return rt.id===((R=p.defaultVariant)==null?void 0:R.id)})||p.variants[0];f=this.createTextFillSpotColor(p,N),s.updateStorage(t,{colorProfileAssetKey:(m=p.colorProfile)==null?void 0:m.key})}const C=await this.getDefaultColor(a),w=C||"#000000",S={stepRegion:A,stepName:t,align:this.textAlign(a),fill:i.color?i.color:w,fontSize:a.size||ta,fontData:n,id:g,layer:A.layer,layerIndex:A.layerIndex,rotation:A.rotation,text:l,input:o,type:M.Textbox,vertical:a.vertical,x:A.left,y:A.top,height:A.height,width:A.width,immutable:A.immutable,verticalAlign:a.verticalAlign||"middle",curved:a.curved,paths:a.paths,fillSpotColorDefinition:f},y=[],E=new Map,b=new Map;if(!S.fontData)throw new z("Failed to resolve font data for text.");const[P,D]=Kt(S.fontSize,S.fontData,{left:S.x,top:S.y,width:S.width,height:S.height,rotation:S.rotation,panelId:""},[l],{size:a.size,minSize:a.minSize,maxSize:a.maxSize});E.set(S.id,P),b.set(S.id,D);const x=a.curved||a.vertical?l:(D||[]).join(`
1499
+ `);y.push(this.generateTextChangeCommandsForRegion(P,a,S.id,x));const k=new G(S,h);return{regionElement:{id:g,region:A},commands:[k,...y],newElement:S,fontData:n}}catch(p){throw console.log(p),new xe("Error adding font to region")}},d=await Promise.all(a.regions.map(c)).catch(A=>{throw A instanceof xe?(mr.setLatestToast("Failed to load font.",me.Error),A):A instanceof ke?A:new Error(A)});return await s.setSelectionsAndElements(t,[e],d.map(A=>A.regionElement),async()=>{s.updateMetadata(t,{text:o}),s.updateStorage(t,{text:o})}),d}generateTextChangeCommandsForRegion(t,e,a,n){const i=[],s=new ur(a,n);if(i.push(s),!e.size){const l=new dr(a,t);i.push(l)}return new $(i)}async changeInputTextWithRegion(t,e,a,n,i,s,o,l,c,d){const A=(n||"").replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,""),u=this.getProcessedInput(A,t.data,o),h=s.getRegionElements(t.stepName),g=new Map,m=new Map;for(const S of h)if(S.region){const[y,E]=Kt(e,a,S.region,[u],{size:t.data.size,minSize:t.data.minSize,maxSize:t.data.maxSize});g.set(S.id,y),m.set(S.id,E)}const f=(()=>{const S=ne(u,s);if(t.data&&t.data.maxLength&&S.length>t.data.maxLength)return d&&d(!0),{info:"0"};const y=s.getProfanities(),E=ia.split(u.toLowerCase());for(const b of E)for(const P in y){const D=y[P].toLowerCase().replace(/\s/g,"");if(b===D)return l(!0),{error:"Blocked profanity."}}return!t.data.vertical&&!t.data.allowNewlines&&(u.includes(`
1476
1500
  `)||u.includes("\r"))?(l(!0),{error:"Cannot span multiple lines."}):!t.data.curved&&!Array.from(m.values()).every(P=>P)?(l(!0),{error:"Does not fit."}):(l(!1),{info:(t.data.maxLength-S.length).toString()})})();if(f.error){c(f.error);return}if(c(`${f.info} characters remaining`||""),d)return;s.updateStorage(t.stepName,{text:A}),s.updateMetadata(t.stepName,{text:this.injectReplaceableText(A,t.data)}),(i.defaultCleared||!t.data.deleteDefaultOnFocus)&&A.trim()!==""&&s.setMandatoryFulfilled(t.stepName,!0);const C=[];for(const S of h){const y=t.data.curved?u:(m.get(S.id)||[]).join(`
1477
- `);C.push(this.generateTextChangeCommandsForRegion(g.get(S.id)||1,t.data,S.id,y))}return new $(C)}}const W=new Qo;class Ro{}const Oo="data:application/octet-stream;base64,AAEAAAAPAIAAAwBwRkZUTYdHeHoAAElcAAAAHEdERUYAJwBUAAAe2AAAAB5HUE9TkNtcVAAAHygAACoyR1NVQrj/uP4AAB74AAAAME9TLzJoWmUcAAABeAAAAGBjbWFwtkIacAAAAxAAAAJWZ2FzcP//AAMAAB7QAAAACGdseWY27KOUAAAGCAAAFcRoZWFkFPal0gAAAPwAAAA2aGhlYQU0Ar0AAAE0AAAAJGhtdHiADw6qAAAB2AAAAThsb2Nh5CzfJAAABWgAAACebWF4cACVAEwAAAFYAAAAIG5hbWXeIPPyAAAbzAAAAiJwb3N0ABeZTwAAHfAAAADdAAEAAAABAAAZ9vREXw889QALA+gAAAAA2ZexNAAAAADZl7E0ADL/yQJ2ArwAAAAIAAIAAAAAAAAAAQAAArz/wwAAAqsAAAAAAnYAAQAAAAAAAAAAAAAAAAAAAE4AAQAAAE4ASQAFAAAAAAACAAAAAQABAAAAQAAAAAAAAAAEAbsBkAAFAAACigK7AAAAjAKKArsAAAHfADEBAgAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAABYWFhYAEAACgCtArz/wwAAAqkANgAAAAMAAAAAAmQCZAAAACAAAgIPADIAAAAAAU0AAAAAAAAAAAAAALQAAAD3ADUCfQA1AcoANQKrADUCDQA1AX4ANQHYADUBNQA1AcgANQHUADUB8AA1AeEANQHpADUBqQA1AdAANQHpADUCqgA1Af8ANQGaADUB3wA1AbgANQFtADUBbQA1AekANQG8ADUA1QA1AYcANQHBADUBUAA1AhsANQHBADUB4QA1AZYANQH0ADUBxQA1AcUAMgGJADUBwwA1Ad0ANQJ1ADUB9wA1AcoANQF6ADUB3AA1Af8ANQGaADUB3wA1AbgANQFtADUBbQA1AekANQG8ADUA1QA1AYcANQHBADUBUAA1AhsANQHBADUB4QA1AZYANQH0ADUBxQA1AcUAMgGJADUBwwA1Ad0ANQJ1ADUB9wA1AcoANQF6ADUAtAAAAAAAAAAAAAMAAAADAAAAHAABAAAAAAFQAAMAAQAAABwABAE0AAAALgAgAAQADgAAAAoADQAhACYAKgA5AFoAXgB6AKAArQDFAM8A1gDdAOUA7wD2AP0A/wF4//8AAAAAAAoADQAgACMAKgAwAEAAXgBhAKAArQDAAMcA0QDYAOAA5wDxAPgA/wF4//8AAf/5//f/5f/k/+H/3P/W/9P/0f+s/6AAAAAAAAAAAAAAAAAAAAAA/0v+twABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABYAIAAwADoARABOAF4AaAAAAAAAAAAXABcAFwAXABcAFwAZABsAGwAbABsAHwAfAB8AHwAkACUAJQAlACUAJQAlACsAKwArACsALwAyADIAMgAyADIAMgA0ADYANgA2ADYAOgA6ADoAOgA/AEAAQABAAEAAQABAAEYARgBGAEYASgAAAQYAAAEAAAAAAAAAAQIDAAAEAAAAAAAAAAAAAAAAAAAAAQAABQYABwgJCgAAAAsAAAAAAAwNDg8QERITFBUAAAAAAAAWFxgZGhscHR4fICEiIyQlJicoKSorLC0uLzAAAAAxAAAyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKSwAAAAAAFxcZGyQlKzIyMjIyMjQ2NjY2Ojo6Oj9AQEBAQEZGRkYAAAAAAAAAAAAAAAAAAAAlAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABMFxclAAAAAAAAAAAAAEovAAAAAAAAAAAAAAAXGxcbGx8fHx8lJQAlKysrAAAAAAAAAAAAAAAAAAAAACgAKAAoACgAKAAoADwAbgC0AQgBbgGQAcYB1AIGAkYCYAKSAtAC4gMoA2ADyAPgBBoEUAR4BI4EogTWBOoE9gUiBToFSAViBXoFqgXWBjAGWgaaBqwG2AbqBwYHIAc2B0wHXgd2B7AH5ggOCCQIOAhsCIAIjAi4CNAI3gj4CRAJQAlsCcYJ8AowCkIKbgqACpwKtgrMCuIK4griAAAABQAyAAAB3QK8AAMABgAJAAwADwAAEyERIRsCCwEREwMhAxMRMgGr/lUcubrGtMG5AXKttQK8/UQCqP7LATX+tgEs/acBGP7MAUn+0QJdAAACADUABQDCAmoAAwAHAAATESMRExUjNcGLi4sCaf5mAZr+KY2NAAAAAgA1AAACSAJkABsAHwAAJQcjNyMHIzcjNzM3IzczNzMHMzczBzMHIwczByc3IwcBthdrFkoXbBdeDl8KYA9fFWwVShVtFWoPagpqDscJSgqqqqqqqmxHbJqamppsR2xsR0cAAAEANf/JAZUCqgAwAAABFR4BByM0LgEjIgYVFBYXHgMVFA4BBxUjNS4BNTMUFjMyNjU0LgInJjU0Njc1ARwwPAF3CBQOExcsPCEwFgkZNyhnPkGDGRQTGBElHBprRzQCqkQNV0INGBIdFB8hGw4tMCkUJkU7EENDCmk8GiUgFBIeGA4LKXpKVxBEAAAABQA1/+8CdgJrAAwAGAAcACkAOAAAEzQ2MzIeARUUBiMiJjcVFBYzMjY1NCYiBiUDIxMDNTQ+ATMyFhQGIyImNxUUHgEzMjY1NC4BIyIGNk02JD0jTTc2TVEeFBUeHiodAWjhVeEtIz0kN01ONjZOUQ4YDRUeDhcOFR4B1j5XKEUoPldXPgEXISEYGCEhcf2dAmP+JgEoRChXfFdWPwEPGhAiGBAbDyIAAwA1AAAB2AJnACQAOQBIAAAlFwcnDgEjIiY1ND4CNyY1NDYzMhYVFA4IBxc3MyciBhUUHgQXPgU1NCYjAxY+ATcnDgUVFBYBmT8qQgdUMk1cDyETFDVTNzdPAwUJBw0HDgUMATUabPULGQQFCgUKAQENBAsEBBYNAQ8bEQRRAQ4ECwUEIbFNZEERMGJKHzMqEhFDQD9ZVjsLFxITDRAJDgULAUFBtRgSBw4LDwcOAQEQBg8LDwcPGf58AQsOB2IBDQUOCg8IGyQAAAAAAQA1ATwBSQJtABEAABMHNxcHFwcnFyM3Byc3JzcXJ+YXVSVnZyhTGE0WUShnZyVWGAJselJLJSVOVXp7Vk4nI0tReQACADUAAAGjAmQAFwAmAAA3NTQ+AzMyHgMdARQOAiMiLgI3FRQeATMyPQE0IyIOAjYZJzIvFxQtMicaIjc9Hh09OiR8CBsXOTkSGAsF4KQxTzEhDQwhMFAypDtaMhkYMlvjrBUkH1isVxEeGgABADUAAAEAAmEABQAAMxEjNTMRhE7KAd6D/Z8AAQA1AAMBkwJmACEAADc1Njc+AzU0JiMiByM+Ajc+AzMyFhUUBgcGBzMVOi5WFxkaCx0XMQJ2AQINDQ4qLCIQTlkjLkAargN3L1kYHCcoFyIhXhsgNxccJxIHbU04WDRHHYEAAAEANQAAAZ8CZAAtAAATNjc2MzIWFRQOAwcWFRQGIyImJyYnMxYXMjY1NC4DKwE1MzI1NCYjIgdDAjktP0RVCw0VCwlca0otVRYVBn4KLhobCg8UDQcsFT0RESQCAaxgMCdfQRcoGBcIBiVpTWwrKCRENgElHRAYCwcCbzsVHjMAAgA1//8BuwJjAAoADQAAITUjNRMzETMVIxUnMzUBDdfadDY20WJrcgGF/oN6a+XAAAAAAAEANf//AawCYwAgAAABFSMHNjMyHgIVFA4CIyIuASczFjMyNjU0JiMiBycTAX+uCxsnKUIlExYrSy8zUS8HfRYjGygkHy4SZSoCYoBSEic+QyEkSkIqL00xJi8hHy80HwFTAAACADUAAAG0AmIAFgAoAAABMhYVFAYjIiYnJjU0PwEzBw4BBzAyNgMyPgE1NC4EIyIGFRQeAQEaO19vTy9QGCksepBYAw4CCA0kEx8TBAgLDxQLHSUVHQGvbF9kgConOV1LVdqUBRYFAv7XFCYXChMSEAwHLyEaJxIAAAAAAQA1//8BdAJjAAYAABMhFQMjEyM2AT6sibS9AmJ3/hUB3wAAAwA1AAABmwJkABkAJAAuAAATNTQ2MhYVFA4BBxYVFA4BIi4BNTQ3LgMXFRQWMjY1NCYiBjcVFBYyNjQmIgZCVqBWFBAMPC1RaFEtPAkLEgpwHjAdHTAeCRskGxskGwG/AUJhYkIeMxINJGU5WjMzWjllJAkNHSbhARgqKhkaKirTARcfHy8fHwAAAAACADUAAAG0AmQAFgAkAAA/AT4BNyYOASMiJjU0NjMyFhcWFRQPARM1NC4BIyIGFRQWMzI2fVgDDQQBCA0EO15uTy9QGCoteSsVHhAcKCUfHiUBlAQWBgEBAWxfZIAqJzldTFXaAYkBGiYSLiIgMi4AAgA1/8wCdQJtADgASAAAAQcGBwYzMjY1NCYjIgYHBh4DFxY3FQYnLgQ3ND4CMzIWFRQGIyInBicuATU0NjMyFhc3BzY1NC4CJyYGHQEUFjc2AfscBAIBFhYmbFVhdgcBBhwtVThNX01cQGlGMBUBLExzQniZWjs3FB07NT1PQBwoBwgqCQIHEg0gKCAUIQG2ux0NGVo8Wm2Laxg2RTcpBAUfWxsCASlBVlsvQHpfOqF8XZBBNwEBWkRIcyAWKMkaIgcQGBEBAz8rAyYjAQIAAAIANQAAAcgCZQAHAAoAADcHIxMzEyMvAge8GG6bYJdvGhknK3JyAmT9nHJz1tYAAAMANQABAWQCaAAPABoAJQAANxEzMhcWFRQHFhUUBw4BIwMzMjc2NTQnJisBFxUzMjc2NTQnJiM2lEAiJC9DJhszNx0mEgkQEAgUJQExFAsVFAoWAgJlKShQUygka1cuIhMBfAYLIB4LBuNwCA4mIgwGAAAAAQA1AAABqQJnACUAACUzDgEjIi4CNTQ+AjMyHgMXIy4DIyIOARUUFjMyPgIBSWAQX0cxSiwWFStLMSM7KB4QA2AFDhQfER4pEi8qFCEUCulrfjNXbD47alk0HzJAPR0SISATNEwsSWcXJxkAAgA1AAABgwJlAA8AGAAAMxEzMh4DFxYVFA4CIwMRMzI1NCcmIzZ/EhcsICYOJBUtTzUiKF4TFzMCZAEMFi4hT29BbFcwAdr+r6dDLjkAAAABADUAAAE3AmUACwAAEyEVIxUzFSMVMxUhNgEBlpGSlv8AAmR4cHmKeQAAAAEANQAAATcCZQAJAAAzESEVIxUzFSMRNgEBmJOTAmR5b3r+/gAAAAABADUAAAG3AmYAIQAAARUmBw4CFRQeAjMyNzY3IzUzFgcGIyIuATU0NjMyFhcBQBQ3FygbEBkgESEWGQVr0wUTMH89WCpiX0haEAGbAUgCASNPOC1FKhUaHDlpZkOyVYlXiaZvWwAAAAEANQAAAYYCZQALAAAzIxEzFTM1MxEjNSOcZmaDZ2eDAmTm5v2c9QABADUAAACgAmUAAwAAMxEzETZpAmT9nAABADUAAAFRAmUAGgAAAREUBwYHBiMiLgMnJjUzFBYVFjMyNzY1EQFQDQ8fJi4IESsgIAUCcQEEGxUHBAJk/pZkLCscIwIRHkEsFxcCDAQzGxAhAZEAAAAAAQA1//8BiwJmAAoAABcRMxETMwMTIwMRNmdzbISTfnABAmb+7AEU/s/+zAEJ/vYAAQA1AAABGgJlAAUAADMRMxEzFTZpewJk/iaKAAEANQAAAeUCZQAMAAAzIxEzGwEzESMTAyMDlmCLTEuMYARZRVgCZP52AYr9nAHK/jYBygABADUAAAGMAmUACQAAGwEDMxEjAxMjEZ2NAWNikwJjAmT+lAFs/ZwBaf6XAmQAAAACADUAAAGsAmUADAAfAAATNDYzMhYVFA4BIyImNxQWMzI+BDU0LgIjIg4BNmRWUWs0VDRWZGgqKg8aEQ0IAwgSIhceJw4BLKGXmJpfjUaelUtjDxohKCcUHzo1IDVKAAACADUAAAFgAmYAEAAbAAATMzIeARcWFRQGBw4BKwEVIxMVMzI3NjU0JyYjNoEjMRoMLhcSFjEtKGRkJRoNGBkOHAJlCxMPO2cvWRkdGMAB3ZMJEi8uEQoAAwA1//8BvwJmABsALgA8AAAlFwYiLgInDgIjIi4BNTQ+ATMyFhUUBx4CAyIOBAc2MzIXFhc2NTQuAQMeAzsBMjcmJyYjIgG9AQINGRgcChMsFBM+VycmWD1Uah0GDQzAERwSDQcCARgVKCIbHQkbLGgGFRUTBgYWDhEOGSAPenkBAggSDRMTAlaGU1GIXK5/ZUkIBwEBZxIgHScLCBEoHzQeLTJOKP7/HCgQCQwiFSMAAAAAAgA1//8BjwJmAA0AGgAAJRcjJxUjETMXFhcWFRQnNjU0LgInKwEVMzIBDYF+cGpqOi4UW4QYCxARBQY1Lhb7++vqAmQBBQosgohEFyoVHg4IAZkAAQAyAAABjwJnACsAADczFBY3NjU0JicuAycmPgEzMhYXIy4DIyIGFRQWFx4BFRQOAiMiJjZ2JBIyJjwRICobAQE0TSs5WQp0AQMJEg0RHCdBQTEUJkQsXFbFKx8BBDgWIB4JFyg7ITlVKFRbCwwTCh0UFSIkJEc2JUE3IGkAAAABADUAAAFTAmUABwAAMxEjNSEVIxGLVQEdVQHseHj+FAAAAAABADUAAAGNAmUAGgAAEzMRFBceATI2NzY1ETMRFA4BBwYjIiYnLgE1NmsIBR8qHgUIagcQDjBUIk0ZGQwCZP6WLhsSGBYQFzUBa/6WM0MvFEEcJCZISwAAAQA1AAABpwJlAAYAADMDMxsBMwO2gGdQUWmAAmT+UwGt/ZwAAQA1AAACQAJkAAwAADMDMxsBMxsBMwMjCwGfaWk4PFA8OGhrWz4+AmP+cwGN/nEBj/2dAYz+dAABADUAAAHBAmUACwAAMxMDMxc3MwMTIycHNop6c0NCcnmJc1VRAUYBHq6u/t/+vdnZAAAAAQA1AAABlAJlAAkAADczAzMXNzMDFSOsAXdvQUFtd3HrAXn29v6H6wAAAAABADUAAAFDAmYACQAAAQMzFSE1EyM1IQFDiIj+85OTAQ0B5v6kimcBdYkAAAEANQFFAaYCagAGAAAbATMTIycHNnx3fYE4NwFFAST+3LOzAAIANQAAAcgCZQAHAAoAADcHIxMzEyMvAge8GG6bYJdvGhknK3JyAmT9nHJz1tYAAAMANQABAWQCaAAPABoAJQAANxEzMhcWFRQHFhUUBw4BIwMzMjc2NTQnJisBFxUzMjc2NTQnJiM2lEAiJC9DJhszNx0mEgkQEAgUJQExFAsVFAoWAgJlKShQUygka1cuIhMBfAYLIB4LBuNwCA4mIgwGAAAAAQA1AAABqQJnACUAACUzDgEjIi4CNTQ+AjMyHgMXIy4DIyIOARUUFjMyPgIBSWAQX0cxSiwWFStLMSM7KB4QA2AFDhQfER4pEi8qFCEUCulrfjNXbD47alk0HzJAPR0SISATNEwsSWcXJxkAAgA1AAABgwJlAA8AGAAAMxEzMh4DFxYVFA4CIwMRMzI1NCcmIzZ/EhcsICYOJBUtTzUiKF4TFzMCZAEMFi4hT29BbFcwAdr+r6dDLjkAAAABADUAAAE3AmUACwAAEyEVIxUzFSMVMxUhNgEBlpGSlv8AAmR4cHmKeQAAAAEANQAAATcCZQAJAAAzESEVIxUzFSMRNgEBmJOTAmR5b3r+/gAAAAABADUAAAG3AmYAIQAAARUmBw4CFRQeAjMyNzY3IzUzFgcGIyIuATU0NjMyFhcBQBQ3FygbEBkgESEWGQVr0wUTMH89WCpiX0haEAGbAUgCASNPOC1FKhUaHDlpZkOyVYlXiaZvWwAAAAEANQAAAYYCZQALAAAzIxEzFTM1MxEjNSOcZmaDZ2eDAmTm5v2c9QABADUAAACgAmUAAwAAMxEzETZpAmT9nAABADUAAAFRAmUAGgAAAREUBwYHBiMiLgMnJjUzFBYVFjMyNzY1EQFQDQ8fJi4IESsgIAUCcQEEGxUHBAJk/pZkLCscIwIRHkEsFxcCDAQzGxAhAZEAAAAAAQA1//8BiwJmAAoAABcRMxETMwMTIwMRNmdzbISTfnABAmb+7AEU/s/+zAEJ/vYAAQA1AAABGgJlAAUAADMRMxEzFTZpewJk/iaKAAEANQAAAeUCZQAMAAAzIxEzGwEzESMTAyMDlmCLTEuMYARZRVgCZP52AYr9nAHK/jYBygABADUAAAGMAmUACQAAGwEDMxEjAxMjEZ2NAWNikwJjAmT+lAFs/ZwBaf6XAmQAAAACADUAAAGsAmUADAAfAAATNDYzMhYVFA4BIyImNxQWMzI+BDU0LgIjIg4BNmRWUWs0VDRWZGgqKg8aEQ0IAwgSIhceJw4BLKGXmJpfjUaelUtjDxohKCcUHzo1IDVKAAACADUAAAFgAmYAEAAbAAATMzIeARcWFRQGBw4BKwEVIxMVMzI3NjU0JyYjNoEjMRoMLhcSFjEtKGRkJRoNGBkOHAJlCxMPO2cvWRkdGMAB3ZMJEi8uEQoAAwA1//8BvwJmABsALgA8AAAlFwYiLgInDgIjIi4BNTQ+ATMyFhUUBx4CAyIOBAc2MzIXFhc2NTQuAQMeAzsBMjcmJyYjIgG9AQINGRgcChMsFBM+VycmWD1Uah0GDQzAERwSDQcCARgVKCIbHQkbLGgGFRUTBgYWDhEOGSAPenkBAggSDRMTAlaGU1GIXK5/ZUkIBwEBZxIgHScLCBEoHzQeLTJOKP7/HCgQCQwiFSMAAAAAAgA1//8BjwJmAA0AGgAAJRcjJxUjETMXFhcWFRQnNjU0LgInKwEVMzIBDYF+cGpqOi4UW4QYCxARBQY1Lhb7++vqAmQBBQosgohEFyoVHg4IAZkAAQAyAAABjwJnACsAADczFBY3NjU0JicuAycmPgEzMhYXIy4DIyIGFRQWFx4BFRQOAiMiJjZ2JBIyJjwRICobAQE0TSs5WQp0AQMJEg0RHCdBQTEUJkQsXFbFKx8BBDgWIB4JFyg7ITlVKFRbCwwTCh0UFSIkJEc2JUE3IGkAAAABADUAAAFTAmUABwAAMxEjNSEVIxGLVQEdVQHseHj+FAAAAAABADUAAAGNAmUAGgAAEzMRFBceATI2NzY1ETMRFA4BBwYjIiYnLgE1NmsIBR8qHgUIagcQDjBUIk0ZGQwCZP6WLhsSGBYQFzUBa/6WM0MvFEEcJCZISwAAAQA1AAABpwJlAAYAADMDMxsBMwO2gGdQUWmAAmT+UwGt/ZwAAQA1AAACQAJkAAwAADMDMxsBMxsBMwMjCwGfaWk4PFA8OGhrWz4+AmP+cwGN/nEBj/2dAYz+dAABADUAAAHBAmUACwAAMxMDMxc3MwMTIycHNop6c0NCcnmJc1VRAUYBHq6u/t/+vdnZAAAAAQA1AAABlAJlAAkAADczAzMXNzMDFSOsAXdvQUFtd3HrAXn29v6H6wAAAAABADUAAAFDAmYACQAAAQMzFSE1EyM1IQFDiIj+85OTAQ0B5v6kimcBdYkAAAAAEADGAAEAAAAAAAEACAASAAEAAAAAAAIABwArAAEAAAAAAAMAFQBfAAEAAAAAAAQACACHAAEAAAAAAAUAIgDWAAEAAAAAAAYADwEZAAEAAAAAABAACAE7AAEAAAAAABEABwFUAAMAAQQJAAEAEAAAAAMAAQQJAAIADgAbAAMAAQQJAAMAKgAzAAMAAQQJAAQAEAB1AAMAAQQJAAUARACQAAMAAQQJAAYAHgD5AAMAAQQJABAAEAEpAAMAAQQJABEADgFEAFYAZQBnAGUAbQBpAHQAZQAAVmVnZW1pdGUAAFIAZQBnAHUAbABhAHIAAFJlZ3VsYXIAADEALgAwADAAMgA7AFYAZQBnAGUAbQBpAHQAZQBSAGUAZwB1AGwAYQByAAAxLjAwMjtWZWdlbWl0ZVJlZ3VsYXIAAFYAZQBnAGUAbQBpAHQAZQAAVmVnZW1pdGUAAFYAZQByAHMAaQBvAG4AIAAxAC4AMAAwADIAOwBGAG8AbgB0AHMAZQBsAGYAIABNAGEAawBlAHIAIAAzAC4AMwAuADAAAFZlcnNpb24gMS4wMDI7Rm9udHNlbGYgTWFrZXIgMy4zLjAAAFYAZQBnAGUAbQBpAHQAZQBSAGUAZwB1AGwAYQByAABWZWdlbWl0ZVJlZ3VsYXIAAFYAZQBnAGUAbQBpAHQAZQAAVmVnZW1pdGUAAFIAZQBnAHUAbABhAHIAAFJlZ3VsYXIAAAAAAgAAAAAAAP+DADIAAAAAAAAAAAAAAAAAAAAAAAAAAABOAAAAAQACAQIBAwADAAQABgAHAAgACQANABMAFAAVABYAFwAYABkAGgAbABwAIwAkACUAJgAnACgAKQAqACsALAAtAC4ALwAwADEAMgAzADQANQA2ADcAOAA5ADoAOwA8AD0AQQBEAEUARgBHAEgASQBKAEsATABNAE4ATwBQAFEAUgBTAFQAVQBWAFcAWABZAFoAWwBcAF0ArAEECWNvbnRyb2xMRgljb250cm9sQ1IKc29mdGh5cGhlbgAAAAAAAAH//wACAAEAAAAMAAAAFgAAAAIAAQABAE0AAQAEAAAAAgAAAAAAAQAAAAoALAAuAAJERkxUAA5sYXRuABgABAAAAAD//wAAAAQAAAAA//8AAAAAAAAAAQAAAAoAMAA+AAJERkxUAA5sYXRuABoABAAAAAD//wABAAAABAAAAAD//wABAAAAAWtlcm4ACAAAAAEAAAABAAQAAgAAAAEACAABKd4ABAAAAEYAlgEwAd4CjAM2A+AEegUsBWYGDAa+B3AIHgjQCYIKNAriC4gMAgx0DOYNZA3mDlQOyg88D54QEBCGEQARchHsEmIS1BOWFAwUghTwFWIV1BaiFxQXkhgEGMYZdBomGtQbfhwYHL4dYB3+HpgfPh/oIJYhPCHmIpQjRiPsJJolSCXuJpQnQifoKJIpRAAmAAn/8QAK//sADP/7AA3/+wAO//sAD//7ABD/+wAR//sAEv/7ABP/+wAU//sAFf/xABb/8QAZ//sAHf/2AB7/+wAf//sAIP/xACH/+wAi//sAI//7ACT/+wAl//EAJv/2ACf/8QAo//sAKf/2ACr/+wAr//sALP/sAC3/7AAu/+IAL//dADD/9gAx/+wAMv/7ADP/+wA0//YAKwAG//EACP/nAAn/4gAK/9MAC//iAAz/9gAN/+IADv/sAA//4gAQ/9gAEf/iABL/1QAT//EAFP/nABX/8QAW/9gAMf/TADL/pgAz//MANP/nADX/8QA2//EAN//7ADj/7gA5//YAOv/7ADv/2AA8//EAPf/2AD7/9gA///EAQP/sAEH/+wBC/+wAQ//xAET/7ABF/+wARv/2AEf/3QBI/90ASf/EAEr/zgBL//YAKwAG//YAB//2AAn/3QAL/+wADP/sAA3/8QAO//YAD//sABD/8QAR/+wAEv/iABP/5wAU/+wAFf/dABb/7AAX/78AMf/YADL/sAAz/+IANP/iADX/8QA2/+cAN//xADj/3QA5/+wAOv/2ADv/4gA8//EAPf/xAD7/8QA///YAQP/YAEH/9gBC/+cAQ//sAET/7ABF/+wARv/xAEf/zgBI/9MASf/OAEr/zgBL/+wAKgAG//YAB//iAAj/4gAK/+IADP/dAA3/ugAO/+IAD//iABD/5wAR/+IAEv/dABP/yQAU/90AFf+mABb/0wAx/5gAMv/YADP/4gA0/9MANf/xADb/7AA3/+wAOP/iADn/7AA6//EAO//dADz/5wA9/+wAPv/sAD//5wBA/9gAQf/sAEL/zgBD/+wARP/YAEX/tQBG/90AR/+hAEj/oQBJ/8QASv+DAEv/7AAqAAb/8QAH/90ACP/YAAn/oQAL/8kADP/iAA3/sAAO/+cAD//YABD/4gAR/90AEv/bABP/4gAU/+IAFf/TABb/5wAg/+QAMf/nADL/3AAz//QANP/rADX/9AA2//IAN//4ADj/8AA5//QAOv/1ADv/7AA8/+oAPf/7AD7/9wA///IAQP/tAEH/+wBC/+IAQ//2AET/4wBF/7YARv/vAEf/pgBK/6MAS//yACYAB//TAAj/8QAK/84ADP/dAA3/9gAO//EAD//dABD/pgAR/8kAEv+6ABP/7AAU/90AFf/OADH/xAAy/5IAM//sADT/3QA1/+cANv/xADf/9gA4/90AO/9WADz/5wA9//EAPv/sAD//5wBA/84AQf/dAEL/0wBD/+cARP/nAEX/5wBG/+cAR//dAEj/2ABJ/7oASv/JAEv/4gAsAAb/+wAH//sACP/xAAn/zgAK/+cAC//dAAz/9gAN/9gADv/tAA//7AAQ/+kAEf/rABL/3QAT/90AFP/hABX/3QAW/90AMf/nADL/vwAz/+cANP/nADX/8QA2//EAN//sADj/5wA5//YAOv/2ADv/4gA8//EAPf/2AD7/+wA///sAQP/2AEH/+wBC/+wAQ//7AET/7ABF/9MARv/7AEf/yQBI/84ASf+wAEr/xABL/+cADgAG//sACf/xAAv/7AAN//sADv/7AA8AAAAR//EAEv/0ABP/9gAU//EAFf/xABb/7AAx//YAQP/2ACkABv/7AAf/9gAI//sACf/iAAr/5wAL/+wADP/vAA3/3QAO//sAD//qABD/8QAR/+wAEv/nABP/8QAU/+cAFf/iABb/7AAx/+cAMv/vADP//AA0/+cANf/7ADb//gA4//EAOf/8ADr//AA7/+kAPP/6AD3//QA+//4AP//7AEL/6gBD//0ARP/2AEX/7ABG//EAR//YAEj/4gBJ/+wASv/LAEv//AAsAAb/+wAH//EACP/2AAn/0wAK/+IAC//JAAz/5wAN/90ADv/iAA//7AAQ/+cAEf/sABL/3QAT/9MAFP/iABX/zgAW/+cAMf/YADL/xAAz/+wANP/dADX/6AA2//EAN//xADj/4wA5//EAOv/2ADv/7AA8/+wAPf/sAD7/9gA//+wAQP/iAEH/8QBC/90AQ//nAET/5wBF/8QARv/mAEf/xABI/8kASf+1AEr/rQBL/+IALAAG//sAB//7AAj/9gAJ/9MACv/2AAv/ugAM/+kADf/dAA7/9gAP/+wAEP/2ABH/8AAS//EAE//2ABT/5wAV/9gAFv/sADH/vwAy/9UAM//eADT/3wA1//EANv/xADf/9gA4/+IAOf/xADr/9gA7/+wAPP/xAD3/9gA+//EAP//2AED/2ABB//EAQv/nAEP/9gBE/+cARf/TAEb/8QBH/9gASP/YAEn/xgBK/78AS//xACsABv/7AAf/9gAI/+wACf/TAAr/5wAL/90ADP/lAA3/zgAO/90AD//dABD/7AAR/+IAEv/iABP/2AAU/+IAFf/JABb/5wAx/90AMv/EADP/6wA0/+EANf/wADb/8AA4/9wAOf/dADr/7AA7/9gAPP/sAD3/5wA+/+wAP//iAED/0wBB/+IAQv/YAEP/4gBE/84ARf/JAEb/4gBH/8kASP/OAEn/vwBK/8kAS//TACwABv/7AAf/3wAI/+cACf+wAAr/4wAL/8kADP/dAA3/xwAO/+cAD//dABD/7AAR/+cAEv/iABP/yQAU/9cAFf+/ABb/4gAa/+kAMf/YADL/uwAz/+EANP/dADb/6wA3//MAOP/lADn/8QA6//IAO//eADz/5wA9/+4APv/zAD//8ABA/+IAQf/2AEL/6gBD//YARP/kAEX/zABG/+8AR/+0AEj/uwBJ/64ASv+vAEv/5QAsAAb/+wAH/90ACP/nAAn/4gAK/9MAC//nAAz/3QAN//YADv/eAA//3QAQ/7AAEf/OABL/sAAT//sAFP/dABX/0wAW/9MAMf/iADL/iAAz//YANP/OADX/9gA2//EAN//xADj/0wA5//YAOv/zADv/gAA8//EAPf/7AD7/+wA///YAQP/OAEH/7gBC/84AQ//2AET/2ABF//sARv/2AEf/5wBI/+cASf/TAEr/4gBL/+wALAAG//sAB//2AAj/8QAJ/9gACv/nAAv/3QAM/+IADf/dAA7/4gAP/+IAEP/nABH/5wAS/9gAE//YABT/3QAV/84AFv/sADH/5wAy/78AM//nADT/2AA1/+cANv/nADf/7AA4/90AOf/sADr/7AA7/+cAPP/sAD3/8QA+/+wAP//xAED/4gBB//EAQv/dAEP/5wBE/+IARf/YAEb/5wBH/78ASP/HAEn/sABK/7UAS//dACsABv/xAAf/8QAI/+IACf/dAAr/0wAL/+IADP/iAA3/3QAO/+cAD//dABD/zgAR/9MAEv/EABP/0wAU/84AFv/dADH/4gAy/6EAM//jADT/3QA1/+wANv/sADf/5wA4/90AOf/nADr/8QA7/78APP/xAD3/9gA+/+wAP//nAED/3QBB/+cAQv/nAEP/5wBE/+IARf/OAEb/3QBH/8QASP/JAEn/lwBK/7oAS//YACkABv/sAAf/0wAI/90ACf/OAAr/3QAM/90ADf/EAA7/5wAP/9gAEP/YABH/3QAS/9MAE//YABT/4gAV/90AMf/sADL/wAAz/+8ANP/kADX/6wA2//AAN//2ADj/5AA5//EAOv/uADv/1gA8//QAPf/2AD7/8QA///AAQP/dAEH/7ABD/+gARP/YAEX/1QBG/+wAR/+3AEj/wwBJ/7UASv+wAEv/5gAeAAf/zgAi/+4AI//5ACT/7wAy/9AAM//pADT/sQA1/+sANv/nADf/5gA4/7oAOf/vADr/9wA7/9AAPP/sAD3/6wA+/+YAP//sAED/uwBB/+kAQv+7AEP/5ABE/9QARf+6AEb/0ABH/34ASP+SAEn/zQBK/5sAS//nABwAF//RACT//wAy/9EAM//uADT/5wA1/+8ANv/3ADf/7gA4/+gAOf/3ADr/+wA7/9oAPP/vAD3/9wA+/+4AP//vAED/4QBB//cAQv/nAEP/7wBE/+4ARf/QAEb/9wBH/8EASP/MAEn/wwBK/7sAS//nABwAF//QABv/+QAy/8EAM//zADT/6wA1//sANv/zADf/+wA4/+8AOf/zADr//gA7/+EAPP/vAD3/9wA+//kAP//3AED/4gBB//kAQv/jAEP/8wBE/+YARf/VAEb/+QBH/84ASP/JAEn/twBK/8EAS//rAB8ABv/7ABL/3wAX/8kAJf/5ACv/7wAy/7oAM//zADT/6wA1/+8ANv/uADf/8wA4/+oAOf/vADr/7wA7/9QAPP/5AD3//gA+//EAP//vAED/4wBB//MAQv/mAEP/7gBE/+cARf/XAEb/6wBH/8kASP/JAEn/twBK/7cAS//nACAABv/7ACQAAgAl/+8AJ//5AC3//gAv//4AMv/oADP//QA0/+sANf/7ADb/+gA3//sAOP/jADn/9wA6//oAO//kADz//wA9//0APv/+AD8AAABA/+gAQf/7AEL/6ABD//sARP/sAEX/8QBG//sAR//qAEj/6wBJ/+cASv/qAEv/+QAbAAb/+wAl/+8AMv+5ADP/+wA0/+8ANf/7ADb/+wA3//0AOP/vADn/+wA6AAAAO/+7ADz//gA9//4APv/7AED/7ABB//4AQv/nAEP/+QBE//kARf/7AEb/+QBH//MASP/rAEn/4gBK/+8AS//7AB0ABv/2ABf/zgAl/+8AMv+3ADP/9wA0/+sANf/3ADb/8QA3//kAOP/uADn/8wA6//sAO//YADz/8wA9/+4APv/3AD//8wBA/+MAQf/3AEL/6QBD/+8ARP/nAEX/1ABG/+8AR//JAEj/zABJ/6YASv/JAEv/3AAcAAb/+wAX//MAJf/7ADL/6wAz//4ANP/uADX/+wA2//4AN//+ADj/8wA5//0AOv/+ADv/7gA8//4APf/+AD7/+wA///4AQP/uAEL/9wBD//4ARP/+AEX/+QBG//4AR//uAEj/9wBJ/+4ASv/zAEv//gAYAAb/+wAx//YAMv/rADP//wA0//MANf//ADYAAQA3//8AOP/zADv/6AA8//4APf/+AD4AAQBA/+4AQf//AEL/8wBD//4ARP/4AEX//QBH/+wASP/3AEn/7ABK//EASwABABwABv/2ABf/4QAy/8oAM//9ADT/+QA1//4ANv/7ADf//gA4//MAOf/+ADr//wA7/+EAPP/7AD3//gA+//4AP//+AED/7wBB//4AQv/zAEP//gBE//sARf/7AEb//gBH/+8ASP/5AEn/2gBK//oAS//+AB0ABv/nABf/5wAx/7AAMv/hADP/7gA0/7QANf/rADb/5wA3/+4AOP+sADn/6wA6//kAO/+3ADz/6gA9/+8APv/nAD//5wBA/6wAQf/uAEL/rgBD/+cARP+8AEX/3ABG/9oAR//cAEj/0QBJ/9oASv/RAEv/7wAeAAb/9gAX//cAI//9ADH/vwAy/+4AM//5ADT/2gA1//4ANv/3ADf/+wA4/9oAOf/3ADr/+wA7/+cAPP/7AD3/+QA+//cAP//5AED/1ABB//sAQv/cAEP/9wBE/+8ARf/JAEb/6wBH/8QASP++AEn/5wBK/8EAS//+ABwAF//7ADH/7AAy/+QAM//+ADT/7gA1//4ANgAAADf//QA4//cAOf/7ADr//gA7/+4APP/+AD3//gA+//0AP//7AED/7wBB//4AQv/uAEP//gBE//cARf/7AEb/+QBH/+gASP/vAEn/6wBK/+gAS//+AB4ABv/7ABf/8wAa//4AHf/3ACX/9wAq//4AMf/2ADL/5AAz//0ANP/zADX/+wA2//4AN//+ADj/+QA7/+4APf/+AD7/+wA///4AQP/2AEH/+gBC/+4AQ//7AET/+QBF//sARv/+AEf/8wBI/+8ASf/zAEr/6wBL//4AHQAG//EAJP/3ADH/7AAy/7sAM//sADT/4wA1/+8ANv/vADf/9wA4/+QAOf/qADr/9wA7/98APP/vAD3/9wA+/+sAP//uAED/4wBB/+4AQv/mAEP/7wBE/+IARf/VAEb/7gBH/8MASP/GAEn/uwBK/7oAS//fABwABv/sACT//gAy/54AM//rADT/6gA1//EANv/rADf/9wA4/+MAOf/oADr/9wA7/64APP/sAD3/8QA+/+wAP//sAED/4QBB//MAQv/oAEP/5ABE/9gARf/kAEb/7gBH/9EASP/QAEn/uwBK/8QAS//zADAAF//3ABj//wAZ/+kAGv//ABv//QAc//4AHf/pAB7/+wAf//8AIP/iACH//gAi//8AI//+ACT//wAl/+IAJ//uACj//gAp/+cAKv/hACv/+QAs/8MALf/QAC7/5AAv/8wAMP//ADL/4QAz//4ANP/jADX/9wA3//kAOP/fADn/9wA7/+IAPP/5AD3/+gA+//EAP//6AED/2gBB/+8AQv/aAET/7wBF/9cARv/qAEf/xgBI/7sASf/qAEr/tABL//sAHQAG/+cAF//oACT/+gAy/+IAM//xADT/zAA1/+8ANv/sADf/+gA4/8wAOf/3ADr/8wA7/8kAPP/uAD3/7wA+/+wAP//rAED/yQBB//cAQv/MAEP/+ABE/9QARf/KAEb/2gBH/8EASP/EAEn/4gBK/7cAS//vAB0ABv/xABv/+QAl/+4AMv+8ADP/7wA0/9wANf/zADb/6AA3//cAOP/hADn/5gA6//MAO//aADz/6QA9//MAPv/pAD//6wBA/+MAQf/3AEL/2gBD/+kARP/rAEX/1ABG/+kAR//JAEj/zABJ/7QASv+7AEv/5wAbAAb/9gAy/6YAM//9ADT/0wA1//oANv/+ADf//QA4/9UAOf/3ADr//wA7/7kAPP/6AD3//gA+//sAP//7AED/0ABB//oAQv/XAEP/+QBE/+IARf/zAEb/9wBH/+8ASP/vAEn/6gBK/+cAS//6ABwABv/7ACQAAgAy/9UAM//7ADT/7wA1//cANv/9ADf//wA4/+4AOf/7ADr//wA7/+sAPP/+AD3//gA+//0AP//6AED/7gBB//sAQv/sAEP/+wBE/+8ARf/7AEb//QBH/+8ASP/qAEn/3wBK//gAS//+ABwABv/nABf/lQAy/4IAM//3ADT/wQA1/+kANv/nADf/+gA4/8QAOf/oADr/6wA7/5UAPP/uAD3/+wA+//cAP//vAED/wQBB/+8AQv/DAEP/5wBE/84ARf/uAEb/7gBH/+kASP/pAEn/zgBK/+4AS//7ADMABv/sABf/owAY//kAGf/XABr//gAb//4AHP/5AB3/0AAe//gAIP+tACH/8wAi//4AJP/+ACX/0AAm//kAJ//MACj//gAp/9oAKv/+ACv//gAs/+MALf/zAC7/3AAv//cAMP/7ADL/jwAz/+oANP/CADX/7wA2/+oAN//3ADj/xgA5/+sAOv/6ADv/qgA8/+sAPf/7AD7/7wA//+8AQP++AEH/7gBC/8MAQ//qAET/1QBF/+sARv/pAEf/6ABI/+cASf/iAEr/2gBL/+4AHAAG/+cAF//hADL/1AAz/+sANP+wADX/6wA2/+QAN//jADj/qgA5/+cAOv/jADv/ugA8/+cAPf/vAD7/2gA//+kAQP+uAEH/7wBC/64AQ//kAET/uwBF/9oARv/aAEf/zABI/84ASf/TAEr/zQBL/+sAHwAG/+IAF/+lACP//gAk//sAL//uADL/hwAz/+8ANP+sADX/+AA2/9wAN//6ADj/uQA5/+4AOv/vADv/hAA8/+gAPf/pAD7/5wA//+YAQP+wAEH/6QBC/7oAQ//vAET/zgBF/+gARv/oAEf/2gBI/+YASf/QAEr/4gBL/+kAHAAG//sAF//+ADL/5wAz//sANP/kADX/+wA2//8AN//7ADj/4QA5//4AOv//ADv/6wA8//sAPf/+AD7//gA///sAQP/hAEH/+wBC/9oAQ//+AET/7wBF//sARv/6AEf/6QBI//kASf/rAEr/6QBL//sAMAAG/+wAB//YAAj/3QAJ/9MACv+/AAv/yQAM/+IADf/YAA7/7AAP/9MAEP/JABH/5wAS/+IAE//OABT/4gAV/+wAFv/nACD/WwAh/+wAIv/xACP/8QAk//YAJf/xADL/oQAz/+wANP/nADX/7AA2//sAN//2ADj/9gA5//sAO/+PADz/7AA9//YAPv/sAD//8QBA/+IAQf/nAEL/7ABD/+IARP/JAEX/zgBG/+cAR/+/AEj/xABJ/5IASv+/AEv/4gArAAb/9gAI/8QACf+cAAr/zAAL/5QADP+6AA3/xAAO/+oAD//BABD/zgAR/78AEv+7ABP/2AAU/78AFf+mABcAAgAk/+cAMf+mADL/2AAz/+cANP+7ADX/5gA2//MAN//zADj/sQA5/+oAOv/rADz/6AA9/+gAPv/mAD//5wBA/7oAQf/4AEL/twBD/+gARP/OAEX/sQBG/88AR/+EAEj/lwBJ/9AASv+NAEv/9wAsAAb/9gAH/+oACP/nAAn/xAAK/+gAC//TAAz/3QAN/9gADv/lAA//5wAQ/+IAEf/aABL/3AAT/9MAFP/bABX/xAAk//EAMf/YADL/zQAz/+wANP/kADX/9wA2//MAN//9ADj/4wA5//cAOv/3ADv/5gA8//4APf/9AD7/7gA//+4AQP/kAEH/+QBC/+YAQ//vAET/6QBF/9oARv/vAEf/zgBI/88ASf/QAEr/uQBL//kAKwAG//YAB//qAAj/7AAJ/9gACv/uAAv/4gAM/+IADf/dAA7/9AAP/+IAEP/eABH/5gAS/+IAE//TABT/3QAV/90AJP/2ADH/7AAy/74AM//uADT/3wA1//oANv/xADj/5wA5/+8AOv/5ADv/2AA8/+0APf/9AD7/8wA///EAQP/rAEH/+ABC/+QAQ//3AET/5gBF/9AARv/zAEf/xgBI/80ASf++AEr/twBL/+gAKgAH//EACP/xAAn/0wAK/+YAC//YAAz/5wAN/9gADv/oAA//5wAQ/+IAEf/iABP/2AAU/90AFf/dACT/+wAx/+wAMv+7ADP/9wA0/+QANf/rADb/5wA3//EAOP/kADn/+QA6//YAO//aADz/9wA9//4APv/uAD//8QBA/+cAQf/vAEL/4wBD/+sARP/cAEX/0ABG/+sAR//CAEj/xABJ/7QASv+6AEv/6AAmAAf/9gAI//EACf/sAAr/9gAM/+cADv/6AA//8QAQ//EAEf/vABL/4QAT//EAFP/iABX/5wAy/+kAM//9ADT/5wA1//sANv/9ADf//gA4/+sAOf/+ADoAAQA7/+gAPP/9AD3/9wA+//0AP//9AED/6wBBAAEAQv/pAEP/+QBE/+wARgACAEf/6QBI/+8ASf/nAEr/6wBL//sAKQAH//sACP/xAAn/5wAK/+4AC//2AAz/4gAN//sADv/1AA//8QAQ/90AEf/kABL/4gAT/+wAFP/YABX/3QAx//YAMv+5ADP/+AA0/+MANf/3ADb/+AA3//kAOP/iADn/+gA6//0AO//OADz//QA9//4APv/5AD///ABA/+YAQv/jAEP/9wBE/+YARf/vAEb//gBH/+cASP/vAEn/0QBK/+YAS//9ACgAB//2AAj/4gAJ/90ACv/sAAv/4gAM/+gADf/iAA7/9QAP/+gAEP/dABH/4AAS/+YAE//OABT/4gAV/90AJP/7ADH/9gAy/8EAM//vADT/3wA2//QAN//4ADj/4wA5/+kAOv/6ADv/0QA8/+YAPf/zAD7/6QA///EAQP/qAEL/3ABD/+gARP/fAEb/+ABH/7sASP+7AEn/rwBK/68AS//jACcACP/xAAn/7AAK//gADP/2AA7/9wAP//YAEP/xABH/5wAS/+cAE//xABT/7AAV/+UAMf/2ADL/6AAz//kANP/qADX/+wA2//oAN//7ADj/6wA5//cAOv//ADv/4wA8//sAPf/+AD7/+wA///oAQP/sAEH/+gBC/+MAQ//5AET/7wBF/+oARv/7AEf/4wBI/+wASf/jAEr/6gBL//4AJgAH//sACP/7AAn/5wAK//oADP/2AA7/9gAP//YAEP/xABH/8QAS//IAE//xABT/5wAV//EAMv/nADP/+wA0//EANf/9ADb//gA3//4AOP/uADn/+wA6//4AO//oAD0AAAA+//sAP//+AED/7wBB//4AQv/qAEP//wBE//EARf/3AEb/+wBH/+YASP/3AEn/2gBK/+QAS//7ACkAB//2AAj/9gAJ/90ACv/yAAz/8QAO//EAD//wABD/6gAR/+wAEv/mABP/9AAU/+wAFf/rABf/zgAx//YAMv/OADP/7wA0/+oANf/5ADb//gA3//0AOP/oADn/+QA6//0AO//YADz//gA9//8APv/6AD//+QBA/+4AQf/5AEL/4wBD//gARP/qAEX/+QBG//oAR//pAEj/6QBJ/9UASv/rAEv/+gAqAAf/sgAI/8kACf+wAAr/ugAL/7UADP+1AA3/3QAO/+QAD/+6ABD/sgAR/7UAEv+xABP/4gAU/6sAFf+mADH/lwAy/9oAM//jADT/qwA1/+IANv/iADf/4wA4/5oAOf/XADr/7gA7/7QAPP/kAD3/6wA+/+4AP//mAED/rQBB/+8AQv+qAEP/6gBE/74ARf/XAEb/2gBH/9AASP/SAEn/1QBK/80AS//qACsAB//nAAj/8QAJ/6YACv/sAAv/nAAM/90ADf+6AA7/9gAP/+IAEP/sABH/3QAS/9oAE//sABT/3QAV/8QAJP/+ADH/pgAy/+sAM//vADT/ygA1//0ANv/zADf/+wA4/9MAOf/vADr/+wA7/9gAPP/3AD3/9wA+//EAP//7AED/1QBB//cAQv/PAEP/8wBE/+YARf+7AEb/5wBH/7UASP/JAEn/2gBK/6UAS//zACkAB//2AAn/7AAK//kAC//sAAz/9gAO//oAD//2ABD/7AAR/+cAEv/vABP/9gAU//EAFf/sABcAAQAx/+YAMv/pADP/+QA0/+oANf/zADb/+wA3//oAOP/nADn/9wA6//4AO//uADz/+QA9//oAPv/7AD//+QBA/+8AQf/3AEL/6QBD//oARP/sAEX/8wBG//gAR//pAEj/6QBJ/+MASv/nAEv//QAqAAf/9gAI//sACf/sAAr/9wAL/+wADP/7AA7/+gAP//EAEP/2ABH/7AAS//EAE//2ABT/9gAV/+QAFwABADH/8QAy/+kAM//3ADT/6QA1//kANv/5ADf/+QA4/+8AOf/6ADr//gA7/+8APP/7AD3/+gA+//oAP//4AED/7wBB//sAQv/rAEP//QBE/+8ARf/3AEb/+gBH/+4ASP/rAEn/4QBK/+wAS//5ACsAB//xAAj/4gAJ/9gACv/sAAv/2AAM//YADf/iAA7/8QAP/90AEP/iABH/0wAS/+IAE//JABT/4gAV/94AJP/7ADH/3QAy/7QAM//pADT/4QA1/+wANv/vADf/6gA4/+IAOf/qADr/+gA7/9oAPP/pAD3/6wA+/+wAP//pAED/4QBB/+sAQv/cAEP/6wBE/+IARf/JAEb/7gBH/7wASP/BAEn/pgBK/7UAS//kACwAB//iAAj/5wAJ/+IACv/OAAv/2AAM/+cADf/nAA7/8AAP/90AEP+6ABH/xAAS/9cAE//XABT/2AAV/9gAG//3ACT/+wAx/+IAMv+gADP/6QA0/+MANf/mADb/7wA3/+sAOP/aADn/6AA6//YAO/+xADz/6wA9/+4APv/oAD//7wBA/9oAQf/oAEL/1wBD/+MARP/aAEX/2ABG/+cAR//PAEj/yQBJ/7kASv/BAEv/6AApAAf/8QAI/+wACf/OAAr/6gAL/84ADP/nAA3/2AAO//YAD//fABD/4gAR/9gAEv/lABP/5wAU/+IAFf/YADH/4gAy/+cAM//3ADT/2gA1//gANv/5ADf/+wA4/9wAOf/3ADr//gA7/+MAPP/3AD3//QA+//cAP//3AED/1QBC/9UAQ//9AET/6QBF/+EARv/pAEf/ugBI/8QASf/aAEr/wgBL//sAKwAH/8kACP/YAAn/xAAK/9MAC/+/AAz/yQAN/9gADv/nAA//xAAQ/7oAEf+1ABL/wQAT/9gAFP+6ABX/vwAk//sAMf+/ADL/2gAz/+gANP/KADX/6QA2/+kAN//oADj/xgA5/+QAOv/nADv/uQA8/+wAPf/uAD7/6QA//+cAQP/GAEH/7ABC/8kAQ//mAET/2ABF/84ARv/VAEf/wQBI/7wASf/GAEr/tABL/+8AKwAH//EACP/2AAn/yQAK/+oAC//TAAz/3QAN/+cADv/sAA//4gAQ/+IAEf/YABL/3wAT/90AFP/dABX/2AAk//sAMf/nADL/xgAz//MANP/iADX/7wA2/+4AN//3ADj/4wA5/+kAOv/vADv/1wA8/+4APf/zAD7/6gA//+0AQP/kAEH/9wBC/98AQ//qAET/5wBF/9AARv/vAEf/yQBI/9AASf/PAEr/xABL/+8AKQAH/+cACP/sAAn/5wAK/+kAC//dAAz/2AAO/+wAD//XABD/qwAR/8kAEv/AABP/9gAU/9MAFf/OADH/2AAy/7AAM//5ADT/2gA1//0ANv/6ADf//gA4/98AOf/3ADr//QA7/8YAPP/7AD3//gA+//gAP//4AED/1QBB//0AQv/VAEP/+ABE/+MARf/zAEb/+QBH/+4ASP/zAEn/4gBK/+cAS//zACkACP/2AAn/5wAK//QAC//sAAz/+wAN//4ADv/2AA//5QAQ/+wAEf/nABL/8wAT//EAFP/nABX/3QAx/+QAMv/KADP/+QA0/+wANf/6ADb/+gA3//sAOP/vADn/+gA6AAAAO//hADz//wA9//0APv/5AD///gBA/+wAQf/7AEL/7ABD//sARP/vAEX/9wBG//sAR//zAEj/6gBJ/+EASv/jAEv/+wArAAf/zgAI/84ACf/YAAr/ygAL/9gADP/JAA3/+wAO/9kAD//JABD/ogAR/7oAEv+5ABP/5wAU/8QAFf+9ACT/+wAx/7oAMv+FADP/+wA0/7sANf/qADb/6wA3/+wAOP++ADn/5gA6/+8AO/+iADz/6AA9/+oAPv/sAD//7wBA/8MAQf/mAEL/uwBD/+YARP/KAEX/6QBG/+8AR//jAEj/3wBJ/9MASv/hAEv/6wApAAf/zgAI/84ACf/TAAv/2AAM/84ADv/eAA//xAAQ/7AAEf/TABL/sQAT/+wAFP/FABX/yQAk//sAMf/JADL/lQAz//MANP/BADX/+QA2//MAN//3ADj/xgA5//sAOv/3ADv/pQA8/+8APf/+AD7/7gA//+oAQP/DAEH/7gBC/8QAQ//vAET/0ABF/+4ARv/uAEf/6QBI/+QASf/aAEr/5gBL//cAKgAH/8QACP/OAAn/pgAL/7oADP+rAA3/3QAO/+cAD/+5ABD/twAR/8QAEv+zABP/0wAU/7AAFf+cACT/+wAx/6EAMv/aADP/4wA0/7cANf/4ADb/4wA3//0AOP+3ADn/7gA6/+8AO/+7ADz/7gA9//EAPv/jAD//6ABA/7oAQf/zAEL/uQBD/+sARP/OAEX/3wBG/+EAR//aAEj/2ABJ/9gASv/MAEv/7gAsAAf/yQAI/84ACf/JAAr/wgAL/8kADP/JAA3//gAO/8kAD/+6ABD/jQAR/7oAEv+gABP/4gAU/7UAFf+6AB7/8QAk//sAMf+1ADL/lwAz/+8ANP+7ADX/5gA2/+4AN//uADj/uQA5/+gAOv/3ADv/hAA8/+8APf/sAD7/7AA//+oAQP+6AEH/7ABC/7kAQ//pAET/ygBF/+8ARv/vAEf/6ABI/+kASf/fAEr/5ABL//EAJgAH//YACf/iAAr/7AAL/+cADP/iAA3//wAO//UAD//nABD/7AAR/+IAEv/gABP/7AAU/90AFf/TADH/4gAy/+sAM//+ADT/6AA1//4ANgAEADf//wA4/9wAOf/6ADv/5gA8//8APf//AD///QBA/+MAQf//AEMAAABE/+8ARf/4AEb/+wBH//cASP/rAEn/6QBK/+kAS//9AAIAAQAGAEsAAAAAAAAAAQAAAADUGBYRAAAAANmXsTQAAAAA2ZexNA==",nt=r=>Si("http://www.w3.org/2000/svg",r),$o=(r,t)=>{const e=nt("rect");return e.setAttribute("height",`${r}`),e.setAttribute("width",`${t}`),e},Uo=(r,t,e,a)=>{const n=fe("filter");n.setAttribute("id",a),n.setAttribute("height","200%"),n.setAttribute("width","200%"),n.setAttribute("x","-50%"),n.setAttribute("y","-50%");const i=fe("feOffset");n.appendChild(i),i.setAttribute("result","offOut"),i.setAttribute("in","SourceAlpha"),i.setAttribute("dx",`${r}`),i.setAttribute("dy",`${t}`);const s=fe("feGaussianBlur");n.appendChild(s),s.setAttribute("result","blurOut"),s.setAttribute("in","offOut"),s.setAttribute("stdDeviation",`${e}`);const o=fe("feBlend");return n.appendChild(o),o.setAttribute("in","SourceGraphic"),o.setAttribute("in2","blurOut"),o.setAttribute("mode","normal"),n},Lo=r=>{let t=r;return t=t.replace(/feoffset/gi,"feOffset"),t=t.replace(/fegaussianblur/gi,"feGaussianBlur"),t=t.replace(/feblend/gi,"feBlend"),t=t.replace(/lineargradient/gi,"linearGradient"),t=t.replace(/stddeviation/gi,"stdDeviation"),t};function Vo(r,t,e,a,n,i){const s=n||1,o=i||1,l={x:t[0],y:t[1],width:t[2]-t[0],height:t[3]-t[1]};if(l.width<=0)return;const c=zo(l.height,l.width,e*s,a*o),d=(a-c*l.width)/2-c*l.x,A=(e-c*l.height)/2-c*l.y;r.setAttribute("transform",`translate(${d} ${A}) scale(${c} ${c})`)}function zo(r,t,e,a){const n=e/r,i=a/t;return n>1&&i>1?Math.min(n,i):n>1&&i<1?i:n<1&&i>1?n:Math.min(n,i)}const cn={m:["x","y"],z:[],l:["x","y"],h:["x"],v:["y"],c:["x1","y1","x2","y2","x","y"],s:["x2","y2","x","y"],q:["x1","y1","x","y"],t:["x","y"],a:["rx","ry","xRotation","largeArc","sweep","x","y"]};class Go{constructor(t){const e=Array.from(t.querySelectorAll("path"));this.paths=e.map(a=>{const n=a.getAttribute("d")||"",i=this.parsePath(n);return{pathElement:a,pathData:i}})}transform(t){for(const e of this.paths)e.pathData=this.runTransformer(e.pathData,t);this.update()}encodePath(t){let e="";const n=i=>{const s=[],o=i.relative?i.type:i.type.toUpperCase();let l=e!==o;const c=cn[i.type];l&&(s.push(o),e=o);for(const d of c){const A=i[d];let u;switch(typeof A){case"boolean":u=A|0;break;case"number":u=(A*100|0)/100;break;default:throw new St("Failed to encode path.")}l||s.push(" "),s.push(u),l=!1}return s.join("")};return t.map(n).join("")}parsePath(t){const e=/([mzlhvcsqta])([^mzlhvcsqta]*)/gi,a=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi,n=[];let i;for(e.lastIndex=0;i=e.exec(t);){const s=i[1].toLowerCase(),o=(i[2].match(a)||[]).map(parseFloat),l=s===i[1],c=cn[s];if(o.length<c.length)throw new St(`Path type "${s}" given ${o.length} arguments, expected ${c.length}.`);if(c.length>0){if(o.length%c.length!==0)throw new St(`Path type "${s}" given ${o.length} arguments, not divisible by ${c.length}`);for(let d=0;d<o.length/c.length;d++){const A={type:s,relative:l};for(let u=0;u<c.length;u++)A[c[u]]=o[d*c.length+u];n.push(A)}}else n.push({type:s,relative:l})}return n}runTransformer(t,e){const a=[["x1","y1"],["x2","y2"],["x","y"]],n=i=>{for(let s=0;s<a.length;s++){const[o,l]=a[s];if(o in i&&l in i){const c=[i[o],i[l]],d=e(c);if(d.length<2)throw new St("Transformer must return at least 2 points.");i[o]=d[0],i[l]=d[1]}}return i};return this.transformPath(t,n)}transformPath(t,e){const a=[];for(let n=0;n<t.length;n++){const i=JSON.parse(JSON.stringify(t[n])),s=e(i);Array.isArray(s)?a.push(...s):s&&a.push(s)}return a}update(){for(const{pathElement:t,pathData:e}of this.paths){const a=this.encodePath(e);t.setAttribute("d",a)}}}class qo extends Ro{constructor(){super(...arguments),this.moduleName="Vegemite"}svgPreview(t,e){return this.svgElement(t,e)}svgPrint(t,e){return this.svgElement(t,e)}svgElement(t,e){const a=Zs(Oo),i=t!==""?(w=>w.charAt(0).toUpperCase()+w.substr(1).toLowerCase())(t):"",s=a.getPath(i,0,72,72),o=s.toSVG(2),l=s.getBoundingBox(),c=l.x2-l.x1,d=s.toPathData(3),A=()=>{const w=nt("g");w.classList.add("module-text-group");const S=nt("defs");w.appendChild(S),S.appendChild(Uo(0,2,2,"shadow"));const y=nt("path");y.setAttribute("d",d),y.setAttribute("stroke","black"),y.setAttribute("stroke-width","3"),S.appendChild(y);const E=nt("g");E.classList.add("module-layer0"),w.appendChild(E),E.setAttribute("filter","url(#shadow)"),E.innerHTML=y.outerHTML;const b=nt("g");b.classList.add("module-layer1"),w.appendChild(b),b.setAttribute("stroke-width","3"),b.setAttribute("stroke","rgb(45,41,38)"),b.setAttribute("fill","rgb(45,41,38)"),b.setAttribute("transform","translate(0.5,0)"),b.innerHTML=o;const P=nt("g");P.classList.add("module-layer2"),w.appendChild(P),P.setAttribute("fill","rgb(255,209,0)"),P.setAttribute("transform","translate(1,-0.1)"),P.innerHTML=o;const x=nt("g");return x.classList.add("module-layer3"),w.appendChild(x),x.setAttribute("fill","white"),x.innerHTML=o,new Go(w).transform(([M,T])=>[M,T+(c/2-M)**2/(c*6)]),w},u=nt("g");u.classList.add("module-root");const h=nt("defs");u.appendChild(h);const g=nt("g");g.classList.add("module-bounds"),u.appendChild(g);const m=$o(e.height,e.width);m.setAttribute("opacity","0"),g.appendChild(m);const p=nt("g");p.classList.add("module-text-enclosure"),u.appendChild(p);const f=A();p.appendChild(f);const C=ci(d);return Vo(p,C,e.height,e.width,.35,.65),Lo(u.outerHTML)}}async function mr(r){if(r==="Vegemite")return new qo;throw new z(`Failed to resolve Module, Module ${r} not found`)}const he=v.gql`
1501
+ `);C.push(this.generateTextChangeCommandsForRegion(g.get(S.id)||1,t.data,S.id,y))}return new $(C)}}const W=new Ro;class Oo{}const $o="data:application/octet-stream;base64,AAEAAAAPAIAAAwBwRkZUTYdHeHoAAElcAAAAHEdERUYAJwBUAAAe2AAAAB5HUE9TkNtcVAAAHygAACoyR1NVQrj/uP4AAB74AAAAME9TLzJoWmUcAAABeAAAAGBjbWFwtkIacAAAAxAAAAJWZ2FzcP//AAMAAB7QAAAACGdseWY27KOUAAAGCAAAFcRoZWFkFPal0gAAAPwAAAA2aGhlYQU0Ar0AAAE0AAAAJGhtdHiADw6qAAAB2AAAAThsb2Nh5CzfJAAABWgAAACebWF4cACVAEwAAAFYAAAAIG5hbWXeIPPyAAAbzAAAAiJwb3N0ABeZTwAAHfAAAADdAAEAAAABAAAZ9vREXw889QALA+gAAAAA2ZexNAAAAADZl7E0ADL/yQJ2ArwAAAAIAAIAAAAAAAAAAQAAArz/wwAAAqsAAAAAAnYAAQAAAAAAAAAAAAAAAAAAAE4AAQAAAE4ASQAFAAAAAAACAAAAAQABAAAAQAAAAAAAAAAEAbsBkAAFAAACigK7AAAAjAKKArsAAAHfADEBAgAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAABYWFhYAEAACgCtArz/wwAAAqkANgAAAAMAAAAAAmQCZAAAACAAAgIPADIAAAAAAU0AAAAAAAAAAAAAALQAAAD3ADUCfQA1AcoANQKrADUCDQA1AX4ANQHYADUBNQA1AcgANQHUADUB8AA1AeEANQHpADUBqQA1AdAANQHpADUCqgA1Af8ANQGaADUB3wA1AbgANQFtADUBbQA1AekANQG8ADUA1QA1AYcANQHBADUBUAA1AhsANQHBADUB4QA1AZYANQH0ADUBxQA1AcUAMgGJADUBwwA1Ad0ANQJ1ADUB9wA1AcoANQF6ADUB3AA1Af8ANQGaADUB3wA1AbgANQFtADUBbQA1AekANQG8ADUA1QA1AYcANQHBADUBUAA1AhsANQHBADUB4QA1AZYANQH0ADUBxQA1AcUAMgGJADUBwwA1Ad0ANQJ1ADUB9wA1AcoANQF6ADUAtAAAAAAAAAAAAAMAAAADAAAAHAABAAAAAAFQAAMAAQAAABwABAE0AAAALgAgAAQADgAAAAoADQAhACYAKgA5AFoAXgB6AKAArQDFAM8A1gDdAOUA7wD2AP0A/wF4//8AAAAAAAoADQAgACMAKgAwAEAAXgBhAKAArQDAAMcA0QDYAOAA5wDxAPgA/wF4//8AAf/5//f/5f/k/+H/3P/W/9P/0f+s/6AAAAAAAAAAAAAAAAAAAAAA/0v+twABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABYAIAAwADoARABOAF4AaAAAAAAAAAAXABcAFwAXABcAFwAZABsAGwAbABsAHwAfAB8AHwAkACUAJQAlACUAJQAlACsAKwArACsALwAyADIAMgAyADIAMgA0ADYANgA2ADYAOgA6ADoAOgA/AEAAQABAAEAAQABAAEYARgBGAEYASgAAAQYAAAEAAAAAAAAAAQIDAAAEAAAAAAAAAAAAAAAAAAAAAQAABQYABwgJCgAAAAsAAAAAAAwNDg8QERITFBUAAAAAAAAWFxgZGhscHR4fICEiIyQlJicoKSorLC0uLzAAAAAxAAAyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKSwAAAAAAFxcZGyQlKzIyMjIyMjQ2NjY2Ojo6Oj9AQEBAQEZGRkYAAAAAAAAAAAAAAAAAAAAlAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABMFxclAAAAAAAAAAAAAEovAAAAAAAAAAAAAAAXGxcbGx8fHx8lJQAlKysrAAAAAAAAAAAAAAAAAAAAACgAKAAoACgAKAAoADwAbgC0AQgBbgGQAcYB1AIGAkYCYAKSAtAC4gMoA2ADyAPgBBoEUAR4BI4EogTWBOoE9gUiBToFSAViBXoFqgXWBjAGWgaaBqwG2AbqBwYHIAc2B0wHXgd2B7AH5ggOCCQIOAhsCIAIjAi4CNAI3gj4CRAJQAlsCcYJ8AowCkIKbgqACpwKtgrMCuIK4griAAAABQAyAAAB3QK8AAMABgAJAAwADwAAEyERIRsCCwEREwMhAxMRMgGr/lUcubrGtMG5AXKttQK8/UQCqP7LATX+tgEs/acBGP7MAUn+0QJdAAACADUABQDCAmoAAwAHAAATESMRExUjNcGLi4sCaf5mAZr+KY2NAAAAAgA1AAACSAJkABsAHwAAJQcjNyMHIzcjNzM3IzczNzMHMzczBzMHIwczByc3IwcBthdrFkoXbBdeDl8KYA9fFWwVShVtFWoPagpqDscJSgqqqqqqqmxHbJqamppsR2xsR0cAAAEANf/JAZUCqgAwAAABFR4BByM0LgEjIgYVFBYXHgMVFA4BBxUjNS4BNTMUFjMyNjU0LgInJjU0Njc1ARwwPAF3CBQOExcsPCEwFgkZNyhnPkGDGRQTGBElHBprRzQCqkQNV0INGBIdFB8hGw4tMCkUJkU7EENDCmk8GiUgFBIeGA4LKXpKVxBEAAAABQA1/+8CdgJrAAwAGAAcACkAOAAAEzQ2MzIeARUUBiMiJjcVFBYzMjY1NCYiBiUDIxMDNTQ+ATMyFhQGIyImNxUUHgEzMjY1NC4BIyIGNk02JD0jTTc2TVEeFBUeHiodAWjhVeEtIz0kN01ONjZOUQ4YDRUeDhcOFR4B1j5XKEUoPldXPgEXISEYGCEhcf2dAmP+JgEoRChXfFdWPwEPGhAiGBAbDyIAAwA1AAAB2AJnACQAOQBIAAAlFwcnDgEjIiY1ND4CNyY1NDYzMhYVFA4IBxc3MyciBhUUHgQXPgU1NCYjAxY+ATcnDgUVFBYBmT8qQgdUMk1cDyETFDVTNzdPAwUJBw0HDgUMATUabPULGQQFCgUKAQENBAsEBBYNAQ8bEQRRAQ4ECwUEIbFNZEERMGJKHzMqEhFDQD9ZVjsLFxITDRAJDgULAUFBtRgSBw4LDwcOAQEQBg8LDwcPGf58AQsOB2IBDQUOCg8IGyQAAAAAAQA1ATwBSQJtABEAABMHNxcHFwcnFyM3Byc3JzcXJ+YXVSVnZyhTGE0WUShnZyVWGAJselJLJSVOVXp7Vk4nI0tReQACADUAAAGjAmQAFwAmAAA3NTQ+AzMyHgMdARQOAiMiLgI3FRQeATMyPQE0IyIOAjYZJzIvFxQtMicaIjc9Hh09OiR8CBsXOTkSGAsF4KQxTzEhDQwhMFAypDtaMhkYMlvjrBUkH1isVxEeGgABADUAAAEAAmEABQAAMxEjNTMRhE7KAd6D/Z8AAQA1AAMBkwJmACEAADc1Njc+AzU0JiMiByM+Ajc+AzMyFhUUBgcGBzMVOi5WFxkaCx0XMQJ2AQINDQ4qLCIQTlkjLkAargN3L1kYHCcoFyIhXhsgNxccJxIHbU04WDRHHYEAAAEANQAAAZ8CZAAtAAATNjc2MzIWFRQOAwcWFRQGIyImJyYnMxYXMjY1NC4DKwE1MzI1NCYjIgdDAjktP0RVCw0VCwlca0otVRYVBn4KLhobCg8UDQcsFT0RESQCAaxgMCdfQRcoGBcIBiVpTWwrKCRENgElHRAYCwcCbzsVHjMAAgA1//8BuwJjAAoADQAAITUjNRMzETMVIxUnMzUBDdfadDY20WJrcgGF/oN6a+XAAAAAAAEANf//AawCYwAgAAABFSMHNjMyHgIVFA4CIyIuASczFjMyNjU0JiMiBycTAX+uCxsnKUIlExYrSy8zUS8HfRYjGygkHy4SZSoCYoBSEic+QyEkSkIqL00xJi8hHy80HwFTAAACADUAAAG0AmIAFgAoAAABMhYVFAYjIiYnJjU0PwEzBw4BBzAyNgMyPgE1NC4EIyIGFRQeAQEaO19vTy9QGCksepBYAw4CCA0kEx8TBAgLDxQLHSUVHQGvbF9kgConOV1LVdqUBRYFAv7XFCYXChMSEAwHLyEaJxIAAAAAAQA1//8BdAJjAAYAABMhFQMjEyM2AT6sibS9AmJ3/hUB3wAAAwA1AAABmwJkABkAJAAuAAATNTQ2MhYVFA4BBxYVFA4BIi4BNTQ3LgMXFRQWMjY1NCYiBjcVFBYyNjQmIgZCVqBWFBAMPC1RaFEtPAkLEgpwHjAdHTAeCRskGxskGwG/AUJhYkIeMxINJGU5WjMzWjllJAkNHSbhARgqKhkaKirTARcfHy8fHwAAAAACADUAAAG0AmQAFgAkAAA/AT4BNyYOASMiJjU0NjMyFhcWFRQPARM1NC4BIyIGFRQWMzI2fVgDDQQBCA0EO15uTy9QGCoteSsVHhAcKCUfHiUBlAQWBgEBAWxfZIAqJzldTFXaAYkBGiYSLiIgMi4AAgA1/8wCdQJtADgASAAAAQcGBwYzMjY1NCYjIgYHBh4DFxY3FQYnLgQ3ND4CMzIWFRQGIyInBicuATU0NjMyFhc3BzY1NC4CJyYGHQEUFjc2AfscBAIBFhYmbFVhdgcBBhwtVThNX01cQGlGMBUBLExzQniZWjs3FB07NT1PQBwoBwgqCQIHEg0gKCAUIQG2ux0NGVo8Wm2Laxg2RTcpBAUfWxsCASlBVlsvQHpfOqF8XZBBNwEBWkRIcyAWKMkaIgcQGBEBAz8rAyYjAQIAAAIANQAAAcgCZQAHAAoAADcHIxMzEyMvAge8GG6bYJdvGhknK3JyAmT9nHJz1tYAAAMANQABAWQCaAAPABoAJQAANxEzMhcWFRQHFhUUBw4BIwMzMjc2NTQnJisBFxUzMjc2NTQnJiM2lEAiJC9DJhszNx0mEgkQEAgUJQExFAsVFAoWAgJlKShQUygka1cuIhMBfAYLIB4LBuNwCA4mIgwGAAAAAQA1AAABqQJnACUAACUzDgEjIi4CNTQ+AjMyHgMXIy4DIyIOARUUFjMyPgIBSWAQX0cxSiwWFStLMSM7KB4QA2AFDhQfER4pEi8qFCEUCulrfjNXbD47alk0HzJAPR0SISATNEwsSWcXJxkAAgA1AAABgwJlAA8AGAAAMxEzMh4DFxYVFA4CIwMRMzI1NCcmIzZ/EhcsICYOJBUtTzUiKF4TFzMCZAEMFi4hT29BbFcwAdr+r6dDLjkAAAABADUAAAE3AmUACwAAEyEVIxUzFSMVMxUhNgEBlpGSlv8AAmR4cHmKeQAAAAEANQAAATcCZQAJAAAzESEVIxUzFSMRNgEBmJOTAmR5b3r+/gAAAAABADUAAAG3AmYAIQAAARUmBw4CFRQeAjMyNzY3IzUzFgcGIyIuATU0NjMyFhcBQBQ3FygbEBkgESEWGQVr0wUTMH89WCpiX0haEAGbAUgCASNPOC1FKhUaHDlpZkOyVYlXiaZvWwAAAAEANQAAAYYCZQALAAAzIxEzFTM1MxEjNSOcZmaDZ2eDAmTm5v2c9QABADUAAACgAmUAAwAAMxEzETZpAmT9nAABADUAAAFRAmUAGgAAAREUBwYHBiMiLgMnJjUzFBYVFjMyNzY1EQFQDQ8fJi4IESsgIAUCcQEEGxUHBAJk/pZkLCscIwIRHkEsFxcCDAQzGxAhAZEAAAAAAQA1//8BiwJmAAoAABcRMxETMwMTIwMRNmdzbISTfnABAmb+7AEU/s/+zAEJ/vYAAQA1AAABGgJlAAUAADMRMxEzFTZpewJk/iaKAAEANQAAAeUCZQAMAAAzIxEzGwEzESMTAyMDlmCLTEuMYARZRVgCZP52AYr9nAHK/jYBygABADUAAAGMAmUACQAAGwEDMxEjAxMjEZ2NAWNikwJjAmT+lAFs/ZwBaf6XAmQAAAACADUAAAGsAmUADAAfAAATNDYzMhYVFA4BIyImNxQWMzI+BDU0LgIjIg4BNmRWUWs0VDRWZGgqKg8aEQ0IAwgSIhceJw4BLKGXmJpfjUaelUtjDxohKCcUHzo1IDVKAAACADUAAAFgAmYAEAAbAAATMzIeARcWFRQGBw4BKwEVIxMVMzI3NjU0JyYjNoEjMRoMLhcSFjEtKGRkJRoNGBkOHAJlCxMPO2cvWRkdGMAB3ZMJEi8uEQoAAwA1//8BvwJmABsALgA8AAAlFwYiLgInDgIjIi4BNTQ+ATMyFhUUBx4CAyIOBAc2MzIXFhc2NTQuAQMeAzsBMjcmJyYjIgG9AQINGRgcChMsFBM+VycmWD1Uah0GDQzAERwSDQcCARgVKCIbHQkbLGgGFRUTBgYWDhEOGSAPenkBAggSDRMTAlaGU1GIXK5/ZUkIBwEBZxIgHScLCBEoHzQeLTJOKP7/HCgQCQwiFSMAAAAAAgA1//8BjwJmAA0AGgAAJRcjJxUjETMXFhcWFRQnNjU0LgInKwEVMzIBDYF+cGpqOi4UW4QYCxARBQY1Lhb7++vqAmQBBQosgohEFyoVHg4IAZkAAQAyAAABjwJnACsAADczFBY3NjU0JicuAycmPgEzMhYXIy4DIyIGFRQWFx4BFRQOAiMiJjZ2JBIyJjwRICobAQE0TSs5WQp0AQMJEg0RHCdBQTEUJkQsXFbFKx8BBDgWIB4JFyg7ITlVKFRbCwwTCh0UFSIkJEc2JUE3IGkAAAABADUAAAFTAmUABwAAMxEjNSEVIxGLVQEdVQHseHj+FAAAAAABADUAAAGNAmUAGgAAEzMRFBceATI2NzY1ETMRFA4BBwYjIiYnLgE1NmsIBR8qHgUIagcQDjBUIk0ZGQwCZP6WLhsSGBYQFzUBa/6WM0MvFEEcJCZISwAAAQA1AAABpwJlAAYAADMDMxsBMwO2gGdQUWmAAmT+UwGt/ZwAAQA1AAACQAJkAAwAADMDMxsBMxsBMwMjCwGfaWk4PFA8OGhrWz4+AmP+cwGN/nEBj/2dAYz+dAABADUAAAHBAmUACwAAMxMDMxc3MwMTIycHNop6c0NCcnmJc1VRAUYBHq6u/t/+vdnZAAAAAQA1AAABlAJlAAkAADczAzMXNzMDFSOsAXdvQUFtd3HrAXn29v6H6wAAAAABADUAAAFDAmYACQAAAQMzFSE1EyM1IQFDiIj+85OTAQ0B5v6kimcBdYkAAAEANQFFAaYCagAGAAAbATMTIycHNnx3fYE4NwFFAST+3LOzAAIANQAAAcgCZQAHAAoAADcHIxMzEyMvAge8GG6bYJdvGhknK3JyAmT9nHJz1tYAAAMANQABAWQCaAAPABoAJQAANxEzMhcWFRQHFhUUBw4BIwMzMjc2NTQnJisBFxUzMjc2NTQnJiM2lEAiJC9DJhszNx0mEgkQEAgUJQExFAsVFAoWAgJlKShQUygka1cuIhMBfAYLIB4LBuNwCA4mIgwGAAAAAQA1AAABqQJnACUAACUzDgEjIi4CNTQ+AjMyHgMXIy4DIyIOARUUFjMyPgIBSWAQX0cxSiwWFStLMSM7KB4QA2AFDhQfER4pEi8qFCEUCulrfjNXbD47alk0HzJAPR0SISATNEwsSWcXJxkAAgA1AAABgwJlAA8AGAAAMxEzMh4DFxYVFA4CIwMRMzI1NCcmIzZ/EhcsICYOJBUtTzUiKF4TFzMCZAEMFi4hT29BbFcwAdr+r6dDLjkAAAABADUAAAE3AmUACwAAEyEVIxUzFSMVMxUhNgEBlpGSlv8AAmR4cHmKeQAAAAEANQAAATcCZQAJAAAzESEVIxUzFSMRNgEBmJOTAmR5b3r+/gAAAAABADUAAAG3AmYAIQAAARUmBw4CFRQeAjMyNzY3IzUzFgcGIyIuATU0NjMyFhcBQBQ3FygbEBkgESEWGQVr0wUTMH89WCpiX0haEAGbAUgCASNPOC1FKhUaHDlpZkOyVYlXiaZvWwAAAAEANQAAAYYCZQALAAAzIxEzFTM1MxEjNSOcZmaDZ2eDAmTm5v2c9QABADUAAACgAmUAAwAAMxEzETZpAmT9nAABADUAAAFRAmUAGgAAAREUBwYHBiMiLgMnJjUzFBYVFjMyNzY1EQFQDQ8fJi4IESsgIAUCcQEEGxUHBAJk/pZkLCscIwIRHkEsFxcCDAQzGxAhAZEAAAAAAQA1//8BiwJmAAoAABcRMxETMwMTIwMRNmdzbISTfnABAmb+7AEU/s/+zAEJ/vYAAQA1AAABGgJlAAUAADMRMxEzFTZpewJk/iaKAAEANQAAAeUCZQAMAAAzIxEzGwEzESMTAyMDlmCLTEuMYARZRVgCZP52AYr9nAHK/jYBygABADUAAAGMAmUACQAAGwEDMxEjAxMjEZ2NAWNikwJjAmT+lAFs/ZwBaf6XAmQAAAACADUAAAGsAmUADAAfAAATNDYzMhYVFA4BIyImNxQWMzI+BDU0LgIjIg4BNmRWUWs0VDRWZGgqKg8aEQ0IAwgSIhceJw4BLKGXmJpfjUaelUtjDxohKCcUHzo1IDVKAAACADUAAAFgAmYAEAAbAAATMzIeARcWFRQGBw4BKwEVIxMVMzI3NjU0JyYjNoEjMRoMLhcSFjEtKGRkJRoNGBkOHAJlCxMPO2cvWRkdGMAB3ZMJEi8uEQoAAwA1//8BvwJmABsALgA8AAAlFwYiLgInDgIjIi4BNTQ+ATMyFhUUBx4CAyIOBAc2MzIXFhc2NTQuAQMeAzsBMjcmJyYjIgG9AQINGRgcChMsFBM+VycmWD1Uah0GDQzAERwSDQcCARgVKCIbHQkbLGgGFRUTBgYWDhEOGSAPenkBAggSDRMTAlaGU1GIXK5/ZUkIBwEBZxIgHScLCBEoHzQeLTJOKP7/HCgQCQwiFSMAAAAAAgA1//8BjwJmAA0AGgAAJRcjJxUjETMXFhcWFRQnNjU0LgInKwEVMzIBDYF+cGpqOi4UW4QYCxARBQY1Lhb7++vqAmQBBQosgohEFyoVHg4IAZkAAQAyAAABjwJnACsAADczFBY3NjU0JicuAycmPgEzMhYXIy4DIyIGFRQWFx4BFRQOAiMiJjZ2JBIyJjwRICobAQE0TSs5WQp0AQMJEg0RHCdBQTEUJkQsXFbFKx8BBDgWIB4JFyg7ITlVKFRbCwwTCh0UFSIkJEc2JUE3IGkAAAABADUAAAFTAmUABwAAMxEjNSEVIxGLVQEdVQHseHj+FAAAAAABADUAAAGNAmUAGgAAEzMRFBceATI2NzY1ETMRFA4BBwYjIiYnLgE1NmsIBR8qHgUIagcQDjBUIk0ZGQwCZP6WLhsSGBYQFzUBa/6WM0MvFEEcJCZISwAAAQA1AAABpwJlAAYAADMDMxsBMwO2gGdQUWmAAmT+UwGt/ZwAAQA1AAACQAJkAAwAADMDMxsBMxsBMwMjCwGfaWk4PFA8OGhrWz4+AmP+cwGN/nEBj/2dAYz+dAABADUAAAHBAmUACwAAMxMDMxc3MwMTIycHNop6c0NCcnmJc1VRAUYBHq6u/t/+vdnZAAAAAQA1AAABlAJlAAkAADczAzMXNzMDFSOsAXdvQUFtd3HrAXn29v6H6wAAAAABADUAAAFDAmYACQAAAQMzFSE1EyM1IQFDiIj+85OTAQ0B5v6kimcBdYkAAAAAEADGAAEAAAAAAAEACAASAAEAAAAAAAIABwArAAEAAAAAAAMAFQBfAAEAAAAAAAQACACHAAEAAAAAAAUAIgDWAAEAAAAAAAYADwEZAAEAAAAAABAACAE7AAEAAAAAABEABwFUAAMAAQQJAAEAEAAAAAMAAQQJAAIADgAbAAMAAQQJAAMAKgAzAAMAAQQJAAQAEAB1AAMAAQQJAAUARACQAAMAAQQJAAYAHgD5AAMAAQQJABAAEAEpAAMAAQQJABEADgFEAFYAZQBnAGUAbQBpAHQAZQAAVmVnZW1pdGUAAFIAZQBnAHUAbABhAHIAAFJlZ3VsYXIAADEALgAwADAAMgA7AFYAZQBnAGUAbQBpAHQAZQBSAGUAZwB1AGwAYQByAAAxLjAwMjtWZWdlbWl0ZVJlZ3VsYXIAAFYAZQBnAGUAbQBpAHQAZQAAVmVnZW1pdGUAAFYAZQByAHMAaQBvAG4AIAAxAC4AMAAwADIAOwBGAG8AbgB0AHMAZQBsAGYAIABNAGEAawBlAHIAIAAzAC4AMwAuADAAAFZlcnNpb24gMS4wMDI7Rm9udHNlbGYgTWFrZXIgMy4zLjAAAFYAZQBnAGUAbQBpAHQAZQBSAGUAZwB1AGwAYQByAABWZWdlbWl0ZVJlZ3VsYXIAAFYAZQBnAGUAbQBpAHQAZQAAVmVnZW1pdGUAAFIAZQBnAHUAbABhAHIAAFJlZ3VsYXIAAAAAAgAAAAAAAP+DADIAAAAAAAAAAAAAAAAAAAAAAAAAAABOAAAAAQACAQIBAwADAAQABgAHAAgACQANABMAFAAVABYAFwAYABkAGgAbABwAIwAkACUAJgAnACgAKQAqACsALAAtAC4ALwAwADEAMgAzADQANQA2ADcAOAA5ADoAOwA8AD0AQQBEAEUARgBHAEgASQBKAEsATABNAE4ATwBQAFEAUgBTAFQAVQBWAFcAWABZAFoAWwBcAF0ArAEECWNvbnRyb2xMRgljb250cm9sQ1IKc29mdGh5cGhlbgAAAAAAAAH//wACAAEAAAAMAAAAFgAAAAIAAQABAE0AAQAEAAAAAgAAAAAAAQAAAAoALAAuAAJERkxUAA5sYXRuABgABAAAAAD//wAAAAQAAAAA//8AAAAAAAAAAQAAAAoAMAA+AAJERkxUAA5sYXRuABoABAAAAAD//wABAAAABAAAAAD//wABAAAAAWtlcm4ACAAAAAEAAAABAAQAAgAAAAEACAABKd4ABAAAAEYAlgEwAd4CjAM2A+AEegUsBWYGDAa+B3AIHgjQCYIKNAriC4gMAgx0DOYNZA3mDlQOyg88D54QEBCGEQARchHsEmIS1BOWFAwUghTwFWIV1BaiFxQXkhgEGMYZdBomGtQbfhwYHL4dYB3+HpgfPh/oIJYhPCHmIpQjRiPsJJolSCXuJpQnQifoKJIpRAAmAAn/8QAK//sADP/7AA3/+wAO//sAD//7ABD/+wAR//sAEv/7ABP/+wAU//sAFf/xABb/8QAZ//sAHf/2AB7/+wAf//sAIP/xACH/+wAi//sAI//7ACT/+wAl//EAJv/2ACf/8QAo//sAKf/2ACr/+wAr//sALP/sAC3/7AAu/+IAL//dADD/9gAx/+wAMv/7ADP/+wA0//YAKwAG//EACP/nAAn/4gAK/9MAC//iAAz/9gAN/+IADv/sAA//4gAQ/9gAEf/iABL/1QAT//EAFP/nABX/8QAW/9gAMf/TADL/pgAz//MANP/nADX/8QA2//EAN//7ADj/7gA5//YAOv/7ADv/2AA8//EAPf/2AD7/9gA///EAQP/sAEH/+wBC/+wAQ//xAET/7ABF/+wARv/2AEf/3QBI/90ASf/EAEr/zgBL//YAKwAG//YAB//2AAn/3QAL/+wADP/sAA3/8QAO//YAD//sABD/8QAR/+wAEv/iABP/5wAU/+wAFf/dABb/7AAX/78AMf/YADL/sAAz/+IANP/iADX/8QA2/+cAN//xADj/3QA5/+wAOv/2ADv/4gA8//EAPf/xAD7/8QA///YAQP/YAEH/9gBC/+cAQ//sAET/7ABF/+wARv/xAEf/zgBI/9MASf/OAEr/zgBL/+wAKgAG//YAB//iAAj/4gAK/+IADP/dAA3/ugAO/+IAD//iABD/5wAR/+IAEv/dABP/yQAU/90AFf+mABb/0wAx/5gAMv/YADP/4gA0/9MANf/xADb/7AA3/+wAOP/iADn/7AA6//EAO//dADz/5wA9/+wAPv/sAD//5wBA/9gAQf/sAEL/zgBD/+wARP/YAEX/tQBG/90AR/+hAEj/oQBJ/8QASv+DAEv/7AAqAAb/8QAH/90ACP/YAAn/oQAL/8kADP/iAA3/sAAO/+cAD//YABD/4gAR/90AEv/bABP/4gAU/+IAFf/TABb/5wAg/+QAMf/nADL/3AAz//QANP/rADX/9AA2//IAN//4ADj/8AA5//QAOv/1ADv/7AA8/+oAPf/7AD7/9wA///IAQP/tAEH/+wBC/+IAQ//2AET/4wBF/7YARv/vAEf/pgBK/6MAS//yACYAB//TAAj/8QAK/84ADP/dAA3/9gAO//EAD//dABD/pgAR/8kAEv+6ABP/7AAU/90AFf/OADH/xAAy/5IAM//sADT/3QA1/+cANv/xADf/9gA4/90AO/9WADz/5wA9//EAPv/sAD//5wBA/84AQf/dAEL/0wBD/+cARP/nAEX/5wBG/+cAR//dAEj/2ABJ/7oASv/JAEv/4gAsAAb/+wAH//sACP/xAAn/zgAK/+cAC//dAAz/9gAN/9gADv/tAA//7AAQ/+kAEf/rABL/3QAT/90AFP/hABX/3QAW/90AMf/nADL/vwAz/+cANP/nADX/8QA2//EAN//sADj/5wA5//YAOv/2ADv/4gA8//EAPf/2AD7/+wA///sAQP/2AEH/+wBC/+wAQ//7AET/7ABF/9MARv/7AEf/yQBI/84ASf+wAEr/xABL/+cADgAG//sACf/xAAv/7AAN//sADv/7AA8AAAAR//EAEv/0ABP/9gAU//EAFf/xABb/7AAx//YAQP/2ACkABv/7AAf/9gAI//sACf/iAAr/5wAL/+wADP/vAA3/3QAO//sAD//qABD/8QAR/+wAEv/nABP/8QAU/+cAFf/iABb/7AAx/+cAMv/vADP//AA0/+cANf/7ADb//gA4//EAOf/8ADr//AA7/+kAPP/6AD3//QA+//4AP//7AEL/6gBD//0ARP/2AEX/7ABG//EAR//YAEj/4gBJ/+wASv/LAEv//AAsAAb/+wAH//EACP/2AAn/0wAK/+IAC//JAAz/5wAN/90ADv/iAA//7AAQ/+cAEf/sABL/3QAT/9MAFP/iABX/zgAW/+cAMf/YADL/xAAz/+wANP/dADX/6AA2//EAN//xADj/4wA5//EAOv/2ADv/7AA8/+wAPf/sAD7/9gA//+wAQP/iAEH/8QBC/90AQ//nAET/5wBF/8QARv/mAEf/xABI/8kASf+1AEr/rQBL/+IALAAG//sAB//7AAj/9gAJ/9MACv/2AAv/ugAM/+kADf/dAA7/9gAP/+wAEP/2ABH/8AAS//EAE//2ABT/5wAV/9gAFv/sADH/vwAy/9UAM//eADT/3wA1//EANv/xADf/9gA4/+IAOf/xADr/9gA7/+wAPP/xAD3/9gA+//EAP//2AED/2ABB//EAQv/nAEP/9gBE/+cARf/TAEb/8QBH/9gASP/YAEn/xgBK/78AS//xACsABv/7AAf/9gAI/+wACf/TAAr/5wAL/90ADP/lAA3/zgAO/90AD//dABD/7AAR/+IAEv/iABP/2AAU/+IAFf/JABb/5wAx/90AMv/EADP/6wA0/+EANf/wADb/8AA4/9wAOf/dADr/7AA7/9gAPP/sAD3/5wA+/+wAP//iAED/0wBB/+IAQv/YAEP/4gBE/84ARf/JAEb/4gBH/8kASP/OAEn/vwBK/8kAS//TACwABv/7AAf/3wAI/+cACf+wAAr/4wAL/8kADP/dAA3/xwAO/+cAD//dABD/7AAR/+cAEv/iABP/yQAU/9cAFf+/ABb/4gAa/+kAMf/YADL/uwAz/+EANP/dADb/6wA3//MAOP/lADn/8QA6//IAO//eADz/5wA9/+4APv/zAD//8ABA/+IAQf/2AEL/6gBD//YARP/kAEX/zABG/+8AR/+0AEj/uwBJ/64ASv+vAEv/5QAsAAb/+wAH/90ACP/nAAn/4gAK/9MAC//nAAz/3QAN//YADv/eAA//3QAQ/7AAEf/OABL/sAAT//sAFP/dABX/0wAW/9MAMf/iADL/iAAz//YANP/OADX/9gA2//EAN//xADj/0wA5//YAOv/zADv/gAA8//EAPf/7AD7/+wA///YAQP/OAEH/7gBC/84AQ//2AET/2ABF//sARv/2AEf/5wBI/+cASf/TAEr/4gBL/+wALAAG//sAB//2AAj/8QAJ/9gACv/nAAv/3QAM/+IADf/dAA7/4gAP/+IAEP/nABH/5wAS/9gAE//YABT/3QAV/84AFv/sADH/5wAy/78AM//nADT/2AA1/+cANv/nADf/7AA4/90AOf/sADr/7AA7/+cAPP/sAD3/8QA+/+wAP//xAED/4gBB//EAQv/dAEP/5wBE/+IARf/YAEb/5wBH/78ASP/HAEn/sABK/7UAS//dACsABv/xAAf/8QAI/+IACf/dAAr/0wAL/+IADP/iAA3/3QAO/+cAD//dABD/zgAR/9MAEv/EABP/0wAU/84AFv/dADH/4gAy/6EAM//jADT/3QA1/+wANv/sADf/5wA4/90AOf/nADr/8QA7/78APP/xAD3/9gA+/+wAP//nAED/3QBB/+cAQv/nAEP/5wBE/+IARf/OAEb/3QBH/8QASP/JAEn/lwBK/7oAS//YACkABv/sAAf/0wAI/90ACf/OAAr/3QAM/90ADf/EAA7/5wAP/9gAEP/YABH/3QAS/9MAE//YABT/4gAV/90AMf/sADL/wAAz/+8ANP/kADX/6wA2//AAN//2ADj/5AA5//EAOv/uADv/1gA8//QAPf/2AD7/8QA///AAQP/dAEH/7ABD/+gARP/YAEX/1QBG/+wAR/+3AEj/wwBJ/7UASv+wAEv/5gAeAAf/zgAi/+4AI//5ACT/7wAy/9AAM//pADT/sQA1/+sANv/nADf/5gA4/7oAOf/vADr/9wA7/9AAPP/sAD3/6wA+/+YAP//sAED/uwBB/+kAQv+7AEP/5ABE/9QARf+6AEb/0ABH/34ASP+SAEn/zQBK/5sAS//nABwAF//RACT//wAy/9EAM//uADT/5wA1/+8ANv/3ADf/7gA4/+gAOf/3ADr/+wA7/9oAPP/vAD3/9wA+/+4AP//vAED/4QBB//cAQv/nAEP/7wBE/+4ARf/QAEb/9wBH/8EASP/MAEn/wwBK/7sAS//nABwAF//QABv/+QAy/8EAM//zADT/6wA1//sANv/zADf/+wA4/+8AOf/zADr//gA7/+EAPP/vAD3/9wA+//kAP//3AED/4gBB//kAQv/jAEP/8wBE/+YARf/VAEb/+QBH/84ASP/JAEn/twBK/8EAS//rAB8ABv/7ABL/3wAX/8kAJf/5ACv/7wAy/7oAM//zADT/6wA1/+8ANv/uADf/8wA4/+oAOf/vADr/7wA7/9QAPP/5AD3//gA+//EAP//vAED/4wBB//MAQv/mAEP/7gBE/+cARf/XAEb/6wBH/8kASP/JAEn/twBK/7cAS//nACAABv/7ACQAAgAl/+8AJ//5AC3//gAv//4AMv/oADP//QA0/+sANf/7ADb/+gA3//sAOP/jADn/9wA6//oAO//kADz//wA9//0APv/+AD8AAABA/+gAQf/7AEL/6ABD//sARP/sAEX/8QBG//sAR//qAEj/6wBJ/+cASv/qAEv/+QAbAAb/+wAl/+8AMv+5ADP/+wA0/+8ANf/7ADb/+wA3//0AOP/vADn/+wA6AAAAO/+7ADz//gA9//4APv/7AED/7ABB//4AQv/nAEP/+QBE//kARf/7AEb/+QBH//MASP/rAEn/4gBK/+8AS//7AB0ABv/2ABf/zgAl/+8AMv+3ADP/9wA0/+sANf/3ADb/8QA3//kAOP/uADn/8wA6//sAO//YADz/8wA9/+4APv/3AD//8wBA/+MAQf/3AEL/6QBD/+8ARP/nAEX/1ABG/+8AR//JAEj/zABJ/6YASv/JAEv/3AAcAAb/+wAX//MAJf/7ADL/6wAz//4ANP/uADX/+wA2//4AN//+ADj/8wA5//0AOv/+ADv/7gA8//4APf/+AD7/+wA///4AQP/uAEL/9wBD//4ARP/+AEX/+QBG//4AR//uAEj/9wBJ/+4ASv/zAEv//gAYAAb/+wAx//YAMv/rADP//wA0//MANf//ADYAAQA3//8AOP/zADv/6AA8//4APf/+AD4AAQBA/+4AQf//AEL/8wBD//4ARP/4AEX//QBH/+wASP/3AEn/7ABK//EASwABABwABv/2ABf/4QAy/8oAM//9ADT/+QA1//4ANv/7ADf//gA4//MAOf/+ADr//wA7/+EAPP/7AD3//gA+//4AP//+AED/7wBB//4AQv/zAEP//gBE//sARf/7AEb//gBH/+8ASP/5AEn/2gBK//oAS//+AB0ABv/nABf/5wAx/7AAMv/hADP/7gA0/7QANf/rADb/5wA3/+4AOP+sADn/6wA6//kAO/+3ADz/6gA9/+8APv/nAD//5wBA/6wAQf/uAEL/rgBD/+cARP+8AEX/3ABG/9oAR//cAEj/0QBJ/9oASv/RAEv/7wAeAAb/9gAX//cAI//9ADH/vwAy/+4AM//5ADT/2gA1//4ANv/3ADf/+wA4/9oAOf/3ADr/+wA7/+cAPP/7AD3/+QA+//cAP//5AED/1ABB//sAQv/cAEP/9wBE/+8ARf/JAEb/6wBH/8QASP++AEn/5wBK/8EAS//+ABwAF//7ADH/7AAy/+QAM//+ADT/7gA1//4ANgAAADf//QA4//cAOf/7ADr//gA7/+4APP/+AD3//gA+//0AP//7AED/7wBB//4AQv/uAEP//gBE//cARf/7AEb/+QBH/+gASP/vAEn/6wBK/+gAS//+AB4ABv/7ABf/8wAa//4AHf/3ACX/9wAq//4AMf/2ADL/5AAz//0ANP/zADX/+wA2//4AN//+ADj/+QA7/+4APf/+AD7/+wA///4AQP/2AEH/+gBC/+4AQ//7AET/+QBF//sARv/+AEf/8wBI/+8ASf/zAEr/6wBL//4AHQAG//EAJP/3ADH/7AAy/7sAM//sADT/4wA1/+8ANv/vADf/9wA4/+QAOf/qADr/9wA7/98APP/vAD3/9wA+/+sAP//uAED/4wBB/+4AQv/mAEP/7wBE/+IARf/VAEb/7gBH/8MASP/GAEn/uwBK/7oAS//fABwABv/sACT//gAy/54AM//rADT/6gA1//EANv/rADf/9wA4/+MAOf/oADr/9wA7/64APP/sAD3/8QA+/+wAP//sAED/4QBB//MAQv/oAEP/5ABE/9gARf/kAEb/7gBH/9EASP/QAEn/uwBK/8QAS//zADAAF//3ABj//wAZ/+kAGv//ABv//QAc//4AHf/pAB7/+wAf//8AIP/iACH//gAi//8AI//+ACT//wAl/+IAJ//uACj//gAp/+cAKv/hACv/+QAs/8MALf/QAC7/5AAv/8wAMP//ADL/4QAz//4ANP/jADX/9wA3//kAOP/fADn/9wA7/+IAPP/5AD3/+gA+//EAP//6AED/2gBB/+8AQv/aAET/7wBF/9cARv/qAEf/xgBI/7sASf/qAEr/tABL//sAHQAG/+cAF//oACT/+gAy/+IAM//xADT/zAA1/+8ANv/sADf/+gA4/8wAOf/3ADr/8wA7/8kAPP/uAD3/7wA+/+wAP//rAED/yQBB//cAQv/MAEP/+ABE/9QARf/KAEb/2gBH/8EASP/EAEn/4gBK/7cAS//vAB0ABv/xABv/+QAl/+4AMv+8ADP/7wA0/9wANf/zADb/6AA3//cAOP/hADn/5gA6//MAO//aADz/6QA9//MAPv/pAD//6wBA/+MAQf/3AEL/2gBD/+kARP/rAEX/1ABG/+kAR//JAEj/zABJ/7QASv+7AEv/5wAbAAb/9gAy/6YAM//9ADT/0wA1//oANv/+ADf//QA4/9UAOf/3ADr//wA7/7kAPP/6AD3//gA+//sAP//7AED/0ABB//oAQv/XAEP/+QBE/+IARf/zAEb/9wBH/+8ASP/vAEn/6gBK/+cAS//6ABwABv/7ACQAAgAy/9UAM//7ADT/7wA1//cANv/9ADf//wA4/+4AOf/7ADr//wA7/+sAPP/+AD3//gA+//0AP//6AED/7gBB//sAQv/sAEP/+wBE/+8ARf/7AEb//QBH/+8ASP/qAEn/3wBK//gAS//+ABwABv/nABf/lQAy/4IAM//3ADT/wQA1/+kANv/nADf/+gA4/8QAOf/oADr/6wA7/5UAPP/uAD3/+wA+//cAP//vAED/wQBB/+8AQv/DAEP/5wBE/84ARf/uAEb/7gBH/+kASP/pAEn/zgBK/+4AS//7ADMABv/sABf/owAY//kAGf/XABr//gAb//4AHP/5AB3/0AAe//gAIP+tACH/8wAi//4AJP/+ACX/0AAm//kAJ//MACj//gAp/9oAKv/+ACv//gAs/+MALf/zAC7/3AAv//cAMP/7ADL/jwAz/+oANP/CADX/7wA2/+oAN//3ADj/xgA5/+sAOv/6ADv/qgA8/+sAPf/7AD7/7wA//+8AQP++AEH/7gBC/8MAQ//qAET/1QBF/+sARv/pAEf/6ABI/+cASf/iAEr/2gBL/+4AHAAG/+cAF//hADL/1AAz/+sANP+wADX/6wA2/+QAN//jADj/qgA5/+cAOv/jADv/ugA8/+cAPf/vAD7/2gA//+kAQP+uAEH/7wBC/64AQ//kAET/uwBF/9oARv/aAEf/zABI/84ASf/TAEr/zQBL/+sAHwAG/+IAF/+lACP//gAk//sAL//uADL/hwAz/+8ANP+sADX/+AA2/9wAN//6ADj/uQA5/+4AOv/vADv/hAA8/+gAPf/pAD7/5wA//+YAQP+wAEH/6QBC/7oAQ//vAET/zgBF/+gARv/oAEf/2gBI/+YASf/QAEr/4gBL/+kAHAAG//sAF//+ADL/5wAz//sANP/kADX/+wA2//8AN//7ADj/4QA5//4AOv//ADv/6wA8//sAPf/+AD7//gA///sAQP/hAEH/+wBC/9oAQ//+AET/7wBF//sARv/6AEf/6QBI//kASf/rAEr/6QBL//sAMAAG/+wAB//YAAj/3QAJ/9MACv+/AAv/yQAM/+IADf/YAA7/7AAP/9MAEP/JABH/5wAS/+IAE//OABT/4gAV/+wAFv/nACD/WwAh/+wAIv/xACP/8QAk//YAJf/xADL/oQAz/+wANP/nADX/7AA2//sAN//2ADj/9gA5//sAO/+PADz/7AA9//YAPv/sAD//8QBA/+IAQf/nAEL/7ABD/+IARP/JAEX/zgBG/+cAR/+/AEj/xABJ/5IASv+/AEv/4gArAAb/9gAI/8QACf+cAAr/zAAL/5QADP+6AA3/xAAO/+oAD//BABD/zgAR/78AEv+7ABP/2AAU/78AFf+mABcAAgAk/+cAMf+mADL/2AAz/+cANP+7ADX/5gA2//MAN//zADj/sQA5/+oAOv/rADz/6AA9/+gAPv/mAD//5wBA/7oAQf/4AEL/twBD/+gARP/OAEX/sQBG/88AR/+EAEj/lwBJ/9AASv+NAEv/9wAsAAb/9gAH/+oACP/nAAn/xAAK/+gAC//TAAz/3QAN/9gADv/lAA//5wAQ/+IAEf/aABL/3AAT/9MAFP/bABX/xAAk//EAMf/YADL/zQAz/+wANP/kADX/9wA2//MAN//9ADj/4wA5//cAOv/3ADv/5gA8//4APf/9AD7/7gA//+4AQP/kAEH/+QBC/+YAQ//vAET/6QBF/9oARv/vAEf/zgBI/88ASf/QAEr/uQBL//kAKwAG//YAB//qAAj/7AAJ/9gACv/uAAv/4gAM/+IADf/dAA7/9AAP/+IAEP/eABH/5gAS/+IAE//TABT/3QAV/90AJP/2ADH/7AAy/74AM//uADT/3wA1//oANv/xADj/5wA5/+8AOv/5ADv/2AA8/+0APf/9AD7/8wA///EAQP/rAEH/+ABC/+QAQ//3AET/5gBF/9AARv/zAEf/xgBI/80ASf++AEr/twBL/+gAKgAH//EACP/xAAn/0wAK/+YAC//YAAz/5wAN/9gADv/oAA//5wAQ/+IAEf/iABP/2AAU/90AFf/dACT/+wAx/+wAMv+7ADP/9wA0/+QANf/rADb/5wA3//EAOP/kADn/+QA6//YAO//aADz/9wA9//4APv/uAD//8QBA/+cAQf/vAEL/4wBD/+sARP/cAEX/0ABG/+sAR//CAEj/xABJ/7QASv+6AEv/6AAmAAf/9gAI//EACf/sAAr/9gAM/+cADv/6AA//8QAQ//EAEf/vABL/4QAT//EAFP/iABX/5wAy/+kAM//9ADT/5wA1//sANv/9ADf//gA4/+sAOf/+ADoAAQA7/+gAPP/9AD3/9wA+//0AP//9AED/6wBBAAEAQv/pAEP/+QBE/+wARgACAEf/6QBI/+8ASf/nAEr/6wBL//sAKQAH//sACP/xAAn/5wAK/+4AC//2AAz/4gAN//sADv/1AA//8QAQ/90AEf/kABL/4gAT/+wAFP/YABX/3QAx//YAMv+5ADP/+AA0/+MANf/3ADb/+AA3//kAOP/iADn/+gA6//0AO//OADz//QA9//4APv/5AD///ABA/+YAQv/jAEP/9wBE/+YARf/vAEb//gBH/+cASP/vAEn/0QBK/+YAS//9ACgAB//2AAj/4gAJ/90ACv/sAAv/4gAM/+gADf/iAA7/9QAP/+gAEP/dABH/4AAS/+YAE//OABT/4gAV/90AJP/7ADH/9gAy/8EAM//vADT/3wA2//QAN//4ADj/4wA5/+kAOv/6ADv/0QA8/+YAPf/zAD7/6QA///EAQP/qAEL/3ABD/+gARP/fAEb/+ABH/7sASP+7AEn/rwBK/68AS//jACcACP/xAAn/7AAK//gADP/2AA7/9wAP//YAEP/xABH/5wAS/+cAE//xABT/7AAV/+UAMf/2ADL/6AAz//kANP/qADX/+wA2//oAN//7ADj/6wA5//cAOv//ADv/4wA8//sAPf/+AD7/+wA///oAQP/sAEH/+gBC/+MAQ//5AET/7wBF/+oARv/7AEf/4wBI/+wASf/jAEr/6gBL//4AJgAH//sACP/7AAn/5wAK//oADP/2AA7/9gAP//YAEP/xABH/8QAS//IAE//xABT/5wAV//EAMv/nADP/+wA0//EANf/9ADb//gA3//4AOP/uADn/+wA6//4AO//oAD0AAAA+//sAP//+AED/7wBB//4AQv/qAEP//wBE//EARf/3AEb/+wBH/+YASP/3AEn/2gBK/+QAS//7ACkAB//2AAj/9gAJ/90ACv/yAAz/8QAO//EAD//wABD/6gAR/+wAEv/mABP/9AAU/+wAFf/rABf/zgAx//YAMv/OADP/7wA0/+oANf/5ADb//gA3//0AOP/oADn/+QA6//0AO//YADz//gA9//8APv/6AD//+QBA/+4AQf/5AEL/4wBD//gARP/qAEX/+QBG//oAR//pAEj/6QBJ/9UASv/rAEv/+gAqAAf/sgAI/8kACf+wAAr/ugAL/7UADP+1AA3/3QAO/+QAD/+6ABD/sgAR/7UAEv+xABP/4gAU/6sAFf+mADH/lwAy/9oAM//jADT/qwA1/+IANv/iADf/4wA4/5oAOf/XADr/7gA7/7QAPP/kAD3/6wA+/+4AP//mAED/rQBB/+8AQv+qAEP/6gBE/74ARf/XAEb/2gBH/9AASP/SAEn/1QBK/80AS//qACsAB//nAAj/8QAJ/6YACv/sAAv/nAAM/90ADf+6AA7/9gAP/+IAEP/sABH/3QAS/9oAE//sABT/3QAV/8QAJP/+ADH/pgAy/+sAM//vADT/ygA1//0ANv/zADf/+wA4/9MAOf/vADr/+wA7/9gAPP/3AD3/9wA+//EAP//7AED/1QBB//cAQv/PAEP/8wBE/+YARf+7AEb/5wBH/7UASP/JAEn/2gBK/6UAS//zACkAB//2AAn/7AAK//kAC//sAAz/9gAO//oAD//2ABD/7AAR/+cAEv/vABP/9gAU//EAFf/sABcAAQAx/+YAMv/pADP/+QA0/+oANf/zADb/+wA3//oAOP/nADn/9wA6//4AO//uADz/+QA9//oAPv/7AD//+QBA/+8AQf/3AEL/6QBD//oARP/sAEX/8wBG//gAR//pAEj/6QBJ/+MASv/nAEv//QAqAAf/9gAI//sACf/sAAr/9wAL/+wADP/7AA7/+gAP//EAEP/2ABH/7AAS//EAE//2ABT/9gAV/+QAFwABADH/8QAy/+kAM//3ADT/6QA1//kANv/5ADf/+QA4/+8AOf/6ADr//gA7/+8APP/7AD3/+gA+//oAP//4AED/7wBB//sAQv/rAEP//QBE/+8ARf/3AEb/+gBH/+4ASP/rAEn/4QBK/+wAS//5ACsAB//xAAj/4gAJ/9gACv/sAAv/2AAM//YADf/iAA7/8QAP/90AEP/iABH/0wAS/+IAE//JABT/4gAV/94AJP/7ADH/3QAy/7QAM//pADT/4QA1/+wANv/vADf/6gA4/+IAOf/qADr/+gA7/9oAPP/pAD3/6wA+/+wAP//pAED/4QBB/+sAQv/cAEP/6wBE/+IARf/JAEb/7gBH/7wASP/BAEn/pgBK/7UAS//kACwAB//iAAj/5wAJ/+IACv/OAAv/2AAM/+cADf/nAA7/8AAP/90AEP+6ABH/xAAS/9cAE//XABT/2AAV/9gAG//3ACT/+wAx/+IAMv+gADP/6QA0/+MANf/mADb/7wA3/+sAOP/aADn/6AA6//YAO/+xADz/6wA9/+4APv/oAD//7wBA/9oAQf/oAEL/1wBD/+MARP/aAEX/2ABG/+cAR//PAEj/yQBJ/7kASv/BAEv/6AApAAf/8QAI/+wACf/OAAr/6gAL/84ADP/nAA3/2AAO//YAD//fABD/4gAR/9gAEv/lABP/5wAU/+IAFf/YADH/4gAy/+cAM//3ADT/2gA1//gANv/5ADf/+wA4/9wAOf/3ADr//gA7/+MAPP/3AD3//QA+//cAP//3AED/1QBC/9UAQ//9AET/6QBF/+EARv/pAEf/ugBI/8QASf/aAEr/wgBL//sAKwAH/8kACP/YAAn/xAAK/9MAC/+/AAz/yQAN/9gADv/nAA//xAAQ/7oAEf+1ABL/wQAT/9gAFP+6ABX/vwAk//sAMf+/ADL/2gAz/+gANP/KADX/6QA2/+kAN//oADj/xgA5/+QAOv/nADv/uQA8/+wAPf/uAD7/6QA//+cAQP/GAEH/7ABC/8kAQ//mAET/2ABF/84ARv/VAEf/wQBI/7wASf/GAEr/tABL/+8AKwAH//EACP/2AAn/yQAK/+oAC//TAAz/3QAN/+cADv/sAA//4gAQ/+IAEf/YABL/3wAT/90AFP/dABX/2AAk//sAMf/nADL/xgAz//MANP/iADX/7wA2/+4AN//3ADj/4wA5/+kAOv/vADv/1wA8/+4APf/zAD7/6gA//+0AQP/kAEH/9wBC/98AQ//qAET/5wBF/9AARv/vAEf/yQBI/9AASf/PAEr/xABL/+8AKQAH/+cACP/sAAn/5wAK/+kAC//dAAz/2AAO/+wAD//XABD/qwAR/8kAEv/AABP/9gAU/9MAFf/OADH/2AAy/7AAM//5ADT/2gA1//0ANv/6ADf//gA4/98AOf/3ADr//QA7/8YAPP/7AD3//gA+//gAP//4AED/1QBB//0AQv/VAEP/+ABE/+MARf/zAEb/+QBH/+4ASP/zAEn/4gBK/+cAS//zACkACP/2AAn/5wAK//QAC//sAAz/+wAN//4ADv/2AA//5QAQ/+wAEf/nABL/8wAT//EAFP/nABX/3QAx/+QAMv/KADP/+QA0/+wANf/6ADb/+gA3//sAOP/vADn/+gA6AAAAO//hADz//wA9//0APv/5AD///gBA/+wAQf/7AEL/7ABD//sARP/vAEX/9wBG//sAR//zAEj/6gBJ/+EASv/jAEv/+wArAAf/zgAI/84ACf/YAAr/ygAL/9gADP/JAA3/+wAO/9kAD//JABD/ogAR/7oAEv+5ABP/5wAU/8QAFf+9ACT/+wAx/7oAMv+FADP/+wA0/7sANf/qADb/6wA3/+wAOP++ADn/5gA6/+8AO/+iADz/6AA9/+oAPv/sAD//7wBA/8MAQf/mAEL/uwBD/+YARP/KAEX/6QBG/+8AR//jAEj/3wBJ/9MASv/hAEv/6wApAAf/zgAI/84ACf/TAAv/2AAM/84ADv/eAA//xAAQ/7AAEf/TABL/sQAT/+wAFP/FABX/yQAk//sAMf/JADL/lQAz//MANP/BADX/+QA2//MAN//3ADj/xgA5//sAOv/3ADv/pQA8/+8APf/+AD7/7gA//+oAQP/DAEH/7gBC/8QAQ//vAET/0ABF/+4ARv/uAEf/6QBI/+QASf/aAEr/5gBL//cAKgAH/8QACP/OAAn/pgAL/7oADP+rAA3/3QAO/+cAD/+5ABD/twAR/8QAEv+zABP/0wAU/7AAFf+cACT/+wAx/6EAMv/aADP/4wA0/7cANf/4ADb/4wA3//0AOP+3ADn/7gA6/+8AO/+7ADz/7gA9//EAPv/jAD//6ABA/7oAQf/zAEL/uQBD/+sARP/OAEX/3wBG/+EAR//aAEj/2ABJ/9gASv/MAEv/7gAsAAf/yQAI/84ACf/JAAr/wgAL/8kADP/JAA3//gAO/8kAD/+6ABD/jQAR/7oAEv+gABP/4gAU/7UAFf+6AB7/8QAk//sAMf+1ADL/lwAz/+8ANP+7ADX/5gA2/+4AN//uADj/uQA5/+gAOv/3ADv/hAA8/+8APf/sAD7/7AA//+oAQP+6AEH/7ABC/7kAQ//pAET/ygBF/+8ARv/vAEf/6ABI/+kASf/fAEr/5ABL//EAJgAH//YACf/iAAr/7AAL/+cADP/iAA3//wAO//UAD//nABD/7AAR/+IAEv/gABP/7AAU/90AFf/TADH/4gAy/+sAM//+ADT/6AA1//4ANgAEADf//wA4/9wAOf/6ADv/5gA8//8APf//AD///QBA/+MAQf//AEMAAABE/+8ARf/4AEb/+wBH//cASP/rAEn/6QBK/+kAS//9AAIAAQAGAEsAAAAAAAAAAQAAAADUGBYRAAAAANmXsTQAAAAA2ZexNA==",at=r=>Si("http://www.w3.org/2000/svg",r),Uo=(r,t)=>{const e=at("rect");return e.setAttribute("height",`${r}`),e.setAttribute("width",`${t}`),e},Lo=(r,t,e,a)=>{const n=fe("filter");n.setAttribute("id",a),n.setAttribute("height","200%"),n.setAttribute("width","200%"),n.setAttribute("x","-50%"),n.setAttribute("y","-50%");const i=fe("feOffset");n.appendChild(i),i.setAttribute("result","offOut"),i.setAttribute("in","SourceAlpha"),i.setAttribute("dx",`${r}`),i.setAttribute("dy",`${t}`);const s=fe("feGaussianBlur");n.appendChild(s),s.setAttribute("result","blurOut"),s.setAttribute("in","offOut"),s.setAttribute("stdDeviation",`${e}`);const o=fe("feBlend");return n.appendChild(o),o.setAttribute("in","SourceGraphic"),o.setAttribute("in2","blurOut"),o.setAttribute("mode","normal"),n},Vo=r=>{let t=r;return t=t.replace(/feoffset/gi,"feOffset"),t=t.replace(/fegaussianblur/gi,"feGaussianBlur"),t=t.replace(/feblend/gi,"feBlend"),t=t.replace(/lineargradient/gi,"linearGradient"),t=t.replace(/stddeviation/gi,"stdDeviation"),t};function zo(r,t,e,a,n,i){const s=n||1,o=i||1,l={x:t[0],y:t[1],width:t[2]-t[0],height:t[3]-t[1]};if(l.width<=0)return;const c=qo(l.height,l.width,e*s,a*o),d=(a-c*l.width)/2-c*l.x,A=(e-c*l.height)/2-c*l.y;r.setAttribute("transform",`translate(${d} ${A}) scale(${c} ${c})`)}function qo(r,t,e,a){const n=e/r,i=a/t;return n>1&&i>1?Math.min(n,i):n>1&&i<1?i:n<1&&i>1?n:Math.min(n,i)}const dn={m:["x","y"],z:[],l:["x","y"],h:["x"],v:["y"],c:["x1","y1","x2","y2","x","y"],s:["x2","y2","x","y"],q:["x1","y1","x","y"],t:["x","y"],a:["rx","ry","xRotation","largeArc","sweep","x","y"]};class Go{constructor(t){const e=Array.from(t.querySelectorAll("path"));this.paths=e.map(a=>{const n=a.getAttribute("d")||"",i=this.parsePath(n);return{pathElement:a,pathData:i}})}transform(t){for(const e of this.paths)e.pathData=this.runTransformer(e.pathData,t);this.update()}encodePath(t){let e="";const n=i=>{const s=[],o=i.relative?i.type:i.type.toUpperCase();let l=e!==o;const c=dn[i.type];l&&(s.push(o),e=o);for(const d of c){const A=i[d];let u;switch(typeof A){case"boolean":u=A|0;break;case"number":u=(A*100|0)/100;break;default:throw new St("Failed to encode path.")}l||s.push(" "),s.push(u),l=!1}return s.join("")};return t.map(n).join("")}parsePath(t){const e=/([mzlhvcsqta])([^mzlhvcsqta]*)/gi,a=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi,n=[];let i;for(e.lastIndex=0;i=e.exec(t);){const s=i[1].toLowerCase(),o=(i[2].match(a)||[]).map(parseFloat),l=s===i[1],c=dn[s];if(o.length<c.length)throw new St(`Path type "${s}" given ${o.length} arguments, expected ${c.length}.`);if(c.length>0){if(o.length%c.length!==0)throw new St(`Path type "${s}" given ${o.length} arguments, not divisible by ${c.length}`);for(let d=0;d<o.length/c.length;d++){const A={type:s,relative:l};for(let u=0;u<c.length;u++)A[c[u]]=o[d*c.length+u];n.push(A)}}else n.push({type:s,relative:l})}return n}runTransformer(t,e){const a=[["x1","y1"],["x2","y2"],["x","y"]],n=i=>{for(let s=0;s<a.length;s++){const[o,l]=a[s];if(o in i&&l in i){const c=[i[o],i[l]],d=e(c);if(d.length<2)throw new St("Transformer must return at least 2 points.");i[o]=d[0],i[l]=d[1]}}return i};return this.transformPath(t,n)}transformPath(t,e){const a=[];for(let n=0;n<t.length;n++){const i=JSON.parse(JSON.stringify(t[n])),s=e(i);Array.isArray(s)?a.push(...s):s&&a.push(s)}return a}update(){for(const{pathElement:t,pathData:e}of this.paths){const a=this.encodePath(e);t.setAttribute("d",a)}}}class Wo extends Oo{constructor(){super(...arguments),this.moduleName="Vegemite"}svgPreview(t,e){return this.svgElement(t,e)}svgPrint(t,e){return this.svgElement(t,e)}svgElement(t,e){const a=to($o),i=t!==""?(w=>w.charAt(0).toUpperCase()+w.substr(1).toLowerCase())(t):"",s=a.getPath(i,0,72,72),o=s.toSVG(2),l=s.getBoundingBox(),c=l.x2-l.x1,d=s.toPathData(3),A=()=>{const w=at("g");w.classList.add("module-text-group");const S=at("defs");w.appendChild(S),S.appendChild(Lo(0,2,2,"shadow"));const y=at("path");y.setAttribute("d",d),y.setAttribute("stroke","black"),y.setAttribute("stroke-width","3"),S.appendChild(y);const E=at("g");E.classList.add("module-layer0"),w.appendChild(E),E.setAttribute("filter","url(#shadow)"),E.innerHTML=y.outerHTML;const b=at("g");b.classList.add("module-layer1"),w.appendChild(b),b.setAttribute("stroke-width","3"),b.setAttribute("stroke","rgb(45,41,38)"),b.setAttribute("fill","rgb(45,41,38)"),b.setAttribute("transform","translate(0.5,0)"),b.innerHTML=o;const P=at("g");P.classList.add("module-layer2"),w.appendChild(P),P.setAttribute("fill","rgb(255,209,0)"),P.setAttribute("transform","translate(1,-0.1)"),P.innerHTML=o;const D=at("g");return D.classList.add("module-layer3"),w.appendChild(D),D.setAttribute("fill","white"),D.innerHTML=o,new Go(w).transform(([k,N])=>[k,N+(c/2-k)**2/(c*6)]),w},u=at("g");u.classList.add("module-root");const h=at("defs");u.appendChild(h);const g=at("g");g.classList.add("module-bounds"),u.appendChild(g);const m=Uo(e.height,e.width);m.setAttribute("opacity","0"),g.appendChild(m);const p=at("g");p.classList.add("module-text-enclosure"),u.appendChild(p);const f=A();p.appendChild(f);const C=ci(d);return zo(p,C,e.height,e.width,.35,.65),Vo(u.outerHTML)}}async function pr(r){if(r==="Vegemite")return new Wo;throw new z(`Failed to resolve Module, Module ${r} not found`)}const he=v.gql`
1478
1502
  fragment GlobalPropertyStateAspectFields on GlobalPropertyStateAspect {
1479
1503
  name
1480
1504
  value
@@ -1496,7 +1520,7 @@
1496
1520
  }
1497
1521
  }
1498
1522
  }
1499
- `,Wo=v.gql`
1523
+ `,jo=v.gql`
1500
1524
  ${he}
1501
1525
  mutation CreateGlobalPropertyState($bundleId: String!) {
1502
1526
  globalPropertyStateCreate(bundleId: $bundleId) {
@@ -1506,7 +1530,7 @@
1506
1530
  }
1507
1531
  }
1508
1532
  }
1509
- `,jo=v.gql`
1533
+ `,Ho=v.gql`
1510
1534
  ${he}
1511
1535
  mutation UpdateGlobalPropertyState($id: String!, $aspects: [GlobalPropertyStateAspectInput]!) {
1512
1536
  globalPropertyStateUpdate(id: $id, aspects: $aspects) {
@@ -1516,7 +1540,7 @@
1516
1540
  }
1517
1541
  }
1518
1542
  }
1519
- `,Ho=v.gql`
1543
+ `,Yo=v.gql`
1520
1544
  ${he}
1521
1545
  query GetGlobalPropertyState($bundleId: String!) {
1522
1546
  globalPropertyState(bundleId: $bundleId) {
@@ -1526,7 +1550,7 @@
1526
1550
  }
1527
1551
  }
1528
1552
  }
1529
- `,Yo=async r=>(await B.getShadowGraphqlClient().query({query:Ho,fetchPolicy:"cache-first",errorPolicy:"all",variables:{bundleId:r}})).data.globalPropertyState,Jo=v.gql`
1553
+ `,Jo=async r=>(await B.getShadowGraphqlClient().query({query:Yo,fetchPolicy:"cache-first",errorPolicy:"all",variables:{bundleId:r}})).data.globalPropertyState,Ko=v.gql`
1530
1554
  ${Le}
1531
1555
  fragment ProductFields on Product {
1532
1556
  id
@@ -1572,7 +1596,7 @@
1572
1596
  }
1573
1597
  }
1574
1598
  `,Va=v.gql`
1575
- ${Jo}
1599
+ ${Ko}
1576
1600
  fragment ProductCollectionProductFields on ProductCollectionProduct {
1577
1601
  id
1578
1602
  productId
@@ -1645,7 +1669,7 @@
1645
1669
  }
1646
1670
  }
1647
1671
  }
1648
- `,Ko=r=>v.gql`
1672
+ `,_o=r=>v.gql`
1649
1673
  ${he}
1650
1674
  ${ge(r)}
1651
1675
  query GetBundle($id: String!) {
@@ -1689,7 +1713,7 @@
1689
1713
  quoteId
1690
1714
  }
1691
1715
  }
1692
- `,dn=v.gql`
1716
+ `,An=v.gql`
1693
1717
  query GetBundleStakeholders($id: String!) {
1694
1718
  bundles(ids: [$id]) {
1695
1719
  id
@@ -1734,7 +1758,7 @@
1734
1758
  }
1735
1759
  }
1736
1760
  }
1737
- `,_o=v.gql`
1761
+ `,Xo=v.gql`
1738
1762
  query GetBundlesForCustomer($id: String!) {
1739
1763
  customers(ids: [$id]) {
1740
1764
  bundleStakeholders {
@@ -1763,7 +1787,7 @@
1763
1787
  }
1764
1788
  }
1765
1789
  }
1766
- `,Xo=v.gql`
1790
+ `,Zo=v.gql`
1767
1791
  ${Va}
1768
1792
  query GetProductCollectionProducts($id: String!, $productIds: [String!]) {
1769
1793
  productCollections(ids: [$id], productIds: $productIds) {
@@ -1773,7 +1797,7 @@
1773
1797
  }
1774
1798
  }
1775
1799
  }
1776
- `,Zo=v.gql`
1800
+ `,tl=v.gql`
1777
1801
  query GetProductCollectionForFilteredProducts(
1778
1802
  $id: String!
1779
1803
  $filters: ProductCollectionProductFilterInput
@@ -1796,7 +1820,7 @@
1796
1820
  }
1797
1821
  }
1798
1822
  }
1799
- `,tl=v.gql`
1823
+ `,el=v.gql`
1800
1824
  ${Va}
1801
1825
  query GetProductCollectionForProductsFeed(
1802
1826
  $id: String!
@@ -1824,7 +1848,7 @@
1824
1848
  }
1825
1849
  }
1826
1850
  }
1827
- `,el=r=>v.gql`
1851
+ `,al=r=>v.gql`
1828
1852
  ${ge(r)}
1829
1853
  mutation CreateBundle(
1830
1854
  $collectionId: String
@@ -1853,7 +1877,7 @@
1853
1877
  }
1854
1878
  }
1855
1879
  }
1856
- `,al=r=>v.gql`
1880
+ `,nl=r=>v.gql`
1857
1881
  ${he}
1858
1882
  ${ge(r)}
1859
1883
  mutation DuplicateBundle(
@@ -1895,7 +1919,7 @@
1895
1919
  }
1896
1920
  }
1897
1921
  }
1898
- `,nl=v.gql`
1922
+ `,rl=v.gql`
1899
1923
  mutation UpdateBundle(
1900
1924
  $id: String!
1901
1925
  $name: String
@@ -1915,19 +1939,19 @@
1915
1939
  id
1916
1940
  }
1917
1941
  }
1918
- `,rl=v.gql`
1942
+ `,il=v.gql`
1919
1943
  mutation BundleAddTransaction($id: String!, $transactionId: String!) {
1920
1944
  bundleAddTransaction(id: $id, transactionId: $transactionId) {
1921
1945
  id
1922
1946
  }
1923
1947
  }
1924
- `,il=v.gql`
1948
+ `,sl=v.gql`
1925
1949
  mutation BundleAddTransactions($id: String!, $transactionIds: [String!]!, $transactionOwnerIds: [String!]) {
1926
1950
  bundleAddTransactions(id: $id, transactionIds: $transactionIds, transactionOwnerIds: $transactionOwnerIds) {
1927
1951
  id
1928
1952
  }
1929
1953
  }
1930
- `,sl=v.gql`
1954
+ `,ol=v.gql`
1931
1955
  mutation BundleRemoveTransaction(
1932
1956
  $id: String!
1933
1957
  $transactionId: String!
@@ -1942,7 +1966,7 @@
1942
1966
  id
1943
1967
  }
1944
1968
  }
1945
- `,ol=v.gql`
1969
+ `,ll=v.gql`
1946
1970
  mutation BundleRemoveTransactions(
1947
1971
  $id: String!
1948
1972
  $transactionIds: [String!]!
@@ -1957,7 +1981,7 @@
1957
1981
  id
1958
1982
  }
1959
1983
  }
1960
- `,ll=v.gql`
1984
+ `,cl=v.gql`
1961
1985
  mutation BundleAddStakeholder($id: String!, $details: CustomerDetailsInput!, $type: String!) {
1962
1986
  bundleAddStakeholder(id: $id, details: $details, type: $type) {
1963
1987
  id
@@ -1977,13 +2001,13 @@
1977
2001
  }
1978
2002
  }
1979
2003
  }
1980
- `,cl=v.gql`
2004
+ `,dl=v.gql`
1981
2005
  mutation BundleAddStakeholder($id: String!, $emailAddress: String!) {
1982
2006
  bundleRemoveStakeholder(id: $id, emailAddress: $emailAddress) {
1983
2007
  id
1984
2008
  }
1985
2009
  }
1986
- `,dl=v.gql`
2010
+ `,Al=v.gql`
1987
2011
  mutation BundleUpdateStakeholders($id: String!, $input: [BundleStakeholderInput!]!) {
1988
2012
  bundleUpdateStakeholders(id: $id, input: $input) {
1989
2013
  id
@@ -2003,13 +2027,13 @@
2003
2027
  }
2004
2028
  }
2005
2029
  }
2006
- `,Al=v.gql`
2030
+ `,ul=v.gql`
2007
2031
  mutation BundleUpdateTransactionOrder($id: String!, $transactionIds: [String!]!) {
2008
2032
  bundleUpdateTransactionOrder(id: $id, transactionIds: $transactionIds) {
2009
2033
  id
2010
2034
  }
2011
2035
  }
2012
- `,ul=r=>v.gql`
2036
+ `,hl=r=>v.gql`
2013
2037
  ${ge(r)}
2014
2038
  mutation BundleAssignProductCollection($id: String!, $productCollectionId: String!) {
2015
2039
  bundleAssignProductCollection(id: $id, collectionId: $productCollectionId) {
@@ -2019,13 +2043,13 @@
2019
2043
  }
2020
2044
  }
2021
2045
  }
2022
- `,hl=v.gql`
2046
+ `,gl=v.gql`
2023
2047
  mutation AssignGlobalPropertyConfiguration($bundleId: String!, $globalPropertyConfigurationId: String!) {
2024
2048
  bundleUpdate(id: $bundleId, globalPropertyConfigurationId: $globalPropertyConfigurationId) {
2025
2049
  id
2026
2050
  }
2027
2051
  }
2028
- `,gl=r=>v.gql`
2052
+ `,ml=r=>v.gql`
2029
2053
  query CustomerBundlesFeed($id: String!, $limit: Int!, $offset: Int!, $template: Boolean, $templateStatus: BundleTemplateStatus, $ordered: Boolean) {
2030
2054
  customerBundlesFeed(id: $id, limit: $limit, offset: $offset, template: $template, templateStatus: $templateStatus, ordered: $ordered) {
2031
2055
  items {
@@ -2061,27 +2085,27 @@
2061
2085
  total
2062
2086
  }
2063
2087
  }
2064
- `,ml=v.gql`
2088
+ `,pl=v.gql`
2065
2089
  mutation FinalizeUpdateBundle($bundleId: String!) {
2066
2090
  bundleFinalizeUpdate(bundleId: $bundleId)
2067
2091
  }
2068
- `,pl=v.gql`
2092
+ `,fl=v.gql`
2069
2093
  mutation ApproveBundle($id: String!, $note: String, $stakeholderId: String) {
2070
2094
  bundleApprove(id: $id, note: $note, stakeholderId: $stakeholderId)
2071
2095
  }
2072
- `,fl=v.gql`
2096
+ `,Cl=v.gql`
2073
2097
  mutation RejectBundle($id: String!, $note: String, $stakeholderId: String) {
2074
2098
  bundleReject(id: $id, note: $note, stakeholderId: $stakeholderId)
2075
2099
  }
2076
- `,Cl=v.gql`
2100
+ `,wl=v.gql`
2077
2101
  mutation ApproveTransaction($id: String!, $note: String) {
2078
2102
  transactionApprove(id: $id, note: $note)
2079
2103
  }
2080
- `,wl=v.gql`
2104
+ `,yl=v.gql`
2081
2105
  mutation RejectTransaction($id: String!, $note: String) {
2082
2106
  transactionReject(id: $id, note: $note)
2083
2107
  }
2084
- `,yl=v.gql`
2108
+ `,Sl=v.gql`
2085
2109
  mutation CreateRecipient(
2086
2110
  $firstName: String
2087
2111
  $lastName: String
@@ -2093,6 +2117,13 @@
2093
2117
  $country: String
2094
2118
  $mobile: String
2095
2119
  $company: String
2120
+ $apartment: String
2121
+ $customField1: String
2122
+ $customField2: String
2123
+ $customField3: String
2124
+ $customField4: String
2125
+ $customField5: String
2126
+ $conversionConfigurationId: String
2096
2127
  ) {
2097
2128
  recipientCreate(
2098
2129
  firstName: $firstName
@@ -2105,11 +2136,18 @@
2105
2136
  country: $country
2106
2137
  mobile: $mobile
2107
2138
  company: $company
2139
+ apartment: $apartment
2140
+ customField1: $customField1
2141
+ customField2: $customField2
2142
+ customField3: $customField3
2143
+ customField4: $customField4
2144
+ customField5: $customField5
2145
+ conversionConfigurationId: $conversionConfigurationId
2108
2146
  ) {
2109
2147
  id
2110
2148
  }
2111
2149
  }
2112
- `,Sl=v.gql`
2150
+ `,vl=v.gql`
2113
2151
  mutation UpdateRecipient(
2114
2152
  $id: String!
2115
2153
  $firstName: String
@@ -2122,6 +2160,13 @@
2122
2160
  $country: String
2123
2161
  $mobile: String
2124
2162
  $company: String
2163
+ $apartment: String
2164
+ $customField1: String
2165
+ $customField2: String
2166
+ $customField3: String
2167
+ $customField4: String
2168
+ $customField5: String
2169
+ $conversionConfigurationId: String
2125
2170
  ) {
2126
2171
  recipientUpdate(
2127
2172
  id: $id
@@ -2135,17 +2180,24 @@
2135
2180
  country: $country
2136
2181
  mobile: $mobile
2137
2182
  company: $company
2183
+ apartment: $apartment
2184
+ customField1: $customField1
2185
+ customField2: $customField2
2186
+ customField3: $customField3
2187
+ customField4: $customField4
2188
+ customField5: $customField5
2189
+ conversionConfigurationId: $conversionConfigurationId
2138
2190
  ) {
2139
2191
  id
2140
2192
  }
2141
2193
  }
2142
- `,vl=v.gql`
2194
+ `,El=v.gql`
2143
2195
  mutation AtttachRecipient($id: String!, $recipientId: String!) {
2144
2196
  transactionAttachRecipient(id: $id, recipientId: $recipientId) {
2145
2197
  id
2146
2198
  }
2147
2199
  }
2148
- `;var me=(r=>(r.Error="Error",r.Warning="Warning",r.Info="Info",r))(me||{});const El=1e3;class An extends Pa{constructor(t){super(),this.createdAt=new Date,this.update=t}async execute(){await this.update(),await new Promise(t=>{window.setTimeout(()=>{t()},El)})}}class bl{constructor(t,e,a,n,i,s,o,l,c,d,A,u,h,g=!1,m,p=!1,f=!1,C=!1){var w;this.workflowStatePromiseQueue=new Da(1),this.initialized=!1,this.readOnly=!1,this.isReloadedTransaction=!1,this.singleVariantsRenderable=!1,this.stepTags={},this.renderLayouts=()=>{var E;if(!this.previewService)return;const S=this.getCommandContext().getAllLayouts(),y=(E=this.getLayoutPreviewService())==null?void 0:E.getAll();if(y)for(const[,b]of y)b.render(S)},this.experience=t,this.client=e,this.updateTransaction=o,this.graphQlClient=l,this.commandContext=s,this.reloadedState=h,this.transaction=c,this.readOnly=g,this.singleVariantsRenderable=f,this.confirmedDesign=!1,this.editedSteps={},this.informationResults=[],this.mandatorySteps={},this.pendingUpdates=[],this.selectionCost=0,this.workflow=a,this.stepSpecificServices={},this.profanityFilter=n,this.pollers=[],this.allScenes=[],this.layouts=i,this.product=d,this.previewService=A,this.modelContainer=m,this.stepElements={},this.stepInitialised={},this.stepMetadata={},this.stepSelections={},this.storage={},this.validationErrors={steps:new Map},this.confirmCallbacks=[],this.editedCallbacks=[],this.elementsCallbacks=[],this.informationResultCallbacks=[],this.initCallbacks=[],this.mandatoryCallbacks=[],this.makingAdjustmentsCallback=[],this.metadataCallbacks=[],this.selectionCallbacks=[],this.stepSpecificStorageCallbacks={},this.storageCallbacks=[],this.validationCallbacks=[],this.recipientCallbacks=[],this.currentAdjustingStepId="",this.renderableContextService=u,(w=this.renderableContextService)==null||w.setWorkflowManager(this),this.isReloadedTransaction=p,this.workflow.steps.forEach(S=>{this.stepTags[S.stepName]=S.tags??[]}),C&&(this.workflowStatePromiseQueue.enabled=!1),this.initializationPromise=this.initializeDefaultWorkflowState(a),this.initializationPromise.then(()=>{this.initialized=!0}),this.initializationPromise.catch(S=>{throw console.error(S),this.initialized=!1,new Error("Workflow initialization failed due to an error. See console.")}),this.initializationPromise.finally(()=>this.getCommandContext().registerStateCallback(()=>{this.updateStateWithServer(),this.renderLayouts()}))}getTemplatingContext(){return{recipient:this.transaction.recipient}}async updateRecipient(t,e,a,n,i,s,o,l,c,d){var A,u,h,g,m;if((A=this.transaction.recipient)!=null&&A.id)this.transaction.recipient={id:this.transaction.recipient.id,firstName:t||this.transaction.recipient.firstName,lastName:e||this.transaction.recipient.lastName,address:a||this.transaction.recipient.address,suburb:n||this.transaction.recipient.suburb,state:i||this.transaction.recipient.state,email:s||this.transaction.recipient.email,postalCode:o||this.transaction.recipient.postalCode,country:l||this.transaction.recipient.country,mobile:c||this.transaction.recipient.mobile,company:d||this.transaction.recipient.company},await this.graphQlClient().mutate({mutation:Sl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.transaction.recipient.id,firstName:t||this.transaction.recipient.firstName,lastName:e||this.transaction.recipient.lastName,address:a||this.transaction.recipient.address,suburb:n||this.transaction.recipient.suburb,state:i||this.transaction.recipient.state,email:s||this.transaction.recipient.email,postalCode:o||this.transaction.recipient.postalCode,country:l||this.transaction.recipient.country,mobile:c||this.transaction.recipient.mobile,company:d||this.transaction.recipient.company}});else{const p=await this.graphQlClient().mutate({mutation:yl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{firstName:t,lastName:e,address:a,suburb:n,state:i,email:s,postalCode:o,country:l,mobile:c,company:d}});this.transaction.recipient={id:(h=(u=p==null?void 0:p.data)==null?void 0:u.recipientCreate)==null?void 0:h.id,firstName:t,lastName:e,address:a,suburb:n,state:i,email:s,postalCode:o,country:l,mobile:c,company:d},await this.graphQlClient().mutate({mutation:vl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.transaction.id,recipientId:(m=(g=p.data)==null?void 0:g.recipientCreate)==null?void 0:m.id},context:{transactionOwnerId:this.transaction.transactionOwnerId}})}this.recipientCallbacks.forEach(p=>p(this.transaction.recipient))}async initializeDefaultWorkflowState(t){const e=()=>{var d,A;const o=this.workflow.finalizeStepConfig;if(!o)return;const l=o.lookAtAnimation,c=o.modelAnimation;l&&((d=this.previewService)==null||d.executeCameraAnimation(l)),c&&((A=this.modelContainer)==null||A.executeAnimation(c))};this.reloadedState&&this.reloadedState.serializableWorkflow.steps.forEach(o=>{this.storage[o.stepName]=o.storage||{}}),this.allScenes=await Ts(t);const n=xt(this.allScenes,this.stepSelections).map(o=>o.silentSteps).flat(),{stepElements:i,commands:s}=await this.stepElementsForIntroducedSilentSteps(n,!!this.reloadedState);this.commandContext.apply(new $(s),!0),this.stepElements={...this.stepElements,...i},await this.ensureStepsAreLoaded(),!this.isReloadedTransaction&&this.updateStateWithServer(),this.renderLayouts(),this.reloadedState&&e()}getWorkflowExperience(){return this.experience}getClient(){return this.client}setWorkflowStateSyncEnabled(t){this.workflowStatePromiseQueue.enabled=t}getProduct(){return this.product}getInitializationPromise(){return this.initializationPromise}isInitialized(){return this.initialized}addConfirmCallback(t){t(this.confirmedDesign),this.confirmCallbacks.push(t)}addEditedCallback(t){t(this.editedSteps),this.editedCallbacks.push(t)}addElementsCallback(t){t(this.stepElements),this.elementsCallbacks.push(t)}addInformationResultCallback(t){t(this.informationResults),this.informationResultCallbacks.push(t)}addInitCallback(t){t(this.stepInitialised),this.initCallbacks.push(t)}addMandatoryCallback(t){t(this.mandatorySteps),this.mandatoryCallbacks.push(t)}addMetadataCallback(t){t(this.stepMetadata),this.metadataCallbacks.push(t)}async addSelectionCallback(t){t({selectionCost:this.selectionCost,selections:this.stepSelections,traversableScenes:await this.traversableScenes()}),this.selectionCallbacks.push(t)}addStepSpecificStorageCallback(t,e){Object.keys(this.storage).includes(e)||(this.storage[e]={}),t(this.storage[e]),Object.keys(this.stepSpecificStorageCallbacks).includes(e)||(this.stepSpecificStorageCallbacks[e]=[]),this.stepSpecificStorageCallbacks[e].push(t)}addStorageCallback(t){t(this.storage),this.storageCallbacks.push(t)}addMakingAdjustmentsCallback(t){t(this.currentAdjustingStepId),this.makingAdjustmentsCallback.push(t)}addPoller(t){this.pollers.push(t)}addValidationCallback(t){this.validationCallbacks.push(t),t(this.validationErrors)}addRecipientCallback(t){this.recipientCallbacks.push(t),t(this.transaction.recipient)}removeRecipientCallback(t){this.recipientCallbacks=this.recipientCallbacks.filter(e=>e!==t)}getLayouts(){return this.layouts}getAllLayoutData(){return this.commandContext.getAllLayouts().map(t=>t.layoutState)}getLayoutPreviewService(){return this.renderableContextService}getInformationResults(){return this.informationResults}getPreviewService(){return this.previewService}getProfanities(){return this.profanityFilter}getCommandContext(){return this.commandContext}getRegionElements(t){return this.stepElements[t]||[]}getStepSpecificServices(t){return this.stepSpecificServices[t]}getTransaction(){return this.transaction}getTransactionCustomer(){return this.ownerCustomer}setTransactionCustomer(t){this.ownerCustomer=t}setTransactionCustomerDetails(t){this.ownerCustomer={...this.ownerCustomer,emailAddress:t.email}}getModelContainer(){return this.modelContainer}setModelContainer(t){(!t||this.previewService&&this.previewService.getAllModels().includes(t))&&(this.modelContainer=t,t&&t.metadata&&t.metadata instanceof Map&&this.modelContainer.metadata.set("workflowManager",this))}setTransaction(t){this.transaction=t}getWorkflow(){return this.workflow}getCommandDispatcher(){return t=>this.commandContext.apply(t,!this.initialized)}getWorkflowSelections(){const t={};return this.workflow.steps.forEach(e=>{const a=this.stepSelections[e.stepName];a&&a.selectedVariants&&a.selectedVariants.length>0&&(t[e.stepName]={selections:a.selectedVariants})}),t}getStepSelections(){return this.stepSelections}markStepsAsInitialised(t){const e={...this.stepInitialised};t.forEach(a=>{e[a]=!0}),this.stepInitialised=e,this.onInitChange()}getUpdatesPending(){return this.pendingUpdates.length>0}markUpdateCompleted(t){this.pendingUpdates=this.pendingUpdates.filter(e=>e!==t)}markUpdatePending(){const t=Q();return this.pendingUpdates=[...this.pendingUpdates,t],t}setEditedStatus(t,e){this.editedSteps={...this.editedSteps,[t]:e},this.onEditedChange()}setInformationResults(t){this.informationResults=[...t],this.onInformationResultChange()}setCurrentAdjustingStepId(t){this.currentAdjustingStepId=t,this.onMakingAdjustmentsChange()}setMandatoryFulfilled(t,e){this.mandatorySteps[t]!==e&&(this.mandatorySteps={...this.mandatorySteps,[t]:e},this.onMandatoryChange())}setStepError(t,e,a){let n=!1;if(!this.validationErrors.steps.has(t)&&a)n=!0,this.validationErrors.steps.set(t,new Map([[e,a]]));else if(this.validationErrors.steps.has(t)){const i=this.validationErrors.steps.get(t);a&&a!==i.get(e)?(n=!0,i.set(e,a)):a||(n=!0,i.delete(e),i.size===0&&this.validationErrors.steps.delete(t))}n&&this.onValidationChange()}getStepErrors(t){return this.validationErrors.steps.get(t)}getValidationErrors(){return this.validationErrors}toggleDesignConfirmed(){this.confirmedDesign=!this.confirmedDesign,this.onConfirmChange()}toggleMakingAdjustmentsCallback(t){t(this.mandatorySteps),this.mandatoryCallbacks.push(t)}async injectIntoPreviewService(t,e){if(this.modelContainer)throw new Error("You must eject from the preview service before injecting again.");if(this.previewService=t,!this.getProduct().modelUrl||!this.previewService)return;const a=t.loadModel({model:this.getProduct().modelUrl,contextService:this.getLayoutPreviewService()},{refocusCamera:e});this.setModelContainer(a),xt(this.allScenes,this.stepSelections).filter(s=>s).map(s=>s.renderableSteps).flat().filter(s=>s.type===I.Model||s.type===I.Material).forEach(s=>{var c,d,A;if(!((c=s.option)!=null&&c.id)){console.error(`Failed to read option id from step: ${s.stepName}`);return}const o=((d=this.stepSelections[s.stepName])==null?void 0:d.selectedVariants)||[];if(o.length===0)return;const l=o[0];if(s.type===I.Model){if(!this.modelContainer)throw new z("We should always have a model container when injecting a preview!");const u=(A=l.asset)==null?void 0:A.fileLink;if(!u){console.error(`Failed to read model url from variant: ${l.id} for step: ${s.stepName}`);return}const h=s.data;this.modelContainer.applyModelVariant(s.stepName,{model:u,contextService:this.getLayoutPreviewService()},h.replaceProductModel||!1)}else{const u=l.material;if(!u){console.error(`Failed to read material from variant: ${l.id} for step: ${s.stepName}`);return}s.data.targetMaterials.forEach(g=>{if(!this.modelContainer)throw new z("We should always have a model container when injecting a preview!");this.modelContainer.applyMaterialVariant(g,s.option.id,u)})}}),await a.getInitializationPromise(),this.renderLayouts()}ejectFromPreviewService(){if(this.modelContainer){if(!this.modelContainer.dispose)throw new Error("This feature is not supported in the current preview service.");this.modelContainer.dispose(),this.modelContainer=void 0}this.previewService=void 0}updateStorage(t,e){const a={...this.storage,[t]:{...this.storage[t],...e}};if(!vn(a,this.storage)){this.storage=a;const n=new on(this.constructSerializableWorkflow());this.commandContext.apply(n,!0),this.onStepSpecificStorageChange(t),this.onStorageChange()}}constructSerializableWorkflow(){const t=[];return this.allScenes.forEach(e=>{e.renderableSteps.forEach(a=>{var i,s;const n={stepName:a.stepName};n.storage=this.storage[a.stepName],n.selectedVariants=(s=(i=this.stepSelections[a.stepName])==null?void 0:i.selectedVariants)==null?void 0:s.map(o=>({id:o.id,priceModifier:o.priceModifier})),t.push(n)})}),{steps:t}}updateStateWithServer(){if(this.readOnly)return;const t=this.serialize();this.workflowStatePromiseQueue.enqueue(new An(async()=>{await new Promise(e=>{setTimeout(()=>{e()},1)}),await this.updateTransaction({variables:{id:this.transaction.id,workflowState:t}})}))}async updateStateWithServerImmediate(){if(this.readOnly)return;const t=this.serialize();return new An(async()=>{await this.updateTransaction({variables:{id:this.transaction.id,workflowState:t}})}).execute()}serialize(){const t=this.getCommandContext().getState();if(!t)throw new z("Attempted to serialize state before it was initialized.");const e=Et(t.transaction),a=this.dehydrateState(e);return JSON.stringify(a)}dehydrateState(t){var e;for(const a of Object.values(t.layouts).map(n=>n.elements).flat())a.type==="illustration"&&(delete a.cachedObjectURL,a.src&&delete a.svg),a.type==="frame"&&((e=a.pattern)==null||delete e.svg);return this.deleteFieldNameFromObjectRecursive(t,"__typename"),t}deleteFieldNameFromObjectRecursive(t,e){if(!(typeof t!="object"||t===null))for(const a in t)a===e?delete t[a]:this.deleteFieldNameFromObjectRecursive(t[a],e)}async outstandingRequestsPromise(){return this.workflowStatePromiseQueue.finalize()}updateMetadata(t,e){this.stepMetadata={...this.stepMetadata,[t]:{...this.stepMetadata[t],...e}},this.onMetadataChange()}removeElements(t){const e=(a,n)=>Object.keys(a).reduce((i,s)=>{const o=[...a[s]||[]];return n.forEach(l=>{const c=o.findIndex(d=>d.id===l.id);c>-1&&o.splice(c,1)}),i[s]=o,i},{});this.stepElements=e(this.stepElements,t)}getInvalidCanvasRegions(){return this.workflow.steps.reduce((t,e)=>(vt(e,this.stepSelections)||this.stepElements[e.stepName]&&this.stepElements[e.stepName].forEach(a=>t.push(a)),t),[])}getInvalidModelVariants(){return this.workflow.steps.reduce((t,e)=>(e.type===I.Model&&!vt(e,this.stepSelections)&&t.push(e.stepName),t),[])}async stepElementsForIntroducedSilentSteps(t,e){const a=this.product;if(!a)return Promise.resolve({stepElements:{},commands:[]});const n=async(c,d,A)=>{if(c.type===I.SilentIllustration){const u=await new ln(c,d).trigger();return{step:c,results:u}}else if(c.type===I.ProductOverlay){const u=await new ln(c,d,A).trigger();return{step:c,results:u}}return Promise.reject("Unknown silent step. This is a bug")},i=t.filter(c=>!this.stepInitialised[c.stepName]),s={stepElements:{},commands:[]},o=[];for(const c of i)this.markStepsAsInitialised([c.stepName]),e||o.push(n(c,this.layouts,a));const l=await Promise.all(o);for(const c of l)s.stepElements[c.step.stepName]=c.results.map(d=>d.regionElement),s.commands=[...s.commands,...c.results.map(d=>d.command)];return s}getStepStorage(t){return this.storage[t]}getMetadata(t){return this.stepMetadata[t]}getWorkflowMetadata(){return this.stepMetadata}getStepTags(t){return this.stepTags[t]||[]}getSerializedStep(t,e){return e.find(a=>a.stepName===t)}async updateTransactionShareActions(){const t=await this.client.getShareActionsForTransaction(this.transaction.id);this.transaction.transactionShareActions=t}async updateTransactionStakeholders(){var e;const t=await B.getShadowGraphqlClient().query({query:Cs,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.transaction.id}});!((e=t==null?void 0:t.data)!=null&&e.transactions)||t.data.transactions.length!==1?(this.transaction.currentStakeholder=void 0,this.transaction.stakeholders=void 0):(this.transaction.stakeholders=t.data.transactions[0].stakeholders,this.transaction.currentStakeholder=t.data.transactions[0].currentStakeholder)}async approveTransaction(t){await B.getShadowGraphqlClient().mutate({mutation:Cl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.getTransaction().id,note:t}})}async rejectTransaction(t){await B.getShadowGraphqlClient().mutate({mutation:wl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.getTransaction().id,note:t}})}async reset(){this.commandContext.getAllLayouts().forEach(e=>e.layoutState.elements.forEach(a=>{this.getCommandDispatcher()(new Ct(a.id))})),this.stepElements={},this.stepInitialised={},this.stepMetadata={},this.stepSelections={},this.storage={},await this.ensureStepsAreLoaded()}async setSelectionsAndElements(t,e,a,n){var y;const i=this.stepSelections;this.stepSelections={...this.stepSelections,[t]:{selectedVariants:e}},this.selectionCost=Object.values(this.stepSelections).reduce((E,b)=>E+b.selectedVariants.map(P=>P.priceModifier||0).reduce((P,x)=>P+x,0),0),this.workflow.steps.forEach(E=>{vt(E,this.stepSelections)||(this.stepInitialised[E.stepName]=!1,delete this.stepMetadata[E.stepName],delete this.stepSelections[E.stepName],delete this.storage[E.stepName])});const s=this.allScenes,o=xt(s,i),l=xt(s,this.stepSelections),c=o.map(E=>E.silentSteps).flat(),A=l.map(E=>E.silentSteps).flat().filter(E=>!c.some(b=>b.stepName===E.stepName));c.forEach(E=>{vt(E,this.stepSelections)||(this.stepInitialised[E.stepName]=!1)});const u=this.getInvalidCanvasRegions(),{stepElements:h,commands:g}=await this.stepElementsForIntroducedSilentSteps(A,!1);this.stepElements={...this.stepElements,...h,[t]:a},this.removeElements(u);const m=this.workflow.steps.find(E=>E.stepName===t);if((m==null?void 0:m.type)===I.Frame){const E=(y=this.getWorkflowExperience().getStepById(m.stepName))==null?void 0:y.frameService;E==null||E.setTargetElements(a.map(b=>b.id))}const p=u.map(E=>new Ct(E.id)),f=new on(this.constructSerializableWorkflow()),C=[...g,...p,f];C.length>0&&this.commandContext.apply(new $(C),!0),await this.ensureStepsAreLoaded(),this.onElementsChange();const w=this.getInvalidModelVariants(),S=this.modelContainer;if(S){const E=w.map(b=>S.applyModelVariant(b,{contextService:this.getLayoutPreviewService()},!1));await Promise.all(E)}await this.onSelectionChange(),n&&await n()}async ensureStepsAreLoaded(){const e=xt(this.allScenes,this.stepSelections).map(l=>l.renderableSteps),a=[],n=e.flat();for(const l of n)if(!this.stepInitialised[l.stepName])switch(this.stepInitialised[l.stepName]=!0,l.type){case I.DigitalContent:a.push(Qa.init(l,this,this.reloadedState));break;case I.Frame:a.push(ut.init(l,this,this.reloadedState));break;case I.Illustration:a.push(Jt.init(l,this,this.reloadedState));break;case I.Material:a.push(Ra.init(l,this,this.reloadedState));break;case I.Model:a.push(Oa.init(l,this,this.reloadedState));break;case I.Module:this.stepSpecificServices[l.stepName]={module:await mr(l.data.module)},a.push($a.init(l,this,this.reloadedState));break;case I.Picture:a.push(Ua.init(l,this,this.reloadedState));break;case I.Question:a.push(La.init(l,this,this.reloadedState));break;case I.Shape:a.push(kt.init(l,this,this.reloadedState));break;case I.Text:a.push(W.init(l,this,this.reloadedState));break}const i=(await Promise.allSettled(a)).map(l=>{if(l.status==="rejected")throw new Error(`Step initialization failed: ${l.reason}`);return l.value}),s=i.filter(l=>!!l&&!!l.command).map(l=>l.command),o=i.filter(l=>!!l&&!!l.followup).map(l=>l.followup);s&&s.length>0&&this.commandContext.apply(new $(s),!0);for(const l of o)await l();o.length>0&&await this.ensureStepsAreLoaded(),this.onInitChange()}onConfirmChange(){this.confirmCallbacks.forEach(t=>t(this.confirmedDesign))}onEditedChange(){this.editedCallbacks.forEach(t=>t(this.editedSteps))}onElementsChange(){this.elementsCallbacks.forEach(t=>t(this.stepElements))}onInformationResultChange(){this.informationResultCallbacks.forEach(t=>t(this.informationResults))}onInitChange(){this.initCallbacks.forEach(t=>t(this.stepInitialised))}onMakingAdjustmentsChange(){this.makingAdjustmentsCallback.forEach(t=>{t(this.currentAdjustingStepId)})}onMandatoryChange(){this.mandatoryCallbacks.forEach(t=>t(this.mandatorySteps))}onMetadataChange(){this.metadataCallbacks.forEach(t=>{t(this.stepMetadata)})}async onSelectionChange(){const t=await this.traversableScenes();for(const e of this.selectionCallbacks)e({selectionCost:this.selectionCost,selections:this.stepSelections,traversableScenes:t})}onStepSpecificStorageChange(t){Object.keys(this.stepSpecificStorageCallbacks).includes(t)||(this.stepSpecificStorageCallbacks[t]=[]),this.stepSpecificStorageCallbacks[t].forEach(e=>e(this.storage[t]))}onStorageChange(){this.storageCallbacks.forEach(t=>t(this.storage))}onValidationChange(){this.validationCallbacks.forEach(t=>t(this.validationErrors))}traversableScenes(){return Rs(this.allScenes,this.stepSelections,this.singleVariantsRenderable)}}class it{constructor(t){this.variantData=t}getType(){var t;return(t=this.variantData.asset)==null?void 0:t.type}getId(){return this.variantData.id}getName(){return this.variantData.name}getPriceFormatted(t,e){return this.variantData.priceModifier.toLocaleString(t||"en-US",{style:"currency",currency:"USD",...e})}getPrice(){return this.variantData.priceModifier}getAsset(){var t,e,a;return(a=(e=(t=this.variantData.asset)==null?void 0:t.versions)==null?void 0:e.find(n=>n.name==="cdn"))==null?void 0:a.link}getAssetResource(){return this.variantData.asset}getThumbnail(){var a,n,i,s;const t=(i=(n=(a=this.variantData.thumbnail)==null?void 0:a.versions)==null?void 0:n.find(o=>o.name==="thumbnail"))==null?void 0:i.link,e=(s=this.variantData.thumbnail)==null?void 0:s.fileLink;return t||e}getColor(){return this.variantData.color}isDefault(){return!!this.variantData.default}getResource(){return this.variantData}isEnabled(){return this.variantData.enabled}}const pr=class pa{constructor(t,e,a){this.manager=t,this.step=e,this.tags=a}setUpdateState(t){pa.updateState.set(`${this.step.stepName}-${this.manager.getTransaction().id}`,t)}getUpdateState(){return!!pa.updateState.get(`${this.step.stepName}-${this.manager.getTransaction().id}`)}getCurrentVariant(){const e=this.manager.getWorkflowSelections()[this.step.stepName],a=e==null?void 0:e.selections[0];if(a)return new it(a)}getAvailableVariants(){var e,a;return(((a=(e=this.step.option)==null?void 0:e.variants)==null?void 0:a.filter(n=>n.enabled))||[]).map(n=>new it(n))}getAllVariants(){var e;return(((e=this.step.option)==null?void 0:e.variants)||[]).map(a=>new it(a))}getId(){return this.step.stepName}getName(){return this.step.stepTitle}getHelpText(){return this.step.helpText}getType(){return this.step.type}getRaw(){return this.step}getTags(){return this.tags}hasTag(t){return this.tags.includes(t)||!1}getMandatory(){return this.step.mandatory||!1}getOverrideGlobalPropertyConfiguration(t){var a;return(((a=this.manager.getStepStorage(this.step.stepName))==null?void 0:a.overrideGlobalConfigurations)??{})[t.toString()]??!1}setOverrideGlobalPropertyConfiguration(t,e){var n;const a=((n=this.manager.getStepStorage(this.step.stepName))==null?void 0:n.overrideGlobalConfigurations)??{};this.manager.updateStorage(this.step.stepName,{overrideGlobalConfigurations:{...a,[t.toString()]:e}})}getGlobalPropertyAspects(t){var e;return((e=this.step.globalPropertyAspectConfigurations)==null?void 0:e.filter(a=>a.globalPropertyConfigurationId===t&&a.aspectName).map(a=>a.aspectName))??[]}executeAnimations(t){const e=this.manager.getPreviewService(),a=this.manager.getModelContainer(),n=this.step.data.modelAnimation,i=this.step.data.lookAtAnimation;e?i&&e.executeCameraAnimation(i):console.warn("No preview service available, cannot execute camera animations."),a?n&&a.executeAnimation(n,t):console.warn("No model container available, cannot execute model animations.")}};pr.updateState=new Map;let rt=pr;class fr extends rt{constructor(t,e,a){super(t,e,a)}async selectVariant(t){if(!this.getUpdateState()&&this.getCurrentVariant()!==t)return Jt.selectVariant(this.step,t.getResource(),this.manager.getRegionElements(this.step.stepName)||[],e=>this.setUpdateState(e),this.manager)}getColors(){var o;const t=this.manager.getRegionElements(this.step.stepName)||[];if(t.length===0)return;const a=L(t[0].id,this.manager.getAllLayoutData()).colors,n=(o=this.getCurrentVariant())==null?void 0:o.getAssetResource(),i=n==null?void 0:n.assetConfiguration,s=(i==null?void 0:i.defaultColorVariants)||[];if(s.length!==0){const l={};return s.forEach(c=>{var A;const d=i.channelNumbers.find(u=>u.number===c.channelNumber);if(d){const u=d.id.replace(/\W/g,"");l[c.channelNumber]={browserValue:((A=a[u])==null?void 0:A.browserValue)||""}}}),l}try{return a}catch(l){console.error(l)}}setColor(t,e,a){var l;const n=new Map,i=(l=this.getCurrentVariant())==null?void 0:l.getAssetResource(),s=i==null?void 0:i.assetConfiguration;return((s==null?void 0:s.defaultColorVariants)||[]).length!==0?s.channelNumbers.forEach(c=>{if(c.number.toString()===t){const d=c.id.replace(/\W/g,"");a?n.set(d,{browserValue:e,pmsValue:a}):n.set(d,e)}}):a?n.set(t,{browserValue:e,pmsValue:a}):n.set(t,e),Jt.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,()=>this.manager.getCommandContext().getAllLayouts(),n)}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?Jt.availableColors(this.step,this.manager):Promise.resolve([])}isColorPickerEnabled(){return this.step.data.colorPickerEnabled??!1}isPMSPickerEnabled(){return this.step.data.pmsPickerEnabled??!1}}class Cr extends rt{constructor(t,e,a){super(t,e,a)}selectVariant(t){return Ra.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class wr extends rt{constructor(t,e,a){super(t,e,a)}selectVariant(t){return Oa.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class yr extends rt{constructor(t,e,a){super(t,e,a)}selectVariant(t){return Ua.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class Sr extends rt{constructor(t,e,a){super(t,e,a)}async selectVariant(t){if(!t.getId())throw new Error("Unable to select variant with a null ID");await La.selectVariant(this.step,t.getId(),this.manager)}getDisplayType(){var t;return this.step.data.displayType||((t=this.step.option)==null?void 0:t.displayType)}}class vr extends rt{constructor(t,e,a){super(t,e,a)}selectVariant(t){const e=t.getResource();return kt.selectVariant(this.step,{fill:e.color,stroke:e.color,variant:e},this.manager.getRegionElements(this.step.stepName)||[],this.manager)}setColor(t){return kt.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return kt.availableColours(this.step)}setCustomColor(t){var e,a;return((e=this.getCurrentVariant())==null?void 0:e.getColor())!=="#custom"&&console.warn(`setting custom color for step ${this.step.stepName} but color is ${(a=this.getCurrentVariant())==null?void 0:a.getColor()}`),kt.setCustomColor(t,this.step,this.manager)}getCustomColor(){var e,a,n;((e=this.getCurrentVariant())==null?void 0:e.getColor())!=="#custom"&&console.warn(`setting custom color for step ${this.step.stepName} but color is ${(a=this.getCurrentVariant())==null?void 0:a.getColor()}`);const t=(n=this.manager.getStepStorage(this.step.stepName))==null?void 0:n.colour;if(!t)throw new Error(`Color not available on step ${this.step.stepName}. Set a default on the workflow to fix this.`);return t}}class Er extends rt{constructor(t,e,a){super(t,e,a)}async selectVariant(t){W.selectVariant(this.step,t.getResource(),this.manager,e=>{if(e)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occurred with text",messageType:me.Error,stepID:this.step.stepName}]);else{const a=this.manager.getInformationResults().filter(n=>n.stepID!==this.step.stepName);this.manager.setInformationResults(a)}},()=>{})}getAvailableFillColors(){return this.step.data.colorPickerEnabled?W.availableFillColors(this.step):[]}async setFillColor(t){const e=this.manager.getRegionElements(this.step.stepName);await W.changeFillColor(this.step,t,e,this.manager)}getFillColor(){var t;return((t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.color)||"#000000"}getAvailableFillImages(){return W.availableFillImages(this.step)}async setFillImage(t){const e=this.manager.getRegionElements(this.step.stepName);await W.changeFillImage(this.step,t,e,this.manager)}getFillImage(){var t;return(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.fillImage}getAlignment(){const t=W.findLayoutElements(this.manager,this.step);return t==null?void 0:t[0].align}setAlignment(t){const e=this.manager.getRegionElements(this.step.stepName);W.changeAlignment(this.step,t,e,this.manager)}setFullTextCustomization(t){var s;const e=((s=this.manager.getStepStorage(this.step.stepName))==null?void 0:s.inputText)||"",a=this.step.data.replaceableText!==void 0?this.step.data.replaceableText.replace("{{}}",e):e,n=t?a:this.step.data.defaultText;return this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:n,defaultCleared:!1}),this.setText(n)}setText(t){var A;const e={input:t,helperData:{}},a=W.findLayoutElements(this.manager,this.step),n=W.filterUnsupportedCharacters(t,(A=a[0])==null?void 0:A.fontData),i=ne(n,this.manager).length,s=!!this.step.data&&!!this.step.data.maxLength&&i>this.step.data.maxLength;s||(e.input=n);const o=a.length<=0,l=o?{inputText:n,text:n}:{inputText:n};this.manager.updateStorage(this.step.stepName,l);const c=this.manager.getStepStorage(this.step.stepName),d=W.getProcessedInput(n,this.step.data,(c==null?void 0:c.customiseAllText)??!1);if(o)s||this.manager.updateMetadata(this.step.stepName,{text:d});else{const{command:u,errorData:h,helperData:g}=W.updateInputText(n,a,this.step,this.manager);u&&this.manager.getCommandDispatcher()(u),e.helperData=g,e.errorData=h,!s&&!h&&this.manager.updateMetadata(this.step.stepName,{text:d})}return e}getText(){var a;const t=this.step.data.defaultText,e=this.manager.getStepStorage(this.step.stepName);return t&&(e==null?void 0:e.defaultCleared)!==void 0&&!(e!=null&&e.defaultCleared)?t:((a=this.manager.getStepStorage(this.step.stepName))==null?void 0:a.text)||""}isReplaceable(){return this.step.data.userCanReplaceText}newLinesSupported(){return this.step.data.allowNewlines||!1}clearDefaultTextIfNecessary(){const t=this.manager.getStepStorage(this.step.stepName);if(!(t!=null&&t.defaultCleared)&&this.step.data.deleteDefaultOnFocus){const e=this.setText("");this.manager.updateStorage(this.step.stepName,{defaultCleared:!0,inputText:""});const a=W.findLayoutElements(this.manager,this.step);return W.updateInputText("",a,this.step,this.manager),e}}hasColorPicker(){return this.step.data.colorPickerEnabled}getRegions(){return this.step.data.regions}getCharacterLimit(){return this.step.data.maxLength}getCharactersRemaining(){const t=this.step.data.maxLength;if(t===void 0)return;const e=ne(this.getText(),this.manager);return t-e.length}setCustomColor(t){throw new Error("Custom color support is not yet available on text. Check back soon.")}getCustomColor(){throw new Error("Custom color support is not yet available on text. Check back soon.")}getAvailableStrokeColors(){return this.step.data.strokeEnabled?W.availableStrokeColors(this.step):[]}getStrokeColor(){var t,e;return((e=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.strokeColor)==null?void 0:e.browserValue)||"#000000"}async setStrokeColor(t){const e=this.manager.getRegionElements(this.step.stepName);await W.changeStrokeColor(this.step,t,e,this.manager)}}class br extends rt{constructor(t,e,a){super(t,e,a)}async selectVariant(){}getContent(){return this.step.data.content}}class Br extends rt{constructor(t,e,a){super(t,e,a)}async selectVariant(){}getPreviewURL(){var t;return((t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.videoUrl)||""}async selectVideo(t){return Qa.regenerateQRCode(this.manager.getRegionElements(this.step.stepName),t.key,this.manager,this.step)}}class Ir extends rt{constructor(t,e,a){super(t,e,a)}async selectVariant(){console.info("Text Modules don't support variants.")}getCharactersRemaining(){const t=this.step.data.maxLength;if(t===void 0)return;const e=ne(this.getText(),this.manager);return t-e.length}getCharacterLimit(){return this.step.data.maxLength}getText(){var t;return((t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.text)||""}setText(t){$a.changeText(this.step,t,this.manager,e=>{if(e){const a=[...this.manager.getInformationResults(),{message:e,messageType:me.Error,stepID:this.step.stepName}];this.manager.setInformationResults(a)}else{const a=this.manager.getInformationResults().filter(n=>n.stepID!==this.step.stepName);this.manager.setInformationResults(a)}})}}class ye{static get(t,e){switch(e.type){case I.DigitalContent:return new Br(t,e,t.getStepTags(e.stepName));case I.Information:return new br(t,e,t.getStepTags(e.stepName));case I.Question:return new Sr(t,e,t.getStepTags(e.stepName));case I.Text:return new Er(t,e,t.getStepTags(e.stepName));case I.Illustration:return new fr(t,e,t.getStepTags(e.stepName));case I.Picture:return new yr(t,e,t.getStepTags(e.stepName));case I.Shape:return new vr(t,e,t.getStepTags(e.stepName));case I.Material:return new Cr(t,e,t.getStepTags(e.stepName));case I.Model:return new wr(t,e,t.getStepTags(e.stepName));case I.Frame:return new Kr(t,e,t.getStepTags(e.stepName));case I.Module:return new Ir(t,e,t.getStepTags(e.stepName));default:throw new z(`Step type ${e.type} not yet supported in Core SDK`)}}}const Pr=v.gql`
2200
+ `;var me=(r=>(r.Error="Error",r.Warning="Warning",r.Info="Info",r))(me||{});const bl=1e3;class un extends Pa{constructor(t){super(),this.createdAt=new Date,this.update=t}async execute(){await this.update(),await new Promise(t=>{window.setTimeout(()=>{t()},bl)})}}class Bl{constructor(t,e,a,n,i,s,o,l,c,d,A,u,h,g=!1,m,p=!1,f=!1,C=!1){var w;this.workflowStatePromiseQueue=new Fa(1),this.initialized=!1,this.readOnly=!1,this.isReloadedTransaction=!1,this.singleVariantsRenderable=!1,this.stepTags={},this.renderLayouts=()=>{var E;if(!this.previewService)return;const S=this.getCommandContext().getAllLayouts(),y=(E=this.getLayoutPreviewService())==null?void 0:E.getAll();if(y)for(const[,b]of y)b.render(S)},this.experience=t,this.client=e,this.updateTransaction=o,this.graphQlClient=l,this.commandContext=s,this.reloadedState=h,this.transaction=c,this.readOnly=g,this.singleVariantsRenderable=f,this.confirmedDesign=!1,this.editedSteps={},this.informationResults=[],this.mandatorySteps={},this.pendingUpdates=[],this.selectionCost=0,this.workflow=a,this.stepSpecificServices={},this.profanityFilter=n,this.pollers=[],this.allScenes=[],this.layouts=i,this.product=d,this.previewService=A,this.modelContainer=m,this.stepElements={},this.stepInitialised={},this.stepMetadata={},this.stepSelections={},this.storage={},this.validationErrors={steps:new Map},this.confirmCallbacks=[],this.editedCallbacks=[],this.elementsCallbacks=[],this.informationResultCallbacks=[],this.initCallbacks=[],this.mandatoryCallbacks=[],this.makingAdjustmentsCallback=[],this.metadataCallbacks=[],this.selectionCallbacks=[],this.stepSpecificStorageCallbacks={},this.storageCallbacks=[],this.validationCallbacks=[],this.recipientCallbacks=[],this.currentAdjustingStepId="",this.renderableContextService=u,(w=this.renderableContextService)==null||w.setWorkflowManager(this),this.isReloadedTransaction=p,this.workflow.steps.forEach(S=>{this.stepTags[S.stepName]=S.tags??[]}),C&&(this.workflowStatePromiseQueue.enabled=!1),this.initializationPromise=this.initializeDefaultWorkflowState(a),this.initializationPromise.then(()=>{this.initialized=!0}),this.initializationPromise.catch(S=>{throw console.error(S),this.initialized=!1,new Error("Workflow initialization failed due to an error. See console.")}),this.initializationPromise.finally(()=>this.getCommandContext().registerStateCallback(()=>{this.updateStateWithServer(),this.renderLayouts()}))}async getTemplatingContext(){var a,n;const t=this.transaction.recipient;if(t!=null&&t.conversionConfigurationId&&!this.recipientConversionConfiguration){const i=await this.graphQlClient().query({query:gs,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t.conversionConfigurationId}});i.data.conversionConfiguration&&(this.recipientConversionConfiguration=i.data.conversionConfiguration)}const e={recipient:t};return(n=(a=this.recipientConversionConfiguration)==null?void 0:a.requestedDataItems)==null||n.forEach(i=>{if(i.type===Ya.Custom){const s=i.uniqueIdentifier??i.title??"";i.customFieldIndex===1?e[s]=t==null?void 0:t.customField1:i.customFieldIndex===2?e[s]=t==null?void 0:t.customField2:i.customFieldIndex===3?e[s]=t==null?void 0:t.customField3:i.customFieldIndex===4?e[s]=t==null?void 0:t.customField4:i.customFieldIndex===5&&(e[s]=t==null?void 0:t.customField5)}}),e}async updateRecipient(t,e,a,n,i,s,o,l,c,d,A,u,h,g,m,p,f){var C,w,S,y,E;if((C=this.transaction.recipient)!=null&&C.id)this.transaction.recipient={id:this.transaction.recipient.id,firstName:t||this.transaction.recipient.firstName,lastName:e||this.transaction.recipient.lastName,address:a||this.transaction.recipient.address,suburb:n||this.transaction.recipient.suburb,state:i||this.transaction.recipient.state,email:s||this.transaction.recipient.email,postalCode:o||this.transaction.recipient.postalCode,country:l||this.transaction.recipient.country,mobile:c||this.transaction.recipient.mobile,company:d||this.transaction.recipient.company,apartment:A||this.transaction.recipient.apartment,customField1:u||this.transaction.recipient.customField1,customField2:h||this.transaction.recipient.customField2,customField3:g||this.transaction.recipient.customField3,customField4:m||this.transaction.recipient.customField4,customField5:p||this.transaction.recipient.customField5,conversionConfigurationId:f||this.transaction.recipient.conversionConfigurationId},await this.graphQlClient().mutate({mutation:vl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.transaction.recipient.id,firstName:t||this.transaction.recipient.firstName,lastName:e||this.transaction.recipient.lastName,address:a||this.transaction.recipient.address,suburb:n||this.transaction.recipient.suburb,state:i||this.transaction.recipient.state,email:s||this.transaction.recipient.email,postalCode:o||this.transaction.recipient.postalCode,country:l||this.transaction.recipient.country,mobile:c||this.transaction.recipient.mobile,company:d||this.transaction.recipient.company,apartment:A||this.transaction.recipient.apartment,customField1:u||this.transaction.recipient.customField1,customField2:h||this.transaction.recipient.customField2,customField3:g||this.transaction.recipient.customField3,customField4:m||this.transaction.recipient.customField4,customField5:p||this.transaction.recipient.customField5,conversionConfigurationId:f||this.transaction.recipient.conversionConfigurationId}});else{const b=await this.graphQlClient().mutate({mutation:Sl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{firstName:t,lastName:e,address:a,suburb:n,state:i,email:s,postalCode:o,country:l,mobile:c,company:d,apartment:A,customField1:u,customField2:h,customField3:g,customField4:m,customField5:p}});this.transaction.recipient={id:(S=(w=b==null?void 0:b.data)==null?void 0:w.recipientCreate)==null?void 0:S.id,firstName:t,lastName:e,address:a,suburb:n,state:i,email:s,postalCode:o,country:l,mobile:c,company:d,apartment:A,customField1:u,customField2:h,customField3:g,customField4:m,customField5:p},await this.graphQlClient().mutate({mutation:El,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.transaction.id,recipientId:(E=(y=b.data)==null?void 0:y.recipientCreate)==null?void 0:E.id},context:{transactionOwnerId:this.transaction.transactionOwnerId}})}this.recipientCallbacks.forEach(b=>b(this.transaction.recipient))}async initializeDefaultWorkflowState(t){const e=()=>{var d,A;const o=this.workflow.finalizeStepConfig;if(!o)return;const l=o.lookAtAnimation,c=o.modelAnimation;l&&((d=this.previewService)==null||d.executeCameraAnimation(l)),c&&((A=this.modelContainer)==null||A.executeAnimation(c))};this.reloadedState&&this.reloadedState.serializableWorkflow.steps.forEach(o=>{this.storage[o.stepName]=o.storage||{}}),this.allScenes=await Ns(t);const n=Dt(this.allScenes,this.stepSelections).map(o=>o.silentSteps).flat(),{stepElements:i,commands:s}=await this.stepElementsForIntroducedSilentSteps(n,!!this.reloadedState);this.commandContext.apply(new $(s),!0),this.stepElements={...this.stepElements,...i},await this.ensureStepsAreLoaded(),!this.isReloadedTransaction&&this.updateStateWithServer(),this.renderLayouts(),this.reloadedState&&e()}getWorkflowExperience(){return this.experience}getClient(){return this.client}setWorkflowStateSyncEnabled(t){this.workflowStatePromiseQueue.enabled=t}getProduct(){return this.product}getInitializationPromise(){return this.initializationPromise}isInitialized(){return this.initialized}addConfirmCallback(t){t(this.confirmedDesign),this.confirmCallbacks.push(t)}addEditedCallback(t){t(this.editedSteps),this.editedCallbacks.push(t)}addElementsCallback(t){t(this.stepElements),this.elementsCallbacks.push(t)}addInformationResultCallback(t){t(this.informationResults),this.informationResultCallbacks.push(t)}addInitCallback(t){t(this.stepInitialised),this.initCallbacks.push(t)}addMandatoryCallback(t){t(this.mandatorySteps),this.mandatoryCallbacks.push(t)}addMetadataCallback(t){t(this.stepMetadata),this.metadataCallbacks.push(t)}async addSelectionCallback(t){t({selectionCost:this.selectionCost,selections:this.stepSelections,traversableScenes:await this.traversableScenes()}),this.selectionCallbacks.push(t)}addStepSpecificStorageCallback(t,e){Object.keys(this.storage).includes(e)||(this.storage[e]={}),t(this.storage[e]),Object.keys(this.stepSpecificStorageCallbacks).includes(e)||(this.stepSpecificStorageCallbacks[e]=[]),this.stepSpecificStorageCallbacks[e].push(t)}addStorageCallback(t){t(this.storage),this.storageCallbacks.push(t)}addMakingAdjustmentsCallback(t){t(this.currentAdjustingStepId),this.makingAdjustmentsCallback.push(t)}addPoller(t){this.pollers.push(t)}addValidationCallback(t){this.validationCallbacks.push(t),t(this.validationErrors)}addRecipientCallback(t){this.recipientCallbacks.push(t),t(this.transaction.recipient)}removeRecipientCallback(t){this.recipientCallbacks=this.recipientCallbacks.filter(e=>e!==t)}getLayouts(){return this.layouts}getAllLayoutData(){return this.commandContext.getAllLayouts().map(t=>t.layoutState)}getLayoutPreviewService(){return this.renderableContextService}getInformationResults(){return this.informationResults}getPreviewService(){return this.previewService}getProfanities(){return this.profanityFilter}getCommandContext(){return this.commandContext}getRegionElements(t){return this.stepElements[t]||[]}getStepSpecificServices(t){return this.stepSpecificServices[t]}getTransaction(){return this.transaction}getTransactionCustomer(){return this.ownerCustomer}setTransactionCustomer(t){this.ownerCustomer=t}setTransactionCustomerDetails(t){this.ownerCustomer={...this.ownerCustomer,emailAddress:t.email}}getModelContainer(){return this.modelContainer}setModelContainer(t){(!t||this.previewService&&this.previewService.getAllModels().includes(t))&&(this.modelContainer=t,t&&t.metadata&&t.metadata instanceof Map&&this.modelContainer.metadata.set("workflowManager",this))}setTransaction(t){this.transaction=t}getWorkflow(){return this.workflow}getCommandDispatcher(){return t=>this.commandContext.apply(t,!this.initialized)}getWorkflowSelections(){const t={};return this.workflow.steps.forEach(e=>{const a=this.stepSelections[e.stepName];a&&a.selectedVariants&&a.selectedVariants.length>0&&(t[e.stepName]={selections:a.selectedVariants})}),t}getStepSelections(){return this.stepSelections}markStepsAsInitialised(t){const e={...this.stepInitialised};t.forEach(a=>{e[a]=!0}),this.stepInitialised=e,this.onInitChange()}getUpdatesPending(){return this.pendingUpdates.length>0}markUpdateCompleted(t){this.pendingUpdates=this.pendingUpdates.filter(e=>e!==t)}markUpdatePending(){const t=Q();return this.pendingUpdates=[...this.pendingUpdates,t],t}setEditedStatus(t,e){this.editedSteps={...this.editedSteps,[t]:e},this.onEditedChange()}setInformationResults(t){this.informationResults=[...t],this.onInformationResultChange()}setCurrentAdjustingStepId(t){this.currentAdjustingStepId=t,this.onMakingAdjustmentsChange()}setMandatoryFulfilled(t,e){this.mandatorySteps[t]!==e&&(this.mandatorySteps={...this.mandatorySteps,[t]:e},this.onMandatoryChange())}setStepError(t,e,a){let n=!1;if(!this.validationErrors.steps.has(t)&&a)n=!0,this.validationErrors.steps.set(t,new Map([[e,a]]));else if(this.validationErrors.steps.has(t)){const i=this.validationErrors.steps.get(t);a&&a!==i.get(e)?(n=!0,i.set(e,a)):a||(n=!0,i.delete(e),i.size===0&&this.validationErrors.steps.delete(t))}n&&this.onValidationChange()}getStepErrors(t){return this.validationErrors.steps.get(t)}getValidationErrors(){return this.validationErrors}toggleDesignConfirmed(){this.confirmedDesign=!this.confirmedDesign,this.onConfirmChange()}toggleMakingAdjustmentsCallback(t){t(this.mandatorySteps),this.mandatoryCallbacks.push(t)}async injectIntoPreviewService(t,e){if(this.modelContainer)throw new Error("You must eject from the preview service before injecting again.");if(this.previewService=t,!this.getProduct().modelUrl||!this.previewService)return;const a=t.loadModel({model:this.getProduct().modelUrl,contextService:this.getLayoutPreviewService()},{refocusCamera:e});this.setModelContainer(a),Dt(this.allScenes,this.stepSelections).filter(s=>s).map(s=>s.renderableSteps).flat().filter(s=>s.type===I.Model||s.type===I.Material).forEach(s=>{var c,d,A;if(!((c=s.option)!=null&&c.id)){console.error(`Failed to read option id from step: ${s.stepName}`);return}const o=((d=this.stepSelections[s.stepName])==null?void 0:d.selectedVariants)||[];if(o.length===0)return;const l=o[0];if(s.type===I.Model){if(!this.modelContainer)throw new z("We should always have a model container when injecting a preview!");const u=(A=l.asset)==null?void 0:A.fileLink;if(!u){console.error(`Failed to read model url from variant: ${l.id} for step: ${s.stepName}`);return}const h=s.data;this.modelContainer.applyModelVariant(s.stepName,{model:u,contextService:this.getLayoutPreviewService()},h.replaceProductModel||!1)}else{const u=l.material;if(!u){console.error(`Failed to read material from variant: ${l.id} for step: ${s.stepName}`);return}s.data.targetMaterials.forEach(g=>{if(!this.modelContainer)throw new z("We should always have a model container when injecting a preview!");this.modelContainer.applyMaterialVariant(g,s.option.id,u)})}}),await a.getInitializationPromise(),this.renderLayouts()}ejectFromPreviewService(){if(this.modelContainer){if(!this.modelContainer.dispose)throw new Error("This feature is not supported in the current preview service.");this.modelContainer.dispose(),this.modelContainer=void 0}this.previewService=void 0}updateStorage(t,e){const a={...this.storage,[t]:{...this.storage[t],...e}};if(!En(a,this.storage)){this.storage=a;const n=new ln(this.constructSerializableWorkflow());this.commandContext.apply(n,!0),this.onStepSpecificStorageChange(t),this.onStorageChange()}}constructSerializableWorkflow(){const t=[];return this.allScenes.forEach(e=>{e.renderableSteps.forEach(a=>{var i,s;const n={stepName:a.stepName};n.storage=this.storage[a.stepName],n.selectedVariants=(s=(i=this.stepSelections[a.stepName])==null?void 0:i.selectedVariants)==null?void 0:s.map(o=>({id:o.id,priceModifier:o.priceModifier})),t.push(n)})}),{steps:t}}updateStateWithServer(){if(this.readOnly)return;const t=this.serialize();this.workflowStatePromiseQueue.enqueue(new un(async()=>{await new Promise(e=>{setTimeout(()=>{e()},1)}),await this.updateTransaction({variables:{id:this.transaction.id,workflowState:t}})}))}async updateStateWithServerImmediate(){if(this.readOnly)return;const t=this.serialize();return new un(async()=>{await this.updateTransaction({variables:{id:this.transaction.id,workflowState:t}})}).execute()}serialize(){const t=this.getCommandContext().getState();if(!t)throw new z("Attempted to serialize state before it was initialized.");const e=Et(t.transaction),a=this.dehydrateState(e);return JSON.stringify(a)}dehydrateState(t){var e;for(const a of Object.values(t.layouts).map(n=>n.elements).flat())a.type==="illustration"&&(delete a.cachedObjectURL,a.src&&delete a.svg),a.type==="frame"&&((e=a.pattern)==null||delete e.svg);return this.deleteFieldNameFromObjectRecursive(t,"__typename"),t}deleteFieldNameFromObjectRecursive(t,e){if(!(typeof t!="object"||t===null))for(const a in t)a===e?delete t[a]:this.deleteFieldNameFromObjectRecursive(t[a],e)}async outstandingRequestsPromise(){return this.workflowStatePromiseQueue.finalize()}updateMetadata(t,e){this.stepMetadata={...this.stepMetadata,[t]:{...this.stepMetadata[t],...e}},this.onMetadataChange()}removeElements(t){const e=(a,n)=>Object.keys(a).reduce((i,s)=>{const o=[...a[s]||[]];return n.forEach(l=>{const c=o.findIndex(d=>d.id===l.id);c>-1&&o.splice(c,1)}),i[s]=o,i},{});this.stepElements=e(this.stepElements,t)}getInvalidCanvasRegions(){return this.workflow.steps.reduce((t,e)=>(vt(e,this.stepSelections)||this.stepElements[e.stepName]&&this.stepElements[e.stepName].forEach(a=>t.push(a)),t),[])}getInvalidModelVariants(){return this.workflow.steps.reduce((t,e)=>(e.type===I.Model&&!vt(e,this.stepSelections)&&t.push(e.stepName),t),[])}async stepElementsForIntroducedSilentSteps(t,e){const a=this.product;if(!a)return Promise.resolve({stepElements:{},commands:[]});const n=async(c,d,A)=>{if(c.type===I.SilentIllustration){const u=await new cn(c,d).trigger();return{step:c,results:u}}else if(c.type===I.ProductOverlay){const u=await new cn(c,d,A).trigger();return{step:c,results:u}}return Promise.reject("Unknown silent step. This is a bug")},i=t.filter(c=>!this.stepInitialised[c.stepName]),s={stepElements:{},commands:[]},o=[];for(const c of i)this.markStepsAsInitialised([c.stepName]),e||o.push(n(c,this.layouts,a));const l=await Promise.all(o);for(const c of l)s.stepElements[c.step.stepName]=c.results.map(d=>d.regionElement),s.commands=[...s.commands,...c.results.map(d=>d.command)];return s}getStepStorage(t){return this.storage[t]}getMetadata(t){return this.stepMetadata[t]}getWorkflowMetadata(){return this.stepMetadata}getStepTags(t){return this.stepTags[t]||[]}getSerializedStep(t,e){return e.find(a=>a.stepName===t)}async updateTransactionShareActions(){const t=await this.client.getShareActionsForTransaction(this.transaction.id);this.transaction.transactionShareActions=t}async updateTransactionStakeholders(){var e;const t=await B.getShadowGraphqlClient().query({query:ws,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.transaction.id}});!((e=t==null?void 0:t.data)!=null&&e.transactions)||t.data.transactions.length!==1?(this.transaction.currentStakeholder=void 0,this.transaction.stakeholders=void 0):(this.transaction.stakeholders=t.data.transactions[0].stakeholders,this.transaction.currentStakeholder=t.data.transactions[0].currentStakeholder)}async approveTransaction(t){await B.getShadowGraphqlClient().mutate({mutation:wl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.getTransaction().id,note:t}})}async rejectTransaction(t){await B.getShadowGraphqlClient().mutate({mutation:yl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.getTransaction().id,note:t}})}async reset(){this.commandContext.getAllLayouts().forEach(e=>e.layoutState.elements.forEach(a=>{this.getCommandDispatcher()(new Ct(a.id))})),this.stepElements={},this.stepInitialised={},this.stepMetadata={},this.stepSelections={},this.storage={},await this.ensureStepsAreLoaded()}async setSelectionsAndElements(t,e,a,n){var y;const i=this.stepSelections;this.stepSelections={...this.stepSelections,[t]:{selectedVariants:e}},this.selectionCost=Object.values(this.stepSelections).reduce((E,b)=>E+b.selectedVariants.map(P=>P.priceModifier||0).reduce((P,D)=>P+D,0),0),this.workflow.steps.forEach(E=>{vt(E,this.stepSelections)||(this.stepInitialised[E.stepName]=!1,delete this.stepMetadata[E.stepName],delete this.stepSelections[E.stepName],delete this.storage[E.stepName])});const s=this.allScenes,o=Dt(s,i),l=Dt(s,this.stepSelections),c=o.map(E=>E.silentSteps).flat(),A=l.map(E=>E.silentSteps).flat().filter(E=>!c.some(b=>b.stepName===E.stepName));c.forEach(E=>{vt(E,this.stepSelections)||(this.stepInitialised[E.stepName]=!1)});const u=this.getInvalidCanvasRegions(),{stepElements:h,commands:g}=await this.stepElementsForIntroducedSilentSteps(A,!1);this.stepElements={...this.stepElements,...h,[t]:a},this.removeElements(u);const m=this.workflow.steps.find(E=>E.stepName===t);if((m==null?void 0:m.type)===I.Frame){const E=(y=this.getWorkflowExperience().getStepById(m.stepName))==null?void 0:y.frameService;E==null||E.setTargetElements(a.map(b=>b.id))}const p=u.map(E=>new Ct(E.id)),f=new ln(this.constructSerializableWorkflow()),C=[...g,...p,f];C.length>0&&this.commandContext.apply(new $(C),!0),await this.ensureStepsAreLoaded(),this.onElementsChange();const w=this.getInvalidModelVariants(),S=this.modelContainer;if(S){const E=w.map(b=>S.applyModelVariant(b,{contextService:this.getLayoutPreviewService()},!1));await Promise.all(E)}await this.onSelectionChange(),n&&await n()}async ensureStepsAreLoaded(){const e=Dt(this.allScenes,this.stepSelections).map(l=>l.renderableSteps),a=[],n=e.flat();for(const l of n)if(!this.stepInitialised[l.stepName])switch(this.stepInitialised[l.stepName]=!0,l.type){case I.DigitalContent:a.push(Qa.init(l,this,this.reloadedState));break;case I.Frame:a.push(ut.init(l,this,this.reloadedState));break;case I.Illustration:a.push(Jt.init(l,this,this.reloadedState));break;case I.Material:a.push(Ra.init(l,this,this.reloadedState));break;case I.Model:a.push(Oa.init(l,this,this.reloadedState));break;case I.Module:this.stepSpecificServices[l.stepName]={module:await pr(l.data.module)},a.push($a.init(l,this,this.reloadedState));break;case I.Picture:a.push(Ua.init(l,this,this.reloadedState));break;case I.Question:a.push(La.init(l,this,this.reloadedState));break;case I.Shape:a.push(kt.init(l,this,this.reloadedState));break;case I.Text:a.push(W.init(l,this,this.reloadedState));break}const i=(await Promise.allSettled(a)).map(l=>{if(l.status==="rejected")throw new Error(`Step initialization failed: ${l.reason}`);return l.value}),s=i.filter(l=>!!l&&!!l.command).map(l=>l.command),o=i.filter(l=>!!l&&!!l.followup).map(l=>l.followup);s&&s.length>0&&this.commandContext.apply(new $(s),!0);for(const l of o)await l();o.length>0&&await this.ensureStepsAreLoaded(),this.onInitChange()}onConfirmChange(){this.confirmCallbacks.forEach(t=>t(this.confirmedDesign))}onEditedChange(){this.editedCallbacks.forEach(t=>t(this.editedSteps))}onElementsChange(){this.elementsCallbacks.forEach(t=>t(this.stepElements))}onInformationResultChange(){this.informationResultCallbacks.forEach(t=>t(this.informationResults))}onInitChange(){this.initCallbacks.forEach(t=>t(this.stepInitialised))}onMakingAdjustmentsChange(){this.makingAdjustmentsCallback.forEach(t=>{t(this.currentAdjustingStepId)})}onMandatoryChange(){this.mandatoryCallbacks.forEach(t=>t(this.mandatorySteps))}onMetadataChange(){this.metadataCallbacks.forEach(t=>{t(this.stepMetadata)})}async onSelectionChange(){const t=await this.traversableScenes();for(const e of this.selectionCallbacks)e({selectionCost:this.selectionCost,selections:this.stepSelections,traversableScenes:t})}onStepSpecificStorageChange(t){Object.keys(this.stepSpecificStorageCallbacks).includes(t)||(this.stepSpecificStorageCallbacks[t]=[]),this.stepSpecificStorageCallbacks[t].forEach(e=>e(this.storage[t]))}onStorageChange(){this.storageCallbacks.forEach(t=>t(this.storage))}onValidationChange(){this.validationCallbacks.forEach(t=>t(this.validationErrors))}traversableScenes(){return Os(this.allScenes,this.stepSelections,this.singleVariantsRenderable)}}class it{constructor(t){this.variantData=t}getType(){var t;return(t=this.variantData.asset)==null?void 0:t.type}getId(){return this.variantData.id}getName(){return this.variantData.name}getPriceFormatted(t,e){return this.variantData.priceModifier.toLocaleString(t||"en-US",{style:"currency",currency:"USD",...e})}getPrice(){return this.variantData.priceModifier}getAsset(){var t,e,a;return(a=(e=(t=this.variantData.asset)==null?void 0:t.versions)==null?void 0:e.find(n=>n.name==="cdn"))==null?void 0:a.link}getAssetResource(){return this.variantData.asset}getThumbnail(){var a,n,i,s;const t=(i=(n=(a=this.variantData.thumbnail)==null?void 0:a.versions)==null?void 0:n.find(o=>o.name==="thumbnail"))==null?void 0:i.link,e=(s=this.variantData.thumbnail)==null?void 0:s.fileLink;return t||e}getColor(){return this.variantData.color}isDefault(){return!!this.variantData.default}getResource(){return this.variantData}isEnabled(){return this.variantData.enabled}}const fr=class pa{constructor(t,e,a){this.manager=t,this.step=e,this.tags=a}setUpdateState(t){pa.updateState.set(`${this.step.stepName}-${this.manager.getTransaction().id}`,t)}getUpdateState(){return!!pa.updateState.get(`${this.step.stepName}-${this.manager.getTransaction().id}`)}getCurrentVariant(){const e=this.manager.getWorkflowSelections()[this.step.stepName],a=e==null?void 0:e.selections[0];if(a)return new it(a)}getAvailableVariants(){var e,a;return(((a=(e=this.step.option)==null?void 0:e.variants)==null?void 0:a.filter(n=>n.enabled))||[]).map(n=>new it(n))}getAllVariants(){var e;return(((e=this.step.option)==null?void 0:e.variants)||[]).map(a=>new it(a))}getId(){return this.step.stepName}getName(){return this.step.stepTitle}getHelpText(){return this.step.helpText}getType(){return this.step.type}getRaw(){return this.step}getTags(){return this.tags}hasTag(t){return this.tags.includes(t)||!1}getMandatory(){return this.step.mandatory||!1}getOverrideGlobalPropertyConfiguration(t){var a;return(((a=this.manager.getStepStorage(this.step.stepName))==null?void 0:a.overrideGlobalConfigurations)??{})[t.toString()]??!1}setOverrideGlobalPropertyConfiguration(t,e){var n;const a=((n=this.manager.getStepStorage(this.step.stepName))==null?void 0:n.overrideGlobalConfigurations)??{};this.manager.updateStorage(this.step.stepName,{overrideGlobalConfigurations:{...a,[t.toString()]:e}})}getGlobalPropertyAspects(t){var e;return((e=this.step.globalPropertyAspectConfigurations)==null?void 0:e.filter(a=>a.globalPropertyConfigurationId===t&&a.aspectName).map(a=>a.aspectName))??[]}executeAnimations(t){const e=this.manager.getPreviewService(),a=this.manager.getModelContainer(),n=this.step.data.modelAnimation,i=this.step.data.lookAtAnimation;e?i&&e.executeCameraAnimation(i):console.warn("No preview service available, cannot execute camera animations."),a?n&&a.executeAnimation(n,t):console.warn("No model container available, cannot execute model animations.")}};fr.updateState=new Map;let nt=fr;class Cr extends nt{constructor(t,e,a){super(t,e,a)}async selectVariant(t){if(!this.getUpdateState()&&this.getCurrentVariant()!==t)return Jt.selectVariant(this.step,t.getResource(),this.manager.getRegionElements(this.step.stepName)||[],e=>this.setUpdateState(e),this.manager)}getColors(){var o;const t=this.manager.getRegionElements(this.step.stepName)||[];if(t.length===0)return;const a=L(t[0].id,this.manager.getAllLayoutData()).colors,n=(o=this.getCurrentVariant())==null?void 0:o.getAssetResource(),i=n==null?void 0:n.assetConfiguration,s=(i==null?void 0:i.defaultColorVariants)||[];if(s.length!==0){const l={};return s.forEach(c=>{var A;const d=i.channelNumbers.find(u=>u.number===c.channelNumber);if(d){const u=d.id.replace(/\W/g,"");l[c.channelNumber]={browserValue:((A=a[u])==null?void 0:A.browserValue)||""}}}),l}try{return a}catch(l){console.error(l)}}setColor(t,e,a){var l;const n=new Map,i=(l=this.getCurrentVariant())==null?void 0:l.getAssetResource(),s=i==null?void 0:i.assetConfiguration;return((s==null?void 0:s.defaultColorVariants)||[]).length!==0?s.channelNumbers.forEach(c=>{if(c.number.toString()===t){const d=c.id.replace(/\W/g,"");a?n.set(d,{browserValue:e,pmsValue:a}):n.set(d,e)}}):a?n.set(t,{browserValue:e,pmsValue:a}):n.set(t,e),Jt.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,()=>this.manager.getCommandContext().getAllLayouts(),n)}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?Jt.availableColors(this.step,this.manager):Promise.resolve([])}isColorPickerEnabled(){return this.step.data.colorPickerEnabled??!1}isPMSPickerEnabled(){return this.step.data.pmsPickerEnabled??!1}}class wr extends nt{constructor(t,e,a){super(t,e,a)}selectVariant(t){return Ra.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class yr extends nt{constructor(t,e,a){super(t,e,a)}selectVariant(t){return Oa.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class Sr extends nt{constructor(t,e,a){super(t,e,a)}selectVariant(t){return Ua.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class vr extends nt{constructor(t,e,a){super(t,e,a)}async selectVariant(t){if(!t.getId())throw new Error("Unable to select variant with a null ID");await La.selectVariant(this.step,t.getId(),this.manager)}getDisplayType(){var t;return this.step.data.displayType||((t=this.step.option)==null?void 0:t.displayType)}}class Er extends nt{constructor(t,e,a){super(t,e,a)}selectVariant(t){const e=t.getResource();return kt.selectVariant(this.step,{fill:e.color,stroke:e.color,variant:e},this.manager.getRegionElements(this.step.stepName)||[],this.manager)}setColor(t){return kt.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return kt.availableColours(this.step)}setCustomColor(t){var e,a;return((e=this.getCurrentVariant())==null?void 0:e.getColor())!=="#custom"&&console.warn(`setting custom color for step ${this.step.stepName} but color is ${(a=this.getCurrentVariant())==null?void 0:a.getColor()}`),kt.setCustomColor(t,this.step,this.manager)}getCustomColor(){var e,a,n;((e=this.getCurrentVariant())==null?void 0:e.getColor())!=="#custom"&&console.warn(`setting custom color for step ${this.step.stepName} but color is ${(a=this.getCurrentVariant())==null?void 0:a.getColor()}`);const t=(n=this.manager.getStepStorage(this.step.stepName))==null?void 0:n.colour;if(!t)throw new Error(`Color not available on step ${this.step.stepName}. Set a default on the workflow to fix this.`);return t}}class br extends nt{constructor(t,e,a){super(t,e,a)}async selectVariant(t){W.selectVariant(this.step,t.getResource(),this.manager,e=>{if(e)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occurred with text",messageType:me.Error,stepID:this.step.stepName}]);else{const a=this.manager.getInformationResults().filter(n=>n.stepID!==this.step.stepName);this.manager.setInformationResults(a)}},()=>{})}getAvailableFillColors(){return this.step.data.colorPickerEnabled?W.availableFillColors(this.step):[]}async setFillColor(t){const e=this.manager.getRegionElements(this.step.stepName);await W.changeFillColor(this.step,t,e,this.manager)}getFillColor(){var t;return((t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.color)||"#000000"}getAvailableFillImages(){return W.availableFillImages(this.step)}async setFillImage(t){const e=this.manager.getRegionElements(this.step.stepName);await W.changeFillImage(this.step,t,e,this.manager)}getFillImage(){var t;return(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.fillImage}getAlignment(){const t=W.findLayoutElements(this.manager,this.step);return t==null?void 0:t[0].align}setAlignment(t){const e=this.manager.getRegionElements(this.step.stepName);W.changeAlignment(this.step,t,e,this.manager)}setFullTextCustomization(t){var s;const e=((s=this.manager.getStepStorage(this.step.stepName))==null?void 0:s.inputText)||"",a=this.step.data.replaceableText!==void 0?this.step.data.replaceableText.replace("{{}}",e):e,n=t?a:this.step.data.defaultText;return this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:n,defaultCleared:!1}),this.setText(n)}setText(t){var A;const e={input:t,helperData:{}},a=W.findLayoutElements(this.manager,this.step),n=W.filterUnsupportedCharacters(t,(A=a[0])==null?void 0:A.fontData),i=ne(n,this.manager).length,s=!!this.step.data&&!!this.step.data.maxLength&&i>this.step.data.maxLength;s||(e.input=n);const o=a.length<=0,l=o?{inputText:n,text:n}:{inputText:n};this.manager.updateStorage(this.step.stepName,l);const c=this.manager.getStepStorage(this.step.stepName),d=W.getProcessedInput(n,this.step.data,(c==null?void 0:c.customiseAllText)??!1);if(o)s||this.manager.updateMetadata(this.step.stepName,{text:d});else{const{command:u,errorData:h,helperData:g}=W.updateInputText(n,a,this.step,this.manager);u&&this.manager.getCommandDispatcher()(u),e.helperData=g,e.errorData=h,!s&&!h&&this.manager.updateMetadata(this.step.stepName,{text:d})}return e}getText(){var a;const t=this.step.data.defaultText,e=this.manager.getStepStorage(this.step.stepName);return t&&(e==null?void 0:e.defaultCleared)!==void 0&&!(e!=null&&e.defaultCleared)?t:((a=this.manager.getStepStorage(this.step.stepName))==null?void 0:a.text)||""}isReplaceable(){return this.step.data.userCanReplaceText}newLinesSupported(){return this.step.data.allowNewlines||!1}clearDefaultTextIfNecessary(){const t=this.manager.getStepStorage(this.step.stepName);if(!(t!=null&&t.defaultCleared)&&this.step.data.deleteDefaultOnFocus){const e=this.setText("");this.manager.updateStorage(this.step.stepName,{defaultCleared:!0,inputText:""});const a=W.findLayoutElements(this.manager,this.step);return W.updateInputText("",a,this.step,this.manager),e}}hasColorPicker(){return this.step.data.colorPickerEnabled}getRegions(){return this.step.data.regions}getCharacterLimit(){return this.step.data.maxLength}getCharactersRemaining(){const t=this.step.data.maxLength;if(t===void 0)return;const e=ne(this.getText(),this.manager);return t-e.length}setCustomColor(t){throw new Error("Custom color support is not yet available on text. Check back soon.")}getCustomColor(){throw new Error("Custom color support is not yet available on text. Check back soon.")}getAvailableStrokeColors(){return this.step.data.strokeEnabled?W.availableStrokeColors(this.step):[]}getStrokeColor(){var t,e;return((e=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.strokeColor)==null?void 0:e.browserValue)||"#000000"}async setStrokeColor(t){const e=this.manager.getRegionElements(this.step.stepName);await W.changeStrokeColor(this.step,t,e,this.manager)}}class Br extends nt{constructor(t,e,a){super(t,e,a)}async selectVariant(){}getContent(){return this.step.data.content}}class Ir extends nt{constructor(t,e,a){super(t,e,a)}async selectVariant(){}getPreviewURL(){var t;return((t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.videoUrl)||""}async selectVideo(t){return Qa.regenerateQRCode(this.manager.getRegionElements(this.step.stepName),t.key,this.manager,this.step)}}class Pr extends nt{constructor(t,e,a){super(t,e,a)}async selectVariant(){console.info("Text Modules don't support variants.")}getCharactersRemaining(){const t=this.step.data.maxLength;if(t===void 0)return;const e=ne(this.getText(),this.manager);return t-e.length}getCharacterLimit(){return this.step.data.maxLength}getText(){var t;return((t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.text)||""}setText(t){$a.changeText(this.step,t,this.manager,e=>{if(e){const a=[...this.manager.getInformationResults(),{message:e,messageType:me.Error,stepID:this.step.stepName}];this.manager.setInformationResults(a)}else{const a=this.manager.getInformationResults().filter(n=>n.stepID!==this.step.stepName);this.manager.setInformationResults(a)}})}}class ye{static get(t,e){switch(e.type){case I.DigitalContent:return new Ir(t,e,t.getStepTags(e.stepName));case I.Information:return new Br(t,e,t.getStepTags(e.stepName));case I.Question:return new vr(t,e,t.getStepTags(e.stepName));case I.Text:return new br(t,e,t.getStepTags(e.stepName));case I.Illustration:return new Cr(t,e,t.getStepTags(e.stepName));case I.Picture:return new Sr(t,e,t.getStepTags(e.stepName));case I.Shape:return new Er(t,e,t.getStepTags(e.stepName));case I.Material:return new wr(t,e,t.getStepTags(e.stepName));case I.Model:return new yr(t,e,t.getStepTags(e.stepName));case I.Frame:return new _r(t,e,t.getStepTags(e.stepName));case I.Module:return new Pr(t,e,t.getStepTags(e.stepName));default:throw new z(`Step type ${e.type} not yet supported in Core SDK`)}}}const Fr=v.gql`
2149
2201
  fragment CreateDesignTransaction on Transaction {
2150
2202
  id
2151
2203
  designName
@@ -2170,8 +2222,8 @@
2170
2222
  externalProductVariantId
2171
2223
  }
2172
2224
  }
2173
- `,Bl=v.gql`
2174
- ${Pr}
2225
+ `,Il=v.gql`
2226
+ ${Fr}
2175
2227
  mutation CreateDesign(
2176
2228
  $name: String!
2177
2229
  $layouts: [LayoutInput]!
@@ -2202,8 +2254,8 @@
2202
2254
  }
2203
2255
  }
2204
2256
  }
2205
- `,Il=v.gql`
2206
- ${Pr}
2257
+ `,Pl=v.gql`
2258
+ ${Fr}
2207
2259
  mutation CreateDesigns($inputs: [DesignCreateInput]!) {
2208
2260
  designCreateMany(inputs: $inputs) {
2209
2261
  id
@@ -2216,7 +2268,7 @@
2216
2268
  }
2217
2269
  }
2218
2270
  }
2219
- `;function _t(r){const t=JSON.parse(atob(r.split(".")[1])).exp;return Math.floor(new Date().getTime()/1e3)>=t}const Pl=async(r,t)=>{var n,i;const e={};try{if(t){const s=await t.loggedInBearerToken();e.Authorization=`Bearer ${s}`}else throw new Error}catch{const l=((n=Object.entries(localStorage).find(([d,A])=>d.startsWith("CognitoIdentityServiceProvider")&&d.endsWith("idToken")))==null?void 0:n[0])||"",c=localStorage.getItem(l);c&&!_t(c)&&(e.Authorization=`Bearer ${c}`)}return(i=(await B.getShadowGraphqlClient().mutate({mutation:Bl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:r.name,layouts:r.layouts,workflowId:r.workflowId,transactionId:r.transactionId,previewImage:r.previewImage,useThreeDimPreview:r.useThreeDimPreview,metadata:r.metadata,selectedVariants:r.selectedVariants},context:{headers:e}})).data)==null?void 0:i.designCreate},Dl=async(r,t)=>{var n,i;const e={};try{if(t){const s=await t.loggedInBearerToken();e.Authorization=`Bearer ${s}`}else throw new Error}catch{const l=((n=Object.entries(localStorage).find(([d,A])=>d.startsWith("CognitoIdentityServiceProvider")&&d.endsWith("idToken")))==null?void 0:n[0])||"",c=localStorage.getItem(l);c&&!_t(c)&&(e.Authorization=`Bearer ${c}`)}return(i=(await B.getShadowGraphqlClient().mutate({mutation:Il,errorPolicy:"all",fetchPolicy:"no-cache",variables:{inputs:r.map(s=>({name:s.name,layouts:s.layouts,workflowId:s.workflowId,transactionId:s.transactionId,previewImage:s.previewImage,useThreeDimPreview:s.useThreeDimPreview,metadata:s.metadata,selectedVariants:s.selectedVariants}))},context:{headers:e}})).data)==null?void 0:i.designCreateMany},fa=(r,t,e)=>{const a=i=>{const s={};if(i.type==="Frame"){const o=r[i.stepName],l=i.data;if(!o||!o.image||l.hideImageInCart&&e)return s;s[`${i.stepTitle} image`]=o.image}if(i.type==="Illustration"){const o=r[i.stepName],l=i.data;if(!o||l.hideColorsInCart&&e||!o.colors)return s;if(o.colors.length>0){const c=o.colors.join(", ").toUpperCase();s[`${i.stepTitle} colors`]=c}}if(i.type==="Module"){const o=r[i.stepName],l=i.data;if(!o||o.text===void 0||o.text===null||l.hideTextInCart&&e)return s;s[`${i.stepTitle} text`]=o.text}if(i.type==="Text"){const o=r[i.stepName];if(!o)return s;const l=i.data;(!l.hideTextInCart||!e&&o.text!==void 0&&o.text!==null)&&(s[`${i.stepTitle} text`]=o.text),o.color&&(!l.hideColorInCart||!e)&&(s[`${i.stepTitle} color`]=o.color),o.strokeColor&&(!l.hideStrokeInCart||!e)&&(s[`${i.stepTitle} stroke`]=o.strokeColor)}return s},n={};return t.steps.forEach(i=>{Object.assign(n,a(i))}),n},xl=(r,t,e,a)=>{const n={};let i={};e?i=fa(e,t,!1):a&&(i=a);const o=t.steps.map(l=>l.stepTitle).filter((l,c,d)=>d.indexOf(l)==c);for(const l of o){if(Object.keys(r).includes(l)){const c=r[l],d=t.steps.find(A=>A.stepTitle===l);n[`${d==null?void 0:d.stepTitle} selection`]={value:c[0].name,priceModifier:c[0].priceModifier}}for(const c of Object.keys(i))[`${l} color`,`${l} colors`,`${l} text`,`${l} image`].includes(c)&&(n[c]={value:i[c],priceModifier:0})}return n},Dr=(r,t,e,a,n,i,s,o)=>{var g,m;const l=t.basePrice||0,c=r.priceModifierTotal||0,d=xl(a,e,void 0,i),u=(N.getMap("transactionOwnerIds")||new Map).get(r.id),h={additionalExternalProductId:(g=r.integrationProduct)==null?void 0:g.additionalExternalProductId,additionalExternalVariantId:(m=r.integrationProduct)==null?void 0:m.additionalExternalVariantId,baseCost:l,designExternalVariants:r.designExternalVariants,designProductId:r.externalDesignProductId,designProductVariantId:r.externalDesignProductVariantId,event:"onComplete",exportedData:d,externalCartProductId:r.externalCartProductId,externalCartProductVariantId:r.externalCartProductVariantId,lineItemImageUrl:s||"",optionsCost:c,processExecutionId:o,quantity:r.quantity,transactionId:r.id,transactionOwnerId:u,weight:t.weight,workflowViewerLink:r.workflowViewerLink||"",workflowViewerReadOnlyLink:r.workflowViewerReadOnlyLink||""};return i&&(h.metadata=i),a&&(h.selectedVariants=a),n&&(h.sku=n),h},xr=async(r,t,e,a,n,i,s,o,l,c)=>{var P;await(async()=>{var R;if(c!==void 0)return c;await r.outstandingRequestsPromise();const F=(N.getMap("transactionOwnerIds")||new Map).get(n.id),T=await B.getShadowGraphqlClient().query({query:Jn,variables:{ids:[n.id]},fetchPolicy:"no-cache",errorPolicy:"all",context:{transactionOwnerId:F}}),Z=(R=T.data)==null?void 0:R.transactions[0].workflowState;return T.errors?(T.errors.forEach(at=>{T.errors&&console.log("Server Error:",at.message)}),null):Z??null})()||(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(a())),await r.updateStateWithServerImmediate(a),console.log("Server state is undefined @ Workflow completion"));const u=r.getPreviewService(),h=(P=t==null?void 0:t.finalizeStepConfig)==null?void 0:P.lookAtAnimation,g=u&&t.showModelOnFinishStep&&!!h,m=l&&fa(l,t,!0),p=l&&fa(l,t,!1),f=async x=>{const F={};let M=0;if(Object.keys(i).length>0)for(const T of Object.keys(i)){const Z=i[T],R=t.steps.find(at=>at.stepName===T);for(let at=0;at<Z.selections.length;++at){const tt=Z.selections[at];if(R&&(!x||R.option&&(R.option.variants||[]).length>1&&!R.data.hideSelectionInCart&&!R.data.hideSelectionsInCart)){const Ut=R.stepTitle;F[Ut]?F[Ut].push({id:tt.id||"",name:tt.name,priceModifier:tt.priceModifier}):F[Ut]=[{id:tt.id||"",name:tt.name,priceModifier:tt.priceModifier}]}M+=tt.priceModifier}}return[F,M]},[C]=await f(!0),w=Object.fromEntries(Object.keys(C).map(x=>[x,C[x].map(F=>F.id)])),[S]=await f(!1),y=Object.fromEntries(Object.keys(S).map(x=>[x,S[x].map(F=>F.id)]));let E=await o(g,n.id);if(E){const x=await(await st(E)).blob();E=(await U.uploadAsset({name:`${n.id}-preview-image.png`,blob:x},Xt.Image,!0,!1)).fileLink}return{designDetails:(()=>{const x={name:s,layouts:e.map(F=>({index:F.index,panelId:F.panelId})),workflowId:t.id,transactionId:n.id,useThreeDimPreview:!!g,previewImage:E};if(p){const F=[];for(const[M,T]of Object.entries(p))F.push({key:M,value:T});x.metadata=F}if(w){const F=[];for(const[M,T]of Object.entries(y))F.push({key:M,ids:T});x.selectedVariants=F}return x})(),cartSelectionsWithPrices:C,cartMetadata:m}},Fr=async(r,t,e,a,n,i,s,o,l,c,d)=>{var f,C;l("workflow.steps.finish.finalize.buildingLayouts");const{designDetails:A,cartSelectionsWithPrices:u,cartMetadata:h}=await xr(r,t,e,a,i,s,o,c,d);l("workflow.steps.finish.finalize.creatingDesign");const g=await Pl(A),m=(f=g==null?void 0:g.transaction)==null?void 0:f.previewImageLink;if(!(g!=null&&g.transaction))throw new Error("Failed to create design");l("workflow.steps.finish.finalize.updatingTransaction");const p=g.transaction;return Dr(p,n,t,u,g==null?void 0:g.sku,h,m,(C=g==null?void 0:g.processExecution)==null?void 0:C.id)},Fl=async(r,t,e)=>{t("workflow.steps.finish.finalize.buildingLayouts"),await Promise.all(r.map(async o=>{await o.workflowManager.outstandingRequestsPromise()}));const n=await(async()=>{var c;const l=await B.getShadowGraphqlClient().query({query:Jn,variables:{ids:r.map(d=>d.transaction.id)},fetchPolicy:"no-cache",errorPolicy:"all"});return l.errors?(l.errors.forEach(d=>{l.errors&&console.log("Server Error:",d.message)}),null):(c=l.data)!=null&&c.transactions?l.data.transactions.map(d=>d.workflowState??null):null})(),i=await Promise.all(r.map(async(o,l)=>await xr(o.workflowManager,o.workflow,o.layouts,o.getReducerState,o.transaction,o.workflowSelections,o.designName,e??(()=>Promise.resolve(void 0)),o.workflowMetadata,n?n[l]:void 0)));t("workflow.steps.finish.finalize.creatingDesign");const s=await Dl(i.map(o=>o.designDetails));if(!s)throw new Error("Failed to create designs");return t("workflow.steps.finish.finalize.updatingTransaction"),s.map((o,l)=>{var u;const c=r[l],d=i[l],A=o.transaction;return Dr(A,c.product,c.workflow,d.cartSelectionsWithPrices,o.sku,d.cartMetadata,A.previewImageLink,(u=o.processExecution)==null?void 0:u.id)})};class kl{constructor(){this.localPersistenceKey="designTransactions",this.storageMethod="Local",this.designSavedListeners=[]}attachSaveListener(t){this.designSavedListeners.push(t)}detachSaveListener(t){this.designSavedListeners=this.designSavedListeners.filter(e=>e!==t)}async getSavedDesigns(){if(this.storageMethod==="Local"){const t=N.get(this.localPersistenceKey);return t?JSON.parse(t):[]}throw new z("Unexpected storage method requested")}async getSavedDesignByTransaction(t){return(await this.getSavedDesigns()).find(a=>a.transactionId===t)}async addDesign(t){const a=(await this.getSavedDesigns()).filter(n=>n.transactionId!==t.transactionId);a.unshift(t),await this.setDesigns(a),this.designSavedListeners.forEach(n=>n(t))}async renameDesign(t,e){const a=await this.getSavedDesigns(),n=a.find(i=>i.transactionId===t);if(!n)throw new Error(`No saved design for transaction ${t}.`);n.title=e,await this.setDesigns(a)}async removeDesign(t){const e=await this.getSavedDesigns();await this.setDesigns(e.filter(a=>a.transactionId!==t))}async setDesigns(t){if(this.storageMethod==="Local"){N.set(this.localPersistenceKey,JSON.stringify(t));return}throw new z("Unexpected storage method requested")}}const be=new kl,Ml=v.gql`
2271
+ `;function _t(r){const t=JSON.parse(atob(r.split(".")[1])).exp;return Math.floor(new Date().getTime()/1e3)>=t}const Fl=async(r,t)=>{var n,i;const e={};try{if(t){const s=await t.loggedInBearerToken();e.Authorization=`Bearer ${s}`}else throw new Error}catch{const l=((n=Object.entries(localStorage).find(([d,A])=>d.startsWith("CognitoIdentityServiceProvider")&&d.endsWith("idToken")))==null?void 0:n[0])||"",c=localStorage.getItem(l);c&&!_t(c)&&(e.Authorization=`Bearer ${c}`)}return(i=(await B.getShadowGraphqlClient().mutate({mutation:Il,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:r.name,layouts:r.layouts,workflowId:r.workflowId,transactionId:r.transactionId,previewImage:r.previewImage,useThreeDimPreview:r.useThreeDimPreview,metadata:r.metadata,selectedVariants:r.selectedVariants},context:{headers:e}})).data)==null?void 0:i.designCreate},Dl=async(r,t)=>{var n,i;const e={};try{if(t){const s=await t.loggedInBearerToken();e.Authorization=`Bearer ${s}`}else throw new Error}catch{const l=((n=Object.entries(localStorage).find(([d,A])=>d.startsWith("CognitoIdentityServiceProvider")&&d.endsWith("idToken")))==null?void 0:n[0])||"",c=localStorage.getItem(l);c&&!_t(c)&&(e.Authorization=`Bearer ${c}`)}return(i=(await B.getShadowGraphqlClient().mutate({mutation:Pl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{inputs:r.map(s=>({name:s.name,layouts:s.layouts,workflowId:s.workflowId,transactionId:s.transactionId,previewImage:s.previewImage,useThreeDimPreview:s.useThreeDimPreview,metadata:s.metadata,selectedVariants:s.selectedVariants}))},context:{headers:e}})).data)==null?void 0:i.designCreateMany},fa=(r,t,e)=>{const a=i=>{const s={};if(i.type==="Frame"){const o=r[i.stepName],l=i.data;if(!o||!o.image||l.hideImageInCart&&e)return s;s[`${i.stepTitle} image`]=o.image}if(i.type==="Illustration"){const o=r[i.stepName],l=i.data;if(!o||l.hideColorsInCart&&e||!o.colors)return s;if(o.colors.length>0){const c=o.colors.join(", ").toUpperCase();s[`${i.stepTitle} colors`]=c}}if(i.type==="Module"){const o=r[i.stepName],l=i.data;if(!o||o.text===void 0||o.text===null||l.hideTextInCart&&e)return s;s[`${i.stepTitle} text`]=o.text}if(i.type==="Text"){const o=r[i.stepName];if(!o)return s;const l=i.data;(!l.hideTextInCart||!e&&o.text!==void 0&&o.text!==null)&&(s[`${i.stepTitle} text`]=o.text),o.color&&(!l.hideColorInCart||!e)&&(s[`${i.stepTitle} color`]=o.color),o.strokeColor&&(!l.hideStrokeInCart||!e)&&(s[`${i.stepTitle} stroke`]=o.strokeColor)}return s},n={};return t.steps.forEach(i=>{Object.assign(n,a(i))}),n},xl=(r,t,e,a)=>{const n={};let i={};e?i=fa(e,t,!1):a&&(i=a);const o=t.steps.map(l=>l.stepTitle).filter((l,c,d)=>d.indexOf(l)==c);for(const l of o){if(Object.keys(r).includes(l)){const c=r[l],d=t.steps.find(A=>A.stepTitle===l);n[`${d==null?void 0:d.stepTitle} selection`]={value:c[0].name,priceModifier:c[0].priceModifier}}for(const c of Object.keys(i))[`${l} color`,`${l} colors`,`${l} text`,`${l} image`].includes(c)&&(n[c]={value:i[c],priceModifier:0})}return n},Dr=(r,t,e,a,n,i,s,o)=>{var g,m;const l=t.basePrice||0,c=r.priceModifierTotal||0,d=xl(a,e,void 0,i),u=(T.getMap("transactionOwnerIds")||new Map).get(r.id),h={additionalExternalProductId:(g=r.integrationProduct)==null?void 0:g.additionalExternalProductId,additionalExternalVariantId:(m=r.integrationProduct)==null?void 0:m.additionalExternalVariantId,baseCost:l,designExternalVariants:r.designExternalVariants,designProductId:r.externalDesignProductId,designProductVariantId:r.externalDesignProductVariantId,event:"onComplete",exportedData:d,externalCartProductId:r.externalCartProductId,externalCartProductVariantId:r.externalCartProductVariantId,lineItemImageUrl:s||"",optionsCost:c,processExecutionId:o,quantity:r.quantity,transactionId:r.id,transactionOwnerId:u,weight:t.weight,workflowViewerLink:r.workflowViewerLink||"",workflowViewerReadOnlyLink:r.workflowViewerReadOnlyLink||""};return i&&(h.metadata=i),a&&(h.selectedVariants=a),n&&(h.sku=n),h},xr=async(r,t,e,a,n,i,s,o,l,c)=>{var P;await(async()=>{var R;if(c!==void 0)return c;await r.outstandingRequestsPromise();const x=(T.getMap("transactionOwnerIds")||new Map).get(n.id),N=await B.getShadowGraphqlClient().query({query:Kn,variables:{ids:[n.id]},fetchPolicy:"no-cache",errorPolicy:"all",context:{transactionOwnerId:x}}),rt=(R=N.data)==null?void 0:R.transactions[0].workflowState;return N.errors?(N.errors.forEach(et=>{N.errors&&console.log("Server Error:",et.message)}),null):rt??null})()||(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(a())),await r.updateStateWithServerImmediate(a),console.log("Server state is undefined @ Workflow completion"));const u=r.getPreviewService(),h=(P=t==null?void 0:t.finalizeStepConfig)==null?void 0:P.lookAtAnimation,g=u&&t.showModelOnFinishStep&&!!h,m=l&&fa(l,t,!0),p=l&&fa(l,t,!1),f=async D=>{const x={};let k=0;if(Object.keys(i).length>0)for(const N of Object.keys(i)){const rt=i[N],R=t.steps.find(et=>et.stepName===N);for(let et=0;et<rt.selections.length;++et){const Z=rt.selections[et];if(R&&(!D||R.option&&(R.option.variants||[]).length>1&&!R.data.hideSelectionInCart&&!R.data.hideSelectionsInCart)){const Ut=R.stepTitle;x[Ut]?x[Ut].push({id:Z.id||"",name:Z.name,priceModifier:Z.priceModifier}):x[Ut]=[{id:Z.id||"",name:Z.name,priceModifier:Z.priceModifier}]}k+=Z.priceModifier}}return[x,k]},[C]=await f(!0),w=Object.fromEntries(Object.keys(C).map(D=>[D,C[D].map(x=>x.id)])),[S]=await f(!1),y=Object.fromEntries(Object.keys(S).map(D=>[D,S[D].map(x=>x.id)]));let E=await o(g,n.id);if(E){const D=await(await st(E)).blob();E=(await U.uploadAsset({name:`${n.id}-preview-image.png`,blob:D},Xt.Image,!0,!1)).fileLink}return{designDetails:(()=>{const D={name:s,layouts:e.map(x=>({index:x.index,panelId:x.panelId})),workflowId:t.id,transactionId:n.id,useThreeDimPreview:!!g,previewImage:E};if(p){const x=[];for(const[k,N]of Object.entries(p))x.push({key:k,value:N});D.metadata=x}if(w){const x=[];for(const[k,N]of Object.entries(y))x.push({key:k,ids:N});D.selectedVariants=x}return D})(),cartSelectionsWithPrices:C,cartMetadata:m}},kr=async(r,t,e,a,n,i,s,o,l,c,d)=>{var f,C;l("workflow.steps.finish.finalize.buildingLayouts");const{designDetails:A,cartSelectionsWithPrices:u,cartMetadata:h}=await xr(r,t,e,a,i,s,o,c,d);l("workflow.steps.finish.finalize.creatingDesign");const g=await Fl(A),m=(f=g==null?void 0:g.transaction)==null?void 0:f.previewImageLink;if(!(g!=null&&g.transaction))throw new Error("Failed to create design");l("workflow.steps.finish.finalize.updatingTransaction");const p=g.transaction;return Dr(p,n,t,u,g==null?void 0:g.sku,h,m,(C=g==null?void 0:g.processExecution)==null?void 0:C.id)},kl=async(r,t,e)=>{t("workflow.steps.finish.finalize.buildingLayouts"),await Promise.all(r.map(async o=>{await o.workflowManager.outstandingRequestsPromise()}));const n=await(async()=>{var c;const l=await B.getShadowGraphqlClient().query({query:Kn,variables:{ids:r.map(d=>d.transaction.id)},fetchPolicy:"no-cache",errorPolicy:"all"});return l.errors?(l.errors.forEach(d=>{l.errors&&console.log("Server Error:",d.message)}),null):(c=l.data)!=null&&c.transactions?l.data.transactions.map(d=>d.workflowState??null):null})(),i=await Promise.all(r.map(async(o,l)=>await xr(o.workflowManager,o.workflow,o.layouts,o.getReducerState,o.transaction,o.workflowSelections,o.designName,e??(()=>Promise.resolve(void 0)),o.workflowMetadata,n?n[l]:void 0)));t("workflow.steps.finish.finalize.creatingDesign");const s=await Dl(i.map(o=>o.designDetails));if(!s)throw new Error("Failed to create designs");return t("workflow.steps.finish.finalize.updatingTransaction"),s.map((o,l)=>{var u;const c=r[l],d=i[l],A=o.transaction;return Dr(A,c.product,c.workflow,d.cartSelectionsWithPrices,o.sku,d.cartMetadata,A.previewImageLink,(u=o.processExecution)==null?void 0:u.id)})};class Ml{constructor(){this.localPersistenceKey="designTransactions",this.storageMethod="Local",this.designSavedListeners=[]}attachSaveListener(t){this.designSavedListeners.push(t)}detachSaveListener(t){this.designSavedListeners=this.designSavedListeners.filter(e=>e!==t)}async getSavedDesigns(){if(this.storageMethod==="Local"){const t=T.get(this.localPersistenceKey);return t?JSON.parse(t):[]}throw new z("Unexpected storage method requested")}async getSavedDesignByTransaction(t){return(await this.getSavedDesigns()).find(a=>a.transactionId===t)}async addDesign(t){const a=(await this.getSavedDesigns()).filter(n=>n.transactionId!==t.transactionId);a.unshift(t),await this.setDesigns(a),this.designSavedListeners.forEach(n=>n(t))}async renameDesign(t,e){const a=await this.getSavedDesigns(),n=a.find(i=>i.transactionId===t);if(!n)throw new Error(`No saved design for transaction ${t}.`);n.title=e,await this.setDesigns(a)}async removeDesign(t){const e=await this.getSavedDesigns();await this.setDesigns(e.filter(a=>a.transactionId!==t))}async setDesigns(t){if(this.storageMethod==="Local"){T.set(this.localPersistenceKey,JSON.stringify(t));return}throw new z("Unexpected storage method requested")}}const be=new Ml,Tl=v.gql`
2220
2272
  mutation AddTransactionStakeholder($id: String!, $type: String!, $details: CustomerDetailsInput!) {
2221
2273
  transactionAddStakeholder(id: $id, details: $details, type: $type) {
2222
2274
  id
@@ -2230,7 +2282,7 @@
2230
2282
  }
2231
2283
  }
2232
2284
  }
2233
- `,Tl=v.gql`
2285
+ `,Nl=v.gql`
2234
2286
  mutation AddAddressToTransaction(
2235
2287
  $transactionId: String!
2236
2288
  $streetAddress: String
@@ -2252,13 +2304,13 @@
2252
2304
  id
2253
2305
  }
2254
2306
  }
2255
- `,Nl=v.gql`
2307
+ `,Ql=v.gql`
2256
2308
  mutation AddOrganizationToTransaction($transactionId: String!, $organizationName: String!) {
2257
2309
  organizationAttachToTransaction(transactionId: $transactionId, organizationName: $organizationName) {
2258
2310
  id
2259
2311
  }
2260
2312
  }
2261
- `;var kr=(r=>(r.QuantityChanged="QuantityChanged",r.PriceBreakChanged="PriceBreakChanged",r))(kr||{});class Mr{constructor(t,e){var n;if(this.cachedStepHandles=new Map,this.currentPriceBreak=1,this.renderableScenes=[],this.renderableSceneCallbacks=[],this.eventCallbacks=new Map,this.debouncedSavedDesignUpdate=En(async()=>{await be.getSavedDesignByTransaction(this.getWorkflowManager().getTransaction().id)&&this.save()},2500),this.getCanvasObjectURLAsync=async i=>new Promise((s,o)=>{try{i.toBlob(l=>{if(l){const c=URL.createObjectURL(l);s(c)}})}catch(l){o(l)}}),!e.workflow)throw new Error("No Workflow ID provided.");this.client=t;const a=e.layouts;this.commandContext=new nr,this.commandContext.initialize(a,e.reloadedState),this.isReadOnly=e.transaction.isOrdered||!!e.readOnly,this.graphQlClient=e.graphQlClient,this.workflowManager=new bl(this,t,e.workflow,((n=e.product.profanities)==null?void 0:n.map(i=>i.word))||[],a,this.commandContext,i=>{try{this.debouncedSavedDesignUpdate()}catch{console.error("Failed to update saved design details.")}return e.stateMutationFunc(i)},e.graphQlClient,e.transaction,e.product,e.previewService,e.renderableContextService,e.reloadedState,e.readOnly,e.modelContainer,e.isReloadedTransaction,e.singleVariantsRenderable,e.delayWorkflowStateSync),this.workflowManager.addSelectionCallback(i=>{const s=i.traversableScenes.map(o=>{const l=o.renderableSteps.map(c=>c.stepName);return{id:o.name,title:o.title,renderableSteps:l,workflowScene:o}});this.renderableScenes=s,this.renderableSceneCallbacks.forEach(o=>o(s))}),this.currentPriceBreak=this.priceBreakToBeApplied()}async attachAddress(t,e,a,n,i,s){await this.graphQlClient().mutate({mutation:Tl,variables:{transactionId:this.getWorkflowManager().getTransaction().id,streetAddress:t||void 0,apartment:e||void 0,city:a||void 0,country:n||void 0,state:i||void 0,postCode:s||void 0}})}async attachOrganization(t){await this.graphQlClient().mutate({mutation:Nl,variables:{transactionId:this.getWorkflowManager().getTransaction().id,organizationName:t}})}getBundle(){return this.bundle}setBundle(t){this.bundle=t}getClient(){return this.client}getIsReadOnly(){return this.isReadOnly}getCommandContext(){return this.commandContext}getWorkflowManager(){return this.workflowManager}async createPreviewImage(t,e){var C,w;const a=this.workflowManager.getWorkflow(),n=(C=a==null?void 0:a.finalizeStepConfig)==null?void 0:C.lookAtAnimation;if(t){if(!n)throw new Error("Failed to generate cart preview image!");return await((w=this.workflowManager.getPreviewService())==null?void 0:w.renderSceneScreenshot(e??512,n))||""}let i=2048;e&&e<=2048&&(i=e);const s=pt(i,i),o=this.commandContext.getAllLayouts(),l=a.defaultPreviewPanelIndex||0,c=a.panels[l],d=o.find(S=>{var y;return((y=S.layoutState)==null?void 0:y.layout.panelId)===(c==null?void 0:c.name)})||o[0],A=d.layoutState.layout.previewRegion?{x:d.layoutState.layout.previewRegion.left,y:d.layoutState.layout.previewRegion.top,width:d.layoutState.layout.previewRegion.width,height:d.layoutState.layout.previewRegion.height}:{x:0,y:0,width:d.layoutState.layout.width,height:d.layoutState.layout.height},u=this.commandContext.getLayoutById(d.layoutState.layout.id),h=s.getContext("2d");if(!h)throw new Ne("Failed to obtain 2D context for preview image creation");const g=ze(u.layoutState.layout,u.layoutState.elements,{renderingConfiguration:{purpose:Tt.Print,region:{left:A.x,top:A.y,width:A.width,height:A.height},templatingContext:this.workflowManager.getTemplatingContext()}}),m=Tn(g);await(await Sa.Pith.from(h,m,{anonymousCrossOrigin:!0,ignoreDimensions:!1,createCanvas:pt,createImage:oe,DOMParser:ba(),fetch})).render();const f=await this.getCanvasObjectURLAsync(s);return s.toDataURL(f)}getStepById(t){const e=this.getWorkflowManager().getWorkflow().steps.find(i=>i.stepName===t);if(!e||!this.stepHasHandle(e))return;const a=this.cachedStepHandles.get(e.stepName);if(a)return a;const n=ye.get(this.getWorkflowManager(),e);return this.cachedStepHandles.set(e.stepName,n),n}getSteps(){return this.getScenes().flatMap(t=>this.getStepsByScene(t))}getStepsConditionallyActive(){return this.getScenes().flatMap(t=>this.getStepsByScene(t).filter(e=>vt(e.getRaw(),this.getWorkflowManager().getStepSelections())))}getScenes(){return this.getWorkflowManager().getWorkflow().stepGroups.map(e=>({id:e.id,name:e.name,stepIds:e.stepNames}))}getSelectionPriceSubunits(t){const e=this.getWorkflowManager().getWorkflowSelections();let a=0;return Object.values(e).forEach(n=>{a+=n.selections.reduce((i,s)=>i+(s.priceModifier||0),0)}),this.getPriceSubUnitsAfterPriceBreaks(a,t)}getBasePriceSubunits(t,e){const a=this.getPriceSubUnitsAfterPriceBreaks(this.getWorkflowManager().getProduct().basePrice||0,e);if(t){const n=this.getAdditionalProductPriceSubunits(e)||0;return a+n}return a}getAdditionalProductPriceSubunits(t){var a;const e=this.getWorkflowManager().getTransaction().integrationProduct;if((a=e==null?void 0:e.additionalIntegrationProduct)!=null&&a.product){const n=e.additionalIntegrationProduct.product.basePrice||0;return this.getPriceSubUnitsAfterPriceBreaks(n,t)}}getTotalPriceSubunits(t){return this.getBasePriceSubunits(!1,t)+this.getSelectionPriceSubunits(t)}getPriceSubUnitsAfterPriceBreaks(t,e){const a=e?1:this.priceBreakToBeApplied(),n=t*a;return Math.ceil(n)}priceBreakToBeApplied(){const t=(this.getWorkflowManager().getProduct().priceBreaks||[]).sort((n,i)=>-(n.minQty-i.minQty)),a=[...this.getMatchingExperiencesFromBundle(),this].reduce((n,i)=>n+i.getQuantity(),0);for(const n of t)if(n.minQty<=a)return n.percentage;return 1}checkForPriceBreakChanges(){const t=this.priceBreakToBeApplied();this.currentPriceBreak!==t&&(this.updatePriceBreak(t),this.getMatchingExperiencesFromBundle().forEach(e=>e.updatePriceBreak(t)))}getMatchingExperiencesFromBundle(){var t;return(((t=this.bundle)==null?void 0:t.getWorkflowExperiences())||[]).filter(e=>e.getWorkflowManager().getTransaction().id!==this.getWorkflowManager().getTransaction().id&&e.getWorkflowManager().getProduct().id===this.getWorkflowManager().getProduct().id)}updatePriceBreak(t){this.currentPriceBreak=t,this.callEvent("PriceBreakChanged")}async copySelectionsViaGlobalConfiguration(t,e,a){const n=await t.getGlobalProperties(),i=a==null?void 0:a.map(c=>c.getId()),s=this.getSteps().filter(c=>i===void 0||i.includes(c.getId())),o=e.getSteps(),l=c=>n.find(d=>d.getRawProperty().name===c.aspectName);s.forEach(c=>{const d=new Set,A=c.getRaw().globalPropertyAspectConfigurations;A!==void 0&&(A.forEach(u=>d.add(JSON.stringify(u))),o.forEach(u=>{const h=u.getRaw().globalPropertyAspectConfigurations;h!==void 0&&h.forEach(g=>{const m=l(g),p=d.has(JSON.stringify(g));if(p&&(m==null?void 0:m.getType())==="Option"){const f=u.getCurrentVariant();if(!f)return;c.selectVariant(f),d.delete(JSON.stringify(g))}else if(p&&(m==null?void 0:m.getType())==="Text"){const f=u.getText();c.setText(f),d.delete(JSON.stringify(g))}})}))})}getStepByName(t){const e=this.getWorkflowManager().getWorkflow().steps.find(a=>a.stepTitle===t);if(!(!e||!this.stepHasHandle(e)))return ye.get(this.getWorkflowManager(),e)}getStepsByType(t){return this.getWorkflowManager().getWorkflow().steps.filter(e=>e.type===t).map(e=>ye.get(this.getWorkflowManager(),e))}getStepsByScene(t){if(!this.getWorkflowManager().getWorkflow().stepGroups.find(a=>a.name===t.name))throw new Error("Given scene is not present on workflow! Be careful when persisting scenes that you only use them with the relevant workflow.");return t.stepIds.map(a=>this.getWorkflowManager().getWorkflow().steps.find(n=>n.stepName===a)).filter(a=>this.stepHasHandle(a)).map(a=>ye.get(this.getWorkflowManager(),a))}async attachCustomerDetails(t){return this.assignCustomerDetails({emailAddress:t.email})}async assignCustomerDetails(t){var n,i,s;const a=(s=(i=(n=(await this.graphQlClient().mutate({mutation:Ml,variables:{id:this.getWorkflowManager().getTransaction().id,details:t,type:"Owner"}})).data)==null?void 0:n.transactionAddStakeholder)==null?void 0:i.stakeholders)==null?void 0:s.find(o=>{var l;return((l=o.customer)==null?void 0:l.emailAddress)===t.emailAddress});if(a!=null&&a.customer){this.getWorkflowManager().setTransactionCustomer(a.customer);const o=N.getMap("transactionCustomerIds")||new Map;o.set(this.getWorkflowManager().getTransaction().id,a.customer.id),N.setMap("transactionCustomerIds",o)}}attachRenderableSceneListener(t){this.renderableSceneCallbacks.push(t),t(this.renderableScenes)}detachRenderableSceneListener(t){this.renderableSceneCallbacks=this.renderableSceneCallbacks.filter(e=>e!==t)}async save(t){if(!this.getCommandContext().getState())throw new z("State undefined!");const n={title:await(async()=>{var l;if(t)return t;const i=this.getWorkflowManager().getTransaction().id,o=(l=(await be.getSavedDesigns()).find(c=>c.transactionId===i))==null?void 0:l.title;return o||"My design"})(),thumbnail:await this.createPreviewImage(!1,256),transactionId:this.getWorkflowManager().getTransaction().id,productId:this.getWorkflowManager().getProduct().id,integrationProductId:this.getWorkflowManager().getTransaction().integrationProduct.id,workflowName:this.getWorkflowManager().getWorkflow().name,workflowId:this.getWorkflowManager().getWorkflow().id,lastEdited:new Date};return await be.addDesign(n),n}async copy(){var s;const t=Et(this.getCommandContext().getState());if(!t)throw new z("Internal state is undefined! Cannot copy experience!");const e=JSON.stringify(t.transaction),a=this.getWorkflowManager().getWorkflow(),n=(s=this.getWorkflowManager().getTransaction().integrationProduct)==null?void 0:s.id;if(!n)throw new z("Integration product id is undefined!");return await this.getClient().getWorkflowExperience({type:"integration",integrationProductId:n,workflowId:a.id,workflowState:e})}async onDesignFinished(t,e=!0){const a=this.workflowManager.getTransaction();return a.completed?(await this.graphQlClient().mutate({mutation:ws,variables:{transactionId:a.id}}),{event:"",exportedData:{},lineItemImageUrl:"",optionsCost:0,transactionId:a.id,workflowViewerLink:"",workflowViewerReadOnlyLink:""}):Fr(this.workflowManager,this.workflowManager.getWorkflow(),this.workflowManager.getLayouts(),()=>this.commandContext.getState(),this.workflowManager.getProduct(),a,this.workflowManager.getWorkflowSelections(),this.workflowManager.getWorkflow().name,t||(()=>{}),n=>e?this.createPreviewImage(n,1024):Promise.resolve(void 0),this.workflowManager.getWorkflowMetadata())}stepHasHandle(t){return t.type!==I.SilentIllustration&&t.type!==I.ProductOverlay}getExportedStepData(){const t=this.getWorkflowManager().getWorkflow(),e=this.getWorkflowManager().getWorkflowMetadata(),a=this.getWorkflowManager().getWorkflowSelections(),n=[];return t.steps.forEach(i=>{var d;const s=i.stepName,o=e[s],l=(d=a[s])==null?void 0:d.selections[0],c={stepId:s,title:i.stepTitle,properties:[]};if(l&&Rl(i,a)&&c.properties.push({type:"selection",value:l.name,priceModifier:l.priceModifier}),!o){n.push(c);return}switch(i.type){case I.Frame:{const A=i.data,u=o;u.image&&A.displayImageOnFinishStep&&c.properties.push({type:"image",value:u.image,priceModifier:0})}break;case I.Illustration:{const A=i.data,u=o;if(u&&u.colors&&u.colors.length>0&&A.displayColorsOnFinishStep){const h=u.colors.join(", ").toUpperCase();c.properties.push({type:"color",value:h,priceModifier:0})}}break;case I.Module:{const A=i.data,u=o;u&&u.text&&A.displayTextOnFinishStep&&c.properties.push({type:"text",value:u.text,priceModifier:0})}break;case I.Text:{const A=i.data,u=o;u&&u.text&&A.displayTextOnFinishStep&&c.properties.push({type:"text",value:u.text,priceModifier:0}),u&&u.color&&A.displayColorOnFinishStep&&c.properties.push({type:"color",value:u.color,priceModifier:0})}}n.push(c)}),n.filter(i=>i.properties&&i.properties.length>0)}getQuantity(){return this.getWorkflowManager().getTransaction().quantity||1}async setQuantity(t){if(t<1)throw new RangeError("WorkflowExperience quantity must be greater than zero.");if(this.isReadOnly)throw new Error("Cannot update quantity on a read-only WorkflowExperience");this.getWorkflowManager().getTransaction().quantity=t,this.callEvent("QuantityChanged"),this.checkForPriceBreakChanges();const e=this.getWorkflowManager().getTransaction();await this.graphQlClient().mutate({mutation:hs,variables:{id:e.id,quantity:t}})}addEventListener(t,e){const a=this.eventCallbacks.get(t)||[];a.push(e),this.eventCallbacks.set(t,a)}removeEventListener(t,e){const a=this.eventCallbacks.get(t)||[];this.eventCallbacks.set(t,a.filter(n=>n!==e))}callEvent(t){(this.eventCallbacks.get(t)||[]).forEach(e=>e(this))}}const Ql=r=>{if([I.Question,I.Frame,I.Illustration,I.Material,I.Model,I.Picture,I.Shape,I.Text].includes(r.type)){const e=r.data;return!!e.displaySelectionOnFinishStep||!!e.displaySelectionsOnFinishStep}return!1},Rl=(r,t)=>{if(!Ql(r))return!1;if(r.option&&(r.option.variants||[]).length>1){const e=t[r.stepName];return!!(e&&e.selections.length>0)}return!1},Ol=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],$l=async(r,t,e)=>{const a=t.data,n=e.data.baseUrl,i=a.assetUrl.replace("localhost","localstack"),s=n.slice(0,4)==="http"?"":"https://",o=new URL(s+n);o.searchParams.append("video",tn(JSON.stringify([{href:i}]))),o.pathname=o.pathname+(o.pathname.slice(-1)==="/"?"":"/");const l=o.toString(),d=`data:image/svg+xml;base64,${tn(await Sn.toString(l,{type:"svg"}))}`,A=h=>{const g=r.find(p=>p.panelId===h.panelId);if(!g)throw new Y(h);const m=Q();return new q({id:m,src:d,type:k.Image,y:h.top,x:h.left,width:h.width,height:h.height,rotation:0},g)},u=e.data.regions;try{return u.map(A)}catch(h){return console.error(h),[]}},Ul=async(r,t,e,a)=>{const n=e.data,i=n.assetUrl,s=await ha(i);try{const o=uo(n,a.option);o&&(t[a.stepName]={selectedVariants:[o]});const l=async c=>{var m;const d=await ir(c,(m=o==null?void 0:o.asset)==null?void 0:m.fileLink),A=await ue(d),u=Q(),h=r.find(p=>p.panelId===c.panelId);if(!h)throw new Y(c);const g=ka(s,A,{scale:n.scale,left:n.x,top:n.y},a.data.forceImageCover);return[new q({id:u,path:A.path,type:k.Frame,forceImageCover:a.data.forceImageCover,x:c.left,y:c.top,width:c.width,height:c.height,layer:c.layer,layerIndex:c.layerIndex,rotation:c.rotation,scaleX:c.width/A.width,scaleY:c.height/A.height,pattern:{id:`${u}-pattern`,src:s.src,x:g.x,y:g.y,width:s.width,height:s.height,rotation:0,scaleX:g.zoom,scaleY:g.zoom,svg:s.svg,colors:s.colors}},h)]};return(await Promise.all(a.data.regions.map(c=>l(c)))).flat()}catch(o){return console.error(o),[]}},Ll=async(r,t,e,a)=>{var y,E;const n=e.data,i=a.option;if(!i)return console.error(`No option for step ${a.stepName}.`),[];const s=((y=i.variants)==null?void 0:y.find(b=>b.id===n.illustrationVariantId))||Ae(i);if(!s)return console.error(`No variant with ID: ${n.illustrationVariantId}`),[];if(!s.asset)return console.error(`No asset for variant with ID: ${n.illustrationVariantId}`),[];t[a.stepName]={selectedVariants:[s]};const o=(E=s.asset)==null?void 0:E.fileLink;if(!o)return console.error(`No asset link for variant with ID: ${n.illustrationVariantId}`),[];const l=await et(o,!0),c=/<svg.*?<\/svg>/s,d=l.match(c)||[],A=(d==null?void 0:d.length)>0?d[0]:"",g=ct().parseFromString(A,"image/svg+xml").firstElementChild;if(!g)return console.error("Failed to read SVG."),[];$e(g);const m={};Rt(g,b=>{Ol.includes(b.tagName)&&!b.attributes.getNamedItem("fill")&&b.setAttribute("fill","#000000");const P=b.attributes.getNamedItem("fill");if(P&&P.value!=="none"){const F=P.value,T=`spiff-fill-${F.replace(/\W/g,"")}`;b.classList.add(T),m[T]={browserValue:F}}const x=b.attributes.getNamedItem("stroke");if(x&&x.value!=="none"){const F=x.value,T=`spiff-stroke-${F.replace(/\W/g,"")}`;b.classList.add(T),m[T]={browserValue:F}}});const f=wt().serializeToString(g),C=n.colors;if(C){for(const[b,P]of Object.entries(m))for(const x of Object.keys(C))if(P.browserValue===x){m[b]={browserValue:C[x]};break}}const w=b=>{const P=r.find(F=>F.panelId===b.panelId);if(!P)throw new Y(b);const x=Q();return new q({colors:m,id:x,svg:f,type:k.Illustration,y:b.top,x:b.left,rotation:b.rotation,width:b.width,height:b.height,layer:b.layer,layerIndex:b.layerIndex,immutable:b.immutable},P)},S=a.data.regions;try{return S.map(w)}catch(b){return console.error(b),[]}},Vl=async(r,t,e)=>{const a=await mr(e.data.module),n=t.data,i=(o,l)=>{const c=r.find(A=>A.panelId===l.panelId);if(!c)throw new Y(l);const d=Q();return new q({colors:{},id:d,svg:o,type:k.Illustration,y:l.top,x:l.left,rotation:l.rotation,width:l.width,height:l.height,layer:l.layer,layerIndex:l.layerIndex},c)},s=e.data.regions;try{return s.map(o=>i(a.svgPrint(n.text,o),o))}catch(o){return console.error(o),[]}},zl=async(r,t,e,a)=>{var d,A;const n=e.data,i=a.option;if(!i)return console.error(`No option for step ${a.stepName}.`),[];const s=((d=i.variants)==null?void 0:d.find(u=>u.id===n.pictureVariantId))||Ae(i);if(!s)return console.error(`No variant with ID: ${n.pictureVariantId}`),[];if(!s.asset)return console.error(`No asset for variant with ID: ${n.pictureVariantId}`),[];t[a.stepName]={selectedVariants:[s]};const o=(A=s.asset)==null?void 0:A.fileLink;if(!o)return console.error(`No asset link for variant with ID: ${n.pictureVariantId}`),[];const l=u=>{const h=r.find(m=>m.panelId===u.panelId);if(!h)throw new Y(u);const g=Q();return new q({id:g,src:o,type:k.Image,y:u.top,x:u.left,rotation:u.rotation,width:u.width,height:u.height,layer:u.layer,layerIndex:u.layerIndex,immutable:u.immutable,preserveAspectRatio:"none"},h)},c=a.data.regions;try{return c.map(l)}catch(u){return console.error(u),[]}},Gl=async(r,t,e,a)=>{var c;const n=e.data,i=a.option;if(!i)return console.error(`No option for step ${a.stepName}.`),[];const s=((c=i.variants)==null?void 0:c.find(d=>d.id===n.colorVariantId))||Ae(i);if(!s)return console.error(`No variant with ID: ${n.colorVariantId}`),[];t[a.stepName]={selectedVariants:[s]};const o=d=>{const A=r.find(p=>p.panelId===d.panelId);if(!A)throw new Y(d);const u=`
2313
+ `;var Mr=(r=>(r.QuantityChanged="QuantityChanged",r.PriceBreakChanged="PriceBreakChanged",r))(Mr||{});class Tr{constructor(t,e){var n;if(this.cachedStepHandles=new Map,this.currentPriceBreak=1,this.renderableScenes=[],this.renderableSceneCallbacks=[],this.eventCallbacks=new Map,this.debouncedSavedDesignUpdate=bn(async()=>{await be.getSavedDesignByTransaction(this.getWorkflowManager().getTransaction().id)&&this.save()},2500),this.getCanvasObjectURLAsync=async i=>new Promise((s,o)=>{try{i.toBlob(l=>{if(l){const c=URL.createObjectURL(l);s(c)}})}catch(l){o(l)}}),!e.workflow)throw new Error("No Workflow ID provided.");this.client=t;const a=e.layouts;this.commandContext=new rr,this.commandContext.initialize(a,e.reloadedState),this.isReadOnly=e.transaction.isOrdered||!!e.readOnly,this.graphQlClient=e.graphQlClient,this.workflowManager=new Bl(this,t,e.workflow,((n=e.product.profanities)==null?void 0:n.map(i=>i.word))||[],a,this.commandContext,i=>{try{this.debouncedSavedDesignUpdate()}catch{console.error("Failed to update saved design details.")}return e.stateMutationFunc(i)},e.graphQlClient,e.transaction,e.product,e.previewService,e.renderableContextService,e.reloadedState,e.readOnly,e.modelContainer,e.isReloadedTransaction,e.singleVariantsRenderable,e.delayWorkflowStateSync),this.workflowManager.addSelectionCallback(i=>{const s=i.traversableScenes.map(o=>{const l=o.renderableSteps.map(c=>c.stepName);return{id:o.name,title:o.title,renderableSteps:l,workflowScene:o}});this.renderableScenes=s,this.renderableSceneCallbacks.forEach(o=>o(s))}),this.currentPriceBreak=this.priceBreakToBeApplied()}async attachAddress(t,e,a,n,i,s){await this.graphQlClient().mutate({mutation:Nl,variables:{transactionId:this.getWorkflowManager().getTransaction().id,streetAddress:t||void 0,apartment:e||void 0,city:a||void 0,country:n||void 0,state:i||void 0,postCode:s||void 0}})}async attachOrganization(t){await this.graphQlClient().mutate({mutation:Ql,variables:{transactionId:this.getWorkflowManager().getTransaction().id,organizationName:t}})}getBundle(){return this.bundle}setBundle(t){this.bundle=t}getClient(){return this.client}getIsReadOnly(){return this.isReadOnly}getCommandContext(){return this.commandContext}getWorkflowManager(){return this.workflowManager}async createPreviewImage(t,e){var w,S;const a=this.workflowManager.getWorkflow(),n=(w=a==null?void 0:a.finalizeStepConfig)==null?void 0:w.lookAtAnimation;if(t){if(!n)throw new Error("Failed to generate cart preview image!");return await((S=this.workflowManager.getPreviewService())==null?void 0:S.renderSceneScreenshot(e??512,n))||""}let i=2048;e&&e<=2048&&(i=e);const s=pt(i,i),o=this.commandContext.getAllLayouts(),l=a.defaultPreviewPanelIndex||0,c=a.panels[l],d=o.find(y=>{var E;return((E=y.layoutState)==null?void 0:E.layout.panelId)===(c==null?void 0:c.name)})||o[0],A=d.layoutState.layout.previewRegion?{x:d.layoutState.layout.previewRegion.left,y:d.layoutState.layout.previewRegion.top,width:d.layoutState.layout.previewRegion.width,height:d.layoutState.layout.previewRegion.height}:{x:0,y:0,width:d.layoutState.layout.width,height:d.layoutState.layout.height},u=this.commandContext.getLayoutById(d.layoutState.layout.id),h=s.getContext("2d");if(!h)throw new Ne("Failed to obtain 2D context for preview image creation");const g=await this.workflowManager.getTemplatingContext(),m=ze(u.layoutState.layout,u.layoutState.elements,{renderingConfiguration:{purpose:Tt.Print,region:{left:A.x,top:A.y,width:A.width,height:A.height},templatingContext:g}}),p=Nn(m);await(await Sa.Pith.from(h,p,{anonymousCrossOrigin:!0,ignoreDimensions:!1,createCanvas:pt,createImage:oe,DOMParser:ba(),fetch})).render();const C=await this.getCanvasObjectURLAsync(s);return s.toDataURL(C)}getStepById(t){const e=this.getWorkflowManager().getWorkflow().steps.find(i=>i.stepName===t);if(!e||!this.stepHasHandle(e))return;const a=this.cachedStepHandles.get(e.stepName);if(a)return a;const n=ye.get(this.getWorkflowManager(),e);return this.cachedStepHandles.set(e.stepName,n),n}getSteps(){return this.getScenes().flatMap(t=>this.getStepsByScene(t))}getStepsConditionallyActive(){return this.getScenes().flatMap(t=>this.getStepsByScene(t).filter(e=>vt(e.getRaw(),this.getWorkflowManager().getStepSelections())))}getScenes(){return this.getWorkflowManager().getWorkflow().stepGroups.map(e=>({id:e.id,name:e.name,stepIds:e.stepNames}))}getSelectionPriceSubunits(t){const e=this.getWorkflowManager().getWorkflowSelections();let a=0;return Object.values(e).forEach(n=>{a+=n.selections.reduce((i,s)=>i+(s.priceModifier||0),0)}),this.getPriceSubUnitsAfterPriceBreaks(a,t)}getBasePriceSubunits(t,e){const a=this.getPriceSubUnitsAfterPriceBreaks(this.getWorkflowManager().getProduct().basePrice||0,e);if(t){const n=this.getAdditionalProductPriceSubunits(e)||0;return a+n}return a}getAdditionalProductPriceSubunits(t){var a;const e=this.getWorkflowManager().getTransaction().integrationProduct;if((a=e==null?void 0:e.additionalIntegrationProduct)!=null&&a.product){const n=e.additionalIntegrationProduct.product.basePrice||0;return this.getPriceSubUnitsAfterPriceBreaks(n,t)}}getTotalPriceSubunits(t){return this.getBasePriceSubunits(!1,t)+this.getSelectionPriceSubunits(t)}getPriceSubUnitsAfterPriceBreaks(t,e){const a=e?1:this.priceBreakToBeApplied(),n=t*a;return Math.ceil(n)}priceBreakToBeApplied(){const t=(this.getWorkflowManager().getProduct().priceBreaks||[]).sort((n,i)=>-(n.minQty-i.minQty)),a=[...this.getMatchingExperiencesFromBundle(),this].reduce((n,i)=>n+i.getQuantity(),0);for(const n of t)if(n.minQty<=a)return n.percentage;return 1}checkForPriceBreakChanges(){const t=this.priceBreakToBeApplied();this.currentPriceBreak!==t&&(this.updatePriceBreak(t),this.getMatchingExperiencesFromBundle().forEach(e=>e.updatePriceBreak(t)))}getMatchingExperiencesFromBundle(){var t;return(((t=this.bundle)==null?void 0:t.getWorkflowExperiences())||[]).filter(e=>e.getWorkflowManager().getTransaction().id!==this.getWorkflowManager().getTransaction().id&&e.getWorkflowManager().getProduct().id===this.getWorkflowManager().getProduct().id)}updatePriceBreak(t){this.currentPriceBreak=t,this.callEvent("PriceBreakChanged")}async copySelectionsViaGlobalConfiguration(t,e,a){const n=await t.getGlobalProperties(),i=a==null?void 0:a.map(c=>c.getId()),s=this.getSteps().filter(c=>i===void 0||i.includes(c.getId())),o=e.getSteps(),l=c=>n.find(d=>d.getRawProperty().name===c.aspectName);s.forEach(c=>{const d=new Set,A=c.getRaw().globalPropertyAspectConfigurations;A!==void 0&&(A.forEach(u=>d.add(JSON.stringify(u))),o.forEach(u=>{const h=u.getRaw().globalPropertyAspectConfigurations;h!==void 0&&h.forEach(g=>{const m=l(g),p=d.has(JSON.stringify(g));if(p&&(m==null?void 0:m.getType())==="Option"){const f=u.getCurrentVariant();if(!f)return;c.selectVariant(f),d.delete(JSON.stringify(g))}else if(p&&(m==null?void 0:m.getType())==="Text"){const f=u.getText();c.setText(f),d.delete(JSON.stringify(g))}})}))})}getStepByName(t){const e=this.getWorkflowManager().getWorkflow().steps.find(a=>a.stepTitle===t);if(!(!e||!this.stepHasHandle(e)))return ye.get(this.getWorkflowManager(),e)}getStepsByType(t){return this.getWorkflowManager().getWorkflow().steps.filter(e=>e.type===t).map(e=>ye.get(this.getWorkflowManager(),e))}getStepsByScene(t){if(!this.getWorkflowManager().getWorkflow().stepGroups.find(a=>a.name===t.name))throw new Error("Given scene is not present on workflow! Be careful when persisting scenes that you only use them with the relevant workflow.");return t.stepIds.map(a=>this.getWorkflowManager().getWorkflow().steps.find(n=>n.stepName===a)).filter(a=>this.stepHasHandle(a)).map(a=>ye.get(this.getWorkflowManager(),a))}async attachCustomerDetails(t){return this.assignCustomerDetails({emailAddress:t.email})}async assignCustomerDetails(t){var n,i,s;const a=(s=(i=(n=(await this.graphQlClient().mutate({mutation:Tl,variables:{id:this.getWorkflowManager().getTransaction().id,details:t,type:"Owner"}})).data)==null?void 0:n.transactionAddStakeholder)==null?void 0:i.stakeholders)==null?void 0:s.find(o=>{var l;return((l=o.customer)==null?void 0:l.emailAddress)===t.emailAddress});if(a!=null&&a.customer){this.getWorkflowManager().setTransactionCustomer(a.customer);const o=T.getMap("transactionCustomerIds")||new Map;o.set(this.getWorkflowManager().getTransaction().id,a.customer.id),T.setMap("transactionCustomerIds",o)}}attachRenderableSceneListener(t){this.renderableSceneCallbacks.push(t),t(this.renderableScenes)}detachRenderableSceneListener(t){this.renderableSceneCallbacks=this.renderableSceneCallbacks.filter(e=>e!==t)}async save(t){if(!this.getCommandContext().getState())throw new z("State undefined!");const n={title:await(async()=>{var l;if(t)return t;const i=this.getWorkflowManager().getTransaction().id,o=(l=(await be.getSavedDesigns()).find(c=>c.transactionId===i))==null?void 0:l.title;return o||"My design"})(),thumbnail:await this.createPreviewImage(!1,256),transactionId:this.getWorkflowManager().getTransaction().id,productId:this.getWorkflowManager().getProduct().id,integrationProductId:this.getWorkflowManager().getTransaction().integrationProduct.id,workflowName:this.getWorkflowManager().getWorkflow().name,workflowId:this.getWorkflowManager().getWorkflow().id,lastEdited:new Date};return await be.addDesign(n),n}async copy(){var s;const t=Et(this.getCommandContext().getState());if(!t)throw new z("Internal state is undefined! Cannot copy experience!");const e=JSON.stringify(t.transaction),a=this.getWorkflowManager().getWorkflow(),n=(s=this.getWorkflowManager().getTransaction().integrationProduct)==null?void 0:s.id;if(!n)throw new z("Integration product id is undefined!");return await this.getClient().getWorkflowExperience({type:"integration",integrationProductId:n,workflowId:a.id,workflowState:e})}async onDesignFinished(t,e=!0){const a=this.workflowManager.getTransaction();return a.completed?(await this.graphQlClient().mutate({mutation:ys,variables:{transactionId:a.id}}),{event:"",exportedData:{},lineItemImageUrl:"",optionsCost:0,transactionId:a.id,workflowViewerLink:"",workflowViewerReadOnlyLink:""}):kr(this.workflowManager,this.workflowManager.getWorkflow(),this.workflowManager.getLayouts(),()=>this.commandContext.getState(),this.workflowManager.getProduct(),a,this.workflowManager.getWorkflowSelections(),this.workflowManager.getWorkflow().name,t||(()=>{}),n=>e?this.createPreviewImage(n,1024):Promise.resolve(void 0),this.workflowManager.getWorkflowMetadata())}stepHasHandle(t){return t.type!==I.SilentIllustration&&t.type!==I.ProductOverlay}getExportedStepData(){const t=this.getWorkflowManager().getWorkflow(),e=this.getWorkflowManager().getWorkflowMetadata(),a=this.getWorkflowManager().getWorkflowSelections(),n=[];return t.steps.forEach(i=>{var d;const s=i.stepName,o=e[s],l=(d=a[s])==null?void 0:d.selections[0],c={stepId:s,title:i.stepTitle,properties:[]};if(l&&Ol(i,a)&&c.properties.push({type:"selection",value:l.name,priceModifier:l.priceModifier}),!o){n.push(c);return}switch(i.type){case I.Frame:{const A=i.data,u=o;u.image&&A.displayImageOnFinishStep&&c.properties.push({type:"image",value:u.image,priceModifier:0})}break;case I.Illustration:{const A=i.data,u=o;if(u&&u.colors&&u.colors.length>0&&A.displayColorsOnFinishStep){const h=u.colors.join(", ").toUpperCase();c.properties.push({type:"color",value:h,priceModifier:0})}}break;case I.Module:{const A=i.data,u=o;u&&u.text&&A.displayTextOnFinishStep&&c.properties.push({type:"text",value:u.text,priceModifier:0})}break;case I.Text:{const A=i.data,u=o;u&&u.text&&A.displayTextOnFinishStep&&c.properties.push({type:"text",value:u.text,priceModifier:0}),u&&u.color&&A.displayColorOnFinishStep&&c.properties.push({type:"color",value:u.color,priceModifier:0})}}n.push(c)}),n.filter(i=>i.properties&&i.properties.length>0)}getQuantity(){return this.getWorkflowManager().getTransaction().quantity||1}async setQuantity(t){if(t<1)throw new RangeError("WorkflowExperience quantity must be greater than zero.");if(this.isReadOnly)throw new Error("Cannot update quantity on a read-only WorkflowExperience");this.getWorkflowManager().getTransaction().quantity=t,this.callEvent("QuantityChanged"),this.checkForPriceBreakChanges();const e=this.getWorkflowManager().getTransaction();await this.graphQlClient().mutate({mutation:hs,variables:{id:e.id,quantity:t}})}addEventListener(t,e){const a=this.eventCallbacks.get(t)||[];a.push(e),this.eventCallbacks.set(t,a)}removeEventListener(t,e){const a=this.eventCallbacks.get(t)||[];this.eventCallbacks.set(t,a.filter(n=>n!==e))}callEvent(t){(this.eventCallbacks.get(t)||[]).forEach(e=>e(this))}}const Rl=r=>{if([I.Question,I.Frame,I.Illustration,I.Material,I.Model,I.Picture,I.Shape,I.Text].includes(r.type)){const e=r.data;return!!e.displaySelectionOnFinishStep||!!e.displaySelectionsOnFinishStep}return!1},Ol=(r,t)=>{if(!Rl(r))return!1;if(r.option&&(r.option.variants||[]).length>1){const e=t[r.stepName];return!!(e&&e.selections.length>0)}return!1},$l=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],Ul=async(r,t,e)=>{const a=t.data,n=e.data.baseUrl,i=a.assetUrl.replace("localhost","localstack"),s=n.slice(0,4)==="http"?"":"https://",o=new URL(s+n);o.searchParams.append("video",en(JSON.stringify([{href:i}]))),o.pathname=o.pathname+(o.pathname.slice(-1)==="/"?"":"/");const l=o.toString(),d=`data:image/svg+xml;base64,${en(await vn.toString(l,{type:"svg"}))}`,A=h=>{const g=r.find(p=>p.panelId===h.panelId);if(!g)throw new Y(h);const m=Q();return new G({id:m,src:d,type:M.Image,y:h.top,x:h.left,width:h.width,height:h.height,rotation:0},g)},u=e.data.regions;try{return u.map(A)}catch(h){return console.error(h),[]}},Ll=async(r,t,e,a)=>{const n=e.data,i=n.assetUrl,s=await ha(i);try{const o=ho(n,a.option);o&&(t[a.stepName]={selectedVariants:[o]});const l=async c=>{var m;const d=await sr(c,(m=o==null?void 0:o.asset)==null?void 0:m.fileLink),A=await ue(d),u=Q(),h=r.find(p=>p.panelId===c.panelId);if(!h)throw new Y(c);const g=ka(s,A,{scale:n.scale,left:n.x,top:n.y},a.data.forceImageCover);return[new G({id:u,path:A.path,type:M.Frame,forceImageCover:a.data.forceImageCover,x:c.left,y:c.top,width:c.width,height:c.height,layer:c.layer,layerIndex:c.layerIndex,rotation:c.rotation,scaleX:c.width/A.width,scaleY:c.height/A.height,pattern:{id:`${u}-pattern`,src:s.src,x:g.x,y:g.y,width:s.width,height:s.height,rotation:0,scaleX:g.zoom,scaleY:g.zoom,svg:s.svg,colors:s.colors}},h)]};return(await Promise.all(a.data.regions.map(c=>l(c)))).flat()}catch(o){return console.error(o),[]}},Vl=async(r,t,e,a)=>{var y,E;const n=e.data,i=a.option;if(!i)return console.error(`No option for step ${a.stepName}.`),[];const s=((y=i.variants)==null?void 0:y.find(b=>b.id===n.illustrationVariantId))||Ae(i);if(!s)return console.error(`No variant with ID: ${n.illustrationVariantId}`),[];if(!s.asset)return console.error(`No asset for variant with ID: ${n.illustrationVariantId}`),[];t[a.stepName]={selectedVariants:[s]};const o=(E=s.asset)==null?void 0:E.fileLink;if(!o)return console.error(`No asset link for variant with ID: ${n.illustrationVariantId}`),[];const l=await tt(o,!0),c=/<svg.*?<\/svg>/s,d=l.match(c)||[],A=(d==null?void 0:d.length)>0?d[0]:"",g=ct().parseFromString(A,"image/svg+xml").firstElementChild;if(!g)return console.error("Failed to read SVG."),[];$e(g);const m={};Rt(g,b=>{$l.includes(b.tagName)&&!b.attributes.getNamedItem("fill")&&b.setAttribute("fill","#000000");const P=b.attributes.getNamedItem("fill");if(P&&P.value!=="none"){const x=P.value,N=`spiff-fill-${x.replace(/\W/g,"")}`;b.classList.add(N),m[N]={browserValue:x}}const D=b.attributes.getNamedItem("stroke");if(D&&D.value!=="none"){const x=D.value,N=`spiff-stroke-${x.replace(/\W/g,"")}`;b.classList.add(N),m[N]={browserValue:x}}});const f=wt().serializeToString(g),C=n.colors;if(C){for(const[b,P]of Object.entries(m))for(const D of Object.keys(C))if(P.browserValue===D){m[b]={browserValue:C[D]};break}}const w=b=>{const P=r.find(x=>x.panelId===b.panelId);if(!P)throw new Y(b);const D=Q();return new G({colors:m,id:D,svg:f,type:M.Illustration,y:b.top,x:b.left,rotation:b.rotation,width:b.width,height:b.height,layer:b.layer,layerIndex:b.layerIndex,immutable:b.immutable},P)},S=a.data.regions;try{return S.map(w)}catch(b){return console.error(b),[]}},zl=async(r,t,e)=>{const a=await pr(e.data.module),n=t.data,i=(o,l)=>{const c=r.find(A=>A.panelId===l.panelId);if(!c)throw new Y(l);const d=Q();return new G({colors:{},id:d,svg:o,type:M.Illustration,y:l.top,x:l.left,rotation:l.rotation,width:l.width,height:l.height,layer:l.layer,layerIndex:l.layerIndex},c)},s=e.data.regions;try{return s.map(o=>i(a.svgPrint(n.text,o),o))}catch(o){return console.error(o),[]}},ql=async(r,t,e,a)=>{var d,A;const n=e.data,i=a.option;if(!i)return console.error(`No option for step ${a.stepName}.`),[];const s=((d=i.variants)==null?void 0:d.find(u=>u.id===n.pictureVariantId))||Ae(i);if(!s)return console.error(`No variant with ID: ${n.pictureVariantId}`),[];if(!s.asset)return console.error(`No asset for variant with ID: ${n.pictureVariantId}`),[];t[a.stepName]={selectedVariants:[s]};const o=(A=s.asset)==null?void 0:A.fileLink;if(!o)return console.error(`No asset link for variant with ID: ${n.pictureVariantId}`),[];const l=u=>{const h=r.find(m=>m.panelId===u.panelId);if(!h)throw new Y(u);const g=Q();return new G({id:g,src:o,type:M.Image,y:u.top,x:u.left,rotation:u.rotation,width:u.width,height:u.height,layer:u.layer,layerIndex:u.layerIndex,immutable:u.immutable,preserveAspectRatio:"none"},h)},c=a.data.regions;try{return c.map(l)}catch(u){return console.error(u),[]}},Gl=async(r,t,e,a)=>{var c;const n=e.data,i=a.option;if(!i)return console.error(`No option for step ${a.stepName}.`),[];const s=((c=i.variants)==null?void 0:c.find(d=>d.id===n.colorVariantId))||Ae(i);if(!s)return console.error(`No variant with ID: ${n.colorVariantId}`),[];t[a.stepName]={selectedVariants:[s]};const o=d=>{const A=r.find(p=>p.panelId===d.panelId);if(!A)throw new Y(d);const u=`
2262
2314
  <svg
2263
2315
  xmlns="http://www.w3.org/2000/svg"
2264
2316
  xmlnsXlink="http://www.w3.org/1999/xlink"
@@ -2278,8 +2330,8 @@
2278
2330
  fill="${s==null?void 0:s.color}"
2279
2331
  />
2280
2332
  </svg>
2281
- `,g={"spiff-fill-shape":{browserValue:s.color||"#000000"}},m=Q();return new q({colors:g,id:m,svg:u,type:k.Illustration,y:d.top,x:d.left,rotation:d.rotation,width:d.width,height:d.height,layer:d.layer,layerIndex:d.layerIndex,immutable:d.immutable},A)},l=a.data.regions;try{return l.map(o)}catch(d){return console.error(d),[]}},ql=async(r,t,e)=>{const a=[],i=(()=>{var c,d;return t.type===I.ProductOverlay?e||((c=t.data.asset)==null?void 0:c.fileLink)||"":((d=t.data.asset)==null?void 0:d.fileLink)||""})(),o=(()=>i.endsWith(".jpeg")||i.endsWith(".jpg")||i.endsWith(".png")?k.Image:(i.endsWith(".svg"),k.Illustration))(),l=t.data.regions;if(o==="image")try{l.forEach(c=>{const d=r.find(u=>u.panelId===c.panelId);if(!d)throw new Y(c);const A={id:Q(),src:i,type:o,y:c.top,x:c.left,width:c.width,height:c.height,layer:c.layer,layerIndex:c.layerIndex,productOverlay:t.type===I.ProductOverlay?!0:void 0,scaleX:1,scaleY:1,rotation:c.rotation,excludeFromExport:t.data.excludeFromPrint,preserveAspectRatio:"none"};a.push(new q(A,d))})}catch(c){console.error(c)}else{const c=await et(i,!0),d=A=>{const u=/<svg.*?<\/svg>/s,h=A.match(u)||[],g=(h==null?void 0:h.length)>0?h[0]:"",f=ct().parseFromString(g,"image/svg+xml").firstElementChild;if(!f)throw new St("Failed to read SVG.");return $e(f),wt().serializeToString(f)};l.forEach(A=>{const u=r.find(g=>g.panelId===A.panelId);if(!u)throw new Y(A);const h={id:Q(),src:i,asset_key:i,svg:d(c),colors:{},type:o,y:A.top,x:A.left,width:A.width,height:A.height,layer:A.layer,layerIndex:A.layerIndex,scaleX:1,scaleY:1,rotation:A.rotation,productOverlay:t.type===I.ProductOverlay?!0:void 0,excludeFromExport:t.data.excludeFromPrint};a.push(new q(h,u))})}return a},Wl=async(r,t,e,a)=>{const n=[],i=e.data,s=30,o=p=>p.vertical?"center":p.textAlign||"center",l=()=>{var w;const p=a.option;if(!p)return;const f=((w=p.variants)==null?void 0:w.find(S=>S.id===i.fontVariantId))||Ae(p);if(!f||!f.asset)return;t[a.stepName]={selectedVariants:[f]};const C=f.asset.fileLink;if(C)return C},d=await(async()=>{const p=l();if(!p)return;const f=await It(p);return{assetUrl:p,name:f.names.fullName.en}})(),A=(a.data.replaceableText?a.data.replaceableText.replace("{{}}",i.text):i.text)||"",u=De(A,{vertical:a.data.vertical,uppercase:a.data.uppercase}),h=async p=>{const f=p.colorOption;if(!f)return;const C=H.getDefaultVariant(f);return C==null?void 0:C.color},g=i.color||await h(a.data),m=a.data.regions;for(const p of m){const f=r.find(w=>w.panelId===p.panelId);if(!f)continue;const C={stepName:e.name,id:Q(),align:o(a.data),curved:a.data.curved,fill:i.color||g||"#000000",fontData:d,fontSize:a.data.size||s,height:p.height,layer:p.layer,layerIndex:p.layerIndex,paths:a.data.paths,rotation:p.rotation,text:u,type:k.Textbox,vertical:a.data.vertical,verticalAlign:a.data.verticalAlign||"middle",width:p.width,x:p.left,y:p.top};if(d){const[w,S]=Kt(a.data.size||s,d,p,[De(u,{vertical:a.data.vertical,uppercase:a.data.uppercase})],{size:a.data.size,minSize:a.data.minSize,maxSize:a.data.maxSize});n.push(new q({...C,fontSize:w,text:C.curved?C.text:(S||[]).join(`
2282
- `)},f))}else n.push(new q(C,f))}return n},jl=(r,t)=>r.conditions?r.conditions.every(e=>{const a=t[e.targetStepName];if(a&&a.selectedVariants){const n=a.selectedVariants;return e.requiredVariantSelections.some(i=>n.find(s=>s.id===i)!==void 0)}return!1}):!0,Tr=async(r,t,e,a)=>{const n=[],i={};for(const s of r){const o=t.steps.find(l=>l.stepName===s.name);if(o)switch(o.type){case I.DigitalContent:n.push(...await $l(e,s,o));break;case I.Frame:case I.Photo:n.push(...await Ul(e,i,s,o));break;case I.Illustration:n.push(...await Ll(e,i,s,o));break;case I.Module:n.push(...await Vl(e,s,o));break;case I.Picture:n.push(...await zl(e,i,s,o));break;case I.Shape:n.push(...await Gl(e,i,s,o));break;case I.Text:n.push(...await Wl(e,i,s,o));break}}for(const s of t.steps)s.type!==I.SilentIllustration&&s.type!==I.ProductOverlay||jl(s,i)&&n.push(...await ql(e,s,a));return n};class Hl{constructor(t){this.handleCompleteRender=null;const e=new Map;t.forEach(a=>e.set(a.id,new Kl(a.id,a.name,this,{width:a.width,height:a.height},this.getWorkflowManager.bind(this)))),this.layouts=e}setCompleteRenderCallback(t){this.handleCompleteRender=t,t(Array.from(this.layouts.values()))}onCompleteRender(){this.handleCompleteRender&&this.handleCompleteRender(Array.from(this.layouts.values()))}getAll(){return this.layouts}setWorkflowManager(t){this.workflowManager=t}getWorkflowManager(){return this.workflowManager}}const Yl=()=>new Promise((r,t)=>{try{const a=pt().getContext("webgl2");r(!!a)}catch{r(!1)}}),Jl=Yl();class Kl{constructor(t,e,a,n,i){this.hasSetStaticContext=!1,this.interactiveDirty=!1,this.staticCtxDirty=!1,this.lastRequestedRenderArguments=void 0,this.lastCompletedStaticRender=void 0,this.renderQueue=new Da(2),this.id=t,this.name=e,this.service=a,this.panelSize=n,this.getWorkflowManager=i}getID(){return this.id}getName(){return this.name}getPanelSize(){return this.panelSize}getStaticContext(){return this.textureCtx}setStaticContext(t){this.textureCtx=t,this.lastRequestedRenderArguments&&this.render(this.lastRequestedRenderArguments)}getStaticContextDirty(){return this.staticCtxDirty}setStaticContextDirty(t){this.staticCtxDirty=t}getInteractiveCanvasDirty(){return this.interactiveDirty}setInteractiveCanvasDirty(t){this.interactiveDirty=t}markLastCompletedStaticRender(){this.lastCompletedStaticRender=Date.now(),this.service.onCompleteRender()}getLastCompletedStaticRender(){return this.lastCompletedStaticRender}async render(t){const e=Et(t);this.lastRequestedRenderArguments=e;const a=this.getStaticContext();if(!a){this.markLastCompletedStaticRender(),this.setStaticContextDirty(!1);return}this.renderQueue.enqueue(new _l(this.getID(),a,await Jl,()=>{this.markLastCompletedStaticRender(),this.setStaticContextDirty(!0)},e,this.getWorkflowManager))}}class _l extends Pa{constructor(t,e,a,n,i,s){super(),this.layoutId=t,this.ctx=e,this.nonPOTSupport=a,this.onRender=n,this.layouts=i,this.getWorkflowManager=s}getDynamicTextureResolution(){return this.getIsMobile()||!this.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}getIsMobile(){return window.innerWidth<=480}offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}resizeFit(t,e=4096){const a=e/t.width,n=e/t.height,i=Math.min(a,n);return i>1?t:{width:t.width*i,height:t.height*i}}async execute(){var h,g;const t=this.layouts.find(m=>m.layoutState.layout.id===this.layoutId);if(!t)return;const e=t.layoutState.elements||[],a=t.layoutState.layout.width,n=t.layoutState.layout.height,i=a===1||n===1?{width:1,height:1}:this.getDynamicTextureResolution(),s=i.width,o=i.height;let l,c;if(this.nonPOTSupport){const m=s/o;a/n<m?(l=s,c=n*(s/a)):(l=a*(o/n),c=o);const f=this.resizeFit({width:l,height:c});l=f.width,c=f.height}else l=i.width,c=i.height;const d=ze(t.layoutState.layout,e,{renderingConfiguration:{purpose:Tt.ThreeD,templatingContext:(g=(h=this.getWorkflowManager)==null?void 0:h.call(this))==null?void 0:g.getTemplatingContext()}}),A=Tn(d),u=await Sa.Pith.from(this.ctx,A,{anonymousCrossOrigin:!0,ignoreDimensions:!this.nonPOTSupport,ignoreAnimation:!0,ignoreClear:!0,ignoreMouse:!0,enableRedraw:!1,createCanvas:pt,createImage:oe,DOMParser:ba(),fetch});u.resize(l,c),await u.render(),this.onRender()}}const Xl=(r,t)=>{const e=[];return r.forEach(a=>{const n=t.steps.find(i=>i.stepName===a.stepName);(n==null?void 0:n.type)===I.Text&&a.stepAspectType==="Text"&&e.push({name:n.stepName,data:{text:a.value}})}),e},Zl=async(r,t,e,a)=>{let n={serializableWorkflow:{steps:[]},layouts:{}};n=new $(e.map(l=>new Na(l))).apply(n);const s=await Tr(r,t,e,a);return new $(s).apply(n)};class tc{constructor(t){this.handleCache={},this.bundle=t}async getHandle(t){if(this.handleCache[t.name])return this.handleCache[t.name];const e=await this.createHandle(t);return this.handleCache[t.name]=e,e}async getHandles(){var e;if(!((e=this.bundle.getProductCollection())!=null&&e.getResource().globalPropertyConfiguration))return[];await this.bundle.getGlobalPropertyStateManager().getInitializationPromise();const t=this.bundle.getProductCollection().getResource().globalPropertyConfiguration;return Promise.all(t.aspects.map(a=>this.getHandle(a)))}applyConditionsFromState(t,e){return e?t.filter(a=>this.aspectConditionsSatisfied(a.getRawProperty(),e)):t}aspectConditionsSatisfied(t,e){return!t.conditions||t.conditions.length===0?!0:t.conditions.some(a=>{const n=e.aspects.find(i=>i.name===a.targetAspectName);return n?a.requiredVariantSelections.some(i=>i===n.value):!1})}async createHandle(t){switch(t.type){case V.FileUpload:return new Nr(this.bundle,t).initialize();case V.ColorOption:return new Ca(this.bundle,t,t.entityId?await H.getOption(t.entityId):void 0);case V.Option:{const e=t.entityId?await H.getOption(t.entityId):void 0;return(e==null?void 0:e.type)==="Color"?new Ca(this.bundle,t,e):new za(this.bundle,t,e)}case V.Text:return new Qr(this.bundle,t);default:throw new Error("Unhandled Global Property Aspect Type")}}}class Ge{constructor(t,e){this.bundle=t,this.property=e}getName(){return this.property.name}getTitle(){return this.property.title}getDescription(){return this.property.description}getType(){return this.property.type}getRawProperty(){return this.property}isMandatory(){return!!this.property.mandatory}isMandatoryFulfilled(){return!this.property.mandatory||!!this.bundle.getGlobalPropertyStateManager().getAspectMandatoryFulfilled(this.property.name)}getSharedSteps(t){return(t??this.bundle.getWorkflowExperiences()).flatMap(n=>n.getStepsConditionallyActive().filter(i=>{var s;return i.getOverrideGlobalPropertyConfiguration(this.property.type)?!1:(s=i.getRaw().globalPropertyAspectConfigurations)==null?void 0:s.some(o=>{var l,c;return o.globalPropertyConfigurationId===((c=(l=this.bundle.getProductCollection())==null?void 0:l.getResource().globalPropertyConfiguration)==null?void 0:c.id)&&o.aspectName===this.property.name})}))}getStateValue(){return this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name)}}class Nr extends Ge{constructor(t,e){super(t,e)}async initialize(){var t,e,a,n;return(e=(t=this.property.data)==null?void 0:t.fileUpload)!=null&&e.colorOptionId&&(this.colorOption=await H.getOption((n=(a=this.property.data)==null?void 0:a.fileUpload)==null?void 0:n.colorOptionId)),await this.loadImageData(),this}async loadImageData(){var e;const t=await this.getImage();if(t!=null&&t.fileLink)if(t!=null&&t.fileLink.endsWith(".svg")){const a=await et(t==null?void 0:t.fileLink),n=await Ma(t==null?void 0:t.fileLink),i=n.width,s=n.height,o=await ot(a),l=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);(e=l==null?void 0:l.colors)==null||e.forEach(d=>{o.colors[d.key]={browserValue:d.browserValue,pmsValue:d.pmsValue}});const c={src:t==null?void 0:t.fileLink,width:i,height:s,aspect:i/s,svg:o.svg,colors:o.colors};dt.set(t==null?void 0:t.fileLink,c),this.imageData=c}else this.imageData=void 0}async selectImage(t){const e=this.bundle.getGlobalPropertyStateManager();await Promise.all([e.setAspect(this.property.name,t.key,{...e.getAspectStorage(this.property.name)||{},originalAssetKey:t.key,backgroundRemovedAssetKey:void 0,useOriginalAsset:void 0},void 0),this.applyImageSelection(t),this.loadImageData()])}async canUseBackgroundRemover(){return this.bundle.getClient().canUseAddon(Me.BackgroundRemover)}async removeBackgroundFromImage(t=!0){if(!await this.canUseBackgroundRemover())throw new Error("The current Integration does not have access to the Background Remover. Please call canUseBackgroundRemover to ensure you disable this feature when appropriate.");const e=await this.getOriginalImage();if(!e)throw new Error("You must supply an image selection before attempting to remove the background.");const a=this.bundle.getGlobalPropertyStateManager(),n=await U.removeBackgroundFromAsset(e),s={...a.getAspectStorage(this.property.name),backgroundRemovedAssetKey:n.key,useOriginalAsset:!t},l=[t?a.setAspect(this.property.name,n.key,s):a.setAspectStorage(this.property.name,s)];return t&&(l.push(this.applyImageSelection(n,void 0,!1,!1)),l.push(this.loadImageData())),await Promise.all(l),this.updateSharedStepStorage(s),n}hasImage(){return!!this.getStateValue()}async getImage(){const t=this.getStateValue();if(t)return U.getLocalOrFromServer(t)}async getImageWithColors(){var t,e;return await this.loadImageData(),(t=this.imageData)!=null&&t.svg?Oe(Ue(this.imageData.svg,this.imageData.colors??{},!1)):(e=this.imageData)==null?void 0:e.src}async getOriginalImage(){const t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(t!=null&&t.originalAssetKey)return U.getLocalOrFromServer(t.originalAssetKey)}async getBackgroundRemovedImage(){const t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(t!=null&&t.backgroundRemovedAssetKey)return U.getLocalOrFromServer(t.backgroundRemovedAssetKey)}getUseOriginalImage(){var t;return((t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name))==null?void 0:t.useOriginalAsset)??!1}async setUseOriginalImage(t){const e=await this.getOriginalImage();if(!e)throw new Error("You must select an image before calling setUseOriginalImage");const a=this.bundle.getGlobalPropertyStateManager(),n=a.getAspectStorage(this.property.name);if((n==null?void 0:n.useOriginalAsset)===t)return;const i={...n,useOriginalAsset:t},s=t?n==null?void 0:n.originalAssetKey:n==null?void 0:n.backgroundRemovedAssetKey,o=[a.setAspect(this.property.name,s||"",i)];if(t)o.push(this.applyImageSelection(e,void 0,!1,!1));else{const l=async()=>{const c=await this.getBackgroundRemovedImage();if(!c)throw new Error("You must call removeBackgroundFromImage before attempting to use that version of the image.");this.applyImageSelection(c,void 0,!1,!1)};o.push(l())}o.push(this.loadImageData()),await Promise.all(o),this.updateSharedStepStorage(i)}async applyGlobalState(t){const e=this.getStateValue();if(!e)return;const a=await U.getLocalOrFromServer(e);if(!a)return;await this.applyImageSelection(a,t,!1,!0);const n=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(n){if(this.updateSharedStepStorage({...n}),n.colors){const i=new Map(n.colors.map(s=>[s.key,{browserValue:s.browserValue,pmsValue:s.pmsValue}])??[]);this.getSharedSteps(t).forEach(s=>{s.changeColors(i)})}}else this.updateSharedStepStorage({originalAssetKey:e}),await this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{originalAssetKey:e})}getAvailableColors(){var t,e,a,n;return(e=(t=this.property.data)==null?void 0:t.fileUpload)!=null&&e.colorPickerEnabled?((n=(a=this.colorOption)==null?void 0:a.variants)==null?void 0:n.map(i=>({fill:i.color,stroke:i.color,variant:i,pmsValue:i.name})))??[]:[]}getCurrentColors(){var t;return(t=this.imageData)==null?void 0:t.colors}isColorPickerEnabled(){var t,e;return((e=(t=this.property.data)==null?void 0:t.fileUpload)==null?void 0:e.colorPickerEnabled)??!1}isPmsPickerEnabled(){var t,e;return((e=(t=this.property.data)==null?void 0:t.fileUpload)==null?void 0:e.pmsPickerEnabled)??!1}async getOriginalColors(){var e;return(e=this.imageData)!=null&&e.svg?(await ot(this.imageData.svg)).colors:void 0}async changeColors(t){var i;if(!((i=this.imageData)!=null&&i.svg))return;const e=this.getSharedSteps(),a=new Map(Object.entries(t));e.forEach(s=>{s.changeColors(a)});const n=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{...n,colors:Object.entries(t).map(([s,o])=>({key:s,browserValue:o.browserValue,pmsValue:o.pmsValue}))}),await this.loadImageData()])}async applyImageSelection(t,e,a=!0,n=!0){const s=this.getSharedSteps(e).map(o=>{const l=o;if(l.getFrameService())return l.selectImage(t,a,n)});await Promise.all(s)}updateSharedStepStorage(t){this.bundle.getWorkflowExperiences().forEach(a=>a.getSteps().forEach(n=>{var s;if(n.getOverrideGlobalPropertyConfiguration(this.property.type))return;((s=n.getRaw().globalPropertyAspectConfigurations)==null?void 0:s.some(o=>{var l,c;return o.globalPropertyConfigurationId===((c=(l=this.bundle.getProductCollection())==null?void 0:l.getResource().globalPropertyConfiguration)==null?void 0:c.id)&&o.aspectName===this.property.name}))&&a.getWorkflowManager().updateStorage(n.getId(),{framePatternData:{originalAssetKey:t.originalAssetKey,backgroundRemovedAssetKey:t.backgroundRemovedAssetKey,useOriginalAsset:t.useOriginalAsset}})}))}}class Qr extends Ge{constructor(t,e){super(t,e)}isTemplatingEnabled(){var t,e;return((e=(t=this.property.data)==null?void 0:t.text)==null?void 0:e.templatingEnabled)||!1}getText(){const t=this.getStateValue();return t||""}async setText(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t,void 0,void 0),this.applyTextSelection(t)])}async applyGlobalState(t){const e=this.getStateValue();if(!e)return Promise.resolve();await this.applyTextSelection(e,t)}async applyTextSelection(t,e){const n=this.getSharedSteps(e).map(i=>{i.setText(t)});await Promise.all(n)}}class za extends Ge{constructor(t,e,a){super(t,e),this.optionResource=a}async initDefaultVariant(){var e,a;const t=(a=(e=this.optionResource)==null?void 0:e.variants)==null?void 0:a.find(n=>{var i,s;return n.id===((s=(i=this.optionResource)==null?void 0:i.defaultVariant)==null?void 0:s.id)});t&&await this.selectVariant(new it(t))}getCurrentVariant(){var e,a;if(!this.optionResource)return;const t=this.getStateValue();if(t){const n=(a=this.optionResource.variants)==null?void 0:a.find(i=>i.id===t);return n?new it(n):void 0}else{const n=(e=this.optionResource.variants)==null?void 0:e.find(i=>{var s,o;return i.id===((o=(s=this.optionResource)==null?void 0:s.defaultVariant)==null?void 0:o.id)});return n?new it(n):void 0}}getAvailableVariants(){var e,a;return(((a=(e=this.optionResource)==null?void 0:e.variants)==null?void 0:a.filter(n=>n.enabled))||[]).map(n=>new it(n))}getAllVariants(){var e;return(((e=this.optionResource)==null?void 0:e.variants)||[]).map(a=>new it(a))}async selectVariant(t,e){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId(),void 0,e),this.applyVariantSelection(t)])}async applyGlobalState(t){var n,i;const e=this.getStateValue();if(!e)return Promise.resolve();const a=(i=(n=this.optionResource)==null?void 0:n.variants)==null?void 0:i.find(s=>s.id===e);return a?this.applyVariantSelection(new it(a),t):Promise.resolve()}async applyVariantSelection(t,e){const n=this.getSharedSteps(e).map(i=>i.selectVariant(t));await Promise.all(n)}}class Ca extends za{constructor(t,e,a){super(t,e,a)}async selectVariant(t,e){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId(),void 0,e),this.applyColorVariant(t,void 0,e)])}async applyGlobalState(t){var i,s,o;const e=this.getStateValue();if(!e)return Promise.resolve();const a=(s=(i=this.optionResource)==null?void 0:i.variants)==null?void 0:s.find(l=>l.id===e);if(!a)return Promise.resolve();await this.applyColorVariant(new it(a),t);const n=(o=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name))==null?void 0:o.customColor;n&&this.setCustomColor(n)}async applyColorVariant(t,e,a){const i=this.getSharedSteps(e).map(s=>{switch(s.getType()){case I.Shape:return s.selectVariant(t);case I.Text:return s.setFillColor({fill:t.getColor(),stroke:t.getColor(),variant:t.getResource()});case I.Illustration:return s.setColor((a==null?void 0:a.toString())||"",t.getColor()||"")}});await Promise.all(i)}setCustomColor(t){this.getSharedSteps().forEach(a=>a.setCustomColor(t)),this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{customColor:t})}getCustomColor(){var t,e;return((t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name))==null?void 0:t.customColor)||((e=this.getCurrentVariant())==null?void 0:e.getColor())||"#ffffff"}}const ec=(r,t,e,a)=>r.flatMap(n=>n.getSteps()).filter(n=>n.getGlobalPropertyAspects(t).includes(e)&&n.getType()===a),ac=(r,t,e)=>{const n=ec(r,t,e,I.Illustration).map(i=>{var l;const s=(l=i.getCurrentVariant())==null?void 0:l.getAssetResource(),o=i.getColors();return!(s!=null&&s.assetConfiguration)||!o?0:Object.getOwnPropertyNames(o).length});return Math.max(...n)};function Rr(r){var e;const t=new Map;return(e=r==null?void 0:r.aspects)==null||e.forEach(a=>{a.value!==""&&t.set(a.name,!0)}),t}class nc{constructor(t,e,a,n,i){this.mandatoryFulfilledAspects=new Map,this.bundleId=t,this.bundleOwnerId=e,this.configuration=a,this.bundleOptions=i;const s=i==null?void 0:i.existingGlobalPropertyState;this.initPromise=s?Promise.resolve(s).then(()=>{console.log("Setting global property state to existing state."),this.globalPropertyState=s,this.recalculateMandatoryStates()}):this.createGlobalPropertyState().then(o=>{console.log("Setting global property state to new state."),this.globalPropertyState=o,this.recalculateMandatoryStates()}),this.onGlobalPropertyStateChange=n}recalculateMandatoryStates(){this.mandatoryFulfilledAspects=Rr(this.globalPropertyState)}setBundleOptions(t){this.bundleOptions=t}getBundleOptions(){return this.bundleOptions}setConfiguration(t){this.configuration=t}getInitializationPromise(){return this.initPromise}getGlobalPropertyState(){return this.globalPropertyState}async setGlobalPropertyState(t){this.globalPropertyState||await this.initPromise;const e=Et(this.globalPropertyState);this.globalPropertyState={...t,id:e.id},this.recalculateMandatoryStates(),await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(e,this.globalPropertyState)}getAspectMandatoryFulfilled(t){return this.mandatoryFulfilledAspects.get(t)}getAspect(t,e){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const a=this.globalPropertyState.aspects.find(n=>n.name===t&&n.channel===e);if(a)return a.value}getAspectStorage(t,e){var a;if(!this.globalPropertyState)throw new Error("Global property state not initialized");return(a=this.globalPropertyState.aspects.find(n=>n.name===t&&n.channel===e))==null?void 0:a.storage}async setAspect(t,e,a,n){if(!this.globalPropertyState)throw new Error("Global property state not initialized");if(!this.configuration)throw new Error("Global property configuration not linked to the state manager.");const i=this.configuration.aspects.find(l=>l.name===t);if(!i)throw new Error(`Failed to find configuration aspect with name: ${t}`);this.mandatoryFulfilledAspects.set(t,e!=="");const s=Et(this.globalPropertyState),o=this.globalPropertyState.aspects.filter(l=>l.name===t);if(o.length>0)if(n){const l=o.find(c=>c.channel===n);if(l)l.value=e,l.type=i.type,l.channel=n,a!==void 0&&(l.storage=a!==null?a:void 0);else{if(n===1){const c=this.globalPropertyState.aspects.findIndex(d=>!d.channel&&d.name===t);c&&c>0&&this.globalPropertyState.aspects.splice(c,1)}this.globalPropertyState.aspects.push({name:t,value:e,type:i.type,storage:a!==null?a:void 0,channel:n})}}else{const l=o[0];l.value=e,l.type=i.type,a!==void 0&&(l.storage=a!==null?a:void 0)}else this.globalPropertyState.aspects.push({name:t,value:e,type:i.type,storage:a!==null?a:void 0,channel:n});await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(s,this.globalPropertyState)}async setAspectStorage(t,e,a){if(!this.globalPropertyState)throw new Error("Global property state not initialized");if(!this.configuration)throw new Error("Global property configuration not linked to the state manager.");const n=this.configuration.aspects.find(o=>o.name===t);if(!n)throw new Error(`Failed to find configuration aspect with name: ${t}`);const i=Et(this.globalPropertyState),s=this.globalPropertyState.aspects.filter(o=>o.name===t);if(s.length>0)if(a){const o=s.find(l=>l.channel===a);o&&(o.storage=e!==null?e:void 0,o.type=n.type)}else{const o=s[0];o.storage=e!==null?e:void 0,o.type=n.type}else this.globalPropertyState.aspects.push({name:t,value:"",type:n.type,storage:e!==null?e:void 0,channel:a});await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(i,this.globalPropertyState)}async updateGlobalPropertyState(){var e,a;if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await B.getShadowGraphqlClient().mutate({mutation:jo,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects.map(n=>{let i=n.type&&n.storage?{}:void 0;if(i)switch(n.type){case V.FileUpload:{i.fileUpload=n.storage;break}case V.Option:{i.option=n.storage;break}case V.ColorOption:{i=n.storage;break}}return{name:n.name,value:n.value,type:n.type,storage:i,channel:n.channel}})},context:{headers:{bundleOwnerId:this.bundleOwnerId,...(e=this.bundleOptions)==null?void 0:e.additionalHeaders}}});if((a=t.data)!=null&&a.globalPropertyStateUpdate)this.globalPropertyState=t.data.globalPropertyStateUpdate;else throw new Error("Unable to update global property state")}async createGlobalPropertyState(){var e,a;const t=await B.getShadowGraphqlClient().mutate({mutation:Wo,variables:{bundleId:this.bundleId},context:{headers:{bundleOwnerId:this.bundleOwnerId,...(e=this.bundleOptions)==null?void 0:e.additionalHeaders}}});if((a=t.data)!=null&&a.globalPropertyStateCreate&&t.data.globalPropertyStateCreate.id)return t.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}class rc{constructor(t){this.setState(t)}setState(t){t&&(this.state=JSON.parse(t))}applyStateToWorkflowExperience(t){var s;if(!this.state||!((s=t==null?void 0:t.getWorkflowManager())!=null&&s.getModelContainer()))return;const e=this.state.transactions.find(o=>o.transactionId===t.getWorkflowManager().getTransaction().id);if(!e)return;const a=this.getTransformToApply(e);if(!a)return;const n=this.flipTransform(a,t.getWorkflowManager().getPreviewService()),i=t.getWorkflowManager().getModelContainer();i.position=n.position,i.rotation=n.rotation,i.scale=n.scale}getTransformToApply(t){return t.activeTransform&&t.transforms?t.transforms[t.activeTransform]:t.transform}updateWorkflowExperienceTransform(t,e,a){const n=t.getWorkflowManager().getTransaction().id;this.state?this.state.transactions||(this.state.transactions=[]):this.state={transactions:[]};const i=this.state.transactions.find(s=>s.transactionId===n);i?(i.transforms||(i.transforms={}),i.transforms[e]=a):this.state.transactions.push({transactionId:n,activeTransform:e,transforms:{[e]:a}})}activateWorkflowExperienceTransform(t,e){var l,c;if(!((l=t==null?void 0:t.getWorkflowManager())!=null&&l.getModelContainer())||!this.state)return;const a=t.getWorkflowManager().getTransaction().id,n=this.state.transactions.find(d=>d.transactionId===a),i=(c=n==null?void 0:n.transforms)==null?void 0:c[e];if(!i)return;const s=this.flipTransform(i,t.getWorkflowManager().getPreviewService()),o=t.getWorkflowManager().getModelContainer();o.position=s.position,o.rotation=s.rotation,o.scale=s.scale,n.activeTransform=e}removeStateForTransaction(t){if(!this.state||!this.state.transactions)return;const e=this.state.transactions.findIndex(a=>a.transactionId===t);e!==-1&&this.state.transactions.splice(e,1)}getSerializedState(){if(this.state)return this.deleteFieldNameFromObjectRecursive(this.state,"__typename"),JSON.stringify(this.state)}deleteFieldNameFromObjectRecursive(t,e){if(!(typeof t!="object"||t===null))for(const a in t)a===e?delete t[a]:this.deleteFieldNameFromObjectRecursive(t[a],e)}flipTransform(t,e){return e&&e.flipTransform?e.flipTransform(t.position,{x:t.rotation.x*Math.PI/180,y:t.rotation.y*Math.PI/180,z:t.rotation.z*Math.PI/180},t.scale):{position:t.position,rotation:{x:t.rotation.x*Math.PI/180,y:t.rotation.y*Math.PI/180,z:t.rotation.z*Math.PI/180},scale:t.scale}}}const ic=v.gql`
2333
+ `,g={"spiff-fill-shape":{browserValue:s.color||"#000000"}},m=Q();return new G({colors:g,id:m,svg:u,type:M.Illustration,y:d.top,x:d.left,rotation:d.rotation,width:d.width,height:d.height,layer:d.layer,layerIndex:d.layerIndex,immutable:d.immutable},A)},l=a.data.regions;try{return l.map(o)}catch(d){return console.error(d),[]}},Wl=async(r,t,e)=>{const a=[],i=(()=>{var c,d;return t.type===I.ProductOverlay?e||((c=t.data.asset)==null?void 0:c.fileLink)||"":((d=t.data.asset)==null?void 0:d.fileLink)||""})(),o=(()=>i.endsWith(".jpeg")||i.endsWith(".jpg")||i.endsWith(".png")?M.Image:(i.endsWith(".svg"),M.Illustration))(),l=t.data.regions;if(o==="image")try{l.forEach(c=>{const d=r.find(u=>u.panelId===c.panelId);if(!d)throw new Y(c);const A={id:Q(),src:i,type:o,y:c.top,x:c.left,width:c.width,height:c.height,layer:c.layer,layerIndex:c.layerIndex,productOverlay:t.type===I.ProductOverlay?!0:void 0,scaleX:1,scaleY:1,rotation:c.rotation,excludeFromExport:t.data.excludeFromPrint,preserveAspectRatio:"none"};a.push(new G(A,d))})}catch(c){console.error(c)}else{const c=await tt(i,!0),d=A=>{const u=/<svg.*?<\/svg>/s,h=A.match(u)||[],g=(h==null?void 0:h.length)>0?h[0]:"",f=ct().parseFromString(g,"image/svg+xml").firstElementChild;if(!f)throw new St("Failed to read SVG.");return $e(f),wt().serializeToString(f)};l.forEach(A=>{const u=r.find(g=>g.panelId===A.panelId);if(!u)throw new Y(A);const h={id:Q(),src:i,asset_key:i,svg:d(c),colors:{},type:o,y:A.top,x:A.left,width:A.width,height:A.height,layer:A.layer,layerIndex:A.layerIndex,scaleX:1,scaleY:1,rotation:A.rotation,productOverlay:t.type===I.ProductOverlay?!0:void 0,excludeFromExport:t.data.excludeFromPrint};a.push(new G(h,u))})}return a},jl=async(r,t,e,a)=>{const n=[],i=e.data,s=30,o=p=>p.vertical?"center":p.textAlign||"center",l=()=>{var w;const p=a.option;if(!p)return;const f=((w=p.variants)==null?void 0:w.find(S=>S.id===i.fontVariantId))||Ae(p);if(!f||!f.asset)return;t[a.stepName]={selectedVariants:[f]};const C=f.asset.fileLink;if(C)return C},d=await(async()=>{const p=l();if(!p)return;const f=await It(p);return{assetUrl:p,name:f.names.fullName.en}})(),A=(a.data.replaceableText?a.data.replaceableText.replace("{{}}",i.text):i.text)||"",u=Fe(A,{vertical:a.data.vertical,uppercase:a.data.uppercase}),h=async p=>{const f=p.colorOption;if(!f)return;const C=H.getDefaultVariant(f);return C==null?void 0:C.color},g=i.color||await h(a.data),m=a.data.regions;for(const p of m){const f=r.find(w=>w.panelId===p.panelId);if(!f)continue;const C={stepName:e.name,id:Q(),align:o(a.data),curved:a.data.curved,fill:i.color||g||"#000000",fontData:d,fontSize:a.data.size||s,height:p.height,layer:p.layer,layerIndex:p.layerIndex,paths:a.data.paths,rotation:p.rotation,text:u,type:M.Textbox,vertical:a.data.vertical,verticalAlign:a.data.verticalAlign||"middle",width:p.width,x:p.left,y:p.top};if(d){const[w,S]=Kt(a.data.size||s,d,p,[Fe(u,{vertical:a.data.vertical,uppercase:a.data.uppercase})],{size:a.data.size,minSize:a.data.minSize,maxSize:a.data.maxSize});n.push(new G({...C,fontSize:w,text:C.curved?C.text:(S||[]).join(`
2334
+ `)},f))}else n.push(new G(C,f))}return n},Hl=(r,t)=>r.conditions?r.conditions.every(e=>{const a=t[e.targetStepName];if(a&&a.selectedVariants){const n=a.selectedVariants;return e.requiredVariantSelections.some(i=>n.find(s=>s.id===i)!==void 0)}return!1}):!0,Nr=async(r,t,e,a)=>{const n=[],i={};for(const s of r){const o=t.steps.find(l=>l.stepName===s.name);if(o)switch(o.type){case I.DigitalContent:n.push(...await Ul(e,s,o));break;case I.Frame:case I.Photo:n.push(...await Ll(e,i,s,o));break;case I.Illustration:n.push(...await Vl(e,i,s,o));break;case I.Module:n.push(...await zl(e,s,o));break;case I.Picture:n.push(...await ql(e,i,s,o));break;case I.Shape:n.push(...await Gl(e,i,s,o));break;case I.Text:n.push(...await jl(e,i,s,o));break}}for(const s of t.steps)s.type!==I.SilentIllustration&&s.type!==I.ProductOverlay||Hl(s,i)&&n.push(...await Wl(e,s,a));return n};class Yl{constructor(t){this.handleCompleteRender=null;const e=new Map;t.forEach(a=>e.set(a.id,new _l(a.id,a.name,this,{width:a.width,height:a.height},this.getWorkflowManager.bind(this)))),this.layouts=e}setCompleteRenderCallback(t){this.handleCompleteRender=t,t(Array.from(this.layouts.values()))}onCompleteRender(){this.handleCompleteRender&&this.handleCompleteRender(Array.from(this.layouts.values()))}getAll(){return this.layouts}setWorkflowManager(t){this.workflowManager=t}getWorkflowManager(){return this.workflowManager}}const Jl=()=>new Promise((r,t)=>{try{const a=pt().getContext("webgl2");r(!!a)}catch{r(!1)}}),Kl=Jl();class _l{constructor(t,e,a,n,i){this.hasSetStaticContext=!1,this.interactiveDirty=!1,this.staticCtxDirty=!1,this.lastRequestedRenderArguments=void 0,this.lastCompletedStaticRender=void 0,this.renderQueue=new Fa(2),this.id=t,this.name=e,this.service=a,this.panelSize=n,this.getWorkflowManager=i}getID(){return this.id}getName(){return this.name}getPanelSize(){return this.panelSize}getStaticContext(){return this.textureCtx}setStaticContext(t){this.textureCtx=t,this.lastRequestedRenderArguments&&this.render(this.lastRequestedRenderArguments)}getStaticContextDirty(){return this.staticCtxDirty}setStaticContextDirty(t){this.staticCtxDirty=t}getInteractiveCanvasDirty(){return this.interactiveDirty}setInteractiveCanvasDirty(t){this.interactiveDirty=t}markLastCompletedStaticRender(){this.lastCompletedStaticRender=Date.now(),this.service.onCompleteRender()}getLastCompletedStaticRender(){return this.lastCompletedStaticRender}async render(t){const e=Et(t);this.lastRequestedRenderArguments=e;const a=this.getStaticContext();if(!a){this.markLastCompletedStaticRender(),this.setStaticContextDirty(!1);return}this.renderQueue.enqueue(new Xl(this.getID(),a,await Kl,()=>{this.markLastCompletedStaticRender(),this.setStaticContextDirty(!0)},e,this.getWorkflowManager))}}class Xl extends Pa{constructor(t,e,a,n,i,s){super(),this.layoutId=t,this.ctx=e,this.nonPOTSupport=a,this.onRender=n,this.layouts=i,this.getWorkflowManager=s}getDynamicTextureResolution(){return this.getIsMobile()||!this.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}getIsMobile(){return window.innerWidth<=480}offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}resizeFit(t,e=4096){const a=e/t.width,n=e/t.height,i=Math.min(a,n);return i>1?t:{width:t.width*i,height:t.height*i}}async execute(){var g,m;const t=this.layouts.find(p=>p.layoutState.layout.id===this.layoutId);if(!t)return;const e=t.layoutState.elements||[],a=t.layoutState.layout.width,n=t.layoutState.layout.height,i=a===1||n===1?{width:1,height:1}:this.getDynamicTextureResolution(),s=i.width,o=i.height;let l,c;if(this.nonPOTSupport){const p=s/o;a/n<p?(l=s,c=n*(s/a)):(l=a*(o/n),c=o);const C=this.resizeFit({width:l,height:c});l=C.width,c=C.height}else l=i.width,c=i.height;const d=await((m=(g=this.getWorkflowManager)==null?void 0:g.call(this))==null?void 0:m.getTemplatingContext()),A=ze(t.layoutState.layout,e,{renderingConfiguration:{purpose:Tt.ThreeD,templatingContext:d}}),u=Nn(A),h=await Sa.Pith.from(this.ctx,u,{anonymousCrossOrigin:!0,ignoreDimensions:!this.nonPOTSupport,ignoreAnimation:!0,ignoreClear:!0,ignoreMouse:!0,enableRedraw:!1,createCanvas:pt,createImage:oe,DOMParser:ba(),fetch});h.resize(l,c),await h.render(),this.onRender()}}const Zl=(r,t)=>{const e=[];return r.forEach(a=>{const n=t.steps.find(i=>i.stepName===a.stepName);(n==null?void 0:n.type)===I.Text&&a.stepAspectType==="Text"&&e.push({name:n.stepName,data:{text:a.value}})}),e},tc=async(r,t,e,a)=>{let n={serializableWorkflow:{steps:[]},layouts:{}};n=new $(e.map(l=>new Na(l))).apply(n);const s=await Nr(r,t,e,a);return new $(s).apply(n)};class ec{constructor(t){this.handleCache={},this.bundle=t}async getHandle(t){if(this.handleCache[t.name])return this.handleCache[t.name];const e=await this.createHandle(t);return this.handleCache[t.name]=e,e}async getHandles(){var e;if(!((e=this.bundle.getProductCollection())!=null&&e.getResource().globalPropertyConfiguration))return[];await this.bundle.getGlobalPropertyStateManager().getInitializationPromise();const t=this.bundle.getProductCollection().getResource().globalPropertyConfiguration;return Promise.all(t.aspects.map(a=>this.getHandle(a)))}applyConditionsFromState(t,e){return e?t.filter(a=>this.aspectConditionsSatisfied(a.getRawProperty(),e)):t}aspectConditionsSatisfied(t,e){return!t.conditions||t.conditions.length===0?!0:t.conditions.some(a=>{const n=e.aspects.find(i=>i.name===a.targetAspectName);return n?a.requiredVariantSelections.some(i=>i===n.value):!1})}async createHandle(t){switch(t.type){case V.FileUpload:return new Qr(this.bundle,t).initialize();case V.ColorOption:return new Ca(this.bundle,t,t.entityId?await H.getOption(t.entityId):void 0);case V.Option:{const e=t.entityId?await H.getOption(t.entityId):void 0;return(e==null?void 0:e.type)==="Color"?new Ca(this.bundle,t,e):new za(this.bundle,t,e)}case V.Text:return new Rr(this.bundle,t);default:throw new Error("Unhandled Global Property Aspect Type")}}}class qe{constructor(t,e){this.bundle=t,this.property=e}getName(){return this.property.name}getTitle(){return this.property.title}getDescription(){return this.property.description}getType(){return this.property.type}getRawProperty(){return this.property}isMandatory(){return!!this.property.mandatory}isMandatoryFulfilled(){return!this.property.mandatory||!!this.bundle.getGlobalPropertyStateManager().getAspectMandatoryFulfilled(this.property.name)}getSharedSteps(t){return(t??this.bundle.getWorkflowExperiences()).flatMap(n=>n.getStepsConditionallyActive().filter(i=>{var s;return i.getOverrideGlobalPropertyConfiguration(this.property.type)?!1:(s=i.getRaw().globalPropertyAspectConfigurations)==null?void 0:s.some(o=>{var l,c;return o.globalPropertyConfigurationId===((c=(l=this.bundle.getProductCollection())==null?void 0:l.getResource().globalPropertyConfiguration)==null?void 0:c.id)&&o.aspectName===this.property.name})}))}getStateValue(){return this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name)}}class Qr extends qe{constructor(t,e){super(t,e)}async initialize(){var t,e,a,n;return(e=(t=this.property.data)==null?void 0:t.fileUpload)!=null&&e.colorOptionId&&(this.colorOption=await H.getOption((n=(a=this.property.data)==null?void 0:a.fileUpload)==null?void 0:n.colorOptionId)),await this.loadImageData(),this}async loadImageData(){var e;const t=await this.getImage();if(t!=null&&t.fileLink)if(t!=null&&t.fileLink.endsWith(".svg")){const a=await tt(t==null?void 0:t.fileLink),n=await Ma(t==null?void 0:t.fileLink),i=n.width,s=n.height,o=await ot(a),l=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);(e=l==null?void 0:l.colors)==null||e.forEach(d=>{o.colors[d.key]={browserValue:d.browserValue,pmsValue:d.pmsValue}});const c={src:t==null?void 0:t.fileLink,width:i,height:s,aspect:i/s,svg:o.svg,colors:o.colors};dt.set(t==null?void 0:t.fileLink,c),this.imageData=c}else this.imageData=void 0}async selectImage(t){const e=this.bundle.getGlobalPropertyStateManager();await Promise.all([e.setAspect(this.property.name,t.key,{...e.getAspectStorage(this.property.name)||{},originalAssetKey:t.key,backgroundRemovedAssetKey:void 0,useOriginalAsset:void 0},void 0),this.applyImageSelection(t),this.loadImageData()])}async canUseBackgroundRemover(){return this.bundle.getClient().canUseAddon(Me.BackgroundRemover)}async removeBackgroundFromImage(t=!0){if(!await this.canUseBackgroundRemover())throw new Error("The current Integration does not have access to the Background Remover. Please call canUseBackgroundRemover to ensure you disable this feature when appropriate.");const e=await this.getOriginalImage();if(!e)throw new Error("You must supply an image selection before attempting to remove the background.");const a=this.bundle.getGlobalPropertyStateManager(),n=await U.removeBackgroundFromAsset(e),s={...a.getAspectStorage(this.property.name),backgroundRemovedAssetKey:n.key,useOriginalAsset:!t},l=[t?a.setAspect(this.property.name,n.key,s):a.setAspectStorage(this.property.name,s)];return t&&(l.push(this.applyImageSelection(n,void 0,!1,!1)),l.push(this.loadImageData())),await Promise.all(l),this.updateSharedStepStorage(s),n}hasImage(){return!!this.getStateValue()}async getImage(){const t=this.getStateValue();if(t)return U.getLocalOrFromServer(t)}async getImageWithColors(){var t,e;return await this.loadImageData(),(t=this.imageData)!=null&&t.svg?Oe(Ue(this.imageData.svg,this.imageData.colors??{},!1)):(e=this.imageData)==null?void 0:e.src}async getOriginalImage(){const t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(t!=null&&t.originalAssetKey)return U.getLocalOrFromServer(t.originalAssetKey)}async getBackgroundRemovedImage(){const t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(t!=null&&t.backgroundRemovedAssetKey)return U.getLocalOrFromServer(t.backgroundRemovedAssetKey)}getUseOriginalImage(){var t;return((t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name))==null?void 0:t.useOriginalAsset)??!1}async setUseOriginalImage(t){const e=await this.getOriginalImage();if(!e)throw new Error("You must select an image before calling setUseOriginalImage");const a=this.bundle.getGlobalPropertyStateManager(),n=a.getAspectStorage(this.property.name);if((n==null?void 0:n.useOriginalAsset)===t)return;const i={...n,useOriginalAsset:t},s=t?n==null?void 0:n.originalAssetKey:n==null?void 0:n.backgroundRemovedAssetKey,o=[a.setAspect(this.property.name,s||"",i)];if(t)o.push(this.applyImageSelection(e,void 0,!1,!1));else{const l=async()=>{const c=await this.getBackgroundRemovedImage();if(!c)throw new Error("You must call removeBackgroundFromImage before attempting to use that version of the image.");this.applyImageSelection(c,void 0,!1,!1)};o.push(l())}o.push(this.loadImageData()),await Promise.all(o),this.updateSharedStepStorage(i)}async applyGlobalState(t){const e=this.getStateValue();if(!e)return;const a=await U.getLocalOrFromServer(e);if(!a)return;await this.applyImageSelection(a,t,!1,!0);const n=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(n){if(this.updateSharedStepStorage({...n}),n.colors){const i=new Map(n.colors.map(s=>[s.key,{browserValue:s.browserValue,pmsValue:s.pmsValue}])??[]);this.getSharedSteps(t).forEach(s=>{s.changeColors(i)})}}else this.updateSharedStepStorage({originalAssetKey:e}),await this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{originalAssetKey:e})}getAvailableColors(){var t,e,a,n;return(e=(t=this.property.data)==null?void 0:t.fileUpload)!=null&&e.colorPickerEnabled?((n=(a=this.colorOption)==null?void 0:a.variants)==null?void 0:n.map(i=>({fill:i.color,stroke:i.color,variant:i,pmsValue:i.name})))??[]:[]}getCurrentColors(){var t;return(t=this.imageData)==null?void 0:t.colors}isColorPickerEnabled(){var t,e;return((e=(t=this.property.data)==null?void 0:t.fileUpload)==null?void 0:e.colorPickerEnabled)??!1}isPmsPickerEnabled(){var t,e;return((e=(t=this.property.data)==null?void 0:t.fileUpload)==null?void 0:e.pmsPickerEnabled)??!1}async getOriginalColors(){var e;return(e=this.imageData)!=null&&e.svg?(await ot(this.imageData.svg)).colors:void 0}async changeColors(t){var i;if(!((i=this.imageData)!=null&&i.svg))return;const e=this.getSharedSteps(),a=new Map(Object.entries(t));e.forEach(s=>{s.changeColors(a)});const n=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{...n,colors:Object.entries(t).map(([s,o])=>({key:s,browserValue:o.browserValue,pmsValue:o.pmsValue}))}),await this.loadImageData()])}async applyImageSelection(t,e,a=!0,n=!0){const s=this.getSharedSteps(e).map(o=>{const l=o;if(l.getFrameService())return l.selectImage(t,a,n)});await Promise.all(s)}updateSharedStepStorage(t){this.bundle.getWorkflowExperiences().forEach(a=>a.getSteps().forEach(n=>{var s;if(n.getOverrideGlobalPropertyConfiguration(this.property.type))return;((s=n.getRaw().globalPropertyAspectConfigurations)==null?void 0:s.some(o=>{var l,c;return o.globalPropertyConfigurationId===((c=(l=this.bundle.getProductCollection())==null?void 0:l.getResource().globalPropertyConfiguration)==null?void 0:c.id)&&o.aspectName===this.property.name}))&&a.getWorkflowManager().updateStorage(n.getId(),{framePatternData:{originalAssetKey:t.originalAssetKey,backgroundRemovedAssetKey:t.backgroundRemovedAssetKey,useOriginalAsset:t.useOriginalAsset}})}))}}class Rr extends qe{constructor(t,e){super(t,e)}isTemplatingEnabled(){var t,e;return((e=(t=this.property.data)==null?void 0:t.text)==null?void 0:e.templatingEnabled)||!1}getText(){const t=this.getStateValue();return t||""}async setText(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t,void 0,void 0),this.applyTextSelection(t)])}async applyGlobalState(t){const e=this.getStateValue();if(!e)return Promise.resolve();await this.applyTextSelection(e,t)}async applyTextSelection(t,e){const n=this.getSharedSteps(e).map(i=>{i.setText(t)});await Promise.all(n)}}class za extends qe{constructor(t,e,a){super(t,e),this.optionResource=a}async initDefaultVariant(){var e,a;const t=(a=(e=this.optionResource)==null?void 0:e.variants)==null?void 0:a.find(n=>{var i,s;return n.id===((s=(i=this.optionResource)==null?void 0:i.defaultVariant)==null?void 0:s.id)});t&&await this.selectVariant(new it(t))}getCurrentVariant(){var e,a;if(!this.optionResource)return;const t=this.getStateValue();if(t){const n=(a=this.optionResource.variants)==null?void 0:a.find(i=>i.id===t);return n?new it(n):void 0}else{const n=(e=this.optionResource.variants)==null?void 0:e.find(i=>{var s,o;return i.id===((o=(s=this.optionResource)==null?void 0:s.defaultVariant)==null?void 0:o.id)});return n?new it(n):void 0}}getAvailableVariants(){var e,a;return(((a=(e=this.optionResource)==null?void 0:e.variants)==null?void 0:a.filter(n=>n.enabled))||[]).map(n=>new it(n))}getAllVariants(){var e;return(((e=this.optionResource)==null?void 0:e.variants)||[]).map(a=>new it(a))}async selectVariant(t,e){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId(),void 0,e),this.applyVariantSelection(t)])}async applyGlobalState(t){var n,i;const e=this.getStateValue();if(!e)return Promise.resolve();const a=(i=(n=this.optionResource)==null?void 0:n.variants)==null?void 0:i.find(s=>s.id===e);return a?this.applyVariantSelection(new it(a),t):Promise.resolve()}async applyVariantSelection(t,e){const n=this.getSharedSteps(e).map(i=>i.selectVariant(t));await Promise.all(n)}}class Ca extends za{constructor(t,e,a){super(t,e,a)}async selectVariant(t,e){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId(),void 0,e),this.applyColorVariant(t,void 0,e)])}async applyGlobalState(t){var i,s,o;const e=this.getStateValue();if(!e)return Promise.resolve();const a=(s=(i=this.optionResource)==null?void 0:i.variants)==null?void 0:s.find(l=>l.id===e);if(!a)return Promise.resolve();await this.applyColorVariant(new it(a),t);const n=(o=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name))==null?void 0:o.customColor;n&&this.setCustomColor(n)}async applyColorVariant(t,e,a){const i=this.getSharedSteps(e).map(s=>{switch(s.getType()){case I.Shape:return s.selectVariant(t);case I.Text:return s.setFillColor({fill:t.getColor(),stroke:t.getColor(),variant:t.getResource()});case I.Illustration:return s.setColor((a==null?void 0:a.toString())||"",t.getColor()||"")}});await Promise.all(i)}setCustomColor(t){this.getSharedSteps().forEach(a=>a.setCustomColor(t)),this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{customColor:t})}getCustomColor(){var t,e;return((t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name))==null?void 0:t.customColor)||((e=this.getCurrentVariant())==null?void 0:e.getColor())||"#ffffff"}}const ac=(r,t,e,a)=>r.flatMap(n=>n.getSteps()).filter(n=>n.getGlobalPropertyAspects(t).includes(e)&&n.getType()===a),nc=(r,t,e)=>{const n=ac(r,t,e,I.Illustration).map(i=>{var l;const s=(l=i.getCurrentVariant())==null?void 0:l.getAssetResource(),o=i.getColors();return!(s!=null&&s.assetConfiguration)||!o?0:Object.getOwnPropertyNames(o).length});return Math.max(...n)};function Or(r){var e;const t=new Map;return(e=r==null?void 0:r.aspects)==null||e.forEach(a=>{a.value!==""&&t.set(a.name,!0)}),t}class rc{constructor(t,e,a,n,i){this.mandatoryFulfilledAspects=new Map,this.bundleId=t,this.bundleOwnerId=e,this.configuration=a,this.bundleOptions=i;const s=i==null?void 0:i.existingGlobalPropertyState;this.initPromise=s?Promise.resolve(s).then(()=>{console.log("Setting global property state to existing state."),this.globalPropertyState=s,this.recalculateMandatoryStates()}):this.createGlobalPropertyState().then(o=>{console.log("Setting global property state to new state."),this.globalPropertyState=o,this.recalculateMandatoryStates()}),this.onGlobalPropertyStateChange=n}recalculateMandatoryStates(){this.mandatoryFulfilledAspects=Or(this.globalPropertyState)}setBundleOptions(t){this.bundleOptions=t}getBundleOptions(){return this.bundleOptions}setConfiguration(t){this.configuration=t}getInitializationPromise(){return this.initPromise}getGlobalPropertyState(){return this.globalPropertyState}async setGlobalPropertyState(t){this.globalPropertyState||await this.initPromise;const e=Et(this.globalPropertyState);this.globalPropertyState={...t,id:e.id},this.recalculateMandatoryStates(),await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(e,this.globalPropertyState)}getAspectMandatoryFulfilled(t){return this.mandatoryFulfilledAspects.get(t)}getAspect(t,e){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const a=this.globalPropertyState.aspects.find(n=>n.name===t&&n.channel===e);if(a)return a.value}getAspectStorage(t,e){var a;if(!this.globalPropertyState)throw new Error("Global property state not initialized");return(a=this.globalPropertyState.aspects.find(n=>n.name===t&&n.channel===e))==null?void 0:a.storage}async setAspect(t,e,a,n){if(!this.globalPropertyState)throw new Error("Global property state not initialized");if(!this.configuration)throw new Error("Global property configuration not linked to the state manager.");const i=this.configuration.aspects.find(l=>l.name===t);if(!i)throw new Error(`Failed to find configuration aspect with name: ${t}`);this.mandatoryFulfilledAspects.set(t,e!=="");const s=Et(this.globalPropertyState),o=this.globalPropertyState.aspects.filter(l=>l.name===t);if(o.length>0)if(n){const l=o.find(c=>c.channel===n);if(l)l.value=e,l.type=i.type,l.channel=n,a!==void 0&&(l.storage=a!==null?a:void 0);else{if(n===1){const c=this.globalPropertyState.aspects.findIndex(d=>!d.channel&&d.name===t);c&&c>0&&this.globalPropertyState.aspects.splice(c,1)}this.globalPropertyState.aspects.push({name:t,value:e,type:i.type,storage:a!==null?a:void 0,channel:n})}}else{const l=o[0];l.value=e,l.type=i.type,a!==void 0&&(l.storage=a!==null?a:void 0)}else this.globalPropertyState.aspects.push({name:t,value:e,type:i.type,storage:a!==null?a:void 0,channel:n});await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(s,this.globalPropertyState)}async setAspectStorage(t,e,a){if(!this.globalPropertyState)throw new Error("Global property state not initialized");if(!this.configuration)throw new Error("Global property configuration not linked to the state manager.");const n=this.configuration.aspects.find(o=>o.name===t);if(!n)throw new Error(`Failed to find configuration aspect with name: ${t}`);const i=Et(this.globalPropertyState),s=this.globalPropertyState.aspects.filter(o=>o.name===t);if(s.length>0)if(a){const o=s.find(l=>l.channel===a);o&&(o.storage=e!==null?e:void 0,o.type=n.type)}else{const o=s[0];o.storage=e!==null?e:void 0,o.type=n.type}else this.globalPropertyState.aspects.push({name:t,value:"",type:n.type,storage:e!==null?e:void 0,channel:a});await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(i,this.globalPropertyState)}async updateGlobalPropertyState(){var e,a;if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await B.getShadowGraphqlClient().mutate({mutation:Ho,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects.map(n=>{let i=n.type&&n.storage?{}:void 0;if(i)switch(n.type){case V.FileUpload:{i.fileUpload=n.storage;break}case V.Option:{i.option=n.storage;break}case V.ColorOption:{i=n.storage;break}}return{name:n.name,value:n.value,type:n.type,storage:i,channel:n.channel}})},context:{headers:{bundleOwnerId:this.bundleOwnerId,...(e=this.bundleOptions)==null?void 0:e.additionalHeaders}}});if((a=t.data)!=null&&a.globalPropertyStateUpdate)this.globalPropertyState=t.data.globalPropertyStateUpdate;else throw new Error("Unable to update global property state")}async createGlobalPropertyState(){var e,a;const t=await B.getShadowGraphqlClient().mutate({mutation:jo,variables:{bundleId:this.bundleId},context:{headers:{bundleOwnerId:this.bundleOwnerId,...(e=this.bundleOptions)==null?void 0:e.additionalHeaders}}});if((a=t.data)!=null&&a.globalPropertyStateCreate&&t.data.globalPropertyStateCreate.id)return t.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}class ic{constructor(t){this.setState(t)}setState(t){t&&(this.state=JSON.parse(t))}applyStateToWorkflowExperience(t){var s;if(!this.state||!((s=t==null?void 0:t.getWorkflowManager())!=null&&s.getModelContainer()))return;const e=this.state.transactions.find(o=>o.transactionId===t.getWorkflowManager().getTransaction().id);if(!e)return;const a=this.getTransformToApply(e);if(!a)return;const n=this.flipTransform(a,t.getWorkflowManager().getPreviewService()),i=t.getWorkflowManager().getModelContainer();i.position=n.position,i.rotation=n.rotation,i.scale=n.scale}getTransformToApply(t){return t.activeTransform&&t.transforms?t.transforms[t.activeTransform]:t.transform}updateWorkflowExperienceTransform(t,e,a){const n=t.getWorkflowManager().getTransaction().id;this.state?this.state.transactions||(this.state.transactions=[]):this.state={transactions:[]};const i=this.state.transactions.find(s=>s.transactionId===n);i?(i.transforms||(i.transforms={}),i.transforms[e]=a):this.state.transactions.push({transactionId:n,activeTransform:e,transforms:{[e]:a}})}activateWorkflowExperienceTransform(t,e){var l,c;if(!((l=t==null?void 0:t.getWorkflowManager())!=null&&l.getModelContainer())||!this.state)return;const a=t.getWorkflowManager().getTransaction().id,n=this.state.transactions.find(d=>d.transactionId===a),i=(c=n==null?void 0:n.transforms)==null?void 0:c[e];if(!i)return;const s=this.flipTransform(i,t.getWorkflowManager().getPreviewService()),o=t.getWorkflowManager().getModelContainer();o.position=s.position,o.rotation=s.rotation,o.scale=s.scale,n.activeTransform=e}removeStateForTransaction(t){if(!this.state||!this.state.transactions)return;const e=this.state.transactions.findIndex(a=>a.transactionId===t);e!==-1&&this.state.transactions.splice(e,1)}getSerializedState(){if(this.state)return this.deleteFieldNameFromObjectRecursive(this.state,"__typename"),JSON.stringify(this.state)}deleteFieldNameFromObjectRecursive(t,e){if(!(typeof t!="object"||t===null))for(const a in t)a===e?delete t[a]:this.deleteFieldNameFromObjectRecursive(t[a],e)}flipTransform(t,e){return e&&e.flipTransform?e.flipTransform(t.position,{x:t.rotation.x*Math.PI/180,y:t.rotation.y*Math.PI/180,z:t.rotation.z*Math.PI/180},t.scale):{position:t.position,rotation:{x:t.rotation.x*Math.PI/180,y:t.rotation.y*Math.PI/180,z:t.rotation.z*Math.PI/180},scale:t.scale}}}const sc=v.gql`
2283
2335
  query GetManyMetafields($entityIds: [String!]!) {
2284
2336
  metafieldsMany(entityIds: $entityIds) {
2285
2337
  id
@@ -2290,14 +2342,14 @@
2290
2342
  }
2291
2343
  }
2292
2344
  }
2293
- `;class sc{constructor(){this.internalMap=new Map}async requestKeysForEntity(t,e){const a=new Map;return await this.ensureIdsArePresent([t]),e.forEach(n=>{const i=this.requestKeyForEntityIfAvailable(t,n);i&&a.set(n,i)}),a}async ensureIdsArePresent(t){if(t.every(a=>this.internalMap.has(a)))return;const e=await B.getShadowGraphqlClient().query({query:ic,errorPolicy:"all",variables:{entityIds:t.filter(a=>!this.internalMap.has(a))}});t.forEach((a,n)=>{const i=e.data.metafieldsMany[n];this.internalMap.set(a,i.map(s=>({key:s.metafieldConfiguration.name,value:s.value})))})}async requestKeyForEntity(t,e){if(!this.internalMap.has(t))return;let a=this.internalMap.get(t);const n=a.find(i=>i.key===e);return n||(await this.ensureIdsArePresent([t]),a=this.internalMap.get(t)),n?JSON.parse(n.value):void 0}requestKeyForEntityIfAvailable(t,e){if(!this.internalMap.has(t))return;const n=this.internalMap.get(t).find(i=>i.key===e);if(n)return JSON.parse(n.value)}}const Or=new sc;var $r=(r=>(r.Default="Default",r.Name="Name",r.Price="Price",r))($r||{});class Ga{constructor(t){this.fullFetched=!1,this.collection=t;const e=this.collection.productCollectionProducts;e&&e.length>0&&(this.fullFetched=!0)}getId(){return this.collection.id}getName(){return this.collection.name}getDescription(){return this.collection.description||""}getDispatchStartDate(){if(this.collection.dispatchStartDate)return new Date(this.collection.dispatchStartDate)}getDispatchEndDate(){if(this.collection.dispatchEndDate)return new Date(this.collection.dispatchEndDate)}getImage(){return this.collection.image}getProducts(){if(!this.collection.productCollectionProducts)throw new Error("Failed to find products on collection. Ensure you fetch them first!");return this.collection.productCollectionProducts.filter(t=>!!t.product).map(t=>new Ht(t))}async fetchProducts(t){if(this.fullFetched)return this.collection.productCollectionProducts.filter(a=>!!a.product).map(a=>new Ht(a));const e=await B.getShadowGraphqlClient().query({query:Xo,variables:{id:this.getId(),productIds:t},errorPolicy:"all"});return t||(this.fullFetched=!0),this.collection.productCollectionProducts=e.data.productCollections[0].productCollectionProducts||[],this.collection.productCollectionProducts.filter(a=>!!a.product).map(a=>new Ht(a))}async filterProducts(t,e,a,n){var l,c;const i=await B.getShadowGraphqlClient().query({query:Zo,errorPolicy:"all",variables:{id:this.getId(),filters:t?{link:"And",metafields:t}:void 0,tags:e?{include:e.include??[],exclude:e.exclude??[]}:void 0,sortKey:a,sortDescending:n}});if(!((l=i.data)!=null&&l.productCollections)||((c=i.data)==null?void 0:c.productCollections.length)===0)throw new Error("Failed to filter product collection products.");const s=this.getProducts(),o=i.data.productCollections[0].productCollectionProducts.map(d=>d.product.id);return s.filter(d=>o.includes(d.getId()))}async fetchProductsFeed(t,e,a,n,i,s){if(this.fullFetched){const d=await(a?this.filterProducts(a):this.fetchProducts());return{total:d.length,items:d.slice(t,t+e)}}const o=new AbortController,{signal:l}=o,c=B.getShadowGraphqlClient().watchQuery({query:tl,variables:{id:this.getId(),limit:e,offset:t,filters:a?{link:"And",metafields:a}:void 0,tags:n?{include:n.include??[],exclude:n.exclude??[]}:void 0,sortKey:i,sortDescending:s},errorPolicy:"all",fetchPolicy:"cache-first",returnPartialData:!0,context:{fetchOptions:{signal:l}}});return new Promise(d=>{let A=!1;const u=c.subscribe({next(h){var m,p,f,C,w,S;if(A||h.partial&&(!h.data.productCollections||h.data.productCollections.length===0||!((m=h.data.productCollections[0].productCollectionProductsFeed)!=null&&m.items)||((p=h.data.productCollections[0].productCollectionProductsFeed)==null?void 0:p.items.length)===0))return;o.abort(),A=!0,u.unsubscribe();const g=((C=(f=h.data.productCollections)==null?void 0:f[0].productCollectionProductsFeed)==null?void 0:C.items.filter(y=>!!y.product).map(y=>new Ht(Et(y))))||[];d({items:g,total:((S=(w=h.data.productCollections)==null?void 0:w[0].productCollectionProductsFeed)==null?void 0:S.total)??0})},error(){A||(A=!0,u.unsubscribe(),d({items:[],total:0}))}})})}getTransformCollection(){if(this.collection.transformCollection)return new Ur(this.collection.transformCollection)}getResource(){return this.collection}}class Ht{constructor(t){this.product=t.product,this.productResource=t}getId(){return this.product.id}getName(){return this.product.name}getIntegrationByType(t,e){const n=(this.product.integrationProducts||[]).find(i=>{var c,d,A;const s=(c=i.integration)==null?void 0:c.type,o=((d=i.integration)==null?void 0:d.type)===t,l=e?((A=i.integration)==null?void 0:A.externalIntegrationId)===e:!0;return s&&o&&l});if(!n)throw new Error("Failed to find requested integration type on product. This is generally due to a configuration error");return n}getCurrentIntegration(){const e=(this.product.integrationProducts||[]).find(a=>{var n;return(n=a.integration)==null?void 0:n.isCurrent});if(!e)throw new Error(`Product: ${this.productResource.id} is not linked to this current integration. This is generally due to a configuration error.`);return e}getDefaultWorkflow(){const t=this.product.workflows;if(t===void 0)throw new ht("Called getDefaultWorkflow() before fetching collection products. Use collection.fetchProducts() first to ensure the data is available.");if(t.length===0)throw new ht("Called getDefaultWorkflow() but no workflows on requested product. Ensure at least 1 workflow is assigned to this product.");const e=this.productResource.workflowId;if(e){const a=t.find(n=>n.workflowName===e);if(a)return new Mt(a)}if(t.length===1)return console.warn("Called getDefaultWorkflow() but no default was configured. There is only one workflow available so we will fall back to using this!"),new Mt(t[0]);throw new ht("Called getDefaultWorkflow() but no default workflow is configured for the requested product. Multiple workflows exist so we can't assume!")}getAllWorkflows(){if((this.product.workflows||[]).length===0)throw new ht("No workflows on configured product. Ensure at least 1 workflow is assigned to this product.");return this.product.workflows.sort((e,a)=>(e.index??0)-(a.index??0)).map(e=>new Mt(e))}getIntegrations(){return this.product.integrationProducts||[]}getResource(){return this.product}getBasePrice(t){var n,i,s,o;const e=this.product.basePrice||0;if(!t)return e;if(!t.integrationType&&!t.externalId&&!t.integrationId)throw new Error("You must provide at least one of the following fields on the includeAdditionalProduct object: integrationType, externalId, integrationId");let a;return t.integrationId?a=(n=this.product.integrationProducts)==null?void 0:n.find(l=>{var c;return((c=l.integration)==null?void 0:c.id)===t.integrationId}):t.externalId?a=(i=this.product.integrationProducts)==null?void 0:i.find(l=>{var c;return((c=l.integration)==null?void 0:c.externalIntegrationId)===t.externalId}):a=(s=this.product.integrationProducts)==null?void 0:s.find(l=>{var c;return((c=l.integration)==null?void 0:c.type)===t.integrationType}),(o=a==null?void 0:a.additionalIntegrationProduct)!=null&&o.product?e+(a.additionalIntegrationProduct.product.basePrice||0):e}async requestMetafields(t){return Or.requestKeysForEntity(this.product.id,t)}}class Mt{constructor(t){this.workflow=t}getId(){return this.workflow.workflowName}getName(){return this.workflow.friendlyName}getThumbnail(){return this.workflow.imageUrl}}class Ur{constructor(t){this.collection=t}getId(){return this.collection.id}getName(){return this.collection.name}getTransforms(){return this.collection.transforms.map(t=>new Lr(t))}}class Lr{constructor(t){this.transform=t}getId(){return this.transform.id}getName(){return this.transform.name}get(){return{position:this.transform.position,rotation:this.transform.rotation,scale:this.transform.scale}}}const oc=v.gql`
2345
+ `;class oc{constructor(){this.internalMap=new Map}async requestKeysForEntity(t,e){const a=new Map;return await this.ensureIdsArePresent([t]),e.forEach(n=>{const i=this.requestKeyForEntityIfAvailable(t,n);i&&a.set(n,i)}),a}async ensureIdsArePresent(t){if(t.every(a=>this.internalMap.has(a)))return;const e=await B.getShadowGraphqlClient().query({query:sc,errorPolicy:"all",variables:{entityIds:t.filter(a=>!this.internalMap.has(a))}});t.forEach((a,n)=>{const i=e.data.metafieldsMany[n];this.internalMap.set(a,i.map(s=>({key:s.metafieldConfiguration.name,value:s.value})))})}async requestKeyForEntity(t,e){if(!this.internalMap.has(t))return;let a=this.internalMap.get(t);const n=a.find(i=>i.key===e);return n||(await this.ensureIdsArePresent([t]),a=this.internalMap.get(t)),n?JSON.parse(n.value):void 0}requestKeyForEntityIfAvailable(t,e){if(!this.internalMap.has(t))return;const n=this.internalMap.get(t).find(i=>i.key===e);if(n)return JSON.parse(n.value)}}const $r=new oc;var Ur=(r=>(r.Default="Default",r.Name="Name",r.Price="Price",r))(Ur||{});class qa{constructor(t){this.fullFetched=!1,this.collection=t;const e=this.collection.productCollectionProducts;e&&e.length>0&&(this.fullFetched=!0)}getId(){return this.collection.id}getName(){return this.collection.name}getDescription(){return this.collection.description||""}getDispatchStartDate(){if(this.collection.dispatchStartDate)return new Date(this.collection.dispatchStartDate)}getDispatchEndDate(){if(this.collection.dispatchEndDate)return new Date(this.collection.dispatchEndDate)}getImage(){return this.collection.image}getProducts(){if(!this.collection.productCollectionProducts)throw new Error("Failed to find products on collection. Ensure you fetch them first!");return this.collection.productCollectionProducts.filter(t=>!!t.product).map(t=>new Ht(t))}async fetchProducts(t){if(this.fullFetched)return this.collection.productCollectionProducts.filter(a=>!!a.product).map(a=>new Ht(a));const e=await B.getShadowGraphqlClient().query({query:Zo,variables:{id:this.getId(),productIds:t},errorPolicy:"all"});return t||(this.fullFetched=!0),this.collection.productCollectionProducts=e.data.productCollections[0].productCollectionProducts||[],this.collection.productCollectionProducts.filter(a=>!!a.product).map(a=>new Ht(a))}async filterProducts(t,e,a,n){var l,c;const i=await B.getShadowGraphqlClient().query({query:tl,errorPolicy:"all",variables:{id:this.getId(),filters:t?{link:"And",metafields:t}:void 0,tags:e?{include:e.include??[],exclude:e.exclude??[]}:void 0,sortKey:a,sortDescending:n}});if(!((l=i.data)!=null&&l.productCollections)||((c=i.data)==null?void 0:c.productCollections.length)===0)throw new Error("Failed to filter product collection products.");const s=this.getProducts(),o=i.data.productCollections[0].productCollectionProducts.map(d=>d.product.id);return s.filter(d=>o.includes(d.getId()))}async fetchProductsFeed(t,e,a,n,i,s){if(this.fullFetched){const d=await(a?this.filterProducts(a):this.fetchProducts());return{total:d.length,items:d.slice(t,t+e)}}const o=new AbortController,{signal:l}=o,c=B.getShadowGraphqlClient().watchQuery({query:el,variables:{id:this.getId(),limit:e,offset:t,filters:a?{link:"And",metafields:a}:void 0,tags:n?{include:n.include??[],exclude:n.exclude??[]}:void 0,sortKey:i,sortDescending:s},errorPolicy:"all",fetchPolicy:"cache-first",returnPartialData:!0,context:{fetchOptions:{signal:l}}});return new Promise(d=>{let A=!1;const u=c.subscribe({next(h){var m,p,f,C,w,S;if(A||h.partial&&(!h.data.productCollections||h.data.productCollections.length===0||!((m=h.data.productCollections[0].productCollectionProductsFeed)!=null&&m.items)||((p=h.data.productCollections[0].productCollectionProductsFeed)==null?void 0:p.items.length)===0))return;o.abort(),A=!0,u.unsubscribe();const g=((C=(f=h.data.productCollections)==null?void 0:f[0].productCollectionProductsFeed)==null?void 0:C.items.filter(y=>!!y.product).map(y=>new Ht(Et(y))))||[];d({items:g,total:((S=(w=h.data.productCollections)==null?void 0:w[0].productCollectionProductsFeed)==null?void 0:S.total)??0})},error(){A||(A=!0,u.unsubscribe(),d({items:[],total:0}))}})})}getTransformCollection(){if(this.collection.transformCollection)return new Lr(this.collection.transformCollection)}getResource(){return this.collection}}class Ht{constructor(t){this.product=t.product,this.productResource=t}getId(){return this.product.id}getName(){return this.product.name}getIntegrationByType(t,e){const n=(this.product.integrationProducts||[]).find(i=>{var c,d,A;const s=(c=i.integration)==null?void 0:c.type,o=((d=i.integration)==null?void 0:d.type)===t,l=e?((A=i.integration)==null?void 0:A.externalIntegrationId)===e:!0;return s&&o&&l});if(!n)throw new Error("Failed to find requested integration type on product. This is generally due to a configuration error");return n}getCurrentIntegration(){const e=(this.product.integrationProducts||[]).find(a=>{var n;return(n=a.integration)==null?void 0:n.isCurrent});if(!e)throw new Error(`Product: ${this.productResource.id} is not linked to this current integration. This is generally due to a configuration error.`);return e}getDefaultWorkflow(){const t=this.product.workflows;if(t===void 0)throw new ht("Called getDefaultWorkflow() before fetching collection products. Use collection.fetchProducts() first to ensure the data is available.");if(t.length===0)throw new ht("Called getDefaultWorkflow() but no workflows on requested product. Ensure at least 1 workflow is assigned to this product.");const e=this.productResource.workflowId;if(e){const a=t.find(n=>n.workflowName===e);if(a)return new Mt(a)}if(t.length===1)return console.warn("Called getDefaultWorkflow() but no default was configured. There is only one workflow available so we will fall back to using this!"),new Mt(t[0]);throw new ht("Called getDefaultWorkflow() but no default workflow is configured for the requested product. Multiple workflows exist so we can't assume!")}getAllWorkflows(){if((this.product.workflows||[]).length===0)throw new ht("No workflows on configured product. Ensure at least 1 workflow is assigned to this product.");return this.product.workflows.sort((e,a)=>(e.index??0)-(a.index??0)).map(e=>new Mt(e))}getIntegrations(){return this.product.integrationProducts||[]}getResource(){return this.product}getBasePrice(t){var n,i,s,o;const e=this.product.basePrice||0;if(!t)return e;if(!t.integrationType&&!t.externalId&&!t.integrationId)throw new Error("You must provide at least one of the following fields on the includeAdditionalProduct object: integrationType, externalId, integrationId");let a;return t.integrationId?a=(n=this.product.integrationProducts)==null?void 0:n.find(l=>{var c;return((c=l.integration)==null?void 0:c.id)===t.integrationId}):t.externalId?a=(i=this.product.integrationProducts)==null?void 0:i.find(l=>{var c;return((c=l.integration)==null?void 0:c.externalIntegrationId)===t.externalId}):a=(s=this.product.integrationProducts)==null?void 0:s.find(l=>{var c;return((c=l.integration)==null?void 0:c.type)===t.integrationType}),(o=a==null?void 0:a.additionalIntegrationProduct)!=null&&o.product?e+(a.additionalIntegrationProduct.product.basePrice||0):e}async requestMetafields(t){return $r.requestKeysForEntity(this.product.id,t)}}class Mt{constructor(t){this.workflow=t}getId(){return this.workflow.workflowName}getName(){return this.workflow.friendlyName}getThumbnail(){return this.workflow.imageUrl}}class Lr{constructor(t){this.collection=t}getId(){return this.collection.id}getName(){return this.collection.name}getTransforms(){return this.collection.transforms.map(t=>new Vr(t))}}class Vr{constructor(t){this.transform=t}getId(){return this.transform.id}getName(){return this.transform.name}get(){return{position:this.transform.position,rotation:this.transform.rotation,scale:this.transform.scale}}}const lc=v.gql`
2294
2346
  ${ge(!1)}
2295
2347
  query GetProductCollections($ids: [String!]!) {
2296
2348
  productCollections(ids: $ids) {
2297
2349
  ...ProductCollectionFields
2298
2350
  }
2299
2351
  }
2300
- `,lc=async r=>{var e,a;return(a=(e=(await B.getShadowGraphqlClient().query({query:oc,errorPolicy:"all",variables:{ids:r}})).data)==null?void 0:e.productCollections)==null?void 0:a.map(n=>new Ga(n))};class cc{constructor(){this.listeners={}}on(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)}off(t,e){this.listeners[t]&&(this.listeners[t]=this.listeners[t].filter(a=>a!==e))}emit(t,e){if(this.listeners[t])for(const a of this.listeners[t])a(e)}clear(t){if(t)delete this.listeners[t];else for(const e in this.listeners)delete this.listeners[e]}}const dc=v.gql`
2352
+ `,cc=async r=>{var e,a;return(a=(e=(await B.getShadowGraphqlClient().query({query:lc,errorPolicy:"all",variables:{ids:r}})).data)==null?void 0:e.productCollections)==null?void 0:a.map(n=>new qa(n))};class dc{constructor(){this.listeners={}}on(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)}off(t,e){this.listeners[t]&&(this.listeners[t]=this.listeners[t].filter(a=>a!==e))}emit(t,e){if(this.listeners[t])for(const a of this.listeners[t])a(e)}clear(t){if(t)delete this.listeners[t];else for(const e in this.listeners)delete this.listeners[e]}}const Ac=v.gql`
2301
2353
  mutation AddAddressToBundle(
2302
2354
  $bundleId: String!
2303
2355
  $streetAddress: String
@@ -2319,26 +2371,26 @@
2319
2371
  id
2320
2372
  }
2321
2373
  }
2322
- `,Ac=v.gql`
2374
+ `,uc=v.gql`
2323
2375
  mutation AddOrganizationToBundle($bundleId: String!, $organizationName: String!) {
2324
2376
  organizationAttachToBundle(bundleId: $bundleId, organizationName: $organizationName) {
2325
2377
  id
2326
2378
  }
2327
2379
  }
2328
- `,uc=v.gql`
2380
+ `,hc=v.gql`
2329
2381
  mutation GenerateQuoteId($id: String!) {
2330
2382
  bundleGenerateQuoteId(id: $id) {
2331
2383
  id
2332
2384
  quoteId
2333
2385
  }
2334
2386
  }
2335
- `;class ea{constructor(t,e,a,n,i,s){var c,d,A;this.workflowExperiences=[],this.eventEmitter=new cc,this.client=t,this.id=e.id,this.name=e.name||"",this.dispatchDate=e.dispatchDate,this.template=e.template||!1,this.quoteId=e.quoteId,this.shareActions=e.bundleShareActions,this.workflowViewerLink=e.workflowViewerLink,this.workflowViewerAmendLink=e.workflowViewerAmendLink,this.ownerId=i,this.metadata=new Map(((c=e.metadata)==null?void 0:c.map(u=>[u.key,u.value]))||[]),this.completed=e.completed??!1,this.productCollection=e.productCollection,this.bundleStateManager=new rc(e.bundleStateData);const o=(d=this.productCollection)==null?void 0:d.globalPropertyConfiguration;this.globalConfigurationPropertyId=o==null?void 0:o.id,this.globalPropertyStateManager=new nc(this.id,this.ownerId,o,this.onGlobalPropertiesChanged.bind(this),s),this.globalPropertyHandleService=new tc(this),this.setPreviewService(a);const l=new Promise((u,h)=>{if(s!=null&&s.readonly){u([]);return}console.log("Setting default global variants.");const g=this.globalPropertyStateManager.getGlobalPropertyState();g?this.globalPropertyHandleService.getHandles().then(m=>{const p=m.map(f=>{if(f.getType()===V.ColorOption||f.getType()===V.Option){const C=f;if(!g.aspects.find(S=>S.name===C.getName()))return C.initDefaultVariant()}});Promise.all(p).then(u).catch(h)}):(console.log("Attempted to set global default variant before state was initialized."),u([]))});this.initializationPromise=Promise.all([this.loadExistingWorkflowExperiences(((A=e.transactions)==null?void 0:A.map(u=>u.id))||[],{...n,bundleOwnerId:i}),this.globalPropertyStateManager.getInitializationPromise()]).then(()=>l),this.initializationPromise.catch(u=>{console.error(`Bundle initialization failed: ${u}`)}),this.initializationPromise.then(()=>{this.getGlobalProperties().then(u=>this.checkMandatoryHandlesChanged(void 0,u))})}getTemplate(){return this.template}async generateQuoteId(){var a,n;const e=(n=(a=(await B.getShadowGraphqlClient().mutate({mutation:uc,variables:{id:this.id},context:{bundleOwnerId:this.ownerId}})).data)==null?void 0:a.bundleGenerateQuoteId)==null?void 0:n.quoteId;return this.quoteId=e,e||""}async attachAddress(t,e,a,n,i,s){await B.getShadowGraphqlClient().mutate({mutation:dc,variables:{bundleId:this.id,streetAddress:t||void 0,apartment:e||void 0,city:a||void 0,country:n||void 0,state:i||void 0,postCode:s||void 0},context:{bundleOwnerId:this.ownerId}})}async attachOrganization(t){await B.getShadowGraphqlClient().mutate({mutation:Ac,variables:{bundleId:this.id,organizationName:t},context:{bundleOwnerId:this.ownerId}})}setBundleOptions(t){this.globalPropertyStateManager.setBundleOptions(t)}getInitializationPromise(){return this.initializationPromise}addEventListener(t,e){this.eventEmitter.on(t,e)}removeEventListener(t,e){this.eventEmitter.off(t,e)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}getQuoteId(){return this.quoteId}setName(t){return this.name=t,this.updateBundle()}getDispatchDate(){return this.dispatchDate}setDispatchDate(t){return this.dispatchDate=t,this.updateBundle()}getPurchaseOrder(){return this.purchaseOrder}setPurchaseOrder(t){return this.purchaseOrder=t,this.updateBundle()}getMetadata(){return new Map(this.metadata)}setMetadata(t){return this.metadata=new Map(t),this.updateBundle()}setNameAndMetadata(t,e){return this.name=t,this.metadata=new Map(e),this.updateBundle()}hasGlobalProperties(){var t;return!!((t=this.productCollection)!=null&&t.globalPropertyConfiguration)}getGlobalPropertyConfiguration(){var t;return(t=this.productCollection)==null?void 0:t.globalPropertyConfiguration}async getGlobalProperties(){return this.globalPropertyHandleService.applyConditionsFromState(await this.globalPropertyHandleService.getHandles(),this.getGlobalPropertyStateManager().getGlobalPropertyState())}async applyGlobalPropertyState(t){var a;const e=await this.globalPropertyHandleService.getHandles();for(const n of t.aspects){const i=n==null?void 0:n.name;this.getGlobalPropertyStateManager().setAspect(i,n.value)}for(const n of t.aspects){const i=n==null?void 0:n.name,s=e.find(o=>o.getName()===i);if(s)switch(n.type){case V.FileUpload:{const o=s,l=await Ie([n.value]);l.length>0&&await o.selectImage(l[0]);const c=(a=n.storage)==null?void 0:a.colors;if(c){const d=Object.fromEntries(c.map(A=>[A.key,{browserValue:A.browserValue,pmsValue:A.pmsValue}])??[]);await o.changeColors(d)}break}case V.ColorOption:{const o=s;if(n.type===V.ColorOption){const c=o.getAllVariants().find(d=>d.getId()===n.value);c&&await o.selectVariant(c)}else o.setCustomColor(n.value);break}case V.Option:{const o=s,c=o.getAllVariants().find(d=>d.getId()===n.value);c&&await o.selectVariant(c);break}case V.Text:{await s.setText(n.value);break}}}}getGlobalPropertyStateManager(){return this.globalPropertyStateManager}async getGlobalPropertyTotalSubunits(){return(await this.globalPropertyHandleService.getHandles()).filter(a=>a.getType()===V.Option).map(a=>{var n;return((n=a.getCurrentVariant())==null?void 0:n.getPrice())||0}).reduce((a,n)=>a+n,0)}getTotalSubunits(){return this.workflowExperiences.map(t=>t.getTotalPriceSubunits()).reduce((t,e)=>t+e,0)}getProductCollection(){return this.productCollection?new Ga(this.productCollection):void 0}async initializeAdditionalRequiredColorChannels(t){var e,a,n,i;for(const s of t.getStepsByType(I.Illustration)){const o=s.getGlobalPropertyAspects(this.globalConfigurationPropertyId||"");for(const l of o){const c=(e=this.getGlobalPropertyConfiguration())==null?void 0:e.aspects.find(d=>d.name===l);if(c&&c.type===V.ColorOption){const d=(a=s.getCurrentVariant())==null?void 0:a.getAssetResource(),A=((n=d==null?void 0:d.assetConfiguration)==null?void 0:n.channelNumbers)||[],u=((i=d==null?void 0:d.assetConfiguration)==null?void 0:i.defaultColorVariants)||[],h=ac(this.getWorkflowExperiences(),this.globalConfigurationPropertyId||"",l),g=[...new Set(A.map(p=>p.number))];if(g.length>h)for(const p of g){const f=this.getGlobalPropertyStateManager(),C=u.find(w=>w.channelNumber===p);C&&await f.setAspect(l,C.variant.id||"",void 0,C.channelNumber)}}}}}async addWorkflowExperience(t){await this.initializeAdditionalRequiredColorChannels(t),t.setBundle(this),await this.appendWorkflowExperience(t),await this.injectExperienceIntoPreviewService(t),await t.getWorkflowManager().getInitializationPromise();const e=await this.getGlobalProperties();for(const a of e)await a.applyGlobalState([t]);this.fireEvent("workflow-experience-added",{workflowExperiences:[t]})}async addWorkflowExperiences(t){for(const o of t)await this.initializeAdditionalRequiredColorChannels(o);const e=t.map(o=>o.getWorkflowManager().getTransaction().id),a=e.map(o=>this.workflowExperiences.find(l=>l.getWorkflowManager().getTransaction().id===o));if(a.some(o=>!!o))throw new Error("Unable to add transaction to bundle - Already Exists: "+a.filter(o=>!!o).map(o=>o==null?void 0:o.getWorkflowManager().getTransaction().id).join(", "));const n=N.getMap("transactionOwnerIds")||new Map,i=e.map(o=>n.get(o));await B.getShadowGraphqlClient().mutate({mutation:il,variables:{id:this.id,transactionIds:e,transactionOwnerIds:i},context:{bundleOwnerId:this.ownerId}}).catch(o=>{console.error(o)}),this.workflowExperiences.push(...t);const s=async()=>{for(const l of t)l.setBundle(this),await this.injectExperienceIntoPreviewService(l);await Promise.all(t.map(l=>l.getWorkflowManager().getInitializationPromise()));const o=await this.getGlobalProperties();for(const l of o)await l.applyGlobalState(t)};await Promise.all([this.updateTransactionOrder(),s()]),this.workflowExperiences.forEach(o=>o.checkForPriceBreakChanges()),this.fireEvent("workflow-experience-added",{workflowExperiences:this.workflowExperiences})}async appendWorkflowExperience(t,e=!0){const a=t.getWorkflowManager().getTransaction().id;if(this.workflowExperiences.find(o=>o.getWorkflowManager().getTransaction().id===a))throw new Error("Unable to add transaction to bundle - Already Exists!");const s=(N.getMap("transactionOwnerIds")||new Map).get(a);await B.getShadowGraphqlClient().mutate({mutation:rl,variables:{id:this.id,transactionId:a},context:{bundleOwnerId:this.ownerId,transactionOwnerId:s}}),e&&(this.workflowExperiences.push(t),this.workflowExperiences.forEach(o=>o.checkForPriceBreakChanges()))}async removeWorkflowExperience(t){const e=this.workflowExperiences.indexOf(t);await this.removeTransaction(e,this.workflowExperiences[e].getWorkflowManager().getTransaction()),this.fireEvent("workflow-experience-added",{workflowExperiences:[t]})}async removeWorkflowExperiences(t){await this.removeTransactions(t.map(e=>e.getWorkflowManager().getTransaction()))}async removeWorkflowExperienceByTransaction(t){const e=this.workflowExperiences.findIndex(a=>a.getWorkflowManager().getTransaction().id===t.id);await this.removeTransaction(e,t)}async removeWorkflowExperiencesByTransactions(t){await this.removeTransactions(t)}async removeTransaction(t,e,a=!0){if(t>-1){const n=this.workflowExperiences.find(i=>i.getWorkflowManager().getTransaction().id===e.id);if(n.setBundle(void 0),this.previewService&&n.getWorkflowManager().ejectFromPreviewService(),this.bundleStateManager.removeStateForTransaction(e.id),await B.getShadowGraphqlClient().mutate({mutation:sl,variables:{id:this.id,transactionId:e.id,name:this.name,metadata:Array.from(this.metadata.entries()).map(([i,s])=>({key:i,value:s})),bundleStateData:this.bundleStateManager.getSerializedState()},context:{bundleOwnerId:this.ownerId}}),a){const i=this.workflowExperiences.splice(t,1);this.workflowExperiences.forEach(s=>s.checkForPriceBreakChanges()),n.checkForPriceBreakChanges(),await this.updateTransactionOrder(),this.fireEvent("workflow-experience-removed",{workflowExperiences:i})}}else throw new Error("Unable to remove workflow experience from bundle - Not Found! - "+e.id)}async removeTransactions(t){const e=t.map(n=>this.workflowExperiences.findIndex(i=>i.getWorkflowManager().getTransaction().id===n.id));if(e.some(n=>n===-1))throw new Error("Unable to remove workflow experience from bundle - The following aren't included in the bundle: "+t.filter((n,i)=>e[i]===-1).map(n=>n.id).join(", "));const a=t.map(n=>this.workflowExperiences.splice(this.workflowExperiences.findIndex(i=>i.getWorkflowManager().getTransaction().id===n.id),1)[0]);a.forEach(n=>n.setBundle(void 0)),[...this.workflowExperiences,...a].forEach(n=>n.checkForPriceBreakChanges()),this.previewService&&a.forEach(n=>n.getWorkflowManager().ejectFromPreviewService()),t.forEach(n=>this.bundleStateManager.removeStateForTransaction(n.id)),await B.getShadowGraphqlClient().mutate({mutation:ol,variables:{id:this.id,transactionIds:t.map(n=>n.id),name:this.name,metadata:Array.from(this.metadata.entries()).map(([n,i])=>({key:n,value:i})),bundleStateData:this.bundleStateManager.getSerializedState()},context:{bundleOwnerId:this.ownerId}}),this.fireEvent("workflow-experience-removed",{workflowExperiences:a}),await this.updateTransactionOrder()}async insertWorkflowExperience(t,e){await this.appendWorkflowExperience(t,!1),this.workflowExperiences.splice(e,0,t),await Promise.all([this.updateTransactionOrder(),(async()=>{await this.injectExperienceIntoPreviewService(t);const a=await this.getGlobalProperties();await Promise.all(a.map(n=>n.applyGlobalState([t])))})()])}async replaceWorkflowExperience(t,e){if(t<0||t>=this.workflowExperiences.length)throw new Error("Unable to replace workflow experience in bundle - Index out of range!");const a=this.workflowExperiences[t];if(a.getWorkflowManager().getTransaction().id===e.getWorkflowManager().getTransaction().id)throw new Error("Unable to replace workflow experience in bundle - Same transaction!");await Promise.all([this.removeTransaction(t,a.getWorkflowManager().getTransaction(),!1),this.appendWorkflowExperience(e,!1)]),this.workflowExperiences[t]=e,await Promise.all([this.updateTransactionOrder(),(async()=>{await this.injectExperienceIntoPreviewService(e);const n=await this.getGlobalProperties();await Promise.all(n.map(i=>i.applyGlobalState([e])))})()])}async swapWorkflowExperiences(t,e){if(t<0||t>=this.workflowExperiences.length||e<0||e>=this.workflowExperiences.length)throw new Error("Unable to swap workflow experiences in bundle - Index out of range!");if(t===e)return;const a=this.workflowExperiences[t];this.workflowExperiences[t]=this.workflowExperiences[e],this.workflowExperiences[e]=a,await this.updateTransactionOrder()}getWorkflowExperiences(){return[...this.workflowExperiences]}async sortWorkflowExperiences(t){this.workflowExperiences=this.workflowExperiences.sort(t),await this.updateTransactionOrder()}getWorkflowExperienceCount(){return this.workflowExperiences.length}async addStakeholder(t,e){var i;const a=await B.getShadowGraphqlClient().mutate({mutation:ll,variables:{id:this.id,details:t,type:e||Zt.Owner},context:{bundleOwnerId:this.ownerId}});if(!((i=a.data)!=null&&i.bundleAddStakeholder))throw new Error("Bundle not found!");const n=a.data.bundleAddStakeholder.bundleStakeholders||[];this.storeStakeholderCustomers(n)}async removeStakeholder(t){var a;if(!((a=(await B.getShadowGraphqlClient().mutate({mutation:cl,variables:{id:this.id,emailAddress:t},context:{bundleOwnerId:this.ownerId}})).data)!=null&&a.bundleRemoveStakeholder))throw new Error("Bundle not found!")}async updateStakeholders(t){var n;const e=await B.getShadowGraphqlClient().mutate({mutation:dl,variables:{id:this.id,input:t},context:{bundleOwnerId:this.ownerId}});if(!((n=e.data)!=null&&n.bundleUpdateStakeholders))throw new Error("Bundle not found!");const a=e.data.bundleUpdateStakeholders.bundleStakeholders||[];this.storeStakeholderCustomers(a)}async getAllStakeholders(){const t=await B.getShadowGraphqlClient().query({query:dn,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id},context:{bundleOwnerId:this.ownerId}});if(!t.data.bundles||t.data.bundles.length===0)throw new Error("Bundle not found!");const e=t.data.bundles[0].bundleStakeholders||[];return this.storeStakeholderCustomers(e),e}async getCurrentStakeholder(){const t=await B.getShadowGraphqlClient().query({query:dn,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id},context:{bundleOwnerId:this.ownerId}});if(!t.data.bundles||t.data.bundles.length===0)throw new Error("Bundle not found!");return t.data.bundles[0].currentBundleStakeholder}storeStakeholderCustomers(t){t.forEach(e=>{e.customer&&this.client.storeCustomer(e.customer)})}async finish(t,e){if(this.completed)return await B.getShadowGraphqlClient().mutate({mutation:ml,variables:{bundleId:this.id}}),{bundleId:this.id,items:[],bundleOwnerId:this.ownerId};const a=await Fl(this.workflowExperiences.map(n=>({workflowManager:n.getWorkflowManager(),workflow:n.getWorkflowManager().getWorkflow(),layouts:n.getWorkflowManager().getLayouts(),getReducerState:()=>n.getCommandContext().getState(),product:n.getWorkflowManager().getProduct(),transaction:n.getWorkflowManager().getTransaction(),workflowSelections:n.getWorkflowManager().getWorkflowSelections(),designName:n.getWorkflowManager().getWorkflow().name,workflowMetadata:n.getWorkflowManager().getWorkflowMetadata()})),t??(()=>{}),e?(n,i)=>{const s=this.workflowExperiences.find(o=>o.getWorkflowManager().getTransaction().id===i);return s?e(s,n):(console.warn("SpiffCommerce - Bundle create design - Unable to find experience for transaction: "+i),Promise.resolve(void 0))}:void 0);return{bundleId:this.id,items:a,bundleOwnerId:this.ownerId}}async placeOrder(){const t=this.workflowExperiences.map(e=>({transactionId:e.getWorkflowManager().getTransaction().id,amountToOrder:e.getWorkflowManager().getTransaction().quantity||1}));return await this.getClient().placeOrder(t)}getPreviewService(){return this.previewService}async setPreviewService(t){if(this.workflowExperiences&&this.workflowExperiences.length>0&&(this.workflowExperiences.forEach(e=>e.getWorkflowManager().ejectFromPreviewService()),t))for(const e of this.workflowExperiences)await this.injectExperienceIntoPreviewService(e);t&&t.registerModelLoadEventListener&&t.registerModelLoadEventListener(this.onModelLoadEvent.bind(this)),this.previewService&&this.previewService!==t&&this.previewService.unregisterModelLoadEventListener&&this.previewService.unregisterModelLoadEventListener(this.onModelLoadEvent.bind(this)),this.previewService=t}updateWorkflowExperienceTransform(t,e,a){return this.bundleStateManager.updateWorkflowExperienceTransform(t,e,a),this.updateBundle()}activateWorkflowExperienceTransform(t,e){return this.bundleStateManager.activateWorkflowExperienceTransform(t,e),this.updateBundle()}async assignGlobalPropertyConfiguration(t){await B.getShadowGraphqlClient().mutate({mutation:hl,variables:{bundleId:this.id,globalPropertyConfigurationId:t},context:{bundleOwnerId:this.ownerId}}),this.globalConfigurationPropertyId=t}async assignProductCollection(t){var a,n;const e=await B.getShadowGraphqlClient().mutate({mutation:ul(((a=this.globalPropertyStateManager.getBundleOptions())==null?void 0:a.eagerFetchProducts)??!1),variables:{id:this.id,productCollectionId:t??""},context:{bundleOwnerId:this.ownerId}});if((n=e.data)!=null&&n.bundleAssignProductCollection.productCollection){this.productCollection=e.data.bundleAssignProductCollection.productCollection;const i=e.data.bundleAssignProductCollection.productCollection.globalPropertyConfiguration;this.globalPropertyStateManager.setConfiguration(i),this.globalConfigurationPropertyId=i==null?void 0:i.id}}onModelLoadEvent(t){t.eventType==="unload"||!t.modelContainer||(t.modelContainer.registerMaterialSelectedCallback(()=>this.onModelSelectedEvent(t.modelContainer,!0)),t.modelContainer.registerMaterialDeselectedCallback(()=>this.onModelSelectedEvent(t.modelContainer,!1)))}onModelSelectedEvent(t,e){if(t&&t.metadata&&t.metadata instanceof Map&&t.metadata.has("workflowManager")){const n=t.metadata.get("workflowManager").getTransaction(),i=this.workflowExperiences.find(s=>s.getWorkflowManager().getTransaction().id===n.id);i&&this.fireEvent(e?"workflow-experience-hover-enter":"workflow-experience-hover-exit",{workflowExperience:i})}}async injectExperienceIntoPreviewService(t){if(this.previewService){const e=t.getWorkflowManager().injectIntoPreviewService(this.previewService);try{this.bundleStateManager.applyStateToWorkflowExperience(t)}catch(a){console.error(`Unable to apply state to workflow experience: ${a}`)}await e}}async loadExistingWorkflowExperiences(t,e){if(t.length===0)return;const a=await this.client.getWorkflowExperiences(t.map(n=>({type:"transaction",transactionId:n})),e);if(a.forEach(n=>n.setBundle(this)),a.forEach(n=>n.checkForPriceBreakChanges()),this.workflowExperiences=a,this.previewService)for(const n of a)await this.injectExperienceIntoPreviewService(n)}async updateBundle(){var e;if(!((e=(await B.getShadowGraphqlClient().mutate({mutation:nl,variables:{id:this.id,name:this.name,metadata:Array.from(this.metadata.entries()).map(([a,n])=>({key:a,value:n})),bundleStateData:this.bundleStateManager.getSerializedState(),dispatchDate:this.dispatchDate,purchaseOrder:this.purchaseOrder},context:{bundleOwnerId:this.ownerId}})).data)!=null&&e.bundleUpdate))throw new Error("Bundle not found!")}async updateTransactionOrder(){await B.getShadowGraphqlClient().mutate({mutation:Al,variables:{id:this.id,transactionIds:this.workflowExperiences.map(t=>t.getWorkflowManager().getTransaction().id)},context:{bundleOwnerId:this.ownerId}})}async onGlobalPropertiesChanged(t,e){const a=await this.globalPropertyHandleService.getHandles(),n=this.globalPropertyHandleService.applyConditionsFromState(a,t),i=this.globalPropertyHandleService.applyConditionsFromState(a,e);this.checkConditionalHandlesChanged(n,i),this.checkMandatoryHandlesChanged(t,i);const s=i.filter(o=>!n.includes(o));await Promise.all(s.map(o=>o.applyGlobalState()))}checkConditionalHandlesChanged(t,e){(()=>{if(t.length!==e.length)return!0;for(let n=0;n<t.length;n++)if(t[n].getName()!==e[n].getName())return!0;return!1})()&&this.fireEvent("conditional-global-properties-changed",{globalProperties:e})}checkMandatoryHandlesChanged(t,e){const a=[],n=[],i=[],s=Rr(t);e.forEach(o=>{if(o.isMandatory()){const l=o.isMandatoryFulfilled();l?n.push(o):i.push(o);const c=s.get(o.getName());(c===void 0||c!==l)&&a.push(o)}}),this.fireEvent("global-properties-mandatory-changed",{changed:a,completed:n,remaining:i})}fireEvent(t,e){this.eventEmitter.emit(t,e)}getShareActions(){return this.shareActions}getWorkflowViewerLink(){return this.workflowViewerLink}getWorkflowViewerAmendLink(){return this.workflowViewerAmendLink}async approve(t,e){await B.getShadowGraphqlClient().mutate({mutation:pl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id,note:t,stakeholderId:e}})}async reject(t,e){await B.getShadowGraphqlClient().mutate({mutation:fl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id,note:t,stakeholderId:e}})}getQuoteCompleteMessage(){return{bundleId:this.id,bundleOwnerId:this.ownerId,quoteId:this.quoteId||""}}}const hc=v.gql`
2387
+ `;class ea{constructor(t,e,a,n,i,s){var c,d,A;this.workflowExperiences=[],this.eventEmitter=new dc,this.client=t,this.id=e.id,this.name=e.name||"",this.dispatchDate=e.dispatchDate,this.template=e.template||!1,this.quoteId=e.quoteId,this.shareActions=e.bundleShareActions,this.workflowViewerLink=e.workflowViewerLink,this.workflowViewerAmendLink=e.workflowViewerAmendLink,this.ownerId=i,this.metadata=new Map(((c=e.metadata)==null?void 0:c.map(u=>[u.key,u.value]))||[]),this.completed=e.completed??!1,this.productCollection=e.productCollection,this.bundleStateManager=new ic(e.bundleStateData);const o=(d=this.productCollection)==null?void 0:d.globalPropertyConfiguration;this.globalConfigurationPropertyId=o==null?void 0:o.id,this.globalPropertyStateManager=new rc(this.id,this.ownerId,o,this.onGlobalPropertiesChanged.bind(this),s),this.globalPropertyHandleService=new ec(this),this.setPreviewService(a);const l=new Promise((u,h)=>{if(s!=null&&s.readonly){u([]);return}console.log("Setting default global variants.");const g=this.globalPropertyStateManager.getGlobalPropertyState();g?this.globalPropertyHandleService.getHandles().then(m=>{const p=m.map(f=>{if(f.getType()===V.ColorOption||f.getType()===V.Option){const C=f;if(!g.aspects.find(S=>S.name===C.getName()))return C.initDefaultVariant()}});Promise.all(p).then(u).catch(h)}):(console.log("Attempted to set global default variant before state was initialized."),u([]))});this.initializationPromise=Promise.all([this.loadExistingWorkflowExperiences(((A=e.transactions)==null?void 0:A.map(u=>u.id))||[],{...n,bundleOwnerId:i}),this.globalPropertyStateManager.getInitializationPromise()]).then(()=>l),this.initializationPromise.catch(u=>{console.error(`Bundle initialization failed: ${u}`)}),this.initializationPromise.then(()=>{this.getGlobalProperties().then(u=>this.checkMandatoryHandlesChanged(void 0,u))})}getTemplate(){return this.template}async generateQuoteId(){var a,n;const e=(n=(a=(await B.getShadowGraphqlClient().mutate({mutation:hc,variables:{id:this.id},context:{bundleOwnerId:this.ownerId}})).data)==null?void 0:a.bundleGenerateQuoteId)==null?void 0:n.quoteId;return this.quoteId=e,e||""}async attachAddress(t,e,a,n,i,s){await B.getShadowGraphqlClient().mutate({mutation:Ac,variables:{bundleId:this.id,streetAddress:t||void 0,apartment:e||void 0,city:a||void 0,country:n||void 0,state:i||void 0,postCode:s||void 0},context:{bundleOwnerId:this.ownerId}})}async attachOrganization(t){await B.getShadowGraphqlClient().mutate({mutation:uc,variables:{bundleId:this.id,organizationName:t},context:{bundleOwnerId:this.ownerId}})}setBundleOptions(t){this.globalPropertyStateManager.setBundleOptions(t)}getInitializationPromise(){return this.initializationPromise}addEventListener(t,e){this.eventEmitter.on(t,e)}removeEventListener(t,e){this.eventEmitter.off(t,e)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}getQuoteId(){return this.quoteId}setName(t){return this.name=t,this.updateBundle()}getDispatchDate(){return this.dispatchDate}setDispatchDate(t){return this.dispatchDate=t,this.updateBundle()}getPurchaseOrder(){return this.purchaseOrder}setPurchaseOrder(t){return this.purchaseOrder=t,this.updateBundle()}getMetadata(){return new Map(this.metadata)}setMetadata(t){return this.metadata=new Map(t),this.updateBundle()}setNameAndMetadata(t,e){return this.name=t,this.metadata=new Map(e),this.updateBundle()}hasGlobalProperties(){var t;return!!((t=this.productCollection)!=null&&t.globalPropertyConfiguration)}getGlobalPropertyConfiguration(){var t;return(t=this.productCollection)==null?void 0:t.globalPropertyConfiguration}async getGlobalProperties(){return this.globalPropertyHandleService.applyConditionsFromState(await this.globalPropertyHandleService.getHandles(),this.getGlobalPropertyStateManager().getGlobalPropertyState())}async applyGlobalPropertyState(t){var a;const e=await this.globalPropertyHandleService.getHandles();for(const n of t.aspects){const i=n==null?void 0:n.name;this.getGlobalPropertyStateManager().setAspect(i,n.value)}for(const n of t.aspects){const i=n==null?void 0:n.name,s=e.find(o=>o.getName()===i);if(s)switch(n.type){case V.FileUpload:{const o=s,l=await Ie([n.value]);l.length>0&&await o.selectImage(l[0]);const c=(a=n.storage)==null?void 0:a.colors;if(c){const d=Object.fromEntries(c.map(A=>[A.key,{browserValue:A.browserValue,pmsValue:A.pmsValue}])??[]);await o.changeColors(d)}break}case V.ColorOption:{const o=s;if(n.type===V.ColorOption){const c=o.getAllVariants().find(d=>d.getId()===n.value);c&&await o.selectVariant(c)}else o.setCustomColor(n.value);break}case V.Option:{const o=s,c=o.getAllVariants().find(d=>d.getId()===n.value);c&&await o.selectVariant(c);break}case V.Text:{await s.setText(n.value);break}}}}getGlobalPropertyStateManager(){return this.globalPropertyStateManager}async getGlobalPropertyTotalSubunits(){return(await this.globalPropertyHandleService.getHandles()).filter(a=>a.getType()===V.Option).map(a=>{var n;return((n=a.getCurrentVariant())==null?void 0:n.getPrice())||0}).reduce((a,n)=>a+n,0)}getTotalSubunits(){return this.workflowExperiences.map(t=>t.getTotalPriceSubunits()).reduce((t,e)=>t+e,0)}getProductCollection(){return this.productCollection?new qa(this.productCollection):void 0}async initializeAdditionalRequiredColorChannels(t){var e,a,n,i;for(const s of t.getStepsByType(I.Illustration)){const o=s.getGlobalPropertyAspects(this.globalConfigurationPropertyId||"");for(const l of o){const c=(e=this.getGlobalPropertyConfiguration())==null?void 0:e.aspects.find(d=>d.name===l);if(c&&c.type===V.ColorOption){const d=(a=s.getCurrentVariant())==null?void 0:a.getAssetResource(),A=((n=d==null?void 0:d.assetConfiguration)==null?void 0:n.channelNumbers)||[],u=((i=d==null?void 0:d.assetConfiguration)==null?void 0:i.defaultColorVariants)||[],h=nc(this.getWorkflowExperiences(),this.globalConfigurationPropertyId||"",l),g=[...new Set(A.map(p=>p.number))];if(g.length>h)for(const p of g){const f=this.getGlobalPropertyStateManager(),C=u.find(w=>w.channelNumber===p);C&&await f.setAspect(l,C.variant.id||"",void 0,C.channelNumber)}}}}}async addWorkflowExperience(t){await this.initializeAdditionalRequiredColorChannels(t),t.setBundle(this),await this.appendWorkflowExperience(t),await this.injectExperienceIntoPreviewService(t),await t.getWorkflowManager().getInitializationPromise();const e=await this.getGlobalProperties();for(const a of e)await a.applyGlobalState([t]);this.fireEvent("workflow-experience-added",{workflowExperiences:[t]})}async addWorkflowExperiences(t){for(const o of t)await this.initializeAdditionalRequiredColorChannels(o);const e=t.map(o=>o.getWorkflowManager().getTransaction().id),a=e.map(o=>this.workflowExperiences.find(l=>l.getWorkflowManager().getTransaction().id===o));if(a.some(o=>!!o))throw new Error("Unable to add transaction to bundle - Already Exists: "+a.filter(o=>!!o).map(o=>o==null?void 0:o.getWorkflowManager().getTransaction().id).join(", "));const n=T.getMap("transactionOwnerIds")||new Map,i=e.map(o=>n.get(o));await B.getShadowGraphqlClient().mutate({mutation:sl,variables:{id:this.id,transactionIds:e,transactionOwnerIds:i},context:{bundleOwnerId:this.ownerId}}).catch(o=>{console.error(o)}),this.workflowExperiences.push(...t);const s=async()=>{for(const l of t)l.setBundle(this),await this.injectExperienceIntoPreviewService(l);await Promise.all(t.map(l=>l.getWorkflowManager().getInitializationPromise()));const o=await this.getGlobalProperties();for(const l of o)await l.applyGlobalState(t)};await Promise.all([this.updateTransactionOrder(),s()]),this.workflowExperiences.forEach(o=>o.checkForPriceBreakChanges()),this.fireEvent("workflow-experience-added",{workflowExperiences:this.workflowExperiences})}async appendWorkflowExperience(t,e=!0){const a=t.getWorkflowManager().getTransaction().id;if(this.workflowExperiences.find(o=>o.getWorkflowManager().getTransaction().id===a))throw new Error("Unable to add transaction to bundle - Already Exists!");const s=(T.getMap("transactionOwnerIds")||new Map).get(a);await B.getShadowGraphqlClient().mutate({mutation:il,variables:{id:this.id,transactionId:a},context:{bundleOwnerId:this.ownerId,transactionOwnerId:s}}),e&&(this.workflowExperiences.push(t),this.workflowExperiences.forEach(o=>o.checkForPriceBreakChanges()))}async removeWorkflowExperience(t){const e=this.workflowExperiences.indexOf(t);await this.removeTransaction(e,this.workflowExperiences[e].getWorkflowManager().getTransaction()),this.fireEvent("workflow-experience-added",{workflowExperiences:[t]})}async removeWorkflowExperiences(t){await this.removeTransactions(t.map(e=>e.getWorkflowManager().getTransaction()))}async removeWorkflowExperienceByTransaction(t){const e=this.workflowExperiences.findIndex(a=>a.getWorkflowManager().getTransaction().id===t.id);await this.removeTransaction(e,t)}async removeWorkflowExperiencesByTransactions(t){await this.removeTransactions(t)}async removeTransaction(t,e,a=!0){if(t>-1){const n=this.workflowExperiences.find(i=>i.getWorkflowManager().getTransaction().id===e.id);if(n.setBundle(void 0),this.previewService&&n.getWorkflowManager().ejectFromPreviewService(),this.bundleStateManager.removeStateForTransaction(e.id),await B.getShadowGraphqlClient().mutate({mutation:ol,variables:{id:this.id,transactionId:e.id,name:this.name,metadata:Array.from(this.metadata.entries()).map(([i,s])=>({key:i,value:s})),bundleStateData:this.bundleStateManager.getSerializedState()},context:{bundleOwnerId:this.ownerId}}),a){const i=this.workflowExperiences.splice(t,1);this.workflowExperiences.forEach(s=>s.checkForPriceBreakChanges()),n.checkForPriceBreakChanges(),await this.updateTransactionOrder(),this.fireEvent("workflow-experience-removed",{workflowExperiences:i})}}else throw new Error("Unable to remove workflow experience from bundle - Not Found! - "+e.id)}async removeTransactions(t){const e=t.map(n=>this.workflowExperiences.findIndex(i=>i.getWorkflowManager().getTransaction().id===n.id));if(e.some(n=>n===-1))throw new Error("Unable to remove workflow experience from bundle - The following aren't included in the bundle: "+t.filter((n,i)=>e[i]===-1).map(n=>n.id).join(", "));const a=t.map(n=>this.workflowExperiences.splice(this.workflowExperiences.findIndex(i=>i.getWorkflowManager().getTransaction().id===n.id),1)[0]);a.forEach(n=>n.setBundle(void 0)),[...this.workflowExperiences,...a].forEach(n=>n.checkForPriceBreakChanges()),this.previewService&&a.forEach(n=>n.getWorkflowManager().ejectFromPreviewService()),t.forEach(n=>this.bundleStateManager.removeStateForTransaction(n.id)),await B.getShadowGraphqlClient().mutate({mutation:ll,variables:{id:this.id,transactionIds:t.map(n=>n.id),name:this.name,metadata:Array.from(this.metadata.entries()).map(([n,i])=>({key:n,value:i})),bundleStateData:this.bundleStateManager.getSerializedState()},context:{bundleOwnerId:this.ownerId}}),this.fireEvent("workflow-experience-removed",{workflowExperiences:a}),await this.updateTransactionOrder()}async insertWorkflowExperience(t,e){await this.appendWorkflowExperience(t,!1),this.workflowExperiences.splice(e,0,t),await Promise.all([this.updateTransactionOrder(),(async()=>{await this.injectExperienceIntoPreviewService(t);const a=await this.getGlobalProperties();await Promise.all(a.map(n=>n.applyGlobalState([t])))})()])}async replaceWorkflowExperience(t,e){if(t<0||t>=this.workflowExperiences.length)throw new Error("Unable to replace workflow experience in bundle - Index out of range!");const a=this.workflowExperiences[t];if(a.getWorkflowManager().getTransaction().id===e.getWorkflowManager().getTransaction().id)throw new Error("Unable to replace workflow experience in bundle - Same transaction!");await Promise.all([this.removeTransaction(t,a.getWorkflowManager().getTransaction(),!1),this.appendWorkflowExperience(e,!1)]),this.workflowExperiences[t]=e,await Promise.all([this.updateTransactionOrder(),(async()=>{await this.injectExperienceIntoPreviewService(e);const n=await this.getGlobalProperties();await Promise.all(n.map(i=>i.applyGlobalState([e])))})()])}async swapWorkflowExperiences(t,e){if(t<0||t>=this.workflowExperiences.length||e<0||e>=this.workflowExperiences.length)throw new Error("Unable to swap workflow experiences in bundle - Index out of range!");if(t===e)return;const a=this.workflowExperiences[t];this.workflowExperiences[t]=this.workflowExperiences[e],this.workflowExperiences[e]=a,await this.updateTransactionOrder()}getWorkflowExperiences(){return[...this.workflowExperiences]}async sortWorkflowExperiences(t){this.workflowExperiences=this.workflowExperiences.sort(t),await this.updateTransactionOrder()}getWorkflowExperienceCount(){return this.workflowExperiences.length}async addStakeholder(t,e){var i;const a=await B.getShadowGraphqlClient().mutate({mutation:cl,variables:{id:this.id,details:t,type:e||Zt.Owner},context:{bundleOwnerId:this.ownerId}});if(!((i=a.data)!=null&&i.bundleAddStakeholder))throw new Error("Bundle not found!");const n=a.data.bundleAddStakeholder.bundleStakeholders||[];this.storeStakeholderCustomers(n)}async removeStakeholder(t){var a;if(!((a=(await B.getShadowGraphqlClient().mutate({mutation:dl,variables:{id:this.id,emailAddress:t},context:{bundleOwnerId:this.ownerId}})).data)!=null&&a.bundleRemoveStakeholder))throw new Error("Bundle not found!")}async updateStakeholders(t){var n;const e=await B.getShadowGraphqlClient().mutate({mutation:Al,variables:{id:this.id,input:t},context:{bundleOwnerId:this.ownerId}});if(!((n=e.data)!=null&&n.bundleUpdateStakeholders))throw new Error("Bundle not found!");const a=e.data.bundleUpdateStakeholders.bundleStakeholders||[];this.storeStakeholderCustomers(a)}async getAllStakeholders(){const t=await B.getShadowGraphqlClient().query({query:An,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id},context:{bundleOwnerId:this.ownerId}});if(!t.data.bundles||t.data.bundles.length===0)throw new Error("Bundle not found!");const e=t.data.bundles[0].bundleStakeholders||[];return this.storeStakeholderCustomers(e),e}async getCurrentStakeholder(){const t=await B.getShadowGraphqlClient().query({query:An,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id},context:{bundleOwnerId:this.ownerId}});if(!t.data.bundles||t.data.bundles.length===0)throw new Error("Bundle not found!");return t.data.bundles[0].currentBundleStakeholder}storeStakeholderCustomers(t){t.forEach(e=>{e.customer&&this.client.storeCustomer(e.customer)})}async finish(t,e){if(this.completed)return await B.getShadowGraphqlClient().mutate({mutation:pl,variables:{bundleId:this.id}}),{bundleId:this.id,items:[],bundleOwnerId:this.ownerId};const a=await kl(this.workflowExperiences.map(n=>({workflowManager:n.getWorkflowManager(),workflow:n.getWorkflowManager().getWorkflow(),layouts:n.getWorkflowManager().getLayouts(),getReducerState:()=>n.getCommandContext().getState(),product:n.getWorkflowManager().getProduct(),transaction:n.getWorkflowManager().getTransaction(),workflowSelections:n.getWorkflowManager().getWorkflowSelections(),designName:n.getWorkflowManager().getWorkflow().name,workflowMetadata:n.getWorkflowManager().getWorkflowMetadata()})),t??(()=>{}),e?(n,i)=>{const s=this.workflowExperiences.find(o=>o.getWorkflowManager().getTransaction().id===i);return s?e(s,n):(console.warn("SpiffCommerce - Bundle create design - Unable to find experience for transaction: "+i),Promise.resolve(void 0))}:void 0);return{bundleId:this.id,items:a,bundleOwnerId:this.ownerId}}async placeOrder(){const t=this.workflowExperiences.map(e=>({transactionId:e.getWorkflowManager().getTransaction().id,amountToOrder:e.getWorkflowManager().getTransaction().quantity||1}));return await this.getClient().placeOrder(t)}getPreviewService(){return this.previewService}async setPreviewService(t){if(this.workflowExperiences&&this.workflowExperiences.length>0&&(this.workflowExperiences.forEach(e=>e.getWorkflowManager().ejectFromPreviewService()),t))for(const e of this.workflowExperiences)await this.injectExperienceIntoPreviewService(e);t&&t.registerModelLoadEventListener&&t.registerModelLoadEventListener(this.onModelLoadEvent.bind(this)),this.previewService&&this.previewService!==t&&this.previewService.unregisterModelLoadEventListener&&this.previewService.unregisterModelLoadEventListener(this.onModelLoadEvent.bind(this)),this.previewService=t}updateWorkflowExperienceTransform(t,e,a){return this.bundleStateManager.updateWorkflowExperienceTransform(t,e,a),this.updateBundle()}activateWorkflowExperienceTransform(t,e){return this.bundleStateManager.activateWorkflowExperienceTransform(t,e),this.updateBundle()}async assignGlobalPropertyConfiguration(t){await B.getShadowGraphqlClient().mutate({mutation:gl,variables:{bundleId:this.id,globalPropertyConfigurationId:t},context:{bundleOwnerId:this.ownerId}}),this.globalConfigurationPropertyId=t}async assignProductCollection(t){var a,n;const e=await B.getShadowGraphqlClient().mutate({mutation:hl(((a=this.globalPropertyStateManager.getBundleOptions())==null?void 0:a.eagerFetchProducts)??!1),variables:{id:this.id,productCollectionId:t??""},context:{bundleOwnerId:this.ownerId}});if((n=e.data)!=null&&n.bundleAssignProductCollection.productCollection){this.productCollection=e.data.bundleAssignProductCollection.productCollection;const i=e.data.bundleAssignProductCollection.productCollection.globalPropertyConfiguration;this.globalPropertyStateManager.setConfiguration(i),this.globalConfigurationPropertyId=i==null?void 0:i.id}}onModelLoadEvent(t){t.eventType==="unload"||!t.modelContainer||(t.modelContainer.registerMaterialSelectedCallback(()=>this.onModelSelectedEvent(t.modelContainer,!0)),t.modelContainer.registerMaterialDeselectedCallback(()=>this.onModelSelectedEvent(t.modelContainer,!1)))}onModelSelectedEvent(t,e){if(t&&t.metadata&&t.metadata instanceof Map&&t.metadata.has("workflowManager")){const n=t.metadata.get("workflowManager").getTransaction(),i=this.workflowExperiences.find(s=>s.getWorkflowManager().getTransaction().id===n.id);i&&this.fireEvent(e?"workflow-experience-hover-enter":"workflow-experience-hover-exit",{workflowExperience:i})}}async injectExperienceIntoPreviewService(t){if(this.previewService){const e=t.getWorkflowManager().injectIntoPreviewService(this.previewService);try{this.bundleStateManager.applyStateToWorkflowExperience(t)}catch(a){console.error(`Unable to apply state to workflow experience: ${a}`)}await e}}async loadExistingWorkflowExperiences(t,e){if(t.length===0)return;const a=await this.client.getWorkflowExperiences(t.map(n=>({type:"transaction",transactionId:n})),e);if(a.forEach(n=>n.setBundle(this)),a.forEach(n=>n.checkForPriceBreakChanges()),this.workflowExperiences=a,this.previewService)for(const n of a)await this.injectExperienceIntoPreviewService(n)}async updateBundle(){var e;if(!((e=(await B.getShadowGraphqlClient().mutate({mutation:rl,variables:{id:this.id,name:this.name,metadata:Array.from(this.metadata.entries()).map(([a,n])=>({key:a,value:n})),bundleStateData:this.bundleStateManager.getSerializedState(),dispatchDate:this.dispatchDate,purchaseOrder:this.purchaseOrder},context:{bundleOwnerId:this.ownerId}})).data)!=null&&e.bundleUpdate))throw new Error("Bundle not found!")}async updateTransactionOrder(){await B.getShadowGraphqlClient().mutate({mutation:ul,variables:{id:this.id,transactionIds:this.workflowExperiences.map(t=>t.getWorkflowManager().getTransaction().id)},context:{bundleOwnerId:this.ownerId}})}async onGlobalPropertiesChanged(t,e){const a=await this.globalPropertyHandleService.getHandles(),n=this.globalPropertyHandleService.applyConditionsFromState(a,t),i=this.globalPropertyHandleService.applyConditionsFromState(a,e);this.checkConditionalHandlesChanged(n,i),this.checkMandatoryHandlesChanged(t,i);const s=i.filter(o=>!n.includes(o));await Promise.all(s.map(o=>o.applyGlobalState()))}checkConditionalHandlesChanged(t,e){(()=>{if(t.length!==e.length)return!0;for(let n=0;n<t.length;n++)if(t[n].getName()!==e[n].getName())return!0;return!1})()&&this.fireEvent("conditional-global-properties-changed",{globalProperties:e})}checkMandatoryHandlesChanged(t,e){const a=[],n=[],i=[],s=Or(t);e.forEach(o=>{if(o.isMandatory()){const l=o.isMandatoryFulfilled();l?n.push(o):i.push(o);const c=s.get(o.getName());(c===void 0||c!==l)&&a.push(o)}}),this.fireEvent("global-properties-mandatory-changed",{changed:a,completed:n,remaining:i})}fireEvent(t,e){this.eventEmitter.emit(t,e)}getShareActions(){return this.shareActions}getWorkflowViewerLink(){return this.workflowViewerLink}getWorkflowViewerAmendLink(){return this.workflowViewerAmendLink}async approve(t,e){await B.getShadowGraphqlClient().mutate({mutation:fl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id,note:t,stakeholderId:e}})}async reject(t,e){await B.getShadowGraphqlClient().mutate({mutation:Cl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id,note:t,stakeholderId:e}})}getQuoteCompleteMessage(){return{bundleId:this.id,bundleOwnerId:this.ownerId,quoteId:this.quoteId||""}}}const gc=v.gql`
2336
2388
  mutation processFlowCreate($processFlowId: String!, $inputs: [String]!) {
2337
2389
  processExecutionCreate(processFlowId: $processFlowId, inputs: $inputs) {
2338
2390
  id
2339
2391
  }
2340
2392
  }
2341
- `;class Vr{async execute(t,e,a){var A,u,h;const i=(u=(A=(await B.getShadowGraphqlClient().mutate({mutation:hc,variables:{processFlowId:t,inputs:[...e.map(g=>g.getValueForTransmission())]}})).data)==null?void 0:A.processExecutionCreate)==null?void 0:u.id;if(!i)throw new Error("Failed to create process execution.");function s(g){return new Promise(m=>{setTimeout(m,g)})}let o=!1,l=0,c,d;for(;!o;){c=await B.getShadowGraphqlClient().query({query:v.gql`
2393
+ `;class zr{async execute(t,e,a){var A,u,h;const i=(u=(A=(await B.getShadowGraphqlClient().mutate({mutation:gc,variables:{processFlowId:t,inputs:[...e.map(g=>g.getValueForTransmission())]}})).data)==null?void 0:A.processExecutionCreate)==null?void 0:u.id;if(!i)throw new Error("Failed to create process execution.");function s(g){return new Promise(m=>{setTimeout(m,g)})}let o=!1,l=0,c,d;for(;!o;){c=await B.getShadowGraphqlClient().query({query:v.gql`
2342
2394
  query getProcessFlowExecution($ids: [String]!) {
2343
2395
  processExecutions(ids: $ids) {
2344
2396
  id
@@ -2351,7 +2403,7 @@
2351
2403
  }
2352
2404
  }
2353
2405
  }
2354
- `,variables:{ids:[i]}});const g=(h=c.data)==null?void 0:h.processExecutions[0];if(!c||!g)throw new Error("Failed to retrieve server response for execution.");if(g.failedAt)throw new Error("Execution has failed to complete. See Automation > FLows in Flight on partner account on SpiffCommerce Hub.");if(g.completedAt){o=!0,d=new zr(g);break}l+=1;const m=a!=null&&a.repeats?a==null?void 0:a.repeats:5;if(l>=m)throw new Error("Maximum wait time exceeded for execution result.");await s(a!=null&&a.sleepTime?Math.max(a.sleepTime,500):2e3)}if(!d)throw new Error("Failed to retrieve server response for execution.");return Promise.resolve(d)}}class zr{constructor(t){this.execution=t}getRaw(){return this.execution}getNodes(){return this.execution.nodes.map(t=>new Yt(t))}getNodesByType(t){return this.execution.nodes.filter(e=>e.type===t).map(e=>new Yt(e))}getInputs(){return this.execution.nodes.filter(t=>t.type==="StartTerminal").map(t=>new Yt(t))}getOutputs(){return this.execution.nodes.filter(t=>t.type==="EndTerminal").map(t=>new Yt(t))}getCompletedAt(){if(this.execution.completedAt)return new Date(this.execution.completedAt)}getFailedAt(){if(this.execution.failedAt)return new Date(this.execution.failedAt)}}class Yt{constructor(t){this.node=t}getId(){return this.node.id}getType(){return this.node.type}getArtifacts(){return new Map(Object.entries(JSON.parse(this.node.artifacts).value))}getArtifactByName(t){return this.getArtifacts().get(t)}}class qa{constructor(t){this.value=t}getRaw(){return this.value}getValueForTransmission(){const t=this.value;return t.startsWith("[")?JSON.stringify(JSON.parse(t)):t}}var Gr=(r=>(r.Transaction="Transaction",r.Bundle="Bundle",r.Product="Product",r.Variant="Variant",r.Option="Option",r.LineItem="LineItem",r.Asset="Asset",r))(Gr||{});class gc extends qa{constructor(t){super(`"${t}"`)}}class Wa extends qa{constructor(t,e){if(e!=="Asset"&&!Wa.validUUID(t))throw new Error("Invalid ID, must be a valid v4 UUID. https://www.uuidgenerator.net/");super(`{"isSpiffObject": true, "id": "${t}", "type": "${e}"}`)}static validUUID(t){return t.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)}}class mc extends qa{constructor(t){super(`[${t.map(e=>e.getRaw()).join(",")}]`)}}class wa{constructor(t){this.integrationProduct=t}getId(){return this.integrationProduct.id}getResource(){return this.integrationProduct}getBasePrice(){var a;if(!this.integrationProduct.product)throw new Error("IntegrationProductResource does not have a product");const t=this.integrationProduct.product.basePrice||0,e=(a=this.integrationProduct)==null?void 0:a.additionalIntegrationProduct;if(!e)return t;if(e&&!e.product)throw new Error("An additional integration product was found, but it does not have a product");return t+(e.product.basePrice||0)}getDefaultWorkflow(){if(!this.integrationProduct.product)throw new Error("IntegrationProductResource does not have a product");const t=this.integrationProduct.product.workflows||[];if(t.length===0)throw new Error("No workflows found on product. This is generally due to a configuration error. Please confirm at least one workflow is configured for this product.");return new Mt(t[0])}getAllWorkflows(){if(!this.integrationProduct.product)throw new Error("IntegrationProductResource does not have a product");const t=this.integrationProduct.product.workflows||[];if(t.length===0)throw new Error("No workflows found on product. This is generally due to a configuration error. Please confirm at least one workflow is configured for this product.");return t.sort((e,a)=>(e.index??0)-(a.index??0)).map(e=>new Mt(e))}}const Se=v.gql`
2406
+ `,variables:{ids:[i]}});const g=(h=c.data)==null?void 0:h.processExecutions[0];if(!c||!g)throw new Error("Failed to retrieve server response for execution.");if(g.failedAt)throw new Error("Execution has failed to complete. See Automation > FLows in Flight on partner account on SpiffCommerce Hub.");if(g.completedAt){o=!0,d=new qr(g);break}l+=1;const m=a!=null&&a.repeats?a==null?void 0:a.repeats:5;if(l>=m)throw new Error("Maximum wait time exceeded for execution result.");await s(a!=null&&a.sleepTime?Math.max(a.sleepTime,500):2e3)}if(!d)throw new Error("Failed to retrieve server response for execution.");return Promise.resolve(d)}}class qr{constructor(t){this.execution=t}getRaw(){return this.execution}getNodes(){return this.execution.nodes.map(t=>new Yt(t))}getNodesByType(t){return this.execution.nodes.filter(e=>e.type===t).map(e=>new Yt(e))}getInputs(){return this.execution.nodes.filter(t=>t.type==="StartTerminal").map(t=>new Yt(t))}getOutputs(){return this.execution.nodes.filter(t=>t.type==="EndTerminal").map(t=>new Yt(t))}getCompletedAt(){if(this.execution.completedAt)return new Date(this.execution.completedAt)}getFailedAt(){if(this.execution.failedAt)return new Date(this.execution.failedAt)}}class Yt{constructor(t){this.node=t}getId(){return this.node.id}getType(){return this.node.type}getArtifacts(){return new Map(Object.entries(JSON.parse(this.node.artifacts).value))}getArtifactByName(t){return this.getArtifacts().get(t)}}class Ga{constructor(t){this.value=t}getRaw(){return this.value}getValueForTransmission(){const t=this.value;return t.startsWith("[")?JSON.stringify(JSON.parse(t)):t}}var Gr=(r=>(r.Transaction="Transaction",r.Bundle="Bundle",r.Product="Product",r.Variant="Variant",r.Option="Option",r.LineItem="LineItem",r.Asset="Asset",r))(Gr||{});class mc extends Ga{constructor(t){super(`"${t}"`)}}class Wa extends Ga{constructor(t,e){if(e!=="Asset"&&!Wa.validUUID(t))throw new Error("Invalid ID, must be a valid v4 UUID. https://www.uuidgenerator.net/");super(`{"isSpiffObject": true, "id": "${t}", "type": "${e}"}`)}static validUUID(t){return t.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)}}class pc extends Ga{constructor(t){super(`[${t.map(e=>e.getRaw()).join(",")}]`)}}class wa{constructor(t){this.integrationProduct=t}getId(){return this.integrationProduct.id}getResource(){return this.integrationProduct}getBasePrice(){var a;if(!this.integrationProduct.product)throw new Error("IntegrationProductResource does not have a product");const t=this.integrationProduct.product.basePrice||0,e=(a=this.integrationProduct)==null?void 0:a.additionalIntegrationProduct;if(!e)return t;if(e&&!e.product)throw new Error("An additional integration product was found, but it does not have a product");return t+(e.product.basePrice||0)}getDefaultWorkflow(){if(!this.integrationProduct.product)throw new Error("IntegrationProductResource does not have a product");const t=this.integrationProduct.product.workflows||[];if(t.length===0)throw new Error("No workflows found on product. This is generally due to a configuration error. Please confirm at least one workflow is configured for this product.");return new Mt(t[0])}getAllWorkflows(){if(!this.integrationProduct.product)throw new Error("IntegrationProductResource does not have a product");const t=this.integrationProduct.product.workflows||[];if(t.length===0)throw new Error("No workflows found on product. This is generally due to a configuration error. Please confirm at least one workflow is configured for this product.");return t.sort((e,a)=>(e.index??0)-(a.index??0)).map(e=>new Mt(e))}}const Se=v.gql`
2355
2407
  query GetCustomer($emailAddress: String!) {
2356
2408
  customer(emailAddress: $emailAddress) {
2357
2409
  id
@@ -2362,7 +2414,7 @@
2362
2414
  }
2363
2415
  }
2364
2416
  }
2365
- `,pc=v.gql`
2417
+ `,fc=v.gql`
2366
2418
  mutation CustomerCreate($details: CustomerDetailsInput!) {
2367
2419
  customerCreate(details: $details) {
2368
2420
  id
@@ -2402,7 +2454,7 @@
2402
2454
  }
2403
2455
  }
2404
2456
  }
2405
- `;const fc=v.gql`
2457
+ `;const Cc=v.gql`
2406
2458
  mutation CustomerGenerateVerificationCode($emailAddress: String!) {
2407
2459
  customerGenerateVerificationCode(emailAddress: $emailAddress)
2408
2460
  }
@@ -2437,7 +2489,7 @@
2437
2489
  }
2438
2490
  }
2439
2491
  }
2440
- `;const Cc=v.gql`
2492
+ `;const wc=v.gql`
2441
2493
  query CustomerMetafields($id: String!) {
2442
2494
  metafields(entityId: $id) {
2443
2495
  id
@@ -2455,7 +2507,7 @@
2455
2507
  }
2456
2508
  }
2457
2509
  }
2458
- `;class wc{constructor(t,e=B.getShadowGraphqlClient.bind(B)){this.options=t,this.client=e}query(t){var a,n;const e=(a=this.options)!=null&&a.onQuery?(n=this.options)==null?void 0:n.onQuery(t):{};return this.client().query({...e,...t,context:{...e.context??{},...t.context??{}}})}mutate(t){var a,n;const e=(a=this.options)!=null&&a.onMutate?(n=this.options)==null?void 0:n.onMutate(t):{};return this.client().mutate({...e,...t,context:{...e.context??{},...t.context??{}}})}}class yc{init(t,e,a){this.cognitoClient=new pe.CognitoIdentityProviderClient({region:e}),this.spiffRegion=t,this.userPoolClientId=a}async generateCode(t){var a;const e=await((a=this.cognitoClient)==null?void 0:a.send(new pe.InitiateAuthCommand({AuthFlow:"CUSTOM_AUTH",ClientId:this.userPoolClientId,AuthParameters:{USERNAME:t}})));(e==null?void 0:e.ChallengeName)==="CUSTOM_CHALLENGE"&&(this.challengeSession=e.Session)}async verifyCode(t,e,a){var i;const n=await((i=this.cognitoClient)==null?void 0:i.send(new pe.RespondToAuthChallengeCommand({ClientId:this.userPoolClientId,ChallengeName:"CUSTOM_CHALLENGE",Session:this.challengeSession,ChallengeResponses:{USERNAME:t,ANSWER:e},ClientMetadata:{partnerId:a,environment:(this.spiffRegion||"").toLowerCase()}})));return(n==null?void 0:n.ChallengeName)==="CUSTOM_CHALLENGE"&&(this.challengeSession=n.Session),n}async refreshTokens(){var a;const t=localStorage.getItem("cognito-tokens");if(!t)throw new Error("Failed to find existing tokens.");const e=JSON.parse(t);return await((a=this.cognitoClient)==null?void 0:a.send(new pe.InitiateAuthCommand({AuthFlow:"REFRESH_TOKEN_AUTH",ClientId:this.userPoolClientId,AuthParameters:{REFRESH_TOKEN:e.RefreshToken||""}})))}}const Wt=new yc;class qr{formatCurrencyForDisplay(t,e){const a={amount:e||0,currency:t,precision:this.getPrecisionForCurrency(t)};return ui(a).toFormat(this.getSpecialFormat(t))}getPrecisionForCurrency(t){const e=t,a=Ka.code(e);return a?a.digits:2}getSpecialFormat(t){const e=t,a=Ka.code(e);if((a==null?void 0:a.code)==="CLP")return"USD0,0"}}const un=new qr;class Wr{constructor(t,e,a,n){this.presentmentCurrency=void 0,this.presentmentCurrency=n,this.partnerCurrency=a,this.rateFrom=t,this.rateTo=e}code(){return this.presentmentCurrency?this.presentmentCurrency:this.partnerCurrency}conversionRequired(){return this.presentmentCurrency!==void 0&&this.code()!==this.partnerCurrency}getConvertedSubunits(t){return this.conversionRequired()?Math.ceil(this.subunits(this.units(t,this.partnerCurrency)/this.rateFrom*this.rateTo,this.code())):t}units(t,e){return t/Math.pow(10,un.getPrecisionForCurrency(e))}subunits(t,e){return t*Math.pow(10,un.getPrecisionForCurrency(e))}}const Sc=async(r,t)=>{var n;const e=await B.getShadowGraphqlClient().query({query:bs(((n=t==null?void 0:t.assets)==null?void 0:n.metadata)||!1),errorPolicy:"all",variables:{ids:r}});if(e.error)throw e.error;if(e.errors)throw e.errors.forEach(i=>console.error(i)),new Error("Unable to read workflows. Consult GraphQL errors.");const a=e.data.workflows;if(a===void 0||a.length!==r.length)throw new Error(`Unable to read workflows: ${e.errors??"Length mismatch in response"}`);return a.forEach(i=>{i.steps.forEach(s=>{var o,l,c;delete s.data.__typename,(o=s.option)!=null&&o.id&&((l=s.option.defaultVariant)!=null&&l.asset&&U.cacheAsset(s.option.defaultVariant.asset),s.option.colorProfile&&U.cacheAsset(s.option.colorProfile),(c=s.option.variants)==null||c.forEach(d=>{d.asset&&U.cacheAsset(d.asset),d.thumbnail&&U.cacheAsset(d.thumbnail),d.material&&U.cacheMaterial(d.material)}),Ot.set({id:s.option.id},Promise.resolve(s.option)))}),i.finalizeStepConfig||(i.finalizeStepConfig={}),i.finalizeStepConfig.termsMarkdown=i.finalizeStepConfig.termsMarkdown||i.partner.termsMarkdown}),a},vc=async(r,t)=>{const a=(await t).find(n=>n.id===r);if(!a)throw new Error(`Workflow not found: ${r}`);return a},ja=async(r,t)=>{const e=r.map(o=>Ot.get({id:o,options:t})),a=r.filter((o,l)=>e[l]===void 0);if(a.length===0)return Promise.all(e);const n=Sc(a,t),i=a.map(o=>Ot.set({id:o,options:t},vc(o,n))),s=e.filter(o=>o!==void 0);return await Promise.all(s.concat(i))},Ec=async(r,t)=>(await ja([r],t))[0],bc=r=>r.sort((t,e)=>t.index-e.index).map(t=>({id:Q(),panelId:t.name,name:t.name,title:t.title,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})),Bc=(r,t)=>{const e=r.workflowState,a=e?JSON.parse(e):void 0;return a?Object.values(a.layouts).map(n=>n.layout):bc(t.panels)};class Ic{constructor(t){this.activeIntegration=void 0,this.updateTransactionState=async e=>{try{return B.getShadowGraphqlClient().mutate({...e,mutation:us})}catch(a){throw console.error(a),new ht("Critical - Unable to synchronize workflow state with server.")}},this.options=t,this.options.applicationKey&&xi(this.options.applicationKey),console.debug("------------------------"),console.debug("Spiff Commerce Core SDK"),console.debug("Version: 29.3.0"),console.debug(`Application Key Provided: ${!!this.options.applicationKey}`),console.debug("------------------------")}configure(t){At.setHubUrl(t.hubUrl),At.setServerUrl(t.serverUrl),At.setServicesApiUrl(t.servicesApiUrl),this.marketplaceThemeInstallId=t.marketplaceThemeInstallId,this.marketplaceThemeInstallConfigurationId=t.marketplaceThemeInstallConfigurationId,this.userPoolClientId=t.userPoolClientId,this.userPoolRegion=t.userPoolRegion,this.spiffRegion=t.spiffRegion,t.bearerAuthenticationToken&&Rn(t.bearerAuthenticationToken),this.options.applicationKey&&this.getIntegration(),this.spiffRegion&&this.userPoolRegion&&this.userPoolClientId&&Wt.init(this.spiffRegion,this.userPoolRegion,this.userPoolClientId)}getAssetManager(){return U}getFlowService(){if(!Fi())throw new Error("Application key required to use Flow Service.");return new Vr}async getCurrencyContext(t){const a=(await this.getIntegration()).partner.currencyCode,i=await B.getShadowGraphqlClient().query({query:Ms,errorPolicy:"all",fetchPolicy:"cache-first",variables:{from:a,to:t}}),{rateFrom:s,rateTo:o}=i.data.currencyConversion;return new Wr(s,o,a,t)}async getIntegration(){if(this.activeIntegration)return this.activeIntegration;if(!this.options.applicationKey)throw new Error("Cannot get current Integration without specifying an Application Key.");return this.activeIntegration=jr(this.options.applicationKey),this.activeIntegration}async canUseAddon(t){var e;try{return((e=(await this.getIntegration()).partner.activeAddons)==null?void 0:e.includes(t))??!1}catch(a){return console.error(a),!1}}async authenticateBundleFromLocalStorage(t){var n,i;const e=N.getMap("bundleOwnerIds");if(e!=null&&e.has(t))return Promise.resolve({success:!0,stakeholderType:Zt.Owner});const a=N.getMap("bundlePartnerIds")||new Map;if(a.has(t)){const s=a.get(t);if((N.getMap("partnerCustomerIds")||new Map).get(s)&&await this.reloadLoggedInCustomer()){const d=(i=(n=this.customer)==null?void 0:n.bundleStakeholders)==null?void 0:i.find(A=>{var u;return((u=A.bundle)==null?void 0:u.id)===t});if(d)return Promise.resolve({success:!0,stakeholderType:d.type})}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){var d,A,u,h,g,m;const e=B.getShadowGraphqlClient(),a=await e.query({query:Bs,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!a.data.transactions||a.data.transactions.length===0)throw new Error(`Transaction not found: ${t}`);const n=a.data.transactions[0];if(!((A=(d=n.product)==null?void 0:d.partner)==null?void 0:A.id))throw new Error(`Unable to read transaction: ${t}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const s=N.getMap("transactionOwnerIds");if(s!=null&&s.has(t))return Promise.resolve({success:!0,stakeholderType:Zt.Owner});const o=N.getMap("transactionCustomerIds");if(o!=null&&o.has(t)&&o.get(t)&&await this.reloadLoggedInCustomer()){const C=((h=(u=this.customer)==null?void 0:u.bundleStakeholders)==null?void 0:h.find(w=>{var S,y;return(y=(S=w.bundle)==null?void 0:S.transactions)==null?void 0:y.some(E=>E.id===t)}))||((m=(g=this.customer)==null?void 0:g.stakeholders)==null?void 0:m.find(w=>{var S;return((S=w.transaction)==null?void 0:S.id)===t}));if(C)return Promise.resolve({success:!0,stakeholderType:C.type})}const c=(await e.query({query:Is,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!c)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:c.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=N.getMap("transactionCustomerIds");e!=null&&e.has(t)&&(e.delete(t),N.setMap("transactionCustomerIds",e))}async customerHasBundleTemplates(t){const n=(await B.getShadowGraphqlClient().query({query:Se,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;return n.id?n.hasBundleTemplates??!1:!1}getStakeholderTypeForTransaction(t){var a,n;const e=(n=(a=this.customer)==null?void 0:a.stakeholders)==null?void 0:n.find(i=>{var s;return((s=i.transaction)==null?void 0:s.id)===t});if(e)return e.type}async getOrCreateCustomer(t){var s;this.customer=void 0;const e=B.getShadowGraphqlClient(),n=(await e.query({query:Se,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!n.id){const l=(s=(await e.mutate({mutation:pc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data)==null?void 0:s.customerCreate;if(!l)throw new Error("Unable to create customer.");return this.storeCustomer(l),this.customer=l,{customer:l,isAuthenticated:!1}}this.storeCustomer(n);const i=await this.reloadLoggedInCustomer();return{customer:this.customer||n,isAuthenticated:i}}getCustomer(){return this.customer}async reloadLoggedInCustomer(){const t=localStorage.getItem("last-refreshed-cognito-tokens"),e=localStorage.getItem("cognito-tokens"),a=localStorage.getItem("cognito-email");if(!t||!e||!a)return!1;const n=JSON.parse(e),i=new Date().getTime()/1e3;if(!n.ExpiresIn||n.ExpiresIn<i-parseInt(t)){const l=await Wt.refreshTokens();if(l!=null&&l.AuthenticationResult)localStorage.setItem("last-refreshed-cognito-tokens",`${new Date().getTime()/1e3}`),n.AccessToken=l.AuthenticationResult.AccessToken,localStorage.setItem("cognito-tokens",JSON.stringify(n));else return this.logOut(),console.error("Failed to refresh tokens."),!1}const o=(await B.getShadowGraphqlClient().query({query:Se,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:a}})).data.customer;return o.id?(this.customer=o,!0):(console.error("Failed to get customer."),!1)}async generateVerificationCode(t){await B.getShadowGraphqlClient().mutate({mutation:fc,variables:{emailAddress:t}}),await Wt.generateCode(t)}async verifyCode(t,e){const a=(await this.getIntegration()).partner.id||"",n=await Wt.verifyCode(t,e,a);if(n!=null&&n.AuthenticationResult){localStorage.setItem("last-refreshed-cognito-tokens",`${new Date().getTime()/1e3}`),localStorage.setItem("cognito-tokens",JSON.stringify(n.AuthenticationResult)),localStorage.setItem("cognito-email",t);const s=(await B.getShadowGraphqlClient().query({query:Se,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!s.id)throw new Error("Failed to get customer.");return this.customer=s,!0}else throw new Error}async logOut(){localStorage.removeItem("last-refreshed-cognito-tokens"),localStorage.removeItem("cognito-tokens"),localStorage.removeItem("cognito-email"),this.clearCustomer()}async loggedInBearerToken(){const t=localStorage.getItem("last-refreshed-cognito-tokens"),e=localStorage.getItem("cognito-tokens");if(!t||!e)throw new Error("No token data in storage.");const a=JSON.parse(e),n=new Date().getTime()/1e3,i=!(a!=null&&a.AccessToken)||_t(a.AccessToken);if(!a.ExpiresIn||a.ExpiresIn<n-parseInt(t)||i){const s=await Wt.refreshTokens();if(s!=null&&s.AuthenticationResult)localStorage.setItem("last-refreshed-cognito-tokens",`${new Date().getTime()/1e3}`),a.AccessToken=s.AuthenticationResult.AccessToken,localStorage.setItem("cognito-tokens",JSON.stringify(a));else throw this.logOut(),new Error("Failed to refresh tokens.")}if(!a.AccessToken)throw new Error("No bearer token in storage.");return a.AccessToken}async getCustomerMetafields(){var e;if(!((e=this.customer)!=null&&e.id))throw new Error("Customer must be logged in before calling this function.");return(await B.getShadowGraphqlClient().query({query:Cc,variables:{id:this.customer.id}})).data.metafields}async getNewBundle(t,e,a){var c,d,A,u,h;const i=(A=(await B.getShadowGraphqlClient().mutate({mutation:el(((d=(c=a==null?void 0:a.graphql)==null?void 0:c.productCollection)==null?void 0:d.eagerFetchProducts)||!1),variables:{collectionId:t,initialMetadata:e?Object.entries(e).map((g,m)=>({key:g[0],value:g[1]})):void 0,marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId},fetchPolicy:"no-cache"})).data)==null?void 0:A.bundleCreate;if(!(i!=null&&i.id))throw new Error("Unable to create bundle");const s=N.getMap("bundlePartnerIds")||new Map;s.set(i.id,i.partner.id),N.setMap("bundlePartnerIds",s);const o=N.getMap("bundleOwnerIds")||new Map;o.set(i.id,i.bundleOwnerId),N.setMap("bundleOwnerIds",o);const l=new ea(this,i,void 0,void 0,i.bundleOwnerId,{eagerFetchProducts:(h=(u=a==null?void 0:a.graphql)==null?void 0:u.productCollection)==null?void 0:h.eagerFetchProducts});return await l.getInitializationPromise(),l}async getExistingBundle(t,e,a,n){var g,m,p,f,C,w,S,y,E,b,P;const i=N.getMap("bundleOwnerIds"),s=i==null?void 0:i.get(t),o={};try{const x=await this.loggedInBearerToken();o.Authorization=`Bearer ${x}`}catch{const M=((g=Object.entries(localStorage).find(([Z,R])=>Z.startsWith("CognitoIdentityServiceProvider")&&Z.endsWith("idToken")))==null?void 0:g[0])||"",T=localStorage.getItem(M);T&&!_t(T)&&(o.Authorization=`Bearer ${T}`)}const l={bundleOwnerId:s,...o,...(m=n==null?void 0:n.graphql)==null?void 0:m.additionalHeaders},c=await B.getShadowGraphqlClient().query({query:Ko(((f=(p=n==null?void 0:n.graphql)==null?void 0:p.productCollection)==null?void 0:f.eagerFetchProducts)||!1),variables:{id:t},fetchPolicy:"no-cache",context:{headers:l}});if(!((C=c.data)!=null&&C.bundles)||((w=c.data)==null?void 0:w.bundles.length)===0||!((S=c.data)!=null&&S.bundles[0]))throw new Error(`Unable to find bundle: ${t}`);const d=(y=c.data)==null?void 0:y.bundles[0],A=N.getMap("bundlePartnerIds")||new Map;A.set(d.id,d.partner.id),N.setMap("bundlePartnerIds",A);const u=new ea(this,d,e,a,s,{additionalHeaders:(E=n==null?void 0:n.graphql)==null?void 0:E.additionalHeaders,eagerFetchProducts:(P=(b=n==null?void 0:n.graphql)==null?void 0:b.productCollection)==null?void 0:P.eagerFetchProducts,existingGlobalPropertyState:c.data.globalPropertyState,readonly:n==null?void 0:n.readonly});await u.getInitializationPromise();const h=c.data.globalPropertyState;return h&&u.applyGlobalPropertyState(h),u}async duplicateBundle(t,e,a,n){var u,h,g,m,p,f;const i=(u=N.getMap("bundleOwnerIds"))==null?void 0:u.get(t),s={};try{const C=await this.loggedInBearerToken();s.Authorization=`Bearer ${C}`}catch{const S=((h=Object.entries(localStorage).find(([E,b])=>E.startsWith("CognitoIdentityServiceProvider")&&E.endsWith("idToken")))==null?void 0:h[0])||"",y=localStorage.getItem(S);y&&!_t(y)&&(s.Authorization=`Bearer ${y}`)}const o={bundleOwnerId:i,...s,...(g=n==null?void 0:n.graphql)==null?void 0:g.additionalHeaders},c=(f=(await B.getShadowGraphqlClient().mutate({mutation:al(((p=(m=n==null?void 0:n.graphql)==null?void 0:m.productCollection)==null?void 0:p.eagerFetchProducts)||!1),variables:{id:t,template:e,marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId,duplicateTransactions:a},context:{headers:o},fetchPolicy:"no-cache"})).data)==null?void 0:f.bundleDuplicate;if(!(c!=null&&c.id))throw new Error("Unable to duplicate bundle");const d=N.getMap("bundlePartnerIds")||new Map;d.set(c.id,c.partner.id),N.setMap("bundlePartnerIds",d);const A=N.getMap("bundleOwnerIds")||new Map;return A.set(c.id,c.bundleOwnerId),N.setMap("bundleOwnerIds",A),async()=>{var w,S;const C=new ea(this,c,void 0,void 0,c.bundleOwnerId,{eagerFetchProducts:(S=(w=n==null?void 0:n.graphql)==null?void 0:w.productCollection)==null?void 0:S.eagerFetchProducts,existingGlobalPropertyState:c.globalPropertyState});return await C.getInitializationPromise(),C}}async getBundlesForCustomer(t){var i;if(!((i=this.customer)!=null&&i.id))throw new Error("Customer not authenticated.");const{includeMetadata:e,...a}=t;return(await B.getShadowGraphqlClient().query({query:gl(e??!1),variables:{...a,id:this.customer.id},fetchPolicy:"no-cache"})).data.customerBundlesFeed}async getBundleStakeholders(){var i;if(!this.customer)throw new Error("Customer not authenticated.");const t=await B.getShadowGraphqlClient().query({query:_o,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!((i=t.data)!=null&&i.customers)||t.data.customers.length===0)throw new Error("Unable to find customer.");const a=t.data.customers[0].bundleStakeholders||[],n=N.getMap("bundlePartnerIds")||new Map;return a.forEach(s=>{var o,l;(o=s.bundle)!=null&&o.id&&((l=s.bundle.partner)!=null&&l.id)&&n.set(s.bundle.id,s.bundle.partner.id)}),N.setMap("bundlePartnerIds",n),a}async getWorkflowExperience(t,e){if(!t)throw new Error("getWorkflowExperience has been called without an options object! This is not supported.");const a=await this.getWorkflowExperiences([t],t.graphql),n=a[0];return e&&await n.getWorkflowManager().injectIntoPreviewService(e(n.getWorkflowManager().getWorkflow())),a[0]}async getWorkflowExperiences(t,e){if(t.length===0)throw new ht("No options provided!");const a=B.getShadowGraphqlClient(),n=async y=>{var x,F,M;if(y.length===0)return[];const E=y.map(T=>T.option.transactionId),b=await a.query({query:As,variables:{ids:E},errorPolicy:"all",fetchPolicy:"no-cache"}),P=b.data.transactions;if(P.length!==y.length){const T=((F=(x=b.errors)==null?void 0:x[0])==null?void 0:F.message)||"Unknown error";throw new ht(`Not all transactions were found: ${T}`)}return!this.activeIntegration&&((M=P[0].integrationProduct)!=null&&M.integration)&&(this.activeIntegration=Promise.resolve(P[0].integrationProduct.integration)),P.map((T,Z)=>{var R;return{transaction:T,workflowId:T.workflowId,readOnly:((R=y.find(at=>at.option.transactionId===T.id))==null?void 0:R.option.readOnly)??!1,index:y[Z].index}})},i=async y=>{var P,x,F;if(y.length===0)return[];const E=await a.mutate({mutation:ds,variables:{inputs:y.map(M=>({integrationProductId:M.option.type==="integration"?M.option.integrationProductId:void 0,externalIntegrationId:M.option.type==="external"?M.option.externalIntegrationId:void 0,externalProductId:M.option.type==="external"?M.option.externalProductId:void 0,workflowId:M.option.workflowId,designName:M.option.designName,claim:!0})),marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId},errorPolicy:"all",fetchPolicy:"no-cache"}),b=(P=E.data)==null?void 0:P.transactionCreateMany;if(!b||b.length===0){const M=((F=(x=E.errors)==null?void 0:x[0])==null?void 0:F.message)||"Unknown error";throw new ht(`Failed to create transactions: ${M}`)}return b.map((M,T)=>({transaction:M,workflowId:M.workflowId,readOnly:!1,index:y[T].index}))},s=t.map((y,E)=>({option:y,index:E})),o=s.filter(y=>y.option.type==="transaction"),l=s.filter(y=>y.option.type==="integration"||y.option.type==="external"),c=Ja(o,10),d=Ja(l,10),A=(await Promise.all([...c.map(n),...d.map(i)])).flat(),u=[...new Set(A.map(y=>y.workflowId))],h=await ja(u,e),g=new Map(h.map(y=>[y.id,y])),m=N.getMap("transactionOwnerIds")||new Map,p=A.map(async y=>{var at;const{transaction:E,workflowId:b,readOnly:P,index:x}=y,F=g.get(b),M=t[x];!m.get(E.id)&&E.transactionOwnerId&&m.set(E.id,E.transactionOwnerId);const T=m.get(E.id)||void 0,Z=new wc({onMutate:()=>({context:{transactionOwnerId:T,bundleOwnerId:e==null?void 0:e.bundleOwnerId}}),onQuery:()=>({context:{transactionOwnerId:T,bundleOwnerId:e==null?void 0:e.bundleOwnerId}})}),R={product:E.product,transaction:E,layouts:[],singleVariantsRenderable:(at=M==null?void 0:M.workflowConfiguration)==null?void 0:at.singleVariantsRenderable,stateMutationFunc:P?async()=>{throw new z("State mutation is forbidden in read only mode!")}:async tt=>this.updateTransactionState({...tt,context:{transactionOwnerId:T,bundleOwnerId:e==null?void 0:e.bundleOwnerId}}),graphQlClient:()=>Z,readOnly:P,workflow:F,isReloadedTransaction:M.type==="transaction"};if(!P&&M.workflowState){const tt=JSON.parse(M.workflowState);R.layouts=Object.values(tt.layouts||{}).map(Ut=>Ut.layout),await or(tt),R.reloadedState=tt}else R.layouts=Bc(R.transaction,R.workflow);return R.renderableContextService=new Hl(R.layouts),R.delayWorkflowStateSync=!0,{experienceOptions:R,index:x,options:M}}),f=await Promise.all(p);N.setMap("transactionOwnerIds",m);const w=f.sort((y,E)=>y.index-E.index).map(async y=>{const{experienceOptions:E,options:b}=y,P=new Mr(this,E);return await P.getWorkflowManager().getInitializationPromise(),b.type!=="transaction"&&this.customer&&await P.attachCustomerDetails({email:this.customer.emailAddress}),P}),S=await Promise.all(w);return S.forEach(y=>y.getWorkflowManager().setWorkflowStateSyncEnabled(!0)),S}storeCustomer(t){const e=N.getMap("partnerCustomerIds")||new Map;e.set(t.partner.id,t.id),N.setMap("partnerCustomerIds",e)}async getIntegrationProductById(t,e){var s,o;const i=(s=(await B.getShadowGraphqlClient().query({query:ps(e),variables:{ids:[t]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:s.integrationProducts;if(!i||i.length===0||!((o=i[0])!=null&&o.id))throw new Error("Integration product not found.");return new wa(i[0])}async getIntegrationProductFromExternalIds(t,e,a){var o;const s=(o=(await B.getShadowGraphqlClient().query({query:fs(a),variables:{externalProductId:e,externalIntegrationId:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:o.integrationProductFromExternalIds;if(!(s!=null&&s.id))throw new Error("Integration product not found.");return new wa(s)}async getIntegrationProduct(t){return t.type==="integration"?this.getIntegrationProductById(t.integrationProductId):this.getIntegrationProductFromExternalIds(t.externalIntegrationId,t.externalProductId)}async getShareActionsForTransaction(t){const a=(N.getMap("transactionOwnerIds")||new Map).get(t)||void 0,n=await B.getShadowGraphqlClient().query({query:ms,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t},context:{transactionOwnerId:a}});if(!n.data.transactions||n.data.transactions.length!==1)throw new Error(`Failed to fetch share actions for transaction: ${t}`);return n.data.transactions[0].transactionShareActions}async placeOrder(t){const e=await B.getShadowGraphqlClient().mutate({mutation:ks,variables:{orderItems:t}});if(e.errors)throw new Error(e.errors[0].message);if(!e.data)throw new Error("Failed to create order: No order data in response.");return{id:e.data.orderCreate.id,internalId:e.data.orderCreate.internalId}}}const jr=async(r,t)=>(await B.getShadowGraphqlClient().query({query:Ds,errorPolicy:"all",fetchPolicy:"no-cache",context:{headers:{"x-application-key":r}},variables:{themeConfigurationId:t}})).data.currentIntegration,Pc=async r=>{const e=await B.getShadowGraphqlClient().query({query:gs,errorPolicy:"all",fetchPolicy:"network-only",variables:{id:r}});if(e.data.transactions.length!==0)return e.data.transactions[0]},Dc=async(r,t)=>{var a;return(a=(await B.getShadowGraphqlClient().query({query:Ps,errorPolicy:"all",variables:{themeConfigurationId:r,themeInstallId:t}})).data)==null?void 0:a.marketplaceThemeInstallConfiguration},xc=async r=>{var e,a,n;return(n=(a=(e=(await B.getShadowGraphqlClient().query({query:Fs,errorPolicy:"all",variables:{id:r}})).data)==null?void 0:e.bundles)==null?void 0:a[0])==null?void 0:n.marketplaceThemeInstallConfiguration},Fc=async r=>{var e,a,n;return(n=(a=(e=(await B.getShadowGraphqlClient().query({query:xs,errorPolicy:"all",variables:{id:r}})).data)==null?void 0:e.transactions)==null?void 0:a[0])==null?void 0:n.marketplaceThemeInstallConfiguration};function Hr(r,t,e,a){const n=e.width*r.zoom,i=e.height*r.zoom;if(a){const o=r,l=Math.max(t.width/e.width,t.height/e.height);o.zoom=Math.max(l,r.zoom);const c=e.width*o.zoom,d=e.height*o.zoom;return o.x=ve(r.x,t.width-c,0),o.y=ve(r.y,t.height-d,0),o}const s=r;return s.x=ve(s.x,-n,t.width),s.y=ve(s.y,-i,t.height),s}function ve(r,t,e){return Math.min(Math.max(r,t),e)}class Yr{constructor(t,e){this.minZoomScale=[.03],this.maxZoomScale=[20],this._debouncedUpdateFrameOffsets=En(this.updateFrameOffsets,200),this.targetElements=[],this.onFrameDataChangeListeners=[],this.onZoomChangeListeners=[],this.forceImageCover=t,this.initialZoom=e,this.thresholdSettings={useThreshold:!1,invertThreshold:!1,threshold:128,thresholdSaturation:.5}}connectWorkflowManager(t,e){e&&t.addStepSpecificStorageCallback(async a=>{if(a){const n=a;if(n.currentFrameSources){let i=!1;for(let s=0;s<n.currentFrameSources.length;s++){const o=n.currentFrameSources[s],l=await ue(o),c=this.frameData?this.frameData[s]:void 0;vn(l,c)||(this.frameData||(this.frameData=new Array(n.currentFrameSources.length)),this.frameData[s]=l,i=!0)}i&&(this.onFrameDataChangeListeners.forEach(s=>s(this.frameData)),this.frameData&&this.imageData&&(this.recalculateOffsets(this.imageData),this.updateOffsets(this.offsets),this.recalculateZoomLimits(this.imageData,this.frameData)))}}},e),this.workflowManager=t,this.stepName=e}setTargetElements(t){this.targetElements=t}getFrameData(){return this.frameData}setFrameData(t){if(!t){this.frameData=void 0;return}t.forEach((e,a)=>{const n=Ft.get(e);n&&(this.frameData||(this.frameData=new Array(t.length)),this.frameData[a]=n)})}getImageData(){return this.imageData}getImageSrc(){if(this.imageData){if(this.imageData.svg){const t=Ue(this.imageData.svg,this.imageData.colors||{},!1);return Oe(t)}return this.imageData.src}}getOffsets(){return this.offsets}setOffsets(t){this.offsets=t}setZoom(t,e,a,n){if(this.imageData&&this.offsets&&this.frameData){(!this.offsets||this.offsets.length!==this.frameData.length)&&(this.offsets=new Array(this.frameData.length));const i=this.frameData.map((s,o)=>{const l=(e[o]-this.offsets[o].x)/this.offsets[o].zoom,c=(a[o]-this.offsets[o].y)/this.offsets[o].zoom,d=e[o]-l*t[o],A=a[o]-c*t[o];return{x:d,y:A,zoom:this.imageData.width*t[o]/this.imageData.width}});this.updateOffsets(i,n),this.onZoomChangeListeners.forEach(s=>s(t))}}setPatternData(t,e=!0){this.imageData=t,t&&this.frameData&&((e||!this.offsets)&&this.recalculateOffsets(t),this.updateOffsets(this.offsets,void 0,!0)),this.imageData&&this.frameData&&this.recalculateZoomLimits(this.imageData,this.frameData)}updateOffsets(t,e,a){const n=this.imageData;if(!n||!this.frameData)return;if(this.frameData.length!==t.length)throw new z("Frame data and offsets are not the same length. This is a bug. Please report it.");if(!this.offsets.some((s,o)=>!(t[o].x===s.x&&t[o].y===s.y&&t[o].zoom===s.zoom))&&!a){e&&e();return}(!this.offsets||this.offsets.length!==this.frameData.length)&&(this.offsets=new Array(this.frameData.length)),this.frameData.forEach((s,o)=>{this.offsets[o]=Hr(t[o],s,this.imageData,this.forceImageCover)}),this._debouncedUpdateFrameOffsets(this.offsets,n,this.frameData,this.thresholdSettings,e)}getThresholdSettings(){return this.thresholdSettings}setThresholdSettings(t){this.thresholdSettings=t,this.imageData&&this.frameData&&this._debouncedUpdateFrameOffsets(this.offsets,this.imageData,this.frameData,t)}onFrameDataChanged(t){t(this.frameData),this.onFrameDataChangeListeners.push(t)}onZoom(t){this.onZoomChangeListeners.push(t)}updateFrameOffsets(t,e,a,n,i){if(!a||a.length===0||a.some(o=>!o))throw new z("Frame data not set. This is a bug");if(!this.workflowManager)throw new z("No workflow manager set, cannot update offsets.");const s=this.workflowManager.getCommandDispatcher();this.targetElements.forEach((o,l)=>{s(new $([new fo(o,e,t[l]),new Co(o,n.useThreshold,n.invertThreshold,n.threshold,n.thresholdSaturation)]))}),this.stepName&&this.workflowManager.updateStorage(this.stepName,{frameOffsetsList:t}),i&&i()}recalculateZoomLimits(t,e){(this.minZoomScale.length!==e.length||this.maxZoomScale.length!==e.length)&&(this.minZoomScale=new Array(e.length),this.maxZoomScale=new Array(e.length)),e.forEach((a,n)=>{const i=Math.max(a.width/t.width,a.height/t.height);this.forceImageCover?(this.minZoomScale[n]=i,this.maxZoomScale[n]=i*2.5):(this.minZoomScale[n]=i/10,this.maxZoomScale[n]=i*2.5)})}recalculateOffsets(t){this.frameData&&((!this.offsets||this.offsets.length!==this.frameData.length)&&(this.offsets=new Array(this.frameData.length)),this.frameData.forEach((e,a)=>{this.offsets[a]=ka(t,e,this.initialZoom&&!this.forceImageCover?{scale:this.initialZoom}:void 0,this.forceImageCover)}),this._debouncedUpdateFrameOffsets(this.offsets,t,this.frameData,this.thresholdSettings))}}class kc{updateRecipient(t,e,a,n,i,s,o,l,c,d){throw new Error("Method not implemented.")}approveTransaction(t){throw new Error("Method not implemented.")}rejectTransaction(t){throw new Error("Method not implemented.")}getClient(){return this.client??{}}getWorkflowExperience(){return{}}setClient(t){this.client=t}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}async reset(){}updateStateWithServer(t){}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}getStepSelections(){return{}}setCurrentAdjustingStepId(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,a){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}setWorkflowStateSyncEnabled(t){}async updateTransactionShareActions(){}addValidationCallback(t){}setStepError(t,e,a){}getStepErrors(t){}getValidationErrors(){return{steps:new Map}}async updateTransactionStakeholders(){}getStepTags(t){return[]}}var Jr=(r=>(r.SelectFrame="SelectFrame",r.SelectImage="SelectImage",r.Position="Position",r))(Jr||{});class Kr extends rt{constructor(t,e,a){super(t,e,a);const n=e.data;this.frameService=new Yr(n.forceImageCover,n.initialZoomLevel),this.frameService.connectWorkflowManager(t,e.stepName)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return ut.selectVariant(this.step,t.getResource(),e,this.manager,a=>this.setUpdateState(a))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged(e=>{e&&t(e)})}async selectImage(t,e=!0,a=!0){var n;if(await ut.selectImage(this.step,t,this.manager,a),e){const i=((n=this.manager.getStepStorage(this.step.stepName))==null?void 0:n.framePatternData)||{};this.manager.updateStorage(this.step.stepName,{framePatternData:{...i,originalAssetKey:t.key,backgroundRemovedAssetKey:void 0,useOriginalAsset:void 0}})}}async canUseBackgroundRemover(){return this.manager.getClient().canUseAddon(Me.BackgroundRemover)}async canRemoveBackground(){var t,e,a,n;return await this.canUseBackgroundRemover()&&this.hasOriginalImageSelection()&&!!((e=(t=this.frameService)==null?void 0:t.getImageData())!=null&&e.src)&&!((n=(a=this.frameService)==null?void 0:a.getImageData())!=null&&n.svg)}async removeBackgroundFromImageSelection(t=!0){var i;if(!await this.canUseBackgroundRemover())throw new Error("The current Integration does not have access to the Background Remover. Please call canUseBackgroundRemover to ensure you disable this feature when appropriate.");const e=await this.getOriginalImageSelection();if(!e)throw new Error("You must supply an image selection before attempting to remove the background.");const a=await U.removeBackgroundFromAsset(e);t&&await ut.selectImage(this.step,a,this.manager,!1);const n=((i=this.manager.getStepStorage(this.step.stepName))==null?void 0:i.framePatternData)||{};return this.manager.updateStorage(this.step.stepName,{framePatternData:{...n,backgroundRemovedAssetKey:a.key,useOriginalAsset:!t}}),a}changeColors(t){ut.changeColors(this.step,this.manager,t)}getImageData(){if(this.frameService)return this.frameService.getImageData()}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?ut.availableColors(this.step,this.manager):Promise.resolve([])}isColorPickerEnabled(){return this.step.data.colorPickerEnabled??!1}async getOriginalImageColors(){const t=this.getImageData();return t!=null&&t.svg?(await ot(t.svg)).colors:void 0}getMaxAllowedColors(){return this.step.data.maxColors}getUniqueColorCount(){return ut.getUniqueColorCount(this.step,this.manager)}getCurrentFrameStep(t,e,a,n){return n&&n.length>1&&t===void 0?"SelectFrame":e||a||this.getImageData()?"Position":"SelectImage"}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}getWhitelistedExtensions(){return[...this.step.data.whitelistedExtensions,...this.step.data.whitelistedExtensions.includes(".jpg")?[".jpeg"]:[]]}async getOriginalImageSelection(){var e,a;const t=(a=(e=this.manager.getStepStorage(this.step.stepName))==null?void 0:e.framePatternData)==null?void 0:a.originalAssetKey;if(t)return U.getLocalOrFromServer(t)}async getBackgroundRemovedImageSelection(){var e,a;const t=(a=(e=this.manager.getStepStorage(this.step.stepName))==null?void 0:e.framePatternData)==null?void 0:a.backgroundRemovedAssetKey;if(t)return U.getLocalOrFromServer(t)}hasOriginalImageSelection(){var t,e;return!!((e=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.framePatternData)!=null&&e.originalAssetKey)}hasBackgroundRemovedImageSelection(){var t,e;return!!((e=(t=this.getFrameStepStorage())==null?void 0:t.framePatternData)!=null&&e.backgroundRemovedAssetKey)}getUseOriginalImageSelection(){var t,e;return((e=(t=this.getFrameStepStorage())==null?void 0:t.framePatternData)==null?void 0:e.useOriginalAsset)??!1}async setUseOriginalImageSelection(t){var n;const e=((n=this.getFrameStepStorage())==null?void 0:n.framePatternData)||{};if(e.useOriginalAsset===t)return;const a=await this.getOriginalImageSelection();if(!a)throw new Error("You must provide an image selection before calling setUseOriginalImageSelection");if(t)await this.selectImage(a,!1,!1);else{const i=await this.getBackgroundRemovedImageSelection();if(!i)throw new Error("You must call removeBackgroundFromImageSelection before attempting to apply the image.");await this.selectImage(i,!1,!1)}this.manager.updateStorage(this.step.stepName,{framePatternData:{...e,useOriginalAsset:t}})}getFrameStepStorage(){return this.manager.getStepStorage(this.step.stepName)}}const Mc=v.gql`
2510
+ `;class yc{constructor(t,e=B.getShadowGraphqlClient.bind(B)){this.options=t,this.client=e}query(t){var a,n;const e=(a=this.options)!=null&&a.onQuery?(n=this.options)==null?void 0:n.onQuery(t):{};return this.client().query({...e,...t,context:{...e.context??{},...t.context??{}}})}mutate(t){var a,n;const e=(a=this.options)!=null&&a.onMutate?(n=this.options)==null?void 0:n.onMutate(t):{};return this.client().mutate({...e,...t,context:{...e.context??{},...t.context??{}}})}}class Sc{init(t,e,a){this.cognitoClient=new pe.CognitoIdentityProviderClient({region:e}),this.spiffRegion=t,this.userPoolClientId=a}async generateCode(t){var a;const e=await((a=this.cognitoClient)==null?void 0:a.send(new pe.InitiateAuthCommand({AuthFlow:"CUSTOM_AUTH",ClientId:this.userPoolClientId,AuthParameters:{USERNAME:t}})));(e==null?void 0:e.ChallengeName)==="CUSTOM_CHALLENGE"&&(this.challengeSession=e.Session)}async verifyCode(t,e,a){var i;const n=await((i=this.cognitoClient)==null?void 0:i.send(new pe.RespondToAuthChallengeCommand({ClientId:this.userPoolClientId,ChallengeName:"CUSTOM_CHALLENGE",Session:this.challengeSession,ChallengeResponses:{USERNAME:t,ANSWER:e},ClientMetadata:{partnerId:a,environment:(this.spiffRegion||"").toLowerCase()}})));return(n==null?void 0:n.ChallengeName)==="CUSTOM_CHALLENGE"&&(this.challengeSession=n.Session),n}async refreshTokens(){var a;const t=localStorage.getItem("cognito-tokens");if(!t)throw new Error("Failed to find existing tokens.");const e=JSON.parse(t);return await((a=this.cognitoClient)==null?void 0:a.send(new pe.InitiateAuthCommand({AuthFlow:"REFRESH_TOKEN_AUTH",ClientId:this.userPoolClientId,AuthParameters:{REFRESH_TOKEN:e.RefreshToken||""}})))}}const Wt=new Sc;class Wr{formatCurrencyForDisplay(t,e){const a={amount:e||0,currency:t,precision:this.getPrecisionForCurrency(t)};return ui(a).toFormat(this.getSpecialFormat(t))}getPrecisionForCurrency(t){const e=t,a=_a.code(e);return a?a.digits:2}getSpecialFormat(t){const e=t,a=_a.code(e);if((a==null?void 0:a.code)==="CLP")return"USD0,0"}}const hn=new Wr;class jr{constructor(t,e,a,n){this.presentmentCurrency=void 0,this.presentmentCurrency=n,this.partnerCurrency=a,this.rateFrom=t,this.rateTo=e}code(){return this.presentmentCurrency?this.presentmentCurrency:this.partnerCurrency}conversionRequired(){return this.presentmentCurrency!==void 0&&this.code()!==this.partnerCurrency}getConvertedSubunits(t){return this.conversionRequired()?Math.ceil(this.subunits(this.units(t,this.partnerCurrency)/this.rateFrom*this.rateTo,this.code())):t}units(t,e){return t/Math.pow(10,hn.getPrecisionForCurrency(e))}subunits(t,e){return t*Math.pow(10,hn.getPrecisionForCurrency(e))}}const vc=async(r,t)=>{var n;const e=await B.getShadowGraphqlClient().query({query:Bs(((n=t==null?void 0:t.assets)==null?void 0:n.metadata)||!1),errorPolicy:"all",variables:{ids:r}});if(e.error)throw e.error;if(e.errors)throw e.errors.forEach(i=>console.error(i)),new Error("Unable to read workflows. Consult GraphQL errors.");const a=e.data.workflows;if(a===void 0||a.length!==r.length)throw new Error(`Unable to read workflows: ${e.errors??"Length mismatch in response"}`);return a.forEach(i=>{i.steps.forEach(s=>{var o,l,c;delete s.data.__typename,(o=s.option)!=null&&o.id&&((l=s.option.defaultVariant)!=null&&l.asset&&U.cacheAsset(s.option.defaultVariant.asset),s.option.colorProfile&&U.cacheAsset(s.option.colorProfile),(c=s.option.variants)==null||c.forEach(d=>{d.asset&&U.cacheAsset(d.asset),d.thumbnail&&U.cacheAsset(d.thumbnail),d.material&&U.cacheMaterial(d.material)}),Ot.set({id:s.option.id},Promise.resolve(s.option)))}),i.finalizeStepConfig||(i.finalizeStepConfig={}),i.finalizeStepConfig.termsMarkdown=i.finalizeStepConfig.termsMarkdown||i.partner.termsMarkdown}),a},Ec=async(r,t)=>{const a=(await t).find(n=>n.id===r);if(!a)throw new Error(`Workflow not found: ${r}`);return a},ja=async(r,t)=>{const e=r.map(o=>Ot.get({id:o,options:t})),a=r.filter((o,l)=>e[l]===void 0);if(a.length===0)return Promise.all(e);const n=vc(a,t),i=a.map(o=>Ot.set({id:o,options:t},Ec(o,n))),s=e.filter(o=>o!==void 0);return await Promise.all(s.concat(i))},bc=async(r,t)=>(await ja([r],t))[0],Bc=r=>r.sort((t,e)=>t.index-e.index).map(t=>({id:Q(),panelId:t.name,name:t.name,title:t.title,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})),Ic=(r,t)=>{const e=r.workflowState,a=e?JSON.parse(e):void 0;return a?Object.values(a.layouts).map(n=>n.layout):Bc(t.panels)};class Pc{constructor(t){this.activeIntegration=void 0,this.updateTransactionState=async e=>{try{return B.getShadowGraphqlClient().mutate({...e,mutation:us})}catch(a){throw console.error(a),new ht("Critical - Unable to synchronize workflow state with server.")}},this.options=t,this.options.applicationKey&&Di(this.options.applicationKey),console.debug("------------------------"),console.debug("Spiff Commerce Core SDK"),console.debug("Version: 30.0.0-beta.4d4ae719-ccda-5077-afdb-40af4c28b3d3"),console.debug(`Application Key Provided: ${!!this.options.applicationKey}`),console.debug("------------------------")}configure(t){At.setHubUrl(t.hubUrl),At.setServerUrl(t.serverUrl),At.setServicesApiUrl(t.servicesApiUrl),this.marketplaceThemeInstallId=t.marketplaceThemeInstallId,this.marketplaceThemeInstallConfigurationId=t.marketplaceThemeInstallConfigurationId,this.userPoolClientId=t.userPoolClientId,this.userPoolRegion=t.userPoolRegion,this.spiffRegion=t.spiffRegion,t.bearerAuthenticationToken&&On(t.bearerAuthenticationToken),this.options.applicationKey&&this.getIntegration(),this.spiffRegion&&this.userPoolRegion&&this.userPoolClientId&&Wt.init(this.spiffRegion,this.userPoolRegion,this.userPoolClientId)}getAssetManager(){return U}getFlowService(){if(!xi())throw new Error("Application key required to use Flow Service.");return new zr}async getCurrencyContext(t){const a=(await this.getIntegration()).partner.currencyCode,i=await B.getShadowGraphqlClient().query({query:Ts,errorPolicy:"all",fetchPolicy:"cache-first",variables:{from:a,to:t}}),{rateFrom:s,rateTo:o}=i.data.currencyConversion;return new jr(s,o,a,t)}async getIntegration(){if(this.activeIntegration)return this.activeIntegration;if(!this.options.applicationKey)throw new Error("Cannot get current Integration without specifying an Application Key.");return this.activeIntegration=Hr(this.options.applicationKey),this.activeIntegration}async canUseAddon(t){var e;try{return((e=(await this.getIntegration()).partner.activeAddons)==null?void 0:e.includes(t))??!1}catch(a){return console.error(a),!1}}async authenticateBundleFromLocalStorage(t){var n,i;const e=T.getMap("bundleOwnerIds");if(e!=null&&e.has(t))return Promise.resolve({success:!0,stakeholderType:Zt.Owner});const a=T.getMap("bundlePartnerIds")||new Map;if(a.has(t)){const s=a.get(t);if((T.getMap("partnerCustomerIds")||new Map).get(s)&&await this.reloadLoggedInCustomer()){const d=(i=(n=this.customer)==null?void 0:n.bundleStakeholders)==null?void 0:i.find(A=>{var u;return((u=A.bundle)==null?void 0:u.id)===t});if(d)return Promise.resolve({success:!0,stakeholderType:d.type})}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){var d,A,u,h,g,m;const e=B.getShadowGraphqlClient(),a=await e.query({query:Is,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!a.data.transactions||a.data.transactions.length===0)throw new Error(`Transaction not found: ${t}`);const n=a.data.transactions[0];if(!((A=(d=n.product)==null?void 0:d.partner)==null?void 0:A.id))throw new Error(`Unable to read transaction: ${t}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const s=T.getMap("transactionOwnerIds");if(s!=null&&s.has(t))return Promise.resolve({success:!0,stakeholderType:Zt.Owner});const o=T.getMap("transactionCustomerIds");if(o!=null&&o.has(t)&&o.get(t)&&await this.reloadLoggedInCustomer()){const C=((h=(u=this.customer)==null?void 0:u.bundleStakeholders)==null?void 0:h.find(w=>{var S,y;return(y=(S=w.bundle)==null?void 0:S.transactions)==null?void 0:y.some(E=>E.id===t)}))||((m=(g=this.customer)==null?void 0:g.stakeholders)==null?void 0:m.find(w=>{var S;return((S=w.transaction)==null?void 0:S.id)===t}));if(C)return Promise.resolve({success:!0,stakeholderType:C.type})}const c=(await e.query({query:Ps,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!c)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:c.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=T.getMap("transactionCustomerIds");e!=null&&e.has(t)&&(e.delete(t),T.setMap("transactionCustomerIds",e))}async customerHasBundleTemplates(t){const n=(await B.getShadowGraphqlClient().query({query:Se,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;return n.id?n.hasBundleTemplates??!1:!1}getStakeholderTypeForTransaction(t){var a,n;const e=(n=(a=this.customer)==null?void 0:a.stakeholders)==null?void 0:n.find(i=>{var s;return((s=i.transaction)==null?void 0:s.id)===t});if(e)return e.type}async getOrCreateCustomer(t){var s;this.customer=void 0;const e=B.getShadowGraphqlClient(),n=(await e.query({query:Se,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!n.id){const l=(s=(await e.mutate({mutation:fc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data)==null?void 0:s.customerCreate;if(!l)throw new Error("Unable to create customer.");return this.storeCustomer(l),this.customer=l,{customer:l,isAuthenticated:!1}}this.storeCustomer(n);const i=await this.reloadLoggedInCustomer();return{customer:this.customer||n,isAuthenticated:i}}getCustomer(){return this.customer}async reloadLoggedInCustomer(){const t=localStorage.getItem("last-refreshed-cognito-tokens"),e=localStorage.getItem("cognito-tokens"),a=localStorage.getItem("cognito-email");if(!t||!e||!a)return!1;const n=JSON.parse(e),i=new Date().getTime()/1e3;if(!n.ExpiresIn||n.ExpiresIn<i-parseInt(t)){const l=await Wt.refreshTokens();if(l!=null&&l.AuthenticationResult)localStorage.setItem("last-refreshed-cognito-tokens",`${new Date().getTime()/1e3}`),n.AccessToken=l.AuthenticationResult.AccessToken,localStorage.setItem("cognito-tokens",JSON.stringify(n));else return this.logOut(),console.error("Failed to refresh tokens."),!1}const o=(await B.getShadowGraphqlClient().query({query:Se,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:a}})).data.customer;return o.id?(this.customer=o,!0):(console.error("Failed to get customer."),!1)}async generateVerificationCode(t){await B.getShadowGraphqlClient().mutate({mutation:Cc,variables:{emailAddress:t}}),await Wt.generateCode(t)}async verifyCode(t,e){const a=(await this.getIntegration()).partner.id||"",n=await Wt.verifyCode(t,e,a);if(n!=null&&n.AuthenticationResult){localStorage.setItem("last-refreshed-cognito-tokens",`${new Date().getTime()/1e3}`),localStorage.setItem("cognito-tokens",JSON.stringify(n.AuthenticationResult)),localStorage.setItem("cognito-email",t);const s=(await B.getShadowGraphqlClient().query({query:Se,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!s.id)throw new Error("Failed to get customer.");return this.customer=s,!0}else throw new Error}async logOut(){localStorage.removeItem("last-refreshed-cognito-tokens"),localStorage.removeItem("cognito-tokens"),localStorage.removeItem("cognito-email"),this.clearCustomer()}async loggedInBearerToken(){const t=localStorage.getItem("last-refreshed-cognito-tokens"),e=localStorage.getItem("cognito-tokens");if(!t||!e)throw new Error("No token data in storage.");const a=JSON.parse(e),n=new Date().getTime()/1e3,i=!(a!=null&&a.AccessToken)||_t(a.AccessToken);if(!a.ExpiresIn||a.ExpiresIn<n-parseInt(t)||i){const s=await Wt.refreshTokens();if(s!=null&&s.AuthenticationResult)localStorage.setItem("last-refreshed-cognito-tokens",`${new Date().getTime()/1e3}`),a.AccessToken=s.AuthenticationResult.AccessToken,localStorage.setItem("cognito-tokens",JSON.stringify(a));else throw this.logOut(),new Error("Failed to refresh tokens.")}if(!a.AccessToken)throw new Error("No bearer token in storage.");return a.AccessToken}async getCustomerMetafields(){var e;if(!((e=this.customer)!=null&&e.id))throw new Error("Customer must be logged in before calling this function.");return(await B.getShadowGraphqlClient().query({query:wc,variables:{id:this.customer.id}})).data.metafields}async getNewBundle(t,e,a){var c,d,A,u,h;const i=(A=(await B.getShadowGraphqlClient().mutate({mutation:al(((d=(c=a==null?void 0:a.graphql)==null?void 0:c.productCollection)==null?void 0:d.eagerFetchProducts)||!1),variables:{collectionId:t,initialMetadata:e?Object.entries(e).map((g,m)=>({key:g[0],value:g[1]})):void 0,marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId},fetchPolicy:"no-cache"})).data)==null?void 0:A.bundleCreate;if(!(i!=null&&i.id))throw new Error("Unable to create bundle");const s=T.getMap("bundlePartnerIds")||new Map;s.set(i.id,i.partner.id),T.setMap("bundlePartnerIds",s);const o=T.getMap("bundleOwnerIds")||new Map;o.set(i.id,i.bundleOwnerId),T.setMap("bundleOwnerIds",o);const l=new ea(this,i,void 0,void 0,i.bundleOwnerId,{eagerFetchProducts:(h=(u=a==null?void 0:a.graphql)==null?void 0:u.productCollection)==null?void 0:h.eagerFetchProducts});return await l.getInitializationPromise(),l}async getExistingBundle(t,e,a,n){var h,g,m,p,f,C,w,S,y,E,b;const i=T.getMap("bundleOwnerIds"),s=i==null?void 0:i.get(t),o={};try{const P=await this.loggedInBearerToken();o.Authorization=`Bearer ${P}`}catch{const x=((h=Object.entries(localStorage).find(([N,rt])=>N.startsWith("CognitoIdentityServiceProvider")&&N.endsWith("idToken")))==null?void 0:h[0])||"",k=localStorage.getItem(x);k&&!_t(k)&&(o.Authorization=`Bearer ${k}`)}const l={bundleOwnerId:s,...o,...(g=n==null?void 0:n.graphql)==null?void 0:g.additionalHeaders},c=await B.getShadowGraphqlClient().query({query:_o(((p=(m=n==null?void 0:n.graphql)==null?void 0:m.productCollection)==null?void 0:p.eagerFetchProducts)||!1),variables:{id:t},fetchPolicy:"no-cache",context:{headers:l}});if(!((f=c.data)!=null&&f.bundles)||((C=c.data)==null?void 0:C.bundles.length)===0||!((w=c.data)!=null&&w.bundles[0]))throw new Error(`Unable to find bundle: ${t}`);const d=(S=c.data)==null?void 0:S.bundles[0],A=T.getMap("bundlePartnerIds")||new Map;A.set(d.id,d.partner.id),T.setMap("bundlePartnerIds",A);const u=new ea(this,d,e,a,s,{additionalHeaders:(y=n==null?void 0:n.graphql)==null?void 0:y.additionalHeaders,eagerFetchProducts:(b=(E=n==null?void 0:n.graphql)==null?void 0:E.productCollection)==null?void 0:b.eagerFetchProducts,existingGlobalPropertyState:c.data.globalPropertyState,readonly:n==null?void 0:n.readonly});return await u.getInitializationPromise(),u}async duplicateBundle(t,e,a,n){var u,h,g,m,p,f;const i=(u=T.getMap("bundleOwnerIds"))==null?void 0:u.get(t),s={};try{const C=await this.loggedInBearerToken();s.Authorization=`Bearer ${C}`}catch{const S=((h=Object.entries(localStorage).find(([E,b])=>E.startsWith("CognitoIdentityServiceProvider")&&E.endsWith("idToken")))==null?void 0:h[0])||"",y=localStorage.getItem(S);y&&!_t(y)&&(s.Authorization=`Bearer ${y}`)}const o={bundleOwnerId:i,...s,...(g=n==null?void 0:n.graphql)==null?void 0:g.additionalHeaders},c=(f=(await B.getShadowGraphqlClient().mutate({mutation:nl(((p=(m=n==null?void 0:n.graphql)==null?void 0:m.productCollection)==null?void 0:p.eagerFetchProducts)||!1),variables:{id:t,template:e,marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId,duplicateTransactions:a},context:{headers:o},fetchPolicy:"no-cache"})).data)==null?void 0:f.bundleDuplicate;if(!(c!=null&&c.id))throw new Error("Unable to duplicate bundle");const d=T.getMap("bundlePartnerIds")||new Map;d.set(c.id,c.partner.id),T.setMap("bundlePartnerIds",d);const A=T.getMap("bundleOwnerIds")||new Map;return A.set(c.id,c.bundleOwnerId),T.setMap("bundleOwnerIds",A),async()=>{var w,S;const C=new ea(this,c,void 0,void 0,c.bundleOwnerId,{eagerFetchProducts:(S=(w=n==null?void 0:n.graphql)==null?void 0:w.productCollection)==null?void 0:S.eagerFetchProducts,existingGlobalPropertyState:c.globalPropertyState});return await C.getInitializationPromise(),C}}async getBundlesForCustomer(t){var i;if(!((i=this.customer)!=null&&i.id))throw new Error("Customer not authenticated.");const{includeMetadata:e,...a}=t;return(await B.getShadowGraphqlClient().query({query:ml(e??!1),variables:{...a,id:this.customer.id},fetchPolicy:"no-cache"})).data.customerBundlesFeed}async getBundleStakeholders(){var i;if(!this.customer)throw new Error("Customer not authenticated.");const t=await B.getShadowGraphqlClient().query({query:Xo,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!((i=t.data)!=null&&i.customers)||t.data.customers.length===0)throw new Error("Unable to find customer.");const a=t.data.customers[0].bundleStakeholders||[],n=T.getMap("bundlePartnerIds")||new Map;return a.forEach(s=>{var o,l;(o=s.bundle)!=null&&o.id&&((l=s.bundle.partner)!=null&&l.id)&&n.set(s.bundle.id,s.bundle.partner.id)}),T.setMap("bundlePartnerIds",n),a}async getWorkflowExperience(t,e){if(!t)throw new Error("getWorkflowExperience has been called without an options object! This is not supported.");const a=await this.getWorkflowExperiences([t],t.graphql),n=a[0];return e&&await n.getWorkflowManager().injectIntoPreviewService(e(n.getWorkflowManager().getWorkflow())),a[0]}async getWorkflowExperiences(t,e){if(t.length===0)throw new ht("No options provided!");const a=B.getShadowGraphqlClient(),n=async y=>{var D,x,k;if(y.length===0)return[];const E=y.map(N=>N.option.transactionId),b=await a.query({query:As,variables:{ids:E},errorPolicy:"all",fetchPolicy:"no-cache"}),P=b.data.transactions;if(P.length!==y.length){const N=((x=(D=b.errors)==null?void 0:D[0])==null?void 0:x.message)||"Unknown error";throw new ht(`Not all transactions were found: ${N}`)}return!this.activeIntegration&&((k=P[0].integrationProduct)!=null&&k.integration)&&(this.activeIntegration=Promise.resolve(P[0].integrationProduct.integration)),P.map((N,rt)=>{var R;return{transaction:N,workflowId:N.workflowId,readOnly:((R=y.find(et=>et.option.transactionId===N.id))==null?void 0:R.option.readOnly)??!1,index:y[rt].index}})},i=async y=>{var P,D,x;if(y.length===0)return[];const E=await a.mutate({mutation:ds,variables:{inputs:y.map(k=>({integrationProductId:k.option.type==="integration"?k.option.integrationProductId:void 0,externalIntegrationId:k.option.type==="external"?k.option.externalIntegrationId:void 0,externalProductId:k.option.type==="external"?k.option.externalProductId:void 0,workflowId:k.option.workflowId,designName:k.option.designName,claim:!0})),marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId},errorPolicy:"all",fetchPolicy:"no-cache"}),b=(P=E.data)==null?void 0:P.transactionCreateMany;if(!b||b.length===0){const k=((x=(D=E.errors)==null?void 0:D[0])==null?void 0:x.message)||"Unknown error";throw new ht(`Failed to create transactions: ${k}`)}return b.map((k,N)=>({transaction:k,workflowId:k.workflowId,readOnly:!1,index:y[N].index}))},s=t.map((y,E)=>({option:y,index:E})),o=s.filter(y=>y.option.type==="transaction"),l=s.filter(y=>y.option.type==="integration"||y.option.type==="external"),c=Ka(o,10),d=Ka(l,10),A=(await Promise.all([...c.map(n),...d.map(i)])).flat(),u=[...new Set(A.map(y=>y.workflowId))],h=await ja(u,e),g=new Map(h.map(y=>[y.id,y])),m=T.getMap("transactionOwnerIds")||new Map,p=A.map(async y=>{var et;const{transaction:E,workflowId:b,readOnly:P,index:D}=y,x=g.get(b),k=t[D];!m.get(E.id)&&E.transactionOwnerId&&m.set(E.id,E.transactionOwnerId);const N=m.get(E.id)||void 0,rt=new yc({onMutate:()=>({context:{transactionOwnerId:N,bundleOwnerId:e==null?void 0:e.bundleOwnerId}}),onQuery:()=>({context:{transactionOwnerId:N,bundleOwnerId:e==null?void 0:e.bundleOwnerId}})}),R={product:E.product,transaction:E,layouts:[],singleVariantsRenderable:(et=k==null?void 0:k.workflowConfiguration)==null?void 0:et.singleVariantsRenderable,stateMutationFunc:P?async()=>{throw new z("State mutation is forbidden in read only mode!")}:async Z=>this.updateTransactionState({...Z,context:{transactionOwnerId:N,bundleOwnerId:e==null?void 0:e.bundleOwnerId}}),graphQlClient:()=>rt,readOnly:P,workflow:x,isReloadedTransaction:k.type==="transaction"};if(!P&&k.workflowState){const Z=JSON.parse(k.workflowState);R.layouts=Object.values(Z.layouts||{}).map(Ut=>Ut.layout),await lr(Z),R.reloadedState=Z}else R.layouts=Ic(R.transaction,R.workflow);return R.renderableContextService=new Yl(R.layouts),R.delayWorkflowStateSync=!0,{experienceOptions:R,index:D,options:k}}),f=await Promise.all(p);T.setMap("transactionOwnerIds",m);const w=f.sort((y,E)=>y.index-E.index).map(async y=>{const{experienceOptions:E,options:b}=y,P=new Tr(this,E);return await P.getWorkflowManager().getInitializationPromise(),b.type!=="transaction"&&this.customer&&await P.attachCustomerDetails({email:this.customer.emailAddress}),P}),S=await Promise.all(w);return S.forEach(y=>y.getWorkflowManager().setWorkflowStateSyncEnabled(!0)),S}storeCustomer(t){const e=T.getMap("partnerCustomerIds")||new Map;e.set(t.partner.id,t.id),T.setMap("partnerCustomerIds",e)}async getIntegrationProductById(t,e){var s,o;const i=(s=(await B.getShadowGraphqlClient().query({query:fs(e),variables:{ids:[t]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:s.integrationProducts;if(!i||i.length===0||!((o=i[0])!=null&&o.id))throw new Error("Integration product not found.");return new wa(i[0])}async getIntegrationProductFromExternalIds(t,e,a){var o;const s=(o=(await B.getShadowGraphqlClient().query({query:Cs(a),variables:{externalProductId:e,externalIntegrationId:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:o.integrationProductFromExternalIds;if(!(s!=null&&s.id))throw new Error("Integration product not found.");return new wa(s)}async getIntegrationProduct(t){return t.type==="integration"?this.getIntegrationProductById(t.integrationProductId):this.getIntegrationProductFromExternalIds(t.externalIntegrationId,t.externalProductId)}async getShareActionsForTransaction(t){const a=(T.getMap("transactionOwnerIds")||new Map).get(t)||void 0,n=await B.getShadowGraphqlClient().query({query:ps,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t},context:{transactionOwnerId:a}});if(!n.data.transactions||n.data.transactions.length!==1)throw new Error(`Failed to fetch share actions for transaction: ${t}`);return n.data.transactions[0].transactionShareActions}async placeOrder(t){const e=await B.getShadowGraphqlClient().mutate({mutation:Ms,variables:{orderItems:t}});if(e.errors)throw new Error(e.errors[0].message);if(!e.data)throw new Error("Failed to create order: No order data in response.");return{id:e.data.orderCreate.id,internalId:e.data.orderCreate.internalId}}}const Hr=async(r,t)=>(await B.getShadowGraphqlClient().query({query:Ds,errorPolicy:"all",fetchPolicy:"no-cache",context:{headers:{"x-application-key":r}},variables:{themeConfigurationId:t}})).data.currentIntegration,Fc=async r=>{const e=await B.getShadowGraphqlClient().query({query:ms,errorPolicy:"all",fetchPolicy:"network-only",variables:{id:r}});if(e.data.transactions.length!==0)return e.data.transactions[0]},Dc=async(r,t)=>{var a;return(a=(await B.getShadowGraphqlClient().query({query:Fs,errorPolicy:"all",variables:{themeConfigurationId:r,themeInstallId:t}})).data)==null?void 0:a.marketplaceThemeInstallConfiguration},xc=async r=>{var e,a,n;return(n=(a=(e=(await B.getShadowGraphqlClient().query({query:ks,errorPolicy:"all",variables:{id:r}})).data)==null?void 0:e.bundles)==null?void 0:a[0])==null?void 0:n.marketplaceThemeInstallConfiguration},kc=async r=>{var e,a,n;return(n=(a=(e=(await B.getShadowGraphqlClient().query({query:xs,errorPolicy:"all",variables:{id:r}})).data)==null?void 0:e.transactions)==null?void 0:a[0])==null?void 0:n.marketplaceThemeInstallConfiguration};function Yr(r,t,e,a){const n=e.width*r.zoom,i=e.height*r.zoom;if(a){const o=r,l=Math.max(t.width/e.width,t.height/e.height);o.zoom=Math.max(l,r.zoom);const c=e.width*o.zoom,d=e.height*o.zoom;return o.x=ve(r.x,t.width-c,0),o.y=ve(r.y,t.height-d,0),o}const s=r;return s.x=ve(s.x,-n,t.width),s.y=ve(s.y,-i,t.height),s}function ve(r,t,e){return Math.min(Math.max(r,t),e)}class Jr{constructor(t,e){this.minZoomScale=[.03],this.maxZoomScale=[20],this._debouncedUpdateFrameOffsets=bn(this.updateFrameOffsets,200),this.targetElements=[],this.onFrameDataChangeListeners=[],this.onZoomChangeListeners=[],this.forceImageCover=t,this.initialZoom=e,this.thresholdSettings={useThreshold:!1,invertThreshold:!1,threshold:128,thresholdSaturation:.5}}connectWorkflowManager(t,e){e&&t.addStepSpecificStorageCallback(async a=>{if(a){const n=a;if(n.currentFrameSources){let i=!1;for(let s=0;s<n.currentFrameSources.length;s++){const o=n.currentFrameSources[s],l=await ue(o),c=this.frameData?this.frameData[s]:void 0;En(l,c)||(this.frameData||(this.frameData=new Array(n.currentFrameSources.length)),this.frameData[s]=l,i=!0)}i&&(this.onFrameDataChangeListeners.forEach(s=>s(this.frameData)),this.frameData&&this.imageData&&(this.recalculateOffsets(this.imageData),this.updateOffsets(this.offsets),this.recalculateZoomLimits(this.imageData,this.frameData)))}}},e),this.workflowManager=t,this.stepName=e}setTargetElements(t){this.targetElements=t}getFrameData(){return this.frameData}setFrameData(t){if(!t){this.frameData=void 0;return}t.forEach((e,a)=>{const n=xt.get(e);n&&(this.frameData||(this.frameData=new Array(t.length)),this.frameData[a]=n)})}getImageData(){return this.imageData}getImageSrc(){if(this.imageData){if(this.imageData.svg){const t=Ue(this.imageData.svg,this.imageData.colors||{},!1);return Oe(t)}return this.imageData.src}}getOffsets(){return this.offsets}setOffsets(t){this.offsets=t}setZoom(t,e,a,n){if(this.imageData&&this.offsets&&this.frameData){(!this.offsets||this.offsets.length!==this.frameData.length)&&(this.offsets=new Array(this.frameData.length));const i=this.frameData.map((s,o)=>{const l=(e[o]-this.offsets[o].x)/this.offsets[o].zoom,c=(a[o]-this.offsets[o].y)/this.offsets[o].zoom,d=e[o]-l*t[o],A=a[o]-c*t[o];return{x:d,y:A,zoom:this.imageData.width*t[o]/this.imageData.width}});this.updateOffsets(i,n),this.onZoomChangeListeners.forEach(s=>s(t))}}setPatternData(t,e=!0){this.imageData=t,t&&this.frameData&&((e||!this.offsets)&&this.recalculateOffsets(t),this.updateOffsets(this.offsets,void 0,!0)),this.imageData&&this.frameData&&this.recalculateZoomLimits(this.imageData,this.frameData)}updateOffsets(t,e,a){const n=this.imageData;if(!n||!this.frameData)return;if(this.frameData.length!==t.length)throw new z("Frame data and offsets are not the same length. This is a bug. Please report it.");if(!this.offsets.some((s,o)=>!(t[o].x===s.x&&t[o].y===s.y&&t[o].zoom===s.zoom))&&!a){e&&e();return}(!this.offsets||this.offsets.length!==this.frameData.length)&&(this.offsets=new Array(this.frameData.length)),this.frameData.forEach((s,o)=>{this.offsets[o]=Yr(t[o],s,this.imageData,this.forceImageCover)}),this._debouncedUpdateFrameOffsets(this.offsets,n,this.frameData,this.thresholdSettings,e)}getThresholdSettings(){return this.thresholdSettings}setThresholdSettings(t){this.thresholdSettings=t,this.imageData&&this.frameData&&this._debouncedUpdateFrameOffsets(this.offsets,this.imageData,this.frameData,t)}onFrameDataChanged(t){t(this.frameData),this.onFrameDataChangeListeners.push(t)}onZoom(t){this.onZoomChangeListeners.push(t)}updateFrameOffsets(t,e,a,n,i){if(!a||a.length===0||a.some(o=>!o))throw new z("Frame data not set. This is a bug");if(!this.workflowManager)throw new z("No workflow manager set, cannot update offsets.");const s=this.workflowManager.getCommandDispatcher();this.targetElements.forEach((o,l)=>{s(new $([new Co(o,e,t[l]),new wo(o,n.useThreshold,n.invertThreshold,n.threshold,n.thresholdSaturation)]))}),this.stepName&&this.workflowManager.updateStorage(this.stepName,{frameOffsetsList:t}),i&&i()}recalculateZoomLimits(t,e){(this.minZoomScale.length!==e.length||this.maxZoomScale.length!==e.length)&&(this.minZoomScale=new Array(e.length),this.maxZoomScale=new Array(e.length)),e.forEach((a,n)=>{const i=Math.max(a.width/t.width,a.height/t.height);this.forceImageCover?(this.minZoomScale[n]=i,this.maxZoomScale[n]=i*2.5):(this.minZoomScale[n]=i/10,this.maxZoomScale[n]=i*2.5)})}recalculateOffsets(t){this.frameData&&((!this.offsets||this.offsets.length!==this.frameData.length)&&(this.offsets=new Array(this.frameData.length)),this.frameData.forEach((e,a)=>{this.offsets[a]=ka(t,e,this.initialZoom&&!this.forceImageCover?{scale:this.initialZoom}:void 0,this.forceImageCover)}),this._debouncedUpdateFrameOffsets(this.offsets,t,this.frameData,this.thresholdSettings))}}class Mc{updateRecipient(t,e,a,n,i,s,o,l,c,d,A,u,h,g,m,p,f){throw new Error("Method not implemented.")}approveTransaction(t){throw new Error("Method not implemented.")}rejectTransaction(t){throw new Error("Method not implemented.")}getClient(){return this.client??{}}getWorkflowExperience(){return{}}setClient(t){this.client=t}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}async reset(){}updateStateWithServer(t){}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}getStepSelections(){return{}}setCurrentAdjustingStepId(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,a){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}setWorkflowStateSyncEnabled(t){}async updateTransactionShareActions(){}addValidationCallback(t){}setStepError(t,e,a){}getStepErrors(t){}getValidationErrors(){return{steps:new Map}}async updateTransactionStakeholders(){}getStepTags(t){return[]}}var Kr=(r=>(r.SelectFrame="SelectFrame",r.SelectImage="SelectImage",r.Position="Position",r))(Kr||{});class _r extends nt{constructor(t,e,a){super(t,e,a);const n=e.data;this.frameService=new Jr(n.forceImageCover,n.initialZoomLevel),this.frameService.connectWorkflowManager(t,e.stepName)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return ut.selectVariant(this.step,t.getResource(),e,this.manager,a=>this.setUpdateState(a))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged(e=>{e&&t(e)})}async selectImage(t,e=!0,a=!0){var n;if(await ut.selectImage(this.step,t,this.manager,a),e){const i=((n=this.manager.getStepStorage(this.step.stepName))==null?void 0:n.framePatternData)||{};this.manager.updateStorage(this.step.stepName,{framePatternData:{...i,originalAssetKey:t.key,backgroundRemovedAssetKey:void 0,useOriginalAsset:void 0}})}}async canUseBackgroundRemover(){return this.manager.getClient().canUseAddon(Me.BackgroundRemover)}async canRemoveBackground(){var t,e,a,n;return await this.canUseBackgroundRemover()&&this.hasOriginalImageSelection()&&!!((e=(t=this.frameService)==null?void 0:t.getImageData())!=null&&e.src)&&!((n=(a=this.frameService)==null?void 0:a.getImageData())!=null&&n.svg)}async removeBackgroundFromImageSelection(t=!0){var i;if(!await this.canUseBackgroundRemover())throw new Error("The current Integration does not have access to the Background Remover. Please call canUseBackgroundRemover to ensure you disable this feature when appropriate.");const e=await this.getOriginalImageSelection();if(!e)throw new Error("You must supply an image selection before attempting to remove the background.");const a=await U.removeBackgroundFromAsset(e);t&&await ut.selectImage(this.step,a,this.manager,!1);const n=((i=this.manager.getStepStorage(this.step.stepName))==null?void 0:i.framePatternData)||{};return this.manager.updateStorage(this.step.stepName,{framePatternData:{...n,backgroundRemovedAssetKey:a.key,useOriginalAsset:!t}}),a}changeColors(t){ut.changeColors(this.step,this.manager,t)}getImageData(){if(this.frameService)return this.frameService.getImageData()}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?ut.availableColors(this.step,this.manager):Promise.resolve([])}isColorPickerEnabled(){return this.step.data.colorPickerEnabled??!1}async getOriginalImageColors(){const t=this.getImageData();return t!=null&&t.svg?(await ot(t.svg)).colors:void 0}getMaxAllowedColors(){return this.step.data.maxColors}getUniqueColorCount(){return ut.getUniqueColorCount(this.step,this.manager)}getCurrentFrameStep(t,e,a,n){return n&&n.length>1&&t===void 0?"SelectFrame":e||a||this.getImageData()?"Position":"SelectImage"}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}getWhitelistedExtensions(){return[...this.step.data.whitelistedExtensions,...this.step.data.whitelistedExtensions.includes(".jpg")?[".jpeg"]:[]]}async getOriginalImageSelection(){var e,a;const t=(a=(e=this.manager.getStepStorage(this.step.stepName))==null?void 0:e.framePatternData)==null?void 0:a.originalAssetKey;if(t)return U.getLocalOrFromServer(t)}async getBackgroundRemovedImageSelection(){var e,a;const t=(a=(e=this.manager.getStepStorage(this.step.stepName))==null?void 0:e.framePatternData)==null?void 0:a.backgroundRemovedAssetKey;if(t)return U.getLocalOrFromServer(t)}hasOriginalImageSelection(){var t,e;return!!((e=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.framePatternData)!=null&&e.originalAssetKey)}hasBackgroundRemovedImageSelection(){var t,e;return!!((e=(t=this.getFrameStepStorage())==null?void 0:t.framePatternData)!=null&&e.backgroundRemovedAssetKey)}getUseOriginalImageSelection(){var t,e;return((e=(t=this.getFrameStepStorage())==null?void 0:t.framePatternData)==null?void 0:e.useOriginalAsset)??!1}async setUseOriginalImageSelection(t){var n;const e=((n=this.getFrameStepStorage())==null?void 0:n.framePatternData)||{};if(e.useOriginalAsset===t)return;const a=await this.getOriginalImageSelection();if(!a)throw new Error("You must provide an image selection before calling setUseOriginalImageSelection");if(t)await this.selectImage(a,!1,!1);else{const i=await this.getBackgroundRemovedImageSelection();if(!i)throw new Error("You must call removeBackgroundFromImageSelection before attempting to apply the image.");await this.selectImage(i,!1,!1)}this.manager.updateStorage(this.step.stepName,{framePatternData:{...e,useOriginalAsset:t}})}getFrameStepStorage(){return this.manager.getStepStorage(this.step.stepName)}}const Tc=v.gql`
2459
2511
  query GetLoggedInCustomer($email: String!) {
2460
2512
  customer(emailAddress: $email) {
2461
2513
  id
@@ -2498,21 +2550,21 @@
2498
2550
  total
2499
2551
  }
2500
2552
  }
2501
- `,Tc=v.gql`
2553
+ `,Nc=v.gql`
2502
2554
  mutation SetTransactionDesignName($id: String!, $name: String!) {
2503
2555
  transactionUpdate(id: $id, designName: $name) {
2504
2556
  id
2505
2557
  designName
2506
2558
  }
2507
2559
  }
2508
- `,Nc=v.gql`
2560
+ `,Qc=v.gql`
2509
2561
  mutation DuplicateTransaction($id: String!, $template: Boolean!) {
2510
2562
  transactionDuplicate(id: $id, template: $template) {
2511
2563
  id
2512
2564
  workflowViewerLink
2513
2565
  }
2514
2566
  }
2515
- `,Qc=v.gql`
2567
+ `,Rc=v.gql`
2516
2568
  query GetCustomerBundles($id: String!, $limit: Int!, $offset: Int!) {
2517
2569
  customerBundlesFeed(id: $id, limit: $limit, offset: $offset) {
2518
2570
  items {
@@ -2527,7 +2579,7 @@
2527
2579
  total
2528
2580
  }
2529
2581
  }
2530
- `,Rc=v.gql`
2582
+ `,Oc=v.gql`
2531
2583
  query GetTransactionsForBundle($id: String!) {
2532
2584
  bundles(ids: [$id]) {
2533
2585
  id
@@ -2548,21 +2600,21 @@
2548
2600
  }
2549
2601
  }
2550
2602
  }
2551
- `,Oc=v.gql`
2603
+ `,$c=v.gql`
2552
2604
  mutation SetBundleName($id: String!, $name: String!) {
2553
2605
  bundleUpdate(id: $id, name: $name) {
2554
2606
  id
2555
2607
  name
2556
2608
  }
2557
2609
  }
2558
- `,$c=v.gql`
2610
+ `,Uc=v.gql`
2559
2611
  mutation DuplicateBundle($id: String!, $template: Boolean!) {
2560
2612
  bundleDuplicate(id: $id, template: $template) {
2561
2613
  id
2562
2614
  workflowViewerLink
2563
2615
  }
2564
2616
  }
2565
- `,Uc=v.gql`
2617
+ `,Lc=v.gql`
2566
2618
  query GetBundleTemplates($id: String!, $limit: Int!, $offset: Int!) {
2567
2619
  customerBundlesFeed(id: $id, limit: $limit, offset: $offset, template: true) {
2568
2620
  items {
@@ -2575,7 +2627,7 @@
2575
2627
  total
2576
2628
  }
2577
2629
  }
2578
- `,Lc=async(r,t,e)=>await B.getShadowGraphqlClient().mutate({mutation:Oc,errorPolicy:"all",variables:{id:r,name:t},context:e}),Vc=async(r,t)=>await B.getShadowGraphqlClient().mutate({mutation:Tc,errorPolicy:"all",variables:{id:r,name:t}}),zc=async(r,t)=>await B.getShadowGraphqlClient().mutate({mutation:$c,errorPolicy:"all",variables:{id:r,template:t}}),Gc=async(r,t)=>await B.getShadowGraphqlClient().mutate({mutation:Nc,errorPolicy:"all",variables:{id:r,template:t}}),qc=async r=>(await B.getShadowGraphqlClient().query({query:Mc,errorPolicy:"all",variables:{email:r}})).data.customer,Wc=async(r,t,e)=>await B.getShadowGraphqlClient().query({query:Qc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:r,offset:e,limit:t}}),jc=async(r,t)=>await B.getShadowGraphqlClient().query({query:Rc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:r},context:t}),Hc=async(r,t,e)=>{var n;const a=await B.getShadowGraphqlClient().query({query:Ha,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:r,quicksearch:"",filters:{link:"and",status:{operator:"isAnyOf",values:["Created","DesignCompleted","ExternallyOrdered"]},template:{value:"false"}},offset:e,limit:t}});return((n=a==null?void 0:a.data.customerTransactionsFeed)==null?void 0:n.items)||[]},Yc=async(r,t,e)=>{var n;const a=await B.getShadowGraphqlClient().query({query:Ha,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:r,quicksearch:"",filters:{link:"and",status:{operator:"equals",value:"Ordered"},template:{value:"false"}},offset:e,limit:t}});return((n=a==null?void 0:a.data.customerTransactionsFeed)==null?void 0:n.items)||[]},Jc=async(r,t,e)=>{var n;const a=await B.getShadowGraphqlClient().query({query:Ha,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:r,quicksearch:"",filters:{link:"and",template:{value:"true"}},offset:e,limit:t}});return((n=a==null?void 0:a.data.customerTransactionsFeed)==null?void 0:n.items)||[]},Kc=async(r,t,e)=>{var n;const a=await B.getShadowGraphqlClient().query({query:Uc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:r,offset:e,limit:t}});return((n=a==null?void 0:a.data.customerBundlesFeed)==null?void 0:n.items)||[]};(function(){try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode("#spiffThemeWrapper{width:100%;height:100%}")),document.head.appendChild(r)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var _r=(r=>(r.Manual="Manual",r.OnStart="OnStart",r.OnQuit="OnQuit",r.OnEnd="OnEnd",r))(_r||{}),Xr=(r=>(r.Email="Email",r.FirstName="FirstName",r.LastName="LastName",r.Phone="Phone",r.Apartment="Apartment",r.City="City",r.Country="Country",r.OrganizationName="OrganizationName",r.PostCode="PostCode",r.State="State",r.StreetAddress="StreetAddress",r.Custom="Custom",r))(Xr||{}),K;K={__e:function(r,t,e,a){for(var n,i,s;t=t.__;)if((n=t.__c)&&!n.__)try{if((i=n.constructor)&&i.getDerivedStateFromError!=null&&(n.setState(i.getDerivedStateFromError(r)),s=n.__d),n.componentDidCatch!=null&&(n.componentDidCatch(r,a||{}),s=n.__d),s)return n.__E=n}catch(o){r=o}throw r}},typeof Promise=="function"&&Promise.prototype.then.bind(Promise.resolve());var lt,aa,hn,Zr=[],na=[],gn=K.__b,mn=K.__r,pn=K.diffed,fn=K.__c,Cn=K.unmount;function _c(){for(var r;r=Zr.shift();)if(r.__P&&r.__H)try{r.__H.__h.forEach(Be),r.__H.__h.forEach(ya),r.__H.__h=[]}catch(t){r.__H.__h=[],K.__e(t,r.__v)}}K.__b=function(r){lt=null,gn&&gn(r)},K.__r=function(r){mn&&mn(r);var t=(lt=r.__c).__H;t&&(aa===lt?(t.__h=[],lt.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.__V=na,e.__N=e.i=void 0})):(t.__h.forEach(Be),t.__h.forEach(ya),t.__h=[])),aa=lt},K.diffed=function(r){pn&&pn(r);var t=r.__c;t&&t.__H&&(t.__H.__h.length&&(Zr.push(t)!==1&&hn===K.requestAnimationFrame||((hn=K.requestAnimationFrame)||Xc)(_c)),t.__H.__.forEach(function(e){e.i&&(e.__H=e.i),e.__V!==na&&(e.__=e.__V),e.i=void 0,e.__V=na})),aa=lt=null},K.__c=function(r,t){t.some(function(e){try{e.__h.forEach(Be),e.__h=e.__h.filter(function(a){return!a.__||ya(a)})}catch(a){t.some(function(n){n.__h&&(n.__h=[])}),t=[],K.__e(a,e.__v)}}),fn&&fn(r,t)},K.unmount=function(r){Cn&&Cn(r);var t,e=r.__c;e&&e.__H&&(e.__H.__.forEach(function(a){try{Be(a)}catch(n){t=n}}),e.__H=void 0,t&&K.__e(t,e.__v))};var wn=typeof requestAnimationFrame=="function";function Xc(r){var t,e=function(){clearTimeout(a),wn&&cancelAnimationFrame(t),setTimeout(r)},a=setTimeout(e,100);wn&&(t=requestAnimationFrame(e))}function Be(r){var t=lt,e=r.__c;typeof e=="function"&&(r.__c=void 0,e()),lt=t}function ya(r){var t=lt;r.__c=r.__(),lt=t}const ti=v.gql`
2630
+ `,Vc=async(r,t,e)=>await B.getShadowGraphqlClient().mutate({mutation:$c,errorPolicy:"all",variables:{id:r,name:t},context:e}),zc=async(r,t)=>await B.getShadowGraphqlClient().mutate({mutation:Nc,errorPolicy:"all",variables:{id:r,name:t}}),qc=async(r,t)=>await B.getShadowGraphqlClient().mutate({mutation:Uc,errorPolicy:"all",variables:{id:r,template:t}}),Gc=async(r,t)=>await B.getShadowGraphqlClient().mutate({mutation:Qc,errorPolicy:"all",variables:{id:r,template:t}}),Wc=async r=>(await B.getShadowGraphqlClient().query({query:Tc,errorPolicy:"all",variables:{email:r}})).data.customer,jc=async(r,t,e)=>await B.getShadowGraphqlClient().query({query:Rc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:r,offset:e,limit:t}}),Hc=async(r,t)=>await B.getShadowGraphqlClient().query({query:Oc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:r},context:t}),Yc=async(r,t,e)=>{var n;const a=await B.getShadowGraphqlClient().query({query:Ha,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:r,quicksearch:"",filters:{link:"and",status:{operator:"isAnyOf",values:["Created","DesignCompleted","ExternallyOrdered"]},template:{value:"false"}},offset:e,limit:t}});return((n=a==null?void 0:a.data.customerTransactionsFeed)==null?void 0:n.items)||[]},Jc=async(r,t,e)=>{var n;const a=await B.getShadowGraphqlClient().query({query:Ha,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:r,quicksearch:"",filters:{link:"and",status:{operator:"equals",value:"Ordered"},template:{value:"false"}},offset:e,limit:t}});return((n=a==null?void 0:a.data.customerTransactionsFeed)==null?void 0:n.items)||[]},Kc=async(r,t,e)=>{var n;const a=await B.getShadowGraphqlClient().query({query:Ha,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:r,quicksearch:"",filters:{link:"and",template:{value:"true"}},offset:e,limit:t}});return((n=a==null?void 0:a.data.customerTransactionsFeed)==null?void 0:n.items)||[]},_c=async(r,t,e)=>{var n;const a=await B.getShadowGraphqlClient().query({query:Lc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:r,offset:e,limit:t}});return((n=a==null?void 0:a.data.customerBundlesFeed)==null?void 0:n.items)||[]};(function(){try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode("#spiffThemeWrapper{width:100%;height:100%}")),document.head.appendChild(r)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var Xr=(r=>(r.Manual="Manual",r.OnStart="OnStart",r.OnQuit="OnQuit",r.OnEnd="OnEnd",r))(Xr||{}),Ya=(r=>(r.Email="Email",r.FirstName="FirstName",r.LastName="LastName",r.Phone="Phone",r.Apartment="Apartment",r.City="City",r.Country="Country",r.OrganizationName="OrganizationName",r.PostCode="PostCode",r.State="State",r.StreetAddress="StreetAddress",r.Custom="Custom",r))(Ya||{}),K;K={__e:function(r,t,e,a){for(var n,i,s;t=t.__;)if((n=t.__c)&&!n.__)try{if((i=n.constructor)&&i.getDerivedStateFromError!=null&&(n.setState(i.getDerivedStateFromError(r)),s=n.__d),n.componentDidCatch!=null&&(n.componentDidCatch(r,a||{}),s=n.__d),s)return n.__E=n}catch(o){r=o}throw r}},typeof Promise=="function"&&Promise.prototype.then.bind(Promise.resolve());var lt,aa,gn,Zr=[],na=[],mn=K.__b,pn=K.__r,fn=K.diffed,Cn=K.__c,wn=K.unmount;function Xc(){for(var r;r=Zr.shift();)if(r.__P&&r.__H)try{r.__H.__h.forEach(Be),r.__H.__h.forEach(ya),r.__H.__h=[]}catch(t){r.__H.__h=[],K.__e(t,r.__v)}}K.__b=function(r){lt=null,mn&&mn(r)},K.__r=function(r){pn&&pn(r);var t=(lt=r.__c).__H;t&&(aa===lt?(t.__h=[],lt.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.__V=na,e.__N=e.i=void 0})):(t.__h.forEach(Be),t.__h.forEach(ya),t.__h=[])),aa=lt},K.diffed=function(r){fn&&fn(r);var t=r.__c;t&&t.__H&&(t.__H.__h.length&&(Zr.push(t)!==1&&gn===K.requestAnimationFrame||((gn=K.requestAnimationFrame)||Zc)(Xc)),t.__H.__.forEach(function(e){e.i&&(e.__H=e.i),e.__V!==na&&(e.__=e.__V),e.i=void 0,e.__V=na})),aa=lt=null},K.__c=function(r,t){t.some(function(e){try{e.__h.forEach(Be),e.__h=e.__h.filter(function(a){return!a.__||ya(a)})}catch(a){t.some(function(n){n.__h&&(n.__h=[])}),t=[],K.__e(a,e.__v)}}),Cn&&Cn(r,t)},K.unmount=function(r){wn&&wn(r);var t,e=r.__c;e&&e.__H&&(e.__H.__.forEach(function(a){try{Be(a)}catch(n){t=n}}),e.__H=void 0,t&&K.__e(t,e.__v))};var yn=typeof requestAnimationFrame=="function";function Zc(r){var t,e=function(){clearTimeout(a),yn&&cancelAnimationFrame(t),setTimeout(r)},a=setTimeout(e,100);yn&&(t=requestAnimationFrame(e))}function Be(r){var t=lt,e=r.__c;typeof e=="function"&&(r.__c=void 0,e()),lt=t}function ya(r){var t=lt;r.__c=r.__(),lt=t}const ti=v.gql`
2579
2631
  fragment AddressValidationResultFields on AddressValidationResult {
2580
2632
  addressComplete
2581
2633
  address {
@@ -2597,7 +2649,7 @@
2597
2649
  }
2598
2650
  missingComponentTypes
2599
2651
  }
2600
- `,Ya=v.gql`
2652
+ `,Ja=v.gql`
2601
2653
  ${ti}
2602
2654
  fragment AddressValidationJobFields on AddressValidationJob {
2603
2655
  id
@@ -2609,15 +2661,15 @@
2609
2661
  ...AddressValidationResultFields
2610
2662
  }
2611
2663
  }
2612
- `,Zc=v.gql`
2613
- ${Ya}
2664
+ `,td=v.gql`
2665
+ ${Ja}
2614
2666
  query GetAddressValidationJobs($ids: [String!]!) {
2615
2667
  addressValidationJobs(ids: $ids) {
2616
2668
  ...AddressValidationJobFields
2617
2669
  }
2618
2670
  }
2619
- `,td=v.gql`
2620
- ${Ya}
2671
+ `,ed=v.gql`
2672
+ ${Ja}
2621
2673
  query GetRecipientsWithAddressValidationJobs($ids: [String!]!) {
2622
2674
  recipients(ids: $ids) {
2623
2675
  id
@@ -2626,19 +2678,19 @@
2626
2678
  }
2627
2679
  }
2628
2680
  }
2629
- `,ed=v.gql`
2681
+ `,ad=v.gql`
2630
2682
  ${ti}
2631
2683
  mutation ValidateRecipientAddress($id: String!) {
2632
2684
  recipientValidate(id: $id) {
2633
2685
  ...AddressValidationResultFields
2634
2686
  }
2635
2687
  }
2636
- `,ad=v.gql`
2637
- ${Ya}
2688
+ `,nd=v.gql`
2689
+ ${Ja}
2638
2690
  mutation BatchValidateRecipientAddress($ids: [String!]!) {
2639
2691
  recipientValidateBatch(ids: $ids) {
2640
2692
  ...AddressValidationJobFields
2641
2693
  }
2642
2694
  }
2643
- `;var ei=(r=>(r.Confirmed="Confirmed",r.Plausible="Plausible",r.Unlikely="Unlikely",r))(ei||{}),ai=(r=>(r.Created="Created",r.Processing="Processing",r.Completed="Completed",r.Failed="Failed",r.Cancelled="Cancelled",r))(ai||{});const nd=async r=>{const t=r.map(a=>{var n;return(n=a.getWorkflowManager().getTransaction().recipient)==null?void 0:n.id}).filter(a=>!!a),e=await B.getShadowGraphqlClient().query({query:td,errorPolicy:"all",fetchPolicy:"network-only",variables:{ids:t}});return r.map(a=>{var i,s,o,l;const n=(i=a.getWorkflowManager().getTransaction().recipient)==null?void 0:i.id;if(n)return(l=(o=(s=e.data)==null?void 0:s.recipients)==null?void 0:o.find(c=>c.id===n))==null?void 0:l.addressValidationJob})},rd=async r=>{var e;return(e=(await B.getShadowGraphqlClient().query({query:Zc,errorPolicy:"all",fetchPolicy:"network-only",variables:{ids:r}})).data)==null?void 0:e.addressValidationJobs},id=async r=>{var e,a;return(e=r.getWorkflowManager().getTransaction().recipient)!=null&&e.id?(a=(await B.getShadowGraphqlClient().mutate({mutation:ed,errorPolicy:"all",fetchPolicy:"network-only",variables:{id:r.getWorkflowManager().getTransaction().recipient.id}})).data)==null?void 0:a.recipientValidate:void 0},sd=async r=>{const t=r.map(a=>{var n;return(n=a.getWorkflowManager().getTransaction().recipient)==null?void 0:n.id}).filter(a=>!!a),e=await B.getShadowGraphqlClient().mutate({mutation:ad,errorPolicy:"all",fetchPolicy:"network-only",variables:{ids:t}});return r.map(a=>{var i,s,o;const n=(i=a.getWorkflowManager().getTransaction().recipient)==null?void 0:i.id;if(n)return(o=(s=e.data)==null?void 0:s.recipientValidateBatch)==null?void 0:o.find(l=>l.entityId===n)})};exports.AddonHandle=Me;exports.AddressValidationJobStatus=ai;exports.AddressValidationResultConfirmationLevel=ei;exports.ArrayInput=mc;exports.AspectType=V;exports.AssetNotFoundError=mt;exports.AssetType=Xt;exports.BringForwardCommand=Eo;exports.BringToBackCommand=vo;exports.BringToFrontCommand=So;exports.BundleDesignCreationCartAddMode=Bn;exports.CanvasCommand=O;exports.CollectionProduct=Ht;exports.ColorOptionGlobalPropertyHandle=Ca;exports.CommandContext=nr;exports.ConversionDataType=Xr;exports.ConversionLocation=_r;exports.CreateElementCommand=q;exports.CreateLayoutCommand=Na;exports.CurrencyContext=Wr;exports.CurrencyService=qr;exports.DeleteElementCommand=Ct;exports.DigitalContentStepHandle=Br;exports.FileUploadGlobalPropertyHandle=Nr;exports.FlowExecutionNodeResult=Yt;exports.FlowExecutionResult=zr;exports.FlowService=Vr;exports.FontAlignmentCommand=dr;exports.FontColorCommand=lr;exports.FontSizeCommand=cr;exports.FontSourceCommand=ga;exports.FrameService=Yr;exports.FrameStep=Jr;exports.FrameStepHandle=Kr;exports.GlobalPropertyHandle=Ge;exports.GroupCommand=$;exports.IllustrationStepHandle=fr;exports.InformationMessageType=me;exports.InformationStepHandle=br;exports.IntegrationProduct=wa;exports.IntegrationType=Pn;exports.LayoutElementFactory=ho;exports.LayoutElementType=k;exports.LayoutNotFoundError=Y;exports.LayoutRenderingPurpose=Tt;exports.MaterialStepHandle=Cr;exports.MisconfigurationError=ee;exports.MockWorkflowManager=kc;exports.ModelStepHandle=wr;exports.ModuleStepHandle=Ir;exports.MoveCommand=go;exports.ObjectInput=Wa;exports.ObjectInputType=Gr;exports.OptionGlobalPropertyHandle=za;exports.OptionNotFoundError=te;exports.ParseError=St;exports.PictureStepHandle=yr;exports.ProductCameraRig=Dn;exports.ProductCollection=Ga;exports.ProductCollectionProductSortKey=$r;exports.ProductWorkflow=Mt;exports.PromiseCache=Ot;exports.PromiseQueue=Da;exports.QuestionStepHandle=Sr;exports.QueueablePromise=Pa;exports.ResizeCommand=po;exports.ResourceNotFoundError=Nt;exports.RotateCommand=mo;exports.ScaleAxis=j;exports.SendBackwardsCommand=bo;exports.ShapeStepHandle=vr;exports.ShareActionType=In;exports.SpiffCommerceClient=Ic;exports.StakeholderType=Zt;exports.StepAspectType=bn;exports.StepHandle=rt;exports.StepType=I;exports.TextAlgorithm=Bt;exports.TextChangeCommand=Ar;exports.TextGlobalPropertyHandle=Qr;exports.TextInput=gc;exports.TextStepHandle=Er;exports.Transform=Lr;exports.TransformCollection=Ur;exports.UnhandledBehaviorError=z;exports.UnitOfMeasurement=xn;exports.UpdateImageSourceCommand=wo;exports.Variant=it;exports.WorkflowExperienceEventType=kr;exports.WorkflowExperienceImpl=Mr;exports.assetService=U;exports.browserColorToHex=Un;exports.cmPerPixel=Js;exports.createDesign=Fr;exports.currentDirection=js;exports.dataUrlFromExternalUrl=bi;exports.designService=be;exports.determineCorrectFontSizeAndLines=Kt;exports.digitalContentStepService=Qa;exports.domParser=ct;exports.duplicateBundle=zc;exports.duplicateTransaction=Gc;exports.fetchAsString=et;exports.findAngle=Us;exports.findElement=L;exports.findPmsColors=Gi;exports.frameDataCache=Ft;exports.frameStepService=ut;exports.generate=Q;exports.generateCommands=Tr;exports.generateSVGWithUnknownColors=ot;exports.generateStateFromDesignInputSteps=Zl;exports.getAddressValidationJobs=rd;exports.getAttributesFromArrayBuffer=le;exports.getAxisAlignedBoundingBox=$s;exports.getBoundedOffsets=Hr;exports.getBundleThemeConfiguration=xc;exports.getCustomer=qc;exports.getCustomerBundles=Wc;exports.getElementVertices=Hs;exports.getFrameData=ue;exports.getGlobalPropertyStateForBundle=Yo;exports.getIntegration=jr;exports.getNEPoint=qs;exports.getNWPoint=Gs;exports.getOrderedTransactions=Yc;exports.getOverrideThemeConfiguration=Dc;exports.getPointOfRotation=zs;exports.getProductCollections=lc;exports.getSEPoint=Ws;exports.getSvgElement=ze;exports.getTemplateBundles=Kc;exports.getTemplateTransactions=Jc;exports.getTransaction=Pc;exports.getTransactionThemeConfiguration=Fc;exports.getTransactionsForBundle=jc;exports.getTrueCoordinates=Vs;exports.getUnorderedTransactions=Hc;exports.getValidationJobsForWorkflowExperiences=nd;exports.getWorkflow=Ec;exports.getWorkflows=ja;exports.graphQlManager=B;exports.illustrationStepService=Jt;exports.isCloseToValue=Ls;exports.loadFont=It;exports.matchHexToPms=Li;exports.materialStepService=Ra;exports.metafieldManager=Or;exports.mmPerPixel=Ys;exports.modelStepService=Oa;exports.modifySVGColors=Ue;exports.moduleStepService=$a;exports.nameBundle=Lc;exports.nameTransaction=Vc;exports.optionService=H;exports.outlineFontsInSvg=to;exports.patternImageDataCache=dt;exports.persistenceService=N;exports.pictureStepService=Ua;exports.pmsToRgb=Ui;exports.questionStepService=La;exports.registerFetchImplementation=wi;exports.registerWindowImplementation=Ci;exports.rehydrateSerializedLayout=or;exports.rgbToPms=$n;exports.rotateAroundPoint=jt;exports.sanitizeSvgTree=$e;exports.setBearerAuthenticationToken=Rn;exports.setCanvasModule=Ea;exports.shapeStepService=kt;exports.shortenUrl=ur;exports.spiffCoreConfiguration=At;exports.stepAspectValuesToDesignInputSteps=Xl;exports.svgColorValueToDefinition=da;exports.svgStringDimensions=Ta;exports.svgToDataUrl=Oe;exports.textStepService=W;exports.toast=gr;exports.validateWorkflowExperienceRecipient=id;exports.validateWorkflowExperienceRecipients=sd;exports.xmlSerializer=wt;
2695
+ `;var ei=(r=>(r.Confirmed="Confirmed",r.Plausible="Plausible",r.Unlikely="Unlikely",r))(ei||{}),ai=(r=>(r.Created="Created",r.Processing="Processing",r.Completed="Completed",r.Failed="Failed",r.Cancelled="Cancelled",r))(ai||{});const rd=async r=>{const t=r.map(a=>{var n;return(n=a.getWorkflowManager().getTransaction().recipient)==null?void 0:n.id}).filter(a=>!!a),e=await B.getShadowGraphqlClient().query({query:ed,errorPolicy:"all",fetchPolicy:"network-only",variables:{ids:t}});return r.map(a=>{var i,s,o,l;const n=(i=a.getWorkflowManager().getTransaction().recipient)==null?void 0:i.id;if(n)return(l=(o=(s=e.data)==null?void 0:s.recipients)==null?void 0:o.find(c=>c.id===n))==null?void 0:l.addressValidationJob})},id=async r=>{var e;return(e=(await B.getShadowGraphqlClient().query({query:td,errorPolicy:"all",fetchPolicy:"network-only",variables:{ids:r}})).data)==null?void 0:e.addressValidationJobs},sd=async r=>{var e,a;return(e=r.getWorkflowManager().getTransaction().recipient)!=null&&e.id?(a=(await B.getShadowGraphqlClient().mutate({mutation:ad,errorPolicy:"all",fetchPolicy:"network-only",variables:{id:r.getWorkflowManager().getTransaction().recipient.id}})).data)==null?void 0:a.recipientValidate:void 0},od=async r=>{const t=r.map(a=>{var n;return(n=a.getWorkflowManager().getTransaction().recipient)==null?void 0:n.id}).filter(a=>!!a),e=await B.getShadowGraphqlClient().mutate({mutation:nd,errorPolicy:"all",fetchPolicy:"network-only",variables:{ids:t}});return r.map(a=>{var i,s,o;const n=(i=a.getWorkflowManager().getTransaction().recipient)==null?void 0:i.id;if(n)return(o=(s=e.data)==null?void 0:s.recipientValidateBatch)==null?void 0:o.find(l=>l.entityId===n)})};exports.AddonHandle=Me;exports.AddressValidationJobStatus=ai;exports.AddressValidationResultConfirmationLevel=ei;exports.ArrayInput=pc;exports.AspectType=V;exports.AssetNotFoundError=mt;exports.AssetType=Xt;exports.BringForwardCommand=bo;exports.BringToBackCommand=Eo;exports.BringToFrontCommand=vo;exports.BundleDesignCreationCartAddMode=In;exports.CanvasCommand=O;exports.CollectionProduct=Ht;exports.ColorOptionGlobalPropertyHandle=Ca;exports.CommandContext=rr;exports.ConversionDataType=Ya;exports.ConversionLocation=Xr;exports.CreateElementCommand=G;exports.CreateLayoutCommand=Na;exports.CurrencyContext=jr;exports.CurrencyService=Wr;exports.DeleteElementCommand=Ct;exports.DigitalContentStepHandle=Ir;exports.FileUploadGlobalPropertyHandle=Qr;exports.FlowExecutionNodeResult=Yt;exports.FlowExecutionResult=qr;exports.FlowService=zr;exports.FontAlignmentCommand=Ar;exports.FontColorCommand=cr;exports.FontSizeCommand=dr;exports.FontSourceCommand=ga;exports.FrameService=Jr;exports.FrameStep=Kr;exports.FrameStepHandle=_r;exports.GlobalPropertyHandle=qe;exports.GroupCommand=$;exports.IllustrationStepHandle=Cr;exports.InformationMessageType=me;exports.InformationStepHandle=Br;exports.IntegrationProduct=wa;exports.IntegrationType=Fn;exports.LayoutElementFactory=go;exports.LayoutElementType=M;exports.LayoutNotFoundError=Y;exports.LayoutRenderingPurpose=Tt;exports.MaterialStepHandle=wr;exports.MisconfigurationError=ee;exports.MockWorkflowManager=Mc;exports.ModelStepHandle=yr;exports.ModuleStepHandle=Pr;exports.MoveCommand=mo;exports.ObjectInput=Wa;exports.ObjectInputType=Gr;exports.OptionGlobalPropertyHandle=za;exports.OptionNotFoundError=te;exports.ParseError=St;exports.PictureStepHandle=Sr;exports.ProductCameraRig=Dn;exports.ProductCollection=qa;exports.ProductCollectionProductSortKey=Ur;exports.ProductWorkflow=Mt;exports.PromiseCache=Ot;exports.PromiseQueue=Fa;exports.QuestionStepHandle=vr;exports.QueueablePromise=Pa;exports.ResizeCommand=fo;exports.ResourceNotFoundError=Nt;exports.RotateCommand=po;exports.ScaleAxis=j;exports.SendBackwardsCommand=Bo;exports.ShapeStepHandle=Er;exports.ShareActionType=Pn;exports.SpiffCommerceClient=Pc;exports.StakeholderType=Zt;exports.StepAspectType=Bn;exports.StepHandle=nt;exports.StepType=I;exports.TextAlgorithm=Bt;exports.TextChangeCommand=ur;exports.TextGlobalPropertyHandle=Rr;exports.TextInput=mc;exports.TextStepHandle=br;exports.Transform=Vr;exports.TransformCollection=Lr;exports.UnhandledBehaviorError=z;exports.UnitOfMeasurement=xn;exports.UpdateImageSourceCommand=yo;exports.Variant=it;exports.WorkflowExperienceEventType=Mr;exports.WorkflowExperienceImpl=Tr;exports.assetService=U;exports.browserColorToHex=Ln;exports.cmPerPixel=Ks;exports.createDesign=kr;exports.currentDirection=Hs;exports.dataUrlFromExternalUrl=bi;exports.designService=be;exports.determineCorrectFontSizeAndLines=Kt;exports.digitalContentStepService=Qa;exports.domParser=ct;exports.duplicateBundle=qc;exports.duplicateTransaction=Gc;exports.fetchAsString=tt;exports.findAngle=Ls;exports.findElement=L;exports.findPmsColors=qi;exports.frameDataCache=xt;exports.frameStepService=ut;exports.generate=Q;exports.generateCommands=Nr;exports.generateSVGWithUnknownColors=ot;exports.generateStateFromDesignInputSteps=tc;exports.getAddressValidationJobs=id;exports.getAttributesFromArrayBuffer=le;exports.getAxisAlignedBoundingBox=Us;exports.getBoundedOffsets=Yr;exports.getBundleThemeConfiguration=xc;exports.getCustomer=Wc;exports.getCustomerBundles=jc;exports.getElementVertices=Ys;exports.getFrameData=ue;exports.getGlobalPropertyStateForBundle=Jo;exports.getIntegration=Hr;exports.getNEPoint=Ws;exports.getNWPoint=Gs;exports.getOrderedTransactions=Jc;exports.getOverrideThemeConfiguration=Dc;exports.getPointOfRotation=qs;exports.getProductCollections=cc;exports.getSEPoint=js;exports.getSvgElement=ze;exports.getTemplateBundles=_c;exports.getTemplateTransactions=Kc;exports.getTransaction=Fc;exports.getTransactionThemeConfiguration=kc;exports.getTransactionsForBundle=Hc;exports.getTrueCoordinates=zs;exports.getUnorderedTransactions=Yc;exports.getValidationJobsForWorkflowExperiences=rd;exports.getWorkflow=bc;exports.getWorkflows=ja;exports.graphQlManager=B;exports.illustrationStepService=Jt;exports.isCloseToValue=Vs;exports.loadFont=It;exports.matchHexToPms=Li;exports.materialStepService=Ra;exports.metafieldManager=$r;exports.mmPerPixel=Js;exports.modelStepService=Oa;exports.modifySVGColors=Ue;exports.moduleStepService=$a;exports.nameBundle=Vc;exports.nameTransaction=zc;exports.optionService=H;exports.outlineFontsInSvg=eo;exports.patternImageDataCache=dt;exports.persistenceService=T;exports.pictureStepService=Ua;exports.pmsToRgb=Ui;exports.questionStepService=La;exports.registerFetchImplementation=wi;exports.registerWindowImplementation=Ci;exports.rehydrateSerializedLayout=lr;exports.rgbToPms=Un;exports.rotateAroundPoint=jt;exports.sanitizeSvgTree=$e;exports.setBearerAuthenticationToken=On;exports.setCanvasModule=Ea;exports.shapeStepService=kt;exports.shortenUrl=hr;exports.spiffCoreConfiguration=At;exports.stepAspectValuesToDesignInputSteps=Zl;exports.svgColorValueToDefinition=da;exports.svgStringDimensions=Ta;exports.svgToDataUrl=Oe;exports.textStepService=W;exports.toast=mr;exports.validateWorkflowExperienceRecipient=sd;exports.validateWorkflowExperienceRecipients=od;exports.xmlSerializer=wt;
2644
2696
  //# sourceMappingURL=index.js.map