@spiffcommerce/core 13.3.2-alpha.0 → 13.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1335,5 +1335,5 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
1335
1335
  }
1336
1336
  }
1337
1337
  }
1338
- `,Gc=async t=>{const e=(await ya.getShadowGraphqlClient().query({query:bc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return e.steps.forEach((t=>{delete t.data.__typename})),e},Tc=(t,e)=>{const i=t.workflowState,A=i?JSON.parse(i):void 0;return A?Object.values(A.layouts).map((t=>t.layout)):e.panels.sort(((t,e)=>t.index-e.index)).map((t=>({id:Te(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})))};class Oc{constructor(t){var e;xc(this,"options",void 0),xc(this,"initialized",void 0),xc(this,"currencyCode",void 0),xc(this,"customer",void 0),xc(this,"experienceOptions",void 0),xc(this,"updateTransactionState",(async t=>{try{return ya.getShadowGraphqlClient().mutate({...t,mutation:Ps})}catch(t){throw console.error(t),new sa("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,Qa=e)}getAssetManager(){return Pa}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!this.options.applicationKey)throw new Error("Application key required to use Flow Service.");return new Cc}async authenticateBundleFromLocalStorage(t){const e=ha.getMap("bundleOwnerIds");if(e?.has(t)){const i=e.get(t);return ma(i),Promise.resolve({success:!0,stakeholderType:nr.Owner})}const i=ha.getMap("bundleCustomerIds");if(i?.has(t)){const e=i.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const e=ya.getShadowGraphqlClient(),i=await e.query({query:Yc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!i.data.transactions||0===i.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const A=i.data.transactions[0],n=A.product?.partner?.id;if(!n)throw new Error(`Unable to read transaction: ${t}`);if(A.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const a=ha.getMap("transactionOwnerIds");if(a?.has(t)){const e=a.get(t);return pa(e),Promise.resolve({success:!0,stakeholderType:nr.Owner})}const r=ha.getMap("transactionCustomerIds");if(r?.has(t)){const e=r.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.transactions?.some((e=>e.id===t))))||this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}const s=(await e.query({query:Pc,errorPolicy:"all",variables:{id:A.workflowId}})).data.workflow;if(!s)throw new Error(`Unable to read workflow: ${A.workflowId}`);return Promise.resolve({success:!1,theme:s.overrideTheme,customLogoLink:A.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=ha.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),ha.setMap("transactionCustomerIds",e))}getStakeholderTypeForTransaction(t){const e=this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return e.type}async getOrCreateCustomer(t){this.customer=void 0;const e=ya.getShadowGraphqlClient(),i=(await e.query({query:Nc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!i.id){const i=(await e.mutate({mutation:Rc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!i)throw new Error("Unable to create customer.");return this.customer=i,{customer:i,isAuthenticated:!1}}const A=await this.authenticateCustomerId(i.id);return{customer:this.customer||i,isAuthenticated:A}}async authenticateCustomerId(t){const e=ya.getShadowGraphqlClient(),i=ha.getMap("customerTokens");if(!i?.has(t))return!1;const A=i.get(t);if(!A)return!1;const n=(await e.mutate({mutation:kc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:A}})).data?.customerAuthenticate;return!!n&&(fa(A),this.customer=n,!0)}async generateVerificationCode(t){await ya.getShadowGraphqlClient().mutate({mutation:Hc,variables:{emailAddress:t}})}async verifyCode(t,e){const i=(await ya.getShadowGraphqlClient().mutate({mutation:Uc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data?.customerVerifyCode;if(i?.loginToken){if(!i.partner?.id)throw new Error(`Unable to find customer: ${t}`);const e=ha.getMap("customerTokens")||new Map;return e.set(i.id,i.loginToken),ha.setMap("customerTokens",e),fa(i.loginToken),this.customer={...i,loginToken:void 0},!0}return!1}async getNewBundle(t){const e=(await ya.getShadowGraphqlClient().mutate({mutation:$o,variables:{collectionId:t}})).data?.bundleCreate;if(!e)throw new Error("Unable to create bundle");ma(e.bundleOwnerId);const i=ha.getMap("bundleOwnerIds")||new Map;return i.set(e.id,e.bundleOwnerId),ha.setMap("bundleOwnerIds",i),new pc(this,e)}async getExistingBundle(t,e){const i=await ya.getShadowGraphqlClient().query({query:qo,variables:{id:t}});if(!i.data?.bundles||0===i.data?.bundles.length||!i.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);console.log("resp",i);const A=i.data?.bundles[0],n=ha.getMap("bundleOwnerIds");n?.has(A.id)&&ma(n.get(A.id));const a=new pc(this,A);if(A.transactions&&A.transactions.length>0){const t=t=>{const i=e?i=>e(i,t):void 0;return this.getWorkflowExperience(void 0,void 0,i,{type:"transaction",transactionId:t})},i=await Promise.all(A.transactions.map((e=>t(e.id))));a._setWorkflowExperiencesInternal(i)}return a}async getWorkflowExperience(t,e,i,A){if(!A)return await this.getWorkflowExperienceDeprecated(t,e,i);const n=async t=>{for(const e in t.layouts){const i=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<i.length;++t){const e=i[t];e.src&&e.svg&&(e.cachedObjectURL=await Kn(e.svg))}const A=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<A.length;++t){const e=A[t];e.fontData?.assetUrl&&rA(e.fontData.assetUrl)}}},{transaction:a,workflow:r,readOnly:s}=await(async()=>{const t=ya.getShadowGraphqlClient();if("transaction"===A.type){const{transactionId:e,readOnly:i}=A,n=await t.query({query:Ys,variables:{id:e},errorPolicy:"all",fetchPolicy:"no-cache"});if(!n.data?.transactions||0===n.data.transactions.length)throw new sa("Existing transaction not found.");const a=n.data?.transactions[0];if(!a.workflowId)throw new sa("Existing transaction has no workflow ID.");const r=await Gc(a.workflowId);if(!a.product)throw new sa("Failed to load transaction, product not available.");return{transaction:a,workflow:r,readOnly:i}}if("integration"===A.type||"external"===A.type){const e=async()=>{const e="integration"===A.type?{integrationProductId:A.integrationProductId}:{externalIntegrationId:A.externalIntegrationId,externalProductId:A.externalProductId},i=await t.mutate({mutation:Fs,variables:{...e,bulk:A.bulk,workflowId:A.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!i.data||!i.data.transactionCreate)throw new sa("Failed to create transaction!");const n=i.data.transactionCreate;if(!n.product)throw new sa("Failed to create transaction, product not available.");return n},i=Gc(A.workflowId),[n,a]=await Promise.all([e(),i]);return{transaction:n,workflow:a}}throw new sa("No workflow ID provided.")})();this.currencyCode=a.product.partner?.currencyCode;const o={product:a.product,transaction:a,layouts:[],stateMutationFunc:s?async()=>{throw new aa("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:s,workflow:r};if("transaction"===A.type&&a.workflowState){const t=JSON.parse(a.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await XA(t),await n(t),o.reloadedState=t}else if(!s&&A.workflowState){const t=JSON.parse(A.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await XA(t),await n(t),o.reloadedState=t}else o.layouts=Tc(o.transaction,o.workflow);if(o.renderableContextService=new fs(o.layouts),A.previewService?(o.previewService=A.previewService,o.product?.modelUrl&&(o.modelContainer=o.previewService.loadModel({model:o.product.modelUrl,contextService:o.renderableContextService}))):(o.previewService=i&&i(r),o.product?.modelUrl&&(o.previewService?.initialize({model:o.product.modelUrl,contextService:o.renderableContextService}),o.modelContainer=o.previewService?.getAllModels()[0])),"transaction"!==A.type){const t=ha.getMap("transactionOwnerIds")||new Map;t.set(a.id,a.transactionOwnerId),pa(a.transactionOwnerId||""),ha.setMap("transactionOwnerIds",t)}else{const t=(ha.getMap("transactionOwnerIds")||new Map).get(a.id);t&&pa(t),o.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=o;const c=new Ko(this,o);return await c.getWorkflowManager().getInitializationPromise(),"transaction"!==A.type&&this.customer&&await c.attachCustomerDetails({email:this.customer.emailAddress}),c}async initFromIntegrationProduct(t){if(""===t)throw new sa("No integration product ID provided.");const e=ya.getShadowGraphqlClient(),i=await e.mutate({mutation:Fs,variables:{integrationProductId:t,bulk:this.options.bulk||!1,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!i.data||!i.data.transactionCreate)throw new sa("Failed to create transaction!");const A=i.data.transactionCreate;if(!A.product)throw new sa("Failed to create transaction, product not available.");this.currencyCode=A.product.partner?.currencyCode;const n=ha.getMap("transactionOwnerIds")||new Map;n.set(A.id,A.transactionOwnerId),pa(A.transactionOwnerId||""),ha.setMap("transactionOwnerIds",n),this.experienceOptions={product:A.product,transaction:A,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new sa("No transaction ID provided.");const i=ya.getShadowGraphqlClient();if(e)return await(async()=>{const A=(await i.query({query:Ys,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!A)throw new sa("Failed to read transaction.");if(!A.product)throw new sa("Failed to load transaction, product not available.");this.currencyCode=A.product.partner?.currencyCode,this.experienceOptions={product:A.product,transaction:A,layouts:[],stateMutationFunc:async()=>{throw new aa("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const A=ha.getMap("transactionOwnerIds")||new Map,n=A.get(t);if(n){pa(n);const A=(await i.query({query:Ys,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!A)throw new sa("Failed to read transaction.");if(!A.product)throw new sa("Failed to load transaction, product not available.");return this.currencyCode=A.product.partner?.currencyCode,this.experienceOptions={product:A.product,transaction:A,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const n=(await i.mutate({mutation:bs,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!n)throw new sa("Failed to read transaction.");if(!n.product)throw new sa("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,n.transactionOwnerId&&(A.set(n.id,n.transactionOwnerId),pa(n.transactionOwnerId),ha.setMap("transactionOwnerIds",A)),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new sa("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,i){if(!this.initialized||!this.experienceOptions)throw new sa("Cannot launch experience: Not initialized.");const A=async t=>{for(const e in t.layouts){const i=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<i.length;++t){const e=i[t];e.src&&e.svg&&(e.cachedObjectURL=await Kn(e.svg))}const A=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<A.length;++t){const e=A[t];e.fontData?.assetUrl&&rA(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await Gc(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=t,this.experienceOptions.transaction.workflowState){const t=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await XA(t),await A(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=i&&i(t),this.experienceOptions.renderableContextService=new fs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const e=new Ko(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const n=ya.getShadowGraphqlClient().mutate({mutation:Ns,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),a=Gc(t);if(await Promise.all([n,a]),this.experienceOptions.workflow=await a,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await XA(t),await A(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=Tc(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=i&&i(await a),this.experienceOptions.renderableContextService=new fs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const r=new Ko(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}throw new sa("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new sa("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new sa("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function Jc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Lc{constructor(){Jc(this,"getProduct",void 0),Jc(this,"getCommandContext",void 0),Jc(this,"getAllLayoutData",void 0),Jc(this,"getMetadata",void 0),Jc(this,"getWorkflowMetadata",void 0),Jc(this,"getStepStorage",void 0),Jc(this,"setModelContainer",void 0),Jc(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(t){}addVariationRecord(t){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(t){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addCurrentVariationCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(t){}setCurrentVariationRecord(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,i){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function zc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let jc;var Vc;(Vc=jc||(jc={})).SelectFrame="SelectFrame",Vc.SelectImage="SelectImage",Vc.Position="Position";class Kc extends Do{constructor(t,e){super(t,e),zc(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return io.selectVariant(this.step,t.getResource(),e,this.manager,(t=>this.setUpdateState(t)))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged((e=>{e&&t(e)}))}selectImage(t){return io.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,i,A){return A&&A.length>1&&void 0===t?jc.SelectFrame:e||i||this.getImageData()?jc.Position:jc.SelectImage}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}hasVaryingUpload(){return this.step.data.varyUpload}hasVaryingSelection(){return this.step.data.varySelection}}const Wc=t=>{const e=(0,A.useRef)(null),n=(0,A.useRef)(void 0),[a,r]=(0,A.useState)(void 0),{addEvent:s,removeEvent:o,updateEvent:c,eventCache:l}=Ga(),[g,h]=(0,A.useState)(!1),[d,u]=(0,A.useState)(!1),{state:w,uiDispatcher:B}=Xa(),p=(0,A.useCallback)((t=>{const e=t;B(new Wa({zoom:Math.max(.1,Math.min(e,w.maxZoom))}))}),[B,w.maxZoom]),E=(0,A.useCallback)((t=>{o(t),1===l.length&&(n.current=void 0),2===l.length&&r(void 0);"touch"===t.pointerType&&l.length>1&&l.length-1==1&&(u(!1),h(!1))}),[o,l.length]),m=(0,A.useCallback)((t=>{s(t);"touch"===t.pointerType&&1===l.length&&(B(new Wa({selectedElement:void 0})),u(!0),h(!0))}),[s,l.length,B]),C=(0,A.useCallback)((t=>{c(t);const e=1===l.length&&"touch"!==l[0].pointerType,i=2===l.length&&"touch"===l[0].pointerType;if(g&&i){const[t,e]=l,i=Math.abs(t.clientX-e.clientX),A=a;A&&p(w.zoom-.0055*(A-i)),r(i)}if(d&&(e||i)&&t.isPrimary){const e=(n?.current?.x||t.screenX)-t.screenX,i=(n?.current?.y||t.screenY)-t.screenY;B(new Wa({selectedElement:void 0,xTranslation:w.xTranslation-e/w.zoom,yTranslation:w.yTranslation-i/w.zoom}))}t.isPrimary&&(n.current={x:t.screenX,y:t.screenY})}),[c,l,g,d,a,p,w.zoom,w.xTranslation,w.yTranslation,B]),f=(0,A.useCallback)((t=>{g&&p(w.zoom-.035*Math.sign(t.deltaY))}),[p,w.zoom,g]);(0,A.useEffect)((()=>{if(!e.current||0===l.length)return;const t=l[0].pointerId,i=e.current.hasPointerCapture(t);d&&!i&&e.current.setPointerCapture(t),!d&&i&&e.current.releasePointerCapture(t)}),[e,d,l]),Ur([" "],(()=>{u(!0),B(new Wa({selectedElement:void 0}))}),(()=>u(!1))),Ur(["Control"],(()=>h(!0)),(()=>h(!1)));const Q=(0,A.useMemo)((()=>({cursor:d&&0===l.length?"grab":d&&1===l.length?"grabbing":g?"zoom-in":void 0,width:"100%",height:"100%",overflow:"clip"})),[d,g,l]);return(0,i.jsx)("div",{ref:e,className:"transform-wrapper",onWheel:f,onPointerDown:m,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:C,style:Q,children:t.children})};
1338
+ `,Gc=async t=>{const e=(await ya.getShadowGraphqlClient().query({query:bc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return e.steps.forEach((t=>{delete t.data.__typename})),e},Tc=(t,e)=>{const i=t.workflowState,A=i?JSON.parse(i):void 0;return A?Object.values(A.layouts).map((t=>t.layout)):e.panels.sort(((t,e)=>t.index-e.index)).map((t=>({id:Te(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})))};class Oc{constructor(t){var e;xc(this,"options",void 0),xc(this,"initialized",void 0),xc(this,"currencyCode",void 0),xc(this,"customer",void 0),xc(this,"experienceOptions",void 0),xc(this,"updateTransactionState",(async t=>{try{return ya.getShadowGraphqlClient().mutate({...t,mutation:Ps})}catch(t){throw console.error(t),new sa("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,Qa=e)}getAssetManager(){return Pa}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!this.options.applicationKey)throw new Error("Application key required to use Flow Service.");return new Cc}async authenticateBundleFromLocalStorage(t){const e=ha.getMap("bundleOwnerIds");if(e?.has(t)){const i=e.get(t);return ma(i),Promise.resolve({success:!0,stakeholderType:nr.Owner})}const i=ha.getMap("bundleCustomerIds");if(i?.has(t)){const e=i.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const e=ya.getShadowGraphqlClient(),i=await e.query({query:Yc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!i.data.transactions||0===i.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const A=i.data.transactions[0],n=A.product?.partner?.id;if(!n)throw new Error(`Unable to read transaction: ${t}`);if(A.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const a=ha.getMap("transactionOwnerIds");if(a?.has(t)){const e=a.get(t);return pa(e),Promise.resolve({success:!0,stakeholderType:nr.Owner})}const r=ha.getMap("transactionCustomerIds");if(r?.has(t)){const e=r.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.transactions?.some((e=>e.id===t))))||this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}const s=(await e.query({query:Pc,errorPolicy:"all",variables:{id:A.workflowId}})).data.workflow;if(!s)throw new Error(`Unable to read workflow: ${A.workflowId}`);return Promise.resolve({success:!1,theme:s.overrideTheme,customLogoLink:A.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=ha.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),ha.setMap("transactionCustomerIds",e))}getStakeholderTypeForTransaction(t){const e=this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return e.type}async getOrCreateCustomer(t){this.customer=void 0;const e=ya.getShadowGraphqlClient(),i=(await e.query({query:Nc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!i.id){const i=(await e.mutate({mutation:Rc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!i)throw new Error("Unable to create customer.");return this.customer=i,{customer:i,isAuthenticated:!1}}const A=await this.authenticateCustomerId(i.id);return{customer:this.customer||i,isAuthenticated:A}}async authenticateCustomerId(t){const e=ya.getShadowGraphqlClient(),i=ha.getMap("customerTokens");if(!i?.has(t))return!1;const A=i.get(t);if(!A)return!1;const n=(await e.mutate({mutation:kc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:A}})).data?.customerAuthenticate;return!!n&&(fa(A),this.customer=n,!0)}async generateVerificationCode(t){await ya.getShadowGraphqlClient().mutate({mutation:Hc,variables:{emailAddress:t}})}async verifyCode(t,e){const i=(await ya.getShadowGraphqlClient().mutate({mutation:Uc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data?.customerVerifyCode;if(i?.loginToken){if(!i.partner?.id)throw new Error(`Unable to find customer: ${t}`);const e=ha.getMap("customerTokens")||new Map;return e.set(i.id,i.loginToken),ha.setMap("customerTokens",e),fa(i.loginToken),this.customer={...i,loginToken:void 0},!0}return!1}async getNewBundle(t){const e=(await ya.getShadowGraphqlClient().mutate({mutation:$o,variables:{collectionId:t},fetchPolicy:"no-cache"})).data?.bundleCreate;if(!e)throw new Error("Unable to create bundle");ma(e.bundleOwnerId);const i=ha.getMap("bundleOwnerIds")||new Map;return i.set(e.id,e.bundleOwnerId),ha.setMap("bundleOwnerIds",i),new pc(this,e)}async getExistingBundle(t,e){const i=await ya.getShadowGraphqlClient().query({query:qo,variables:{id:t},fetchPolicy:"no-cache"});if(!i.data?.bundles||0===i.data?.bundles.length||!i.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const A=i.data?.bundles[0],n=ha.getMap("bundleOwnerIds");n?.has(A.id)&&ma(n.get(A.id));const a=new pc(this,A);if(A.transactions&&A.transactions.length>0){const t=t=>{const i=e?i=>e(i,t):void 0;return this.getWorkflowExperience(void 0,void 0,i,{type:"transaction",transactionId:t})},i=await Promise.all(A.transactions.map((e=>t(e.id))));a._setWorkflowExperiencesInternal(i)}return a}async getWorkflowExperience(t,e,i,A){if(!A)return await this.getWorkflowExperienceDeprecated(t,e,i);const n=async t=>{for(const e in t.layouts){const i=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<i.length;++t){const e=i[t];e.src&&e.svg&&(e.cachedObjectURL=await Kn(e.svg))}const A=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<A.length;++t){const e=A[t];e.fontData?.assetUrl&&rA(e.fontData.assetUrl)}}},{transaction:a,workflow:r,readOnly:s}=await(async()=>{const t=ya.getShadowGraphqlClient();if("transaction"===A.type){const{transactionId:e,readOnly:i}=A,n=await t.query({query:Ys,variables:{id:e},errorPolicy:"all",fetchPolicy:"no-cache"});if(!n.data?.transactions||0===n.data.transactions.length)throw new sa("Existing transaction not found.");const a=n.data?.transactions[0];if(!a.workflowId)throw new sa("Existing transaction has no workflow ID.");const r=await Gc(a.workflowId);if(!a.product)throw new sa("Failed to load transaction, product not available.");return{transaction:a,workflow:r,readOnly:i}}if("integration"===A.type||"external"===A.type){const e=async()=>{const e="integration"===A.type?{integrationProductId:A.integrationProductId}:{externalIntegrationId:A.externalIntegrationId,externalProductId:A.externalProductId},i=await t.mutate({mutation:Fs,variables:{...e,bulk:A.bulk,workflowId:A.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!i.data||!i.data.transactionCreate)throw new sa("Failed to create transaction!");const n=i.data.transactionCreate;if(!n.product)throw new sa("Failed to create transaction, product not available.");return n},i=Gc(A.workflowId),[n,a]=await Promise.all([e(),i]);return{transaction:n,workflow:a}}throw new sa("No workflow ID provided.")})();this.currencyCode=a.product.partner?.currencyCode;const o={product:a.product,transaction:a,layouts:[],stateMutationFunc:s?async()=>{throw new aa("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:s,workflow:r};if("transaction"===A.type&&a.workflowState){const t=JSON.parse(a.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await XA(t),await n(t),o.reloadedState=t}else if(!s&&A.workflowState){const t=JSON.parse(A.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await XA(t),await n(t),o.reloadedState=t}else o.layouts=Tc(o.transaction,o.workflow);if(o.renderableContextService=new fs(o.layouts),A.previewService?(o.previewService=A.previewService,o.product?.modelUrl&&(o.modelContainer=o.previewService.loadModel({model:o.product.modelUrl,contextService:o.renderableContextService}))):(o.previewService=i&&i(r),o.product?.modelUrl&&(o.previewService?.initialize({model:o.product.modelUrl,contextService:o.renderableContextService}),o.modelContainer=o.previewService?.getAllModels()[0])),"transaction"!==A.type){const t=ha.getMap("transactionOwnerIds")||new Map;t.set(a.id,a.transactionOwnerId),pa(a.transactionOwnerId||""),ha.setMap("transactionOwnerIds",t)}else{const t=(ha.getMap("transactionOwnerIds")||new Map).get(a.id);t&&pa(t),o.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=o;const c=new Ko(this,o);return await c.getWorkflowManager().getInitializationPromise(),"transaction"!==A.type&&this.customer&&await c.attachCustomerDetails({email:this.customer.emailAddress}),c}async initFromIntegrationProduct(t){if(""===t)throw new sa("No integration product ID provided.");const e=ya.getShadowGraphqlClient(),i=await e.mutate({mutation:Fs,variables:{integrationProductId:t,bulk:this.options.bulk||!1,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!i.data||!i.data.transactionCreate)throw new sa("Failed to create transaction!");const A=i.data.transactionCreate;if(!A.product)throw new sa("Failed to create transaction, product not available.");this.currencyCode=A.product.partner?.currencyCode;const n=ha.getMap("transactionOwnerIds")||new Map;n.set(A.id,A.transactionOwnerId),pa(A.transactionOwnerId||""),ha.setMap("transactionOwnerIds",n),this.experienceOptions={product:A.product,transaction:A,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new sa("No transaction ID provided.");const i=ya.getShadowGraphqlClient();if(e)return await(async()=>{const A=(await i.query({query:Ys,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!A)throw new sa("Failed to read transaction.");if(!A.product)throw new sa("Failed to load transaction, product not available.");this.currencyCode=A.product.partner?.currencyCode,this.experienceOptions={product:A.product,transaction:A,layouts:[],stateMutationFunc:async()=>{throw new aa("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const A=ha.getMap("transactionOwnerIds")||new Map,n=A.get(t);if(n){pa(n);const A=(await i.query({query:Ys,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!A)throw new sa("Failed to read transaction.");if(!A.product)throw new sa("Failed to load transaction, product not available.");return this.currencyCode=A.product.partner?.currencyCode,this.experienceOptions={product:A.product,transaction:A,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const n=(await i.mutate({mutation:bs,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!n)throw new sa("Failed to read transaction.");if(!n.product)throw new sa("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,n.transactionOwnerId&&(A.set(n.id,n.transactionOwnerId),pa(n.transactionOwnerId),ha.setMap("transactionOwnerIds",A)),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new sa("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,i){if(!this.initialized||!this.experienceOptions)throw new sa("Cannot launch experience: Not initialized.");const A=async t=>{for(const e in t.layouts){const i=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<i.length;++t){const e=i[t];e.src&&e.svg&&(e.cachedObjectURL=await Kn(e.svg))}const A=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<A.length;++t){const e=A[t];e.fontData?.assetUrl&&rA(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await Gc(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=t,this.experienceOptions.transaction.workflowState){const t=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await XA(t),await A(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=i&&i(t),this.experienceOptions.renderableContextService=new fs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const e=new Ko(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const n=ya.getShadowGraphqlClient().mutate({mutation:Ns,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),a=Gc(t);if(await Promise.all([n,a]),this.experienceOptions.workflow=await a,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await XA(t),await A(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=Tc(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=i&&i(await a),this.experienceOptions.renderableContextService=new fs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const r=new Ko(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}throw new sa("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new sa("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new sa("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function Jc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Lc{constructor(){Jc(this,"getProduct",void 0),Jc(this,"getCommandContext",void 0),Jc(this,"getAllLayoutData",void 0),Jc(this,"getMetadata",void 0),Jc(this,"getWorkflowMetadata",void 0),Jc(this,"getStepStorage",void 0),Jc(this,"setModelContainer",void 0),Jc(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(t){}addVariationRecord(t){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(t){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addCurrentVariationCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(t){}setCurrentVariationRecord(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,i){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function zc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var A=i.call(t,e||"default");if("object"!=typeof A)return A;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let jc;var Vc;(Vc=jc||(jc={})).SelectFrame="SelectFrame",Vc.SelectImage="SelectImage",Vc.Position="Position";class Kc extends Do{constructor(t,e){super(t,e),zc(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return io.selectVariant(this.step,t.getResource(),e,this.manager,(t=>this.setUpdateState(t)))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged((e=>{e&&t(e)}))}selectImage(t){return io.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,i,A){return A&&A.length>1&&void 0===t?jc.SelectFrame:e||i||this.getImageData()?jc.Position:jc.SelectImage}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}hasVaryingUpload(){return this.step.data.varyUpload}hasVaryingSelection(){return this.step.data.varySelection}}const Wc=t=>{const e=(0,A.useRef)(null),n=(0,A.useRef)(void 0),[a,r]=(0,A.useState)(void 0),{addEvent:s,removeEvent:o,updateEvent:c,eventCache:l}=Ga(),[g,h]=(0,A.useState)(!1),[d,u]=(0,A.useState)(!1),{state:w,uiDispatcher:B}=Xa(),p=(0,A.useCallback)((t=>{const e=t;B(new Wa({zoom:Math.max(.1,Math.min(e,w.maxZoom))}))}),[B,w.maxZoom]),E=(0,A.useCallback)((t=>{o(t),1===l.length&&(n.current=void 0),2===l.length&&r(void 0);"touch"===t.pointerType&&l.length>1&&l.length-1==1&&(u(!1),h(!1))}),[o,l.length]),m=(0,A.useCallback)((t=>{s(t);"touch"===t.pointerType&&1===l.length&&(B(new Wa({selectedElement:void 0})),u(!0),h(!0))}),[s,l.length,B]),C=(0,A.useCallback)((t=>{c(t);const e=1===l.length&&"touch"!==l[0].pointerType,i=2===l.length&&"touch"===l[0].pointerType;if(g&&i){const[t,e]=l,i=Math.abs(t.clientX-e.clientX),A=a;A&&p(w.zoom-.0055*(A-i)),r(i)}if(d&&(e||i)&&t.isPrimary){const e=(n?.current?.x||t.screenX)-t.screenX,i=(n?.current?.y||t.screenY)-t.screenY;B(new Wa({selectedElement:void 0,xTranslation:w.xTranslation-e/w.zoom,yTranslation:w.yTranslation-i/w.zoom}))}t.isPrimary&&(n.current={x:t.screenX,y:t.screenY})}),[c,l,g,d,a,p,w.zoom,w.xTranslation,w.yTranslation,B]),f=(0,A.useCallback)((t=>{g&&p(w.zoom-.035*Math.sign(t.deltaY))}),[p,w.zoom,g]);(0,A.useEffect)((()=>{if(!e.current||0===l.length)return;const t=l[0].pointerId,i=e.current.hasPointerCapture(t);d&&!i&&e.current.setPointerCapture(t),!d&&i&&e.current.releasePointerCapture(t)}),[e,d,l]),Ur([" "],(()=>{u(!0),B(new Wa({selectedElement:void 0}))}),(()=>u(!1))),Ur(["Control"],(()=>h(!0)),(()=>h(!1)));const Q=(0,A.useMemo)((()=>({cursor:d&&0===l.length?"grab":d&&1===l.length?"grabbing":g?"zoom-in":void 0,width:"100%",height:"100%",overflow:"clip"})),[d,g,l]);return(0,i.jsx)("div",{ref:e,className:"transform-wrapper",onWheel:f,onPointerDown:m,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:C,style:Q,children:t.children})};
1339
1339
  //# sourceMappingURL=main.js.map
package/dist/module.js CHANGED
@@ -1335,5 +1335,5 @@ import{CommandContext as t,AssetType as e,BringForwardCommand as A,BringToFrontC
1335
1335
  }
1336
1336
  }
1337
1337
  }
1338
- `,Ja=async t=>{const e=(await ye.getShadowGraphqlClient().query({query:Na,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return e.steps.forEach((t=>{delete t.data.__typename})),e},La=(t,e)=>{const A=t.workflowState,n=A?JSON.parse(A):void 0;return n?Object.values(n.layouts).map((t=>t.layout)):e.panels.sort(((t,e)=>t.index-e.index)).map((t=>({id:F(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})))};class Ta{constructor(t){var e;Fa(this,"options",void 0),Fa(this,"initialized",void 0),Fa(this,"currencyCode",void 0),Fa(this,"customer",void 0),Fa(this,"experienceOptions",void 0),Fa(this,"updateTransactionState",(async t=>{try{return ye.getShadowGraphqlClient().mutate({...t,mutation:Un})}catch(t){throw console.error(t),new ce("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,fe=e)}getAssetManager(){return He}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!this.options.applicationKey)throw new Error("Application key required to use Flow Service.");return new ma}async authenticateBundleFromLocalStorage(t){const e=de.getMap("bundleOwnerIds");if(e?.has(t)){const A=e.get(t);return me(A),Promise.resolve({success:!0,stakeholderType:oA.Owner})}const A=de.getMap("bundleCustomerIds");if(A?.has(t)){const e=A.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const e=ye.getShadowGraphqlClient(),A=await e.query({query:Pa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!A.data.transactions||0===A.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const n=A.data.transactions[0],i=n.product?.partner?.id;if(!i)throw new Error(`Unable to read transaction: ${t}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const a=de.getMap("transactionOwnerIds");if(a?.has(t)){const e=a.get(t);return Qe(e),Promise.resolve({success:!0,stakeholderType:oA.Owner})}const o=de.getMap("transactionCustomerIds");if(o?.has(t)){const e=o.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.transactions?.some((e=>e.id===t))))||this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}const r=(await e.query({query:Ra,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!r)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:r.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=de.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),de.setMap("transactionCustomerIds",e))}getStakeholderTypeForTransaction(t){const e=this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return e.type}async getOrCreateCustomer(t){this.customer=void 0;const e=ye.getShadowGraphqlClient(),A=(await e.query({query:Ha,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!A.id){const A=(await e.mutate({mutation:Ua,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!A)throw new Error("Unable to create customer.");return this.customer=A,{customer:A,isAuthenticated:!1}}const n=await this.authenticateCustomerId(A.id);return{customer:this.customer||A,isAuthenticated:n}}async authenticateCustomerId(t){const e=ye.getShadowGraphqlClient(),A=de.getMap("customerTokens");if(!A?.has(t))return!1;const n=A.get(t);if(!n)return!1;const i=(await e.mutate({mutation:ba,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data?.customerAuthenticate;return!!i&&(Ie(n),this.customer=i,!0)}async generateVerificationCode(t){await ye.getShadowGraphqlClient().mutate({mutation:Ga,variables:{emailAddress:t}})}async verifyCode(t,e){const A=(await ye.getShadowGraphqlClient().mutate({mutation:ka,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data?.customerVerifyCode;if(A?.loginToken){if(!A.partner?.id)throw new Error(`Unable to find customer: ${t}`);const e=de.getMap("customerTokens")||new Map;return e.set(A.id,A.loginToken),de.setMap("customerTokens",e),Ie(A.loginToken),this.customer={...A,loginToken:void 0},!0}return!1}async getNewBundle(t){const e=(await ye.getShadowGraphqlClient().mutate({mutation:_i,variables:{collectionId:t}})).data?.bundleCreate;if(!e)throw new Error("Unable to create bundle");me(e.bundleOwnerId);const A=de.getMap("bundleOwnerIds")||new Map;return A.set(e.id,e.bundleOwnerId),de.setMap("bundleOwnerIds",A),new ua(this,e)}async getExistingBundle(t,e){const A=await ye.getShadowGraphqlClient().query({query:Zi,variables:{id:t}});if(!A.data?.bundles||0===A.data?.bundles.length||!A.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);console.log("resp",A);const n=A.data?.bundles[0],i=de.getMap("bundleOwnerIds");i?.has(n.id)&&me(i.get(n.id));const a=new ua(this,n);if(n.transactions&&n.transactions.length>0){const t=t=>{const A=e?A=>e(A,t):void 0;return this.getWorkflowExperience(void 0,void 0,A,{type:"transaction",transactionId:t})},A=await Promise.all(n.transactions.map((e=>t(e.id))));a._setWorkflowExperiencesInternal(A)}return a}async getWorkflowExperience(t,e,A,n){if(!n)return await this.getWorkflowExperienceDeprecated(t,e,A);const i=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await dt(e.svg))}const n=t.layouts[e].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const e=n[t];e.fontData?.assetUrl&&H(e.fontData.assetUrl)}}},{transaction:a,workflow:o,readOnly:r}=await(async()=>{const t=ye.getShadowGraphqlClient();if("transaction"===n.type){const{transactionId:e,readOnly:A}=n,i=await t.query({query:Hn,variables:{id:e},errorPolicy:"all",fetchPolicy:"no-cache"});if(!i.data?.transactions||0===i.data.transactions.length)throw new ce("Existing transaction not found.");const a=i.data?.transactions[0];if(!a.workflowId)throw new ce("Existing transaction has no workflow ID.");const o=await Ja(a.workflowId);if(!a.product)throw new ce("Failed to load transaction, product not available.");return{transaction:a,workflow:o,readOnly:A}}if("integration"===n.type||"external"===n.type){const e=async()=>{const e="integration"===n.type?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},A=await t.mutate({mutation:Pn,variables:{...e,bulk:n.bulk,workflowId:n.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new ce("Failed to create transaction!");const i=A.data.transactionCreate;if(!i.product)throw new ce("Failed to create transaction, product not available.");return i},A=Ja(n.workflowId),[i,a]=await Promise.all([e(),A]);return{transaction:i,workflow:a}}throw new ce("No workflow ID provided.")})();this.currencyCode=a.product.partner?.currencyCode;const s={product:a.product,transaction:a,layouts:[],stateMutationFunc:r?async()=>{throw new re("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:r,workflow:o};if("transaction"===n.type&&a.workflowState){const t=JSON.parse(a.workflowState);s.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await i(t),s.reloadedState=t}else if(!r&&n.workflowState){const t=JSON.parse(n.workflowState);s.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await i(t),s.reloadedState=t}else s.layouts=La(s.transaction,s.workflow);if(s.renderableContextService=new fn(s.layouts),n.previewService?(s.previewService=n.previewService,s.product?.modelUrl&&(s.modelContainer=s.previewService.loadModel({model:s.product.modelUrl,contextService:s.renderableContextService}))):(s.previewService=A&&A(o),s.product?.modelUrl&&(s.previewService?.initialize({model:s.product.modelUrl,contextService:s.renderableContextService}),s.modelContainer=s.previewService?.getAllModels()[0])),"transaction"!==n.type){const t=de.getMap("transactionOwnerIds")||new Map;t.set(a.id,a.transactionOwnerId),Qe(a.transactionOwnerId||""),de.setMap("transactionOwnerIds",t)}else{const t=(de.getMap("transactionOwnerIds")||new Map).get(a.id);t&&Qe(t),s.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=s;const c=new Xi(this,s);return await c.getWorkflowManager().getInitializationPromise(),"transaction"!==n.type&&this.customer&&await c.attachCustomerDetails({email:this.customer.emailAddress}),c}async initFromIntegrationProduct(t){if(""===t)throw new ce("No integration product ID provided.");const e=ye.getShadowGraphqlClient(),A=await e.mutate({mutation:Pn,variables:{integrationProductId:t,bulk:this.options.bulk||!1,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new ce("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new ce("Failed to create transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode;const i=de.getMap("transactionOwnerIds")||new Map;i.set(n.id,n.transactionOwnerId),Qe(n.transactionOwnerId||""),de.setMap("transactionOwnerIds",i),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new ce("No transaction ID provided.");const A=ye.getShadowGraphqlClient();if(e)return await(async()=>{const n=(await A.query({query:Hn,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!n)throw new ce("Failed to read transaction.");if(!n.product)throw new ce("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async()=>{throw new re("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const n=de.getMap("transactionOwnerIds")||new Map,i=n.get(t);if(i){Qe(i);const n=(await A.query({query:Hn,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!n)throw new ce("Failed to read transaction.");if(!n.product)throw new ce("Failed to load transaction, product not available.");return this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const i=(await A.mutate({mutation:Rn,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!i)throw new ce("Failed to read transaction.");if(!i.product)throw new ce("Failed to load transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode,i.transactionOwnerId&&(n.set(i.id,i.transactionOwnerId),Qe(i.transactionOwnerId),de.setMap("transactionOwnerIds",n)),this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new ce("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,A){if(!this.initialized||!this.experienceOptions)throw new ce("Cannot launch experience: Not initialized.");const n=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await dt(e.svg))}const n=t.layouts[e].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const e=n[t];e.fontData?.assetUrl&&H(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await Ja(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=t,this.experienceOptions.transaction.workflowState){const t=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await n(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=A&&A(t),this.experienceOptions.renderableContextService=new fn(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const e=new Xi(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const i=ye.getShadowGraphqlClient().mutate({mutation:bn,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),a=Ja(t);if(await Promise.all([i,a]),this.experienceOptions.workflow=await a,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await n(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=La(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await a),this.experienceOptions.renderableContextService=new fn(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const o=new Xi(this,this.experienceOptions);return await o.getWorkflowManager().getInitializationPromise(),o}throw new ce("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new ce("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new ce("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function Oa(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class za{constructor(){Oa(this,"getProduct",void 0),Oa(this,"getCommandContext",void 0),Oa(this,"getAllLayoutData",void 0),Oa(this,"getMetadata",void 0),Oa(this,"getWorkflowMetadata",void 0),Oa(this,"getStepStorage",void 0),Oa(this,"setModelContainer",void 0),Oa(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(t){}addVariationRecord(t){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(t){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addCurrentVariationCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(t){}setCurrentVariationRecord(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,A){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function ja(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let Ka;var Va;(Va=Ka||(Ka={})).SelectFrame="SelectFrame",Va.SelectImage="SelectImage",Va.Position="Position";class Wa extends Mi{constructor(t,e){super(t,e),ja(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return ai.selectVariant(this.step,t.getResource(),e,this.manager,(t=>this.setUpdateState(t)))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged((e=>{e&&t(e)}))}selectImage(t){return ai.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,A,n){return n&&n.length>1&&void 0===t?Ka.SelectFrame:e||A||this.getImageData()?Ka.Position:Ka.SelectImage}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}hasVaryingUpload(){return this.step.data.varyUpload}hasVaryingSelection(){return this.step.data.varySelection}}const Xa=t=>{const e=kt(null),A=kt(void 0),[n,i]=Pt(void 0),{addEvent:a,removeEvent:o,updateEvent:r,eventCache:s}=Le(),[c,g]=Pt(!1),[l,B]=Pt(!1),{state:w,uiDispatcher:d}=Ze(),h=Rt((t=>{const e=t;d(new qe({zoom:Math.max(.1,Math.min(e,w.maxZoom))}))}),[d,w.maxZoom]),E=Rt((t=>{o(t),1===s.length&&(A.current=void 0),2===s.length&&i(void 0);"touch"===t.pointerType&&s.length>1&&s.length-1==1&&(B(!1),g(!1))}),[o,s.length]),C=Rt((t=>{a(t);"touch"===t.pointerType&&1===s.length&&(d(new qe({selectedElement:void 0})),B(!0),g(!0))}),[a,s.length,d]),u=Rt((t=>{r(t);const e=1===s.length&&"touch"!==s[0].pointerType,a=2===s.length&&"touch"===s[0].pointerType;if(c&&a){const[t,e]=s,A=Math.abs(t.clientX-e.clientX),a=n;a&&h(w.zoom-.0055*(a-A)),i(A)}if(l&&(e||a)&&t.isPrimary){const e=(A?.current?.x||t.screenX)-t.screenX,n=(A?.current?.y||t.screenY)-t.screenY;d(new qe({selectedElement:void 0,xTranslation:w.xTranslation-e/w.zoom,yTranslation:w.yTranslation-n/w.zoom}))}t.isPrimary&&(A.current={x:t.screenX,y:t.screenY})}),[r,s,c,l,n,h,w.zoom,w.xTranslation,w.yTranslation,d]),Q=Rt((t=>{c&&h(w.zoom-.035*Math.sign(t.deltaY))}),[h,w.zoom,c]);Ut((()=>{if(!e.current||0===s.length)return;const t=s[0].pointerId,A=e.current.hasPointerCapture(t);l&&!A&&e.current.setPointerCapture(t),!l&&A&&e.current.releasePointerCapture(t)}),[e,l,s]),JA([" "],(()=>{B(!0),d(new qe({selectedElement:void 0}))}),(()=>B(!1))),JA(["Control"],(()=>g(!0)),(()=>g(!1)));const p=Gt((()=>({cursor:l&&0===s.length?"grab":l&&1===s.length?"grabbing":c?"zoom-in":void 0,width:"100%",height:"100%",overflow:"clip"})),[l,c,s]);return Jt("div",{ref:e,className:"transform-wrapper",onWheel:Q,onPointerDown:C,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:u,style:p,children:t.children})};export{Ta as SpiffCommerceClient,t as CommandContext,Ee as spiffCoreConfiguration,zA as PromiseQueue,OA as QueueablePromise,za as MockWorkflowManager,Qi as InformationMessageType,Mi as StepHandle,bi as TextStepHandle,Wa as FrameStepHandle,vi as BulkStepHandle,Ui as ShapeStepHandle,xi as IllustrationStepHandle,Ni as MaterialStepHandle,Pi as ModelStepHandle,Ri as PictureStepHandle,Hi as QuestionStepHandle,tA as BulkPriceCalculationStrategy,fi as Variant,ee as OptionNotFoundError,Ae as LayoutNotFoundError,ne as AssetNotFoundError,ie as ResourceNotFoundError,ae as MisconfigurationError,se as ParseError,re as UnhandledBehaviorError,He as assetService,Vi as designService,zi as createDesign,ke as optionService,de as persistenceService,ye as graphQlManager,gA as toast,Zn as FrameService,Xn as getBoundedOffsets,ai as frameStepService,si as modelStepService,ri as materialStepService,Bi as shapeStepService,li as questionStepService,ni as digitalContentStepService,ci as moduleStepService,gi as pictureStepService,Ci as textStepService,oi as illustrationStepService,$e as ProductCameraRig,Ka as FrameStep,AA as ConversionLocation,iA as ConversionDataType,Ja as getWorkflow,ti as shortenUrl,ya as ObjectInput,Ma as TextInput,Ia as ObjectInputType,e as AssetType,A as BringForwardCommand,n as BringToFrontCommand,i as BringToBackCommand,a as CanvasCommand,o as CreateElementCommand,r as CreateLayoutCommand,s as DeleteElementCommand,c as FontAlignmentCommand,g as FontColorCommand,l as FontSizeCommand,B as FontSourceCommand,w as GroupCommand,d as LayoutElementFactory,h as LayoutElementType,E as MoveCommand,C as ResizeCommand,u as RotateCommand,Q as SendBackwardsCommand,oA as StakeholderType,p as StepAspectType,m as StepType,D as TextChangeCommand,I as UnitOfMeasurement,f as dataUrlFromExternalUrl,y as findElement,M as frameDataCache,F as generate,Y as getAxisAlignedBoundingBox,S as generateSVGWithUnknownColors,v as getAttributesFromArrayBuffer,x as rehydrateSerializedLayout,N as getFrameData,P as getSvgElement,R as loadFontFromDataUrl,H as loadFontFromExternalUrl,U as determineCorrectFontSizeAndLines,b as patternImageDataCache,Dn as generateCommands,G as registerJSDOM,bA as minZoom,Nn as AdvancedEditor,Xa as TransformWrapper,xn as EditorCore,Te as useLayouts,Ze as useEditorState,kA as useEditorInteraction,JA as useShortcutCombination,Ve as commandReducer,Ke as getDefaultState,Je as CommandContextContext,Xe as AdvancedEditorStateProvider,We as AdvancedEditorContext,qe as UICommand,ze as EditorSubMenu,lA as ElementEventType,wA as KeyEvent,Ln as gatherVaryingStepAspects};
1338
+ `,Ja=async t=>{const e=(await ye.getShadowGraphqlClient().query({query:Na,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return e.steps.forEach((t=>{delete t.data.__typename})),e},La=(t,e)=>{const A=t.workflowState,n=A?JSON.parse(A):void 0;return n?Object.values(n.layouts).map((t=>t.layout)):e.panels.sort(((t,e)=>t.index-e.index)).map((t=>({id:F(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})))};class Ta{constructor(t){var e;Fa(this,"options",void 0),Fa(this,"initialized",void 0),Fa(this,"currencyCode",void 0),Fa(this,"customer",void 0),Fa(this,"experienceOptions",void 0),Fa(this,"updateTransactionState",(async t=>{try{return ye.getShadowGraphqlClient().mutate({...t,mutation:Un})}catch(t){throw console.error(t),new ce("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,fe=e)}getAssetManager(){return He}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!this.options.applicationKey)throw new Error("Application key required to use Flow Service.");return new ma}async authenticateBundleFromLocalStorage(t){const e=de.getMap("bundleOwnerIds");if(e?.has(t)){const A=e.get(t);return me(A),Promise.resolve({success:!0,stakeholderType:oA.Owner})}const A=de.getMap("bundleCustomerIds");if(A?.has(t)){const e=A.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const e=ye.getShadowGraphqlClient(),A=await e.query({query:Pa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!A.data.transactions||0===A.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const n=A.data.transactions[0],i=n.product?.partner?.id;if(!i)throw new Error(`Unable to read transaction: ${t}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const a=de.getMap("transactionOwnerIds");if(a?.has(t)){const e=a.get(t);return Qe(e),Promise.resolve({success:!0,stakeholderType:oA.Owner})}const o=de.getMap("transactionCustomerIds");if(o?.has(t)){const e=o.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.transactions?.some((e=>e.id===t))))||this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}const r=(await e.query({query:Ra,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!r)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:r.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=de.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),de.setMap("transactionCustomerIds",e))}getStakeholderTypeForTransaction(t){const e=this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return e.type}async getOrCreateCustomer(t){this.customer=void 0;const e=ye.getShadowGraphqlClient(),A=(await e.query({query:Ha,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!A.id){const A=(await e.mutate({mutation:Ua,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!A)throw new Error("Unable to create customer.");return this.customer=A,{customer:A,isAuthenticated:!1}}const n=await this.authenticateCustomerId(A.id);return{customer:this.customer||A,isAuthenticated:n}}async authenticateCustomerId(t){const e=ye.getShadowGraphqlClient(),A=de.getMap("customerTokens");if(!A?.has(t))return!1;const n=A.get(t);if(!n)return!1;const i=(await e.mutate({mutation:ba,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data?.customerAuthenticate;return!!i&&(Ie(n),this.customer=i,!0)}async generateVerificationCode(t){await ye.getShadowGraphqlClient().mutate({mutation:Ga,variables:{emailAddress:t}})}async verifyCode(t,e){const A=(await ye.getShadowGraphqlClient().mutate({mutation:ka,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data?.customerVerifyCode;if(A?.loginToken){if(!A.partner?.id)throw new Error(`Unable to find customer: ${t}`);const e=de.getMap("customerTokens")||new Map;return e.set(A.id,A.loginToken),de.setMap("customerTokens",e),Ie(A.loginToken),this.customer={...A,loginToken:void 0},!0}return!1}async getNewBundle(t){const e=(await ye.getShadowGraphqlClient().mutate({mutation:_i,variables:{collectionId:t},fetchPolicy:"no-cache"})).data?.bundleCreate;if(!e)throw new Error("Unable to create bundle");me(e.bundleOwnerId);const A=de.getMap("bundleOwnerIds")||new Map;return A.set(e.id,e.bundleOwnerId),de.setMap("bundleOwnerIds",A),new ua(this,e)}async getExistingBundle(t,e){const A=await ye.getShadowGraphqlClient().query({query:Zi,variables:{id:t},fetchPolicy:"no-cache"});if(!A.data?.bundles||0===A.data?.bundles.length||!A.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const n=A.data?.bundles[0],i=de.getMap("bundleOwnerIds");i?.has(n.id)&&me(i.get(n.id));const a=new ua(this,n);if(n.transactions&&n.transactions.length>0){const t=t=>{const A=e?A=>e(A,t):void 0;return this.getWorkflowExperience(void 0,void 0,A,{type:"transaction",transactionId:t})},A=await Promise.all(n.transactions.map((e=>t(e.id))));a._setWorkflowExperiencesInternal(A)}return a}async getWorkflowExperience(t,e,A,n){if(!n)return await this.getWorkflowExperienceDeprecated(t,e,A);const i=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await dt(e.svg))}const n=t.layouts[e].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const e=n[t];e.fontData?.assetUrl&&H(e.fontData.assetUrl)}}},{transaction:a,workflow:o,readOnly:r}=await(async()=>{const t=ye.getShadowGraphqlClient();if("transaction"===n.type){const{transactionId:e,readOnly:A}=n,i=await t.query({query:Hn,variables:{id:e},errorPolicy:"all",fetchPolicy:"no-cache"});if(!i.data?.transactions||0===i.data.transactions.length)throw new ce("Existing transaction not found.");const a=i.data?.transactions[0];if(!a.workflowId)throw new ce("Existing transaction has no workflow ID.");const o=await Ja(a.workflowId);if(!a.product)throw new ce("Failed to load transaction, product not available.");return{transaction:a,workflow:o,readOnly:A}}if("integration"===n.type||"external"===n.type){const e=async()=>{const e="integration"===n.type?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},A=await t.mutate({mutation:Pn,variables:{...e,bulk:n.bulk,workflowId:n.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new ce("Failed to create transaction!");const i=A.data.transactionCreate;if(!i.product)throw new ce("Failed to create transaction, product not available.");return i},A=Ja(n.workflowId),[i,a]=await Promise.all([e(),A]);return{transaction:i,workflow:a}}throw new ce("No workflow ID provided.")})();this.currencyCode=a.product.partner?.currencyCode;const s={product:a.product,transaction:a,layouts:[],stateMutationFunc:r?async()=>{throw new re("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:r,workflow:o};if("transaction"===n.type&&a.workflowState){const t=JSON.parse(a.workflowState);s.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await i(t),s.reloadedState=t}else if(!r&&n.workflowState){const t=JSON.parse(n.workflowState);s.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await i(t),s.reloadedState=t}else s.layouts=La(s.transaction,s.workflow);if(s.renderableContextService=new fn(s.layouts),n.previewService?(s.previewService=n.previewService,s.product?.modelUrl&&(s.modelContainer=s.previewService.loadModel({model:s.product.modelUrl,contextService:s.renderableContextService}))):(s.previewService=A&&A(o),s.product?.modelUrl&&(s.previewService?.initialize({model:s.product.modelUrl,contextService:s.renderableContextService}),s.modelContainer=s.previewService?.getAllModels()[0])),"transaction"!==n.type){const t=de.getMap("transactionOwnerIds")||new Map;t.set(a.id,a.transactionOwnerId),Qe(a.transactionOwnerId||""),de.setMap("transactionOwnerIds",t)}else{const t=(de.getMap("transactionOwnerIds")||new Map).get(a.id);t&&Qe(t),s.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=s;const c=new Xi(this,s);return await c.getWorkflowManager().getInitializationPromise(),"transaction"!==n.type&&this.customer&&await c.attachCustomerDetails({email:this.customer.emailAddress}),c}async initFromIntegrationProduct(t){if(""===t)throw new ce("No integration product ID provided.");const e=ye.getShadowGraphqlClient(),A=await e.mutate({mutation:Pn,variables:{integrationProductId:t,bulk:this.options.bulk||!1,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new ce("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new ce("Failed to create transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode;const i=de.getMap("transactionOwnerIds")||new Map;i.set(n.id,n.transactionOwnerId),Qe(n.transactionOwnerId||""),de.setMap("transactionOwnerIds",i),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new ce("No transaction ID provided.");const A=ye.getShadowGraphqlClient();if(e)return await(async()=>{const n=(await A.query({query:Hn,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!n)throw new ce("Failed to read transaction.");if(!n.product)throw new ce("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async()=>{throw new re("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const n=de.getMap("transactionOwnerIds")||new Map,i=n.get(t);if(i){Qe(i);const n=(await A.query({query:Hn,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!n)throw new ce("Failed to read transaction.");if(!n.product)throw new ce("Failed to load transaction, product not available.");return this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const i=(await A.mutate({mutation:Rn,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!i)throw new ce("Failed to read transaction.");if(!i.product)throw new ce("Failed to load transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode,i.transactionOwnerId&&(n.set(i.id,i.transactionOwnerId),Qe(i.transactionOwnerId),de.setMap("transactionOwnerIds",n)),this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new ce("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,A){if(!this.initialized||!this.experienceOptions)throw new ce("Cannot launch experience: Not initialized.");const n=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await dt(e.svg))}const n=t.layouts[e].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const e=n[t];e.fontData?.assetUrl&&H(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await Ja(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=t,this.experienceOptions.transaction.workflowState){const t=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await n(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=A&&A(t),this.experienceOptions.renderableContextService=new fn(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const e=new Xi(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const i=ye.getShadowGraphqlClient().mutate({mutation:bn,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),a=Ja(t);if(await Promise.all([i,a]),this.experienceOptions.workflow=await a,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await n(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=La(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await a),this.experienceOptions.renderableContextService=new fn(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const o=new Xi(this,this.experienceOptions);return await o.getWorkflowManager().getInitializationPromise(),o}throw new ce("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new ce("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new ce("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function Oa(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class za{constructor(){Oa(this,"getProduct",void 0),Oa(this,"getCommandContext",void 0),Oa(this,"getAllLayoutData",void 0),Oa(this,"getMetadata",void 0),Oa(this,"getWorkflowMetadata",void 0),Oa(this,"getStepStorage",void 0),Oa(this,"setModelContainer",void 0),Oa(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(t){}addVariationRecord(t){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(t){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addCurrentVariationCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(t){}setCurrentVariationRecord(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,A){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function ja(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let Ka;var Va;(Va=Ka||(Ka={})).SelectFrame="SelectFrame",Va.SelectImage="SelectImage",Va.Position="Position";class Wa extends Mi{constructor(t,e){super(t,e),ja(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return ai.selectVariant(this.step,t.getResource(),e,this.manager,(t=>this.setUpdateState(t)))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged((e=>{e&&t(e)}))}selectImage(t){return ai.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,A,n){return n&&n.length>1&&void 0===t?Ka.SelectFrame:e||A||this.getImageData()?Ka.Position:Ka.SelectImage}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}hasVaryingUpload(){return this.step.data.varyUpload}hasVaryingSelection(){return this.step.data.varySelection}}const Xa=t=>{const e=kt(null),A=kt(void 0),[n,i]=Pt(void 0),{addEvent:a,removeEvent:o,updateEvent:r,eventCache:s}=Le(),[c,g]=Pt(!1),[l,B]=Pt(!1),{state:w,uiDispatcher:d}=Ze(),h=Rt((t=>{const e=t;d(new qe({zoom:Math.max(.1,Math.min(e,w.maxZoom))}))}),[d,w.maxZoom]),E=Rt((t=>{o(t),1===s.length&&(A.current=void 0),2===s.length&&i(void 0);"touch"===t.pointerType&&s.length>1&&s.length-1==1&&(B(!1),g(!1))}),[o,s.length]),C=Rt((t=>{a(t);"touch"===t.pointerType&&1===s.length&&(d(new qe({selectedElement:void 0})),B(!0),g(!0))}),[a,s.length,d]),u=Rt((t=>{r(t);const e=1===s.length&&"touch"!==s[0].pointerType,a=2===s.length&&"touch"===s[0].pointerType;if(c&&a){const[t,e]=s,A=Math.abs(t.clientX-e.clientX),a=n;a&&h(w.zoom-.0055*(a-A)),i(A)}if(l&&(e||a)&&t.isPrimary){const e=(A?.current?.x||t.screenX)-t.screenX,n=(A?.current?.y||t.screenY)-t.screenY;d(new qe({selectedElement:void 0,xTranslation:w.xTranslation-e/w.zoom,yTranslation:w.yTranslation-n/w.zoom}))}t.isPrimary&&(A.current={x:t.screenX,y:t.screenY})}),[r,s,c,l,n,h,w.zoom,w.xTranslation,w.yTranslation,d]),Q=Rt((t=>{c&&h(w.zoom-.035*Math.sign(t.deltaY))}),[h,w.zoom,c]);Ut((()=>{if(!e.current||0===s.length)return;const t=s[0].pointerId,A=e.current.hasPointerCapture(t);l&&!A&&e.current.setPointerCapture(t),!l&&A&&e.current.releasePointerCapture(t)}),[e,l,s]),JA([" "],(()=>{B(!0),d(new qe({selectedElement:void 0}))}),(()=>B(!1))),JA(["Control"],(()=>g(!0)),(()=>g(!1)));const p=Gt((()=>({cursor:l&&0===s.length?"grab":l&&1===s.length?"grabbing":c?"zoom-in":void 0,width:"100%",height:"100%",overflow:"clip"})),[l,c,s]);return Jt("div",{ref:e,className:"transform-wrapper",onWheel:Q,onPointerDown:C,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:u,style:p,children:t.children})};export{Ta as SpiffCommerceClient,t as CommandContext,Ee as spiffCoreConfiguration,zA as PromiseQueue,OA as QueueablePromise,za as MockWorkflowManager,Qi as InformationMessageType,Mi as StepHandle,bi as TextStepHandle,Wa as FrameStepHandle,vi as BulkStepHandle,Ui as ShapeStepHandle,xi as IllustrationStepHandle,Ni as MaterialStepHandle,Pi as ModelStepHandle,Ri as PictureStepHandle,Hi as QuestionStepHandle,tA as BulkPriceCalculationStrategy,fi as Variant,ee as OptionNotFoundError,Ae as LayoutNotFoundError,ne as AssetNotFoundError,ie as ResourceNotFoundError,ae as MisconfigurationError,se as ParseError,re as UnhandledBehaviorError,He as assetService,Vi as designService,zi as createDesign,ke as optionService,de as persistenceService,ye as graphQlManager,gA as toast,Zn as FrameService,Xn as getBoundedOffsets,ai as frameStepService,si as modelStepService,ri as materialStepService,Bi as shapeStepService,li as questionStepService,ni as digitalContentStepService,ci as moduleStepService,gi as pictureStepService,Ci as textStepService,oi as illustrationStepService,$e as ProductCameraRig,Ka as FrameStep,AA as ConversionLocation,iA as ConversionDataType,Ja as getWorkflow,ti as shortenUrl,ya as ObjectInput,Ma as TextInput,Ia as ObjectInputType,e as AssetType,A as BringForwardCommand,n as BringToFrontCommand,i as BringToBackCommand,a as CanvasCommand,o as CreateElementCommand,r as CreateLayoutCommand,s as DeleteElementCommand,c as FontAlignmentCommand,g as FontColorCommand,l as FontSizeCommand,B as FontSourceCommand,w as GroupCommand,d as LayoutElementFactory,h as LayoutElementType,E as MoveCommand,C as ResizeCommand,u as RotateCommand,Q as SendBackwardsCommand,oA as StakeholderType,p as StepAspectType,m as StepType,D as TextChangeCommand,I as UnitOfMeasurement,f as dataUrlFromExternalUrl,y as findElement,M as frameDataCache,F as generate,Y as getAxisAlignedBoundingBox,S as generateSVGWithUnknownColors,v as getAttributesFromArrayBuffer,x as rehydrateSerializedLayout,N as getFrameData,P as getSvgElement,R as loadFontFromDataUrl,H as loadFontFromExternalUrl,U as determineCorrectFontSizeAndLines,b as patternImageDataCache,Dn as generateCommands,G as registerJSDOM,bA as minZoom,Nn as AdvancedEditor,Xa as TransformWrapper,xn as EditorCore,Te as useLayouts,Ze as useEditorState,kA as useEditorInteraction,JA as useShortcutCombination,Ve as commandReducer,Ke as getDefaultState,Je as CommandContextContext,Xe as AdvancedEditorStateProvider,We as AdvancedEditorContext,qe as UICommand,ze as EditorSubMenu,lA as ElementEventType,wA as KeyEvent,Ln as gatherVaryingStepAspects};
1339
1339
  //# sourceMappingURL=module.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/core",
3
- "version": "13.3.2-alpha.0",
3
+ "version": "13.3.3",
4
4
  "description": "Core client API for interacting with the Spiff Commerce backend.",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/main.js",