@spiffcommerce/core 12.11.0 → 12.11.2

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/module.js CHANGED
@@ -651,7 +651,7 @@ import{CommandContext as t,AssetType as A,BringForwardCommand as e,BringToFrontC
651
651
  id
652
652
  }
653
653
  }
654
- `;function ri(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class si{constructor(t,A){ri(this,"bundle",void 0),ri(this,"property",void 0),this.bundle=t,this.property=A}getName(){return this.property.name}getDescription(){return this.property.description}getType(){return this.property.type}getSharedSteps(t){const A=(t??this.bundle.getWorkflowExperiences()).flatMap((t=>t.getSteps().filter((t=>t.getRaw().globalPropertyConfigurationAspectNames?.includes(this.property.name)))));return console.log("Shared steps:",A),A}}class ci extends si{constructor(t,A){super(t,A)}async selectImage(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.key),this.applyImageSelection(t)])}async applyGlobalState(t){const A=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!A)return Promise.resolve();const e=await HA.getLocalOrFromServer(A);return e?this.applyImageSelection(e,t):Promise.resolve()}async applyImageSelection(t,A){const e=this.getSharedSteps(A).map((A=>A.selectImage(t)));await Promise.all(e)}}class gi extends si{constructor(t,A){super(t,A)}async setText(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t),this.applyTextSelection(t)])}async applyGlobalState(t){const A=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!A)return Promise.resolve();await this.applyTextSelection(A,t)}async applyTextSelection(t,A){const e=this.getSharedSteps(A).map((A=>{A.setText(t)}));await Promise.all(e)}}class li extends si{constructor(t,A,e){super(t,A),ri(this,"optionResource",void 0),this.optionResource=e}getCurrentVariant(){if(!this.optionResource)return;const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!t)return;const A=this.optionResource.variants?.find((A=>A.id===t));return A?new fa(A):void 0}getAvailableVariants(){return(this.optionResource?.variants?.filter((t=>t.enabled))||[]).map((t=>new fa(t)))}getAllVariants(){return(this.optionResource?.variants||[]).map((t=>new fa(t)))}async selectVariant(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId()),this.applyVariantSelection(t)])}async applyGlobalState(t){const A=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!A)return Promise.resolve();const e=this.optionResource?.variants?.find((t=>t.id===A));return e?this.applyVariantSelection(new fa(e),t):Promise.resolve()}async applyVariantSelection(t,A){const e=this.getSharedSteps(A).map((A=>A.selectVariant(t)));await Promise.all(e)}}const Bi=Zt`
654
+ `;function ri(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class si{constructor(t,A){ri(this,"bundle",void 0),ri(this,"property",void 0),this.bundle=t,this.property=A}getName(){return this.property.name}getDescription(){return this.property.description}getType(){return this.property.type}getSharedSteps(t){const A=(t??this.bundle.getWorkflowExperiences()).flatMap((t=>t.getSteps().filter((t=>t.getRaw().globalPropertyConfigurationAspectNames?.includes(this.property.name)))));return console.log("Shared steps:",A),A}}class ci extends si{constructor(t,A){super(t,A)}async selectImage(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.key),this.applyImageSelection(t)])}async applyGlobalState(t){const A=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!A)return Promise.resolve();const e=await HA.getLocalOrFromServer(A);return e?this.applyImageSelection(e,t):Promise.resolve()}async applyImageSelection(t,A){const e=this.getSharedSteps(A).map((A=>A.selectImage(t)));await Promise.all(e)}}class gi extends si{constructor(t,A){super(t,A)}getText(){const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);return t||""}async setText(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t),this.applyTextSelection(t)])}async applyGlobalState(t){const A=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!A)return Promise.resolve();await this.applyTextSelection(A,t)}async applyTextSelection(t,A){const e=this.getSharedSteps(A).map((A=>{A.setText(t)}));await Promise.all(e)}}class li extends si{constructor(t,A,e){super(t,A),ri(this,"optionResource",void 0),this.optionResource=e}getCurrentVariant(){if(!this.optionResource)return;const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!t)return;const A=this.optionResource.variants?.find((A=>A.id===t));return A?new fa(A):void 0}getAvailableVariants(){return(this.optionResource?.variants?.filter((t=>t.enabled))||[]).map((t=>new fa(t)))}getAllVariants(){return(this.optionResource?.variants||[]).map((t=>new fa(t)))}async selectVariant(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId()),this.applyVariantSelection(t)])}async applyGlobalState(t){const A=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!A)return Promise.resolve();const e=this.optionResource?.variants?.find((t=>t.id===A));return e?this.applyVariantSelection(new fa(e),t):Promise.resolve()}async applyVariantSelection(t,A){const e=this.getSharedSteps(A).map((A=>A.selectVariant(t)));await Promise.all(e)}}const Bi=Zt`
655
655
  mutation CreateGlobalPropertyState($bundleId: String!) {
656
656
  globalPropertyStateCreate(bundleId: $bundleId) {
657
657
  id
@@ -677,7 +677,7 @@ import{CommandContext as t,AssetType as A,BringForwardCommand as e,BringToFrontC
677
677
  }
678
678
  }
679
679
  }
