@imagineio/configurator-sdk 0.1.5 → 0.1.7

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.
@@ -1 +1 @@
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};
1
+ import g from"./be337ddda5.js";import P from"./9c6c598569.js";import v 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 _}from"./4e1db1e3b0.js";import{dispatchEvents as k,dispatchCustomEffects as F}from"./970313b92b.js";import{emitEvent as h,EVENTS as x}from"./2e366d7386.js";import{setConfigState as d,setInitial as z,resetConfigState as Y}from"./817d930a49.js";import{buildCanonicalState as p,applyResolvedToScene as Q,applyRemovedPlacements as G,applyAddedPlacements as V,applyWarnings as J,applyMessages as E,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 Pt,getShareToken as vt,setOrganizationId as It,getOrganizationId as Ct}from"./431a2d8618.js";import{isReadOnlyCredential as Tt,onReadOnlyChange as At}from"./431a2d8618.js";import{setTokenProvider as bt,clearSessionToken as Et,getSessionScope as wt}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{v.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{v.setState({placementBoundsExcludeIds:o})}catch{}}async function Se({onRefetchCatalog:e}={}){L(e||fe),U(Pe),$(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=P.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=P.getState().selectedInstanceId}catch{}try{if(T.getState().isLayoutLoading)return null}catch{}d(p());let t=null;try{t=await _(m.noop())}catch{return null}return f(t)}function Pe(){const e=P.getState(),t=e.selectedInstanceId;if(t==null)return{};if(String(t).endsWith("__host")){const a=String(t).replace(/__host$/,""),s=(e.productInstances||{})[a]||null,c=v.getState(),l=s?c.getProduct?.(s.variantId??s.productId):null,i=ce(l,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 ve(e,t,r,o){const n=e&&typeof e=="object"?e:{placementId:e,optionSetId:t,optionId:r,...o||{}},{placementId:a,optionSetId:s,optionId:c,optimistic:l,rollback:i}=n;if(a==null||s==null||c==null)return null;try{if(P.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 _(m.selectOption(a,s,c),{optimistic:l,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,c=o.placementId!=null?String(o.placementId).replace(/__host$/,""):null;if(c==null||n==null)return null;try{if(P.getState().productInstances?.[c]?.locked)return T.getState().showWarning?.("This item is locked and can\u2019t be changed."),null}catch{}d(p());let l=null;try{l=await y(m.changeHostVariant(c,n),{optimistic:a,rollback:s})}catch{return h(x.ERROR,{op:"changeHostVariant"}),null}return f(l)}async function ze(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 Ye(e,t,r){const o=e&&typeof e=="object"?e:{optionSetId:e,optionId:t,...r||{}},{optionSetId:n,optionId:a,optimistic:s,rollback:c}=o;if(n==null||a==null)return null;const l=I.getState(),i=l.sceneSelections?.[n];l.setSceneSelection?.(n,a),d(p());let u=null;try{u=await _(m.selectSystemOption(n,a),{optimistic:s,rollback:c})}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=v.getState().options||{},n=o[t]||o[String(t)];if(!n)return null;const a=n.value??n.valueText??n.value_text,s=v.getState().products||{},c=a!=null?s[a]||s[String(a)]:null;if(!c&&r.productGraphId==null)return null;const l=r.productGraphId??c?.productGraph??c?.product_graph??c?.productGraphId??null,i=r.placementGroup??c?.placementGroup??c?.placement_group??null,u=r.variantId??a,S=r.replacePlacementId!==void 0?r.replacePlacementId:le({placementGroup:i});return Ce({productGraphId:l,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:c}=o;if(n==null||a==null)return null;d(p());let l=null;try{l=await _(m.changeVariant(n,a),{optimistic:s,rollback:c})}catch{return null}return f(l)}function W(){let e=null,t=null;try{e=g.getState().systemId??null}catch{}try{const r=P.getState(),o=g.getState();t=r.activeSceneConfigId||o.defaultPresetId||Object.keys(o.sceneConfigurations||{})[0]||null}catch{}return e==null?null:`${e}|${t??""}`}let b=null;const O=new Set;async function Ze({force:e=!1}={}){const t=W();if(!e&&t!=null&&O.has(t))return null;if(b)return b;b=Ie(),M(!0);try{const r=await b;t!=null&&O.add(t);const o=W();return o!=null&&O.add(o),r}finally{b=null,M(!1)}}async function Ie(){const e=g.getState().systemId;if(e==null)return null;const t=P.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;z(r);try{ee(r.state)}catch{}try{E(r.messages)}catch{}try{E(r.customDiagnostics)}catch{}try{k(r.events)}catch{}try{F(r.customEffects)}catch{}try{const o=r.state.sceneId??r.state.scene_id;o!=null&&P.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{Q(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&&(Q(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(e.messages)}catch{}try{E(e.customDiagnostics)}catch{}try{k(e.events)}catch{}try{F(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:c,replacePlacementId:l,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:c,replacePlacementId:l}),{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:c,rollback:l}={}){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:c,rollback:l})}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 _(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=v.getState(),s=a.features?.[e]??a.features?.[String(e)],c=s?.defaultOption??s?.default_option_id??s?.default_option??void 0;o.setSceneSelection?.(e,c),d(p());let l=null;try{l=await y(m.clearSystemSelection(e),{optimistic:t,rollback:r})}catch{return I.getState().setSceneSelection?.(e,n),null}if(l&&l.rejected)I.getState().setSceneSelection?.(e,n);else{const i=l?.defaultOptionOverrides?.[e]??l?.defaultOptionOverrides?.[String(e)];i!=null&&I.getState().setSceneSelection?.(e,i)}return f(l)}function Re(e,t,r){if(e==null)return null;const o=String(e),n=P.getState(),a=n.productInstances?.[o];if(!a)return null;const s=Array.isArray(t)?t:null,c=Array.isArray(r)?r:null;if(!s&&!c)return null;s&&n.updateInstancePosition(o,s),c&&n.updateInstanceRotation(o,c);const l=v.getState(),i=l.getProduct?.(a.variantId)||l.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,c??a.rotation)),{placementId:o,position:s??a.position??null,rotation:c??a.rotation??null,freeMovable:R}}async function Te(e=null,{geometry:t=!0}={}){const r=v.getState(),o=g.getState(),n=typeof window<"u"&&window.location?new URLSearchParams(window.location.search).get("system"):null,a=e??n??null;let s="3d";try{const{peekPrefetchedSystem:l}=await import("./be0cfe2236.js"),i=l(a);s=i?.renderMode??i?.render_mode??"3d"}catch{}await r.loadCatalog({systemId:a,skipProducts:s==="rendered"||!t}),await o.loadConfigurations(a??e);try{const l=g.getState(),i=l.systemDomainDefaults??l.systemRoom?.domain_defaults??null;if(i){const{loadDomainDefaults:u}=await import("./ee242c0099.js");u(i)}}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}={})=>ve({placementId:e,...t});function pt(){L(null),U(null),he(),Y()}import{dispatch as Ot}from"./776277593f.js";import{subscribe as Bt,getVersion as Lt,getConfigState as Ut,getResolved as kt,getBindingAvailable as Ft,getPlacementBinding as Qt,getPlacementBindings as Gt,getEffectiveSelections as Vt,resetConfigState as Ht}from"./817d930a49.js";import{getPlacementOverrides as jt,getSlotOverride as Wt,resolveComponentTransform as Kt,resolveComponentVisibility as $t,resolveComponentMaterial as qt}from"./c3b8f1973b.js";export*from"./3c916f744f.js";import{buildCanonicalState as Jt,hostedProductPlacementId as Xt,getHostedProductSpawnSelections as Zt,applySceneConfigDefaults as eo,queuePieceAdd as to,dequeuePieceAdd as oo,wasPieceAddConsumed as ro}from"./bcd44b4040.js";import{recomputePrice as ao,applyBackendPricing as so}from"./67f6338a4a.js";import{on as co,registerEffectHandler as io,_resetEventBus as uo}from"./970313b92b.js";import{registerComponent as mo,resolveComponent as fo,hasComponent as go,listComponentOverrides as So,_resetComponents as yo}from"./882bc739c8.js";import{registerSlot as xo,listSlots as Po,hasSlot as vo,SlotHost as Io,_resetSlots as Co}from"./73f7d65985.js";import{use as To,runIntent as Ao,listMiddleware as _o,INTENTS as bo,_resetMiddleware as Eo}from"./6d238282c1.js";import{onEvent as Mo,onceEvent as Oo,offEvent as Do,listEvents as Bo,emitEvent as Lo,EVENTS as Uo,_resetEvents as ko}from"./2e366d7386.js";import{onRequest as Qo,onResponse as Go,setTransport as Vo,hasTransport as Ho,_resetHttp as No}from"./a3f18e76fe.js";import{readBom as Wo,readQuote as Ko,readGeneratedAssets as $o,setMetadata as qo,readMetadata as zo,serializeMetadata as Yo,restoreMetadata as Jo,METADATA_LIMITS as Xo,_resetMetadata as Zo}from"./3656ffa1b8.js";import{collectGenericBom as tr,collectGenericBom as or,collectPlacementParts as rr}from"./81802759ca.js";import{readBounds as ar,onSettled as sr}from"./da7b5f450d.js";import{registerComponentRenderer as cr,resolveComponentRenderer as ir,listComponentRenderers as ur,registerMaterialResolver as dr,listMaterialResolvers as pr,registerInteraction as mr,runInteraction as fr,listInteractions as gr,onSceneReady as Sr,getSceneContext as yr,_resetSceneRegistry as hr}from"./95a44ebec2.js";import{registerAction as Pr,runAction as vr,listActions as Ir,actions as Cr,registerIcon as Rr,resolveIcon as Tr,listIcons as Ar,hasIcon as _r,useIcon as br,useHasIcon as Er,registerModal as wr,listModals as Mr,ModalHost as Or,openModal as Dr,_resetUiRegistry as Br}from"./09c4973968.js";import{setLabels as Ur,getLabel as kr,getLabels as Fr,useLabel as Qr,setLocale as Gr,getLocale as Vr,setCurrency as Hr,getCurrency as Nr,isRtl as jr,formatMoney as Wr,formatNumber as Kr,useFormatters as $r,useLabels as qr,_resetLabels as zr}from"./28d887bf8a.js";import{computeTargets as Jr,resolveTarget as Xr,registerTargetRenderer as Zr,resolveTargetRenderer as en,resolveInsertSequence as tn,_resetTargets as on}from"./58e6419ba8.js";import{default as nn}from"./205827c5c8.js";import{registerQuoteTemplate as sn,resolveQuoteTemplate as ln,hasQuoteTemplate as cn,useQuoteTemplate as un,setQuoteTemplate as dn,setBackendQuoteTemplate as pn,activeQuoteTemplateKey as mn,activeQuoteDesignKey as fn,listQuoteTemplates as gn,_resetQuoteTemplate as Sn}from"./4ba4f544b9.js";import{useUIRegion as hn,useUIRegions as xn,getUIRegions as Pn,UI_REGIONS as vn}from"./9840b9ce12.js";import{default as Cn}from"./b976df09ec.js";import{default as Tn}from"./6c0a2572dd.js";import{default as _n}from"./cdb4a0f7b3.js";import{default as En}from"./0f7c8345a8.js";import{default as Mn}from"./82a8a4bc35.js";import{default as Dn}from"./e379e0039b.js";import{registerRoute as Ln,resolveRoute as Un,hasRoute as kn,listRoutes as Fn,useRouteRegistry as Qn,_resetRoutes as Gn}from"./61e0c0c9b5.js";import{hideComponent as Hn,showComponent as Nn,transformComponent as jn,setComponentMaterial as Wn,clearComponentOverrides as Kn,listComponents as $n,componentOverrideFor as qn,useComponentOverride as zn,_resetComponentApi as Yn}from"./a3c983d431.js";import{setToggles as Xn,getToggles as Zn,useHostToggles as ea,_resetToggles as ta}from"./41ed5985ad.js";import{registerAssetResolver as ra,hasAssetResolver as na,resolveAssetUrl as aa,_resetAssetResolver as sa}from"./cec035efb1.js";import{registerButton as ca}from"./f1b3b2622a.js";import{SaveProjectButton as ua,GenerateAssetsButton as da,LiveStatusPanel as pa,ChatBar as ma,NotificationContainer as fa,EvaluatingOverlay as ga,Modals as Sa,SaveProjectModal as ya,ExportModal as ha,ARModal as xa,GeneratedAssetsModal as Pa,Header as va,SceneToolbar as Ia,Sidebar as Ca,SidebarFrame as Ra,OptionSidebar as Ta,LoadingScreen as Aa,ConfirmDialog as _a,Modal as ba,Button as Ea,ARViewer as wa,SceneRoom as Ma,SceneDimensions as Oa,CameraAnimator as Da}from"./64e9020b49.js";import{default as La}from"./921bf270dd.js";import{registerLayout as ka,resolveLayout as Fa,hasLayout as Qa,listLayouts as Ga,useLayoutRegistry as Va,setLayout as Ha,activeLayoutKey as Na,_resetLayouts as ja}from"./31ea036f5c.js";import{setQuoteDocument as Ka,getQuoteDocument as $a,hasQuoteDocument as qa,resetQuoteDocument as za,subscribeQuoteDocument as Ya,QUOTE_COLUMNS as Ja,COLUMN_DEFS as Xa}from"./12b8165d6d.js";import{useQuoteDocument as es}from"./d464da28a5.js";import{generateSilo as os,generateLifestyle as rs,generateAr as ns,generateBomPdf as as,generateAll as ss,generationStatus as ls,waitForAssets as cs,ASSET_GROUPS as is}from"./5d05e8982e.js";import{buildQuotePdfBlob as ds,saveQuotePdf as ps,registerQuotePdf as ms,registerQuotePdfEndpoint as fs,hasQuotePdf as gs,listQuotePdfBuilders as Ss,_resetQuotePdf as ys}from"./d20718159b.js";import{configureSDK as xs}from"./db4afd43c9.js";import{default as vs}from"./7206ce49c6.js";import{default as Cs}from"./d0f9681634.js";import{default as Ts}from"./2990ba64d6.js";import{useSelection as _s,useProducts as bs,usePrice as Es}from"./16a399703e.js";import{getProduct as Ms,getProductName as Os,getPlacedProductName as Ds,getProductVariants as Bs,listProducts as Ls,getOptionSet as Us,getOption as ks,useProduct as Fs,listOptionSets as Qs,listSceneOptionSets as Gs,listProductOptionSets as Vs,listOptions as Hs,listMaterials as Ns,getMaterial as js}from"./1458417bdb.js";import{useBootStatus as Ks,useSystem as $s,endBootLoading as qs,markThemeReady as zs,setEmbedded as Ys,setSystemTheme as Js}from"./066fc9aa40.js";import{default as Zs}from"./60d697292c.js";import{default as tl}from"./811b403d43.js";import{default as rl}from"./6ba86aa3b8.js";import{default as al}from"./3fb3ab6757.js";import{OptionThumbnail as ll,FinishThumbnail as cl,LayoutThumbnail as il,HostedProductThumbnail as ul,WidthSlider as dl,ColorSwatch as pl,FrameSizeButton as ml,ProductFeaturePickers as fl}from"./c12c112c6f.js";import{loadWallMaterial as Sl,getConcreteWallMaterial as yl,getWallBoxMaterials as hl,createWallDiffuse as xl,createWallNormalMap as Pl,createWallRoughnessMap as vl}from"./22bd38ddcf.js";import{SelectionBox as Cl,SELECTION_COLOR as Rl,SelectionActionPanel as Tl,ProductInstance as Al,ComponentMesh as _l,FreeMovable as bl,PlacementGaps as El,SceneStage as wl,SceneEnvironment as Ml,applyEnvironmentToRenderer as Ol}from"./8a3a57c008.js";import{PLACEMENT_TYPES as Bl,getPlacementType as Ll,resolveReplaceTarget as Ul}from"./4d7a0d1897.js";import{FEATURE_ACTIONS as Fl,resolveFeatureAction as Ql,isAddFeature as Gl}from"./8c27edda0f.js";import{getPlacementStrategy as Hl,resolvePlacementStrategyId as Nl,setPlacementStrategy as jl,clearPlacementStrategy as Wl,getPlacementStrategyOverride as Kl,resolvePlacementStrategyConfig as $l,setPlacementStrategyConfig as ql,DEFAULT_STRATEGY_ID as zl,STRATEGIES as Yl}from"./281cf952fa.js";import{default as Xl}from"./a493e9aa8f.js";import{registerPlacementStrategy as ec,hasPlacementStrategy as tc,listPlacementStrategies as oc,currentConfiguratorKey as rc,_resetPlacementStrategies as nc}from"./281cf952fa.js";import{enforceCorners as sc}from"./388cadacbd.js";import{resolveAddMode as cc,armPlacement as ic,disarmPlacement as uc,getPendingPlacement as dc,computeGaps as pc}from"./ab6c80484f.js";import{armHostedProduct as fc,disarmHostedProduct as gc}from"./ab6c80484f.js";import{usePlacementInteraction as yc}from"./4b8958aa4c.js";import{bootConfigurator as xc}from"./371ed78aa2.js";import{setAllowedOrigins as vc,getAllowedOrigins as Ic}from"./1e243363f6.js";import{mountConfigurator as Rc}from"./1870fc037b.js";import*as Tc from"./d30f1f506e.js";export*from"./2cafe3274b.js";import{registerCommand as bc,runCommand as Ec,hasCommand as wc,listCommands as Mc,resetCommands as Oc,COMMANDS as Dc}from"./d6851ea979.js";import{captureDesignViews as Lc,buildDesignPdf as Uc,saveProject as kc,loadProject as Fc,restoreProject as Qc,parseShareToken as Gc,buildShareUrl as Vc,adoptShareTokenInUrl as Hc,generateArForCurrentScene as Nc}from"./d30f1f506e.js";import{default as Wc}from"./be337ddda5.js";import{default as $c}from"./872c4302e0.js";import{default as zc}from"./9c6c598569.js";import{default as Jc}from"./8f60e5059a.js";import{default as Zc}from"./1fac915f8b.js";import{default as ti}from"./3f37665dd1.js";import{default as ri,fetchEmbedBoot as ni}from"./79a397bb92.js";import{getApiKey as si}from"./431a2d8618.js";import{setApiBaseUrl as ci,getApiBaseUrl as ii}from"./8ade32d067.js";import{setServiceUrls as di}from"./9544661159.js";import{applyTheme as mi,applyThemeById as fi,themeMode as gi,normalizeThemeId as Si,themeLayoutKey as yi}from"./5c9fd9201c.js";import{validateTheme as xi,checkThemeContrast as Pi,contrastRatio as vi,applyCustomCss as Ii,applyFontUrl as Ci}from"./b1349d5a21.js";import{default as Ti}from"./f11a45a150.js";import{setEmbedContext as _i,trackEmbed as bi}from"./0af28430ab.js";import{CopilotContext as wi,useCopilotAvailable as Mi}from"./672404d987.js";import{checkCopilotAvailability as Di,getCopilotRuntimeUrl as Bi,getCopilotWarmupUrl as Li,getCopilotApiUrl as Ui,setCopilotApiUrl as ki}from"./fe58a84b85.js";export{xa as ARModal,wa as ARViewer,is as ASSET_GROUPS,Ea as Button,Xa as COLUMN_DEFS,Dc as COMMANDS,Da as CameraAnimator,ma as ChatBar,pl as ColorSwatch,_l as ComponentMesh,Mn as ConfigurationSummary,_a as ConfirmDialog,wi as CopilotContext,zl as DEFAULT_STRATEGY_ID,_n as DefaultQuoteTemplate,Uo as EVENTS,ga as EvaluatingOverlay,ha as ExportModal,Fl as FEATURE_ACTIONS,cl as FinishThumbnail,ml as FrameSizeButton,bl as FreeMovable,da as GenerateAssetsButton,Pa as GeneratedAssetsModal,va as Header,ul as HostedProductThumbnail,bo as INTENTS,il as LayoutThumbnail,pa as LiveStatusPanel,Aa as LoadingScreen,Xo as METADATA_LIMITS,ba as Modal,Or as ModalHost,Sa as Modals,fa as NotificationContainer,al as OptionSetSection,Ta as OptionSidebar,ll as OptionThumbnail,Bl as PLACEMENT_TYPES,El as PlacementGaps,nn as PlacementTargets,vs as Popover,fl as ProductFeaturePickers,Al as ProductInstance,Ja as QUOTE_COLUMNS,Dn as QuoteQr,En as QuoteRenders,Tn as QuoteView,Rl as SELECTION_COLOR,Yl as STRATEGIES,ua as SaveProjectButton,ya as SaveProjectModal,Oa as SceneDimensions,Ml as SceneEnvironment,Ma as SceneRoom,wl as SceneStage,Ia as SceneToolbar,Tl as SelectionActionPanel,Cl as SelectionBox,Ca as Sidebar,Ra as SidebarFrame,Io as SlotHost,vn as UI_REGIONS,dl as WidthSlider,sa as _resetAssetResolver,Yn as _resetComponentApi,yo as _resetComponents,uo as _resetEventBus,ko as _resetEvents,No as _resetHttp,zr as _resetLabels,ja as _resetLayouts,Zo as _resetMetadata,Eo as _resetMiddleware,nc as _resetPlacementStrategies,ys as _resetQuotePdf,Sn as _resetQuoteTemplate,Gn as _resetRoutes,hr as _resetSceneRegistry,Co as _resetSlots,on as _resetTargets,ta as _resetToggles,Br as _resetUiRegistry,Cr as actions,Na as activeLayoutKey,fn as activeQuoteDesignKey,mn as activeQuoteTemplateKey,Ce as addProduct,Je as addProductFromOption,Hc as adoptShareTokenInUrl,ri as apiService,so as applyBackendPricing,Ii as applyCustomCss,Ol as applyEnvironmentToRenderer,Ci as applyFontUrl,nt as applyLayoutPreset,eo as applySceneConfigDefaults,mi as applyTheme,fi as applyThemeById,fc as armHostedProduct,ic as armPlacement,xc as bootConfigurator,Jt as buildCanonicalState,Uc as buildDesignPdf,Pe as buildFocusContext,ds as buildQuotePdfBlob,Vc as buildShareUrl,Lc as captureDesignViews,qe as changeHostVariantForProduct,Xe as changeProductVariant,Di as checkCopilotAvailability,Pi as checkThemeContrast,Kn as clearComponentOverrides,Wl as clearPlacementStrategy,lt as clearProductOption,ct as clearSceneOption,Et as clearSessionToken,or as collectBom,tr as collectGenericBom,rr as collectPlacementParts,qn as componentOverrideFor,pc as computeGaps,Jr as computeTargets,xs as configureSDK,vi as contrastRatio,xl as createWallDiffuse,Pl as createWallNormalMap,vl as createWallRoughnessMap,rc as currentConfiguratorKey,oo as dequeuePieceAdd,gc as disarmHostedProduct,uc as disarmPlacement,Ot as dispatch,Lo as emitEvent,qs as endBootLoading,sc as enforceCorners,ni as fetchEmbedBoot,Wr as formatMoney,Kr as formatNumber,ss as generateAll,ns as generateArAsset,Nc as generateArForCurrentScene,as as generateBomPdf,rs as generateLifestyle,os as generateSilo,ls as generationStatus,ii as getApiBaseUrl,si as getApiKey,Ft as getBindingAvailable,yt as getChannelId,yl as getConcreteWallMaterial,Ut as getConfigState,Ui as getCopilotApiUrl,Bi as getCopilotRuntimeUrl,Li as getCopilotWarmupUrl,Nr as getCurrency,Vt as getEffectiveSelections,xt as getEmbedSlug,Zt as getHostedProductSpawnSelections,Ic as getIframeAllowedOrigins,kr as getLabel,Fr as getLabels,Vr as getLocale,js as getMaterial,ks as getOption,Us as getOptionSet,Ct as getOrganizationId,dc as getPendingPlacement,Ds as getPlacedProductName,Qt as getPlacementBinding,Gt as getPlacementBindings,jt as getPlacementOverrides,Hl as getPlacementStrategy,Kl as getPlacementStrategyOverride,Ll as getPlacementType,Ms as getProduct,Os as getProductName,Bs as getProductVariants,$a as getQuoteDocument,kt as getResolved,yr as getSceneContext,ut as getSelectedSystemId,wt as getSessionScope,vt as getShareToken,Wt as getSlotOverride,Zn as getToggles,Pn as getUIRegions,Lt as getVersion,hl as getWallBoxMaterials,na as hasAssetResolver,wc as hasCommand,go as hasComponent,_r as hasIcon,Qa as hasLayout,tc as hasPlacementStrategy,qa as hasQuoteDocument,gs as hasQuotePdf,cn as hasQuoteTemplate,kn as hasRoute,vo as hasSlot,Ho as hasTransport,Hn as hideComponent,Xt as hostedProductPlacementId,Se as initConfigEngine,Gl as isAddFeature,Tt as isReadOnlyCredential,jr as isRtl,Ir as listActions,Mc as listCommands,So as listComponentOverrides,ur as listComponentRenderers,$n as listComponents,Bo as listEvents,Ar as listIcons,gr as listInteractions,Ga as listLayouts,pr as listMaterialResolvers,Ns as listMaterials,_o as listMiddleware,Mr as listModals,Qs as listOptionSets,Hs as listOptions,oc as listPlacementStrategies,Vs as listProductOptionSets,Ls as listProducts,Ss as listQuotePdfBuilders,gn as listQuoteTemplates,Fn as listRoutes,Gs as listSceneOptionSets,Po as listSlots,Te as loadConfigurator,Fc as loadProject,Sl as loadWallMaterial,zs as markThemeReady,Rc as mountConfigurator,rt as moveProduct,Si as normalizeThemeId,Do as offEvent,co as on,Mo as onEvent,At as onReadOnlyChange,Qo as onRequest,Go as onResponse,Sr as onSceneReady,sr as onSceneSettled,Oo as onceEvent,Dr as openModal,Gc as parseShareToken,dt as pilotFinishSelect,ze as placeHostedProduct,Xl as placementKit,Tc as projects,to as queuePieceAdd,Wo as readBom,$o as readGeneratedAssets,zo as readMetadata,Ko as readQuote,ar as readSceneBounds,ao as recomputePrice,xe as reevaluateForFocus,tt as refreshCanonicalState,Pr as registerAction,ra as registerAssetResolver,ca as registerButton,bc as registerCommand,mo as registerComponent,cr as registerComponentRenderer,io as registerEffectHandler,Rr as registerIcon,mr as registerInteraction,ka as registerLayout,dr as registerMaterialResolver,wr as registerModal,ec as registerPlacementStrategy,ms as registerQuotePdf,fs as registerQuotePdfEndpoint,sn as registerQuoteTemplate,Ln as registerRoute,xo as registerSlot,Zr as registerTargetRenderer,ot as removeProduct,Oc as resetCommands,Ht as resetConfigState,za as resetQuoteDocument,cc as resolveAddMode,aa as resolveAssetUrl,fo as resolveComponent,qt as resolveComponentMaterial,ir as resolveComponentRenderer,Kt as resolveComponentTransform,$t as resolveComponentVisibility,Ql as resolveFeatureAction,Tr as resolveIcon,tn as resolveInsertSequence,Fa as resolveLayout,$l as resolvePlacementStrategyConfig,Nl as resolvePlacementStrategyId,ln as resolveQuoteTemplate,Ul as resolveReplaceTarget,Un as resolveRoute,Xr as resolveTarget,en as resolveTargetRenderer,at as restoreConfiguration,Jo as restoreMetadata,Qc as restoreProject,vr as runAction,Ec as runCommand,Ao as runIntent,fr as runInteraction,kc as saveProject,ps as saveQuotePdf,Ze as seedInitialState,ve as selectOptionForProduct,Ye as selectOptionForScene,it as selectSystem,Yo as serializeMetadata,ci as setApiBaseUrl,gt as setApiKey,pn as setBackendQuoteTemplate,St as setChannelId,Wn as setComponentMaterial,ki as setCopilotApiUrl,Hr as setCurrency,_i as setEmbedContext,ht as setEmbedSlug,Ys as setEmbedded,vc as setIframeAllowedOrigins,Ur as setLabels,Ha as setLayout,Gr as setLocale,qo as setMetadata,It as setOrganizationId,jl as setPlacementStrategy,ql as setPlacementStrategyConfig,Ka as setQuoteDocument,dn as setQuoteTemplate,st as setRoomDimensions,di as setServiceUrls,Pt as setShareToken,Js as setSystemTheme,Xn as setToggles,bt as setTokenProvider,Vo as setTransport,Nn as showComponent,Bt as subscribe,Ya as subscribeQuoteDocument,pt as teardownConfigEngine,yi as themeLayoutKey,gi as themeMode,bi as trackEmbed,jn as transformComponent,Re as transformProduct,To as use,Ti as useAppVersion,Ks as useBootStatus,zn as useComponentOverride,Wc as useConfigurationGraphStore,Mi as useCopilotAvailable,$r as useFormatters,La as useGenerateAssets,ti as useGeneratedAssetsStore,Er as useHasIcon,ea as useHostToggles,br as useIcon,Qr as useLabel,qr as useLabels,Va as useLayoutRegistry,$c as useObjectGraphStore,Ts as useOptionSets,yc as usePlacementInteraction,Es as usePrice,Fs as useProduct,Zs as useProductOrder,rl as useProductOverrides,bs as useProducts,es as useQuoteDocument,un as useQuoteTemplate,Cn as useReadOnly,Qn as useRouteRegistry,zc as useSceneGraphStore,_s as useSelection,tl as useSelectionActions,$s as useSystem,Cs as useToolbar,hn as useUIRegion,xn as useUIRegions,Jc as useUIStore,Zc as useUndoRedoStore,xi as validateTheme,cs as waitForAssets,ro as wasPieceAddConsumed};
@@ -1 +1 @@
1
- import c from"./79a397bb92.js";import{markThemeReady as o}from"./066fc9aa40.js";let i=null,a=null;function s(t){if(!i||t==null||String(t)!==i.id)return null;const{data:e}=i;return i=null,e}function p(t){if(!a||t==null||String(t)!==a.id)return null;const{data:e}=a;return a=null,e}function d(){i=null,a=null}function f(t){return t!=null&&(typeof t=="number"||/^\d+$/.test(String(t)))}async function S(t){try{const e=new URLSearchParams(window.location.search);if(e.has("theme")){const{applySystemTheme:r}=await import("./5c9fd9201c.js");return r(e.get("theme")),o(),!0}}catch{}if(t==null)return!1;try{const e=await c.fetchSystem(t);if(!e)return!1;i={id:String(t),data:e};const r=e.themeId??e.theme_id??null,u=e.theme??e.themeKey??null;let n=null;if(f(r)){try{const l=await c.fetchTheme(r);l&&(a={id:String(r),data:l},n=l)}catch{}n==null&&(n=String(r))}else u&&(n=String(u).trim().toLowerCase());if(n!=null){const{applySystemTheme:l}=await import("./5c9fd9201c.js");l(n)}return o(),!0}catch{return!1}}export{d as _resetPrefetch,S as prepareTheme,s as takePrefetchedSystem,p as takePrefetchedTheme};
1
+ import c from"./79a397bb92.js";import{markThemeReady as o}from"./066fc9aa40.js";let r=null,u=null;function s(e){if(!r||e==null||String(e)!==r.id)return null;const{data:t}=r;return r=null,t}function p(e){return!r||e==null||String(e)!==r.id?null:r.data}function d(e){if(!u||e==null||String(e)!==u.id)return null;const{data:t}=u;return u=null,t}function S(){r=null,u=null}function f(e){return e!=null&&(typeof e=="number"||/^\d+$/.test(String(e)))}async function y(e){try{const t=new URLSearchParams(window.location.search);if(t.has("theme")){const{applySystemTheme:n}=await import("./5c9fd9201c.js");return n(t.get("theme")),o(),!0}}catch{}if(e==null)return!1;try{const t=await c.fetchSystem(e);if(!t)return!1;r={id:String(e),data:t};const n=t.themeId??t.theme_id??null,a=t.theme??t.themeKey??null;let l=null;if(f(n)){try{const i=await c.fetchTheme(n);i&&(u={id:String(n),data:i},l=i)}catch{}l==null&&(l=String(n))}else a&&(l=String(a).trim().toLowerCase());if(l!=null){const{applySystemTheme:i}=await import("./5c9fd9201c.js");i(l)}return o(),!0}catch{return!1}}export{S as _resetPrefetch,p as peekPrefetchedSystem,y as prepareTheme,s as takePrefetchedSystem,d as takePrefetchedTheme};
@@ -1 +1 @@
1
- import{create as fe}from"zustand";import{devtools as de}from"./52436e0169.js";import oe from"./79a397bb92.js";import{isHostThemeApplied as ie}from"./40d6aeb28c.js";import W from"./872c4302e0.js";import J from"./8f60e5059a.js";import X,{registerSelectionReconciler as pe}from"./d94df858ea.js";import"./9326c23506.js";import{isHostedProduct as le,isHostFloating as ae}from"./061b81ad81.js";import{setWatermarkFromBackend as ge}from"./d3cd7f1bc1.js";import{isOptionSetVisible as me}from"./817d930a49.js";const _e=["option_selected","option_deselected","variant_selected","variant_deselected","component_loaded","component_removed"];function ye(a){return a?.startsWith?.("option_")?{single:["triggerOption","trigger_option"],many:["triggerOptions","trigger_options"]}:a?.startsWith?.("variant_")?{single:["triggerVariant","trigger_variant"],many:["triggerVariants","trigger_variants"]}:a?.startsWith?.("component_")?{single:["triggerComponent","trigger_component"],many:["triggerComponents","trigger_components"]}:null}function ce(a,o){for(const e of o){const r=a?.[e];if(r!=null)return r}return null}function Se(a,o){const e=ye(o);if(!e)return[];const r=ce(a,e.single),l=ce(a,e.many),n=new Set;if(r!=null&&n.add(String(r)),Array.isArray(l))for(const p of l)p!=null&&n.add(String(p));return[...n]}function he(a){const o={};for(const e of _e)o[e]=new Map;if(!Array.isArray(a))return o;for(const e of a){const r=e.triggerType??e.trigger_type,l=o[r];if(!l)continue;const n=Se(e,r);for(const p of n)l.has(p)||l.set(p,[]),l.get(p).push(e)}for(const e of Object.values(o))for(const r of e.values())r.sort((l,n)=>(n.priority||0)-(l.priority||0));return o}let Z=null;function ve(a,o){const e=o?.[a]??o?.[String(a)]??{},r=e.type??e.kind??null,l=e.wall??e.location??null,n=e.position??e.corner??void 0;return{wall:l,type:r,...n?{position:n}:{}}}function be(a,o,e,r,l,n,p){if(!Array.isArray(e)||e.length===0)return{id:a,name:o,sceneOptionId:l??null,scene_option_id:l??null,optionSets:Array.isArray(r)?r:[],products:[],floatingHostedProducts:[]};const h=t=>typeof t!="string"?"":t.replace("_overlay","").replace("overlay_",""),g=[...e].sort((t,s)=>{const u=h(t?.placement_group||t?.placementGroup||""),c=h(s?.placement_group||s?.placementGroup||"");return u!==c?u.localeCompare(c):(t?.sequence??0)-(s?.sequence??0)}),P=t=>{const s=Array.isArray(t?.hostVariants)?t.hostVariants:Array.isArray(t?.host_variants)?t.host_variants:null;if(!Array.isArray(s)||s.length===0)return null;const u=s.find(c=>c?.isDefault??c?.is_default)||s[0];return u?.hostVariantId??u?.host_variant_id??null},f=g.map(t=>{let s=t.variant??t.variantId??t.product??t.productId,u=t.placement_group??t.placementGroup??null,c=null,_=!1,L=!1;const q=s;if(s!=null&&n){const j=n[s]||n[String(s)];if(j&&le(j))if(ae(j))_=!0;else{const d=P(j);if(d!=null){c=s,s=d;const w=n[d]||n[String(d)],N=w?.placement_group??w?.placementGroup;N!=null&&(u=N)}else c=s,L=!0,typeof u=="string"&&(u=u.replace("_overlay","").replace("overlay_",""))}}return{p:t,productId:s,placementGroup:u,autoLoadHostedProductId:c,dropPlacement:_,overlayHostedProduct:L}}),y=new Map;f.forEach((t,s)=>{if(t.dropPlacement||t.productId==null||t.autoLoadHostedProductId!=null)return;const u=String(t.productId);y.has(u)||y.set(u,s)}),f.forEach(t=>{if(t.dropPlacement||t.autoLoadHostedProductId==null)return;const s=y.get(String(t.productId));s!=null&&(f[s].autoLoadHostedProductId==null&&(f[s].autoLoadHostedProductId=t.autoLoadHostedProductId),t.dropPlacement=!0)});const S=f.map(t=>{if(t.dropPlacement)return null;const s=t.p,u=t.placementGroup,c=s.defaultTransform??s.default_transform??(s.position?{position:s.position,rotation:s.rotation,scale:s.scale}:null),_=ve(u,p);return{placement_id:s.id??s.placementId,product_id:t.productId,product_graph_id:s.product??s.productId??null,placement_group:u,sequence:s.sequence,default_transform:c,initial_options:s.options??s.initialOptions??s.initial_options??null,..._,...t.autoLoadHostedProductId!=null?{auto_load_appliance_product_id:t.autoLoadHostedProductId}:{},...t.overlayHostedProduct?{overlay_appliance:!0}:{}}}).filter(Boolean),T=t=>typeof t?.sequence=="number"?t.sequence:0;for(const t of["corner","wall_corner"]){const s=S.filter(u=>u.type===t&&(u.position==="back-right"||u.position==="back-left")).sort((u,c)=>T(u)-T(c));s.length>=2&&s.every(u=>u.position===s[0].position)&&(s[0].position="back-left",s[s.length-1].position="back-right")}for(const t of["corner","wall_corner"]){const s=S.filter(u=>u.type===t&&(u.position==="front-right"||u.position==="front-left")).sort((u,c)=>T(u)-T(c));s.length>=2&&s.every(u=>u.position===s[0].position)&&(s[0].position="front-left",s[s.length-1].position="front-right")}const F=t=>typeof t?.sequence=="number"?t.sequence:0,A=(t,s)=>{const u=S.find(c=>c.type===t&&c.position===s);return u!=null?F(u):null},K=[{rowType:"base",cornerType:"corner",backWall:"back"},{rowType:"upper",cornerType:"wall_corner",backWall:"back"}];for(const{rowType:t,cornerType:s,backWall:u}of K){const c=A(s,"back-left"),_=A(s,"back-right"),L=S.filter(d=>d.type===t&&d.wall===u).map(F),q=c!=null&&L.some(d=>d>c),j=_!=null&&L.some(d=>d<_);for(const d of S){if(d.type!==t||d.wall!==u)continue;const w=F(d);if(j&&w>_){d.wall="right";continue}if(q&&w<c){d.wall="left";continue}}}const V=f.filter(t=>{if(!t.dropPlacement)return!1;const s=t.p.variant??t.p.variantId??t.p.product??t.p.productId,u=n?.[s]||n?.[String(s)];return le(u)&&ae(u)}).map(t=>({placement_id:t.p.id??t.p.placementId,product_id:t.p.variant??t.p.variantId??t.p.product??t.p.productId,sequence:t.p.sequence}));return{id:a,name:o,sceneOptionId:l??null,scene_option_id:l??null,optionSets:r,products:S,floatingHostedProducts:V}}function Y(a){return a==null?null:typeof a=="object"?a.id??a.optionSetId??a.option_set_id??a.optionId??a.option_id??null:a}function Ie(a){if(!a)return{};const e=(Array.isArray(a.optionSets)?a.optionSets:[]).map(Y).filter(f=>f!=null),r=a.products||null,l=a.placement_groups??a.placementGroups??{},n={},p=(f,y,S,T,F=!1)=>{if(f==null)return;const A=be(f,y,S,e,T,r,l);A&&(A.useTransform=!!F,n[A.id]=A)},h=a.presets??a.layouts??null;if(h&&typeof h=="object"){const f=Array.isArray(h)?h.map(y=>[y?.id,y]):Object.entries(h);for(const[y,S]of f){const T=Array.isArray(S?.data)?S.data:Array.isArray(S?.placements)?S.placements:[];p(S?.id??y,S?.name??null,T,S?.sceneOptionId??S?.scene_option_id??S?.optionId??S?.option_id??null,S?.useTransform??S?.use_transform??!1)}if(Object.keys(n).length>0)return n}const g=a.defaultPreset??a.default_preset;if(g&&typeof g=="object"){const f=Array.isArray(g.placements)?g.placements:Array.isArray(g.data)?g.data:[];if(p(g.id??"default_layout",g.name??null,f,null,g.useTransform??g.use_transform??!1),Object.keys(n).length>0)return n}const P=Array.isArray(a.placements)?a.placements:[];if(P.length>0){const f=Y(g)??"default_layout";p(f,null,P,null,(g&&(g.useTransform??g.use_transform))??a.useTransform??a.use_transform??!1)}return Object.keys(n).length===0&&p(Y(g)??"default_layout",a.name??null,[],null,a.useTransform??a.use_transform??!1),n}function Oe(a,o,e,r,l){const n=a?.optionSets||[],p=a?.sceneOptionId||a?.scene_option_id,h=[];return n.forEach((g,P)=>{const f=e[g];if(!f)return;const y=f.type==="layout_change"||f.type==="load_configuration";let S=f.type;y&&(S="layout_change");const T=String(g),F=l&&l[T],A=y?p:F??f.default_option_id??f.defaultOption,K=o[String(g)],V=typeof K=="number"?K:P,t=r&&r[T];h.push({id:g,feature_id:g,...f.presentation?{presentation:f.presentation}:{},...f.flow?{flow:f.flow}:{},sequence:V,name:f.name,type:S,...f.role?{role:f.role}:{},...f.metadata?.role&&!f.role?{role:f.metadata.role}:{},contentKind:f.contentKind||"options",childOptionSetIds:f.childOptionSetIds||[],default_option_id:A,...Array.isArray(t)&&t.length>0?{options:t}:{}})}),h.sort((g,P)=>(g.sequence??0)-(P.sequence??0)),h}const ue=new WeakMap,ne=fe(de((a,o)=>({rules:[],rulesTriggerIndex:{option_selected:new Map,option_deselected:new Map,component_loaded:new Map,component_removed:new Map},productConfigurations:{},sceneConfigurations:{},originalSceneConfigurations:{},channels:{},constraints:[],systemRoom:null,placementStrategy:null,placementStrategyConfig:null,placementType:null,systemEnvironment:null,placementGroups:{},systemOptionSetSequence:{},systemOptionSetOptions:{},systemOptionSetDefault:{},systemId:null,systemName:null,systemConfiguratorKey:null,systemLayoutTemplate:null,systemQuoteTemplate:null,systemTheme:null,systemThemeRecord:null,useTransform:!1,catalogVersion:null,defaultPresetId:null,activeChannelId:"channel_internal",isLoading:!1,loadError:null,rulesReady:!1,loadConfigurations:async(e=null)=>{if(Z)return Z;const r=o();return r.sceneConfigurations&&Object.keys(r.sceneConfigurations).length>0?Promise.resolve():(Z=(async()=>{a({isLoading:!0,loadError:null});try{const l=W.getState().features,n=W.getState().products,p=W.getState().presets||{},h=W.getState().defaultPresetId,g=new URLSearchParams(window.location.search);let P=e??g.get("system")??null;if(!P)try{const v=await oe.fetchSystems(),i=Array.isArray(v)?v[0]:Object.values(v||{})[0];i?.id!=null&&(P=i.id)}catch{}let f=[],y=[],S=null,T=null,F=null,A=null,K={},V=[];const t={},s={},u={};let c=null,_=null,L=null,q=null,j=null,d=null,w=null,N=null,b=!1,m=null;if(P)try{const{takePrefetchedSystem:v}=await import("./be0cfe2236.js"),i=v(P)??await oe.fetchSystem(P),M=i.uiToggles??i.ui_toggles??null;if(M&&typeof M=="object")try{W.getState().mergeSystemUiToggles(M)}catch{}const z=i.watermarkEnabled??i.watermark_enabled;if(z!=null){try{ge(z)}catch{}try{W.setState({watermarkEnabled:z!==!1})}catch{}}f=i.rules??[],y=i.constraints??[],S=i.room??null,T=i.placementStrategy??i.placement_strategy??i.room?.placement_strategy??null,F=i.placementStrategyConfig??i.placement_strategy_config??i.room?.placement_strategy_config??null,L=i.name??null,q=i.configurator??i.configurator_key??i.configuratorKey??null,j=i.uiTemplate??i.ui_template??i.layoutTemplate??i.layout_template??null,j=j?String(j).trim().toLowerCase():null,d=i.quoteTemplate??i.quote_template??null;const I=i.themeId??i.theme_id??null,D=i.theme??i.themeKey??null;if(I!=null&&(typeof I=="number"||/^\d+$/.test(String(I)))){w=String(I);try{const{takePrefetchedTheme:C}=await import("./be0cfe2236.js"),R=C(I)??await oe.fetchTheme(I);R&&(N=R)}catch{}}else w=D?String(D).trim().toLowerCase():null;b=i.useTransform??i.use_transform??!1,_=i.catalogVersion??i.catalog_version??null,A=i.environment??null,m=i.placement_type??i.placementType??i.room?.placement_type??null,m=m?String(m).toLowerCase():null,K=i.placement_groups??i.placementGroups??{};const O=Array.isArray(i.optionSets)?i.optionSets:[];V=O.map(Y).filter(C=>C!=null);for(const C of O){if(!C||typeof C!="object")continue;const R=Y(C);if(R==null)continue;const Q=String(R),ee=C.sequence??C.seq??null;ee!=null&&(t[Q]=ee),Array.isArray(C.options)&&(s[Q]=C.options.map(H=>H&&typeof H=="object"?H.id??H.optionId:H).filter(H=>H!=null));const te=C.defaultOption??C.default_option??C.default_option_id;te!=null&&(u[Q]=te)}c=Y(i.defaultPreset??i.default_preset)}catch{}const k={},G=Ie({presets:p,defaultPreset:h,optionSets:V,products:n});for(const[v,i]of Object.entries(G))k[v]=i;let E=null;if(c!=null&&k[c])E=c;else if(h!=null&&k[h])E=h;else{const v=Object.keys(k)[0];v!=null&&(E=v)}const U={};for(const[v,i]of Object.entries(n)){const M=i.optionSets||i.features_configuration_ids||[],z=[],I={};let D=1;for(const O of M){const C=O&&typeof O=="object"&&!Array.isArray(O),R=C?O.optionSetId??O.option_set_id??O.id??O.feature_id:O;if(R==null)continue;const Q=l[R]||l[String(R)];if(!Q)continue;const ee=C?O.defaultOption??O.default_option??O.default_option_id:null,te=C&&O.sequence!=null?O.sequence:D++,H=ee??Q.default_option_id??Q.defaultOption,se=C&&Array.isArray(O.options)?O.options:null;z.push({feature_id:R,sequence:te,default_option_id:H,...se?{options:se}:{}}),H!=null&&(I[R]=H)}U[v]={...i,feature_sets:z,default_selections:I}}const B={};for(const[v,i]of Object.entries(k))B[v]={...i,scene_option_id:i.sceneOptionId||i.scene_option_id};const x=new Map;for(const v of f||[])v?.id!=null&&x.set(v.id,v);for(const v of Object.values(l||{}))for(const i of v?.rules||[])i?.id!=null&&!x.has(i.id)&&x.set(i.id,i);const $=W.getState().options||{};for(const[v,i]of Object.entries($))for(const M of i?.rules||[]){if(M?.id==null)continue;const I={...x.get(M.id)||{},...M},D=Number(v),O=Number.isFinite(D)&&String(D)===String(v)?D:v;I.triggerType==null&&I.trigger_type==null&&(I.triggerType="option_selected"),I.triggerOption==null&&I.trigger_option==null&&(!Array.isArray(I.triggerOptions)||I.triggerOptions.length===0)&&(!Array.isArray(I.trigger_options)||I.trigger_options.length===0)&&(I.triggerOption=O),x.set(M.id,I)}for(const[,v]of Object.entries(n||{}))for(const i of v?.rules||[])i?.id!=null&&!x.has(i.id)&&x.set(i.id,i);const re=[...x.values()];a({rules:re,rulesTriggerIndex:he(re),productConfigurations:U,sceneConfigurations:B,originalSceneConfigurations:B,constraints:y,systemRoom:S,placementStrategy:T,placementStrategyConfig:F,systemEnvironment:A,placementType:m,placementGroups:K,systemOptionSetSequence:t,systemOptionSetOptions:s,systemOptionSetDefault:u,systemId:P,systemName:L,systemConfiguratorKey:q,systemLayoutTemplate:j,systemQuoteTemplate:d,systemTheme:ie()?o().systemTheme:w,systemThemeRecord:ie()?o().systemThemeRecord:N,useTransform:b,catalogVersion:_,defaultPresetId:E,isLoading:!1}),a({rulesReady:!0})}catch(l){throw a({loadError:l.message,isLoading:!1,rulesReady:!1}),Z=null,l}})(),Z)},setActiveChannel:e=>{o().channels[e]&&a({activeChannelId:e})},syncSelectionsToSelectedVariant:()=>{const e=J.getState(),r=e.selectedPieceIndex;if(!r)return;const l=e.hostProductOverrides?.[r]??e.basePiecePositions?.[r]?.productId??null;if(l==null)return;const n=W.getState(),p=n.products||{},h=n.features||{},g=p[l]||p[String(l)];if(!g)return;const P=o().rulesTriggerIndex?.option_selected,f=new Set;for(const c of P?.values?.()||[])for(const _ of c){if((_.effectType??_.effect_type)!=="show_option")continue;const q=_.effectParams??_.effect_params??{},j=q.option_ids??q.optionIds;if(Array.isArray(j))for(const d of j)d!=null&&f.add(String(d));else{const d=_.effectOption??_.effect_option;d!=null&&f.add(String(d))}}const y=n.options||{},S=o().rules||[],T=g.product_graph??g.productGraph??g.parent_graph??g.parentGraph??null,F=T!=null?p[T]||p[String(T)]:null,A={};for(const c of F?.optionSets||[]){const _=c?.optionSetId??c?.option_set_id??c?.id??c?.feature_id;_!=null&&(A[String(_)]=c)}const K=g.optionSets||g.features_configuration_ids||[],V={},t=[];for(const c of K){const _=c?.optionSetId??c?.option_set_id??c?.id??c?.feature_id;if(_==null)continue;const L=h[_]||h[String(_)],q=L?.options||[];if(!q.some(b=>{const m=typeof b=="object"?b?.id:b;return m!=null&&f.has(String(m))}))continue;let d=null,w=null;const N=b=>{if(!b||typeof b!="object")return null;for(const[m,k]of Object.entries(b))if(String(k)===String(l))return m;return null};if(d=N(c?.valueProductOverrides??c?.value_product_overrides),d!=null&&(w="binding.vpo"),d==null){const b=A[String(_)];d=N(b?.valueProductOverrides??b?.value_product_overrides),d!=null&&(w="parentGraph.vpo")}if(d==null)for(const b of q){const m=typeof b=="object"?b?.id:b,k=y[m]||y[String(m)]||(typeof b=="object"?b:null),G=k?.value??k?.optionValue??k?.option_value;if(G!=null&&String(G)===String(l)){d=m,w="option.value";break}}if(d==null){const b=new Set(q.map(m=>String(typeof m=="object"?m?.id:m)));for(const m of S){const k=m.effectType??m.effect_type;if(k!=="load_product"&&k!=="swap_via_group")continue;const G=m.effectVariant??m.effect_variant,E=m.effectProduct??m.effect_product,U=m.effectParams??m.effect_params??{},B=U.variant_id??U.variantId??U.product_id??U.productId,x=G??E??B;if(x==null||String(x)!==String(l))continue;const $=m.triggerOption??m.trigger_option;if($!=null&&b.has(String($))){d=$,w="rule.lookup";break}}}if(d==null){const b=(g?.name||"").toLowerCase();if(b){let m=null,k=0;for(const G of q){const E=typeof G=="object"?G?.id:G,B=((y[E]?.name??y[String(E)]?.name??(typeof G=="object"?G?.name:null))||"").toLowerCase();B&&B.length>k&&b.includes(B)&&(m=E,k=B.length)}m!=null&&(d=m,w="name.match")}}d==null&&(d=c?.defaultOption??c?.default_option??c?.default_option_id??null,d!=null&&(w="binding.defaultOption")),t.push({osId:_,osName:L?.name,identityOpt:d,identitySource:w,bindingVpo:c?.valueProductOverrides??c?.value_product_overrides,parentVpo:A[String(_)]?.valueProductOverrides??A[String(_)]?.value_product_overrides,defaultOption:c?.defaultOption??c?.default_option}),d!=null&&(V[_]=d)}if(Object.keys(V).length===0)return;const s=X.getState().sceneSelections||{};let u=!1;for(const[c,_]of Object.entries(V))if(String(s[c])!==String(_)){u=!0;break}u&&X.setState({sceneSelections:{...s,...V}})},recomputeVisibilityForSelectedPiece:()=>{},getRule:e=>o().rules.find(r=>r.id===e),getProductConfiguration:e=>o().productConfigurations[e],getSceneConfiguration:e=>o().sceneConfigurations[e],getChannel:e=>o().channels[e],getFeaturesConfiguration:e=>o().featuresConfiguration[e],getAllSceneConfigurations:()=>Object.values(o().sceneConfigurations).sort((r,l)=>(r.sequence||0)-(l.sequence||0)),getActiveChannel:()=>o().channels[o().activeChannelId],getRulesForConfiguration:e=>{const r=o().productConfigurations[e];if(!r||!r.rules)return[];const l=o().rules;return r.rules.map(n=>l.find(p=>p.id===n)).filter(Boolean)},getRulesForSceneConfiguration:e=>{const r=o().sceneConfigurations[e];if(!r||!r.scene_rules)return[];const l=o().rules;return r.scene_rules.map(n=>l.find(p=>p.id===n)).filter(Boolean)},getProductConfigForChannel:(e,r=null)=>{const l=r||o().activeChannelId,n=o().productConfigurations[e];return n&&n.channel_id===l?n:Object.values(o().productConfigurations).find(h=>h.id===e&&h.channel_id===l)},getSceneConfigForChannel:(e,r=null)=>{const l=r||o().activeChannelId;return Object.values(o().sceneConfigurations).find(p=>p.scene_id===e&&p.channel_id===l)},getAvailableFeaturesForProduct:e=>{const r=o().getProductConfigForChannel(e),l=o().getActiveChannel();if(!r)return[];let n=[...r.feature_sets||[]];return l?.option_restrictions?.hidden_features&&(n=n.filter(p=>!l.option_restrictions.hidden_features.includes(p))),n},getDefaultSelections:e=>o().productConfigurations[e]?.default_selections||{},getSceneDefaultSelections:e=>o().sceneConfigurations[e]?.default_scene_selections||{},isFeatureAvailableInChannel:(e,r=null)=>{const l=o().channels[r||o().activeChannelId];return l?!l.option_restrictions?.hidden_features?.includes(e):!0},isOptionAvailableInChannel:(e,r=null)=>(o().channels[r||o().activeChannelId],!0),getChannelUIConfig:()=>o().getActiveChannel()?.ui_config||{},getChannelPermissions:()=>o().getActiveChannel()?.permissions||{},getChannelPriceConfig:()=>o().getActiveChannel()?.price_config||{multiplier:1,currency:"USD"},getAvailableChannels:()=>Object.values(o().channels).filter(e=>e.status==="active"),getSceneFeaturesForConfig:e=>{if(!e)return[];const r=ue.get(e);if(r)return r;const l=W.getState().features||{},n=o(),p=Oe(e,n.systemOptionSetSequence||{},l,n.systemOptionSetOptions||{},n.systemOptionSetDefault||{});return ue.set(e,p),p},getSceneFeatures:e=>{const r=o().sceneConfigurations[e];if(!r)return[];let l=o().getSceneFeaturesForConfig(r);return r.overrides?.hidden_scene_features&&(l=l.filter(n=>!r.overrides.hidden_scene_features.includes(n.id))),l.filter(n=>me(n?.id??n?.feature_id))},getSceneProducts:e=>o().sceneConfigurations[e]?.products||[]}),{name:"configuration-graph"}));{const a=()=>ne.getState().recomputeVisibilityForSelectedPiece(),o=()=>ne.getState().syncSelectionsToSelectedVariant();let e=J.getState().selectedPieceIndex,r=J.getState().hostProductOverrides;J.subscribe(n=>{(n.selectedPieceIndex!==e||n.hostProductOverrides!==r)&&(e=n.selectedPieceIndex,r=n.hostProductOverrides,o(),a())});let l=X.getState().sceneSelections;X.subscribe(n=>{n.sceneSelections!==l&&(l=n.sceneSelections,a())})}pe(()=>{const o=J.getState().hiddenOptions;if(!o||o.size===0)return;const e=X.getState(),r=e.sceneSelections||{},l=W.getState().features||{},n=e.setSceneSelection;for(const[p,h]of Object.entries(r)){if(h==null||!o.has(String(h))&&!o.has(h))continue;const f=((l[p]||l[String(p)])?.options||[]).map(y=>typeof y=="object"?y?.id:y).find(y=>y!=null&&!o.has(String(y))&&!o.has(y));if(f!=null&&String(f)!==String(h))try{n(p,f)}catch{}}});function xe(a){return ne.getState().getSceneFeaturesForConfig(a)}var Re=ne;export{Re as default,xe as deriveSceneFeatures};
1
+ import{create as ge}from"zustand";import{devtools as me}from"./52436e0169.js";import se from"./79a397bb92.js";import{isHostThemeApplied as ae}from"./40d6aeb28c.js";import W from"./872c4302e0.js";import X from"./8f60e5059a.js";import Z,{registerSelectionReconciler as ye}from"./d94df858ea.js";import"./9326c23506.js";import{isHostedProduct as ce,isHostFloating as ue}from"./061b81ad81.js";import{setWatermarkFromBackend as _e}from"./d3cd7f1bc1.js";import{isOptionSetVisible as Se}from"./817d930a49.js";const he=["option_selected","option_deselected","variant_selected","variant_deselected","component_loaded","component_removed"];function ve(a){return a?.startsWith?.("option_")?{single:["triggerOption","trigger_option"],many:["triggerOptions","trigger_options"]}:a?.startsWith?.("variant_")?{single:["triggerVariant","trigger_variant"],many:["triggerVariants","trigger_variants"]}:a?.startsWith?.("component_")?{single:["triggerComponent","trigger_component"],many:["triggerComponents","trigger_components"]}:null}function fe(a,r){for(const e of r){const s=a?.[e];if(s!=null)return s}return null}function be(a,r){const e=ve(r);if(!e)return[];const s=fe(a,e.single),l=fe(a,e.many),o=new Set;if(s!=null&&o.add(String(s)),Array.isArray(l))for(const p of l)p!=null&&o.add(String(p));return[...o]}function Ie(a){const r={};for(const e of he)r[e]=new Map;if(!Array.isArray(a))return r;for(const e of a){const s=e.triggerType??e.trigger_type,l=r[s];if(!l)continue;const o=be(e,s);for(const p of o)l.has(p)||l.set(p,[]),l.get(p).push(e)}for(const e of Object.values(r))for(const s of e.values())s.sort((l,o)=>(o.priority||0)-(l.priority||0));return r}let ee=null;function Oe(a,r){const e=r?.[a]??r?.[String(a)]??{},s=e.type??e.kind??null,l=e.wall??e.location??null,o=e.position??e.corner??void 0;return{wall:l,type:s,...o?{position:o}:{}}}function Ce(a,r,e,s,l,o,p){if(!Array.isArray(e)||e.length===0)return{id:a,name:r,sceneOptionId:l??null,scene_option_id:l??null,optionSets:Array.isArray(s)?s:[],products:[],floatingHostedProducts:[]};const h=t=>typeof t!="string"?"":t.replace("_overlay","").replace("overlay_",""),g=[...e].sort((t,i)=>{const u=h(t?.placement_group||t?.placementGroup||""),c=h(i?.placement_group||i?.placementGroup||"");return u!==c?u.localeCompare(c):(t?.sequence??0)-(i?.sequence??0)}),P=t=>{const i=Array.isArray(t?.hostVariants)?t.hostVariants:Array.isArray(t?.host_variants)?t.host_variants:null;if(!Array.isArray(i)||i.length===0)return null;const u=i.find(c=>c?.isDefault??c?.is_default)||i[0];return u?.hostVariantId??u?.host_variant_id??null},f=g.map(t=>{let i=t.variant??t.variantId??t.product??t.productId,u=t.placement_group??t.placementGroup??null,c=null,m=!1,L=!1;const k=i;if(i!=null&&o){const q=o[i]||o[String(i)];if(q&&ce(q))if(ue(q))m=!0;else{const d=P(q);if(d!=null){c=i,i=d;const w=o[d]||o[String(d)],V=w?.placement_group??w?.placementGroup;V!=null&&(u=V)}else c=i,L=!0,typeof u=="string"&&(u=u.replace("_overlay","").replace("overlay_",""))}}return{p:t,productId:i,placementGroup:u,autoLoadHostedProductId:c,dropPlacement:m,overlayHostedProduct:L}}),_=new Map;f.forEach((t,i)=>{if(t.dropPlacement||t.productId==null||t.autoLoadHostedProductId!=null)return;const u=String(t.productId);_.has(u)||_.set(u,i)}),f.forEach(t=>{if(t.dropPlacement||t.autoLoadHostedProductId==null)return;const i=_.get(String(t.productId));i!=null&&(f[i].autoLoadHostedProductId==null&&(f[i].autoLoadHostedProductId=t.autoLoadHostedProductId),t.dropPlacement=!0)});const S=f.map(t=>{if(t.dropPlacement)return null;const i=t.p,u=t.placementGroup,c=i.defaultTransform??i.default_transform??(i.position?{position:i.position,rotation:i.rotation,scale:i.scale}:null),m=Oe(u,p);return{placement_id:i.id??i.placementId,product_id:t.productId,product_graph_id:i.product??i.productId??null,placement_group:u,sequence:i.sequence,default_transform:c,initial_options:i.options??i.initialOptions??i.initial_options??null,...m,...t.autoLoadHostedProductId!=null?{auto_load_appliance_product_id:t.autoLoadHostedProductId}:{},...t.overlayHostedProduct?{overlay_appliance:!0}:{}}}).filter(Boolean),T=t=>typeof t?.sequence=="number"?t.sequence:0;for(const t of["corner","wall_corner"]){const i=S.filter(u=>u.type===t&&(u.position==="back-right"||u.position==="back-left")).sort((u,c)=>T(u)-T(c));i.length>=2&&i.every(u=>u.position===i[0].position)&&(i[0].position="back-left",i[i.length-1].position="back-right")}for(const t of["corner","wall_corner"]){const i=S.filter(u=>u.type===t&&(u.position==="front-right"||u.position==="front-left")).sort((u,c)=>T(u)-T(c));i.length>=2&&i.every(u=>u.position===i[0].position)&&(i[0].position="front-left",i[i.length-1].position="front-right")}const R=t=>typeof t?.sequence=="number"?t.sequence:0,A=(t,i)=>{const u=S.find(c=>c.type===t&&c.position===i);return u!=null?R(u):null},K=[{rowType:"base",cornerType:"corner",backWall:"back"},{rowType:"upper",cornerType:"wall_corner",backWall:"back"}];for(const{rowType:t,cornerType:i,backWall:u}of K){const c=A(i,"back-left"),m=A(i,"back-right"),L=S.filter(d=>d.type===t&&d.wall===u).map(R),k=c!=null&&L.some(d=>d>c),q=m!=null&&L.some(d=>d<m);for(const d of S){if(d.type!==t||d.wall!==u)continue;const w=R(d);if(q&&w>m){d.wall="right";continue}if(k&&w<c){d.wall="left";continue}}}const G=f.filter(t=>{if(!t.dropPlacement)return!1;const i=t.p.variant??t.p.variantId??t.p.product??t.p.productId,u=o?.[i]||o?.[String(i)];return ce(u)&&ue(u)}).map(t=>({placement_id:t.p.id??t.p.placementId,product_id:t.p.variant??t.p.variantId??t.p.product??t.p.productId,sequence:t.p.sequence}));return{id:a,name:r,sceneOptionId:l??null,scene_option_id:l??null,optionSets:s,products:S,floatingHostedProducts:G}}function J(a){return a==null?null:typeof a=="object"?a.id??a.optionSetId??a.option_set_id??a.optionId??a.option_id??null:a}function Pe(a){if(!a)return{};const e=(Array.isArray(a.optionSets)?a.optionSets:[]).map(J).filter(f=>f!=null),s=a.products||null,l=a.placement_groups??a.placementGroups??{},o={},p=(f,_,S,T,R=!1)=>{if(f==null)return;const A=Ce(f,_,S,e,T,s,l);A&&(A.useTransform=!!R,o[A.id]=A)},h=a.presets??a.layouts??null;if(h&&typeof h=="object"){const f=Array.isArray(h)?h.map(_=>[_?.id,_]):Object.entries(h);for(const[_,S]of f){const T=Array.isArray(S?.data)?S.data:Array.isArray(S?.placements)?S.placements:[];p(S?.id??_,S?.name??null,T,S?.sceneOptionId??S?.scene_option_id??S?.optionId??S?.option_id??null,S?.useTransform??S?.use_transform??!1)}if(Object.keys(o).length>0)return o}const g=a.defaultPreset??a.default_preset;if(g&&typeof g=="object"){const f=Array.isArray(g.placements)?g.placements:Array.isArray(g.data)?g.data:[];if(p(g.id??"default_layout",g.name??null,f,null,g.useTransform??g.use_transform??!1),Object.keys(o).length>0)return o}const P=Array.isArray(a.placements)?a.placements:[];if(P.length>0){const f=J(g)??"default_layout";p(f,null,P,null,(g&&(g.useTransform??g.use_transform))??a.useTransform??a.use_transform??!1)}return Object.keys(o).length===0&&p(J(g)??"default_layout",a.name??null,[],null,a.useTransform??a.use_transform??!1),o}function Te(a,r,e,s,l){const o=a?.optionSets||[],p=a?.sceneOptionId||a?.scene_option_id,h=[];return o.forEach((g,P)=>{const f=e[g];if(!f)return;const _=f.type==="layout_change"||f.type==="load_configuration";let S=f.type;_&&(S="layout_change");const T=String(g),R=l&&l[T],A=_?p:R??f.default_option_id??f.defaultOption,K=r[String(g)],G=typeof K=="number"?K:P,t=s&&s[T];h.push({id:g,feature_id:g,...f.presentation?{presentation:f.presentation}:{},...f.flow?{flow:f.flow}:{},sequence:G,name:f.name,type:S,...f.role?{role:f.role}:{},...f.metadata?.role&&!f.role?{role:f.metadata.role}:{},contentKind:f.contentKind||"options",childOptionSetIds:f.childOptionSetIds||[],default_option_id:A,...Array.isArray(t)&&t.length>0?{options:t}:{}})}),h.sort((g,P)=>(g.sequence??0)-(P.sequence??0)),h}const de=new WeakMap,oe=ge(me((a,r)=>({rules:[],rulesTriggerIndex:{option_selected:new Map,option_deselected:new Map,component_loaded:new Map,component_removed:new Map},productConfigurations:{},sceneConfigurations:{},originalSceneConfigurations:{},channels:{},constraints:[],systemRoom:null,placementStrategy:null,placementStrategyConfig:null,placementType:null,systemEnvironment:null,systemRenderMode:"3d",systemRender:null,systemRenders:null,placementGroups:{},systemOptionSetSequence:{},systemOptionSetOptions:{},systemOptionSetDefault:{},systemId:null,systemName:null,systemConfiguratorKey:null,systemLayoutTemplate:null,systemQuoteTemplate:null,systemTheme:null,systemThemeRecord:null,useTransform:!1,catalogVersion:null,defaultPresetId:null,activeChannelId:"channel_internal",isLoading:!1,loadError:null,rulesReady:!1,loadConfigurations:async(e=null)=>{if(ee)return ee;const s=r();return s.sceneConfigurations&&Object.keys(s.sceneConfigurations).length>0?Promise.resolve():(ee=(async()=>{a({isLoading:!0,loadError:null});try{const l=W.getState().features,o=W.getState().products,p=W.getState().presets||{},h=W.getState().defaultPresetId,g=new URLSearchParams(window.location.search);let P=e??g.get("system")??null;if(!P)try{const v=await se.fetchSystems(),n=Array.isArray(v)?v[0]:Object.values(v||{})[0];n?.id!=null&&(P=n.id)}catch{}let f=[],_=[],S=null,T=null,R=null,A=null,K="3d",G=null,t=null,i={},u=[];const c={},m={},L={};let k=null,q=null,d=null,w=null,V=null,b=null,y=null,j=null,F=!1,x=null;if(P)try{const{takePrefetchedSystem:v}=await import("./be0cfe2236.js"),n=v(P)??await se.fetchSystem(P),E=n.uiToggles??n.ui_toggles??null;if(E&&typeof E=="object")try{W.getState().mergeSystemUiToggles(E)}catch{}const z=n.watermarkEnabled??n.watermark_enabled;if(z!=null){try{_e(z)}catch{}try{W.setState({watermarkEnabled:z!==!1})}catch{}}f=n.rules??[],_=n.constraints??[],S=n.room??null,T=n.placementStrategy??n.placement_strategy??n.room?.placement_strategy??null,R=n.placementStrategyConfig??n.placement_strategy_config??n.room?.placement_strategy_config??null,d=n.name??null,w=n.configurator??n.configurator_key??n.configuratorKey??null,V=n.uiTemplate??n.ui_template??n.layoutTemplate??n.layout_template??null,V=V?String(V).trim().toLowerCase():null,b=n.quoteTemplate??n.quote_template??null;const I=n.themeId??n.theme_id??null,D=n.theme??n.themeKey??null;if(I!=null&&(typeof I=="number"||/^\d+$/.test(String(I)))){y=String(I);try{const{takePrefetchedTheme:C}=await import("./be0cfe2236.js"),M=C(I)??await se.fetchTheme(I);M&&(j=M)}catch{}}else y=D?String(D).trim().toLowerCase():null;if(F=n.useTransform??n.use_transform??!1,q=n.catalogVersion??n.catalog_version??null,A=n.environment??null,K=n.render_mode??n.renderMode??"3d",G=n.render??null,t=n.renders??null,K==="rendered")try{W.getState().mergeSystemUiToggles({toggle2d3d:!1,dimensions:!1,walls:!1,resetCamera:!1,...E})}catch{}x=n.placement_type??n.placementType??n.room?.placement_type??null,x=x?String(x).toLowerCase():null,i=n.placement_groups??n.placementGroups??{};const O=Array.isArray(n.optionSets)?n.optionSets:[];u=O.map(J).filter(C=>C!=null);for(const C of O){if(!C||typeof C!="object")continue;const M=J(C);if(M==null)continue;const Y=String(M),te=C.sequence??C.seq??null;te!=null&&(c[Y]=te),Array.isArray(C.options)&&(m[Y]=C.options.map(B=>B&&typeof B=="object"?B.id??B.optionId:B).filter(B=>B!=null));const ne=C.defaultOption??C.default_option??C.default_option_id;ne!=null&&(L[Y]=ne)}k=J(n.defaultPreset??n.default_preset)}catch{}const H={},N=Pe({presets:p,defaultPreset:h,optionSets:u,products:o});for(const[v,n]of Object.entries(N))H[v]=n;let Q=null;if(k!=null&&H[k])Q=k;else if(h!=null&&H[h])Q=h;else{const v=Object.keys(H)[0];v!=null&&(Q=v)}const $={};for(const[v,n]of Object.entries(o)){const E=n.optionSets||n.features_configuration_ids||[],z=[],I={};let D=1;for(const O of E){const C=O&&typeof O=="object"&&!Array.isArray(O),M=C?O.optionSetId??O.option_set_id??O.id??O.feature_id:O;if(M==null)continue;const Y=l[M]||l[String(M)];if(!Y)continue;const te=C?O.defaultOption??O.default_option??O.default_option_id:null,ne=C&&O.sequence!=null?O.sequence:D++,B=te??Y.default_option_id??Y.defaultOption,le=C&&Array.isArray(O.options)?O.options:null;z.push({feature_id:M,sequence:ne,default_option_id:B,...le?{options:le}:{}}),B!=null&&(I[M]=B)}$[v]={...n,feature_sets:z,default_selections:I}}const re={};for(const[v,n]of Object.entries(H))re[v]={...n,scene_option_id:n.sceneOptionId||n.scene_option_id};const U=new Map;for(const v of f||[])v?.id!=null&&U.set(v.id,v);for(const v of Object.values(l||{}))for(const n of v?.rules||[])n?.id!=null&&!U.has(n.id)&&U.set(n.id,n);const pe=W.getState().options||{};for(const[v,n]of Object.entries(pe))for(const E of n?.rules||[]){if(E?.id==null)continue;const I={...U.get(E.id)||{},...E},D=Number(v),O=Number.isFinite(D)&&String(D)===String(v)?D:v;I.triggerType==null&&I.trigger_type==null&&(I.triggerType="option_selected"),I.triggerOption==null&&I.trigger_option==null&&(!Array.isArray(I.triggerOptions)||I.triggerOptions.length===0)&&(!Array.isArray(I.trigger_options)||I.trigger_options.length===0)&&(I.triggerOption=O),U.set(E.id,I)}for(const[,v]of Object.entries(o||{}))for(const n of v?.rules||[])n?.id!=null&&!U.has(n.id)&&U.set(n.id,n);const ie=[...U.values()];a({rules:ie,rulesTriggerIndex:Ie(ie),productConfigurations:$,sceneConfigurations:re,originalSceneConfigurations:re,constraints:_,systemRoom:S,placementStrategy:T,placementStrategyConfig:R,systemEnvironment:A,systemRenderMode:K,systemRender:G,systemRenders:t,placementType:x,placementGroups:i,systemOptionSetSequence:c,systemOptionSetOptions:m,systemOptionSetDefault:L,systemId:P,systemName:d,systemConfiguratorKey:w,systemLayoutTemplate:V,systemQuoteTemplate:b,systemTheme:ae()?r().systemTheme:y,systemThemeRecord:ae()?r().systemThemeRecord:j,useTransform:F,catalogVersion:q,defaultPresetId:Q,isLoading:!1}),a({rulesReady:!0})}catch(l){throw a({loadError:l.message,isLoading:!1,rulesReady:!1}),ee=null,l}})(),ee)},setActiveChannel:e=>{r().channels[e]&&a({activeChannelId:e})},syncSelectionsToSelectedVariant:()=>{const e=X.getState(),s=e.selectedPieceIndex;if(!s)return;const l=e.hostProductOverrides?.[s]??e.basePiecePositions?.[s]?.productId??null;if(l==null)return;const o=W.getState(),p=o.products||{},h=o.features||{},g=p[l]||p[String(l)];if(!g)return;const P=r().rulesTriggerIndex?.option_selected,f=new Set;for(const c of P?.values?.()||[])for(const m of c){if((m.effectType??m.effect_type)!=="show_option")continue;const k=m.effectParams??m.effect_params??{},q=k.option_ids??k.optionIds;if(Array.isArray(q))for(const d of q)d!=null&&f.add(String(d));else{const d=m.effectOption??m.effect_option;d!=null&&f.add(String(d))}}const _=o.options||{},S=r().rules||[],T=g.product_graph??g.productGraph??g.parent_graph??g.parentGraph??null,R=T!=null?p[T]||p[String(T)]:null,A={};for(const c of R?.optionSets||[]){const m=c?.optionSetId??c?.option_set_id??c?.id??c?.feature_id;m!=null&&(A[String(m)]=c)}const K=g.optionSets||g.features_configuration_ids||[],G={},t=[];for(const c of K){const m=c?.optionSetId??c?.option_set_id??c?.id??c?.feature_id;if(m==null)continue;const L=h[m]||h[String(m)],k=L?.options||[];if(!k.some(b=>{const y=typeof b=="object"?b?.id:b;return y!=null&&f.has(String(y))}))continue;let d=null,w=null;const V=b=>{if(!b||typeof b!="object")return null;for(const[y,j]of Object.entries(b))if(String(j)===String(l))return y;return null};if(d=V(c?.valueProductOverrides??c?.value_product_overrides),d!=null&&(w="binding.vpo"),d==null){const b=A[String(m)];d=V(b?.valueProductOverrides??b?.value_product_overrides),d!=null&&(w="parentGraph.vpo")}if(d==null)for(const b of k){const y=typeof b=="object"?b?.id:b,j=_[y]||_[String(y)]||(typeof b=="object"?b:null),F=j?.value??j?.optionValue??j?.option_value;if(F!=null&&String(F)===String(l)){d=y,w="option.value";break}}if(d==null){const b=new Set(k.map(y=>String(typeof y=="object"?y?.id:y)));for(const y of S){const j=y.effectType??y.effect_type;if(j!=="load_product"&&j!=="swap_via_group")continue;const F=y.effectVariant??y.effect_variant,x=y.effectProduct??y.effect_product,H=y.effectParams??y.effect_params??{},N=H.variant_id??H.variantId??H.product_id??H.productId,Q=F??x??N;if(Q==null||String(Q)!==String(l))continue;const $=y.triggerOption??y.trigger_option;if($!=null&&b.has(String($))){d=$,w="rule.lookup";break}}}if(d==null){const b=(g?.name||"").toLowerCase();if(b){let y=null,j=0;for(const F of k){const x=typeof F=="object"?F?.id:F,N=((_[x]?.name??_[String(x)]?.name??(typeof F=="object"?F?.name:null))||"").toLowerCase();N&&N.length>j&&b.includes(N)&&(y=x,j=N.length)}y!=null&&(d=y,w="name.match")}}d==null&&(d=c?.defaultOption??c?.default_option??c?.default_option_id??null,d!=null&&(w="binding.defaultOption")),t.push({osId:m,osName:L?.name,identityOpt:d,identitySource:w,bindingVpo:c?.valueProductOverrides??c?.value_product_overrides,parentVpo:A[String(m)]?.valueProductOverrides??A[String(m)]?.value_product_overrides,defaultOption:c?.defaultOption??c?.default_option}),d!=null&&(G[m]=d)}if(Object.keys(G).length===0)return;const i=Z.getState().sceneSelections||{};let u=!1;for(const[c,m]of Object.entries(G))if(String(i[c])!==String(m)){u=!0;break}u&&Z.setState({sceneSelections:{...i,...G}})},recomputeVisibilityForSelectedPiece:()=>{},getRule:e=>r().rules.find(s=>s.id===e),getProductConfiguration:e=>r().productConfigurations[e],getSceneConfiguration:e=>r().sceneConfigurations[e],getChannel:e=>r().channels[e],getFeaturesConfiguration:e=>r().featuresConfiguration[e],getAllSceneConfigurations:()=>Object.values(r().sceneConfigurations).sort((s,l)=>(s.sequence||0)-(l.sequence||0)),getActiveChannel:()=>r().channels[r().activeChannelId],getRulesForConfiguration:e=>{const s=r().productConfigurations[e];if(!s||!s.rules)return[];const l=r().rules;return s.rules.map(o=>l.find(p=>p.id===o)).filter(Boolean)},getRulesForSceneConfiguration:e=>{const s=r().sceneConfigurations[e];if(!s||!s.scene_rules)return[];const l=r().rules;return s.scene_rules.map(o=>l.find(p=>p.id===o)).filter(Boolean)},getProductConfigForChannel:(e,s=null)=>{const l=s||r().activeChannelId,o=r().productConfigurations[e];return o&&o.channel_id===l?o:Object.values(r().productConfigurations).find(h=>h.id===e&&h.channel_id===l)},getSceneConfigForChannel:(e,s=null)=>{const l=s||r().activeChannelId;return Object.values(r().sceneConfigurations).find(p=>p.scene_id===e&&p.channel_id===l)},getAvailableFeaturesForProduct:e=>{const s=r().getProductConfigForChannel(e),l=r().getActiveChannel();if(!s)return[];let o=[...s.feature_sets||[]];return l?.option_restrictions?.hidden_features&&(o=o.filter(p=>!l.option_restrictions.hidden_features.includes(p))),o},getDefaultSelections:e=>r().productConfigurations[e]?.default_selections||{},getSceneDefaultSelections:e=>r().sceneConfigurations[e]?.default_scene_selections||{},isFeatureAvailableInChannel:(e,s=null)=>{const l=r().channels[s||r().activeChannelId];return l?!l.option_restrictions?.hidden_features?.includes(e):!0},isOptionAvailableInChannel:(e,s=null)=>(r().channels[s||r().activeChannelId],!0),getChannelUIConfig:()=>r().getActiveChannel()?.ui_config||{},getChannelPermissions:()=>r().getActiveChannel()?.permissions||{},getChannelPriceConfig:()=>r().getActiveChannel()?.price_config||{multiplier:1,currency:"USD"},getAvailableChannels:()=>Object.values(r().channels).filter(e=>e.status==="active"),getSceneFeaturesForConfig:e=>{if(!e)return[];const s=de.get(e);if(s)return s;const l=W.getState().features||{},o=r(),p=Te(e,o.systemOptionSetSequence||{},l,o.systemOptionSetOptions||{},o.systemOptionSetDefault||{});return de.set(e,p),p},getSceneFeatures:e=>{const s=r().sceneConfigurations[e];if(!s)return[];let l=r().getSceneFeaturesForConfig(s);return s.overrides?.hidden_scene_features&&(l=l.filter(o=>!s.overrides.hidden_scene_features.includes(o.id))),l.filter(o=>Se(o?.id??o?.feature_id))},getSceneProducts:e=>r().sceneConfigurations[e]?.products||[]}),{name:"configuration-graph"}));queueMicrotask(()=>{const a=()=>oe.getState().recomputeVisibilityForSelectedPiece(),r=()=>oe.getState().syncSelectionsToSelectedVariant();let e=X.getState().selectedPieceIndex,s=X.getState().hostProductOverrides;X.subscribe(o=>{(o.selectedPieceIndex!==e||o.hostProductOverrides!==s)&&(e=o.selectedPieceIndex,s=o.hostProductOverrides,r(),a())});let l=Z.getState().sceneSelections;Z.subscribe(o=>{o.sceneSelections!==l&&(l=o.sceneSelections,a())})}),ye(()=>{const r=X.getState().hiddenOptions;if(!r||r.size===0)return;const e=Z.getState(),s=e.sceneSelections||{},l=W.getState().features||{},o=e.setSceneSelection;for(const[p,h]of Object.entries(s)){if(h==null||!r.has(String(h))&&!r.has(h))continue;const f=((l[p]||l[String(p)])?.options||[]).map(_=>typeof _=="object"?_?.id:_).find(_=>_!=null&&!r.has(String(_))&&!r.has(_));if(f!=null&&String(f)!==String(h))try{o(p,f)}catch{}}});function Ee(a){return oe.getState().getSceneFeaturesForConfig(a)}var Me=oe;export{Me as default,Ee as deriveSceneFeatures};
@@ -1 +1 @@
1
- import{Fragment as T,jsx as e,jsxs as p}from"react/jsx-runtime";import{useState as R,useMemo as Y,useRef as F,useEffect as H,useCallback as Z,memo as I}from"react";import E from"./8f60e5059a.js";import{resolveAssetUrl as tt}from"./cec035efb1.js";import et from"./872c4302e0.js";const at=s=>typeof s=="string"&&(s.startsWith("http")||s.startsWith("/")||s.startsWith("data:"));function A(s,a){const l=!s||typeof s!="string"?null:at(s)?s:`/${s}`;return tt(l,{kind:"thumbnail",...a})}function D(s){const[a,l]=R(!1),[b,h]=R(!1),[c,u]=R(0),f=F(0);H(()=>{l(!1),h(!1),u(0),f.current=0},[s]);const d=()=>{f.current<2?(f.current+=1,u(f.current)):l(!0)},m=()=>h(!0),g=Z(v=>{v&&v.complete&&v.naturalWidth>0&&h(!0)},[s]);return{imgError:a,imgLoaded:b,onError:d,onLoad:m,imgRef:g,imgKey:`${s}#${c}`}}function B(){return e("div",{className:"thumb-skeleton","aria-hidden":"true"})}const ot=I(function({option:a,isSelected:l,onClick:b}){const h=a.value||"l_shaped",c=A(a.thumbnail),{imgError:u,imgLoaded:f,onError:d,onLoad:m,imgRef:g,imgKey:v}=D(c),o=a.disabled;return p("div",{className:`layout-thumbnail ${l?"layout-thumbnail--selected":""} ${o?"layout-thumbnail--disabled":""}`,"data-part":"option-card",onClick:o?void 0:b,title:o?a.disabledReason||"Not available":a.name,"aria-disabled":o||void 0,children:[e("div",{className:"layout-thumbnail__scene",children:c&&!u?p(T,{children:[!f&&e(B,{}),e("img",{ref:g,src:c,alt:a.name,className:"layout-thumbnail__img",loading:"lazy",onLoad:m,onError:d,style:{opacity:f?1:0}},v)]}):p(T,{children:[e("div",{className:"layout-thumbnail__floor"}),e("div",{className:`layout-thumbnail__cabinets layout-thumbnail__cabinets--${h}`})]})}),e("span",{className:"layout-thumbnail__label",children:a.name})]})}),nt=I(function({option:a,material:l,isSelected:b,onClick:h}){const c=E(n=>n.showOptionLabels),u=a.thumbnail??l?.thumbnail??l?.thumbnailUrl??l?.thumbnail_url,f=l?.textures?.diffuse??l?.diffuseMap??l?.diffuse_map??l?.materialJson?.map,d=l?.color??l?.materialJson?.color??a.color??a.color_hex??a.metadata?.color_hex,m=(()=>{if(d==null)return"var(--border-dark, #cccccc)";if(typeof d=="number")return"#"+d.toString(16).padStart(6,"0");if(typeof d=="string"){const n=d.trim();return/^[0-9a-fA-F]{3}$/.test(n)||/^[0-9a-fA-F]{6}$/.test(n)?"#"+n:n}return"var(--border-dark, #cccccc)"})(),g=A(u)||A(f)||null,{imgError:v,imgLoaded:o,onError:r,onLoad:y,imgRef:N,imgKey:k}=D(g),C=`data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><rect width='100' height='100' fill='${m}'/></svg>`)}`,i=a.disabled;return p("div",{className:`finish-thumbnail ${b?"finish-thumbnail--selected":""} ${i?"finish-thumbnail--disabled":""} ${c?"finish-thumbnail--show-labels":""}`,"data-part":"option-card",onClick:i?void 0:h,title:i?a.disabledReason||"Not available":a.name,"aria-disabled":i||void 0,children:[e("div",{className:"finish-thumbnail__preview",children:g&&!v?p(T,{children:[!o&&e(B,{}),e("img",{ref:N,src:g,alt:a.name,className:"finish-thumbnail__img",loading:"lazy",onLoad:y,onError:r,style:{opacity:o?1:0}},k)]}):e("img",{src:C,alt:a.name,className:"finish-thumbnail__img",draggable:!1})}),e("span",{className:"finish-thumbnail__name",children:a.name}),i&&e("div",{className:"finish-thumbnail__unavailable",children:a.disabledReason||"Not available"})]})}),ct=I(function({option:a,isSelected:l,onClick:b}){const h=a.disabled,c=A(a.thumbnail),{imgError:u,imgLoaded:f,onError:d,onLoad:m,imgRef:g,imgKey:v}=D(c),o=E(r=>r.showOptionLabels);return p("div",{className:`option-thumbnail ${l?"option-thumbnail--selected":""} ${h?"option-thumbnail--disabled":""} ${c&&!u?"option-thumbnail--has-img":""} ${o?"option-thumbnail--show-labels":""}`,"data-part":"option-card",onClick:h?void 0:b,title:h?a.disabledReason||"Coming soon":a.description||a.name,children:[c&&!u?p(T,{children:[!f&&e(B,{}),e("img",{ref:g,src:c,alt:a.name,className:"option-thumbnail__img",loading:"lazy",onLoad:m,onError:d,style:{opacity:f?1:0}},v),e("span",{className:"option-thumbnail__img-label",children:a.name})]}):e("div",{className:"option-thumbnail__content",children:e("span",{className:"option-thumbnail__name",children:a.name})}),h&&e("div",{className:"option-thumbnail__coming-soon",children:a.disabledReason||"Coming soon"})]})}),dt=I(function({widthOptions:a,currentWidth:l,defaultWidth:b,onSelect:h}){const c=Y(()=>[...a].sort((i,n)=>(i.value||0)-(n.value||0)),[a]),u=b||c[0]?.value,f=l||u,d=c.findIndex(i=>i.value===f),m=d>=0?d:0,g=F(null),v=F(null),o=F(h);o.current=h;const r=F(null),y=F(!1),N=F(-1);H(()=>()=>{r.current&&cancelAnimationFrame(r.current)},[]),H(()=>{!y.current&&g.current&&(g.current.value=m),k(m)},[m]);const k=i=>{if(!v.current||i===N.current)return;const n=v.current.children;N.current>=0&&N.current<n.length&&n[N.current].classList.remove("width-slider__tick--active"),i>=0&&i<n.length&&n[i].classList.add("width-slider__tick--active"),N.current=i},C=i=>{r.current&&cancelAnimationFrame(r.current),g.current&&(g.current.value=i),k(i);const n=c[i];n&&(r.current=requestAnimationFrame(()=>{r.current=null,o.current(n.value)}))};return e("div",{className:"width-slider",children:p("div",{className:"width-slider__track-wrapper",children:[e("input",{ref:g,type:"range",step:"any",min:0,max:c.length-1,defaultValue:m,onChange:i=>k(Math.round(parseFloat(i.target.value))),onPointerDown:i=>{y.current=!0,i.currentTarget.setPointerCapture(i.pointerId)},onPointerUp:i=>{if(!y.current)return;y.current=!1,i.currentTarget.releasePointerCapture(i.pointerId);const n=parseFloat(g.current?.value||0),$=Math.max(0,Math.min(Math.round(n),c.length-1));C($)},onTouchEnd:()=>{y.current=!1;const i=parseFloat(g.current?.value||0),n=Math.max(0,Math.min(Math.round(i),c.length-1));C(n)},className:"width-slider__input"}),e("div",{className:"width-slider__ticks",ref:v,children:c.map((i,n)=>p("span",{className:`width-slider__tick${n===m?" width-slider__tick--active":""}`,onClick:()=>C(n),children:[i.value,'"']},i.id||n))})]})})},(s,a)=>s.widthOptions===a.widthOptions&&s.currentWidth===a.currentWidth&&s.defaultWidth===a.defaultWidth);function ut({optionSet:s,getOptionsForSet:a,feature:l,getOptionsForFeature:b,getSelection:h,onSelectionChange:c}){l=s??l,b=a??b;const u=b(l),f=et(n=>n.products),d=n=>n!=null&&!!(f?.[n]||f?.[String(n)]),m=u.find(n=>!d(n.value)),g=u.find(n=>d(n.value)),v=h(l.id),o=v&&v!==m?.id,r=E(n=>n.freePieceTier),y=E(n=>n.setFreePieceTier),N=n=>{if(y(n),!o){const $=u.find(S=>S.tier===n)||g;c(l.id,$?.id)}},[k,C]=R({none:!1,standard:!1,large:!1}),i=n=>{C($=>({...$,[n]:!0}))};return p("div",{className:"sidebar__section",children:[e("h3",{className:"sidebar__section-title",children:"ISLAND"}),p("div",{className:"thumbnail-grid thumbnail-grid--3col",children:[p("button",{className:`option-thumbnail option-thumbnail--has-img${o?"":" option-thumbnail--selected"}`,onClick:()=>c(l.id,m?.id),children:[k.none?p("svg",{width:"100%",height:"100%",viewBox:"0 0 60 60",fill:"none",style:{display:"block"},children:[e("rect",{width:"60",height:"60",fill:"#F7F7F7"}),e("rect",{x:"12",y:"20",width:"36",height:"20",rx:"2",stroke:"#C4A882",strokeWidth:"1.5",strokeDasharray:"4 2"}),e("line",{x1:"18",y1:"26",x2:"42",y2:"34",stroke:"#C4A882",strokeWidth:"1.5"}),e("line",{x1:"42",y1:"26",x2:"18",y2:"34",stroke:"#C4A882",strokeWidth:"1.5"})]}):e("img",{src:"/assets/thumbnails/islands/none.svg",alt:"No Island",style:{width:"100%",height:"100%",display:"block",objectFit:"cover"},loading:"lazy",onError:()=>i("none")}),e("span",{className:"option-thumbnail__img-label",children:"No Island"})]}),p("button",{className:`option-thumbnail option-thumbnail--has-img${o&&r==="single"?" option-thumbnail--selected":""}`,onClick:()=>N("single"),children:[k.standard?p("svg",{width:"100%",height:"100%",viewBox:"0 0 60 60",fill:"none",style:{display:"block"},children:[e("rect",{width:"60",height:"60",fill:"#F7F7F7"}),e("rect",{x:"10",y:"12",width:"40",height:"36",rx:"2",fill:"#E8DED0",stroke:"#C4A882",strokeWidth:"1"}),e("line",{x1:"10",y1:"29",x2:"50",y2:"29",stroke:"#C4A882",strokeWidth:"0.5",strokeDasharray:"3 2"})]}):e("img",{src:"/assets/thumbnails/islands/standard.svg",alt:"Standard Island",style:{width:"100%",height:"100%",display:"block",objectFit:"cover"},loading:"lazy",onError:()=>i("standard")}),e("span",{className:"option-thumbnail__img-label",children:"Single"})]}),p("button",{className:`option-thumbnail option-thumbnail--has-img${o&&r==="double"?" option-thumbnail--selected":""}`,onClick:()=>N("double"),children:[k.large?p("svg",{width:"100%",height:"100%",viewBox:"0 0 60 60",fill:"none",style:{display:"block"},children:[e("rect",{width:"60",height:"60",fill:"#F7F7F7"}),e("rect",{x:"14",y:"8",width:"32",height:"18",rx:"2",fill:"#E8DED0",stroke:"#C4A882",strokeWidth:"1"}),e("rect",{x:"8",y:"34",width:"44",height:"18",rx:"2",fill:"#E8DED0",stroke:"#C4A882",strokeWidth:"1"})]}):e("img",{src:"/assets/thumbnails/islands/large.svg",alt:"Large Island",style:{width:"100%",height:"100%",display:"block",objectFit:"cover"},loading:"lazy",onError:()=>i("large")}),e("span",{className:"option-thumbnail__img-label",children:"Double"})]})]})]})}function ht({option:s,isSelected:a,onClick:l,disabled:b}){const h=s.value?.height,c=s.value?.width;let u;return h&&c?u=`${c}W x ${h}H`:h&&!c?u=`${h}H`:u=s.name,e("button",{className:`frame-size-btn ${a?"frame-size-btn--selected":""}`,onClick:l,disabled:b,title:s.description||s.name,style:b?{opacity:.4,cursor:"not-allowed"}:void 0,children:u})}function mt({option:s,isSelected:a,onClick:l}){const b=s.color_hex||s.metadata?.color_hex||"var(--border-dark, #cccccc)";return p("div",{className:`color-swatch ${a?"color-swatch--selected":""}`,onClick:l,title:s.name,children:[e("div",{className:"color-swatch__color",style:{backgroundColor:b}}),e("span",{className:"color-swatch__name",children:s.name})]})}const bt=I(function({hostedProduct:a,onClick:l,isSelected:b,isPlaced:h,canReplace:c,isDisabled:u,selectedPieceType:f}){const{name:d,icon:m,thumbnail:g}=a,v=a.hasNoSlots,o=a.hasNoCompatiblePieceInLayout,r=A(g),{imgError:y,onError:N,imgKey:k}=D(r),C=()=>{let n="hosted-product-thumbnail";return u?n+=" hosted-product-thumbnail--disabled":h?n+=" hosted-product-thumbnail--placed":b&&(n+=" hosted-product-thumbnail--selected"),r&&!y&&(n+=" hosted-product-thumbnail--has-img"),n},i=()=>v&&a.placement_type!=="replace_full"?`${d} - coming soon`:o?`No compatible piece for ${d} in the current layout`:u?`${d} is not compatible with this piece type`:h?`Click to remove ${d}`:b?`Click to cancel ${d} placement`:c?`Click to replace ${f} with ${d}`:`Click to place ${d}`;return p("div",{className:C(),onClick:u?null:l,title:i(),style:u?{cursor:"not-allowed"}:{},children:[r&&!y?e("img",{src:r,alt:d,className:"hosted-product-thumbnail__img",loading:"lazy",onError:N},k):m?e("div",{className:"hosted-product-thumbnail__icon",children:e(m,{})}):e("div",{className:"hosted-product-thumbnail__icon hosted-product-thumbnail__icon--placeholder","aria-hidden":"true"}),e("span",{className:"hosted-product-thumbnail__label",children:d}),h&&p("span",{className:"hosted-product-thumbnail__badge",children:[e("span",{className:"hosted-product-badge-placed",children:"Placed"}),e("span",{className:"hosted-product-badge-remove",children:"Remove"})]}),u&&e("span",{className:"hosted-product-thumbnail__badge hosted-product-thumbnail__badge--disabled",children:v?"Coming Soon":o?"Not in Layout":"Not Compatible"})]})}),gt=I(function({productFeatureSets:a,features:l,options:b,materials:h,currentSelections:c,hiddenOptions:u,managedOptionSets:f,featureToOptionsMap:d,disabledOptions:m,onSelect:g}){if(!Array.isArray(a)||a.length===0)return null;const v=[...a].sort((o,r)=>(o.sequence||0)-(r.sequence||0));return e(T,{children:v.map(o=>{const r=o.feature_id,y=l?.[r]||l?.[String(r)];if(!y)return null;const N=f&&(f.has(String(r))||f.has(r)),k=d&&(d[String(r)]||d[r]),C=N&&Array.isArray(k)&&k.length>0?k:(y.options||[]).map(t=>typeof t=="object"?t.id:t);let i;if(N?i=C:o.options&&o.options.length>0?i=o.options:C.length>0?i=C:o.default_option_id!=null?i=[o.default_option_id]:i=[],!i||i.length===0)return null;const n=t=>u&&(u.has(String(t))||u.has(t)),$=i.filter(t=>!n(t));let S;if($.length>0?S=$:o.options&&o.options.length>0?S=o.options:o.default_option_id!=null?S=[o.default_option_id]:S=N?[]:i,S.length===0)return null;const L=S.map(t=>b?.[t]||b?.[String(t)]).filter(Boolean);if(L.length===0)return null;const K=c?.[r]??c?.[String(r)],O=t=>typeof t=="string"&&(t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/")||t.startsWith("data:")),j=h||{},W=t=>{if(!t)return null;const _=t.value;return _==null?null:j[_]||j[String(_)]||null},J=t=>{const _=W(t),w=t?.thumbnail??t?.thumbnailUrl??t?.thumbnail_url??_?.thumbnail??_?.thumbnailUrl??_?.thumbnail_url;return O(w)?w:null},q=t=>{const _=W(t);if(!_)return null;const w=_?.textures?.diffuse??_?.diffuseMap??_?.diffuse_map??_?.materialJson?.map;return O(w)?w:null},V=t=>{const _=W(t),w=_?.color??_?.materialJson?.color??t?.color??t?.color_hex??t?.metadata?.color_hex;if(w==null)return null;if(typeof w=="number")return"#"+w.toString(16).padStart(6,"0");if(typeof w=="string"){const x=w.trim();return/^[0-9a-fA-F]{3}$/.test(x)||/^[0-9a-fA-F]{6}$/.test(x)?"#"+x:x}return null},M=L.some(t=>!!J(t)||!!q(t)||!!V(t)),G=L.length>0&&L.some(t=>!!W(t)),Q=/finish/i.test(String(y?.type||""));return G||Q?p("div",{className:"sidebar__section",children:[e("h3",{className:"sidebar__section-title",children:y.name||String(r)}),e("div",{className:"thumbnail-grid thumbnail-grid--finish",children:L.map(t=>{const _=m&&(m.has(String(t.id))||m.has(t.id));return e(nt,{option:t,material:W(t),isSelected:String(t.id)===String(K),onClick:_?void 0:()=>g(r,t.id,t)},t.id)})})]},r):p("div",{className:"sidebar__section",children:[e("h3",{className:"sidebar__section-title",children:y.name||String(r)}),e("div",{className:`thumbnail-grid ${M?"thumbnail-grid--options":"thumbnail-grid--handle"}`,children:L.map(t=>{const _=J(t),w=_?null:q(t),x=!_&&!w?V(t):null,P=t.name||t.displayName||t.label||t.value||String(t.id),X=String(t.id)===String(K),z=m&&(m.has(String(t.id))||m.has(t.id)),U=_||w;return p("button",{type:"button",disabled:z,className:`option-thumbnail${X?" option-thumbnail--selected":""}${z?" option-thumbnail--disabled":""}`,onClick:z?void 0:()=>g(r,t.id,t),title:P,children:[U?e("img",{src:U,alt:P,className:"option-thumbnail__img",loading:"lazy"}):x?e("span",{className:"option-thumbnail__swatch",style:{backgroundColor:x,display:"block",width:"100%",height:"100%",borderRadius:4},"aria-hidden":"true"}):M?e("span",{className:"option-thumbnail__swatch",style:{backgroundColor:"var(--border-dark, #cccccc)",display:"block",width:"100%",height:"100%",borderRadius:4},"aria-hidden":"true"}):null,e("span",{className:U||x||M?"option-thumbnail__img-label":"option-thumbnail__name",children:P})]},t.id)})})]},r)})})});export{ut as AddProductToggle,mt as ColorSwatch,nt as FinishThumbnail,ht as FrameSizeButton,bt as HostedProductThumbnail,ot as LayoutThumbnail,ct as OptionThumbnail,gt as ProductFeaturePickers,dt as WidthSlider};
1
+ import{Fragment as A,jsx as e,jsxs as p}from"react/jsx-runtime";import{useState as R,useMemo as Y,useRef as F,useEffect as O,useCallback as Z,memo as T}from"react";import E from"./8f60e5059a.js";import{resolveAssetUrl as tt}from"./cec035efb1.js";import et from"./872c4302e0.js";const at=s=>typeof s=="string"&&(s.startsWith("http")||s.startsWith("/")||s.startsWith("data:"));function I(s,a){const l=!s||typeof s!="string"?null:at(s)?s:`/${s}`;return tt(l,{kind:"thumbnail",...a})}function D(s){const[a,l]=R(!1),[b,h]=R(!1),[c,u]=R(0),f=F(0);O(()=>{l(!1),h(!1),u(0),f.current=0},[s]);const d=()=>{f.current<2?(f.current+=1,u(f.current)):l(!0)},m=()=>h(!0),g=Z(v=>{v&&v.complete&&v.naturalWidth>0&&h(!0)},[s]);return{imgError:a,imgLoaded:b,onError:d,onLoad:m,imgRef:g,imgKey:`${s}#${c}`}}function H(){return e("div",{className:"thumb-skeleton","aria-hidden":"true"})}const ot=T(function({option:a,isSelected:l,onClick:b}){const h=a.value||"l_shaped",c=I(a.thumbnail),{imgError:u,imgLoaded:f,onError:d,onLoad:m,imgRef:g,imgKey:v}=D(c),o=a.disabled;return p("div",{className:`layout-thumbnail ${l?"layout-thumbnail--selected":""} ${o?"layout-thumbnail--disabled":""}`,"data-part":"option-card",onClick:o?void 0:b,title:o?a.disabledReason||"Not available":void 0,"aria-disabled":o||void 0,children:[e("div",{className:"layout-thumbnail__scene",children:c&&!u?p(A,{children:[!f&&e(H,{}),e("img",{ref:g,src:c,alt:a.name,className:"layout-thumbnail__img",loading:"lazy",onLoad:m,onError:d,style:{opacity:f?1:0}},v)]}):p(A,{children:[e("div",{className:"layout-thumbnail__floor"}),e("div",{className:`layout-thumbnail__cabinets layout-thumbnail__cabinets--${h}`})]})}),e("span",{className:"layout-thumbnail__label",children:a.name})]})}),it=T(function({option:a,material:l,isSelected:b,onClick:h}){const c=E(i=>i.showOptionLabels),u=a.thumbnail??l?.thumbnail??l?.thumbnailUrl??l?.thumbnail_url,f=l?.textures?.diffuse??l?.diffuseMap??l?.diffuse_map??l?.materialJson?.map,d=l?.color??l?.materialJson?.color??a.color??a.color_hex??a.metadata?.color_hex,m=(()=>{if(d==null)return"var(--border-dark, #cccccc)";if(typeof d=="number")return"#"+d.toString(16).padStart(6,"0");if(typeof d=="string"){const i=d.trim();return/^[0-9a-fA-F]{3}$/.test(i)||/^[0-9a-fA-F]{6}$/.test(i)?"#"+i:i}return"var(--border-dark, #cccccc)"})(),g=I(u)||I(f)||null,{imgError:v,imgLoaded:o,onError:r,onLoad:y,imgRef:N,imgKey:k}=D(g),C=`data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><rect width='100' height='100' fill='${m}'/></svg>`)}`,n=a.disabled;return p("div",{className:`finish-thumbnail ${b?"finish-thumbnail--selected":""} ${n?"finish-thumbnail--disabled":""} ${c?"finish-thumbnail--show-labels":""}`,"data-part":"option-card",onClick:n?void 0:h,title:n?a.disabledReason||"Not available":void 0,"aria-disabled":n||void 0,children:[e("div",{className:"finish-thumbnail__preview",children:g&&!v?p(A,{children:[!o&&e(H,{}),e("img",{ref:N,src:g,alt:a.name,className:"finish-thumbnail__img",loading:"lazy",onLoad:y,onError:r,style:{opacity:o?1:0}},k)]}):e("img",{src:C,alt:a.name,className:"finish-thumbnail__img",draggable:!1})}),e("span",{className:"finish-thumbnail__name",children:a.name}),n&&e("div",{className:"finish-thumbnail__unavailable",children:a.disabledReason||"Not available"})]})}),ct=T(function({option:a,isSelected:l,onClick:b}){const h=a.disabled,c=I(a.thumbnail),{imgError:u,imgLoaded:f,onError:d,onLoad:m,imgRef:g,imgKey:v}=D(c),o=E(r=>r.showOptionLabels);return p("div",{className:`option-thumbnail ${l?"option-thumbnail--selected":""} ${h?"option-thumbnail--disabled":""} ${c&&!u?"option-thumbnail--has-img":""} ${o?"option-thumbnail--show-labels":""}`,"data-part":"option-card",onClick:h?void 0:b,title:h?a.disabledReason||"Coming soon":a.description||a.name,children:[c&&!u?p(A,{children:[!f&&e(H,{}),e("img",{ref:g,src:c,alt:a.name,className:"option-thumbnail__img",loading:"lazy",onLoad:m,onError:d,style:{opacity:f?1:0}},v),e("span",{className:"option-thumbnail__img-label",children:a.name})]}):e("div",{className:"option-thumbnail__content",children:e("span",{className:"option-thumbnail__name",children:a.name})}),h&&e("div",{className:"option-thumbnail__coming-soon",children:a.disabledReason||"Coming soon"})]})}),dt=T(function({widthOptions:a,currentWidth:l,defaultWidth:b,onSelect:h}){const c=Y(()=>[...a].sort((n,i)=>(n.value||0)-(i.value||0)),[a]),u=b||c[0]?.value,f=l||u,d=c.findIndex(n=>n.value===f),m=d>=0?d:0,g=F(null),v=F(null),o=F(h);o.current=h;const r=F(null),y=F(!1),N=F(-1);O(()=>()=>{r.current&&cancelAnimationFrame(r.current)},[]),O(()=>{!y.current&&g.current&&(g.current.value=m),k(m)},[m]);const k=n=>{if(!v.current||n===N.current)return;const i=v.current.children;N.current>=0&&N.current<i.length&&i[N.current].classList.remove("width-slider__tick--active"),n>=0&&n<i.length&&i[n].classList.add("width-slider__tick--active"),N.current=n},C=n=>{r.current&&cancelAnimationFrame(r.current),g.current&&(g.current.value=n),k(n);const i=c[n];i&&(r.current=requestAnimationFrame(()=>{r.current=null,o.current(i.value)}))};return e("div",{className:"width-slider",children:p("div",{className:"width-slider__track-wrapper",children:[e("input",{ref:g,type:"range",step:"any",min:0,max:c.length-1,defaultValue:m,onChange:n=>k(Math.round(parseFloat(n.target.value))),onPointerDown:n=>{y.current=!0,n.currentTarget.setPointerCapture(n.pointerId)},onPointerUp:n=>{if(!y.current)return;y.current=!1,n.currentTarget.releasePointerCapture(n.pointerId);const i=parseFloat(g.current?.value||0),S=Math.max(0,Math.min(Math.round(i),c.length-1));C(S)},onTouchEnd:()=>{y.current=!1;const n=parseFloat(g.current?.value||0),i=Math.max(0,Math.min(Math.round(n),c.length-1));C(i)},className:"width-slider__input"}),e("div",{className:"width-slider__ticks",ref:v,children:c.map((n,i)=>p("span",{className:`width-slider__tick${i===m?" width-slider__tick--active":""}`,onClick:()=>C(i),children:[n.value,'"']},n.id||i))})]})})},(s,a)=>s.widthOptions===a.widthOptions&&s.currentWidth===a.currentWidth&&s.defaultWidth===a.defaultWidth);function ut({optionSet:s,getOptionsForSet:a,feature:l,getOptionsForFeature:b,getSelection:h,onSelectionChange:c}){l=s??l,b=a??b;const u=b(l),f=et(i=>i.products),d=i=>i!=null&&!!(f?.[i]||f?.[String(i)]),m=u.find(i=>!d(i.value)),g=u.find(i=>d(i.value)),v=h(l.id),o=v&&v!==m?.id,r=E(i=>i.freePieceTier),y=E(i=>i.setFreePieceTier),N=i=>{if(y(i),!o){const S=u.find($=>$.tier===i)||g;c(l.id,S?.id)}},[k,C]=R({none:!1,standard:!1,large:!1}),n=i=>{C(S=>({...S,[i]:!0}))};return p("div",{className:"sidebar__section",children:[e("h3",{className:"sidebar__section-title",children:"ISLAND"}),p("div",{className:"thumbnail-grid thumbnail-grid--3col",children:[p("button",{className:`option-thumbnail option-thumbnail--has-img${o?"":" option-thumbnail--selected"}`,onClick:()=>c(l.id,m?.id),children:[k.none?p("svg",{width:"100%",height:"100%",viewBox:"0 0 60 60",fill:"none",style:{display:"block"},children:[e("rect",{width:"60",height:"60",fill:"#F7F7F7"}),e("rect",{x:"12",y:"20",width:"36",height:"20",rx:"2",stroke:"#C4A882",strokeWidth:"1.5",strokeDasharray:"4 2"}),e("line",{x1:"18",y1:"26",x2:"42",y2:"34",stroke:"#C4A882",strokeWidth:"1.5"}),e("line",{x1:"42",y1:"26",x2:"18",y2:"34",stroke:"#C4A882",strokeWidth:"1.5"})]}):e("img",{src:"/assets/thumbnails/islands/none.svg",alt:"No Island",style:{width:"100%",height:"100%",display:"block",objectFit:"cover"},loading:"lazy",onError:()=>n("none")}),e("span",{className:"option-thumbnail__img-label",children:"No Island"})]}),p("button",{className:`option-thumbnail option-thumbnail--has-img${o&&r==="single"?" option-thumbnail--selected":""}`,onClick:()=>N("single"),children:[k.standard?p("svg",{width:"100%",height:"100%",viewBox:"0 0 60 60",fill:"none",style:{display:"block"},children:[e("rect",{width:"60",height:"60",fill:"#F7F7F7"}),e("rect",{x:"10",y:"12",width:"40",height:"36",rx:"2",fill:"#E8DED0",stroke:"#C4A882",strokeWidth:"1"}),e("line",{x1:"10",y1:"29",x2:"50",y2:"29",stroke:"#C4A882",strokeWidth:"0.5",strokeDasharray:"3 2"})]}):e("img",{src:"/assets/thumbnails/islands/standard.svg",alt:"Standard Island",style:{width:"100%",height:"100%",display:"block",objectFit:"cover"},loading:"lazy",onError:()=>n("standard")}),e("span",{className:"option-thumbnail__img-label",children:"Single"})]}),p("button",{className:`option-thumbnail option-thumbnail--has-img${o&&r==="double"?" option-thumbnail--selected":""}`,onClick:()=>N("double"),children:[k.large?p("svg",{width:"100%",height:"100%",viewBox:"0 0 60 60",fill:"none",style:{display:"block"},children:[e("rect",{width:"60",height:"60",fill:"#F7F7F7"}),e("rect",{x:"14",y:"8",width:"32",height:"18",rx:"2",fill:"#E8DED0",stroke:"#C4A882",strokeWidth:"1"}),e("rect",{x:"8",y:"34",width:"44",height:"18",rx:"2",fill:"#E8DED0",stroke:"#C4A882",strokeWidth:"1"})]}):e("img",{src:"/assets/thumbnails/islands/large.svg",alt:"Large Island",style:{width:"100%",height:"100%",display:"block",objectFit:"cover"},loading:"lazy",onError:()=>n("large")}),e("span",{className:"option-thumbnail__img-label",children:"Double"})]})]})]})}function ht({option:s,isSelected:a,onClick:l,disabled:b}){const h=s.value?.height,c=s.value?.width;let u;return h&&c?u=`${c}W x ${h}H`:h&&!c?u=`${h}H`:u=s.name,e("button",{className:`frame-size-btn ${a?"frame-size-btn--selected":""}`,onClick:l,disabled:b,title:s.description||s.name,style:b?{opacity:.4,cursor:"not-allowed"}:void 0,children:u})}function mt({option:s,isSelected:a,onClick:l}){const b=s.color_hex||s.metadata?.color_hex||"var(--border-dark, #cccccc)";return p("div",{className:`color-swatch ${a?"color-swatch--selected":""}`,onClick:l,title:s.name,children:[e("div",{className:"color-swatch__color",style:{backgroundColor:b}}),e("span",{className:"color-swatch__name",children:s.name})]})}const bt=T(function({hostedProduct:a,onClick:l,isSelected:b,isPlaced:h,canReplace:c,isDisabled:u,selectedPieceType:f}){const{name:d,icon:m,thumbnail:g}=a,v=a.hasNoSlots,o=a.hasNoCompatiblePieceInLayout,r=I(g),{imgError:y,onError:N,imgKey:k}=D(r),C=()=>{let i="hosted-product-thumbnail";return u?i+=" hosted-product-thumbnail--disabled":h?i+=" hosted-product-thumbnail--placed":b&&(i+=" hosted-product-thumbnail--selected"),r&&!y&&(i+=" hosted-product-thumbnail--has-img"),i},n=()=>v&&a.placement_type!=="replace_full"?`${d} - coming soon`:o?`No compatible piece for ${d} in the current layout`:u?`${d} is not compatible with this piece type`:h?`Click to remove ${d}`:b?`Click to cancel ${d} placement`:c?`Click to replace ${f} with ${d}`:`Click to place ${d}`;return p("div",{className:C(),onClick:u?null:l,title:n(),style:u?{cursor:"not-allowed"}:{},children:[r&&!y?e("img",{src:r,alt:d,className:"hosted-product-thumbnail__img",loading:"lazy",onError:N},k):m?e("div",{className:"hosted-product-thumbnail__icon",children:e(m,{})}):e("div",{className:"hosted-product-thumbnail__icon hosted-product-thumbnail__icon--placeholder","aria-hidden":"true"}),e("span",{className:"hosted-product-thumbnail__label",children:d}),h&&p("span",{className:"hosted-product-thumbnail__badge",children:[e("span",{className:"hosted-product-badge-placed",children:"Placed"}),e("span",{className:"hosted-product-badge-remove",children:"Remove"})]}),u&&e("span",{className:"hosted-product-thumbnail__badge hosted-product-thumbnail__badge--disabled",children:v?"Coming Soon":o?"Not in Layout":"Not Compatible"})]})}),gt=T(function({productFeatureSets:a,features:l,options:b,materials:h,currentSelections:c,hiddenOptions:u,managedOptionSets:f,featureToOptionsMap:d,disabledOptions:m,onSelect:g}){if(!Array.isArray(a)||a.length===0)return null;const v=[...a].sort((o,r)=>(o.sequence||0)-(r.sequence||0));return e(A,{children:v.map(o=>{const r=o.feature_id,y=l?.[r]||l?.[String(r)];if(!y)return null;const N=f&&(f.has(String(r))||f.has(r)),k=d&&(d[String(r)]||d[r]),C=N&&Array.isArray(k)&&k.length>0?k:(y.options||[]).map(t=>typeof t=="object"?t.id:t);let n;if(N?n=C:o.options&&o.options.length>0?n=o.options:C.length>0?n=C:o.default_option_id!=null?n=[o.default_option_id]:n=[],!n||n.length===0)return null;const i=t=>u&&(u.has(String(t))||u.has(t)),S=n.filter(t=>!i(t));let $;if(S.length>0?$=S:o.options&&o.options.length>0?$=o.options:o.default_option_id!=null?$=[o.default_option_id]:$=N?[]:n,$.length===0)return null;const L=$.map(t=>b?.[t]||b?.[String(t)]).filter(Boolean);if(L.length===0)return null;const B=c?.[r]??c?.[String(r)],K=t=>typeof t=="string"&&(t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/")||t.startsWith("data:")),j=h||{},W=t=>{if(!t)return null;const _=t.value;return _==null?null:j[_]||j[String(_)]||null},J=t=>{const _=W(t),w=t?.thumbnail??t?.thumbnailUrl??t?.thumbnail_url??_?.thumbnail??_?.thumbnailUrl??_?.thumbnail_url;return K(w)?w:null},q=t=>{const _=W(t);if(!_)return null;const w=_?.textures?.diffuse??_?.diffuseMap??_?.diffuse_map??_?.materialJson?.map;return K(w)?w:null},V=t=>{const _=W(t),w=_?.color??_?.materialJson?.color??t?.color??t?.color_hex??t?.metadata?.color_hex;if(w==null)return null;if(typeof w=="number")return"#"+w.toString(16).padStart(6,"0");if(typeof w=="string"){const x=w.trim();return/^[0-9a-fA-F]{3}$/.test(x)||/^[0-9a-fA-F]{6}$/.test(x)?"#"+x:x}return null},M=L.some(t=>!!J(t)||!!q(t)||!!V(t)),G=L.length>0&&L.some(t=>!!W(t)),Q=/finish/i.test(String(y?.type||""));return G||Q?p("div",{className:"sidebar__section",children:[e("h3",{className:"sidebar__section-title",children:y.name||String(r)}),e("div",{className:"thumbnail-grid thumbnail-grid--finish",children:L.map(t=>{const _=m&&(m.has(String(t.id))||m.has(t.id));return e(it,{option:t,material:W(t),isSelected:String(t.id)===String(B),onClick:_?void 0:()=>g(r,t.id,t)},t.id)})})]},r):p("div",{className:"sidebar__section",children:[e("h3",{className:"sidebar__section-title",children:y.name||String(r)}),e("div",{className:`thumbnail-grid ${M?"thumbnail-grid--options":"thumbnail-grid--handle"}`,children:L.map(t=>{const _=J(t),w=_?null:q(t),x=!_&&!w?V(t):null,P=t.name||t.displayName||t.label||t.value||String(t.id),X=String(t.id)===String(B),z=m&&(m.has(String(t.id))||m.has(t.id)),U=_||w;return p("button",{type:"button",disabled:z,className:`option-thumbnail${X?" option-thumbnail--selected":""}${z?" option-thumbnail--disabled":""}`,onClick:z?void 0:()=>g(r,t.id,t),title:P,children:[U?e("img",{src:U,alt:P,className:"option-thumbnail__img",loading:"lazy"}):x?e("span",{className:"option-thumbnail__swatch",style:{backgroundColor:x,display:"block",width:"100%",height:"100%",borderRadius:4},"aria-hidden":"true"}):M?e("span",{className:"option-thumbnail__swatch",style:{backgroundColor:"var(--border-dark, #cccccc)",display:"block",width:"100%",height:"100%",borderRadius:4},"aria-hidden":"true"}):null,e("span",{className:U||x||M?"option-thumbnail__img-label":"option-thumbnail__name",children:P})]},t.id)})})]},r)})})});export{ut as AddProductToggle,mt as ColorSwatch,it as FinishThumbnail,ht as FrameSizeButton,bt as HostedProductThumbnail,ot as LayoutThumbnail,ct as OptionThumbnail,gt as ProductFeaturePickers,dt as WidthSlider};
@@ -0,0 +1 @@
1
+ import{Fragment as O,jsx as n,jsxs as g}from"react/jsx-runtime";import{useCallback as I,useEffect as k,useMemo as A,useRef as E,useState as C}from"react";import{Box as te,ChevronLeft as ne,ChevronRight as ae,Copy as se,Download as re,ExternalLink as oe}from"lucide-react";import{QRCodeSVG as ie}from"qrcode.react";import le from"./d94df858ea.js";import ue from"./9c6c598569.js";import K from"./be337ddda5.js";import W from"./8f60e5059a.js";import{generateArForCurrentScene as de}from"./d30f1f506e.js";import{ARIcon as B}from"./c5e990946e.js";import{fetchFinalRenders as J}from"./fbd844f2d1.js";import{useZoom as ce}from"./5183c26339.js";import"./2d1e844d0e.css";const fe=4e3,N="ar",v="3d",me=380;function pe(o,d){if(!o||o.kind==="snap"||o.kind==="upload")return!0;const a=o.rendered||{};for(const[l,r]of Object.entries(d||{})){if(r==null)continue;const f=a[String(l)];if(Array.isArray(f)&&!f.map(Number).includes(Number(r)))return!1}return!0}function ge(o){const d=Object.entries(o||{}).filter(([,a])=>a!=null).map(([a,l])=>[String(a),Number(l)]);return d.sort(([a],[l])=>a<l?-1:a>l?1:0),JSON.stringify(Object.fromEntries(d))}async function he(o,d){try{const l=await(await fetch(o)).blob(),r=URL.createObjectURL(l),f=document.createElement("a");f.href=r,f.download=d,document.body.appendChild(f),f.click(),f.remove(),setTimeout(()=>URL.revokeObjectURL(r),3e4)}catch{window.open(o,"_blank","noopener")}}const ve=o=>String(o||"view").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"view";function be({selections:o,cache:d}){const[a,l]=C(()=>d.current.get(o)?{status:"ready",url:d.current.get(o),progress:100}:{status:"idle",url:null,progress:0}),[r,f]=C(!1),i=I(async()=>{l({status:"working",url:null,progress:0});const u=await de({onProgress:P=>l(D=>({...D,progress:Math.round(P)}))});u?(d.current.set(o,u),l({status:"ready",url:u,progress:100})):l({status:"error",url:null,progress:0})},[o,d]);k(()=>{const u=d.current.get(o);u?l({status:"ready",url:u,progress:100}):i()},[o,d,i]);const m=async()=>{try{await navigator.clipboard.writeText(a.url),f(!0),setTimeout(()=>f(!1),2e3)}catch{}};return g("div",{className:"studio-final-stage__ar",children:[a.status==="ready"&&g(O,{children:[n("div",{className:"studio-final-stage__qr","data-part":"final-ar-qr",children:n(ie,{value:a.url,size:220,level:"M"})}),n("p",{className:"studio-muted",children:"Scan with a phone to place this configuration in a room."}),g("div",{className:"studio-final-stage__actions",children:[g("a",{className:"studio-btn",href:a.url,target:"_blank",rel:"noreferrer",children:[n(oe,{size:14,"aria-hidden":"true"})," Open"]}),g("button",{type:"button",className:"studio-btn",onClick:m,children:[n(se,{size:14,"aria-hidden":"true"})," ",r?"Copied":"Copy link"]}),n("button",{type:"button",className:"studio-btn",onClick:i,children:"Regenerate"})]})]}),a.status==="working"&&g(O,{children:[n(B,{style:{width:52,height:52,color:"var(--color-primary, #ff5a1f)"}}),g("p",{className:"studio-muted",children:["Preparing the AR model\u2026 ",a.progress?`${a.progress}%`:""]})]}),a.status==="error"&&g(O,{children:[n("p",{className:"studio-muted",children:"The AR model could not be made."}),n("button",{type:"button",className:"studio-btn",onClick:i,children:"Try again"})]})]})}function _e({systemId:o,presetId:d,view:a,selections:l}){const[r,f]=C({loading:!0,url:null,frames:null}),[i,m]=C(a.startFrame||0),[u,P]=C(!1),D=E(null),S=a.frames>1,[M,U]=C(!1),$=ce({onChange:U}),[R,T]=C({key:null,url:null}),b=`${a.id}:${i}:${l}`,_=I(s=>J({systemId:o,presetId:d,viewId:a.id,selections:l,...s}),[o,d,a.id,l]);k(()=>{if(!M)return;const s=b;if(R.key===s)return;let c=!0;return _({tier:"full",frame:i}).then(y=>{c&&T({key:s,url:y?.views?.[0]?.url??null})}).catch(()=>{c&&T({key:s,url:null})}),()=>{c=!1}},[M,_,i,R.key,b]),k(()=>{m(a.startFrame||0)},[a.id,a.startFrame]),k(()=>{let s=!0;return f(c=>({...c,loading:!0})),_({tier:"preview"}).then(c=>{if(!s)return;const y=c?.views?.[0];f({loading:!1,url:y?.url??null,frames:y?.frameUrls??null})}).catch(()=>{s&&f(c=>({...c,loading:!1}))}),()=>{s=!1}},[_]),k(()=>{if(!S||!r.frames)return;const s=c=>{if(c.key!=="ArrowLeft"&&c.key!=="ArrowRight")return;const y=r.frames.length;m(V=>(V+(c.key==="ArrowRight"?1:-1)+y)%y)};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[S,r.frames]);const z=s=>{!S||!r.frames||$.active||(D.current={x:s.clientX,frame:i},s.currentTarget.setPointerCapture?.(s.pointerId))},F=s=>{if(!D.current||!r.frames)return;const c=r.frames.length,y=Math.round((s.clientX-D.current.x)/12);m(((D.current.frame-y)%c+c)%c)},L=()=>{D.current=null},w=S?r.frames?.[i]:r.url,j=$.active&&R.key===b&&R.url?R.url:w,{ref:q,...p}=$.bind,G=async()=>{P(!0);try{const c=(await _({tier:"full",format:"png",...S?{frame:i}:null}))?.views?.[0]?.url||r.url;c&&await he(c,`${ve(a.name)}${S?`_${String(i+1).padStart(2,"0")}`:""}.png`)}finally{P(!1)}};return g(O,{children:[g("div",{className:"studio-final-stage__top",children:[g("div",{className:"studio-final-stage__caption",children:[n("strong",{children:a.name}),(a.resolution||S)&&g("span",{children:[a.resolution?`${a.resolution[0]} \xD7 ${a.resolution[1]}`:"",S?`${a.resolution?" \xB7 ":""}360\xB0 \xB7 ${i+1}/${a.frames}`:""]})]}),n("button",{type:"button",className:"studio-final-stage__download",onClick:G,disabled:u||!w,"aria-label":"Download full resolution",title:u?"Preparing\u2026":"Download full resolution",children:n(re,{size:17,"aria-hidden":"true"})})]}),g("div",{ref:$.bind.ref,className:`studio-final-stage__image${S&&!$.active?" studio-final-stage__image--spin":""}${$.active?" is-zoomed":""}`,onPointerDown:s=>{p.onPointerDown(s),z(s)},onPointerMove:s=>{p.onPointerMove(s),F(s)},onPointerUp:s=>{p.onPointerUp(s),L(s)},onPointerCancel:s=>{p.onPointerCancel(s),L(s)},onDoubleClick:p.onDoubleClick,onWheel:p.onWheel,onDragStart:p.onDragStart,children:[!w&&n("span",{className:"studio-muted",children:r.loading?"Loading the image\u2026":"This view has no image yet."}),w&&n("div",{className:"studio-final-stage__zoom",style:$.active?$.style:void 0,children:n("img",{src:j,alt:a.name,draggable:!1,className:r.loading?"is-loading":""})}),w&&!$.active&&n("span",{className:"studio-final-stage__zoom-badge","aria-hidden":"true",children:"Double-click to zoom"})]}),S&&r.frames&&n("input",{className:"studio-final-stage__frames",type:"range",min:"0",max:r.frames.length-1,value:i,"aria-label":"Frame",onChange:s=>m(Number(s.target.value))})]})}function ye({systemId:o,presetId:d}){const a=le(e=>e.sceneSelections),l=A(()=>ge(a),[a]),[r,f]=C(null),[i,m]=C({token:null,prev:null,dir:1,n:0}),u=i.token;k(()=>{W.getState().setFinalRenderShowing?.(u!=null)},[u]),k(()=>()=>W.getState().setFinalRenderShowing?.(!1),[]);const P=E(!1),[D,S]=C(0),M=E(null),U=E(new Map),$=I(()=>S(e=>e+1),[]);k(()=>{let e=!0;return clearTimeout(M.current),J({systemId:o,presetId:d,selections:l}).then(t=>{if(!e)return;f(t),(t?.status==="queued"||t?.status==="running"||(t?.views||[]).some(x=>x.status==="rendering"))&&(M.current=setTimeout($,fe))}).catch(()=>{e&&f(t=>t||{views:[],order:[]})}),()=>{e=!1,clearTimeout(M.current)}},[o,d,l,D,$]),k(()=>{m({token:null,prev:null,dir:1,n:0}),P.current=!1},[d]);const R=A(()=>r?.views||[],[r]),T=A(()=>R.filter(e=>pe(e,a)),[R,a]),b=A(()=>new Map(T.map(e=>[`view:${e.id}`,e])),[T]),_=A(()=>new Set(r?.hiddenCards||[]),[r?.hiddenCards]),z=A(()=>{const e=(r?.order||[]).filter(h=>h===v||h===N?!_.has(h):b.has(h)),t=[...new Set(e)];!t.includes(v)&&!_.has(v)&&t.unshift(v);for(const h of b.keys())t.includes(h)||t.splice(t.includes(N)?t.indexOf(N):t.length,0,h);return!t.includes(N)&&!_.has(N)&&t.push(N),t},[r?.order,b,_]),F=e=>e===N?N:e?b.get(e)??null:null,L=F(u),w=I((e,t)=>{const h=e===v?null:e;m(x=>{if(x.token===h)return x;const Y=z.indexOf(x.token??v),ee=z.indexOf(h??v);return{token:h,prev:x.token,dir:t??(ee>=Y?1:-1),n:x.n+1}})},[z]);k(()=>{u&&u!==N&&!b.has(u)&&w(v)},[u,b,w]),k(()=>{if(!u||_.has(v))return;const e=t=>{t.key==="Escape"&&w(v)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[u,w,_]);const[j,q]=C(!1);k(()=>{if(!i.n)return;q(!0);const e=setTimeout(()=>q(!1),me);return()=>clearTimeout(e)},[i.n]);const p=A(()=>z.filter(e=>e===v||e===N||!!b.get(e)?.thumb),[z,b]),G=u??v,s=e=>{if(!p.length)return null;const t=p.indexOf(G),h=t<0?0:(t+e+p.length)%p.length;return p[h]},c=e=>{const t=s(e);t!=null&&w(t,e)},y=e=>e===v?"3D":e===N?"AR":b.get(e)?.name||"";if(k(()=>{if(u!=null||!_.has(v))return;const e=p.find(t=>t!==v);e&&m({token:e,prev:null,dir:1,n:0})},[u,_,p]),k(()=>{if(P.current||!R.length||!p.length)return;P.current=!0;const e=p[0];e!==v&&m({token:e,prev:null,dir:1,n:0})},[R.length,p]),!r||!p.length)return null;const V=p.length>1,X=e=>e===N?n(be,{selections:l,cache:U}):n(_e,{systemId:o,presetId:d,view:e,selections:l},e.id),Z=(e,t=!0)=>()=>{t&&w(e)},Q=e=>e===v?u==null:u===e,H=(e,t="")=>`studio-final-card${t}${Q(e)?" is-active":""}`;return g(O,{children:[p.length>1&&g("div",{className:"studio-final-nav has-dock","data-part":"final-nav",children:[n("button",{type:"button",className:"studio-final-nav__btn studio-final-nav__btn--prev",onClick:()=>c(-1),"aria-label":`Previous: ${y(s(-1))}`,"data-label":y(s(-1)),children:n(ne,{size:20,"aria-hidden":"true"})}),n("button",{type:"button",className:"studio-final-nav__btn studio-final-nav__btn--next",onClick:()=>c(1),"aria-label":`Next: ${y(s(1))}`,"data-label":y(s(1)),children:n(ae,{size:20,"aria-hidden":"true"})})]}),g("div",{className:`studio-final-stage has-dock${L?" is-open":""}`,"data-part":"final-stage","aria-hidden":!L,children:[j&&F(i.prev)&&n("div",{className:`studio-final-stage__panel is-leaving-${i.dir>0?"next":"prev"}`,"aria-hidden":"true",children:X(F(i.prev))},`out-${i.n}`),L&&n("div",{className:`studio-final-stage__panel${i.n?` is-entering-${i.dir>0?"next":"prev"}`:""}`,children:X(L)},`in-${i.n}`)]}),V&&n("div",{className:"studio-final-dock","data-part":"final-dock",children:n("div",{className:"studio-final-dock__strip",children:n("div",{className:"studio-final-dock__cards",children:z.map(e=>{if(e===v)return g("button",{type:"button",className:H(e," studio-final-card--3d"),onClick:Z(e),title:"The 3D scene",children:[n("span",{className:"studio-final-card__img studio-final-card__img--ar",children:n(te,{size:30,"aria-hidden":"true"})}),n("span",{className:"studio-final-card__name",children:"3D"}),n("span",{className:"studio-final-card__meta",children:"Live scene"})]},e);if(e===N)return g("button",{type:"button",className:H(e," studio-final-card--ar"),onClick:Z(e),title:"AR: view the configuration in your space",children:[n("span",{className:"studio-final-card__img studio-final-card__img--ar",children:n(B,{style:{width:34,height:34}})}),n("span",{className:"studio-final-card__name",children:"AR"}),n("span",{className:"studio-final-card__meta",children:"View in your space"})]},e);const t=b.get(e);if(!t)return null;const h=t.progress?.total?Math.round(100*t.progress.done/t.progress.total):0;return g("button",{type:"button",className:H(e,` studio-final-card--${t.status}`),onClick:Z(e,!!t.thumb),"aria-disabled":!t.thumb||void 0,title:t.thumb?`Show ${t.name}`:`${t.name}: rendering`,"data-view-id":t.id,children:[g("span",{className:"studio-final-card__img",children:[t.thumb?n("img",{src:t.thumb,alt:"",loading:"lazy",draggable:!1}):n("span",{className:"studio-final-card__wait"}),t.frames>1&&n("span",{className:"studio-final-card__badge",children:"360\xB0"}),t.status!=="done"&&t.status!=="not_rendered"&&n("span",{className:"studio-final-card__progress","aria-label":`${h}%`,children:n("span",{style:{width:`${h}%`}})})]}),n("span",{className:"studio-final-card__name",children:t.name}),n("span",{className:"studio-final-card__meta",children:t.status==="done"?t.resolution?`${t.resolution[0]} \xD7 ${t.resolution[1]}`:"Done":t.status==="failed"?"Failed":`${h}%`})]},e)})})})})]})}function ke(){const o=K(m=>m.systemId),d=K(m=>m.systemRenderMode),a=K(m=>m.defaultPresetId),l=ue(m=>m.activeSceneConfigId),r=W(m=>m.hostMode),f=l||a,i=f==null||f==="default_layout"?null:String(f);return o==null||d==="rendered"||r==="admin"?null:n(ye,{systemId:o,presetId:i},`${o}:${i??""}`)}export{ke as default,pe as viewFits};
@@ -0,0 +1 @@
1
+ import{useEffect as v,useMemo as x,useState as C}from"react";import{fetchFinalRenders as S,fetchRenderLayers as F}from"./fbd844f2d1.js";import d from"./be337ddda5.js";import p from"./9c6c598569.js";import y from"./d94df858ea.js";const w=(t,r)=>{const s=t||r;return s==null||s==="default_layout"?null:String(s)},I=t=>{const r={};for(const[s,e]of Object.entries(t||{}))e!=null&&(r[String(s)]=Number(e));return r};function m({systemId:t,presetId:r,selections:s}={}){const e=d.getState().systemId??null,l=t??e;if(l==null)throw new Error("renders: no systemId \u2014 pass one, or call after boot() / mount()");const u=e!=null&&String(l)===String(e),a=r!==void 0?r:u?w(p.getState().activeSceneConfigId,d.getState().defaultPresetId):null,n=I(s!==void 0?s:u?y.getState().sceneSelections:null);return{systemId:l,presetId:a,selections:Object.keys(n).length?n:null}}async function R(t={}){return((await S(m(t)))?.views||[]).map(({id:s,name:e,kind:l,frames:u,startFrame:a,status:n,resolution:i,thumb:g})=>({id:s,name:e,kind:l,frames:u,startFrame:a,status:n,resolution:i,thumb:g}))}async function O({viewId:t,frame:r,tier:s="full",format:e,...l}={}){if(t==null)throw new Error("renders.getImage: viewId is required");const u=m(l),a=async i=>(await S({...u,viewId:t,tier:s,...i!=null?{frame:i}:{},...e?{format:e}:{}}))?.views?.[0]??null;let n=await a(r);return n&&!n.url&&n.frameUrls&&(n=await a(n.startFrame??0)),n?.url?{url:n.url,viewId:n.id,name:n.name,frame:r??n.startFrame??0,resolution:n.resolution??null,selections:n.selections??null}:null}async function U({viewId:t,...r}={}){if(t==null)throw new Error("renders.getFrames: viewId is required");const e=(await S({...m(r),viewId:t,tier:"preview"}))?.views?.[0];return e?.frameUrls?e.frameUrls:e?.url?[e.url]:[]}async function j({viewId:t,tier:r="full",...s}={}){const{systemId:e,presetId:l}=m(s);return F({systemId:e,viewId:t,tier:r,presetId:l})}function q(t,{tier:r="preview",frame:s,format:e}={}){const l=d(o=>o.systemId),u=d(o=>o.defaultPresetId),a=p(o=>o.activeSceneConfigId),n=y(o=>o.sceneSelections),i=x(()=>JSON.stringify(I(n)),[n]),[g,f]=C({url:null,loading:t!=null,error:null});return v(()=>{if(l==null||t==null){f({url:null,loading:!1,error:null});return}let o=!0;return f(c=>({...c,loading:!0,error:null})),O({viewId:t,tier:r,frame:s,format:e,systemId:l,presetId:w(a,u),selections:JSON.parse(i)}).then(c=>{o&&f({url:c?.url??null,loading:!1,error:null})}).catch(c=>{o&&f(h=>({...h,loading:!1,error:c}))}),()=>{o=!1}},[l,u,a,i,t,r,s,e]),g}export{U as getFrames,O as getImage,j as getLayers,R as getViews,q as useRenderImage};
@@ -1 +1 @@
1
- import*as r from"three";import T from"./872c4302e0.js";import F from"./d94df858ea.js";import R from"./8f60e5059a.js";import{deriveSceneFeatures as P}from"./be337ddda5.js";import{waitForAssetsIdle as _}from"./2774152dd2.js";const g=new Map,p=new Map,M=new Map,C=new r.TextureLoader(new r.LoadingManager),S=new Map;let w=!1;function Q(e){w=e}function L(e){if(!w||!e)return e;const t=e.lastIndexOf(".");return t===-1?e:e.slice(0,t)+"_mobile"+e.slice(t)}function x(e){if(e==null)return null;if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="string")return null;const t=e.trim().replace(/^#/,"");if(/^[0-9a-fA-F]{3}$/.test(t)){const n=t[0],i=t[1],a=t[2];return parseInt(n+n+i+i+a+a,16)}return/^[0-9a-fA-F]{6}$/.test(t)?parseInt(t,16):/^[0-9a-fA-F]{8}$/.test(t)?parseInt(t.slice(0,6),16):null}function B(e){if(!e||typeof e!="object")return e;const t=["color","emissive","specular","sheenColor","attenuationColor"];let n=null;for(const i of t){if(e[i]===void 0)continue;const a=x(e[i]);a!=null&&a!==e[i]&&(n||(n={...e}),n[i]=a)}return n||e}function d(e){if(e==null)return new r.Color(16777215);if(typeof e=="number")return new r.Color(e);if(typeof e=="string"){const t=e.trim();return/^[0-9a-fA-F]{3}$/.test(t)||/^[0-9a-fA-F]{6}$/.test(t)?new r.Color("#"+t):/^[0-9a-fA-F]{8}$/.test(t)?new r.Color("#"+t.slice(0,6)):new r.Color(t)}return new r.Color(16777215)}function G(e,t){return new Promise(n=>{C.load(encodeURI(e),i=>{i.colorSpace=r.SRGBColorSpace,i.wrapS=r.RepeatWrapping,i.wrapT=r.RepeatWrapping,n(i)},void 0,()=>{t&&t!==e?C.load(encodeURI(t),i=>{i.colorSpace=r.SRGBColorSpace,i.wrapS=r.RepeatWrapping,i.wrapT=r.RepeatWrapping,n(i)},void 0,()=>n(null)):n(null)})})}async function v(e){if(g.has(e))return g.get(e);try{const t=await fetch(encodeURI(e));if(!t.ok)throw new Error(`Failed to fetch ${e}`);const n=await t.json();return g.set(e,n),n}catch{return null}}const A={diffuse:{slot:"map",space:r.SRGBColorSpace},albedo:{slot:"map",space:r.SRGBColorSpace},normal:{slot:"normalMap",space:r.LinearSRGBColorSpace},roughness:{slot:"roughnessMap",space:r.LinearSRGBColorSpace},ao:{slot:"aoMap",space:r.LinearSRGBColorSpace},metalness:{slot:"metalnessMap",space:r.LinearSRGBColorSpace},emissive:{slot:"emissiveMap",space:r.SRGBColorSpace},map:{slot:"map",space:r.SRGBColorSpace},albedoMap:{slot:"map",space:r.SRGBColorSpace},normalMap:{slot:"normalMap",space:r.LinearSRGBColorSpace},roughnessMap:{slot:"roughnessMap",space:r.LinearSRGBColorSpace},metalnessMap:{slot:"metalnessMap",space:r.LinearSRGBColorSpace},aoMap:{slot:"aoMap",space:r.LinearSRGBColorSpace},emissiveMap:{slot:"emissiveMap",space:r.SRGBColorSpace}};function O(e){const t={};let n=!1;if(e.color!==void 0&&(t.color=d(e.color)),e.roughness!==void 0&&(t.roughness=e.roughness),e.metalness!==void 0&&(t.metalness=e.metalness),e.emissive!==void 0&&(t.emissive=d(e.emissive)),e.envMapIntensity!==void 0&&(t.envMapIntensity=e.envMapIntensity),e.sheen!==void 0&&e.sheen>0&&(t.sheen=e.sheen,n=!0),e.sheenColor!==void 0&&e.sheenColor!==0&&(t.sheenColor=d(e.sheenColor),n=!0),e.sheenRoughness!==void 0&&e.sheenRoughness!==1&&(t.sheenRoughness=e.sheenRoughness,n=!0),e.clearcoat!==void 0&&e.clearcoat>0&&(t.clearcoat=e.clearcoat,n=!0),e.clearcoatRoughness!==void 0&&e.clearcoatRoughness>0&&(t.clearcoatRoughness=e.clearcoatRoughness,n=!0),e.transmission!==void 0&&e.transmission>0&&(t.transmission=e.transmission,n=!0),e.thickness!==void 0&&e.thickness>0&&(t.thickness=e.thickness,n=!0),e.attenuationColor!==void 0&&e.attenuationColor!==16777215&&(t.attenuationColor=d(e.attenuationColor),n=!0),e.iridescence!==void 0&&e.iridescence>0&&(t.iridescence=e.iridescence,n=!0),e.iridescenceIOR!==void 0&&e.iridescenceIOR!==1.3&&(t.iridescenceIOR=e.iridescenceIOR,n=!0),e.iridescenceThicknessRange!==void 0){const i=e.iridescenceThicknessRange;(i[0]!==100||i[1]!==400)&&(t.iridescenceThicknessRange=i,n=!0)}if(e.specularIntensity!==void 0&&e.specularIntensity!==1&&(t.specularIntensity=e.specularIntensity,n=!0),e.specularColor!==void 0&&e.specularColor!==16777215&&(t.specularColor=d(e.specularColor),n=!0),e.reflectivity!==void 0&&e.reflectivity!==.5&&(t.reflectivity=e.reflectivity,n=!0),e.anisotropy!==void 0&&e.anisotropy!==0&&(t.anisotropy=e.anisotropy,n=!0),e.anisotropyRotation!==void 0&&e.anisotropyRotation!==0&&(t.anisotropyRotation=e.anisotropyRotation,n=!0),e.side!==void 0){const i={0:r.FrontSide,1:r.BackSide,2:r.DoubleSide};t.side=i[e.side]??r.FrontSide}return{params:t,needsPhysical:n}}async function E(e){if(!e)return null;const t=e.id;if(t!=null&&p.has(t))return p.get(t);if(t!=null&&S.has(t))return S.get(t);const n=k(e);if(t==null)return n;S.set(t,n);try{return await n}finally{S.delete(t)}}async function k(e){const t=e.id;let n=null,i=[1,1];if(e.materialJson)try{let a=B(e.materialJson);a.type||(a={...a,type:"MeshPhysicalMaterial"}),n=new r.MaterialLoader().parse(a),Array.isArray(e.materialJson.tiling)&&(i=e.materialJson.tiling)}catch{}if(!n&&e.materialFile){const a=await v(e.materialFile);if(a){const{params:c,needsPhysical:o}=O(a);Array.isArray(a.tiling)&&(i=a.tiling),n=o?new r.MeshPhysicalMaterial(c):new r.MeshStandardMaterial(c)}}if(!n&&(e.color!=null||e.roughness!=null||e.metalness!=null)){const a={};e.color!=null&&(a.color=d(e.color)),e.roughness!=null&&(a.roughness=e.roughness),e.metalness!=null&&(a.metalness=e.metalness),n=new r.MeshStandardMaterial(a)}if(!n&&e.textures&&(n=new r.MeshStandardMaterial),!n)return null;if(e.textures&&typeof e.textures=="object"){const a=[];for(const[c,o]of Object.entries(e.textures)){const l=A[c];if(!l||!o)continue;const u=String(o);a.push(G(L(u),u).then(s=>{s&&(s.colorSpace=l.space,s.repeat.set(i[0],i[1]),n[l.slot]=s)}))}await Promise.all(a),n.needsUpdate=!0}if(Array.isArray(i)&&(i[0]!==1||i[1]!==1)){const a=["map","normalMap","roughnessMap","metalnessMap","aoMap","emissiveMap","bumpMap","displacementMap","alphaMap"];for(const c of a){const o=n[c];o&&(o.wrapS=r.RepeatWrapping,o.wrapT=r.RepeatWrapping,o.repeat.set(i[0],i[1]),o.needsUpdate=!0)}n.needsUpdate=!0}return t!=null&&p.set(t,n),n}function $(e){return e?!!(e.materialJson||e.materialFile||e.textures||e.color!=null||e.roughness!=null||e.metalness!=null):!1}function J(e){return!e||!e.id?null:p.get(e.id)||null}let b=[],m="idle",y=!1;function X(e){m=e==="never"?"never":"idle"}const I=e=>E(e).catch(()=>null);function Y(e){const t=T.getState(),n=t.materials,i=t.options||{};if(!n)return;const a=new Set,c=s=>{if(s==null)return;const f=i[s]??i[String(s)],h=f?.value??f?.valueMaterial??f?.value_material;h!=null&&(n[h]||n[String(h)])&&a.add(String(h))};try{for(const s of P(e)||[])s?.type==="finish_change"&&c(s.default_option_id??s.defaultOption)}catch{}try{const{sceneSelections:s}=F.getState();for(const f of Object.values(s||{}))c(f)}catch{}const o=["cabinet_finish","hardware_finish","countertop_finish"];o.forEach(s=>c(e?.[s])),e?.products?.forEach(s=>o.forEach(f=>c(s?.[f])));const l=Object.values(n).filter($),u=l.filter(s=>a.has(String(s.id)));b=l.filter(s=>!a.has(String(s.id))),y=!1,Promise.all(u.map(I))}const U=3;function V(){if(y||m==="never"||typeof navigator<"u"&&navigator.connection?.saveData)return;y=!0;const e=R.getState(),t=()=>_({quietMs:1e3,safetyMs:12e4}).then(W);if(e.bootLoading){let n=null;const i=()=>{n&&n(),n=null,t()};n=R.subscribe(a=>{a.bootLoading||i()}),setTimeout(()=>{n&&i()},2e4);return}t()}function W(){const e=b.slice(),t=()=>new Promise(i=>{typeof requestIdleCallback=="function"?requestIdleCallback(()=>i(),{timeout:2e3}):setTimeout(i,250)}),n=async()=>{for(;e.length;){if(m==="never")return;const i=e.shift();J(i)||(await t(),await I(i))}};for(let i=0;i<Math.min(U,e.length);i+=1)n()}function Z({color:e="#ffffff",roughness:t=.7,metalness:n=0,side:i}={}){const c=`${String(e).toLowerCase()}|${t}|${n}|${i??"def"}`,o=M.get(c);if(o)return o;const l={color:e,roughness:t,metalness:n};i!=null&&(l.side=i);const u=new r.MeshStandardMaterial(l);return M.set(c,u),u}function D(){p.forEach(e=>e.dispose()),p.clear(),g.clear(),M.forEach(e=>e.dispose()),M.clear()}export{D as clearMaterialCache,J as getCachedMaterial,Z as getFlatMaterial,$ as isPhysicalMaterial,E as loadPhysicalMaterial,V as prefetchRemainingMaterialsWhenIdle,Y as preloadMaterials,X as setFinishPrefetch,Q as setUseMobileTextures};
1
+ import*as i from"three";import A from"./872c4302e0.js";import T from"./d94df858ea.js";import R from"./8f60e5059a.js";import{deriveSceneFeatures as F}from"./be337ddda5.js";import{waitForAssetsIdle as P}from"./2774152dd2.js";const m=new Map,d=new Map,y=new Map,C=new i.TextureLoader(new i.LoadingManager),g=new Map;let w=!1;function Q(e){w=e}function _(e){if(!w||!e)return e;const t=e.lastIndexOf(".");return t===-1?e:e.slice(0,t)+"_mobile"+e.slice(t)}function L(e){if(e==null)return null;if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="string")return null;const t=e.trim().replace(/^#/,"");if(/^[0-9a-fA-F]{3}$/.test(t)){const n=t[0],r=t[1],s=t[2];return parseInt(n+n+r+r+s+s,16)}return/^[0-9a-fA-F]{6}$/.test(t)?parseInt(t,16):/^[0-9a-fA-F]{8}$/.test(t)?parseInt(t.slice(0,6),16):null}function B(e){if(!e||typeof e!="object")return e;const t=["color","emissive","specular","sheenColor","attenuationColor"];let n=null;for(const r of t){if(e[r]===void 0)continue;const s=L(e[r]);s!=null&&s!==e[r]&&(n||(n={...e}),n[r]=s)}return n||e}function h(e){if(e==null)return new i.Color(16777215);if(typeof e=="number")return new i.Color(e);if(typeof e=="string"){const t=e.trim();return/^[0-9a-fA-F]{3}$/.test(t)||/^[0-9a-fA-F]{6}$/.test(t)?new i.Color("#"+t):/^[0-9a-fA-F]{8}$/.test(t)?new i.Color("#"+t.slice(0,6)):new i.Color(t)}return new i.Color(16777215)}function G(e,t){return new Promise(n=>{C.load(encodeURI(e),r=>{r.colorSpace=i.SRGBColorSpace,r.wrapS=i.RepeatWrapping,r.wrapT=i.RepeatWrapping,n(r)},void 0,()=>{t&&t!==e?C.load(encodeURI(t),r=>{r.colorSpace=i.SRGBColorSpace,r.wrapS=i.RepeatWrapping,r.wrapT=i.RepeatWrapping,n(r)},void 0,()=>n(null)):n(null)})})}async function v(e){if(m.has(e))return m.get(e);try{const t=await fetch(encodeURI(e));if(!t.ok)throw new Error(`Failed to fetch ${e}`);const n=await t.json();return m.set(e,n),n}catch{return null}}const x={diffuse:{slot:"map",space:i.SRGBColorSpace},albedo:{slot:"map",space:i.SRGBColorSpace},normal:{slot:"normalMap",space:i.LinearSRGBColorSpace},roughness:{slot:"roughnessMap",space:i.LinearSRGBColorSpace},ao:{slot:"aoMap",space:i.LinearSRGBColorSpace},metalness:{slot:"metalnessMap",space:i.LinearSRGBColorSpace},emissive:{slot:"emissiveMap",space:i.SRGBColorSpace},map:{slot:"map",space:i.SRGBColorSpace},albedoMap:{slot:"map",space:i.SRGBColorSpace},normalMap:{slot:"normalMap",space:i.LinearSRGBColorSpace},roughnessMap:{slot:"roughnessMap",space:i.LinearSRGBColorSpace},metalnessMap:{slot:"metalnessMap",space:i.LinearSRGBColorSpace},aoMap:{slot:"aoMap",space:i.LinearSRGBColorSpace},emissiveMap:{slot:"emissiveMap",space:i.SRGBColorSpace}};function O(e){const t={};let n=!1;if(e.color!==void 0&&(t.color=h(e.color)),e.roughness!==void 0&&(t.roughness=e.roughness),e.metalness!==void 0&&(t.metalness=e.metalness),e.emissive!==void 0&&(t.emissive=h(e.emissive)),e.envMapIntensity!==void 0&&(t.envMapIntensity=e.envMapIntensity),e.sheen!==void 0&&e.sheen>0&&(t.sheen=e.sheen,n=!0),e.sheenColor!==void 0&&e.sheenColor!==0&&(t.sheenColor=h(e.sheenColor),n=!0),e.sheenRoughness!==void 0&&e.sheenRoughness!==1&&(t.sheenRoughness=e.sheenRoughness,n=!0),e.clearcoat!==void 0&&e.clearcoat>0&&(t.clearcoat=e.clearcoat,n=!0),e.clearcoatRoughness!==void 0&&e.clearcoatRoughness>0&&(t.clearcoatRoughness=e.clearcoatRoughness,n=!0),e.transmission!==void 0&&e.transmission>0&&(t.transmission=e.transmission,n=!0),e.thickness!==void 0&&e.thickness>0&&(t.thickness=e.thickness,n=!0),e.attenuationColor!==void 0&&e.attenuationColor!==16777215&&(t.attenuationColor=h(e.attenuationColor),n=!0),e.iridescence!==void 0&&e.iridescence>0&&(t.iridescence=e.iridescence,n=!0),e.iridescenceIOR!==void 0&&e.iridescenceIOR!==1.3&&(t.iridescenceIOR=e.iridescenceIOR,n=!0),e.iridescenceThicknessRange!==void 0){const r=e.iridescenceThicknessRange;(r[0]!==100||r[1]!==400)&&(t.iridescenceThicknessRange=r,n=!0)}if(e.specularIntensity!==void 0&&e.specularIntensity!==1&&(t.specularIntensity=e.specularIntensity,n=!0),e.specularColor!==void 0&&e.specularColor!==16777215&&(t.specularColor=h(e.specularColor),n=!0),e.reflectivity!==void 0&&e.reflectivity!==.5&&(t.reflectivity=e.reflectivity,n=!0),e.anisotropy!==void 0&&e.anisotropy!==0&&(t.anisotropy=e.anisotropy,n=!0),e.anisotropyRotation!==void 0&&e.anisotropyRotation!==0&&(t.anisotropyRotation=e.anisotropyRotation,n=!0),e.side!==void 0){const r={0:i.FrontSide,1:i.BackSide,2:i.DoubleSide};t.side=r[e.side]??i.FrontSide}return{params:t,needsPhysical:n}}async function E(e){if(!e)return null;const t=e.id;if(t!=null&&d.has(t))return d.get(t);if(t!=null&&g.has(t))return g.get(t);const n=k(e);if(t==null)return n;g.set(t,n);try{return await n}finally{g.delete(t)}}async function k(e){const t=e.id;let n=null,r=[1,1],s=[0,0];if(e.materialJson)try{let a=B(e.materialJson);a.type||(a={...a,type:"MeshPhysicalMaterial"}),n=new i.MaterialLoader().parse(a),Array.isArray(e.materialJson.tiling)&&(r=e.materialJson.tiling),Array.isArray(e.materialJson.offset)&&(s=e.materialJson.offset)}catch{}if(!n&&e.materialFile){const a=await v(e.materialFile);if(a){const{params:l,needsPhysical:c}=O(a);Array.isArray(a.tiling)&&(r=a.tiling),Array.isArray(a.offset)&&(s=a.offset),n=c?new i.MeshPhysicalMaterial(l):new i.MeshStandardMaterial(l)}}if(!n&&(e.color!=null||e.roughness!=null||e.metalness!=null)){const a={};e.color!=null&&(a.color=h(e.color)),e.roughness!=null&&(a.roughness=e.roughness),e.metalness!=null&&(a.metalness=e.metalness),n=new i.MeshStandardMaterial(a)}if(!n&&e.textures&&(n=new i.MeshStandardMaterial),!n)return null;if(e.textures&&typeof e.textures=="object"){const a=[];for(const[l,c]of Object.entries(e.textures)){const o=x[l];if(!o||!c)continue;const f=String(c);a.push(G(_(f),f).then(p=>{p&&(p.colorSpace=o.space,p.repeat.set(r[0],r[1]),p.offset.set(Number(s[0])||0,Number(s[1])||0),n[o.slot]=p)}))}await Promise.all(a),n.needsUpdate=!0}const u=Array.isArray(s)&&((Number(s[0])||0)!==0||(Number(s[1])||0)!==0);if(Array.isArray(r)&&(r[0]!==1||r[1]!==1)||u){const a=["map","normalMap","roughnessMap","metalnessMap","aoMap","emissiveMap","bumpMap","displacementMap","alphaMap"];for(const l of a){const c=n[l];c&&(c.wrapS=i.RepeatWrapping,c.wrapT=i.RepeatWrapping,Array.isArray(r)&&c.repeat.set(r[0],r[1]),u&&c.offset.set(Number(s[0])||0,Number(s[1])||0),c.needsUpdate=!0)}n.needsUpdate=!0}return t!=null&&d.set(t,n),n}function J(e){return e?!!(e.materialJson||e.materialFile||e.textures||e.color!=null||e.roughness!=null||e.metalness!=null):!1}function $(e){return!e||!e.id?null:d.get(e.id)||null}let b=[],M="idle",S=!1;function X(e){M=e==="never"?"never":"idle"}const I=e=>E(e).catch(()=>null);function Y(e){const t=A.getState(),n=t.materials,r=t.options||{};if(!n)return;const s=new Set,u=o=>{if(o==null)return;const f=r[o]??r[String(o)],p=f?.value??f?.valueMaterial??f?.value_material;p!=null&&(n[p]||n[String(p)])&&s.add(String(p))};try{for(const o of F(e)||[])o?.type==="finish_change"&&u(o.default_option_id??o.defaultOption)}catch{}try{const{sceneSelections:o}=T.getState();for(const f of Object.values(o||{}))u(f)}catch{}const a=["cabinet_finish","hardware_finish","countertop_finish"];a.forEach(o=>u(e?.[o])),e?.products?.forEach(o=>a.forEach(f=>u(o?.[f])));const l=Object.values(n).filter(J),c=l.filter(o=>s.has(String(o.id)));b=l.filter(o=>!s.has(String(o.id))),S=!1,Promise.all(c.map(I))}const U=3;function V(){if(S||M==="never"||typeof navigator<"u"&&navigator.connection?.saveData)return;S=!0;const e=R.getState(),t=()=>P({quietMs:1e3,safetyMs:12e4}).then(N);if(e.bootLoading){let n=null;const r=()=>{n&&n(),n=null,t()};n=R.subscribe(s=>{s.bootLoading||r()}),setTimeout(()=>{n&&r()},2e4);return}t()}function N(){const e=b.slice(),t=()=>new Promise(r=>{typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(),{timeout:2e3}):setTimeout(r,250)}),n=async()=>{for(;e.length;){if(M==="never")return;const r=e.shift();$(r)||(await t(),await I(r))}};for(let r=0;r<Math.min(U,e.length);r+=1)n()}function Z({color:e="#ffffff",roughness:t=.7,metalness:n=0,side:r}={}){const u=`${String(e).toLowerCase()}|${t}|${n}|${r??"def"}`,a=y.get(u);if(a)return a;const l={color:e,roughness:t,metalness:n};r!=null&&(l.side=r);const c=new i.MeshStandardMaterial(l);return y.set(u,c),c}function D(){d.forEach(e=>e.dispose()),d.clear(),m.clear(),y.forEach(e=>e.dispose()),y.clear()}export{D as clearMaterialCache,$ as getCachedMaterial,Z as getFlatMaterial,J as isPhysicalMaterial,E as loadPhysicalMaterial,V as prefetchRemainingMaterialsWhenIdle,Y as preloadMaterials,X as setFinishPrefetch,Q as setUseMobileTextures};
@@ -1 +1 @@
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};
1
+ import{Fragment as ct,jsx as h,jsxs as Z}from"react/jsx-runtime";import{useRef as F,useMemo as I,useEffect as O,useState as X,Suspense as U}from"react";import{useGLTF as $,Edges as tt}from"@react-three/drei";import*as c from"three";import rt from"./9c6c598569.js";import K from"./872c4302e0.js";import et from"./609e5e5d28.js";import{useComponentOverride as nt,_trackMount as ot}from"./a3c983d431.js";import{getFlatMaterial as H}from"./c44d37da7a.js";import q from"./983cbed22c.js";import{resolveMaterial as st}from"./95a44ebec2.js";const it={"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 J(t){t.updateMatrixWorld(!0);const e=new c.Matrix4().copy(t.matrixWorld).invert(),a=new c.Box3,v=new c.Box3,p=new c.Matrix4;return t.traverse(u=>{if(!u.isMesh||!u.geometry)return;const x=`${u.name||""} ${u.material?.name||""}`.toLowerCase();/shadow|contact[\s_-]?shadow|ao[\s_-]?(plane|map)|ground[\s_-]?plane/.test(x)||(u.geometry.boundingBox||u.geometry.computeBoundingBox(),v.copy(u.geometry.boundingBox),p.multiplyMatrices(e,u.matrixWorld),v.applyMatrix4(p),a.union(v))}),a}function at({url:t,onReady:e}){return $(t,"/assets/draco/"),O(()=>{e?.()},[t,e]),null}function lt({frame:t,onClick:e,isSelected:a,onMeasure:v,slotName:p,slotKey:u,componentId:x}){const[b,g]=X(t),B=t.url===b.url;B&&b!==t&&g(t);const s=B?t:b,w=()=>g(t);return Z(ct,{children:[h(ut,{url:s.url,material:s.material,position:s.position,rotation:s.rotation,scale:s.scale,skirt:s.skirt,onClick:e,isSelected:a,onMeasure:v,recalcPosition:s.recalcPosition,slotName:p,slotKey:u,componentId:x,pivot:s.pivot,children:s.childNodes}),!B&&h(q,{onError:w,children:h(U,{children:h(at,{url:t.url,onReady:w})})})]})}function ut({url:t,material:e,position:a,rotation:v,scale:p,skirt:u,onClick:x,isSelected:b,onMeasure:g,recalcPosition:B,slotName:s,slotKey:w,componentId:_,pivot:G,children:L}){const R=F(),{scene:M}=$(t,"/assets/draco/"),[D,z]=X(0),j=F(null);O(()=>{if(!B||!R.current){j.current=null,z(0);return}const n=R.current;n.updateWorldMatrix(!0,!0);const l=new c.Matrix4().copy(n.matrixWorld).invert(),i=n.parent?new c.Matrix4().copy(n.parent.matrixWorld).invert():new c.Matrix4,o=new c.Matrix4().multiplyMatrices(i,n.matrixWorld),d=new c.Box3,S=new c.Box3,T=new c.Matrix4;if(n.traverse(f=>{!f.isMesh||!f.geometry||(f.geometry.boundingBox||f.geometry.computeBoundingBox(),T.multiplyMatrices(o,new c.Matrix4().multiplyMatrices(l,f.matrixWorld)),S.copy(f.geometry.boundingBox).applyMatrix4(T),d.union(S))}),d.isEmpty())return;const W=(d.max.x-d.min.x)/2,m=(Array.isArray(a)&&a[0]||0)<0?-1:1;let y=j.current;if(j.current=W,y==null&&(y=.1),y==null){z(0);return}if(Math.abs(W-y)<1e-4)return;const A=m*(W-y);z(f=>f+A)},[M,B,a]);const k=I(()=>{const n=M.clone(!0),l=s!=null&&String(s)!==""?String(s):null;l&&(n.name=l),n.userData={...n.userData,slotKey:w,componentId:_,slotName:l};let i=null;if(u){const o=new c.Box3().setFromObject(n);i=o.min.y+(o.max.y-o.min.y)*.12}return n.traverse(o=>{if(o.userData={...o.userData,slotKey:w,componentId:_,slotName:l},o.isMesh&&(o.castShadow=!0,o.receiveShadow=!0,e)){const d=e.clone();i!=null&&o.geometry?.attributes?.position&&d.color&&new c.Box3().setFromBufferAttribute(o.geometry.attributes.position).max.y<i&&d.color.multiplyScalar(.65),b&&(d.emissive=new c.Color("#ff6b35"),d.emissiveIntensity=1),o.material=d}}),n},[M,e,b,u,s,w,_]);O(()=>()=>{k.traverse(n=>{n.isMesh&&n.material&&n.material.dispose()})},[k]);const P=I(()=>{const n=it[G||"model-derived"];if(!n)return null;const l=J(k);if(l.isEmpty())return null;const{min:i,max:o}=l,d=(i.x+o.x)/2,S=(i.y+o.y)/2,T=(i.z+o.z)/2,W=n.x==="min"?i.x:n.x==="max"?o.x:d,r=n.y==="min"?i.y:S,m=n.z==="min"?i.z:n.z==="max"?o.z:T;return[-W,-r,-m]},[k,G]);O(()=>{if(!g||!M)return;const n=J(M);if(n.isEmpty())return;const l=n.getSize(new c.Vector3),i=n.getCenter(new c.Vector3),o=P||[0,0,0];(l.x>0||l.y>0||l.z>0)&&g({width:l.x,height:l.y,depth:l.z,cx:i.x+o[0],cy:i.y+o[1],cz:i.z+o[2]})},[M,g,P]);const E=F(g);E.current=g,O(()=>()=>{try{E.current?.(null)}catch{}},[]);const C=B&&D&&Array.isArray(a)?[(a[0]||0)+D,a[1]||0,a[2]||0]:a;return Z("group",{ref:R,name:s!=null?String(s):void 0,userData:{slotKey:w,componentId:_,slotName:s!=null?String(s):void 0},position:C,rotation:v,scale:p,onClick:x,children:[P?h("group",{position:P,children:h("primitive",{object:k})}):h("primitive",{object:k}),L]})}function vt({geometry:t,material:e,position:a,onClick:v,isSelected:p}){const u=F(),x=I(()=>{if(p){const b=e.clone();return b.emissive=new c.Color("#ff6b35"),b.emissiveIntensity=1,b}return e},[e,p]);return O(()=>()=>{x!==e&&x.dispose()},[x,e]),h("mesh",{ref:u,geometry:t,material:x,position:a,onClick:v,castShadow:!0,receiveShadow:!0,children:p&&h(tt,{scale:1.01,threshold:15,color:"#ff6b35",linewidth:3})})}const Q={visible:!0,materialId:null};function Y({component:t,componentState:e,instanceId:a,isSelected:v,onMeasure:p,onPick:u,slotName:x,slotKey:b,componentId:g,pivot:B,hiddenComponentIds:s,onDescendantMeasured:w,slotMaterials:_}){const G=rt(r=>r.selectInstance),L=K(r=>r.getMaterial),R=K(r=>r.getComponent),M=nt(x,t?.name??t?.componentName,g);M?.materialId&&(e={...e,materialId:M.materialId}),O(()=>ot({name:t?.name??t?.componentName??null,slotName:x??null,componentId:g!=null?String(g):null,instanceId:a??null}),[t?.name,t?.componentName,x,g,a]);const{physicalMat:D}=et(e.materialId,{getMaterial:L}),z=I(()=>{const r=e.variantId&&t.style_variants?t.style_variants[e.variantId]:null,m=t.variants,y=m&&typeof m=="object"?m.default||Object.values(m)[0]:null;return r||t.url||t.asset_url||t.modelPath||t.model_path||t.modelUrl||t.model_url||y||null},[t,e.variantId]),j=I(()=>{if(!z||typeof z!="string")return!1;const r=z.split(/[?#]/)[0].toLowerCase();return r.endsWith(".glb")||r.endsWith(".gltf")},[z]),k=I(()=>{if(D)return D;if(e.materialId){const r=L(e.materialId),m=st({...e,materialId:e.materialId,definition:r},{THREE:c,Default:()=>r&&r.color?H({color:r.color||"#808080",roughness:r.roughness||.5,metalness:r.metalness||0}):null});if(m)return m;if(r&&r.color)return H({color:r.color||"#808080",roughness:r.roughness||.5,metalness:r.metalness||0})}return e.color?H({color:e.color,roughness:e.roughness??.5,metalness:e.metalness??0}):null},[e.materialId,e.color,e.roughness,e.metalness,L,D]),P=r=>{r.stopPropagation();const m=g??t?.id??null;if(u){u(m);return}G(a,m)},E=t.position||[0,0,0],C=t.rotation||t.orientation||[0,0,0],n=Math.PI/180,l=Array.isArray(C)&&C.length===3?t.rotationRad?[C[0],C[1],C[2]]:[C[0]*n,C[1]*n,C[2]*n]:[0,0,0];let i=t.scale||[1,1,1],o=E,d=l;if(M?.transform){const r=M.transform;r.position&&(o=[E[0]+r.position[0],E[1]+r.position[1],E[2]+r.position[2]]),r.rotation&&(d=[l[0]+r.rotation[0]*n,l[1]+r.rotation[1]*n,l[2]+r.rotation[2]*n]),r.scale&&(i=[i[0]*r.scale[0],i[1]*r.scale[1],i[2]*r.scale[2]])}const S=I(()=>{const r=Array.isArray(t.children)?t.children:[];if(!r.length)return null;const m=Array.isArray(s)&&s.length?new Set(s.map(y=>String(y))):null;return r.map(y=>{const A=y.componentId??y.component_id;if(m&&A!=null&&m.has(String(A)))return null;const f=A!=null?R(A):null;if(!f)return null;const V=String(f.materialSlot??f.material_slot??"").toLowerCase(),N=_&&V?_[V]:null;return h(Y,{component:{...f,position:y.position,rotation:y.rotation,scale:y.scale},componentState:N?{...Q,materialId:N}:Q,instanceId:a,componentId:A,slotKey:f.materialSlot??f.name??String(A),slotName:f.name??null,onPick:u,hiddenComponentIds:s,slotMaterials:_,onMeasure:w,onDescendantMeasured:w},y.id??A)})},[t.children,R,a,u,s,w,_]),T=[...o,...d,...i].join(","),W=I(()=>({url:z,material:k,position:o,rotation:d,scale:i,skirt:t.skirt,recalcPosition:t.recalcPosition,pivot:B,childNodes:S}),[z,k,T,t.skirt,t.recalcPosition,B,S]);return M?.hidden?null:j?h(q,{children:h(U,{children:h(lt,{frame:W,onClick:P,isSelected:v,onMeasure:p,slotName:x,slotKey:b,componentId:g})})}):null}var wt=Y;export{wt as default};