@spiffcommerce/core 14.7.2-beta.0 → 14.7.3-alpha.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/module.js CHANGED
@@ -1,4 +1,4 @@
1
- import{CommandContext as t,AssetType as e,BringForwardCommand as A,BringToFrontCommand as n,BringToBackCommand as a,CanvasCommand as i,CreateElementCommand as o,CreateLayoutCommand as r,DeleteElementCommand as s,FontAlignmentCommand as c,FontColorCommand as g,FontSizeCommand as l,FontSourceCommand as B,GroupCommand as w,LayoutElementFactory as d,LayoutElementType as h,MoveCommand as E,ResizeCommand as u,RotateCommand as C,SendBackwardsCommand as Q,StepAspectType as p,StepType as m,TextChangeCommand as D,UnitOfMeasurement as f,dataUrlFromExternalUrl as I,findElement as y,frameDataCache as M,generate as F,getAxisAlignedBoundingBox as Y,generateSVGWithUnknownColors as S,getAttributesFromArrayBuffer as v,rehydrateSerializedLayout as x,getFrameData as N,getSvgElement as P,loadFontFromDataUrl as R,loadFontFromExternalUrl as H,determineCorrectFontSizeAndLines as U,patternImageDataCache as b,registerJSDOM as k,isCloseToValue as G,mmPerPixel as J,cmPerPixel as L,getElementVertices as T,rotateAroundPoint as O,ScaleAxis as z,findAngle as j,currentDirection as K,sortElementsByLayersWithIndex as V,LayoutRenderingPurpose as W,TextAlgorithm as X,toBase64 as q,getPatternImageData as Z,getVariant as $,generateFrameSVG as _,calculateOffsets as tt,UpdateFramePattern as et,getDefaultVariant as At,fetchAsString as nt,domParser as at,sanitizeSvgTree as it,traverse as ot,xmlSerializer as rt,fetchAsArrayBuffer as st,arrayBufferToDataUrl as ct,loadFontFaceSet as gt,applyTextTransformations as lt,createElementNS as Bt,createElement as wt,svgObjectURL as dt,UpdateWorkflowStateCommand as ht,generateDefaultRectangleFrameSvg as Et,GetSVGDimensions as ut,modifySVGWithElementProperties as Ct,IllustrationColorCommand as Qt,IllustrationCacheCommand as pt,getFontMetrics as mt,FontImageFillCommand as Dt,AspectType as ft}from"@spiffcommerce/papyrus";import{gql as It,createHttpLink as yt,InMemoryCache as Mt,ApolloClient as Ft,from as Yt}from"@apollo/client";import{setContext as St}from"@apollo/client/link/context";import{onError as vt}from"@apollo/client/link/error";import{fetch as xt}from"cross-fetch";import{createContext as Nt,useState as Pt,useCallback as Rt,useContext as Ht,useEffect as Ut,useReducer as bt,useMemo as kt,useRef as Gt}from"react";import{jsx as Jt,jsxs as Lt,Fragment as Tt}from"react/jsx-runtime";import Ot from"lodash.isequal";import zt from"lodash.clonedeep";import{Pith as jt}from"pith";import Kt from"react-dom/server";import{toString as Vt}from"qrcode";import Wt from"svg-path-bbox";import Xt from"lodash.debounce";import{split as qt}from"unicode-default-word-boundary";import{gql as Zt}from"@apollo/client/core";function $t(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class _t extends Error{constructor(t){super(t),this.name=this.constructor.name}}class te extends _t{constructor(t){super(`ConfigurationError - ${t}`)}}class ee extends te{constructor(t){super(`Option not Configured: ${t.stepTitle}`),$t(this,"optionId",void 0),this.optionId=t?.optionId||"N/A"}}class Ae extends te{constructor(t){super(`Panel not Found: ${t.panelId}`),$t(this,"panelId",void 0),this.panelId=t?.panelId||"N/A"}}class ne extends te{constructor(t){super(`Asset not found for variant: ${t.name}`),$t(this,"variant",void 0),this.variant=t}}class ae extends te{constructor(t){super(`Resource not found for asset: ${t.name}`),$t(this,"asset",void 0),this.asset=t}}class ie extends te{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),$t(this,"step",void 0),this.step=t}}class oe extends _t{constructor(t){super(`ImplementationError - ${t}`)}}class re extends oe{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class se extends oe{constructor(t){super(`Parsing Error: ${t}`)}}class ce extends oe{constructor(t){super(`Client Error: ${t}`)}}class ge extends oe{constructor(t){super(`Resource Generation Failed: ${t}`)}}function le(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Be{get(t){return localStorage.getItem(t)||void 0}set(t,e){localStorage.setItem(t,e)}remove(t){localStorage.removeItem(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}class we{constructor(){le(this,"storage",new Map)}get(t){return this.storage.get(t)||void 0}set(t,e){this.storage.set(t,e)}remove(t){this.storage.delete(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}const de=(()=>{try{return localStorage?new Be:new we}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new we}})();function he(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const Ee=new class{constructor(){he(this,"defaultServerUrl","https://api.spiff.com.au"),he(this,"defaultServicesApiUrl","https://services.spiff.com.au"),he(this,"defaultHubUrl","https://hub.spiff.com.au"),he(this,"serverUrl",void 0),he(this,"servicesApiUrl",void 0),he(this,"hubUrl",void 0),he(this,"serverUrlCallbacks",void 0),this.serverUrl=this.defaultServerUrl,this.servicesApiUrl=this.defaultServicesApiUrl,this.hubUrl=this.defaultHubUrl,this.serverUrlCallbacks=[]}getServerUrl(){return this.serverUrl}getServicesApiUrl(){return this.servicesApiUrl}getHubUrl(){return this.hubUrl}setServerUrl(t){this.serverUrl=t,this.serverUrlCallbacks.forEach((t=>t()))}setServicesApiUrl(t){this.servicesApiUrl=t}setHubUrl(t){this.hubUrl=t}addServerUrlCallback(t){this.serverUrlCallbacks.push(t)}};function ue(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let Ce;const Qe=t=>{Ce=t};let pe;const me=t=>{pe=t};let De;const fe=t=>{De=t};let Ie;const ye=new class{constructor(){ue(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),Ee.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const t=yt({uri:`${Ee.getServerUrl()}/graphql`,fetch:xt}),e=St((async(t,e)=>{const{headers:A}=e,n=A||{},a=await(async()=>{const t={applicationKey:Ie,bundleOwnerId:pe,customerToken:De,transactionOwnerId:Ce};return"undefined"!=typeof window&&(window.location.href.includes("/workflows/product/")||window.location.href.includes("hub=true"))?{...await new Promise((t=>{const e=Ee.getHubUrl(),A=n=>{n.origin===e&&(window.removeEventListener("message",A),t(n.data))};window.parent!==window&&(window.addEventListener("message",A,!1),window.parent.postMessage("ready",e))})),...t}:t})(),i=e.bearer??a.bearer,o=e.partnerId??a.partnerId,r=e.activeIntegration??a.activeIntegration,s=e.transactionOwnerId??a.transactionOwnerId,c=e.customerToken??a.customerToken,g=e.applicationKey??a.applicationKey,l=e.bundleOwnerId??a.bundleOwnerId;return i&&(n.Authorization=`Bearer ${i}`),o&&(n.partnerId=o),r&&(n.activeIntegration=r),s&&(n.transactionOwnerId=s),c&&(n.customerToken=c),g&&(n["X-Application-Key"]=g),l&&(n.bundleOwnerId=l),{headers:n}})),A=vt((({operation:t,graphQLErrors:e,networkError:A})=>{(e||[]).forEach((({message:e,locations:A,path:n})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+t.operationName),console.log("Query:"+JSON.stringify(t.query)),console.log(`Message: ${e}, Location: ${JSON.stringify(A,null,2)}, Path: ${n}`),console.log("Variables:"+JSON.stringify(t.variables))})),A&&console.log("GraphQL Network error")}));const n=new Mt({addTypename:!1,typePolicies:{Transaction:{fields:{bulkEmailAddress:{read:(t=null)=>t,merge:(t,e)=>e||t||null},transactionOwnerId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},customLogoLink:{read:(t=null)=>t,merge:(t,e)=>e||t||null},workflowFooterLogoLink:{read:(t=null)=>t,merge:(t,e)=>e||t||null},workflowState:{read:(t=null)=>t,merge:(t,e)=>e||t||null},bulkSourceUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalDesignProductId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalDesignProductVariantId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalCartProductId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalCartProductVariantId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},lastSyncedAt:{read:(t=null)=>t,merge:(t,e)=>e||t||null},lineItem:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}},WorkflowProduct:{fields:{isPresent:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}},Product:{fields:{imageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},overlayImageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},preloadImageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},weight:{read:(t=null)=>t,merge:(t,e)=>e||t||null},conversionConfiguration:{read:(t=null)=>t,merge:(t,e)=>e||t||null},bulkConfiguration:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}}}});return new Ft({link:Yt([A,e,t]),cache:n,name:"Core"})}};function Me(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const Fe=It`
1
+ import{CommandContext as t,AssetType as e,BringForwardCommand as A,BringToFrontCommand as n,BringToBackCommand as a,CanvasCommand as i,CreateElementCommand as o,CreateLayoutCommand as r,DeleteElementCommand as s,FontAlignmentCommand as c,FontColorCommand as g,FontSizeCommand as l,FontSourceCommand as B,GroupCommand as w,LayoutElementFactory as d,LayoutElementType as h,MoveCommand as E,ResizeCommand as u,RotateCommand as C,SendBackwardsCommand as Q,StepAspectType as p,StepType as m,TextChangeCommand as D,UnitOfMeasurement as f,dataUrlFromExternalUrl as I,findElement as y,frameDataCache as M,generate as F,getAxisAlignedBoundingBox as Y,generateSVGWithUnknownColors as S,getAttributesFromArrayBuffer as v,rehydrateSerializedLayout as x,getFrameData as N,getSvgElement as P,loadFontFromDataUrl as R,loadFontFromExternalUrl as H,determineCorrectFontSizeAndLines as U,patternImageDataCache as b,registerJSDOM as k,isCloseToValue as G,mmPerPixel as J,cmPerPixel as L,getElementVertices as T,rotateAroundPoint as O,ScaleAxis as z,findAngle as j,currentDirection as K,sortElementsByLayersWithIndex as V,LayoutRenderingPurpose as W,TextAlgorithm as X,toBase64 as q,getPatternImageData as Z,getVariant as $,generateFrameSVG as _,calculateOffsets as tt,UpdateFramePattern as et,getDefaultVariant as At,fetchAsString as nt,domParser as at,sanitizeSvgTree as it,traverse as ot,xmlSerializer as rt,fetchAsArrayBuffer as st,arrayBufferToDataUrl as ct,loadFontFaceSet as gt,applyTextTransformations as lt,createElementNS as Bt,createElement as wt,svgObjectURL as dt,UpdateWorkflowStateCommand as ht,generateDefaultRectangleFrameSvg as Et,GetSVGDimensions as ut,modifySVGWithElementProperties as Ct,IllustrationColorCommand as Qt,IllustrationCacheCommand as pt,getFontMetrics as mt,FontImageFillCommand as Dt,AspectType as ft}from"@spiffcommerce/papyrus";import{gql as It,createHttpLink as yt,InMemoryCache as Mt,ApolloClient as Ft,from as Yt}from"@apollo/client";import{setContext as St}from"@apollo/client/link/context";import{onError as vt}from"@apollo/client/link/error";import{fetch as xt}from"cross-fetch";import{createContext as Nt,useState as Pt,useCallback as Rt,useContext as Ht,useEffect as Ut,useReducer as bt,useMemo as kt,useRef as Gt}from"react";import{jsx as Jt,jsxs as Lt,Fragment as Tt}from"react/jsx-runtime";import Ot from"lodash.isequal";import zt from"lodash.clonedeep";import{Pith as jt}from"pith";import Kt from"react-dom/server";import{toString as Vt}from"qrcode";import Wt from"svg-path-bbox";import Xt from"lodash.debounce";import{split as qt}from"unicode-default-word-boundary";import{gql as Zt}from"@apollo/client/core";function $t(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class _t extends Error{constructor(t){super(t),this.name=this.constructor.name}}class te extends _t{constructor(t){super(`ConfigurationError - ${t}`)}}class ee extends te{constructor(t){super(`Option not Configured: ${t.stepTitle}`),$t(this,"optionId",void 0),this.optionId=t?.optionId||"N/A"}}class Ae extends te{constructor(t){super(`Panel not Found: ${t.panelId}`),$t(this,"panelId",void 0),this.panelId=t?.panelId||"N/A"}}class ne extends te{constructor(t){super(`Asset not found for variant: ${t.name}`),$t(this,"variant",void 0),this.variant=t}}class ae extends te{constructor(t){super(`Resource not found for asset: ${t.name}`),$t(this,"asset",void 0),this.asset=t}}class ie extends te{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),$t(this,"step",void 0),this.step=t}}class oe extends _t{constructor(t){super(`ImplementationError - ${t}`)}}class re extends oe{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class se extends oe{constructor(t){super(`Parsing Error: ${t}`)}}class ce extends oe{constructor(t){super(`Client Error: ${t}`)}}class ge extends oe{constructor(t){super(`Resource Generation Failed: ${t}`)}}function le(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Be{get(t){return localStorage.getItem(t)||void 0}set(t,e){localStorage.setItem(t,e)}remove(t){localStorage.removeItem(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}class we{constructor(){le(this,"storage",new Map)}get(t){return this.storage.get(t)||void 0}set(t,e){this.storage.set(t,e)}remove(t){this.storage.delete(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}const de=(()=>{try{return localStorage?new Be:new we}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new we}})();function he(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const Ee=new class{constructor(){he(this,"defaultServerUrl","https://api.spiff.com.au"),he(this,"defaultServicesApiUrl","https://services.spiff.com.au"),he(this,"defaultHubUrl","https://hub.spiff.com.au"),he(this,"serverUrl",void 0),he(this,"servicesApiUrl",void 0),he(this,"hubUrl",void 0),he(this,"serverUrlCallbacks",void 0),this.serverUrl=this.defaultServerUrl,this.servicesApiUrl=this.defaultServicesApiUrl,this.hubUrl=this.defaultHubUrl,this.serverUrlCallbacks=[]}getServerUrl(){return this.serverUrl}getServicesApiUrl(){return this.servicesApiUrl}getHubUrl(){return this.hubUrl}setServerUrl(t){this.serverUrl=t,this.serverUrlCallbacks.forEach((t=>t()))}setServicesApiUrl(t){this.servicesApiUrl=t}setHubUrl(t){this.hubUrl=t}addServerUrlCallback(t){this.serverUrlCallbacks.push(t)}};function ue(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let Ce;const Qe=t=>{Ce=t};let pe;const me=t=>{pe=t};let De;const fe=t=>{De=t};let Ie;const ye=new class{constructor(){ue(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),Ee.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const t=yt({uri:`${Ee.getServerUrl()}/graphql`,fetch:xt}),e=St((async(t,e)=>{const{headers:A}=e,n=A||{},a=await(async()=>{const t={applicationKey:Ie,bundleOwnerId:pe,customerToken:De,transactionOwnerId:Ce};return"undefined"!=typeof window&&(window.location.href.includes("/workflows/product/")||window.location.href.includes("hub=true"))?{...await new Promise((t=>{const e=Ee.getHubUrl(),A=n=>{n.origin===e&&(window.removeEventListener("message",A),t(n.data))};window.parent!==window&&(window.addEventListener("message",A,!1),window.parent.postMessage("ready",e))})),...t}:t})(),i=e.bearer??a.bearer,o=e.partnerId??a.partnerId,r=e.activeIntegration??a.activeIntegration,s=e.transactionOwnerId??a.transactionOwnerId,c=e.customerToken??a.customerToken,g=e.applicationKey??a.applicationKey,l=e.bundleOwnerId??a.bundleOwnerId;return i&&(n.Authorization=`Bearer ${i}`),o&&(n.partnerId=o),r&&(n.activeIntegration=r),s&&(n.transactionOwnerId=s),c&&(n.customerToken=c),g&&(n["X-Application-Key"]=g),l&&(n.bundleOwnerId=l),{headers:n}})),A=vt((({operation:t,graphQLErrors:e,networkError:A})=>{(e||[]).forEach((({message:e,locations:A,path:n})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+t.operationName),console.log("Query:"+JSON.stringify(t.query)),console.log(`Message: ${e}, Location: ${JSON.stringify(A,null,2)}, Path: ${n}`),console.log("Variables:"+JSON.stringify(t.variables))})),A&&console.log("GraphQL Network error")}));const n=new Mt({typePolicies:{Transaction:{fields:{bulkEmailAddress:{read:(t=null)=>t,merge:(t,e)=>e||t||null},transactionOwnerId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},customLogoLink:{read:(t=null)=>t,merge:(t,e)=>e||t||null},workflowFooterLogoLink:{read:(t=null)=>t,merge:(t,e)=>e||t||null},workflowState:{read:(t=null)=>t,merge:(t,e)=>e||t||null},bulkSourceUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalDesignProductId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalDesignProductVariantId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalCartProductId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalCartProductVariantId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},lastSyncedAt:{read:(t=null)=>t,merge:(t,e)=>e||t||null},lineItem:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}},WorkflowProduct:{fields:{isPresent:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}},Product:{fields:{imageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},overlayImageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},preloadImageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},weight:{read:(t=null)=>t,merge:(t,e)=>e||t||null},conversionConfiguration:{read:(t=null)=>t,merge:(t,e)=>e||t||null},bulkConfiguration:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}}}});return new Ft({link:Yt([A,e,t]),cache:n,name:"Core"})}};function Me(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const Fe=It`
2
2
  fragment AssetFields on Asset {
3
3
  name
4
4
  key
@@ -1358,5 +1358,5 @@ import{CommandContext as t,AssetType as e,BringForwardCommand as A,BringToFrontC
1358
1358
  }
1359
1359
  }
1360
1360
  }