680
- `;function hi(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class Ei{constructor(t){hi(this,"bundleId",void 0),hi(this,"globalPropertyState",void 0),this.bundleId=t,this.getOrCreateGlobalPropertyState().then((t=>this.globalPropertyState=t))}getGlobalPropertyState(){return this.globalPropertyState}getAspect(t){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const A=this.globalPropertyState.aspects.find((A=>A.name===t));if(A)return A.value}setAspect(t,A){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const e=this.globalPropertyState.aspects.find((A=>A.name===t));return e?e.value=A:this.globalPropertyState.aspects.push({name:t,value:A}),this.updateGlobalPropertyState()}async updateGlobalPropertyState(){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await yA.getShadowGraphqlClient().mutate({mutation:wi,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects}});if(!t.data?.globalPropertyStateUpdate)throw new Error("Unable to update global property state");this.globalPropertyState=t.data.globalPropertyStateUpdate}async getOrCreateGlobalPropertyState(){const t=await yA.getShadowGraphqlClient().query({query:di,errorPolicy:"all",fetchPolicy:"no-cache",variables:{bundleId:this.bundleId}});if(t.data.globalPropertyState&&t.data.globalPropertyState.id)return t.data.globalPropertyState;const A=await yA.getShadowGraphqlClient().mutate({mutation:Bi,variables:{bundleId:this.bundleId}});if(A.data?.globalPropertyStateCreate&&A.data.globalPropertyStateCreate.id)return A.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}function Ci(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class Qi{constructor(t,A){Ci(this,"client",void 0),Ci(this,"id",void 0),Ci(this,"name",void 0),Ci(this,"metadata",void 0),Ci(this,"productCollection",void 0),Ci(this,"globalConfigurations",void 0),Ci(this,"globalPropertyStateManager",void 0),Ci(this,"workflowExperiences",[]),this.client=t,this.id=A.id,this.name=A.name||"",this.metadata=new Map(A.metadata?.map((t=>[t.key,t.value]))||[]),this.productCollection=A.productCollection,this.globalConfigurations=this.resolveGlobalProperties(),this.globalPropertyStateManager=new Ei(this.id)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}setName(t){return this.name=t,this.updateBundle()}getMetadata(){return new Map(this.metadata)}setMetadata(t){return this.metadata=new Map(t),this.updateBundle()}setNameAndMetadata(t,A){return this.name=t,this.metadata=new Map(A),this.updateBundle()}async hasGlobalProperties(){const t=await this.globalConfigurations;return t.length>0&&t.some((t=>t.aspects.length>0))}async getGlobalProperties(){const t=await this.globalConfigurations;if(0===t.length)return[];return(await Promise.all(t.map((async t=>await Promise.all(t.aspects.map((async t=>{switch(t.type){case It.FileUpload:return new ci(this,t);case It.Option:const A=t.entityId?await bA.getOption(t.entityId):void 0;return new li(this,t,A);case It.Text:return new gi(this,t)}}))))))).flat()}getGlobalPropertyStateManager(){return this.globalPropertyStateManager}getTotalSubunits(){return this.workflowExperiences.map((t=>t.getTotalPriceSubunits())).reduce(((t,A)=>t+A),0)}getProductCollection(){return this.productCollection}async addWorkflowExperience(t){const A=t.getWorkflowManager().getTransaction().id;if(this.workflowExperiences.find((t=>t.getWorkflowManager().getTransaction().id===A)))throw new Error("Unable to add transaction to bundle - Already Exists!");await yA.getShadowGraphqlClient().mutate({mutation:Ai,variables:{id:this.id,transactionId:A}}),this.workflowExperiences.push(t);const e=await this.getGlobalProperties();await Promise.all(e.map((A=>A.applyGlobalState([t]))))}async removeWorkflowExperience(t){const A=this.workflowExperiences.indexOf(t);if(!(A>-1))throw new Error("Unable to remove workflow experience from bundle - Not Found!");await yA.getShadowGraphqlClient().mutate({mutation:ei,variables:{id:this.id,transactionId:t.getWorkflowManager().getTransaction().id}}),this.workflowExperiences.splice(A,1)}getWorkflowExperiences(){return[...this.workflowExperiences]}async sortWorkflowExperiences(t){this.workflowExperiences=this.workflowExperiences.sort(t),await yA.getShadowGraphqlClient().mutate({mutation:oi,variables:{id:this.id,transactionIds:this.workflowExperiences.map((t=>t.getWorkflowManager().getTransaction().id))}})}getWorkflowExperienceCount(){return this.workflowExperiences.length}async addStakeholder(t,A){await yA.getShadowGraphqlClient().mutate({mutation:ni,variables:{id:this.id,details:t,type:A||oe.Owner}})}async updateStakeholders(t){await yA.getShadowGraphqlClient().mutate({mutation:ai,variables:{id:this.id,input:t}})}async getAllStakeholders(){const t=await yA.getShadowGraphqlClient().query({query:$a,errorPolicy:"all",variables:{id:this.id}});if(!t.data.bundles||0===t.data.bundles.length)throw new Error("Bundle not found!");return t.data.bundles[0].bundleStakeholders||[]}setWorkflowExperiencesInternal(t){this.workflowExperiences=t}async updateBundle(){if(!(await yA.getShadowGraphqlClient().mutate({mutation:ti,variables:{id:this.id,name:this.name,metadata:Array.from(this.metadata.entries()).map((([t,A])=>({key:t,value:A})))}})).data?.bundleUpdate)throw new Error("Bundle not found!")}async resolveGlobalProperties(){const t=this.productCollection;if(!t)return Promise.resolve([]);const A=new Set;t.products.forEach((t=>t.workflows?.forEach((t=>A.add(t.workflowName)))));const e=await yA.getShadowGraphqlClient().query({query:ii,errorPolicy:"all",variables:{ids:Array.from(A)}}),n=new Map;return e.data.workflows?.forEach((t=>{t.globalPropertyConfiguration&&n.set(t.globalPropertyConfiguration.id,t.globalPropertyConfiguration)})),Array.from(n.values())}}function ui(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}const pi=ft`
680
+ `;function hi(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class Ei{constructor(t){hi(this,"bundleId",void 0),hi(this,"globalPropertyState",void 0),this.bundleId=t,this.getOrCreateGlobalPropertyState().then((t=>this.globalPropertyState=t))}getGlobalPropertyState(){return this.globalPropertyState}getAspect(t){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const A=this.globalPropertyState.aspects.find((A=>A.name===t));if(A)return A.value}setAspect(t,A){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const e=this.globalPropertyState.aspects.find((A=>A.name===t));return e?e.value=A:this.globalPropertyState.aspects.push({name:t,value:A}),this.updateGlobalPropertyState()}async updateGlobalPropertyState(){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await yA.getShadowGraphqlClient().mutate({mutation:wi,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects}});if(!t.data?.globalPropertyStateUpdate)throw new Error("Unable to update global property state");this.globalPropertyState=t.data.globalPropertyStateUpdate}async getOrCreateGlobalPropertyState(){const t=await yA.getShadowGraphqlClient().query({query:di,errorPolicy:"all",fetchPolicy:"no-cache",variables:{bundleId:this.bundleId}});if(t.data.globalPropertyState&&t.data.globalPropertyState.id)return t.data.globalPropertyState;const A=await yA.getShadowGraphqlClient().mutate({mutation:Bi,variables:{bundleId:this.bundleId}});if(A.data?.globalPropertyStateCreate&&A.data.globalPropertyStateCreate.id)return A.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}function Ci(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class Qi{constructor(t,A){Ci(this,"client",void 0),Ci(this,"id",void 0),Ci(this,"name",void 0),Ci(this,"metadata",void 0),Ci(this,"productCollection",void 0),Ci(this,"globalConfigurations",void 0),Ci(this,"globalPropertyStateManager",void 0),Ci(this,"workflowExperiences",[]),this.client=t,this.id=A.id,this.name=A.name||"",this.metadata=new Map(A.metadata?.map((t=>[t.key,t.value]))||[]),this.productCollection=A.productCollection,this.globalConfigurations=this.resolveGlobalProperties(),this.globalPropertyStateManager=new Ei(this.id)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}setName(t){return this.name=t,this.updateBundle()}getMetadata(){return new Map(this.metadata)}setMetadata(t){return this.metadata=new Map(t),this.updateBundle()}setNameAndMetadata(t,A){return this.name=t,this.metadata=new Map(A),this.updateBundle()}async hasGlobalProperties(){const t=await this.globalConfigurations;return t.length>0&&t.some((t=>t.aspects.length>0))}async getGlobalProperties(){const t=await this.globalConfigurations;if(0===t.length)return[];return(await Promise.all(t.map((async t=>await Promise.all(t.aspects.map((async t=>{switch(t.type){case It.FileUpload:return new ci(this,t);case It.Option:const A=t.entityId?await bA.getOption(t.entityId):void 0;return new li(this,t,A);case It.Text:return new gi(this,t)}}))))))).flat()}getGlobalPropertyStateManager(){return this.globalPropertyStateManager}getTotalSubunits(){return this.workflowExperiences.map((t=>t.getTotalPriceSubunits())).reduce(((t,A)=>t+A),0)}getProductCollection(){return this.productCollection}async addWorkflowExperience(t){const A=t.getWorkflowManager().getTransaction().id;if(this.workflowExperiences.find((t=>t.getWorkflowManager().getTransaction().id===A)))throw new Error("Unable to add transaction to bundle - Already Exists!");await yA.getShadowGraphqlClient().mutate({mutation:Ai,variables:{id:this.id,transactionId:A}}),this.workflowExperiences.push(t);const e=await this.getGlobalProperties();await Promise.all(e.map((A=>A.applyGlobalState([t]))))}async removeWorkflowExperience(t){const A=this.workflowExperiences.indexOf(t);if(!(A>-1))throw new Error("Unable to remove workflow experience from bundle - Not Found!");await yA.getShadowGraphqlClient().mutate({mutation:ei,variables:{id:this.id,transactionId:t.getWorkflowManager().getTransaction().id}}),this.workflowExperiences.splice(A,1)}getWorkflowExperiences(){return[...this.workflowExperiences]}async sortWorkflowExperiences(t){this.workflowExperiences=this.workflowExperiences.sort(t),await yA.getShadowGraphqlClient().mutate({mutation:oi,variables:{id:this.id,transactionIds:this.workflowExperiences.map((t=>t.getWorkflowManager().getTransaction().id))}})}getWorkflowExperienceCount(){return this.workflowExperiences.length}async addStakeholder(t,A){await yA.getShadowGraphqlClient().mutate({mutation:ni,variables:{id:this.id,details:t,type:A||oe.Owner}})}async updateStakeholders(t){await yA.getShadowGraphqlClient().mutate({mutation:ai,variables:{id:this.id,input:t}})}async getAllStakeholders(){const t=await yA.getShadowGraphqlClient().query({query:$a,errorPolicy:"all",variables:{id:this.id}});if(!t.data.bundles||0===t.data.bundles.length)throw new Error("Bundle not found!");return t.data.bundles[0].bundleStakeholders||[]}async finish(){return Promise.all(this.workflowExperiences.map((t=>t.onDesignFinished())))}_setWorkflowExperiencesInternal(t){this.workflowExperiences=t}async updateBundle(){if(!(await yA.getShadowGraphqlClient().mutate({mutation:ti,variables:{id:this.id,name:this.name,metadata:Array.from(this.metadata.entries()).map((([t,A])=>({key:t,value:A})))}})).data?.bundleUpdate)throw new Error("Bundle not found!")}async resolveGlobalProperties(){const t=this.productCollection;if(!t)return Promise.resolve([]);const A=new Set;t.products.forEach((t=>t.workflows?.forEach((t=>A.add(t.workflowName)))));const e=await yA.getShadowGraphqlClient().query({query:ii,errorPolicy:"all",variables:{ids:Array.from(A)}}),n=new Map;return e.data.workflows?.forEach((t=>{t.globalPropertyConfiguration&&n.set(t.globalPropertyConfiguration.id,t.globalPropertyConfiguration)})),Array.from(n.values())}}function ui(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}const pi=ft`
681
681
  ${FA}
