@imagineio/configurator-sdk 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/1e243363f6.js +1 -1
- package/dist/2990ba64d6.js +1 -1
- package/dist/2c7c1bcef1.js +1 -1
- package/dist/30be653f00.css +106 -106
- package/dist/39a62ef7b8.js +1 -1
- package/dist/3c916f744f.js +1 -1
- package/dist/4e7d0a0d4a.js +1 -1
- package/dist/60d697292c.js +1 -1
- package/dist/6bff84d27e.js +1 -1
- package/dist/718ecf1729.js +1 -0
- package/dist/776277593f.js +1 -1
- package/dist/7d9ddaeb47.js +1 -1
- package/dist/811b403d43.js +1 -1
- package/dist/87bb469216.js +1 -1
- package/dist/921bf270dd.js +6 -6
- package/dist/9526094bb7.js +1 -1
- package/dist/97abcad34e.js +1 -0
- package/dist/98f3644031.js +1 -1
- package/dist/99577e3161.js +1 -0
- package/dist/a0f71d0bf5.js +1 -1
- package/dist/a493e9aa8f.js +1 -1
- package/dist/a77b15c0d6.js +1 -1
- package/dist/bcd44b4040.js +1 -1
- package/dist/bdec200d00.js +1 -1
- package/dist/be07a7f885.js +1 -0
- package/dist/c9a1656c62.js +1 -1
- package/dist/ce663020e4.js +2 -2
- package/dist/d4378d9afa.js +1 -1
- package/dist/dbd5ba1d07.js +1 -1
- package/dist/dc2a1a0e13.js +1 -1
- package/dist/fbd844f2d1.js +1 -1
- package/package.json +1 -1
package/dist/87bb469216.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fragment as ue,jsx as f,jsxs as it}from"react/jsx-runtime";import{useCallback as Y,useEffect as N,useMemo as Z,useRef as Mt,useState as Pt,useSyncExternalStore as We}from"react";import{Html as bn,useProgress as yn}from"@react-three/drei";import O from"./9c6c598569.js";import K from"./872c4302e0.js";import z from"./be337ddda5.js";import ft from"./d94df858ea.js";import{normalizeMaterialTargets as vn}from"./dc2a1a0e13.js";import S from"./8f60e5059a.js";import Mn from"./60d697292c.js";import Pn from"./811b403d43.js";import{useUiToggles as xn}from"./d0f9681634.js";import{ProductInstance as le,SelectionActionPanel as wn,FreeMovable as Cn,PlacementGaps as _n,SceneStage as Tn,SceneRoom as Fn,SceneProductsSource as On}from"./8a3a57c008.js";import Gn from"./205827c5c8.js";import{computeTargets as Ln,resolveTarget as kn,resolveTargetRenderer as An,resolveInsertSequence as Dn}from"./58e6419ba8.js";import{disarmPlacement as Ye}from"./ab6c80484f.js";import{resolveComponent as de,useComponentRegistry as Ke}from"./882bc739c8.js";import Rn from"./88251d6671.js";import{useLabels as zn}from"./28d887bf8a.js";import{SlotHost as En}from"./73f7d65985.js";import{ModalHost as Nn}from"./09c4973968.js";import qn from"./6c0a2572dd.js";import Xn from"./20b0104576.js";import{getConfigState as Zn,subscribe as $e,getVersion as Et}from"./817d930a49.js";import{getPlacementStrategy as Qe}from"./281cf952fa.js";import{resolveAddMode as Hn,armPlacement as jn}from"./ab6c80484f.js";import{resolveReplaceTarget as Vn}from"./4d7a0d1897.js";import{enforceCorners as Un}from"./388cadacbd.js";import{resolvePlacementStrategyConfig as Je}from"./281cf952fa.js";import{getLabel as Bn}from"./28d887bf8a.js";import{isAddFeature as Wn}from"./8c27edda0f.js";import{usePlacementInteraction as Yn}from"./4b8958aa4c.js";import{refreshCanonicalState as Kn,seedInitialState as $n,addProduct as Nt}from"./a77b15c0d6.js";import{resolveLayout as Qn,hasLayout as Jn,useLayoutRegistry as to,layoutOverride as eo,_publishResolvedLayoutKey as no}from"./31ea036f5c.js";import{themeLayoutKey as oo,useSystemTheme as so}from"./5c9fd9201c.js";import"./1a2629800a.css";import{runIntent as qt,INTENTS as Xt}from"./6d238282c1.js";function ro(){const w=ft(r=>r.sceneSelections),g=ft(r=>r.selectionOrder),m=O(r=>r.activeSceneConfigId),u=z(r=>r.defaultPresetId),i=z(r=>r.sceneConfigurations),G=z(r=>r.getSceneFeatures),I=We($e,Et,Et);return Z(()=>{const r=m||u||Object.keys(i||{})[0],$=r?G(r):[],H=K.getState(),b=[],Q=new Set,lt=(c,L)=>{if(!c||c.id==null||Q.has(String(c.id))||L>4)return;Q.add(String(c.id)),b.push(c);const P=(H.features?.[c.id]||H.features?.[String(c.id)])?.childOptionSetIds||[];for(const y of P){const d=H.features?.[y]||H.features?.[String(y)];d&<({id:y,type:d.type,sequence:d.sequence},L+1)}};for(const c of $)lt(c,0);const mt=b.filter(c=>/finish/i.test(c.type||"")&&w[c.id]!=null).sort((c,L)=>{const q=g?.[String(c.id)]??-1,P=g?.[String(L.id)]??-1;return q!==P?q-P:(c.sequence??0)-(L.sequence??0)}),M={};for(const c of mt){const L=w[c.id],q=H.options?.[L]?.value;if(q==null)continue;const P=H.features?.[c.id]||{},y=vn(P.materialTargets??P.material_targets??P.materials);for(const d of y)M[String(d).toLowerCase()]=q}return M},[w,g,m,u,i,G,I])}function ao(w,g){if(g==null)return null;const m=String(g);for(const u of Object.values(w.products||{})){const i=u?.components_configuration||u?.componentsConfiguration;if(!(!i||typeof i!="object"))for(const G of Object.values(i))for(const I of Array.isArray(G)?G:[G]){const r=I&&typeof I=="object"?I.componentId??I.component_id:I;if(r!=null&&String(r)===m)return u}}return null}function co(w){const g=ft(b=>b.sceneSelections),m=ft(b=>b.setSceneSelection),u=z(b=>b.getSceneFeatures),i=z(b=>b.sceneConfigurations),G=We($e,Et,Et),I=Z(()=>new Set((w?u(w)||[]:[]).filter(b=>Wn(b)).map(b=>String(b.id))),[w,u,i,G]),r=Mt({}),$=Mt(!1),H=ft(b=>b.sceneSelectionsSettled);N(()=>{if(!H){r.current={...g};return}if(!$.current){$.current=!0;let M=!1;for(const[c,L]of Object.entries(g||{}))L==null||!I.has(String(c))||(m(c,null),M=!0);if(M){r.current={...g};return}}const b=r.current,Q=[];for(const[M,c]of Object.entries(g||{}))b[M]===c||c==null||I.has(String(M))&&Q.push([M,c]);if(r.current={...g},!Q.length)return;const lt=z.getState().systemId;let mt=!1;return(async()=>{const M=K.getState(),c=O.getState();for(const[L,q]of Q){const P=M.options?.[q];let y=P?.valueProductVariantId??P?.value_product_variant_id??P?.value_product_variant??P?.variantId??P?.variant_id??null,d=y!=null?M.getProduct?.(y):null;if(d==null){const p=P?.value??(M.optionToProducts?.[String(q)]||[])[0]??P?.product_id??P?.productId??null;d=p!=null?M.getProduct?.(p):null,d==null&&p!=null&&M.getComponent?.(p)&&(d=ao(M,p)),y=d?.id??y??p}else y=d?.id??y;if(y==null){m(L,null);continue}const xt=d?.id??y,wt=d?.placementGroup??d?.placement_group??null,Zt=d?.productGraph??d?.product_graph??null,gt=d?.compatibleSlots??d?.compatible_slots??null;if(Array.isArray(gt)&>.length){const p=new Set(gt.map(String));if(Object.values(c.productInstances||{}).some(pt=>{const Vt=M.getProduct?.(pt.variantId)||M.getProduct?.(pt.productId),St=Vt?.product_graph??Vt?.productGraph;return St!=null&&p.has(String(St))})){S.getState().setPendingSlotPlacement?.({productId:xt,variantId:y,name:d?.name??d?.displayName??d?.variantName??"product",compatibleGraphIds:Array.from(p)}),m(L,null);continue}}if(Hn(lt,d)==="arm"){jn({productId:xt,variantId:y});const p=Qe(),Ct=typeof p?.computeTargets=="function",pt=Object.prototype.hasOwnProperty.call(p??{},"armHint")?p.armHint:Bn(Ct?"placement.armedPickTarget":"placement.armedPickGap",Ct?"":"Click a + between pieces to insert it.");pt&&S.getState().showInfo?.(pt),m(L,null);continue}const It=O.getState(),dt=It.selectedInstanceId,j=dt!=null?(It.productInstances||{})[dt]:null,J=j&&Number.isFinite(Number(j.sequence))?Number(j.sequence):void 0,ut=Vn({placementGroup:wt}),A=ut!=null?(It.productInstances||{})[ut]:null,Ht=A&&Number.isFinite(Number(A.sequence))?Number(A.sequence):J,nt=Array.isArray(A?.position)?A.position:[0,0,0];let jt=null;try{jt=await qt({type:Xt.PRODUCT_ADD,productGraphId:Zt,variantId:y,placementGroup:wt,sequence:Ht,replacePlacementId:ut??void 0},p=>Nt({productGraphId:p.productGraphId,variantId:p.variantId,placementGroup:p.placementGroup,position:nt,sequence:p.sequence,replace:p.replacePlacementId!=null,replacePlacementId:p.replacePlacementId}))}catch{}if(m(L,null),mt)return}})(),()=>{mt=!0}},[g,I,w,m])}function io({position:w,onClick:g}){const[m,u]=Pt(!1);return f(bn,{position:w,center:!0,style:{pointerEvents:"auto"},zIndexRange:[100,0],children:f("div",{onClick:g,onPointerEnter:()=>u(!0),onPointerLeave:()=>u(!1),style:{width:22,height:22,borderRadius:"50%",background:m?"#ff8a65":"rgba(255, 87, 34, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--bg-primary, #fff)",fontSize:13,fontWeight:"bold",boxShadow:"0 1px 4px rgba(0,0,0,0.3)",cursor:"pointer",transition:"transform 0.2s",transform:m?"scale(1.15)":"scale(1)"},children:"+"})})}function lo({isMobile:w}={}){Ke();const g=de("SelectionActionPanel",wn),m=O(t=>t.productInstances),u=K(t=>t.getProduct),i=K(t=>t.componentGroups),G=O(t=>t.clearSelection),I=O(t=>t.selectedInstanceId),r=O(t=>t.isFocusing),$=S(t=>t.bootLoading),H=S(t=>t.bootDetail),b=S(t=>t.bootProgress);Ke();const Q=de("LoadingScreen",Rn),lt=zn();N(()=>{if(typeof document>"u")return;const t=document.documentElement;return $?t.setAttribute("data-scene-booting",""):t.removeAttribute("data-scene-booting"),()=>t.removeAttribute("data-scene-booting")},[$]),N(()=>{S.getState().markUiReady?.()},[]);const mt=O(t=>t.removeProductInstance),M=O(t=>t.addProductInstance),c=O(t=>t.updateInstancePosition),L=O(t=>t.updateInstanceRotation),q=O(t=>t.activeSceneConfigId),P=z(t=>t.defaultPresetId),y=z(t=>t.sceneConfigurations),d=z(t=>t.systemId),xt=z(t=>t.useTransform),wt=S(t=>t.sceneCapabilities),Zt=S(t=>t.showWalls),gt=S(t=>t.showDimensions),It=S(t=>t.pendingSlotPlacement),dt=ro(),j=S(t=>t.hostMaterialOverrides),J=(Zn()||{}).room||null,ut=q||P||Object.keys(y||{})[0]||null;co(ut);const[A,Ht]=Pt(!0),[nt,jt]=Pt(!1),p=Y(async()=>{try{await $n()}catch{}jt(!0)},[]),{edgeOf:Ct,cornerOf:pt,isHostAnchored:Vt,isMovable:St,rawFree:po,splitReliable:ho,freeInstances:_t,ordered:x,syntheticHosts:pe,moveInFlightRef:fo}=Mn(),Tt=Z(()=>new Map(pe.map(t=>[t.hostedProductId,t])),[pe]),[bt,en]=Pt({}),Ut=Y((t,e)=>{en(n=>{const o=n[t],a=e.full||null;return o&&o.width===e.width&&o.depth===e.depth&&o.height===e.height&&o.cx===e.cx&&o.cz===e.cz&&(o.full?.width??null)===(a?.width??null)&&(o.full?.height??null)===(a?.height??null)&&(o.full?.depth??null)===(a?.depth??null)?n:{...n,[t]:{width:e.width,depth:e.depth,height:e.height,cx:e.cx,cz:e.cz,full:a}}})},[]),ot=Y(t=>bt[t]||null,[bt]),he=K(t=>t.placementBoundsExcludeIds),fe=Z(()=>new Set((he||[]).map(t=>String(t))),[he]),Bt=Y((t,e)=>{const n=t?.componentId??e?.id??e?.componentId??null;return n!=null&&fe.has(String(n))||/leg|arm/i.test(String(t?.slotKey||""))?!0:(e?.groups||e?.group_ids||[]).some(a=>{const l=i?.[a]||i?.[String(a)];return/leg|arm/i.test(String(l?.name??l?.slotKey??l?.slot_key??""))})},[i,fe]),st=Mt(!1),Ft=Mt(!1),D=x.length+_t.length,Wt=Z(()=>[...x,..._t],[x,_t]),rt=D>0&&Wt.every(t=>bt[t.productId]),Ot=Z(()=>Wt.filter(t=>bt[t.productId]).length,[Wt,bt]),{active:Yt,loaded:me,total:Kt}=yn(),ge=S(t=>t.isEvaluating),Gt=S(t=>t.isLayoutLoading),Ie=S(t=>t.bootEvaluating),Se=Mt({pieceCount:0,allMeasured:!1});Se.current={pieceCount:D,allMeasured:rt};const Lt=Y(()=>{const{pieceCount:t,allMeasured:e}=Se.current;t>0&&!st.current&&!Ft.current&&(O.getState().resetCameraToDefault?.({instant:!0}),st.current=e,Ft.current=!e)},[]);N(()=>S.subscribe((t,e)=>{e?.bootLoading&&!t.bootLoading&&Lt()}),[Lt]),N(()=>{if(!nt)return;const t=!Yt&&(Kt===0||me>=Kt),e=(rt||D===0)&&t&&!ge&&!Ie,n=()=>{Lt(),Ht(!1),S.getState().endBootLoading()};if(e){const a=setTimeout(n,900);return()=>clearTimeout(a)}const o=setTimeout(n,Yt?12e4:15e3);return()=>clearTimeout(o)},[nt,rt,D,Ot,Yt,me,Kt,ge,Ie,Lt]);const[be,ye]=Pt(!1);N(()=>{if(!A){ye(!1);return}(rt&&D>0||nt&&D===0)&&ye(!0)},[rt,D,nt,A]);const ve=nt?be||D===0?"Finishing up\u2026":`Loading products\u2026 ${Math.min(Ot,D)}/${D}`:"Preparing your configurator\u2026",Me=be?100:D>0?Math.min(Math.round(Ot/D*100),92):0;N(()=>{A&&S.getState().setBootPhase(ve,Me)},[A,ve,Me]),N(()=>(S.setState({initialSceneLoading:A}),()=>S.setState({initialSceneLoading:!1})),[A]),N(()=>{Gt&&(st.current=!1)},[Gt]),N(()=>{if(D===0){st.current=!1;return}if(st.current||A||Gt||!rt)return;const t=setTimeout(()=>{st.current||(O.getState().resetCameraToDefault?.({instant:!Ft.current}),Ft.current=!1,st.current=!0)},250);return()=>clearTimeout(t)},[D,Ot,A,Gt,rt]);const yt=Qe(),kt=Z(()=>x.map(t=>{const e=Tt.get(t.id);return e?{...t,productId:e.hostVariantId}:t}),[x,Tt]),Pe=xt||!!y?.[ut]?.useTransform,X=O(t=>t.pendingPlacementPiece),xe=!!X&&typeof yt?.computeTargets=="function"&&!!An(),at=Z(()=>{const t={getProduct:u,getDims:ot,useTransform:Pe,candidate:X,openSlots:xe,config:Je()},e=yt.computeLayout?yt.computeLayout(kt,t):kt.map(()=>({position:[0,0,0],rotation:[0,0,0]}));return Un(e,kt,t,yt)},[yt,kt,u,ot,Pe,X,xe]),V=Z(()=>{const e=J?.height>0?J.height:2.7,n=.1,o=.05,a=new Map;let l=1/0,C=-1/0,k=1/0,h=-1/0,U=0,R=!1;if(x.forEach((s,B)=>{const _=at[B];if(!_||St(s))return;const v=_.position||[0,0,0],T=ot(s.productId),W=u(s.productId),E=T?.full||T,re=E?.height>0?E.height:W?.height>0?W.height*.0254:0,Rt=(v[1]||0)+re;if(Rt>U&&(U=Rt),(s.positionedAbove??s.positioned_above)!=null)return;const ae=(v[1]||0)<=.01,zt=-((Array.isArray(_.rotation)?_.rotation[1]:0)||0),ce=T?.depth>0?T.depth:W?.depth>0?W.depth*.0254:.6,ie=T?.width>0?T.width:W?.width>0?W.width*.0254:.9,tt=Math.cos(zt),et=Math.sin(zt),Ge=T?.cx||0,Le=T?.cz||0,ke=v[0]+tt*Ge-et*Le,Ae=v[2]+et*Ge+tt*Le,De=(ie*Math.abs(tt)+ce*Math.abs(et))/2,Re=(ie*Math.abs(et)+ce*Math.abs(tt))/2,ze=ke-De,Ee=ke+De,Ne=Ae-Re,qe=Ae+Re,Xe=E?.width>0?E.width:ie,Ze=E?.depth>0?E.depth:ce,He=v[0]+tt*(E?.cx||0)-et*(E?.cz||0),je=v[2]+et*(E?.cx||0)+tt*(E?.cz||0),Ve=(Xe*Math.abs(tt)+Ze*Math.abs(et))/2,Ue=(Xe*Math.abs(et)+Ze*Math.abs(tt))/2,mn=He-Ve,gn=He+Ve,In=je-Ue,Sn=je+Ue,Be=String((Math.round(zt/(Math.PI/2))%4+4)%4),F=a.get(Be)||{heading:zt,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,fMinX:1/0,fMaxX:-1/0,fMinZ:1/0,fMaxZ:-1/0,hasFloor:!1};F.minX=Math.min(F.minX,ze),F.maxX=Math.max(F.maxX,Ee),F.minZ=Math.min(F.minZ,Ne),F.maxZ=Math.max(F.maxZ,qe),ae&&(F.fMinX=Math.min(F.fMinX,ze),F.fMaxX=Math.max(F.fMaxX,Ee),F.fMinZ=Math.min(F.fMinZ,Ne),F.fMaxZ=Math.max(F.fMaxZ,qe),F.hasFloor=!0),a.set(Be,F),l=Math.min(l,mn),C=Math.max(C,gn),k=Math.min(k,In),h=Math.max(h,Sn),R=!0}),!R)return null;const ht=Math.max(e,U>0?U+.02:e),Jt=[...a.values()].map(s=>{const B=Math.sin(s.heading),_=Math.cos(s.heading),v=B,T=-_,W=Math.abs(v)>Math.abs(T),E=s.hasFloor?s.fMinX:s.minX,re=s.hasFloor?s.fMaxX:s.maxX,Rt=s.hasFloor?s.fMinZ:s.minZ,ae=s.hasFloor?s.fMaxZ:s.maxZ,Oe=W?(v>0?re:E)+(v>0?n/2:-n/2):(T>0?ae:Rt)+(T>0?n/2:-n/2);return{g:s,isSide:W,plane:Oe}}),At=Jt.some(s=>s.g.hasFloor)?Jt.filter(s=>s.g.hasFloor):Jt,un=At.filter(s=>s.isSide).map(s=>s.plane),pn=At.filter(s=>!s.isSide).map(s=>s.plane),te=[];for(const s of At){const{g:B}=s;if(s.isSide){let _=B.minZ,v=B.maxZ;for(const T of pn)_=Math.min(_,T),v=Math.max(v,T);te.push({cx:s.plane,cz:(_+v)/2,cy:ht/2,length:v-_+o*2,thickness:n,height:ht,rotY:Math.PI/2})}else{let _=B.minX,v=B.maxX;for(const T of un)_=Math.min(_,T),v=Math.max(v,T);te.push({cx:(_+v)/2,cz:s.plane,cy:ht/2,length:v-_+o*2,thickness:n,height:ht,rotY:0})}}const Dt=.4,Fe=C>l&&h>k;let ee=l-Dt,ne=C+Dt,oe=k-Dt,se=h+Dt;for(const s of At){const B=Math.sin(s.g.heading),_=-Math.cos(s.g.heading);s.isSide?B<0?ee=s.plane-n/2:ne=s.plane+n/2:_<0?oe=s.plane-n/2:se=s.plane+n/2}const hn=Fe?{cx:(ee+ne)/2,cz:(oe+se)/2,w:ne-ee,d:se-oe}:null,fn=Fe?{minX:l,maxX:C,minZ:k,maxZ:h,w:C-l,d:h-k,h:ht,height:U>0?U:ht}:null;return{segments:te,floor:hn,bbox:fn}},[x,at,J,ot,u,St]),nn=Zt&&!!(V&&V.segments&&V.segments.length),on=gt&&!!(V&&V.bbox&&V.bbox.w>0),sn=(t,e)=>{const n=at[e]||{position:[0,0,0],rotation:[0,0,0]},o=Tt.get(t.id);if(!o)return n;const a=n.position||[0,0,0],l=(Array.isArray(n.rotation)?n.rotation[1]:0)||0,C=Math.cos(l),k=Math.sin(l),h=o.offset||[0,0,0];return{position:[a[0]+(h[0]||0)*C+(h[2]||0)*k,a[1]+(h[1]||0),a[2]-(h[0]||0)*k+(h[2]||0)*C],rotation:[0,l+(o.rotDegY||0)*Math.PI/180,0]}},ct=It,vt=!!ct,we=Z(()=>{if(!ct)return new Set;const t=new Set((ct.compatibleGraphIds||[]).map(String)),e=new Set;for(const n of Object.values(m||{})){const o=u(n.variantId)||u(n.productId),a=o?.product_graph??o?.productGraph;a!=null&&t.has(String(a))&&e.add(String(n.id))}return e},[ct,m,u]),$t=Y(()=>{S.getState().clearPendingSlotPlacement?.(),S.getState().clearPendingHostedProduct?.()},[]),Ce=Y((t,e)=>{if(!e)return;const n=K.getState(),o=n.getProduct?.(e.variantId)||n.getProduct?.(e.productId),a=o?.productGraph??o?.product_graph??null,l=O.getState().productInstances?.[String(t)],C=o?.placementGroup??o?.placement_group??l?.placementGroup??null,k=Array.isArray(l?.position)?l.position:[0,0,0],h=l?.variantId??l?.productId??null,U=Number.isFinite(Number(l?.sequence))?Number(l.sequence):void 0;$t(),qt({type:Xt.PRODUCT_ADD,productGraphId:a,variantId:e.variantId??e.productId,placementGroup:C,sequence:U,hostPlacementId:String(t),hostVariantId:h},R=>Nt({productGraphId:R.productGraphId,variantId:R.variantId,placementGroup:R.placementGroup,position:k,sequence:R.sequence,hostPlacementId:R.hostPlacementId,hostVariantId:R.hostVariantId}).catch(()=>{}))},[$t]),Qt=Y((t,e)=>{const n=K.getState(),o=n.getProduct?.(e.variantId)||n.getProduct?.(e.productId),a=o?.productGraph??o?.product_graph??null,l=o?.placementGroup??o?.placement_group??null,C=x[t-1]||x[t],k=Array.isArray(C?.position)?C.position:[0,0,0],h=x[t],U=h&&Number.isFinite(Number(h.sequence))?Number(h.sequence):void 0;qt({type:Xt.PRODUCT_ADD,productGraphId:a,variantId:e.variantId??e.productId,placementGroup:l,sequence:U},R=>Nt({productGraphId:R.productGraphId,variantId:R.variantId,placementGroup:R.placementGroup,position:k,sequence:R.sequence}).catch(()=>{}))},[x]);N(()=>{if(!X||x.length>0)return;const t=X;Ye(),Qt(0,t)},[X,x.length,Qt]);const{gaps:rn,onInsert:an}=Yn({systemId:d,count:x.length,positionOf:t=>at[t]?.position||[0,0,0],insertAt:Qt}),_e=Z(()=>{if(!X)return[];const t=K.getState();return Ln(x,{candidate:X,getProduct:e=>t.getProduct?.(e),getDims:ot,config:Je(),layout:at})},[X,x,at,ot]),cn=Y(t=>{const e=kn(t,{candidate:X});if(!e)return;const n=K.getState(),o=n.getProduct?.(e.variantId)||n.getProduct?.(e.productId),a=o?.productGraph??o?.product_graph??null,l=o?.placementGroup??o?.placement_group??null,C=e.transform?.position??t.position??[0,0,0],k=Dn(e,t,x);qt({type:Xt.PRODUCT_ADD,productGraphId:a,variantId:e.variantId??e.productId,placementGroup:l,anchor:e.anchor??null,sequence:k},h=>Nt({productGraphId:h.productGraphId,variantId:h.variantId,placementGroup:h.placementGroup,position:C,sequence:h.sequence}).catch(()=>{})),Ye()},[X,x]),{selectedInst:mo,swapOrder:go,panelActions:Te,priceInfo:ln}=Pn(),dn=xn()("selectionPanel");N(()=>{if(I==null)return;const t=m||{},e=String(I),n="__host";if(e.endsWith(n)){const o=e.slice(0,-n.length);if(t[o]||Object.values(t).some(a=>String(a?.id??a?.instanceId)===o))return}else if(t[I]||Object.values(t).some(o=>String(o?.instanceId??o?.id)===e))return;G?.()},[I,m,G]);const So=ft(t=>t.placementPricing),bo=z(t=>t.getChannelPriceConfig);return it(ue,{children:[f(On,{onSeeded:p}),it(Tn,{isMobile:w,camera:{position:[2.6,2.2,4],fov:45},controlsTarget:[0,.5,0],onPointerMissed:()=>G?.(),groundShadowCatcher:!0,overlay:it(ue,{children:[!vt&&Te&&dn?f(g,{actions:Te,priceInfo:ln}):null,vt&&f("div",{className:"placement-mode-overlay",children:it("div",{className:"placement-mode-overlay__content",children:[it("span",{className:"placement-mode-overlay__text",children:["Click on a highlighted slot to place ",f("strong",{children:ct?.name})]}),f("button",{type:"button",className:"placement-mode-overlay__cancel",onClick:$t,children:f("span",{className:"placement-mode-overlay__cancel-text",children:"Cancel"})})]})}),f(En,{name:"overlay"}),$&&f(Q,{scene:!0,message:lt("loading.message","Loading your configurator\u2026"),detail:H,progress:b}),r&&f("div",{"aria-hidden":"true",style:{position:"absolute",inset:0,zIndex:30,cursor:"default"}})]}),children:[nn&&f(Fn,{width:J?.width,depth:J?.depth,height:J?.height??V?.bbox?.h??2.7,showCeiling:wt?.ceiling===!0,segments:V?.segments||null,floor:V?.floor||null}),on&&(()=>{const t=de("SceneDimensions",Xn);return f(t,{bbox:V.bbox})})(),x.map((t,e)=>{const n=Tt.get(t.id),o=at[e]||{position:[0,0,0],rotation:[0,0,0]};return o.hidden?null:it("group",{children:[n&&f(le,{instance:{id:n.id,instanceId:n.id,productId:n.hostVariantId,variantId:n.hostVariantId,position:o.position||[0,0,0],rotation:o.rotation||[0,0,0]},slotMaterials:{...dt,...j?.[n.hostedProductId]||{},...j?.[n.id]||{}},stateInstanceId:n.hostedProductId,onSelect:()=>O.getState().selectInstance(n.id),isSelected:String(I)===String(n.id),onMeasure:a=>Ut(n.hostVariantId,a),footprintExcludeItem:Bt,hoverable:!0,focusable:!0},n.id),f(le,{instance:{...t,...sn(t,e)},slotMaterials:{...dt,...j?.[t.id]||j?.[t.instanceId]||{}},onSelect:(a,l,C)=>{if(vt){we.has(String(t.id))&&Ce(t.id,ct);return}O.getState().selectInstance(a,C??null)},isSelected:!vt&&String(I)===String(t.instanceId??t.id),onMeasure:a=>Ut(t.productId,a),footprintExcludeItem:Bt,hoverable:!0,focusable:!0}),vt&&we.has(String(t.id))&&f(io,{position:[o.position?.[0]||0,(o.position?.[1]||0)+.45,o.position?.[2]||0],onClick:()=>Ce(t.id,ct)})]},t.id??t.instanceId??e)}),_t.map((t,e)=>f(Cn,{selected:I===t.id,disabled:!!t.locked,position:t.position||[0,0,0],rotationY:(Array.isArray(t.rotation)&&t.rotation[1]||0)*Math.PI/180,gizmoOffset:(()=>{const n=ot(t.productId);return[n?.cx||0,0,n?.cz||0]})(),onCommit:({position:n,rotationY:o})=>{c(t.id,n),L(t.id,[0,o*180/Math.PI,0]),Kn({allowRevert:!0}).catch(()=>{})},children:f(le,{instance:{...t,position:[0,0,0],rotation:[0,0,0]},slotMaterials:{...dt,...j?.[t.id]||j?.[t.instanceId]||{}},onMeasure:n=>Ut(t.productId,n),footprintExcludeItem:Bt})},t.id??t.instanceId??`free-${e}`)),_e.length>0?f(Gn,{targets:_e,onPick:cn}):f(_n,{gaps:rn,onInsert:an})]})]})}const tn=new Set;function uo(){to();const w=z(r=>r.systemLayoutTemplate),g=z(r=>r.systemTheme),m=z(r=>r.systemThemeRecord);so(g,m);const u=oo(m)||(g?String(g).trim().toLowerCase():null);let i=w;try{const r=new URLSearchParams(window.location.search);r.has("template")?i=r.get("template"):r.has("theme")&&(i=r.get("theme"))}catch{}i=i||w||u||null;const G=eo();G&&(i=G),!G&&!w&&i&&i===u&&!Jn(i)&&!/^theme\d+$/.test(i)&&!tn.has(i)&&tn.add(i),no(i);const I=Qn(i);return it(ue,{children:[f(I,{Scene:lo,template:i}),f(Nn,{}),f(qn,{})]})}export{lo as SharedConfiguratorScene,uo as default};
|
|
1
|
+
import{Fragment as le,jsx as m,jsxs as dt}from"react/jsx-runtime";import{useCallback as J,useEffect as N,useMemo as H,useRef as Mt,useState as xt,useSyncExternalStore as We}from"react";import{Html as yn,useProgress as vn}from"@react-three/drei";import _ from"./9c6c598569.js";import W from"./872c4302e0.js";import R from"./be337ddda5.js";import gt from"./d94df858ea.js";import{normalizeMaterialTargets as Pn}from"./dc2a1a0e13.js";import y from"./8f60e5059a.js";import Mn from"./60d697292c.js";import xn from"./811b403d43.js";import{useUiToggles as wn}from"./d0f9681634.js";import{ProductInstance as ce,SelectionActionPanel as Cn,FreeMovable as _n,PlacementGaps as Tn,SceneStage as Fn,SceneRoom as Gn,SceneProductsSource as On}from"./8a3a57c008.js";import An from"./205827c5c8.js";import{computeTargets as Dn,resolveTarget as Ln,resolveTargetRenderer as kn,resolveInsertSequence as zn}from"./58e6419ba8.js";import{disarmPlacement as Ye}from"./ab6c80484f.js";import{isCompatibleSlot as $e}from"./99577e3161.js";import{resolveComponent as ie,useComponentRegistry as Ke}from"./882bc739c8.js";import Rn from"./88251d6671.js";import{useLabels as En}from"./28d887bf8a.js";import{SlotHost as qn}from"./73f7d65985.js";import{ModalHost as Nn}from"./09c4973968.js";import Xn from"./6c0a2572dd.js";import Zn from"./20b0104576.js";import{getConfigState as Hn,subscribe as Qe,getVersion as Et}from"./817d930a49.js";import{getPlacementStrategy as Je}from"./281cf952fa.js";import{resolveAddMode as Vn,armPlacement as jn}from"./ab6c80484f.js";import{resolveReplaceTarget as Un}from"./4d7a0d1897.js";import{enforceCorners as Bn}from"./388cadacbd.js";import{resolvePlacementStrategyConfig as tn}from"./281cf952fa.js";import{getLabel as Wn}from"./28d887bf8a.js";import{isAddFeature as Yn}from"./8c27edda0f.js";import{usePlacementInteraction as $n}from"./4b8958aa4c.js";import{refreshCanonicalState as Kn,seedInitialState as Qn,addProduct as qt}from"./a77b15c0d6.js";import{resolveLayout as Jn,hasLayout as to,useLayoutRegistry as eo,layoutOverride as no,_publishResolvedLayoutKey as oo}from"./31ea036f5c.js";import{themeLayoutKey as so,useSystemTheme as ro}from"./5c9fd9201c.js";import"./1a2629800a.css";import{runIntent as Nt,INTENTS as Xt}from"./6d238282c1.js";function ao(){const T=gt(c=>c.sceneSelections),S=gt(c=>c.selectionOrder),g=_(c=>c.activeSceneConfigId),h=R(c=>c.defaultPresetId),f=R(c=>c.sceneConfigurations),D=R(c=>c.getSceneFeatures),b=We(Qe,Et,Et);return H(()=>{const c=g||h||Object.keys(f||{})[0],tt=c?D(c):[],V=W.getState(),v=[],et=new Set,ut=(l,L)=>{if(!l||l.id==null||et.has(String(l.id))||L>4)return;et.add(String(l.id)),v.push(l);const w=(V.features?.[l.id]||V.features?.[String(l.id)])?.childOptionSetIds||[];for(const M of w){const d=V.features?.[M]||V.features?.[String(M)];d&&ut({id:M,type:d.type,sequence:d.sequence},L+1)}};for(const l of tt)ut(l,0);const It=v.filter(l=>/finish/i.test(l.type||"")&&T[l.id]!=null).sort((l,L)=>{const X=S?.[String(l.id)]??-1,w=S?.[String(L.id)]??-1;return X!==w?X-w:(l.sequence??0)-(L.sequence??0)}),P={};for(const l of It){const L=T[l.id],X=V.options?.[L]?.value;if(X==null)continue;const w=V.features?.[l.id]||{},M=Pn(w.materialTargets??w.material_targets??w.materials);for(const d of M)P[String(d).toLowerCase()]=X}return P},[T,S,g,h,f,D,b])}function co(T,S){if(S==null)return null;const g=String(S);for(const h of Object.values(T.products||{})){const f=h?.components_configuration||h?.componentsConfiguration;if(!(!f||typeof f!="object"))for(const D of Object.values(f))for(const b of Array.isArray(D)?D:[D]){const c=b&&typeof b=="object"?b.componentId??b.component_id:b;if(c!=null&&String(c)===g)return h}}return null}function io(T){const S=gt(v=>v.sceneSelections),g=gt(v=>v.setSceneSelection),h=R(v=>v.getSceneFeatures),f=R(v=>v.sceneConfigurations),D=We(Qe,Et,Et),b=H(()=>new Set((T?h(T)||[]:[]).filter(v=>Yn(v)).map(v=>String(v.id))),[T,h,f,D]),c=Mt({}),tt=Mt(!1),V=gt(v=>v.sceneSelectionsSettled);N(()=>{if(!V){c.current={...S};return}if(!tt.current){tt.current=!0;let P=!1;for(const[l,L]of Object.entries(S||{}))L==null||!b.has(String(l))||(g(l,null),P=!0);if(P){c.current={...S};return}}const v=c.current,et=[];for(const[P,l]of Object.entries(S||{}))v[P]===l||l==null||b.has(String(P))&&et.push([P,l]);if(c.current={...S},!et.length)return;const ut=R.getState().systemId;let It=!1;return(async()=>{const P=W.getState(),l=_.getState();for(const[L,X]of et){const w=P.options?.[X];let M=w?.valueProductVariantId??w?.value_product_variant_id??w?.value_product_variant??w?.variantId??w?.variant_id??null,d=M!=null?P.getProduct?.(M):null;if(d==null){const I=w?.value??(P.optionToProducts?.[String(X)]||[])[0]??w?.product_id??w?.productId??null;d=I!=null?P.getProduct?.(I):null,d==null&&I!=null&&P.getComponent?.(I)&&(d=co(P,I)),M=d?.id??M??I}else M=d?.id??M;if(M==null){g(L,null);continue}const wt=d?.id??M,Ct=d?.placementGroup??d?.placement_group??null,Zt=d?.productGraph??d?.product_graph??null,St=d?.compatibleSlots??d?.compatible_slots??null;if(Array.isArray(St)&&St.length){const I=new Set(St.map(String));if(Object.values(l.productInstances||{}).some(ft=>{const de=P.getProduct?.(ft.variantId)||P.getProduct?.(ft.productId);return $e(d,de,P.products)})){y.getState().setPendingSlotPlacement?.({productId:wt,variantId:M,name:d?.name??d?.displayName??d?.variantName??"product",compatibleGraphIds:Array.from(I)}),g(L,null);continue}}if(Vn(ut,d)==="arm"){jn({productId:wt,variantId:M});const I=Je(),_t=typeof I?.computeTargets=="function",ft=Object.prototype.hasOwnProperty.call(I??{},"armHint")?I.armHint:Wn(_t?"placement.armedPickTarget":"placement.armedPickGap",_t?"":"Click a + between pieces to insert it.");ft&&y.getState().showInfo?.(ft),g(L,null);continue}const bt=_.getState(),pt=bt.selectedInstanceId,j=pt!=null?(bt.productInstances||{})[pt]:null,nt=j&&Number.isFinite(Number(j.sequence))?Number(j.sequence):void 0,ht=Un({placementGroup:Ct}),z=ht!=null?(bt.productInstances||{})[ht]:null,Ht=z&&Number.isFinite(Number(z.sequence))?Number(z.sequence):nt,ct=Array.isArray(z?.position)?z.position:[0,0,0];let Vt=null;try{Vt=await Nt({type:Xt.PRODUCT_ADD,productGraphId:Zt,variantId:M,placementGroup:Ct,sequence:Ht,replacePlacementId:ht??void 0},I=>qt({productGraphId:I.productGraphId,variantId:I.variantId,placementGroup:I.placementGroup,position:ct,sequence:I.sequence,replace:I.replacePlacementId!=null,replacePlacementId:I.replacePlacementId}))}catch{}if(g(L,null),It)return}})(),()=>{It=!0}},[S,b,T,g])}function lo({position:T,onClick:S}){const[g,h]=xt(!1);return m(yn,{position:T,center:!0,style:{pointerEvents:"auto"},zIndexRange:[100,0],children:m("div",{onClick:S,onPointerEnter:()=>h(!0),onPointerLeave:()=>h(!1),style:{width:22,height:22,borderRadius:"50%",background:g?"#ff8a65":"rgba(255, 87, 34, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--bg-primary, #fff)",fontSize:13,fontWeight:"bold",boxShadow:"0 1px 4px rgba(0,0,0,0.3)",cursor:"pointer",transition:"transform 0.2s",transform:g?"scale(1.15)":"scale(1)"},children:"+"})})}function uo({isMobile:T}={}){Ke();const S=ie("SelectionActionPanel",Cn),g=_(t=>t.productInstances),h=W(t=>t.getProduct),f=W(t=>t.componentGroups),D=_(t=>t.clearSelection),b=_(t=>t.selectedInstanceId),c=_(t=>t.isFocusing),tt=y(t=>t.bootLoading),V=y(t=>t.bootDetail),v=y(t=>t.bootProgress);Ke();const et=ie("LoadingScreen",Rn),ut=En();N(()=>{if(typeof document>"u")return;const t=document.documentElement;return tt?t.setAttribute("data-scene-booting",""):t.removeAttribute("data-scene-booting"),()=>t.removeAttribute("data-scene-booting")},[tt]),N(()=>{y.getState().markUiReady?.()},[]);const It=_(t=>t.removeProductInstance),P=_(t=>t.addProductInstance),l=_(t=>t.updateInstancePosition),L=_(t=>t.updateInstanceRotation),X=_(t=>t.activeSceneConfigId),w=R(t=>t.defaultPresetId),M=R(t=>t.sceneConfigurations),d=R(t=>t.systemId),wt=R(t=>t.useTransform),Ct=y(t=>t.sceneCapabilities),Zt=y(t=>t.showWalls),St=y(t=>t.showDimensions),bt=y(t=>t.pendingSlotPlacement),pt=ao(),j=y(t=>t.hostMaterialOverrides),nt=(Hn()||{}).room||null,ht=X||w||Object.keys(M||{})[0]||null;io(ht);const[z,Ht]=xt(!0),[ct,Vt]=xt(!1),I=J(async()=>{try{await Qn()}catch{}Vt(!0)},[]),{edgeOf:_t,cornerOf:ft,isHostAnchored:de,isMovable:ue,rawFree:ho,splitReliable:fo,freeInstances:Tt,ordered:C,syntheticHosts:pe,moveInFlightRef:mo}=Mn(),Ft=H(()=>new Map(pe.map(t=>[t.hostedProductId,t])),[pe]),[ot,nn]=xt({}),jt=J((t,e,n=null)=>{const o=(r,a)=>{const i=r[a],u=e.full||null;return i&&i.width===e.width&&i.depth===e.depth&&i.height===e.height&&i.cx===e.cx&&i.cz===e.cz&&(i.full?.width??null)===(u?.width??null)&&(i.full?.height??null)===(u?.height??null)&&(i.full?.depth??null)===(u?.depth??null)?r:{...r,[a]:{width:e.width,depth:e.depth,height:e.height,cx:e.cx,cz:e.cz,full:u,forProductId:t,...e.__slots?{slots:e.__slots}:{}}}};nn(r=>{const a=o(r,t);return n!=null?o(a,`inst:${n}`):a})},[]),st=J((t,e)=>{const n=e?.id!=null?ot[`inst:${e.id}`]:null;return n&&String(n.forProductId)===String(t)?n:ot[t]||null},[ot]),he=W(t=>t.placementBoundsExcludeIds),fe=H(()=>new Set((he||[]).map(t=>String(t))),[he]),Ut=J((t,e)=>{const n=t?.componentId??e?.id??e?.componentId??null;if(n!=null&&fe.has(String(n)))return!0},[f,fe]),Y=Mt(!1),Gt=Mt(!1),k=C.length+Tt.length,Bt=H(()=>[...C,...Tt],[C,Tt]),it=k>0&&Bt.every(t=>ot[t.productId]),Ot=H(()=>Bt.filter(t=>ot[t.productId]).length,[Bt,ot]),{active:Wt,loaded:me,total:Yt}=vn(),ge=y(t=>t.isEvaluating),At=y(t=>t.isLayoutLoading),Ie=y(t=>t.bootEvaluating),Se=Mt({pieceCount:0,allMeasured:!1});Se.current={pieceCount:k,allMeasured:it};const Dt=J(()=>{const{pieceCount:t,allMeasured:e}=Se.current;t>0&&!Y.current&&!Gt.current&&(_.getState().resetCameraToDefault?.({instant:!0}),Y.current=e,Gt.current=!e)},[]);N(()=>y.subscribe((t,e)=>{e?.bootLoading&&!t.bootLoading&&Dt()}),[Dt]),N(()=>{if(!ct)return;const t=!Wt&&(Yt===0||me>=Yt),e=(it||k===0)&&t&&!ge&&!Ie,n=()=>{Dt(),Ht(!1),y.getState().endBootLoading()};if(e){let r=null;const a=setTimeout(()=>{k>0&&!Y.current&&(_.getState().resetCameraToDefault?.({instant:!0}),Y.current=!0),r=setTimeout(n,120)},780);return()=>{clearTimeout(a),r&&clearTimeout(r)}}const o=setTimeout(n,Wt?12e4:15e3);return()=>clearTimeout(o)},[ct,it,k,Ot,Wt,me,Yt,ge,Ie,Dt]);const[be,ye]=xt(!1);N(()=>{if(!z){ye(!1);return}(it&&k>0||ct&&k===0)&&ye(!0)},[it,k,ct,z]);const ve=ct?be||k===0?"Finishing up\u2026":`Loading products\u2026 ${Math.min(Ot,k)}/${k}`:"Preparing your configurator\u2026",Pe=be?100:k>0?Math.min(Math.round(Ot/k*100),92):0;N(()=>{z&&y.getState().setBootPhase(ve,Pe)},[z,ve,Pe]),N(()=>(y.setState({initialSceneLoading:z}),()=>y.setState({initialSceneLoading:!1})),[z]),N(()=>{At&&(Y.current=!1)},[At]),N(()=>{if(k===0){Y.current=!1;return}if(Y.current||z||At||!it)return;const t=setTimeout(()=>{Y.current||(_.getState().resetCameraToDefault?.({instant:!Gt.current}),Gt.current=!1,Y.current=!0)},250);return()=>clearTimeout(t)},[k,Ot,z,At,it]);const yt=Je(),mt=H(()=>C.map(t=>{const e=Ft.get(t.id);return e?{...t,productId:e.hostVariantId}:t}),[C,Ft]),Me=wt||!!M?.[ht]?.useTransform,Z=_(t=>t.pendingPlacementPiece),xe=!!Z&&typeof yt?.computeTargets=="function"&&!!kn(),lt=H(()=>{const t={getProduct:h,getDims:st,useTransform:Me,candidate:Z,openSlots:xe,config:tn()},e=yt.computeLayout?yt.computeLayout(mt,t):mt.map(()=>({position:[0,0,0],rotation:[0,0,0]})),n=Bn(e,mt,t,yt);try{import.meta.env?.DEV&&typeof window<"u"&&(window.__layoutDebug={at:Date.now(),dims:ot,items:mt.map(o=>({id:o.id,variantId:o.variantId,productId:o.productId,placementGroup:o.placementGroup,sequence:o.sequence,positionedAbove:o.positionedAbove??null,hostVariantId:o.hostVariantId??null,position:o.position,rotation:o.rotation,corner:!!o.corner})),layout:n})}catch{}return n},[yt,mt,h,st,Me,Z,xe,ot]),U=H(()=>{const e=nt?.height>0?nt.height:2.7,n=.1,o=.05,r=new Map;let a=1/0,i=-1/0,u=1/0,p=-1/0,E=0,A=!1;if(C.forEach((s,B)=>{const F=lt[B];if(!F||ue(s))return;const x=F.position||[0,0,0],G=st(s.productId,s),Q=h(s.productId),q=G?.full||G,oe=q?.height>0?q.height:Q?.height>0?Q.height*.0254:0,zt=(x[1]||0)+oe;if(zt>E&&(E=zt),(s.positionedAbove??s.positioned_above)!=null)return;const se=(x[1]||0)<=.01,Rt=-((Array.isArray(F.rotation)?F.rotation[1]:0)||0),re=G?.depth>0?G.depth:Q?.depth>0?Q.depth*.0254:.6,ae=G?.width>0?G.width:Q?.width>0?Q.width*.0254:.9,rt=Math.cos(Rt),at=Math.sin(Rt),Oe=G?.cx||0,Ae=G?.cz||0,De=x[0]+rt*Oe-at*Ae,Le=x[2]+at*Oe+rt*Ae,ke=(ae*Math.abs(rt)+re*Math.abs(at))/2,ze=(ae*Math.abs(at)+re*Math.abs(rt))/2,Re=De-ke,Ee=De+ke,qe=Le-ze,Ne=Le+ze,Xe=q?.width>0?q.width:ae,Ze=q?.depth>0?q.depth:re,He=x[0]+rt*(q?.cx||0)-at*(q?.cz||0),Ve=x[2]+at*(q?.cx||0)+rt*(q?.cz||0),je=(Xe*Math.abs(rt)+Ze*Math.abs(at))/2,Ue=(Xe*Math.abs(at)+Ze*Math.abs(rt))/2,gn=He-je,In=He+je,Sn=Ve-Ue,bn=Ve+Ue,Be=String((Math.round(Rt/(Math.PI/2))%4+4)%4),O=r.get(Be)||{heading:Rt,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,fMinX:1/0,fMaxX:-1/0,fMinZ:1/0,fMaxZ:-1/0,hasFloor:!1};O.minX=Math.min(O.minX,Re),O.maxX=Math.max(O.maxX,Ee),O.minZ=Math.min(O.minZ,qe),O.maxZ=Math.max(O.maxZ,Ne),se&&(O.fMinX=Math.min(O.fMinX,Re),O.fMaxX=Math.max(O.fMaxX,Ee),O.fMinZ=Math.min(O.fMinZ,qe),O.fMaxZ=Math.max(O.fMaxZ,Ne),O.hasFloor=!0),r.set(Be,O),a=Math.min(a,gn),i=Math.max(i,In),u=Math.min(u,Sn),p=Math.max(p,bn),A=!0}),!A)return null;const K=Math.max(e,E>0?E+.02:e),Pt=[...r.values()].map(s=>{const B=Math.sin(s.heading),F=Math.cos(s.heading),x=B,G=-F,Q=Math.abs(x)>Math.abs(G),q=s.hasFloor?s.fMinX:s.minX,oe=s.hasFloor?s.fMaxX:s.maxX,zt=s.hasFloor?s.fMinZ:s.minZ,se=s.hasFloor?s.fMaxZ:s.maxZ,Ge=Q?(x>0?oe:q)+(x>0?n/2:-n/2):(G>0?se:zt)+(G>0?n/2:-n/2);return{g:s,isSide:Q,plane:Ge}}),Lt=Pt.some(s=>s.g.hasFloor)?Pt.filter(s=>s.g.hasFloor):Pt,pn=Lt.filter(s=>s.isSide).map(s=>s.plane),hn=Lt.filter(s=>!s.isSide).map(s=>s.plane),Qt=[];for(const s of Lt){const{g:B}=s;if(s.isSide){let F=B.minZ,x=B.maxZ;for(const G of hn)F=Math.min(F,G),x=Math.max(x,G);Qt.push({cx:s.plane,cz:(F+x)/2,cy:K/2,length:x-F+o*2,thickness:n,height:K,rotY:Math.PI/2})}else{let F=B.minX,x=B.maxX;for(const G of pn)F=Math.min(F,G),x=Math.max(x,G);Qt.push({cx:(F+x)/2,cz:s.plane,cy:K/2,length:x-F+o*2,thickness:n,height:K,rotY:0})}}const kt=.4,Fe=i>a&&p>u;let Jt=a-kt,te=i+kt,ee=u-kt,ne=p+kt;for(const s of Lt){const B=Math.sin(s.g.heading),F=-Math.cos(s.g.heading);s.isSide?B<0?Jt=s.plane-n/2:te=s.plane+n/2:F<0?ee=s.plane-n/2:ne=s.plane+n/2}const fn=Fe?{cx:(Jt+te)/2,cz:(ee+ne)/2,w:te-Jt,d:ne-ee}:null,mn=Fe?{minX:a,maxX:i,minZ:u,maxZ:p,w:i-a,d:p-u,h:K,height:E>0?E:K}:null;return{segments:Qt,floor:fn,bbox:mn}},[C,lt,nt,st,h,ue]),on=Zt&&!!(U&&U.segments&&U.segments.length),sn=St&&!!(U&&U.bbox&&U.bbox.w>0),rn=(t,e)=>{const n=lt[e]||{position:[0,0,0],rotation:[0,0,0]},o=Ft.get(t.id);if(!o)return n;const r=n.position||[0,0,0],a=(Array.isArray(n.rotation)?n.rotation[1]:0)||0,i=Math.cos(a),u=Math.sin(a),p=o.offset||[0,0,0];return{position:[r[0]+(p[0]||0)*i+(p[2]||0)*u,r[1]+(p[1]||0),r[2]-(p[0]||0)*u+(p[2]||0)*i],rotation:[0,a+(o.rotDegY||0)*Math.PI/180,0]}},$=bt,vt=!!$,we=H(()=>{if(!$)return new Set;const t=h($.variantId)||h($.productId)||null,e=W.getState().products,n=new Set;for(const o of Object.values(g||{})){const r=h(o.variantId)||h(o.productId);(t?$e(t,r,e):(()=>{const i=new Set(($.compatibleGraphIds||[]).map(String)),u=r?.product_graph??r?.productGraph;return u!=null&&i.has(String(u))})())&&n.add(String(o.id))}return n},[$,g,h]),$t=J(()=>{y.getState().clearPendingSlotPlacement?.(),y.getState().clearPendingHostedProduct?.()},[]),Ce=J((t,e)=>{if(!e)return;const n=W.getState(),o=n.getProduct?.(e.variantId)||n.getProduct?.(e.productId),r=o?.productGraph??o?.product_graph??null,a=_.getState().productInstances?.[String(t)],i=o?.placementGroup??o?.placement_group??a?.placementGroup??null,u=Array.isArray(a?.position)?a.position:[0,0,0],p=a?.variantId??a?.productId??null,E=Number.isFinite(Number(a?.sequence))?Number(a.sequence):void 0;$t(),Nt({type:Xt.PRODUCT_ADD,productGraphId:r,variantId:e.variantId??e.productId,placementGroup:i,sequence:E,hostPlacementId:String(t),hostVariantId:p},A=>qt({productGraphId:A.productGraphId,variantId:A.variantId,placementGroup:A.placementGroup,position:u,sequence:A.sequence,hostPlacementId:A.hostPlacementId,hostVariantId:A.hostVariantId}).catch(()=>{}))},[$t]),Kt=J((t,e)=>{const n=W.getState(),o=n.getProduct?.(e.variantId)||n.getProduct?.(e.productId),r=o?.productGraph??o?.product_graph??null,a=o?.placementGroup??o?.placement_group??null,i=C[t-1]||C[t],u=Array.isArray(i?.position)?i.position:[0,0,0],p=C[t],E=p&&Number.isFinite(Number(p.sequence))?Number(p.sequence):void 0;Nt({type:Xt.PRODUCT_ADD,productGraphId:r,variantId:e.variantId??e.productId,placementGroup:a,sequence:E},A=>qt({productGraphId:A.productGraphId,variantId:A.variantId,placementGroup:A.placementGroup,position:u,sequence:A.sequence}).catch(()=>{}))},[C]);N(()=>{if(!Z||C.length>0)return;const t=Z;Ye(),Kt(0,t)},[Z,C.length,Kt]);const{gaps:an,onInsert:cn}=$n({systemId:d,count:C.length,positionOf:t=>lt[t]?.position||[0,0,0],insertAt:Kt}),_e=H(()=>{if(!Z)return[];const t=W.getState();return Dn(C,{candidate:Z,getProduct:e=>t.getProduct?.(e),getDims:st,config:tn(),layout:lt})},[Z,C,lt,st]),ln=J(t=>{const e=Ln(t,{candidate:Z});if(!e)return;const n=W.getState(),o=n.getProduct?.(e.variantId)||n.getProduct?.(e.productId),r=o?.productGraph??o?.product_graph??null,a=o?.placementGroup??o?.placement_group??null,i=e.transform?.position??t.position??[0,0,0],u=zn(e,t,C);Nt({type:Xt.PRODUCT_ADD,productGraphId:r,variantId:e.variantId??e.productId,placementGroup:a,anchor:e.anchor??null,sequence:u},p=>qt({productGraphId:p.productGraphId,variantId:p.variantId,placementGroup:p.placementGroup,position:i,sequence:p.sequence}).catch(()=>{})),Ye()},[Z,C]),{selectedInst:go,swapOrder:Io,panelActions:Te,priceInfo:dn}=xn(),un=wn()("selectionPanel");N(()=>{if(b==null)return;const t=g||{},e=String(b),n="__host";if(e.endsWith(n)){const o=e.slice(0,-n.length);if(t[o]||Object.values(t).some(r=>String(r?.id??r?.instanceId)===o))return}else if(t[b]||Object.values(t).some(o=>String(o?.instanceId??o?.id)===e))return;D?.()},[b,g,D]);const bo=gt(t=>t.placementPricing),yo=R(t=>t.getChannelPriceConfig);return dt(le,{children:[m(On,{onSeeded:I}),dt(Fn,{isMobile:T,camera:{position:[2.6,2.2,4],fov:45},controlsTarget:[0,.5,0],onPointerMissed:()=>D?.(),groundShadowCatcher:!0,overlay:dt(le,{children:[!vt&&Te&&un?m(S,{actions:Te,priceInfo:dn}):null,vt&&m("div",{className:"placement-mode-overlay",children:dt("div",{className:"placement-mode-overlay__content",children:[dt("span",{className:"placement-mode-overlay__text",children:["Click on a highlighted slot to place ",m("strong",{children:$?.name})]}),m("button",{type:"button",className:"placement-mode-overlay__cancel",onClick:$t,children:m("span",{className:"placement-mode-overlay__cancel-text",children:"Cancel"})})]})}),m(qn,{name:"overlay"}),tt&&m(et,{scene:!0,message:ut("loading.message","Loading your configurator\u2026"),detail:V,progress:v}),c&&m("div",{"aria-hidden":"true",style:{position:"absolute",inset:0,zIndex:30,cursor:"default"}})]}),children:[on&&m(Gn,{width:nt?.width,depth:nt?.depth,height:nt?.height??U?.bbox?.h??2.7,showCeiling:Ct?.ceiling===!0,segments:U?.segments||null,floor:U?.floor||null}),sn&&(()=>{const t=ie("SceneDimensions",Zn);return m(t,{bbox:U.bbox})})(),C.map((t,e)=>{const n=Ft.get(t.id),o=lt[e]||{position:[0,0,0],rotation:[0,0,0]};return o.hidden?null:dt("group",{children:[n&&m(ce,{instance:{id:n.id,instanceId:n.id,productId:n.hostVariantId,variantId:n.hostVariantId,position:o.position||[0,0,0],rotation:o.rotation||[0,0,0]},slotMaterials:{...pt,...j?.[n.hostedProductId]||{},...j?.[n.id]||{}},stateInstanceId:n.hostedProductId,onSelect:()=>_.getState().selectInstance(n.id),isSelected:String(b)===String(n.id),onMeasure:r=>jt(n.hostVariantId,r),footprintExcludeItem:Ut,hoverable:!0,focusable:!0},n.id),m(ce,{instance:{...t,...rn(t,e)},slotMaterials:{...pt,...j?.[t.id]||j?.[t.instanceId]||{}},onSelect:(r,a,i)=>{if(vt){we.has(String(t.id))&&Ce(t.id,$);return}_.getState().selectInstance(r,i??null)},isSelected:!vt&&String(b)===String(t.instanceId??t.id),onMeasure:r=>jt(t.productId,r,t.id),footprintExcludeItem:Ut,hoverable:!0,focusable:!0}),vt&&we.has(String(t.id))&&(()=>{const r=o.position||[0,0,0],a=st(mt[e]?.productId??t.productId,t),i=(Array.isArray(o.rotation)?o.rotation[1]:0)||0,u=Math.cos(i),p=Math.sin(i),E=a?.cx||0,A=a?.cz||0,K=a?.full?.height??a?.height,Pt=[r[0]+E*u+A*p,r[1]+(K>0?K/2:.45),r[2]-E*p+A*u];return m(lo,{position:Pt,onClick:()=>Ce(t.id,$)})})()]},t.id??t.instanceId??e)}),Tt.map((t,e)=>m(_n,{selected:b===t.id,disabled:!!t.locked,position:t.position||[0,0,0],rotationY:(Array.isArray(t.rotation)&&t.rotation[1]||0)*Math.PI/180,gizmoOffset:(()=>{const n=st(t.productId,t);return[n?.cx||0,0,n?.cz||0]})(),onCommit:({position:n,rotationY:o})=>{l(t.id,n),L(t.id,[0,o*180/Math.PI,0]),Kn({allowRevert:!0}).catch(()=>{})},children:m(ce,{instance:{...t,position:[0,0,0],rotation:[0,0,0]},slotMaterials:{...pt,...j?.[t.id]||j?.[t.instanceId]||{}},onMeasure:n=>jt(t.productId,n,t.id),footprintExcludeItem:Ut})},t.id??t.instanceId??`free-${e}`)),_e.length>0?m(An,{targets:_e,onPick:ln}):m(Tn,{gaps:an,onInsert:cn})]})]})}const en=new Set;function po(){eo();const T=R(c=>c.systemLayoutTemplate),S=R(c=>c.systemTheme),g=R(c=>c.systemThemeRecord);ro(S,g);const h=so(g)||(S?String(S).trim().toLowerCase():null);let f=T;try{const c=new URLSearchParams(window.location.search);c.has("template")?f=c.get("template"):c.has("theme")&&(f=c.get("theme"))}catch{}f=f||T||h||null;const D=no();D&&(f=D),!D&&!T&&f&&f===h&&!to(f)&&!/^theme\d+$/.test(f)&&!en.has(f)&&en.add(f),oo(f);const b=Jn(f);return dt(le,{children:[m(b,{Scene:uo,template:f}),m(Nn,{}),m(Xn,{})]})}export{uo as SharedConfiguratorScene,po as default};
|
package/dist/921bf270dd.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import*as p from"three";import
|
|
2
|
-
`)}const
|
|
1
|
+
import*as p from"three";import Z from"./8f60e5059a.js";import ae from"./9c6c598569.js";import be from"./d94df858ea.js";import le from"./872c4302e0.js";import ce,{deriveSceneFeatures as De}from"./be337ddda5.js";import y,{ASSET_IDS as j}from"./3f37665dd1.js";import{canvasToDataUrl as ot}from"./97abcad34e.js";import{refreshAiQuota as at,aiQuotaBlock as Fe,aiQuotaBlockText as $e,aiQuotaImageBudget as rt,aiQuotaPartialText as nt}from"./2f8cc8b292.js";import{imageAsDataUrl as st,captureAndWarm as Ve}from"./0e2dedae0d.js";import{useEffect as it,useRef as lt}from"react";import{runIntent as ct,INTENTS as dt}from"./6d238282c1.js";import{registerBuiltinCommand as ut,COMMANDS as ft}from"./d6851ea979.js";import{uploadReferenceImage as pt,generateImage as mt,generationErrorMessage as gt}from"./d7c9500ba9.js";import{getR3FState as Ge}from"./e1cd279733.js";import{isStructureConsistent as ht,buildStructureSignature as wt,scoreAgainstSignature as yt}from"./2239b22616.js";import{generateARModel as St}from"./f7b4a178e3.js";import{FRONT_VIEW_POSITION as vt,VIEW_PRESETS as bt,PERSPECTIVE_VIEW_DIR as Ne,PERSPECTIVE_VIEW_DIR_LEFT as xt}from"./23dc0ccf32.js";import{dataUrlToFile as _t}from"./00ab3dcbb5.js";import{isHostFloating as Ct,isHostedProduct as Tt}from"./061b81ad81.js";import{isAddFeature as Et}from"./8c27edda0f.js";const O={mood:["modern warm minimalist","Scandinavian","mid-century modern","luxurious contemporary","farmhouse","Japandi","industrial-chic","coastal","quiet contemporary","warm traditional","soft brutalist","eclectic collected"],floor:["wide oak plank floors","light ash floors","herringbone walnut floors","polished concrete floors","reclaimed timber floors","pale oak floors","dark stained timber floors","whitewashed plank floors","large-format stone tiles","warm terracotta tiles"],walls:["off-white walls","warm greige walls","soft taupe walls","cream walls with exposed beams","pale blue-grey walls","chalky white plaster walls","muted sage walls","limewashed clay walls","warm beige walls","deep charcoal feature wall behind"],light:["warm pendants overhead","soft diffused daylight","low warm recessed lighting","bright even daylight","warm late-afternoon light raking across the floor","soft overcast daylight","warm wall sconces","gentle ambient light with soft shadows"],furnishing:["a defocused dining table with mismatched chairs at the side","a defocused low bench with a stone tea set","a defocused reading chair and floor lamp at the rear","a defocused sideboard with ceramics beyond a doorway","a defocused rattan nook at the side","a defocused console table with stacked books","a defocused upholstered bench at the rear","a defocused open shelving unit with pottery to one side"],greenery:["a fiddle-leaf fig in a woven basket","an olive tree in a terracotta pot","a monstera in a ribbed planter","a snake plant in a concrete pot","trailing pothos on a high shelf","a small bonsai on a side counter","eucalyptus stems in a stoneware vase","a potted fern on the floor"],detail:["framed art on an empty wall","a jute rug underfoot","a linen runner and a ceramic bowl","a stack of art books","a woven throw over a chair back","a stoneware jug with wildflowers","a flat-weave runner rug","a pair of hand-thrown vases"]},J=(n,r=Math.random)=>n[Math.floor(r()*n.length)];function Le(n,r={}){const a=r.rng||Math.random,o=new Set([n?.productLabel||"",...(n?.pieces||[]).map(l=>l.name)].join(" ").toLowerCase().match(/[a-z]+/g)||[]),e=l=>(l.toLowerCase().match(/[a-z]+/g)||[]).some(g=>g.length>3&&o.has(g)),m=O.furnishing.filter(l=>!e(l)),i=r.avoidMood?O.mood.filter(l=>l!==r.avoidMood):O.mood,s=J(i.length?i:O.mood,a),c=[J(O.floor,a),J(O.walls,a),J(O.light,a),m.length?J(m,a):null,J(O.greenery,a),J(O.detail,a)].filter(Boolean);return{mood:s,text:`${s}: ${c.join(", ")}`}}function At(){const n=be.getState().sceneSelections||{},r=le.getState().options||{},a=le.getState().materials||{},o=le.getState().products||{},e=ae.getState().activeSceneConfigId,i=(ce.getState().sceneConfigurations||{})[e],s=ce.getState(),c=ae.getState().productInstances||{},l=De(i)||[],g=[];let d=null,h=null;for(const f of l){if(Et(f,{productSelected:!1}))continue;const v=n[f.id]??n[f.feature_id]??n[String(f.id)];if(v==null)continue;const t=r[v]||r[String(v)];if(!t)continue;const C=(t.value!=null?a[t.value]||a[String(t.value)]:null)?.color||t.color_hex||null,I=String(f.type||"").toLowerCase();I==="layout_change"&&(d=t.name||null,h=t.value||null),g.push({feature:f.name||f.feature_id||f.id,value:t.name||String(t.value??""),colorHex:C,type:I})}const _=f=>{const v=o[f?.variantId]||o[f?.productId]||o[String(f?.variantId)]||o[String(f?.productId)];return{name:String(v?.name||f?.name||"part"),product:v}},A=new Map;let w=!1,S=!1;for(const f of Object.values(c)){const{name:v,product:t}=_(f);A.set(v,(A.get(v)||0)+1),t&&Ct(t)&&(w=!0),t&&Tt(t)&&(S=!0)}const k=[...A.entries()].map(([f,v])=>({name:f,count:v})).sort((f,v)=>v.count-f.count);return{productLabel:s.systemName||s.systemRoom?.name||k[0]?.name||"product",selections:g,pieces:k,hasWallMountedParts:w,hasHostedParts:S,layoutName:d,layoutType:h}}function kt(n){const r=[`${n.productLabel} \u2014 Product Master:`];for(const a of n.selections||[])r.push(`\u2022 ${a.feature}: ${a.value}${a.colorHex?` (${a.colorHex})`:""}`);return n.pieces&&n.pieces.length&&r.push(`\u2022 Parts: ${n.pieces.map(a=>`${a.count} ${a.name}`).join(", ")}`),r.join(`
|
|
2
|
+
`)}const ze=(n,r,a)=>{const o=r.productLabel||"product",e=r.hasWallMountedParts?`
|
|
3
3
|
|
|
4
4
|
WALLS (CRITICAL): The reference image shows the ${o} ALONE, with no room around it \u2014 you must BUILD the walls. Every wall-mounted part must end up against a continuous solid wall directly behind it \u2014 wall-mounted parts DO NOT FLOAT. The wall surface continues above and beside each one to the ceiling. Windows, doorways, archways, and open passages are ONLY allowed on wall sections that have NO mounted parts. The wall continues past the outer edge of any tall/end part to the room corner \u2014 do not crop the frame at that edge or place another room beside it, and keep a clean material boundary where a part meets the wall.`:"";return`TASK: Place the EXACT ${o} from the reference image into a styled, lived-in interior \u2014 ${n}. The ${o} is the hero object; the room around it is secondary context.
|
|
5
5
|
|
|
6
|
-
PRESERVE pixel-faithful from the reference: every part, panel/surface design, hardware, colour, material, proportion, and layout exactly as shown.${
|
|
6
|
+
PRESERVE pixel-faithful from the reference: every part, panel/surface design, hardware, colour, material, proportion, and layout exactly as shown.${e}
|
|
7
7
|
|
|
8
8
|
EDIT: only the room around the ${o} \u2014 flooring, ceiling lighting, defocused furniture at the side or rear, plants, decor, framed art on an empty wall, a window on an empty wall.
|
|
9
9
|
|
|
@@ -11,10 +11,10 @@ CAMERA: front-facing catalog shot, 28mm full-frame, eye level, the ${o} 70-85% o
|
|
|
11
11
|
|
|
12
12
|
${a}
|
|
13
13
|
|
|
14
|
-
NEGATIVE: any part not in the reference, added parts, removed parts, replaced product, substituted design, altered materials or colours, moved or resized parts, distorted geometry, rotation, mirroring, scaling, empty/unfurnished room, fisheye, 3D render look, CGI look, cartoonish, illustration, cropped or partial ${o}, different camera angle, wide architectural shot, clutter obscuring the ${o}, a second ${o} in the scene, a duplicate ${o} in the background${r.hasWallMountedParts?", floating wall-mounted parts, wall-mounted parts in mid-air, missing wall behind mounted parts, window or open passage behind mounted parts, frame cropped at a part edge":""}`};function
|
|
14
|
+
NEGATIVE: any part not in the reference, added parts, removed parts, replaced product, substituted design, altered materials or colours, moved or resized parts, distorted geometry, rotation, mirroring, scaling, empty/unfurnished room, fisheye, 3D render look, CGI look, cartoonish, illustration, cropped or partial ${o}, different camera angle, wide architectural shot, clutter obscuring the ${o}, a second ${o} in the scene, a duplicate ${o} in the background${r.hasWallMountedParts?", floating wall-mounted parts, wall-mounted parts in mid-air, missing wall behind mounted parts, window or open passage behind mounted parts, frame cropped at a part edge":""}`};function It(){const n=be.getState().sceneSelections,r=ae.getState().activeSceneConfigId,o=(ce.getState().sceneConfigurations||{})[r],e=De(o).find(s=>s.type==="layout_change");if(!e)return!1;const m=n[e.id];return le.getState().options[m]?.value==="galley"}function Mt(){const n=be.getState().sceneSelections||{},r=ae.getState(),a=Z.getState(),o=r.productInstances||{},e=Object.entries(o).map(([m,i])=>({id:m,v:i?.variantId??i?.productId??null,seq:i?.sequence??null,g:i?.placementGroup??i?.placement_group??null}));return JSON.stringify({sceneSelections:n,pieces:e,componentStates:r.componentStates||{},hostMaterialOverrides:a.hostMaterialOverrides||{}})}const oo=st;function ao(n=2){return new Promise(r=>{const a=o=>{if(o<=0){r();return}requestAnimationFrame(()=>a(o-1))};a(n)})}function Oe(n){const r=new p.Box3;return n.traverse(a=>{if(!a.isMesh||!a.visible)return;const o=a.material;if(!(o&&o.transparent&&o.opacity<.01))try{const e=new p.Box3().setFromObject(a);if(!isFinite(e.min.x)||!isFinite(e.max.x))return;const m=e.max.x-e.min.x,i=e.max.y-e.min.y,s=e.max.z-e.min.z;if(m>20||i>10||s>20)return;r.union(e)}catch{}}),r.isEmpty()?null:r}function Rt(n,r,a,o=45){const e=Oe(n);if(!e||!r)return null;const m=o*Math.PI/180/2;if(m<=0)return null;const i=new p.Vector3;e.getCenter(i);const s=new p.Vector3;if(r.getWorldDirection(s),!isFinite(s.x)||s.lengthSq()===0)return null;s.normalize();const c=new p.Vector3().crossVectors(s,r.up).normalize();if(c.lengthSq()===0)return null;const l=new p.Vector3().crossVectors(c,s).normalize(),g=Math.tan(m),d=g*a;let h=1.8;const _=new p.Vector3;for(let w=0;w<8;w++){_.set(w&1?e.max.x:e.min.x,w&2?e.max.y:e.min.y,w&4?e.max.z:e.min.z).sub(i);const S=-_.dot(s);h=Math.max(h,S+Math.abs(_.dot(c))/d,S+Math.abs(_.dot(l))/g)}h*=1.06;const A=i.clone().addScaledVector(s.clone().negate(),h);return{position:[A.x,A.y,A.z],target:[i.x,i.y,i.z],up:[r.up.x,r.up.y,r.up.z]}}function Pt(n,r,a=45,o="front"){const e=Oe(n);if(!e)return null;const m=new p.Vector3;e.getCenter(m);const i=new p.Vector3;e.getSize(i);const s=a*Math.PI/180/2;if(s<=0)return null;let c;const l=1.5;if(o==="front"){const w=i.y/2*l,S=i.x/2*l,k=w/Math.tan(s),W=S/(Math.tan(s)*r);c=Math.max(k,W,1.8)}else if(o==="side"){const w=i.y/2*l,S=i.z/2*l,k=w/Math.tan(s),W=S/(Math.tan(s)*r);c=Math.max(k,W,1.8)}else{const w=Math.max(i.length()*.5,.5),S=w/Math.sin(s),k=w/Math.sin(Math.atan(Math.tan(s)*r));c=Math.max(S,k,1.8)*1.15}const g={front:new p.Vector3(0,.15,1),side:new p.Vector3(-1,.2,0),perspective:new p.Vector3(...Ne),perspective_left:new p.Vector3(...xt),perspective_right:new p.Vector3(...Ne),top:new p.Vector3(0,1,0)},d=(g[o]||g.front).clone().normalize(),h=m.clone();o!=="top"&&(h.y=m.y*.92);const _=m.clone().addScaledVector(d,c),A=o==="top"?[0,0,-1]:[0,1,0];return{position:[_.x,_.y,_.z],target:[h.x,h.y,h.z],up:A}}async function Dt(n,r){const a=Ge()||n?.__r3f?.store?.getState();if(!a)return{};const{scene:o,gl:e,camera:m}=a,i=e.domElement,s=m.fov||45,c=1536,l=1152,g=c/l,d={},h=new p.PerspectiveCamera(s,g,.1,1e3),_=r||bt,A=e.getRenderTarget(),w=e.getSize(new p.Vector2),S=e.getPixelRatio(),k=o.background,W=e.getClearColor(new p.Color),f=e.getClearAlpha(),v=e.autoClear,t=a.frameloop;a.setFrameloop?.("never"),o.background=null,e.setClearColor(16777215,1),e.autoClear=!0;const U=new p.WebGLRenderTarget(c,l,{minFilter:p.LinearFilter,magFilter:p.LinearFilter,format:p.RGBAFormat,type:p.UnsignedByteType,colorSpace:p.SRGBColorSpace}),C=document.createElement("canvas");C.width=c,C.height=l;const I=C.getContext("2d"),M=new Uint8Array(c*l*4),R=I.createImageData(c,l);try{for(const P of _){try{let F=P.position,$=P.target,H=[0,1,0];if(P.liveAngle)try{const x=Rt(o,m,g,s);x&&(F=x.position,$=x.target,H=x.up||H)}catch{}else if(P.autoFit)try{const x=Pt(o,g,s,P.key);x&&(F=x.position,$=x.target,H=x.up||H)}catch{}h.position.set(...F),h.up.set(...H),h.lookAt(new p.Vector3(...$)),h.updateMatrixWorld(!0),e.setRenderTarget(U),e.setSize(c,l,!1),e.render(o,h),e.readRenderTargetPixels(U,0,0,c,l,M);for(let x=0;x<l;x++){const de=(l-x-1)*c*4,xe=x*c*4;R.data.set(M.subarray(de,de+c*4),xe)}I.putImageData(R,0,0),d[P.key]=C.toDataURL("image/jpeg",.9)}catch{d[P.key]=null}await new Promise(F=>setTimeout(F,0))}}finally{U.dispose(),o.background=k,e.setClearColor(W,f),e.autoClear=v,e.setRenderTarget(A),e.setPixelRatio(S),e.setSize(w.x,w.y,!1),e.render(o,m),a.setFrameloop?.(t??"demand"),a.invalidate?.()}return d}function Ft({openModal:n,setCameraPosition:r}={}){const a=Z(t=>t.openModal),o=ae(t=>t.setCameraPosition),e=n??a,m=r??o,i=y(t=>t.setScreenshot),s=y(t=>t.setScreenshotViews),c=y(t=>t.setUploadStatus),l=y(t=>t.setAiGenerationStatus),g=y(t=>t.setPipelineMessage),d=y(t=>t.updateAsset),h=y(t=>t.startSlowProgress),_=y(t=>t.startPdfFakeProgress),A=y(t=>t.setUploadedImageUrl),w=y(t=>t.isGenerating),S=y(t=>t.setIsGenerating),k=({wantSilo:t,wantLifestyle:U,wantAr:C,wantPdf:I})=>[...t?j.silo:[],...U?j.lifestyle:[],...C?["ar-viewer"]:[],...I?["bom-pdf"]:[]],W=async(t={})=>{const U=t.silent===!0,C=()=>{U||e("generateAssets")},I=Array.isArray(t.families)&&t.families.length?t.families:["silo","lifestyle","ar","pdf"];let M=I.includes("silo"),R=I.includes("lifestyle");const P=I.includes("ar"),F=I.includes("pdf"),$=y.getState(),H=Mt();if($.isGenerating){const T=k({wantSilo:M,wantLifestyle:R,wantAr:P,wantPdf:F}).filter(b=>$.assets.find(D=>D.id===b)?.status==="idle");C();return}const x=k({wantSilo:M,wantLifestyle:R,wantAr:P,wantPdf:F});if($._lastConfigSnapshot===H&&x.every(T=>{const b=$.assets.find(D=>D.id===T)?.status;return b==="complete"||b==="blocked"})){C();return}I.length===4&&$.resetAssets(),S(!0),$.setLastConfigSnapshot(H);let ee=null;const te=[...M?j.silo:[],...R?j.lifestyle:[]];if(te.length){const T=await at();y.getState().setAiQuota(T);const b=Fe(T),D=b?0:rt(T);if(!b&&te.length>D&&(ee=new Set(te.slice(0,D)),te.slice(D).forEach(V=>d(V,{status:"blocked",progress:0,error:nt(D)})),j.silo.some(V=>ee.has(V))||(M=!1),j.lifestyle.some(V=>ee.has(V))||(R=!1),C()),b&&(te.forEach(V=>d(V,{status:"blocked",progress:0,error:$e(b)})),M=!1,R=!1,C(),!P&&!F)){S(!1);return}}const ue=T=>!ee||ee.has(T),fe=[...M?j.silo:[],...R?j.lifestyle:[]].filter(ue);fe.forEach(T=>d(T,{status:"generating",progress:0,error:null})),C();const We=Z.getState().showWalls,Ue=Z.getState().showDimensions,$t=It();Z.setState({showWalls:!1,showDimensions:!1,captureMode:!0}),setTimeout(async()=>{const T=document.querySelector(".scene-canvas canvas");if(!T){fe.forEach(q=>d(q,{status:"idle",progress:0,error:null})),S(!1);return}const b=await Dt(T,[{key:"front",liveAngle:!0,position:vt,target:[0,1,0],label:"Front"}]),D=b.front||ot(T,{type:"image/jpeg",quality:.9});if(i(D),Z.setState({showWalls:We,showDimensions:Ue,captureMode:!1}),P){d("ar-viewer",{status:"generating",progress:0,error:null});const q=Ge()?.scene??null;if(!q)d("ar-viewer",{status:"error",progress:0,error:"3D scene not ready \u2014 open the configurator first, then click generate again."});else try{St({scene:q,onProgress:E=>{d("ar-viewer",{progress:E})},onComplete:E=>{d("ar-viewer",{status:"complete",progress:100,url:E})},onError:E=>{d("ar-viewer",{status:"error",progress:0,error:E||"AR generation failed"})}})}catch(E){d("ar-viewer",{status:"error",progress:0,error:E?.message||"AR generation failed"})}}const V=Date.now().toString(36),pe=[];let _e=null,me=!1;try{g("Processing data..."),c("in_progress",0);const q=b.front||b.perspective||b.side||b.top||D,E=M||R?[{key:"front",dataUrl:q}]:[],X={},Ce=E.length;let B=0;[5,10,15,20,25,28].forEach((u,N)=>{const Y=setTimeout(()=>{if(me)return;const L=y.getState().uploadProgress;u>L&&c("in_progress",u)},(N+1)*1e3);pe.push(Y)}),await Promise.all(E.map(async({key:u,dataUrl:N})=>{const Y=`${u}_${V}.jpg`,L=_t(N,Y),{url:he}=await pt(L);X[u]=he,B++,c("in_progress",Math.round(B/Ce*100))})),me=!0,pe.forEach(clearTimeout);for(const u of Object.keys(b))b[u]=null;_e=await wt((E.find(u=>u.key==="front")||{}).dataUrl||null);for(const u of E)u.dataUrl=null;c("complete",100),A(X.front),g("Generating Content"),l("in_progress"),fe.forEach(u=>h(u)),F&&(_(),y.getState()._checkPdfNotStranded?.({lifestyleRequested:R,siloRequested:M}));const He="1024x768",G=At(),ge=kt(G),re=G.productLabel||"product",qe=re,Be=G.layoutName||null,Qe=G.layoutType||null,Te=`3D render look, CGI look, modified ${re}, changed layout, added or removed parts, altered materials or colours, moved or resized parts, distorted geometry, rotation, mirroring, scaling, cropped or partial ${re}, different camera angle, wide architectural shot, clutter, obstruction`,Ee=`${Te}, room background, walls, floor pattern, ceiling, lighting fixtures, plants, props`,je=`${Te}${G.hasWallMountedParts?", floating wall-mounted parts, missing wall behind mounted parts, window or open passage behind mounted parts":""}`,Ye=`TASK: Take the ${re} from the reference image and upgrade ONLY the surface materials to be photorealistic \u2014 real wood grain with subtle natural imperfections, real metallic anisotropy on any metal, real stone veining and slight specular highlights on any stone, real fabric weave on any upholstery. Remove any 3D-render or CGI look on the surfaces.
|
|
15
15
|
|
|
16
16
|
EVERYTHING ELSE STAYS IDENTICAL TO THE REFERENCE: same background, same camera angle, same framing, same part count, same positions, same design of every part, same colours, same proportions, same layout, same lighting direction. Do NOT add or remove any part or accessory. Do NOT change the camera angle, perspective, or zoom. Do NOT add walls, floors, decor, lighting fixtures, plants, or props. Do NOT replace the background. The output and the reference must look like the SAME image with only the materials re-rendered as real photographic textures.
|
|
17
17
|
|
|
18
|
-
${
|
|
18
|
+
${ge}
|
|
19
19
|
|
|
20
|
-
NEGATIVE: any element not in the reference, added parts, removed parts, different camera angle, perspective change, replaced background, added decoration, room background, walls, floor pattern, lighting fixtures, plants, accessories, props, colour shift, layout change, 3D render look, CGI look, cartoonish, illustration, ${
|
|
20
|
+
NEGATIVE: any element not in the reference, added parts, removed parts, different camera angle, perspective change, replaced background, added decoration, room background, walls, floor pattern, lighting fixtures, plants, accessories, props, colour shift, layout change, 3D render look, CGI look, cartoonish, illustration, ${Ee}`,Ae=Le(G),Je=Le(G,{avoidMood:Ae.mood}),Xe=ze(Ae.text,G,ge),Ke=ze(Je.text,G,ge),{setAssetGenParams:Ze}=y.getState(),ke=async(u,N,Y,L,he,et=null)=>{const we=u.startsWith("silo-"),Ie=u.startsWith("lifestyle-"),Me=we,Re=.72,ne=Me?3:Ie?2:1;let oe=he,Pe=!1,ye=N;const se=async Q=>{if(we&&L){const ie=await Ve(L);return d(u,{status:"complete",progress:100,url:L,dataUrl:ie,source:"reference-render",validated:!1,reason:Q}),L}return d(u,{status:"error",progress:0,error:"Generation failed. Try again."}),null};for(let Q=1;Q<=ne;Q++){const ie={assetId:u,systemId:ce.getState().systemId??null,attempt:Q,productName:qe,productDescription:ye,imageUrl:L,allowedAngles:Y,size:et||He,imageStrength:oe,negativePrompt:we?Ee:je,layoutType:Qe,layoutName:Be};Ze(u,ie);try{const z=await mt(ie),K=z.images[0].url;if(Me){const Se=await yt(_e,K),ve=ht(Se,Re);if(ve===null&&(Pe=!0),ve===!1&&Q<ne){oe=Math.min(.98,oe+.04),ye=`${N} [STRICT] Preserve the geometry and placement of every part exactly. Do not alter any part's width, height, spacing, or position.`;continue}if(ve===!1&&Q>=ne)return await se(`Consistency floor reached (last score=${Se?.toFixed?.(3)??Se}, threshold=${Re})`)}const tt=await Ve(K);return d(u,{status:"complete",progress:100,url:K,dataUrl:tt,source:"generated",validated:!Pe}),z.quota&&y.getState().setAiQuota(z.quota),K}catch(z){if(z?.isQuota){z.quota&&y.getState().setAiQuota(z.quota);const K=Fe(z.quota)||{code:"limit_reached"};return d(u,{status:"blocked",progress:0,error:$e(K)}),null}if(z?.isDeadReference)return await se("Reference render expired");if(Q>=ne)return await se("API error on final attempt");oe=Math.min(.98,oe+.04),Ie&&(ye=`${N} [RETRY \u2014 STRICT] Preserve the geometry, layout, and every part exactly as in the reference. Only generate the room background. Match the catalog photography style precisely.`)}}return await se("Exhausted all attempts")};await Promise.all([...M&&ue("silo-front")?[ke("silo-front",Ye,["silo_front"],X.front,.94)]:[],...R?[...[["lifestyle-1",Xe,["lifestyle_1"]],["lifestyle-2",Ke,["lifestyle_2"]]].filter(([u])=>ue(u)).map(([u,N,Y])=>ke(u,N,Y,X.front,.85,"1536x1152"))]:[]]),l("complete"),g("Content generated successfully"),S(!1)}catch(q){me=!0,pe.forEach(clearTimeout);const{uploadStatus:E}=y.getState();E!=="complete"?(c("error"),g("Failed to upload screenshot")):(l("error"),g("Content generation failed"));const X=gt(q,"Generation failed before this asset started.");y.getState().assets.filter(B=>B.status==="generating").map(B=>B.id).forEach(B=>d(B,{status:"error",progress:0,error:X})),S(!1)}},500)},f=t=>ct({type:dt.ASSETS_GENERATE,families:t?.families??null},()=>W(t)),v=lt(null);return v.current=f,it(()=>ut(ft.GENERATE_ASSETS,t=>v.current?.(t)),[]),{handleGenerateAssets:f,isGenerating:w}}export{oo as _imageAsDataUrl,kt as buildProductMasterText,At as buildSceneJson,Dt as captureMultipleViews,Ft as default,Pt as getAutoFitCamera,Mt as getConfigSnapshot,Rt as getLiveAngleCamera,It as isGalleyLayout,Le as pickBackdrop,ao as waitForRenderFrames};
|
package/dist/9526094bb7.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import S from"./8f60e5059a.js";import w from"./872c4302e0.js";import L,{deriveSceneFeatures as b}from"./be337ddda5.js";import D from"./9c6c598569.js";import N from"./d94df858ea.js";import{extractHostedProductsFromProducts as W,placeHostedProductsFromList as j}from"./37addc7fb3.js";import{isWallCornerProduct as R}from"./5e4f2349ff.js";import{FEATURE_ROLES as u,FEATURE_TYPES as x,findFeatureByType as Y,pickToggleOption as $,roleSelectionsToFeatureIds as U}from"./f8cb80a93c.js";import{normalizeLayoutConfig as z}from"./bb719febc6.js";function k(a,y,O){if(!a)return{color:null,materialId:null};if(a.startsWith("#"))return{color:a,materialId:null};const f=y[a];if(!f)return{color:null,materialId:null};const o=f.value||null;return{color:(o?O[o]:null)?.color||f.color||f.color_hex||null,materialId:o}}function
|
|
1
|
+
import S from"./8f60e5059a.js";import w from"./872c4302e0.js";import L,{deriveSceneFeatures as b}from"./be337ddda5.js";import D from"./9c6c598569.js";import N from"./d94df858ea.js";import{extractHostedProductsFromProducts as W,placeHostedProductsFromList as j}from"./37addc7fb3.js";import{isWallCornerProduct as R}from"./5e4f2349ff.js";import{FEATURE_ROLES as u,FEATURE_TYPES as x,findFeatureByType as Y,pickToggleOption as $,roleSelectionsToFeatureIds as U}from"./f8cb80a93c.js";import{normalizeLayoutConfig as z}from"./bb719febc6.js";import{isAddFeature as M}from"./8c27edda0f.js";function k(a,y,O){if(!a)return{color:null,materialId:null};if(a.startsWith("#"))return{color:a,materialId:null};const f=y[a];if(!f)return{color:null,materialId:null};const o=f.value||null;return{color:(o?O[o]:null)?.color||f.color||f.color_hex||null,materialId:o}}function G(a,y,O,f){const o={finishes:{},materials:{},styles:{},handleTypes:{},hardwareFinishes:{}},d=s=>O[s]?.value??s,p=(s,l,m,{fillOnly:H=!1}={})=>{const E=(e,i)=>{i==null||i===""||H&&o[e][s]!=null||(o[e][s]=i)},_=l||{};if(_[u.PIECE_FINISH]){const{color:e,materialId:i}=k(_[u.PIECE_FINISH],O,f);E("finishes",e),E("materials",i)}m&&E("materials",m),_[u.DOOR_STYLE]&&E("styles",d(_[u.DOOR_STYLE])),_[u.HANDLE_TYPE]&&E("handleTypes",d(_[u.HANDLE_TYPE])),_[u.HARDWARE_FINISH]&&E("hardwareFinishes",d(_[u.HARDWARE_FINISH]))},t="island",c={corner:0,[t]:0},r=(s,l)=>{const m=s.type||"base";return m==="corner"?`corner-${c.corner++}`:m===t?`${t}-part-${c[t]++}`:`${m}-${l}`},n=a.map((s,l)=>r(s,l));a.forEach((s,l)=>p(n[l],s.selections,s.materialId));const g=c[t],h=y?.freePieceConfig;if(h&&g>0){p(t,h.selections,null,{fillOnly:!0});for(let s=0;s<g;s++){const l=`${t}-part-${s}`;for(const m of Object.keys(o))o[m][l]==null&&o[m][t]!=null&&(o[m][l]=o[m][t])}}else if(g>0){const s=a.find(l=>(l.type||"base")===t);s&&p(t,s.selections,s.materialId)}const F=S.getState(),P={},T={finishes:"hostFinishes",materials:"hostMaterials",styles:"hostStyles",handleTypes:"hostHandleTypes",hardwareFinishes:"hostHardwareFinishes"};for(const[s,l]of Object.entries(T))Object.keys(o[s]).length>0&&(P[l]={...F[l],...o[s]});const C={};return a.forEach((s,l)=>{s.product_id&&(C[n[l]]=s.product_id)}),{stylingUpdate:P,overridesToRestore:C}}function V(a,y,O){const f=S.getState(),o={finishes:{},materials:{},styles:{},handleTypes:{},hardwareFinishes:{}},d=c=>y[c]?.value??c;a.forEach((c,r)=>{const n=`wcorner-${r}`,g=c.selections||{};if(g[u.PIECE_FINISH]){const{color:h,materialId:F}=k(g[u.PIECE_FINISH],y,O);h&&(o.finishes[n]=h),F&&(o.materials[n]=F)}c.materialId&&(o.materials[n]=c.materialId),g[u.DOOR_STYLE]&&(o.styles[n]=d(g[u.DOOR_STYLE])),g[u.HANDLE_TYPE]&&(o.handleTypes[n]=d(g[u.HANDLE_TYPE])),g[u.HARDWARE_FINISH]&&(o.hardwareFinishes[n]=d(g[u.HARDWARE_FINISH]))});const p={},t={finishes:"hostFinishes",materials:"hostMaterials",styles:"hostStyles",handleTypes:"hostHandleTypes",hardwareFinishes:"hostHardwareFinishes"};for(const[c,r]of Object.entries(t))Object.keys(o[c]).length>0&&(p[r]={...f[r],...o[c]});Object.keys(p).length>0&&S.setState(p)}function B(a,y,O,f){const o=()=>S.getState().clearSceneLoading(),d=()=>{y.length>0?setTimeout(()=>{j(y)},400):o()};if(a.length>0){let p=0;const t=()=>{if(p>=a.length){V(a,O,f),setTimeout(()=>{const{pieceConfigSnapshot:r}=S.getState();r&&S.getState().setInitialPieceConfigSnapshot(r)},400),setTimeout(d,300);return}const c=a[p];S.setState({pendingWallCornerAdd:{productId:c.product_id}}),p++,setTimeout(t,300)};t()}else setTimeout(d,300)}function ie(a,y){const O=w.getState().options,f=L.getState().sceneConfigurations,o=L.getState().originalSceneConfigurations,d=N.getState().setSceneSelection,p=D.getState().initializeScene,t=S.getState();D.getState().resetCameraToDefault(),t.clearHostedProducts(),t.clearHostWidths(),t.clearHostDoorTypes(),t.clearHostProductOverrides(),t.clearHostFinishes(),t.clearHostStyles(),t.clearHostHandleTypes(),t.clearHostHardwareFinishes(),t.clearDisabledWalls(),t.clearSelectedFeature(),S.setState({_snapshotOverridesOnLoadComplete:!0,isLayoutLoading:!0,pieceOverlapDetected:!1,tallWallOverlapDetected:!1,wallPieceOverlapDetected:!1,wallPieceHostedOverlapDetected:!1,overlappingPieces:[],islandOverlapDetected:!1,skipWallPieceOverlapCheck:!0,cornerOverflowDetected:!1,wallOverflowDetected:!1,wallOverflowRecenterMode:!1,wallOverflowSuppressUntil:Date.now()+1500}),t.setFreePiecePosition(null),t.setFreePieceRotation(null),y.forEach(e=>{e.type!=="layout_change"&&(e.default_option_id&&!M(e)?d(e.id,e.default_option_id):d(e.id,null))});const c=()=>(S.setState({isSceneLoading:!1,sceneLoadingMessage:null,isLayoutLoading:!1}),!1),r=O[a];if(!r)return c();let n=null;for(const[e,i]of Object.entries(f)){const I=i?.scene_option_id??i?.sceneOptionId;if(I!=null&&String(I)===String(a)){n=e;break}}if(!n){const e=[r.value,r.valueText,r.value_text,a].filter(i=>i!=null).map(String);for(const i of e)if(f[i]){n=i;break}}if(!n){let e=r.value??r.valueText??r.value_text;if(!e&&Array.isArray(r.rules))for(const i of r.rules){const I=i?.effectParams??i?.effect_params??{},v=I.layout??I.value??I.variant_key;if(v){e=v;break}}if(!e&&r.name&&(e=String(r.name).trim().toLowerCase().replace(/[\s-]+/g,"_")),e){const i=`scene_config_${e}_internal`;f[i]&&(n=i)}}if(!n||!f[n])return c();const g=o[n]||f[n],h=z(g,b(g),U),F=h?.products||[],P=h?.freePieceConfig?.product_id||[],T=[...F,...P],{pendingHostedProducts:C}=W(T),s=T.filter(R),l=T.filter(e=>!R(e)),m=l.some(e=>e.type==="island")||P.length>0,H=Y(b(h),x.FREE_PIECE);if(H){const e=$(H,O,{on:m,tier:h?.freePieceConfig?.tier??null});e!=null&&d(H.id,e)}if(h?.freePieceConfig){const e=h.freePieceConfig;e.tier&&t.setFreePieceTier(e.tier),e.width&&t.setFreePieceWidthOption(e.width)}for(const[e,i]of Object.entries(h?.default_scene_selections||{}))i!=null&&d(e,i);const E=o[n];E&&L.setState(e=>({sceneConfigurations:{...e.sceneConfigurations,[n]:E}})),p(n);const _=C.length>0||s.length>0||F.some(e=>e.selections&&Object.keys(e.selections).length>0||e.materialId);setTimeout(_?()=>{const e=w.getState().options,i=w.getState().materials,{stylingUpdate:I,overridesToRestore:v}=G(l,h,e,i);if(Object.keys(I).length>0&&S.setState(I),Object.keys(v).length>0){const A=S.getState().hostProductOverrides;S.setState({hostProductOverrides:{...A,...v}})}B(s,C,e,i)}:()=>{S.getState().clearSceneLoading()},600)}export{ie as executeLayoutChange,k as resolveFinish,G as restorePieceStyling};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const n="#ffffff";function u(t,o={}){const{background:f=n,type:r="image/jpeg",quality:h=.9}=o;if(!t||!t.width||!t.height)return"";if(r==="image/png")try{return t.toDataURL(r)}catch{return""}try{const e=document.createElement("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");return i?(i.fillStyle=f,i.fillRect(0,0,e.width,e.height),i.drawImage(t,0,0),e.toDataURL(r,h)):t.toDataURL(r,h)}catch{try{return t.toDataURL(r,h)}catch{return""}}}var g=u;export{u as canvasToDataUrl,g as default};
|
package/dist/98f3644031.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fragment as fe,jsx as e,jsxs as
|
|
1
|
+
import{Fragment as fe,jsx as e,jsxs as b}from"react/jsx-runtime";import{Suspense as U,useEffect as j,useRef as x,useSyncExternalStore as W}from"react";import{getSceneAccessGranted as A,subscribeSceneAccess as _}from"./87f511c4a8.js";import*as F from"three";import{Canvas as Q,useThree as L}from"@react-three/fiber";import{setSceneContext as T,disposeSceneExtras as q}from"./95a44ebec2.js";import{PerspectiveCamera as J,OrbitControls as K}from"@react-three/drei";import X from"./be337ddda5.js";import O from"./8f60e5059a.js";import"./9c6c598569.js";import Y from"./d4378d9afa.js";import Z from"./00a41227ff.js";import $ from"./28a9d58274.js";import ee from"./8db8655f21.js";import{rememberRenderer as te}from"./b59b0dde17.js";import oe from"./14c83bc57a.js";import{applyEnvironmentToRenderer as re,RENDERER_DEFAULTS as G}from"./4e7d0a0d4a.js";import{setR3FState as z}from"./e1cd279733.js";import{computeTopDownView as ne,computeFitView as ie,ORTHO_FOV as B}from"./85af90fade.js";const V=(t,o)=>t?o:Math.max(o,1e5);function ae({defaultPosition:t,fov:o,controlsRef:a,controlsTarget:p,maxDistance:c}){const{scene:f,size:m,invalidate:h}=L(),u=O(r=>r.is3D)!==!1,g=x(),w=x(u),D=x(!1);return j(()=>{const r=g.current,n=a?.current;if(!r)return;const R=w.current;w.current=u;const C=!D.current;D.current=!0;const y=m.width/Math.max(m.height,1);if(n&&(n.maxDistance=V(u,c)),!u){const i=ne({scene:f,aspect:y,fov:B});if(!i)return;r.fov=B,r.position.set(i.position[0],i.position[1],i.position[2]),r.updateProjectionMatrix(),n&&(n.target.set(i.target[0],i.target[1],i.target[2]),n.update()),h?.();return}if(R&&!C){r.updateProjectionMatrix(),h?.();return}r.fov=o;const S=R?null:ie({scene:f,aspect:y,fov:o}),v=S?.position||t,M=S?.target||p;r.position.set(v[0],v[1],v[2]),r.updateProjectionMatrix(),n&&(n.target.set(M[0],M[1],M[2]),n.update()),h?.()},[u,f,m.width,m.height]),e(J,{ref:g,makeDefault:!0,position:t,fov:o})}function se(){const{gl:t,scene:o,camera:a,invalidate:p}=L(),c=W(_,A,()=>!1);return j(()=>(z({gl:t,scene:o,camera:a}),c?T({THREE:F,scene:o,camera:a,renderer:t,invalidate:p}):T(null),()=>{q(),T(null),z(null)}),[t,o,a,c]),null}function ce({background:t="#f4f4f5"}){return b(fe,{children:[e("color",{attach:"background",args:[t]}),e("ambientLight",{intensity:.7}),e("directionalLight",{position:[4,6,4],intensity:1.1,castShadow:!0,"shadow-mapSize-width":1024,"shadow-mapSize-height":1024})]})}function ue({env:t}){return!!t&&Object.keys(t).length>0?null:b("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.001,0],receiveShadow:!0,children:[e("circleGeometry",{args:[21,64]}),e("shadowMaterial",{transparent:!0,opacity:.28,color:"#000000"})]})}function pe({children:t,overlay:o,isMobile:a=!1,is3D:p,camera:c={position:[2.6,2.2,4],fov:45},controlsTarget:f=[0,.5,0],renderCamera:m=!0,renderControls:h=!0,minDistance:u=1.2,maxDistance:g=14,orbitProps:w,renderFallbackLighting:D=!0,fallbackBackground:r="#f4f4f5",groundShadowCatcher:n=!1,fallback:R=null,dpr:C=[1,2],shadows:y=!0,frameloop:S,canvasStyle:v,onPointerMissed:M,onCreated:i}){const k=x(),P=X(s=>s.systemEnvironment),H=O(s=>s.is3D),I=O(s=>s.captureMode)===!0,E=p??H!==!1,l=P&&Object.keys(P).length>0?P:null,N=V(E,g);return b("div",{className:"scene-canvas",style:{position:"relative",width:"100%",height:"100%"},children:[b(Q,{shadows:y,dpr:C,...S?{frameloop:S}:{},style:{width:"100%",height:"100%",...v||{}},onPointerMissed:M,onCreated:s=>{const{gl:d}=s;te(d),d.outputColorSpace=F.SRGBColorSpace,d.toneMapping=G.toneMapping,d.toneMappingExposure=G.exposure,d.shadowMap.type=G.shadowMapType,l&&re(l,d),A()&&i?.(s)},children:[l&&e(Y,{env:l,isMobile:a,is3D:E,reducedQuality:!!a,captureMode:I}),!l&&D&&e(ce,{background:r}),n&&E&&!I&&e(ue,{env:l}),m&&e(ae,{defaultPosition:c.position,fov:c.fov,controlsRef:k,controlsTarget:f,maxDistance:g}),e(U,{fallback:R,children:t}),h&&e(K,{ref:k,makeDefault:!0,target:f,enablePan:!0,minDistance:u,maxDistance:N,maxPolarAngle:Math.PI/2.05,enableRotate:E,...w||{}}),e(se,{}),e(oe,{controlsRef:k}),e(Z,{})]}),o,e($,{}),e(ee,{})]})}export{pe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=t=>t?.productGraph??t?.product_graph??null,m=t=>{const n=t?.hostVariants??t?.host_variants;return Array.isArray(n)?n:[]},b=t=>t?.hostVariantId??t?.host_variant_id??null;function p(t,n,a){if(!t||!n)return!1;const h=new Set((t.compatibleSlots??t.compatible_slots??[]).map(String)),e=o(n);if(e==null||!h.has(String(e)))return!1;if(!n.corner)return!0;const c=String(n.id),f=a instanceof Map?Array.from(a.values()):Object.values(a||{}),S=r=>(a instanceof Map?a.get(r)??a.get(String(r)):a?.[r]??a?.[String(r)])??null,l=[t],u=o(t);for(const r of f)r&&r!==t&&u!=null&&String(o(r))===String(u)&&l.push(r);const g=r=>{const i=b(r);if(i==null)return!1;if(String(i)===c)return!0;const s=S(i);return!!s?.corner&&String(o(s))===String(o(n))&&s.width!=null&&n.width!=null&&Number(s.width)===Number(n.width)};return l.some(r=>m(r).some(g))}export{p as isCompatibleSlot};
|
package/dist/a0f71d0bf5.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{addProduct as q,removeProduct as N,moveProduct as K,transformProduct as Y,changeProductVariant as z,placeHostedProduct as W,applyLayoutPreset as J,setRoomDimensions as X,restoreConfiguration as Z,clearProductOption as $,selectOptionForProduct as ee,selectOptionForScene as te,clearSceneOption as oe}from"./a77b15c0d6.js";import{selectProduct as re,deselect as ne,getSelectedProduct as se,moveSelectedLeft as ae,moveSelectedRight as ie,duplicateSelected as le,deleteSelected as ce,resetScene as de,undo as ue,redo as me,canUndo as pe,canRedo as ge,clearHistory as fe,toggleDimensions as Se,toggleWalls as Pe,toggleFloor as he,toggleCeiling as ve,resetCamera as ye,setCameraPreset as Ie,focusOnObject as be,setRoomFootprint as Ce,toggleView as Te,isView3D as Ae,view2D as Oe,view3D as xe,toggleSidebar as Re,setSidebarTab as Ee,closeModal as Me,notify as Le,setGuiVisible as Be,openQuote as De,setUIRegions as He,hideUI as Fe,showUI as we,showInfo as Ue,setSceneLoading as Ge,clearSceneLoading as Qe,setSceneSelection as Ve,clearSceneSelection as je,removeSceneInstance as _e,setSceneInstanceVariant as ke,setPendingSlotPlacement as T,clearPendingSlotPlacement as A,clearDeferredHostedProductPlacement as qe,setHostedProductFeatureForSlot as O,updateHostedProductSlotForProduct as Ne,addHostedProduct as Ke,removeHostedProduct as Ye,clearHostedProducts as ze,placeHostedProductAtHost as We}from"./2cafe3274b.js";import{registerPlacementStrategy as Je,listPlacementStrategies as Xe,hasPlacementStrategy as Ze,setPlacementStrategy as $e,getPlacementStrategy as et,clearPlacementStrategy as tt,getPlacementStrategyOverride as ot,resolvePlacementStrategyConfig as rt,setPlacementStrategyConfig as nt,placementKit as st,STRATEGIES as at,DEFAULT_STRATEGY_ID as it,PLACEMENT_TYPES as lt,getPlacementType as ct,currentConfiguratorKey as dt,armPlacement as x,disarmPlacement as R,getPendingPlacement as E,armHostedProduct as M,disarmHostedProduct as L,computeTargets as ut,resolveTarget as mt,registerTargetRenderer as pt}from"./a77b15c0d6.js";import{registerComponentRenderer as gt,registerMaterialResolver as ft,registerInteraction as St,onSceneReady as Pt,readSceneBounds as ht,onSceneSettled as vt,listComponentRenderers as yt,listMaterialResolvers as It,listInteractions as bt,hideComponent as Ct,showComponent as Tt,transformComponent as At,setComponentMaterial as Ot,clearComponentOverrides as xt,listComponents as Rt,setToggles as Et,getToggles as Mt,registerAssetResolver as Lt,resolveAssetUrl as Bt,registerButton as Dt}from"./a77b15c0d6.js";import{registerComponent as Ht,resolveComponent as Ft,hasComponent as wt,listComponentOverrides as Ut,registerLayout as Gt,resolveLayout as Qt,hasLayout as Vt,listLayouts as jt,setLayout as _t,activeLayoutKey as kt,registerRoute as qt,resolveRoute as Nt,hasRoute as Kt,listRoutes as Yt,registerSlot as zt,listSlots as Wt,hasSlot as Jt,registerAction as Xt,runAction as Zt,listActions as $t,actions as eo,registerIcon as to,resolveIcon as oo,listIcons as ro,hasIcon as no,registerModal as so,listModals as ao,setLabels as io,getLabel as lo,getLabels as co,setLocale as uo,getLocale as mo,setCurrency as po,getCurrency as go,isRtl as fo,formatMoney as So,formatNumber as Po,applyTheme as ho,applyThemeById as vo,validateTheme as yo,checkThemeContrast as Io,contrastRatio as bo,applyCustomCss as Co,applyFontUrl as To}from"./a77b15c0d6.js";import{openModal as Ao}from"./09c4973968.js";import{useComponentRegistry as Oo}from"./882bc739c8.js";import{getLastEvaluation as xo,getEvaluationHistory as Ro,isEvaluationPending as Eo,subscribeEvaluation as Mo,explainOption as Lo}from"./9f474b5d1a.js";import{selectOption as Bo}from"./dbd5ba1d07.js";import P from"./872c4302e0.js";function h(e,o,a){let i=a;if(!i){const l=P.getState().features||{};i=l[e]??l[String(e)]??null}return Bo(e,o,i??{id:e})}const c=e=>String(e??"").trim().toLowerCase();function Do(e,o){const a=P.getState(),i=a.features||{},l=a.options||{},m=t=>i[t]??i[String(t)]??null,d=t=>Object.values(i).filter(r=>c(r?.name)===c(t)),p=Object.entries(l).filter(([,t])=>t&&typeof t=="object").map(([t,r])=>r.id==null?{...r,id:t}:r),b=t=>{const r=Array.isArray(t?.options)?t.options.map(n=>{if(n&&typeof n=="object")return n;const u=l[n]??l[String(n)];return u&&typeof u=="object"?u.id==null?{...u,id:n}:u:n==null?null:{id:n}}):[],s=p.filter(n=>String(n?.optionSetId??n?.option_set_id??"")===String(t?.id??""));return[...r,...s].filter(Boolean)},k=(t,r)=>t.find(s=>String(s?.id)===String(r))??t.find(s=>c(s?.name)===c(r))??null;if(o!=null){const t=m(e)?[m(e)]:d(e);if(!t.length||t.length>1)return null;const r=t[0],s=k(b(r),o);return s?{optionSetId:r.id,optionId:s.id,optionSet:r}:null}const C=p.filter(t=>String(t?.id)===String(e)),S=C.length?C:p.filter(t=>c(t?.name)===c(e)||c(t?.label)===c(e));if(!S.length){const t=m(e)??d(e)[0]??null;if(t){const r=b(t).map(s=>s?.name??s?.id).filter(Boolean);return null}return p.length,null}if(S.length>1)return null;const f=S[0];let g=f.optionSetId??f.option_set_id??null;if(g==null){const t=Object.entries(i).find(([r,s])=>Array.isArray(s?.options)&&s.options.some(n=>{const u=n&&typeof n=="object"?n.id:n;return String(u)===String(f.id)})&&r);t&&(g=t[1]?.id??t[0])}return g==null?null:{optionSetId:g,optionId:f.id,optionSet:m(g)}}function Ho(e,o,a){const l=P.getState().features||{};if(o!=null&&(l[e]!=null||l[String(e)]!=null))return h(e,o,a);const d=Do(e,o);return d?h(d.optionSetId,d.optionId,a??d.optionSet):!1}import{use as B,runIntent as v,INTENTS as y,onEvent as D,onceEvent as H,offEvent as F,on as w,registerEffectHandler as U,onRequest as Fo,onResponse as wo,setTransport as Uo,hasTransport as Go,readBom as Qo,readQuote as I,readGeneratedAssets as Vo,getUIRegions as jo,UI_REGIONS as _o,collectGenericBom as ko,setMetadata as qo,readMetadata as No,serializeMetadata as Ko,restoreMetadata as Yo,registerQuoteTemplate as zo,hasQuoteTemplate as Wo,setQuoteTemplate as Jo,listQuoteTemplates as Xo,activeQuoteTemplateKey as Zo,listQuotePdfBuilders as $o,buildQuotePdfBlob as er,saveQuotePdf as tr,registerQuotePdf as or,registerQuotePdfEndpoint as rr,hasQuotePdf as nr,generateSilo as sr,generateLifestyle as ar,generateArAsset as ir,generateBomPdf as lr,generateAll as cr,generationStatus as dr,METADATA_LIMITS as ur}from"./a77b15c0d6.js";import{bootConfigurator as G,mountConfigurator as Q,loadConfigurator as V,configureSDK as j,getVersion as _,saveProject as mr,loadProject as pr,restoreProject as gr,buildShareUrl as fr,parseShareToken as Sr,getShareToken as Pr,fetchEmbedBoot as hr,setEmbedSlug as vr,getEmbedSlug as yr,setEmbedContext as Ir,trackEmbed as br,setIframeAllowedOrigins as Cr,getIframeAllowedOrigins as Tr,getApiBaseUrl as Ar,setApiKey as Or,setChannelId as xr,getChannelId as Rr,setEmbedded as Er,getEffectiveSelections as Mr,recomputePrice as Lr,getProduct as Br,getProductName as Dr,getPlacedProductName as Hr,getProductVariants as Fr,listProducts as wr,getOptionSet as Ur,getOption as Gr,listOptionSets as Qr,listSceneOptionSets as Vr,listProductOptionSets as jr,listOptions as _r,listMaterials as kr,getMaterial as qr,buildDesignPdf as Nr,captureDesignViews as Kr,generateArForCurrentScene as Yr,checkCopilotAvailability as zr,getCopilotRuntimeUrl as Wr,setCopilotApiUrl as Jr}from"./a77b15c0d6.js";const Xr={add:(e={})=>v({type:y.PRODUCT_ADD,productGraphId:e.productGraphId,variantId:e.variantId,placementGroup:e.placementGroup??null,sequence:e.sequence??null},o=>q({...e,productGraphId:o.productGraphId,variantId:o.variantId,placementGroup:o.placementGroup??e.placementGroup,sequence:o.sequence??e.sequence})),remove:(e,o)=>v({type:y.PRODUCT_REMOVE,placementId:e},a=>N(a.placementId,o)),move:(e={})=>v({type:y.PRODUCT_MOVE,placementId:e.placementId,sequence:e.sequence??null,direction:null},o=>K({...e,placementId:o.placementId,sequence:o.sequence??e.sequence})),transform:Y,changeVariant:z,addHosted:W,select:re,deselect:ne,getSelected:se,moveLeft:ae,moveRight:ie,duplicate:le,deleteSelected:ce,anchor:x,unanchor:R,getAnchored:E,anchorHosted:M,unanchorHosted:L,arm:x,disarm:R,getArmed:E,armHosted:M,disarmHosted:L,hosted:{add:Ke,remove:Ye,clear:ze,placeAtHost:We}},Zr={select:Ho,selectByIds:h,selectForProduct:ee,clearForProduct:$,selectForScene:te,clearForScene:oe,effective:Mr},$r={applyPreset:J,setRoomDimensions:X,setRoomFootprint:Ce,restoreState:Z,reset:de,recomputePrice:Lr,camera:{reset:ye,preset:Ie,focusOn:be},view:{toggle:Te,is3D:Ae,to2D:Oe,to3D:xe},toggle:{dimensions:Se,walls:Pe,floor:he,ceiling:ve},onReady:Pt,readBounds:ht,onSettled:vt,registerRenderer:gt,registerMaterial:ft,registerInteraction:St,listRenderers:yt,listMaterials:It,listInteractions:bt,capture:Kr,buildPdf:Nr,generateAr:Yr,setSelection:Ve,clearSelection:je,removeInstance:_e,setInstanceVariant:ke,anchorSlot:T,unanchorSlot:A,armSlot:T,disarmSlot:A,clearDeferredHostedPlacement:qe,setHostedOptionForSlot:O,setHostedFeatureForSlot:O,moveHostedToSlot:Ne,hideComponent:Ct,showComponent:Tt,transformComponent:At,setComponentMaterial:Ot,clearComponentOverrides:xt,listComponents:Rt},en={registerComponent:Ht,resolveComponent:Ft,hasComponent:wt,listComponentOverrides:Ut,useComponentRegistry:Oo,registerLayout:Gt,resolveLayout:Qt,hasLayout:Vt,listLayouts:jt,activeLayout:kt,setLayout:_t,registerRoute:qt,resolveRoute:Nt,hasRoute:Kt,listRoutes:Yt,setToggles:Et,getToggles:Mt,registerAssetResolver:Lt,resolveAssetUrl:Bt,registerButton:Dt,registerSlot:zt,listSlots:Wt,hasSlot:Jt,registerAction:Xt,runAction:Zt,listActions:$t,actions:eo,registerIcon:to,resolveIcon:oo,listIcons:ro,hasIcon:no,registerModal:so,openModal:Ao,closeModal:Me,listModals:ao,setLabels:io,getLabel:lo,getLabels:co,setLocale:uo,getLocale:mo,setCurrency:po,getCurrency:go,isRtl:fo,formatMoney:So,formatNumber:Po,applyTheme:ho,applyThemeById:vo,validateTheme:yo,checkThemeContrast:Io,contrastRatio:bo,applyCustomCss:Co,applyFontUrl:To,hide:Fe,show:we,setVisible:He,visible:jo,regions:_o,sidebar:{toggle:Re,setTab:Ee},notify:Le,setSceneOverlaysVisible:Be,showInfo:Ue,setLoading:Ge,clearLoading:Qe},tn={read:I,registerTemplate:zo,hasTemplate:Wo,setTemplate:Jo,listTemplates:Xo,activeTemplate:Zo,listPdfBuilders:$o,open:De,images:Vo,generateSilo:sr,generateLifestyle:ar,generateAr:ir,generateBomPdf:lr,generateAll:cr,generationStatus:dr,toPdf:(e={})=>er(I(),e),savePdf:(e={})=>tr(I(),e),registerPdf:or,registerPdfEndpoint:rr,hasPdf:nr,setDocument:jn,hasDocument:_n,resetDocument:kn},on={registerStrategy:Je,listStrategies:Xe,hasStrategy:Ze,setStrategy:$e,strategyOverride:ot,config:rt,setConfig:nt,kit:st,getStrategy:et,clearStrategy:tt,computeTargets:ut,resolveTarget:mt,registerTargetRenderer:pt,getType:ct,currentKey:dt,STRATEGIES:at,DEFAULT_STRATEGY_ID:it,TYPES:lt},rn={readBom:Qo,collectBom:ko,setMetadata:qo,readMetadata:No,serializeMetadata:Ko,restoreMetadata:Yo,LIMITS:ur},nn={onRequest:Fo,onResponse:wo,setTransport:Uo,hasTransport:Go},sn={save:mr,load:pr,restore:gr,shareUrl:fr,parseShareToken:Sr,getShareToken:Pr},an={undo:ue,redo:me,canUndo:pe,canRedo:ge,clear:fe},ln={fetchBoot:hr,setSlug:vr,getSlug:yr,setContext:Ir,track:br,setEmbedded:Er,setAllowedOrigins:Cr,getAllowedOrigins:Tr},cn={isAvailable:zr,runtimeUrl:Wr,setApiUrl:Jr},As={quota:ds},dn={getProduct:Br,getProductName:Dr,getProductVariants:Fr,getPlacedProductName:Hr,listProducts:wr,listOptionSets:Qr,listSceneOptionSets:Vr,listProductOptionSets:jr,listOptions:_r,listMaterials:kr,getMaterial:qr,getOptionSet:Ur,getOption:Gr},Os={last:xo,history:Ro,pending:Eo,subscribe:Mo,explainOption:Lo},un={getApiBaseUrl:Ar,setChannelId:xr,getChannelId:Rr,setApiKey:Or};import{default as ks}from"./2990ba64d6.js";import{useComponentRegistry as Ns}from"./882bc739c8.js";import{default as Ys}from"./60d697292c.js";import{default as Ws}from"./6ba86aa3b8.js";import{default as Xs}from"./811b403d43.js";import{useSelection as $s,useProducts as ea,usePrice as ta}from"./16a399703e.js";import{default as ra}from"./d0f9681634.js";import{useBootStatus as sa,useSystem as aa}from"./066fc9aa40.js";import{useEvaluation as la}from"./9f474b5d1a.js";import{useLabel as da,useLabels as ua,useFormatters as ma}from"./28d887bf8a.js";import{useProduct as ga,useCatalogMaps as fa}from"./1458417bdb.js";import{useSceneState as Pa}from"./16a399703e.js";import{useUIState as va,useOptionGating as ya,useHostedProductState as Ia,useUIRegion as ba,useUIRegions as Ca}from"./9840b9ce12.js";import{useSystemConfig as Aa}from"./6855e6a3b1.js";import{useIcon as xa}from"./09c4973968.js";import{default as Ea}from"./921bf270dd.js";import{usePlacementInteraction as La}from"./4b8958aa4c.js";import{default as Da}from"./f11a45a150.js";import{useCopilotAvailable as Fa}from"./672404d987.js";import mn from"./3fb3ab6757.js";import pn from"./7206ce49c6.js";import gn from"./0f7c8345a8.js";import fn from"./82a8a4bc35.js";import Sn from"./e379e0039b.js";import{Sidebar as Pn,SaveProjectButton as hn,GenerateAssetsButton as vn,LiveStatusPanel as yn,ChatBar as In,NotificationContainer as bn,EvaluatingOverlay as Cn,Modals as Tn,SaveProjectModal as An,ExportModal as On,ARModal as xn,GeneratedAssetsModal as Rn,Header as En,SceneToolbar as Mn,SidebarFrame as Ln,OptionSidebar as Bn,LoadingScreen as Dn,ConfirmDialog as Hn,Modal as Fn,Button as wn,ARViewer as Un,SceneRoom as Gn,SceneDimensions as Qn,CameraAnimator as Vn}from"./64e9020b49.js";import{setQuoteDocument as jn,hasQuoteDocument as _n,resetQuoteDocument as kn}from"./12b8165d6d.js";import{SlotHost as qn}from"./73f7d65985.js";import{ModalHost as Nn}from"./09c4973968.js";import{OptionThumbnail as Kn,FinishThumbnail as Yn,LayoutThumbnail as zn,ColorSwatch as Wn,WidthSlider as Jn,FrameSizeButton as Xn,HostedProductThumbnail as Zn,ProductFeaturePickers as $n,AddProductToggle as es}from"./c12c112c6f.js";import{ProductInstance as ts,ComponentMesh as os,SceneStage as rs,SceneEnvironment as ns,SelectionBox as ss,FreeMovable as as,PlacementGaps as is,SelectionActionPanel as ls}from"./8a3a57c008.js";import cs from"./205827c5c8.js";import{refreshAiQuota as ds}from"./2f8cc8b292.js";const us={Sidebar:Pn,SidebarFrame:Ln,OptionSetSection:mn,OptionThumbnail:Kn,FinishThumbnail:Yn,LayoutThumbnail:zn,ColorSwatch:Wn,WidthSlider:Jn,FrameSizeButton:Xn,HostedProductThumbnail:Zn,ProductFeaturePickers:$n,AddProductToggle:es,QuoteRenders:gn,QuoteQr:Sn,ConfigurationSummary:fn,SaveProjectButton:hn,GenerateAssetsButton:vn,LiveStatusPanel:yn,ChatBar:In,NotificationContainer:bn,EvaluatingOverlay:Cn,Header:En,SceneToolbar:Mn,OptionSidebar:Bn,LoadingScreen:Dn,Modals:Tn,SaveProjectModal:An,ExportModal:On,ARModal:xn,GeneratedAssetsModal:Rn,Modal:Fn,Button:wn,ConfirmDialog:Hn,ARViewer:Un,SceneRoom:Gn,SceneDimensions:Qn,CameraAnimator:Vn,Popover:pn,SlotHost:qn,ModalHost:Nn,ProductInstance:ts,ComponentMesh:os,SceneStage:rs,SceneEnvironment:ns,SelectionBox:ss,FreeMovable:as,PlacementGaps:is,PlacementTargets:cs,SelectionActionPanel:ls},ms={products:Xr,options:Zr,scene:$r,ui:en,placement:on,commerce:rn,http:nn,project:sn,history:an,embed:ln,config:un,copilot:cn,catalog:dn,parts:us,quote:tn,boot:G,mount:Q,load:V,configure:j,version:_,on:D,once:H,off:F,onBackendEvent:w,registerEffectHandler:U,addMiddleware:B};var Vs=ms;export{B as addMiddleware,As as ai,G as boot,dn as catalog,rn as commerce,un as config,j as configure,cn as copilot,Vs as default,ln as embed,Os as evaluation,an as history,nn as http,V as load,Q as mount,F as off,D as on,w as onBackendEvent,H as once,Zr as options,us as parts,on as placement,Xr as products,sn as project,tn as quote,U as registerEffectHandler,$r as scene,en as ui,Da as useAppVersion,sa as useBootStatus,fa as useCatalogMaps,Ns as useComponentRegistry,Fa as useCopilotAvailable,la as useEvaluation,ma as useFormatters,Ea as useGenerateAssets,Ia as useHostedProductState,xa as useIcon,da as useLabel,ua as useLabels,ya as useOptionGating,ks as useOptionSets,La as usePlacementInteraction,ta as usePrice,ga as useProduct,Ys as useProductOrder,Ws as useProductOverrides,ea as useProducts,Pa as useSceneState,$s as useSelection,Xs as useSelectionActions,aa as useSystem,Aa as useSystemConfig,ra as useToolbar,ba as useUIRegion,Ca as useUIRegions,va as useUIState,_ as version};
|
|
1
|
+
import{addProduct as q,removeProduct as N,moveProduct as K,transformProduct as Y,changeProductVariant as z,changeHostVariantForProduct as W,placeHostedProduct as J,applyLayoutPreset as X,setRoomDimensions as Z,restoreConfiguration as $,clearProductOption as ee,selectOptionForProduct as te,selectOptionForScene as oe,clearSceneOption as re}from"./a77b15c0d6.js";import{selectProduct as ne,deselect as se,getSelectedProduct as ae,moveSelectedLeft as ie,moveSelectedRight as le,duplicateSelected as ce,deleteSelected as de,resetScene as ue,undo as me,redo as pe,canUndo as ge,canRedo as fe,clearHistory as Se,toggleDimensions as Pe,toggleWalls as he,toggleFloor as ve,toggleCeiling as ye,resetCamera as Ie,setCameraPreset as be,focusOnObject as Ce,setRoomFootprint as Te,toggleView as Ae,isView3D as Oe,view2D as xe,view3D as Re,toggleSidebar as Ee,setSidebarTab as Me,closeModal as He,notify as Le,setGuiVisible as Be,openQuote as De,setUIRegions as Fe,hideUI as we,showUI as Ue,showInfo as Ge,setSceneLoading as Qe,clearSceneLoading as Ve,setSceneSelection as je,clearSceneSelection as _e,removeSceneInstance as ke,setSceneInstanceVariant as qe,setPendingSlotPlacement as T,clearPendingSlotPlacement as A,clearDeferredHostedProductPlacement as Ne,setHostedProductFeatureForSlot as O,updateHostedProductSlotForProduct as Ke,addHostedProduct as Ye,removeHostedProduct as ze,clearHostedProducts as We,placeHostedProductAtHost as Je}from"./2cafe3274b.js";import{registerPlacementStrategy as Xe,listPlacementStrategies as Ze,hasPlacementStrategy as $e,setPlacementStrategy as et,getPlacementStrategy as tt,clearPlacementStrategy as ot,getPlacementStrategyOverride as rt,resolvePlacementStrategyConfig as nt,setPlacementStrategyConfig as st,placementKit as at,STRATEGIES as it,DEFAULT_STRATEGY_ID as lt,PLACEMENT_TYPES as ct,getPlacementType as dt,currentConfiguratorKey as ut,armPlacement as x,disarmPlacement as R,getPendingPlacement as E,armHostedProduct as M,disarmHostedProduct as H,computeTargets as mt,resolveTarget as pt,registerTargetRenderer as gt}from"./a77b15c0d6.js";import{registerComponentRenderer as ft,registerMaterialResolver as St,registerInteraction as Pt,onSceneReady as ht,readSceneBounds as vt,onSceneSettled as yt,listComponentRenderers as It,listMaterialResolvers as bt,listInteractions as Ct,hideComponent as Tt,showComponent as At,transformComponent as Ot,setComponentMaterial as xt,clearComponentOverrides as Rt,listComponents as Et,setToggles as Mt,getToggles as Ht,registerAssetResolver as Lt,resolveAssetUrl as Bt,registerButton as Dt}from"./a77b15c0d6.js";import{registerComponent as Ft,resolveComponent as wt,hasComponent as Ut,listComponentOverrides as Gt,registerLayout as Qt,resolveLayout as Vt,hasLayout as jt,listLayouts as _t,setLayout as kt,activeLayoutKey as qt,registerRoute as Nt,resolveRoute as Kt,hasRoute as Yt,listRoutes as zt,registerSlot as Wt,listSlots as Jt,hasSlot as Xt,registerAction as Zt,runAction as $t,listActions as eo,actions as to,registerIcon as oo,resolveIcon as ro,listIcons as no,hasIcon as so,registerModal as ao,listModals as io,setLabels as lo,getLabel as co,getLabels as uo,setLocale as mo,getLocale as po,setCurrency as go,getCurrency as fo,isRtl as So,formatMoney as Po,formatNumber as ho,applyTheme as vo,applyThemeById as yo,validateTheme as Io,checkThemeContrast as bo,contrastRatio as Co,applyCustomCss as To,applyFontUrl as Ao}from"./a77b15c0d6.js";import{openModal as Oo}from"./09c4973968.js";import{useComponentRegistry as xo}from"./882bc739c8.js";import{getLastEvaluation as Ro,getEvaluationHistory as Eo,isEvaluationPending as Mo,subscribeEvaluation as Ho,explainOption as Lo}from"./9f474b5d1a.js";import{selectOption as Bo}from"./dbd5ba1d07.js";import P from"./872c4302e0.js";function h(e,o,a){let i=a;if(!i){const l=P.getState().features||{};i=l[e]??l[String(e)]??null}return Bo(e,o,i??{id:e})}const c=e=>String(e??"").trim().toLowerCase();function Do(e,o){const a=P.getState(),i=a.features||{},l=a.options||{},m=t=>i[t]??i[String(t)]??null,d=t=>Object.values(i).filter(r=>c(r?.name)===c(t)),p=Object.entries(l).filter(([,t])=>t&&typeof t=="object").map(([t,r])=>r.id==null?{...r,id:t}:r),b=t=>{const r=Array.isArray(t?.options)?t.options.map(n=>{if(n&&typeof n=="object")return n;const u=l[n]??l[String(n)];return u&&typeof u=="object"?u.id==null?{...u,id:n}:u:n==null?null:{id:n}}):[],s=p.filter(n=>String(n?.optionSetId??n?.option_set_id??"")===String(t?.id??""));return[...r,...s].filter(Boolean)},k=(t,r)=>t.find(s=>String(s?.id)===String(r))??t.find(s=>c(s?.name)===c(r))??null;if(o!=null){const t=m(e)?[m(e)]:d(e);if(!t.length||t.length>1)return null;const r=t[0],s=k(b(r),o);return s?{optionSetId:r.id,optionId:s.id,optionSet:r}:null}const C=p.filter(t=>String(t?.id)===String(e)),S=C.length?C:p.filter(t=>c(t?.name)===c(e)||c(t?.label)===c(e));if(!S.length){const t=m(e)??d(e)[0]??null;if(t){const r=b(t).map(s=>s?.name??s?.id).filter(Boolean);return null}return p.length,null}if(S.length>1)return null;const f=S[0];let g=f.optionSetId??f.option_set_id??null;if(g==null){const t=Object.entries(i).find(([r,s])=>Array.isArray(s?.options)&&s.options.some(n=>{const u=n&&typeof n=="object"?n.id:n;return String(u)===String(f.id)})&&r);t&&(g=t[1]?.id??t[0])}return g==null?null:{optionSetId:g,optionId:f.id,optionSet:m(g)}}function Fo(e,o,a){const l=P.getState().features||{};if(o!=null&&(l[e]!=null||l[String(e)]!=null))return h(e,o,a);const d=Do(e,o);return d?h(d.optionSetId,d.optionId,a??d.optionSet):!1}import{use as L,runIntent as v,INTENTS as y,onEvent as B,onceEvent as D,offEvent as F,on as w,registerEffectHandler as U,onRequest as wo,onResponse as Uo,setTransport as Go,hasTransport as Qo,readBom as Vo,readQuote as I,readGeneratedAssets as jo,getUIRegions as _o,UI_REGIONS as ko,collectGenericBom as qo,setMetadata as No,readMetadata as Ko,serializeMetadata as Yo,restoreMetadata as zo,registerQuoteTemplate as Wo,hasQuoteTemplate as Jo,setQuoteTemplate as Xo,listQuoteTemplates as Zo,activeQuoteTemplateKey as $o,listQuotePdfBuilders as er,buildQuotePdfBlob as tr,saveQuotePdf as or,registerQuotePdf as rr,registerQuotePdfEndpoint as nr,hasQuotePdf as sr,generateSilo as ar,generateLifestyle as ir,generateArAsset as lr,generateBomPdf as cr,generateAll as dr,generationStatus as ur,METADATA_LIMITS as mr}from"./a77b15c0d6.js";import{bootConfigurator as G,mountConfigurator as Q,loadConfigurator as V,configureSDK as j,getVersion as _,saveProject as pr,loadProject as gr,restoreProject as fr,buildShareUrl as Sr,parseShareToken as Pr,getShareToken as hr,fetchEmbedBoot as vr,setEmbedSlug as yr,getEmbedSlug as Ir,setEmbedContext as br,trackEmbed as Cr,setIframeAllowedOrigins as Tr,getIframeAllowedOrigins as Ar,getApiBaseUrl as Or,setApiKey as xr,setChannelId as Rr,getChannelId as Er,setEmbedded as Mr,getEffectiveSelections as Hr,recomputePrice as Lr,getProduct as Br,getProductName as Dr,getPlacedProductName as Fr,getProductVariants as wr,listProducts as Ur,getOptionSet as Gr,getOption as Qr,listOptionSets as Vr,listSceneOptionSets as jr,listProductOptionSets as _r,listOptions as kr,listMaterials as qr,getMaterial as Nr,buildDesignPdf as Kr,captureDesignViews as Yr,generateArForCurrentScene as zr,checkCopilotAvailability as Wr,getCopilotRuntimeUrl as Jr,setCopilotApiUrl as Xr}from"./a77b15c0d6.js";const Zr={add:(e={})=>v({type:y.PRODUCT_ADD,productGraphId:e.productGraphId,variantId:e.variantId,placementGroup:e.placementGroup??null,sequence:e.sequence??null},o=>q({...e,productGraphId:o.productGraphId,variantId:o.variantId,placementGroup:o.placementGroup??e.placementGroup,sequence:o.sequence??e.sequence})),remove:(e,o)=>v({type:y.PRODUCT_REMOVE,placementId:e},a=>N(a.placementId,o)),move:(e={})=>v({type:y.PRODUCT_MOVE,placementId:e.placementId,sequence:e.sequence??null,direction:null},o=>K({...e,placementId:o.placementId,sequence:o.sequence??e.sequence})),transform:Y,changeVariant:z,changeHost:W,addHosted:J,select:ne,deselect:se,getSelected:ae,moveLeft:ie,moveRight:le,duplicate:ce,deleteSelected:de,anchor:x,unanchor:R,getAnchored:E,anchorHosted:M,unanchorHosted:H,arm:x,disarm:R,getArmed:E,armHosted:M,disarmHosted:H,hosted:{add:Ye,remove:ze,clear:We,placeAtHost:Je}},$r={select:Fo,selectByIds:h,selectForProduct:te,clearForProduct:ee,selectForScene:oe,clearForScene:re,effective:Hr},en={applyPreset:X,setRoomDimensions:Z,setRoomFootprint:Te,restoreState:$,reset:ue,recomputePrice:Lr,camera:{reset:Ie,preset:be,focusOn:Ce},view:{toggle:Ae,is3D:Oe,to2D:xe,to3D:Re},toggle:{dimensions:Pe,walls:he,floor:ve,ceiling:ye},onReady:ht,readBounds:vt,onSettled:yt,registerRenderer:ft,registerMaterial:St,registerInteraction:Pt,listRenderers:It,listMaterials:bt,listInteractions:Ct,capture:Yr,buildPdf:Kr,generateAr:zr,setSelection:je,clearSelection:_e,removeInstance:ke,setInstanceVariant:qe,anchorSlot:T,unanchorSlot:A,armSlot:T,disarmSlot:A,clearDeferredHostedPlacement:Ne,setHostedOptionForSlot:O,setHostedFeatureForSlot:O,moveHostedToSlot:Ke,hideComponent:Tt,showComponent:At,transformComponent:Ot,setComponentMaterial:xt,clearComponentOverrides:Rt,listComponents:Et},tn={registerComponent:Ft,resolveComponent:wt,hasComponent:Ut,listComponentOverrides:Gt,useComponentRegistry:xo,registerLayout:Qt,resolveLayout:Vt,hasLayout:jt,listLayouts:_t,activeLayout:qt,setLayout:kt,registerRoute:Nt,resolveRoute:Kt,hasRoute:Yt,listRoutes:zt,setToggles:Mt,getToggles:Ht,registerAssetResolver:Lt,resolveAssetUrl:Bt,registerButton:Dt,registerSlot:Wt,listSlots:Jt,hasSlot:Xt,registerAction:Zt,runAction:$t,listActions:eo,actions:to,registerIcon:oo,resolveIcon:ro,listIcons:no,hasIcon:so,registerModal:ao,openModal:Oo,closeModal:He,listModals:io,setLabels:lo,getLabel:co,getLabels:uo,setLocale:mo,getLocale:po,setCurrency:go,getCurrency:fo,isRtl:So,formatMoney:Po,formatNumber:ho,applyTheme:vo,applyThemeById:yo,validateTheme:Io,checkThemeContrast:bo,contrastRatio:Co,applyCustomCss:To,applyFontUrl:Ao,hide:we,show:Ue,setVisible:Fe,visible:_o,regions:ko,sidebar:{toggle:Ee,setTab:Me},notify:Le,setSceneOverlaysVisible:Be,showInfo:Ge,setLoading:Qe,clearLoading:Ve},on={read:I,registerTemplate:Wo,hasTemplate:Jo,setTemplate:Xo,listTemplates:Zo,activeTemplate:$o,listPdfBuilders:er,open:De,images:jo,generateSilo:ar,generateLifestyle:ir,generateAr:lr,generateBomPdf:cr,generateAll:dr,generationStatus:ur,toPdf:(e={})=>tr(I(),e),savePdf:(e={})=>or(I(),e),registerPdf:rr,registerPdfEndpoint:nr,hasPdf:sr,setDocument:_n,hasDocument:kn,resetDocument:qn},rn={registerStrategy:Xe,listStrategies:Ze,hasStrategy:$e,setStrategy:et,strategyOverride:rt,config:nt,setConfig:st,kit:at,getStrategy:tt,clearStrategy:ot,computeTargets:mt,resolveTarget:pt,registerTargetRenderer:gt,getType:dt,currentKey:ut,STRATEGIES:it,DEFAULT_STRATEGY_ID:lt,TYPES:ct},nn={readBom:Vo,collectBom:qo,setMetadata:No,readMetadata:Ko,serializeMetadata:Yo,restoreMetadata:zo,LIMITS:mr},sn={onRequest:wo,onResponse:Uo,setTransport:Go,hasTransport:Qo},an={save:pr,load:gr,restore:fr,shareUrl:Sr,parseShareToken:Pr,getShareToken:hr},ln={undo:me,redo:pe,canUndo:ge,canRedo:fe,clear:Se},cn={fetchBoot:vr,setSlug:yr,getSlug:Ir,setContext:br,track:Cr,setEmbedded:Mr,setAllowedOrigins:Tr,getAllowedOrigins:Ar},dn={isAvailable:Wr,runtimeUrl:Jr,setApiUrl:Xr},Os={quota:us},un={getProduct:Br,getProductName:Dr,getProductVariants:wr,getPlacedProductName:Fr,listProducts:Ur,listOptionSets:Vr,listSceneOptionSets:jr,listProductOptionSets:_r,listOptions:kr,listMaterials:qr,getMaterial:Nr,getOptionSet:Gr,getOption:Qr},xs={last:Ro,history:Eo,pending:Mo,subscribe:Ho,explainOption:Lo},mn={getApiBaseUrl:Or,setChannelId:Rr,getChannelId:Er,setApiKey:xr};import{default as qs}from"./2990ba64d6.js";import{useComponentRegistry as Ks}from"./882bc739c8.js";import{default as zs}from"./60d697292c.js";import{default as Js}from"./6ba86aa3b8.js";import{default as Zs}from"./811b403d43.js";import{useSelection as ea,useProducts as ta,usePrice as oa}from"./16a399703e.js";import{default as na}from"./d0f9681634.js";import{useBootStatus as aa,useSystem as ia}from"./066fc9aa40.js";import{useEvaluation as ca}from"./9f474b5d1a.js";import{useLabel as ua,useLabels as ma,useFormatters as pa}from"./28d887bf8a.js";import{useProduct as fa,useCatalogMaps as Sa}from"./1458417bdb.js";import{useSceneState as ha}from"./16a399703e.js";import{useUIState as ya,useOptionGating as Ia,useHostedProductState as ba,useUIRegion as Ca,useUIRegions as Ta}from"./9840b9ce12.js";import{useSystemConfig as Oa}from"./6855e6a3b1.js";import{useIcon as Ra}from"./09c4973968.js";import{default as Ma}from"./921bf270dd.js";import{usePlacementInteraction as La}from"./4b8958aa4c.js";import{default as Da}from"./f11a45a150.js";import{useCopilotAvailable as wa}from"./672404d987.js";import pn from"./3fb3ab6757.js";import gn from"./7206ce49c6.js";import fn from"./0f7c8345a8.js";import Sn from"./82a8a4bc35.js";import Pn from"./e379e0039b.js";import{Sidebar as hn,SaveProjectButton as vn,GenerateAssetsButton as yn,LiveStatusPanel as In,ChatBar as bn,NotificationContainer as Cn,EvaluatingOverlay as Tn,Modals as An,SaveProjectModal as On,ExportModal as xn,ARModal as Rn,GeneratedAssetsModal as En,Header as Mn,SceneToolbar as Hn,SidebarFrame as Ln,OptionSidebar as Bn,LoadingScreen as Dn,ConfirmDialog as Fn,Modal as wn,Button as Un,ARViewer as Gn,SceneRoom as Qn,SceneDimensions as Vn,CameraAnimator as jn}from"./64e9020b49.js";import{setQuoteDocument as _n,hasQuoteDocument as kn,resetQuoteDocument as qn}from"./12b8165d6d.js";import{SlotHost as Nn}from"./73f7d65985.js";import{ModalHost as Kn}from"./09c4973968.js";import{OptionThumbnail as Yn,FinishThumbnail as zn,LayoutThumbnail as Wn,ColorSwatch as Jn,WidthSlider as Xn,FrameSizeButton as Zn,HostedProductThumbnail as $n,ProductFeaturePickers as es,AddProductToggle as ts}from"./c12c112c6f.js";import{ProductInstance as os,ComponentMesh as rs,SceneStage as ns,SceneEnvironment as ss,SelectionBox as as,FreeMovable as is,PlacementGaps as ls,SelectionActionPanel as cs}from"./8a3a57c008.js";import ds from"./205827c5c8.js";import{refreshAiQuota as us}from"./2f8cc8b292.js";const ms={Sidebar:hn,SidebarFrame:Ln,OptionSetSection:pn,OptionThumbnail:Yn,FinishThumbnail:zn,LayoutThumbnail:Wn,ColorSwatch:Jn,WidthSlider:Xn,FrameSizeButton:Zn,HostedProductThumbnail:$n,ProductFeaturePickers:es,AddProductToggle:ts,QuoteRenders:fn,QuoteQr:Pn,ConfigurationSummary:Sn,SaveProjectButton:vn,GenerateAssetsButton:yn,LiveStatusPanel:In,ChatBar:bn,NotificationContainer:Cn,EvaluatingOverlay:Tn,Header:Mn,SceneToolbar:Hn,OptionSidebar:Bn,LoadingScreen:Dn,Modals:An,SaveProjectModal:On,ExportModal:xn,ARModal:Rn,GeneratedAssetsModal:En,Modal:wn,Button:Un,ConfirmDialog:Fn,ARViewer:Gn,SceneRoom:Qn,SceneDimensions:Vn,CameraAnimator:jn,Popover:gn,SlotHost:Nn,ModalHost:Kn,ProductInstance:os,ComponentMesh:rs,SceneStage:ns,SceneEnvironment:ss,SelectionBox:as,FreeMovable:is,PlacementGaps:ls,PlacementTargets:ds,SelectionActionPanel:cs},ps={products:Zr,options:$r,scene:en,ui:tn,placement:rn,commerce:nn,http:sn,project:an,history:ln,embed:cn,config:mn,copilot:dn,catalog:un,parts:ms,quote:on,boot:G,mount:Q,load:V,configure:j,version:_,on:B,once:D,off:F,onBackendEvent:w,registerEffectHandler:U,addMiddleware:L};var js=ps;export{L as addMiddleware,Os as ai,G as boot,un as catalog,nn as commerce,mn as config,j as configure,dn as copilot,js as default,cn as embed,xs as evaluation,ln as history,sn as http,V as load,Q as mount,F as off,B as on,w as onBackendEvent,D as once,$r as options,ms as parts,rn as placement,Zr as products,an as project,on as quote,U as registerEffectHandler,en as scene,tn as ui,Da as useAppVersion,aa as useBootStatus,Sa as useCatalogMaps,Ks as useComponentRegistry,wa as useCopilotAvailable,ca as useEvaluation,pa as useFormatters,Ma as useGenerateAssets,ba as useHostedProductState,Ra as useIcon,ua as useLabel,ma as useLabels,Ia as useOptionGating,qs as useOptionSets,La as usePlacementInteraction,oa as usePrice,fa as useProduct,zs as useProductOrder,Js as useProductOverrides,ta as useProducts,ha as useSceneState,ea as useSelection,Zs as useSelectionActions,ia as useSystem,Oa as useSystemConfig,na as useToolbar,Ca as useUIRegion,Ta as useUIRegions,ya as useUIState,_ as version};
|
package/dist/a493e9aa8f.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const E=.0254,L=.9,P=.95,O=Math.PI/2,D=1,A=t=>t*180/Math.PI,F=t=>t*Math.PI/180;function l(t,r={}){const
|
|
1
|
+
const E=.0254,L=.9,P=.95,O=Math.PI/2,D=1,A=t=>t*180/Math.PI,F=t=>t*Math.PI/180;function l(t,r={}){const c=t?.productId??t?.variantId??t,e=r.getDims?.(c,t&&typeof t=="object"?t:void 0),o=r.getProduct?.(c),n=typeof o?.width=="number"&&o.width>0?o.width*.0254:.9,h=typeof o?.depth=="number"&&o.depth>0?o.depth*.0254:.95;return{width:e?.width>0?e.width:n,depth:e?.depth>0?e.depth:h,cx:e?.cx||0,cz:e?.cz||0}}function u(t){return{hx:Math.cos(t),hz:Math.sin(t),fx:-Math.sin(t)*D,fz:Math.cos(t)*D}}function N(t,r){const c=(r?.[0]??0)-(t?.[0]??0),e=(r?.[2]??0)-(t?.[2]??0);return Math.hypot(c,e)<1e-6?null:Math.atan2(e,c)}const I=t=>!!(t?.corner??t?.isCorner);function y(t,r={},c={}){const e=typeof c.turn=="number"?c.turn:O,o=r.openSlots&&r.candidate?l(r.candidate,r).width:0;let n=0,h=0,i=0;const d=[];for(const a of t||[]){if(o){const w=u(n);h+=w.hx*o,i+=w.hz*o}const{width:s,depth:p,cx:f,cz:g}=l(a,r),{hx:x,hz:M,fx:z,fz:_}=u(n),m=I(a);d.push({position:[h+x*(s/2)+z*(p/2)-(x*f+z*g),0,i+M*(s/2)+_*(p/2)-(M*f+_*g)],rotation:[0,-n,0]}),h+=x*s,i+=M*s,m&&(n+=e,h+=Math.cos(n)*p,i+=Math.sin(n)*p)}return d}function T(t,r,c={}){return Array.isArray(t)?t.map((e,o)=>{const n=e?.position||[0,0,0],h=-(e?.rotation?.[1]??0),{hx:i,hz:d}=u(h),a=l(r?.[o],c).width/2;return{heading:h,trailing:[n[0]-i*a,n[1]??0,n[2]-d*a],leading:[n[0]+i*a,n[1]??0,n[2]+d*a]}}):[]}function U(t,r,c={},e=0){const o=T(t,r,c);if(!o.length)return[];const n=e/2,h=o.map((s,p)=>{const{hx:f,hz:g}=u(s.heading);return{index:p,heading:s.heading,position:[s.trailing[0]-f*n,s.trailing[1],s.trailing[2]-g*n]}}),i=o[o.length-1],{hx:d,hz:a}=u(i.heading);return h.push({index:o.length,heading:i.heading,position:[i.leading[0]+d*n,i.leading[1],i.leading[2]+a*n]}),h}var W={dimsOf:l,axesFor:u,headingOf:N,isCorner:I,chain:y,edgesOf:T,gapCentres:U,toDegrees:A,toRadians:F};export{D as FRONT_SIGN,O as TURN,u as axesFor,y as chain,W as default,l as dimsOf,T as edgesOf,U as gapCentres,N as headingOf,I as isCorner,A as toDegrees,F as toRadians};
|