@imagineio/configurator-sdk 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{useCallback as d,useMemo as v,useRef as y}from"react";import O from"./872c4302e0.js";import _ from"./9c6c598569.js";function j(){const r=O(e=>e.getProduct),s=_(e=>e.productInstances),u=d(e=>r(e?.variantId)?.edge||r(e?.productId)?.edge||""||null,[r]),l=d(e=>{const o=r(e?.variantId)||r(e?.productId);return o?.corner===!0||o?.corner==="true"||String(o?.edge??"").toLowerCase()==="corner"},[r]),f=d(e=>{if(e?.positionedAbove!=null)return!0;const o=r(e?.variantId)||r(e?.productId),c=o?.hostVariants??o?.host_variants;return Array.isArray(c)&&c.length>0},[r]),p=d(e=>!f(e)&&!!(r(e?.variantId)?.movable??r(e?.productId)?.movable),[r,f]),i=v(()=>Object.values(s||{}).filter(p),[s,p]),I=i.length>0&&i.length<Object.keys(s||{}).length,h=I?i:[],m=y(!1),b=v(()=>{const e=t=>t==="left"?-1:t==="right"?1:0,o=new Set(h.map(t=>t.id)),c=t=>{const n=Number(t?.sequence);return Number.isFinite(n)?n:t?.createdAt||0};return Object.values(s||{}).filter(t=>!o.has(t.id)).map(t=>({inst:{...t,corner:l(t)},edge:u(t)})).sort((t,n)=>e(t.edge)-e(n.edge)||c(t.inst)-c(n.inst)).map(t=>t.inst)},[s,u,l,h]),A=v(()=>{const e=[];for(const o of Object.values(s||{})){if(o.positionedAbove!=null)continue;const c=r(o.variantId)||r(o.productId),a=c?.hostVariants??c?.host_variants;if(!Array.isArray(a)||!a.length)continue;const t=a.find(g=>g?.isDefault??g?.is_default)||a[0],n=t?.hostVariantId??t?.host_variant_id;n==null||!r(n)||e.push({id:`${o.id}__host`,hostedProductId:o.id,hostVariantId:n,offset:Array.isArray(t?.position)?t.position:[0,0,0],rotDegY:Array.isArray(t?.rotation)&&t.rotation[1]||0})}return e},[s,r]);return{edgeOf:u,cornerOf:l,isHostAnchored:f,isMovable:p,rawFree:i,splitReliable:I,freeInstances:h,ordered:b,syntheticHosts:A,moveInFlightRef:m,productInstances:s,getProduct:r}}export{j as default};
1
+ import{useCallback as d,useMemo as v,useRef as y}from"react";import A from"./872c4302e0.js";import O from"./9c6c598569.js";import{resolveHostEntry as j}from"./be07a7f885.js";function S(){const r=A(t=>t.getProduct),n=O(t=>t.productInstances),u=d(t=>r(t?.variantId)?.edge||r(t?.productId)?.edge||""||null,[r]),l=d(t=>{const o=r(t?.variantId)||r(t?.productId);return o?.corner===!0||o?.corner==="true"||String(o?.edge??"").toLowerCase()==="corner"},[r]),f=d(t=>{if(t?.positionedAbove!=null)return!0;const o=r(t?.variantId)||r(t?.productId),c=o?.hostVariants??o?.host_variants;return Array.isArray(c)&&c.length>0},[r]),p=d(t=>!f(t)&&!!(r(t?.variantId)?.movable??r(t?.productId)?.movable),[r,f]),i=v(()=>Object.values(n||{}).filter(p),[n,p]),I=i.length>0&&i.length<Object.keys(n||{}).length,h=I?i:[],m=y(!1),g=v(()=>{const t=e=>e==="left"?-1:e==="right"?1:0,o=new Set(h.map(e=>e.id)),c=e=>{const a=Number(e?.sequence);return Number.isFinite(a)?a:e?.createdAt||0};return Object.values(n||{}).filter(e=>!o.has(e.id)).map(e=>({inst:{...e,corner:l(e)},edge:u(e)})).sort((e,a)=>t(e.edge)-t(a.edge)||c(e.inst)-c(a.inst)).map(e=>e.inst)},[n,u,l,h]),b=v(()=>{const t=[];for(const o of Object.values(n||{})){if(o.positionedAbove!=null)continue;const c=r(o.variantId)||r(o.productId),s=j(c,o);if(!s)continue;const e=s?.hostVariantId??s?.host_variant_id;e==null||!r(e)||t.push({id:`${o.id}__host`,hostedProductId:o.id,hostVariantId:e,offset:Array.isArray(s?.position)?s.position:[0,0,0],rotDegY:Array.isArray(s?.rotation)&&s.rotation[1]||0})}return t},[n,r]);return{edgeOf:u,cornerOf:l,isHostAnchored:f,isMovable:p,rawFree:i,splitReliable:I,freeInstances:h,ordered:g,syntheticHosts:b,moveInFlightRef:m,productInstances:n,getProduct:r}}export{S as default};
@@ -1 +1 @@
1
- import ht from"./d803155241.js";import{resolveLockVariantId as lt}from"./061b81ad81.js";const ft=E=>{const O=Number(E);return!Number.isFinite(O)||O===0?null:O},ut=(E,O)=>{const H=Array.isArray(E?.hostVariants)?E.hostVariants:Array.isArray(E?.host_variants)?E.host_variants:[];if(!H.length)return null;const R=J=>String(J?.hostVariantId??J?.host_variant_id)===String(O);return H.find(R)||H.find(J=>J?.isDefault??J?.is_default)||H[0]||null},Mt=(E,O)=>{const H=E?.placementGroup??E?.placement_group;if(H!=null&&String(H)!=="")return String(H);const R=O?.(E?.variantId)||O?.(E?.productId);return String(R?.placementGroup??R?.placement_group??"")};var wt={id:"grouped-chain",label:"Grouped chain (backend + group attach)",mode:"compute",handlesCorners:!0,computeLayout(E,O={}){const{getProduct:H}=O,R=Array.isArray(E)?E:[],J=p=>String(p?.id??p?.instanceId??""),pt=new Map(R.map(p=>[J(p),p])),W=p=>H?.(p?.variantId)||H?.(p?.productId)||null,it=p=>{const x=W(p),w=x?.hostVariants??x?.host_variants;return Array.isArray(w)&&w.length?w:null},et=p=>{const x=p?.positionedAbove??p?.positioned_above??null;return x!=null?String(x):null},tt=p=>et(p)!=null,nt=p=>lt(p)??lt(W(p)),yt=p=>nt(p)!=null,ct=p=>String(p?.variantId??p?.productId??""),ot=new Set,C=p=>ot.has(p),j=R.filter(p=>!tt(p)),U=R.filter(p=>tt(p));if(O.useTransform){const p=Math.PI/180;return R.map(x=>{const w=Array.isArray(x?.position)?x.position:[0,0,0],Z=Array.isArray(x?.rotation)?x.rotation:[0,0,0];return{position:[Number(w[0])||0,Number(w[1])||0,Number(w[2])||0],rotation:[(Number(Z[0])||0)*p,(Number(Z[1])||0)*p,(Number(Z[2])||0)*p]}})}const G=new Map;for(const p of j){const x=Mt(p,H);G.has(x)||G.set(x,[]),G.get(x).push(p)}const g=new Map;for(const[,p]of G){const x=ht.computeLayout(p,O);p.forEach((w,Z)=>{const a=x[Z]||{position:[0,0,0],rotation:[0,0,0]},s=Array.isArray(w?.position)?w.position:[],t=a.position||[0,0,0],o=ft(s[1]);g.set(w,{position:[t[0],o??t[1],t[2]],rotation:a.rotation||[0,0,0]})})}for(const[,p]of G){const x=new Map;for(const a of p){const s=g.get(a)?.position?.[1]||0;s>.01&&x.set(s,(x.get(s)||0)+1)}if(!x.size)continue;let w=0,Z=0;for(const[a,s]of x)s>Z&&(Z=s,w=a);if(!(Z<p.length/2))for(const a of p){const s=g.get(a);s&&(s.position[1]||0)<=.01&&g.set(a,{position:[s.position[0],w,s.position[2]],rotation:s.rotation})}}{const x=t=>{const o=g.get(t);if(!o)return null;const M=o.position,i=-((Array.isArray(o.rotation)?o.rotation[1]:0)||0),h=Math.cos(i),e=Math.sin(i),r=-Math.sin(i),c=Math.cos(i),l=O.getDims?.(t.productId)??O.getDims?.(t.variantId)??null,u=W(t),m=l?.width>.05&&l?.depth>.05,f=m?l.width:u?.width>0?u.width*.0254:.9,A=m?l.depth:u?.depth>0?u.depth*.0254:.95,X=m&&l.cx||0,I=m&&l.cz||0,N=M[0]+h*X+r*I,d=M[2]+e*X+c*I;return[N+h*(f/2)-r*(A/2),d+e*(f/2)-c*(A/2)]},w=new Set;for(const t of R){const o=nt(t);o!=null&&w.add(o)}let Z=null,a=0;for(const[t,o]of G){const M=o.reduce((i,h)=>i+(w.has(ct(h))?1:0),0);M>a&&(a=M,Z=t)}const s=Z!=null?G.get(Z):null;if(s){const t=new Map;for(const o of[...s].sort((M,i)=>Number(M.sequence)-Number(i.sequence))){const M=ct(o);t.has(M)||t.set(M,[]),t.get(M).push(o)}for(const[o,M]of G){if(o===Z)continue;const i=M.map(c=>({inst:c,tv:nt(c),seq:Number(c.sequence)})).filter(c=>c.tv!=null&&Number.isFinite(c.seq)).sort((c,l)=>c.seq-l.seq);if(!i.length)continue;const h=new Map,e=[];for(const c of i){const l=t.get(c.tv);if(!l||!l.length)continue;const u=h.get(c.tv)||0,m=Math.min(u,l.length-1);h.set(c.tv,u+1);const f=l[m],A=x(c.inst),X=x(f);!A||!X||(e.push({seq:c.seq,delta:[X[0]-A[0],X[1]-A[1]],lockInst:c.inst}),ot.add(c.inst),ot.add(f))}if(!e.length)continue;e.sort((c,l)=>c.seq-l.seq);const r=new Map;for(const c of M){const l=Number(c?.sequence);let u=e[0];if(Number.isFinite(l))for(const m of e)if(m.seq<=l)u=m;else break;r.set(c,u.delta)}for(const c of M){const l=g.get(c);if(!l)continue;const u=r.get(c)||e[0].delta;g.set(c,{position:[l.position[0]+u[0],l.position[1],l.position[2]+u[1]],rotation:l.rotation})}}}}{const x=Z=>{const a=O.getDims?.(Z.productId)??O.getDims?.(Z.variantId)??null,s=W(Z),t=a?.width>.05&&a?.depth>.05;return{w:t?a.width:s?.width>0?s.width*.0254:.9,dp:t?a.depth:s?.depth>0?s.depth*.0254:.6,cx:t&&a.cx||0,cz:t&&a.cz||0}},w=Z=>{const a=g.get(Z);if(!a)return null;const[s,,t]=a.position,o=(Array.isArray(a.rotation)?a.rotation[1]:0)||0,{cx:M,cz:i}=x(Z);return{x:s+M*Math.cos(o)+i*Math.sin(o),z:t-M*Math.sin(o)+i*Math.cos(o),y:a.position[1],r:o}};for(const[,Z]of G){const a=Z.filter(r=>C(r)&&Number.isFinite(Number(r.sequence))).map(r=>({inst:r,seq:Number(r.sequence)})).sort((r,c)=>r.seq-c.seq);if(a.length<2)continue;const s=[];for(let r=0;r<a.length-1;r++){const c=a[r].inst,l=a[r+1].inst,u=Z.filter(Y=>{const F=Number(Y?.sequence);return!C(Y)&&Number.isFinite(F)&&F>a[r].seq&&F<a[r+1].seq}).sort((Y,F)=>Number(Y.sequence)-Number(F.sequence));if(!u.length)continue;const m=-((Array.isArray(g.get(u[0])?.rotation)?g.get(u[0]).rotation[1]:0)||0),f=Math.cos(m),A=Math.sin(m),X=-A,I=f,N=Y=>Y.x*f+Y.z*A,d=Y=>{const{w:F,dp:D}=x(Y),P=w(Y);return P?Math.abs(Math.cos(P.r+m))*(F/2)+Math.abs(Math.sin(P.r+m))*(D/2):0},z=w(c),n=w(l);if(!z||!n)continue;const b=N(z),q=N(n),v=q>=b?1:-1,y=b+v*d(c),S=q-v*d(l),L=(S-y)*v,_=u.map(Y=>x(Y).w),k=_.reduce((Y,F)=>Y+F,0),V=new Array(u.length);if(k<=L+.02){const Y=k/2;let F=0,D=u.length;for(let T=0;T<u.length;T++)if(F+=_[T],F>Y){D=T;break}let P=y;for(let T=0;T<D;T++)V[T]=P+v*_[T]/2,P+=v*_[T];P=S;for(let T=u.length-1;T>=D;T--)V[T]=P-v*_[T]/2,P-=v*_[T]}else{let Y=0,F=0;for(let B=0;B<u.length&&!(F+_[B]>L+.02);B++)F+=_[B],Y=B+1;for(let B=Y;B<u.length;B++)s.push(u[B]);const P=_.slice(0,Y).reduce((B,xt)=>B+xt,0)/2;let T=0,K=Y;for(let B=0;B<Y;B++)if(T+=_[B],T>P){K=B;break}let Q=y;for(let B=0;B<K;B++)V[B]=Q+v*_[B]/2,Q+=v*_[B];Q=S;for(let B=Y-1;B>=K;B--)V[B]=Q-v*_[B]/2,Q-=v*_[B]}u.forEach((Y,F)=>{const D=w(Y);if(!D||V[F]==null)return;const{cx:P,cz:T}=x(Y),K=D.x*X+D.z*I,Q=V[F]*f+K*X,B=V[F]*A+K*I;g.set(Y,{position:[Q-(P*Math.cos(D.r)+T*Math.sin(D.r)),D.y,B-(-P*Math.sin(D.r)+T*Math.cos(D.r))],rotation:g.get(Y).rotation})})}const t=(r,c,l)=>{if(!c.length||!r)return;const u=l&&l.rotY!=null,m=u?l.rotY:(Array.isArray(g.get(c[0])?.rotation)?g.get(c[0]).rotation[1]:0)||0,f=-m,A=Math.cos(f),X=Math.sin(f),I=-X,N=A,d=S=>S.x*A+S.z*X,z=w(r);if(!z)return;const n=w(l?.dirRef||c[0]),b=n&&Math.sign(d(n)-d(z))||1,q=x(r),v=Math.abs(Math.cos(z.r+f))*(q.w/2)+Math.abs(Math.sin(z.r+f))*(q.dp/2);let y=d(z)+b*v;for(const S of c){const L=w(S);if(!L)continue;const{w:_,dp:k,cx:V,cz:Y}=x(S),F=y+b*_/2,D=u?m:L.r,P=u?l.perpBack!=null?l.perpBack+k/2:l.perpLine:L.x*I+L.z*N,T=F*A+P*I,K=F*X+P*N;g.set(S,{position:[T-(V*Math.cos(D)+Y*Math.sin(D)),L.y,K-(-V*Math.sin(D)+Y*Math.cos(D))],rotation:u?[0,m,0]:g.get(S).rotation}),y+=b*_}},o=a[0].seq,M=a[a.length-1].seq,i=Z.filter(r=>{const c=Number(r?.sequence);return!C(r)&&Number.isFinite(c)&&c<o}).sort((r,c)=>Number(c.sequence)-Number(r.sequence)),h=Z.filter(r=>{const c=Number(r?.sequence);return!C(r)&&Number.isFinite(c)&&c>M}).sort((r,c)=>Number(r.sequence)-Number(c.sequence));t(a[0].inst,i);const e=a[a.length-1].inst;if(h.length){const r=w(h[0]),c=(Array.isArray(g.get(h[0])?.rotation)?g.get(h[0]).rotation[1]:0)||0,l=-c,u=-Math.sin(l),m=Math.cos(l),f=r?r.x*u+r.z*m:0,A=f-x(h[0]).dp/2,X=[...s,...h],I=X.findIndex(z=>!!z?.corner),N=I>=0?X.slice(0,I+1):X;t(e,N,{rotY:c,perpLine:f,perpBack:A,dirRef:h[0]});const d=I>=0?X.slice(I+1):[];if(d.length){const z=X[I],n=[z,...d],b=ht.computeLayout(n,O)||[],q=g.get(z),v=b[0];if(q&&v){const y=(q.rotation?.[1]||0)-(v.rotation?.[1]||0),S=Math.cos(y),L=Math.sin(y);d.forEach((_,k)=>{const V=b[k+1];if(!V)return;const Y=V.position[0]-v.position[0],F=V.position[2]-v.position[2],D=g.get(_);g.set(_,{position:[q.position[0]+Y*S+F*L,D?.position?.[1]??q.position[1],q.position[2]-Y*L+F*S],rotation:[0,(V.rotation?.[1]||0)+y,0]})})}}}else t(e,s)}}const rt=new Map;for(const p of R){if(!C(p))continue;const x=g.get(p);x?.position&&rt.set(p,x.position.slice())}const dt=()=>{for(const[p,x]of rt){const w=g.get(p);w&&g.set(p,{position:x.slice(),rotation:w.rotation})}};{const x=a=>{const s=O.getDims?.(a.productId)??O.getDims?.(a.variantId)??null,t=W(a);return{w:s?.width>0?s.width:t?.width>0?t.width*.0254:.9,dp:s?.depth>0?s.depth:t?.depth>0?t.depth*.0254:.6,h:s?.height>0?s.height:t?.height>0?t.height*.0254:.9,cx:s?.cx||0,cz:s?.cz||0}},w=a=>{const s=g.get(a);if(!s)return null;const[t,o,M]=s.position,i=(Array.isArray(s.rotation)?s.rotation[1]:0)||0,{w:h,dp:e,h:r,cx:c,cz:l}=x(a),u=Math.cos(i),m=Math.sin(i),f=t+c*u+l*m,A=M-c*m+l*u,X=Math.abs(u),I=Math.abs(m),N=(h*X+e*I)/2,d=(h*I+e*X)/2;let z=f-N,n=f+N,b=A-d,q=A+d;if(tt(a)?null:it(a)){const y=ut(W(a),null),S=Array.isArray(y?.position)?y.position:[0,0,0],L=f+(S[0]||0)*u+(S[2]||0)*m,_=A-(S[0]||0)*m+(S[2]||0)*u;z=Math.min(z,L-N),n=Math.max(n,L+N),b=Math.min(b,_-d),q=Math.max(q,_+d)}return{minX:z,maxX:n,minZ:b,maxZ:q,minY:o,maxY:o+r}};let Z=1/0;for(const a of R){const s=g.get(a)?.position?.[1]||0;s>.01&&s<Z&&(Z=s)}if(Number.isFinite(Z)){const a=new Map,s=new Map;for(const i of j){const h=w(i);h&&(a.set(i,h),s.set(i,(g.get(i)?.position?.[1]||0)>.01))}const t=j.filter(i=>{if(C(i))return!1;const h=a.get(i);return h&&!s.get(i)&&h.maxY>Z+.05}),o=(i,h)=>i.minX<h.maxX-.02&&i.maxX>h.minX+.02&&i.minZ<h.maxZ-.02&&i.maxZ>h.minZ+.02&&i.minY<h.maxY-.02&&i.maxY>h.minY+.02,M=new Set(t);for(const i of t){const h=a.get(i),e=-(g.get(i)?.rotation?.[1]||0),r=Math.cos(e),c=Math.sin(e),l=-c,u=r,m=y=>({lo:Math.min(y.minX*r+y.minZ*c,y.maxX*r+y.maxZ*c),hi:Math.max(y.minX*r+y.minZ*c,y.maxX*r+y.maxZ*c)}),f=y=>(y.minX+y.maxX)/2*l+(y.minZ+y.maxZ)/2*u,A=f(h),X=m(h);let I=!1;for(const y of j){if(!s.get(y))continue;const S=a.get(y);if(S&&o(h,S)){I=!0;break}}if(!I)continue;const N=j.filter(y=>{if(y===i||M.has(y))return!1;const S=-(g.get(y)?.rotation?.[1]||0);if(Math.abs(Math.cos(e-S))<.9)return!1;const L=a.get(y);return L&&Math.abs(f(L)-A)<1});if(!N.length)continue;let d=null;for(const y of[...j,...U]){if(!y?.corner)continue;const S=a.get(y)||w(y);if(!S||Math.abs(f(S)-A)>1.6)continue;const L=m(S);d=(L.lo+L.hi)/2;break}const z=(X.lo+X.hi)/2,n=d!=null&&z<d?-1:1;let b=0;const q=Math.max(...N.map(y=>m(a.get(y)).hi)),v=Math.min(...N.map(y=>m(a.get(y)).lo));if(n>0?b=Math.max(0,q+.005-X.lo):b=Math.min(0,v-.005-X.hi),Math.abs(b)>.005){const y=g.get(i);g.set(i,{position:[y.position[0]+r*b,y.position[1],y.position[2]+c*b],rotation:y.rotation}),a.set(i,w(i))}}}}const at=p=>String(p?.variantId??p?.productId??""),gt=p=>{const x=et(p);if(x!=null)return pt.get(x)||null;const w=it(p)||[],Z=new Set(w.map(a=>String(a?.hostVariantId??a?.host_variant_id)));return R.find(a=>a!==p&&Z.has(at(a)))||null};let $=U.slice(),st=!0;for(;$.length&&st;){st=!1;const p=[];for(const x of $){const w=gt(x),Z=w?g.get(w):null;if(!Z){p.push(x);continue}const a=ut(W(x),at(w)),s=Z.position||[0,0,0],t=(Array.isArray(Z.rotation)?Z.rotation[1]:0)||0,o=Math.cos(t),M=Math.sin(t),i=a&&Array.isArray(a.position)?a.position:[0,0,0],e=(O.getDims?.(w.productId)??O.getDims?.(w.variantId)??null)?.cx||0,r=ft(Array.isArray(x?.position)?x.position[1]:null),c=[s[0]+e*o+(i[2]||0)*M,r??s[1]+(i[1]||0),s[2]-e*M+(i[2]||0)*o],l=a&&Array.isArray(a.rotation)?(a.rotation[1]||0)*Math.PI/180:0;g.set(x,{position:c,rotation:[0,t+l,0]}),st=!0}$=p}for(const p of $){const x=Array.isArray(p?.position)?p.position:[];g.set(p,{position:x.length?x:[0,0,0],rotation:p?.rotation||[0,0,0]})}{const x=[],w=t=>{const o=O.getDims?.(t.productId)??O.getDims?.(t.variantId)??null,M=W(t);return{w:o?.width>0?o.width:M?.width>0?M.width*.0254:.9,dp:o?.depth>0?o.depth:M?.depth>0?M.depth*.0254:.6,h:o?.height>0?o.height:M?.height>0?M.height*.0254:.9,cx:o?.cx||0,cz:o?.cz||0}},Z=t=>{const o=g.get(t);if(!o)return null;const[M,i,h]=o.position,e=(Array.isArray(o.rotation)?o.rotation[1]:0)||0,{w:r,dp:c,h:l,cx:u,cz:m}=w(t),f=Math.cos(e),A=Math.sin(e),X=M+u*f+m*A,I=h-u*A+m*f,N=Math.abs(f),d=Math.abs(A),z=(r*N+c*d)/2,n=(r*d+c*N)/2;return{minX:X-z,maxX:X+z,minZ:I-n,maxZ:I+n,minY:i,maxY:i+l}};let a=1/0;for(const t of R){const o=g.get(t)?.position?.[1]||0;o>.01&&o<a&&(a=o)}const s=t=>(g.get(t)?.position?.[1]||0)>.01;for(const t of U){const o=Z(t);if(!o||o.maxY<=a+.05)continue;const M=-((Array.isArray(g.get(t)?.rotation)?g.get(t).rotation[1]:0)||0),i=Math.cos(M),h=Math.sin(M),e=-h,r=i,c=n=>Math.min(n.minX*i+n.minZ*h,n.maxX*i+n.maxZ*h),l=n=>Math.max(n.minX*i+n.minZ*h,n.maxX*i+n.maxZ*h),u=n=>(n.minX+n.maxX)/2*e+(n.minZ+n.maxZ)/2*r,m=n=>(n.minX+n.maxX)/2*i+(n.minZ+n.maxZ)/2*h,f=c(o),A=l(o),X=(f+A)/2,I=u(o);let N=null;for(const n of[...j,...U]){if(!n?.corner)continue;const b=Z(n);if(b&&!(Math.abs(u(b)-I)>1.6)){N=m(b);break}}const d=N!=null&&X<N?-1:1,z=[];for(const n of j){if(C(n)||!s(n))continue;const b=Z(n);if(!b)continue;const q=-((Array.isArray(g.get(n)?.rotation)?g.get(n).rotation[1]:0)||0);Math.abs(Math.cos(M-q))<.9||Math.abs(u(b)-I)>1||z.push({inst:n,lo:c(b),hi:l(b)})}if(d>0){const n=z.filter(q=>q.hi>f),b=n.filter(q=>q.lo<A);if(b.length){const q=A-Math.min(...b.map(v=>v.lo))+.01;for(const{inst:v}of n){const y=g.get(v);g.set(v,{...y,position:[y.position[0]+i*q,y.position[1],y.position[2]+h*q]})}x.push({chimShift:+q.toFixed(3),dir:"+run",n:n.length})}}else{const n=z.filter(q=>q.lo<A),b=n.filter(q=>q.hi>f);if(b.length){const q=Math.max(...b.map(v=>v.hi))-f+.01;for(const{inst:v}of n){const y=g.get(v);g.set(v,{...y,position:[y.position[0]-i*q,y.position[1],y.position[2]-h*q]})}x.push({chimShift:+q.toFixed(3),dir:"-run",n:n.length})}}}}{const x=s=>{const t=O.getDims?.(s.productId)??O.getDims?.(s.variantId)??null,o=H?.(s.variantId)||H?.(s.productId);return{w:t?.width>0?t.width:o?.width>0?o.width*.0254:.9,dp:t?.depth>0?t.depth:o?.depth>0?o.depth*.0254:.6,h:t?.height>0?t.height:o?.height>0?o.height*.0254:.9,cx:t?.cx||0,cz:t?.cz||0}},w=s=>{const t=g.get(s);if(!t)return null;const[o,M,i]=t.position,h=(Array.isArray(t.rotation)?t.rotation[1]:0)||0,{w:e,dp:r,h:c,cx:l,cz:u}=x(s),m=Math.cos(h),f=Math.sin(h),A=o+l*m+u*f,X=i-l*f+u*m,I=Math.abs(m),N=Math.abs(f),d=(e*I+r*N)/2,z=(e*N+r*I)/2;return{minX:A-d,maxX:A+d,minZ:X-z,maxZ:X+z,minY:M,maxY:M+c}},Z=(s,t)=>s&&t&&s.minX<t.maxX-.02&&s.maxX>t.minX+.02&&s.minZ<t.maxZ-.02&&s.maxZ>t.minZ+.02&&s.minY<t.maxY-.02&&s.maxY>t.minY+.02;let a=1/0;for(const s of R){const t=g.get(s)?.position?.[1]||0;t>.01&&t<a&&(a=t)}if(Number.isFinite(a)){const s=new Map;for(const i of R){const h=w(i);h&&s.set(i,h)}const t=i=>(g.get(i)?.position?.[1]||0)>.01,o=R.filter(i=>{if(C(i))return!1;const h=s.get(i);return h&&!t(i)&&h.maxY>a+.05}),M=new Set(o);for(const i of o){const h=-(g.get(i)?.rotation?.[1]||0),e=Math.cos(h),r=Math.sin(h),c=d=>({lo:Math.min(d.minX*e+d.minZ*r,d.maxX*e+d.maxZ*r),hi:Math.max(d.minX*e+d.minZ*r,d.maxX*e+d.maxZ*r)});let l=s.get(i),u=1/0,m=-1/0,f=!1;for(const d of R){if(d===i||M.has(d)||!t(d))continue;const z=s.get(d);if(!z||!Z(l,z))continue;const n=c(z);u=Math.min(u,n.lo),m=Math.max(m,n.hi),f=!0}if(!f)continue;const A=c(l),X=(A.lo+A.hi)/2,I=(u+m)/2,N=X>=I?m+.005-A.lo:u-.005-A.hi;if(Math.abs(N)>.002){const d=g.get(i);g.set(i,{position:[d.position[0]+e*N,d.position[1],d.position[2]+r*N],rotation:d.rotation}),l=w(i),s.set(i,l)}}}}{const x=s=>{const t=O.getDims?.(s.productId)??O.getDims?.(s.variantId)??null,o=W(s),M=t?.width>.05&&t?.depth>.05;return{w:M?t.width:o?.width>0?o.width*.0254:.9,dp:M?t.depth:o?.depth>0?o.depth*.0254:.6,cx:M&&t.cx||0,cz:M&&t.cz||0}},w=s=>{const t=g.get(s);if(!t)return null;const[o,,M]=t.position,i=(Array.isArray(t.rotation)?t.rotation[1]:0)||0,{cx:h,cz:e}=x(s);return{x:o+h*Math.cos(i)+e*Math.sin(i),z:M-h*Math.sin(i)+e*Math.cos(i),y:t.position[1],r:i}},Z=s=>{const t=w(s);if(!t)return null;const{w:o,dp:M}=x(s),i=Math.abs(Math.cos(t.r)),h=Math.abs(Math.sin(t.r)),e=(o*i+M*h)/2,r=(o*h+M*i)/2;return{minX:t.x-e,maxX:t.x+e,minZ:t.z-r,maxZ:t.z+r}},a=(s,t)=>s&&t&&s.minX<t.maxX-.04&&s.maxX>t.minX+.04&&s.minZ<t.maxZ-.04&&s.maxZ>t.minZ+.04;for(const[,s]of G){const t=s.filter(n=>C(n)&&Number.isFinite(Number(n.sequence))).map(n=>({inst:n,seq:Number(n.sequence)})).sort((n,b)=>n.seq-b.seq);if(!t.length)continue;const o=t[t.length-1].inst,M=t[t.length-1].seq,i=s.filter(n=>!C(n)&&Number.isFinite(Number(n.sequence))).sort((n,b)=>Number(n.sequence)-Number(b.sequence)),h=[];for(const n of t){const b=Z(n.inst);b&&h.push(b)}const e=[];for(const n of i){const b=Z(n);b&&(h.some(q=>a(b,q))?e.push(n):h.push(b))}if(!e.length)continue;const r=i.filter(n=>Number(n.sequence)>M&&!e.includes(n)),c=r.length?(Array.isArray(g.get(r[0])?.rotation)?g.get(r[0]).rotation[1]:0)||0:((Array.isArray(g.get(o)?.rotation)?g.get(o).rotation[1]:0)||0)-Math.PI/2,l=-c,u=Math.cos(l),m=Math.sin(l),f=-m,A=u,X=n=>n.x*u+n.z*m,I=w(o);if(!I)continue;const N=r.length?(()=>{const n=w(r[0]);return n?n.x*f+n.z*A:I.x*f+I.z*A})():I.x*f+I.z*A;let d,z;if(r.length){const n=w(r[0]);d=Math.sign(X(n)-X(I))||1,z=Math.max(...r.map(b=>{const q=w(b);return q?X(q)+d*x(b).w/2:-1/0}))}else{d=1;const n=x(o);z=X(I)+d*(Math.abs(Math.cos(I.r+l))*(n.w/2)+Math.abs(Math.sin(I.r+l))*(n.dp/2))}if(Number.isFinite(z))for(const n of e){const b=w(n);if(!b)continue;const{w:q,cx:v,cz:y}=x(n),S=z+d*q/2,L=S*u+N*f,_=S*m+N*A;g.set(n,{position:[L-(v*Math.cos(c)+y*Math.sin(c)),b.y,_-(-v*Math.sin(c)+y*Math.cos(c))],rotation:[0,c,0]}),z+=d*q}}}{const x=t=>{const o=O.getDims?.(t.productId)??O.getDims?.(t.variantId)??null,M=W(t),i=o?.width>.05&&o?.depth>.05;return{w:i?o.width:M?.width>0?M.width*.0254:.9,dp:i?o.depth:M?.depth>0?M.depth*.0254:.6,cx:i&&o.cx||0,cz:i&&o.cz||0}},w=t=>{const o=g.get(t);if(!o)return null;const[M,,i]=o.position,h=(Array.isArray(o.rotation)?o.rotation[1]:0)||0,{w:e,dp:r,cx:c,cz:l}=x(t),u=M+c*Math.cos(h)+l*Math.sin(h),m=i-c*Math.sin(h)+l*Math.cos(h),f=Math.abs(Math.cos(h)),A=Math.abs(Math.sin(h)),X=(e*f+r*A)/2,I=(e*A+r*f)/2;return{minX:u-X,maxX:u+X,minZ:m-I,maxZ:m+I}};let Z=0,a=0,s=0;for(const t of R){const o=g.get(t);o&&(Z+=o.position[0],a+=o.position[2],s+=1)}s&&(Z/=s,a/=s);for(const[,t]of G){const o=t.filter(e=>C(e)).map(e=>({b:w(e)})).filter(e=>e.b);if(!o.length)continue;const M=t.filter(e=>!C(e)).map(e=>({inst:e,b:w(e)})).filter(e=>e.b);for(const{b:e}of o){const r=(u,m)=>o.some(({b:f})=>f===e?!1:u==="x"?f.minZ<e.maxZ-.05&&f.maxZ>e.minZ+.05&&(m?f.minX>e.maxX:f.maxX<e.minX):f.minX<e.maxX-.05&&f.maxX>e.minX+.05&&(m?f.minZ>e.maxZ:f.maxZ<e.minZ)),c={xp:[],xn:[],zp:[],zn:[]};for(const{inst:u,b:m}of M){const f=m.minZ<e.maxZ-.05&&m.maxZ>e.minZ+.05,A=m.minX<e.maxX-.05&&m.maxX>e.minX+.05;f&&!A?m.minX>=e.maxX?c.xp.push({inst:u,gap:m.minX-e.maxX}):m.maxX<=e.minX&&c.xn.push({inst:u,gap:e.minX-m.maxX}):A&&!f&&(m.minZ>=e.maxZ?c.zp.push({inst:u,gap:m.minZ-e.maxZ}):m.maxZ<=e.minZ&&c.zn.push({inst:u,gap:e.minZ-m.maxZ}))}const l=(u,m,f,A)=>{if(!u.length||r(m,f))return;const X=Math.min(...u.map(N=>N.gap));if(X>.015&&X<.5){const N=A*X;for(const{inst:d}of u){const z=g.get(d);z&&g.set(d,{position:[z.position[0]+(m==="x"?N:0),z.position[1],z.position[2]+(m==="z"?N:0)],rotation:z.rotation})}}const I=m==="x"?"z":"x";for(const{inst:N}of u){const d=w(N),z=g.get(N);if(!(!d||!z))if(I==="z"){const n=mt((d.minZ+d.maxZ)/2,z.position[2],a),b=n?d.maxZ:d.minZ,v=(n?e.maxZ:e.minZ)-b;(n?v>0:v<0)&&Math.abs(v)>.015&&Math.abs(v)<.5&&g.set(N,{position:[z.position[0],z.position[1],z.position[2]+v],rotation:z.rotation})}else{const n=mt((d.minX+d.maxX)/2,z.position[0],Z),b=n?d.maxX:d.minX,v=(n?e.maxX:e.minX)-b;(n?v>0:v<0)&&Math.abs(v)>.015&&Math.abs(v)<.5&&g.set(N,{position:[z.position[0]+v,z.position[1],z.position[2]],rotation:z.rotation})}}};l(c.xp,"x",!0,-1),l(c.xn,"x",!1,1),l(c.zp,"z",!0,-1),l(c.zn,"z",!1,1)}const i=(e,r)=>r==="x"?(e.minX+e.maxX)/2:(e.minZ+e.maxZ)/2,h=(e,r)=>r==="x"?(e.minZ+e.maxZ)/2:(e.minX+e.maxX)/2;for(let e=0;e<o.length;e++)for(let r=e+1;r<o.length;r++){const c=o[e].b,l=o[r].b,u=Math.abs((c.minX+c.maxX)/2-(l.minX+l.maxX)/2),m=Math.abs((c.minZ+c.maxZ)/2-(l.minZ+l.maxZ)/2);let f=null;if(m<.35&&u>.5?f="x":u<.35&&m>.5&&(f="z"),!f)continue;const A=i(c,f)<i(l,f),X=A?c:l,I=A?l:c,N=f==="x"?X.maxX:X.maxZ,d=f==="x"?I.minX:I.minZ,z=h(X,f),n=t.filter(k=>!C(k)).map(k=>({inst:k,b:w(k)})).filter(({b:k})=>k&&i(k,f)>N-.15&&i(k,f)<d+.15&&Math.abs(h(k,f)-z)<.4).sort((k,V)=>i(k.b,f)-i(V.b,f));if(!n.length)continue;const b=n.map(({inst:k})=>x(k).w),q=b.reduce((k,V)=>k+V,0);if(q>d-N+.02)continue;const v=q/2;let y=0,S=n.length;for(let k=0;k<n.length;k++)if(y+=b[k],y>v){S=k;break}const L=(k,V)=>{const Y=g.get(k);if(!Y)return;const F=(Array.isArray(Y.rotation)?Y.rotation[1]:0)||0,{cx:D,cz:P}=x(k);f==="x"?g.set(k,{position:[V-(D*Math.cos(F)+P*Math.sin(F)),Y.position[1],Y.position[2]],rotation:Y.rotation}):g.set(k,{position:[Y.position[0],Y.position[1],V-(-D*Math.sin(F)+P*Math.cos(F))],rotation:Y.rotation})};let _=N;for(let k=0;k<S;k++)L(n[k].inst,_+b[k]/2),_+=b[k];_=d;for(let k=n.length-1;k>=S;k--)L(n[k].inst,_-b[k]/2),_-=b[k]}}}return dt(),R.map(p=>g.get(p)||{position:[0,0,0],rotation:[0,0,0]})}};import{appendTargetFor as Zt,neighborsFor as It,groupByPlacement as Nt}from"./dc812f3e14.js";function mt(E,O,H){const R=E-O;return R<-.01?!0:R>.01?!1:O>H}export{Zt as appendTargetFor,wt as default,Nt as groupByPlacement,It as neighborsFor};
1
+ import ht from"./d803155241.js";import{resolveLockVariantId as lt}from"./061b81ad81.js";const ft=C=>{const B=Number(C);return!Number.isFinite(B)||B===0?null:B},ut=(C,B)=>{const P=Array.isArray(C?.hostVariants)?C.hostVariants:Array.isArray(C?.host_variants)?C.host_variants:[];if(!P.length)return null;const H=K=>String(K?.hostVariantId??K?.host_variant_id)===String(B);return P.find(H)||P.find(K=>K?.isDefault??K?.is_default)||P[0]||null},yt=(C,B)=>{const P=C?.placementGroup??C?.placement_group;if(P!=null&&String(P)!=="")return String(P);const H=B?.(C?.variantId)||B?.(C?.productId);return String(H?.placementGroup??H?.placement_group??"")};var At={id:"grouped-chain",label:"Grouped chain (backend + group attach)",mode:"compute",handlesCorners:!0,computeLayout(C,B={}){const{getProduct:P}=B,H=Array.isArray(C)?C:[],K=u=>String(u?.id??u?.instanceId??""),pt=new Map(H.map(u=>[K(u),u])),G=u=>P?.(u?.variantId)||P?.(u?.productId)||null,it=u=>{const d=G(u),b=d?.hostVariants??d?.host_variants;return Array.isArray(b)&&b.length?b:null},et=u=>{const d=u?.positionedAbove??u?.positioned_above??null;return d!=null?String(d):null},tt=u=>et(u)!=null,nt=u=>lt(u)??lt(G(u)),zt=u=>nt(u)!=null,ct=u=>String(u?.variantId??u?.productId??""),ot=new Set,V=u=>ot.has(u),U=H.filter(u=>!tt(u)),Q=H.filter(u=>tt(u));if(B.useTransform){const u=Math.PI/180;return H.map(d=>{const b=Array.isArray(d?.position)?d.position:[0,0,0],v=Array.isArray(d?.rotation)?d.rotation:[0,0,0];return{position:[Number(b[0])||0,Number(b[1])||0,Number(b[2])||0],rotation:[(Number(v[0])||0)*u,(Number(v[1])||0)*u,(Number(v[2])||0)*u]}})}const W=new Map;for(const u of U){const d=yt(u,P);W.has(d)||W.set(d,[]),W.get(d).push(u)}const g=new Map,dt=new Set;for(const[,u]of W){const d=ht.computeLayout(u,B);u.forEach((b,v)=>{const h=d[v]||{position:[0,0,0],rotation:[0,0,0]},i=Array.isArray(b?.position)?b.position:[],t=h.position||[0,0,0],c=ft(i[1]);g.set(b,{position:[t[0],c??t[1],t[2]],rotation:h.rotation||[0,0,0]})})}for(const[,u]of W){const d=new Map;for(const h of u){const i=g.get(h)?.position?.[1]||0;i>.01&&d.set(i,(d.get(i)||0)+1)}if(!d.size)continue;let b=0,v=0;for(const[h,i]of d)i>v&&(v=i,b=h);if(!(v<u.length/2))for(const h of u){const i=g.get(h);i&&(i.position[1]||0)<=.01&&g.set(h,{position:[i.position[0],b,i.position[2]],rotation:i.rotation})}}{const d=t=>{const c=g.get(t);if(!c)return null;const y=c.position,m=-((Array.isArray(c.rotation)?c.rotation[1]:0)||0),p=Math.cos(m),r=Math.sin(m),o=-Math.sin(m),s=Math.cos(m),a=B.getDims?.(t.productId,t)??B.getDims?.(t.variantId,t)??null,f=G(t),x=a?.width>.05&&a?.depth>.05,l=x?a.width:f?.width>0?f.width*.0254:.9,z=x?a.depth:f?.depth>0?f.depth*.0254:.95,I=x&&a.cx||0,X=x&&a.cz||0,S=y[0]+p*I+o*X,N=y[2]+r*I+s*X;return[S+p*(l/2)-o*(z/2),N+r*(l/2)-s*(z/2)]},b=new Set;for(const t of H){const c=nt(t);c!=null&&b.add(c)}let v=null,h=0;for(const[t,c]of W){const y=c.reduce((m,p)=>m+(b.has(ct(p))?1:0),0);y>h&&(h=y,v=t)}const i=v!=null?W.get(v):null;if(i){const t=new Map;for(const c of[...i].sort((y,m)=>Number(y.sequence)-Number(m.sequence))){const y=ct(c);t.has(y)||t.set(y,[]),t.get(y).push(c)}for(const[c,y]of W){if(c===v)continue;const m=y.map(s=>({inst:s,tv:nt(s),seq:Number(s.sequence)})).filter(s=>s.tv!=null&&Number.isFinite(s.seq)).sort((s,a)=>s.seq-a.seq);if(!m.length)continue;const p=new Map,r=[];for(const s of m){const a=t.get(s.tv);if(!a||!a.length)continue;const f=p.get(s.tv)||0,x=Math.min(f,a.length-1);p.set(s.tv,f+1);const l=a[x],z=d(s.inst),I=d(l);!z||!I||(r.push({seq:s.seq,delta:[I[0]-z[0],I[1]-z[1]],lockInst:s.inst}),ot.add(s.inst),ot.add(l))}if(!r.length)continue;r.sort((s,a)=>s.seq-a.seq);const o=new Map;for(const s of y){const a=Number(s?.sequence);let f=r[0];if(Number.isFinite(a))for(const x of r)if(x.seq<=a)f=x;else break;o.set(s,f.delta)}for(const s of y){const a=g.get(s);if(!a)continue;const f=o.get(s)||r[0].delta;g.set(s,{position:[a.position[0]+f[0],a.position[1],a.position[2]+f[1]],rotation:a.rotation})}}}}{const d=v=>{const h=B.getDims?.(v.productId,v)??B.getDims?.(v.variantId,v)??null,i=G(v),t=h?.width>.05&&h?.depth>.05;return{w:t?h.width:i?.width>0?i.width*.0254:.9,dp:t?h.depth:i?.depth>0?i.depth*.0254:.6,cx:t&&h.cx||0,cz:t&&h.cz||0}},b=v=>{const h=g.get(v);if(!h)return null;const[i,,t]=h.position,c=(Array.isArray(h.rotation)?h.rotation[1]:0)||0,{cx:y,cz:m}=d(v);return{x:i+y*Math.cos(c)+m*Math.sin(c),z:t-y*Math.sin(c)+m*Math.cos(c),y:h.position[1],r:c}};for(const[,v]of W){const h=v.filter(o=>V(o)&&Number.isFinite(Number(o.sequence))).map(o=>({inst:o,seq:Number(o.sequence)})).sort((o,s)=>o.seq-s.seq);if(h.length<2)continue;const i=[];for(let o=0;o<h.length-1;o++){const s=h[o].inst,a=h[o+1].inst,f=v.filter(e=>{const A=Number(e?.sequence);return!V(e)&&Number.isFinite(A)&&A>h[o].seq&&A<h[o+1].seq}).sort((e,A)=>Number(e.sequence)-Number(A.sequence));if(!f.length)continue;const x=-((Array.isArray(g.get(f[0])?.rotation)?g.get(f[0]).rotation[1]:0)||0),l=Math.cos(x),z=Math.sin(x),I=-z,X=l,S=e=>e.x*l+e.z*z,N=e=>{const{w:A,dp:L}=d(e),E=b(e);return E?Math.abs(Math.cos(E.r+x))*(A/2)+Math.abs(Math.sin(E.r+x))*(L/2):0},Z=b(s),n=b(a);if(!Z||!n)continue;const M=S(Z),q=S(n),Y=q>=M?1:-1,O=M+Y*N(s),F=q-Y*N(a),T=(F-O)*Y,_=f.map(e=>d(e).w),k=_.reduce((e,A)=>e+A,0),w=new Array(f.length);if(k<=T+.02){const e=k/2;let A=0,L=f.length;for(let R=0;R<f.length;R++)if(A+=_[R],A>e){L=R;break}let E=O;for(let R=0;R<L;R++)w[R]=E+Y*_[R]/2,E+=Y*_[R];E=F;for(let R=f.length-1;R>=L;R--)w[R]=E-Y*_[R]/2,E-=Y*_[R]}else{let e=0,A=0;for(let D=0;D<f.length&&!(A+_[D]>T+.02);D++)A+=_[D],e=D+1;for(let D=e;D<f.length;D++)i.push(f[D]);const E=_.slice(0,e).reduce((D,Mt)=>D+Mt,0)/2;let R=0,j=e;for(let D=0;D<e;D++)if(R+=_[D],R>E){j=D;break}let J=O;for(let D=0;D<j;D++)w[D]=J+Y*_[D]/2,J+=Y*_[D];J=F;for(let D=e-1;D>=j;D--)w[D]=J-Y*_[D]/2,J-=Y*_[D]}f.forEach((e,A)=>{const L=b(e);if(!L||w[A]==null)return;const{cx:E,cz:R}=d(e),j=L.x*I+L.z*X,J=w[A]*l+j*I,D=w[A]*z+j*X;g.set(e,{position:[J-(E*Math.cos(L.r)+R*Math.sin(L.r)),L.y,D-(-E*Math.sin(L.r)+R*Math.cos(L.r))],rotation:g.get(e).rotation})})}const t=(o,s,a)=>{if(!s.length||!o)return;const f=a&&a.rotY!=null,x=f?a.rotY:(Array.isArray(g.get(s[0])?.rotation)?g.get(s[0]).rotation[1]:0)||0,l=-x,z=Math.cos(l),I=Math.sin(l),X=-I,S=z,N=F=>F.x*z+F.z*I,Z=b(o);if(!Z)return;const n=b(a?.dirRef||s[0]),M=n&&Math.sign(N(n)-N(Z))||1,q=d(o),Y=Math.abs(Math.cos(Z.r+l))*(q.w/2)+Math.abs(Math.sin(Z.r+l))*(q.dp/2);let O=N(Z)+M*Y;for(const F of s){const T=b(F);if(!T)continue;const{w:_,dp:k,cx:w,cz:e}=d(F),A=O+M*_/2,L=f?x:T.r,E=f?a.perpBack!=null?a.perpBack+k/2:a.perpLine:T.x*X+T.z*S,R=A*z+E*X,j=A*I+E*S;g.set(F,{position:[R-(w*Math.cos(L)+e*Math.sin(L)),T.y,j-(-w*Math.sin(L)+e*Math.cos(L))],rotation:f?[0,x,0]:g.get(F).rotation}),O+=M*_}},c=h[0].seq,y=h[h.length-1].seq,m=v.filter(o=>{const s=Number(o?.sequence);return!V(o)&&Number.isFinite(s)&&s<c}).sort((o,s)=>Number(s.sequence)-Number(o.sequence)),p=v.filter(o=>{const s=Number(o?.sequence);return!V(o)&&Number.isFinite(s)&&s>y}).sort((o,s)=>Number(o.sequence)-Number(s.sequence));t(h[0].inst,m);const r=h[h.length-1].inst;if(p.length){const o=b(p[0]),s=(Array.isArray(g.get(p[0])?.rotation)?g.get(p[0]).rotation[1]:0)||0,a=-s,f=-Math.sin(a),x=Math.cos(a),l=o?o.x*f+o.z*x:0,z=l-d(p[0]).dp/2,I=[...i,...p],X=I.findIndex(Z=>!!Z?.corner),S=X>=0?I.slice(0,X+1):I;t(r,S,{rotY:s,perpLine:l,perpBack:z,dirRef:p[0]});const N=X>=0?I.slice(X+1):[];if(N.length){const Z=I[X],n=[Z,...N],M=ht.computeLayout(n,B)||[],q=g.get(Z),Y=M[0];if(q&&Y){const O=(q.rotation?.[1]||0)-(Y.rotation?.[1]||0),F=Math.cos(O),T=Math.sin(O);N.forEach((_,k)=>{const w=M[k+1];if(!w)return;const e=w.position[0]-Y.position[0],A=w.position[2]-Y.position[2],L=g.get(_);g.set(_,{position:[q.position[0]+e*F+A*T,L?.position?.[1]??q.position[1],q.position[2]-e*T+A*F],rotation:[0,(w.rotation?.[1]||0)+O,0]})})}}}else t(r,i)}}const rt=new Map;for(const u of H){if(!V(u))continue;const d=g.get(u);d?.position&&rt.set(u,d.position.slice())}const gt=()=>{for(const[u,d]of rt){const b=g.get(u);b&&g.set(u,{position:d.slice(),rotation:b.rotation})}};{const d=h=>{const i=B.getDims?.(h.productId,h)??B.getDims?.(h.variantId,h)??null,t=G(h);return{w:i?.width>0?i.width:t?.width>0?t.width*.0254:.9,dp:i?.depth>0?i.depth:t?.depth>0?t.depth*.0254:.6,h:i?.height>0?i.height:t?.height>0?t.height*.0254:.9,cx:i?.cx||0,cz:i?.cz||0}},b=h=>{const i=g.get(h);if(!i)return null;const[t,c,y]=i.position,m=(Array.isArray(i.rotation)?i.rotation[1]:0)||0,{w:p,dp:r,h:o,cx:s,cz:a}=d(h),f=Math.cos(m),x=Math.sin(m),l=t+s*f+a*x,z=y-s*x+a*f,I=Math.abs(f),X=Math.abs(x),S=(p*I+r*X)/2,N=(p*X+r*I)/2;let Z=l-S,n=l+S,M=z-N,q=z+N;if(tt(h)?null:it(h)){const O=ut(G(h),null),F=Array.isArray(O?.position)?O.position:[0,0,0],T=l+(F[0]||0)*f+(F[2]||0)*x,_=z-(F[0]||0)*x+(F[2]||0)*f;Z=Math.min(Z,T-S),n=Math.max(n,T+S),M=Math.min(M,_-N),q=Math.max(q,_+N)}return{minX:Z,maxX:n,minZ:M,maxZ:q,minY:c,maxY:c+o}};let v=1/0;for(const h of H){const i=g.get(h)?.position?.[1]||0;i>.01&&i<v&&(v=i)}if(Number.isFinite(v)){const h=new Map,i=new Map;for(const o of U){const s=b(o);s&&(h.set(o,s),i.set(o,(g.get(o)?.position?.[1]||0)>.01))}const t=U.filter(o=>{if(V(o))return!1;const s=h.get(o);return s&&!i.get(o)&&s.maxY>v+.05}),c=(o,s)=>o.minX<s.maxX-.02&&o.maxX>s.minX+.02&&o.minZ<s.maxZ-.02&&o.maxZ>s.minZ+.02&&o.minY<s.maxY-.02&&o.maxY>s.minY+.02,y=o=>{const s=-(g.get(o)?.rotation?.[1]||0),a=Math.cos(s),f=Math.sin(s);return{ht:s,rx:a,rz:f,nx:-f,nz:a}},m=(o,s,a)=>({lo:Math.min(o.minX*s+o.minZ*a,o.maxX*s+o.maxZ*a),hi:Math.max(o.minX*s+o.minZ*a,o.maxX*s+o.maxZ*a)}),p=(o,s,a)=>(o.minX+o.maxX)/2*s+(o.minZ+o.maxZ)/2*a,r=new Set;for(const o of t){if(r.has(o))continue;const{ht:s,rx:a,rz:f,nx:x,nz:l}=y(o),z=p(h.get(o),x,l),I=w=>{const e=-(g.get(w)?.rotation?.[1]||0);if(Math.abs(Math.cos(s-e))<.9)return!1;const A=h.get(w);return!!A&&Math.abs(p(A,x,l)-z)<1},X=t.filter(w=>!r.has(w)&&I(w));X.forEach(w=>r.add(w));const S=U.filter(w=>i.get(w)&&I(w));if(!S.length)continue;let N=null;for(const w of[...U,...Q]){if(!w?.corner)continue;const e=h.get(w)||b(w);if(!e||Math.abs(p(e,x,l)-z)>1.6)continue;const A=m(e,a,f);N=(A.lo+A.hi)/2;break}const Z=w=>{const e=m(h.get(w),a,f);return(e.lo+e.hi)/2},n=N!=null&&Z(X[0])<N?-1:1;X.sort((w,e)=>(Z(w)-Z(e))*n);const M=X.findIndex(w=>S.some(e=>c(h.get(w),h.get(e))));if(M<0)continue;const q=X[M],Y=Math.max(...S.map(w=>m(h.get(w),a,f).hi)),O=Math.min(...S.map(w=>m(h.get(w),a,f).lo)),F=m(h.get(q),a,f),T=n>0?Math.max(0,Y+.005-F.lo):Math.min(0,O-.005-F.hi);if(Math.abs(T)<.005)continue;const _=Z(q),k=U.filter(w=>{if(w===q)return!0;if(i.get(w)||V(w)||!I(w))return!1;const e=m(h.get(w),a,f),A=(e.lo+e.hi)/2;return n>0?A>_-.01:A<_+.01});for(const w of k){const e=g.get(w);g.set(w,{position:[e.position[0]+a*T,e.position[1],e.position[2]+f*T],rotation:e.rotation}),h.set(w,b(w))}}}}const at=u=>String(u?.variantId??u?.productId??""),xt=u=>{const d=et(u);if(d!=null)return pt.get(d)||null;const b=it(u)||[],v=new Set(b.map(h=>String(h?.hostVariantId??h?.host_variant_id)));return H.find(h=>h!==u&&v.has(at(h)))||null};let $=Q.slice(),st=!0;for(;$.length&&st;){st=!1;const u=[];for(const d of $){const b=xt(d),v=b?g.get(b):null;if(!v){u.push(d);continue}const h=ut(G(d),at(b)),i=v.position||[0,0,0],t=(Array.isArray(v.rotation)?v.rotation[1]:0)||0,c=Math.cos(t),y=Math.sin(t),m=h&&Array.isArray(h.position)?h.position:[0,0,0],r=(B.getDims?.(b.productId,b)??B.getDims?.(b.variantId,b)??null)?.cx||0,o=ft(Array.isArray(d?.position)?d.position[1]:null),s=[i[0]+r*c+(m[2]||0)*y,o??i[1]+(m[1]||0),i[2]-r*y+(m[2]||0)*c],a=h&&Array.isArray(h.rotation)?(h.rotation[1]||0)*Math.PI/180:0;g.set(d,{position:s,rotation:[0,t+a,0]}),st=!0}$=u}for(const u of $){const d=Array.isArray(u?.position)?u.position:[];g.set(u,{position:d.length?d:[0,0,0],rotation:u?.rotation||[0,0,0]})}{const d=[],b=t=>{const c=B.getDims?.(t.productId,t)??B.getDims?.(t.variantId,t)??null,y=G(t);return{w:c?.width>0?c.width:y?.width>0?y.width*.0254:.9,dp:c?.depth>0?c.depth:y?.depth>0?y.depth*.0254:.6,h:c?.height>0?c.height:y?.height>0?y.height*.0254:.9,cx:c?.cx||0,cz:c?.cz||0}},v=t=>{const c=g.get(t);if(!c)return null;const[y,m,p]=c.position,r=(Array.isArray(c.rotation)?c.rotation[1]:0)||0,{w:o,dp:s,h:a,cx:f,cz:x}=b(t),l=Math.cos(r),z=Math.sin(r),I=y+f*l+x*z,X=p-f*z+x*l,S=Math.abs(l),N=Math.abs(z),Z=(o*S+s*N)/2,n=(o*N+s*S)/2;return{minX:I-Z,maxX:I+Z,minZ:X-n,maxZ:X+n,minY:m,maxY:m+a}};let h=1/0;for(const t of H){const c=g.get(t)?.position?.[1]||0;c>.01&&c<h&&(h=c)}const i=t=>(g.get(t)?.position?.[1]||0)>.01;for(const t of Q){const c=v(t);if(!c||c.maxY<=h+.05)continue;const y=-((Array.isArray(g.get(t)?.rotation)?g.get(t).rotation[1]:0)||0),m=Math.cos(y),p=Math.sin(y),r=-p,o=m,s=n=>Math.min(n.minX*m+n.minZ*p,n.maxX*m+n.maxZ*p),a=n=>Math.max(n.minX*m+n.minZ*p,n.maxX*m+n.maxZ*p),f=n=>(n.minX+n.maxX)/2*r+(n.minZ+n.maxZ)/2*o,x=n=>(n.minX+n.maxX)/2*m+(n.minZ+n.maxZ)/2*p,l=s(c),z=a(c),I=(l+z)/2,X=f(c);let S=null;for(const n of[...U,...Q]){if(!n?.corner)continue;const M=v(n);if(M&&!(Math.abs(f(M)-X)>1.6)){S=x(M);break}}const N=S!=null&&I<S?-1:1,Z=[];for(const n of U){if(V(n)||!i(n))continue;const M=v(n);if(!M)continue;const q=-((Array.isArray(g.get(n)?.rotation)?g.get(n).rotation[1]:0)||0);Math.abs(Math.cos(y-q))<.9||Math.abs(f(M)-X)>1||Z.push({inst:n,lo:s(M),hi:a(M)})}if(N>0){const n=Z.filter(q=>q.hi>l),M=n.filter(q=>q.lo<z);if(M.length){const q=z-Math.min(...M.map(Y=>Y.lo))+.01;for(const{inst:Y}of n){const O=g.get(Y);g.set(Y,{...O,position:[O.position[0]+m*q,O.position[1],O.position[2]+p*q]})}d.push({chimShift:+q.toFixed(3),dir:"+run",n:n.length})}}else{const n=Z.filter(q=>q.lo<z),M=n.filter(q=>q.hi>l);if(M.length){const q=Math.max(...M.map(Y=>Y.hi))-l+.01;for(const{inst:Y}of n){const O=g.get(Y);g.set(Y,{...O,position:[O.position[0]-m*q,O.position[1],O.position[2]-p*q]})}d.push({chimShift:+q.toFixed(3),dir:"-run",n:n.length})}}}}{const d=i=>{const t=B.getDims?.(i.productId,i)??B.getDims?.(i.variantId,i)??null,c=P?.(i.variantId)||P?.(i.productId);return{w:t?.width>0?t.width:c?.width>0?c.width*.0254:.9,dp:t?.depth>0?t.depth:c?.depth>0?c.depth*.0254:.6,h:t?.height>0?t.height:c?.height>0?c.height*.0254:.9,cx:t?.cx||0,cz:t?.cz||0}},b=i=>{const t=g.get(i);if(!t)return null;const[c,y,m]=t.position,p=(Array.isArray(t.rotation)?t.rotation[1]:0)||0,{w:r,dp:o,h:s,cx:a,cz:f}=d(i),x=Math.cos(p),l=Math.sin(p),z=c+a*x+f*l,I=m-a*l+f*x,X=Math.abs(x),S=Math.abs(l),N=(r*X+o*S)/2,Z=(r*S+o*X)/2;return{minX:z-N,maxX:z+N,minZ:I-Z,maxZ:I+Z,minY:y,maxY:y+s}},v=(i,t)=>i&&t&&i.minX<t.maxX-.02&&i.maxX>t.minX+.02&&i.minZ<t.maxZ-.02&&i.maxZ>t.minZ+.02&&i.minY<t.maxY-.02&&i.maxY>t.minY+.02;let h=1/0;for(const i of H){const t=g.get(i)?.position?.[1]||0;t>.01&&t<h&&(h=t)}if(Number.isFinite(h)){const i=new Map;for(const p of H){const r=b(p);r&&i.set(p,r)}const t=p=>(g.get(p)?.position?.[1]||0)>.01,c=H.filter(p=>{if(V(p))return!1;const r=i.get(p);return r&&!t(p)&&r.maxY>h+.05}),y=new Set(c),m=new Set;for(const p of c){if(m.has(p))continue;const r=-(g.get(p)?.rotation?.[1]||0),o=Math.cos(r),s=Math.sin(r),a=-s,f=o,x=e=>({lo:Math.min(e.minX*o+e.minZ*s,e.maxX*o+e.maxZ*s),hi:Math.max(e.minX*o+e.minZ*s,e.maxX*o+e.maxZ*s)}),l=e=>(e.minX+e.maxX)/2*a+(e.minZ+e.maxZ)/2*f,z=i.get(p);if(!z){m.add(p);continue}const I=l(z),X=e=>{const A=-(g.get(e)?.rotation?.[1]||0);if(Math.abs(Math.cos(r-A))<.9)return!1;const L=i.get(e);return!!L&&Math.abs(l(L)-I)<1},S=c.filter(e=>!m.has(e)&&X(e));S.forEach(e=>m.add(e));const N=H.filter(e=>!y.has(e)&&t(e)&&X(e));if(!N.length)continue;let Z=null;for(const e of H){if(!e?.corner)continue;const A=i.get(e);if(!A||Math.abs(l(A)-I)>1.6)continue;const L=x(A);Z=(L.lo+L.hi)/2;break}const n=e=>{const A=x(i.get(e));return(A.lo+A.hi)/2},M=Z!=null&&n(S[0])<Z?-1:1;S.sort((e,A)=>(n(e)-n(A))*M);const q=S.findIndex(e=>N.some(A=>v(i.get(e),i.get(A))));if(q<0)continue;const Y=S[q],O=Math.max(...N.map(e=>x(i.get(e)).hi)),F=Math.min(...N.map(e=>x(i.get(e)).lo)),T=x(i.get(Y)),_=M>0?Math.max(0,O+.005-T.lo):Math.min(0,F-.005-T.hi);if(Math.abs(_)<.002)continue;const k=n(Y),w=H.filter(e=>{if(e===Y)return!0;if(t(e)||V(e)||!X(e))return!1;const A=n(e);return M>0?A>k-.01:A<k+.01});for(const e of w){const A=g.get(e);g.set(e,{position:[A.position[0]+o*_,A.position[1],A.position[2]+s*_],rotation:A.rotation}),i.set(e,b(e))}}}}{const d=i=>{const t=B.getDims?.(i.productId,i)??B.getDims?.(i.variantId,i)??null,c=G(i),y=t?.width>.05&&t?.depth>.05;return{w:y?t.width:c?.width>0?c.width*.0254:.9,dp:y?t.depth:c?.depth>0?c.depth*.0254:.6,cx:y&&t.cx||0,cz:y&&t.cz||0}},b=i=>{const t=g.get(i);if(!t)return null;const[c,,y]=t.position,m=(Array.isArray(t.rotation)?t.rotation[1]:0)||0,{cx:p,cz:r}=d(i);return{x:c+p*Math.cos(m)+r*Math.sin(m),z:y-p*Math.sin(m)+r*Math.cos(m),y:t.position[1],r:m}},v=i=>{const t=b(i);if(!t)return null;const{w:c,dp:y}=d(i),m=Math.abs(Math.cos(t.r)),p=Math.abs(Math.sin(t.r)),r=(c*m+y*p)/2,o=(c*p+y*m)/2;return{minX:t.x-r,maxX:t.x+r,minZ:t.z-o,maxZ:t.z+o}},h=(i,t)=>i&&t&&i.minX<t.maxX-.04&&i.maxX>t.minX+.04&&i.minZ<t.maxZ-.04&&i.maxZ>t.minZ+.04;for(const[,i]of W){const t=i.filter(n=>V(n)&&Number.isFinite(Number(n.sequence))).map(n=>({inst:n,seq:Number(n.sequence)})).sort((n,M)=>n.seq-M.seq);if(!t.length)continue;const c=t[t.length-1].inst,y=t[t.length-1].seq,m=i.filter(n=>!V(n)&&Number.isFinite(Number(n.sequence))).sort((n,M)=>Number(n.sequence)-Number(M.sequence)),p=[];for(const n of t){const M=v(n.inst);M&&p.push(M)}const r=[];for(const n of m){const M=v(n);M&&(p.some(q=>h(M,q))?r.push(n):p.push(M))}if(!r.length)continue;const o=m.filter(n=>Number(n.sequence)>y&&!r.includes(n)),s=o.length?(Array.isArray(g.get(o[0])?.rotation)?g.get(o[0]).rotation[1]:0)||0:((Array.isArray(g.get(c)?.rotation)?g.get(c).rotation[1]:0)||0)-Math.PI/2,a=-s,f=Math.cos(a),x=Math.sin(a),l=-x,z=f,I=n=>n.x*f+n.z*x,X=b(c);if(!X)continue;const S=o.length?(()=>{const n=b(o[0]);return n?n.x*l+n.z*z:X.x*l+X.z*z})():X.x*l+X.z*z;let N,Z;if(o.length){const n=b(o[0]);N=Math.sign(I(n)-I(X))||1,Z=Math.max(...o.map(M=>{const q=b(M);return q?I(q)+N*d(M).w/2:-1/0}))}else{N=1;const n=d(c);Z=I(X)+N*(Math.abs(Math.cos(X.r+a))*(n.w/2)+Math.abs(Math.sin(X.r+a))*(n.dp/2))}if(Number.isFinite(Z))for(const n of r){const M=b(n);if(!M)continue;const{w:q,cx:Y,cz:O}=d(n),F=Z+N*q/2,T=F*f+S*l,_=F*x+S*z;g.set(n,{position:[T-(Y*Math.cos(s)+O*Math.sin(s)),M.y,_-(-Y*Math.sin(s)+O*Math.cos(s))],rotation:[0,s,0]}),Z+=N*q}}}{const d=t=>{const c=B.getDims?.(t.productId,t)??B.getDims?.(t.variantId,t)??null,y=G(t),m=c?.width>.05&&c?.depth>.05;return{w:m?c.width:y?.width>0?y.width*.0254:.9,dp:m?c.depth:y?.depth>0?y.depth*.0254:.6,cx:m&&c.cx||0,cz:m&&c.cz||0}},b=t=>{const c=g.get(t);if(!c)return null;const[y,,m]=c.position,p=(Array.isArray(c.rotation)?c.rotation[1]:0)||0,{w:r,dp:o,cx:s,cz:a}=d(t),f=y+s*Math.cos(p)+a*Math.sin(p),x=m-s*Math.sin(p)+a*Math.cos(p),l=Math.abs(Math.cos(p)),z=Math.abs(Math.sin(p)),I=(r*l+o*z)/2,X=(r*z+o*l)/2;return{minX:f-I,maxX:f+I,minZ:x-X,maxZ:x+X}};let v=0,h=0,i=0;for(const t of H){const c=g.get(t);c&&(v+=c.position[0],h+=c.position[2],i+=1)}i&&(v/=i,h/=i);for(const[,t]of W){const c=t.filter(r=>V(r)).map(r=>({b:b(r)})).filter(r=>r.b);if(!c.length)continue;const y=t.filter(r=>!V(r)).map(r=>({inst:r,b:b(r)})).filter(r=>r.b);for(const{b:r}of c){const o=(x,l)=>c.some(({b:z})=>z===r?!1:x==="x"?z.minZ<r.maxZ-.05&&z.maxZ>r.minZ+.05&&(l?z.minX>r.maxX:z.maxX<r.minX):z.minX<r.maxX-.05&&z.maxX>r.minX+.05&&(l?z.minZ>r.maxZ:z.maxZ<r.minZ)),a={xp:[],xn:[],zp:[],zn:[]};for(const{inst:x,b:l}of y){const z=l.minZ<r.maxZ-.05&&l.maxZ>r.minZ+.05,I=l.minX<r.maxX-.05&&l.maxX>r.minX+.05;z&&!I?l.minX>=r.maxX-.02?a.xp.push({inst:x,gap:Math.max(0,l.minX-r.maxX)}):l.maxX<=r.minX+.02&&a.xn.push({inst:x,gap:Math.max(0,r.minX-l.maxX)}):I&&!z&&(l.minZ>=r.maxZ-.02?a.zp.push({inst:x,gap:Math.max(0,l.minZ-r.maxZ)}):l.maxZ<=r.minZ+.02&&a.zn.push({inst:x,gap:Math.max(0,r.minZ-l.maxZ)}))}const f=(x,l,z,I)=>{if(!x.length||o(l,z))return;const X=Math.min(...x.map(N=>N.gap));if(X>.015&&X<.5){const N=I*X;for(const{inst:Z}of x){const n=g.get(Z);n&&g.set(Z,{position:[n.position[0]+(l==="x"?N:0),n.position[1],n.position[2]+(l==="z"?N:0)],rotation:n.rotation})}}const S=l==="x"?"z":"x";for(const{inst:N}of x){const Z=b(N),n=g.get(N);if(!(!Z||!n))if(S==="z"){const M=mt((Z.minZ+Z.maxZ)/2,n.position[2],h),q=M?Z.maxZ:Z.minZ,O=(M?r.maxZ:r.minZ)-q;(M?O>0:O<0)&&Math.abs(O)>.015&&Math.abs(O)<.5&&g.set(N,{position:[n.position[0],n.position[1],n.position[2]+O],rotation:n.rotation})}else{const M=mt((Z.minX+Z.maxX)/2,n.position[0],v),q=M?Z.maxX:Z.minX,O=(M?r.maxX:r.minX)-q;(M?O>0:O<0)&&Math.abs(O)>.015&&Math.abs(O)<.5&&g.set(N,{position:[n.position[0]+O,n.position[1],n.position[2]],rotation:n.rotation})}}};f(a.xp,"x",!0,-1),f(a.xn,"x",!1,1),f(a.zp,"z",!0,-1),f(a.zn,"z",!1,1)}const m=(r,o)=>o==="x"?(r.minX+r.maxX)/2:(r.minZ+r.maxZ)/2,p=(r,o)=>o==="x"?(r.minZ+r.maxZ)/2:(r.minX+r.maxX)/2;for(let r=0;r<c.length;r++)for(let o=r+1;o<c.length;o++){const s=c[r].b,a=c[o].b,f=Math.abs((s.minX+s.maxX)/2-(a.minX+a.maxX)/2),x=Math.abs((s.minZ+s.maxZ)/2-(a.minZ+a.maxZ)/2);let l=null;if(x<.35&&f>.5?l="x":f<.35&&x>.5&&(l="z"),!l)continue;const z=m(s,l)<m(a,l),I=z?s:a,X=z?a:s,S=l==="x"?I.maxX:I.maxZ,N=l==="x"?X.minX:X.minZ,Z=p(I,l),n=t.filter(k=>!V(k)).map(k=>({inst:k,b:b(k)})).filter(({b:k})=>k&&m(k,l)>S-.15&&m(k,l)<N+.15&&Math.abs(p(k,l)-Z)<.4).sort((k,w)=>m(k.b,l)-m(w.b,l));if(!n.length)continue;const M=n.map(({inst:k})=>d(k).w),q=M.reduce((k,w)=>k+w,0);if(q>N-S+.02)continue;const Y=q/2;let O=0,F=n.length;for(let k=0;k<n.length;k++)if(O+=M[k],O>Y){F=k;break}const T=(k,w)=>{const e=g.get(k);if(!e)return;const A=(Array.isArray(e.rotation)?e.rotation[1]:0)||0,{cx:L,cz:E}=d(k);l==="x"?g.set(k,{position:[w-(L*Math.cos(A)+E*Math.sin(A)),e.position[1],e.position[2]],rotation:e.rotation}):g.set(k,{position:[e.position[0],e.position[1],w-(-L*Math.sin(A)+E*Math.cos(A))],rotation:e.rotation})};let _=S;for(let k=0;k<F;k++)T(n[k].inst,_+M[k]/2),_+=M[k];_=N;for(let k=n.length-1;k>=F;k--)T(n[k].inst,_-M[k]/2),_-=M[k]}}}return gt(),H.map(u=>{const d=g.get(u)||{position:[0,0,0],rotation:[0,0,0]};return dt.has(u)?{...d,hidden:!0}:d})}};import{appendTargetFor as It,neighborsFor as Nt,groupByPlacement as qt}from"./dc812f3e14.js";function mt(C,B,P){const H=C-B;return H<-.01?!0:H>.01?!1:B>P}export{It as appendTargetFor,At as default,qt as groupByPlacement,Nt as neighborsFor};
@@ -0,0 +1 @@
1
+ function g(n){return n===!0?!0:n==="depth"?"depth":!1}function B(n,t,i=!1){const o=Array.isArray(t?.position)?t.position:Array.isArray(t)?t:[0,0,0],r=Array.isArray(t?.scale)?t.scale:[1,1,1],a=Array.isArray(t?.rotation)&&t.rotation[1]||0,s=t?.rotationRad?a:a*Math.PI/180,c=Math.cos(s),h=Math.sin(s),l=(n.width||0)/2,e=(n.depth||0)/2,d=(n.height||0)/2;let u=1/0,x=-1/0,p=1/0,m=-1/0;for(const w of[-l,l])for(const A of[-e,e]){const z=((n.cx||0)+w)*(r[0]||1),F=((n.cz||0)+A)*(r[2]||1),I=z*c+F*h+(o[0]||0),b=-z*h+F*c+(o[2]||0);u=Math.min(u,I),x=Math.max(x,I),p=Math.min(p,b),m=Math.max(m,b)}const y=Math.abs(r[1]||1),M=(o[1]||0)+(n.cy||0)*(r[1]||1);return{minx:u,maxx:x,minz:p,maxz:m,height:(n.height||0)*y,bottom:M-d*y,top:M+d*y,excludedFromFootprint:g(i)}}function f(n,t=()=>!0){let i=1/0,o=-1/0,r=1/0,a=-1/0,s=-1/0,c=1/0,h=!1;for(const e of Object.values(n||{}))!e||!t(e)||(h=!0,i=Math.min(i,e.minx),o=Math.max(o,e.maxx),r=Math.min(r,e.minz),a=Math.max(a,e.maxz),s=Math.max(s,e.top!=null?e.top:e.height||0),c=Math.min(c,e.bottom!=null?e.bottom:0));if(!h||!Number.isFinite(i))return null;const l=Number.isFinite(s)&&Number.isFinite(c)?Math.max(0,s-c):0;return{width:o-i,depth:a-r,height:l,cx:(i+o)/2,cz:(r+a)/2,minX:i,minZ:r}}function N(n){const t=f(n),i=f(n,a=>a.excludedFromFootprint!==!0),o=f(n,a=>!a.excludedFromFootprint);return{body:i&&o?{...o,width:i.width,cx:i.cx,minX:i.minX}:i||o||t,full:t}}function X(){const n={};return{boxes:n,set(t,i,o,r){return n[t]=B(i,o,r),n[t]},remove(t){const i=t in n;return delete n[t],i},has(t){return t in n},report(){const{body:t,full:i}=N(n);return t?i?{...t,full:i}:t:null}}}export{X as createSlotFootprint,g as footprintFlag,N as footprintOf,B as slotBox,f as unionBoxes};
@@ -1 +1 @@
1
- import{evaluateConfiguration as C}from"./fbd844f2d1.js";import{emitEvent as p,EVENTS as s}from"./2e366d7386.js";import{recordEvaluationStarted as j,recordEvaluationSettled as T,recordEvaluationResult as R}from"./9f474b5d1a.js";import{getConfigState as m,getCatalogVersion as h,applyEvaluateResult as w,patchConfigState as V}from"./817d930a49.js";import{isLocalOnlyMutation as x,MutationType as S}from"./3c916f744f.js";let l=null,y=null;function H(t){y=typeof t=="function"?t:null}let d=null;function I(t){d=typeof t=="function"?t:null}let E=null;function U(t){E=typeof t=="function"?t:null}function v(t){if(E)try{E(t)}catch{}}let g=null;function b(t){g=typeof t=="function"?t:null}function D(t){t.type===S.SET_TRANSFORM&&V(i=>({...i,placements:(i.placements||[]).map(n=>String(n.id)===String(t.placementId)?{...n,transform:{position:t.position??n.transform?.position,rotation:t.rotation??n.transform?.rotation}}:n)}))}async function _(t,i,n){const u=m();return C({systemId:u.systemId,catalogVersion:i,state:u,mutation:t},{signal:n})}async function F(t,{optimistic:i,rollback:n}={}){if(!m()||!t)return null;if(x(t))return D(t),null;if(typeof i=="function")try{i()}catch{}let r=t;if(d&&r.context==null)try{const o=d();o&&typeof o=="object"&&Object.keys(o).length&&(r={...r,context:{focus:o}})}catch{}l&&l.abort();const c=new AbortController;l=c;const a=r.type===S.NOOP;a||v(!0),p(s.EVALUATE_STARTED,{mutation:r,internal:a}),j();const A=Date.now();let e=null;try{if(e=await _(r,h(),c.signal),e.staleCatalog)if(y){const f=(await y(e))?.catalogVersion??e.catalogVersion??h();e=await _(r,f,c.signal)}else return e}catch(o){if(o?.name==="AbortError")return null;if(typeof n=="function")try{n()}catch{}throw o}finally{l===c&&(l=null),a||v(!1),T()}w(e);{const o=e?.rejected?"rejected":"completed",f={mutation:r,internal:a,applied:!!e?.applied,rejected:!!e?.rejected,resolvedState:e?.resolvedState??null,warnings:e?.warnings??[],pricing:e?.pricing??null,code:e?.code??null,errors:Array.isArray(e?.errors)?e.errors:[]};R(o,f,e,Date.now()-A),p(o==="rejected"?s.EVALUATE_REJECTED:s.EVALUATE_COMPLETED,f),!a&&e?.pricing&&p(s.PRICE_CHANGED,e.pricing)}if(e.rejected&&typeof n=="function")try{n()}catch{}if(e.rejected&&r.type!=="noop"&&typeof g=="function")try{g(e,r)}catch{}return e}export{F as dispatch,U as setEvaluationStateHandler,I as setFocusProvider,H as setRefetchCatalogHandler,b as setRejectionHandler};
1
+ import{evaluateConfiguration as D}from"./fbd844f2d1.js";import{emitEvent as d,EVENTS as s}from"./2e366d7386.js";import{recordEvaluationStarted as I,recordEvaluationSettled as R,recordEvaluationResult as V}from"./9f474b5d1a.js";import{getConfigState as A,getCatalogVersion as C,applyEvaluateResult as O,patchConfigState as b}from"./817d930a49.js";import{isLocalOnlyMutation as N,MutationType as y}from"./3c916f744f.js";let c=null,g=!1,E=!1,m=null;function J(t){m=typeof t=="function"?t:null}let h=null;function q(t){h=typeof t=="function"?t:null}let _=null;function z(t){_=typeof t=="function"?t:null}function j(t){if(_)try{_(t)}catch{}}let S=null;function B(t){S=typeof t=="function"?t:null}function L(t){t.type===y.SET_TRANSFORM&&b(l=>({...l,placements:(l.placements||[]).map(r=>String(r.id)===String(t.placementId)?{...r,transform:{position:t.position??r.transform?.position,rotation:t.rotation??r.transform?.rotation}}:r)}))}async function T(t,l,r){const p=A();return D({systemId:p.systemId,catalogVersion:l,state:p,mutation:t},{signal:r})}async function P(t,{optimistic:l,rollback:r}={}){if(!A()||!t)return null;if(N(t))return L(t),null;if(typeof l=="function")try{l()}catch{}let n=t;if(h&&n.context==null)try{const o=h();o&&typeof o=="object"&&Object.keys(o).length&&(n={...n,context:{focus:o}})}catch{}if(n&&typeof n=="object"&&!(n.context&&n.context.mutation)){const{type:o,optionSetId:a,optionId:v,placementId:w}=n,u={type:o};a!=null&&(u.optionSetId=a),v!=null&&(u.optionId=v),w!=null&&(u.placementId=w),n={...n,context:{...n.context||{},mutation:u}}}try{import.meta.env?.DEV&&typeof window<"u"&&window.__layoutDebug&&(n={...n,_layoutDebug:window.__layoutDebug})}catch{}const i=n.type===y.NOOP;if(i&&c&&!g)return E=!0,null;c&&c.abort();const f=new AbortController;c=f,g=i,i||j(!0),d(s.EVALUATE_STARTED,{mutation:n,internal:i}),I();const x=Date.now();let e=null;try{if(e=await T(n,C(),f.signal),e.staleCatalog)if(m){const a=(await m(e))?.catalogVersion??e.catalogVersion??C();e=await T(n,a,f.signal)}else return e}catch(o){if(o?.name==="AbortError")return null;if(typeof r=="function")try{r()}catch{}throw o}finally{c===f&&(c=null,g=!1,!i&&E&&(E=!1,setTimeout(()=>{P({type:y.NOOP}).catch(()=>{})},0))),i||j(!1),R()}O(e);{const o=e?.rejected?"rejected":"completed",a={mutation:n,internal:i,applied:!!e?.applied,rejected:!!e?.rejected,resolvedState:e?.resolvedState??null,warnings:e?.warnings??[],pricing:e?.pricing??null,code:e?.code??null,errors:Array.isArray(e?.errors)?e.errors:[]};V(o,a,e,Date.now()-x),d(o==="rejected"?s.EVALUATE_REJECTED:s.EVALUATE_COMPLETED,a),!i&&e?.pricing&&d(s.PRICE_CHANGED,e.pricing)}if(e.rejected&&typeof r=="function")try{r()}catch{}if(e.rejected&&n.type!=="noop"&&typeof S=="function")try{S(e,n)}catch{}return e}export{P as dispatch,z as setEvaluationStateHandler,q as setFocusProvider,J as setRefetchCatalogHandler,B as setRejectionHandler};
@@ -1 +1 @@
1
- const w=.0254,a=.9,i=c=>{const t=c?.width;return typeof t=="number"&&t>0?t*.0254:.9};var _={id:"append-sequence",label:"Append in a row",mode:"compute",computeLayout(c,{getProduct:t,getDims:r}){let n=0;const e=[];for(const s of c||[]){const o=r?.(s.productId),d=o?.width>0?o.width:i(t(s.productId)),u=o?.cx||0,p=o?.cz||0;e.push({position:[n+d/2-u,0,-p],rotation:[0,0,0]}),n+=d}return e}};export{_ as default};
1
+ const w=.0254,a=.9,i=c=>{const t=c?.width;return typeof t=="number"&&t>0?t*.0254:.9};var _={id:"append-sequence",label:"Append in a row",mode:"compute",computeLayout(c,{getProduct:t,getDims:r}){let e=0;const s=[];for(const n of c||[]){const o=r?.(n.productId,n),d=o?.width>0?o.width:i(t(n.productId)),u=o?.cx||0,p=o?.cz||0;s.push({position:[e+d/2-u,0,-p],rotation:[0,0,0]}),e+=d}return s}};export{_ as default};
@@ -1 +1 @@
1
- import{useCallback as w,useEffect as k,useMemo as C,useRef as x}from"react";import g from"./9c6c598569.js";import{registerBuiltinCommand as H,hasCommand as B,COMMANDS as S}from"./d6851ea979.js";import z from"./d94df858ea.js";import J from"./be337ddda5.js";import D from"./872c4302e0.js";import Q from"./60d697292c.js";import{runIntent as b,INTENTS as y}from"./6d238282c1.js";import{addProduct as W,moveProduct as X,removeProduct as Y}from"./a77b15c0d6.js";function Z(){const d=g(e=>e.selectedInstanceId),V=g(e=>e.addProductInstance),M=g(e=>e.removeProductInstance),_=g(e=>e.clearSelection),R=z(e=>e.placementPricing),N=J(e=>e.getChannelPriceConfig),$=D(e=>e.getProduct),{edgeOf:I,isMovable:G,ordered:T,syntheticHosts:L,moveInFlightRef:E,productInstances:h}=Q(),O=C(()=>{if(!d)return null;const e=h||{};return e[d]??Object.values(e).find(r=>String(r?.instanceId??r?.id)===String(d))??null},[d,h]),v=w((e,r)=>{const o=g.getState().productInstances||{},l=o[r],i=o[e],c=Number(l?.sequence),p=Number.isFinite(c)?Math.round(c):null;let a=i?.positionedAbove!=null?String(i.positionedAbove):null,s=null;if(a){const u=o[a];s=u?u.variantId??u.productId??null:null}else{const u=D.getState(),t=u.getProduct?.(i?.variantId)||u.getProduct?.(i?.productId),n=t?.hostVariants??t?.host_variants;if(Array.isArray(n)&&n.length){const f=n.find(P=>P?.isDefault??P?.is_default)||n[0];s=f?.hostVariantId??f?.host_variant_id??null}}const m=Number(i?.sequence);p==null||Number.isFinite(m)&&Math.round(m)===p||E.current||(E.current=!0,X({placementId:e,sequence:p,hostPlacementId:a,hostVariantId:s}).catch(()=>{}).finally(()=>{E.current=!1}))},[]),q=C(()=>{let e=O;if(!e&&d!=null){const t=L.find(n=>n.id===String(d));if(t){const n=h||{};e=n[t.hostedProductId]??Object.values(n).find(f=>String(f?.id??f?.instanceId)===String(t.hostedProductId))??null}}if(!e)return null;const r=I(e),o=G(e),l=e.placementGroup??null,i=T.filter(t=>(t.placementGroup??null)===l),c=i.findIndex(t=>t.id===e.id),p=i[c-1],a=i[c+1],s=t=>t==="left"||t==="right",m=!o&&!s(r)&&p&&!s(I(p)),u=!o&&!s(r)&&a&&!s(I(a));return{targetId:e.id,placementId:e.id,onMoveLeft:()=>b({type:y.PRODUCT_MOVE,placementId:e.id,direction:"left"},()=>{m&&v(e.id,p.id)}),onMoveRight:()=>b({type:y.PRODUCT_MOVE,placementId:e.id,direction:"right"},()=>{u&&v(e.id,a.id)}),onDuplicate:r?void 0:()=>b({type:y.PRODUCT_DUPLICATE,placementId:e.id},()=>{const t=D.getState(),n=t.getProduct?.(e.variantId)||t.getProduct?.(e.productId),f=n?.productGraph??n?.product_graph??null,P=e.placementGroup??n?.placementGroup??n?.placement_group??null,j=Array.isArray(e.position)?e.position:[0,0,0],F=Number.isFinite(Number(e.sequence))?Number(e.sequence):void 0;W({productGraphId:f,variantId:e.variantId??e.productId,placementGroup:P,position:j,sequence:F}).catch(()=>{})}),onDelete:()=>b({type:y.PRODUCT_REMOVE,placementId:e.id},()=>{const t=e.id;Y(t).then(n=>{n&&n.applied&&(M(t),_())}).catch(()=>{})}),disabledActions:{moveLeft:m?void 0:{disabled:!0,reason:o?"Drag to move":"Already at the start"},moveRight:u?void 0:{disabled:!0,reason:o?"Drag to move":"Already at the end"},duplicate:r?{disabled:!0,reason:"Only one of this piece allowed"}:void 0}}},[O,d,L,h,T,I,G,v,V,M,_]),A=x(null);A.current=q,k(()=>{const e=(o,l,i)=>async()=>{let c=A.current;for(let a=0;a<5;a++){const s=g.getState().selectedInstanceId;if(s==null?c==null:c!=null&&String(c.targetId)===String(s))break;await new Promise(u=>setTimeout(u,0)),c=A.current}return!c||(i?c.disabledActions?.[i]:null)||typeof c[l]!="function"?!1:(c[l](),!0)},r=[[S.MOVE_LEFT,e("moveLeft","onMoveLeft","moveLeft")],[S.MOVE_RIGHT,e("moveRight","onMoveRight","moveRight")],[S.DUPLICATE,e("duplicate","onDuplicate","duplicate")],[S.DELETE,e("deleteSelected","onDelete",null)]].map(([o,l])=>B(o)?()=>{}:H(o,l));return()=>r.forEach(o=>o())},[]);const U=C(()=>{const e=d?R?.[d]:null,r=e?.unitPrice??e?.unit_price;return e==null||!Number.isFinite(Number(r))?null:{unitPrice:Number(r),adjustments:Array.isArray(e.adjustments)?e.adjustments:[],currency:(N?.()||{}).currency||"USD"}},[d,R,N]);return{selectedInst:O,swapOrder:v,panelActions:q,priceInfo:U}}export{Z as default};
1
+ import{useCallback as w,useEffect as k,useMemo as M,useRef as x}from"react";import f from"./9c6c598569.js";import{registerBuiltinCommand as H,hasCommand as B,COMMANDS as v}from"./d6851ea979.js";import z from"./d94df858ea.js";import J from"./be337ddda5.js";import y from"./872c4302e0.js";import Q from"./60d697292c.js";import{resolveHostVariantId as W}from"./be07a7f885.js";import{runIntent as S,INTENTS as b}from"./6d238282c1.js";import{addProduct as X,moveProduct as Y,removeProduct as Z}from"./a77b15c0d6.js";function $(){const d=f(e=>e.selectedInstanceId),q=f(e=>e.addProductInstance),D=f(e=>e.removeProductInstance),R=f(e=>e.clearSelection),A=z(e=>e.placementPricing),N=J(e=>e.getChannelPriceConfig),K=y(e=>e.getProduct),{edgeOf:g,isMovable:G,ordered:T,syntheticHosts:_,moveInFlightRef:E,productInstances:I}=Q(),O=M(()=>{if(!d)return null;const e=I||{};return e[d]??Object.values(e).find(n=>String(n?.instanceId??n?.id)===String(d))??null},[d,I]),h=w((e,n)=>{const o=f.getState().productInstances||{},a=o[n],c=o[e],r=Number(a?.sequence),p=Number.isFinite(r)?Math.round(r):null;let l=c?.positionedAbove!=null?String(c.positionedAbove):null,s=null;if(l){const u=o[l];s=u?u.variantId??u.productId??null:null}else{const u=y.getState(),t=u.getProduct?.(c?.variantId)||u.getProduct?.(c?.productId);s=W(t,c)}const m=Number(c?.sequence);p==null||Number.isFinite(m)&&Math.round(m)===p||E.current||(E.current=!0,Y({placementId:e,sequence:p,hostPlacementId:l,hostVariantId:s}).catch(()=>{}).finally(()=>{E.current=!1}))},[]),L=M(()=>{let e=O;if(!e&&d!=null){const t=_.find(i=>i.id===String(d));if(t){const i=I||{};e=i[t.hostedProductId]??Object.values(i).find(P=>String(P?.id??P?.instanceId)===String(t.hostedProductId))??null}}if(!e)return null;const n=g(e),o=G(e),a=e.placementGroup??null,c=T.filter(t=>(t.placementGroup??null)===a),r=c.findIndex(t=>t.id===e.id),p=c[r-1],l=c[r+1],s=t=>t==="left"||t==="right",m=!o&&!s(n)&&p&&!s(g(p)),u=!o&&!s(n)&&l&&!s(g(l));return{targetId:e.id,placementId:e.id,onMoveLeft:()=>S({type:b.PRODUCT_MOVE,placementId:e.id,direction:"left"},()=>{m&&h(e.id,p.id)}),onMoveRight:()=>S({type:b.PRODUCT_MOVE,placementId:e.id,direction:"right"},()=>{u&&h(e.id,l.id)}),onDuplicate:n?void 0:()=>S({type:b.PRODUCT_DUPLICATE,placementId:e.id},()=>{const t=y.getState(),i=t.getProduct?.(e.variantId)||t.getProduct?.(e.productId),P=i?.productGraph??i?.product_graph??null,V=e.placementGroup??i?.placementGroup??i?.placement_group??null,j=Array.isArray(e.position)?e.position:[0,0,0],F=Number.isFinite(Number(e.sequence))?Number(e.sequence):void 0;X({productGraphId:P,variantId:e.variantId??e.productId,placementGroup:V,position:j,sequence:F}).catch(()=>{})}),onDelete:()=>S({type:b.PRODUCT_REMOVE,placementId:e.id},()=>{const t=e.id;Z(t).then(i=>{i&&i.applied&&(D(t),R())}).catch(()=>{})}),disabledActions:{moveLeft:m?void 0:{disabled:!0,reason:o?"Drag to move":"Already at the start"},moveRight:u?void 0:{disabled:!0,reason:o?"Drag to move":"Already at the end"},duplicate:n?{disabled:!0,reason:"Only one of this piece allowed"}:void 0}}},[O,d,_,I,T,g,G,h,q,D,R]),C=x(null);C.current=L,k(()=>{const e=(o,a,c)=>async()=>{let r=C.current;for(let l=0;l<5;l++){const s=f.getState().selectedInstanceId;if(s==null?r==null:r!=null&&String(r.targetId)===String(s))break;await new Promise(u=>setTimeout(u,0)),r=C.current}return!r||(c?r.disabledActions?.[c]:null)||typeof r[a]!="function"?!1:(r[a](),!0)},n=[[v.MOVE_LEFT,e("moveLeft","onMoveLeft","moveLeft")],[v.MOVE_RIGHT,e("moveRight","onMoveRight","moveRight")],[v.DUPLICATE,e("duplicate","onDuplicate","duplicate")],[v.DELETE,e("deleteSelected","onDelete",null)]].map(([o,a])=>B(o)?()=>{}:H(o,a));return()=>n.forEach(o=>o())},[]);const U=M(()=>{const e=d?A?.[d]:null,n=e?.unitPrice??e?.unit_price;return e==null||!Number.isFinite(Number(n))?null:{unitPrice:Number(n),adjustments:Array.isArray(e.adjustments)?e.adjustments:[],currency:(N?.()||{}).currency||"USD"}},[d,A,N]);return{selectedInst:O,swapOrder:h,panelActions:L,priceInfo:U}}export{$ as default};
@@ -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&&lt({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)&&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 de,jsx as h,jsxs as lt}from"react/jsx-runtime";import{useCallback as J,useEffect as N,useMemo as H,useRef as Pt,useState as xt,useSyncExternalStore as We}from"react";import{Html as yn,useProgress as vn}from"@react-three/drei";import T from"./9c6c598569.js";import W from"./872c4302e0.js";import z from"./be337ddda5.js";import gt from"./d94df858ea.js";import{normalizeMaterialTargets as Mn}from"./dc2a1a0e13.js";import y from"./8f60e5059a.js";import Pn from"./60d697292c.js";import xn from"./811b403d43.js";import{useUiToggles as wn}from"./d0f9681634.js";import{ProductInstance as ce,SelectionActionPanel as Cn,FreeMovable as Tn,PlacementGaps as _n,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 Rn}from"./58e6419ba8.js";import{disarmPlacement as Ye}from"./ab6c80484f.js";import{applyMeasurement as zn}from"./9ce3c3df25.js";import{isCompatibleSlot as $e}from"./99577e3161.js";import{resolveComponent as ie,useComponentRegistry as Ke}from"./882bc739c8.js";import En from"./88251d6671.js";import{useLabels as qn}from"./28d887bf8a.js";import{SlotHost as Nn}from"./73f7d65985.js";import{ModalHost as Xn}from"./09c4973968.js";import Zn from"./6c0a2572dd.js";import Hn from"./20b0104576.js";import{getConfigState as Vn,subscribe as Qe,getVersion as Et}from"./817d930a49.js";import{getPlacementStrategy as Je}from"./281cf952fa.js";import{resolveAddMode as jn,armPlacement as Un}from"./ab6c80484f.js";import{resolveReplaceTarget as Bn}from"./4d7a0d1897.js";import{enforceCorners as Wn}from"./388cadacbd.js";import{resolvePlacementStrategyConfig as tn}from"./281cf952fa.js";import{getLabel as Yn}from"./28d887bf8a.js";import{isAddFeature as $n}from"./8c27edda0f.js";import{usePlacementInteraction as Kn}from"./4b8958aa4c.js";import{refreshCanonicalState as Qn,seedInitialState as Jn,addProduct as qt}from"./a77b15c0d6.js";import{resolveLayout as to,hasLayout as eo,useLayoutRegistry as no,layoutOverride as oo,_publishResolvedLayoutKey as so}from"./31ea036f5c.js";import{themeLayoutKey as ro,useSystemTheme as ao}from"./5c9fd9201c.js";import"./1a2629800a.css";import{runIntent as Nt,INTENTS as Xt}from"./6d238282c1.js";function co(){const _=gt(a=>a.sceneSelections),I=gt(a=>a.selectionOrder),f=T(a=>a.activeSceneConfigId),u=z(a=>a.defaultPresetId),p=z(a=>a.sceneConfigurations),D=z(a=>a.getSceneFeatures),S=We(Qe,Et,Et);return H(()=>{const a=f||u||Object.keys(p||{})[0],tt=a?D(a):[],V=W.getState(),v=[],et=new Set,ut=(i,L)=>{if(!i||i.id==null||et.has(String(i.id))||L>4)return;et.add(String(i.id)),v.push(i);const w=(V.features?.[i.id]||V.features?.[String(i.id)])?.childOptionSetIds||[];for(const P of w){const d=V.features?.[P]||V.features?.[String(P)];d&&ut({id:P,type:d.type,sequence:d.sequence},L+1)}};for(const i of tt)ut(i,0);const It=v.filter(i=>/finish/i.test(i.type||"")&&_[i.id]!=null).sort((i,L)=>{const X=I?.[String(i.id)]??-1,w=I?.[String(L.id)]??-1;return X!==w?X-w:(i.sequence??0)-(L.sequence??0)}),M={};for(const i of It){const L=_[i.id],X=V.options?.[L]?.value;if(X==null)continue;const w=V.features?.[i.id]||{},P=Mn(w.materialTargets??w.material_targets??w.materials);for(const d of P)M[String(d).toLowerCase()]=X}return M},[_,I,f,u,p,D,S])}function io(_,I){if(I==null)return null;const f=String(I);for(const u of Object.values(_.products||{})){const p=u?.components_configuration||u?.componentsConfiguration;if(!(!p||typeof p!="object"))for(const D of Object.values(p))for(const S of Array.isArray(D)?D:[D]){const a=S&&typeof S=="object"?S.componentId??S.component_id:S;if(a!=null&&String(a)===f)return u}}return null}function lo(_){const I=gt(v=>v.sceneSelections),f=gt(v=>v.setSceneSelection),u=z(v=>v.getSceneFeatures),p=z(v=>v.sceneConfigurations),D=We(Qe,Et,Et),S=H(()=>new Set((_?u(_)||[]:[]).filter(v=>$n(v)).map(v=>String(v.id))),[_,u,p,D]),a=Pt({}),tt=Pt(!1),V=gt(v=>v.sceneSelectionsSettled);N(()=>{if(!V){a.current={...I};return}if(!tt.current){tt.current=!0;let M=!1;for(const[i,L]of Object.entries(I||{}))L==null||!S.has(String(i))||(f(i,null),M=!0);if(M){a.current={...I};return}}const v=a.current,et=[];for(const[M,i]of Object.entries(I||{}))v[M]===i||i==null||S.has(String(M))&&et.push([M,i]);if(a.current={...I},!et.length)return;const ut=z.getState().systemId;let It=!1;return(async()=>{const M=W.getState(),i=T.getState();for(const[L,X]of et){const w=M.options?.[X];let P=w?.valueProductVariantId??w?.value_product_variant_id??w?.value_product_variant??w?.variantId??w?.variant_id??null,d=P!=null?M.getProduct?.(P):null;if(d==null){const g=w?.value??(M.optionToProducts?.[String(X)]||[])[0]??w?.product_id??w?.productId??null;d=g!=null?M.getProduct?.(g):null,d==null&&g!=null&&M.getComponent?.(g)&&(d=io(M,g)),P=d?.id??P??g}else P=d?.id??P;if(P==null){f(L,null);continue}const wt=d?.id??P,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 g=new Set(St.map(String));if(Object.values(i.productInstances||{}).some(ht=>{const le=M.getProduct?.(ht.variantId)||M.getProduct?.(ht.productId);return $e(d,le,M.products)})){y.getState().setPendingSlotPlacement?.({productId:wt,variantId:P,name:d?.name??d?.displayName??d?.variantName??"product",compatibleGraphIds:Array.from(g)}),f(L,null);continue}}if(jn(ut,d)==="arm"){Un({productId:wt,variantId:P});const g=Je(),Tt=typeof g?.computeTargets=="function",ht=Object.prototype.hasOwnProperty.call(g??{},"armHint")?g.armHint:Yn(Tt?"placement.armedPickTarget":"placement.armedPickGap",Tt?"":"Click a + between pieces to insert it.");ht&&y.getState().showInfo?.(ht),f(L,null);continue}const bt=T.getState(),pt=bt.selectedInstanceId,j=pt!=null?(bt.productInstances||{})[pt]:null,nt=j&&Number.isFinite(Number(j.sequence))?Number(j.sequence):void 0,mt=Bn({placementGroup:Ct}),R=mt!=null?(bt.productInstances||{})[mt]:null,Ht=R&&Number.isFinite(Number(R.sequence))?Number(R.sequence):nt,ct=Array.isArray(R?.position)?R.position:[0,0,0];let Vt=null;try{Vt=await Nt({type:Xt.PRODUCT_ADD,productGraphId:Zt,variantId:P,placementGroup:Ct,sequence:Ht,replacePlacementId:mt??void 0},g=>qt({productGraphId:g.productGraphId,variantId:g.variantId,placementGroup:g.placementGroup,position:ct,sequence:g.sequence,replace:g.replacePlacementId!=null,replacePlacementId:g.replacePlacementId}))}catch{}if(f(L,null),It)return}})(),()=>{It=!0}},[I,S,_,f])}function uo({position:_,onClick:I}){const[f,u]=xt(!1);return h(yn,{position:_,center:!0,style:{pointerEvents:"auto"},zIndexRange:[100,0],children:h("div",{onClick:I,onPointerEnter:()=>u(!0),onPointerLeave:()=>u(!1),style:{width:22,height:22,borderRadius:"50%",background:f?"#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:f?"scale(1.15)":"scale(1)"},children:"+"})})}function po({isMobile:_}={}){Ke();const I=ie("SelectionActionPanel",Cn),f=T(t=>t.productInstances),u=W(t=>t.getProduct),p=W(t=>t.componentGroups),D=T(t=>t.clearSelection),S=T(t=>t.selectedInstanceId),a=T(t=>t.isFocusing),tt=y(t=>t.bootLoading),V=y(t=>t.bootDetail),v=y(t=>t.bootProgress);Ke();const et=ie("LoadingScreen",En),ut=qn();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=>t.removeProductInstance),M=T(t=>t.addProductInstance),i=T(t=>t.updateInstancePosition),L=T(t=>t.updateInstanceRotation),X=T(t=>t.activeSceneConfigId),w=z(t=>t.defaultPresetId),P=z(t=>t.sceneConfigurations),d=z(t=>t.systemId),wt=z(t=>t.useTransform),Ct=y(t=>t.sceneCapabilities),Zt=y(t=>t.showWalls),St=y(t=>t.showDimensions),bt=y(t=>t.pendingSlotPlacement),pt=co(),j=y(t=>t.hostMaterialOverrides),nt=(Vn()||{}).room||null,mt=X||w||Object.keys(P||{})[0]||null;lo(mt);const[R,Ht]=xt(!0),[ct,Vt]=xt(!1),g=J(async()=>{try{await Jn()}catch{}Vt(!0)},[]),{edgeOf:Tt,cornerOf:ht,isHostAnchored:le,isMovable:ue,rawFree:ho,splitReliable:fo,freeInstances:_t,ordered:C,syntheticHosts:pe,moveInFlightRef:go}=Pn(),Ft=H(()=>new Map(pe.map(t=>[t.hostedProductId,t])),[pe]),[ot,nn]=xt({}),jt=J((t,n,e=null,o=e)=>{nn(r=>zn(r,t,n,e,o))},[]),st=J((t,n)=>{const e=n?.id!=null?ot[`inst:${n.id}`]:null;return e&&String(e.forProductId)===String(t)?e:ot[t]||null},[ot]),me=W(t=>t.placementBoundsExcludeIds),he=H(()=>new Set((me||[]).map(t=>String(t))),[me]),Ut=J((t,n)=>{const e=t?.componentId??n?.id??n?.componentId??null;if(e!=null&&he.has(String(e)))return!0},[p,he]),Y=Pt(!1),Gt=Pt(!1),k=C.length+_t.length,Bt=H(()=>[...C,..._t],[C,_t]),it=k>0&&Bt.every(t=>ot[t.productId]),Ot=H(()=>Bt.filter(t=>ot[t.productId]).length,[Bt,ot]),{active:Wt,loaded:fe,total:Yt}=vn(),ge=y(t=>t.isEvaluating),At=y(t=>t.isLayoutLoading),Ie=y(t=>t.bootEvaluating),Se=Pt({pieceCount:0,allMeasured:!1});Se.current={pieceCount:k,allMeasured:it};const Dt=J(()=>{const{pieceCount:t,allMeasured:n}=Se.current;t>0&&!Y.current&&!Gt.current&&(T.getState().resetCameraToDefault?.({instant:!0}),Y.current=n,Gt.current=!n)},[]);N(()=>y.subscribe((t,n)=>{n?.bootLoading&&!t.bootLoading&&Dt()}),[Dt]),N(()=>{if(!ct)return;const t=!Wt&&(Yt===0||fe>=Yt),n=(it||k===0)&&t&&!ge&&!Ie,e=()=>{Dt(),Ht(!1),y.getState().endBootLoading()};if(n){let r=null;const c=setTimeout(()=>{k>0&&!Y.current&&(T.getState().resetCameraToDefault?.({instant:!0}),Y.current=!0),r=setTimeout(e,120)},780);return()=>{clearTimeout(c),r&&clearTimeout(r)}}const o=setTimeout(e,Wt?12e4:15e3);return()=>clearTimeout(o)},[ct,it,k,Ot,Wt,fe,Yt,ge,Ie,Dt]);const[be,ye]=xt(!1);N(()=>{if(!R){ye(!1);return}(it&&k>0||ct&&k===0)&&ye(!0)},[it,k,ct,R]);const ve=ct?be||k===0?"Finishing up\u2026":`Loading products\u2026 ${Math.min(Ot,k)}/${k}`:"Preparing your configurator\u2026",Me=be?100:k>0?Math.min(Math.round(Ot/k*100),92):0;N(()=>{R&&y.getState().setBootPhase(ve,Me)},[R,ve,Me]),N(()=>(y.setState({initialSceneLoading:R}),()=>y.setState({initialSceneLoading:!1})),[R]),N(()=>{At&&(Y.current=!1)},[At]),N(()=>{if(k===0){Y.current=!1;return}if(Y.current||R||At||!it)return;const t=setTimeout(()=>{Y.current||(T.getState().resetCameraToDefault?.({instant:!Gt.current}),Gt.current=!1,Y.current=!0)},250);return()=>clearTimeout(t)},[k,Ot,R,At,it]);const yt=Je(),ft=H(()=>C.map(t=>{const n=Ft.get(t.id);return n?{...t,productId:n.hostVariantId}:t}),[C,Ft]),Pe=wt||!!P?.[mt]?.useTransform,Z=T(t=>t.pendingPlacementPiece),xe=!!Z&&typeof yt?.computeTargets=="function"&&!!kn(),dt=H(()=>{const t={getProduct:u,getDims:st,useTransform:Pe,candidate:Z,openSlots:xe,config:tn()},n=yt.computeLayout?yt.computeLayout(ft,t):ft.map(()=>({position:[0,0,0],rotation:[0,0,0]})),e=Wn(n,ft,t,yt);try{import.meta.env?.DEV&&typeof window<"u"&&(window.__layoutDebug={at:Date.now(),dims:ot,items:ft.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:e})}catch{}return e},[yt,ft,u,st,Pe,Z,xe,ot]),U=H(()=>{const n=nt?.height>0?nt.height:2.7,e=.1,o=.05,r=new Map;let c=1/0,m=-1/0,b=1/0,l=-1/0,E=0,A=!1;if(C.forEach((s,B)=>{const F=dt[B];if(!F||ue(s))return;const x=F.position||[0,0,0],G=st(s.productId,s),Q=u(s.productId),q=G?.full||G,oe=q?.height>0?q.height:Q?.height>0?Q.height*.0254:0,Rt=(x[1]||0)+oe;if(Rt>E&&(E=Rt),(s.positionedAbove??s.positioned_above)!=null)return;const se=(x[1]||0)<=.01,zt=-((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(zt),at=Math.sin(zt),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,Re=(ae*Math.abs(at)+re*Math.abs(rt))/2,ze=De-ke,Ee=De+ke,qe=Le-Re,Ne=Le+Re,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(zt/(Math.PI/2))%4+4)%4),O=r.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};O.minX=Math.min(O.minX,ze),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,ze),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),c=Math.min(c,gn),m=Math.max(m,In),b=Math.min(b,Sn),l=Math.max(l,bn),A=!0}),!A)return null;const K=Math.max(n,E>0?E+.02:n),Mt=[...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,Rt=s.hasFloor?s.fMinZ:s.minZ,se=s.hasFloor?s.fMaxZ:s.maxZ,Ge=Q?(x>0?oe:q)+(x>0?e/2:-e/2):(G>0?se:Rt)+(G>0?e/2:-e/2);return{g:s,isSide:Q,plane:Ge}}),Lt=Mt.some(s=>s.g.hasFloor)?Mt.filter(s=>s.g.hasFloor):Mt,pn=Lt.filter(s=>s.isSide).map(s=>s.plane),mn=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 mn)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:e,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:e,height:K,rotY:0})}}const kt=.4,Fe=m>c&&l>b;let Jt=c-kt,te=m+kt,ee=b-kt,ne=l+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-e/2:te=s.plane+e/2:F<0?ee=s.plane-e/2:ne=s.plane+e/2}const hn=Fe?{cx:(Jt+te)/2,cz:(ee+ne)/2,w:te-Jt,d:ne-ee}:null,fn=Fe?{minX:c,maxX:m,minZ:b,maxZ:l,w:m-c,d:l-b,h:K,height:E>0?E:K}:null;return{segments:Qt,floor:hn,bbox:fn}},[C,dt,nt,st,u,ue]),on=Zt&&!!(U&&U.segments&&U.segments.length),sn=St&&!!(U&&U.bbox&&U.bbox.w>0),rn=(t,n)=>{const e=dt[n]||{position:[0,0,0],rotation:[0,0,0]},o=Ft.get(t.id);if(!o)return e;const r=e.position||[0,0,0],c=(Array.isArray(e.rotation)?e.rotation[1]:0)||0,m=Math.cos(c),b=Math.sin(c),l=o.offset||[0,0,0];return{position:[r[0]+(l[0]||0)*m+(l[2]||0)*b,r[1]+(l[1]||0),r[2]-(l[0]||0)*b+(l[2]||0)*m],rotation:[0,c+(o.rotDegY||0)*Math.PI/180,0]}},$=bt,vt=!!$,we=H(()=>{if(!$)return new Set;const t=u($.variantId)||u($.productId)||null,n=W.getState().products,e=new Set;for(const o of Object.values(f||{})){const r=u(o.variantId)||u(o.productId);(t?$e(t,r,n):(()=>{const m=new Set(($.compatibleGraphIds||[]).map(String)),b=r?.product_graph??r?.productGraph;return b!=null&&m.has(String(b))})())&&e.add(String(o.id))}return e},[$,f,u]),$t=J(()=>{y.getState().clearPendingSlotPlacement?.(),y.getState().clearPendingHostedProduct?.()},[]),Ce=J((t,n)=>{if(!n)return;const e=W.getState(),o=e.getProduct?.(n.variantId)||e.getProduct?.(n.productId),r=o?.productGraph??o?.product_graph??null,c=T.getState().productInstances?.[String(t)],m=o?.placementGroup??o?.placement_group??c?.placementGroup??null,b=Array.isArray(c?.position)?c.position:[0,0,0],l=c?.variantId??c?.productId??null,E=Number.isFinite(Number(c?.sequence))?Number(c.sequence):void 0;$t(),Nt({type:Xt.PRODUCT_ADD,productGraphId:r,variantId:n.variantId??n.productId,placementGroup:m,sequence:E,hostPlacementId:String(t),hostVariantId:l},A=>qt({productGraphId:A.productGraphId,variantId:A.variantId,placementGroup:A.placementGroup,position:b,sequence:A.sequence,hostPlacementId:A.hostPlacementId,hostVariantId:A.hostVariantId}).catch(()=>{}))},[$t]),Kt=J((t,n)=>{const e=W.getState(),o=e.getProduct?.(n.variantId)||e.getProduct?.(n.productId),r=o?.productGraph??o?.product_graph??null,c=o?.placementGroup??o?.placement_group??null,m=C[t-1]||C[t],b=Array.isArray(m?.position)?m.position:[0,0,0],l=C[t],E=l&&Number.isFinite(Number(l.sequence))?Number(l.sequence):void 0;Nt({type:Xt.PRODUCT_ADD,productGraphId:r,variantId:n.variantId??n.productId,placementGroup:c,sequence:E},A=>qt({productGraphId:A.productGraphId,variantId:A.variantId,placementGroup:A.placementGroup,position:b,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}=Kn({systemId:d,count:C.length,positionOf:t=>dt[t]?.position||[0,0,0],insertAt:Kt}),Te=H(()=>{if(!Z)return[];const t=W.getState();return Dn(C,{candidate:Z,getProduct:n=>t.getProduct?.(n),getDims:st,config:tn(),layout:dt})},[Z,C,dt,st]),dn=J(t=>{const n=Ln(t,{candidate:Z});if(!n)return;const e=W.getState(),o=e.getProduct?.(n.variantId)||e.getProduct?.(n.productId),r=o?.productGraph??o?.product_graph??null,c=o?.placementGroup??o?.placement_group??null,m=n.transform?.position??t.position??[0,0,0],b=Rn(n,t,C);Nt({type:Xt.PRODUCT_ADD,productGraphId:r,variantId:n.variantId??n.productId,placementGroup:c,anchor:n.anchor??null,sequence:b},l=>qt({productGraphId:l.productGraphId,variantId:l.variantId,placementGroup:l.placementGroup,position:m,sequence:l.sequence}).catch(()=>{})),Ye()},[Z,C]),{selectedInst:Io,swapOrder:So,panelActions:_e,priceInfo:ln}=xn(),un=wn()("selectionPanel");N(()=>{if(S==null)return;const t=f||{},n=String(S),e="__host";if(n.endsWith(e)){const o=n.slice(0,-e.length);if(t[o]||Object.values(t).some(r=>String(r?.id??r?.instanceId)===o))return}else if(t[S]||Object.values(t).some(o=>String(o?.instanceId??o?.id)===n))return;D?.()},[S,f,D]);const yo=gt(t=>t.placementPricing),vo=z(t=>t.getChannelPriceConfig);return lt(de,{children:[h(On,{onSeeded:g}),lt(Fn,{isMobile:_,camera:{position:[2.6,2.2,4],fov:45},controlsTarget:[0,.5,0],onPointerMissed:()=>D?.(),groundShadowCatcher:!0,overlay:lt(de,{children:[!vt&&_e&&un?h(I,{actions:_e,priceInfo:ln}):null,vt&&h("div",{className:"placement-mode-overlay",children:lt("div",{className:"placement-mode-overlay__content",children:[lt("span",{className:"placement-mode-overlay__text",children:["Click on a highlighted slot to place ",h("strong",{children:$?.name})]}),h("button",{type:"button",className:"placement-mode-overlay__cancel",onClick:$t,children:h("span",{className:"placement-mode-overlay__cancel-text",children:"Cancel"})})]})}),h(Nn,{name:"overlay"}),tt&&h(et,{scene:!0,message:ut("loading.message","Loading your configurator\u2026"),detail:V,progress:v}),a&&h("div",{"aria-hidden":"true",style:{position:"absolute",inset:0,zIndex:30,cursor:"default"}})]}),children:[on&&h(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",Hn);return h(t,{bbox:U.bbox})})(),C.map((t,n)=>{const e=Ft.get(t.id),o=dt[n]||{position:[0,0,0],rotation:[0,0,0]};return o.hidden?null:lt("group",{children:[e&&h(ce,{instance:{id:e.id,instanceId:e.id,productId:e.hostVariantId,variantId:e.hostVariantId,position:o.position||[0,0,0],rotation:o.rotation||[0,0,0]},slotMaterials:{...pt,...j?.[e.hostedProductId]||{},...j?.[e.id]||{}},stateInstanceId:e.hostedProductId,onSelect:()=>T.getState().selectInstance(e.id),isSelected:String(S)===String(e.id),onMeasure:r=>jt(e.hostVariantId,r,null,e.id),footprintExcludeItem:Ut,hoverable:!0,focusable:!0},e.id),h(ce,{instance:{...t,...rn(t,n)},slotMaterials:{...pt,...j?.[t.id]||j?.[t.instanceId]||{}},onSelect:(r,c,m)=>{if(vt){we.has(String(t.id))&&Ce(t.id,$);return}T.getState().selectInstance(r,m??null)},isSelected:!vt&&String(S)===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],c=st(ft[n]?.productId??t.productId,t),m=(Array.isArray(o.rotation)?o.rotation[1]:0)||0,b=Math.cos(m),l=Math.sin(m),E=c?.cx||0,A=c?.cz||0,K=c?.full?.height??c?.height,Mt=[r[0]+E*b+A*l,r[1]+(K>0?K/2:.45),r[2]-E*l+A*b];return h(uo,{position:Mt,onClick:()=>Ce(t.id,$)})})()]},t.id??t.instanceId??n)}),_t.map((t,n)=>h(Tn,{selected:S===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 e=st(t.productId,t);return[e?.cx||0,0,e?.cz||0]})(),onCommit:({position:e,rotationY:o})=>{i(t.id,e),L(t.id,[0,o*180/Math.PI,0]),Qn({allowRevert:!0}).catch(()=>{})},children:h(ce,{instance:{...t,position:[0,0,0],rotation:[0,0,0]},slotMaterials:{...pt,...j?.[t.id]||j?.[t.instanceId]||{}},onMeasure:e=>jt(t.productId,e,t.id),footprintExcludeItem:Ut})},t.id??t.instanceId??`free-${n}`)),Te.length>0?h(An,{targets:Te,onPick:dn}):h(_n,{gaps:an,onInsert:cn})]})]})}const en=new Set;function mo(){no();const _=z(a=>a.systemLayoutTemplate),I=z(a=>a.systemTheme),f=z(a=>a.systemThemeRecord);ao(I,f);const u=ro(f)||(I?String(I).trim().toLowerCase():null);let p=_;try{const a=new URLSearchParams(window.location.search);a.has("template")?p=a.get("template"):a.has("theme")&&(p=a.get("theme"))}catch{}p=p||_||u||null;const D=oo();D&&(p=D),!D&&!_&&p&&p===u&&!eo(p)&&!/^theme\d+$/.test(p)&&!en.has(p)&&en.add(p),so(p);const S=to(p);return lt(de,{children:[h(S,{Scene:po,template:p}),h(Xn,{}),h(Zn,{})]})}export{po as SharedConfiguratorScene,mo as default};
@@ -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 M(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 P=S.getState(),F={},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&&(F[l]={...P[l],...o[s]});const C={};return a.forEach((s,l)=>{s.product_id&&(C[n[l]]=s.product_id)}),{stylingUpdate:F,overridesToRestore:C}}function G(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:P}=k(g[u.PIECE_FINISH],y,O);h&&(o.finishes[n]=h),P&&(o.materials[n]=P)}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 V(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){G(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 se(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?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),P=h?.products||[],F=h?.freePieceConfig?.product_id||[],T=[...P,...F],{pendingHostedProducts:C}=W(T),s=T.filter(R),l=T.filter(e=>!R(e)),m=l.some(e=>e.type==="island")||F.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||P.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}=M(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}})}V(s,C,e,i)}:()=>{S.getState().clearSceneLoading()},600)}export{se as executeLayoutChange,k as resolveFinish,M as restorePieceStyling};
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};
@@ -1 +1 @@
1
- import{Fragment as fe,jsx as e,jsxs as E}from"react/jsx-runtime";import{Suspense as W,useEffect as I,useRef as x,useSyncExternalStore as N}from"react";import{getSceneAccessGranted as j,subscribeSceneAccess as Q}from"./87f511c4a8.js";import*as b from"three";import{Canvas as U,useThree as A}from"@react-three/fiber";import{setSceneContext as T,disposeSceneExtras as _}from"./95a44ebec2.js";import{PerspectiveCamera as q,OrbitControls as J}from"@react-three/drei";import K from"./be337ddda5.js";import F from"./8f60e5059a.js";import"./9c6c598569.js";import X from"./d4378d9afa.js";import Y from"./00a41227ff.js";import Z from"./28a9d58274.js";import $ from"./8db8655f21.js";import{rememberRenderer as ee}from"./b59b0dde17.js";import te from"./14c83bc57a.js";import{applyEnvironmentToRenderer as oe}from"./4e7d0a0d4a.js";import{setR3FState as L}from"./e1cd279733.js";import{computeTopDownView as re,computeFitView as ne,ORTHO_FOV as z}from"./85af90fade.js";const B=(t,o)=>t?o:Math.max(o,1e5);function ie({defaultPosition:t,fov:o,controlsRef:a,controlsTarget:f,maxDistance:c}){const{scene:p,size:m,invalidate:h}=A(),u=F(r=>r.is3D)!==!1,g=x(),w=x(u),D=x(!1);return I(()=>{const r=g.current,n=a?.current;if(!r)return;const y=w.current;w.current=u;const k=!D.current;D.current=!0;const C=m.width/Math.max(m.height,1);if(n&&(n.maxDistance=B(u,c)),!u){const i=re({scene:p,aspect:C,fov:z});if(!i)return;r.fov=z,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(y&&!k){r.updateProjectionMatrix(),h?.();return}r.fov=o;const S=y?null:ne({scene:p,aspect:C,fov:o}),v=S?.position||t,M=S?.target||f;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,p,m.width,m.height]),e(q,{ref:g,makeDefault:!0,position:t,fov:o})}function ae(){const{gl:t,scene:o,camera:a,invalidate:f}=A(),c=N(Q,j,()=>!1);return I(()=>(L({gl:t,scene:o,camera:a}),c?T({THREE:b,scene:o,camera:a,renderer:t,invalidate:f}):T(null),()=>{_(),T(null),L(null)}),[t,o,a,c]),null}function se({background:t="#f4f4f5"}){return E(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 ce({env:t}){return!!t&&Object.keys(t).length>0?null:E("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 ue({children:t,overlay:o,isMobile:a=!1,is3D:f,camera:c={position:[2.6,2.2,4],fov:45},controlsTarget:p=[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:y=null,dpr:k=[1,2],shadows:C=!0,frameloop:S,canvasStyle:v,onPointerMissed:M,onCreated:i}){const P=x(),O=K(s=>s.systemEnvironment),V=F(s=>s.is3D),G=F(s=>s.captureMode)===!0,R=f??V!==!1,l=O&&Object.keys(O).length>0?O:null,H=B(R,g);return E("div",{className:"scene-canvas",style:{position:"relative",width:"100%",height:"100%"},children:[E(U,{shadows:C,dpr:k,...S?{frameloop:S}:{},style:{width:"100%",height:"100%",...v||{}},onPointerMissed:M,onCreated:s=>{const{gl:d}=s;ee(d),d.outputColorSpace=b.SRGBColorSpace,d.toneMapping=b.ACESFilmicToneMapping,d.toneMappingExposure=.9,d.shadowMap.type=b.PCFSoftShadowMap,l&&oe(l,d),j()&&i?.(s)},children:[l&&e(X,{env:l,isMobile:a,is3D:R,reducedQuality:!!a,captureMode:G}),!l&&D&&e(se,{background:r}),n&&R&&!G&&e(ce,{env:l}),m&&e(ie,{defaultPosition:c.position,fov:c.fov,controlsRef:P,controlsTarget:p,maxDistance:g}),e(W,{fallback:y,children:t}),h&&e(J,{ref:P,makeDefault:!0,target:p,enablePan:!0,minDistance:u,maxDistance:H,maxPolarAngle:Math.PI/2.05,enableRotate:R,...w||{}}),e(ae,{}),e(te,{controlsRef:P}),e(Y,{})]}),o,e(Z,{}),e($,{})]})}export{ue as default};
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};
@@ -0,0 +1 @@
1
+ const g=(l,t)=>{const h=t.full||null;return!!l&&l.width===t.width&&l.depth===t.depth&&l.height===t.height&&l.cx===t.cx&&l.cz===t.cz&&(l.full?.width??null)===(h?.width??null)&&(l.full?.height??null)===(h?.height??null)&&(l.full?.depth??null)===(h?.depth??null)},a=(l,t,h)=>({width:l.width,depth:l.depth,height:l.height,cx:l.cx,cz:l.cz,full:l.full||null,forProductId:t,...h!=null?{ownerId:h}:{},...l.__slots?{slots:l.__slots}:{}});function _(l,t,h,e=null,f=e){let n=l;const u=l[t];if((!u||u.ownerId==null||f==null||String(u.ownerId)===String(f))&&!g(u,h)&&(n={...n,[t]:a(h,t,f)}),e!=null){const o=`inst:${e}`;g(n[o],h)||(n={...n,[o]:a(h,t,e)})}return n}export{_ as applyMeasurement};
@@ -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};
@@ -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 s=t?.productId??t?.variantId??t,e=r.getDims?.(s),o=r.getProduct?.(s),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 s=(r?.[0]??0)-(t?.[0]??0),e=(r?.[2]??0)-(t?.[2]??0);return Math.hypot(s,e)<1e-6?null:Math.atan2(e,s)}const I=t=>!!(t?.corner??t?.isCorner);function U(t,r={},s={}){const e=typeof s.turn=="number"?s.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:c,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*(c/2)+z*(p/2)-(x*f+z*g),0,i+M*(c/2)+_*(p/2)-(M*f+_*g)],rotation:[0,-n,0]}),h+=x*c,i+=M*c,m&&(n+=e,h+=Math.cos(n)*p,i+=Math.sin(n)*p)}return d}function T(t,r,s={}){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],s).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 y(t,r,s={},e=0){const o=T(t,r,s);if(!o.length)return[];const n=e/2,h=o.map((c,p)=>{const{hx:f,hz:g}=u(c.heading);return{index:p,heading:c.heading,position:[c.trailing[0]-f*n,c.trailing[1],c.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:U,edgesOf:T,gapCentres:y,toDegrees:A,toRadians:F};export{D as FRONT_SIGN,O as TURN,u as axesFor,U as chain,W as default,l as dimsOf,T as edgesOf,y as gapCentres,N as headingOf,I as isCorner,A as toDegrees,F as toRadians};
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};