@imagineio/configurator-sdk 0.1.3 → 0.1.5
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/README.md +134 -134
- package/dist/0a35b2c5f4.js +1 -1
- package/dist/2990ba64d6.js +1 -1
- package/dist/2c7c1bcef1.js +1 -1
- package/dist/30be653f00.css +106 -106
- package/dist/39a62ef7b8.js +1 -1
- package/dist/3c916f744f.js +1 -1
- package/dist/4e7d0a0d4a.js +1 -1
- package/dist/60d697292c.js +1 -1
- package/dist/6bff84d27e.js +1 -1
- package/dist/718ecf1729.js +1 -0
- package/dist/776277593f.js +1 -1
- package/dist/7d9ddaeb47.js +1 -1
- package/dist/811b403d43.js +1 -1
- package/dist/87bb469216.js +1 -1
- package/dist/9526094bb7.js +1 -1
- package/dist/98f3644031.js +1 -1
- package/dist/99577e3161.js +1 -0
- package/dist/9ce3c3df25.js +1 -0
- package/dist/a0f71d0bf5.js +1 -1
- package/dist/a493e9aa8f.js +1 -1
- package/dist/a77b15c0d6.js +1 -1
- package/dist/bcd44b4040.js +1 -1
- package/dist/bdec200d00.js +1 -1
- package/dist/be07a7f885.js +1 -0
- package/dist/c9a1656c62.js +1 -1
- package/dist/ce663020e4.js +2 -2
- package/dist/d4378d9afa.js +1 -1
- package/dist/dbd5ba1d07.js +1 -1
- package/dist/dc2a1a0e13.js +1 -1
- package/dist/fbd844f2d1.js +1 -1
- package/package.json +16 -14
package/dist/a77b15c0d6.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import S from"./be337ddda5.js";import v from"./9c6c598569.js";import C from"./872c4302e0.js";import A from"./8f60e5059a.js";import L from"./1fac915f8b.js";import I from"./d94df858ea.js";import{dispatch as h,setRefetchCatalogHandler as U,setFocusProvider as F,setRejectionHandler as $,setEvaluationStateHandler as q}from"./776277593f.js";import{coalescedDispatch as _}from"./4e1db1e3b0.js";import{dispatchEvents as Q,dispatchCustomEffects as G}from"./970313b92b.js";import{emitEvent as x,EVENTS as P}from"./2e366d7386.js";import{setConfigState as d,setInitial as Y,resetConfigState as z}from"./817d930a49.js";import{buildCanonicalState as m,applyResolvedToScene as k,applyRemovedPlacements as N,applyAddedPlacements as V,applyWarnings as J,applyMessages as w,applyWallMountedPlacements as X,applyPresetPieceTrims as Z,applyInitialSelections as ee,getHostedProductSpawnSelections as te,applyResolvedPieceAdds as oe,hydrateProductInstancesFromState as H,syncOwnedInstanceVariants as re,applyOwnedTransforms as ne}from"./bcd44b4040.js";import{applyBackendPricing as j}from"./67f6338a4a.js";import{fetchInitialConfiguration as ae}from"./fbd844f2d1.js";import*as p from"./3c916f744f.js";import{resolveReplaceTarget as se}from"./4d7a0d1897.js";import{authHeaders as le,isAuthFailure as ce,reportAuthFailure as ie}from"./431a2d8618.js";import{assertLicensed as ue}from"./fe235d7160.js";import{setApiKey as dt,setChannelId as mt,getChannelId as pt,setEmbedSlug as ft,getEmbedSlug as gt,setShareToken as St,getShareToken as yt}from"./431a2d8618.js";import{isReadOnlyCredential as xt,onReadOnlyChange as Pt}from"./431a2d8618.js";import{setTokenProvider as Ct,clearSessionToken as It,getSessionScope as Tt}from"./33fa2c8ca2.js";import{getApiBaseUrl as de}from"./8ade32d067.js";async function me(){const e=S.getState().systemId;try{const t=`/api/v1/systems/${e}/`;await ue(t);const r=await fetch(`${de()}${t}`,{cache:"no-store",headers:{...le(t)}});ce(r)&&await ie(r,{url:t,method:"GET"});const o=await r.json(),n=o?.catalogVersion??o?.catalog_version??null;return n!=null&&S.setState({catalogVersion:n}),{catalogVersion:n}}catch{return{catalogVersion:S.getState().catalogVersion}}}let O=0;function M(e){O=Math.max(0,O+(e?1:-1));try{A.setState({isEvaluating:O>0})}catch{}}function W(e){const t=e?.uiToggles??e?.ui_toggles??null;if(!(!t||typeof t!="object"))try{C.getState().mergeSystemUiToggles(t)}catch{}}function pe(e){const t=e?.placementBoundsExclude??e?.placement_bounds_exclude??e?.state?.placementBoundsExclude??e?.state?.placement_bounds_exclude??e?.system?.placementBoundsExclude??e?.system?.placement_bounds_exclude??null,r=t?.componentIds??t?.component_ids??null,o=Array.isArray(r)?r.map(n=>String(n)):[];try{C.setState({placementBoundsExcludeIds:o})}catch{}}async function fe({onRefetchCatalog:e}={}){U(e||me),F(he),$(t=>{try{A.getState().showWarning?.(B(t))}catch{}}),q(M),ge(),d(m())}let T=null,R=null;function ge(){if(T){try{T()}catch{}T=null}T=v.subscribe(e=>`${e.selectedInstanceId??""}|${e.selectedComponentId??""}`,()=>{R&&clearTimeout(R),R=setTimeout(()=>{ye()},120)})}function Se(){if(R&&(clearTimeout(R),R=null),T){try{T()}catch{}T=null}}async function ye(){let e=null;try{e=v.getState().selectedInstanceId}catch{}try{if(A.getState().isLayoutLoading)return null}catch{}d(m());let t=null;try{t=await _(p.noop())}catch{return null}return g(t)}function he(){const e=v.getState(),t=e.selectedInstanceId;if(t==null)return{};if(String(t).endsWith("__host")){const a=String(t).replace(/__host$/,""),s=(e.productInstances||{})[a]||null,l=C.getState(),c=s?l.getProduct?.(s.variantId??s.productId):null,i=c?.hostVariants??c?.host_variants,u=Array.isArray(i)?i.find(b=>b?.isDefault??b?.is_default)??i[0]:null,f=u?.hostVariantId??u?.host_variant_id??null,y={placementId:String(t)};return f!=null&&(y.variantId=f),y.componentId=e.selectedComponentId??null,y}const r=(e.productInstances||{})[String(t)]||null,o=r?.variantId??r?.productId??null,n={placementId:String(t)};return o!=null&&(n.variantId=o),n.componentId=e.selectedComponentId??null,n}async function xe(e,t,r,o){const n=e&&typeof e=="object"?e:{placementId:e,optionSetId:t,optionId:r,...o||{}},{placementId:a,optionSetId:s,optionId:l,optimistic:c,rollback:i}=n;if(a==null||s==null||l==null)return null;try{if(v.getState().productInstances?.[String(a)]?.locked)return A.getState().showWarning?.("This item is locked and can\u2019t be changed."),null}catch{}d(m());let u=null;try{u=await _(p.selectOption(a,s,l),{optimistic:c,rollback:i})}catch{return null}return g(u)}async function We(e){if(e==null)return null;const{osId:t,assignments:r}=te(),o=r.find(s=>String(s.instanceId)===String(e));if(t==null||!o)return null;d(m({excludeHostedProductInstanceId:e}));const n=Number(t)||t;let a=null;try{a=await h(p.selectOption(o.pieceId,n,o.optionId))}catch{return null}return g(a)}async function Ke(e,t,r){const o=e&&typeof e=="object"?e:{optionSetId:e,optionId:t,...r||{}},{optionSetId:n,optionId:a,optimistic:s,rollback:l}=o;if(n==null||a==null)return null;const c=I.getState(),i=c.sceneSelections?.[n];c.setSceneSelection?.(n,a),d(m());let u=null;try{u=await _(p.selectSystemOption(n,a),{optimistic:s,rollback:l})}catch{return I.getState().setSceneSelection?.(n,i),null}return u&&u.rejected&&I.getState().setSceneSelection?.(n,i),g(u)}async function $e({optionSetId:e,optionId:t,overrides:r={}}={}){if(e==null||t==null)return null;const o=C.getState().options||{},n=o[t]||o[String(t)];if(!n)return null;const a=n.value??n.valueText??n.value_text,s=C.getState().products||{},l=a!=null?s[a]||s[String(a)]:null;if(!l&&r.productGraphId==null)return null;const c=r.productGraphId??l?.productGraph??l?.product_graph??l?.productGraphId??null,i=r.placementGroup??l?.placementGroup??l?.placement_group??null,u=r.variantId??a,f=r.replacePlacementId!==void 0?r.replacePlacementId:se({placementGroup:i});return ve({productGraphId:c,variantId:u,placementGroup:i,position:r.position,replace:f!=null,replacePlacementId:f})}async function qe(e,t,r){const o=e&&typeof e=="object"?e:{placementId:e,variantId:t,...r||{}},{placementId:n,variantId:a,optimistic:s,rollback:l}=o;if(n==null||a==null)return null;d(m());let c=null;try{c=await _(p.changeVariant(n,a),{optimistic:s,rollback:l})}catch{return null}return g(c)}function K(){let e=null,t=null;try{e=S.getState().systemId??null}catch{}try{const r=v.getState(),o=S.getState();t=r.activeSceneConfigId||o.defaultPresetId||Object.keys(o.sceneConfigurations||{})[0]||null}catch{}return e==null?null:`${e}|${t??""}`}let E=null;const D=new Set;async function Ye({force:e=!1}={}){const t=K();if(!e&&t!=null&&D.has(t))return null;if(E)return E;E=Pe(),M(!0);try{const r=await E;t!=null&&D.add(t);const o=K();return o!=null&&D.add(o),r}finally{E=null,M(!1)}}async function Pe(){const e=S.getState().systemId;if(e==null)return null;const t=v.getState().activeSceneConfigId??null;let r=null;try{r=await ae({systemId:e,presetId:t})}catch{return null}if(W(r?.system),pe(r),!r?.state)return null;Y(r);try{ee(r.state)}catch{}try{w(r.messages)}catch{}try{w(r.customDiagnostics)}catch{}try{Q(r.events)}catch{}try{G(r.customEffects)}catch{}try{const o=r.state.sceneId??r.state.scene_id;o!=null&&v.getState().setActiveSceneId?.(o)}catch{}try{Z(r.removedPlacements)}catch{}try{N(r.removedPlacements)}catch{}try{X(r.state)}catch{}try{V(r.addedPlacements,r.state)}catch{}try{H(r.state)}catch{}try{k(r.state)}catch{}try{ne(r.state)}catch{}try{j(r.pricing)}catch{}try{I.getState().markSceneSelectionsSettled?.()}catch{}try{x(P.READY,{systemId:r?.state?.systemId??null})}catch{}return r}function B(e){const r=(Array.isArray(e?.errors)?e.errors:[]).map(n=>typeof n=="string"?n:n?.message??n?.detail??null).filter(Boolean),o=[...new Set(r)];return o.length?o.join(" "):"That change isn\u2019t allowed by the current design rules \u2014 reverted."}function ze(e){const t=A.getState();if(t.isLayoutLoading||t._snapshotOverridesOnLoadComplete){try{t.showWarning?.(B(e))}catch{}return}try{t.showError?.(B(e))}catch{}if((L.getState().past||[]).length>0)try{L.getState().undo()}catch{}}async function Je(){try{d(m())}catch{}return null}function g(e){if(W(e?.system),e&&e.applied&&e.resolvedState&&(k(e.resolvedState),N(e.removedPlacements),V(e.addedPlacements,e.resolvedState),oe(e.resolvedState),H(e.resolvedState),re(e.resolvedState),J(e.warnings)),e){try{w(e.messages)}catch{}try{w(e.customDiagnostics)}catch{}try{Q(e.events)}catch{}try{G(e.customEffects)}catch{}try{e.pricing&&j(e.pricing)}catch{}}return e}async function ve({productGraphId:e,variantId:t,placementGroup:r,position:o,sequence:n,hostPlacementId:a,hostVariantId:s,replace:l,replacePlacementId:c,excludePieceIndex:i,optimistic:u,rollback:f}={}){d(m(i!=null?{excludePieceIndex:i}:{}));let y=null;try{y=await h(p.addPlacement({productGraphId:e,variantId:t,placementGroup:r,position:o,sequence:n,hostPlacementId:a,hostVariantId:s,replace:l,replacePlacementId:c}),{optimistic:u,rollback:f})}catch{return x(P.ERROR,{op:"addPlacement"}),null}const b=g(y);return y?.applied&&x(P.PRODUCT_ADDED,{variantId:t,productGraphId:e,placementGroup:r,placementIds:Object.keys(y?.resolvedState?.placements||{})}),b}async function Xe(e,{optimistic:t,rollback:r}={}){if(e==null)return null;d(m());let o=null;try{o=await h(p.removePlacement(e),{optimistic:t,rollback:r})}catch{return x(P.ERROR,{op:"removePlacement"}),null}const n=g(o);return o?.applied&&x(P.PRODUCT_REMOVED,{placementId:e}),n}async function Ze({placementId:e,sequence:t,placementGroup:r,position:o,rotation:n,hostPlacementId:a,hostVariantId:s,optimistic:l,rollback:c}={}){if(e==null)return null;if(!(t!=null&&Number.isInteger(Number(t))))return o!=null||n!=null?Ce(e,o,n):null;d(m());let u=null;try{u=await h(p.movePlacement({placementId:e,sequence:Number(t),placementGroup:r,position:o,rotation:n,hostPlacementId:a,hostVariantId:s}),{optimistic:l,rollback:c})}catch{return x(P.ERROR,{op:"movePlacement"}),null}const f=g(u);return u?.applied&&x(P.PRODUCT_MOVED,{placementId:e,sequence:Number(t)}),f}async function et(e,{optimistic:t,rollback:r}={}){if(e==null)return null;d(m());let o=null;try{o=await h(p.applyPreset(e),{optimistic:t,rollback:r})}catch{return x(P.ERROR,{op:"applyPreset"}),null}const n=g(o);return o?.applied&&x(P.LAYOUT_CHANGED,{presetId:e}),n}async function tt(e,{optimistic:t,rollback:r}={}){if(!e)return null;let o=null;try{o=await h(p.restoreState(e),{optimistic:t,rollback:r})}catch{return null}return g(o)}async function ot(e,t,r,{optimistic:o,rollback:n}={}){d(m());let a=null;try{a=await _(p.setRoomDimensions(e,t,r),{optimistic:o,rollback:n})}catch{return null}return g(a)}async function rt(e,t,{optimistic:r,rollback:o}={}){if(e==null||t==null)return null;d(m());let n=null;try{n=await h(p.clearSelection(e,t),{optimistic:r,rollback:o})}catch{return null}return g(n)}async function nt(e,{optimistic:t,rollback:r}={}){if(e==null)return null;const o=I.getState(),n=o.sceneSelections?.[e],a=C.getState(),s=a.features?.[e]??a.features?.[String(e)],l=s?.defaultOption??s?.default_option_id??s?.default_option??void 0;o.setSceneSelection?.(e,l),d(m());let c=null;try{c=await h(p.clearSystemSelection(e),{optimistic:t,rollback:r})}catch{return I.getState().setSceneSelection?.(e,n),null}if(c&&c.rejected)I.getState().setSceneSelection?.(e,n);else{const i=c?.defaultOptionOverrides?.[e]??c?.defaultOptionOverrides?.[String(e)];i!=null&&I.getState().setSceneSelection?.(e,i)}return g(c)}function Ce(e,t,r){if(e==null)return null;const o=String(e),n=v.getState(),a=n.productInstances?.[o];if(!a)return null;const s=Array.isArray(t)?t:null,l=Array.isArray(r)?r:null;if(!s&&!l)return null;s&&n.updateInstancePosition(o,s),l&&n.updateInstanceRotation(o,l);const c=C.getState(),i=c.getProduct?.(a.variantId)||c.getProduct?.(a.productId),u=i?.hostVariants??i?.host_variants,y=!(a.positionedAbove!=null||Array.isArray(u)&&u.length>0)&&!!i?.movable;return d(m()),h(p.setTransform(o,s??a.position,l??a.rotation)),{placementId:o,position:s??a.position??null,rotation:l??a.rotation??null,freeMovable:y}}async function Ie(e=null){const t=C.getState(),r=S.getState(),o=typeof window<"u"&&window.location?new URLSearchParams(window.location.search).get("system"):null,n=e??o??null;await t.loadCatalog({systemId:n}),await r.loadConfigurations(n??e);try{const s=S.getState(),l=s.systemDomainDefaults??s.systemRoom?.domain_defaults??null;if(l){const{loadDomainDefaults:c}=await import("./ee242c0099.js");c(l)}}catch{}return fe(),{systemId:S.getState().systemId,sceneConfigurations:S.getState().sceneConfigurations}}const at=(e=null)=>Ie(e);function st(){return S.getState().systemId??null}const lt=({pieceIndex:e,...t}={})=>xe({placementId:e,...t});function ct(){U(null),F(null),Se(),z()}import{dispatch as At}from"./776277593f.js";import{subscribe as Et,getVersion as bt,getConfigState as wt,getResolved as Ot,getBindingAvailable as Mt,getPlacementBinding as Dt,getPlacementBindings as Bt,getEffectiveSelections as Lt,resetConfigState as Ut}from"./817d930a49.js";import{getPlacementOverrides as Qt,getSlotOverride as Gt,resolveComponentTransform as kt,resolveComponentVisibility as Nt,resolveComponentMaterial as Vt}from"./c3b8f1973b.js";export*from"./3c916f744f.js";import{buildCanonicalState as Wt,hostedProductPlacementId as Kt,getHostedProductSpawnSelections as $t,applySceneConfigDefaults as qt,queuePieceAdd as Yt,dequeuePieceAdd as zt,wasPieceAddConsumed as Jt}from"./bcd44b4040.js";import{recomputePrice as Zt,applyBackendPricing as eo}from"./67f6338a4a.js";import{on as oo,registerEffectHandler as ro,_resetEventBus as no}from"./970313b92b.js";import{registerComponent as so,resolveComponent as lo,hasComponent as co,listComponentOverrides as io,_resetComponents as uo}from"./882bc739c8.js";import{registerSlot as po,listSlots as fo,hasSlot as go,SlotHost as So,_resetSlots as yo}from"./73f7d65985.js";import{use as xo,runIntent as Po,listMiddleware as vo,INTENTS as Co,_resetMiddleware as Io}from"./6d238282c1.js";import{onEvent as Ro,onceEvent as Ao,offEvent as _o,listEvents as Eo,emitEvent as bo,EVENTS as wo,_resetEvents as Oo}from"./2e366d7386.js";import{onRequest as Do,onResponse as Bo,setTransport as Lo,hasTransport as Uo,_resetHttp as Fo}from"./a3f18e76fe.js";import{readBom as Go,readQuote as ko,readGeneratedAssets as No,setMetadata as Vo,readMetadata as Ho,serializeMetadata as jo,restoreMetadata as Wo,METADATA_LIMITS as Ko,_resetMetadata as $o}from"./3656ffa1b8.js";import{collectGenericBom as Yo,collectGenericBom as zo,collectPlacementParts as Jo}from"./81802759ca.js";import{readBounds as Zo,onSettled as er}from"./da7b5f450d.js";import{registerComponentRenderer as or,resolveComponentRenderer as rr,listComponentRenderers as nr,registerMaterialResolver as ar,listMaterialResolvers as sr,registerInteraction as lr,runInteraction as cr,listInteractions as ir,onSceneReady as ur,getSceneContext as dr,_resetSceneRegistry as mr}from"./95a44ebec2.js";import{registerAction as fr,runAction as gr,listActions as Sr,actions as yr,registerIcon as hr,resolveIcon as xr,listIcons as Pr,hasIcon as vr,useIcon as Cr,useHasIcon as Ir,registerModal as Tr,listModals as Rr,ModalHost as Ar,openModal as _r,_resetUiRegistry as Er}from"./09c4973968.js";import{setLabels as wr,getLabel as Or,getLabels as Mr,useLabel as Dr,setLocale as Br,getLocale as Lr,setCurrency as Ur,getCurrency as Fr,isRtl as Qr,formatMoney as Gr,formatNumber as kr,useFormatters as Nr,useLabels as Vr,_resetLabels as Hr}from"./28d887bf8a.js";import{computeTargets as Wr,resolveTarget as Kr,registerTargetRenderer as $r,resolveTargetRenderer as qr,resolveInsertSequence as Yr,_resetTargets as zr}from"./58e6419ba8.js";import{default as Xr}from"./205827c5c8.js";import{registerQuoteTemplate as en,resolveQuoteTemplate as tn,hasQuoteTemplate as on,useQuoteTemplate as rn,setQuoteTemplate as nn,setBackendQuoteTemplate as an,activeQuoteTemplateKey as sn,activeQuoteDesignKey as ln,listQuoteTemplates as cn,_resetQuoteTemplate as un}from"./4ba4f544b9.js";import{useUIRegion as mn,useUIRegions as pn,getUIRegions as fn,UI_REGIONS as gn}from"./9840b9ce12.js";import{default as yn}from"./b976df09ec.js";import{default as xn}from"./6c0a2572dd.js";import{default as vn}from"./cdb4a0f7b3.js";import{default as In}from"./0f7c8345a8.js";import{default as Rn}from"./82a8a4bc35.js";import{default as _n}from"./e379e0039b.js";import{registerRoute as bn,resolveRoute as wn,hasRoute as On,listRoutes as Mn,useRouteRegistry as Dn,_resetRoutes as Bn}from"./61e0c0c9b5.js";import{hideComponent as Un,showComponent as Fn,transformComponent as Qn,setComponentMaterial as Gn,clearComponentOverrides as kn,listComponents as Nn,componentOverrideFor as Vn,useComponentOverride as Hn,_resetComponentApi as jn}from"./a3c983d431.js";import{setToggles as Kn,getToggles as $n,useHostToggles as qn,_resetToggles as Yn}from"./41ed5985ad.js";import{registerAssetResolver as Jn,hasAssetResolver as Xn,resolveAssetUrl as Zn,_resetAssetResolver as ea}from"./cec035efb1.js";import{registerButton as oa}from"./f1b3b2622a.js";import{SaveProjectButton as na,GenerateAssetsButton as aa,LiveStatusPanel as sa,ChatBar as la,NotificationContainer as ca,EvaluatingOverlay as ia,Modals as ua,SaveProjectModal as da,ExportModal as ma,ARModal as pa,GeneratedAssetsModal as fa,Header as ga,SceneToolbar as Sa,Sidebar as ya,SidebarFrame as ha,OptionSidebar as xa,LoadingScreen as Pa,ConfirmDialog as va,Modal as Ca,Button as Ia,ARViewer as Ta,SceneRoom as Ra,SceneDimensions as Aa,CameraAnimator as _a}from"./64e9020b49.js";import{default as ba}from"./921bf270dd.js";import{registerLayout as Oa,resolveLayout as Ma,hasLayout as Da,listLayouts as Ba,useLayoutRegistry as La,setLayout as Ua,activeLayoutKey as Fa,_resetLayouts as Qa}from"./31ea036f5c.js";import{setQuoteDocument as ka,getQuoteDocument as Na,hasQuoteDocument as Va,resetQuoteDocument as Ha,subscribeQuoteDocument as ja,QUOTE_COLUMNS as Wa,COLUMN_DEFS as Ka}from"./12b8165d6d.js";import{useQuoteDocument as qa}from"./d464da28a5.js";import{generateSilo as za,generateLifestyle as Ja,generateAr as Xa,generateBomPdf as Za,generateAll as es,generationStatus as ts,waitForAssets as os,ASSET_GROUPS as rs}from"./5d05e8982e.js";import{buildQuotePdfBlob as as,saveQuotePdf as ss,registerQuotePdf as ls,registerQuotePdfEndpoint as cs,hasQuotePdf as is,listQuotePdfBuilders as us,_resetQuotePdf as ds}from"./d20718159b.js";import{configureSDK as ps}from"./db4afd43c9.js";import{default as gs}from"./7206ce49c6.js";import{default as ys}from"./d0f9681634.js";import{default as xs}from"./2990ba64d6.js";import{useSelection as vs,useProducts as Cs,usePrice as Is}from"./16a399703e.js";import{getProduct as Rs,getProductName as As,getPlacedProductName as _s,getProductVariants as Es,listProducts as bs,getOptionSet as ws,getOption as Os,useProduct as Ms,listOptionSets as Ds,listSceneOptionSets as Bs,listProductOptionSets as Ls,listOptions as Us,listMaterials as Fs,getMaterial as Qs}from"./1458417bdb.js";import{useBootStatus as ks,useSystem as Ns,endBootLoading as Vs,markThemeReady as Hs,setEmbedded as js,setSystemTheme as Ws}from"./066fc9aa40.js";import{default as $s}from"./60d697292c.js";import{default as Ys}from"./811b403d43.js";import{default as Js}from"./6ba86aa3b8.js";import{default as Zs}from"./3fb3ab6757.js";import{OptionThumbnail as tl,FinishThumbnail as ol,LayoutThumbnail as rl,HostedProductThumbnail as nl,WidthSlider as al,ColorSwatch as sl,FrameSizeButton as ll,ProductFeaturePickers as cl}from"./c12c112c6f.js";import{loadWallMaterial as ul,getConcreteWallMaterial as dl,getWallBoxMaterials as ml,createWallDiffuse as pl,createWallNormalMap as fl,createWallRoughnessMap as gl}from"./22bd38ddcf.js";import{SelectionBox as yl,SELECTION_COLOR as hl,SelectionActionPanel as xl,ProductInstance as Pl,ComponentMesh as vl,FreeMovable as Cl,PlacementGaps as Il,SceneStage as Tl,SceneEnvironment as Rl,applyEnvironmentToRenderer as Al}from"./8a3a57c008.js";import{PLACEMENT_TYPES as El,getPlacementType as bl,resolveReplaceTarget as wl}from"./4d7a0d1897.js";import{FEATURE_ACTIONS as Ml,resolveFeatureAction as Dl,isAddFeature as Bl}from"./8c27edda0f.js";import{getPlacementStrategy as Ul,resolvePlacementStrategyId as Fl,setPlacementStrategy as Ql,clearPlacementStrategy as Gl,getPlacementStrategyOverride as kl,resolvePlacementStrategyConfig as Nl,setPlacementStrategyConfig as Vl,DEFAULT_STRATEGY_ID as Hl,STRATEGIES as jl}from"./281cf952fa.js";import{default as Kl}from"./a493e9aa8f.js";import{registerPlacementStrategy as ql,hasPlacementStrategy as Yl,listPlacementStrategies as zl,currentConfiguratorKey as Jl,_resetPlacementStrategies as Xl}from"./281cf952fa.js";import{enforceCorners as ec}from"./388cadacbd.js";import{resolveAddMode as oc,armPlacement as rc,disarmPlacement as nc,getPendingPlacement as ac,computeGaps as sc}from"./ab6c80484f.js";import{armHostedProduct as cc,disarmHostedProduct as ic}from"./ab6c80484f.js";import{usePlacementInteraction as dc}from"./4b8958aa4c.js";import{bootConfigurator as pc}from"./371ed78aa2.js";import{setAllowedOrigins as gc,getAllowedOrigins as Sc}from"./1e243363f6.js";import{mountConfigurator as hc}from"./1870fc037b.js";import*as xc from"./d30f1f506e.js";export*from"./2cafe3274b.js";import{registerCommand as Cc,runCommand as Ic,hasCommand as Tc,listCommands as Rc,resetCommands as Ac,COMMANDS as _c}from"./d6851ea979.js";import{captureDesignViews as bc,buildDesignPdf as wc,saveProject as Oc,loadProject as Mc,restoreProject as Dc,parseShareToken as Bc,buildShareUrl as Lc,adoptShareTokenInUrl as Uc,generateArForCurrentScene as Fc}from"./d30f1f506e.js";import{default as Gc}from"./be337ddda5.js";import{default as Nc}from"./872c4302e0.js";import{default as Hc}from"./9c6c598569.js";import{default as Wc}from"./8f60e5059a.js";import{default as $c}from"./1fac915f8b.js";import{default as Yc}from"./3f37665dd1.js";import{default as Jc,fetchEmbedBoot as Xc}from"./79a397bb92.js";import{getApiKey as ei}from"./431a2d8618.js";import{setApiBaseUrl as oi,getApiBaseUrl as ri}from"./8ade32d067.js";import{setServiceUrls as ai}from"./9544661159.js";import{applyTheme as li,applyThemeById as ci,themeMode as ii,normalizeThemeId as ui,themeLayoutKey as di}from"./5c9fd9201c.js";import{validateTheme as pi,checkThemeContrast as fi,contrastRatio as gi,applyCustomCss as Si,applyFontUrl as yi}from"./b1349d5a21.js";import{default as xi}from"./f11a45a150.js";import{setEmbedContext as vi,trackEmbed as Ci}from"./0af28430ab.js";import{CopilotContext as Ti,useCopilotAvailable as Ri}from"./672404d987.js";import{checkCopilotAvailability as _i,getCopilotRuntimeUrl as Ei,getCopilotWarmupUrl as bi,getCopilotApiUrl as wi,setCopilotApiUrl as Oi}from"./fe58a84b85.js";export{pa as ARModal,Ta as ARViewer,rs as ASSET_GROUPS,Ia as Button,Ka as COLUMN_DEFS,_c as COMMANDS,_a as CameraAnimator,la as ChatBar,sl as ColorSwatch,vl as ComponentMesh,Rn as ConfigurationSummary,va as ConfirmDialog,Ti as CopilotContext,Hl as DEFAULT_STRATEGY_ID,vn as DefaultQuoteTemplate,wo as EVENTS,ia as EvaluatingOverlay,ma as ExportModal,Ml as FEATURE_ACTIONS,ol as FinishThumbnail,ll as FrameSizeButton,Cl as FreeMovable,aa as GenerateAssetsButton,fa as GeneratedAssetsModal,ga as Header,nl as HostedProductThumbnail,Co as INTENTS,rl as LayoutThumbnail,sa as LiveStatusPanel,Pa as LoadingScreen,Ko as METADATA_LIMITS,Ca as Modal,Ar as ModalHost,ua as Modals,ca as NotificationContainer,Zs as OptionSetSection,xa as OptionSidebar,tl as OptionThumbnail,El as PLACEMENT_TYPES,Il as PlacementGaps,Xr as PlacementTargets,gs as Popover,cl as ProductFeaturePickers,Pl as ProductInstance,Wa as QUOTE_COLUMNS,_n as QuoteQr,In as QuoteRenders,xn as QuoteView,hl as SELECTION_COLOR,jl as STRATEGIES,na as SaveProjectButton,da as SaveProjectModal,Aa as SceneDimensions,Rl as SceneEnvironment,Ra as SceneRoom,Tl as SceneStage,Sa as SceneToolbar,xl as SelectionActionPanel,yl as SelectionBox,ya as Sidebar,ha as SidebarFrame,So as SlotHost,gn as UI_REGIONS,al as WidthSlider,ea as _resetAssetResolver,jn as _resetComponentApi,uo as _resetComponents,no as _resetEventBus,Oo as _resetEvents,Fo as _resetHttp,Hr as _resetLabels,Qa as _resetLayouts,$o as _resetMetadata,Io as _resetMiddleware,Xl as _resetPlacementStrategies,ds as _resetQuotePdf,un as _resetQuoteTemplate,Bn as _resetRoutes,mr as _resetSceneRegistry,yo as _resetSlots,zr as _resetTargets,Yn as _resetToggles,Er as _resetUiRegistry,yr as actions,Fa as activeLayoutKey,ln as activeQuoteDesignKey,sn as activeQuoteTemplateKey,ve as addProduct,$e as addProductFromOption,Uc as adoptShareTokenInUrl,Jc as apiService,eo as applyBackendPricing,Si as applyCustomCss,Al as applyEnvironmentToRenderer,yi as applyFontUrl,et as applyLayoutPreset,qt as applySceneConfigDefaults,li as applyTheme,ci as applyThemeById,cc as armHostedProduct,rc as armPlacement,pc as bootConfigurator,Wt as buildCanonicalState,wc as buildDesignPdf,he as buildFocusContext,as as buildQuotePdfBlob,Lc as buildShareUrl,bc as captureDesignViews,qe as changeProductVariant,_i as checkCopilotAvailability,fi as checkThemeContrast,kn as clearComponentOverrides,Gl as clearPlacementStrategy,rt as clearProductOption,nt as clearSceneOption,It as clearSessionToken,zo as collectBom,Yo as collectGenericBom,Jo as collectPlacementParts,Vn as componentOverrideFor,sc as computeGaps,Wr as computeTargets,ps as configureSDK,gi as contrastRatio,pl as createWallDiffuse,fl as createWallNormalMap,gl as createWallRoughnessMap,Jl as currentConfiguratorKey,zt as dequeuePieceAdd,ic as disarmHostedProduct,nc as disarmPlacement,At as dispatch,bo as emitEvent,Vs as endBootLoading,ec as enforceCorners,Xc as fetchEmbedBoot,Gr as formatMoney,kr as formatNumber,es as generateAll,Xa as generateArAsset,Fc as generateArForCurrentScene,Za as generateBomPdf,Ja as generateLifestyle,za as generateSilo,ts as generationStatus,ri as getApiBaseUrl,ei as getApiKey,Mt as getBindingAvailable,pt as getChannelId,dl as getConcreteWallMaterial,wt as getConfigState,wi as getCopilotApiUrl,Ei as getCopilotRuntimeUrl,bi as getCopilotWarmupUrl,Fr as getCurrency,Lt as getEffectiveSelections,gt as getEmbedSlug,$t as getHostedProductSpawnSelections,Sc as getIframeAllowedOrigins,Or as getLabel,Mr as getLabels,Lr as getLocale,Qs as getMaterial,Os as getOption,ws as getOptionSet,ac as getPendingPlacement,_s as getPlacedProductName,Dt as getPlacementBinding,Bt as getPlacementBindings,Qt as getPlacementOverrides,Ul as getPlacementStrategy,kl as getPlacementStrategyOverride,bl as getPlacementType,Rs as getProduct,As as getProductName,Es as getProductVariants,Na as getQuoteDocument,Ot as getResolved,dr as getSceneContext,st as getSelectedSystemId,Tt as getSessionScope,yt as getShareToken,Gt as getSlotOverride,$n as getToggles,fn as getUIRegions,bt as getVersion,ml as getWallBoxMaterials,Xn as hasAssetResolver,Tc as hasCommand,co as hasComponent,vr as hasIcon,Da as hasLayout,Yl as hasPlacementStrategy,Va as hasQuoteDocument,is as hasQuotePdf,on as hasQuoteTemplate,On as hasRoute,go as hasSlot,Uo as hasTransport,Un as hideComponent,Kt as hostedProductPlacementId,fe as initConfigEngine,Bl as isAddFeature,xt as isReadOnlyCredential,Qr as isRtl,Sr as listActions,Rc as listCommands,io as listComponentOverrides,nr as listComponentRenderers,Nn as listComponents,Eo as listEvents,Pr as listIcons,ir as listInteractions,Ba as listLayouts,sr as listMaterialResolvers,Fs as listMaterials,vo as listMiddleware,Rr as listModals,Ds as listOptionSets,Us as listOptions,zl as listPlacementStrategies,Ls as listProductOptionSets,bs as listProducts,us as listQuotePdfBuilders,cn as listQuoteTemplates,Mn as listRoutes,Bs as listSceneOptionSets,fo as listSlots,Ie as loadConfigurator,Mc as loadProject,ul as loadWallMaterial,Hs as markThemeReady,hc as mountConfigurator,Ze as moveProduct,ui as normalizeThemeId,_o as offEvent,oo as on,Ro as onEvent,Pt as onReadOnlyChange,Do as onRequest,Bo as onResponse,ur as onSceneReady,er as onSceneSettled,Ao as onceEvent,_r as openModal,Bc as parseShareToken,lt as pilotFinishSelect,We as placeHostedProduct,Kl as placementKit,xc as projects,Yt as queuePieceAdd,Go as readBom,No as readGeneratedAssets,Ho as readMetadata,ko as readQuote,Zo as readSceneBounds,Zt as recomputePrice,ye as reevaluateForFocus,Je as refreshCanonicalState,fr as registerAction,Jn as registerAssetResolver,oa as registerButton,Cc as registerCommand,so as registerComponent,or as registerComponentRenderer,ro as registerEffectHandler,hr as registerIcon,lr as registerInteraction,Oa as registerLayout,ar as registerMaterialResolver,Tr as registerModal,ql as registerPlacementStrategy,ls as registerQuotePdf,cs as registerQuotePdfEndpoint,en as registerQuoteTemplate,bn as registerRoute,po as registerSlot,$r as registerTargetRenderer,Xe as removeProduct,Ac as resetCommands,Ut as resetConfigState,Ha as resetQuoteDocument,oc as resolveAddMode,Zn as resolveAssetUrl,lo as resolveComponent,Vt as resolveComponentMaterial,rr as resolveComponentRenderer,kt as resolveComponentTransform,Nt as resolveComponentVisibility,Dl as resolveFeatureAction,xr as resolveIcon,Yr as resolveInsertSequence,Ma as resolveLayout,Nl as resolvePlacementStrategyConfig,Fl as resolvePlacementStrategyId,tn as resolveQuoteTemplate,wl as resolveReplaceTarget,wn as resolveRoute,Kr as resolveTarget,qr as resolveTargetRenderer,tt as restoreConfiguration,Wo as restoreMetadata,Dc as restoreProject,gr as runAction,Ic as runCommand,Po as runIntent,cr as runInteraction,Oc as saveProject,ss as saveQuotePdf,Ye as seedInitialState,xe as selectOptionForProduct,Ke as selectOptionForScene,at as selectSystem,jo as serializeMetadata,oi as setApiBaseUrl,dt as setApiKey,an as setBackendQuoteTemplate,mt as setChannelId,Gn as setComponentMaterial,Oi as setCopilotApiUrl,Ur as setCurrency,vi as setEmbedContext,ft as setEmbedSlug,js as setEmbedded,gc as setIframeAllowedOrigins,wr as setLabels,Ua as setLayout,Br as setLocale,Vo as setMetadata,Ql as setPlacementStrategy,Vl as setPlacementStrategyConfig,ka as setQuoteDocument,nn as setQuoteTemplate,ot as setRoomDimensions,ai as setServiceUrls,St as setShareToken,Ws as setSystemTheme,Kn as setToggles,Ct as setTokenProvider,Lo as setTransport,Fn as showComponent,Et as subscribe,ja as subscribeQuoteDocument,ct as teardownConfigEngine,di as themeLayoutKey,ii as themeMode,Ci as trackEmbed,Qn as transformComponent,Ce as transformProduct,xo as use,xi as useAppVersion,ks as useBootStatus,Hn as useComponentOverride,Gc as useConfigurationGraphStore,Ri as useCopilotAvailable,Nr as useFormatters,ba as useGenerateAssets,Yc as useGeneratedAssetsStore,Ir as useHasIcon,qn as useHostToggles,Cr as useIcon,Dr as useLabel,Vr as useLabels,La as useLayoutRegistry,Nc as useObjectGraphStore,xs as useOptionSets,dc as usePlacementInteraction,Is as usePrice,Ms as useProduct,$s as useProductOrder,Js as useProductOverrides,Cs as useProducts,qa as useQuoteDocument,rn as useQuoteTemplate,yn as useReadOnly,Dn as useRouteRegistry,Hc as useSceneGraphStore,vs as useSelection,Ys as useSelectionActions,Ns as useSystem,ys as useToolbar,mn as useUIRegion,pn as useUIRegions,Wc as useUIStore,$c as useUndoRedoStore,pi as validateTheme,os as waitForAssets,Jt as wasPieceAddConsumed};
|
|
1
|
+
import g from"./be337ddda5.js";import v from"./9c6c598569.js";import P from"./872c4302e0.js";import T from"./8f60e5059a.js";import B from"./1fac915f8b.js";import I from"./d94df858ea.js";import{dispatch as y,setRefetchCatalogHandler as L,setFocusProvider as U,setRejectionHandler as $,setEvaluationStateHandler as q}from"./776277593f.js";import{coalescedDispatch as b}from"./4e1db1e3b0.js";import{dispatchEvents as F,dispatchCustomEffects as Q}from"./970313b92b.js";import{emitEvent as h,EVENTS as x}from"./2e366d7386.js";import{setConfigState as d,setInitial as Y,resetConfigState as z}from"./817d930a49.js";import{buildCanonicalState as p,applyResolvedToScene as k,applyRemovedPlacements as G,applyAddedPlacements as V,applyWarnings as J,applyMessages as _,applyWallMountedPlacements as X,applyPresetPieceTrims as Z,applyInitialSelections as ee,applySelectionOverrides as te,getHostedProductSpawnSelections as oe,applyResolvedPieceAdds as re,hydrateProductInstancesFromState as H,syncOwnedInstanceVariants as ne,applyOwnedTransforms as ae}from"./bcd44b4040.js";import{applyBackendPricing as N}from"./67f6338a4a.js";import{fetchInitialConfiguration as se}from"./fbd844f2d1.js";import*as m from"./3c916f744f.js";import{resolveReplaceTarget as le}from"./4d7a0d1897.js";import{resolveHostVariantId as ce}from"./be07a7f885.js";import{authHeaders as ie,isAuthFailure as ue,reportAuthFailure as de}from"./431a2d8618.js";import{assertLicensed as pe}from"./fe235d7160.js";import{setApiKey as gt,setChannelId as St,getChannelId as yt,setEmbedSlug as ht,getEmbedSlug as xt,setShareToken as vt,getShareToken as Pt}from"./431a2d8618.js";import{isReadOnlyCredential as Ct,onReadOnlyChange as Rt}from"./431a2d8618.js";import{setTokenProvider as At,clearSessionToken as bt,getSessionScope as Et}from"./33fa2c8ca2.js";import{getApiBaseUrl as me}from"./8ade32d067.js";async function fe(){const e=g.getState().systemId;try{const t=`/api/v1/systems/${e}/`;await pe(t);const r=await fetch(`${me()}${t}`,{cache:"no-store",headers:{...ie(t)}});ue(r)&&await de(r,{url:t,method:"GET"});const o=await r.json(),n=o?.catalogVersion??o?.catalog_version??null;return n!=null&&g.setState({catalogVersion:n}),{catalogVersion:n}}catch{return{catalogVersion:g.getState().catalogVersion}}}let w=0;function M(e){w=Math.max(0,w+(e?1:-1));try{T.setState({isEvaluating:w>0})}catch{}}function j(e){const t=e?.uiToggles??e?.ui_toggles??null;if(!(!t||typeof t!="object"))try{P.getState().mergeSystemUiToggles(t)}catch{}}function ge(e){const t=e?.placementBoundsExclude??e?.placement_bounds_exclude??e?.state?.placementBoundsExclude??e?.state?.placement_bounds_exclude??e?.system?.placementBoundsExclude??e?.system?.placement_bounds_exclude??null,r=t?.componentIds??t?.component_ids??null,o=Array.isArray(r)?r.map(n=>String(n)):[];try{P.setState({placementBoundsExcludeIds:o})}catch{}}async function Se({onRefetchCatalog:e}={}){L(e||fe),U(ve),$(t=>{try{T.getState().showWarning?.(D(t))}catch{}}),q(M),ye(),d(p())}let C=null,A=null;function ye(){if(C){try{C()}catch{}C=null}C=v.subscribe(e=>`${e.selectedInstanceId??""}|${e.selectedComponentId??""}`,()=>{A&&clearTimeout(A),A=setTimeout(()=>{xe()},120)})}function he(){if(A&&(clearTimeout(A),A=null),C){try{C()}catch{}C=null}}async function xe(){let e=null;try{e=v.getState().selectedInstanceId}catch{}try{if(T.getState().isLayoutLoading)return null}catch{}d(p());let t=null;try{t=await b(m.noop())}catch{return null}return f(t)}function ve(){const e=v.getState(),t=e.selectedInstanceId;if(t==null)return{};if(String(t).endsWith("__host")){const a=String(t).replace(/__host$/,""),s=(e.productInstances||{})[a]||null,l=P.getState(),c=s?l.getProduct?.(s.variantId??s.productId):null,i=ce(c,s),u={placementId:String(t)};return i!=null&&(u.variantId=i),u.componentId=e.selectedComponentId??null,u}const r=(e.productInstances||{})[String(t)]||null,o=r?.variantId??r?.productId??null,n={placementId:String(t)};return o!=null&&(n.variantId=o),n.componentId=e.selectedComponentId??null,n}async function Pe(e,t,r,o){const n=e&&typeof e=="object"?e:{placementId:e,optionSetId:t,optionId:r,...o||{}},{placementId:a,optionSetId:s,optionId:l,optimistic:c,rollback:i}=n;if(a==null||s==null||l==null)return null;try{if(v.getState().productInstances?.[String(a)]?.locked)return T.getState().showWarning?.("This item is locked and can\u2019t be changed."),null}catch{}d(p());let u=null;try{u=await b(m.selectOption(a,s,l),{optimistic:c,rollback:i})}catch{return null}return f(u)}async function qe(e,t,r){const o=e&&typeof e=="object"?e:{placementId:e,variantId:t,...r||{}},{variantId:n,optimistic:a,rollback:s}=o,l=o.placementId!=null?String(o.placementId).replace(/__host$/,""):null;if(l==null||n==null)return null;try{if(v.getState().productInstances?.[l]?.locked)return T.getState().showWarning?.("This item is locked and can\u2019t be changed."),null}catch{}d(p());let c=null;try{c=await y(m.changeHostVariant(l,n),{optimistic:a,rollback:s})}catch{return h(x.ERROR,{op:"changeHostVariant"}),null}return f(c)}async function Ye(e){if(e==null)return null;const{osId:t,assignments:r}=oe(),o=r.find(s=>String(s.instanceId)===String(e));if(t==null||!o)return null;d(p({excludeHostedProductInstanceId:e}));const n=Number(t)||t;let a=null;try{a=await y(m.selectOption(o.pieceId,n,o.optionId))}catch{return null}return f(a)}async function ze(e,t,r){const o=e&&typeof e=="object"?e:{optionSetId:e,optionId:t,...r||{}},{optionSetId:n,optionId:a,optimistic:s,rollback:l}=o;if(n==null||a==null)return null;const c=I.getState(),i=c.sceneSelections?.[n];c.setSceneSelection?.(n,a),d(p());let u=null;try{u=await b(m.selectSystemOption(n,a),{optimistic:s,rollback:l})}catch{return I.getState().setSceneSelection?.(n,i),null}return u&&u.rejected&&I.getState().setSceneSelection?.(n,i),f(u)}async function Je({optionSetId:e,optionId:t,overrides:r={}}={}){if(e==null||t==null)return null;const o=P.getState().options||{},n=o[t]||o[String(t)];if(!n)return null;const a=n.value??n.valueText??n.value_text,s=P.getState().products||{},l=a!=null?s[a]||s[String(a)]:null;if(!l&&r.productGraphId==null)return null;const c=r.productGraphId??l?.productGraph??l?.product_graph??l?.productGraphId??null,i=r.placementGroup??l?.placementGroup??l?.placement_group??null,u=r.variantId??a,S=r.replacePlacementId!==void 0?r.replacePlacementId:le({placementGroup:i});return Ce({productGraphId:c,variantId:u,placementGroup:i,position:r.position,replace:S!=null,replacePlacementId:S})}async function Xe(e,t,r){const o=e&&typeof e=="object"?e:{placementId:e,variantId:t,...r||{}},{placementId:n,variantId:a,optimistic:s,rollback:l}=o;if(n==null||a==null)return null;d(p());let c=null;try{c=await b(m.changeVariant(n,a),{optimistic:s,rollback:l})}catch{return null}return f(c)}function W(){let e=null,t=null;try{e=g.getState().systemId??null}catch{}try{const r=v.getState(),o=g.getState();t=r.activeSceneConfigId||o.defaultPresetId||Object.keys(o.sceneConfigurations||{})[0]||null}catch{}return e==null?null:`${e}|${t??""}`}let E=null;const O=new Set;async function Ze({force:e=!1}={}){const t=W();if(!e&&t!=null&&O.has(t))return null;if(E)return E;E=Ie(),M(!0);try{const r=await E;t!=null&&O.add(t);const o=W();return o!=null&&O.add(o),r}finally{E=null,M(!1)}}async function Ie(){const e=g.getState().systemId;if(e==null)return null;const t=v.getState().activeSceneConfigId??null;let r=null;try{r=await se({systemId:e,presetId:t})}catch{return null}if(j(r?.system),ge(r),!r?.state)return null;Y(r);try{ee(r.state)}catch{}try{_(r.messages)}catch{}try{_(r.customDiagnostics)}catch{}try{F(r.events)}catch{}try{Q(r.customEffects)}catch{}try{const o=r.state.sceneId??r.state.scene_id;o!=null&&v.getState().setActiveSceneId?.(o)}catch{}try{Z(r.removedPlacements)}catch{}try{G(r.removedPlacements)}catch{}try{X(r.state)}catch{}try{V(r.addedPlacements,r.state)}catch{}try{H(r.state)}catch{}try{k(r.state)}catch{}try{ae(r.state)}catch{}try{N(r.pricing)}catch{}try{I.getState().markSceneSelectionsSettled?.()}catch{}try{h(x.READY,{systemId:r?.state?.systemId??null})}catch{}return r}function D(e){const r=(Array.isArray(e?.errors)?e.errors:[]).map(n=>typeof n=="string"?n:n?.message??n?.detail??null).filter(Boolean),o=[...new Set(r)];return o.length?o.join(" "):"That change isn\u2019t allowed by the current design rules \u2014 reverted."}function et(e){const t=T.getState();if(t.isLayoutLoading||t._snapshotOverridesOnLoadComplete){try{t.showWarning?.(D(e))}catch{}return}try{t.showError?.(D(e))}catch{}if((B.getState().past||[]).length>0)try{B.getState().undo()}catch{}}async function tt(){try{d(p())}catch{}return null}function f(e){if(j(e?.system),e&&e.applied&&e.resolvedState&&(k(e.resolvedState),G(e.removedPlacements),V(e.addedPlacements,e.resolvedState),re(e.resolvedState),H(e.resolvedState),ne(e.resolvedState),te(e.selectionOverrides),J(e.warnings)),e){try{_(e.messages)}catch{}try{_(e.customDiagnostics)}catch{}try{F(e.events)}catch{}try{Q(e.customEffects)}catch{}try{e.pricing&&N(e.pricing)}catch{}}return e}async function Ce({productGraphId:e,variantId:t,placementGroup:r,position:o,sequence:n,hostPlacementId:a,hostVariantId:s,replace:l,replacePlacementId:c,excludePieceIndex:i,optimistic:u,rollback:S}={}){d(p(i!=null?{excludePieceIndex:i}:{}));let R=null;try{R=await y(m.addPlacement({productGraphId:e,variantId:t,placementGroup:r,position:o,sequence:n,hostPlacementId:a,hostVariantId:s,replace:l,replacePlacementId:c}),{optimistic:u,rollback:S})}catch{return h(x.ERROR,{op:"addPlacement"}),null}const K=f(R);return R?.applied&&h(x.PRODUCT_ADDED,{variantId:t,productGraphId:e,placementGroup:r,placementIds:Object.keys(R?.resolvedState?.placements||{})}),K}async function ot(e,{optimistic:t,rollback:r}={}){if(e==null)return null;d(p());let o=null;try{o=await y(m.removePlacement(e),{optimistic:t,rollback:r})}catch{return h(x.ERROR,{op:"removePlacement"}),null}const n=f(o);return o?.applied&&h(x.PRODUCT_REMOVED,{placementId:e}),n}async function rt({placementId:e,sequence:t,placementGroup:r,position:o,rotation:n,hostPlacementId:a,hostVariantId:s,optimistic:l,rollback:c}={}){if(e==null)return null;if(!(t!=null&&Number.isInteger(Number(t))))return o!=null||n!=null?Re(e,o,n):null;d(p());let u=null;try{u=await y(m.movePlacement({placementId:e,sequence:Number(t),placementGroup:r,position:o,rotation:n,hostPlacementId:a,hostVariantId:s}),{optimistic:l,rollback:c})}catch{return h(x.ERROR,{op:"movePlacement"}),null}const S=f(u);return u?.applied&&h(x.PRODUCT_MOVED,{placementId:e,sequence:Number(t)}),S}async function nt(e,{optimistic:t,rollback:r}={}){if(e==null)return null;d(p());let o=null;try{o=await y(m.applyPreset(e),{optimistic:t,rollback:r})}catch{return h(x.ERROR,{op:"applyPreset"}),null}const n=f(o);return o?.applied&&h(x.LAYOUT_CHANGED,{presetId:e}),n}async function at(e,{optimistic:t,rollback:r}={}){if(!e)return null;let o=null;try{o=await y(m.restoreState(e),{optimistic:t,rollback:r})}catch{return null}return f(o)}async function st(e,t,r,{optimistic:o,rollback:n}={}){d(p());let a=null;try{a=await b(m.setRoomDimensions(e,t,r),{optimistic:o,rollback:n})}catch{return null}return f(a)}async function lt(e,t,{optimistic:r,rollback:o}={}){if(e==null||t==null)return null;d(p());let n=null;try{n=await y(m.clearSelection(e,t),{optimistic:r,rollback:o})}catch{return null}return f(n)}async function ct(e,{optimistic:t,rollback:r}={}){if(e==null)return null;const o=I.getState(),n=o.sceneSelections?.[e],a=P.getState(),s=a.features?.[e]??a.features?.[String(e)],l=s?.defaultOption??s?.default_option_id??s?.default_option??void 0;o.setSceneSelection?.(e,l),d(p());let c=null;try{c=await y(m.clearSystemSelection(e),{optimistic:t,rollback:r})}catch{return I.getState().setSceneSelection?.(e,n),null}if(c&&c.rejected)I.getState().setSceneSelection?.(e,n);else{const i=c?.defaultOptionOverrides?.[e]??c?.defaultOptionOverrides?.[String(e)];i!=null&&I.getState().setSceneSelection?.(e,i)}return f(c)}function Re(e,t,r){if(e==null)return null;const o=String(e),n=v.getState(),a=n.productInstances?.[o];if(!a)return null;const s=Array.isArray(t)?t:null,l=Array.isArray(r)?r:null;if(!s&&!l)return null;s&&n.updateInstancePosition(o,s),l&&n.updateInstanceRotation(o,l);const c=P.getState(),i=c.getProduct?.(a.variantId)||c.getProduct?.(a.productId),u=i?.hostVariants??i?.host_variants,R=!(a.positionedAbove!=null||Array.isArray(u)&&u.length>0)&&!!i?.movable;return d(p()),y(m.setTransform(o,s??a.position,l??a.rotation)),{placementId:o,position:s??a.position??null,rotation:l??a.rotation??null,freeMovable:R}}async function Te(e=null){const t=P.getState(),r=g.getState(),o=typeof window<"u"&&window.location?new URLSearchParams(window.location.search).get("system"):null,n=e??o??null;await t.loadCatalog({systemId:n}),await r.loadConfigurations(n??e);try{const s=g.getState(),l=s.systemDomainDefaults??s.systemRoom?.domain_defaults??null;if(l){const{loadDomainDefaults:c}=await import("./ee242c0099.js");c(l)}}catch{}return Se(),{systemId:g.getState().systemId,sceneConfigurations:g.getState().sceneConfigurations}}const it=(e=null)=>Te(e);function ut(){return g.getState().systemId??null}const dt=({pieceIndex:e,...t}={})=>Pe({placementId:e,...t});function pt(){L(null),U(null),he(),z()}import{dispatch as wt}from"./776277593f.js";import{subscribe as Ot,getVersion as Dt,getConfigState as Bt,getResolved as Lt,getBindingAvailable as Ut,getPlacementBinding as Ft,getPlacementBindings as Qt,getEffectiveSelections as kt,resetConfigState as Gt}from"./817d930a49.js";import{getPlacementOverrides as Ht,getSlotOverride as Nt,resolveComponentTransform as jt,resolveComponentVisibility as Wt,resolveComponentMaterial as Kt}from"./c3b8f1973b.js";export*from"./3c916f744f.js";import{buildCanonicalState as Yt,hostedProductPlacementId as zt,getHostedProductSpawnSelections as Jt,applySceneConfigDefaults as Xt,queuePieceAdd as Zt,dequeuePieceAdd as eo,wasPieceAddConsumed as to}from"./bcd44b4040.js";import{recomputePrice as ro,applyBackendPricing as no}from"./67f6338a4a.js";import{on as so,registerEffectHandler as lo,_resetEventBus as co}from"./970313b92b.js";import{registerComponent as uo,resolveComponent as po,hasComponent as mo,listComponentOverrides as fo,_resetComponents as go}from"./882bc739c8.js";import{registerSlot as yo,listSlots as ho,hasSlot as xo,SlotHost as vo,_resetSlots as Po}from"./73f7d65985.js";import{use as Co,runIntent as Ro,listMiddleware as To,INTENTS as Ao,_resetMiddleware as bo}from"./6d238282c1.js";import{onEvent as _o,onceEvent as wo,offEvent as Mo,listEvents as Oo,emitEvent as Do,EVENTS as Bo,_resetEvents as Lo}from"./2e366d7386.js";import{onRequest as Fo,onResponse as Qo,setTransport as ko,hasTransport as Go,_resetHttp as Vo}from"./a3f18e76fe.js";import{readBom as No,readQuote as jo,readGeneratedAssets as Wo,setMetadata as Ko,readMetadata as $o,serializeMetadata as qo,restoreMetadata as Yo,METADATA_LIMITS as zo,_resetMetadata as Jo}from"./3656ffa1b8.js";import{collectGenericBom as Zo,collectGenericBom as er,collectPlacementParts as tr}from"./81802759ca.js";import{readBounds as rr,onSettled as nr}from"./da7b5f450d.js";import{registerComponentRenderer as sr,resolveComponentRenderer as lr,listComponentRenderers as cr,registerMaterialResolver as ir,listMaterialResolvers as ur,registerInteraction as dr,runInteraction as pr,listInteractions as mr,onSceneReady as fr,getSceneContext as gr,_resetSceneRegistry as Sr}from"./95a44ebec2.js";import{registerAction as hr,runAction as xr,listActions as vr,actions as Pr,registerIcon as Ir,resolveIcon as Cr,listIcons as Rr,hasIcon as Tr,useIcon as Ar,useHasIcon as br,registerModal as Er,listModals as _r,ModalHost as wr,openModal as Mr,_resetUiRegistry as Or}from"./09c4973968.js";import{setLabels as Br,getLabel as Lr,getLabels as Ur,useLabel as Fr,setLocale as Qr,getLocale as kr,setCurrency as Gr,getCurrency as Vr,isRtl as Hr,formatMoney as Nr,formatNumber as jr,useFormatters as Wr,useLabels as Kr,_resetLabels as $r}from"./28d887bf8a.js";import{computeTargets as Yr,resolveTarget as zr,registerTargetRenderer as Jr,resolveTargetRenderer as Xr,resolveInsertSequence as Zr,_resetTargets as en}from"./58e6419ba8.js";import{default as on}from"./205827c5c8.js";import{registerQuoteTemplate as nn,resolveQuoteTemplate as an,hasQuoteTemplate as sn,useQuoteTemplate as ln,setQuoteTemplate as cn,setBackendQuoteTemplate as un,activeQuoteTemplateKey as dn,activeQuoteDesignKey as pn,listQuoteTemplates as mn,_resetQuoteTemplate as fn}from"./4ba4f544b9.js";import{useUIRegion as Sn,useUIRegions as yn,getUIRegions as hn,UI_REGIONS as xn}from"./9840b9ce12.js";import{default as Pn}from"./b976df09ec.js";import{default as Cn}from"./6c0a2572dd.js";import{default as Tn}from"./cdb4a0f7b3.js";import{default as bn}from"./0f7c8345a8.js";import{default as _n}from"./82a8a4bc35.js";import{default as Mn}from"./e379e0039b.js";import{registerRoute as Dn,resolveRoute as Bn,hasRoute as Ln,listRoutes as Un,useRouteRegistry as Fn,_resetRoutes as Qn}from"./61e0c0c9b5.js";import{hideComponent as Gn,showComponent as Vn,transformComponent as Hn,setComponentMaterial as Nn,clearComponentOverrides as jn,listComponents as Wn,componentOverrideFor as Kn,useComponentOverride as $n,_resetComponentApi as qn}from"./a3c983d431.js";import{setToggles as zn,getToggles as Jn,useHostToggles as Xn,_resetToggles as Zn}from"./41ed5985ad.js";import{registerAssetResolver as ta,hasAssetResolver as oa,resolveAssetUrl as ra,_resetAssetResolver as na}from"./cec035efb1.js";import{registerButton as sa}from"./f1b3b2622a.js";import{SaveProjectButton as ca,GenerateAssetsButton as ia,LiveStatusPanel as ua,ChatBar as da,NotificationContainer as pa,EvaluatingOverlay as ma,Modals as fa,SaveProjectModal as ga,ExportModal as Sa,ARModal as ya,GeneratedAssetsModal as ha,Header as xa,SceneToolbar as va,Sidebar as Pa,SidebarFrame as Ia,OptionSidebar as Ca,LoadingScreen as Ra,ConfirmDialog as Ta,Modal as Aa,Button as ba,ARViewer as Ea,SceneRoom as _a,SceneDimensions as wa,CameraAnimator as Ma}from"./64e9020b49.js";import{default as Da}from"./921bf270dd.js";import{registerLayout as La,resolveLayout as Ua,hasLayout as Fa,listLayouts as Qa,useLayoutRegistry as ka,setLayout as Ga,activeLayoutKey as Va,_resetLayouts as Ha}from"./31ea036f5c.js";import{setQuoteDocument as ja,getQuoteDocument as Wa,hasQuoteDocument as Ka,resetQuoteDocument as $a,subscribeQuoteDocument as qa,QUOTE_COLUMNS as Ya,COLUMN_DEFS as za}from"./12b8165d6d.js";import{useQuoteDocument as Xa}from"./d464da28a5.js";import{generateSilo as es,generateLifestyle as ts,generateAr as os,generateBomPdf as rs,generateAll as ns,generationStatus as as,waitForAssets as ss,ASSET_GROUPS as ls}from"./5d05e8982e.js";import{buildQuotePdfBlob as is,saveQuotePdf as us,registerQuotePdf as ds,registerQuotePdfEndpoint as ps,hasQuotePdf as ms,listQuotePdfBuilders as fs,_resetQuotePdf as gs}from"./d20718159b.js";import{configureSDK as ys}from"./db4afd43c9.js";import{default as xs}from"./7206ce49c6.js";import{default as Ps}from"./d0f9681634.js";import{default as Cs}from"./2990ba64d6.js";import{useSelection as Ts,useProducts as As,usePrice as bs}from"./16a399703e.js";import{getProduct as _s,getProductName as ws,getPlacedProductName as Ms,getProductVariants as Os,listProducts as Ds,getOptionSet as Bs,getOption as Ls,useProduct as Us,listOptionSets as Fs,listSceneOptionSets as Qs,listProductOptionSets as ks,listOptions as Gs,listMaterials as Vs,getMaterial as Hs}from"./1458417bdb.js";import{useBootStatus as js,useSystem as Ws,endBootLoading as Ks,markThemeReady as $s,setEmbedded as qs,setSystemTheme as Ys}from"./066fc9aa40.js";import{default as Js}from"./60d697292c.js";import{default as Zs}from"./811b403d43.js";import{default as tl}from"./6ba86aa3b8.js";import{default as rl}from"./3fb3ab6757.js";import{OptionThumbnail as al,FinishThumbnail as sl,LayoutThumbnail as ll,HostedProductThumbnail as cl,WidthSlider as il,ColorSwatch as ul,FrameSizeButton as dl,ProductFeaturePickers as pl}from"./c12c112c6f.js";import{loadWallMaterial as fl,getConcreteWallMaterial as gl,getWallBoxMaterials as Sl,createWallDiffuse as yl,createWallNormalMap as hl,createWallRoughnessMap as xl}from"./22bd38ddcf.js";import{SelectionBox as Pl,SELECTION_COLOR as Il,SelectionActionPanel as Cl,ProductInstance as Rl,ComponentMesh as Tl,FreeMovable as Al,PlacementGaps as bl,SceneStage as El,SceneEnvironment as _l,applyEnvironmentToRenderer as wl}from"./8a3a57c008.js";import{PLACEMENT_TYPES as Ol,getPlacementType as Dl,resolveReplaceTarget as Bl}from"./4d7a0d1897.js";import{FEATURE_ACTIONS as Ul,resolveFeatureAction as Fl,isAddFeature as Ql}from"./8c27edda0f.js";import{getPlacementStrategy as Gl,resolvePlacementStrategyId as Vl,setPlacementStrategy as Hl,clearPlacementStrategy as Nl,getPlacementStrategyOverride as jl,resolvePlacementStrategyConfig as Wl,setPlacementStrategyConfig as Kl,DEFAULT_STRATEGY_ID as $l,STRATEGIES as ql}from"./281cf952fa.js";import{default as zl}from"./a493e9aa8f.js";import{registerPlacementStrategy as Xl,hasPlacementStrategy as Zl,listPlacementStrategies as ec,currentConfiguratorKey as tc,_resetPlacementStrategies as oc}from"./281cf952fa.js";import{enforceCorners as nc}from"./388cadacbd.js";import{resolveAddMode as sc,armPlacement as lc,disarmPlacement as cc,getPendingPlacement as ic,computeGaps as uc}from"./ab6c80484f.js";import{armHostedProduct as pc,disarmHostedProduct as mc}from"./ab6c80484f.js";import{usePlacementInteraction as gc}from"./4b8958aa4c.js";import{bootConfigurator as yc}from"./371ed78aa2.js";import{setAllowedOrigins as xc,getAllowedOrigins as vc}from"./1e243363f6.js";import{mountConfigurator as Ic}from"./1870fc037b.js";import*as Cc from"./d30f1f506e.js";export*from"./2cafe3274b.js";import{registerCommand as Ac,runCommand as bc,hasCommand as Ec,listCommands as _c,resetCommands as wc,COMMANDS as Mc}from"./d6851ea979.js";import{captureDesignViews as Dc,buildDesignPdf as Bc,saveProject as Lc,loadProject as Uc,restoreProject as Fc,parseShareToken as Qc,buildShareUrl as kc,adoptShareTokenInUrl as Gc,generateArForCurrentScene as Vc}from"./d30f1f506e.js";import{default as Nc}from"./be337ddda5.js";import{default as Wc}from"./872c4302e0.js";import{default as $c}from"./9c6c598569.js";import{default as Yc}from"./8f60e5059a.js";import{default as Jc}from"./1fac915f8b.js";import{default as Zc}from"./3f37665dd1.js";import{default as ti,fetchEmbedBoot as oi}from"./79a397bb92.js";import{getApiKey as ni}from"./431a2d8618.js";import{setApiBaseUrl as si,getApiBaseUrl as li}from"./8ade32d067.js";import{setServiceUrls as ii}from"./9544661159.js";import{applyTheme as di,applyThemeById as pi,themeMode as mi,normalizeThemeId as fi,themeLayoutKey as gi}from"./5c9fd9201c.js";import{validateTheme as yi,checkThemeContrast as hi,contrastRatio as xi,applyCustomCss as vi,applyFontUrl as Pi}from"./b1349d5a21.js";import{default as Ci}from"./f11a45a150.js";import{setEmbedContext as Ti,trackEmbed as Ai}from"./0af28430ab.js";import{CopilotContext as Ei,useCopilotAvailable as _i}from"./672404d987.js";import{checkCopilotAvailability as Mi,getCopilotRuntimeUrl as Oi,getCopilotWarmupUrl as Di,getCopilotApiUrl as Bi,setCopilotApiUrl as Li}from"./fe58a84b85.js";export{ya as ARModal,Ea as ARViewer,ls as ASSET_GROUPS,ba as Button,za as COLUMN_DEFS,Mc as COMMANDS,Ma as CameraAnimator,da as ChatBar,ul as ColorSwatch,Tl as ComponentMesh,_n as ConfigurationSummary,Ta as ConfirmDialog,Ei as CopilotContext,$l as DEFAULT_STRATEGY_ID,Tn as DefaultQuoteTemplate,Bo as EVENTS,ma as EvaluatingOverlay,Sa as ExportModal,Ul as FEATURE_ACTIONS,sl as FinishThumbnail,dl as FrameSizeButton,Al as FreeMovable,ia as GenerateAssetsButton,ha as GeneratedAssetsModal,xa as Header,cl as HostedProductThumbnail,Ao as INTENTS,ll as LayoutThumbnail,ua as LiveStatusPanel,Ra as LoadingScreen,zo as METADATA_LIMITS,Aa as Modal,wr as ModalHost,fa as Modals,pa as NotificationContainer,rl as OptionSetSection,Ca as OptionSidebar,al as OptionThumbnail,Ol as PLACEMENT_TYPES,bl as PlacementGaps,on as PlacementTargets,xs as Popover,pl as ProductFeaturePickers,Rl as ProductInstance,Ya as QUOTE_COLUMNS,Mn as QuoteQr,bn as QuoteRenders,Cn as QuoteView,Il as SELECTION_COLOR,ql as STRATEGIES,ca as SaveProjectButton,ga as SaveProjectModal,wa as SceneDimensions,_l as SceneEnvironment,_a as SceneRoom,El as SceneStage,va as SceneToolbar,Cl as SelectionActionPanel,Pl as SelectionBox,Pa as Sidebar,Ia as SidebarFrame,vo as SlotHost,xn as UI_REGIONS,il as WidthSlider,na as _resetAssetResolver,qn as _resetComponentApi,go as _resetComponents,co as _resetEventBus,Lo as _resetEvents,Vo as _resetHttp,$r as _resetLabels,Ha as _resetLayouts,Jo as _resetMetadata,bo as _resetMiddleware,oc as _resetPlacementStrategies,gs as _resetQuotePdf,fn as _resetQuoteTemplate,Qn as _resetRoutes,Sr as _resetSceneRegistry,Po as _resetSlots,en as _resetTargets,Zn as _resetToggles,Or as _resetUiRegistry,Pr as actions,Va as activeLayoutKey,pn as activeQuoteDesignKey,dn as activeQuoteTemplateKey,Ce as addProduct,Je as addProductFromOption,Gc as adoptShareTokenInUrl,ti as apiService,no as applyBackendPricing,vi as applyCustomCss,wl as applyEnvironmentToRenderer,Pi as applyFontUrl,nt as applyLayoutPreset,Xt as applySceneConfigDefaults,di as applyTheme,pi as applyThemeById,pc as armHostedProduct,lc as armPlacement,yc as bootConfigurator,Yt as buildCanonicalState,Bc as buildDesignPdf,ve as buildFocusContext,is as buildQuotePdfBlob,kc as buildShareUrl,Dc as captureDesignViews,qe as changeHostVariantForProduct,Xe as changeProductVariant,Mi as checkCopilotAvailability,hi as checkThemeContrast,jn as clearComponentOverrides,Nl as clearPlacementStrategy,lt as clearProductOption,ct as clearSceneOption,bt as clearSessionToken,er as collectBom,Zo as collectGenericBom,tr as collectPlacementParts,Kn as componentOverrideFor,uc as computeGaps,Yr as computeTargets,ys as configureSDK,xi as contrastRatio,yl as createWallDiffuse,hl as createWallNormalMap,xl as createWallRoughnessMap,tc as currentConfiguratorKey,eo as dequeuePieceAdd,mc as disarmHostedProduct,cc as disarmPlacement,wt as dispatch,Do as emitEvent,Ks as endBootLoading,nc as enforceCorners,oi as fetchEmbedBoot,Nr as formatMoney,jr as formatNumber,ns as generateAll,os as generateArAsset,Vc as generateArForCurrentScene,rs as generateBomPdf,ts as generateLifestyle,es as generateSilo,as as generationStatus,li as getApiBaseUrl,ni as getApiKey,Ut as getBindingAvailable,yt as getChannelId,gl as getConcreteWallMaterial,Bt as getConfigState,Bi as getCopilotApiUrl,Oi as getCopilotRuntimeUrl,Di as getCopilotWarmupUrl,Vr as getCurrency,kt as getEffectiveSelections,xt as getEmbedSlug,Jt as getHostedProductSpawnSelections,vc as getIframeAllowedOrigins,Lr as getLabel,Ur as getLabels,kr as getLocale,Hs as getMaterial,Ls as getOption,Bs as getOptionSet,ic as getPendingPlacement,Ms as getPlacedProductName,Ft as getPlacementBinding,Qt as getPlacementBindings,Ht as getPlacementOverrides,Gl as getPlacementStrategy,jl as getPlacementStrategyOverride,Dl as getPlacementType,_s as getProduct,ws as getProductName,Os as getProductVariants,Wa as getQuoteDocument,Lt as getResolved,gr as getSceneContext,ut as getSelectedSystemId,Et as getSessionScope,Pt as getShareToken,Nt as getSlotOverride,Jn as getToggles,hn as getUIRegions,Dt as getVersion,Sl as getWallBoxMaterials,oa as hasAssetResolver,Ec as hasCommand,mo as hasComponent,Tr as hasIcon,Fa as hasLayout,Zl as hasPlacementStrategy,Ka as hasQuoteDocument,ms as hasQuotePdf,sn as hasQuoteTemplate,Ln as hasRoute,xo as hasSlot,Go as hasTransport,Gn as hideComponent,zt as hostedProductPlacementId,Se as initConfigEngine,Ql as isAddFeature,Ct as isReadOnlyCredential,Hr as isRtl,vr as listActions,_c as listCommands,fo as listComponentOverrides,cr as listComponentRenderers,Wn as listComponents,Oo as listEvents,Rr as listIcons,mr as listInteractions,Qa as listLayouts,ur as listMaterialResolvers,Vs as listMaterials,To as listMiddleware,_r as listModals,Fs as listOptionSets,Gs as listOptions,ec as listPlacementStrategies,ks as listProductOptionSets,Ds as listProducts,fs as listQuotePdfBuilders,mn as listQuoteTemplates,Un as listRoutes,Qs as listSceneOptionSets,ho as listSlots,Te as loadConfigurator,Uc as loadProject,fl as loadWallMaterial,$s as markThemeReady,Ic as mountConfigurator,rt as moveProduct,fi as normalizeThemeId,Mo as offEvent,so as on,_o as onEvent,Rt as onReadOnlyChange,Fo as onRequest,Qo as onResponse,fr as onSceneReady,nr as onSceneSettled,wo as onceEvent,Mr as openModal,Qc as parseShareToken,dt as pilotFinishSelect,Ye as placeHostedProduct,zl as placementKit,Cc as projects,Zt as queuePieceAdd,No as readBom,Wo as readGeneratedAssets,$o as readMetadata,jo as readQuote,rr as readSceneBounds,ro as recomputePrice,xe as reevaluateForFocus,tt as refreshCanonicalState,hr as registerAction,ta as registerAssetResolver,sa as registerButton,Ac as registerCommand,uo as registerComponent,sr as registerComponentRenderer,lo as registerEffectHandler,Ir as registerIcon,dr as registerInteraction,La as registerLayout,ir as registerMaterialResolver,Er as registerModal,Xl as registerPlacementStrategy,ds as registerQuotePdf,ps as registerQuotePdfEndpoint,nn as registerQuoteTemplate,Dn as registerRoute,yo as registerSlot,Jr as registerTargetRenderer,ot as removeProduct,wc as resetCommands,Gt as resetConfigState,$a as resetQuoteDocument,sc as resolveAddMode,ra as resolveAssetUrl,po as resolveComponent,Kt as resolveComponentMaterial,lr as resolveComponentRenderer,jt as resolveComponentTransform,Wt as resolveComponentVisibility,Fl as resolveFeatureAction,Cr as resolveIcon,Zr as resolveInsertSequence,Ua as resolveLayout,Wl as resolvePlacementStrategyConfig,Vl as resolvePlacementStrategyId,an as resolveQuoteTemplate,Bl as resolveReplaceTarget,Bn as resolveRoute,zr as resolveTarget,Xr as resolveTargetRenderer,at as restoreConfiguration,Yo as restoreMetadata,Fc as restoreProject,xr as runAction,bc as runCommand,Ro as runIntent,pr as runInteraction,Lc as saveProject,us as saveQuotePdf,Ze as seedInitialState,Pe as selectOptionForProduct,ze as selectOptionForScene,it as selectSystem,qo as serializeMetadata,si as setApiBaseUrl,gt as setApiKey,un as setBackendQuoteTemplate,St as setChannelId,Nn as setComponentMaterial,Li as setCopilotApiUrl,Gr as setCurrency,Ti as setEmbedContext,ht as setEmbedSlug,qs as setEmbedded,xc as setIframeAllowedOrigins,Br as setLabels,Ga as setLayout,Qr as setLocale,Ko as setMetadata,Hl as setPlacementStrategy,Kl as setPlacementStrategyConfig,ja as setQuoteDocument,cn as setQuoteTemplate,st as setRoomDimensions,ii as setServiceUrls,vt as setShareToken,Ys as setSystemTheme,zn as setToggles,At as setTokenProvider,ko as setTransport,Vn as showComponent,Ot as subscribe,qa as subscribeQuoteDocument,pt as teardownConfigEngine,gi as themeLayoutKey,mi as themeMode,Ai as trackEmbed,Hn as transformComponent,Re as transformProduct,Co as use,Ci as useAppVersion,js as useBootStatus,$n as useComponentOverride,Nc as useConfigurationGraphStore,_i as useCopilotAvailable,Wr as useFormatters,Da as useGenerateAssets,Zc as useGeneratedAssetsStore,br as useHasIcon,Xn as useHostToggles,Ar as useIcon,Fr as useLabel,Kr as useLabels,ka as useLayoutRegistry,Wc as useObjectGraphStore,Cs as useOptionSets,gc as usePlacementInteraction,bs as usePrice,Us as useProduct,Js as useProductOrder,tl as useProductOverrides,As as useProducts,Xa as useQuoteDocument,ln as useQuoteTemplate,Pn as useReadOnly,Fn as useRouteRegistry,$c as useSceneGraphStore,Ts as useSelection,Zs as useSelectionActions,Ws as useSystem,Ps as useToolbar,Sn as useUIRegion,yn as useUIRegions,Yc as useUIStore,Jc as useUndoRedoStore,yi as validateTheme,ss as waitForAssets,to as wasPieceAddConsumed};
|
package/dist/bcd44b4040.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{HOSTED_PLACEMENT_ID_PREFIX as M,isHostedPlacementId as $,stripHostedPlacementPrefix as N}from"./23dc0ccf32.js";import k,{deriveSceneFeatures as U}from"./be337ddda5.js";import G from"./d94df858ea.js";import w from"./9c6c598569.js";import _ from"./8f60e5059a.js";import j from"./872c4302e0.js";import{isHostFloating as B}from"./061b81ad81.js";import{getProductAllComponents as V,pieceKindOf as q}from"./9326c23506.js";import{autoFixAdjacency as z}from"./710c1ab641.js";import{getPlacementStrategy as X}from"./281cf952fa.js";function K(o){const l=o?.features||{};for(const[d,p]of Object.entries(l))if(p?.type==="appliance_selection")return d;const u=new Set(Object.keys(o?.hostedProductByOptionId||{}));if(u.size>0){for(const[d,p]of Object.entries(l))if((Array.isArray(p?.options)?p.options.map(String):[]).some(a=>u.has(a)))return d}return null}function Y(o,l){if(l==null)return!1;const u=o?.products||{},d=u[l]||u[String(l)];return d?String(d.placement_group??d.placementGroup??"").toLowerCase().includes("overlay"):!1}function Q(o=null){const l=_.getState(),u=j.getState(),d=K(u);if(d==null)return{osId:null,assignments:[]};const p=l.basePiecePositions||{},g=l.hostProductOverrides||{},a=Object.keys(p).filter(n=>!Y(u,g[n]??p[n]?.productId)).sort((n,f)=>n.localeCompare(f,void 0,{numeric:!0})),t=[];for(const n of l.sceneHostedProducts||[]){if(o!=null&&String(n.id)===String(o))continue;const f=n.hostedProductId??n.productId??null;if(f==null)continue;const m=u.getHostedProduct?.(f)?.optionId??null;m!=null&&t.push({instanceId:n.id,variantId:f,optionId:m,replacedPiece:n.replacedPiece??null,pos:Array.isArray(n.position)?n.position:null})}const i=new Map;for(const n of t){const f=String(n.optionId),m=i.get(f);(!m||!m.pos&&n.pos)&&i.set(f,n)}const r=[...i.values()],s=new Set,e=[],c=(n,f)=>{const m=p[f]?.position;if(!Array.isArray(m)||!Array.isArray(n))return 1/0;const I=(m[0]??0)-(n[0]??0),b=(m[1]??0)-(n[1]??0),v=(m[2]??0)-(n[2]??0);return I*I+b*b+v*v},S=r.filter(n=>n.pos),y=new Set(S.map(n=>n.instanceId));for(;y.size;){let n=null;for(const f of S)if(y.has(f.instanceId))for(const m of a){if(s.has(m))continue;const I=c(f.pos,m);(n==null||I<n.d)&&(n={a:f,pieceId:m,d:I})}if(!n)break;s.add(n.pieceId),y.delete(n.a.instanceId),e.push({instanceId:n.a.instanceId,variantId:n.a.variantId,pieceId:n.pieceId,optionId:n.a.optionId})}for(const n of r){if(n.pos)continue;const f=n.replacedPiece&&!s.has(n.replacedPiece)&&p[n.replacedPiece]?n.replacedPiece:a.find(m=>!s.has(m));if(!f)break;s.add(f),e.push({instanceId:n.instanceId,variantId:n.variantId,pieceId:f,optionId:n.optionId})}return{osId:d,assignments:e}}const J=1;function mt(o){const l=N(o);return`${M}${l}`}function Z(o){switch(o){case"left":return"left";case"right":case"side":return"right";case"front":case"front-left":case"front-right":return"front";default:return"back"}}function yt(o,l){const u=k.getState().placementGroups||{},d=Object.keys(u);if(d.length===0)return null;const p=i=>u[i]?.type??u[i]?.kind??null,g=i=>String(u[i]?.wall??u[i]?.location??"").toLowerCase(),a=i=>p(i)===o,t=Z(l);return d.find(i=>a(i)&&g(i)===t)||d.find(i=>a(i)&&g(i).includes(t))||d.find(a)||null}const L="floor_back";function St(){const o=Object.keys(k.getState().placementGroups||{});return o.find(l=>/floor/i.test(l))??o[0]??L}function It(o={}){const l=k.getState(),u=_.getState(),d=j.getState(),p=G.getState().sceneSelections||{},g=w.getState().placementSelections||{},a=[];{const s=w.getState(),e=j.getState(),c=Object.keys(k.getState().placementGroups||{}),S=Object.values(s.productInstances||{}).map(y=>y?.placementGroup).find(Boolean)??null;for(const[y,n]of Object.entries(s.productInstances||{})){if(!n)continue;const f=n.variantId??n.productId??null;if(f==null)continue;const m=e.getProduct?.(n.productId)||e.getProduct?.(f),I=n.placementGroup??m?.placementGroup??m?.placement_group??S??c.find(v=>/floor/i.test(v))??c[0]??L,b=(()=>{const v=n.positionedAbove??n.positioned_above??null;if(v!=null){const O=(s.productInstances||{})[String(v)];return O?.variantId??O?.productId??null}const h=m?.hostVariants??m?.host_variants;if(Array.isArray(h)&&h.length){const O=h.find(x=>x?.isDefault??x?.is_default)||h[0];return O?.hostVariantId??O?.host_variant_id??null}return null})();a.push({id:y,variantId:f,placementGroup:I,sequence:0,...b!=null?{hostVariantId:b}:{},transform:{position:n.position||[0,0,0],rotation:n.rotation||[0,0,0]},selections:g[y]||{},overrides:{},edge:(m?.edge??e.getProduct?.(f)?.edge??"")||null,createdAt:n.createdAt??0})}}{const s=w.getState().productInstances||{};for(const e of a){const c=Number(s[String(e.id)]?.sequence);e.sequence=Number.isFinite(c)?c:0}for(const e of a)e.sequence==null&&(e.sequence=0),delete e.createdAt,delete e.edge}const{osId:t,assignments:i}=Q(o.excludeHostedProductInstanceId??null);if(t!=null){const s=String(t);for(const c of a)c.selections&&s in c.selections&&delete c.selections[s];const e=new Map(a.map(c=>[String(c.id),c]));for(const c of i){const S=e.get(String(c.pieceId));S&&(S.selections[s]=c.optionId)}}const r={};for(const[s,e]of Object.entries(p)){const c=Number(e);!Number.isFinite(c)||!Number.isFinite(Number(s))||(d.features?.[s]?.type??d.features?.[String(s)]?.type)==="load_new_product"||(r[String(s)]=c)}return{schemaVersion:J,systemId:Number(l.systemId)||l.systemId,versionNumber:1,catalogVersion:l.catalogVersion??null,room:(()=>{const s=l.systemRoom||{},e=c=>Number(c)>0?Number(c):null;return{width:(u.roomFootprint?.width>0?u.roomFootprint.width:null)??e(s.width)??4,depth:(u.roomFootprint?.depth>0?u.roomFootprint.depth:null)??e(s.depth)??3.5,height:e(s.height)??2.7}})(),selections:r,placements:a}}function ht(o){if(!Array.isArray(o)||o.length===0)return;try{tt(o)}catch{}const l=_.getState(),u=j.getState();for(const d of o){if(String(d?.reason||"").includes("max_count"))continue;const p=String(d?.variantId??N(d?.id)),g=(l.sceneHostedProducts||[]).find(a=>{if(String(a.hostedProductId)===p)return!0;const t=u.getHostedProduct?.(a.hostedProductId)?.id;return t!=null&&String(t)===p});if(g){try{l.removeHostedProduct?.(g.id)}catch{}const a=g.name||u.getHostedProduct?.(g.hostedProductId)?.name||"Hosted product",t=String(d?.reason||"");let i=`${a} was removed automatically.`;t.includes("mutually_exclusive")?i=`${a} was removed \u2014 it can't be combined with the product you just added.`:(t.includes("positioned_above")||t.includes("cascade"))&&(i=`${a} was removed because the product it was paired with is no longer in the scene.`);try{l.showInfo?.(i)}catch{}}}}let R="",W=0;function tt(o){const l=(Array.isArray(o)?o:[]).filter(f=>String(f?.reason||"").includes("max_count"));if(l.length===0)return;const u=_.getState(),d=u.pieceConfigSnapshot;if(!d||typeof d!="object")return;const p=u.basePiecePositions||{},g=u.hostProductOverrides||{},a=f=>String(g[f]??p[f]?.productId??""),t={};for(const f of l){const m=String(f?.variantId??String(f?.id??"").replace(/^.*?-/,""));m&&(t[m]=(t[m]||0)+1)}const i=Object.entries(t).map(([f,m])=>`${f}:${m}`).sort().join(","),r=Date.now();if(i&&i===R&&r-W<6e3)return;const s=[];for(const[f,m]of Object.entries(t)){const I=Object.keys(p).filter(b=>a(b)===f).sort((b,v)=>b.localeCompare(v,void 0,{numeric:!0}));s.push(...I.slice(Math.max(0,I.length-m)))}if(s.length===0)return;const e={...d};for(const f of s){const m=f.indexOf("-");if(m===-1)continue;const I=f.slice(0,m),b=Number(f.slice(m+1));Array.isArray(e[I])&&(e[I]=e[I].filter(h=>h!==b));const v=`${I}ByWall`;if(e[v]&&typeof e[v]=="object"){const h={};for(const[O,x]of Object.entries(e[v]))h[O]=Array.isArray(x)?x.filter(H=>H!==b):x;e[v]=h}if(I==="corner"&&e.cornerPositions&&typeof e.cornerPositions=="object"){const h={...e.cornerPositions};delete h[b],e.cornerPositions=h}}const c=new Set(s),S=f=>{const m={...f};for(const I of c)delete m[I];return m},y={pieceConfigSnapshot:e};for(const f of["hostProductOverrides","hostWidths","hostDoorTypes","hostStyles","hostHandleTypes","hostFinishes","hostMaterials","hostHardwareFinishes"])u[f]&&typeof u[f]=="object"&&(y[f]=S(u[f]));_.setState(y);const n=_.getState().selectedPieceIndex;n&&c.has(n)&&_.getState().clearSelectedFeature?.(),R=i,W=r}function Pt(o){const l=(Array.isArray(o)?o:[]).filter(a=>String(a?.code??a?.type??"").toUpperCase()!=="STALE_SELECTION"),u=_.getState().setConstraintWarnings;if(typeof u!="function")return;const d=k.getState().constraints||[],p=new Map(d.map(a=>[String(a.id),a.constraintType??a.constraint_type??null])),g=l.map(a=>{const t=a?.details?.constraintId??a?.constraintId??null;return{code:a?.code??a?.type??"CONSTRAINT_VIOLATION_SOFT",message:a?.message??String(a??""),constraintId:t,constraintType:t!=null?p.get(String(t))??null:null,placementId:a?.details?.placementId??null,offending:Array.isArray(a?.details?.offending)?a.details.offending:[]}});u(g);try{z(g)}catch{}}function D(o){const l=String(o??"info").toLowerCase();return l==="success"||l==="warning"||l==="error"?l:"info"}function bt(o){const l=_.getState(),u=(Array.isArray(o)?o:[]).map(t=>{const i=t||{};return{ruleId:i.ruleId??i.rule_id??null,text:i.text??i.message??"",severity:String(i.severity??"info").toLowerCase(),display:String(i.display??"toast").toLowerCase(),placementId:i.placementId??i.placement_id??null}}).filter(t=>t.text),d=u.filter(t=>t.display==="modal"),p=u.filter(t=>t.display!=="modal");try{l.setInlineMessages?.([])}catch{}for(const t of p){const i=D(t.severity),r=i==="warning"||i==="error"?0:5e3;try{l.addNotification?.({type:i,message:t.text,duration:r})}catch{}}const g=d.map(t=>t.ruleId??t.text??null).filter(t=>t!=null),a=Array.isArray(l.lastModalKeys)?l.lastModalKeys:[];if(d.length){const t=d[d.length-1],i=t.ruleId??t.text??null;if(i==null||!a.includes(i))try{l.setMessageModal?.({ruleId:t.ruleId,text:t.text,severity:D(t.severity)})}catch{}}try{_.setState({lastModalKeys:g})}catch{}}function At(o,l){if(!Array.isArray(o)||o.length===0)return;const u=_.getState(),d=j.getState(),p=u.basePiecePositions||{};let g=!1;for(const a of o){const t=a?.variantId??String(a?.id??"").replace(/^.*?-/,"");if(t==null||t===""||(u.sceneHostedProducts||[]).some(y=>{if(String(y.hostedProductId)===String(t))return!0;const n=d.getHostedProduct?.(y.hostedProductId)?.id;return n!=null&&String(n)===String(t)}))continue;const r=d.getHostedProduct?.(t);if(!r?.id)continue;let s=r.modelUrl;s||(s=(V(r.id)||[]).find(n=>!!n.url)?.url||null);const e=(l?.placements||[]).find(y=>String(y.id)===String(a.id));let c=e?.hostPlacementId&&p[e.hostPlacementId]?e.hostPlacementId:null;if(!c){const y=(u.sceneHostedProducts||[]).find(n=>B(n)&&n.replacedPiece);y?.replacedPiece&&p[y.replacedPiece]&&(c=y.replacedPiece)}if(c||(c=Object.keys(p).sort((y,n)=>y.localeCompare(n,void 0,{numeric:!0})).find(y=>q(y)==="base"&&p[y]?.position)||null),!c||!p[c]?.position)continue;const S=p[c];try{u.placeHostedProductAtPiece?.({...r,modelUrl:s},c,S.position,S.rotation||[0,0,0]),g=!0}catch{}}}let C=[],et=0;function _t(o){const l=++et;return C.push({token:l,req:o,consumed:!1}),l}function vt(o){C=C.filter(l=>l.token!==o)}function Ot(o){const u=!!C.find(d=>d.token===o)?.consumed;return C=C.filter(d=>d.token!==o),u}function xt(o){if(C.length===0)return 0;const l=Array.isArray(o?.placements)?o.placements:[];if(l.length===0)return 0;const u=j.getState(),d=_.getState(),p=d.basePiecePositions||{};let g=0;for(const a of C){if(a.consumed)continue;const t=String(a.req.productId);l.find(r=>{if(p[r.id])return!1;const s=r.variantId??String(r.id??"");return!(String(s)!==t||u.getHostedProduct?.(s)?.id)})&&(d.setPendingPieceAdd({...a.req,_preValidated:!0,_fromResponse:!0}),a.consumed=!0,g+=1)}return g}function wt(o){if(!o||typeof o!="object")return;const l=o.selections||{},u=G.getState(),d=u.sceneSelections||{};for(const[p,g]of Object.entries(l)){const a=Number(g);if(Number.isFinite(a)&&!(d[p]!=null||d[String(p)]!=null))try{(u.setSeededSceneSelection??u.setSceneSelection)?.(p,a)}catch{}}}function Ht(o){const d=(k.getState().sceneConfigurations||{})[o];if(!d)return!1;const p=G.getState(),g=w.getState(),a=j.getState();d?.scene_id&&g.setActiveSceneId?.(d.scene_id);const t=U(d);for(const i of t)i.id&&i.default_option_id&&p.setSceneSelection(i.id,i.default_option_id);if(t.length>0){const i=a.options||{};for(const r of t){if(!r?.id)continue;const s=r.type;if(s!=="layout_change"&&s!=="load_configuration")continue;let e=d.scene_option_id??d.sceneOptionId??null;if(e==null){const c=a.features||{},S=r.feature_id??r.id,y=c[S]??c[String(S)],n=Array.isArray(y?.options)?y.options:[];for(const f of n){const m=typeof f=="object"?f?.id??f?.optionId??f?.option_id:f;if(m==null)continue;const I=i[m]??i[String(m)];if(!I)continue;if([I.value,I.valueText,I.value_text,I.id].filter(v=>v!=null).map(String).includes(String(o))){e=I.id;break}}}e!=null&&p.setSceneSelection(r.id,e)}}if(d.default_scene_selections)for(const[i,r]of Object.entries(d.default_scene_selections))p.setSceneSelection(i,r);return g.setSceneLoading?.(!1),!0}function nt(o){const l=Array.isArray(o?.placements)?o.placements:[],u=l.filter(g=>g?.positionedAbove!=null);if(u.length===0)return;const d=j.getState(),p=_.getState().basePiecePositions||{};for(const g of u){const a=g.variantId??N(g.id),t=d.getHostedProduct?.(a);if(!t?.id)continue;const i=l.find(A=>String(A.id)===String(g.positionedAbove)),r=i?.variantId??(i?N(i.id):null);if(r==null)continue;const s=(_.getState().sceneHostedProducts||[]).find(A=>{if(String(A.hostedProductId)===String(r))return!0;const P=d.getHostedProduct?.(A.hostedProductId)?.id;return P!=null&&String(P)===String(r)}),e=s?.replacedPiece,c=e&&p[e]?.position?p[e]:null,S=c?.position??s?.position??null,y=c?.rotation??s?.rotation??[0,0,0];if(!S)continue;let n=0;if(c){const A=d.getHostedProduct?.(r),P=c.productId||A?.target_product_id;n=(A?.slots?.find(F=>F.product_id===P)||A?.slots?.find(F=>F.isDefault)||A?.slots?.[0])?.position?.[0]??A?.componentModelOffset?.[0]??0}const f=S[0];let m=S[1]+1.5;for(const[A,P]of Object.entries(p))if(q(A)==="upper"&&Math.abs((P.position?.[0]??1/0)-f)<.5){m=P.position[1];break}const I=m-S[1]+.25,b=(y||[0,0,0])[1],v=Math.cos(b),h=Math.sin(b),O=[n,I,0],x=[S[0]+n*v,S[1]+I,S[2]-n*h];let H=t.modelUrl;H||(H=(V(t.id)||[]).find(P=>!!P.url)?.url||null);const T=(_.getState().sceneHostedProducts||[]).find(A=>{if(String(A.hostedProductId)===String(t.id))return!0;const P=d.getHostedProduct?.(A.hostedProductId)?.id;return P!=null&&String(P)===String(t.id)});if(T)_.setState(A=>({sceneHostedProducts:A.sceneHostedProducts.map(P=>P.id===T.id?{...P,position:x,rotation:y||[0,0,0],positionOffset:O,replacedPiece:e??P.replacedPiece,pairedWithPiece:e??P.pairedWithPiece,pairedWithHostedProductId:s?.id??P.pairedWithHostedProductId}:P)}));else{const A=String(g.id??`${M}${t.id}`);_.setState(P=>({sceneHostedProducts:[...P.sceneHostedProducts,{id:A,hostedProductId:t.id,name:t.name,modelUrl:H,position:x,rotation:y||[0,0,0],scale:t.scale||[1,1,1],placement_type:t.placement_type,replacedPiece:e??null,positionOffset:O,pairedWithPiece:e??null,pairedWithHostedProductId:s?.id??null}],...e?{occupiedPieceSlots:{...P.occupiedPieceSlots,[e]:{...P.occupiedPieceSlots[e],pairedHostedProductId:A}}}:{}}))}}}const E=()=>{try{const o=X();return!!o&&typeof o.computeLayout!="function"}catch{return!1}};function jt(o){if(!o||!Array.isArray(o.placements))return;const u=w.getState().productInstances||{};let d=!1;try{d=!!_.getState().ownsSceneGraph}catch{}if(E())return;const p={};let g=!1;for(const r of o.placements){const s=String(r.id??"");if(!s)continue;const e=[r.transform,r.default_transform,r.defaultTransform,Array.isArray(r.position)?{position:r.position,rotation:r.rotation}:null].find(y=>y&&Array.isArray(y.position))||{},c=u[s],S={id:s,instanceId:s,placementId:s,productId:r.variantId,variantId:r.variantId,configId:null,placementGroup:r.placementGroup??null,sequence:Number.isFinite(Number(r.sequence))?Number(r.sequence):null,positionedAbove:r.positionedAbove??r.positioned_above??r.hostPlacementId??r.host_placement_id??r.host??null,lockVariantId:r.lockVariantId??r.lock_variant_id??null,position:Array.isArray(e.position)?e.position:[0,0,0],rotation:Array.isArray(e.rotation)?e.rotation:[0,0,0],scale:[1,1,1],locked:r.locked===!0,createdAt:c?.createdAt??(d?Date.now()+(Number.isFinite(Number(r.sequence))?Number(r.sequence):0):Date.now())};p[s]=S,(!c||c.productId!==S.productId||c.position!==S.position||c.rotation!==S.rotation||c.locked!==S.locked)&&(g=!0)}for(const[r,s]of Object.entries(u))r in p||(g=!0);const a=Object.entries(u).filter(([r])=>!(r in p));let t=a;Object.keys(p).length>0&&(t=[]);const i=t.length!==a.length;!g&&!i||w.setState({productInstances:{...Object.fromEntries(t),...p}})}function Ct(o){if(!o||!Array.isArray(o.placements))return;try{if(!_.getState().ownsSceneGraph)return}catch{return}const l=w.getState(),u=l.productInstances||{},d=l.componentStates||{},p={...u},g={...d};let a=!1;if(!E()){for(const t of o.placements){const i=String(t.id??""),r=u[i];if(!r)continue;const s=t.variantId;s!=null&&(String(r.productId)===String(s)&&String(r.variantId??r.productId)===String(s)||(p[i]={...r,productId:s,variantId:s},g[i]&&(g[i]={}),a=!0))}a&&w.setState({productInstances:p,componentStates:g})}}function ot(o){if(!o||!Array.isArray(o.placements))return;try{if(!_.getState().ownsSceneGraph)return}catch{return}const u=w.getState().productInstances||{},d={};for(const t of o.placements){const i=String(t?.id??"");i&&(d[i]=t)}const p=t=>{const r=d[String(t?.id??"")]?.transform?.position?.[1];return typeof r=="number"&&r>0?r:null},g={...u};let a=!1;for(const[t,i]of Object.entries(u)){const r=p(i);if(r==null)continue;const s=Array.isArray(i.position)?i.position:[0,0,0];Math.abs((s[1]||0)-r)<1e-6||(g[t]={...i,position:[s[0]||0,r,s[2]||0]},a=!0)}a&&w.setState({productInstances:g})}function kt(o){if(!o||!Array.isArray(o.placements))return;const l=_.getState(),u=j.getState(),d=u.componentGroups||{},p=u.components||{},g={},a={},t=(s,e,c)=>{e!=null&&(s!=null&&(g[String(s)]={variantKey:e,isHandle:c}),a[String(e)]=c)};for(const s of Object.values(d)){const e=c=>(p[c]?.type??p[String(c)]?.type)==="handle";for(const[c,S]of Object.entries(s?.variants||{}))t(S,c,e(S));for(const c of Array.isArray(s?.members)?s.members:[]){const S=c?.componentId??c?.component_id;t(S,c?.variantKey??c?.variant_key,e(S))}}const i=(s,e)=>{const c=g[String(e)];return c||{variantKey:e,isHandle:a[String(e)]??!1}},r=K(u);for(const s of o.placements){const e=s.id;if(!e)continue;if(s.selections&&typeof s.selections=="object"){let h=s.selections;r!=null&&String(r)in h&&(h={...h},delete h[String(r)]),w.getState().setPlacementSelections?.(e,h)}if($(String(e)))continue;const c=s.overrides||{},S=c.materials;if(S&&typeof S=="object")for(const[h,O]of Object.entries(S))O!=null&&l.setHostMaterialOverride(e,h,O);const y=c.componentSlots||c.component_slots,n=[];if(y&&typeof y=="object"){const h=w.getState();for(const[O,x]of Object.entries(y)){if(x===null){n.push(O),h.setComponentSwap?.(e,O,null);continue}if(x===void 0)continue;h.setComponentSwap?.(e,O,x);const{variantKey:H,isHandle:T}=i(O,x);H!=null&&(T?l.setHostHandleType?.(e,H):l.setHostStyle?.(e,H))}}const f=c.visibility&&typeof c.visibility=="object"?{...c.visibility}:null,m=f||n.length?f||{}:null;for(const h of n)m[h]===void 0&&(m[h]=!1);const I=c.transforms||c.transform,b=c.hiddenComponentIds||c.hidden_component_ids,v=Array.isArray(b)&&b.length?b.map(Number):null;if(w.getState().setPlacementOverrides?.(e,{visibility:m,transforms:I&&typeof I=="object"?I:null,hiddenComponentIds:v}),m)for(const[h,O]of Object.entries(m))O===!1&&String(h).toLowerCase().includes("handle")&&l.setHostHandleType?.(e,"none")}nt(o),ot(o)}export{L as DEFAULT_PLACEMENT_GROUP,At as applyAddedPlacements,wt as applyInitialSelections,bt as applyMessages,ot as applyOwnedTransforms,tt as applyPresetPieceTrims,ht as applyRemovedPlacements,xt as applyResolvedPieceAdds,kt as applyResolvedToScene,Ht as applySceneConfigDefaults,nt as applyWallMountedPlacements,Pt as applyWarnings,It as buildCanonicalState,vt as dequeuePieceAdd,Q as getHostedProductSpawnSelections,mt as hostedProductPlacementId,jt as hydrateProductInstancesFromState,Y as isOverlayPlacementProduct,_t as queuePieceAdd,yt as resolveDeclaredPlacementGroup,St as resolveDefaultFloorPlacementGroup,Ct as syncOwnedInstanceVariants,Ot as wasPieceAddConsumed};
|
|
1
|
+
import{HOSTED_PLACEMENT_ID_PREFIX as M,isHostedPlacementId as $,stripHostedPlacementPrefix as N}from"./23dc0ccf32.js";import k,{deriveSceneFeatures as B}from"./be337ddda5.js";import F from"./d94df858ea.js";import x from"./9c6c598569.js";import _ from"./8f60e5059a.js";import H from"./872c4302e0.js";import{isHostFloating as z}from"./061b81ad81.js";import{getProductAllComponents as V,pieceKindOf as L}from"./9326c23506.js";import{autoFixAdjacency as X}from"./710c1ab641.js";import{getPlacementStrategy as Y}from"./281cf952fa.js";import{resolveHostVariantId as Q}from"./be07a7f885.js";import{isAddFeature as E}from"./8c27edda0f.js";function R(e){const l=e?.features||{};for(const[a,p]of Object.entries(l))if(p?.type==="appliance_selection")return a;const u=new Set(Object.keys(e?.hostedProductByOptionId||{}));if(u.size>0){for(const[a,p]of Object.entries(l))if((Array.isArray(p?.options)?p.options.map(String):[]).some(d=>u.has(d)))return a}return null}function J(e,l){if(l==null)return!1;const u=e?.products||{},a=u[l]||u[String(l)];return a?String(a.placement_group??a.placementGroup??"").toLowerCase().includes("overlay"):!1}function Z(e=null){const l=_.getState(),u=H.getState(),a=R(u);if(a==null)return{osId:null,assignments:[]};const p=l.basePiecePositions||{},f=l.hostProductOverrides||{},d=Object.keys(p).filter(s=>!J(u,f[s]??p[s]?.productId)).sort((s,g)=>s.localeCompare(g,void 0,{numeric:!0})),t=[];for(const s of l.sceneHostedProducts||[]){if(e!=null&&String(s.id)===String(e))continue;const g=s.hostedProductId??s.productId??null;if(g==null)continue;const m=u.getHostedProduct?.(g)?.optionId??null;m!=null&&t.push({instanceId:s.id,variantId:g,optionId:m,replacedPiece:s.replacedPiece??null,pos:Array.isArray(s.position)?s.position:null})}const o=new Map;for(const s of t){const g=String(s.optionId),m=o.get(g);(!m||!m.pos&&s.pos)&&o.set(g,s)}const i=[...o.values()],r=new Set,n=[],c=(s,g)=>{const m=p[g]?.position;if(!Array.isArray(m)||!Array.isArray(s))return 1/0;const I=(m[0]??0)-(s[0]??0),b=(m[1]??0)-(s[1]??0),v=(m[2]??0)-(s[2]??0);return I*I+b*b+v*v},y=i.filter(s=>s.pos),S=new Set(y.map(s=>s.instanceId));for(;S.size;){let s=null;for(const g of y)if(S.has(g.instanceId))for(const m of d){if(r.has(m))continue;const I=c(g.pos,m);(s==null||I<s.d)&&(s={a:g,pieceId:m,d:I})}if(!s)break;r.add(s.pieceId),S.delete(s.a.instanceId),n.push({instanceId:s.a.instanceId,variantId:s.a.variantId,pieceId:s.pieceId,optionId:s.a.optionId})}for(const s of i){if(s.pos)continue;const g=s.replacedPiece&&!r.has(s.replacedPiece)&&p[s.replacedPiece]?s.replacedPiece:d.find(m=>!r.has(m));if(!g)break;r.add(g),n.push({instanceId:s.instanceId,variantId:s.variantId,pieceId:g,optionId:s.optionId})}return{osId:a,assignments:n}}const tt=1;function ht(e){const l=N(e);return`${M}${l}`}function et(e){switch(e){case"left":return"left";case"right":case"side":return"right";case"front":case"front-left":case"front-right":return"front";default:return"back"}}function Pt(e,l){const u=k.getState().placementGroups||{},a=Object.keys(u);if(a.length===0)return null;const p=o=>u[o]?.type??u[o]?.kind??null,f=o=>String(u[o]?.wall??u[o]?.location??"").toLowerCase(),d=o=>p(o)===e,t=et(l);return a.find(o=>d(o)&&f(o)===t)||a.find(o=>d(o)&&f(o).includes(t))||a.find(d)||null}const q="floor_back";function bt(){const e=Object.keys(k.getState().placementGroups||{});return e.find(l=>/floor/i.test(l))??e[0]??q}function At(e={}){const l=k.getState(),u=_.getState(),a=H.getState(),p=F.getState().sceneSelections||{},f=x.getState().placementSelections||{},d=[];{const r=x.getState(),n=H.getState(),c=Object.keys(k.getState().placementGroups||{}),y=Object.values(r.productInstances||{}).map(S=>S?.placementGroup).find(Boolean)??null;for(const[S,s]of Object.entries(r.productInstances||{})){if(!s)continue;const g=s.variantId??s.productId??null;if(g==null)continue;const m=n.getProduct?.(s.productId)||n.getProduct?.(g),I=s.placementGroup??m?.placementGroup??m?.placement_group??y??c.find(v=>/floor/i.test(v))??c[0]??q,b=(()=>{const v=s.positionedAbove??s.positioned_above??null;if(v!=null){const h=(r.productInstances||{})[String(v)];return h?.variantId??h?.productId??null}return Q(m,s)})();d.push({id:S,variantId:g,placementGroup:I,sequence:0,...b!=null?{hostVariantId:b}:{},transform:{position:s.position||[0,0,0],rotation:s.rotation||[0,0,0]},selections:f[S]||{},overrides:{},edge:(m?.edge??n.getProduct?.(g)?.edge??"")||null,createdAt:s.createdAt??0})}}{const r=x.getState().productInstances||{};for(const n of d){const c=Number(r[String(n.id)]?.sequence);n.sequence=Number.isFinite(c)?c:0}for(const n of d)n.sequence==null&&(n.sequence=0),delete n.createdAt,delete n.edge}const{osId:t,assignments:o}=Z(e.excludeHostedProductInstanceId??null);if(t!=null){const r=String(t);for(const c of d)c.selections&&r in c.selections&&delete c.selections[r];const n=new Map(d.map(c=>[String(c.id),c]));for(const c of o){const y=n.get(String(c.pieceId));y&&(y.selections[r]=c.optionId)}}const i={};for(const[r,n]of Object.entries(p)){const c=Number(n);!Number.isFinite(c)||!Number.isFinite(Number(r))||(a.features?.[r]?.type??a.features?.[String(r)]?.type)==="load_new_product"||(i[String(r)]=c)}return{schemaVersion:tt,systemId:Number(l.systemId)||l.systemId,versionNumber:1,catalogVersion:l.catalogVersion??null,room:(()=>{const r=l.systemRoom||{},n=c=>Number(c)>0?Number(c):null;return{width:(u.roomFootprint?.width>0?u.roomFootprint.width:null)??n(r.width)??4,depth:(u.roomFootprint?.depth>0?u.roomFootprint.depth:null)??n(r.depth)??3.5,height:n(r.height)??2.7}})(),selections:i,placements:d}}function _t(e){if(!Array.isArray(e)||e.length===0)return;try{nt(e)}catch{}const l=_.getState(),u=H.getState();for(const a of e){if(String(a?.reason||"").includes("max_count"))continue;const p=String(a?.variantId??N(a?.id)),f=(l.sceneHostedProducts||[]).find(d=>{if(String(d.hostedProductId)===p)return!0;const t=u.getHostedProduct?.(d.hostedProductId)?.id;return t!=null&&String(t)===p});if(f){try{l.removeHostedProduct?.(f.id)}catch{}const d=f.name||u.getHostedProduct?.(f.hostedProductId)?.name||"Hosted product",t=String(a?.reason||"");let o=`${d} was removed automatically.`;t.includes("mutually_exclusive")?o=`${d} was removed \u2014 it can't be combined with the product you just added.`:(t.includes("positioned_above")||t.includes("cascade"))&&(o=`${d} was removed because the product it was paired with is no longer in the scene.`);try{l.showInfo?.(o)}catch{}}}}let K="",D=0;function nt(e){const l=(Array.isArray(e)?e:[]).filter(g=>String(g?.reason||"").includes("max_count"));if(l.length===0)return;const u=_.getState(),a=u.pieceConfigSnapshot;if(!a||typeof a!="object")return;const p=u.basePiecePositions||{},f=u.hostProductOverrides||{},d=g=>String(f[g]??p[g]?.productId??""),t={};for(const g of l){const m=String(g?.variantId??String(g?.id??"").replace(/^.*?-/,""));m&&(t[m]=(t[m]||0)+1)}const o=Object.entries(t).map(([g,m])=>`${g}:${m}`).sort().join(","),i=Date.now();if(o&&o===K&&i-D<6e3)return;const r=[];for(const[g,m]of Object.entries(t)){const I=Object.keys(p).filter(b=>d(b)===g).sort((b,v)=>b.localeCompare(v,void 0,{numeric:!0}));r.push(...I.slice(Math.max(0,I.length-m)))}if(r.length===0)return;const n={...a};for(const g of r){const m=g.indexOf("-");if(m===-1)continue;const I=g.slice(0,m),b=Number(g.slice(m+1));Array.isArray(n[I])&&(n[I]=n[I].filter(h=>h!==b));const v=`${I}ByWall`;if(n[v]&&typeof n[v]=="object"){const h={};for(const[O,w]of Object.entries(n[v]))h[O]=Array.isArray(w)?w.filter(j=>j!==b):w;n[v]=h}if(I==="corner"&&n.cornerPositions&&typeof n.cornerPositions=="object"){const h={...n.cornerPositions};delete h[b],n.cornerPositions=h}}const c=new Set(r),y=g=>{const m={...g};for(const I of c)delete m[I];return m},S={pieceConfigSnapshot:n};for(const g of["hostProductOverrides","hostWidths","hostDoorTypes","hostStyles","hostHandleTypes","hostFinishes","hostMaterials","hostHardwareFinishes"])u[g]&&typeof u[g]=="object"&&(S[g]=y(u[g]));_.setState(S);const s=_.getState().selectedPieceIndex;s&&c.has(s)&&_.getState().clearSelectedFeature?.(),K=o,D=i}function vt(e){const l=(Array.isArray(e)?e:[]).filter(d=>{const t=String(d?.code??d?.type??"").toUpperCase();return t!=="STALE_SELECTION"&&t!=="RULE_APPLIED"}),u=_.getState().setConstraintWarnings;if(typeof u!="function")return;const a=k.getState().constraints||[],p=new Map(a.map(d=>[String(d.id),d.constraintType??d.constraint_type??null])),f=l.map(d=>{const t=d?.details?.constraintId??d?.constraintId??null;return{code:d?.code??d?.type??"CONSTRAINT_VIOLATION_SOFT",message:d?.message??String(d??""),constraintId:t,constraintType:t!=null?p.get(String(t))??null:null,placementId:d?.details?.placementId??null,offending:Array.isArray(d?.details?.offending)?d.details.offending:[]}});u(f);try{X(f)}catch{}}function W(e){const l=String(e??"info").toLowerCase();return l==="success"||l==="warning"||l==="error"?l:"info"}function Ot(e){const l=_.getState(),u=(Array.isArray(e)?e:[]).map(t=>{const o=t||{};return{ruleId:o.ruleId??o.rule_id??null,text:o.text??o.message??"",severity:String(o.severity??"info").toLowerCase(),display:String(o.display??"toast").toLowerCase(),placementId:o.placementId??o.placement_id??null,code:String(o.code??"").toUpperCase()}}).filter(t=>t.text&&t.code!=="RULE_APPLIED"),a=u.filter(t=>t.display==="modal"),p=u.filter(t=>t.display!=="modal");try{l.setInlineMessages?.([])}catch{}for(const t of p){const o=W(t.severity),i=o==="warning"||o==="error"?0:5e3;try{l.addNotification?.({type:o,message:t.text,duration:i})}catch{}}const f=a.map(t=>t.ruleId??t.text??null).filter(t=>t!=null),d=Array.isArray(l.lastModalKeys)?l.lastModalKeys:[];if(a.length){const t=a[a.length-1],o=t.ruleId??t.text??null;if(o==null||!d.includes(o))try{l.setMessageModal?.({ruleId:t.ruleId,text:t.text,severity:W(t.severity)})}catch{}}try{_.setState({lastModalKeys:f})}catch{}}function xt(e,l){if(!Array.isArray(e)||e.length===0)return;const u=_.getState(),a=H.getState(),p=u.basePiecePositions||{};let f=!1;for(const d of e){const t=d?.variantId??String(d?.id??"").replace(/^.*?-/,"");if(t==null||t===""||(u.sceneHostedProducts||[]).some(S=>{if(String(S.hostedProductId)===String(t))return!0;const s=a.getHostedProduct?.(S.hostedProductId)?.id;return s!=null&&String(s)===String(t)}))continue;const i=a.getHostedProduct?.(t);if(!i?.id)continue;let r=i.modelUrl;r||(r=(V(i.id)||[]).find(s=>!!s.url)?.url||null);const n=(l?.placements||[]).find(S=>String(S.id)===String(d.id));let c=n?.hostPlacementId&&p[n.hostPlacementId]?n.hostPlacementId:null;if(!c){const S=(u.sceneHostedProducts||[]).find(s=>z(s)&&s.replacedPiece);S?.replacedPiece&&p[S.replacedPiece]&&(c=S.replacedPiece)}if(c||(c=Object.keys(p).sort((S,s)=>S.localeCompare(s,void 0,{numeric:!0})).find(S=>L(S)==="base"&&p[S]?.position)||null),!c||!p[c]?.position)continue;const y=p[c];try{u.placeHostedProductAtPiece?.({...i,modelUrl:r},c,y.position,y.rotation||[0,0,0]),f=!0}catch{}}}let C=[],ot=0;function wt(e){const l=++ot;return C.push({token:l,req:e,consumed:!1}),l}function Ht(e){C=C.filter(l=>l.token!==e)}function jt(e){const u=!!C.find(a=>a.token===e)?.consumed;return C=C.filter(a=>a.token!==e),u}function Ct(e){if(C.length===0)return 0;const l=Array.isArray(e?.placements)?e.placements:[];if(l.length===0)return 0;const u=H.getState(),a=_.getState(),p=a.basePiecePositions||{};let f=0;for(const d of C){if(d.consumed)continue;const t=String(d.req.productId);l.find(i=>{if(p[i.id])return!1;const r=i.variantId??String(i.id??"");return!(String(r)!==t||u.getHostedProduct?.(r)?.id)})&&(a.setPendingPieceAdd({...d.req,_preValidated:!0,_fromResponse:!0}),d.consumed=!0,f+=1)}return f}function kt(e){if(!Array.isArray(e)||e.length===0)return;const l=F.getState(),u=x.getState();for(const a of e){const p=a?.optionSetId,f=Number(a?.optionId);if(!(p==null||!Number.isFinite(f)))try{if(a.placementId==null)(l.setSeededSceneSelection??l.setSceneSelection)?.(p,f);else{const d=a.placementId,t=u.placementSelections?.[d]??u.placementSelections?.[String(d)]??{};u.setPlacementSelections?.(d,{...t,[String(p)]:f})}}catch{}}}function Tt(e){if(!e||typeof e!="object")return;const l=e.selections||{},u=F.getState(),a=u.sceneSelections||{},p=H.getState().features||{};for(const[f,d]of Object.entries(l)){const t=Number(d);if(!Number.isFinite(t)||a[f]!=null||a[String(f)]!=null)continue;const o=p[f]??p[String(f)];if(!(o&&E(o)))try{(u.setSeededSceneSelection??u.setSceneSelection)?.(f,t)}catch{}}}function Nt(e){const a=(k.getState().sceneConfigurations||{})[e];if(!a)return!1;const p=F.getState(),f=x.getState(),d=H.getState();a?.scene_id&&f.setActiveSceneId?.(a.scene_id);const t=B(a);for(const o of t)o.id&&o.default_option_id&&!E(o)&&p.setSceneSelection(o.id,o.default_option_id);if(t.length>0){const o=d.options||{};for(const i of t){if(!i?.id)continue;const r=i.type;if(r!=="layout_change"&&r!=="load_configuration")continue;let n=a.scene_option_id??a.sceneOptionId??null;if(n==null){const c=d.features||{},y=i.feature_id??i.id,S=c[y]??c[String(y)],s=Array.isArray(S?.options)?S.options:[];for(const g of s){const m=typeof g=="object"?g?.id??g?.optionId??g?.option_id:g;if(m==null)continue;const I=o[m]??o[String(m)];if(!I)continue;if([I.value,I.valueText,I.value_text,I.id].filter(v=>v!=null).map(String).includes(String(e))){n=I.id;break}}}n!=null&&p.setSceneSelection(i.id,n)}}if(a.default_scene_selections)for(const[o,i]of Object.entries(a.default_scene_selections))p.setSceneSelection(o,i);return f.setSceneLoading?.(!1),!0}function st(e){const l=Array.isArray(e?.placements)?e.placements:[],u=l.filter(f=>f?.positionedAbove!=null);if(u.length===0)return;const a=H.getState(),p=_.getState().basePiecePositions||{};for(const f of u){const d=f.variantId??N(f.id),t=a.getHostedProduct?.(d);if(!t?.id)continue;const o=l.find(A=>String(A.id)===String(f.positionedAbove)),i=o?.variantId??(o?N(o.id):null);if(i==null)continue;const r=(_.getState().sceneHostedProducts||[]).find(A=>{if(String(A.hostedProductId)===String(i))return!0;const P=a.getHostedProduct?.(A.hostedProductId)?.id;return P!=null&&String(P)===String(i)}),n=r?.replacedPiece,c=n&&p[n]?.position?p[n]:null,y=c?.position??r?.position??null,S=c?.rotation??r?.rotation??[0,0,0];if(!y)continue;let s=0;if(c){const A=a.getHostedProduct?.(i),P=c.productId||A?.target_product_id;s=(A?.slots?.find(G=>G.product_id===P)||A?.slots?.find(G=>G.isDefault)||A?.slots?.[0])?.position?.[0]??A?.componentModelOffset?.[0]??0}const g=y[0];let m=y[1]+1.5;for(const[A,P]of Object.entries(p))if(L(A)==="upper"&&Math.abs((P.position?.[0]??1/0)-g)<.5){m=P.position[1];break}const I=m-y[1]+.25,b=(S||[0,0,0])[1],v=Math.cos(b),h=Math.sin(b),O=[s,I,0],w=[y[0]+s*v,y[1]+I,y[2]-s*h];let j=t.modelUrl;j||(j=(V(t.id)||[]).find(P=>!!P.url)?.url||null);const T=(_.getState().sceneHostedProducts||[]).find(A=>{if(String(A.hostedProductId)===String(t.id))return!0;const P=a.getHostedProduct?.(A.hostedProductId)?.id;return P!=null&&String(P)===String(t.id)});if(T)_.setState(A=>({sceneHostedProducts:A.sceneHostedProducts.map(P=>P.id===T.id?{...P,position:w,rotation:S||[0,0,0],positionOffset:O,replacedPiece:n??P.replacedPiece,pairedWithPiece:n??P.pairedWithPiece,pairedWithHostedProductId:r?.id??P.pairedWithHostedProductId}:P)}));else{const A=String(f.id??`${M}${t.id}`);_.setState(P=>({sceneHostedProducts:[...P.sceneHostedProducts,{id:A,hostedProductId:t.id,name:t.name,modelUrl:j,position:w,rotation:S||[0,0,0],scale:t.scale||[1,1,1],placement_type:t.placement_type,replacedPiece:n??null,positionOffset:O,pairedWithPiece:n??null,pairedWithHostedProductId:r?.id??null}],...n?{occupiedPieceSlots:{...P.occupiedPieceSlots,[n]:{...P.occupiedPieceSlots[n],pairedHostedProductId:A}}}:{}}))}}}const U=()=>{try{const e=Y();return!!e&&typeof e.computeLayout!="function"}catch{return!1}};function Ft(e){if(!e||!Array.isArray(e.placements))return;const u=x.getState().productInstances||{};let a=!1;try{a=!!_.getState().ownsSceneGraph}catch{}if(U())return;const p={};let f=!1;for(const i of e.placements){const r=String(i.id??"");if(!r)continue;const n=[i.transform,i.default_transform,i.defaultTransform,Array.isArray(i.position)?{position:i.position,rotation:i.rotation}:null].find(S=>S&&Array.isArray(S.position))||{},c=u[r],y={id:r,instanceId:r,placementId:r,productId:i.variantId,variantId:i.variantId,configId:null,placementGroup:i.placementGroup??null,sequence:Number.isFinite(Number(i.sequence))?Number(i.sequence):null,positionedAbove:i.positionedAbove??i.positioned_above??i.hostPlacementId??i.host_placement_id??i.host??null,hostVariantId:i.hostVariantId??i.host_variant_id??null,lockVariantId:i.lockVariantId??i.lock_variant_id??null,position:Array.isArray(n.position)?n.position:[0,0,0],rotation:Array.isArray(n.rotation)?n.rotation:[0,0,0],scale:[1,1,1],locked:i.locked===!0,createdAt:c?.createdAt??(a?Date.now()+(Number.isFinite(Number(i.sequence))?Number(i.sequence):0):Date.now())};p[r]=y,(!c||c.productId!==y.productId||c.position!==y.position||c.rotation!==y.rotation||c.locked!==y.locked||(c.hostVariantId??null)!==(y.hostVariantId??null))&&(f=!0)}for(const[i,r]of Object.entries(u))i in p||(f=!0);const d=Object.entries(u).filter(([i])=>!(i in p));let t=d;Object.keys(p).length>0&&(t=[]);const o=t.length!==d.length;!f&&!o||x.setState({productInstances:{...Object.fromEntries(t),...p}})}function Gt(e){if(!e||!Array.isArray(e.placements))return;try{if(!_.getState().ownsSceneGraph)return}catch{return}const l=x.getState(),u=l.productInstances||{},a=l.componentStates||{},p={...u},f={...a};let d=!1;if(!U()){for(const t of e.placements){const o=String(t.id??""),i=u[o];if(!i)continue;const r=t.variantId;r!=null&&(String(i.productId)===String(r)&&String(i.variantId??i.productId)===String(r)||(p[o]={...i,productId:r,variantId:r},f[o]&&(f[o]={}),d=!0))}d&&x.setState({productInstances:p,componentStates:f})}}function it(e){if(!e||!Array.isArray(e.placements))return;try{if(!_.getState().ownsSceneGraph)return}catch{return}const u=x.getState().productInstances||{},a={};for(const t of e.placements){const o=String(t?.id??"");o&&(a[o]=t)}const p=t=>{const i=a[String(t?.id??"")]?.transform?.position?.[1];return typeof i=="number"&&i>0?i:null},f={...u};let d=!1;for(const[t,o]of Object.entries(u)){const i=p(o);if(i==null)continue;const r=Array.isArray(o.position)?o.position:[0,0,0];Math.abs((r[1]||0)-i)<1e-6||(f[t]={...o,position:[r[0]||0,i,r[2]||0]},d=!0)}d&&x.setState({productInstances:f})}function Mt(e){if(!e||!Array.isArray(e.placements))return;const l=_.getState(),u=H.getState(),a=u.componentGroups||{},p=u.components||{},f={},d={},t=(r,n,c)=>{n!=null&&(r!=null&&(f[String(r)]={variantKey:n,isHandle:c}),d[String(n)]=c)};for(const r of Object.values(a)){const n=c=>(p[c]?.type??p[String(c)]?.type)==="handle";for(const[c,y]of Object.entries(r?.variants||{}))t(y,c,n(y));for(const c of Array.isArray(r?.members)?r.members:[]){const y=c?.componentId??c?.component_id;t(y,c?.variantKey??c?.variant_key,n(y))}}const o=(r,n)=>{const c=f[String(n)];return c||{variantKey:n,isHandle:d[String(n)]??!1}},i=R(u);for(const r of e.placements){const n=r.id;if(!n)continue;if(r.selections&&typeof r.selections=="object"){let h=r.selections;i!=null&&String(i)in h&&(h={...h},delete h[String(i)]),x.getState().setPlacementSelections?.(n,h)}if($(String(n)))continue;const c=r.overrides||{},y=c.materials;if(y&&typeof y=="object")for(const[h,O]of Object.entries(y))O!=null&&l.setHostMaterialOverride(n,h,O);const S=c.componentSlots||c.component_slots,s=[];if(S&&typeof S=="object"){const h=x.getState();for(const[O,w]of Object.entries(S)){if(w===null){s.push(O),h.setComponentSwap?.(n,O,null);continue}if(w===void 0)continue;h.setComponentSwap?.(n,O,w);const{variantKey:j,isHandle:T}=o(O,w);j!=null&&(T?l.setHostHandleType?.(n,j):l.setHostStyle?.(n,j))}}const g=c.visibility&&typeof c.visibility=="object"?{...c.visibility}:null,m=g||s.length?g||{}:null;for(const h of s)m[h]===void 0&&(m[h]=!1);const I=c.transforms||c.transform,b=c.hiddenComponentIds||c.hidden_component_ids,v=Array.isArray(b)&&b.length?b.map(Number):null;if(x.getState().setPlacementOverrides?.(n,{visibility:m,transforms:I&&typeof I=="object"?I:null,hiddenComponentIds:v}),m)for(const[h,O]of Object.entries(m))O===!1&&String(h).toLowerCase().includes("handle")&&l.setHostHandleType?.(n,"none")}st(e),it(e)}export{q as DEFAULT_PLACEMENT_GROUP,xt as applyAddedPlacements,Tt as applyInitialSelections,Ot as applyMessages,it as applyOwnedTransforms,nt as applyPresetPieceTrims,_t as applyRemovedPlacements,Ct as applyResolvedPieceAdds,Mt as applyResolvedToScene,Nt as applySceneConfigDefaults,kt as applySelectionOverrides,st as applyWallMountedPlacements,vt as applyWarnings,At as buildCanonicalState,Ht as dequeuePieceAdd,Z as getHostedProductSpawnSelections,ht as hostedProductPlacementId,Ft as hydrateProductInstancesFromState,J as isOverlayPlacementProduct,wt as queuePieceAdd,Pt as resolveDeclaredPlacementGroup,bt as resolveDefaultFloorPlacementGroup,Gt as syncOwnedInstanceVariants,jt as wasPieceAddConsumed};
|
package/dist/bdec200d00.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fragment as Z,jsx as d,jsxs as C}from"react/jsx-runtime";import{useMemo as $e,useRef as Ie,useEffect as ae,useSyncExternalStore as mt}from"react";import{HOSTED_PLACEMENT_ID_PREFIX as St}from"./23dc0ccf32.js";import"./4d7a0d1897.js";import"./ab6c80484f.js";import{subscribe as _t,getVersion as We,getPlacementBindings as Ve,getEffectiveSelections as ft,isOptionAvailable as Ke,isOptionVisible as bt,getPlacementOSAllowlist as yt}from"./817d930a49.js";import{ChevronLeft as Ce,LogoIcon as vt}from"./c5e990946e.js";import{useHasIcon as Pt}from"./09c4973968.js";import{getProductAllComponents as It,pieceKindOf as Ct}from"./9326c23506.js";import{isHostedProduct as Ot,isHostFloating as je}from"./061b81ad81.js";import"./87dcc12b65.js";import"./ee242c0099.js";import{applyFinishClick as Oe}from"./dc2a1a0e13.js";import kt from"./54f0fcf38b.js";import wt from"./c4790179f1.js";import{useSystemConfig as Tt,useSceneFeaturesReader as Ht}from"./6855e6a3b1.js";import{getCatalog as w,useCatalogMaps as Ft}from"./1458417bdb.js";import{useUIState as ze,useOptionGating as Nt,useHostedProductState as J,getUIState as ce,useUIRegion as Ge}from"./9840b9ce12.js";import{useCornerSlots as At,getBasePiecePositions as Dt,clearOverlapFlags as Lt,appendSceneHostedProduct as Rt}from"./367a479d3a.js";import{useSceneState as ke,getSceneState as we}from"./16a399703e.js";import{useSystem as Bt}from"./066fc9aa40.js";import{setSceneSelection as Ye,clearSceneSelection as Et,removeSceneInstance as xt,setSceneInstanceVariant as Ut,showInfo as Q,clearSceneLoading as Mt,clearPendingHostedProduct as $t,setPendingSlotPlacement as Wt,clearPendingSlotPlacement as Vt,clearDeferredHostedProductPlacement as Kt,deselect as jt}from"./2cafe3274b.js";import zt from"./6e2595aa36.js";import Gt from"./2990ba64d6.js";import Yt from"./6ba86aa3b8.js";import{selectOption as qt,selectProductOption as Xt}from"./dbd5ba1d07.js";import"./9526094bb7.js";import"./2774152dd2.js";import Jt from"./3fb3ab6757.js";import{resolveComponent as B,useComponentRegistry as Qt}from"./882bc739c8.js";import{SlotHost as qe}from"./73f7d65985.js";import{LayoutThumbnail as Zt,FinishThumbnail as en,OptionThumbnail as tn,AddProductToggle as nn,HostedProductThumbnail as sn}from"./c12c112c6f.js";import"./239b619005.css";let Te=null;function ji(){return Te||(Te=w().listHostedProducts()),Te}function Xe(E,ee,F){if(ee==null||!Array.isArray(E)||E.length===0)return null;const te=S=>S.value_product??S.valueProduct??S.value,ie=S=>S==null?null:F[S]||F[String(S)]||null,z=S=>String(S??"").toLowerCase().replace(/\s+/g," ").trim(),x=E.find(S=>{const N=te(S);return N!=null&&String(N)===String(ee)});if(x)return x;const u=ie(ee),ue=z(u?.name??u?.title);if(ue){const S=E.filter(N=>{const U=z(N.name??N.label??N.title);return U.length>0&&ue.includes(U)});if(S.length===1)return S[0]}const pe=u?u.productGraph??u.product_graph??null:null;if(pe!=null){const S=E.filter(N=>{const U=ie(te(N)),he=U?U.productGraph??U.product_graph??null:null;return he!=null&&String(he)===String(pe)});if(S.length===1)return S[0]}return null}function on({embedded:E=!1,optionSetIds:ee=null,filterFeatureIds:F=null,backHeader:te=!0}={}){F=ee??F;const ie=Pt("logo"),{confirmDialog:z,setConfirmDialog:x}=zt(),u=Yt(),ue=u.finishes,pe=u.widths,S=u.styles,N=u.handleTypes,U=u.hardwareFinishes,he=u.doorTypes,Je=u.productOverrides,Qe=u.materialOverrides,rn=u.materials,dn=u.freePieceTier,ln=u.freePieceWidthOption,an=u.setFinish,cn=u.setWidth,un=u.setStyle,pn=u.setHandleType,hn=u.setHardwareFinish,gn=u.setDoorType,mn=u.setProductOverride,Sn=u.setMaterialOverride,_n=u.setFreePieceTier,fn=u.setFreePieceWidthOption;Qt();const D=B("OptionSetSection",Jt),se=B("OptionThumbnail",tn),ge=B("FinishThumbnail",en),Ze=B("LayoutThumbnail",Zt),He=B("ChatBar",kt),et=B("HostedProductThumbnail",sn),tt=B("AddProductToggle",nn),me=B("ConfirmDialog",wt),{isMobile:nt,selectedFeatureId:G,selectedElementType:bn,isLayoutLoading:oe}=ze(),it=Ge("sidebar"),Fe=Ge("chat"),{selectedId:Se,locked:_e,instances:re,placementSelections:yn}=ke(),st=xt,ot=mt(_t,We,We),Ne=e=>{if(e==null)return null;const g=re?.[e];let r=Je?.[e]??g?.variantId??g?.productId??null;if(r==null&&String(e).endsWith("__host")){const i=w(),n=we(),o=String(e).replace(/__host$/,""),t=n.productInstances?.[o],s=i.getProduct?.(t?.variantId??t?.productId),a=s?.hostVariants??s?.host_variants,l=Array.isArray(a)?a.find(h=>h?.isDefault??h?.is_default)??a[0]:null;r=l?.hostVariantId??l?.host_variant_id??null}return r},{standalone:rt}=J(),{validCornerSlots:vn,wallCornerCount:Pn}=At(),{pending:fe}=J(),{pendingSlot:Ae}=J(),{placed:Y}=J(),{scene:dt,product:In,features:Cn,rulesReady:lt,rulesTriggerIndex:On}=Tt(),{name:at}=Bt(),{deferred:De}=J(),{occupiedSlots:kn}=J(),{pieceConfigSnapshot:wn}=ze(),Tn=e=>Y.some(g=>g.hostedProductId===e),de=Ie({}),T=Se!=null,f=Se??null;ae(()=>{G&&de.current[G]&&de.current[G].scrollIntoView({behavior:"smooth",block:"center"})},[G]);const Le=Ie(new Set);ae(()=>{const e=new Set((Y||[]).map(t=>t.id)),g=Le.current,r=[...e].filter(t=>!g.has(t)),i=[...g].filter(t=>!e.has(t));if(Le.current=e,r.length===0&&i.length===0||oe)return;const n=r,o=i.length>0;import("./a77b15c0d6.js").then(({placeHostedProduct:t,refreshCanonicalState:s})=>{n.forEach(a=>t(a)),o&&n.length===0&&s()}).catch(()=>{})},[Y,oe]),ae(()=>{if(!De)return;const e=setTimeout(()=>{ce().deferred&&(Kt(),Mt(),Q("Could not place the product \u2014 please try again"))},1e4);return()=>clearTimeout(e)},[De]);const{options:Re,materials:M,features:$}=Ft(),{activeSceneConfigId:be}=ke(),Be=Ht(),{sceneSelections:ct}=ke(),{disabled:Hn,hidden:ye,managedOptionSets:Fn,featureToOptions:Nn}=Nt(),W=$e(()=>be?Be(be):[],[be,Be,dt,ot]),An=$e(()=>{const e=W.find(n=>n.type==="layout_change"),g=W.filter(n=>n.type==="finish_change"),r=W.filter(n=>n.type==="load_new_product"),i=W.find(n=>n.type==="appliance_selection");return{layoutFeature:e,finishFeatures:g,productFeatures:r,appliancesFeature:i}},[W]),ut=Ie(new Map),pt=`${Object.keys($).length}_${Object.keys(Re).length}`;ae(()=>{ut.current.clear()},[pt]);const{getOptionsForFeature:O,getSelection:L,getEffectiveSelection:Dn,optionDisabledPropsFor:q,visibleOptions:X}=Gt(),le=qt,ht=(e,g)=>{const r=e?._hostedProductRecord||e;if(!r){Q("No product data.");return}const i=e?._hostedProductRecord?e:{id:r.id,name:r.name,isPlaced:Y?.some(o=>String(o.hostedProductId)===String(r.id)||String(o.hostedProductId)===String(r.optionId))||ce().standalone.some(o=>String(o.optionId)===String(r.optionId)||String(o.optionId)===String(r.id))};if(i.isPlaced){const o=we().productInstances,t=Object.values(o).find(s=>String(s.variantId??s.productId)===String(r.id));t&&import("./a77b15c0d6.js").then(({removeProduct:s})=>s(t.id)).then(s=>{s&&s.applied&&(st(t.id),Q(`${i.name} removed`))}).catch(()=>{});return}if(String(fe?.id)===String(r.id)||String(Ae?.productId)===String(r.id)){$t(),Vt();return}let n=r.modelUrl;if(!n&&r.id!=null&&(n=(It(r.id)||[]).find(t=>!!t.url)?.url||null),je(r)){const o=Dt(),t=Object.keys(o).filter(l=>Ct(l)==="base"&&o[l]?.position).sort((l,h)=>l.localeCompare(h,void 0,{numeric:!0}))[0];if(!t){Q(`Add a floor piece first \u2014 ${r.name} mounts above it.`);return}const s=o[t],a=`${St}${r.id}-${Date.now()}`;Rt({id:a,hostedProductId:r.id,name:r.name,modelUrl:n,position:[s.position[0],(s.position[1]||0)+1.5,s.position[2]],rotation:s.rotation||[0,0,0],scale:r.scale||[1,1,1],placement_type:"wall_mounted",replacedPiece:t}),Q(`${r.name} added`);return}Wt({productId:r.id,variantId:r.id,name:r.name??"product",compatibleGraphIds:Array.isArray(r.compatibleSlots)?r.compatibleSlots:Array.isArray(r.compatible_slots)?r.compatible_slots:[]}),Q(`Click a highlighted slot to place ${r.name}.`)},ve=()=>{jt(),Et()},Ee=e=>{const g=e?.feature_id??e?.id;let r=e?O(e)||[]:[];const i=T&&ye&&ye.size>0;let n=r.filter(t=>bt(g,t.id));i&&(n=n.filter(t=>!ye.has(String(t.id))));const o=n.map(t=>{const s=[t.value_product,t.valueProduct,typeof t.value=="number"?t.value:null].filter(c=>c!=null);let a=null,l=null;for(const c of s){const v=w().getHostedProduct(c);if(v){l=v,a=c;break}}l||(l={id:a??t.id,optionId:t.id,name:t.name||t.displayName||t.label||`Option ${t.id}`,thumbnail:t.thumbnail||t.thumbnailUrl||t.thumbnail_url||t.imageUrl||t.image_url||null,placement_type:"replace_full"});const h=l.optionId??l.option_id??l.id??t.id,b=rt?.some(c=>String(c.optionId)===String(h)||String(c.optionId)===String(l.id))||Y?.some(c=>String(c.hostedProductId)===String(h)||String(c.hostedProductId)===String(l.id))||Object.values(re||{}).some(c=>String(c.variantId??c.productId)===String(l.id));let y=!1;if(!b){const c=new Set((l.compatibleSlots??l.compatible_slots??[]).map(String)),v=w();y=je(l)?Object.keys(re||{}).length>0:c.size>0&&Object.values(re||{}).some(I=>{const K=v.getProduct?.(I.variantId)||v.getProduct?.(I.productId),R=K?.product_graph??K?.productGraph;return R!=null&&c.has(String(R))})}const A=!Ke(g,t.id),_=A||!b&&!y,m=A?"Not available":null;return{id:h,optId:t.id,name:l.name||String(h),thumbnail:l.thumbnail||l.thumbnailUrl||l.icon||null,description:l.description,isPlaced:b,isDisabled:_,disabledReason:m,canReplace:b,_hostedProductRecord:l}});return o.length===0?null:d(D,{title:e?.name?.toUpperCase()||"APPLIANCES",presentation:e?.presentation,gridClassName:"thumbnail-grid thumbnail-grid--hosted",beforeGrid:fe&&d("p",{className:"sidebar__hint",children:"Click on a highlighted slot in the scene to place the hostedProduct"}),children:o.map(t=>d(et,{hostedProduct:t,isSelected:fe?.id===t.id||String(Ae?.productId)===String(t.id),isPlaced:t.isPlaced,canReplace:t.canReplace,isDisabled:t.isDisabled,onClick:()=>ht(t,e)},t.optId??t.id))})},xe=(e,g)=>{if(!e)return null;const r=g||new Set;if(e.contentKind==="group"||Array.isArray(e.childOptionSetIds)&&e.childOptionSetIds.length>0){if(r.has(e.id))return null;const i=r.size;r.add(e.id);const n=w().features,o=e.childOptionSetIds&&e.childOptionSetIds.length?e.childOptionSetIds:n[e.id]?.childOptionSetIds||[],t=s=>{const a=n[s];if(!a)return null;let l=a.type;return(l==="layout_change"||l==="load_configuration")&&(l="layout_change"),{id:s,feature_id:s,name:a.name,type:l,contentKind:a.contentKind||"options",childOptionSetIds:a.childOptionSetIds||[],default_option_id:a.default_option_id??a.defaultOption,...a.presentation?{presentation:a.presentation}:{}}};return d(D,{labelKey:e.id,sectionRef:s=>de.current[e.id]=s,className:`sidebar__section sidebar__section--group ${G===e.id?"sidebar__section--highlighted":""}`,title:e.name?.toUpperCase(),presentation:e.presentation||"inline",flow:e.flow||"column",kind:"group",depth:i,children:o.map(s=>{const a=t(s);return a?d("div",{className:"sidebar__group-child",children:xe(a,r)},s):null})},e.id)}if(e.type==="layout_change")return d(D,{labelKey:e.id,sectionRef:i=>de.current[e.id]=i,className:`sidebar__section ${G===e.id?"sidebar__section--highlighted":""}`,title:e.name?.toUpperCase()||"LAYOUT",presentation:e.presentation,flow:e.flow,gridClassName:"thumbnail-grid thumbnail-grid--layout",children:X(e.id,O(e)).map(i=>d(Ze,{option:q(e.id,i).disabled?{...i,...q(e.id,i)}:i,isSelected:L(e.id)===i.id,onClick:()=>{if(L(e.id)===i.id)return;const n=ce(),o=n.initialPerPieceOverrides||{},t=(_,m)=>{if(_===m)return!1;const c=_||{},v=m||{},I=Object.keys(c),K=Object.keys(v);if(I.length!==K.length)return!0;for(const R of I)if(c[R]!==v[R])return!0;return!1},a=((_,m)=>{if(_===m)return!1;const c=_||[],v=m||[];if(c.length!==v.length)return!0;for(let I=0;I<c.length;I++)if(c[I]!==v[I])return!0;return!1})(Y,o.sceneHostedProducts)||t(n.hostFinishes,o.hostFinishes)||t(n.hostStyles,o.hostStyles)||t(n.hostHandleTypes,o.hostHandleTypes)||t(n.hostWidths,o.hostWidths)||t(n.hostDoorTypes,o.hostDoorTypes)||t(n.hostProductOverrides,o.hostProductOverrides)||t(n.hostHardwareFinishes,o.hostHardwareFinishes),l=o.sceneSelections||{},h=W.some(_=>{if(_.type==="layout_change")return!1;const m=ct[_.id];if(!m)return!1;const c=l[_.id];return c!==void 0?m!==c:_.default_option_id?m!==_.default_option_id:Re[m]?.value!==null}),b=!!n.initialPieceConfigSnapshot&&!!n.pieceConfigSnapshot&&n.pieceConfigSnapshot!==n.initialPieceConfigSnapshot,y=(n.disabledWalls||[]).length>0;a||h||b||y?x({title:"Change Layout",message:"You will lose the existing configuration. Do you want to continue?",confirmText:"Yes",cancelText:"No",onConfirm:()=>{Lt(),le(e.id,i.id)},onCancel:()=>{}}):le(e.id,i.id)}},i.id))},e.id);if(e.type==="load_new_product"){const i=O(e),n=w().products;if(i.some(t=>{const s=t.value_product??t.valueProduct??(typeof t.value=="number"?t.value:null)??(typeof t.value=="string"&&n[t.value]?t.value:null);return s!=null&&n[s]?.category==="island"}))return d(tt,{optionSet:e,getOptionsForSet:O,feature:e,getOptionsForFeature:O,getSelection:L,onSelectionChange:le},e.id)}if(e.type==="finish_change"&&!T){const i=O(e);if(i.length>0&&i.some(o=>!!M?.[o.value]))return d(D,{labelKey:e.id,title:e.name?.toUpperCase(),presentation:e.presentation,flow:e.flow,gridClassName:"thumbnail-grid thumbnail-grid--finish",children:X(e.id,i).map(o=>{const t=q(e.id,o);return d(ge,{option:t.disabled?{...o,...t}:o,material:M[o.value],isSelected:L(e.id)===o.id,onClick:()=>{le(e.id,o.id,e)}},o.id)})},e.id)}{const i=w().products,n=O(e);if(e.type==="appliance_selection"||n.some(t=>{const s=t.value_product??t.valueProduct;return s!=null&&Ot(i?.[s])}))return Ee(e)}if(e.type==="load_new_component"||e.type==="load_new_product"||e.type==="product_change"){let i=null;if((e.type==="load_new_product"||e.type==="product_change")&&T&&f!=null){const n=Ne(f),o=Xe(O(e),n,w().products);o&&(i=o.id)}return d(D,{labelKey:e.id,title:e.name?.toUpperCase(),presentation:e.presentation,flow:e.flow,gridClassName:"thumbnail-grid thumbnail-grid--options",children:X(e.id,O(e)).map(n=>{const o=!Ke(e.id,n.id);return d(se,{option:o?{...n,disabled:!0,disabledReason:o?"Not available":null}:n,isSelected:i!=null?String(i)===String(n.id):String(L(e.id))===String(n.id),onClick:()=>Xt(e,n)},n.id)})},e.id)}if(e.type==="appliance_selection")return Ee(e);if(e.type==="finish_change"&&!T)return d(D,{labelKey:e.id,title:e.name?.toUpperCase(),presentation:e.presentation,flow:e.flow,gridClassName:"thumbnail-grid thumbnail-grid--options",children:X(e.id,O(e)).map(i=>{const n=q(e.id,i);return d(se,{option:n.disabled?{...i,...n}:i,isSelected:L(e.id)===i.id,onClick:()=>{if(n.disabled)return;const o=$?.[e.id]||$?.[String(e.id)]||e;Oe({option:i,feature:{...e||{},...o},scope:T?"single":"all",pieceIndex:T?f:null}).scope||Ye(e.id,i.id)}},i.id)})},e.id);if(e.type==="finish_change"&&T){const i=O(e),n=i.length>0&&i.some(t=>!!M?.[t.value]),o=t=>{const s=$?.[e.id]||$?.[String(e.id)]||e;Oe({option:t,feature:{...e||{},...s},scope:T?"single":"all",pieceIndex:T?f:null}).scope||Ye(e.id,t.id)};return d(D,{labelKey:e.id,title:e.name?.toUpperCase(),presentation:e.presentation,flow:e.flow,gridClassName:`thumbnail-grid ${n?"thumbnail-grid--finish":"thumbnail-grid--options"}`,children:X(e.id,i).map(t=>{const s=q(e.id,t),a=s.disabled?{...t,...s}:t;return n?d(ge,{option:a,material:M[t.value],isSelected:L(e.id)===t.id,onClick:()=>{s.disabled||o(t)}},t.id):d(se,{option:a,isSelected:L(e.id)===t.id,onClick:()=>{s.disabled||o(t)}},t.id)})},e.id)}return null},ne=()=>C(Z,{children:[d(qe,{name:"sidebar-top",ctx:{placementId:f??null}}),(()=>{const e=(()=>{if(!(T&&f!=null))return null;const i=w(),n=we(),o=n.productInstances?.[f];let t=o?.variantId??o?.productId;if(t==null&&String(f).endsWith("__host")){const h=String(f).replace(/__host$/,""),b=n.productInstances?.[h],y=i.getProduct?.(b?.variantId??b?.productId),A=y?.hostVariants??y?.host_variants,_=Array.isArray(A)?A.find(m=>m?.isDefault??m?.is_default)??A[0]:null;t=_?.hostVariantId??_?.host_variant_id??null}t=t??ce().hostProductOverrides?.[f]??f;const s=i.getProduct?.(t)||i.getProduct?.(f),a=s?.optionSets||s?.features_configuration_ids||[];if(!Array.isArray(a)||a.length===0)return null;const l=new Set;for(const h of a){const b=h&&typeof h=="object"?h.optionSetId??h.option_set_id??h.id??h.feature_id:h;b!=null&&l.add(String(b))}return l})(),g=new Set,r=Array.isArray(F)?new Set(F.map(String)):null;return W.filter(i=>{const n=String(i?.feature_id??i?.id??"");return!n||g.has(n)||(g.add(n),r&&!r.has(n)&&!r.has(String(i?.id))&&!r.has(String(i?.feature_id)))?!1:i?.type==="finish_change"?!0:!(e&&!e.has(n)&&!e.has(String(i?.id))&&!e.has(String(i?.feature_id)))}).map(i=>d("div",{children:xe(i)},i.id))})(),d(qe,{name:"sidebar-bottom",ctx:{placementId:f??null}})]}),gt=()=>{const e=f,g=yt(e),r=[...Ve(e)].filter(t=>!g||g.includes(String(t.optionSetId))).sort((t,s)=>(t.sequence??0)-(s.sequence??0)),i=Array.isArray(F)?new Set(F.map(String)):null;let n=r;if(i){const t=r.filter(s=>i.has(String(s.optionSetId)));t.length>0&&(n=t)}const o=ft(e)||{};return!n.length&&!_e?null:C(Z,{children:[_e&&d("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"8px 12px",marginBottom:10,borderRadius:6,fontSize:13,background:"rgba(120,120,120,0.12)",borderLeft:"3px solid #888",color:"inherit"},children:"\u{1F512} This item is locked and can\u2019t be changed."}),d("div",{style:_e?{opacity:.5,pointerEvents:"none"}:void 0,children:n.map(t=>{const s=t.optionSetId,a=$[s]||$[String(s)]||{id:s,name:""},l=a.type,h={id:s,feature_id:s,name:a.name,options:a.options},b=new Set((t.available||[]).map(String)),y=O(h);if(!y.length)return null;const A=l==="load_new_product"||l==="product_change",_=/finish/i.test(String(l||"")),m=!A&&y.length>0&&(_?y.some(p=>!!M?.[p.value]):y.every(p=>!!M?.[p.value])),c=o[s]??o[String(s)]??t.default??null;let v=null;if(l==="load_new_product"||l==="product_change"){const p=Ne(e),H=Xe(y,p,w().products);H&&(v=H.id)}let I=null;if(m){const p=Qe?.[e]||{},H=new Set((a.material_targets??a.materialTargets??a.materials??[]).map(P=>String(P).toLowerCase())),k=new Set(Object.entries(p).filter(([P])=>H.size===0||H.has(String(P).toLowerCase())).map(([,P])=>String(P)));if(k.size>0){const P=y.find(j=>j.value!=null&&k.has(String(j.value)));P&&(I=P.id)}}const K=v??I??c,R=p=>{if(l&&/finish/i.test(String(l))){Oe({option:p,feature:a,scope:"single",pieceIndex:e});return}if(l==="load_new_product"){const k=p.value??p.valueText??p.value_text,P=w().products,j=k!=null?P[k]||P[String(k)]:null;j?.id!=null&&Ut(e,j.id)}const H=String(e).endsWith("__host")?String(e).replace(/__host$/,""):e;import("./a77b15c0d6.js").then(({selectOptionForProduct:k})=>k({placementId:H,optionSetId:s,optionId:p.id})).catch(()=>{})};return d(D,{labelKey:s,title:String(a.name||"").toUpperCase(),presentation:a.presentation,flow:a.flow,gridClassName:`thumbnail-grid ${m?"thumbnail-grid--finish":"thumbnail-grid--options"}`,children:X(s,y).map(p=>{const H=q(s,p),k=b.size>0&&!b.has(String(p.id)),P=H.disabled||k,j=H.disabledReason||(k?"Not available":null),Me=P?{...p,disabled:!0,disabledReason:j}:p;return m?d(ge,{option:Me,material:M[p.value],isSelected:String(K)===String(p.id),onClick:()=>{P||R(p)}},p.id):d(se,{option:Me,isSelected:String(K)===String(p.id),onClick:()=>{P||R(p)}},p.id)})},s)})})]})},V=Se!=null,Ue=V&&[...Ve(f)||[]].length>0,Pe=()=>Ue?gt()??ne():ne();return E?C("div",{className:"sidebar sidebar--embedded",style:oe?{opacity:.5,pointerEvents:"none"}:void 0,children:[V&&Ue&&te&&d("div",{className:"sidebar__mobile-header",children:C("button",{className:"sidebar__back-btn",onClick:ve,children:[d(Ce,{}),d("span",{children:"Selected"})]})}),d("div",{className:"sidebar__content",children:V?Pe():ne()}),d(me,{dialog:z,onClose:()=>x(null)})]}):it?nt?C(Z,{children:[V&&te&&d("div",{className:"sidebar__mobile-header",children:C("button",{className:"sidebar__back-btn",onClick:ve,children:[d(Ce,{}),d("span",{children:"Selected"})]})}),d("div",{className:"sidebar__content sidebar__content--mobile",children:V?Pe():ne()}),d(me,{dialog:z,onClose:()=>x(null)})]}):C(Z,{children:[C("div",{"data-sdk-overlay":!0,className:"sidebar-container",style:oe?{opacity:.5,pointerEvents:"none"}:void 0,children:[C("aside",{className:"sidebar sidebar--card",children:[d("div",{className:"sidebar__header",children:V?C("button",{className:"sidebar__back-btn",onClick:ve,children:[d(Ce,{}),d("span",{children:"Selected"})]}):C(Z,{children:[C("div",{className:"sidebar__logo",children:[ie?C(Z,{children:[d(vt,{className:"sidebar__logo-icon"}),d("span",{className:"sidebar__logo-divider"})]}):null,d("span",{className:"sidebar__logo-text",children:at||"Configurator"})]}),d("div",{className:"sidebar__header-actions"})]})}),d("div",{className:"sidebar__content",children:V?Pe():ne()})]}),Fe&&d("div",{className:"sidebar-chat-card",children:d(He,{})})]}),d(me,{dialog:z,onClose:()=>x(null)})]}):Fe?d("div",{"data-sdk-overlay":!0,className:"sidebar-container sidebar-container--chat-only",children:d("div",{className:"sidebar-chat-card",children:d(He,{})})}):null}var zi=on;export{zi as default};
|
|
1
|
+
import{Fragment as Q,jsx as d,jsxs as C}from"react/jsx-runtime";import{useMemo as We,useRef as Oe,useEffect as ue,useSyncExternalStore as bt}from"react";import{HOSTED_PLACEMENT_ID_PREFIX as ft}from"./23dc0ccf32.js";import"./4d7a0d1897.js";import"./ab6c80484f.js";import{subscribe as yt,getVersion as Ve,getPlacementBindings as Ke,getEffectiveSelections as vt,isOptionAvailable as je,isOptionVisible as Pt,getPlacementOSAllowlist as It}from"./817d930a49.js";import{ChevronLeft as ke,LogoIcon as Ct}from"./c5e990946e.js";import{useHasIcon as Ot}from"./09c4973968.js";import{getProductAllComponents as kt,pieceKindOf as wt}from"./9326c23506.js";import{isHostedProduct as Ht,isHostFloating as ze}from"./061b81ad81.js";import"./87dcc12b65.js";import"./ee242c0099.js";import{applyFinishClick as we}from"./dc2a1a0e13.js";import Tt from"./54f0fcf38b.js";import Ft from"./c4790179f1.js";import{useSystemConfig as Nt,useSceneFeaturesReader as At}from"./6855e6a3b1.js";import{getCatalog as w,useCatalogMaps as Dt}from"./1458417bdb.js";import{useUIState as Ge,useOptionGating as Lt,useHostedProductState as X,getUIState as pe,useUIRegion as Ye}from"./9840b9ce12.js";import{useCornerSlots as Rt,getBasePiecePositions as Bt,clearOverlapFlags as Et,appendSceneHostedProduct as xt}from"./367a479d3a.js";import{useSceneState as He,getSceneState as Te}from"./16a399703e.js";import{useSystem as Ut}from"./066fc9aa40.js";import{setSceneSelection as qe,clearSceneSelection as Mt,removeSceneInstance as $t,showInfo as J,clearSceneLoading as Wt,clearPendingHostedProduct as Vt,setPendingSlotPlacement as Kt,clearPendingSlotPlacement as jt,clearDeferredHostedProductPlacement as zt,deselect as Gt}from"./2cafe3274b.js";import Yt from"./6e2595aa36.js";import qt from"./2990ba64d6.js";import Xt from"./6ba86aa3b8.js";import{selectOption as Jt,selectProductOption as Qt}from"./dbd5ba1d07.js";import"./9526094bb7.js";import"./2774152dd2.js";import Zt from"./3fb3ab6757.js";import{resolveComponent as L,useComponentRegistry as en}from"./882bc739c8.js";import{SlotHost as Xe}from"./73f7d65985.js";import{resolveHostVariantId as Je}from"./be07a7f885.js";import{LayoutThumbnail as tn,FinishThumbnail as nn,OptionThumbnail as sn,AddProductToggle as on,HostedProductThumbnail as rn}from"./c12c112c6f.js";import"./239b619005.css";let Fe=null;function Yi(){return Fe||(Fe=w().listHostedProducts()),Fe}function Qe(R,Z,T){if(Z==null||!Array.isArray(R)||R.length===0)return null;const ee=S=>S.value_product??S.valueProduct??S.value,ie=S=>S==null?null:T[S]||T[String(S)]||null,j=S=>String(S??"").toLowerCase().replace(/\s+/g," ").trim(),B=R.find(S=>{const F=ee(S);return F!=null&&String(F)===String(Z)});if(B)return B;const u=ie(Z),ge=j(u?.name??u?.title);if(ge){const S=R.filter(F=>{const E=j(F.name??F.label??F.title);return E.length>0&&ge.includes(E)});if(S.length===1)return S[0]}const he=u?u.productGraph??u.product_graph??null:null;if(he!=null){const S=R.filter(F=>{const E=ie(ee(F)),me=E?E.productGraph??E.product_graph??null:null;return me!=null&&String(me)===String(he)});if(S.length===1)return S[0]}return null}function dn({embedded:R=!1,optionSetIds:Z=null,filterFeatureIds:T=null,backHeader:ee=!0}={}){T=Z??T;const ie=Ot("logo"),{confirmDialog:j,setConfirmDialog:B}=Yt(),u=Xt(),ge=u.finishes,he=u.widths,S=u.styles,F=u.handleTypes,E=u.hardwareFinishes,me=u.doorTypes,Ze=u.productOverrides,et=u.materialOverrides,ln=u.materials,an=u.freePieceTier,cn=u.freePieceWidthOption,un=u.setFinish,pn=u.setWidth,gn=u.setStyle,hn=u.setHandleType,mn=u.setHardwareFinish,Sn=u.setDoorType,_n=u.setProductOverride,bn=u.setMaterialOverride,fn=u.setFreePieceTier,yn=u.setFreePieceWidthOption;en();const N=L("OptionSetSection",Zt),se=L("OptionThumbnail",sn),Se=L("FinishThumbnail",nn),tt=L("LayoutThumbnail",tn),Ne=L("ChatBar",Tt),nt=L("HostedProductThumbnail",rn),it=L("AddProductToggle",on),_e=L("ConfirmDialog",Ft),{isMobile:st,selectedFeatureId:z,selectedElementType:vn,isLayoutLoading:oe}=Ge(),ot=Ye("sidebar"),Ae=Ye("chat"),{selectedId:be,locked:fe,instances:re,placementSelections:Pn}=He(),rt=$t,dt=bt(yt,Ve,Ve),De=e=>{if(e==null)return null;const g=re?.[e];let r=Ze?.[e]??g?.variantId??g?.productId??null;if(r==null&&String(e).endsWith("__host")){const i=w(),n=Te(),o=String(e).replace(/__host$/,""),t=n.productInstances?.[o],s=i.getProduct?.(t?.variantId??t?.productId);r=Je(s,t)}return r},{standalone:lt}=X(),{validCornerSlots:In,wallCornerCount:Cn}=Rt(),{pending:ye}=X(),{pendingSlot:Le}=X(),{placed:G}=X(),{scene:at,product:On,features:kn,rulesReady:ct,rulesTriggerIndex:wn}=Nt(),{name:ut}=Ut(),{deferred:Re}=X(),{occupiedSlots:Hn}=X(),{pieceConfigSnapshot:Tn}=Ge(),Fn=e=>G.some(g=>g.hostedProductId===e),de=Oe({}),H=be!=null,f=be??null;ue(()=>{z&&de.current[z]&&de.current[z].scrollIntoView({behavior:"smooth",block:"center"})},[z]);const Be=Oe(new Set);ue(()=>{const e=new Set((G||[]).map(t=>t.id)),g=Be.current,r=[...e].filter(t=>!g.has(t)),i=[...g].filter(t=>!e.has(t));if(Be.current=e,r.length===0&&i.length===0||oe)return;const n=r,o=i.length>0;import("./a77b15c0d6.js").then(({placeHostedProduct:t,refreshCanonicalState:s})=>{n.forEach(a=>t(a)),o&&n.length===0&&s()}).catch(()=>{})},[G,oe]),ue(()=>{if(!Re)return;const e=setTimeout(()=>{pe().deferred&&(zt(),Wt(),J("Could not place the product \u2014 please try again"))},1e4);return()=>clearTimeout(e)},[Re]);const{options:Ee,materials:x,features:U}=Dt(),{activeSceneConfigId:ve}=He(),xe=At(),{sceneSelections:pt}=He(),{disabled:Nn,hidden:Pe,managedOptionSets:An,featureToOptions:Dn}=Lt(),M=We(()=>ve?xe(ve):[],[ve,xe,at,dt]),Ln=We(()=>{const e=M.find(n=>n.type==="layout_change"),g=M.filter(n=>n.type==="finish_change"),r=M.filter(n=>n.type==="load_new_product"),i=M.find(n=>n.type==="appliance_selection");return{layoutFeature:e,finishFeatures:g,productFeatures:r,appliancesFeature:i}},[M]),gt=Oe(new Map),ht=`${Object.keys(U).length}_${Object.keys(Ee).length}`;ue(()=>{gt.current.clear()},[ht]);const{getOptionsForFeature:O,getSelection:A,getEffectiveSelection:Rn,optionDisabledPropsFor:Y,visibleOptions:q}=qt(),le=Jt,mt=(e,g)=>{const r=e?._hostedProductRecord||e;if(!r){J("No product data.");return}const i=e?._hostedProductRecord?e:{id:r.id,name:r.name,isPlaced:G?.some(o=>String(o.hostedProductId)===String(r.id)||String(o.hostedProductId)===String(r.optionId))||pe().standalone.some(o=>String(o.optionId)===String(r.optionId)||String(o.optionId)===String(r.id))};if(i.isPlaced){const o=Te().productInstances,t=Object.values(o).find(s=>String(s.variantId??s.productId)===String(r.id));t&&import("./a77b15c0d6.js").then(({removeProduct:s})=>s(t.id)).then(s=>{s&&s.applied&&(rt(t.id),J(`${i.name} removed`))}).catch(()=>{});return}if(String(ye?.id)===String(r.id)||String(Le?.productId)===String(r.id)){Vt(),jt();return}let n=r.modelUrl;if(!n&&r.id!=null&&(n=(kt(r.id)||[]).find(t=>!!t.url)?.url||null),ze(r)){const o=Bt(),t=Object.keys(o).filter(l=>wt(l)==="base"&&o[l]?.position).sort((l,h)=>l.localeCompare(h,void 0,{numeric:!0}))[0];if(!t){J(`Add a floor piece first \u2014 ${r.name} mounts above it.`);return}const s=o[t],a=`${ft}${r.id}-${Date.now()}`;xt({id:a,hostedProductId:r.id,name:r.name,modelUrl:n,position:[s.position[0],(s.position[1]||0)+1.5,s.position[2]],rotation:s.rotation||[0,0,0],scale:r.scale||[1,1,1],placement_type:"wall_mounted",replacedPiece:t}),J(`${r.name} added`);return}Kt({productId:r.id,variantId:r.id,name:r.name??"product",compatibleGraphIds:Array.isArray(r.compatibleSlots)?r.compatibleSlots:Array.isArray(r.compatible_slots)?r.compatible_slots:[]}),J(`Click a highlighted slot to place ${r.name}.`)},Ie=()=>{Gt(),Mt()},Ue=e=>{const g=e?.feature_id??e?.id;let r=e?O(e)||[]:[];const i=H&&Pe&&Pe.size>0;let n=r.filter(t=>Pt(g,t.id));i&&(n=n.filter(t=>!Pe.has(String(t.id))));const o=n.map(t=>{const s=[t.value_product,t.valueProduct,typeof t.value=="number"?t.value:null].filter(c=>c!=null);let a=null,l=null;for(const c of s){const v=w().getHostedProduct(c);if(v){l=v,a=c;break}}l||(l={id:a??t.id,optionId:t.id,name:t.name||t.displayName||t.label||`Option ${t.id}`,thumbnail:t.thumbnail||t.thumbnailUrl||t.thumbnail_url||t.imageUrl||t.image_url||null,placement_type:"replace_full"});const h=l.optionId??l.option_id??l.id??t.id,_=lt?.some(c=>String(c.optionId)===String(h)||String(c.optionId)===String(l.id))||G?.some(c=>String(c.hostedProductId)===String(h)||String(c.hostedProductId)===String(l.id))||Object.values(re||{}).some(c=>String(c.variantId??c.productId)===String(l.id));let P=!1;if(!_){const c=new Set((l.compatibleSlots??l.compatible_slots??[]).map(String)),v=w();P=ze(l)?Object.keys(re||{}).length>0:c.size>0&&Object.values(re||{}).some(I=>{const W=v.getProduct?.(I.variantId)||v.getProduct?.(I.productId),D=W?.product_graph??W?.productGraph;return D!=null&&c.has(String(D))})}const ne=!je(g,t.id),y=ne||!_&&!P,b=ne?"Not available":null;return{id:h,optId:t.id,name:l.name||String(h),thumbnail:l.thumbnail||l.thumbnailUrl||l.icon||null,description:l.description,isPlaced:_,isDisabled:y,disabledReason:b,canReplace:_,_hostedProductRecord:l}});return o.length===0?null:d(N,{title:e?.name?.toUpperCase()||"APPLIANCES",presentation:e?.presentation,gridClassName:"thumbnail-grid thumbnail-grid--hosted",beforeGrid:ye&&d("p",{className:"sidebar__hint",children:"Click on a highlighted slot in the scene to place the hostedProduct"}),children:o.map(t=>d(nt,{hostedProduct:t,isSelected:ye?.id===t.id||String(Le?.productId)===String(t.id),isPlaced:t.isPlaced,canReplace:t.canReplace,isDisabled:t.isDisabled,onClick:()=>mt(t,e)},t.optId??t.id))})},Me=(e,g)=>{if(!e)return null;const r=g||new Set;if(e.contentKind==="group"||Array.isArray(e.childOptionSetIds)&&e.childOptionSetIds.length>0){if(r.has(e.id))return null;const i=r.size;r.add(e.id);const n=w().features,o=e.childOptionSetIds&&e.childOptionSetIds.length?e.childOptionSetIds:n[e.id]?.childOptionSetIds||[],t=s=>{const a=n[s];if(!a)return null;let l=a.type;return(l==="layout_change"||l==="load_configuration")&&(l="layout_change"),{id:s,feature_id:s,name:a.name,type:l,contentKind:a.contentKind||"options",childOptionSetIds:a.childOptionSetIds||[],default_option_id:a.default_option_id??a.defaultOption,...a.presentation?{presentation:a.presentation}:{}}};return d(N,{labelKey:e.id,sectionRef:s=>de.current[e.id]=s,className:`sidebar__section sidebar__section--group ${z===e.id?"sidebar__section--highlighted":""}`,title:e.name?.toUpperCase(),presentation:e.presentation||"inline",flow:e.flow||"column",kind:"group",depth:i,children:o.map(s=>{const a=t(s);return a?d("div",{className:"sidebar__group-child",children:Me(a,r)},s):null})},e.id)}if(e.type==="layout_change")return d(N,{labelKey:e.id,sectionRef:i=>de.current[e.id]=i,className:`sidebar__section ${z===e.id?"sidebar__section--highlighted":""}`,title:e.name?.toUpperCase()||"LAYOUT",presentation:e.presentation,flow:e.flow,gridClassName:"thumbnail-grid thumbnail-grid--layout",children:q(e.id,O(e)).map(i=>d(tt,{option:Y(e.id,i).disabled?{...i,...Y(e.id,i)}:i,isSelected:A(e.id)===i.id,onClick:()=>{if(A(e.id)===i.id)return;const n=pe(),o=n.initialPerPieceOverrides||{},t=(y,b)=>{if(y===b)return!1;const c=y||{},v=b||{},I=Object.keys(c),W=Object.keys(v);if(I.length!==W.length)return!0;for(const D of I)if(c[D]!==v[D])return!0;return!1},a=((y,b)=>{if(y===b)return!1;const c=y||[],v=b||[];if(c.length!==v.length)return!0;for(let I=0;I<c.length;I++)if(c[I]!==v[I])return!0;return!1})(G,o.sceneHostedProducts)||t(n.hostFinishes,o.hostFinishes)||t(n.hostStyles,o.hostStyles)||t(n.hostHandleTypes,o.hostHandleTypes)||t(n.hostWidths,o.hostWidths)||t(n.hostDoorTypes,o.hostDoorTypes)||t(n.hostProductOverrides,o.hostProductOverrides)||t(n.hostHardwareFinishes,o.hostHardwareFinishes),l=o.sceneSelections||{},h=M.some(y=>{if(y.type==="layout_change")return!1;const b=pt[y.id];if(!b)return!1;const c=l[y.id];return c!==void 0?b!==c:y.default_option_id?b!==y.default_option_id:Ee[b]?.value!==null}),_=!!n.initialPieceConfigSnapshot&&!!n.pieceConfigSnapshot&&n.pieceConfigSnapshot!==n.initialPieceConfigSnapshot,P=(n.disabledWalls||[]).length>0;a||h||_||P?B({title:"Change Layout",message:"You will lose the existing configuration. Do you want to continue?",confirmText:"Yes",cancelText:"No",onConfirm:()=>{Et(),le(e.id,i.id)},onCancel:()=>{}}):le(e.id,i.id)}},i.id))},e.id);if(e.type==="load_new_product"){const i=O(e),n=w().products;if(i.some(t=>{const s=t.value_product??t.valueProduct??(typeof t.value=="number"?t.value:null)??(typeof t.value=="string"&&n[t.value]?t.value:null);return s!=null&&n[s]?.category==="island"}))return d(it,{optionSet:e,getOptionsForSet:O,feature:e,getOptionsForFeature:O,getSelection:A,onSelectionChange:le},e.id)}if(e.type==="finish_change"&&!H){const i=O(e);if(i.length>0&&i.some(o=>!!x?.[o.value]))return d(N,{labelKey:e.id,title:e.name?.toUpperCase(),presentation:e.presentation,flow:e.flow,gridClassName:"thumbnail-grid thumbnail-grid--finish",children:q(e.id,i).map(o=>{const t=Y(e.id,o);return d(Se,{option:t.disabled?{...o,...t}:o,material:x[o.value],isSelected:A(e.id)===o.id,onClick:()=>{le(e.id,o.id,e)}},o.id)})},e.id)}{const i=w().products,n=O(e);if(e.type==="appliance_selection"||n.some(t=>{const s=t.value_product??t.valueProduct;return s!=null&&Ht(i?.[s])}))return Ue(e)}if(e.type==="load_new_component"||e.type==="load_new_product"||e.type==="product_change"){let i=null;if((e.type==="load_new_product"||e.type==="product_change")&&H&&f!=null){const n=De(f),o=Qe(O(e),n,w().products);o&&(i=o.id)}return d(N,{labelKey:e.id,title:e.name?.toUpperCase(),presentation:e.presentation,flow:e.flow,gridClassName:"thumbnail-grid thumbnail-grid--options",children:q(e.id,O(e)).map(n=>{const o=!je(e.id,n.id);return d(se,{option:o?{...n,disabled:!0,disabledReason:o?"Not available":null}:n,isSelected:i!=null?String(i)===String(n.id):String(A(e.id))===String(n.id),onClick:()=>Qt(e,n)},n.id)})},e.id)}if(e.type==="appliance_selection")return Ue(e);if(e.type==="finish_change"&&!H)return d(N,{labelKey:e.id,title:e.name?.toUpperCase(),presentation:e.presentation,flow:e.flow,gridClassName:"thumbnail-grid thumbnail-grid--options",children:q(e.id,O(e)).map(i=>{const n=Y(e.id,i);return d(se,{option:n.disabled?{...i,...n}:i,isSelected:A(e.id)===i.id,onClick:()=>{if(n.disabled)return;const o=U?.[e.id]||U?.[String(e.id)]||e;we({option:i,feature:{...e||{},...o},scope:H?"single":"all",pieceIndex:H?f:null}).scope||qe(e.id,i.id)}},i.id)})},e.id);if(e.type==="finish_change"&&H){const i=O(e),n=i.length>0&&i.some(t=>!!x?.[t.value]),o=t=>{const s=U?.[e.id]||U?.[String(e.id)]||e;we({option:t,feature:{...e||{},...s},scope:H?"single":"all",pieceIndex:H?f:null}).scope||qe(e.id,t.id)};return d(N,{labelKey:e.id,title:e.name?.toUpperCase(),presentation:e.presentation,flow:e.flow,gridClassName:`thumbnail-grid ${n?"thumbnail-grid--finish":"thumbnail-grid--options"}`,children:q(e.id,i).map(t=>{const s=Y(e.id,t),a=s.disabled?{...t,...s}:t;return n?d(Se,{option:a,material:x[t.value],isSelected:A(e.id)===t.id,onClick:()=>{s.disabled||o(t)}},t.id):d(se,{option:a,isSelected:A(e.id)===t.id,onClick:()=>{s.disabled||o(t)}},t.id)})},e.id)}return null},te=()=>C(Q,{children:[d(Xe,{name:"sidebar-top",ctx:{placementId:f??null}}),(()=>{const e=(()=>{if(!(H&&f!=null))return null;const i=w(),n=Te(),o=n.productInstances?.[f];let t=o?.variantId??o?.productId;if(t==null&&String(f).endsWith("__host")){const h=String(f).replace(/__host$/,""),_=n.productInstances?.[h],P=i.getProduct?.(_?.variantId??_?.productId);t=Je(P,_)}t=t??pe().hostProductOverrides?.[f]??f;const s=i.getProduct?.(t)||i.getProduct?.(f),a=s?.optionSets||s?.features_configuration_ids||[];if(!Array.isArray(a)||a.length===0)return null;const l=new Set;for(const h of a){const _=h&&typeof h=="object"?h.optionSetId??h.option_set_id??h.id??h.feature_id:h;_!=null&&l.add(String(_))}return l})(),g=new Set,r=Array.isArray(T)?new Set(T.map(String)):null;return M.filter(i=>{const n=String(i?.feature_id??i?.id??"");return!n||g.has(n)||(g.add(n),r&&!r.has(n)&&!r.has(String(i?.id))&&!r.has(String(i?.feature_id)))?!1:i?.type==="finish_change"?!0:!(e&&!e.has(n)&&!e.has(String(i?.id))&&!e.has(String(i?.feature_id)))}).map(i=>d("div",{children:Me(i)},i.id))})(),d(Xe,{name:"sidebar-bottom",ctx:{placementId:f??null}})]}),St=()=>{const e=f,g=It(e),r=[...Ke(e)].filter(t=>!g||g.includes(String(t.optionSetId))).sort((t,s)=>(t.sequence??0)-(s.sequence??0)),i=Array.isArray(T)?new Set(T.map(String)):null;let n=r;if(i){const t=r.filter(s=>i.has(String(s.optionSetId)));t.length>0&&(n=t)}const o=vt(e)||{};return!n.length&&!fe?null:C(Q,{children:[fe&&d("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"8px 12px",marginBottom:10,borderRadius:6,fontSize:13,background:"rgba(120,120,120,0.12)",borderLeft:"3px solid #888",color:"inherit"},children:"\u{1F512} This item is locked and can\u2019t be changed."}),d("div",{style:fe?{opacity:.5,pointerEvents:"none"}:void 0,children:n.map(t=>{const s=t.optionSetId,a=U[s]||U[String(s)]||{id:s,name:""},l=a.type,h={id:s,feature_id:s,name:a.name,options:a.options},_=new Set((t.available||[]).map(String)),P=O(h);if(!P.length)return null;const ne=l==="load_new_product"||l==="product_change",y=/finish/i.test(String(l||"")),b=!ne&&P.length>0&&(y?P.some(p=>!!x?.[p.value]):P.every(p=>!!x?.[p.value])),c=o[s]??o[String(s)]??t.default??null;let v=null;if(l==="load_new_product"||l==="product_change"){const p=De(e),k=Qe(P,p,w().products);k&&(v=k.id)}let I=null;if(b){const p=et?.[e]||{},k=new Set((a.material_targets??a.materialTargets??a.materials??[]).map(m=>String(m).toLowerCase())),V=new Set(Object.entries(p).filter(([m])=>k.size===0||k.has(String(m).toLowerCase())).map(([,m])=>String(m)));if(V.size>0){const m=P.find(K=>K.value!=null&&V.has(String(K.value)));m&&(I=m.id)}}const W=v??I??c,D=p=>{if(l&&/finish/i.test(String(l))){we({option:p,feature:a,scope:"single",pieceIndex:e});return}const k=String(e).endsWith("__host");if(l==="load_new_product"||k&&l==="product_change"){const m=p.value??p.valueText??p.value_text??p.valueProductVariantId??p.value_product_variant_id,K=w().products,ce=m!=null?K[m]||K[String(m)]:null;if(k){const $e=ce?.id??m;if($e==null)return;import("./a77b15c0d6.js").then(({changeHostVariantForProduct:_t})=>_t({placementId:String(e).replace(/__host$/,""),variantId:$e})).catch(()=>{});return}}const V=String(e).endsWith("__host")?String(e).replace(/__host$/,""):e;import("./a77b15c0d6.js").then(({selectOptionForProduct:m})=>m({placementId:V,optionSetId:s,optionId:p.id})).catch(()=>{})};return d(N,{labelKey:s,title:String(a.name||"").toUpperCase(),presentation:a.presentation,flow:a.flow,gridClassName:`thumbnail-grid ${b?"thumbnail-grid--finish":"thumbnail-grid--options"}`,children:q(s,P).map(p=>{const k=Y(s,p),V=_.size>0&&!_.has(String(p.id)),m=k.disabled||V,K=k.disabledReason||(V?"Not available":null),ce=m?{...p,disabled:!0,disabledReason:K}:p;return b?d(Se,{option:ce,material:x[p.value],isSelected:String(W)===String(p.id),onClick:()=>{m||D(p)}},p.id):d(se,{option:ce,isSelected:String(W)===String(p.id),onClick:()=>{m||D(p)}},p.id)})},s)})})]})},$=be!=null,ae=$&&[...Ke(f)||[]].length>0,Ce=()=>ae?St()??te():te();return R?C("div",{className:"sidebar sidebar--embedded",style:oe?{opacity:.5,pointerEvents:"none"}:void 0,children:[$&&ae&&ee&&d("div",{className:"sidebar__mobile-header",children:C("button",{className:"sidebar__back-btn",onClick:Ie,children:[d(ke,{}),d("span",{children:"Selected"})]})}),d("div",{className:"sidebar__content",children:$?Ce():te()}),d(_e,{dialog:j,onClose:()=>B(null)})]}):ot?st?C(Q,{children:[$&&ae&&ee&&d("div",{className:"sidebar__mobile-header",children:C("button",{className:"sidebar__back-btn",onClick:Ie,children:[d(ke,{}),d("span",{children:"Selected"})]})}),d("div",{className:"sidebar__content sidebar__content--mobile",children:$?Ce():te()}),d(_e,{dialog:j,onClose:()=>B(null)})]}):C(Q,{children:[C("div",{"data-sdk-overlay":!0,className:"sidebar-container",style:oe?{opacity:.5,pointerEvents:"none"}:void 0,children:[C("aside",{className:"sidebar sidebar--card",children:[d("div",{className:"sidebar__header",children:$&&ae?C("button",{className:"sidebar__back-btn",onClick:Ie,children:[d(ke,{}),d("span",{children:"Selected"})]}):C(Q,{children:[C("div",{className:"sidebar__logo",children:[ie?C(Q,{children:[d(Ct,{className:"sidebar__logo-icon"}),d("span",{className:"sidebar__logo-divider"})]}):null,d("span",{className:"sidebar__logo-text",children:ut||"Configurator"})]}),d("div",{className:"sidebar__header-actions"})]})}),d("div",{className:"sidebar__content",children:$?Ce():te()})]}),Ae&&d("div",{className:"sidebar-chat-card",children:d(Ne,{})})]}),d(_e,{dialog:j,onClose:()=>B(null)})]}):Ae?d("div",{"data-sdk-overlay":!0,className:"sidebar-container sidebar-container--chat-only",children:d("div",{className:"sidebar-chat-card",children:d(Ne,{})})}):null}var qi=dn;export{qi as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=t=>t?.hostVariantId??t?.host_variant_id??null;function e(t){const n=t?.hostVariants??t?.host_variants;return Array.isArray(n)?n:[]}function l(t,n){const i=e(t);if(!i.length)return null;const o=n?.hostVariantId??n?.host_variant_id??null;if(o!=null){const r=i.find(a=>String(s(a))===String(o));if(r)return r}return i.find(r=>r?.isDefault??r?.is_default)??i[0]??null}function u(t,n){return s(l(t,n))}export{e as hostVariantsOf,l as resolveHostEntry,u as resolveHostVariantId};
|
package/dist/c9a1656c62.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as _,jsxs as st}from"react/jsx-runtime";import{useRef as H,useMemo as S,useEffect as D,useState as $,Suspense as q}from"react";import{useGLTF as J,Edges as Q}from"@react-three/drei";import*as u from"three";import Y from"./9c6c598569.js";import F from"./872c4302e0.js";import Z from"./609e5e5d28.js";import{useComponentOverride as K,_trackMount as tt}from"./a3c983d431.js";import{getFlatMaterial as V}from"./c44d37da7a.js";import rt from"./983cbed22c.js";import{resolveMaterial as et}from"./95a44ebec2.js";const nt={"bottom-center":{x:"c",y:"min",z:"c"},"front-bottom-center":{x:"c",y:"min",z:"max"},"back-bottom-center":{x:"c",y:"min",z:"min"},"left-bottom-center":{x:"min",y:"min",z:"c"},"right-bottom-center":{x:"max",y:"min",z:"c"},"front-left-bottom-center":{x:"min",y:"min",z:"max"},"front-right-bottom-center":{x:"max",y:"min",z:"max"},"back-left-bottom-center":{x:"min",y:"min",z:"min"},"back-right-bottom-center":{x:"max",y:"min",z:"min"}};function X(r){r.updateMatrixWorld(!0);const n=new u.Matrix4().copy(r.matrixWorld).invert(),a=new u.Box3,w=new u.Box3,v=new u.Matrix4;return r.traverse(c=>{if(!c.isMesh||!c.geometry)return;const y=`${c.name||""} ${c.material?.name||""}`.toLowerCase();/shadow|contact[\s_-]?shadow|ao[\s_-]?(plane|map)|ground[\s_-]?plane/.test(y)||(c.geometry.boundingBox||c.geometry.computeBoundingBox(),w.copy(c.geometry.boundingBox),v.multiplyMatrices(n,c.matrixWorld),w.applyMatrix4(v),a.union(w))}),a}function ot({url:r,material:n,position:a,rotation:w,scale:v,skirt:c,onClick:y,isSelected:A,onMeasure:d,recalcPosition:T,slotName:f,slotKey:C,componentId:z,pivot:P,children:L}){const W=H(),{scene:h}=J(r,"/assets/draco/"),[E,B]=$(0),G=H(null);D(()=>{if(!T||!W.current){G.current=null,B(0);return}const e=W.current;e.updateWorldMatrix(!0,!0);const i=new u.Matrix4().copy(e.matrixWorld).invert(),s=e.parent?new u.Matrix4().copy(e.parent.matrixWorld).invert():new u.Matrix4,o=new u.Matrix4().multiplyMatrices(s,e.matrixWorld),m=new u.Box3,R=new u.Box3,t=new u.Matrix4;if(e.traverse(p=>{!p.isMesh||!p.geometry||(p.geometry.boundingBox||p.geometry.computeBoundingBox(),t.multiplyMatrices(o,new u.Matrix4().multiplyMatrices(i,p.matrixWorld)),R.copy(p.geometry.boundingBox).applyMatrix4(t),m.union(R))}),m.isEmpty())return;const l=(m.max.x-m.min.x)/2,b=(Array.isArray(a)&&a[0]||0)<0?-1:1;let g=G.current;if(G.current=l,g==null&&(g=.1),g==null){B(0);return}if(Math.abs(l-g)<1e-4)return;const j=b*(l-g);B(p=>p+j)},[h,T,a]);const I=S(()=>{const e=h.clone(!0),i=f!=null&&String(f)!==""?String(f):null;i&&(e.name=i),e.userData={...e.userData,slotKey:C,componentId:z,slotName:i};let s=null;if(c){const o=new u.Box3().setFromObject(e);s=o.min.y+(o.max.y-o.min.y)*.12}return e.traverse(o=>{if(o.userData={...o.userData,slotKey:C,componentId:z,slotName:i},o.isMesh&&(o.castShadow=!0,o.receiveShadow=!0,n)){const m=n.clone();s!=null&&o.geometry?.attributes?.position&&m.color&&new u.Box3().setFromBufferAttribute(o.geometry.attributes.position).max.y<s&&m.color.multiplyScalar(.65),A&&(m.emissive=new u.Color("#ff6b35"),m.emissiveIntensity=1),o.material=m}}),e},[h,n,A,c,f,C,z]);D(()=>()=>{I.traverse(e=>{e.isMesh&&e.material&&e.material.dispose()})},[I]);const O=S(()=>{const e=nt[P||"model-derived"];if(!e)return null;const i=X(I);if(i.isEmpty())return null;const{min:s,max:o}=i,m=(s.x+o.x)/2,R=(s.y+o.y)/2,t=(s.z+o.z)/2,l=e.x==="min"?s.x:e.x==="max"?o.x:m,x=e.y==="min"?s.y:R,b=e.z==="min"?s.z:e.z==="max"?o.z:t;return[-l,-x,-b]},[I,P]);D(()=>{if(!d||!h)return;const e=X(h);if(e.isEmpty())return;const i=e.getSize(new u.Vector3),s=e.getCenter(new u.Vector3),o=O||[0,0,0];(i.x>0||i.y>0||i.z>0)&&d({width:i.x,height:i.y,depth:i.z,cx:s.x+o[0],cy:s.y+o[1],cz:s.z+o[2]})},[h,d,O]);const k=H(d);k.current=d,D(()=>()=>{try{k.current?.(null)}catch{}},[]);const M=T&&E&&Array.isArray(a)?[(a[0]||0)+E,a[1]||0,a[2]||0]:a;return st("group",{ref:W,name:f!=null?String(f):void 0,userData:{slotKey:C,componentId:z,slotName:f!=null?String(f):void 0},position:M,rotation:w,scale:v,onClick:y,children:[O?_("group",{position:O,children:_("primitive",{object:I})}):_("primitive",{object:I}),L]})}function dt({geometry:r,material:n,position:a,onClick:w,isSelected:v}){const c=H(),y=S(()=>{if(v){const A=n.clone();return A.emissive=new u.Color("#ff6b35"),A.emissiveIntensity=1,A}return n},[n,v]);return D(()=>()=>{y!==n&&y.dispose()},[y,n]),_("mesh",{ref:c,geometry:r,material:y,position:a,onClick:w,castShadow:!0,receiveShadow:!0,children:v&&_(Q,{scale:1.01,threshold:15,color:"#ff6b35",linewidth:3})})}const U={visible:!0,materialId:null};function N({component:r,componentState:n,instanceId:a,isSelected:w,onMeasure:v,onPick:c,slotName:y,slotKey:A,componentId:d,pivot:T,hiddenComponentIds:f,onDescendantMeasured:C,slotMaterials:z}){const P=Y(t=>t.selectInstance),L=F(t=>t.getMaterial),W=F(t=>t.getComponent),h=K(y,r?.name??r?.componentName,d);h?.materialId&&(n={...n,materialId:h.materialId}),D(()=>tt({name:r?.name??r?.componentName??null,slotName:y??null,componentId:d!=null?String(d):null,instanceId:a??null}),[r?.name,r?.componentName,y,d,a]);const{physicalMat:E}=Z(n.materialId,{getMaterial:L}),B=S(()=>{const t=n.variantId&&r.style_variants?r.style_variants[n.variantId]:null,l=r.variants,x=l&&typeof l=="object"?l.default||Object.values(l)[0]:null;return t||r.url||r.asset_url||r.modelPath||r.model_path||r.modelUrl||r.model_url||x||null},[r,n.variantId]),G=S(()=>{if(!B||typeof B!="string")return!1;const t=B.split(/[?#]/)[0].toLowerCase();return t.endsWith(".glb")||t.endsWith(".gltf")},[B]),I=S(()=>{if(E)return E;if(n.materialId){const t=L(n.materialId),l=et({...n,materialId:n.materialId,definition:t},{THREE:u,Default:()=>t&&t.color?V({color:t.color||"#808080",roughness:t.roughness||.5,metalness:t.metalness||0}):null});if(l)return l;if(t&&t.color)return V({color:t.color||"#808080",roughness:t.roughness||.5,metalness:t.metalness||0})}return n.color?V({color:n.color,roughness:n.roughness??.5,metalness:n.metalness??0}):null},[n.materialId,n.color,n.roughness,n.metalness,L,E]),O=t=>{t.stopPropagation();const l=d??r?.id??null;if(c){c(l);return}P(a,l)},k=r.position||[0,0,0],M=r.rotation||r.orientation||[0,0,0],e=Math.PI/180,i=Array.isArray(M)&&M.length===3?r.rotationRad?[M[0],M[1],M[2]]:[M[0]*e,M[1]*e,M[2]*e]:[0,0,0];let s=r.scale||[1,1,1],o=k,m=i;if(h?.transform){const t=h.transform;t.position&&(o=[k[0]+t.position[0],k[1]+t.position[1],k[2]+t.position[2]]),t.rotation&&(m=[i[0]+t.rotation[0]*e,i[1]+t.rotation[1]*e,i[2]+t.rotation[2]*e]),t.scale&&(s=[s[0]*t.scale[0],s[1]*t.scale[1],s[2]*t.scale[2]])}const R=S(()=>{const t=Array.isArray(r.children)?r.children:[];if(!t.length)return null;const l=Array.isArray(f)&&f.length?new Set(f.map(x=>String(x))):null;return t.map(x=>{const b=x.componentId??x.component_id;if(l&&b!=null&&l.has(String(b)))return null;const g=b!=null?W(b):null;if(!g)return null;const j=String(g.materialSlot??g.material_slot??"").toLowerCase(),p=z&&j?z[j]:null;return _(N,{component:{...g,position:x.position,rotation:x.rotation,scale:x.scale},componentState:p?{...U,materialId:p}:U,instanceId:a,componentId:b,slotKey:g.materialSlot??g.name??String(b),slotName:g.name??null,onPick:c,hiddenComponentIds:f,slotMaterials:z,onMeasure:C,onDescendantMeasured:C},x.id??b)})},[r.children,W,a,c,f,C,z]);return h?.hidden?null:G?_(rt,{children:_(q,{children:_(ot,{url:B,material:I,position:o,rotation:m,scale:s,skirt:r.skirt,onClick:O,isSelected:w,onMeasure:v,recalcPosition:r.recalcPosition,slotName:y,slotKey:A,componentId:d,pivot:T,children:R})})}):null}var ht=N;export{ht as default};
|
package/dist/ce663020e4.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{useMemo as
|
|
1
|
+
import{useMemo as B,useSyncExternalStore as ee}from"react";import{useCopilotAction as D,useCopilotReadable as U,useCopilotAdditionalInstructions as te}from"@copilotkit/react-core";import ne from"./d94df858ea.js";import N from"./8f60e5059a.js";import v from"./9c6c598569.js";import $ from"./872c4302e0.js";import G from"./be337ddda5.js";import{isAddFeature as ie}from"./8c27edda0f.js";import{getPlacementBindings as Y,getEffectiveSelections as ae,subscribe as oe,getVersion as _}from"./817d930a49.js";import{selectOption as se}from"./dbd5ba1d07.js";import{getLastEvaluation as H}from"./9f474b5d1a.js";import{resolveHostVariantId as re}from"./be07a7f885.js";const K="Adding pieces is not available for the current product.";function q(g=2){return new Promise(A=>{let f=g;const h=()=>{f-=1,f<=0?A():requestAnimationFrame(h)};requestAnimationFrame(h)})}async function ce({instanceId:g,featureKey:A,optionKey:f}){if(g==null)return{ok:!1,msg:"No piece is selected. Select a piece first (selectPiece)."};const h=await import("./a77b15c0d6.js"),C=$.getState().features||{},P=$.getState().options||{},M=$.getState().products||{};try{v.getState().selectInstance?.(g)}catch{}try{await h.reevaluateForFocus()}catch{}await q(2);let j=h.getPlacementBindings(g)||[];if(j.length||(await q(2),j=h.getPlacementBindings(g)||[]),!j.length)return{ok:!1,msg:"This piece has no editable options yet \u2014 try selecting it again."};const E=s=>String((C[s]||C[String(s)]||{}).name||""),V=s=>String((C[s]||C[String(s)]||{}).type||""),F=String(A).toLowerCase(),b=j.find(s=>{const T=E(s.optionSetId).toLowerCase();return String(s.optionSetId)===String(A)||T===F||T&&(T.includes(F)||F.includes(T))});if(!b){const s=j.map(T=>E(T.optionSetId)).filter(Boolean).join(", ");return{ok:!1,msg:`"${A}" isn't an option on the selected piece. Available: ${s||"(none)"}.`}}const S=(b.available||[]).map(s=>P[s]||P[String(s)]).filter(Boolean),L=String(f).toLowerCase(),y=S.find(s=>String(s.id)===String(f)||String(s.name).toLowerCase()===L||String(s.name).toLowerCase().includes(L)||L.includes(String(s.name).toLowerCase()));if(!y)return{ok:!1,msg:`"${f}" not available for ${E(b.optionSetId)||"that feature"}. Available: ${S.map(s=>s.name).join(", ")||"(none)"}.`};const x=E(b.optionSetId)||"Feature",O=/finish/i.test(V(b.optionSetId))||/finish|colou?r|material/i.test(x);try{if(O){const{applyFinishClick:s}=await import("./dc2a1a0e13.js"),T=C[b.optionSetId]||C[String(b.optionSetId)]||{},R=s({option:y,feature:{...T,id:b.optionSetId,name:T.name||x},scope:"single",pieceIndex:g});if(!R||R.ok===!1)return{ok:!1,msg:`Couldn't apply ${y.name} \u2014 ${x} has no matching material slot on this piece.`}}else{const s=y.value;s!=null&&!!(M[s]||M[String(s)])?await h.changeProductVariant({placementId:g,variantId:s}):await h.selectOptionForProduct({placementId:g,optionSetId:b.optionSetId,optionId:y.id})}}catch(s){return{ok:!1,msg:`Couldn't change ${x}: ${s?.message||"engine error"}.`}}return{ok:!0,msg:`${x} changed to ${y.name} for the selected piece.`}}async function le(g,A){const f=A!=null?String(A).match(/\d+(?:\.\d+)?/g):null;if(!f||!f.length||g==null)return{ok:!1,reason:"no-size"};const h=await import("./a77b15c0d6.js"),C=$.getState().features||{},P=$.getState().options||{},M=$.getState().products||{};try{v.getState().selectInstance?.(g)}catch{}try{await h.reevaluateForFocus()}catch{}await q(2);const E=(h.getPlacementBindings(g)||[]).find(S=>{const L=C[S.optionSetId]||C[String(S.optionSetId)];return/width|frame|size/i.test(String(L?.name||""))});if(!E)return{ok:!1,reason:"no-binding"};const V=(E.available||[]).map(S=>P[S]||P[String(S)]).filter(Boolean),F=V.find(S=>f.every(L=>String(S.name).includes(L)))||V.find(S=>String(S.name).includes(f[f.length-1]));if(!F)return{ok:!1,reason:"no-match",available:V.map(S=>S.name)};try{const S=F.value;S!=null&&!!(M[S]||M[String(S)])?await h.changeProductVariant({placementId:g,variantId:S}):await h.selectOptionForProduct({placementId:g,optionSetId:E.optionSetId,optionId:F.id})}catch{return{ok:!1,reason:"apply-failed"}}return{ok:!0,featureName:(C[E.optionSetId]||C[String(E.optionSetId)])?.name||"size",matchedName:F.name}}function de(){try{te({instructions:`
|
|
2
2
|
You help the user customize the 3D product in the scene. Act immediately \u2014 never ask
|
|
3
3
|
follow-up questions; infer the best option from the catalogs and execute.
|
|
4
4
|
|
|
@@ -57,4 +57,4 @@ Match names/options against the catalogs; always pick the closest rather than re
|
|
|
57
57
|
NEVER refuse a change by claiming it's "already set" to that value. When the user asks
|
|
58
58
|
to set a feature to a value, ALWAYS call the tool to apply it \u2014 applying an already-set
|
|
59
59
|
value is harmless. The current values in sceneInventory.selectedFeatures may be
|
|
60
|
-
approximate (per-piece finishes especially), so do not skip the action based on them.`})}catch{}const g=ne(e=>e.sceneSelections),A=v(e=>e.activeSceneConfigId),f=$(e=>e.features),h=$(e=>e.options),C=v(e=>e.productInstances),P=v(e=>e.selectedInstanceId),W=G(e=>e.sceneConfigurations),V=G(e=>e.getSceneFeatures),E=q(e=>e.hostMaterialOverrides),x=ee(oe,K,K),F=$(e=>e.systemUiToggles)||{},b=F.walls!==!1,S=F.dimensions!==!1,L=A?V(A)||[]:[],y=_(()=>L.map(e=>{const t=e.feature_id||e.id,l=f[t]||f[String(t)];let i=(l?.options||[]).map(n=>{const o=typeof n=="string"||typeof n=="number"?n:n?.id,u=h[o]||h[String(o)];return u?{id:u.id,name:u.name}:null}).filter(Boolean);i.length===0&&(i=Object.values(h).filter(n=>n?.optionSetId==t||n?.option_set_id==t||n?.optionSet==t||n?.feature_id==t).sort((n,o)=>(n?.sequence||0)-(o?.sequence||0)).map(n=>({id:n.id,name:n.name})));const d=g[e.id]??g[String(e.id)]??g[t]??g[String(t)]??null,m=d!=null?i.find(n=>String(n.id)===String(d))?.name??null:null;return{sceneFeatureId:e.id,featureId:t,name:e.name||l?.name||t,current:m,currentSelection:d,options:i}}),[L,f,h,g]);U({description:"Scene-wide features and their options for the current product (from the live catalog \u2014 any configurator). Use featureKey when calling selectOption.",value:y});const R=_(()=>{const e=C||{},t=$.getState().products||{},l=n=>{const o=t[n?.variantId]||t[n?.productId]||t[String(n?.variantId)]||t[String(n?.productId)];return String(o?.name||n?.name||"")},i=Object.entries(e).map(([n,o])=>{const u=(Y(n)||[]).map(r=>(f[r.optionSetId]||f[String(r.optionSetId)]||{}).name).filter(Boolean);return{id:n,name:l(o),selected:String(n)===String(P),features:u}});let d=null;if(P!=null){const n=Y(P)||[],o=ae(P)||{},u=E?.[P]||{};d=n.map(r=>{const a=f[r.optionSetId]||f[String(r.optionSetId)],I=a?.name||String(r.optionSetId),c=(r.available||[]).map(w=>h[w]||h[String(w)]).filter(Boolean),k=/finish/i.test(String(a?.type||""))||/finish|colou?r|material/i.test(I);let p=null;if(k){const w=new Set(Object.values(u).map(String));if(p=c.find(O=>O.value!=null&&w.has(String(O.value)))?.name??null,p==null){const O=y.find(B=>String(B.featureId)===String(r.optionSetId)),z=O?g[O.sceneFeatureId]:null;p=z!=null?(h[z]||h[String(z)])?.name??null:null}}else{const w=o[r.optionSetId]??o[String(r.optionSetId)];p=w!=null?(h[w]||h[String(w)])?.name??null:null}return{feature:I,current:p,options:c.map(w=>w.name)}})}const m=i.find(n=>n.selected)?.name||null;return{pieces:i,selectedPiece:m,selectedFeatures:d,note:P==null?'NOTHING is selected. For a "change/delete the selected piece" request, first call selectPiece(description) to select the piece the user means, or reply that no piece is currently selected. Do NOT claim any current value or that something is "already set".':`"${m}" is selected; its changeable features are in selectedFeatures.`}},[C,P,f,h,g,y,E,x]);U({description:"Pieces in the scene (each with its feature names), which is selected, and the selected piece's current values + options. To change a feature of a piece that isn't selected (e.g. a hosted product's option), find the piece in pieces[] whose features include it and selectPiece it \u2014 or just call updatePieceFeature(featureKey, optionKey); it auto-targets the piece that has that feature when only one does.",value:R});const N=_(()=>{const e=new Set((L||[]).filter(t=>ie(t,{productSelected:!1})).map(t=>String(t.feature_id||t.id)));return y.filter(t=>e.has(String(t.featureId))).filter(t=>Array.isArray(t.options)&&t.options.length>0)},[L,y]),s=N.length>0,T=N.map(e=>`${e.name}: ${e.options.map(t=>t.name).join(", ")}`).join("; "),M=N.map(e=>e.name);U({description:"Kinds of pieces that can be ADDED for this product, with their options. Use these exact names as pieceType when calling addPiece.",value:N.map(e=>({pieceType:e.name,options:e.options.map(t=>t.name)}))});const Q=y.map(e=>`${e.name} (e.g. ${e.options.slice(0,3).map(t=>t.name).join(", ")})`).join(", "),J=y.slice(0,4).map(e=>`"${e.name}"`).join(", "),Z=y.flatMap(e=>e.options.slice(0,1)).slice(0,4).map(e=>`"${e.name}"`).join(", ");D({name:"selectOption",description:`Change a scene-wide feature option (finish, layout, door style, handle, \u2026). Features: ${Q}.`,parameters:[{name:"featureKey",type:"string",description:`The feature name or id. Examples: ${J}.`,required:!0},{name:"optionKey",type:"string",description:`The option name or id. Examples: ${Z}.`,required:!0}],handler:async({featureKey:e,optionKey:t})=>{const l=String(e).toLowerCase(),i=y.find(a=>String(a.sceneFeatureId)===String(e)||String(a.featureId)===String(e)||String(a.sceneFeatureId).toLowerCase()===l||String(a.featureId).toLowerCase()===l||String(a.name).toLowerCase()===l||String(a.name).toLowerCase().includes(l)||l.includes(String(a.name).toLowerCase()));if(!i)return`Feature "${e}" not found. Available: ${y.map(a=>a.name).join(", ")}`;const d=String(t).toLowerCase(),m=i.options.find(a=>String(a.id)===String(t)||String(a.id).toLowerCase()===d||String(a.name).toLowerCase()===d||String(a.name).toLowerCase().includes(d)||d.includes(String(a.name).toLowerCase()));if(!m)return`Option "${t}" not found for ${i.name}. Available: ${i.options.map(a=>a.name).join(", ")}`;const n=f[i.featureId]||f[String(i.featureId)]||{id:i.featureId},o=H();let u=!1;try{u=await se(i.featureId,m.id,n),await j(2)}catch(a){return`Could not change ${i.name}: ${a?.message||a}`}const r=H();if(r&&r!==o&&r.rejected){const a=r.errors?.[0]?.message||r.code||"the engine refused it";return`${i.name} could not be changed to ${m.name}: ${a}`}return u===!1?`${i.name} could not be changed to ${m.name}.`:`${i.name} changed to ${m.name}.`}}),D({name:"addPiece",available:s?"enabled":"disabled",description:s?`Add a new piece to the scene. Choose a pieceType and an option (free pieces / corners / hosted products are pieceTypes here too). Available \u2014 ${T}.`:X,parameters:[{name:"pieceType",type:"string",required:!1,description:`Which kind of piece. Valid: ${M.join(", ")||"(none)"}. Optional when there's only one.`,...M.length?{enum:M}:{}},{name:"option",type:"string",required:!0,description:"The option to add \u2014 name or id."},{name:"size",type:"string",required:!1,description:'Optional size/width, e.g. "18" or "30x18". Applied after adding if the piece has a size option.'}],handler:async({pieceType:e,option:t,size:l})=>{if(!s)return X;let i=null;if(e!=null&&String(e).trim()!==""){const c=String(e).trim().toLowerCase();i=N.find(k=>String(k.name).toLowerCase()===c||String(k.featureId).toLowerCase()===c||String(k.name).toLowerCase().includes(c)||c.includes(String(k.name).toLowerCase()))}if(!i&&N.length===1&&(i=N[0]),!i)return`Which piece type? Choose one of: ${M.join(", ")}.`;const d=String(t).trim().toLowerCase(),m=i.options.find(c=>String(c.id)===String(t)||String(c.name).toLowerCase()===d||String(c.name).toLowerCase().includes(d)||d.includes(String(c.name).toLowerCase()));if(!m)return`Option "${t}" not found for ${i.name}. Available: ${i.options.map(c=>c.name).join(", ")}.`;let n,o;const u=new Set(Object.keys(v.getState().productInstances||{}));try{n=await import("./a77b15c0d6.js"),o=await n.addProductFromOption({optionSetId:i.featureId,optionId:m.id})}catch(c){return`Couldn't add ${m.name}: ${c?.message||"the engine is unavailable"}.`}await j(2);let r=o?.addedPlacements?.[0]?.id??null;r==null&&(r=Object.keys(v.getState().productInstances||{}).find(c=>!u.has(c))??null);const a=`Added ${m.name} (${i.name}) to the scene.`;if(l==null||String(l).trim()===""||r==null)return a;const I=await ce(r,l);return I.ok?`Added ${m.name} (${i.name}) and set ${I.featureName} to ${I.matchedName}.`:I.reason==="no-match"?`${a} Couldn't match size "${l}" \u2014 available: ${(I.available||[]).join(", ")||"(none)"}.`:a}}),D({name:"selectPiece",description:'Select a piece in the scene so it can be changed or deleted. Match by product name / description (e.g. "left chaise", "the elevated piece", "the hosted product").',parameters:[{name:"description",type:"string",required:!0,description:"The piece's product name or a description of it."}],handler:async({description:e})=>{const t=v.getState().productInstances||{},l=$.getState().products||{},i=Object.entries(t).map(([o,u])=>{const r=l[u?.variantId]||l[u?.productId]||l[String(u?.variantId)]||l[String(u?.productId)];return{id:o,name:String(r?.name||u?.name||o)}});if(!i.length)return"There are no pieces in the scene to select.";const d=String(e).toLowerCase().trim(),m=d.split(/\s+/).filter(o=>o.length>2),n=i.find(o=>o.name.toLowerCase()===d)||i.find(o=>o.name.toLowerCase().includes(d))||i.find(o=>d.includes(o.name.toLowerCase()))||i.find(o=>m.some(u=>o.name.toLowerCase().includes(u)));if(!n)return`Couldn't find a piece matching "${e}". In the scene: ${i.map(o=>o.name).join(", ")}.`;try{v.getState().selectInstance?.(n.id)}catch{}return await j(2),`Selected ${n.name}. You can now change or delete it.`}}),D({name:"updatePieceFeature",description:"Change a feature (width, door, handle, finish, size, \u2026) on the CURRENTLY SELECTED piece. Select one first with selectPiece. See sceneInventory for the selected piece's features and options.",parameters:[{name:"featureKey",type:"string",required:!0,description:"The feature name (or id) to change \u2014 from the selected piece's features."},{name:"optionKey",type:"string",required:!0,description:"The option name (or id) to select."}],handler:async({featureKey:e,optionKey:t})=>{let l=v.getState().selectedInstanceId;if(l==null){const d=await import("./a77b15c0d6.js"),m=v.getState().productInstances||{},n=$.getState().products||{},o=$.getState().features||{},u=String(e).toLowerCase(),r=Object.keys(m).filter(a=>(d.getPlacementBindings(a)||[]).some(I=>{const c=String((o[I.optionSetId]||o[String(I.optionSetId)]||{}).name||"").toLowerCase();return c&&(c===u||c.includes(u)||u.includes(c))}));if(r.length===1)l=r[0];else if(r.length>1){const a=r.map(I=>{const c=m[I];return(n[c?.variantId]||n[c?.productId])?.name||I});return`Several pieces have a "${e}" option (${a.join(", ")}). Say which one (e.g. by its name), then I'll change it.`}}const i=await re({instanceId:l,featureKey:e,optionKey:t});return await j(2),i.msg}}),D({name:"deleteSelectedPiece",description:"Delete the currently selected piece from the scene. Select one first with selectPiece if needed.",parameters:[],handler:async()=>{const e=v.getState().selectedInstanceId;if(e==null)return"No piece is selected. Select one first (selectPiece).";try{await(await import("./a77b15c0d6.js")).removeProduct(e)}catch(t){return`Couldn't delete the selected piece: ${t?.message||"the engine is unavailable"}.`}try{v.getState().removeProductInstance?.(e)}catch{}try{v.getState().selectInstance?.(null)}catch{}return await j(2),"Deleted the selected piece."}}),D({name:"movePiece",description:"Move/reorder the CURRENTLY SELECTED piece one position left or right within its run. Select a piece first with selectPiece if needed. (Pieces snap into a sequenced run, so this reorders rather than free-positions.)",parameters:[{name:"direction",type:"string",required:!0,enum:["left","right"],description:'"left" or "right".'}],handler:async({direction:e})=>{const t=v.getState(),l=t.selectedInstanceId;if(l==null)return"No piece is selected. Select one first (selectPiece), then say which way to move it.";const i=t.productInstances||{},d=i[l];if(!d)return"The selected piece is no longer in the scene.";const m=p=>p?.placementGroup??p?.placement_group??null,n=p=>{const w=Number(p?.sequence);return Number.isFinite(w)?w:null},o=m(d),u=Object.entries(i).filter(([,p])=>m(p)===o&&n(p)!=null).map(([p,w])=>({id:p,seq:n(w)})).sort((p,w)=>p.seq-w.seq),r=u.findIndex(p=>String(p.id)===String(l));if(r<0||u.length<2)return"There is nothing to reorder \u2014 the selected piece has no neighbours in its run.";const a=/right|next|forward|end/i.test(String(e)),I=a?u[r+1]:u[r-1];if(!I)return a?"The piece is already at the right end of its run.":"The piece is already at the left end of its run.";let c=d?.positionedAbove!=null?String(d.positionedAbove):null,k=null;if(c){const p=i[c];k=p?p.variantId??p.productId??null:null}else{const p=$.getState(),w=p.getProduct?.(d?.variantId)||p.getProduct?.(d?.productId),O=w?.hostVariants??w?.host_variants;if(Array.isArray(O)&&O.length){const z=O.find(B=>B?.isDefault??B?.is_default)||O[0];k=z?.hostVariantId??z?.host_variant_id??null}}try{await(await import("./a77b15c0d6.js")).moveProduct({placementId:l,sequence:Math.round(I.seq),hostPlacementId:c,hostVariantId:k})}catch(p){return`Couldn't move the piece: ${p?.message||"the engine is unavailable"}.`}return await j(2),`Moved the selected piece one position to the ${a?"right":"left"}.`}}),D({name:"toggleFullscreen",description:"Toggle fullscreen for the 3D scene.",parameters:[{name:"enabled",type:"boolean",required:!0,description:"true = enter, false = exit."}],handler:async({enabled:e})=>{const t=document.querySelector(".scene-canvas");return t?e&&!document.fullscreenElement?(await t.requestFullscreen?.(),"Entered fullscreen."):!e&&document.fullscreenElement?(await document.exitFullscreen?.(),"Exited fullscreen."):e?"Already in fullscreen.":"Not in fullscreen.":"Could not find the scene element."}}),D({name:"switchView",description:"Switch between 2D top-down and 3D perspective view.",parameters:[{name:"view",type:"string",required:!0,enum:["2D","3D"],description:'"2D" or "3D".'}],handler:async({view:e})=>{const t=e==="3D";return q.getState().is3D===t?`Already in ${e} view.`:(v.getState().setCameraPosition(t?[4,4,6]:[0,10,.1]),q.getState().toggleView(),`Switched to ${e} view.`)}}),D({name:"resetCamera",description:"Reset the camera to the default 3D view.",parameters:[],handler:async()=>(v.getState().setCameraPosition([4,4,6]),q.getState().is3D||q.getState().toggleView(),"Camera reset.")}),D({name:"toggleDimensions",available:S?"enabled":"disabled",description:S?"Show or hide the dimension overlay.":"This product has no dimension overlay to show or hide.",parameters:[{name:"show",type:"boolean",required:!0,description:"true = show, false = hide."}],handler:async({show:e})=>S?q.getState().showDimensions===e?e?"Dimensions already visible.":"Dimensions already hidden.":(q.getState().toggleDimensions(),e?"Dimensions shown.":"Dimensions hidden."):"This product has no dimension overlay."}),D({name:"toggleWalls",available:b?"enabled":"disabled",description:b?"Show or hide the room walls in the scene.":"This product has no room walls to show or hide.",parameters:[{name:"show",type:"boolean",required:!0,description:"true = show walls, false = hide walls."}],handler:async({show:e})=>b?q.getState().showWalls===e?e?"Walls already visible.":"Walls already hidden.":(q.getState().toggleWalls(),e?"Walls shown.":"Walls hidden."):"This product has no walls to toggle."})}export{le as default};
|
|
60
|
+
approximate (per-piece finishes especially), so do not skip the action based on them.`})}catch{}const g=ne(e=>e.sceneSelections),A=v(e=>e.activeSceneConfigId),f=$(e=>e.features),h=$(e=>e.options),C=v(e=>e.productInstances),P=v(e=>e.selectedInstanceId),M=G(e=>e.sceneConfigurations),j=G(e=>e.getSceneFeatures),E=N(e=>e.hostMaterialOverrides),V=ee(oe,_,_),F=$(e=>e.systemUiToggles)||{},b=F.walls!==!1,S=F.dimensions!==!1,L=A?j(A)||[]:[],y=B(()=>L.map(e=>{const t=e.feature_id||e.id,d=f[t]||f[String(t)];let i=(d?.options||[]).map(n=>{const o=typeof n=="string"||typeof n=="number"?n:n?.id,u=h[o]||h[String(o)];return u?{id:u.id,name:u.name}:null}).filter(Boolean);i.length===0&&(i=Object.values(h).filter(n=>n?.optionSetId==t||n?.option_set_id==t||n?.optionSet==t||n?.feature_id==t).sort((n,o)=>(n?.sequence||0)-(o?.sequence||0)).map(n=>({id:n.id,name:n.name})));const c=g[e.id]??g[String(e.id)]??g[t]??g[String(t)]??null,m=c!=null?i.find(n=>String(n.id)===String(c))?.name??null:null;return{sceneFeatureId:e.id,featureId:t,name:e.name||d?.name||t,current:m,currentSelection:c,options:i}}),[L,f,h,g]);U({description:"Scene-wide features and their options for the current product (from the live catalog \u2014 any configurator). Use featureKey when calling selectOption.",value:y});const x=B(()=>{const e=C||{},t=$.getState().products||{},d=n=>{const o=t[n?.variantId]||t[n?.productId]||t[String(n?.variantId)]||t[String(n?.productId)];return String(o?.name||n?.name||"")},i=Object.entries(e).map(([n,o])=>{const u=(Y(n)||[]).map(r=>(f[r.optionSetId]||f[String(r.optionSetId)]||{}).name).filter(Boolean);return{id:n,name:d(o),selected:String(n)===String(P),features:u}});let c=null;if(P!=null){const n=Y(P)||[],o=ae(P)||{},u=E?.[P]||{};c=n.map(r=>{const a=f[r.optionSetId]||f[String(r.optionSetId)],I=a?.name||String(r.optionSetId),l=(r.available||[]).map(w=>h[w]||h[String(w)]).filter(Boolean),k=/finish/i.test(String(a?.type||""))||/finish|colou?r|material/i.test(I);let p=null;if(k){const w=new Set(Object.values(u).map(String));if(p=l.find(W=>W.value!=null&&w.has(String(W.value)))?.name??null,p==null){const W=y.find(Z=>String(Z.featureId)===String(r.optionSetId)),z=W?g[W.sceneFeatureId]:null;p=z!=null?(h[z]||h[String(z)])?.name??null:null}}else{const w=o[r.optionSetId]??o[String(r.optionSetId)];p=w!=null?(h[w]||h[String(w)])?.name??null:null}return{feature:I,current:p,options:l.map(w=>w.name)}})}const m=i.find(n=>n.selected)?.name||null;return{pieces:i,selectedPiece:m,selectedFeatures:c,note:P==null?'NOTHING is selected. For a "change/delete the selected piece" request, first call selectPiece(description) to select the piece the user means, or reply that no piece is currently selected. Do NOT claim any current value or that something is "already set".':`"${m}" is selected; its changeable features are in selectedFeatures.`}},[C,P,f,h,g,y,E,V]);U({description:"Pieces in the scene (each with its feature names), which is selected, and the selected piece's current values + options. To change a feature of a piece that isn't selected (e.g. a hosted product's option), find the piece in pieces[] whose features include it and selectPiece it \u2014 or just call updatePieceFeature(featureKey, optionKey); it auto-targets the piece that has that feature when only one does.",value:x});const O=B(()=>{const e=new Set((L||[]).filter(t=>ie(t,{productSelected:!1})).map(t=>String(t.feature_id||t.id)));return y.filter(t=>e.has(String(t.featureId))).filter(t=>Array.isArray(t.options)&&t.options.length>0)},[L,y]),s=O.length>0,T=O.map(e=>`${e.name}: ${e.options.map(t=>t.name).join(", ")}`).join("; "),R=O.map(e=>e.name);U({description:"Kinds of pieces that can be ADDED for this product, with their options. Use these exact names as pieceType when calling addPiece.",value:O.map(e=>({pieceType:e.name,options:e.options.map(t=>t.name)}))});const X=y.map(e=>`${e.name} (e.g. ${e.options.slice(0,3).map(t=>t.name).join(", ")})`).join(", "),Q=y.slice(0,4).map(e=>`"${e.name}"`).join(", "),J=y.flatMap(e=>e.options.slice(0,1)).slice(0,4).map(e=>`"${e.name}"`).join(", ");D({name:"selectOption",description:`Change a scene-wide feature option (finish, layout, door style, handle, \u2026). Features: ${X}.`,parameters:[{name:"featureKey",type:"string",description:`The feature name or id. Examples: ${Q}.`,required:!0},{name:"optionKey",type:"string",description:`The option name or id. Examples: ${J}.`,required:!0}],handler:async({featureKey:e,optionKey:t})=>{const d=String(e).toLowerCase(),i=y.find(a=>String(a.sceneFeatureId)===String(e)||String(a.featureId)===String(e)||String(a.sceneFeatureId).toLowerCase()===d||String(a.featureId).toLowerCase()===d||String(a.name).toLowerCase()===d||String(a.name).toLowerCase().includes(d)||d.includes(String(a.name).toLowerCase()));if(!i)return`Feature "${e}" not found. Available: ${y.map(a=>a.name).join(", ")}`;const c=String(t).toLowerCase(),m=i.options.find(a=>String(a.id)===String(t)||String(a.id).toLowerCase()===c||String(a.name).toLowerCase()===c||String(a.name).toLowerCase().includes(c)||c.includes(String(a.name).toLowerCase()));if(!m)return`Option "${t}" not found for ${i.name}. Available: ${i.options.map(a=>a.name).join(", ")}`;const n=f[i.featureId]||f[String(i.featureId)]||{id:i.featureId},o=H();let u=!1;try{u=await se(i.featureId,m.id,n),await q(2)}catch(a){return`Could not change ${i.name}: ${a?.message||a}`}const r=H();if(r&&r!==o&&r.rejected){const a=r.errors?.[0]?.message||r.code||"the engine refused it";return`${i.name} could not be changed to ${m.name}: ${a}`}return u===!1?`${i.name} could not be changed to ${m.name}.`:`${i.name} changed to ${m.name}.`}}),D({name:"addPiece",available:s?"enabled":"disabled",description:s?`Add a new piece to the scene. Choose a pieceType and an option (free pieces / corners / hosted products are pieceTypes here too). Available \u2014 ${T}.`:K,parameters:[{name:"pieceType",type:"string",required:!1,description:`Which kind of piece. Valid: ${R.join(", ")||"(none)"}. Optional when there's only one.`,...R.length?{enum:R}:{}},{name:"option",type:"string",required:!0,description:"The option to add \u2014 name or id."},{name:"size",type:"string",required:!1,description:'Optional size/width, e.g. "18" or "30x18". Applied after adding if the piece has a size option.'}],handler:async({pieceType:e,option:t,size:d})=>{if(!s)return K;let i=null;if(e!=null&&String(e).trim()!==""){const l=String(e).trim().toLowerCase();i=O.find(k=>String(k.name).toLowerCase()===l||String(k.featureId).toLowerCase()===l||String(k.name).toLowerCase().includes(l)||l.includes(String(k.name).toLowerCase()))}if(!i&&O.length===1&&(i=O[0]),!i)return`Which piece type? Choose one of: ${R.join(", ")}.`;const c=String(t).trim().toLowerCase(),m=i.options.find(l=>String(l.id)===String(t)||String(l.name).toLowerCase()===c||String(l.name).toLowerCase().includes(c)||c.includes(String(l.name).toLowerCase()));if(!m)return`Option "${t}" not found for ${i.name}. Available: ${i.options.map(l=>l.name).join(", ")}.`;let n,o;const u=new Set(Object.keys(v.getState().productInstances||{}));try{n=await import("./a77b15c0d6.js"),o=await n.addProductFromOption({optionSetId:i.featureId,optionId:m.id})}catch(l){return`Couldn't add ${m.name}: ${l?.message||"the engine is unavailable"}.`}await q(2);let r=o?.addedPlacements?.[0]?.id??null;r==null&&(r=Object.keys(v.getState().productInstances||{}).find(l=>!u.has(l))??null);const a=`Added ${m.name} (${i.name}) to the scene.`;if(d==null||String(d).trim()===""||r==null)return a;const I=await le(r,d);return I.ok?`Added ${m.name} (${i.name}) and set ${I.featureName} to ${I.matchedName}.`:I.reason==="no-match"?`${a} Couldn't match size "${d}" \u2014 available: ${(I.available||[]).join(", ")||"(none)"}.`:a}}),D({name:"selectPiece",description:'Select a piece in the scene so it can be changed or deleted. Match by product name / description (e.g. "left chaise", "the elevated piece", "the hosted product").',parameters:[{name:"description",type:"string",required:!0,description:"The piece's product name or a description of it."}],handler:async({description:e})=>{const t=v.getState().productInstances||{},d=$.getState().products||{},i=Object.entries(t).map(([o,u])=>{const r=d[u?.variantId]||d[u?.productId]||d[String(u?.variantId)]||d[String(u?.productId)];return{id:o,name:String(r?.name||u?.name||o)}});if(!i.length)return"There are no pieces in the scene to select.";const c=String(e).toLowerCase().trim(),m=c.split(/\s+/).filter(o=>o.length>2),n=i.find(o=>o.name.toLowerCase()===c)||i.find(o=>o.name.toLowerCase().includes(c))||i.find(o=>c.includes(o.name.toLowerCase()))||i.find(o=>m.some(u=>o.name.toLowerCase().includes(u)));if(!n)return`Couldn't find a piece matching "${e}". In the scene: ${i.map(o=>o.name).join(", ")}.`;try{v.getState().selectInstance?.(n.id)}catch{}return await q(2),`Selected ${n.name}. You can now change or delete it.`}}),D({name:"updatePieceFeature",description:"Change a feature (width, door, handle, finish, size, \u2026) on the CURRENTLY SELECTED piece. Select one first with selectPiece. See sceneInventory for the selected piece's features and options.",parameters:[{name:"featureKey",type:"string",required:!0,description:"The feature name (or id) to change \u2014 from the selected piece's features."},{name:"optionKey",type:"string",required:!0,description:"The option name (or id) to select."}],handler:async({featureKey:e,optionKey:t})=>{let d=v.getState().selectedInstanceId;if(d==null){const c=await import("./a77b15c0d6.js"),m=v.getState().productInstances||{},n=$.getState().products||{},o=$.getState().features||{},u=String(e).toLowerCase(),r=Object.keys(m).filter(a=>(c.getPlacementBindings(a)||[]).some(I=>{const l=String((o[I.optionSetId]||o[String(I.optionSetId)]||{}).name||"").toLowerCase();return l&&(l===u||l.includes(u)||u.includes(l))}));if(r.length===1)d=r[0];else if(r.length>1){const a=r.map(I=>{const l=m[I];return(n[l?.variantId]||n[l?.productId])?.name||I});return`Several pieces have a "${e}" option (${a.join(", ")}). Say which one (e.g. by its name), then I'll change it.`}}const i=await ce({instanceId:d,featureKey:e,optionKey:t});return await q(2),i.msg}}),D({name:"deleteSelectedPiece",description:"Delete the currently selected piece from the scene. Select one first with selectPiece if needed.",parameters:[],handler:async()=>{const e=v.getState().selectedInstanceId;if(e==null)return"No piece is selected. Select one first (selectPiece).";try{await(await import("./a77b15c0d6.js")).removeProduct(e)}catch(t){return`Couldn't delete the selected piece: ${t?.message||"the engine is unavailable"}.`}try{v.getState().removeProductInstance?.(e)}catch{}try{v.getState().selectInstance?.(null)}catch{}return await q(2),"Deleted the selected piece."}}),D({name:"movePiece",description:"Move/reorder the CURRENTLY SELECTED piece one position left or right within its run. Select a piece first with selectPiece if needed. (Pieces snap into a sequenced run, so this reorders rather than free-positions.)",parameters:[{name:"direction",type:"string",required:!0,enum:["left","right"],description:'"left" or "right".'}],handler:async({direction:e})=>{const t=v.getState(),d=t.selectedInstanceId;if(d==null)return"No piece is selected. Select one first (selectPiece), then say which way to move it.";const i=t.productInstances||{},c=i[d];if(!c)return"The selected piece is no longer in the scene.";const m=p=>p?.placementGroup??p?.placement_group??null,n=p=>{const w=Number(p?.sequence);return Number.isFinite(w)?w:null},o=m(c),u=Object.entries(i).filter(([,p])=>m(p)===o&&n(p)!=null).map(([p,w])=>({id:p,seq:n(w)})).sort((p,w)=>p.seq-w.seq),r=u.findIndex(p=>String(p.id)===String(d));if(r<0||u.length<2)return"There is nothing to reorder \u2014 the selected piece has no neighbours in its run.";const a=/right|next|forward|end/i.test(String(e)),I=a?u[r+1]:u[r-1];if(!I)return a?"The piece is already at the right end of its run.":"The piece is already at the left end of its run.";let l=c?.positionedAbove!=null?String(c.positionedAbove):null,k=null;if(l){const p=i[l];k=p?p.variantId??p.productId??null:null}else{const p=$.getState(),w=p.getProduct?.(c?.variantId)||p.getProduct?.(c?.productId);k=re(w,c)}try{await(await import("./a77b15c0d6.js")).moveProduct({placementId:d,sequence:Math.round(I.seq),hostPlacementId:l,hostVariantId:k})}catch(p){return`Couldn't move the piece: ${p?.message||"the engine is unavailable"}.`}return await q(2),`Moved the selected piece one position to the ${a?"right":"left"}.`}}),D({name:"toggleFullscreen",description:"Toggle fullscreen for the 3D scene.",parameters:[{name:"enabled",type:"boolean",required:!0,description:"true = enter, false = exit."}],handler:async({enabled:e})=>{const t=document.querySelector(".scene-canvas");return t?e&&!document.fullscreenElement?(await t.requestFullscreen?.(),"Entered fullscreen."):!e&&document.fullscreenElement?(await document.exitFullscreen?.(),"Exited fullscreen."):e?"Already in fullscreen.":"Not in fullscreen.":"Could not find the scene element."}}),D({name:"switchView",description:"Switch between 2D top-down and 3D perspective view.",parameters:[{name:"view",type:"string",required:!0,enum:["2D","3D"],description:'"2D" or "3D".'}],handler:async({view:e})=>{const t=e==="3D";return N.getState().is3D===t?`Already in ${e} view.`:(v.getState().setCameraPosition(t?[4,4,6]:[0,10,.1]),N.getState().toggleView(),`Switched to ${e} view.`)}}),D({name:"resetCamera",description:"Reset the camera to the default 3D view.",parameters:[],handler:async()=>(v.getState().setCameraPosition([4,4,6]),N.getState().is3D||N.getState().toggleView(),"Camera reset.")}),D({name:"toggleDimensions",available:S?"enabled":"disabled",description:S?"Show or hide the dimension overlay.":"This product has no dimension overlay to show or hide.",parameters:[{name:"show",type:"boolean",required:!0,description:"true = show, false = hide."}],handler:async({show:e})=>S?N.getState().showDimensions===e?e?"Dimensions already visible.":"Dimensions already hidden.":(N.getState().toggleDimensions(),e?"Dimensions shown.":"Dimensions hidden."):"This product has no dimension overlay."}),D({name:"toggleWalls",available:b?"enabled":"disabled",description:b?"Show or hide the room walls in the scene.":"This product has no room walls to show or hide.",parameters:[{name:"show",type:"boolean",required:!0,description:"true = show walls, false = hide walls."}],handler:async({show:e})=>b?N.getState().showWalls===e?e?"Walls already visible.":"Walls already hidden.":(N.getState().toggleWalls(),e?"Walls shown.":"Walls hidden."):"This product has no walls to toggle."})}export{de as default};
|