682
682
  ${SA}
683
683
  ${GA}
@@ -1303,5 +1303,5 @@ import{CommandContext as t,AssetType as A,BringForwardCommand as e,BringToFrontC
1303
1303
  }
1304
1304
  }
1305
1305
  }
1306
- `,Yi=async t=>{const A=(await yA.getShadowGraphqlClient().query({query:pi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return A.steps.forEach((t=>{delete t.data.__typename})),A},Si=(t,A)=>{const e=t.workflowState,n=e?JSON.parse(e):void 0;return n?Object.values(n.layouts).map((t=>t.layout)):A.panels.sort(((t,A)=>t.index-A.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 vi{constructor(t){var A;ui(this,"options",void 0),ui(this,"initialized",void 0),ui(this,"currencyCode",void 0),ui(this,"customer",void 0),ui(this,"experienceOptions",void 0),ui(this,"updateTransactionState",(async t=>{try{return yA.getShadowGraphqlClient().mutate({...t,mutation:Un})}catch(t){throw console.error(t),new cA("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(A=this.options.applicationKey,fA=A)}getAssetManager(){return HA}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}async authenticateBundleFromLocalStorage(t){const A=dA.getMap("bundleOwnerIds");if(A?.has(t)){const e=A.get(t);return mA(e),Promise.resolve({success:!0,stakeholderType:oe.Owner})}const e=dA.getMap("bundleCustomerIds");if(e?.has(t)){const A=e.get(t);if(A){if(await this.authenticateCustomerId(A)){const A=this.customer?.bundleStakeholders?.find((A=>A.bundle?.id===t));if(A)return Promise.resolve({success:!0,stakeholderType:A.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const A=yA.getShadowGraphqlClient(),e=await A.query({query:mi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!e.data.transactions||0===e.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const n=e.data.transactions[0],a=n.product?.partner?.id;if(!a)throw new Error(`Unable to read transaction: ${t}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const i=dA.getMap("transactionOwnerIds");if(i?.has(t)){const A=i.get(t);return uA(A),Promise.resolve({success:!0,stakeholderType:oe.Owner})}const o=dA.getMap("transactionCustomerIds");if(o?.has(t)){const A=o.get(t);if(A){if(await this.authenticateCustomerId(A)){const A=this.customer?.bundleStakeholders?.find((A=>A.bundle?.transactions?.some((A=>A.id===t))))||this.customer?.stakeholders?.find((A=>A.transaction?.id===t));if(A)return Promise.resolve({success:!0,stakeholderType:A.type})}}}const r=(await A.query({query:Di,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 A=dA.getMap("transactionCustomerIds");A?.has(t)&&(A.delete(t),dA.setMap("transactionCustomerIds",A))}getStakeholderTypeForTransaction(t){const A=this.customer?.stakeholders?.find((A=>A.transaction?.id===t));if(A)return A.type}async getOrCreateCustomer(t){this.customer=void 0;const A=yA.getShadowGraphqlClient(),e=(await A.query({query:Ii,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!e.id){const e=(await A.mutate({mutation:fi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!e)throw new Error("Unable to create customer.");return this.customer=e,{customer:e,isAuthenticated:!1}}const n=await this.authenticateCustomerId(e.id);return{customer:this.customer||e,isAuthenticated:n}}async authenticateCustomerId(t){const A=yA.getShadowGraphqlClient(),e=dA.getMap("customerTokens");if(!e?.has(t))return!1;const n=e.get(t);if(!n)return!1;const a=(await A.mutate({mutation:yi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data?.customerAuthenticate;return!!a&&(IA(n),this.customer=a,!0)}async generateVerificationCode(t){await yA.getShadowGraphqlClient().mutate({mutation:Mi,variables:{emailAddress:t}})}async verifyCode(t,A){const e=(await yA.getShadowGraphqlClient().mutate({mutation:Fi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:A}})).data?.customerVerifyCode;if(e?.loginToken){if(!e.partner?.id)throw new Error(`Unable to find customer: ${t}`);const A=dA.getMap("customerTokens")||new Map;return A.set(e.id,e.loginToken),dA.setMap("customerTokens",A),IA(e.loginToken),this.customer={...e,loginToken:void 0},!0}return!1}async getNewBundle(t){const A=(await yA.getShadowGraphqlClient().mutate({mutation:_a,variables:{collectionId:t}})).data?.bundleCreate;if(!A)throw new Error("Unable to create bundle");mA(A.bundleOwnerId);const e=dA.getMap("bundleOwnerIds")||new Map;return e.set(A.id,A.bundleOwnerId),dA.setMap("bundleOwnerIds",e),new Qi(this,A)}async getExistingBundle(t,A){const e=await yA.getShadowGraphqlClient().query({query:Za,variables:{id:t}});if(!e.data?.bundles||0===e.data?.bundles.length||!e.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const n=e.data?.bundles[0],a=dA.getMap("bundleOwnerIds");a?.has(n.id)&&mA(a.get(n.id));const i=new Qi(this,n);if(n.transactions&&n.transactions.length>0){const t=t=>{const e=A?e=>A(e,t):void 0;return this.getWorkflowExperience(void 0,void 0,e,{type:"transaction",transactionId:t})},e=await Promise.all(n.transactions.map((A=>t(A.id))));i.setWorkflowExperiencesInternal(e)}return i}async getWorkflowExperience(t,A,e,n){if(!n)return await this.getWorkflowExperienceDeprecated(t,A,e);const a=async t=>{for(const A in t.layouts){const e=t.layouts[A].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<e.length;++t){const A=e[t];A.src&&A.svg&&(A.cachedObjectURL=await dt(A.svg))}const n=t.layouts[A].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const A=n[t];A.fontData?.assetUrl&&H(A.fontData.assetUrl)}}},{transaction:i,workflow:o,readOnly:r}=await(async()=>{const t=yA.getShadowGraphqlClient();if("transaction"===n.type){const{transactionId:A,readOnly:e}=n,a=await t.query({query:Hn,variables:{id:A},errorPolicy:"all",fetchPolicy:"no-cache"});if(!a.data?.transactions||0===a.data.transactions.length)throw new cA("Existing transaction not found.");const i=a.data?.transactions[0];if(!i.workflowId)throw new cA("Existing transaction has no workflow ID.");const o=await Yi(i.workflowId);if(!i.product)throw new cA("Failed to load transaction, product not available.");return{transaction:i,workflow:o,readOnly:e}}if("integration"===n.type||"external"===n.type){const A=async()=>{const A="integration"===n.type?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},e=await t.mutate({mutation:Rn,variables:{...A,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(!e.data||!e.data.transactionCreate)throw new cA("Failed to create transaction!");const a=e.data.transactionCreate;if(!a.product)throw new cA("Failed to create transaction, product not available.");return a},e=Yi(n.workflowId),[a,i]=await Promise.all([A(),e]);return{transaction:a,workflow:i}}throw new cA("No workflow ID provided.")})();this.currencyCode=i.product.partner?.currencyCode;const s={product:i.product,transaction:i,layouts:[],stateMutationFunc:r?async()=>{throw new rA("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:r,workflow:o};if("transaction"===n.type&&i.workflowState){const t=JSON.parse(i.workflowState);s.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await a(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 a(t),s.reloadedState=t}else s.layouts=Si(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=e&&e(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=dA.getMap("transactionOwnerIds")||new Map;t.set(i.id,i.transactionOwnerId),uA(i.transactionOwnerId||""),dA.setMap("transactionOwnerIds",t)}else{const t=(dA.getMap("transactionOwnerIds")||new Map).get(i.id);t&&uA(t),s.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=s;const c=new Xa(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 cA("No integration product ID provided.");const A=yA.getShadowGraphqlClient(),e=await A.mutate({mutation:Rn,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(!e.data||!e.data.transactionCreate)throw new cA("Failed to create transaction!");const n=e.data.transactionCreate;if(!n.product)throw new cA("Failed to create transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode;const a=dA.getMap("transactionOwnerIds")||new Map;a.set(n.id,n.transactionOwnerId),uA(n.transactionOwnerId||""),dA.setMap("transactionOwnerIds",a),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,A=!1){if(""===t)throw new cA("No transaction ID provided.");const e=yA.getShadowGraphqlClient();if(A)return await(async()=>{const n=(await e.query({query:Hn,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!n)throw new cA("Failed to read transaction.");if(!n.product)throw new cA("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 rA("State mutation is forbidden in read only mode!")},readOnly:A},this.initialized=!0})();const n=dA.getMap("transactionOwnerIds")||new Map,a=n.get(t);if(a){uA(a);const n=(await e.query({query:Hn,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!n)throw new cA("Failed to read transaction.");if(!n.product)throw new cA("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:A},void(this.initialized=!0)}try{const a=(await e.mutate({mutation:Pn,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!a)throw new cA("Failed to read transaction.");if(!a.product)throw new cA("Failed to load transaction, product not available.");this.currencyCode=a.product.partner?.currencyCode,a.transactionOwnerId&&(n.set(a.id,a.transactionOwnerId),uA(a.transactionOwnerId),dA.setMap("transactionOwnerIds",n)),this.experienceOptions={product:a.product,transaction:a,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:A},this.initialized=!0}catch{throw new cA("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,A,e){if(!this.initialized||!this.experienceOptions)throw new cA("Cannot launch experience: Not initialized.");const n=async t=>{for(const A in t.layouts){const e=t.layouts[A].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<e.length;++t){const A=e[t];A.src&&A.svg&&(A.cachedObjectURL=await dt(A.svg))}const n=t.layouts[A].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const A=n[t];A.fontData?.assetUrl&&H(A.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await Yi(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=e&&e(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 A=new Xa(this,this.experienceOptions);return await A.getWorkflowManager().getInitializationPromise(),A}if(t){const a=yA.getShadowGraphqlClient().mutate({mutation:Gn,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),i=Yi(t);if(await Promise.all([a,i]),this.experienceOptions.workflow=await i,A){const t=JSON.parse(A);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=Si(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=e&&e(await i),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 Xa(this,this.experienceOptions);return await o.getWorkflowManager().getInitializationPromise(),o}throw new cA("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new cA("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new cA("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function xi(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class Ni{constructor(){xi(this,"getProduct",void 0),xi(this,"getCommandContext",void 0),xi(this,"getAllLayoutData",void 0),xi(this,"getMetadata",void 0),xi(this,"getWorkflowMetadata",void 0),xi(this,"getStepStorage",void 0),xi(this,"setModelContainer",void 0),xi(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,A){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,A){}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,A){}setInformationResults(t){}setMandatoryFulfilled(t,A){}async setSelectionsAndElements(t,A,e){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,A){}async updateStorage(t,A){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function Ri(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}let Pi;var Hi;(Hi=Pi||(Pi={})).SelectFrame="SelectFrame",Hi.SelectImage="SelectImage",Hi.Position="Position";class Ui extends Ma{constructor(t,A){super(t,A),Ri(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const A=this.manager.getRegionElements(this.step.stepName);return ia.selectVariant(this.step,t.getResource(),A,this.manager,(t=>this.setUpdateState(t)))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged((A=>{A&&t(A)}))}selectImage(t){return ia.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,A,e,n){return n&&n.length>1&&void 0===t?Pi.SelectFrame:A||e||this.getImageData()?Pi.Position:Pi.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 Gi=t=>{const A=bt(null),e=bt(void 0),[n,a]=Rt(void 0),{addEvent:i,removeEvent:o,updateEvent:r,eventCache:s}=LA(),[c,g]=Rt(!1),[l,B]=Rt(!1),{state:w,uiDispatcher:d}=ZA(),h=Pt((t=>{const A=t;d(new qA({zoom:Math.max(.1,Math.min(A,w.maxZoom))}))}),[d,w.maxZoom]),E=Pt((t=>{o(t),1===s.length&&(e.current=void 0),2===s.length&&a(void 0);"touch"===t.pointerType&&s.length>1&&s.length-1==1&&(B(!1),g(!1))}),[o,s.length]),C=Pt((t=>{i(t);"touch"===t.pointerType&&1===s.length&&(d(new qA({selectedElement:void 0})),B(!0),g(!0))}),[i,s.length,d]),Q=Pt((t=>{r(t);const A=1===s.length&&"touch"!==s[0].pointerType,i=2===s.length&&"touch"===s[0].pointerType;if(c&&i){const[t,A]=s,e=Math.abs(t.clientX-A.clientX),i=n;i&&h(w.zoom-.0055*(i-e)),a(e)}if(l&&(A||i)&&t.isPrimary){const A=(e?.current?.x||t.screenX)-t.screenX,n=(e?.current?.y||t.screenY)-t.screenY;d(new qA({selectedElement:void 0,xTranslation:w.xTranslation-A/w.zoom,yTranslation:w.yTranslation-n/w.zoom}))}t.isPrimary&&(e.current={x:t.screenX,y:t.screenY})}),[r,s,c,l,n,h,w.zoom,w.xTranslation,w.yTranslation,d]),u=Pt((t=>{c&&h(w.zoom-.035*Math.sign(t.deltaY))}),[h,w.zoom,c]);Ut((()=>{if(!A.current||0===s.length)return;const t=s[0].pointerId,e=A.current.hasPointerCapture(t);l&&!e&&A.current.setPointerCapture(t),!l&&e&&A.current.releasePointerCapture(t)}),[A,l,s]),Je([" "],(()=>{B(!0),d(new qA({selectedElement:void 0}))}),(()=>B(!1))),Je(["Control"],(()=>g(!0)),(()=>g(!1)));const p=kt((()=>({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:A,className:"transform-wrapper",onWheel:u,onPointerDown:C,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:Q,style:p,children:t.children})};export{vi as SpiffCommerceClient,t as CommandContext,EA as spiffCoreConfiguration,ze as PromiseQueue,Oe as QueueablePromise,Ni as MockWorkflowManager,ua as InformationMessageType,Ma as StepHandle,Ga as TextStepHandle,Ui as FrameStepHandle,va as BulkStepHandle,Ua as ShapeStepHandle,xa as IllustrationStepHandle,Na as MaterialStepHandle,Ra as ModelStepHandle,Pa as PictureStepHandle,Ha as QuestionStepHandle,te as BulkPriceCalculationStrategy,fa as Variant,AA as OptionNotFoundError,eA as LayoutNotFoundError,nA as AssetNotFoundError,aA as ResourceNotFoundError,iA as MisconfigurationError,sA as ParseError,rA as UnhandledBehaviorError,HA as assetService,Va as designService,za as createDesign,bA as optionService,dA as persistenceService,yA as graphQlManager,ge as toast,Zn as FrameService,Xn as getBoundedOffsets,ia as frameStepService,sa as modelStepService,ra as materialStepService,Ba as shapeStepService,la as questionStepService,na as digitalContentStepService,ca as moduleStepService,ga as pictureStepService,Ca as textStepService,oa as illustrationStepService,$A as ProductCameraRig,Pi as FrameStep,ee as ConversionLocation,ae as ConversionDataType,Yi as getWorkflow,ta as shortenUrl,A as AssetType,e as BringForwardCommand,n as BringToFrontCommand,a as BringToBackCommand,i 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,Q as RotateCommand,u as SendBackwardsCommand,oe 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,R as getSvgElement,P as loadFontFromDataUrl,H as loadFontFromExternalUrl,U as determineCorrectFontSizeAndLines,G as patternImageDataCache,Dn as generateCommands,k as registerJSDOM,Ge as minZoom,Nn as AdvancedEditor,Gi as TransformWrapper,xn as EditorCore,TA as useLayouts,ZA as useEditorState,be as useEditorInteraction,Je as useShortcutCombination,VA as commandReducer,KA as getDefaultState,JA as CommandContextContext,XA as AdvancedEditorStateProvider,WA as AdvancedEditorContext,qA as UICommand,zA as EditorSubMenu,le as ElementEventType,we as KeyEvent,Ln as gatherVaryingStepAspects};
1306
+ `,Yi=async t=>{const A=(await yA.getShadowGraphqlClient().query({query:pi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return A.steps.forEach((t=>{delete t.data.__typename})),A},Si=(t,A)=>{const e=t.workflowState,n=e?JSON.parse(e):void 0;return n?Object.values(n.layouts).map((t=>t.layout)):A.panels.sort(((t,A)=>t.index-A.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 vi{constructor(t){var A;ui(this,"options",void 0),ui(this,"initialized",void 0),ui(this,"currencyCode",void 0),ui(this,"customer",void 0),ui(this,"experienceOptions",void 0),ui(this,"updateTransactionState",(async t=>{try{return yA.getShadowGraphqlClient().mutate({...t,mutation:Un})}catch(t){throw console.error(t),new cA("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(A=this.options.applicationKey,fA=A)}getAssetManager(){return HA}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}async authenticateBundleFromLocalStorage(t){const A=dA.getMap("bundleOwnerIds");if(A?.has(t)){const e=A.get(t);return mA(e),Promise.resolve({success:!0,stakeholderType:oe.Owner})}const e=dA.getMap("bundleCustomerIds");if(e?.has(t)){const A=e.get(t);if(A){if(await this.authenticateCustomerId(A)){const A=this.customer?.bundleStakeholders?.find((A=>A.bundle?.id===t));if(A)return Promise.resolve({success:!0,stakeholderType:A.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const A=yA.getShadowGraphqlClient(),e=await A.query({query:mi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!e.data.transactions||0===e.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const n=e.data.transactions[0],a=n.product?.partner?.id;if(!a)throw new Error(`Unable to read transaction: ${t}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const i=dA.getMap("transactionOwnerIds");if(i?.has(t)){const A=i.get(t);return uA(A),Promise.resolve({success:!0,stakeholderType:oe.Owner})}const o=dA.getMap("transactionCustomerIds");if(o?.has(t)){const A=o.get(t);if(A){if(await this.authenticateCustomerId(A)){const A=this.customer?.bundleStakeholders?.find((A=>A.bundle?.transactions?.some((A=>A.id===t))))||this.customer?.stakeholders?.find((A=>A.transaction?.id===t));if(A)return Promise.resolve({success:!0,stakeholderType:A.type})}}}const r=(await A.query({query:Di,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 A=dA.getMap("transactionCustomerIds");A?.has(t)&&(A.delete(t),dA.setMap("transactionCustomerIds",A))}getStakeholderTypeForTransaction(t){const A=this.customer?.stakeholders?.find((A=>A.transaction?.id===t));if(A)return A.type}async getOrCreateCustomer(t){this.customer=void 0;const A=yA.getShadowGraphqlClient(),e=(await A.query({query:Ii,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!e.id){const e=(await A.mutate({mutation:fi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!e)throw new Error("Unable to create customer.");return this.customer=e,{customer:e,isAuthenticated:!1}}const n=await this.authenticateCustomerId(e.id);return{customer:this.customer||e,isAuthenticated:n}}async authenticateCustomerId(t){const A=yA.getShadowGraphqlClient(),e=dA.getMap("customerTokens");if(!e?.has(t))return!1;const n=e.get(t);if(!n)return!1;const a=(await A.mutate({mutation:yi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data?.customerAuthenticate;return!!a&&(IA(n),this.customer=a,!0)}async generateVerificationCode(t){await yA.getShadowGraphqlClient().mutate({mutation:Mi,variables:{emailAddress:t}})}async verifyCode(t,A){const e=(await yA.getShadowGraphqlClient().mutate({mutation:Fi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:A}})).data?.customerVerifyCode;if(e?.loginToken){if(!e.partner?.id)throw new Error(`Unable to find customer: ${t}`);const A=dA.getMap("customerTokens")||new Map;return A.set(e.id,e.loginToken),dA.setMap("customerTokens",A),IA(e.loginToken),this.customer={...e,loginToken:void 0},!0}return!1}async getNewBundle(t){const A=(await yA.getShadowGraphqlClient().mutate({mutation:_a,variables:{collectionId:t}})).data?.bundleCreate;if(!A)throw new Error("Unable to create bundle");mA(A.bundleOwnerId);const e=dA.getMap("bundleOwnerIds")||new Map;return e.set(A.id,A.bundleOwnerId),dA.setMap("bundleOwnerIds",e),new Qi(this,A)}async getExistingBundle(t,A){const e=await yA.getShadowGraphqlClient().query({query:Za,variables:{id:t}});if(!e.data?.bundles||0===e.data?.bundles.length||!e.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const n=e.data?.bundles[0],a=dA.getMap("bundleOwnerIds");a?.has(n.id)&&mA(a.get(n.id));const i=new Qi(this,n);if(n.transactions&&n.transactions.length>0){const t=t=>{const e=A?e=>A(e,t):void 0;return this.getWorkflowExperience(void 0,void 0,e,{type:"transaction",transactionId:t})},e=await Promise.all(n.transactions.map((A=>t(A.id))));i._setWorkflowExperiencesInternal(e)}return i}async getWorkflowExperience(t,A,e,n){if(!n)return await this.getWorkflowExperienceDeprecated(t,A,e);const a=async t=>{for(const A in t.layouts){const e=t.layouts[A].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<e.length;++t){const A=e[t];A.src&&A.svg&&(A.cachedObjectURL=await dt(A.svg))}const n=t.layouts[A].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const A=n[t];A.fontData?.assetUrl&&H(A.fontData.assetUrl)}}},{transaction:i,workflow:o,readOnly:r}=await(async()=>{const t=yA.getShadowGraphqlClient();if("transaction"===n.type){const{transactionId:A,readOnly:e}=n,a=await t.query({query:Hn,variables:{id:A},errorPolicy:"all",fetchPolicy:"no-cache"});if(!a.data?.transactions||0===a.data.transactions.length)throw new cA("Existing transaction not found.");const i=a.data?.transactions[0];if(!i.workflowId)throw new cA("Existing transaction has no workflow ID.");const o=await Yi(i.workflowId);if(!i.product)throw new cA("Failed to load transaction, product not available.");return{transaction:i,workflow:o,readOnly:e}}if("integration"===n.type||"external"===n.type){const A=async()=>{const A="integration"===n.type?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},e=await t.mutate({mutation:Rn,variables:{...A,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(!e.data||!e.data.transactionCreate)throw new cA("Failed to create transaction!");const a=e.data.transactionCreate;if(!a.product)throw new cA("Failed to create transaction, product not available.");return a},e=Yi(n.workflowId),[a,i]=await Promise.all([A(),e]);return{transaction:a,workflow:i}}throw new cA("No workflow ID provided.")})();this.currencyCode=i.product.partner?.currencyCode;const s={product:i.product,transaction:i,layouts:[],stateMutationFunc:r?async()=>{throw new rA("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:r,workflow:o};if("transaction"===n.type&&i.workflowState){const t=JSON.parse(i.workflowState);s.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await a(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 a(t),s.reloadedState=t}else s.layouts=Si(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=e&&e(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=dA.getMap("transactionOwnerIds")||new Map;t.set(i.id,i.transactionOwnerId),uA(i.transactionOwnerId||""),dA.setMap("transactionOwnerIds",t)}else{const t=(dA.getMap("transactionOwnerIds")||new Map).get(i.id);t&&uA(t),s.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=s;const c=new Xa(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 cA("No integration product ID provided.");const A=yA.getShadowGraphqlClient(),e=await A.mutate({mutation:Rn,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(!e.data||!e.data.transactionCreate)throw new cA("Failed to create transaction!");const n=e.data.transactionCreate;if(!n.product)throw new cA("Failed to create transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode;const a=dA.getMap("transactionOwnerIds")||new Map;a.set(n.id,n.transactionOwnerId),uA(n.transactionOwnerId||""),dA.setMap("transactionOwnerIds",a),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,A=!1){if(""===t)throw new cA("No transaction ID provided.");const e=yA.getShadowGraphqlClient();if(A)return await(async()=>{const n=(await e.query({query:Hn,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!n)throw new cA("Failed to read transaction.");if(!n.product)throw new cA("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 rA("State mutation is forbidden in read only mode!")},readOnly:A},this.initialized=!0})();const n=dA.getMap("transactionOwnerIds")||new Map,a=n.get(t);if(a){uA(a);const n=(await e.query({query:Hn,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!n)throw new cA("Failed to read transaction.");if(!n.product)throw new cA("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:A},void(this.initialized=!0)}try{const a=(await e.mutate({mutation:Pn,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!a)throw new cA("Failed to read transaction.");if(!a.product)throw new cA("Failed to load transaction, product not available.");this.currencyCode=a.product.partner?.currencyCode,a.transactionOwnerId&&(n.set(a.id,a.transactionOwnerId),uA(a.transactionOwnerId),dA.setMap("transactionOwnerIds",n)),this.experienceOptions={product:a.product,transaction:a,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:A},this.initialized=!0}catch{throw new cA("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,A,e){if(!this.initialized||!this.experienceOptions)throw new cA("Cannot launch experience: Not initialized.");const n=async t=>{for(const A in t.layouts){const e=t.layouts[A].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<e.length;++t){const A=e[t];A.src&&A.svg&&(A.cachedObjectURL=await dt(A.svg))}const n=t.layouts[A].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const A=n[t];A.fontData?.assetUrl&&H(A.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await Yi(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=e&&e(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 A=new Xa(this,this.experienceOptions);return await A.getWorkflowManager().getInitializationPromise(),A}if(t){const a=yA.getShadowGraphqlClient().mutate({mutation:Gn,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),i=Yi(t);if(await Promise.all([a,i]),this.experienceOptions.workflow=await i,A){const t=JSON.parse(A);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=Si(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=e&&e(await i),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 Xa(this,this.experienceOptions);return await o.getWorkflowManager().getInitializationPromise(),o}throw new cA("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new cA("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new cA("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function xi(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class Ni{constructor(){xi(this,"getProduct",void 0),xi(this,"getCommandContext",void 0),xi(this,"getAllLayoutData",void 0),xi(this,"getMetadata",void 0),xi(this,"getWorkflowMetadata",void 0),xi(this,"getStepStorage",void 0),xi(this,"setModelContainer",void 0),xi(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,A){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,A){}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,A){}setInformationResults(t){}setMandatoryFulfilled(t,A){}async setSelectionsAndElements(t,A,e){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,A){}async updateStorage(t,A){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function Ri(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}let Pi;var Hi;(Hi=Pi||(Pi={})).SelectFrame="SelectFrame",Hi.SelectImage="SelectImage",Hi.Position="Position";class Ui extends Ma{constructor(t,A){super(t,A),Ri(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const A=this.manager.getRegionElements(this.step.stepName);return ia.selectVariant(this.step,t.getResource(),A,this.manager,(t=>this.setUpdateState(t)))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged((A=>{A&&t(A)}))}selectImage(t){return ia.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,A,e,n){return n&&n.length>1&&void 0===t?Pi.SelectFrame:A||e||this.getImageData()?Pi.Position:Pi.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 Gi=t=>{const A=bt(null),e=bt(void 0),[n,a]=Rt(void 0),{addEvent:i,removeEvent:o,updateEvent:r,eventCache:s}=LA(),[c,g]=Rt(!1),[l,B]=Rt(!1),{state:w,uiDispatcher:d}=ZA(),h=Pt((t=>{const A=t;d(new qA({zoom:Math.max(.1,Math.min(A,w.maxZoom))}))}),[d,w.maxZoom]),E=Pt((t=>{o(t),1===s.length&&(e.current=void 0),2===s.length&&a(void 0);"touch"===t.pointerType&&s.length>1&&s.length-1==1&&(B(!1),g(!1))}),[o,s.length]),C=Pt((t=>{i(t);"touch"===t.pointerType&&1===s.length&&(d(new qA({selectedElement:void 0})),B(!0),g(!0))}),[i,s.length,d]),Q=Pt((t=>{r(t);const A=1===s.length&&"touch"!==s[0].pointerType,i=2===s.length&&"touch"===s[0].pointerType;if(c&&i){const[t,A]=s,e=Math.abs(t.clientX-A.clientX),i=n;i&&h(w.zoom-.0055*(i-e)),a(e)}if(l&&(A||i)&&t.isPrimary){const A=(e?.current?.x||t.screenX)-t.screenX,n=(e?.current?.y||t.screenY)-t.screenY;d(new qA({selectedElement:void 0,xTranslation:w.xTranslation-A/w.zoom,yTranslation:w.yTranslation-n/w.zoom}))}t.isPrimary&&(e.current={x:t.screenX,y:t.screenY})}),[r,s,c,l,n,h,w.zoom,w.xTranslation,w.yTranslation,d]),u=Pt((t=>{c&&h(w.zoom-.035*Math.sign(t.deltaY))}),[h,w.zoom,c]);Ut((()=>{if(!A.current||0===s.length)return;const t=s[0].pointerId,e=A.current.hasPointerCapture(t);l&&!e&&A.current.setPointerCapture(t),!l&&e&&A.current.releasePointerCapture(t)}),[A,l,s]),Je([" "],(()=>{B(!0),d(new qA({selectedElement:void 0}))}),(()=>B(!1))),Je(["Control"],(()=>g(!0)),(()=>g(!1)));const p=kt((()=>({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:A,className:"transform-wrapper",onWheel:u,onPointerDown:C,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:Q,style:p,children:t.children})};export{vi as SpiffCommerceClient,t as CommandContext,EA as spiffCoreConfiguration,ze as PromiseQueue,Oe as QueueablePromise,Ni as MockWorkflowManager,ua as InformationMessageType,Ma as StepHandle,Ga as TextStepHandle,Ui as FrameStepHandle,va as BulkStepHandle,Ua as ShapeStepHandle,xa as IllustrationStepHandle,Na as MaterialStepHandle,Ra as ModelStepHandle,Pa as PictureStepHandle,Ha as QuestionStepHandle,te as BulkPriceCalculationStrategy,fa as Variant,AA as OptionNotFoundError,eA as LayoutNotFoundError,nA as AssetNotFoundError,aA as ResourceNotFoundError,iA as MisconfigurationError,sA as ParseError,rA as UnhandledBehaviorError,HA as assetService,Va as designService,za as createDesign,bA as optionService,dA as persistenceService,yA as graphQlManager,ge as toast,Zn as FrameService,Xn as getBoundedOffsets,ia as frameStepService,sa as modelStepService,ra as materialStepService,Ba as shapeStepService,la as questionStepService,na as digitalContentStepService,ca as moduleStepService,ga as pictureStepService,Ca as textStepService,oa as illustrationStepService,$A as ProductCameraRig,Pi as FrameStep,ee as ConversionLocation,ae as ConversionDataType,Yi as getWorkflow,ta as shortenUrl,A as AssetType,e as BringForwardCommand,n as BringToFrontCommand,a as BringToBackCommand,i 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,Q as RotateCommand,u as SendBackwardsCommand,oe 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,R as getSvgElement,P as loadFontFromDataUrl,H as loadFontFromExternalUrl,U as determineCorrectFontSizeAndLines,G as patternImageDataCache,Dn as generateCommands,k as registerJSDOM,Ge as minZoom,Nn as AdvancedEditor,Gi as TransformWrapper,xn as EditorCore,TA as useLayouts,ZA as useEditorState,be as useEditorInteraction,Je as useShortcutCombination,VA as commandReducer,KA as getDefaultState,JA as CommandContextContext,XA as AdvancedEditorStateProvider,WA as AdvancedEditorContext,qA as UICommand,zA as EditorSubMenu,le as ElementEventType,we as KeyEvent,Ln as gatherVaryingStepAspects};
1307
1307
  //# sourceMappingURL=module.js.map
package/dist/types.d.ts CHANGED
@@ -2043,6 +2043,12 @@ interface _Bundle1 {
2043
2043
  * Retrieves all stakeholders associated with this bundle.
2044
2044
  */
2045
2045
  getAllStakeholders(): Promise<BundleStakeholder[]>;
2046
+ /**
2047
+ * Finalizes all experiences within the bundle. This will return a promise that resolves when all experiences have been finalized.
2048
+ * The promise resolves with a list of messages that indicate the status of each experience including
2049
+ * helpful details like what product to add to cart on supported e-commerce platforms.
2050
+ */
2051
+ finish(): Promise<DesignCreationMessage[]>;
2046
2052
  }
2047
2053
  export const getWorkflow: (id: string) => Promise<_Workflow1>;
2048
2054
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/core",
3
- "version": "12.11.0",
3
+ "version": "12.11.2",
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",