toposync-ext-structural 0.4.3__tar.gz → 0.4.4__tar.gz
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.
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/PKG-INFO +1 -1
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/pyproject.toml +1 -1
- toposync_ext_structural-0.4.4/src/toposync_ext_structural/static/449.js +2 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/src/elements/AreaElementType.tsx +207 -51
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/src/tools/structuralTools.ts +268 -68
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/src/wallGeometry.test.ts +188 -22
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/src/wallGeometry.ts +185 -35
- toposync_ext_structural-0.4.3/src/toposync_ext_structural/static/449.js +0 -2
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/.gitignore +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/LICENSE +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/README.md +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/src/toposync_ext_structural/__init__.py +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/src/toposync_ext_structural/extension.json +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/src/toposync_ext_structural/plugin.py +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/src/toposync_ext_structural/static/326.js +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/src/toposync_ext_structural/static/326.js.LICENSE.txt +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/src/toposync_ext_structural/static/449.js.LICENSE.txt +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/src/toposync_ext_structural/static/main.js +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/src/toposync_ext_structural/static/remoteEntry.js +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/package.json +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/src/activate.tsx +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/src/colors.ts +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/src/constants.ts +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/src/elements/PoolElementType.tsx +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/src/elements/WallElementType.tsx +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/src/entry.ts +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/src/geometry.ts +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/src/parsing.ts +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/src/textures.ts +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/src/translations.ts +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/src/wallOpenings.ts +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/tsconfig.json +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/tsconfig.wall-geometry-test.json +0 -0
- {toposync_ext_structural-0.4.3 → toposync_ext_structural-0.4.4}/ui/webpack.config.js +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 449.js.LICENSE.txt */
|
|
2
|
+
"use strict";(self.webpackChunk_toposync_extension_structural_ui=self.webpackChunk_toposync_extension_structural_ui||[]).push([[449],{94(t,e,n){var o=n(496),r=Symbol.for("react.element"),a=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function l(t,e,n){var o,l={},c=null,u=null;for(o in void 0!==n&&(c=""+n),void 0!==e.key&&(c=""+e.key),void 0!==e.ref&&(u=e.ref),e)a.call(e,o)&&!s.hasOwnProperty(o)&&(l[o]=e[o]);if(t&&t.defaultProps)for(o in e=t.defaultProps)void 0===l[o]&&(l[o]=e[o]);return{$$typeof:r,type:t,key:c,ref:u,props:l,_owner:i.current}}e.jsx=l,e.jsxs=l},449(t,e,n){n.r(e),n.d(e,{activate:()=>pe});var o=n(870),r=n(496);function a(t){const e=t.trim().replace(/^#/,"");return/^[0-9a-fA-F]{6}$/.test(e)?{r:Number.parseInt(e.slice(0,2),16),g:Number.parseInt(e.slice(2,4),16),b:Number.parseInt(e.slice(4,6),16)}:null}function i(t,e){const n=a(t),o=Math.max(0,Math.min(1,e));return n?`rgba(${n.r},${n.g},${n.b},${o})`:`rgba(99,102,241,${o})`}function s(t,e,n){const o=a(t),r=a(e);if(!o||!r)return t;const i=Math.max(0,Math.min(1,n));return function(t){const e=t=>Math.round(Math.max(0,Math.min(255,t))).toString(16).padStart(2,"0");return`#${e(t.r)}${e(t.g)}${e(t.b)}`}({r:o.r+(r.r-o.r)*i,g:o.g+(r.g-o.g)*i,b:o.b+(r.b-o.b)*i})}function l(t,e){return e>=0?s(t,"#ffffff",e):s(t,"#000000",Math.abs(e))}const c="com.toposync.structural.wall",u="com.toposync.structural.area",d="com.toposync.structural.pool",p="#dcddda",m=.12,h="#dcddda",x="toposync.structural.area.fill.v1";function f(t,e){return"number"==typeof t&&Number.isFinite(t)?t:e}function g(t,e){return"string"==typeof t?t:e}function w(t){return/^#[0-9a-fA-F]{6}$/.test(t)}function y(t){try{if(!w(t))return;localStorage.setItem(x,t)}catch{}}function M(t,e){if(!t||"object"!=typeof t||Array.isArray(t))return e;const n=t;return{x:f(n.x,e.x),z:f(n.z,e.z)}}function _(t){return Array.isArray(t)?t.map(t=>M(t,{x:0,z:0})).filter(t=>Number.isFinite(t.x)&&Number.isFinite(t.z)):[]}function b(t){const e=document.createElement("canvas");return e.width=t,e.height=t,e}function v(t,e){return t+Math.floor(Math.random()*(e-t+1))}function k(t,e,n,o){t.save(),t.globalAlpha=o;for(let o=0;o<n;o++){const n=Math.random()*e,o=Math.random()*e,r=1+2*Math.random(),a=1+2*Math.random(),i=v(0,255);t.fillStyle=`rgb(${i},${i},${i})`,t.fillRect(n,o,r,a)}t.restore()}function z(t){const e=b(t),n=e.getContext("2d");if(!n)return e;n.fillStyle="#6b7280",n.fillRect(0,0,t,t);const o=t/10,r=2.2*o,a=Math.max(1,Math.round(.01*t));for(let e=0;e<10;e++){const i=e*o;for(let s=-(e%2==0?0:r/2);s<t+r;s+=r){const t=Math.floor(s+a),e=Math.floor(i+a),l=Math.ceil(r-2*a),c=Math.ceil(o-2*a),u=v(86,140);n.fillStyle=`rgb(${u},${u},${u})`,n.fillRect(t,e,l,c)}}n.strokeStyle="#111827",n.lineWidth=a,n.globalAlpha=.85;for(let e=0;e<=10;e++){const r=e*o;n.beginPath(),n.moveTo(0,r+.5),n.lineTo(t,r+.5),n.stroke()}for(let e=0;e<10;e++){const a=e*o;for(let i=-(e%2==0?0:r/2);i<t+r;i+=r){const t=i;n.beginPath(),n.moveTo(t+.5,a),n.lineTo(t+.5,a+o),n.stroke()}}return k(n,t,Math.floor(t*t/10),.06),e}function S(t){const e=b(t),n=e.getContext("2d");if(!n)return e;n.fillStyle="#7c5d3a",n.fillRect(0,0,t,t),n.save(),n.globalAlpha=.35;for(let e=0;e<t;e+=1){const o=e/t,r=Math.sin(o*Math.PI*8+1.2*Math.sin(o*Math.PI*2)),a=Math.round(88+20*r+12*Math.random());n.fillStyle=`rgb(${a},${Math.round(.72*a)},${Math.round(.45*a)})`,n.fillRect(0,e,t,1)}n.restore(),n.save(),n.globalAlpha=.18,n.strokeStyle="#3f2f1f",n.lineWidth=1;for(let e=0;e<48;e++){const e=Math.random()*t,o=Math.random()*t,r=2+6*Math.random(),a=1+3*Math.random();n.beginPath(),n.ellipse(e,o,r,a,Math.random()*Math.PI,0,2*Math.PI),n.stroke()}return n.restore(),k(n,t,Math.floor(t*t/4),.06),e}function N(t){const e=b(t),n=e.getContext("2d");return n?(n.fillStyle="#9ca3af",n.fillRect(0,0,t,t),k(n,t,Math.floor(t*t/2),.08),k(n,t,Math.floor(t*t/3),.06),e):e}function j(t){const e=b(t),n=e.getContext("2d");if(!n)return e;n.fillStyle="#166534",n.fillRect(0,0,t,t),k(n,t,Math.floor(t*t/2),.1),n.save(),n.globalAlpha=.2,n.strokeStyle="#052e16",n.lineWidth=1;for(let e=0;e<360;e++){const e=Math.random()*t,o=Math.random()*t,r=4+10*Math.random(),a=-Math.PI/2+.8*(Math.random()-.5);n.beginPath(),n.moveTo(e,o),n.lineTo(e+Math.cos(a)*r,o+Math.sin(a)*r),n.stroke()}n.globalAlpha=.14,n.strokeStyle="#4ade80";for(let e=0;e<180;e++){const e=Math.random()*t,o=Math.random()*t,r=3+8*Math.random(),a=-Math.PI/2+.9*(Math.random()-.5);n.beginPath(),n.moveTo(e,o),n.lineTo(e+Math.cos(a)*r,o+Math.sin(a)*r),n.stroke()}return n.restore(),e}function W(t){const e=b(t),n=e.getContext("2d");if(!n)return e;n.fillStyle="#14532d",n.fillRect(0,0,t,t),k(n,t,Math.floor(t*t/2),.08),k(n,t,Math.floor(t*t/3),.06),n.save(),n.globalAlpha=.18,n.strokeStyle="#052e16",n.lineWidth=1;for(let e=0;e<900;e++){const e=Math.random()*t,o=Math.random()*t,r=4+12*Math.random(),a=-Math.PI/2+.9*(Math.random()-.5);n.beginPath(),n.moveTo(e,o),n.lineTo(e+Math.cos(a)*r,o+Math.sin(a)*r),n.stroke()}n.globalAlpha=.12,n.strokeStyle="#86efac";for(let e=0;e<520;e++){const e=Math.random()*t,o=Math.random()*t,r=3+10*Math.random(),a=-Math.PI/2+1*(Math.random()-.5);n.beginPath(),n.moveTo(e,o),n.lineTo(e+Math.cos(a)*r,o+Math.sin(a)*r),n.stroke()}return n.restore(),e}const T=new Map;function P(t,e,n,o){const r=T.get(e);if(r)return r;const a=n(o?.size??256),i=new t.CanvasTexture(a);return i.wrapS=t.RepeatWrapping,i.wrapT=t.RepeatWrapping,i.colorSpace=t.SRGBColorSpace,i.anisotropy=o?.anisotropy??4,T.set(e,i),i}function D(t,e){return"none"===t||"brick"===t||"concrete"===t?t:e}function C(t,e){return"none"===t||"grass"===t||"concrete"===t?t:e}function A(t,e){return"none"===t||"wood"===t||"concrete"===t||"glass"===t||"transparent"===t?t:e}function F(t,e){return"none"===e||"glass"===e||"transparent"===e?null:"wood"===e?P(t,"opening:wood",S,{size:256,anisotropy:4}):"concrete"===e?P(t,"opening:concrete",N,{size:256,anisotropy:4}):null}function E(t,e){const n=t.x-e.x,o=t.z-e.z;return Math.hypot(n,o)}function I(t,e){return{x:t.x+e.x,z:t.z+e.z}}function R(t,e){return{x:t.x-e.x,z:t.z-e.z}}function B(t,e){return{x:t.x*e,z:t.z*e}}function G(t){const e=Math.hypot(t.x,t.z);return e<=1e-9?{x:1,z:0}:{x:t.x/e,z:t.z/e}}function O(t){return{x:-t.z,z:t.x}}function $(t){if(0===t.length)return{x:0,z:0};const e=t.reduce((t,e)=>({x:t.x+e.x,z:t.z+e.z}),{x:0,z:0});return{x:e.x/t.length,z:e.z/t.length}}function q(t,e){return`${t.elementId}:${e}`}function L(t,e){return"a"===e?t.a:t.b}function K(t,e){return"a"===e?t.direction:B(t.direction,-1)}function X(t,e){return t.x*e.x+t.z*e.z}function V(t,e){return t.x*e.z-t.z*e.x}function Z(t){return Number.isFinite(t.x)&&Number.isFinite(t.z)}function U(t){if(0===t.length)return{x:0,z:0};let e=0,n=0;for(const o of t)e+=o.x,n+=o.z;return{x:e/t.length,z:n/t.length}}function H(t,e,n){return I(t,B(e.normal,n*e.halfWidth))}function Y(t,e,n,o){const r=e.wall,a=n.wall,i=K(r,e.endpoint),s=K(a,n.endpoint);if(Math.abs(V(i,s))<1e-8)return H(t.point,r,o);const l=function(t,e,n,o){const r=V(e,o);return Math.abs(r)<1e-9?null:I(t,B(e,V(R(n,t),o)/r))}(H(t.point,r,o),i,I(t.point,B(a.normal,o*a.halfWidth)),s);if(!l||!Z(l))return H(t.point,r,o);const c=Math.max(2*Math.min(r.halfWidth,a.halfWidth),1e-6);return E(l,t.point)>c+1e-9?H(t.point,r,o):l}function J(t,e){if(2!==t.refs.length)return{left:H(t.point,e.wall,1),right:H(t.point,e.wall,-1)};const n=t.refs[0]===e?t.refs[1]:t.refs[0];return{left:Y(t,e,n,1),right:Y(t,e,n,-1)}}function Q(t,e){return I(t.a,B(t.direction,e))}function tt(t,e,n){return Math.max(e,Math.min(n,t))}function et(t,e){return Math.min(Math.min(t.width,e.width)/2,.06)}function nt(t){if(0===t.refs.length)return 0;const e=Math.min(...t.refs.map(t=>t.wall.width));return Math.min(e/2,.06)}function ot(t){const e=[];for(const n of t){if(n.type!==c)continue;const t=M(n.props.a,{x:n.position.x,z:n.position.z}),o=M(n.props.b,{x:n.position.x+1,z:n.position.z}),r=E(t,o);if(!Number.isFinite(r)||r<=1e-6)continue;const a=Math.max(.04,f(n.props.width,m)),i=G(R(o,t));e.push({element:n,elementId:n.id,a:t,b:o,width:a,halfWidth:a/2,length:r,direction:i,normal:O(i)})}return e}function rt(t){const e=ot(t),n=[];for(const t of e)n.push({wall:t,endpoint:"a",point:t.a}),n.push({wall:t,endpoint:"b",point:t.b});const o=function(t){const e=Array.from({length:t},(t,e)=>e);function n(t){let n=t;for(;e[n]!==n;)e[n]=e[e[n]],n=e[n];return n}return{find:n,union:function(t,o){const r=n(t),a=n(o);r!==a&&(e[a]=r)}}}(n.length);for(let t=0;t<n.length;t+=1)for(let e=t+1;e<n.length;e+=1){const r=n[t],a=n[e];if(r.wall.elementId===a.wall.elementId)continue;const i=et(r.wall,a.wall);E(r.point,a.point)<=i+1e-9&&o.union(t,e)}const r=new Map;for(let t=0;t<n.length;t+=1){const e=o.find(t),a=r.get(e)??[];a.push(n[t]),r.set(e,a)}const a=[],i=new Map;let s=0;for(const t of r.values()){const e={id:`wall-node:${s}`,point:U(t.map(t=>t.point)),refs:t};s+=1,a.push(e);for(const n of t)i.set(q(n.wall,n.endpoint),e)}return{walls:e,nodes:a,endpointNodes:i}}function at(t,e){return function(t){const e=rt(t),n=new Map;for(const t of e.walls){const o=e.endpointNodes.get(q(t,"a")),r=e.endpointNodes.get(q(t,"b"));if(!o||!r)continue;const a=o.refs.find(e=>e.wall.elementId===t.elementId&&"a"===e.endpoint),i=r.refs.find(e=>e.wall.elementId===t.elementId&&"b"===e.endpoint);if(!a||!i)continue;const s=J(o,a),l=J(r,i),c=[s.left,l.left,l.right,s.right];c.every(Z)&&n.set(t.elementId,{wall:t,startNode:o,endNode:r,startLeft:s.left,startRight:s.right,endLeft:l.left,endRight:l.right,polygon:c})}return n}(e.some(e=>e.id===t.id)?e:[...e,t]).get(t.id)??null}function it(t,e,n){const o=t.wall,r=tt(Math.min(e,n),0,o.length),a=tt(Math.max(e,n),0,o.length);if(a-r<=1e-6)return null;const i=Q(o,r),s=Q(o,a),l=r<=1e-6,c=a>=o.length-1e-6,u=l?t.startLeft:I(i,B(o.normal,o.halfWidth)),d=l?t.startRight:I(i,B(o.normal,-o.halfWidth)),p=[u,c?t.endLeft:I(s,B(o.normal,o.halfWidth)),c?t.endRight:I(s,B(o.normal,-o.halfWidth)),d];return p.every(Z)?{start:r,end:a,points:p}:null}function st(t,e){if(0===e.length)return e;const n=rt(t);return 0===n.nodes.length?e:e.map(t=>{let e=null;for(const o of n.nodes){const n=nt(o);if(n<=0)continue;const r=E(t,o.point);r>n+1e-9||(!e||r<e.distance)&&(e={nodeId:o.id,point:o.point,distance:r})}return e?.point??t})}let lt=null;function ct(t){const e=Math.random(),n=Math.random(),o=Math.sqrt(e),r=1-o,a=n*o,i=1-r-a;return{x:t.ax*r+t.bx*a+t.cx*i,z:t.az*r+t.bz*a+t.cz*i}}function ut(t){return{type:u,layerGroup:"areas",name:{key:"ext.structural.area.name",fallback:"Area"},description:{key:"ext.structural.area.desc",fallback:"Area (polygon) in 2D."},defaultProps:{fill:h,opacity:1,texture:"none",vertices:[{x:-1,z:-1},{x:1,z:-1},{x:1,z:1},{x:-1,z:1}]},getMain2DBounds:t=>function(t){if(0===t.length)return null;let e=t[0].x,n=t[0].x,o=t[0].z,r=t[0].z;for(let a=1;a<t.length;a+=1){const i=t[a];e=Math.min(e,i.x),n=Math.max(n,i.x),o=Math.min(o,i.z),r=Math.max(r,i.z)}return{minX:e,maxX:n,minZ:o,maxZ:r}}(_(t.props.vertices)),renderMain2DVector:({element:t,elements:e})=>{const n=st(e,_(t.props.vertices));if(n.length<3)return null;const r=g(t.props.fill,h),a=f(t.props.opacity,1),s=a<.001?0:a;if(s<=0)return null;const c=C(t.props.texture,"none"),u=function(t){return t.map(t=>`${t.x},${t.z}`).join(" ")}(n),d=i(l(r,"grass"===c?-.24:-.16),Math.min(.34,.34*s)),p=i(l(r,.42),Math.min(.2,.2*s)),m="grass"===c?"mainVector2dGrassPattern":"concrete"===c?"mainVector2dConcretePattern":"";return(0,o.jsxs)("g",{className:"mainVector2dArea",children:[(0,o.jsx)("polygon",{points:u,fill:i(r,Math.min(.92,Math.max(0,s))),stroke:d,strokeWidth:.026,vectorEffect:"non-scaling-stroke",filter:"url(#mainVector2dSoftShadow)"}),m?(0,o.jsx)("polygon",{points:u,fill:`url(#${m})`,opacity:Math.min(.42,.38*s)}):null,(0,o.jsx)("polygon",{points:u,fill:"none",stroke:p,strokeWidth:.01,vectorEffect:"non-scaling-stroke"})]})},create3D:({THREE:t,view:e,elements:n},o)=>{const r=new t.Group,a=new t.MeshStandardMaterial({color:h,roughness:.95,metalness:0,side:t.DoubleSide,transparent:!1,opacity:1,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1});a.stencilWrite=!0,a.stencilRef=1,a.stencilFunc=t.NotEqualStencilFunc,a.stencilFail=t.KeepStencilOp,a.stencilZFail=t.KeepStencilOp,a.stencilZPass=t.KeepStencilOp,a.stencilWriteMask=0,a.stencilFuncMask=255;let i=null,s="",l=null,c=null,u="",d=n;function p(t){return st(d,_(t.props.vertices))}function m(e,n,o){if(l&&(r.remove(l),l.geometry.dispose(),l=null),!(n>0))return;const a=new t.PlaneGeometry(1,1,1,4);a.translate(0,.5,0);const i=a,s=new t.InstancedBufferAttribute(new Float32Array(n),1);i.setAttribute("instanceSeed",s);const u=function(){if(c)return c;const e=function(t){if(lt)return lt;const e=64,n=document.createElement("canvas");n.width=e,n.height=e;const o=n.getContext("2d");if(o){o.clearRect(0,0,e,e),o.fillStyle="black",o.fillRect(0,0,e,e);const t=o.createLinearGradient(0,e,0,0);t.addColorStop(0,"rgba(255,255,255,0)"),t.addColorStop(.18,"rgba(255,255,255,1)"),t.addColorStop(1,"rgba(255,255,255,1)"),o.fillStyle=t,o.beginPath(),o.moveTo(32,1.28),o.quadraticCurveTo(37.12,28.8,39.68,62.72),o.quadraticCurveTo(32,57.6,24.32,62.72),o.quadraticCurveTo(26.88,28.8,32,1.28),o.closePath(),o.fill(),o.globalCompositeOperation="destination-in";const n=o.createRadialGradient(32,51.2,0,32,51.2,35.2);n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(1,"rgba(255,255,255,0)"),o.fillStyle=n,o.fillRect(0,0,e,e)}const r=new t.CanvasTexture(n);return r.wrapS=t.ClampToEdgeWrapping,r.wrapT=t.ClampToEdgeWrapping,r.magFilter=t.LinearFilter,r.minFilter=t.LinearMipmapLinearFilter,r.colorSpace=t.NoColorSpace??t.LinearSRGBColorSpace,lt=r,r}(t),n=new t.MeshStandardMaterial({color:1483594,roughness:.88,metalness:0,side:t.DoubleSide,alphaMap:e,alphaTest:.35});return n.stencilWrite=!0,n.stencilRef=1,n.stencilFunc=t.NotEqualStencilFunc,n.stencilFail=t.KeepStencilOp,n.stencilZFail=t.KeepStencilOp,n.stencilZPass=t.KeepStencilOp,n.stencilWriteMask=0,n.stencilFuncMask=255,n.onBeforeCompile=t=>{t.uniforms.uTime={value:0},t.vertexShader=t.vertexShader.replace("#include <common>","#include <common>\nuniform float uTime;\nattribute float instanceSeed;").replace("#include <begin_vertex>","#include <begin_vertex>\nfloat h01 = clamp(position.y, 0.0, 1.0);\nfloat wind = sin(uTime * 1.2 + instanceSeed + position.x * 2.4) * 0.12;\nfloat wind2 = cos(uTime * 0.9 + instanceSeed * 1.7) * 0.08;\ntransformed.x += (wind + wind2) * h01 * h01;\ntransformed.z += sin(uTime * 1.1 + instanceSeed * 0.7) * 0.06 * h01 * h01;"),n.userData.shader=t},c=n,n}();u.color.set(o);const d=new t.InstancedMesh(i,u,n);d.frustumCulled=!1,d.renderOrder=5;const p=function(t){const e=t.getAttribute("position"),n=t.getIndex(),o=[],r=[];let a=0;function i(t,n,i){const s=e.getX(t),l=e.getZ(t),c=e.getX(n),u=e.getZ(n),d=e.getX(i),p=e.getZ(i),m=.5*Math.abs((c-s)*(p-l)-(d-s)*(u-l));m>1e-9&&(a+=m,o.push({ax:s,az:l,bx:c,bz:u,cx:d,cz:p,area:m}),r.push(a))}if(n)for(let t=0;t<n.count;t+=3)i(n.getX(t),n.getX(t+1),n.getX(t+2));else for(let t=0;t<e.count;t+=3)i(t,t+1,t+2);return{triangles:o,cdf:r,totalArea:a}}(e);if(!(p.totalArea>1e-9)||0===p.triangles.length)return void i.dispose();const m=new t.Matrix4,h=new t.Quaternion,x=new t.Vector3,f=new t.Vector3,g=new t.Vector3(0,1,0);for(let t=0;t<n;t+=1){const e=Math.random()*p.totalArea;let n=0,o=p.cdf.length-1;for(;n<o;){const t=n+o>>1;e<=p.cdf[t]?o=t:n=t+1}const r=ct(p.triangles[n]),a=Math.random()*Math.PI*2;h.setFromAxisAngle(g,a);const i=.1+.2*Math.random(),l=i*(.12+.1*Math.random());f.set(l,i,1),x.set(r.x,.012,r.z),m.compose(x,h,f),d.setMatrixAt(t,m),s.setX(t,1e3*Math.random())}d.instanceMatrix.needsUpdate=!0,s.needsUpdate=!0,l=d,r.add(d)}function x(n,o){d=o?.elements??d;const x=p(n),w=JSON.stringify(x.map(t=>({x:Math.round(1e3*(t.x-n.position.x))/1e3,z:Math.round(1e3*(t.z-n.position.z))/1e3})));if(w!==s){s=w;const e=function(e){const n=p(e);if(n.length<3)return null;const o=n.map(t=>({x:t.x-e.position.x,z:t.z-e.position.z})),r=new t.Shape;r.moveTo(o[0].x,-o[0].z);for(let t=1;t<o.length;t++)r.lineTo(o[t].x,-o[t].z);r.closePath();const a=new t.ShapeGeometry(r);a.rotateX(-Math.PI/2);const i=a.getAttribute("position"),s=new t.BufferAttribute(new Float32Array(2*i.count),2);for(let t=0;t<i.count;t++){const n=i.getX(t)+e.position.x,o=i.getZ(t)+e.position.z;s.setXY(t,n,o)}return a.setAttribute("uv",s),a}(n);e?i?(i.geometry.dispose(),i.geometry=e):(i=new t.Mesh(e,a),i.receiveShadow=!0,r.add(i)):i&&(r.remove(i),i.geometry.dispose(),i=null)}const y=g(n.props.fill,h),M=Math.max(0,Math.min(1,f(n.props.opacity,1)))<.001,_=M?0:1,b=C(n.props.texture,"none"),v=e.graphicsQuality??"simplified",k=function(t,e,n="simplified"){return"none"===e?null:"grass"===e?"detailed"===n?P(t,"floor:grass:detailed",W,{size:512,anisotropy:8}):P(t,"floor:grass:simplified",j,{size:256,anisotropy:4}):"concrete"===e?P(t,"floor:concrete",N,{size:256,anisotropy:4}):null}(t,b,v);if(a.color.set(y),a.map!==k&&(a.map=k,a.needsUpdate=!0),a.roughness="grass"===b?.98:.95,a.metalness=0,a.opacity=_,a.transparent=M,a.depthWrite=!M,i&&(i.visible=!M,i.position.y=.01),M||"grass"!==b||"detailed"!==v||!Boolean(i&&i.geometry))return void(l&&(l.visible=!1));l&&(l.visible=!0);const z=function(t){if(t.length<3)return 0;let e=0;for(let n=0;n<t.length;n+=1){const o=t[n],r=t[(n+1)%t.length];e+=o.x*r.z-r.x*o.z}return Math.abs(e)/2}(x),S=Math.max(240,Math.min(1800,Math.floor(35*z))),T=`${w}:${S}`;T!==u&&i?(u=T,m(i.geometry,S,y)):c&&c.color.set(y)}return x(o),{object:r,update:x,tick:()=>{if(!c||!l?.visible)return!1;const t=c.userData.shader;return!!t&&(t.uniforms.uTime.value=performance.now()/1e3,!0)},dispose:()=>{i&&i.geometry.dispose(),a.dispose(),l&&l.geometry.dispose(),c?.dispose()}}},render2D:({ctx:t,element:e,elements:n,viewport:o})=>{const r=st(n,_(e.props.vertices));if(r.length<3)return;const a=g(e.props.fill,h),s=f(e.props.opacity,1)<.001?0:1,l=r.map(t=>o.worldToScreen(t));t.save(),t.beginPath(),t.moveTo(l[0].x,l[0].y);for(let e=1;e<l.length;e++)t.lineTo(l[e].x,l[e].y);t.closePath(),t.fillStyle=i(a,s),t.fill(),t.strokeStyle=i("#e6e8f2",.22),t.lineWidth=2,t.stroke(),t.restore()},renderEditorModal:({element:e,update:n,remove:r,close:a})=>(0,o.jsx)(dt,{element:e,update:n,remove:r,close:a,i18n:t})}}function dt({element:t,update:e,remove:n,close:r,i18n:a}){const{t:i}=a.useI18n(),s=g(t.props.fill,h),l=f(t.props.opacity,1)<.001,c=C(t.props.texture,"none");return(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{className:"field",children:[(0,o.jsx)("div",{className:"label",children:i("ext.structural.editor.area_name")}),(0,o.jsx)("input",{className:"input",value:t.name,onChange:t=>e({name:t.target.value})})]}),(0,o.jsxs)("div",{className:"rowWrap",children:[(0,o.jsxs)("div",{className:"field",style:{flex:1,minWidth:160},children:[(0,o.jsx)("div",{className:"label",children:i("ext.structural.editor.area_color")}),(0,o.jsx)("input",{className:"input",type:"color",value:s,onChange:t=>{const n=t.target.value;y(n),e({props:{fill:n}})}})]}),(0,o.jsxs)("div",{className:"field",style:{flex:1,minWidth:160},children:[(0,o.jsx)("div",{className:"label",children:i("ext.structural.editor.floor_texture")}),(0,o.jsxs)("select",{className:"input",value:c,onChange:t=>{const n=C(t.target.value,c),o="grass"===n?"#16a34a":"concrete"===n?h:s;y(o),e({props:{texture:n,fill:o}})},children:[(0,o.jsx)("option",{value:"none",children:i("ext.structural.editor.texture.none")}),(0,o.jsx)("option",{value:"grass",children:i("ext.structural.editor.texture.grass")}),(0,o.jsx)("option",{value:"concrete",children:i("ext.structural.editor.texture.concrete")})]})]}),(0,o.jsxs)("label",{className:"chipButton",style:{display:"inline-flex",alignItems:"center",gap:10},children:[(0,o.jsx)("input",{type:"checkbox",checked:l,onChange:t=>e({props:{opacity:t.target.checked?0:1}})}),(0,o.jsx)("span",{children:i("ext.structural.editor.transparent")})]})]}),(0,o.jsx)("div",{className:"sectionDivider"}),(0,o.jsxs)("div",{className:"rowWrap",children:[(0,o.jsx)("button",{className:"dangerButton",type:"button",onClick:n,children:i("core.actions.delete")}),(0,o.jsx)("button",{className:"chipButton",type:"button",onClick:r,children:i("core.actions.close")})]})]})}let pt=null,mt=null;function ht(t,e,n){return Math.max(e,Math.min(n,t))}function xt(t){return{depth_m:ht(f(t.depth_m,1.4),.1,20),vertices:_(t.vertices)}}function ft(t){return{type:d,layerGroup:"areas",name:{key:"ext.structural.pool.name",fallback:"Pool"},description:{key:"ext.structural.pool.desc",fallback:"Swimming pool (hole) in 2D."},defaultProps:{depth_m:1.4,vertices:[{x:-1,z:-1},{x:1,z:-1},{x:1,z:1},{x:-1,z:1}]},getMain2DBounds:t=>function(t){if(0===t.length)return null;let e=t[0].x,n=t[0].x,o=t[0].z,r=t[0].z;for(let a=1;a<t.length;a+=1){const i=t[a];e=Math.min(e,i.x),n=Math.max(n,i.x),o=Math.min(o,i.z),r=Math.max(r,i.z)}return{minX:e,maxX:n,minZ:o,maxZ:r}}(xt(t.props).vertices),renderMain2DVector:({element:t})=>{const e=xt(t.props);if(e.vertices.length<3)return null;const n=function(t){return t.map(t=>`${t.x},${t.z}`).join(" ")}(e.vertices),r=ht(e.depth_m/4.5,.16,.42);return(0,o.jsxs)("g",{className:"mainVector2dPool",children:[(0,o.jsx)("polygon",{points:n,fill:`rgba(8,47,73,${r})`,stroke:"rgba(125,211,252,0.60)",strokeWidth:.045,vectorEffect:"non-scaling-stroke",filter:"url(#mainVector2dSoftShadow)"}),(0,o.jsx)("polygon",{points:n,fill:"url(#mainVector2dWaterGradient)",opacity:"0.86"}),(0,o.jsx)("polygon",{points:n,fill:"url(#mainVector2dWaterPattern)",opacity:"0.46"}),(0,o.jsx)("polygon",{points:n,fill:"none",stroke:"rgba(224,242,254,0.58)",strokeWidth:.016,vectorEffect:"non-scaling-stroke"})]})},create3D:({THREE:t,view:e},n)=>{const o=new t.Group,r=new t.BufferGeometry,a=new t.MeshBasicMaterial({color:0});a.colorWrite=!1,a.depthWrite=!1,a.depthTest=!1,a.stencilWrite=!0,a.stencilRef=1,a.stencilFunc=t.AlwaysStencilFunc,a.stencilZPass=t.ReplaceStencilOp;const i=function(t){if(pt)return pt;const e=function(t){const e=document.createElement("canvas");e.width=t,e.height=t;const n=e.getContext("2d");if(!n)return e;n.fillStyle="rgb(128,128,128)",n.fillRect(0,0,t,t),n.save(),n.globalAlpha=.14,n.fillStyle="rgb(150,150,150)";for(let e=0;e<220;e++){const e=Math.random()*t,o=Math.random()*t,r=6+26*Math.random();n.beginPath(),n.arc(e,o,r,0,2*Math.PI),n.fill()}n.globalAlpha=.1,n.fillStyle="rgb(100,100,100)";for(let e=0;e<160;e++){const e=Math.random()*t,o=Math.random()*t,r=4+20*Math.random();n.beginPath(),n.arc(e,o,r,0,2*Math.PI),n.fill()}return n.restore(),e}(256),n=new t.CanvasTexture(e);return n.wrapS=t.RepeatWrapping,n.wrapT=t.RepeatWrapping,n.repeat.set(2,2),n.anisotropy=4,n.colorSpace=t.NoColorSpace??t.LinearSRGBColorSpace,pt=n,n}(t),s=function(t){if(mt)return mt;const e=function(t){const e=document.createElement("canvas");e.width=t,e.height=t;const n=e.getContext("2d");if(!n)return e;const o=n.createImageData(t,t),r=o.data,a=2*Math.PI,i=[{dirX:.92,dirY:.39,freq:3,amp:.7,phase:Math.random()*a},{dirX:-.16,dirY:.99,freq:5,amp:.5,phase:Math.random()*a},{dirX:.68,dirY:-.73,freq:8,amp:.35,phase:Math.random()*a},{dirX:-.91,dirY:-.41,freq:12,amp:.22,phase:Math.random()*a}];for(let e=0;e<t;e+=1){const n=e/t;for(let o=0;o<t;o+=1){const s=o/t;let l=0,c=0;for(const t of i){const e=a*(t.dirX*s+t.dirY*n)*t.freq+t.phase,o=Math.cos(e),r=t.amp*t.freq*a;l+=o*r*t.dirX,c+=o*r*t.dirY}let u=.085*-l,d=1,p=.085*-c;const m=1/Math.sqrt(u*u+d*d+p*p);u*=m,d*=m,p*=m;const h=4*(e*t+o);r[h+0]=Math.round(255*(.5*u+.5)),r[h+1]=Math.round(255*(.5*d+.5)),r[h+2]=Math.round(255*(.5*p+.5)),r[h+3]=255}}return n.putImageData(o,0,0),e}(256),n=new t.CanvasTexture(e);return n.wrapS=t.RepeatWrapping,n.wrapT=t.RepeatWrapping,n.repeat.set(2,2),n.anisotropy=8,n.colorSpace=t.NoColorSpace??t.LinearSRGBColorSpace,mt=n,n}(t),l=new t.MeshStandardMaterial({color:959977,roughness:.18,metalness:.02,transparent:!0,opacity:.68,side:t.DoubleSide,depthWrite:!1,emissive:new t.Color(402490),emissiveIntensity:.1});l.bumpMap=i,l.bumpScale=0;const c=new t.MeshPhysicalMaterial({color:959977,roughness:.12,metalness:0,transmission:.92,thickness:.18,ior:1.33,transparent:!0,opacity:1,side:t.DoubleSide,depthWrite:!1,clearcoat:.62,clearcoatRoughness:.08});c.normalMap=s,c.normalScale=new t.Vector2(.55,.55),c.attenuationColor=new t.Color(402490),c.attenuationDistance=.8;const u=new t.MeshStandardMaterial({color:988970,roughness:.95,metalness:.02,side:t.DoubleSide}),d=new t.MeshStandardMaterial({color:728888,roughness:.98,metalness:0,side:t.DoubleSide}),p=new t.Mesh(r,a);p.renderOrder=-20;const m=new t.Mesh(r,l);m.renderOrder=10;const h=new t.Mesh(r,u),x=new t.Mesh(r,d);o.add(p),o.add(h),o.add(x),o.add(m);let f=null,g=null,w="";function y(n){const o=xt(n.props),a="detailed"===(e.graphicsQuality??"simplified"),i=JSON.stringify({v:o.vertices.map(t=>({x:Math.round(1e3*(t.x-n.position.x))/1e3,z:Math.round(1e3*(t.z-n.position.z))/1e3})),d:Math.round(1e3*o.depth_m)/1e3});if(i!==w){w=i;const e=function(t,e,n){if(n.length<3)return null;const o=n.map(t=>({x:t.x-e.position.x,z:t.z-e.position.z})),r=new t.Shape;r.moveTo(o[0].x,-o[0].z);for(let t=1;t<o.length;t++)r.lineTo(o[t].x,-o[t].z);r.closePath();const a=new t.ShapeGeometry(r);return a.rotateX(-Math.PI/2),a}(t,n,o.vertices),a=function(t,e,n,o){if(n.length<2)return null;const r=n.map(t=>({x:t.x-e.position.x,z:t.z-e.position.z})),a=-Math.abs(o),i=r.length,s=new Float32Array(4*i*3),l=[];for(let t=0;t<i;t++){const e=r[t],n=r[(t+1)%i],o=4*t;s[3*(o+0)+0]=e.x,s[3*(o+0)+1]=0,s[3*(o+0)+2]=e.z,s[3*(o+1)+0]=n.x,s[3*(o+1)+1]=0,s[3*(o+1)+2]=n.z,s[3*(o+2)+0]=n.x,s[3*(o+2)+1]=a,s[3*(o+2)+2]=n.z,s[3*(o+3)+0]=e.x,s[3*(o+3)+1]=a,s[3*(o+3)+2]=e.z,l.push(o+0,o+1,o+2,o+0,o+2,o+3)}const c=new t.BufferGeometry;return c.setAttribute("position",new t.BufferAttribute(s,3)),c.setIndex(l),c.computeVertexNormals(),c}(t,n,o.vertices,o.depth_m);f&&f.dispose(),g&&g.dispose(),f=e,g=a,p.geometry=f??r,m.geometry=f??r,x.geometry=f??r,h.geometry=g??r}const s=Boolean(f&&g);if(p.visible=s,m.visible=s,x.visible=s,h.visible=s,!s)return;p.position.y=.01,h.position.y=0,x.position.y=0-o.depth_m;const u=Math.min(.06,Math.max(.02,.3*o.depth_m));m.position.y=0-u,m.material=a?c:l,a?(c.roughness=.1,c.transmission=.92,c.clearcoat=.65,c.clearcoatRoughness=.08,c.attenuationDistance=.8+.35*ht(o.depth_m,.2,2.5)):(l.roughness=.22,l.opacity=.66,l.emissiveIntensity=.06,l.bumpScale=0)}return y(n),{object:o,update:y,tick:t=>{if("detailed"!==(e.graphicsQuality??"simplified")||!m.visible)return!1;const n=performance.now(),o=s.userData??={};return n-("number"==typeof o.lastOffsetUpdateMs?o.lastOffsetUpdateMs:0)<4||(o.lastOffsetUpdateMs=n,s.offset.x=(s.offset.x+.022*t)%1,s.offset.y=(s.offset.y+.022*t*.7)%1),!0},dispose:()=>{f&&f.dispose(),g&&g.dispose(),r.dispose(),a.dispose(),u.dispose(),d.dispose(),l.dispose(),c.dispose()}}},render2D:({ctx:t,element:e,viewport:n})=>{const o=xt(e.props);if(o.vertices.length<3)return;const r=o.vertices.map(t=>n.worldToScreen(t));t.save(),t.beginPath(),t.moveTo(r[0].x,r[0].y);for(let e=1;e<r.length;e++)t.lineTo(r[e].x,r[e].y);t.closePath(),t.fillStyle=i("#0ea5e9",.14),t.fill(),t.strokeStyle=i("#38bdf8",.65),t.lineWidth=2,t.stroke(),t.restore()},renderEditorModal:({element:e,update:n,remove:r,close:a})=>(0,o.jsx)(gt,{element:e,update:n,remove:r,close:a,i18n:t})}}function gt({element:t,update:e,remove:n,close:a,i18n:i}){const{t:s,locale:l}=i.useI18n(),c=xt(t.props),u=(0,r.useMemo)(()=>new Intl.NumberFormat(l,{minimumFractionDigits:2,maximumFractionDigits:2}),[l]);return(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{className:"card",children:[(0,o.jsxs)("div",{className:"cardHeaderRow",children:[(0,o.jsx)("div",{className:"cardTitle",children:s("ext.structural.pool.name")}),(0,o.jsxs)("div",{className:"cardMeta",children:[u.format(c.depth_m)," m"]})]}),(0,o.jsx)("div",{className:"cardBody",children:s("ext.structural.pool.desc")})]}),(0,o.jsx)("div",{className:"sectionDivider"}),(0,o.jsxs)("div",{className:"field",children:[(0,o.jsx)("div",{className:"label",children:s("ext.structural.editor.pool_name")}),(0,o.jsx)("input",{className:"input",value:t.name,onChange:t=>e({name:t.target.value})})]}),(0,o.jsx)("div",{className:"rowWrap",children:(0,o.jsxs)("div",{className:"field",style:{flex:1,minWidth:160},children:[(0,o.jsx)("div",{className:"label",children:s("ext.structural.editor.pool_depth")}),(0,o.jsx)("input",{className:"input",type:"number",inputMode:"decimal",min:.1,max:20,step:.1,value:c.depth_m,onChange:t=>{const n=Number.parseFloat(t.target.value);Number.isFinite(n)&&e({props:{depth_m:ht(n,.1,20)}})}})]})}),(0,o.jsx)("div",{className:"sectionDivider"}),(0,o.jsxs)("div",{className:"rowWrap",children:[(0,o.jsx)("button",{className:"dangerButton",type:"button",onClick:n,children:s("core.actions.delete")}),(0,o.jsx)("button",{className:"chipButton",type:"button",onClick:a,children:s("core.actions.close")})]})]})}const wt=.25,yt=/^#[0-9a-fA-F]{6}$/;function Mt(t,e,n){return Math.max(e,Math.min(n,t))}function _t(t,e){return"number"==typeof t&&Number.isFinite(t)?t:e}function bt(t){return"number"==typeof t&&Number.isFinite(t)?t:void 0}function vt(t){if("string"!=typeof t)return;const e=t.trim();return e.length>0?e:void 0}function kt(t){return"door"===t?.9:"window"===t?1.2:1}function zt(t){return"door"===t?"#8f806a":"window"===t?"#b9d8f4":void 0}function St(t){return"door"===t?"wood":"window"===t?"glass":"none"}function Nt(){const t=crypto;return t.randomUUID?.()??`opening-${Date.now()}-${Math.random().toString(16).slice(2)}`}function jt(t){if(!t||"object"!=typeof t||Array.isArray(t))return null;const e=t,n=function(t){return"opening"===t||"door"===t||"window"===t}(e.kind)?e.kind:"opening",o=Math.max(wt,_t(e.width_m,kt(n))),r=vt(e.color),a=vt(e.texture);return{id:vt(e.id)??Nt(),kind:n,center_m:_t(e.center_m,0),width_m:o,y_min_m:bt(e.y_min_m),y_max_m:bt(e.y_max_m),color:r&&yt.test(r)?r:void 0,texture:a}}function Wt(t){if(!Array.isArray(t))return[];const e=[],n=new Set;for(const o of t){const t=jt(o);if(t){for(;n.has(t.id);)t.id=Nt();n.add(t.id),e.push(t)}}return e}function Tt(t,e){const n=Math.max(.15,e);if("opening"===t)return{yMin:0,yMax:n};if("door"===t)return{yMin:0,yMax:Math.min(n,2.1)};const o=Math.min(.9,Math.max(0,n-.3));return{yMin:o,yMax:Math.min(n,Math.max(o+.25,2))}}function Pt(t){const e=Math.max(wt,t.width_m);return{id:Nt(),kind:t.kind,center_m:t.center_m,width_m:e,color:zt(t.kind),texture:St(t.kind)}}function Dt(t,e,n){const o=Math.max(.001,e),r=Math.max(.15,n),a=[];for(const e of t){const t=Math.min(wt,o),n=Mt(Number.isFinite(e.width_m)?e.width_m:kt(e.kind),t,o),i=Mt(Number.isFinite(e.center_m)?e.center_m:o/2,n/2,o-n/2),s=i-n/2,l=i+n/2;if(l-s<t-1e-6)continue;const c=Tt(e.kind,r);let u,d;if("opening"===e.kind?(u=0,d=r):(u=Number.isFinite(e.y_min_m??NaN)?e.y_min_m:c.yMin,d=Number.isFinite(e.y_max_m??NaN)?e.y_max_m:c.yMax),u=Mt(u,0,r),d=Mt(d,0,r),d<u){const t=d;d=u,u=t}d-u<.08||a.push({id:e.id,kind:e.kind,center_m:i,width_m:n,start_m:s,end_m:l,y_min_m:u,y_max_m:d,color:e.color,texture:e.texture})}return a.sort((t,e)=>t.start_m-e.start_m||t.id.localeCompare(e.id)),a}function Ct(t){return t.map(t=>{const e={id:t.id,kind:t.kind,center_m:t.center_m,width_m:t.width_m};return"number"==typeof t.y_min_m&&Number.isFinite(t.y_min_m)&&(e.y_min_m=t.y_min_m),"number"==typeof t.y_max_m&&Number.isFinite(t.y_max_m)&&(e.y_max_m=t.y_max_m),t.color&&(e.color=t.color),t.texture&&(e.texture=t.texture),e})}function At(t,e,n){return Math.max(e,Math.min(n,t))}function Ft(t){return Math.round(1e3*t)/1e3}function Et(t,e){const n=function(t,e,n){const o=t.map(t=>({start:At(Math.min(t.start,t.end),0,n),end:At(Math.max(t.start,t.end),0,n)})).filter(t=>t.end-t.start>1e-6).sort((t,e)=>t.start-e.start),r=[];for(const t of o){const e=r[r.length-1];!e||t.start>e.end+1e-6?r.push(t):e.end=Math.max(e.end,t.end)}return r}(e,0,t),o=[];let r=0;for(const t of n)t.start>r+1e-6&&o.push({start:r,end:t.start}),r=Math.max(r,t.end);return r<t-1e-6&&o.push({start:r,end:t}),o}function It(t,e,n){return I(t,B(e,n))}function Rt(t){const e=M(t.props.a,{x:t.position.x,z:t.position.z}),n=M(t.props.b,{x:t.position.x+1,z:t.position.z}),o=Math.max(.04,f(t.props.width,m));return{minX:Math.min(e.x,n.x)-o,maxX:Math.max(e.x,n.x)+o,minZ:Math.min(e.z,n.z)-o,maxZ:Math.max(e.z,n.z)+o}}function Bt(t){return t.map(t=>`${t.x},${t.z}`).join(" ")}function Gt(t,e,n,o,r,a){const i=It(t,e,r),s=It(t,e,a);return[I(i,B(n,o)),I(s,B(n,o)),I(s,B(n,-o)),I(i,B(n,-o))]}function Ot(t,e,n,o){const r=new t.BufferGeometry,a=[],i=[],s=[];function l(t,e,n,o){const r=a.length/3;return a.push(t.x,e,t.z),i.push(n,o),r}function c(t,e,a,i,c){const u=s.length,d=l(t,n,t.x,n),p=l(e,n,e.x,n),m=l(a,o,a.x,o),h=l(i,o,i.x,o);s.push(d,p,m,d,m,h),r.addGroup(u,6,c)}const[u,d,p,m]=e;c(u,d,d,u,0),c(p,m,m,p,0),c(m,u,u,m,1),c(d,p,p,d,1);const h=s.length,x=l(u,o,u.x,u.z),f=l(d,o,d.x,d.z),g=l(p,o,p.x,p.z),w=l(m,o,m.x,m.z);s.push(x,f,g,x,g,w),r.addGroup(h,6,1);const y=s.length,M=l(m,n,m.x,m.z),_=l(p,n,p.x,p.z),b=l(d,n,d.x,d.z),v=l(u,n,u.x,u.z);return s.push(M,_,b,M,b,v),r.addGroup(y,6,1),r.setAttribute("position",new t.Float32BufferAttribute(a,3)),r.setAttribute("uv",new t.Float32BufferAttribute(i,2)),r.setIndex(s),r.computeVertexNormals(),r.computeBoundingBox(),r.computeBoundingSphere(),r}function $t(t,e){if(Array.isArray(t))for(const n of t)e.has(n)||(e.add(n),n.dispose());else e.has(t)||(e.add(t),t.dispose())}function qt(t,e){const n=new Set;for(const o of[...t.children]){const r=o;r.geometry&&"dispose"in r.geometry&&r.geometry.dispose(),e&&r.material&&$t(r.material,n),t.remove(o)}}function Lt(t){return"door"===t?{fill:"rgba(251,146,60,0.20)",stroke:"rgba(251,146,60,0.92)",dash:[7,4]}:"window"===t?{fill:"rgba(56,189,248,0.18)",stroke:"rgba(56,189,248,0.92)",dash:[5,4]}:{fill:"rgba(251,191,36,0.12)",stroke:"rgba(251,191,36,0.92)",dash:[9,5]}}function Kt(t,e){const n=A(e,St(t));return"window"!==t&&"transparent"===n?St(t):n}function Xt(t,e,n,o){const r=n.y_max_m-n.y_min_m;if(n.width_m<=.12||r<=.12)return;const a=At(.11*Math.min(n.width_m,r),.03,.09),i=.48*o,s=.34*o,l=F(t,Kt("door",n.texture)),c=new t.MeshStandardMaterial({color:"#5b5044",roughness:.82,metalness:.05,map:l}),u=new t.MeshStandardMaterial({color:n.color??zt("door")??"#8f806a",roughness:.74,metalness:.08,map:l}),d=new t.BoxGeometry(a,r,i),p=new t.BoxGeometry(a,r,i),m=new t.BoxGeometry(n.width_m,a,i),h=new t.Mesh(d,c),x=new t.Mesh(p,c),f=new t.Mesh(m,c);for(const t of[h,x,f])t.userData.__toposyncAllowPickWhenGhostWalls=!0;const g=0+n.y_min_m+r/2;h.position.set(n.start_m+a/2,g,0),x.position.set(n.end_m-a/2,g,0),f.position.set(n.center_m,0+n.y_max_m-a/2,0);const w=At(.02*a,.001,.004),y=n.width_m-2*a-2*w,M=r-a-w;if(y>.08&&M>.2){const o=new t.BoxGeometry(y,M,s),r=new t.Mesh(o,u);r.userData.__toposyncAllowPickWhenGhostWalls=!0,r.position.set(n.center_m,0+n.y_min_m+M/2,0),r.castShadow=!0,r.receiveShadow=!0,e.add(r)}else u.dispose();for(const t of[h,x,f])t.castShadow=!0,t.receiveShadow=!0,e.add(t)}function Vt(t,e,n,o){const r=n.y_max_m-n.y_min_m;if(n.width_m<=.12||r<=.12)return;const a=At(.09*Math.min(n.width_m,r),.025,.07),i=.35*o,s=.14*o,l=Kt("window",n.texture),c=F(t,l),u=new t.MeshStandardMaterial({color:n.color??zt("window")??"#b9d8f4",roughness:.55,metalness:.18,map:c}),d=new t.BoxGeometry(n.width_m,a,i),p=new t.BoxGeometry(n.width_m,a,i),m=new t.BoxGeometry(a,r,i),h=new t.BoxGeometry(a,r,i),x=new t.Mesh(d,u),f=new t.Mesh(p,u),g=new t.Mesh(m,u),w=new t.Mesh(h,u);for(const t of[x,f,g,w])t.userData.__toposyncAllowPickWhenGhostWalls=!0;const y=0+n.y_min_m+r/2;x.position.set(n.center_m,0+n.y_max_m-a/2,0),f.position.set(n.center_m,0+n.y_min_m+a/2,0),g.position.set(n.start_m+a/2,y,0),w.position.set(n.end_m-a/2,y,0);for(const t of[x,f,g,w])t.castShadow=!0,t.receiveShadow=!0,e.add(t);const M=n.width_m-2.2*a,_=r-2.2*a;if("transparent"===l)return;if(M<=.08||_<=.08)return;const b=new t.BoxGeometry(M,_,s);let v;v="glass"===l?new t.MeshPhysicalMaterial({color:n.color??zt("window")??"#b9d8f4",roughness:.1,metalness:0,transmission:.88,thickness:.05,transparent:!0,opacity:.55,depthWrite:!1,side:t.DoubleSide}):new t.MeshStandardMaterial({color:n.color??zt("window")??"#b9d8f4",roughness:.42,metalness:.12,map:c});const k=new t.Mesh(b,v);k.userData.__toposyncAllowPickWhenGhostWalls=!0,k.position.set(n.center_m,y,0),"glass"===l&&(k.renderOrder=12),k.castShadow=!1,k.receiveShadow="glass"!==l,e.add(k)}function Zt({element:t,update:e,remove:n,close:a,i18n:i}){const{t:s,locale:l}=i.useI18n(),c=g(t.props.color,p),u=D(t.props.texture,"none"),d=(0,r.useMemo)(()=>Wt(t.props.openings),[t.props.openings]),m=(0,r.useMemo)(()=>new Intl.NumberFormat(l,{minimumFractionDigits:2,maximumFractionDigits:2}),[l]),h=(0,r.useMemo)(()=>E(M(t.props.a,{x:t.position.x,z:t.position.z}),M(t.props.b,{x:t.position.x+1,z:t.position.z})),[t]),x=(0,r.useMemo)(()=>[...d].sort((t,e)=>t.center_m-e.center_m||t.id.localeCompare(e.id)),[d]),f=(0,r.useMemo)(()=>{const t=Dt(d,h,3.2),e=new Map;for(const n of t)e.set(n.id,n);return e},[d,h]);function w(t){e({props:{openings:Ct(t)}})}function y(t,e){w(d.map(n=>n.id===t?{...n,...e}:n))}function _(t){const e="door"===t?.9:"window"===t?1.2:1,n=Math.max(0,h),o=At(e,Math.min(wt,n),n),r=Pt({kind:t,center_m:h/2,width_m:o});w([...d,r])}return(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{className:"card",children:[(0,o.jsxs)("div",{className:"cardHeaderRow",children:[(0,o.jsx)("div",{className:"cardTitle",children:s("ext.structural.wall.name")}),(0,o.jsxs)("div",{className:"cardMeta",children:[m.format(h)," m"]})]}),(0,o.jsxs)("div",{className:"cardBody",children:[s("ext.structural.editor.preview")," • ",x.length," ",s("ext.structural.editor.openings")]})]}),(0,o.jsx)("div",{className:"sectionDivider"}),(0,o.jsxs)("div",{className:"rowWrap",children:[(0,o.jsxs)("div",{className:"field",style:{flex:1,minWidth:160},children:[(0,o.jsx)("div",{className:"label",children:s("ext.structural.editor.wall_color")}),(0,o.jsx)("input",{className:"input",type:"color",value:c,onChange:t=>e({props:{color:t.target.value}})})]}),(0,o.jsxs)("div",{className:"field",style:{flex:1,minWidth:160},children:[(0,o.jsx)("div",{className:"label",children:s("ext.structural.editor.wall_texture")}),(0,o.jsxs)("select",{className:"input",value:u,onChange:t=>e({props:{texture:D(t.target.value,u)}}),children:[(0,o.jsx)("option",{value:"none",children:s("ext.structural.editor.texture.none")}),(0,o.jsx)("option",{value:"brick",children:s("ext.structural.editor.texture.brick")}),(0,o.jsx)("option",{value:"concrete",children:s("ext.structural.editor.texture.concrete")})]})]})]}),(0,o.jsx)("div",{className:"sectionDivider"}),(0,o.jsxs)("div",{className:"rowWrap",style:{alignItems:"center",justifyContent:"space-between"},children:[(0,o.jsx)("div",{className:"label",children:s("ext.structural.editor.openings")}),(0,o.jsxs)("div",{className:"rowWrap",style:{gap:8},children:[(0,o.jsxs)("button",{className:"chipButton",type:"button",onClick:()=>_("opening"),children:["+ ",s("ext.structural.tools.wall_opening")]}),(0,o.jsxs)("button",{className:"chipButton",type:"button",onClick:()=>_("door"),children:["+ ",s("ext.structural.tools.wall_door")]}),(0,o.jsxs)("button",{className:"chipButton",type:"button",onClick:()=>_("window"),children:["+ ",s("ext.structural.tools.wall_window")]})]})]}),0===x.length?(0,o.jsx)("div",{className:"cardBody",children:s("ext.structural.editor.openings_empty")}):null,x.map(t=>{const e=t.kind,n=Kt(e,t.texture),r=t.color??zt(e)??"#8f806a",a=f.get(t.id)??null,i="opening"===e?s("ext.structural.editor.opening_height_full"):a?s("ext.structural.editor.opening_height_range",{yMin:m.format(a.y_min_m),yMax:m.format(a.y_max_m)}):null,l=Math.max(0,h),c=Math.min(wt,l),u=At(t.width_m,c,Math.max(c,l)),p=u/2,x=Math.max(p,l-u/2),g=At(t.center_m,p,x);return(0,o.jsxs)("div",{className:"card",style:{marginTop:10},children:[(0,o.jsxs)("div",{className:"cardHeaderRow",children:[(0,o.jsx)("div",{className:"cardTitle",children:s(`ext.structural.editor.kind.${e}`)}),(0,o.jsxs)("div",{className:"cardMeta",children:[m.format(u)," m"]})]}),i?(0,o.jsx)("div",{className:"cardMeta",style:{marginTop:6},children:i}):null,(0,o.jsxs)("div",{className:"rowWrap",children:[(0,o.jsxs)("div",{className:"field",style:{flex:1,minWidth:120},children:[(0,o.jsx)("div",{className:"label",children:s("ext.structural.editor.opening_kind")}),(0,o.jsxs)("select",{className:"input",value:e,onChange:n=>{const o="opening"===(r=n.target.value)||"door"===r||"window"===r?r:e;var r;const a={kind:o};!t.color&&zt(o)&&(a.color=zt(o)),t.texture&&t.texture!==St(e)||(a.texture=St(o)),y(t.id,a)},children:[(0,o.jsx)("option",{value:"opening",children:s("ext.structural.editor.kind.opening")}),(0,o.jsx)("option",{value:"door",children:s("ext.structural.editor.kind.door")}),(0,o.jsx)("option",{value:"window",children:s("ext.structural.editor.kind.window")})]})]}),(0,o.jsxs)("div",{className:"field",style:{flex:1,minWidth:120},children:[(0,o.jsx)("div",{className:"label",children:s("ext.structural.editor.opening_center")}),(0,o.jsx)("input",{className:"input",type:"number",step:.05,value:g,onChange:e=>{const n=Number(e.target.value);Number.isFinite(n)&&y(t.id,{center_m:At(n,p,x)})}}),(0,o.jsx)("div",{className:"cardMeta",children:s("ext.structural.editor.opening_center_hint",{start:m.format(0),end:m.format(h)})})]}),(0,o.jsxs)("div",{className:"field",style:{flex:1,minWidth:120},children:[(0,o.jsx)("div",{className:"label",children:s("ext.structural.editor.opening_width")}),(0,o.jsx)("input",{className:"input",type:"number",step:.05,min:c,max:Math.max(c,l),value:u,onChange:e=>{const n=Number(e.target.value);if(!Number.isFinite(n))return;const o=At(n,c,Math.max(c,l)),r=o/2,a=Math.max(r,l-o/2);y(t.id,{width_m:o,center_m:At(t.center_m,r,a)})}})]})]}),"opening"!==e?(0,o.jsxs)("div",{className:"rowWrap",children:[(0,o.jsxs)("div",{className:"field",style:{flex:1,minWidth:120},children:[(0,o.jsx)("div",{className:"label",children:s("ext.structural.editor.opening_color")}),(0,o.jsx)("input",{className:"input",type:"color",value:r,onChange:e=>y(t.id,{color:e.target.value})})]}),(0,o.jsxs)("div",{className:"field",style:{flex:1,minWidth:120},children:[(0,o.jsx)("div",{className:"label",children:s("ext.structural.editor.opening_texture")}),(0,o.jsxs)("select",{className:"input",value:n,onChange:e=>y(t.id,{texture:A(e.target.value,n)}),children:[(0,o.jsx)("option",{value:"none",children:s("ext.structural.editor.texture.none")}),(0,o.jsx)("option",{value:"wood",children:s("ext.structural.editor.texture.wood")}),(0,o.jsx)("option",{value:"concrete",children:s("ext.structural.editor.texture.concrete")}),(0,o.jsx)("option",{value:"glass",children:s("ext.structural.editor.texture.glass")}),"window"===e?(0,o.jsx)("option",{value:"transparent",children:s("ext.structural.editor.texture.transparent_cutout")}):null]})]})]}):null,(0,o.jsx)("div",{className:"rowWrap",children:(0,o.jsx)("button",{className:"dangerButton",type:"button",onClick:()=>{return e=t.id,void w(d.filter(t=>t.id!==e));var e},children:s("core.actions.delete")})})]},t.id)}),(0,o.jsx)("div",{className:"sectionDivider"}),(0,o.jsxs)("div",{className:"rowWrap",children:[(0,o.jsx)("button",{className:"dangerButton",type:"button",onClick:n,children:s("core.actions.delete")}),(0,o.jsx)("button",{className:"chipButton",type:"button",onClick:a,children:s("core.actions.close")})]})]})}const Ut={id:"structure",name:{key:"core.ui.tools.group.structure",fallback:"Structure"},order:20},Ht={id:"areas",name:{key:"core.ui.tools.group.areas",fallback:"Areas"},order:30};function Yt(t,e,n){const o={x:(e.x+n.x)/2,z:(e.z+n.z)/2};return t.createElement(c,{name:"",position:{x:o.x,y:0,z:o.z},props:{a:e,b:n,color:p,width:m,openings:[]}})}function Jt(t,e){const n=$(e),o=function(){try{const t=localStorage.getItem(x);if(t&&w(t))return t}catch{}return h}();return t.createElement(u,{name:"",position:{x:n.x,y:0,z:n.z},props:{vertices:e,fill:o,opacity:1}})}function Qt(t,e){const n=$(e);return t.createElement(d,{name:"",position:{x:n.x,y:0,z:n.z},props:{vertices:e,depth_m:1.4}})}function te(t,e){const n=e.length;if(!(n<2))for(let o=0;o<n;o++)Yt(t,e[o],e[(o+1)%n])}function ee(t,e){if(e.altKey)return e.rawWorld;const n=function(t,e){const n=rt(t);let o=null;for(const t of n.nodes){const n=nt(t);if(n<=0)continue;const r=E(e,t.point);r>n+1e-9||(!o||r<o.distance)&&(o={nodeId:t.id,point:t.point,distance:r})}return o}(t.getElements(),e.rawWorld);return n?.point??e.world}function ne(t,e,n){return Math.max(e,Math.min(n,t))}function oe(t,e){return{x:t.x+e.x,z:t.z+e.z}}function re(t,e){return{x:t.x*e,z:t.z*e}}function ae(t,e,n,o){const r=function(t,e){return t.x*e.x+t.z*e.z}(function(t,e){return{x:t.x-e.x,z:t.z-e.z}}(t,e),n),a=Math.max(0,Math.min(o,r));return{point:oe(e,re(n,a)),scalar:a}}function ie(t,e,n){const o=E(e,n);return E(t,o<=1e-6?e:ae(t,e,{x:(n.x-e.x)/o,z:(n.z-e.z)/o},o).point)}function se(t,e){const n="door"===(o=e.kind)?{stroke:i("#fb923c",.92),fill:i("#fb923c",.22),dash:[8,6],labelKey:"ext.structural.tools.wall_door",fallback:"Door",descriptionKey:"ext.structural.tools.wall_door_desc",descriptionFallback:"Place a door cutout on a wall.",icon:"door-open",order:20}:"window"===o?{stroke:i("#38bdf8",.92),fill:i("#38bdf8",.22),dash:[5,5],labelKey:"ext.structural.tools.wall_window",fallback:"Window",descriptionKey:"ext.structural.tools.wall_window_desc",descriptionFallback:"Place a window cutout on a wall.",icon:"window-maximize",order:30}:{stroke:i("#fbbf24",.92),fill:i("#fbbf24",.22),dash:[9,4],labelKey:"ext.structural.tools.wall_opening",fallback:"Opening",descriptionKey:"ext.structural.tools.wall_opening_desc",descriptionFallback:"Hover a wall, click and drag to size. Click to place default width.",icon:"crop-simple",order:40};var o;return{id:"door"===e.kind?"com.toposync.structural.tool.door":"window"===e.kind?"com.toposync.structural.tool.window":"com.toposync.structural.tool.opening",name:{key:n.labelKey,fallback:n.fallback},description:{key:n.descriptionKey,fallback:n.descriptionFallback},icon:n.icon,group:Ut,order:n.order,createSession:t=>{let o=null,r=null,a=null,i=null,s=null,l=!1;function u(){a=null,i=null,s=null,l=!1}function d(t,n,o,r){const a=Math.min(Math.max(wt,.2),t),i=Math.abs(o-n);let s=i,l=(n+o)/2;return r?(s=2*i,l=n):i<.04&&(s=Math.min(t,Math.max(a,function(t){return"door"===t?.9:"window"===t?1.2:1}(e.kind))),l=n),s=ne(s,a,t),l=ne(l,s/2,t-s/2),{start:l-s/2,end:l+s/2,center:l,width:s}}function p(e){if(a)return;const n=function(t){const e=[];for(const n of t.getElements()){if(n.type!==c)continue;const t=M(n.props.a,{x:n.position.x-.5,z:n.position.z}),o=M(n.props.b,{x:n.position.x+.5,z:n.position.z}),r=E(t,o);if(r<=1e-6)continue;const a={x:(o.x-t.x)/r,z:(o.z-t.z)/r},i={x:-a.z,z:a.x};e.push({id:n.id,a:t,b:o,dir:a,normal:i,length:r,width:Math.max(.04,f(n.props.width,m)),props:n.props})}return e}(t),i=function(t,e){let n=null,o=Number.POSITIVE_INFINITY;for(const r of t){const t=ie(e,r.a,r.b);t>Math.max(.45,3.5*r.width)||t<o&&(o=t,n=r)}return n}(n,e);o=i,r=i?ae(e,i.a,i.dir,i.length).scalar:null}function h(t,e,n){const o=e.worldToScreen(n.a),r=e.worldToScreen(n.b);t.beginPath(),t.moveTo(o.x,o.y),t.lineTo(r.x,r.y),t.strokeStyle="rgba(255,255,255,0.55)",t.lineWidth=2.25,t.setLineDash([6,6]),t.stroke()}function x(t,e,o,r,a,i){const s=d(o.length,r,a,i),l=oe(o.a,re(o.dir,s.start)),c=oe(o.a,re(o.dir,s.end)),u=Math.max(.09,o.width/2),p=[oe(l,re(o.normal,u)),oe(c,re(o.normal,u)),oe(c,re(o.normal,-u)),oe(l,re(o.normal,-u))].map(t=>e.worldToScreen(t));t.beginPath(),t.moveTo(p[0].x,p[0].y);for(let e=1;e<p.length;e++)t.lineTo(p[e].x,p[e].y);t.closePath(),t.fillStyle=n.fill,t.fill(),t.strokeStyle=n.stroke,t.lineWidth=2,t.setLineDash(n.dash),t.stroke(),t.setLineDash([]);const m=e.worldToScreen(oe(o.a,re(o.dir,s.center))),h=`${s.width.toFixed(2)} m`;t.font="12px ui-sans-serif, system-ui";const x=t.measureText(h).width+16,f=m.x-x/2,g=m.y-Math.max(28,24+12/Math.max(1,e.scale));t.fillStyle="rgba(8,12,26,0.86)",t.fillRect(f,g,x,20),t.strokeStyle="rgba(255,255,255,0.18)",t.lineWidth=1,t.strokeRect(f+.5,g+.5,x-1,19),t.fillStyle="rgba(230,232,242,0.95)",t.textAlign="center",t.textBaseline="middle",t.fillText(h,m.x,g+10)}return{onPointerEvent:n=>{if("cancel"!==n.kind){if("move"===n.kind)return a?(l=n.shiftKey,void(s=ae(n.world,a.a,a.dir,a.length).scalar)):void p(n.world);if("down"===n.kind){if(0!==n.button)return;return p(n.world),o&&null!=r?(a=o,i=r,s=r,void(l=n.shiftKey)):void u()}if("up"===n.kind){if(0!==n.button)return;if(!a||null==i)return;l=n.shiftKey,s=ae(n.world,a.a,a.dir,a.length).scalar,function(){if(!a||null==i||null==s)return;const n=d(a.length,i,s,l),o=t.getElements().find(t=>t.id===a?.id),r=Wt(o?.props.openings??a.props.openings),c=Pt({kind:e.kind,center_m:n.center,width_m:n.width});t.updateElement(a.id,{props:{openings:Ct([...r,c])}}),t.openEditor(a.id)}(),u(),p(n.world)}}else u()},onKeyDown:t=>{"Escape"===t.key&&u()},renderOverlay2D:({ctx:t,viewport:e})=>{t.save(),a&&null!=i&&null!=s?(h(t,e,a),x(t,e,a,i,s,l)):o&&null!=r&&(h(t,e,o),x(t,e,o,r,r,!1)),t.restore()},getCursor:()=>o?"copy":"crosshair"}}}}function le(t,e){return{id:e.withWalls?"com.toposync.structural.tool.area_square_walls":"com.toposync.structural.tool.area_square",name:{key:e.withWalls?"ext.structural.tools.area_square_walls":"ext.structural.tools.area_square",fallback:e.withWalls?"Rectangular room":"Rectangular area"},icon:e.withWalls?"border-all":"vector-square",group:Ht,order:e.withWalls?10:30,createSession:t=>{let n=null,o=null;function r(){n=null,o=null}return{onPointerEvent:a=>{if("cancel"!==a.kind)if("move"!==a.kind){if("down"===a.kind&&0===a.button){if(!n){const e=ee(t,a);return n=e,void(o=e)}!function(o){if(!n)return;const a=function(t,e){const n=Math.min(t.x,e.x),o=Math.max(t.x,e.x),r=Math.min(t.z,e.z),a=Math.max(t.z,e.z);return[{x:n,z:r},{x:o,z:r},{x:o,z:a},{x:n,z:a}]}(n,o);if(E(a[0],a[2])<.12)return void r();const i=Jt(t,a);e.withWalls&&te(t,a),i&&t.openEditor(i),r()}(ee(t,a))}}else n&&(o=ee(t,a));else r()},onKeyDown:t=>{"Escape"===t.key&&r()},renderOverlay2D:({ctx:t,viewport:e})=>{if(!n||!o)return;const r=[n,{x:o.x,z:n.z},o,{x:n.x,z:o.z}].map(t=>e.worldToScreen(t));t.save(),t.beginPath(),t.moveTo(r[0].x,r[0].y);for(let e=1;e<r.length;e++)t.lineTo(r[e].x,r[e].y);t.closePath(),t.fillStyle=i("#fbbf24",.12),t.fill(),t.strokeStyle=i("#fbbf24",.8),t.lineWidth=2,t.setLineDash([6,6]),t.stroke(),t.restore()},getCursor:()=>"crosshair"}}}}function ce(t){return{id:"com.toposync.structural.tool.pool_square",name:{key:"ext.structural.tools.pool_square",fallback:"Rectangular pool"},icon:"water-ladder",group:Ht,order:50,createSession:t=>{let e=null,n=null;function o(){e=null,n=null}return{onPointerEvent:r=>{if("cancel"!==r.kind)if("move"!==r.kind){if("down"===r.kind&&0===r.button)return e?void function(n){if(!e)return;const r=function(t,e){const n=Math.min(t.x,e.x),o=Math.max(t.x,e.x),r=Math.min(t.z,e.z),a=Math.max(t.z,e.z);return[{x:n,z:r},{x:o,z:r},{x:o,z:a},{x:n,z:a}]}(e,n);if(E(r[0],r[2])<.12)return void o();const a=Qt(t,r);a&&t.openEditor(a),o()}(r.world):(e=r.world,void(n=r.world))}else e&&(n=r.world);else o()},onKeyDown:t=>{"Escape"===t.key&&o()},renderOverlay2D:({ctx:t,viewport:o})=>{if(!e||!n)return;const r=[e,{x:n.x,z:e.z},n,{x:e.x,z:n.z}].map(t=>o.worldToScreen(t));t.save(),t.beginPath(),t.moveTo(r[0].x,r[0].y);for(let e=1;e<r.length;e++)t.lineTo(r[e].x,r[e].y);t.closePath(),t.fillStyle=i("#0ea5e9",.12),t.fill(),t.strokeStyle=i("#38bdf8",.8),t.lineWidth=2,t.setLineDash([6,6]),t.stroke(),t.restore()},getCursor:()=>"crosshair"}}}}function ue(t,e){return{id:e.withWalls?"com.toposync.structural.tool.area_polygon_walls":"com.toposync.structural.tool.area_polygon",name:{key:e.withWalls?"ext.structural.tools.area_polygon_walls":"ext.structural.tools.area_polygon",fallback:e.withWalls?"Freeform room":"Freeform area"},icon:e.withWalls?"object-group":"draw-polygon",group:Ht,order:e.withWalls?20:40,createSession:t=>{const n=[];let o=null;function r(){n.splice(0,n.length),o=null}function a(){if(n.length<3)return void r();const o=Jt(t,[...n]);e.withWalls&&te(t,n),o&&t.openEditor(o),r()}return{onPointerEvent:e=>{if("cancel"===e.kind)return void r();if("move"===e.kind)return void(o=ee(t,e));if("dblclick"===e.kind)return void a();if("down"!==e.kind)return;if(0!==e.button)return;const i=ee(t,e);!function(t){return!(n.length<3)&&E(t,n[0])<.22}(i)?(n.push(i),o=i):a()},onKeyDown:t=>{"Escape"===t.key&&r(),"Enter"===t.key&&a(),("Backspace"===t.key||"Delete"===t.key)&&n.length>0&&n.pop()},renderOverlay2D:({ctx:t,viewport:e})=>{if(0===n.length)return;const r=n.map(t=>e.worldToScreen(t)),a=o?e.worldToScreen(o):null;if(t.save(),n.length>=2){t.beginPath(),t.moveTo(r[0].x,r[0].y);for(let e=1;e<r.length;e++)t.lineTo(r[e].x,r[e].y);a&&t.lineTo(a.x,a.y),t.strokeStyle=i("#fbbf24",.85),t.lineWidth=2,t.setLineDash([6,6]),t.stroke()}for(let e=0;e<r.length;e++){const o=r[e],a=0===e&&n.length>=3;t.beginPath(),t.arc(o.x,o.y,a?6:5,0,2*Math.PI),t.fillStyle=i(a?"#22c55e":"#fbbf24",.85),t.fill(),t.strokeStyle="rgba(0,0,0,0.35)",t.lineWidth=2,t.stroke()}t.restore()},getCursor:()=>"crosshair"}}}}const de={en:{"ext.structural.wall.name":"Wall","ext.structural.wall.desc":"Simple wall (line) in 2D.","ext.structural.area.name":"Area","ext.structural.area.desc":"Area (polygon) in 2D.","ext.structural.pool.name":"Pool","ext.structural.pool.desc":"Swimming pool (hole) in 2D.","ext.structural.tools.wall":"Wall","ext.structural.tools.wall_opening":"Opening","ext.structural.tools.wall_opening_desc":"Floor-to-ceiling wall cutout. Hover a wall, click and drag to size. Click to place default width. Hold Shift for symmetric sizing.","ext.structural.tools.wall_door":"Door","ext.structural.tools.wall_door_desc":"Place a door cutout on a wall.","ext.structural.tools.wall_window":"Window","ext.structural.tools.wall_window_desc":"Place a window cutout on a wall.","ext.structural.tools.area_square":"Rectangular area","ext.structural.tools.area_polygon":"Freeform area","ext.structural.tools.area_square_walls":"Rectangular room","ext.structural.tools.area_polygon_walls":"Freeform room","ext.structural.tools.pool_square":"Rectangular pool","ext.structural.tools.pool_polygon":"Freeform pool","ext.structural.editor.wall_color":"Wall color","ext.structural.editor.wall_texture":"Wall texture","ext.structural.editor.openings":"Openings","ext.structural.editor.openings_empty":"No openings yet. Use tools or add one here.","ext.structural.editor.opening_kind":"Type","ext.structural.editor.opening_center":"Position (m)","ext.structural.editor.opening_center_hint":"Along the wall: {{start}} m = start (1st point), {{end}} m = end (2nd point).","ext.structural.editor.opening_width":"Width (m)","ext.structural.editor.opening_height_full":"Height: floor to ceiling.","ext.structural.editor.opening_height_range":"Height: {{yMin}} - {{yMax}} m.","ext.structural.editor.opening_color":"Color","ext.structural.editor.opening_texture":"Texture","ext.structural.editor.kind.opening":"Opening","ext.structural.editor.kind.door":"Door","ext.structural.editor.kind.window":"Window","ext.structural.editor.area_name":"Area name (optional)","ext.structural.editor.area_color":"Area color","ext.structural.editor.floor_texture":"Floor texture","ext.structural.editor.transparent":"Transparent","ext.structural.editor.texture.none":"None","ext.structural.editor.texture.brick":"Brick","ext.structural.editor.texture.concrete":"Concrete","ext.structural.editor.texture.wood":"Wood","ext.structural.editor.texture.glass":"Glass","ext.structural.editor.texture.transparent_cutout":"Transparent cutout","ext.structural.editor.texture.grass":"Grass","ext.structural.editor.pool_name":"Pool name (optional)","ext.structural.editor.pool_depth":"Depth (m)","ext.structural.editor.preview":"Preview"},"pt-BR":{"ext.structural.wall.name":"Parede","ext.structural.wall.desc":"Parede simples (linha) em 2D.","ext.structural.area.name":"Área","ext.structural.area.desc":"Área (polígono) em 2D.","ext.structural.pool.name":"Piscina","ext.structural.pool.desc":"Piscina (buraco) em 2D.","ext.structural.tools.wall":"Parede","ext.structural.tools.wall_opening":"Abertura","ext.structural.tools.wall_opening_desc":"Recorte do piso ao teto. Passe sobre a parede, clique e arraste para dimensionar. Clique para largura padrão. Segure Shift para simetria.","ext.structural.tools.wall_door":"Porta","ext.structural.tools.wall_door_desc":"Adiciona um recorte de porta na parede.","ext.structural.tools.wall_window":"Janela","ext.structural.tools.wall_window_desc":"Adiciona um recorte de janela na parede.","ext.structural.tools.area_square":"Área retangular","ext.structural.tools.area_polygon":"Área livre","ext.structural.tools.area_square_walls":"Ambiente retangular","ext.structural.tools.area_polygon_walls":"Ambiente livre","ext.structural.tools.pool_square":"Piscina retangular","ext.structural.tools.pool_polygon":"Piscina livre","ext.structural.editor.wall_color":"Cor da parede","ext.structural.editor.wall_texture":"Textura da parede","ext.structural.editor.openings":"Aberturas","ext.structural.editor.openings_empty":"Sem aberturas ainda. Use as ferramentas ou adicione aqui.","ext.structural.editor.opening_kind":"Tipo","ext.structural.editor.opening_center":"Posição (m)","ext.structural.editor.opening_center_hint":"Ao longo da parede: {{start}} m = início (1º ponto), {{end}} m = fim (2º ponto).","ext.structural.editor.opening_width":"Largura (m)","ext.structural.editor.opening_height_full":"Altura: piso ao teto.","ext.structural.editor.opening_height_range":"Altura: {{yMin}} - {{yMax}} m.","ext.structural.editor.opening_color":"Cor","ext.structural.editor.opening_texture":"Textura","ext.structural.editor.kind.opening":"Abertura","ext.structural.editor.kind.door":"Porta","ext.structural.editor.kind.window":"Janela","ext.structural.editor.area_name":"Nome da área (opcional)","ext.structural.editor.area_color":"Cor da área","ext.structural.editor.floor_texture":"Textura do chão","ext.structural.editor.transparent":"Transparente","ext.structural.editor.texture.none":"Nenhuma","ext.structural.editor.texture.brick":"Tijolo","ext.structural.editor.texture.concrete":"Concreto","ext.structural.editor.texture.wood":"Madeira","ext.structural.editor.texture.glass":"Vidro","ext.structural.editor.texture.transparent_cutout":"Recorte transparente","ext.structural.editor.texture.grass":"Grama","ext.structural.editor.pool_name":"Nome da piscina (opcional)","ext.structural.editor.pool_depth":"Profundidade (m)","ext.structural.editor.preview":"Prévia"}};function pe(t){var e;t.i18n.registerTranslations(de),t.registerElementType((e=t.i18n,{type:c,layerGroup:"walls",name:{key:"ext.structural.wall.name",fallback:"Wall"},description:{key:"ext.structural.wall.desc",fallback:"Simple wall (line) in 2D."},defaultProps:{color:p,texture:"none",width:m,a:{x:0,z:0},b:{x:1,z:0},openings:[]},getMain2DBounds:Rt,renderMain2DVector:({element:t,elements:e})=>{const n=at(t,e),r=M(t.props.a,{x:t.position.x,z:t.position.z}),a=M(t.props.b,{x:t.position.x+1,z:t.position.z}),s=g(t.props.color,p),c=D(t.props.texture,"none"),u=n?.wall.width??Math.max(.04,f(t.props.width,m)),d=n?.wall.length??Math.max(.001,E(r,a)),h=n?.wall.direction??G(R(a,r)),x=n?.wall.normal??O(h),w=Dt(Wt(t.props.openings),d,3.2),y=Et(d,w.map(t=>({start:t.start_m,end:t.end_m}))),_=Math.max(u/2,.09),b=i(l(s,"brick"===c?-.16:"concrete"===c?-.1:-.12),.98);return(0,o.jsxs)("g",{className:"mainVector2dWall",children:[y.map((t,e)=>{const a=Math.max(u/2,.02),i=n?it(n,t.start,t.end):null,s=i?.points??Gt(r,h,x,a,t.start,t.end);return(0,o.jsx)("polygon",{points:Bt(s),fill:b},`solid:${e}`)}),w.map(t=>{const e=It(r,h,t.start_m),n=It(r,h,t.end_m),a=I(e,B(x,_)),s=I(n,B(x,_)),c=I(n,B(x,-_)),d=I(e,B(x,-_)),p=function(t){const e=zt(t.kind)??"#cbd5e1",n=t.color??e,o=Kt(t.kind,t.texture);if("window"===t.kind){if("transparent"===o)return{fill:"rgba(255,255,255,0.02)",stroke:i(l(n,-.08),.34),accent:"rgba(255,255,255,0.08)",highlight:"rgba(255,255,255,0.10)"};const t="glass"===o?n:"#b9d8f4";return{fill:i(t,.3),stroke:i(l(t,-.16),.56),accent:i(l(t,.34),.82),highlight:"rgba(255,255,255,0.38)"}}return"door"===t.kind?{fill:i(n,"wood"===o?.5:.38),stroke:i(l(n,-.28),.52),accent:i(l(n,.26),.42),highlight:"rgba(255,255,255,0.16)"}:{fill:"rgba(255,255,255,0.08)",stroke:i(n,.26),accent:i(l(n,.2),.22),highlight:"rgba(255,255,255,0.10)"}}(t),m=It(r,h,t.start_m+.18*t.width_m),f=It(r,h,t.end_m-.18*t.width_m);return(0,o.jsxs)("g",{className:`mainVector2dWallOpening mainVector2dWallOpening-${t.kind}`,children:[(0,o.jsx)("polygon",{points:Bt([a,s,c,d]),fill:p.fill,stroke:p.stroke,strokeWidth:.018,vectorEffect:"non-scaling-stroke"}),(0,o.jsx)("line",{x1:m.x,y1:m.z,x2:f.x,y2:f.z,stroke:p.accent,strokeWidth:Math.max(.008,"window"===t.kind?.32*u:.18*u),strokeLinecap:"round"}),"window"===t.kind?(0,o.jsx)("line",{x1:I(m,B(x,.46*-_)).x,y1:I(m,B(x,.46*-_)).z,x2:I(f,B(x,.46*-_)).x,y2:I(f,B(x,.46*-_)).z,stroke:p.highlight,strokeWidth:.01,strokeLinecap:"round",vectorEffect:"non-scaling-stroke"}):null]},t.id)})]})},create3D:({THREE:t,view:e,elements:n},o)=>{const r=new t.Group,a=new t.Group,i=new t.Group,s=new t.Group,l=new t.Group;a.add(i),a.add(s),a.add(l),r.add(a);const c=new t.MeshStandardMaterial({color:p,roughness:.82,metalness:.05,flatShading:!0,side:t.DoubleSide}),u=new t.MeshStandardMaterial({color:p,roughness:.86,metalness:.04,flatShading:!0,side:t.DoubleSide}),d=new t.MeshBasicMaterial({color:"#000000",transparent:!0,opacity:0,depthWrite:!1});d.colorWrite=!1;let h="",x=n;function w(n,o){x=o?.elements??x;const r=at(n,x),w=r?.wall.a??M(n.props.a,{x:n.position.x-.5,z:n.position.z}),y=r?.wall.b??M(n.props.b,{x:n.position.x+.5,z:n.position.z}),_=r?.wall.direction??G(R(y,w)),b=r?.wall.normal??O(_),v=r?.wall.width??Math.max(.04,f(n.props.width,m)),k=Math.max(.15,e.wallHeight),S=r?.wall.length??Math.max(.001,E(w,y)),j=g(n.props.color,p),W=D(n.props.texture,"none"),T=function(t,e){if("none"===e)return null;if("brick"===e){const e=P(t,"wall:brick",z,{size:256,anisotropy:4});return e.repeat.set(1,1),e}if("concrete"===e){const e=P(t,"wall:concrete",N,{size:256,anisotropy:4});return e.repeat.set(.5,.5),e}return null}(t,W);a.position.set(w.x-n.position.x,0,w.z-n.position.z),a.rotation.set(0,Math.atan2(-_.z,_.x),0);const C=Dt(Wt(n.props.openings),S,k),A=function(t,e,n){const o=[0,e];for(const t of n)o.push(At(t.y_min_m,0,e)),o.push(At(t.y_max_m,0,e));o.sort((t,e)=>t-e);const r=[];for(const t of o)(0===r.length||Math.abs(t-r[r.length-1])>1e-6)&&r.push(t);const a=[];for(let e=0;e<r.length-1;e++){const o=r[e],i=r[e+1];if(i-o<=1e-6)continue;const s=[];for(const t of n)t.y_min_m>=i-1e-6||t.y_max_m<=o+1e-6||s.push({start:t.start_m,end:t.end_m});const l=Et(t,s);for(const t of l)t.end-t.start<=1e-6||a.push({x0:t.start,x1:t.end,y0:o,y1:i})}return a}(S,k,C),F=A.filter(t=>t.x1-t.x0>1e-6&&t.y1-t.y0>1e-6).map(t=>{const e=Math.max(v/2,.02),n=r?it(r,t.x0,t.x1):null,o=n?.points??Gt(w,_,b,e,t.x0,t.x1);return{rect:t,localPoints:r?o.map(t=>function(t,e){const n=R(e,t.a);return{x:X(n,t.direction),z:X(n,t.normal)}}(r.wall,t)):[{x:t.x0,z:e},{x:t.x1,z:e},{x:t.x1,z:-e},{x:t.x0,z:-e}]}}),I=JSON.stringify({length:Ft(S),thickness:Ft(v),height:Ft(k),footprint:F.map(t=>t.localPoints.map(t=>({x:Ft(t.x),z:Ft(t.z)}))),openings:C.map(t=>({id:t.id,kind:t.kind,start:Ft(t.start_m),end:Ft(t.end_m),y0:Ft(t.y_min_m),y1:Ft(t.y_max_m),color:t.color??"",texture:t.texture??""}))});if(I!==h){h=I,qt(i,!1),qt(s,!0),qt(l,!1);for(const e of F){const n=Ot(t,e.localPoints,0+e.rect.y0,0+e.rect.y1),o=[c,u],r=new t.Mesh(n,o);r.castShadow=!0,r.receiveShadow=!0,i.add(r)}for(const e of C)"door"!==e.kind?"window"===e.kind&&Vt(t,s,e,v):Xt(t,s,e,v);for(const e of C){const n=e.y_max_m-e.y_min_m;if(e.width_m<=.08||n<=.08)continue;const o=new t.BoxGeometry(e.width_m,n,1.06*v),r=new t.Mesh(o,d);r.userData.__toposyncAllowPickWhenGhostWalls=!0,r.position.set(e.center_m,0+e.y_min_m+n/2,0),r.castShadow=!1,r.receiveShadow=!1,l.add(r)}}c.color.set(j),u.color.set(j),c.map!==T&&(c.map=T,c.needsUpdate=!0),c.roughness="brick"===W?.9:.82,c.metalness="brick"===W?.02:.05}return w(o),{object:r,update:w,dispose:()=>{qt(i,!1),qt(s,!0),qt(l,!1),c.dispose(),u.dispose(),d.dispose()}}},render2D:({ctx:t,element:e,elements:n,viewport:o})=>{const r=at(e,n),a=M(e.props.a,{x:e.position.x,z:e.position.z}),i=M(e.props.b,{x:e.position.x+1,z:e.position.z}),s=g(e.props.color,p),l=r?.wall.width??Math.max(.04,f(e.props.width,m)),c=r?.wall.length??Math.max(.001,E(a,i)),u=r?.wall.direction??G(R(i,a)),d=r?.wall.normal??O(u),h=Dt(Wt(e.props.openings),c,3.2),x=Et(c,h.map(t=>({start:t.start_m,end:t.end_m})));t.save(),t.lineJoin="miter";for(const e of x){const n=Math.max(l/2,.02),i=r?it(r,e.start,e.end):null,c=(i?.points??Gt(a,u,d,n,e.start,e.end)).map(t=>o.worldToScreen(t));t.beginPath(),t.moveTo(c[0].x,c[0].y);for(let e=1;e<c.length;e+=1)t.lineTo(c[e].x,c[e].y);t.closePath(),t.strokeStyle="rgba(0,0,0,0.35)",t.lineWidth=3,t.stroke(),t.fillStyle=s,t.fill()}const w=Math.max(l/2,.09);for(const e of h){const n=It(a,u,e.start_m),r=It(a,u,e.end_m),i=o.worldToScreen(I(n,B(d,w))),s=o.worldToScreen(I(r,B(d,w))),l=o.worldToScreen(I(r,B(d,-w))),c=o.worldToScreen(I(n,B(d,-w))),p=Lt(e.kind);t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(s.x,s.y),t.lineTo(l.x,l.y),t.lineTo(c.x,c.y),t.closePath(),t.fillStyle=p.fill,t.fill(),t.strokeStyle=p.stroke,t.lineWidth=1.8,t.setLineDash(p.dash),t.stroke(),t.setLineDash([])}t.restore()},hitTest2D:({element:t,world:e,viewport:n})=>{const o=M(t.props.a,{x:t.position.x,z:t.position.z}),r=M(t.props.b,{x:t.position.x+1,z:t.position.z}),a=Math.max(.04,f(t.props.width,m)),i=Math.max(a/2,.09,10/Math.max(1,n.scale));return function(t,e,n){const o=R(n,e),r=R(t,e),a=o.x*o.x+o.z*o.z;return a<=1e-9?Math.hypot(r.x,r.z):E(t,I(e,B(o,At((r.x*o.x+r.z*o.z)/a,0,1))))}(e,o,r)<=i},renderEditorModal:({element:t,update:n,remove:r,close:a})=>(0,o.jsx)(Zt,{element:t,update:n,remove:r,close:a,i18n:e})})),t.registerElementType(ut(t.i18n)),t.registerElementType(ft(t.i18n));for(const e of(t.i18n,[{id:"com.toposync.structural.tool.wall",name:{key:"ext.structural.tools.wall",fallback:"Wall"},icon:"grip-lines",group:Ut,order:10,createSession:t=>{let e=null,n=null,o=0;function r(){e=null,n=null}function a(e){if(e.altKey)return e.rawWorld;const n=Math.max(.08,o>0?12/o:0),r=function(t,e,n,o={}){const r=Math.max(0,n);let a=null;for(const n of ot(t))if(!o.excludeElementId||n.elementId!==o.excludeElementId)for(const t of["a","b"]){const o=L(n,t),i=E(e,o);i>r||(!a||i<a.distance)&&(a={elementId:n.elementId,endpoint:t,point:o,distance:i})}return a}(t.getElements(),e.rawWorld,n);return r?.point??e.world}return{onPointerEvent:o=>{if("cancel"!==o.kind)if("move"!==o.kind){if("down"===o.kind&&0===o.button){if(!e){const t=a(o);return e=t,void(n=t)}var i;i=a(o),e&&(E(e,i)<.05||Yt(t,e,i),r())}}else e&&(n=a(o));else r()},onKeyDown:t=>{"Escape"===t.key&&r()},renderOverlay2D:({ctx:t,viewport:r})=>{if(o=r.scale,!e||!n)return;const a=r.worldToScreen(e),s=r.worldToScreen(n),l=Math.max(2,m*r.scale);t.save(),t.setLineDash([8,6]),t.lineCap="round",t.strokeStyle=i("#fbbf24",.85),t.lineWidth=l,t.beginPath(),t.moveTo(a.x,a.y),t.lineTo(s.x,s.y),t.stroke(),t.restore()},getCursor:()=>"crosshair"}}},se(0,{kind:"door"}),se(0,{kind:"window"}),se(0,{kind:"opening"}),le(0,{withWalls:!0}),ue(0,{withWalls:!0}),le(0,{withWalls:!1}),ue(0,{withWalls:!1}),ce(),{id:"com.toposync.structural.tool.pool_polygon",name:{key:"ext.structural.tools.pool_polygon",fallback:"Freeform pool"},icon:"water",group:Ht,order:60,createSession:t=>{const e=[];let n=null;function o(){e.splice(0,e.length),n=null}function r(){if(e.length<3)return void o();const n=Qt(t,[...e]);n&&t.openEditor(n),o()}return{onPointerEvent:t=>{"cancel"!==t.kind?"move"!==t.kind?"dblclick"!==t.kind?"down"===t.kind&&0===t.button&&(function(t){if(e.length<3)return!1;const n=e[0];return E(t.world,n)<.22}(t)?r():(e.push(t.world),n=t.world)):r():n=t.world:o()},onKeyDown:t=>{"Escape"===t.key&&o(),"Enter"===t.key&&r(),("Backspace"===t.key||"Delete"===t.key)&&e.length>0&&e.pop()},renderOverlay2D:({ctx:t,viewport:o})=>{if(0===e.length)return;const r=e.map(t=>o.worldToScreen(t)),a=n?o.worldToScreen(n):null;if(t.save(),e.length>=2){t.beginPath(),t.moveTo(r[0].x,r[0].y);for(let e=1;e<r.length;e++)t.lineTo(r[e].x,r[e].y);a&&t.lineTo(a.x,a.y),t.strokeStyle=i("#38bdf8",.85),t.lineWidth=2,t.setLineDash([6,6]),t.stroke()}for(let n=0;n<r.length;n++){const o=r[n],a=0===n&&e.length>=3;t.beginPath(),t.arc(o.x,o.y,a?6:5,0,2*Math.PI),t.fillStyle=i(a?"#22c55e":"#38bdf8",.85),t.fill(),t.strokeStyle="rgba(0,0,0,0.35)",t.lineWidth=2,t.stroke()}t.restore()},getCursor:()=>"crosshair"}}}]))t.registerEditorTool(e)}},870(t,e,n){t.exports=n(94)}}]);
|