@layoutit/polycss 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -7
- package/dist/PolyShapeElements-BviHejaw.d.cts +371 -0
- package/dist/PolyShapeElements-DV9o3DDi.d.ts +371 -0
- package/dist/createPolyScene-BBjx0kRF.d.cts +5 -0
- package/dist/createPolyScene-DHnue9qz.d.ts +5 -0
- package/dist/elements.cjs +2 -2
- package/dist/elements.d.cts +2 -1
- package/dist/elements.d.ts +2 -1
- package/dist/elements.js +2 -2
- package/dist/index.cjs +20 -20
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +20 -20
- package/dist/three.cjs +799 -0
- package/dist/three.d.cts +23 -0
- package/dist/three.d.ts +23 -0
- package/dist/three.js +799 -0
- package/dist/types-CfRKEj2z.d.cts +359 -0
- package/dist/types-CfRKEj2z.d.ts +359 -0
- package/package.json +17 -2
- package/dist/PolyShapeElements-YDkJX2Fz.d.cts +0 -671
- package/dist/PolyShapeElements-YDkJX2Fz.d.ts +0 -671
package/dist/three.cjs
ADDED
|
@@ -0,0 +1,799 @@
|
|
|
1
|
+
"use strict";var rr=Object.defineProperty;var va=Object.getOwnPropertyDescriptor;var Sa=Object.getOwnPropertyNames;var Ca=Object.prototype.hasOwnProperty;var ei=(e,n)=>{for(var t in n)rr(e,t,{get:n[t],enumerable:!0})},or=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Sa(n))!Ca.call(e,i)&&i!==t&&rr(e,i,{get:()=>n[i],enumerable:!(o=va(n,i))||o.enumerable});return e},he=(e,n,t)=>(or(e,n,"default"),t&&or(t,n,"default"));var Ta=e=>or(rr({},"__esModule",{value:!0}),e);var wu={};ei(wu,{AmbientLight:()=>ye.AmbientLight,DirectionalLight:()=>ye.DirectionalLight,Euler:()=>ye.Euler,Object3D:()=>ye.Object3D,OrthographicCamera:()=>ye.OrthographicCamera,PerspectiveCamera:()=>ye.PerspectiveCamera,PointLight:()=>ye.PointLight,Vector3:()=>ye.Vector3,boxPolygons:()=>Me.boxPolygons,conePolygons:()=>Me.conePolygons,createPolyOrthographicCamera:()=>ut,createPolyOrthographicCameraFromThree:()=>la,createPolyPerspectiveCamera:()=>vt,createPolyPerspectiveCameraFromThree:()=>aa,createPolyScene:()=>Yt,cylinderPolygons:()=>Me.cylinderPolygons,dodecahedronPolygons:()=>Me.dodecahedronPolygons,icosahedronPolygons:()=>Me.icosahedronPolygons,loadMesh:()=>Me.loadMesh,mountPolyThreeScene:()=>Au,octahedronPolygons:()=>Me.octahedronPolygons,planePolygons:()=>Me.planePolygons,polyToThreeDirection:()=>ye.polyToThreeDirection,polyToThreePoint:()=>ye.polyToThreePoint,spherePolygons:()=>Me.spherePolygons,tetrahedronPolygons:()=>Me.tetrahedronPolygons,threeToPolyDirection:()=>ye.threeToPolyDirection,threeToPolyPoint:()=>ye.threeToPolyPoint,torusPolygons:()=>Me.torusPolygons,transformPointToPoly:()=>ye.transformPointToPoly,transformPolygonsToPoly:()=>ye.transformPolygonsToPoly});module.exports=Ta(wu);var sa=require("@layoutit/polycss-core/three");var de={};ei(de,{PolyBoxElement:()=>jo,PolyCameraElement:()=>Io,PolyConeElement:()=>Qo,PolyCylinderElement:()=>Zo,PolyDodecahedronElement:()=>Xo,PolyFirstPersonControlsElement:()=>Oo,PolyIcosahedronElement:()=>Yo,PolyIframeElement:()=>Ao,PolyMapControlsElement:()=>_o,PolyMeshElement:()=>bn,PolyOctahedronElement:()=>Uo,PolyOrbitControlsElement:()=>ko,PolyOrthographicCameraElement:()=>Pn,PolyPerspectiveCameraElement:()=>Do,PolyPlaneElement:()=>$o,PolyPolygonElement:()=>wo,PolyRingElement:()=>Wo,PolySceneElement:()=>Ue,PolySceneSnapshotError:()=>Ft,PolySelectElement:()=>Fo,PolySphereElement:()=>qo,PolyTetrahedronElement:()=>Go,PolyTorusElement:()=>Ko,PolyTransformControlsElement:()=>Ho,buildAtlasPages:()=>jt,buildPolyMeshTransform:()=>we.buildPolyMeshTransform,buildPolySceneTransform:()=>we.buildPolySceneTransform,buildTextureEdgeRepairSets:()=>Ot.buildTextureEdgeRepairSets,collectPolyRenderStats:()=>Vs,collectPolyTextureReadiness:()=>Zr,computeTextureAtlasPlanPublic:()=>io.computeTextureAtlasPlanPublic,createPolyBox:()=>Xs,createPolyCamera:()=>hs,createPolyCone:()=>oa,createPolyCylinder:()=>na,createPolyDodecahedron:()=>ta,createPolyFirstPersonControls:()=>bo,createPolyIcosahedron:()=>ea,createPolyMapControls:()=>yo,createPolyOctahedron:()=>Qs,createPolyOrbitControls:()=>ho,createPolyOrthographicCamera:()=>ut,createPolyPerspectiveCamera:()=>vt,createPolyPlane:()=>qs,createPolyRing:()=>Zs,createPolyScene:()=>Yt,createPolySphere:()=>Ks,createPolyTetrahedron:()=>Js,createPolyTorus:()=>ra,createSelect:()=>xo,createTransformControls:()=>To,cssBorderShapeForPlan:()=>Dt.cssBorderShapeForPlan,cssDistanceToWorld:()=>we.cssDistanceToWorld,cssPositionToWorld:()=>we.cssPositionToWorld,exportPolySceneSnapshot:()=>Ys,filterAtlasPlans:()=>Zn,formatBorderShapeEntryMatrix:()=>Dt.formatBorderShapeEntryMatrix,formatCssLengthPx:()=>nt.formatCssLengthPx,formatMatrix3d:()=>nt.formatMatrix3d,formatSolidQuadEntryMatrix:()=>nt.formatSolidQuadEntryMatrix,getSolidPaintDefaults:()=>kt,getSolidPaintDefaultsFromPlans:()=>qn,injectPolyBaseStyles:()=>so,isBorderShapeSupported:()=>Mn,isFullRectSolid:()=>Y.isFullRectSolid,isProjectiveQuadPlan:()=>Y.isProjectiveQuadPlan,isSolidTrianglePlan:()=>Y.isSolidTrianglePlan,isSolidTriangleSupported:()=>Ln,packTextureAtlasPlansWithScale:()=>Nt,polyCssDistanceToWorld:()=>we.cssDistanceToWorld,polyCssPositionToWorld:()=>we.cssPositionToWorld,queryPolyLeaves:()=>No,renderPolygonsWithStableTriangles:()=>Wt,renderPolygonsWithTextureAtlas:()=>_t,renderPolygonsWithTextureAtlasAsync:()=>cn,updatePolygonsWithStableTopology:()=>dn,updatePolygonsWithStableTriangles:()=>ro,updateStableTriangleFrame:()=>un,worldDirectionToPolyCss:()=>we.worldDirectionToPolyCss,worldDirectionalLightToPolyCss:()=>we.worldDirectionalLightToCss,worldDistanceToCss:()=>we.worldDistanceToCss,worldDistanceToPolyCss:()=>we.worldDistanceToCss,worldPositionToPolyCss:()=>we.worldPositionToPolyCss});var J=require("@layoutit/polycss-core");var ti=require("@layoutit/polycss-core");function Ea(e){if(!e)return!1;let t=(e.defaultView??(typeof window<"u"?window:void 0))?.matchMedia;return t?t("(pointer: coarse)").matches||t("(hover: none)").matches:!1}function Nt(e,n,t,o){return(0,ti.packTextureAtlasPlansWithScaleCore)(e,n,Ea(t),o)}var Ot=require("@layoutit/polycss-core");var xt=require("@layoutit/polycss-core"),ai=require("@layoutit/polycss-core"),li=require("@layoutit/polycss-core"),Qt=new Map;function Aa(e){let n=Qt.get(e);return n||(n=new Promise((t,o)=>{let i=new Image;i.decoding="async",i.crossOrigin="anonymous",i.onload=()=>t(i),i.onerror=()=>o(new Error(`texture load failed: ${e}`)),i.src=e}),Qt.set(e,n),n.then(()=>{Qt.get(e)===n&&Qt.delete(e)},()=>{Qt.get(e)===n&&Qt.delete(e)})),n}function Xe(e,n,t=1,o=0,i=0,r=1,s=0,c=0){e.setTransform(t*n,o*n,i*n,r*n,s*n,c*n)}function ir(e){let n=e/255;return n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function sr(e){let n=e<=.0031308?e*12.92:1.055*Math.pow(e,.4166666666666667)-.055;return Math.max(0,Math.min(255,Math.round(n*255)))}function wa(e,n,t,o,i,r,s){let c=Math.round(n*s),l=Math.round(t*s),d=Math.max(1,Math.round(o*s)),p=Math.max(1,Math.round(i*s)),y=e.getImageData(c,l,d,p),g=y.data,b=r.r,x=r.g,v=r.b;for(let h=0;h<g.length;h+=4)g[h+3]!==0&&(g[h]=sr(ir(g[h])*b),g[h+1]=sr(ir(g[h+1])*x),g[h+2]=sr(ir(g[h+2])*v));e.putImageData(y,c,l)}function Ma(e,n,t,o,i,r,s){let c=n.naturalWidth||n.width||1,l=n.naturalHeight||n.height||1,d=Math.max(i/c,r/l),p=c*d,y=l*d;Xe(e,s),e.drawImage(n,t+(i-p)/2,o+(r-y)/2,p,y)}function Kt(e,n){return Math.max(0,Math.min(n,e))}function ni(e,n,t,o,i,r,s,c){let l=n.naturalWidth||n.width||1,d=n.naturalHeight||n.height||1,p=Kt(Math.min(t.minU,t.maxU)*l,l),y=Kt(Math.max(t.minU,t.maxU)*l,l),g=Kt(Math.min(t.minV,t.maxV)*d,d),b=Kt(Math.max(t.minV,t.maxV)*d,d),x=Math.floor(p),v=Math.floor(g),h=Math.ceil(y)-x,C=Math.ceil(b)-v;h<1&&(x=Math.floor(Kt((t.minU+t.maxU)/2*l,l-1)),h=1),C<1&&(v=Math.floor(Kt((t.minV+t.maxV)/2*d,d-1)),C=1),x=Math.max(0,Math.min(l-1,x)),v=Math.max(0,Math.min(d-1,v)),h=Math.max(1,Math.min(l-x,h)),C=Math.max(1,Math.min(d-v,C)),Xe(e,c),e.drawImage(n,x,v,h,C,o,i,r,s)}function ci(e){return e==="repeat"||e==="mirrored-repeat"}function oi(e,n){return ci(e)?Math.floor(n):0}function ri(e,n){return ci(e)?Math.ceil(n)-1:0}function ii(e,n){return e==="mirrored-repeat"&&Math.abs(n%2)===1}function si(e,n,t,o,i,r,s){let c=i?oi(r,i.minU):0,l=i?ri(r,i.maxU):0,d=i?oi(s,i.minV):0,p=i?ri(s,i.maxV):0;for(let y=c;y<=l;y++)for(let g=d;g<=p;g++){let b=ii(r,y),x=ii(s,g);if(!b&&!x){e.drawImage(n,y*t,g*o);continue}e.save(),e.translate((b?y+1:y)*t,(x?g+1:g)*o),e.scale(b?-1:1,x?-1:1),e.drawImage(n,0,0),e.restore()}}function ar(e,n,t,o){for(let i=0;i<o.length;i+=2){let r=n+o[i],s=t+o[i+1];i===0?e.moveTo(r,s):e.lineTo(r,s)}e.closePath()}function Gn(e,n,t,o,i,r){for(let s=0;s<o.length;s+=2){let c=n+o[s]+i,l=t+o[s+1]+r;s===0?e.moveTo(c,l):e.lineTo(c,l)}e.closePath()}function La(e,n,t,o){Xe(e,o),e.beginPath(),ar(e,n.x,n.y,n.screenPts),e.clip(),Xe(e,o),e.fillStyle=t==="dynamic"?n.polygon.color??"#cccccc":n.shadedColor,e.fillRect(n.x,n.y,n.canvasW,n.canvasH)}function Yn(e,n,t,o,i){n.polygon.textureAlphaMode==="opaque"&&(Xe(e,t),e.fillStyle=n.polygon.color??"#cccccc",e.fillRect(n.x+o,n.y+i,n.canvasW,n.canvasH))}function Ra(e,n,t,o,i=0,r=0){if(n.textureTriangles?.length){let s=t.naturalWidth||t.width||1,c=t.naturalHeight||t.height||1;for(let l of n.textureTriangles){let d=(0,ai.expandClipPoints)(l.screenPts,xt.TEXTURE_TRIANGLE_BLEED*(n.bleedRatio??1));e.save(),Xe(e,o),e.beginPath(),Gn(e,n.x,n.y,d,i,r),e.clip(),Yn(e,n,o,i,r),l.uvAffine?(Xe(e,o,l.uvAffine.a/s,l.uvAffine.c/s,l.uvAffine.b/c,l.uvAffine.d/c,n.x+l.uvAffine.e+i,n.y+l.uvAffine.f+r),si(e,t,s,c,l.uvSampleRect,n.polygon.textureWrap?.s,n.polygon.textureWrap?.t)):l.uvSampleRect&&ni(e,t,l.uvSampleRect,n.x+i,n.y+r,n.canvasW,n.canvasH,o),e.restore()}}else if(n.uvAffine){let s=t.naturalWidth||t.width||1,c=t.naturalHeight||t.height||1,l=n.polygon.textureAlphaMode==="opaque";l&&(e.save(),Xe(e,o),e.beginPath(),Gn(e,n.x,n.y,n.screenPts,i,r),e.clip(),Yn(e,n,o,i,r)),Xe(e,o,n.uvAffine.a/s,n.uvAffine.c/s,n.uvAffine.b/c,n.uvAffine.d/c,n.x+n.uvAffine.e+i,n.y+n.uvAffine.f+r),si(e,t,s,c,n.uvSampleRect,n.polygon.textureWrap?.s,n.polygon.textureWrap?.t),l&&e.restore()}else if(n.uvSampleRect){let s=n.polygon.textureAlphaMode==="opaque";s&&(e.save(),Xe(e,o),e.beginPath(),Gn(e,n.x,n.y,n.screenPts,i,r),e.clip(),Yn(e,n,o,i,r)),ni(e,t,n.uvSampleRect,n.x+i,n.y+r,n.canvasW,n.canvasH,o),s&&e.restore()}else{let s=n.polygon.textureAlphaMode==="opaque";s&&(e.save(),Xe(e,o),e.beginPath(),Gn(e,n.x,n.y,n.screenPts,i,r),e.clip(),Yn(e,n,o,i,r)),Ma(e,t,n.x+i,n.y+r,n.canvasW,n.canvasH,o),s&&e.restore()}}function ka(e,n,t,o,i,r){let s=i-t,c=r-o,l=s*s+c*c;if(l<=li.BASIS_EPS)return Math.hypot(e-t,n-o);let d=Math.max(0,Math.min(1,((e-t)*s+(n-o)*c)/l));return Math.hypot(e-(t+s*d),n-(o+c*d))}function _a(e,n,t,o){let i=1/0,r=t.length/2;for(let s of o){if(s<0||s>=r)continue;let c=s*2,l=(s+1)%r*2;i=Math.min(i,ka(e,n,t[c],t[c+1],t[l],t[l+1]))}return i}function Oa(e,n,t,o,i,r){let s=Math.max(0,o-r),c=Math.min(n-1,o+r),l=Math.max(0,i-r),d=Math.min(t-1,i+r),p=null,y=1/0;for(let g=l;g<=d;g++)for(let b=s;b<=c;b++){if(b===o&&g===i)continue;let x=b-o,v=g-i,h=x*x+v*v;if(h>r*r||h>=y)continue;let C=(g*n+b)*4;e[C+3]<xt.TEXTURE_EDGE_REPAIR_SOURCE_ALPHA_MIN||(p=C,y=h)}return p}function Da(e,n,t){if(!n.textureEdgeRepair||!n.texture||!n.textureEdgeRepairEdges||n.textureEdgeRepairEdges.size===0)return;let o=e.canvas;if(!o)return;let i=Math.max(0,Math.floor(n.x*t)),r=Math.max(0,Math.floor(n.y*t)),s=Math.max(1,Math.min(o.width-i,Math.ceil(n.canvasW*t))),c=Math.max(1,Math.min(o.height-r,Math.ceil(n.canvasH*t)));if(s<=0||c<=0)return;let l;try{l=e.getImageData(i,r,s,c)}catch{return}let d=l.data,p=new Uint8ClampedArray(d),y=Math.max(xt.TEXTURE_EDGE_REPAIR_RADIUS,xt.TEXTURE_EDGE_REPAIR_RADIUS/t),g=Math.max(2,Math.ceil(y*t)+1),b=!1;for(let x=0;x<c;x++)for(let v=0;v<s;v++){let h=(x*s+v)*4,C=d[h+3];if(C<xt.TEXTURE_EDGE_REPAIR_ALPHA_MIN||C===255)continue;let R=(i+v+.5)/t-n.x,I=(r+x+.5)/t-n.y;if(_a(R,I,n.screenPts,n.textureEdgeRepairEdges)>y)continue;let z=Oa(p,s,c,v,x,g);z!==null&&(d[h]=p[z],d[h+1]=p[z+1],d[h+2]=p[z+2],d[h+3]=255,b=!0)}b&&e.putImageData(l,i,r)}function Ia(e){if(typeof e.toBlob=="function")return new Promise(n=>{e.toBlob(t=>{n(t?URL.createObjectURL(t):null)},"image/png")});try{return Promise.resolve(e.toDataURL("image/png"))}catch{return Promise.resolve(null)}}async function Ha(e,n,t,o){let i=t.createElement("canvas");i.width=Math.max(1,Math.ceil(e.width*o)),i.height=Math.max(1,Math.ceil(e.height*o));let r=e.entries.some(p=>p.textureEdgeRepair&&p.texture&&p.textureEdgeRepairEdges&&p.textureEdgeRepairEdges.size>0),s=i.getContext("2d",r?{willReadFrequently:!0}:void 0);if(!s)return{width:e.width,height:e.height,url:null};let c=Array.from(new Set(e.entries.flatMap(p=>p.texture?[p.texture]:[]))),l=new Map;await Promise.all(c.map(async p=>{l.set(p,await Aa(p))}));for(let p of e.entries){let y=p.texture?l.get(p.texture):null;if(!p.texture){s.save(),La(s,p,n,o),s.restore();continue}y&&(s.save(),Xe(s,o),s.beginPath(),ar(s,p.x,p.y,p.screenPts),s.clip(),Ra(s,p,y,o),s.restore()),p.texture&&n==="baked"&&(s.save(),Xe(s,o),s.beginPath(),ar(s,p.x,p.y,p.screenPts),s.clip(),wa(s,p.x,p.y,p.canvasW,p.canvasH,p.textureTint,o),s.restore()),Da(s,p,o)}let d=await Ia(i);return i.width=1,i.height=1,{width:e.width,height:e.height,url:d}}async function jt(e,n,t,o,i){let r=[];for(let s of e){if(i())break;r.push(await Ha(s,n,t,o))}return r}var Y=require("@layoutit/polycss-core"),Xn=require("@layoutit/polycss-core"),di=require("@layoutit/polycss-core");var ui=require("@layoutit/polycss-core");function Jt(e,n){let o=e?.defaultView?.__polycssProjectiveQuadGuards,i=n&&o?{...n,...o}:o??n;return(0,ui.resolveProjectiveQuadGuards)(i)}function en(e){if(!!!(e.defaultView?.CSS??(typeof CSS<"u"?CSS:void 0))?.supports?.("border-shape","polygon(0 0, 100% 0, 0 100%) circle(0)"))return!1;let i=(e.defaultView??(typeof window<"u"?window:void 0))?.matchMedia;return i?i("(pointer: fine)").matches&&i("(hover: hover)").matches:!0}function lr(e){if(pi(e))return!0;let t=(e.defaultView??(typeof window<"u"?window:void 0))?.navigator?.userAgent??"";return t?!(0,Y.safariCssProjectiveUnsupported)(t):!0}function An(e){let n=e.defaultView?.CSS??(typeof CSS<"u"?CSS:void 0);return!!n?.supports?.("corner-top-left-shape","bevel")&&!!n.supports("corner-top-right-shape","bevel")&&!!n.supports("corner-bottom-right-shape","bevel")&&!!n.supports("corner-bottom-left-shape","bevel")}function pi(e){let n=e.defaultView?.CSS??(typeof CSS<"u"?CSS:void 0);return!!n?.supports?.("corner-top-left-shape","bevel")&&!!n.supports("corner-top-right-shape","bevel")}function Fa(e){let t=(e.defaultView??(typeof window<"u"?window:void 0))?.navigator?.userAgent??"";return/\bFirefox\//.test(t)}function tt(e,n){return n?.disable?.includes("u")?null:pi(e)?"corner-bevel":lr(e)?Fa(e)?"border-large":"border":null}function tn(e){let t=(e.defaultView??(typeof window<"u"?window:void 0))?.navigator?.userAgent??"";return t?!(0,Y.safariCssProjectiveUnsupported)(t):!0}function wn(e,n,t,o,i){let r=new Set(o?.disable??[]);return(0,Y.getSolidPaintDefaultsForPlansCore)(e,n,r,{solidTriangleSupported:lr(t),projectiveQuadSupported:tn(t),cornerShapeSupported:An(t),borderShapeSupported:en(t)},Xn.parseHex,Xn.rgbKey,i)}function qn(e,n,t=new Set,o){let i=o??(typeof document<"u"?document:null);if(!i)return{};let r=t.size>0?{disable:Array.from(t)}:void 0;return wn(e,n,i,r)}function Mn(e){let n=e??(typeof document<"u"?document:null);if(!n){if(!!!(typeof CSS<"u"?CSS:void 0)?.supports?.("border-shape","polygon(0 0, 100% 0, 0 100%) circle(0)"))return!1;let i=typeof matchMedia<"u"?matchMedia:void 0;return i?i("(pointer: fine)").matches&&i("(hover: hover)").matches:!0}return en(n)}function Ln(e){let n=e??(typeof document<"u"?document:null);if(!n){let t=typeof CSS<"u"?CSS:void 0;if(t?.supports?.("corner-top-left-shape","bevel")&&t.supports("corner-top-right-shape","bevel"))return!0;let o=(typeof navigator<"u"?navigator:globalThis.navigator)?.userAgent??"";if(!o)return!0;let i=/\b(?:Chrome|HeadlessChrome|Chromium|Edg|OPR)\//.test(o);return!/\bVersion\/[\d.]+.*\bSafari\//.test(o)||i}return lr(n)}function Zn(e,n,t,o){let i=o??(typeof document<"u"?document:null);return(0,Y.filterAtlasPlans)(e,n,t,{solidTriangleSupported:Ln(o),projectiveQuadSupported:i?tn(i):!0,borderShapeSupported:Mn(o)})}var De=require("@layoutit/polycss-core"),ze=require("@layoutit/polycss-core");var ln=require("@layoutit/polycss-core");var Le=require("@layoutit/polycss-core"),mi=require("@layoutit/polycss-core");var nn=require("@layoutit/polycss-core");function Oe(e,n,t){let o=e.getAttribute("style")??"",i=`${n}:${t}`,r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=new RegExp(`(^|;)\\s*${r}\\s*:[^;]*`,"i"),c=s.test(o)?o.replace(s,(l,d)=>`${d}${i}`):`${o}${o.trim()&&!o.trim().endsWith(";")?";":""}${i}`;c!==o&&e.setAttribute("style",c)}function wt(e,n){let t=e.getAttribute("style")??"";if(!t||!t.toLowerCase().includes(n.toLowerCase()))return;let o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=new RegExp(`^\\s*${o}\\s*:`,"i"),r=t.split(";").map(s=>s.trim()).filter(s=>s&&!i.test(s)).join(";");r?e.setAttribute("style",r):e.removeAttribute("style")}function Rn(e,n,t,o=!1){if(n==="dynamic"){let i=(0,nn.parseHex)(e.polygon.color??"#cccccc"),r=o?"":`;--pnx:${e.normal[0].toFixed(4)};--pny:${e.normal[1].toFixed(4)};--pnz:${e.normal[2].toFixed(4)}`;return(0,nn.rgbKey)(i)!==t?.dynamicColorKey&&(r+=`;--psr:${(i.r/255).toFixed(4)};--psg:${(i.g/255).toFixed(4)};--psb:${(i.b/255).toFixed(4)}`),r}return e.shadedColor?`;color:${e.shadedColor}`:""}function za(e,n){Oe(e,"--pnx",n.normal[0].toFixed(4)),Oe(e,"--pny",n.normal[1].toFixed(4)),Oe(e,"--pnz",n.normal[2].toFixed(4))}function on(e,n,t,o){if(t==="dynamic"){wt(e,"color"),wt(e,"background"),za(e,n);let i=(0,nn.parseHex)(n.polygon.color??"#cccccc");(0,nn.rgbKey)(i)===o?.dynamicColorKey?(wt(e,"--psr"),wt(e,"--psg"),wt(e,"--psb")):(Oe(e,"--psr",(i.r/255).toFixed(4)),Oe(e,"--psg",(i.g/255).toFixed(4)),Oe(e,"--psb",(i.b/255).toFixed(4)))}else n.shadedColor!==o?.paintColor?(wt(e,"background"),Oe(e,"color",n.shadedColor)):(wt(e,"background"),wt(e,"color"))}var rn=require("@layoutit/polycss-core"),On=require("@layoutit/polycss-core"),Kn=require("@layoutit/polycss-core"),yt=require("@layoutit/polycss-core"),fi="polycss-corner-shape-solid";function kn(e){return e.atlasLeafWidth??(0,On.atlasCanonicalSizeForEntry)(e)}function _n(e){return e.atlasLeafHeight??(0,On.atlasCanonicalSizeForEntry)(e)}function gi(e,n){return(0,Le.resolvePolyTextureImageRendering)(e.polygon,n)}function Qn(e){return e==="pixelated"?";image-rendering:pixelated":""}function dr(e,n,t,o,i,r,s,c,l){e.setAttribute("data-polycss-leaf","polygon"),e.setAttribute("data-polycss-texture-backend",n),e.setAttribute("data-polycss-texture-ready",t?"true":"false"),e.setAttribute("data-polycss-texture-image-rendering",o),i?e.setAttribute("data-polycss-texture-leaf-sizing",i):e.removeAttribute("data-polycss-texture-leaf-sizing"),r?e.setAttribute("data-polycss-texture-projection",r):e.removeAttribute("data-polycss-texture-projection"),s?e.setAttribute("data-polycss-texture-lighting",s):e.removeAttribute("data-polycss-texture-lighting"),typeof c=="number"?e.setAttribute("data-polycss-texture-leaf-width",String(c)):e.removeAttribute("data-polycss-texture-leaf-width"),typeof l=="number"?e.setAttribute("data-polycss-texture-leaf-height",String(l)):e.removeAttribute("data-polycss-texture-leaf-height")}var cr=new WeakMap,ur=new WeakMap;function _e(e,n,t){let o=cr.get(e),i=ur.get(e),r=typeof t=="number";if(!n.data&&!r&&(!o||o.length===0)){e.__polycssHasDataAttrs=!1;return}let s=new Map;if(n.data)for(let[l,d]of Object.entries(n.data))s.set(l,String(d));if(n.doubleSided===!0&&s.set("polycss-double-sided","true"),r&&s.set("poly-index",String(t)),o)for(let l of o)s.has(l)||e.removeAttribute(`data-${l}`);for(let[l,d]of s)i?.get(l)!==d&&e.setAttribute(`data-${l}`,d);let c=Array.from(s.keys());c.length>0?cr.set(e,c):cr.delete(e),s.size>0?ur.set(e,s):ur.delete(e),e.__polycssHasDataAttrs=c.length>0}function sn(e){return e.__polycssHasDataAttrs===!0}function pr(e,n,t,o,i=t==="dynamic",r){if(!n.url)return;let s=gi(o,r),c=`url(${n.url})`,l=o.canvasW||1,d=o.canvasH||1,p=(0,On.atlasCanonicalSizeForEntry)(o),y=kn(o),g=_n(o),b=`${(0,Le.formatCssLength)(-o.x/l*y)} ${(0,Le.formatCssLength)(-o.y/d*g)}`,x=`${(0,Le.formatCssLength)(n.width/l*y)} ${(0,Le.formatCssLength)(n.height/d*g)}`,v=`transform:matrix3d(${o.atlasMatrix});--polycss-atlas-size:${p}px;--polycss-atlas-width:${(0,Le.formatCssLength)(y)};--polycss-atlas-height:${(0,Le.formatCssLength)(g)};--polycss-atlas-leaf-sizing:${o.atlasLeafSizing??"canonical"}`,h=`${v};--polycss-atlas-position:${b};--polycss-atlas-image-size:${x}`;if(t==="dynamic"){let C=i?`;--pnx:${o.normal[0].toFixed(4)};--pny:${o.normal[1].toFixed(4)};--pnz:${o.normal[2].toFixed(4)}`:"";e.setAttribute("style",h+`;--polycss-atlas-url:${c}`+C+Qn(s))}else e.setAttribute("style",v+`;background-image:${c};background-position:${b};background-size:${x};background-repeat:no-repeat;--pnx:${o.normal[0].toFixed(4)};--pny:${o.normal[1].toFixed(4)};--pnz:${o.normal[2].toFixed(4)}`+Qn(s));dr(e,"atlas",!0,s,o.atlasLeafSizing??"canonical","affine",t,y,g)}function hi(e,n,t,o){if(n.texture){if(!t.texture||n.texture!==t.texture)return!1}else if(t.texture)return!1;let i=yi(n,t);return i?(e.style.visibility="",Oe(e,"transform",`matrix3d(${i.matrix})`),o==="dynamic"&&(Oe(e,"--pnx",i.normal[0].toFixed(4)),Oe(e,"--pny",i.normal[1].toFixed(4)),Oe(e,"--pnz",i.normal[2].toFixed(4))),_e(e,t,n.index),!0):(e.style.visibility="hidden",_e(e,t,n.index),!0)}function mr(e,n,t,o,i){if(o!=="baked")return{...e,polygon:n,normal:t};let r=i.directionalLight,s=i.ambientLight,c=r?.direction??yt.DEFAULT_LIGHT_DIR,l=r?.color??yt.DEFAULT_LIGHT_COLOR,d=Math.max(0,r?.intensity??yt.DEFAULT_LIGHT_INTENSITY),p=s?.color??yt.DEFAULT_AMBIENT_COLOR,y=Math.max(0,s?.intensity??yt.DEFAULT_AMBIENT_INTENSITY),g=Math.hypot(c[0],c[1],c[2])||1,b=c[0]/g,x=c[1]/g,v=c[2]/g,C=i.lightOccludedPolyIndices?.has(e.index)??!1?0:d*Math.max(0,t[0]*b+t[1]*x+t[2]*v);return{...e,polygon:n,normal:t,shadedColor:(0,mi.shadePolygon)(n.color??"#cccccc",C,l,p,y)}}function yi(e,n){let t=bi(e,n);if(!t)return null;let{normal:o,xAxis:i,yAxis:r,tx:s,ty:c,tz:l}=t;return{normal:o,matrix:(0,Le.formatMatrix3dValues)([i[0]*e.canvasW/kn(e),i[1]*e.canvasW/kn(e),i[2]*e.canvasW/kn(e),0,r[0]*e.canvasH/_n(e),r[1]*e.canvasH/_n(e),r[2]*e.canvasH/_n(e),0,o[0],o[1],o[2],0,s,c,l,1])}}var bi=Kn.stableBasisFromPlan;function Ba(e,n,t){if(e.screenPts.length!==8||n.vertices.length!==4)return null;let o=bi(e,n);if(!o)return null;let i=(0,Kn.computeProjectiveQuadMatrix)(e.screenPts,o.xAxis,o.yAxis,o.normal,o.tx,o.ty,o.tz,t);return i?{matrix:i,normal:o.normal}:null}function fr(e,n,t,o,i=!1){let r=t.createElement("b");return r.setAttribute("style",`transform:matrix3d(${(0,Le.formatSolidQuadMatrix)(e)})`+Rn(e,n,o,i)),_e(r,e.polygon,e.index),r}function gr(e,n,t,o,i=!1){let r=t.createElement("i");return r.setAttribute("style",(0,rn.formatBorderShapeElementStyle)(e)+Rn(e,n,o,i)),_e(r,e.polygon,e.index),r}function hr(e,n,t,o,i,r=!1){let s=o.createElement("u");return s.className=fi,s.setAttribute("style",(0,rn.formatCornerShapeElementStyle)(e,n)+Rn(e,t,i,r)),_e(s,e.polygon,e.index),s}function yr(e,n,t,o,i=!1){let r=t.createElement("b");return r.setAttribute("style",`transform:matrix3d(${e.projectiveMatrix})`+Rn(e,n,o,i)),_e(r,e.polygon,e.index),r}function xi(e,n,t,o,i,r,s){let c=n.projectiveMatrix?Ba(n,t,r):yi(n,t);if(!c)return!1;let l=mr(n,t,c.normal,o,i);return e.style.visibility="",e.style.transform=`matrix3d(${c.matrix})`,on(e,l,o,s),_e(e,l.polygon,l.index),!0}function Pi(e,n,t,o){e.style.visibility="",e.setAttribute("style",(0,rn.formatBorderShapeElementStyle)(n)),on(e,n,t,o),_e(e,n.polygon,n.index)}function vi(e,n,t,o,i){e.style.visibility="",e.className=fi,e.setAttribute("style",(0,rn.formatCornerShapeElementStyle)(n,t)),on(e,n,o,i),Oe(e,"background","currentColor"),_e(e,n.polygon,n.index)}function br(e,n,t,o=!1,i){let r=t.createElement("s"),s=gi(e,i),c=(0,On.atlasCanonicalSizeForEntry)(e),l=kn(e),d=_n(e),p=o?"":`;--pnx:${e.normal[0].toFixed(4)};--pny:${e.normal[1].toFixed(4)};--pnz:${e.normal[2].toFixed(4)}`;return r.setAttribute("style",`transform:matrix3d(${e.atlasMatrix});--polycss-atlas-size:${c}px;--polycss-atlas-width:${(0,Le.formatCssLength)(l)};--polycss-atlas-height:${(0,Le.formatCssLength)(d)};--polycss-atlas-leaf-sizing:${e.atlasLeafSizing??"canonical"};opacity:0`+p+Qn(s)),dr(r,"atlas",!1,s,e.atlasLeafSizing??"canonical","affine",n,l,d),_e(r,e.polygon,e.index),r}function xr(e,n,t,o=!1){let i=t.createElement("s"),r=o?"":`;--pnx:${e.normal[0].toFixed(4)};--pny:${e.normal[1].toFixed(4)};--pnz:${e.normal[2].toFixed(4)}`;return i.setAttribute("style",`transform:matrix3d(${n.matrix});--polycss-atlas-width:${(0,Le.formatCssLength)(n.leafWidth)};--polycss-atlas-height:${(0,Le.formatCssLength)(n.leafHeight)};--polycss-atlas-leaf-sizing:image;background-image:url(${n.url});background-position:${(0,Le.formatCssLength)(n.backgroundPosition[0])} ${(0,Le.formatCssLength)(n.backgroundPosition[1])};background-size:${(0,Le.formatCssLength)(n.backgroundSize[0])} ${(0,Le.formatCssLength)(n.backgroundSize[1])};background-repeat:no-repeat;background-blend-mode:normal;mask-image:none;-webkit-mask-image:none`+r+Qn(n.imageRendering)),dr(i,"image",!0,n.imageRendering,"image",n.projection,n.lighting,n.leafWidth,n.leafHeight),i.setAttribute("data-polycss-texture-source-x",String(n.sourceRect.x)),i.setAttribute("data-polycss-texture-source-y",String(n.sourceRect.y)),i.setAttribute("data-polycss-texture-source-width",String(n.sourceRect.width)),i.setAttribute("data-polycss-texture-source-height",String(n.sourceRect.height)),_e(i,e.polygon,e.index),i}var Ti=require("@layoutit/polycss-core");var Jn=require("@layoutit/polycss-core");function Mt(e,n,t,o={}){let i=o.primitive!=null?void 0:(()=>{let r=t.doc??(typeof document<"u"?document:null);return r?tt(r,t.strategies)??"border":"border"})();return(0,Jn.computeSolidTrianglePlan)(e,n,t,{...o,resolvedPrimitive:o.resolvedPrimitive??i})}function Pr(e,n,t,o,i,r,s,c,l,d,p,y,g){let b=o.primitive!=null?void 0:(()=>{let x=t.doc??(typeof document<"u"?document:null);return x?tt(x,t.strategies)??"border":"border"})();return(0,Jn.computeSolidTrianglePlanFromCssPoints)(e,n,t,{...o,resolvedPrimitive:o.resolvedPrimitive??b},i,r,s,c,l,d,p,y,g)}var $t=require("@layoutit/polycss-core"),Rt=require("@layoutit/polycss-core"),vr=require("@layoutit/polycss-core");var eo=require("@layoutit/polycss-core");var Va="0 48px 96px 48px";function Sr(e,n){return(0,$t.buildSeamBleedPolygonEdges)(e,{tileSize:n.tileSize,layerElevation:n.layerElevation,directionalLight:n.directionalLight,ambientLight:n.ambientLight})}function Cr(e,n,t){let o=(0,$t.resolveBleedRatio)(t.seamBleed),i=$t.DEFAULT_SEAM_BLEED*o,r={...t,bleedRatio:o};return n&&i>0?{...r,seamBleed:n.has(e)?i:void 0,seamEdges:n.get(e)}:r}function to(e){return{updatesDisabled:e.stableTriangleColorFreezeFrames===0,freezeFrames:Math.max(1,Math.floor(e.stableTriangleColorFreezeFrames??1)),colorFrame:Math.max(0,Math.floor(e.stableTriangleColorFrame??0)),maxStep:Math.max(0,Math.floor(e.stableTriangleColorMaxStep??0))}}function Si(e,n){return!n.updatesDisabled&&(n.freezeFrames<=1||(n.colorFrame+e)%n.freezeFrames===0)}function Lt(e,n,t,o,i,r){return t?r.updatesDisabled||o==="plan-only"||o==="transform-only"?!1:i==="adaptive"||e.__polycssSolidTriangleColor===void 0?!0:Si(n,r):!0}function Tr(e,n){let t=e;t.__polycssSolidTrianglePrimitive!==n&&(n==="corner-bevel"?(e.style.width="",e.style.height="",e.style.backgroundColor="",e.style.borderWidth="",e.style.borderTopLeftRadius="",e.style.borderTopRightRadius="",e.style.removeProperty("corner-top-left-shape"),e.style.removeProperty("corner-top-right-shape")):(e.style.width="",e.style.height="",e.style.backgroundColor="",e.style.borderTopLeftRadius="",e.style.borderTopRightRadius="",e.style.removeProperty("corner-top-left-shape"),e.style.removeProperty("corner-top-right-shape"),e.style.borderWidth=n==="border-large"?Va:""),t.__polycssSolidTrianglePrimitive=n)}function Er(e){let n=e;n.__polycssSolidTriangleHidden&&(e.style.visibility="",n.__polycssSolidTriangleHidden=!1)}function an(e){let n=e;n.__polycssSolidTriangleHidden||(e.style.visibility="hidden",n.__polycssSolidTriangleHidden=!0)}function Dn(e,n){e.setAttribute("style",n.styleText),Tr(e,n.primitive);let t=e;t.__polycssSolidTriangleBasis=n.basis,t.__polycssSolidTriangleHidden=!1,n.colorComputed&&(t.__polycssSolidTriangleColor=n.bakedColor??"",t.__polycssSolidTriangleColorRgb=n.bakedRgb,t.__polycssSolidTriangleColorAlpha=n.bakedAlpha),t.__polycssSolidTriangleColorFrame=void 0,(n.polygon.data||sn(e))&&_e(e,n.polygon)}function Ci(e,n,t,o){if(!n.colorComputed){(n.polygon.data||sn(e))&&_e(e,n.polygon);return}let i=e,r=n.bakedColor??"",s=n.bakedRgb,c=n.bakedAlpha??1,l=i.__polycssSolidTriangleColor,d=i.__polycssSolidTriangleColorRgb,p=i.__polycssSolidTriangleColorAlpha??1,y=o??Si(n.index,t);if(!t.updatesDisabled&&l!==r&&(l===void 0||y)){let g=r,b=s;if(t.maxStep>0&&d&&s&&p===c){let x=(0,Rt.stepRgbToward)(d,s,t.maxStep);b=x,g=(0,Rt.rgbToCss)(x,c)}(g!==l||!(0,Rt.rgbEqual)(b,d))&&(e.style.color=g),i.__polycssSolidTriangleColor=g,i.__polycssSolidTriangleColorRgb=b,i.__polycssSolidTriangleColorAlpha=c,i.__polycssSolidTriangleColorFrame=t.colorFrame}(n.polygon.data||sn(e))&&_e(e,n.polygon)}function In(e,n,t,o){let i=e;Tr(e,n.primitive),i.__polycssSolidTriangleBasis!==n.basis&&(i.__polycssSolidTriangleBasis=n.basis),Er(e),e.style.transform=n.transformText,(n.colorComputed||n.polygon.data||sn(e))&&Ci(e,n,t,o)}function no(e,n,t,o){Er(e),Ci(e,n,t,o)}function Hn(e,n){let t=e;Tr(e,n.primitive),t.__polycssSolidTriangleBasis!==n.basis&&(t.__polycssSolidTriangleBasis=n.basis),Er(e),e.style.transform=n.transformText,(n.polygon.data||sn(e))&&_e(e,n.polygon)}function Na(e,n){let t=n.stableTriangleColorBudget;if(typeof t=="number"&&Number.isFinite(t)&&t>0)return t<=1?Math.max(1,Math.ceil(e*t)):Math.max(1,Math.floor(t));let o=Math.max(1,Math.floor(n.stableTriangleColorFreezeFrames??1));return Math.max(1,Math.ceil(e/o))}function Ar(e,n,t){if(t.stableTriangleColorPolicy!=="adaptive")return null;if(t.stableTriangleColorFreezeFrames===0)return new Set;let o=Math.max(0,Math.floor(t.stableTriangleColorFrame??0)),i=Math.max(1,Math.floor(t.stableTriangleColorFreezeFrames??1));if(i<=1&&!Number.isFinite(t.stableTriangleColorBudget))return null;let r=Na(e.length,t),s=Math.max(1,Math.floor(t.stableTriangleColorMaxAge??Math.max(2,i*2))),c=[];for(let l=0;l<e.length;l++){let d=e[l],p=n[l];if(d.kind!=="triangle"||!p)continue;let y=d.element,g=y.__polycssSolidTriangleColor,b=p.bakedColor??"";if(g===b)continue;let x=y.__polycssSolidTriangleColorFrame??0,v=Math.max(0,o-x),h=(0,Rt.colorErrorScore)(g,b);c.push({index:l,score:(v>=s?1e6:0)+h*1e4+v})}return c.length===0?new Set:(c.sort((l,d)=>d.score-l.score),new Set(c.slice(0,r).map(l=>l.index)))}function oo(e,n){let t=n.createElement("u");return Dn(t,e),_e(t,e.polygon,e.index),t}function ja(e,n,t){let o=t.createElement("u");return an(o),_e(o,e,n),o}function wr(e,n,t,o,i,r){let s=t,c=s.stableTriangleDebug,l=o&&i==="color-only";if(s.stableTriangleColorPolicy==="adaptive"||e.length!==n.length)return!1;let d=(0,eo.stableTriangleMatrixDecimals)(s.stableTriangleMatrixDecimals),p=t.doc??(typeof document<"u"?document:null),y=p?tt(p,t.strategies)??"border":"border";for(let b=0;b<e.length;b++){let x=e[b];if(x.kind!=="triangle"||x.polygonIndex!==b||!n[b])return!1}let g=Sr(n,t);for(let b=0;b<e.length;b++){let x=e[b].element,v=n[b];if(l){if(Lt(x,b,o,c,s.stableTriangleColorPolicy,r)){let C=(0,vr.computeSolidTriangleColorPlan)(v,b,t);if(!C)continue;no(x,C,r)}continue}let h=Mt(v,b,Cr(b,g,t),{basis:x.__polycssSolidTriangleBasis,matrixDecimals:d,primitive:y,includeColor:i!=="plan-only"&&i!=="transform-only"&&Lt(x,b,o,c,s.stableTriangleColorPolicy,r)});if(!h){an(x);continue}o&&i==="plan-only"||(o&&i==="transform-only"?Hn(x,h):o?In(x,h,r):Dn(x,h))}return!0}function Wt(e,n={}){let t=n.doc??(typeof document<"u"?document:null);if(!t)return{rendered:[],dispose:()=>{}};let o=tt(t,n.strategies);if(!o||e.some(c=>c.texture||c.vertices.length!==3))return null;let i=(0,eo.stableTriangleMatrixDecimals)(n.stableTriangleMatrixDecimals),r=[],s=Sr(e,n);for(let c=0;c<e.length;c+=1){let l=e[c],d=Mt(l,c,Cr(c,s,n),{matrixDecimals:i,primitive:o}),p=d?oo(d,t):ja(l,c,t);r.push({polygonIndex:c,element:p,kind:"triangle",dispose:()=>{}})}return{rendered:r,dispose(){}}}function ro(e,n,t={}){let o=t.doc??(typeof document<"u"?document:null);if(!o)return{rendered:e,dispose:()=>{}};let i=tt(o,t.strategies);if(!i||e.some(h=>h.kind!=="triangle")||n.length!==e.length)return null;for(let h=0;h<e.length;h++)if(e[h].polygonIndex!==h)return null;let r=t.optimizeStableTriangleStyle===!0&&(t.textureLighting??"baked")==="baked",s=t,c=s.stableTriangleDebug,l=s.stableTriangleUpdateMode??(c==="plan-only"||c==="transform-only"?c:"full"),d=r&&l==="color-only",p=to(s),y=(0,eo.stableTriangleMatrixDecimals)(s.stableTriangleMatrixDecimals);if(wr(e,n,t,r,l,p))return{rendered:e,dispose(){}};let g=new Array(e.length),b=new Array(e.length),x=Sr(n,t);for(let h=0;h<e.length;h++){let C=e[h].element;if(d){let R=s.stableTriangleColorPolicy==="adaptive"||Lt(C,h,r,c,s.stableTriangleColorPolicy,p);b[h]=R?(0,vr.computeSolidTriangleColorPlan)(n[h],h,t):null;continue}g[h]=Mt(n[h],h,Cr(h,x,t),{basis:C.__polycssSolidTriangleBasis,matrixDecimals:y,primitive:i,includeColor:l!=="plan-only"&&l!=="transform-only"&&Lt(C,h,r,c,s.stableTriangleColorPolicy,p)})}let v=r&&l!=="plan-only"&&l!=="transform-only"?Ar(e,d?b:g,s):null;for(let h=0;h<e.length;h++){if(d){let R=b[h];R&&no(e[h].element,R,p,v?.has(h));continue}let C=g[h];if(!C){an(e[h].element);continue}r&&l==="plan-only"||(r&&l==="transform-only"?Hn(e[h].element,C):r?In(e[h].element,C,p,v?.has(h)):Dn(e[h].element,C))}return{rendered:e,dispose(){}}}var Lr=require("@layoutit/polycss-core");function Ei(){return new Promise(e=>setTimeout(e,0))}async function Mr(e){return performance.now()-e<De.ASYNC_RENDER_BUDGET_MS?e:(await Ei(),performance.now())}function Ai(e,n){let t=(0,De.resolveBleedRatio)(n.seamBleed),o=De.DEFAULT_SEAM_BLEED*t,i={...n,bleedRatio:t};return e.seamBleedEdges?.size&&o>0?{...i,seamBleed:o,seamEdges:e.seamBleedEdges}:{...i,seamBleed:void 0,seamEdges:void 0}}function wi(e,n){return(0,ze.buildSeamBleedPolygonEdges)(e,{tileSize:n.tileSize,layerElevation:n.layerElevation,directionalLight:n.directionalLight,ambientLight:n.ambientLight})}function Mi(e,n,t){let o=(0,De.resolveBleedRatio)(t.seamBleed),i=De.DEFAULT_SEAM_BLEED*o,r={...t,bleedRatio:o};return n&&i>0?{...r,seamBleed:n.has(e)?i:void 0,seamEdges:n.get(e)}:r}function kt(e,n={}){let t=n.doc??(typeof document<"u"?document:null);if(!t)return{};let o=(0,ze.buildBasisHints)(e,n),i=Jt(t),r=e.map((s,c)=>(0,ze.computeTextureAtlasPlan)(s,c,n,i,o[c]));return wn(r,n.textureLighting??"baked",t,n.strategies)}function _t(e,n={}){let t=n.doc??(typeof document<"u"?document:null);if(!t)return{rendered:[],dispose:()=>{}};let o=n.textureLighting??"baked",i=n,r=o==="dynamic"&&i.skipDynamicNormalVars===!0,s=new Set(n.strategies?.disable??[]),c=!s.has("b"),l=c&&tn(t),d=tt(t,n.strategies),p=d!==null,y=!s.has("i")&&An(t),g=!s.has("i")&&en(t),b=(0,ze.buildBasisHints)(e,n),x=Jt(t),v=wi(e,n),h=e.map((u,m)=>(0,ze.computeTextureAtlasPlan)(u,m,Mi(m,v,n),x,b[m])),C=n.solidPaintDefaults??(i.computeSolidPaintDefaults?wn(h,o,t,n.strategies):void 0),R=C?{...n,solidPaintDefaults:C}:n,I=h.map(u=>u&&p&&(0,Y.isSolidTrianglePlan)(u)?Mt(u.polygon,u.index,Ai(u,R),{primitive:d??void 0}):null),z=h.map(u=>u&&y&&!(0,Y.isSolidTrianglePlan)(u)&&!(c&&(0,Y.isFullRectSolid)(u))&&!(l&&(0,Y.isProjectiveQuadPlan)(u))?(0,ln.cornerShapeGeometryForPlan)(u):null),D=h.map(u=>u?(0,ze.resolvePolyTextureLeafGeometry)(u,{imageRendering:n.textureImageRendering,backend:n.textureBackend,projection:n.textureProjection,allowProjective:l,projectiveQuadGuards:x}):null),q=h.map((u,m)=>D[m]?null:u&&(u.texture||!(c&&(0,Y.isFullRectSolid)(u))&&!I[m]&&!(l&&(0,Y.isProjectiveQuadPlan)(u))&&!z[m]&&!g?u:null)),{packed:Z,atlasScale:M}=Nt(q,n.textureQuality,t,n.textureLeafSizing),V=new Map,B=[],F=!1,ae=[];for(let u=0;u<e.length;u++){let m=h[u],A=I[u],k=z[u],N=D[u];if(!m)continue;let X=Z.entries[u];if(X){let w=br(X,o,t,r,n.textureImageRendering);V.set(u,w),B.push({polygonIndex:u,element:w,kind:"atlas",plan:X,dispose:()=>{}})}else if(N){let w=xr(m,N,t,r);B.push({polygonIndex:u,element:w,kind:"image",plan:m,dispose:()=>{}})}else if(!m.texture&&c&&(0,Y.isFullRectSolid)(m)){let w=fr(m,o,t,C,r);B.push({polygonIndex:u,element:w,kind:"solid",plan:m,dispose:()=>{}})}else if(!m.texture&&A){let w=oo(A,t);B.push({polygonIndex:u,element:w,kind:"triangle",plan:m,dispose:()=>{}})}else if(!m.texture&&l&&(0,Y.isProjectiveQuadPlan)(m)){let w=yr(m,o,t,C,r);B.push({polygonIndex:u,element:w,kind:"solid",plan:m,dispose:()=>{}})}else if(!m.texture&&k){let w=hr(m,k,o,t,C,r);B.push({polygonIndex:u,element:w,kind:"corner",plan:m,dispose:()=>{}})}else if(!m.texture&&g){let w=gr(m,o,t,C,r);B.push({polygonIndex:u,element:w,kind:"border",plan:m,dispose:()=>{}})}}B.sort((u,m)=>u.polygonIndex-m.polygonIndex);let P=jt(Z.pages,o,t,M,()=>F).then(u=>{if(F){for(let m of u)m.url?.startsWith("blob:")&&URL.revokeObjectURL(m.url);return}ae=u.flatMap(m=>m.url?.startsWith("blob:")?[m.url]:[]);for(let m=0;m<Z.pages.length;m++){let A=Z.pages[m],k=u[m];if(k)for(let N of A.entries){let X=V.get(N.index);!X||!k.url||pr(X,k,o,N,!0,n.textureImageRendering)}}}).catch(()=>{if(!F)for(let u of V.values())Oe(u,"opacity","0.5"),Oe(u,"outline","1px dashed rgba(255, 0, 0, 0.6)")});return{rendered:B,solidPaintDefaults:C??{},pagesReady:P,dispose(){F=!0;for(let u of ae)URL.revokeObjectURL(u);ae=[]}}}async function cn(e,n={},t=()=>!1){let o=n.doc??(typeof document<"u"?document:null);if(!o||t())return{rendered:[],solidPaintDefaults:{},dispose:()=>{}};let i=n.textureLighting??"baked",s=i==="dynamic"&&n.skipDynamicNormalVars===!0,c=new Set(n.strategies?.disable??[]),l=!c.has("b"),d=l&&tn(o),p=tt(o,n.strategies),y=p!==null,g=!c.has("i")&&An(o),b=!c.has("i")&&en(o);if(await Ei(),t())return{rendered:[],solidPaintDefaults:{},dispose:()=>{}};let x=(0,ze.buildBasisHints)(e,n),v=Jt(o),h=wi(e,n),C=performance.now(),R=new Array(e.length);for(let u=0;u<e.length;u++)if(R[u]=(0,ze.computeTextureAtlasPlan)(e[u],u,Mi(u,h,n),v,x[u]),C=await Mr(C),t())return{rendered:[],solidPaintDefaults:{},dispose:()=>{}};let I=n.solidPaintDefaults??wn(R,i,o,n.strategies),z=new Array(R.length),D=new Array(R.length),q=new Array(R.length),Z=new Array(R.length);for(let u=0;u<R.length;u++){let m=R[u],A=m&&y&&(0,Y.isSolidTrianglePlan)(m)?Mt(m.polygon,m.index,Ai(m,{...n,solidPaintDefaults:I}),{primitive:p??void 0}):null;z[u]=A;let k=m&&g&&!(0,Y.isSolidTrianglePlan)(m)&&!(l&&(0,Y.isFullRectSolid)(m))&&!(d&&(0,Y.isProjectiveQuadPlan)(m))?(0,ln.cornerShapeGeometryForPlan)(m):null;D[u]=k;let N=m?(0,ze.resolvePolyTextureLeafGeometry)(m,{imageRendering:n.textureImageRendering,backend:n.textureBackend,projection:n.textureProjection,allowProjective:d,projectiveQuadGuards:v}):null;if(q[u]=N,Z[u]=N?null:m&&(m.texture||!(l&&(0,Y.isFullRectSolid)(m))&&!A&&!(d&&(0,Y.isProjectiveQuadPlan)(m))&&!k&&!b?m:null),C=await Mr(C),t())return{rendered:[],solidPaintDefaults:I,dispose:()=>{}}}let{packed:M,atlasScale:V}=Nt(Z,n.textureQuality,o,n.textureLeafSizing),B=new Map,F=[],ae=!1,P=[];for(let u=0;u<e.length;u++){let m=R[u],A=z[u],k=D[u],N=q[u];if(!m)continue;let X=M.entries[u];if(X){let w=br(X,i,o,s,n.textureImageRendering);B.set(u,w),F.push({polygonIndex:u,element:w,kind:"atlas",plan:X,dispose:()=>{}})}else if(N){let w=xr(m,N,o,s);F.push({polygonIndex:u,element:w,kind:"image",plan:m,dispose:()=>{}})}else if(!m.texture&&l&&(0,Y.isFullRectSolid)(m)){let w=fr(m,i,o,I,s);F.push({polygonIndex:u,element:w,kind:"solid",plan:m,dispose:()=>{}})}else if(!m.texture&&A){let w=oo(A,o);F.push({polygonIndex:u,element:w,kind:"triangle",plan:m,dispose:()=>{}})}else if(!m.texture&&d&&(0,Y.isProjectiveQuadPlan)(m)){let w=yr(m,i,o,I,s);F.push({polygonIndex:u,element:w,kind:"solid",plan:m,dispose:()=>{}})}else if(!m.texture&&k){let w=hr(m,k,i,o,I,s);F.push({polygonIndex:u,element:w,kind:"corner",plan:m,dispose:()=>{}})}else if(!m.texture&&b){let w=gr(m,i,o,I,s);F.push({polygonIndex:u,element:w,kind:"border",plan:m,dispose:()=>{}})}if(C=await Mr(C),t()){for(let w of F)w.dispose();return{rendered:[],solidPaintDefaults:I,dispose:()=>{}}}}F.sort((u,m)=>u.polygonIndex-m.polygonIndex);let L=jt(M.pages,i,o,V,()=>ae||t()).then(u=>{if(ae||t()){for(let m of u)m.url?.startsWith("blob:")&&URL.revokeObjectURL(m.url);return}P=u.flatMap(m=>m.url?.startsWith("blob:")?[m.url]:[]);for(let m=0;m<M.pages.length;m++){let A=M.pages[m],k=u[m];if(k)for(let N of A.entries){let X=B.get(N.index);!X||!k.url||pr(X,k,i,N,!0,n.textureImageRendering)}}}).catch(()=>{if(!(ae||t()))for(let u of B.values())Oe(u,"opacity","0.5"),Oe(u,"outline","1px dashed rgba(255, 0, 0, 0.6)")});return{rendered:F,solidPaintDefaults:I,pagesReady:L,dispose(){ae=!0;for(let u of P)URL.revokeObjectURL(u);P=[]}}}function un(e,n,t,o={}){let i=o.textureLighting??"baked",r=o,s=r.optimizeStableTriangleStyle===!0&&i==="baked";if(!s||r.stableTriangleColorPolicy==="adaptive"||e.length!==t.polygonCount||n.length!==t.polygonCount||t.vertices.length<t.polygonCount*9)return!1;let c=r.stableTriangleDebug,l=r.stableTriangleUpdateMode??(c==="plan-only"||c==="transform-only"?c:"full");if(l==="color-only")return!1;let d=(0,Lr.stableTriangleMatrixDecimals)(r.stableTriangleMatrixDecimals),p=to(r),y=o.tileSize??De.DEFAULT_TILE,g=o.layerElevation??y,b=o.doc??(typeof document<"u"?document:null),x=b?tt(b,o.strategies)??"border":"border";for(let h=0;h<e.length;h++){let C=e[h],R=n[h];if(C.kind!=="triangle"||C.polygonIndex!==h||!R||R.vertices.length!==3||R.texture||R.material?.texture)return!1}let v=t.vertices;for(let h=0;h<e.length;h++){let C=e[h].element,R=n[h],I=h*9,z=v[I+1]*y,D=v[I]*y,q=v[I+2]*g,Z=v[I+4]*y,M=v[I+3]*y,V=v[I+5]*g,B=v[I+7]*y,F=v[I+6]*y,ae=v[I+8]*g,P=Pr(R,h,o,{basis:C.__polycssSolidTriangleBasis,matrixDecimals:d,primitive:x,color:t.colors?.[h],includeColor:l!=="plan-only"&&l!=="transform-only"&&Lt(C,h,s,c,r.stableTriangleColorPolicy,p)},z,D,q,Z,M,V,B,F,ae);if(!P){an(C);continue}l!=="plan-only"&&(l==="transform-only"?Hn(C,P):In(C,P,p))}return!0}function dn(e,n,t={}){if(e.length!==n.length)return!1;let o=t,i=t.doc??(typeof document<"u"?document:null),r=t.textureLighting??"baked",s=new Set(t.strategies?.disable??[]),c=!s.has("b"),l=!!i&&c&&tn(i),d=!!i&&!s.has("i")&&An(i),p=!!i&&!s.has("i")&&en(i),y=(0,De.resolveBleedRatio)(o.seamBleed),g=i?Jt(i,{bleed:De.PROJECTIVE_QUAD_BLEED*y}):{denomEps:De.PROJECTIVE_QUAD_DENOM_EPS,maxWeightRatio:De.PROJECTIVE_QUAD_MAX_WEIGHT_RATIO,bleed:De.PROJECTIVE_QUAD_BLEED*y,disableGuards:!1},b=o.optimizeStableTriangleStyle===!0&&r==="baked",x=o.stableTriangleDebug,v=o.stableTriangleUpdateMode??(x==="plan-only"||x==="transform-only"?x:"full"),h=b&&v==="color-only",C=to(o),R=(0,Lr.stableTriangleMatrixDecimals)(o.stableTriangleMatrixDecimals),I=i?tt(i,t.strategies)??"border":"border";if(wr(e,n,t,b,v,C))return!0;let z=[],D=[],q=[];for(let M=0;M<e.length;M++){let V=e[M];if(V.polygonIndex!==M)return!1;let B=n[M];if(!B||h&&V.kind!=="triangle")return!1;if(V.kind==="atlas"){if(!V.plan||!hi(V.element,V.plan,B,r))return!1;continue}if(V.kind==="triangle"){let F=V.element;if(h){let P=o.stableTriangleColorPolicy==="adaptive"||Lt(F,M,b,x,o.stableTriangleColorPolicy,C);D[M]=P?(0,Ti.computeSolidTriangleColorPlan)(B,M,t):null;continue}let ae=Mt(B,M,t,{basis:F.__polycssSolidTriangleBasis,matrixDecimals:R,primitive:I,includeColor:v!=="plan-only"&&v!=="transform-only"&&Lt(F,M,b,x,o.stableTriangleColorPolicy,C)});if(!ae){z[M]=null;continue}z[M]=ae;continue}if(V.kind==="solid"){if(!V.plan||B.texture||B.vertices.length!==V.plan.polygon.vertices.length)return!1;q[M]=V.plan;continue}if(V.kind==="border"){let F=(0,ze.computeTextureAtlasPlan)(B,M,t,g);if(!F||F.texture||!p||c&&(0,Y.isFullRectSolid)(F)||l&&(0,Y.isProjectiveQuadPlan)(F)||d&&(0,ln.cornerShapeGeometryForPlan)(F))return!1;q[M]=F;continue}if(V.kind==="corner"){let F=(0,ze.computeTextureAtlasPlan)(B,M,t,g);if(!F||F.texture||!d||(0,Y.isSolidTrianglePlan)(F)||c&&(0,Y.isFullRectSolid)(F)||l&&(0,Y.isProjectiveQuadPlan)(F)||!(0,ln.cornerShapeGeometryForPlan)(F))return!1;q[M]=F;continue}return!1}let Z=b&&v!=="plan-only"&&v!=="transform-only"?Ar(e,h?D:z,o):null;for(let M=0;M<e.length;M++){let V=e[M];if(V.kind==="triangle"){if(h){let F=D[M];F&&no(V.element,F,C,Z?.has(M));continue}let B=z[M];if(!B){an(V.element);continue}if(b&&v==="plan-only")continue;b&&v==="transform-only"?Hn(V.element,B):b?In(V.element,B,C,Z?.has(M)):Dn(V.element,B)}else if(V.kind==="solid"){let B=q[M];if(!B||!xi(V.element,B,n[M],r,t,g,o.solidPaintDefaults))return!1}else if(V.kind==="border"){let B=q[M];if(!B)return!1;Pi(V.element,B,r,o.solidPaintDefaults)}else if(V.kind==="corner"){let B=q[M],F=B?(0,ln.cornerShapeGeometryForPlan)(B):null;if(!B||!F)return!1;vi(V.element,B,F,r,o.solidPaintDefaults)}}return!0}var io=require("@layoutit/polycss-core"),nt=require("@layoutit/polycss-core"),Dt=require("@layoutit/polycss-core");var re=require("@layoutit/polycss-core"),$a=[.4,-.7,.59],Wa="#ffffff",Ua=1,Ga="#ffffff",Ya=.4,Di=1,Xa=8,qa=re.PROJECTIVE_QUAD_BLEED,Pt=1e-6,Za=(0,re.resolveProjectiveQuadGuards)({bleed:0}),Ii={t:[0,0,1],b:[0,0,-1],fl:[0,1,0],br:[0,-1,0],fr:[1,0,0],bl:[-1,0,0]},_r=["t","b","bl","br","fr","fl"],Qa=new Map([["0,0,1","t"],["0,0,-1","b"],["0,1,0","fl"],["0,-1,0","br"],["1,0,0","fr"],["-1,0,0","bl"]]);function Li(e){let n=[];for(let t of _r)(0,re.normalFacesCamera)(Ii[t],e)&&n.push(t);return n.join("|")}function Ka(e,n,t){let o=e.__polycssVoxelBrushState??(e.__polycssVoxelBrushState={});o.color!==n&&(e.style.color=n,o.color=n),o.transform!==t&&(e.style.transform=t,o.transform=t)}function Ja(e){let n=e.vertices;if(n.length<3)return null;let t=n[0],o=0,i=0,r=0;for(let c=1;c+1<n.length;c+=1){let l=n[c],d=n[c+1],p=l[1]-t[1],y=l[0]-t[0],g=l[2]-t[2],b=d[1]-t[1],x=d[0]-t[0],v=d[2]-t[2];o-=y*v-g*x,i-=g*b-p*v,r-=p*x-y*b}let s=Math.hypot(o,i,r);return s<=1e-9?null:[Math.round(o/s),Math.round(i/s),Math.round(r/s)]}function el(e){if(e.texture||e.material||e.uvs||e.textureTriangles||e.vertices.length!==4)return null;let n=Ja(e),t=n?Qa.get(n.join(",")):void 0;if(!t)return null;let o=1/0,i=1/0,r=1/0,s=-1/0,c=-1/0,l=-1/0;for(let y of e.vertices)o=Math.min(o,y[0]),i=Math.min(i,y[1]),r=Math.min(r,y[2]),s=Math.max(s,y[0]),c=Math.max(c,y[1]),l=Math.max(l,y[2]);let d=1e-6,p=al(e.color);return Math.abs(l-r)<=d?{axis:"z",face:t,left:i*re.BASE_TILE,top:o*re.BASE_TILE,width:Math.max(0,(c-i)*re.BASE_TILE),height:Math.max(0,(s-o)*re.BASE_TILE),z:r*re.BASE_TILE,baseColor:p,bleed:Rr()}:Math.abs(s-o)<=d?{axis:"x",face:t,left:i*re.BASE_TILE,top:r*re.BASE_TILE,width:Math.max(0,(c-i)*re.BASE_TILE),height:Math.max(0,(l-r)*re.BASE_TILE),z:-o*re.BASE_TILE,baseColor:p,bleed:Rr()}:Math.abs(c-i)<=d?{axis:"y",face:t,left:r*re.BASE_TILE,top:o*re.BASE_TILE,width:Math.max(0,(l-r)*re.BASE_TILE),height:Math.max(0,(s-o)*re.BASE_TILE),z:-i*re.BASE_TILE,baseColor:p,bleed:Rr()}:null}function Rr(){return{left:0,right:0,top:0,bottom:0}}function tl(e){let n=o=>String(Number(o.toFixed(6))),t=`${e.item.baseColor}|${e.variableAxis}`;for(let o=0;o<3;o+=1)o!==e.variableAxis&&(t+=`|${o}:${n(e.fixed[o])}`);return t}function Ri(e){return[e[1]*re.BASE_TILE,e[0]*re.BASE_TILE,e[2]*re.BASE_TILE]}function ki(e,n){return e.axis==="x"?[n[0],n[2]]:e.axis==="y"?[n[2],n[1]]:[n[0],n[1]]}function nl(e,n,t){let o=e.left,i=e.left+e.width,r=e.top,s=e.top+e.height;if(Math.abs(n[0]-t[0])<=Pt){if(Math.abs(n[0]-o)<=Pt)return"left";if(Math.abs(n[0]-i)<=Pt)return"right"}if(Math.abs(n[1]-t[1])<=Pt){if(Math.abs(n[1]-r)<=Pt)return"top";if(Math.abs(n[1]-s)<=Pt)return"bottom"}return null}function ol(e,n){let t=null;for(let o=0;o<3;o+=1)if(!(Math.abs(e[o]-n[o])<=Pt)){if(t!==null)return null;t=o}return t}function rl(e,n,t){let o=n.vertices,i=Ri(o[t]),r=Ri(o[(t+1)%o.length]),s=nl(e,ki(e,i),ki(e,r));if(!s)return null;let c=ol(i,r);if(c===null)return null;let l=Math.min(i[c],r[c]),d=Math.max(i[c],r[c]);return d-l>Pt?{item:e,side:s,variableAxis:c,fixed:i,start:l,end:d}:null}function _i(e){e.item.bleed[e.side]=Math.max(e.item.bleed[e.side],qa)}function il(e,n){let t=new Map;for(let o of n){let i=e[o.sourceIndex];if(i)for(let r=0;r<i.vertices.length;r+=1){let s=rl(o,i,r);if(!s)continue;let c=tl(s),l=t.get(c);l?l.push(s):t.set(c,[s])}}for(let o of t.values()){if(o.length<2)continue;o.sort((r,s)=>r.start-s.start||r.end-s.end);let i=[];for(let r of o){i=i.filter(s=>s.end>r.start+Pt);for(let s of i)s.item.sourceIndex!==r.item.sourceIndex&&(_i(s),_i(r));i.push(r)}}}function sl(e){let n=(0,re.parsePureColor)(e);return n?{r:n.rgb[0],g:n.rgb[1],b:n.rgb[2],alpha:n.alpha}:{r:255,g:255,b:255,alpha:1}}function al(e){if(!e)return"#cccccc";let n=(0,re.parsePureColor)(e);if(!n)return e;let t={r:n.rgb[0],g:n.rgb[1],b:n.rgb[2],alpha:n.alpha};if(t.alpha<1){let o=Math.round(Math.max(0,t.alpha)*1e3)/1e3;return`rgba(${kr(t.r)}, ${kr(t.g)}, ${kr(t.b)}, ${o})`}return ll(t)}function ll({r:e,g:n,b:t}){let o=i=>Math.round(Math.max(0,Math.min(255,i))).toString(16).padStart(2,"0");return`#${o(e)}${o(n)}${o(t)}`}function kr(e){return Math.round(Math.max(0,Math.min(255,e)))}function cl(e,n,t,o){let i=t?.direction??$a,r=Math.hypot(i[0],i[1],i[2])||1,s=i[0]/r,c=i[1]/r,l=i[2]/r,d=Math.max(0,t?.intensity??Ua)*Math.max(0,e[0]*s+e[1]*c+e[2]*l),p=Math.max(0,o?.intensity??Ya),y=t?.color??Wa,g=o?.color??Ga,b=(0,re.shadePolygon)(n,d,y,g,p),x=sl(n);if(x.alpha>=1)return b;let v=parseInt(b.slice(1,3),16),h=parseInt(b.slice(3,5),16),C=parseInt(b.slice(5,7),16);return`rgba(${v}, ${h}, ${C}, ${x.alpha})`}function ul(e){if(!e?.length)return[];let n=[];for(let t=0;t<e.length;t+=1){let o=e[t],i=el(o);if(!i||i.width<=0||i.height<=0)return[];n.push({...i,sourceIndex:t})}return il(e,n),n}function dl(e){return e.axis==="x"?{xAxis:[1,0,0],yAxis:[0,0,1],normal:[0,-1,0],tx:0,ty:-e.z,tz:0}:e.axis==="y"?{xAxis:[0,0,1],yAxis:[0,1,0],normal:[-1,0,0],tx:-e.z,ty:0,tz:0}:{xAxis:[1,0,0],yAxis:[0,1,0],normal:[0,0,1],tx:0,ty:0,tz:e.z}}function pl(e){let n=e.left,t=e.top,o=e.left+e.width,i=e.top+e.height;return[n,t,o,t,o,i,n,i]}function ml(e){return new Map([[0,e.bleed.top],[1,e.bleed.right],[2,e.bleed.bottom],[3,e.bleed.left]])}function fl(e,n){let t=e.split(",").map(Number);if(t.length!==16||t.some(i=>!Number.isFinite(i)))return null;let o=re.SOLID_QUAD_CANONICAL_SIZE/n;for(let i=0;i<8;i+=1)t[i]*=o;return`matrix3d(${t.map(i=>Number(i.toFixed(6))).join(",")})`}function Oi(e,n){let t=e.left-e.bleed.left,o=e.top-e.bleed.top,i=e.width+e.bleed.left+e.bleed.right,r=e.height+e.bleed.top+e.bleed.bottom,s=e.z,c=i/n,l=r/n;return`matrix3d(${(e.axis==="x"?[c,0,0,0,0,0,l,0,0,-1,0,0,t,-s,o,1]:e.axis==="y"?[0,0,c,0,0,l,0,0,-1,0,0,0,-s,o,t,1]:[c,0,0,0,0,l,0,0,0,0,1,0,t,o,s,1]).map(p=>Number(p.toFixed(6))).join(",")})`}function gl(e,n){let{xAxis:t,yAxis:o,normal:i,tx:r,ty:s,tz:c}=dl(e),l=(0,re.computeProjectiveQuadMatrix)(pl(e),t,o,i,r,s,c,Za,ml(e));return l?fl(l,n)??Oi(e,n):Oi(e,n)}function hl(e){let n=e.defaultView?.matchMedia;return n?n("(pointer: coarse)").matches||n("(hover: none)").matches:!1}function yl(e){return hl(e)?Xa:Di}function bl(e){return e.axis==="x"?[e.left+e.width/2,-e.z,e.top+e.height/2]:e.axis==="y"?[-e.z,e.top+e.height/2,e.left+e.width/2]:[e.left+e.width/2,e.top+e.height/2,e.z]}function xl(e,n){let t=bl(e),o=n.meshRotation;o&&(t=(0,re.rotateVec3InWrapperCssFrame)(t,o));let[i,r]=(0,re.rotateVec3)(t,n.rotX,0,n.rotY);return{x:i,y:r}}function Pl(e,n,t){let o=e.filter(g=>n.has(g.face)).map(g=>({item:g,...xl(g,t)}));if(o.length===0)return[];let i=1/0,r=-1/0,s=1/0,c=-1/0;for(let g of o)i=Math.min(i,g.x),r=Math.max(r,g.x),s=Math.min(s,g.y),c=Math.max(c,g.y);let l=4,d=Math.max(1e-6,r-i),p=Math.max(1e-6,c-s),y=new Map;for(let g of o){let b=Math.min(l-1,Math.max(0,Math.floor((g.x-i)/d*l))),x=Math.min(l-1,Math.max(0,Math.floor((g.y-s)/p*l))),v=`${b}:${x}`,h=y.get(v);h||(h={tx:b,ty:x,sourceIndex:g.item.sourceIndex,items:[]},y.set(v,h)),h.items.push(g.item),h.sourceIndex=Math.min(h.sourceIndex,g.item.sourceIndex)}return Array.from(y.values()).sort((g,b)=>g.ty-b.ty||g.tx-b.tx||g.sourceIndex-b.sourceIndex).flatMap(g=>g.items)}function Hi(e){let{doc:n,wrapper:t,polygons:o,directionalLight:i,ambientLight:r}=e,s=ul(o);if(s.length===0)return null;let c=new Set(s.map(P=>P.face));t.classList.add("polycss-voxel-mesh");let l=yl(n);l!==Di&&t.style.setProperty("--polycss-voxel-primitive",`${l}px`);let d=new Map,p=(P,L)=>{let u=`${P}|${L}`,m=d.get(u);if(m)return m;let A=cl(Ii[P],L,i,r);return d.set(u,A),A},y=new Map,g=new Map,b=new Map,x=new Map;for(let P of s){let L=x.get(P.face);L||(L=[],x.set(P.face,L)),L.push(P)}let v="",h=0,C=new Set,R=P=>{let L=y.get(P.sourceIndex);return L||(L=n.createElement("b"),y.set(P.sourceIndex,L),Ka(L,p(P.face,P.baseColor),gl(P,l))),L},I=P=>{let L=g.get(P);return L||(L=n.createElement("span"),L.className=`polycss-voxel-face polycss-voxel-face-${P}`,L.dataset.polycssVoxelFace=P,L.__polycssVoxelFaceHost=!0,g.set(P,L)),L},z=()=>{for(let P of Array.from(t.childNodes))if(!P.__polycssVoxelFaceHost)return P;return null},D=(P,L)=>{let u=L.map(k=>k.sourceIndex).join(",");if(b.get(P)===u)return;let m=I(P),A=n.createDocumentFragment();for(let k of L)A.appendChild(R(k));m.replaceChildren(A),b.set(P,u)},q=()=>{for(let P of _r)c.has(P)&&D(P,x.get(P)??[])},Z=P=>new Set(P.split("|").filter(Boolean)),M=P=>{let L=Z(P);return _r.filter(u=>L.has(u)&&c.has(u))},V=P=>{let L=0;for(let u of P)L+=x.get(u)?.length??0;return L},B=P=>{let L=new Set,u=[],m=new Map;for(let A of P){L.has(A.face)||(L.add(A.face),u.push(A.face));let k=m.get(A.face);k||(k=[],m.set(A.face,k)),k.push(A)}return{orderedFaces:u,itemsByFace:m}},F=(P,L)=>{let u=new Set(P);for(let m of C){if(u.has(m))continue;let A=g.get(m);A?.parentNode===t&&t.removeChild(A)}if(L){let m=n.createDocumentFragment();for(let A of P)m.appendChild(I(A));t.insertBefore(m,z()),C=u;return}for(let m=0;m<P.length;m+=1){let A=P[m],k=I(A);if(k.parentNode===t)continue;let N=null;for(let X=m+1;X<P.length;X+=1){let w=g.get(P[X]);if(w?.parentNode===t){N=w;break}}t.insertBefore(k,N??z())}C=u},ae=(P,L,u)=>{if(!u){let X=M(P);F(X,!1),h=V(X);return}let m=new Set(P.split("|").filter(Boolean)),A=Pl(s,m,L),{orderedFaces:k,itemsByFace:N}=B(A);for(let X of k)D(X,N.get(X)??[]);F(k,!0),h=A.length};return q(),{get brushCount(){return h},render(P){v=Li(P),ae(v,P,!0)},syncCamera(P){let L=Li(P);L!==v&&(v=L,ae(L,P,!1))},dispose(){for(let P of g.values())P.remove();t.classList.remove("polycss-voxel-mesh"),t.style.removeProperty("--polycss-voxel-primitive"),y.clear(),g.clear(),b.clear(),h=0,C=new Set,v=""}}}var Fi="polycss-styles";function so(e){let n=e??(typeof document<"u"?document:void 0);if(!n||n.getElementById(Fi))return;let t=n.createElement("style");t.id=Fi,t.textContent=vl,n.head.appendChild(t)}var vl=`
|
|
2
|
+
/* \u2500\u2500 Scene container \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
3
|
+
|
|
4
|
+
.polycss-scene,
|
|
5
|
+
.polycss-scene *,
|
|
6
|
+
.polycss-scene *::before,
|
|
7
|
+
.polycss-scene *::after {
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* Camera wrapper (mounted by createPolyCamera / PolyPerspectiveCamera /
|
|
12
|
+
PolyOrthographicCamera). Fills its parent so the scene inside has a
|
|
13
|
+
positioned, sized layout context for its top: 50% / left: 50% pin to
|
|
14
|
+
resolve against. Inline styles win on specificity if the user sizes
|
|
15
|
+
the camera explicitly. */
|
|
16
|
+
.polycss-camera {
|
|
17
|
+
position: relative;
|
|
18
|
+
display: block;
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: 100%;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.polycss-scene {
|
|
24
|
+
position: absolute;
|
|
25
|
+
top: 50%;
|
|
26
|
+
left: 50%;
|
|
27
|
+
width: 0;
|
|
28
|
+
height: 0;
|
|
29
|
+
transform-style: preserve-3d;
|
|
30
|
+
/* Pin the scene as a composited layer. Without this, mobile Chrome
|
|
31
|
+
re-rasterizes every descendant tile when the scene transform changes
|
|
32
|
+
each animation frame, which overruns the raster budget on textured
|
|
33
|
+
meshes (faces drop, fragments float). With will-change, the GPU
|
|
34
|
+
reuses the cached layer pixels and only re-composites. */
|
|
35
|
+
will-change: transform;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* \u2500\u2500 First-person controls perspective context \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
39
|
+
|
|
40
|
+
/* PolyFirstPersonControls toggles this class on the camera wrapper
|
|
41
|
+
(scene.cameraEl in vanilla; the camera wrapper div in react/vue). FPV needs a real perspective
|
|
42
|
+
context so scene Z translation produces visible depth motion - without
|
|
43
|
+
it, walking forward looks like a planar pan. The class wins over inline
|
|
44
|
+
perspective styles (e.g. PolyOrthographicCamera's perspective: none)
|
|
45
|
+
via !important. The actual perspective value is set inline by the
|
|
46
|
+
controls as the --polycss-fpv-perspective custom property; the default
|
|
47
|
+
of 2000px matches the controls' lookOffset fallback so the FPV math and
|
|
48
|
+
visual perspective stay in sync. */
|
|
49
|
+
.polycss-fpv-host {
|
|
50
|
+
perspective: var(--polycss-fpv-perspective, 2000px) !important;
|
|
51
|
+
transform-style: preserve-3d !important;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* \u2500\u2500 Shadow root wrapper \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
55
|
+
|
|
56
|
+
/* Single 0\xD70 preserve-3d container that owns every shadow SVG (ground +
|
|
57
|
+
per-face receiver). Children composite via their own absolute matrix3d
|
|
58
|
+
transforms exactly as if mounted on .polycss-scene directly. The wrapper
|
|
59
|
+
exists so the DOM has one obvious "shadows live here" node and so
|
|
60
|
+
future toggles (clip-region, hide-all-shadows) flip a single ancestor. */
|
|
61
|
+
.polycss-shadows {
|
|
62
|
+
position: absolute;
|
|
63
|
+
top: 0;
|
|
64
|
+
left: 0;
|
|
65
|
+
width: 0;
|
|
66
|
+
height: 0;
|
|
67
|
+
transform-style: preserve-3d;
|
|
68
|
+
pointer-events: none;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* \u2500\u2500 Mesh wrapper \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
72
|
+
|
|
73
|
+
.polycss-mesh {
|
|
74
|
+
position: absolute;
|
|
75
|
+
transform-style: preserve-3d;
|
|
76
|
+
/* Pivot at wrapper local (0,0,0) for three.js mesh.position/rotation/scale
|
|
77
|
+
parity. Geometry is positioned by the parser (bbox-min-at-origin by
|
|
78
|
+
default, or pre-centered via parseGltf/parseObj { center: true }). */
|
|
79
|
+
transform-origin: 0 0 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* \u2500\u2500 Polygon leaf element \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
83
|
+
|
|
84
|
+
.polycss-scene b,
|
|
85
|
+
.polycss-scene i,
|
|
86
|
+
.polycss-scene s,
|
|
87
|
+
.polycss-scene u {
|
|
88
|
+
position: absolute;
|
|
89
|
+
display: block;
|
|
90
|
+
transform-origin: 0 0;
|
|
91
|
+
transform-style: preserve-3d;
|
|
92
|
+
margin: 0;
|
|
93
|
+
padding: 0;
|
|
94
|
+
font: inherit;
|
|
95
|
+
font-weight: normal;
|
|
96
|
+
font-style: normal;
|
|
97
|
+
line-height: 0;
|
|
98
|
+
text-decoration: none;
|
|
99
|
+
backface-visibility: hidden;
|
|
100
|
+
background-repeat: no-repeat;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.polycss-scene b,
|
|
104
|
+
.polycss-scene i,
|
|
105
|
+
.polycss-scene u {
|
|
106
|
+
color: var(--polycss-paint, currentColor);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.polycss-scene b {
|
|
110
|
+
background: currentColor;
|
|
111
|
+
width: 64px;
|
|
112
|
+
height: 64px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.polycss-mesh.polycss-voxel-mesh > .polycss-voxel-face {
|
|
116
|
+
position: absolute;
|
|
117
|
+
display: block;
|
|
118
|
+
top: 0;
|
|
119
|
+
left: 0;
|
|
120
|
+
width: 0;
|
|
121
|
+
height: 0;
|
|
122
|
+
transform-style: preserve-3d;
|
|
123
|
+
transform-origin: 0 0;
|
|
124
|
+
margin: 0;
|
|
125
|
+
padding: 0;
|
|
126
|
+
font: inherit;
|
|
127
|
+
line-height: 0;
|
|
128
|
+
pointer-events: none;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.polycss-mesh.polycss-voxel-mesh > .polycss-voxel-face > b {
|
|
132
|
+
top: 0;
|
|
133
|
+
left: 0;
|
|
134
|
+
width: var(--polycss-voxel-primitive, 1px);
|
|
135
|
+
height: var(--polycss-voxel-primitive, 1px);
|
|
136
|
+
backface-visibility: visible;
|
|
137
|
+
pointer-events: none;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.polycss-scene i {
|
|
141
|
+
width: 16px;
|
|
142
|
+
height: 16px;
|
|
143
|
+
border-color: currentColor;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.polycss-scene s {
|
|
147
|
+
width: var(--polycss-atlas-width, var(--polycss-atlas-size, 64px));
|
|
148
|
+
height: var(--polycss-atlas-height, var(--polycss-atlas-size, 64px));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.polycss-scene u {
|
|
152
|
+
width: 0;
|
|
153
|
+
height: 0;
|
|
154
|
+
background: transparent;
|
|
155
|
+
box-sizing: content-box;
|
|
156
|
+
border: 0 solid transparent;
|
|
157
|
+
border-color: transparent transparent currentColor transparent;
|
|
158
|
+
border-width: 0 16px 32px 16px;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@supports (corner-top-left-shape: bevel) and (corner-top-right-shape: bevel) {
|
|
162
|
+
.polycss-scene > u,
|
|
163
|
+
.polycss-mesh > u,
|
|
164
|
+
.polycss-bucket > u {
|
|
165
|
+
border-width: 0;
|
|
166
|
+
width: 32px;
|
|
167
|
+
height: 32px;
|
|
168
|
+
background-color: currentColor;
|
|
169
|
+
border-top-left-radius: 50% 100%;
|
|
170
|
+
border-top-right-radius: 50% 100%;
|
|
171
|
+
corner-top-left-shape: bevel;
|
|
172
|
+
corner-top-right-shape: bevel;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.polycss-scene > u.polycss-corner-shape-solid,
|
|
176
|
+
.polycss-mesh > u.polycss-corner-shape-solid,
|
|
177
|
+
.polycss-bucket > u.polycss-corner-shape-solid {
|
|
178
|
+
width: 16px;
|
|
179
|
+
height: 16px;
|
|
180
|
+
box-sizing: border-box;
|
|
181
|
+
border: 0;
|
|
182
|
+
background: currentColor;
|
|
183
|
+
border-radius: 0;
|
|
184
|
+
corner-top-left-shape: initial;
|
|
185
|
+
corner-top-right-shape: initial;
|
|
186
|
+
corner-bottom-right-shape: initial;
|
|
187
|
+
corner-bottom-left-shape: initial;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* Reserved internal <q> shadow element rules. Current shadow emission uses SVG
|
|
192
|
+
surfaces; these rules keep any retained <q> markup styled as a plain
|
|
193
|
+
border-shape leaf instead of inheriting UA quote styling. */
|
|
194
|
+
.polycss-scene q {
|
|
195
|
+
position: absolute;
|
|
196
|
+
display: block;
|
|
197
|
+
transform-origin: 0 0;
|
|
198
|
+
transform-style: preserve-3d;
|
|
199
|
+
margin: 0;
|
|
200
|
+
padding: 0;
|
|
201
|
+
font: inherit;
|
|
202
|
+
font-weight: normal;
|
|
203
|
+
font-style: normal;
|
|
204
|
+
line-height: 0;
|
|
205
|
+
text-decoration: none;
|
|
206
|
+
backface-visibility: visible;
|
|
207
|
+
border-color: currentColor;
|
|
208
|
+
pointer-events: none;
|
|
209
|
+
will-change: transform;
|
|
210
|
+
}
|
|
211
|
+
.polycss-scene q::before,
|
|
212
|
+
.polycss-scene q::after {
|
|
213
|
+
content: none;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/* \u2500\u2500 Gizmo override (createTransformControls) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
217
|
+
|
|
218
|
+
/*
|
|
219
|
+
* Translate arrows + rotate rings render through the same polygon
|
|
220
|
+
* pipeline as user content but the gizmo is a UI affordance \u2014 both
|
|
221
|
+
* faces of every polygon should remain visible regardless of camera
|
|
222
|
+
* orientation, otherwise the cuboid shafts and pyramid heads end up
|
|
223
|
+
* half-culled. Transitions on color, border-color, and background-color
|
|
224
|
+
* smooth the idle / hover / drag alpha changes.
|
|
225
|
+
*/
|
|
226
|
+
.polycss-mesh.polycss-transform-gizmo i,
|
|
227
|
+
.polycss-mesh.polycss-transform-gizmo b,
|
|
228
|
+
.polycss-mesh.polycss-transform-gizmo s,
|
|
229
|
+
.polycss-mesh.polycss-transform-gizmo u {
|
|
230
|
+
backface-visibility: visible;
|
|
231
|
+
transition: color 150ms ease-out, border-color 150ms ease-out, background-color 150ms ease-out;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/*
|
|
235
|
+
* Rotate rings are rendered as a single square quad per ring, then masked
|
|
236
|
+
* to a donut via a radial-gradient. The --ring-inner-ratio CSS var is set
|
|
237
|
+
* inline by createTransformControls (= innerR / outerR, where outerR maps
|
|
238
|
+
* to the quad's edge at 50%). Hit-testing has to use the donut shape too.
|
|
239
|
+
* Single DOM node per ring instead of N segment quads.
|
|
240
|
+
*/
|
|
241
|
+
.polycss-mesh.polycss-transform-ring i,
|
|
242
|
+
.polycss-mesh.polycss-transform-ring b,
|
|
243
|
+
.polycss-mesh.polycss-transform-ring s,
|
|
244
|
+
.polycss-mesh.polycss-transform-ring u {
|
|
245
|
+
--ring-inner-r: calc(var(--ring-inner-ratio, 0.92) * 50%);
|
|
246
|
+
--ring-outer-r: calc(var(--ring-outer-ratio, 1) * 50%);
|
|
247
|
+
-webkit-mask: radial-gradient(circle at 50% 50%,
|
|
248
|
+
transparent 0%,
|
|
249
|
+
transparent var(--ring-inner-r),
|
|
250
|
+
black var(--ring-inner-r),
|
|
251
|
+
black var(--ring-outer-r),
|
|
252
|
+
transparent var(--ring-outer-r));
|
|
253
|
+
mask: radial-gradient(circle at 50% 50%,
|
|
254
|
+
transparent 0%,
|
|
255
|
+
transparent var(--ring-inner-r),
|
|
256
|
+
black var(--ring-inner-r),
|
|
257
|
+
black var(--ring-outer-r),
|
|
258
|
+
transparent var(--ring-outer-r));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/* \u2500\u2500 Dynamic lighting cascade vars (scene root \u2192 polygons) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
262
|
+
|
|
263
|
+
/*
|
|
264
|
+
* Dynamic mode: the scene root carries the directional + ambient light
|
|
265
|
+
* setup as custom properties. Each polygon leaf bakes its own normal
|
|
266
|
+
* directly into an inline calc() that reads these vars to resolve the
|
|
267
|
+
* Lambert dot product and per-channel tint. Sliding the light only
|
|
268
|
+
* writes these scene-root vars \u2014 no JS, no atlas redraw.
|
|
269
|
+
*
|
|
270
|
+
* Registering with @property forces the browser to parse the values as
|
|
271
|
+
* <number>s instead of opaque token streams; that makes the polygon-level
|
|
272
|
+
* calc() expressions resolve reliably across engines.
|
|
273
|
+
*/
|
|
274
|
+
|
|
275
|
+
@property --plx { syntax: "<number>"; inherits: true; initial-value: 0; }
|
|
276
|
+
@property --ply { syntax: "<number>"; inherits: true; initial-value: 0; }
|
|
277
|
+
@property --plz { syntax: "<number>"; inherits: true; initial-value: 1; }
|
|
278
|
+
|
|
279
|
+
/* CSS-space light components (world-Y\u2192cssX, world-X\u2192cssY, world-Z\u2192cssZ).
|
|
280
|
+
Used by the shadow projection matrix. --clx is clamped away from 0 in JS
|
|
281
|
+
to avoid divide-by-zero when the light is near-horizontal. */
|
|
282
|
+
@property --clx { syntax: "<number>"; inherits: true; initial-value: 0.01; }
|
|
283
|
+
@property --cly { syntax: "<number>"; inherits: true; initial-value: 0; }
|
|
284
|
+
@property --clz { syntax: "<number>"; inherits: true; initial-value: 1; }
|
|
285
|
+
|
|
286
|
+
/* Ground-plane position in CSS pixels along the CSS-Z axis (= world-Z, the
|
|
287
|
+
up axis in PolyCSS's world convention). Stored as a <number> so it can be
|
|
288
|
+
used directly inside matrix3d() calc() expressions (matrix3d requires
|
|
289
|
+
dimensionless entries \u2014 no px units).
|
|
290
|
+
Set by recomputeShadowGround() from the min world-Z of casting meshes. */
|
|
291
|
+
@property --shadow-ground-cssz { syntax: "<number>"; inherits: true; initial-value: 0; }
|
|
292
|
+
@property --plr { syntax: "<number>"; inherits: true; initial-value: 1; }
|
|
293
|
+
@property --plg { syntax: "<number>"; inherits: true; initial-value: 1; }
|
|
294
|
+
@property --plb { syntax: "<number>"; inherits: true; initial-value: 1; }
|
|
295
|
+
@property --pli { syntax: "<number>"; inherits: true; initial-value: 1; }
|
|
296
|
+
@property --par { syntax: "<number>"; inherits: true; initial-value: 1; }
|
|
297
|
+
@property --pag { syntax: "<number>"; inherits: true; initial-value: 1; }
|
|
298
|
+
@property --pab { syntax: "<number>"; inherits: true; initial-value: 1; }
|
|
299
|
+
@property --pai { syntax: "<number>"; inherits: true; initial-value: 0.4; }
|
|
300
|
+
|
|
301
|
+
/* Per-polygon surface normal \u2014 set inline by the renderer per leaf, OR by
|
|
302
|
+
a .polycss-bucket wrapper that groups axis-aligned polys sharing the
|
|
303
|
+
same face direction. inherits:true so polys inside a bucket pick up
|
|
304
|
+
the wrapper's normal automatically; polys outside any bucket still
|
|
305
|
+
override it inline. */
|
|
306
|
+
@property --pnx { syntax: "<number>"; inherits: true; initial-value: 0; }
|
|
307
|
+
@property --pny { syntax: "<number>"; inherits: true; initial-value: 0; }
|
|
308
|
+
@property --pnz { syntax: "<number>"; inherits: true; initial-value: 1; }
|
|
309
|
+
@property --psr { syntax: "<number>"; inherits: true; initial-value: 1; }
|
|
310
|
+
@property --psg { syntax: "<number>"; inherits: true; initial-value: 1; }
|
|
311
|
+
@property --psb { syntax: "<number>"; inherits: true; initial-value: 1; }
|
|
312
|
+
|
|
313
|
+
/* Hoisted Lambert dot product \u2014 computed once per element it's set on.
|
|
314
|
+
inherits:true so a bucket wrapper computes lambert ONCE for its whole
|
|
315
|
+
group (one calc per bucket, not per polygon). Solo polys still set it
|
|
316
|
+
themselves via the per-poly rule below. */
|
|
317
|
+
@property --plam { syntax: "<number>"; inherits: true; initial-value: 0; }
|
|
318
|
+
|
|
319
|
+
/* Calc-driven Lambert + tint, scoped to dynamic-lighting scenes. Lives
|
|
320
|
+
here (not inline per polygon) so each leaf only carries its tiny normal
|
|
321
|
+
declarations \u2014 ~12\xD7 smaller per-polygon style payload on big meshes.
|
|
322
|
+
--plam is computed once and reused 3\xD7 (one per channel),
|
|
323
|
+
cutting the dot-product calc count from 3 \u2192 1 per polygon per frame. */
|
|
324
|
+
/* Lambert-bucket wrapper: createPolyScene groups axis-aligned polys
|
|
325
|
+
sharing one face direction inside a .polycss-bucket div with the
|
|
326
|
+
bucket's normal as inline CSS vars. Lambert is computed ONCE per
|
|
327
|
+
bucket (inherits:true on --plam propagates the value to
|
|
328
|
+
every leaf child). For voxel meshes this collapses thousands of
|
|
329
|
+
per-frame dot products into a few dozen. */
|
|
330
|
+
.polycss-bucket {
|
|
331
|
+
position: absolute;
|
|
332
|
+
transform-style: preserve-3d;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/* Per-bucket lambert calc \u2014 runs once per bucket per frame. */
|
|
336
|
+
.polycss-scene[data-polycss-lighting="dynamic"] .polycss-bucket {
|
|
337
|
+
--plam: max(0, calc(
|
|
338
|
+
var(--pnx) * var(--plx) +
|
|
339
|
+
var(--pny) * var(--ply) +
|
|
340
|
+
var(--pnz) * var(--plz)
|
|
341
|
+
));
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/* Per-poly lambert calc \u2014 applies to any leaf whose direct parent is NOT
|
|
345
|
+
a .polycss-bucket. Covers:
|
|
346
|
+
- vanilla createPolyScene polys not inside a bucket (e.g. off-axis
|
|
347
|
+
curved polys that didn't make a bucket group)
|
|
348
|
+
- React <PolyScene polygons> path (leaves are direct children of
|
|
349
|
+
.polycss-scene; no <PolyMesh> wrapper)
|
|
350
|
+
- React <PolyScene><PolyMesh polygons></PolyMesh> path (leaves are
|
|
351
|
+
direct children of .polycss-mesh)
|
|
352
|
+
Bucketed leaves are skipped \u2014 their parent IS .polycss-bucket so they
|
|
353
|
+
inherit the bucket's hoisted lambert (one calc per bucket, not per
|
|
354
|
+
leaf). */
|
|
355
|
+
.polycss-scene[data-polycss-lighting="dynamic"] :not(.polycss-bucket) > i,
|
|
356
|
+
.polycss-scene[data-polycss-lighting="dynamic"] :not(.polycss-bucket) > b,
|
|
357
|
+
.polycss-scene[data-polycss-lighting="dynamic"] :not(.polycss-bucket) > s,
|
|
358
|
+
.polycss-scene[data-polycss-lighting="dynamic"] :not(.polycss-bucket) > u {
|
|
359
|
+
--plam: max(0, calc(
|
|
360
|
+
var(--pnx) * var(--plx) +
|
|
361
|
+
var(--pny) * var(--ply) +
|
|
362
|
+
var(--pnz) * var(--plz)
|
|
363
|
+
));
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/* Atlas polys: containment + background-color from lambert (inherited or
|
|
367
|
+
own) and the scene-level light vars. Splitting this from the lambert
|
|
368
|
+
calc above lets bucketed polys skip the dot-product entirely. */
|
|
369
|
+
.polycss-scene[data-polycss-lighting="dynamic"] s {
|
|
370
|
+
/* Isolate each leaf's layout/style/paint walks from siblings. Works
|
|
371
|
+
because the leaf transform-style:preserve-3d was dropped above \u2014
|
|
372
|
+
the 3D context lives on .polycss-scene / .polycss-mesh, not the
|
|
373
|
+
leaves, so there's nothing inside a leaf that needs to participate
|
|
374
|
+
in 3D compositing across the contain boundary. */
|
|
375
|
+
contain: strict;
|
|
376
|
+
/*
|
|
377
|
+
* Three.js MeshLambertMaterial parity for textured surfaces:
|
|
378
|
+
*
|
|
379
|
+
* target = sRGB_encode(albedo_linear \xD7 irradiance_linear / \u03C0)
|
|
380
|
+
*
|
|
381
|
+
* background-blend-mode: multiply produces (bitmap \xD7 tint) in sRGB
|
|
382
|
+
* \u2014 approximately sRGB(albedo_linear \xD7 tint_linear) when bitmap \u2248
|
|
383
|
+
* sRGB(albedo_linear). So we want tint = sRGB_encode(irradiance /\u03C0).
|
|
384
|
+
*
|
|
385
|
+
* Each light/ambient colour channel is sRGB-to-linearised
|
|
386
|
+
* via pow((c + 0.055) / 1.055, 2.4) before the dot product so the
|
|
387
|
+
* irradiance accumulates in linear space; final encode is
|
|
388
|
+
* 1.055 \xD7 pow(c, 1/2.4) - 0.055. min(1, \u2026) clamps inside the encode
|
|
389
|
+
* domain. Matches the solid <b>/<i>/<u> pipeline below.
|
|
390
|
+
*/
|
|
391
|
+
background-color: rgb(
|
|
392
|
+
calc(255 * max(0, 1.055 * pow(min(1, (
|
|
393
|
+
pow((var(--par) + 0.055) / 1.055, 2.4) * var(--pai) +
|
|
394
|
+
pow((var(--plr) + 0.055) / 1.055, 2.4) * var(--pli) * var(--plam)
|
|
395
|
+
) / 3.14159265), 0.4167) - 0.055))
|
|
396
|
+
calc(255 * max(0, 1.055 * pow(min(1, (
|
|
397
|
+
pow((var(--pag) + 0.055) / 1.055, 2.4) * var(--pai) +
|
|
398
|
+
pow((var(--plg) + 0.055) / 1.055, 2.4) * var(--pli) * var(--plam)
|
|
399
|
+
) / 3.14159265), 0.4167) - 0.055))
|
|
400
|
+
calc(255 * max(0, 1.055 * pow(min(1, (
|
|
401
|
+
pow((var(--pab) + 0.055) / 1.055, 2.4) * var(--pai) +
|
|
402
|
+
pow((var(--plb) + 0.055) / 1.055, 2.4) * var(--pli) * var(--plam)
|
|
403
|
+
) / 3.14159265), 0.4167) - 0.055))
|
|
404
|
+
);
|
|
405
|
+
background-blend-mode: multiply;
|
|
406
|
+
background-image: var(--polycss-atlas-url);
|
|
407
|
+
background-position: var(--polycss-atlas-position);
|
|
408
|
+
background-repeat: no-repeat;
|
|
409
|
+
background-size: var(--polycss-atlas-image-size);
|
|
410
|
+
mask-image: var(--polycss-atlas-url);
|
|
411
|
+
mask-mode: alpha;
|
|
412
|
+
mask-position: var(--polycss-atlas-position);
|
|
413
|
+
mask-repeat: no-repeat;
|
|
414
|
+
mask-size: var(--polycss-atlas-image-size);
|
|
415
|
+
-webkit-mask-image: var(--polycss-atlas-url);
|
|
416
|
+
-webkit-mask-position: var(--polycss-atlas-position);
|
|
417
|
+
-webkit-mask-repeat: no-repeat;
|
|
418
|
+
-webkit-mask-size: var(--polycss-atlas-image-size);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
.polycss-scene[data-polycss-lighting="dynamic"] b,
|
|
422
|
+
.polycss-scene[data-polycss-lighting="dynamic"] i,
|
|
423
|
+
.polycss-scene[data-polycss-lighting="dynamic"] u {
|
|
424
|
+
/*
|
|
425
|
+
* Three.js MeshLambertMaterial parity (default useLegacyLights=false,
|
|
426
|
+
* physically-correct pipeline):
|
|
427
|
+
*
|
|
428
|
+
* lit_linear = albedo_linear \xD7 (lightColor_linear \xD7 intensity \xD7 lambert
|
|
429
|
+
* + ambient_linear \xD7 ambientIntensity) / \u03C0
|
|
430
|
+
* output = 255 \xD7 sRGB_encode(min(1, lit_linear))
|
|
431
|
+
*
|
|
432
|
+
* sRGB\u2192linear: pow((c + 0.055) / 1.055, 2.4) for c > 0.04045
|
|
433
|
+
* 12.92 \xD7 c otherwise (skipped \u2014 tiny)
|
|
434
|
+
* linear\u2192sRGB: 1.055 \xD7 pow(c, 1/2.4) - 0.055 for c > 0.0031308
|
|
435
|
+
* 12.92 \xD7 c otherwise (skipped \u2014 tiny)
|
|
436
|
+
*
|
|
437
|
+
* The naive pow(c, 2.4) shortcut undershoots by ~2x for small c
|
|
438
|
+
* (dark channels of a saturated colour) \u2014 the +0.055/1.055 offset
|
|
439
|
+
* is load-bearing for the G/B drift on saturated fixtures.
|
|
440
|
+
*
|
|
441
|
+
* Verified against per-pixel screenshots in bench/three-parity.html
|
|
442
|
+
* (cube #dc2626 top face): drift <3 per channel across i=0.5..3,
|
|
443
|
+
* ambient=0..0.3, lambert=0..1.
|
|
444
|
+
*/
|
|
445
|
+
color: rgb(
|
|
446
|
+
calc(255 * max(0, 1.055 * pow(min(1,
|
|
447
|
+
pow((var(--psr) + 0.055) / 1.055, 2.4) * (
|
|
448
|
+
pow((var(--par) + 0.055) / 1.055, 2.4) * var(--pai) +
|
|
449
|
+
pow((var(--plr) + 0.055) / 1.055, 2.4) * var(--pli) * var(--plam)
|
|
450
|
+
) / 3.14159265
|
|
451
|
+
), 0.4167) - 0.055))
|
|
452
|
+
calc(255 * max(0, 1.055 * pow(min(1,
|
|
453
|
+
pow((var(--psg) + 0.055) / 1.055, 2.4) * (
|
|
454
|
+
pow((var(--pag) + 0.055) / 1.055, 2.4) * var(--pai) +
|
|
455
|
+
pow((var(--plg) + 0.055) / 1.055, 2.4) * var(--pli) * var(--plam)
|
|
456
|
+
) / 3.14159265
|
|
457
|
+
), 0.4167) - 0.055))
|
|
458
|
+
calc(255 * max(0, 1.055 * pow(min(1,
|
|
459
|
+
pow((var(--psb) + 0.055) / 1.055, 2.4) * (
|
|
460
|
+
pow((var(--pab) + 0.055) / 1.055, 2.4) * var(--pai) +
|
|
461
|
+
pow((var(--plb) + 0.055) / 1.055, 2.4) * var(--pli) * var(--plam)
|
|
462
|
+
) / 3.14159265
|
|
463
|
+
), 0.4167) - 0.055))
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/* \u2500\u2500 Retained <q> shadow projection (dynamic-mode CSS path) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
468
|
+
|
|
469
|
+
/*
|
|
470
|
+
* Projection matrix for retained internal <q> shadow leaves. Projects any
|
|
471
|
+
* 3D point P onto the horizontal ground plane (cssZ \u2248 G) along the CSS-space
|
|
472
|
+
* light direction (--clx/y/z).
|
|
473
|
+
*
|
|
474
|
+
* In PolyCSS's world convention world Z is up (red-green plane is the
|
|
475
|
+
* floor in the axes helper). After the world\u2192CSS swap (Y\u2194X), world Z stays
|
|
476
|
+
* as CSS Z, so the ground plane normal in CSS space is +cssZ.
|
|
477
|
+
*
|
|
478
|
+
* The strict projection formula would set m22=0 (output.z is a constant G,
|
|
479
|
+
* the polygon is exactly flat). But Chromium SKIPS rendering elements
|
|
480
|
+
* whose composed transform matrix is non-invertible (singular). m22=0
|
|
481
|
+
* makes the matrix singular, so the shadow paints nothing even though it
|
|
482
|
+
* has a valid layout box. The fix: collapse along z by a near-zero
|
|
483
|
+
* scale (Z_SQUASH = 0.01) instead of exactly zero \u2014 output.z is then
|
|
484
|
+
* approximately G with ~1% drift from the input, full-rank and renderable.
|
|
485
|
+
* The result still looks flat to the eye (the drift is sub-pixel for
|
|
486
|
+
* any realistic scene size).
|
|
487
|
+
*
|
|
488
|
+
* out.cssX = P.cssX - (--clx/--clz) * (P.cssZ - G)
|
|
489
|
+
* out.cssY = P.cssY - (--cly/--clz) * (P.cssZ - G)
|
|
490
|
+
* out.cssZ = Z_SQUASH * P.cssZ + (1 - Z_SQUASH) * G
|
|
491
|
+
*
|
|
492
|
+
* As column-major 4\xD74 (CSS matrix3d order):
|
|
493
|
+
* col1: [1, 0, 0, 0]
|
|
494
|
+
* col2: [0, 1, 0, 0]
|
|
495
|
+
* col3: [-(--clx/--clz), -(--cly/--clz), Z_SQUASH, 0]
|
|
496
|
+
* col4: [G*(--clx/--clz), G*(--cly/--clz), G*(1-Z_SQUASH), 1]
|
|
497
|
+
*/
|
|
498
|
+
.polycss-scene[data-polycss-lighting="dynamic"] {
|
|
499
|
+
--shadow-proj: matrix3d(
|
|
500
|
+
1, 0, 0, 0,
|
|
501
|
+
0, 1, 0, 0,
|
|
502
|
+
calc(-1 * var(--clx) / var(--clz)),
|
|
503
|
+
calc(-1 * var(--cly) / var(--clz)),
|
|
504
|
+
0.01,
|
|
505
|
+
0,
|
|
506
|
+
calc(var(--shadow-ground-cssz) * var(--clx) / var(--clz)),
|
|
507
|
+
calc(var(--shadow-ground-cssz) * var(--cly) / var(--clz)),
|
|
508
|
+
calc(var(--shadow-ground-cssz) * 0.99),
|
|
509
|
+
1
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/* Retained <q> opacity gate. Polygons facing the light cast full shadow;
|
|
514
|
+
polygons facing away cast zero shadow. The * 10 multiplier sharpens the
|
|
515
|
+
cutoff so small positive Lambert values jump quickly to 1. */
|
|
516
|
+
.polycss-scene[data-polycss-lighting="dynamic"] q {
|
|
517
|
+
opacity: clamp(0, calc((var(--pnx) * var(--clx) + var(--pny) * var(--cly) + var(--pnz) * var(--clz)) * 10), 1);
|
|
518
|
+
}
|
|
519
|
+
`;var ot=require("@layoutit/polycss-core");var Fn=ot.BASE_TILE,Sl=.1;function zi(e){return(0,ot.worldPositionToCss)(e)}function zn(e){return(0,ot.worldDirectionToCss)(e)}function It(e){return(0,ot.worldDirectionalLightToCss)(e)}function ao(e){return(0,ot.buildPolyMeshTransform)(e)}function Or(e,n=[0,0,0],t=1){return(0,ot.buildPolyCameraSceneTransform)(e.state,{autoCenterOffset:n,layoutScale:t})}function Cl(e){let n=e.trim();if(!n||n==="normal")return 1;let t=n.endsWith("%")?Number(n.slice(0,-1))/100:Number(n);return Number.isFinite(t)&&t>0?t:1}function Bi(e){let n=e.ownerDocument?.defaultView;if(!n)return 1;let t=1;for(let o=e;o;o=o.parentElement)t*=Cl(n.getComputedStyle(o).getPropertyValue("zoom"));return Number.isFinite(t)&&t>0?t:1}function Vi(e,n){Math.abs(n-1)<1e-6?e.style.removeProperty("zoom"):e.style.setProperty("zoom",String(1/n))}function Ni(e){if(e.vertices.length<3)return null;let n=e.vertices[0],t=0,o=0,i=0;for(let y=1;y+1<e.vertices.length;y++){let g=e.vertices[y],b=e.vertices[y+1],x=g[1]-n[1],v=g[0]-n[0],h=g[2]-n[2],C=b[1]-n[1],R=b[0]-n[0],I=b[2]-n[2];t-=v*I-h*R,o-=h*C-x*I,i-=x*R-v*C}let r=Math.hypot(t,o,i);if(r<1e-9)return null;t/=r,o/=r,i/=r;let s=1/Sl,c=Math.round(t*s)/s,l=Math.round(o*s)/s,d=Math.round(i*s)/s,p=Math.hypot(c,l,d);return p<1e-9?null:{key:c+","+l+","+d,vec:[c/p,l/p,d/p]}}function ji(e,n){let t=e?.disable??[],o=n?.disable??[];if(t.length!==o.length)return!1;for(let i of t)if(!o.includes(i))return!1;return!0}function $i(e,n){return e===n?!0:!e||!n?!1:e[0]===n[0]&&e[1]===n[1]&&e[2]===n[2]}function Wi(e,n){return e===n?!0:(e?.color??"#000000")===(n?.color??"#000000")&&(e?.opacity??.25)===(n?.opacity??.25)&&(e?.lift??.05)===(n?.lift??.05)&&(e?.maxExtend??2e3)===(n?.maxExtend??2e3)&&(e?.parametric??!1)===(n?.parametric??!1)&&(e?.definition??16)===(n?.definition??16)&&(e?.dragDefinition??-1)===(n?.dragDefinition??-1)&&(e?.style??"vector")===(n?.style??"vector")&&(e?.followAnimation??!1)===(n?.followAnimation??!1)}var Ht=require("@layoutit/polycss-core");var Tl=["--plx","--ply","--plz","--plr","--plg","--plb","--pli","--par","--pag","--pab","--pai","--clx","--cly","--clz"],pn="--polycss-light-preview-active",Ui=`var(${pn}, 0)`,El="max(0, calc(var(--pnx, 0) * var(--plx, 0) + var(--pny, 0) * var(--ply, 0) + var(--pnz, 1) * var(--plz, 1)))",Dr=(e,n,t)=>`calc(255 * max(0, 1.055 * pow(min(1, pow((var(${e}, 1) + 0.055) / 1.055, 2.4) * (pow((var(${n}, 1) + 0.055) / 1.055, 2.4) * var(--pai, 0.4) + pow((var(${t}, 1) + 0.055) / 1.055, 2.4) * var(--pli, 1) * var(--plam, 0)) / 3.14159265), 0.4167) - 0.055))`,Al=Dr("--psr","--par","--plr"),wl=Dr("--psg","--pag","--plg"),Ml=Dr("--psb","--pab","--plb");function xe(e,n,t){return e.style.getPropertyValue(n)===t?!1:(e.style.setProperty(n,t),!0)}function Ut(e){for(let n of Tl)e.style.getPropertyValue(n)&&e.style.removeProperty(n)}function lo(e,n){let t=n.directionalLight?.direction??[.4,-.7,.59],o=zn(t),i=Math.hypot(o[0],o[1],o[2])||1,r=o[0]/i,s=o[1]/i,c=o[2]/i,l=(0,Ht.parseHexColor)(n.directionalLight?.color??"#ffffff")?.rgb??[255,255,255],d=(0,Ht.parseHexColor)(n.ambientLight?.color??"#ffffff")?.rgb??[255,255,255],p=n.directionalLight?.intensity??1,y=n.ambientLight?.intensity??.4,g=v=>(v/255).toFixed(4);xe(e,"--plx",r.toFixed(2)),xe(e,"--ply",s.toFixed(2)),xe(e,"--plz",c.toFixed(2)),xe(e,"--plr",g(l[0])),xe(e,"--plg",g(l[1])),xe(e,"--plb",g(l[2])),xe(e,"--pli",p.toFixed(4)),xe(e,"--par",g(d[0])),xe(e,"--pag",g(d[1])),xe(e,"--pab",g(d[2])),xe(e,"--pai",y.toFixed(4));let b=c,x=Math.sign(b||1)*Math.max(Math.abs(b),.01);xe(e,"--clx",r.toFixed(2)),xe(e,"--cly",s.toFixed(2)),xe(e,"--clz",x.toFixed(2))}function Gi(e,n){let t=n.textureLighting==="dynamic";if(e.dataset.polycssLighting=n.textureLighting??"baked",!t){Ut(e);return}lo(e,n)}function Gt(e,n){n.paintColor?e.style.setProperty("--polycss-paint",n.paintColor):e.style.getPropertyValue("--polycss-paint")&&e.style.removeProperty("--polycss-paint"),n.dynamicColor?(e.style.setProperty("--psr",(n.dynamicColor.r/255).toFixed(4)),e.style.setProperty("--psg",(n.dynamicColor.g/255).toFixed(4)),e.style.setProperty("--psb",(n.dynamicColor.b/255).toFixed(4))):(e.style.getPropertyValue("--psr")||e.style.getPropertyValue("--psg")||e.style.getPropertyValue("--psb"))&&(e.style.removeProperty("--psr"),e.style.removeProperty("--psg"),e.style.removeProperty("--psb"))}function Yi(e,n){let t=(0,Ht.parseHex)(n??"#cccccc");e.style.setProperty("--psr",(t.r/255).toFixed(4)),e.style.setProperty("--psg",(t.g/255).toFixed(4)),e.style.setProperty("--psb",(t.b/255).toFixed(4))}function Ir(e,n,t){if(!e.plan||e.kind==="atlas"||e.plan.texture)return!1;let o=t.textureLighting??"baked",i={directionalLight:It(t.directionalLight),ambientLight:t.ambientLight,textureLighting:o,textureQuality:t.textureQuality,seamBleed:t.seamBleed,strategies:t.strategies},r=mr(e.plan,n,e.plan.normal,o,i);return on(e.element,r,o),o==="baked"&&Rl(e.element),!0}function Ll(e){let n=(0,Ht.parsePureColor)(e)??{rgb:[255,255,255],alpha:1},[t,o,i]=n.rgb,r=(c,l)=>`calc(${c} * (1 - ${Ui}) + var(${l}, ${c}) * ${Ui})`,s=n.alpha<1?` / ${n.alpha}`:"";return`rgb(${r(t,"--polycss-preview-r")} ${r(o,"--polycss-preview-g")} ${r(i,"--polycss-preview-b")}${s})`}function Xi(e,n,t){if(!e.plan||e.kind==="atlas"||e.plan.texture)return!1;let o=e.element,i=e.plan.normal,r=(0,Ht.parseHex)(n.color??"#cccccc"),s=!1;return s=xe(o,"--pnx",i[0].toFixed(4))||s,s=xe(o,"--pny",i[1].toFixed(4))||s,s=xe(o,"--pnz",i[2].toFixed(4))||s,s=xe(o,"--psr",(r.r/255).toFixed(4))||s,s=xe(o,"--psg",(r.g/255).toFixed(4))||s,s=xe(o,"--psb",(r.b/255).toFixed(4))||s,s=xe(o,"--plam",El)||s,s=xe(o,"--polycss-preview-r",Al)||s,s=xe(o,"--polycss-preview-g",wl)||s,s=xe(o,"--polycss-preview-b",Ml)||s,s=xe(o,"--polycss-paint",Ll(t))||s,o.style.getPropertyValue("color")&&(o.style.removeProperty("color"),s=!0),s}function Rl(e){e.style.removeProperty("--pnx"),e.style.removeProperty("--pny"),e.style.removeProperty("--pnz"),e.style.removeProperty("--psr"),e.style.removeProperty("--psg"),e.style.removeProperty("--psb"),e.style.removeProperty("--plam"),e.style.removeProperty("--polycss-preview-r"),e.style.removeProperty("--polycss-preview-g"),e.style.removeProperty("--polycss-preview-b"),e.style.removeProperty("--polycss-paint")}var co=class{constructor(){this.groundSvg=null;this.groundVisible=!1;this.currentGroundCssZ=null;this.shadowRoot=null}};function qi(e,n,t){let o=e.shadowRoot;if(o||(o=n.createElement("div"),o.setAttribute("class","polycss-shadows"),o.style.position="absolute",o.style.top="0",o.style.left="0",o.style.width="0",o.style.height="0",o.style.transformStyle="preserve-3d",o.style.pointerEvents="none",e.shadowRoot=o),o.parentNode!==t){let i=t.firstChild;i?t.insertBefore(o,i):t.appendChild(o)}return o}function Zi(e){e.groundSvg?.parentNode&&e.groundSvg.parentNode.removeChild(e.groundSvg),e.groundSvg=null,e.groundVisible=!1}function Qi(e){e.groundSvg&&e.groundVisible&&(e.groundSvg.style.display="none",e.groundVisible=!1)}function Ki(e){return{host:e.host,doc:e.doc,cameraEl:e.cameraEl,sceneEl:e.sceneEl,camera:e.camera,layoutScale:e.layoutScale,options:{current:e.options},meshes:new Set,meshAutoCounter:{next:0},autoCenter:{offset:[0,0,0]},bboxCenterCssCache:{value:null},shadowSvgState:new co,receiverShadowCache:new Map,receiverShadowCacheKey:new Map,casterItemsCache:new Map,casterItemsCacheKey:new Map,shadowDragActive:!1}}var Be=require("@layoutit/polycss-core");function Ji(e){for(let n of e)n.svg&&n.svg.parentNode&&n.svg.parentNode.removeChild(n.svg),n.svg=null}function es(e,n){if(n){let t=e.receiverShadowCache.get(n);t&&Ji(t),e.receiverShadowCache.delete(n),e.receiverShadowCacheKey.delete(n)}else{for(let t of e.receiverShadowCache.values())Ji(t);e.receiverShadowCache.clear(),e.receiverShadowCacheKey.clear()}}function ts(e,n){n?(e.casterItemsCache.delete(n),e.casterItemsCacheKey.delete(n)):(e.casterItemsCache.clear(),e.casterItemsCacheKey.clear())}function ns(e){Zi(e.shadowSvgState),rs(e)}function os(e){return e.handle.id??e.autoMeshId}var us="http://www.w3.org/2000/svg",uo=new WeakMap,is=new WeakMap,ss=new WeakMap,as=new WeakMap,ls=new WeakMap;function kl(e){let n=uo.get(e);return n||(n=new Map,uo.set(e,n)),n}function _l(e,n){let t=kl(e),o=t.get(n);return o||(o=new Map,t.set(n,o)),o}function ds(e){let n=uo.get(e);if(n){for(let t of n.values()){for(let o of t.values())o.svg&&o.svg.parentNode&&o.svg.parentNode.removeChild(o.svg);t.clear()}n.clear()}}function Hr(e){ds(e),uo.delete(e)}function rs(e){for(let n of e.meshes)Hr(n)}function ps(e,n,t,o,i,r,s,c,l,d,p){let y=e.options.current,{receiverShadowCache:g,receiverShadowCacheKey:b,casterItemsCache:x,casterItemsCacheKey:v}=e,h=o.handle.transform.position??[0,0,0],C=o.handle.transform.rotation??[0,0,0],R=o.polygons.some(u=>u.texture!==void 0),I=(0,Be.meshScaleVec3)(o.handle.transform.scale),z=o.bboxCenterCss,D=y.shadow?.lift??.001,q=`${o.polygons.length}|${i.size}|${h.join(",")}|${C.join(",")}|${I.join(",")}|${z?z.join(","):"n"}|${D}`,Z=g.get(o);(Z===void 0||b.get(o)!==q)&&(Z=(0,Be.prepareReceiverFacePlanes)(o.polygons,h,o.handle.transform.scale,i,D,C),g.set(o,Z),b.set(o,q),ds(o));let M=[];for(let u of n){let m=u.handle.transform.position??[0,0,0],A=u.handle.transform.rotation??[0,0,0],k=(0,Be.meshScaleVec3)(u.handle.transform.scale),N=u.bboxCenterCss,X=`${u.polygons.length}|${m.join(",")}|${A.join(",")}|${k.join(",")}|${N?N.join(","):"n"}`,w=x.get(u);(w===void 0||v.get(u)!==X)&&(w=(0,Be.prepareCasterPolyItems)(u.polygons,m,u.handle.transform.scale,()=>!0,A),x.set(u,w),v.set(u,X));let ee;if(u===o){let K=is.get(u);(K===void 0||ss.get(u)!==u.polygons)&&(K=(0,Be.buildSharedEdgeMap)(u.polygons),is.set(u,K),ss.set(u,u.polygons)),ee=K}let te;if(u!==o&&(u.polygons.length>=40||p.points.length>0)){let K=as.get(u);(K===void 0||ls.get(u)!==X)&&(K=(0,Be.prepareCasterEdgeOwners)(u.polygons,m,u.handle.transform.scale,A),as.set(u,K),ls.set(u,X)),te=K}let ne,Pe;if(y.shadow?.parametric){let K=u.shadowDefinition??y.shadow.definition??16,be=e.shadowDragActive?Math.min(K,y.shadow.dragDefinition??K):K,Se=(0,Be.buildParametricCasterOverride)({polysWorldVerts:w.map(Ee=>Ee.wv),lightDir:r,definition:be,isSelf:u===o,style:y.shadow.style,pointLights:p.points.map(Ee=>({position:Ee.lightPos,index:Ee.index}))});ne=Se.overrideSilhouette,Pe=Se.overridePointSilhouettes}M.push({id:u,items:w,selfShadowEdgeMap:ee,edgeOwners:te,casterPolygonCount:u.polygons.length,overrideSilhouette:ne,overridePointSilhouettes:Pe})}let V={rotX:e.camera.state.rotX,rotY:e.camera.state.rotY,meshRotation:o.handle.transform.rotation},B=(0,Be.computeMergedReceiverShadows)({receiverPlanes:Z,receiverPolygons:o.polygons,receiverHasTexture:R,casters:M,lightDir:r,runDirectional:p.runDirectional,pointPasses:p.points,allPointLights:p.allPointLights,cameraRot:V,ambientLight:y.ambientLight,directionalLight:y.directionalLight,shadow:{color:y.shadow?.color,opacity:d,maxExtend:y.shadow?.maxExtend}}),F=_l(o,"m"),ae=new Set,P=!!y.debugShadowAttrs,L=qi(e.shadowSvgState,e.doc,e.sceneEl);for(let u of B){ae.add(u.faceIndex);let m=F.get(u.faceIndex);m||(m={svg:null,visible:!1,width:-1,height:-1,matrixCss:""},F.set(u.faceIndex,m));let A=m.svg;A||(A=e.doc.createElementNS(us,"svg"),A.setAttribute("class","polycss-shadow polycss-shadow-svg polycss-shadow-receiver"),L.appendChild(A),m.svg=A),m.visible||(A.style.display="block"),m.visible=!0,(m.width!==u.width||m.height!==u.height)&&(A.setAttribute("width",String(u.width)),A.setAttribute("height",String(u.height)),A.setAttribute("viewBox",`0 0 ${u.width} ${u.height}`),m.width=u.width,m.height=u.height);let k=`position:absolute;top:0;left:0;display:block;overflow:hidden;transform-origin:0 0;pointer-events:none;will-change:transform;opacity:${u.svgOpacity.toFixed(4)};transform:${u.matrixCss}`;for(m.matrixCss!==k&&(A.setAttribute("style",k),m.matrixCss=k),P&&(A.setAttribute("data-poly-shadow-type","receiver"),A.setAttribute("data-poly-shadow-receiver",os(o)),A.setAttribute("data-poly-shadow-receiver-face",String(u.faceIndex)),A.setAttribute("data-poly-shadow-receiver-polys",JSON.stringify(u.memberPolyIndices)),A.setAttribute("data-poly-shadow-layers",String(u.layers.length)));A.firstChild;)A.removeChild(A.firstChild);u.baseFill&&u.baseD&&A.appendChild(cs(e.doc,u.baseD,u.baseFill,!1,1));for(let N of u.layers)A.appendChild(cs(e.doc,N.d,N.fill,N.multiply,N.opacity))}for(let[u,m]of F)ae.has(u)||m.svg&&m.visible&&(m.svg.style.display="none",m.visible=!1)}function cs(e,n,t,o,i){let r=e.createElementNS(us,"path");return r.setAttribute("d",n),r.setAttribute("fill",t),r.setAttribute("fill-rule","nonzero"),i!==1&&r.setAttribute("opacity",i.toFixed(4)),o&&(r.style.mixBlendMode="multiply"),r}var ms=Symbol.for("polycss.animation.triangleFrameTarget");var Ol=750;var po=Promise.resolve();function fs(e){return!Object.prototype.hasOwnProperty.call(e,"seamBleed")||e.seamBleed!==void 0?e:{...e,seamBleed:J.DEFAULT_SEAM_BLEED}}var Dl={key:"non-cullable",normal:[1,1,0]};function gs(){return[Dl]}function Yt(e,n){if(!e||typeof e.appendChild!="function")throw new Error("createPolyScene: host must be an HTMLElement");if(!n?.camera)throw new Error("createPolyScene: a camera handle is required. Use createPolyCamera({...}) or createPolyPerspectiveCamera({...}) and pass as { camera }.");let t=n.camera;e.ownerDocument&&so(e.ownerDocument),e.ownerDocument?.defaultView&&e.ownerDocument.defaultView.getComputedStyle(e).position==="static"&&(e.style.position="relative");let{camera:o,...i}=n,r=fs({seamBleed:J.DEFAULT_SEAM_BLEED,...i}),s=Bi(e),c=[0,0,0],l=e.ownerDocument??document,d=l.createElement("div");d.className="polycss-camera",F(d,r),e.appendChild(d);let p=l.createElement("div");p.className="polycss-scene",p.setAttribute("aria-hidden","true"),ae(p,r),d.appendChild(p);let y=Ki({host:e,doc:l,cameraEl:d,sceneEl:p,camera:t,layoutScale:s,options:r}),g=y.meshes,b=new WeakMap,x=y.shadowSvgState,v=()=>Qi(x),h=()=>ns(y),C=null,R=null,I=140,z=0,D=80;function q(a){if(!r.shadow?.followAnimation||!a.castShadow&&!a.receiveShadow)return;let f=typeof performance<"u"?performance.now():Date.now();f-z<D||(z=f,M(),We())}function Z(a){if(!a)return null;let f=Math.hypot(a[0],a[1],a[2]);if(!Number.isFinite(f)||f<=0)return null;let S=Math.round(a[0]/f*100)/100,E=Math.round(a[1]/f*100)/100,j=Math.round(a[2]/f*100)/100;return`${S}|${E}|${j}`}function M(){C=null}let V=a=>es(y,a),B=a=>ts(y,a);function F(a,f){let S=(0,J.capturePolyCameraSnapshot)(t);a.style.perspective=S.appliedPerspectiveStyle,a.dataset.polycssCameraProjection=S.projection,a.dataset.polycssCameraPerspective=S.perspectiveStyle,a.dataset.polycssCameraAppliedPerspective=S.appliedPerspectiveStyle,a.dataset.polycssCameraZoom=String(S.state.zoom),a.dataset.polycssCameraDistance=String(S.state.distance),a.dataset.polycssCameraRotX=String(S.state.rotX),a.dataset.polycssCameraRotY=String(S.state.rotY),a.dataset.polycssCameraTarget=S.state.target.join(",")}function ae(a,f){Vi(a,s),a.style.transform=Or(t,c,s),Gi(a,f)}function P(a){a.style.transform=Or(t,c,s)}function L(a){a.textureReadyPromise=po,a.voxelRenderer?.dispose(),a.voxelRenderer=void 0,k(a.rendered,a.disposeAtlas),a.disposeAtlas=void 0,a.rendered.length=0,a.renderedByPolygonIndex=[],a.cameraCullGroups=[],a.cameraCullSignature="",a.solidLightingPreviewPrepared=!1,a.solidLightingPreviewActive=!1,A(a);for(let f of Array.from(a.wrapper.children))f instanceof HTMLElement&&f.classList.contains("polycss-bucket")&&f.remove();a.hasBuckets=!1}function u(a){for(let f of Array.from(a.wrapper.childNodes)){if(!(f instanceof HTMLElement))return f;if(f.classList.contains("polycss-bucket")||f.classList.contains("polycss-shadow"))continue;let S=f.tagName.toLowerCase();if(!(S==="b"||S==="i"||S==="s"||S==="u"||S==="q"))return f}return null}function m(a,f,S){S?.parentNode===a.wrapper?a.wrapper.insertBefore(f,S):a.wrapper.appendChild(f)}function A(a){for(let f of a.shadowRendered)f.parentNode&&f.parentNode.removeChild(f);a.shadowRendered.length=0,h()}function k(a,f){f?.();for(let S of a){try{S.dispose()}catch{}S.element.parentNode&&S.element.parentNode.removeChild(S.element)}}function N(a,f,S,E){a.rendered=f,a.renderedByPolygonIndex=[];for(let j of f)a.renderedByPolygonIndex[j.polygonIndex]=j;a.disposeAtlas=S,a.textureReadyPromise=E?E.catch(()=>{}):po,a.solidLightingPreviewPrepared=!1}function X(a,f){let S=a.renderedByPolygonIndex[f];return S?.polygonIndex===f?S:void 0}function w(a){for(let f of Array.from(a.wrapper.children))f instanceof HTMLElement&&f.classList.contains("polycss-bucket")&&f.remove();a.hasBuckets=!1;for(let f of a.rendered)f.element.parentNode&&f.element.parentNode.removeChild(f.element)}function ee(a,f){let S=a.polygons[f.polygonIndex];return a.stableDom&&S?(0,J.polygonCssSurfaceNormal)(S):f.plan?.normal??(S?(0,J.polygonCssSurfaceNormal)(S):null)}function te(a){if(!Se(a))return a.rendered;let f=ne(a);return a.rendered.filter(S=>Pe(a,S,J.CAMERA_BACKFACE_CULL_EPS,f))}function ne(a){return{rotX:t.state.rotX,rotY:t.state.rotY,meshRotation:a.handle.transform.rotation}}function Pe(a,f,S=J.CAMERA_BACKFACE_CULL_EPS,E=ne(a)){let j=ee(a,f);return j===null||(0,J.normalFacesCamera)(j,E,S)}function K(a){if(a.excludeFromAutoCenter){a.cameraCullGroups=[];return}let f=new Map;for(let S of a.rendered){let E=ee(a,S);if(!E)continue;if(!(0,J.isAxisAlignedSurfaceNormal)(E)){a.cameraCullGroups=gs();return}let j=(0,J.cameraCullNormalKey)(E);if(!f.has(j)&&(f.set(j,E),f.size>J.VOXEL_CAMERA_CULL_NORMAL_LIMIT)){a.cameraCullGroups=gs();return}}a.cameraCullGroups=Array.from(f,([S,E])=>({key:S,normal:E}))}function be(a){return Se(a)?(0,J.cameraCullVisibleSignature)(a.cameraCullGroups,ne(a)):"all"}function Se(a){return!a.excludeFromAutoCenter&&(0,J.isVoxelCameraCullableNormalGroups)(a.cameraCullGroups)}function Ee(a){a.cameraCullSignature=Se(a)?be(a):"all"}function it(a,f){let S=new Array(a.rendered.length),E=!1,j=ne(a);for(let Q=0;Q<a.rendered.length;Q+=1){let le=a.rendered[Q],Ce=Pe(a,le,f,j);S[Q]=Ce}let H=null,_=null,$=()=>{if(!(!H||!_)){if(H===_)H.remove();else{let Q=l.createRange();Q.setStartBefore(H),Q.setEndAfter(_),Q.deleteContents(),Q.detach()}H=null,_=null,E=!0}};for(let Q=0;Q<a.rendered.length;Q+=1){let le=a.rendered[Q];!S[Q]&&le.element.parentNode===a.wrapper?(_&&_.nextSibling===le.element||($(),H=le.element),_=le.element):$()}$();let G=Q=>{for(let le=Q;le<a.rendered.length;le+=1){let Ce=a.rendered[le].element;if(Ce.parentNode===a.wrapper)return Ce}return u(a)},fe=-1,ue=Q=>{if(fe<0)return;let le=l.createDocumentFragment();for(let Ce=fe;Ce<Q;Ce+=1){let ke=a.rendered[Ce];Tt(a,ke),le.appendChild(ke.element)}m(a,le,G(Q)),fe=-1,E=!0};for(let Q=0;Q<a.rendered.length;Q+=1){let le=a.rendered[Q];S[Q]&&le.element.parentNode!==a.wrapper?fe<0&&(fe=Q):ue(Q)}return ue(a.rendered.length),E}function Ne(a,f=!1){if(a.voxelRenderer){f?a.voxelRenderer.render(ne(a)):a.voxelRenderer.syncCamera(ne(a)),a.cameraCullSignature="voxel-direct";return}if(!Se(a)){let j=a.cameraCullSignature!=="all";a.cameraCullSignature="all",j&&Wn(a);return}if(a.hasBuckets){mt(a,f);return}let S=be(a);if(!f&&S===a.cameraCullSignature)return;let E=it(a,J.CAMERA_BACKFACE_CULL_EPS);a.cameraCullSignature=S,E&&$e(a)}function mt(a,f=!1){let S=Se(a)?be(a):"all";!f&&S===a.cameraCullSignature||Wn(a)}function Sn(a,f){return ee(a,f)}function Tt(a,f){if(r.textureLighting!=="dynamic")return;let S=Sn(a,f);S&&(f.element.style.setProperty("--pnx",S[0].toFixed(4)),f.element.style.setProperty("--pny",S[1].toFixed(4)),f.element.style.setProperty("--pnz",S[2].toFixed(4)))}function ft(a){w(a),a.hasBuckets=!1;let f=a.skipBucketNormalCleanupOnce;a.skipBucketNormalCleanupOnce=!1;let S=l.createDocumentFragment(),E=r.textureLighting==="dynamic"&&!a.stableDom,j=new Map,H=[];for(let _ of te(a)){let $=a.polygons[_.polygonIndex],G=E&&$?Ni($):null;if(!G){H.push(_);continue}let fe=G.key+"|"+($.color??""),ue=j.get(fe);ue||(ue={vec:G.vec,items:[]},j.set(fe,ue)),ue.items.push(_)}for(let _ of H)Tt(a,_),S.appendChild(_.element);for(let _ of j.values()){if(_.items.length<2){for(let G of _.items)Tt(a,G),S.appendChild(G.element);continue}let $=l.createElement("div");$.className="polycss-bucket",a.hasBuckets=!0,$.style.setProperty("--pnx",String(_.vec[0])),$.style.setProperty("--pny",String(_.vec[1])),$.style.setProperty("--pnz",String(_.vec[2]));for(let G of _.items)$.appendChild(G.element),(!f||G.kind==="triangle")&&(G.element.style.removeProperty("--pnx"),G.element.style.removeProperty("--pny"),G.element.style.removeProperty("--pnz"));S.appendChild($)}m(a,S,u(a)),Ee(a)}function Jo(){return new Promise(a=>setTimeout(a,0))}async function er(a,f){if(r.textureLighting==="dynamic"&&!a.stableDom)return ft(a),!f();w(a);let E=l.createDocumentFragment(),j=u(a),H=0;for(let _ of te(a)){if(f())return!1;Tt(a,_),E.appendChild(_.element),H++,H%Ol===0&&(m(a,E,j),E=l.createDocumentFragment(),await Jo())}return E.childNodes.length>0&&m(a,E,j),Ee(a),!f()}function Cn(a,f){let S=r.textureLighting==="dynamic",E=r.directionalLight?.direction,j=f&&(f[0]!==0||f[1]!==0||f[2]!==0);if(!S||!j||!E){if(a.lightOverrideSignature==="clear")return;a.wrapper.style.removeProperty("--plx"),a.wrapper.style.removeProperty("--ply"),a.wrapper.style.removeProperty("--plz"),a.lightOverrideSignature="clear";return}let H=(0,J.inverseRotateVec3)(E,f),_=zn(H),$=Math.hypot(_[0],_[1],_[2])||1,G=(_[0]/$).toFixed(2),fe=(_[1]/$).toFixed(2),ue=(_[2]/$).toFixed(2),Q=`${G}|${fe}|${ue}`;a.lightOverrideSignature!==Q&&(a.wrapper.style.setProperty("--plx",G),a.wrapper.style.setProperty("--ply",fe),a.wrapper.style.setProperty("--plz",ue),a.lightOverrideSignature=Q)}function $n(a){let f=!1;for(let S of a.rendered){if(!S.plan||S.kind==="atlas"||S.plan.texture)continue;let E=a.polygons[S.polygonIndex];E&&(f=Ir(S,E,r)||f)}return a.solidLightingPreviewPrepared=!1,a.solidLightingPreviewActive=!1,f}function W(a){if((r.textureLighting??"baked")!=="baked")return!1;let f=!1;for(let S of a.rendered){if(!S.plan||S.kind==="atlas"||S.plan.texture)continue;let E=a.polygons[S.polygonIndex];E&&(Xi(S,E,S.plan.shadedColor),f=!0)}return a.solidLightingPreviewPrepared=f,f}function pe(a){return(r.textureLighting??"baked")!=="baked"||!a.solidLightingPreviewPrepared&&!W(a)?!1:(a.solidLightingPreviewActive=!0,!0)}function me(a){return a.kind==="atlas"||!!a.plan?.texture}function je(){if((r.textureLighting??"baked")!=="baked")return!1;let a=!1;for(let f of g)a=$n(f)||a,f.rendered.some(me)&&(nr(f),a=!0);p.style.removeProperty(pn);for(let f of g)Ut(f.wrapper),f.solidLightingPreviewActive=!1;return Ut(p),a}function Tn(){p.style.removeProperty(pn);for(let a of g)a.solidLightingPreviewActive&&($n(a),Ut(a.wrapper));(r.textureLighting??"baked")!=="dynamic"&&(Ut(p),M(),We())}function En(a,f){let S=a.handle.transform.rotation,E=f.directionalLight?.direction??r.directionalLight?.direction;if(!(S&&(S[0]!==0||S[1]!==0||S[2]!==0))||!E){Ut(a.wrapper);return}let H=(0,J.inverseRotateVec3)(E,S);lo(a.wrapper,{...r,...f,directionalLight:{...r.directionalLight,...f.directionalLight,direction:H}})}function zt(a){if((r.textureLighting??"baked")!=="baked")return!1;lo(p,{...r,...a}),!a.skipShadows&&a.directionalLight?.direction&&We(a.directionalLight.direction,{progressive:!0});let f=!1;for(let S of g)En(S,a),f=pe(S)||f;return f?xe(p,pn,"1"):p.style.removeProperty(pn),f}function He(a,f,S){let E=a.polygons[f];if(!E)return!1;let j=X(a,f);if(!j)return!1;let H=r.textureLighting??"baked";return H==="dynamic"?(Yi(j.element,S),!0):H==="baked"?Ir(j,E,r):!1}function Ze(a,f){let S=a.polygons[f];if(!S)return!1;let E=X(a,f);return E?(_e(E.element,S,f),!0):!1}function st(a,f,S){return!(S.length===0||!S.every(E=>E==="color"||E==="data")||S.includes("color")&&!He(a,f,a.polygons[f]?.color)||S.includes("data")&&!Ze(a,f))}function $e(a){M(),We()}function We(a,f){let S=r.shadow,E=!!f?.progressive&&!!S?.parametric&&S?.dragDefinition!=null&&S.dragDefinition<(S.definition??16);y.shadowDragActive=E,E&&(R&&clearTimeout(R),R=setTimeout(()=>{R=null,y.shadowDragActive=!1,M(),We()},I));let j=[];for(let oe of g)!oe.disposed&&oe.castShadow&&j.push(oe);if(j.length===0){h(),C=null;return}let H=r.shadow?.color??"#000000",_=r.shadow?.opacity??.25,$=(0,J.parseHexColor)(H)?.rgb??[0,0,0],G=$[0],fe=$[1],ue=$[2],Q=a??r.directionalLight?.direction??[.4,-.7,.59],le=zn(Q),Ce=r.textureLighting==="dynamic"?[]:r.pointLights??[],ke=Ce.map(oe=>({position:zi(oe.position),color:oe.color,intensity:oe.intensity})),Qe=Ce.map((oe,O)=>oe.castShadow?O:-1).filter(oe=>oe>=0),T=Qe.map(oe=>ke[oe].position),gt=r.directionalLight,Et=!!gt?.direction&&(gt.intensity??1)>0,ht=Z(le),at=T.map(oe=>`${Math.round(oe[0])},${Math.round(oe[1])},${Math.round(oe[2])}`).join(";"),Ke=ht===null&&at===""?null:`${ht??""}|${at}`;if(Ke!==null&&Ke===C)return;let At=new Map;for(let oe of j)At.set(oe,(0,J.findOverlappingPolygonDuplicates)(oe.polygons,{normalTolerance:.1,distanceTolerance:.5,overlapFraction:.95,preserveDoubleSidedBackfaces:!1}));let bt=new Map;for(let oe of g)oe.disposed||!oe.receiveShadow||bt.set(oe,new Set);v();for(let oe of g){if(oe.disposed||!oe.receiveShadow)continue;let O=bt.get(oe)??new Set;ps(y,j,At,oe,O,le,G,fe,ue,_,{runDirectional:Et,points:T.map((U,ce)=>({lightPos:U,index:Qe[ce]})),allPointLights:ke})}C=Ke}function Wn(a){if(a.voxelRenderer){a.voxelRenderer.render(ne(a)),a.cameraCullSignature="voxel-direct";return}A(a),ft(a),$e(a)}function tr(a,f){if(!f||!a.polygons||a.polygons.length<2)return;let S=Math.hypot(f[0],f[1],f[2]);if(!Number.isFinite(S)||S<=0)return;let E=f[0]/S,j=f[1]/S,H=f[2]/S,_=Q=>Math.round(Q*1e3)/1e3,$=`${_(E)},${_(j)},${_(H)}`,G=a.lightOcclusionCache;if(G&&G.polygons===a.polygons&&G.lightDirKey===$)return G.occluded;let fe=G&&G.polygons===a.polygons?G.dedupDropped:(0,J.findOverlappingPolygonDuplicates)(a.polygons,{normalTolerance:.1,distanceTolerance:.12,overlapFraction:.98,preserveDoubleSidedBackfaces:!1}),ue=(0,J.computeLightVisibility)(a.polygons,[E,j,H],fe);return a.lightOcclusionCache={polygons:a.polygons,lightDirKey:$,occluded:ue,dedupDropped:fe},ue}function Un(a){return!!a.voxelSource&&r.textureLighting!=="dynamic"&&!a.stableDom&&!a.castShadow}function Zt(a){let f=r.pointLights;if(!f||f.length===0)return;let S=a.handle.transform.position??[0,0,0],E=a.handle.transform.rotation??[0,0,0],j=E[0]!==0||E[1]!==0||E[2]!==0;return f.map(H=>{let _=[H.position[0]-S[0],H.position[1]-S[1],H.position[2]-S[2]],$=j?(0,J.inverseRotateVec3)(_,E):_;return{...H,position:$}})}function Ge(a,f){L(a);let S=r.directionalLight,E=f?{...S,direction:f}:S,j=It(E),H=void 0;if(Un(a)){let G=Hi({doc:l,wrapper:a.wrapper,polygons:a.parseResult.polygons,directionalLight:j,ambientLight:r.ambientLight});if(G){a.voxelRenderer=G,G.render(ne(a)),a.cameraCullSignature="voxel-direct",a.textureReadyPromise=po;return}}let _={doc:l,directionalLight:j,pointLights:Zt(a),ambientLight:r.ambientLight,textureLighting:r.textureLighting,textureQuality:r.textureQuality,textureLeafSizing:r.textureLeafSizing,textureImageRendering:r.textureImageRendering,textureBackend:r.textureBackend,textureProjection:r.textureProjection,seamBleed:r.seamBleed,strategies:r.strategies,lightOccludedPolyIndices:H},$=a.stableDom?(()=>{let G=kt(a.polygons,_);return Gt(a.wrapper,G),Wt(a.polygons,{..._,solidPaintDefaults:G})??_t(a.polygons,{..._,solidPaintDefaults:G})})():_t(a.polygons,{..._,computeSolidPaintDefaults:!0,skipDynamicNormalVars:r.textureLighting==="dynamic"});a.stableDom||Gt(a.wrapper,$.solidPaintDefaults??{}),N(a,$.rendered,$.dispose,$.pagesReady),a.skipBucketNormalCleanupOnce=r.textureLighting==="dynamic"&&!a.stableDom,K(a),ft(a),$e(a)}function nr(a,f){if(a.rendered.length===0||a.voxelRenderer||a.stableDom||Un(a)){Ge(a,f);return}if(a.rendered[0]?.element.parentNode===null){Ge(a,f);return}let S=r.directionalLight,E=f?{...S,direction:f}:S,j=It(E),H={doc:l,directionalLight:j,pointLights:Zt(a),ambientLight:r.ambientLight,textureLighting:r.textureLighting,textureQuality:r.textureQuality,textureLeafSizing:r.textureLeafSizing,textureImageRendering:r.textureImageRendering,textureBackend:r.textureBackend,textureProjection:r.textureProjection,seamBleed:r.seamBleed,strategies:r.strategies,computeSolidPaintDefaults:!0,skipDynamicNormalVars:r.textureLighting==="dynamic"},_=_t(a.polygons,H),$=()=>{a.rebakeInFlight=!1;let ue=a.rebakeQueuedLightDir;ue!==null&&(a.rebakeQueuedLightDir=null,nr(a,ue))},G=()=>{if(a.disposed){_.dispose(),$();return}if(_.rendered.length!==a.rendered.length){_.dispose(),Ge(a,f),$();return}for(let le of _.rendered){let Ce=a.renderedByPolygonIndex[le.polygonIndex];if(!Ce)continue;let ke=le.element.getAttribute("style");ke!==null&&Ce.element.setAttribute("style",ke)}let ue=_.solidPaintDefaults;ue&&Gt(a.wrapper,ue);let Q=a.disposeAtlas;a.disposeAtlas=_.dispose,Q&&(typeof requestAnimationFrame=="function"?Ce=>{requestAnimationFrame(Ce)}:Ce=>{setTimeout(Ce,0)})(Q),$e(a),$()},fe=_.pagesReady;fe&&typeof fe.then=="function"?(a.textureReadyPromise=fe.catch(()=>{}),fe.then(()=>ua(_.rendered)).then(da).then(G,()=>{_.dispose(),a.disposed||Ge(a,f),$()})):G()}function ca(a,f){if(a.rebakeInFlight){a.rebakeQueuedLightDir=f;return}a.rebakeInFlight=!0,nr(a,f)}function ua(a){let f=new Set;for(let S of a){let E=S.element.getAttribute("style")??"",j=/url\((blob:[^)]+)\)/g,H;for(;(H=j.exec(E))!==null;)f.add(H[1])}return Array.from(f)}function da(a){return a.length===0||typeof Image>"u"?Promise.resolve():Promise.all(a.map(f=>{let S=new Image;S.src=f;let E=S.decode?.();return E?E.catch(()=>{}):Promise.resolve()})).then(()=>{})}function Bt(){let a=1/0,f=!1;for(let H of g)if(!H.disposed&&H.receiveShadow){f=!0;break}for(let H of g){if(H.disposed||!(f?H.receiveShadow:H.castShadow))continue;let $=H.handle.transform.position?.[2]??0;for(let G of H.polygons)for(let fe of G.vertices){let ue=fe[2]+$;ue<a&&(a=ue)}}if(!Number.isFinite(a)){let H=x.currentGroundCssZ!==null;x.currentGroundCssZ=null,H&&(h(),M());return}let S=r.shadow?.lift??.05,E=(a+S)*Fn,j=x.currentGroundCssZ;x.currentGroundCssZ=E,j!==E&&(M(),We())}async function pa(a,f){L(a);let S=It(r.directionalLight),E={doc:l,directionalLight:S,pointLights:Zt(a),ambientLight:r.ambientLight,textureLighting:r.textureLighting,textureQuality:r.textureQuality,textureLeafSizing:r.textureLeafSizing,textureImageRendering:r.textureImageRendering,textureBackend:r.textureBackend,textureProjection:r.textureProjection,seamBleed:r.seamBleed,strategies:r.strategies,lightOccludedPolyIndices:void 0},j=a.stableDom?Wt(a.polygons,E):null;if(j){let $=kt(a.polygons,E);return Gt(a.wrapper,$),N(a,j.rendered,j.dispose,j.pagesReady),K(a),ft(a),$e(a),!f()}let H=await cn(a.polygons,{...E,skipDynamicNormalVars:r.textureLighting==="dynamic"},f);if(f())return H.dispose(),!1;Gt(a.wrapper,H.solidPaintDefaults),N(a,H.rendered,H.dispose,H.pagesReady),a.skipBucketNormalCleanupOnce=r.textureLighting==="dynamic"&&!a.stableDom,K(a);let _=await er(a,f);return _&&$e(a),_}function Vt(){let a=c,f=[0,0,0];if(r.autoCenter){let S=[];for(let E of g)!E.disposed&&!E.excludeFromAutoCenter&&S.push(...E.polygons);if(S.length>0){let E=(0,J.computeSceneBbox)(S);f=[(E.min[0]+E.max[0])/2,(E.min[1]+E.max[1])/2,(E.min[2]+E.max[2])/2]}}a[0]===f[0]&&a[1]===f[1]&&a[2]===f[2]||(c=f,y.autoCenter.offset=f,ae(p,r))}function ma(a,f={}){let E=(p.ownerDocument??document).createElement("div");E.className="polycss-mesh",f.id&&E.setAttribute("data-poly-mesh-id",f.id);let j=`polycss-mesh-${y.meshAutoCounter.next++}`;E.setAttribute("data-poly-mesh-index",j);let H={...f},_=f.merge!==!1,$=!!f.stableDom,G=0,fe=ao(H);fe&&(E.style.transform=fe);let ue=(O,U)=>a.voxelSource?O:U?(0,J.optimizeMeshPolygons)(O,{meshResolution:f.meshResolution}):($||f.excludeFromAutoCenter,O),Q=ue(a.polygons,_),le=null;function Ce(){let O=ao(H);E.style.transform=O??""}function ke(O){if(O.length===0){le=null,Qe&&(Qe.bboxCenterCss=null),Ce();return}let U=1/0,ce=1/0,ge=1/0,Fe=-1/0,ie=-1/0,ve=-1/0;for(let ct of O)for(let et of ct.vertices)et[0]<U&&(U=et[0]),et[0]>Fe&&(Fe=et[0]),et[1]<ce&&(ce=et[1]),et[1]>ie&&(ie=et[1]),et[2]<ge&&(ge=et[2]),et[2]>ve&&(ve=et[2]);if(!Number.isFinite(U)){le=null,Qe&&(Qe.bboxCenterCss=null),Ce();return}let Je=(ce+ie)/2*Fn,lt=(U+Fe)/2*Fn,Ye=(ge+ve)/2*Fn;le=[Je,lt,Ye],Qe&&(Qe.bboxCenterCss=le),Ce()}let Qe=null;ke(Q),p.appendChild(E);let T={handle:void 0,wrapper:E,parseResult:a,rendered:[],renderedByPolygonIndex:[],shadowRendered:[],polygons:Q,voxelSource:a.voxelSource,disposed:!1,stableDom:$,hasBuckets:!1,skipBucketNormalCleanupOnce:!1,excludeFromAutoCenter:!!f.excludeFromAutoCenter,castShadow:!!f.castShadow,bboxCenterCss:le,receiveShadow:!!f.receiveShadow,shadowDefinition:f.shadowDefinition,cameraCullGroups:[],cameraCullSignature:"",lightOverrideSignature:"clear",stableTriangleColorFrame:0,solidLightingPreviewPrepared:!1,solidLightingPreviewActive:!1,bakedRotation:f.rotation?[...f.rotation]:[0,0,0],autoMeshId:j,rebakeInFlight:!1,rebakeQueuedLightDir:null,textureReadyPromise:po},gt=null,Et=0,ht=-1,at=null;function Ke(){gt=null,at=null,ht=-1}function At(){let O=gt;if(!O||O.polygonCount!==T.polygons.length)return T.polygons;if(at&&ht===Et)return at;let U=O.vertices,ce=new Array(O.polygonCount);for(let ge=0;ge<O.polygonCount;ge++){let Fe=T.polygons[ge],ie=ge*9;ce[ge]={...Fe,color:O.colors?.[ge]??Fe.color,vertices:[[U[ie],U[ie+1],U[ie+2]],[U[ie+3],U[ie+4],U[ie+5]],[U[ie+6],U[ie+7],U[ie+8]]]}}return at=ce,ht=Et,ce}function bt(O,U){let ce=O?.stableTriangleUpdateMode==="color-only";T.stableTriangleColorFrame++;let ge=T.stableDom&&!U;if(ge||ke(T.polygons),T.stableDom&&!T.hasBuckets){let Fe={doc:l,directionalLight:It(r.directionalLight),ambientLight:r.ambientLight,textureLighting:r.textureLighting,textureQuality:r.textureQuality,textureLeafSizing:r.textureLeafSizing,textureImageRendering:r.textureImageRendering,textureBackend:r.textureBackend,textureProjection:r.textureProjection,seamBleed:r.seamBleed},ie=T.rendered.length===T.polygons.length&&T.rendered.every(Ye=>Ye.kind==="triangle"),ve=T.stableDom&&!U,Je=ie||ve?{}:kt(T.polygons,Fe);ie||Gt(T.wrapper,Je);let lt={...Fe,solidPaintDefaults:Je,optimizeStableTriangleStyle:!0,stableTriangleDebug:O?.stableTriangleDebug,stableTriangleUpdateMode:O?.stableTriangleUpdateMode,stableTriangleColorPolicy:O?.stableTriangleColorPolicy,stableTriangleColorSteps:O?.stableTriangleColorSteps,stableTriangleColorFreezeFrames:O?.stableTriangleColorFreezeFrames,stableTriangleColorBudget:O?.stableTriangleColorBudget,stableTriangleColorMaxAge:O?.stableTriangleColorMaxAge,stableTriangleColorMaxStep:O?.stableTriangleColorMaxStep,stableTriangleMatrixDecimals:O?.stableTriangleMatrixDecimals,stableTriangleColorFrame:T.stableTriangleColorFrame};if(dn(T.rendered,T.polygons,lt))return ce||(K(T),Ne(T,!0),U&&Vt()),!0}return ge&&ke(T.polygons),!1}let oe={get polygons(){return At()},set polygons(O){Ke(),T.polygons=O},element:E,id:f.id,get transform(){return H},remove(){G++,E.parentNode&&E.parentNode.removeChild(E),L(T),g.delete(T),b.delete(E),V(T),B(T),Vt(),Bt()},setPolygons(O,U){G++,_=U?.merge??_,$=U?.stableDom??$,T.stableDom=$,T.voxelSource=void 0,T.polygons=ue(O,_),B(T),V(T),Ke(),oe.polygons=T.polygons;let ce=U?.recomputeAutoCenter??!0;q(T),!bt(U,ce)&&(Ge(T),ce&&Vt())},[ms](O,U){let ce=U?.merge??_,ge=U?.stableDom??$;if(!O.solidTriangles||!ge||ce||f.meshResolution!==void 0||T.hasBuckets||O.polygonCount!==T.polygons.length||O.vertices.length<O.polygonCount*9||T.rendered.length!==O.polygonCount)return!1;for(let ve=0;ve<T.rendered.length;ve++){let Je=T.rendered[ve],lt=T.polygons[ve];if(Je?.kind!=="triangle"||Je.polygonIndex!==ve||!lt||lt.vertices.length!==3||lt.texture||lt.material?.texture)return!1}let Fe=U?.recomputeAutoCenter??!0;if(!Fe){let ve=T.stableTriangleColorFrame+1,Je={doc:l,directionalLight:It(r.directionalLight),ambientLight:r.ambientLight,textureLighting:r.textureLighting,textureQuality:r.textureQuality,textureLeafSizing:r.textureLeafSizing,textureImageRendering:r.textureImageRendering,textureBackend:r.textureBackend,textureProjection:r.textureProjection,seamBleed:r.seamBleed,solidPaintDefaults:{},optimizeStableTriangleStyle:!0,stableTriangleDebug:U?.stableTriangleDebug,stableTriangleUpdateMode:U?.stableTriangleUpdateMode,stableTriangleColorPolicy:U?.stableTriangleColorPolicy,stableTriangleColorSteps:U?.stableTriangleColorSteps,stableTriangleColorFreezeFrames:U?.stableTriangleColorFreezeFrames??0,stableTriangleColorBudget:U?.stableTriangleColorBudget,stableTriangleColorMaxAge:U?.stableTriangleColorMaxAge,stableTriangleColorMaxStep:U?.stableTriangleColorMaxStep,stableTriangleMatrixDecimals:U?.stableTriangleMatrixDecimals,stableTriangleColorFrame:ve};if(un(T.rendered,T.polygons,O,Je))return G++,_=ce,$=ge,T.stableDom=$,T.voxelSource=void 0,T.stableTriangleColorFrame=ve,gt=O,Et++,at=null,ht=-1,Se(T)?(K(T),Ne(T,!0)):Ee(T),!0}G++,_=ce,$=ge,T.stableDom=$,T.voxelSource=void 0;let ie=O.vertices;for(let ve=0;ve<O.polygonCount;ve++){let Je=T.polygons[ve],lt=O.colors?.[ve];lt&&(Je.color=lt);let Ye=Je.vertices,ct=ve*9;Ye[0][0]=ie[ct],Ye[0][1]=ie[ct+1],Ye[0][2]=ie[ct+2],Ye[1][0]=ie[ct+3],Ye[1][1]=ie[ct+4],Ye[1][2]=ie[ct+5],Ye[2][0]=ie[ct+6],Ye[2][1]=ie[ct+7],Ye[2][2]=ie[ct+8]}return Ke(),oe.polygons=T.polygons,bt(U,Fe)},updatePolygon(O,U){let ce=typeof O=="number"?O:T.polygons.indexOf(O);if(ce<0&&typeof O!="number"&>&&(ce=At().indexOf(O)),ce<0||ce>=T.polygons.length)return;Ke(),T.voxelSource=void 0,Object.assign(T.polygons[ce],U);let ge=Object.keys(U);st(T,ce,ge)||Ge(T)},async setPolygonsChunked(O,U){let ce=++G;_=U?.merge??_,$=U?.stableDom??$,T.stableDom=$,T.voxelSource=void 0,T.polygons=ue(O,_),Ke(),oe.polygons=T.polygons,ke(T.polygons);let ge=U?.recomputeAutoCenter??!0;if(!await pa(T,()=>T.disposed||ce!==G)){L(T);return}ge&&Vt()},setTransform(O){let U=T.castShadow,ce=T.receiveShadow,ge=T.shadowDefinition;O.castShadow!==void 0&&(T.castShadow=!!O.castShadow),O.receiveShadow!==void 0&&(T.receiveShadow=!!O.receiveShadow),O.shadowDefinition!==void 0&&(T.shadowDefinition=O.shadowDefinition),H={...H,...O};let Fe=ao(H);E.style.transform=Fe??"",Cn(T,H.rotation),O.rotation!==void 0&&Ne(T,!0),T.castShadow!==U&&(T.voxelSource&&Ge(T),$e(T),Bt()),T.receiveShadow!==ce&&(T.receiveShadow||Hr(T),M(),We()),(O.position!==void 0||O.scale!==void 0)&&(T.castShadow||T.receiveShadow)&&(Bt(),M(),We()),T.shadowDefinition!==ge&&(T.castShadow||T.receiveShadow)&&(M(),We())},dispose(){if(!T.disposed){T.disposed=!0,G++,E.parentNode&&E.parentNode.removeChild(E),L(T);try{a.dispose()}catch{}g.delete(T),b.delete(E),Vt(),Bt()}},rebakeAtlas(){T.bakedRotation=H.rotation?[...H.rotation]:[0,0,0];let O=r.directionalLight?.direction??[.4,-.7,.59],U=(0,J.inverseRotateVec3)(O,T.bakedRotation);ca(T,U)},whenTexturesReady(){return T.textureReadyPromise},getPosition(){return H.position},getRotation(){return H.rotation},getScale(){return H.scale},getPolygons(){return oe.polygons}};return T.handle=oe,Qe=T,b.set(E,T),g.add(T),Ge(T),Cn(T,H.rotation),Vt(),Bt(),T.receiveShadow&&(M(),We()),oe}function fa(a){let f=!!r.autoCenter,S=r.strategies,E=r.seamBleed,j=r.textureLeafSizing,H=r.textureImageRendering,_=r.textureBackend,$=r.textureProjection,G=r.textureLighting,fe=r.directionalLight?.direction,ue=r.directionalLight?.intensity,Q=r.directionalLight?.color,le=r.shadow,Ce=r.pointLights,ke=fs(a);r={...r,...ke},y.options.current=r,ae(p,r);let Qe=!!r.autoCenter;for(let ie of g)Cn(ie,ie.handle.transform.rotation);let T=a.strategies!==void 0&&!ji(a.strategies,S),gt=Object.prototype.hasOwnProperty.call(a,"seamBleed")&&ke.seamBleed!==E,Et=Object.prototype.hasOwnProperty.call(a,"textureLeafSizing")&&ke.textureLeafSizing!==j,ht=Object.prototype.hasOwnProperty.call(a,"textureImageRendering")&&ke.textureImageRendering!==H,at=Object.prototype.hasOwnProperty.call(a,"textureBackend")&&ke.textureBackend!==_,Ke=Object.prototype.hasOwnProperty.call(a,"textureProjection")&&ke.textureProjection!==$,At=ie=>(ie??[]).map(ve=>`${ve.position.join(",")}|${ve.color??""}|${ve.intensity??1}|${ve.castShadow?1:0}`).join(";"),bt=Object.prototype.hasOwnProperty.call(a,"pointLights")&&At(r.pointLights)!==At(Ce);if(T||gt||Et||ht||at||Ke||bt)for(let ie of g)Ge(ie);f!==Qe&&Vt();let oe=a.textureLighting!==void 0&&G!==r.textureLighting,O=r.directionalLight,U=a.directionalLight!==void 0&&(!$i(fe,O?.direction)||(ue??1)!==(O?.intensity??1)||(Q??"#ffffff")!==(O?.color??"#ffffff")),ce=r.shadow,ge=a.shadow!==void 0&&!Wi(le,ce),Fe=U||ge||bt;if(oe){if(!T&&!gt&&!Et&&!ht&&!at&&!Ke)for(let ie of g)Ge(ie);Bt(),M(),We()}else Fe&&((ge||U)&&M(),We(void 0,{progressive:(U||bt)&&!ge}));ge&&a.shadow?.lift!==le?.lift&&Bt()}function ga(){return r}function ha(){F(d,r),P(p);for(let a of g)Ne(a)}function ya(){let a=[];for(let f of g)a.push(f.handle);return a}function ba(){return Promise.all(Array.from(g,a=>a.handle.whenTexturesReady())).then(()=>{})}function xa(a){let f=a;for(;f;){if(f instanceof HTMLElement){let S=b.get(f);if(S&&!S.disposed)return S.handle;if(f.classList.contains("polycss-mesh"))return null}f=f.parentElement}return null}function Pa(){R&&(clearTimeout(R),R=null);let a=Array.from(g);for(let f of a)try{f.handle.dispose()}catch{}d.parentNode&&d.parentNode.removeChild(d)}return{add:ma,setOptions:fa,destroy:Pa,host:e,camera:t,cameraEl:d,sceneElement:p,applyCamera:ha,getOptions:ga,meshes:ya,whenTexturesReady:ba,findMeshByElement:xa,previewBakedSolidLighting:zt,commitBakedSolidLighting:je,clearBakedSolidLightingPreview:Tn}}var we=require("@layoutit/polycss-core");var Fr=require("@layoutit/polycss-core"),Il=32e3;function vt(e={}){let n={};e.zoom!==void 0&&(n.zoom=e.zoom),e.target!==void 0&&(n.target=e.target),e.rotX!==void 0&&(n.rotX=e.rotX),e.rotY!==void 0&&(n.rotY=e.rotY),e.distance!==void 0&&(n.distance=e.distance);let t=(0,Fr.createIsometricCamera)(n),o=`${e.perspective??Il}px`;return{get state(){return t.state},update(i){t.update(i)},getStyle(i){return t.getStyle(i)},type:"perspective",perspectiveStyle:o}}function ut(e={}){let n={};e.zoom!==void 0&&(n.zoom=e.zoom),e.target!==void 0&&(n.target=e.target),e.rotX!==void 0&&(n.rotX=e.rotX),e.rotY!==void 0&&(n.rotY=e.rotY),e.distance!==void 0&&(n.distance=e.distance);let t=(0,Fr.createIsometricCamera)(n);return{get state(){return t.state},update(o){t.update(o)},getStyle(o){return t.getStyle(o)},type:"orthographic",perspectiveStyle:"none"}}var hs=ut;var ys=require("@layoutit/polycss-core");var mo={drag:!0,wheel:!0,dolly:!1,invert:!1,minZoom:.1,maxZoom:10,minDistance:0,maxDistance:1/0,animate:!1};function mn(e,n){let t;return n.animate===!1?t=!1:n.animate?t={speed:n.animate.speed??.3,axis:n.animate.axis??"y",pauseOnInteraction:n.animate.pauseOnInteraction??!0}:t=e.animate,{drag:n.drag??e.drag,wheel:n.wheel??e.wheel,dolly:n.dolly??e.dolly,invert:n.invert??e.invert,minZoom:n.minZoom??e.minZoom,maxZoom:n.maxZoom??e.maxZoom,minDistance:n.minDistance??e.minDistance,maxDistance:n.maxDistance??e.maxDistance,animate:t}}function Bn(e){return e===!0?-1:e===!1?1:e}function fn(){let e=[],n=[],t=[];function o(s){return s==="change"?e:s==="start"?n:t}function i(s){if(e.length===0)return;let c={type:"change",camera:s()},l=e.slice();for(let d of l)try{d(c)}catch(p){console.error("[polycss] controls 'change' listener threw:",p)}}function r(s,c){let l=s==="start"?n:t;if(l.length===0)return;let d={type:s,camera:c()},p=l.slice();for(let y of p)try{y(d)}catch(g){console.error(`[polycss] controls '${s}' listener threw:`,g)}}return{changeListeners:e,startListeners:n,endListeners:t,listenerArray:o,emitChange:i,emitInteraction:r}}function gn(e){return()=>{let n=e.camera.state,t=n.target??[0,0,0];return{rotX:n.rotX??0,rotY:n.rotY??0,zoom:n.zoom??1,target:[t[0],t[1],t[2]],distance:n.distance??0}}}function fo(e,n,t,o,i,r){let s=!1,c=null;return{onWheel:p=>{let y=n();if(!y.wheel||t())return;p.preventDefault();let g=p.deltaMode===1?16:p.deltaMode===2?100:1,b=p.deltaY*g;p.ctrlKey?b*=10:b*=3;let x=e.camera.state;if(y.dolly){let v=x.distance??0,h=Math.max(y.minDistance,Math.min(y.maxDistance,v+b*.05));e.camera.update({distance:h})}else{let v=Math.exp(-b*513e-6),h=x.zoom??1,C=Math.max(y.minZoom,Math.min(y.maxZoom,h*v));e.camera.update({zoom:C})}e.applyCamera(),s||(s=!0,r("start",o)),i(o),c!==null&&clearTimeout(c),c=setTimeout(()=>{c=null,s=!1,r("end",o)},150)},teardown:()=>{c!==null&&(clearTimeout(c),c=null),s=!1}}}function go(e,n,t,o,i,r,s){let c=null,l=0,d=b=>{if(c===null||o())return;let x=t();if(!x.animate){c=null;return}if(i())l=b;else{let v=Math.min(50,l?b-l:16.67);l=b;let h=x.animate.speed*(v/16.67),C=n.camera.state;if(x.animate.axis==="x"){let R=(((C.rotX??65)+h)%360+360)%360;n.camera.update({rotX:R})}else{let R=(((C.rotY??45)+h)%360+360)%360;n.camera.update({rotY:R})}n.applyCamera(),s(r)}c=e.requestAnimationFrame(d)};return{start:()=>{c!==null||!t().animate||o()||(l=0,c=e.requestAnimationFrame(d))},stop:()=>{c!==null&&(e.cancelAnimationFrame(c),c=null)},isRunning:()=>c!==null}}function ho(e,n={}){let t=mn(mo,n),o=e.host,i=o.ownerDocument?.defaultView??globalThis,r=null,s={x:0,y:0},c=!1,l=!1,d=fn(),p=gn(e),{changeListeners:y,startListeners:g,endListeners:b,listenerArray:x,emitChange:v,emitInteraction:h}=d,C=go(i,e,()=>t,()=>l,()=>c,p,v),R=u=>{if(!(!t.drag||l)&&r===null&&u.isPrimary!==!1){u.preventDefault(),r=u.pointerId,s={x:u.clientX,y:u.clientY},o.style.cursor="grabbing";try{u.target.setPointerCapture(u.pointerId)}catch{}t.animate&&t.animate.pauseOnInteraction&&(c=!0),h("start",p)}},I=u=>{if(r===null||u.pointerId!==r||!t.drag||l)return;u.preventDefault();let m=u.clientX-s.x,A=u.clientY-s.y;s={x:u.clientX,y:u.clientY};let k=Bn(t.invert),N=m/4*k,X=A/4*k,w=e.camera.state;if(u.shiftKey){let ee=w.rotX??65,te=w.rotY??45,ne=Math.max(.01,w.zoom??1),Pe=Math.cos(ee*Math.PI/180),K=Pe>=0?Math.max(.1,Pe):Math.min(-.1,Pe),be=Math.cos(te*Math.PI/180),Se=Math.sin(te*Math.PI/180),Ee=ne*ys.BASE_TILE,it=(m*Se-A*be/K)/Ee,Ne=-(m*be+A*Se/K)/Ee,mt=w.target??[0,0,0];e.camera.update({target:[mt[0]+it,mt[1]+Ne,mt[2]]})}else{let ee=Math.max(0,Math.min(89,(w.rotX??65)-X)),te=(((w.rotY??45)-N)%360+360)%360;e.camera.update({rotX:ee,rotY:te})}e.applyCamera(),v(p)},z=u=>{if(r===u.pointerId){r=null,o.style.cursor=t.drag&&!l?"grab":"";try{u.target.releasePointerCapture(u.pointerId)}catch{}t.animate&&t.animate.pauseOnInteraction&&(c=!1),h("end",p)}},D=fo(e,()=>t,()=>l,p,v,h);function q(){o.addEventListener("pointerdown",R),o.addEventListener("pointermove",I),o.addEventListener("pointerup",z),o.addEventListener("pointercancel",z),o.addEventListener("wheel",D.onWheel,{passive:!1}),o.style.cursor=t.drag?"grab":"",o.style.touchAction="none",o.style.userSelect="none"}function Z(){o.removeEventListener("pointerdown",R),o.removeEventListener("pointermove",I),o.removeEventListener("pointerup",z),o.removeEventListener("pointercancel",z),o.removeEventListener("wheel",D.onWheel),o.style.cursor="",o.style.touchAction="",o.style.userSelect="",D.teardown()}q(),C.start();function M(u){let m=!!t.animate;t=mn(t,u),!l&&r===null&&(o.style.cursor=t.drag?"grab":"");let A=!!t.animate;m&&!A?C.stop():!m&&A&&C.start()}function V(){l&&(l=!1,q(),C.start())}function B(){l||(l=!0,Z(),C.stop(),r=null,c=!1,D.teardown())}function F(){B(),y.length=0,g.length=0,b.length=0}function ae(u,m){let A=x(u);A.includes(m)||A.push(m)}function P(u,m){let A=x(u),k=A.indexOf(m);k>=0&&A.splice(k,1)}function L(u,m){return x(u).includes(m)}return{update:M,resume:V,pause:B,destroy:F,addEventListener:ae,removeEventListener:P,hasEventListener:L}}var bs=require("@layoutit/polycss-core");function yo(e,n={}){let t=mn(mo,n),o=e.host,i=o.ownerDocument?.defaultView??globalThis,r=null,s={x:0,y:0},c=!1,l=!1,d=!1,p={x:0,y:0},y=fn(),g=gn(e),{changeListeners:b,startListeners:x,endListeners:v,listenerArray:h,emitChange:C,emitInteraction:R}=y,I=go(i,e,()=>t,()=>l,()=>c,g,C),z=w=>{if(!(!t.drag||l)&&r===null&&w.isPrimary!==!1){w.preventDefault(),r=w.pointerId,s={x:w.clientX,y:w.clientY},o.style.cursor="grabbing";try{w.target.setPointerCapture(w.pointerId)}catch{}t.animate&&t.animate.pauseOnInteraction&&(c=!0),R("start",g)}},D=w=>{if(r===null||w.pointerId!==r||!t.drag||l)return;w.preventDefault();let ee=w.clientX-s.x,te=w.clientY-s.y;s={x:w.clientX,y:w.clientY};let ne=e.camera.state;if(w.shiftKey){let Pe=Bn(t.invert),K=ee/4*Pe,be=te/4*Pe,Se=(ne.rotX??65)-be,Ee=(((ne.rotY??45)-K)%360+360)%360;e.camera.update({rotX:Se,rotY:Ee})}else{let Pe=ne.rotX??65,K=ne.rotY??45,be=Math.max(.01,ne.zoom??1),Se=Math.cos(Pe*Math.PI/180),Ee=Se>=0?Math.max(.1,Se):Math.min(-.1,Se),it=Math.cos(K*Math.PI/180),Ne=Math.sin(K*Math.PI/180),mt=be*bs.BASE_TILE,Sn=(ee*Ne-te*it/Ee)/mt,Tt=-(ee*it+te*Ne/Ee)/mt,ft=ne.target??[0,0,0];e.camera.update({target:[ft[0]+Sn,ft[1]+Tt,ft[2]]})}e.applyCamera(),C(g)},q=w=>{if(r===w.pointerId){r=null,o.style.cursor=t.drag&&!l?"grab":"";try{w.target.releasePointerCapture(w.pointerId)}catch{}t.animate&&t.animate.pauseOnInteraction&&(c=!1),R("end",g)}},Z=w=>{w.preventDefault()},M=w=>{w.button===2&&(d=!0,p={x:w.clientX,y:w.clientY},t.animate&&t.animate.pauseOnInteraction&&(c=!0),R("start",g))},V=w=>{if(!d||!t.drag)return;let ee=w.clientX-p.x,te=w.clientY-p.y;p={x:w.clientX,y:w.clientY};let ne=Bn(t.invert),Pe=ee/4*ne,K=te/4*ne,be=e.camera.state,Se=(be.rotX??65)-K,Ee=(((be.rotY??45)-Pe)%360+360)%360;e.camera.update({rotX:Se,rotY:Ee}),e.applyCamera(),C(g)},B=w=>{w.button===2&&d&&(d=!1,R("end",g))},F=fo(e,()=>t,()=>l,g,C,R);function ae(){o.addEventListener("pointerdown",z),o.addEventListener("pointermove",D),o.addEventListener("pointerup",q),o.addEventListener("pointercancel",q),o.addEventListener("wheel",F.onWheel,{passive:!1}),o.addEventListener("contextmenu",Z),o.addEventListener("mousedown",M),o.addEventListener("mousemove",V),o.addEventListener("mouseup",B),o.style.cursor=t.drag?"grab":"",o.style.touchAction="none",o.style.userSelect="none"}function P(){o.removeEventListener("pointerdown",z),o.removeEventListener("pointermove",D),o.removeEventListener("pointerup",q),o.removeEventListener("pointercancel",q),o.removeEventListener("wheel",F.onWheel),o.removeEventListener("contextmenu",Z),o.removeEventListener("mousedown",M),o.removeEventListener("mousemove",V),o.removeEventListener("mouseup",B),o.style.cursor="",o.style.touchAction="",o.style.userSelect="",F.teardown()}ae(),I.start();function L(w){let ee=!!t.animate;t=mn(t,w),!l&&r===null&&(o.style.cursor=t.drag?"grab":"");let te=!!t.animate;ee&&!te?I.stop():!ee&&te&&I.start()}function u(){l&&(l=!1,ae(),I.start())}function m(){l||(l=!0,P(),I.stop(),r=null,c=!1,d=!1,F.teardown())}function A(){m(),b.length=0,x.length=0,v.length=0}function k(w,ee){let te=h(w);te.includes(ee)||te.push(ee)}function N(w,ee){let te=h(w),ne=te.indexOf(ee);ne>=0&&te.splice(ne,1)}function X(w,ee){return h(w).includes(ee)}return{update:L,resume:u,pause:m,destroy:A,addEventListener:k,removeEventListener:N,hasEventListener:X}}var Es=require("@layoutit/polycss-core");var Hl={enabled:!0,lookEnabled:!0,moveEnabled:!0,jumpEnabled:!0,crouchEnabled:!0,lookSensitivity:.15,invertY:!1,moveSpeed:5,jumpVelocity:7,gravity:18,eyeHeight:1.7,crouchHeight:1,groundZ:0,minPitch:5,maxPitch:175};function xs(e,n){return{enabled:n.enabled??e.enabled,lookEnabled:n.lookEnabled??e.lookEnabled,moveEnabled:n.moveEnabled??e.moveEnabled,jumpEnabled:n.jumpEnabled??e.jumpEnabled,crouchEnabled:n.crouchEnabled??e.crouchEnabled,lookSensitivity:n.lookSensitivity??e.lookSensitivity,invertY:n.invertY??e.invertY,moveSpeed:n.moveSpeed??e.moveSpeed,jumpVelocity:n.jumpVelocity??e.jumpVelocity,gravity:n.gravity??e.gravity,eyeHeight:n.eyeHeight??e.eyeHeight,crouchHeight:n.crouchHeight??e.crouchHeight,groundZ:n.groundZ??e.groundZ,minPitch:n.minPitch??e.minPitch,maxPitch:n.maxPitch??e.maxPitch}}var Ps=new Set(["KeyW","ArrowUp"]),vs=new Set(["KeyS","ArrowDown"]),Ss=new Set(["KeyA","ArrowLeft"]),Cs=new Set(["KeyD","ArrowRight"]),Ts=new Set(["Space"]),zr=new Set(["ControlLeft","ControlRight"]);function bo(e,n={}){let t=xs(Hl,n),o=e.host,i=e.cameraEl,r=o.ownerDocument??document,s=r.defaultView??globalThis,c=fn(),l=gn(e),{changeListeners:d,startListeners:p,endListeners:y,listenerArray:g,emitChange:b,emitInteraction:x}=c,v=new Set,h=!1,C=!1,R=0,I=0,z=!1,D=[0,0,t.groundZ+t.eyeHeight];function q(W,pe){let me=W*Math.PI/180,je=pe*Math.PI/180;return[-Math.sin(me)*Math.cos(je),-Math.sin(me)*Math.sin(je),-Math.cos(me)]}function Z(){let W=e.camera.perspectiveStyle,pe=W==="none"?0:parseFloat(W);return(Number.isFinite(pe)&&pe>0?pe:2e3)/Es.BASE_TILE}function M(){let W=e.camera.state,pe=q(W.rotX??90,W.rotY??0),me=Z();return[D[0]+pe[0]*me,D[1]+pe[1]*me,D[2]+pe[2]*me]}function V(){let W=M();e.camera.update({target:W}),e.applyCamera()}function B(){let W=e.camera.state.target??[0,0,0];D=[W[0],W[1],t.groundZ+t.eyeHeight],V()}let F=()=>{if(!(!t.enabled||!t.lookEnabled||C||h))try{o.requestPointerLock()}catch{}},ae=()=>{let W=r.pointerLockElement===o;W!==h&&(h=W,h?(z=!0,x("start",l)):z&&(z=!1,x("end",l)))},P=W=>{if(!h||!t.enabled||!t.lookEnabled||C)return;let pe=W.movementX??0,me=W.movementY??0;if(pe===0&&me===0)return;let je=e.camera.state,Tn=t.lookSensitivity,En=t.invertY?-1:1,zt=(((je.rotY??0)-pe*Tn)%360+360)%360,He=(je.rotX??90)-me*Tn*En;He<t.minPitch?He=t.minPitch:He>t.maxPitch&&(He=t.maxPitch);let Ze=q(He,zt),st=Z(),$e=[D[0]+Ze[0]*st,D[1]+Ze[1]*st,D[2]+Ze[2]*st];e.camera.update({rotX:He,rotY:zt,target:$e}),e.applyCamera(),b(l)},L=W=>Ps.has(W)||vs.has(W)||Ss.has(W)||Cs.has(W)||Ts.has(W)||zr.has(W),u=W=>{if(!(!t.enabled||C)&&L(W.code)&&!(!h&&!t.moveEnabled)){if(Ts.has(W.code)){if(!t.jumpEnabled)return;W.preventDefault(),!v.has(W.code)&&R===0&&I===0&&(R=t.jumpVelocity),v.add(W.code);return}zr.has(W.code)&&!t.crouchEnabled||!t.moveEnabled&&!zr.has(W.code)||(W.preventDefault(),v.add(W.code))}},m=W=>{L(W.code)&&v.delete(W.code)},A=()=>{v.clear()},k=null,N=0,X=.05,w=W=>{if(k===null||C)return;let pe=Math.min(X,N?(W-N)/1e3:.0167);if(N=W,t.enabled){let me=!1,je=e.camera.state;if(t.moveEnabled){let He=0,Ze=0;for(let st of v)Ps.has(st)?He+=1:vs.has(st)?He-=1:Cs.has(st)?Ze+=1:Ss.has(st)&&(Ze-=1);if(He!==0||Ze!==0){let $e=(je.rotY??0)*Math.PI/180,We=-Math.cos($e),Wn=-Math.sin($e),tr=-Math.sin($e),Un=Math.cos($e),Zt=Math.hypot(He,Ze)||1,Ge=t.moveSpeed*pe;D[0]+=(We*He+tr*Ze)/Zt*Ge,D[1]+=(Wn*He+Un*Ze)/Zt*Ge,me=!0}}let En=t.crouchEnabled&&(v.has("ControlLeft")||v.has("ControlRight"))?t.crouchHeight:t.eyeHeight;t.jumpEnabled&&(R!==0||I>0)?(R-=t.gravity*pe,I+=R*pe,I<=0&&(I=0,R=0)):t.jumpEnabled||(I=0,R=0);let zt=t.groundZ+En+I;if(Math.abs(D[2]-zt)>1e-4&&(D[2]=zt,me=!0),me){let He=M();e.camera.update({target:He}),e.applyCamera(),b(l)}}k=s.requestAnimationFrame(w)};function ee(){k!==null||C||(N=0,k=s.requestAnimationFrame(w))}function te(){k!==null&&(s.cancelAnimationFrame(k),k=null)}function ne(){let pe=i.ownerDocument?.defaultView?.getComputedStyle(i).perspective??"",me=parseFloat(pe),je=Number.isFinite(me)&&me>0?me:2e3;i.style.setProperty("--polycss-fpv-perspective",`${je}px`),i.classList.add("polycss-fpv-host")}function Pe(){i.classList.remove("polycss-fpv-host"),i.style.removeProperty("--polycss-fpv-perspective")}function K(){o.addEventListener("click",F),r.addEventListener("pointerlockchange",ae),r.addEventListener("mousemove",P),s.addEventListener("keydown",u),s.addEventListener("keyup",m),s.addEventListener("blur",A),o.style.cursor=t.lookEnabled?"crosshair":"",ne()}function be(){if(o.removeEventListener("click",F),r.removeEventListener("pointerlockchange",ae),r.removeEventListener("mousemove",P),s.removeEventListener("keydown",u),s.removeEventListener("keyup",m),s.removeEventListener("blur",A),o.style.cursor="",v.clear(),h)try{r.exitPointerLock()}catch{}Pe()}B(),K(),ee();function Se(W){let pe=t.eyeHeight,me=t.groundZ;t=xs(t,W),C||(o.style.cursor=t.lookEnabled?"crosshair":""),(t.eyeHeight!==pe||t.groundZ!==me)&&(D[2]=t.groundZ+t.eyeHeight,V(),b(l))}function Ee(){C&&(C=!1,K(),ee())}function it(){C||(C=!0,be(),te(),z&&(z=!1,x("end",l)))}function Ne(){it(),d.length=0,p.length=0,y.length=0}function mt(){if(!(!t.enabled||!t.lookEnabled||C))try{o.requestPointerLock()}catch{}}function Sn(){if(h)try{r.exitPointerLock()}catch{}}function Tt(){return h}function ft(W,pe){let me=g(W);me.includes(pe)||me.push(pe)}function Jo(W,pe){let me=g(W),je=me.indexOf(pe);je>=0&&me.splice(je,1)}function er(W,pe){return g(W).includes(pe)}function Cn(){return[D[0],D[1],D[2]]}function $n(W){D[0]=W[0],D[1]=W[1],D[2]=W[2],V(),b(l)}return{update:Se,resume:Ee,pause:it,destroy:Ne,lock:mt,unlock:Sn,isLocked:Tt,getOrigin:Cn,setOrigin:$n,addEventListener:ft,removeEventListener:Jo,hasEventListener:er}}function hn(e,n,t){let o=Array.from(e.querySelectorAll("i,b,s,u"));for(let i of o){let r=i.getBoundingClientRect();if(!(r.width<=0||r.height<=0)&&n>=r.left&&n<=r.right&&t>=r.top&&t<=r.bottom)return!0}return!1}function As(e,n,t,o){for(let i of e)if(!(o&&!o(i))&&hn(i.element,n,t))return i;return null}function xo(e,n={}){let t=[],o=new Set;n.onChange&&o.add(n.onChange);function i(){t=n.filter?n.filter(t):t;for(let v of o)try{v(t)}catch(h){console.error("[polycss/createSelect] onChange threw:",h)}}function r(x){t=x,i()}function s(x){n.multiple?t.includes(x)||(t=[...t,x]):t=[x],i()}function c(x){t.includes(x)&&(t=t.filter(v=>v!==x),i())}function l(x){t.includes(x)?t=t.filter(v=>v!==x):n.multiple?t=[...t,x]:t=[x],i()}function d(){t.length!==0&&(t=[],i())}function p(x){return t.includes(x)}function y(x,v){return As(e.meshes(),x,v,h=>!h.element.classList.contains("polycss-transform-gizmo"))}let g=x=>{let v=x.target;if(v?.closest(".polycss-transform-gizmo"))return;let h=e.findMeshByElement(v)??y(x.clientX,x.clientY);if(!h){n.onPointerMissed&&n.onPointerMissed(x),n.clearOnMiss!==!1&&d();return}n.multiple&&(x.shiftKey||x.metaKey||x.ctrlKey)?l(h):t.length===1&&t[0]===h?d():r([h])};e.host.addEventListener("click",g);function b(){e.host.removeEventListener("click",g),o.clear()}return{get selected(){return t},set:r,add:s,remove:c,toggle:l,clear:d,has:p,destroy:b}}var Ie=require("@layoutit/polycss-core");var Po="#ff3653",vo="#8adb00",So="#2c8fff",yn=50,ws=60,Fl=.6,zl=.0125,Bl=.15,Vl=.04,Nl=1,Ms=.02,Br=1.04,jl=.1,$l=.25,_s=1e-4,Wl=.6,Ul=.8,Gl=1,St={0:1,1:0,2:2},Ls=[{cssAxis:0,sign:1,key:"x",color:Po},{cssAxis:0,sign:-1,key:"-x",color:Po},{cssAxis:1,sign:1,key:"y",color:vo},{cssAxis:1,sign:-1,key:"-y",color:vo},{cssAxis:2,sign:1,key:"z",color:So},{cssAxis:2,sign:-1,key:"-z",color:So}],Rs=[{cssAxis:0,key:"x",color:Po},{cssAxis:1,key:"y",color:vo},{cssAxis:2,key:"z",color:So}],ks=[{perpAxis:2,axisA:0,axisB:1,key:"xy",color:So},{perpAxis:1,axisA:0,axisB:2,key:"xz",color:vo},{perpAxis:0,axisA:1,axisB:2,key:"yz",color:Po}];function Vr(e,n,t,o){let i=t*Math.PI/180,r=o*Math.PI/180,s=[0,0,0];s[e]=n;let c=s[0]*Math.cos(r)-s[1]*Math.sin(r),l=s[0]*Math.sin(r)+s[1]*Math.cos(r),d=s[2];return l*Math.sin(i)+d*Math.cos(i)<0}function Yl(e,n){let t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!t)return e;let o=parseInt(t[1],16),i=parseInt(t[2],16),r=parseInt(t[3],16);return`rgba(${o}, ${i}, ${r}, ${n})`}function Co(e,n){return!n||n<=0?e:Math.round(e/n)*n}function Xl(e){if(e.length===0)return[0,0,0];let n=1/0,t=1/0,o=1/0,i=-1/0,r=-1/0,s=-1/0;for(let c of e)for(let l of c.vertices)l[0]<n&&(n=l[0]),l[0]>i&&(i=l[0]),l[1]<t&&(t=l[1]),l[1]>r&&(r=l[1]),l[2]<o&&(o=l[2]),l[2]>s&&(s=l[2]);return Number.isFinite(n)?[(n+i)/2,(t+r)/2,(o+s)/2]:[0,0,0]}function Nr(e){if(e.length===0)return ws;let n=1/0,t=1/0,o=1/0,i=-1/0,r=-1/0,s=-1/0;for(let l of e)for(let d of l.vertices)d[0]<n&&(n=d[0]),d[0]>i&&(i=d[0]),d[1]<t&&(t=d[1]),d[1]>r&&(r=d[1]),d[2]<o&&(o=d[2]),d[2]>s&&(s=d[2]);return Number.isFinite(n)?Math.max(i-n,r-t,s-o)*yn*Fl:ws}function ql(e){let{cssAxis:n,sign:t,shaftLengthCss:o,wrapper:i,target:r,startClientX:s,startClientY:c,translationSnap:l,onAxisDelta:d,onMouseDown:p,onMouseUp:y,onDraggingChanged:g}=e,b=o,x=[0,0,0];x[n]=t;let v=i.ownerDocument.createElement("div");v.style.position="absolute",v.style.left="0",v.style.top="0",v.style.width="0",v.style.height="0",v.style.transform=`translate3d(${x[0]*b}px, ${x[1]*b}px, ${x[2]*b}px)`,i.appendChild(v);let h=i.getBoundingClientRect(),C=v.getBoundingClientRect();i.removeChild(v);let R=(C.left-h.left)/b,I=(C.top-h.top)/b,z=R*R+I*I;if(z<_s)return;p?.(),g?.(!0);let D=Z=>{let M=Z.clientX-s,V=Z.clientY-c,B=(M*R+V*I)/z;B=Co(B,l),d(B,x)},q=()=>{window.removeEventListener("pointermove",D),window.removeEventListener("pointerup",q),window.removeEventListener("pointercancel",q);let Z=M=>{M.stopPropagation(),M.stopImmediatePropagation()};window.addEventListener("click",Z,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",Z,!0),0),y?.(),g?.(!1)};window.addEventListener("pointermove",D),window.addEventListener("pointerup",q),window.addEventListener("pointercancel",q)}function Zl(e){let{axisA:n,axisB:t,probeDistanceCss:o,wrapper:i,startClientX:r,startClientY:s,translationSnap:c,onPlaneDelta:l,onMouseDown:d,onMouseUp:p,onDraggingChanged:y}=e,g=[0,0,0];g[n]=1;let b=[0,0,0];b[t]=1;function x(z){let D=i.ownerDocument.createElement("div");D.style.position="absolute",D.style.left="0",D.style.top="0",D.style.width="0",D.style.height="0",D.style.transform=`translate3d(${z[0]*o}px, ${z[1]*o}px, ${z[2]*o}px)`,i.appendChild(D);let q=i.getBoundingClientRect(),Z=D.getBoundingClientRect();return i.removeChild(D),{x:(Z.left-q.left)/o,y:(Z.top-q.top)/o}}let v=x(g),h=x(b),C=v.x*h.y-h.x*v.y;if(Math.abs(C)<_s)return;d?.(),y?.(!0);let R=z=>{let D=z.clientX-r,q=z.clientY-s,Z=(h.y*D-h.x*q)/C,M=(-v.y*D+v.x*q)/C;Z=Co(Z,c),M=Co(M,c),l(Z,M,g,b)},I=()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",I),window.removeEventListener("pointercancel",I);let z=D=>{D.stopPropagation(),D.stopImmediatePropagation()};window.addEventListener("click",z,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",z,!0),0),p?.(),y?.(!1)};window.addEventListener("pointermove",R),window.addEventListener("pointerup",I),window.addEventListener("pointercancel",I)}function Ql(e){let{cssAxis:n,wrapper:t,target:o,startClientX:i,startClientY:r,rotationSnap:s,onAngleDelta:c,onMouseDown:l,onMouseUp:d,onDraggingChanged:p}=e,y=t.getBoundingClientRect(),g=y.left,b=y.top,x=Math.atan2(r-b,i-g),v=0;l?.(),p?.(!0);let h=R=>{let I=Math.atan2(R.clientY-b,R.clientX-g),z=I-x;z>Math.PI?z-=2*Math.PI:z<-Math.PI&&(z+=2*Math.PI),v+=z,x=I;let D=v*180/Math.PI;D=Co(D,s),c(D)},C=()=>{window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C);let R=I=>{I.stopPropagation(),I.stopImmediatePropagation()};window.addEventListener("click",R,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",R,!0),0),d?.(),p?.(!1)};window.addEventListener("pointermove",h),window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C)}function To(e,n={}){let t=null,o=n.mode??"translate",i=n.size??1,r={...n},s=new Map,c=null,l=null,d=[0,0,0];function p(){if(!t)return[0,0,0];let P=t.transform.position??[0,0,0],L=t.transform.rotation??[0,0,0],u=typeof t.transform.scale=="number"?t.transform.scale:t.transform.scale?.[0]??1,m=(0,Ie.rotateVec3)(d,L[0],L[1],L[2]);return[P[0]+u*m[0],P[1]+u*m[1],P[2]+u*m[2]]}function y(P){return l===P?Gl:c===P?Ul:Wl}function g(){for(let[P,L]of s){let u=b(L.spec,y(P));L.handle.setPolygons(u,{recomputeAutoCenter:!1})}}function b(P,L){let m=Nr(t?.polygons??[])*i,A=m/yn,k=Yl(P.color,L);if(P.kind==="arrow"){let w=e.camera.state,ee=Vr(P.cssAxis,P.sign,w.rotX??65,w.rotY??45);return(0,Ie.arrowPolygons)({axis:St[P.cssAxis],sign:P.sign,shaftLength:A,shaftHalfThickness:A*zl,headLength:A*Bl,headHalfThickness:A*Vl,color:k,shaft:!ee})}if(P.kind==="plane"){let w=e.camera.state,ee=w.rotX??65,te=w.rotY??45,ne=St[P.perpAxis],Pe=(ne+1)%3,K=(ne+2)%3,be=St[Pe],Se=St[K],Ee=Vr(be,1,ee,te)?-1:1,it=Vr(Se,1,ee,te)?-1:1,Ne=A*$l;return(0,Ie.planePolygons)({axis:ne,size:A*jl,offset:[Ee*Ne,it*Ne],color:k})}let X=m*Nl/yn*Br;return(0,Ie.ringQuadPolygons)({axis:St[P.cssAxis],outerRadius:X,color:k})}function x(P){return P.kind==="arrow"?"polycss-transform-arrow":P.kind==="plane"?"polycss-transform-plane":"polycss-transform-ring"}function v(){if(o==="translate"){let P=Ls.map(u=>({kind:"arrow",key:u.key,cssAxis:u.cssAxis,sign:u.sign,color:u.color})),L=ks.map(u=>({kind:"plane",key:u.key,perpAxis:u.perpAxis,axisA:u.axisA,axisB:u.axisB,color:u.color}));return[...P,...L]}return o==="rotate"?Rs.map(P=>({kind:"ring",key:P.key,cssAxis:P.cssAxis,color:P.color})):[]}function h(){if(C(),!t)return;let P={x:r.showX!==!1,y:r.showY!==!1,z:r.showZ!==!1};function L(m){if(m.kind==="arrow"){let N=m.key.replace("-","")[0];return P[N]}if(m.kind==="ring")return P[m.key];let A=["x","y","z"][m.axisA],k=["x","y","z"][m.axisB];return P[A]&&P[k]}let u=p();for(let m of v()){if(!L(m))continue;let A=b(m,y(m.key)),k=e.add({polygons:A,objectUrls:[],warnings:[],dispose:()=>{}},{excludeFromAutoCenter:!0,id:`__poly-gizmo-${m.key}`,position:u}),N=x(m);if(k.element.classList.add("polycss-transform-gizmo",N,`${N}--${m.key}`),m.kind==="ring"){let X=(1-Ms)/Br,w=(1+Ms)/Br;k.element.style.setProperty("--ring-inner-ratio",`${X}`),k.element.style.setProperty("--ring-outer-ratio",`${w}`)}s.set(m.key,{handle:k,spec:m})}}function C(){for(let{handle:P}of s.values())P.remove();s.clear(),c=null,l=null}function R(){if(!t)return;let P=p();for(let{handle:L}of s.values())L.setTransform({position:P})}function I(){t&&(s.size===0?h():R())}function z(P){if(t=P,!P){d=[0,0,0],C();return}d=Xl(P.polygons),C(),h()}function D(){z(null)}function q(P){P!==o&&(o=P,t&&(C(),h()))}function Z(P,L,u){if(!t||!M)return;let m=u[P.cssAxis],A=St[P.cssAxis],k=L*m/yn,N=M.slice();N[A]=M[A]+k,t.setTransform({position:N}),R(),r.onObjectChange?.({object:t,position:N}),r.onChange?.()}let M=null,V=null,B=P=>{if(!t||r.enabled===!1)return;let L={x:r.showX!==!1,y:r.showY!==!1,z:r.showZ!==!1};if(o==="translate"){for(let u of ks){let m=["x","y","z"][u.axisA],A=["x","y","z"][u.axisB];if(!L[m]||!L[A])continue;let k=s.get(u.key);if(k&&hn(k.handle.element,P.clientX,P.clientY)){P.preventDefault(),P.stopPropagation(),l=u.key,g(),M=(t.transform.position??[0,0,0]).slice(),Zl({axisA:u.axisA,axisB:u.axisB,probeDistanceCss:Nr(t.polygons)*i,wrapper:k.handle.element,target:t,startClientX:P.clientX,startClientY:P.clientY,translationSnap:r.translationSnap??null,onPlaneDelta:(N,X,w,ee)=>{if(!t||!M)return;let te=w[u.axisA],ne=ee[u.axisB],Pe=St[u.axisA],K=St[u.axisB],be=M.slice();be[Pe]+=N*te/yn,be[K]+=X*ne/yn,t.setTransform({position:be}),R(),r.onObjectChange?.({object:t,position:be}),r.onChange?.()},onMouseDown:r.onMouseDown,onMouseUp:r.onMouseUp,onDraggingChanged:N=>{N||(l=null,M=null,g()),r.onDraggingChanged?.(N)}});return}}for(let u of Ls){let m=u.key.replace("-","")[0];if(!L[m])continue;let A=s.get(u.key);if(A&&hn(A.handle.element,P.clientX,P.clientY)){P.preventDefault(),P.stopPropagation(),l=u.key,g(),M=(t.transform.position??[0,0,0]).slice(),ql({cssAxis:u.cssAxis,sign:u.sign,shaftLengthCss:Nr(t.polygons)*i,wrapper:A.handle.element,target:t,startClientX:P.clientX,startClientY:P.clientY,translationSnap:r.translationSnap??null,onAxisDelta:(k,N)=>Z(u,k,N),onMouseDown:r.onMouseDown,onMouseUp:r.onMouseUp,onDraggingChanged:k=>{k||(l=null,M=null,g()),r.onDraggingChanged?.(k)}});return}}}else if(o==="rotate")for(let u of Rs){if(!L[u.key])continue;let m=s.get(u.key);if(m&&hn(m.handle.element,P.clientX,P.clientY)){P.preventDefault(),P.stopPropagation(),l=u.key,g(),V=(t.transform.rotation??[0,0,0]).slice(),M=(t.transform.position??[0,0,0]).slice(),Ql({cssAxis:u.cssAxis,wrapper:m.handle.element,target:t,startClientX:P.clientX,startClientY:P.clientY,rotationSnap:r.rotationSnap??null,onAngleDelta:A=>{if(!t||!V||!M)return;let k=St[u.cssAxis],N=[0,0,0];N[k]=1;let X=-A*Math.PI/180,w=(0,Ie.quatFromEulerXYZ)(V),ee=(0,Ie.quatFromAxisAngle)(N,X),te=(0,Ie.eulerXYZFromQuat)((0,Ie.quatMultiply)(ee,w)),ne=typeof t.transform.scale=="number"?t.transform.scale:t.transform.scale?.[0]??1,Pe=(0,Ie.rotateVec3)(d,V[0],V[1],V[2]),K=(0,Ie.rotateVec3)(d,te[0],te[1],te[2]),be=[M[0]+ne*(Pe[0]-K[0]),M[1]+ne*(Pe[1]-K[1]),M[2]+ne*(Pe[2]-K[2])];t.setTransform({rotation:te,position:be}),R(),r.onObjectChange?.({object:t,rotation:te,position:be}),r.onChange?.()},onMouseDown:r.onMouseDown,onMouseUp:r.onMouseUp,onDraggingChanged:A=>{A||(l=null,V=null,M=null,g(),t?.rebakeAtlas()),r.onDraggingChanged?.(A)}});return}}};e.host.addEventListener("pointerdown",B,{capture:!0});let F=P=>{if(!t||l||r.enabled===!1)return;let L=null;for(let[u,m]of s)if(hn(m.handle.element,P.clientX,P.clientY)){L=u;break}L!==c&&(c=L,g())};e.host.addEventListener("pointermove",F);function ae(){e.host.removeEventListener("pointerdown",B,{capture:!0}),e.host.removeEventListener("pointermove",F),C()}return{attach:z,detach:D,setMode:q,update:I,destroy:ae}}var Kl=typeof HTMLElement<"u"?HTMLElement:class{},Jl=["perspective","rot-x","rot-y","zoom","directional-direction","directional-color","directional-intensity","ambient-color","ambient-intensity","texture-lighting","texture-quality","texture-leaf-sizing","texture-image-rendering","texture-backend","texture-projection","auto-center"];function rt(e){if(e==null)return;let n=parseFloat(e);return Number.isFinite(n)?n:void 0}function ec(e){return e==="false"?!1:rt(e)}function jr(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function tc(e){if(e==="baked"||e==="dynamic")return e}function nc(e){return e==="auto"?"auto":rt(e)}function oc(e){if(e==="canonical"||e==="local"||e==="raster")return e}function rc(e){if(e==="auto"||e==="pixelated")return e}function ic(e){if(e==="auto"||e==="atlas"||e==="image")return e}function sc(e){if(e==="affine"||e==="projective")return e}function ac(e){return typeof e.getCamera=="function"}var Ue=class extends Kl{constructor(){super(...arguments);this._scene=null;this._implicitCamera=null}static get observedAttributes(){return[...Jl]}getScene(){return this._scene}_findAncestorCamera(){let t=this.parentElement;for(;t;){if(ac(t)){let o=t.getCamera();if(o)return o}t=t.parentElement}return null}_buildImplicitCamera(){let t=ec(this.getAttribute("perspective")),o=rt(this.getAttribute("rot-x")),i=rt(this.getAttribute("rot-y")),r=rt(this.getAttribute("zoom")),s=rt(this.getAttribute("distance")),c=jr(this.getAttribute("target")),l={...o!==void 0?{rotX:o}:{},...i!==void 0?{rotY:i}:{},...r!==void 0?{zoom:r}:{},...s!==void 0?{distance:s}:{},...c!==void 0?{target:c}:{}};return t===!1?ut(l):t!==void 0?vt({...l,perspective:t}):ut(l)}_readNonCameraOptions(){let t=this._readDirectionalLight(),o=this._readAmbientLight(),i={};i.textureLighting=tc(this.getAttribute("texture-lighting"))??"baked";let r=nc(this.getAttribute("texture-quality"));r!==void 0&&(i.textureQuality=r),i.textureLeafSizing=oc(this.getAttribute("texture-leaf-sizing"))??"canonical";let s=rc(this.getAttribute("texture-image-rendering"));s!==void 0&&(i.textureImageRendering=s);let c=ic(this.getAttribute("texture-backend"));c!==void 0&&(i.textureBackend=c);let l=sc(this.getAttribute("texture-projection"));return l!==void 0&&(i.textureProjection=l),i.autoCenter=this.hasAttribute("auto-center"),t&&(i.directionalLight=t),o&&(i.ambientLight=o),i}_readDirectionalLight(){let t=jr(this.getAttribute("directional-direction")),o=this.getAttribute("directional-color")||void 0,i=rt(this.getAttribute("directional-intensity"));if(!t&&!o&&i===void 0)return;let r={direction:t??[.4,-.7,.59]};return o&&(r.color=o),i!==void 0&&(r.intensity=i),r}_readAmbientLight(){let t=this.getAttribute("ambient-color")||void 0,o=rt(this.getAttribute("ambient-intensity"));if(!t&&o===void 0)return;let i={};return t&&(i.color=t),o!==void 0&&(i.intensity=o),i}connectedCallback(){if(this._scene)return;let t=this._findAncestorCamera(),o;t?(o=t,this._implicitCamera=null):(this._implicitCamera=this._buildImplicitCamera(),o=this._implicitCamera),this._scene=Yt(this,{camera:o,...this._readNonCameraOptions()}),this.dispatchEvent(new CustomEvent("polycss:scene-ready",{bubbles:!1}))}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null),this._implicitCamera=null}attributeChangedCallback(t,o,i){if(o!==i&&this._scene){if(this._implicitCamera&&["rot-x","rot-y","zoom","distance","target"].includes(t)){let s=rt(this.getAttribute("rot-x")),c=rt(this.getAttribute("rot-y")),l=rt(this.getAttribute("zoom")),d=rt(this.getAttribute("distance")),p=jr(this.getAttribute("target"));s!==void 0&&this._implicitCamera.update({rotX:s}),c!==void 0&&this._implicitCamera.update({rotY:c}),l!==void 0&&this._implicitCamera.update({zoom:l}),d!==void 0&&this._implicitCamera.update({distance:d}),p!==void 0&&this._implicitCamera.update({target:p}),this._scene.applyCamera();return}this._scene.setOptions(this._readNonCameraOptions())}}};var Eo=require("@layoutit/polycss-core"),lc=typeof HTMLElement<"u"?HTMLElement:class{},cc=["src","mtl","mesh-resolution","position","scale","rotation","auto-center","cast-shadow","receive-shadow","target-size","default-color","palette","include-objects","exclude-objects"];function Vn(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function Os(e){if(e){if(!e.includes(",")){let n=parseFloat(e);return Number.isFinite(n)?n:void 0}return Vn(e)}}function $r(e){if(!e)return;let n=e.split(",").map(t=>t.trim()).filter(t=>t.length>0);return n.length>0?n:void 0}function uc(e){let n=e.getAttribute("target-size"),t=e.getAttribute("default-color"),o=$r(e.getAttribute("palette")),i=$r(e.getAttribute("include-objects")),r=$r(e.getAttribute("exclude-objects")),s=n!==null?parseFloat(n):NaN,c={};return Number.isFinite(s)&&(c.targetSize=s),t&&(c.defaultColor=t),o&&(c.palette=o),i&&(c.includeObjects=i),r&&(c.excludeObjects=r),Object.keys(c).length>0?c:void 0}function dc(e){return e.closest("poly-scene")??null}function pc(e){if(e.length===0)return e;let n=(0,Eo.computeSceneBbox)(e),t=(n.min[0]+n.max[0])/2,o=(n.min[1]+n.max[1])/2,i=(n.min[2]+n.max[2])/2;if(t===0&&o===0&&i===0)return e;let r=s=>[s[0]-t,s[1]-o,s[2]-i];return e.map(s=>({...s,vertices:s.vertices.map(r),...s.textureTriangles?.length?{textureTriangles:s.textureTriangles.map(c=>({...c,vertices:c.vertices.map(r)}))}:null}))}var bn=class extends lc{constructor(){super(...arguments);this._handle=null;this._parseResult=null;this._loadToken=0}static get observedAttributes(){return[...cc]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(t,o,i){if(o!==i){if(t==="src"||t==="mtl"||t==="mesh-resolution"||t==="target-size"||t==="default-color"||t==="palette"||t==="include-objects"||t==="exclude-objects"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform({position:Vn(this.getAttribute("position")),scale:Os(this.getAttribute("scale")),rotation:Vn(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")})}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}this._parseResult=null}async _maybeLoad(){let t=this.getAttribute("src");if(!t)return;let o=dc(this);if(!o)return;let i=++this._loadToken,r=this.getAttribute("mtl")||void 0,c=this.getAttribute("mesh-resolution")==="lossless"?"lossless":void 0,l=uc(this),d;try{let g=r||c!==void 0||l?{...r?{mtlUrl:r}:{},...c!==void 0?{meshResolution:c}:{},...l?{objOptions:l}:{}}:void 0;d=await(0,Eo.loadMesh)(t,g)}catch(g){this.dispatchEvent(new CustomEvent("polycss:error",{detail:g,bubbles:!0}));return}if(i!==this._loadToken){try{d.dispose()}catch{}return}let p=o.getScene();if(!p){try{d.dispose()}catch{}return}this.hasAttribute("auto-center")&&(d={...d,polygons:pc(d.polygons)}),this._parseResult=d,this._handle=p.add(d,{position:Vn(this.getAttribute("position")),scale:Os(this.getAttribute("scale")),rotation:Vn(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}),this.dispatchEvent(new CustomEvent("polycss:loaded",{detail:{polygons:this._handle.polygons},bubbles:!0}))}};var xn=require("@layoutit/polycss-core"),mc=typeof HTMLElement<"u"?HTMLElement:class{},fc=["src","width","height","position","rotation","scale","allow","loading","referrerpolicy","sandbox","title"];function Wr(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function gc(e){if(e){if(!e.includes(",")){let n=parseFloat(e);return Number.isFinite(n)?n:void 0}return Wr(e)}}function Ds(e,n){if(e===null)return n;let t=parseFloat(e);return Number.isFinite(t)?t:n}function hc(e){let n=e.closest("poly-scene");return n?n.querySelector(".polycss-scene"):null}function yc(e,n,t,o,i){let r=typeof t=="number"?t:t?.[0]??1,s=typeof t=="number"?t:t?.[1]??1,c=typeof t=="number"?t:t?.[2]??1,l=r!==1||s!==1||c!==1,d=!!n&&(!!n[0]||!!n[1]||!!n[2]),p=(e?.[1]??0)*xn.BASE_TILE,y=(e?.[0]??0)*xn.BASE_TILE,g=(e?.[2]??0)*xn.BASE_TILE,b=[];return b.push(`translate3d(${p}px, ${y}px, ${g}px)`),d&&(n[0]&&b.push(`rotateY(${-n[0]}deg)`),n[1]&&b.push(`rotateX(${-n[1]}deg)`),n[2]&&b.push(`rotateZ(${-n[2]}deg)`)),l&&b.push(`scale3d(${r}, ${s}, ${c})`),b.push(`translate(${-o/2}px, ${-i/2}px)`),b.join(" ")}var Ao=class extends mc{constructor(){super(...arguments);this._wrapper=null;this._iframe=null}static get observedAttributes(){return[...fc]}getIframeElement(){return this._iframe}connectedCallback(){this._mount()}disconnectedCallback(){this._teardown()}attributeChangedCallback(t,o,i){if(o!==i&&!(!this._wrapper||!this._iframe)){if(t==="src"){this._iframe.src=this.getAttribute("src")??"";return}if(t==="allow"||t==="loading"||t==="referrerpolicy"||t==="sandbox"||t==="title"){let r=this.getAttribute(t);r===null?this._iframe.removeAttribute(t):this._iframe.setAttribute(t,r);return}this._applyGeometry()}}_mount(){let t=hc(this);if(!t)return;let o=this.ownerDocument;if(!o)return;let i=o.createElement("div");i.className="polycss-iframe",i.style.position="absolute",i.style.left="0",i.style.top="0",i.style.transformOrigin="0 0",i.style.transformStyle="preserve-3d";let r=o.createElement("iframe");r.style.display="block",r.style.border="0",r.style.background="#000";let s=this.getAttribute("src");s&&(r.src=s);let c=this.getAttribute("allow");c&&r.setAttribute("allow",c);for(let l of["loading","referrerpolicy","sandbox","title"]){let d=this.getAttribute(l);d!==null&&r.setAttribute(l,d)}i.appendChild(r),t.appendChild(i),this._wrapper=i,this._iframe=r,this._applyGeometry()}_applyGeometry(){if(!this._wrapper||!this._iframe)return;let t=Ds(this.getAttribute("width"),16),o=Ds(this.getAttribute("height"),9),i=t*xn.BASE_TILE,r=o*xn.BASE_TILE;this._iframe.style.width=`${i}px`,this._iframe.style.height=`${r}px`;let s=Wr(this.getAttribute("position")),c=Wr(this.getAttribute("rotation")),l=gc(this.getAttribute("scale"));this._wrapper.style.transform=yc(s,c,l,i,r)}_teardown(){this._wrapper?.parentNode&&this._wrapper.parentNode.removeChild(this._wrapper),this._wrapper=null,this._iframe=null}};var bc=typeof HTMLElement<"u"?HTMLElement:class{},xc=["vertices","color","texture","uvs","position","scale","rotation"];function Is(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function Ur(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function Pc(e){if(e){if(!e.includes(",")){let n=parseFloat(e);return Number.isFinite(n)?n:void 0}return Ur(e)}}function vc(e){return e.closest("poly-scene")??null}var wo=class extends bc{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return[...xc]}connectedCallback(){this._mount()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(t,o,i){o!==i&&(this._tearDown(),this.isConnected&&this._mount())}_tearDown(){if(this._handle){try{this._handle.dispose()}catch{}this._handle=null}}_mount(){let t=vc(this);if(!t)return;let o=t.getScene();if(!o)return;let i=Is(this.getAttribute("vertices"));if(!i||!Array.isArray(i)||i.length<3)return;let r=this.getAttribute("color")||void 0,s=this.getAttribute("texture")||void 0,c=Is(this.getAttribute("uvs"))??void 0,l={};for(let y of Array.from(this.attributes))y.name.startsWith("data-")&&(l[y.name.slice(5)]=y.value);let p={polygons:[{vertices:i,...r!==void 0?{color:r}:{},...s!==void 0?{texture:s}:{},...c!==void 0?{uvs:c}:{},...Object.keys(l).length>0?{data:l}:{}}],objectUrls:[],warnings:[],dispose:()=>{}};this._handle=o.add(p,{position:Ur(this.getAttribute("position")),scale:Pc(this.getAttribute("scale")),rotation:Ur(this.getAttribute("rotation"))})}};function se(e){if(e==null)return;let n=parseFloat(e);return Number.isFinite(n)?n:void 0}function Mo(e){if(!e)return;let n=e.split(",").map(t=>parseFloat(t.trim()));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return[n[0],n[1],n[2]]}function Ve(e){if(e!==null)return!(e==="false"||e==="0")}function Lo(e){if(e===null)return;if(e==="true")return!0;if(e==="false")return!1;let n=parseFloat(e);return Number.isFinite(n)?n:!0}function Ro(e){if(e==="x"||e==="y")return e}var Sc=typeof HTMLElement<"u"?HTMLElement:class{},Cc=["drag","wheel","dolly","min-distance","max-distance","invert","zoom-min","zoom-max","animate-speed","animate-axis","animate-pause-on-interaction"],ko=class extends Sc{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return[...Cc]}getControls(){return this._controls}_readAnimate(){let t=se(this.getAttribute("animate-speed")),o=Ro(this.getAttribute("animate-axis")),i=this.getAttribute("animate-pause-on-interaction");if(this.hasAttribute("animate-speed")||this.hasAttribute("animate-axis")||this.hasAttribute("animate-pause-on-interaction"))return{...t!==void 0?{speed:t}:{},...o!==void 0?{axis:o}:{},...i!==null?{pauseOnInteraction:Ve(i)}:{}}}_readOptions(){let t={},o=Ve(this.getAttribute("drag"));o!==void 0&&(t.drag=o);let i=Ve(this.getAttribute("wheel"));i!==void 0&&(t.wheel=i),this.hasAttribute("dolly")&&(t.dolly=!0);let r=se(this.getAttribute("min-distance"));r!==void 0&&(t.minDistance=r);let s=se(this.getAttribute("max-distance"));s!==void 0&&(t.maxDistance=s);let c=Lo(this.getAttribute("invert"));c!==void 0&&(t.invert=c);let l=se(this.getAttribute("zoom-min")),d=se(this.getAttribute("zoom-max"));return l!==void 0&&(t.minZoom=l),d!==void 0&&(t.maxZoom=d),t.animate=this._readAnimate()??!1,t}_findScene(){let t=this.parentNode;for(;t;){if(t instanceof Ue)return t;t=t.parentNode}return null}_attach(){if(this._controls)return;let t=this._findScene(),o=t?.getScene();if(!o){if(t){let i=()=>{t.removeEventListener("polycss:scene-ready",i),this._attach()};t.addEventListener("polycss:scene-ready",i)}return}this._controls=ho(o,this._readOptions())}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(t,o,i){o!==i&&this._controls&&this._controls.update(this._readOptions())}};var Tc=typeof HTMLElement<"u"?HTMLElement:class{},Ec=["drag","wheel","dolly","min-distance","max-distance","invert","zoom-min","zoom-max","animate-speed","animate-axis","animate-pause-on-interaction"],_o=class extends Tc{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return[...Ec]}_readAnimate(){let t=se(this.getAttribute("animate-speed")),o=Ro(this.getAttribute("animate-axis")),i=this.getAttribute("animate-pause-on-interaction");if(this.hasAttribute("animate-speed")||this.hasAttribute("animate-axis")||this.hasAttribute("animate-pause-on-interaction"))return{...t!==void 0?{speed:t}:{},...o!==void 0?{axis:o}:{},...i!==null?{pauseOnInteraction:Ve(i)}:{}}}_readOptions(){let t={},o=Ve(this.getAttribute("drag"));o!==void 0&&(t.drag=o);let i=Ve(this.getAttribute("wheel"));i!==void 0&&(t.wheel=i),this.hasAttribute("dolly")&&(t.dolly=!0);let r=se(this.getAttribute("min-distance"));r!==void 0&&(t.minDistance=r);let s=se(this.getAttribute("max-distance"));s!==void 0&&(t.maxDistance=s);let c=Lo(this.getAttribute("invert"));c!==void 0&&(t.invert=c);let l=se(this.getAttribute("zoom-min")),d=se(this.getAttribute("zoom-max"));return l!==void 0&&(t.minZoom=l),d!==void 0&&(t.maxZoom=d),t.animate=this._readAnimate()??!1,t}_findScene(){let t=this.parentNode;for(;t;){if(t instanceof Ue)return t;t=t.parentNode}return null}_attach(){if(this._controls)return;let t=this._findScene(),o=t?.getScene();if(!o){if(t){let i=()=>{t.removeEventListener("polycss:scene-ready",i),this._attach()};t.addEventListener("polycss:scene-ready",i)}return}this._controls=yo(o,this._readOptions())}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(t,o,i){o!==i&&this._controls&&this._controls.update(this._readOptions())}};var Ac=typeof HTMLElement<"u"?HTMLElement:class{},wc=["enabled","look-enabled","move-enabled","jump-enabled","crouch-enabled","look-sensitivity","invert-y","move-speed","jump-velocity","gravity","eye-height","crouch-height","ground-z","min-pitch","max-pitch"],Oo=class extends Ac{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return[...wc]}_readOptions(){let t={},o=Ve(this.getAttribute("enabled"));o!==void 0&&(t.enabled=o);let i=Ve(this.getAttribute("look-enabled"));i!==void 0&&(t.lookEnabled=i);let r=Ve(this.getAttribute("move-enabled"));r!==void 0&&(t.moveEnabled=r);let s=Ve(this.getAttribute("jump-enabled"));s!==void 0&&(t.jumpEnabled=s);let c=Ve(this.getAttribute("crouch-enabled"));c!==void 0&&(t.crouchEnabled=c);let l=se(this.getAttribute("look-sensitivity"));if(l!==void 0&&(t.lookSensitivity=l),this.hasAttribute("invert-y")){let C=Ve(this.getAttribute("invert-y"));C!==void 0&&(t.invertY=C)}let d=se(this.getAttribute("move-speed"));d!==void 0&&(t.moveSpeed=d);let p=se(this.getAttribute("jump-velocity"));p!==void 0&&(t.jumpVelocity=p);let y=se(this.getAttribute("gravity"));y!==void 0&&(t.gravity=y);let g=se(this.getAttribute("eye-height"));g!==void 0&&(t.eyeHeight=g);let b=se(this.getAttribute("crouch-height"));b!==void 0&&(t.crouchHeight=b);let x=se(this.getAttribute("ground-z"));x!==void 0&&(t.groundZ=x);let v=se(this.getAttribute("min-pitch"));v!==void 0&&(t.minPitch=v);let h=se(this.getAttribute("max-pitch"));return h!==void 0&&(t.maxPitch=h),t}_findScene(){let t=this.parentNode;for(;t;){if(t instanceof Ue)return t;t=t.parentNode}return null}_attach(){if(this._controls)return;let t=this._findScene(),o=t?.getScene();if(!o){if(t){let i=()=>{t.removeEventListener("polycss:scene-ready",i),this._attach()};t.addEventListener("polycss:scene-ready",i)}return}this._controls=bo(o,this._readOptions())}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(t,o,i){o!==i&&this._controls&&this._controls.update(this._readOptions())}};var Mc=typeof HTMLElement<"u"?HTMLElement:class{},Lc=["perspective","zoom","rot-x","rot-y","target","distance"],Do=class extends Mc{constructor(){super(...arguments);this._camera=null;this._wrapper=null}static get observedAttributes(){return[...Lc]}getCamera(){return this._camera}_readOptions(){return{perspective:se(this.getAttribute("perspective")),zoom:se(this.getAttribute("zoom")),rotX:se(this.getAttribute("rot-x")),rotY:se(this.getAttribute("rot-y")),target:Mo(this.getAttribute("target")),distance:se(this.getAttribute("distance"))}}_mount(){if(this._camera)return;let t=this._readOptions();for(this._camera=vt(t),this._wrapper=this.ownerDocument.createElement("div"),this._wrapper.className="polycss-camera",this._wrapper.style.perspective=this._camera.perspectiveStyle;this.firstChild;)this._wrapper.appendChild(this.firstChild);this.appendChild(this._wrapper),this.dispatchEvent(new CustomEvent("polycss:camera-ready",{bubbles:!1}))}_teardown(){if(this._wrapper){for(;this._wrapper.firstChild;)this.insertBefore(this._wrapper.firstChild,this._wrapper);this._wrapper.parentNode&&this._wrapper.parentNode.removeChild(this._wrapper),this._wrapper=null}this._camera=null}connectedCallback(){this._mount()}disconnectedCallback(){this._teardown()}attributeChangedCallback(t,o,i){if(o===i||!this._camera||!this._wrapper)return;let r=this._readOptions();if(t==="perspective"){let l=r.perspective!==void 0?`${r.perspective}px`:"32000px";this._wrapper.style.perspective=l;return}this._camera.update({rotX:r.rotX,rotY:r.rotY,zoom:r.zoom,target:r.target,distance:r.distance}),this.querySelector("poly-scene")?.getScene?.()?.applyCamera()}};var Rc=typeof HTMLElement<"u"?HTMLElement:class{},kc=["zoom","rot-x","rot-y","target","distance"],Pn=class extends Rc{constructor(){super(...arguments);this._camera=null;this._wrapper=null}static get observedAttributes(){return[...kc]}getCamera(){return this._camera}_readOptions(){return{zoom:se(this.getAttribute("zoom")),rotX:se(this.getAttribute("rot-x")),rotY:se(this.getAttribute("rot-y")),target:Mo(this.getAttribute("target")),distance:se(this.getAttribute("distance"))}}_mount(){if(this._camera)return;let t=this._readOptions();for(this._camera=ut(t),this._wrapper=this.ownerDocument.createElement("div"),this._wrapper.className="polycss-camera",this._wrapper.style.perspective=this._camera.perspectiveStyle;this.firstChild;)this._wrapper.appendChild(this.firstChild);this.appendChild(this._wrapper),this.dispatchEvent(new CustomEvent("polycss:camera-ready",{bubbles:!1}))}_teardown(){if(this._wrapper){for(;this._wrapper.firstChild;)this.insertBefore(this._wrapper.firstChild,this._wrapper);this._wrapper.parentNode&&this._wrapper.parentNode.removeChild(this._wrapper),this._wrapper=null}this._camera=null}connectedCallback(){this._mount()}disconnectedCallback(){this._teardown()}attributeChangedCallback(t,o,i){if(o===i||!this._camera)return;let r=this._readOptions();r.zoom!==void 0&&this._camera.update({zoom:r.zoom}),r.rotX!==void 0&&this._camera.update({rotX:r.rotX}),r.rotY!==void 0&&this._camera.update({rotY:r.rotY}),r.target!==void 0&&this._camera.update({target:r.target}),r.distance!==void 0&&this._camera.update({distance:r.distance}),this.querySelector("poly-scene")?.getScene?.()?.applyCamera()}};var Io=class extends Pn{};var _c=typeof HTMLElement<"u"?HTMLElement:class{},Oc=["mode","target","size","enabled"];function Hs(e){if(e==="translate"||e==="rotate")return e}var Ho=class extends _c{constructor(){super(...arguments);this._tc=null}static get observedAttributes(){return[...Oc]}_findScene(){let t=this.parentNode;for(;t;){if(t instanceof Ue)return t;t=t.parentNode}return null}_findTargetMesh(){let t=this.getAttribute("target");if(!t)return null;let o=this._findScene();if(!o)return null;let i=null;try{i=o.querySelector(`#${t}`)??o.querySelector(t)}catch{i=o.querySelector(`[id="${t}"]`)}return i instanceof bn?i:null}_readOptions(){let t={},o=Hs(this.getAttribute("mode"));o!==void 0&&(t.mode=o);let i=se(this.getAttribute("size"));i!==void 0&&(t.size=i);let r=this.getAttribute("enabled");return r!==null&&(t.enabled=r!=="false"&&r!=="0"),t.onObjectChange=s=>{this.dispatchEvent(new CustomEvent("polycss:object-change",{bubbles:!0,detail:{position:s.position,rotation:s.rotation}}))},t}_attach(){if(this._tc)return;let t=this._findScene(),o=t?.getScene();if(!o){if(t){let r=()=>{t.removeEventListener("polycss:scene-ready",r),this._attach()};t.addEventListener("polycss:scene-ready",r)}return}this._tc=To(o,this._readOptions());let i=this._findTargetMesh();if(i){let r=i.getMeshHandle();r&&this._tc.attach(r)}}connectedCallback(){this._attach()}disconnectedCallback(){this._tc&&(this._tc.destroy(),this._tc=null)}attributeChangedCallback(t,o,i){if(o!==i&&this._tc){if(t==="mode"){let r=Hs(i);r&&this._tc.setMode(r)}else if(t==="target"){let r=this._findTargetMesh();this._tc.attach(r?r.getMeshHandle()??null:null)}}}};var Dc=typeof HTMLElement<"u"?HTMLElement:class{},Ic=["multiple","clear-on-miss"],Fo=class extends Dc{constructor(){super(...arguments);this._selection=null}static get observedAttributes(){return[...Ic]}_findScene(){let t=this.parentNode;for(;t;){if(t instanceof Ue)return t;t=t.parentNode}return null}_readOptions(){return{multiple:this.hasAttribute("multiple"),clearOnMiss:!this.hasAttribute("clear-on-miss")||this.getAttribute("clear-on-miss")!=="false",onChange:t=>{this.dispatchEvent(new CustomEvent("polycss:select",{bubbles:!0,detail:{selected:t}}))}}}_attach(){if(this._selection)return;let t=this._findScene(),o=t?.getScene();if(!o){if(t){let i=()=>{t.removeEventListener("polycss:scene-ready",i),this._attach()};t.addEventListener("polycss:scene-ready",i)}return}this._selection=xo(o,this._readOptions())}connectedCallback(){this._attach()}disconnectedCallback(){this._selection&&(this._selection.destroy(),this._selection=null)}attributeChangedCallback(t,o,i){o!==i&&(this._selection&&(this._selection.destroy(),this._selection=null),this._attach())}};var Gr={quad:0,clippedSolid:0,atlas:0,stableTriangle:0},Yr={ready:!0,textureLeafCount:0,readyTextureLeafCount:0,pendingTextureLeafCount:0,atlasTextureLeafCount:0,imageTextureLeafCount:0};function Xr(){return{ready:!0,leafCount:0,atlasCount:0,imageCount:0,pendingCount:0,sizingCounts:{canonical:0,local:0,raster:0,image:0,unknown:0},imageRenderingCounts:{auto:0,pixelated:0,unknown:0},projectionCounts:{affine:0,projective:0,fallback:0,unknown:0},minLeafWidth:0,maxLeafWidth:0,minLeafHeight:0,maxLeafHeight:0,doubleSidedCount:0}}function qr(){return{runtimeAtlasUrlCount:0,snapshotAtlasCount:0,snapshotBackgroundCount:0,selfContained:!0}}function zo(){return{rootFound:!1,projection:"unknown",perspectiveStyle:"",appliedPerspectiveStyle:""}}var Hc={polygonCount:0,mountedPolygonLeafCount:0,shadowLeafCount:0,surfaceLeafCounts:Gr,textureReadiness:Yr,textureStats:Xr(),snapshotStats:qr(),cameraStats:zo(),bucketCount:0};function Bo(e){return typeof e=="number"?{polygonCount:e}:e??{}}function Xt(e,n){return e.querySelectorAll(n).length}function Fs(e,n){return(Bs(e,n)?1:0)+Xt(e,n)}function zs(e){if(!e)return!1;let n=/url\((?:"([^"]*)"|'([^']*)'|([^)]*))\)/g,t;for(;t=n.exec(e);){let o=(t[1]??t[2]??t[3]??"").trim();if(o&&!o.startsWith("data:"))return!0}return!1}function Fc(e){let n=0,t=e instanceof HTMLElement?e:null;t&&zs(t.getAttribute("style"))&&n++;for(let o of Array.from(e.querySelectorAll("[style]")))o instanceof HTMLElement&&zs(o.getAttribute("style"))&&n++;return n}function Bs(e,n){let t=e;return typeof t.matches=="function"&&t.matches(n)}function Vo(e,n){if(!n)return[e];let t=[];return Bs(e,n)&&t.push(e),t.push(...Array.from(e.querySelectorAll(n))),t}function zc(e){switch(e.toLowerCase()){case"b":return"quad";case"i":return"clippedSolid";case"s":return"atlas";case"u":return"stableTriangle";default:return null}}function Bc(e){if(e==null||e==="")return;let n=Number.parseInt(e,10);return Number.isFinite(n)?n:void 0}function vn(e){if(e==null||e==="")return;let n=Number(e);return Number.isFinite(n)?n:void 0}function Vc(e){if(e==null||e==="")return;let n=e.split(",").map(t=>Number(t));if(!(n.length!==3||n.some(t=>!Number.isFinite(t))))return n}function Nc(e){return e==="orthographic"||e==="perspective"?e:"unknown"}function jc(e,n){if(!n)return;let t=e.getAttribute("data-polycss-texture-ready");return t==="true"?!0:t==="false"?!1:e.style.opacity!=="0"}function No(e,n){if(!e)return[];let t=Bo(n),o=[];for(let i of Vo(e,t.scopeSelector))for(let r of Array.from(i.querySelectorAll("b,i,s,u"))){let s=r,c=zc(s.tagName);if(!c)continue;let l=s.getAttribute("data-polycss-texture-backend")??(c==="atlas"?"atlas":void 0),d=jc(s,l);o.push({element:s,strategy:c,polygonIndex:Bc(s.getAttribute("data-poly-index")),textureBackend:l,textureReady:d,textureLeafSizing:s.getAttribute("data-polycss-texture-leaf-sizing")??void 0,textureImageRendering:s.getAttribute("data-polycss-texture-image-rendering")??void 0,textureProjection:s.getAttribute("data-polycss-texture-projection")??void 0,textureLeafWidth:vn(s.getAttribute("data-polycss-texture-leaf-width")),textureLeafHeight:vn(s.getAttribute("data-polycss-texture-leaf-height")),doubleSided:s.getAttribute("data-polycss-double-sided")==="true"})}return o}function Zr(e,n){let t={...Yr};for(let o of No(e,n))o.textureBackend&&(t.textureLeafCount++,o.textureBackend==="image"?t.imageTextureLeafCount++:t.atlasTextureLeafCount++,o.textureReady===!1?t.pendingTextureLeafCount++:t.readyTextureLeafCount++);return t.ready=t.pendingTextureLeafCount===0,t}function $c(e,n){let t=Xr(),o=!1,i=!1;for(let r of No(e,n))if(r.textureBackend){switch(t.leafCount++,r.textureBackend==="image"?t.imageCount++:t.atlasCount++,r.textureReady===!1&&t.pendingCount++,r.textureLeafSizing){case"canonical":case"local":case"raster":case"image":t.sizingCounts[r.textureLeafSizing]++;break;default:t.sizingCounts.unknown++;break}switch(r.textureImageRendering){case"auto":case"pixelated":t.imageRenderingCounts[r.textureImageRendering]++;break;default:t.imageRenderingCounts.unknown++;break}switch(r.textureProjection){case"affine":case"projective":case"fallback":t.projectionCounts[r.textureProjection]++;break;default:t.projectionCounts.unknown++;break}typeof r.textureLeafWidth=="number"&&(t.minLeafWidth=o?Math.min(t.minLeafWidth,r.textureLeafWidth):r.textureLeafWidth,t.maxLeafWidth=o?Math.max(t.maxLeafWidth,r.textureLeafWidth):r.textureLeafWidth,o=!0),typeof r.textureLeafHeight=="number"&&(t.minLeafHeight=i?Math.min(t.minLeafHeight,r.textureLeafHeight):r.textureLeafHeight,t.maxLeafHeight=i?Math.max(t.maxLeafHeight,r.textureLeafHeight):r.textureLeafHeight,i=!0),r.doubleSided&&t.doubleSidedCount++}return t.pendingCount=Math.min(t.pendingCount,t.leafCount),t.ready=t.pendingCount===0,t}function Wc(e,n){let t=qr();if(!e)return t;let o=Bo(n);for(let i of Vo(e,o.scopeSelector))t.runtimeAtlasUrlCount+=Fc(i),t.snapshotAtlasCount+=Fs(i,"[data-polycss-snapshot-atlas]"),t.snapshotBackgroundCount+=Fs(i,"[data-polycss-snapshot-bg]");return t.selfContained=t.runtimeAtlasUrlCount===0,t}function Uc(e){let n=e instanceof HTMLElement?e:null;if(n){if(n.classList.contains("polycss-camera"))return n;let o=n.closest(".polycss-camera");if(o instanceof HTMLElement)return o}let t=e.querySelector(".polycss-camera");return t instanceof HTMLElement?t:null}function Gc(e,n){if(!e)return zo();let t=Bo(n),o=null;for(let i of Vo(e,t.scopeSelector))if(o=Uc(i),o)break;return o?{rootFound:!0,projection:Nc(o.getAttribute("data-polycss-camera-projection")),perspectiveStyle:o.getAttribute("data-polycss-camera-perspective")??"",appliedPerspectiveStyle:o.getAttribute("data-polycss-camera-applied-perspective")??o.style.perspective??"",zoom:vn(o.getAttribute("data-polycss-camera-zoom")),distance:vn(o.getAttribute("data-polycss-camera-distance")),rotX:vn(o.getAttribute("data-polycss-camera-rot-x")),rotY:vn(o.getAttribute("data-polycss-camera-rot-y")),target:Vc(o.getAttribute("data-polycss-camera-target"))}:zo()}function Vs(e,n){let t=Bo(n);if(!e)return{...Hc,surfaceLeafCounts:{...Gr},textureReadiness:{...Yr},textureStats:Xr(),snapshotStats:qr(),cameraStats:zo(),polygonCount:t.polygonCount??0};let o=Vo(e,t.scopeSelector),i={...Gr},r=0,s=0;for(let l of o)i.quad+=Xt(l,"b"),i.clippedSolid+=Xt(l,"i"),i.atlas+=Xt(l,"s"),i.stableTriangle+=Xt(l,"u"),r+=Xt(l,"q, .polycss-shadow-svg"),s+=Xt(l,".polycss-bucket");let c=i.quad+i.clippedSolid+i.atlas+i.stableTriangle;return{polygonCount:t.polygonCount??c,mountedPolygonLeafCount:c,shadowLeafCount:r,surfaceLeafCounts:i,textureReadiness:Zr(e,t),textureStats:$c(e,t),snapshotStats:Wc(e,t),cameraStats:Gc(e,t),bucketCount:s}}var Ft=class extends Error{constructor(n,t,o){super(t),this.name="PolySceneSnapshotError",this.code=n,this.url=o,Object.setPrototypeOf(this,new.target.prototype)}},Yc=`
|
|
520
|
+
html,
|
|
521
|
+
body {
|
|
522
|
+
width: 100%;
|
|
523
|
+
height: 100%;
|
|
524
|
+
margin: 0;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
body {
|
|
528
|
+
position: relative;
|
|
529
|
+
overflow: hidden;
|
|
530
|
+
}
|
|
531
|
+
`,Qr=["b","i","s","u"],Xc=["b","i","u"],qc=["--plx","--ply","--plz","--plr","--plg","--plb","--pli","--par","--pag","--pab","--pai","--pnx","--pny","--pnz","--psr","--psg","--psb","--plam","--polycss-light-preview-active","--polycss-preview-r","--polycss-preview-g","--polycss-preview-b"],Zc=["--clx","--cly","--clz","--shadow-ground-cssz"],Qc=["--polycss-atlas-size","--polycss-atlas-width","--polycss-atlas-height","--polycss-atlas-leaf-sizing","--polycss-atlas-url","--polycss-atlas-position","--polycss-atlas-image-size"],Kc=["--polycss-atlas-size","--polycss-atlas-width","--polycss-atlas-height","--polycss-atlas-leaf-sizing"];function Jc(e){return!!e&&typeof e.querySelector=="function"&&typeof e.cloneNode=="function"}function eu(e){let n=e.closest(".polycss-camera");if(n)return n;let t=e.closest(".polycss-scene");return t?t.closest(".polycss-camera")??t:e.querySelector(".polycss-camera")??e.querySelector(".polycss-scene")}function jn(e){return[e,...Array.from(e.querySelectorAll("*"))]}function Ct(e,n){return e.matches(n)||!!e.querySelector(n)}function Ns(e,n){return e.tagName.toLowerCase()===n||!!e.querySelector(n)}function tu(e){let n=Qr.filter(o=>Ns(e,o)),t=Xc.filter(o=>n.includes(o));return{hasCamera:Ct(e,".polycss-camera"),hasScene:Ct(e,".polycss-scene"),hasMesh:Ct(e,".polycss-mesh"),hasFpvHost:Ct(e,".polycss-fpv-host"),hasBucket:Ct(e,".polycss-bucket"),hasVoxelMesh:Ct(e,".polycss-voxel-mesh"),hasTransformGizmo:Ct(e,".polycss-transform-gizmo"),hasTransformRing:Ct(e,".polycss-transform-ring"),hasDynamicLighting:Ct(e,'.polycss-scene[data-polycss-lighting="dynamic"]'),hasQ:Ns(e,"q"),leafTags:n,solidLeafTags:t}}function Nn(e,n=".polycss-scene "){return e.map(t=>`${n}${t}`).join(`,
|
|
532
|
+
`)}function nu(e){return e.map(n=>`.polycss-scene[data-polycss-lighting="dynamic"] :not(.polycss-bucket) > ${n}`).join(`,
|
|
533
|
+
`)}function ou(e){let n=['@property --plx { syntax: "<number>"; inherits: true; initial-value: 0; }','@property --ply { syntax: "<number>"; inherits: true; initial-value: 0; }','@property --plz { syntax: "<number>"; inherits: true; initial-value: 1; }','@property --plr { syntax: "<number>"; inherits: true; initial-value: 1; }','@property --plg { syntax: "<number>"; inherits: true; initial-value: 1; }','@property --plb { syntax: "<number>"; inherits: true; initial-value: 1; }','@property --pli { syntax: "<number>"; inherits: true; initial-value: 1; }','@property --par { syntax: "<number>"; inherits: true; initial-value: 1; }','@property --pag { syntax: "<number>"; inherits: true; initial-value: 1; }','@property --pab { syntax: "<number>"; inherits: true; initial-value: 1; }','@property --pai { syntax: "<number>"; inherits: true; initial-value: 0.4; }','@property --pnx { syntax: "<number>"; inherits: true; initial-value: 0; }','@property --pny { syntax: "<number>"; inherits: true; initial-value: 0; }','@property --pnz { syntax: "<number>"; inherits: true; initial-value: 1; }','@property --psr { syntax: "<number>"; inherits: true; initial-value: 1; }','@property --psg { syntax: "<number>"; inherits: true; initial-value: 1; }','@property --psb { syntax: "<number>"; inherits: true; initial-value: 1; }','@property --plam { syntax: "<number>"; inherits: true; initial-value: 0; }'];return e&&n.push('@property --clx { syntax: "<number>"; inherits: true; initial-value: 0.01; }','@property --cly { syntax: "<number>"; inherits: true; initial-value: 0; }','@property --clz { syntax: "<number>"; inherits: true; initial-value: 1; }','@property --shadow-ground-cssz { syntax: "<number>"; inherits: true; initial-value: 0; }'),n.join(`
|
|
534
|
+
`)}function ru(e){let n=[ou(e.hasQ)];return e.hasBucket&&n.push(`
|
|
535
|
+
.polycss-scene[data-polycss-lighting="dynamic"] .polycss-bucket {
|
|
536
|
+
--plam: max(0, calc(
|
|
537
|
+
var(--pnx) * var(--plx) +
|
|
538
|
+
var(--pny) * var(--ply) +
|
|
539
|
+
var(--pnz) * var(--plz)
|
|
540
|
+
));
|
|
541
|
+
}
|
|
542
|
+
`),e.leafTags.length>0&&n.push(`
|
|
543
|
+
${nu(e.leafTags)} {
|
|
544
|
+
--plam: max(0, calc(
|
|
545
|
+
var(--pnx) * var(--plx) +
|
|
546
|
+
var(--pny) * var(--ply) +
|
|
547
|
+
var(--pnz) * var(--plz)
|
|
548
|
+
));
|
|
549
|
+
}
|
|
550
|
+
`),e.leafTags.includes("s")&&n.push(`
|
|
551
|
+
.polycss-scene[data-polycss-lighting="dynamic"] s {
|
|
552
|
+
contain: strict;
|
|
553
|
+
background-color: rgb(
|
|
554
|
+
calc(255 * (var(--par) * var(--pai)
|
|
555
|
+
+ var(--plr) * var(--pli) * var(--plam)))
|
|
556
|
+
calc(255 * (var(--pag) * var(--pai)
|
|
557
|
+
+ var(--plg) * var(--pli) * var(--plam)))
|
|
558
|
+
calc(255 * (var(--pab) * var(--pai)
|
|
559
|
+
+ var(--plb) * var(--pli) * var(--plam)))
|
|
560
|
+
);
|
|
561
|
+
background-blend-mode: multiply;
|
|
562
|
+
background-image: var(--polycss-atlas-url);
|
|
563
|
+
background-position: var(--polycss-atlas-position);
|
|
564
|
+
background-repeat: no-repeat;
|
|
565
|
+
background-size: var(--polycss-atlas-image-size);
|
|
566
|
+
mask-image: var(--polycss-atlas-url);
|
|
567
|
+
mask-mode: alpha;
|
|
568
|
+
mask-position: var(--polycss-atlas-position);
|
|
569
|
+
mask-repeat: no-repeat;
|
|
570
|
+
mask-size: var(--polycss-atlas-image-size);
|
|
571
|
+
-webkit-mask-image: var(--polycss-atlas-url);
|
|
572
|
+
-webkit-mask-position: var(--polycss-atlas-position);
|
|
573
|
+
-webkit-mask-repeat: no-repeat;
|
|
574
|
+
-webkit-mask-size: var(--polycss-atlas-image-size);
|
|
575
|
+
}
|
|
576
|
+
`),e.solidLeafTags.length>0&&n.push(`
|
|
577
|
+
${Nn(e.solidLeafTags)} {
|
|
578
|
+
color: rgb(
|
|
579
|
+
calc(255 * var(--psr) * (var(--par) * var(--pai)
|
|
580
|
+
+ var(--plr) * var(--pli) * var(--plam)))
|
|
581
|
+
calc(255 * var(--psg) * (var(--pag) * var(--pai)
|
|
582
|
+
+ var(--plg) * var(--pli) * var(--plam)))
|
|
583
|
+
calc(255 * var(--psb) * (var(--pab) * var(--pai)
|
|
584
|
+
+ var(--plb) * var(--pli) * var(--plam)))
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
`),e.hasQ&&n.push(`
|
|
588
|
+
.polycss-scene[data-polycss-lighting="dynamic"] {
|
|
589
|
+
--shadow-proj: matrix3d(
|
|
590
|
+
1, 0, 0, 0,
|
|
591
|
+
0, 1, 0, 0,
|
|
592
|
+
calc(-1 * var(--clx) / var(--clz)),
|
|
593
|
+
calc(-1 * var(--cly) / var(--clz)),
|
|
594
|
+
0.01,
|
|
595
|
+
0,
|
|
596
|
+
calc(var(--shadow-ground-cssz) * var(--clx) / var(--clz)),
|
|
597
|
+
calc(var(--shadow-ground-cssz) * var(--cly) / var(--clz)),
|
|
598
|
+
calc(var(--shadow-ground-cssz) * 0.99),
|
|
599
|
+
1
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
.polycss-scene[data-polycss-lighting="dynamic"] q {
|
|
604
|
+
opacity: clamp(0, calc((var(--pnx) * var(--clx) + var(--pny) * var(--cly) + var(--pnz) * var(--clz)) * 10), 1);
|
|
605
|
+
}
|
|
606
|
+
`),n.join(`
|
|
607
|
+
`)}function iu(e){let n=[Yc];if(e.hasScene&&n.push(`
|
|
608
|
+
.polycss-scene,
|
|
609
|
+
.polycss-scene *,
|
|
610
|
+
.polycss-scene *::before,
|
|
611
|
+
.polycss-scene *::after {
|
|
612
|
+
box-sizing: border-box;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
.polycss-scene {
|
|
616
|
+
position: absolute;
|
|
617
|
+
top: 50%;
|
|
618
|
+
left: 50%;
|
|
619
|
+
width: 0;
|
|
620
|
+
height: 0;
|
|
621
|
+
transform-style: preserve-3d;
|
|
622
|
+
}
|
|
623
|
+
`),e.hasCamera&&n.push(`
|
|
624
|
+
.polycss-camera {
|
|
625
|
+
position: relative;
|
|
626
|
+
display: block;
|
|
627
|
+
width: 100%;
|
|
628
|
+
height: 100%;
|
|
629
|
+
}
|
|
630
|
+
`),e.hasFpvHost&&n.push(`
|
|
631
|
+
.polycss-fpv-host {
|
|
632
|
+
perspective: var(--polycss-fpv-perspective, 2000px) !important;
|
|
633
|
+
transform-style: preserve-3d !important;
|
|
634
|
+
}
|
|
635
|
+
`),e.hasMesh&&n.push(`
|
|
636
|
+
.polycss-mesh {
|
|
637
|
+
position: absolute;
|
|
638
|
+
transform-style: preserve-3d;
|
|
639
|
+
}
|
|
640
|
+
`),e.hasBucket&&n.push(`
|
|
641
|
+
.polycss-bucket {
|
|
642
|
+
position: absolute;
|
|
643
|
+
transform-style: preserve-3d;
|
|
644
|
+
}
|
|
645
|
+
`),e.leafTags.length>0&&n.push(`
|
|
646
|
+
${Nn(e.leafTags)} {
|
|
647
|
+
position: absolute;
|
|
648
|
+
display: block;
|
|
649
|
+
transform-origin: 0 0;
|
|
650
|
+
transform-style: preserve-3d;
|
|
651
|
+
margin: 0;
|
|
652
|
+
padding: 0;
|
|
653
|
+
font: inherit;
|
|
654
|
+
font-weight: normal;
|
|
655
|
+
font-style: normal;
|
|
656
|
+
line-height: 0;
|
|
657
|
+
text-decoration: none;
|
|
658
|
+
backface-visibility: hidden;
|
|
659
|
+
background-repeat: no-repeat;
|
|
660
|
+
}
|
|
661
|
+
`),e.solidLeafTags.length>0&&!e.hasDynamicLighting&&n.push(`
|
|
662
|
+
${Nn(e.solidLeafTags)} {
|
|
663
|
+
color: currentColor;
|
|
664
|
+
}
|
|
665
|
+
`),e.leafTags.includes("b")&&n.push(`
|
|
666
|
+
.polycss-scene b {
|
|
667
|
+
background: currentColor;
|
|
668
|
+
width: 64px;
|
|
669
|
+
height: 64px;
|
|
670
|
+
}
|
|
671
|
+
`),e.hasVoxelMesh&&n.push(`
|
|
672
|
+
.polycss-mesh.polycss-voxel-mesh > .polycss-voxel-face {
|
|
673
|
+
position: absolute;
|
|
674
|
+
display: block;
|
|
675
|
+
top: 0;
|
|
676
|
+
left: 0;
|
|
677
|
+
width: 0;
|
|
678
|
+
height: 0;
|
|
679
|
+
transform-style: preserve-3d;
|
|
680
|
+
transform-origin: 0 0;
|
|
681
|
+
margin: 0;
|
|
682
|
+
padding: 0;
|
|
683
|
+
font: inherit;
|
|
684
|
+
line-height: 0;
|
|
685
|
+
pointer-events: none;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
.polycss-mesh.polycss-voxel-mesh > .polycss-voxel-face > b {
|
|
689
|
+
top: 0;
|
|
690
|
+
left: 0;
|
|
691
|
+
width: var(--polycss-voxel-primitive, 1px);
|
|
692
|
+
height: var(--polycss-voxel-primitive, 1px);
|
|
693
|
+
backface-visibility: visible;
|
|
694
|
+
pointer-events: none;
|
|
695
|
+
}
|
|
696
|
+
`),e.leafTags.includes("i")&&n.push(`
|
|
697
|
+
.polycss-scene i {
|
|
698
|
+
width: 16px;
|
|
699
|
+
height: 16px;
|
|
700
|
+
border-color: currentColor;
|
|
701
|
+
}
|
|
702
|
+
`),e.leafTags.includes("s")&&n.push(`
|
|
703
|
+
.polycss-scene s {
|
|
704
|
+
width: 64px;
|
|
705
|
+
height: 64px;
|
|
706
|
+
}
|
|
707
|
+
`),e.leafTags.includes("u")&&n.push(`
|
|
708
|
+
.polycss-scene u {
|
|
709
|
+
width: 0;
|
|
710
|
+
height: 0;
|
|
711
|
+
background: transparent;
|
|
712
|
+
box-sizing: content-box;
|
|
713
|
+
border: 0 solid transparent;
|
|
714
|
+
border-color: transparent transparent currentColor transparent;
|
|
715
|
+
border-width: 0 16px 32px 16px;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
@supports (corner-top-left-shape: bevel) and (corner-top-right-shape: bevel) {
|
|
719
|
+
.polycss-scene > u,
|
|
720
|
+
.polycss-mesh > u,
|
|
721
|
+
.polycss-bucket > u {
|
|
722
|
+
border-width: 0;
|
|
723
|
+
width: 32px;
|
|
724
|
+
height: 32px;
|
|
725
|
+
background-color: currentColor;
|
|
726
|
+
border-top-left-radius: 50% 100%;
|
|
727
|
+
border-top-right-radius: 50% 100%;
|
|
728
|
+
corner-top-left-shape: bevel;
|
|
729
|
+
corner-top-right-shape: bevel;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
.polycss-scene > u.polycss-corner-shape-solid,
|
|
733
|
+
.polycss-mesh > u.polycss-corner-shape-solid,
|
|
734
|
+
.polycss-bucket > u.polycss-corner-shape-solid {
|
|
735
|
+
width: 16px;
|
|
736
|
+
height: 16px;
|
|
737
|
+
box-sizing: border-box;
|
|
738
|
+
border: 0;
|
|
739
|
+
background: currentColor;
|
|
740
|
+
border-radius: 0;
|
|
741
|
+
corner-top-left-shape: initial;
|
|
742
|
+
corner-top-right-shape: initial;
|
|
743
|
+
corner-bottom-right-shape: initial;
|
|
744
|
+
corner-bottom-left-shape: initial;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
`),e.hasQ&&n.push(`
|
|
748
|
+
.polycss-scene q {
|
|
749
|
+
position: absolute;
|
|
750
|
+
display: block;
|
|
751
|
+
transform-origin: 0 0;
|
|
752
|
+
transform-style: preserve-3d;
|
|
753
|
+
margin: 0;
|
|
754
|
+
padding: 0;
|
|
755
|
+
font: inherit;
|
|
756
|
+
font-weight: normal;
|
|
757
|
+
font-style: normal;
|
|
758
|
+
line-height: 0;
|
|
759
|
+
text-decoration: none;
|
|
760
|
+
backface-visibility: visible;
|
|
761
|
+
border-color: currentColor;
|
|
762
|
+
pointer-events: none;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
.polycss-scene q::before,
|
|
766
|
+
.polycss-scene q::after {
|
|
767
|
+
content: none;
|
|
768
|
+
}
|
|
769
|
+
`),e.hasTransformGizmo){let t=e.leafTags.length>0?e.leafTags:Qr;n.push(`
|
|
770
|
+
${Nn(t,".polycss-mesh.polycss-transform-gizmo ")} {
|
|
771
|
+
backface-visibility: visible;
|
|
772
|
+
transition: color 150ms ease-out, border-color 150ms ease-out, background-color 150ms ease-out;
|
|
773
|
+
}
|
|
774
|
+
`)}if(e.hasTransformRing){let t=e.leafTags.length>0?e.leafTags:Qr;n.push(`
|
|
775
|
+
${Nn(t,".polycss-mesh.polycss-transform-ring ")} {
|
|
776
|
+
--ring-inner-r: calc(var(--ring-inner-ratio, 0.92) * 50%);
|
|
777
|
+
--ring-outer-r: calc(var(--ring-outer-ratio, 1) * 50%);
|
|
778
|
+
-webkit-mask: radial-gradient(circle at 50% 50%,
|
|
779
|
+
transparent 0%,
|
|
780
|
+
transparent var(--ring-inner-r),
|
|
781
|
+
black var(--ring-inner-r),
|
|
782
|
+
black var(--ring-outer-r),
|
|
783
|
+
transparent var(--ring-outer-r));
|
|
784
|
+
mask: radial-gradient(circle at 50% 50%,
|
|
785
|
+
transparent 0%,
|
|
786
|
+
transparent var(--ring-inner-r),
|
|
787
|
+
black var(--ring-inner-r),
|
|
788
|
+
black var(--ring-outer-r),
|
|
789
|
+
transparent var(--ring-outer-r));
|
|
790
|
+
}
|
|
791
|
+
`)}return e.hasDynamicLighting&&n.push(ru(e)),n.map(t=>t.trim()).filter(Boolean).join(`
|
|
792
|
+
|
|
793
|
+
`)}function Jr(e){let n=e.style;return n&&typeof n.getPropertyValue=="function"?n:null}function $s(e){let n=e.getAttribute("style");n!==null&&n.trim()===""&&e.removeAttribute("style")}function su(e,n){let t=e;for(;t;){let o=Jr(t)?.getPropertyValue(n).trim();if(o)return o;t=t.parentElement}return""}function au(e,n,t){let o=jn(e),i=jn(n);for(let r=0;r<i.length;r++){let s=o[r],c=i[r];if(!s||!c)continue;let l=Jr(c);if(!l)continue;if(c.classList.contains("polycss-mesh")){let p=l.getPropertyValue("--origin").trim();p&&(l.setProperty("transform-origin",p),l.removeProperty("--origin"))}let d=c.tagName.toLowerCase();if(d==="s"){let p=l.getPropertyValue("--polycss-atlas-size").trim(),y=l.getPropertyValue("--polycss-atlas-width").trim()||p,g=l.getPropertyValue("--polycss-atlas-height").trim()||p;if(y&&l.setProperty("width",y),g&&l.setProperty("height",g),t.hasDynamicLighting)for(let b of Kc)l.removeProperty(b);else for(let b of Qc)l.removeProperty(b)}else if(d==="b"||d==="i"||d==="u"){let p=su(s,"--polycss-paint"),y=t.hasDynamicLighting?"":s.ownerDocument.defaultView?.getComputedStyle(s).color;y?l.setProperty("color",y):p&&!l.getPropertyValue("color")&&l.setProperty("color",p)}if(!t.hasDynamicLighting)for(let p of qc)l.removeProperty(p);if(!t.hasQ)for(let p of Zc)l.removeProperty(p);l.removeProperty("will-change"),l.removeProperty("--polycss-paint"),$s(c)}}function lu(e){for(let n of Array.from(e.querySelectorAll("script")))n.remove();for(let n of jn(e))for(let t of Array.from(n.attributes))t.name.toLowerCase().startsWith("on")&&n.removeAttribute(t.name)}function Ws(e){let n=e.trim();return n===""||n.startsWith("#")||/^data:/i.test(n)}function cu(e,n){return/^data:/i.test(e.trim())?e.trim():Us(e,n.baseUrl)}function js(e){let n=/url\(\s*(?:(["'])(.*?)\1|([^)]*?))\s*\)/i.exec(e);return(n?.[2]??n?.[3]??"").trim()||null}function uu(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\a ")}function Us(e,n){try{return new URL(e,n).href}catch{throw new Ft("ASSET_INLINE_FAILED",`exportPolySceneSnapshot: could not resolve asset URL "${e}".`,e)}}function du(e){let n=(()=>{try{return new URL(e).pathname.toLowerCase()}catch{return e.toLowerCase()}})();return n.endsWith(".jpg")||n.endsWith(".jpeg")?"image/jpeg":n.endsWith(".png")?"image/png":n.endsWith(".webp")?"image/webp":n.endsWith(".gif")?"image/gif":n.endsWith(".svg")?"image/svg+xml":n.endsWith(".avif")?"image/avif":"application/octet-stream"}function pu(e){let n=new Uint8Array(e),t=32768,o="";for(let i=0;i<n.length;i+=t){let r=n.subarray(i,i+t);o+=String.fromCharCode(...r)}return btoa(o)}function mu(e){return/^(blob|filesystem):/i.test(e.trim())}function fu(e){return new Promise((n,t)=>{let o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType="blob",o.onload=()=>{o.status===0||o.status>=200&&o.status<300?n(o.response):t(new Error(`XHR ${o.status}`))},o.onerror=()=>t(new Error("XHR request failed")),o.send()})}async function gu(e){let n=mu(e);try{if(typeof fetch!="function")throw new Error("fetch is not available");let t=await fetch(e,n?void 0:{credentials:"same-origin"});if(!t.ok)throw new Error(`HTTP ${t.status}`);return await t.blob()}catch(t){if(n&&typeof XMLHttpRequest=="function")return fu(e);throw t}}async function Gs(e,n){if(Ws(e))return e;let t=Us(e,n.baseUrl),o=n.cache.get(t);if(o)return o;let i=(async()=>{try{let r=await gu(t),s=r.type||du(t),c=pu(await r.arrayBuffer());return`data:${s};base64,${c}`}catch{throw new Ft("ASSET_INLINE_FAILED",`exportPolySceneSnapshot: could not inline asset "${t}".`,t)}})();return n.cache.set(t,i),i}async function Kr(e,n){let t=/url\(\s*(?:(["'])(.*?)\1|([^)]*?))\s*\)/gi,o="",i=0,r;for(;(r=t.exec(e))!==null;){o+=e.slice(i,r.index);let s=(r[2]??r[3]??"").trim(),c=await Gs(s,n);o+=Ws(s)?r[0]:`url("${c}")`,i=t.lastIndex}return o+e.slice(i)}async function hu(e,n){for(let t of jn(e)){let o=t.getAttribute("style");o&&t.setAttribute("style",await Kr(o,n))}for(let t of Array.from(e.querySelectorAll("style")))t.textContent=await Kr(t.textContent??"",n)}function yu(e){return{position:e.getPropertyValue("background-position").trim(),size:e.getPropertyValue("background-size").trim(),repeat:e.getPropertyValue("background-repeat").trim()}}function bu(e,n){n.position&&e.setProperty("background-position",n.position),n.size&&e.setProperty("background-size",n.size),n.repeat&&e.setProperty("background-repeat",n.repeat)}async function xu(e,n){let t=[],o=new Map,i=new Map,r=async l=>{let d=cu(l,n),p=o.get(d);if(p)return p;let y=`a${o.size}`;return o.set(d,y),i.set(d,await Gs(l,n)),y},s=l=>{for(let[d,p]of o)if(p===l)return i.get(d)??"";return""};for(let l of jn(e)){let d=Jr(l);if(!d||l.tagName.toLowerCase()!=="s")continue;let p=js(d.getPropertyValue("--polycss-atlas-url"));if(p&&!p.startsWith("#")){let v=await r(p),h="data-polycss-snapshot-atlas";l.setAttribute(h,v),d.removeProperty("--polycss-atlas-url"),t.push({attr:h,value:v,property:"--polycss-atlas-url",dataUrl:s(v)})}let y=js(d.getPropertyValue("background-image"));if(!y||y.startsWith("#"))continue;let g=await r(y),b="data-polycss-snapshot-bg",x=yu(d);l.setAttribute(b,g),d.removeProperty("background"),d.removeProperty("background-image"),bu(d,x),t.push({attr:b,value:g,property:"background-image",dataUrl:s(g)}),$s(l)}let c=new Set;return t.filter(l=>{let d=`${l.attr}|${l.value}|${l.property}`;return c.has(d)?!1:(c.add(d),!0)}).map(l=>`.polycss-scene [${l.attr}="${l.value}"] {
|
|
794
|
+
${l.property}: url("${uu(l.dataUrl)}");
|
|
795
|
+
}`).join(`
|
|
796
|
+
|
|
797
|
+
`)}function Pu(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function vu(e){return e.replace(/<\/style/gi,"<\\/style")}function Su(e){return e.baseURI||e.URL||e.defaultView?.location.href||"http://localhost/"}async function Ys(e){if(!Jc(e))throw new Ft("INVALID_TARGET","exportPolySceneSnapshot: target must be an Element.");let n=eu(e);if(!n)throw new Ft("SCENE_NOT_FOUND","exportPolySceneSnapshot: target is not inside and does not contain a rendered PolyCSS scene.");let t=e.ownerDocument,o={baseUrl:Su(t),cache:new Map},i=n.cloneNode(!0),r=tu(i);au(n,i,r),lu(i);let s=await xu(i,o);await hu(i,o);let c=await Kr([iu(r),s].filter(Boolean).join(`
|
|
798
|
+
|
|
799
|
+
`),o);return["<!doctype html>","<html>","<head>",'<meta charset="utf-8">',t.title?`<title>${Pu(t.title)}</title>`:"",`<style>${vu(c)}</style>`,"</head>","<body>",i.outerHTML,"</body>","</html>"].filter(Boolean).join("")}var Ae=require("@layoutit/polycss-core");function dt(e){return{polygons:e,objectUrls:[],warnings:[],dispose:()=>{}}}function Xs(e={}){return dt((0,Ae.boxPolygons)(e))}function qs(e){return dt((0,Ae.planePolygons)(e))}function Zs(e){return dt((0,Ae.ringPolygons)(e))}function Qs(e){return dt((0,Ae.octahedronPolygons)(e))}function Ks(e={}){return dt((0,Ae.spherePolygons)(e))}function Js(e={}){return dt((0,Ae.tetrahedronPolygons)(e))}function ea(e={}){return dt((0,Ae.icosahedronPolygons)(e))}function ta(e={}){return dt((0,Ae.dodecahedronPolygons)(e))}function na(e={}){return dt((0,Ae.cylinderPolygons)(e))}function oa(e={}){return dt((0,Ae.conePolygons)(e))}function ra(e={}){return dt((0,Ae.torusPolygons)(e))}var Te=require("@layoutit/polycss-core"),Cu=typeof HTMLElement<"u"?HTMLElement:class{};function Tu(e){return e.closest("poly-scene")??null}function Re(e,n,t){let o=e.getAttribute(n);if(!o)return t;let i=parseFloat(o);return Number.isFinite(i)?i:t}function pt(e,n,t){return e.getAttribute(n)??t}function qt(e,n){let t=e.getAttribute(n);if(!t)return;let o=t.split(",").map(i=>parseFloat(i.trim()));if(!(o.length!==3||o.some(i=>!Number.isFinite(i))))return[o[0],o[1],o[2]]}function Eu(e){if(e.length===0)return e;let n=(0,Te.computeSceneBbox)(e),t=(n.min[0]+n.max[0])/2,o=(n.min[1]+n.max[1])/2,i=(n.min[2]+n.max[2])/2;if(t===0&&o===0&&i===0)return e;let r=s=>[s[0]-t,s[1]-o,s[2]-i];return e.map(s=>({...s,vertices:s.vertices.map(r)}))}var qe=class extends Cu{constructor(){super(...arguments);this._handle=null}connectedCallback(){this._mount()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(t,o,i){if(o!==i&&this._handle){if(t==="position"||t==="scale"||t==="rotation"||t==="cast-shadow"||t==="receive-shadow"){this._handle.setTransform({position:qt(this,"position"),scale:(()=>{let r=this.getAttribute("scale");if(!r)return;if(r.includes(","))return qt(this,"scale");let s=parseFloat(r);return Number.isFinite(s)?s:void 0})(),rotation:qt(this,"rotation"),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")});return}this._tearDown(),this._mount()}}_tearDown(){if(this._handle){try{this._handle.dispose()}catch{}this._handle=null}}_mount(){let t=Tu(this);if(!t)return;let o=t.getScene?.();if(!o)return;let i=this.buildPolygons();this.hasAttribute("auto-center")&&(i=Eu(i));let r={polygons:i,objectUrls:[],warnings:[],dispose:()=>{}};this._handle=o.add(r,{position:qt(this,"position"),scale:(()=>{let s=this.getAttribute("scale");if(!s)return;if(s.includes(","))return qt(this,"scale");let c=parseFloat(s);return Number.isFinite(c)?c:void 0})(),rotation:qt(this,"rotation"),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow"),excludeFromAutoCenter:this.hasAttribute("exclude-from-auto-center"),merge:!1})}},jo=class extends qe{static get observedAttributes(){return["size","color","auto-center","position","scale","rotation"]}buildPolygons(){let n=this.getAttribute("size"),t=n?parseFloat(n):void 0;return(0,Te.boxPolygons)({size:t!==void 0&&Number.isFinite(t)?t:void 0,color:pt(this,"color")})}},$o=class extends qe{static get observedAttributes(){return["axis","size","offset","color","auto-center","position","scale","rotation","cast-shadow","receive-shadow"]}buildPolygons(){let n=Re(this,"axis",2),t=n===0||n===1||n===2?n:2,o=this.getAttribute("offset"),i=o===null?0:parseFloat(o);return(0,Te.planePolygons)({axis:t,size:Re(this,"size",.4),offset:Number.isFinite(i)?i:0,color:pt(this,"color")})}},Wo=class extends qe{static get observedAttributes(){return["axis","radius","segments","half-thickness","color","auto-center","position","scale","rotation"]}buildPolygons(){let n=Re(this,"axis",2),t=n===0||n===1||n===2?n:2,o=this.getAttribute("half-thickness");return(0,Te.ringPolygons)({axis:t,radius:Re(this,"radius",50),segments:Re(this,"segments",32),halfThickness:o?parseFloat(o):void 0,color:pt(this,"color")})}},Uo=class extends qe{static get observedAttributes(){return["size","color","center","auto-center","position","scale","rotation"]}buildPolygons(){return(0,Te.octahedronPolygons)({center:qt(this,"center")??[0,0,0],size:Re(this,"size",50),color:pt(this,"color")})}},Go=class extends qe{static get observedAttributes(){return["size","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,Te.tetrahedronPolygons)({size:Re(this,"size",100),color:pt(this,"color")})}},Yo=class extends qe{static get observedAttributes(){return["size","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,Te.icosahedronPolygons)({size:Re(this,"size",100),color:pt(this,"color")})}},Xo=class extends qe{static get observedAttributes(){return["size","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,Te.dodecahedronPolygons)({size:Re(this,"size",100),color:pt(this,"color")})}},qo=class extends qe{static get observedAttributes(){return["radius","subdivisions","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,Te.spherePolygons)({radius:Re(this,"radius",50),subdivisions:Re(this,"subdivisions",1),color:pt(this,"color")})}},Zo=class extends qe{static get observedAttributes(){return["radius","radius-top","height","radial-segments","color","auto-center","position","scale","rotation"]}buildPolygons(){let n=this.getAttribute("radius-top");return(0,Te.cylinderPolygons)({radius:Re(this,"radius",50),radiusTop:n?parseFloat(n):void 0,height:Re(this,"height",100),radialSegments:Re(this,"radial-segments",12),color:pt(this,"color")})}},Qo=class extends qe{static get observedAttributes(){return["radius","height","radial-segments","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,Te.conePolygons)({radius:Re(this,"radius",50),height:Re(this,"height",100),radialSegments:Re(this,"radial-segments",12),color:pt(this,"color")})}},Ko=class extends qe{static get observedAttributes(){return["radius","tube","radial-segments","tubular-segments","color","auto-center","position","scale","rotation"]}buildPolygons(){return(0,Te.torusPolygons)({radius:Re(this,"radius",50),tube:Re(this,"tube",15),radialSegments:Re(this,"radial-segments",12),tubularSegments:Re(this,"tubular-segments",16),color:pt(this,"color")})}};he(de,require("@layoutit/polycss-core"));var ye=require("@layoutit/polycss-core/three"),Me=require("@layoutit/polycss-core");function aa(e,n={}){return vt(e.toPolyCameraState(n))}function la(e,n={}){return ut(e.toPolyCameraState(n))}function Au(e,n){let t=n.camera instanceof sa.PerspectiveCamera?aa(n.camera,n.cameraOptions):la(n.camera,n.cameraOptions),{camera:o,cameraOptions:i,polygons:r,meshes:s,...c}=n,l=Yt(e,{...c,textureLighting:c.textureLighting??"baked",camera:t});if(s)for(let d of s)l.add(ia(d.polygons),{merge:!1,...d.transform});else l.add(ia(r??[]),{merge:!1});return l}function ia(e){return{polygons:e,objectUrls:[],warnings:[],dispose(){}}}0&&(module.exports={AmbientLight,DirectionalLight,Euler,Object3D,OrthographicCamera,PerspectiveCamera,PointLight,Vector3,boxPolygons,conePolygons,createPolyOrthographicCamera,createPolyOrthographicCameraFromThree,createPolyPerspectiveCamera,createPolyPerspectiveCameraFromThree,createPolyScene,cylinderPolygons,dodecahedronPolygons,icosahedronPolygons,loadMesh,mountPolyThreeScene,octahedronPolygons,planePolygons,polyToThreeDirection,polyToThreePoint,spherePolygons,tetrahedronPolygons,threeToPolyDirection,threeToPolyPoint,torusPolygons,transformPointToPoly,transformPolygonsToPoly});
|