1361
- `,Oi=async t=>{const e=(await ye.getShadowGraphqlClient().query({query:Hi,errorPolicy:"all",fetchPolicy:"cache-first",variables:{id:t}})).data.workflow;return e.steps.forEach((t=>{delete t.data.__typename})),e},zi=(t,e)=>{const A=t.workflowState,n=A?JSON.parse(A):void 0;return n?Object.values(n.layouts).map((t=>t.layout)):e.panels.sort(((t,e)=>t.index-e.index)).map((t=>({id:F(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})))};class ji{constructor(t){var e;vi(this,"options",void 0),vi(this,"initialized",void 0),vi(this,"currencyCode",void 0),vi(this,"customer",void 0),vi(this,"experienceOptions",void 0),vi(this,"updateTransactionState",(async t=>{try{return ye.getShadowGraphqlClient().mutate({...t,mutation:Un})}catch(t){throw console.error(t),new ce("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,Ie=e)}getAssetManager(){return He}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!this.options.applicationKey)throw new Error("Application key required to use Flow Service.");return new Ii}async authenticateBundleFromLocalStorage(t){const e=de.getMap("bundleOwnerIds");if(e?.has(t)){const A=e.get(t);return me(A),Promise.resolve({success:!0,stakeholderType:oA.Owner})}const A=de.getMap("bundleCustomerIds");if(A?.has(t)){const e=A.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const e=ye.getShadowGraphqlClient(),A=await e.query({query:Ui,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!A.data.transactions||0===A.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const n=A.data.transactions[0],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=de.getMap("transactionOwnerIds");if(i?.has(t)){const e=i.get(t);return Qe(e),Promise.resolve({success:!0,stakeholderType:oA.Owner})}const o=de.getMap("transactionCustomerIds");if(o?.has(t)){const e=o.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.transactions?.some((e=>e.id===t))))||this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}const r=(await e.query({query:bi,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!r)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:r.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=de.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),de.setMap("transactionCustomerIds",e))}getStakeholderTypeForTransaction(t){const e=this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return e.type}async getOrCreateCustomer(t){this.customer=void 0;const e=ye.getShadowGraphqlClient(),A=(await e.query({query:ki,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!A.id){const A=(await e.mutate({mutation:Gi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!A)throw new Error("Unable to create customer.");return this.customer=A,{customer:A,isAuthenticated:!1}}const n=await this.authenticateCustomerId(A.id);return{customer:this.customer||A,isAuthenticated:n}}async authenticateCustomerId(t){const e=ye.getShadowGraphqlClient(),A=de.getMap("customerTokens");if(!A?.has(t))return!1;const n=A.get(t);if(!n)return!1;const a=(await e.mutate({mutation:Ji,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data?.customerAuthenticate;return!!a&&(fe(n),this.customer=a,!0)}async generateVerificationCode(t){await ye.getShadowGraphqlClient().mutate({mutation:Li,variables:{emailAddress:t}})}async verifyCode(t,e){const A=(await ye.getShadowGraphqlClient().mutate({mutation:Ti,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data?.customerVerifyCode;if(A?.loginToken){if(!A.partner?.id)throw new Error(`Unable to find customer: ${t}`);const e=de.getMap("customerTokens")||new Map;return e.set(A.id,A.loginToken),de.setMap("customerTokens",e),fe(A.loginToken),this.customer={...A,loginToken:void 0},!0}return!1}async getNewBundle(t){const e=(await ye.getShadowGraphqlClient().mutate({mutation:ti,variables:{collectionId:t},fetchPolicy:"no-cache"})).data?.bundleCreate;if(!e)throw new Error("Unable to create bundle");me(e.bundleOwnerId);const A=de.getMap("bundleOwnerIds")||new Map;return A.set(e.id,e.bundleOwnerId),de.setMap("bundleOwnerIds",A),new mi(this,e)}async getExistingBundle(t,e){const A=de.getMap("bundleOwnerIds")?.get(t);A&&me(A);const n=await ye.getShadowGraphqlClient().query({query:Za,variables:{id:t},fetchPolicy:"no-cache"});if(!n.data?.bundles||0===n.data?.bundles.length||!n.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const a=n.data?.bundles[0],i=new mi(this,a,e);return await i.getInitializationPromise(),i}async getBundleStakeholders(){if(!this.customer)throw new Error("Customer not authenticated.");const t=await ye.getShadowGraphqlClient().query({query:_a,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!t.data?.customers||0===t.data.customers.length)throw new Error("Unable to find customer.");return t.data.customers[0].bundleStakeholders||[]}async getWorkflowExperience(t,e,A,n){if(!n)return await this.getWorkflowExperienceDeprecated(t,e,A);const a=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await dt(e.svg))}const n=t.layouts[e].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const e=n[t];e.fontData?.assetUrl&&H(e.fontData.assetUrl)}}},{transaction:i,workflow:o,readOnly:r}=await(async()=>{const t=ye.getShadowGraphqlClient();if("transaction"===n.type){const{transactionId:e,readOnly:A}=n,a=await t.query({query:Hn,variables:{id:e},errorPolicy:"all",fetchPolicy:"no-cache"});if(!a.data?.transactions||0===a.data.transactions.length)throw new ce("Existing transaction not found.");const i=a.data?.transactions[0];if(!i.workflowId)throw new ce("Existing transaction has no workflow ID.");const o=await Oi(i.workflowId);if(!i.product)throw new ce("Failed to load transaction, product not available.");return{transaction:i,workflow:o,readOnly:A}}if("integration"===n.type||"external"===n.type){const e=async()=>{const e="integration"===n.type?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},A=await t.mutate({mutation:Pn,variables:{...e,bulk:n.bulk,workflowId:n.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new ce("Failed to create transaction!");const a=A.data.transactionCreate;if(!a.product)throw new ce("Failed to create transaction, product not available.");return a},A=Oi(n.workflowId),[a,i]=await Promise.all([e(),A]);return{transaction:a,workflow:i}}throw new ce("No workflow ID provided.")})();this.currencyCode=i.product.partner?.currencyCode;const s={product:i.product,transaction:i,layouts:[],stateMutationFunc:r?async()=>{throw new re("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:r,workflow:o};if("transaction"===n.type&&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=zi(s.transaction,s.workflow);if(s.renderableContextService=new In(s.layouts),n.previewService?(s.previewService=n.previewService,s.product?.modelUrl&&(s.modelContainer=s.previewService.loadModel({model:s.product.modelUrl,contextService:s.renderableContextService}))):(s.previewService=A&&A(o),s.product?.modelUrl&&(s.previewService?.initialize({model:s.product.modelUrl,contextService:s.renderableContextService}),s.modelContainer=s.previewService?.getAllModels()[0])),"transaction"!==n.type){const t=de.getMap("transactionOwnerIds")||new Map;t.set(i.id,i.transactionOwnerId),Qe(i.transactionOwnerId||""),de.setMap("transactionOwnerIds",t)}else{const t=(de.getMap("transactionOwnerIds")||new Map).get(i.id);t&&Qe(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 ce("No integration product ID provided.");const e=ye.getShadowGraphqlClient(),A=await e.mutate({mutation:Pn,variables:{integrationProductId:t,bulk:this.options.bulk||!1,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new ce("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new ce("Failed to create transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode;const a=de.getMap("transactionOwnerIds")||new Map;a.set(n.id,n.transactionOwnerId),Qe(n.transactionOwnerId||""),de.setMap("transactionOwnerIds",a),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new ce("No transaction ID provided.");const A=ye.getShadowGraphqlClient();if(e)return await(async()=>{const n=(await A.query({query:Hn,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!n)throw new ce("Failed to read transaction.");if(!n.product)throw new ce("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async()=>{throw new re("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const n=de.getMap("transactionOwnerIds")||new Map,a=n.get(t);if(a){Qe(a);const n=(await A.query({query:Hn,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!n)throw new ce("Failed to read transaction.");if(!n.product)throw new ce("Failed to load transaction, product not available.");return this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const a=(await A.mutate({mutation:Rn,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!a)throw new ce("Failed to read transaction.");if(!a.product)throw new ce("Failed to load transaction, product not available.");this.currencyCode=a.product.partner?.currencyCode,a.transactionOwnerId&&(n.set(a.id,a.transactionOwnerId),Qe(a.transactionOwnerId),de.setMap("transactionOwnerIds",n)),this.experienceOptions={product:a.product,transaction:a,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new ce("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,A){if(!this.initialized||!this.experienceOptions)throw new ce("Cannot launch experience: Not initialized.");const n=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await dt(e.svg))}const n=t.layouts[e].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const e=n[t];e.fontData?.assetUrl&&H(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await Oi(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=t,this.experienceOptions.transaction.workflowState){const t=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await n(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=A&&A(t),this.experienceOptions.renderableContextService=new In(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const e=new Xa(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const a=ye.getShadowGraphqlClient().mutate({mutation:bn,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),i=Oi(t);if(await Promise.all([a,i]),this.experienceOptions.workflow=await i,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await n(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=zi(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await i),this.experienceOptions.renderableContextService=new In(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 ce("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new ce("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new ce("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function Ki(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Vi{constructor(){Ki(this,"getProduct",void 0),Ki(this,"getCommandContext",void 0),Ki(this,"getAllLayoutData",void 0),Ki(this,"getMetadata",void 0),Ki(this,"getWorkflowMetadata",void 0),Ki(this,"getStepStorage",void 0),Ki(this,"setModelContainer",void 0),Ki(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(t){}addVariationRecord(t){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(t){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addCurrentVariationCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(t){}setCurrentVariationRecord(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,A){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function Wi(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let Xi;var qi;(qi=Xi||(Xi={})).SelectFrame="SelectFrame",qi.SelectImage="SelectImage",qi.Position="Position";class Zi extends Ma{constructor(t,e){super(t,e),Wi(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return ia.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 ia.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,A,n){return n&&n.length>1&&void 0===t?Xi.SelectFrame:e||A||this.getImageData()?Xi.Position:Xi.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 $i=t=>{const e=Gt(null),A=Gt(void 0),[n,a]=Pt(void 0),{addEvent:i,removeEvent:o,updateEvent:r,eventCache:s}=Le(),[c,g]=Pt(!1),[l,B]=Pt(!1),{state:w,uiDispatcher:d}=Ze(),h=Rt((t=>{const e=t;d(new qe({zoom:Math.max(.1,Math.min(e,w.maxZoom))}))}),[d,w.maxZoom]),E=Rt((t=>{o(t),1===s.length&&(A.current=void 0),2===s.length&&a(void 0);"touch"===t.pointerType&&s.length>1&&s.length-1==1&&(B(!1),g(!1))}),[o,s.length]),u=Rt((t=>{i(t);"touch"===t.pointerType&&1===s.length&&(d(new qe({selectedElement:void 0})),B(!0),g(!0))}),[i,s.length,d]),C=Rt((t=>{r(t);const e=1===s.length&&"touch"!==s[0].pointerType,i=2===s.length&&"touch"===s[0].pointerType;if(c&&i){const[t,e]=s,A=Math.abs(t.clientX-e.clientX),i=n;i&&h(w.zoom-.0055*(i-A)),a(A)}if(l&&(e||i)&&t.isPrimary){const e=(A?.current?.x||t.screenX)-t.screenX,n=(A?.current?.y||t.screenY)-t.screenY;d(new qe({selectedElement:void 0,xTranslation:w.xTranslation-e/w.zoom,yTranslation:w.yTranslation-n/w.zoom}))}t.isPrimary&&(A.current={x:t.screenX,y:t.screenY})}),[r,s,c,l,n,h,w.zoom,w.xTranslation,w.yTranslation,d]),Q=Rt((t=>{c&&h(w.zoom-.035*Math.sign(t.deltaY))}),[h,w.zoom,c]);Ut((()=>{if(!e.current||0===s.length)return;const t=s[0].pointerId,A=e.current.hasPointerCapture(t);l&&!A&&e.current.setPointerCapture(t),!l&&A&&e.current.releasePointerCapture(t)}),[e,l,s]),JA([" "],(()=>{B(!0),d(new qe({selectedElement:void 0}))}),(()=>B(!1))),JA(["Control"],(()=>g(!0)),(()=>g(!1)));const p=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:e,className:"transform-wrapper",onWheel:Q,onPointerDown:u,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:C,style:p,children:t.children})};export{ji as SpiffCommerceClient,t as CommandContext,Ee as spiffCoreConfiguration,zA as PromiseQueue,OA as QueueablePromise,Vi as MockWorkflowManager,Qa as InformationMessageType,Ma as StepHandle,ba as TextStepHandle,Zi as FrameStepHandle,va as BulkStepHandle,Ua as ShapeStepHandle,xa as IllustrationStepHandle,Na as MaterialStepHandle,Pa as ModelStepHandle,Ra as PictureStepHandle,Ha as QuestionStepHandle,tA as BulkPriceCalculationStrategy,Ia as Variant,Xa as WorkflowExperienceImpl,ee as OptionNotFoundError,Ae as LayoutNotFoundError,ne as AssetNotFoundError,ae as ResourceNotFoundError,ie as MisconfigurationError,se as ParseError,re as UnhandledBehaviorError,He as assetService,Va as designService,za as createDesign,Ge as optionService,de as persistenceService,ye as graphQlManager,gA 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,ua as textStepService,oa as illustrationStepService,$e as ProductCameraRig,Xi as FrameStep,AA as ConversionLocation,aA as ConversionDataType,Oi as getWorkflow,ta as shortenUrl,Yi as ObjectInput,Si as TextInput,Mi as ObjectInputType,e as AssetType,A 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,u as ResizeCommand,C as RotateCommand,Q as SendBackwardsCommand,oA as StakeholderType,p as StepAspectType,m as StepType,D as TextChangeCommand,f as UnitOfMeasurement,I as dataUrlFromExternalUrl,y as findElement,M as frameDataCache,F as generate,Y as getAxisAlignedBoundingBox,S as generateSVGWithUnknownColors,v as getAttributesFromArrayBuffer,x as rehydrateSerializedLayout,N as getFrameData,P as getSvgElement,R as loadFontFromDataUrl,H as loadFontFromExternalUrl,U as determineCorrectFontSizeAndLines,b as patternImageDataCache,Dn as generateCommands,k as registerJSDOM,bA as minZoom,Nn as AdvancedEditor,$i as TransformWrapper,xn as EditorCore,Te as useLayouts,Ze as useEditorState,GA as useEditorInteraction,JA as useShortcutCombination,Ve as commandReducer,Ke as getDefaultState,Je as CommandContextContext,Xe as AdvancedEditorStateProvider,We as AdvancedEditorContext,qe as UICommand,ze as EditorSubMenu,lA as ElementEventType,wA as KeyEvent,Ln as gatherVaryingStepAspects};
1361
+ `,Oi=async t=>(await ye.getShadowGraphqlClient().query({query:Hi,errorPolicy:"all",fetchPolicy:"cache-first",variables:{id:t}})).data.workflow,zi=(t,e)=>{const A=t.workflowState,n=A?JSON.parse(A):void 0;return n?Object.values(n.layouts).map((t=>t.layout)):e.panels.sort(((t,e)=>t.index-e.index)).map((t=>({id:F(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})))};class ji{constructor(t){var e;vi(this,"options",void 0),vi(this,"initialized",void 0),vi(this,"currencyCode",void 0),vi(this,"customer",void 0),vi(this,"experienceOptions",void 0),vi(this,"updateTransactionState",(async t=>{try{return ye.getShadowGraphqlClient().mutate({...t,mutation:Un})}catch(t){throw console.error(t),new ce("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,Ie=e)}getAssetManager(){return He}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!this.options.applicationKey)throw new Error("Application key required to use Flow Service.");return new Ii}async authenticateBundleFromLocalStorage(t){const e=de.getMap("bundleOwnerIds");if(e?.has(t)){const A=e.get(t);return me(A),Promise.resolve({success:!0,stakeholderType:oA.Owner})}const A=de.getMap("bundleCustomerIds");if(A?.has(t)){const e=A.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const e=ye.getShadowGraphqlClient(),A=await e.query({query:Ui,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!A.data.transactions||0===A.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const n=A.data.transactions[0],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=de.getMap("transactionOwnerIds");if(i?.has(t)){const e=i.get(t);return Qe(e),Promise.resolve({success:!0,stakeholderType:oA.Owner})}const o=de.getMap("transactionCustomerIds");if(o?.has(t)){const e=o.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.transactions?.some((e=>e.id===t))))||this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}const r=(await e.query({query:bi,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!r)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:r.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=de.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),de.setMap("transactionCustomerIds",e))}getStakeholderTypeForTransaction(t){const e=this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return e.type}async getOrCreateCustomer(t){this.customer=void 0;const e=ye.getShadowGraphqlClient(),A=(await e.query({query:ki,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!A.id){const A=(await e.mutate({mutation:Gi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!A)throw new Error("Unable to create customer.");return this.customer=A,{customer:A,isAuthenticated:!1}}const n=await this.authenticateCustomerId(A.id);return{customer:this.customer||A,isAuthenticated:n}}async authenticateCustomerId(t){const e=ye.getShadowGraphqlClient(),A=de.getMap("customerTokens");if(!A?.has(t))return!1;const n=A.get(t);if(!n)return!1;const a=(await e.mutate({mutation:Ji,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data?.customerAuthenticate;return!!a&&(fe(n),this.customer=a,!0)}async generateVerificationCode(t){await ye.getShadowGraphqlClient().mutate({mutation:Li,variables:{emailAddress:t}})}async verifyCode(t,e){const A=(await ye.getShadowGraphqlClient().mutate({mutation:Ti,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data?.customerVerifyCode;if(A?.loginToken){if(!A.partner?.id)throw new Error(`Unable to find customer: ${t}`);const e=de.getMap("customerTokens")||new Map;return e.set(A.id,A.loginToken),de.setMap("customerTokens",e),fe(A.loginToken),this.customer={...A,loginToken:void 0},!0}return!1}async getNewBundle(t){const e=(await ye.getShadowGraphqlClient().mutate({mutation:ti,variables:{collectionId:t},fetchPolicy:"no-cache"})).data?.bundleCreate;if(!e)throw new Error("Unable to create bundle");me(e.bundleOwnerId);const A=de.getMap("bundleOwnerIds")||new Map;return A.set(e.id,e.bundleOwnerId),de.setMap("bundleOwnerIds",A),new mi(this,e)}async getExistingBundle(t,e){const A=de.getMap("bundleOwnerIds")?.get(t);A&&me(A);const n=await ye.getShadowGraphqlClient().query({query:Za,variables:{id:t},fetchPolicy:"no-cache"});if(!n.data?.bundles||0===n.data?.bundles.length||!n.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const a=n.data?.bundles[0],i=new mi(this,a,e);return await i.getInitializationPromise(),i}async getBundleStakeholders(){if(!this.customer)throw new Error("Customer not authenticated.");const t=await ye.getShadowGraphqlClient().query({query:_a,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!t.data?.customers||0===t.data.customers.length)throw new Error("Unable to find customer.");return t.data.customers[0].bundleStakeholders||[]}async getWorkflowExperience(t,e,A,n){if(!n)return await this.getWorkflowExperienceDeprecated(t,e,A);const a=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await dt(e.svg))}const n=t.layouts[e].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const e=n[t];e.fontData?.assetUrl&&H(e.fontData.assetUrl)}}},{transaction:i,workflow:o,readOnly:r}=await(async()=>{const t=ye.getShadowGraphqlClient();if("transaction"===n.type){const{transactionId:e,readOnly:A}=n,a=await t.query({query:Hn,variables:{id:e},errorPolicy:"all",fetchPolicy:"no-cache"});if(!a.data?.transactions||0===a.data.transactions.length)throw new ce("Existing transaction not found.");const i=a.data?.transactions[0];if(!i.workflowId)throw new ce("Existing transaction has no workflow ID.");const o=await Oi(i.workflowId);if(!i.product)throw new ce("Failed to load transaction, product not available.");return{transaction:i,workflow:o,readOnly:A}}if("integration"===n.type||"external"===n.type){const e=async()=>{const e="integration"===n.type?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},A=await t.mutate({mutation:Pn,variables:{...e,bulk:n.bulk,workflowId:n.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new ce("Failed to create transaction!");const a=A.data.transactionCreate;if(!a.product)throw new ce("Failed to create transaction, product not available.");return a},A=Oi(n.workflowId),[a,i]=await Promise.all([e(),A]);return{transaction:a,workflow:i}}throw new ce("No workflow ID provided.")})();this.currencyCode=i.product.partner?.currencyCode;const s={product:i.product,transaction:i,layouts:[],stateMutationFunc:r?async()=>{throw new re("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:r,workflow:o};if("transaction"===n.type&&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=zi(s.transaction,s.workflow);if(s.renderableContextService=new In(s.layouts),n.previewService?(s.previewService=n.previewService,s.product?.modelUrl&&(s.modelContainer=s.previewService.loadModel({model:s.product.modelUrl,contextService:s.renderableContextService}))):(s.previewService=A&&A(o),s.product?.modelUrl&&(s.previewService?.initialize({model:s.product.modelUrl,contextService:s.renderableContextService}),s.modelContainer=s.previewService?.getAllModels()[0])),"transaction"!==n.type){const t=de.getMap("transactionOwnerIds")||new Map;t.set(i.id,i.transactionOwnerId),Qe(i.transactionOwnerId||""),de.setMap("transactionOwnerIds",t)}else{const t=(de.getMap("transactionOwnerIds")||new Map).get(i.id);t&&Qe(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 ce("No integration product ID provided.");const e=ye.getShadowGraphqlClient(),A=await e.mutate({mutation:Pn,variables:{integrationProductId:t,bulk:this.options.bulk||!1,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new ce("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new ce("Failed to create transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode;const a=de.getMap("transactionOwnerIds")||new Map;a.set(n.id,n.transactionOwnerId),Qe(n.transactionOwnerId||""),de.setMap("transactionOwnerIds",a),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new ce("No transaction ID provided.");const A=ye.getShadowGraphqlClient();if(e)return await(async()=>{const n=(await A.query({query:Hn,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!n)throw new ce("Failed to read transaction.");if(!n.product)throw new ce("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async()=>{throw new re("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const n=de.getMap("transactionOwnerIds")||new Map,a=n.get(t);if(a){Qe(a);const n=(await A.query({query:Hn,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!n)throw new ce("Failed to read transaction.");if(!n.product)throw new ce("Failed to load transaction, product not available.");return this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const a=(await A.mutate({mutation:Rn,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!a)throw new ce("Failed to read transaction.");if(!a.product)throw new ce("Failed to load transaction, product not available.");this.currencyCode=a.product.partner?.currencyCode,a.transactionOwnerId&&(n.set(a.id,a.transactionOwnerId),Qe(a.transactionOwnerId),de.setMap("transactionOwnerIds",n)),this.experienceOptions={product:a.product,transaction:a,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new ce("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,A){if(!this.initialized||!this.experienceOptions)throw new ce("Cannot launch experience: Not initialized.");const n=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===h.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await dt(e.svg))}const n=t.layouts[e].elements.filter((t=>t.type===h.Textbox));for(let t=0;t<n.length;++t){const e=n[t];e.fontData?.assetUrl&&H(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await Oi(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=t,this.experienceOptions.transaction.workflowState){const t=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await n(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=A&&A(t),this.experienceOptions.renderableContextService=new In(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const e=new Xa(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const a=ye.getShadowGraphqlClient().mutate({mutation:bn,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),i=Oi(t);if(await Promise.all([a,i]),this.experienceOptions.workflow=await i,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await x(t),await n(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=zi(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await i),this.experienceOptions.renderableContextService=new In(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 ce("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new ce("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new ce("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function Ki(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Vi{constructor(){Ki(this,"getProduct",void 0),Ki(this,"getCommandContext",void 0),Ki(this,"getAllLayoutData",void 0),Ki(this,"getMetadata",void 0),Ki(this,"getWorkflowMetadata",void 0),Ki(this,"getStepStorage",void 0),Ki(this,"setModelContainer",void 0),Ki(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(t){}addVariationRecord(t){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(t){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addCurrentVariationCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(t){}setCurrentVariationRecord(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,A){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function Wi(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let Xi;var qi;(qi=Xi||(Xi={})).SelectFrame="SelectFrame",qi.SelectImage="SelectImage",qi.Position="Position";class Zi extends Ma{constructor(t,e){super(t,e),Wi(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return ia.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 ia.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,A,n){return n&&n.length>1&&void 0===t?Xi.SelectFrame:e||A||this.getImageData()?Xi.Position:Xi.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 $i=t=>{const e=Gt(null),A=Gt(void 0),[n,a]=Pt(void 0),{addEvent:i,removeEvent:o,updateEvent:r,eventCache:s}=Le(),[c,g]=Pt(!1),[l,B]=Pt(!1),{state:w,uiDispatcher:d}=Ze(),h=Rt((t=>{const e=t;d(new qe({zoom:Math.max(.1,Math.min(e,w.maxZoom))}))}),[d,w.maxZoom]),E=Rt((t=>{o(t),1===s.length&&(A.current=void 0),2===s.length&&a(void 0);"touch"===t.pointerType&&s.length>1&&s.length-1==1&&(B(!1),g(!1))}),[o,s.length]),u=Rt((t=>{i(t);"touch"===t.pointerType&&1===s.length&&(d(new qe({selectedElement:void 0})),B(!0),g(!0))}),[i,s.length,d]),C=Rt((t=>{r(t);const e=1===s.length&&"touch"!==s[0].pointerType,i=2===s.length&&"touch"===s[0].pointerType;if(c&&i){const[t,e]=s,A=Math.abs(t.clientX-e.clientX),i=n;i&&h(w.zoom-.0055*(i-A)),a(A)}if(l&&(e||i)&&t.isPrimary){const e=(A?.current?.x||t.screenX)-t.screenX,n=(A?.current?.y||t.screenY)-t.screenY;d(new qe({selectedElement:void 0,xTranslation:w.xTranslation-e/w.zoom,yTranslation:w.yTranslation-n/w.zoom}))}t.isPrimary&&(A.current={x:t.screenX,y:t.screenY})}),[r,s,c,l,n,h,w.zoom,w.xTranslation,w.yTranslation,d]),Q=Rt((t=>{c&&h(w.zoom-.035*Math.sign(t.deltaY))}),[h,w.zoom,c]);Ut((()=>{if(!e.current||0===s.length)return;const t=s[0].pointerId,A=e.current.hasPointerCapture(t);l&&!A&&e.current.setPointerCapture(t),!l&&A&&e.current.releasePointerCapture(t)}),[e,l,s]),JA([" "],(()=>{B(!0),d(new qe({selectedElement:void 0}))}),(()=>B(!1))),JA(["Control"],(()=>g(!0)),(()=>g(!1)));const p=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:e,className:"transform-wrapper",onWheel:Q,onPointerDown:u,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:C,style:p,children:t.children})};export{ji as SpiffCommerceClient,t as CommandContext,Ee as spiffCoreConfiguration,zA as PromiseQueue,OA as QueueablePromise,Vi as MockWorkflowManager,Qa as InformationMessageType,Ma as StepHandle,ba as TextStepHandle,Zi as FrameStepHandle,va as BulkStepHandle,Ua as ShapeStepHandle,xa as IllustrationStepHandle,Na as MaterialStepHandle,Pa as ModelStepHandle,Ra as PictureStepHandle,Ha as QuestionStepHandle,tA as BulkPriceCalculationStrategy,Ia as Variant,Xa as WorkflowExperienceImpl,ee as OptionNotFoundError,Ae as LayoutNotFoundError,ne as AssetNotFoundError,ae as ResourceNotFoundError,ie as MisconfigurationError,se as ParseError,re as UnhandledBehaviorError,He as assetService,Va as designService,za as createDesign,Ge as optionService,de as persistenceService,ye as graphQlManager,gA 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,ua as textStepService,oa as illustrationStepService,$e as ProductCameraRig,Xi as FrameStep,AA as ConversionLocation,aA as ConversionDataType,Oi as getWorkflow,ta as shortenUrl,Yi as ObjectInput,Si as TextInput,Mi as ObjectInputType,e as AssetType,A 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,u as ResizeCommand,C as RotateCommand,Q as SendBackwardsCommand,oA as StakeholderType,p as StepAspectType,m as StepType,D as TextChangeCommand,f as UnitOfMeasurement,I as dataUrlFromExternalUrl,y as findElement,M as frameDataCache,F as generate,Y as getAxisAlignedBoundingBox,S as generateSVGWithUnknownColors,v as getAttributesFromArrayBuffer,x as rehydrateSerializedLayout,N as getFrameData,P as getSvgElement,R as loadFontFromDataUrl,H as loadFontFromExternalUrl,U as determineCorrectFontSizeAndLines,b as patternImageDataCache,Dn as generateCommands,k as registerJSDOM,bA as minZoom,Nn as AdvancedEditor,$i as TransformWrapper,xn as EditorCore,Te as useLayouts,Ze as useEditorState,GA as useEditorInteraction,JA as useShortcutCombination,Ve as commandReducer,Ke as getDefaultState,Je as CommandContextContext,Xe as AdvancedEditorStateProvider,We as AdvancedEditorContext,qe as UICommand,ze as EditorSubMenu,lA as ElementEventType,wA as KeyEvent,Ln as gatherVaryingStepAspects};
1362
1362
  //# sourceMappingURL=module.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/core",
3
- "version": "14.7.2-beta.0",
3
+ "version": "14.7.3-alpha.0",
4
4
  "description": "Core client API for interacting with the Spiff Commerce backend.",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/main.js",
@@ -87,7 +87,7 @@
87
87
  },
88
88
  "dependencies": {
89
89
  "@apollo/client": "^3.7.0",
90
- "@spiffcommerce/papyrus": "5.0.0",
90
+ "@spiffcommerce/papyrus": "5.0.1",
91
91
  "cross-fetch": "^3.1.5",
92
92
  "graphql": "^16.6.0",
93
93
  "lodash.clonedeep": "^4.5.0",