@spiffcommerce/core 11.2.0 → 11.3.0
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 +24 -8
- package/dist/module.js +24 -8
- package/dist/types.d.ts +26 -3
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1046,8 +1046,10 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
|
|
|
1046
1046
|
query GetTransactionForPartner($id: String!) {
|
|
1047
1047
|
transactions(ids: [$id]) {
|
|
1048
1048
|
id
|
|
1049
|
+
bundle {
|
|
1050
|
+
id
|
|
1051
|
+
}
|
|
1049
1052
|
customLogoLink
|
|
1050
|
-
designName
|
|
1051
1053
|
isOrdered
|
|
1052
1054
|
product {
|
|
1053
1055
|
id
|
|
@@ -1055,8 +1057,6 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
|
|
|
1055
1057
|
id
|
|
1056
1058
|
}
|
|
1057
1059
|
}
|
|
1058
|
-
workflowId
|
|
1059
|
-
workflowViewerReadOnlyLink
|
|
1060
1060
|
}
|
|
1061
1061
|
}
|
|
1062
1062
|
`,ic=t.gql`
|
|
@@ -1105,8 +1105,16 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
|
|
|
1105
1105
|
type
|
|
1106
1106
|
transaction {
|
|
1107
1107
|
id
|
|
1108
|
-
|
|
1109
|
-
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
bundleStakeholders {
|
|
1111
|
+
id
|
|
1112
|
+
type
|
|
1113
|
+
bundle {
|
|
1114
|
+
id
|
|
1115
|
+
transactions {
|
|
1116
|
+
id
|
|
1117
|
+
}
|
|
1110
1118
|
}
|
|
1111
1119
|
}
|
|
1112
1120
|
}
|
|
@@ -1132,11 +1140,19 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
|
|
|
1132
1140
|
type
|
|
1133
1141
|
transaction {
|
|
1134
1142
|
id
|
|
1135
|
-
|
|
1136
|
-
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
bundleStakeholders {
|
|
1146
|
+
id
|
|
1147
|
+
type
|
|
1148
|
+
bundle {
|
|
1149
|
+
id
|
|
1150
|
+
transactions {
|
|
1151
|
+
id
|
|
1152
|
+
}
|
|
1137
1153
|
}
|
|
1138
1154
|
}
|
|
1139
1155
|
}
|
|
1140
1156
|
}
|
|
1141
|
-
`,cc=async t=>{const e=(await Cr.getShadowGraphqlClient().query({query:ec,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return e.steps.forEach((t=>{delete t.data.__typename})),e},lc=(t,e)=>{const A=t.workflowState,i=A?JSON.parse(A):void 0;return i?Object.values(i.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 gc{constructor(t){var e;Zo(this,"options",void 0),Zo(this,"initialized",void 0),Zo(this,"experienceOptions",void 0),Zo(this,"currencyCode",void 0),Zo(this,"customer",void 0),Zo(this,"updateTransactionState",(async t=>{try{return Cr.getShadowGraphqlClient().mutate({...t,mutation:Ss})}catch(t){throw console.error(t),new nr("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,mr=e)}getAssetManager(){return Sr}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}async authenticateTransactionFromLocalStorage(t){const e=Cr.getShadowGraphqlClient(),A=await e.query({query:Ac,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 i=A.data.transactions[0],n=i.product?.partner?.id;if(!n)throw new Error(`Unable to read transaction: ${t}`);if(i.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const r=cr.getMap("transactionOwnerIds");if(r?.has(t)){const e=r.get(t);return ur(e),Promise.resolve({success:!0,stakeholderType:ea.Owner})}const a=cr.getMap("transactionCustomerIds");if(a?.has(t)){const e=a.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=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:ic,errorPolicy:"all",variables:{id:i.workflowId}})).data.workflow;if(!s)throw new Error(`Unable to read workflow: ${i.workflowId}`);return Promise.resolve({success:!1,theme:s.overrideTheme,customLogoLink:i.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=cr.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),cr.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=Cr.getShadowGraphqlClient(),A=(await e.query({query:nc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!A.id){const A=(await e.mutate({mutation:rc,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 i=await this.authenticateCustomerId(A.id);return{customer:this.customer||A,isAuthenticated:i}}async authenticateCustomerId(t){const e=Cr.getShadowGraphqlClient(),A=cr.getMap("customerTokens");if(!A?.has(t))return!1;const i=A.get(t);if(!i)return!1;const n=(await e.mutate({mutation:ac,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:i}})).data?.customerAuthenticate;return!!n&&(pr(i),this.customer=n,!0)}async generateVerificationCode(t){await Cr.getShadowGraphqlClient().mutate({mutation:sc,variables:{emailAddress:t}})}async verifyCode(t,e){const A=await Cr.getShadowGraphqlClient().mutate({mutation:oc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}});if(A.data?.customerVerifyCode.loginToken){if(!A.data.customerVerifyCode.partner?.id)throw new Error(`Unable to find customer: ${t}`);const e=cr.getMap("customerTokens")||new Map;return e.set(A.data.customerVerifyCode.id,A.data.customerVerifyCode.loginToken),cr.setMap("customerTokens",e),pr(A.data.customerVerifyCode.loginToken),this.customer={...A.data.customerVerifyCode,loginToken:void 0},!0}return!1}async getNewBundle(){const t=(await Cr.getShadowGraphqlClient().mutate({mutation:Vo})).data?.bundleCreate;if(!t)throw new Error("Unable to create bundle");wr(t.bundleOwnerId);const e=cr.getMap("bundleOwnerIds")||new Map;return e.set(t.id,t.bundleOwnerId),cr.setMap("bundleOwnerIds",e),new qo(this,t.id)}async getExistingBundle(t){const e=await Cr.getShadowGraphqlClient().query({query:jo,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 A=e.data?.bundles[0],i=cr.getMap("bundleOwnerIds");return i?.has(A.id)&&wr(i.get(A.id)),new qo(this,A.id)}async getWorkflowExperience(t,e,A,i){if(!i)return await this.getWorkflowExperienceDeprecated(t,e,A);const n=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await zn(e.svg))}const i=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<i.length;++t){const e=i[t];e.fontData?.assetUrl&&ii(e.fontData.assetUrl)}}},{transaction:r,workflow:a,readOnly:s}=await(async()=>{const t=Cr.getShadowGraphqlClient();if(await t.resetStore(),"transaction"===i.type){const{transactionId:e,readOnly:A}=i,n=await t.query({query:Fs,variables:{id:e},errorPolicy:"all"});if(!n.data?.transactions||0===n.data.transactions.length)throw new nr("Existing transaction not found.");const r=n.data?.transactions[0];if(!r.workflowId)throw new nr("Existing transaction has no workflow ID.");const a=await cc(r.workflowId);if(!r.product)throw new nr("Failed to load transaction, product not available.");return{transaction:r,workflow:a,readOnly:A}}if("integration"===i.type||"external"===i.type){const e=async()=>{const e="integration"===i.type?{integrationProductId:i.integrationProductId}:{externalIntegrationId:i.externalIntegrationId,externalProductId:i.externalProductId},A=await t.mutate({mutation:Ms,variables:{...e,bulk:i.bulk,workflowId:i.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 nr("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new nr("Failed to create transaction, product not available.");return n},A=cc(i.workflowId),[n,r]=await Promise.all([e(),A]);return{transaction:n,workflow:r}}throw new nr("No workflow ID provided.")})();if(this.currencyCode=r.product.partner?.currencyCode,this.experienceOptions={product:r.product,transaction:r,layouts:[],stateMutationFunc:s?async()=>{throw new Ar("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:s,workflow:a},"transaction"===i.type&&r.workflowState){const t=JSON.parse(r.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Vi(t),await n(t),this.experienceOptions.reloadedState=t}else if(!s&&i.workflowState){const t=JSON.parse(i.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Vi(t),await n(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=lc(this.experienceOptions.transaction,this.experienceOptions.workflow);if(this.experienceOptions.previewService=A&&A(a),this.experienceOptions.renderableContextService=new ps(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&this.experienceOptions.previewService?.initialize(this.experienceOptions.product.modelUrl,this.experienceOptions.renderableContextService),"transaction"!==i.type){const t=cr.getMap("transactionOwnerIds")||new Map;t.set(r.id,r.transactionOwnerId),ur(r.transactionOwnerId||""),cr.setMap("transactionOwnerIds",t)}else{const t=(cr.getMap("transactionOwnerIds")||new Map).get(r.id);t&&ur(t)}this.initialized=!0;const o=new zo(this,this.experienceOptions);return await o.getWorkflowManager().getInitializationPromise(),"transaction"!==i.type&&this.customer&&await o.attachCustomerDetails({email:this.customer.emailAddress}),o}async initFromIntegrationProduct(t){if(""===t)throw new nr("No integration product ID provided.");const e=Cr.getShadowGraphqlClient();await e.resetStore();const A=await e.mutate({mutation:Ms,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 nr("Failed to create transaction!");const i=A.data.transactionCreate;if(!i.product)throw new nr("Failed to create transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode;const n=cr.getMap("transactionOwnerIds")||new Map;n.set(i.id,i.transactionOwnerId),ur(i.transactionOwnerId||""),cr.setMap("transactionOwnerIds",n),this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new nr("No transaction ID provided.");const A=Cr.getShadowGraphqlClient();await A.resetStore();if(e)return await(async()=>{const i=(await A.query({query:Fs,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!i)throw new nr("Failed to read transaction.");if(!i.product)throw new nr("Failed to load transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode,this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:async()=>{throw new Ar("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const i=cr.getMap("transactionOwnerIds")||new Map,n=i.get(t);if(n){ur(n);const i=(await A.query({query:Fs,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!i)throw new nr("Failed to read transaction.");if(!i.product)throw new nr("Failed to load transaction, product not available.");return this.currencyCode=i.product.partner?.currencyCode,this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const n=(await A.mutate({mutation:vs,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!n)throw new nr("Failed to read transaction.");if(!n.product)throw new nr("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,n.transactionOwnerId&&(i.set(n.id,n.transactionOwnerId),ur(n.transactionOwnerId),cr.setMap("transactionOwnerIds",i)),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new nr("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,A){if(!this.initialized||!this.experienceOptions)throw new nr("Cannot launch experience: Not initialized.");const i=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await zn(e.svg))}const i=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<i.length;++t){const e=i[t];e.fontData?.assetUrl&&ii(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await cc(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 Vi(t),await i(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=A&&A(t),this.experienceOptions.renderableContextService=new ps(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&this.experienceOptions.previewService?.initialize(this.experienceOptions.product.modelUrl,this.experienceOptions.renderableContextService);const e=new zo(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const n=Cr.getShadowGraphqlClient().mutate({mutation:bs,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),r=cc(t);if(await Promise.all([n,r]),this.experienceOptions.workflow=await r,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Vi(t),await i(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=lc(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await r),this.experienceOptions.renderableContextService=new ps(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&this.experienceOptions.previewService?.initialize(this.experienceOptions.product.modelUrl,this.experienceOptions.renderableContextService);const a=new zo(this,this.experienceOptions);return await a.getWorkflowManager().getInitializationPromise(),a}throw new nr("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new nr("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new nr("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function hc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class dc{constructor(){hc(this,"getProduct",void 0),hc(this,"getCommandContext",void 0),hc(this,"getAllLayoutData",void 0),hc(this,"getMetadata",void 0),hc(this,"getWorkflowMetadata",void 0),hc(this,"getStepStorage",void 0),hc(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(){}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){}}function uc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let Bc;var wc;(wc=Bc||(Bc={})).SelectFrame="SelectFrame",wc.SelectImage="SelectImage",wc.Position="Position";class Ec extends fo{constructor(t,e){super(t,e),uc(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return _s.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 _s.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,A,i){return i&&i.length>1&&void 0===t?Bc.SelectFrame:e||A||this.getImageData()?Bc.Position:Bc.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 pc=t=>{const e=(0,i.useRef)(null),n=(0,i.useRef)(void 0),[r,a]=(0,i.useState)(void 0),{addEvent:s,removeEvent:o,updateEvent:c,eventCache:l}=kr(),[g,h]=(0,i.useState)(!1),[d,u]=(0,i.useState)(!1),{state:B,uiDispatcher:w}=Vr(),E=(0,i.useCallback)((t=>{const e=t;w(new jr({zoom:Math.max(.1,Math.min(e,B.maxZoom))}))}),[w,B.maxZoom]),p=(0,i.useCallback)((t=>{o(t),1===l.length&&(n.current=void 0),2===l.length&&a(void 0);"touch"===t.pointerType&&l.length>1&&l.length-1==1&&(u(!1),h(!1))}),[o,l.length]),m=(0,i.useCallback)((t=>{s(t);"touch"===t.pointerType&&1===l.length&&(w(new jr({selectedElement:void 0})),u(!0),h(!0))}),[s,l.length,w]),C=(0,i.useCallback)((t=>{c(t);const e=1===l.length&&"touch"!==l[0].pointerType,A=2===l.length&&"touch"===l[0].pointerType;if(g&&A){const[t,e]=l,A=Math.abs(t.clientX-e.clientX),i=r;i&&E(B.zoom-.0055*(i-A)),a(A)}if(d&&(e||A)&&t.isPrimary){const e=(n?.current?.x||t.screenX)-t.screenX,A=(n?.current?.y||t.screenY)-t.screenY;w(new jr({selectedElement:void 0,xTranslation:B.xTranslation-e/B.zoom,yTranslation:B.yTranslation-A/B.zoom}))}t.isPrimary&&(n.current={x:t.screenX,y:t.screenY})}),[c,l,g,d,r,E,B.zoom,B.xTranslation,B.yTranslation,w]),f=(0,i.useCallback)((t=>{g&&E(B.zoom-.035*Math.sign(t.deltaY))}),[E,B.zoom,g]);(0,i.useEffect)((()=>{if(!e.current||0===l.length)return;const t=l[0].pointerId,A=e.current.hasPointerCapture(t);d&&!A&&e.current.setPointerCapture(t),!d&&A&&e.current.releasePointerCapture(t)}),[e,d,l]),Ra([" "],(()=>{u(!0),w(new jr({selectedElement:void 0}))}),(()=>u(!1))),Ra(["Control"],(()=>h(!0)),(()=>h(!1)));const Q=(0,i.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,A.jsx)("div",{ref:e,className:"transform-wrapper",onWheel:f,onPointerDown:m,onPointerUp:p,onPointerCancel:p,onPointerLeave:p,onPointerMove:C,style:Q,children:t.children})};
|
|
1157
|
+
`,cc=async t=>{const e=(await Cr.getShadowGraphqlClient().query({query:ec,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return e.steps.forEach((t=>{delete t.data.__typename})),e},lc=(t,e)=>{const A=t.workflowState,i=A?JSON.parse(A):void 0;return i?Object.values(i.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 gc{constructor(t){var e;Zo(this,"options",void 0),Zo(this,"initialized",void 0),Zo(this,"experienceOptions",void 0),Zo(this,"currencyCode",void 0),Zo(this,"customer",void 0),Zo(this,"updateTransactionState",(async t=>{try{return Cr.getShadowGraphqlClient().mutate({...t,mutation:Ss})}catch(t){throw console.error(t),new nr("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,mr=e)}getAssetManager(){return Sr}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}async authenticateBundleFromLocalStorage(t){const e=cr.getMap("bundleOwnerIds");if(e?.has(t)){const A=e.get(t);return wr(A),Promise.resolve({success:!0,stakeholderType:ea.Owner})}const A=cr.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=Cr.getShadowGraphqlClient(),A=await e.query({query:Ac,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 i=A.data.transactions[0],n=i.product?.partner?.id;if(!n)throw new Error(`Unable to read transaction: ${t}`);if(i.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const r=cr.getMap("transactionOwnerIds");if(r?.has(t)){const e=r.get(t);return ur(e),Promise.resolve({success:!0,stakeholderType:ea.Owner})}const a=cr.getMap("transactionCustomerIds");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?.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:ic,errorPolicy:"all",variables:{id:i.workflowId}})).data.workflow;if(!s)throw new Error(`Unable to read workflow: ${i.workflowId}`);return Promise.resolve({success:!1,theme:s.overrideTheme,customLogoLink:i.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=cr.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),cr.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=Cr.getShadowGraphqlClient(),A=(await e.query({query:nc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!A.id){const A=(await e.mutate({mutation:rc,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 i=await this.authenticateCustomerId(A.id);return{customer:this.customer||A,isAuthenticated:i}}async authenticateCustomerId(t){const e=Cr.getShadowGraphqlClient(),A=cr.getMap("customerTokens");if(!A?.has(t))return!1;const i=A.get(t);if(!i)return!1;const n=(await e.mutate({mutation:ac,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:i}})).data?.customerAuthenticate;return!!n&&(pr(i),this.customer=n,!0)}async generateVerificationCode(t){await Cr.getShadowGraphqlClient().mutate({mutation:sc,variables:{emailAddress:t}})}async verifyCode(t,e){const A=(await Cr.getShadowGraphqlClient().mutate({mutation:oc,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=cr.getMap("customerTokens")||new Map;return e.set(A.id,A.loginToken),cr.setMap("customerTokens",e),pr(A.loginToken),this.customer={...A,loginToken:void 0},!0}return!1}async getNewBundle(){const t=(await Cr.getShadowGraphqlClient().mutate({mutation:Vo})).data?.bundleCreate;if(!t)throw new Error("Unable to create bundle");wr(t.bundleOwnerId);const e=cr.getMap("bundleOwnerIds")||new Map;return e.set(t.id,t.bundleOwnerId),cr.setMap("bundleOwnerIds",e),new qo(this,t.id)}async getExistingBundle(t){const e=await Cr.getShadowGraphqlClient().query({query:jo,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 A=e.data?.bundles[0],i=cr.getMap("bundleOwnerIds");return i?.has(A.id)&&wr(i.get(A.id)),new qo(this,A.id)}async getWorkflowExperience(t,e,A,i){if(!i)return await this.getWorkflowExperienceDeprecated(t,e,A);const n=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await zn(e.svg))}const i=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<i.length;++t){const e=i[t];e.fontData?.assetUrl&&ii(e.fontData.assetUrl)}}},{transaction:r,workflow:a,readOnly:s}=await(async()=>{const t=Cr.getShadowGraphqlClient();if(await t.resetStore(),"transaction"===i.type){const{transactionId:e,readOnly:A}=i,n=await t.query({query:Fs,variables:{id:e},errorPolicy:"all"});if(!n.data?.transactions||0===n.data.transactions.length)throw new nr("Existing transaction not found.");const r=n.data?.transactions[0];if(!r.workflowId)throw new nr("Existing transaction has no workflow ID.");const a=await cc(r.workflowId);if(!r.product)throw new nr("Failed to load transaction, product not available.");return{transaction:r,workflow:a,readOnly:A}}if("integration"===i.type||"external"===i.type){const e=async()=>{const e="integration"===i.type?{integrationProductId:i.integrationProductId}:{externalIntegrationId:i.externalIntegrationId,externalProductId:i.externalProductId},A=await t.mutate({mutation:Ms,variables:{...e,bulk:i.bulk,workflowId:i.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 nr("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new nr("Failed to create transaction, product not available.");return n},A=cc(i.workflowId),[n,r]=await Promise.all([e(),A]);return{transaction:n,workflow:r}}throw new nr("No workflow ID provided.")})();if(this.currencyCode=r.product.partner?.currencyCode,this.experienceOptions={product:r.product,transaction:r,layouts:[],stateMutationFunc:s?async()=>{throw new Ar("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:s,workflow:a},"transaction"===i.type&&r.workflowState){const t=JSON.parse(r.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Vi(t),await n(t),this.experienceOptions.reloadedState=t}else if(!s&&i.workflowState){const t=JSON.parse(i.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Vi(t),await n(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=lc(this.experienceOptions.transaction,this.experienceOptions.workflow);if(this.experienceOptions.previewService=A&&A(a),this.experienceOptions.renderableContextService=new ps(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&this.experienceOptions.previewService?.initialize(this.experienceOptions.product.modelUrl,this.experienceOptions.renderableContextService),"transaction"!==i.type){const t=cr.getMap("transactionOwnerIds")||new Map;t.set(r.id,r.transactionOwnerId),ur(r.transactionOwnerId||""),cr.setMap("transactionOwnerIds",t)}else{const t=(cr.getMap("transactionOwnerIds")||new Map).get(r.id);t&&ur(t)}this.initialized=!0;const o=new zo(this,this.experienceOptions);return await o.getWorkflowManager().getInitializationPromise(),"transaction"!==i.type&&this.customer&&await o.attachCustomerDetails({email:this.customer.emailAddress}),o}async initFromIntegrationProduct(t){if(""===t)throw new nr("No integration product ID provided.");const e=Cr.getShadowGraphqlClient();await e.resetStore();const A=await e.mutate({mutation:Ms,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 nr("Failed to create transaction!");const i=A.data.transactionCreate;if(!i.product)throw new nr("Failed to create transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode;const n=cr.getMap("transactionOwnerIds")||new Map;n.set(i.id,i.transactionOwnerId),ur(i.transactionOwnerId||""),cr.setMap("transactionOwnerIds",n),this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new nr("No transaction ID provided.");const A=Cr.getShadowGraphqlClient();await A.resetStore();if(e)return await(async()=>{const i=(await A.query({query:Fs,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!i)throw new nr("Failed to read transaction.");if(!i.product)throw new nr("Failed to load transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode,this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:async()=>{throw new Ar("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const i=cr.getMap("transactionOwnerIds")||new Map,n=i.get(t);if(n){ur(n);const i=(await A.query({query:Fs,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!i)throw new nr("Failed to read transaction.");if(!i.product)throw new nr("Failed to load transaction, product not available.");return this.currencyCode=i.product.partner?.currencyCode,this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const n=(await A.mutate({mutation:vs,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!n)throw new nr("Failed to read transaction.");if(!n.product)throw new nr("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,n.transactionOwnerId&&(i.set(n.id,n.transactionOwnerId),ur(n.transactionOwnerId),cr.setMap("transactionOwnerIds",i)),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new nr("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,A){if(!this.initialized||!this.experienceOptions)throw new nr("Cannot launch experience: Not initialized.");const i=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await zn(e.svg))}const i=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<i.length;++t){const e=i[t];e.fontData?.assetUrl&&ii(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await cc(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 Vi(t),await i(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=A&&A(t),this.experienceOptions.renderableContextService=new ps(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&this.experienceOptions.previewService?.initialize(this.experienceOptions.product.modelUrl,this.experienceOptions.renderableContextService);const e=new zo(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const n=Cr.getShadowGraphqlClient().mutate({mutation:bs,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),r=cc(t);if(await Promise.all([n,r]),this.experienceOptions.workflow=await r,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Vi(t),await i(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=lc(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await r),this.experienceOptions.renderableContextService=new ps(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&this.experienceOptions.previewService?.initialize(this.experienceOptions.product.modelUrl,this.experienceOptions.renderableContextService);const a=new zo(this,this.experienceOptions);return await a.getWorkflowManager().getInitializationPromise(),a}throw new nr("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new nr("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new nr("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function hc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class dc{constructor(){hc(this,"getProduct",void 0),hc(this,"getCommandContext",void 0),hc(this,"getAllLayoutData",void 0),hc(this,"getMetadata",void 0),hc(this,"getWorkflowMetadata",void 0),hc(this,"getStepStorage",void 0),hc(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(){}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){}}function uc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let Bc;var wc;(wc=Bc||(Bc={})).SelectFrame="SelectFrame",wc.SelectImage="SelectImage",wc.Position="Position";class Ec extends fo{constructor(t,e){super(t,e),uc(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return _s.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 _s.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,A,i){return i&&i.length>1&&void 0===t?Bc.SelectFrame:e||A||this.getImageData()?Bc.Position:Bc.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 pc=t=>{const e=(0,i.useRef)(null),n=(0,i.useRef)(void 0),[r,a]=(0,i.useState)(void 0),{addEvent:s,removeEvent:o,updateEvent:c,eventCache:l}=kr(),[g,h]=(0,i.useState)(!1),[d,u]=(0,i.useState)(!1),{state:B,uiDispatcher:w}=Vr(),E=(0,i.useCallback)((t=>{const e=t;w(new jr({zoom:Math.max(.1,Math.min(e,B.maxZoom))}))}),[w,B.maxZoom]),p=(0,i.useCallback)((t=>{o(t),1===l.length&&(n.current=void 0),2===l.length&&a(void 0);"touch"===t.pointerType&&l.length>1&&l.length-1==1&&(u(!1),h(!1))}),[o,l.length]),m=(0,i.useCallback)((t=>{s(t);"touch"===t.pointerType&&1===l.length&&(w(new jr({selectedElement:void 0})),u(!0),h(!0))}),[s,l.length,w]),C=(0,i.useCallback)((t=>{c(t);const e=1===l.length&&"touch"!==l[0].pointerType,A=2===l.length&&"touch"===l[0].pointerType;if(g&&A){const[t,e]=l,A=Math.abs(t.clientX-e.clientX),i=r;i&&E(B.zoom-.0055*(i-A)),a(A)}if(d&&(e||A)&&t.isPrimary){const e=(n?.current?.x||t.screenX)-t.screenX,A=(n?.current?.y||t.screenY)-t.screenY;w(new jr({selectedElement:void 0,xTranslation:B.xTranslation-e/B.zoom,yTranslation:B.yTranslation-A/B.zoom}))}t.isPrimary&&(n.current={x:t.screenX,y:t.screenY})}),[c,l,g,d,r,E,B.zoom,B.xTranslation,B.yTranslation,w]),f=(0,i.useCallback)((t=>{g&&E(B.zoom-.035*Math.sign(t.deltaY))}),[E,B.zoom,g]);(0,i.useEffect)((()=>{if(!e.current||0===l.length)return;const t=l[0].pointerId,A=e.current.hasPointerCapture(t);d&&!A&&e.current.setPointerCapture(t),!d&&A&&e.current.releasePointerCapture(t)}),[e,d,l]),Ra([" "],(()=>{u(!0),w(new jr({selectedElement:void 0}))}),(()=>u(!1))),Ra(["Control"],(()=>h(!0)),(()=>h(!1)));const Q=(0,i.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,A.jsx)("div",{ref:e,className:"transform-wrapper",onWheel:f,onPointerDown:m,onPointerUp:p,onPointerCancel:p,onPointerLeave:p,onPointerMove:C,style:Q,children:t.children})};
|
|
1142
1158
|
//# sourceMappingURL=main.js.map
|
package/dist/module.js
CHANGED
|
@@ -1046,8 +1046,10 @@ import{CommandContext as A,AssetType as t,BringForwardCommand as e,BringToFrontC
|
|
|
1046
1046
|
query GetTransactionForPartner($id: String!) {
|
|
1047
1047
|
transactions(ids: [$id]) {
|
|
1048
1048
|
id
|
|
1049
|
+
bundle {
|
|
1050
|
+
id
|
|
1051
|
+
}
|
|
1049
1052
|
customLogoLink
|
|
1050
|
-
designName
|
|
1051
1053
|
isOrdered
|
|
1052
1054
|
product {
|
|
1053
1055
|
id
|
|
@@ -1055,8 +1057,6 @@ import{CommandContext as A,AssetType as t,BringForwardCommand as e,BringToFrontC
|
|
|
1055
1057
|
id
|
|
1056
1058
|
}
|
|
1057
1059
|
}
|
|
1058
|
-
workflowId
|
|
1059
|
-
workflowViewerReadOnlyLink
|
|
1060
1060
|
}
|
|
1061
1061
|
}
|
|
1062
1062
|
`,ia=IA`
|
|
@@ -1105,8 +1105,16 @@ import{CommandContext as A,AssetType as t,BringForwardCommand as e,BringToFrontC
|
|
|
1105
1105
|
type
|
|
1106
1106
|
transaction {
|
|
1107
1107
|
id
|
|
1108
|
-
|
|
1109
|
-
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
bundleStakeholders {
|
|
1111
|
+
id
|
|
1112
|
+
type
|
|
1113
|
+
bundle {
|
|
1114
|
+
id
|
|
1115
|
+
transactions {
|
|
1116
|
+
id
|
|
1117
|
+
}
|
|
1110
1118
|
}
|
|
1111
1119
|
}
|
|
1112
1120
|
}
|
|
@@ -1132,11 +1140,19 @@ import{CommandContext as A,AssetType as t,BringForwardCommand as e,BringToFrontC
|
|
|
1132
1140
|
type
|
|
1133
1141
|
transaction {
|
|
1134
1142
|
id
|
|
1135
|
-
|
|
1136
|
-
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
bundleStakeholders {
|
|
1146
|
+
id
|
|
1147
|
+
type
|
|
1148
|
+
bundle {
|
|
1149
|
+
id
|
|
1150
|
+
transactions {
|
|
1151
|
+
id
|
|
1152
|
+
}
|
|
1137
1153
|
}
|
|
1138
1154
|
}
|
|
1139
1155
|
}
|
|
1140
1156
|
}
|
|
1141
|
-
`,ga=async A=>{const t=(await ft.getShadowGraphqlClient().query({query:ea,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:A}})).data.workflow;return t.steps.forEach((A=>{delete A.data.__typename})),t},la=(A,t)=>{const e=A.workflowState,n=e?JSON.parse(e):void 0;return n?Object.values(n.layouts).map((A=>A.layout)):t.panels.sort(((A,t)=>A.index-t.index)).map((A=>({id:F(),panelId:A.name,name:A.name,index:A.index,createdAt:new Date,updatedAt:new Date,transparentBackground:A.transparentBackground,height:A.height,width:A.width,previewRegion:A.previewRegion,useEditableArea:A.useEditableArea,editableArea:A.editableArea})))};class Ba{constructor(A){var t;ta(this,"options",void 0),ta(this,"initialized",void 0),ta(this,"experienceOptions",void 0),ta(this,"currencyCode",void 0),ta(this,"customer",void 0),ta(this,"updateTransactionState",(async A=>{try{return ft.getShadowGraphqlClient().mutate({...A,mutation:Un})}catch(A){throw console.error(A),new st("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=A,this.options.applicationKey&&(t=this.options.applicationKey,It=t)}getAssetManager(){return Ht}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}async authenticateTransactionFromLocalStorage(A){const t=ft.getShadowGraphqlClient(),e=await t.query({query:na,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:A}});if(!e.data.transactions||0===e.data.transactions.length)throw new Error(`Transaction not found: ${A}`);const n=e.data.transactions[0],i=n.product?.partner?.id;if(!i)throw new Error(`Unable to read transaction: ${A}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const a=wt.getMap("transactionOwnerIds");if(a?.has(A)){const t=a.get(A);return Ct(t),Promise.resolve({success:!0,stakeholderType:ae.Owner})}const o=wt.getMap("transactionCustomerIds");if(o?.has(A)){const t=o.get(A);if(t){if(await this.authenticateCustomerId(t)){const t=this.customer?.stakeholders?.find((t=>t.transaction?.id===A));if(t)return Promise.resolve({success:!0,stakeholderType:t.type})}}}const r=(await t.query({query:ia,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(A){const t=wt.getMap("transactionCustomerIds");t?.has(A)&&(t.delete(A),wt.setMap("transactionCustomerIds",t))}getStakeholderTypeForTransaction(A){const t=this.customer?.stakeholders?.find((t=>t.transaction?.id===A));if(t)return t.type}async getOrCreateCustomer(A){this.customer=void 0;const t=ft.getShadowGraphqlClient(),e=(await t.query({query:aa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:A}})).data.customer;if(!e.id){const e=(await t.mutate({mutation:oa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:A}}})).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(A){const t=ft.getShadowGraphqlClient(),e=wt.getMap("customerTokens");if(!e?.has(A))return!1;const n=e.get(A);if(!n)return!1;const i=(await t.mutate({mutation:ra,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data?.customerAuthenticate;return!!i&&(pt(n),this.customer=i,!0)}async generateVerificationCode(A){await ft.getShadowGraphqlClient().mutate({mutation:sa,variables:{emailAddress:A}})}async verifyCode(A,t){const e=await ft.getShadowGraphqlClient().mutate({mutation:ca,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:A,verificationCode:t}});if(e.data?.customerVerifyCode.loginToken){if(!e.data.customerVerifyCode.partner?.id)throw new Error(`Unable to find customer: ${A}`);const t=wt.getMap("customerTokens")||new Map;return t.set(e.data.customerVerifyCode.id,e.data.customerVerifyCode.loginToken),wt.setMap("customerTokens",t),pt(e.data.customerVerifyCode.loginToken),this.customer={...e.data.customerVerifyCode,loginToken:void 0},!0}return!1}async getNewBundle(){const A=(await ft.getShadowGraphqlClient().mutate({mutation:qi})).data?.bundleCreate;if(!A)throw new Error("Unable to create bundle");mt(A.bundleOwnerId);const t=wt.getMap("bundleOwnerIds")||new Map;return t.set(A.id,A.bundleOwnerId),wt.setMap("bundleOwnerIds",t),new Aa(this,A.id)}async getExistingBundle(A){const t=await ft.getShadowGraphqlClient().query({query:Xi,variables:{id:A}});if(!t.data?.bundles||0===t.data?.bundles.length||!t.data?.bundles[0])throw new Error(`Unable to find bundle: ${A}`);const e=t.data?.bundles[0],n=wt.getMap("bundleOwnerIds");return n?.has(e.id)&&mt(n.get(e.id)),new Aa(this,e.id)}async getWorkflowExperience(A,t,e,n){if(!n)return await this.getWorkflowExperienceDeprecated(A,t,e);const i=async A=>{for(const t in A.layouts){const e=A.layouts[t].elements.filter((A=>A.type===E.Illustration));for(let A=0;A<e.length;++A){const t=e[A];t.src&&t.svg&&(t.cachedObjectURL=await dA(t.svg))}const n=A.layouts[t].elements.filter((A=>A.type===E.Textbox));for(let A=0;A<n.length;++A){const t=n[A];t.fontData?.assetUrl&&U(t.fontData.assetUrl)}}},{transaction:a,workflow:o,readOnly:r}=await(async()=>{const A=ft.getShadowGraphqlClient();if(await A.resetStore(),"transaction"===n.type){const{transactionId:t,readOnly:e}=n,i=await A.query({query:Hn,variables:{id:t},errorPolicy:"all"});if(!i.data?.transactions||0===i.data.transactions.length)throw new st("Existing transaction not found.");const a=i.data?.transactions[0];if(!a.workflowId)throw new st("Existing transaction has no workflow ID.");const o=await ga(a.workflowId);if(!a.product)throw new st("Failed to load transaction, product not available.");return{transaction:a,workflow:o,readOnly:e}}if("integration"===n.type||"external"===n.type){const t=async()=>{const t="integration"===n.type?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},e=await A.mutate({mutation:Nn,variables:{...t,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 st("Failed to create transaction!");const i=e.data.transactionCreate;if(!i.product)throw new st("Failed to create transaction, product not available.");return i},e=ga(n.workflowId),[i,a]=await Promise.all([t(),e]);return{transaction:i,workflow:a}}throw new st("No workflow ID provided.")})();if(this.currencyCode=a.product.partner?.currencyCode,this.experienceOptions={product:a.product,transaction:a,layouts:[],stateMutationFunc:r?async()=>{throw new ot("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:r,workflow:o},"transaction"===n.type&&a.workflowState){const A=JSON.parse(a.workflowState);this.experienceOptions.layouts=Object.values(A.layouts).map((A=>A.layout)),await v(A),await i(A),this.experienceOptions.reloadedState=A}else if(!r&&n.workflowState){const A=JSON.parse(n.workflowState);this.experienceOptions.layouts=Object.values(A.layouts).map((A=>A.layout)),await v(A),await i(A),this.experienceOptions.reloadedState=A}else this.experienceOptions.layouts=la(this.experienceOptions.transaction,this.experienceOptions.workflow);if(this.experienceOptions.previewService=e&&e(o),this.experienceOptions.renderableContextService=new In(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&this.experienceOptions.previewService?.initialize(this.experienceOptions.product.modelUrl,this.experienceOptions.renderableContextService),"transaction"!==n.type){const A=wt.getMap("transactionOwnerIds")||new Map;A.set(a.id,a.transactionOwnerId),Ct(a.transactionOwnerId||""),wt.setMap("transactionOwnerIds",A)}else{const A=(wt.getMap("transactionOwnerIds")||new Map).get(a.id);A&&Ct(A)}this.initialized=!0;const s=new Wi(this,this.experienceOptions);return await s.getWorkflowManager().getInitializationPromise(),"transaction"!==n.type&&this.customer&&await s.attachCustomerDetails({email:this.customer.emailAddress}),s}async initFromIntegrationProduct(A){if(""===A)throw new st("No integration product ID provided.");const t=ft.getShadowGraphqlClient();await t.resetStore();const e=await t.mutate({mutation:Nn,variables:{integrationProductId:A,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 st("Failed to create transaction!");const n=e.data.transactionCreate;if(!n.product)throw new st("Failed to create transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode;const i=wt.getMap("transactionOwnerIds")||new Map;i.set(n.id,n.transactionOwnerId),Ct(n.transactionOwnerId||""),wt.setMap("transactionOwnerIds",i),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(A,t=!1){if(""===A)throw new st("No transaction ID provided.");const e=ft.getShadowGraphqlClient();await e.resetStore();if(t)return await(async()=>{const n=(await e.query({query:Hn,variables:{id:A},errorPolicy:"all"})).data?.transactions[0];if(!n)throw new st("Failed to read transaction.");if(!n.product)throw new st("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 ot("State mutation is forbidden in read only mode!")},readOnly:t},this.initialized=!0})();const n=wt.getMap("transactionOwnerIds")||new Map,i=n.get(A);if(i){Ct(i);const n=(await e.query({query:Hn,variables:{id:A},errorPolicy:"all"})).data?.transactions[0];if(!n)throw new st("Failed to read transaction.");if(!n.product)throw new st("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:t},void(this.initialized=!0)}try{const i=(await e.mutate({mutation:Rn,variables:{id:A},errorPolicy:"all"})).data?.transactionClaim;if(!i)throw new st("Failed to read transaction.");if(!i.product)throw new st("Failed to load transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode,i.transactionOwnerId&&(n.set(i.id,i.transactionOwnerId),Ct(i.transactionOwnerId),wt.setMap("transactionOwnerIds",n)),this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:t},this.initialized=!0}catch{throw new st("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(A,t,e){if(!this.initialized||!this.experienceOptions)throw new st("Cannot launch experience: Not initialized.");const n=async A=>{for(const t in A.layouts){const e=A.layouts[t].elements.filter((A=>A.type===E.Illustration));for(let A=0;A<e.length;++A){const t=e[A];t.src&&t.svg&&(t.cachedObjectURL=await dA(t.svg))}const n=A.layouts[t].elements.filter((A=>A.type===E.Textbox));for(let A=0;A<n.length;++A){const t=n[A];t.fontData?.assetUrl&&U(t.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const A=await ga(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=A,this.experienceOptions.transaction.workflowState){const A=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(A.layouts).map((A=>A.layout)),await v(A),await n(A),this.experienceOptions.reloadedState=A}this.experienceOptions.previewService=e&&e(A),this.experienceOptions.renderableContextService=new In(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&this.experienceOptions.previewService?.initialize(this.experienceOptions.product.modelUrl,this.experienceOptions.renderableContextService);const t=new Wi(this,this.experienceOptions);return await t.getWorkflowManager().getInitializationPromise(),t}if(A){const i=ft.getShadowGraphqlClient().mutate({mutation:Pn,variables:{workflowId:A,id:this.experienceOptions.transaction.id}}),a=ga(A);if(await Promise.all([i,a]),this.experienceOptions.workflow=await a,t){const A=JSON.parse(t);this.experienceOptions.layouts=Object.values(A.layouts).map((A=>A.layout)),await v(A),await n(A),this.experienceOptions.reloadedState=A}else this.experienceOptions.layouts=la(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=e&&e(await a),this.experienceOptions.renderableContextService=new In(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&this.experienceOptions.previewService?.initialize(this.experienceOptions.product.modelUrl,this.experienceOptions.renderableContextService);const o=new Wi(this,this.experienceOptions);return await o.getWorkflowManager().getInitializationPromise(),o}throw new st("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new st("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new st("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function wa(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class da{constructor(){wa(this,"getProduct",void 0),wa(this,"getCommandContext",void 0),wa(this,"getAllLayoutData",void 0),wa(this,"getMetadata",void 0),wa(this,"getWorkflowMetadata",void 0),wa(this,"getStepStorage",void 0),wa(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(A){}addVariationRecord(A){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(A){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(A){}addPoller(A){}addConfirmCallback(A){}addCurrentVariationCallback(A){}addEditedCallback(A){}addElementsCallback(A){}addInformationResultCallback(A){}addInitCallback(A){}addMakingAdjustmentsCallback(A){}addMandatoryCallback(A){}addMetadataCallback(A){}addSelectionCallback(A){}addStepSpecificStorageCallback(A,t){}addStorageCallback(A){}addVariationRecordsCallback(A){}getCommandDispatcher(){return A=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getProfanities(){return[]}getRegionElements(A){return[]}getSerializedStep(A,t){}getStepSpecificServices(A){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(A){}markUpdateCompleted(A){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(A){}setCurrentVariationRecord(A){}setEditedStatus(A,t){}setInformationResults(A){}setMandatoryFulfilled(A,t){}async setSelectionsAndElements(A,t,e){}setVariationRecords(A){}toggleDesignConfirmed(){}updateMetadata(A,t){}async updateStorage(A,t){}}function Ea(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let ha;var Qa;(Qa=ha||(ha={})).SelectFrame="SelectFrame",Qa.SelectImage="SelectImage",Qa.Position="Position";class Ca extends yi{constructor(A,t){super(A,t),Ea(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(A){const t=this.manager.getRegionElements(this.step.stepName);return ii.selectVariant(this.step,A.getResource(),t,this.manager,(A=>this.setUpdateState(A)))}onFrameDataChanged(A){this.frameService&&this.frameService.onFrameDataChanged((t=>{t&&A(t)}))}selectImage(A){return ii.selectImage(this.step,A,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(A,t,e,n){return n&&n.length>1&&void 0===A?ha.SelectFrame:t||e||this.getImageData()?ha.Position:ha.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 ua=A=>{const t=kA(null),e=kA(void 0),[n,i]=NA(void 0),{addEvent:a,removeEvent:o,updateEvent:r,eventCache:s}=Jt(),[c,g]=NA(!1),[l,B]=NA(!1),{state:w,uiDispatcher:d}=qt(),E=RA((A=>{const t=A;d(new Xt({zoom:Math.max(.1,Math.min(t,w.maxZoom))}))}),[d,w.maxZoom]),h=RA((A=>{o(A),1===s.length&&(e.current=void 0),2===s.length&&i(void 0);"touch"===A.pointerType&&s.length>1&&s.length-1==1&&(B(!1),g(!1))}),[o,s.length]),Q=RA((A=>{a(A);"touch"===A.pointerType&&1===s.length&&(d(new Xt({selectedElement:void 0})),B(!0),g(!0))}),[a,s.length,d]),C=RA((A=>{r(A);const t=1===s.length&&"touch"!==s[0].pointerType,a=2===s.length&&"touch"===s[0].pointerType;if(c&&a){const[A,t]=s,e=Math.abs(A.clientX-t.clientX),a=n;a&&E(w.zoom-.0055*(a-e)),i(e)}if(l&&(t||a)&&A.isPrimary){const t=(e?.current?.x||A.screenX)-A.screenX,n=(e?.current?.y||A.screenY)-A.screenY;d(new Xt({selectedElement:void 0,xTranslation:w.xTranslation-t/w.zoom,yTranslation:w.yTranslation-n/w.zoom}))}A.isPrimary&&(e.current={x:A.screenX,y:A.screenY})}),[r,s,c,l,n,E,w.zoom,w.xTranslation,w.yTranslation,d]),u=RA((A=>{c&&E(w.zoom-.035*Math.sign(A.deltaY))}),[E,w.zoom,c]);UA((()=>{if(!t.current||0===s.length)return;const A=s[0].pointerId,e=t.current.hasPointerCapture(A);l&&!e&&t.current.setPointerCapture(A),!l&&e&&t.current.releasePointerCapture(A)}),[t,l,s]),be([" "],(()=>{B(!0),d(new Xt({selectedElement:void 0}))}),(()=>B(!1))),be(["Control"],(()=>g(!0)),(()=>g(!1)));const m=GA((()=>({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 bA("div",{ref:t,className:"transform-wrapper",onWheel:u,onPointerDown:Q,onPointerUp:h,onPointerCancel:h,onPointerLeave:h,onPointerMove:C,style:m,children:A.children})};export{Ba as SpiffCommerceClient,A as CommandContext,Et as spiffCoreConfiguration,Te as PromiseQueue,Oe as QueueablePromise,da as MockWorkflowManager,Ci as InformationMessageType,yi as StepHandle,Pi as TextStepHandle,Ca as FrameStepHandle,xi as BulkStepHandle,Ui as ShapeStepHandle,Si as IllustrationStepHandle,vi as MaterialStepHandle,Ni as ModelStepHandle,Ri as PictureStepHandle,Hi as QuestionStepHandle,_t as BulkPriceCalculationStrategy,Ii as Variant,At as OptionNotFoundError,tt as LayoutNotFoundError,et as AssetNotFoundError,nt as ResourceNotFoundError,it as MisconfigurationError,rt as ParseError,ot as UnhandledBehaviorError,Ht as assetService,Ki as designService,Ti as createDesign,kt as optionService,wt as persistenceService,ft as graphQlManager,ce as toast,qn as FrameService,Wn as getBoundedOffsets,ii as frameStepService,ri as modelStepService,oi as materialStepService,li as shapeStepService,gi as questionStepService,ei as digitalContentStepService,si as moduleStepService,ci as pictureStepService,hi as textStepService,ai as illustrationStepService,Zt as ProductCameraRig,ha as FrameStep,te as ConversionLocation,ne as ConversionDataType,ga as getWorkflow,t as AssetType,e 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,E as LayoutElementType,h as MoveCommand,Q as ResizeCommand,C as RotateCommand,u as SendBackwardsCommand,ae as StakeholderType,m as StepAspectType,D as StepType,p as TextChangeCommand,I as UnitOfMeasurement,f as dataUrlFromExternalUrl,y as findElement,M as frameDataCache,F as generate,Y as getAxisAlignedBoundingBox,x as generateSVGWithUnknownColors,S as getAttributesFromArrayBuffer,v as rehydrateSerializedLayout,N as getFrameData,R as getSvgElement,H as loadFontFromDataUrl,U as loadFontFromExternalUrl,P as determineCorrectFontSizeAndLines,G as patternImageDataCache,Dn as generateCommands,k as registerJSDOM,Pe as minZoom,vn as AdvancedEditor,ua as TransformWrapper,Sn as EditorCore,Lt as useLayouts,qt as useEditorState,ke as useEditorInteraction,be as useShortcutCombination,Kt as commandReducer,jt as getDefaultState,bt as CommandContextContext,Wt as AdvancedEditorStateProvider,Vt as AdvancedEditorContext,Xt as UICommand,Tt as EditorSubMenu,ge as ElementEventType,Be as KeyEvent,Jn as gatherVaryingStepAspects};
|
|
1157
|
+
`,ga=async A=>{const t=(await ft.getShadowGraphqlClient().query({query:ea,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:A}})).data.workflow;return t.steps.forEach((A=>{delete A.data.__typename})),t},la=(A,t)=>{const e=A.workflowState,n=e?JSON.parse(e):void 0;return n?Object.values(n.layouts).map((A=>A.layout)):t.panels.sort(((A,t)=>A.index-t.index)).map((A=>({id:F(),panelId:A.name,name:A.name,index:A.index,createdAt:new Date,updatedAt:new Date,transparentBackground:A.transparentBackground,height:A.height,width:A.width,previewRegion:A.previewRegion,useEditableArea:A.useEditableArea,editableArea:A.editableArea})))};class Ba{constructor(A){var t;ta(this,"options",void 0),ta(this,"initialized",void 0),ta(this,"experienceOptions",void 0),ta(this,"currencyCode",void 0),ta(this,"customer",void 0),ta(this,"updateTransactionState",(async A=>{try{return ft.getShadowGraphqlClient().mutate({...A,mutation:Un})}catch(A){throw console.error(A),new st("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=A,this.options.applicationKey&&(t=this.options.applicationKey,It=t)}getAssetManager(){return Ht}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}async authenticateBundleFromLocalStorage(A){const t=wt.getMap("bundleOwnerIds");if(t?.has(A)){const e=t.get(A);return mt(e),Promise.resolve({success:!0,stakeholderType:ae.Owner})}const e=wt.getMap("bundleCustomerIds");if(e?.has(A)){const t=e.get(A);if(t){if(await this.authenticateCustomerId(t)){const t=this.customer?.bundleStakeholders?.find((t=>t.bundle?.id===A));if(t)return Promise.resolve({success:!0,stakeholderType:t.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(A){const t=ft.getShadowGraphqlClient(),e=await t.query({query:na,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:A}});if(!e.data.transactions||0===e.data.transactions.length)throw new Error(`Transaction not found: ${A}`);const n=e.data.transactions[0],i=n.product?.partner?.id;if(!i)throw new Error(`Unable to read transaction: ${A}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const a=wt.getMap("transactionOwnerIds");if(a?.has(A)){const t=a.get(A);return Ct(t),Promise.resolve({success:!0,stakeholderType:ae.Owner})}const o=wt.getMap("transactionCustomerIds");if(o?.has(A)){const t=o.get(A);if(t){if(await this.authenticateCustomerId(t)){const t=this.customer?.bundleStakeholders?.find((t=>t.bundle?.transactions?.some((t=>t.id===A))))||this.customer?.stakeholders?.find((t=>t.transaction?.id===A));if(t)return Promise.resolve({success:!0,stakeholderType:t.type})}}}const r=(await t.query({query:ia,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(A){const t=wt.getMap("transactionCustomerIds");t?.has(A)&&(t.delete(A),wt.setMap("transactionCustomerIds",t))}getStakeholderTypeForTransaction(A){const t=this.customer?.stakeholders?.find((t=>t.transaction?.id===A));if(t)return t.type}async getOrCreateCustomer(A){this.customer=void 0;const t=ft.getShadowGraphqlClient(),e=(await t.query({query:aa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:A}})).data.customer;if(!e.id){const e=(await t.mutate({mutation:oa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:A}}})).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(A){const t=ft.getShadowGraphqlClient(),e=wt.getMap("customerTokens");if(!e?.has(A))return!1;const n=e.get(A);if(!n)return!1;const i=(await t.mutate({mutation:ra,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data?.customerAuthenticate;return!!i&&(pt(n),this.customer=i,!0)}async generateVerificationCode(A){await ft.getShadowGraphqlClient().mutate({mutation:sa,variables:{emailAddress:A}})}async verifyCode(A,t){const e=(await ft.getShadowGraphqlClient().mutate({mutation:ca,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:A,verificationCode:t}})).data?.customerVerifyCode;if(e?.loginToken){if(!e.partner?.id)throw new Error(`Unable to find customer: ${A}`);const t=wt.getMap("customerTokens")||new Map;return t.set(e.id,e.loginToken),wt.setMap("customerTokens",t),pt(e.loginToken),this.customer={...e,loginToken:void 0},!0}return!1}async getNewBundle(){const A=(await ft.getShadowGraphqlClient().mutate({mutation:qi})).data?.bundleCreate;if(!A)throw new Error("Unable to create bundle");mt(A.bundleOwnerId);const t=wt.getMap("bundleOwnerIds")||new Map;return t.set(A.id,A.bundleOwnerId),wt.setMap("bundleOwnerIds",t),new Aa(this,A.id)}async getExistingBundle(A){const t=await ft.getShadowGraphqlClient().query({query:Xi,variables:{id:A}});if(!t.data?.bundles||0===t.data?.bundles.length||!t.data?.bundles[0])throw new Error(`Unable to find bundle: ${A}`);const e=t.data?.bundles[0],n=wt.getMap("bundleOwnerIds");return n?.has(e.id)&&mt(n.get(e.id)),new Aa(this,e.id)}async getWorkflowExperience(A,t,e,n){if(!n)return await this.getWorkflowExperienceDeprecated(A,t,e);const i=async A=>{for(const t in A.layouts){const e=A.layouts[t].elements.filter((A=>A.type===E.Illustration));for(let A=0;A<e.length;++A){const t=e[A];t.src&&t.svg&&(t.cachedObjectURL=await dA(t.svg))}const n=A.layouts[t].elements.filter((A=>A.type===E.Textbox));for(let A=0;A<n.length;++A){const t=n[A];t.fontData?.assetUrl&&U(t.fontData.assetUrl)}}},{transaction:a,workflow:o,readOnly:r}=await(async()=>{const A=ft.getShadowGraphqlClient();if(await A.resetStore(),"transaction"===n.type){const{transactionId:t,readOnly:e}=n,i=await A.query({query:Hn,variables:{id:t},errorPolicy:"all"});if(!i.data?.transactions||0===i.data.transactions.length)throw new st("Existing transaction not found.");const a=i.data?.transactions[0];if(!a.workflowId)throw new st("Existing transaction has no workflow ID.");const o=await ga(a.workflowId);if(!a.product)throw new st("Failed to load transaction, product not available.");return{transaction:a,workflow:o,readOnly:e}}if("integration"===n.type||"external"===n.type){const t=async()=>{const t="integration"===n.type?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},e=await A.mutate({mutation:Nn,variables:{...t,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 st("Failed to create transaction!");const i=e.data.transactionCreate;if(!i.product)throw new st("Failed to create transaction, product not available.");return i},e=ga(n.workflowId),[i,a]=await Promise.all([t(),e]);return{transaction:i,workflow:a}}throw new st("No workflow ID provided.")})();if(this.currencyCode=a.product.partner?.currencyCode,this.experienceOptions={product:a.product,transaction:a,layouts:[],stateMutationFunc:r?async()=>{throw new ot("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:r,workflow:o},"transaction"===n.type&&a.workflowState){const A=JSON.parse(a.workflowState);this.experienceOptions.layouts=Object.values(A.layouts).map((A=>A.layout)),await v(A),await i(A),this.experienceOptions.reloadedState=A}else if(!r&&n.workflowState){const A=JSON.parse(n.workflowState);this.experienceOptions.layouts=Object.values(A.layouts).map((A=>A.layout)),await v(A),await i(A),this.experienceOptions.reloadedState=A}else this.experienceOptions.layouts=la(this.experienceOptions.transaction,this.experienceOptions.workflow);if(this.experienceOptions.previewService=e&&e(o),this.experienceOptions.renderableContextService=new In(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&this.experienceOptions.previewService?.initialize(this.experienceOptions.product.modelUrl,this.experienceOptions.renderableContextService),"transaction"!==n.type){const A=wt.getMap("transactionOwnerIds")||new Map;A.set(a.id,a.transactionOwnerId),Ct(a.transactionOwnerId||""),wt.setMap("transactionOwnerIds",A)}else{const A=(wt.getMap("transactionOwnerIds")||new Map).get(a.id);A&&Ct(A)}this.initialized=!0;const s=new Wi(this,this.experienceOptions);return await s.getWorkflowManager().getInitializationPromise(),"transaction"!==n.type&&this.customer&&await s.attachCustomerDetails({email:this.customer.emailAddress}),s}async initFromIntegrationProduct(A){if(""===A)throw new st("No integration product ID provided.");const t=ft.getShadowGraphqlClient();await t.resetStore();const e=await t.mutate({mutation:Nn,variables:{integrationProductId:A,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 st("Failed to create transaction!");const n=e.data.transactionCreate;if(!n.product)throw new st("Failed to create transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode;const i=wt.getMap("transactionOwnerIds")||new Map;i.set(n.id,n.transactionOwnerId),Ct(n.transactionOwnerId||""),wt.setMap("transactionOwnerIds",i),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(A,t=!1){if(""===A)throw new st("No transaction ID provided.");const e=ft.getShadowGraphqlClient();await e.resetStore();if(t)return await(async()=>{const n=(await e.query({query:Hn,variables:{id:A},errorPolicy:"all"})).data?.transactions[0];if(!n)throw new st("Failed to read transaction.");if(!n.product)throw new st("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 ot("State mutation is forbidden in read only mode!")},readOnly:t},this.initialized=!0})();const n=wt.getMap("transactionOwnerIds")||new Map,i=n.get(A);if(i){Ct(i);const n=(await e.query({query:Hn,variables:{id:A},errorPolicy:"all"})).data?.transactions[0];if(!n)throw new st("Failed to read transaction.");if(!n.product)throw new st("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:t},void(this.initialized=!0)}try{const i=(await e.mutate({mutation:Rn,variables:{id:A},errorPolicy:"all"})).data?.transactionClaim;if(!i)throw new st("Failed to read transaction.");if(!i.product)throw new st("Failed to load transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode,i.transactionOwnerId&&(n.set(i.id,i.transactionOwnerId),Ct(i.transactionOwnerId),wt.setMap("transactionOwnerIds",n)),this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:t},this.initialized=!0}catch{throw new st("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(A,t,e){if(!this.initialized||!this.experienceOptions)throw new st("Cannot launch experience: Not initialized.");const n=async A=>{for(const t in A.layouts){const e=A.layouts[t].elements.filter((A=>A.type===E.Illustration));for(let A=0;A<e.length;++A){const t=e[A];t.src&&t.svg&&(t.cachedObjectURL=await dA(t.svg))}const n=A.layouts[t].elements.filter((A=>A.type===E.Textbox));for(let A=0;A<n.length;++A){const t=n[A];t.fontData?.assetUrl&&U(t.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const A=await ga(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=A,this.experienceOptions.transaction.workflowState){const A=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(A.layouts).map((A=>A.layout)),await v(A),await n(A),this.experienceOptions.reloadedState=A}this.experienceOptions.previewService=e&&e(A),this.experienceOptions.renderableContextService=new In(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&this.experienceOptions.previewService?.initialize(this.experienceOptions.product.modelUrl,this.experienceOptions.renderableContextService);const t=new Wi(this,this.experienceOptions);return await t.getWorkflowManager().getInitializationPromise(),t}if(A){const i=ft.getShadowGraphqlClient().mutate({mutation:Pn,variables:{workflowId:A,id:this.experienceOptions.transaction.id}}),a=ga(A);if(await Promise.all([i,a]),this.experienceOptions.workflow=await a,t){const A=JSON.parse(t);this.experienceOptions.layouts=Object.values(A.layouts).map((A=>A.layout)),await v(A),await n(A),this.experienceOptions.reloadedState=A}else this.experienceOptions.layouts=la(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=e&&e(await a),this.experienceOptions.renderableContextService=new In(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&this.experienceOptions.previewService?.initialize(this.experienceOptions.product.modelUrl,this.experienceOptions.renderableContextService);const o=new Wi(this,this.experienceOptions);return await o.getWorkflowManager().getInitializationPromise(),o}throw new st("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new st("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new st("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function wa(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class da{constructor(){wa(this,"getProduct",void 0),wa(this,"getCommandContext",void 0),wa(this,"getAllLayoutData",void 0),wa(this,"getMetadata",void 0),wa(this,"getWorkflowMetadata",void 0),wa(this,"getStepStorage",void 0),wa(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(A){}addVariationRecord(A){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(A){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(A){}addPoller(A){}addConfirmCallback(A){}addCurrentVariationCallback(A){}addEditedCallback(A){}addElementsCallback(A){}addInformationResultCallback(A){}addInitCallback(A){}addMakingAdjustmentsCallback(A){}addMandatoryCallback(A){}addMetadataCallback(A){}addSelectionCallback(A){}addStepSpecificStorageCallback(A,t){}addStorageCallback(A){}addVariationRecordsCallback(A){}getCommandDispatcher(){return A=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getProfanities(){return[]}getRegionElements(A){return[]}getSerializedStep(A,t){}getStepSpecificServices(A){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(A){}markUpdateCompleted(A){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(A){}setCurrentVariationRecord(A){}setEditedStatus(A,t){}setInformationResults(A){}setMandatoryFulfilled(A,t){}async setSelectionsAndElements(A,t,e){}setVariationRecords(A){}toggleDesignConfirmed(){}updateMetadata(A,t){}async updateStorage(A,t){}}function Ea(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let ha;var Qa;(Qa=ha||(ha={})).SelectFrame="SelectFrame",Qa.SelectImage="SelectImage",Qa.Position="Position";class Ca extends yi{constructor(A,t){super(A,t),Ea(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(A){const t=this.manager.getRegionElements(this.step.stepName);return ii.selectVariant(this.step,A.getResource(),t,this.manager,(A=>this.setUpdateState(A)))}onFrameDataChanged(A){this.frameService&&this.frameService.onFrameDataChanged((t=>{t&&A(t)}))}selectImage(A){return ii.selectImage(this.step,A,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(A,t,e,n){return n&&n.length>1&&void 0===A?ha.SelectFrame:t||e||this.getImageData()?ha.Position:ha.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 ua=A=>{const t=kA(null),e=kA(void 0),[n,i]=NA(void 0),{addEvent:a,removeEvent:o,updateEvent:r,eventCache:s}=Jt(),[c,g]=NA(!1),[l,B]=NA(!1),{state:w,uiDispatcher:d}=qt(),E=RA((A=>{const t=A;d(new Xt({zoom:Math.max(.1,Math.min(t,w.maxZoom))}))}),[d,w.maxZoom]),h=RA((A=>{o(A),1===s.length&&(e.current=void 0),2===s.length&&i(void 0);"touch"===A.pointerType&&s.length>1&&s.length-1==1&&(B(!1),g(!1))}),[o,s.length]),Q=RA((A=>{a(A);"touch"===A.pointerType&&1===s.length&&(d(new Xt({selectedElement:void 0})),B(!0),g(!0))}),[a,s.length,d]),C=RA((A=>{r(A);const t=1===s.length&&"touch"!==s[0].pointerType,a=2===s.length&&"touch"===s[0].pointerType;if(c&&a){const[A,t]=s,e=Math.abs(A.clientX-t.clientX),a=n;a&&E(w.zoom-.0055*(a-e)),i(e)}if(l&&(t||a)&&A.isPrimary){const t=(e?.current?.x||A.screenX)-A.screenX,n=(e?.current?.y||A.screenY)-A.screenY;d(new Xt({selectedElement:void 0,xTranslation:w.xTranslation-t/w.zoom,yTranslation:w.yTranslation-n/w.zoom}))}A.isPrimary&&(e.current={x:A.screenX,y:A.screenY})}),[r,s,c,l,n,E,w.zoom,w.xTranslation,w.yTranslation,d]),u=RA((A=>{c&&E(w.zoom-.035*Math.sign(A.deltaY))}),[E,w.zoom,c]);UA((()=>{if(!t.current||0===s.length)return;const A=s[0].pointerId,e=t.current.hasPointerCapture(A);l&&!e&&t.current.setPointerCapture(A),!l&&e&&t.current.releasePointerCapture(A)}),[t,l,s]),be([" "],(()=>{B(!0),d(new Xt({selectedElement:void 0}))}),(()=>B(!1))),be(["Control"],(()=>g(!0)),(()=>g(!1)));const m=GA((()=>({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 bA("div",{ref:t,className:"transform-wrapper",onWheel:u,onPointerDown:Q,onPointerUp:h,onPointerCancel:h,onPointerLeave:h,onPointerMove:C,style:m,children:A.children})};export{Ba as SpiffCommerceClient,A as CommandContext,Et as spiffCoreConfiguration,Te as PromiseQueue,Oe as QueueablePromise,da as MockWorkflowManager,Ci as InformationMessageType,yi as StepHandle,Pi as TextStepHandle,Ca as FrameStepHandle,xi as BulkStepHandle,Ui as ShapeStepHandle,Si as IllustrationStepHandle,vi as MaterialStepHandle,Ni as ModelStepHandle,Ri as PictureStepHandle,Hi as QuestionStepHandle,_t as BulkPriceCalculationStrategy,Ii as Variant,At as OptionNotFoundError,tt as LayoutNotFoundError,et as AssetNotFoundError,nt as ResourceNotFoundError,it as MisconfigurationError,rt as ParseError,ot as UnhandledBehaviorError,Ht as assetService,Ki as designService,Ti as createDesign,kt as optionService,wt as persistenceService,ft as graphQlManager,ce as toast,qn as FrameService,Wn as getBoundedOffsets,ii as frameStepService,ri as modelStepService,oi as materialStepService,li as shapeStepService,gi as questionStepService,ei as digitalContentStepService,si as moduleStepService,ci as pictureStepService,hi as textStepService,ai as illustrationStepService,Zt as ProductCameraRig,ha as FrameStep,te as ConversionLocation,ne as ConversionDataType,ga as getWorkflow,t as AssetType,e 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,E as LayoutElementType,h as MoveCommand,Q as ResizeCommand,C as RotateCommand,u as SendBackwardsCommand,ae as StakeholderType,m as StepAspectType,D as StepType,p as TextChangeCommand,I as UnitOfMeasurement,f as dataUrlFromExternalUrl,y as findElement,M as frameDataCache,F as generate,Y as getAxisAlignedBoundingBox,x as generateSVGWithUnknownColors,S as getAttributesFromArrayBuffer,v as rehydrateSerializedLayout,N as getFrameData,R as getSvgElement,H as loadFontFromDataUrl,U as loadFontFromExternalUrl,P as determineCorrectFontSizeAndLines,G as patternImageDataCache,Dn as generateCommands,k as registerJSDOM,Pe as minZoom,vn as AdvancedEditor,ua as TransformWrapper,Sn as EditorCore,Lt as useLayouts,qt as useEditorState,ke as useEditorInteraction,be as useShortcutCombination,Kt as commandReducer,jt as getDefaultState,bt as CommandContextContext,Wt as AdvancedEditorStateProvider,Vt as AdvancedEditorContext,Xt as UICommand,Tt as EditorSubMenu,ge as ElementEventType,Be as KeyEvent,Jn as gatherVaryingStepAspects};
|
|
1142
1158
|
//# sourceMappingURL=module.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -985,6 +985,7 @@ export interface Customer {
|
|
|
985
985
|
loginToken?: string;
|
|
986
986
|
partner?: Partner;
|
|
987
987
|
stakeholders?: Stakeholder[];
|
|
988
|
+
bundleStakeholders?: BundleStakeholder[];
|
|
988
989
|
}
|
|
989
990
|
export interface CustomerDetailsInput {
|
|
990
991
|
emailAddress: string;
|
|
@@ -1004,6 +1005,19 @@ export interface Stakeholder {
|
|
|
1004
1005
|
transaction?: Transaction;
|
|
1005
1006
|
customer?: Customer;
|
|
1006
1007
|
}
|
|
1008
|
+
interface Bundle {
|
|
1009
|
+
id?: string;
|
|
1010
|
+
bundleOwnerId?: string;
|
|
1011
|
+
bundleStakeholders?: BundleStakeholder[];
|
|
1012
|
+
partner?: Partner;
|
|
1013
|
+
transactions?: Transaction[];
|
|
1014
|
+
}
|
|
1015
|
+
interface BundleStakeholder {
|
|
1016
|
+
id: string;
|
|
1017
|
+
bundle?: Bundle;
|
|
1018
|
+
customer?: Customer;
|
|
1019
|
+
type?: StakeholderType;
|
|
1020
|
+
}
|
|
1007
1021
|
interface StorageService {
|
|
1008
1022
|
/**
|
|
1009
1023
|
* Get a value.
|
|
@@ -1812,7 +1826,7 @@ export interface WorkflowExperience {
|
|
|
1812
1826
|
/**
|
|
1813
1827
|
* A bundle serves as a container for a set of workflow experience.
|
|
1814
1828
|
*/
|
|
1815
|
-
interface
|
|
1829
|
+
interface _Bundle1 {
|
|
1816
1830
|
/**
|
|
1817
1831
|
* @returns The client that this bundle is associated with.
|
|
1818
1832
|
*/
|
|
@@ -1910,6 +1924,15 @@ export class SpiffCommerceClient {
|
|
|
1910
1924
|
*/
|
|
1911
1925
|
getAssetManager(): AssetManager;
|
|
1912
1926
|
getCurrencyCode(): string;
|
|
1927
|
+
/**
|
|
1928
|
+
* Attempts to load persisted authentication information from local storage, and authenticate with the Spiff Commerce API.
|
|
1929
|
+
* @param bundleId The ID of the bundle you intend to load.
|
|
1930
|
+
* @returns An object containing the success status of the authentication attempt, and the type of stakeholder when successful.
|
|
1931
|
+
*/
|
|
1932
|
+
authenticateBundleFromLocalStorage(bundleId: string): Promise<{
|
|
1933
|
+
stakeholderType?: StakeholderType;
|
|
1934
|
+
success: boolean;
|
|
1935
|
+
}>;
|
|
1913
1936
|
/**
|
|
1914
1937
|
* Attempts to load persisted authentication information from local storage, and authenticate with the Spiff Commerce API.
|
|
1915
1938
|
* @param transactionId The ID of the transaction that the user is attempting to load.
|
|
@@ -1950,12 +1973,12 @@ export class SpiffCommerceClient {
|
|
|
1950
1973
|
* @param configurationId The id of the configuration to be used for the bundle.
|
|
1951
1974
|
* @returns A bundle to be used for grouping and operating on large amounts of workflow experiences.
|
|
1952
1975
|
*/
|
|
1953
|
-
getNewBundle(): Promise<
|
|
1976
|
+
getNewBundle(): Promise<_Bundle1>;
|
|
1954
1977
|
/**
|
|
1955
1978
|
* Retrieves an existing bundle from the API, by id.
|
|
1956
1979
|
* @returns A bundle to be used for grouping and operating on large amounts of workflow experiences.
|
|
1957
1980
|
*/
|
|
1958
|
-
getExistingBundle(bundleId: string): Promise<
|
|
1981
|
+
getExistingBundle(bundleId: string): Promise<_Bundle1>;
|
|
1959
1982
|
/**
|
|
1960
1983
|
* Creates a new instance of WorkflowExperience. A high level wrapper for workflows.
|
|
1961
1984
|
* @param workflowId The id of the workflow to be run. Deprecated: Provide options instead.
|