PageSourceSearch

https://sitearchitect.ai/assets/Index-CpfI_eXK.js

js sitearchitect.ai collected 2026-10-05 12:38:55 UTC 3,583,276 bytes, 2,607 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DevelopersCRMPanel-BA4bA5IQ.js","assets/index-Do7gCgTf.js","assets/index-BHURmq_K.css","assets/popover-DOG9pVrj.js","assets/table-CKYDBTMQ.js","assets/index-CX-zOJAH.js","assets/format-Uz3vuPWI.js","assets/CustomFieldsEditor-BTFdWict.js","assets/dialog-BvWXSvw9.js","assets/separator-DC-q8O1p.js","assets/triangle-alert-dkNl1DfS.js","assets/PieChart-C1m0W3PY.js","assets/useAuth-D6HFUQJP.js","assets/useLayerAccess-DsDblBUV.js","assets/switch-bX6mH869.js","assets/globe-D4UjWWDL.js","assets/zap-BcqC4-X-.js","assets/loader-circle-DmAamJPS.js","assets/upload-DupVj1Qu.js","assets/eye-off-xek2c-cU.js","assets/message-square-ChJs3mPa.js","assets/checkbox-KkTvvzXH.js","assets/shield-ODDfY4F8.js","assets/filter-B4l6vqD4.js","assets/designElementTypes-Cvp5XMKg.js","assets/box-4ke8pqBX.js","assets/useDesignElements-WUhDsmUV.js","assets/useModel3DAssets-DAHVQeqI.js","assets/arrow-left-CSAX1adD.js","assets/OwnersCRMPanel-DHVUc2gM.js","assets/TenantsCRMPanel-25a6tTKW.js","assets/mirrorGeometry-fBud_E6H.js","assets/signageLogoRenderer-BfZvTPj_.js","assets/threeJsMapLayer-G3fUOP7P.js","assets/columnGrid3DRenderer-DB5Ueeni.js","assets/floorSlab3DRenderer-CXkN0Q74.js","assets/tree3DModelRenderer-DA0T29pn.js","assets/pylonLogoRenderer-uqbojm-r.js","assets/EmbedCodeDialog-C-KeS9Bz.js","assets/UserManagement-6rQIctMZ.js","assets/MapOverlaysPanel-CxdUloM5.js","assets/RetailerLogoLibrary-D5BzLU2y.js","assets/imageOptimizer-CHd1-2bN.js","assets/NomenclaturePanel-BX76q8Vd.js","assets/EditOverlayDialog-B-XCtPpB.js","assets/RegionFilterPanel-BwKxSs_h.js"])))=>i.map(i=>d[i]);
2var QL=Object.defineProperty;var UL=(t,s,n)=>s in t?QL(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var za=(t,s,n)=>UL(t,typeof s!="symbol"?s+"":s,n);import{c as Ps,s as Fs,r as k,u as lc,a as Ve,j as e,B as Le,M as ji,C as Mo,b as Io,d as Mt,R as Fo,e as Fm,f as fs,X as ja,L as Da,g as vc,h as bc,i as Ci,S as Ld,I as be,k as B,T as j1,_ as br,l as Ao,E as kc,m as rr,n as ir,o as or,p as Do,q as mx,t as hm,v as w1,w as $C,x as e5,y as Sb,z as ph,A as v0,P as Wd,D as Iy,F as N1,G as k1,H as t5,J as s5,K as bp,N as n5,O as Ay,Q as VC,U as qC,V as a5,W as b0,Y as GC,Z as r5,$ as dg,a0 as Lx,a1 as qw}from"./index-Do7gCgTf.js";import{u as HC,L as jc}from"./useAuth-D6HFUQJP.js";import{u as fu,a as md,C as Oa,b as Cc,S as rt,c as it,d as ct,e as ot,f as le,T as wr,O as C1,g as S1,h as i5,i as ZC,D as WC,R as YC,P as XC,j as o5,k as KC,l as JC,m as QC}from"./table-CKYDBTMQ.js";import{D as Vd,B as uh,a as jp,b as wp,c as l5,d as Np,e as zm,f as cd,g as co,F as UC,j as c5,C as hp,S as Xc,A as Dy,h as Ry,i as d5,U as yl,k as Sc,u as Kx,l as Ca,m as _g,E as Mg,n as Mx,o as Ix,p as Ax,q as E1,r as jv,W as yg,H as Eb,s as P1,L as gh,t as Fy,G as Gw,v as xr,T as u5,w as eS,x as I_,y as h5,z as m5,I as f5,J as Pb,R as Tb,K as p5,P as g5,M as x5,N as Hw,O as _5,Q as y5,X as v5,Y as b5,V as j5,Z as em}from"./PieChart-C1m0W3PY.js";import{M as mp,C as wi,a as Ni,b as ki,S as du,G as j0,P as tr,c as Du,d as kp,e as Dh,L as tS,u as sS,f as w5,g as N5,h as k5,i as C5,j as S5,k as E5,l as Rh,I as hh,m as lm,F as Ff,n as Nf,K as P5,W as T1,N as T5,o as L5,p as Sf,q as nS,r as M5,s as Lb,t as I5,v as A5,w as D5,x as R5,y as Zw,z as F5,A as Ww,B as z5,D as L1,E as O5,H as B5,T as $5,J as V5}from"./useLayerAccess-DsDblBUV.js";import{a as q5,f as M1,u as Jx,b as Qx,c as I1,g as op,d as _f,e as Rm,i as zy,S as fp,p as G5,s as Yw,h as H5,j as Z5,P as Ef,k as Pf,l as Tf,m as Cp,n as pu,o as Sp,q as Oy,R as mh,r as ym,B as Mb,M as Om,C as Xw,t as wx,v as Kw,D as yy,A as W5,w as Y5,G as Jw,x as Ib,y as tg,z as Dx}from"./popover-DOG9pVrj.js";import{T as Zm,a as mm,b as Bi,c as $i,D as dd,d as ud,e as Gd,f as Hd,g as vg,h as vf,i as w0,R as aS,I as rS,P as A1,j as X5}from"./dialog-BvWXSvw9.js";import{S as ks,C as kf,F as D1}from"./separator-DC-q8O1p.js";import{T as ho,C as iS,R as N0,F as Ig,a as bg}from"./triangle-alert-dkNl1DfS.js";import{G as By}from"./globe-D4UjWWDL.js";import{D as Fu,E as Rx,a as Kc,Z as Xd,C as $y}from"./zap-BcqC4-X-.js";import{L as Va}from"./loader-circle-DmAamJPS.js";import{C as k0,M as Vy}from"./message-square-ChJs3mPa.js";import{U as Ep,C as A_,S as kt}from"./switch-bX6mH869.js";import{H as qd,C as Ux}from"./checkbox-KkTvvzXH.js";import{C as cl,u as K5}from"./index-CX-zOJAH.js";import{S as jg,B as oS,a as hd}from"./shield-ODDfY4F8.js";import{f as J5}from"./format-Uz3vuPWI.js";import{E as Wc}from"./eye-off-xek2c-cU.js";import{F as wg}from"./filter-B4l6vqD4.js";import{A as R1,a as F1,b as z1,c as O1,d as B1,e as $1,f as V1,g as q1,S as Qw}from"./designElementTypes-Cvp5XMKg.js";import{B as cm}from"./box-4ke8pqBX.js";import{P as lS,U as Ab}from"./upload-DupVj1Qu.js";import{u as Q5,a as U5}from"./useDesignElements-WUhDsmUV.js";import{T as qy,C as Ml,u as cS,g as Db,A as dS,H as e3}from"./useModel3DAssets-DAHVQeqI.js";import{A as t3}from"./arrow-left-CSAX1adD.js";function s3(t,s){for(var n=0;n<s.length;n++){const a=s[n];if(typeof a!="string"&&!Array.isArray(a)){for(const l in a)if(l!=="default"&&!(l in t)){const c=Object.getOwnPropertyDescriptor(a,l);c&&Object.defineProperty(t,l,c.get?c:{enumerable:!0,get:()=>a[l]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}/**
3 * @license lucide-react v0.462.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const fh=Ps("Accessibility",[["circle",{cx:"16",cy:"4",r:"1",key:"1grugj"}],["path",{d:"m18 19 1-7-6 1",key:"r0i19z"}],["path",{d:"m5 8 3-3 5.5 3-2.36 3.5",key:"9ptxx2"}],["path",{d:"M4.24 14.5a5 5 0 0 0 6.88 6",key:"10kmtu"}],["path",{d:"M13.76 17.5a5 5 0 0 0-6.88-6",key:"2qq6rc"}]]);/**
8 * @license lucide-react v0.462.0 - ISC
9 *
10 * This source code is licensed under the ISC license.
11 * See the LICENSE file in the root directory of this source tree.
12 */const n3=Ps("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/**
13 * @license lucide-react v0.462.0 - ISC
14 *
15 * This source code is licensed under the ISC license.
16 * See the LICENSE file in the root directory of this source tree.
17 */const uS=Ps("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);/**
18 * @license lucide-react v0.462.0 - ISC
19 *
20 * This source code is licensed under the ISC license.
21 * See the LICENSE file in the root directory of this source tree.
22 */const Rb=Ps("ArrowRightFromLine",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M21 12H7",key:"13ipq5"}],["path",{d:"m15 18 6-6-6-6",key:"6tx3qv"}]]);/**
23 * @license lucide-react v0.462.0 - ISC
24 *
25 * This source code is licensed under the ISC license.
26 * See the LICENSE file in the root directory of this source tree.
27 */const a3=Ps("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/**
28 * @license lucide-react v0.462.0 - ISC
29 *
30 * This source code is licensed under the ISC license.
31 * See the LICENSE file in the root directory of this source tree.
32 */const e_=Ps("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/**
33 * @license lucide-react v0.462.0 - ISC
34 *
35 * This source code is licensed under the ISC license.
36 * See the LICENSE file in the root directory of this source tree.
37 */const r3=Ps("ArrowUpFromLine",[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/**
38 * @license lucide-react v0.462.0 - ISC
39 *
40 * This source code is licensed under the ISC license.
41 * See the LICENSE file in the root directory of this source tree.
42 */const i3=Ps("Baby",[["path",{d:"M9 12h.01",key:"157uk2"}],["path",{d:"M15 12h.01",key:"1k8ypt"}],["path",{d:"M10 16c.5.3 1.2.5 2 .5s1.5-.2 2-.5",key:"1u7htd"}],["path",{d:"M19 6.3a9 9 0 0 1 1.8 3.9 2 2 0 0 1 0 3.6 9 9 0 0 1-17.6 0 2 2 0 0 1 0-3.6A9 9 0 0 1 12 3c2 0 3.5 1.1 3.5 2.5s-.9 2.5-2 2.5c-.8 0-1.5-.4-1.5-1",key:"5yv0yz"}]]);/**
43 * @license lucide-react v0.462.0 - ISC
44 *
45 * This source code is licensed under the ISC license.
46 * See the LICENSE file in the root directory of this source tree.
47 */const hS=Ps("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
48 * @license lucide-react v0.462.0 - ISC
49 *
50 * This source code is licensed under the ISC license.
51 * See the LICENSE file in the root directory of this source tree.
52 */const mS=Ps("Battery",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}]]);/**
53 * @license lucide-react v0.462.0 - ISC
54 *
55 * This source code is licensed under the ISC license.
56 * See the LICENSE file in the root directory of this source tree.
57 */const G1=Ps("Bike",[["circle",{cx:"18.5",cy:"17.5",r:"3.5",key:"15x4ox"}],["circle",{cx:"5.5",cy:"17.5",r:"3.5",key:"1noe27"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["path",{d:"M12 17.5V14l-3-3 4-3 2 3h2",key:"1npguv"}]]);/**
58 * @license lucide-react v0.462.0 - ISC
59 *
60 * This source code is licensed under the ISC license.
61 * See the LICENSE file in the root directory of this source tree.
62 */const Uw=Ps("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);/**
63 * @license lucide-react v0.462.0 - ISC
64 *
65 * This source code is licensed under the ISC license.
66 * See the LICENSE file in the root directory of this source tree.
67 */const o3=Ps("BookmarkPlus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"12",x2:"12",y1:"7",y2:"13",key:"1cppfj"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);/**
68 * @license lucide-react v0.462.0 - ISC
69 *
70 * This source code is licensed under the ISC license.
71 * See the LICENSE file in the root directory of this source tree.
72 */const l3=Ps("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/**
73 * @license lucide-react v0.462.0 - ISC
74 *
75 * This source code is licensed under the ISC license.
76 * See the LICENSE file in the root directory of this source tree.
77 */const c3=Ps("Bus",[["path",{d:"M8 6v6",key:"18i7km"}],["path",{d:"M15 6v6",key:"1sg6z9"}],["path",{d:"M2 12h19.6",key:"de5uta"}],["path",{d:"M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3",key:"1wwztk"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}],["path",{d:"M9 18h5",key:"lrx6i"}],["circle",{cx:"16",cy:"18",r:"2",key:"1v4tcr"}]]);/**
78 * @license lucide-react v0.462.0 - ISC
79 *
80 * This source code is licensed under the ISC license.
81 * See the LICENSE file in the root directory of this source tree.
82 */const Gy=Ps("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/**
83 * @license lucide-react v0.462.0 - ISC
84 *
85 * This source code is licensed under the ISC license.
86 * See the LICENSE file in the root directory of this source tree.
87 */const eN=Ps("ChevronsDownUp",[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]);/**
88 * @license lucide-react v0.462.0 - ISC
89 *
90 * This source code is licensed under the ISC license.
91 * See the LICENSE file in the root directory of this source tree.
92 */const Fb=Ps("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/**
93 * @license lucide-react v0.462.0 - ISC
94 *
95 * This source code is licensed under the ISC license.
96 * See the LICENSE file in the root directory of this source tree.
97 */const t_=Ps("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
98 * @license lucide-react v0.462.0 - ISC
99 *
100 * This source code is licensed under the ISC license.
101 * See the LICENSE file in the root directory of this source tree.
102 */const H1=Ps("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
103 * @license lucide-react v0.462.0 - ISC
104 *
105 * This source code is licensed under the ISC license.
106 * See the LICENSE file in the root directory of this source tree.
107 */const fm=Ps("CircleParking",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9 17V7h4a3 3 0 0 1 0 6H9",key:"1dfk2c"}]]);/**
108 * @license lucide-react v0.462.0 - ISC
109 *
110 * This source code is licensed under the ISC license.
111 * See the LICENSE file in the root directory of this source tree.
112 */const d3=Ps("CircuitBoard",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M11 9h4a2 2 0 0 0 2-2V3",key:"1ve2rv"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"M7 21v-4a2 2 0 0 1 2-2h4",key:"1fwkro"}],["circle",{cx:"15",cy:"15",r:"2",key:"3i40o0"}]]);/**
113 * @license lucide-react v0.462.0 - ISC
114 *
115 * This source code is licensed under the ISC license.
116 * See the LICENSE file in the root directory of this source tree.
117 */const fS=Ps("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/**
118 * @license lucide-react v0.462.0 - ISC
119 *
120 * This source code is licensed under the ISC license.
121 * See the LICENSE file in the root directory of this source tree.
122 */const zb=Ps("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/**
123 * @license lucide-react v0.462.0 - ISC
124 *
125 * This source code is licensed under the ISC license.
126 * See the LICENSE file in the root directory of this source tree.
127 */const u3=Ps("CloudRain",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 14v6",key:"1j4efv"}],["path",{d:"M8 14v6",key:"17c4r9"}],["path",{d:"M12 16v6",key:"c8a4gj"}]]);/**
128 * @license lucide-react v0.462.0 - ISC
129 *
130 * This source code is licensed under the ISC license.
131 * See the LICENSE file in the root directory of this source tree.
132 */const Z1=Ps("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);/**
133 * @license lucide-react v0.462.0 - ISC
134 *
135 * This source code is licensed under the ISC license.
136 * See the LICENSE file in the root directory of this source tree.
137 */const W1=Ps("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
138 * @license lucide-react v0.462.0 - ISC
139 *
140 * This source code is licensed under the ISC license.
141 * See the LICENSE file in the root directory of this source tree.
142 */const h3=Ps("Command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]);/**
143 * @license lucide-react v0.462.0 - ISC
144 *
145 * This source code is licensed under the ISC license.
146 * See the LICENSE file in the root directory of this source tree.
147 */const pS=Ps("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
148 * @license lucide-react v0.462.0 - ISC
149 *
150 * This source code is licensed under the ISC license.
151 * See the LICENSE file in the root directory of this source tree.
152 */const gS=Ps("Construction",[["rect",{x:"2",y:"6",width:"20",height:"8",rx:"1",key:"1estib"}],["path",{d:"M17 14v7",key:"7m2elx"}],["path",{d:"M7 14v7",key:"1cm7wv"}],["path",{d:"M17 3v3",key:"1v4jwn"}],["path",{d:"M7 3v3",key:"7o6guu"}],["path",{d:"M10 14 2.3 6.3",key:"1023jk"}],["path",{d:"m14 6 7.7 7.7",key:"1s8pl2"}],["path",{d:"m8 6 8 8",key:"hl96qh"}]]);/**
153 * @license lucide-react v0.462.0 - ISC
154 *
155 * This source code is licensed under the ISC license.
156 * See the LICENSE file in the root directory of this source tree.
157 */const Wm=Ps("Container",[["path",{d:"M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z",key:"1t2lqe"}],["path",{d:"M10 21.9V14L2.1 9.1",key:"o7czzq"}],["path",{d:"m10 14 11.9-6.9",key:"zm5e20"}],["path",{d:"M14 19.8v-8.1",key:"159ecu"}],["path",{d:"M18 17.5V9.4",key:"11uown"}]]);/**
158 * @license lucide-react v0.462.0 - ISC
159 *
160 * This source code is licensed under the ISC license.
161 * See the LICENSE file in the root directory of this source tree.
162 */const m3=Ps("CornerDownRight",[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]);/**
163 * @license lucide-react v0.462.0 - ISC
164 *
165 * This source code is licensed under the ISC license.
166 * See the LICENSE file in the root directory of this source tree.
167 */const xS=Ps("Crop",[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]]);/**
168 * @license lucide-react v0.462.0 - ISC
169 *
170 * This source code is licensed under the ISC license.
171 * See the LICENSE file in the root directory of this source tree.
172 */const tN=Ps("Crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);/**
173 * @license lucide-react v0.462.0 - ISC
174 *
175 * This source code is licensed under the ISC license.
176 * See the LICENSE file in the root directory of this source tree.
177 */const f3=Ps("Dog",[["path",{d:"M11.25 16.25h1.5L12 17z",key:"w7jh35"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M4.42 11.247A13.152 13.152 0 0 0 4 14.556C4 18.728 7.582 21 12 21s8-2.272 8-6.444a11.702 11.702 0 0 0-.493-3.309",key:"u7s9ue"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M8.5 8.5c-.384 1.05-1.083 2.028-2.344 2.5-1.931.722-3.576-.297-3.656-1-.113-.994 1.177-6.53 4-7 1.923-.321 3.651.845 3.651 2.235A7.497 7.497 0 0 1 14 5.277c0-1.39 1.844-2.598 3.767-2.277 2.823.47 4.113 6.006 4 7-.08.703-1.725 1.722-3.656 1-1.261-.472-1.855-1.45-2.239-2.5",key:"v8hric"}]]);/**
178 * @license lucide-react v0.462.0 - ISC
179 *
180 * This source code is licensed under the ISC license.
181 * See the LICENSE file in the root directory of this source tree.
182 */const Lf=Ps("DoorOpen",[["path",{d:"M13 4h3a2 2 0 0 1 2 2v14",key:"hrm0s9"}],["path",{d:"M2 20h3",key:"1gaodv"}],["path",{d:"M13 20h9",key:"s90cdi"}],["path",{d:"M10 12v.01",key:"vx6srw"}],["path",{d:"M13 4.562v16.157a1 1 0 0 1-1.242.97L5 20V5.562a2 2 0 0 1 1.515-1.94l4-1A2 2 0 0 1 13 4.561Z",key:"199qr4"}]]);/**
183 * @license lucide-react v0.462.0 - ISC
184 *
185 * This source code is licensed under the ISC license.
186 * See the LICENSE file in the root directory of this source tree.
187 */const Fx=Ps("Droplet",[["path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z",key:"c7niix"}]]);/**
188 * @license lucide-react v0.462.0 - ISC
189 *
190 * This source code is licensed under the ISC license.
191 * See the LICENSE file in the root directory of this source tree.
192 */const Y1=Ps("Fan",[["path",{d:"M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z",key:"484a7f"}],["path",{d:"M12 12v.01",key:"u5ubse"}]]);/**
193 * @license lucide-react v0.462.0 - ISC
194 *
195 * This source code is licensed under the ISC license.
196 * See the LICENSE file in the root directory of this source tree.
197 */const s_=Ps("Fence",[["path",{d:"M4 3 2 5v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"1n2rgs"}],["path",{d:"M6 8h4",key:"utf9t1"}],["path",{d:"M6 18h4",key:"12yh4b"}],["path",{d:"m12 3-2 2v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"3ha7mj"}],["path",{d:"M14 8h4",key:"1r8wg2"}],["path",{d:"M14 18h4",key:"1t3kbu"}],["path",{d:"m20 3-2 2v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"dfd4e2"}]]);/**
198 * @license lucide-react v0.462.0 - ISC
199 *
200 * This source code is licensed under the ISC license.
201 * See the LICENSE file in the root directory of this source tree.
202 */const _S=Ps("FileWarning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
203 * @license lucide-react v0.462.0 - ISC
204 *
205 * This source code is licensed under the ISC license.
206 * See the LICENSE file in the root directory of this source tree.
207 */const sN=Ps("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/**
208 * @license lucide-react v0.462.0 - ISC
209 *
210 * This source code is licensed under the ISC license.
211 * See the LICENSE file in the root directory of this source tree.
212 */const p3=Ps("FlipHorizontal2",[["path",{d:"m3 7 5 5-5 5V7",key:"couhi7"}],["path",{d:"m21 7-5 5 5 5V7",key:"6ouia7"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/**
213 * @license lucide-react v0.462.0 - ISC
214 *
215 * This source code is licensed under the ISC license.
216 * See the LICENSE file in the root directory of this source tree.
217 */const Ob=Ps("Flower2",[["path",{d:"M12 5a3 3 0 1 1 3 3m-3-3a3 3 0 1 0-3 3m3-3v1M9 8a3 3 0 1 0 3 3M9 8h1m5 0a3 3 0 1 1-3 3m3-3h-1m-2 3v-1",key:"3pnvol"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M12 10v12",key:"6ubwww"}],["path",{d:"M12 22c4.2 0 7-1.667 7-5-4.2 0-7 1.667-7 5Z",key:"9hd38g"}],["path",{d:"M12 22c-4.2 0-7-1.667-7-5 4.2 0 7 1.667 7 5Z",key:"ufn41s"}]]);/**
218 * @license lucide-react v0.462.0 - ISC
219 *
220 * This source code is licensed under the ISC license.
221 * See the LICENSE file in the root directory of this source tree.
222 */const g3=Ps("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}
222]]);/**
223 * @license lucide-react v0.462.0 - ISC
224 *
225 * This source code is licensed under the ISC license.
226 * See the LICENSE file in the root directory of this source tree.
227 */const Nx=Ps("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/**
228 * @license lucide-react v0.462.0 - ISC
229 *
230 * This source code is licensed under the ISC license.
231 * See the LICENSE file in the root directory of this source tree.
232 */const zu=Ps("Footprints",[["path",{d:"M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z",key:"1dudjm"}],["path",{d:"M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z",key:"l2t8xc"}],["path",{d:"M16 17h4",key:"1dejxt"}],["path",{d:"M4 13h4",key:"1bwh8b"}]]);/**
233 * @license lucide-react v0.462.0 - ISC
234 *
235 * This source code is licensed under the ISC license.
236 * See the LICENSE file in the root directory of this source tree.
237 */const X1=Ps("Fuel",[["line",{x1:"3",x2:"15",y1:"22",y2:"22",key:"xegly4"}],["line",{x1:"4",x2:"14",y1:"9",y2:"9",key:"xcnuvu"}],["path",{d:"M14 22V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v18",key:"16j0yd"}],["path",{d:"M14 13h2a2 2 0 0 1 2 2v2a2 2 0 0 0 2 2a2 2 0 0 0 2-2V9.83a2 2 0 0 0-.59-1.42L18 5",key:"7cu91f"}]]);/**
238 * @license lucide-react v0.462.0 - ISC
239 *
240 * This source code is licensed under the ISC license.
241 * See the LICENSE file in the root directory of this source tree.
242 */const x3=Ps("GalleryHorizontalEnd",[["path",{d:"M2 7v10",key:"a2pl2d"}],["path",{d:"M6 5v14",key:"1kq3d7"}],["rect",{width:"12",height:"18",x:"10",y:"3",rx:"2",key:"13i7bc"}]]);/**
243 * @license lucide-react v0.462.0 - ISC
244 *
245 * This source code is licensed under the ISC license.
246 * See the LICENSE file in the root directory of this source tree.
247 */const nN=Ps("Gavel",[["path",{d:"m14.5 12.5-8 8a2.119 2.119 0 1 1-3-3l8-8",key:"15492f"}],["path",{d:"m16 16 6-6",key:"vzrcl6"}],["path",{d:"m8 8 6-6",key:"18bi4p"}],["path",{d:"m9 7 8 8",key:"5jnvq1"}],["path",{d:"m21 11-8-8",key:"z4y7zo"}]]);/**
248 * @license lucide-react v0.462.0 - ISC
249 *
250 * This source code is licensed under the ISC license.
251 * See the LICENSE file in the root directory of this source tree.
252 */const _3=Ps("Gem",[["path",{d:"M6 3h12l4 6-10 13L2 9Z",key:"1pcd5k"}],["path",{d:"M11 3 8 9l4 13 4-13-3-6",key:"1fcu3u"}],["path",{d:"M2 9h20",key:"16fsjt"}]]);/**
253 * @license lucide-react v0.462.0 - ISC
254 *
255 * This source code is licensed under the ISC license.
256 * See the LICENSE file in the root directory of this source tree.
257 */const zx=Ps("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/**
258 * @license lucide-react v0.462.0 - ISC
259 *
260 * This source code is licensed under the ISC license.
261 * See the LICENSE file in the root directory of this source tree.
262 */const y3=Ps("Grid2x2",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/**
263 * @license lucide-react v0.462.0 - ISC
264 *
265 * This source code is licensed under the ISC license.
266 * See the LICENSE file in the root directory of this source tree.
267 */const dm=Ps("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
268 * @license lucide-react v0.462.0 - ISC
269 *
270 * This source code is licensed under the ISC license.
271 * See the LICENSE file in the root directory of this source tree.
272 */const v3=Ps("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]);/**
273 * @license lucide-react v0.462.0 - ISC
274 *
275 * This source code is licensed under the ISC license.
276 * See the LICENSE file in the root directory of this source tree.
277 */const Fh=Ps("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
278 * @license lucide-react v0.462.0 - ISC
279 *
280 * This source code is licensed under the ISC license.
281 * See the LICENSE file in the root directory of this source tree.
282 */const b3=Ps("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}
282]]);/**
283 * @license lucide-react v0.462.0 - ISC
284 *
285 * This source code is licensed under the ISC license.
286 * See the LICENSE file in the root directory of this source tree.
287 */const j3=Ps("Hexagon",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]]);/**
288 * @license lucide-react v0.462.0 - ISC
289 *
290 * This source code is licensed under the ISC license.
291 * See the LICENSE file in the root directory of this source tree.
292 */const Ox=Ps("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
293 * @license lucide-react v0.462.0 - ISC
294 *
295 * This source code is licensed under the ISC license.
296 * See the LICENSE file in the root directory of this source tree.
297 */const Zd=Ps("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
298 * @license lucide-react v0.462.0 - ISC
299 *
300 * This source code is licensed under the ISC license.
301 * See the LICENSE file in the root directory of this source tree.
302 */const K1=Ps("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/**
303 * @license lucide-react v0.462.0 - ISC
304 *
305 * This source code is licensed under the ISC license.
306 * See the LICENSE file in the root directory of this source tree.
307 */const Mh=Ps("LandPlot",[["path",{d:"m12 8 6-3-6-3v10",key:"mvpnpy"}],["path",{d:"m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12",key:"ek95tt"}],["path",{d:"m6.49 12.85 11.02 6.3",key:"1kt42w"}],["path",{d:"M17.51 12.85 6.5 19.15",key:"v55bdg"}]]);/**
308 * @license lucide-react v0.462.0 - ISC
309 *
310 * This source code is licensed under the ISC license.
311 * See the LICENSE file in the root directory of this source tree.
312 */const Bm=Ps("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
313 * @license lucide-react v0.462.0 - ISC
314 *
315 * This source code is licensed under the ISC license.
316 * See the LICENSE file in the root directory of this source tree.
317 */const pm=Ps("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
318 * @license lucide-react v0.462.0 - ISC
319 *
320 * This source code is licensed under the ISC license.
321 * See the LICENSE file in the root directory of this source tree.
322 */const Hy=Ps("Leaf",[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]]);/**
323 * @license lucide-react v0.462.0 - ISC
324 *
325 * This source code is licensed under the ISC license.
326 * See the LICENSE file in the root directory of this source tree.
327 */const Cf=Ps("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/**
328 * @license lucide-react v0.462.0 - ISC
329 *
330 * This source code is licensed under the ISC license.
331 * See the LICENSE file in the root directory of this source tree.
332 */const w3=Ps("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/**
333 * @license lucide-react v0.462.0 - ISC
334 *
335 * This source code is licensed under the ISC license.
336 * See the LICENSE file in the root directory of this source tree.
337 */const pp=Ps("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",ke
337y:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
338 * @license lucide-react v0.462.0 - ISC
339 *
340 * This source code is licensed under the ISC license.
341 * See the LICENSE file in the root directory of this source tree.
342 */const J1=Ps("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
343 * @license lucide-react v0.462.0 - ISC
344 *
345 * This source code is licensed under the ISC license.
346 * See the LICENSE file in the root directory of this source tree.
347 */const Mf=Ps("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
348 * @license lucide-react v0.462.0 - ISC
349 *
350 * This source code is licensed under the ISC license.
351 * See the LICENSE file in the root directory of this source tree.
352 */const N3=Ps("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/**
353 * @license lucide-react v0.462.0 - ISC
354 *
355 * This source code is licensed under the ISC license.
356 * See the LICENSE file in the root directory of this source tree.
357 */const k3=Ps("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
358 * @license lucide-react v0.462.0 - ISC
359 *
360 * This source code is licensed under the ISC license.
361 * See the LICENSE file in the root directory of this source tree.
362 */const C3=Ps("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
363 * @license lucide-react v0.462.0 - ISC
364 *
365 * This source code is licensed under the ISC license.
366 * See the LICENSE file in the root directory of this source tree.
367 */const Q1=Ps("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/**
368 * @license lucide-react v0.462.0 - ISC
369 *
370 * This source code is licensed under the ISC license.
371 * See the LICENSE file in the root directory of this source tree.
372 */const S3=Ps("MousePointer",[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]]);/**
373 * @license lucide-react v0.462.0 - ISC
374 *
375 * This source code is licensed under the ISC license.
376 * See the LICENSE file in the root directory of this source tree.
377 */const yS=Ps("Move3d",[["path",{d:"M5 3v16h16",key:"1mqmf9"}],["path",{d:"m5 19 6-6",key:"jh6hbb"}],["path",{d:"m2 6 3-3 3 3",key:"tkyvxa"}],["path",{d:"m18 16 3 3-3 3",key:"1d4glt"}]]);/**
378 * @license lucide-react v0.462.0 - ISC
379 *
380 * This source code is licensed under the ISC license.
381 * See the LICENSE file in the root directory of this source tree.
382 */const vS=Ps("MoveHorizontal",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}]]);/**
383 * @license lucide-react v0.462.0 - ISC
384 *
385 * This source code is licensed under the ISC license.
386 * See the LICENSE file in the root directory of this source tree.
387 */const bS=Ps("MoveVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]);/**
388 * @license lucide-react v0.462.0 - ISC
389 *
390 * This source code is licensed under the ISC license.
391 * See the LICENSE file in the root directory of this source tree.
392 */const If=Ps("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/**
393 * @license lucide-react v0.462.0 - ISC
394 *
395 * This source code is licensed under the ISC license.
396 * See the LICENSE file in the root directory of this source tree.
397 */const jS=Ps("Paintbrush",[["path",{d:"m14.622 17.897-10.68-2.913",key:"vj2p1u"}],["path",{d:"M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z",ke
397y:"18tc5c"}],["path",{d:"M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15",key:"ytzfxy"}]]);/**
398 * @license lucide-react v0.462.0 - ISC
399 *
400 * This source code is licensed under the ISC license.
401 * See the LICENSE file in the root directory of this source tree.
402 */const C0=Ps("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/**
403 * @license lucide-react v0.462.0 - ISC
404 *
405 * This source code is licensed under the ISC license.
406 * See the LICENSE file in the root directory of this source tree.
407 */const aN=Ps("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/**
408 * @license lucide-react v0.462.0 - ISC
409 *
410 * This source code is licensed under the ISC license.
411 * See the LICENSE file in the root directory of this source tree.
412 */const E3=Ps("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/**
413 * @license lucide-react v0.462.0 - ISC
414 *
415 * This source code is licensed under the ISC license.
416 * See the LICENSE file in the root directory of this source tree.
417 */const P3=Ps("PanelTop",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]);/**
418 * @license lucide-react v0.462.0 - ISC
419 *
420 * This source code is licensed under the ISC license.
421 * See the LICENSE file in the root directory of this source tree.
422 */const T3=Ps("PencilLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}],["path",{d:"m15 5 3 3",key:"1w25hb"}]]);/**
423 * @license lucide-react v0.462.0 - ISC
424 *
425 * This source code is licensed under the ISC license.
426 * See the LICENSE file in the root directory of this source tree.
427 */const fd=Ps("Pentagon",[["path",{d:"M10.83 2.38a2 2 0 0 1 2.34 0l8 5.74a2 2 0 0 1 .73 2.25l-3.04 9.26a2 2 0 0 1-1.9 1.37H7.04a2 2 0 0 1-1.9-1.37L2.1 10.37a2 2 0 0 1 .73-2.25z",key:"2hea0t"}]]);/**
428 * @license lucide-react v0.462.0 - ISC
429 *
430 * This source code is licensed under the ISC license.
431 * See the LICENSE file in the root directory of this source tree.
432 */const L3=Ps("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]);/**
433 * @license lucide-react v0.462.0 - ISC
434 *
435 * This source code is licensed under the ISC license.
436 * See the LICENSE file in the root directory of this source tree.
437 */const wS=Ps("PersonStanding",[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["path",{d:"m9 20 3-6 3 6",key:"se2kox"}],["path",{d:"m6 8 6 2 6-2",key:"4o3us4"}],["path",{d:"M12 10v4",key:"1kjpxc"}]]);/**
438 * @license lucide-react v0.462.0 - ISC
439 *
440 * This source code is licensed under the ISC license.
441 * See the LICENSE file in the root directory of this source tree.
442 */const rN=Ps("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);/**
443 * @license lucide-react v0.462.0 - ISC
444 *
445 * This source code is licensed under the ISC license.
446 * See the LICENSE file in the root directory of this source tree.
447 */const Bb=Ps("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7
447a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);/**
448 * @license lucide-react v0.462.0 - ISC
449 *
450 * This source code is licensed under the ISC license.
451 * See the LICENSE file in the root directory of this source tree.
452 */const M3=Ps("Pipette",[["path",{d:"m2 22 1-1h3l9-9",key:"1sre89"}],["path",{d:"M3 21v-3l9-9",key:"hpe2y6"}],["path",{d:"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z",key:"196du1"}]]);/**
453 * @license lucide-react v0.462.0 - ISC
454 *
455 * This source code is licensed under the ISC license.
456 * See the LICENSE file in the root directory of this source tree.
457 */const I3=Ps("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/**
458 * @license lucide-react v0.462.0 - ISC
459 *
460 * This source code is licensed under the ISC license.
461 * See the LICENSE file in the root directory of this source tree.
462 */const NS=Ps("RectangleHorizontal",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/**
463 * @license lucide-react v0.462.0 - ISC
464 *
465 * This source code is licensed under the ISC license.
466 * See the LICENSE file in the root directory of this source tree.
467 */const U1=Ps("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/**
468 * @license lucide-react v0.462.0 - ISC
469 *
470 * This source code is licensed under the ISC license.
471 * See the LICENSE file in the root directory of this source tree.
472 */const A3=Ps("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/**
473 * @license lucide-react v0.462.0 - ISC
474 *
475 * This source code is licensed under the ISC license.
476 * See the LICENSE file in the root directory of this source tree.
477 */const D3=Ps("Rotate3d",[["path",{d:"M16.466 7.5C15.643 4.237 13.952 2 12 2 9.239 2 7 6.477 7 12s2.239 10 5 10c.342 0 .677-.069 1-.2",key:"10n0gc"}],["path",{d:"m15.194 13.707 3.814 1.86-1.86 3.814",key:"16shm9"}],["path",{d:"M19 15.57c-1.804.885-4.274 1.43-7 1.43-5.523 0-10-2.239-10-5s4.477-5 10-5c4.838 0 8.873 1.718 9.8 4",key:"1lxi77"}]]);/**
478 * @license lucide-react v0.462.0 - ISC
479 *
480 * This source code is licensed under the ISC license.
481 * See the LICENSE file in the root directory of this source tree.
482 */const S0=Ps("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/**
483 * @license lucide-react v0.462.0 - ISC
484 *
485 * This source code is licensed under the ISC license.
486 * See the LICENSE file in the root directory of this source tree.
487 */const uo=Ps("Route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);/**
488 * @license lucide-react v0.462.0 - ISC
489 *
490 * This source code is licensed under the ISC license.
491 * See the LICENSE file in the root directory of this source tree.
492 */const kS=Ps("Rows3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/**
493 * @license lucide-react v0.462.0 - ISC
494 *
495 * This source code is licensed under the ISC license.
496 * See the LICENSE file in the root directory of this source tree.
497 */const CS=Ps("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/**
498 * @license lucide-react v0.462.0 - ISC
499 *
500 * This source code is licensed under the ISC license.
501 * See the LICENSE file in the root directory of this source tree.
502 */const $b=Ps("School",[["path",{d:"M14 22v-4a2 2 0 1 0-4 0v4",key:"hhkicm"}],["path",{d:"m18 10 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-7.382a1 1 0 0 1 .553-.894L6 10",key:"1xqip1"}],["path",{d:"M18 5v17",key:"1sw6gf"}],["path",{d:"m4 6 7.106-3.553a2 2 0 0 1 1.788 0L20 6",key:"9d2ml
502k"}],["path",{d:"M6 5v17",key:"1xfsm0"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}]]);/**
503 * @license lucide-react v0.462.0 - ISC
504 *
505 * This source code is licensed under the ISC license.
506 * See the LICENSE file in the root directory of this source tree.
507 */const Zy=Ps("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);/**
508 * @license lucide-react v0.462.0 - ISC
509 *
510 * This source code is licensed under the ISC license.
511 * See the LICENSE file in the root directory of this source tree.
512 */const R3=Ps("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/**
513 * @license lucide-react v0.462.0 - ISC
514 *
515 * This source code is licensed under the ISC license.
516 * See the LICENSE file in the root directory of this source tree.
517 */const dp=Ps("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
518 * @license lucide-react v0.462.0 - ISC
519 *
520 * This source code is licensed under the ISC license.
521 * See the LICENSE file in the root directory of this source tree.
522 */const F3=Ps("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/**
523 * @license lucide-react v0.462.0 - ISC
524 *
525 * This source code is licensed under the ISC license.
526 * See the LICENSE file in the root directory of this source tree.
527 */const Ag=Ps("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/**
528 * @license lucide-react v0.462.0 - ISC
529 *
530 * This source code is licensed under the ISC license.
531 * See the LICENSE file in the root directory of this source tree.
532 */const z3=Ps("ShowerHead",[["path",{d:"m4 4 2.5 2.5",key:"uv2vmf"}],["path",{d:"M13.5 6.5a4.95 4.95 0 0 0-7 7",key:"frdkwv"}],["path",{d:"M15 5 5 15",key:"1ag8rq"}],["path",{d:"M14 17v.01",key:"eokfpp"}],["path",{d:"M10 16v.01",key:"14uyyl"}],["path",{d:"M13 13v.01",key:"1v1k97"}],["path",{d:"M16 10v.01",key:"5169yg"}],["path",{d:"M11 20v.01",key:"cj92p8"}],["path",{d:"M17 14v.01",key:"11cswd"}],["path",{d:"M20 11v.01",key:"19e0od"}]]);/**
533 * @license lucide-react v0.462.0 - ISC
534 *
535 * This source code is licensed under the ISC license.
536 * See the LICENSE file in the root directory of this source tree.
537 */const Ng=Ps("Signpost",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M12 3v3",key:"1n5kay"}],["path",{d:"M18 6a2 2 0 0 1 1.387.56l2.307 2.22a1 1 0 0 1 0 1.44l-2.307 2.22A2 2 0 0 1 18 13H6a2 2 0 0 1-1.387-.56l-2.306-2.22a1 1 0 0 1 0-1.44l2.306-2.22A2 2 0 0 1 6 6z",key:"gqqp9m"}]]);/**
538 * @license lucide-react v0.462.0 - ISC
539 *
540 * This source code is licensed under the ISC license.
541 * See the LICENSE file in the root directory of this source tree.
542 */const ej=Ps("Siren",[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]]);/**
543 * @license lucide-react v0.462.0 - ISC
544 *
545 * This source code is licensed under the ISC license.
546 * See the LICENSE file in the root directory of this source tree.
547 */const O3=Ps("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/**
548 * @license lucide-react v0.462.0 - ISC
549 *
550 * This source code is licensed under the ISC license.
551 * See the LICENSE file in the root directory of this source tree.
552 */const tj=Ps("SlidersVertical",[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]]);/**
553 * @license lucide-react v0.462.0 - ISC
554 *
555 * This source code is licensed under the ISC license.
556 * See the LICENSE file in the root directory of this source tree.
557 */const SS=Ps("Snowflake",[["line",{x1:"2",x2:"22",y1:"12",y2:"12",key:"1dnqot"}],["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"m20 16-4-4 4-4",key:"rquw4f"}],["path",{d:"m4 8 4 4-4 4",key:"12s3z9"}],["path",{d:"m16 4-4 4-4-4",key:"1tumq1"}],["path",{d:"m8 20 4-4 4 4",key:"9p200w"}]]);/**
558 * @license lucide-react v0.462.0 - ISC
559 *
560 * This source code is licensed under the ISC license.
561 * See the LICENSE file in the root directory of this source tree.
562 */const iN=Ps("SquareAsterisk",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8.5 14 7-4",key:"12hpby"}],["path",{d:"m8.5 10 7 4",key:"wwy2dy"}]]);/**
563 * @license lucide-react v0.462.0 - ISC
564 *
565 * This source code is licensed under the ISC license.
566 * See the LICENSE file in the root directory of this source tree.
567 */const B3=Ps("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
568 * @license lucide-react v0.462.0 - ISC
569 *
570 * This source code is licensed under the ISC license.
571 * See the LICENSE file in the root directory of this source tree.
572 */const $3=Ps("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/**
573 * @license lucide-react v0.462.0 - ISC
574 *
575 * This source code is licensed under the ISC license.
576 * See the LICENSE file in the root directory of this source tree.
577 */const ES=Ps("SquareSlash",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/**
578 * @license lucide-react v0.462.0 - ISC
579 *
580 * This source code is licensed under the ISC license.
581 * See the LICENSE file in the root directory of this source tree.
582 */const PS=Ps("SquareSplitHorizontal",[["path",{d:"M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3",key:"lubmu8"}],["path",{d:"M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3",key:"1ag34g"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
583 * @license lucide-react v0.462.0 - ISC
584 *
585 * This source code is licensed under the ISC license.
586 * See the LICENSE file in the root directory of this source tree.
587 */const V3=Ps("SquareStack",[["path",{d:"M4 10c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"4i38lg"}],["path",{d:"M10 16c-1.1 0-2-.9-2-2v-4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"mlte4a"}],["rect",{width:"8",height:"8",x:"14",y:"14",rx:"2",key:"1fa9i4"}]]);/**
588 * @license lucide-react v0.462.0 - ISC
589 *
590 * This source code is licensed under the ISC license.
591 * See the LICENSE file in the root directory of this source tree.
592 */const Il=Ps("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
593 * @license lucide-react v0.462.0 - ISC
594 *
595 * This source code is licensed under the ISC license.
596 * See the LICENSE file in the root directory of this source tree.
597 */const E0=Ps("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);/**
598 * @license lucide-react v0.462.0 - ISC
599 *
600 * This source code is licensed under the ISC license.
601 * See the LICENSE file in the root directory of this source tree.
602 */const q3=Ps("StretchHorizontal",[["rect",{width:"20",height:"6",x:"2",y:"4",rx:"2",key:"qdearl"}],["rect",{width:"20",height:"6",x:"2",y:"14",rx:"2",key:"1xrn6j"}]]);/**
603 * @license lucide-react v0.462.0 - ISC
604 *
605 * This source code is licensed under the ISC license.
606 * See the LICENSE file in the root directory of this source tree.
607 */const n_=Ps("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/**
608 * @license lucide-react v0.462.0 - ISC
609 *
610 * This source code is licensed under the ISC license.
611 * See the LICENSE file in the root directory of this source tree.
612 */const G3=Ps("Thermometer",[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]]);/**
613 * @license lucide-react v0.462.0 - ISC
614 *
615 * This source code is licensed under the ISC license.
616 * See the LICENSE file in the root directory of this source tree.
617 */const H3=Ps("TrainTrack",[["path",{d:"M2 17 17 2",key:"18b09t"}],["path",{d:"m2 14 8 8",key:"1gv9hu"}],["path",{d:"m5 11 8 8",key:"189pqp"}],["path",{d:"m8 8 8 8",key:"1imecy"}],["path",{d:"m11 5 8 8",key:"ummqn6"}],["path",{d:"m14 2 8 8",key:"1vk7dn"}],["path",{d:"M7 22 22 7",key:"15mb1i"}]]);/**
618 * @license lucide-react v0.462.0 - ISC
619 *
620 * This source code is licensed under the ISC license.
621 * See the LICENSE file in the root directory of this source tree.
622 */const Ih=Ps("TreePine",[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]]);/**
623 * @license lucide-react v0.462.0 - ISC
624 *
625 * This source code is licensed under the ISC license.
626 * See the LICENSE file in the root directory of this source tree.
627 */const Bx=Ps("Trees",[["path",{d:"M10 10v.2A3 3 0 0 1 8.9 16H5a3 3 0 0 1-1-5.8V10a3 3 0 0 1 6 0Z",key:"1l6gj6"}],["path",{d:"M7 16v6",key:"1a82de"}],["path",{d:"M13 19v3",key:"13sx9i"}],["path",{d:"M12 19h8.3a1 1 0 0 0 .7-1.7L18 14h.3a1 1 0 0 0 .7-1.7L16 9h.2a1 1 0 0 0 .8-1.7L13 3l-1.4 1.5",key:"1sj9kv"}]]);/**
628 * @license lucide-react v0.462.0 - ISC
629 *
630 * This source code is licensed under the ISC license.
631 * See the LICENSE file in the root directory of this source tree.
632 */const Z3=Ps("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}
632],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/**
633 * @license lucide-react v0.462.0 - ISC
634 *
635 * This source code is licensed under the ISC license.
636 * See the LICENSE file in the root directory of this source tree.
637 */const hu=Ps("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/**
638 * @license lucide-react v0.462.0 - ISC
639 *
640 * This source code is licensed under the ISC license.
641 * See the LICENSE file in the root directory of this source tree.
642 */const ug=Ps("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
643 * @license lucide-react v0.462.0 - ISC
644 *
645 * This source code is licensed under the ISC license.
646 * See the LICENSE file in the root directory of this source tree.
647 */const TS=Ps("Umbrella",[["path",{d:"M22 12a10.06 10.06 1 0 0-20 0Z",key:"1teyop"}],["path",{d:"M12 12v8a2 2 0 0 0 4 0",key:"ulpmoc"}],["path",{d:"M12 2v1",key:"11qlp1"}]]);/**
648 * @license lucide-react v0.462.0 - ISC
649 *
650 * This source code is licensed under the ISC license.
651 * See the LICENSE file in the root directory of this source tree.
652 */const zf=Ps("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/**
653 * @license lucide-react v0.462.0 - ISC
654 *
655 * This source code is licensed under the ISC license.
656 * See the LICENSE file in the root directory of this source tree.
657 */const Wy=Ps("Unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]);/**
658 * @license lucide-react v0.462.0 - ISC
659 *
660 * This source code is licensed under the ISC license.
661 * See the LICENSE file in the root directory of this source tree.
662 */const W3=Ps("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/**
663 * @license lucide-react v0.462.0 - ISC
664 *
665 * This source code is licensed under the ISC license.
666 * See the LICENSE file in the root directory of this source tree.
667 */const oN=Ps("UtensilsCrossed",[["path",{d:"m16 2-2.3 2.3a3 3 0 0 0 0 4.2l1.8 1.8a3 3 0 0 0 4.2 0L22 8",key:"n7qcjb"}],["path",{d:"M15 15 3.3 3.3a4.2 4.2 0 0 0 0 6l7.3 7.3c.7.7 2 .7 2.8 0L15 15Zm0 0 7 7",key:"d0u48b"}],["path",{d:"m2.1 21.8 6.4-6.3",key:"yn04lh"}],["path",{d:"m19 5-7 7",key:"194lzd"}]]);/**
668 * @license lucide-react v0.462.0 - ISC
669 *
670 * This source code is licensed under the ISC license.
671 * See the LICENSE file in the root directory of this source tree.
672 */const lN=Ps("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);/**
673 * @license lucide-react v0.462.0 - ISC
674 *
675 * This source code is licensed under the ISC license.
676 * See the LICENSE file in the root directory of this source tree.
677 */const LS=Ps("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/**
678 * @license lucide-react v0.462.0 - ISC
679 *
680 * This source code is licensed under the ISC license.
681 * See the LICENSE file in the root directory of this source tree.
682 */const cN=Ps("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/**
683 * @license lucide-react v0.462.0 - ISC
684 *
685 * This source code is licensed under the ISC license.
686 * See the LICENSE file in the root directory of this source tree.
687 */const gp=Ps("Waves",[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]]);/**
688 * @license lucide-react v0.462.0 - ISC
689 *
690 * This source code is licensed under the ISC license.
691 * See the LICENSE file in the root directory of this source tree.
692 */const MS=Ps("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}
vendor: 2,883 bytes, lines 692-707
692],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/**
693 * @license lucide-react v0.462.0 - ISC
694 *
695 * This source code is licensed under the ISC license.
696 * See the LICENSE file in the root directory of this source tree.
697 */const sj=Ps("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/**
698 * @license lucide-react v0.462.0 - ISC
699 *
700 * This source code is licensed under the ISC license.
701 * See the LICENSE file in the root directory of this source tree.
702 */const IS=Ps("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/**
703 * @license lucide-react v0.462.0 - ISC
704 *
705 * This source code is licensed under the ISC license.
706 * See the LICENSE file in the root directory of this source tree.
707 */const Y3=Ps("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);var Td=63710088e-1,AS={centimeters:Td*100,centimetres:Td*100,degrees:360/(2*Math.PI),feet:Td*3.28084,inches:Td*39.37,kilometers:Td/1e3,kilometres:Td/1e3,meters:Td,metres:Td,miles:Td/1609.344,millimeters:Td*1e3,millimetres:Td*1e3,nauticalmiles:Td/1852,radians:1,yards:Td*1.0936};function qm(t,s,n={}){const a={type:"Feature"};return(n.id===0||n.id)&&(a.id=n.id),n.bbox&&(a.bbox=n.bbox),a.properties=s||{},a.geometry=t,a}function us(t,s,n={}){if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!dN(t[0])||!dN(t[1]))throw new Error("coordinates must contain numbers");return qm({type:"Point",coordinates:t},s,n)}function Xn(t,s,n={}){for(const l of t){if(l.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(l[l.length-1].length!==l[0].length)throw new Error("First and last Position are not equivalent.");for(let c=0;c<l[l.length-1].length;c++)if(l[l.length-1][c]!==l[0][c])throw new Error("First and last Position are not equivalent.")}return qm({type:"Polygon",coordinates:t},s,n)}function Yd(t,s,n={}){if(t.length<2)throw new Error("coordinates must be an array of two or more positions");return qm({type:"LineString",coordinates:t},s,n)}function Un(t,s={}){const n={type:"FeatureCollection"};return s.id&&(n.id=s.id),s.bbox&&(n.bbox=s.bbox),n.features=t,n}function nj(t,s,n={}){return qm({type:"MultiPolygon",coordinates:t},s,n)}function DS(t,s="kilometers"){const n=AS[s];
vendor: 3,192 bytes, line 707
707if(!n)throw new Error(s+" units is invalid");return t*n}function X3(t,s="kilometers"){const n=AS[s];if(!n)throw new Error(s+" units is invalid");return t/n}function D_(t){return t%360*Math.PI/180}function dN(t){return!isNaN(t)&&t!==null&&!Array.isArray(t)}const $m=11102230246251565e-32,Cd=134217729,K3=(3+8*$m)*$m;function wv(t,s,n,a,l){let c,u,i,_,j=s[0],y=a[0],x=0,v=0;y>j==y>-j?(c=j,j=s[++x]):(c=y,y=a[++v]);let C=0;if(x<t&&v<n)for(y>j==y>-j?(u=j+c,i=c-(u-j),j=s[++x]):(u=y+c,i=c-(u-y),y=a[++v]),c=u,i!==0&&(l[C++]=i);x<t&&v<n;)y>j==y>-j?(u=c+j,_=u-c,i=c-(u-_)+(j-_),j=s[++x]):(u=c+y,_=u-c,i=c-(u-_)+(y-_),y=a[++v]),c=u,i!==0&&(l[C++]=i);for(;x<t;)u=c+j,_=u-c,i=c-(u-_)+(j-_),j=s[++x],c=u,i!==0&&(l[C++]=i);for(;v<n;)u=c+y,_=u-c,i=c-(u-_)+(y-_),y=a[++v],c=u,i!==0&&(l[C++]=i);return(c!==0||C===0)&&(l[C++]=c),C}function J3(t,s){let n=s[0];for(let a=1;a<t;a++)n+=s[a];return n}function a_(t){return new Float64Array(t)}const Q3=(3+16*$m)*$m,U3=(2+12*$m)*$m,eM=(9+64*$m)*$m*$m,Hp=a_(4),uN=a_(8),hN=a_(12),mN=a_(16),$d=a_(4);function tM(t,s,n,a,l,c,u){let i,_,j,y,x,v,C,P,I,z,F,D,X,K,te,J,H,O;const q=t-l,W=n-l,Q=s-c,Z=a-c;K=q*Z,v=Cd*q,C=v-(v-q),P=q-C,v=Cd*Z,I=v-(v-Z),z=Z-I,te=P*z-(K-C*I-P*I-C*z),J=Q*W,v=Cd*Q,C=v-(v-Q),P=Q-C,v=Cd*W,I=v-(v-W),z=W-I,H=P*z-(J-C*I-P*I-C*z),F=te-H,x=te-F,Hp[0]=te-(F+x)+(x-H),D=K+F,x=D-K,X=K-(D-x)+(F-x),F=X-J,x=X-F,Hp[1]=X-(F+x)+(x-J),O=D+F,x=O-D,Hp[2]=D-(O-x)+(F-x),Hp[3]=O;let oe=J3(4,Hp),ce=U3*u;if(oe>=ce||-oe>=ce||(x=t-q,i=t-(q+x)+(x-l),x=n-W,j=n-(W+x)+(x-l),x=s-Q,_=s-(Q+x)+(x-c),x=a-Z,y=a-(Z+x)+(x-c),i===0&&_===0&&j===0&&y===0)||(ce=eM*u+K3*Math.abs(oe),oe+=q*y+Z*i-(Q*j+W*_),oe>=ce||-oe>=ce))return oe;K=i*Z,v=Cd*i,C=v-(v-i),P=i-C,v=Cd*Z,I=v-(v-Z),z=Z-I,te=P*z-(K-C*I-P*I-C*z),J=_*W,v=Cd*_,C=v-(v-_),P=_-C,v=Cd*W,I=v-(v-W),z=W-I,H=P*z-(J-C*I-P*I-C*z),F=te-H,x=te-F,$d[0]=te-(F+x)+(x-H),D=K+F,x=D-K,X=K-(D-x)+(F-x),F=X-J,x=X-F,$d[1]=X-(F+x)+(x-J),O=D+F,x=O-D,$d[2]=D-(O-x)+(F-x),$d[3]=O;const ae=wv(4,Hp,4,$d,uN);K=q*y,v=Cd*q,C=v-(v-q),P=q-C,v=Cd*y,I=v-(v-y),z=y-I,te=P*z-(K-C*I-P*I-C*z),J=Q*j,v=Cd*Q,C=v-(v-Q),P=Q-C,v=Cd*j,I=v-(v-j),z=j-I,H=P*z-(J-C*I-P*I-C*z),F=te-H,x=te-F,$d[0]=te-(F+x)+(x-H),D=K+F,x=D-K,X=K-(D-x)+(F-x),F=X-J,x=X-F,$d[1]=X-(F+x)+(x-J),O=D+F,x=O-D,$d[2]=D-(O-x)+(F-x),$d[3]=O;const ie=wv(ae,uN,4,$d,hN);K=i*y,v=Cd*i,C=v-(v-i),P=i-C,v=Cd*y,I=v-(v-y),z=y-I,te=P*z-(K-C*I-P*I-C*z),J=_*j,v=Cd*_,C=v-(v-_),P=_-C,v=Cd*j,I=v-(v-j),z=j-I,H=P*z-(J-C*I-P*I-C*z),F=te-H,x=te-F,$d[0]=te-(F+x)+(x-H),D=K+F,x=D-K,X=K-(D-x)+(F-x),F=X-J,x=X-F,$d[1]=X-(F+x)+(x-J),O=D+F,x=O-D,$d[2]=D-(O-x)+(F-x),$d[3]=O;const de=wv(ie,hN,4,$d,mN);return mN[de-1]}function sM(t,s,n,a,l,c){const u=(s-c)*(n-l),i=(t-l)*(a-c),_=u-i,j=Math.abs(u+i);return Math.abs(_)>=Q3*j?_:-tM(t,s,n,a,l,c,j)}function nM(t,s){var n,a,l=0,c,u,i,_,j,y,x,v=t[0],C=t[1],P=s.length;for(n=0;n<P;n++){a=0;var I=s[n],z=I.length-1;if(y=I[0],y[0]!==I[z][0]&&y[1]!==I[z][1])throw new Error("First and last coordinates in a ring must be the same");for(u=y[0]-v,i=y[1]-C,a;a<z;a++){if(x=I[a+1],_=x[0]-v,j=x[1]-C,i===0&&j===0){if(_<=0&&u>=0||u<=0&&_>=0)return 0}else if(j>=0&&i<=0||j<=0&&i>=0){if(c=sM(u,_,i,j,0,0),c===0)return 0;(c>0&&j>0&&i<=0||c<0&&j<=0&&i>0)&&l++}y=x,i=j,u=_}}return l%2!==0}
707function aM(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if(t.type==="Feature"&&t.geometry!==null&&t.geometry.type==="Point")return[...t.geometry.coordinates];if(t.type==="Point")return[...t.coordinates]}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return[...t];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function rM(t){return t.type==="Feature"?t.geometry:t}function iM(t,s,n={}){if(!t)throw new Error("point is required");if(!s)throw new Error("polygon is required");const a=aM(t),l=rM(s),c=l.type,u=s.bbox;let i=l.coordinates;if(u&&oM(a,u)===!1)return!1;c==="Polygon"&&(i=[i]);let _=!1;for(var j=0;j<i.length;++j){const y=nM(a,i[j]);if(y===0)return!n.ignoreBoundary;y&&(_=!0)}return _}function oM(t,s){return s[0]<=t[0]&&s[1]<=t[1]&&s[2]>=t[0]&&s[3]>=t[1]}var uu=iM;function Yy(t){return{id:String(t.id),apn:t.apn,fips:t.fips||void 0,address:t.address||"",city:t.city||void 0,state:t.state||void 0,stateName:t.state_name||void 0,zip:t.zip||void 0,zip4:t.zip4||void 0,placeName:t.place_name||void 0,owner:t.owner||"",ownerAddress:t.owner_address||void 0,ownerSecondary:t.owner_secondary||void 0,ownerType:t.owner_type||void 0,ownerOccupied:t.owner_occupied??void 0,acres:t.acres??void 0,sqft:t.sqft??void 0,lotWidth:t.lot_width??void 0,lotDepth:t.lot_depth??void 0,lotFrontage:t.lot_frontage??void 0,topography:t.topography||void 0,waterSource:t.water_source||void 0,sewerType:t.sewer_type||void 0,yearBuilt:t.year_built??void 0,effectiveYearBuilt:t.effective_year_built??void 0,stories:t.stories??void 0,bedrooms:t.bedrooms??void 0,bathrooms:t.bathrooms??void 0,halfBaths:t.half_baths??void 0,fullBaths:t.full_baths??void 0,totalRooms:t.total_rooms??void 0,buildingCount:t.building_count??void 0,unitCount:t.unit_count??void 0,buildingSqft:t.building_sqft??void 0,totalSqft:t.total_sqft??void 0,livingSqft:t.living_sqft??void 0,grossSqft:t.gross_sqft??void 0,finishedSqft:t.finished_sqft??void 0,elevation:t.elevation??void 0,hasBasement:t.has_basement||void 0,basementSqft:t.basement_sqft??void 0,garageType:t.garage_type||void 0,garageSqft:t.garage_sqft??void 0,hasAttic:t.has_attic||void 0,hasPool:t.has_pool||void 0,hasFireplace:t.has_fireplace||void 0,hasCarport:t.has_carport||void 0,parkingSpaces:t.parking_spaces??void 0,porchSqft:t.porch_sqft??void 0,patioSqft:t.patio_sqft??void 0,deckSqft:t.deck_sqft??void 0,viewType:t.view_type||void 0,acType:t.ac_type||void 0,heatingType:t.heating_type||void 0,roofType:t.roof_type||void 0,exteriorType:t.exterior_type||void 0,foundationType:t.foundation_type||void 0,constructionType:t.construction_type||void 0,floorType:t.floor_type||void 0,buildingStyle:t.building_style||void 0,buildingClass:t.building_class||void 0,buildingType:t.building_type||void 0,buildingQuality:t.building_quality||void 0,buildingCondition:t.building_condition||void 0,electricService:t.electric_service||void 0,gasService:t.gas_service||void 0,utilities:t.utilities||void 0,county:t.county||void 0,municipality:t.municipality||void 0,township:t.township||void 0,censusTract:t.census_tract||void 0,censusZip:t.census_zip||void 0,censusBlock:t.census_block||void 0,censusBlockGroup:t.census_block_group||void 0,schoolDistrict:t.school_district||void 0,schoolElementary:t.school_elementary||void 0,schoolMiddle:t.school_middle||void 0,schoolHigh:t.school_high||void 0,neighborhood:t.neighborhood||void 0,subdivisionName:t.subdivision_name||void 0,metroArea:t.metro_area||void 0,region:t.region||void 0,congressionalDistrict:t.congressional_district||void 0,floodZone:t.flood_zone||void 0,floodZoneCode:t.flood_zone_code||void 0,hasWetland:t.has_wetland??void 0,isCoastal:t.is_coastal??void 0,isWaterfront:t.is_waterfront??void 0,nearGolf:t.near_golf??void 0,landUse:t.land_use||void 0,landUseCode:t.land_use_code||void 0,zoning:t.zoning||void 0,zoningDescription:t.zoning_description||void 0,propertyType:t.property_type||void 0,landUseDescription:t.land_use_description||void 0,useCodeDescription:t.use_code_description||void 0,useType:t.use_type||void 0,assessedValue:t.assessed_value??void 0,marketValue:t.market_value??void 0,taxAmount:t.tax_amount??void 0,assessedLand:t.assessed_land??void 0,assessedImprovements:t.assessed_improvements??void 0,marketLand:t.market_land??void 0,marketImprovements:t.market_improvements??void 0,marketBuilding:t.market_building??void 0,taxYear:t.tax_year??void 0,landValue:t.land_value??void 0,improvementValue:t.improvement_value??void 0,totalValue:t.total_value??void 0,appraisedValue:t.appraised_value??void 0,priorAssessedValue:t.prior_assessed_value??void 0,taxCode:t.tax_code||void 0,taxRate:t.tax_rate??void 0,exemptAmount:t.exempt_amount??void 0,exemptionType:t.exemption_type||void 0,homesteadExempt:t.homestead_exempt??void 0,assessmentYear:t.assessment_year??void 0,taxDelinquent:t.tax_delinquent??void 0,taxLien:t.tax_lien??void 0,saleDate:t.sale_date||void 0,salePrice:t.sale_price??void 0,priorSaleDate:t.prior_sale_date||void 0,priorSalePrice:t.prior_sale_price??void 0,saleType:t.sale_type||void 0,sellerName:t.seller_name||void 0,buyerName:t.buyer_name||void 0,financingType:t.financing_type||void 0,armsLength:t.arms_length??void 0,isQuitclaim:t.is_quitclaim??void 0,isForeclosure:t.is_foreclosure??void 0,isReo:t.is_reo??void 0,isShortSale:t.is_short_sale??void 0,mortgageAmou
707nt:t.mortgage_amount??void 0,mortgageDate:t.mortgage_date||void 0,mortgageLender:t.mortgage_lender||void 0,mortgageType:t.mortgage_type||void 0,mortgage2Amount:t.mortgage2_amount??void 0,legalDescription:t.legal_description||void 0,subdivision:t.subdivision||void 0,deedBook:t.deed_book||void 0,deedPage:t.deed_page||void 0,documentNumber:t.document_number||void 0,recordingDate:t.recording_date||void 0,platBook:t.plat_book||void 0,platPage:t.plat_page||void 0,section:t.section||void 0,range:t.range||void 0,block:t.block||void 0,lot:t.lot||void 0,unit:t.unit||void 0,phase:t.phase||void 0,geometry:t.geometry||void 0,clickedLat:t.lat,clickedLng:t.lng,centroidLat:t.centroid_lat??void 0,centroidLon:t.centroid_lon??void 0,rawData:t.raw_data||void 0,source:t.source||"cache",fromCache:!0}}function lM(t){return{apn:t.apn,fips:t.fips||null,address:t.address||null,city:t.city||null,state:t.state||null,state_name:t.stateName||null,zip:t.zip||null,zip4:t.zip4||null,place_name:t.placeName||null,owner:t.owner||null,owner_address:t.ownerAddress||null,owner_secondary:t.ownerSecondary||null,owner_type:t.ownerType||null,owner_occupied:t.ownerOccupied??null,acres:t.acres??null,sqft:t.sqft??null,lot_width:t.lotWidth??null,lot_depth:t.lotDepth??null,lot_frontage:t.lotFrontage??null,topography:t.topography||null,water_source:t.waterSource||null,sewer_type:t.sewerType||null,year_built:t.yearBuilt??null,effective_year_built:t.effectiveYearBuilt??null,stories:t.stories??null,bedrooms:t.bedrooms??null,bathrooms:t.bathrooms??null,half_baths:t.halfBaths??null,full_baths:t.fullBaths??null,total_rooms:t.totalRooms??null,building_count:t.buildingCount??null,unit_count:t.unitCount??null,building_sqft:t.buildingSqft??null,total_sqft:t.totalSqft??null,living_sqft:t.livingSqft??null,gross_sqft:t.grossSqft??null,finished_sqft:t.finishedSqft??null,elevation:t.elevation??null,has_basement:t.hasBasement||null,basement_sqft:t.basementSqft??null,garage_type:t.garageType||null,garage_sqft:t.garageSqft??null,has_attic:t.hasAttic||null,has_pool:t.hasPool||null,has_fireplace:t.hasFireplace||null,has_carport:t.hasCarport||null,parking_spaces:t.parkingSpaces??null,porch_sqft:t.porchSqft??null,patio_sqft:t.patioSqft??null,deck_sqft:t.deckSqft??null,view_type:t.viewType||null,ac_type:t.acType||null,heating_type:t.heatingType||null,roof_type:t.roofType||null,exterior_type:t.exteriorType||null,foundation_type:t.foundationType||null,construction_type:t.constructionType||null,floor_type:t.floorType||null,building_style:t.buildingStyle||null,building_class:t.buildingClass||null,building_type:t.buildingType||null,building_quality:t.buildingQuality||null,building_condition:t.buildingCondition||null,electric_service:t.electricService||null,gas_service:t.gasService||null,utilities:t.utilities||null,county:t.county||null,municipality:t.municipality||null,township:t.township||null,census_tract:t.censusTract||null,census_zip:t.censusZip||null,census_block:t.censusBlock||null,census_block_group:t.censusBlockGroup||null,school_district:t.schoolDistrict||null,school_elementary:t.schoolElementary||null,school_middle:t.schoolMiddle||null,school_high:t.schoolHigh||null,
707neighborhood:t.neighborhood||null,subdivision_name:t.subdivisionName||null,metro_area:t.metroArea||null,region:t.region||null,congressional_district:t.congressionalDistrict||null,flood_zone:t.floodZone||null,flood_zone_code:t.floodZoneCode||null,has_wetland:t.hasWetland??null,is_coastal:t.isCoastal??null,is_waterfront:t.isWaterfront??null,near_golf:t.nearGolf??null,land_use:t.landUse||null,land_use_code:t.landUseCode||null,zoning:t.zoning||null,zoning_description:t.zoningDescription||null,property_type:t.propertyType||null,land_use_description:t.landUseDescription||null,use_code_description:t.useCodeDescription||null,use_type:t.useType||null,assessed_value:t.assessedValue??null,market_value:t.marketValue??null,tax_amount:t.taxAmount??null,assessed_land:t.assessedLand??null,assessed_improvements:t.assessedImprovements??null,market_land:t.marketLand??null,market_improvements:t.marketImprovements??null,market_building:t.marketBuilding??null,tax_year:t.taxYear??null,land_value:t.landValue??null,improvement_value:t.improvementValue??null,total_value:t.totalValue??null,appraised_value:t.appraisedValue??null,prior_assessed_value:t.priorAssessedValue??null,tax_code:t.taxCode||null,tax_rate:t.taxRate??null,exempt_amount:t.exemptAmount??null,exemption_type:t.exemptionType||null,homestead_exempt:t.homesteadExempt??null,assessment_year:t.assessmentYear??null,tax_delinquent:t.taxDelinquent??null,tax_lien:t.taxLien??null,sale_date:t.saleDate||null,sale_price:t.salePrice??null,prior_sale_date:t.priorSaleDate||null,prior_sale_price:t.priorSalePrice??null,sale_type:t.saleType||null,seller_name:t.sellerName||null,buyer_name:t.buyerName||null,financing_type:t.financingType||null,arms_length:t.armsLength??null,is_quitclaim:t.isQuitclaim??null,is_foreclosure:t.isForeclosure??null,is_reo:t.isReo??null,is_short_sale:t.isShortSale??null,mortgage_amount:t.mortgageAmount??null,mortgage_date:t.mortgageDate||null,mortgage_lender:t.mortgageLender||null,mortgage_type:t.mortgageType||null,mortgage2_amount:t.mortgage2Amount??null,legal_description:t.legalDescription||null,subdivision:t.subdivision||null,deed_book:t.deedBook||null,deed_page:t.deedPage||null,document_number:t.documentNumber||null,recording_date:t.recordingDate||null,plat_book:t.platBook||null,plat_page:t.platPage||null,section:t.section||null,range:t.range||null,block:t.block||null,lot:t.lot||null,unit:t.unit||null,phase:t.phase||null,geometry:t.geometry||null,lat:t.clickedLat||t.lat||null,lng:t.clickedLng||t.lng||null,centroid_lat:t.centroidLat??null,centroid_lon:t.centroidLon??null,raw_data:t.rawData||null,source:t.source||"api"}}async function cM(t){const s=t.trim().toLowerCase(),{data:n,error:a}=await Fs.from("parcel_cache").select("*").ilike("address",`%${s.split(",")[0].trim()}%`).limit(10);if(!a&&n&&n.length>0){const l=n.find(c=>{var u;return(u=c.address)==null?void 0:u.toLowerCase().includes(s.split(",")[0].trim().toLowerCase())})||n[0];return{found:!0,parcel:Yy(l),source:"cache"}}return{found:!1,parcel:null,source:null}}async function dM(t){const s=t.trim().replace(/[\s\-\.]/g,"");let{data:n,error:a}=await Fs.from("parcel_cache").select("*").eq("apn",t.trim()).limit(1);if((!n||n.length===0)&&!a){const{data:l}=await Fs.from("parcel_cache").select("*").ilike("apn",`%${s}%`).limit(5);n=l}return!a&&n&&n.length>0?{found:!0,parcel:Yy(n[0]),source:"cache"}:{found:!1,parcel:null,source:null}}const uM=()=>{const[t,s]=k.useState(!1),[n,a]=k.useState(null),[l,c]=k.useState(null),u=lc(),i=k.useCallback(async(v,C,P)=>{try{const I=lM({...v,clickedLat:C,clickedLng:P});v.geometry&&(I.geometry=JSON.parse(JSON.stringify(v.geometry))),v.rawData&&(I.raw_data=JSON.parse(JSON.stringify(v.rawData)));const{error:z}=await Fs.from("parcel_cache").upsert([I],{onConflict:"apn"});z?console.warn("Failed to cache parcel:",z):u.invalidateQueries({queryKey:["cached-parcels"]})}catch(I){console.warn("Error caching parcel:",I)}},[u]),_=k.useCallback(async(v,C)=>{s(!0),c(null),a(null);try{const{data:I,error:z}=await Fs.from("parcel_cache").select("*").gte("lat",v-.005).lte("lat",v+.005).gte("lng",C-.005).lte("lng",C+.005).order("updated_at",{ascending:!1}).limit(50);if(!z&&I&&I.length>0){const X=us([C,v]);for(const K of I)if(K.geometry)try{const te=K.geometry;let J=!1;if(te.type==="Polygon"){const H=Xn(te.coordinates);J=uu(X,H)}else if(te.type==="MultiPolygon"){const H=nj(te.coordinates);J=uu(X,H)}if(J){const H=Yy(K);return H.clickedLat=v,H.clickedLng=C,a(H),Ve.success("Loaded from cache",{description:`APN: ${H.apn}`,duration:2e3}),H}}catch(te){console.warn("Error checking point in polygon:",te)}}const{data:F,error:D}=await Fs.functions.invoke("report-all-parcel-lookup",{body:{lat:v,lng:C}});if(D)throw new Error(D.message);if(!F.success)throw new Error(F.error||"Failed to lookup parcel");if(F.parcel){const X={...F.parcel,clickedLat:v,clickedLng:C,fromCache:!1};return a(X),await i(X,v,C),Ve.success("Loaded from API",{description:`APN: ${X.apn} (now cached)`,duration:2e3}),X}else return Ve.info("No parcel found at this location"),null}catch(P){const I=P instanceof Error?P.message:"Failed to lookup parcel";return c(I),Ve.error(I),null}finally{s(!1)}},[i]),j=k.useCallback(async v=>{s(!0),c(null);try{const{data:C,error:P}=await Fs.from("parcel_cache").select("*").eq("id",v).single();if(P||!C)throw new Error("Parcel not found in cache");const I=Yy(C);return a(I),Ve.success("Loaded from cache",{description:`APN: ${I.apn}`,duration:2e3}),I}catch(C){const P=C instanceof Error?C.message:"Failed to load parcel";return c(P),Ve.error(P),null}finally{s(!1)}},[]),y=k.useCallback(()=>{a(null),c(null)},[]),x=k.useCallback(async(v,C)=>{s(!0),c(null);try{const{data:P,error:I}=await Fs.functions.invoke("report-all-parcel-lookup",{body:{lat:v,lng:C}});if(I)throw new Error(I.message);if(!P.success)throw new Error(P.error||"Failed to lookup parcel");if(P.parcel){const z={...P.parcel,clickedLat:v,clickedLng:C,fromCache:!1};return a(z),await i(z,v,C),Ve.success("Refreshed from API",{description:`APN: ${z.apn}
707 (cache updated)`,duration:2e3}),z}else return Ve.info("No parcel found at this location"),null}catch(P){const I=P instanceof Error?P.message:"Failed to refresh parcel";return c(I),Ve.error(I),null}finally{s(!1)}},[i]);return{isLoading:t,parcel:n,error:l,lookupParcel:_,loadParcelById:j,clearParcel:y,forceRefreshFromAPI:x}};var hM=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Nv=Math.ceil,rh=Math.floor,ou="[BigNumber Error] ",fN=ou+"Number primitive has more than 15 significant digits: ",Th=1e14,Fr=14,kv=9007199254740991,Cv=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],mf=1e7,Gc=1e9;function RS(t){var s,n,a,l=D.prototype={constructor:D,toString:null,valueOf:null},c=new D(1),u=20,i=4,_=-7,j=21,y=-1e7,x=1e7,v=!1,C=1,P=0,I={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},z="0123456789abcdefghijklmnopqrstuvwxyz",F=!0;function D(O,q){var W,Q,Z,oe,ce,ae,ie,de,ge=this;if(!(ge instanceof D))return new D(O,q);if(q==null){if(O&&O._isBigNumber===!0){ge.s=O.s,!O.c||O.e>x?ge.c=ge.e=null:O.e<y?ge.c=[ge.e=0]:(ge.e=O.e,ge.c=O.c.slice());return}if((ae=typeof O=="number")&&O*0==0){if(ge.s=1/O<0?(O=-O,-1):1,O===~~O){for(oe=0,ce=O;ce>=10;ce/=10,oe++);oe>x?ge.c=ge.e=null:(ge.e=oe,ge.c=[O]);return}de=String(O)}else{if(!hM.test(de=String(O)))return a(ge,de,ae);ge.s=de.charCodeAt(0)==45?(de=de.slice(1),-1):1}(oe=de.indexOf("."))>-1&&(de=de.replace(".","")),(ce=de.search(/e/i))>0?(oe<0&&(oe=ce),oe+=+de.slice(ce+1),de=de.substring(0,ce)):oe<0&&(oe=de.length)}else{if(_l(q,2,z.length,"Base"),q==10&&F)return ge=new D(O),J(ge,u+ge.e+1,i);if(de=String(O),ae=typeof O=="number"){if(O*0!=0)return a(ge,de,ae,q);if(ge.s=1/O<0?(de=de.slice(1),-1):1,D.DEBUG&&de.replace(/^0\.0*|\./,"").length>15)throw Error(fN+O)}else ge.s=de.charCodeAt(0)===45?(de=de.slice(1),-1):1;for(W=z.slice(0,q),oe=ce=0,ie=de.length;ce<ie;ce++)if(W.indexOf(Q=de.charAt(ce))<0){if(Q=="."){if(ce>oe){oe=ie;continue}}else if(!Z&&(de==de.toUpperCase()&&(de=de.toLowerCase())||de==de.toLowerCase()&&(de=de.toUpperCase()))){Z=!0,ce=-1,oe=0;continue}return a(ge,String(O),ae,q)}ae=!1,de=n(de,q,10,ge.s),(oe=de.indexOf("."))>-1?de=de.replace(".",""):oe=de.length}for(ce=0;de.charCodeAt(ce)===48;ce++);for(ie=de.length;de.charCodeAt(--ie)===48;);if(de=de.slice(ce,++ie)){if(ie-=ce,ae&&D.DEBUG&&ie>15&&(O>kv||O!==rh(O)))throw Error(fN+ge.s*O);if((oe=oe-ce-1)>x)ge.c=ge.e=null;else if(oe<y)ge.c=[ge.e=0];else{if(ge.e=oe,ge.c=[],ce=(oe+1)%Fr,oe<0&&(ce+=Fr),ce<ie){for(ce&&ge.c.push(+de.slice(0,ce)),ie-=Fr;ce<ie;)ge.c.push(+de.slice(ce,ce+=Fr));ce=Fr-(de=de.slice(ce)).length}else ce-=ie;for(;ce--;de+="0");ge.c.push(+de)}}else ge.c=[ge.e=0]}D.clone=RS,D.ROUND_UP=0,D.ROUND_DOWN=1,D.ROUND_CEIL=2,D.ROUND_FLOOR=3,D.ROUND_HALF_UP=4,D.ROUND_HALF_DOWN=5,D.ROUND_HALF_EVEN=6,D.ROUND_HALF_CEIL=7,D.ROUND_HALF_FLOOR=8,D.EUCLID=9,D.config=D.set=function(O){var q,W;if(O!=null)if(typeof O=="object"){if(O.hasOwnProperty(q="DECIMAL_PLACES")&&(W=O[q],_l(W,0,Gc,q),u=W),O.hasOwnProperty(q="ROUNDING_MODE")&&(W=O[q],_l(W,0,8,q),i=W),O.hasOwnProperty(q="EXPONENTIAL_AT")&&(W=O[q],W&&W.pop?(_l(W[0],-Gc,0,q),_l(W[1],0,Gc,q),_=W[0],j=W[1]):(_l(W,-Gc,Gc,q),_=-(j=W<0?-W:W))),O.hasOwnProperty(q="RANGE"))if(W=O[q],W&&W.pop)_l(W[0],-Gc,-1,q),_l(W[1],1,Gc,q),y=W[0],x=W[1];else if(_l(W,-Gc,Gc,q),W)y=-(x=W<0?-W:W);else throw Error(ou+q+" cannot be zero: "+W);if(O.hasOwnProperty(q="CRYPTO"))if(W=O[q],W===!!W)if(W)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))v=W;else throw v=!W,Error(ou+"crypto unavailable");else v=W;else throw Error(ou+q+" not true or false: "+W);if(O.hasOwnProperty(q="MODULO_MODE")&&(W=O[q],_l(W,0,9,q),C=W),O.hasOwnProperty(q="POW_PRECISION")&&(W=O[q],_l(W,0,Gc,q),P=W),O.hasOwnProperty(q="FORMAT"))if(W=O[q],typeof W=="object")I=W;else throw Error(ou+q+" not an object: "+W);if(O.hasOwnProperty(q="ALPHABET"))if(W=O[q],typeof W=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(W))F=W.slice(0,10)=="0123456789",z=W;else throw Error(ou+q+" invalid: "+W)}else throw Error(ou+"Object expected: "+O);return{DECIMAL_PLACES:u,ROUNDING_MODE:i,EXPONENTIAL_AT:[_,j],RANGE:[y,x],CRYPTO:v,MODULO_MODE:C,POW_PRECISION:P,FORMAT:I,ALPHABET:z}},D.isBigNumber=function(O){if(!O||O._isBigNumber!==!0)return!1;if(!D.DEBUG)return!0;
vendor: 10,480 bytes, line 707
707var q,W,Q=O.c,Z=O.e,oe=O.s;e:if({}.toString.call(Q)=="[object Array]"){if((oe===1||oe===-1)&&Z>=-Gc&&Z<=Gc&&Z===rh(Z)){if(Q[0]===0){if(Z===0&&Q.length===1)return!0;break e}if(q=(Z+1)%Fr,q<1&&(q+=Fr),String(Q[0]).length==q){for(q=0;q<Q.length;q++)if(W=Q[q],W<0||W>=Th||W!==rh(W))break e;if(W!==0)return!0}}}else if(Q===null&&Z===null&&(oe===null||oe===1||oe===-1))return!0;throw Error(ou+"Invalid BigNumber: "+O)},D.maximum=D.max=function(){return K(arguments,-1)},D.minimum=D.min=function(){return K(arguments,1)},D.random=function(){var O=9007199254740992,q=Math.random()*O&2097151?function(){return rh(Math.random()*O)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(W){var Q,Z,oe,ce,ae,ie=0,de=[],ge=new D(c);if(W==null?W=u:_l(W,0,Gc),ce=Nv(W/Fr),v)if(crypto.getRandomValues){for(Q=crypto.getRandomValues(new Uint32Array(ce*=2));ie<ce;)ae=Q[ie]*131072+(Q[ie+1]>>>11),ae>=9e15?(Z=crypto.getRandomValues(new Uint32Array(2)),Q[ie]=Z[0],Q[ie+1]=Z[1]):(de.push(ae%1e14),ie+=2);ie=ce/2}else if(crypto.randomBytes){for(Q=crypto.randomBytes(ce*=7);ie<ce;)ae=(Q[ie]&31)*281474976710656+Q[ie+1]*1099511627776+Q[ie+2]*4294967296+Q[ie+3]*16777216+(Q[ie+4]<<16)+(Q[ie+5]<<8)+Q[ie+6],ae>=9e15?crypto.randomBytes(7).copy(Q,ie):(de.push(ae%1e14),ie+=7);ie=ce/7}else throw v=!1,Error(ou+"crypto unavailable");if(!v)for(;ie<ce;)ae=q(),ae<9e15&&(de[ie++]=ae%1e14);for(ce=de[--ie],W%=Fr,ce&&W&&(ae=Cv[Fr-W],de[ie]=rh(ce/ae)*ae);de[ie]===0;de.pop(),ie--);if(ie<0)de=[oe=0];else{for(oe=-1;de[0]===0;de.splice(0,1),oe-=Fr);for(ie=1,ae=de[0];ae>=10;ae/=10,ie++);ie<Fr&&(oe-=Fr-ie)}return ge.e=oe,ge.c=de,ge}}(),D.sum=function(){for(var O=1,q=arguments,W=new D(q[0]);O<q.length;)W=W.plus(q[O++]);return W},n=function(){var O="0123456789";function q(W,Q,Z,oe){for(var ce,ae=[0],ie,de=0,ge=W.length;de<ge;){for(ie=ae.length;ie--;ae[ie]*=Q);for(ae[0]+=oe.indexOf(W.charAt(de++)),ce=0;ce<ae.length;ce++)ae[ce]>Z-1&&(ae[ce+1]==null&&(ae[ce+1]=0),ae[ce+1]+=ae[ce]/Z|0,ae[ce]%=Z)}return ae.reverse()}return function(W,Q,Z,oe,ce){var ae,ie,de,ge,We,Ee,ve,we,Ze=W.indexOf("."),ke=u,ze=i;for(Ze>=0&&(ge=P,P=0,W=W.replace(".",""),we=new D(Q),Ee=we.pow(W.length-Ze),P=ge,we.c=q(Tm(ah(Ee.c),Ee.e,"0"),10,Z,O),we.e=we.c.length),ve=q(W,Q,Z,ce?(ae=z,O):(ae=O,z)),de=ge=ve.length;ve[--ge]==0;ve.pop());if(!ve[0])return ae.charAt(0);if(Ze<0?--de:(Ee.c=ve,Ee.e=de,Ee.s=oe,Ee=s(Ee,we,ke,ze,Z),ve=Ee.c,We=Ee.r,de=Ee.e),ie=de+ke+1,Ze=ve[ie],ge=Z/2,We=We||ie<0||ve[ie+1]!=null,We=ze<4?(Ze!=null||We)&&(ze==0||ze==(Ee.s<0?3:2)):Ze>ge||Ze==ge&&(ze==4||We||ze==6&&ve[ie-1]&1||ze==(Ee.s<0?8:7)),ie<1||!ve[0])W=We?Tm(ae.charAt(1),-ke,ae.charAt(0)):ae.charAt(0);else{if(ve.length=ie,We)for(--Z;++ve[--ie]>Z;)ve[ie]=0,ie||(++de,ve=[1].concat(ve));for(ge=ve.length;!ve[--ge];);for(Ze=0,W="";Ze<=ge;W+=ae.charAt(ve[Ze++]));W=Tm(W,de,ae.charAt(0))}return W}}(),s=function(){function O(Q,Z,oe){var ce,ae,ie,de,ge=0,We=Q.length,Ee=Z%mf,ve=Z/mf|0;for(Q=Q.slice();We--;)ie=Q[We]%mf,de=Q[We]/mf|0,ce=ve*ie+de*Ee,ae=Ee*ie+ce%mf*mf+ge,ge=(ae/oe|0)+(ce/mf|0)+ve*de,Q[We]=ae%oe;return ge&&(Q=[ge].concat(Q)),Q}function q(Q,Z,oe,ce){var ae,ie;if(oe!=ce)ie=oe>ce?1:-1;else for(ae=ie=0;ae<oe;ae++)if(Q[ae]!=Z[ae]){ie=Q[ae]>Z[ae]?1:-1;break}return ie}function W(Q,Z,oe,ce){for(var ae=0;oe--;)Q[oe]-=ae,ae=Q[oe]<Z[oe]?1:0,Q[oe]=ae*ce+Q[oe]-Z[oe];for(;!Q[0]&&Q.length>1;Q.splice(0,1));}return function(Q,Z,oe,ce,ae){var ie,de,ge,We,Ee,ve,we,Ze,ke,ze,Ke,dt,Re,qt,ft,Fe,fe,Qe=Q.s==Z.s?1:-1,ht=Q.c,_t=Z.c;if(!ht||!ht[0]||!_t||!_t[0])return new D(!Q.s||!Z.s||(ht?_t&&ht[0]==_t[0]:!_t)?NaN:ht&&ht[0]==0||!_t?Qe*0:Qe/0);for(Ze=new D(Qe),ke=Ze.c=[],de=Q.e-Z.e,Qe=oe+de+1,ae||(ae=Th,de=ih(Q.e/Fr)-ih(Z.e/Fr),Qe=Qe/Fr|0),ge=0;_t[ge]==(ht[ge]||0);ge++);if(_t[ge]>(ht[ge]||0)&&de--,Qe<0)ke.push(1),We=!0;else{for(qt=ht.length,Fe=_t.length,ge=0,Qe+=2,Ee=rh(ae/(_t[0]+1)),Ee>1&&(_t=O(_t,Ee,ae),ht=O(ht,Ee,ae),Fe=_t.length,qt=ht.length),Re=Fe,ze=ht.slice(0,Fe),Ke=ze.length;Ke<Fe;ze[Ke++]=0);fe=_t.slice(),fe=[0].concat(fe),ft=_t[0],_t[1]>=ae/2&&ft++;do{if(Ee=0,ie=q(_t,ze,Fe,Ke),ie<0){if(dt=ze[0],Fe!=Ke&&(dt=dt*ae+(ze[1]||0)),Ee=rh(dt/ft),Ee>1)for(Ee>=ae&&(Ee=ae-1),ve=O(_t,Ee,ae),we=ve.length,Ke=ze.length;q(ve,ze,we,Ke)==1;)Ee--,W(ve,Fe<we?fe:_t,we,ae),we=ve.length,ie=1;else Ee==0&&(ie=Ee=1),ve=_t.slice(),we=ve.length;if(we<Ke&&(ve=[0].concat(ve)),W(ze,ve,Ke,ae),Ke=ze.length,ie==-1)for(;q(_t,ze,Fe,Ke)<1;)Ee++,W(ze,Fe<Ke?fe:_t,Ke,ae),Ke=ze.length}else ie===0&&(Ee++,ze=[0]);ke[ge++]=Ee,ze[0]?ze[Ke++]=ht[Re]||0:(ze=[ht[Re]],Ke=1)}while((Re++<qt||ze[0]!=null)&&Qe--);We=ze[0]!=null,ke[0]||ke.splice(0,1)}if(ae==Th){for(ge=1,Qe=ke[0];Qe>=10;Qe/=10,ge++);J(Ze,oe+(Ze.e=ge+de*Fr-1)+1,ce,We)}else Ze.e=de,Ze.r=+We;return Ze}}();function X(O,q,W,Q){var Z,oe,ce,ae,ie;if(W==null?W=i:_l(W,0,8),!O.c)return O.toString();if(Z=O.c[0],ce=O.e,q==null)ie=ah(O.c),ie=Q==1||Q==2&&(ce<=_||ce>=j)?F_(ie,ce):Tm(ie,ce,"0");else if(O=J(new D(O),q,W),oe=O.e,ie=ah(O.c),ae=ie.length,Q==1||Q==2&&(q<=oe||oe<=_)){for(;ae<q;ie+="0",ae++);ie=F_(ie,oe)}else if(q-=ce+(Q===2&&oe>ce),ie=Tm(ie,oe,"0"),oe+1>ae){if(--q>0)for(ie+=".";q--;ie+="0");}else if(q+=oe-ae,q>0)for(oe+1==ae&&(ie+=".");q--;ie+="0");return O.s<0&&Z?"-"+ie:ie}function K(O,q){for(var W,Q,Z=1,oe=new D(O[0]);Z<O.length;Z++)Q=new D(O[Z]),(!Q.s||(W=ep(oe,Q))===q||W===0&&oe.s===q)&&(oe=Q);return oe}function te(O,q,W){for(var Q=1,Z=q.length;!q[--Z];q.pop());for(Z=q[0];Z>=10;Z/=10,Q++);return(W=Q+W*Fr-1)>x?O.c=O.e=null:W<y?O.c=[O.e=0]:(O.e=W,O.c=q),O}a=function(){var O=/^(-?)0([xbo])(?=\w[\w.]*$)/i,q=/^([^.]+)\.$/,W=/^\.([^.]+)$/,Q=/^-?(Infinity|NaN)$/,Z=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(oe,ce,ae,ie){var de,ge=ae?ce:ce.replace(Z,"");if(Q.test(ge))oe.s=isNaN(ge)?null:ge<0?-1:1;else{if(!ae&&(ge=ge.replace(O,function(We,Ee,ve){return de=(ve=ve.toLowerCase())=="x"?16:ve=="b"?2:8,!ie||ie==de?Ee:We}),ie&&(de=ie,ge=ge.replace(q,"$1").replace(W,"0.$1")),ce!=ge))return new D(ge,de);if(D.DEBUG)throw Error(ou+"Not a"+(ie?" base "+ie:"")+" number: "+ce);oe.s=null}oe.c=oe.e=null}}();function J(O,q,W,Q){var Z,oe,ce,ae,ie,de,ge,We=O.c,Ee=Cv;if(We){e:{for(Z=1,ae=We[0];ae>=10;ae/=10,Z++);if(oe=q-Z,oe<0)oe+=Fr,ce=q,ie=We[de=0],ge=rh(ie/Ee[Z-ce-1]%10);else if(de=Nv((oe+1)/Fr),de>=We.length)if(Q){for(;We.length<=de;We.push(0));ie=ge=0,Z=1,oe%=Fr,ce=oe-Fr+1}else break e;else{for(ie=ae=We[de],Z=1;ae>=10;ae/=10,Z++);oe%=Fr,ce=oe-Fr+Z,ge=ce<0?0:rh(ie/Ee[Z-ce-1]%10)}if(Q=Q||q<0||We[de+1]!=null||(ce<0?ie:ie%Ee[Z-ce-1]),Q=W<4?(ge||Q)&&(W==0||W==(O.s<0?3:2)):ge>5||ge==5&&(W==4||Q||W==6&&(oe>0?ce>0?ie/Ee[Z-ce]:0:We[de-1])%10&1||W==(O.s<0?8:7)),q<1||!We[0])return We.length=0,Q?(q-=O.e+1,We[0]=Ee[(Fr-q%Fr)%Fr],O.e=-q||0):We[0]=O.e=0,O;if(oe==0?(We.length=de,ae=1,de--):(We.length=de+1,ae=Ee[Fr-oe],We[de]=ce>0?rh(ie/Ee[Z-ce]%Ee[ce])*ae:0),Q)for(;;)if(de==0){for(oe=1,ce=We[0];ce>=10;ce/=10,oe++);for(ce=We[0]+=ae,ae=1;ce>=10;ce/=10,ae++);oe!=ae&&(O.e++,We[0]==Th&&(We[0]=1));break}else{if(We[de]+=ae,We[de]!=Th)break;We[de--]=0,ae=1}for(oe=We.length;We[--oe]===0;We.pop());}O.e>x?O.c=O.e=null:O.e<y&&(O.c=[O.e=0])}return O}function H(O){var q,W=O.e;return W===null?O.toString():(q=ah(O.c),q=W<=_||W>=j?F_(q,W):Tm(q,W,"0"),O.s<0?"-"+q:q)}return l.absoluteValue=l.abs=function(){var O=new D(this);return O.s<0&&(O.s=1),O},l.comparedTo=function(O,q){return ep(this,new D(O,q))},l.decimalPlaces=l.dp=function(O,q){var W,Q,Z,oe=this;if(O!=null)return _l(O,0,Gc),q==null?q=i:_l(q,0,8),J(new D(oe),O+oe.e+1,q);if(!(W=oe.c))return null;if(Q=((Z=W.length-1)-ih(this.e/Fr))*Fr,Z=W[Z])for(;Z%10==0;Z/=10,Q--);return Q<0&&(Q=0),Q},l.dividedBy=l.div=function(O,q){return s(this,new D(O,q),u,i)},l.dividedToIntegerBy=l.idiv=function(O,q){return s(this,new D(O,q),0,1)},l.exponentiatedBy=l.pow=function(O,q){var W,Q,Z,oe,ce,ae,ie,de,ge,We=this;if(O=new D(O),O.c&&!O.isInteger())throw Error(ou+"Exponent not an integer: "+H(O));if(q!=null&&(q=new D(q)),ae=O.e>14,!We.c||!We.c[0]||We.c[0]==1&&!We.e&&We.c.length==1||!O.c||!O.c[0])return ge=new D(Math.pow(+H(We),ae?O.s*(2-R_(O)):+H(O))),q?ge.mod(q):ge;if(ie=O.s<0,q){if(q.c?!q.c[0]:!q.s)return new D(NaN);Q=!ie&&We.isInteger()&&q.isInteger(),Q&&(We=We.mod(q))}else{if(O.e>9&&(We.e>0||We.e<-1||(We.e==0?We.c[0]>1||ae&&We.c[1]>=24e7:We.c[0]<8e13||ae&&We.c[0]<=9999975e7)))return oe=We.s<0&&R_(O)?-0:0,We.e>-1&&(oe=1/oe),new D(ie?1/oe:oe);P&&(oe=Nv(P/Fr+2))}for(ae?(W=new D(.5),ie&&(O.s=1),de=R_(O)):(Z=Math.abs(+H(O)),de=Z%2),ge=new D(c);;){if(de){if(ge=ge.times(We),!ge.c)break;oe?ge.c.length>oe&&(ge.c.length=oe):Q&&(ge=ge.mod(q))}if(Z){if(Z=rh(Z/2),Z===0)break;de=Z%2}else if(O=O.times(W),J(O,O.e+1,1),O.e>14)de=R_(O);else{if(Z=+H(O),Z===0)break;de=Z%2}We=We.times(We),oe?We.c&&We.c.length>oe&&(We.c.length=oe):Q&&(We=We.mod(q))}return Q?ge:(ie&&(ge=c.div(ge)),q?ge.mod(q):oe?J(ge,P,i,ce):ge)},l.integerValue=function(O){var q=new D(this);return O==null?O=i:_l(O,0,8),J(q,q.e+1,O)},l.isEqualTo=l.eq=function(O,q){return ep(this,new D(O,q))===0},l.isFinite=function(){return!!this.c},l.isGreaterThan=l.gt=function(O,q){return ep(this,new D(O,q))>0},l.isGreaterThanOrEqualTo=l.gte=function(O,q){return(q=ep(this,new D(O,q)))===1||q===0},l.isInteger=function(){return!!this.c&&ih(this.e/Fr)>this.c.length-2},l.isLessThan=l.lt=function(O,q){return ep(this,new D(O,q))<0},l.isLessThanOrEqualTo=l.lte=function(O,q){return(q=ep(this,new D(O,q)))===-1||q===0},l.isNaN=function(){return!this.s},l.isNegative=function(){return this.s<0},l.isPositive=function(){return this.s>0},l.isZero=function(){return!!this.c&&this.c[0]==0},l.minus=function(O,q){var W,Q,Z,oe,ce=this,ae=ce.s;if(O=new D(O,q),q=O.s,!ae||!q)return new D(NaN);if(ae!=q)return O.s=-q,ce.plus(O);var ie=ce.e/Fr,de=O.e/Fr,ge=ce.c,We=O.c;if(!ie||!de){if(!ge||!We)return ge?(O.s=-q,O):new D(We?ce:NaN);if(!ge[0]||!We[0])return We[0]?(O.s=-q,O):new D(ge[0]?ce:i==3?-0:0)}if(ie=ih(ie),de=ih(de),ge=ge.slice(),ae=ie-de){for((oe=ae<0)?(ae=-ae,Z=ge):(de=ie,Z=We),Z.reverse(),q=ae;q--;Z.push(0));Z.reverse()}else for(Q=(oe=(ae=ge.length)<(q=We.length))?ae:q,ae=q=0;q<Q;q++)if(ge[q]!=We[q]){oe=ge[q]<We[q];break}if(oe&&(Z=ge,ge=We,We=Z,O.s=-O.s),q=(Q=We.length)-(W=ge.length),q>0)for(;q--;ge[W++]=0);for(q=Th-1;Q>ae;){if(ge[--Q]<We[Q]){for(W=Q;W&&!ge[--W];ge[W]=q);--ge[W],ge[Q]+=Th}ge[Q]-=We[Q]}for(;ge[0]==0;ge.splice(0,1),--de);return ge[0]?te(O,ge,de):(O.s=i==3?-1:1,O.c=[O.e=0],O)},l.modulo=l.mod=function(O,q){var W,Q,Z=this;return O=new D(O,q),!Z.c||!O.s||O.c&&!O.c[0]?new D(NaN):!O.c||Z.c&&!Z.c[0]?new D(Z):(C==9?(Q=O.s,O.s=1,W=s(Z,O,0,3),O.s=Q,W.s*=Q):W=s(Z,O,0,C),O=Z.minus(W.t
vendor: 2,269 bytes, line 707
707imes(O)),!O.c[0]&&C==1&&(O.s=Z.s),O)},l.multipliedBy=l.times=function(O,q){var W,Q,Z,oe,ce,ae,ie,de,ge,We,Ee,ve,we,Ze,ke,ze=this,Ke=ze.c,dt=(O=new D(O,q)).c;if(!Ke||!dt||!Ke[0]||!dt[0])return!ze.s||!O.s||Ke&&!Ke[0]&&!dt||dt&&!dt[0]&&!Ke?O.c=O.e=O.s=null:(O.s*=ze.s,!Ke||!dt?O.c=O.e=null:(O.c=[0],O.e=0)),O;for(Q=ih(ze.e/Fr)+ih(O.e/Fr),O.s*=ze.s,ie=Ke.length,We=dt.length,ie<We&&(we=Ke,Ke=dt,dt=we,Z=ie,ie=We,We=Z),Z=ie+We,we=[];Z--;we.push(0));for(Ze=Th,ke=mf,Z=We;--Z>=0;){for(W=0,Ee=dt[Z]%ke,ve=dt[Z]/ke|0,ce=ie,oe=Z+ce;oe>Z;)de=Ke[--ce]%ke,ge=Ke[ce]/ke|0,ae=ve*de+ge*Ee,de=Ee*de+ae%ke*ke+we[oe]+W,W=(de/Ze|0)+(ae/ke|0)+ve*ge,we[oe--]=de%Ze;we[oe]=W}return W?++Q:we.splice(0,1),te(O,we,Q)},l.negated=function(){var O=new D(this);return O.s=-O.s||null,O},l.plus=function(O,q){var W,Q=this,Z=Q.s;if(O=new D(O,q),q=O.s,!Z||!q)return new D(NaN);if(Z!=q)return O.s=-q,Q.minus(O);var oe=Q.e/Fr,ce=O.e/Fr,ae=Q.c,ie=O.c;if(!oe||!ce){if(!ae||!ie)return new D(Z/0);if(!ae[0]||!ie[0])return ie[0]?O:new D(ae[0]?Q:Z*0)}if(oe=ih(oe),ce=ih(ce),ae=ae.slice(),Z=oe-ce){for(Z>0?(ce=oe,W=ie):(Z=-Z,W=ae),W.reverse();Z--;W.push(0));W.reverse()}for(Z=ae.length,q=ie.length,Z-q<0&&(W=ie,ie=ae,ae=W,q=Z),Z=0;q;)Z=(ae[--q]=ae[q]+ie[q]+Z)/Th|0,ae[q]=Th===ae[q]?0:ae[q]%Th;return Z&&(ae=[Z].concat(ae),++ce),te(O,ae,ce)},l.precision=l.sd=function(O,q){var W,Q,Z,oe=this;if(O!=null&&O!==!!O)return _l(O,1,Gc),q==null?q=i:_l(q,0,8),J(new D(oe),O,q);if(!(W=oe.c))return null;if(Z=W.length-1,Q=Z*Fr+1,Z=W[Z]){for(;Z%10==0;Z/=10,Q--);for(Z=W[0];Z>=10;Z/=10,Q++);}return O&&oe.e+1>Q&&(Q=oe.e+1),Q},l.shiftedBy=function(O){return _l(O,-kv,kv),this.times("1e"+O)},l.squareRoot=l.sqrt=function(){var O,q,W,Q,Z,oe=this,ce=oe.c,ae=oe.s,ie=oe.e,de=u+4,ge=new D("0.5");if(ae!==1||!ce||!ce[0])return new D(!ae||ae<0&&(!ce||ce[0])?NaN:ce?oe:1/0);if(ae=Math.sqrt(+H(oe)),ae==0||ae==1/0?(q=ah(ce),(q.length+ie)%2==0&&(q+="0"),ae=Math.sqrt(+q),ie=ih((ie+1)/2)-(ie<0||ie%2),ae==1/0?q="5e"+ie:(q=ae.toExponential(),q=q.slice(0,q.indexOf("e")+1)+ie),W=new D(q)):W=new D(ae+""),W.c[0]){for(ie=W.e,ae=ie+de,ae<3&&(ae=0);;)if(Z=W,W=ge.times(Z.plus(s(oe,Z,de,1))),ah(Z.c).slice(0,ae)===(q=ah(W.c)).slice(0,ae))if(W.e<ie&&--ae,q=q.slice(ae-3,ae+1),q=="9999"||!Q&&q=="4999"){if(!Q&&(J(Z,Z.e+u+2,0),Z.times(Z).eq(oe))){W
vendor: 1,524 bytes, line 707
707=Z;break}de+=4,ae+=4,Q=1}else{(!+q||!+q.slice(1)&&q.charAt(0)=="5")&&(J(W,W.e+u+2,1),O=!W.times(W).eq(oe));break}}return J(W,W.e+u+1,i,O)},l.toExponential=function(O,q){return O!=null&&(_l(O,0,Gc),O++),X(this,O,q,1)},l.toFixed=function(O,q){return O!=null&&(_l(O,0,Gc),O=O+this.e+1),X(this,O,q)},l.toFormat=function(O,q,W){var Q,Z=this;if(W==null)O!=null&&q&&typeof q=="object"?(W=q,q=null):O&&typeof O=="object"?(W=O,O=q=null):W=I;else if(typeof W!="object")throw Error(ou+"Argument not an object: "+W);if(Q=Z.toFixed(O,q),Z.c){var oe,ce=Q.split("."),ae=+W.groupSize,ie=+W.secondaryGroupSize,de=W.groupSeparator||"",ge=ce[0],We=ce[1],Ee=Z.s<0,ve=Ee?ge.slice(1):ge,we=ve.length;if(ie&&(oe=ae,ae=ie,ie=oe,we-=oe),ae>0&&we>0){for(oe=we%ae||ae,ge=ve.substr(0,oe);oe<we;oe+=ae)ge+=de+ve.substr(oe,ae);ie>0&&(ge+=de+ve.slice(oe)),Ee&&(ge="-"+ge)}Q=We?ge+(W.decimalSeparator||"")+((ie=+W.fractionGroupSize)?We.replace(new RegExp("\\d{"+ie+"}\\B","g"),"$&"+(W.fractionGroupSeparator||"")):We):ge}return(W.prefix||"")+Q+(W.suffix||"")},l.toFraction=function(O){var q,W,Q,Z,oe,ce,ae,ie,de,ge,We,Ee,ve=this,we=ve.c;if(O!=null&&(ae=new D(O),!ae.isInteger()&&(ae.c||ae.s!==1)||ae.lt(c)))throw Error(ou+"Argument "+(ae.isInteger()?"out of range: ":"not an integer: ")+H(ae));if(!we)return new D(ve);for(q=new D(c),de=W=new D(c),Q=ie=new D(c),Ee=ah(we),oe=q.e=Ee.length-ve.e-1,q.c[0]=Cv[(ce=oe%Fr)<0?Fr+ce:ce],O=!O||ae.comparedTo(q)>0?oe>0?q:de:ae,ce=x,x=1/0,ae=new D(Ee),ie.c[0]=0;ge=s(ae,q,0,1),Z=W.plus(ge.times(Q)),Z.comparedTo(O)!=1;
vendor: 22,510 bytes, line 707
707)W=Q,Q=Z,de=ie.plus(ge.times(Z=de)),ie=Z,q=ae.minus(ge.times(Z=q)),ae=Z;return Z=s(O.minus(W),Q,0,1),ie=ie.plus(Z.times(de)),W=W.plus(Z.times(Q)),ie.s=de.s=ve.s,oe=oe*2,We=s(de,Q,oe,i).minus(ve).abs().comparedTo(s(ie,W,oe,i).minus(ve).abs())<1?[de,Q]:[ie,W],x=ce,We},l.toNumber=function(){return+H(this)},l.toPrecision=function(O,q){return O!=null&&_l(O,1,Gc),X(this,O,q,2)},l.toString=function(O){var q,W=this,Q=W.s,Z=W.e;return Z===null?Q?(q="Infinity",Q<0&&(q="-"+q)):q="NaN":(O==null?q=Z<=_||Z>=j?F_(ah(W.c),Z):Tm(ah(W.c),Z,"0"):O===10&&F?(W=J(new D(W),u+Z+1,i),q=Tm(ah(W.c),W.e,"0")):(_l(O,2,z.length,"Base"),q=n(Tm(ah(W.c),Z,"0"),10,O,Q,!0)),Q<0&&W.c[0]&&(q="-"+q)),q},l.valueOf=l.toJSON=function(){return H(this)},l._isBigNumber=!0,l[Symbol.toStringTag]="BigNumber",l[Symbol.for("nodejs.util.inspect.custom")]=l.valueOf,t!=null&&D.set(t),D}function ih(t){var s=t|0;return t>0||t===s?s:s-1}function ah(t){for(var s,n,a=1,l=t.length,c=t[0]+"";a<l;){for(s=t[a++]+"",n=Fr-s.length;n--;s="0"+s);c+=s}for(l=c.length;c.charCodeAt(--l)===48;);return c.slice(0,l+1||1)}function ep(t,s){var n,a,l=t.c,c=s.c,u=t.s,i=s.s,_=t.e,j=s.e;if(!u||!i)return null;if(n=l&&!l[0],a=c&&!c[0],n||a)return n?a?0:-i:u;if(u!=i)return u;if(n=u<0,a=_==j,!l||!c)return a?0:!l^n?1:-1;if(!a)return _>j^n?1:-1;for(i=(_=l.length)<(j=c.length)?_:j,u=0;u<i;u++)if(l[u]!=c[u])return l[u]>c[u]^n?1:-1;return _==j?0:_>j^n?1:-1}function _l(t,s,n,a){if(t<s||t>n||t!==rh(t))throw Error(ou+(a||"Argument")+(typeof t=="number"?t<s||t>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function R_(t){var s=t.c.length-1;return ih(t.e/Fr)==s&&t.c[s]%2!=0}function F_(t,s){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(s<0?"e":"e+")+s}function Tm(t,s,n){var a,l;if(s<0){for(l=n+".";++s;l+=n);t=l+t}else if(a=t.length,++s>a){for(l=n,s-=a;--s;l+=n);t+=l}else s<a&&(t=t.slice(0,s)+"."+t.slice(s));return t}var im=RS(),mM=class{constructor(t){za(this,"key");za(this,"left",null);za(this,"right",null);this.key=t}},ax=class extends mM{constructor(t){super(t)}},fM=class{constructor(){za(this,"size",0);za(this,"modificationCount",0);za(this,"splayCount",0)}splay(t){const s=this.root;if(s==null)return this.compare(t,t),-1;let n=null,a=null,l=null,c=null,u=s;const i=this.compare;let _;for(;;)if(_=i(u.key,t),_>0){let j=u.left;if(j==null||(_=i(j.key,t),_>0&&(u.left=j.right,j.right=u,u=j,j=u.left,j==null)))break;n==null?a=u:n.left=u,n=u,u=j}else if(_<0){let j=u.right;if(j==null||(_=i(j.key,t),_<0&&(u.right=j.left,j.left=u,u=j,j=u.right,j==null)))break;l==null?c=u:l.right=u,l=u,u=j}else break;return l!=null&&(l.right=u.left,u.left=c),n!=null&&(n.left=u.right,u.right=a),this.root!==u&&(this.root=u,this.splayCount++),_}splayMin(t){let s=t,n=s.left;for(;n!=null;){const a=n;s.left=a.right,a.right=s,s=a,n=s.left}return s}splayMax(t){let s=t,n=s.right;for(;n!=null;){const a=n;s.right=a.left,a.left=s,s=a,n=s.right}return s}_delete(t){if(this.root==null||this.splay(t)!=0)return null;let n=this.root;const a=n,l=n.left;if(this.size--,l==null)this.root=n.right;else{const c=n.right;n=this.splayMax(l),n.right=c,this.root=n}return this.modificationCount++,a}addNewRoot(t,s){this.size++,this.modificationCount++;const n=this.root;if(n==null){this.root=t;return}s<0?(t.left=n,t.right=n.right,n.right=null):(t.right=n,t.left=n.left,n.left=null),this.root=t}_first(){const t=this.root;return t==null?null:(this.root=this.splayMin(t),this.root)}_last(){const t=this.root;return t==null?null:(this.root=this.splayMax(t),this.root)}clear(){this.root=null,this.size=0,this.modificationCount++}has(t){return this.validKey(t)&&this.splay(t)==0}defaultCompare(){return(t,s)=>t<s?-1:t>s?1:0}wrap(){return{getRoot:()=>this.root,setRoot:t=>{this.root=t},getSize:()=>this.size,getModificationCount:()=>this.modificationCount,getSplayCount:()=>this.splayCount,setSplayCount:t=>{this.splayCount=t},splay:t=>this.splay(t),has:t=>this.has(t)}}},OC,BC,Xy=class fx extends fM{constructor(n,a){super();za(this,"root",null);za(this,"compare");za(this,"validKey");za(this,OC,"[object Set]");this.compare=n??this.defaultCompare(),this.validKey=a??(l=>l!=null&&l!=null)}delete(n){return this.validKey(n)?this._delete(n)!=null:!1}deleteAll(n){for(const a of n)this.delete(a)}forEach(n){const a=this[Symbol.iterator]();let l;for(;l=a.next(),!l.done;)n(l.value,l.value,this)}add(n){const a=this.splay(n);return a!=0&&this.addNewRoot(new ax(n),a),this}addAndReturn(n){const a=this.splay(n);return a!=0&&this.addNewRoot(new ax(n),a),this.root.key}addAll(n){for(const a of n)this.add(a)}isEmpty(){return this.root==null}isNotEmpty(){return this.root!=null}single(){if(this.size==0)throw"Bad state: No element";if(this.size>1)throw"Bad state: Too many element";return this.root.key}first(){if(this.size==0)throw"Bad state: No element";return this._first().key}last(){if(this.size==0)throw"Bad state: No element";return this._last().key}lastBefore(n){if(n==null)throw"Invalid arguments(s)";if(this.root==null)return null;if(this.splay(n)<0)return this.root.key;let l=this.root.left;if(l==null)return null;let c=l.right;for(;c!=null;)l=c,c=l.right;return l.key}firstAfter(n){if(n==null)throw"Invalid arguments(s)";if(this.root==null)return null;if(this.splay(n)>0)return this.root.key;let l=this.root.right;if(l==null)return null;let c=l.left;for(;c!=null;)l=c,c=l.left;return l.key}retainAll(n){const a=new fx(this.compare,this.validKey),l=this.modificationCount;for(const c of n){if(l!=this.modificationCount)throw"Concurrent modification during iteration.";this.validKey(c)&&this.splay(c)==0&&a.add(this.root.key)}a.size!=this.size&&(this.root=a.root,this.size=a.size,this.modificationCount++)}lookup(n){return!this.validKey(n)||this.splay(n)!=0?null:this.root.key}intersection(n){const a=new fx(this.compare,this.validKey);for(const l of this)n.has(l)&&a.add(l);return a}difference(n){const a=new fx(this.compare,this.validKey);for(const l of this)n.has(l)||a.add(l);return a}union(n){const a=this.clone();return a.addAll(n),a}clone(){const n=new fx(this.compare,this.validKey);return n.size=this.size,n.root=this.copyNode(this.root),n}copyNode(n){if(n==null)return null;function a(c,u){let i,_;do{if(i=c.left,_=c.right,i!=null){const j=new ax(i.key);u.left=j,a(i,j)}if(_!=null){const j=new ax(_.key);u.right=j,c=_,u=j}}while(_!=null)}const l=new ax(n.key);return a(n,l),l}toSet(){return this.clone()}entries(){return new gM(this.wrap())}keys(){return this[Symbol.iterator]()}values(){return this[Symbol.iterator]()}[(BC=Symbol.iterator,OC=Symbol.toStringTag,BC)](){return new pM(this.wrap())}},FS=class{constructor(t){za(this,"tree");za(this,"path",new Array);za(this,"modificationCount",null);za(this,"splayCount");this.tree=t,this.splayCount=t.getSplayCount()}[Symbol.iterator](){return this}next(){return this.moveNext()?{done:!1,value:this.current()}:{done:!0,value:null}}current(){if(!this.path.length)return null;const t=this.path[this.path.length-1];return this.getValue(t)}rebuildPath(t){this.path.splice(0,this.path.length),this.tree.splay(t),this.path.push(this.tree.getRoot()),this.splayCount=this.tree.getSplayCount()}findLeftMostDescendent(t){for(;t!=null;)this.path.push(t),t=t.left}moveNext(){if(this.modificationCount!=this.tree.getModificationCount()){if(this.modificationCount==null){this.modificationCount=this.tree.getModificationCount();let n=this.tree.getRoot();for(;n!=null;)this.path.push(n),n=n.left;return this.path.length>0}throw"Concurrent modification during iteration."}if(!this.path.length)return!1;this.splayCount!=this.tree.getSplayCount()&&this.rebuildPath(this.path[this.path.length-1].key);let t=this.path[this.path.length-1],s=t.right;if(s!=null){for(;s!=null;)this.path.push(s),s=s.left;return!0}for(this.path.pop();this.path.length&&this.path[this.path.length-1].right===t;)t=this.path.pop();return this.path.length>0}},pM=class extends FS{getValue(t){return t.key}},gM=class extends FS{getValue(t){return[t.key,t.key]}},zS=t=>()=>t,Vb=t=>{const s=t?(n,a)=>a.minus(n).abs().isLessThanOrEqualTo(t):zS(!1);return(n,a)=>s(n,a)?0:n.comparedTo(a)};function xM(t){const s=t?(n,a,l,c,u)=>n.exponentiatedBy(2).isLessThanOrEqualTo(c.minus(a).exponentiatedBy(2).plus(u.minus(l).exponentiatedBy(2)).times(t)):zS(!1);return(n,a,l)=>{const c=n.x,u=n.y,i=l.x,_=l.y,j=u.minus(_).times(a.x.minus(i)).minus(c.minus(i).times(a.y.minus(_)));return s(j,c,u,i,_)?0:j.comparedTo(0)}}var _M=t=>t,yM=t=>{if(t){const s=new Xy(Vb(t)),n=new Xy(Vb(t)),a=(c,u)=>u.addAndReturn(c),l=c=>({x:a(c.x,s),y:a(c.y,n)});return l({x:new im(0),y:new im(0)}),l}return _M},qb=t=>({set:s=>{Gm=qb(s)},reset:()=>qb(t),compare:Vb(t),snap:yM(t),orient:xM(t)}),Gm=qb(),rx=(t,s)=>t.ll.x.isLessThanOrEqualTo(s.x)&&s.x.isLessThanOrEqualTo(t.ur.x)&&t.ll.y.isLessThanOrEqualTo(s.y)&&s.y.isLessThanOrEqualTo(t.ur.y),Gb=(t,s)=>{if(s.ur.x.isLessThan(t.ll.x)||t.ur.x.isLessThan(s.ll.x)||s.ur.y.isLessThan(t.ll.y)||t.ur.y.isLessThan(s.ll.y))return null;const n=t.ll.x.isLessThan(s.ll.x)?s.ll.x:t.ll.x,a=t.ur.x.isLessThan(s.ur.x)?t.ur.x:s.ur.x,l=t.ll.y.isLessThan(s.ll.y)?s.ll.y:t.ll.y,c=t.ur.y.isLessThan(s.ur.y)?t.ur.y:s.ur.y;return{ll:{x:n,y:l},ur:{x:a,y:c}}},vy=(t,s)=>t.x.times(s.y).minus(t.y.times(s.x)),OS=(t,s)=>t.x.times(s.x).plus(t.y.times(s.y)),Ky=t=>OS(t,t).sqrt(),vM=(t,s,n)=>{const a={x:s.x.minus(t.x),y:s.y.minus(t.y)},l={x:n.x.minus(t.x),y:n.y.minus(t.y)};return vy(l,a).div(Ky(l)).div(Ky(a))},bM=(t,s,n)=>{const a={x:s.x.minus(t.x),y:s.y.minus(t.y)},l={x:n.x.minus(t.x),y:n.y.minus(t.y)};return OS(l,a).div(Ky(l)).div(Ky(a))},pN=(t,s,n)=>s.y.isZero()?null:{x:t.x.plus(s.x.div(s.y).times(n.minus(t.y))),y:n},gN=(t,s,n)=>s.x.isZero()?null:{x:n,y:t.y.plus(s.y.div(s.x).times(n.minus(t.x)))},jM=(t,s,n,a)=>{if(s.x.isZero())return gN(n,a,t.x);if(a.x.isZero())return gN(t,s,n.x);if(s.y.isZero())return pN(n,a,t.y);if(a.y.isZero())return pN(t,s,n.y);const l=vy(s,a);if(l.isZero())return null;const c={x:n.x.minus(t.x),y:n.y.minus(t.y)},u=vy(c,s).div(l),i=vy(c,a).div(l),_=t.x.plus(i.times(s.x)),j=n.x.plus(u.times(a.x)),y=t.y.plus(i.times(s.y)),x=n.y.plus(u.times(a.y)),v=_.plus(j).div(2),C=y.plus(x).div(2);return{x:v,y:C}},am=class BS{constructor(s,n){za(this,"point");za(this,"isLeft");za(this,"segment");za(this,"otherSE");za(this,"consumedBy");s.events===void 0?s.events=[this]:s.events.push(this),this.point=s,this.isLeft=n}static compare(s,n){const a=BS.comparePoints(s.point,n.point);return a!==0?a:(s.point!==n.point&&s.link(n),s.isLeft!==n.isLeft?s.isLeft?1:-1:Jy.compare(s.segment,n.segment))}static comparePoints(s,n){return s.x.isLessThan(n.x)?-1:s.x.isGreaterThan(n.x)?1:s.y.isLessThan(n.y)?-1:s.y.isGreaterThan(n.y)?1:0}link(s){if(s.point===this.point)throw new Error("Tried to link already linked events");const n=s.point.events;for(let a=0,l=n.length;a<l;a++){const c=n[a];this.point.events.push(c),c.point=this.point}this.checkForConsuming()}checkForConsuming(){const s=this.point.events.length;for(let n=0;n<s;n++){const a=this.point.events[n];if(a.segment.consumedBy===void 0)for(let l=n+1;l<s;l++){const c=this.point.events[l];c.consumedBy===void 0&&a.otherSE.point.events===c.otherSE.point.events&&a.segment.consume(c.segment)}}}getAvailableLinkedEvents(){const s=[];for(let n=0,a=this.point.events.length;n<a;n++){const l=this.point.events[n];l!==this&&!l.segment.ringOut&&l.segment.isInResult()&&s.push(l)}return s}getLeftmostComparator(s){const n=new Map,a=l=>{const c=l.otherSE;n.set(l,{sine:vM(this.point,s.point,c.point),cosine:bM(this.point,s.point,c.point)})};return(l,c)=>{n.has(l)||a(l),n.has(c)||a(c);const{sine:u,cosine:i}=n.get(l),{sine:_,cosine:j}=n.get(c);return u.isGreaterThanOrEqualTo(0)&&_.isGreaterThanOrEqualTo(0)?i.isLessThan(j)?1:i.isGreaterThan(j)?-1:0:u.isLessThan(0)&&_.isLessThan(0)?i.isLessThan(j)?-1:i.isGreaterThan(j)?1:0:_.isLessThan(u)?-1:_.isGreaterThan(u)?1:0}}},wM=class Hb{constructor(s){za(this,"events");za(this,"poly");za(this,"_isExteriorRing");za(this,"_enclosingRing");this.events=s;for(let n=0,a=s.length;n<a;n++)s[n].segment.ringOut=this;this.poly=null}static factory(s){const n=[];for(let a=0,l=s.length;a<l;a++){const c=s[a];if(!c.isInResult()||c.ringOut)continue;let u=null,i=c.leftSE,_=c.rightSE;const j=[i],y=i.point,x=[];for(;u=i,i=_,j.push(i),i.point!==y;)for(;;){const v=i.getAvailableLinkedEvents();if(v.length===0){const I=j[0].point,z=j[j.length-1].point;throw new Error(`Unable to complete output ring starting at [${I.x}, ${I.y}]. Last matching segment found ends at [${z.x}, ${z.y}].`)}if(v.length===1){_=v[0].otherSE;break}let C=null;for(let I=0,z=x.length;I<z;I++)if(x[I].point===i.point){C=I;break}if(C!==null){const I=x.splice(C)[0],z=j.splice(I.index);z.unshift(z[0].otherSE),n.push(new Hb(z.reverse()));continue}x.push({index:j.length,point:i.point});const P=i.getLeftmostComparator(u);_=v.sort(P)[0].otherSE;break}n.push(new Hb(j))}return n}getGeom(){let s=this.events[0].point;const n=[s];for(let j=1,y=this.events.length-1;j<y;j++){const x=this.events[j].point,v=this.events[j+1].point;Gm.orient(x,s,v)!==0&&(n.push(x),s=x)}if(n.length===1)return null;const a=n[0],l=n[1];Gm.orient(a,s,l)===0&&n.shift(),n.push(n[0]);const c=this.isExteriorRing()?1:-1,u=this.isExteriorRing()?0:n.length-1,i=this.isExteriorRing()?n.length:-1,_=[];for(let j=u;j!=i;j+=c)_.push([n[j].x.toNumber(),n[j].y.toNumber()]);return _}isExteriorRing(){if(this._isExteriorRing===void 0){const s=this.enclosingRing();this._isExteriorRing=s?!s.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){var l,c;let s=this.events[0];for(let u=1,i=this.events.length;u<i;u++){const _=this.events[u];am.compare(s,_)>0&&(s=_)}let n=s.segment.prevInResult(),a=n?n.prevInResult():null;for(;;){if(!n)return null;if(!a)return n.ringOut;if(a.ringOut!==n.ringOut)return((l=a.ringOut)==null?void 0:l.enclosingRing())!==n.ringOut?n.ringOut:(c=n.ringOut)==null?void 0:c.enclosingRing();n=a.prevInResult(),a=n?n.prevInResult():null}}},xN=class{constructor(t){za(this,"exteriorRing");za(this,"interiorRings");this.exteriorRing=t,t.poly=this,this.interiorRings=[]}addInterior(t){this.interiorRings.push(t),t.poly=this}getGeom(){const t=this.exteriorRing.getGeom();if(t===null)return null;const s=[t];for(let n=0,a=this.interiorRings.length;n<a;n++){const l=this.interiorRings[n].getGeom();l!==null&&s.push(l)}return s}},NM=class{constructor(t){za(this,"rings");za(this,"polys");this.rings=t,this.polys=this._composePolys(t)}getGeom(){const t=[];for(let s=0,n=this.polys.length;s<n;s++){const a=this.polys[s].getGeom();a!==null&&t.push(a)}return t}_composePolys(t){var n;const s=[];for(let a=0,l=t.length;a<l;a++){const c=t[a];if(!c.poly)if(c.isExteriorRing())s.push(new xN(c));else{const u=c.enclosingRing();u!=null&&u.poly||s.push(new xN(u)),(n=u==null?void 0:u.poly)==null||n.addInterior(c)}}return s}},kM=class{constructor(t,s=Jy.compare){za(this,"queue");za(this,"tree");za(this,"segments");this.queue=t,this.tree=new Xy(s),this.segments=[]}process(t){const s=t.segment,n=[];if(t.consumedBy)return t.isLeft?this.queue.delete(t.otherSE):this.tree.delete(s),n;t.isLeft&&this.tree.add(s);let a=s,l=s;do a=this.tree.lastBefore(a);while(a!=null&&a.consumedBy!=null);do l=this.tree.firstAfter(l);while(l!=null&&l.consumedBy!=null);if(t.isLeft){let c=null;if(a){const i=a.getIntersection(s);if(i!==null&&(s.isAnEndpoint(i)||(c=i),!a.isAnEndpoint(i))){const _=this._splitSafely(a,i);for(let j=0,y=_.length;j<y;j++)n.push(_[j])}}let u=null;if(l){const i=l.getIntersection(s);if(i!==null&&(s.isAnEndpoint(i)||(u=i),!l.isAnEndpoint(i))){const _=this._splitSafely(l,i);for(let j=0,y=_.length;j<y;j++)n.push(_[j])}}if(c!==null||u!==null){let i=null;c===null?i=u:u===null?i=c:i=am.comparePoints(c,u)<=0?c:u,this.queue.delete(s.rightSE),n.push(s.rightSE);const _=s.split(i);for(let j=0,y=_.length;j<y;j++)n.push(_[j])}n.length>0?(this.tree.delete(s),n.push(t)):(this.segments.push(s),s.prev=a)}else{if(a&&l){const c=a.getIntersection(l);if(c!==null){if(!a.isAnEndpoint(c)){const u=this._splitSafely(a,c);for(let i=0,_=u.length;i<_;i++)n.push(u[i])}if(!l.isAnEndpoint(c)){const u=this._splitSafely(l,c);for(let i=0,_=u.length;i<_;i++)n.push(u[i])}}}this.tree.delete(s)}return n}_splitSafely(t,s){this.tree.delete(t);const n=t.rightSE;this.queue.delete(n);const a=t.split(s);return a.push(n),t.consumedBy===void 0&&this.tree.add(t),a}},CM=class{constructor(){za(this,"type");za(this,"numMultiPolys")}run(t,s,n){px.type=t;const a=[new yN(s,!0)];for(let j=0,y=n.length;j<y;j++)a.push(new yN(n[j],!1));if(px.numMultiPolys=a.length,px.type==="difference"){const j=a[0];let y=1;for(;y<a.length;)Gb(a[y].bbox,j.bbox)!==null?y++:a.splice(y,1)}if(px.type==="intersection")for(let j=0,y=a.length;j<y;j++){const x=a[j];for(let v=j+1,C=a.length;v<C;v++)if(Gb(x.bbox,a[v].bbox)===null)return[]}const l=new Xy(am.compare);for(let j=0,y=a.length;j<y;j++){const x=a[j].getSweepEvents();for(let v=0,C=x.length;v<C;v++)l.add(x[v])}const c=new kM(l);let u=null;for(l.size!=0&&(u=l.first(),l.delete(u));u;){const j=c.process(u);for(let y=0,x=j.length;y<x;y++){const v=j[y];v.consumedBy===void 0&&l.add(v)}l.size!=0?(u=l.first(),l.delete(u)):u=null}Gm.reset();const i=wM.factory(c.segments);return new NM(i).getGeom()}},px=new CM,$x=px,SM=0,Jy=class by{constructor(s,n,a,l){za(this,"id");za(this,"leftSE");za(this,"rightSE");za(this,"rings");za(this,"windings");za(this,"ringOut");za(this,"consumedBy");za(this,"prev");za(this,"_prevInResult");za(this,"_beforeState");za(this,"_afterState");za(this,"_isInResult");this.id=++SM,this.leftSE=s,s.segment=this,s.otherSE=n,this.rightSE=n,n.segment=this,n.otherSE=s,this.rings=a,this.windings=l}static compare(s,n){const a=s.leftSE.point.x,l=n.leftSE.point.x,c=s.rightSE.point.x,u=n.rightSE.point.x;if(u.isLessThan(a))return 1;if(c.isLessThan(l))return-1;const i=s.leftSE.point.y,_=n.leftSE.point.y,j=s.rightSE.point.y,y=n.rightSE.point.y;if(a.isLessThan(l)){if(_.isLessThan(i)&&_.isLessThan(j))return 1;if(_.isGreaterThan(i)&&_.isGreaterThan(j))return-1;const x=s.comparePoint(n.leftSE.point);if(x<0)return 1;if(x>0)return-1;const v=n.comparePoint(s.rightSE.point);return v!==0?v:-1}if(a.isGreaterThan(l)){if(i.isLessThan(_)&&i.isLessThan(y))return-1;if(i.isGreaterThan(_)&&i.isGreaterThan(y))return 1;const x=n.comparePoint(s.leftSE.point);if(x!==0)return x;const v=s.comparePoint(n.rightSE.point);return v<0?1:v>0?-1:1}if(i.isLessThan(_))return-1;if(i.isGreaterThan(_))return 1;if(c.isLessThan(u)){const x=n.comparePoint(s.rightSE.point);if(x!==0)return x}if(c.isGreaterThan(u)){const x=s.comparePoint(n.rightSE.point);if(x<0)return 1;if(x>0)return-1}if(!c.eq(u)){const x=j.minus(i),v=c.minus(a),C=y.minus(_),P=u.minus(l);if(x.isGreaterThan(v)&&C.isLessThan(P))return 1;if(x.isLessThan(v)&&C.isGreaterThan(P))return-1}return c.isGreaterThan(u)?1:c.isLessThan(u)||j.isLessThan(y)?-1:j.isGreaterThan(y)?1:s.id<n.id?-1:s.id>n.id?1:0}static fromRing(s,n,a){let l,c,u;const i=am.comparePoints(s,n);if(i<0)l=s,c=n,u=1;else if(i>0)l=n,c=s,u=-1;else throw new Error(`Tried to create degenerate segment at [${s.x}, ${s.y}]`);const _=new am(l,!0),j=new am(c,!1);return new by(_,j,[a],[u])}replaceRightSE(s){this.rightSE=s,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const s=this.leftSE.point.y,n=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:s.isLessThan(n)?s:n},ur:{x:this.rightSE.point.x,y:s.isGreaterThan(n)?s:n}}}vector(){return{x:this.rightSE.point.x.minus(this.leftSE.point.x),y:this.rightSE.point.y.minus(this.leftSE.point.y)}}isAnEndpoint(s){return s.x.eq(this.leftSE.point.x)&&s.y.eq(this.leftSE.point.y)||s.x.eq(this.rightSE.point.x)&&s.y.eq(this.rightSE.point.y)}comparePoint(s){return Gm.orient(this.leftSE.point,s,this.rightSE.point)}getIntersection(s){const n=this.bbox(),a=s.bbox(),l=Gb(n,a);if(l===null)return null;const c=this.leftSE.point,u=this.rightSE.point,i=s.leftSE.point,_=s.rightSE.point,j=rx(n,i)&&this.comparePoint(i)===0,y=rx(a,c)&&s.comparePoint(c)===0,x=rx(n,_)&&this.comparePoint(_)===0,v=rx(a,u)&&s.comparePoint(u)===0;if(y&&j)return v&&!x?u:!v&&x?_:null;if(y)return x&&c.x.eq(_.x)&&c.y.eq(_.y)?null:c;if(j)return v&&u.x.eq(i.x)&&u.y.eq(i.y)?null:i;if(v&&x)return null;if(v)return u;if(x)return _;const C=jM(c,this.vector(),i,s.vector());return C===null||!rx(l,C)?null:Gm.snap(C)}split(s){const n=[],a=s.events!==void 0,l=new am(s,!0),c=new am(s,!1),u=this.rightSE;this.replaceRightSE(c),n.push(c),n.push(l);const i=new by(l,u,this.rings.slice(),this.windings.slice());return am.comparePoints(i.leftSE.point,i.rightSE.point)>0&&i.swapEvents(),am.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),a&&(l.checkForConsuming(),c.checkForConsuming()),n}swapEvents(){const s=this.rightSE;this.rightSE=this.leftSE,this.leftSE=s,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let n=0,a=this.windings.length;n<a;n++)this.windings[n]*=-1}consume(s){let n=this,a=s;for(;n.consumedBy;)n=n.consumedBy;for(;a.consumedBy;)a=a.consumedBy;const l=by.compare(n,a);if(l!==0){if(l>0){const c=n;n=a,a=c}if(n.prev===a){const c=n;n=a,a=c}for(let c=0,u=a.rings.length;c<u;c++){const i=a.rings[c],_=a.windings[c],j=n.rings.indexOf(i);j===-1?(n.rings.push(i),n.windings.push(_)):n.windings[j]+=_}a.rings=null,a.windings=null,a.consumedBy=n,a.leftSE.consumedBy=n.leftSE,a.rightSE.consumedBy=n.rightSE}}prevInResult(){return this._prevInResult!==void 0?this._prevInResult:(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null,this._prevInResult)}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{const s=this.prev.consumedBy||this.prev;this._beforeState=s.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;const s=this.beforeState();this._afterState={rings:s.rings.slice(0),windings:s.windings.slice(0),multiPolys:[]};const n=this._afterState.rings,a=this._afterState.windings,l=this._afterState.multiPolys;for(let i=0,_=this.rings.length;i<_;i++){const j=this.rings[i],y=this.windings[i],x=n.indexOf(j);x===-1?(n.push(j),a.push(y)):a[x]+=y}const c=[],u=[];for(let i=0,_=n.length;i<_;i++){if(a[i]===0)continue;const j=n[i],y=j.poly;if(u.indexOf(y)===-1)if(j.isExterior)c.push(y);else{u.indexOf(y)===-1&&u.push(y);const x=c.indexOf(j.poly);x!==-1&&c.splice(x,1)}}for(let i=0,_=c.length;i<_;i++){const j=c[i].multiPoly;l.indexOf(j)===-1&&l.push(j)}return this._afterState}
707isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;const s=this.beforeState().multiPolys,n=this.afterState().multiPolys;switch($x.type){case"union":{const a=s.length===0,l=n.length===0;this._isInResult=a!==l;break}case"intersection":{let a,l;s.length<n.length?(a=s.length,l=n.length):(a=n.length,l=s.length),this._isInResult=l===$x.numMultiPolys&&a<l;break}case"xor":{const a=Math.abs(s.length-n.length);this._isInResult=a%2===1;break}case"difference":{const a=l=>l.length===1&&l[0].isSubject;this._isInResult=a(s)!==a(n);break}}return this._isInResult}},_N=class{constructor(t,s,n){za(this,"poly");za(this,"isExterior");za(this,"segments");za(this,"bbox");if(!Array.isArray(t)||t.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=s,this.isExterior=n,this.segments=[],typeof t[0][0]!="number"||typeof t[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const a=Gm.snap({x:new im(t[0][0]),y:new im(t[0][1])});this.bbox={ll:{x:a.x,y:a.y},ur:{x:a.x,y:a.y}};let l=a;for(let c=1,u=t.length;c<u;c++){if(typeof t[c][0]!="number"||typeof t[c][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const i=Gm.snap({x:new im(t[c][0]),y:new im(t[c][1])});i.x.eq(l.x)&&i.y.eq(l.y)||(this.segments.push(Jy.fromRing(l,i,this)),i.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=i.x),i.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=i.y),i.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=i.x),i.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=i.y),l=i)}(!a.x.eq(l.x)||!a.y.eq(l.y))&&this.segments.push(Jy.fromRing(l,a,this))}getSweepEvents(){const t=[];for(let s=0,n=this.segments.length;s<n;s++){const a=this.segments[s];t.push(a.leftSE),t.push(a.rightSE)}return t}},EM=class{constructor(t,s){za(this,"multiPoly");za(this,"exteriorRing");za(this,"interiorRings");za(this,"bbox");if(!Array.isArray(t))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new _N(t[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let n=1,a=t.length;n<a;n++){const l=new _N(t[n],this,!1);l.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=l.bbox.ll.x),l.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=l.bbox.ll.y),l.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=l.bbox.ur.x),l.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=l.bbox.ur.y),this.interiorRings.push(l)}this.multiPoly=s}getSweepEvents(){const t=this.exteriorRing.getSweepEvents();for(let s=0,n=this.interiorRings.length;s<n;s++){const a=this.interiorRings[s].getSweepEvents();for(let l=0,c=a.length;l<c;l++)t.push(a[l])}return t}},yN=class{constructor(t,s){za(this,"isSubject");za(this,"polys");za(this,"bbox");if(!Array.isArray(t))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{typeof t[0][0][0]=="number"&&(t=[t])}catch{}this.polys=[],this.bbox={ll:{x:new im(Number.POSITIVE_INFINITY),y:new im(Number.POSITIVE_INFINITY)},ur:{x:new im(Number.NEGATIVE_INFINITY),y:new im(Number.NEGATIVE_INFINITY)}};for(let n=0,a=t.length;n<a;n++){const l=new EM(t[n],this);l.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=l.bbox.ll.x),l.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=l.bbox.ll.y),l.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=l.bbox.ur.x),l.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=l.bbox.ur.y),this.polys.push(l)}this.isSubject=s}getSweepEvents(){const t=[];for(let s=0,n=this.polys.length;s<n;s++){const a=this.polys[s].getSweepEvents();for(let l=0,c=a.length;l<c;l++)t.push(a[l])}return t}},PM=(t,...s)=>$x.run("union",t,s),TM=(t,...s)=>$x.run("intersection",t,s),LM=(t,...s)=>$x.run("difference",t,s);Gm.set;function P0(t,s,n){if(t!==null)for(var a,l,c,u,i,_,j,y=0,x=0,v,C=t.type,P=C==="FeatureCollection",I=C==="Feature",z=P?t.features.length:1,F=0;F<z;F++){j=P?t.features[F].geometry:I?t.geometry:t,v=j?j.type==="GeometryCollection":!1,i=v?j.geometries.length:1;for(var D=0;D<i;D++){var X=0,K=0;if(u=v?j.geometries[D]:j,u!==null){_=u.coordinates;var te=u.type;switch(y=n&&(te==="Polygon"||te==="MultiPolygon")?1:0,te){case null:break;case"Point":if(s(_,x,F,X,K)===!1)return!1;x++,X++;break;case"LineString":case"MultiPoint":for(a=0;a<_.length;a++){if(s(_[a],x,F,X,K)===!1)return!1;x++,te==="MultiPoint"&&X++}te==="LineString"&&X++;break;case"Polygon":case"MultiLineString":for(a=0;a<_.length;a++){for(l=0;l<_[a].length-y;l++){if(s(_[a][l],x,F,X,K)===!1)return!1;x++}te==="MultiLineString"&&X++,te==="Polygon"&&K++}te==="Polygon"&&X++;break;case"MultiPolygon":for(a=0;a<_.length;a++){for(K=0,l=0;l<_[a].length;l++){for(c=0;c<_[a][l].length-y;c++){if(s(_[a][l][c],x,F,X,K)===!1)return!1;x++}K++}X++}break;case"GeometryCollection":for(a=0;a<u.geometries.length;a++)if(P0(u.geometries[a],s,n)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function vN(t,s){if(t.type==="Feature")s(t,0);else if(t.type==="FeatureCollection")for(var n=0;n<t.features.length&&s(t.features[n],n)!==!1;n++);}function r_(t,s){var n,a,l,c,u,i,_,j,y,x,v=0,C=t.type==="FeatureCollection",P=t.type==="Feature",I=C?t.features.length:1;for(n=0;n<I;n++){for(i=C?t.features[n].geometry:P?t.geometry:t,j=C?t.features[n].properties:P?t.properties:{},y=C?t.features[n].bbox:P?t.bbox:void 0,x=C?t.features[n].id:P?t.id:void 0,_=i?i.type==="GeometryCollection":!1,u=_?i.geometries.length:1,l=0;l<u;l++){if(c=_?i.geometries[l]:i,c===null){if(s(null,v,j,y,x)===!1)return!1;continue}switch(c.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(s(c,v,j,y,x)===!1)return!1;break}case"GeometryCollection":{for(a=0;a<c.geometries.length;a++)if(s(c.geometries[a],v,j,y,x)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}v++}}function MM(t,s,n){var a=n;return r_(t,function(l,c,u,i,_){c===0&&n===void 0?a=l:a=s(a,l,c,u,i,_)}),a}function IM(t,s){r_(t,function(n,a,l,c,u){var i=n===null?null:n.type;switch(i){case null:case"Point":case"LineString":case"Polygon":return s(qm(n,l,{bbox:c,id:u}),a,0)===!1?!1:void 0}var _;switch(i){case"MultiPoint":_="Point";break;case"MultiLineString":_="LineString";break;case"MultiPolygon":_="Polygon";break}for(var j=0;j<n.coordinates.length;j++){var y=n.coordinates[j],x={type:_,coordinates:y};if(s(qm(x,l),a,j)===!1)return!1}})}function AM(t,s){IM(t,function(n,a,l){var c=0;if(n.geometry){var u=n.geometry.type;if(!(u==="Point"||u==="MultiPoint")){var i,_=0,j=0,y=0;if(P0(n,function(x,v,C,P,I){if(i===void 0||a>_||P>j||I>y){i=x,_=a,j=P,y=I,c=0;return}var z=Yd([i,x],n.properties);if(s(z,a,l,I,c)===!1)return!1;c++,i=x})===!1)return!1}}})}function DM(t,s,n){var a=n,l=!1;return AM(t,function(c,u,i,_,j){l===!1&&n===void 0?a=c:a=s(a,c,u,i,_,j),l=!0}),a}function RM(t,s={}){const n=[];if(r_(t,l=>{n.push(l.coordinates)}
707),n.length<2)throw new Error("Must have at least 2 geometries");const a=PM(n[0],...n.slice(1));return a.length===0?null:a.length===1?Xn(a[0],s.properties):nj(a,s.properties)}var aj=RM;function FM(t){return MM(t,(s,n)=>s+zM(n),0)}function zM(t){let s=0,n;switch(t.type){case"Polygon":return bN(t.coordinates);case"MultiPolygon":for(n=0;n<t.coordinates.length;n++)s+=bN(t.coordinates[n]);return s;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function bN(t){let s=0;if(t&&t.length>0){s+=Math.abs(jN(t[0]));for(let n=1;n<t.length;n++)s-=Math.abs(jN(t[n]))}return s}var OM=Td*Td/2,Sv=Math.PI/180;function jN(t){const s=t.length-1;if(s<=2)return 0;let n=0,a=0;for(;a<s;){const l=t[a],c=t[a+1===s?0:a+1],u=t[a+2>=s?(a+2)%s:a+2],i=l[0]*Sv,_=c[1]*Sv,j=u[0]*Sv;n+=(j-i)*Math.sin(_),a++}return n*OM}var zr=FM;function wN(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if(t.type==="Feature"&&t.geometry!==null&&t.geometry.type==="Point")return[...t.geometry.coordinates];if(t.type==="Point")return[...t.coordinates]}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return[...t];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function $S(t,s,n={}){var a=wN(t),l=wN(s),c=D_(l[1]-a[1]),u=D_(l[0]-a[0]),i=D_(a[1]),_=D_(l[1]),j=Math.pow(Math.sin(c/2),2)+Math.pow(Math.sin(u/2),2)*Math.cos(i)*Math.cos(_);return DS(2*Math.atan2(Math.sqrt(j),Math.sqrt(1-j)),n.units)}var gi=$S;function BM(t,s={}){return DM(t,(n,a)=>{const l=a.geometry.coordinates;return n+$S(l[0],l[1],s)},0)}var i_=BM;function VS(t,s={}){if(t.bbox!=null&&s.recompute!==!0)return t.bbox;const n=[1/0,1/0,-1/0,-1/0];return P0(t,a=>{n[0]>a[0]&&(n[0]=a[0]),n[1]>a[1]&&(n[1]=a[1]),n[2]<a[0]&&(n[2]=a[0]),n[3]<a[1]&&(n[3]=a[1])}),n}var xp=VS;const $M=t=>{if(!t.geometry)return null;try{return t.geometry.type==="Polygon"?Xn(t.geometry.coordinates,{id:t.id}):t.geometry.type==="MultiPolygon"?nj(t.geometry.coordinates,{id:t.id}):null}catch(s){return console.warn("Failed to convert parcel geometry:",s),null}},VM=t=>{const s=t.filter(n=>n!==null);if(s.length===0)return null;if(s.length===1)return s[0];try{let n=s[0];for(let a=1;a<s.length;a++)n&&(n=aj(Un([n,s[a]])));return n}catch(n){return console.warn("Failed to merge geometries, returning first:",n),s[0]}},qM=t=>{let s="",n=t;for(;n>=0;)s=String.fromCharCode(65+n%26)+s,n=Math.floor(n/26)-1;return s},qS=()=>{const[t,s]=k.useState(!1),[n,a]=k.useState(new Array),[l,c]=k.useState([]),[u,i]=k.useState(!1),{user:_,loading:j}=HC(),y=lc(),x=k.useCallback(()=>{s(oe=>(oe&&(a([]),c([]),i(!1)),!oe))},[]),v=k.useCallback(oe=>{a(ce=>ce.some(ie=>ie.id===oe.id)?ce.filter(ie=>ie.id!==oe.id):[...ce,oe])},[]),C=k.useCallback(oe=>n.some(ce=>ce.id===oe),[n]),P=k.useCallback(oe=>{a(ce=>ce.filter(ae=>ae.id!==oe))},[]),I=k.useCallback(oe=>{const ae=zr(oe)/4046.86,ie={id:`custom-${Date.now()}`,name:`Custom Area ${l.length+1}`,geometry:oe,acres:ae,createdAt:new Date};c(de=>[...de,ie]),i(!1),Ve.success(`Added custom area (${ae.toFixed(2)} acres)`)},[l.length]),z=k.useCallback(oe=>{c(ce=>ce.filter(ae=>ae.id!==oe))},[]),F=k.useCallback((oe,ce)=>{c(ae=>ae.map(ie=>ie.id===oe?{...ie,name:ce}:ie))},[]),D=k.useCallback(()=>{i(!0)},[]),X=k.useCallback(()=>{i(!1)},[]),K=k.useCallback(()=>{a([]),c([])},[]),te=k.useMemo(()=>{const oe=[];return n.forEach((ce,ae)=>{oe.push({type:"parcel",data:ce,label:`Parcel ${qM(ae)}`})}),l.forEach((ce,ae)=>{oe.push({type:"customArea",data:ce,label:`Custom Area ${ae+1}`})}),oe},[n,l]),J=k.useMemo(()=>{const oe=n.reduce((Ke,dt)=>Ke+(dt.acres||0),0),ce=l.reduce((Ke,dt)=>Ke+dt.acres,0),ae=oe+ce,ie=n.reduce((Ke,dt)=>Ke+(dt.assessedValue||0),0),de=n.reduce((Ke,dt)=>Ke+(dt.marketValue||0),0),ge=n.map($M),We=l.map(Ke=>Ke.geometry),Ee=[...ge,...We],ve=VM(Ee);let we=ae,Ze=0,ke=0,ze=0;if(ve){const Ke=zr(ve);ae===0&&(we=Ke/4046.86);try{const dt=ve.geometry.type==="MultiPolygon"?ve.geometry.coordinates[0][0]:ve.geometry.coordinates[0],Re=Yd(dt);Ze=i_(Re,{units:"meters"})*3.28084}catch(dt){console.warn("Failed to calculate perimeter:",dt)}try{const[dt,Re,qt,ft]=xp(ve),Fe=gi(us([dt,(Re+ft)/2]),us([qt,(Re+ft)/2]),{units:"kilometers"}),fe=gi(us([(dt+qt)/2,Re]),us([(dt+qt)/2,ft]),{units:"kilometers"});ke=Fe*3280.84,ze=fe*3280.84}catch(dt){console.warn("Failed to calculate dimensions:",dt)}}return{parcelCount:n.length,customAreaCount:l.length,totalItems:n.length+l.length,totalAcres:we,totalAssessedValue:ie,totalMarketValue:de,combinedBoundary:ve,perimeterFeet:Ze,widthFeet:ke,depthFeet:ze}},[n,l]),{data:H=[],isLoading:O}=fu({queryKey:["parcel-assemblages",_==null?void 0:_.id],queryFn:async()=>{const{data:oe,error:ce}=await Fs.from("parcel_assemblages").select("*").order("created_at",{ascending:!1});if(ce)throw ce;return oe},enabled:!j&&!!_}
707),q=md({mutationFn:async oe=>{if(!_)throw new Error("Must be logged in to save assemblage");if(n.length===0&&l.length===0)throw new Error("No parcels or custom areas selected");const{data:ce,error:ae}=await Fs.from("parcel_assemblages").insert({name:oe.name,description:oe.description||null,parcel_ids:n.map(ie=>ie.id),combined_boundary:J.combinedBoundary?JSON.parse(JSON.stringify(J.combinedBoundary.geometry)):null,total_acres:J.totalAcres,total_assessed_value:J.totalAssessedValue,total_market_value:J.totalMarketValue,parcel_count:J.totalItems,created_by:_.id}).select().single();if(ae)throw ae;return ce},onSuccess:()=>{y.invalidateQueries({queryKey:["parcel-assemblages"]}),Ve.success("Assemblage saved successfully")},onError:oe=>{Ve.error("Failed to save assemblage",{description:oe.message})}}),W=md({mutationFn:async oe=>{const{error:ce}=await Fs.from("parcel_assemblages").delete().eq("id",oe);if(ce)throw ce},onSuccess:()=>{y.invalidateQueries({queryKey:["parcel-assemblages"]}),Ve.success("Assemblage deleted")},onError:oe=>{Ve.error("Failed to delete assemblage",{description:oe.message})}}),Q=k.useCallback(async oe=>{try{const{data:ce,error:ae}=await Fs.from("parcel_cache").select("*").in("id",oe.parcel_ids);if(ae)throw ae;const ie=(ce||[]).map(de=>({id:String(de.id),apn:de.apn,address:de.address||"",owner:de.owner||"",ownerAddress:de.owner_address||void 0,acres:de.acres??void 0,sqft:de.sqft??void 0,landUse:de.land_use||void 0,zoning:de.zoning||void 0,yearBuilt:de.year_built??void 0,assessedValue:de.assessed_value??void 0,marketValue:de.market_value??void 0,taxAmount:de.tax_amount??void 0,geometry:de.geometry||void 0,rawData:de.raw_data||void 0,source:de.source||"cache",clickedLat:de.lat,clickedLng:de.lng,fromCache:!0}));a(ie),c([]),s(!0),Ve.success(`Loaded ${ie.length} parcels from "${oe.name}"`)}catch(ce){Ve.error("Failed to load assemblage parcels"),console.error(ce)}},[]),Z=k.useCallback((oe,ce)=>{ce==="parcel"?P(oe):z(oe)},[P,z]);return{isAssemblageMode:t,toggleAssemblageMode:x,setIsAssemblageMode:s,isDrawingCustomArea:u,startDrawingCustomArea:D,cancelDrawingCustomArea:X,addCustomArea:I,selectedParcels:n,customAreas:l,assemblageItems:te,toggleParcelSelection:v,isParcelSelected:C,removeParcel:P,removeCustomArea:z,renameCustomArea:F,removeItem:Z,clearSelection:K,stats:J,savedAssemblages:H,isLoadingAssemblages:O,loadAssemblageParcels:Q,saveAssemblage:q.mutate,isSaving:q.isPending,deleteAssemblage:W.mutate,isDeleting:W.isPending}},GS="sitearchitect_api_usage",NN="sitearchitect_session_id",GM={maxParcelRequests:3e3,maxTileRequests:2e4,warningThreshold:.8};function HM(){let t=sessionStorage.getItem(NN);return t||(t=`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,sessionStorage.setItem(NN,t)),t}function ZM(){try{const t=sessionStorage.getItem(GS);if(t){const s=JSON.parse(t);return{parcelRequests:s.parcelRequests||0,tileRequests:s.tileRequests||0,lastReset:s.lastReset||Date.now()}}}catch{}return{parcelRequests:0,tileRequests:0,lastReset:Date.now()}}function WM(t){try{sessionStorage.setItem(GS,JSON.stringify(t))}catch{}}const HS=t=>{const s={...GM,...t},[n,a]=k.useState(ZM),[l,c]=k.useState(!1);k.useRef(HM()),k.useEffect(()=>{WM(n)},[n]);const u=Math.min(n.parcelRequests/s.maxParcelRequests,1),i=Math.min(n.tileRequests/s.maxTileRequests,1),_=n.parcelRequests>=s.maxParcelRequests,j=n.tileRequests>=s.maxTileRequests,y=u>=s.warningThreshold&&!_,x=i>=s.warningThreshold&&!j;k.useEffect(()=>{(_||j)&&c(!0)},[_,j]);const v=k.useCallback((I=1)=>l||_?(console.warn("Parcel request blocked: session limit reached"),!1):(a(z=>({...z,parcelRequests:z.parcelRequests+I})),console.log(`Parcel request tracked: ${n.parcelRequests+I}/${s.maxParcelRequests}`),!0),[l,_,n.parcelRequests,s.maxParcelRequests]),C=k.useCallback((I=1)=>l||j?(console.warn("Tile request blocked: session limit reached"),!1):(a(z=>({...z,tileRequests:z.tileRequests+I})),!0),[l,j]),P=k.useCallback((I,z,F,D)=>{a({parcelRequests:I,tileRequests:z,lastReset:Date.now()}),(F>0||D>0)&&console.log(`Synced with API quota: ${I}/${F} parcels, ${z}/${D} tiles`),c(!1)},[]);return{parcelRequests:n.parcelRequests,tileRequests:n.tileRequests,isParcelLimitReached:_,isTileLimitReached:j,isParcelWarning:y,isTileWarning:x,parcelUsagePercent:u,tileUsagePercent:i,trackParcelRequest:v,trackTileRequest:C,syncWithApiQuota:P,isLocked:l,limits:s}},kx=768,kN=1024;function o_(){const[t,s]=k.useState(void 0);return k.useEffect(()=>{const n=window.matchMedia(`(max-width: ${kx-1}px)`),a=()=>{s(window.innerWidth<kx)};return n.addEventListener("change",a),s(window.innerWidth<kx),()=>n.removeEventListener("change",a)},[]),!!t}function YM(){const[t,s]=k.useState(void 0);return k.useEffect(()=>{const n=()=>{const u=window.innerWidth;s(u>=kx&&u<kN)},a=window.matchMedia(`(min-width: ${kx}px)`),l=window.matchMedia(`(max-width: ${kN-1}px)`),c=()=>n();return a.addEventListener("change",c),l.addEventListener("change",c),n(),()=>{a.removeEventListener("change",c),l.removeEventListener("change",c)}},[]),!!t}const XM=({onSwipeRight:t,onSwipeLeft:s,edgeThreshold:n=30,minSwipeDistance:a=50})=>{const l=k.useRef(null),c=k.useRef(null),u=k.useRef(!1);k.useEffect(()=>{const i=j=>{const y=j.touches[0];l.current=y.clientX,c.current=y.clientY,u.current=y.clientX<=n},_=j=>{if(l.current===null||c.current===null)return;const y=j.changedTouches[0],x=y.clientX-l.current,v=y.clientY-c.
707current;Math.abs(x)>Math.abs(v)&&Math.abs(x)>=a&&(x>0&&u.current&&t?t():x<0&&s&&s()),l.current=null,c.current=null,u.current=!1};return document.addEventListener("touchstart",i,{passive:!0}),document.addEventListener("touchend",_,{passive:!0}),()=>{document.removeEventListener("touchstart",i),document.removeEventListener("touchend",_)}},[t,s,n,a])},KM=()=>fu({queryKey:["saved-regions"],queryFn:async()=>{const{data:t,error:s}=await Fs.from("saved_regions").select("*").order("created_at",{ascending:!1});if(s)throw s;return t}}),EH=()=>{const t=lc();return md({mutationFn:async s=>{const{data:n,error:a}=await Fs.from("saved_regions").insert({name:s.name,description:s.description,region_type:s.region_type,center_lat:s.center_lat,center_lng:s.center_lng,radius_miles:s.radius_miles,polygon_points:s.polygon_points,created_by:s.created_by}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["saved-regions"]})}})},PH=()=>{const t=lc();return md({mutationFn:async s=>{const{error:n}=await Fs.from("saved_regions").delete().eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["saved-regions"]})}})},JM=(t,s,n)=>{const l=(t.lat-s.lat)*Math.PI/180,c=(t.lng-s.lng)*Math.PI/180,u=Math.sin(l/2)*Math.sin(l/2)+Math.cos(s.lat*Math.PI/180)*Math.cos(t.lat*Math.PI/180)*Math.sin(c/2)*Math.sin(c/2);return 3959*(2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u)))<=n},QM=(t,s)=>{if(s.length<3)return!1;let n=!1;for(let a=0,l=s.length-1;a<s.length;l=a++){const c=s[a].lng,u=s[a].lat,i=s[l].lng,_=s[l].lat;u>t.lat!=_>t.lat&&t.lng<(i-c)*(t.lat-u)/(_-u)+c&&(n=!n)}return n},CN=(t,s)=>s.region_type==="circle"?s.center_lat==null||s.center_lng==null||s.radius_miles==null?!1:JM(t,{lat:s.center_lat,lng:s.center_lng},s.radius_miles):s.region_type==="polygon"?!s.polygon_points||s.polygon_points.length<3?!1:QM(t,s.polygon_points):!1,UM=()=>{const[t,s]=k.useState(!1),[n,a]=k.useState(null),[l,c]=k.useState(null),u=k.useCallback(async j=>{s(!0),c(null);try{const{data:y,error:x}=await Fs.functions.invoke("search-owner-portfolios",{body:{ownerName:j,searchMode:"cache"}});if(x)throw new Error(x.message);if(!y.success)throw new Error(y.error||"Search failed");return a(y.portfolio),y.portfolio}catch(y){const x=y instanceof Error?y.message:"Search failed";return c(x),Ve.error(x),null}finally{s(!1)}},[]),i=k.useCallback(async(j,y)=>{s(!0),c(null);try{const{data:x,error:v}=await Fs.functions.invoke("search-owner-portfolios",{body:{ownerName:j,searchMode:"deep",geoScope:y}});if(v)throw new Error(v.message);if(!x.success)throw new Error(x.error||"Search failed");a(x.portfolio);const C=x.portfolio;return C.apiCallsUsed>0&&Ve.success(`Found ${C.totalCount} properties using ${C.apiCallsUsed} API call${C.apiCallsUsed>1?"s":""}`),C}catch(x){const v=x instanceof Error?x.message:"Search failed";return c(v),Ve.error(v),null}finally{s(!1)}},[]),_=k.useCallback(()=>{a(null),c(null)},[]);return{isLoading:t,portfolio:n,error:l,searchCacheOnly:u,searchDeep:i,clearResults:_}},eI=t=>{switch(t.type){case"zip":return{min:1,max:2};case"county":return{min:1,max:5};case"state":return{min:5,max:50,warning:"State-wide searches may use significant API quota"};default:return{min:1,max:10}}},SN=t=>t?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t):"N/A",EN=(t,s=2)=>t?new Intl.NumberFormat("en-US",{maximumFractionDigits:s}).format(t):"N/A",tI=({parcel:t,onViewOnMap:s,onViewDetails:n,isCompact:a=!1})=>a?e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.address||t.apn}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.acres&&e.jsxs("span",{children:[EN(t.acres)," ac"]}),t.assessed_value&&e.jsx("span",{children:SN(t.assessed_value)})]})]}),s&&t.lat&&t.lng&&e.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:()=>s(t.lat,t.lng),children:e.jsx(ji,{className:"h-3 w-3"})})]}):e.jsx(Mo,{className:"overflow-hidden hover:shadow-md transition-shadow",children:e.jsxs(Io,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-medium leading-tight",children:t.address||"Address Unknown"}),t.land_use&&e.jsx(Mt,{variant:"secondary",className:"text-xs shrink-0",children:t.land_use})]}),e.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:["APN: ",t.apn]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[t.acres&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Fo,{className:"h-3 w-3"}),e.jsxs("span",{children:[EN(t.acres)," acres"]})]}),t.assessed_value&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Vd,{className:"h-3 w-3"}),e.jsx("span",{children:SN(t.assessed_value)})]}),t.zoning&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(uh,{className:"h-3 w-3"}),e.jsx("span",{children:t.zoning})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[s&&t.lat&&t.lng&&e.jsxs(Le,{variant:"outline",size:"sm",className:"flex-1 h-7 text-xs",onClick:()=>s(t.lat,t.lng),children:[e.jsx(ji,{className:"h-3 w-3 mr-1"}),"View on Map"]}),n&&e.jsx(Le,{variant:"outline",size:"sm",className:"flex-1 h-7 text-xs",onClick:()=>n(t),children:"Details"})]})]})});function sI(t,s={}){let n=0,a=0,l=0;return P0(t,function(c){n+=c[0],a+=c[1],l++},!0),us([n/l,a/l],s.properties)}var Yo=sI;const nI=t=>{if(!t||typeof t!="object")return null;const s=t;
707if(!s.type||!s.coordinates)return null;try{if(s.type==="Polygon")return Xn(s.coordinates);if(s.type==="MultiPolygon"){const n=s.coordinates;if(n.length>0)return Xn(n[0])}return null}catch(n){return console.error("Error converting geometry to feature:",n),null}},ZS=(t,s)=>{const n=us([t[0],t[1]]),a=us([s[0],s[1]]);return gi(n,a,{units:"kilometers"})*3280.84},aI=t=>{const s=[];for(let n=0;n<t.length-1;n++)s.push(ZS(t[n],t[n+1]));return s},rI=t=>{try{const[s,n,a,l]=xp(t);if(Math.abs((a-s)*(l-n))===0)return 0;const u=zr(t),i=(n+l)/2,_=111320*Math.cos(i*Math.PI/180),y=(a-s)*_*(l-n)*110540;return Math.min(1,u/y)}catch{return 0}},iI=t=>{const s=nI(t);if(!s)return null;try{const n=zr(s),a=n*10.7639,l=a/43560,c=t,u=c.type==="MultiPolygon"?c.coordinates[0][0]:c.coordinates[0],i=Yd(u),_=i_(i,{units:"meters"}),j=_*3.28084,[y,x,v,C]=xp(s),P=gi(us([y,(x+C)/2]),us([v,(x+C)/2]),{units:"kilometers"}),I=gi(us([(y+v)/2,x]),us([(y+v)/2,C]),{units:"kilometers"}),z=P*3280.84,F=I*3280.84,D=z>0?F/z:0,X=Yo(s),K=X.geometry.coordinates[0],te=X.geometry.coordinates[1],J=u.length-1,H=rI(s),O=H>.85&&(J===4||J===5),q=aI(u),W=q.length>0?Math.max(...q):0;return{sqft:a,acres:l,sqMeters:n,perimeterFeet:j,perimeterMeters:_,widthFeet:z,depthFeet:F,aspectRatio:D,centroidLat:te,centroidLng:K,vertexCount:J,isRectangular:O,regularityScore:H,frontageEstimateFeet:W}}catch(n){return console.error("Error calculating parcel metrics:",n),null}},oI=(t,s)=>{if(t===null||t===0)return{reportedAcres:t,calculatedAcres:s,discrepancy:null,hasSignificantDiscrepancy:!1};const n=(s-t)/t*100;return{reportedAcres:t,calculatedAcres:s,discrepancy:n,hasSignificantDiscrepancy:Math.abs(n)>10}},tm={feet:t=>`${Math.round(t).toLocaleString()} ft`,acres:t=>`${t.toFixed(2)} ac`,sqft:t=>`${Math.round(t).toLocaleString()} sqft`,ratio:t=>t.toFixed(2),percentage:t=>`${t>0?"+":""}${t.toFixed(1)}%`,score:t=>`${Math.round(t*100)}%`},lI=(t,s)=>{const n=s[0]-t[0],a=s[1]-t[1];let l=Math.atan2(a,n)*(180/Math.PI);return l>90&&(l-=180),l<-90&&(l+=180),l},cI=t=>{if(!t||typeof t!="object")return null;const s=t;if(!s.type||!s.coordinates)return null;try{let n=[];if(s.type==="Polygon")n=s.coordinates[0];else if(s.type==="MultiPolygon"){const l=s.coordinates;l.length>0&&(n=l[0][0])}if(n.length<3)return null;const a=[];for(let l=0;l<n.length-1;l++){const c=n[l],u=n[l+1],i=(c[0]+u[0])/2,_=(c[1]+u[1])/2,j=ZS(c,u);if(j<10)continue;const y=lI(c,u);a.push({midpointLat:_,midpointLng:i,lengthFeet:j,angle:y})}return a}catch(n){return console.error("Error getting parcel edge measurements:",n),null}},WS=({geometry:t,reportedAcres:s,reportedSqft:n,defaultOpen:a=!1,compact:l=!1})=>{const c=k.useMemo(()=>t?iI(t):null,[t]),u=k.useMemo(()=>c?oI(s??null,c.acres):null,[c,s]);if(!c)return null;const i=e.jsxs("div",{className:"space-y-3",children:[u&&u.discrepancy!==null&&e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg ${u.hasSignificantDiscrepancy?"bg-amber-500/10 border border-amber-500/20":"bg-emerald-500/10 border border-emerald-500/20"}`,children:[u.hasSignificantDiscrepancy?e.jsx(ho,{className:"h-4 w-4 text-amber-500"}):e.jsx(iS,{className:"h-4 w-4 text-emerald-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-medium",children:u.hasSignificantDiscrepancy?"Acreage Discrepancy Detected":"Acreage Verified"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Reported: ",tm.acres(u.reportedAcres||0)," | Calculated: ",tm.acres(u.calculatedAcres),u.discrepancy!==null&&e.jsxs("span",{className:u.hasSignificantDiscrepancy?"text-amber-600":"text-emerald-600",children:[" ","(",tm.percentage(u.discrepancy),")"]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground",children:[e.jsx(Il,{className:"h-3 w-3"}),"Calculated Area"]}),e.jsx("p",{className:"text-sm font-medium",children:tm.acres(c.acres)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:tm.sqft(c.sqft)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground",children:[e.jsx(Fo,{className:"h-3 w-3"}),"Perimeter"]}),e.jsx("p",{className:"text-sm font-medium",children:tm.feet(c.perimeterFeet)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(c.perimeterFeet/5280).toFixed(2)," mi"]})]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground",children:[e.jsx(uS,{className:"h-3 w-3"}),"Width (Est.)"]}),e.jsx("p",{className:"text-sm font-medium",children:tm.feet(c.widthFeet)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground",children:[e.jsx(e_,{className:"h-3 w-3"}),"Depth (Est.)"]}),e.jsx("p",{className:"text-sm font-medium",children:tm.feet(c.depthFeet)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground",children:[e.jsx(Fo,{className:"h-3 w-3"}),"Frontage (Est.)"]}),e.jsx("p",{className:"text-sm font-medium",children:tm.feet(c.frontageEstimateFeet)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground",children:[e.jsx(j3,{className:"h-3 w-3"}),"Shape"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Mt,{variant:c.isRectangular?"default":"secondary",className:"text-[10px]",children:c.isRectangular?"Rectangular":`${c.vertexCount} sides`}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",tm.score(c.regularityScore)," regular)"]})]})]})]}),!l&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground",children:[e.jsx(mp,{className:"h-3 w-3"}),"Centroid"]}),e.jsxs("p",{className:"text-xs font-mono text-muted-foreground",children:[c.centroidLat.toFixed(6),", ",c.centroidLng.toFixed(6)]})]})]})]});return l?i:e.jsxs(wi,{defaultOpen:a,children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full justify-between",children:[e.jsxs("span",{className:"text-xs flex items-center gap-1",children:[e.jsx(Fo,{className:"h-3 w-3"}),"Geometry Metrics (Calculated)"]}),e.jsx(Oa,{className:"h-4 w-4 transition-transform ui-expanded:rotate-180"})]})}),e.jsx(ki,{className:"pt-2",children:i})]})},jy=({onExport:t,disabled:s=!1,label:n="Export",variant:a="outline",size:l="sm",className:c})=>{const[u,i]=k.useState(!1),_=async j=>{i(!0);try{await t(j)}finally{i(!1)}};return e.jsxs(jp,{children:[e.jsx(wp,{asChild:!0,children:e.jsxs(Le,{variant:a,size:l,disabled:s||u,className:c,children:[e.jsx(l5,{className:"w-4 h-4 mr-1.5"}),n]})}),e.jsxs(Np,{align:"end",children:[e.jsx(zm,{children:"Export Format"}),e.jsx(cd,{}),e.jsxs(co,{onClick:()=>
707_("geojson"),children:[e.jsx(UC,{className:"w-4 h-4 mr-2"}),"GeoJSON (.geojson)"]}),e.jsxs(co,{onClick:()=>_("kml"),children:[e.jsx(By,{className:"w-4 h-4 mr-2"}),"KML (.kml)"]}),e.jsxs(co,{onClick:()=>_("shp"),children:[e.jsx(Fu,{className:"w-4 h-4 mr-2"}),"Shapefile (.shp)"]})]})]})};var T0={},rj={};rj.geometries={NULL:0,POINT:1,POLYLINE:3,POLYGON:5,MULTIPOINT:8,POINTZ:11,POLYLINEZ:13,POLYGONZ:15,MULTIPOINTZ:18,POINTM:21,POLYLINEM:23,POLYGONM:25,MULTIPOINTM:28,MULTIPATCH:31};var YS={},dI={C:254,L:1,D:8,N:18,M:18,F:18,B:8},L0={};L0.lpad=function(s,n,a){for(;s.length<n;)s=a+s;return s};L0.rpad=function(s,n,a){for(;s.length<n;)s=s+a;return s};L0.writeField=function(s,n,a,l){for(var c=0;c<n;c++)s.setUint8(l,a.charCodeAt(c)),l++;return l};var M0={},uI=dI,hI={string:"C",number:"N",boolean:"L",null:"C"};M0.multi=mI;M0.bytesPer=pI;M0.obj=XS;function mI(t){var s={};t.forEach(n);function n(a){fI(s,a)}return XS(s)}function fI(t,s){for(var n in s){var a=typeof s[n]<"u"&&s[n]!==null;(typeof t[n]>"u"||a)&&(t[n]=s[n])}return t}function XS(t){var s={},n=[];for(var a in t)s[a]=t[a]===null?"null":typeof t[a];for(var l in s){var c=hI[s[l]];c&&n.push({name:l,type:c,size:uI[c]})}return n}function pI(t){return t.reduce(function(s,n){return s+n.size},1)}var Zp=L0,PN=M0,gI=function(s,n){var a=n||PN.multi(s),l=32*a.length+1,c=PN.bytesPer(a),u=new ArrayBuffer(l+32+c*s.length+1),i=new Date,_=new DataView(u);_.setUint8(0,3),_.setUint8(1,i.getFullYear()-1900),_.setUint8(2,i.getMonth()+1),_.setUint8(3,i.getDate()),_.setUint32(4,s.length,!0);var j=l+32;_.setUint16(8,j,!0),_.setUint16(10,c,!0),_.setInt8(32+l-1,13),a.forEach(function(x,v){x.name.split("").slice(0,10).forEach(function(C,P){_.setInt8(32+v*32+P,C.charCodeAt(0))}),_.setInt8(32+v*32+11,x.type.charCodeAt(0)),_.setInt8(32+v*32+16,x.size),x.type=="N"&&_.setInt8(32+v*32+17,3)});var y=l+32;return s.forEach(function(x,v){_.setUint8(y,32),y++,a.forEach(function(C){var P=x[C.name];switch((P===null||typeof P>"u")&&(P=""),C.type){case"L":_.setUint8(y,P?84:70),y++;break;case"D":y=Zp.writeField(_,8,Zp.lpad(P.toString(),8," "),y);break;case"N":y=Zp.writeField(_,C.size,Zp.lpad(P.toString(),C.size," ").substr(0,18),y);break;case"C":y=Zp.writeField(_,C.size,Zp.rpad(P.toString(),C.size," "),y);break;default:throw new Error("Unknown field type")}})}),_.setUint8(y,26),_};YS.structure=gI;var KS='GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]',Dg={},l_={};l_.enlarge=function(s,n){return n[0]<s.xmin&&(s.xmin=n[0]),n[0]>s.xmax&&(s.xmax=n[0]),n[1]<s.ymin&&(s.ymin=n[1]),n[1]>s.ymax&&(s.ymax=n[1]),s};l_.enlargeExtent=function(s,n){return n.xmax>s.xmax&&(s.xmax=n.xmax),n.xmin<s.xmin&&(s.xmin=n.xmin),n.ymax>s.ymax&&(s.ymax=n.ymax),n.ymin<s.ymin&&(s.ymin=n.ymin),s};l_.blank=function(){return{xmin:Number.MAX_VALUE,ymin:Number.MAX_VALUE,xmax:-Number.MAX_VALUE,ymax:-Number.MAX_VALUE}};var TN=l_;Dg.write=function(s,n,a,l){var c=28,u=100,i=0,_=0;s.forEach(function(y,x){a.setInt32(i,x+1),a.setInt32(i+4,10),a.setInt32(i+8,1,!0),a.setFloat64(i+12,y[0],!0),a.setFloat64(i+20,y[1],!0),l.setInt32(_,u/2),l.setInt32(_+4,10),_+=8,i+=c,u+=c})};Dg.extent=function(t){return t.reduce(function(s,n){return TN.enlarge(s,n)},TN.blank())};Dg.parts=function(s,n){return s.length};Dg.shxLength=function(t){return t.length*8};Dg.shpLength=function(t){return t.length*28};var Rg={},Qy=l_,LN=rj;Rg.write=function(s,n,a,l,c){var u=0,i=0,_=100;s.forEach(j);function j(y,x){var v=I0(y),C=JS([y],c),P=v.length*16+48+(C-1)*4,I=v.reduce(function(D,X){return Qy.enlarge(D,X)},Qy.blank());l.setInt32(i,_/2),l.setInt32(i+4,P/2),i+=8,_+=P+8,a.setInt32(u,x+1),a.setInt32(u+4,P/2),a.setInt32(u+8,c,!0),a.setFloat64(u+12,I.xmin,!0),a.setFloat64(u+20,I.ymin,!0),a.setFloat64(u+28,I.xmax,!0),a.setFloat64(u+36,I.ymax,!0),a.setInt32(u+44,C,!0),a.setInt32(u+48,v.length,!0),a.setInt32(u+52,0,!0);for(var z=y.reduce(function(D,X){return Array.isArray(X[0][0])?D=D.concat(X):D.push(X),D},[]),F=1;F<C;F++)a.setInt32(u+52+F*4,z.reduce(function(D,X,K){return K<F?D+X.length:D},0),!0);v.forEach(function(X,K){a.setFloat64(u+56+K*16+(C-1)*4,X[0],!0),a.setFloat64(u+56+K*16+(C-1)*4+8,X[1],!0)}),u+=P+8}};Rg.shpLength=function(t){return t.length*56+I0(t).length*16};Rg.shxLength=function(t){return t.length*8};Rg.extent=function(t){return I0(t).reduce(function(s,n){return Qy.enlarge(s,n)},Qy.blank())};function JS(t,s){var n=1;return(s===LN.geometries.POLYGON||s===LN.geometries.POLYLINE)&&(n=t.reduce(function(a,l){return a+=l.length,Array.isArray(l[0][0][0])&&(a+=l.reduce(function(c,u){return c+u.length-1},0)),a},0)),n}Rg.parts=JS;function I0(t,s){return s===void 0&&(s=[]),typeof t[0][0]=="object"?t.reduce(function(n,a){return n.concat(I0(a))},s):t}var xI=rj,_I=YS,yI=KS,vI=Dg,MN=Rg,bI={1:vI,5:MN,3:MN},QS=jI;function jI(t,s,n,a){var l=xI.geometries[s],c=bI[l],u=c.parts(n,l),i=100+(u-n.length)*4+c.shpLength(n),_=100+c.shxLength(n),j=new ArrayBuffer(i),y=new DataView(j),x=new ArrayBuffer(_),v=new DataView(x),C=c.extent(n);IN(y,l),IN(v,l),AN(C,y),AN(C,v),c.write(n,C,new DataView(j,100),new DataView(x,100),l),y.setInt32(24,i/2),v.setInt32(24,50+n.length*4);var P=_I.structure(t);a(null,{shp:y,shx:v,dbf:P,prj:yI})}function IN(t,s){t.setInt32(0,9994),t.setInt32(28,1e3,!0),t.setInt32(32,s,!0)}function AN(t,s){s.setFloat64(36,t.xmin,!0),s.setFloat64(44,t.ymin,!0),s.setFloat64(52,t.xmax,!0),s.setFloat64(60,t.ymax,!0)}var Fg={};Fg.point=c_("Point","POINT");Fg.line=c_("LineString","POLYLINE");Fg.multiline=c_("MultiLineString","POLYLINE");Fg.polygon=c_("Polygon","POLYGON");Fg.multipolygon=c_("MultiPolygon","POLYGON");function c_(t,s){return function(n){var a=n.features.filter(NI(t));return{geometries:s==="POLYLINE"?[a.map(DN)]:a.map(DN),properties:a.map(wI),type:s}}}function DN(t){return t.geometry.coordinates}function wI(t){return t.properties}function NI(t){return Array.isArray(t)?function(s){return t.includes(s.geometry.type)}:function(s){return s.geometry.type===t}}var kI=QS,ix=Fg,CI=KS,SI=c5,US=function(t,s,n=!1){let a=new SI,l=a;s&&s.folder&&(l=a.folder(s.folder));var c=s&&s.prj?s.prj:CI;
707[ix.point(t),ix.line(t),ix.polygon(t),ix.multipolygon(t),ix.multiline(t)].forEach(function(i){i.geometries.length&&i.geometries[0].length&&kI(i.properties,i.type,i.geometries,function(_,j){var y=s&&s.types&&s.types[i.type.toLowerCase()]?s.types[i.type.toLowerCase()]:i.type;l.file(y+".shp",j.shp.buffer,{binary:!0}),l.file(y+".shx",j.shx.buffer,{binary:!0}),l.file(y+".dbf",j.dbf.buffer,{binary:!0}),l.file(y+".prj",c)})});var u={};return!s||!s.outputType?u.type="base64":u.type=s.outputType,!s||!s.compression?u.compression="DEFLATE":u.compression=s.compression,n?a.generateNodeStream({...u,streamFiles:!0}):a.generateAsync(u)},eE={exports:{}};(function(t,s){(function(n,a){a()})(Fm,function(){function n(j,y){return typeof y>"u"?y={autoBom:!1}:typeof y!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),y={autoBom:!y}),y.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(j.type)?new Blob(["\uFEFF",j],{type:j.type}):j}function a(j,y,x){var v=new XMLHttpRequest;v.open("GET",j),v.responseType="blob",v.onload=function(){_(v.response,y,x)},v.onerror=function(){console.error("could not download file")},v.send()}function l(j){var y=new XMLHttpRequest;y.open("HEAD",j,!1);try{y.send()}catch{}return 200<=y.status&&299>=y.status}function c(j){try{j.dispatchEvent(new MouseEvent("click"))}catch{var y=document.createEvent("MouseEvents");
707y.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),j.dispatchEvent(y)}}var u=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof Fm=="object"&&Fm.global===Fm?Fm:void 0,i=u.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),_=u.saveAs||(typeof window!="object"||window!==u?function(){}:"download"in HTMLAnchorElement.prototype&&!i?function(j,y,x){var v=u.URL||u.webkitURL,C=document.createElement("a");y=y||j.name||"download",C.download=y,C.rel="noopener",typeof j=="string"?(C.href=j,C.origin===location.origin?c(C):l(C.href)?a(j,y,x):c(C,C.target="_blank")):(C.href=v.createObjectURL(j),setTimeout(function(){v.revokeObjectURL(C.href)},4e4),setTimeout(function(){c(C)},0))}:"msSaveOrOpenBlob"in navigator?function(j,y,x){if(y=y||j.name||"download",typeof j!="string")navigator.msSaveOrOpenBlob(n(j,x),y);else if(l(j))a(j,y,x);else{var v=document.createElement("a");v.href=j,v.target="_blank",setTimeout(function(){c(v)})}}:function(j,y,x,v){if(v=v||open("","_blank"),v&&(v.document.title=v.document.body.innerText="downloading..."),typeof j=="string")return a(j,y,x);var C=j.type==="application/octet-stream",P=/constructor/i.test(u.HTMLElement)||u.safari,I=/CriOS\/[\d]+/.test(navigator.userAgent);if((I||C&&P||i)&&typeof FileReader<"u"){var z=new FileReader;z.onloadend=function(){var X=z.result;X=I?X:X.replace(/^data:[^;]*;/,"data:attachment/file;"),v?v.location.href=X:location=X,v=null},z.readAsDataURL(j)}else{var F=u.URL||u.webkitURL,D=F.createObjectURL(j);v?v.location=D:location.href=D,v=null,setTimeout(function(){F.revokeObjectURL(D)},4e4)}});u.saveAs=_.saveAs=_,t.exports=_})})(eE);var EI=eE.exports,PI=US,TI=EI.saveAs,LI=function(t,s){let n="download";s&&(s.filename||s.folder)&&(n=s.filename||s.folder),PI(t,s).then(function(a){TI(a,n+".zip")})};T0.download=LI;T0.write=QS;T0.zip=US;const ij=(t,s={})=>{if(!t)return null;if(t.type==="Feature"){const n=t;return{type:"Feature",properties:{...n.properties,...s},geometry:n.geometry}}return t.type==="Polygon"||t.type==="MultiPolygon"?{type:"Feature",properties:s,geometry:t}:null},oj=t=>({type:"FeatureCollection",features:t}),lj=(t,s,n)=>{let a;t instanceof Blob?a=t:t instanceof ArrayBuffer?a=new Blob([t],{type:n}):a=new Blob([t],{type:n});const l=URL.createObjectURL(a),c=document.createElement("a");c.href=l,c.download=s,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(l)},MI=(t,s)=>{const n=oj(t),a=JSON.stringify(n,null,2);lj(a,`${s}.geojson`,"application/geo+json")},z_=t=>t?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"):"",II=t=>t.map(s=>`${s[0]},${s[1]},${s[2]||0}`).join(" "),O_=t=>`<LinearRing><coordinates>${II(t)}</coordinates></LinearRing>`,AI=t=>{const s=t.properties||{},n=s.name||s.apn||"Feature",a=s.description||"";let l="";if(t.geometry.type==="Polygon"){const u=t.geometry.coordinates,i=`<outerBoundaryIs>${O_(u[0])}</outerBoundaryIs>`,_=u.slice(1).map(j=>`<innerBoundaryIs>${O_(j)}</innerBoundaryIs>`).join("");l=`<Polygon>${i}${_}</Polygon>`}else t.geometry.type==="MultiPolygon"&&(l=`<MultiGeometry>${t.geometry.coordinates.map(i=>{const _=`<outerBoundaryIs>${O_(i[0])}</outerBoundaryIs>`,j=i.slice(1).map(y=>`<innerBoundaryIs>${O_(y)}</innerBoundaryIs>`).join("");return`<Polygon>${_}${j}</Polygon>`}).join("")}</MultiGeometry>`);const c=Object.entries(s).filter(([u])=>u!=="name"&&u!=="description").map(([u,i])=>`<Data name="${z_(u)}"><value>${z_(String(i??""))}</value></Data>`).join("");return`<Placemark>
708    <name>${z_(String(n))}</name>
709    <description>${z_(String(a))}</description>
710    ${c?`<ExtendedData>${c}</ExtendedData>`:""}
711    ${l}
712  </Placemark>`},DI=t=>`<?xml version="1.0" encoding="UTF-8"?>
713<kml xmlns="http://www.opengis.net/kml/2.2">
714  <Document>
715    <name>Export</name>
716    <description>Exported from Site Architect</description>
717    ${t.features.map(AI).join(`
718`)}
719  </Document>
720</kml>`,RI=(t,s)=>{const n=oj(t),a=DI(n);lj(a,`${s}.kml`,"application/vnd.google-earth.kml+xml")},FI=async(t,s)=>{const n=oj(t);try{const a={folder:s,filename:s,outputType:"blob",compression:"DEFLATE"},l=await T0.zip(n,a);lj(l,`${s}.zip`,"application/zip")}catch(a){throw console.error("Shapefile export error:",a),new Error("Failed to generate shapefile")}},cj=async({filename:t,format:s,features:n})=>{if(!n||n.length===0){Ve.error("No geometry to export");return}const a=t.replace(/[^a-zA-Z0-9-_]/g,"_");try{switch(s){case"geojson":MI(n,a),Ve.success(`Exported ${n.length} feature(s) to GeoJSON`);break;case"kml":RI(n,a),Ve.success(`Exported ${n.length} feature(s) to KML`);break;case"shp":await FI(n,a),Ve.success(`Exported ${n.length} feature(s) to Shapefile`);break;default:Ve.error("Unsupported export format")}}catch(l){console.error("Export error:",l),Ve.error("Failed to export geometry")}},tE=async(t,s,n,a={})=>
720{if(!t){Ve.error("No parcel geometry available to export");return}const l=ij(t,{apn:s,...a});if(!l){Ve.error("Invalid geometry format");return}await cj({filename:`parcel_${s}`,format:n,features:[l]})},zI=async(t,s,n="parcels")=>{const a=t.filter(l=>l.geometry).map(l=>ij(l.geometry,{apn:l.apn,address:l.address,owner:l.owner,acres:l.acres,marketValue:l.marketValue})).filter(l=>l!==null);if(a.length===0){Ve.error("No valid geometries to export");return}await cj({filename:n,format:s,features:a})},OI=async(t,s,n)=>{if(!t){Ve.error("No assemblage boundary available to export");return}const a=ij(t,{name:s});if(!a){Ve.error("Invalid geometry format");return}await cj({filename:`assemblage_${s.replace(/\s+/g,"_")}`,format:n,features:[a]})},BI=[{code:"AL",name:"Alabama"},{code:"AK",name:"Alaska"},{code:"AZ",name:"Arizona"},{code:"AR",name:"Arkansas"},{code:"CA",name:"California"},{code:"CO",name:"Colorado"},{code:"CT",name:"Connecticut"},{code:"DE",name:"Delaware"},{code:"FL",name:"Florida"},{code:"GA",name:"Georgia"},{code:"HI",name:"Hawaii"},{code:"ID",name:"Idaho"},{code:"IL",name:"Illinois"},{code:"IN",name:"Indiana"},{code:"IA",name:"Iowa"},{code:"KS",name:"Kansas"},{code:"KY",name:"Kentucky"},{code:"LA",name:"Louisiana"},{code:"ME",name:"Maine"},{code:"MD",name:"Maryland"},{code:"MA",name:"Massachusetts"},{code:"MI",name:"Michigan"},{code:"MN",name:"Minnesota"},{code:"MS",name:"Mississippi"},{code:"MO",name:"Missouri"},{code:"MT",name:"Montana"},{code:"NE",name:"Nebraska"},{code:"NV",name:"Nevada"},{code:"NH",name:"New Hampshire"},{code:"NJ",name:"New Jersey"},{code:"NM",name:"New Mexico"},{code:"NY",name:"New York"},{code:"NC",name:"North Carolina"},{code:"ND",name:"North Dakota"},{code:"OH",name:"Ohio"},{code:"OK",name:"Oklahoma"},{code:"OR",name:"Oregon"},{code:"PA",name:"Pennsylvania"},{code:"RI",name:"Rhode Island"},{code:"SC",name:"South Carolina"},{code:"SD",name:"South Dakota"},{code:"TN",name:"Tennessee"},{code:"TX",name:"Texas"},{code:"UT",name:"Utah"},{code:"VT",name:"Vermont"},{code:"VA",name:"Virginia"},{code:"WA",name:"Washington"},{code:"WV",name:"West Virginia"},{code:"WI",name:"Wisconsin"},{code:"WY",name:"Wyoming"}],sm=t=>t==null?"—":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),B_=(t,s=2)=>t==null?"—":new Intl.NumberFormat("en-US",{maximumFractionDigits:s}).format(t),RN=t=>t==null?"—":t.toFixed(6),$I=t=>{if(!t)return"—";try{const s=new Date(t);return isNaN(s.getTime())?"—":new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric"}).format(s)}catch{return"—"}},ql=({label:t,value:s,icon:n})=>e.jsxs("div",{className:"flex items-start justify-between py-2 border-b border-border/50 last:border-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[n&&e.jsx(n,{className:"h-4 w-4"}),e.jsx("span",{children:t})]}),e.jsx("span",{className:"text-sm font-medium text-right max-w-[60%]",children:s||"—"})]});function VI({parcel:t,isLoading:s,isAdmin:n,onClose:a,onAddAsDevelopment:l,onAddAsExistingProduct:c,onCopyBoundaryToDevelopment:u,onCopyBoundaryToExistingProduct:i,onCopyToDrawings:_,onCreateSiteLayout:j,onViewOnMap:y,onSelectDevelopment:x,onSelectExistingProduct:v,onRefreshFromAPI:C,developments:P=[],existingProducts:I=[],isParcelsLayerVisible:z=!0,onToggleParcelsLayer:F}){const[D,X]=k.useState("details"),[K,te]=k.useState(null),[J,H]=k.useState(!1),[O,q]=k.useState(""),[W,Q]=k.useState("development"),[Z,oe]=k.useState(!1),[ce,ae]=k.useState(!1),[ie,de]=k.useState("development"),[ge,We]=k.useState(""),[Ee,ve]=k.useState(!1),[we,Ze]=k.useState(null),[ke,ze]=k.useState(null),[Ke,dt]=k.useState(!1),[Re,qt]=k.useState(null),[ft,Fe]=k.useState(null),[fe,Qe]=k.useState(!1),[ht,_t]=k.useState(null),[He,as]=k.useState(null),[vt,Xe]=k.useState(null),[Ce,Be]=k.useState(""),[Dt,Rt]=k.useState(!1),[zt,rs]=k.useState({type:"state",state:"PA"}),{isLoading:_s,portfolio:vs,error:$t,searchCacheOnly:Ns,searchDeep:Ts,clearResults:bs}=UM(),en=o_(),Jt=k.useRef(null),Vs=k.useRef(null),ps=k.useCallback(je=>{Jt.current=je.touches[0].clientY},[]),nt=k.useCallback(je=>{if(Jt.current===null||!en)return;je.changedTouches[0].clientY-Jt.current>80&&a&&a(),Jt.current=null},[en,a]);k.useEffect(()=>{const je=Ge=>{Ge.key==="Escape"&&a&&(Ge.preventDefault(),a())};return window.addEventListener("keydown",je),()=>window.removeEventListener("keydown",je)},[a]),k.useEffect(()=>{if(!we){as(null),Xe(null);return}const je=P.find(De=>De.parcel_id===we)||null,Ge=I.find(De=>De.parcel_id===we)||null;as(je),Xe(Ge)},[we,P,I]),k.useEffect(()=>{t&&((async()=>
720{if(!(t!=null&&t.owner)){te(null);return}try{const{count:Ge}=await Fs.from("parcel_cache").select("*",{count:"exact",head:!0}).ilike("owner_normalized",`%${t.owner.toLowerCase().replace(/[^a-z0-9]/g,"")}%`);te(Ge?Ge-1:0)}catch(Ge){console.error("Failed to fetch owner count:",Ge)}})(),Be(t.owner||""))},[t==null?void 0:t.owner]),k.useEffect(()=>{(async()=>{var Ge,De,bt,Ct,pe,wt;if(!(t!=null&&t.clickedLat)||!(t!=null&&t.clickedLng)){ze(null),Fe(null);return}dt(!0),qt(null);try{const Zt=await Fs.functions.invoke("street-view-image",{body:{lat:t.clickedLat,lng:t.clickedLng,size:"600x300",type:"streetview"}});if(Zt.error)throw new Error(Zt.error.message);(Ge=Zt.data)!=null&&Ge.success&&((De=Zt.data)!=null&&De.imageUrl)?ze(Zt.data.imageUrl):qt(((bt=Zt.data)==null?void 0:bt.error)||"Street View not available")}catch(Zt){console.error("Failed to fetch Street View:",Zt),qt("Failed to load Street View")}finally{dt(!1)}Qe(!0),_t(null);try{const Zt=await Fs.functions.invoke("street-view-image",{body:{lat:t.clickedLat,lng:t.clickedLng,size:"600x300",type:"satellite"}});if(Zt.error)throw new Error(Zt.error.message);(Ct=Zt.data)!=null&&Ct.success&&((pe=Zt.data)!=null&&pe.imageUrl)?Fe(Zt.data.imageUrl):_t(((wt=Zt.data)==null?void 0:wt.error)||"Satellite imagery not available")}catch(Zt){console.error("Failed to fetch Satellite:",Zt),_t("Failed to load satellite imagery")}finally{Qe(!1)}})()},[t==null?void 0:t.clickedLat,t==null?void 0:t.clickedLng]),k.useEffect(()=>{(async()=>{if(!(t!=null&&t.apn)){Ze(null);return}try{const{data:Ge}=await Fs.from("parcel_cache").select("id").eq("apn",t.apn).maybeSingle();Ze((Ge==null?void 0:Ge.id)||null)}catch(Ge){console.error("Failed to fetch parcel cache ID:",Ge),Ze(null)}})()},[t==null?void 0:t.apn]),k.useEffect(()=>{X("details"),bs(),Rt(!1),ae(!1),We("")},[t==null?void 0:t.apn]);const ts=je=>{if(je.preventDefault(),je.stopPropagation(),t!=null&&t.clickedLat&&(t!=null&&t.clickedLng)){const Ge=`https://www.google.com/maps/@${t.clickedLat},${t.clickedLng},3a,75y,0h,90t/data=!3m6!1e1!3m4!1s!2e0!7i16384!8i8192`;window.open(Ge,"_blank","noopener,noreferrer")}},ds=je=>{if(je.preventDefault(),je.stopPropagation(),t!=null&&t.clickedLat&&(t!=null&&t.clickedLng)){const Ge=`https://www.google.com/maps/@${t.clickedLat},${t.clickedLng},200m/data=!3m1!1e3`;window.open(Ge,"_blank","noopener,noreferrer")}},Is=(je,Ge)=>{navigator.clipboard.writeText(je),Ve.success(`${Ge} copied to clipboard`)},tn=async()=>{if(!Ce.trim()){Ve.error("Please enter an owner name");return}await Ns(Ce.trim())},wn=async()=>{if(!Ce.trim()){Ve.error("Please enter an owner name");return}await Ts(Ce.trim(),zt)},Gs=async()=>{if(!ge||!t){Ve.error("Please select a project to link");return}ve(!0);try{let je=we;if(!je&&t.apn&&t.clickedLat&&t.clickedLng){const{data:Ge,error:De}=await Fs.from("parcel_cache").insert({apn:t.apn,address:t.address||null,owner:t.owner||null,owner_address:t.ownerAddress||null,acres:t.acres||null,sqft:t.sqft||null,land_use:t.landUse||null,zoning:t.zoning||null,year_built:t.yearBuilt||null,assessed_value:t.assessedValue||null,market_value:t.marketValue||null,tax_amount:t.taxAmount||null,geometry:t.geometry||null,raw_data:t.rawData||null,lat:t.clickedLat,lng:t.clickedLng,source:t.source||"manual"}).select("id").single();if(De)if(De.code==="23505"){const{data:bt}=await Fs.from("parcel_cache").select("id").eq("apn",t.apn).single();je=(bt==null?void 0:bt.id)||null}else throw De;else je=(Ge==null?void 0:Ge.id)||null;Ze(je)}if(!je)throw new Error("Could not create or find parcel in cache");if(ie==="development"){const{error:Ge}=await Fs.from("developments").update({parcel_id:je}).eq("id",ge);if(Ge)throw Ge;const De=P.find(bt=>bt.id===ge);Ve.success(`Parcel linked to ${(De==null?void 0:De.name)||"development"}`)}else{const{error:Ge}=await Fs.from("existing_products").update({parcel_id:je}).eq("id",ge);if(Ge)throw Ge;const De=I.find(bt=>bt.id===ge);Ve.success(`Parcel linked to ${(De==null?void 0:De.name)||"existing site"}`)}ae(!1),We("")}catch(je){console.error("Failed to link parcel:",je),Ve.error("Failed to link parcel to project")}finally{ve(!1)}},Ue=async()=>
720{if(n)try{if(He){const{error:je}=await Fs.from("developments").update({parcel_id:null}).eq("id",He.id);if(je)throw je;Ve.success("Parcel unlinked from development")}else if(vt){const{error:je}=await Fs.from("existing_products").update({parcel_id:null}).eq("id",vt.id);if(je)throw je;Ve.success("Parcel unlinked from existing site")}}catch(je){console.error("Failed to unlink parcel:",je),Ve.error("Failed to unlink parcel")}},Pe=eI(zt);return!t&&!s?null:e.jsxs("div",{ref:Vs,className:"h-full flex flex-col bg-background",onTouchStart:ps,onTouchEnd:nt,children:[en&&e.jsx("div",{className:"flex justify-center py-2 bg-muted/30 border-b cursor-grab active:cursor-grabbing",children:e.jsx("div",{className:"w-12 h-1.5 rounded-full bg-muted-foreground/30"})}),e.jsxs("div",{className:"px-4 py-3 border-b bg-muted/30 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-lg font-semibold truncate",children:s?e.jsx(du,{className:"h-5 w-32"}):"Parcel Profile"}),(t==null?void 0:t.apn)&&e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs("code",{className:"text-xs text-muted-foreground bg-muted px-2 py-0.5 rounded truncate",children:["APN: ",t.apn]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0",onClick:()=>Is(t.apn,"APN"),children:e.jsx(hp,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[C&&t&&e.jsx(Le,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:async()=>{oe(!0);try{await C(),Ve.success("Parcel data refreshed from API")}catch{Ve.error("Failed to refresh parcel data")}finally{oe(!1)}},disabled:Z||s,title:"Refresh data from API",children:e.jsx(N0,{className:fs("h-4 w-4",Z&&"animate-spin")})}),(t==null?void 0:t.fromCache)!==void 0&&e.jsx(Mt,{variant:t.fromCache?"secondary":"outline",className:fs("text-[10px] px-1.5 py-0.5",t.fromCache?"bg-green-100 text-green-700 border-green-200":"bg-amber-100 text-amber-700 border-amber-200"),children:t.fromCache?"Cache":"API"}),(t==null?void 0:t.source)&&e.jsx(Mt,{variant:"secondary",className:"text-xs",children:t.source}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:a,children:e.jsx(ja,{className:"h-4 w-4"})})]})]}),!z&&(t==null?void 0:t.geometry)&&e.jsxs("div",{className:"mx-3 mt-3 p-3 bg-amber-50 dark:bg-amber-950/50 border border-amber-200 dark:border-amber-800 rounded-lg flex items-center gap-3",children:[e.jsx(Da,{className:"h-5 w-5 text-amber-600 dark:text-amber-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Parcel outline hidden"}),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:"Turn on the Parcels layer to see the boundary on the map"})]}),F&&e.jsx(Le,{size:"sm",variant:"outline",className:"shrink-0 border-amber-300 dark:border-amber-700 hover:bg-amber-100 dark:hover:bg-amber-900",onClick:F,children:"Show Parcels"})]}),s?e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(du,{className:"h-8 w-full"}),e.jsx(du,{className:"h-32 w-full"}),e.jsx(du,{className:"h-32 w-full"})]}):t?e.jsxs(Zm,{value:D,onValueChange:X,className:"flex flex-col flex-1 overflow-hidden",children:[e.jsxs(mm,{className:"grid w-full grid-cols-3 rounded-none border-b bg-transparent h-auto p-0 shrink-0",children:[e.jsx(Bi,{value:"details",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent py-2 text-xs",children:"Details"}),e.jsx(Bi,{value:"portfolio",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent py-2 text-xs",children:"Portfolio"}),e.jsx(Bi,{value:"raw",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent py-2 text-xs",children:"Raw Data"})]}),e.jsxs(Xc,{className:"flex-1",children:[e.jsxs($i,{value:"details",className:"p-3 space-y-3 m-0",children:[(He||vt)&&e.jsxs(Mo,{className:"border-primary/50 bg-primary/5",children:[e.jsx(vc,{className:"pb-2",children:e.jsxs(bc,{className:"text-sm flex items-center gap-2",children:[e.jsx(Cf,{className:"h-4 w-4 text-primary"}),"Linked Project"]})}),e.jsxs(Io,{children:[He&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:x?e.jsxs("button",{type:"button",className:"text-left",onClick:()=>{x(He),a()},children:[e.jsx("p",{className:"font-medium text-sm hover:underline underline-offset-2",children:He.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Development"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-sm",children:He.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Development"})]})}),e.jsx(Mt,{variant:"outline",className:"text-xs",children:He.status})]}),e.jsxs("div",{className:"space-y-2",children:[x&&e.jsx(Le,{size:"sm",variant:"outline",className:"w-full",onClick:()=>{x(He),a()},children:"View Project Details"}),n&&e.jsx(Le,{size:"sm",variant:"destructive",className:"w-full",onClick:Ue,children:"Unlink Parcel"})]})]}),vt&&!He&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:v?e.jsxs("button",{type:"button",className:"text-left",onClick:()=>{v(vt),a()},children:[e.jsx("p",{className:"font-medium text-sm hover:underline underline-offset-2",children:vt.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Existing Site"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-sm",children:vt.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Existing Site"})]})}),e.jsx(Mt,{variant:"outline",className:"text-xs",children:vt.status})]}),e.jsxs("div",{className:"space-y-2",children:[v&&e.jsx(Le,{size:"sm",variant:"outline",className:"w-full",onClick:()=>{v(vt),a()},children:"View Project Details"}),n&&e.jsx(Le,{size:"sm",variant:"destructive",className:"w-full",onClick:Ue,children:"Unlink Parcel"})]})]})]})]}),e.jsxs(Mo,{children:[e.jsx(vc,{className:"pb-2",children:e.jsxs(bc,{className:"text-sm flex items-center gap-2",children:[e.jsx(Da,{className:"h-4 w-4 text-primary"}),"Satellite View"]})}),e.jsx(Io,{className:"p-3 pt-0",children:fe?e.jsx("div",{className:"flex items-center justify-center h-32 bg-muted/30 rounded-lg",children:e.jsx(Va,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):ht?e.jsx("div",{className:"flex items-center justify-center h-32 bg-muted/30 rounded-lg",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center px-2",children:ht})}):ft?e.jsxs("div",{className:"space-y-1",children:[e.jsx("button",{onClick:ds,className:"block w-full rounded-lg overflow-hidden border hover:border-primary/50 transition-colors cursor-pointer",children:e.jsx("img",{src:ft,alt:"Satellite View",className:"w-full h-32 object-cover"})}),e.jsxs("p",{className:"text-[10px] text-muted-foreground text-center flex items-center justify-center gap-1",children:[e.jsx(Rx,{className:"h-3 w-3"}),"Click to open in Google Earth"]})]}):e.jsx("div",{className:"flex items-center justify-center h-32 bg-muted/30 rounded-lg",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"Not available"})})})]}),e.jsxs(Mo,{children:[e.jsx(vc,{className:"pb-2",children:e.jsxs(bc,{className:"text-sm flex items-center gap-2",children:[e.jsx(k0,{className:"h-4 w-4 text-primary"}),"Street View"]})}),e.jsx(Io,{className:"p-3 pt-0",children:Ke?e.jsx("div",{className:"flex items-center justify-center h-32 bg-muted/30 rounded-lg",children:e.jsx(Va,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):Re?e.jsx("div",{className:"flex items-center justify-center h-32 bg-muted/30 rounded-lg",children:e.jsx("p",{className:"text-xs text-muted-foreground text-center px-2",children:Re})}):ke?e.jsxs("div",{className:"space-y-1",children:[e.jsx("button",{onClick:ts,className:"block w-full rounded-lg overflow-hidden border hover:border-primary/50 transition-colors cursor-pointer",children:e.jsx("img",{src:ke,alt:"Street View",className:"w-full h-32 object-cover"})}),e.jsxs("p",{className:"text-[10px] text-muted-foreground text-center flex items-center justify-center gap-1",children:[e.jsx(Rx,{className:"h-3 w-3"}),"Click to open in Street View"]})]}):e.jsx("div",{className:"flex items-center justify-center h-32 bg-muted/30 rounded-lg",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"Street View not available at this location"})})})]}),t.geometry&&e.jsxs(Mo,{children:[e.jsx(vc,{className:"pb-2",children:e.jsxs(bc,{className:"text-sm flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Da,{className:"h-4 w-4 text-primary"}),"Parcel Boundary"]}),e.jsx(jy,{label:"Export",size:"sm",variant:"outline",onExport:je=>tE(t.geometry,t.apn||"parcel",je,{address:t.address,owner:t.owner,acres:t.acres,marketValue:t.marketValue,zoning:t.zoning})})]})}),e.jsxs(Io,{className:"p-3 pt-0",children:[e.jsxs("div",{className:"mb-3 p-2 bg-muted/30 rounded-lg border",children:[e.jsx("svg",{viewBox:"0 0 200 150",className:"w-full h-32",preserveAspectRatio:"xMidYMid meet",children:(()=>{var Hs,xt,os,Ls,Es;let je=[];if(((Hs=t.geometry)==null?void 0:Hs.type)==="Polygon"&&((xt=t.geometry.coordinates)!=null&&xt[0])?je=t.geometry.coordinates[0]:((os=t.geometry)==null?void 0:os.type)==="MultiPolygon"&&((Es=(Ls=t.geometry.coordinates)==null?void 0:Ls[0])!=null&&Es[0])&&(je=t.geometry.coordinates[0][0]),je.length<3)return e.jsx("text",{x:"100",y:"75",textAnchor:"middle",className:"fill-muted-foreground text-xs",children:"Invalid geometry"});const Ge=je.map(Qs=>Qs[0]),De=je.map(Qs=>Qs[1]),bt=Math.min(...Ge),Ct=Math.max(...Ge),pe=Math.min(...De),wt=Math.max(...De),Zt=15,ys=200-Zt*2,es=150-Zt*2,is=ys/(Ct-bt||1),Ws=es/(wt-pe||1),an=Math.min(is,Ws),ya=je.map(Qs=>{const Pn=Zt+(Qs[0]-bt)*an,Ks=Zt+(wt-Qs[1])*an;return`${Pn},${Ks}`}).join(" ");return e.jsxs(e.Fragment,{children:[e.jsx("polygon",{points:ya,className:"fill-primary/20 stroke-primary",strokeWidth:"2",strokeLinejoin:"round"}),e.jsx("circle",{cx:Zt+((Ct+bt)/2-bt)*an,cy:Zt+(wt-(wt+pe)/2)*an,r:"4",className:"fill-primary"})]})})()}),e.jsx("p",{className:"text-xs text-center text-muted-foreground mt-1",children:"Parcel Outline"})]}),n&&(u||i||_)&&e.jsxs(wi,{open:J,onOpenChange:H,children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full justify-between",children:["Copy Boundary To...",J?e.jsx(Cc,{className:"h-4 w-4"}):e.jsx(Oa,{className:"h-4 w-4"})]})}),e.jsxs(ki,{className:"pt-3 space-y-3",children:[_&&t&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Copy to Drawings:"}),e.jsxs(Le,{variant:"default",size:"sm",className:"w-full gap-2 bg-violet-600 hover:bg-violet-700",onClick:()=>{_(t),H(!1)},children:[e.jsx(fd,{className:"h-4 w-4"}),"Copy to Drawings"]})]}),(u||i)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{variant:W==="development"?"default":"outline",size:"sm",onClick:()=>Q("development"),children:"Development"}),e.jsx(Le,{variant:W==="existing"?"default":"outline",size:"sm",onClick:()=>Q("existing"),children:"Existing Site"})]}),e.jsxs(rt,{value:O,onValueChange:q,children:[e.jsx(it,{children:e.jsx(ct,{placeholder:`Select ${W==="development"?"development":"existing site"}...`})}),e.jsx(ot,{children:(W==="development"?P:I).map(je=>e.jsx(le,{value:je.id,children:je.name},je.id))})]}),e.jsx(Le,{size:"sm",disabled:!O,onClick:async()=>{W==="development"&&u?await u(O):W==="existing"&&i&&await i(O),H(!1),q("")},children:"Copy Boundary"})]})]})]})]})]}),e.jsxs(Mo,{children:[e.jsx(vc,{className:"pb-2",children:e.jsxs(bc,{className:"text-sm flex items-center gap-2",children:[e.jsx(ji,{className:"h-4 w-4 text-primary"}
720),"Location"]})}),e.jsxs(Io,{className:"space-y-1",children:[t.address&&e.jsx("p",{className:"font-medium text-sm",children:t.address}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Lat: ",RN(t.clickedLat)]}),e.jsxs("span",{children:["Lng: ",RN(t.clickedLng)]})]})]})]}),e.jsxs(Mo,{children:[e.jsx(vc,{className:"pb-2",children:e.jsxs(bc,{className:"text-sm flex items-center gap-2",children:[e.jsx(Ep,{className:"h-4 w-4 text-primary"}),"Owner Information"]})}),e.jsxs(Io,{children:[e.jsx(ql,{label:"Owner Name",value:t.owner}),e.jsx(ql,{label:"Mailing Address",value:t.ownerAddress}),K!==null&&K>0&&e.jsxs("div",{className:"mt-3 p-2 bg-muted/50 rounded-lg",children:[e.jsxs("p",{className:"text-xs",children:[e.jsx("span",{className:"font-medium text-primary",children:K})," ","other ",K===1?"property":"properties"," found in cache"]}),e.jsx(Le,{variant:"link",size:"sm",className:"p-0 h-auto text-xs",onClick:()=>X("portfolio"),children:"View Portfolio →"})]})]})]}),e.jsxs(Mo,{children:[e.jsx(vc,{className:"pb-2",children:e.jsxs(bc,{className:"text-sm flex items-center gap-2",children:[e.jsx(Fo,{className:"h-4 w-4 text-primary"}),"Physical Characteristics"]})}),e.jsxs(Io,{children:[e.jsx(ql,{label:"Parcel Size",value:t.acres||t.sqft?e.jsxs("span",{children:[t.acres&&e.jsxs("span",{children:[B_(t.acres)," acres"]}),t.acres&&t.sqft&&e.jsx("span",{className:"text-muted-foreground mx-1",children:"·"}),t.sqft&&e.jsxs("span",{children:[B_(t.sqft,0)," sq ft"]})]}):"—"}),e.jsx(ql,{label:"Land Use",value:t.landUse,icon:Ci}),e.jsx(ql,{label:"Zoning",value:t.zoning?e.jsx(Mt,{variant:"outline",className:"text-xs",children:t.zoning}):"—"}),e.jsx(ql,{label:"Year Built",value:t.yearBuilt,icon:kf}),e.jsx(ql,{label:"Building Count",value:t.buildingCount,icon:qd}),t.buildingSqft&&e.jsx(ql,{label:"Building Size",value:`${B_(t.buildingSqft,0)} sq ft`})]})]}),t.geometry&&e.jsxs(Mo,{children:[e.jsx(vc,{className:"pb-2",children:e.jsxs(bc,{className:"text-sm flex items-center gap-2",children:[e.jsx(Fo,{className:"h-4 w-4 text-primary"}),"Geometry Metrics (Calculated)"]})}),e.jsx(Io,{children:e.jsx(WS,{geometry:t.geometry,reportedAcres:t.acres,reportedSqft:t.sqft,defaultOpen:!0,compact:!0})})]}),e.jsxs(Mo,{children:[e.jsx(vc,{className:"pb-2",children:e.jsxs(bc,{className:"text-sm flex items-center gap-2",children:[e.jsx(j0,{className:"h-4 w-4 text-primary"}),"Location Details"]})}),e.jsxs(Io,{children:[e.jsx(ql,{label:"School District",value:t.schoolDistrict}),e.jsx(ql,{label:"County",value:t.county}),e.jsx(ql,{label:"Municipality",value:t.municipality})]})]}),e.jsxs(Mo,{children:[e.jsx(vc,{className:"pb-2",children:e.jsxs(bc,{className:"text-sm flex items-center gap-2",children:[e.jsx(Vd,{className:"h-4 w-4 text-primary"}),"Valuation & Sales"]})}),e.jsxs(Io,{children:[e.jsx(ql,{label:"Assessed Value",value:sm(t.assessedValue)}),(t.assessedLand||t.assessedImprovements)&&e.jsxs("div",{className:"pl-4 border-l-2 border-muted ml-2 space-y-0",children:[e.jsx(ql,{label:"Land Value",value:sm(t.assessedLand)}),e.jsx(ql,{label:"Improvements",value:sm(t.assessedImprovements)})]}),e.jsx(ql,{label:"Market Value",value:sm(t.marketValue)}),(t.marketLand||t.marketImprovements)&&e.jsxs("div",{className:"pl-4 border-l-2 border-muted ml-2 space-y-0",children:[e.jsx(ql,{label:"Land Value",value:sm(t.marketLand)}),e.jsx(ql,{label:"Improvements",value:sm(t.marketImprovements)})]}),t.assessedValue&&t.marketValue&&e.jsx(ql,{label:"Assessment Ratio",value:`${(t.assessedValue/t.marketValue*100).toFixed(1)}%`}),e.jsx(ql,{label:"Annual Tax",value:sm(t.taxAmount)}),e.jsxs("div",{className:"border-t border-border/50 mt-2 pt-2",children:[e.jsx(ql,{label:"Last Sale Price",value:sm(t.salePrice),icon:a3}),e.jsx(ql,{label:"Sale Date",value:$I(t.saleDate),icon:kf})]})]})]}),t.legalDescription&&e.jsxs(Mo,{children:[e.jsx(vc,{className:"pb-2",children:e.jsxs(bc,{className:"text-sm flex items-center gap-2",children:[e.jsx(D1,{className:"h-4 w-4 text-primary"}),"Legal Description"]})}),e.jsx(Io,{children:e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:t.legalDescription})})]}),n&&(l||c)&&!He&&!vt&&e.jsxs(Mo,{children:[e.jsx(vc,{className:"pb-2",children:e.jsxs(bc,{className:"text-sm flex items-center gap-2",children:[e.jsx(tr,{className:"h-4 w-4 text-primary"}),"Actions"]})}),e.jsxs(Io,{className:"space-y-3",children:[j&&t.geometry&&e.jsxs(Le,{size:"sm",className:"w-full gap-2 bg-indigo-600 hover:bg-indigo-700 text-white",onClick:()=>j(t),children:[e.jsx(Da,{className:"h-4 w-4"}),"Create Site Layout"]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l&&e.jsx(Le,{size:"sm",onClick:()=>l(t),children:"Add as Development"}),c&&e.jsx(Le,{size:"sm",variant:"outline",onClick:()=>c(t),children:"Add as Existing Site"})]}),_&&t.geometry&&e.jsxs(Le,{size:"sm",variant:"outline",className:"w-full gap-2",onClick:()=>_(t),children:[e.jsx(fd,{className:"h-4 w-4 text-amber-500"}),"Copy to Drawings"]}),(P.length>0||I.length>0)&&e.jsxs(wi,{open:ce,onOpenChange:ae,children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full justify-between",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Cf,{className:"h-4 w-4"}),"Link to Existing Project"]}),ce?e.jsx(Cc,{className:"h-4 w-4"}):e.jsx(Oa,{className:"h-4 w-4"})]})}),e.jsxs(ki,{className:"pt-3 space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{variant:ie==="development"?"default":"outline",size:"sm",onClick:()=>{de("development"),We("")},disabled:P.length===0,children:"Development"}),e.jsx(Le,{variant:ie==="existing"?"default":"outline",size:"sm",onClick:()=>{de("existing"),We("")},disabled:I.length===0,children:"Existing Site"})]}),e.jsxs(rt,{value:ge,onValueChange:We,children:[e.jsx(it,{children:e.jsx(ct,{placeholder:`Select ${ie==="development"?"development":"existing site"}...`})}),e.jsx(ot,{children:(ie==="development"?P:I).map(je=>e.jsx(le,{value:je.id,children:je.name},je.id))})]}),e.jsx(Le,{size:"sm",disabled:!ge||Ee,onClick:Gs,className:"w-full",children:Ee?e.jsxs(e.Fragment,{children:[e.jsx(Va,{className:"h-4 w-4 mr-2 animate-spin"}),"Linking..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Cf,{className:"h-4 w-4 mr-2"}),"Link Parcel"]})})]})]})]})]})]}),e.jsxs($i,{value:"portfolio",className:"p-3 space-y-3 m-0",children:[e.jsxs(Mo,{children:[e.jsx(vc,{className:"pb-2",children:e.jsxs(bc,{className:"text-sm flex items-center gap-2",children:[e.jsx(Ld,{className:"h-4 w-4 text-primary"}),"Owner Portfolio Search"]})}),e.jsxs(Io,{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(be,{placeholder:"Owner name...",value:Ce,onChange:je=>Be(je.target.value),onKeyDown:je=>je.key==="Enter"&&tn(),className:"h-8 text-sm"}),e.jsx(Le,{size:"sm",onClick:tn,disabled:_s,children:_s?e.jsx(Va,{className:"h-4 w-4 animate-spin"}):"Search"})]}),e.jsxs(wi,{open:Dt,onOpenChange:Rt,children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full justify-between text-muted-foreground text-xs",children:["Deep Search (API)",Dt?e.jsx(Cc,{className:"h-4 w-4"}):e.jsx(Oa,{className:"h-4 w-4"})]})}),e.jsxs(ki,{className:"pt-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Search Report All USA API for owner properties."}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"State"}),e.jsxs(rt,{value:zt.state||"",onValueChange:je=>rs({...zt,state:je}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{placeholder:"State"})}),e.jsx(ot,{children:BI.map(je=>e.jsx(le,{value:je.code,children:je.name},je.code))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"County"}),e.jsx(be,{className:"h-7 text-xs",placeholder:"County",value:zt.county||"",onChange:je=>rs({...zt,county:je.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"ZIP"}),e.jsx(be,{className:"h-7 text-xs",placeholder:"ZIP",value:zt.zip||"",onChange:je=>rs({...zt,zip:je.target.value})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Est. API calls: ",Pe.min,"
720-",Pe.max]}),e.jsx(Le,{size:"sm",onClick:wn,disabled:_s,children:_s?e.jsx(Va,{className:"h-4 w-4 animate-spin"}):"Deep Search"})]})]})]})]})]}),$t&&e.jsx("div",{className:"p-3 bg-destructive/10 text-destructive text-xs rounded-lg",children:$t}),vs&&e.jsxs(e.Fragment,{children:[e.jsxs(Mo,{children:[e.jsx(vc,{className:"pb-2",children:e.jsx(bc,{className:"text-sm",children:"Portfolio Summary"})}),e.jsxs(Io,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:vs.totalCount}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Properties"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:B_(vs.totalAcres)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Acres"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:sm(vs.totalMarketValue)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Market Value"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:sm(vs.totalAssessedValue)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Assessed Value"})]})]}),vs.ownerVariations&&vs.ownerVariations.length>1&&e.jsxs("div",{className:"mt-3 pt-3 border-t",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Owner Name Variations:"}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[vs.ownerVariations.slice(0,5).map((je,Ge)=>e.jsx(Mt,{variant:"outline",className:"text-xs",children:je},Ge)),vs.ownerVariations.length>5&&e.jsxs(Mt,{variant:"secondary",className:"text-xs",children:["+",vs.ownerVariations.length-5," more"]})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-sm font-medium",children:["Properties (",vs.parcels.length,")"]}),vs.parcels.map((je,Ge)=>e.jsx(tI,{parcel:je,isCompact:!0,onViewOnMap:y?()=>y(je.lat,je.lng):void 0},je.apn||Ge))]})]}),!vs&&!_s&&!$t&&e.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[e.jsx(Ld,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"Search for an owner to view their portfolio"})]})]}),e.jsx($i,{value:"raw",className:"p-3 m-0",children:e.jsxs(Mo,{children:[e.jsx(vc,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(bc,{className:"text-sm flex items-center gap-2",children:[e.jsx(UC,{className:"h-4 w-4 text-primary"}),"Raw Parcel Data"]}),e.jsxs(Le,{variant:"ghost",size:"sm",onClick:()=>Is(JSON.stringify(t.rawData||t,null,2),"Raw data"),children:[e.jsx(hp,{className:"h-3 w-3 mr-1"}),"Copy"]})]})}),e.jsx(Io,{children:e.jsx("pre",{className:"text-xs bg-muted p-3 rounded-lg overflow-auto max-h-96 whitespace-pre-wrap",children:JSON.stringify(t.rawData||{apn:t.apn,address:t.address,owner:t.owner,ownerAddress:t.ownerAddress,acres:t.acres,sqft:t.sqft,landUse:t.landUse,zoning:t.zoning,yearBuilt:t.yearBuilt,assessedValue:t.assessedValue,marketValue:t.marketValue,taxAmount:t.taxAmount,lat:t.clickedLat,lng:t.clickedLng,source:t.source},null,2)})})]})})]})]}):e.jsx("div",{className:"p-6 text-center text-muted-foreground",children:"No parcel data available"})]})}const qI=[{label:"White House, DC",value:"1600 Pennsylvania Ave NW, Washington, DC"},{label:"Empire State Building, NY",value:"350 5th Ave, New York, NY"},{label:"Universal Studios, CA",value:"100 Universal City Plaza, Universal City, CA"},{label:"Willis Tower, IL",value:"233 S Wacker Dr, Chicago, IL"}];function GI(t){return!t||t.length<5?!0:t.includes(",")||/,?\s*[A-Za-z]{2,}\s*,?\s*[A-Z]{2}\s*(\d{5})?$/.test(t)}const HI=({onParcelFound:t,onClose:s})=>{const[n,a]=k.useState("address"),[l,c]=k.useState(""),[u,i]=k.useState(!1),[_,j]=k.useState(null),[y,x]=k.useState(!1),v=lc(),C=n==="address"&&l.length>10&&!GI(l),P=k.useCallback(async()=>{var F,D,X,K,te,J,H,O;if(!l.trim()){Ve.error("Please enter a search value");return}i(!0),j(null);try{const q=n==="address"?await cM(l):await dM(l);if(q.found&&q.parcel){j("cache"),t(q.parcel),Ve.success("Loaded from cache",{description:`APN: ${q.parcel.apn} (no API call)`,duration:3e3}),i(!1);return}const{data:W,error:Q}=await Fs.functions.invoke("report-all-parcel-lookup",{body:{searchType:n,searchValue:l.trim()}});if(Q)throw new Error(Q.message);if(!W.success){if(W.errorType==="ADDRESS_INCOMPLETE")Ve.error("Address incomplete",{description:"Please include city and state (e.g., 123 Main St, Reading, PA)",duration:5e3});else throw new Error(W.error||"Failed to search parcel");i(!1);return}if(W.parcel){j("api");const Z=W.parcel,oe=Z.clickedLat||((K=(X=(D=(F=Z.geometry)==null?void 0:F.coordinates)==null?void 0:D[0])==null?void 0:X[0])==null?void 0:K[1]),ce=Z.clickedLng||((O=(H=(J=(te=Z.geometry)==null?void 0:te.coordinates)==null?void 0:J[0])==null?void 0:H[0])==null?void 0:O[0]);if(oe&&ce){const ae=Z.ownerAddress||null;await Fs.from("parcel_cache").upsert([{apn:Z.apn,address:Z.address||null,owner:Z.owner||null,owner_address:ae,acres:Z.acres??null,sqft:Z.sqft??null,land_use:Z.landUse||null,zoning:Z.zoning||null,year_built:Z.yearBuilt??null,assessed_value:Z.assessedValue??null,market_value:Z.marketValue??null,tax_amount:Z.taxAmount??null,geometry:Z.geometry?JSON.parse(JSON.stringify(Z.geometry)):null,raw_data:Z.rawData?JSON.parse(JSON.stringify(Z.rawData)):null,lat:oe,lng:ce,source:"Report All USA"}],{onConflict:"apn"}
720),v.invalidateQueries({queryKey:["cached-parcels"]})}t({...Z,fromCache:!1}),Ve.success("Loaded from API",{description:`APN: ${Z.apn} (now cached)`,duration:3e3})}else{const Z=W.message||"No parcel found matching your search";Ve.info(Z,{duration:5e3})}}catch(q){const W=q instanceof Error?q.message:"Search failed";W.includes("region")||W.includes("incomplete")?Ve.error("Address format issue",{description:"Include city and state (e.g., 123 Main St, Reading, PA)",duration:5e3}):Ve.error(W)}finally{i(!1)}},[n,l,t,v]),I=F=>{F.key==="Enter"&&P()},z=F=>{c(F),x(!1)};return e.jsxs(Mo,{className:"w-80 bg-background/95 backdrop-blur-sm shadow-xl border-border",children:[e.jsx(vc,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs(bc,{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(Mh,{className:"h-4 w-4 text-emerald-500"}),"Parcel Search"]}),_&&e.jsxs(Mt,{variant:_==="cache"?"secondary":"outline",className:"mt-1 text-[10px]",children:[e.jsx(Fu,{className:"h-3 w-3 mr-1"}),_==="cache"?"From Cache":"From API"]})]}),s&&e.jsx(Le,{variant:"ghost",size:"icon",className:"h-7 w-7 -mt-1 -mr-2",onClick:s,children:e.jsx(ja,{className:"h-4 w-4"})})]})}),e.jsxs(Io,{className:"space-y-4",children:[e.jsxs(Zm,{value:n,onValueChange:F=>a(F),children:[e.jsxs(mm,{className:"grid w-full grid-cols-2",children:[e.jsxs(Bi,{value:"address",className:"text-xs",children:[e.jsx(ji,{className:"h-3 w-3 mr-1"}),"Address"]}),e.jsxs(Bi,{value:"apn",className:"text-xs",children:[e.jsx(Mh,{className:"h-3 w-3 mr-1"}),"APN"]})]}),e.jsxs($i,{value:"address",className:"mt-3 space-y-2",children:[e.jsx(be,{placeholder:"123 Main St, City, PA (city & state required)",value:l,onChange:F=>c(F.target.value),onKeyDown:I,className:"text-sm"}),C&&e.jsxs(Dy,{variant:"default",className:"py-2 bg-amber-500/10 border-amber-500/30",children:[e.jsx(ho,{className:"h-3 w-3 text-amber-500"}),e.jsx(Ry,{className:"text-xs text-amber-600 dark:text-amber-400",children:"Include city and state for best results"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Full address with city and state required"}),e.jsxs(wi,{open:y,onOpenChange:x,children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs h-7 px-2",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(zb,{className:"h-3 w-3"}),"Sample Addresses"]}),e.jsx(Oa,{className:`h-3 w-3 transition-transform ${y?"rotate-180":""}`})]})}),e.jsx(ki,{className:"mt-1",children:e.jsx("div",{className:"border rounded-md divide-y text-xs",children:qI.map(F=>e.jsxs("button",{onClick:()=>z(F.value),className:"w-full text-left px-2 py-1.5 hover:bg-muted transition-colors",children:[e.jsx("span",{className:"font-medium",children:F.label}),e.jsx("span",{className:"block text-muted-foreground truncate",children:F.value})]},F.value))})})]})]}),e.jsxs($i,{value:"apn",className:"mt-3",children:[e.jsx(be,{placeholder:"Enter APN (e.g., 123-456-789)",value:l,onChange:F=>c(F.target.value),onKeyDown:I,className:"text-sm font-mono"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Search by Assessor's Parcel Number"})]})]}),e.jsx(Le,{onClick:P,disabled:u||!l.trim(),className:"w-full",children:u?e.jsxs(e.Fragment,{children:[e.jsx(Va,{className:"h-4 w-4 mr-2 animate-spin"}),"Searching..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ld,{className:"h-4 w-4 mr-2"}),"Search Parcel"]})})]})]})},FN=t=>t>=1e6?`$${(t/1e6).toFixed(1)}M`:t>=1e3?`$${(t/1e3).toFixed(0)}K`:`$${t.toFixed(0)}`,Ev=t=>t>=1?`${t.toFixed(2)} ac`:`${(t*43560).toFixed(0)} sqft`,Pv=t=>t>=5280?`${(t/5280).toFixed(2)} mi`:`${Math.round(t).toLocaleString()} ft`,ZI=({isActive:t,assemblageItems:s,stats:n,isDrawingCustomArea:a,onToggleMode:l,onClearSelection:c,onRemoveItem:u,onRenameCustomArea:i,onSave:_,onCreateDevelopment:j,onCreateExistingSite:y,onStartDrawingCustomArea:x,onCancelDrawingCustomArea:v,onCopyToDrawings:C,onCreateSiteLayout:P,isSaving:I=!1,isCopyingToDrawings:z=!1,isCreatingSiteLayout:F=!1})=>{const[D,X]=k.useState(!0),[K,te]=k.useState(null),[J,H]=k.useState(""),O=s.length>0;return!t&&!O?e.jsxs(Le,{variant:"outline",size:"sm",onClick:l,className:"gap-2 bg-background/95 backdrop-blur-sm shadow-md border-border",children:[e.jsx(Da,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Assemblage Mode"}),e.jsx("span",{className:"sm:hidden",children:"Assemble"})]}):e.jsxs("div",{className:fs("bg-background/95 backdrop-blur-sm rounded-lg shadow-lg border border-border","min-w-[280px] max-w-[360px]"),children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:fs("w-2 h-2 rounded-full",t?"bg-green-500 animate-pulse":"bg-muted")}),e.jsx("span",{className:"font-medium text-sm",children:"Assemblage Mode"}),O&&e.jsxs(Mt,{variant:"secondary",className:"text-xs",children:[n.totalItems," ",n.totalItems===1?"item":"items"]})]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:l,children:e.jsx(ja,{className:"w-4 h-4"})})]}),a&&e.jsxs("div",{className:"p-3 bg-primary/10 border-b border-border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Du,{className:"w-4 h-4 text-primary animate-pulse"}),e.jsx("span",{className:"font-medium",children:"Drawing Custom Area"})]}),e.jsx(Le,{variant:"ghost",size:"sm",onClick:v,className:"h-6 text-xs",children:"Cancel"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Click on the map to draw polygon points. Double-click to finish."})]}),O&&e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Il,{className:"w-4 h-4"}),e.jsx("span",{children:"Total Area:"})]}),e.jsx("span",{className:"font-semibold text-right",children:Ev(n.totalAcres)}),n.perimeterFeet>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Fo,{className:"w-4 h-4"}),e.jsx("span",{children:"Perimeter:"})]}),e.jsx("span",{className:"font-medium text-right",children:Pv(n.perimeterFeet)})]}),n.widthFeet>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(uS,{className:"w-4 h-4"}),e.jsx("span",{children:"Width:"})]}),e.jsx("span",{className:"font-medium text-right",children:Pv(n.widthFeet)})]}),n.depthFeet>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(e_,{className:"w-4 h-4"}),e.jsx("span",{children:"Depth:"})]}),e.jsx("span",{className:"font-medium text-right",children:Pv(n.depthFeet)})]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[n.parcelCount>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ji,{className:"w-4 h-4"}),e.jsx("span",{children:"Parcels:"})]}),e.jsx("span",{className:"font-medium text-right",children:n.parcelCount})]}),n.customAreaCount>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Du,{className:"w-4 h-4"}),e.jsx("span",{children:"Custom Areas:"})]}),e.jsx("span",{className:"font-medium text-right",children:n.customAreaCount})]}),n.totalAssessedValue>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Vd,{className:"w-4 h-4"}),e.jsx("span",{children:"Assessed:"})]}),e.jsx("span",{className:"font-semibold text-right",children:FN(n.totalAssessedValue)})]}),n.totalMarketValue>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Vd,{className:"w-4 h-4"}),e.jsx("span",{children:"Market:"})]}),e.jsx("span",{className:"font-semibold text-right",children:FN(n.totalMarketValue)})]})]}),e.jsxs(wi,{open:D,onOpenChange:X,children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full justify-between h-8",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["View all items (",s.length,")"]}),D?e.jsx(Cc,{className:"w-4 h-4"}):e.jsx(Oa,{className:"w-4 h-4"})]})}),e.jsx(ki,{className:"mt-2 space-y-1 max-h-[200px] overflow-y-auto",children:s.map(q=>e.jsxs("div",{className:fs("flex items-center justify-between p-2 rounded text-xs group",q.type==="parcel"?"bg-muted/50":"bg-primary/10"),children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[q.type==="parcel"?e.jsx(ji,{className:"w-3 h-3 text-muted-foreground shrink-0"}):e.jsx(Du,{className:"w-3 h-3 text-primary shrink-0"}),e.jsxs("div",{className:"truncate flex-1",children:[q.type==="customArea"&&K===q.data.id?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(be,{value:J,onChange:W=>H(W.target.value),className:"h-5 text-xs py-0 px-1",autoFocus:!0,onKeyDown:W=>{W.key==="Enter"?(i==null||i(q.data.id,J),te(null)):W.key==="Escape"&&te(null)}}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{i==null||i(q.data.id,J),te(null)},children:e.jsx(cl,{className:"w-3 h-3"})})]}):e.jsxs("div",{className:fs("font-medium",q.type==="customArea"&&"cursor-pointer hover:text-primary"),onClick:()=>{q.type==="customArea"&&(te(q.data.id),H(q.data.name))},children:[q.type==="customArea"?q.data.name:q.label,q.type==="customArea"&&e.jsx(kp,{className:"w-2.5 h-2.5 inline ml-1 opacity-50"})]}),q.type==="parcel"?e.jsxs("div",{className:"text-muted-foreground truncate",children:[q.data.apn,q.data.address&&` - ${q.data.address}`]}):e.jsx("div",{className:"text-muted-foreground",children:Ev(q.data.acres)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[q.type==="parcel"&&q.data.acres&&e.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:Ev(q.data.acres)}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>u((q.type==="parcel",q.data.id),q.type),children:e.jsx(ja,{className:"w-3 h-3"})})]})]},(q.type==="parcel",q.data.id)))})]}),e.jsx(ks,{}),C&&e.jsxs(Le,{variant:"default",size:"sm",onClick:C,disabled:z,className:"w-full gap-2 bg-violet-600 hover:bg-violet-700 text-white",children:[z?e.jsx(Va,{className:"w-4 h-4 animate-spin"}):e.jsx(fd,{className:"w-4 h-4"}),"Copy Outline to Drawings"]}),P&&e.jsxs(Le,{size:"sm",onClick:P,disabled:F,className:"w-full gap-2 bg-indigo-600 hover:bg-indigo-700 text-white",children:[F?e.jsx(Va,{className:"w-4 h-4 animate-spin"}):e.jsx(Bm,{className:"w-4 h-4"}),"Create Site Layout"]}),!a&&e.jsxs(Le,{variant:"outline",size:"sm",onClick:x,className:"w-full gap-2",children:[e.jsx(Du,{className:"w-4 h-4"}),"Draw Custom Area"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Le,{variant:"outline",size:"sm",onClick:c,className:"flex-1",children:[e.jsx(wr,{className:"w-4 h-4 mr-1"}),"Clear"]}),e.jsxs(Le,{variant:"default",size:"sm",onClick:_,disabled:I,className:"flex-1",children:[e.jsx(jg,{className:"w-4 h-4 mr-1"}),"Save"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Le,{variant:"secondary",size:"sm",onClick:j,className:"flex-1 text-xs",children:[e.jsx(tr,{className:"w-3 h-3 mr-1"}),"New Development"]}),e.jsxs(Le,{variant:"secondary",size:"sm",onClick:y,className:"flex-1 text-xs",children:[e.jsx(tr,{className:"w-3 h-3 mr-1"}),"Existing Site"]})]})]}),t&&!O&&!a&&e.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground space-y-3",children:[e.jsx("p",{children:"Click on parcels to add them to your assemblage"}),e.jsx("p",{className:"text-xs opacity-70",children:"Tip: Make sure Parcel Inspect Mode is active"}),e.jsx(ks,{}),e.jsxs(Le,{variant:"outline",size:"sm",onClick:x,className:"w-full gap-2",children:[e.jsx(Du,{className:"w-4 h-4"}),"Draw Custom Area"]})]})]})},zN=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),WI=({open:t,onOpenChange:s,stats:n,onSave:a,isSaving:l=!1})=>{const[c,u]=k.useState(""),[i,_]=k.useState(""),j=()=>{c.trim()&&(a(c.trim(),i.trim()||void 0),u(""),_(""))},y=()=>{u(""),_(""),s(!1)};return e.jsx(dd,{open:t,onOpenChange:y,children:e.jsxs(ud,{className:"sm:max-w-[425px]",children:[e.jsxs(Gd,{children:[e.jsx(Hd,{children:"Save Parcel Assemblage"}),e.jsxs(vg,{children:["Save this selection of ",n.parcelCount," parcels for future reference."]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2 p-3 bg-muted rounded-lg text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Parcels:"}),e.jsx("span",{className:"font-medium text-right",children:n.parcelCount}),e.jsx("span",{className:"text-muted-foreground",children:"Total Acres:"}),e.jsxs("span",{className:"font-medium text-right",children:[n.totalAcres.toFixed(2)," ac"]}),n.totalAssessedValue>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:"Assessed Value:"}),e.jsx("span",{className:"font-medium text-right",children:zN(n.totalAssessedValue)})]}),n.totalMarketValue>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:"Market Value:"}),e.jsx("span",{className:"font-medium text-right",children:zN(n.totalMarketValue)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"name",children:"Name *"}),e.jsx(be,{id:"name",placeholder:"e.g., Main Street Assemblage",value:c,onChange:x=>u(x.target.value),autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"description",children:"Description (optional)"}),e.jsx(j1,{id:"description",placeholder:"Add notes about this assemblage...",value:i,onChange:x=>_(x.target.value),rows:3})]})]}),e.jsxs(vf,{children:[e.jsx(Le,{variant:"outline",onClick:y,disabled:l,children:"Cancel"}),e.jsx(Le,{onClick:j,disabled:!c.trim()||l,children:l?e.jsxs(e.Fragment,{children:[e.jsx(Va,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Assemblage"})]})]})})};function YI(t,s){return q5(t,-s)}const Tv=t=>t>=1e6?`$${(t/1e6).toFixed(2)}M`:t>=1e3?`$${(t/1e3).toFixed(1)}K`:`$${t.toFixed(0)}`,ON=(t,s=2)=>
720t.toLocaleString(void 0,{minimumFractionDigits:s,maximumFractionDigits:s}),XI=({assemblage:t,onClose:s,onLoad:n,onZoomToBoundary:a,onCreateSiteLayout:l,isCreatingSiteLayout:c=!1})=>{const[u,i]=k.useState([]),[_,j]=k.useState(!1);return k.useEffect(()=>{(async()=>{if(!t.parcel_ids||t.parcel_ids.length===0){i([]);return}j(!0);try{const{data:x,error:v}=await Fs.from("parcel_cache").select("*").in("id",t.parcel_ids);if(v)throw v;const C=(x||[]).map(P=>({id:String(P.id),apn:P.apn,address:P.address||"",owner:P.owner||"",ownerAddress:P.owner_address||void 0,acres:P.acres??void 0,sqft:P.sqft??void 0,landUse:P.land_use||void 0,zoning:P.zoning||void 0,yearBuilt:P.year_built??void 0,assessedValue:P.assessed_value??void 0,marketValue:P.market_value??void 0,taxAmount:P.tax_amount??void 0,geometry:P.geometry||void 0,rawData:P.raw_data||void 0,source:P.source||"cache",clickedLat:P.lat,clickedLng:P.lng,fromCache:!0}));i(C)}catch(x){console.error("Failed to load parcel details:",x)}finally{j(!1)}})()},[t.parcel_ids]),e.jsxs("div",{className:"h-full flex flex-col bg-background border-l border-border",children:[e.jsxs("div",{className:"p-4 border-b border-border",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"font-semibold text-lg truncate",children:t.name}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:t.description})]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"shrink-0",onClick:s,children:e.jsx(ja,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-3",children:[e.jsxs(Le,{size:"sm",onClick:()=>n(t),className:"gap-1.5",children:[e.jsx(d5,{className:"w-3.5 h-3.5"}),"Load Assemblage"]}),t.combined_boundary&&e.jsxs(Le,{variant:"outline",size:"sm",onClick:()=>a(t.combined_boundary),className:"gap-1.5",children:[e.jsx(Mf,{className:"w-3.5 h-3.5"}),"Zoom to Boundary"]}),l&&t.combined_boundary&&e.jsxs(Le,{size:"sm",onClick:()=>l(t),disabled:c,className:"gap-1.5 bg-indigo-600 hover:bg-indigo-700 text-white",children:[c?e.jsx(Va,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Bm,{className:"w-3.5 h-3.5"}),"Create Site Layout"]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 pt-3 border-t border-border",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Export:"}),e.jsx(jy,{label:"All Parcels",size:"sm",variant:"outline",disabled:u.length===0,onExport:y=>zI(u,y,`assemblage_${t.name}_parcels`)}),t.combined_boundary&&e.jsx(jy,{label:"Combined",size:"sm",variant:"outline",onExport:y=>OI(t.combined_boundary,t.name,y)})]})]}),e.jsxs("div",{className:"p-4 border-b border-border",children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Statistics"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Da,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs",children:"Parcels"})]}),e.jsx("div",{className:"text-lg font-semibold",children:t.parcel_count})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Il,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs",children:"Total Acres"})]}),e.jsx("div",{className:"text-lg font-semibold",children:t.total_acres?ON(t.total_acres):"—"})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Vd,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs",children:"Market Value"})]}),e.jsx("div",{className:"text-lg font-semibold",children:t.total_market_value?Tv(t.total_market_value):"—"})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Vd,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs",children:"Assessed Value"})]}),e.jsx("div",{className:"text-lg font-semibold",children:t.total_assessed_value?Tv(t.total_assessed_value):"—"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-3 text-xs text-muted-foreground",children:[e.jsx(kf,{className:"w-3 h-3"}),"Created ",M1(new Date(t.created_at),{addSuffix:!0}),e.jsxs("span",{className:"ml-1",children:["(",J5(new Date(t.created_at),"MMM d, yyyy"),")"]})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsx("div",{className:"px-4 py-3 border-b border-border",children:e.jsxs("h3",{className:"text-sm font-medium",children:["Included Parcels (",u.length,")"]})}),e.jsx(Xc,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-2",children:_?[...Array(3)].map((y,x)=>e.jsxs("div",{className:"p-3 rounded-lg border border-border",children:[e.jsx(du,{className:"h-4 w-1/2 mb-2"}),e.jsx(du,{className:"h-3 w-3/4 mb-1"}),e.jsx(du,{className:"h-3 w-1/3"})]},x)):u.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-6 text-sm",children:"No parcel details available"}):u.map((y,x)=>e.jsxs("div",{className:"p-3 rounded-lg border border-border bg-card hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mt,{variant:"secondary",className:"text-xs",children:String.fromCharCode(65+x)}),e.jsx("span",{className:"font-medium text-sm",children:y.apn})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[y.geometry&&e.jsx(jy,{label:"",size:"icon",variant:"ghost",className:"h-6 w-6",onExport:v=>tE(y.geometry,y.apn||"parcel",v,{address:y.address,owner:y.owner,acres:y.acres,marketValue:y.marketValue})}),y.acres&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[ON(y.acres)," ac"]})]})]}),y.address&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mb-1",children:[e.jsx(ji,{className:"w-3 h-3 shrink-0"}),e.jsx("span",{className:"truncate",children:y.address})]}),y.owner&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mb-1",children:[e.jsx(Ep,{className:"w-3 h-3 shrink-0"}),e.jsx("span",{className:"truncate",children:y.owner})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[y.zoning&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(D1,{className:"w-3 h-3"}),y.zoning]}),y.marketValue&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Vd,{className:"w-3 h-3"}),Tv(y.marketValue)]})]})]},y.id))})})]})]})},dj=()=>fu({queryKey:["all-development-tenants"],queryFn:async()=>{const{data:t,error:s}=await Fs.from("development_tenants").select(`
721          id,
722          development_id,
723          retailer_logo_id,
724          tenant_id,
725          display_order,
726          retailer_logos (
727            id,
728            name,
729            logo_url,
730            category,
731            is_preset
732          )
733        `).order("display_order");if(s)throw s;const n=new Map;return(t||[]).forEach(a=>{const l={id:a.id,development_id:a.development_id,retailer_logo_id:a.retailer_logo_id,tenant_id:a.tenant_id,display_order:a.display_order??0,retailer_logo:a.retailer_logos},c=n.get(a.development_id)||[];c.push(l),n.set(a.development_id,c)}),n}}),uj=()=>fu({queryKey:["all-existing-product-tenants"],queryFn:async()=>{const{data:t,error:s}=await Fs.from("existing_product_tenants").select(`
734          id,
735          existing_product_id,
736          retailer_logo_id,
737          tenant_id,
738          display_order,
739          retailer_logo:retailer_logos(id, name, logo_url, category, is_preset)
740        `).order("display_order");if(s)throw s;const n=new Map;return(t||[]).forEach(a=>{const l={id:a.id,existing_product_id:a.existing_product_id,retailer_logo_id:a.retailer_logo_id,tenant_id:a.tenant_id,display_order:a.display_order,retailer_logo:a.retailer_logo},c=n.get(a.existing_product_id)||[];c.push(l),n.set(a.existing_product_id,c)}),n}}),KI=k.lazy(()=>br(()=>import("./DevelopersCRMPanel-BA4bA5IQ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]))),JI=k.lazy(()=>br(()=>import("./OwnersCRMPanel-DHVUc2gM.js"),__vite__mapDeps([29,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,17,20,21,22,23,24,25,26,27,28]))),QI=k.lazy(()=>br(()=>import("./TenantsCRMPanel-25a6tTKW.js"),__vite__mapDeps([30,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]))),UI=({isAdmin:t=!1,pendingDeveloperId:s,pendingOwnerId:n,pendingTenantId:a,onClearPendingCrm:l,onNavigateToProperty:c,onViewOnMap:u,onToggleCrmVisibility:i,visibleDeveloperIds:_,visibleOwnerIds:j,visibleTenantIds:y,crmFilter:x,onCrmFilterChange:v})=>{const{developers:C}=Jx(),{owners:P}=Qx(),{tenants:I}=I1(),[z,F]=k.useState(()=>{try{return localStorage.getItem("crm-active-section")||null}catch{return null}}),[D,X]=k.useState(null),[K,te]=k.useState(null),[J,H]=k.useState(null),[O,q]=k.useState(()=>{try{const ce=localStorage.getItem("crm-panel-expanded");return ce!==null?ce==="true":!1}catch{return!1}});k.useEffect(()=>{localStorage.setItem("crm-panel-expanded",String(O))},[O]),k.useEffect(()=>{z?localStorage.setItem("crm-active-section",z):localStorage.removeItem("crm-active-section")},[z]),k.useEffect(()=>{s?(X(s),F("developers"),q(!0),l==null||l()):n?(te(n),F("owners"),q(!0),l==null||l()):a&&(H(a),F("tenants"),q(!0),l==null||l())},[s,n,a,l]);const W=ce=>{F(z===ce?null:ce)},Q=(ce,ae)=>{if(ce==="developer"){const ie=C.find(de=>de.id===ae);v({type:"developer",id:ae,name:(ie==null?void 0:ie.name)||null})}else if(ce==="owner"){const ie=P.find(de=>de.id===ae);v({type:"owner",id:ae,name:(ie==null?void 0:ie.true_owner_name)||null})}else{const ie=I==null?void 0:I.find(de=>de.id===ae);v({type:"tenant",id:ae,name:(ie==null?void 0:ie.name)||null})}},Z=()=>{v({type:null,id:null,name:null})},oe=x.type!==null&&x.id!==null;return e.jsxs(wi,{open:O,onOpenChange:q,children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",className:"w-full justify-between px-4 py-2 h-auto border-b border-border shrink-0",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(oS,{className:"w-4 h-4 text-primary"}),"CRM",oe&&e.jsx(Mt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:"Filtered"})]}),O?e.jsx(Oa,{className:"w-4 h-4"}):e.jsx(Ao,{className:"w-4 h-4"})]})}),e.jsxs(ki,{className:"border-b border-border",children:[e.jsxs("div",{className:"px-3 py-2 border-b border-border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-muted-foreground font-medium",children:"Filter Map"}),oe&&e.jsx(Le,{variant:"ghost",size:"icon",className:"h-4 w-4 hover:bg-destructive/10",onClick:Z,children:e.jsx(ja,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(rt,{value:x.type==="developer"&&x.id||"",onValueChange:ce=>Q("developer",ce),children:[e.jsxs(it,{className:"h-7 text-xs flex-1",children:[e.jsx(uh,{className:"w-3 h-3 mr-1 shrink-0"}),e.jsx("span",{className:"truncate",children:x.type==="developer"&&x.name?x.name:"Developer"})]}),e.jsx(ot,{children:C.length>0?C.map(ce=>e.jsx(le,{value:ce.id,className:"text-xs",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ce.logo_url?e.jsx("img",{src:ce.logo_url,alt:"",className:"w-4 h-4 object-contain rounded"}):e.jsx(uh,{className:"w-4 h-4 text-muted-foreground"}),ce.name]})},ce.id)):e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No developers"})})]}),e.jsxs(rt,{value:x.type==="owner"&&x.id||"",onValueChange:ce=>Q("owner",ce),children:[e.jsxs(it,{className:"h-7 text-xs flex-1",children:[e.jsx(A_,{className:"w-3 h-3 mr-1 shrink-0"}),e.jsx("span",{className:"truncate",children:x.type==="owner"&&x.name?x.name:"Owner"})]}),e.jsx(ot,{children:P.length>0?P.map(ce=>e.jsx(le,{value:ce.id,className:"text-xs",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ce.logo_url?e.jsx("img",{src:ce.logo_url,alt:"",className:"w-4 h-4 object-contain rounded"}):e.jsx(A_,{className:"w-4 h-4 text-muted-foreground"}),ce.true_owner_name]})},ce.id)):e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No owners"})})]}),e.jsxs(rt,{value:x.type==="tenant"&&x.id||"",onValueChange:ce=>Q("tenant",ce),children:[e.jsxs(it,{className:"h-7 text-xs flex-1",children:[e.jsx(yl,{className:"w-3 h-3 mr-1 shrink-0"}),e.jsx("span",{className:"truncate",children:x.type==="tenant"&&x.name?x.name:"Tenant"})]}),e.jsx(ot,{children:I&&I.length>0?I.map(ce=>e.jsx(le,{value:ce.id,className:"text-xs",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ce.logo_url?e.jsx("img",{src:ce.logo_url,alt:"",className:"w-4 h-4 object-contain rounded"}):e.jsx(yl,{className:"w-4 h-4 text-muted-foreground"}),ce.name]})},ce.id)):e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No tenants"})})]})]}),oe&&e.jsxs("div",{className:"flex items-center gap-2 mt-2 p-1.5 rounded-md bg-primary/10 border border-primary/20",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-1.5 text-xs",children:[x.type==="developer"&&e.jsx(uh,{className:"w-3 h-3 text-primary"}),x.type==="owner"&&e.jsx(A_,{className:"w-3 h-3 text-primary"}),x.type==="tenant"&&e.jsx(yl,{className:"w-3 h-3 text-primary"}),e.jsx("span",{className:"font-medium truncate",children:x.name})]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5 hover:bg-destructive/10",onClick:Z,children:e.jsx(ja,{className:"w-3 h-3"})})]})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs(wi,{open:z==="developers",onOpenChange:()=>W("developers"),children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",className:"w-full justify-between px-4 py-2 h-auto hover:bg-muted/50",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[e.jsx(uh,{className:"w-4 h-4"}),"Developers",e.jsx(Mt,{variant:"outline",className:"text-[10px] px-1 py-0 h-4",children:C.length})]}),z==="developers"?e.jsx(Oa,{className:"w-4 h-4"}):e.jsx(Ao,{className:"w-4 h-4"})]})}),e.jsx(ki,{children:e.jsx("div",{className:"max-h-[300px] overflow-y-auto",children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading..."}),children:e.jsx(KI,{isAdmin:t,initialExpandedId:D,onNavigateToProperty:c,onViewOnMap:u,onToggleCrmVisibility:i,visibleDeveloperIds:_})})})})]}),e.jsxs(wi,{open:z==="owners",onOpenChange:()=>W("owners"),children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",className:"w-full justify-between px-4 py-2 h-auto hover:bg-muted/50",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[e.jsx(A_,{className:"w-4 h-4"}),"Owners",e.jsx(Mt,{variant:"outline",className:"text-[10px] px-1 py-0 h-4",children:P.length})]}),z==="owners"?e.jsx(Oa,{className:"w-4 h-4"}):e.jsx(Ao,{className:"w-4 h-4"})]})}),e.jsx(ki,{children:e.jsx("div",{className:"max-h-[300px] overflow-y-auto",children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading..."}),children:e.jsx(JI,{isAdmin:t,initialExpandedId:K,onNavigateToProperty:c,onViewOnMap:u,onToggleCrmVisibility:i,visibleOwnerIds:j})})})})]}),e.jsxs(wi,{open:z==="tenants",onOpenChange:()=>W("tenants"),children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",className:"w-full justify-between px-4 py-2 h-auto hover:bg-muted/50",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[e.jsx(yl,{className:"w-4 h-4"}),"Tenants",e.jsx(Mt,{variant:"outline",className:"text-[10px] px-1 py-0 h-4",children:(I==null?void 0:I.length)||0})]}),z==="tenants"?e.jsx(Oa,{className:"w-4 h-4"}):e.jsx(Ao,{className:"w-4 h-4"})]})}),e.jsx(ki,{children:e.jsx("div",{className:"max-h-[300px] overflow-y-auto",children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading..."}),children:e.jsx(QI,{isAdmin:t,initialExpandedId:J,onNavigateToProperty:c,onViewOnMap:u,onToggleCrmVisibility:i,visibleTenantIds:y})})})})]})]})]})]})},Wp=({src:t,alt:s,className:n,fallbackClassName:a})=>{const[l,c]=k.useState(!1),[u,i]=k.useState(!0);return!t||l?e.jsx("div",{className:fs("flex items-center justify-center bg-muted rounded",a||n),title:s,children:e.jsx(Sc,{className:"w-1/2 h-1/2 text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[u&&e.jsx("div",{className:fs("animate-pulse bg-muted rounded",n)}),e.jsx("img",{src:t,alt:s,className:fs(n,u&&"hidden"),onError:()=>c(!0),onLoad:()=>i(!1)})]})},e4=["completed","construction","planned","approved"],t4=["singles","townhomes","apartments","industrial","retail","mixed_use","medical","data_centers"],BN={singles:e.jsx(qd,{className:"w-4 h-4"}),townhomes:e.jsx(pm,{className:"w-4 h-4"}),apartments:e.jsx(Ci,{className:"w-4 h-4"}),industrial:e.jsx(Ig,{className:"w-4 h-4"}),retail:e.jsx(fp,{className:"w-4 h-4"}),mixed_use:e.jsx(Da,{className:"w-4 h-4"}),medical:e.jsx(E0,{className:"w-4 h-4"}),data_centers:e.jsx(Ci,{className:"w-4 h-4"})},$N=t=>t.includes("4889 Penn")||t.includes("Penn Ave")?"Penn Avenue":t.includes("Route 422")?"Route 422":t.includes("Downtown")||t.includes("Wyomissing")?"Downtown":t.includes("Industrial")||t.includes("Business")?"Industrial Parks":t.includes("Exeter")||t.includes("Muhlenberg")?"Northern Suburbs":t.includes("Spring")||t.includes("Sinking")?"Spring Township":t.includes("Bern")||t.includes("Cumru")?"Southern Region":"Other",s4=({developments:t,existingProducts:s,selectedDevelopment:n,selectedExistingProduct:a,onSelectDevelopment:l,onSelectExistingProduct:c,filters:u,onFiltersChange:i,isLoading:_=!1,searchQuery:j="",highlightMatch:y})=>{const[x,v]=k.useState(()=>{try{const Ce=localStorage.getItem("properties-panel-open");return Ce!==null?JSON.parse(Ce):!0}catch{return!0}}),[C,P]=k.useState(()=>{try{const Ce=localStorage.getItem("properties-panel-developments-open");return Ce!==null?JSON.parse(Ce):!0}catch{return!0}}),[I,z]=k.useState(()=>{try{const Ce=localStorage.getItem("properties-panel-existing-open");return Ce!==null?JSON.parse(Ce):!0}catch{return!0}}),[F,D]=k.useState(()=>{try{return localStorage.getItem("sidebar-developments-group-by")||"none"}catch{return"none"}}),[X,K]=k.useState(()=>{try{return localStorage.getItem("sidebar-existing-sites-group-by")||"none"}catch{return"none"}}),[te,J]=k.useState(()=>{try{const Ce=localStorage.getItem("sidebar-collapsed-dev-groups");return Ce?new Set(JSON.parse(Ce)):new Set}catch{return new Set}}),[H,O]=k.useState(()=>{try{const Ce=localStorage.getItem("sidebar-collapsed-existing-groups");return Ce?new Set(JSON.parse(Ce)):new Set}catch{return new Set}}),[q,W]=k.useState(()=>{try{const Ce=localStorage.getItem("sidebar-hidden-dev-groups");return Ce?new Set(JSON.parse(Ce)):new Set}catch{return new Set}}),[Q,Z]=k.useState(()=>{try{const Ce=localStorage.getItem("sidebar-hidden-existing-groups");return Ce?new Set(JSON.parse(Ce)):new Set}catch{return new Set}}),[oe,ce]=k.useState(!1),[ae,ie]=k.useState(!1),[de,ge]=k.useState(()=>{try{const Ce=localStorage.getItem("properties-panel-filters-open");return Ce!==null?JSON.parse(Ce):!1}catch{return!1}}),We=k.useCallback(Ce=>{ge(Ce),localStorage.setItem("properties-panel-filters-open",JSON.stringify(Ce))},[]),Ee=k.useCallback(Ce=>{const Be=u.types.includes(Ce)?u.types.filter(Dt=>Dt!==Ce):[...u.types,Ce];i({...u,types:Be})},[u,i]),ve=k.useCallback(Ce=>{const Be=u.statuses.includes(Ce)?u.statuses.filter(Dt=>Dt!==Ce):[...u.statuses,Ce];i({...u,statuses:Be})},[u,i]),{data:we}=dj(),{data:Ze}=uj(),{developers:ke}=Jx(),{owners:ze}=Qx(),Ke=k.useCallback(Ce=>{v(Ce),localStorage.setItem("properties-panel-open",JSON.stringify(Ce))},[]),dt=k.useCallback(Ce=>{P(Ce),localStorage.setItem("properties-panel-developments-open",JSON.stringify(Ce))},[]),Re=k.useCallback(Ce=>{z(Ce),localStorage.setItem("properties-panel-existing-open",JSON.stringify(Ce))},[]),qt=k.useCallback(()=>{const Ce=new Map;return F==="none"?(Ce.set("All Developments",t),Ce):(t.forEach(Be=>{let Dt=[];switch(F){case"status":Dt=[_f(Be.status)];break;case"type":Dt=[op(Be.type)];break;case"area":Dt=[$N(Be.name)];break;case"tenant":const Rt=(we==null?void 0:we.get(Be.id))||[];Dt=Rt.length>0?Rt.map(_s=>{var vs;return((vs=_s.retailer_logo)==null?void 0:vs.name)||"Unknown Tenant"}):["No Tenant"];break;case"developer":const zt=ke.find(_s=>_s.id===Be.developer_id);Dt=[(zt==null?void 0:zt.name)||"No Developer"];break;case"owner":const rs=ze.find(_s=>_s.id===Be.owner_id);Dt=[(rs==null?void 0:rs.true_owner_name)||"No Owner"];break;case"county":Dt=[Be.county||"No County"];break;case"market_region":Dt=[Be.market_region||"No Market Region"];break;default:Dt=["Other"]}Dt.forEach(Rt=>{Ce.has(Rt)||Ce.set(Rt,[]),Ce.get(Rt).push(Be)})}),Ce)},[t,F,we,ke,ze]),ft=k.useCallback(()=>{const Ce=new Map;return X==="none"?(Ce.set("All Existing Sites",s),Ce):(s.forEach(Be=>{let Dt=[];switch(X){case"status":Dt=[_f(Be.status)];break;case"type":Dt=[op(Be.type)];break;case"area":Dt=[$N(Be.name)];break;case"tenant":const Rt=(Ze==null?void 0:Ze.get(Be.id))||[];Dt=Rt.length>0?Rt.map(_s=>{var vs;return((vs=_s.retailer_logo)==null?void 0:vs.name)||"Unknown Tenant"}):["No Tenant"];break;case"developer":const zt=ke.find(_s=>_s.id===Be.developer_id);Dt=[(zt==null?void 0:zt.name)||"No Developer"];break;case"owner":const rs=ze.find(_s=>_s.id===Be.owner_id);Dt=[(rs==null?void 0:rs.true_owner_name)||"No Owner"];break;case"county":Dt=[Be.county||"No County"];break;case"market_region":Dt=[Be.market_region||"No Market Region"];break;default:Dt=["Other"]}Dt.forEach(Rt=>{Ce.has(Rt)||Ce.set(Rt,[]),Ce.get(Rt).push(Be)})}),Ce)},[s,X,Ze,ke,ze]),Fe=k.useCallback((Ce,Be)=>{Be.stopPropagation();const Dt=u.hiddenDevelopmentIds.includes(Ce)?u.hiddenDevelopmentIds.filter(Rt=>Rt!==Ce):[...u.hiddenDevelopmentIds,Ce];i({...u,hiddenDevelopmentIds:Dt})},[u,i]),fe=k.useCallback((Ce,Be)=>{Be.stopPropagation();const Dt=u.hiddenExistingProductIds.includes(Ce)?u.hiddenExistingProductIds.filter(Rt=>Rt!==Ce):[...u.hiddenExistingProductIds,Ce];i({...u,hiddenExistingProductIds:Dt})},[u,i]),Qe=k.useCallback((Ce,Be,Dt)=>{Dt.stopPropagation();const Rt=q.has(Ce),zt=Be.map(rs=>rs.id);if(Rt){const rs=new Set(q);rs.delete(Ce),W(rs),localStorage.setItem("sidebar-hidden-dev-groups",JSON.stringify([...rs]));const _s=u.hiddenDevelopmentIds.filter(vs=>!zt.includes(vs));i({...u,hiddenDevelopmentIds:_s})}else{const rs=new Set(q);rs.add(Ce),W(rs),localStorage.setItem("sidebar-hidden-dev-groups",JSON.stringify([...rs]));const _s=[...new Set([...u.hiddenDevelopmentIds,...zt])];i({...u,hiddenDevelopmentIds:_s})}},[q,u,i]),ht=k.useCallback((Ce,Be,Dt)=>{Dt.stopPropagation();const Rt=Q.has(Ce),zt=Be.map(rs=>rs.id);if(Rt){const rs=new Set(Q);rs.delete(Ce),Z(rs),localStorage.setItem("sidebar-hidden-existing-groups",JSON.stringify([...rs]));const _s=u.hiddenExistingProductIds.filter(vs=>!zt.includes(vs));i({...u,hiddenExistingProductIds:_s})}else{const rs=new Set(Q);rs.add(Ce),Z(rs),localStorage.setItem("sidebar-hidden-existing-groups",JSON.stringify([...r
740s]));const _s=[...new Set([...u.hiddenExistingProductIds,...zt])];i({...u,hiddenExistingProductIds:_s})}},[Q,u,i]),_t=k.useCallback(Ce=>{const Be=new Set(te);Be.has(Ce)?Be.delete(Ce):Be.add(Ce),J(Be),localStorage.setItem("sidebar-collapsed-dev-groups",JSON.stringify([...Be]))},[te]),He=k.useCallback(Ce=>{const Be=new Set(H);Be.has(Ce)?Be.delete(Ce):Be.add(Ce),O(Be),localStorage.setItem("sidebar-collapsed-existing-groups",JSON.stringify([...Be]))},[H]),as=k.useCallback(Ce=>{const Be=u.hiddenDevelopmentIds.includes(Ce.id),Dt=(n==null?void 0:n.id)===Ce.id,Rt=(we==null?void 0:we.get(Ce.id))||[],zt=ke.find(vs=>vs.id===Ce.developer_id),rs=ze.find(vs=>vs.id===Ce.owner_id),_s=Ce.display_logo_type;return e.jsx("div",{onClick:()=>l(Dt?null:Ce),className:`
741          p-3 rounded-lg cursor-pointer transition-all border
742          ${Dt?"bg-primary/10 border-primary":"bg-card hover:bg-muted border-border"}
743          ${Be?"opacity-50":""}
744        `,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[_s==="developer"&&(zt!=null&&zt.logo_url)?e.jsx(Wp,{src:zt.logo_url,alt:zt.name,className:"w-5 h-5 rounded object-contain"}):_s==="owner"&&(rs!=null&&rs.logo_url)?e.jsx(Wp,{src:rs.logo_url,alt:rs.true_owner_name,className:"w-5 h-5 rounded object-contain"}):e.jsx("span",{className:"text-muted-foreground",children:BN[Ce.type]}),e.jsx("h4",{className:"font-medium text-sm text-foreground truncate",children:j.trim()&&y?y(Ce.name,j):Ce.name})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Mt,{variant:"outline",className:"text-xs",style:{borderColor:Rm(Ce.status),color:Rm(Ce.status)},children:_f(Ce.status)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Ce.type==="mixed_use"?`${Ce.units||0} units • ${(Ce.square_footage||0).toLocaleString()} SF`:zy(Ce.type)?`${(Ce.square_footage||0).toLocaleString()} SF`:`${Ce.units||0} units`}),Ce.year&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["• ",Ce.year]})]}),Rt.length>0&&e.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[Rt.slice(0,3).map((vs,$t)=>{var Ns,Ts;return e.jsx(Wp,{src:(Ns=vs.retailer_logo)==null?void 0:Ns.logo_url,alt:((Ts=vs.retailer_logo)==null?void 0:Ts.name)||"Tenant",className:"w-5 h-5 rounded object-contain bg-white"},$t)}),Rt.length>3&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",Rt.length-3]})]})]}),e.jsx("button",{onClick:vs=>Fe(Ce.id,vs),className:"p-1 hover:bg-muted rounded text-muted-foreground hover:text-foreground",children:Be?e.jsx(Wc,{className:"w-4 h-4"}):e.jsx(kc,{className:"w-4 h-4"})})]})},Ce.id)},[u.hiddenDevelopmentIds,n,we,ke,ze,l,j,y,Fe]),vt=k.useCallback(Ce=>{const Be=u.hiddenExistingProductIds.includes(Ce.id),Dt=(a==null?void 0:a.id)===Ce.id,Rt=(Ze==null?void 0:Ze.get(Ce.id))||[],zt=ke.find(vs=>vs.id===Ce.developer_id),rs=ze.find(vs=>vs.id===Ce.owner_id),_s=Ce.display_logo_type;return e.jsx("div",{onClick:()=>c==null?void 0:c(Dt?null:Ce),className:`
745          p-3 rounded-lg cursor-pointer transition-all border
746          ${Dt?"bg-cyan-500/10 border-cyan-500":"bg-card hover:bg-muted border-border"}
747          ${Be?"opacity-50":""}
748        `,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[_s==="developer"&&(zt!=null&&zt.logo_url)?e.jsx(Wp,{src:zt.logo_url,alt:zt.name,className:"w-5 h-5 rounded object-contain"}):_s==="owner"&&(rs!=null&&rs.logo_url)?e.jsx(Wp,{src:rs.logo_url,alt:rs.true_owner_name,className:"w-5 h-5 rounded object-contain"}):e.jsx("span",{className:"text-cyan-500",children:BN[Ce.type]}),e.jsx("h4",{className:"font-medium text-sm text-foreground truncate",children:j.trim()&&y?y(Ce.name,j):Ce.name})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Mt,{variant:"outline",className:"text-xs border-cyan-500/50 text-cyan-600 dark:text-cyan-400",children:_f(Ce.status)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Ce.type==="mixed_use"?`${Ce.units||0}
748 units • ${(Ce.square_footage||0).toLocaleString()} SF`:zy(Ce.type)?`${(Ce.square_footage||0).toLocaleString()} SF`:`${Ce.units||0} units`}),Ce.year&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["• ",Ce.year]})]}),Rt.length>0&&e.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[Rt.slice(0,3).map((vs,$t)=>{var Ns,Ts;return e.jsx(Wp,{src:(Ns=vs.retailer_logo)==null?void 0:Ns.logo_url,alt:((Ts=vs.retailer_logo)==null?void 0:Ts.name)||"Tenant",className:"w-5 h-5 rounded object-contain bg-white"},$t)}),Rt.length>3&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",Rt.length-3]})]})]}),e.jsx("button",{onClick:vs=>fe(Ce.id,vs),className:"p-1 hover:bg-muted rounded text-muted-foreground hover:text-foreground",children:Be?e.jsx(Wc,{className:"w-4 h-4"}):e.jsx(kc,{className:"w-4 h-4"})})]})},Ce.id)},[u.hiddenExistingProductIds,a,Ze,ke,ze,c,j,y,fe]),Xe=()=>e.jsx("div",{className:"space-y-2",children:[...Array(3)].map((Ce,Be)=>e.jsx("div",{className:"p-3 rounded-lg border border-border bg-card",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(du,{className:"w-4 h-4 rounded"}),e.jsx(du,{className:"h-4 w-32"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(du,{className:"h-5 w-20 rounded-full"}),e.jsx(du,{className:"h-3 w-16"})]})]}),e.jsx(du,{className:"w-6 h-6 rounded"})]})},Be))});return e.jsxs(wi,{open:x,onOpenChange:Ke,children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",className:"w-full justify-between px-4 py-2 h-auto border-b border-border",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(mp,{className:"w-4 h-4 text-primary"}),"Properties (",t.length+s.length,")"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Ci,{className:"w-3 h-3 text-amber-500"}),e.jsx("span",{children:t.length}),e.jsx(Sc,{className:"w-3 h-3 text-cyan-500 ml-1"}),e.jsx("span",{children:s.length})]}),x?e.jsx(Oa,{className:"w-4 h-4"}):e.jsx(Ao,{className:"w-4 h-4"})]})]})}),e.jsxs(ki,{className:"space-y-0",children:[e.jsxs(wi,{open:de,onOpenChange:We,children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",className:"w-full justify-between px-4 py-1.5 h-auto border-b border-border/50 bg-muted/30",children:[e.jsxs("span",{className:"flex items-center gap-2 text-xs font-medium",children:[e.jsx(wg,{className:"w-3.5 h-3.5 text-muted-foreground"}),"Filters & Display",(u.types.length>0||u.statuses.length>0)&&e.jsx(Mt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:u.types.length+u.statuses.length})]}),de?e.jsx(Oa,{className:"w-3.5 h-3.5"}):e.jsx(Ao,{className:"w-3.5 h-3.5"})]})}),e.jsxs(ki,{className:"px-4 py-3 space-y-3 border-b border-border/50",children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-xs text-muted-foreground mb-2 block",children:"Property Types"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:t4.map(Ce=>e.jsx(Mt,{variant:u.types.includes(Ce)?"default":"outline",className:"cursor-pointer text-xs",onClick:()=>Ee(Ce),children:op(Ce)},Ce))})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs text-muted-foreground mb-2 block",children:"Status"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:e4.map(Ce=>e.jsx(Mt,{variant:u.statuses.includes(Ce)?"default":"outline",className:"cursor-pointer text-xs",onClick:()=>ve(Ce),style:u.statuses.includes(Ce)?{backgroundColor:Rm(Ce),borderColor:Rm(Ce)}:{borderColor:Rm(Ce),color:Rm(Ce)},children:_f(Ce)},Ce))})]})]})]}),e.jsxs(wi,{open:C,onOpenChange:dt,children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",className:"w-full justify-between px-4 py-1.5 h-auto border-b border-border/50 bg-muted/30",children:[e.jsxs("span",{className:"flex items-center gap-2 text-xs font-medium",children:[e.jsx(Ci,{className:"w-3.5 h-3.5 text-amber-500"}),"New Developments (",t.length,")"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kt,{checked:u.showDevelopments,onCheckedChange:Ce=>{i({...u,showDevelopments:Ce})},onClick:Ce=>Ce.stopPropagation(),className:"scale-75"}),C?e.jsx(Oa,{className:"w-3.5 h-3.5"}):e.jsx(Ao,{className:"w-3.5 h-3.5"})]})]})}),e.jsxs(ki,{className:"px-4 py-2 space-y-2",children:[e.jsxs("div",{className:"pb-2 border-b border-border flex items-center gap-2",children:[e.jsxs(rt,{value:F,onValueChange:Ce=>{const Be=Ce;D(Be),ce(!1),localStorage.setItem("sidebar-developments-group-by",Be)},children:[e.jsxs(it,{className:"flex-1 h-8 text-xs",children:[e.jsx(Da,{className:"w-3 h-3 mr-1"}),e.jsx(ct,{placeholder:"Group by..."})]}),e.jsxs(ot,{children:[e.jsx(le,{value:"none",children:"No Grouping"}),e.jsx(le,{value:"status",children:"Status"}),e.jsx(le,{value:"type",children:"Property Type"}),e.jsx(le,{value:"area",children:"Area"}),e.jsx(le,{value:"tenant",children:"Tenant"}),e.jsx(le,{value:"developer",children:"Developer"}),e.jsx(le,{value:"owner",children:"Owner"}),e.jsx(le,{value:"county",children:"County"}),e.jsx(le,{value:"market_region",children:"Market Region"})]})]}),F!=="none"&&e.jsx(Le,{variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>{const Ce=Array.from(qt().keys());oe?(J(new Set),localStorage.setItem("sidebar-collapsed-dev-groups",JSON.stringify([]))):(J(new Set(Ce)),localStorage.setItem("sidebar-collapsed-dev-groups",JSON.stringify(Ce))),ce(!oe)},title:oe?"Expand all groups":"Collapse all groups",children:oe?e.jsx(Ao,{className:"w-4 h-4"}):e.jsx(Oa,{className:"w-4 h-4"})})]}),_?e.jsx(Xe,{}):F==="none"?e.jsx("div",{className:"space-y-2",children:t.map(Ce=>as(Ce))}):Array.from(qt().entries()).map(([Ce,Be])=>{const Dt=te.has(Ce),Rt=q.has(Ce);return e.jsxs("div",{className:`${Rt?"opacity-50":""}`,children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[e.jsxs("button",{onClick:()=>_t(Ce),className:"flex items-center gap-2 flex-1 text-left font-medium text-sm hover:text-primary",children:[Dt?e.jsx(Ao,{className:"w-4 h-4"}):e.jsx(Oa,{className:"w-4 h-4"}),Ce," (",Be.length,")"]}),e.jsx("button",{onClick:zt=>Qe(Ce,Be,zt),className:"p-1 hover:bg-muted rounded text-muted-foreground hover:text-foreground",title:Rt?"Show group on map":"Hide group from map",children:Rt?e.jsx(Wc,{className:"w-4 h-4"}):e.jsx(kc,{className:"w-4 h-4"})})]}),!Dt&&e.jsx("div",{className:"space-y-2 ml-2",children:Be.map(zt=>as(zt))})]},Ce)}),!_&&t.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-4 text-sm",children:"No developments found"})]})]}),e.jsxs(wi,{open:I,onOpenChange:Re,children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",className:"w-full justify-between px-4 py-1.5 h-auto border-b border-border/50 bg-muted/30",children:[e.jsxs("span",{className:"flex items-center gap-2 text-xs font-medium",children:[e.jsx(Sc,{className:"w-3.5 h-3.5 text-cyan-500"}),"Existing Sites (",s.length,")"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kt,{checked:u.showExistingProducts,onCheckedChange:Ce=>{i({...u,showExistingProducts:Ce})},onClick:Ce=>Ce.stopPropagation(),className:"scale-75"}),I?e.jsx(Oa,{className:"w-3.5 h-3.5"}):e.jsx(Ao,{className:"w-3.5 h-3.5"})]})]})}),e.jsxs(ki,{className:"px-4 py-2 space-y-2",children:[e.jsx("div",{className:"flex flex-wrap gap-1 pb-2 border-b border-border",children:[{value:"all",label:"All"},{value:"retail",label:"Retail"},{value:"industrial",label:"Industrial"},{value:"apartments",label:"Multi-Family"},{value:"mixed_use",label:"Mixed-Use"},{value:"medical",label:"Medical"}].map(({value:Ce,label:Be})=>e.jsx(Mt,{variant:(u.existingSiteType||"all")===Ce?"default":"outline",className:"cursor-pointer text-xs",onClick:()=>i({...u,existingSiteType:Ce}),children:Be},Ce))}),e.jsxs("div",{className:"pb-2 border-b border-border flex items-center gap-2",children:[e.jsxs(rt,{value:X,onValueChange:Ce=>{const Be=Ce;K(Be),ie(!1),localStorage.setItem("sidebar-existing-sites-group-by",Be)},children:[e.jsxs(it,{className:"flex-1 h-8 text-xs",children:[e.jsx(Da,{className:"w-3 h-3 mr-1"}),e.jsx(ct,{placeholder:"Group by..."})]}),e.jsxs(ot,{children:[e.jsx(le,{value:"none",children:"No Grouping"}),e.jsx(le,{value:"status",children:"Status"}),e.jsx(le,{value:"type",children:"Property Type"}),e.jsx(le,{value:"area",children:"Area"}),e.jsx(le,{value:"tenant",children:"Tenant"}),e.jsx(le,{value:"developer",children:"Developer"}),e.jsx(le,{value:"owner",children:"Owner"}),e.jsx(le,{value:"county",children:"County"}),e.jsx(le,{value:"market_region",children:"Market Region"})]})]}),X!=="none"&&e.jsx(Le,{variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>
748{const Ce=Array.from(ft().keys());ae?(O(new Set),localStorage.setItem("sidebar-collapsed-existing-groups",JSON.stringify([]))):(O(new Set(Ce)),localStorage.setItem("sidebar-collapsed-existing-groups",JSON.stringify(Ce))),ie(!ae)},title:ae?"Expand all groups":"Collapse all groups",children:ae?e.jsx(Ao,{className:"w-4 h-4"}):e.jsx(Oa,{className:"w-4 h-4"})})]}),_?e.jsx(Xe,{}):X==="none"?e.jsx("div",{className:"space-y-2",children:s.map(Ce=>vt(Ce))}):Array.from(ft().entries()).map(([Ce,Be])=>{const Dt=H.has(Ce),Rt=Q.has(Ce);return e.jsxs("div",{className:`${Rt?"opacity-50":""}`,children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[e.jsxs("button",{onClick:()=>He(Ce),className:"flex items-center gap-2 flex-1 text-left font-medium text-sm hover:text-primary",children:[Dt?e.jsx(Ao,{className:"w-4 h-4"}):e.jsx(Oa,{className:"w-4 h-4"}),Ce," (",Be.length,")"]}),e.jsx("button",{onClick:zt=>ht(Ce,Be,zt),className:"p-1 hover:bg-muted rounded text-muted-foreground hover:text-foreground",title:Rt?"Show group on map":"Hide group from map",children:Rt?e.jsx(Wc,{className:"w-4 h-4"}):e.jsx(kc,{className:"w-4 h-4"})})]}),!Dt&&e.jsx("div",{className:"space-y-2 ml-2",children:Be.map(zt=>vt(zt))})]},Ce)}),!_&&s.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-4 text-sm",children:"No existing sites found"})]})]})]})]})},Lv=t=>t>=1e6?`$${(t/1e6).toFixed(1)}M`:t>=1e3?`$${(t/1e3).toFixed(0)}K`:`$${t.toFixed(0)}`,n4=({assemblages:t,isLoading:s,onSelect:n,onDelete:a,isDeleting:l=!1,selectedAssemblageId:c})=>{const{preferences:u,updateAssemblagesPanelExpanded:i}=Kx(),[_,j]=k.useState(u.assemblagesPanelExpanded??!0),[y,x]=k.useState(""),[v,C]=k.useState(null),[P,I]=k.useState(!1);k.useEffect(()=>{u.assemblagesPanelExpanded!==void 0&&j(u.assemblagesPanelExpanded)},[u.assemblagesPanelExpanded]);const z=ie=>{j(ie),i(ie)},[F,D]=k.useState("all"),[X,K]=k.useState(0),[te,J]=k.useState(1e3),[H,O]=k.useState(0),[q,W]=k.useState(1e8),{maxAssemblageAcres:Q,maxAssemblageValue:Z}=k.useMemo(()=>{const ie=t.map(ge=>ge.total_acres||0),de=t.map(ge=>ge.total_market_value||0);return{maxAssemblageAcres:Math.max(...ie,100),maxAssemblageValue:Math.max(...de,1e6)}},[t]),oe=k.useMemo(()=>t.filter(ie=>{var We;if(y.trim()){const Ee=y.toLowerCase(),ve=ie.name.toLowerCase().includes(Ee),we=(We=ie.description)==null?void 0:We.toLowerCase().includes(Ee);if(!ve&&!we)return!1}if(F!=="all"){const Ee=G5(ie.created_at),ve=new Date;let we;switch(F){case"today":we=H5(ve,1);break;case"week":we=YI(ve,1);break;case"month":we=Yw(ve,1);break;case"3months":we=Yw(ve,3);break;default:we=new Date(0)}if(Z5(Ee,we))return!1}const de=ie.total_acres||0;if(de<X||de>te)return!1;const ge=ie.total_market_value||0;return!(ge<H||ge>q)}),[t,y,F,X,te,H,q]),ce=F!=="all"||X>0||te<Q||H>0||q<Z,ae=()=>{D("all"),K(0),J(Q),O(0),W(Z)};return e.jsxs(e.Fragment,{children:[e.jsxs(wi,{open:_,onOpenChange:z,children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",className:"w-full justify-between px-4 py-2 h-auto border-b border-border",children:[e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Da,{className:"w-4 h-4 text-orange-500"}),"Assemblages (",oe.length,")"]})}),e.jsx(or,{side:"right",children:"AssemblagesSidebarPanel"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ce&&e.jsx(Mt,{variant:"secondary",className:"text-xs",children:"Filtered"}),_?e.jsx(Oa,{className:"w-4 h-4"}):e.jsx(Ao,{className:"w-4 h-4"})]})]})}),e.jsxs(ki,{className:"px-4 py-2 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ld,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),e.jsx(be,{placeholder:"Search assemblages...",value:y,onChange:ie=>x(ie.target.value),className:"pl-8 h-8 text-xs"}),y&&e.jsx("button",{onClick:()=>x(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(ja,{className:"w-3 h-3"})})]}),e.jsxs(Ef,{open:P,onOpenChange:I,children:[e.jsx(Pf,{asChild:!0,children:e.jsx(Le,{variant:ce?"default":"outline",size:"sm",className:"h-8 px-2",children:e.jsx(O3,{className:"w-3.5 h-3.5"})})}),e.jsx(Tf,{className:"w-72",align:"end",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Filters"}),ce&&e.jsx(Le,{variant:"ghost",size:"sm",onClick:ae,className:"h-7 text-xs",children:"Clear all"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Date Created"}),e.jsxs(rt,{value:F,onValueChange:ie=>D(ie),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"all",children:"All time"}),e.jsx(le,{value:"today",children:"Today"}),e.jsx(le,{value:"week",children:"This week"}),e.jsx(le,{value:"month",children:"This month"}),e.jsx(le,{value:"3months",children:"Last 3 months"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{className:"text-xs",children:["Acres: ",X.toFixed(1)," - ",te.toFixed(1)]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Ca,{value:[X,te],min:0,max:Q,step:1,onValueChange:([ie,de])=>{K(ie),J(de)},className:"flex-1"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{className:"text-xs",children:["Market Value: ",Lv(H)," - ",Lv(q)]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Ca,{value:[H,q],min:0,max:Z,step:1e4,onValueChange:([ie,de])=>{O(ie),W(de)},className:"flex-1"})})]})]})})]})]}),e.jsx(Xc,{className:"max-h-[400px]",children:e.jsx("div",{className:"space-y-2 pr-2",children:s?[...Array(3)].map((ie,de)=>e.jsxs("div",{className:"p-3 rounded-lg border border-border bg-card",children:[e.jsx(du,{className:"h-4 w-3/4 mb-2"}),e.jsx(du,{className:"h-3 w-1/2"})]},de)):oe.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-6 text-sm",children:y||ce?"No assemblages match your filters":"No saved assemblages yet"}):oe.map(ie=>e.jsxs("div",{className:`p-3 rounded-lg border transition-colors cursor-pointer ${c===ie.id?"border-orange-500 bg-orange-500/10":"border-border bg-card hover:bg-accent/50"}`,onClick:()=>n(ie),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-sm truncate",children:ie.name}),ie.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:ie.description})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:de=>{de.stopPropagation(),n(ie)},title:"View assemblage",children:e.jsx(kc,{className:"w-3.5 h-3.5"})}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive hover:text-destructive",onClick:de=>{de.stopPropagation(),C(ie.id)},title:"Delete assemblage",children:e.jsx(wr,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Da,{className:"w-3 h-3"}),ie.parcel_count]}),ie.total_acres&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Il,{className:"w-3 h-3"}),ie.total_acres.toFixed(2)," ac"]}),ie.total_market_value&&ie.total_market_value>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Vd,{className:"w-3 h-3"}),Lv(ie.total_market_value)]})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-1.5 text-xs text-muted-foreground",children:[e.jsx(kf,{className:"w-3 h-3"}),M1(new Date(ie.created_at),{addSuffix:!0})]})]},ie.id))})})]})]}),e.jsx(R1,{open:!!v,onOpenChange:()=>C(null),children:e.jsxs(F1,{children:[e.jsxs(z1,{children:[e.jsx(O1,{children:"Delete Assemblage?"}),e.jsx(B1,{children:"This will permanently delete this saved assemblage. This action cannot be undone."})]}),e.jsxs($1,{children:[e.jsx(V1,{disabled:l,children:"Cancel"}),e.jsx(q1,{onClick:()=>{v&&(a(v),C(null))},disabled:l,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:l?"Deleting...":"Delete"})]})]})})]})};function a4(){for(var t=arguments.length,s=new Array(t),n=0;n<t;n++)s[n]=arguments[n];return k.useMemo(()=>a=>
748{s.forEach(l=>l(a))},s)}const A0=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function zg(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function hj(t){return"nodeType"in t}function gu(t){var s,n;return t?zg(t)?t:hj(t)&&(s=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?s:window:window}function mj(t){const{Document:s}=gu(t);return t instanceof s}function d_(t){return zg(t)?!1:t instanceof gu(t).HTMLElement}function sE(t){return t instanceof gu(t).SVGElement}function Og(t){return t?zg(t)?t.document:hj(t)?mj(t)?t:d_(t)||sE(t)?t.ownerDocument:document:document:document}const gm=A0?k.useLayoutEffect:k.useEffect;function fj(t){const s=k.useRef(t);return gm(()=>{s.current=t}),k.useCallback(function(){for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return s.current==null?void 0:s.current(...a)},[])}function r4(){const t=k.useRef(null),s=k.useCallback((a,l)=>{t.current=setInterval(a,l)},[]),n=k.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,n]}function Vx(t,s){s===void 0&&(s=[t]);const n=k.useRef(t);return gm(()=>{n.current!==t&&(n.current=t)},s),n}function u_(t,s){const n=k.useRef();return k.useMemo(()=>{const a=t(n.current);return n.current=a,a},[...s])}function Uy(t){const s=fj(t),n=k.useRef(null),a=k.useCallback(l=>{l!==n.current&&(s==null||s(l,n.current)),n.current=l},[]);return[n,a]}function Zb(t){const s=k.useRef();return k.useEffect(()=>{s.current=t},[t]),s.current}let Mv={};function h_(t,s){return k.useMemo(()=>{if(s)return s;const n=Mv[t]==null?0:Mv[t]+1;return Mv[t]=n,t+"-"+n},[t,s])}function nE(t){return function(s){for(var n=arguments.length,a=new Array(n>1?n-1:0),l=1;l<n;l++)a[l-1]=arguments[l];return a.reduce((c,u)=>{const i=Object.entries(u);for(const[_,j]of i){const y=c[_];y!=null&&(c[_]=y+t*j)}return c},{...s})}}const hg=nE(1),qx=nE(-1);function i4(t){return"clientX"in t&&"clientY"in t}function pj(t){if(!t)return!1;const{KeyboardEvent:s}=gu(t.target);return s&&t instanceof s}function o4(t){if(!t)return!1;const{TouchEvent:s}=gu(t.target);return s&&t instanceof s}function Wb(t){if(o4(t)){if(t.touches&&t.touches.length){const{clientX:s,clientY:n}=t.touches[0];return{x:s,y:n}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:s,clientY:n}=t.changedTouches[0];return{x:s,y:n}}}return i4(t)?{x:t.clientX,y:t.clientY}:null}const _p=Object.freeze({Translate:{toString(t){if(!t)return;const{x:s,y:n}=t;return"translate3d("+(s?Math.round(s):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:s,scaleY:n}=t;return"scaleX("+s+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[_p.Translate.toString(t),_p.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:n,easing:a}=t;return s+" "+n+"ms "+a}}}),VN="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function l4(t){return t.matches(VN)?t:t.querySelector(VN)}const c4={display:"none"};function d4(t){let{id:s,value:n}=t;return Do.createElement("div",{id:s,style:c4},n)}function u4(t){let{id:s,announcement:n,ariaLiveType:a="assertive"}=t;const l={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Do.createElement("div",{id:s,style:l,role:"status","aria-live":a,"aria-atomic":!0},n)}function h4(){const[t,s]=k.useState("");return{announce:k.useCallback(a=>{a!=null&&s(a)},[]),announcement:t}}const aE=k.createContext(null);function m4(t){const s=k.useContext(aE);k.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(t)},[t,s])}function f4(){const[t]=k.useState(()=>new Set),s=k.useCallback(a=>(t.add(a),()=>t.delete(a)),[t]);return[k.useCallback(a=>{let{type:l,event:c}=a;t.forEach(u=>{var i;return(i=u[l])==null?void 0:i.call(u,c)})},[t]),s]}const p4={draggable:`
749    To pick up a draggable item, press the space bar.
750    While dragging, use the arrow keys to move the item.
751    Press space again to drop the item in its new position, or press escape to cancel.
752  `},g4={onDragStart(t){let{active:s}=t;return"Picked up draggable item "+s.id+"."},onDragOver(t){let{active:s,over:n}
752=t;return n?"Draggable item "+s.id+" was moved over droppable area "+n.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(t){let{active:s,over:n}=t;return n?"Draggable item "+s.id+" was dropped over droppable area "+n.id:"Draggable item "+s.id+" was dropped."},onDragCancel(t){let{active:s}=t;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function x4(t){let{announcements:s=g4,container:n,hiddenTextDescribedById:a,screenReaderInstructions:l=p4}=t;const{announce:c,announcement:u}=h4(),i=h_("DndLiveRegion"),[_,j]=k.useState(!1);if(k.useEffect(()=>{j(!0)},[]),m4(k.useMemo(()=>({onDragStart(x){let{active:v}=x;c(s.onDragStart({active:v}))},onDragMove(x){let{active:v,over:C}=x;s.onDragMove&&c(s.onDragMove({active:v,over:C}))},onDragOver(x){let{active:v,over:C}=x;c(s.onDragOver({active:v,over:C}))},onDragEnd(x){let{active:v,over:C}=x;c(s.onDragEnd({active:v,over:C}))},onDragCancel(x){let{active:v,over:C}=x;c(s.onDragCancel({active:v,over:C}))}}),[c,s])),!_)return null;const y=Do.createElement(Do.Fragment,null,Do.createElement(d4,{id:a,value:l.draggable}),Do.createElement(u4,{id:i,announcement:u}));return n?mx.createPortal(y,n):y}var wc;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(wc||(wc={}));function e0(){}function t0(t,s){return k.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function rE(){for(var t=arguments.length,s=new Array(t),n=0;n<t;n++)s[n]=arguments[n];return k.useMemo(()=>[...s].filter(a=>a!=null),[...s])}const zh=Object.freeze({x:0,y:0});function iE(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function oE(t,s){let{data:{value:n}}=t,{data:{value:a}}=s;return n-a}function _4(t,s){let{data:{value:n}}=t,{data:{value:a}}=s;return a-n}function qN(t){let{left:s,top:n,height:a,width:l}=t;return[{x:s,y:n},{x:s+l,y:n},{x:s,y:n+a},{x:s+l,y:n+a}]}function lE(t,s){if(!t||t.length===0)return null;const[n]=t;return n[s]}function GN(t,s,n){return s===void 0&&(s=t.left),n===void 0&&(n=t.top),{x:s+t.width*.5,y:n+t.height*.5}}const cE=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:a}=t;const l=GN(s,s.left,s.top),c=[];for(const u of a){const{id:i}=u,_=n.get(i);if(_){const j=iE(GN(_),l);c.push({id:i,data:{droppableContainer:u,value:j}})}}return c.sort(oE)},y4=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:a}=t;const l=qN(s),c=[];for(const u of a){const{id:i}=u,_=n.get(i);if(_){const j=qN(_),y=l.reduce((v,C,P)=>v+iE(j[P],C),0),x=Number((y/4).toFixed(4));c.push({id:i,data:{droppableContainer:u,value:x}})}}return c.sort(oE)};function v4(t,s){const n=Math.max(s.top,t.top),a=Math.max(s.left,t.left),l=Math.min(s.left+s.width,t.left+t.width),c=Math.min(s.top+s.height,t.top+t.height),u=l-a,i=c-n;if(a<l&&n<c){const _=s.width*s.height,j=t.width*t.height,y=u*i,x=y/(_+j-y);return Number(x.toFixed(4))}return 0}const b4=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:a}=t;const l=[];for(const c of a){const{id:u}=c,i=n.get(u);if(i){const _=v4(i,s);_>0&&l.push({id:u,data:{droppableContainer:c,value:_}})}}return l.sort(_4)};function j4(t,s,n){return{...t,scaleX:s&&n?s.width/n.width:1,scaleY:s&&n?s.height/n.height:1}}function dE(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:zh}function w4(t){return function(n){for(var a=arguments.length,l=new Array(a>1?a-1:0),c=1;c<a;c++)l[c-1]=arguments[c];return l.reduce((u,i)=>({...u,top:u.top+t*i.y,bottom:u.bottom+t*i.y,left:u.left+t*i.x,right:u.right+t*i.x}),{...n})}}const N4=w4(1);function k4(t){if(t.startsWith("matrix3d(")){const s=t.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(t.startsWith("matrix(")){const s=t.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function C4(t,s,n){const a=k4(s);if(!a)return t;const{scaleX:l,scaleY:c,x:u,y:i}=a,_=t.left-u-(1-l)*parseFloat(n),j=t.top-i-(1-c)*parseFloat(n.slice(n.indexOf(" ")+1)),y=l?t.width/l:t.width,x=c?t.height/c:t.height;
752return{width:y,height:x,top:j,right:_+y,bottom:j+x,left:_}}const S4={ignoreTransform:!1};function Bg(t,s){s===void 0&&(s=S4);let n=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:j,transformOrigin:y}=gu(t).getComputedStyle(t);j&&(n=C4(n,j,y))}const{top:a,left:l,width:c,height:u,bottom:i,right:_}=n;return{top:a,left:l,width:c,height:u,bottom:i,right:_}}function HN(t){return Bg(t,{ignoreTransform:!0})}function E4(t){const s=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:s,bottom:n,width:s,height:n}}function P4(t,s){return s===void 0&&(s=gu(t).getComputedStyle(t)),s.position==="fixed"}function T4(t,s){s===void 0&&(s=gu(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(l=>{const c=s[l];return typeof c=="string"?n.test(c):!1})}function D0(t,s){const n=[];function a(l){if(s!=null&&n.length>=s||!l)return n;if(mj(l)&&l.scrollingElement!=null&&!n.includes(l.scrollingElement))return n.push(l.scrollingElement),n;if(!d_(l)||sE(l)||n.includes(l))return n;const c=gu(t).getComputedStyle(l);return l!==t&&T4(l,c)&&n.push(l),P4(l,c)?n:a(l.parentNode)}return t?a(t):n}function uE(t){const[s]=D0(t,1);return s??null}function Iv(t){return!A0||!t?null:zg(t)?t:hj(t)?mj(t)||t===Og(t).scrollingElement?window:d_(t)?t:null:null}function hE(t){return zg(t)?t.scrollX:t.scrollLeft}function mE(t){return zg(t)?t.scrollY:t.scrollTop}function Yb(t){return{x:hE(t),y:mE(t)}}var Zc;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Zc||(Zc={}));function fE(t){return!A0||!t?!1:t===document.scrollingElement}function pE(t){const s={x:0,y:0},n=fE(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},a={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},l=t.scrollTop<=s.y,c=t.scrollLeft<=s.x,u=t.scrollTop>=a.y,i=t.scrollLeft>=a.x;return{isTop:l,isLeft:c,isBottom:u,isRight:i,maxScroll:a,minScroll:s}}const L4={x:.2,y:.2};function M4(t,s,n,a,l){let{top:c,left:u,right:i,bottom:_}=n;a===void 0&&(a=10),l===void 0&&(l=L4);const{isTop:j,isBottom:y,isLeft:x,isRight:v}=pE(t),C={x:0,y:0},P={x:0,y:0},I={height:s.height*l.y,width:s.width*l.x};return!j&&c<=s.top+I.height?(C.y=Zc.Backward,P.y=a*Math.abs((s.top+I.height-c)/I.height)):!y&&_>=s.bottom-I.height&&(C.y=Zc.Forward,P.y=a*Math.abs((s.bottom-I.height-_)/I.height)),!v&&i>=s.right-I.width?(C.x=Zc.Forward,P.x=a*Math.abs((s.right-I.width-i)/I.width)):!x&&u<=s.left+I.width&&(C.x=Zc.Backward,P.x=a*Math.abs((s.left+I.width-u)/I.width)),{direction:C,speed:P}}function I4(t){if(t===document.scrollingElement){const{innerWidth:c,innerHeight:u}=window;return{top:0,left:0,right:c,bottom:u,width:c,height:u}}const{top:s,left:n,right:a,bottom:l}=t.getBoundingClientRect();return{top:s,left:n,right:a,bottom:l,width:t.clientWidth,height:t.clientHeight}}function gE(t){return t.reduce((s,n)=>hg(s,Yb(n)),zh)}function A4(t){return t.reduce((s,n)=>s+hE(n),0)}function D4(t){return t.reduce((s,n)=>s+mE(n),0)}function R4(t,s){if(s===void 0&&(s=Bg),!t)return;const{top:n,left:a,bottom:l,right:c}=s(t);uE(t)&&(l<=0||c<=0||n>=window.innerHeight||a>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const F4=[["x",["left","right"],A4],["y",["top","bottom"],D4]];class gj{constructor(s,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const a=D0(n),l=gE(a);this.rect={...s},this.width=s.width,this.height=s.height;for(const[c,u,i]of F4)for(const _ of u)Object.defineProperty(this,_,{get:()=>{const j=i(a),y=l[c]-j;return this.rect[_]+y},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Cx{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var a;return(a=this.target)==null?void 0:a.removeEventListener(...n)})},this.target=s}add(s,n,a){var l;(l=this.target)==null||l.addEventListener(s,n,a),this.listeners.push([s,n,a])}}function z4(t){const{EventTarget:s}=gu(t);return t instanceof s?t:Og(t)}function Av(t,s){const n=Math.abs(t.x),a=Math.abs(t.y);return typeof s=="number"?Math.sqrt(n**2+a**2)>s:"x"in s&&"y"in s?n>s.x&&a>s.y:"x"in s?n>s.x:"y"in s?a>s.y:!1}var ch;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(ch||(ch={}));function ZN(t){t.preventDefault()}function O4(t){t.stopPropagation()}var bi;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(bi||(bi={}));const xE={start:[bi.Space,bi.Enter],cancel:[bi.Esc],end:[bi.Space,bi.Enter,bi.Tab]},B4=(t,s)=>{let{currentCoordinates:n}=s;switch(t.code){case bi.Right:return{...n,x:n.x+25};case bi.Left:return{...n,x:n.x-25};case bi.Down:return{...n,y:n.y+25};case bi.Up:return{...n,y:n.y-25}}};class R0{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:n}}=s;this.props=s,this.listeners=new Cx(Og(n)),this.windowListeners=new Cx(gu(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ch.Resize,this.handleCancel),this.windowListeners.add(ch.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ch.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:n}=this.props,a=s.node.current;a&&R4(a),n(zh)}handleKeyDown(s){if(pj(s)){const{active:n,context:a,options:l}
752=this.props,{keyboardCodes:c=xE,coordinateGetter:u=B4,scrollBehavior:i="smooth"}=l,{code:_}=s;if(c.end.includes(_)){this.handleEnd(s);return}if(c.cancel.includes(_)){this.handleCancel(s);return}const{collisionRect:j}=a.current,y=j?{x:j.left,y:j.top}:zh;this.referenceCoordinates||(this.referenceCoordinates=y);const x=u(s,{active:n,context:a.current,currentCoordinates:y});if(x){const v=qx(x,y),C={x:0,y:0},{scrollableAncestors:P}=a.current;for(const I of P){const z=s.code,{isTop:F,isRight:D,isLeft:X,isBottom:K,maxScroll:te,minScroll:J}=pE(I),H=I4(I),O={x:Math.min(z===bi.Right?H.right-H.width/2:H.right,Math.max(z===bi.Right?H.left:H.left+H.width/2,x.x)),y:Math.min(z===bi.Down?H.bottom-H.height/2:H.bottom,Math.max(z===bi.Down?H.top:H.top+H.height/2,x.y))},q=z===bi.Right&&!D||z===bi.Left&&!X,W=z===bi.Down&&!K||z===bi.Up&&!F;if(q&&O.x!==x.x){const Q=I.scrollLeft+v.x,Z=z===bi.Right&&Q<=te.x||z===bi.Left&&Q>=J.x;if(Z&&!v.y){I.scrollTo({left:Q,behavior:i});return}Z?C.x=I.scrollLeft-Q:C.x=z===bi.Right?I.scrollLeft-te.x:I.scrollLeft-J.x,C.x&&I.scrollBy({left:-C.x,behavior:i});break}else if(W&&O.y!==x.y){const Q=I.scrollTop+v.y,Z=z===bi.Down&&Q<=te.y||z===bi.Up&&Q>=J.y;if(Z&&!v.x){I.scrollTo({top:Q,behavior:i});return}Z?C.y=I.scrollTop-Q:C.y=z===bi.Down?I.scrollTop-te.y:I.scrollTop-J.y,C.y&&I.scrollBy({top:-C.y,behavior:i});break}}this.handleMove(s,hg(qx(x,this.referenceCoordinates),C))}}}handleMove(s,n){const{onMove:a}=this.props;s.preventDefault(),a(n)}handleEnd(s){const{onEnd:n}=this.props;s.preventDefault(),this.detach(),n()}handleCancel(s){const{onCancel:n}=this.props;s.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}R0.activators=[{eventName:"onKeyDown",handler:(t,s,n)=>{let{keyboardCodes:a=xE,onActivation:l}=s,{active:c}=n;const{code:u}=t.nativeEvent;if(a.start.includes(u)){const i=c.activatorNode.current;return i&&t.target!==i?!1:(t.preventDefault(),l==null||l({event:t.nativeEvent}),!0)}return!1}}];function WN(t){return!!(t&&"distance"in t)}function YN(t){return!!(t&&"delay"in t)}class xj{constructor(s,n,a){var l;a===void 0&&(a=z4(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=n;const{event:c}=s,{target:u}=c;this.props=s,this.events=n,this.document=Og(u),this.documentListeners=new Cx(this.document),this.listeners=new Cx(a),this.windowListeners=new Cx(gu(u)),this.initialCoordinates=(l=Wb(c))!=null?l:zh,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:n,bypassActivationConstraint:a}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(ch.Resize,this.handleCancel),this.windowListeners.add(ch.DragStart,ZN),this.windowListeners.add(ch.VisibilityChange,this.handleCancel),this.windowListeners.add(ch.ContextMenu,ZN),this.documentListeners.add(ch.Keydown,this.handleKeydown),n){if(a!=null&&a({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(YN(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(WN(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,n){const{active:a,onPending:l}=this.props;l(a,s,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:s}=this,{onStart:n}=this.props;s&&(this.activated=!0,this.documentListeners.add(ch.Click,O4,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ch.SelectionChange,this.removeTextSelection),n(s))}handleMove(s){var n;const{activated:a,initialCoordinates:l,props:c}=this,{onMove:u,options:{activationConstraint:i}}=c;if(!l)return;const _=(n=Wb(s))!=null?n:zh,j=qx(l,_);
752if(!a&&i){if(WN(i)){if(i.tolerance!=null&&Av(j,i.tolerance))return this.handleCancel();if(Av(j,i.distance))return this.handleStart()}if(YN(i)&&Av(j,i.tolerance))return this.handleCancel();this.handlePending(i,j);return}s.cancelable&&s.preventDefault(),u(_)}handleEnd(){const{onAbort:s,onEnd:n}=this.props;this.detach(),this.activated||s(this.props.active),n()}handleCancel(){const{onAbort:s,onCancel:n}=this.props;this.detach(),this.activated||s(this.props.active),n()}handleKeydown(s){s.code===bi.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const $4={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class F0 extends xj{constructor(s){const{event:n}=s,a=Og(n.target);super(s,$4,a)}}F0.activators=[{eventName:"onPointerDown",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:a}=s;return!n.isPrimary||n.button!==0?!1:(a==null||a({event:n}),!0)}}];const V4={move:{name:"mousemove"},end:{name:"mouseup"}};var Xb;(function(t){t[t.RightClick=2]="RightClick"})(Xb||(Xb={}));class q4 extends xj{constructor(s){super(s,V4,Og(s.event.target))}}q4.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:a}=s;return n.button===Xb.RightClick?!1:(a==null||a({event:n}),!0)}}];const Dv={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class G4 extends xj{constructor(s){super(s,Dv)}static setup(){return window.addEventListener(Dv.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Dv.move.name,s)};function s(){}}}G4.activators=[{eventName:"onTouchStart",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:a}=s;const{touches:l}=n;return l.length>1?!1:(a==null||a({event:n}),!0)}}];var Sx;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Sx||(Sx={}));var s0;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(s0||(s0={}));function H4(t){let{acceleration:s,activator:n=Sx.Pointer,canScroll:a,draggingRect:l,enabled:c,interval:u=5,order:i=s0.TreeOrder,pointerCoordinates:_,scrollableAncestors:j,scrollableAncestorRects:y,delta:x,threshold:v}=t;const C=W4({delta:x,disabled:!c}),[P,I]=r4(),z=k.useRef({x:0,y:0}),F=k.useRef({x:0,y:0}),D=k.useMemo(()=>{switch(n){case Sx.Pointer:return _?{top:_.y,bottom:_.y,left:_.x,right:_.x}:null;case Sx.DraggableRect:return l}},[n,l,_]),X=k.useRef(null),K=k.useCallback(()=>{const J=X.current;if(!J)return;const H=z.current.x*F.current.x,O=z.current.y*F.current.y;J.scrollBy(H,O)},[]),te=k.useMemo(()=>i===s0.TreeOrder?[...j].reverse():j,[i,j]);k.useEffect(()=>{if(!c||!j.length||!D){I();return}for(const J of te){if((a==null?void 0:a(J))===!1)continue;const H=j.indexOf(J),O=y[H];if(!O)continue;const{direction:q,speed:W}=M4(J,O,D,s,v);for(const Q of["x","y"])C[Q][q[Q]]||(W[Q]=0,q[Q]=0);if(W.x>0||W.y>0){I(),X.current=J,P(K,u),z.current=W,F.current=q;return}}z.current={x:0,y:0},F.current={x:0,y:0},I()},[s,K,a,I,c,u,JSON.stringify(D),JSON.stringify(C),P,j,te,y,JSON.stringify(v)])}const Z4={x:{[Zc.Backward]:!1,[Zc.Forward]:!1},y:{[Zc.Backward]:!1,[Zc.Forward]:!1}};function W4(t){let{delta:s,disabled:n}=t;const a=Zb(s);return u_(l=>{if(n||!a||!l)return Z4;const c={x:Math.sign(s.x-a.x),y:Math.sign(s.y-a.y)};return{x:{[Zc.Backward]:l.x[Zc.Backward]||c.x===-1,[Zc.Forward]:l.x[Zc.Forward]||c.x===1},y:{[Zc.Backward]:l.y[Zc.Backward]||c.y===-1,[Zc.Forward]:l.y[Zc.Forward]||c.y===1}}},[n,s,a])}function Y4(t,s){const n=s!=null?t.get(s):void 0,a=n?n.node.current:null;return u_(l=>{var c;return s==null?null:(c=a??l)!=null?c:null},[a,s])}function X4(t,s){return k.useMemo(()=>t.reduce((n,a)=>{const{sensor:l}=a,c=l.activators.map(u=>({eventName:u.eventName,handler:s(u.handler,a)}));return[...n,...c]},[]),[t,s])}var Gx;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Gx||(Gx={}));var Kb;(function(t){t.Optimized="optimized"})(Kb||(Kb={}));const XN=new Map;function K4(t,s){let{dragging:n,dependencies:a,config:l}=s;const[c,u]=k.useState(null),{frequency:i,measure:_,strategy:j}=l,y=k.useRef(t),x=z(),v=Vx(x),C=k.useCallback(function(F){F===void 0&&(F=[]),!v.current&&u(D=>D===null?F:D.concat(F.filter(X=>!D.includes(X))))},[v]),P=k.useRef(null),I=u_(F=>{if(x&&!n)return XN;if(!F||F===XN||y.current!==t||c!=null){const D=new Map;for(let X of t){if(!X)continue;if(c&&c.length>0&&!c.includes(X.id)&&X.rect.current){D.set(X.id,X.rect.current);continue}const K=X.node.current,te=K?new gj(_(K),K):null;X.rect.current=te,te&&D.set(X.id,te)}return D}return F},[t,c,n,x,_]);return k.useEffect(()=>{y.current=t},[t]),k.useEffect(()=>{x||C()},[n,x]),k.useEffect(()=>{c&&c.length>0&&u(null)},[JSON.stringify(c)]),k.useEffect(()=>{x||typeof i!="number"||P.current!==null||(P.current=setTimeout(()=>{C(),P.current=null},i))},[i,x,C,...a]),{droppableRects:I,measureDroppableContainers:C,measuringScheduled:c!=null};function z(){switch(j){case Gx.Always:return!1;case Gx.BeforeDragging:return n;default:return!n}}}function _E(t,s){return u_(n=>t?n||(typeof s=="function"?s(t):t):null,[s,t])}function J4(t,s){return _E(t,s)}function Q4(t){let{callback:s,disabled:n}=t;const a=fj(s),l=k.useMemo(()=>
752{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(a)},[a,n]);return k.useEffect(()=>()=>l==null?void 0:l.disconnect(),[l]),l}function z0(t){let{callback:s,disabled:n}=t;const a=fj(s),l=k.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(a)},[n]);return k.useEffect(()=>()=>l==null?void 0:l.disconnect(),[l]),l}function U4(t){return new gj(Bg(t),t)}function KN(t,s,n){s===void 0&&(s=U4);const[a,l]=k.useState(null);function c(){l(_=>{if(!t)return null;if(t.isConnected===!1){var j;return(j=_??n)!=null?j:null}const y=s(t);return JSON.stringify(_)===JSON.stringify(y)?_:y})}const u=Q4({callback(_){if(t)for(const j of _){const{type:y,target:x}=j;if(y==="childList"&&x instanceof HTMLElement&&x.contains(t)){c();break}}}}),i=z0({callback:c});return gm(()=>{c(),t?(i==null||i.observe(t),u==null||u.observe(document.body,{childList:!0,subtree:!0})):(i==null||i.disconnect(),u==null||u.disconnect())},[t]),a}function eA(t){const s=_E(t);return dE(t,s)}const JN=[];function tA(t){const s=k.useRef(t),n=u_(a=>t?a&&a!==JN&&t&&s.current&&t.parentNode===s.current.parentNode?a:D0(t):JN,[t]);return k.useEffect(()=>{s.current=t},[t]),n}function sA(t){const[s,n]=k.useState(null),a=k.useRef(t),l=k.useCallback(c=>{const u=Iv(c.target);u&&n(i=>i?(i.set(u,Yb(u)),new Map(i)):null)},[]);return k.useEffect(()=>{const c=a.current;if(t!==c){u(c);const i=t.map(_=>{const j=Iv(_);return j?(j.addEventListener("scroll",l,{passive:!0}),[j,Yb(j)]):null}).filter(_=>_!=null);n(i.length?new Map(i):null),a.current=t}return()=>{u(t),u(c)};function u(i){i.forEach(_=>{const j=Iv(_);j==null||j.removeEventListener("scroll",l)})}},[l,t]),k.useMemo(()=>t.length?s?Array.from(s.values()).reduce((c,u)=>hg(c,u),zh):gE(t):zh,[t,s])}function QN(t,s){s===void 0&&(s=[]);const n=k.useRef(null);return k.useEffect(()=>{n.current=null},s),k.useEffect(()=>{const a=t!==zh;a&&!n.current&&(n.current=t),!a&&n.current&&(n.current=null)},[t]),n.current?qx(t,n.current):zh}function nA(t){k.useEffect(()=>{if(!A0)return;const s=t.map(n=>{let{sensor:a}=n;return a.setup==null?void 0:a.setup()});return()=>{for(const n of s)n==null||n()}},t.map(s=>{let{sensor:n}=s;return n}))}function aA(t,s){return k.useMemo(()=>t.reduce((n,a)=>{let{eventName:l,handler:c}=a;return n[l]=u=>{c(u,s)},n},{}),[t,s])}function yE(t){return k.useMemo(()=>t?E4(t):null,[t])}const UN=[];function rA(t,s){s===void 0&&(s=Bg);const[n]=t,a=yE(n?gu(n):null),[l,c]=k.useState(UN);function u(){c(()=>t.length?t.map(_=>fE(_)?a:new gj(s(_),_)):UN)}const i=z0({callback:u});return gm(()=>{i==null||i.disconnect(),u(),t.forEach(_=>i==null?void 0:i.observe(_))},[t]),l}function iA(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return d_(s)?s:t}function oA(t){let{measure:s}=t;const[n,a]=k.useState(null),l=k.useCallback(j=>{for(const{target:y}of j)if(d_(y)){a(x=>{const v=s(y);return x?{...x,width:v.width,height:v.height}:v});break}},[s]),c=z0({callback:l}),u=k.useCallback(j=>{const y=iA(j);c==null||c.disconnect(),y&&(c==null||c.observe(y)),a(y?s(y):null)},[s,c]),[i,_]=Uy(u);return k.useMemo(()=>({nodeRef:i,rect:n,setRef:_}),[n,i,_])}const lA=[{sensor:F0,options:{}},{sensor:R0,options:{}}],cA={current:{}},wy={draggable:{measure:HN},droppable:{measure:HN,strategy:Gx.WhileDragging,frequency:Kb.Optimized},dragOverlay:{measure:Bg}};class Ex extends Map{get(s){var n;return s!=null&&(n=super.get(s))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:n}=s;return!n})}getNodeFor(s){var n,a;return(n=(a=this.get(s))==null?void 0:a.node.current)!=null?n:void 0}}const dA={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ex,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:e0},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:wy,measureDroppableContainers:e0,windowRect:null,measuringScheduled:!1},uA={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:e0,draggableNodes:new Map,over:null,measureDroppableContainers:e0},O0=k.createContext(uA),vE=k.createContext(dA);function hA(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ex}}}function mA(t,s){switch(s.type){case wc.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case wc.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:s.coordinates.x-t.draggable.initialCoordinates.x,y:s.coordinates.y-t.draggable.initialCoordinates.y}}};case wc.DragEnd:case wc.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case wc.RegisterDroppable:{const{element:n}=s,{id:a}
752=n,l=new Ex(t.droppable.containers);return l.set(a,n),{...t,droppable:{...t.droppable,containers:l}}}case wc.SetDroppableDisabled:{const{id:n,key:a,disabled:l}=s,c=t.droppable.containers.get(n);if(!c||a!==c.key)return t;const u=new Ex(t.droppable.containers);return u.set(n,{...c,disabled:l}),{...t,droppable:{...t.droppable,containers:u}}}case wc.UnregisterDroppable:{const{id:n,key:a}=s,l=t.droppable.containers.get(n);if(!l||a!==l.key)return t;const c=new Ex(t.droppable.containers);return c.delete(n),{...t,droppable:{...t.droppable,containers:c}}}default:return t}}function fA(t){let{disabled:s}=t;const{active:n,activatorEvent:a,draggableNodes:l}=k.useContext(O0),c=Zb(a),u=Zb(n==null?void 0:n.id);return k.useEffect(()=>{if(!s&&!a&&c&&u!=null){if(!pj(c)||document.activeElement===c.target)return;const i=l.get(u);if(!i)return;const{activatorNode:_,node:j}=i;if(!_.current&&!j.current)return;requestAnimationFrame(()=>{for(const y of[_.current,j.current]){if(!y)continue;const x=l4(y);if(x){x.focus();break}}})}},[a,s,l,u,c]),null}function pA(t,s){let{transform:n,...a}=s;return t!=null&&t.length?t.reduce((l,c)=>c({transform:l,...a}),n):n}function gA(t){return k.useMemo(()=>({draggable:{...wy.draggable,...t==null?void 0:t.draggable},droppable:{...wy.droppable,...t==null?void 0:t.droppable},dragOverlay:{...wy.dragOverlay,...t==null?void 0:t.dragOverlay}}),[t==null?void 0:t.draggable,t==null?void 0:t.droppable,t==null?void 0:t.dragOverlay])}function xA(t){let{activeNode:s,measure:n,initialRect:a,config:l=!0}=t;const c=k.useRef(!1),{x:u,y:i}=typeof l=="boolean"?{x:l,y:l}:l;gm(()=>{if(!u&&!i||!s){c.current=!1;return}if(c.current||!a)return;const j=s==null?void 0:s.node.current;if(!j||j.isConnected===!1)return;const y=n(j),x=dE(y,a);if(u||(x.x=0),i||(x.y=0),c.current=!0,Math.abs(x.x)>0||Math.abs(x.y)>0){const v=uE(j);v&&v.scrollBy({top:x.y,left:x.x})}},[s,u,i,a,n])}const bE=k.createContext({...zh,scaleX:1,scaleY:1});var gf;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(gf||(gf={}));const jE=k.memo(function(s){var n,a,l,c;let{id:u,accessibility:i,autoScroll:_=!0,children:j,sensors:y=lA,collisionDetection:x=b4,measuring:v,modifiers:C,...P}=s;const I=k.useReducer(mA,void 0,hA),[z,F]=I,[D,X]=f4(),[K,te]=k.useState(gf.Uninitialized),J=K===gf.Initialized,{draggable:{active:H,nodes:O,translate:q},droppable:{containers:W}}=z,Q=H!=null?O.get(H):null,Z=k.useRef({initial:null,translated:null}),oe=k.useMemo(()=>{var Gs;return H!=null?{id:H,data:(Gs=Q==null?void 0:Q.data)!=null?Gs:cA,rect:Z}:null},[H,Q]),ce=k.useRef(null),[ae,ie]=k.useState(null),[de,ge]=k.useState(null),We=Vx(P,Object.values(P)),Ee=h_("DndDescribedBy",u),ve=k.useMemo(()=>W.getEnabled(),[W]),we=gA(v),{droppableRects:Ze,measureDroppableContainers:ke,measuringScheduled:ze}=K4(ve,{dragging:J,dependencies:[q.x,q.y],config:we.droppable}),Ke=Y4(O,H),dt=k.useMemo(()=>de?Wb(de):null,[de]),Re=wn(),qt=J4(Ke,we.draggable.measure);xA({activeNode:H!=null?O.get(H):null,config:Re.layoutShiftCompensation,initialRect:qt,measure:we.draggable.measure});
752const ft=KN(Ke,we.draggable.measure,qt),Fe=KN(Ke?Ke.parentElement:null),fe=k.useRef({activatorEvent:null,active:null,activeNode:Ke,collisionRect:null,collisions:null,droppableRects:Ze,draggableNodes:O,draggingNode:null,draggingNodeRect:null,droppableContainers:W,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Qe=W.getNodeFor((n=fe.current.over)==null?void 0:n.id),ht=oA({measure:we.dragOverlay.measure}),_t=(a=ht.nodeRef.current)!=null?a:Ke,He=J?(l=ht.rect)!=null?l:ft:null,as=!!(ht.nodeRef.current&&ht.rect),vt=eA(as?null:ft),Xe=yE(_t?gu(_t):null),Ce=tA(J?Qe??Ke:null),Be=rA(Ce),Dt=pA(C,{transform:{x:q.x-vt.x,y:q.y-vt.y,scaleX:1,scaleY:1},activatorEvent:de,active:oe,activeNodeRect:ft,containerNodeRect:Fe,draggingNodeRect:He,over:fe.current.over,overlayNodeRect:ht.rect,scrollableAncestors:Ce,scrollableAncestorRects:Be,windowRect:Xe}),Rt=dt?hg(dt,q):null,zt=sA(Ce),rs=QN(zt),_s=QN(zt,[ft]),vs=hg(Dt,rs),$t=He?N4(He,Dt):null,Ns=oe&&$t?x({active:oe,collisionRect:$t,droppableRects:Ze,droppableContainers:ve,pointerCoordinates:Rt}):null,Ts=lE(Ns,"id"),[bs,en]=k.useState(null),Jt=as?Dt:hg(Dt,_s),Vs=j4(Jt,(c=bs==null?void 0:bs.rect)!=null?c:null,ft),ps=k.useRef(null),nt=k.useCallback((Gs,Ue)=>{let{sensor:Pe,options:je}=Ue;if(ce.current==null)return;const Ge=O.get(ce.current);if(!Ge)return;const De=Gs.nativeEvent,bt=new Pe({active:ce.current,activeNode:Ge,event:De,options:je,context:fe,onAbort(pe){if(!O.get(pe))return;const{onDragAbort:Zt}=We.current,ys={id:pe};Zt==null||Zt(ys),D({type:"onDragAbort",event:ys})},onPending(pe,wt,Zt,ys){if(!O.get(pe))return;const{onDragPending:is}=We.current,Ws={id:pe,constraint:wt,initialCoordinates:Zt,offset:ys};is==null||is(Ws),D({type:"onDragPending",event:Ws})},onStart(pe){const wt=ce.current;if(wt==null)return;const Zt=O.get(wt);if(!Zt)return;const{onDragStart:ys}=We.current,es={activatorEvent:De,active:{id:wt,data:Zt.data,rect:Z}};mx.unstable_batchedUpdates(()=>{ys==null||ys(es),te(gf.Initializing),F({type:wc.DragStart,initialCoordinates:pe,active:wt}),D({type:"onDragStart",event:es}),ie(ps.current),ge(De)})},onMove(pe){F({type:wc.DragMove,coordinates:pe})},onEnd:Ct(wc.DragEnd),onCancel:Ct(wc.DragCancel)});ps.current=bt;function Ct(pe){return async function(){const{active:Zt,collisions:ys,over:es,scrollAdjustedTranslate:is}=fe.current;let Ws=null;if(Zt&&is){const{cancelDrop:an}=We.current;Ws={activatorEvent:De,active:Zt,collisions:ys,delta:is,over:es},pe===wc.DragEnd&&typeof an=="function"&&await Promise.resolve(an(Ws))&&(pe=wc.DragCancel)}ce.current=null,mx.unstable_batchedUpdates(()=>{F({type:pe}),te(gf.Uninitialized),en(null),ie(null),ge(null),ps.current=null;const an=pe===wc.DragEnd?"onDragEnd":"onDragCancel";if(Ws){const ya=We.current[an];ya==null||ya(Ws),D({type:an,event:Ws})}})}}},[O]),ts=k.useCallback((Gs,Ue)=>(Pe,je)=>{const Ge=Pe.nativeEvent,De=O.get(je);if(ce.current!==null||!De||Ge.dndKit||Ge.defaultPrevented)return;const bt={active:De};Gs(Pe,Ue.options,bt)===!0&&(Ge.dndKit={capturedBy:Ue.sensor},ce.current=je,nt(Pe,Ue))},[O,nt]),ds=X4(y,ts);nA(y),gm(()=>{ft&&K===gf.Initializing&&te(gf.Initialized)},[ft,K]),k.useEffect(()=>{const{onDragMove:Gs}=We.current,{active:Ue,activatorEvent:Pe,collisions:je,over:Ge}=fe.current;if(!Ue||!Pe)return;const De={active:Ue,activatorEvent:Pe,collisions:je,delta:{x:vs.x,y:vs.y},over:Ge};mx.unstable_batchedUpdates(()=>{Gs==null||Gs(De),D({type:"onDragMove",event:De})})},[vs.x,vs.y]),k.useEffect(()=>{const{active:Gs,activatorEvent:Ue,collisions:Pe,droppableContainers:je,scrollAdjustedTranslate:Ge}=fe.current;if(!Gs||ce.current==null||!Ue||!Ge)return;const{onDragOver:De}=We.current,bt=je.get(Ts),Ct=bt&&bt.rect.current?{id:bt.id,rect:bt.rect.current,data:bt.data,disabled:bt.disabled}:null,pe={active:Gs,activatorEvent:Ue,collisions:Pe,delta:{x:Ge.x,y:Ge.y},over:Ct};mx.unstable_batchedUpdates(()=>{en(Ct),De==null||De(pe),D({type:"onDragOver",event:pe})})},[Ts]),gm(()=>{fe.current={activatorEvent:de,active:oe,activeNode:Ke,collisionRect:$t,collisions:Ns,droppableRects:Ze,draggableNodes:O,draggingNode:_t,draggingNodeRect:He,droppableContainers:W,over:bs,scrollableAncestors:Ce,scrollAdjustedTranslate:vs},Z.current={initial:He,translated:$t}}
752,[oe,Ke,Ns,$t,O,_t,He,Ze,W,bs,Ce,vs]),H4({...Re,delta:q,draggingRect:$t,pointerCoordinates:Rt,scrollableAncestors:Ce,scrollableAncestorRects:Be});const Is=k.useMemo(()=>({active:oe,activeNode:Ke,activeNodeRect:ft,activatorEvent:de,collisions:Ns,containerNodeRect:Fe,dragOverlay:ht,draggableNodes:O,droppableContainers:W,droppableRects:Ze,over:bs,measureDroppableContainers:ke,scrollableAncestors:Ce,scrollableAncestorRects:Be,measuringConfiguration:we,measuringScheduled:ze,windowRect:Xe}),[oe,Ke,ft,de,Ns,Fe,ht,O,W,Ze,bs,ke,Ce,Be,we,ze,Xe]),tn=k.useMemo(()=>({activatorEvent:de,activators:ds,active:oe,activeNodeRect:ft,ariaDescribedById:{draggable:Ee},dispatch:F,draggableNodes:O,over:bs,measureDroppableContainers:ke}),[de,ds,oe,ft,F,Ee,O,bs,ke]);return Do.createElement(aE.Provider,{value:X},Do.createElement(O0.Provider,{value:tn},Do.createElement(vE.Provider,{value:Is},Do.createElement(bE.Provider,{value:Vs},j)),Do.createElement(fA,{disabled:(i==null?void 0:i.restoreFocus)===!1})),Do.createElement(x4,{...i,hiddenTextDescribedById:Ee}));function wn(){const Gs=(ae==null?void 0:ae.autoScrollEnabled)===!1,Ue=typeof _=="object"?_.enabled===!1:_===!1,Pe=J&&!Gs&&!Ue;return typeof _=="object"?{..._,enabled:Pe}:{enabled:Pe}}}),_A=k.createContext(null),ek="button",yA="Draggable";function vA(t){let{id:s,data:n,disabled:a=!1,attributes:l}=t;const c=h_(yA),{activators:u,activatorEvent:i,active:_,activeNodeRect:j,ariaDescribedById:y,draggableNodes:x,over:v}=k.useContext(O0),{role:C=ek,roleDescription:P="draggable",tabIndex:I=0}=l??{},z=(_==null?void 0:_.id)===s,F=k.useContext(z?bE:_A),[D,X]=Uy(),[K,te]=Uy(),J=aA(u,s),H=Vx(n);gm(()=>(x.set(s,{id:s,key:c,node:D,activatorNode:K,data:H}),()=>{const q=x.get(s);q&&q.key===c&&x.delete(s)}),[x,s]);const O=k.useMemo(()=>({role:C,tabIndex:I,"aria-disabled":a,"aria-pressed":z&&C===ek?!0:void 0,"aria-roledescription":P,"aria-describedby":y.draggable}),[a,C,I,z,P,y.draggable]);return{active:_,activatorEvent:i,activeNodeRect:j,attributes:O,isDragging:z,listeners:a?void 0:J,node:D,over:v,setNodeRef:X,setActivatorNodeRef:te,transform:F}}function bA(){return k.useContext(vE)}const jA="Droppable",wA={timeout:25};function NA(t){let{data:s,disabled:n=!1,id:a,resizeObserverConfig:l}=t;const c=h_(jA),{active:u,dispatch:i,over:_,measureDroppableContainers:j}=k.useContext(O0),y=k.useRef({disabled:n}),x=k.useRef(!1),v=k.useRef(null),C=k.useRef(null),{disabled:P,updateMeasurementsFor:I,timeout:z}={...wA,...l},F=Vx(I??a),D=k.useCallback(()=>{if(!x.current){x.current=!0;return}C.current!=null&&clearTimeout(C.current),C.current=setTimeout(()=>{j(Array.isArray(F.current)?F.current:[F.current]),C.current=null},z)},[z]),X=z0({callback:D,disabled:P||!u}),K=k.useCallback((O,q)=>{X&&(q&&(X.unobserve(q),x.current=!1),O&&X.observe(O))},[X]),[te,J]=Uy(K),H=Vx(s);return k.useEffect(()=>{!X||!te.current||(X.disconnect(),x.current=!1,X.observe(te.current))},[te,X]),k.useEffect(()=>(i({type:wc.RegisterDroppable,element:{id:a,key:c,disabled:n,node:te,rect:v,data:H}}),()=>i({type:wc.UnregisterDroppable,key:c,id:a})),[a]),k.useEffect(()=>{n!==y.current.disabled&&(i({type:wc.SetDroppableDisabled,id:a,key:c,disabled:n}),y.current.disabled=n)},[a,c,n,i]),{active:u,rect:v,isOver:(_==null?void 0:_.id)===a,node:te,over:_,setNodeRef:J}}function Hx(t,s,n){const a=t.slice();return a.splice(n<0?a.length+n:n,0,a.splice(s,1)[0]),a}function kA(t,s){return t.reduce((n,a,l)=>{const c=s.get(a);return c&&(n[l]=c),n},Array(t.length))}function $_(t){return t!==null&&t>=0}function CA(t,s){if(t===s)return!0;if(t.length!==s.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==s[n])return!1;return!0}function SA(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const wE=t=>{let{rects:s,activeIndex:n,overIndex:a,index:l}=t;const c=Hx(s,a,n),u=s[l],i=c[l];return!i||!u?null:{x:i.left-u.left,y:i.top-u.top,scaleX:i.width/u.width,scaleY:i.height/u.height}},V_={scaleX:1,scaleY:1},Ny=t=>{var s;let{activeIndex:n,activeNodeRect:a,index:l,rects:c,overIndex:u}=t;const i=(s=c[n])!=null?s:a;if(!i)return null;if(l===n){const j=c[u];return j?{x:0,y:n<u?j.top+j.height-(i.top+i.height):j.top-i.top,...V_}:null}const _=EA(c,l,n);return l>n&&l<=u?{x:0,y:-i.height-_,...V_}:l<n&&l>=u?{x:0,y:i.height+_,...V_}:{x:0,y:0,...V_}};function EA(t,s,n){const a=t[s],l=t[s-1],c=t[s+1];return a?n<s?l?a.top-(l.top+l.height):c?c.top-(a.top+a.height):0:c?c.top-(a.top+a.height):l?a.top-(l.top+l.height):0:0}
752const NE="Sortable",kE=Do.createContext({activeIndex:-1,containerId:NE,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:wE,disabled:{draggable:!1,droppable:!1}});function ky(t){let{children:s,id:n,items:a,strategy:l=wE,disabled:c=!1}=t;const{active:u,dragOverlay:i,droppableRects:_,over:j,measureDroppableContainers:y}=bA(),x=h_(NE,n),v=i.rect!==null,C=k.useMemo(()=>a.map(J=>typeof J=="object"&&"id"in J?J.id:J),[a]),P=u!=null,I=u?C.indexOf(u.id):-1,z=j?C.indexOf(j.id):-1,F=k.useRef(C),D=!CA(C,F.current),X=z!==-1&&I===-1||D,K=SA(c);gm(()=>{D&&P&&y(C)},[D,C,P,y]),k.useEffect(()=>{F.current=C},[C]);const te=k.useMemo(()=>({activeIndex:I,containerId:x,disabled:K,disableTransforms:X,items:C,overIndex:z,useDragOverlay:v,sortedRects:kA(C,_),strategy:l}),[I,x,K.draggable,K.droppable,X,C,z,_,v,l]);return Do.createElement(kE.Provider,{value:te},s)}const PA=t=>{let{id:s,items:n,activeIndex:a,overIndex:l}=t;return Hx(n,a,l).indexOf(s)},TA=t=>{let{containerId:s,isSorting:n,wasDragging:a,index:l,items:c,newIndex:u,previousItems:i,previousContainerId:_,transition:j}=t;return!j||!a||i!==c&&l===u?!1:n?!0:u!==l&&s===_},LA={duration:200,easing:"ease"},CE="transform",MA=_p.Transition.toString({property:CE,duration:0,easing:"linear"}),IA={roleDescription:"sortable"};function AA(t){let{disabled:s,index:n,node:a,rect:l}=t;const[c,u]=k.useState(null),i=k.useRef(n);return gm(()=>{if(!s&&n!==i.current&&a.current){const _=l.current;if(_){const j=Bg(a.current,{ignoreTransform:!0}),y={x:_.left-j.left,y:_.top-j.top,scaleX:_.width/j.width,scaleY:_.height/j.height};(y.x||y.y)&&u(y)}}n!==i.current&&(i.current=n)},[s,n,a,l]),k.useEffect(()=>{c&&u(null)},[c]),c}function _j(t){let{animateLayoutChanges:s=TA,attributes:n,disabled:a,data:l,getNewIndex:c=PA,id:u,strategy:i,resizeObserverConfig:_,transition:j=LA}=t;const{items:y,containerId:x,activeIndex:v,disabled:C,disableTransforms:P,sortedRects:I,overIndex:z,useDragOverlay:F,strategy:D}=k.useContext(kE),X=DA(a,C),K=y.indexOf(u),te=k.useMemo(()=>({sortable:{containerId:x,index:K,items:y},...l}),[x,l,K,y]),J=k.useMemo(()=>y.slice(y.indexOf(u)),[y,u]),{rect:H,node:O,isOver:q,setNodeRef:W}=NA({id:u,data:te,disabled:X.droppable,resizeObserverConfig:{updateMeasurementsFor:J,..._}}),{active:Q,activatorEvent:Z,activeNodeRect:oe,attributes:ce,setNodeRef:ae,listeners:ie,isDragging:de,over:ge,setActivatorNodeRef:We,transform:Ee}=vA({id:u,data:te,attributes:{...IA,...n},disabled:X.draggable}),ve=a4(W,ae),we=!!Q,Ze=we&&!P&&$_(v)&&$_(z),ke=!F&&de,ze=ke&&Ze?Ee:null,dt=Ze?ze??(i??D)({rects:I,activeNodeRect:oe,activeIndex:v,overIndex:z,index:K}):null,Re=$_(v)&&$_(z)?c({id:u,items:y,activeIndex:v,overIndex:z}):K,qt=Q==null?void 0:Q.id,ft=k.useRef({activeId:qt,items:y,newIndex:Re,containerId:x}),Fe=y!==ft.current.items,fe=s({active:Q,containerId:x,isDragging:de,isSorting:we,id:u,index:K,items:y,newIndex:ft.current.newIndex,previousItems:ft.current.items,previousContainerId:ft.current.containerId,transition:j,wasDragging:ft.current.activeId!=null}),Qe=AA({disabled:!fe,index:K,node:O,rect:H});return k.useEffect(()=>{we&&ft.current.newIndex!==Re&&(ft.current.newIndex=Re),x!==ft.current.containerId&&(ft.current.containerId=x),y!==ft.current.items&&(ft.current.items=y)},[we,Re,x,y]),k.useEffect(()=>{if(qt===ft.current.activeId)return;if(qt!=null&&ft.current.activeId==null){ft.current.activeId=qt;return}const _t=setTimeout(()=>{ft.current.activeId=qt},50);return()=>clearTimeout(_t)},[qt]),{active:Q,activeIndex:v,attributes:ce,data:te,rect:H,index:K,newIndex:Re,items:y,isOver:q,isSorting:we,isDragging:de,listeners:ie,node:O,overIndex:z,over:ge,setNodeRef:ve,setActivatorNodeRef:We,setDroppableNodeRef:W,setDraggableNodeRef:ae,transform:Qe??dt,transition:ht()};function ht(){if(Qe||Fe&&ft.current.newIndex===K)return MA;if(!(ke&&!pj(Z)||!j)&&(we||fe))return _p.Transition.toString({...j,property:CE})}}function DA(t,s){var n,a;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t==null?void 0:t.draggable)!=null?n:s.draggable,droppable:(a=t==null?void 0:t.droppable)!=null?a:s.droppable}}function n0(t){if(!t)return!1;const s=t.data.current;return!!(s&&"sortable"in s&&typeof s.sortable=="object"&&"containerId"in s.sortable&&"items"in s.sortable&&"index"in s.sortable)}const RA=[bi.Down,bi.Right,bi.Up,bi.Left],SE=(t,s)=>{let{context:{active:n,collisionRect:a,droppableRects:l,droppableContainers:c,over:u,scrollableAncestors:i}}=s;
752if(RA.includes(t.code)){if(t.preventDefault(),!n||!a)return;const _=[];c.getEnabled().forEach(x=>{if(!x||x!=null&&x.disabled)return;const v=l.get(x.id);if(v)switch(t.code){case bi.Down:a.top<v.top&&_.push(x);break;case bi.Up:a.top>v.top&&_.push(x);break;case bi.Left:a.left>v.left&&_.push(x);break;case bi.Right:a.left<v.left&&_.push(x);break}});const j=y4({active:n,collisionRect:a,droppableRects:l,droppableContainers:_,pointerCoordinates:null});let y=lE(j,"id");if(y===(u==null?void 0:u.id)&&j.length>1&&(y=j[1].id),y!=null){const x=c.get(n.id),v=c.get(y),C=v?l.get(v.id):null,P=v==null?void 0:v.node.current;if(P&&C&&x&&v){const z=D0(P).some((J,H)=>i[H]!==J),F=EE(x,v),D=FA(x,v),X=z||!F?{x:0,y:0}:{x:D?a.width-C.width:0,y:D?a.height-C.height:0},K={x:C.left,y:C.top};return X.x&&X.y?K:qx(K,X)}}}};function EE(t,s){return!n0(t)||!n0(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function FA(t,s){return!n0(t)||!n0(s)||!EE(t,s)?!1:t.data.current.sortable.index<s.data.current.sortable.index}const yj=()=>fu({queryKey:["drawing-folders"],queryFn:async()=>{const{data:t,error:s}=await Fs.from("drawing_folders").select("*").order("display_order",{ascending:!0});if(s)throw s;return t}}),zA=()=>{const t=lc();return md({mutationFn:async s=>{var c;const{data:n}=await Fs.auth.getUser(),{data:a,error:l}=await Fs.from("drawing_folders").insert({name:s.name,parent_folder_id:s.parent_folder_id||null,created_by:(c=n==null?void 0:n.user)==null?void 0:c.id}).select().single();if(l)throw l;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["drawing-folders"]})}})},OA=()=>{const t=lc();return md({mutationFn:async({id:s,...n})=>{const{data:a,error:l}=await Fs.from("drawing_folders").update(n).eq("id",s).select().single();if(l)throw l;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["drawing-folders"]})}})},BA=()=>{const t=lc();return md({mutationFn:async s=>{const{error:n}=await Fs.from("drawing_folders").delete().eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["drawing-folders"]}),t.invalidateQueries({queryKey:["map-overlays"]})}})},Zx={site:{label:"Site",description:"Overall development site - parent of all layers",icon:mp,order:0},boundary:{label:"Boundary",description:"Property boundaries within the site",icon:Il,order:1},constraints:{label:"Constraints",description:"Setbacks, buffers, no-build zones",icon:hd,order:2},access:{label:"Access",description:"Curb cuts, drive aisles, fire lanes",icon:uo,order:3},parking:{label:"Parking",description:"Stalls, aisles, loading berths",icon:fm,order:4},building:{label:"Building",description:"Building footprints, cores, bays",icon:Ci,order:5},program:{label:"Program",description:"Stormwater, landscaping, amenities",icon:Ih,order:6},massing:{label:"Massing",description:"Future phases, expansion areas",icon:cm,order:7},context:{label:"Context",description:"Adjacent parcels, roads, utilities",icon:ji,order:8},annotations:{label:"Annotations",description:"Labels, dimensions, callouts",icon:Vy,order:9},general:{label:"Other",description:"Uncategorized layers",icon:Da,order:10}},Af=[{value:"site",label:"Site",category:"site",color:"bg-indigo-600",description:"Overall development site - contains all properties and improvements"},{value:"property_outline",label:"Property",category:"boundary",color:"bg-purple-600",description:"Individual property boundary within the site"},{value:"lot",label:"Lot",category:"boundary",color:"bg-purple-200",description:"Individual development lot within a property"},{value:"buildable_area",label:"Buildable Area",category:"constraints",color:"bg-green-300",description:"Allowable building footprint area"},{value:"setback_front",label:"Front Setback",category:"constraints",color:"bg-red-300",description:"Front yard setback zone"},{value:"setback_rear",label:"Rear Setback",category:"constraints",color:"bg-red-200",description:"Rear yard setback zone"},{value:"setback_side",label:"Side Setback",category:"constraints",color:"bg-red-100",description:"Side yard setback zone"},{value:"no_build_zone",label:"No-Build Zone",category:"constraints",color:"bg-red-500",description:"Restricted area - no construction"},{value:"floodplain",label:"Floodplain",category:"constraints",color:"bg-blue-300",de
752scription:"Flood hazard area"},{value:"phase_overlay",label:"Phase Overlay",category:"constraints",color:"bg-indigo-400",description:"Construction phasing dashed boundary overlay"},{value:"secure_zone",label:"Secure Zone",category:"constraints",color:"bg-red-500",description:"Security classification zone shading overlay"},{value:"curb_cut",label:"Curb Cut",category:"access",color:"bg-slate-600",description:"Driveway entrance point"},{value:"drive_aisle",label:"Drive Aisle",category:"access",color:"bg-slate-500",description:"Internal vehicular circulation"},{value:"fire_lane",label:"Fire Lane",category:"access",color:"bg-red-600",description:"Emergency vehicle access"},{value:"sidewalk",label:"Sidewalk",category:"access",color:"bg-slate-300",description:"Pedestrian walkway"},{value:"truck_court",label:"Truck Court",category:"access",color:"bg-slate-700",description:"Truck maneuvering area",specialty:!0},{value:"scale_house",label:"Scale House",category:"access",color:"bg-slate-500",description:"Truck weigh station",specialty:!0},{value:"parking",label:"Parking",category:"parking",color:"bg-slate-500",description:"Surface parking area"},{value:"parking_zone",label:"Parking Zone",category:"parking",color:"bg-slate-600",description:"Named parking zone with purpose (customer, employee, ADA)"},{value:"ada_stalls",label:"ADA Stalls",category:"parking",color:"bg-blue-500",description:"Accessible parking spaces"},{value:"loading_berth",label:"Loading Berth",category:"parking",color:"bg-orange-500",description:"Truck loading/unloading area",specialty:!0},{value:"trailer_parking",label:"Trailer Parking",category:"parking",color:"bg-slate-600",description:"Trailer staging area",specialty:!0},{value:"mf_parking_garage",label:"Parking Garage",category:"parking",color:"bg-slate-600",description:"Structured parking: podium, standalone, underground",specialty:!0},{value:"building_footprint",label:"Building Footprint",category:"building",color:"bg-orange-600",description:"Building ground floor outline"},{value:"building_core",label:"Core/Elevator",category:"building",color:"bg-orange-700",description:"Vertical circulation core"},{value:"office_area",label:"Office Area",category:"building",color:"bg-blue-400",description:"Office space within building"},{value:"floor_plan",label:"Floor Plan",category:"building",color:"bg-indigo-500",description:"Interior space outline within building"},{value:"building_floor",label:"Floor Slab",category:"building",color:"bg-amber-500",description:"Structural floor slab within a building"},{value:"canopy",label:"Canopy",category:"building",color:"bg-gray-400",description:"Covered structure/awning"},{value:"trash_enclosure",label:"Trash Enclosure",category:"building",color:"bg-stone-500",description:"Waste enclosure"},{value:"warehouse_bay",label:"Warehouse Bay",category:"building",color:"bg-orange-500",description:"Warehouse column bay",specialty:!0},{value:"dock_door",label:"Dock Door",category:"building",color:"bg-orange-400",description:"Loading dock door location",specialty:!0},{value:"retail_pad",label:"Retail Pad",category:"building",color:"bg-pink-500",description:"Standalone retail building",specialty:!0},{value:"guard_booth",label:"Guard Booth",category:"building",color:"bg-slate-700",description:"Security checkpoint with boom barrier",specialty:!0},{value:"overhead_crane",label:"Overhead Crane",category:"building",color:"bg-yellow-600",description:"Bridge/jib crane rail systems",specialty:!0},{value:"mezzanine",label:"Mezzanine",category:"building",color:"bg-indigo-400",description:"Parti
752al-height intermediate floor",specialty:!0},{value:"cold_storage",label:"Cold Storage",category:"building",color:"bg-sky-700",description:"Freezer walls, condensers, refrigeration",specialty:!0},{value:"dc_ups_room",label:"UPS / Battery Room",category:"building",color:"bg-amber-600",description:"UPS and battery storage",subsystem:"PWR",specialty:!0},{value:"dc_meet_me_room",label:"Meet-Me Room",category:"building",color:"bg-purple-500",description:"Carrier interconnection room",subsystem:"NET",specialty:!0},{value:"mf_unit_layout",label:"Unit Layout",category:"building",color:"bg-violet-500",description:"Unit mix and floor plan configuration",specialty:!0},{value:"mf_corridor",label:"Corridor / Breezeway",category:"building",color:"bg-violet-400",description:"Interior corridors or exterior breezeways",specialty:!0},{value:"stormwater",label:"Stormwater",category:"program",color:"bg-cyan-500",description:"Detention/retention area"},{value:"landscaping",label:"Landscaping",category:"program",color:"bg-green-500",description:"Landscaped area"},{value:"landscape_buffer",label:"Landscape Buffer",category:"program",color:"bg-green-400",description:"Perimeter landscape screening"},{value:"fencing",label:"Fencing",category:"program",color:"bg-slate-500",description:"Perimeter fencing"},{value:"hardscape",label:"Hardscape",category:"program",color:"bg-stone-500",description:"Paved surfaces"},{value:"outdoor_storage",label:"Outdoor Storage",category:"program",color:"bg-stone-400",description:"Storage yard"},{value:"container_yard",label:"Container Yard",category:"program",color:"bg-blue-600",description:"Container/chassis staging area",specialty:!0},{value:"dc_substation",label:"Electrical Substation",category:"program",color:"bg-yellow-600",description:"Utility substation for primary power",subsystem:"PWR",specialty:!0},{value:"dc_generator_yard",label:"Generator Yard",category:"program",color:"bg-yellow-500",description:"Diesel/gas generator farm",subsystem:"PWR",specialty:!0},{value:"dc_chiller_plant",label:"Chiller Plant",category:"program",color:"bg-cyan-600",description:"Central chilled water plant",subsystem:"CLG",specialty:!0},{value:"dc_perimeter_security",label:"DC Perimeter Security",category:"program",color:"bg-slate-700",description:"Multi-layer security system",subsystem:"SEC",specialty:!0},{value:"mf_clubhouse",label:"Clubhouse / Leasing",category:"program",color:"bg-amber-500",description:"Community building with fitness and leasing",specialty:!0},{value:"mf_pool",label:"Pool / Spa",category:"program",color:"bg-cyan-500",description:"Swimming pool and spa area",specialty:!0},{value:"mf_dog_park",label:"Dog Park",category:"program",color:"bg-green-500",description:"Fenced off-leash dog area",specialty:!0},{value:"mf_ev_charging",label:"EV Charging",category:"program",color:"bg-green-600",description:"Electric vehicle charging stations",specialty:!0},{value:"building_envelope",label:"Building Envelope",category:"massing",color:"bg-orange-300",description:"Allowable building mass"},{value:"future_phase",label:"Future Phase",category:"massing",color:"bg-indigo-400",description:"Future development area"},{value:"expansion_area",label:"Expansion Area",category:"massing",color:"bg-indigo-300",description:"Potential building expansion"},{value:"roads",label:"Roads",category:"context",color:"bg-gray-500",description:"Adjacent roads and streets"},{value:"adjacent_parcel",label:"Adjacent Parcel",category:"context",color:"bg-gray-400",description:"Neighboring property boundaries"},{value:"easement",label:"Easement",category:"context",color:"bg-amber-500",description:"Access or utility easements"},{value:"utility_line",label:"Utility Line",category:"context",color:"bg-yellow-500",description:"Existing utility infrastructure"},{value:"existing_building",label:"Existing Building",category:"context",color:"bg-stone-500",description:"Existing structures on or near site"},{value:"dimension_line",label:"Dimension Line",category:"annotations",color:"bg-gray-600",description:"Measurement annotation"},{value:"callout",label:"Callout",category:"annotations",color:"bg-gray-500",description:"Text callout marker"},{value:"label",label:"Label",category:"annotations",color:"bg-gray-400",description:"Text label"},{value:"general",label:"General",category:"general",color:"bg-gray-500",description:"Generic polygon"}],$A={site_boundary:"site",assemblage:"site",parking_field:"parking",parking_bay:"parking",parcel_assembly:"property_outline",legal_line:"property_outline",lot_line:"lot"},VA={industrial:["truck_court","loading_berth","trailer_parking","guard_booth","overhead_crane","mezzanine","warehouse_bay","dock_door","cold_storage","scale_house","container_yard"],distribution:["truck_court","loading_berth","trailer_parking","guard_booth","overhead_crane","mezzanine","warehouse_bay","dock_door","cold_storage","scale_house","container_yard"],retail:["retail_pad"],retail_pad:["retail_pad"],office:[],medical:[],mixed_use:["retail_pad","mf_unit_layout","mf_corridor","mf_parking_garage","mf_clubhouse","mf_ev_charging"],multifamily:["mf_unit_layout","mf_corridor","mf_parking_garage","mf_clubhouse","mf_pool","mf_dog_par
752k","mf_ev_charging"],data_center:["dc_substation","dc_generator_yard","dc_chiller_plant","dc_ups_room","dc_meet_me_room","dc_perimeter_security","guard_booth"],other:[]};function qA(t){if(!t||t==="other")return Af;const s=VA[t]||[];return Af.filter(n=>n.specialty?s.includes(n.value):!0)}function rp(t){const s=Af.find(a=>a.value===t);if(s)return s;const n=$A[t];if(n)return Af.find(a=>a.value===n)}function GA(){return Object.entries(Zx).sort((t,s)=>t[1].order-s[1].order).map(([t])=>t)}function PE(t){return t?new Set(["parking","parking_field","parking_zone","parking_bay","loading_berth","trailer_parking","ada_stalls"]).has(t):!1}function HA(t){if(!t)return 500;const s={site:50,site_boundary:60,assemblage:70,property_outline:100,parcel_assembly:110,legal_line:120,setback_front:130,setback_rear:140,setback_side:150,buildable_area:160,no_build_zone:170,floodplain:178,phase_overlay:180,secure_zone:185,lot:200,lot_line:210,roads:280,adjacent_parcel:285,easement:290,utility_line:295,existing_building:300,curb_cut:400,drive_aisle:410,fire_lane:420,truck_court:430,sidewalk:450,scale_house:455,parking:500,parking_field:510,parking_zone:515,parking_bay:520,loading_berth:530,ada_stalls:540,trailer_parking:550,mf_parking_garage:555,building_envelope:600,future_phase:610,expansion_area:620,building_footprint:700,building_core:710,warehouse_bay:720,dock_door:730,building_floor:735,office_area:740,floor_plan:745,retail_pad:750,canopy:760,trash_enclosure:770,guard_booth:775,overhead_crane:778,mezzanine:780,cold_storage:785,dc_ups_room:790,dc_meet_me_room:792,mf_unit_layout:794,mf_corridor:796,stormwater:820,landscaping:830,landscape_buffer:835,outdoor_storage:840,fencing:842,hardscape:845,container_yard:848,dc_substation:850,dc_generator_yard:852,dc_chiller_plant:854,dc_perimeter_security:856,mf_clubhouse:858,mf_pool:860,mf_dog_park:862,mf_ev_charging:864,dimension_line:900,callout:910,label:920,general:500};if(s[t]!==void 0)return s[t];const n=rp(t);if(!n)return 500;const a=n.category,l=Zx[a];return l?l.order*100:500}function Wx(t,s=0){return HA(t)+s*50}function TE(t,s){return[...t].sort((n,a)=>{const l=s&&n.id?s[n.id]??0:0,c=s&&a.id?s[a.id]??0:0,u=Wx(n.layer_type,l),i=Wx(a.layer_type,c);return u-i})}const ZA=new Set(["property_outline","parcel_assembly","legal_line","setback_front","setback_rear","setback_side","buildable_area","no_build_zone"]);function WA(t){return t?ZA.has(t):!1}function ip(t){if(!t||t.is_photo_overlay||t.image_url)return!1;if(WA(t.layer_type)||t.setback_geometry||t.setback_front_ft||t.setback_rear_ft||t.setback_side_ft||t.setback_side1_ft||t.setback_side2_ft)return!0;if(t.name){const s=t.name.toLowerCase();if(s.includes("property line")||s.includes("propertyline")||s.includes("property outline")||s.includes("site boundary")||s.includes("parcel boundary")||s.includes("lot boundary"))return!0}return!1}function oo(t){return t?["site","site_boundary","assemblage"].includes(t):!1}function rm(t){return t?["property_outline","parcel_assembly","legal_line"].includes(t):!1}function bf(t){return t?["lot","lot_line"].includes(t):!1}function Cy(t){return t?["building_footprint","office_area","retail_pad","warehouse_bay","building_core","dock_door","building_floor","canopy","trash_enclosure"].includes(t):!1}function YA(t){return t?["stormwater"].includes(t):!1}function XA(t){return t?["landscaping","landscape_buffer"].includes(t):!1}function KA(t){return t?["outdoor_storage"].includes(t):!1}function JA(t){return t?["fire_lane"].includes(t):!1}function QA(t){return t?["easement"].includes(t):!1}function UA(t){return t?["hardscape","sidewalk"].includes(t):!1}function eD(t){return t?["site_lighting"].includes(t):!1}function tD(t){return t?["retaining_wall"].includes(t):!1}function sD(t){return t?["fencing"].includes(t):!1}function nD(t){return t?["utility_line"].includes(t):!1}function aD(t){return t?XA(t)?"landscape_buffer":sD(t)?"fencing":JA(t)?"fire_lane":QA(t)?"easement":UA(t)?"hardscape":eD(t)?"lighting":tD(t)?"retaining_wall":KA(t)?"outdoor_storage":nD(t)?"utility_corridor":null:null}const rD={site:["property_outline","building_footprint","parking","parking_field","parking_zone","stormwater","landscaping","landscape_buffer","drive_aisle","curb_cut"],site_boundary:["property_outline","building_footprint","parking","parking_field","parking_zone","stormwater","landscaping","landscape_buffer","drive_aisle","curb_cut"],assemblage:["property_outline","building_footprint","parking","parking_field","parking_zone","stormwater","landscaping","landscape_buffer"],property_outline:["building_footprint","parking","parking_field","parking_zone","stormwater","landscaping","landscape_buffer","lot","truck_court","drive_aisle","loading_berth","trash_enclosure","canopy"],parcel_assembly:["building_footprint","parking","parking_field","parking_zone","stormwater","landscaping","lot","landscape_buffer"],lot:["building_footprint","parking","parking_field","parking_zone","trash_enclosure","canopy"],building_footprint:["office_area","floor_plan","building_core","warehouse_bay","dock_door","building_floor"],warehouse_bay:["dock_door","office_area"],retail_pad:["office_area","floor_plan"]};function iD(t){return t?rD[t]||[]:[]}const vj={property_outline:["site","site_boundary","assemblage"],parcel_assembly:["site","site_boundary","assemblage"],lot:["property_outline","parcel_assembly"],lot_line:["property_outline","parcel_assembly"],building_footprint:["lot","property_outline","parcel_assembly","site","site_boundary","assemblage"],retail_pad:["lot","property_outline","parcel_assembly","site","site_boundary"],warehouse_bay:["building_footprint"],office_area:["building_footprint","retail_pad"],floor_plan:["building_footprint","retail_pad"],building_floor:["building_footprint","retail_pad"],parking:["lot","property_outline","parcel_assembly","site","site_boundary"],parking_field:["lot","property_outline","parcel_assembly","site","site_boundary"],parking_zone:["lot","property_outline","parcel_assembly","site","site_boundary"],stormwater:["lot","property_outline","parcel_assembly","site","site_boundary"],landscaping:["lot","property_outline","parcel_assembly","site","site_boundary"],landscape_buffer:["lot","property_outline","parcel_assembly","site","site_boundary"],truck_court:["lot","property_outline","parcel_assembly","site","site_boundary"],drive_aisle:["lot","property_outline","parcel_assembly","site","site_boundary"],curb_cut:["property_outline","parcel_assembly","site","site_boundary"]},LE=new Set(["site","site_boundary","assemblage","general","roads","adjacent_parcel","easement","utility_line","existing_building","dimension_line","callout","label","setback_front","setback_rear","setback_side","buildable_area","no_build_zone","floodplain","phase_overlay","secure_zone"]);function oD(t){return t?!LE.has(t)&&vj[t]!==void 0:!1}function lD(t){return t?vj[t]||[]:[]}
752function cD(t,s){if(!t||LE.has(t))return!0;const n=vj[t];return!n||n.length===0?!0:s?n.includes(s):!1}function dD(t){return t?rm(t)?"Properties require a Site. Please create or select a Site layer first.":bf(t)?"Lots require a Property parent. Please create or select a Property layer first.":Cy(t)?"Buildings require a Lot or Property parent. Please select a parent layer.":["parking","parking_field","stormwater","landscaping","truck_court","drive_aisle"].includes(t)?"This layer type requires a Lot or Property parent.":"This layer type requires a parent layer.":""}function uD(t,s,n){if(!t)return[];const a=lD(t);return a.length===0?[]:s.filter(l=>l.id!==n&&l.layer_type&&a.includes(l.layer_type))}let Yp=null;async function ME(){if(Yp&&Yp.size>0)return Yp;try{const{data:t,error:s}=await Fs.from("map_overlays").select("*").limit(1);if(!s&&t&&t.length>0)return Yp=new Set(Object.keys(t[0])),console.log(`[mapOverlayColumns] Discovered ${Yp.size} columns from DB`),Yp;s&&console.error("[mapOverlayColumns] Error discovering columns:",s.message)}catch(t){console.error("[mapOverlayColumns] Exception discovering columns:",t)}return console.warn("[mapOverlayColumns] Could not discover columns, returning empty set"),new Set}const hD=()=>{const t=lc();return md({mutationFn:async({folder:s,allFolders:n,allOverlays:a})=>{var z;const{data:l}=await Fs.auth.getUser(),c=((z=l==null?void 0:l.user)==null?void 0:z.id)??null,u=await ME(),i=new Map,_=new Map,j=F=>{const D=n.filter(K=>K.parent_folder_id===F),X=[...D];for(const K of D)X.push(...j(K.id));return X},y=j(s.id),x=[s,...y],v=new Set(x.map(F=>F.id));for(const F of x){const D=F.id===s.id?s.parent_folder_id:i.get(F.parent_folder_id)??null,{data:X,error:K}=await Fs.from("drawing_folders").insert({name:F.id===s.id?`${F.name} (copy)`:F.name,parent_folder_id:D,is_visible:F.is_visible,is_expanded:F.is_expanded,created_by:c}).select("id").single();if(K)throw K;i.set(F.id,X.id)}const C=a.filter(F=>F.folder_id&&v.has(F.folder_id));if(C.length===0)return{foldersCreated:x.length,overlaysCreated:0};const P=mD(C),I=new Set(["id","created_at","updated_at","created_by","current_version"]);for(const F of P){const D=i.get(F.folder_id)??null;let X=F.parent_overlay_id??null;X&&_.has(X)&&(X=_.get(X));const K={};for(const[H,O]of Object.entries(F))I.has(H)||u.has(H)&&O!=null&&(Array.isArray(O)&&O.length===0||typeof O=="object"&&!Array.isArray(O)&&Object.keys(O).length===0||(K[H]=O));K.name=F.name,K.folder_id=D,K.parent_overlay_id=X,K.geometry=F.geometry,K.created_by=c,K.approval_status="draft",console.log(`[duplicateFolder] Inserting overlay "${F.name}" with ${Object.keys(K).length} fields`);const{data:te,error:J}=await Fs.from("map_overlays").insert([K]).select("id").single();if(J)throw console.error(`[duplicateFolder] Insert failed for "${F.name}":`,J.message,J.details,J.hint),J;_.set(F.id,te.id)}return{foldersCreated:x.length,overlaysCreated:P.length,newRootFolderId:i.get(s.id)}},onSuccess:s=>{t.invalidateQueries({queryKey:["drawing-folders"]}),t.invalidateQueries({queryKey:["map-overlays"]}),Ve.success(`Duplicated ${s.foldersCreated} folder(s) with ${s.overlaysCreated} layer(s)`)},onError:()=>{Ve.error("Failed to duplicate folder")}})};function mD(t){const s=new Set(t.map(c=>c.id)),n=[],a=new Set,l=c=>{if(!a.has(c.id)){if(a.add(c.id),c.parent_overlay_id&&s.has(c.parent_overlay_id)){const u=t.find(i=>i.id===c.parent_overlay_id);u&&l(u)}n.push(c)}};for(const c of t)l(c);return n}const IE=()=>{const t=lc();return md({mutationFn:async({overlay:s,allOverlays:n})=>{var x;const{data:a}=await Fs.auth.getUser(),l=((x=a==null?void 0:a.user)==null?void 0:x.id)??null,c=await ME(),u=v=>{const C=n.filter(I=>I.parent_overlay_id===v),P=[...C];for(const I of C)P.push(...u(I.id));return P},i=u(s.id),_=[s,...i],j=new Map,y=new Set(["id","created_at","updated_at","created_by","current_version"]);for(const v of _){let C=v.parent_overlay_id??null;v.id===s.id?C=s.parent_overlay_id??null:C&&j.has(C)&&(C=j.get(C));const P={};for(const[F,D]of Object.entries(v))y.has(F)||c.has(F)&&D!=null&&(Array.isArray(D)&&D.length===0||typeof D=="object"&&!Array.isArray(D)&&Object.keys(D).length===0||(P[F]=D));P.name=v.id===s.id?`${v.name}
752 (copy)`:v.name,P.parent_overlay_id=C,P.geometry=v.geometry,P.created_by=l,P.approval_status="draft",console.log(`[duplicateOverlay] Inserting overlay "${v.name}" with ${Object.keys(P).length} fields`);const{data:I,error:z}=await Fs.from("map_overlays").insert([P]).select("id").single();if(z)throw console.error(`[duplicateOverlay] Insert failed for "${v.name}":`,z.message,z.details,z.hint),z;j.set(v.id,I.id)}return{overlaysCreated:_.length}},onSuccess:s=>{t.invalidateQueries({queryKey:["map-overlays"]});const n=s.overlaysCreated;Ve.success(n===1?"Layer duplicated":`Duplicated layer with ${n-1} child layer(s)`)},onError:()=>{Ve.error("Failed to duplicate layer")}})},AE={polygon:e.jsx(fd,{className:"w-4 h-4"}),polyline:e.jsx(uo,{className:"w-4 h-4"}),marker:e.jsx(ji,{className:"w-4 h-4"})},DE={polygon:"text-amber-500",polyline:"text-blue-500",marker:"text-green-500"},gx=Af.reduce((t,s)=>(t[s.value]=s.label,t),{}),ig={property_outline:"bg-purple-500/20 text-purple-400 border-purple-500/30",setback_line:"bg-purple-300/20 text-purple-300 border-purple-300/30",building_envelope:"bg-purple-400/20 text-purple-400 border-purple-400/30",building_footprint:"bg-orange-500/20 text-orange-400 border-orange-500/30",foundation:"bg-orange-400/20 text-orange-400 border-orange-400/30",loading_dock:"bg-orange-300/20 text-orange-300 border-orange-300/30",canopy:"bg-orange-200/20 text-orange-200 border-orange-200/30",trash_enclosure:"bg-stone-500/20 text-stone-400 border-stone-500/30",parking:"bg-slate-500/20 text-slate-400 border-slate-500/30",truck_court:"bg-slate-600/20 text-slate-400 border-slate-600/30",fire_lane:"bg-red-500/20 text-red-400 border-red-500/30",driveway:"bg-slate-400/20 text-slate-400 border-slate-400/30",sidewalk:"bg-slate-300/20 text-slate-300 border-slate-300/30",utility_easement:"bg-amber-500/20 text-amber-400 border-amber-500/30",electric_vault:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",water_sewer:"bg-blue-400/20 text-blue-400 border-blue-400/30",gas_line:"bg-yellow-400/20 text-yellow-400 border-yellow-400/30",stormwater:"bg-cyan-500/20 text-cyan-400 border-cyan-500/30",landscaping:"bg-green-500/20 text-green-400 border-green-500/30",tree_save:"bg-green-600/20 text-green-400 border-green-600/30",wetland_buffer:"bg-teal-500/20 text-teal-400 border-teal-500/30",floodplain:"bg-blue-300/20 text-blue-300 border-blue-300/30",future_phase:"bg-indigo-400/20 text-indigo-400 border-indigo-400/30",expansion_area:"bg-indigo-300/20 text-indigo-300 border-indigo-300/30",outdoor_storage:"bg-stone-400/20 text-stone-400 border-stone-400/30",general:"bg-gray-500/20 text-gray-400 border-gray-500/30"},tk=({overlay:t,isSelected:s,selectMode:n,onToggleSelection:a,onNavigate:l,onToggleVisibility:c,onEdit:u,onDelete:i,onDuplicate:_,onOpenPolygonTools:j,childCount:y,isExpanded:x,onToggleExpand:v,children:C,folders:P,parentOverlays:I,onMoveToFolder:z,onSetParent:F,onOpenLinkDialog:D,link:X})=>{const{attributes:K,listeners:te,setNodeRef:J,transform:H,transition:O,isDragging:q}=_j({id:t.id}),W={transform:_p.Transform.toString(H),transition:O,zIndex:q?100:void 0,opacity:q?.8:void 0},Q=t.layer_type||"general",Z=y>0;return e.jsxs("div",{ref:J,style:W,className:"space-y-0.5",children:[e.jsxs("div",{className:`flex items-center gap-1 px-2 py-1.5 rounded-md hover:bg-muted/50 group ${q?"bg-muted shadow-lg":""} ${t.is_visible?"":"opacity-50"} ${s?"bg-primary/10 border border-primary/30":""}`,children:[!n&&e.jsx("div",{...K,...te,className:"cursor-grab active:cursor-grabbing p-0.5 hover:bg-muted rounded touch-none",title:"Drag to reorder",children:e.jsx(Fh,{className:"w-3 h-3 text-muted-foreground"})}),n?e.jsx(Ux,{checked:s,onCheckedChange:a,onClick:oe=>oe.stopPropagation(),className:"h-4 w-4"}):Z?e.jsx("button",{onClick:v,className:"p-0.5",children:x?e.jsx(Oa,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(Ao,{className:"w-3 h-3 text-muted-foreground"})}):e.jsx("div",{className:"w-4"}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 cursor-pointer",onClick:n?a:l,title:n?"Click to select":"Click to navigate to drawing",children:[e.jsx("span",{className:DE[t.type]||"text-muted-foreground",children:AE[t.type]||e.jsx(Da,{className:"w-4 h-4"})}),e.jsx("span",{className:"flex-1 text-sm truncate font-medium",children:t.name}),e.jsx(Mt,{variant:"outline",className:`text-[10px] h-4 px-1.5 shrink-0 ${ig[Q]||ig.general}`,children:gx[Q]||Q}),Z&&e.jsxs(Mt,{variant:"secondary",className:"text-[10px] h-4 px-1.5 shrink-0",children:[e.jsx(zx,{className:"w-2.5 h-2.5 mr-0.5"}),y]}),X&&e.jsxs(Mt,{variant:"outline",className:"text-xs h-5 shrink-0",children:[X.type==="development"&&e.jsx(Ci,{className:"w-3 h-3 mr-1"}),X.type==="existing"&&e.jsx(Sc,{className:"w-3 h-3 mr-1"}),X.type==="assemblage"&&e.jsx(Da,{className:"w-3 h-3 mr-1"}),X.name.substring(0,10),"..."]})]}),!n&&e.jsxs("div",{className:"flex items-center gap-0.5",onClick:oe=>oe.stopPropagation(),children:[e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:c,title:t.is_visible?"Hide":"Show",children:t.is_visible?e.jsx(kc,{className:"w-3 h-3"}):e.jsx(Wc,{className:"w-3 h-3"})}),e.jsxs(jp,{children:[e.jsx(wp,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6",children:e.jsx(Mg,{className:"w-3 h-3"})})}),e.jsxs(Np,{align:"end",className:"w-52 bg-popover border border-border shadow-lg z-50",children:[t.type==="polygon"&&e.jsxs(co,{onClick:u,children:[e.jsx(Du,{className:"w-4 h-4 mr-2"}),"Edit Geometry"]}),j&&t.type==="polygon"&&e.jsxs(co,{onClick:j,children:[e.jsx(Dh,{className:"w-4 h-4 mr-2"}),"Polygon Tools"]}),e.jsxs(Mx,{children:[e.jsxs(Ix,{children:[e.jsx(Nx,{className:"w-4 h-4 mr-2"}),"Move to Folder"]}),e.jsxs(Ax,{className:"bg-popover border border-border shadow-lg z-50",children:[e.jsx(co,{onClick:()=>z(null),children:e.jsx("span",{className:"text-muted-foreground",children:"Unfiled"})}),P.map(oe=>e.jsxs(co,{onClick:()=>z(oe.id),children:[e.jsx(Nx,{className:"w-4 h-4 mr-2"}),oe.name]},oe.id))]})]}),e.jsxs(Mx,{children:[e.jsxs(Ix,{children:[e.jsx(zx,{className:"w-4 h-4 mr-2"}),"Set as Child of..."]}),e.jsxs(Ax,{className:"bg-popover border border-border shadow-lg z-50 max-h-64 overflow-y-auto",children:[I.filter(oe=>oe.id!==t.id).map(oe=>e.jsxs(co,{onClick:()=>F(oe.id),children:[e.jsx(fd,{className:"w-4 h-4 mr-2 text-amber-500"}),oe.name]},oe.id)),I.filter(oe=>oe.id!==t.id).length===0&&e.jsx(co,{disabled:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:"No other polygons available"})})]})]}),e.jsxs(co,{onClick:D,children:[e.jsx(tS,{className:"w-4 h-4 mr-2"}),"Link to Project"]}),e.jsx(cd,{}),e.jsxs(co,{onClick:_,children:[e.jsx(hp,{className:"w-4 h-4 mr-2"}),"Duplicate Layer"]}),e.jsx(cd,{}),e.jsxs(co,{className:"text-destructive focus:text-destructive",onClick:i,children:[e.jsx(wr,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]})]})]}),Z&&x&&C]})},fD=({folder:t,isOpen:s,totalItems:n,depth:a=0,onToggleFolder:l,onToggleVisibility:c,onEditFolder:u,onDeleteFolder:i,onDuplicateFolder:_,onMoveToParentFolder:j,allFolders:y,children:x})=>{const{attributes:v,listeners:C,setNodeRef:P,transform:I,transition:z,isDragging:F,isOver:D}=_j({id:`folder-${t.id}`,data:{type:"folder",folderId:t.id}}),X={transform:_p.Transform.toString(I),transition:z,zIndex:F?100:void 0,opacity:F?.8:void 0},K=O=>{const q=[],W=y.filter(Q=>Q.parent_folder_id===O);
752for(const Q of W)q.push(Q.id),q.push(...K(Q.id));return q},te=K(t.id),J=y.filter(O=>O.id!==t.id&&!te.includes(O.id)),H=t.is_visible!==!1;return e.jsxs("div",{ref:P,style:X,className:"space-y-0.5",children:[e.jsxs("div",{className:`flex items-center gap-1 px-2 py-1 rounded-md hover:bg-muted/50 group transition-colors ${F?"bg-muted shadow-lg":""} ${D?"bg-primary/20 ring-2 ring-primary/50":""} ${H?"":"opacity-50"}`,style:{marginLeft:a*16},children:[e.jsx("div",{...v,...C,className:"cursor-grab active:cursor-grabbing p-0.5 hover:bg-muted rounded touch-none",title:"Drag to reorder or nest",children:e.jsx(Fh,{className:"w-3 h-3 text-muted-foreground"})}),e.jsxs("button",{onClick:l,className:"flex items-center gap-1 flex-1 text-left",children:[s?e.jsx(Oa,{className:"w-4 h-4"}):e.jsx(Ao,{className:"w-4 h-4"}),e.jsx(Nx,{className:`w-4 h-4 ${D?"text-primary":"text-amber-500"}`}),e.jsx("span",{className:"text-sm font-medium truncate",children:t.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",n,")"]}),a>0&&e.jsxs("span",{className:"text-[10px] text-muted-foreground/50",children:["L",a+1]})]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity",onClick:O=>{O.stopPropagation(),c()},title:H?"Hide folder contents on map":"Show folder contents on map",children:H?e.jsx(kc,{className:"w-3 h-3"}):e.jsx(Wc,{className:"w-3 h-3"})}),e.jsxs(jp,{children:[e.jsx(wp,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Mg,{className:"w-3 h-3"})})}),e.jsxs(Np,{align:"end",className:"bg-popover border border-border shadow-lg z-50",children:[e.jsxs(co,{onClick:c,children:[H?e.jsx(Wc,{className:"w-4 h-4 mr-2"}):e.jsx(kc,{className:"w-4 h-4 mr-2"}),H?"Hide on Map":"Show on Map"]}),e.jsx(cd,{}),e.jsxs(co,{onClick:u,children:[e.jsx(kp,{className:"w-4 h-4 mr-2"}),"Rename"]}),e.jsxs(Mx,{children:[e.jsxs(Ix,{children:[e.jsx(Nx,{className:"w-4 h-4 mr-2"}),"Move to Folder"]}),e.jsxs(Ax,{className:"bg-popover border border-border shadow-lg z-50 max-h-64 overflow-y-auto",children:[e.jsx(co,{onClick:()=>j(null),children:e.jsx("span",{className:"text-muted-foreground",children:"Root Level"})}),J.length>0&&e.jsx(cd,{}),J.map(O=>e.jsxs(co,{onClick:()=>j(O.id),children:[e.jsx(Nx,{className:"w-4 h-4 mr-2 text-amber-500"}),O.name]},O.id))]})]}),e.jsx(cd,{}),e.jsxs(co,{onClick:_,children:[e.jsx(hp,{className:"w-4 h-4 mr-2"}),"Duplicate Group"]}),e.jsx(cd,{}),e.jsxs(co,{className:"text-destructive focus:text-destructive",onClick:i,children:[e.jsx(wr,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]})]}),s&&x]})},sk=({onNavigateToOverlay:t,onStartDrawing:s,onEditOverlay:n,onOpenPolygonTools:a,activeSiteLayoutId:l,activeFocusId:c,onActiveFocusIdChange:u,externalSearchQuery:i})=>{const{preferences:_,updateDrawingsPanelExpanded:j}=Kx(),[y,x]=k.useState(_.drawingsPanelExpanded??!0),[v,C]=k.useState(""),[P,I]=k.useState(!1),[z,F]=k.useState(null),[D,X]=k.useState(null),[K,te]=k.useState(null),[J,H]=k.useState(new Set),[O,q]=k.useState(new Set);k.useState(new Set);const[W,Q]=k.useState(!1),[Z,oe]=k.useState(null),[ce,ae]=k.useState(!1),[ie,de]=k.useState(new Set),[ge,We]=k.useState(!1),[Ee,ve]=k.useState("");k.useEffect(()=>{i!==void 0&&ve(i)},[i]);const we=rE(t0(F0,{activationConstraint:{distance:5}}),t0(R0,{coordinateGetter:SE}));k.useEffect(()=>{_.drawingsPanelExpanded!==void 0&&x(_.drawingsPanelExpanded)},[_.drawingsPanelExpanded]);const Ze=xt=>{x(xt),j(xt)},{data:ke=[],isLoading:ze}=Cp(),{data:Ke=[],isLoading:dt}=yj(),Re=[],qt=[],{savedAssemblages:ft=[]}=qS(),Fe=zA(),fe=OA(),Qe=BA(),ht=hD(),_t=IE(),He=pu(),as=Sp(),vt=k.useMemo(()=>{const xt=ke.filter(Qs=>["polygon","polyline","marker"].includes(Qs.type));if(!l||!xt.find(Qs=>Qs.id===l))return xt;const Ls=Qs=>{const Pn=xt.filter(Fn=>Fn.parent_overlay_id===Qs),Ks=Pn.map(Fn=>Fn.id),xa=Pn.flatMap(Fn=>Ls(Fn.id));return[...Ks,...xa]},Es=new Set([l,...Ls(l)]);return xt.filter(Qs=>Es.has(Qs.id))},[ke,l]),{topLevelOverlays:Xe,childOverlaysByParent:Ce,getDepth:Be,getAllDescendants:Dt}=k.useMemo(()=>{const xt={},os={};vt.forEach(Ks=>
752{const xa=Ks.parent_overlay_id;os[Ks.id]=xa||null,xa&&(xt[xa]||(xt[xa]=[]),xt[xa].push(Ks))}),Object.keys(xt).forEach(Ks=>{xt[Ks].sort((xa,Fn)=>{const Sa=xa.display_order??0,sr=Fn.display_order??0;return Sa-sr})});const Ls={},Es=Ks=>{if(Ls[Ks]!==void 0)return Ls[Ks];if(!os[Ks])return Ls[Ks]=0,0;const Fn=new Set;let Sa=0,sr=Ks;for(;sr&&os[sr]&&!Fn.has(sr);)Fn.add(sr),Sa++,sr=os[sr];return Ls[Ks]=Sa,Sa},Qs=Ks=>{const xa=[],Fn=xt[Ks]||[];for(const Sa of Fn)xa.push(Sa),xa.push(...Qs(Sa.id));return xa};return{topLevelOverlays:vt.filter(Ks=>!os[Ks.id]),childOverlaysByParent:xt,getDepth:Es,getAllDescendants:Qs}},[vt]),Rt=Xe,zt=k.useMemo(()=>[...Rt].sort((xt,os)=>{const Ls=xt.display_order??0,Es=os.display_order??0;return Ls-Es}),[Rt]),rs=k.useMemo(()=>{const xt={unfiled:[]};return Ke.forEach(os=>{xt[os.id]=[]}),zt.forEach(os=>{const Ls=os.folder_id;Ls&&xt[Ls]?xt[Ls].push(os):xt.unfiled.push(os)}),xt},[zt,Ke]),_s=k.useCallback(xt=>{if(!Ee.trim())return!0;const os=Ee.toLowerCase();return xt.name.toLowerCase().includes(os)?!0:Dt(xt.id).some(Es=>Es.name.toLowerCase().includes(os))},[Ee,Dt]),vs=k.useMemo(()=>{if(!Ee.trim())return rs;const xt={};for(const[os,Ls]of Object.entries(rs))xt[os]=Ls.filter(_s);return xt},[rs,Ee,_s]);k.useEffect(()=>{if(!Ee.trim())return;const xt=Ee.toLowerCase(),os=new Set;vt.forEach(Ls=>{if(Ls.name.toLowerCase().includes(xt)){let Es=Ls.parent_overlay_id;for(;Es;){os.add(Es);const Qs=vt.find(Pn=>Pn.id===Es);Es=Qs?Qs.parent_overlay_id:null}}}),os.size>0&&q(Ls=>new Set([...Ls,...os]))},[Ee,vt]);const $t=k.useCallback(async xt=>{const{active:os,over:Ls}=xt;if(!Ls||os.id===Ls.id)return;const Es=os.id,Qs=Ls.id,Pn=Es.startsWith("folder-"),Ks=Qs.startsWith("folder-"),xa=(ra,Ka)=>{const Ha=Ke.find(qa=>qa.id===ra);return Ha?Ha.parent_folder_id===Ka?!0:Ha.parent_folder_id?xa(Ha.parent_folder_id,Ka):!1:!1};if(Pn&&Ks){const ra=Es.replace("folder-",""),Ka=Qs.replace("folder-","");if(xa(Ka,ra)){Ve.error("Cannot move folder into its own subfolder");return}const Ha=Ke.find(Mn=>Mn.id===ra),qa=Ke.find(Mn=>Mn.id===Ka);if(!Ha||!qa)return;if(Ha.parent_folder_id===qa.parent_folder_id){const Mn=Ke.filter(Cn=>Cn.parent_folder_id===Ha.parent_folder_id).sort((Cn,Na)=>(Cn.display_order??0)-(Na.display_order??0)),_r=Mn.findIndex(Cn=>Cn.id===ra),Ar=Mn.findIndex(Cn=>Cn.id===Ka);if(_r===-1||Ar===-1)return;const Zs=Hx(Mn,_r,Ar);try{for(let Cn=0;Cn<Zs.length;Cn++)await fe.mutateAsync({id:Zs[Cn].id,display_order:Cn});Ve.success("Folder order updated")}catch{Ve.error("Failed to update folder order")}}else try{await fe.mutateAsync({id:ra,parent_folder_id:Ka}),Ve.success(`Moved "${Ha.name}" into "${qa.name}"`),H(Mn=>new Set([...Mn,Ka]))}catch{Ve.error("Failed to move folder")}return}if(!Pn&&Ks){const ra=Qs.replace("folder-","");if(zt.find(Ha=>Ha.id===Es)){const Ha=Ke.find(qa=>qa.id===ra);try{await He.mutateAsync({id:Es,folder_id:ra}),Ve.success(`Moved to "${(Ha==null?void 0:Ha.name)||"folder"}"`)}catch{Ve.error("Failed to move to folder")}}return}const Fn=zt.find(ra=>ra.id===Es),Sa=zt.find(ra=>ra.id===Qs);if(!Fn||!Sa)return;const sr=Fn.folder_id,An=Sa.folder_id;if(sr!==An){try{await He.mutateAsync({id:Es,folder_id:An}),Ve.success(An?"Moved to folder":"Moved to unfiled")}catch{Ve.error("Failed to move to folder")}return}const xi=rs[sr||"unfiled"]||[],ei=xi.findIndex(ra=>ra.id===Es),Yr=xi.findIndex(ra=>ra.id===Qs);if(ei===-1||Yr===-1)return;const Xo=Hx(xi,ei,Yr);try{for(let ra=0;ra<Xo.length;ra++)await He.mutateAsync({id:Xo[ra].id,display_order:ra});Ve.success("Layer order updated")}catch{Ve.error("Failed to update layer order")}},[zt,rs,He,Ke,fe]),Ns=k.useMemo(()=>{var xa,Fn;const xt={};vt.forEach(Sa=>{const sr=Sa.layer_type||"general";xt[sr]||(xt[sr]={count:0,totalSqft:0,visible:0}),xt[sr].count++,Sa.is_visible&&xt[sr].visible++;const An=Sa.calculated_area_sqft||0;xt[sr].totalSqft+=An});const os={totalPolygons:vt.filter(Sa=>Sa.type==="polygon").length,totalSqft:Object.values(xt).reduce((Sa,sr)=>Sa+sr.totalSqft,0),visibleCount:vt.filter(Sa=>Sa.is_visible).length,hiddenCount:vt.filter(Sa=>!Sa.is_visible).length},Ls=vt.find(Sa=>Sa.layer_type==="property_outline"),Es=Ls&&Ls.calculated_area_sqft||0,Qs=((xa=xt.building_footprint)==null?void 0:xa.totalSqft)||0,Pn=Es>0?Qs/Es*100:0,Ks=((Fn=xt.parking)==null?void 0:Fn.totalSqft)||0;
752return{byType:xt,totals:os,propertySqft:Es,buildingSqft:Qs,buildingCoverage:Pn,parkingSqft:Ks}},[vt]),Ts=async()=>{const xt=vt.filter(os=>!os.is_visible);for(const os of xt)await He.mutateAsync({id:os.id,is_visible:!0});Ve.success(`Showing ${xt.length} layers`)},bs=async()=>{const xt=vt.filter(os=>os.is_visible);for(const os of xt)await He.mutateAsync({id:os.id,is_visible:!1});Ve.success(`Hidden ${xt.length} layers`)},en=async xt=>{const os=vt.filter(Es=>Es.layer_type===xt),Ls=os.every(Es=>Es.is_visible);for(const Es of os)await He.mutateAsync({id:Es.id,is_visible:!Ls});Ve.success(`${Ls?"Hidden":"Showing"} ${os.length} ${gx[xt]||xt} layers`)},Jt=async xt=>{if(Z===xt){oe(null);for(const os of vt)await He.mutateAsync({id:os.id,is_visible:!0});Ve.success("Showing all layers")}else{oe(xt);for(const os of vt){const Ls=os.layer_type===xt;await He.mutateAsync({id:os.id,is_visible:Ls})}Ve.success(`Solo: ${gx[xt]||xt}`)}},Vs=()=>{ae(xt=>!xt),de(new Set)},ps=xt=>{de(os=>{const Ls=new Set(os);return Ls.has(xt)?Ls.delete(xt):Ls.add(xt),Ls})},nt=async()=>{if(ie.size!==0&&confirm(`Delete ${ie.size} selected layer(s)? This cannot be undone.`)){We(!0);try{for(const xt of ie)await as.mutateAsync(xt);Ve.success(`Deleted ${ie.size} layers`),de(new Set),ae(!1)}catch{Ve.error("Failed to delete some layers")}finally{We(!1)}}},ts=()=>{const xt=vt.filter(os=>os.is_visible!==!1).map(os=>os.id);de(new Set(xt))},ds=xt=>{H(os=>{const Ls=new Set(os);return Ls.has(xt)?Ls.delete(xt):Ls.add(xt),Ls})},[Is,tn]=k.useState(!1),wn=async()=>{if(!(!v.trim()||Is)){tn(!0);try{await Fe.mutateAsync({name:v.trim()}),C(""),I(!1),Ve.success("Folder created")}catch{Ve.error("Failed to create folder")}finally{tn(!1)}}},Gs=async()=>{if(!(!z||!v.trim()))try{await fe.mutateAsync({id:z.id,name:v.trim()}),F(null),C(""),Ve.success("Folder renamed")}catch{Ve.error("Failed to rename folder")}},Ue=async xt=>{if(confirm(`Delete folder "${xt.name}"? Items will be moved to unfiled.`))try{await Qe.mutateAsync(xt.id),Ve.success("Folder deleted")}catch{Ve.error("Failed to delete folder")}},Pe=async(xt,os)=>{try{await He.mutateAsync({id:xt.id,folder_id:os}),Ve.success("Item moved")}catch{Ve.error("Failed to move item")}},je=async xt=>{try{await He.mutateAsync({id:xt.id,is_visible:!xt.is_visible})}catch{Ve.error("Failed to update visibility")}},Ge=async xt=>{try{const os=xt.is_visible===!1;await fe.mutateAsync({id:xt.id,is_visible:os}),Ve.success(os?"Folder contents shown on map":"Folder contents hidden from map")}catch{Ve.error("Failed to update folder visibility")}},De=async xt=>{if(confirm(`Delete "${xt.name}"?`))try{await as.mutateAsync(xt.id),Ve.success("Item deleted")}catch{Ve.error("Failed to delete item")}},bt=async(xt,os)=>{try{await He.mutateAsync({id:xt.id,parent_overlay_id:os}),Ve.success(os?"Set as child layer":"Removed from parent")}catch{Ve.error("Failed to update parent")}},Ct=async(xt,os)=>{if(K)try{const Ls={id:K.id,development_id:xt==="development"?os:null,existing_product_id:xt==="existing"?os:null,assemblage_id:xt==="assemblage"?os:null};await He.mutateAsync(Ls),te(null),Ve.success(os?"Linked to project":"Unlinked from project")}catch{Ve.error("Failed to link")}},pe=xt=>{const os=xt;if(os.development_id){const Ls=Re.find(Es=>Es.id===os.development_id);return Ls?{type:"development",name:Ls.name}:null}if(os.existing_product_id){const Ls=qt.find(Es=>Es.id===os.existing_product_id);return Ls?{type:"existing",name:Ls.name}:null}if(os.assemblage_id){const Ls=ft.find(Es=>Es.id===os.assemblage_id);return Ls?{type:"assemblage",name:Ls.name}:null}return null},wt=xt=>{q(os=>{const Ls=new Set(os);return Ls.has(xt)?Ls.delete(xt):Ls.add(xt),Ls})},Zt=xt=>{var os;return((os=Ce[xt])==null?void 0:os.length)||0},ys=(xt,os=1)=>{var sr;const Ls=xt.layer_type||"general",Es=Zt(xt.id)>0,Qs=O.has(xt.id),Pn=Be(xt.id),Ks=()=>{t&&t(xt),a&&a(xt)},xa=An=>{const Ai=Ce[An]||[],xi=[];for(const ei of Ai)xi.push(ei.id),xi.push(...xa(ei.id));return xi},Fn=new Set(xa(xt.id)),Sa=vt.filter(An=>An.id!==xt.id&&!Fn.has(An.id));return e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("div",{className:`flex items-center gap-2 px-2 py-1 rounded-md hover:bg-muted/50 group cursor-pointer ${xt.is_visible?"":"opacity-50"} ${ie.has(xt.id)?"bg-primary/10 border border-primary/30":""}`,onClick:ce?()=>ps(xt.id):Ks,title:ce?"Click to select":"Click to navigate to layer",children:[ce?e.jsx(Ux,{checked:ie.has(xt.id),onCheckedChange:()=>ps(xt.id),onClick:An=>An.stopPropagation(),className:"h-4 w-4"}):Es?e.jsx("button",{onClick:An=>{An.stopPropagation(),wt(xt.id)},className:"p-0.5",children:Qs?e.jsx(Oa,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(Ao,{className:"w-3 h-3 text-muted-foreground"})}):e.jsx(m3,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",onClick:ce?void 0:Ks,children:[e.jsx("span",{className:DE[xt.type]||"text-muted-foreground",children:AE[xt.type]||e.jsx(Da,{className:"w-3 h-3"})}),e.jsx("span",{className:"flex-1 text-xs truncate",children:xt.name}),e.jsxs(Mt,{variant:"outline",className:"text-[9px] h-3.5 px-1 shrink-0 opacity-50",children:["L",Pn+1]}),e.jsx(Mt,{variant:"outline",className:`text-[10px] h-4 px-1.5 shrink-0 ${ig[Ls]||ig.general}`,children:gx[Ls]||Ls}),Es&&e.jsxs(Mt,{variant:"secondary",className:"text-[10px] h-4 px-1 shrink-0",children:[e.jsx(zx,{className:"w-2.5 h-2.5 mr-0.5"}),Zt(xt.id)]})]}),!ce&&e.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:An=>An.stopPropagation(),children:[e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:An=>{An.stopPropagation(),je(xt)},title:xt.is_visible?"Hide":"Show",children:xt.is_visible?e.jsx(kc,{className:"w-3 h-3"}):e.jsx(Wc,{className:"w-3 h-3"})}),e.jsxs(jp,{children:[e.jsx(wp,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:An=>An.stopPropagation(),children:e.jsx(Mg,{className:"w-3 h-3"})})}),e.jsxs(Np,{align:"end",className:"w-52 bg-popover border border-border shadow-lg z-50",children:[n&&xt.type==="polygon"&&e.jsxs(co,{onClick:()=>n(xt),children:[e.jsx(Du,{className:"w-4 h-4 mr-2"}),"Edit Geometry"]}),a&&xt.type==="polygon"&&e.jsxs(co,{onClick:()=>a(xt),children:[e.jsx(Dh,{className:"w-4 h-4 mr-2"}),"Polygon Tools"]}),e.jsxs(co,{onClick:()=>X(xt),children:[e.jsx(lS,{className:"w-4 h-4 mr-2"}),"Rename"]}),e.jsxs(Mx,{children:[e.jsxs(Ix,{children:[e.jsx(zx,{className:"w-4 h-4 mr-2"}),"Set as Child of..."]}),e.jsxs(Ax,{className:"bg-popover border border-border shadow-lg z-50 max-h-64 overflow-y-auto",children:[e.jsx(co,{onClick:()=>bt(xt,null),children:e.jsx("span",{className:"text-muted-foreground",children:"Make Top-Level"})}),e.jsx(cd,{}),Sa.map(An=>e.jsxs(co,{onClick:()=>bt(xt,An.id),className:"flex items-center gap-2",children:[e.jsx(fd,{className:"w-4 h-4 text-amber-500"}),e.jsx("span",{className:"flex-1 truncate",children:An.name}),Be(An.id)>0&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["L",Be(An.id)+1]})]},An.id)),Sa.length===0&&e.jsx(co,{disabled:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:"No other layers available"})})]})]}),e.jsx(cd,{}),e.jsxs(co,{className:"text-destructive focus:text-destructive",onClick:()=>De(xt),children:[e.jsx(wr,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]})]})]}),Es&&Qs&&e.jsx("div",{className:"ml-4 pl-2 border-l border-border/50 space-y-0.5",children:(sr=Ce[xt.id])==null?void 0:sr.map(An=>ys(An,os+1))})]},xt.id)},es=async(xt,os)=>{try{if(await fe.mutateAsync({id:xt.id,parent_folder_id:os}),os){const Ls=Ke.find(Es=>Es.id===os);Ve.success(`Moved "${xt.name}" into "${(Ls==null?void 0:Ls.name)||"folder"}"`),H(Es=>new Set([...Es,os]))}else Ve.success(`Moved "${xt.name}" to root level`)}catch{Ve.error("Failed to move folder")}},is=k.useMemo(()=>Ke.filter(xt=>!xt.parent_folder_id).sort((xt,os)=>(xt.display_order??0)-(os.display_order??0)),[Ke]),Ws=xt=>Ke.filter(os=>os.parent_folder_id===xt).sort((os,Ls)=>(os.display_order??0)-(Ls.display_order??0)),an=xt=>{const Ls=(rs[xt]||[]).reduce((Pn,Ks)=>Pn+1+Zt(Ks.id),0),Es=Ws(xt),Qs=Es.reduce((Pn,Ks)=>
752Pn+an(Ks.id),0);return Ls+Qs+Es.length},ya=(xt,os=0)=>{const Ls=vs[xt.id]||[],Es=Ws(xt.id),Qs=J.has(xt.id),Pn=an(xt.id);return e.jsxs(fD,{folder:xt,isOpen:Qs,totalItems:Pn,depth:os,onToggleFolder:()=>ds(xt.id),onToggleVisibility:()=>Ge(xt),onEditFolder:()=>{F(xt),C(xt.name)},onDeleteFolder:()=>Ue(xt),onDuplicateFolder:()=>ht.mutate({folder:xt,allFolders:Ke,allOverlays:ke}),onMoveToParentFolder:Ks=>es(xt,Ks),allFolders:Ke,children:[Es.length>0&&e.jsx("div",{className:"space-y-0.5",children:Es.map(Ks=>ya(Ks,os+1))}),Ls.length>0&&e.jsx("div",{className:"ml-4 space-y-0.5",style:{marginLeft:(os+1)*16},children:e.jsx(ky,{items:Ls.map(Ks=>Ks.id),strategy:Ny,children:Ls.map(Ks=>e.jsx(tk,{overlay:Ks,isSelected:ie.has(Ks.id),selectMode:ce,onToggleSelection:()=>ps(Ks.id),onNavigate:()=>t==null?void 0:t(Ks),onToggleVisibility:()=>je(Ks),onEdit:()=>n==null?void 0:n(Ks),onDelete:()=>De(Ks),onDuplicate:()=>_t.mutate({overlay:Ks,allOverlays:ke}),onOpenPolygonTools:a?()=>a(Ks):void 0,childCount:Zt(Ks.id),isExpanded:O.has(Ks.id),onToggleExpand:()=>wt(Ks.id),folders:Ke,parentOverlays:Rt,onMoveToFolder:xa=>Pe(Ks,xa),onSetParent:xa=>bt(Ks,xa),onOpenLinkDialog:()=>te(Ks),link:pe(Ks),children:Ce[Ks.id]&&e.jsx("div",{className:"ml-6 pl-2 border-l border-border/50 space-y-0.5",children:Ce[Ks.id].map(ys)})},Ks.id))})})]},xt.id)},Hs=ze||dt;return e.jsxs(e.Fragment,{children:[e.jsxs(wi,{open:y,onOpenChange:Ze,children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",className:"w-full justify-between px-4 py-2 h-auto hover:bg-muted/50",children:[e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(kp,{className:"w-4 h-4 text-indigo-500"}),"Drawings (",vt.length,")"]})}),e.jsx(or,{side:"right",children:"DrawingsSidebarPanel"})]}),y?e.jsx(Oa,{className:"w-4 h-4"}):e.jsx(Ao,{className:"w-4 h-4"})]})}),e.jsxs(ki,{className:"px-4 py-2 space-y-2",children:[e.jsx("div",{className:"flex items-center gap-1.5 justify-end",children:e.jsx(Le,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>{if(O.size>0||J.size>0)q(new Set),H(new Set);else{const xt=new Set;vt.forEach(os=>{var Ls;((Ls=Ce[os.id])==null?void 0:Ls.length)>0&&xt.add(os.id)}),q(xt),H(new Set(Ke.map(os=>os.id)))}},title:O.size>0||J.size>0?"Collapse All":"Expand All",children:e.jsx(Fb,{className:"w-3.5 h-3.5"})})}),e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsxs(Le,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:()=>I(!0),children:[e.jsx(g3,{className:"w-3 h-3"}),"New Folder"]}),s&&e.jsxs(e.Fragment,{children:[e.jsxs(Le,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:()=>s("polygon"),children:[e.jsx(fd,{className:"w-3 h-3"}),"Polygon"]}),e.jsxs(Le,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:()=>s("polyline"),children:[e.jsx(uo,{className:"w-3 h-3"}),"Line"]}),e.jsxs(Le,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:()=>s("marker"),children:[e.jsx(ji,{className:"w-3 h-3"}),"Marker"]})]})]}),vt.length>0&&e.jsxs("div",{className:"flex items-center gap-1 flex-wrap border-t pt-2",children:[e.jsxs(Le,{size:"sm",variant:ce?"secondary":"ghost",className:"h-6 text-[10px] gap-1 px-2",onClick:Vs,children:[e.jsx(B3,{className:"w-3 h-3"}),ce?"Cancel":"Select"]}),ce?e.jsxs(e.Fragment,{children:[e.jsx(Le,{size:"sm",variant:"ghost",className:"h-6 text-[10px] gap-1 px-2",onClick:ts,children:"All"}),e.jsxs(Le,{size:"sm",variant:"ghost",className:"h-6 text-[10px] gap-1 px-2 text-destructive hover:text-destructive",onClick:nt,disabled:ie.size===0||ge,children:[ge?e.jsx(Va,{className:"w-3 h-3 animate-spin"}):e.jsx(wr,{className:"w-3 h-3"}),"Delete (",ie.size,")"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Le,{size:"sm",variant:"ghost",className:"h-6 text-[10px] gap-1 px-2",onClick:Ts,disabled:Ns.totals.hiddenCount===0,children:[e.jsx(kc,{className:"w-3 h-3"}),"Show All"]}),e.jsxs(Le,{size:"sm",variant:"ghost",className:"h-6 text-[10px] gap-1 px-2",onClick:bs,disabled:Ns.totals.visibleCount===0,children:[e.jsx(Wc,{className:"w-3 h-3"}),"Hide All"]})]}),e.jsxs(Le,{size:"sm",variant:W?"secondary":"ghost",className:"h-6 text-[10px] gap-1 px-2 ml-auto",onClick:()=>
752Q(!W),children:[e.jsx(_g,{className:"w-3 h-3"}),"Stats"]})]}),W&&vt.length>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 space-y-3",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Layer Statistics"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"bg-card rounded p-2",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Total Area"}),e.jsx("div",{className:"text-sm font-semibold",children:Ns.totals.totalSqft>43560?`${(Ns.totals.totalSqft/43560).toFixed(2)} ac`:`${Ns.totals.totalSqft.toLocaleString()} sf`})]}),e.jsxs("div",{className:"bg-card rounded p-2",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Coverage"}),e.jsxs("div",{className:"text-sm font-semibold",children:[Ns.buildingCoverage.toFixed(1),"%"]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground font-medium",children:"By Layer Type"}),Object.entries(Ns.byType).map(([xt,os])=>e.jsxs("div",{className:"flex items-center gap-2 text-xs hover:bg-muted/50 rounded px-1 py-0.5 group",children:[e.jsx(Mt,{variant:"outline",className:`text-[9px] h-4 px-1 shrink-0 ${ig[xt]||ig.general}`,children:gx[xt]||xt}),e.jsxs("span",{className:"text-muted-foreground flex-1",children:[os.count," layer",os.count!==1?"s":""]}),e.jsx("span",{className:"font-medium",children:os.totalSqft>43560?`${(os.totalSqft/43560).toFixed(2)} ac`:`${os.totalSqft.toLocaleString()} sf`}),e.jsxs("div",{className:"opacity-0 group-hover:opacity-100 flex gap-0.5",children:[e.jsx(Le,{size:"icon",variant:"ghost",className:"h-5 w-5",onClick:()=>en(xt),title:"Toggle visibility",children:os.visible===os.count?e.jsx(kc,{className:"w-3 h-3"}):e.jsx(Wc,{className:"w-3 h-3"})}),e.jsx(Le,{size:"icon",variant:Z===xt?"secondary":"ghost",className:"h-5 w-5",onClick:()=>Jt(xt),title:"Solo this layer type",children:e.jsx(Da,{className:"w-3 h-3"})})]})]},xt))]})]}),Hs?e.jsx("div",{className:"text-center py-4 text-muted-foreground text-sm",children:"Loading..."}):vt.length===0&&Ke.length===0?e.jsxs("div",{className:"text-center py-6 space-y-2",children:[e.jsx("div",{className:"w-12 h-12 mx-auto bg-muted/50 rounded-full flex items-center justify-center",children:e.jsx(fd,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No drawings yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Copy parcels from the map or use the drawing tools to create polygons, lines, and markers."})]}):e.jsx(jE,{sensors:we,collisionDetection:cE,onDragEnd:$t,children:e.jsx(ky,{items:[...Ke.map(xt=>`folder-${xt.id}`),...zt.map(xt=>xt.id)],strategy:Ny,children:e.jsx(Xc,{className:"max-h-[calc(100vh-320p
752x)]",children:e.jsxs("div",{className:"space-y-1",children:[is.map(xt=>ya(xt,0)),vs.unfiled&&vs.unfiled.length>0&&e.jsxs("div",{className:"space-y-0.5",children:[Ke.length>0&&e.jsxs("div",{className:"px-2 py-1 text-xs text-muted-foreground font-medium",children:["Unfiled (",vs.unfiled.reduce((xt,os)=>xt+1+Zt(os.id),0),")"]}),e.jsx(ky,{items:vs.unfiled.map(xt=>xt.id),strategy:Ny,children:vs.unfiled.map(xt=>e.jsx(tk,{overlay:xt,isSelected:ie.has(xt.id),selectMode:ce,onToggleSelection:()=>ps(xt.id),onNavigate:()=>t==null?void 0:t(xt),onToggleVisibility:()=>je(xt),onEdit:()=>n==null?void 0:n(xt),onDelete:()=>De(xt),onDuplicate:()=>_t.mutate({overlay:xt,allOverlays:ke}),onOpenPolygonTools:a?()=>a(xt):void 0,childCount:Zt(xt.id),isExpanded:O.has(xt.id),onToggleExpand:()=>wt(xt.id),folders:Ke,parentOverlays:Rt,onMoveToFolder:os=>Pe(xt,os),onSetParent:os=>bt(xt,os),onOpenLinkDialog:()=>te(xt),link:pe(xt),children:Ce[xt.id]&&e.jsx("div",{className:"ml-6 pl-2 border-l border-border/50 space-y-0.5",children:Ce[xt.id].map(ys)})},xt.id))})]})]})})})})]})]}),e.jsx(dd,{open:P,onOpenChange:xt=>{xt||(I(!1),C(""))},children:e.jsxs(ud,{className:"bg-background",children:[e.jsxs(Gd,{children:[e.jsx(Hd,{children:"Create Folder"}),e.jsx(vg,{children:"Enter a name for the new folder."})]}),e.jsx(be,{placeholder:"Folder name",value:v,onChange:xt=>C(xt.target.value),onKeyDown:xt=>{xt.key==="Enter"&&!Is&&(xt.preventDefault(),wn())},disabled:Is}),e.jsxs(vf,{children:[e.jsx(Le,{variant:"outline",onClick:()=>I(!1),disabled:Is,children:"Cancel"}),e.jsx(Le,{onClick:wn,disabled:!v.trim()||Is,children:Is?"Creating...":"Create"})]})]})}),e.jsx(dd,{open:!!z,onOpenChange:xt=>!xt&&F(null),children:e.jsxs(ud,{className:"bg-background",children:[e.jsx(Gd,{children:e.jsx(Hd,{children:"Rename Folder"})}),e.jsx(be,{placeholder:"Folder name",value:v,onChange:xt=>C(xt.target.value),onKeyDown:xt=>xt.key==="Enter"&&Gs()}),e.jsxs(vf,{children:[e.jsx(Le,{variant:"outline",onClick:()=>F(null),children:"Cancel"}),e.jsx(Le,{onClick:Gs,disabled:!v.trim(),children:"Save"})]})]})}),e.jsx(dd,{open:!!D,onOpenChange:xt=>!xt&&X(null),children:e.jsxs(ud,{className:"bg-background",children:[e.jsx(Gd,{children:e.jsx(Hd,{children:"Rename Drawing"})}),e.jsx(be,{placeholder:"Name",defaultValue:D==null?void 0:D.name,onKeyDown:async xt=>{if(xt.key==="Enter"&&D){const os=xt.target.value.trim();os&&(await He.mutateAsync({id:D.id,name:os}),X(null),Ve.success("Renamed"))}}}),e.jsxs(vf,{children:[e.jsx(Le,{variant:"outline",onClick:()=>X(null),children:"Cancel"}),e.jsx(Le,{onClick:async()=>{const xt=document.querySelector('input[placeholder="Name"]');if(xt&&D){const os=xt.value.trim();os&&(await He.mutateAsync({id:D.id,name:os}),X(null),Ve.success("Renamed"))}},children:"Save"})]})]})}),e.jsx(dd,{open:!!K,onOpenChange:xt=>!xt&&te(null),children:e.jsxs(ud,{className:"bg-background",children:[e.jsxs(Gd,{children:[e.jsx(Hd,{children:"Link to Project"}),e.jsxs(vg,{children:['Attach "',K==null?void 0:K.name,'" to a project for organization.']})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"New Development"}),e.jsxs(rt,{onValueChange:xt=>Ct("development",xt||null),children:[e.jsx(it,{children:e.jsx(ct,{placeholder:"Select development..."})}),e.jsxs(ot,{className:"bg-popover border border-border z-50",children:[e.jsx(le,{value:"none",children:"None"}),Re.map(xt=>e.jsx(le,{value:xt.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ci,{className:"w-4 h-4"}),xt.name]})},xt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Existing Site"}),e.jsxs(rt,{onValueChange:xt=>Ct("existing",xt||null),children:[e.jsx(it,{children:e.jsx(ct,{placeholder:"Select existing site..."})}),e.jsxs(ot,{className:"bg-popover border border-border z-50",children:[e.jsx(le,{value:"none",children:"None"}),qt.map(xt=>e.jsx(le,{value:xt.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Sc,{className:"w-4 h-4"}),xt.name]})},xt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Assemblage"}),e.jsxs(rt,{onValueChange:xt=>Ct("assemblage",xt||null),children:[e.jsx(it,{children:e.jsx(ct,{placeholder:"Select assemblage..."})}),e.jsxs(ot,{className:"bg-popover border border-border z-50",children:[e.jsx(le,{value:"none",children:"None"}),ft.map(xt=>e.jsx(le,{value:xt.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Da,{className:"w-4 h-4"}),xt.name]})},xt.id))]})]})]})]}),e.jsx(vf,{children:e.jsx(Le,{variant:"outline",onClick:()=>te(null),children:"Close"})})]})})]})};function $g(){const{data:t,isLoading:s}=sS();return{isEnabled:(t==null?void 0:t.site_architect_enabled)==="true",isLoading:s}}const nk=({developments:t,existingProducts:s=[],selectedDevelopment:n,selectedExistingProduct:a,onSelectDevelopment:l,onSelectExistingProduct:c,filters:u,onFiltersChange:i,isLoading:_,scrollPosition:j=0,onScrollPositionChange:y,isCollapsed:x=!1,onToggleCollapse:v,isAdmin:C=!1,pendingDeveloperId:P,pen
752dingOwnerId:I,pendingTenantId:z,onClearPendingCrm:F,onNavigateToProperty:D,onViewOnMap:X,onToggleCrmVisibility:K,visibleDeveloperIds:te,visibleOwnerIds:J,visibleTenantIds:H,assemblages:O=[],isLoadingAssemblages:q=!1,selectedAssemblageId:W,onSelectAssemblage:Q,onDeleteAssemblage:Z,isDeletingAssemblage:oe=!1,onNavigateToOverlay:ce,onEditOverlay:ae,onOpenPolygonTools:ie,onStartDrawing:de,onSiteLayoutsModeChange:ge,activeSiteLayoutId:We,activeFocusId:Ee,onActiveFocusIdChange:ve,onShowSiteArchitectDashboard:we})=>{var Ge;const{preferences:Ze,savePreferences:ke,isLoading:ze}=Kx(),{isEnabled:Ke}=$g(),[dt,Re]=k.useState(""),[qt,ft]=k.useState("layouts"),[Fe,fe]=k.useState(()=>{try{const De=localStorage.getItem("sidebar-show-logo");return De!==null?De==="true":!0}catch{return!0}}),[Qe,ht]=k.useState(!1),[_t,He]=k.useState({x:80,y:100}),[as,vt]=k.useState(!1),[Xe,Ce]=k.useState({x:0,y:0});k.useEffect(()=>{if(!as)return;const De=Ct=>{const pe=Ct.clientX-Xe.x,wt=Ct.clientY-Xe.y;He({x:Math.max(20,Math.min(window.innerWidth-380,pe)),y:Math.max(20,Math.min(window.innerHeight-200,wt))})},bt=()=>vt(!1);return window.addEventListener("mousemove",De),window.addEventListener("mouseup",bt),()=>{window.removeEventListener("mousemove",De),window.removeEventListener("mouseup",bt)}},[as,Xe]);const[Be,Dt]=k.useState({type:null,id:null,name:null}),[Rt,zt]=k.useState(()=>{try{const De=localStorage.getItem("sidebar-show-new-developments");return De!==null?JSON.parse(De):!0}catch{return!0}}),[rs,_s]=k.useState(()=>{try{const De=localStorage.getItem("sidebar-show-existing-sites");return De!==null?JSON.parse(De):!0}catch{return!0}});k.useEffect(()=>{var De;if(!ze&&((De=Ze.preferences)!=null&&De.leftSidebarSections)){const bt=Ze.preferences.leftSidebarSections;bt.newDevelopments!==void 0&&zt(bt.newDevelopments),bt.existingSites!==void 0&&_s(bt.existingSites)}},[ze,(Ge=Ze.preferences)==null?void 0:Ge.leftSidebarSections]);const[vs,$t]=k.useState(()=>{try{const De=localStorage.getItem("sidebar-all-sections-collapsed");return De!==null?JSON.parse(De):!1}catch{return!1}}),Ns=k.useCallback(()=>{var Ct;const De=!vs;$t(De),localStorage.setItem("sidebar-all-sections-collapsed",JSON.stringify(De));const bt=((Ct=Ze.preferences)==null?void 0:Ct.leftSidebarSections)||{};De?(zt(!1),localStorage.setItem("sidebar-show-new-developments",JSON.stringify(!1)),_s(!1),localStorage.setItem("sidebar-show-existing-sites",JSON.stringify(!1)),ke({preferences:{...Ze.preferences,leftSidebarSections:{...bt,newDevelopments:!1,existingSites:!1}}})):(zt(!0),localStorage.setItem("sidebar-show-new-developments",JSON.stringify(!0)),_s(!0),localStorage.setItem("sidebar-show-existing-sites",JSON.stringify(!0)),ke({preferences:{...Ze.preferences,leftSidebarSections:{...bt,newDevelopments:!0,existingSites:!0}}}))},[vs,Ze.preferences,ke]),Ts=k.useRef(null),bs=k.useRef(null),en=k.useRef(!1),Jt=k.useCallback(()=>{!v||!x||en.current||(en.current=!0,v(),window.setTimeout(()=>{en.current=!1},450))},[v,x]),[Vs,ps]=k.useState(-1),{data:nt}=dj(),{data:ts}=uj(),{developers:ds}=Jx(),{owners:Is}=Qx(),{tenants:tn}=I1(),wn=k.useCallback((De,bt)=>{if(!bt.trim())return De;const Ct=new RegExp(`(${bt.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return De.split(Ct).map((wt,Zt)=>Ct.test(wt)?e.jsx("mark",{className:"bg-yellow-200 dark:bg-yellow-800 text-inherit rounded-sm px-0.5",children:wt},Zt):wt)},[]);k.useEffect(()=>{Ts.current&&j>0&&(Ts.current.scrollTop=j)},[j]),k.useEffect(()=>{if(dt.trim()){const De=dt.toLowerCase(),bt=t.filter(Ct=>{var pe;return Ct.name.toLowerCase().includes(De)||((pe=Ct.description)==null?void 0:pe.toLowerCase().includes(De))});s.filter(Ct=>{var pe;return Ct.name.toLowerCase().includes(De)||((pe=Ct.description)==null?void 0:pe.toLowerCase().includes(De))}),bt.length>0&&!Rt&&zt(!0)}},[dt,t,s,nt,ts,ds,Is]);const Gs=()=>{Ts.current&&y&&y(Ts.current.scrollTop)},Ue=t.filter(De=>{var es;const bt=u.types.length===0||u.types.includes(De.type),Ct=u.statuses.length===0||u.statuses.includes(De.status),pe=dt===""||De.name.toLowerCase().includes(dt.toLowerCase())||((es=De.description)==null?void 0:es.toLowerCase().includes(dt.toLowerCase())),wt=!u.developerId||De.developer_id===u.developerId,Zt=!u.ownerId||De.owner_id===u.ownerId;let ys=!0;return u.tenantId&&(ys=((nt==null?void 0:nt.get(De.id))||[]).some(Ws=>{var an;return((an=Ws.retailer_logo)==null?void 0:an.name)===u.tenantId})),bt&&Ct&&pe&&wt&&Zt&&ys}),Pe=s.filter(De=>{var is;const bt=u.types.length===0||u.types.includes(De.type),Ct=u.statuses.length===0||u.statuses.includes(De.status),pe=dt===""||De.name.toLowerCase().includes(dt.toLowerCase())||((is=De.description)==null?void 0:is.toLowerCase().includes(dt.toLowerCase())),wt=!u.developerId||De.developer_id===u.developerId,Zt=!u.ownerId||De.owner_id===u.ownerId;let ys=!0;u.tenantId&&(ys=((ts==null?void 0:ts.get(De.id))||[]).some(an=>{var ya;return((ya=an.retailer_logo)==null?void 0:ya.name)===u.tenantId}));const es=!u.existingSiteType||u.existingSiteType==="all"||De.type===u.existingSiteType;return bt&&Ct&&pe&&wt&&Zt&&ys&&es}),je=k.useMemo(()=>dt.trim()?[...Ue.map(De=>({type:"development",item:De})),...Pe.map(De=>({type:"existing",item:De}))]:[],[Ue,Pe,dt]);return k.useEffect(()=>{ps(-1)}
752,[dt]),k.useCallback(De=>{var bt,Ct;if(!(!dt.trim()||je.length===0))switch(De.key){case"ArrowDown":De.preventDefault(),ps(pe=>pe<je.length-1?pe+1:pe);break;case"ArrowUp":De.preventDefault(),ps(pe=>pe>0?pe-1:-1);break;case"Enter":if(De.preventDefault(),Vs>=0&&Vs<je.length){const pe=je[Vs];pe.type==="development"?l(pe.item):c&&c(pe.item),Re(""),ps(-1),(bt=bs.current)==null||bt.blur()}break;case"Escape":De.preventDefault(),ps(-1),Re(""),(Ct=bs.current)==null||Ct.blur();break}},[dt,je,Vs,l,c]),x?e.jsx(hm,{delayDuration:100,children:e.jsxs("div",{className:"h-full flex flex-col bg-sidebar border-r border-sidebar-border w-16 items-start pl-1 pr-3 py-3 gap-1",children:[e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx("button",{onClick:Jt,className:"p-2 hover:bg-muted rounded-lg text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(E3,{className:"w-5 h-5"})})}),e.jsx(or,{side:"right",children:"Expand sidebar"})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx("button",{onClick:Jt,className:"my-2 rounded-lg p-0.5 transition-colors bg-white shadow-sm ring-1 ring-primary/20",children:e.jsx(Oy,{size:"sm",className:"h-10 w-10"})})}),e.jsx(or,{side:"right",children:"Site Architect"})]}),e.jsx("div",{className:"w-8 h-px bg-border my-1"}),e.jsx("span",{className:"text-[7px] font-bold text-orange-400 tracking-wider uppercase",children:"SA.ai"}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx("button",{onClick:Jt,className:"p-2 hover:bg-muted rounded-lg text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(Ld,{className:"w-5 h-5"})})}),e.jsx(or,{side:"right",children:"Search projects"})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx("button",{onClick:Jt,className:"p-2 hover:bg-muted rounded-lg transition-colors text-muted-foreground hover:text-foreground",children:e.jsx(ji,{className:"w-5 h-5"})})}),e.jsx(or,{side:"right",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:"Properties"}),e.jsx(Mt,{variant:"secondary",className:"text-xs",children:t.length+s.length})]})})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx("button",{onClick:()=>{Jt()},className:"p-2 hover:bg-muted rounded-lg transition-colors text-muted-foreground hover:text-foreground",children:e.jsx(oS,{className:"w-5 h-5"})})}),e.jsx(or,{side:"right",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:"CRM"}),e.jsx(Mt,{variant:"secondary",className:"text-xs",children:ds.length+Is.length+tn.length})]})})]}),Ke&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-8 h-px bg-border my-1"}),e.jsx("span",{className:"text-[7px] font-bold text-blue-400 tracking-wider uppercase",children:"SA.ai"}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx("button",{onClick:Jt,className:"p-2 hover:bg-orange-500/10 rounded-lg transition-colors text-orange-500 hover:text-orange-400",children:e.jsx(Du,{className:"w-5 h-5"})})}),e.jsx(or,{side:"right",children:"Site Layouts"})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx("button",{onClick:Jt,className:"p-2 hover:bg-muted rounded-lg transition-colors text-muted-foreground hover:text-foreground",children:e.jsx(Da,{className:"w-5 h-5"})})}),e.jsx(or,{side:"right",children:"Assemblages"})]})]}),e.jsx("div",{className:"w-8 h-px bg-border my-1"})]})}):e.jsxs("div",{className:"h-full flex flex-col bg-sidebar border-r border-sidebar-border",children:[Fe?e.jsxs("div",{className:"bg-white shadow-md",children:[e.jsx("div",{className:"flex items-center justify-center p-3",children:e.jsx(Oy,{size:"lg",className:"h-16 w-auto"})}),e.jsxs("div",{className:"flex items-center justify-end gap-0.5 px-2 py-1 border-t border-border/50",children:[e.jsx("button",{onClick:()=>{fe(!1),localStorage.setItem("sidebar-show-logo","false")},className:"p-1.5 hover:bg-gray-100 rounded-lg text-gray-600 hover:text-gray-900 transition-colors",title:"Hide header",children:e.jsx(Wc,{className:"w-4 h-4"})}),e.jsx("button",{onClick:Ns,className:"p-1.5 hover:bg-gray-100 rounded-lg text-gray-600 hover:text-gray-900 transition-colors",title:vs?"Expand all sections":"Collapse all sections",children:vs?e.jsx(Fb,{className:"w-4 h-4"}):e.jsx(eN,{className:"w-4 h-4"})}),v&&e.jsx("button",{onClick:v,className:"p-1.5 hover:bg-gray-100 rounded-lg text-gray-600 hover:text-gray-900 transition-colors",title:"Collapse sidebar",children:e.jsx(aN,{className:"w-4 h-4"})})]})]}):e.jsxs("div",{className:"px-2 py-1 bg-sidebar flex items-center justify-end gap-1 border-b border-sidebar-border",children:[e.jsx("button",{onClick:()=>
752{fe(!0),localStorage.setItem("sidebar-show-logo","true")},className:"p-1.5 hover:bg-muted rounded-lg text-muted-foreground hover:text-foreground transition-colors",title:"Show header",children:e.jsx(kc,{className:"w-4 h-4"})}),e.jsx("button",{onClick:Ns,className:"p-1.5 hover:bg-muted rounded-lg text-muted-foreground hover:text-foreground transition-colors",title:vs?"Expand all sections":"Collapse all sections",children:vs?e.jsx(Fb,{className:"w-4 h-4"}):e.jsx(eN,{className:"w-4 h-4"})}),v&&e.jsx("button",{onClick:v,className:"p-1.5 hover:bg-muted rounded-lg text-muted-foreground hover:text-foreground transition-colors",title:"Collapse sidebar",children:e.jsx(aN,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"p-4 pt-2 pb-2 bg-sidebar",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ld,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),e.jsx(be,{ref:bs,placeholder:"Search layouts...",value:dt,onChange:De=>Re(De.target.value),className:"pl-9 bg-white border-gray-300 text-gray-900 placeholder:text-gray-500"}),dt&&e.jsx("button",{onClick:()=>Re(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded hover:bg-muted text-gray-400 hover:text-gray-600",children:e.jsx(ja,{className:"w-3.5 h-3.5"})})]}),Ke&&e.jsx("div",{className:"mt-2",children:e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsxs(Le,{variant:qt==="layouts"?"default":"outline",size:"sm",className:`h-8 text-xs gap-1.5 ${qt==="layouts"?"bg-orange-500 hover:bg-orange-600 text-white border-orange-500":"border-orange-400/50 text-orange-500 hover:bg-orange-500/10 hover:text-orange-400"}`,onClick:()=>{const De=qt==="layouts"?"":"layouts";ft(De),ge==null||ge(De==="layouts")},children:[e.jsx(Du,{className:"w-3.5 h-3.5"}),"Layouts"]}),e.jsxs(Le,{variant:qt==="assemblages"?"default":"outline",size:"sm",className:`h-8 text-xs gap-1.5 ${qt==="assemblages"?"bg-orange-500 hover:bg-orange-600 text-white border-orange-500":"border-orange-400/50 text-orange-500 hover:bg-orange-500/10 hover:text-orange-400"}`,onClick:()=>ft(qt==="assemblages"?"":"assemblages"),children:[e.jsx(Da,{className:"w-3.5 h-3.5"}),"Assemblages"]}),qt==="layouts"&&e.jsx(Le,{variant:Qe?"default":"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>ht(!Qe),title:Qe?"Dock layouts panel":"Detach layouts panel",children:Qe?e.jsx(Cf,{className:"h-3.5 w-3.5"}):e.jsx(Wy,{className:"h-3.5 w-3.5"})})]})})]}),qt==="crm"&&e.jsx(UI,{isAdmin:C,pendingDeveloperId:P,pendingOwnerId:I,pendingTenantId:z,onClearPendingCrm:F,onNavigateToProperty:D,onViewOnMap:X,onToggleCrmVisibility:K,visibleDeveloperIds:te,visibleOwnerIds:J,visibleTenantIds:H,crmFilter:Be,onCrmFilterChange:Dt}),e.jsxs("div",{ref:Ts,onScroll:Gs,className:"flex-1 overflow-y-auto",children:[qt==="properties"&&e.jsx(s4,{developments:Ue,existingProducts:Pe,selectedDevelopment:n,selectedExistingProduct:a||null,onSelectDevelopment:l,onSelectExistingProduct:c,filters:u,onFiltersChange:i,isLoading:_,searchQuery:dt,highlightMatch:wn}),qt==="assemblages"&&Ke&&Q&&e.jsx(n4,{assemblages:O,isLoading:q,onSelect:Q,onDelete:Z||(()=>{}),isDeleting:oe,selectedAssemblageId:W}),qt==="layouts"&&Ke&&!Qe&&e.jsx(sk,{onNavigateToOverlay:ce,onEditOverlay:ae,onOpenPolygonTools:ie,onStartDrawing:de,activeSiteLayoutId:We,activeFocusId:Ee,onActiveFocusIdChange:ve,externalSearchQuery:dt})]}),qt==="layouts"&&Ke&&Qe&&e.jsxs("div",{className:`fixed z-[1060] bg-background border border-border rounded-xl shadow-2xl flex flex-col overflow-hidden ${as?"cursor-grabbing select-none":""}`,style:{left:_t.x,top:_t.y,width:360,height:"calc(100vh - 140px)",maxHeight:700},children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b bg-muted/30 cursor-move",onMouseDown:De=>{De.target.closest("button")||(De.preventDefault(),vt(!0),Ce({x:De.clientX-_t.x,y:De.clientY-_t.y}))},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fh,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(Du,{className:"w-4 h-4 text-orange-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Site Layouts"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Le,{variant:"default",size:"icon",className:"h-7 w-7",onClick:()=>ht(!1),title:"Dock panel",children:e.jsx(Cf,{className:"h-3.5 w-3.5"})}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{ht(!1),ft(""),ge==null||ge(!1)},title:"Close",children:e.jsx(ja,{className:"h-3.5 w-3.5"})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(sk,{onNavigateToOverlay:ce,onEditOverlay:ae,onOpenPolygonTools:ie,onStartDrawing:de,activeSiteLayoutId:We,activeFocusId:Ee,onActiveFocusIdChange:ve,externalSearchQuery:dt})})]})]})};var Jb={exports:{}};/* @preserve
753 * Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com
754 * (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade
755 */(function(t,s){(function(n,a){a(s)})(Fm,function(n){var a="1.9.4";function l(p){var M,Y,ue,Se;for(Y=1,ue=arguments.length;Y<ue;Y++){Se=arguments[Y];for(M in Se)p[M]=Se[M]}return p}var c=Object.create||function(){function p(){}return function(M){return p.prototype=M,new p}}();function u(p,M){var Y=Array.prototype.slice;
755if(p.bind)return p.bind.apply(p,Y.call(arguments,1));var ue=Y.call(arguments,2);return function(){return p.apply(M,ue.length?ue.concat(Y.call(arguments)):arguments)}}var i=0;function _(p){return"_leaflet_id"in p||(p._leaflet_id=++i),p._leaflet_id}function j(p,M,Y){var ue,Se,st,At;return At=function(){ue=!1,Se&&(st.apply(Y,Se),Se=!1)},st=function(){ue?Se=arguments:(p.apply(Y,arguments),setTimeout(At,M),ue=!0)},st}function y(p,M,Y){var ue=M[1],Se=M[0],st=ue-Se;return p===ue&&Y?p:((p-Se)%st+st)%st+Se}function x(){return!1}function v(p,M){if(M===!1)return p;var Y=Math.pow(10,M===void 0?6:M);return Math.round(p*Y)/Y}function C(p){return p.trim?p.trim():p.replace(/^\s+|\s+$/g,"")}function P(p){return C(p).split(/\s+/)}function I(p,M){Object.prototype.hasOwnProperty.call(p,"options")||(p.options=p.options?c(p.options):{});for(var Y in M)p.options[Y]=M[Y];return p.options}function z(p,M,Y){var ue=[];for(var Se in p)ue.push(encodeURIComponent(Y?Se.toUpperCase():Se)+"="+encodeURIComponent(p[Se]));return(!M||M.indexOf("?")===-1?"?":"&")+ue.join("&")}var F=/\{ *([\w_ -]+) *\}/g;function D(p,M){return p.replace(F,function(Y,ue){var Se=M[ue];if(Se===void 0)throw new Error("No value provided for variable "+Y);return typeof Se=="function"&&(Se=Se(M)),Se})}var X=Array.isArray||function(p){return Object.prototype.toString.call(p)==="[object Array]"};function K(p,M){for(var Y=0;Y<p.length;Y++)if(p[Y]===M)return Y;return-1}var te="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function J(p){return window["webkit"+p]||window["moz"+p]||window["ms"+p]}var H=0;function O(p){var M=+new Date,Y=Math.max(0,16-(M-H));return H=M+Y,window.setTimeout(p,Y)}var q=window.requestAnimationFrame||J("RequestAnimationFrame")||O,W=window.cancelAnimationFrame||J("CancelAnimationFrame")||J("CancelRequestAnimationFrame")||function(p){window.clearTimeout(p)};function Q(p,M,Y){if(Y&&q===O)p.call(M);else return q.call(window,u(p,M))}function Z(p){p&&W.call(window,p)}var oe={__proto__:null,extend:l,create:c,bind:u,get lastId(){return i},stamp:_,throttle:j,wrapNum:y,falseFn:x,formatNum:v,trim:C,splitWords:P,setOptions:I,getParamString:z,template:D,isArray:X,indexOf:K,emptyImageUrl:te,requestFn:q,cancelFn:W,requestAnimFrame:Q,cancelAnimFrame:Z};function ce(){}ce.extend=function(p){var M=function(){I(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()},Y=M.__super__=this.prototype,ue=c(Y);ue.constructor=M,M.prototype=ue;for(var Se in this)Object.prototype.hasOwnProperty.call(this,Se)&&Se!=="prototype"&&Se!=="__super__"&&(M[Se]=this[Se]);return p.statics&&l(M,p.statics),p.includes&&(ae(p.includes),l.apply(null,[ue].concat(p.includes))),l(ue,p),delete ue.statics,delete ue.includes,ue.options&&(ue.options=Y.options?c(Y.options):{},l(ue.options,p.options)),ue._initHooks=[],ue.callInitHooks=function(){if(!this._initHooksCalled){Y.callInitHooks&&Y.callInitHooks.call(this),this._initHooksCalled=!0;for(var st=0,At=ue._initHooks.length;st<At;st++)ue._initHooks[st].call(this)}},M},ce.include=function(p){var M=this.prototype.options;return l(this.prototype,p),p.options&&(this.prototype.options=M,this.mergeOptions(p.options)),this},ce.mergeOptions=function(p){return l(this.prototype.options,p),this},ce.addInitHook=function(p){var M=Array.prototype.slice.call(arguments,1),Y=typeof p=="function"?p:function(){this[p].apply(this,M)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(Y),this};function ae(p){if(!(typeof L>"u"||!L||!L.Mixin)){p=X(p)?p:[p];for(var M=0;M<p.length;
755M++)p[M]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",new Error().stack)}}var ie={on:function(p,M,Y){if(typeof p=="object")for(var ue in p)this._on(ue,p[ue],M);else{p=P(p);for(var Se=0,st=p.length;Se<st;Se++)this._on(p[Se],M,Y)}return this},off:function(p,M,Y){if(!arguments.length)delete this._events;else if(typeof p=="object")for(var ue in p)this._off(ue,p[ue],M);else{p=P(p);for(var Se=arguments.length===1,st=0,At=p.length;st<At;st++)Se?this._off(p[st]):this._off(p[st],M,Y)}return this},_on:function(p,M,Y,ue){if(typeof M!="function"){console.warn("wrong listener type: "+typeof M);return}if(this._listens(p,M,Y)===!1){Y===this&&(Y=void 0);var Se={fn:M,ctx:Y};ue&&(Se.once=!0),this._events=this._events||{},this._events[p]=this._events[p]||[],this._events[p].push(Se)}},_off:function(p,M,Y){var ue,Se,st;if(this._events&&(ue=this._events[p],!!ue)){if(arguments.length===1){if(this._firingCount)for(Se=0,st=ue.length;Se<st;Se++)ue[Se].fn=x;delete this._events[p];return}if(typeof M!="function"){console.warn("wrong listener type: "+typeof M);return}var At=this._listens(p,M,Y);if(At!==!1){var hs=ue[At];this._firingCount&&(hs.fn=x,this._events[p]=ue=ue.slice()),ue.splice(At,1)}}},fire:function(p,M,Y){if(!this.listens(p,Y))return this;var ue=l({},M,{type:p,target:this,sourceTarget:M&&M.sourceTarget||this});if(this._events){var Se=this._events[p];if(Se){this._firingCount=this._firingCount+1||1;for(var st=0,At=Se.length;st<At;st++){var hs=Se[st],ws=hs.fn;hs.once&&this.off(p,ws,hs.ctx),ws.call(hs.ctx||this,ue)}this._firingCount--}}return Y&&this._propagateEvent(ue),this},listens:function(p,M,Y,ue){typeof p!="string"&&console.warn('"string" type argument expected');var Se=M;typeof M!="function"&&(ue=!!M,Se=void 0,Y=void 0);var st=this._events&&this._events[p];if(st&&st.length&&this._listens(p,Se,Y)!==!1)return!0;if(ue){for(var At in this._eventParents)if(this._eventParents[At].listens(p,M,Y,ue))return!0}return!1},_listens:function(p,M,Y){if(!this._events)return!1;var ue=this._events[p]||[];if(!M)return!!ue.length;Y===this&&(Y=void 0);for(var Se=0,st=ue.length;Se<st;Se++)if(ue[Se].fn===M&&ue[Se].ctx===Y)return Se;return!1},once:function(p,M,Y){if(typeof p=="object")for(var ue in p)this._on(ue,p[ue],M,!0);else{p=P(p);for(var Se=0,st=p.length;Se<st;Se++)this._on(p[Se],M,Y,!0)}return this},addEventParent:function(p){return this._eventParents=this._eventParents||{},this._eventParents[_(p)]=p,this},removeEventParent:function(p){return this._eventParents&&delete this._eventParents[_(p)],this},_propagateEvent:function(p){for(var M in this._eventParents)this._eventParents[M].fire(p.type,l({layer:p.target,propagatedFrom:p.target},p),!0)}};ie.addEventListener=ie.on,ie.removeEventListener=ie.clearAllEventListeners=ie.off,ie.addOneTimeEventListener=ie.once,ie.fireEvent=ie.fire,ie.hasEventListeners=ie.listens;var de=ce.extend(ie);function ge(p,M,Y){this.x=Y?Math.round(p):p,this.y=Y?Math.round(M):M}var We=Math.trunc||function(p){return p>0?Math.floor(p):Math.ceil(p)};ge.prototype={clone:function(){return new ge(this.x,this.y)},add:function(p){return this.clone()._add(Ee(p))},_add:function(p){return this.x+=p.x,this.y+=p.y,this},subtract:function(p){return this.clone()._subtract(Ee(p))},_subtract:function(p){return this.x-=p.x,this.y-=p.y,this},divideBy:function(p){return this.clone()._divideBy(p)},_divideBy:function(p){return this.x/=p,this.y/=p,this},multiplyBy:function(p){return this.clone()._multiplyBy(p)},_multiplyBy:function(p){return this.x*=p,this.y*=p,this},scaleBy:function(p){return new ge(this.x*p.x,this.y*p.y)},unscaleBy:function(p){return new ge(this.x/p.x,this.y/p.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=We(this.x),this.y=We(this.y),this},distanceTo:function(p){p=Ee(p);var M=p.x-this.x,Y=p.y-this.y;return Math.sqrt(M*M+Y*Y)},equals:function(p){return p=Ee(p),p.x===this.x&&p.y===this.y},contains:function(p){return p=Ee(p),Math.abs(p.x)<=Math.abs(this.x)&&Math.abs(p.y)<=Math.abs(this.y)},toString:function(){return"Point("+v(this.x)+", "+v(this.y)+")"}};
755function Ee(p,M,Y){return p instanceof ge?p:X(p)?new ge(p[0],p[1]):p==null?p:typeof p=="object"&&"x"in p&&"y"in p?new ge(p.x,p.y):new ge(p,M,Y)}function ve(p,M){if(p)for(var Y=M?[p,M]:p,ue=0,Se=Y.length;ue<Se;ue++)this.extend(Y[ue])}ve.prototype={extend:function(p){var M,Y;if(!p)return this;if(p instanceof ge||typeof p[0]=="number"||"x"in p)M=Y=Ee(p);else if(p=we(p),M=p.min,Y=p.max,!M||!Y)return this;return!this.min&&!this.max?(this.min=M.clone(),this.max=Y.clone()):(this.min.x=Math.min(M.x,this.min.x),this.max.x=Math.max(Y.x,this.max.x),this.min.y=Math.min(M.y,this.min.y),this.max.y=Math.max(Y.y,this.max.y)),this},getCenter:function(p){return Ee((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,p)},getBottomLeft:function(){return Ee(this.min.x,this.max.y)},getTopRight:function(){return Ee(this.max.x,this.min.y)},getTopLeft:function(){return this.min},getBottomRight:function(){return this.max},getSize:function(){return this.max.subtract(this.min)},contains:function(p){var M,Y;return typeof p[0]=="number"||p instanceof ge?p=Ee(p):p=we(p),p instanceof ve?(M=p.min,Y=p.max):M=Y=p,M.x>=this.min.x&&Y.x<=this.max.x&&M.y>=this.min.y&&Y.y<=this.max.y},intersects:function(p){p=we(p);var M=this.min,Y=this.max,ue=p.min,Se=p.max,st=Se.x>=M.x&&ue.x<=Y.x,At=Se.y>=M.y&&ue.y<=Y.y;return st&&At},overlaps:function(p){p=we(p);var M=this.min,Y=this.max,ue=p.min,Se=p.max,st=Se.x>M.x&&ue.x<Y.x,At=Se.y>M.y&&ue.y<Y.y;return st&&At},isValid:function(){return!!(this.min&&this.max)},pad:function(p){var M=this.min,Y=this.max,ue=Math.abs(M.x-Y.x)*p,Se=Math.abs(M.y-Y.y)*p;return we(Ee(M.x-ue,M.y-Se),Ee(Y.x+ue,Y.y+Se))},equals:function(p){return p?(p=we(p),this.min.equals(p.getTopLeft())&&this.max.equals(p.getBottomRight())):!1}};function we(p,M){return!p||p instanceof ve?p:new ve(p,M)}function Ze(p,M){if(p)for(var Y=M?[p,M]:p,ue=0,Se=Y.length;ue<Se;ue++)this.extend(Y[ue])}Ze.prototype={extend:function(p){var M=this._southWest,Y=this._northEast,ue,Se;if(p instanceof ze)ue=p,Se=p;else if(p instanceof Ze){if(ue=p._southWest,Se=p._northEast,!ue||!Se)return this}else return p?this.extend(Ke(p)||ke(p)):this;return!M&&!Y?(this._southWest=new ze(ue.lat,ue.lng),this._northEast=new ze(Se.lat,Se.lng)):(M.lat=Math.min(ue.lat,M.lat),M.lng=Math.min(ue.lng,M.lng),Y.lat=Math.max(Se.lat,Y.lat),Y.lng=Math.max(Se.lng,Y.lng)),this},pad:function(p){var M=this._southWest,Y=this._northEast,ue=Math.abs(M.lat-Y.lat)*p,Se=Math.abs(M.lng-Y.lng)*p;return new Ze(new ze(M.lat-ue,M.lng-Se),new ze(Y.lat+ue,Y.lng+Se))},getCenter:function(){return new ze((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new ze(this.getNorth(),this.getWest())},getSouthEast:function(){return new ze(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(p){typeof p[0]=="number"||p instanceof ze||"lat"in p?p=Ke(p):p=ke(p);var M=this._southWest,Y=this._northEast,ue,Se;
755return p instanceof Ze?(ue=p.getSouthWest(),Se=p.getNorthEast()):ue=Se=p,ue.lat>=M.lat&&Se.lat<=Y.lat&&ue.lng>=M.lng&&Se.lng<=Y.lng},intersects:function(p){p=ke(p);var M=this._southWest,Y=this._northEast,ue=p.getSouthWest(),Se=p.getNorthEast(),st=Se.lat>=M.lat&&ue.lat<=Y.lat,At=Se.lng>=M.lng&&ue.lng<=Y.lng;return st&&At},overlaps:function(p){p=ke(p);var M=this._southWest,Y=this._northEast,ue=p.getSouthWest(),Se=p.getNorthEast(),st=Se.lat>M.lat&&ue.lat<Y.lat,At=Se.lng>M.lng&&ue.lng<Y.lng;return st&&At},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(p,M){return p?(p=ke(p),this._southWest.equals(p.getSouthWest(),M)&&this._northEast.equals(p.getNorthEast(),M)):!1},isValid:function(){return!!(this._southWest&&this._northEast)}};function ke(p,M){return p instanceof Ze?p:new Ze(p,M)}function ze(p,M,Y){if(isNaN(p)||isNaN(M))throw new Error("Invalid LatLng object: ("+p+", "+M+")");this.lat=+p,this.lng=+M,Y!==void 0&&(this.alt=+Y)}ze.prototype={equals:function(p,M){if(!p)return!1;p=Ke(p);var Y=Math.max(Math.abs(this.lat-p.lat),Math.abs(this.lng-p.lng));return Y<=(M===void 0?1e-9:M)},toString:function(p){return"LatLng("+v(this.lat,p)+", "+v(this.lng,p)+")"},distanceTo:function(p){return Re.distance(this,Ke(p))},wrap:function(){return Re.wrapLatLng(this)},toBounds:function(p){var M=180*p/40075017,Y=M/Math.cos(Math.PI/180*this.lat);return ke([this.lat-M,this.lng-Y],[this.lat+M,this.lng+Y])},clone:function(){return new ze(this.lat,this.lng,this.alt)}};function Ke(p,M,Y){return p instanceof ze?p:X(p)&&typeof p[0]!="object"?p.length===3?new ze(p[0],p[1],p[2]):p.length===2?new ze(p[0],p[1]):null:p==null?p:typeof p=="object"&&"lat"in p?new ze(p.lat,"lng"in p?p.lng:p.lon,p.alt):M===void 0?null:new ze(p,M,Y)}var dt={latLngToPoint:function(p,M){var Y=this.projection.project(p),ue=this.scale(M);return this.transformation._transform(Y,ue)},pointToLatLng:function(p,M){var Y=this.scale(M),ue=this.transformation.untransform(p,Y);return this.projection.unproject(ue)},project:function(p){return this.projection.project(p)},unproject:function(p){return this.projection.unproject(p)},scale:function(p){return 256*Math.pow(2,p)},zoom:function(p){return Math.log(p/256)/Math.LN2},getProjectedBounds:function(p){if(this.infinite)return null;var M=this.projection.bounds,Y=this.scale(p),ue=this.transformation.transform(M.min,Y),Se=this.transformation.transform(M.max,Y);return new ve(ue,Se)},infinite:!1,wrapLatLng:function(p){var M=this.wrapLng?y(p.lng,this.wrapLng,!0):p.lng,Y=this.wrapLat?y(p.lat,this.wrapLat,!0):p.lat,ue=p.alt;return new ze(Y,M,ue)},wrapLatLngBounds:function(p){var M=p.getCenter(),Y=this.wrapLatLng(M),ue=M.lat-Y.lat,Se=M.lng-Y.lng;if(ue===0&&Se===0)return p;
755var st=p.getSouthWest(),At=p.getNorthEast(),hs=new ze(st.lat-ue,st.lng-Se),ws=new ze(At.lat-ue,At.lng-Se);return new Ze(hs,ws)}},Re=l({},dt,{wrapLng:[-180,180],R:6371e3,distance:function(p,M){var Y=Math.PI/180,ue=p.lat*Y,Se=M.lat*Y,st=Math.sin((M.lat-p.lat)*Y/2),At=Math.sin((M.lng-p.lng)*Y/2),hs=st*st+Math.cos(ue)*Math.cos(Se)*At*At,ws=2*Math.atan2(Math.sqrt(hs),Math.sqrt(1-hs));return this.R*ws}}),qt=6378137,ft={R:qt,MAX_LATITUDE:85.0511287798,project:function(p){var M=Math.PI/180,Y=this.MAX_LATITUDE,ue=Math.max(Math.min(Y,p.lat),-Y),Se=Math.sin(ue*M);return new ge(this.R*p.lng*M,this.R*Math.log((1+Se)/(1-Se))/2)},unproject:function(p){var M=180/Math.PI;return new ze((2*Math.atan(Math.exp(p.y/this.R))-Math.PI/2)*M,p.x*M/this.R)},bounds:function(){var p=qt*Math.PI;return new ve([-p,-p],[p,p])}()};function Fe(p,M,Y,ue){if(X(p)){this._a=p[0],this._b=p[1],this._c=p[2],this._d=p[3];return}this._a=p,this._b=M,this._c=Y,this._d=ue}Fe.prototype={transform:function(p,M){return this._transform(p.clone(),M)},_transform:function(p,M){return M=M||1,p.x=M*(this._a*p.x+this._b),p.y=M*(this._c*p.y+this._d),p},untransform:function(p,M){return M=M||1,new ge((p.x/M-this._b)/this._a,(p.y/M-this._d)/this._c)}};function fe(p,M,Y,ue){return new Fe(p,M,Y,ue)}var Qe=l({},Re,{code:"EPSG:3857",projection:ft,transformation:function(){var p=.5/(Math.PI*ft.R);return fe(p,.5,-p,.5)}()}),ht=l({},Qe,{code:"EPSG:900913"});function _t(p){return document.createElementNS("http://www.w3.org/2000/svg",p)}function He(p,M){var Y="",ue,Se,st,At,hs,ws;for(ue=0,st=p.length;ue<st;ue++){for(hs=p[ue],Se=0,At=hs.length;Se<At;Se++)ws=hs[Se],Y+=(Se?"L":"M")+ws.x+" "+ws.y;Y+=M?is.svg?"z":"x":""}return Y||"M0 0"}var as=document.documentElement.style,vt="ActiveXObject"in window,Xe=vt&&!document.addEventListener,Ce="msLaunchUri"in navigator&&!("documentMode"in document),Be=es("webkit"),Dt=es("android"),Rt=es("android 2")||es("android 3"),zt=parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1],10),rs=Dt&&es("Google")&&zt<537&&!("AudioNode"in window),_s=!!window.opera,vs=!Ce&&es("chrome"),$t=es("gecko")&&!Be&&!_s&&!vt,Ns=!vs&&es("safari"),Ts=es("phantom"),bs="OTransition"in as,en=navigator.platform.indexOf("Win")===0,Jt=vt&&"transition"in as,Vs="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!Rt,ps="MozPerspective"in as,nt=!window.L_DISABLE_3D&&(Jt||Vs||ps)&&!bs&&!Ts,ts=typeof orientation<"u"||es("mobile"),ds=ts&&Be,Is=ts&&Vs,tn=!window.PointerEvent&&window.MSPointerEvent,wn=!!(window.PointerEvent||tn),Gs="ontouchstart"in window||!!window.TouchEvent,Ue=!window.L_NO_TOUCH&&(Gs||wn),Pe=ts&&_s,je=ts&&$t,Ge=(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI)>1,De=function(){var p=!1;try{var M=Object.defineProperty({},"passive",{get:function(){p=!0}});window.addEventListener("testPassiveEventSupport",x,M),window.removeEventListener("testPassiveEventSupport",x,M)}catch{}return p}(),bt=function(){return!!document.createElement("canvas").getContext}(),Ct=!!(document.createElementNS&&_t("svg").createSVGRect),pe=!!Ct&&function(){var p=document.createElement("div");return p.innerHTML="<svg/>",(p.firstChild&&p.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"}(),wt=!Ct&&function(){try{var p=document.createElement("div");p.innerHTML='<v:shape adj="1"/>';var M=p.firstChild;return M.style.behavior="url(#default#VML)",M&&typeof M.adj=="object"}catch{return!1}}(),Zt=navigator.platform.indexOf("Mac")===0,ys=navigator.platform.indexOf("Linux")===0;function es(p){return navigator.userAgent.toLowerCase().indexOf(p)>=0}var is={ie:vt,ielt9:Xe,edge:Ce,webkit:Be,android:Dt,android23:Rt,androidStock:rs,opera:_s,chrome:vs,gecko:$t,safari:Ns,phantom:Ts,opera12:bs,win:en,ie3d:Jt,webkit3d:Vs,gecko3d:ps,any3d:nt,mobile:ts,mobileWebkit:ds,mobileWebkit3d:Is,msPointer:tn,pointer:wn,touch:Ue,touchNative:Gs,mobileOpera:Pe,mobileGecko:je,retina:Ge,passiveEvents:De,canvas:bt,svg:Ct,vml:wt,inlineSvg:pe,mac:Zt,linux:ys},Ws=is.msPointer?"MSPointerDown":"pointerdown",an=is.msPointer?"MSPointerMove":"pointermove",ya=is.msPointer?"MSPointerUp":"pointerup",Hs=is.msPointer?"MSPointerCancel":"pointercancel",xt={touchstart:Ws,touchmove:an,touchend:ya,touchcancel:Hs},os={touchstart:An,touchmove:sr,touchend:sr,touchcancel:sr},Ls={},Es=!1;function Qs(p,M,Y){return M==="touchstart"&&Sa(),os[M]?(Y=os[M].bind(this,Y),p.addEventListener(xt[M],Y,!1),Y):(console.warn("wrong event specified:",M),x)}function Pn(p,M,Y){if(!xt[M]){console.warn("wrong event specified:",M);return}p.removeEventListener(xt[M],Y,!1)}function Ks(p){Ls[p.pointerId]=p}function xa(p){Ls[p.pointerId]&&(Ls[p.pointerId]=p)}function Fn(p){delete Ls[p.pointerId]}function Sa(){Es||(document.addEventListener(Ws,Ks,!0),document.addEventListener(an,xa,!0),document.addEventListener(ya,Fn,!0),document.addEventListener(Hs,Fn,!0),Es=!0)}function sr(p,M){if(M.pointerType!==(M.MSPOINTER_TYPE_MOUSE||"mouse")){M.touches=[];for(var Y in Ls)M.touches.push(Ls[Y]);M.changedTouches=[M],p(M)}}function An(p,M){M.MSPOINTER_TYPE_TOUCH&&M.pointerType===M.MSPOINTER_TYPE_TOUCH&&ti(M),sr(p,M)}function Ai(p){var M={},Y,ue;for(ue in p)Y=p[ue],M[ue]=Y&&Y.bind?Y.bind(p):Y;return p=M,M.type="dblclick",M.detail=2,M.isTrusted=!1,M._simulated=!0,M}var xi=200;function ei(p,M){p.addEventListener("dblclick",M);var Y=0,ue;function Se(st){if(st.detail!==1){ue=st.detail;return}if(!(st.pointerType==="mouse"||st.sourceCapabilities&&!st.sourceCapabilities.firesTouchEvents)){var At=Tn(st);if(!(At.some(function(ws){return ws instanceof HTMLLabelElement&&ws.attributes.for})&&!At.some(function(ws){return ws instanceof HTMLInputElement||ws instanceof HTMLSelectElement}))){var hs=Date.now();hs-Y<=xi?(ue++,ue===2&&M(Ai(st))):ue=1,Y=hs}}}return p.addEventListener("click",Se),{dblclick:M,simDblclick:Se}}function Yr(p,M){p.removeEventListener("dblclick",M.dblclick),p.removeEventListener("click",M.simDblclick)}var Xo=Za(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),ra=Za(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),Ka=ra==="webkitTransition"||ra==="OTransition"?ra+"End":"transitionend";function Ha(p){return typeof p=="string"?document.getElementById(p):p}function qa(p,M){var Y=p.style[M]||p.currentStyle&&p.currentStyle[M];if((!Y||Y==="auto")&&document.defaultView){var ue=document.defaultView.getComputedStyle(p,null);Y=ue?ue[M]:null}return Y==="auto"?null:Y}function Mn(p,M,Y){var ue=document.createElement(p);return ue.className=M||"",Y&&Y.appendChild(ue),ue}function _r(p){var M=p.parentNode;M&&M.removeChild(p)}function Ar(p){for(;p.firstChild;)p.removeChild(p.firstChild)}function Zs(p){var M=p.parentNode;M&&M.lastChild!==p&&M.appendChild(p)}function Cn(p){var M=p.parentNode;M&&M.firstChild!==p&&M.insertBefore(p,M.firstChild)}function Na(p,M){if(p.classList!==void 0)return p.classList.contains(M);var Y=oi(p);return Y.length>0&&new RegExp("(^|\\s)"+M+"(\\s|$)").test(Y)}function Gn(p,M){if(p.classList!==void 0)for(var Y=P(M),ue=0,Se=Y.length;ue<Se;ue++)p.classList.add(Y[ue]);else if(!Na(p,M)){var st=oi(p);Pr(p,(st?st+" ":"")+M)}}function sa(p,M){p.classList!==void 0?p.classList.remove(M):Pr(p,C((" "+oi(p)+" ").replace(" "+M+" "," ")))}function Pr(p,M){p.className.baseVal===void 0?p.className=M:p.className.baseVal=M}function oi(p){return p.correspondingElement&&(p=p.correspondingElement),p.className.baseVal===void 0?p.className:p.className.baseVal}function Tr(p,M){"opacity"in p.style?p.style.opacity=M:"filter"in p.style&&Ko(p,M)}function Ko(p,M){var Y=!1,ue="DXImageTransform.Microsoft.Alpha";try{Y=p.filters.item(ue)}catch{if(M===1)return}M=Math.round(M*100),Y?(Y.Enabled=M!==100,Y.Opacity=M):p.style.filter+=" progid:"+ue+"(opacity="+M+")"}function Za(p){for(var M=document.documentElement.style,Y=0;Y<p.length;Y++)if(p[Y]in M)return p[Y];return!1}function Gr(p,M,Y){var ue=M||new ge(0,0);p.style[Xo]=(is.ie3d?"translate("+ue.x+"px,"+ue.y+"px)":"translate3d("+ue.x+"px,"+ue.y+"px,0)")+(Y?" scale("+Y+")":"")}function Xr(p,M){p._leaflet_pos=M,is.any3d?Gr(p,M):(p.style.left=M.x+"px",p.style.top=M.y+"px")}function rn(p){return p._leaflet_pos||new ge(0,0)}var In,Yi,jl;if("onselectstart"in document)In=function(){fn(window,"selectstart",ti)},Yi=function(){nr(window,"selectstart",ti)};else{var Si=Za(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]);In=function(){if(Si){var p=document.documentElement.style;jl=p[Si],p[Si]="none"}},Yi=function(){Si&&(document.documentElement.style[Si]=jl,jl=void 0)}}function zo(){fn(window,"dragstart",ti)}function Pc(){nr(window,"dragstart",ti)}var Hr,ul;function hl(p){for(;p.tabIndex===-1;)p=p.parentNode;p.style&&(Nr(),Hr=p,ul=p.style.outlineStyle,p.style.outlineStyle="none",fn(window,"keydown",Nr))}function Nr(){Hr&&(Hr.style.outlineStyle=ul,Hr=void 0,ul=void 0,nr(window,"keydown",Nr))}function ui(p){do p=p.parentNode;while((!p.offsetWidth||!p.offsetHeight)&&p!==document.body);return p}function Zr(p){var M=p.getBoundingClientRect();return{x:M.width/p.offsetWidth||1,y:M.height/p.offsetHeight||1,boundingClientRect:M}}var Gi={__proto__:null,TRANSFORM:Xo,TRANSITION:ra,TRANSITION_END:Ka,get:Ha,getStyle:qa,create:Mn,remove:_r,empty:Ar,toFront:Zs,toBack:Cn,hasClass:Na,addClass:Gn,removeClass:sa,setClass:Pr,getClass:oi,setOpacity:Tr,testProp:Za,setTransform:Gr,setPosition:Xr,getPosition:rn,get disableTextSelection(){return In},get enableTextSelection(){return Yi},disableImageDrag:zo,enableImageDrag:Pc,preventOutline:hl,restoreOutline:Nr,getSizedParentNode:ui,getScale:Zr};function fn(p,M,Y,ue){if(M&&typeof M=="object")for(var Se in M)Nl(p,Se,M[Se],Y);else{M=P(M);for(var st=0,At=M.length;
755st<At;st++)Nl(p,M[st],Y,ue)}return this}var kr="_leaflet_events";function nr(p,M,Y,ue){if(arguments.length===1)Br(p),delete p[kr];else if(M&&typeof M=="object")for(var Se in M)lr(p,Se,M[Se],Y);else if(M=P(M),arguments.length===2)Br(p,function(hs){return K(M,hs)!==-1});else for(var st=0,At=M.length;st<At;st++)lr(p,M[st],Y,ue);return this}function Br(p,M){for(var Y in p[kr]){var ue=Y.split(/\d/)[0];(!M||M(ue))&&lr(p,ue,null,null,Y)}}var wl={mouseenter:"mouseover",mouseleave:"mouseout",wheel:!("onwheel"in window)&&"mousewheel"};function Nl(p,M,Y,ue){var Se=M+_(Y)+(ue?"_"+_(ue):"");if(p[kr]&&p[kr][Se])return this;var st=function(hs){return Y.call(ue||p,hs||window.event)},At=st;!is.touchNative&&is.pointer&&M.indexOf("touch")===0?st=Qs(p,M,st):is.touch&&M==="dblclick"?st=ei(p,st):"addEventListener"in p?M==="touchstart"||M==="touchmove"||M==="wheel"||M==="mousewheel"?p.addEventListener(wl[M]||M,st,is.passiveEvents?{passive:!1}:!1):M==="mouseenter"||M==="mouseleave"?(st=function(hs){hs=hs||window.event,$r(p,hs)&&At(hs)},p.addEventListener(wl[M],st,!1)):p.addEventListener(M,At,!1):p.attachEvent("on"+M,st),p[kr]=p[kr]||{},p[kr][Se]=st}function lr(p,M,Y,ue,Se){Se=Se||M+_(Y)+(ue?"_"+_(ue):"");var st=p[kr]&&p[kr][Se];if(!st)return this;!is.touchNative&&is.pointer&&M.indexOf("touch")===0?Pn(p,M,st):is.touch&&M==="dblclick"?Yr(p,st):"removeEventListener"in p?p.removeEventListener(wl[M]||M,st,!1):p.detachEvent("on"+M,st),p[kr][Se]=null}function Xi(p){return p.stopPropagation?p.stopPropagation():p.originalEvent?p.originalEvent._stopped=!0:p.cancelBubble=!0,this}function ml(p){return Nl(p,"wheel",Xi),this}function Co(p){return fn(p,"mousedown touchstart dblclick contextmenu",Xi),p._leaflet_disable_click=!0,this}function ti(p){return p.preventDefault?p.preventDefault():p.returnValue=!1,this}function qs(p){return ti(p),Xi(p),this}function Tn(p){if(p.composedPath)return p.composedPath();for(var M=[],Y=p.target;Y;)M.push(Y),Y=Y.parentNode;return M}function oa(p,M){if(!M)return new ge(p.clientX,p.clientY);var Y=Zr(M),ue=Y.boundingClientRect;return new ge((p.clientX-ue.left)/Y.x-M.clientLeft,(p.clientY-ue.top)/Y.y-M.clientTop)}var Pa=is.linux&&is.chrome?window.devicePixelRatio:is.mac?window.devicePixelRatio*3:window.devicePixelRatio>0?2*window.devicePixelRatio:1;function mr(p){return is.edge?p.wheelDeltaY/2:p.deltaY&&p.deltaMode===0?-p.deltaY/Pa:p.deltaY&&p.deltaMode===1?-p.deltaY*20:p.deltaY&&p.deltaMode===2?-p.deltaY*60:p.deltaX||p.deltaZ?0:p.wheelDelta?(p.wheelDeltaY||p.wheelDelta)/2:p.detail&&Math.abs(p.detail)<32765?-p.detail*20:p.detail?p.detail/-32765*60:0}function $r(p,M){var Y=M.relatedTarget;if(!Y)return!0;try{for(;Y&&Y!==p;)Y=Y.parentNode}catch{return!1}return Y!==p}var Jo={__proto__:null,on:fn,off:nr,stopPropagation:Xi,disableScrollPropagation:ml,disableClickPropagation:Co,preventDefault:ti,stop:qs,getPropagationPath:Tn,getMousePosition:oa,getWheelDelta:mr,isExternalTarget:$r,addListener:fn,removeListener:nr},na=de.extend({run:function(p,M,Y,ue){this.stop(),this._el=p,this._inProgress=!0,this._duration=Y||.25,this._easeOutPower=1/Math.max(ue||.5,.2),this._startPos=rn(p),this._offset=M.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=Q(this._animate,this),this._step()},_step:function(p){var M=+new Date-this._startTime,Y=this._duration*1e3;M<Y?this._runFrame(this._easeOut(M/Y),p):(this._runFrame(1),this._complete())},_runFrame:function(p,M){var Y=this._startPos.add(this._offset.multiplyBy(p));M&&Y._round(),Xr(this._el,Y),this.fire("step")},_complete:function(){Z(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(p){return 1-Math.pow(1-p,this._easeOutPower)}}),Sn=de.extend({options:{crs:Qe,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0},initialize:function(p,M){M=I(this,M),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(p),this._initLayout(),this._onResize=u(this._onResize,this),this._initEvents(),M.maxBounds&&this.setMaxBounds(M.maxBounds),M.zoom!==void 0&&(this._zoom=this._limitZoom(M.zoom)),M.center&&M.zoom!==void 0&&this.setView(Ke(M.center),M.zoom,{reset:!0}),this.callInitHooks(),this._zoomAnimated=ra&&is.any3d&&!is.mobileOpera&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),fn(this._proxy,Ka,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)}
755,setView:function(p,M,Y){if(M=M===void 0?this._zoom:this._limitZoom(M),p=this._limitCenter(Ke(p),M,this.options.maxBounds),Y=Y||{},this._stop(),this._loaded&&!Y.reset&&Y!==!0){Y.animate!==void 0&&(Y.zoom=l({animate:Y.animate},Y.zoom),Y.pan=l({animate:Y.animate,duration:Y.duration},Y.pan));var ue=this._zoom!==M?this._tryAnimatedZoom&&this._tryAnimatedZoom(p,M,Y.zoom):this._tryAnimatedPan(p,Y.pan);if(ue)return clearTimeout(this._sizeTimer),this}return this._resetView(p,M,Y.pan&&Y.pan.noMoveStart),this},setZoom:function(p,M){return this._loaded?this.setView(this.getCenter(),p,{zoom:M}):(this._zoom=p,this)},zoomIn:function(p,M){return p=p||(is.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom+p,M)},zoomOut:function(p,M){return p=p||(is.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom-p,M)},setZoomAround:function(p,M,Y){var ue=this.getZoomScale(M),Se=this.getSize().divideBy(2),st=p instanceof ge?p:this.latLngToContainerPoint(p),At=st.subtract(Se).multiplyBy(1-1/ue),hs=this.containerPointToLatLng(Se.add(At));return this.setView(hs,M,{zoom:Y})},_getBoundsCenterZoom:function(p,M){M=M||{},p=p.getBounds?p.getBounds():ke(p);var Y=Ee(M.paddingTopLeft||M.padding||[0,0]),ue=Ee(M.paddingBottomRight||M.padding||[0,0]),Se=this.getBoundsZoom(p,!1,Y.add(ue));if(Se=typeof M.maxZoom=="number"?Math.min(M.maxZoom,Se):Se,Se===1/0)return{center:p.getCenter(),zoom:Se};var st=ue.subtract(Y).divideBy(2),At=this.project(p.getSouthWest
755(),Se),hs=this.project(p.getNorthEast(),Se),ws=this.unproject(At.add(hs).divideBy(2).add(st),Se);return{center:ws,zoom:Se}},fitBounds:function(p,M){if(p=ke(p),!p.isValid())throw new Error("Bounds are not valid.");var Y=this._getBoundsCenterZoom(p,M);return this.setView(Y.center,Y.zoom,M)},fitWorld:function(p){return this.fitBounds([[-90,-180],[90,180]],p)},panTo:function(p,M){return this.setView(p,this._zoom,{pan:M})},panBy:function(p,M){if(p=Ee(p).round(),M=M||{},!p.x&&!p.y)return this.fire("moveend");if(M.animate!==!0&&!this.getSize().contains(p))return this._resetView(this.unproject(this.project(this.getCenter()).add(p)),this.getZoom()),this;if(this._panAnim||(this._panAnim=new na,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),M.noMoveStart||this.fire("movestart"),M.animate!==!1){Gn(this._mapPane,"leaflet-pan-anim");var Y=this._getMapPanePos().subtract(p).round();this._panAnim.run(this._mapPane,Y,M.duration||.25,M.easeLinearity)}else this._rawPanBy(p),this.fire("move").fire("moveend");return this},flyTo:function(p,M,Y){if(Y=Y||{},Y.animate===!1||!is.any3d)return this.setView(p,M,Y);this._stop();var ue=this.project(this.getCenter()),Se=this.project(p),st=this.getSize(),At=this._zoom;p=Ke(p),M=M===void 0?At:M;var hs=Math.max(st.x,st.y),ws=hs*this.getZoomScale(At,M),Os=Se.distanceTo(ue)||1,_n=1.42,Ta=_n*_n;function yr(fo){var Ua=fo?-1:1,vm=fo?ws:hs,_h=ws*ws-hs*hs+Ua*Ta*Ta*Os*Os,yh=2*vm*Ta*Os,Bu=_h/yh,Ad=Math.sqrt(Bu*Bu+1)-Bu,Vf=Ad<1e-9?-18:Math.log(Ad);return Vf}function cr(fo){return(Math.exp(fo)-Math.exp(-fo))/2}function bo(fo){return(Math.exp(fo)+Math.exp(-fo))/2}function zi(fo){return cr(fo)/bo(fo)}var jo=yr(0);function $a(fo){return hs*(bo(jo)/bo(jo+_n*fo))}function jn(fo){return hs*(bo(jo)*zi(jo+_n*fo)-cr(jo))/Ta}function Ou(fo){return 1-Math.pow(1-fo,1.5)}var xh=Date.now(),Ac=(yr(1)-jo)/_n,Uc=Y.duration?1e3*Y.duration:1e3*Ac*.8;function Dc(){var fo=(Date.now()-xh)/Uc,Ua=Ou(fo)*Ac;fo<=1?(this._flyToFrame=Q(Dc,this),this._move(this.unproject(ue.add(Se.subtract(ue).multiplyBy(jn(Ua)/Os)),At),this.getScaleZoom(hs/$a(Ua),At),{flyTo:!0})):this._move(p,M)._moveEnd(!0)}return this._moveStart(!0,Y.noMoveStart),Dc.call(this),this},flyToBounds:function(p,M){var Y=this._getBoundsCenterZoom(p,M);return this.flyTo(Y.center,Y.zoom,M)}
755,setMaxBounds:function(p){return p=ke(p),this.listens("moveend",this._panInsideMaxBounds)&&this.off("moveend",this._panInsideMaxBounds),p.isValid()?(this.options.maxBounds=p,this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds)):(this.options.maxBounds=null,this)},setMinZoom:function(p){var M=this.options.minZoom;return this.options.minZoom=p,this._loaded&&M!==p&&(this.fire("zoomlevelschange"),this.getZoom()<this.options.minZoom)?this.setZoom(p):this},setMaxZoom:function(p){var M=this.options.maxZoom;return this.options.maxZoom=p,this._loaded&&M!==p&&(this.fire("zoomlevelschange"),this.getZoom()>this.options.maxZoom)?this.setZoom(p):this},panInsideBounds:function(p,M){this._enforcingBounds=!0;var Y=this.getCenter(),ue=this._limitCenter(Y,this._zoom,ke(p));return Y.equals(ue)||this.panTo(ue,M),this._enforcingBounds=!1,this},panInside:function(p,M){M=M||{};var Y=Ee(M.paddingTopLeft||M.padding||[0,0]),ue=Ee(M.paddingBottomRight||M.padding||[0,0]),Se=this.project(this.getCenter()),st=this.project(p),At=this.getPixelBounds(),hs=we([At.min.add(Y),At.max.subtract(ue)]),ws=hs.getSize();if(!hs.contains(st)){this._enforcingBounds=!0;var Os=st.subtract(hs.getCenter()),_n=hs.extend(st).getSize().subtract(ws);Se.x+=Os.x<0?-_n.x:_n.x,Se.y+=Os.y<0?-_n.y:_n.y,this.panTo(this.unproject(Se),M),this._enforcingBounds=!1}return this},invalidateSize:function(p){if(!this._loaded)return this;p=l({animate:!1,pan:!0},p===!0?{animate:!0}:p);var M=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var Y=this.getSize(),ue=M.divideBy(2).round(),Se=Y.divideBy(2).round(),st=ue.subtract(Se);return!st.x&&!st.y?this:(p.animate&&p.pan?this.panBy(st):(p.pan&&this._rawPanBy(st),this.fire("move"),p.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(u(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:M,newSize:Y}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(p){if(p=this._locateOptions=l({timeout:1e4,watch:!1},p),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var M=u(this._handleGeolocationResponse,this),Y=u(this._handleGeolocationError,this);return p.watch?this._locationWatchId=navigator.geolocation.watchPosition(M,Y,p):navigator.geolocation.getCurrentPosition(M,Y,p),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(p){if(this._container._leaflet_id){var M=p.code,Y=p.message||(M===1?"permission denied":M===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:M,message:"Geolocation error: "+Y+"."})}},_handleGeolocationResponse:function(p){if(this._container._leaflet_id){var M=p.coords.latitude,Y=p.coords.longitude,ue=new ze(M,Y),Se=ue.toBounds(p.coords.accuracy*2),st=this._locateOptions;if(st.setView){var At=this.getBoundsZoom(Se);this.setView(ue,st.maxZoom?Math.min(At,st.maxZoom):At)}var hs={latlng:ue,bounds:Se,timestamp:p.timestamp};for(var ws in p.coords)typeof p.coords[ws]=="number"&&(hs[ws]=p.coords[ws]);this.fire("locationfound",hs)}},addHandler:function(p,M){if(!M)return this;var Y=this[p]=new M(this);return this._handlers.push(Y),this.options[p]&&Y.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),_r(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(Z(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var p;for(p in this._layers)this._layers[p].remove();
755for(p in this._panes)_r(this._panes[p]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(p,M){var Y="leaflet-pane"+(p?" leaflet-"+p.replace("Pane","")+"-pane":""),ue=Mn("div",Y,M||this._mapPane);return p&&(this._panes[p]=ue),ue},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var p=this.getPixelBounds(),M=this.unproject(p.getBottomLeft()),Y=this.unproject(p.getTopRight());return new Ze(M,Y)},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(p,M,Y){p=ke(p),Y=Ee(Y||[0,0]);var ue=this.getZoom()||0,Se=this.getMinZoom(),st=this.getMaxZoom(),At=p.getNorthWest(),hs=p.getSouthEast(),ws=this.getSize().subtract(Y),Os=we(this.project(hs,ue),this.project(At,ue)).getSize(),_n=is.any3d?this.options.zoomSnap:1,Ta=ws.x/Os.x,yr=ws.y/Os.y,cr=M?Math.max(Ta,yr):Math.min(Ta,yr);return ue=this.getScaleZoom(cr,ue),_n&&(ue=Math.round(ue/(_n/100))*(_n/100),ue=M?Math.ceil(ue/_n)*_n:Math.floor(ue/_n)*_n),Math.max(Se,Math.min(st,ue))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new ge(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(p,M){var Y=this._getTopLeftPoint(p,M);return new ve(Y,Y.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(p){return this.options.crs.getProjectedBounds(p===void 0?this.getZoom():p)},getPane:function(p){return typeof p=="string"?this._panes[p]:p},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(p,M){var Y=this.options.crs;return M=M===void 0?this._zoom:M,Y.scale(p)/Y.scale(M)},getScaleZoom:function(p,M){var Y=this.options.crs;M=M===void 0?this._zoom:M;var ue=Y.zoom(p*Y.scale(M));return isNaN(ue)?1/0:ue},project:function(p,M){return M=M===void 0?this._zoom:M,this.options.crs.latLngToPoint(Ke(p),M)},unproject:function(p,M){return M=M===void 0?this._zoom:M,this.options.crs.pointToLatLng(Ee(p),M)},layerPointToLatLng:function(p){var M=Ee(p).add(this.getPixelOrigin());return this.unproject(M)},latLngToLayerPoint:function(p){var M=this.project(Ke(p))._round();return M._subtract(this.getPixelOrigin())},wrapLatLng:function(p){return this.options.crs.wrapLatLng(Ke(p))},wrapLatLngBounds:function(p){return this.options.crs.wrapLatLngBounds(ke(p))},distance:function(p,M){return this.options.crs.distance(Ke(p),Ke(M))},containerPointToLayerPoint:function(p){return Ee(p).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(p){return Ee(p).add(this._getMapPanePos())},containerPointToLatLng:function(p){var M=this.containerPointToLayerPoint(Ee(p));return this.layerPointToLatLng(M)},latLngToContainerPoint:function(p){return this.layerPointToContainerPoint(this.latLngToLayerPoint(Ke(p)))},mouseEventToContainerPoint:function(p){return oa(p,this._container)},mouseEventToLayerPoint:function(p){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(p))},mouseEventToLatLng:function(p){return this.layerPointToLatLng(this.mouseEventToLayerPoint(p))},_initContainer:function(p){var M=this._container=Ha(p);if(M){if(M._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");fn(M,"scroll",this._onScroll,this),this._containerId=_(M)},_initLayout:function(){var p=this._container;this._fadeAnimated=this.options.fadeAnimation&&is.any3d,Gn(p,"leaflet-container"+(is.touch?" leaflet-touch":"")+(is.retina?" leaflet-retina":"")+(is.ielt9?" leaflet-oldie":"")+(is.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var M=qa(p,"position");M!=="absolute"&&M!=="relative"&&M!=="fixed"&&M!=="sticky"&&(p.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var p=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),Xr(this._mapPane,new ge(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(Gn(p.markerPane,"leaflet-zoom-hide"),Gn(p.shadowPane,"leaflet-zoom-hide"))},_resetView:function(p,M,Y){Xr(this._mapPane,new ge(0,0));var ue=!this._loaded;this._loaded=!0,M=this._limitZoom(M),this.fire("viewprereset");var Se=this._zoom!==M;this._moveStart(Se,Y)._move(p,M)._moveEnd(Se),this.fire("viewreset"),ue&&this.fire("load")},_moveStart:function(p,M){return p&&this.fire("zoomstart"),M||this.fire("movestart"),this},_move:function(p,M,Y,ue){M===void 0&&(M=this._zoom);var Se=this._zoom!==M;return this._zoom=M,this._lastCenter=p,this._pixelOrigin=this._getNewPixelOrigin(p),ue?Y&&Y.pinch&&this.fire("zoom",Y):((Se||Y&&Y.pinch)&&this.fire("zoom",Y),this.fire("move",Y)),this},_moveEnd:function(p){return p&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return Z(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(p){Xr(this._mapPane,this._getMapPanePos().subtract(p))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(p){this._targets={},this._targets[_(this._container)]=this;var M=p?nr:fn;M(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&M(window,"resize",this._onResize,this),is.any3d&&this.options.transform3DLimit&&(p?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){Z(this._resizeRequest),this._resizeRequest=Q(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var p=this._getMapPanePos();Math.max(Math.abs(p.x),Math.abs(p.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(p,M){for(var Y=[],ue,Se=M==="mouseout"||M==="mouseover",st=p.target||p.srcElement,At=!1;st;){if(ue=this._targets[_(st)],ue&&(M==="click"||M==="preclick")&&this._draggableMoved(ue)){At=!0;break}if(ue&&ue.listens(M,!0)&&(Se&&!$r(st,p)||(Y.push(ue),Se))||st===this._container)break;st=st.parentNode}return!Y.length&&!At&&!Se&&this.listens(M,!0)&&(Y=[this]),Y},_isClickDisabled:function(p){for(;p&&p!==this._container;){if(p._leaflet_disable_click)return!0;p=p.parentNode}},_handleDOMEvent:function(p){var M=p.target||p.srcElement;if(!(!this._loaded||M._leaflet_disable_events||p.type==="click"&&this._isCl
755ickDisabled(M))){var Y=p.type;Y==="mousedown"&&hl(M),this._fireDOMEvent(p,Y)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(p,M,Y){if(p.type==="click"){var ue=l({},p);ue.type="preclick",this._fireDOMEvent(ue,ue.type,Y)}var Se=this._findEventTargets(p,M);if(Y){for(var st=[],At=0;At<Y.length;At++)Y[At].listens(M,!0)&&st.push(Y[At]);Se=st.concat(Se)}if(Se.length){M==="contextmenu"&&ti(p);var hs=Se[0],ws={originalEvent:p};if(p.type!=="keypress"&&p.type!=="keydown"&&p.type!=="keyup"){var Os=hs.getLatLng&&(!hs._radius||hs._radius<=10);ws.containerPoint=Os?this.latLngToContainerPoint(hs.getLatLng()):this.mouseEventToContainerPoint(p),ws.layerPoint=this.containerPointToLayerPoint(ws.containerPoint),ws.latlng=Os?hs.getLatLng():this.layerPointToLatLng(ws.layerPoint)}for(At=0;At<Se.length;At++)if(Se[At].fire(M,ws,!0),ws.originalEvent._stopped||Se[At].options.bubblingMouseEvents===!1&&K(this._mouseEvents,M)!==-1)return}},_draggableMoved:function(p){return p=p.dragging&&p.dragging.enabled()?p:this,p.dragging&&p.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var p=0,M=this._handlers.length;p<M;p++)this._handlers[p].disable()},whenReady:function(p,M){return this._loaded?p.call(M||this,{target:this}):this.on("load",p,M),this},_getMapPanePos:function(){return rn(this._mapPane)||new ge(0,0)},_moved:function(){var p=this._getMapPanePos();return p&&!p.equals([0,0])},_getTopLeftPoint:function(p,M){var Y=p&&M!==void 0?this._getNewPixelOrigin(p,M):this.getPixelOrigin();return Y.subtract(this._getMapPanePos())},_getNewPixelOrigin:function(p,M){var Y=this.getSize()._divideBy(2);return this.project(p,M)._subtract(Y)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(p,M,Y){var ue=this._getNewPixelOrigin(Y,M);return this.project(p,M)._subtract(ue)},_latLngBoundsToNewLayerBounds:function(p,M,Y){var ue=this._getNewPixelOrigin(Y,M);
755return we([this.project(p.getSouthWest(),M)._subtract(ue),this.project(p.getNorthWest(),M)._subtract(ue),this.project(p.getSouthEast(),M)._subtract(ue),this.project(p.getNorthEast(),M)._subtract(ue)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(p){return this.latLngToLayerPoint(p).subtract(this._getCenterLayerPoint())},_limitCenter:function(p,M,Y){if(!Y)return p;var ue=this.project(p,M),Se=this.getSize().divideBy(2),st=new ve(ue.subtract(Se),ue.add(Se)),At=this._getBoundsOffset(st,Y,M);return Math.abs(At.x)<=1&&Math.abs(At.y)<=1?p:this.unproject(ue.add(At),M)},_limitOffset:function(p,M){if(!M)return p;var Y=this.getPixelBounds(),ue=new ve(Y.min.add(p),Y.max.add(p));return p.add(this._getBoundsOffset(ue,M))},_getBoundsOffset:function(p,M,Y){var ue=we(this.project(M.getNorthEast(),Y),this.project(M.getSouthWest(),Y)),Se=ue.min.subtract(p.min),st=ue.max.subtract(p.max),At=this._rebound(Se.x,-st.x),hs=this._rebound(Se.y,-st.y);return new ge(At,hs)},_rebound:function(p,M){return p+M>0?Math.round(p-M)/2:Math.max(0,Math.ceil(p))-Math.max(0,Math.floor(M))},_limitZoom:function(p){var M=this.getMinZoom(),Y=this.getMaxZoom(),ue=is.any3d?this.options.zoomSnap:1;return ue&&(p=Math.round(p/ue)*ue),Math.max(M,Math.min(Y,p))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){sa(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(p,M){var Y=this._getCenterOffset(p)._trunc();return(M&&M.animate)!==!0&&!this.getSize().contains(Y)?!1:(this.panBy(Y,M),!0)},_createAnimProxy:function(){var p=this._proxy=Mn("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(p),this.on("zoomanim",function(M){var Y=Xo,ue=this._proxy.style[Y];Gr(this._proxy,this.project(M.center,M.zoom),this.getZoomScale(M.zoom,1)),ue===this._proxy.style[Y]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){_r(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var p=this.getCenter(),M=this.getZoom();Gr(this._proxy,this.project(p,M),this.getZoomScale(M,1))},_catchTransitionEnd:function(p){this._animatingZoom&&p.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(p,M,Y){if(this._animatingZoom)return!0;if(Y=Y||{}
vendor: 5,044 bytes, line 755
755,!this._zoomAnimated||Y.animate===!1||this._nothingToAnimate()||Math.abs(M-this._zoom)>this.options.zoomAnimationThreshold)return!1;var ue=this.getZoomScale(M),Se=this._getCenterOffset(p)._divideBy(1-1/ue);return Y.animate!==!0&&!this.getSize().contains(Se)?!1:(Q(function(){this._moveStart(!0,Y.noMoveStart||!1)._animateZoom(p,M,!0)},this),!0)},_animateZoom:function(p,M,Y,ue){this._mapPane&&(Y&&(this._animatingZoom=!0,this._animateToCenter=p,this._animateToZoom=M,Gn(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:p,zoom:M,noUpdate:ue}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(u(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&sa(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function Ui(p,M){return new Sn(p,M)}var Ma=ce.extend({options:{position:"topright"},initialize:function(p){I(this,p)},getPosition:function(){return this.options.position},setPosition:function(p){var M=this._map;return M&&M.removeControl(this),this.options.position=p,M&&M.addControl(this),this},getContainer:function(){return this._container},addTo:function(p){this.remove(),this._map=p;var M=this._container=this.onAdd(p),Y=this.getPosition(),ue=p._controlCorners[Y];return Gn(M,"leaflet-control"),Y.indexOf("bottom")!==-1?ue.insertBefore(M,ue.firstChild):ue.appendChild(M),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(_r(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(p){this._map&&p&&p.screenX>0&&p.screenY>0&&this._map.getContainer().focus()}}),Di=function(p){return new Ma(p)};Sn.include({addControl:function(p){return p.addTo(this),this},removeControl:function(p){return p.remove(),this},_initControlPos:function(){var p=this._controlCorners={},M="leaflet-",Y=this._controlContainer=Mn("div",M+"control-container",this._container);function ue(Se,st){var At=M+Se+" "+M+st;p[Se+st]=Mn("div",At,Y)}ue("top","left"),ue("top","right"),ue("bottom","left"),ue("bottom","right")},_clearControlPos:function(){for(var p in this._controlCorners)_r(this._controlCorners[p]);_r(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var Al=Ma.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(p,M,Y,ue){return Y<ue?-1:ue<Y?1:0}},initialize:function(p,M,Y){I(this,Y),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1;for(var ue in p)this._addLayer(p[ue],ue);for(ue in M)this._addLayer(M[ue],ue,!0)},onAdd:function(p){this._initLayout(),this._update(),this._map=p,p.on("zoomend",this._checkDisabledLayers,this);for(var M=0;M<this._layers.length;M++)this._layers[M].layer.on("add remove",this._onLayerChange,this);return this._container},addTo:function(p){return Ma.prototype.addTo.call(this,p),this._expandIfNotCollapsed()},onRemove:function(){this._map.off("zoomend",this._checkDisabledLayers,this);for(var p=0;p<this._layers.length;p++)this._layers[p].layer.off("add remove",this._onLayerChange,this)},addBaseLayer:function(p,M){return this._addLayer(p,M),this._map?this._update():this},addOverlay:function(p,M){return this._addLayer(p,M,!0),this._map?this._update():this},removeLayer:function(p){p.off("add remove",this._onLayerChange,this);var M=this._getLayer(_(p));return M&&this._layers.splice(this._layers.indexOf(M),1),this._map?this._update():this},expand:function(){Gn(this._container,"leaflet-control-layers-expanded"),this._section.style.height=null;var p=this._map.getSize().y-(this._container.offsetTop+50);return p<this._section.clientHeight?(Gn(this._section,"leaflet-control-layers-scrollbar"),this._section.style.height=p+"px"):sa(this._section,"leaflet-control-layers-scrollbar"),this._checkDisabledLayers(),this},collapse:function(){return sa(this._container,"leaflet-control-layers-expanded"),this},_initLayout:function(){var p="leaflet-control-layers",M=this._container=Mn("div",p),Y=this.options.collapsed;M.setAttribute("aria-haspopup",!0),Co(M),ml(M);var ue=this._section=Mn("section",p+"-list");Y&&(this._map.on("click",this.collapse,this),fn(M,{mouseenter:this._expandSafely,mouseleave:this.collapse},this));var Se=this._layersLink=Mn("a",p+"-toggle",M);Se.href="#",Se.title="Layers",Se.setAttribute("role","button"),fn(Se,{keydown:function(st){st.keyCode===13&&this._expandSafely()},click:function(st){ti(st),this._expandSafely()}},this),Y||this.expand(),this._baseLayersList=Mn("div",p+"-base",ue),this._separator=Mn("div",p+"-separator",ue),this._overlaysList=Mn("div",p+"-overlays",ue),M.appendChild(ue)},_getLayer:function(p){for(var M=0;M<this._layers.length;
755M++)if(this._layers[M]&&_(this._layers[M].layer)===p)return this._layers[M]},_addLayer:function(p,M,Y){this._map&&p.on("add remove",this._onLayerChange,this),this._layers.push({layer:p,name:M,overlay:Y}),this.options.sortLayers&&this._layers.sort(u(function(ue,Se){return this.options.sortFunction(ue.layer,Se.layer,ue.name,Se.name)},this)),this.options.autoZIndex&&p.setZIndex&&(this._lastZIndex++,p.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()},_update:function(){if(!this._container)return this;Ar(this._baseLayersList),Ar(this._overlaysList),this._layerControlInputs=[];var p,M,Y,ue,Se=0;for(Y=0;Y<this._layers.length;Y++)ue=this._layers[Y],this._addItem(ue),M=M||ue.overlay,p=p||!ue.overlay,Se+=ue.overlay?0:1;return this.options.hideSingleBase&&(p=p&&Se>1,this._baseLayersList.style.display=p?"":"none"),this._separator.style.display=M&&p?"":"none",this},_onLayerChange:function(p){this._handlingClick||this._update();var M=this._getLayer(_(p.target)),Y=M.overlay?p.type==="add"?"overlayadd":"overlayremove":p.type==="add"?"baselayerchange":null;Y&&this._map.fire(Y,M)},_createRadioElement:function(p,M){var Y='<input type="radio" class="leaflet-control-layers-selector" name="'+p+'"'+(M?' checked="checked"':"")+"/>",ue=document.createElement("div");return ue.innerHTML=Y,ue.firstChild},_addItem:function(p){var M=document.createElement("label"),Y=this._map.hasLayer(p.layer),ue;p.overlay?(ue=document.createElement("input"),ue.type="checkbox",ue.className="leaflet-control-layers-selector",ue.defaultChecked=Y):ue=this._createRadioElement("leaflet-base-layers_"+_(this),Y),this._layerControlInputs.push(ue),ue.layerId=_(p.layer),fn(ue,"click",this._onInputClick,this);var Se=document.createElement("span");Se.innerHTML=" "+p.name;var st=document.createElement("span");M.appendChild(st),st.appendChild(ue),st.appendChild(Se);var At=p.overlay?this._overlaysList:this._baseLayersList;return At.appendChild(M),this._checkDisabledLayers(),M},_onInputClick:function(){if(!this._preventClick){var p=this._layerControlInputs,M,Y,ue=[],Se=[];this._handlingClick=!0;for(var st=p.length-1;st>=0;st--)M=p[st],Y=this._getLayer(M.layerId).layer,M.checked?ue.push(Y):M.checked||Se.push(Y);for(st=0;st<Se.length;st++)this._map.hasLayer(Se[st])&&this._map.removeLayer(Se[st]);for(st=0;st<ue.length;st++)this._map.hasLayer(ue[st])||this._map.addLayer(ue[st]);this._handlingClick=!1,this._refocusOnMap()}},_checkDisabledLayers:function(){for(var p=this._layerControlInputs,M,Y,ue=this._map.getZoom(),Se=p.length-1;Se>=0;Se--)M=p[Se],Y=this._getLayer(M.layerId).layer,M.disabled=Y.options.minZoom!==void 0&&ue<Y.options.minZoom||Y.options.maxZoom!==void 0&&ue>Y.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var p=this._section;this._preventClick=!0,fn(p,"click",ti),this.expand();var M=this;setTimeout(function(){nr(p,"click",ti),M._preventClick=!1})}}),cc=function(p,M,Y){return new Al(p,M,Y)},dc=Ma.extend({options:{position:"topleft",zoomInText:'<span aria-hidden="true">+</span>',zoomInTitle:"Zoom in",zoomOutText:'<span aria-hidden="true">&#x2212;</span>',zoomOutTitle:"Zoom out"},onAdd:function(p){var M="leaflet-control-zoom",Y=Mn("div",M+" leaflet-bar"),ue=this.options;return this._zoomInButton=this._createButton(ue.zoomInText,ue.zoomInTitle,M+"-in",Y,this._zoomIn),this._zoomOutButton=this._createButton(ue.zoomOutText,ue.zoomOutTitle,M+"-out",Y,this._zoomOut),this._updateDisabled(),p.on("zoomend zoomlevelschange",this._updateDisabled,this),Y},onRemove:function(p){p.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(p){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(p.shiftKey?3:1))},_zoomOut:function(p){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(p.shiftKey?3:1))},_createButton:function(p,M,Y,ue,Se){var st=Mn("a",Y,ue);return st.innerHTML=p,st.href="#",st.title=M,st.setAttribute("role","button"),st.setAttribute("aria-label",M),Co(st),fn(st,"click",qs),fn(st,"click",Se,this),fn(st,"click",this._refocusOnMap,this),st},_updateDisabled:function(){var p=this._map,M="leaflet-disabled";sa(this._zoomInButton,M),sa(this._zoomOutButton,M),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||p._zoom===p.getMinZoom())&&(Gn(this._zoomOutButton,M),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||p._zoom===p.getMaxZoom())&&(Gn(this._zoomInButton,M),this._zoomInButton.setAttribute("aria-disabled","true"))}});Sn.mergeOptions({zoomControl:!0}),Sn.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new dc,this.addControl(this.zoomControl))});var _u=function(p){return new dc(p)},uc=Ma.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(p){var M="leaflet-control-scale",Y=Mn("div",M),ue=this.options;return this._addScales(ue,M+"-line",Y),p.on(ue.updateWhenIdle?"moveend":"move",this._update,this),p.whenReady(this._update,this),Y},onRemove:function(p){p.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(p,M,Y){p.metric&&(this._mScale=Mn("div",M,Y)),p.imperial&&(this._iScale=Mn("div",M,Y))},_update:function(){var p=this._map,M=p.getSize().y/2,Y=p.distance(p.containerPointToLatLng([0,M]),p.containerPointToLatLng([this.options.maxWidth,M]));this._updateScales(Y)},_updateScales:function(p){this.options.metric&&p&&this._updateMetric(p),this.options.imperial&&p&&this._updateImperial(p)},_updateMetric:function(p){var M=this._getRoundNum(p),Y=M<1e3?M+" m":M/1e3+" km";this._updateScale(this._mScale,Y,M/p)},_updateImperial:function(p){var M=p*3.2808399,Y,ue,Se;M>
7555280?(Y=M/5280,ue=this._getRoundNum(Y),this._updateScale(this._iScale,ue+" mi",ue/Y)):(Se=this._getRoundNum(M),this._updateScale(this._iScale,Se+" ft",Se/M))},_updateScale:function(p,M,Y){p.style.width=Math.round(this.options.maxWidth*Y)+"px",p.innerHTML=M},_getRoundNum:function(p){var M=Math.pow(10,(Math.floor(p)+"").length-1),Y=p/M;return Y=Y>=10?10:Y>=5?5:Y>=3?3:Y>=2?2:1,M*Y}}),hc=function(p){return new uc(p)},kl='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8" class="leaflet-attribution-flag"><path fill="#4C7BE1" d="M0 0h12v4H0z"/><path fill="#FFD500" d="M0 4h12v3H0z"/><path fill="#E0BC00" d="M0 7h12v1H0z"/></svg>',Ki=Ma.extend({options:{position:"bottomright",prefix:'<a href="https://leafletjs.com" title="A JavaScript library for interactive maps">'+(is.inlineSvg?kl+" ":"")+"Leaflet</a>"},initialize:function(p){I(this,p),this._attributions={}},onAdd:function(p){p.attributionControl=this,this._container=Mn("div","leaflet-control-attribution"),Co(this._container);for(var M in p._layers)p._layers[M].getAttribution&&this.addAttribution(p._layers[M].getAttribution());return this._update(),p.on("layeradd",this._addAttribution,this),this._container},onRemove:function(p){p.off("layeradd",this._addAttribution,this)},_addAttribution:function(p){p.layer.getAttribution&&(this.addAttribution(p.layer.getAttribution()),p.layer.once("remove",function(){this.removeAttribution(p.layer.getAttribution())},this))},setPrefix:function(p){return this.options.prefix=p,this._update(),this},addAttribution:function(p){return p?(this._attributions[p]||(this._attributions[p]=0),this._attributions[p]++,this._update(),this):this},removeAttribution:function(p){return p?(this._attributions[p]&&
755(this._attributions[p]--,this._update()),this):this},_update:function(){if(this._map){var p=[];for(var M in this._attributions)this._attributions[M]&&p.push(M);var Y=[];this.options.prefix&&Y.push(this.options.prefix),p.length&&Y.push(p.join(", ")),this._container.innerHTML=Y.join(' <span aria-hidden="true">|</span> ')}}});Sn.mergeOptions({attributionControl:!0}),Sn.addInitHook(function(){this.options.attributionControl&&new Ki().addTo(this)});var Dl=function(p){return new Ki(p)};Ma.Layers=Al,Ma.Zoom=dc,Ma.Scale=uc,Ma.Attribution=Ki,Di.layers=cc,Di.zoom=_u,Di.scale=hc,Di.attribution=Dl;var Ri=ce.extend({initialize:function(p){this._map=p},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});Ri.addTo=function(p,M){return p.addHandler(M,this),this};var Qo={Events:ie},Cl=is.touch?"touchstart mousedown":"mousedown",Rl=de.extend({options:{clickTolerance:3},initialize:function(p,M,Y,ue){I(this,ue),this._element=p,this._dragStartTarget=M||p,this._preventOutline=Y},enable:function(){this._enabled||(fn(this._dragStartTarget,Cl,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(Rl._dragging===this&&this.finishDrag(!0),nr(this._dragStartTarget,Cl,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(p){if(this._enabled&&(this._moved=!1,!Na(this._element,"leaflet-zoom-anim"))){if(p.touches&&p.touches.length!==1){Rl._dragging===this&&this.finishDrag();return}if(!(Rl._dragging||p.shiftKey||p.which!==1&&p.button!==1&&!p.touches)&&(Rl._dragging=this,this._preventOutline&&hl(this._element),zo(),In(),!this._moving)){this.fire("down");var M=p.touches?p.touches[0]:p,Y=ui(this._element);this._startPoint=new ge(M.clientX,M.clientY),this._startPos=rn(this._element),this._parentScale=Zr(Y);var ue=p.type==="mousedown";fn(document,ue?"mousemove":"touchmove",this._onMove,this),fn(document,ue?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(p){if(this._enabled){if(p.touches&&p.touches.length>1){this._moved=!0;return}var M=p.touches&&p.touches.length===1?p.touches[0]:p,Y=new ge(M.clientX,M.clientY)._subtract(this._startPoint);!Y.x&&!Y.y||Math.abs(Y.x)+Math.abs(Y.y)<this.options.clickTolerance||(Y.x/=this._parentScale.x,Y.y/=this._parentScale.y,ti(p),this._moved||(this.fire("dragstart"),this._moved=!0,Gn(document.body,"leaflet-dragging"),this._lastTarget=p.target||p.srcElement,window.SVGElementInstance&&this._lastTarget instanceof window.SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),Gn(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(Y),this._moving=!0,this._lastEvent=p,this._updatePosition())}},_updatePosition:function(){var p={originalEvent:this._lastEvent};this.fire("predrag",p),Xr(this._element,this._newPos),this.fire("drag",p)},_onUp:function(){this._enabled&&this.finishDrag()},finishDrag:function(p){sa(document.body,"leaflet-dragging"),this._lastTarget&&(sa(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null),nr(document,"mousemove touchmove",this._onMove,this),nr(document,"mouseup touchend touchcancel",this._onUp,this),Pc(),Yi();var M=this._moved&&this._moving;this._moving=!1,Rl._dragging=!1,M&&this.fire("dragend",{noInertia:p,distance:this._newPos.distanceTo(this._startPos)})}});function Md(p,M,Y){var ue,Se=[1,4,2,8],st,At,hs,ws,Os,_n,Ta,yr;for(st=0,_n=p.length;st<_n;st++)p[st]._code=Wr(p[st],M);for(hs=0;hs<4;hs++){for(Ta=Se[hs],ue=[],st=0,_n=p.length,At=_n-1;st<_n;At=st++)ws=p[st],Os=p[At],ws._code&Ta?Os._code&Ta||(yr=eo(Os,ws,Ta,M,Y),yr._code=Wr(yr,M),ue.push(yr)):(Os._code&Ta&&(yr=eo(Os,ws,Ta,M,Y),yr._code=Wr(yr,M),ue.push(yr)),ue.push(ws));p=ue}return p}function fl(p,M){var Y,ue,Se,st,At,hs,ws,Os,_n;if(!p||p.length===0)throw new Error("latlngs not passed");_o(p)||(console.warn("latlngs are not flat! Only the first ring will be used"),p=p[0]);var Ta=Ke([0,0]),yr=ke(p),cr=yr.getNorthWest().distanceTo(yr.getSouthWest
755())*yr.getNorthEast().distanceTo(yr.getNorthWest());cr<1700&&(Ta=So(p));var bo=p.length,zi=[];for(Y=0;Y<bo;Y++){var jo=Ke(p[Y]);zi.push(M.project(Ke([jo.lat-Ta.lat,jo.lng-Ta.lng])))}for(hs=ws=Os=0,Y=0,ue=bo-1;Y<bo;ue=Y++)Se=zi[Y],st=zi[ue],At=Se.y*st.x-st.y*Se.x,ws+=(Se.x+st.x)*At,Os+=(Se.y+st.y)*At,hs+=At*3;hs===0?_n=zi[0]:_n=[ws/hs,Os/hs];var $a=M.unproject(Ee(_n));return Ke([$a.lat+Ta.lat,$a.lng+Ta.lng])}function So(p){for(var M=0,Y=0,ue=0,Se=0;Se<p.length;Se++){var st=Ke(p[Se]);M+=st.lat,Y+=st.lng,ue++}return Ke([M/ue,Y/ue])}var Kr={__proto__:null,clipPolygon:Md,polygonCenter:fl,centroid:So};function hi(p,M){if(!M||!p.length)return p.slice();var Y=M*M;return p=gd(p,Y),p=Hl(p,Y),p}function Jd(p,M,Y){return Math.sqrt(Wl(p,M,Y,!0))}function Id(p,M,Y){return Wl(p,M,Y)}function Hl(p,M){var Y=p.length,ue=typeof Uint8Array<"u"?Uint8Array:Array,Se=new ue(Y);Se[0]=Se[Y-1]=1,Sl(p,Se,M,0,Y-1);var st,At=[];for(st=0;st<Y;st++)Se[st]&&At.push(p[st]);return At}function Sl(p,M,Y,ue,Se){var st=0,At,hs,ws;for(hs=ue+1;hs<=Se-1;hs++)ws=Wl(p[hs],p[ue],p[Se],!0),ws>
755st&&(At=hs,st=ws);st>Y&&(M[At]=1,Sl(p,M,Y,ue,At),Sl(p,M,Y,At,Se))}function gd(p,M){for(var Y=[p[0]],ue=1,Se=0,st=p.length;ue<st;ue++)Tc(p[ue],p[Se])>M&&(Y.push(p[ue]),Se=ue);return Se<st-1&&Y.push(p[st-1]),Y}var Zl;function Hi(p,M,Y,ue,Se){var st=ue?Zl:Wr(p,Y),At=Wr(M,Y),hs,ws,Os;for(Zl=At;;){if(!(st|At))return[p,M];if(st&At)return!1;hs=st||At,ws=eo(p,M,hs,Y,Se),Os=Wr(ws,Y),hs===st?(p=ws,st=Os):(M=ws,At=Os)}}function eo(p,M,Y,ue,Se){var st=M.x-p.x,At=M.y-p.y,hs=ue.min,ws=ue.max,Os,_n;return Y&8?(Os=p.x+st*(ws.y-p.y)/At,_n=ws.y):Y&4?(Os=p.x+st*(hs.y-p.y)/At,_n=hs.y):Y&2?(Os=ws.x,_n=p.y+At*(ws.x-p.x)/st):Y&1&&(Os=hs.x,_n=p.y+At*(hs.x-p.x)/st),new ge(Os,_n,Se)}function Wr(p,M){var Y=0;return p.x<M.min.x?Y|=1:p.x>M.max.x&&(Y|=2),p.y<M.min.y?Y|=4:p.y>M.max.y&&(Y|=8),Y}function Tc(p,M){var Y=M.x-p.x,ue=M.y-p.y;return Y*Y+ue*ue}function Wl(p,M,Y,ue){var Se=M.x,st=M.y,At=Y.x-Se,hs=Y.y-st,ws=At*At+hs*hs,Os;return ws>0&&(Os=((p.x-Se)*At+(p.y-st)*hs)/ws,Os>1?(Se=Y.x,st=Y.y):Os>0&&(Se+=At*Os,st+=hs*Os)),At=p.x-Se,hs=p.y-st,ue?At*At+hs*hs:new ge(Se,st)}function _o(p){return!X(p[0])||typeof p[0][0]!="object"&&typeof p[0][0]<"u"}function Yl(p){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),_o(p)}function Xl(p,M){var Y,ue,Se,st,At,hs,ws,Os;if(!p||p.length===0)throw new Error("latlngs not passed");_o(p)||(console.warn("latlngs are not flat! Only the first ring will be used"),p=p[0]);var _n=Ke([0,0]),Ta=ke(p),yr=Ta.getNorthWest().distanceTo(Ta.getSouthWest
755())*Ta.getNorthEast().distanceTo(Ta.getNorthWest());yr<1700&&(_n=So(p));var cr=p.length,bo=[];for(Y=0;Y<cr;Y++){var zi=Ke(p[Y]);bo.push(M.project(Ke([zi.lat-_n.lat,zi.lng-_n.lng])))}for(Y=0,ue=0;Y<cr-1;Y++)ue+=bo[Y].distanceTo(bo[Y+1])/2;if(ue===0)Os=bo[0];else for(Y=0,st=0;Y<cr-1;Y++)if(At=bo[Y],hs=bo[Y+1],Se=At.distanceTo(hs),st+=Se,st>ue){ws=(st-ue)/Se,Os=[hs.x-ws*(hs.x-At.x),hs.y-ws*(hs.y-At.y)];break}var jo=M.unproject(Ee(Os));return Ke([jo.lat+_n.lat,jo.lng+_n.lng])}var pl={__proto__:null,simplify:hi,pointToSegmentDistance:Jd,closestPointOnSegment:Id,clipSegment:Hi,_getEdgeIntersection:eo,_getBitCode:Wr,_sqClosestPointOnSegment:Wl,isFlat:_o,_flat:Yl,polylineCenter:Xl},Fl={project:function(p){return new ge(p.lng,p.lat)},unproject:function(p){return new ze(p.y,p.x)},bounds:new ve([-180,-90],[180,90])},Lc={R:6378137,R_MINOR:6356752314245179e-9,bounds:new ve([-2003750834279e-5,-1549657073972e-5],[2003750834279e-5,1876465623138e-5]),project:function(p){var M=Math.PI/180,Y=this.R,ue=p.lat*M,Se=this.R_MINOR/Y,st=Math.sqrt(1-Se*Se),At=st*Math.sin(ue),hs=Math.tan(Math.PI/4-ue/2)/Math.pow((1-At)/(1+At),st/2);return ue=-Y*Math.log(Math.max(hs,1e-10)),new ge(p.lng*M*Y,ue)},unproject:function(p){for(var M=180/Math.PI,Y=this.R,ue=this.R_MINOR/Y,Se=Math.sqrt(1-ue*ue),st=Math.exp(-p.y/Y),At=Math.PI/2-2*Math.atan(st),hs=0,ws=.1,Os;hs<15&&Math.abs(ws)>1e-7;hs++)Os=Se*Math.sin(At),Os=Math.pow((1-Os)/(1+Os),Se/2),ws=Math.PI/2-2*Math.atan(st*Os)-At,At+=ws;return new ze(At*M,p.x*M/Y)}},li={__proto__:null,LonLat:Fl,Mercator:Lc,SphericalMercator:ft},Kl=l({},Re,{code:"EPSG:3395",projection:Lc,transformation:function(){var p=.5/(Math.PI*Lc.R);return fe(p,.5,-p,.5)}()}),Ia=l({},Re,{code:"EPSG:4326",projection:Fl,transformation:fe(1/180,1,-1/180,.5)}),Jl=l({},dt,{projection:Fl,transformation:fe(1,0,-1,0),scale:function(p){return Math.pow(2,p)},zoom:function(p){return Math.log(p)/Math.LN2},distance:function(p,M){var Y=M.lng-p.lng,ue=M.lat-p.lat;return Math.sqrt(Y*Y+ue*ue)},infinite:!0});dt.Earth=Re,dt.EPSG3395=Kl,dt.EPSG3857=Qe,dt.EPSG900913=ht,dt.EPSG4326=Ia,dt.Simple=Jl;var fr=de.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(p){return p.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(p){return p&&p.removeLayer(this),this},getPane:function(p){return this._map.getPane(p?this.options[p]||p:this.options.pane)},addInteractiveTarget:function(p){return this._map._targets[_(p)]=this,this},removeInteractiveTarget:function(p){return delete this._map._targets[_(p)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(p){var M=p.target;if(M.hasLayer(this)){if(this._map=M,this._zoomAnimated=M._zoomAnimated,this.getEvents){var Y=this.getEvents();M.on(Y,this),this.once("remove",function(){M.off(Y,this)},this)}this.onAdd(M),this.fire("add"),M.fire("layeradd",{layer:this})}}});Sn.include({addLayer:function(p){if(!p._layerAdd)throw new Error("The provided object is not a Layer.");var M=_(p);return this._layers[M]?this:(this._layers[M]=p,p._mapToAdd=this,p.beforeAdd&&p.beforeAdd(this),this.whenReady(p._layerAdd,p),this)},removeLayer:function(p){var M=_(p);return this._layers[M]?(this._loaded&&p.onRemove(this),delete this._layers[M],this._loaded&&(this.fire("layerremove",{layer:p}),p.fire("remove")),p._map=p._mapToAdd=null,this):this},hasLayer:function(p){return _(p)in this._layers},eachLayer:function(p,M){for(var Y in this._layers)p.call(M,this._layers[Y]);return this},_addLayers:function(p){p=p?X(p)?p:[p]:[];for(var M=0,Y=p.length;M<Y;M++)this.addLayer(p[M])},_addZoomLimit:function(p){(!isNaN(p.options.maxZoom)||!isNaN(p.options.minZoom))&&(this._zoomBoundLayers[_(p)]=p,this._updateZoomLevels())},_removeZoomLimit:function(p){var M=_(p);this._zoomBoundLayers[M]&&(delete this._zoomBoundLayers[M],this._updateZoomLevels())},_updateZoomLevels:function(){var p=1/0,M=-1/0,Y=this._getZoomSpan();for(var ue in this._zoomBoundLayers){var Se=this._zoomBoundLayers[ue].options;p=Se.minZoom===void 0?p:Math.min(p,Se.minZoom),M=Se.maxZoom===void 0?M:Math.max(M,Se.maxZoom)}
755this._layersMaxZoom=M===-1/0?void 0:M,this._layersMinZoom=p===1/0?void 0:p,Y!==this._getZoomSpan()&&this.fire("zoomlevelschange"),this.options.maxZoom===void 0&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}});var Dr=fr.extend({initialize:function(p,M){I(this,M),this._layers={};var Y,ue;if(p)for(Y=0,ue=p.length;Y<ue;Y++)this.addLayer(p[Y])},addLayer:function(p){var M=this.getLayerId(p);return this._layers[M]=p,this._map&&this._map.addLayer(p),this},removeLayer:function(p){var M=p in this._layers?p:this.getLayerId(p);return this._map&&this._layers[M]&&this._map.removeLayer(this._layers[M]),delete this._layers[M],this},hasLayer:function(p){var M=typeof p=="number"?p:this.getLayerId(p);return M in this._layers},clearLayers:function(){return this.eachLayer(this.removeLayer,this)},invoke:function(p){var M=Array.prototype.slice.call(arguments,1),Y,ue;for(Y in this._layers)ue=this._layers[Y],ue[p]&&ue[p].apply(ue,M);return this},onAdd:function(p){this.eachLayer(p.addLayer,p)},onRemove:function(p){this.eachLayer(p.removeLayer,p)},eachLayer:function(p,M){for(var Y in this._layers)p.call(M,this._layers[Y]);return this},getLayer:function(p){return this._layers[p]},getLayers:function(){var p=[];return this.eachLayer(p.push,p),p},setZIndex:function(p){return this.invoke("setZIndex",p)},getLayerId:function(p){return _(p)}}),zl=function(p,M){return new Dr(p,M)},qe=Dr.extend({addLayer:function(p){return this.hasLayer(p)?this:(p.addEventParent(this),Dr.prototype.addLayer.call(this,p),this.fire("layeradd",{layer:p}))},removeLayer:function(p){return this.hasLayer(p)?(p in this._layers&&(p=this._layers[p]),p.removeEventParent(this),Dr.prototype.removeLayer.call(this,p),this.fire("layerremove",{layer:p})):this},setStyle:function(p){return this.invoke("setStyle",p)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var p=new Ze;for(var M in this._layers){var Y=this._layers[M];p.extend(Y.getBounds?Y.getBounds():Y.getLatLng())}return p}}),Xt=function(p,M){return new qe(p,M)},js=ce.extend({options:{popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1},initialize:function(p){I(this,p)},createIcon:function(p){return this._createIcon("icon",p)},createShadow:function(p){return this._createIcon("shadow",p)},_createIcon:function(p,M){var Y=this._getIconUrl(p);if(!Y){if(p==="icon")throw new Error("iconUrl not set in Icon options (see the docs).");return null}var ue=this._createImg(Y,M&&M.tagName==="IMG"?M:null);return this._setIconStyles(ue,p),(this.options.crossOrigin||this.options.crossOrigin==="")&&(ue.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),ue},_setIconStyles:function(p,M){var Y=this.options,ue=Y[M+"Size"];typeof ue=="number"&&(ue=[ue,ue]);var Se=Ee(ue),st=Ee(M==="shadow"&&Y.shadowAnchor||Y.iconAnchor||Se&&Se.divideBy(2,!0));p.className="leaflet-marker-"+M+" "+(Y.className||""),st&&(p.style.marginLeft=-st.x+"px",p.style.marginTop=-st.y+"px"),Se&&(p.style.width=Se.x+"px",p.style.height=Se.y+"px")},_createImg:function(p,M){return M=M||document.createElement("img"),M.src=p,M}
vendor: 10,983 bytes, line 755
755,_getIconUrl:function(p){return is.retina&&this.options[p+"RetinaUrl"]||this.options[p+"Url"]}});function Rs(p){return new js(p)}var la=js.extend({options:{iconUrl:"marker-icon.png",iconRetinaUrl:"marker-icon-2x.png",shadowUrl:"marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]},_getIconUrl:function(p){return typeof la.imagePath!="string"&&(la.imagePath=this._detectIconPath()),(this.options.imagePath||la.imagePath)+js.prototype._getIconUrl.call(this,p)},_stripUrl:function(p){var M=function(Y,ue,Se){var st=ue.exec(Y);return st&&st[Se]};return p=M(p,/^url\((['"])?(.+)\1\)$/,2),p&&M(p,/^(.*)marker-icon\.png$/,1)},_detectIconPath:function(){var p=Mn("div","leaflet-default-icon-path",document.body),M=qa(p,"background-image")||qa(p,"backgroundImage");if(document.body.removeChild(p),M=this._stripUrl(M),M)return M;var Y=document.querySelector('link[href$="leaflet.css"]');return Y?Y.href.substring(0,Y.href.length-11-1):""}}),Bn=Ri.extend({initialize:function(p){this._marker=p},addHooks:function(){var p=this._marker._icon;this._draggable||(this._draggable=new Rl(p,p,!0)),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),Gn(p,"leaflet-marker-draggable")},removeHooks:function(){this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon&&sa(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_adjustPan:function(p){var M=this._marker,Y=M._map,ue=this._marker.options.autoPanSpeed,Se=this._marker.options.autoPanPadding,st=rn(M._icon),At=Y.getPixelBounds(),hs=Y.getPixelOrigin(),ws=we(At.min._subtract(hs).add(Se),At.max._subtract(hs).subtract(Se));if(!ws.contains(st)){var Os=Ee((Math.max(ws.max.x,st.x)-ws.max.x)/(At.max.x-ws.max.x)-(Math.min(ws.min.x,st.x)-ws.min.x)/(At.min.x-ws.min.x),(Math.max(ws.max.y,st.y)-ws.max.y)/(At.max.y-ws.max.y)-(Math.min(ws.min.y,st.y)-ws.min.y)/(At.min.y-ws.min.y)).multiplyBy(ue);Y.panBy(Os,{animate:!1}),this._draggable._newPos._add(Os),this._draggable._startPos._add(Os),Xr(M._icon,this._draggable._newPos),this._onDrag(p),this._panRequest=Q(this._adjustPan.bind(this,p))}},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup&&this._marker.closePopup(),this._marker.fire("movestart").fire("dragstart")},_onPreDrag:function(p){this._marker.options.autoPan&&(Z(this._panRequest),this._panRequest=Q(this._adjustPan.bind(this,p)))},_onDrag:function(p){var M=this._marker,Y=M._shadow,ue=rn(M._icon),Se=M._map.layerPointToLatLng(ue);Y&&Xr(Y,ue),M._latlng=Se,p.latlng=Se,p.oldLatLng=this._oldLatLng,M.fire("move",p).fire("drag",p)},_onDragEnd:function(p){Z(this._panRequest),delete this._oldLatLng,this._marker.fire("moveend").fire("dragend",p)}}),Rr=fr.extend({options:{icon:new la,interactive:!0,keyboard:!0,title:"",alt:"Marker",zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:"markerPane",shadowPane:"shadowPane",bubblingMouseEvents:!1,autoPanOnFocus:!0,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10},initialize:function(p,M){I(this,M),this._latlng=Ke(p)},onAdd:function(p){this._zoomAnimated=this._zoomAnimated&&p.options.markerZoomAnimation,this._zoomAnimated&&p.on("zoomanim",this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(p){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&p.off("zoomanim",this._animateZoom,this),this._removeIcon(),this._removeShadow()},getEvents:function(){return{zoom:this.update,viewreset:this.update}},getLatLng:function(){return this._latlng},setLatLng:function(p){var M=this._latlng;return this._latlng=Ke(p),this.update(),this.fire("move",{oldLatLng:M,latlng:this._latlng})},setZIndexOffset:function(p){return this.options.zIndexOffset=p,this.update()},getIcon:function(){return this.options.icon},setIcon:function(p){return this.options.icon=p,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this},getElement:function(){return this._icon},update:function(){if(this._icon&&this._map){var p=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(p)}return this},_initIcon:function(){var p=this.options,M="leaflet-zoom-"+(this._zoomAnimated?"animated":"hide"),Y=p.icon.createIcon(this._icon),ue=!1;Y!==this._icon&&(this._icon&&this._removeIcon(),ue=!0,p.title&&(Y.title=p.title),Y.tagName==="IMG"&&(Y.alt=p.alt||"")),Gn(Y,M),p.keyboard&&(Y.tabIndex="0",Y.setAttribute("role","button")),this._icon=Y,p.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&fn(Y,"focus",this._panOnFocus,this);var Se=p.icon.createShadow(this._shadow),st=!1;Se!==this._shadow&&(this._removeShadow(),st=!0),Se&&(Gn(Se,M),Se.alt=""),this._shadow=Se,p.opacity<1&&this._updateOpacity(),ue&&this.getPane().appendChild(this._icon),this._initInteraction(),Se&&st&&this.getPane(p.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&nr(this._icon,"focus",this._panOnFocus,this),_r(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&_r(this._shadow),this._shadow=null},_setPos:function(p){this._icon&&Xr(this._icon,p),this._shadow&&Xr(this._shadow,p),this._zIndex=p.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(p){this._icon&&(this._icon.style.zIndex=this._zIndex+p)},_animateZoom:function(p){var M=this._map._latLngToNewLayerPoint(this._latlng,p.zoom,p.center).round();this._setPos(M)},_initInteraction:function(){if(this.options.interactive&&(Gn(this._icon,"leaflet-interactive"),this.addInteractiveTarget(this._icon),Bn)){var p=this.options.draggable;this.dragging&&(p=this.dragging.enabled(),this.dragging.disable()),this.dragging=new Bn(this),p&&this.dragging.enable()}},setOpacity:function(p){return this.options.opacity=p,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var p=this.options.opacity;this._icon&&Tr(this._icon,p),this._shadow&&Tr(this._shadow,p)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_panOnFocus:function(){var p=this._map;if(p){var M=this.options.icon.options,Y=M.iconSize?Ee(M.iconSize):Ee(0,0),ue=M.iconAnchor?Ee(M.iconAnchor):Ee(0,0);p.panInside(this._latlng,{paddingTopLeft:ue,paddingBottomRight:Y.subtract(ue)})}},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}});function Mc(p,M){return new Rr(p,M)}var Uo=fr.extend({options:{stroke:!0,color:"#3388ff",weight:3,opacity:1,lineCap:"round",lineJoin:"round",dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:"evenodd",interactive:!0,bubblingMouseEvents:!0},beforeAdd:function(p){this._renderer=p.getRenderer(this)},onAdd:function(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)},onRemove:function(){this._renderer._removePath(this)},redraw:function(){return this._map&&this._renderer._updatePath(this),this},setStyle:function(p){return I(this,p),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&p&&Object.prototype.hasOwnProperty.call(p,"weight")&&this._updateBounds()),this},bringToFront:function(){return this._renderer&&this._renderer._bringToFront(this),this},bringToBack:function(){return this._renderer&&this._renderer._bringToBack(this),this},getElement:function(){return this._path},_reset:function(){this._project(),this._update()},_clickTolerance:function(){return(this.options.stroke?this.options.weight/2:0)+(this._renderer.options.tolerance||0)}}),el=Uo.extend({options:{fill:!0,radius:10},initialize:function(p,M){I(this,M),this._latlng=Ke(p),this._radius=this.options.radius},setLatLng:function(p){var M=this._latlng;return this._latlng=Ke(p),this.redraw(),this.fire("move",{oldLatLng:M,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(p){return this.options.radius=this._radius=p,this.redraw()},getRadius:function(){return this._radius},setStyle:function(p){var M=p&&p.radius||this._radius;return Uo.prototype.setStyle.call(this,p),this.setRadius(M),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var p=this._radius,M=this._radiusY||p,Y=this._clickTolerance(),ue=[p+Y,M+Y];this._pxBounds=new ve(this._point.subtract(ue),this._point.add(ue))},_update:function(){this._map&&this._updatePath()},_updatePath:function(){this._renderer._updateCircle(this)},_empty:function(){return this._radius&&!this._renderer._bounds.intersects(this._pxBounds)},_containsPoint:function(p){return p.distanceTo(this._point)<=this._radius+this._clickTolerance()}});function Oo(p,M){return new el(p,M)}var yo=el.extend({initialize:function(p,M,Y){if(typeof M=="number"&&(M=l({},Y,{radius:M})),I(this,M),this._latlng=Ke(p),isNaN(this.options.radius))throw new Error("Circle radius cannot be NaN");this._mRadius=this.options.radius},setRadius:function(p){return this._mRadius=p,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var p=[this._radius,this._radiusY||this._radius];return new Ze(this._map.layerPointToLatLng(this._point.subtract(p)),this._map.layerPointToLatLng(this._point.add(p)))},setStyle:Uo.prototype.setStyle,_project:function(){var p=this._latlng.lng,M=this._latlng.lat,Y=this._map,ue=Y.options.crs;if(ue.distance===Re.distance){var Se=Math.PI/180,st=this._mRadius/Re.R/Se,At=Y.project([M+st,p]),hs=Y.project([M-st,p]),ws=At.add(hs).divideBy(2),Os=Y.unproject(ws).lat,_n=Math.acos((Math.cos(st*Se)-Math.sin(M*Se)*Math.sin(Os*Se))/(Math.cos(M*Se)*Math.cos(Os*Se)))/Se;(isNaN(_n)||_n===0)&&(_n=st/Math.cos(Math.PI/180*M)),this._point=ws.subtract(Y.getPixelOrigin()),this._radius=isNaN(_n)?0:ws.x-Y.project([Os,p-_n]).x,this._radiusY=ws.y-At.y}else{var Ta=ue.unproject(ue.project(this._latlng).subtract([this._mRadius,0]));this._point=Y.latLngToLayerPoint(this._latlng),this._radius=this._point.x-Y.latLngToLayerPoint(Ta).x}this._updateBounds()}});function gl(p,M,Y){return new yo(p,M,Y)}var ci=Uo.extend({options:{smoothFactor:1,noClip:!1},initialize:function(p,M){I(this,M),this._setLatLngs(p)},getLatLngs:function(){return this._latlngs},setLatLngs:function(p){return this._setLatLngs(p),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(p){for(var M=1/0,Y=null,ue=Wl,Se,st,At=0,hs=this._parts.length;At<hs;At++)for(var ws=this._parts[At],Os=1,_n=ws.length;Os<_n;Os++){Se=ws[Os-1],st=ws[Os];var Ta=ue(p,Se,st,!0);Ta<M&&(M=Ta,Y=ue(p,Se,st))}return Y&&(Y.distance=Math.sqrt(M)),Y}
755,getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return Xl(this._defaultShape(),this._map.options.crs)},getBounds:function(){return this._bounds},addLatLng:function(p,M){return M=M||this._defaultShape(),p=Ke(p),M.push(p),this._bounds.extend(p),this.redraw()},_setLatLngs:function(p){this._bounds=new Ze,this._latlngs=this._convertLatLngs(p)},_defaultShape:function(){return _o(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(p){for(var M=[],Y=_o(p),ue=0,Se=p.length;ue<Se;ue++)Y?(M[ue]=Ke(p[ue]),this._bounds.extend(M[ue])):M[ue]=this._convertLatLngs(p[ue]);return M},_project:function(){var p=new ve;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,p),this._bounds.isValid()&&p.isValid()&&(this._rawPxBounds=p,this._updateBounds())},_updateBounds:function(){var p=this._clickTolerance(),M=new ge(p,p);this._rawPxBounds&&(this._pxBounds=new ve([this._rawPxBounds.min.subtract(M),this._rawPxBounds.max.add(M)]))},_projectLatlngs:function(p,M,Y){var ue=p[0]instanceof ze,Se=p.length,st,At;if(ue){for(At=[],st=0;st<Se;st++)At[st]=this._map.latLngToLayerPoint(p[st]),Y.extend(At[st]);M.push(At)}else for(st=0;st<Se;st++)this._projectLatlngs(p[st],M,Y)},_clipPoints:function(){var p=this._renderer._bounds;if(this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(p))){if(this.options.noClip){this._parts=this._rings;return}var M=this._parts,Y,ue,Se,st,At,hs,ws;for(Y=0,Se=0,st=this._rings.length;Y<st;Y++)for(ws=this._rings[Y],ue=0,At=ws.length;ue<At-1;ue++)hs=Hi(ws[ue],ws[ue+1],p,ue,!0),hs&&(M[Se]=M[Se]||[],M[Se].push(hs[0]),(hs[1]!==ws[ue+1]||ue===At-2)&&(M[Se].push(hs[1]),Se++))}},_simplifyPoints:function(){for(var p=this._parts,M=this.options.smoothFactor,Y=0,ue=p.length;Y<ue;Y++)p[Y]=hi(p[Y],M)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)},_containsPoint:function(p,M){var Y,ue,Se,st,At,hs,ws=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(p))return!1;for(Y=0,st=this._parts.length;Y<st;Y++)for(hs=this._parts[Y],ue=0,At=hs.length,Se=At-1;ue<At;Se=ue++)if(!(!M&&ue===0)&&Jd(p,hs[Se],hs[ue])<=ws)return!0;return!1}});function Eo(p,M){return new ci(p,M)}ci._flat=Yl;var tl=ci.extend({options:{fill:!0},isEmpty:function(){return!this._latlngs.length||!this._latlngs[0].length}
755,getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return fl(this._defaultShape(),this._map.options.crs)},_convertLatLngs:function(p){var M=ci.prototype._convertLatLngs.call(this,p),Y=M.length;return Y>=2&&M[0]instanceof ze&&M[0].equals(M[Y-1])&&M.pop(),M},_setLatLngs:function(p){ci.prototype._setLatLngs.call(this,p),_o(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return _o(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var p=this._renderer._bounds,M=this.options.weight,Y=new ge(M,M);if(p=new ve(p.min.subtract(Y),p.max.add(Y)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(p))){if(this.options.noClip){this._parts=this._rings;return}for(var ue=0,Se=this._rings.length,st;ue<Se;ue++)st=Md(this._rings[ue],p,!0),st.length&&this._parts.push(st)}},_updatePath:function(){this._renderer._updatePoly(this,!0)},_containsPoint:function(p){var M=!1,Y,ue,Se,st,At,hs,ws,Os;if(!this._pxBounds||!this._pxBounds.contains(p))return!1;for(st=0,ws=this._parts.length;st<ws;st++)for(Y=this._parts[st],At=0,Os=Y.length,hs=Os-1;At<Os;hs=At++)ue=Y[At],Se=Y[hs],ue.y>p.y!=Se.y>p.y&&p.x<(Se.x-ue.x)*(p.y-ue.y)/(Se.y-ue.y)+ue.x&&(M=!M);return M||ci.prototype._containsPoint.call(this,p,!0)}});function xl(p,M){return new tl(p,M)}var Bo=qe.extend({initialize:function(p,M){I(this,M),this._layers={},p&&this.addData(p)},addData:function(p){var M=X(p)?p:p.features,Y,ue,Se;if(M){for(Y=0,ue=M.length;Y<ue;Y++)Se=M[Y],(Se.geometries||Se.geometry||Se.features||Se.coordinates)&&this.addData(Se);return this}var st=this.options;if(st.filter&&!st.filter(p))return this;var At=Jc(p,st);return At?(At.feature=N(p),At.defaultOptions=At.options,this.resetStyle(At),st.onEachFeature&&st.onEachFeature(p,At),this.addLayer(At)):this},resetStyle:function(p){return p===void 0?this.eachLayer(this.resetStyle,this):(p.options=l({},p.defaultOptions),this._setLayerStyle(p,this.options.style),this)},setStyle:function(p){return this.eachLayer(function(M){this._setLayerStyle(M,p)},this)},_setLayerStyle:function(p,M){p.setStyle&&(typeof M=="function"&&(M=M(p.feature)),p.setStyle(M))}});function Jc(p,M){var Y=p.type==="Feature"?p.geometry:p,ue=Y?Y.coordinates:null,Se=[],st=M&&M.pointToLayer,At=M&&M.coordsToLatLng||Ic,hs,ws,Os,_n;if(!ue&&!Y)return null;switch(Y.type){case"Point":return hs=At(ue),Cr(st,p,hs,M);case"MultiPoint":for(Os=0,_n=ue.length;Os<_n;Os++)hs=At(ue[Os]),Se.push(Cr(st,p,hs,M));return new qe(Se);case"LineString":case"MultiLineString":return ws=yu(ue,Y.type==="LineString"?0:1,At),new ci(ws,M);case"Polygon":case"MultiPolygon":return ws=yu(ue,Y.type==="Polygon"?1:2,At),new tl(ws,M);case"GeometryCollection":for(Os=0,_n=Y.geometries.length;Os<_n;Os++){var Ta=Jc({geometry:Y.geometries[Os],type:"Feature",properties:p.properties},M);Ta&&Se.push(Ta)}return new qe(Se);case"FeatureCollection":for(Os=0,_n=Y.features.length;Os<_n;Os++){var yr=Jc(Y.features[Os],M);yr&&Se.push(yr)}return new qe(Se);default:throw new Error("Invalid GeoJSON object.")}}function Cr(p,M,Y,ue){return p?p(M,Y):new Rr(Y,ue&&ue.markersInheritOptions&&ue)}function Ic(p){return new ze(p[1],p[0],p[2])}function yu(p,M,Y){for(var ue=[],Se=0,st=p.length,At;Se<st;Se++)At=M?yu(p[Se],M-1,Y):(Y||Ic)(p[Se]),ue.push(At);return ue}function Qd(p,M){return p=Ke(p),p.alt!==void 0?[v(p.lng,M),v(p.lat,M),v(p.alt,M)]:[v(p.lng,M),v(p.lat,M)]}function to(p,M,Y,ue){for(var Se=[],st=0,At=p.length;st<At;st++)Se.push(M?to(p[st],_o(p[st])?0:M-1,Y,ue):Qd(p[st],ue));return!M&&Y&&Se.length>0&&Se.push(Se[0].slice()),Se}function $o(p,M){return p.feature?l({},p.feature,{geometry:M}):N(M)}function N(p){return p.type==="Feature"||p.type==="FeatureCollection"?p:{type:"Feature",properties:{},geometry:p}}var h={toGeoJSON:function(p){return $o(this,{type:"Point",coordinates:Qd(this.getLatLng(),p)})}};Rr.include(h),yo.include(h),el.include(h),ci.include({toGeoJSON:function(p){var M=!_o(this._latlngs),Y=to(this._latlngs,M?1:0,!1,p);return $o(this,{type:(M?"Multi":"")+"LineString",coordinates:Y})}}),tl.include({toGeoJSON:function(p){var M=!_o(this._latlngs),Y=M&&!_o(this._latlngs[0]),ue=to(this._latlngs,Y?2:M?1:0,!0,p);return M||(ue=[ue]),$o(this,{type:(Y?"Multi":"")+"Polygon",coordinates:ue})}}),Dr.include({toMultiPoint:function(p){var M=[];return this.eachLayer(function(Y){M.push(Y.toGeoJSON(p).geometry.coordinates)}),$o(this,{type:"MultiPoint",coordinates:M})},toGeoJSON:function(p){var M=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(M==="MultiPoint")return this.toMultiPoint(p);var Y=M==="GeometryCollection",ue=[];return this.eachLayer(function(Se){if(Se.toGeoJSON){var st=Se.toGeoJSON(p);if(Y)ue.push(st.geometry);else{var At=N(st);At.type==="FeatureCollection"?ue.push.apply(ue,At.features):ue.push(At)}}}),Y?$o(this,{geometries:ue,type:"GeometryCollection"}):{type:"FeatureCollection",features:ue}}});function f(p,M){return new Bo(p,M)}var w=f,G=fr.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""}
755,initialize:function(p,M,Y){this._url=p,this._bounds=ke(M),I(this,Y)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(Gn(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){_r(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(p){return this.options.opacity=p,this._image&&this._updateOpacity(),this},setStyle:function(p){return p.opacity&&this.setOpacity(p.opacity),this},bringToFront:function(){return this._map&&Zs(this._image),this},bringToBack:function(){return this._map&&Cn(this._image),this},setUrl:function(p){return this._url=p,this._image&&(this._image.src=p),this},setBounds:function(p){return this._bounds=ke(p),this._map&&this._reset(),this},getEvents:function(){var p={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(p.zoomanim=this._animateZoom),p},setZIndex:function(p){return this.options.zIndex=p,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var p=this._url.tagName==="IMG",M=this._image=p?this._url:Mn("img");if(Gn(M,"leaflet-image-layer"),this._zoomAnimated&&Gn(M,"leaflet-zoom-animated"),this.options.className&&Gn(M,this.options.className),M.onselectstart=x,M.onmousemove=x,M.onload=u(this.fire,this,"load"),M.onerror=u(this._overlayOnError,this,"error"),(this.options.crossOrigin||this.options.crossOrigin==="")&&(M.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),p){this._url=M.src;return}M.src=this._url,M.alt=this.options.alt},_animateZoom:function(p){var M=this._map.getZoomScale(p.zoom),Y=this._map._latLngBoundsToNewLayerBounds(this._bounds,p.zoom,p.center).min;Gr(this._image,Y,M)},_reset:function(){var p=this._image,M=new ve(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),Y=M.getSize();Xr(p,M.min),p.style.width=Y.x+"px",p.style.height=Y.y+"px"},_updateOpacity:function(){Tr(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var p=this.options.errorOverlayUrl;p&&this._url!==p&&(this._url=p,this._image.src=p)},getCenter:function(){return this._bounds.getCenter()}}),re=function(p,M,Y){return new G(p,M,Y)},xe=G.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var p=this._url.tagName==="VIDEO",M=this._image=p?this._url:Mn("video");if(Gn(M,"leaflet-image-layer"),this._zoomAnimated&&Gn(M,"leaflet-zoom-animated"),this.options.className&&Gn(M,this.options.className),M.onselectstart=x,M.onmousemove=x,M.onloadeddata=u(this.fire,this,"load"),p){for(var Y=M.getElementsByTagName("source"),ue=[],Se=0;Se<Y.length;Se++)ue.push(Y[Se].src);this._url=Y.length>0?ue:[M.src];return}X(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(M.style,"objectFit")&&(M.style.objectFit="fill"),M.autoplay=!!this.options.autoplay,M.loop=!!this.options.loop,M.muted=!!this.options.muted,M.playsInline=!!this.options.playsInline;for(var st=0;st<this._url.length;st++){var At=Mn("source");At.src=this._url[st],M.appendChild(At)}}});function Ae(p,M,Y){return new xe(p,M,Y)}var tt=G.extend({_initImage:function(){var p=this._image=this._url;Gn(p,"leaflet-image-layer"),this._zoomAnimated&&Gn(p,"leaflet-zoom-animated"),this.options.className&&Gn(p,this.options.className),p.onselectstart=x,p.onmousemove=x}});function Nt(p,M,Y){return new tt(p,M,Y)}var Ut=fr.extend({options:{interactive:!1,offset:[0,0],className:"",pane:void 0,content:""},initialize:function(p,M){p&&(p instanceof ze||X(p))?(this._latlng=Ke(p),I(this,M)):(I(this,p),this._source=M),this.options.content&&(this._content=this.options.content)},openOn:function(p){return p=arguments.length?p:this._source._map,p.hasLayer(this)||p.addLayer(this),this},close:function(){return this._map&&this._map.removeLayer(this),this},toggle:function(p){return this._map?this.close():(arguments.length?this._source=p:p=this._source,this._prepareOpen(),this.openOn(p._map)),this},onAdd:function(p){this._zoomAnimated=p._zoomAnimated,this._container||this._initLayout(),p._fadeAnimated&&Tr(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),p._fadeAnimated&&Tr(this._container,1),this.bringToFront(),this.options.interactive&&(Gn(this._container,"leaflet-interactive"),this.addInteractiveTarget(this._container))},onRemove:function(p){p._fadeAnimated?(Tr(this._container,0),this._removeTimeout=setTimeout(u(_r,void 0,this._container),200)):_r(this._container),this.options.interactive&&(sa(this._container,"leaflet-interactive"),this.removeInteractiveTarget(this._container))},getLatLng:function(){return this._latlng},setLatLng:function(p){return this._latlng=Ke(p),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(p){return this._content=p,this.update(),this},getElement:function(){return this._container},update:function(){this._map&&(this._container.style.visibility="hidden",this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility="",this._adjustPan())},getEvents:function(){var p={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(p.zoomanim=this._animateZoom),p},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&Zs(this._container),this},bringToBack:function(){return this._map&&Cn(this._container),this},_prepareOpen:function(p){var M=this._source;if(!M._map)return!1;if(M instanceof qe){M=null;var Y=this._source._layers;for(var ue in Y)if(Y[ue]._map){M=Y[ue];break}if(!M)return!1;this._source=M}if(!p)if(M.getCenter)p=M.getCenter();else if(M.getLatLng)p=M.getLatLng();else if(M.getBounds)p=M.getBounds().getCenter();else throw new Error("Unable to get source layer LatLng.");return this.setLatLng(p),this._map&&this.update(),!0},_updateContent:function(){if(this._content){var p=this._contentNode,M=typeof this._content=="function"?this._content(this._source||this):this._content;
vendor: 5,165 bytes, line 755
755if(typeof M=="string")p.innerHTML=M;else{for(;p.hasChildNodes();)p.removeChild(p.firstChild);p.appendChild(M)}this.fire("contentupdate")}},_updatePosition:function(){if(this._map){var p=this._map.latLngToLayerPoint(this._latlng),M=Ee(this.options.offset),Y=this._getAnchor();this._zoomAnimated?Xr(this._container,p.add(Y)):M=M.add(p).add(Y);var ue=this._containerBottom=-M.y,Se=this._containerLeft=-Math.round(this._containerWidth/2)+M.x;this._container.style.bottom=ue+"px",this._container.style.left=Se+"px"}},_getAnchor:function(){return[0,0]}});Sn.include({_initOverlay:function(p,M,Y,ue){var Se=M;return Se instanceof p||(Se=new p(ue).setContent(M)),Y&&Se.setLatLng(Y),Se}}),fr.include({_initOverlay:function(p,M,Y,ue){var Se=Y;return Se instanceof p?(I(Se,ue),Se._source=this):(Se=M&&!ue?M:new p(ue,this),Se.setContent(Y)),Se}});var xs=Ut.extend({options:{pane:"popupPane",offset:[0,7],maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:""},openOn:function(p){return p=arguments.length?p:this._source._map,!p.hasLayer(this)&&p._popup&&p._popup.options.autoClose&&p.removeLayer(p._popup),p._popup=this,Ut.prototype.openOn.call(this,p)},onAdd:function(p){Ut.prototype.onAdd.call(this,p),p.fire("popupopen",{popup:this}),this._source&&(this._source.fire("popupopen",{popup:this},!0),this._source instanceof Uo||this._source.on("preclick",Xi))},onRemove:function(p){Ut.prototype.onRemove.call(this,p),p.fire("popupclose",{popup:this}),this._source&&(this._source.fire("popupclose",{popup:this},!0),this._source instanceof Uo||this._source.off("preclick",Xi))},getEvents:function(){var p=Ut.prototype.getEvents.call(this);return(this.options.closeOnClick!==void 0?this.options.closeOnClick:this._map.options.closePopupOnClick)&&(p.preclick=this.close),this.options.keepInView&&(p.moveend=this._adjustPan),p},_initLayout:function(){var p="leaflet-popup",M=this._container=Mn("div",p+" "+(this.options.className||"")+" leaflet-zoom-animated"),Y=this._wrapper=Mn("div",p+"-content-wrapper",M);if(this._contentNode=Mn("div",p+"-content",Y),Co(M),ml(this._contentNode),fn(M,"contextmenu",Xi),this._tipContainer=Mn("div",p+"-tip-container",M),this._tip=Mn("div",p+"-tip",this._tipContainer),this.options.closeButton){var ue=this._closeButton=Mn("a",p+"-close-button",M);ue.setAttribute("role","button"),ue.setAttribute("aria-label","Close popup"),ue.href="#close",ue.innerHTML='<span aria-hidden="true">&#215;</span>',fn(ue,"click",function(Se){ti(Se),this.close()},this)}},_updateLayout:function(){var p=this._contentNode,M=p.style;M.width="",M.whiteSpace="nowrap";var Y=p.offsetWidth;Y=Math.min(Y,this.options.maxWidth),Y=Math.max(Y,this.options.minWidth),M.width=Y+1+"px",M.whiteSpace="",M.height="";var ue=p.offsetHeight,Se=this.options.maxHeight,st="leaflet-popup-scrolled";Se&&ue>Se?(M.height=Se+"px",Gn(p,st)):sa(p,st),this._containerWidth=this._container.offsetWidth},_animateZoom:function(p){var M=this._map._latLngToNewLayerPoint(this._latlng,p.zoom,p.center),Y=this._getAnchor();Xr(this._container,M.add(Y))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning){this._autopanning=!1;return}var p=this._map,M=parseInt(qa(this._container,"marginBottom"),10)||0,Y=this._container.offsetHeight+M,ue=this._containerWidth,Se=new ge(this._containerLeft,-Y-this._containerBottom);Se._add(rn(this._container));var st=p.layerPointToContainerPoint(Se),At=Ee(this.options.autoPanPadding),hs=Ee(this.options.autoPanPaddingTopLeft||At),ws=Ee(this.options.autoPanPaddingBottomRight||At),Os=p.getSize(),_n=0,Ta=0;st.x+ue+ws.x>Os.x&&(_n=st.x+ue-Os.x+ws.x),st.x-_n-hs.x<0&&(_n=st.x-hs.x),st.y+Y+ws.y>Os.y&&(Ta=st.y+Y-Os.y+ws.y),st.y-Ta-hs.y<0&&(Ta=st.y-hs.y),(_n||Ta)&&(this.options.keepInView&&(this._autopanning=!0),p.fire("autopanstart").panBy([_n,Ta]))}},_getAnchor:function(){return Ee(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),$s=function(p,M){return new xs(p,M)};Sn.mergeOptions({closePopupOnClick:!0}),Sn.include({openPopup:function(p,M,Y){return this._initOverlay(xs,p,M,Y).openOn(this),this},closePopup:function(p){return p=arguments.length?p:this._popup,p&&p.close(),this}}),fr.include({bindPopup:function(p,M){return this._popup=this._initOverlay(xs,this._popup,p,M),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(p){return this._popup&&(this instanceof qe||(this._popup._source=this),this._popup._prepareOpen(p||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1}
755,setPopupContent:function(p){return this._popup&&this._popup.setContent(p),this},getPopup:function(){return this._popup},_openPopup:function(p){if(!(!this._popup||!this._map)){qs(p);var M=p.layer||p.target;if(this._popup._source===M&&!(M instanceof Uo)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(p.latlng);return}this._popup._source=M,this.openPopup(p.latlng)}},_movePopup:function(p){this._popup.setLatLng(p.latlng)},_onKeyPress:function(p){p.originalEvent.keyCode===13&&this._openPopup(p)}});var bn=Ut.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(p){Ut.prototype.onAdd.call(this,p),this.setOpacity(this.options.opacity),p.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(p){Ut.prototype.onRemove.call(this,p),p.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var p=Ut.prototype.getEvents.call(this);return this.options.permanent||(p.preclick=this.close),p},_initLayout:function(){var p="leaflet-tooltip",M=p+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=Mn("div",M),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+_(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(p){var M,Y,ue=this._map,Se=this._container,st=ue.latLngToContainerPoint(ue.getCenter()),At=ue.layerPointToContainerPoint(p),hs=this.options.direction,ws=Se.offsetWidth,Os=Se.offsetHeight,_n=Ee(this.options.offset),Ta=this._getAnchor();hs==="top"?(M=ws/2,Y=Os):hs==="bottom"?(M=ws/2,Y=0):hs==="center"?(M=ws/2,Y=Os/2):hs==="right"?(M=0,Y=Os/2):hs==="left"?(M=ws,Y=Os/2):At.x<st.x?(hs="right",M=0,Y=Os/2):(hs="left",M=ws+(_n.x+Ta.x)*2,Y=Os/2),p=p.subtract(Ee(M,Y,!0)).add(_n).add(Ta),sa(Se,"leaflet-tooltip-right"),sa(Se,"leaflet-tooltip-left"),sa(Se,"leaflet-tooltip-top"),sa(Se,"leaflet-tooltip-bottom"),Gn(Se,"leaflet-tooltip-"+hs),Xr(Se,p)},_updatePosition:function(){var p=this._map.latLngToLayerPoint(this._latlng);this._setPosition(p)},setOpacity:function(p){this.options.opacity=p,this._container&&Tr(this._container,p)},_animateZoom:function(p){var M=this._map._latLngToNewLayerPoint(this._latlng,p.zoom,p.center);this._setPosition(M)},_getAnchor:function(){return Ee(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}}),da=function(p,M){return new bn(p,M)};Sn.include({openTooltip:function(p,M,Y){return this._initOverlay(bn,p,M,Y).openOn(this),this},closeTooltip:function(p){return p.close(),this}}),fr.include({bindTooltip:function(p,M){return this._tooltip&&this.isTooltipOpen()&&this.unbindTooltip(),this._tooltip=this._initOverlay(bn,this._tooltip,p,M),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip:function(){return this._tooltip&&(this._initTooltipInteractions(!0),this.closeTooltip(),this._tooltip=null),this},_initTooltipInteractions:function(p){if(!(!p&&this._tooltipHandlersAdded)){var M=p?"off":"on",Y={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?Y.add=this._openTooltip:(Y.mouseover=this._openTooltip,Y.mouseout=this.closeTooltip,Y.click=this._openTooltip,this._map?this._addFocusListeners():Y.add=this._addFocusListeners),this._tooltip.options.sticky&&(Y.mousemove=this._moveTooltip),this[M](Y),this._tooltipHandlersAdded=!p}},openTooltip:function(p){return this._tooltip&&(this instanceof qe||(this._tooltip._source=this),this._tooltip._prepareOpen(p)&&(this._tooltip.openOn(this._map),this.getElement?this._setAriaDescribedByOnLayer(this):this.eachLayer&&this.eachLayer(this._setAriaDescribedByOnLayer,this))),this},closeTooltip:function(){if(this._tooltip)return this._tooltip.close()},toggleTooltip:function(){return this._tooltip&&this._tooltip.toggle(this),this},isTooltipOpen:function(){return this._tooltip.isOpen()},setTooltipContent:function(p){return this._tooltip&&this._tooltip.setContent(p),this},getTooltip:function(){return this._tooltip},_addFocusListeners:function(){this.getElement?this._addFocusListenersOnLayer(this):this.eachLayer&&this.eachLayer(this._addFocusListenersOnLayer,this)},_addFocusListenersOnLayer:function(p){var M=typeof p.getElement=="function"&&p.getElement();M&&(fn(M,"focus",function(){this._tooltip._source=p,this.openTooltip()},this),fn(M,"blur",this.closeTooltip,this))},_setAriaDescribedByOnLayer:function(p){var M=typeof p.getElement=="function"&&p.getElement();M&&M.setAttribute("aria-describedby",this._tooltip._container.id)},_openTooltip:function(p){if(!(!this._tooltip||!this._map)){if(this._map.dragging&&this._map.dragging.moving()&&!this._openOnceFlag){this._openOnceFlag=!0;var M=this;this._map.once("moveend",function(){M._openOnceFlag=!1,M._openTooltip(p)});return}this._tooltip._source=p.layer||p.target,this.openTooltip(this._tooltip.options.sticky?p.latlng:void 0)}},_moveTooltip:function(p){var M=p.latlng,Y,ue;this._tooltip.options.sticky&&p.originalEvent&&(Y=this._map.mouseEventToContainerPoint(p.originalEvent),ue=this._map.containerPointToLayerPoint(Y),M=this._map.layerPointToLatLng(ue)),this._tooltip.setLatLng(M)}});var wa=js.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:"leaflet-div-icon"},createIcon:function(p){var M=p&&p.tagName==="DIV"?p:document.createElement("div"),Y=this.options;if(Y.html instanceof Element?(Ar(M),M.appendChild(Y.html)):M.innerHTML=Y.html!==!1?Y.html:"",Y.bgPos){var ue=Ee(Y.bgPos);M.style.backgroundPosition=-ue.x+"px "+-ue.y+"px"}return this._setIconStyles(M,"icon"),M},createShadow:function(){return null}});
755function Lr(p){return new wa(p)}js.Default=la;var ur=fr.extend({options:{tileSize:256,opacity:1,updateWhenIdle:is.mobile,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:"tilePane",className:"",keepBuffer:2},initialize:function(p){I(this,p)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView()},beforeAdd:function(p){p._addZoomLimit(this)},onRemove:function(p){this._removeAllTiles(),_r(this._container),p._removeZoomLimit(this),this._container=null,this._tileZoom=void 0},bringToFront:function(){return this._map&&(Zs(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(Cn(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(p){return this.options.opacity=p,this._updateOpacity(),this},setZIndex:function(p){return this.options.zIndex=p,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){if(this._map){this._removeAllTiles();var p=this._clampZoom(this._map.getZoom());p!==this._tileZoom&&(this._tileZoom=p,this._updateLevels()),this._update()}return this},getEvents:function(){var p={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||(this._onMove=j(this._onMoveEnd,this.options.updateInterval,this)),p.move=this._onMove),this._zoomAnimated&&(p.zoomanim=this._animateZoom),p},createTile:function(){return document.createElement("div")},getTileSize:function(){var p=this.options.tileSize;return p instanceof ge?p:new ge(p,p)},_updateZIndex:function(){this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(p){for(var M=this.getPane().children,Y=-p(-1/0,1/0),ue=0,Se=M.length,st;ue<Se;ue++)st=M[ue].style.zIndex,M[ue]!==this._container&&st&&(Y=p(Y,+st));isFinite(Y)&&(this.options.zIndex=Y+p(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!is.ielt9){Tr(this._container,this.options.opacity);var p=+new Date,M=!1,Y=!1;for(var ue in this._tiles){var Se=this._tiles[ue];if(!(!Se.current||!Se.loaded)){var st=Math.min(1,(p-Se.loaded)/200);Tr(Se.el,st),st<1?M=!0:(Se.active?Y=!0:this._onOpaqueTile(Se),Se.active=!0)}}Y&&!this._noPrune&&this._pruneTiles(),M&&(Z(this._fadeFrame),this._fadeFrame=Q(this._updateOpacity,this))}},_onOpaqueTile:x,_initContainer:function(){this._container||(this._container=Mn("div","leaflet-layer "+(this.options.className||"")),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var p=this._tileZoom,M=this.options.maxZoom;if(p!==void 0){for(var Y in this._levels)Y=Number(Y),this._levels[Y].el.children.length||Y===p?(this._levels[Y].el.style.zIndex=M-Math.abs(p-Y),this._onUpdateLevel(Y)):(_r(this._levels[Y].el),this._removeTilesAtZoom(Y),this._onRemoveLevel(Y),delete this._levels[Y]);var ue=this._levels[p],Se=this._map;return ue||(ue=this._levels[p]={},ue.el=Mn("div","leaflet-tile-container leaflet-zoom-animated",this._container),ue.el.style.zIndex=M,ue.origin=Se.project(Se.unproject(Se.getPixelOrigin()),p).round(),ue.zoom=p,this._setZoomTransform(ue,Se.getCenter(),Se.getZoom()),x(ue.el.offsetWidth),this._onCreateLevel(ue)),this._level=ue,ue}},_onUpdateLevel:x,_onRemoveLevel:x,_onCreateLevel:x,_pruneTiles:function(){if(this._map){var p,M,Y=this._map.getZoom();if(Y>this.options.maxZoom||Y<this.options.minZoom){this._removeAllTiles();return}for(p in this._tiles)M=this._tiles[p],M.retain=M.current;for(p in this._tiles)if(M=this._tiles[p],M.current&&!M.active){var ue=M.coords;this._retainParent(ue.x,ue.y,ue.z,ue.z-5)||this._retainChildren(ue.x,ue.y,ue.z,ue.z+2)}for(p in this._tiles)this._tiles[p].retain||this._removeTile(p)}},_removeTilesAtZoom:function(p){for(var M in this._tiles)this._tiles[M].coords.z===p&&this._removeTile(M)},_removeAllTiles:function(){for(var p in this._tiles)this._removeTile(p)},_invalidateAll:function(){for(var p in this._levels)_r(this._levels[p].el),this._onRemoveLevel(Number(p)),delete this._levels[p];this._removeAllTiles(),this._tileZoom=void 0},_retainParent:function(p,M,Y,ue){var Se=Math.floor(p/2),st=Math.floor(M/2),At=Y-1,hs=new ge(+Se,+st);hs.z=+At;var ws=this._tileCoordsToKey(hs),Os=this._tiles[ws];return Os&&Os.active?(Os.retain=!0,!0):(Os&&Os.loaded&&(Os.retain=!0),At>ue?this._retainParent(Se,st,At,ue):!1)},_retainChildren:function(p,M,Y,ue){for(var Se=2*p;Se<2*p+2;Se++)for(var st=2*M;st<2*M+2;st++){var At=new ge(Se,st);At.z=Y+1;var hs=this._tileCoordsToKey(At),ws=this._tiles[hs];if(ws&&ws.active){ws.retain=!0;continue}else ws&&ws.loaded&&(ws.retain=!0);Y+1<ue&&this._retainChildren(Se,st,Y+1,ue)}},_resetView:function(p){var M=p&&(p.pinch||p.flyTo);
755this._setView(this._map.getCenter(),this._map.getZoom(),M,M)},_animateZoom:function(p){this._setView(p.center,p.zoom,!0,p.noUpdate)},_clampZoom:function(p){var M=this.options;return M.minNativeZoom!==void 0&&p<M.minNativeZoom?M.minNativeZoom:M.maxNativeZoom!==void 0&&M.maxNativeZoom<p?M.maxNativeZoom:p},_setView:function(p,M,Y,ue){var Se=Math.round(M);this.options.maxZoom!==void 0&&Se>this.options.maxZoom||this.options.minZoom!==void 0&&Se<this.options.minZoom?Se=void 0:Se=this._clampZoom(Se);var st=this.options.updateWhenZooming&&Se!==this._tileZoom;(!ue||st)&&(this._tileZoom=Se,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),Se!==void 0&&this._update(p),Y||this._pruneTiles(),this._noPrune=!!Y),this._setZoomTransforms(p,M)},_setZoomTransforms:function(p,M){for(var Y in this._levels)this._setZoomTransform(this._levels[Y],p,M)},_setZoomTransform:function(p,M,Y){var ue=this._map.getZoomScale(Y,p.zoom),Se=p.origin.multiplyBy(ue).subtract(this._map._getNewPixelOrigin(M,Y)).round();is.any3d?Gr(p.el,Se,ue):Xr(p.el,Se)},_resetGrid:function(){var p=this._map,M=p.options.crs,Y=this._tileSize=this.getTileSize(),ue=this._tileZoom,Se=this._map.getPixelWorldBounds(this._tileZoom);Se&&(this._globalTileRange=this._pxBoundsToTileRange(Se)),this._wrapX=M.wrapLng&&!this.options.noWrap&&[Math.floor(p.project([0,M.wrapLng[0]],ue).x/Y.x),Math.ceil(p.project([0,M.wrapLng[1]],ue).x/Y.y)],this._wrapY=M.wrapLat&&!this.options.noWrap&&[Math.floor(p.project([M.wrapLat[0],0],ue).y/Y.x),Math.ceil(p.project([M.wrapLat[1],0],ue).y/Y.y)]},_onMoveEnd:function(){!this._map||this._map._animatingZoom||this._update()},_getTiledPixelBounds:function(p){var M=this._map,Y=M._animatingZoom?Math.max(M._animateToZoom,M.getZoom()):M.getZoom(),ue=M.getZoomScale(Y,this._tileZoom),Se=M.project(p,this._tileZoom).floor(),st=M.getSize().divideBy(ue*2);return new ve(Se.subtract(st),Se.add(st))},_update:function(p){var M=this._map;if(M){var Y=this._clampZoom(M.getZoom());if(p===void 0&&(p=M.getCenter()),this._tileZoom!==void 0){var ue=this._getTiledPixelBounds(p),Se=this._pxBoundsToTileRange(ue),st=Se.getCenter(),At=[],hs=this.options.keepBuffer,ws=new ve(Se.getBottomLeft().subtract([hs,-hs]),Se.getTopRight().add([hs,-hs]));if(!(isFinite(Se.min.x)&&isFinite(Se.min.y)&&isFinite(Se.max.x)&&isFinite(Se.max.y)))throw new Error("Attempted to load an infinite number of tiles");for(var Os in this._tiles){var _n=this._tiles[Os].coords;(_n.z!==this._tileZoom||!ws.contains(new ge(_n.x,_n.y)))&&(this._tiles[Os].current=!1)}if(Math.abs(Y-this._tileZoom)>1){this._setView(p,Y);return}for(var Ta=Se.min.y;Ta<=Se.max.y;Ta++)for(var yr=Se.min.x;yr<=Se.max.x;yr++){var cr=new ge(yr,Ta);if(cr.z=this._tileZoom,!!this._isValidTile(cr)){var bo=this._tiles[this._tileCoordsToKey(cr)];bo?bo.current=!0:At.push(cr)}}if(At.sort(function(jo,$a){return jo.distanceTo(st)-$a.distanceTo(st)}),At.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var zi=document.createDocumentFragment();for(yr=0;yr<At.length;yr++)this._addTile(At[yr],zi);this._level.el.appendChild(zi)}}}},_isValidTile:function(p){var M=this._map.options.crs;if(!M.infinite){var Y=this._globalTileRange;if(!M.wrapLng&&(p.x<Y.min.x||p.x>Y.max.x)||!M.wrapLat&&(p.y<Y.min.y||p.y>Y.max.y))return!1}if(!this.options.bounds)return!0;var ue=this._tileCoordsToBounds(p);return ke(this.options.bounds).overlaps(ue)},_keyToBounds:function(p){return this._tileCoordsToBounds(this._keyToTileCoords(p))},_tileCoordsToNwSe:function(p){var M=this._map,Y=this.getTileSize(),ue=p.scaleBy(Y),Se=ue.add(Y),st=M.unproject(ue,p.z),At=M.unproject(Se,p.z);return[st,At]},_tileCoordsToBounds:function(p){var M=this._tileCoordsToNwSe(p),Y=new Ze(M[0],M[1]);return this.options.noWrap||(Y=this._map.wrapLatLngBounds(Y)),Y},_tileCoordsToKey:function(p){return p.x+":"+p.y+":"+p.z},_keyToTileCoords:function(p){var M=p.split(":"),Y=new ge(+M[0],+M[1]);return Y.z=+M[2],Y},_removeTile:function(p){var M=this._tiles[p];M&&(_r(M.el),delete this._tiles[p],this.fire("tileunload",{tile:M.el,coords:this._keyToTileCoords(p)}))},_initTile:function(p){Gn(p,"leaflet-tile");var M=this.getTileSize();p.style.width=M.x+"px",p.style.height=M.y+"px",p.onselectstart=x,p.onmousemove=x,is.ielt9&&this.options.opacity<1&&Tr(p,this.options.opacity)},_addTile:function(p,M){var Y=this._getTilePos(p),ue=this._tileCoordsToKey(p),Se=this.createTile(this._wrapCoords(p),u(this._tileReady,this,p));this._initTile(Se),this.createTile.length<2&&Q(u(this._tileReady,this,p,null,Se)),Xr(Se,Y),this._tiles[ue]={el:Se,coords:p,current:!0},M.appendChild(Se),this.fire("tileloadstart",{tile:Se,coords:p})},_tileReady:function(p,M,Y){M&&this.fire("tileerror",{error:M,tile:Y,coords:p});var ue=this._tileCoordsToKey(p);Y=this._tiles[ue],Y&&(Y.loaded=+new Date,this._map._fadeAnimated?(Tr(Y.el,0),Z(this._fadeFrame),this._fadeFrame=Q(this._updateOpacity,this)):(Y.active=!0,this._pruneTiles()),M||(Gn(Y.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:Y.el,coords:p})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),is.ielt9||!this._map._fadeAnimated?Q(this._pruneTiles,this):setTimeout(u(this._pruneTiles,this),250)))},_getTilePos:function(p){return p.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(p){var M=new ge(this._wrapX?y(p.x,this._wrapX):p.x,this._wrapY?y(p.y,this._wrapY):p.y);return M.z=p.z,M},_pxBoundsToTileRange:function(p){var M=this.getTileSize();return new ve(p.min.unscaleBy(M).floor(),p.max.unscaleBy(M).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var p in this._tiles)if(!this._tiles[p].loaded)return!1;return!0}});function si(p){return new ur(p)}var Ei=ur.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(p,M){this._url=p,M=I(this,M),M.detectRetina&&is.retina&&M.maxZoom>0?(M.tileSize=Math.floor(M.tileSize/2),M.zoomReverse?(M.zoomOffset--,M.minZoom=Math.min(M.maxZoom,M.minZoom+1)):(M.zoomOffset++,M.maxZoom=Math.max(M.minZ
755oom,M.maxZoom-1)),M.minZoom=Math.max(0,M.minZoom)):M.zoomReverse?M.minZoom=Math.min(M.maxZoom,M.minZoom):M.maxZoom=Math.max(M.minZoom,M.maxZoom),typeof M.subdomains=="string"&&(M.subdomains=M.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(p,M){return this._url===p&&M===void 0&&(M=!0),this._url=p,M||this.redraw(),this},createTile:function(p,M){var Y=document.createElement("img");return fn(Y,"load",u(this._tileOnLoad,this,M,Y)),fn(Y,"error",u(this._tileOnError,this,M,Y)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(Y.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(Y.referrerPolicy=this.options.referrerPolicy),Y.alt="",Y.src=this.getTileUrl(p),Y},getTileUrl:function(p){var M={r:is.retina?"@2x":"",s:this._getSubdomain(p),x:p.x,y:p.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var Y=this._globalTileRange.max.y-p.y;this.options.tms&&(M.y=Y),M["-y"]=Y}return D(this._url,l(M,this.options))},_tileOnLoad:function(p,M){is.ielt9?setTimeout(u(p,this,null,M),0):p(null,M)},_tileOnError:function(p,M,Y){var ue=this.options.errorTileUrl;ue&&M.getAttribute("src")!==ue&&(M.src=ue),p(Y,M)},_onTileRemove:function(p){p.tile.onload=null},_getZoomForUrl:function(){var p=this._tileZoom,M=this.options.maxZoom,Y=this.options.zoomReverse,ue=this.options.zoomOffset;return Y&&(p=M-p),p+ue},_getSubdomain:function(p){var M=Math.abs(p.x+p.y)%this.options.subdomains.length;return this.options.subdomains[M]},_abortLoading:function(){var p,M;for(p in this._tiles)if(this._tiles[p].coords.z!==this._tileZoom&&(M=this._tiles[p].el,M.onload=x,M.onerror=x,!M.complete)){M.src=te;var Y=this._tiles[p].coords;_r(M),delete this._tiles[p],this.fire("tileabort",{tile:M,coords:Y})}},_removeTile:function(p){var M=this._tiles[p];if(M)return M.el.setAttribute("src",te),ur.prototype._removeTile.call(this,p)},_tileReady:function(p,M,Y){if(!(!this._map||Y&&Y.getAttribute("src")===te))return ur.prototype._tileReady.call(this,p,M,Y)}});function hr(p,M){return new Ei(p,M)}var mo=Ei.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(p,M){this._url=p;var Y=l({},this.defaultWmsParams);for(var ue in M)ue in this.options||(Y[ue]=M[ue]);M=I(this,M);var Se=M.detectRetina&&is.retina?2:1,st=this.getTileSize();Y.width=st.x*Se,Y.height=st.y*Se,this.wmsParams=Y},onAdd:function(p){this._crs=this.options.crs||p.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var M=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[M]=this._crs.code,Ei.prototype.onAdd.call(this,p)},getTileUrl:function(p){var M=this._tileCoordsToNwSe(p),Y=this._crs,ue=we(Y.project(M[0]),Y.project(M[1])),Se=ue.min,st=ue.max,At=(this._wmsVersion>=1.3&&this._crs===Ia?[Se.y,Se.x,st.y,st.x]:[Se.x,Se.y,st.x,st.y]).join(","),hs=Ei.prototype.getTileUrl.call(this,p);return hs+z(this.wmsParams,hs,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+At},setParams:function(p,M){return l(this.wmsParams,p),M||this.redraw(),this}});function Ud(p,M){return new mo(p,M)}Ei.WMS=mo,hr.wms=Ud;var mc=fr.extend({options:{padding:.1},initialize:function(p){I(this,p),_(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),Gn(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var p={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(p.zoomanim=this._onAnimZoom),p},_onAnimZoom:function(p){this._updateTransform(p.center,p.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(p,M){var Y=this._map.getZoomScale(M,this._zoom),ue=this._map.getSize().multiplyBy(.5+this.options.padding),Se=this._map.project(this._center,M),st=ue.multiplyBy(-Y).add(Se).subtract(this._map._getNewPixelOrigin(p,M));is.any3d?Gr(this._container,st,Y):Xr(this._container,st)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var p in this._layers)this._layers[p]._reset()},_onZoomEnd:function(){for(var p in this._layers)this._layers[p]._project()},_updatePaths:function(){for(var p in this._layers)this._layers[p]._update()},_update:function(){var p=this.options.padding,M=this._map.getSize(),Y=this._map.containerPointToLayerPoint(M.multiplyBy(-p)).round();
755this._bounds=new ve(Y,Y.add(M.multiplyBy(1+p*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),_i=mc.extend({options:{tolerance:0},getEvents:function(){var p=mc.prototype.getEvents.call(this);return p.viewprereset=this._onViewPreReset,p},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){mc.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var p=this._container=document.createElement("canvas");fn(p,"mousemove",this._onMouseMove,this),fn(p,"click dblclick mousedown mouseup contextmenu",this._onClick,this),fn(p,"mouseout",this._handleMouseOut,this),p._leaflet_disable_events=!0,this._ctx=p.getContext("2d")},_destroyContainer:function(){Z(this._redrawRequest),delete this._ctx,_r(this._container),nr(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var p;this._redrawBounds=null;for(var M in this._layers)p=this._layers[M],p._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){mc.prototype._update.call(this);var p=this._bounds,M=this._container,Y=p.getSize(),ue=is.retina?2:1;Xr(M,p.min),M.width=ue*Y.x,M.height=ue*Y.y,M.style.width=Y.x+"px",M.style.height=Y.y+"px",is.retina&&this._ctx.scale(2,2),this._ctx.translate(-p.min.x,-p.min.y),this.fire("update")}},_reset:function(){mc.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(p){this._updateDashArray(p),this._layers[_(p)]=p;var M=p._order={layer:p,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=M),this._drawLast=M,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(p){this._requestRedraw(p)},_removePath:function(p){var M=p._order,Y=M.next,ue=M.prev;Y?Y.prev=ue:this._drawLast=ue,ue?ue.next=Y:this._drawFirst=Y,delete p._order,delete this._layers[_(p)],this._requestRedraw(p)},_updatePath:function(p){this._extendRedrawBounds(p),p._project(),p._update(),this._requestRedraw(p)},_updateStyle:function(p){this._updateDashArray(p),this._requestRedraw(p)},_updateDashArray:function(p){if(typeof p.options.dashArray=="string"){var M=p.options.dashArray.split(/[, ]+/),Y=[],ue,Se;for(Se=0;Se<M.length;Se++){if(ue=Number(M[Se]),isNaN(ue))return;Y.push(ue)}p.options._dashArray=Y}else p.options._dashArray=p.options.dashArray},_requestRedraw:function(p){this._map&&(this._extendRedrawBounds(p),this._redrawRequest=this._redrawRequest||Q(this._redraw,this))},_extendRedrawBounds:function(p){if(p._pxBounds){var M=(p.options.weight||0)+1;this._redrawBounds=this._redrawBounds||new ve,this._redrawBounds.extend(p._pxBounds.min.subtract([M,M])),this._redrawBounds.extend(p._pxBounds.max.add([M,M]))}},_redraw:function(){this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null},_clear:function(){var p=this._redrawBounds;if(p){var M=p.getSize();this._ctx.clearRect(p.min.x,p.min.y,M.x,M.y)}else this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore()},_draw:function(){var p,M=this._redrawBounds;if(this._ctx.save(),M){var Y=M.getSize();this._ctx.beginPath(),this._ctx.rect(M.min.x,M.min.y,Y.x,Y.y),this._ctx.clip()}this._drawing=!0;for(var ue=this._drawFirst;ue;ue=ue.next)p=ue.layer,(!M||p._pxBounds&&p._pxBounds.intersects(M))&&p._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(p,M){if(this._drawing){var Y,ue,Se,st,At=p._parts,hs=At.length,ws=this._ctx;if(hs){for(ws.beginPath(),Y=0;Y<hs;Y++){for(ue=0,Se=At[Y].length;ue<Se;ue++)st=At[Y][ue],ws[ue?"lineTo":"moveTo"](st.x,st.y);M&&ws.closePath()}this._fillStroke(ws,p)}}},_updateCircle:function(p){if(!(!this._drawing||p._empty())){var M=p._point,Y=this._ctx,ue=Math.max(Math.round(p._radius),1),Se=(Math.max(Math.round(p._radiusY),1)||ue)/ue;Se!==1&&(Y.save(),Y.scale(1,Se)),Y.beginPath(),Y.arc(M.x,M.y/Se,ue,0,Math.PI*2,!1),Se!==1&&Y.restore(),this._fillStroke(Y,p)}},_fillStroke:function(p,M){var Y=M.options;Y.fill&&(p.globalAlpha=Y.fillOpacity,p.fillStyle=Y.fillColor||Y.color,p.fill(Y.fillRule||"evenodd")),Y.stroke&&Y.weight!==0&&(p.setLineDash&&p.setLineDash(M.options&&M.options._dashArray||[]),p.globalAlpha=Y.opacity,p.lineWidth=Y.weight,p.strokeStyle=Y.color,p.lineCap=Y.lineCap,p.lineJoin=Y.lineJoin,p.stroke())},_onClick:function(p){for(var M=this._map.mouseEventToLayerPoint(p),Y,ue,Se=this._drawFirst;Se;Se=Se.next)Y=Se.layer,Y.options.interactive&&Y._containsPoint(M)&&(!(p.type==="click"||p.type==="preclick")||!this._map._draggableMoved(Y))&&(ue=Y);this._fireEvent(ue?[ue]:!1,p)},_onMouseMove:function(p){if(!(!this._map||this._map.dragging.moving()||this._map._animatingZoom)){var M=this._map.mouseEventToLayerPoint(p);this._handleMouseHover(p,M)}},_handleMouseOut:function(p){var M=this._hoveredLayer;M&&(sa(this._container,"leaflet-interactive"),this._fireEvent([M],p,"mouseout"),this._hoveredLayer=null,this._mouseHoverThrottled=!1)},_handleMouseHover:function(p,M){if(!this._mouseHoverThrottled){for(var Y,ue,Se=this._drawFirst;Se;Se=Se.next)Y=Se.layer,Y.options.interactive&&Y._containsPoint(M)&&(ue=Y);ue!==this._hoveredLayer&&(this._handleMouseOut(p),ue&&(Gn(this._container,"leaflet-interactive"),this._fireEvent([ue],p,"mouseover"),this._hoveredLayer=ue)),this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,p),this._mouseHoverThrottled=!0,setTimeout(u(function(){this._mouseHoverThrottled=!1},this),32)}},_fireEvent:function(p,M,Y){this._map._fireDOMEvent(M,Y||M.type,p)},_bringToFront:function(p){var M=p._order;if(M){var Y=M.next,ue=M.prev;if(Y)Y.prev=ue;else return;ue?ue.next=Y:Y&&(this._drawFirst=Y),M.prev=this._drawLast,this._drawLast.next=
755M,M.next=null,this._drawLast=M,this._requestRedraw(p)}},_bringToBack:function(p){var M=p._order;if(M){var Y=M.next,ue=M.prev;if(ue)ue.next=Y;else return;Y?Y.prev=ue:ue&&(this._drawLast=ue),M.prev=null,M.next=this._drawFirst,this._drawFirst.prev=M,this._drawFirst=M,this._requestRedraw(p)}}});function sl(p){return is.canvas?new _i(p):null}var Ba=function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(p){return document.createElement("<lvml:"+p+' class="lvml">')}}catch{}return function(p){return document.createElement("<"+p+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),xd={_initContainer:function(){this._container=Mn("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(mc.prototype._update.call(this),this.fire("update"))},_initPath:function(p){var M=p._container=Ba("shape");Gn(M,"leaflet-vml-shape "+(this.options.className||"")),M.coordsize="1 1",p._path=Ba("path"),M.appendChild(p._path),this._updateStyle(p),this._layers[_(p)]=p},_addPath:function(p){var M=p._container;this._container.appendChild(M),p.options.interactive&&p.addInteractiveTarget(M)},_removePath:function(p){var M=p._container;_r(M),p.removeInteractiveTarget(M),delete this._layers[_(p)]},_updateStyle:function(p){var M=p._stroke,Y=p._fill,ue=p.options,Se=p._container;Se.stroked=!!ue.stroke,Se.filled=!!ue.fill,ue.stroke?(M||(M=p._stroke=Ba("stroke")),Se.appendChild(M),M.weight=ue.weight+"px",M.color=ue.color,M.opacity=ue.opacity,ue.dashArray?M.dashStyle=X(ue.dashArray)?ue.dashArray.join(" "):ue.dashArray.replace(/( *, *)/g," "):M.dashStyle="",M.endcap=ue.lineCap.replace("butt","flat"),M.joinstyle=ue.lineJoin):M&&(Se.removeChild(M),p._stroke=null),ue.fill?(Y||(Y=p._fill=Ba("fill")),Se.appendChild(Y),Y.color=ue.fillColor||ue.color,Y.opacity=ue.fillOpacity):Y&&(Se.removeChild(Y),p._fill=null)},_updateCircle:function(p){var M=p._point.round(),Y=Math.round(p._radius),ue=Math.round(p._radiusY||Y);this._setPath(p,p._empty()?"M0 0":"AL "+M.x+","+M.y+" "+Y+","+ue+" 0,"+65535*360)},_setPath:function(p,M){p._path.v=M},_bringToFront:function(p){Zs(p._container)},_bringToBack:function(p){Cn(p._container)}},nl=is.vml?Ba:_t,so=mc.extend({_initContainer:function(){this._container=nl("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=nl("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){_r(this._container),nr(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){mc.prototype._update.call(this);var p=this._bounds,M=p.getSize(),Y=this._container;(!this._svgSize||!this._svgSize.equals(M))&&(this._svgSize=M,Y.setAttribute("width",M.x),Y.setAttribute("height",M.y)),Xr(Y,p.min),Y.setAttribute("viewBox",[p.min.x,p.min.y,M.x,M.y].join(" ")),this.fire("update")}},_initPath:function(p){var M=p._path=nl("path");p.options.className&&Gn(M,p.options.className),p.options.interactive&&Gn(M,"leaflet-interactive"),this._updateStyle(p),this._layers[_(p)]=p},_addPath:function(p){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(p._path),p.addInteractiveTarget(p._path)},_removePath:function(p){_r(p._path),p.removeInteractiveTarget(p._path),delete this._layers[_(p)]},_updatePath:function(p){p._project(),p._update()},_updateStyle:function(p){var M=p._path,Y=p.options;M&&(Y.stroke?(M.setAttribute("stroke",Y.color),M.setAttribute("stroke-opacity",Y.opacity),M.setAttribute("stroke-width",Y.weight),M.setAttribute("stroke-linecap",Y.lineCap),M.setAttribute("stroke-linejoin",Y.lineJoin),Y.dashArray?M.setAttribute("stroke-dasharray",Y.dashArray):M.removeAttribute("stroke-dasharray"),Y.dashOffset?M.setAttribute("stroke-dashoffset",Y.dashOffset):M.removeAttribute("stroke-dashoffset")):M.setAttribute("stroke","none"),Y.fill?(M.setAttribute("fill",Y.fillColor||Y.color),M.setAttribute("fill-opacity",Y.fillOpacity),M.setAttribute("fill-rule",Y.fillRule||"evenodd")):M.setAttribute("fill","none"))},_updatePoly:function(p,M){this._setPath(p,He(p._parts,M))},_updateCircle:function(p){var M=p._point,Y=Math.max(Math.round(p._radius),1),ue=Math.max(Math.round(p._radiusY),1)||Y,Se="a"+Y+","+ue+" 0 1,0 ",st=p._empty()?"M0 0":"M"+(M.x-Y)+","+M.y+Se+Y*2+",0 "+Se+-Y*2+",0 ";this._setPath(p,st)},_setPath:function(p,M){p._path.setAttribute("d",M)},_bringToFront:function(p){Zs(p._path)},_bringToBack:function(p){Cn(p._path)}});is.vml&&so.include(xd);function Qc(p){return is.svg||is.vml?new so(p):null}Sn.include({getRenderer:function(p){var M=p.options.renderer||this._getPaneRenderer(p.options.pane)||this.options.renderer||this._renderer;return M||(M=this._renderer=this._createRenderer()),this.hasLayer(M)||this.addLayer(M),M},_getPaneRenderer:function(p){if(p==="overlayPane"||p===void 0)return!1;var M=this._paneRenderers[p];return M===void 0&&(M=this._createRenderer({pane:p}),this._paneRenderers[p]=M),M},_createRenderer:function(p){return this.options.preferCanvas&&sl(p)||Qc(p)}});var _d=tl.extend({initialize:function(p,M){tl.prototype.initialize.call(this,this._boundsToLatLngs(p),M)},setBounds:function(p){return this.setLatLngs(this._boundsToLatLngs(p))}
vendor: 6,288 bytes, line 755
755,_boundsToLatLngs:function(p){return p=ke(p),[p.getSouthWest(),p.getNorthWest(),p.getNorthEast(),p.getSouthEast()]}});function ai(p,M){return new _d(p,M)}so.create=nl,so.pointsToPath=He,Bo.geometryToLayer=Jc,Bo.coordsToLatLng=Ic,Bo.coordsToLatLngs=yu,Bo.latLngToCoords=Qd,Bo.latLngsToCoords=to,Bo.getFeature=$o,Bo.asFeature=N,Sn.mergeOptions({boxZoom:!0});var eu=Ri.extend({initialize:function(p){this._map=p,this._container=p._container,this._pane=p._panes.overlayPane,this._resetStateTimeout=0,p.on("unload",this._destroy,this)},addHooks:function(){fn(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){nr(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){_r(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(p){if(!p.shiftKey||p.which!==1&&p.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),In(),zo(),this._startPoint=this._map.mouseEventToContainerPoint(p),fn(document,{contextmenu:qs,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(p){this._moved||(this._moved=!0,this._box=Mn("div","leaflet-zoom-box",this._container),Gn(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(p);var M=new ve(this._point,this._startPoint),Y=M.getSize();Xr(this._box,M.min),this._box.style.width=Y.x+"px",this._box.style.height=Y.y+"px"},_finish:function(){this._moved&&(_r(this._box),sa(this._container,"leaflet-crosshair")),Yi(),Pc(),nr(document,{contextmenu:qs,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(p){if(!(p.which!==1&&p.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(u(this._resetState,this),0);var M=new Ze(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(M).fire("boxzoomend",{boxZoomBounds:M})}},_onKeyDown:function(p){p.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});Sn.addInitHook("addHandler","boxZoom",eu),Sn.mergeOptions({doubleClickZoom:!0});var Vr=Ri.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(p){var M=this._map,Y=M.getZoom(),ue=M.options.zoomDelta,Se=p.originalEvent.shiftKey?Y-ue:Y+ue;M.options.doubleClickZoom==="center"?M.setZoom(Se):M.setZoomAround(p.containerPoint,Se)}});Sn.addInitHook("addHandler","doubleClickZoom",Vr),Sn.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var Fi=Ri.extend({addHooks:function(){if(!this._draggable){var p=this._map;this._draggable=new Rl(p._mapPane,p._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),p.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),p.on("zoomend",this._onZoomEnd,this),p.whenReady(this._onZoomEnd,this))}Gn(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){sa(this._map._container,"leaflet-grab"),sa(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var p=this._map;if(p._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var M=ke(this._map.options.maxBounds);this._offsetLimit=we(this._map.latLngToContainerPoint(M.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(M.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;p.fire("movestart").fire("dragstart"),p.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(p){if(this._map.options.inertia){var M=this._lastTime=+new Date,Y=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(Y),this._times.push(M),this._prunePositions(M)}this._map.fire("move",p).fire("drag",p)},_prunePositions:function(p){for(;this._positions.length>1&&p-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var p=this._map.getSize().divideBy(2),M=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=M.subtract(p).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(p,M){return p-(p-M)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var p=this._draggable._newPos.subtract(this._draggable._startPos),M=this._offsetLimit;p.x<M.min.x&&(p.x=this._viscousLimit(p.x,M.min.x)),p.y<M.min.y&&(p.y=this._viscousLimit(p.y,M.min.y)),p.x>M.max.x&&(p.x=this._viscousLimit(p.x,M.max.x)),p.y>M.max.y&&(p.y=this._viscousLimit(p.y,M.max.y)),this._draggable._newPos=this._draggable._startPos.add(p)}},_onPreDragWrap:function(){var p=this._worldWidth,M=Math.round(p/2),Y=this._initialWorldOffset,ue=this._draggable._newPos.x,Se=(ue-M+Y)%p+M-Y,st=(ue+M+Y)%p-M-Y,At=Math.abs(Se+Y)<Math.abs(st+Y)?Se:st;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=At},_onDragEnd:function(p){var M=this._map,Y=M.options,ue=!Y.inertia||p.noInertia||this._times.length<2;if(M.fire("dragend",p),ue)M.fire("moveend");else{this._prunePositions(+new Date);var Se=this._lastPos.subtract(this._positions[0]),st=(this._lastTime-this._times[0])/1e3,At=Y.easeLinearity,hs=Se.multiplyBy(At/st),ws=hs.distanceTo([0,0]),Os=Math.min(Y.inertiaMaxSpeed,ws),_n=hs.multiplyBy(Os/ws),Ta=Os/(Y.inertiaDeceleration*At),yr=_n.multiplyBy(-Ta/2).round();!yr.x&&!yr.y?M.fire("moveend"):(yr=M._limitOffset(yr,M.options.maxBounds),Q(function(){M.panBy(yr,{duration:Ta,easeLinearity:At,noMoveStart:!0,animate:!0})}
755))}}});Sn.addInitHook("addHandler","dragging",Fi),Sn.mergeOptions({keyboard:!0,keyboardPanDelta:80});var ri=Ri.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(p){this._map=p,this._setPanDelta(p.options.keyboardPanDelta),this._setZoomDelta(p.options.zoomDelta)},addHooks:function(){var p=this._map._container;p.tabIndex<=0&&(p.tabIndex="0"),fn(p,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),nr(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){if(!this._focused){var p=document.body,M=document.documentElement,Y=p.scrollTop||M.scrollTop,ue=p.scrollLeft||M.scrollLeft;this._map._container.focus(),window.scrollTo(ue,Y)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanDelta:function(p){var M=this._panKeys={},Y=this.keyCodes,ue,Se;for(ue=0,Se=Y.left.length;ue<Se;ue++)M[Y.left[ue]]=[-1*p,0];for(ue=0,Se=Y.right.length;ue<Se;ue++)M[Y.right[ue]]=[p,0];for(ue=0,Se=Y.down.length;ue<Se;ue++)M[Y.down[ue]]=[0,p];for(ue=0,Se=Y.up.length;ue<Se;ue++)M[Y.up[ue]]=[0,-1*p]},_setZoomDelta:function(p){var M=this._zoomKeys={},Y=this.keyCodes,ue,Se;for(ue=0,Se=Y.zoomIn.length;ue<Se;ue++)M[Y.zoomIn[ue]]=p;for(ue=0,Se=Y.zoomOut.length;ue<Se;ue++)M[Y.zoomOut[ue]]=-p},_addHooks:function(){fn(document,"keydown",this._onKeyDown,this)},_removeHooks:function(){nr(document,"keydown",this._onKeyDown,this)},_onKeyDown:function(p){if(!(p.altKey||p.ctrlKey||p.metaKey)){var M=p.keyCode,Y=this._map,ue;if(M in this._panKeys){if(!Y._panAnim||!Y._panAnim._inProgress)if(ue=this._panKeys[M],p.shiftKey&&(ue=Ee(ue).multiplyBy(3)),Y.options.maxBounds&&(ue=Y._limitOffset(Ee(ue),Y.options.maxBounds)),Y.options.worldCopyJump){var Se=Y.wrapLatLng(Y.unproject(Y.project(Y.getCenter()).add(ue)));Y.panTo(Se)}else Y.panBy(ue)}else if(M in this._zoomKeys)Y.setZoom(Y.getZoom()+(p.shiftKey?3:1)*this._zoomKeys[M]);else if(M===27&&Y._popup&&Y._popup.options.closeOnEscapeKey)Y.closePopup();else return;qs(p)}}});Sn.addInitHook("addHandler","keyboard",ri),Sn.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});var vo=Ri.extend({addHooks:function(){fn(this._map._container,"wheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){nr(this._map._container,"wheel",this._onWheelScroll,this)},_onWheelScroll:function(p){var M=mr(p),Y=this._map.options.wheelDebounceTime;this._delta+=M,this._lastMousePos=this._map.mouseEventToContainerPoint(p),this._startTime||(this._startTime=+new Date);var ue=Math.max(Y-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(u(this._performZoom,this),ue),qs(p)},_performZoom:function(){var p=this._map,M=p.getZoom(),Y=this._map.options.zoomSnap||0;p._stop();var ue=this._delta/(this._map.options.wheelPxPerZoomLevel*4),Se=4*Math.log(2/(1+Math.exp(-Math.abs(ue))))/Math.LN2,st=Y?Math.ceil(Se/Y)*Y
755:Se,At=p._limitZoom(M+(this._delta>0?st:-st))-M;this._delta=0,this._startTime=null,At&&(p.options.scrollWheelZoom==="center"?p.setZoom(M+At):p.setZoomAround(this._lastMousePos,M+At))}});Sn.addInitHook("addHandler","scrollWheelZoom",vo);var vu=600;Sn.mergeOptions({tapHold:is.touchNative&&is.safari&&is.mobile,tapTolerance:15});var tu=Ri.extend({addHooks:function(){fn(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){nr(this._map._container,"touchstart",this._onDown,this)},_onDown:function(p){if(clearTimeout(this._holdTimeout),p.touches.length===1){var M=p.touches[0];this._startPos=this._newPos=new ge(M.clientX,M.clientY),this._holdTimeout=setTimeout(u(function(){this._cancel(),this._isTapValid()&&(fn(document,"touchend",ti),fn(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",M))},this),vu),fn(document,"touchend touchcancel contextmenu",this._cancel,this),fn(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function p(){nr(document,"touchend",ti),nr(document,"touchend touchcancel",p)},_cancel:function(){clearTimeout(this._holdTimeout),nr(document,"touchend touchcancel contextmenu",this._cancel,this),nr(document,"touchmove",this._onMove,this)},_onMove:function(p){var M=p.touches[0];this._newPos=new ge(M.clientX,M.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(p,M){var Y=new MouseEvent(p,{bubbles:!0,cancelable:!0,view:window,screenX:M.screenX,screenY:M.screenY,clientX:M.clientX,clientY:M.clientY});Y._simulated=!0,M.target.dispatchEvent(Y)}});Sn.addInitHook("addHandler","tapHold",tu),Sn.mergeOptions({touchZoom:is.touch,bounceAtZoomLimits:!0});var bu=Ri.extend({addHooks:function(){Gn(this._map._container,"leaflet-touch-zoom"),fn(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){sa(this._map._container,"leaflet-touch-zoom"),nr(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(p){var M=this._map;if(!(!p.touches||p.touches.length!==2||M._animatingZoom||this._zooming)){var Y=M.mouseEventToContainerPoint(p.touches[0]),ue=M.mouseEventToContainerPoint(p.touches[1]);this._centerPoint=M.getSize()._divideBy(2),this._startLatLng=M.containerPointToLatLng(this._centerPoint),M.options.touchZoom!=="center"&&(this._pinchStartLatLng=M.containerPointToLatLng(Y.add(ue)._divideBy(2))),this._startDist=Y.distanceTo(ue),this._startZoom=M.getZoom(),this._moved=!1,this._zooming=!0,M._stop(),fn(document,"touchmove",this._onTouchMove,this),fn(document,"touchend touchcancel",this._onTouchEnd,this),ti(p)}},_onTouchMove:function(p){if(!(!p.touches||p.touches.length!==2||!this._zooming)){var M=this._map,Y=M.mouseEventToContainerPoint(p.touches[0]),ue=M.mouseEventToContainerPoint(p.touches[1]),Se=Y.distanceTo(ue)/this._startDist;if(this._zoom=M.getScaleZoom(Se,this._startZoom),!M.options.bounceAtZoomLimits&&(this._zoom<M.getMinZoom()&&Se<1||this._zoom>M.getMaxZoom()&&Se>1)&&(this._zoom=M._limitZoom(this._zoom)),M.options.touchZoom==="center"){if(this._center=this._startLatLng,Se===1)return}else{var st=Y._add(ue)._divideBy(2)._subtract(this._centerPoint);if(Se===1&&st.x===0&&st.y===0)return;this._center=M.unproject(M.project(this._pinchStartLatLng,this._zoom).subtract(st),this._zoom)}this._moved||(M._moveStart(!0,!1),this._moved=!0),Z(this._animRequest);var At=u(M._move,M,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=Q(At,this,!0),ti(p)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,Z(this._animRequest),nr(document,"touchmove",this._onTouchMove,this),nr(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}});Sn.addInitHook("addHandler","touchZoom",bu),Sn.BoxZoom=eu,Sn.DoubleClickZoom=Vr,Sn.Drag=Fi,Sn.Keyboard=ri,Sn.ScrollWheelZoom=vo,Sn.TapHold=tu,Sn.TouchZoom=bu,n.Bounds=ve,n.Browser=is,n.CRS=dt,n.Canvas=_i,n.Circle=yo,n.CircleMarker=el,n.Class=ce,n.Control=Ma,n.DivIcon=wa,n.DivOverlay=Ut,n.DomEvent=Jo,n.DomUtil=Gi,n.Draggable=Rl,n.Evented=de,n.FeatureGroup=qe,n.GeoJSON=Bo,n.GridLayer=ur,n.Handler=Ri,n.Icon=js,n.ImageOverlay=G,n.LatLng=ze,n.LatLngBounds=Ze,n.Layer=fr,n.LayerGroup=Dr,n.LineUtil=pl,n.Map=Sn,n.Marker=Rr,n.Mixin=Qo,n.Path=Uo,n.Point=ge,
755n.PolyUtil=Kr,n.Polygon=tl,n.Polyline=ci,n.Popup=xs,n.PosAnimation=na,n.Projection=li,n.Rectangle=_d,n.Renderer=mc,n.SVG=so,n.SVGOverlay=tt,n.TileLayer=Ei,n.Tooltip=bn,n.Transformation=Fe,n.Util=oe,n.VideoOverlay=xe,n.bind=u,n.bounds=we,n.canvas=sl,n.circle=gl,n.circleMarker=Oo,n.control=Di,n.divIcon=Lr,n.extend=l,n.featureGroup=Xt,n.geoJSON=f,n.geoJson=w,n.gridLayer=si,n.icon=Rs,n.imageOverlay=re,n.latLng=Ke,n.latLngBounds=ke,n.layerGroup=zl,n.map=Ui,n.marker=Mc,n.point=Ee,n.polygon=xl,n.polyline=Eo,n.popup=$s,n.rectangle=ai,n.setOptions=I,n.stamp=_,n.svg=Qc,n.svgOverlay=Nt,n.tileLayer=hr,n.tooltip=da,n.transformation=fe,n.version=a,n.videoOverlay=Ae;var Bh=window.L;n.noConflict=function(){return window.L=Bh,this},window.L=n})})(Jb,Jb.exports);var pD=Jb.exports;const Bt=w1(pD);var ak={exports:{}};(function(t,s){(function(n,a){a(s)})(Fm,function(n){var a=L.MarkerClusterGroup=L.FeatureGroup.extend({options:{maxClusterRadius:80,iconCreateFunction:null,clusterPane:L.Marker.prototype.options.pane,spiderfyOnEveryZoom:!1,spiderfyOnMaxZoom:!0,showCoverageOnHover:!0,zoomToBoundsOnClick:!0,singleMarkerMode:!1,disableClusteringAtZoom:null,removeOutsideVisibleBounds:!0,animate:!0,animateAddingMarkers:!1,spiderfyShapePositions:null,spiderfyDistanceMultiplier:1,spiderLegPolylineOptions:{weight:1.5,color:"#222",opacity:.5},chunkedLoading:!1,chunkInterval:200,chunkDelay:50,chunkProgress:null,polygonOptions:{}},initialize:function(c){L.Util.setOptions(this,c),this.options.iconCreateFunction||(this.options.iconCreateFunction=this._defaultIconCreateFunction),this._featureGroup=L.featureGroup(),this._featureGroup.addEventParent(this),this._nonPointGroup=L.featureGroup(),this._nonPointGroup.addEventParent(this),this._inZoomAnimation=0,this._needsClustering=[],this._needsRemoving=[],this._currentShownBounds=null,this._queue=[],this._childMarkerEventHandlers={dragstart:this._childMarkerDragStart,move:this._childMarkerMoved,dragend:this._childMarkerDragEnd};var u=L.DomUtil.TRANSITION&&this.options.animate;L.extend(this,u?this._withAnimation:this._noAnimation),this._markerCluster=u?L.MarkerCluster:L.MarkerClusterNonAnimated},addLayer:function(c){if(c instanceof L.LayerGroup)return this.addLayers([c]);if(!c.getLatLng)return this._nonPointGroup.addLayer(c),this.fire("layeradd",{layer:c}),this;if(!this._map)return this._needsClustering.push(c),this.fire("layeradd",{layer:c}),this;if(this.hasLayer(c))return this;this._unspiderfy&&this._unspiderfy(),this._addLayer(c,this._maxZoom),this.fire("layeradd",{layer:c}),this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons();var u=c,i=this._zoom;if(c.__parent)for(;u.__parent._zoom>=i;)u=u.__parent;return this._currentShownBounds.contains(u.getLatLng())&&(this.options.animateAddingMarkers?this._animationAddLayer(c,u):this._animationAddLayerNonAnimated(c,u)),this},removeLayer:function(c){return c instanceof L.LayerGroup?this.removeLayers([c]):c.getLatLng?this._map?c.__parent?(this._unspiderfy&&(this._unspiderfy(),this._unspiderfyLayer(c)),this._removeLayer(c,!0),this.fire("layerremove",{layer:c}),this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),c.off(this._childMarkerEventHandlers,this),this._featureGroup.hasLayer(c)&&(this._featureGroup.removeLayer(c),c.clusterShow&&c.clusterShow()),this):this:(!this._arraySplice(this._needsClustering,c)&&this.hasLayer(c)&&this._needsRemoving.push({layer:c,latlng:c._latlng}),this.fire("layerremove",{layer:c}),this):(this._nonPointGroup.removeLayer(c),this.fire("layerremove",{layer:c}),this)},addLayers:function(c,u){if(!L.Util.isArray(c))return this.addLayer(c);var i=this._featureGroup,_=this._nonPointGroup,j=this.options.chunkedLoading,y=this.options.chunkInterval,x=this.options.chunkProgress,v=c.length,C=0,P=!0,I;if(this._map){var z=new Date().getTime(),F=L.bind(function(){var X=new Date().getTime();for(this._map&&this._unspiderfy&&this._unspiderfy();C<v;C++){if(j&&C%200===0){var K=new Date().getTime()-X;if(K>y)break}if(I=c[C],I instanceof L.LayerGroup){P&&(c=c.slice(),P=!1),this._extractNonGroupLayers(I,c),v=c.length;continue}if(!I.getLatLng){_.addLayer(I),u||this.fire("layeradd",{layer:I});continue}if(!this.hasLayer(I)&&(this._addLayer(I,this._maxZoom),u||this.fire("layeradd",{layer:I}),I.__parent&&I.__parent.getChildCount()===2)){var te=I.__parent.getAllChildMarkers(),J=te[0]===I?te[1]:te[0];i.removeLayer(J)}}x&&x(C,v,new Date().getTime()-z),C===v?(this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),this._topClusterLevel._recursivelyAddChildrenToMap(null,this._zoom,this._currentShownBounds)):setTimeout(F,this.options.chunkDelay)},this);F()}else for(var D=this._needsClustering;C<v;C++){if(I=c[C],I instanceof L.LayerGroup){P&&(c=c.slice(),P=!1),this._extractNonGroupLayers(I,c),v=c.length;continue}if(!I.getLatLng){_.addLayer(I);continue}this.hasLayer(I)||D.push(I)}return this},removeLayers:function(c){var u,i,_=c.length,j=this._featureGroup,y=this._nonPointGroup,x=!0;if(!this._map){for(u=0;
755u<_;u++){if(i=c[u],i instanceof L.LayerGroup){x&&(c=c.slice(),x=!1),this._extractNonGroupLayers(i,c),_=c.length;continue}this._arraySplice(this._needsClustering,i),y.removeLayer(i),this.hasLayer(i)&&this._needsRemoving.push({layer:i,latlng:i._latlng}),this.fire("layerremove",{layer:i})}return this}if(this._unspiderfy){this._unspiderfy();var v=c.slice(),C=_;for(u=0;u<C;u++){if(i=v[u],i instanceof L.LayerGroup){this._extractNonGroupLayers(i,v),C=v.length;continue}this._unspiderfyLayer(i)}}for(u=0;u<_;u++){if(i=c[u],i instanceof L.LayerGroup){x&&(c=c.slice(),x=!1),this._extractNonGroupLayers(i,c),_=c.length;continue}if(!i.__parent){y.removeLayer(i),this.fire("layerremove",{layer:i});continue}this._removeLayer(i,!0,!0),this.fire("layerremove",{layer:i}),j.hasLayer(i)&&(j.removeLayer(i),i.clusterShow&&i.clusterShow())}return this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),this._topClusterLevel._recursivelyAddChildrenToMap(null,this._zoom,this._currentShownBounds),this},clearLayers:function(){return this._map||(this._needsClustering=[],this._needsRemoving=[],delete this._gridClusters,delete this._gridUnclustered),this._noanimationUnspiderfy&&this._noanimationUnspiderfy(),this._featureGroup.clearLayers(),this._nonPointGroup.clearLayers(),this.eachLayer(function(c){c.off(this._childMarkerEventHandlers,this),delete c.__parent},this),this._map&&this._generateInitialClusters(),this},getBounds:function(){var c=new L.LatLngBounds;this._topClusterLevel&&c.extend(this._topClusterLevel._bounds);for(var u=this._needsClustering.length-1;u>=0;u--)c.extend(this._needsClustering[u].getLatLng());return c.extend(this._nonPointGroup.getBounds()),c},eachLayer:function(c,u){var i=this._needsClustering.slice(),_=this._needsRemoving,j,y,x;for(this._topClusterLevel&&this._topClusterLevel.getAllChildMarkers(i),y=i.length-1;y>=0;y--){for(j=!0,x=_.length-1;x>=0;x--)if(_[x].layer===i[y]){j=!1;break}j&&c.call(u,i[y])}this._nonPointGroup.eachLayer(c,u)},getLayers:function(){var c=[];return this.eachLayer(function(u){c.push(u)}),c},getLayer:function(c){var u=null;return c=parseInt(c,10),this.eachLayer(function(i){L.stamp(i)===c&&(u=i)}),u},hasLayer:function(c){if(!c)return!1;var u,i=this._needsClustering;for(u=i.length-1;u>=0;u--)if(i[u]===c)return!0;for(i=this._needsRemoving,u=i.length-1;u>=0;u--)if(i[u].layer===c)return!1;return!!(c.__parent&&c.__parent._group===this)||this._nonPointGroup.hasLayer(c)},zoomToShowLayer:function(c,u){var i=this._map;typeof u!="function"&&(u=function(){});var _=function(){(i.hasLayer(c)||i.hasLayer(c.__parent))&&!this._inZoomAnimation&&(this._map.off("moveend",_,this),this.off("animationend",_,this),i.hasLayer(c)?u():c.__parent._icon&&(this.once("spiderfied",u,this),c.__parent.spiderfy()))};c._icon&&this._map.getBounds().contains(c.getLatLng())?u():c.__parent._zoom<Math.round(this._map._zoom)?(this._map.on("moveend",_,this),this._map.panTo(c.getLatLng())):(this._map.on("moveend",_,this),this.on("animationend",_,this),c.__parent.zoomToBounds())},onAdd:function(c){this._map=c;var u,i,_;if(!isFinite(this._map.getMaxZoom()))throw"Map has no maxZoom specified";for(this._featureGroup.addTo(c),this._nonPointGroup.addTo(c),this._gridClusters||this._generateInitialClusters(),this._maxLat=c.options.crs.projection.MAX_LATITUDE,u=0,i=this._needsRemoving.length;u<i;u++)_=this._needsRemoving[u],_.newlatlng=_.layer._latlng,_.layer._latlng=_.latlng;for(u=0,i=this._needsRemoving.length;u<i;u++)_=this._needsRemoving[u],this._removeLayer(_.layer,!0),_.layer._latlng=_.newlatlng;this._needsRemoving=[],this._zoom=Math.round(this._map._zoom),this._currentShownBounds=this._getExpandedVisibleBounds(),this._map.on("zoomend",this._zoomEnd,this),this._map.on("moveend",this._moveEnd,this),this._spiderfierOnAdd&&this._spiderfierOnAdd(),this._bindEvents(),i=this._needsClustering,this._needsClustering=[],this.addLayers(i,!0)},onRemove:function(c){c.off("zoomend",this._zoomEnd,this),c.off("moveend",this._moveEnd,this),this._unbindEvents(),this._map._mapPane.className=this._map._mapPane.className.replace(" leaflet-cluster-anim",""),this._spiderfierOnRemove&&this._spiderfierOnRemove(),delete this._maxLat,this._hideCoverage(),this._featureGroup.remove(),this._nonPointGroup.remove(),this._featureGroup.clearLayers(),this._map=null},getVisibleParent:function(c){for(var u=c;u&&!u._icon;)u=u.__parent;return u||null},_arraySplice:function(c,u){for(var i=c.length-1;i>=0;i--)if(c[i]===u)return c.splice(i,1),!0},_removeFromGridUnclustered:function(c,u){for(var i=this._map,_=this._gridUnclustered,j=Math.floor(this._map.getMinZoom());u>=j&&_[u].removeObject(c,i.project(c.getLatLng(),u));u--);},_childMarkerDragStart:function(c){c.target.__dragStart=c.target._latlng},_childMarkerMoved:function(c){if(!this._ignoreMove&&!c.target.__dragStart){var u=c.target._popup&&c.target._popup.isOpen();this._moveChild(c.target,c.oldLatLng,c.latlng),u&&c.target.openPopup()}},_moveChild:function(c,u,i){c._latlng=u,this.removeLayer(c),c._latlng=i,this.addLayer(c)},_childMarkerDragEnd:function(c){var u=c.target.__dragStart;delete c.target.__dragStart,u&&this._moveChild(c.target,u,c.target._latlng)},_removeLayer:function(c,u,i){var _=this._gridClusters,j=this._gridUnclustered,y=this._featureGroup,x=this._map,v=Math.floor(this._map.getMinZoom());u&&this._removeFromGridUnclustered(c,this._maxZoom);var C=c.__parent,P=C._markers,I;for(this._arraySplice(P,c);C&&(C._childCount--,C._boundsNeedUpdate=!0,!(C._zoom<v));)u&&C._childCount<=1?(I=C._markers[0]===c?C._markers[1]:C._markers[0],_[C._zoom].removeObject(C,x.project(C._cLatLng,C._zoom)),j[C._zoom].addObject(I,x.project(I.getLatLng(),C._zoom)),this._arraySplice(C.__parent._childClusters,C),C.__parent._markers.push(I),I.__parent=C.__parent,C._icon&&(y.removeLayer(C),i||y.addLayer(I))):C._iconNeedsUpdate=!0,C=C.__parent;delete c.__parent},_isOrIsParent:function(c,u){for(;u;){if(c===u)return!0;u=u.parentNode}return!1},fire:function(c,u,i){if(u&&u.layer instanceof L.MarkerCluster){if(u.originalEvent&&this._isOrIsParent(u.layer._icon,u.originalEvent.relatedTarget))return;c="cluster"+c}L.FeatureGroup.prototype.fire.call(this,c,u,i)},listens:function(c,u){return L.FeatureGroup.prototype.listens.call(this,c,u)||L.FeatureGroup.prototype.listens.call(this,"cluster"+c,u)},_defaultIconCreateFunction:function(c){var u=c.getChildCount(),i=" marker-cluster-";return u<10?i+="small":u<100?i+="medium":i+="large",new L.DivIcon({html:"<div><span>"+u+"</span></div>",className:"marker-cluster"+i,iconSize:new L.Point(40,40)})},_bindEvents:function(){var c=this._map,u=this.options.spiderfyOnMaxZoom,i=this.options.showCoverageOnHover,_=this.options.zoomToBoundsOnClick,j=this.options.spiderfyOnEveryZoom;(u||_||j)&&this.on("clusterclick clusterkeypress",this._zoomOrSpiderfy,this),i&&(this.on("clustermouseover",this._showCoverage,this),this.on("clustermouseout",this._hideCoverage,this),c.on("zoomend",this._hideCoverage,this))},_zoomOrSpiderfy:function(c){var u=c.layer,i=u;if(!(c.type==="clusterkeypress"&&c.originalEvent&&c.originalEvent.keyCode!==13)){for(;i._childClusters.length===1;)i=i._childClusters[0];i._zoom===this._maxZoom&&i._childCount===u._childCount&&this.options.spiderfyOnMaxZoom?u.spiderfy():this.options.zoomToBoundsOnClick&&u.zoomToBounds(),this.options.spiderfyOnEveryZoom&&u.spiderfy(),c.originalEvent&&c.originalEvent.keyCode===13&&this._map._container.focus()}},_showCoverage:function(c){var u=this._map;this._inZoomAnimation||(this._shownPolygon&&u.removeLayer(this._shownPolygon),c.layer.getChildCount()>2&&c.layer!==this._spiderfied&&(this._shownPolygon=new L.Polygon(c.layer.getConvexHull(),this.options.polygonOptions),u.addLayer(this._shownPolygon)))},_hideCoverage:function(){this._shownPolygon&&(this._map.removeLayer(this._shownPolygon),this._shownPolygon=null)},_unbindEvents:function(){var c=this.options.spiderfyOnMaxZoom,u=this.options.showCoverageOnHover,i=this.options.zoomToBoundsOnClick,_=this.options.spiderfyOnEveryZoom,j=this._map;(c||i||_)&&this.off("clusterclick clusterkeypress",this._zoomOrSpiderfy,this),u&&(this.off("clustermouseover",this._showCoverage,this),this.off("clustermouseout",this._hideCoverage,this),j.off("zoomend",this._hideCoverage,this))}
755,_zoomEnd:function(){this._map&&(this._mergeSplitClusters(),this._zoom=Math.round(this._map._zoom),this._currentShownBounds=this._getExpandedVisibleBounds())},_moveEnd:function(){if(!this._inZoomAnimation){var c=this._getExpandedVisibleBounds();this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,Math.floor(this._map.getMinZoom()),this._zoom,c),this._topClusterLevel._recursivelyAddChildrenToMap(null,Math.round(this._map._zoom),c),this._currentShownBounds=c}},_generateInitialClusters:function(){var c=Math.ceil(this._map.getMaxZoom()),u=Math.floor(this._map.getMinZoom()),i=this.options.maxClusterRadius,_=i;typeof i!="function"&&(_=function(){return i}),this.options.disableClusteringAtZoom!==null&&(c=this.options.disableClusteringAtZoom-1),this._maxZoom=c,this._gridClusters={},this._gridUnclustered={};for(var j=c;j>=u;j--)this._gridClusters[j]=new L.DistanceGrid(_(j)),this._gridUnclustered[j]=new L.DistanceGrid(_(j));this._topClusterLevel=new this._markerCluster(this,u-1)},_addLayer:function(c,u){var i=this._gridClusters,_=this._gridUnclustered,j=Math.floor(this._map.getMinZoom()),y,x;for(this.options.singleMarkerMode&&this._overrideMarkerIcon(c),c.on(this._childMarkerEventHandlers,this);u>=j;u--){y=this._map.project(c.getLatLng(),u);var v=i[u].getNearObject(y);if(v){v._addChild(c),c.__parent=v;return}if(v=_[u].getNearObject(y),v){var C=v.__parent;C&&this._removeLayer(v,!1);var P=new this._markerCluster(this,u,v,c);i[u].addObject(P,this._map.project(P._cLatLng,u)),v.__parent=P,c.__parent=P;var I=P;for(x=u-1;x>C._zoom;x--)I=new this._markerCluster(this,x,I),i[x].addObject(I,this._map.project(v.getLatLng(),x));C._addChild(I),this._removeFromGridUnclustered(v,u);return}_[u].addObject(c,y)}this._topClusterLevel._addChild(c),c.__parent=this._topClusterLevel},_refreshClustersIcons:function(){this._featureGroup.eachLayer(function(c){c instanceof L.MarkerCluster&&c._iconNeedsUpdate&&c._updateIcon()})},_enqueue:function(c){this._queue.push(c),this._queueTimeout||(this._queueTimeout=setTimeout(L.bind(this._processQueue,this),300))},_processQueue:function(){for(var c=0;c<this._queue.length;c++)this._queue[c].call(this);this._queue.length=0,clearTimeout(this._queueTimeout),this._queueTimeout=null},_mergeSplitClusters:function(){var c=Math.round(this._map._zoom);this._processQueue(),this._zoom<c&&this._currentShownBounds.intersects(this._getExpandedVisibleBounds())?(this._animationStart(),this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,Math.floor(this._map.getMinZoom()),this._zoom,this._getExpandedVisibleBounds()),this._animationZoomIn(this._zoom,c)):this._zoom>c?(this._animationStart(),this._animationZoomOut(this._zoom,c)):this._moveEnd()},_getExpandedVisibleBounds:function(){if(this.options.removeOutsideVisibleBounds){if(L.Browser.mobile)return this._checkBoundsMaxLat(this._map.getBounds())}else return this._mapBoundsInfinite;return this._checkBoundsMaxLat(this._map.getBounds().pad(1))},_checkBoundsMaxLat:function(c){var u=this._maxLat;return u!==void 0&&(c.getNorth()>=u&&(c._northEast.lat=1/0),c.getSouth()<=-u&&(c._southWest.lat=-1/0)),c},_animationAddLayerNonAnimated:function(c,u){if(u===c)this._featureGroup.addLayer(c);else if(u._childCount===2){u._addToMap();var i=u.getAllChildMarkers();this._featureGroup.removeLayer(i[0]),this._featureGroup.removeLayer(i[1])}else u._updateIcon()},_extractNonGroupLayers:function(c,u){var i=c.getLayers(),_=0,j;for(u=u||[];_<i.length;_++){if(j=i[_],j instanceof L.LayerGroup){this._extractNonGroupLayers(j,u);continue}u.push(j)}return u},_overrideMarkerIcon:function(c){var u=c.options.icon=this.options.iconCreateFunction({getChildCount:function(){return 1},getAllChildMarkers:function(){return[c]}});return u}});L.MarkerClusterGroup.include({_mapBoundsInfinite:new L.LatLngBounds(new L.LatLng(-1/0,-1/0),new L.LatLng(1/0,1/0))}),L.MarkerClusterGroup.include({_noAnimation:{_animationStart:function(){},_animationZoomIn:function(c,u){this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,Math.floor(this._map.getMinZoom()),c),this._topClusterLevel._recursivelyAddChildrenToMap(null,u,this._getExpandedVisibleBounds()),this.fire("animationend")},_animationZoomOut:function(c,u){this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,Math.floor(this._map.getMinZoom()),c),this._topClusterLevel._recursivelyAddChildrenToMap(null,u,this._getExpandedVisibleBounds()),this.fire("animationend")},_animationAddLayer:function(c,u){this._animationAddLayerNonAnimated(c,u)}},_withAnimation:{_animationStart:function(){this._map._mapPane.className+=" leaflet-cluster-anim",this._inZoomAnimation++},_animationZoomIn:function(c,u){var i=this._getExpandedVisibleBounds(),_=this._featureGroup,j=Math.floor(this._map.getMinZoom()),y;this._ignoreMove=!0,this._topClusterLevel._recursively(i,c,j,function(x){var v=x._latlng,C=x._markers,P;for(i.contains(v)||(v=null),x._isSingleParent()&&c+1===u?(_.removeLayer(x),x._recursivelyAddChildrenToMap(null,u,i)):(x.clusterHide(),x._recursivelyAddChildrenToMap(v,u,i)),y=C.length-1;y>=0;y--)P=C[y],i.contains(P._latlng)||_.removeLayer(P)}),this._forceLayout(),this._topClusterLevel._recursivelyBecomeVisible(i,u),_.eachLayer(function(x){!(x instanceof L.MarkerCluster)&&x._icon&&x.clusterShow()}),this._topClusterLevel._recursively(i,c,u,function(x){x._recursivelyRestoreChildPositions(u)}),this._ignoreMove=!1,this._enqueue(function(){this._topClusterLevel._recursively(i,c,j,function(x){_.removeLayer(x),x.clusterShow()}),this._animationEnd()})},_animationZoomOut:function(c,u){this._animationZoomOutSingle(this._topClusterLevel,c-1,u),this._topClusterLevel._recursivelyAddChildrenToMap(null,u,this._getExpandedVisibleBounds()),this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,Math.floor(this._map.getMinZoom()),c,this._getExpandedVisibleBounds())},_animationAddLayer:function(c,u){var i=this,_=this._featureGroup;_.addLayer(c),u!==c&&(u._childCount>2?(u._updateIcon(),this._forceLayout(),this._animationStart(),c._setPos(this._map.latLngToLayerPoint(u.getLatLng())),c.clusterHide(),this._enqueue(function(){_.removeLayer(c),c.clusterShow(),i._animationEnd()})):(this._forceLayout(),i._animationStart(),i._animationZoomOutSingle(u,this._map.getMaxZoom(),this._zoom)))}},_animationZoomOutSingle:function(c,u,i){var _=this._getExpandedVisibleBounds(),j=Math.floor(this._map.getMinZoom());c._recursivelyAnimateChildrenInAndAddSelfToMap(_,j,u+1,i);var y=this;this._forceLayout(),c._recursivelyBecomeVisible(_,i),this._enqueue(function(){if(c._childCount===1){var x=c._markers[0];this._ignoreMove=!0,x.setLatLng(x.getLatLng()),this._ignoreMove=!1,x.clusterShow&&x.clusterShow()}else c._recursively(_,i,j,function(v){v._recursivelyRemoveChildrenFromMap(_,j,u+1)});y._animationEnd()})},_animationEnd:function(){this._map&&(this._map._mapPane.className=this._map._mapPane.className.replace(" leaflet-cluster-anim","")),this._inZoomAnimation--,this.fire("animationend")},_forceLayout:function(){L.Util.falseFn(document.body.offsetWidth)}}),L.markerClusterGroup=function(c){return new L.MarkerClusterGroup(c)};
755var l=L.MarkerCluster=L.Marker.extend({options:L.Icon.prototype.options,initialize:function(c,u,i,_){L.Marker.prototype.initialize.call(this,i?i._cLatLng||i.getLatLng():new L.LatLng(0,0),{icon:this,pane:c.options.clusterPane}),this._group=c,this._zoom=u,this._markers=[],this._childClusters=[],this._childCount=0,this._iconNeedsUpdate=!0,this._boundsNeedUpdate=!0,this._bounds=new L.LatLngBounds,i&&this._addChild(i),_&&this._addChild(_)},getAllChildMarkers:function(c,u){c=c||[];for(var i=this._childClusters.length-1;i>=0;i--)this._childClusters[i].getAllChildMarkers(c,u);for(var _=this._markers.length-1;_>=0;_--)u&&this._markers[_].__dragStart||c.push(this._markers[_]);return c},getChildCount:function(){return this._childCount},zoomToBounds:function(c){for(var u=this._childClusters.slice(),i=this._group._map,_=i.getBoundsZoom(this._bounds),j=this._zoom+1,y=i.getZoom(),x;u.length>0&&_>j;){j++;var v=[];for(x=0;x<u.length;x++)v=v.concat(u[x]._childClusters);u=v}_>j?this._group._map.setView(this._latlng,j):_<=y?this._group._map.setVie
755w(this._latlng,y+1):this._group._map.fitBounds(this._bounds,c)},getBounds:function(){var c=new L.LatLngBounds;return c.extend(this._bounds),c},_updateIcon:function(){this._iconNeedsUpdate=!0,this._icon&&this.setIcon(this)},createIcon:function(){return this._iconNeedsUpdate&&(this._iconObj=this._group.options.iconCreateFunction(this),this._iconNeedsUpdate=!1),this._iconObj.createIcon()},createShadow:function(){return this._iconObj.createShadow()},_addChild:function(c,u){this._iconNeedsUpdate=!0,this._boundsNeedUpdate=!0,this._setClusterCenter(c),c instanceof L.MarkerCluster?(u||(this._childClusters.push(c),c.__parent=this),this._childCount+=c._childCount):(u||this._markers.push(c),this._childCount++),this.__parent&&this.__parent._addChild(c,!0)},_setClusterCenter:function(c){this._cLatLng||(this._cLatLng=c._cLatLng||c._latlng)},_resetBounds:function(){var c=this._bounds;c._southWest&&(c._southWest.lat=1/0,c._southWest.lng=1/0),c._northEast&&(c._northEast.lat=-1/0,c._northEast.lng=-1/0)},_recalculateBounds:function(){var c=this._markers,u=this._childClusters,i=0,_=0,j=this._childCount,y,x,v,C;if(j!==0){for(this._resetBounds(),y=0;y<c.length;y++)v=c[y]._latlng,this._bounds.extend(v),i+=v.lat,_+=v.lng;for(y=0;y<u.length;y++)x=u[y],x._boundsNeedUpdate&&x._recalculateBounds(),this._bounds.extend(x._bounds),v=x._wLatLng,C=x._childCount,i+=v.lat*C,_+=v.lng*C;this._latlng=this._wLatLng=new L.LatLng(i/j,_/j),this._boundsNeedUpdate=!1}},_addToMap:function(c){c&&(this._backupLatlng=this._latlng,this.setLatLng(c)),this._group._featureGroup.addLayer(this)},_recursivelyAnimateChildrenIn:function(c,u,i){this._recursively(c,this._group._map.getMinZoom(),i-1,function(_){var j=_._markers,y,x;for(y=j.length-1;y>=0;y--)x=j[y],x._icon&&(x._setPos(u),x.clusterHide())},function(_){var j=_._childClusters,y,x;for(y=j.length-1;y>=0;y--)x=j[y],x._icon&&(x._setPos(u),x.clusterHide())})},_recursivelyAnimateChildrenInAndAddSelfToMap:function(c,u,i,_){this._recursively(c,_,u,function(j){j._recursivelyAnimateChildrenIn(c,j._group._map.latLngToLayerPoint(j.getLatLng()).round(),i),j._isSingleParent()&&i-1===_?(j.clusterShow(),j._recursivelyRemoveChildrenFromMap(c,u,i)):j.clusterHide(),j._addToMap()})},_recursivelyBecomeVisible:function(c,u){this._recursively(c,this._group._map.getMinZoom(),u,null,function(i){i.clusterShow()})},_recursivelyAddChildrenToMap:function(c,u,i){this._recursively(i,this._group._map.getMinZoom()-1,u,function(_){if(u!==_._zoom)for(var j=_._markers.length-1;j>=0;j--){var y=_._markers[j];i.contains(y._latlng)&&(c&&(y._backupLatlng=y.getLatLng(),y.setLatLng(c),y.clusterHide&&y.clusterHide()),_._group._featureGroup.addLayer(y))}},function(_){_._addToMap(c)})},_recursivelyRestoreChildPositions:function(c){for(var u=this._markers.length-1;u>=0;u--){var i=this._markers[u];i._backupLatlng&&(i.setLatLng(i._backupLatlng),delete i._backupLatlng)}if(c-1===this._zoom)for(var _=this._childClusters.length-1;_>=0;_--)this._childClusters[_]._restorePosition();else for(var j=this._childClusters.length-1;j>=0;j--)this._childClusters[j]._recursivelyRestoreChildPositions(c)},_restorePosition:function(){this._backupLatlng&&(this.setLatLng(this._backupLatlng),delete this._backupLatlng)},_recursivelyRemoveChildrenFromMap:function(c,u,i,_){var j,y;this._recursively(c,u-1,i-1,function(x){for(y=x._markers.length-1;y>=0;y--)j=x._markers[y],(!_||!_.contains(j._latlng))&&(x._group._featureGroup.removeLayer(j),j.clusterShow&&j.clusterShow())},function(x){for(y=x._childClusters.length-1;y>=0;y--)j=x._childClusters[y],(!_||!_.contains(j._latlng))&&(x._group._featureGroup.removeLayer(j),j.clusterShow&&j.clusterShow())})},_recursively:function(c,u,i,_,j){var y=this._childClusters,x=this._zoom,v,C;if(u<=x&&(_&&_(this),j&&x===i&&j(this)),x<u||x<i)for(v=y.length-1;v>=0;v--)C=y[v],C._boundsNeedUpdate&&C._recalculateBounds(),c.intersects(C._bounds)&&C._recursively(c,u,i,_,j)},_isSingleParent:function(){return this._childClusters.length>0&&this._childClusters[0]._childCount===this._childCount}});L.Marker.include({clusterHide:function(){var c=this.options.opacity;return this.setOpacity(0),this.options.opacity=c,this},clusterShow:function(){return this.setOpacity(this.options.opacity)}}),L.DistanceGrid=function(c){this._cellSize=c,this._sqCellSize=c*c,this._grid={},this._objectPoint={}},L.DistanceGrid.prototype={addObject:function(c,u){var i=this._getCoord(u.x),_=this._getCoord(u.
vendor: 6,456 bytes, line 755
755y),j=this._grid,y=j[_]=j[_]||{},x=y[i]=y[i]||[],v=L.Util.stamp(c);this._objectPoint[v]=u,x.push(c)},updateObject:function(c,u){this.removeObject(c),this.addObject(c,u)},removeObject:function(c,u){var i=this._getCoord(u.x),_=this._getCoord(u.y),j=this._grid,y=j[_]=j[_]||{},x=y[i]=y[i]||[],v,C;for(delete this._objectPoint[L.Util.stamp(c)],v=0,C=x.length;v<C;v++)if(x[v]===c)return x.splice(v,1),C===1&&delete y[i],!0},eachObject:function(c,u){var i,_,j,y,x,v,C,P=this._grid;for(i in P){x=P[i];for(_ in x)for(v=x[_],j=0,y=v.length;j<y;j++)C=c.call(u,v[j]),C&&(j--,y--)}},getNearObject:function(c){var u=this._getCoord(c.x),i=this._getCoord(c.y),_,j,y,x,v,C,P,I,z=this._objectPoint,F=this._sqCellSize,D=null;for(_=i-1;_<=i+1;_++)if(x=this._grid[_],x){for(j=u-1;j<=u+1;j++)if(v=x[j],v)for(y=0,C=v.length;y<C;y++)P=v[y],I=this._sqDist(z[L.Util.stamp(P)],c),(I<F||I<=F&&D===null)&&(F=I,D=P)}return D},_getCoord:function(c){var u=Math.floor(c/this._cellSize);return isFinite(u)?u:c},_sqDist:function(c,u){var i=u.x-c.x,_=u.y-c.y;return i*i+_*_}},function(){L.QuickHull={getDistant:function(c,u){var i=u[1].lat-u[0].lat,_=u[0].lng-u[1].lng;return _*(c.lat-u[0].lat)+i*(c.lng-u[0].lng)},findMostDistantPointFromBaseLine:function(c,u){var i=0,_=null,j=[],y,x,v;for(y=u.length-1;y>=0;y--){if(x=u[y],v=this.getDistant(x,c),v>0)j.push(x);else continue;v>i&&(i=v,_=x)}return{maxPoint:_,newPoints:j}},buildConvexHull:function(c,u){var i=[],_=this.findMostDistantPointFromBaseLine(c,u);return _.maxPoint?(i=i.concat(this.buildConvexHull([c[0],_.maxPoint],_.newPoints)),i=i.concat(this.buildConvexHull([_.maxPoint,c[1]],_.newPoints)),i):[c[0]]},getConvexHull:function(c){var u=!1,i=!1,_=!1,j=!1,y=null,x=null,v=null,C=null,P=null,I=null,z;for(z=c.length-1;z>=0;z--){var F=c[z];(u===!1||F.lat>u)&&(y=F,u=F.lat),(i===!1||F.lat<i)&&(x=F,i=F.lat),(_===!1||F.lng>_)&&(v=F,_=F.lng),(j===!1||F.lng<j)&&(C=F,j=F.lng)}i!==u?(I=x,P=y):(I=C,P=v);var D=[].concat(this.buildConvexHull([I,P],c),this.buildConvexHull([P,I],c));return D}}}(),L.MarkerCluster.include({getConvexHull:function(){var c=this.getAllChildMarkers(),u=[],i,_;for(_=c.length-1;_>=0;_--)i=c[_].getLatLng(),u.push(i);return L.QuickHull.getConvexHull(u)}}),L.MarkerCluster.include({_2PI:Math.PI*2,_circleFootSeparation:25,_circleStartAngle:0,_spiralFootSeparation:28,_spiralLengthStart:11,_spiralLengthFactor:5,_circleSpiralSwitchover:9,spiderfy:function(){if(!(this._group._spiderfied===this||this._group._inZoomAnimation)){var c=this.getAllChildMarkers(null,!0),u=this._group,i=u._map,_=i.latLngToLayerPoint(this._latlng),j;this._group._unspiderfy(),this._group._spiderfied=this,this._group.options.spiderfyShapePositions?j=this._group.options.spiderfyShapePositions(c.length,_):c.length>=this._circleSpiralSwitchover?j=this._generatePointsSpiral(c.length,_):(_.y+=10,j=this._generatePointsCircle(c.length,_)),this._animationSpiderfy(c,j)}},unspiderfy:function(c){this._group._inZoomAnimation||(this._animationUnspiderfy(c),this._group._spiderfied=null)},_generatePointsCircle:function(c,u){var i=this._group.options.spiderfyDistanceMultiplier*this._circleFootSeparation*(2+c),_=i/this._2PI,j=this._2PI/c,y=[],x,v;for(_=Math.max(_,35),y.length=c,x=0;x<c;x++)v=this._circleStartAngle+x*j,y[x]=new L.Point(u.x+_*Math.cos(v),u.y+_*Math.sin(v))._round();return y},_generatePointsSpiral:function(c,u){var i=this._group.options.spiderfyDistanceMultiplier,_=i*this._spiralLengthStart,j=i*this._spiralFootSeparation,y=i*this._spiralLengthFactor*this._2PI,x=0,v=[],C;for(v.length=c,C=c;C>=0;C--)C<c&&(v[C]=new L.Point(u.x+_*Math.cos(x),u.y+_*Math.sin(x))._round()),x+=j/_+C*5e-4,_+=y/x;return v},_noanimationUnspiderfy:function(){var c=this._group,u=c._map,i=c._featureGroup,_=this.getAllChildMarkers(null,!0),j,y;for(c._ignoreMove=!0,this.setOpacity(1),y=_.length-1;y>=0;y--)j=_[y],i.removeLayer(j),j._preSpiderfyLatlng&&(j.setLatLng(j._preSpiderfyLatlng),delete j._preSpiderfyLatlng),j.setZIndexOffset&&j.setZIndexOffset(0),j._spiderLeg&&(u.removeLayer(j._spiderLeg),delete j._spiderLeg);c.fire("unspiderfied",{cluster:this,markers:_}),c._ignoreMove=!1,c._spiderfied=null}}),L.MarkerClusterNonAnimated=L.MarkerCluster.extend({_animationSpiderfy:function(c,u){var i=this._group,_=i._map,j=i._featureGroup,y=this._group.options.spiderLegPolylineOptions,x,v,C,P;for(i._ignoreMove=!0,x=0;x<c.length;x++)P=_.layerPointToLatLng(u[x]),v=c[x],C=new L.Polyline([this._latlng,P],y),_.addLayer(C),v._spiderLeg=C,v._preSpiderfyLatlng=v._latlng,v.setLatLng(P),v.setZIndexOffset&&v.setZIndexOffset(1e6),j.addLayer(v);this.setOpacity(.3),i._ignoreMove=!1,i.fire("spiderfied",{cluster:this,markers:c})},_animationUnspiderfy:function(){this._noanimationUnspiderfy()}}),L.MarkerCluster.include({_animationSpiderfy:function(c,u){var i=this,_=this._group,j=_._map,y=_._featureGroup,x=this._latlng,v=j.latLngToLayerPoint(x),C=L.Path.SVG,P=L.extend({},this._group.options.spiderLegPolylineOptions),I=P.opacity,z,F,D,X,K,te;for(I===void 0&&(I=L.MarkerClusterGroup.prototype.options.spiderLegPolylineOptions.opacity),C?(P.opacity=0,P.className=(P.className||"")+" leaflet-cluster-spider-leg"):P.opacity=I,_._ignoreMove=!0,z=0;z<c.length;z++)F=c[z],te=j.layerPointToLatLng(u[z]),D=new L.Polyline([x,te],P),j.addLayer(D),F._spiderLeg=D,C&&(X=D._path,K=X.getTotalLength()+.1,X.style.strokeDasharray=K,X.style.strokeDashoffset=K),F.setZIndexOffset&&F.setZIndexOffset(1e6),F.clusterHide&&F.clusterHide(),y.addLayer(F),F._setPos&&F._setPos(v);for(_._forceLayout(),_._animationStart(),z=c.length-1;z>=0;z--)te=j.layerPointToLatLng(u[z]),F=c[z],F._preSpiderfyLatlng=F._latlng,F.setLatLng(te),F.clusterShow&&F.clusterShow(),C&&(D=F._spiderLeg,X=D._path,X.style.strokeDashoffset=0,D.setStyle({opacity:I}));this.setOpacity(.3),_._ignoreMove=!1,setTimeout(function(){_._animationEnd(),_.fire("spiderfied",{cluster:i,markers:c})},200)},_animationUnspiderfy:function(c){var u=this,i=this._group,_=i._map,j=i._featureGroup,y=c?_._latLngToNewLayerPoint(this._latlng,c.zoom,c.center):_.latLngToLayerPoint(this._latlng),x=this.getAllChildMarkers(null,!0),v=L.Path.SVG,C,P,I,z,F,D;for(i._ignoreMove=!0,i._animationStart(),this.setOpacity(1),P=x.length-1;P>=0;P--)C=x[P],C._preSpiderfyLatlng&&(C.closePopup(),C.setLatLng(C._preSpiderfyLatlng),delete C._preSpiderfyLatlng,D=!0,C._setPos&&(C._setPos(y),D=!1),C.clusterHide&&(C.clusterHide(),D=!1),D&&j.removeLayer(C),v&&(I=C._spiderLeg,z=I._path,F=z.getTotalLength()+.1,z.style.strokeDashoffset=F,I.setStyle({opacity:0}
vendor: 2,706 bytes, line 755
755)));i._ignoreMove=!1,setTimeout(function(){var X=0;for(P=x.length-1;P>=0;P--)C=x[P],C._spiderLeg&&X++;for(P=x.length-1;P>=0;P--)C=x[P],C._spiderLeg&&(C.clusterShow&&C.clusterShow(),C.setZIndexOffset&&C.setZIndexOffset(0),X>1&&j.removeLayer(C),_.removeLayer(C._spiderLeg),delete C._spiderLeg);i._animationEnd(),i.fire("unspiderfied",{cluster:u,markers:x})},200)}}),L.MarkerClusterGroup.include({_spiderfied:null,unspiderfy:function(){this._unspiderfy.apply(this,arguments)},_spiderfierOnAdd:function(){this._map.on("click",this._unspiderfyWrapper,this),this._map.options.zoomAnimation&&this._map.on("zoomstart",this._unspiderfyZoomStart,this),this._map.on("zoomend",this._noanimationUnspiderfy,this),L.Browser.touch||this._map.getRenderer(this)},_spiderfierOnRemove:function(){this._map.off("click",this._unspiderfyWrapper,this),this._map.off("zoomstart",this._unspiderfyZoomStart,this),this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._map.off("zoomend",this._noanimationUnspiderfy,this),this._noanimationUnspiderfy()},_unspiderfyZoomStart:function(){this._map&&this._map.on("zoomanim",this._unspiderfyZoomAnim,this)},_unspiderfyZoomAnim:function(c){L.DomUtil.hasClass(this._map._mapPane,"leaflet-touching")||(this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._unspiderfy(c))},_unspiderfyWrapper:function(){this._unspiderfy()},_unspiderfy:function(c){this._spiderfied&&this._spiderfied.unspiderfy(c)},_noanimationUnspiderfy:function(){this._spiderfied&&this._spiderfied._noanimationUnspiderfy()},_unspiderfyLayer:function(c){c._spiderLeg&&(this._featureGroup.removeLayer(c),c.clusterShow&&c.clusterShow(),c.setZIndexOffset&&c.setZIndexOffset(0),this._map.removeLayer(c._spiderLeg),delete c._spiderLeg)}}),L.MarkerClusterGroup.include({refreshClusters:function(c){return c?c instanceof L.MarkerClusterGroup?c=c._topClusterLevel.getAllChildMarkers():c instanceof L.LayerGroup?c=c._layers:c instanceof L.MarkerCluster?c=c.getAllChildMarkers():c instanceof L.Marker&&(c=[c]):c=this._topClusterLevel.getAllChildMarkers(),this._flagParentsIconsNeedUpdate(c),this._refreshClustersIcons(),this.options.singleMarkerMode&&this._refreshSingleMarkerModeMarkers(c),this},_flagParentsIconsNeedUpdate:function(c){var u,i;for(u in c)for(i=c[u].__parent;i;)i._iconNeedsUpdate=!0,i=i.__parent},_refreshSingleMarkerModeMarkers:function(c){var u,i;for(u in c)i=c[u],this.hasLayer(i)&&i.setIcon(this._overrideMarkerIcon(i))}}),L.Marker.include({refreshIconOptions:function(c,u){var i=this.options.icon;return L.setOptions(i,c),this.setIcon(i),u&&this.__parent&&this.__parent._group.refreshClusters(this),this}}),n.MarkerClusterGroup=a,n.MarkerCluster=l,Object.defineProperty(n,"__esModule",{value:!0})})}
vendor: 13,352 bytes, line 755
755)(ak,ak.exports);const rk=L.extend({},L.DomUtil);L.extend(L.DomUtil,{setTransform:function(t,s,n,a,l){var c=s||new L.Point(0,0);if(!a)return s=c._round(),rk.setTransform.apply(this,arguments);c=c.rotateFrom(a,l),t.style[L.DomUtil.TRANSFORM]="translate3d("+c.x+"px,"+c.y+"px,0)"+(n?" scale("+n+")":"")+" rotate("+a+"rad)"},setPosition:function(t,s,n,a,l){if(!n)return rk.setPosition.apply(this,arguments);t._leaflet_pos=s,L.Browser.any3d?L.DomUtil.setTransform(t,s,l,n,a):(t.style.left=s.x+"px",t.style.top=s.y+"px")},DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI});L.Draggable.include({});L.extend(L.Point.prototype,{rotate:function(t){return this.rotateFrom(t,new L.Point(0,0))},rotateFrom:function(t,s){if(!t)return this;var n=Math.sin(t),a=Math.cos(t),l=s.x,c=s.y,u=this.x-l,i=this.y-c;return new L.Point(u*a-i*n+l,u*n+i*a+c)}});const ik=L.extend({},L.DivOverlay.prototype);L.DivOverlay.include({getEvents:function(){return L.extend(ik.getEvents.apply(this,arguments),{rotate:this._updatePosition})},_updatePosition:function(){if(this._map&&(ik._updatePosition.apply(this,arguments),this._map&&this._map._rotate&&this._zoomAnimated)){var t=this._getAnchor(),s=L.DomUtil.getPosition(this._container).subtract(t);L.DomUtil.setPosition(this._container,this._map.rotatedPointToMapPanePoint(s).add(t))}}});const gD=L.extend({},L.Popup.prototype);L.Popup.include({_animateZoom:function(t){if(gD._animateZoom.apply(this,arguments),this._map&&this._map._rotate){var s=this._getAnchor(),n=L.DomUtil.getPosition(this._container).subtract(s);L.DomUtil.setPosition(this._container,this._map.rotatedPointToMapPanePoint(n).add(s))}},_adjustPan:function(){if(!(!this.options.autoPan||this._map._panAnim&&this._map._panAnim._inProgress)){if(this._autopanning){this._autopanning=!1;return}var t=this._map,s=parseInt(L.DomUtil.getStyle(this._container,"marginBottom"),10)||0,n=this._container.offsetHeight+s,a=this._containerWidth,l=new L.Point(this._containerLeft,-n-this._containerBottom);l._add(L.DomUtil.getPosition(this._container));var c=l._add(this._map._getMapPanePos()),u=L.point(this.options.autoPanPadding),i=L.point(this.options.autoPanPaddingTopLeft||u),_=L.point(this.options.autoPanPaddingBottomRight||u),j=t.getSize(),y=0,x=0;c.x+a+_.x>j.x&&(y=c.x+a-j.x+_.x),c.x-y-i.x<0&&(y=c.x-i.x),c.y+n+_.y>j.y&&(x=c.y+n-j.y+_.y),c.y-x-i.y<0&&(x=c.y-i.y),(y||x)&&(this.options.keepInView&&(this._autopanning=!0),t.fire("autopanstart").panBy([y,x]))}}});const ok=L.extend({},L.Tooltip.prototype);L.Tooltip.include({_animateZoom:function(t){if(!this._map._rotate)return ok._animateZoom.apply(this,arguments);var s=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center);s=this._map.rotatedPointToMapPanePoint(s),this._setPosition(s)},_updatePosition:function(){if(!this._map._rotate)return ok._updatePosition.apply(this,arguments);var t=this._map.latLngToLayerPoint(this._latlng);t=this._map.rotatedPointToMapPanePoint(t),this._setPosition(t)}});L.extend({},L.Icon.prototype);L.Icon.include({_setIconStyles:function(t,s){var n=this.options,a=n[s+"Size"];typeof a=="number"&&(a=[a,a]);var l=L.point(a),c=L.point(s==="shadow"&&n.shadowAnchor||n.iconAnchor||l&&l.divideBy(2,!0));t.className="leaflet-marker-"+s+" "+(n.className||""),c&&(t.style.marginLeft=-c.x+"px",t.style.marginTop=-c.y+"px",t.style[L.DomUtil.TRANSFORM+"Origin"]=c.x+"px "+c.y+"px 0px"),l&&(t.style.width=l.x+"px",t.style.height=l.y+"px")}});const lk=L.extend({},L.Marker.prototype);L.Marker.mergeOptions({rotation:0,rotateWithView:!1,scale:void 0});var Qb,ck={_onDrag:function(t){var s=this._marker,n=s.options.rotation||s.options.rotateWithView,a=s._shadow,l=L.DomUtil.getPosition(s._icon);!n&&a&&L.DomUtil.setPosition(a,l),s._map._rotate&&(l=s._map.mapPanePointToRotatedPoint(l));var c=s._map.layerPointToLatLng(l);s._latlng=c,t.latlng=c,t.oldLatLng=this._oldLatLng,n?s.setLatLng(c):s.fire("move",t),s.fire("drag",t)},_onDragEnd:function(t){this._marker._map._rotate&&this._marker.update(),Qb._onDragEnd.apply(this,arguments)}};L.Marker.include({getEvents:function(){return L.extend(lk.getEvents.apply(this,arguments),{rotate:this.update})},_initInteraction:function(){var t=lk._initInteraction.apply(this,arguments);return this.dragging&&this.dragging.enabled()&&this._map&&this._map._rotate&&(Qb=Qb||Object.getPrototypeOf(this.dragging),this.dragging.disable(),Object.assign(this.dragging,{_onDrag:ck._onDrag.bind(this.dragging),_onDragEnd:ck._onDragEnd.bind(this.dragging)}),this.dragging.enable()),t},_setPos:function(t){this._map._rotate&&(t=this._map.rotatedPointToMapPanePoint(t));var s=this.options.rotation||0;this.options.rotateWithView&&(s+=this._map._bearing),this._icon&&L.DomUtil.setPosition(this._icon,t,s,t,this.options.scale),this._shadow&&L.DomUtil.setPosition(this._shadow,t,s,t,this.options.scale),this._zIndex=t.y+this.options.zIndexOffset,this._resetZIndex()},setRotation:function(t){this.options.rotation=t,this.update()}});const dk=L.extend({},L.GridLayer.prototype);L.GridLayer.include({getEvents:function(){var t=dk.getEvents.apply(this,arguments);return this._map._rotate&&!this.options.updateWhenIdle&&(this._onRotate||(this._onRotate=L.Util.throttle(this._onMoveEnd,this.options.updateInterval,this)),t.rotate=this._onRotate),t},_getTiledPixelBounds:function(t){return this._map._rotate?this._map._getNewPixelBounds(t,this._tileZoom):dk._getTiledPixelBounds.apply(this,arguments)}});const q_=L.extend({},L.Renderer.prototype);L.Renderer.include({getEvents:function(){return L.extend(q_.getEvents.apply(this,arguments),{rotate:this._update})},onAdd:function(){q_.onAdd.apply(this,arguments),L.version<="1.9.3"&&this._container.classList.add("leaflet-zoom-animated")},_updateTransform:function(t,s){if(!this._map._rotate)return q_._updateTransform.apply(this,arguments);var n=this._map.getZoomScale(s,this._zoom),a=this._map._latLngToNewLayerPoint(this._topLeft,s,t);L.DomUtil.setTransform(this._container,a,n)},_update:function(){if(!this._map._rotate)return q_._update.apply(this,arguments);this._bounds=this._map._getPaddedPixelBounds(this.options.padding),this._topLeft=this._map.layerPointToLatLng(this._bounds.min),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}});const Sd=L.extend({},L.Map.prototype);L.Map.mergeOptions({rotate:!1,bearing:0});L.Map.include({initialize:function(t,s){s.rotate&&(this._rotate=!0,this._bearing=0),Sd.initialize.apply(this,arguments),this.options.rotate&&this.setBearing(this.options.bearing)},containerPointToLayerPoint:function(t){return this._rotate?L.point(t).subtract(this._getMapPanePos()).rotateFrom(-this._bearing,this._getRotatePanePos()).subtract(this._getRotatePanePos()):Sd.containerPointToLayerPoint.apply(this,arguments)},layerPointToContainerPoint:function(t){return this._rotate?L.point(t).add(this._getRotatePanePos()).rotateFrom(this._bearing,this._getRotatePanePos()).add(this._getMapPanePos()):Sd.layerPointToContainerPoint.apply(this,arguments)},rotatedPointToMapPanePoint:function(t){return L.point(t).rotate(this._bearing)._add(this._getRotatePanePos())},mapPanePointToRotatedPoint:function(t){return L.point(t)._subtract(this._getRotatePanePos()).rotate(-this._bearing)},mapBoundsToContainerBounds:function(t){if(!this._rotate&&Sd.mapBoundsToContainerBounds)return Sd.mapBoundsToContainerBounds.apply(this,arguments);const s=this.getPixelOrigin(),n=this.layerPointToContainerPoint(this.project(t.getNorthWest())._subtract(s)),a=this.layerPointToContainerPoint(this.project(t.getNorthEast())._subtract(s)),l=this.layerPointToContainerPoint(this.project(t.getSouthWest())._subtract(s)),c=this.layerPointToContainerPoint(this.project(t.getSouthEast())._subtract(s));return L.bounds([L.point(Math.min(n.x,a.x,c.x,l.x),Math.min(n.y,a.y,c.y,l.y)),L.point(Math.max(n.x,a.x,c.x,l.x),Math.max(n.y,a.y,c.y,l.y))])},getBounds:function(){if(!this._rotate)return Sd.getBounds.apply(this,arguments);var t=this.getSize();return new L.LatLngBounds([this.containerPointToLatLng([0,0]),this.containerPointToLatLng([t.x,0]),this.containerPointToLatLng([t.x,t.y]),this.containerPointToLatLng([0,t.y])])},setBearing:function(t){if(!(!L.Browser.any3d||!this._rotate)){var s=L.Util.wrapNum(t,[0,360])*L.DomUtil.DEG_TO_RAD,n=this._getPixelCenter(),a=this._getRotatePanePos().rotateFrom(-this._bearing,n),l=a.rotateFrom(s,n);L.DomUtil.setPosition(this._rotatePane,a,s,n),this._pivot=n,this._bearing=s,this._rotatePanePos=l,this.fire("rotate")}},getBearing:function(){return this._bearing*L.DomUtil.RAD_TO_DEG},_initPanes:function(){var t=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),L.DomUtil.setPosition(this._mapPane,new L.Point(0,0)),this._rotate?(this._rotatePane=this.createPane("rotatePane",this._mapPane),this._norotatePane=this.createPane("norotatePane",this._mapPane),this.createPane("tilePane",this._rotatePane),this.createPane("overlayPane",this._rotatePane),this.createPane("shadowPane",this._norotatePane),this.createPane("markerPane",this._norotatePane),this.createPane("tooltipPane",this._norotatePane),this.createPane("popupPane",this._norotatePane)):(this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane")),this.options.markerZoomAnimation||(L.DomUtil.addClass(t.markerPane,"leaflet-zoom-hide"),L.DomUtil.addClass(t.shadowPane,"leaflet-zoom-hide"))},panInside(t,s){if(!this._rotate||Math.abs(this._bearing).toFixed(1)<.1)return Sd.panInside.apply(this,arguments);s=s||{};const n=L.point(s.paddingTopLeft||s.padding||[0,0]),a=L.point(s.paddingBottomRight||s.padding||[0,0]),l=this._container.getBoundingClientRect(),c=this.latLngToContainerPoint(t),u=L.bounds([L.point(l),L.point(l).add(this.getSize())]),i=u.getCenter(),_=L.bounds([u.min.add(n),u.max.subtract(a)]),j=_.getSize();if(!_.contains(c)){this._enforcingBounds=!0;const y=c.subtract(_.getCenter()),x=_.extend(c).getSize().subtract(j);i.x+=y.x<0?-x.x:x.x,i.y+=y.y<0?-x.y:x.y,this.panTo(this.containerPointToLatLng(i),s),this._enforcingBounds=!1}return this},getBoundsZoom(t,s,n){if(!this._rotate||Math.abs(this._bearing).toFixed(1)<.1)return Sd.getBoundsZoom.apply(this,arguments);t=L.latLngBounds(t),n=L.point(n||[0,0]);let a=this.getZoom()||0;const l=this.getMinZoom(),c=this.getMaxZoom(),u=this.getSize().subtract(n),i=this.mapBoundsToContainerBounds(t).getSize(),_=this.options.zoomSnap,j=u.x/i.x,y=u.y/i.y,x=s?Math.max(j,y):Math.min(j,y);return a=this.getScaleZoom(x,a),_&&(a=Math.round(a/(_/100))*(_/100),a=s?Math.ceil(a/_)*_:Math.floor(a/_)*_),Math.max(l,Math.min(c,a))},_getCenterOffset:function(t){var s=Sd._getCenterOffset.apply(this,arguments);return this._rotate&&(s=s.rotate(this._bearing)),s},_getRotatePanePos:function(){return this._rotatePanePos||new L.Point(0,0)},_getNewPixelOrigin:function(t,s){if(!this._rotate)return Sd._getNewPixelOrigin.apply(this,arguments);var n=this.getSize()._divideBy(2);return this.project(t,s).rotate(this._bearing)._subtract(n)._add(this._getMapPanePos())._add(this._getRotatePanePos()).rotate(-this._bearing)._round()},_getNewPixelBounds:function(t,s){if(t=t||this.getCenter(),s=s||this.getZoom(),!this._rotate&&Sd._getNewPixelBounds)return Sd._getNewPixelBounds.apply(this,arguments);var n=this._animatingZoom?Math.max(this._animateToZoom,this.getZoom()):this.getZoom(),a=this.getZoomScale(n,s),l=this.project(t,s).floor(),c=this.getSize(),u=new L.Bounds([this.containerPointToLayerPoint([0,0]).floor(),this.containerPointToLayerPoint([c.x,0]).floor(),this.containerPointToLayerPoint([0,c.y]).floor(),this.containerPointToLayerPoint([c.x,c.y]).floor()]).getSize().divideBy(a*2);return new L.Bounds(l.subtract(u),l.add(u))},_getPixelCenter:function(){return!this._rotate&&Sd._getPixelCenter?Sd._getPixelCenter.apply(this,arguments):this.getSize()._divideBy(2)._subtract(this._getMapPanePos())},_getPaddedPixelBounds:function(t){if(!this._rotate&&Sd._getPaddedPixelBounds)return Sd._getPaddedPixelBounds.apply(this,arguments);var s=t,n=this.getSize(),a=n.multiplyBy(-s),l=n.multiplyBy(1+s);return new L.Bounds([this.containerPointToLayerPoint([a.x,a.y]).floor(),this.containerPointToLayerPoint([a.x,l.y]).floor(),this.containerPointToLayerPoint([l.x,a.y]).floor(),this.containerPointToLayerPoint([l.x,l.y]).floor()])},_handleGeolocationResponse:function(t){if(this._container._leaflet_id){var s=t.coords.latitude,n=t.coords.longitude,a=t.coords.heading,l=new L.LatLng(s,n),c=l.toBounds(t.coords.accuracy),u=this._locateOptions;if(u.setView){var i=this.getBoundsZoom(c);this.setView(l,u.maxZoom?Math.min(i,u.maxZoom):i)}var _={latlng:l,bounds:c,timestamp:t.timestamp,heading:a};for(var j in t.coords)typeof t.coords[j]=="number"&&(_[j]=t.coords[j]);this.fire("locationfound",_)}}});L.Map.CompassBearing=L.Handler.extend({initialize:function(t){this._map=t,"ondeviceorientationabsolute"in window?this.__deviceOrientationEvent="deviceorientationabsolute":"ondeviceorientation"in window&&(this.__deviceOrientationEvent="deviceorientation"),this._throttled=L.Util.throttle(this._onDeviceOrientation,100,this)},addHooks:function(){this._map._rotate&&this.__deviceOrientationEvent?L.DomEvent.on(window,this.__deviceOrientationEvent,this._throttled,this):this.disable()},removeHooks:function(){this._map._rotate&&this.__deviceOrientationEvent&&L.DomEvent.off(window,this.__deviceOrientationEvent,this._throttled,this)}
755,_onDeviceOrientation:function(t){var s=t.webkitCompassHeading||t.alpha,n=0;!t.absolute&&t.webkitCompassHeading&&(s=360-s),!t.absolute&&typeof window.orientation<"u"&&(n=window.orientation),this._map.setBearing(s-n)}});L.Map.addInitHook("addHandler","compassBearing",L.Map.CompassBearing);L.Map.mergeOptions({trackContainerMutation:!1});L.Map.ContainerMutation=L.Handler.extend({addHooks:function(){this._observer||(this._observer=new MutationObserver(L.Util.bind(this._map.invalidateSize,this._map))),this._observer.observe(this._map.getContainer(),{childList:!1,attributes:!0,characterData:!1,subtree:!1,attributeFilter:["style"]})},removeHooks:function(){this._observer.disconnect()}});L.Map.addInitHook("addHandler","trackContainerMutation",L.Map.ContainerMutation);L.Map.mergeOptions({bounceAtZoomLimits:!0});L.Map.TouchGestures=L.Handler.extend({initialize:function(t){this._map=t,this.rotate=!!this._map.options.touchRotate,this.zoom=!!this._map.options.touchZoom},addHooks:function(){L.DomEvent.on(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){L.DomEvent.off(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(t){var s=this._map;if(!(!t.touches||t.touches.length!==2||s._animatingZoom||this._zooming||this._rotating)){var n=s.mouseEventToContainerPoint(t.touches[0]),a=s.mouseEventToContainerPoint(t.touches[1]),l=n.subtract(a);this._centerPoint=s.getSize()._divideBy(2),this._startLatLng=s.containerPointToLatLng(this._centerPoint),this.zoom?(s.options.touchZoom!=="center"&&(this._pinchStartLatLng=s.containerPointToLatLng(n.add(a)._divideBy(2))),this._startDist=n.distanceTo(a),this._startZoom=s.getZoom(),this._zooming=!0):this._zooming=!1,this.rotate?(this._startTheta=Math.atan(l.x/l.y),this._startBearing=s.getBearing(),l.y<0&&(this._startBearing+=180),this._rotating=!0):this._rotating=!1,this._moved=!1,s._stop(),L.DomEvent.on(document,"touchmove",this._onTouchMove,this).on(document,"touchend touchcancel",this._onTouchEnd,this),L.DomEvent.preventDefault(t)}},_onTouchMove:function(t){if(!(!t.touches||t.touches.length!==2||!(this._zooming||this._rotating))){var s=this._map,n=s.mouseEventToContainerPoint(t.touches[0]),a=s.mouseEventToContainerPoint(t.touches[1]),l=n.subtract(a),c=n.distanceTo(a)/this._startDist,u;if(this._rotating){var i=Math.atan(l.x/l.y),_=(i-this._startTheta)*L.DomUtil.RAD_TO_DEG;l.y<0&&(_+=180),_&&s.setBearing(this._startBearing-_)}if(this._zooming)if(this._zoom=s.getScaleZoom(c,this._startZoom),!s.options.bounceAtZoomLimits&&(this._zoom<s.getMinZoom()&&c<1||this._zoom>s.getMaxZoom()&&c>1)&&(this._zoom=s._limitZoom(this._zoom)),s.options.touchZoom==="center"){if(this._center=this._startLatLng,c===1)return}else{if(u=n._add(a)._divideBy(2)._subtract(this._centerPoint),c===1&&u.x===0&&u.y===0)return;var j=-s.getBearing()*L.DomUtil.DEG_TO_RAD;this._center=s.unproject(s.project(this._pinchStartLatLng).subtract(u.rotate(j)))}this._moved||(s._moveStart(!0,!1),this._moved=!0),L.Util.cancelAnimFrame(this._animRequest);var y=s._move.bind(s,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=L.Util.requestAnimFrame(y,this,!0),L.DomEvent.preventDefault(t)}},_onTouchEnd:function(){if(!this._moved||!(this._zooming||this._rotating)){this._zooming=!1;return}this._zooming=!1,this._rotating=!1,L.Util.cancelAnimFrame(this._animRequest),L.DomEvent.off(document,"touchmove",this._onTouchMove,this).off(document,"touchend touchcancel",this._onTouchEnd,this),this.zoom&&(this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom)))}});L.Map.addInitHook("addHandler","touchGestures",L.Map.TouchGestures);L.Map.mergeOptions({touchRotate:!1});L.Map.TouchRotate=L.Handler.extend({addHooks:function(){this._map.touchGestures.enable(),this._map.touchGestures.rotate=!0},removeHooks:function(){this._map.touchGestures.rotate=!1}});L.Map.addInitHook("addHandler","touchRotate",L.Map.TouchRotate);L.Map.mergeOptions({shiftKeyRotate:!0});L.Map.ShiftKeyRotate=L.Handler.extend({addHooks:function(){L.DomEvent.on(this._map._container,"wheel",this._handleShiftScroll,this),this._map.shift
755KeyRotate.rotate=!0},removeHooks:function(){L.DomEvent.off(this._map._container,"wheel",this._handleShiftScroll,this),this._map.shiftKeyRotate.rotate=!1},_handleShiftScroll:function(t){t.shiftKey?(t.preventDefault(),this._map.scrollWheelZoom.disable(),this._map.setBearing(this._map._bearing*L.DomUtil.RAD_TO_DEG+Math.sign(t.deltaY)*5)):this._map.scrollWheelZoom.enable()}});L.Map.addInitHook("addHandler","shiftKeyRotate",L.Map.ShiftKeyRotate);L.Map.addInitHook(function(){this.scrollWheelZoom.enabled()&&this.shiftKeyRotate.enabled()&&(this.scrollWheelZoom.disable(),this.scrollWheelZoom.enable())});L.Map.mergeOptions({touchZoom:L.Browser.touch,bounceAtZoomLimits:!1});L.Map.TouchZoom=L.Handler.extend({addHooks:function(){L.DomUtil.addClass(this._map._container,"leaflet-touch-zoom"),this._map.touchGestures.enable(),this._map.touchGestures.zoom=!0},removeHooks:function(){L.DomUtil.removeClass(this._map._container,"leaflet-touch-zoom"),this._map.touchGestures.zoom=!1}});L.Map.addInitHook("addHandler","touchZoom",L.Map.TouchZoom);L.Control.Rotate=L.Control.extend({options:{position:"topleft",closeOnZeroBearing:!0},onAdd:function(t){var s=this._container=L.DomUtil.create("div","leaflet-control-rotate leaflet-bar"),n=this._arrow=L.DomUtil.create("span","leaflet-control-rotate-arrow");n.style.backgroundImage=`url("data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E%3C/svg%3E")`,n.style.cursor="grab",n.style.display="block",n.style.width="100%",n.style.height="100%",n.style.backgroundRepeat="no-repeat",n.style.backgroundPosition="50%";var a=this._link=L.DomUtil.create("a","leaflet-control-rotate-toggle",s);return a.appendChild(n),a.href="#",a.title="Rotate map",L.DomEvent.on(a,"dblclick",L.DomEvent.stopPropagation).on(a,"mousedown",this._handleMouseDown,this).on(a,"click",L.DomEvent.stop).on(a,"click",this._cycleState,this).on(a,"click",this._refocusOnMap,this),L.Browser.any3d||L.DomUtil.addClass(a,"leaflet-disabled"),this._restyle(),t.on("rotate",this._restyle,this),this._follow=!1,this._canFollow=!1,this.options.closeOnZeroBearing&&t.getBearing()===0&&(s.style.display="none"),s},onRemove:function(t){t.off("rotate",this._restyle,this)},_handleMouseDown:function(t){L.DomEvent.stop(t),this.dragging=!0,this.dragstartX=t.pageX,this.dragstartY=t.pageY,L.DomEvent.on(document,"mousemove",this._handleMouseDrag,this).on(document,"mouseup",this._handleMouseUp,this)},_handleMouseUp:function(t){L.DomEvent.stop(t),this.dragging=!1,L.DomEvent.off(document,"mousemove",this._handleMouseDrag,this).off(document,"mouseup",this._handleMouseUp,this)},_handleMouseDrag:function(t){if(this.dragging){var s=t.clientX-this.dragstartX;this._map.setBearing(s)}},_cycleState:function(t){if(this._map){var s=this._map;!s.touchRotate.enabled()&&!s.compassBearing.enabled()?s.touchRotate.enable():s.compassBearing.enabled()?(s.compassBearing.disable(),s.setBearing(0),this.options.closeOnZeroBearing&&s.touchRotate.enable()):(s.touchRotate.disable(),s.compassBearing.enable()),this._restyle()}},_restyle:function(){if(!this._map.options.rotate)L.DomUtil.addClass(this._link,"leaflet-disabled");else{var t=this._map,s=t.getBearing();this._arrow.style.transform="rotate("+s+"deg)",s&&this.options.closeOnZeroBearing&&(this._container.style.display="block"),t.compassBearing.enabled()?this._link.style.backgroundColor="orange":t.touchRotate.enabled()?this._link.style.backgroundColor=null:(this._link.style.backgroundColor="grey",s===0&&this.options.closeOnZeroBearing&&(this._container.style.display="none"))}}});L.control.rotate=function(t){return new L.Control.Rotate(t)};L.Map.mergeOptions({rotateControl:!0});L.Map.addInitHook(function(){if(this.options.rotateControl){var t=typeof this.options.rotateControl=="object"?this.options.rotateControl:{};this.rotateControl=L.control.rotate(t),this.addControl(this.rotateControl)}});const B0=({modal:t=!0,...s})=>e.jsx(YC,{modal:t,...s}),xD=o5,_D=XC,RE=k.forwardRef(({className:t,...s},n)=>e.jsx(C1,{className:fs("fixed inset-0 z-[9999] bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:n}));RE.displayName=C1.displayName;const yD=$C("fixed z-[9999] gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4  border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),m_=k.forwardRef(({side:t="right",className:s,children:n,hideOverlay:a=!1,hideCloseButton:l=!1,...c},u)=>e.jsxs(_D,{children:[!a&&e.jsx(RE,{}),e.jsxs(S1,{ref:u,className:fs(yD({side:t}),s),...c,children:[n,!l&&e.jsxs(i5,{className:"absolute right-4 top-4 roun
755ded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(ja,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));m_.displayName=S1.displayName;const $0=({className:t,...s})=>e.jsx("div",{className:fs("flex flex-col space-y-2 text-center sm:text-left",t),...s});$0.displayName="SheetHeader";const V0=k.forwardRef(({className:t,...s},n)=>e.jsx(ZC,{ref:n,className:fs("text-lg font-semibold text-foreground",t),...s}));V0.displayName=ZC.displayName;const FE=k.forwardRef(({className:t,...s},n)=>e.jsx(WC,{ref:n,className:fs("text-sm text-muted-foreground",t),...s}));FE.displayName=WC.displayName;const vD=[{code:"AL",name:"Alabama"},{code:"AK",name:"Alaska"},{code:"AZ",name:"Arizona"},{code:"AR",name:"Arkansas"},{code:"CA",name:"California"},{code:"CO",name:"Colorado"},{code:"CT",name:"Connecticut"},{code:"DE",name:"Delaware"},{code:"DC",name:"District of Columbia"},{code:"FL",name:"Florida"},{code:"GA",name:"Georgia"},{code:"HI",name:"Hawaii"},{code:"ID",name:"Idaho"},{code:"IL",name:"Illinois"},{code:"IN",name:"Indiana"},{code:"IA",name:"Iowa"},{code:"KS",name:"Kansas"},{code:"KY",name:"Kentucky"},{code:"LA",name:"Louisiana"},{code:"ME",name:"Maine"},{code:"MD",name:"Maryland"},{code:"MA",name:"Massachusetts"},{code:"MI",name:"Michigan"},{code:"MN",name:"Minnesota"},{code:"MS",name:"Mississippi"},{code:"MO",name:"Missouri"},{code:"MT",name:"Montana"},{code:"NE",name:"Nebraska"},{code:"NV",name:"Nevada"},{code:"NH",name:"New Hampshire"},{code:"NJ",name:"New Jersey"},{code:"NM",name:"New Mexico"},{code:"NY",name:"New York"},{code:"NC",name:"North Carolina"},{code:"ND",name:"North Dakota"},{code:"OH",name:"Ohio"},{code:"OK",name:"Oklahoma"},{code:"OR",name:"Oregon"},{code:"PA",name:"Pennsylvania"},{code:"RI",name:"Rhode Island"},{code:"SC",name:"South Carolina"},{code:"SD",name:"South Dakota"},{code:"TN",name:"Tennessee"},{code:"TX",name:"Texas"},{code:"UT",name:"Utah"},{code:"VT",name:"Vermont"},{code:"VA",name:"Virginia"},{code:"WA",name:"Washington"},{code:"WV",name:"West Virginia"},{code:"WI",name:"Wisconsin"},{code:"WY",name:"Wyoming"}];function bD({className:t}){const[s,n]=k.useState("PA"),{data:a,isLoading:l,refetch:c}=w5(),u=N5(),i=k5(),_=C5(),j=S5(),y=E5(),x=u.isPending||i.isPending||_.isPending||j.isPending||y.isPending,v=I=>{var z;return((z=a==null?void 0:a[I])==null?void 0:z.total)||0},C=(I,z)=>{var F,D;return((D=(F=a==null?void 0:a[I])==null?void 0:F.byState)==null?void 0:D[z])||0},P=[{type:"state",label:"States",icon:By,color:"#6366f1",nationwide:!0},{type:"county",label:"Counties",icon:uh,color:"#0891b2",nationwide:!0},{type:"zipcode",label:"ZIP Codes",icon:Sb,color:"#10b981",nationwide:!1},{type:"school_district",label:"Schools",icon:$b,color:"#bc6c25",nationwide:!1},{type:"road",label:"Roads",icon:uo,color:"#71717a",nationwide:!1}];return e.jsxs(Mo,{className:t,children:[e.jsxs(vc,{className:"pb-3",children:[e.jsxs(bc,{className:"flex items-center gap-2 text-base",children:[e.jsx(Fu,{className:"w-5 h-5"}),"Boundary Cache Manager"]}),e.jsx(e5,{className:"text-xs",children:"Cache boundary data for offline use and faster loading"})]}),e.jsxs(Io,{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-5 gap-2",children:P.map(({type:I,label:z,icon:F,color:D})=>e.jsxs("div",{className:"flex flex-col items-center p-2 rounded-lg border bg-muted/30",children:[e.jsx(F,{className:"w-4 h-4 mb-1",style:{color:D}}),e.jsx("span",{className:"text-[10px] font-medium",children:z}),e.jsx(Mt,{variant:"secondary",className:"text-[10px] mt-1",children:l?"...":v(I).toLocaleString()})]},I))}),e.jsx(ks,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Nationwide Data"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Le,{size:"sm",variant:"outline",onClick:()=>u.mutate(),disabled:x,className:"flex-1",children:[u.isPending?e.jsx(Va,{className:"w-4 h-4 mr-2 animate-spin"}):v("state")>0?e.jsx(cl,{className:"w-4 h-4 mr-2 text-green-500"}):e.jsx(By,{className:"w-4 h-4 mr-2"}),"Cache States"]}),e.jsxs(Le,{size:"sm",variant:"outline",onClick:()=>i.mutate(),disabled:x,className:"flex-1",children:[i.isPending?e.jsx(Va,{className:"w-4 h-4 mr-2 animate-spin"}):v("county")>0?e.jsx(cl,{className:"w-4 h-4 mr-2 text-green-500"}):e.jsx(uh,{className:"w-4 h-4 mr-2"}),"Cache Counties"]})]})]}),e.jsx(ks,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"State-by-State Data"}),e.jsx("div",{className:"flex gap-2 mb-3",children:e.jsxs(rt,{value:s,onValueChange:n,children:[e.jsx(it,{className:"w-[180px]",children:e.jsx(ct,{placeholder:"Select state"})}),e.jsx(ot,{children:e.jsx(Xc,{className:"h-[200px]",children:vD.map(I=>e.jsxs(le,{value:I.code,children:[I.code," - ",I.name]},I.code))})})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs(Le,{size:"sm",variant:"outline",onClick:()=>_.mutate(s),disabled:x||!s,children:[_.isPending?e.jsx(Va,{className:"w-4 h-4 mr-1 animate-spin"}):C("zipcode",s)>0?e.jsx(cl,{className:"w-4 h-4 mr-1 text-green-500"}):e.jsx(Sb,{className:"w-4 h-4 mr-1"}),e.jsx("span",{className:"text-xs",children:"ZIPs"})]}),e.jsxs(Le,{size:"sm",variant:"outline",onClick:()=>j.mutate(s),disabled:x||!s,children:[j.isPending?e.jsx(Va,{className:"w-4 h-4 mr-1 animate-spin"}):C("school_district",s)>0?e.jsx(cl,{className:"w-4 h-4 mr-1 text-green-500"}):e.jsx($b,{className:"w-4 h-4 mr-1"}),e.jsx("span",{className:"text-xs",children:"Schools"})]}),e.jsxs(Le,{size:"sm",variant:"outline",onClick:()=>y.mutate(s),disabled:x||!s,children:[y.isPending?e.jsx(Va,{className:"w-4 h-4 mr-1 animate-spin"}):C("road",s)>0?e.jsx(cl,{className:"w-4 h-4 mr-1 text-green-500"}):e.jsx(uo,{className:"w-4 h-4 mr-1"}),e.jsx("span",{className:"text-xs",children:"Roads"})]})]}),s&&e.jsxs("div",{className:"mt-2 flex gap-2 text-[10px] text-muted-foreground",children:[e.jsxs("span",{children:["Cached for ",s,":"]}),e.jsxs("span",{children:["ZIPs: ",C("zipcode",s)]}),e.jsxs("span",{children:["Schools: ",C("school_district",s)]}),e.jsxs("span",{children:["Roads: ",C("road",s)]})]})]}),e.jsx(ks,{}),e.jsx("div",{className:"flex justify-end",children:e.jsx(Le,{size:"sm",variant:"ghost",onClick:()=>c(),disabled:l,children:l?e.jsx(Va,{className:"w-4 h-4 animate-spin"}):"Refresh Stats"})})]})]})}const zE="https://ntrjyokaupvmnftawavp.supabase.co",jD=typeof window<"u"&&window.devicePixelRatio>1,tp=(t,s=jD)=>`${zE}/functions/v1/mapbox-tiles?style=${t}&z={z}&x={x}&y={y}${s?"&retina=true":""}`,wD=4,ND=4,kD=6,sp=t=>`${zE}/functions/v1/mapbox-tiles?style=${t}&z=${wD}&x=${ND}&y=${kD}`,xf={light:{url:tp("light-v11"),attribution:"© Mapbox © OpenStreetMap",name:"Light",description:"Clean, minimal style",previewUrl:sp("light-v11"),icon:e.jsx(ph,{className:"w-5 h-5"}),tileSize:512},dark:{url:tp("dark-v11"),attribution:"© Mapbox © OpenStreetMap",name:"Dark",description:"Dark theme for low light",previewUrl:sp("dark-v11"),icon:e.jsx(ph,{className:"w-5 h-5"}),tileSize:512},satellite:{url:tp("satellite-streets-v12"),attribution:"© Mapbox © OpenStreetMap",name:"Satellite",description:"Aerial imagery with labels",previewUrl:sp("satellite-streets-v12"),icon:e.jsx(Da,{className:"w-5 h-5"}),tileSize:512},terrain:{url:tp("outdoors-v12"),attribution:"© Mapbox © OpenStreetMap",name:"Terrain",description:"Elevation & landforms",previewUrl:sp("outdoors-v12"),icon:e.jsx(Rh,{className:"w-5 h-5"}),tileSize:512},streets:{url:tp("streets-v12"),attribution:"© Mapbox © OpenStreetMap",name:"Streets",description:"Roads & landmarks",previewUrl:sp("streets-v12"),icon:e.jsx(ji,{className:"w-5 h-5"}),tileSize:512},outdoors:{url:tp("outdoors-v12"),attribution:"© Mapbox © OpenStreetMap",name:"Outdoors",description:"Hiking & nature",previewUrl:sp("outdoors-v12"),icon:e.jsx(pS,{className:"w-5 h-5"}),tileSize:512},navigation:{url:tp("navigation-day-v1"),attribution:"© Mapbox © OpenStreetMap",name:"Navigation",description:"Clear road focu
755s",previewUrl:sp("navigation-day-v1"),icon:e.jsx(By,{className:"w-5 h-5"}),tileSize:512}},CD=[{id:"development-analysis",name:"Development Analysis",description:"Boundaries for site analysis",icon:e.jsx(Ci,{className:"w-4 h-4"}),layers:["censusTracks","schoolDistricts"]},{id:"terrain-analysis",name:"Terrain Analysis",description:"Topographic and elevation data",icon:e.jsx(Rh,{className:"w-4 h-4"}),layers:["topographic"]}],SD=({open:t,onClose:s,mapStyle:n,onMapStyleChange:a,boundaryLayers:l,onBoundaryLayerToggle:c,layerOpacity:u,onLayerOpacityChange:i,isAdmin:_=!1})=>{const[j,y]=k.useState({boundaries:!0,terrain:!1,cacheManager:!1}),x=D=>{y(X=>({...X,[D]:!X[D]}))},v=({children:D})=>e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(H1,{className:"w-3 h-3 text-muted-foreground cursor-help ml-1"})}),e.jsx(or,{side:"left",className:"max-w-[200px] text-xs",children:D})]}),C=D=>{["states","counties","municipalities","zipCodes","censusTracks","schoolDistricts","topographic"].forEach(K=>{l[K]&&!D.layers.includes(K)&&c(K)}),D.layers.forEach(K=>{l[K]||c(K)})},P=()=>{["states","counties","municipalities","zipCodes","censusTracks","schoolDistricts","topographic"].forEach(X=>{l[X]&&c(X)})},z=["states","counties","municipalities","zipCodes","censusTracks","schoolDistricts","roadsOverlay","majorRoads","topographic"].filter(D=>l[D]).length,F=Object.entries(xf);return e.jsx(B0,{open:t,onOpenChange:D=>!D&&s(),children:e.jsxs(m_,{side:"right",className:"w-[340px] sm:w-[380px] p-0",hideOverlay:!0,children:[e.jsx($0,{className:"px-4 py-3 border-b",children:e.jsxs(V0,{className:"flex items-center gap-2 text-base",children:[e.jsx(ph,{className:"w-5 h-5"}),"Map Style & Layers"]})}),e.jsx(Xc,{className:"h-[calc(100vh-60px)]",children:e.jsx(hm,{delayDuration:300,children:e.jsxs("div",{className:"space-y-5 p-4",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ph,{className:"w-4 h-4 text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Base Map"})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:F.map(([D,X])=>e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsxs("button",{onClick:()=>a(D),className:fs("flex flex-col items-center gap-1.5 p-2 rounded-lg border-2 transition-all relative",n===D?"border-primary bg-primary/5 ring-2 ring-primary/20":"border-transparent bg-background hover:border-muted-foreground/30 hover:bg-muted/50"),children:[e.jsxs("div",{className:"w-full aspect-square rounded-md overflow-hidden relative bg-muted shadow-sm",children:[e.jsx("img",{src:X.previewUrl,alt:X.name,className:"w-full h-full object-cover",loading:"lazy"}),e.jsx("div",{className:fs("absolute inset-0 flex items-center justify-center bg-black/20",D==="dark"?"text-white":"text-white drop-shadow-md"),children:X.icon}),n===D&&e.jsx("div",{className:"absolute top-1 right-1 w-5 h-5 rounded-full bg-primary flex items-center justify-center shadow-md",children:e.jsx(cl,{className:"w-3 h-3 text-primary-foreground"})})]}),e.jsx("span",{className:fs("text-[10px] font-medium leading-tight truncate w-full text-center",n===D&&"text-primary"),children:X.name})]})}),e.jsxs(or,{side:"bottom",className:"text-xs",children:[e.jsx("p",{className:"font-medium",children:X.name}),e.jsx("p",{className:"text-muted-foreground",children:X.description})]})]},D))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Layer Presets"}),z>0&&e.jsxs(Le,{variant:"ghost",size:"sm",onClick:P,className:"h-6 text-xs px-2",children:["Clear All (",z,")"]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:CD.map(D=>e.jsxs("button",{onClick:()=>C(D),className:"flex items-start gap-1.5 p-2 rounded-lg border border-border hover:border-primary/50 hover:bg-muted/50 transition-all text-left",children:[e.jsx("div",{className:"mt-0.5 text-primary",children:D.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-medium leading-tight",children:D.name}),e.jsx("p",{className:"text-[9px] text-muted-foreground leading-tight",children:D.description})]})]},D.id))})]}),e.jsxs("div",{className:"space-y-2 border rounded-lg p-3 bg-muted/30",children:[e.jsx("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide mb-2",children:"Public Map Layers"}),e.jsxs("div",{className:"border-b border-border pb-2",children:[e.jsxs("button",{onClick:()=>x("boundaries"),className:"flex items-center justify-between w-full text-left py-1",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Boundaries"}),e.jsx(v,{children:"Show or hide administrative boundaries like state lines, county borders, and city/municipality limits."})]}),e.jsx(Oa,{className:fs("w-4 h-4 transition-transform",j.boundaries&&"rotate-180")}
755)]}),j.boundaries&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 gap-1 mt-2",children:[{key:"states",label:"States",color:"#6366f1"},{key:"counties",label:"Counties",color:"#0891b2"},{key:"municipalities",label:"Municipalities",color:"#f59e0b"},{key:"zipCodes",label:"ZIP Codes",color:"#10b981"},{key:"censusTracks",label:"Census",color:"#7b2cbf"},{key:"schoolDistricts",label:"Schools",color:"#bc6c25"},{key:"roadsOverlay",label:"Roads",color:"#71717a"},{key:"majorRoads",label:"Street Map",color:"#dc2626"}].map(({key:D,label:X,color:K})=>e.jsxs("button",{onClick:()=>c(D),className:fs("flex items-center gap-1 px-2 py-1 rounded text-[10px] font-medium transition-colors",l[D]?"bg-primary text-primary-foreground":"bg-secondary text-secondary-foreground hover:bg-secondary/80"),children:[e.jsx("span",{className:"w-2 h-2 rounded-sm flex-shrink-0",style:{backgroundColor:K}}),X]},D))}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground w-12",children:"Opacity"}),e.jsx(Ca,{value:[u.boundaries*100],onValueChange:([D])=>i("boundaries",D/100),min:10,max:100,step:5,className:"flex-1"}),e.jsxs("span",{className:"text-[9px] text-muted-foreground w-8 text-right",children:[Math.round(u.boundaries*100),"%"]})]}),l.states&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground w-12",children:"States"}),e.jsx(Ca,{value:[(u.states??.85)*100],onValueChange:([D])=>i("states",D/100),min:10,max:100,step:5,className:"flex-1"}),e.jsxs("span",{className:"text-[9px] text-muted-foreground w-8 text-right",children:[Math.round((u.states??.85)*100),"%"]})]}),l.counties&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground w-12",children:"Counties"}),e.jsx(Ca,{value:[(u.counties??.8)*100],onValueChange:([D])=>i("counties",D/100),min:10,max:100,step:5,className:"flex-1"}),e.jsxs("span",{className:"text-[9px] text-muted-foreground w-8 text-right",children:[Math.round((u.counties??.8)*100),"%"]})]}),l.municipalities&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground w-12",children:"Munic."}),e.jsx(Ca,{value:[(u.municipalities??.75)*100],onValueChange:([D])=>i("municipalities",D/100),min:10,max:100,step:5,className:"flex-1"}),e.jsxs("span",{className:"text-[9px] text-muted-foreground w-8 text-right",children:[Math.round((u.municipalities??.75)*100),"%"]})]}),l.schoolDistricts&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground w-12",children:"Schools"}),e.jsx(Ca,{value:[(u.schoolDistricts??.75)*100],onValueChange:([D])=>i("schoolDistricts",D/100),min:10,max:100,step:5,className:"flex-1"}),e.jsxs("span",{className:"text-[9px] text-muted-foreground w-8 text-right",children:[Math.round((u.schoolDistricts??.75)*100),"%"]})]}),(l.roadsOverlay||l.majorRoads)&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground w-12",children:"Roads"}),e.jsx(Ca,{value:[(u.roads??.6)*100],onValueChange:([D])=>i("roads",D/100),min:10,max:100,step:5,className:"flex-1"}),e.jsxs("span",{className:"text-[9px] text-muted-foreground w-8 text-right",children:[Math.round((u.roads??.6)*100),"%"]})]})]})]}),e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>x("terrain"),className:"flex items-center justify-between w-full text-left py-1",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("p",{className:"text-[11px] font-medium",children:"Terrain"}),e.jsx(v,{children:"Show terrain relief shading and topographic maps."})]}),e.jsx(Oa,{className:fs("w-4 h-4 transition-transform",j.terrain&&"rotate-180")})]}),j.terrain&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 gap-1 mt-2",children:e.jsx("button",{onClick:()=>c("topographic"),className:fs("flex items-center justify-center px-2 py-1 rounded text-[10px] font-medium transition-colors",l.topographic?"bg-primary text-primary-foreground":"bg-secondary text-secondary-foreground hover:bg-secondary/80"),children:"Topo Map"})}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground w-12",children:"Opacity"}),e.jsx(Ca,{value:[u.terrain*100],onValueChange:([D])=>i("terrain",D/100),min:10,max:100,step:5,className:"flex-1"}),e.jsxs("span",{className:"text-[9px] text-muted-foreground w-8 text-right",children:[Math.round(u.terrain*100),"%"]})]})]})]})]}),_&&e.jsxs(wi,{open:j.cacheManager,onOpenChange:()=>x("cacheManager"),children:[e.jsxs(Ni,{className:"flex items-center justify-between w-full text-left py-2 px-3 rounded-lg border bg-muted/30 hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fu,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Boundary Cache"})]}),e.jsx(Oa,{className:fs("w-4 h-4 transition-transform",j.cacheManager&&"rotate-180")}
755)]}),e.jsx(ki,{className:"mt-2",children:e.jsx(bD,{})})]})]})})})]})})},ED=Object.freeze(Object.defineProperty({__proto__:null,MAP_STYLE_CONFIG:xf,default:SD},Symbol.toStringTag,{value:"Module"})),OE=()=>"hsl(180 70% 45%)",Sy=[{id:"tiles",name:"Base Map Tiles",category:"base",defaultZIndex:200},{id:"states",name:"State Boundaries",category:"boundaries",defaultZIndex:320},{id:"counties",name:"County Boundaries",category:"boundaries",defaultZIndex:330},{id:"municipalities",name:"Municipalities",category:"boundaries",defaultZIndex:340},{id:"zipCodes",name:"ZIP Codes",category:"boundaries",defaultZIndex:345},{id:"congressionalDistricts",name:"Congressional Districts",category:"boundaries",defaultZIndex:346},{id:"schoolDistricts",name:"School Districts",category:"boundaries",defaultZIndex:347},{id:"censusTracks",name:"Census Tracts",category:"boundaries",defaultZIndex:348},{id:"parcels",name:"Parcel Boundaries",category:"boundaries",defaultZIndex:380},{id:"zoningBoundary",name:"Zoning Area Boundary",category:"boundaries",defaultZIndex:382},{id:"zoneomicsTiles",name:"Zoning Overlay",category:"boundaries",defaultZIndex:385},{id:"cacheCoverage",name:"Cache Coverage",category:"overlays",defaultZIndex:350}
755,{id:"roads",name:"Roads",category:"infrastructure",defaultZIndex:390},{id:"railroads",name:"Railroads",category:"infrastructure",defaultZIndex:392},{id:"hifldTransmission",name:"HIFLD Transmission Lines",category:"infrastructure",defaultZIndex:393},{id:"hifldSubstations",name:"HIFLD Substations",category:"infrastructure",defaultZIndex:394},{id:"transmissionLines",name:"OSM Transmission Lines",category:"infrastructure",defaultZIndex:395},{id:"substations",name:"OSM Substations",category:"infrastructure",defaultZIndex:396},{id:"powerPlants",name:"Power Plants",category:"infrastructure",defaultZIndex:397},{id:"topographic",name:"Topo Map",category:"topography",defaultZIndex:210},{id:"overlays",name:"Custom Overlays",category:"overlays",defaultZIndex:400},{id:"drawnRegions",name:"Drawn Regions",category:"overlays",defaultZIndex:410},{id:"wetlands",name:"Wetlands",category:"overlays",defaultZIndex:415},{id:"floodZones",name:"Flood Zones",category:"overlays",defaultZIndex:420},{id:"hydrology",name:"Hydrology",category:"overlays",defaultZIndex:425},{id:"geology",name:"Geology",category:"overlays",defaultZIndex:430},{id:"soils",name:"Soils",category:"overlays",defaultZIndex:435},{id:"bedrock",name:"Bedrock",category:"overlays",defaultZIndex:440},{id:"groundwater",name:"Groundwater",category:"overlays",defaultZIndex:445},{id:"usgsImagery",name:"USGS High-Res Imagery",category:"base",defaultZIndex:205},{id:"developments",name:"Developments",category:"markers",defaultZIndex:650},{id:"existingProducts",name:"Existing Sites",category:"markers",defaultZIndex:655},{id:"searchMarker",name:"Search Marker",category:"markers",defaultZIndex:660}],PD="map-layer-order",uk=()=>{const t=localStorage.getItem(PD);if(t)try{const s=JSON.parse(t),n=new Set(s.map(l=>l.id)),a=Sy.filter(l=>!n.has(l.id));return[...s,...a]}catch{return[...Sy]}return[...Sy]},Lm=(t,s)=>{const n=s.find(u=>u.id===t);if(!n){const u=Sy.find(i=>i.id===t);return(u==null?void 0:u.defaultZIndex)??400}const l=s.filter(u=>u.category===n.category).findIndex(u=>u.id===t),c=Math.min(l,9);return n.defaultZIndex+c};function hk(t,s){if(!t)return!0;const n=new Set;let a=t;for(;a&&!n.has(a);){n.add(a);const l=s.get(a);if(!l)return!0;if(l.is_visible===!1)return!1;a=l.parent_folder_id}return!0}function TD(t,s){const n=new Set;n.add(t);const a=l=>{s.forEach(c=>{c.parent_overlay_id===l&&!n.has(c.id)&&(n.add(c.id),a(c.id))})};return a(t),n}function LD(t,s,n){if(s.activeGroupId&&!TD(s.activeGroupId,s.allOverlays).has(t.id)||n!=null&&n.has(t.id)||t.is_visible===!1||t.folder_id&&!hk(t.folder_id,s.foldersById))return!1;const a=new Set;let l=t.parent_overlay_id??null;for(;l&&!a.has(l);){a.add(l);const c=s.overlaysById.get(l);if(!c)break;if(c.is_visible===!1||c.folder_id&&!hk(c.folder_id,s.foldersById))return!1;l=c.parent_overlay_id??null}return!0}function BE(t,s,n,a=!0){return t.filter(l=>a&&l.type==="wms"?!1:LD(l,s,n))}const MD=["building_footprint","office_area","retail_pad","warehouse_bay","dock_door","building_floor","canopy","trash_enclosure"];function lu(t){return t?MD.includes(t):!1}var $E="Toggle",bj=k.forwardRef((t,s)=>
755{const{pressed:n,defaultPressed:a,onPressedChange:l,...c}=t,[u,i]=v0({prop:n,onChange:l,defaultProp:a??!1,caller:$E});return e.jsx(Wd.button,{type:"button","aria-pressed":u,"data-state":u?"on":"off","data-disabled":t.disabled?"":void 0,...c,ref:s,onClick:Iy(t.onClick,()=>{t.disabled||i(!u)})})});bj.displayName=$E;var VE=bj,Of="ToggleGroup",[qE,TH]=N1(Of,[w0]),GE=w0(),jj=Do.forwardRef((t,s)=>{const{type:n,...a}=t;if(n==="single"){const l=a;return e.jsx(ID,{...l,ref:s})}if(n==="multiple"){const l=a;return e.jsx(AD,{...l,ref:s})}throw new Error(`Missing prop \`type\` expected on \`${Of}\``)});jj.displayName=Of;var[HE,ZE]=qE(Of),ID=Do.forwardRef((t,s)=>{const{value:n,defaultValue:a,onValueChange:l=()=>{},...c}=t,[u,i]=v0({prop:n,defaultProp:a??"",onChange:l,caller:Of});return e.jsx(HE,{scope:t.__scopeToggleGroup,type:"single",value:Do.useMemo(()=>u?[u]:[],[u]),onItemActivate:i,onItemDeactivate:Do.useCallback(()=>i(""),[i]),children:e.jsx(WE,{...c,ref:s})})}),AD=Do.forwardRef((t,s)=>{const{value:n,defaultValue:a,onValueChange:l=()=>{},...c}=t,[u,i]=v0({prop:n,defaultProp:a??[],onChange:l,caller:Of}),_=Do.useCallback(y=>i((x=[])=>[...x,y]),[i]),j=Do.useCallback(y=>i((x=[])=>x.filter(v=>v!==y)),[i]);return e.jsx(HE,{scope:t.__scopeToggleGroup,type:"multiple",value:u,onItemActivate:_,onItemDeactivate:j,children:e.jsx(WE,{...c,ref:s})})});jj.displayName=Of;var[DD,RD]=qE(Of),WE=Do.forwardRef((t,s)=>{const{__scopeToggleGroup:n,disabled:a=!1,rovingFocus:l=!0,orientation:c,dir:u,loop:i=!0,..._}=t,j=GE(n),y=KC(u),x={role:"group",dir:y,..._};return e.jsx(DD,{scope:n,rovingFocus:l,disabled:a,children:l?e.jsx(aS,{asChild:!0,...j,orientation:c,dir:y,loop:i,children:e.jsx(Wd.div,{...x,ref:s})}):e.jsx(Wd.div,{...x,ref:s})})}),a0="ToggleGroupItem",YE=Do.forwardRef((t,s)=>{const n=ZE(a0,t.__scopeToggleGroup),a=RD(a0,t.__scopeToggleGroup),l=GE(t.__scopeToggleGroup),c=n.value.includes(t.value),u=a.disabled||t.disabled,i={...t,pressed:c,disabled:u},_=Do.useRef(null);return a.rovingFocus?e.jsx(rS,{asChild:!0,...l,focusable:!u,active:c,ref:_,children:e.jsx(mk,{...i,ref:s})}):e.jsx(mk,{...i,ref:s})});YE.displayName=a0;var mk=Do.forwardRef((t,s)=>{const{__scopeToggleGroup:n,value:a,...l}=t,c=ZE(a0,n),u={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=c.type==="single"?u:void 0;
755return e.jsx(bj,{...i,...l,ref:s,onPressedChange:_=>{_?c.onItemActivate(a):c.onItemDeactivate(a)}})}),XE=jj,KE=YE;const JE=$C("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),FD=k.forwardRef(({className:t,variant:s,size:n,...a},l)=>e.jsx(VE,{ref:l,className:fs(JE({variant:s,size:n,className:t})),...a}));FD.displayName=VE.displayName;const QE=k.createContext({size:"default",variant:"default"}),q0=k.forwardRef(({className:t,variant:s,size:n,children:a,...l},c)=>e.jsx(XE,{ref:c,className:fs("flex items-center justify-center gap-1",t),...l,children:e.jsx(QE.Provider,{value:{variant:s,size:n},children:a})}));q0.displayName=XE.displayName;const Vm=k.forwardRef(({className:t,children:s,variant:n,size:a,...l},c)=>{const u=k.useContext(QE);return e.jsx(KE,{ref:c,className:fs(JE({variant:u.variant||n,size:u.size||a}),t),...l,children:s})});Vm.displayName=KE.displayName;const zD=({open:t,imageUrl:s,onCrop:n,onSkip:a,onCancel:l})=>{const c=k.useRef(null),u=k.useRef(null),i=k.useRef(null),[_,j]=k.useState(!1),[y,x]=k.useState({w:0,h:0}),[v,C]=k.useState("rect"),[P,I]=k.useState(null),[z,F]=k.useState(!1),[D,X]=k.useState(null),[K,te]=k.useState(null),[J,H]=k.useState([]),[O,q]=k.useState(!1),[W,Q]=k.useState(null),[Z,oe]=k.useState(1),[ce,ae]=k.useState({x:0,y:0}),[ie,de]=k.useState(!1),[ge,We]=k.useState(null),[Ee,ve]=k.useState(!1);k.useEffect(()=>{if(!t||!s)return;const Be=new Image;return Be.crossOrigin="anonymous",Be.onload=()=>{i.current=Be,j(!0),I(null),H([]),q(!1),oe(1),ae({x:0,y:0})},Be.src=s,()=>{j(!1)}},[t,s]),k.useEffect(()=>{if(!_||!i.current||!u.current)return;const Be=i.current,Dt=u.current.clientWidth,zt=Math.min(Dt/Be.width,450/Be.height,1);x({w:Math.round(Be.width*zt),h:Math.round(Be.height*zt)})},[_]);const we=k.useCallback((Be,Dt)=>({x:(Be-ce.x)/Z,y:(Dt-ce.y)/Z}),[Z,ce]),Ze=k.useCallback((Be,Dt)=>({x:Be*Z+ce.x,y:Dt*Z+ce.y}),[Z,ce]),ke=k.useCallback(()=>{const Be=c.current,Dt=i.current;if(!Be||!Dt||!_||y.w===0)return;Be.width=y.w,Be.height=y.h;const Rt=Be.getContext("2d");if(!Rt)return;Rt.clearRect(0,0,y.w,y.h);const rs=y.w/Dt.width*Z,_s=ce.x,vs=ce.y;Rt.save(),Rt.beginPath(),Rt.rect(0,0,y.w,y.h),Rt.clip(),Rt.drawImage(Dt,_s,vs,Dt.width*rs,Dt.height*rs),Rt.restore();const $t=getComputedStyle(document.documentElement).getPropertyValue("--primary").trim(),Ns=$t?`hsl(${$t})`:"#3b82f6";if(v==="rect"&&P){const Ts=Ze(P.x,P.y),bs=Ze(P.x+P.w,P.y+P.h),en=Ts.x,Jt=Ts.y,Vs=bs.x-Ts.x,ps=bs.y-Ts.y;Rt.fillStyle="rgba(0,0,0,0.45)",Rt.fillRect(0,0,y.w,y.h),Rt.clearRect(en,Jt,Vs,ps),Rt.save(),Rt.beginPath(),Rt.rect(en,Jt,Vs,ps),Rt.clip(),Rt.drawImage(Dt,_s,vs,Dt.width*rs,Dt.height*rs),Rt.restore(),Rt.strokeStyle=Ns,Rt.lineWidth=2,Rt.setLineDash([6,3]),Rt.strokeRect(en,Jt,Vs,ps),Rt.setLineDash([]);const nt=8;Rt.fillStyle=Ns,[[en,Jt],[en+Vs,Jt],[en,Jt+ps],[en+Vs,Jt+ps]].forEach(([ts,ds])=>{Rt.fillRect(ts-nt/2,ds-nt/2,nt,nt)})}if(v==="polygon"&&J.length>0){const Ts=J.map(bs=>Ze(bs.x,bs.y));if(O&&(Rt.fillStyle="rgba(0,0,0,0.45)",Rt.fillRect(0,0,y.w,y.h),Rt.save(),Rt.beginPath(),Ts.forEach((bs,en)=>en===0?Rt.moveTo(bs.x,bs.y):Rt.lineTo(bs.x,bs.y)),Rt.closePath(),Rt.clip(),Rt.drawImage(Dt,_s,vs,Dt.width*rs,Dt.height*rs),Rt.restore()),Rt.beginPath(),Ts.forEach((bs,en)=>en===0?Rt.moveTo(bs.x,bs.y):Rt.lineTo(bs.x,bs.y)),O&&Rt.closePath(),Rt.strokeStyle=Ns,Rt.lineWidth=2,Rt.stroke(),Ts.forEach((bs,en)=>{Rt.beginPath(),Rt.arc(bs.x,bs.y,en===0&&!O?7:5,0,Math.PI*2),Rt.fillStyle=W===en?"#ffffff":Ns,Rt.fill(),Rt.strokeStyle=Ns,Rt.lineWidth=2,Rt.stroke()}),!O&&J.length>=3){const bs=Ts[0];Rt.beginPath(),Rt.arc(bs.x,bs.y,10,0,Math.PI*2),Rt.strokeStyle="rgba(255,255,255,0.6)",Rt.lineWidth=1,Rt.stroke()}}},[_,P,J,O,y,Z,ce,v,Ze,W]);k.useEffect(()=>{ke()},[ke]);const ze=Be=>{const Dt=c.current;if(!Dt)return{x:0,y:0};const Rt=Dt.getBoundingClientRect();return{x:Be.clientX-Rt.left,y:Be.clientY-Rt.top}},Ke=Be=>{if(!P)return null;
755const Dt=12/Z,Rt=Ze(P.x,P.y),zt=Ze(P.x+P.w,P.y+P.h),rs={tl:[Rt.x,Rt.y],tr:[zt.x,Rt.y],bl:[Rt.x,zt.y],br:[zt.x,zt.y]};for(const[_s,[vs,$t]]of Object.entries(rs))if(Math.abs(Be.x-vs)<Dt&&Math.abs(Be.y-$t)<Dt)return _s;return Be.x>=Rt.x&&Be.x<=zt.x&&Be.y>=Rt.y&&Be.y<=zt.y?"move":null},dt=Be=>{if(J.length<3)return!1;const Dt=Ze(J[0].x,J[0].y);return Math.hypot(Be.x-Dt.x,Be.y-Dt.y)<12},Re=Be=>{const Dt=ze(Be);if(Ee||Be.button===1){de(!0),We({x:Be.clientX,y:Be.clientY,px:ce.x,py:ce.y});return}if(v==="rect"){const Rt=Ke(Dt);if(Rt)te(Rt),X(Dt),F(!0);else{const zt=we(Dt.x,Dt.y);X(Dt),F(!0),te("new"),I({x:zt.x,y:zt.y,w:0,h:0})}}if(v==="polygon"&&!O)if(dt(Dt))q(!0);else{const Rt=we(Dt.x,Dt.y);H(zt=>[...zt,Rt])}},qt=Be=>{const Dt=ze(Be);if(ie&&ge){ae({x:ge.px+(Be.clientX-ge.x),y:ge.py+(Be.clientY-ge.y)});return}if(v==="polygon"&&!O&&J.length>=3&&Q(dt(Dt)?0:null),v==="rect"&&z&&D){if(K==="new"){const Rt=we(D.x,D.y),zt=we(Dt.x,Dt.y);I({x:Math.min(Rt.x,zt.x),y:Math.min(Rt.y,zt.y),w:Math.abs(zt.x-Rt.x),h:Math.abs(zt.y-Rt.y)})}else if(K==="move"&&P){const Rt=(Dt.x-D.x)/Z,zt=(Dt.y-D.y)/Z;I({...P,x:P.x+Rt,y:P.y+zt}),X(Dt)}else if(P){const Rt=we(Dt.x,Dt.y);let{x:zt,y:rs,w:_s,h:vs}=P;K==="br"?(_s=Math.max(10/Z,Rt.x-zt),vs=Math.max(10/Z,Rt.y-rs)):K==="bl"?(_s=Math.max(10/Z,zt+_s-Rt.x),vs=Math.max(10/Z,Rt.y-rs),zt=Rt.x):K==="tr"?(_s=Math.max(10/Z,Rt.x-zt),vs=Math.max(10/Z,rs+vs-Rt.y),rs=Rt.y):K==="tl"&&(_s=Math.max(10/Z,zt+_s-Rt.x),vs=Math.max(10/Z,rs+vs-Rt.y),zt=Rt.x,rs=Rt.y),I({x:zt,y:rs,w:_s,h:vs}),X(Dt)}}},ft=()=>{F(!1),te(null),de(!1),We(null),v==="rect"&&P&&(P.w<5/Z||P.h<5/Z)&&I(null)},Fe=Be=>{Be.preventDefault();const Dt=ze(Be),Rt=Be.deltaY<0?1.15:1/1.15,zt=Math.min(8,Math.max(.5,Z*Rt)),rs=Dt.x-(Dt.x-ce.x)/Z*zt,_s=Dt.y-(Dt.y-ce.y)/Z*zt;oe(zt),ae({x:rs,y:_s})},fe=()=>{const Be=Math.min(8,Z*1.3),Dt=y.w/2,Rt=y.h/2;ae({x:Dt-(Dt-ce.x)/Z*Be,y:Rt-(Rt-ce.y)/Z*Be}),oe(Be)},Qe=()=>{const Be=Math.max(.5,Z/1.3),Dt=y.w/2,Rt=y.h/2;ae({x:Dt-(Dt-ce.x)/Z*Be,y:Rt-(Rt-ce.y)/Z*Be}),oe(Be)},ht=()=>{oe(1),ae({x:0,y:0})},_t=()=>{I(null),H([]),q(!1),Q(null)},He=()=>{O?q(!1):H(Be=>Be.slice(0,-1))},as=()=>{const Be=i.current;if(!Be||y.w===0)return;const Dt=y.w/Be.width;if(v==="rect"&&P){const Rt=P.x/Dt,zt=P.y/Dt,rs=P.w/Dt,_s=P.h/Dt,vs=document.createElement("canvas");vs.width=Math.round(rs),vs.height=Math.round(_s);const $t=vs.getContext("2d");if(!$t)return;$t.drawImage(Be,Rt,zt,rs,_s,0,0,vs.width,vs.height),vs.toBlob(Ns=>{Ns&&n(Ns)},"image/png")}if(v==="polygon"&&O&&J.length>=3){const Rt=J.map(Vs=>({x:Vs.x/Dt,y:Vs.y/Dt})),zt=Rt.map(Vs=>Vs.x),rs=Rt.map(Vs=>Vs.y),_s=Math.max(0,Math.floor(Math.min(...zt))),vs=Math.max(0,Math.floor(Math.min(...rs))),$t=Math.min(Be.width,Math.ceil(Math.max(...zt))),Ns=Math.min(Be.height,Math.ceil(Math.max(...rs))),Ts=$t-_s,bs=Ns-vs,en=document.createElement("canvas");en.width=Ts,en.height=bs;const Jt=en.getContext("2d");if(!Jt)return;Jt.beginPath(),Rt.forEach((Vs,ps)=>{const nt=Vs.x-_s,ts=Vs.y-vs;ps===0?Jt.moveTo(nt,ts):Jt.lineTo(nt,ts)}),Jt.closePath(),Jt.clip(),Jt.drawImage(Be,_s,vs,Ts,bs,0,0,Ts,bs),en.toBlob(Vs=>{Vs&&n(Vs)},"image/png")}},vt=v==="rect"&&P&&P.w>5/Z&&P.h>5/Z||v==="polygon"&&O&&J.length>=3,Xe=Ee?"grab":ie?"grabbing":"crosshair",Ce=Be=>{Be&&(C(Be),_t())};return e.jsx(dd,{open:t,onOpenChange:Be=>!Be&&l(),children:e.jsxs(ud,{className:"sm:max-w-2xl bg-background",children:[e.jsx(Gd,{children:e.jsxs(Hd,{className:"flex items-center gap-2",children:[e.jsx(xS,{className:"w-5 h-5"}),"Crop Site Plan"]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs(q0,{type:"single",value:v,onValueChange:Ce,size:"sm",children:[e.jsxs(Vm,{value:"rect",className:"gap-1.5 text-xs",children:[e.jsx(Il,{className:"w-3.5 h-3.5"}),"Rectangle"]}),e.jsxs(Vm,{value:"polygon",className:"gap-1.5 text-xs",children:[e.jsx(fd,{className:"w-3.5 h-3.5"}),"Freeform"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Le,{size:"icon",variant:Ee?"default":"ghost",className:"h-7 w-7",onClick:()=>ve(!Ee),title:"Pan mode (or hold middle mouse)",children:e.jsx(If,{className:"w-3.5 h-3.5"})}),e.jsx(Le,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:Qe,title:"Zoom out",children:e.jsx(Y3,{className:"w-3.5 h-3.5"})}),e.jsxs("span",{className:"text-xs text-muted-foreground min-w-[3rem] text-center",children:[Math.round(Z*100),"%"]}),e.jsx(Le,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:fe,title:"Zoom in",children:e.jsx(IS,{className:"w-3.5 h-3.5"})}),e.jsx(Le,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:ht,title:"Reset view",children:e.jsx(mh,{className:"w-3 h-3"})})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:v==="rect"?"Draw a rectangle over the area y
755ou want to keep. Scroll to zoom, hold pan button to move.":"Click to place points. Click the first point to close the shape. Scroll to zoom."}),e.jsx("div",{ref:u,className:"relative bg-muted/30 rounded-lg overflow-hidden flex justify-center",children:e.jsx("canvas",{ref:c,style:{cursor:Xe,maxWidth:"100%"},onMouseDown:Re,onMouseMove:qt,onMouseUp:ft,onMouseLeave:ft,onWheel:Fe})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[v==="rect"&&P&&`Crop: ${Math.round(P.w)}×${Math.round(P.h)}px`,v==="polygon"&&J.length>0&&(O?`${J.length} points (closed)`:`${J.length} point${J.length>1?"s":""} — click first point to close`)]}),e.jsxs("div",{className:"flex gap-1",children:[v==="polygon"&&J.length>0&&e.jsxs(Le,{size:"sm",variant:"ghost",onClick:He,children:[e.jsx(zf,{className:"w-3 h-3 mr-1"}),"Undo"]}),(P||J.length>0)&&e.jsxs(Le,{size:"sm",variant:"ghost",onClick:_t,children:[e.jsx(mh,{className:"w-3 h-3 mr-1"}),"Reset"]})]})]})]}),e.jsxs(vf,{className:"flex gap-2",children:[e.jsxs(Le,{variant:"ghost",onClick:l,children:[e.jsx(ja,{className:"w-4 h-4 mr-1"}),"Cancel"]}),e.jsx(Le,{variant:"outline",onClick:a,children:"Use Full Image"}),e.jsxs(Le,{onClick:as,disabled:!vt,children:[e.jsx(cl,{className:"w-4 h-4 mr-1"}),"Apply Crop"]})]})]})})},OD=({open:t,imageUrl:s,initialRotation:n,initialScale:a,onConfirm:l,onCancel:c})=>{const[u,i]=k.useState(n),[_,j]=k.useState(a),[y,x]=k.useState({x:20,y:80}),v=k.useRef(null),C=k.useRef(null),P=k.useCallback(D=>{D.preventDefault(),D.target.setPointerCapture(D.pointerId),v.current={startX:D.clientX,startY:D.clientY,origX:y.x,origY:y.y}},[y]),I=k.useCallback(D=>{if(!v.current)return;const X=D.clientX-v.current.startX,K=D.clientY-v.current.startY;x({x:v.current.origX+X,y:v.current.origY+K})},[]),z=k.useCallback(()=>{v.current=null},[]),F=D=>{i(X=>{const K=(X+D)%360;return K<0?K+360:K})};return t?e.jsxs("div",{ref:C,className:"fixed z-[10000] w-64 rounded-lg border border-border bg-background/95 backdrop-blur-sm shadow-xl",style:{left:y.x,top:y.y},children:[e.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-border cursor-grab active:cursor-grabbing select-none bg-muted/50 rounded-t-lg",onPointerDown:P,onPointerMove:I,onPointerUp:z,children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:[e.jsx(v3,{className:"w-3.5 h-3.5 text-muted-foreground"}),"Adjust Site Plan"]}),e.jsx(Le,{size:"sm",variant:"ghost",className:"h-5 w-5 p-0",onClick:c,children:e.jsx(ja,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"p-2 space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(B,{className:"flex items-center gap-1 text-[11px]",children:[e.jsx(S0,{className:"w-3 h-3"}),"Rotation: ",Math.round(u),"°"]}),e.jsxs("div",{className:"flex gap-0.5 flex-wrap",children:[e.jsx(Le,{size:"sm",variant:"ghost",className:"h-5 px-1 text-[10px]",onClick:()=>F(-90),children:"-90°"}),e.jsx(Le,{size:"sm",variant:"ghost",className:"h-5 px-1 text-[10px]",onClick:()=>F(-45),children:"-45°"}),e.jsx(Le,{size:"sm",variant:"ghost",className:"h-5 px-1 text-[10px]",onClick:()=>i(0),children:"0°"}),e.jsx(Le,{size:"sm",variant:"ghost",className:"h-5 px-1 text-[10px]",onClick:()=>F(45),children:"+45°"}),e.jsx(Le,{size:"sm",variant:"ghost",className:"h-5 px-1 text-[10px]",onClick:()=>F(90),children:"+90°"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ca,{value:[u],onValueChange:D=>i(D[0]),min:0,max:359,step:1,className:"flex-1"}),e.jsx(be,{type:"number",value:Math.round(u),onChange:D=>i(Number(D.target.value)%360),className:"w-12 h-6 text-[10px] text-center px-1"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(B,{className:"flex items-center gap-1 text-[11px]",children:[e.jsx(Mf,{className:"w-3 h-3"}),"Scale: ",Math.round(_*100),"%"]}),e.jsxs("div",{className:"flex gap-0.5 flex-wrap",children:[e.jsx(Le,{size:"sm",variant:"ghost",className:"h-5 px-1 text-[10px]",onClick:()=>j(.5),children:"50%"}),e.jsx(Le,{size:"sm",variant:"ghost",className:"h-5 px-1 text-[10px]",onClick:()=>j(.75),children:"75%"}),e.jsx(Le,{size:"sm",variant:"ghost",className:"h-5 px-1 text-[10px]",onClick:()=>j(1),children:"100%"}),e.jsx(Le,{size:"sm",variant:"ghost",className:"h-5 px-1 text-[10px]",onClick:()=>j(1.25),children:"125%"}),e.jsx(Le,{size:"sm",variant:"ghost",className:"h-5 px-1 text-[10px]",onClick:()=>j(1.5),children:"150%"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ca,{value:[_],onValueChange:D=>
755j(D[0]),min:.1,max:3,step:.05,className:"flex-1"}),e.jsx(be,{type:"number",value:Math.round(_*100),onChange:D=>j(Number(D.target.value)/100),className:"w-12 h-6 text-[10px] text-center px-1"})]})]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(Le,{variant:"outline",size:"sm",className:"flex-1 h-7 text-xs",onClick:c,children:"Cancel"}),e.jsx(Le,{size:"sm",className:"flex-1 h-7 text-xs",onClick:()=>l(u,_),children:"Insert"})]})]})]}):null};function BD(t,s){return t.find(n=>n.parent_overlay_id===s&&n.is_photo_overlay&&n.image_url)||null}const $D=({open:t,onClose:s,overlay:n})=>{const[a,l]=k.useState(!1),[c,u]=k.useState(null),[i,_]=k.useState(.7),j=k.useRef(null),y=ym(),x=pu(),{data:v=[]}=Cp(),[C,P]=k.useState(!1),[I,z]=k.useState(null),[F,D]=k.useState(""),[X,K]=k.useState(!1),[te,J]=k.useState(null),[H,O]=k.useState(""),q=n?BD(v,n.id):null,W=(q==null?void 0:q.image_url)||null;Do.useEffect(()=>{q&&_(q.opacity??.7)},[q==null?void 0:q.id]);const Q=Ze=>{var Ke;const ke=(Ke=Ze.target.files)==null?void 0:Ke[0];if(!ke||!n)return;if(!ke.type.startsWith("image/")){Ve.error("Please select an image file");return}if(ke.size>10*1024*1024){Ve.error("Image must be less than 10MB");return}const ze=URL.createObjectURL(ke);z(ke),D(ze),P(!0),Ze.target.value=""},Z=async(Ze,ke,ze)=>{var Ke;if(n){l(!0);try{const{data:dt}=await Fs.auth.getUser(),Re=(Ke=dt==null?void 0:dt.user)==null?void 0:Ke.id;if(!Re)throw new Error("Not authenticated");const qt=`${n.id}-${Date.now()}.png`,ft=`${Re}/polygon-images/${qt}`;q!=null&&q.image_storage_path&&await Fs.storage.from("overlay-images").remove([q.image_storage_path]);const{error:Fe}=await Fs.storage.from("overlay-images").upload(ft,Ze,{contentType:"image/png"});if(Fe)throw Fe;const{data:{publicUrl:fe}}=Fs.storage.from("overlay-images").getPublicUrl(ft);q?await x.mutateAsync({id:q.id,image_url:fe,image_storage_path:ft,opacity:i,rotation_degrees:ke,scale_factor:ze}):await y.mutateAsync({name:`${n.name} - Site Plan`,type:n.type,geometry:n.geometry,style:{color:"transparent",fillColor:"transparent",fillOpacity:0,weight:0},is_visible:!0,created_by:n.created_by,layer_type:"general",parent_overlay_id:n.id,folder_id:n.folder_id||null,image_url:fe,image_storage_path:ft,opacity:i,is_photo_overlay:!0,rotation_degrees:ke,scale_factor:ze}),u(fe),Ve.success("Site plan uploaded as a new layer")}catch(dt){console.error("Upload error:",dt),Ve.error("Failed to upload image")}finally{l(!1)}}},oe=Ze=>{P(!1),URL.revokeObjectURL(F),z(null),D("");const ke=URL.createObjectURL(Ze);J(Ze),O(ke),K(!0)},ce=()=>{if(P(!1),I){const Ze=URL.createObjectURL(I);J(I),O(Ze),K(!0),URL.revokeObjectURL(F)}z(null),D("")},ae=()=>{P(!1),I&&URL.revokeObjectURL(F),z(null),D("")},ie=(Ze,ke)=>{K(!1),te&&Z(te,Ze,ke),URL.revokeObjectURL(H),J(null),O("")},de=()=>{K(!1),URL.revokeObjectURL(H),J(null),O("")},ge=()=>{const Ze=c||W;Ze&&(D(Ze),z(null),P(!0))},We=async()=>{if(q)try{q.image_storage_path&&await Fs.storage.from("overlay-images").remove([q.image_storage_path]);const{error:Ze}=await Fs.from("map_overlays").delete().eq("id",q.id);if(Ze)throw Ze;u(null),Ve.success("Site plan layer removed")}catch(Ze){console.error("Remove error:",Ze),Ve.error("Failed to remove site plan")}},Ee=async Ze=>{_(Ze[0]),q&&await x.mutateAsync({id:q.id,opacity:Ze[0]})},ve=c||W,we=t&&!C&&!X;return e.jsxs(e.Fragment,{children:[e.jsx(dd,{open:we,onOpenChange:Ze=>!Ze&&s(),children:e.jsxs(ud,{className:"sm:max-w-md bg-background",children:[e.jsxs(Gd,{children:[e.jsxs(Hd,{className:"flex items-center gap-2",children:[e.jsx(Zd,{className:"w-5 h-5"}),"Add Site Plan / Image"]}),e.jsxs(vg,{children:['Upload an image or site plan to overlay on "',n==null?void 0:n.name,'". It will be added as a separate child layer.']})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:`border-2 border-dashed rounded-lg p-6 text-center transition-colors ${a?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,children:a?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Va,{className:"w-8 h-8 animate-spin text-primary"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}):ve?e.jsxs("div",{className:"space-y-3",children:[e.jsx("img",{src:ve,alt:"Site plan preview",className:"max-h-48 mx-auto rounded-md object-contain"}),e.jsxs("div",{className:"flex justify-center gap-2",children:[e.jsxs(Le,{size:"sm",variant:"outline",onClick:ge,children:[e.jsx(xS,{className:"w-4 h-4 mr-2"}),"Crop"]}),e.jsxs(Le,{size:"sm",variant:"outline",onClick:()=>{var Ze;return(Ze=j.current)==null?void 0:Ze.click()},children:[e.jsx(Ab,{className:"w-4 h-4 mr-2"}),"Replace"]}),e.jsxs(Le,{size:"sm",variant:"destructive",onClick:We,children:[e.jsx(wr,{className:"w-4 h-4 mr-2"}),"Remove"]})]})]}):e.jsxs("div",{className:"cursor-pointer",onClick:()=>{var Ze;return(Ze=j.current)==null?void 0:Ze.click()},children:[e.jsx(Ab,{className:"w-12 h-12 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm font-medium",children:"Click to upload"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"PNG, JPG, or GIF (max 10MB)"})]})}),e.jsx("input",{ref:j,type:"file",accept:"image/*",onChange:Q,className:"hidden"}),ve&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{children:["Image Opacity: ",Math.round(i*100),"%"]}
755),e.jsx(Ca,{value:[i],onValueChange:Ee,min:.1,max:1,step:.05,className:"w-full"})]})]}),e.jsx(vf,{children:e.jsx(Le,{variant:"outline",onClick:s,children:"Done"})})]})}),C&&e.jsx(zD,{open:C,imageUrl:F,fileName:(I==null?void 0:I.name)||"image",onCrop:oe,onSkip:ce,onCancel:ae}),X&&e.jsx(OD,{open:X,imageUrl:H,initialRotation:(q==null?void 0:q.rotation_degrees)??0,initialScale:(q==null?void 0:q.scale_factor)??1,onConfirm:ie,onCancel:de})]})},mg=t=>{if(t.length<3)return{acres:0,sqft:0};try{const s=t.map(u=>[u.lng,u.lat]);s.push(s[0]);const n=Xn([s]),l=zr(n)*10.7639,c=l/43560;return{acres:Math.round(c*100)/100,sqft:Math.round(l)}}catch(s){return console.error("Error calculating polygon area:",s),{acres:0,sqft:0}}},Ub=t=>{if(t.length<2)return 0;try{const s=t.map(c=>[c.lng,c.lat]);s.push(s[0]);const n=Yd(s),l=i_(n,{units:"kilometers"})*3280.84;return Math.round(l)}catch(s){return console.error("Error calculating perimeter:",s),0}},VD=t=>{if(t.length<2)return[];const s=[];for(let n=0;n<t.length;n++){const a=t[n],l=t[(n+1)%t.length];try{const c=Yd([[a.lng,a.lat],[l.lng,l.lat]]),u=i_(c,{units:"kilometers"}),i=Math.round(u*3280.84),_={lat:(a.lat+l.lat)/2,lng:(a.lng+l.lng)/2};s.push({start:a,end:l,lengthFt:i,midpoint:_})}catch{}}return s},qD=t=>{if(t.length===0)return{lat:0,lng:0};let s=0,n=0;return t.forEach(a=>{s+=a.lat,n+=a.lng}),{lat:s/t.length,lng:n/t.length}},GD=(t,s)=>{if(t.length<3||s.length<3)return!1;try{const n=s.map(l=>[l.lng,l.lat]);n.push(n[0]);const a=Xn([n]);for(const l of t){const c=us([l.lng,l.lat]);if(!uu(c,a))return!1}return!0}catch(n){return console.error("Error checking polygon containment:",n),!1}},UE=t=>{const s=pu(),[n,a]=k.useState(!1),l=k.useMemo(()=>{if(!(t!=null&&t.geometry)||t.geometry.length<3)return{area:{acres:0,sqft:0},perimeter:0,edges:[],centroid:{lat:0,lng:0}};const O=mg(t.geometry),q=Ub(t.geometry),W=VD(t.geometry),Q=qD(t.geometry);return{area:O,perimeter:q,edges:W,centroid:Q}},[t==null?void 0:t.geometry]),c=k.useCallback(async O=>{if(t){a(!0);try{await s.mutateAsync({id:t.id,...O}),Ve.success("Visual style updated")}catch{Ve.error("Failed to update visual style")}finally{a(!1)}}},[t,s]),u=k.useCallback(async()=>{if(t){a(!0);try{const{area:O,perimeter:q}=l;await s.mutateAsync({id:t.id,show_area_label:!t.show_area_label,calculated_area_acres:O.acres,calculated_area_sqft:O.sqft,calculated_perimeter_ft:q}),Ve.success(t.show_area_label?"Area label hidden":"Area label shown")}catch{Ve.error("Failed to toggle area label")}finally{a(!1)}}},[t,s,l]),i=k.useCallback(async O=>{if(t){a(!0);try{const{area:q,perimeter:W}=l;await s.mutateAsync({id:t.id,area_label_unit:O,calculated_area_acres:q.acres,calculated_area_sqft:q.sqft,calculated_perimeter_ft:W}),Ve.success(`Area label unit set to ${O}`)}catch{Ve.error("Failed to update area label unit")}finally{a(!1)}}},[t,s,l]),_=k.useCallback(async()=>{if(t){a(!0);try{await s.mutateAsync({id:t.id,show_measurements:!t.show_measurements}),Ve.success(t.show_measurements?"Measurements hidden":"Measurements shown")}catch{Ve.error("Failed to toggle measurements")}finally{a(!1)}}},[t,s]),j=k.useCallback(async O=>{if(t){a(!0);try{const q={...O,id:crypto.randomUUID()},W=Array.isArray(t.callout_markers)?t.callout_markers:[];await s.mutateAsync({id:t.id,callout_markers:[...W,q]}),Ve.success("Callout added")}catch{Ve.error("Failed to add callout")}finally{a(!1)}}},[t,s]),y=k.useCallback(async O=>{if(t){a(!0);try{const W=(Array.isArray(t.callout_markers)?t.callout_markers:[]).filter(Q=>Q.id!==O);await s.mutateAsync({id:t.id,callout_markers:W}),Ve.success("Callout removed")}catch{Ve.error("Failed to remove callout")}finally{a(!1)}}},[t,s]),x=k.useCallback(async O=>{if(t){a(!0);try{const q={...O,id:crypto.randomUUID(),uploadedAt:new Date().toISOString()},W=Array.isArray(t.media_items)?t.media_items:[];await s.mutateAsync({id:t.id,media_items:[...W,q]}),Ve.success("Media added")}catch{Ve.error("Failed to add media")}finally{a(!1)}}},[t,s]),v=k.useCallback(async O=>{if(t){a(!0);try{const W=(Array.isArray(t.media_items)?t.media_items:[]).filter(Q=>Q.id!==O);await s.mutateAsync({id:t.id,media_items:W}),Ve.success("Media removed")}catch{Ve.error("Failed to remove media")}finally{a(!1)}}},[t,s]),C=k.useCallback(async(O,q)=>{if(t){a(!0);try{await s.mutateAsync({id:t.id,approval_status:O,approved_by:O==="approved"?q:null,approved_at:O==="approved"?new Date().toISOString():null}),Ve.success(`Status changed to ${O}`)}catch{Ve.error("Failed to update status")}finally{a(!1)}}},[t,s]),P=k.useCallback(async O=>{if(t){a(!0);
755try{const q=t.current_version||1,W=Array.isArray(t.version_history)?t.version_history:[],Q={version:q,timestamp:new Date().toISOString(),changes:O,geometry:t.geometry};await s.mutateAsync({id:t.id,version_history:[...W,Q],current_version:q+1}),Ve.success(`Version ${q+1} saved`)}catch{Ve.error("Failed to save version")}finally{a(!1)}}},[t,s]),I=k.useCallback(async O=>{if(!t)return;const W=(Array.isArray(t.version_history)?t.version_history:[]).find(Q=>Q.version===O);if(!W||!W.geometry){Ve.error("Version data not found");return}a(!0);try{await s.mutateAsync({id:t.id,geometry:W.geometry}),Ve.success(`Restored to version ${O}`)}catch{Ve.error("Failed to restore version")}finally{a(!1)}},[t,s]),z=k.useCallback(async(O,q)=>{if(t){a(!0);try{await s.mutateAsync({id:t.id,before_image_url:O,after_image_url:q}),Ve.success("Before/after images updated")}catch{Ve.error("Failed to update images")}finally{a(!1)}}},[t,s]),F=k.useCallback(async O=>{if(t){a(!0);try{await s.mutateAsync({id:t.id,video_url:O}),Ve.success("Video updated")}catch{Ve.error("Failed to update video")}finally{a(!1)}}},[t,s]),D=k.useCallback(async O=>{if(t){a(!0);try{const{calculateSetbacks:q,setbackResultToGeoJSON:W}=await br(async()=>{const{calculateSetbacks:ce,setbackResultToGeoJSON:ae}=await Promise.resolve().then(()=>f_);return{calculateSetbacks:ce,setbackResultToGeoJSON:ae}},void 0),Q={front_ft:O.front_ft??t.setback_front_ft??null,rear_ft:O.rear_ft??t.setback_rear_ft??null,side_ft:O.side_ft??t.setback_side_ft??null,side1_ft:O.side1_ft??t.setback_side1_ft??null,side2_ft:O.side2_ft??t.setback_side2_ft??null},Z=q(t.geometry,Q),oe=W(Z);await s.mutateAsync({id:t.id,setback_front_ft:Q.front_ft,setback_rear_ft:Q.rear_ft,setback_side_ft:Q.side_ft,setback_side1_ft:Q.side1_ft,setback_side2_ft:Q.side2_ft,setback_geometry:oe}),Ve.success("Setbacks updated")}catch(q){console.error("Failed to update setbacks:",q),Ve.error("Failed to update setbacks")}finally{a(!1)}}},[t,s]),X=k.useCallback(async()=>{if(t){a(!0);try{await s.mutateAsync({id:t.id,setback_front_ft:null,setback_rear_ft:null,setback_side_ft:null,setback_side1_ft:null,setback_side2_ft:null,setback_geometry:null}),Ve.success("Setbacks cleared")}catch{Ve.error("Failed to clear setbacks")}finally{a(!1)}}},[t,s]),K=k.useCallback(async()=>{if(t){a(!0);try{await s.mutateAsync({id:t.id,is_draggable:!t.is_draggable}),Ve.success(t.is_draggable?"Dragging disabled":"Dragging enabled")}catch{Ve.error("Failed to toggle draggable")}finally{a(!1)}}},[t,s]),te=k.useCallback(async O=>{if(t)try{await s.mutateAsync({id:t.id,geometry:O})}catch(q){console.error("Failed to update geometry:",q),Ve.error("Failed to update position")}},[t,s]),J=k.useCallback(async O=>{if(t){a(!0);try{await s.mutateAsync({id:t.id,layer_type:O}),Ve.success(`Layer type set to ${O.replace(/_/g," ")}`)}catch{Ve.error("Failed to update layer type")}finally{a(!1)}}},[t,s]),H=k.useCallback(async O=>{if(t){a(!0);try{await s.mutateAsync({id:t.id,parent_overlay_id:O}),Ve.success(O?"Linked to property outline":"Unlinked from parent")}catch{Ve.error("Failed to link to parent")}finally{a(!1)}}},[t,s]);return{polygonMetrics:l,isUpdating:n,updateVisualStyle:c,toggleAreaLabel:u,setAreaLabelUnit:i,toggleMeasurements:_,addCalloutMarker:j,removeCalloutMarker:y,addMediaItem:x,removeMediaItem:v,updateApprovalStatus:C,saveVersionSnapshot:P,restoreVersion:I,setBeforeAfterImages:z,setVideoUrl:F,updateSetbacks:D,clearSetbacks:X,toggleDraggable:K,updateGeometry:te,updateLayerType:J,linkToParent:H}},wj=t=>{if(!Array.isArray(t))return{lat:0,lng:0};if(t.length===0)return{lat:0,lng:0};if(t.length<3){let s=0,n=0;return t.forEach(a=>{s+=a.lat,n+=a.lng}),{lat:s/t.length,lng:n/t.length}}try{const s=t.map(l=>[l.lng,l.lat]);s.push(s[0]);const n=Xn([s]),a=Yo(n);return{lat:a.geometry.coordinates[1],lng:a.geometry.coordinates[0]}}catch{let n=0,a=0;return t.forEach(l=>{n+=l.lat,a+=l.lng}),{lat:n/t.length,lng:a/t.length}}},Nj=t=>{if(!Array.isArray(t))return{minLat:0,maxLat:0,minLng:0,maxLng:0,width:0,height:0};if(t.length===0)return{minLat:0,maxLat:0,minLng:0,maxLng:0,width:0,height:0};let s=1/0,n=-1/0,a=1/0,l=-1/0;return t.forEach(c=>{s=Math.min(s,c.lat),n=Math.max(n,c.lat),a=Math.min(a,c.lng),l=Math.max(l,c.lng)}),{minLat:s,maxLat:n,minLng:a,maxLng:l,width:l-a,height:n-s}},fk=(t,s,n)=>t.map(a=>({lat:a.lat+s,lng:a.lng+n})),r0=(t,s,n,a)=>
755{if(a===0)return t;const l=a*Math.PI/180,c=Math.cos(l),u=Math.sin(l),i=Math.cos(s*Math.PI/180);return t.map(_=>{const j=(_.lng-n)*i,y=_.lat-s,x=j*c-y*u;return{lat:j*u+y*c+s,lng:x/i+n}})},HD=(t,s,n,a)=>a===1?t:t.map(l=>{const c=l.lng-n,u=l.lat-s;return{lat:s+u*a,lng:n+c*a}}),pk=(t,s,n,a,l,c=0)=>{if(a===1)return t;if(l==="both")return HD(t,s,n,a);if(c!==0){const i=r0(t,s,n,-c).map(_=>{const j=_.lng-n,y=_.lat-s;return{lat:l==="length"?s+y*a:_.lat,lng:l==="width"?n+j*a:_.lng}});return r0(i,s,n,c)}return t.map(u=>{const i=u.lng-n,_=u.lat-s;return{lat:l==="length"?s+_*a:u.lat,lng:l==="width"?n+i*a:u.lng}})},eP=t=>{const s=Nj(t),n=wj(t);return{topLeft:{lat:s.maxLat,lng:s.minLng},topRight:{lat:s.maxLat,lng:s.maxLng},bottomLeft:{lat:s.minLat,lng:s.minLng},bottomRight:{lat:s.minLat,lng:s.maxLng},top:{lat:s.maxLat,lng:(s.minLng+s.maxLng)/2},right:{lat:(s.minLat+s.maxLat)/2,lng:s.maxLng},bottom:{lat:s.minLat,lng:(s.minLng+s.maxLng)/2},left:{lat:(s.minLat+s.maxLat)/2,lng:s.minLng},center:n}},gk=(t,s)=>{const n=s.lng-t.lng,a=s.lat-t.lat;return Math.atan2(a,n)*(180/Math.PI)},ZD=(t,s,n)=>{const a=gk(t,s);return gk(t,n)-a},WD=(t,s)=>s<=0?t:Math.round(t/s)*s,xk=(t,s)=>{const n=us([t.lng,t.lat]),a=us([s.lng,s.lat]);return gi(n,a,{units:"kilometers"})*3280.84},_k=t=>{if(t.length<3)return{widthFt:0,lengthFt:0};const s=Nj(t),n=wj(t),a=xk({lat:n.lat,lng:s.minLng},{lat:n.lat,lng:s.maxLng}),l=xk({lat:s.minLat,lng:n.lng},{lat:s.maxLat,lng:n.lng});return{widthFt:a,lengthFt:l}},tP=({overlay:t,onTransformComplete:s})=>{const n=pu(),[a,l]=k.useState({mode:"none",isTransforming:!1,previewGeometry:null,startPoint:null,startAngle:0,currentAngle:0,startScale:1,currentScale:1,scaleAxis:(t==null?void 0:t.scale_axis)||"both",currentDimensions:null}),[c,u]=k.useState(!1),[i,_]=k.useState(25),[j,y]=k.useState(!1),[x,v]=k.useState(15),C=k.useMemo(()=>{if(!(t!=null&&t.geometry)||!Array.isArray(t.geometry)||t.geometry.length<3)return null;const W=t.geometry[0];return!W||typeof W.lat!="number"||typeof W.lng!="number"?null:t.geometry},[t==null?void 0:t.geometry]);k.useEffect(()=>{t!=null&&t.scale_axis&&l(W=>({...W,scaleAxis:t.scale_axis}))},[t==null?void 0:t.id,t==null?void 0:t.scale_axis]);const P=k.useMemo(()=>C?eP(C):null,[C]),I=k.useMemo(()=>C?wj(C):null,[C]),z=k.useCallback(W=>{l(Q=>({...Q,mode:W,isTransforming:!1,previewGeometry:null,startPoint:null}))},[]),F=k.useCallback(async W=>{if(l(Q=>({...Q,scaleAxis:W})),t!=null&&t.id)try{await n.mutateAsync({id:t.id,scale_axis:W})}catch(Q){console.error("Failed to save scale axis:",Q)}},[t==null?void 0:t.id,n]),[D,X]=k.useState(null),K=k.useCallback(W=>{if(!C||!I)return;const Q=_k(C);X([...C]),l(Z=>({...Z,isTransforming:!0,startPoint:W,previewGeometry:[...C],startAngle:(t==null?void 0:t.rotation_degrees)||0,currentAngle:(t==null?void 0:t.rotation_degrees)||0,startScale:(t==null?void 0:t.scale_factor)||1,currentScale:(t==null?void 0:t.scale_factor)||1,currentDimensions:Q}))},[C,t==null?void 0:t.rotation_degrees,t==null?void 0:t.scale_factor,I]),te=k.useCallback(W=>{if(!a.isTransforming||!a.startPoint||!C||!I)return;const Q=D||C;let Z,oe=a.currentAngle,ce=a.currentScale;switch(a.mode){case"move":{const ie=W.lat-a.startPoint.lat,de=W.lng-a.startPoint.lng;Z=fk(Q,ie,de);break}case"rotate":{const ie=ZD(I,a.startPoint,W);oe=a.startAngle+ie,j&&(oe=WD(oe,x)),oe=(oe%360+360)%360,t!=null&&t.image_url?Z=C:Z=r0(C,I.lat,I.lng,oe-((t==null?void 0:t.rotation_degrees)||0));break}case"scale":{const ie=a.scaleAxis;let de,ge;ie==="width"?(de=Math.abs(a.startPoint.lng-I.lng),ge=Math.abs(W.lng-I.lng)):ie==="length"?(de=Math.abs(a.startPoint.lat-I.lat),ge=Math.abs(W.lat-I.lat)):(de=Math.sqrt(Math.pow(a.startPoint.lat-I.lat,2)+Math.pow(a.startPoint.lng-I.lng,2)),ge=Math.sqrt(Math.pow(W.lat-I.lat,2)+Math.pow(W.lng-I.lng,2))),de>0&&(ce=a.startScale*ge/de,ce=Math.max(.1,Math.min(10,ce)));const We=ce/((t==null?void 0:t.scale_factor)||1);Z=pk(C,I.lat,I.lng,We,ie,0);break}default:return}const ae=a.mode==="scale"?_k(Z):a.currentDimensions;l(ie=>({...ie,previewGeometry:Z,currentAngle:oe,currentScale:ce,currentDimensions:ae}))},[a,C,D,t==null?void 0:t.rotation_degrees,t==null?void 0:t.scale_factor,I,j,x]),J=k.useCallback(async(W=!1)=>
755{if(t!=null&&t.id){if(!W&&a.previewGeometry)try{const{acres:Q,sqft:Z}=mg(a.previewGeometry),oe=Ub(a.previewGeometry);await n.mutateAsync({id:t.id,geometry:a.previewGeometry,rotation_degrees:a.currentAngle,scale_factor:a.currentScale,calculated_area_acres:Q,calculated_area_sqft:Z,calculated_perimeter_ft:oe}),s==null||s(a.previewGeometry);const ce=a.mode==="move"?"moved":a.mode==="rotate"?"rotated":"scaled";Ve.success(`Polygon ${ce} successfully`)}catch(Q){Ve.error("Failed to save transform"),console.error("Transform save error:",Q)}X(null),l(Q=>({...Q,isTransforming:!1,previewGeometry:null,startPoint:null}))}},[t,a,n,s]),H=k.useCallback(()=>{J(!0)},[J]),O=k.useCallback(async W=>{if(!(t!=null&&t.id)||!C||!I)return;let Q=[...C],Z=t.rotation_degrees||0,oe=t.scale_factor||1;if(W.offsetXFt||W.offsetYFt){const ae=364e3*Math.cos(I.lat*Math.PI/180),ie=(W.offsetYFt||0)/364e3,de=(W.offsetXFt||0)/ae;Q=fk(Q,ie,de)}if(W.rotationDegrees!==void 0){const ce=W.rotationDegrees-Z;ce!==0&&(t!=null&&t.image_url||(Q=r0(Q,I.lat,I.lng,ce)),Z=W.rotationDegrees)}if(W.scalePercent!==void 0&&W.scalePercent!==100){const ce=W.scalePercent/100;if(ce!==1){const ae=W.scaleAxis??a.scaleAxis;Q=pk(Q,I.lat,I.lng,ce,ae,0),oe=oe*ce}}try{const{acres:ce,sqft:ae}=mg(Q),ie=Ub(Q);await n.mutateAsync({id:t.id,geometry:Q,rotation_degrees:Z,scale_factor:oe,calculated_area_acres:ce,calculated_area_sqft:ae,calculated_perimeter_ft:ie}),Ve.success("Transform applied")}catch(ce){Ve.error("Failed to apply transform"),console.error("Numeric transform error:",ce)}},[t==null?void 0:t.id,t==null?void 0:t.rotation_degrees,t==null?void 0:t.scale_factor,C,I,n,a.scaleAxis]),q=k.useCallback(async()=>{if(t!=null&&t.id)try{await n.mutateAsync({id:t.id,rotation_degrees:0,scale_factor:1}),Ve.success("Transform values reset")}catch{Ve.error("Failed to reset transform")}},[t,n]);return{transformState:a,handles:P,centroid:I,setTransformMode:z,setScaleAxis:F,startTransform:K,updateTransform:te,endTransform:J,cancelTransform:H,applyNumericTransform:O,resetTransform:q,snapToGrid:c,setSnapToGrid:u,snapGridSize:i,setSnapGridSize:_,snapToAngle:j,setSnapToAngle:y,snapAngleIncrement:x,setSnapAngleIncrement:v,isUpdating:n.isPending}},sP=({overlay:t,maxHistorySize:s=50})=>{const n=pu(),[a,l]=k.useState([]),[c,u]=k.useState(-1),[i,_]=k.useState(!1),[j,y]=k.useState(null);k.useEffect(()=>{const te=t==null?void 0:t.geometry;Array.isArray(te)&&te.length>=3&&te[0]&&typeof te[0].lat=="number"&&typeof te[0].lng=="number"&&!j&&y({id:"original",timestamp:new Date().toISOString(),action:"edit",geometry:[...te],rotation_degrees:t.rotation_degrees??0,scale_factor:t.scale_factor??1,description:"Original position"})},[t==null?void 0:t.id,t==null?void 0:t.geometry,j]),k.useEffect(()=>{y(null),l([]),u(-1)},[t==null?void 0:t.id]);const x=k.useMemo(()=>{const te=[];if(j&&te.push(j),t!=null&&t.version_history)try{t.version_history.forEac
755h(H=>{te.push({id:`v${H.version}`,timestamp:H.timestamp,action:"edit",geometry:H.geometry||t.geometry,rotation_degrees:t.rotation_degrees||0,scale_factor:t.scale_factor||1,description:H.changes||"Version snapshot"})})}catch{}return te},[t==null?void 0:t.version_history,t==null?void 0:t.geometry,t==null?void 0:t.rotation_degrees,t==null?void 0:t.scale_factor,j]),v=k.useMemo(()=>[...x,...a],[x,a]),C=c===-1&&v.length>=2||c>0,P=c>=0&&c<v.length-1,I=k.useCallback((te,J,H,O,q)=>{const W={id:`local-${Date.now()}`,timestamp:new Date().toISOString(),action:te,geometry:J,rotation_degrees:O,scale_factor:q,description:H};l(Q=>[...c>=0?Q.slice(0,c-x.length+1):Q,W].slice(-s)),u(-1)},[c,x.length,s]),z=k.useCallback(async()=>{var te;if(!(t!=null&&t.id)||!C||i)return!1;_(!0);try{const J=c===-1?v.length-2:c-1;if(J<0)return Ve.info("Nothing to undo"),!1;const H=v[J];return await n.mutateAsync({id:t.id,geometry:H.geometry,rotation_degrees:H.rotation_degrees||0,scale_factor:H.scale_factor||1}),u(J),Ve.success(`Undid: ${((te=v[J+1])==null?void 0:te.description)||"last change"}`),!0}catch(J){return Ve.error("Failed to undo"),console.error("Undo error:",J),!1}finally{_(!1)}},[t,C,i,c,v,n]),F=k.useCallback(async()=>{if(!(t!=null&&t.id)||!P||i)return!1;_(!0);try{const te=c+1,J=v[te];return await n.mutateAsync({id:t.id,geometry:J.geometry,rotation_degrees:J.rotation_degrees||0,scale_factor:J.scale_factor||1}),u(te===v.length-1?-1:te),Ve.success(`Redid: ${J.description}`),!0}catch(te){return Ve.error("Failed to redo"),console.error("Redo error:",te),!1}finally{_(!1)}},[t,P,i,c,v,n]),D=k.useCallback(async te=>{if(!(t!=null&&t.id)||i)return!1;const J=v.findIndex(H=>H.id===te);if(J<0)return Ve.error("History entry not found"),!1;_(!0);try{const H=v[J];return await n.mutateAsync({id:t.id,geometry:H.geometry,rotation_degrees:H.rotation_degrees||0,scale_factor:H.scale_factor||1}),u(J===v.length-1?-1:J),Ve.success(`Restored: ${H.description}`),!0}catch(H){return Ve.error("Failed to restore version"),console.error("Jump to entry error:",H),!1}finally{_(!1)}},[t,i,v,n]),X=k.useCallback(()=>{l([]),u(-1)},[]),K=k.useCallback(async te=>{if(!(t!=null&&t.id))return!1;try{const J=t.version_history||[],H=J.length+1,O={version:H,timestamp:new Date().toISOString(),changes:te,geometry:t.geometry};return await n.mutateAsync({id:t.id,version_history:[...J,O],current_version:H}),Ve.success(`Saved version ${H}`),!0}catch(J){return Ve.error("Failed to save snapshot"),console.error("Save snapshot error:",J),!1}},[t,n]);return{fullHistory:v,currentIndex:c,canUndo:C,canRedo:P,isRestoring:i,pushToHistory:I,undo:z,redo:F,jumpToEntry:D,clearLocalHistory:X,saveSnapshot:K,historyCount:v.length,currentEntry:c>=0?v[c]:v[v.length-1]}},YD=({isActive:t,onUndo:s,onRedo:n,canUndo:a,canRedo:l,onCancel:c,onReset:u})=>{const i=k.useCallback(_=>{if(!t)return;const j=_.target;if(!(j.tagName==="INPUT"||j.tagName==="TEXTAREA"||j.isContentEditable)){if((_.ctrlKey||_.metaKey)&&_.key==="z"&&!_.shiftKey){a&&(_.preventDefault(),_.stopPropagation(),s());return}if((_.ctrlKey||_.metaKey)&&_.key==="y"){l&&(_.preventDefault(),_.stopPropagation(),n());return}if((_.ctrlKey||_.metaKey)&&_.key==="z"&&_.shiftKey){u?(_.preventDefault(),_.stopPropagation(),u()):l&&(_.preventDefault(),_.stopPropagation(),n());return}if(_.key==="Escape"&&c){_.preventDefault(),_.stopPropagation(),c();return}}},[t,s,n,a,l,c,u]);return k.useEffect(()=>{if(t)return document.addEventListener("keydown",i,!0),()=>{document.removeEventListener("keydown",i,!0)}},[t,i]),{shortcuts:[{key:"Ctrl+Z",action:"Undo",available:a},{key:"Ctrl+Y",action:"Redo",available:l},...u?[{key:"Ctrl+Shift+Z",action:"Reset",available:!0}]:[],...c?[{key:"Esc",action:"Cancel",available:!0}]:[]]}},XD=(t={})=>{const{enabled:s=!0,autoApply:n=!1,parkingSpaceSize:a=360}=t,{data:l=[]}=Cp(),c=pu(),u=k.useCallback(C=>C.parent_overlay_id?l.filter(P=>P.parent_overlay_id===C.parent_overlay_id&&P.layer_type==="parking"&&P.id!==C.id):[],[l]),i=k.useCallback(C=>C.parent_overlay_id&&l.find(P=>P.id===C.parent_overlay_id)||null,[l]),_=k.useCallback(C=>l.filter(I=>
755I.parent_overlay_id===C&&I.layer_type==="building_footprint").reduce((I,z)=>{if(z.geometry&&z.geometry.length>=3){const{sqft:F}=mg(z.geometry);return I+F}return I},0),[l]),j=k.useCallback(C=>{const P=l.find(D=>D.id===C);if(!(P!=null&&P.geometry)||P.geometry.length<3)return 0;const{sqft:I}=mg(P.geometry),z=_(C),F=(I-z)*.7;return Math.max(0,F)},[l,_]),y=k.useCallback(C=>{const I=C*.55;return Math.floor(I/a)},[a]),x=k.useCallback(async(C,P={})=>{if(!s)return null;const{showToast:I=!0,autoUpdate:z=n}=P,F=C.parent_overlay_id;if(!F)return I&&Ve.info("Building is not linked to a property outline"),null;const D=u(C),X=D.reduce((H,O)=>H+(O.parking_spaces||0),0),K=j(F),te=y(K),J={newParkingSpaces:te,previousParkingSpaces:X,affectedLayers:D.map(H=>H.id)};if(z&&D.length>0){const H=X||D.length;for(const O of D){const W=(O.parking_spaces||1)/H,Q=Math.round(te*W);await c.mutateAsync({id:O.id,parking_spaces:Q})}if(I){const O=te-X,q=O>0?`+${O}`:O.toString();Ve.success(`Parking updated: ${te} spaces (${q})`)}}else if(I&&D.length>0){const H=te-X;Math.abs(H)>=5&&Ve.info(`Parking capacity changed: ${X} → ${te} spaces`,{action:{label:"Update",onClick:()=>x(C,{showToast:!0,autoUpdate:!0})}})}return J},[s,n,u,j,y,c]),v=k.useCallback(C=>{if(!l.find(J=>J.id===C))return null;const I=j(C),z=y(I),F=l.filter(J=>J.parent_overlay_id===C&&J.layer_type==="parking"),D=F.reduce((J,H)=>J+(H.parking_spaces||0),0),X=l.filter(J=>J.parent_overlay_id===C&&J.layer_type==="building_footprint"),K=X.reduce((J,H)=>H.geometry&&H.geometry.length>=3?J+mg(H.geometry).sqft:J,0),te=K>0?(D/(K/1e3)).toFixed(2):"N/A";return{availableAreaSqft:I,estimatedSpaces:z,currentSpaces:D,parkingRatio:te,parkingLayers:F.length,buildingLayers:X.length,totalBuildingSqft:K}},[l,j,y]);return{recalculateParking:x,getParkingSummary:v,findSiblingParkingLayers:u,findParentLayer:i,calculateAvailableParkingArea:j,estimateParkingSpaces:y,isRecalculating:c.isPending}};function KD(t){return t%(2*Math.PI)*180/Math.PI}function G_(t){return t%360*Math.PI/180}
755function e1(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if(t.type==="Feature"&&t.geometry!==null&&t.geometry.type==="Point")return[...t.geometry.coordinates];if(t.type==="Point")return[...t.coordinates]}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return[...t];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function nP(t,s,n={}){if(n.final===!0)return JD(t,s);const a=e1(t),l=e1(s),c=G_(a[0]),u=G_(l[0]),i=G_(a[1]),_=G_(l[1]),j=Math.sin(u-c)*Math.cos(_),y=Math.cos(i)*Math.sin(_)-Math.sin(i)*Math.cos(_)*Math.cos(u-c);return KD(Math.atan2(j,y))}function JD(t,s){let n=nP(s,t);return n=(n+180)%360,n}var Or=nP,Iu=63710088e-1,QD={centimeters:Iu*100,centimetres:Iu*100,degrees:360/(2*Math.PI),feet:Iu*3.28084,inches:Iu*39.37,kilometers:Iu/1e3,kilometres:Iu/1e3,meters:Iu,metres:Iu,miles:Iu/1609.344,millimeters:Iu*1e3,millimetres:Iu*1e3,nauticalmiles:Iu/1852,radians:1,yards:Iu*1.0936};function UD(t,s,n={}){const a={type:"Feature"};return(n.id===0||n.id)&&(a.id=n.id),n.bbox&&(a.bbox=n.bbox),a.properties=s||{},a.geometry=t,a}function yk(t,s,n={}){if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!bk(t[0])||!bk(t[1]))throw new Error("coordinates must contain numbers");return UD({type:"Point",coordinates:t},s,n)}function eR(t,s="kilometers"){const n=QD[s];
755if(!n)throw new Error(s+" units is invalid");return t/n}function vk(t){return t%(2*Math.PI)*180/Math.PI}function Rv(t){return t%360*Math.PI/180}function bk(t){return!isNaN(t)&&t!==null&&!Array.isArray(t)}function tR(t,s,n,a={}){const l=e1(t),c=Rv(l[0]),u=Rv(l[1]),i=Rv(n),_=eR(s,a.units),j=Math.asin(Math.sin(u)*Math.cos(_)+Math.cos(u)*Math.sin(_)*Math.cos(i)),y=c+Math.atan2(Math.sin(i)*Math.sin(_)*Math.cos(u),Math.cos(_)-Math.sin(u)*Math.sin(j)),x=vk(y),v=vk(j);return l[2]!==void 0?yk([x,v,l[2]],a.properties):yk([x,v],a.properties)}var On=tR;function aP(t,s,n={}){const a={type:"Feature"};return(n.id===0||n.id)&&(a.id=n.id),n.bbox&&(a.bbox=n.bbox),a.properties=s||{},a.geometry=t,a}function sR(t,s,n={}){for(const l of t){if(l.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(l[l.length-1].length!==l[0].length)throw new Error("First and last Position are not equivalent.");for(let c=0;c<l[l.length-1].length;c++)if(l[l.length-1][c]!==l[0][c])throw new Error("First and last Position are not equivalent.")}return aP({type:"Polygon",coordinates:t},s,n)}function nR(t,s,n={}){return aP({type:"MultiPolygon",coordinates:t},s,n)}function aR(t,s){var n,a,l,c,u,i,_,j,y,x,v=0,C=t.type==="FeatureCollection",P=t.type==="Feature",I=C?t.features.length:1;for(n=0;n<I;n++){for(i=C?t.features[n].geometry:P?t.geometry:t,j=C?t.features[n].properties:P?t.properties:{},y=C?t.features[n].bbox:P?t.bbox:void 0,x=C?t.features[n].id:P?t.id:void 0,_=i?i.type==="GeometryCollection":!1,u=_?i.geometries.length:1,l=0;l<u;l++){if(c=_?i.geometries[l]:i,c===null){if(s(null,v,j,y,x)===!1)return!1;continue}switch(c.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(s(c,v,j,y,x)===!1)return!1;break}case"GeometryCollection":{for(a=0;a<c.geometries.length;a++)if(s(c.geometries[a],v,j,y,x)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}v++}}function rR(t){const s=[];if(aR(t,l=>{s.push(l.coordinates)}
vendor: 1,660 bytes, line 755
755),s.length<2)throw new Error("Must have at least two features");const n=t.features[0].properties||{},a=LM(s[0],...s.slice(1));return a.length===0?null:a.length===1?sR(a[0],n):nR(a,n)}var pd=rR;function rP(t,s,n={}){const a={type:"Feature"};return(n.id===0||n.id)&&(a.id=n.id),n.bbox&&(a.bbox=n.bbox),a.properties=s||{},a.geometry=t,a}function iR(t,s,n={}){for(const l of t){if(l.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(l[l.length-1].length!==l[0].length)throw new Error("First and last Position are not equivalent.");for(let c=0;c<l[l.length-1].length;c++)if(l[l.length-1][c]!==l[0][c])throw new Error("First and last Position are not equivalent.")}return rP({type:"Polygon",coordinates:t},s,n)}function oR(t,s,n={}){return rP({type:"MultiPolygon",coordinates:t},s,n)}function lR(t,s){var n,a,l,c,u,i,_,j,y,x,v=0,C=t.type==="FeatureCollection",P=t.type==="Feature",I=C?t.features.length:1;for(n=0;n<I;n++){for(i=C?t.features[n].geometry:P?t.geometry:t,j=C?t.features[n].properties:P?t.properties:{},y=C?t.features[n].bbox:P?t.bbox:void 0,x=C?t.features[n].id:P?t.id:void 0,_=i?i.type==="GeometryCollection":!1,u=_?i.geometries.length:1,l=0;l<u;l++){if(c=_?i.geometries[l]:i,c===null){if(s(null,v,j,y,x)===!1)return!1;continue}switch(c.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(s(c,v,j,y,x)===!1)return!1;break}case"GeometryCollection":{for(a=0;a<c.geometries.length;a++)if(s(c.geometries[a],v,j,y,x)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}v++}}function cR(t,s={}){const n=[];if(lR(t,l=>{n.push(l.coordinates)}
755),n.length<2)throw new Error("Must specify at least 2 geometries");const a=TM(n[0],...n.slice(1));return a.length===0?null:a.length===1?iR(a[0],s.properties):oR(a,s.properties)}var xm=cR;function dR(t){if(t.geometry.type==="Polygon")return t;const s=t.geometry.coordinates;let n=null,a=0;for(const l of s){const c=zr(Xn(l));c>a&&(a=c,n=l)}return Xn(n??s[0])}function uR(t){return(t.geometry.coordinates[0]||[]).slice(0,-1).map(n=>({lat:n[1],lng:n[0]}))}function sg(t,s){const n=us([t.lng,t.lat]);return uu(n,s)}function hR(t){const s=t.map(n=>[n.lng,n.lat]);return s.push([t[0].lng,t[0].lat]),Xn([s])}function Fv(t,s){try{const n=hR(t),a=xm(Un([s,n]));if(!a)return!1;const l=zr(n);return zr(a)>=l*.999}catch{return t.every(n=>sg(n,s))}}function mR(t,s,n){const a={lat:(t.lat+s.lat)/2,lng:(t.lng+s.lng)/2},l={lat:(t.lat+a.lat)/2,lng:(t.lng+a.lng)/2},c={lat:(a.lat+s.lat)/2,lng:(a.lng+s.lng)/2};return sg(t,n)&&sg(l,n)&&sg(a,n)&&sg(c,n)&&sg(s,n)}function jk(t){const s=t.map(n=>[n.lng,n.lat]);return s.length>0&&(s[0][0]!==s[s.length-1][0]||s[0][1]!==s[s.length-1][1])&&s.push([...s[0]]),Xn([s])}const iP={standard:{widthMultiplier:1,depthMultiplier:1},ada:{widthMultiplier:1,depthMultiplier:1},reserved:{widthMultiplier:1,depthMultiplier:1},ev_charging:{widthMultiplier:1,depthMultiplier:1},compact:{widthMultiplier:.8,depthMultiplier:.8},motorcycle:{widthMultiplier:.5,depthMultiplier:.5},van_accessible:{widthMultiplier:1.2,depthMultiplier:1},loading_zone:{widthMultiplier:1,depthMultiplier:1},no_parking:{widthMultiplier:1,depthMultiplier:1},island:{widthMultiplier:1,depthMultiplier:1}};function oP(t){return t<=25?1:t<=50?2:t<=75?3:t<=100?4:t<=150?5:t<=200?6:t<=300?7:t<=400?8:t<=500?9:Math.ceil(t*.02)+1}function oc(t,s,n){const a=us([t.lng,t.lat]),l=On(a,n,s,{units:"feet"});return{lat:l.geometry.coordinates[1],lng:l.geometry.coordinates[0]}}function H_(t,s,n,a,l,c="front"){const u=t,i=oc(u,a,s),_=oc(i,l,n),j=oc(u,l,n);return{geometry:[u,i,_,j],openEdgeIndex:c==="front"?0:2}}function fR(t){if(t.length<2)return{start:t[0],end:t[0],bearing:0,length_ft:0,edgeIndex:0};let s={start:t[0],end:t[1],bearing:0,length_ft:0,edgeIndex:0};for(let n=0;n<t.length;n++){const a=t[n],l=t[(n+1)%t.length],c=us([a.lng,a.lat]),u=us([l.lng,l.lat]),i=gi(c,u,{units:"feet"});i>s.length_ft&&(s={start:a,end:l,bearing:Or(c,u),length_ft:i,edgeIndex:n})}return s}function wk(t,s=!0){return s?(t+90)%360:(t-90+360)%360}function Hm(t,s){var vs,$t;const{stallWidth_ft:n,stallDepth_ft:a,aisleWidth_ft:l,layoutType:c,stripingVisible:u,exclusionZones:i}=s,_=[],j=[],y=[],x=[];if(t.length<3)return{stalls:[],stripingLines:[],driveAisles:[],islands:[],metrics:{totalSpaces:0,adaSpaces:0,rows:0,efficiency:0,aisleArea_sqft:0,stallArea_sqft:0,islandCount:0}};let v=jk(t);if(i&&i.length>0)try{let Ns=v;for(const Ts of i){if(!Ts||Ts.length<3)continue;const bs=jk(Ts);let en=null;try{en=pd(Ns,bs)}catch{en=pd(Un([Ns,bs]))}if(en){(en.geometry.type==="Polygon"||en.geometry.type==="MultiPolygon")&&(Ns=en);const Jt=dR(Ns);if(!(($t=(vs=Jt==null?void 0:Jt.geometry)==null?void 0:vs.coordinates)!=null&&$t[0])||Jt.geometry.coordinates[0].length<4)return{stalls:[],stripingLines:[],driveAisles:[],islands:[],metrics:{totalSpaces:0,adaSpaces:0,rows:0,efficiency:0,aisleArea_sqft:0,stallArea_sqft:0,islandCount:0}};v=Jt,Ns=Jt}}console.log("[ParkingGeometry] Applied",i.length,"exclusion zone(s)")}catch(Ns){console.error("[ParkingGeometry] Error applying exclusion zones:",Ns)}const C=uR(v),P=Yo(v),I=zr(v)*10.764,z=fR(C),F=z.bearing,D=wk(F,!0),X=wk(F,!1),K=z.length_ft,te={lat:(z.start.lat+z.end.lat)/2,lng:(z.start.lng+z.end.lng)/2},J={lat:P.geometry.coordinates[1],lng:P.geometry.coordinates[0]},H=us([te.lng,te.lat]),O=us([J.lng,J.lat]),q=Or(H,O),W=Math.abs((q-D+540)%360-180),Q=Math.abs((q-X+540)%360-180),Z=W<Q,oe=Z?D:X;console.log("[ParkingGeometry] Area:",(I/43560).toFixed(2),"acres"),console.log("[ParkingGeometry] Longest edge:",z.length_ft.toFixed(0),"ft"),console.log("[ParkingGeometry] Interior direction:",Z?"CW":"CCW");let ce=0;for(let Ns=0;Ns<C.length;Ns++){const Ts=C[Ns],bs=us([te.lng,te.lat]),en=us([Ts.lng,Ts.lat]),Jt=gi(bs,en,{units:"feet"}),ps=(Or(bs,en)-oe+540)%360-180;
755if(Math.abs(ps)<90){const nt=Jt*Math.cos(ps*Math.PI/180);ce=Math.max(ce,nt)}}console.log("[ParkingGeometry] Usable depth:",ce.toFixed(0),"ft");const ae=0,ie=K-ae*2,de=ce-ae*2;let ge,We,Ee=!1;switch(c){case"double_loaded":ge=a*2+l,We=Math.floor(ie/n),Ee=!0;break;case"single_loaded":ge=a+l,We=Math.floor(ie/n);break;case"angled_45":const Ns=n/Math.sin(Math.PI/4);ge=a*Math.cos(Math.PI/4)*2+l+2,We=Math.floor(ie/Ns),Ee=!0;break;case"angled_60":const Ts=n/Math.sin(Math.PI/3);ge=a*Math.cos(Math.PI/3)*2+l+2,We=Math.floor(ie/Ts),Ee=!0;break;default:ge=a*2+l,We=Math.floor(ie/n),Ee=!0}const ve=Math.floor(de/ge);if(console.log("[ParkingGeometry] Effective width:",ie.toFixed(0),"ft, depth:",de.toFixed(0),"ft"),console.log("[ParkingGeometry] Row module:",ge.toFixed(0),"ft, stalls/row:",We,"rows:",ve),ve===0||We===0)return{stalls:[],stripingLines:[],driveAisles:[],islands:[],metrics:{totalSpaces:0,adaSpaces:0,rows:0,efficiency:0,aisleArea_sqft:0,stallArea_sqft:0,islandCount:0}};const we=oc(z.start,F,ae),Ze=oc(we,oe,ae);let ke=0,ze=0;const Ke=s.maxStallRun??null,dt=s.islandType||"painted",Re=s.islandWidth_ft||(dt==="landscape"?6:4),qt=s.islandTrees??!1,ft=s.islandCrossAisle!==!1,Fe=s.islandTreeSpecies||"deciduous",fe=s.islandTreeHeight_ft||30,Qe=s.islandCanopyDiameter_ft||15,ht=s.islandCustomModelId,_t=s.islandCustomModelUrl;function He(Ns,Ts,bs,en,Jt){let Vs=0,ps=0,nt=0;for(;nt<We;){if(Ke&&ps>=Ke&&nt<We){const wn=Ee?a*2+l:a+l;if(ft){const Gs=Math.max(Re,l),Ue=oc(Ns,F,Vs),{geometry:Pe}=H_(Ue,Gs,wn,F,oe),je={lat:Pe.reduce((Ge,De)=>Ge+De.lat,0)/Pe.length,lng:Pe.reduce((Ge,De)=>Ge+De.lng,0)/Pe.length};y.push({id:`cross-aisle-${Ts}-${ze++}`,geometry:Pe,width_ft:Gs,labelPosition:je,labelText:"Cross Aisle",bearing:oe,centerPosition:je}),Vs+=Gs}else{const Gs=oc(Ns,F,Vs),{geometry:Ue}=H_(Gs,Re,wn,F,oe),Pe={lat:Ue.reduce((je,Ge)=>je+Ge.lat,0)/Ue.length,lng:Ue.reduce((je,Ge)=>je+Ge.lng,0)/Ue.length};x.push({id:`island-${Ts}-${ze++}`,geometry:Ue,type:dt,hasTree:dt==="landscape"&&qt,rowIndex:Ts,centerPosition:Pe,treeSpecies:Fe,treeHeight_ft:fe,canopyDiameter_ft:Qe,customModelId:ht,customModelUrl:_t}),Vs+=Re}ps=0;continue}const ts=oc(Ns,F,Vs),{geometry:ds,openEdgeIndex:Is}=H_(ts,n,a,F,Jt,en),tn=bs==="top"?nt:nt+We;if(_.push({id:`stall-${Ts}-${bs}-${nt}`,geometry:ds,isAda:!1,rowIndex:Ts,stallIndex:tn,openEdgeIndex:Is}),u&&nt<We-1&&!(Ke&&ps+1>=Ke&&nt+1<We)){const Gs=oc(ts,F,n),Ue=oc(Gs,Jt,a);j.push({id:`stripe-${ke++}`,start:Gs,end:Ue,type:"stall_divider"})}Vs+=n,nt++,ps++}return Vs}for(let Ns=0;Ns<ve;Ns++){const Ts=Ns*ge,bs=oc(Ze,oe,Ts),en=He(bs,Ns,"top","back",oe);if(u){const ts=oc(bs,F,en);j.push({id:`row-edge-${Ns}-top`,start:bs,end:ts,type:"row_edge"})}const Jt=oc(bs,oe,a),{geometry:Vs}=H_(Jt,We*n,l,F,oe),ps=oc(Jt,F,We*n/2),nt=oc(ps,oe,l/2);if(y.push({id:`aisle-${Ns}`,geometry:Vs,width_ft:l,labelPosition:nt,labelText:`Drive Aisle ${l}'`,bearing:F,centerPosition:nt}),Ee){const ts=oc(bs,oe,a+l);if(He(ts,Ns,"bottom","front",oe),u){const ds=oc(bs,oe,a+l+a),Is=oc(ds,F,en);j.push({id:`center-divider-${Ns}`,start:ds,end:Is,type:"center_divider"})}}else if(u){const ts=oc(bs,oe,a),ds=oc(ts,F,en);j.push({id:`center-divider-${Ns}`,start:ts,end:ds,type:"center_divider"})}}const as=_.filter(Ns=>Fv(Ns.geometry,v)),vt=j.filter(Ns=>mR(Ns.start,Ns.end,v)),Xe=y.filter(Ns=>Fv(Ns.geometry,v)),Ce=x.filter(Ns=>Fv(Ns.geometry,v)),Be=as.length,Dt=oP(Be);for(let Ns=0;Ns<Math.min(Dt,as.length);Ns++)as[Ns].isAda=!0;const Rt=Be*n*a,zt=Xe.reduce((Ns,Ts)=>Ns+Ts.width_ft*We*n,0),rs=I/43560,_s=rs>0?Math.round(Be/rs):0;return{stalls:as,stripingLines:vt,driveAisles:Xe,islands:Ce,metrics:{totalSpaces:Be,adaSpaces:Dt,rows:ve,efficiency:_s,aisleArea_sqft:zt,stallArea_sqft:Rt,islandCount:Ce.length}}}function kj(){return{stallWidth_ft:9,stallDepth_ft:18,aisleWidth_ft:24,layoutType:"double_loaded",stripingVisible:!0,aisleLabelsVisible:!0}}const lP=[{value:"double_loaded",label:"Double-Loaded",description:"Stalls on both sides of aisle (most efficient)"},{value:"single_loaded",label:"Single-Loaded",description:"Stalls on one side of aisle"},{value:"angled_45",label:"45° Angled",description:"Angled parking at 45 degrees"},{value:"angled_60",label:"60° Angled",description:"Angled parking at 60 degrees"}];function jf(t){if(t.length===0)return{lat:0,lng:0};let s=0,n=0;for(const a of t)s+=a.lat,n+=a.lng;return{lat:s/t.length,lng:n/t.length}}function cP(t){const{geometry:s}=t;if(s.length<4)return jf(s);const n=s[2],a=s[3];return{lat:(n.lat+a.lat)/2,lng:(n.lng+a.lng)/2}}function G0(t,s=4){if(t.length<4)return[];const n=[],[a,l,c,u]=t;for(let i=1;i<=s;i++){const _=i/(s+1),j=a.lat+_*(u.lat-a.lat),y=a.lng+_*(u.lng-a.lng),x=l.lat+_*(c.lat-l.lat),v=l.lng+_*(c.lng-l.lng);n.push({start:{lat:j,lng:y},end:{lat:x,lng:v}})}return n}function dP(t,s,n){if(t.length<4)return t;const a=jf(t),l=Math.sqrt(s*n);return t.map(c=>({lat:a.lat+(c.lat-a.lat)*l,lng:a.lng+(c.lng-a.lng)*l}))}function H0(t,s,n){if((!s||Object.keys(s).length===0)&&(!n||Object.keys(n).length===0))return t;let a=1;const l=t.stalls.map(_=>{const j=_.id.split("-"),y=j[1],x=j[2]||"top",v=`row-${y}-${x}`,C=n==null?void 0:n[v],P=s[_.id];if(!P&&!C)return _;const I={..._};if(C!=null&&C.hidden)return I.isRemoved=!0,I;if(P!=null&&P.isRemoved&&(I.isRemoved=!0),P!=null&&P.type){if(I.renderType=P.type,I.isAda=P.type==="ada"||P.type==="van_accessible",P.type==="island")I.islandFinish=P.islandFinish||"landscape",I.islandTreeEnabled=P.islandTreeEnabled??!0,I.islandTreeSpecies=P.islandTreeSpecies||"deciduous",I.edgeVisibility={front:!1,back:!1,left:!1,right:!1};else switch(P.type){case"ada":case"van_accessible":I.iconType="wheelchair";break;case"ev_charging":I.iconType="ev_charger";break;case"reserved":I.iconType="number",I.displayLabel=P.label||String(a++);break;case"loading_zone":case"no_parking":I.hasHatching=!0;break}const D=iP[P.type];D&&(D.widthMultiplier!==1||D.depthMultiplier!==1)&&(I.geometry=dP(_.geometry,D.widthMultiplier,D.depthMultiplier),I.effectiveWidth_ft=9*D.widthMultiplier,I.effectiveDepth_ft=18*D.depthMultiplier)}P!=null&&P.color&&(I.customColor=P.color),P!=null&&P.label&&(I.label=P.label,I.renderType==="reserved"&&(I.displayLabel=P.label));const z=C==null?void 0:C.edges,F=P==null?void 0:P.edges;return(z||F)&&(I.edgeVisibility={front:(F==null?void 0:F.front)??(z==null?void 0:z.front)??!1,back:(F==null?void 0:F.back)??(z==null?void 0:z.back)??!0,left:(F==null?void 0:F.left)??(z==null?void 0:z.left)??!0,right:(F==null?void 0:F.right)??(z==null?void 0:z.right)??!0}),I}),c=Object.entries(s).filter(([_,j])=>j.type==="island"&&(j.islandWidthStalls||1)>1);for(const[_,j]of c){const y=j.islandWidthStalls||1,x=_.split("-");if(x.length<4)continue;
755const v=x[1],C=x[2],P=parseInt(x[3],10);for(let I=1;I<y;I++){const z=`stall-${v}-${C}-${P+I}`,F=l.find(D=>D.id===z);F&&!F.isRemoved&&(F.isRemoved=!0)}}const u=l.filter(_=>!_.isRemoved),i=u.filter(_=>_.isAda||_.renderType==="ada"||_.renderType==="van_accessible").length;return{...t,stalls:l,metrics:{...t.metrics,totalSpaces:u.length,adaSpaces:i}}}function uP(t){const{geometry:s,openEdgeIndex:n,edgeVisibility:a}=t,l=[];if(a){const c=["front","right","back","left"];for(let u=0;u<s.length;u++){const i=c[u];if(a[i]){const _=s[u],j=s[(u+1)%s.length];l.push({start:_,end:j})}}return l}for(let c=0;c<s.length;c++){if(c===n)continue;const u=s[c],i=s[(c+1)%s.length];l.push({start:u,end:i})}return l}function hP(t,s){if(t.length<3)return{layout:{stalls:[],stripingLines:[],driveAisles:[],islands:[],metrics:{totalSpaces:0,adaSpaces:0,rows:0,efficiency:0,aisleArea_sqft:0,stallArea_sqft:0,islandCount:0}},orientationIndex:0,orientationAngle:0};const n=[];for(let c=0;c<t.length;c++){const u=[...t.slice(c),...t.slice(0,c)],i=Hm(u,s),_=t[c],j=t[(c+1)%t.length],y=us([_.lng,_.lat]),x=us([j.lng,j.lat]),v=Or(y,x);n.push({layout:i,edgeIndex:c,angle:v})}const a=[45,135];for(const c of a){const u=Hm(t,s);n.push({layout:u,edgeIndex:-1,angle:c})}let l=n[0];for(const c of n)c.layout.metrics.totalSpaces>l.layout.metrics.totalSpaces&&(l=c);return console.log("[ParkingOptimize] Tested",n.length,"orientations. Best:",l.layout.metrics.totalSpaces,"spaces at edge",l.edgeIndex),{layout:l.layout,orientationIndex:l.edgeIndex,orientationAngle:l.angle}}function Cj(t,s,n=.1){if(!t||t.length===0||!s||s.length===0)return[];const a=[],l=s.map(c=>{const u=c.coordinates.map(i=>[i.lng,i.lat]);return u.length>0&&(u[0][0]!==u[u.length-1][0]||u[0][1]!==u[u.length-1][1])&&u.push([...u[0]]),Xn([u])});for(const c of t){if(c.isRemoved)continue;const u=c.geometry.map(i=>[i.lng,i.lat]);u.length>0&&(u[0][0]!==u[u.length-1][0]||u[0][1]!==u[u.length-1][1])&&u.push([...u[0]]);try{const i=Xn([u]),_=zr(i);for(const j of l)try{let y=null;try{y=xm(i,j)}catch{y=xm(Un([i,j]))}if(y){const x=zr(y);if((_>0?x/_:0)>=n){a.push(c.id);break}}}catch{}}catch{}}return a}function pR(t,s,n,a,l,c){var u;if(!t||t.length<3||!a||a.length===0)return{stallOverrides:{},removedCount:0};if(!c)return console.warn("[ParkingGeometry] generateEntryPolygons function not provided"),{stallOverrides:{},removedCount:0};try{const i={stallWidth_ft:n.stallWidth_ft||9,stallDepth_ft:n.stallDepth_ft||18,aisleWidth_ft:n.aisleWidth_ft||24,layoutType:n.layoutType||"double_loaded",stripingVisible:!0,aisleLabelsVisible:!0},_=Hm(t,i);if(!_.stalls||_.stalls.length===0)return{stallOverrides:{},removedCount:0};const j=c(a,t,40,l);if(j.length===0)return{stallOverrides:{},removedCount:0};const y=Cj(_.stalls,j);if(y.length===0)return{stallOverrides:{},removedCount:0};const C={...((s==null?void 0:s.parkingCirculation)||{}).stallOverrides||{}};let P=0;for(const I of y)(u=C[I])!=null&&u.isRemoved||(C[I]={...C[I]||{},stallId:I,isRemoved:!0},P++);return{stallOverrides:C,removedCount:P}}catch(i){return console.warn("[ParkingGeometry] Auto-removal error:",i),{stallOverrides:{},removedCount:0}}}const t1=Object.freeze(Object.defineProperty({__proto__:null,PARKING_LAYOUT_TYPES:lP,STALL_TYPE_SIZE_MULTIPLIERS:iP,applyStallOverrides:H0,autoMarkIntersectingStallsRemoved:pR,calculateMinAdaSpaces:oP,generateDiagonalHatching:G0,generateParkingLayout:Hm,getDefaultParkingParams:kj,getStallBackEdgeCenter:cP,getStallCentroid:jf,getStallClosedEdges:uP,getStallsIntersectingEntryPoints:Cj,optimizeParkingLayout:hP,resizeStallGeometry:dP},Symbol.toStringTag,{value:"Module"})),gR=["#ef4444","#f97316","#f59e0b","#84cc16","#22c55e","#10b981","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#a855f7","#d946ef","#ec4899","#f43f5e"],xR=[{value:"solid",label:"Solid"},{value:"diagonal",label:"Diagonal Lines"},{value:"horizontal",label:"Horizontal Lines"},{value:"vertical",label:"Vertical Lines"},{value:"dots",label:"Dots"},{value:"crosshatch",label:"Crosshatch"}],Nk=[{value:"concrete",label:"Concrete",color:"#6b7280"},{value:"glass",label:"Glass",color:"#38bdf8"},{value:"brick",label:"Brick",color:"#b45309"},{value:"metal_panel",label:"Metal Panel",color:"#94a3b8"},{value:"stucco",label:"Stucco",color:"#d6d3d1"},{value:"tilt_up",label:"Tilt-Up",color:"#78716c"}];function _R({overlay:t,onUpdate:s,mode:n,isUpdating:a}){var j,y,x,v,C,P,I,z,F,D;const l=X=>{s({style:{...t.style,fillColor:X,color:X}})},c=X=>{s({style:{...t.style,fillOpacity:X/100}})},u=X=>{s({style:{...t.style,weight:X}})},i=X=>{s({fill_pattern:X})},_=X=>{const K=Nk.find(te=>te.value===X);
755s({material_preset:X,wall_color:(K==null?void 0:K.color)||null})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-sm font-medium",children:"Fill Color"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:gR.map(X=>{var K,te;return e.jsx("button",{className:`w-8 h-8 rounded-lg border-2 transition-all ${(((K=t.style)==null?void 0:K.fillColor)||((te=t.style)==null?void 0:te.color))===X?"border-foreground ring-2 ring-primary ring-offset-1":"border-transparent hover:border-foreground/30"}`,style:{backgroundColor:X},onClick:()=>l(X),disabled:a},X)})}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(be,{type:"color",value:((j=t.style)==null?void 0:j.fillColor)||((y=t.style)==null?void 0:y.color)||"#3b82f6",onChange:X=>l(X.target.value),className:"w-10 h-8 p-1 cursor-pointer"}),e.jsx(be,{type:"text",value:((x=t.style)==null?void 0:x.fillColor)||((v=t.style)==null?void 0:v.color)||"#3b82f6",onChange:X=>l(X.target.value),className:"h-8 text-xs font-mono flex-1",placeholder:"#hex"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-sm font-medium",children:"Fill Opacity"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round((((C=t.style)==null?void 0:C.fillOpacity)??.2)*100),"%"]})]}),e.jsx(Ca,{value:[(((P=t.style)==null?void 0:P.fillOpacity)??.2)*100],min:0,max:100,step:5,onValueChange:([X])=>c(X),disabled:a})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-sm font-medium",children:"3D Opacity"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round((t.opacity??.85)*100),"%"]})]}),e.jsx(Ca,{value:[(t.opacity??.85)*100],min:10,max:100,step:5,onValueChange:([X])=>s({opacity:X/100}),disabled:a}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Controls building transparency in 3D view"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-sm font-medium",children:"Show Outline"}),e.jsx(kt,{checked:(((I=t.style)==null?void 0:I.weight)??2)>0,onCheckedChange:X=>u(X?2:0),disabled:a})]}),(((z=t.style)==null?void 0:z.weight)??2)>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Outline Width"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[((F=t.style)==null?void 0:F.weight)??2,"px"]})]}),e.jsx(Ca,{value:[((D=t.style)==null?void 0:D.weight)??2],min:1,max:8,step:1,onValueChange:([X])=>u(X),disabled:a})]})]}),n==="2d"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-sm font-medium",children:"Fill Pattern"}),e.jsxs(rt,{value:t.fill_pattern||"solid",onValueChange:X=>i(X),disabled:a,children:[e.jsx(it,{className:"h-9",children:e.jsx(ct,{})}),e.jsx(ot,{children:xR.map(X=>e.jsx(le,{value:X.value,children:X.label},X.value))})]})]}),n==="3d"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-sm font-medium",children:"Material Preset"}),e.jsxs(rt,{value:t.material_preset||"concrete",onValueChange:X=>_(X),disabled:a,children:[e.jsx(it,{className:"h-9",children:e.jsx(ct,{})}),e.jsx(ot,{children:Nk.map(X=>e.jsx(le,{value:X.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-sm border",style:{backgroundColor:X.color}}),X.label]})},X.value))})]})]}),n==="3d"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-sm font-medium",children:"Wall Color Override"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(be,{type:"color",value:t.wall_color||"#6b7280",onChange:X=>s({wall_color:X.target.value}),className:"w-10 h-8 p-1 cursor-pointer",disabled:a}),e.jsx(be,{type:"text",value:t.wall_color||"",onChange:X=>s({wall_color:X.target.value}),className:"h-8 text-xs font-mono flex-1",placeholder:"Default from material",disabled:a})]})]})]})}var Sj="Radio",[yR,mP]=N1(Sj),[vR,bR]=yR(Sj),fP=k.forwardRef((t,s)=>{const{__scopeRadio:n,name:a,checked:l=!1,required:c,disabled:u,value:i="on",onCheck:_,form:j,...y}=t,[x,v]=k.useState(null),C=k1(s,z=>v(z)),P=k.useRef(!1),I=x?j||!!x.closest("form"):!0;return e.jsxs(vR,{scope:n,checked:l,disabled:u,children:[e.jsx(Wd.button,{type:"button",role:"radio","aria-checked":l,"data-state":_P(l),"data-disabled":u?"":void 0,disabled:u,value:i,...y,ref:C,onClick:Iy(t.onClick,z=>{l||_==null||_(),I&&(P.current=z.isPropagationStopped(),P.current||z.stopPropagation())})}),I&&e.jsx(xP,{control:x,bubbles:!P.current,name:a,value:i,checked:l,required:c,disabled:u,form:j,style:{transform:"translateX(-100%)"}})]})});fP.displayName=Sj;var pP="RadioIndicator",gP=k.forwardRef((t,s)=>{const{__scopeRadio:n,forceMount:a,...l}=t,c=bR(pP,n);return e.jsx(t5,{present:a||c.checked,children:e.jsx(Wd.span,{"data-state":_P(c.checked),"data-disabled":c.disabled?"":void 0,...l,ref:s})})});gP.displayName=pP;var jR="RadioBubbleInput",xP=k.forwardRef(({__scopeRadio:t,control:s,checked:n,bubbles:a=!0,...l},c)=>{const u=k.useRef(null),i=k1(u,c),_=K5(n),j=s5(s);return k.useEffect(()=>{const y=u.current;if(!y)return;const x=window.HTMLInputElement.prototype,C=Object.getOwnPropertyDescriptor(x,"checked").set;if(_!==n&&C){const P=new Event("click",{bubbles:a});C.call(y,n),y.dispatchEvent(P)}},[_,n,a]),e.jsx(Wd.input,{type:"radio","aria-hidden":!0,defaultChecked:n,...l,tabIndex:-1,ref:i,style:{...l.style,...j,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});xP.displayName=jR;function _P(t){return t?"checked":"unchecked"}var wR=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Z0="RadioGroup",[NR,LH]=N1(Z0,[w0,mP]),yP=w0(),vP=mP(),[kR,CR]=NR(Z0),bP=k.forwardRef((t,s)=>{const{__scopeRadioGroup:n,name:a,defaultValue:l,value:c,required:u=!1,disabled:i=!1,orientation:_,dir:j,loop:y=!0,onValueChange:x,...v}=t,C=yP(n),P=KC(j),[I,z]=v0({prop:c,defaultProp:l??null,onChange:x,caller:Z0});
755return e.jsx(kR,{scope:n,name:a,required:u,disabled:i,value:I,onValueChange:z,children:e.jsx(aS,{asChild:!0,...C,orientation:_,dir:P,loop:y,children:e.jsx(Wd.div,{role:"radiogroup","aria-required":u,"aria-orientation":_,"data-disabled":i?"":void 0,dir:P,...v,ref:s})})})});bP.displayName=Z0;var jP="RadioGroupItem",wP=k.forwardRef((t,s)=>{const{__scopeRadioGroup:n,disabled:a,...l}=t,c=CR(jP,n),u=c.disabled||a,i=yP(n),_=vP(n),j=k.useRef(null),y=k1(s,j),x=c.value===l.value,v=k.useRef(!1);return k.useEffect(()=>{const C=I=>{wR.includes(I.key)&&(v.current=!0)},P=()=>v.current=!1;return document.addEventListener("keydown",C),document.addEventListener("keyup",P),()=>{document.removeEventListener("keydown",C),document.removeEventListener("keyup",P)}},[]),e.jsx(rS,{asChild:!0,...i,focusable:!u,active:x,children:e.jsx(fP,{disabled:u,required:c.required,checked:x,..._,...l,name:c.name,ref:y,onCheck:()=>c.onValueChange(l.value),onKeyDown:Iy(C=>{C.key==="Enter"&&C.preventDefault()}),onFocus:Iy(l.onFocus,()=>{var C;v.current&&((C=j.current)==null||C.click())})})})});wP.displayName=jP;var SR="RadioGroupIndicator",NP=k.forwardRef((t,s)=>{const{__scopeRadioGroup:n,...a}=t,l=vP(n);return e.jsx(gP,{...l,...a,ref:s})});NP.displayName=SR;var kP=bP,CP=wP,ER=NP;const i0=k.forwardRef(({className:t,...s},n)=>e.jsx(kP,{className:fs("grid gap-2",t),...s,ref:n}));i0.displayName=kP.displayName;const o0=k.forwardRef(({className:t,...s},n)=>e.jsx(CP,{ref:n,className:fs("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(ER,{className:"flex items-center justify-center",children:e.jsx(E1,{className:"h-2.5 w-2.5 fill-current text-current"})})}));o0.displayName=CP.displayName;const PR=[{value:"front_left",label:"Corner (Front-Left)",description:"Office at front-left corner"},{value:"front_right",label:"Corner (Front-Right)",description:"Office at front-right corner"},{value:"full_front",label:"Full Front Width",description:"Office spanning full front"},{value:"custom",label:"Custom",description:"Draw custom office footprint"}],TR=[{value:"glass",label:"Glass",color:"#38bdf8"},{value:"concrete",label:"Concrete",color:"#6b7280"},{value:"brick",label:"Brick",color:"#b45309"},{value:"stucco",label:"Stucco",color:"#d6d3d1"}];function LR({overlay:t,onUpdate:s,isUpdating:n}){const a=!!t.office_percentage&&t.office_percentage>0,[l,c]=k.useState(t.office_percentage||15),[u,i]=k.useState(t.office_location||"front_right"),[_,j]=k.useState(t.office_floor_count||2),[y,x]=k.useState(t.office_floor_height_ft||12),[v,C]=k.useState(t.office_material_preset||"glass");k.useEffect(()=>{t.office_percentage!==void 0&&c(t.office_percentage||15),t.office_location&&i(t.office_location)},[t.office_percentage,t.office_location]);const P=t.calculated_area_sqft||0,I=k.useMemo(()=>Math.round(P*l/100),[P,l]),z=_*y,F=()=>{s({office_percentage:15,office_location:"front_right",office_floor_count:2,office_floor_height_ft:12,office_material_preset:"glass"})},D=()=>{s({office_percentage:null,office_location:null,office_floor_count:null,office_floor_height_ft:null,office_material_preset:null,office_geometry:null})},X=K=>{c(K),s({office_percentage:K})};return a?e.jsxs("div",{className:"space-y-4 p-3 bg-blue-500/5 rounded-lg border border-blue-500/20",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ci,{className:"w-4 h-4 text-blue-500"}),e.jsx(B,{className:"text-sm font-medium",children:"Office Build-Out"})]}),e.jsx(Le,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:D,children:"Remove"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Office Percentage"}),e.jsxs(Mt,{variant:"secondary",className:"font-mono text-xs",children:[l,"%"]})]}),e.jsx(Ca,{value:[l],min:5,max:50,step:1,onValueChange:([K])=>X(K),disabled:n,className:"[&>span:first-child]:bg-blue-500/30 [&_[role=slider]]:bg-blue-500"}),e.jsxs("div",{className:"flex justify-between text-[10px] text-muted-foreground",children:[e.jsxs("span",{children:["Office Area: ",I.toLocaleStr
755ing()," sf"]}),e.jsxs("span",{children:["Warehouse: ",(P-I).toLocaleString()," sf"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Location"}),e.jsx(i0,{value:u,onValueChange:K=>{i(K),s({office_location:K})},disabled:n,className:"grid grid-cols-2 gap-2",children:PR.map(K=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(o0,{value:K.value,id:`office-loc-${K.value}`}),e.jsx(B,{htmlFor:`office-loc-${K.value}`,className:"text-xs cursor-pointer",children:K.label})]},K.value))})]}),e.jsxs("div",{className:"space-y-3 pt-3 border-t border-border/50",children:[e.jsx(B,{className:"text-xs font-medium",children:"Office Height"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Floors"}),e.jsx(be,{type:"number",value:_,onChange:K=>{const te=parseInt(K.target.value)||1;j(te),s({office_floor_count:te})},min:1,max:5,className:"h-7 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Height/Floor (ft)"}),e.jsx(be,{type:"number",value:y,onChange:K=>{const te=parseFloat(K.target.value)||12;x(te),s({office_floor_height_ft:te})},min:10,max:20,className:"h-7 text-xs"})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Total Office Height: ",e.jsxs("span",{className:"font-medium text-foreground",children:[z," ft"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Material"}),e.jsxs(rt,{value:v,onValueChange:K=>{C(K),s({office_material_preset:K})},disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:TR.map(K=>e.jsx(le,{value:K.value,className:"text-xs",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:K.color}}),K.label]})},K.value))})]})]}),e.jsxs("div",{className:"p-2 bg-background rounded-md space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(hh,{className:"w-3 h-3"}),"Office Summary"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Area:"}),e.jsxs("span",{className:"font-mono",children:[I.toLocaleString()," sf"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Height:"}),e.jsxs("span",{className:"font-mono",children:[z," ft"]})]})]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ci,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(B,{className:"text-sm font-medium",children:"Office Build-Out"})]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"gap-1",onClick:F,disabled:n,children:[e.jsx($3,{className:"w-3 h-3"}),"Add"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Mezzanine or integrated office space within warehouse."})]})}function kk(t,s,n){const a=[],l=[0];for(let c=0;c<t;c++){const u=(n==null?void 0:n[c])??s;a.push(u),l.push(l[c]+u)}return{offsets:l,spacings:a}}function MR(t,s){return Or(us([t.lng,t.lat]),us([s.lng,s.lat]))}function IR(t,s){return gi(us([t.lng,t.lat]),us([s.lng,s.lat]),{units:"feet"})}function AR(t){let s=0,n=0;for(let a=0;a<t.length;a++){const l=(a+1)%t.length,c=IR(t[a],t[l]);c>s&&(s=c,n=a)}return n}function DR(t,s,n){const a=gi(us([s.lng,s.lat]),us([t.lng,t.lat]),{units:"feet"}),c=(Or(us([s.lng,s.lat]),us([t.lng,t.lat]))-n)*Math.PI/180,u=a*Math.sin(c),i=a*Math.cos(c);return[u,i]}function Mm(t,s,n,a){const l=Math.sqrt(t*t+s*s);if(l<.001)return{...n};const c=Math.atan2(t,s)*(180/Math.PI),u=a+c,i=l*.3048/1e3,_=On(us([n.lng,n.lat]),i,u,{units:"kilometers"});return{lng:_.geometry.coordinates[0],lat:_.geometry.coordinates[1]}}function RR(t,s){return`${String.fromCharCode(65+t)}${s+1}`}function FR(t){const s=t.gridOffsetFt??4;return{front:t.offsetFrontFt??s,rear:t.offsetRearFt??s,side1:t.offsetSide1Ft??s,side2:t.offsetSide2Ft??s}}function Ej(t,s){if(!t||t.length<3)return null;const{bayWidthFt:n,bayDepthFt:a,lineOverridesX:l,lineOverridesY:c}=s,u=FR(s),i=s.extraLinesX??0,_=s.extraLinesY??0,j=s.frontEdgeIndex!=null&&s.frontEdgeIndex>=0&&s.frontEdgeIndex<t.length?s.frontEdgeIndex:AR(t),y=(j+1)%t.length,x=MR(t[j],t[y]),v=t.map(Ze=>[Ze.lng,Ze.lat]),C=Xn([[...v,v[0]]]);let P=0,I=0;for(const Ze of t)P+=Ze.lat,I+=Ze.lng;P/=t.length,I/=t.length;const z={lat:P,lng:I},F=t.map(Ze=>DR(Ze,z,x));let D=1/0,X=-1/0,K=1/0,te=-1/0;for(const[Ze,ke]of F)Ze<D&&(D=Ze),Ze>X&&(X=Ze),ke<K&&(K=ke),ke>te&&(te=ke);const J=D+u.side1,H=X-u.side2,O=K+u.front,q=te-u.rear,W=H-J,Q=q-O;let Z=Math.max(1,Math.floor(W/n)),oe=Math.max(1,Math.floor(Q/a));if(Z+=i,oe+=_,Z<1||oe<1)return null;const ce=kk(Z,n,l),ae=kk(oe,a,c),ie=J,de=O,ge=[],We=[],Ee=[];for(let Ze=0;Ze<=oe;Ze++){const ke=de+ae.offsets[Ze];for(let ze=0;ze<=Z;ze++){const Ke=ie+ce.offsets[ze],dt=Mm(Ke,ke,z,x),Re=us([dt.lng,dt.lat]);uu(Re,C)&&ge.push({lat:dt.lat,lng:dt.lng,row:Ze,col:ze})}}for(let Ze=0;Ze<oe;Ze++)for(let ke=0;ke<Z;ke++){const ze=ie+ce.offsets[ke],Ke=ie+ce.offsets[ke+1],dt=de+ae.offsets[Ze],Re=de+ae.offsets[Ze+1],qt=ce.spacings[ke],ft=ae.spacings[Ze],Fe=Mm(ze,dt,z,x),fe=Mm(Ke,dt,z,x),Qe=Mm(Ke,Re,z,x),ht=Mm(ze,Re,z,x);Ee.push({row:Ze,col:ke,label:RR(Ze,ke),widthFt:qt,depthFt:ft,areaSqFt:qt*ft,corners:[[Fe.lng,Fe.lat],[fe.lng,fe.lat],[Qe.lng,Qe.lat],[ht.lng,ht.lat]]})}const ve=ce.offsets[Z],we=ae.offsets[oe];for(let Ze=0;Ze<=oe;Ze++){const ke=de+ae.offsets[Ze],ze=Mm(ie,ke,z,x),Ke=Mm(ie+ve,ke,z,x);We.push({start:[ze.lng,ze.lat],end:[Ke.lng,Ke.lat]})}for(let Ze=0;Ze<=Z;Ze++){const ke=ie+ce.offsets[Ze],ze=Mm(ke,de,z,x),Ke=Mm(ke,de+we,z,x);We.push({start:[ze.lng,ze.lat],end:[Ke.lng,Ke.lat]})}return{columns:ge,gridLines:We,totalColumns:ge.length,baysX:Z,baysY:oe,lineSpacingsX:ce.spacings,lineSpacingsY:ae.spacings,bearingDeg:x,bays:Ee}}function Bf({elementType:t,currentElementId:s,currentConfig:n,onSelectElement:a,onApplyConfig:l,disabled:c=!1}){const[u,i]=k.useState(!1),[_,j]=k.useState(!1),[y,x]=k.useState(""),[v,C]=k.useState(!0),{data:P=[],isLoading:I}=Q5(t),z=U5(),F=s?P.find(te=>te.id===s):null,D=async()=>
755{if(y.trim())try{await z.mutateAsync({name:y.trim(),element_type:t,config:n,is_template:v}),x(""),i(!1)}catch{}},X=te=>{const J=P.find(H=>H.id===te);J&&(l(J.config),a(te),j(!1))},K=()=>{a(null)};return e.jsxs("div",{className:"flex items-center gap-1",children:[F&&e.jsxs(Mt,{variant:"secondary",className:"text-[10px] gap-1 h-5",children:[e.jsx(tS,{className:"w-3 h-3"}),F.name]}),e.jsxs(Ef,{open:_,onOpenChange:j,children:[e.jsx(Pf,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",disabled:c,title:"Load preset",children:e.jsx(Mb,{className:"w-3.5 h-3.5"})})}),e.jsx(Tf,{className:"w-56 p-2",align:"end",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs font-medium",children:"Load Preset"}),I?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Va,{className:"w-4 h-4 animate-spin"})}):P.length===0?e.jsx("p",{className:"text-xs text-muted-foreground py-2",children:"No saved presets yet"}):e.jsxs(rt,{onValueChange:X,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{placeholder:"Select preset..."})}),e.jsx(ot,{children:P.map(te=>e.jsx(le,{value:te.id,className:"text-xs",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:te.name}),te.is_template&&e.jsx(Mt,{variant:"outline",className:"text-[9px] h-4",children:"Template"})]})},te.id))})]})]})})]}),e.jsxs(Ef,{open:u,onOpenChange:i,children:[e.jsx(Pf,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",disabled:c,title:"Save as preset",children:e.jsx(o3,{className:"w-3.5 h-3.5"})})}),e.jsx(Tf,{className:"w-56 p-3",align:"end",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-xs font-medium",children:"Save as Preset"}),e.jsx(be,{placeholder:"Preset name...",value:y,onChange:te=>x(te.target.value),className:"h-8 text-xs",onKeyDown:te=>{te.key==="Enter"&&D()}}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Make template"}),e.jsx("input",{type:"checkbox",checked:v,onChange:te=>C(te.target.checked),className:"h-3.5 w-3.5"})]}),e.jsxs(Le,{size:"sm",className:"w-full h-7 text-xs",onClick:D,disabled:!y.trim()||z.isPending,children:[z.isPending?e.jsx(Va,{className:"w-3.5 h-3.5 animate-spin mr-1"}):e.jsx(cl,{className:"w-3.5 h-3.5 mr-1"}),"Save"]})]})})]}),F&&e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:K,disabled:c,title:"Unlink preset",children:e.jsx(Wy,{className:"w-3.5 h-3.5"})})]})}function ff(t){const s=Math.floor(t),n=Math.round((t-s)*12);return{feet:s,inches:n>=12?11:n}}function Ck(t,s){return t+s/12}function zR({overlay:t,onUpdate:s,isUpdating:n}){const a=t.show_column_grid??!1,[l,c]=k.useState(t.column_bay_width_ft||50),[u,i]=k.useState(t.column_bay_depth_ft||50),[_,j]=k.useState(t.column_size_inches||24),[y,x]=k.useState(!1),[v,C]=k.useState(t.column_offset_front_ft??4),[P,I]=k.useState(t.column_offset_rear_ft??4),[z,F]=k.useState(t.column_offset_side1_ft??4),[D,X]=k.useState(t.column_offset_side2_ft??4),K=t.column_extra_lines_x??0,te=t.column_extra_lines_y??0,[J,H]=k.useState(()=>ff(l).feet),[O,q]=k.useState(()=>ff(l).inches),[W,Q]=k.useState(()=>ff(u).feet),[Z,oe]=k.useState(()=>ff(u).inches),ce=t.column_grid_front_edge??null,ae=k.useMemo(()=>{var fe,Qe;return{x:((fe=t.column_line_overrides)==null?void 0:fe.x)??{},y:((Qe=t.column_line_overrides)==null?void 0:Qe.y)??{}}},[t.column_line_overrides]);k.useEffect(()=>{if(t.column_bay_width_ft!==void 0){const fe=t.column_bay_width_ft||50;c(fe);const{feet:Qe,inches:ht}=ff(fe);H(Qe),q(ht)}if(t.column_bay_depth_ft!==void 0){const fe=t.column_bay_depth_ft||50;i(fe);const{feet:Qe,inches:ht}=ff(fe);Q(Qe),oe(ht)}},[t.column_bay_width_ft,t.column_bay_depth_ft]),k.useEffect(()=>{C(t.column_offset_front_ft??4),I(t.column_offset_rear_ft??4),F(t.column_offset_side1_ft??4),X(t.column_offset_side2_ft??4)},[t.column_offset_front_ft,t.column_offset_rear_ft,t.column_offset_side1_ft,t.column_offset_side2_ft]);const ie=k.useMemo(()=>{if(!t.geometry||t.geometry.length<3)return[];const fe=t.geometry;return fe.map((Qe,ht)=>{const _t=fe[(ht+1)%fe.length],He=(_t.lat-Qe.lat)*111320,as=(_t.lng-Qe.lng)*111320*Math.cos(Qe.lat*Math.PI/180),vt=Math.sqrt(He*He+as*as)*3.28084;return{index:ht,lengthFt:vt}})},[t.geometry]),de=k.useMemo(()=>
755{if(ie.length===0)return 0;let fe=0,Qe=0;return ie.forEach(ht=>{ht.lengthFt>fe&&(fe=ht.lengthFt,Qe=ht.index)}),Qe},[ie]),ge=k.useMemo(()=>{if(!t.geometry||t.geometry.length<3)return{totalColumns:0,baysX:0,baysY:0,lineSpacingsX:[],lineSpacingsY:[],bays:[]};const fe={},Qe={};for(const[_t,He]of Object.entries(ae.x))fe[Number(_t)]=He;for(const[_t,He]of Object.entries(ae.y))Qe[Number(_t)]=He;return Ej(t.geometry,{bayWidthFt:l,bayDepthFt:u,columnSizeInches:_,offsetFrontFt:v,offsetRearFt:P,offsetSide1Ft:z,offsetSide2Ft:D,frontEdgeIndex:ce,extraLinesX:K,extraLinesY:te,lineOverridesX:Object.keys(fe).length>0?fe:void 0,lineOverridesY:Object.keys(Qe).length>0?Qe:void 0})||{totalColumns:0,baysX:0,baysY:0,lineSpacingsX:[],lineSpacingsY:[],bays:[]}},[t.geometry,l,u,_,v,P,z,D,ae,ce,K,te]),We=fe=>{s({show_column_grid:fe})},Ee=(fe,Qe)=>{H(fe),q(Qe);const ht=Ck(fe,Qe);c(ht),s({column_bay_width_ft:ht})},ve=(fe,Qe)=>{Q(fe),oe(Qe);const ht=Ck(fe,Qe);i(ht),s({column_bay_depth_ft:ht})},we=fe=>{const Qe=parseInt(fe)||24;j(Qe),s({column_size_inches:Qe})},Ze=(fe,Qe)=>{const ht=parseFloat(Qe)||0,_t={front:C,rear:I,side1:F,side2:X},He={front:"column_offset_front_ft",rear:"column_offset_rear_ft",side1:"column_offset_side1_ft",side2:"column_offset_side2_ft"};_t[fe](ht),s({[He[fe]]:ht})},ke=fe=>{s({column_grid_front_edge:fe})},ze=(fe,Qe)=>{const ht=fe==="x"?"column_extra_lines_x":"column_extra_lines_y",He=Math.max(0,(fe==="x"?K:te)+Qe);s({[ht]:He})},Ke=(fe,Qe,ht)=>{const _t=parseFloat(ht),He=fe==="x"?l:u,as={...ae},vt={...as[fe]};isNaN(_t)||_t===He?delete vt[Qe.toString()]:vt[Qe.toString()]=_t;const Xe={...as,[fe]:vt};s({column_line_overrides:Xe})},dt=(fe,Qe)=>{const ht={...ae},_t={...ht[fe]};delete _t[Qe.toString()];const He={...ht,[fe]:_t};s({column_line_overrides:He})},Re=()=>{s({column_line_overrides:{x:{},y:{}}})},qt=Object.keys(ae.x).length>0||Object.keys(ae.y).length>0,ft=k.useMemo(()=>({bay_width_ft:l,bay_depth_ft:u,column_size_inches:_,offset_front_ft:v,offset_rear_ft:P,offset_side1_ft:z,offset_side2_ft:D}),[l,u,_,v,P,z,D]),Fe=fe=>{const Qe=fe.bay_width_ft??l,ht=fe.bay_depth_ft??u,_t=fe.column_size_inches??_;c(Qe),i(ht),j(_t);const He=ff(Qe);H(He.feet),q(He.inches);const as=ff(ht);Q(as.feet),oe(as.inches),s({column_bay_width_ft:Qe,column_bay_depth_ft:ht,column_size_inches:_t})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dm,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(B,{className:"text-sm font-medium",children:"Structural Bay Grid"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bf,{elementType:"column_grid",currentElementId:t.column_grid_element_id,currentConfig:ft,onSelectElement:fe=>s({column_grid_element_id:fe}),onApplyConfig:Fe,disabled:n}),e.jsx(kt,{checked:a,onCheckedChange:We,disabled:n})]})]}),!a&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Column spacing for clear span and structural bay layout."}),a&&e.jsxs("div",{className:"space-y-4 p-3 bg-muted/50 rounded-lg border animate-in fade-in-50",children:[ie.length>=3&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Orientation Edge (Front)"}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx("button",{onClick:()=>ke(null),className:`px-2 py-0.5 rounded text-[10px] transition-colors ${ce===null?"bg-primary text-primary-foreground":"bg-muted hover:bg-muted-foreground/10"}`,disabled:n,children:"Auto"}),ie.map(fe=>e.jsxs("button",{onClick:()=>ke(fe.index),className:`px-2 py-0.5 rounded text-[10px] transition-colors ${ce===fe.index?"bg-primary text-primary-foreground":fe.index===de&&ce===null?"bg-primary/20 border border-primary/40":"bg-muted hover:bg-muted-foreground/10"}`,disabled:n,title:`${Math.round(fe.lengthFt)}ft`,children:["Edge ",fe.index+1,e.jsxs("span",{className:"ml-0.5 opacity-60",children:[Math.round(fe.lengthFt),"′"]})]},fe.index))]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["X-axis runs parallel to this edge, Y-axis perpendicular.",ce===null&&` Auto = longest edge (Edge ${de+1}).`]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Bay Width (X)"}),e.jsxs("div",{className:"flex gap-1 items-center",children:[e.jsx(be,{type:"number",value:J,onChange:fe=>Ee(parseInt(fe.target.value)||0,O),min:20,max:100,className:"h-7 text-xs w-14",disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"ft"}),e.jsx(be,{type:"number",value:O,onChange:fe=>Ee(J,Math.min(11,Math.max(0,parseInt(fe.target.value)||0))),min:0,max:11,className:"h-7 text-xs w-12",disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"in"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Bay Depth (Y)"}),e.jsxs("div",{className:"flex gap-1 items-center",children:[e.jsx(be,{type:"number",value:W,onChange:fe=>ve(parseInt(fe.target.value)||0,Z),min:20,max:100,className:"h-7 text-xs w-14",disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"ft"}),e.jsx(be,{type:"number",value:Z,onChange:fe=>ve(W,Math.min(11,Math.max(0,parseInt(fe.target.value)||0))),min:0,max:11,className:"h-7 text-xs w-12",disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"in"})]})]})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground self-center mr-1",children:"Presets:"}),[40,50,60].map(fe=>e.jsxs("button",{onClick:()=>{Ee(fe,0),ve(fe,0)},className:`px-2 py-0.5 rounded text-[10px] transition-colors ${J===fe&&O===0&&W===fe&&Z===0?"bg-primary text-primary-foreground":"bg-muted hover:bg-muted-foreground
755/10"}`,children:[fe,"×",fe]},fe))]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Column Size"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(be,{type:"number",value:_,onChange:fe=>we(fe.target.value),min:12,max:48,className:"h-7 w-20 text-xs"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["× ",_," inches"]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Column Offset from Edge"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{key:"front",label:"From Front",value:v},{key:"rear",label:"From Rear",value:P},{key:"side1",label:"From Side 1",value:z},{key:"side2",label:"From Side 2",value:D}].map(({key:fe,label:Qe,value:ht})=>e.jsxs("div",{className:"flex gap-1 items-center",children:[e.jsx(be,{type:"number",value:ht,onChange:_t=>Ze(fe,_t.target.value),min:0,max:30,className:"h-7 w-14 text-xs",disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground truncate",children:Qe})]},fe))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Extra X Lines"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Le,{variant:"outline",size:"sm",className:"h-6 w-6 p-0",onClick:()=>ze("x",-1),disabled:n||K<=0,children:e.jsx(Om,{className:"w-3 h-3"})}),e.jsx(Mt,{variant:"secondary",className:"font-mono text-[10px] h-5 min-w-[24px] justify-center",children:K}),e.jsx(Le,{variant:"outline",size:"sm",className:"h-6 w-6 p-0",onClick:()=>ze("x",1),disabled:n,children:e.jsx(tr,{className:"w-3 h-3"})})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Extra Y Lines"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Le,{variant:"outline",size:"sm",className:"h-6 w-6 p-0",onClick:()=>ze("y",-1),disabled:n||te<=0,children:e.jsx(Om,{className:"w-3 h-3"})}),e.jsx(Mt,{variant:"secondary",className:"font-mono text-[10px] h-5 min-w-[24px] justify-center",children:te}),e.jsx(Le,{variant:"outline",size:"sm",className:"h-6 w-6 p-0",onClick:()=>ze("y",1),disabled:n,children:e.jsx(tr,{className:"w-3 h-3"})})]})]})]}),e.jsxs("div",{className:"p-2 bg-background rounded-md space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(hh,{className:"w-3 h-3"}),"Grid Statistics"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Columns:"}),e.jsx(Mt,{variant:"secondary",className:"font-mono text-[10px] h-5",children:ge.totalColumns})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Clear Spans:"}),e.jsxs(Mt,{variant:"secondary",className:"font-mono text-[10px] h-5",children:[ge.baysX,"×",ge.baysY]})]})]})]}),ge.baysX>0&&ge.baysY>0&&e.jsxs(wi,{open:y,onOpenChange:x,children:[e.jsxs(Ni,{className:"flex items-center justify-between w-full p-2 bg-background rounded-md hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[e.jsx("span",{children:"Column Line Spacing"}),qt&&e.jsxs(Mt,{variant:"default",className:"text-[9px] h-4 px-1.5",children:[Object.keys(ae.x).length+Object.keys(ae.y).length," modified"]})]}),e.jsx(Oa,{className:`w-3.5 h-3.5 text-muted-foreground transition-transform ${y?"rotate-180":""}`})]}),e.jsxs(ki,{className:"mt-2 space-y-3",children:[qt&&e.jsxs(Le,{variant:"ghost",size:"sm",onClick:Re,className:"h-6 text-[10px] text-muted-foreground px-2",disabled:n,children:[e.jsx(mh,{className:"w-3 h-3 mr-1"}),"Reset All to Default"]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"X Lines (Width) — bay spacing to next line"}),e.jsx("div",{className:"space-y-1",children:Array.from({length:ge.baysX},(fe,Qe)=>{const ht=ae.x[Qe.toString()],_t=ht!==void 0,He=_t?ht:l;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:`text-[10px] font-mono w-6 ${_t?"text-primary font-bold":"text-muted-foreground"}`,children:["X",Qe+1]}),_t&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary flex-shrink-0"}
755),e.jsx(be,{type:"number",value:He,onChange:as=>Ke("x",Qe,as.target.value),min:20,max:100,className:`h-6 text-[10px] w-16 ${_t?"border-primary/50":""}`,disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"ft"}),_t&&e.jsx("button",{onClick:()=>dt("x",Qe),className:"text-muted-foreground hover:text-foreground",title:"Reset to default",children:e.jsx(mh,{className:"w-3 h-3"})})]},`x-${Qe}`)})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Y Lines (Depth) — bay spacing to next line"}),e.jsx("div",{className:"space-y-1",children:Array.from({length:ge.baysY},(fe,Qe)=>{const ht=ae.y[Qe.toString()],_t=ht!==void 0,He=_t?ht:u;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:`text-[10px] font-mono w-6 ${_t?"text-primary font-bold":"text-muted-foreground"}`,children:["Y",Qe+1]}),_t&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary flex-shrink-0"}),e.jsx(be,{type:"number",value:He,onChange:as=>Ke("y",Qe,as.target.value),min:20,max:100,className:`h-6 text-[10px] w-16 ${_t?"border-primary/50":""}`,disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"ft"}),_t&&e.jsx("button",{onClick:()=>dt("y",Qe),className:"text-muted-foreground hover:text-foreground",title:"Reset to default",children:e.jsx(mh,{className:"w-3 h-3"})})]},`y-${Qe}`)})})]})]})]})]})]})}function OR(t,s,n,a){const l=s+n,c=Math.floor((t-n)/l);return Math.min(c,a)}function Pj(t,s){if(!t||t.length<3||s.doorCount<=0)return null;const{doorCount:n,doorWidthFt:a,spacingFt:l,edgeIndices:c}=s,u=t.map(v=>[v.lng,v.lat]);let i;if(c&&c.length>0)i=c;else{let v={index:0,length:0};for(let C=0;C<u.length;C++){const P=(C+1)%u.length,I=gi(us(u[C]),us(u[P]),{units:"feet"});I>v.length&&(v={index:C,length:I})}i=[v.index]}const _=[];let j=0;const y=Math.ceil(n/i.length);for(const v of i){const C=(v+1)%u.length,P=gi(us(u[v]),us(u[C]),{units:"feet"}),I=n-j,z=Math.min(y,I),F=OR(P,a,l,z);_.push({index:v,length:Math.round(P),doorCount:F}),j+=F}const x=[];for(const v of _){if(v.doorCount<=0)continue;const C=v.index,P=(v.index+1)%u.length,I=u[C],z=u[P],F=Or(us(I),us(z)),D=a+l,X=v.doorCount*D-l,K=(v.length-X)/2+a/2;for(let te=0;te<v.doorCount;te++){const H=(K+te*D)*.3048,O=On(us(I),H/1e3,F,{units:"kilometers"});x.push({position:O.geometry.coordinates,bearing:F,edgeIndex:v.index,doorIndex:te})}}return{doors:x,totalDoors:x.length,edgeLengths:_}}function SP(t,s,n,a="#94a3b8"){const l=s*.3048,c=n*.3048,u=.3;return{type:"FeatureCollection",features:t.map((_,j)=>{const y=us(_.position),x=l/2/1e3,v=u/2/1e3,C=_.bearing+90,P=On(On(y,x,_.bearing+180),v,C),I=On(On(y,x,_.bearing),v,C),z=On(On(y,x,_.bearing),v,C+180),F=On(On(y,x,_.bearing+180),v,C+180);return{...Xn([[P.geometry.coordinates,I.geometry.coordinates,z.geometry.coordinates,F.geometry.coordinates,P.geometry.coordinates]]),id:`drive-in-door-${j}`,properties:{height:c,base:0,color:a,doorIndex:_.doorIndex,edgeIndex:_.edgeIndex}}})}}function EP(t,s,n,a=.75){const l=(s+a*2)*.3048,c=.5;return{type:"FeatureCollection",features:t.map((i,_)=>{const j=us(i.position),y=l/2/1e3,x=c/2/1e3,v=i.bearing+90,C=On(On(j,y,i.bearing+180),x,v),P=On(On(j,y,i.bearing),x,v),I=On(On(j,y,i.bearing),x,v+180),z=On(On(j,y,i.bearing+180),x,v+180);return{...Xn([[C.geometry.coordinates,P.geometry.coordinates,I.geometry.coordinates,z.geometry.coordinates,C.geometry.coordinates]]),id:`drive-in-frame-${_}`,properties:{height:(n+a)*.3048,base:0,doorIndex:i.doorIndex,edgeIndex:i.edgeIndex}}})}}function BR({overlay:t,onUpdate:s,isUpdating:n,onStartEdgeSelection:a,edgeSelectionMode:l=!1,pendingEdgeIndex:c}){const[u,i]=k.useState(t.drive_in_door_count||0),[_,j]=k.useState(t.drive_in_door_width_ft||14),[y,x]=k.useState(t.drive_in_door_height_ft||16),[v,C]=k.useState(t.drive_in_door_spacing_ft||20),[P,I]=k.useState(t.drive_in_door_color||"#94a3b8");k.useEffect(()=>{t.drive_in_door_count!==void 0&&i(t.drive_in_door_count||0)},[t.drive_in_door_count]);const z=k.useMemo(()=>!t.geometry||t.geometry.length<3||u<=0?null:Pj(t.geometry,{doorCount:u,doorWidthFt:_,doorHeightFt:y,spacingFt:v,edgeIndices:t.drive_in_door_edge_indices||void 0,doorColor:P}),[t.geometry,u,_,y,v,t.drive_in_door_edge_indices,P]),F=u>0,D=z&&z.totalDoors<u,X=t.drive_in_door_edge_indices||[],K=Z=>{const oe=Math.max(0,parseInt(Z)||0);i(oe),s({drive_in_door_count:oe})},te=Z=>{const oe=parseFloat(Z)||14;j(oe),s({drive_in_door_width_ft:oe})},J=Z=>{const oe=parseFloat(Z)||16;x(oe),s({drive_in_door_height_ft:oe})},H=Z=>{const oe=parseFloat(Z)||20;C(oe),s({drive_in_door_spacing_ft:oe})},O=Z=>{I(Z),s({drive_in_door_color:Z})},q=()=>{s({drive_in_door_edge_indices:null})},W=k.useMemo(()=>({count:u,width_ft:_,height_ft:y,spacing_ft:v,color:P,edge_indices:X}),[u,_,y,v,P,X]),Q=Z=>{const oe=Z.count??u,ce=Z.width_ft??_,ae=Z.height_ft??y,ie=Z.spacing_ft??v,de=Z.color??P;i(oe),j(ce),x(ae),C(ie),I(de),s({drive_in_door_count:oe,drive_in_door_width_ft:ce,drive_in_door_height_ft:ae,drive_in_door_spacing_ft:ie,drive_in_door_color:de})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lf,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(B,{className:"text-sm font-medium",children:"Roll-Up Doors"})]}),e.jsx(Bf,{elementType:"drive_in_doors",currentElementId:t.drive_in_doors_element_id,currentConfig:W,onSelectElement:Z=>s({drive_in_doors_element_id:Z}),onApplyConfig:Q,disabled:n})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Grade-level overhead doors for drive-in access."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Door Count"}),e.jsx(be,{type:"number",value:u,onChange:Z=>K(Z.target.value),min:0,max:20,className:"h-8 text-sm",disabled:n})]}),F&&e.jsxs("div",{className:"space-y-4 p-3 bg-muted/50 rounded-lg border animate-in fade-in-50",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Width (ft)"}
755),e.jsx(be,{type:"number",value:_,onChange:Z=>te(Z.target.value),min:10,max:24,className:"h-7 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Height (ft)"}),e.jsx(be,{type:"number",value:y,onChange:Z=>J(Z.target.value),min:12,max:20,className:"h-7 text-xs"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Spacing (ft)"}),e.jsx(be,{type:"number",value:v,onChange:Z=>H(Z.target.value),min:10,max:40,className:"h-7 text-xs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Placement"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Le,{variant:l?"default":"outline",size:"sm",className:"flex-1 gap-1.5",onClick:a,disabled:n,children:[e.jsx(Q1,{className:"w-3.5 h-3.5"}),l?"Click building edge...":"Select Edge"]}),X.length>0&&e.jsx(Le,{variant:"ghost",size:"sm",onClick:q,disabled:n,children:"Clear"})]}),X.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:X.map(Z=>e.jsxs(Mt,{variant:"secondary",className:"text-[10px]",children:["Edge ",Z]},Z))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Door Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(be,{type:"color",value:P,onChange:Z=>O(Z.target.value),className:"h-7 w-10 p-1 cursor-pointer"}),e.jsx(be,{type:"text",value:P,onChange:Z=>O(Z.target.value),className:"h-7 text-xs font-mono flex-1"})]})]}),z&&e.jsxs("div",{className:`p-2 rounded-md text-xs ${D?"bg-amber-500/10 border border-amber-500/30":"bg-green-500/10 border border-green-500/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[D?e.jsx(ho,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}):e.jsx(bp,{className:"w-3.5 h-3.5 text-green-500 shrink-0"}),e.jsx("div",{className:D?"text-amber-600 dark:text-amber-400":"text-green-600 dark:text-green-400",children:D?`${z.totalDoors} doors (reduced from ${u})`:`${z.totalDoors} doors placed`})]}),D&&e.jsx("p",{className:"text-muted-foreground mt-1.5 text-[10px]",children:"💡 Reduce door width or spacing to fit more doors"})]})]})]})}const zv=[{value:"none",label:"None",description:"No windows"},{value:"bands",label:"Horizontal Bands",description:"Ribbon windows"},{value:"grid",label:"Grid Pattern",description:"Individual openings"},{value:"curtainwall",label:"Curtain Wall",description:"Full glass facade"},{value:"warehouse",label:"Warehouse (Clerestory)",description:"High band near roofline"}];function $R({overlay:t,onUpdate:s,isUpdating:n,onStartEdgeSelection:a,onCancelEdgeSelection:l,edgeSelectionMode:c=!1}){const u=k.useRef(),[i,_]=k.useState(null),[j,y]=k.useState(null);k.useEffect(()=>{_(null),y(null)},[t.id]);const x=t.window_pattern&&t.window_pattern!=="none",v=t.window_edge_indices||[],C=t.window_pattern||"none",P=t.window_color||"#38bdf8",I=t.fenestration_edge_config||{},z=J=>{const H=I[String(J)]||{};return{pattern:H.pattern??C,color:H.color??P,enabled:H.enabled??!0}},F=(J,H)=>{const O={...I};O[String(J)]={...z(J),...H},s({fenestration_edge_config:O})},D=J=>{_(J),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{s({window_color:J})},300)},X=()=>{s({window_edge_indices:null,fenestration_edge_config:{}})},K=k.useMemo(()=>({pattern:C,color:P,edge_indices:v,edge_config:I}),[C,P,v,I]),te=J=>{s({window_pattern:J.pattern??C,window_color:J.color??P,fenestration_edge_config:J.edge_config??I})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-muted-foreground flex-1",children:"Window patterns for building facades."}),e.jsx(Bf,{elementType:"fenestration",currentElementId:t.fenestration_element_id,currentConfig:K,onSelectElement:J=>s({fenestration_element_id:J}),onApplyConfig:te,disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Default Pattern"}),e.jsxs(rt,{value:C,onValueChange:J=>s({window_pattern:J}),disabled:n,children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:zv.map(J=>e.jsx(le,{value:J.value,className:"text-xs",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:J.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:J.description})]})},J.value))})]})]}),x&&e.jsxs("div",{className:"space-y-4 p-3 bg-muted/50 rounded-lg border animate-in fade-in-50",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Window Face Selection"}),v.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-green-500/10 border border-green-500/30 rounded-md",children:[e.jsx(bp,{className:"w-3.5 h-3.5 text-green-500 shrink-0"}),e.jsx("div",{className:"flex-1",children:e.jsx("span",{className:"text-xs text-green-600 dark:text-green-400",children:v.length===1?`Edge ${v[0]} selected`:`Edges ${v.join(", ")} selected`})}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground hover:text-destructive",onClick:X,disabled:n,children:"Clear"})]}),a&&e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full h-7 text-xs",onClick:a,disabled:c||n,children:[e.jsx(tr,{className:"w-3 h-3 mr-1"}),"Add Another Face"]})]}):c?e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-primary/10 border border-primary/30 rounded-md animate-pulse",children:[e.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-ping"}),e.jsx("span",{className:"text-xs text-primary flex-1",children:"Click a building edge in the map..."}),l&&e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:l,children:"Cancel"})]}):a?e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full h-7 text-xs",onClick:a,disabled:n,children:[e.jsx(Il,{className:"w-3 h-3 mr-1"}),"Select Window Faces"]}),e.jsx("p",{className:"text-[10px] text-muted-foreground text-center",children:"Or leave unselected to apply to all sides"})]}):e.jsx(Mt,{variant:"secondary",className:"text-[10px]",children:"Applied to all sides"})]}),v.length>0&&!c&&e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dh,{className:"w-3 h-3 text-muted-foreground"}),e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Per-Edge Configuration"})]}),e.jsx("div",{className:"space-y-1",children:v.map(J=>{var q;const H=z(J),O=j===J;return e.jsxs(wi,{open:O,onOpenChange:W=>y(W?J:null),children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full h-7 justify-between text-[10px] px-2",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsxs(Mt,{variant:H.enabled?"outline":"secondary",className:"text-[9px] h-4",children:["Edge ",J]}),e.jsx("span",{className:"text-muted-foreground",children:H.enabled?((q=zv.find(W=>W.value===H.pattern))==null?void 0:q.label)||H.pattern:"Disabled"})]}),e.jsx(Oa,{className:`w-3 h-3 transition-transform ${O?"rotate-180":""}`})]})}),e.jsxs(ki,{className:"pt-2 pb-3 px-2 space-y-3 bg-muted/30 rounded-md mt-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-[10px]",children:"Show Windows"}),e.jsx("input",{type:"checkbox",checked:H.enabled,onChange:W=>F(J,{enabled:W.target.checked}),className:"h-4 w-4",disabled:n})]}),H.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Pattern"}),e.jsxs(rt,{value:H.pattern,onValueChange:W=>F(J,{pattern:W}),disabled:n,children:[e.jsx(it,{className:"h-6 text-[10px]",children:e.jsx(ct,{})}),e.jsx(ot,{children:zv.filter(W=>W.value!=="none").map(W=>e.jsx(le,{value:W.value,className:"text-[10px]",children:W.label},W.value))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Color"}),e.jsx("input",{type:"color",value:H.color,onChange:W=>F(J,{color:W.target.value}),className:"w-6 h-5 rounded border cursor-pointer",disabled:n}),e.jsx("span",{className:"text-[9px] text-muted-foreground font-mono",children:H.color})]})]})]})]},J)})}),e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Expand each edge to customize pattern & color"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Default Window Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(be,{type:"color",value:i??P,onCh
755ange:J=>D(J.target.value),className:"h-8 w-12 p-1 cursor-pointer",disabled:n}),e.jsx(be,{type:"text",value:i??P,onChange:J=>D(J.target.value),className:"h-8 text-xs flex-1 font-mono",placeholder:"#38bdf8",disabled:n})]}),v.length>0&&e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Override per-edge in configuration above"})]}),C==="curtainwall"&&e.jsx("div",{className:"p-2 bg-sky-500/10 border border-sky-500/30 rounded-md",children:e.jsx("p",{className:"text-[10px] text-sky-600 dark:text-sky-400",children:"💡 Curtain wall makes the building slightly translucent and adds glass panels on selected faces."})}),C==="warehouse"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded-md",children:e.jsx("p",{className:"text-[10px] text-amber-600 dark:text-amber-400",children:"🏭 Clerestory windows positioned near the roofline, typical for warehouse/industrial buildings."})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Window Height (ft)"}),e.jsx(be,{type:"number",min:1,max:12,step:.5,value:t.warehouse_window_height_ft??4,onChange:J=>s({warehouse_window_height_ft:parseFloat(J.target.value)||4}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Offset from Top (ft)"}),e.jsx(be,{type:"number",min:0,max:20,step:.5,value:t.warehouse_window_offset_ft??3,onChange:J=>s({warehouse_window_offset_ft:parseFloat(J.target.value)||3}),className:"h-8 text-xs",disabled:n})]})]})]})]})]})}const Z_=12;function VR({overlay:t,onUpdate:s,isUpdating:n,onStartEdgeSelection:a,onCancelEdgeSelection:l,edgeSelectionMode:c=!1}){const u=k.useRef(),i=k.useRef(),_=k.useRef(),j=k.useRef(),[y,x]=k.useState(null),[v,C]=k.useState(null),[P,I]=k.useState(null),[z,F]=k.useState(null),[D,X]=k.useState(null);k.useEffect(()=>{x(null),C(null),I(null),F(null),X(null)},[t.id]);const K=t.show_canopy??!1,te=t.canopy_edge_indices||[],J=te.length===0,H=t.canopy_type,O=y??t.canopy_depth_ft??8,q=v??t.canopy_height_ft??12,W=t.canopy_show_pillars??O>Z_,Q=P??t.canopy_pillar_spacing_ft??20,Z=z??t.canopy_pillar_size_inches??8,oe=t.canopy_color||"#78716c",ce=t.canopy_edge_config||{},ae=Re=>{const qt=ce[String(Re)]||{};return{depthFt:qt.depthFt??O,heightFt:qt.heightFt??q,color:qt.color??oe,showPillars:qt.showPillars??W,pillarSpacingFt:qt.pillarSpacingFt??Q,pillarSizeInches:qt.pillarSizeInches??Z}},ie=(Re,qt)=>{const ft={...ce};ft[String(Re)]={...ae(Re),...qt},s({canopy_edge_config:ft})},de=Re=>{const qt=Math.max(4,Math.min(100,parseFloat(Re)||8));x(qt),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{const ft={canopy_depth_ft:qt};qt>Z_&&!t.canopy_show_pillars&&(ft.canopy_show_pillars=!0),s(ft)},300)},ge=Re=>{const qt=Math.max(8,Math.min(30,parseFloat(Re)||12));C(qt),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{s({canopy_height_ft:qt})},300)},We=Re=>{const qt=Math.max(10,Math.min(40,parseFloat(Re)||20));I(qt),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{s({canopy_pillar_spacing_ft:qt})},300)},Ee=Re=>{const qt=Math.max(4,Math.min(24,parseFloat(Re)||8));F(qt),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{s({canopy_pillar_size_inches:qt})},300)},ve=Re=>{s({show_canopy:Re})},we=Re=>{const qt=Re,ft=Xw[qt];ft&&s({canopy_type:qt,canopy_depth_ft:ft.defaultDepth,canopy_height_ft:ft.defaultHeight,canopy_show_pillars:ft.defaultDepth>Z_})},Ze=Re=>{s({canopy_show_pillars:Re})},ke=()=>{s({canopy_edge_indices:null,canopy_edge_config:{}})},ze=()=>{s({canopy_edge_indices:null})},Ke=k.useMemo(()=>({type:H,depth_ft:O,height_ft:q,color:oe,show_pillars:W,pillar_spacing_ft:Q,pillar_size_inches:Z,edge_indices:te,edge_config:ce}),[H,O,q,oe,W,Q,Z,te,ce]),dt=Re=>{s({canopy_type:Re.type??H,canopy_depth_ft:Re.depth_ft??O,canopy_height_ft:Re.height_ft??q,canopy_color:Re.color??oe,canopy_show_pillars:Re.show_pillars??W,canopy_pillar_spacing_ft:Re.pillar_spacing_ft??Q,canopy_pillar_size_inches:Re.pillar_size_inches??Z,canopy_edge_config:Re.edge_config??ce})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs flex-1",children:"Enable Canopy"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bf,{elementType:"canopy",currentElementId:t.canopy_element_id,currentConfig:Ke,onSelectElement:Re=>s({canopy_element_id:Re}),onApplyConfig:dt,disabled:n}),e.jsx(kt,{checked:K,onCheckedChange:ve,disabled:n})]})]}),K&&e.jsxs("div",{className:"space-y-4 p-3 bg-muted/50 rounded-lg border animate-in fade-in-50",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Canopy Type"}),e.jsxs(rt,{value:H||"",onValueChange:we,disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{placeholder:"Select type (optional)"})}),e.jsx(ot,{children:Object.entries(Xw).map(([Re,qt])=>e.jsx(le,{value:Re,className:"text-xs",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:qt.name}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:qt.description})]})},Re))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Canopy Placement"}),J&&!c&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-blue-500/10 border border-blue-500/30 rounded-md",children:[e.jsx(bp,{className:"w-3.5 h-3.5 text-blue-500 shrink-0"}
755),e.jsx("span",{className:"text-xs text-blue-600 dark:text-blue-400 flex-1",children:"Around entire building"})]}),a&&e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full h-7 text-xs",onClick:a,disabled:n,children:[e.jsx(Il,{className:"w-3 h-3 mr-1"}),"Select Specific Edges"]})]}),te.length>0&&!c&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-green-500/10 border border-green-500/30 rounded-md",children:[e.jsx("div",{className:"flex-1",children:e.jsx("span",{className:"text-xs text-green-600 dark:text-green-400",children:te.length===1?`Edge ${te[0]} selected`:`Edges ${te.join(", ")} selected`})}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground hover:text-destructive",onClick:ke,disabled:n,children:"Clear"})]}),e.jsxs("div",{className:"flex gap-2",children:[a&&e.jsxs(Le,{variant:"outline",size:"sm",className:"flex-1 h-7 text-xs",onClick:a,disabled:n,children:[e.jsx(tr,{className:"w-3 h-3 mr-1"}),"Add Edge"]}),e.jsx(Le,{variant:"outline",size:"sm",className:"flex-1 h-7 text-xs",onClick:ze,disabled:n,children:"All Edges"})]})]}),c&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-primary/10 border border-primary/30 rounded-md animate-pulse",children:[e.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-ping"}),e.jsx("span",{className:"text-xs text-primary flex-1",children:"Click a building edge in the map..."}),l&&e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:l,children:"Cancel"})]})]}),te.length>0&&!c&&e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dh,{className:"w-3 h-3 text-muted-foreground"}),e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Per-Edge Configuration"})]}),e.jsx("div",{className:"space-y-1",children:te.map(Re=>{const qt=ae(Re),ft=D===Re;return e.jsxs(wi,{open:ft,onOpenChange:Fe=>X(Fe?Re:null),children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full h-7 justify-between text-[10px] px-2",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsxs(Mt,{variant:"outline",className:"text-[9px] h-4",children:["Edge ",Re]}),e.jsxs("span",{className:"text-muted-foreground",children:[qt.depthFt,"ft deep"]})]}),e.jsx(Oa,{className:`w-3 h-3 transition-transform ${ft?"rotate-180":""}`})]})}),e.jsxs(ki,{className:"pt-2 pb-3 px-2 space-y-3 bg-muted/30 rounded-md mt-1",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Depth (ft)"}),e.jsx(be,{type:"number",value:qt.depthFt,onChange:Fe=>ie(Re,{depthFt:Number(Fe.target.value)}),className:"h-6 text-[10px]",min:4,max:100,disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Height (ft)"}),e.jsx(be,{type:"number",value:qt.heightFt,onChange:Fe=>ie(Re,{heightFt:Number(Fe.target.value)}),className:"h-6 text-[10px]",min:8,max:30,disabled:n})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Color"}),e.jsx("input",{type:"color",value:qt.color,onChange:Fe=>ie(Re,{color:Fe.target.value}),className:"w-6 h-5 rounded border cursor-pointer",disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-[10px]",children:"Show Pillars"}),e.jsx(kt,{checked:qt.showPillars??!1,onCheckedChange:Fe=>ie(Re,{showPillars:Fe}),disabled:n})]}),qt.showPillars&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Spacing (ft)"}),e.jsx(be,{type:"number",value:qt.pillarSpacingFt,onChange:Fe=>ie(Re,{pillarSpacingFt:Number(Fe.target.value)}),className:"h-6 text-[10px]",min:10,max:40,disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Size (in)"}),e.jsx(be,{type:"number",value:qt.pillarSizeInches,onChange:Fe=>ie(Re,{pillarSizeInches:Number(Fe.target.value)}),className:"h-6 text-[10px]",min:4,max:24,disabled:n})]})]})]})]},Re)})}),e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Expand each edge to customize depth, height & pillars"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"text-xs",children:"Default Depth (ft)"}),e.jsx(hm,{children:e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(hh,{className:"w-3 h-3 text-muted-foreground cursor-help"})}),e.jsx(or,{side:"top",className:"max-w-[200px]",children:e.jsxs("p",{className:"text-xs",children:["Projection distance from building. Depths over ",Z_,"ft will add support pillars."]})})]})})]}),e.jsx(be,{type:"number",min:4,max:100,value:O,onChange:Re=>de(Re.target.value),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Default Height (ft)"}),e.jsx(be,{type:"number",min:8,max:30,value:q,onChange:Re=>ge(Re.target.value),className:"h-8 text-xs",disabled:n})]})]}),te.length>0&&e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Override per
755-edge in configuration above"}),e.jsxs("div",{className:"space-y-3 pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Z1,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Default Support Pillars"})]}),e.jsx(kt,{checked:W,onCheckedChange:Ze,disabled:n})]}),W&&e.jsxs("div",{className:"grid grid-cols-2 gap-3 animate-in fade-in-50",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Spacing (ft)"}),e.jsx(be,{type:"number",min:10,max:40,value:Q,onChange:Re=>We(Re.target.value),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Size (in)"}),e.jsx(be,{type:"number",min:4,max:24,value:Z,onChange:Re=>Ee(Re.target.value),className:"h-8 text-xs",disabled:n})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Default Canopy Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(be,{type:"color",value:oe,onChange:Re=>s({canopy_color:Re.target.value}),className:"h-8 w-12 p-1 cursor-pointer",disabled:n}),e.jsx(be,{type:"text",value:oe,onChange:Re=>s({canopy_color:Re.target.value}),className:"h-8 text-xs flex-1 font-mono",placeholder:"#78716c",disabled:n})]})]})]})]})}const W_=[{value:"none",label:"No Doors",defaultWidth:0,defaultHeight:0},{value:"single",label:"Single Door",defaultWidth:3,defaultHeight:7},{value:"double",label:"Double Door",defaultWidth:6,defaultHeight:7},{value:"sliding",label:"Automatic Sliding",defaultWidth:8,defaultHeight:8}],Sk=[{value:"center",label:"Centered"},{value:"left",label:"Left Side"},{value:"right",label:"Right Side"},{value:"evenly_spaced",label:"Evenly Spaced"}];function qR({overlay:t,onUpdate:s,isUpdating:n,onStartEdgeSelection:a,onCancelEdgeSelection:l,edgeSelectionMode:c=!1}){var ht,_t;const u=k.useRef(),[i,_]=k.useState(null),[j,y]=k.useState(null),[x,v]=k.useState(null),[C,P]=k.useState(null);k.useEffect(()=>{_(null),y(null),v(null),P(null)},[t.id]);const I=t.show_storefront??!1,z=t.storefront_height_ft||10,F=t.storefront_style||"continuous",D=t.storefront_edge_indices,X=t.storefront_mullion_spacing_ft||8,K=t.storefront_transom_height_ft||0,te=t.storefront_mullion_color||"#374151",J=t.storefront_door_count||0,H=t.storefront_door_type||"none",O=t.storefront_door_placement||"center",q=t.storefront_door_color||"#1f2937",W=t.storefront_door_width_ft||((ht=W_.find(He=>He.value===H))==null?void 0:ht.defaultWidth)||6,Q=t.storefront_door_height_ft||((_t=W_.find(He=>He.value===H))==null?void 0:_t.defaultHeight)||7,Z=t.storefront_glass_color||"#38bdf8",oe=t.storefront_doors_only_edge_indices,ce=t.storefront_show_door_transom??!0,ae=t.storefront_edge_config||{},ie=t.storefront_coverage_start_pct??0,de=t.storefront_coverage_end_pct??100,ge=t.storefront_height_profile??"uniform",We=t.storefront_peak_height_ft??14,Ee=t.storefront_base_height_ft??8,ve=t.storefront_peak_width_pct??40,we=D&&D.length>0,Ze=F==="paneled",ke=H!=="none"&&J>0,ze=He=>{const as=ae[String(He)]||{},vt=(oe==null?void 0:oe.includes(He))??!1;return{doorType:as.doorType??H,doorCount:as.doorCount??J,doorPlacement:as.doorPlacement??O,doorWidthFt:as.doorWidthFt??W,doorHeightFt:as.doorHeightFt??Q,doorColor:as.doorColor??q,showTransom:as.showTransom??ce,isDoorsOnly:as.isDoorsOnly??vt}},Ke=(He,as)=>{const vt={...ae};vt[String(He)]={...ze(He),...as},s({storefront_edge_config:vt})},dt=He=>{_(He),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{s({storefront_height_ft:He})},300)},Re=He=>{y(He),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{s({storefront_mullion_spacing_ft:He})},300)},qt=He=>{s({show_storefront:He})},ft=He=>{const as=Kw[He];s({storefront_style:He,storefront_mullion_spacing_ft:as.mullionSpacing||X})},Fe=()=>{s({storefront_edge_indices:null})},fe=k.useMemo(()=>({height_ft:z,style:F,mullion_spacing_ft:X,mullion_color:te,glass_color:Z,transom_height_ft:K,door_type:H,door_count:J,door_placement:O,door_width_ft:W,door_height_ft:Q,door_color:q,show_door_transom:ce,edge_indices:D,doors_only_edge_indices:oe,edge_config:ae}),[z,F,X,te,Z,K,H,J,O,W,Q,q,ce,D,oe,ae]),Qe=He=>{s({storefront_height_ft:He.height_ft??z,storefront_style:He.style??F,storefront_mullion_spacing_ft:He.mullion_spacing_ft??X,storefront_mullion_color:He.mullion_color??te,storefront_glass_color:He.glass_color??Z,storefront_transom_height_ft:He.transom_height_ft??K,storefront_door_type:He.door_type??H,storefront_door_count:He.door_count??J,storefront_door_placement:He.door_placement??O,storefront_door_width_ft:He.door_width_ft??W,storefront_door_height_ft:He.door_height_ft??Q,storefront_door_color:He.door_color??q,storefront_show_door_transom:He.show_door_transom??ce,storefront_edge_config:He.edge_config??ae})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-muted-foreground flex-1",children:"Ground-level glazing for retail buildings."}),e.jsx(Bf,{elementType:"storefront",currentElementId:t.storefront_element_id,currentConfig:fe,onSelectElement:He=>s({storefront_element_id:He}),onApplyConfig:Qe,disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Sc,{className:"w-4 h-4 text-sky-500"}),e.jsxs("div",{children:[e.jsx(B,{className:"text-sm font-medium",children:"Enable Storefront"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Glass facade at ground level"})]})]}),e.jsx(kt,{checked:I,onCheckedChange:qt,disabled:n})]}),I&&e.jsxs("div",{className:"space-y-4 animate-in fade-in-50",children:[e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border space-y-2",children:[e.jsx(B,{className:"text-xs font-medium",children:"Qu
755ick Presets"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"h-8 text-[10px] justify-start gap-1.5",onClick:()=>s({storefront_coverage_start_pct:0,storefront_coverage_end_pct:100,storefront_height_profile:"uniform",storefront_style:"continuous",storefront_height_ft:10,storefront_edge_config:{}}),disabled:n,children:[e.jsx(Sc,{className:"w-3 h-3"})," Full Glass"]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"h-8 text-[10px] justify-start gap-1.5",onClick:()=>s({storefront_coverage_start_pct:25,storefront_coverage_end_pct:75,storefront_height_profile:"center_peak",storefront_peak_height_ft:14,storefront_base_height_ft:8,storefront_peak_width_pct:40,storefront_style:"paneled",storefront_door_type:"sliding",storefront_door_count:1,storefront_door_placement:"center",storefront_edge_config:{}}),disabled:n,children:[e.jsx(fp,{className:"w-3 h-3"})," Big Box"]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"h-8 text-[10px] justify-start gap-1.5",onClick:()=>{const He=D&&D.length>0?D:[0],as={...ae};for(const vt of He)as[String(vt)]={...as[String(vt)],zones:[{startPct:5,endPct:35,heightProfile:"center_peak",peakHeightFt:14,baseHeightFt:10,peakWidthPct:50,doorType:"sliding",doorCount:1,doorPlacement:"center"},{startPct:65,endPct:95,heightProfile:"center_peak",peakHeightFt:14,baseHeightFt:10,peakWidthPct:50,doorType:"sliding",doorCount:1,doorPlacement:"center"}]};s({storefront_style:"paneled",storefront_edge_config:as})},disabled:n,children:[e.jsx(hp,{className:"w-3 h-3"})," Dual Entry"]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"h-8 text-[10px] justify-start gap-1.5",onClick:()=>s({storefront_coverage_start_pct:0,storefront_coverage_end_pct:100,storefront_height_profile:"uniform",storefront_style:"paneled",storefront_height_ft:10,storefront_door_type:"single",storefront_door_count:1,storefront_door_placement:"evenly_spaced",storefront_edge_config:{}}),disabled:n,children:[e.jsx(Ci,{className:"w-3 h-3"})," Strip Mall"]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"h-8 text-[10px] justify-start gap-1.5",onClick:()=>s({storefront_coverage_start_pct:0,storefront_coverage_end_pct:100,storefront_height_profile:"uniform",storefront_style:"continuous",storefront_height_ft:16,storefront_edge_config:{}}),disabled:n,children:[e.jsx(_3,{className:"w-3 h-3"})," Showroom"]})]})]}),e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs font-medium",children:"Glazing Zones"}),e.jsx(Mt,{variant:"secondary",className:"text-[10px]",children:(()=>{const as=(D&&D.length>0?D:[0])[0],vt=ae[String(as)],Xe=vt==null?void 0:vt.zones;return Xe?`${Xe.length} zone${Xe.length>1?"s":""}`:"1 zone"})()})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Define one or more glass zones along the facade. Each zone can have its own door and height settings."}),(()=>{const He=D&&D.length>0?D:[0],as=He[0],vt=ae[String(as)],Xe=(vt==null?void 0:vt.zones)||[{startPct:ie,endPct:de,heightProfile:ge,peakHeightFt:We,baseHeightFt:Ee,peakWidthPct:ve,doorType:H,doorCount:J,doorPlacement:O}],Ce=zt=>{const rs={...ae};for(const _s of He)rs[String(_s)]={...rs[String(_s)],zones:zt};s({storefront_edge_config:rs})},Be=(zt,rs)=>{const _s=Xe.map((vs,$t)=>$t===zt?{...vs,...rs}:vs);Ce(_s)},Dt=()=>{const zt=Xe[Xe.length-1],rs=Math.min(zt.endPct+5,95),_s=Math.min(rs+25,100);Ce([...Xe,{startPct:rs,endPct:_s,doorType:"sliding",doorCount:1,doorPlacement:"center"}])},Rt=zt=>{Xe.length<=1||Ce(Xe.filter((rs,_s)=>_s!==zt))};return e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"relative h-4 bg-muted rounded-full overflow-hidden",children:Xe.map((zt,rs)=>e.jsx("div",{className:"absolute top-0 bottom-0 rounded-full border border-sky-600/30",style:{left:`${zt.startPct}%`,right:`${100-zt.endPct}%`,background:`hsl(${200+rs*30}, 70%, 60%, 0.5)`},children:e.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[8px] font-medium text-foreground",children:rs+1})},rs))}),Xe.map((zt,rs)=>e.jsxs("div",{className:"p-2.5 bg-background rounded-lg border space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-[10px] font-medium",children:["Zone ",rs+1]}),Xe.length>1&&e.jsx(Le,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>Rt(rs),disabled:n,children:e.jsx(ja,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Start %"}),e.jsx(be,{type:"number",value:zt.startPct,onChange:_s=>Be(rs,{startPct:Math.max(0,Math.min(99,Number(_s.target.value)))}),className:"h-6 text-[10px]",min:0,max:99,step:5,disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"End %"}),e.jsx(be,{type:"number",value:zt.endPct,onChange:_s=>Be(rs,{endPct:Math.max(1,Math.min(100,Number(_s.target.value)))}),className:"h-6 text-[10px]",min:1,max:100,step:5,disabled:n})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Door"}),e.jsxs(rt,{value:zt.doorType||"none",onValueChange:_s=>Be(rs,{doorType:_s,doorCount:_s!=="none"?Math.max(1,zt.doorCount||1):0}),disabled:n,children:[e.jsx(it,{className:"h-6 text-[10px]",children:e.jsx(ct,{})}),e.jsx(ot,{children:W_.map(_s=>e.jsx(le,{value:_s.value,className:"text-[10px]",children:_s.label},_s.value))})]})]}),zt.doorType&&zt.doorType!=="none"&&e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Placement"}),e.jsxs(rt,{value:zt.doorPlacement||"center",onValueChange:_s=>Be(rs,{doorPlacement:_s}),disabled:n,children:[e.jsx(it,{className:"h-6 text-[10px]",children:e.jsx(ct,{})}),e.jsx(ot,{children:Sk.map(_s=>e.jsx(le,{value:_s.value,className:"text-[10px]",children:_s.label},_s.value))})]})]})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Height Profile"}),e.jsxs(rt,{value:zt.heightProfile||"uniform",onValueChange:_s=>Be(rs,{heightProfile:_s}),disabled:n,children:[e.jsx(it,{className:"h-6 text-[10px]",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"uniform",className:"text-[10px]",children:"Uniform"}),e.jsx(le,{value:"center_peak",className:"text-[10px]",children:"Center Peak"}),e.jsx(le,{value:"left_peak",className:"text-[10px]",children:"Left Peak"}),e.jsx(le,{value:"right_peak",className:"text-[10px]",children:"Right Peak"})]})]})]}),zt.heightProfile&&zt.heightProfile!=="uniform"&&e.jsxs("div",{className:"grid grid-cols-3 gap-1.5",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Peak ft"}),e.jsx(be,{type:"number",value:zt.peakHeightFt??14,onChange:_s=>Be(rs,{peakHeightFt:Number(_s.target.value)}),className:"h-6 text-[10px]",min:6,max:30,disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Base ft"}),e.jsx(be,{type:"number",value:zt.baseHeightFt??8,onChange:_s=>Be(rs,{baseHeightFt:Number(_s.target.value)}),className:"h-6 text-[10px]",min:4,max:20,disabled:n})]}),zt.heightProfile==="center_peak"&&e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Peak W%"}),e.jsx(be,{type:"number",value:zt.peakWidthPct??40,onChange:_s=>Be(rs,{peakWidthPct:Number(_s.target.value)}),className:"h-6 text-[10px]",min:10,max:90,disabled:n})]})]})]},rs)),Xe.length<4&&e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full h-7 text-[10px]",onClick:Dt,disabled:n,children:[e.jsx(tr,{className:"w-3 h-3 mr-1"})," Add Zone"]})]})})()]}),e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border space-y-3",children:[e.jsx(B,{className:"text-xs font-medium",children:"Default Height Profile"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Applied to edges without per-zone height overrides"}),e.jsxs(rt,{value:ge,onValueChange:He=>s({storefront_height_profile:He}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"uniform",className:"text-xs",children:"Uniform (same height)"}),e.jsx(le,{value:"center_peak",className:"text-xs",children:"Center Peak (taller center)"}),e.jsx(le,{value:"left_peak",className:"text-xs",children:"Left Peak (taller left)"}),e.jsx(le,{value:"right_peak",className:"text-xs",children:"Right Peak (taller right)"})]})]}),ge!=="uniform"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Peak Height (ft)"}),e.jsx(be,{type:"number",value:We,onChange:He=>s({storefront_peak_height_ft:Number(He.target.value)}),className:"h-7 text-xs",min:6,max:30,step:1,disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Base Height (ft)"}),e.jsx(be,{type:"number",value:Ee,onChange:He=>s({storefront_base_height_ft:Number(He.target.value)}),className:"h-7 text-xs",min:4,max:20,step:1,disabled:n})]})]}),ge==="center_peak"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Peak Width %"}),e.jsx(be,{type:"number",value:ve,onChange:He=>s({storefront_peak_width_pct:Number(He.target.value)}),className:"h-7 text-xs",min:10,max:90,step:5,disabled:n})]}),e.jsx("div",{className:"flex items-end h-8 gap-px",children:Array.from({length:20},(He,as)=>{const vt=as/19;let Xe;if(ge==="center_peak"){const Dt=(50-ve/2)/100,Rt=(50+ve/2)/100;vt<Dt?Xe=Ee+(We-Ee)*(vt/Dt):vt>Rt?Xe=Ee+(We-Ee)*((1-vt)/(1-Rt)):Xe=We}else ge==="left_peak"?Xe=We+(Ee-We)*vt:Xe=Ee+(We-Ee)*vt;const Ce=Math.max(We,Ee),Be=Ce>0?Xe/Ce*100:0;return e.jsx("div",{className:"flex-1 bg-sky-500/50 rounded-t-sm",style:{height:`${Be}%`}},as)})})]})]}),e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs font-medium",children:"Placement"}),we&&e.jsxs(Mt,{variant:"secondary",className:"text-[10px]",children:[D.length," edge",D.length>
7551?"s":""]})]}),c?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(Mt,{variant:"default",className:"text-xs animate-pulse",children:"Click edges to toggle (multi-select)"})}),e.jsx(Le,{variant:"secondary",size:"sm",className:"w-full h-7 text-xs",onClick:l,children:"Done Selecting"})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Le,{variant:we?"secondary":"outline",size:"sm",className:"flex-1 h-7 text-xs",onClick:a,disabled:n,children:[e.jsx(wx,{className:"w-3 h-3 mr-1"}),"Select Edges"]}),we&&e.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:Fe,disabled:n,children:"All Sides"})]}),we&&!c&&ke&&e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dh,{className:"w-3 h-3 text-muted-foreground"}),e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Per-Edge Configuration"})]}),e.jsx("div",{className:"space-y-1",children:D.map(He=>{const as=oe==null?void 0:oe.includes(He),vt=ze(He),Xe=C===He;return e.jsxs(wi,{open:Xe,onOpenChange:Ce=>P(Ce?He:null),children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full h-7 justify-between text-[10px] px-2",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsxs(Mt,{variant:as?"default":"outline",className:"text-[9px] h-4",children:["Edge ",He]}),e.jsx("span",{className:"text-muted-foreground",children:as?"Doors Only":"Glass + Doors"})]}),e.jsx(Oa,{className:`w-3 h-3 transition-transform ${Xe?"rotate-180":""}`})]})}),e.jsxs(ki,{className:"pt-2 pb-3 px-2 space-y-3 bg-muted/30 rounded-md mt-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-[10px]",children:"Doors Only (No Glass)"}),e.jsx(kt,{checked:vt.isDoorsOnly,onCheckedChange:Ce=>Ke(He,{isDoorsOnly:Ce}),disabled:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Door Width (ft)"}),e.jsx(be,{type:"number",value:vt.doorWidthFt,onChange:Ce=>Ke(He,{doorWidthFt:Number(Ce.target.value)}),className:"h-6 text-[10px]",min:2,max:15,step:.5,disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Door Height (ft)"}),e.jsx(be,{type:"number",value:vt.doorHeightFt,onChange:Ce=>Ke(He,{doorHeightFt:Number(Ce.target.value)}),className:"h-6 text-[10px]",min:6,max:12,step:.5,disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-[10px]",children:"Glass Above Door"}),e.jsx(kt,{checked:vt.showTransom,onCheckedChange:Ce=>Ke(He,{showTransom:Ce}),disabled:n})]})]})]},He)})}),e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Expand each edge to customize door size & transom glass"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Storefront Style"}),e.jsxs(rt,{value:F,onValueChange:He=>ft(He),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:Object.entries(Kw).map(([He,as])=>e.jsx(le,{value:He,className:"text-xs",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:as.name}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:as.description})]})},He))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Storefront Height"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{type:"number",value:i??z,onChange:He=>dt(Number(He.target.value)),className:"h-8 text-sm flex-1",min:6,max:20,step:1,disabled:n}),e.jsx(Mt,{variant:"secondary",className:"text-xs",children:"ft"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Typically 8-12 ft for retail, up to 16 ft for showrooms"})]}),Ze&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border space-y-3",children:[e.jsx(B,{className:"text-xs font-medium",children:"Panel Configuration"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Mullion Spacing (ft)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{type:"number",value:j??X,onChange:He=>Re(Number(He.target.value)),className:"h-7 text-xs flex-1",min:4,max:15,step:.5,disabled:n}),e.jsx(Mt,{variant:"outline",className:"text-[10px]",children:"ft"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Frame Color"}),e.jsx("input",{type:"color",value:te,onChange:He=>s({storefront_mullion_color:He.target.value}),className:"w-8 h-6 rounded border cursor-pointer",disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:te})]})]}),e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lf,{className:"w-4 h-4 text-amber-500"}),e.jsx(B,{className:"text-xs font-medium",children:"Entry Doors"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Type"}),e.jsxs(rt,{value:H,onValueChange:He=>s({storefront_door_type:He,storefront_door_count:He==="none"?0:Math.max(1,J)}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:W_.map(He=>e.jsx(le,{value:He.value,className:"text-xs",children:He.label},He.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Count"}),e.jsx(be,{type:"number",value:J,onChange:He=>s({storefront_door_count:Number(He.target.value)}),className:"h-7 text-xs",min:0,max:4,disabled:n||H==="none"})]})]}),ke&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Placement"}),e.jsxs(rt,{value:O,onValueChange:He=>s({storefront_door_placement:He}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:Sk.map(He=>e.jsx(le,{value:He.value,className:"text-xs",children:He.label},He.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Default Width (ft)"}),e.jsx(be,{type:"number",value:W,onChange:He=>s({storefront_door_width_ft:Number(He.target.value)}),className:"h-7 text-xs",min:2,max:15,step:.5,disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Default Height (ft)"}),e.jsx(be,{type:"number",value:Q,onChange:He=>s({storefront_door_height_ft:Number(He.target.value)}),className:"h-7 text-xs",min:6,max:12,step:.5,disabled:n})]})]}),we&&e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Override per
755-edge in Edge Configuration above"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Door Color"}),e.jsx("input",{type:"color",value:q,onChange:He=>s({storefront_door_color:He.target.value}),className:"w-8 h-6 rounded border cursor-pointer",disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:q})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Default Glass Above Doors"}),e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Transom glass when door is shorter than storefront"})]}),e.jsx(kt,{checked:ce,onCheckedChange:He=>s({storefront_show_door_transom:He}),disabled:n})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg border",children:[e.jsx(C0,{className:"w-4 h-4 text-sky-500"}),e.jsx(B,{className:"text-xs",children:"Glass Tint"}),e.jsx("input",{type:"color",value:Z,onChange:He=>s({storefront_glass_color:He.target.value}),className:"w-8 h-6 rounded border cursor-pointer ml-auto",disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:Z})]}),e.jsx("div",{className:"p-2 bg-sky-500/10 border border-sky-500/30 rounded-md",children:e.jsx("p",{className:"text-[10px] text-sky-600 dark:text-sky-400",children:"💡 Storefront is rendered in 3D view with glass panels, mullions, and door openings."})})]})]})}const GR={Warehouse:e.jsx(yg,{className:"w-4 h-4"}),Package:e.jsx(A1,{className:"w-4 h-4"}),Store:e.jsx(Sc,{className:"w-4 h-4"}),Building:e.jsx(uh,{className:"w-4 h-4"}),Building2:e.jsx(Ci,{className:"w-4 h-4"}),Hospital:e.jsx(Eb,{className:"w-4 h-4"}),Layers:e.jsx(Da,{className:"w-4 h-4"}),Home:e.jsx(qd,{className:"w-4 h-4"}),Server:e.jsx(P1,{className:"w-4 h-4"}),MoreHorizontal:e.jsx(Mg,{className:"w-4 h-4"})};function HR({currentType:t,onSelect:s,isUpdating:n,defaultOpen:a=!0}){var i,_;const[l,c]=k.useState(a),u=t?((i=jv.find(j=>j.id===t))==null?void 0:i.label)||t:null;return e.jsxs(wi,{open:l,onOpenChange:c,children:[e.jsxs(Ni,{className:"flex items-center justify-between w-full py-2 px-1 -mx-1 rounded-md hover:bg-muted/50 transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ci,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Building Type"}),u&&e.jsx(Mt,{variant:"secondary",className:"text-[10px]",children:u})]}),e.jsx(Oa,{className:fs("h-4 w-4 text-muted-foreground transition-transform duration-200",l?"rotate-0":"-rotate-90")})]}),e.jsxs(ki,{className:"pt-3 space-y-3",children:[e.jsx("div",{className:"p-2 bg-amber-500/10 border border-amber-500/20 rounded-md",children:e.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-400 flex items-start gap-1.5",children:[e.jsx("span",{className:"shrink-0 mt-0.5",children:"⚠️"}),e.jsx("span",{children:"Changing Building Type will update the available design elements and configuration options (e.g., docks, windows, storefronts)."})]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Select a building type to show relevant configuration options"}),e.jsx(Xc,{className:"h-[180px] pr-3",children:e.jsx("div",{className:"grid grid-cols-2 gap-2",children:jv.map(j=>{const y=t===j.id;return e.jsxs(Le,{variant:y?"default":"outline",size:"sm",className:`h-auto py-2 px-3 flex flex-col items-center gap-1 ${y?"":"hover:bg-accent"}`,onClick:()=>s(j.id,j.defaults),disabled:n,children:[GR[j.icon]||e.jsx(Ci,{className:"w-4 h-4"}),e.jsx("span",{className:"text-[10px] leading-tight text-center",children:j.label})]},j.id)})})}),t&&e.jsx("div",{className:"p-2 bg-muted/50 rounded-md",children:e.jsx("p",{className:"text-[10px] text-muted-foreground",children:(_=jv.find(j=>j.id===t))==null?void 0:_.description})})]})]})}function ns({title:t,icon:s,badge:n,defaultOpen:a=!0,open:l,onOpenChange:c,children:u,className:i,headerAction:_}){const[j,y]=k.useState(a),x=l!==void 0?l:j,v=C=>{c?c(C):y(C)};return e.jsxs(wi,{open:x,onOpenChange:v,className:i,children:[e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs(Ni,{className:"flex items-center justify-between flex-1 py-2 px-1 -mx-1 rounded-md hover:bg-muted/50 transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s&&e.jsx("span",{className:"text-primary",children:s}),e.jsx("span",{className:"text-sm font-medium",children:t}),n]}),e.jsx(Oa,{className:fs("h-4 w-4 text-muted-foreground transition-transform duration-200",x?"rotate-0":"-rotate-90")})]}),_&&e.jsx("div",{className:"shrink-0 ml-1",onClick:C=>C.stopPropagation(),children:_})]}),e.jsx(ki,{className:"pt-3 space-y-3",children:u})]})}function ZR({overlay:t,onUpdate:s,isUpdating:n}){const[a,l]=k.useState(!1),c=k.useRef(),[u,i]=k.useState(null),_=j=>{const y=j[0];i(y),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{s({dock_light_height_ft:y})},300)};return e.jsxs(wi,{open:a,onOpenChange:l,children:[e.jsxs(Ni,{className:"flex items-center justify-between w-full p-2 rounded-md hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gh,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Dock Lighting"})]}),e.jsx(Oa,{className:`w-3.5 h-3.5 text-muted-foreground transition-transform ${a?"rotate-180":""}`})]}),e.jsxs(ki,{className:"space-y-3 pt-2 pl-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Enable Dock Lights"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Fixtures above each dock door"})]}),e.jsx(kt,{checked:t.dock_light_enabled??!1,onCheckedChange:j=>s({dock_light_enabled:j}),disabled:n})]}),t.dock_light_enabled&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Light Type"}),e.jsxs(rt,{value:t.dock_light_type||"gooseneck",onValueChange:j=>s({dock_light_type:j}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"gooseneck",className:"text-xs",children:"Gooseneck (Curved Arm)"}),e.jsx(le,{value:"wall_pack",className:"text-xs",children:"Wall Pack (Box)"}),e.jsx(le,{value:"led_strip",className:"text-xs",children:"LED Strip (Continuous)"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(B,{className:"text-[10px]",children:"Mounting Height"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[u??t.dock_light_height_ft??14," ft"]})]}),e.jsx(Ca,{value:[u??t.dock_light_height_ft??14],min:10,max:20,step:1,onValueChange:_,disabled:n})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-[10px] shrink-0",children:"Color"}),e.jsx(be,{type:"color",value:t.dock_light_color||"#FFD700",onChange:j=>s({dock_light_color:j.target.value}),className:"h-6 w-10 p-0.5 cursor-pointer",disabled:n})]})]})]})]})}function WR({overlay:t,onUpdate:s,isUpdating:n}){const[a,l]=k.useState(!1),[c,u]=k.useState(!1),i=k.useRef(),[_,j]=k.useState(null),y=x=>
755{const v=x[0];j(v),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{s({dock_canopy_depth_ft:v})},300)};return e.jsxs("div",{className:"space-y-2 mt-3",children:[e.jsxs(wi,{open:a,onOpenChange:l,children:[e.jsxs(Ni,{className:"flex items-center justify-between w-full p-2 rounded-md hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hd,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Dock Equipment"})]}),e.jsx(Oa,{className:`w-3.5 h-3.5 text-muted-foreground transition-transform ${a?"rotate-180":""}`})]}),e.jsxs(ki,{className:"space-y-3 pt-2 pl-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Seal / Shelter"}),e.jsxs(rt,{value:t.dock_seal_type||"none",onValueChange:x=>s({dock_seal_type:x==="none"?null:x}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"none",className:"text-xs",children:"None"}),e.jsx(le,{value:"seal",className:"text-xs",children:"Dock Seal (Foam Pads)"}),e.jsx(le,{value:"shelter",className:"text-xs",children:"Dock Shelter (Rigid Frame)"})]})]}),t.dock_seal_type&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-[10px] shrink-0",children:"Color"}),e.jsx(be,{type:"color",value:t.dock_seal_color||"#1a1a1a",onChange:x=>s({dock_seal_color:x.target.value}),className:"h-6 w-10 p-0.5 cursor-pointer",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Dock Leveler"}),e.jsxs(rt,{value:t.dock_leveler_type||"none",onValueChange:x=>s({dock_leveler_type:x==="none"?null:x}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"none",className:"text-xs",children:"None"}),e.jsx(le,{value:"hydraulic",className:"text-xs",children:"Hydraulic"}),e.jsx(le,{value:"mechanical",className:"text-xs",children:"Mechanical"}),e.jsx(le,{value:"edge_of_dock",className:"text-xs",children:"Edge-of-Dock"})]})]}),t.dock_leveler_type&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-[10px] shrink-0",children:"Color"}),e.jsx(be,{type:"color",value:t.dock_leveler_color||"#9CA3AF",onChange:x=>s({dock_leveler_color:x.target.value}),className:"h-6 w-10 p-0.5 cursor-pointer",disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Dock Bumpers"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Rubber impact pads"})]}),e.jsx(kt,{checked:t.dock_bumpers_enabled??!1,onCheckedChange:x=>s({dock_bumpers_enabled:x}),disabled:n})]}),t.dock_bumpers_enabled&&e.jsxs("div",{className:"flex items-center gap-2 pl-2",children:[e.jsx(B,{className:"text-[10px] shrink-0",children:"Color"}),e.jsx(be,{type:"color",value:t.dock_bumper_color||"#111827",onChange:x=>s({dock_bumper_color:x.target.value}),className:"h-6 w-10 p-0.5 cursor-pointer",disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Vehicle Restraints"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Safety chocks/hooks"})]}),e.jsx(kt,{checked:t.dock_restraints_enabled??!1,onCheckedChange:x=>s({dock_restraints_enabled:x}),disabled:n})]}),t.dock_restraints_enabled&&e.jsxs("div",{className:"flex items-center gap-2 pl-2",children:[e.jsx(B,{className:"text-[10px] shrink-0",children:"Color"}),e.jsx(be,{type:"color",value:t.dock_restraint_color||"#EAB308",onChange:x=>s({dock_restraint_color:x.target.value}),className:"h-6 w-10 p-0.5 cursor-pointer",disabled:n})]})]})]}),e.jsxs(wi,{open:c,onOpenChange:u,children:[e.jsxs(Ni,{className:"flex items-center justify-between w-full p-2 rounded-md hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u3,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Weather Protection"})]}),e.jsx(Oa,{className:`w-3.5 h-3.5 text-muted-foreground transition-transform ${c?"rotate-180":""}`})]}),e.jsxs(ki,{className:"space-y-3 pt-2 pl-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Rain Hood / Canopy"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Roof overhang above docks"})]}),e.jsx(kt,{checked:t.dock_canopy_enabled??!1,onCheckedChange:x=>s({dock_canopy_enabled:x}),disabled:n})]}),t.dock_canopy_enabled&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(B,{className:"text-[10px]",children:"Projection Depth"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[_??t.dock_canopy_depth_ft??6," ft"]})]}),e.jsx(Ca,{value:[_??t.dock_canopy_depth_ft??6],min:4,max:8,step:.5,onValueChange:y,disabled:n})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-[10px] shrink-0",children:"Color"}),e.jsx(be,{type:"color",value:t.dock_canopy_color||t.roof_color||"#6B7280",onChange:x=>s({dock_canopy_color:x.target.value}),className:"h-6 w-10 p-0.5 cursor-pointer",disabled:n})]})]})]})]}),e.jsx(ZR,{overlay:t,onUpdate:s,isUpdating:n})]})}function Oh(t,s){const n=us(t),a=us(s);return gi(n,a,{units:"kilometers"})*3280.84}function YR(t,s){return Or(us(t),us(s))}function Ii(t,s,n){const a=s/3280.84;return On(us(t),a,n,{units:"kilometers"}).geometry.coordinates}function Ec(t){const s=[];for(let n=0;n<t.length;n++){const a=t[n],l=t[(n+1)%t.length],c=Oh(a,l),u=[(a[0]+l[0])/2,(a[1]+l[1])/2],i=YR(a,l);s.push({start:a,end:l,lengthFt:c,midpoint:u,bearingDeg:i,index:n})}return s}function PP(t,s){const n=t[s],a=t[(s+1)%t.length];return{type:"Feature",properties:{edgeIndex:s},geometry:{type:"LineString",coordinates:[n,a]}}}function l0(t,s){let n=1/0,a=0;for(let l=0;l<s.length;l++){const c=s[l],u=s[(l+1)%s.length],i=XR(t,c,u);i<n&&(n=i,a=l)}return a}function XR(t,s,n){const a=n[0]-s[0],l=n[1]-s[1];if(a===0&&l===0)return Oh(t,s);const c=Math.max(0,Math.min(1,((t[0]-s[0])*a+(t[1]-s[1])*l)/(a*a+l*l))),u=[s[0]+c*a,s[1]+c*l];return Oh(t,u)}function TP(t,s,n,a,l,c=4){const u=[];let i=0,_=0;if(t.length<3||n<=0)return{features:Un([]),actualCount:0,requestedCount:n*s.length,reduced:!1};const j=Xn([[...t,t[0]]]),x=Yo(j).geometry.coordinates,v=Ec(t);for(const C of s){if(C<0||C>=v.length)continue;const P=v[C];_+=n;const I=LP(P,x,n,a,l,c);i+=I.features.length,u.push(...I.features)}return{features:Un(u),actualCount:i,requestedCount:_,reduced:i<_}}function LP(t,s,n,a,l,c){const u=[];
755if(n<=0||t.lengthFt<a)return Un(u);const i=a+l,_=n*i-l;let j=n;_>t.lengthFt&&(j=Math.max(1,Math.floor((t.lengthFt+l)/i)));const y=j*i-l,x=(t.lengthFt-y)/2+a/2,v=t.bearingDeg,C=(v+90)%360,P=(v-90+360)%360,I=Ii(t.midpoint,10,C),z=Ii(t.midpoint,10,P),F=Oh(I,s),D=Oh(z,s),X=F>D?C:P;for(let K=0;K<j;K++){const te=x+K*i,J=Ii(t.start,te,v),H=a/2,O=Ii(J,H,(v+180)%360),q=Ii(J,H,v),W=Ii(O,c,X),Q=Ii(q,c,X),Z=[O,q,Q,W,O];u.push({type:"Feature",properties:{dockIndex:K,edgeIndex:t.index},geometry:{type:"Polygon",coordinates:[Z]}})}return Un(u)}function kg(t){if(t.length<3)throw new Error("Need at least 3 coordinates to classify edges");const s=Xn([[...t,t[0]]]),a=Yo(s).geometry.coordinates,l=Ec(t),c=[...l].sort((I,z)=>z.lengthFt-I.lengthFt),u=c[0],i=c[1],_=Oh(u.midpoint,a),j=Oh(i.midpoint,a);let y,x;_>=j?(y=u,x=i):(y=i,x=u);const v=l.filter(I=>I.index!==y.index&&I.index!==x.index);let C=null,P=null;if(v.length>=2){const I=[a[0]-y.midpoint[0],a[1]-y.midpoint[1]];for(const z of v){const F=[z.midpoint[0]-y.midpoint[0],z.midpoint[1]-y.midpoint[1]];I[0]*F[1]-I[1]*F[0]>0?C=z:P=z}!C&&v.length>=1&&(C=v.find(z=>z!==P)||null),!P&&v.length>=1&&(P=v.find(z=>z!==C)||null)}else v.length===1&&(C=v[0]);return{rear:y,front:x,left:C,right:P,centroid:a}}function Cg(t,s){switch(t){case"single_rear":return[s.rear];case"single_front":return[s.front];case"single_left":return s.left?[s.left]:[];case"single_right":return s.right?[s.right]:[];case"cross_dock":return[s.rear,s.front];default:return[s.rear]}}function KR(t,s,n,a,l,c=4){return LP(t,s,n,a,l,c)}function JR(t,s,n,a){if(s<=0||t<n)return 0;const l=n+a;return s*l-a>t?Math.max(1,Math.floor((t+a)/l)):s}function QR(t,s,n,a,l,c){if(t.length<3||a<=0)return{requested:0,actual:0,edges:[]};try{const u=Ec(t),i=kg(t);let _=[];n&&n.length>0?_=n.filter(v=>v>=0&&v<u.length):_=Cg(s,i).map(C=>C.index);let j=0;const y=[];for(const v of _){const C=u[v];if(!C)continue;const P=JR(C.lengthFt,a,l,c);j+=P,y.push({index:v,length:Math.round(C.lengthFt),count:P})}return{requested:_.length*a,actual:j,edges:y}}catch(u){return console.warn("Failed to calculate dock count:",u),{requested:a,actual:a,edges:[]}}}function MP(t,s,n=18,a=10,l=12){var x,v,C,P;if(!t.features.length||s.length<3)return Un([]);const c=Xn([[...s,s[0]]]);Yo(c).geometry.coordinates;const i=Ec(s),_=n/12,j=1,y=[];for(const I of t.features){const z=((x=I.properties)==null?void 0:x.edgeIndex)??0;if(!i[z])continue;const D=I.geometry.coordinates[0],X=D[0],K=D[1],te=D[2],J=D[3],H=Or(us(X),us(K)),O=Or(us(X),us(J)),q=Ii(X,j,(H+180)%360),W=Ii(K,j,H),Q=Ii(q,_,O),Z=Ii(W,_,O);y.push({type:"Feature",properties:{equipmentType:"dock_seal",dockIndex:(v=I.properties)==null?void 0:v.dockIndex,edgeIndex:z},geometry:{type:"Polygon",coordinates:[[q,X,J,Q,q]]}}),y.push({type:"Feature",properties:{equipmentType:"dock_seal",dockIndex:(C=I.properties)==null?void 0:C.dockIndex,edgeIndex:z},geometry:{type:"Polygon",coordinates:[[K,W,Z,te,K]]}}),y.push({type:"Feature",properties:{equipmentType:"dock_seal_header",dockIndex:(P=I.properties)==null?void 0:P.dockIndex,edgeIndex:z},geometry:{type:"Polygon",coordinates:[[J,te,Z,Q,J]]}})}return Un(y)}function UR(t,s,n=6){var _,j;if(!t.features.length||s.length<3)return Un([]);const a=Xn([[...s,s[0]]]),c=Yo(a).geometry.coordinates,u=Ec(s),i=[];for(const y of t.features){const x=((_=y.properties)==null?void 0:_.edgeIndex)??0,v=u[x];if(!v)continue;const C=y.geometry.coordinates[0],P=C[0],I=C[1],z=Or(us(P),us(I)),F=(z+90)%360,D=(z-90+360)%360,X=Ii(v.midpoint,10,F),K=Oh(X,c),te=Oh(Ii(v.midpoint,10,D),c),J=K<te?F:D,H=Ii(P,n,J),O=Ii(I,n,J);i.push({type:"Feature",properties:{equipmentType:"dock_leveler",dockIndex:(j=y.properties)==null?void 0:j.dockIndex,edgeIndex:x},geometry:{type:"Polygon",coordinates:[[P,I,O,H,P]]}})}return Un(i)}function IP(t,s,n=1,a=.5){var u,i,_;if(!t.features.length||s.length<3)return Un([]);const l=Ec(s),c=[];for(const j of t.features){const y=((u=j.properties)==null?void 0:u.edgeIndex)??0;if(!l[y])continue;const v=j.geometry.coordinates[0],C=v[0],P=v[1];v[2];const I=v[3],z=Or(us(C),us(P)),F=Or(us(C),us(I)),D=C,X=Ii(C,n,(z+180)%360),K=Ii(X,a,F),te=Ii(D,a,F);c.push({type:"Feature",properties:{equipmentType:"dock_bumper",side:"left",dockIndex:(i=j.properties)==null?void 0:i.dockIndex,edgeIndex:y},geometry:{type:"Polygon",coordinates:[[D,X,K,te,D]]}});const J=P,H=Ii(P,n,z),O=Ii(H,a,F),q=Ii(J,a,F);c.push({type:"Feature",properties:{equipmentType:"dock_bumper",side:"right",dockIndex:(_=j.properties)==null?void 0:_.dockIndex,edgeIndex:y},geometry:{type:"Polygon",coordinates:[[J,H,O,q,J]]}})}return Un(c)}function eF(t,s,n=1.5){var c,u;if(!t.features.length||s.length<3)return Un([]);const a=Ec(s),l=[];for(const i of t.features){const _=((c=i.properties)==null?void 0:c.edgeIndex)??0;if(!a[_])continue;const y=i.geometry.coordinates[0],x=y[3],v=y[2],C=(x[0]+v[0])/2,P=(x[1]+v[1])/2,I=[
755C,P],z=Or(us(x),us(v)),F=n/2,D=Ii(I,F,z),X=Ii(I,F,(z+90)%360),K=Ii(I,F,(z+180)%360),te=Ii(I,F,(z-90+360)%360);l.push({type:"Feature",properties:{equipmentType:"dock_restraint",dockIndex:(u=i.properties)==null?void 0:u.dockIndex,edgeIndex:_},geometry:{type:"Polygon",coordinates:[[D,X,K,te,D]]}})}return Un(l)}function AP(t,s,n=6,a=10){var i,_;if(!t.features.length||s.length<3)return Un([]);const l=Ec(s),c=[],u=2;for(const j of t.features){const y=((i=j.properties)==null?void 0:i.edgeIndex)??0;if(!l[y])continue;const v=j.geometry.coordinates[0],C=v[0],P=v[1],I=Or(us(C),us(P)),z=Or(us(C),us(v[3])),F=Ii(C,u,(I+180)%360),D=Ii(P,u,I),X=Ii(F,n,z),K=Ii(D,n,z);c.push({type:"Feature",properties:{equipmentType:"dock_canopy",dockIndex:(_=j.properties)==null?void 0:_.dockIndex,edgeIndex:y},geometry:{type:"Polygon",coordinates:[[F,D,K,X,F]]}})}return Un(c)}function DP(t,s,n=70){if(t.length<3||s.length===0)return Un([]);const a=Xn([[...t,t[0]]]),c=Yo(a).geometry.coordinates,u=Ec(t),i=[];for(const _ of s){const j=u[_];if(!j)continue;const y=j.bearingDeg,x=(y+90)%360,v=(y-90+360)%360,C=Ii(j.midpoint,10,x),P=Oh(C,c),I=Oh(Ii(j.midpoint,10,v),c),z=P>I?x:v,F=Ii(j.start,n,z),D=Ii(j.end,n,z);i.push({type:"Feature",properties:{equipmentType:"dock_apron",edgeIndex:_},geometry:{type:"Polygon",coordinates:[[j.start,j.end,D,F,j.start]]}})}return Un(i)}function RP(t,s,n,a,l,c=4){if(t.length<3||n<=0)return Un([]);try{const u=kg(t),i=Cg(s,u),_=n,j=[];for(const y of i){const x=KR(y,u.centroid,_,a,l,c);j.push(...x.features)}return Un(j)}catch(u){return console.warn("Failed to generate dock doors:",u),Un([])}}function tF({overlay:t,onUpdate:s,isUpdating:n,onStartEdgeSelection:a,onCancelEdgeSelection:l,edgeSelectionMode:c=!1}){const u=k.useRef(),i=k.useRef(),_=k.useRef(),j=k.useRef(),y=k.useRef(),x=k.useRef(),v=k.useRef(),C=k.useRef(),[P,I]=k.useState(null),[z,F]=k.useState(null),[D,X]=k.useState(null),[K,te]=k.useState(null),[J,H]=k.useState(null),[O,q]=k.useState(null),[W,Q]=k.useState(null),[Z,oe]=k.useState(null),[ce,ae]=k.useState(!1),[ie,de]=k.useState(!1),[ge,We]=k.useState(!1);k.useEffect(()=>{I(null),F(null),X(null),te(null),H(null),q(null),Q(null),oe(null)},[t.id]);const Ee=k.useMemo(()=>{if(!t.geometry||t.geometry.length<3||!t.dock_count||t.dock_count<=0)return null;const Ce=t.geometry.map(Be=>[Be.lng,Be.lat]);return QR(Ce,t.dock_config||"single_rear",t.dock_edge_indices,t.dock_count,t.dock_width_ft||10,t.dock_spacing_ft||12)},[t.geometry,t.dock_count,t.dock_config,t.dock_edge_indices,t.dock_width_ft,t.dock_spacing_ft]),ve=(t.dock_count??0)>0,we=Ee&&Ee.actual<Ee.requested,Ze=t.dock_edge_indices||[],ke=t.dock_layout_mode||"manual",ze=Ce=>{const Be=Math.max(0,parseInt(Ce)||0);I(Be),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{s({dock_count:Be})},300)},Ke=Ce=>{const Be=Math.max(8,parseFloat(Ce)||12);F(Be),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{s({dock_spacing_ft:Be})},300)},dt=Ce=>{const Be=parseFloat(Ce)||12;X(Be),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{s({dock_height_ft:Be})},300)},Re=Ce=>{const Be=parseFloat(Ce)||10;te(Be),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{s({dock_width_ft:Be})},300)},qt=Ce=>{const Be=Ce[0];H(Be),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{s({dock_depth_ft:Be})},300)},ft=Ce=>{const Be=Math.max(0,parseFloat(Ce)||0);q(Be),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{s({dock_end_gap_left_ft:Be})},300)},Fe=Ce=>{const Be=Math.max(0,parseFloat(Ce)||0);Q(Be),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{s({dock_end_gap_right_ft:Be})},300)},fe=Ce=>{const Be=Math.max(0,parseInt(Ce)||0);oe(Be),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{s({dock_man_door_interval:Be})},300)},Qe=()=>{s({dock_edge_indices:null})},ht=t.dock_zones||[],_t=()=>{const Ce=[...ht,{dock_count:10,label:`Zone ${ht.length+1}`}];s({dock_zones:Ce})},He=(Ce,Be)=>{const Dt=ht.map((Rt,zt)=>zt===Ce?{...Rt,...Be}:Rt);s({dock_zones:Dt})},as=Ce=>{const Be=ht.filter((Dt,Rt)=>Rt!==Ce);s({dock_zones:Be.length>0?Be:null})},vt=k.useMemo(()=>({count:t.dock_count??0,width_ft:t.dock_width_ft??10,height_ft:t.dock_height_ft??12,spacing_ft:t.dock_spacing_ft??12,style:t.dock_style,color:t.dock_color,vertical_gradient:t.dock_vertical_gradient,config:t.dock_config,edge_indices:Ze}),[t.dock_count,t.dock_width_ft,t.dock_height_ft,t.dock_spacing_ft,t.dock_style,t.dock_color,t.dock_vertical_gradient,t.dock_config,Ze]),Xe=Ce=>{s({dock_count:Ce.count??t.dock_count,dock_width_ft:Ce.width_ft??t.dock_width_ft,dock_height_ft:Ce.height_ft??t.dock_height_ft,dock_spacing_ft:Ce.spacing_ft??t.dock_spacing_ft,dock_style:Ce.style??t.dock_style,dock_color:Ce.color??t.dock_color,dock_vertical_gradient:Ce.vertical_gradient??t.dock_vertical_gradient})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(Bf,{elementType:"docks",currentElementId:t.docks_element_id,currentConfig:vt,onSelectElement:Ce=>s({docks_element_id:Ce}),onApplyConfig:Xe,disabled:n})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'Dock-high doors for trailer loading (typically 48" AFF).'}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Layout Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsx(Le,{variant:ke==="manual"?"default":"outline",size:"sm",className:"h-7 text-xs",onClick:()=>s({dock_layout_mode:"manual"}),disabled:n,children:"Manual"}),e.jsxs(Le,{variant:ke==="maximize"?"default":"outline",size:"sm",className:"h-7 text-xs",onClick:()=>s({dock_layout_mode:"maximize"}),disabled:n,children:[e.jsx(Mf,{className:"w-3 h-3 mr-1"}),"Maximize"]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:ke==="maximize"?"Auto-fill edge with as many docks as possible":"Specify exact dock count per edge"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[ke==="manual"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Dock Count (per edge)"}),e.jsx(be,{type:"number",min:0,value:P??t.dock_count??0,onChange:Ce=>ze(Ce.target.value),className:"h-8 text-sm",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Spacing (ft)"}),e.jsx(be,{type:"number",min:8,value:z??t.dock_spacing_ft??12,onChange:Ce=>Ke(Ce.target.value),className:"h-8 text-sm",disabled:n})]}),ke==="maximize"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Dock Count (per edge)"}),e.jsx(be,{type:"number",min:0,value:P??t.dock_count??0,onChange:Ce=>ze(Ce.target.value),className:"h-8 text-sm",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(B,{className:"text-xs",children:"Dock Depth (protrusion)"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[J??t.dock_depth_ft??4," ft"]})]}),e.jsx(Ca,{value:[J??t.dock_depth_ft??4],min:2,max:10,step:.5,onValueChange:qt,disabled:n}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"How far docks extend from the building wall"})]}),Ee&&Ee.requested>0&&e.jsxs("div",{className:`p-2 rounded-md text-xs ${we?"bg-amber-500/10 border border-amber-500/30":"bg-green-500/10 border border-green-500/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[we?e.jsx(ho,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}):e.jsx(bp,{className:"w-3.5 h-3.5 text-green-500 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:we?"text-amber-600 dar
755k:text-amber-400":"text-green-600 dark:text-green-400",children:we?`${Ee.actual} total docks (reduced from ${Ee.requested})`:`${Ee.actual} total docks`}),Ee.edges.length>0&&e.jsxs("div",{className:"text-muted-foreground mt-1 space-y-0.5",children:[Ee.edges.length>1&&e.jsxs("div",{className:"text-[10px] font-medium text-muted-foreground/80 mb-0.5",children:["Cross Dock: ",Ee.edges.length," edges"]}),Ee.edges.map(Ce=>e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{children:["Edge ",Ce.index,":"]}),e.jsxs("span",{className:"font-medium",children:[Ce.count," docks on ",Ce.length,"ft"]})]},Ce.index))]})]})]}),we&&e.jsx("p",{className:"text-muted-foreground mt-1.5 text-[10px]",children:"💡 Reduce dock width or spacing to fit more docks"})]}),ve&&e.jsxs("div",{className:"space-y-4 p-3 bg-muted/50 rounded-lg border animate-in fade-in-50",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Dock Face Selection"}),Ze.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-green-500/10 border border-green-500/30 rounded-md",children:[e.jsx("div",{className:"flex-1",children:e.jsx("span",{className:"text-xs text-green-600 dark:text-green-400",children:Ze.length===1?`Edge ${Ze[0]} selected`:`Edges ${Ze.join(", ")} selected (Cross Dock)`})}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground hover:text-destructive",onClick:Qe,disabled:n,children:"Clear"})]}),Ze.length===1&&a&&e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full h-7 text-xs",onClick:a,disabled:c||n,children:[e.jsx(tr,{className:"w-3 h-3 mr-1"}),"Add Second Face (Cross Dock)"]})]}):c?e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-primary/10 border border-primary/30 rounded-md animate-pulse",children:[e.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-ping"}),e.jsx("span",{className:"text-xs text-primary flex-1",children:"Click a building edge in the map..."}),l&&e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:l,children:"Cancel"})]}):a?e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full h-7 text-xs",onClick:a,disabled:n,children:[e.jsx(Il,{className:"w-3 h-3 mr-1"}),"Select Dock Face"]}):null,!Ze.length&&!c&&e.jsxs("div",{className:"pt-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Or use auto-placement:"}),e.jsxs(rt,{value:t.dock_config||"single_rear",onValueChange:Ce=>s({dock_config:Ce}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs mt-1",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"single_rear",className:"text-xs",children:"Single Load (Rear)"}),e.jsx(le,{value:"single_front",className:"text-xs",children:"Single Load (Front)"}),e.jsx(le,{value:"single_left",className:"text-xs",children:"Single Load (Left)"}),e.jsx(le,{value:"single_right",className:"text-xs",children:"Single Load (Right)"}),e.jsx(le,{value:"cross_dock",className:"text-xs",children:"Cross Dock (Front & Rear)"})]})]})]})]}),e.jsxs(wi,{open:ce,onOpenChange:ae,children:[e.jsxs(Ni,{className:"flex items-center justify-between w-full p-2 rounded-md hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mf,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"End Gaps & Offsets"})]}),e.jsx(Oa,{className:`w-3.5 h-3.5 text-muted-foreground transition-transform ${ce?"rotate-180":""}`})]}),e.jsxs(ki,{className:"space-y-3 pt-2 pl-2",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Offset docks from building corners"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Left Gap (ft)"}),e.jsx(be,{type:"number",min:0,value:O??t.dock_end_gap_left_ft??0,onChange:Ce=>ft(Ce.target.value),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Right Gap (ft)"}),e.jsx(be,{type:"number",min:0,value:W??t.dock_end_gap_right_ft??0,onChange:Ce=>Fe(Ce.target.value),className:"h-7 text-xs",disabled:n})]})]})]})]}),e.jsxs(wi,{open:ie,onOpenChange:de,children:[e.jsxs(Ni,{className:"flex items-center justify-between w-full p-2 rounded-md hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yl,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Multi-Tenant Zones"}),ht.length>0&&e.jsxs(Mt,{variant:"default",className:"text-[9px] h-4",children:[ht.length," zones"]}
755)]}),e.jsx(Oa,{className:`w-3.5 h-3.5 text-muted-foreground transition-transform ${ie?"rotate-180":""}`})]}),e.jsxs(ki,{className:"space-y-3 pt-2 pl-2",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Split dock edge into zones for multi-tenant buildings"}),ht.map((Ce,Be)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background rounded border",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(be,{type:"text",value:Ce.label||`Zone ${Be+1}`,onChange:Dt=>He(Be,{label:Dt.target.value}),className:"h-6 text-[10px]",disabled:n}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"text-[10px] shrink-0",children:"Docks:"}),e.jsx(be,{type:"number",min:1,value:Ce.dock_count,onChange:Dt=>He(Be,{dock_count:parseInt(Dt.target.value)||1}),className:"h-6 w-16 text-[10px]",disabled:n})]})]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-destructive shrink-0",onClick:()=>as(Be),disabled:n,children:"×"})]},Be)),ht.length<3&&e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full h-7 text-xs",onClick:_t,disabled:n,children:[e.jsx(tr,{className:"w-3 h-3 mr-1"}),"Add Zone"]})]})]}),e.jsxs(wi,{open:ge,onOpenChange:We,children:[e.jsxs(Ni,{className:"flex items-center justify-between w-full p-2 rounded-md hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wS,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Man Doors"}),(t.dock_man_door_interval??0)>0&&e.jsxs(Mt,{variant:"default",className:"text-[9px] h-4",children:["Every ",t.dock_man_door_interval]})]}),e.jsx(Oa,{className:`w-3.5 h-3.5 text-muted-foreground transition-transform ${ge?"rotate-180":""}`})]}),e.jsxs(ki,{className:"space-y-3 pt-2 pl-2",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Insert personnel doors at regular intervals between docks"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Every N Docks"}),e.jsx(be,{type:"number",min:0,value:Z??t.dock_man_door_interval??0,onChange:Ce=>fe(Ce.target.value),className:"h-7 text-xs",placeholder:"0 = disabled",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Door Width (ft)"}),e.jsx(be,{type:"number",min:2,max:5,value:t.dock_man_door_width_ft??3,onChange:Ce=>s({dock_man_door_width_ft:parseFloat(Ce.target.value)||3}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Door Height (ft)"}),e.jsx(be,{type:"number",min:5,max:10,step:.5,value:t.dock_man_door_height_ft??7,onChange:Ce=>s({dock_man_door_height_ft:parseFloat(Ce.target.value)||7}),className:"h-7 text-xs",disabled:n})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Height (ft)"}),e.jsx(be,{type:"number",value:D??t.dock_height_ft??12,onChange:Ce=>dt(Ce.target.value),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Width (ft)"}),e.jsx(be,{type:"number",value:K??t.dock_width_ft??10,onChange:Ce=>Re(Ce.target.value),className:"h-7 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Dock Style"}),e.jsx("div",{className:"grid grid-cols-3 gap-1",children:Object.entries(yy).filter(([Ce])=>Ce!=="custom").map(([Ce,Be])=>e.jsxs(Le,{variant:(t.dock_style||"steel_gray")===Ce?"default":"outline",size:"sm",className:"h-7 px-1.5 text-[9px] flex items-center gap-1",onClick:()=>s({dock_style:Ce,dock_color:Be.color}),disabled:n,children:[e.jsx("span",{className:"w-3 h-3 rounded-sm border border-border shrink-0",style:{backgroundColor:Be.color}}),e.jsx("span",{className:"truncate",children:Be.name.split(" ")[0]})]},Ce))})]}),e.jsx(WR,{overlay:t,onUpdate:s,isUpdating:n})]})]})}function FP(t,s){if(t.length<3)return{startIdx:0,endIdx:1,bearing:0};const n=t.map(v=>[v.lng,v.lat]),a=Xn([[...n,n[0]]]),l=Yo(a),[c,u]=l.geometry.coordinates,i=[];for(let v=0;v<t.length;v++){const C=(v+1)%t.length,P=t[v],I=t[C],z=[(P.lng+I.lng)/2,(P.lat+I.lat)/2],F=Or(us([c,u]),us(z));i.push({startIdx:v,endIdx:C,midpoint:z,bearing:F})}const j={front:0,rear:180,left:-90,right:90}[s];let y=i[0],x=360;for(const v of i){let C=Math.abs(v.bearing-j);C>180&&(C=360-C),C<x&&(x=C,y=v)}return y}function sF(t,s,n=0){if(!t||t.length<3)return null;const{depth_ft:a,placement:l,trailerParkingCount:c=0,trailerSpotLength:u=53}=s,i=FP(t,l),_=t[i.startIdx],j=t[i.endIdx],y=gi(us([_.lng,_.lat]),us([j.lng,j.lat]),{units:"feet"}),x=s.width_ft||y,v=Or(us([_.lng,_.lat]),us([j.lng,j.lat])),C=t.map(ge=>[ge.lng,ge.lat]),P=Xn([[...C,C[0]]]),I=Yo(P),z=us([(_.lng+j.lng)/2,(_.lat+j.lat)/2]),F=v+90,D=On(z,.01,F,{units:"kilometers"}),X=gi(D,I,{units:"kilometers"}),K=gi(z,I,{units:"kilometers"}),te=X<K?v-90:F,J=a*.3048,H=n*.3048,O=n>0?On(us([_.lng,_.lat]),H/1e3,te,{units:"kilometers"}):us([_.lng,_.lat]),q=n>0?On(us([j.lng,j.lat]),H/1e3,te,{units:"kilometers"}):us([j.lng,j.lat]),W=O,Q=q,Z=On(Q,J/1e3,te,{units:"kilometers"}),oe=On(W,J/1e3,te,{units:"kilometers"}),ce=[W.geometry.coordinates,Q.geometry.coordinates,Z.geometry.coordinates,oe.geometry.coordinates],ae=x*a;let ie,de;if(c>0){ie=[];const ge=10,Ee=u*.3048,ve=ge*.3048,we=oe.geometry.coordinates,Ze=Z.geometry.coordinates,ke=Or(us(we),us(Ze)),ze=te+180;for(let ft=0;ft<c;ft++){const Fe=ft*ve,fe=On(us(we),Fe/1e3,ke,{units:"kilometers"}),Qe=On(fe,ve/1e3,ke,{units:"kilometers"}),ht=On(Qe,Ee/1e3,ze,{units:"kilometers"}),_t=On(fe,Ee/1e3,ze,{units:"kilometers"});ie.push([fe.geometry.coordinates,Qe.geometry.coordinates,ht.geometry.coordinates,_t.geometry.coordinates])}const Ke=c*ve,dt=On(us(we),Ke/1e3,ke,{units:"kilometers"}),Re=On(us(we),Ee/1e3,ze,{units:"kilometers"}),qt=On(dt,Ee/1e3,ze,{units:"kilometers"});de=[we,dt.geometry.coordinates,qt.geometry.coordinates,Re.geometry.coordinates]}return{courtPolygon:ce,trailerSpots:ie,concretePadPolygon:de,areaSquareFeet:Math.round(ae)}}function nF(t,s,n){if(!t||t.length<3||n<=0)return null;const a=FP(t,s),l=t[a.startIdx],c=t[a.endIdx],u=Or(us([l.lng,l.lat]),us([c.lng,c.lat])),i=t.map(te=>[te.lng,te.lat]),_=Xn([[...i,i[0]]]),j=Yo(_),y=us([(l.lng+c.lng)/2,(l.lat+c.lat)/2]),x=u+90,v=On(y,.01,x,{units:"kilometers"}),C=gi(v,j,{units:"kilometers"}),P=gi(y,j,{units:"kilometers"}),I=C<P?u-90:x,z=n*.3048,F=us([l.lng,l.lat]),D=us([c.lng,c.lat]),X=On(D,z/1e3,I,{units:"kilometers"}),K=On(F,z/1e3,I,{units:"kilometers"});return[[l.lng,l.lat],[c.lng,c.lat],X.geometry.coordinates,K.geometry.coordinates]}const aF=[{value:"rear",label:"Rear"},{value:"front",label:"Front"},{value:"left",label:"Left"},{value:"right",label:"Right"}],rF=[{value:"#64748b",label:"Asphalt Gray"},{value:"#374151",label:"Dark Asphalt"},{value:"#9ca3af",label:"Concrete"},{value:"#475569",label:"Slate"}],iF=[{value:"#ffffff",label:"White"},{value:"#fbbf24",label:"Yellow"}];function oF({overlay:t,allOverlays:s,onUpdate:n,isUpdating:a}){var Vs,ps;const{data:l=[]}=Cp(),c=s??l,u=ym(),i=pu(),_=Sp(),j=!!t.truck_court_depth_ft,[y,x]=k.useState(t.truck_court_depth_ft||135),[v,C]=k.useState(t.truck_court_width_ft||null),[P,I]=k.useState(t.truck_court_placement||"rear"),[z,F]=k.useState((t.trailer_parking_count||0)>0),[D,X]=k.useState(t.trailer_parking_count||12),[K,te]=k.useState(((Vs=t.style)==null?void 0:Vs.fillColor)||"#64748b"),[J,H]=k.useState(((ps=t.style)==null?void 0:ps.fillOpacity)||.25),[O,q]=k.useState(t.truck_court_trailer_surface||"asphalt"),[W,Q]=k.useState(!!t.truck_court_line_color),[Z,oe]=k.useState(t.truck_court_line_color||"#ffffff"),[ce,ae]=k.useState(t.truck_court_line_style||"solid"),[ie,de]=k.useState(t.dock_apron_enabled??!1),[ge,We]=k.useState(t.dock_apron_depth_ft||70),[Ee,ve]=k.useState(t.dock_apron_color||"#D1D5DB"),[we,Ze]=k.useState(t.truck_court_offset_by_apron??!1),[ke,ze]=k.useState(!1),Ke=k.useRef(null),dt=k.useRef(void 0),Re=k.useMemo(()=>c.find(nt=>
755nt.parent_overlay_id===t.id&&nt.layer_type==="dock_apron"),[c,t.id]);k.useEffect(()=>{dt.current=Re},[Re]);const qt=k.useRef(void 0),ft=k.useMemo(()=>c.find(nt=>nt.parent_overlay_id===t.id&&nt.layer_type==="truck_court"),[c,t.id]);k.useEffect(()=>{qt.current=ft},[ft]),k.useEffect(()=>{t.truck_court_depth_ft!==void 0&&x(t.truck_court_depth_ft||135),t.truck_court_placement&&I(t.truck_court_placement)},[t.truck_court_depth_ft,t.truck_court_placement]);const Fe=k.useRef(null),fe=k.useCallback(async nt=>{var bt;const ts=t.geometry;if(!ts||ts.length<3)return;const ds={depth_ft:nt.depth_ft,width_ft:nt.width_ft??void 0,placement:nt.placement,trailerParkingCount:nt.trailerParkingCount},Is=(nt.offsetByApron??we)&&ie?nt.apronDepthFt??ge:0,tn=sF(ts,ds,Is);if(!tn){Ve.error("Could not generate truck court geometry");return}const wn=tn.courtPolygon.map(([Ct,pe])=>({lat:pe,lng:Ct})),Gs=nt.color||K,Ue=nt.opacity??J,Pe=nt.showLabels??ke,je=nt.stripingColor!==void 0?nt.stripingColor:W?Z:null,Ge=nt.stripingStyle!==void 0?nt.stripingStyle:ce,De=Ge==="dashed"?"8 4":void 0;try{const Ct=qt.current,pe={geometry:wn,calculated_area_sqft:tn.areaSquareFeet,trailer_parking_count:nt.trailerParkingCount,show_area_label:Pe,show_measurements:Pe,truck_court_line_color:je,truck_court_line_style:Ge,style:{color:je||Gs,fillColor:Gs,fillOpacity:Ue,weight:je?2:1,...De?{dashArray:De}:{}}};let wt;if(Ct)await i.mutateAsync({id:Ct.id,...pe}),wt=Ct.id;else{const Zt=await u.mutateAsync({name:"Truck Court",type:"polygon",layer_type:"truck_court",parent_overlay_id:t.id,is_visible:!0,...pe});wt=(Zt==null?void 0:Zt.id)||((bt=qt.current)==null?void 0:bt.id)}if(wt){const Zt=O==="concrete"?"#D1D5DB":"#64748b",ys=nt.trailerParkingCount>0&&tn.trailerSpots&&tn.trailerSpots.length>0?tn.trailerSpots.map((es,is)=>({polygon:es,index:is})):[];await i.mutateAsync({id:wt,style:{...pe.style,trailerSpots:ys,trailerSurface:O,trailerStripingColor:je||"#ffffff",trailerStripingStyle:Ge||"solid",trailerFillColor:Zt}})}}catch(Ct){console.error("Failed to sync truck court overlay:",Ct)}},[t.geometry,t.id,K,J,we,ie,ge,ke,W,Z,ce,O,c,u,i,_]),Qe=k.useCallback(nt=>{Fe.current&&clearTimeout(Fe.current),Fe.current=setTimeout(()=>fe(nt),300)},[fe]),ht=k.useCallback(()=>({depth_ft:y,width_ft:v,placement:P,trailerParkingCount:z?D:0,color:K,opacity:J}),[y,v,P,z,D,K,J]),_t=async()=>{n({truck_court_depth_ft:135,truck_court_placement:"rear",trailer_parking_count:0}),await fe({depth_ft:135,placement:"rear",trailerParkingCount:0}),Ve.success("Truck court added")},He=async()=>{n({truck_court_depth_ft:null,truck_court_width_ft:null,truck_court_placement:null,trailer_parking_count:null,truck_court_line_color:null,truck_court_line_style:null,truck_court_trailer_surface:null,dock_apron_enabled:!1,dock_apron_depth_ft:null,dock_apron_color:null});const nt=qt.current;if(nt)try{await _.mutateAsync(nt.id)}catch(ds){console.error("Failed to delete truck court overlay:",ds)}const ts=dt.current;if(ts)try{await _.mutateAsync(ts.id)}catch(ds){console.error("Failed to delete apron overlay:",ds)}},as=nt=>{x(nt),n({truck_court_depth_ft:nt}),Qe({...ht(),depth_ft:nt})},vt=nt=>{I(nt),n({truck_court_placement:nt}),fe({...ht(),placement:nt})},Xe=nt=>{C(nt),n({truck_court_width_ft:nt}),Qe({...ht(),width_ft:nt})},Ce=nt=>{F(nt);const ts=nt?D:0;n({trailer_parking_count:ts}),fe({...ht(),trailerParkingCount:ts})},Be=nt=>{X(nt),z&&(n({trailer_parking_count:nt}),Qe({...ht(),trailerParkingCount:nt}))},Dt=nt=>{te(nt),Qe({...ht(),color:nt})},Rt=nt=>{H(nt),Qe({...ht(),opacity:nt})},zt=nt=>{q(nt),n({truck_court_trailer_surface:nt})},rs=nt=>{Q(nt);const ts=nt?Z:null,ds=nt?ce:null;n({truck_court_line_color:ts,truck_court_line_style:ds}),Qe({...ht(),stripingColor:ts,stripingStyle:ds})},_s=nt=>{oe(nt),W&&(n({truck_court_line_color:nt}),Qe({...ht(),stripingColor:nt,stripingStyle:ce}))},vs=nt=>{ae(nt),n({truck_court_line_style:nt}),W&&Qe({...ht(),stripingColor:Z,stripingStyle:nt})},$t=k.useCallback(async(nt,ts,ds)=>{const Is=t.geometry;if(!Is||Is.length<3)return;if(!nt){const Ue=dt.current;if(Ue)try{await _.mutateAsync(Ue.id)}catch(Pe){console.error("Failed to delete apron:",Pe)}return}const tn=nF(Is,P,ts);if(!tn)return;const wn=tn.map(([Ue,Pe])=>({lat:Pe,lng:Ue})),Gs=dt.current;try{Gs?await i.mutateAsync({id:Gs.id,geometry:wn,style:{color:ds,fillColor:ds,fillOpacity:.4,weight:1}}):await u.mutateAsync({name:"Dock Approach Pad",type:"polygon",geometry:wn,layer_type:"dock_apron",parent_overlay_i
755d:t.id,is_visible:!0,style:{color:ds,fillColor:ds,fillOpacity:.4,weight:1}})}catch(Ue){console.error("Failed to sync apron pad:",Ue)}},[t.geometry,t.id,P,u,i,_]),Ns=nt=>{de(nt),n({dock_apron_enabled:nt}),$t(nt,ge,Ee)},Ts=nt=>{We(nt),n({dock_apron_depth_ft:nt}),Ke.current&&clearTimeout(Ke.current),Ke.current=setTimeout(()=>{ie&&$t(!0,nt,Ee)},300)},bs=nt=>{ve(nt),n({dock_apron_color:nt}),ie&&$t(!0,ge,nt)},en=nt=>{Ze(nt),n({truck_court_offset_by_apron:nt}),Qe({...ht(),offsetByApron:nt})},Jt=y*(v||400);return j?e.jsxs("div",{className:"space-y-4 p-3 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hu,{className:"w-4 h-4 text-primary"}),e.jsx(B,{className:"text-sm font-medium",children:"Truck Court"})]}),e.jsx(Le,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:He,children:"Remove"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Court Depth"}),e.jsx(be,{type:"number",value:y,onChange:nt=>{const ts=parseInt(nt.target.value)||120;as(Math.max(60,Math.min(300,ts)))},className:"h-7 w-20 text-xs font-mono",min:60,max:300})]}),e.jsx(Ca,{value:[y],min:60,max:300,step:5,onValueChange:([nt])=>as(nt),disabled:a}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Standard: 120-185 ft for semi-truck maneuvers"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Court Width"}),e.jsx(be,{type:"number",value:v||"",onChange:nt=>{const ts=nt.target.value?parseFloat(nt.target.value):null;Xe(ts)},placeholder:"Auto",className:"h-7 w-20 text-xs"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Leave blank to auto-match building edge width"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Placement"}),e.jsx("div",{className:"flex gap-1.5 flex-wrap",children:aF.map(nt=>e.jsx(Le,{variant:P===nt.value?"default":"outline",size:"sm",className:"h-7 text-xs px-3",onClick:()=>vt(nt.value),disabled:a,children:nt.label},nt.value))})]}),e.jsxs("div",{className:"space-y-3 pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Dock Approach Pad"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Reinforced concrete pad at dock face"})]}),e.jsx(kt,{checked:ie,onCheckedChange:Ns,disabled:a})]}),ie&&e.jsxs("div",{className:"space-y-2 pl-2 border-l-2 border-primary/20",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Pad Depth"}),e.jsx(be,{type:"number",value:ge,onChange:nt=>{const ts=parseInt(nt.target.value)||30;Ts(Math.max(10,Math.min(150,ts)))},className:"h-7 w-20 text-xs font-mono",min:10,max:150})]}),e.jsx(Ca,{value:[ge],min:10,max:150,step:5,onValueChange:([nt])=>Ts(nt),disabled:a})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-[10px] shrink-0",children:"Pad Color"}),e.jsx(be,{type:"color",value:Ee,onChange:nt=>bs(nt.target.value),className:"h-6 w-10 p-0.5 cursor-pointer",disabled:a})]}),e.jsxs("div",{className:"flex items-center justify-between pt-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Court starts after pad"}),e.jsx(kt,{checked:we,onCheckedChange:en,disabled:a})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:we?`Zones: Pad (${ge}ft) → Court (${y}ft)`:"Court overlaps pad from building edge"})]})]}),e.jsxs("div",{className:"space-y-3 pt-3 border-t border-border/50",children:[e.jsx(B,{className:"text-xs font-medium",children:"Court Color"}),e.jsxs("div",{className:"flex gap-1.5 flex-wrap",children:[rF.map(nt=>e.jsx("button",{className:`w-7 h-7 rounded-md border-2 transition-all ${K===nt.value?"border-primary ring-1 ring-primary":"border-border"}`,style:{backgroundColor:nt.value},onClick:()=>Dt(nt.value),title:nt.label},nt.value)),e.jsx(be,{type:"color",value:K,onChange:nt=>
755Dt(nt.target.value),className:"w-7 h-7 p-0 border-border cursor-pointer"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Fill Opacity"}),e.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:J.toFixed(2)})]}),e.jsx(Ca,{value:[J*100],min:10,max:100,step:5,onValueChange:([nt])=>Rt(nt/100),disabled:a})]})]}),e.jsxs("div",{className:"space-y-3 pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Include Trailer Staging"}),e.jsx(kt,{checked:z,onCheckedChange:Ce,disabled:a})]}),z&&e.jsxs("div",{className:"space-y-3 pl-2 border-l-2 border-primary/20",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Trailer Spots"}),e.jsx(be,{type:"number",value:D,onChange:nt=>Be(parseInt(nt.target.value)||0),min:1,max:50,className:"h-7 w-16 text-xs"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Standard spot size: 10 × 53 ft"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Surface"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(Le,{variant:O==="asphalt"?"default":"outline",size:"sm",className:"h-7 text-xs px-3",onClick:()=>zt("asphalt"),children:"Asphalt"}),e.jsx(Le,{variant:O==="concrete"?"default":"outline",size:"sm",className:"h-7 text-xs px-3",onClick:()=>zt("concrete"),children:"Concrete"})]}),O==="concrete"&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Concrete pad rendered beneath trailer spots"})]})]})]}),e.jsxs("div",{className:"space-y-3 pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Court Striping"}),e.jsx(kt,{checked:W,onCheckedChange:rs,disabled:a})]}),W&&e.jsxs("div",{className:"space-y-2 pl-2 border-l-2 border-primary/20",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Line Color"}),e.jsx("div",{className:"flex gap-1.5",children:iF.map(nt=>e.jsx("button",{className:`w-7 h-7 rounded-md border-2 transition-all ${Z===nt.value?"border-primary ring-1 ring-primary":"border-border"}`,style:{backgroundColor:nt.value},onClick:()=>_s(nt.value),title:nt.label},nt.value))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Line Style"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(Le,{variant:ce==="solid"?"default":"outline",size:"sm",className:"h-7 text-xs px-3",onClick:()=>vs("solid"),children:"Solid"}),e.jsx(Le,{variant:ce==="dashed"?"default":"outline",size:"sm",className:"h-7 text-xs px-3",onClick:()=>vs("dashed"),children:"Dashed"})]})]})]})]}),e.jsxs("div",{className:"space-y-2 pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fo,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Show Dimensions on Map"})]}),e.jsx(kt,{checked:ke,onCheckedChange:nt=>{ze(nt);const ts=qt.current;ts&&i.mutateAsync({id:ts.id,show_area_label:nt,show_measurements:nt});const ds=dt.current;ds&&i.mutateAsync({id:ds.id,show_area_label:nt,show_measurements:nt})},disabled:a})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Display area and edge dimensions on the 2D plan"})]}),e.jsxs("div",{className:"p-2 bg-background rounded-md flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(hh,{className:"w-3 h-3"}),"Est. Court Area"]}),e.jsxs(Mt,{variant:"secondary",className:"font-mono text-xs",children:[Math.round(Jt).toLocaleString()," sf"]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hu,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(B,{className:"text-sm font-medium",children:"Truck Court"})]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"gap-1",onClick:_t,disabled:a,children:[e.jsx(tr,{className:"w-3 h-3"}),"Add"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Truck maneuvering and staging area with optional concrete approach pad."})]})}const Y_=[{value:"retention_pond",label:"Retention Pond",icon:gp,description:"Permanent water feature",color:"#3b82f6"},{value:"detention_basin",label:"Detention Basin",icon:Wm,description:"Dry basin, fills during storms",color:"#22c55e"},{value:"bioswale",label:"Bioswale",icon:Hy,description:"Vegetated drainage channel",color:"#22c55e"},{value:"underground",label:"Underground",icon:Fu,description:"Below-grade storage system",color:"#8b5cf6"},{value:"decorative_pond",label:"Decorative Pond",icon:gp,description:"Amenity w
755ater feature",color:"#06b6d4"},{value:"infiltration_bed",label:"Infiltration Bed",icon:Kc,description:"Subsurface gravel percolation",color:"#a78bfa"},{value:"rain_garden",label:"Rain Garden",icon:Hy,description:"Landscaped depression with plantings",color:"#4ade80"}],ox={retention_pond:"#3b82f6",detention_basin:"#22c55e",bioswale:"#22c55e",underground:"#8b5cf6",decorative_pond:"#06b6d4",infiltration_bed:"#a78bfa",rain_garden:"#4ade80"},Ek=[{id:"chain_link",label:"Chain Link",color:"#9ca3af"},{id:"chain_link_privacy",label:"Chain Link w/ Privacy",color:"#6b7280"},{id:"ornamental",label:"Ornamental Iron",color:"#1f2937"},{id:"wood",label:"Wood Privacy",color:"#92400e"}],Pk=[{id:"grass",label:"Grass",color:"#86efac",description:"Natural turf buffer"},{id:"gravel",label:"Gravel",color:"#a8a29e",description:"Crushed stone surface"},{id:"concrete",label:"Concrete",color:"#d4d4d4",description:"Paved walkway"}];function lF({overlay:t,onUpdate:s,isUpdating:n}){var Z,oe,ce,ae;const a=t.style||{},l=a.stormwaterConfig||{},c=a.stormwaterFencing||{enabled:!1,height_ft:6,type:"chain_link",has_barbed_wire:!1,has_gates:!0,gate_count:1,buffer_ft:5,buffer_material:"grass"},[u,i]=k.useState(l.capacity_gallons||5e4),[_,j]=k.useState(l.depth_ft||4),[y,x]=k.useState(l.type||"detention_basin"),[v,C]=k.useState(a.fillOpacity||.4);k.useEffect(()=>{var de,ge;const ie=((de=t.style)==null?void 0:de.stormwaterConfig)||{};i(ie.capacity_gallons||5e4),j(ie.depth_ft||4),x(ie.type||"detention_basin"),C(((ge=t.style)==null?void 0:ge.fillOpacity)||.4)},[t.id,t.style]);const P=ie=>{const de={...l,...ie},ge=ie.type||y,We=ox[ge]||a.color||"#3b82f6";s({style:{...a,color:We,fillColor:We,stormwaterConfig:de}})},I=ie=>{i(ie),P({capacity_gallons:ie})},z=ie=>{j(ie),P({depth_ft:ie})},F=ie=>{x(ie);const de=Y_.find(We=>We.value===ie),ge=ox[ie]||"#3b82f6";s({name:(de==null?void 0:de.label)||t.name,style:{...a,color:ge,fillColor:ge,stormwaterConfig:{...l,type:ie}}})},D=ie=>{C(ie),s({style:{...a,fillOpacity:ie}})},X=ie=>{const de={...c,...ie};s({style:{...a,stormwaterFencing:de}})},K=()=>{X({enabled:!c.enabled})},te=ie=>ie>=1e6?`${(ie/1e6).toFixed(1)}M gal`:ie>=1e3?`${(ie/1e3).toFixed(0)}K gal`:`${ie} gal`,J=t.custom_sqft||t.calculated_area_sqft||0,H=J*_,O=()=>({type:y,capacity_gallons:u,depth_ft:_,fill_opacity:v}),q=ie=>{ie.type&&F(ie.type),ie.capacity_gallons&&I(ie.capacity_gallons),ie.depth_ft&&z(ie.depth_ft),ie.fill_opacity&&D(ie.fill_opacity)},W=a.linkedDesignElementId||null,Q=ie=>{s({style:{...a,linkedDesignElementId:ie}})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Kc,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium",children:"Stormwater Feature"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Configure detention/retention properties"})]})]}),e.jsx(Bf,{elementType:"stormwater_detention",currentElementId:W,currentConfig:O(),onSelectElement:Q,onApplyConfig:q,disabled:n})]}),e.jsx(ns,{title:"Feature Type",icon:e.jsx(Wm,{className:"w-4 h-4"}),badge:e.jsx(Mt,{variant:"outline",className:"text-[10px] h-5",style:{borderColor:ox[y],color:ox[y]},children:((Z=Y_.find(ie=>ie.value===y))==null?void 0:Z.label)||"Unknown"}),defaultOpen:!0,children:e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Y_.map(ie=>{const de=ie.icon,ge=y===ie.value;return e.jsxs("button",{onClick:()=>F(ie.value),className:`p-2 rounded-lg border text-left transition-colors ${ge?"bg-blue-500/10 border-blue-500":"bg-background hover:bg-muted"}`,disabled:n,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:ie.color}}),e.jsx(de,{className:`w-4 h-4 ${ge?"text-blue-500":"text-muted-foreground"}`}),e.jsx("span",{className:"text-xs font-medium",children:ie.label})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:ie.description})]},ie.value)})})}),(y==="retention_pond"||y==="decorative_pond")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(ns,{title:"Water & Edge Options",icon:e.jsx(gp,{className:"w-4 h-4"}),defaultOpen:y==="decorative_pond",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Water Color"}
755),e.jsxs(rt,{value:t.pond_water_color||"blue",onValueChange:ie=>s({pond_water_color:ie}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"blue",className:"text-xs",children:"Blue"}),e.jsx(le,{value:"natural_green",className:"text-xs",children:"Natural Green"}),e.jsx(le,{value:"dark",className:"text-xs",children:"Dark / Reflective"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Fountain / Aerator"}),e.jsx(kt,{checked:t.pond_fountain_enabled??!1,onCheckedChange:ie=>s({pond_fountain_enabled:ie}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Edge Material"}),e.jsxs(rt,{value:t.pond_edge_material||"natural",onValueChange:ie=>s({pond_edge_material:ie}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"natural",className:"text-xs",children:"Natural Edge"}),e.jsx(le,{value:"concrete",className:"text-xs",children:"Concrete Edge"}),e.jsx(le,{value:"stone",className:"text-xs",children:"Stone Edge"})]})]})]})]})})]}),e.jsx(ks,{}),e.jsx(ns,{title:"Capacity & Dimensions",icon:e.jsx(Fo,{className:"w-4 h-4"}),badge:e.jsx(Mt,{variant:"outline",className:"text-[10px] h-5",children:te(u)}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Storage Capacity"}),e.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:te(u)})]}),e.jsx(be,{type:"number",value:u,onChange:ie=>I(parseFloat(ie.target.value)||0),className:"h-8 text-sm",disabled:n}),e.jsx("div",{className:"flex gap-1",children:[1e4,25e3,5e4,1e5].map(ie=>e.jsx(Le,{variant:u===ie?"default":"outline",size:"sm",className:"h-6 text-[10px] px-2 flex-1",onClick:()=>I(ie),disabled:n,children:te(ie).replace(" gal","")},ie))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Depth"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[_," ft"]})]}),e.jsx(Ca,{value:[_],min:2,max:15,step:.5,onValueChange:([ie])=>z(ie),disabled:n}),e.jsx("div",{className:"flex gap-1",children:[3,4,6,8,10].map(ie=>e.jsxs(Le,{variant:_===ie?"default":"outline",size:"sm",className:"h-6 text-[10px] px-2 flex-1",onClick:()=>z(ie),disabled:n,children:[ie,"ft"]},ie))})]}),J>0&&e.jsxs("div",{className:"p-2 bg-muted/50 rounded text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Surface Area:"}),e.jsxs("span",{className:"font-mono",children:[J.toLocaleString()," SF"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Volume:"}),e.jsxs("span",{className:"font-mono",children:[H.toLocaleString()," CF"]})]})]})]})}),e.jsx(ks,{}),y!=="underground"&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Perimeter Fencing",icon:e.jsx(s_,{className:"w-4 h-4"}),badge:c.enabled?e.jsxs(Mt,{variant:"default",className:"text-[10px] h-5 bg-amber-500/20 text-amber-700",children:[c.height_ft,"ft ",((oe=Ek.find(ie=>ie.id===c.type))==null?void 0:oe.label)||"Fence"]}):e.jsx(Mt,{variant:"outline",className:"text-[10px] h-5",children:"None"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between py-2 px-3 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-sm font-medium",children:"Enable Perimeter Fence"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add safety fencing around the basin"})]}),e.jsx(kt,{checked:c.enabled,onCheckedChange:K,disabled:n})]}),c.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Fence Type"}),e.jsxs(rt,{value:c.type,onValueChange:ie=>X({type:ie}),disabled:n,children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:Ek.map(ie=>e.jsx(le,{value:ie.id,className:"text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm border",style:{backgroundColor:ie.color}}),ie.label]})},ie.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Fence Height"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[c.height_ft," ft"]})]}),e.jsx(Ca,{value:[c.height_ft],min:4,max:10,step:1,onValueChange:([ie])=>X({height_ft:ie}),disabled:n}),e.jsx("div",{className:"flex gap-1",children:[4,6,8].map(ie=>e.jsxs(Le,{variant:c.height_ft===ie?"default":"outline",size:"sm",className:"h-6 text-[10px] px-2 flex-1",onClick:()=>X({height_ft:ie}),disabled:n,children:[ie,"ft"]},ie))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Buffer Distance"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[c.buffer_ft||5," ft"]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Distance from basin edge to fence"}),e.jsx(Ca,{value:[c.buffer_ft||5],min:2,max:15,step:1,onValueChange:([ie])=>X({buffer_ft:ie}),disabled:n}),e.jsx("div",{className:"flex gap-1",children:[3,5,8,10].map(ie=>e.jsxs(Le,{variant:(c.buffer_ft||5)===ie?"default":"outline",size:"sm",className:"h-6 text-[10px] px-2 flex-1",onClick:()=>X({buffer_ft:ie}),disabled:n,children:[ie,"ft"]},ie))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Buffer Material"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:Pk.map(ie=>{const de=(c.buffer_material||"grass")===ie.id;return e.jsxs("button",{onClick:()=>X({buffer_material:ie.id}),className:`p-2 rounded-lg border text-center transition-colors ${de?"bg-primary/10 border-primary":"bg-background hover:bg-muted"}`,disabled:n,children:[e.jsx("div",{className:"w-6 h-6 rounded-full mx-auto mb-1 border",style:{backgroundColor:ie.color}}),e.jsx("span",{className:"text-[10px] font-medium",children:ie.label})]},ie.id)})}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:(ce=Pk.find(ie=>ie.id===(c.buffer_material||"grass")))==null?void 0:ce.description})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-xs font-medium",children:"Security Options"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Barbed Wire Top"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Add security topper"})]}),e.jsx(kt,{checked:c.has_barbed_wire,onCheckedChange:ie=>X({has_barbed_wire:ie}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Access Gates"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"For maintenance entry"})]}),e.jsx(kt,{checked:c.has_gates,onCheckedChange:ie=>X({has_gates:ie}),disabled:n})]}),c.has_gates&&e.jsxs("div",{className:"space-y-2 pl-4 border-l-2 border-muted",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Gate Count"}),e.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:c.gate_count})]}),e.jsx("div",{className:"flex gap-1",children:[1,2,3,4].map(ie=>e.jsx(Le,{variant:c.gate_count===ie?"default":"outline",size:"sm",className:"h-6 text-[10px] px-2 flex-1",onClick:()=>X({gate_count:ie}),disabled:n,children:ie},ie))})]})]})]})]})}),e.jsx(ks,{})]}),e.jsx(ns,{title:"Labels & Dimensions",icon:e.jsx(n_,{className:"w-4 h-4"}),badge:t.show_area_label||t.show_measurements?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5 bg-blue-500/20 text-blue-700",children:[t.show_area_label&&"Area",t.show_measurements&&"Dims"].filter(
755Boolean).join(" + ")}):e.jsx(Mt,{variant:"outline",className:"text-[10px] h-5",children:"Hidden"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between py-2 px-3 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-sm font-medium",children:"Show Area Label"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display square footage on the basin"})]}),e.jsx(kt,{checked:t.show_area_label||!1,onCheckedChange:ie=>s({show_area_label:ie}),disabled:n})]}),t.show_area_label&&e.jsxs("div",{className:"space-y-2 pl-4 border-l-2 border-muted",children:[e.jsx(B,{className:"text-xs",children:"Area Unit"}),e.jsxs(rt,{value:t.area_label_unit||"auto",onValueChange:ie=>s({area_label_unit:ie}),disabled:n,children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"auto",className:"text-sm",children:"Auto (Acres/SF)"}),e.jsx(le,{value:"acres",className:"text-sm",children:"Acres Only"}),e.jsx(le,{value:"sqft",className:"text-sm",children:"Square Feet Only"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 px-3 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-sm font-medium",children:"Show Dimensions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display edge lengths on the perimeter"})]}),e.jsx(kt,{checked:t.show_measurements||!1,onCheckedChange:ie=>s({show_measurements:ie}),disabled:n})]}),J>0&&e.jsxs("div",{className:"p-3 bg-muted/30 rounded-lg border space-y-2",children:[e.jsxs(B,{className:"text-xs font-medium flex items-center gap-2",children:[e.jsx(Fo,{className:"w-3.5 h-3.5 text-muted-foreground"}),"Current Measurements"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Area:"}),e.jsxs(Mt,{variant:"secondary",className:"font-mono text-[10px]",children:[J.toLocaleString()," sf"]})]}),J>=43560&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Acres:"}),e.jsxs(Mt,{variant:"secondary",className:"font-mono text-[10px]",children:[(J/43560).toFixed(2)," ac"]})]}),t.calculated_perimeter_ft&&e.jsxs("div",{className:"flex justify-between col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Perimeter:"}),e.jsxs(Mt,{variant:"secondary",className:"font-mono text-[10px]",children:[Math.round(t.calculated_perimeter_ft).toLocaleString()," ft"]})]})]})]})]})}),e.jsx(ks,{}),e.jsx(ns,{title:"Visual Style",icon:e.jsx(C0,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Fill Opacity"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[Math.round(v*100),"%"]})]}),e.jsx(Ca,{value:[v],min:.1,max:.8,step:.05,onValueChange:([ie])=>D(ie),disabled:n})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg border",style:{backgroundColor:ox[y],opacity:v}}),e.jsxs("div",{className:"text-xs",children:[e.jsx("p",{className:"font-medium",children:(ae=Y_.find(ie=>ie.value===y))==null?void 0:ae.label}),e.jsx("p",{className:"text-muted-foreground",children:"Color auto-set by type"})]})]})]})})]})}const cF=[{id:"electric",label:"Electric",icon:Xd,color:"#eab308"},{id:"gas",label:"Gas",icon:Ff,color:"#f97316"},{id:"water",label:"Water",icon:Kc,color:"#3b82f6"},{id:"sewer",label:"Sewer",icon:t_,color:"#78716c"},{id:"telecom",label:"Telecom",icon:MS,color:"#a855f7"}],Ov={electric:"#eab308",gas:"#f97316",water:"#3b82f6",sewer:"#78716c",telecom:"#a855f7",mixed:"#6366f1"};function zP(t){return{ftPerDegLon:364e3*Math.cos(t*Math.PI/180),ftPerDegLat:364e3}}function dF(t,s,n,a,l,c,u){const i=a-s,_=n-t,j=Math.sqrt(i*i+_*_);if(j===0)return[];const y=-_/j,x=i/j,v=l/2/c,C=l/2/u;return[{lat:t+x*C,lng:s+y*v},{lat:n+x*C,lng:a+y*v},{lat:n-x*C,lng:a-y*v},{lat:t-x*C,lng:s-y*v}]}function uF(t){if(!t||t.length<4)return null;const s=t[0],n=t[1],a=t[2],l=t[3],c=Math.sqrt(Math.pow(n.lng-s.lng,2)+Math.pow(n.lat-s.lat,2)),u=Math.sqrt(Math.pow(a.lng-n.lng,2)+Math.pow(a.lat-n.lat,2)),i=(s.lat+n.lat+a.lat
755+l.lat)/4,{ftPerDegLon:_,ftPerDegLat:j}=zP(i);let y,x,v,C,P;c>u?(y=(s.lat+l.lat)/2,x=(s.lng+l.lng)/2,v=(n.lat+a.lat)/2,C=(n.lng+a.lng)/2,P=c*_):(y=(s.lat+n.lat)/2,x=(s.lng+n.lng)/2,v=(a.lat+l.lat)/2,C=(a.lng+l.lng)/2,P=u*_);const I=(C-x)*_,z=(v-y)*j;return P=Math.sqrt(I*I+z*z),{startLat:y,startLng:x,endLat:v,endLng:C,lengthFt:P}}function hF({overlay:t,onUpdate:s,isUpdating:n}){const a=t.style||{},l=a.corridorConfig||{},[c,u]=k.useState(l.width_ft||20),[i,_]=k.useState(100),[j,y]=k.useState(l.utility_types||["electric"]),[x,v]=k.useState(l.is_underground??!0),C=k.useMemo(()=>{const z=t.geometry;return uF(z)},[t.geometry]);k.useEffect(()=>{var F;const z=((F=t.style)==null?void 0:F.corridorConfig)||{};u(z.width_ft||20),y(z.utility_types||["electric"]),v(z.is_underground??!0),C&&_(Math.round(C.lengthFt))},[t.id,t.style,C]);const P=z=>{const F={...l,...z},D=z.utility_types||j;let X=Ov.mixed;D.length===1&&(X=Ov[D[0]]||Ov.mixed);const K=z.is_underground??x,te={...a,color:X,fillColor:X,fillOpacity:K?.3:.5,dashArray:K?"5, 5":void 0,corridorConfig:F};if((z.width_ft||z.length_ft)&&C){const J=z.width_ft||c,H=z.length_ft||i,O=C.lengthFt,{ftPerDegLon:q,ftPerDegLat:W}=zP(C.startLat);let Q=C.endLat,Z=C.endLng;if(z.length_ft&&O>0){const ce=H/O,ae=C.endLng-C.startLng,ie=C.endLat-C.startLat;Z=C.startLng+ae*ce,Q=C.startLat+ie*ce}const oe=dF(C.startLat,C.startLng,Q,Z,J,q,W);if(oe.length>0){s({geometry:oe,style:te});return}}s({style:te})},I=z=>{const F=j.includes(z)?j.filter(D=>D!==z):[...j,z];F.length!==0&&(y(F),P({utility_types:F}))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs font-medium",children:"Utility Types"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:cF.map(z=>{const F=z.icon,D=j.includes(z.id);return e.jsxs("div",{className:fs("flex items-center gap-2 p-2 rounded-md border cursor-pointer transition-colors",D?"bg-primary/10 border-primary":"hover:bg-muted"),onClick:()=>I(z.id),children:[e.jsx(Ux,{checked:D,className:"pointer-events-none"}),e.jsx(F,{className:"w-4 h-4",style:{color:z.color}}),e.jsx("span",{className:"text-sm",children:z.label})]},z.id)})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 px-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-sm",children:"Underground Installation"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Utilities run below grade (dashed line)"})]}),e.jsx(kt,{checked:x,onCheckedChange:z=>{v(z),P({is_underground:z})},disabled:n})]}),e.jsxs("div",{className:"space-y-4 pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Fo,{className:"w-4 h-4"}),e.jsx("span",{children:"Dimensions"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Corridor Width"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[c," ft"]})]}),e.jsx(Ca,{value:[c],min:5,max:50,step:5,onValueChange:([z])=>{u(z)},onValueCommit:([z])=>{P({width_ft:z})},disabled:n}),e.jsx("div",{className:"flex gap-1",children:[10,15,20,30].map(z=>e.jsxs(Le,{variant:c===z?"default":"outline",size:"sm",className:"h-6 text-[10px] px-2 flex-1",onClick:()=>{u(z),P({width_ft:z})},disabled:n,children:[z,"ft"]},z))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-xs flex items-center gap-1",children:[e.jsx(If,{className:"w-3 h-3"}),"Corridor Length"]}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[i," ft"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{type:"number",value:i,onChange:z=>_(parseFloat(z.target.value)||50),onBlur:z=>{const F=parseFloat(z.target.value)||50;P({length_ft:F})},className:"h-8 text-sm",min:10,max:2e3,disabled:n}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"ft"})]}),e.jsx("div",{className:"flex gap-1",children:[100,200,500,1e3].map(z=>e.jsxs(Le,{variant:Math.abs(i-z)<10?"default":"outline",size:"sm",className:"h-6 text-[10px] px-2 flex-1",onClick:()=>{_(z),P({length_ft:z})},disabled:n,children:[z,"ft"]},z))})]}),t.calculated_area_sqft&&e.jsx("div",{className:"p-2 bg-muted/50 rounded text-xs",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Area:"}),e.jsxs("span",{className:"font-mono",children:[Math.round(t.calculated_area_sqft).toLocaleStr
755ing()," SF"]})]})})]}),e.jsxs("div",{className:"p-2 bg-primary/5 border border-primary/20 rounded-lg text-xs text-muted-foreground",children:[e.jsx(lm,{className:"w-4 h-4 inline mr-1 text-primary"}),"Drag the corridor on the map to reposition. Use Move/Rotate/Scale tools for precise adjustments."]})]})}const mF={landscape_buffer:"landscape_buffer",fencing:"perimeter_fencing",fire_lane:"fire_lane",easement:"easement",hardscape:"hardscape",lighting:"site_lighting",retaining_wall:"retaining_wall",erosion_control:"erosion_control",site_amenity:"site_amenity",grading:"grading",utility_corridor:"utility_corridor",monument_signage:"monument_signage",entry_point:"entry_point"},fF={landscape_buffer:{icon:e.jsx(Bx,{className:"w-5 h-5 text-green-500"}),title:"Landscape Buffer",description:"Perimeter screening and landscape areas",color:"green",fields:["width","type","density","tree_species"]},fencing:{icon:e.jsx(s_,{className:"w-5 h-5 text-slate-500"}),title:"Perimeter Fencing",description:"Security and boundary fencing",color:"slate",fields:["height","type","material","barbed_wire"]},fire_lane:{icon:e.jsx(uo,{className:"w-5 h-5 text-red-500"}),title:"Fire Lane",description:"Emergency vehicle access route",color:"red",fields:["width","surface_type","striping"]},easement:{icon:e.jsx(q3,{className:"w-5 h-5 text-amber-500"}),title:"Easement",description:"Utility or access easement",color:"amber",fields:["width","easement_type","owner"]},hardscape:{icon:e.jsx(Il,{className:"w-5 h-5 text-stone-500"}),title:"Hardscape / Paving",description:"Paved surfaces and hardscaping",color:"stone",fields:["material","pattern","color"]},lighting:{icon:e.jsx(gh,{className:"w-5 h-5 text-yellow-500"}),title:"Site Lighting",description:"Pole and area lighting zones",color:"yellow",fields:["pole_height","spacing","type"]},retaining_wall:{icon:e.jsx(gS,{className:"w-5 h-5 text-stone-600"}),title:"Retaining Wall",description:"Grade change retention structure",color:"stone",fields:["height","material","type"]},erosion_control:{icon:e.jsx(ho,{className:"w-5 h-5 text-orange-500"}),title:"Erosion Control",description:"Silt fence and erosion control measures",color:"orange",fields:["type","temporary"]},site_amenity:{icon:e.jsx(Nf,{className:"w-5 h-5 text-purple-500"}),title:"Site Amenity",description:"Benches, outdoor furniture, features",color:"purple",fields:["amenity_type","quantity"]},grading:{icon:e.jsx(Rh,{className:"w-5 h-5 text-amber-600"}),title:"Grading / Earthwork",description:"Cut and fill zones",color:"amber",fields:["cut_fill_type","volume"]},utility_corridor:{icon:e.jsx(lm,{className:"w-5 h-5 text-indigo-500"}),title:"Utility Corridor",description:"Underground or overhead utility paths",color:"indigo",fields:["utility_type","width","underground"]},monument_signage:{icon:e.jsx(Da,{className:"w-5 h-5 text-indigo-500"}),title:"Monument Signage",description:"Entry and wayfinding signage",color:"indigo",fields:["sign_type","height","width"]},entry_point:{icon:e.jsx(uo,{className:"w-5 h-5 text-teal-500"}),title:"Entry Point",description:"Site access and entry location",color:"teal",fields:["entry_type","lanes"]}},pF=[{value:"perimeter_screen",label:"Perimeter Screen"},{value:"setback_landscape",label:"Setback Landscape"},{value:"tree_line",label:"Tree Line"},{value:"bioswale",label:"Bioswale"}],Tk=[{value:"chain_link",label:"Chain Link",color:"#9ca3af"},{value:"wrought_iron",label:"Wrought Iron",color:"#1f2937"},{value:"privacy",label:"Privacy",color:"#78716c"},{value:"security",label:"Security",color:"#374151"},{value:"decorative",label:"Decorative",color:"#d4a574"}],gF=[{value:"utility",label:"Utility Easement"},{value:"drainage",label:"Drainage Easement"},{value:"access",label:"Access Easement"},{value:"conservation",label:"Conservation Easement"}],xF=[{value:"concrete",label:"Concrete"},{value:"asphalt",label:"Asphalt"},{value:"pavers",label:"Pavers"},{value:"gravel",label:"Gravel"},{value:"decomposed_granite",label:"Decomposed Granite"}],_F=[{value:"deciduous",label:"Deciduous",icon:"🌳"},{value:"evergreen",label:"Evergreen",icon:"🌲"},{value:"palm",label:"Palm",icon:"🌴"},{value:"shrub",label:"Shrub",icon:"🌿"}];function yF({overlay:t,onUpdate:s,isUpdating:n,elementType:a}){const l=fF[a],c=t.style||{},u=c.elementConfig||{},[i,_]=k.useState(u.width_ft||20),[j,y]=k.useState(u.height_ft||6),[x,v]=k.useState(u.type||""),[C,P]=k.useState(c.fillOpacity||.4),[I,z]=k.useState(u.tree_spacing_ft||25),[F,D]=k.useState(u.tree_species||"deciduous"),[X,K]=k.useState(u.has_barbed_wire||!1),[te,J]=k.useState(u.owner||"");k.useEffect(()=>{var ie,de;const ae=((ie=t.style)==null?void 0:ie.elementConfig)||{};_(ae.width_ft||20),y(ae.height_ft||6),v(ae.type||H()),P(((de=t.style)==null?void 0:de.fillOpacity)||.4),z(ae.tree_spacing_ft||25),D(ae.tree_species||"deciduous"),K(ae.has_barbed_wire||!1),J(ae.owner||"")},[t.id,t.style]);const H=()=>{switch(a){case"landscape_buffer":return"perimeter_screen";case"fencing":return"chain_link";case"easement":return"utility";case"hardscape":return"concrete";default:return""}},O=ae=>{const ie={...u,...ae};s({style:{...c,elementConfig:ie}})},q=ae=>{P(ae),s({style:{...c,fillOpacity:ae}})};if(!l)return e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ho,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"Unknown element type"})]});const W=()=>({type:x,width_ft:i,height_ft:j,fill_opacity:C,tree_spacing_ft:I,tree_species:F,has_barbed_wire:X,owner:te}),Q=ae=>{const ie={};ae.type&&(v(ae.type),ie.type=ae.type),ae.width_ft&&(_(ae.width_ft),ie.width_ft=ae.width_ft),ae.height_ft&&(y(ae.height_ft),ie.height_ft=ae.height_ft),ae.tree_spacing_ft&&(z(ae.tree_spacing_ft),ie.tree_spacing_ft=ae.tree_spacing_ft),ae.tree_species&&(D(ae.tree_species),ie.tree_species=ae.tree_species),ae.has_barbed_wire!==void 0&&(K(ae.has_barbed_wire),ie.has_barbed_wire=ae.has_barbed_wire),ae.owner&&(J(ae.owner),ie.owner=ae.owner),ae.fill_opacity&&P(ae.fill_opacity),O(ie),ae.f
755ill_opacity&&q(ae.fill_opacity)},Z=mF[a],oe=c.linkedDesignElementId||null,ce=ae=>{s({style:{...c,linkedDesignElementId:ae}})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[l.icon,e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium",children:l.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.description})]})]}),Z&&e.jsx(Bf,{elementType:Z,currentElementId:oe,currentConfig:W(),onSelectElement:ce,onApplyConfig:Q,disabled:n})]}),e.jsx(ns,{title:"Configuration",icon:e.jsx(Da,{className:"w-4 h-4"}),badge:x?e.jsx(Mt,{variant:"outline",className:"text-[10px] h-5",children:x.replace(/_/g," ")}):null,defaultOpen:!0,children:e.jsxs("div",{className:"space-y-4",children:[a==="landscape_buffer"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Buffer Type"}),e.jsxs(rt,{value:x,onValueChange:ae=>{v(ae),O({type:ae})},children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{placeholder:"Select type"})}),e.jsx(ot,{children:pF.map(ae=>e.jsx(le,{value:ae.value,className:"text-xs",children:ae.label},ae.value))})]})]}),x==="tree_line"&&e.jsxs("div",{className:"p-3 bg-primary/5 rounded-lg border border-primary/20 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qy,{className:"w-4 h-4 text-green-500"}),e.jsx(B,{className:"text-sm font-medium",children:"Tree Settings"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Spacing"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(be,{type:"number",value:I,onChange:ae=>{const ie=parseFloat(ae.target.value)||25;z(ie),O({tree_spacing_ft:ie})},className:"h-7 text-xs",min:10,max:100,disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"ft"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Species"}),e.jsxs(rt,{value:F,onValueChange:ae=>{D(ae),O({tree_species:ae})},children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:_F.map(ae=>e.jsx(le,{value:ae.value,className:"text-xs",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{children:ae.icon}),e.jsx("span",{children:ae.label})]})},ae.value))})]})]})]})]})]}),a==="fencing"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Fence Type"}),e.jsxs(rt,{value:x,onValueChange:ae=>{v(ae);const ie=Tk.find(de=>de.value===ae);O({type:ae,color:ie==null?void 0:ie.color})},children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{placeholder:"Select type"})}),e.jsx(ot,{children:Tk.map(ae=>e.jsx(le,{value:ae.value,className:"text-xs",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm border",style:{backgroundColor:ae.color}}),ae.label]})},ae.value))})]})]}),(x==="chain_link"||x==="security")&&e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Barbed Wire Top"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Security enhancement"})]}),e.jsx(kt,{checked:X,onCheckedChange:ae=>{K(ae),O({has_barbed_wire:ae})},disabled:n})]})]}),a==="easement"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Easement Type"}),e.jsxs(rt,{value:x,onValueChange:ae=>{v(ae),O({type:ae})},children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{placeholder:"Select type"})}),e.jsx(ot,{children:gF.map(ae=>e.jsx(le,{value:ae.value,className:"text-xs",children:ae.label},ae.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Owner/Holder"}),e.jsx(be,{value:te,onChange:ae=>{J(ae.target.value),O({owner:ae.target.value})},placeholder:"e.g., City of Dallas, TXU Energy",className:"h-8 text-xs",disabled:n})]})]}),a==="hardscape"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Material"}),e.jsxs(rt,{value:x,onValueChange:ae=>{v(ae),O({type:ae})},children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{placeholder:"Select material"})}),e.jsx(ot,{children:xF.map(ae=>e.jsx(le,{value:ae.value,className:"text-xs",children:ae.label},ae.value))})]})]}),a==="utility_corridor"&&e.jsx(hF,{overlay:t,onUpdate:s,isUpdating:n})]})}),e.jsx(ks,{}),e.jsx(ns,{title:"Dimensions",icon:e.jsx(Fo,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-4",children:[l.fields.includes("width")&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Width"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[i," ft"]})]}),e.jsx(Ca,{value:[i],min:5,max:100,step:5,onValueChange:([ae])=>{_(ae),O({width_ft:ae})},disabled:n}),e.jsx("div",{className:"flex gap-1",children:[10,15,20,30,50].map(ae=>e.jsxs(Le,{variant:i===ae?"default":"outline",size:"sm",className:"h-6 text-[10px] px-2 flex-1",onClick:()=>{_(ae),O({width_ft:ae})},disabled:n,children:[ae,"ft"]},ae))})]}),l.fields.includes("height")&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Height"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[j," ft"]})]}),e.jsx(Ca,{value:[j],min:3,max:12,step:1,onValueChange:([ae])=>{y(ae),O({height_ft:ae})},disabled:n}),e.jsx("div",{className:"flex gap-1",children:[4,6,8,10].map(ae=>e.jsxs(Le,{variant:j===ae?"default":"outline",size:"sm",className:"h-6 text-[10px] px-2 flex-1",onClick:()=>{y(ae),O({height_ft:ae})},disabled:n,children:[ae,"ft"]},ae))})]}),t.calculated_area_sqft&&e.jsxs("div",{className:"p-2 bg-muted/50 rounded text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Area:"}),e.jsxs("span",{className:"font-mono",children:[Math.round(t.calculated_area_sqft).toLocaleStr
755ing()," SF"]})]}),t.calculated_area_acres&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Acres:"}),e.jsxs("span",{className:"font-mono",children:[t.calculated_area_acres.toFixed(2)," AC"]})]})]})]})}),e.jsx(ks,{}),e.jsx(ns,{title:"Visual Style",icon:e.jsx(C0,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Fill Opacity"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[Math.round(C*100),"%"]})]}),e.jsx(Ca,{value:[C],min:.1,max:.8,step:.05,onValueChange:([ae])=>q(ae),disabled:n})]})})})]})}const OP=()=>fu({queryKey:["retailer-logos"],queryFn:async()=>{const{data:t,error:s}=await Fs.from("retailer_logos").select("*").order("name");if(s)throw s;return t}}),MH=()=>{const t=lc();return md({mutationFn:async s=>{const{data:n,error:a}=await Fs.from("retailer_logos").insert({name:s.name,logo_url:s.logo_url,category:s.category||"general",is_preset:!1}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["retailer-logos"]})}})},IH=()=>{const t=lc();return md({mutationFn:async s=>{const{error:n}=await Fs.from("retailer_logos").delete().eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["retailer-logos"]})}})},AH=()=>{const t=lc();return md({mutationFn:async({id:s,name:n,category:a,logo_url:l})=>{const c={};n!==void 0&&(c.name=n),a!==void 0&&(c.category=a),l!==void 0&&(c.logo_url=l);const{data:u,error:i}=await Fs.from("retailer_logos").update(c).eq("id",s).select().single();if(i)throw i;return u},onSuccess:()=>{t.invalidateQueries({queryKey:["retailer-logos"]})}})},vF=[{id:"arial",label:"Arial"},{id:"helvetica",label:"Helvetica"},{id:"times",label:"Times New Roman"},{id:"garamond",label:"Garamond"},{id:"futura",label:"Futura"},{id:"impact",label:"Impact"},{id:"copperplate",label:"Copperplate"},{id:"custom",label:"Custom"}],Bv=[{id:"wall_logo",label:"Wall Logo",icon:Zd,description:"Logo placed directly on the building wall"},{id:"channel_letters",label:"Channel Letters",icon:ug,description:"Individual 3D letters mounted to building"},{id:"box_sign",label:"Box Sign",icon:Il,description:"Illuminated cabinet sign with face graphics"},{id:"blade_sign",label:"Blade Sign",icon:Rb,description:"Projecting sign perpendicular to building"},{id:"awning_sign",label:"Awning Sign",icon:NS,description:"Graphics applied to awning/canopy"},{id:"projecting_sign",label:"Projecting Sign",icon:Rb,description:"Double-sided sign extending from wall"},{id:"canopy_sign",label:"Canopy Sign",icon:Sc,description:"Sign mounted on or under canopy fascia"}],bF=[{id:"building_edge",label:"Building Edge/Wall"},{id:"above_door",label:"Above Storefront Door"},{id:"storefront_fascia",label:"Storefront Fascia"}],jF=[{id:"front_lit",label:"Front Lit"},{id:"back_lit",label:"Back Lit"},{id:"halo_lit",label:"Halo Lit"},{id:"neon",label:"Neon/LED Neon"}],Lk={wall_logo:{width:6,height:6,mounting:12},channel_letters:{width:12,height:2,mounting:14},box_sign:{width:8,height:4,mounting:12},blade_sign:{width:3,height:4,mounting:10},awning_sign:{width:6,height:2,mounting:9},projecting_sign:{width:4,height:3,mounting:12},canopy_sign:{width:10,height:1.5,mounting:8}},Mk=["Front","Right","Rear","Left"];function wF({overlay:t,onUpdate:s,edgeCount:n=4}){const a=t.style||{},l=a.building_signs||[],[c,u]=k.useState(null),[i,_]=k.useState(null),[j,y]=k.useState(null),x=k.useRef(null),[v,C]=k.useState(null),{data:P=[]}=OP(),I=J=>{s({style:{...a,building_signs:J}})},z=(J="channel_letters")=>{const H=Bv.find(W=>W.id===J),O=Lk[J],q={id:crypto.randomUUID(),name:`${(H==null?void 0:H.label)||"Sign"} ${l.filter(W=>W.type===J).length+1}`,type:J,placement:"building_edge",edge_index:0,width_ft:O.width,height_ft:O.height,mounting_height_ft:O.mounting,illuminated:J!=="awning_sign",illumination_type:"front_lit",background_color:"#1a1a2e",letter_color:"#ffffff"};I([...l,q]),u(q.id)},F=(J,H)=>{I(l.map(O=>O.id===J?{...O,...H}:O))},D=J=>{I(l.filter(H=>H.id!==J)),c===J&&u(null)},X=J=>{const H=Bv.find(O=>O.id===J);return H?H.icon:ug},K=J=>J<Mk.length?Mk[J]:`Edge ${J+1}`,te=async J=>{var O,q;const H=(O=J.target.files)==null?void 0:O[0];if(!(!H||!v)){y(v);try{const W=((q=H.name.split(".").pop())==null?void 0:q.toLowerCase())||"png",Q=`signage-logos/${crypto.randomUUID()}.${W}`,{error:Z}=await Fs.storage.from("development-files").upload(Q,H,{contentType:H.type});if(Z)throw Z;const{data:{publicUrl:oe}}=Fs.storage.from("development-files").getPublicUrl(Q);F(v,{logo_id:"custom",logo_url:oe,logo_name:H.name.replace(/\.[^/.]+$/,"")}),_(null)}catch(W){console.error("Logo upload failed:",W)}finally{y(null),C(null),x.current&&(x.current.value="")}}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("input",{ref:x,type:"file",accept:"image/*",className:"hidden",onChange:te}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add signage to building facades, above doors, or on storefronts."}),l.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm border border-dashed rounded-lg",children:[e.jsx(ug,{className:"w-6 h-6 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-xs",children:"No signage added yet"})]}):e.jsx("div",{className:"space-y-2",children:l.map(J=>{const H=X(J.type),O=c===J.id;return e.jsxs("div",{className:"border rounded-lg bg-muted/30 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>u(O?null:J.id),children:[e.jsx(H,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-xs font-medium flex-1 truncate",children:J.name}),e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:[J.width_ft,"′ × ",J.height_ft,"′"]}),J.illuminated&&e.jsx(gh,{className:"w-3 h-3 text-yellow-500"}),O?e.jsx(Cc,{className:"w-3.5 h-3.5 text-muted-foreground"}):e.jsx(Oa,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:q=>{q.stopPropagation(),D(J.id)},children:e.jsx(wr,{className:"w-3 h-3 text-destructive"})})]}),O&&e.jsxs("div",{className:"p-3 space-y-3 border-t bg-muted/50",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Sign Type"}),e.jsxs(rt,{value:J.type,onValueChange:q=>{const W=Lk[q];F(J.id,{type:q,width_ft:W.width,height_ft:W.height,mounting_height_ft:W.mounting})},children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:Bv.map(q=>{const W=q.icon;return e.jsx(le,{value:q.id,className:"text-xs",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:q.label})]})},q.id)})})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Placement"}),e.jsxs(rt,{value:J.placement,onValueChange:q=>F(J.id,{placement:q}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:bF.map(q=>e.jsx(le,{value:q.id,className:"text-xs",children:q.label}
755,q.id))})]})]})]}),J.placement==="building_edge"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Building Edge"}),e.jsxs(rt,{value:String(J.edge_index??0),onValueChange:q=>F(J.id,{edge_index:parseInt(q,10)}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:Array.from({length:n},(q,W)=>e.jsx(le,{value:String(W),className:"text-xs",children:K(W)},W))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-xs flex items-center gap-1.5",children:[e.jsx(ji,{className:"w-3.5 h-3.5"}),"Position Along Edge"]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round((J.edge_position_t??.5)*100),"%"]})]}),e.jsx(Ca,{value:[(J.edge_position_t??.5)*100],onValueChange:q=>F(J.id,{edge_position_t:q[0]/100}),min:0,max:100,step:1,className:"w-full"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Le,{variant:"outline",size:"sm",className:"h-6 text-[10px] flex-1",onClick:()=>F(J.id,{edge_position_t:.15}),children:"Start"}),e.jsx(Le,{variant:"outline",size:"sm",className:"h-6 text-[10px] flex-1",onClick:()=>F(J.id,{edge_position_t:.5}),children:"Center"}),e.jsx(Le,{variant:"outline",size:"sm",className:"h-6 text-[10px] flex-1",onClick:()=>F(J.id,{edge_position_t:.85}),children:"End"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Width (ft)"}),e.jsx(be,{type:"number",value:J.width_ft,onChange:q=>F(J.id,{width_ft:parseFloat(q.target.value)||0}),className:"h-7 text-xs",min:1,max:50})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Height (ft)"}),e.jsx(be,{type:"number",value:J.height_ft,onChange:q=>F(J.id,{height_ft:parseFloat(q.target.value)||0}),className:"h-7 text-xs",min:.5,max:20})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Mount (ft)"}),e.jsx(be,{type:"number",value:J.mounting_height_ft,onChange:q=>F(J.id,{mounting_height_ft:parseFloat(q.target.value)||0}),className:"h-7 text-xs",min:6,max:50})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Text Content"}),e.jsx(be,{value:J.text_content||"",onChange:q=>F(J.id,{text_content:q.target.value}),className:"h-7 text-xs",placeholder:"COMPANY NAME"})]}),(J.type==="box_sign"||J.type==="wall_logo")&&e.jsxs("div",{className:"space-y-1.5 pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-xs flex items-center gap-1.5",children:[e.jsx(Zd,{className:"w-3.5 h-3.5"}),"Tenant Logo"]}),J.logo_url&&e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>F(J.id,{logo_id:void 0,logo_url:void 0,logo_name:void 0}),children:e.jsx(ja,{className:"w-3 h-3"})})]}),J.logo_url?e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background rounded border",children:[e.jsx("img",{src:J.logo_url,alt:J.logo_name||"Logo",className:"w-8 h-8 object-contain"}),e.jsx("span",{className:"text-xs truncate flex-1",children:J.logo_name||"Selected Logo"})]}):i===J.id?e.jsxs("div",{className:"border rounded-lg bg-background",children:[e.jsxs("div",{className:"p-2 border-b flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium",children:"Select Logo"}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>_(null),children:e.jsx(ja,{className:"w-3 h-3"})})]}),e.jsx("div",{className:"px-2 pt-2",children:e.jsx(Le,{variant:"outline",size:"sm",className:"w-full h-7 text-xs mb-2",disabled:j===J.id,onClick:()=>{var q;C(J.id),(q=x.current)==null||q.click()},children:j===J.id?e.jsx("span",{className:"text-xs",children:"Uploading…"}):e.jsxs(e.Fragment,{children:[e.jsx(tr,{className:"w-3 h-3 mr-1"}),"Upload Custom Logo"]})})}),e.jsx(Xc,{className:"h-[150px]",children:e.jsx("div",{className:"grid grid-cols-4 gap-1.5 p-2",children:P.map(q=>e.jsx("button",{className:"p-1.5 border rounded hover:bg-muted/50 transition-colors",onClick:()=>{F(J.id,{logo_id:q.id,logo_url:q.logo_url,logo_name:q.name}),_(null)},title:q.name,children:e.jsx("img",{src:q.logo_url,alt:q.name,className:"w-8 h-8 object-contain mx-auto"})},q.id))})})]}):e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full h-7 text-xs",onClick:()=>_(J.id),children:[e.jsx(Zd,{className:"w-3.5 h-3.5 mr-1.5"}),"Add Tenant Logo"]})]}),J.type==="channel_letters"&&e.jsxs("div",{className:"space-y-3 pt-2 border-t",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Font"}),e.jsxs(rt,{value:J.font_family||"arial",onValueChange:q=>F(J.id,{font_family:q}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:vF.map(q=>e.jsx(le,{value:q.id,className:"text-xs",children:q.label}
755,q.id))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Letter Color"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(be,{type:"color",value:J.letter_color,onChange:q=>F(J.id,{letter_color:q.target.value}),className:"h-7 w-8 p-0.5 cursor-pointer"}),e.jsx(be,{value:J.letter_color,onChange:q=>F(J.id,{letter_color:q.target.value}),className:"h-7 text-xs font-mono flex-1"})]})]})]}),J.type!=="channel_letters"&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Background"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(be,{type:"color",value:J.background_color,onChange:q=>F(J.id,{background_color:q.target.value}),className:"h-7 w-8 p-0.5 cursor-pointer"}),e.jsx(be,{value:J.background_color,onChange:q=>F(J.id,{background_color:q.target.value}),className:"h-7 text-xs font-mono flex-1"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Letters"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(be,{type:"color",value:J.letter_color,onChange:q=>F(J.id,{letter_color:q.target.value}),className:"h-7 w-8 p-0.5 cursor-pointer"}),e.jsx(be,{value:J.letter_color,onChange:q=>F(J.id,{letter_color:q.target.value}),className:"h-7 text-xs font-mono flex-1"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gh,{className:"w-3.5 h-3.5 text-yellow-500"}),e.jsx(B,{className:"text-xs",children:"Illuminated"})]}),e.jsx(kt,{checked:J.illuminated,onCheckedChange:q=>F(J.id,{illuminated:q})})]}),J.illuminated&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Illumination Type"}),e.jsxs(rt,{value:J.illumination_type||"front_lit",onValueChange:q=>F(J.id,{illumination_type:q}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:jF.map(q=>e.jsx(le,{value:q.id,className:"text-xs",children:q.label},q.id))})]})]})]})]},J.id)})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"h-auto py-2",onClick:()=>z("wall_logo"),children:[e.jsx(Zd,{className:"w-4 h-4 mr-1.5"}),e.jsx("span",{className:"text-xs",children:"Wall Logo"})]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"h-auto py-2",onClick:()=>z("channel_letters"),children:[e.jsx(ug,{className:"w-4 h-4 mr-1.5"}),e.jsx("span",{className:"text-xs",children:"Channel Letters"})]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"h-auto py-2",onClick:()=>z("box_sign"),children:[e.jsx(Il,{className:"w-4 h-4 mr-1.5"}),e.jsx("span",{className:"text-xs",children:"Box Sign"})]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"h-auto py-2",onClick:()=>z("blade_sign"),children:[e.jsx(Rb,{className:"w-4 h-4 mr-1.5"}),e.jsx("span",{className:"text-xs",children:"Blade Sign"})]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"h-auto py-2",onClick:()=>z("canopy_sign"),children:[e.jsx(Sc,{className:"w-4 h-4 mr-1.5"}),e.jsx("span",{className:"text-xs",children:"Canopy Sign"})]})]}),l.length>0&&e.jsx("div",{className:"text-xs text-muted-foreground pt-2 border-t",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{children:[l.length," sign",l.length!==1?"s":""]}),e.jsxs("span",{children:[l.filter(J=>J.illuminated).length," illuminated"]})]})})]})}const NF=[{value:"stone",label:"Stone"},{value:"brick",label:"Brick"},{value:"cmu",label:"CMU"},{value:"tile",label:"Tile"},{value:"eifs",label:"EIFS / Stucco"},{value:"metal_panel",label:"Metal Panel"},{value:"wood_accent",label:"Wood-Look Accents"},{value:"stone_veneer",label:"Stone Veneer"}],Ik=["Front","Rear","Side 1","Side 2"],$v={wainscot_enabled:!1,wainscot_height_ft:4,wainscot_color:"#78716c",wainscot_material:"stone",accent_bands:[],cornice_enabled:!1,cornice_depth_ft:1,cornice_height_ft:1.5,cornice_color:"#374151",color_split_enabled:!1,color_split_height_ft:10,upper_color:"#e5e7eb",lower_color:"#78716c",pilasters:[]}
755,kF=[{id:"retail_center",name:"Retail Center",config:{wainscot_enabled:!0,wainscot_height_ft:4,wainscot_color:"#78716c",wainscot_material:"stone",accent_bands:[{height_ft:14,thickness_ft:1,color:"#b91c1c"}],cornice_enabled:!0,cornice_depth_ft:1.5,cornice_height_ft:1.5,cornice_color:"#374151",color_split_enabled:!1,pilasters:[{edgeIndex:0,positionPct:0,widthFt:2,depthFt:1.5,heightMode:"full"},{edgeIndex:0,positionPct:33,widthFt:2,depthFt:1.5,heightMode:"full"},{edgeIndex:0,positionPct:67,widthFt:2,depthFt:1.5,heightMode:"full"},{edgeIndex:0,positionPct:100,widthFt:2,depthFt:1.5,heightMode:"full"}]}},{id:"strip_mall",name:"Strip Mall",config:{wainscot_enabled:!0,wainscot_height_ft:3,wainscot_color:"#92400e",wainscot_material:"brick",accent_bands:[{height_ft:12,thickness_ft:.5,color:"#1e40af"}],cornice_enabled:!0,cornice_depth_ft:1,cornice_height_ft:1,cornice_color:"#374151",color_split_enabled:!1,pilasters:[{edgeIndex:0,positionPct:25,widthFt:1.5,depthFt:1,heightMode:"full"},{edgeIndex:0,positionPct:50,widthFt:1.5,depthFt:1,heightMode:"full"},{edgeIndex:0,positionPct:75,widthFt:1.5,depthFt:1,heightMode:"full"}]}},{id:"big_box",name:"Big Box",config:{wainscot_enabled:!0,wainscot_height_ft:8,wainscot_color:"#6b7280",wainscot_material:"cmu",accent_bands:[],cornice_enabled:!0,cornice_depth_ft:2,cornice_height_ft:2,cornice_color:"#374151",color_split_enabled:!1,pilasters:[]}},{id:"modern_office",name:"Modern Office",config:{wainscot_enabled:!1,accent_bands:[],cornice_enabled:!0,cornice_depth_ft:.5,cornice_height_ft:.5,cornice_color:"#9ca3af",color_split_enabled:!1,pilasters:[]}}];function CF({overlay:t,onUpdate:s,isUpdating:n,edgeCount:a}){const l=t.exterior_finishes||$v,c=O=>{s({exterior_finishes:{...$v,...l,...O}})},u=O=>{s({exterior_finishes:{...$v,...O}})},i=O=>O<Ik.length?Ik[O]:`Edge ${O+1}`,_=l.accent_bands||[],j=()=>{_.length>=4||c({accent_bands:[..._,{height_ft:12,thickness_ft:1,color:"#b91c1c"}]})},y=O=>{const q=[..._];q.splice(O,1),c({accent_bands:q})},x=(O,q)=>{const W=_.map((Q,Z)=>Z===O?{...Q,...q}:Q);c({accent_bands:W})},v=l.pilasters||[],C=()=>{v.length>=12||c({pilasters:[...v,{edgeIndex:0,positionPct:50,widthFt:2,depthFt:1.5,heightMode:"full"}]})},P=O=>{const q=[...v];q.splice(O,1),c({pilasters:q})},I=(O,q)=>{const W=v.map((Q,Z)=>Z===O?{...Q,...q}:Q);c({pilasters:W})},z=(O,q)=>{if(q<1)return;const W=[];for(let Z=0;Z<q;Z++){const oe=q===1?50:Z/(q-1)*100;W.push({edgeIndex:O,positionPct:Math.round(oe*10)/10,widthFt:2,depthFt:1.5,heightMode:"full"})}const Q=v.filter(Z=>Z.edgeIndex!==O);c({pilasters:[...Q,...W]})},F=l.wainscot_enabled||l.cornice_enabled||l.color_split_enabled||_.length>0||v.length>0,D=t.facade_peaks||[],X=()=>{D.length>=6||s({facade_peaks:[...D,{edgeIndex:0,startPct:30,endPct:70,heightFt:4,depthFt:5}]})},K=O=>{const q=[...D];q.splice(O,1),s({facade_peaks:q})},te=(O,q)=>{const W=D.map((Q,Z)=>Z===O?{...Q,...q}:Q);s({facade_peaks:W})},J=["Front","Rear","Side 1","Side 2"],H=O=>O<J.length?J[O]:`Edge ${O+1}`;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs font-medium",children:"Facade Peaks"}),e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:[D.length," / 6"]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Raised parapet accents at entrances, end caps, or brand towers"}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[e.jsx(Le,{variant:"outline",size:"sm",className:"h-7 text-[10px]",disabled:n,onClick:()=>s({facade_peaks:[{edgeIndex:0,startPct:35,endPct:65,heightFt:6,depthFt:6}]}),children:"Center Tower"}),e.jsx(Le,{variant:"outline",size:"sm",className:"h-7 text-[10px]",disabled:n,onClick:()=>s({facade_peaks:[{edgeIndex:0,startPct:0,endPct:15,heightFt:4,depthFt:5},{edgeIndex:0,startPct:85,endPct:100,heightFt:4,depthFt:5}]}),children:"End Caps"}),e.jsx(Le,{variant:"outline",size:"sm",className:"h-7 text-[10px]",disabled:n,onClick:()=>s({facade_peaks:[{edgeIndex:0,startPct:0,endPct:12,heightFt:4,depthFt:5},{edgeIndex:0,startPct:38,endPct:62,heightFt:6,depthFt:6},{edgeIndex:0,startPct:88,endPct:100,heightFt:4,depthFt:5}]}),children:"Triple Entry"}),e.jsx(Le,{variant:"outline",size:"sm",className:"h-7 text-[10px]",disabled:n,onClick:()=>s({facade_peaks:[{edgeIndex:0,startPct:0,endPct:100,heightFt:4,depthFt:4}]}),children:"Full Parapet"})]}),D.map((O,q)=>{var W;return e.jsxs("div",{className:"bg-muted/50 rounded p-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] font-medium",children:["Peak ",q+1]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",disabled:n,onClick:()=>K(q),children:e.jsx(Om,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-1.5",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Edge"}),e.jsxs(rt,{value:String(O.edgeIndex),onValueChange:Q=>te(q,{edgeIndex:parseInt(Q)||0}),disabled:n,children:[e.jsx(it,{className:"h-6 text-[10px]",children:e.jsx(ct,{})}),e.jsx(ot,{children:Array.from({length:a},(Q,Z)=>e.jsx(le,{value:String(Z),className:"text-[10px]",children:H(Z)},Z))})]})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Start %"}),e.jsx(be,{type:"number",value:O.startPct,onChange:Q=>te(q,{startPct:parseFloat(Q.target.value)||0}),className:"h-6 text-[10px]",min:0,max:100,disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"End %"}),e.jsx(be,{type:"number",value:O.endPct,onChange:Q=>te(q,{endPct:parseFloat(Q.target.value)||0}),className:"h-6 text-[10px]",min:0,max:100,disabled:n})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-1.5",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Height (ft)"}),e.jsx(be,{type:"number",value:O.heightFt,onChange:Q=>te(q,{heightFt:parseFloat(Q.target.value)||4}),className:"h-6 text-[10px]",min:1,max:20,disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Depth (ft)"}),e.jsx(be,{type:"number",value:O.depthFt,onChange:Q=>te(q,{depthFt:parseFloat(Q.target.value)||4}),className:"h-6 text-[10px]",min:1,max:30,disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Color"}),e.jsx(be,{type:"color",value:O.color||t.wall_color||((W=t.style)==null?void 0:W.color)||"#8B8B8B",onChange:Q=>te(q,{color:Q.target.value}),className:"h-6 w-full p-0.5 cursor-pointer",disabled:n})]})]})]},q)}),D.length<6&&e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full h-7 text-[10px]",disabled:n,onClick:X,children:[e.jsx(tr,{className:"w-3 h-3 mr-1"})," Add Peak Zone"]}),D.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded px-2 py-1",children:[e.jsx(B,{className:"text-[10px]",children:"Peak in front of Cap Tr
755im"}),e.jsx(kt,{checked:l.peaks_above_cornice??!1,onCheckedChange:O=>c({peaks_above_cornice:O}),disabled:n})]}),e.jsx(Le,{variant:"ghost",size:"sm",className:"w-full h-6 text-[10px] text-muted-foreground",disabled:n,onClick:()=>s({facade_peaks:[]}),children:"Clear All Peaks"})]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs font-medium",children:"Finish Presets"}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:kF.map(O=>e.jsx(Le,{variant:"outline",size:"sm",className:"h-7 text-[10px]",disabled:n,onClick:()=>u(O.config),children:O.name},O.id))})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs font-medium",children:"Wainscoting"}),e.jsx(kt,{checked:l.wainscot_enabled??!1,onCheckedChange:O=>c({wainscot_enabled:O}),disabled:n})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Contrasting lower-wall material band"}),l.wainscot_enabled&&e.jsxs("div",{className:"grid grid-cols-3 gap-1.5",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Height (ft)"}),e.jsx(be,{type:"number",value:l.wainscot_height_ft??4,onChange:O=>c({wainscot_height_ft:parseFloat(O.target.value)||4}),className:"h-6 text-[10px]",min:1,max:20,disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Material"}),e.jsxs(rt,{value:l.wainscot_material??"stone",onValueChange:O=>c({wainscot_material:O}),disabled:n,children:[e.jsx(it,{className:"h-6 text-[10px]",children:e.jsx(ct,{})}),e.jsx(ot,{children:NF.map(O=>e.jsx(le,{value:O.value,className:"text-[10px]",children:O.label},O.value))})]})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Color"}),e.jsx(be,{type:"color",value:l.wainscot_color??"#78716c",onChange:O=>c({wainscot_color:O.target.value}),className:"h-6 w-full p-0.5 cursor-pointer",disabled:n})]})]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs font-medium",children:"Two-Tone Color Split"}),e.jsx(kt,{checked:l.color_split_enabled??!1,onCheckedChange:O=>c({color_split_enabled:O}),disabled:n})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Upper and lower wall colors at a split height"}),l.color_split_enabled&&e.jsxs("div",{className:"grid grid-cols-3 gap-1.5",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Split Height (ft)"}),e.jsx(be,{type:"number",value:l.color_split_height_ft??10,onChange:O=>c({color_split_height_ft:parseFloat(O.target.value)||10}),className:"h-6 text-[10px]",min:2,max:50,disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Lower"}),e.jsx(be,{type:"color",value:l.lower_color??"#78716c",onChange:O=>c({lower_color:O.target.value}),className:"h-6 w-full p-0.5 cursor-pointer",disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Upper"}),e.jsx(be,{type:"color",value:l.upper_color??"#e5e7eb",onChange:O=>c({upper_color:O.target.value}),className:"h-6 w-full p-0.5 cursor-pointer",disabled:n})]})]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs font-medium",children:"Accent Bands"}),e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:[_.length," / 4"]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Horizontal decorative stripes at specific heights"}),_.map((O,q)=>e.jsxs("div",{className:"bg-muted/50 rounded p-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] font-medium",children:["Band ",q+1]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",disabled:n,onClick:()=>y(q),children:e.jsx(Om,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-1.5",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Height (ft)"}),e.jsx(be,{type:"number",value:O.height_ft,onChange:W=>x(q,{height_ft:parseFloat(W.target.value)||12}),className:"h-6 text-[10px]",min:1,max:80,disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Thickness (ft)"}),e.jsx(be,{type:"number",value:O.thickness_ft,onChange:W=>x(q,{thickness_ft:parseFloat(W.target.value)||1}),className:"h-6 text-[10px]",min:.25,max:4,step:.25,disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Color"}),e.jsx(be,{type:"color",value:O.color,onChange:W=>x(q,{color:W.target.value}),className:"h-6 w-full p-0.5 cursor-pointer",disabled:n})]})]})]},q)),_.length<4&&e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full h-7 text-[10px]",disabled:n,onClick:j,children:[e.jsx(tr,{className:"w-3 h-3 mr-1"})," Add Accent Band"]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs font-medium",children:"Cornice / Cap Trim"}),e.jsx(kt,{checked:l.cornice_enabled??!1,onCheckedChange:O=>c({cornice_enabled:O}),disabled:n})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Decorative cap band at the roofline"}),l.cornice_enabled&&e.jsxs("div",{className:"grid grid-cols-3 gap-1.5",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Depth (ft)"}),e.jsx(be,{type:"number",value:l.cornice_depth_ft??1,onChange:O=>c({cornice_depth_ft:parseFloat(O.target.value)||1}),className:"h-6 text-[10px]",min:.5,max:4,step:.25,disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Height (ft)"}),e.jsx(be,{type:"number",value:l.cornice_height_ft??1.5,onChange:O=>c({cornice_height_ft:parseFloat(O.target.value)||1.5}),className:"h-6 text-[10px]",min:.5,max:4,step:.25,disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Color"}),e.jsx(be,{type:"color",value:l.cornice_color??"#374151",onChange:O=>c({cornice_color:O.target.value}),className:"h-6 w-full p-0.5 cursor-pointer",disabled:n})]})]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs font-medium",children:"Pilasters / Bump-Outs"}),e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:[v.length," / 12"]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Vertical columns projecting outward to add facade rhythm"}),e.jsxs("div",{className:"flex items-center gap-1.5 bg-muted/30 rounded p-1.5",children:[e.jsx(B,{className:"text-[10px] whitespace-nowrap",children:"Auto-Space"}),e.jsxs(rt,{defaultValue:"0",onValueChange:O=>{},disabled:n,children:[e.jsx(it,{className:"h-6 text-[10px] w-20",children:e.jsx(ct,{placeholder:"Edge"})}),e.jsx(ot,{children:Array.from({length:a},(O,q)=>e.jsx(le,{value:String(q),className:"text-[10px]",children:i(q)},q))})]}),[3,4,5,6].map(O=>e.jsx(Le,{variant:"outline",size:"sm",className:"h-6 w-6 text-[10px] p-0",disabled:n,onClick:()=>z(0,O),children:O},O))]}),v.map((O,q)=>e.jsxs("div",{className:"bg-muted/50 rounded p-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] font-medium",children:["Pilaster ",q+1]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",disabled:n,onClick:()=>P(q),children:e.jsx(Om,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-1.5",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Edge"}),e.jsxs(rt,{value:String(O.edgeIndex),onValueChange:W=>I(q,{edgeIndex:parseInt(W)||0}),disabled:n,children:[e.jsx(it,{className:"h-6 text-[10px]",children:e.jsx(ct,{})}),e.jsx(ot,{children:Array.from({length:a},(W,Q)=>e.jsx(le,{value:String(Q),className:"text-[10px]",children:i(Q)},Q))})]})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Position %"}),e.jsx(be,{type:"number",value:O.positionPct,onChange:W=>I(q,{positionPct:Math.min(100,Math.max(0,parseFloat(W.target.value)||50))}),className:"h-6 text-[10px]",min:0,max:100,disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Color"}
755),e.jsx(be,{type:"color",value:O.color??l.wainscot_color??"#78716c",onChange:W=>I(q,{color:W.target.value}),className:"h-6 w-full p-0.5 cursor-pointer",disabled:n})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-1.5",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Width (ft)"}),e.jsx(be,{type:"number",value:O.widthFt,onChange:W=>I(q,{widthFt:parseFloat(W.target.value)||2}),className:"h-6 text-[10px]",min:.5,max:8,step:.5,disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Depth (ft)"}),e.jsx(be,{type:"number",value:O.depthFt,onChange:W=>I(q,{depthFt:parseFloat(W.target.value)||1.5}),className:"h-6 text-[10px]",min:.5,max:6,step:.25,disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Height"}),e.jsxs(rt,{value:O.heightMode,onValueChange:W=>I(q,{heightMode:W}),disabled:n,children:[e.jsx(it,{className:"h-6 text-[10px]",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"full",className:"text-[10px]",children:"Full Height"}),e.jsx(le,{value:"partial",className:"text-[10px]",children:"Partial"})]})]})]})]}),O.heightMode==="partial"&&e.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"Start (ft)"}),e.jsx(be,{type:"number",value:O.startHeightFt??0,onChange:W=>I(q,{startHeightFt:parseFloat(W.target.value)||0}),className:"h-6 text-[10px]",min:0,disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px]",children:"End (ft)"}),e.jsx(be,{type:"number",value:O.endHeightFt??20,onChange:W=>I(q,{endHeightFt:parseFloat(W.target.value)||20}),className:"h-6 text-[10px]",min:1,disabled:n})]})]})]},q)),v.length<12&&e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full h-7 text-[10px]",disabled:n,onClick:C,children:[e.jsx(tr,{className:"w-3 h-3 mr-1"})," Add Pilaster"]})]}),F&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(Le,{variant:"ghost",size:"sm",className:"w-full h-6 text-[10px] text-muted-foreground",disabled:n,onClick:()=>s({exterior_finishes:null}),children:"Clear All Exterior Finishes"})]})]})}function SF(t,s={}){const n=VS(t),a=(n[0]+n[2])/2,l=(n[1]+n[3])/2;return us([a,l],s.properties,s)}var BP={exports:{}};(function(t,s){(function(n,a){t.exports=a()})(Fm,function(){function n(N,h){(h==null||h>N.length)&&(h=N.length);for(var f=0,w=Array(h);f<h;f++)w[f]=N[f];return w}function a(N,h,f){return h=y(h),function(w,G){if(G&&(typeof G=="object"||typeof G=="function"))return G;if(G!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(re){if(re===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return re}(w)}(N,v()?Reflect.construct(h,f||[],y(N).constructor):h.apply(N,f))}function l(N,h){if(!(N instanceof h))throw new TypeError("Cannot call a class as a function")}function c(N,h,f){if(v())return Reflect.construct.apply(null,arguments);var w=[null];w.push.apply(w,h);var G=new(N.bind.apply(N,w));return f&&C(G,f.prototype),G}function u(N,h){for(var f=0;f<h.length;f++){var w=h[f];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(N,z(w.key),w)}}function i(N,h,f){return h&&u(N.prototype,h),f&&u(N,f),Object.defineProperty(N,"prototype",{writable:!1}),N}function _(N,h){var f=typeof Symbol<"u"&&N[Symbol.iterator]||N["@@iterator"];if(!f){if(Array.isArray(N)||(f=F(N))||h){f&&(N=f);var w=0,G=function(){};return{s:G,n:function(){return w>=N.length?{done:!0}:{done:!1,value:N[w++]}},e:function(tt){throw tt},f:G}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
756In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var re,xe=!0,Ae=!1;return{s:function(){f=f.call(N)},n:function(){var tt=f.next();return xe=tt.done,tt},e:function(tt){Ae=!0,re=tt},f:function(){try{xe||f.return==null||f.return()}finally{if(Ae)throw re}}}}function j(){return j=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(N,h,f){var w=function(re,xe){for(;!{}.hasOwnProperty.call(re,xe)&&(re=y(re))!==null;);return re}(N,h);if(w){var G=Object.getOwnPropertyDescriptor(w,h);return G.get?G.get.call(arguments.length<3?N:f):G.value}},j.apply(null,arguments)}
756function y(N){return y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},y(N)}function x(N,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");N.prototype=Object.create(h&&h.prototype,{constructor:{value:N,writable:!0,configurable:!0}}),Object.defineProperty(N,"prototype",{writable:!1}),h&&C(N,h)}function v(){try{var N=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(v=function(){return!!N})()}function C(N,h){return C=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,w){return f.__proto__=w,f},C(N,h)}function P(N,h,f,w){var G=j(y(1&w?N.prototype:N),h,f);return 2&w&&typeof G=="function"?function(re){return G.apply(f,re)}:G}function I(N){return function(h){if(Array.isArray(h))return n(h)}(N)||function(h){if(typeof Symbol<"u"&&h[Symbol.iterator]!=null||h["@@iterator"]!=null)return Array.from(h)}(N)||F(N)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
757In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function z(N){var h=function(f,w){if(typeof f!="object"||!f)return f;var G=f[Symbol.toPrimitive];if(G!==void 0){var re=G.call(f,w);if(typeof re!="object")return re;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(f)}(N,"string");return typeof h=="symbol"?h:h+""}function F(N,h){if(N){if(typeof N=="string")return n(N,h);var f={}.toString.call(N).slice(8,-1);return f==="Object"&&N.constructor&&(f=N.constructor.name),f==="Map"||f==="Set"?Array.from(N):f==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(f)?n(N,h):void 0}}function D(N){var h=typeof Map=="function"?new Map:void 0;return D=function(f){if(f===null||!function(G){try{return Function.toString.call(G).indexOf("[native code]")!==-1}catch{return typeof G=="function"}}(f))return f;if(typeof f!="function")throw new TypeError("Super expression must either be null or a function");if(h!==void 0){if(h.has(f))return h.get(f);h.set(f,w)}function w(){return c(f,arguments,y(this).constructor)}return w.prototype=Object.create(f.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),C(w,f)},D(N)}var X=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"getEndCapStyle",value:function(){return this._endCapStyle}},{key:"isSingleSided",value:function(){return this._isSingleSided}},{key:"setQuadrantSegments",value:function(h){this._quadrantSegments=h,this._quadrantSegments===0&&(this._joinStyle=N.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=N.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),h<=0&&(this._quadrantSegments=1),this._joinStyle!==N.JOIN_ROUND&&(this._quadrantSegments=N.DEFAULT_QUADRANT_SEGMENTS)}},{key:"getJoinStyle",value:function(){return this._joinStyle}},{key:"setJoinStyle",value:function(h){this._joinStyle=h}},{key:"setSimplifyFactor",value:function(h){this._simplifyFactor=h<0?0:h}},{key:"getSimplifyFactor",value:function(){return this._simplifyFactor}},{key:"getQuadrantSegments",value:function(){return this._quadrantSegments}},{key:"setEndCapStyle",value:function(h){this._endCapStyle=h}},{key:"getMitreLimit",value:function(){return this._mitreLimit}},{key:"setMitreLimit",value:function(h){this._mitreLimit=h}},{key:"setSingleSided",value:function(h){this._isSingleSided=h}}],[{key:"constructor_",value:function(){if(this._quadrantSegments=N.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=N.CAP_ROUND,this._joinStyle=N.JOIN_ROUND,this._mitreLimit=N.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=N.DEFAULT_SIMPLIFY_FACTOR,arguments.length!==0){if(arguments.length===1){var h=arguments[0];this.setQuadrantSegments(h)}else if(arguments.length===2){var f=arguments[0],w=arguments[1];this.setQuadrantSegments(f),this.setEndCapStyle(w)}else if(arguments.length===4){var G=arguments[0],re=arguments[1],xe=arguments[2],Ae=arguments[3];this.setQuadrantSegments(G),this.setEndCapStyle(re),this.setJoinStyle(xe),this.setMitreLimit(Ae)}}}},{key:"bufferDistanceError",value:function(h){var f=Math.PI/2/h;return 1-Math.cos(f/2)}}])}();X.CAP_ROUND=1,X.CAP_FLAT=2,X.CAP_SQUARE=3,X.JOIN_ROUND=1,X.JOIN_MITRE=2,X.JOIN_BEVEL=3,X.DEFAULT_QUADRANT_SEGMENTS=8,X.DEFAULT_MITRE_LIMIT=5,X.DEFAULT_SIMPLIFY_FACTOR=.01;var K=function(N){function h(f){var w;return l(this,h),(w=a(this,h,[f])).name=Object.keys({Exception:h})[0],w}return x(h,N),i(h,[{key:"toString",value:function(){return this.message}}])}(D(Error)),te=function(N){function h(f){var w;return l(this,h),(w=a(this,h,[f])).name=Object.keys({IllegalArgumentException:h})[0],w}return x(h,N),i(h)}(K),J=function(){return i(function N(){l(this,N)},[{key:"filter",value:function(N){}}])}();function H(){}function O(){}function q(){}var W,Q,Z,oe,ce,ae,ie,de,ge=function(){return i(function N(){l(this,N)},null,[{key:"equalsWithTolerance",value:function(N,h,f){return Math.abs(N-h)<=f}}])}(),We=function(){return i(function N(h,f){l(this,N),this.low=f||0,this.high=h||0},null,[{key:"toBinaryString",value:function(N){var h,f="";for(h=2147483648;h>0;h>>>=1)f+=(N.high&h)===h?"1":"0";for(h=2147483648;h>0;h>>>=1)f+=(N.low&h)===h?"1":"0";return f}}])}();function Ee(){}function ve(){}Ee.NaN=NaN,Ee.isNaN=function(N){return Number.isNaN(N)},Ee.isInfinite=function(N){return!Number.isFinite(N)},Ee.MAX_VALUE=Number.MAX_VALUE,Ee.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,Ee.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,typeof Float64Array=="function"&&typeof Int32Array=="function"?(ae=2146435072,ie=new Float64Array(1),de=new Int32Array(ie.buffer),Ee.doubleToLongBits=function(N){ie[0]=N;var h=0|de[0],f=0|de[1];return(f&ae)===ae&&1048575&f&&h!==0&&(h=0,f=2146959360),new We(f,h)},Ee.longBitsToDouble=function(N){return de[0]=N.low,de[1]=N.high,ie[0]}):(W=1023,Q=Math.log2,Z=Math.floor,oe=Math.pow,ce=function(){for(var N=53;N>0;N--){var h=oe(2,N)-1;if(Z(Q(h))+1===N)return h}return 0}(),Ee.doubleToLongBits=function(N){var h,f,w,G,re,xe,Ae,tt,Nt;if(N<0||1/N===Number.NEGATIVE_INFINITY?(xe=1<<31,N=-N):xe=0,N===0)return new We(tt=xe,Nt=0);if(N===1/0)return new We(tt=2146435072|xe,Nt=0);if(N!=N)return new We(tt=2146959360,Nt=0);if(G=0,Nt=0,(h=Z(N))>1)if(h<=ce)(G=Z(Q(h)))<=20?(Nt=0,tt=h<<20-G&1048575):(Nt=h%(f=oe(2,w=G-20))<<32-w,tt
757=h/f&1048575);else for(w=h,Nt=0;(w=Z(f=w/2))!==0;)G++,Nt>>>=1,Nt|=(1&tt)<<31,tt>>>=1,f!==w&&(tt|=524288);if(Ae=G+W,re=h===0,h=N-h,G<52&&h!==0)for(w=0;;){if((f=2*h)>=1?(h=f-1,re?(Ae--,re=!1):(w<<=1,w|=1,G++)):(h=f,re?--Ae==0&&(G++,re=!1):(w<<=1,G++)),G===20)tt|=w,w=0;else if(G===52){Nt|=w;break}if(f===1){G<20?tt|=w<<20-G:G<52&&(Nt|=w<<52-G);break}}return tt|=Ae<<20,new We(tt|=xe,Nt)},Ee.longBitsToDouble=function(N){var h,f,w,G,re=N.high,xe=N.low,Ae=re&1<<31?-1:1;for(w=((2146435072&re)>>20)-W,G=0,f=1<<19,h=1;h<=20;h++)re&f&&(G+=oe(2,-h)),f>>>=1;for(f=1<<31,h=21;h<=52;h++)xe&f&&(G+=oe(2,-h)),f>>>=1;if(w===-1023){if(G===0)return 0*Ae;w=-1022}else{if(w===1024)return G===0?Ae/0:NaN;G+=1}return Ae*G*oe(2,w)});var we=function(N){function h(f){var w;return l(this,h),(w=a(this,h,[f])).name=Object.keys({RuntimeException:h})[0],w}return x(h,N),i(h)}(K),Ze=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,null,[{key:"constructor_",value:function(){if(arguments.length===0)we.constructor_.call(this);else if(arguments.length===1){var f=arguments[0];we.constructor_.call(this,f)}}}])}(we),ke=function(){function N(){l(this,N)}return i(N,null,[{key:"shouldNeverReachHere",value:function(){if(arguments.length===0)N.shouldNeverReachHere(null);else if(arguments.length===1){var h=arguments[0];throw new Ze("Should never reach here"+(h!==null?": "+h:""))}}},{key:"isTrue",value:function(){if(arguments.length===1){var h=arguments[0];N.isTrue(h,null)}else if(arguments.length===2){var f=arguments[1];if(!arguments[0])throw f===null?new Ze:new Ze(f)}}},{key:"equals",value:function(){if(arguments.length===2){var h=arguments[0],f=arguments[1];N.equals(h,f,null)}else if(arguments.length===3){var w=arguments[0],G=arguments[1],re=arguments[2];if(!G.equals(w))throw new Ze("Expected "+w+" but encountered "+G+(re!==null?": "+re:""))}}}])}(),ze=new ArrayBuffer(8),Ke=new Float64Array(ze),dt=new Int32Array(ze),Re=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"getM",value:function(){return Ee.NaN}},{key:"setOrdinate",value:function(h,f){switch(h){case N.X:this.x=f;break;case N.Y:this.y=f;break;case N.Z:this.setZ(f);break;default:throw new te("Invalid ordinate index: "+h)}}},{key:"equals2D",value:function(){if(arguments.length===1){var h=arguments[0];return this.x===h.x&&this.y===h.y}if(arguments.length===2){var f=arguments[0],w=arguments[1];return!!ge.equalsWithTolerance(this.x,f.x,w)&&!!ge.equalsWithTolerance(this.y,f.y,w)}}},{key:"setM",value:function(h){throw new te("Invalid ordinate index: "+N.M)}},{key:"getZ",value:function(){return this.z}},{key:"getOrdinate",value:function(h){switch(h){case N.X:return this.x;case N.Y:return this.y;case N.Z:return this.getZ()}throw new te("Invalid ordinate index: "+h)}},{key:"equals3D",value:function(h){return this.x===h.x&&this.y===h.y&&(this.getZ()===h.getZ()||Ee.isNaN(this.getZ())&&Ee.isNaN(h.getZ()))}},{key:"equals",value:function(h){return h instanceof N&&this.equals2D(h)}},{key:"equalInZ",value:function(h,f){return ge.equalsWithTolerance(this.getZ(),h.getZ(),f)}},{key:"setX",value:function(h){this.x=h}},{key:"compareTo",value:function(h){var f=h;return this.x<f.x?-1:this.x>f.x?1:this.y<f.y?-1:this.y>f.y?1:0}},{key:"getX",value:function(){return this.x}},{key:"setZ",value:function(h){this.z=h}},{key:"clone",value:function(){try{return null}catch(h){if(h instanceof CloneNotSupportedException)return ke.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw h}}},{key:"copy",value:function(){return new N(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+")"}},{key:"distance3D",value:function(h){var f=this.x-h.x,w=this.y-h.y,G=this.getZ()-h.getZ();return Math.sqrt(f*f+w*w+G*G)}},{key:"getY",value:function(){return this.y}},{key:"setY",value:function(h){this.y=h}},{key:"distance",value:function(h){var f=this.x-h.x,w=this.y-h.y;return Math.sqrt(f*f+w*w)}},{key:"hashCode",value:function(){var h=17;return h=37*(h=37*h+N.hashCode(this.x))+N.hashCode(this.y)}},{key:"setCoordinate",value:function(h){this.x=h.x,this.y=h.y,this.z=h.getZ()}},{key:"interfaces_",get:function(){return[H,O,q]}}
757],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.z=null,arguments.length===0)N.constructor_.call(this,0,0);else if(arguments.length===1){var h=arguments[0];N.constructor_.call(this,h.x,h.y,h.getZ())}else if(arguments.length===2){var f=arguments[0],w=arguments[1];N.constructor_.call(this,f,w,N.NULL_ORDINATE)}else if(arguments.length===3){var G=arguments[0],re=arguments[1],xe=arguments[2];this.x=G,this.y=re,this.z=xe}}},{key:"hashCode",value:function(h){return Ke[0]=h,dt[0]^dt[1]}}])}(),qt=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"compare",value:function(h,f){var w=N.compare(h.x,f.x);if(w!==0)return w;var G=N.compare(h.y,f.y);return G!==0?G:this._dimensionsToTest<=2?0:N.compare(h.getZ(),f.getZ())}},{key:"interfaces_",get:function(){return[ve]}}],[{key:"constructor_",value:function(){if(this._dimensionsToTest=2,arguments.length===0)N.constructor_.call(this,2);else if(arguments.length===1){var h=arguments[0];if(h!==2&&h!==3)throw new te("only 2 or 3 dimensions may be specified");this._dimensionsToTest=h}}},{key:"compare",value:function(h,f){return h<f?-1:h>f?1:Ee.isNaN(h)?Ee.isNaN(f)?0:-1:Ee.isNaN(f)?1:0}}])}();Re.DimensionalComparator=qt,Re.NULL_ORDINATE=Ee.NaN,Re.X=0,Re.Y=1,Re.Z=2,Re.M=3;var ft=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"getArea",value:function(){return this.getWidth()*this.getHeight()}},{key:"equals",value:function(h){if(!(h instanceof N))return!1;var f=h;return this.isNull()?f.isNull():this._maxx===f.getMaxX()&&this._maxy===f.getMaxY()&&this._minx===f.getMinX()&&this._miny===f.getMinY()}},{key:"intersection",value:function(h){if(this.isNull()||h.isNull()||!this.intersects(h))return new N;var f=this._minx>h._minx?this._minx:h._minx,w=this._miny>h._miny?this._miny:h._miny;return new N(f,this._maxx<h._maxx?this._maxx:h._maxx,w,this._maxy<h._maxy?this._maxy:h._maxy)}},{key:"isNull",value:function(){return this._maxx<this._minx}},{key:"getMaxX",value:function(){return this._maxx}},{key:"covers",value:function(){if(arguments.length===1){if(arguments[0]instanceof Re){var h=arguments[0];return this.covers(h.x,h.y)}if(arguments[0]instanceof N){var f=arguments[0];return!this.isNull()&&!f.isNull()&&f.getMinX()>=this._minx&&f.getMaxX()<=this._maxx&&f.getMinY()>=this._miny&&f.getMaxY()<=this._maxy}}else if(arguments.length===2){var w=arguments[0],G=arguments[1];return!this.isNull()&&w>=this._minx&&w<=this._maxx&&G>=this._miny&&G<=this._maxy}}},{key:"intersects",value:function(){if(arguments.length===1){if(arguments[0]instanceof N){var h=arguments[0];return!this.isNull()&&!h.isNull()&&!(h._minx>this._maxx||h._maxx<this._minx||h._miny>this._maxy||h._maxy<this._miny)}if(arguments[0]instanceof Re){var f=arguments[0];return this.intersects(f.x,f.y)}}else if(arguments.length===2){if(arguments[0]instanceof Re&&arguments[1]instanceof Re){var w=arguments[0],G=arguments[1];return!this.isNull()&&!((w.x<G.x?w.x:G.x)>this._maxx)&&!((w.x>G.x?w.x:G.x)<this._minx)&&!((w.y<G.y?w.y:G.y)>this._maxy)&&!((w.y>G.y?w.y:G.y)<this._miny)}if(typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var re=arguments[0],xe=arguments[1];return!this.isNull()&&!(re>this._maxx||re<this._minx||xe>this._maxy||xe<this._miny)}}}},{key:"getMinY",value:function(){return this._miny}},{key:"getDiameter",value:function(){if(this.isNull())return 0;var h=this.getWidth(),f=this.getHeight();return Math.sqrt(h*h+f*f)}},{key:"getMinX",value:function(){return this._minx}},{key:"expandToInclude",value:function(){if(arguments.length===1){if(arguments[0]instanceof Re){var h=arguments[0];this.expandToInclude(h.x,h.y)}else if(arguments[0]instanceof N){var f=arguments[0];if(f.isNull())return null;this.isNull()?(this._minx=f.getMinX(),this._maxx=f.getMaxX(),this._miny=f.getMinY(),this._maxy=f.getMaxY()):(f._minx<this._minx&&(this._minx=f._minx),f._maxx>this._maxx&&(this._maxx=f._maxx),f._miny<this._miny&&(this._miny=f._miny),f._maxy>this._maxy&&(this._maxy=f._maxy))}}else if(arguments.length===2){var w=arguments[0],G=arguments[1];
757this.isNull()?(this._minx=w,this._maxx=w,this._miny=G,this._maxy=G):(w<this._minx&&(this._minx=w),w>this._maxx&&(this._maxx=w),G<this._miny&&(this._miny=G),G>this._maxy&&(this._maxy=G))}}},{key:"minExtent",value:function(){if(this.isNull())return 0;var h=this.getWidth(),f=this.getHeight();return h<f?h:f}},{key:"getWidth",value:function(){return this.isNull()?0:this._maxx-this._minx}},{key:"compareTo",value:function(h){var f=h;return this.isNull()?f.isNull()?0:-1:f.isNull()?1:this._minx<f._minx?-1:this._minx>f._minx?1:this._miny<f._miny?-1:this._miny>f._miny?1:this._maxx<f._maxx?-1:this._maxx>f._maxx?1:this._maxy<f._maxy?-1:this._maxy>f._maxy?1:0}},{key:"translate",value:function(h,f){if(this.isNull())return null;this.init(this.getMinX()+h,this.getMaxX()+h,this.getMinY()+f,this.getMaxY()+f)}},{key:"copy",value:function(){return new N(this)}},{key:"toString",value:function(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"}},{key:"setToNull",value:function(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1}},{key:"disjoint",value:function(h){return!(!this.isNull()&&!h.isNull())||h._minx>this._maxx||h._maxx<this._minx||h._miny>this._maxy||h._maxy<this._miny}},{key:"getHeight",value:function(){return this.isNull()?0:this._maxy-this._miny}},{key:"maxExtent",value:function(){if(this.isNull())return 0;var h=this.getWidth(),f=this.getHeight();return h>f?h:f}},{key:"expandBy",value:function(){if(arguments.length===1){var h=arguments[0];this.expandBy(h,h)}else if(arguments.length===2){var f=arguments[0],w=arguments[1];if(this.isNull())return null;this._minx-=f,this._maxx+=f,this._miny-=w,this._maxy+=w,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}}},{key:"contains",value:function(){if(arguments.length===1){if(arguments[0]instanceof N){var h=arguments[0];return this.covers(h)}if(arguments[0]instanceof Re){var f=arguments[0];return this.covers(f)}}else if(arguments.length===2){var w=arguments[0],G=arguments[1];return this.covers(w,G)}}},{key:"centre",value:function(){return this.isNull()?null:new Re((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)}},{key:"init",value:function(){if(arguments.length===0)this.setToNull();else if(arguments.length===1){if(arguments[0]instanceof Re){var h=arguments[0];this.init(h.x,h.x,h.y,h.y)}else if(arguments[0]instanceof N){var f=arguments[0];this._minx=f._minx,this._maxx=f._maxx,this._miny=f._miny,this._maxy=f._maxy}}else if(arguments.length===2){var w=arguments[0],G=arguments[1];this.init(w.x,G.x,w.y,G.y)}else if(arguments.length===4){var re=arguments[0],xe=arguments[1],Ae=arguments[2],tt=arguments[3];re<xe?(this._minx=re,this._maxx=xe):(this._minx=xe,this._maxx=re),Ae<tt?(this._miny=Ae,this._maxy=tt):(this._miny=tt,this._maxy=Ae)}}},{key:"getMaxY",value:function(){return this._maxy}},{key:"distance",value:function(h){if(this.intersects(h))return 0;var f=0;this._maxx<h._minx?f=h._minx-this._maxx:this._minx>h._maxx&&(f=this._minx-h._maxx);var w=0;return this._maxy<h._miny?w=h._miny-this._maxy:this._miny>h._maxy&&(w=this._miny-h._maxy),f===0?w:w===0?f:Math.sqrt(f*f+w*w)}},{key:"hashCode",value:function(){var h=17;return h=37*(h=37*(h=37*(h=37*h+Re.hashCode(this._minx))+Re.hashCode(this._maxx))+Re.hashCode(this._miny))+Re.hashCode(this._maxy)}},{key:"interfaces_",get:function(){return[H,q]}}],[{key:"constructor_",value:function(){if(this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,arguments.length===0)this.init();else if(arguments.length===1){if(arguments[0]instanceof Re){var h=arguments[0];this.init(h.x,h.x,h.y,h.y)}else if(arguments[0]instanceof N){var f=arguments[0];this.init(f)}}else if(arguments.length===2){var w=arguments[0],G=arguments[1];this.init(w.x,G.x,w.y,G.y)}else if(arguments.length===4){var re=arguments[0],xe=arguments[1],Ae=arguments[2],tt=arguments[3];this.init(re,xe,Ae,tt)}}},{key:"intersects",value:function(){if(arguments.length===3){var h=arguments[0],f=arguments[1],w=arguments[2];return w.x>=(h.x<f.x?h.x:f.x)&&w.x<=(h.x>f.x?h.x:f.x)&&w.y>=(h.y<f.y?h.y:f.y)&&w.y<=(h.y>f.y?h.y:f.y)}if(arguments.length===4){var G=arguments[0],re=arguments[1],xe=arguments[2],Ae=arguments[3],tt=Math.min(xe.x,Ae.x),Nt=Math.max(xe.x,Ae.x),Ut=Math.min(G.x,re.x),xs=Math.max(G.x,re.x);return!(Ut>Nt)&&!(xs<tt)&&(tt=Math.min(xe.y,Ae.y),Nt=Math.max(xe.y,Ae.y),Ut=Math.min(G.y,re.y),xs=Math.max(G.y,re.y),!(Ut>Nt)&&!(xs<tt))}}}])}(),Fe=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"isGeometryCollection",value:function(){return this.getTypeCode()===N.TYPECODE_GEOMETRYCOLLECTION}},{key:"getFactory",value:function(){return this._factory}},{key:"getGeometryN",value:function(h){return this}},{key:"getArea",value:function(){return 0}},{key:"isRectangle",value:function(){return!1}},{key:"equalsExact",value:function(h){return this===h||this.equalsExact(h,0)}},{key:"geometryChanged",value:function(){this.apply(N.geometryChangedFilter)}},{key:"geometryChangedAction",value:function(){this._envelope=null}},{key:"equalsNorm",value:function(h){return h!==null&&this.norm().equalsExact(h.norm())}},{key:"getLength",value:function(){return 0}},{key:"getNumGeometries",value:function(){return 1}},{key:"compareTo",value:function(){var h;if(arguments.length===1){var f=arguments[0];return h=f,this.getTypeCode()!==h.getTypeCode()?this.getTypeCode()-h.getTypeCode():this.isEmpty()&&h.isEmpty()?0:this.isEmpty()?-1:h.isEmpty()?1:this.compareToSameClass(f)}if(arguments.length===2){var w=arguments[0],G=arguments[1];return h=w,this.getTypeCode()!==h.getTypeCode()?this.getTypeCode()-h.getTypeCode():this.isEmpty()&&h.isEmpty()?0:this.isEmpty()?-1:h.isEmpty()?1:this.compareToSameClass(w,G)}}},{key:"getUserData",value:function(){return this._userData}},{key:"getSRID",value:function(){return this._SRID}},{key:"getEnvelope",value:function(){return this.getFactory().toGeometry(this.getEnvelopeInternal())}},{key:"checkNotGeometryCollection",value:function(h){if(h.getTypeCode()===N.TYPECODE_GEOMETRYCOLLECTION)throw new te("This method does not support GeometryCollection arguments")}},{key:"equal",value:function(h,f,w){return w===0?h.equals(f):h.distance(f)<=w}},{key:"norm",value:function(){var h=this.copy();return h.normalize(),h}},{key:"reverse",value:function(){var h=this.reverseInternal();return this.envelope!=null&&(h.envelope=this.envelope.copy()),h.setSRID(this.getSRID()),h}},{key:"copy",value:function(){var h=this.copyInternal();return h.envelope=this._envelope==null?null:this._envelope.copy(),h._SRID=this._SRID,h._userData=this._userData,h}},{key:"getPrecisionModel",value:function(){return this._factory.getPrecisionModel()}},{key:"getEnvelopeInternal",value:function(){return this._envelope===null&&(this._envelope=this.computeEnvelopeInternal()),new ft(this._envelope)}},{key:"setSRID",value:function(h){this._SRID=h}},{key:"setUserData",value:function(h){this._userData=h}},{key:"compare",value:function(h,f){for(var w=h.iterator(),G=f.iterator();w.hasNext()&&G.hasNext();){var re=w.next(),xe=G.next(),Ae=re.compareTo(xe);if(Ae!==0)return Ae}return w.hasNext()?1:G.hasNext()?-1:0}},{key:"hashCode",value:function(){return this.getEnvelopeInternal().hashCode()}},{key:"isEquivalentClass",value:function(h){return this.getClass()===h.getClass()}},{key:"isGeometryCollectionOrDerived",value:function(){return this.getTypeCode()===N.TYPECODE_GEOMETRYCOLLECTION||this.getTypeCode()===N.TYPECODE_MULTIPOINT||this.getTypeCode()===N.TYPECODE_MULTILINESTRING||this.getTypeCode()===N.TYPECODE_MULTIPOLYGON}},{key:"interfaces_",get:function(){return[O,H,q]}},{key:"getClass",value:function(){return N}}],[{key:"hasNonEmptyElements",value:function(h){for(var f=0;f<h.length;f++)if(!h[f].isEmpty())return!0;return!1}},{key:"hasNullElements",value:function(h){for(var f=0;f<h.length;f++)if(h[f]===null)return!0;return!1}}])}();Fe.constructor_=function(N){N&&(this._envelope=null,this._userData=null,this._factory=N,this._SRID=N.getSRID())},Fe.TYPECODE_POINT=0,Fe.TYPECODE_MULTIPOINT=1,Fe.TYPECODE_LINESTRING=2,Fe.TYPECODE_LINEARRING=3,Fe.TYPECODE_MULTILINESTRING=4,Fe.TYPECODE_POLYGON=5,Fe.TYPECODE_MULTIPOLYGON=6,Fe.TYPECODE_GEOMETRYCOLLECTION=7,Fe.TYPENAME_POINT="Point",Fe.TYPENAME_MULTIPOINT="MultiPoint",Fe.TYPENAME_LINESTRING="LineString",Fe.TYPENAME_LINEARRING="LinearRing",Fe.TYPENAME_MULTILINESTRING="MultiLineString",Fe.TYPENAME_POLYGON="Polygon",Fe.TYPENAME_MULTIPOLYGON="MultiPolygon",Fe.TYPENAME_GEOMETRYCOLLECTION="GeometryCollection",Fe.geometryChangedFilter={get interfaces_(){return[J]},filter:function(N){N.geometryChangedAction()}};var fe=function(){function N(){l(this,N)}return i(N,null,[{key:"toLocationSymbol",value:function(h){switch(h){case N.EXTERIOR:return"e";case N.BOUNDARY:return"b";case N.INTERIOR:return"i";case N.NONE:return"-"}throw new te("Unknown location value: "+h)}}])}();fe.INTERIOR=0,fe.BOUNDARY=1,fe.EXTERIOR=2,fe.NONE=-1;var Qe=function(){return i(function N(){l(this,N)},[{key:"add",value:function(){}},{key:"addAll",value:function(){}},{key:"isEmpty",value:function(){}},{key:"iterator",value:function(){}},{key:"size",value:function(){}},{key:"toArray",value:function(){}},{key:"remove",value:function(){}}])}(),ht=function(N){function h(f){var w;return l(this,h),(w=a(this,h,[f])).name=Object.keys({NoSuchElementException:h})[0],w}return x(h,N),i(h)}(K),_t=function(N){function h(f){var w;return l(this,h),(w=a(this,h,[f])).name=Object.keys({UnsupportedOperationException:h})[0],w}return x(h,N),i(h)}(K),He=function(N){function h(){return l(this,h),a(this,h,arguments)}
vendor: 11,254 bytes, line 757
757return x(h,N),i(h,[{key:"contains",value:function(){}}])}(Qe),as=function(N){function h(f){var w;return l(this,h),(w=a(this,h)).map=new Map,f instanceof Qe&&w.addAll(f),w}return x(h,N),i(h,[{key:"contains",value:function(f){var w=f.hashCode?f.hashCode():f;return!!this.map.has(w)}},{key:"add",value:function(f){var w=f.hashCode?f.hashCode():f;return!this.map.has(w)&&!!this.map.set(w,f)}},{key:"addAll",value:function(f){var w,G=_(f);try{for(G.s();!(w=G.n()).done;){var re=w.value;this.add(re)}}catch(xe){G.e(xe)}finally{G.f()}return!0}},{key:"remove",value:function(){throw new _t}},{key:"size",value:function(){return this.map.size}},{key:"isEmpty",value:function(){return this.map.size===0}},{key:"toArray",value:function(){return Array.from(this.map.values())}},{key:"iterator",value:function(){return new vt(this.map)}},{key:Symbol.iterator,value:function(){return this.map}}])}(He),vt=function(){return i(function N(h){l(this,N),this.iterator=h.values();var f=this.iterator.next(),w=f.done,G=f.value;this.done=w,this.value=G},[{key:"next",value:function(){if(this.done)throw new ht;var N=this.value,h=this.iterator.next(),f=h.done,w=h.value;return this.done=f,this.value=w,N}},{key:"hasNext",value:function(){return!this.done}},{key:"remove",value:function(){throw new _t}}])}(),Xe=function(){function N(){l(this,N)}return i(N,null,[{key:"opposite",value:function(h){return h===N.LEFT?N.RIGHT:h===N.RIGHT?N.LEFT:h}}])}();Xe.ON=0,Xe.LEFT=1,Xe.RIGHT=2;var Ce=function(N){function h(f){var w;return l(this,h),(w=a(this,h,[f])).name=Object.keys({EmptyStackException:h})[0],w}return x(h,N),i(h)}(K),Be=function(N){function h(f){var w;return l(this,h),(w=a(this,h,[f])).name=Object.keys({IndexOutOfBoundsException:h})[0],w}return x(h,N),i(h)}(K),Dt=function(N){function h(){return l(this,h),a(this,h,arguments)}return x(h,N),i(h,[{key:"get",value:function(){}},{key:"set",value:function(){}},{key:"isEmpty",value:function(){}}])}(Qe),Rt=function(N){function h(){var f;return l(this,h),(f=a(this,h)).array=[],f}return x(h,N),i(h,[{key:"add",value:function(f){return this.array.push(f),!0}},{key:"get",value:function(f){if(f<0||f>=this.size())throw new Be;return this.array[f]}},{key:"push",value:function(f){return this.array.push(f),f}},{key:"pop",value:function(){if(this.array.length===0)throw new Ce;return this.array.pop()}},{key:"peek",value:function(){if(this.array.length===0)throw new Ce;return this.array[this.array.length-1]}},{key:"empty",value:function(){return this.array.length===0}},{key:"isEmpty",value:function(){return this.empty()}},{key:"search",value:function(f){return this.array.indexOf(f)}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}}])}(Dt);function zt(N,h){return N.interfaces_&&N.interfaces_.indexOf(h)>-1}var rs=function(){return i(function N(h){l(this,N),this.str=h},[{key:"append",value:function(N){this.str+=N}},{key:"setCharAt",value:function(N,h){this.str=this.str.substr(0,N)+h+this.str.substr(N+1)}},{key:"toString",value:function(){return this.str}}])}(),_s=function(){function N(h){l(this,N),this.value=h}return i(N,[{key:"intValue",value:function(){return this.value}},{key:"compareTo",value:function(h){return this.value<h?-1:this.value>h?1:0}}],[{key:"compare",value:function(h,f){return h<f?-1:h>f?1:0}},{key:"isNan",value:function(h){return Number.isNaN(h)}},{key:"valueOf",value:function(h){return new N(h)}}])}(),vs=function(){return i(function N(){l(this,N)},null,[{key:"isWhitespace",value:function(N){return N<=32&&N>=0||N===127}},{key:"toUpperCase",value:function(N){return N.toUpperCase()}}])}(),$t=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"le",value:function(h){return this._hi<h._hi||this._hi===h._hi&&this._lo<=h._lo}},{key:"extractSignificantDigits",value:function(h,f){var w=this.abs(),G=N.magnitude(w._hi),re=N.TEN.pow(G);(w=w.divide(re)).gt(N.TEN)?(w=w.divide(N.TEN),G+=1):w.lt(N.ONE)&&(w=w.multiply(N.TEN),G-=1);for(var xe=G+1,Ae=new rs,tt=N.MAX_PRINT_DIGITS-1,Nt=0;Nt<=tt;Nt++){h&&Nt===xe&&Ae.append(".");var Ut=Math.trunc(w._hi);if(Ut<0)break;var xs=!1,$s=0;Ut>9?(xs=!0,$s="9"):$s="0"+Ut,Ae.append($s),w=w.subtract(N.valueOf(Ut)).multiply(N.TEN),xs&&w.selfAdd(N.TEN);var bn=!0,da=N.magnitude(w._hi);if(da<0&&Math.abs(da)>=tt-Nt&&(bn=!1),!bn)break}return f[0]=G,Ae.toString()}},{key:"sqr",value:function(){return this.multiply(this)}},{key:"doubleValue",value:function(){return this._hi+this._lo}},{key:"subtract",value:function(){if(arguments[0]instanceof N){var h=arguments[0];return this.add(h.negate())}if(typeof arguments[0]=="number"){var f=arguments[0];return this.add(-f)}}},{key:"equals",value:function(){if(arguments.length===1&&arguments[0]instanceof N){var h=arguments[0];return this._hi===h._hi&&this._lo===h._lo}}},{key:"isZero",value:function(){return this._hi===0&&this._lo===0}},{key:"selfSubtract",value:function(){if(arguments[0]instanceof N){var h=arguments[0];return this.isNaN()?this:this.selfAdd(-h._hi,-h._lo)}if(typeof arguments[0]=="number"){var f=arguments[0];return this.isNaN()?this:this.selfAdd(-f,0)}}},{key:"getSpecialNumberString",value:function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null}},{key:"min",value:function(h){return this.le(h)?this:h}},{key:"selfDivide",value:function(){if(arguments.length===1){if(arguments[0]instanceof N){var h=arguments[0];return this.selfDivide(h._hi,h._lo)}if(typeof arguments[0]=="number"){var f=arguments[0];return this.selfDivide(f,0)}}else if(arguments.length===2){var w,G,re,xe,Ae=arguments[0],tt=arguments[1],Nt=null,Ut=null,xs=null,$s=null;return re=this._hi/Ae,$s=(Nt=(xs=N.SPLIT*re)-(Nt=xs-re))*(Ut=($s=N.SPLIT*Ae)-(Ut=$s-Ae))-(xe=re*Ae)+Nt*(G=Ae-Ut)+(w=re-Nt)*Ut+w*G,$s=re+(xs=(this._hi-xe-$s+this._lo-re*tt)/Ae),this._hi=$s,this._lo=re-$s+xs,this}}},{key:"dump",value:function(){return"DD<"+this._hi+", "+this._lo+">"}},{key:"divide",value:function(){if(arguments[0]instanceof N){var h,f,w,G,re=arguments[0],xe=null,Ae=null,tt=null,Nt=null;return h=(w=this._hi/re._hi)-(xe=(tt=N.SPLIT*w)-(xe=tt-w)),Nt=xe*(Ae=(Nt=N.SPLIT*re._hi)-(Ae=Nt-re._hi))-(G=w*re._hi)+xe*(f=re._hi-Ae)+h*Ae+h*f,new N(Nt=w+(tt=(this._hi-G-Nt+this._lo-w*re._lo)/re._hi),w-Nt+tt)}if(typeof arguments[0]=="number"){var Ut=arguments[0];return Ee.isNaN(Ut)?N.createNaN():N.copy(this).selfDivide(Ut,0)}}},{key:"ge",value:function(h){return this._hi>h._hi||this._hi===h._hi&&this._lo>=h._lo}},{key:"pow",value:function(h){if(h===0)return N.valueOf(1);var f=new N(this),w=N.valueOf(1),G=Math.abs(h);if(G>1)for(;G>0;)G%2==1&&w.selfMultiply(f),(G/=2)>0&&(f=f.sqr());else w=f;return h<0?w.reciprocal():w}},{key:"ceil",value:function(){if(this.isNaN())return N.NaN;var h=Math.ceil(this._hi),f=0;return h===this._hi&&(f=Math.ceil(this._lo)),new N(h,f)}},{key:"compareTo",value:function(h){var f=h;return this._hi<f._hi?-1:this._hi>f._hi?1:this._lo<f._lo?-1:this._lo>f._lo?1:0}},{key:"rint",value:function(){return this.isNaN()?this:this.add(.5).floor()}},{key:"setValue",value:function(){if(arguments[0]instanceof N){var h=arguments[0];return this.init(h),this}if(typeof arguments[0]=="number"){var f=arguments[0];return this.init(f),this}}},{key:"max",value:function(h){return this.ge(h)?this:h}},{key:"sqrt",value:function(){if(this.isZero())return N.valueOf(0);if(this.isNegative())return N.NaN;var h=1/Math.sqrt(this._hi),f=this._hi*h,w=N.valueOf(f),G=this.subtract(w.sqr())._hi*(.5*h);return w.add(G)}},{key:"selfAdd",value:function(){if(arguments.length===1){if(arguments[0]instanceof N){var h=arguments[0];return this.selfAdd(h._hi,h._lo)}if(typeof arguments[0]=="number"){var f,w,G,re,xe,Ae=arguments[0],tt=null;return tt=(G=this._hi+Ae)-(re=G-this._hi),w=(xe=(tt=Ae-re+(this._hi-tt))+this._lo)+(G-(f=G+xe)),this._hi=f+w,this._lo=w+(f-this._hi),this}}else if(arguments.length===2){var Nt,Ut,xs,$s,bn=arguments[0],da=arguments[1],wa=null,Lr=null,ur=null;xs=this._hi+bn,Ut=this._lo+da,Lr=xs-(ur=xs-this._hi),wa=Ut-($s=Ut-this._lo);var si=(Nt=xs+(ur=(Lr=bn-ur+(this._hi-Lr))+Ut))+(ur=(wa=da-$s+(this._lo-wa))+(ur+(xs-Nt))),Ei=ur+(Nt-si);return this._hi=si,this._lo=Ei,this}}},{key:"selfMultiply",value:function(){if(arguments.length===1){if(arguments[0]instanceof N){var h=arguments[0];return this.selfMultiply(h._hi,h._lo)}if(typeof arguments[0]=="number"){var f=arguments[0];return this.selfMultiply(f,0)}}else if(arguments.length===2){var w,G,re=arguments[0],xe=arguments[1],Ae=null,tt=null,Nt=null,Ut=null;Ae=(Nt=N.SPLIT*this._hi)-this._hi,Ut=N.SPLIT*re,Ae=Nt-Ae,w=this._hi-Ae,tt=Ut-re;var xs=(Nt=this._hi*re)+(Ut=Ae*(tt=Ut-tt)-Nt+Ae*(G=re-tt)+w*tt+w*G+(this._hi*xe+this._lo*re)),$s=Ut+(Ae=Nt-xs);return this._hi=xs,this._lo=$s,this}}},{key:"selfSqr",value:function(){return this.selfMultiply(this)}},{key:"floor",value:function(){if(this.isNaN())return N.NaN;var h=Math.floor(this._hi),f=0;return h===this._hi&&(f=Math.floor(this._lo)),new N(h,f)}},{key:"negate",value:function(){return this.isNaN()?this:new N(-this._hi,-this._lo)}},{key:"clone",value:function(){try{return null}catch(h){if(h instanceof CloneNotSupportedException)return null;throw h}}},{key:"multiply",value:function(){if(arguments[0]instanceof N){var h=arguments[0];return h.isNaN()?N.createNaN():N.copy(this).selfMultiply(h)}if(typeof arguments[0]=="number"){var f=arguments[0];return Ee.isNaN(f)?N.createNaN():N.copy(this).selfMultiply(f,0)}}},{key:"isNaN",value:function(){return Ee.isNaN(this._hi)}},{key:"intValue",value:function(){return Math.trunc(this._hi)}},{key:"toString",value:function(){var h=N.magnitude(this._hi);return h>=-3&&h<=20?this.toStandardNotation():this.toSciNotation()}},{key:"toStandardNotation",value:function(){var h=this.getSpecialNumberString();if(h!==null)return h;var f=new Array(1).fill(null),w=this.extractSignificantDigits(!0,f),G=f[0]+1,re=w;if(w.charAt(0)===".")re="0"+w;else if(G<0)re="0."+N.stringOfChar("0",-G)+w;else if(w.indexOf(".")===-1){var xe=G-w.length;re=w+N.stringOfChar("0",xe)+".0"}return this.isNegative()?"-"+re:re}},{key:"reciprocal",value:function(){var h,f,w,G,re=null,xe=null,Ae=null,tt=null;h=(w=1/this._hi)-(re=(Ae=N.SPLIT*w)-(re=Ae-w)),xe=(tt=N.SPLIT*this._hi)-this._hi;var Nt=w+(Ae=(1-(G=w*this._hi)-(tt=re*(xe=tt-xe)-G+re*(f=this._hi-xe)+h*xe+h*f)-w*this._lo)/this._hi);return new N(Nt,w-Nt+Ae)}},{key:"toSciNotation",value:function(){if(this.isZero())return N.SCI_NOT_ZERO;var h=this.getSpecialNumberString();if(h!==null)return h;var f=new Array(1).fill(null),w=this.extractSignificantDigits(!1,f),G=N.SCI_NOT_EXPONENT_CHAR+f[0];if(w.charAt(0)==="0")throw new IllegalStateException("Found leading zero: "+w);var re="";w.length>1&&(re=w.substring(1));var xe=w.charAt(0)+"."+re;return this.isNegative()?"-"+xe+G:xe+G}},{key:"abs",value:function(){return this.isNaN()?N.NaN:this.isNegative()?this.negate():new N(this)}},{key:"isPositive",value:function(){return this._hi>0||this._hi===0&&this._lo>0}},{key:"lt",value:function(h){return this._hi<h._hi||this._hi===h._hi&&this._lo<h._lo}},{key:"add",value:function(){if(arguments[0]instanceof N){var h=arguments[0];return N.copy(this).selfAdd(h)}if(typeof arguments[0]=="number"){var f=arguments[0];return N.copy(this).selfAdd(f)}}},{key:"init",value:function(){if(arguments.length===1){if(typeof arguments[0]=="number"){var h=arguments[0];
757this._hi=h,this._lo=0}else if(arguments[0]instanceof N){var f=arguments[0];this._hi=f._hi,this._lo=f._lo}}else if(arguments.length===2){var w=arguments[0],G=arguments[1];this._hi=w,this._lo=G}}},{key:"gt",value:function(h){return this._hi>h._hi||this._hi===h._hi&&this._lo>h._lo}},{key:"isNegative",value:function(){return this._hi<0||this._hi===0&&this._lo<0}},{key:"trunc",value:function(){return this.isNaN()?N.NaN:this.isPositive()?this.floor():this.ceil()}},{key:"signum",value:function(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0}},{key:"interfaces_",get:function(){return[q,H,O]}}],[{key:"constructor_",value:function(){if(this._hi=0,this._lo=0,arguments.length===0)this.init(0);else if(arguments.length===1){if(typeof arguments[0]=="number"){var h=arguments[0];this.init(h)}else if(arguments[0]instanceof N){var f=arguments[0];this.init(f)}else if(typeof arguments[0]=="string"){var w=arguments[0];N.constructor_.call(this,N.parse(w))}}else if(arguments.length===2){var G=arguments[0],re=arguments[1];this.init(G,re)}}},{key:"determinant",value:function(){if(typeof arguments[3]=="number"&&typeof arguments[2]=="number"&&typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var h=arguments[0],f=arguments[1],w=arguments[2],G=arguments[3];return N.determinant(N.valueOf(h),N.valueOf(f),N.valueOf(w),N.valueOf(G))}if(arguments[3]instanceof N&&arguments[2]instanceof N&&arguments[0]instanceof N&&arguments[1]instanceof N){var re=arguments[1],xe=arguments[2],Ae=arguments[3];return arguments[0].multiply(Ae).selfSubtract(re.multiply(xe))}}},{key:"sqr",value:function(h){return N.valueOf(h).selfMultiply(h)}},{key:"valueOf",value:function(){if(typeof arguments[0]=="string"){var h=arguments[0];return N.parse(h)}if(typeof arguments[0]=="number")return new N(arguments[0])}},{key:"sqrt",value:function(h){return N.valueOf(h).sqrt()}},{key:"parse",value:function(h){for(var f=0,w=h.length;vs.isWhitespace(h.charAt(f));)f++;var G=!1;if(f<w){var re=h.charAt(f);re!=="-"&&re!=="+"||(f++,re==="-"&&(G=!0))}for(var xe=new N,Ae=0,tt=0,Nt=0,Ut=!1;!(f>=w);){var xs=h.charAt(f);if(f++,vs.isDigit(xs)){var $s=xs-"0";xe.selfMultiply(N.TEN),xe.selfAdd($s),Ae++}else{if(xs!=="."){if(xs==="e"||xs==="E"){var bn=h.substring(f);try{Nt=_s.parseInt(bn)}catch(si){throw si instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+bn+" in string "+h):si}break}throw new NumberFormatException("Unexpected character '"+xs+"' at position "+f+" in string "+h)}tt=Ae,Ut=!0}}var da=xe;Ut||(tt=Ae);var wa=Ae-tt-Nt;if(wa===0)da=xe;else if(wa>0){var Lr=N.TEN.pow(wa);da=xe.divide(Lr)}else if(wa<0){var ur=N.TEN.pow(-wa);da=xe.multiply(ur)}return G?da.negate():da}},{key:"createNaN",value:function(){return new N(Ee.NaN,Ee.NaN)}},{key:"copy",value:function(h){return new N(h)}},{key:"magnitude",value:function(h){var f=Math.abs(h),w=Math.log(f)/Math.log(10),G=Math.trunc(Math.floor(w));return 10*Math.pow(10,G)<=f&&(G+=1),G}},{key:"stringOfChar",value:function(h,f){for(var w=new rs,G=0;G<f;G++)w.append(h);return w.toString()}}])}();$t.PI=new $t(3.141592653589793,12246467991473532e-32),$t.TWO_PI=new $t(6.283185307179586,24492935982947064e-32),$t.PI_2=new $t(1.5707963267948966,6123233995736766e-32),$t.E=new $t(2.718281828459045,14456468917292502e-32),$t.NaN=new $t(Ee.NaN,Ee.NaN),$t.EPS=123259516440783e-46,$t.SPLIT=134217729,$t.MAX_PRINT_DIGITS=32,$t.TEN=$t.valueOf(10),$t.ONE=$t.valueOf(1),$t.SCI_NOT_EXPONENT_CHAR="E",$t.SCI_NOT_ZERO="0.0E0";var Ns=function(){function N(){l(this,N)}return i(N,null,[{key:"orientationIndex",value:function(h,f,w){var G=N.orientationIndexFilter(h,f,w);if(G<=1)return G;var re=$t.valueOf(f.x).selfAdd(-h.x),xe=$t.valueOf(f.y).selfAdd(-h.y),Ae=$t.valueOf(w.x).selfAdd(-f.x),tt=$t.valueOf(w.y).selfAdd(-f.y);return re.selfMultiply(tt).selfSubtract(xe.selfMultiply(Ae)).signum()}},{key:"signOfDet2x2",value:function(){if(arguments[3]instanceof $t&&arguments[2]instanceof $t&&arguments[0]instanceof $t&&arguments[1]instanceof $t){var h=arguments[1],f=arguments[2],w=arguments[3];return arguments[0].multiply(w).selfSubtract(h.multiply(f)).signum()}if(typeof arguments[3]=="number"&&typeof arguments[2]=="number"&&typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var G=arguments[0],re=arguments[1],xe=arguments[2],Ae=arguments[3],tt=$t.valueOf(G),Nt=$t.valueOf(re),Ut=$t.valueOf(xe),xs=$t.valueOf(Ae);return tt.multiply(xs).selfSubtract(Nt.multiply(Ut)).signum()}}},{key:"intersection",value:function(h,f,w,G){var re=new $t(h.y).selfSubtract(f.y),xe=new $t(f.x).selfSubtract(h.x),Ae=new $t(h.x).selfMultiply(f.y).selfSubtract(new $t(f.x).selfMultiply(h.y)),tt=new $t(w.y).selfSubtract(G.y),Nt=new $t(G.x).selfSubtract(w.x),Ut=ne
757w $t(w.x).selfMultiply(G.y).selfSubtract(new $t(G.x).selfMultiply(w.y)),xs=xe.multiply(Ut).selfSubtract(Nt.multiply(Ae)),$s=tt.multiply(Ae).selfSubtract(re.multiply(Ut)),bn=re.multiply(Nt).selfSubtract(tt.multiply(xe)),da=xs.selfDivide(bn).doubleValue(),wa=$s.selfDivide(bn).doubleValue();return Ee.isNaN(da)||Ee.isInfinite(da)||Ee.isNaN(wa)||Ee.isInfinite(wa)?null:new Re(da,wa)}},{key:"orientationIndexFilter",value:function(h,f,w){var G=null,re=(h.x-w.x)*(f.y-w.y),xe=(h.y-w.y)*(f.x-w.x),Ae=re-xe;if(re>0){if(xe<=0)return N.signum(Ae);G=re+xe}else{if(!(re<0)||xe>=0)return N.signum(Ae);G=-re-xe}var tt=N.DP_SAFE_EPSILON*G;return Ae>=tt||-Ae>=tt?N.signum(Ae):2}},{key:"signum",value:function(h){return h>0?1:h<0?-1:0}}])}();Ns.DP_SAFE_EPSILON=1e-15;var Ts=function(){return i(function N(){l(this,N)},[{key:"getM",value:function(N){if(this.hasM()){var h=this.getDimension()-this.getMeasures();return this.getOrdinate(N,h)}return Ee.NaN}},{key:"setOrdinate",value:function(N,h,f){}},{key:"getZ",value:function(N){return this.hasZ()?this.getOrdinate(N,2):Ee.NaN}},{key:"size",value:function(){}},{key:"getOrdinate",value:function(N,h){}},{key:"getCoordinate",value:function(){}},{key:"getCoordinateCopy",value:function(N){}},{key:"createCoordinate",value:function(){}},{key:"getDimension",value:function(){}},{key:"hasM",value:function(){return this.getMeasures()>0}},{key:"getX",value:function(N){}},{key:"hasZ",value:function(){return this.getDimension()-this.getMeasures()>2}},{key:"getMeasures",value:function(){return 0}},{key:"expandEnvelope",value:function(N){}},{key:"copy",value:function(){}},{key:"getY",value:function(N){}},{key:"toCoordinateArray",value:function(){}},{key:"interfaces_",get:function(){return[O]}}])}();Ts.X=0,Ts.Y=1,Ts.Z=2,Ts.M=3;var bs=function(){function N(){l(this,N)}return i(N,null,[{key:"index",value:function(h,f,w){return Ns.orientationIndex(h,f,w)}},{key:"isCCW",value:function(){if(arguments[0]instanceof Array){var h=arguments[0],f=h.length-1;if(f<3)throw new te("Ring has fewer than 4 points, so orientation cannot be determined");for(var w=h[0],G=0,re=1;re<=f;re++){var xe=h[re];xe.y>w.y&&(w=xe,G=re)}var Ae=G;do(Ae-=1)<0&&(Ae=f);while(h[Ae].equals2D(w)&&Ae!==G);var tt=G;do tt=(tt+1)%f;while(h[tt].equals2D(w)&&tt!==G);var Nt=h[Ae],Ut=h[tt];if(Nt.equals2D(w)||Ut.equals2D(w)||Nt.equals2D(Ut))return!1;var xs=N.index(Nt,w,Ut);return xs===0?Nt.x>Ut.x:xs>0}if(zt(arguments[0],Ts)){var $s=arguments[0],bn=$s.size()-1;if(bn<3)throw new te("Ring has fewer than 4 points, so orientation cannot be determined");for(var da=$s.getCoordinate(0),wa=0,Lr=1;Lr<=bn;Lr++){var ur=$s.getCoordinate(Lr);ur.y>da.y&&(da=ur,wa=Lr)}var si=null,Ei=wa;do(Ei-=1)<0&&(Ei=bn),si=$s.getCoordinate(Ei);while(si.equals2D(da)&&Ei!==wa);var hr=null,mo=wa;do mo=(mo+1)%bn,hr=$s.getCoordinate(mo);while(hr.equals2D(da)&&mo!==wa);if(si.equals2D(da)||hr.equals2D(da)||si.equals2D(hr))return!1;var Ud=N.index(si,da,hr);return Ud===0?si.x>hr.x:Ud>0}}}])}();bs.CLOCKWISE=-1,bs.RIGHT=bs.CLOCKWISE,bs.COUNTERCLOCKWISE=1,bs.LEFT=bs.COUNTERCLOCKWISE,bs.COLLINEAR=0,bs.STRAIGHT=bs.COLLINEAR;var en=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"getCoordinate",value:function(){return this._minCoord}},{key:"getRightmostSide",value:function(N,h){var f=this.getRightmostSideOfSegment(N,h);return f<0&&(f=this.getRightmostSideOfSegment(N,h-1)),f<0&&(this._minCoord=null,this.checkForRightmostCoordinate(N)),f}},{key:"findRightmostEdgeAtVertex",value:function(){var N=this._minDe.getEdge().getCoordinates();ke.isTrue(this._minIndex>0&&this._minIndex<N.length,"rightmost point expected to be interior vertex of edge");var h=N[this._minIndex-1],f=N[this._minIndex+1],w=bs.index(this._minCoord,f,h),G=!1;(h.y<this._minCoord.y&&f.y<this._minCoord.y&&w===bs.COUNTERCLOCKWISE||h.y>this._minCoord.y&&f.y>this._minCoord.y&&w===bs.CLOCKWISE)&&(G=!0),G&&(this._minIndex=this._minIndex-1)}},{key:"getRightmostSideOfSegment",value:function(N,h){var f=N.getEdge().getCoordinates();if(h<0||h+1>=f.length||f[h].y===f[h+1].y)return-1;var w=Xe.LEFT;return f[h].y<f[h+1].y&&(w=Xe.RIGHT),w}},{key:"getEdge",value:function(){return this._orientedDe}},{key:"checkForRightmostCoordinate",value:function(N){for(var h=N.getEdge().getCoordinates(),f=0;f<h.length-1;f++)(this._minCoord===null||h[f].x>this._minCoord.x)&&(this._minDe=N,this._minIndex=f,this._minCoord=h[f])}},{key:"findRightmostEdgeAtNode",value:function(){var N=this._minDe.getNode().getEdges();this._minDe=N.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)}},{key:"findEdge",value:function(N){for(var h=N.iterator();h.hasNext();){var f=h.next();f.isForward()&&this.checkForRightmostCoordinate(f)}ke.isTrue(this._minIndex!==0||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),this._minIndex===0?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe,this.getRightmostSide(this._minDe,this._minIndex)===Xe.LEFT&&(this._orientedDe=this._minDe.getSym()
757)}}],[{key:"constructor_",value:function(){this._minIndex=-1,this._minCoord=null,this._minDe=null,this._orientedDe=null}}])}(),Jt=function(N){function h(f,w){var G;return l(this,h),(G=a(this,h,[w?f+" [ "+w+" ]":f])).pt=w?new Re(w):void 0,G.name=Object.keys({TopologyException:h})[0],G}return x(h,N),i(h,[{key:"getCoordinate",value:function(){return this.pt}}])}(we),Vs=function(){return i(function N(){l(this,N),this.array=[]},[{key:"addLast",value:function(N){this.array.push(N)}},{key:"removeFirst",value:function(){return this.array.shift()}},{key:"isEmpty",value:function(){return this.array.length===0}}])}(),ps=function(N){function h(f){var w;return l(this,h),(w=a(this,h)).array=[],f instanceof Qe&&w.addAll(f),w}return x(h,N),i(h,[{key:"interfaces_",get:function(){return[Dt,Qe]}},{key:"ensureCapacity",value:function(){}},{key:"add",value:function(f){return arguments.length===1?this.array.push(f):this.array.splice(arguments[0],0,arguments[1]),!0}},{key:"clear",value:function(){this.array=[]}},{key:"addAll",value:function(f){var w,G=_(f);try{for(G.s();!(w=G.n()).done;){var re=w.value;this.array.push(re)}}catch(xe){G.e(xe)}finally{G.f()}}},{key:"set",value:function(f,w){var G=this.array[f];return this.array[f]=w,G}},{key:"iterator",value:function(){return new nt(this)}},{key:"get",value:function(f){if(f<0||f>=this.size())throw new Be;return this.array[f]}},{key:"isEmpty",value:function(){return this.array.length===0}},{key:"sort",value:function(f){f?this.array.sort(function(w,G){return f.compare(w,G)}):this.array.sort()}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}},{key:"remove",value:function(f){for(var w=0,G=this.array.length;w<G;w++)if(this.array[w]===f)return!!this.array.splice(w,1);return!1}},{key:Symbol.iterator,value:function(){return this.array.values()}}])}(Dt),nt=function(){return i(function N(h){l(this,N),this.arrayList=h,this.position=0},[{key:"next",value:function(){if(this.position===this.arrayList.size())throw new ht;return this.arrayList.get(this.position++)}},{key:"hasNext",value:function(){return this.position<this.arrayList.size()}},{key:"set",value:function(N){return this.arrayList.set(this.position-1,N)}},{key:"remove",value:function(){this.arrayList.remove(this.arrayList.get(this.position))}}])}(),ts=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"clearVisitedEdges",value:function(){for(var N=this._dirEdgeList.iterator();N.hasNext();)N.next().setVisited(!1)}},{key:"getRightmostCoordinate",value:function(){return this._rightMostCoord}},{key:"computeNodeDepth",value:function(N){for(var h=null,f=N.getEdges().iterator();f.hasNext();){var w=f.next();if(w.isVisited()||w.getSym().isVisited()){h=w;break}}if(h===null)throw new Jt("unable to find edge to compute depths at "+N.getCoordinate());N.getEdges().computeDepths(h);for(var G=N.getEdges().iterator();G.hasNext();){var re=G.next();re.setVisited(!0),this.copySymDepths(re)}}},{key:"computeDepth",value:function(N){this.clearVisitedEdges();var h=this._finder.getEdge();h.getNode(),h.getLabel(),h.setEdgeDepths(Xe.RIGHT,N),this.copySymDepths(h),this.computeDepths(h)}},{key:"create",value:function(N){this.addReachable(N),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()}},{key:"findResultEdges",value:function(){for(var N=this._dirEdgeList.iterator();N.hasNext();){var h=N.next();h.getDepth(Xe.RIGHT)>=1&&h.getDepth(Xe.LEFT)<=0&&!h.isInteriorAreaEdge()&&h.setInResult(!0)}}},{key:"computeDepths",value:function(N){var h=new as,f=new Vs,w=N.getNode();for(f.addLast(w),h.add(w),N.setVisited(!0);!f.isEmpty();){var G=f.removeFirst();h.add(G),this.computeNodeDepth(G);for(var re=G.getEdges().iterator();re.hasNext();){var xe=re.next().getSym();if(!xe.isVisited()){var Ae=xe.getNode();h.contains(Ae)||(f.addLast(Ae),h.add(Ae))}}}}},{key:"compareTo",value:function(N){var h=N;return this._rightMostCoord.x<h._rightMostCoord.x?-1:this._rightMostCoord.x>h._rightMostCoord.x?1:0}},{key:"getEnvelope",value:function(){if(this._env===null){for(var N=new ft,h=this._dirEdgeList.iterator();h.hasNext();)for(var f=h.next().getEdge().getCoordinates(),w=0;w<f.length-1;w++)N.expandToInclude(f[w]);this._env=N}return this._env}},{key:"addReachable",value:function(N){var h=new Rt;for(h.add(N);!h.empty();){var f=h.pop();this.add(f,h)}}},{key:"copySymDepths",value:function(N){var h=N.getSym();h.setDepth(Xe.LEFT,N.getDepth(Xe.RIGHT)),h.setDepth(Xe.RIGHT,N.getDepth(Xe.LEFT))}},{key:"add",value:function(N,h){N.setVisited(!0),this._nodes.add(N);for(var f=N.getEdges().iterator();f.hasNext();){var w=f.next();this._dirEdgeList.add(w);var G=w.getSym().getNode();G.isVisited()||h.push(G)}}},{key:"getNodes",value:function(){return this._nodes}},{key:"getDirectedEdges",value:function(){return this._dirEdgeList}},{key:"interfaces_",get:function(){return[H]}}
757],[{key:"constructor_",value:function(){this._finder=null,this._dirEdgeList=new ps,this._nodes=new ps,this._rightMostCoord=null,this._env=null,this._finder=new en}}])}(),ds=function(){return i(function N(){l(this,N)},null,[{key:"intersection",value:function(N,h,f,w){var G=N.x<h.x?N.x:h.x,re=N.y<h.y?N.y:h.y,xe=N.x>h.x?N.x:h.x,Ae=N.y>h.y?N.y:h.y,tt=f.x<w.x?f.x:w.x,Nt=f.y<w.y?f.y:w.y,Ut=f.x>w.x?f.x:w.x,xs=f.y>w.y?f.y:w.y,$s=((G>tt?G:tt)+(xe<Ut?xe:Ut))/2,bn=((re>Nt?re:Nt)+(Ae<xs?Ae:xs))/2,da=N.x-$s,wa=N.y-bn,Lr=h.x-$s,ur=h.y-bn,si=f.x-$s,Ei=f.y-bn,hr=w.x-$s,mo=w.y-bn,Ud=wa-ur,mc=Lr-da,_i=da*ur-Lr*wa,sl=Ei-mo,Ba=hr-si,xd=si*mo-hr*Ei,nl=Ud*Ba-sl*mc,so=(mc*xd-Ba*_i)/nl,Qc=(sl*_i-Ud*xd)/nl;return Ee.isNaN(so)||Ee.isInfinite(so)||Ee.isNaN(Qc)||Ee.isInfinite(Qc)?null:new Re(so+$s,Qc+bn)}}])}(),Is=function(){return i(function N(){l(this,N)},null,[{key:"arraycopy",value:function(N,h,f,w,G){for(var re=0,xe=h;xe<h+G;xe++)f[w+re]=N[xe],re++}},{key:"getProperty",value:function(N){return{"line.separator":`
758`}[N]}}])}(),tn=function(){function N(){l(this,N)}return i(N,null,[{key:"log10",value:function(h){var f=Math.log(h);return Ee.isInfinite(f)||Ee.isNaN(f)?f:f/N.LOG_10}},{key:"min",value:function(h,f,w,G){var re=h;return f<re&&(re=f),w<re&&(re=w),G<re&&(re=G),re}},{key:"clamp",value:function(){if(typeof arguments[2]=="number"&&typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var h=arguments[0],f=arguments[1],w=arguments[2];return h<f?f:h>w?w:h}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var G=arguments[0],re=arguments[1],xe=arguments[2];return G<re?re:G>xe?xe:G}}},{key:"wrap",value:function(h,f){return h<0?f- -h%f:h%f}},{key:"max",value:function(){if(arguments.length===3){var h=arguments[1],f=arguments[2],w=arguments[0];return h>w&&(w=h),f>w&&(w=f),w}if(arguments.length===4){var G=arguments[1],re=arguments[2],xe=arguments[3],Ae=arguments[0];return G>Ae&&(Ae=G),re>Ae&&(Ae=re),xe>Ae&&(Ae=xe),Ae}}},{key:"average",value:function(h,f){return(h+f)/2}}])}();tn.LOG_10=Math.log(10);var wn=function(){function N(){l(this,N)}return i(N,null,[{key:"segmentToSegment",value:function(h,f,w,G){if(h.equals(f))return N.pointToSegment(h,w,G);if(w.equals(G))return N.pointToSegment(G,h,f);var re=!1;if(ft.intersects(h,f,w,G)){var xe=(f.x-h.x)*(G.y-w.y)-(f.y-h.y)*(G.x-w.x);if(xe===0)re=!0;else{var Ae=(h.y-w.y)*(G.x-w.x)-(h.x-w.x)*(G.y-w.y),tt=((h.y-w.y)*(f.x-h.x)-(h.x-w.x)*(f.y-h.y))/xe,Nt=Ae/xe;(Nt<0||Nt>1||tt<0||tt>1)&&(re=!0)}}else re=!0;return re?tn.min(N.pointToSegment(h,w,G),N.pointToSegment(f,w,G),N.pointToSegment(w,h,f),N.pointToSegment(G,h,f)):0}},{key:"pointToSegment",value:function(h,f,w){if(f.x===w.x&&f.y===w.y)return h.distance(f);var G=(w.x-f.x)*(w.x-f.x)+(w.y-f.y)*(w.y-f.y),re=((h.x-f.x)*(w.x-f.x)+(h.y-f.y)*(w.y-f.y))/G;if(re<=0)return h.distance(f);if(re>=1)return h.distance(w);var xe=((f.y-h.y)*(w.x-f.x)-(f.x-h.x)*(w.y-f.y))/G;return Math.abs(xe)*Math.sqrt(G)}},{key:"pointToLinePerpendicular",value:function(h,f,w){var G=(w.x-f.x)*(w.x-f.x)+(w.y-f.y)*(w.y-f.y),re=((f.y-h.y)*(w.x-f.x)-(f.x-h.x)*(w.y-f.y))/G;return Math.abs(re)*Math.sqrt(G)}},{key:"pointToSegmentString",value:function(h,f){if(f.length===0)throw new te("Line array must contain at least one vertex");for(var w=h.distance(f[0]),G=0;G<f.length-1;G++){var re=N.pointToSegment(h,f[G],f[G+1]);re<w&&(w=re)}return w}}])}(),Gs=function(){return i(function N(){l(this,N)},[{key:"create",value:function(){if(arguments.length===1)arguments[0]instanceof Array||zt(arguments[0],Ts);else if(arguments.length!==2){if(arguments.length===3){var N=arguments[0],h=arguments[1];return this.create(N,h)}}}}])}(),Ue=function(){return i(function N(){l(this,N)},[{key:"filter",value:function(N){}}])}(),Pe=function(){return i(function N(){l(this,N)},null,[{key:"ofLine",value:function(N){var h=N.size();if(h<=1)return 0;var f=0,w=new Re;N.getCoordinate(0,w);for(var G=w.x,re=w.y,xe=1;xe<h;xe++){N.getCoordinate(xe,w);var Ae=w.x,tt=w.y,Nt=Ae-G,Ut=tt-re;f+=Math.sqrt(Nt*Nt+Ut*Ut),G=Ae,re=tt}return f}}])}(),je=i(function N(){l(this,N)}),Ge=function(){function N(){l(this,N)}
758return i(N,null,[{key:"copyCoord",value:function(h,f,w,G){for(var re=Math.min(h.getDimension(),w.getDimension()),xe=0;xe<re;xe++)w.setOrdinate(G,xe,h.getOrdinate(f,xe))}},{key:"isRing",value:function(h){var f=h.size();return f===0||!(f<=3)&&h.getOrdinate(0,Ts.X)===h.getOrdinate(f-1,Ts.X)&&h.getOrdinate(0,Ts.Y)===h.getOrdinate(f-1,Ts.Y)}},{key:"scroll",value:function(){if(arguments.length===2){if(zt(arguments[0],Ts)&&Number.isInteger(arguments[1])){var h=arguments[0],f=arguments[1];N.scroll(h,f,N.isRing(h))}else if(zt(arguments[0],Ts)&&arguments[1]instanceof Re){var w=arguments[0],G=arguments[1],re=N.indexOf(G,w);if(re<=0)return null;N.scroll(w,re)}}else if(arguments.length===3){var xe=arguments[0],Ae=arguments[1],tt=arguments[2];if(Ae<=0)return null;for(var Nt=xe.copy(),Ut=tt?xe.size()-1:xe.size(),xs=0;xs<Ut;xs++)for(var $s=0;$s<xe.getDimension();$s++)xe.setOrdinate(xs,$s,Nt.getOrdinate((Ae+xs)%Ut,$s));if(tt)for(var bn=0;bn<xe.getDimension();bn++)xe.setOrdinate(Ut,bn,xe.getOrdinate(0,bn))}}},{key:"isEqual",value:function(h,f){var w=h.size();if(w!==f.size())return!1;for(var G=Math.min(h.getDimension(),f.getDimension()),re=0;re<w;re++)for(var xe=0;xe<G;xe++){var Ae=h.getOrdinate(re,xe),tt=f.getOrdinate(re,xe);if(h.getOrdinate(re,xe)!==f.getOrdinate(re,xe)&&(!Ee.isNaN(Ae)||!Ee.isNaN(tt)))return!1}return!0}},{key:"minCoordinateIndex",value:function(){if(arguments.length===1){var h=arguments[0];return N.minCoordinateIndex(h,0,h.size()-1)}if(arguments.length===3){for(var f=arguments[0],w=arguments[2],G=-1,re=null,xe=arguments[1];xe<=w;xe++){var Ae=f.getCoordinate(xe);(re===null||re.compareTo(Ae)>0)&&(re=Ae,G=xe)}return G}}},{key:"extend",value:function(h,f,w){var G=h.create(w,f.getDimension()),re=f.size();if(N.copy(f,0,G,0,re),re>0)for(var xe=re;xe<w;xe++)N.copy(f,re-1,G,xe,1);return G}},{key:"reverse",value:function(h){for(var f=h.size()-1,w=Math.trunc(f/2),G=0;G<=w;G++)N.swap(h,G,f-G)}},{key:"swap",value:function(h,f,w){if(f===w)return null;for(var G=0;G<h.getDimension();G++){var re=h.getOrdinate(f,G);h.setOrdinate(f,G,h.getOrdinate(w,G)),h.setOrdinate(w,G,re)}}},{key:"copy",value:function(h,f,w,G,re){for(var xe=0;xe<re;xe++)N.copyCoord(h,f+xe,w,G+xe)}},{key:"ensureValidRing",value:function(h,f){var w=f.size();return w===0?f:w<=3?N.createClosedRing(h,f,4):f.getOrdinate(0,Ts.X)===f.getOrdinate(w-1,Ts.X)&&f.getOrdinate(0,Ts.Y)===f.getOrdinate(w-1,Ts.Y)?f:N.createClosedRing(h,f,w+1)}},{key:"indexOf",value:function(h,f){for(var w=0;w<f.size();w++)if(h.x===f.getOrdinate(w,Ts.X)&&h.y===f.getOrdinate(w,Ts.Y))return w;return-1}},{key:"createClosedRing",value:function(h,f,w){var G=h.create(w,f.getDimension()),re=f.size();N.copy(f,0,G,0,re);for(var xe=re;xe<w;xe++)N.copy(f,0,G,xe,1);return G}},{key:"minCoordinate",value:function(h){for(var f=null,w=0;w<h.size();w++){var G=h.getCoordinate(w);(f===null||f.compareTo(G)>0)&&(f=G)}return f}}])}(),De=function(){function N(){l(this,N)}return i(N,null,[{key:"toDimensionSymbol",value:function(h){switch(h){case N.FALSE:return N.SYM_FALSE;case N.TRUE:return N.SYM_TRUE;case N.DONTCARE:return N.SYM_DONTCARE;case N.P:return N.SYM_P;case N.L:return N.SYM_L;case N.A:return N.SYM_A}throw new te("Unknown dimension value: "+h)}},{key:"toDimensionValue",value:function(h){switch(vs.toUpperCase(h)){case N.SYM_FALSE:return N.FALSE;case N.SYM_TRUE:return N.TRUE;case N.SYM_DONTCARE:return N.DONTCARE;case N.SYM_P:return N.P;case N.SYM_L:return N.L;case N.SYM_A:return N.A}throw new te("Unknown dimension symbol: "+h)}}])}();De.P=0,De.L=1,De.A=2,De.FALSE=-1,De.TRUE=-2,De.DONTCARE=-3,De.SYM_FALSE="F",De.SYM_TRUE="T",De.SYM_DONTCARE="*",De.SYM_P="0",De.SYM_L="1",De.SYM_A="2";var bt=function(){return i(function N(){l(this,N)},[{key:"filter",value:function(N){}}])}(),Ct=function(){return i(function N(){l(this,N)},[{key:"filter",value:function(N,h){}},{key:"isDone",value:function(){}},{key:"isGeometryChanged",value:function(){}}])}(),pe=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"computeEnvelopeInternal",value:function(){return this.isEmpty()?new ft:this._points.expandEnvelope(ne
758w ft)}},{key:"isRing",value:function(){return this.isClosed()&&this.isSimple()}},{key:"getCoordinates",value:function(){return this._points.toCoordinateArray()}},{key:"copyInternal",value:function(){return new h(this._points.copy(),this._factory)}},{key:"equalsExact",value:function(){if(arguments.length===2&&typeof arguments[1]=="number"&&arguments[0]instanceof Fe){var f=arguments[0],w=arguments[1];if(!this.isEquivalentClass(f))return!1;var G=f;if(this._points.size()!==G._points.size())return!1;for(var re=0;re<this._points.size();re++)if(!this.equal(this._points.getCoordinate(re),G._points.getCoordinate(re),w))return!1;return!0}return P(h,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){for(var f=0;f<Math.trunc(this._points.size()/2);f++){var w=this._points.size()-1-f;if(!this._points.getCoordinate(f).equals(this._points.getCoordinate(w))){if(this._points.getCoordinate(f).compareTo(this._points.getCoordinate(w))>0){var G=this._points.copy();Ge.reverse(G),this._points=G}return null}}}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this._points.getCoordinate(0)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?De.FALSE:0}},{key:"isClosed",value:function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))}},{key:"reverseInternal",value:function(){var f=this._points.copy();return Ge.reverse(f),this.getFactory().createLineString(f)}},{key:"getEndPoint",value:function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)}},{key:"getTypeCode",value:function(){return Fe.TYPECODE_LINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getLength",value:function(){return Pe.ofLine(this._points)}},{key:"getNumPoints",value:function(){return this._points.size()}},{key:"compareToSameClass",value:function(){if(arguments.length===1){for(var f=arguments[0],w=0,G=0;w<this._points.size()&&G<f._points.size();){var re=this._points.getCoordinate(w).compareTo(f._points.getCoordinate(G));if(re!==0)return re;w++,G++}return w<this._points.size()?1:G<f._points.size()?-1:0}if(arguments.length===2){var xe=arguments[0];return arguments[1].compare(this._points,xe._points)}}},{key:"apply",value:function(){if(zt(arguments[0],Ue))for(var f=arguments[0],w=0;w<this._points.size();w++)f.filter(this._points.getCoordinate(w));else if(zt(arguments[0],Ct)){var G=arguments[0];if(this._points.size()===0)return null;for(var re=0;re<this._points.size()&&(G.filter(this._points,re),!G.isDone());re++);G.isGeometryChanged()&&this.geometryChanged()}else zt(arguments[0],bt)?arguments[0].filter(this):zt(arguments[0],J)&&arguments[0].filter(this)}},{key:"getBoundary",value:function(){throw new _t}},{key:"isEquivalentClass",value:function(f){return f instanceof h}},{key:"getCoordinateN",value:function(f){return this._points.getCoordinate(f)}},{key:"getGeometryType",value:function(){return Fe.TYPENAME_LINESTRING}},{key:"getCoordinateSequence",value:function(){return this._points}},{key:"isEmpty",value:function(){return this._points.size()===0}},{key:"init",value:function(f){if(f===null&&(f=this.getFactory().getCoordinateSequenceFactory().create([])),f.size()===1)throw new te("Invalid number of points in LineString (found "+f.size()+" - must be 0 or >= 2)");this._points=f}},{key:"isCoordinate",value:function(f){for(var w=0;w<this._points.size();w++)if(this._points.getCoordinate(w).equals(f))return!0;return!1}},{key:"getStartPoint",value:function(){return this.isEmpty()?null:this.getPointN(0)}},{key:"getPointN",value:function(f){return this.getFactory().createPoint(this._points.getCoordinate(f))}},{key:"interfaces_",get:function(){return[je]}}],[{key:"constructor_",value:function(){if(this._points=null,arguments.length!==0){if(arguments.length===2){var f=arguments[0],w=arguments[1];Fe.constructor_.call(this,w),this.init(f)}}}}])}(Fe),wt=i(function N(){l(this,N)}),Zt=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"computeEnvelopeInternal",value:function(){if(this.isEmpty())return new ft;var f=new ft;return f.expandToInclude(this._coordinates.getX(0),this._coordinates.getY(0)),f}},{key:"getCoordinates",value:function(){return this.isEmpty()?[]:[this.getCoordinate()]}},{key:"copyInternal",value:function(){return new h(this._coordinates.copy(),this._factory)}},{key:"equalsExact",value:function(){if(arguments.length===2&&typeof arguments[1]=="number"&&arguments[0]instanceof Fe){var f=arguments[0],w=arguments[1];return!!this.isEquivalentClass(f)&&(!(!this.isEmpty()||!f.isEmpty())||this.isEmpty()===f.isEmpty()&&this.equal(f.getCoordinate(),this.getCoordinate(),w))}return P(h,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){}},{key:"getCoordinate",value:function(){return this._coordinates.size()!==0?this._coordinates.getCoordinate(0):null}},{key:"getBoundaryDimension",value:function(){return De.FALSE}},{key:"reverseInternal",value:function(){return this.getFactory().createPoint(this._coordinates.copy())}},{key:"getTypeCode",value:function(){return Fe.TYPECODE_POINT}},{key:"getDimension",value:function(){return 0}},{key:"getNumPoints",value:function(){return this.isEmpty()?0:1}},{key:"getX",value:function(){if(this.getCoordinate()===null)throw new IllegalStateException("getX called on empty Point");return this.getCoordinate().x}},{key:"compareToSameClass",value:function(){if(arguments.length===1){var f=arguments[0];return this.getCoordinate().compareTo(f.getCoordinate())}if(arguments.length===2){var w=arguments[0];return arguments[1].compare(this._coordinates,w._coordinates)}}},{key:"apply",value:function(){if(zt(arguments[0],Ue)){var f=arguments[0];if(this.isEmpty())return null;f.filter(this.getCoordinate())}else if(zt(arguments[0],Ct)){var w=arguments[0];if(this.isEmpty())return null;w.filter(this._coordinates,0),w.isGeometryChanged()&&this.geometryChanged()}else zt(arguments[0],bt)?arguments[0].filter(this):zt(arguments[0],J)&&arguments[0].filter(this)}},{key:"getBoundary",value:function(){return this.getFactory().createGeometryCollection()}},{key:"getGeometryType",value:function(){return Fe.TYPENAME_POINT}},{key:"getCoordinateSequence",value:function(){return this._coordinates}},{key:"getY",value:function(){if(this.getCoordinate()===null)throw new IllegalStateException("getY called on empty Point");return this.getCoordinate().y}},{key:"isEmpty",value:function(){return this._coordinates.size()===0}},{key:"init",value:function(f){f===null&&(f=this.getFactory().getCoordinateSequenceFactory().create([])),ke.isTrue(f.size()<=1),this._coordinates=f}},{key:"isSimple",value:function(){return!0}},{key:"interfaces_",get:function(){return[wt]}}
758],[{key:"constructor_",value:function(){this._coordinates=null;var f=arguments[0],w=arguments[1];Fe.constructor_.call(this,w),this.init(f)}}])}(Fe),ys=function(){function N(){l(this,N)}return i(N,null,[{key:"ofRing",value:function(){if(arguments[0]instanceof Array){var h=arguments[0];return Math.abs(N.ofRingSigned(h))}if(zt(arguments[0],Ts)){var f=arguments[0];return Math.abs(N.ofRingSigned(f))}}},{key:"ofRingSigned",value:function(){if(arguments[0]instanceof Array){var h=arguments[0];if(h.length<3)return 0;for(var f=0,w=h[0].x,G=1;G<h.length-1;G++){var re=h[G].x-w,xe=h[G+1].y;f+=re*(h[G-1].y-xe)}return f/2}if(zt(arguments[0],Ts)){var Ae=arguments[0],tt=Ae.size();if(tt<3)return 0;var Nt=new Re,Ut=new Re,xs=new Re;Ae.getCoordinate(0,Ut),Ae.getCoordinate(1,xs);var $s=Ut.x;xs.x-=$s;for(var bn=0,da=1;da<tt-1;da++)Nt.y=Ut.y,Ut.x=xs.x,Ut.y=xs.y,Ae.getCoordinate(da+1,xs),xs.x-=$s,bn+=Ut.x*(Nt.y-xs.y);return bn/2}}}])}(),es=function(){return i(function N(){l(this,N)},null,[{key:"sort",value:function(){var N=arguments,h=arguments[0];if(arguments.length===1)h.sort(function($s,bn){return $s.compareTo(bn)});else if(arguments.length===2)h.sort(function($s,bn){return N[1].compare($s,bn)});else if(arguments.length===3){var f=h.slice(arguments[1],arguments[2]);f.sort();var w=h.slice(0,arguments[1]).concat(f,h.slice(arguments[2],h.length));h.splice(0,h.length);var G,re=_(w);try{for(re.s();!(G=re.n()).done;){var xe=G.value;h.push(xe)}}catch($s){re.e($s)}finally{re.f()}}else if(arguments.length===4){var Ae=h.slice(arguments[1],arguments[2]);Ae.sort(function($s,bn){return N[3].compare($s,bn)});var tt=h.slice(0,arguments[1]).concat(Ae,h.slice(arguments[2],h.length));h.splice(0,h.length);var Nt,Ut=_(tt);try{for(Ut.s();!(Nt=Ut.n()).done;){var xs=Nt.value;h.push(xs)}}catch($s){Ut.e($s)}finally{Ut.f()}}}},{key:"asList",value:function(N){var h,f=new ps,w=_(N);try{for(w.s();!(h=w.n()).done;){var G=h.value;f.add(G)}}catch(re){w.e(re)}finally{w.f()}return f}},{key:"copyOf",value:function(N,h){return N.slice(0,h)}}])}(),is=i(function N(){l(this,N)}),Ws=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"computeEnvelopeInternal",value:function(){return this._shell.getEnvelopeInternal()}},{key:"getCoordinates",value:function(){if(this.isEmpty())return[];for(var f=new Array(this.getNumPoints()).fill(null),w=-1,G=this._shell.getCoordinates(),re=0;re<G.length;re++)f[++w]=G[re];for(var xe=0;xe<this._holes.length;xe++)for(var Ae=this._holes[xe].getCoordinates(),tt=0;tt<Ae.length;tt++)f[++w]=Ae[tt];return f}},{key:"getArea",value:function(){var f=0;f+=ys.ofRing(this._shell.getCoordinateSequence());for(var w=0;w<this._holes.length;w++)f-=ys.ofRing(this._holes[w].getCoordinateSequence());return f}},{key:"copyInternal",value:function(){for(var f=this._shell.copy(),w=new Array(this._holes.length).fill(null),G=0;G<this._holes.length;G++)w[G]=this._holes[G].copy();return new h(f,w,this._factory)}},{key:"isRectangle",value:function(){if(this.getNumInteriorRing()!==0||this._shell===null||this._shell.getNumPoints()!==5)return!1;for(var f=this._shell.getCoordinateSequence(),w=this.getEnvelopeInternal(),G=0;G<5;G++){var re=f.getX(G);if(re!==w.getMinX()&&re!==w.getMaxX())return!1;var xe=f.getY(G);if(xe!==w.getMinY()&&xe!==w.getMaxY())return!1}for(var Ae=f.getX(0),tt=f.getY(0),Nt=1;Nt<=4;Nt++){var Ut=f.getX(Nt),xs=f.getY(Nt);if(Ut!==Ae==(xs!==tt))return!1;Ae=Ut,tt=xs}return!0}},{key:"equalsExact",value:function(){if(arguments.length===2&&typeof arguments[1]=="number"&&arguments[0]instanceof Fe){var f=arguments[0],w=arguments[1];if(!this.isEquivalentClass(f))return!1;var G=f,re=this._shell,xe=G._shell;if(!re.equalsExact(xe,w)||this._holes.length!==G._holes.length)return!1;for(var Ae=0;Ae<this._holes.length;Ae++)if(!this._holes[Ae].equalsExact(G._holes[Ae],w))return!1;return!0}return P(h,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){if(arguments.length===0){this._shell=this.normalized(this._shell,!0);for(var f=0;f<this._holes.length;f++)this._holes[f]=this.normalized(this._holes[f],!1);es.sort(this._holes)}else if(arguments.length===2){var w=arguments[0],G=arguments[1];if(w.isEmpty())return null;var re=w.getCoordinateSequence(),xe=Ge.minCoordinateIndex(re,0,re.size()-2);Ge.scroll(re,xe,!0),bs.isCCW(re)===G&&Ge.reverse(re)}}},{key:"getCoordinate",value:function(){return this._shell.getCoordinate()}},{key:"getNumInteriorRing",value:function(){return this._holes.length}},{key:"getBoundaryDimension",value:function(){return 1}},{key:"reverseInternal",value:function(){for(var f=this.getExteriorRing().reverse(),w=new Array(this.getNumInteriorRing()).fill(null),G=0;G<w.length;G++)w[G]=this.getInteriorRingN(G).reverse();return this.getFactory().createPolygon(f,w)}},{key:"getTypeCode",value:function(){return Fe.TYPECODE_POLYGON}},{key:"getDimension",value:function(){return 2}},{key:"getLength",value:function(){var f=0;f+=this._shell.getLength();for(var w=0;w<this._holes.length;w++)f+=this._holes[w].getLength();return f}},{key:"getNumPoints",value:function(){for(var f=this._shell.getNumPoints(),w=0;w<this._holes.length;w++)f+=this._holes[w].getNumPoints();return f}},{key:"convexHull",value:function(){return this.getExteriorRing().convexHull()}},{key:"normalized",value:function(f,w){var G=f.copy();return this.normalize(G,w),G}},{key:"compareToSameClass",value:function(){if(arguments.length===1){var f=arguments[0],w=this._shell,G=f._shell;return w.compareToSameClass(G)}if(arguments.length===2){var re=arguments[1],xe=arguments[0],Ae=this._shell,tt=xe._shell,Nt=Ae.compareToSameClass(tt,re);if(Nt!==0)return Nt;for(var Ut=this.getNumInteriorRing(),xs=xe.getNumInteriorRing(),$s=0;$s<Ut&&$s<xs;){var bn=this.getInteriorRingN($s),da=xe.getInteriorRingN($s),wa=bn.compareToSameClass(da,re);if(wa!==0)return wa;$s++}return $s<Ut?1:$s<xs?-1:0}}},{key:"apply",value:function(){if(zt(arguments[0],Ue)){var f=arguments[0];this._shell.apply(f);for(var w=0;w<this._holes.length;w++)this._holes[w].apply(f)}else if(zt(arguments[0],Ct)){var G=arguments[0];if(this._shell.apply(G),!G.isDone())for(var re=0;re<this._holes.length&&(this._holes[re].apply(G),!G.isDone());re++);G.isGeometryChanged()&&this.geometryChanged()}else if(zt(arguments[0],bt))arguments[0].filter(this);else if(zt(arguments[0],J)){var xe=arguments[0];xe.filter(this),this._shell.apply(xe);for(var Ae=0;Ae<this._holes.length;Ae++)this._holes[Ae].apply(xe)}}},{key:"getBoundary",value:function(){if(this.isEmpty())return this.getFactory().createMultiLineString();var f=new Array(this._holes.length+1).fill(null);f[0]=this._shell;for(var w=0;w<this._holes.length;w++)f[w+1]=this._holes[w];return f.length<=1?this.getFactory().createLinearRing(f[0].getCoordinateSequence()):this.getFactory().createMultiLineString(f)}},{key:"getGeometryType",value:function(){return Fe.TYPENAME_POLYGON}},{key:"getExteriorRing",value:function(){return this._shell}},{key:"isEmpty",value:function(){return this._shell.isEmpty()}},{key:"getInteriorRingN",value:function(f){return this._holes[f]}},{key:"interfaces_",get:function(){return[is]}}
758],[{key:"constructor_",value:function(){this._shell=null,this._holes=null;var f=arguments[0],w=arguments[1],G=arguments[2];if(Fe.constructor_.call(this,G),f===null&&(f=this.getFactory().createLinearRing()),w===null&&(w=[]),Fe.hasNullElements(w))throw new te("holes must not contain null elements");if(f.isEmpty()&&Fe.hasNonEmptyElements(w))throw new te("shell is empty but holes are not");this._shell=f,this._holes=w}}])}(Fe),an=function(N){function h(){return l(this,h),a(this,h,arguments)}return x(h,N),i(h)}(He),ya=function(N){function h(f){var w;return l(this,h),(w=a(this,h)).array=[],f instanceof Qe&&w.addAll(f),w}return x(h,N),i(h,[{key:"contains",value:function(f){var w,G=_(this.array);try{for(G.s();!(w=G.n()).done;)if(w.value.compareTo(f)===0)return!0}catch(re){G.e(re)}finally{G.f()}return!1}},{key:"add",value:function(f){if(this.contains(f))return!1;for(var w=0,G=this.array.length;w<G;w++)if(this.array[w].compareTo(f)===1)return!!this.array.splice(w,0,f);return this.array.push(f),!0}},{key:"addAll",value:function(f){var w,G=_(f);try{for(G.s();!(w=G.n()).done;){var re=w.value;this.add(re)}}catch(xe){G.e(xe)}finally{G.f()}return!0}},{key:"remove",value:function(){throw new _t}},{key:"size",value:function(){return this.array.length}},{key:"isEmpty",value:function(){return this.array.length===0}},{key:"toArray",value:function(){return this.array.slice()}},{key:"iterator",value:function(){return new Hs(this.array)}}])}(an),Hs=function(){return i(function N(h){l(this,N),this.array=h,this.position=0},[{key:"next",value:function(){if(this.position===this.array.length)throw new ht;return this.array[this.position++]}},{key:"hasNext",value:function(){return this.position<this.array.length}},{key:"remove",value:function(){throw new _t}}])}(),xt=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"computeEnvelopeInternal",value:function(){for(var f=new ft,w=0;w<this._geometries.length;w++)f.expandToInclude(this._geometries[w].getEnvelopeInternal());return f}},{key:"getGeometryN",value:function(f){return this._geometries[f]}},{key:"getCoordinates",value:function(){for(var f=new Array(this.getNumPoints()).fill(null),w=-1,G=0;G<this._geometries.length;G++)for(var re=this._geometries[G].getCoordinates(),xe=0;xe<re.length;xe++)f[++w]=re[xe];return f}},{key:"getArea",value:function(){for(var f=0,w=0;w<this._geometries.length;w++)f+=this._geometries[w].getArea();return f}},{key:"copyInternal",value:function(){for(var f=new Array(this._geometries.length).fill(null),w=0;w<f.length;w++)f[w]=this._geometries[w].copy();return new h(f,this._factory)}},{key:"equalsExact",value:function(){if(arguments.length===2&&typeof arguments[1]=="number"&&arguments[0]instanceof Fe){var f=arguments[0],w=arguments[1];if(!this.isEquivalentClass(f))return!1;var G=f;if(this._geometries.length!==G._geometries.length)return!1;for(var re=0;re<this._geometries.length;re++)if(!this._geometries[re].equalsExact(G._geometries[re],w))return!1;return!0}return P(h,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){for(var f=0;f<this._geometries.length;f++)this._geometries[f].normalize();es.sort(this._geometries)}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this._geometries[0].getCoordinate()}},{key:"getBoundaryDimension",value:function(){for(var f=De.FALSE,w=0;w<this._geometries.length;w++)f=Math.max(f,this._geometries[w].getBoundaryDimension());return f}},{key:"reverseInternal",value:function(){for(var f=this._geometries.length,w=new ps(f),G=0;G<f;G++)w.add(this._geometries[G].reverse());return this.getFactory().buildGeometry(w)}},{key:"getTypeCode",value:function(){return Fe.TYPECODE_GEOMETRYCOLLECTION}},{key:"getDimension",value:function(){for(var f=De.FALSE,w=0;w<this._geometries.length;w++)f=Math.max(f,this._geometries[w].getDimension());return f}},{key:"getLength",value:function(){for(var f=0,w=0;w<this._geometries.length;w++)f+=this._geometries[w].getLength();return f}},{key:"getNumPoints",value:function(){for(var f=0,w=0;w<this._geometries.length;w++)f+=this._geometries[w].getNumPoints();return f}},{key:"getNumGeometries",value:function(){return this._geometries.length}},{key:"compareToSameClass",value:function(){if(arguments.length===1){var f=arguments[0],w=new ya(es.asList(this._geometries)),G=new ya(es.asList(f._geometries));return this.compare(w,G)}if(arguments.length===2){for(var re=arguments[1],xe=arguments[0],Ae=this.getNumGeometries(),tt=xe.getNumGeometries(),Nt=0;Nt<Ae&&Nt<tt;){var Ut=this.getGeometryN(Nt),xs=xe.getGeometryN(Nt),$s=Ut.compareToSameClass(xs,re);if($s!==0)return $s;Nt++}return Nt<Ae?1:Nt<tt?-1:0}}},{key:"apply",value:function(){if(zt(arguments[0],Ue))for(var f=arguments[0],w=0;w<this._geometries.length;w++)this._geometries[w].apply(f);else if(zt(arguments[0],Ct)){var G=arguments[0];if(this._geometries.length===0)return null;for(var re=0;re<this._geometries.length&&(this._geometries[re].apply(G),!G.isDone());re++);G.isGeometryChanged()&&this.geometryChanged()}else if(zt(arguments[0],bt)){var xe=arguments[0];xe.filter(this);for(var Ae=0;Ae<this._geometries.length;Ae++)this._geometries[Ae].apply(xe)}else if(zt(arguments[0],J)){var tt=arguments[0];tt.filter(this);for(var Nt=0;Nt<this._geometries.length;Nt++)this._geometries[Nt].apply(tt)}}},{key:"getBoundary",value:function(){return Fe.checkNotGeometryCollection(this),ke.shouldNeverReachHere(),null}},{key:"getGeometryType",value:function(){return Fe.TYPENAME_GEOMETRYCOLLECTION}},{key:"isEmpty",value:function(){for(var f=0;f<this._geometries.length;f++)if(!this._geometries[f].isEmpty())return!1;return!0}}
758],[{key:"constructor_",value:function(){if(this._geometries=null,arguments.length!==0){if(arguments.length===2){var f=arguments[0],w=arguments[1];if(Fe.constructor_.call(this,w),f===null&&(f=[]),Fe.hasNullElements(f))throw new te("geometries must not contain null elements");this._geometries=f}}}}])}(Fe),os=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"copyInternal",value:function(){for(var f=new Array(this._geometries.length).fill(null),w=0;w<f.length;w++)f[w]=this._geometries[w].copy();return new h(f,this._factory)}},{key:"isValid",value:function(){return!0}},{key:"equalsExact",value:function(){if(arguments.length===2&&typeof arguments[1]=="number"&&arguments[0]instanceof Fe){var f=arguments[0],w=arguments[1];return!!this.isEquivalentClass(f)&&P(h,"equalsExact",this,1).call(this,f,w)}return P(h,"equalsExact",this,1).apply(this,arguments)}},{key:"getCoordinate",value:function(){if(arguments.length===1&&Number.isInteger(arguments[0])){var f=arguments[0];return this._geometries[f].getCoordinate()}return P(h,"getCoordinate",this,1).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return De.FALSE}},{key:"getTypeCode",value:function(){return Fe.TYPECODE_MULTIPOINT}},{key:"getDimension",value:function(){return 0}},{key:"getBoundary",value:function(){return this.getFactory().createGeometryCollection()}},{key:"getGeometryType",value:function(){return Fe.TYPENAME_MULTIPOINT}},{key:"interfaces_",get:function(){return[wt]}}],[{key:"constructor_",value:function(){var f=arguments[0],w=arguments[1];xt.constructor_.call(this,f,w)}}])}(xt),Ls=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"copyInternal",value:function(){return new h(this._points.copy(),this._factory)}},{key:"getBoundaryDimension",value:function(){return De.FALSE}},{key:"isClosed",value:function(){return!!this.isEmpty()||P(h,"isClosed",this,1).call(this)}},{key:"reverseInternal",value:function(){var f=this._points.copy();return Ge.reverse(f),this.getFactory().createLinearRing(f)}},{key:"getTypeCode",value:function(){return Fe.TYPECODE_LINEARRING}},{key:"validateConstruction",value:function(){if(!this.isEmpty()&&!P(h,"isClosed",this,1).call(this))throw new te("Points of LinearRing do not form a closed linestring");if(this.getCoordinateSequence().size()>=1&&this.getCoordinateSequence().size()<h.MINIMUM_VALID_SIZE)throw new te("Invalid number of points in LinearRing (found "+this.getCoordinateSequence().size()+" - must be 0 or >= 4)")}},{key:"getGeometryType",value:function(){return Fe.TYPENAME_LINEARRING}}],[{key:"constructor_",value:function(){var f=arguments[0],w=arguments[1];pe.constructor_.call(this,f,w),this.validateConstruction()}}])}(pe);Ls.MINIMUM_VALID_SIZE=4;var Es=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"setOrdinate",value:function(f,w){switch(f){case h.X:this.x=w;break;case h.Y:this.y=w;break;default:throw new te("Invalid ordinate index: "+f)}}},{key:"getZ",value:function(){return Re.NULL_ORDINATE}},{key:"getOrdinate",value:function(f){switch(f){case h.X:return this.x;case h.Y:return this.y}throw new te("Invalid ordinate index: "+f)}},{key:"setZ",value:function(f){throw new te("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new h(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+")"}},{key:"setCoordinate",value:function(f){this.x=f.x,this.y=f.y,this.z=f.getZ()}}],[{key:"constructor_",value:function(){if(arguments.length===0)Re.constructor_.call(this);else if(arguments.length===1){if(arguments[0]instanceof h){var f=arguments[0];Re.constructor_.call(this,f.x,f.y)}else if(arguments[0]instanceof Re){var w=arguments[0];Re.constructor_.call(this,w.x,w.y)}}else if(arguments.length===2){var G=arguments[0],re=arguments[1];Re.constructor_.call(this,G,re,Re.NULL_ORDINATE)}}}])}(Re);Es.X=0,Es.Y=1,Es.Z=-1,Es.M=-1;var Qs=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(f,w){switch(f){case h.X:this.x=w;break;case h.Y:this.y=w;break;case h.M:this._m=w;break;default:throw new te("Invalid ordinate index: "+f)}}},{key:"setM",value:function(f){this._m=f}},{key:"getZ",value:function(){return Re.NULL_ORDINATE}},{key:"getOrdinate",value:function(f){switch(f){case h.X:return this.x;case h.Y:return this.y;case h.M:return this._m}throw new te("Invalid ordinate index: "+f)}},{key:"setZ",value:function(f){throw new te("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new h(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(f){this.x=f.x,this.y=f.y,this.z=f.getZ(),this._m=f.getM()}}
758],[{key:"constructor_",value:function(){if(this._m=null,arguments.length===0)Re.constructor_.call(this),this._m=0;else if(arguments.length===1){if(arguments[0]instanceof h){var f=arguments[0];Re.constructor_.call(this,f.x,f.y),this._m=f._m}else if(arguments[0]instanceof Re){var w=arguments[0];Re.constructor_.call(this,w.x,w.y),this._m=this.getM()}}else if(arguments.length===3){var G=arguments[0],re=arguments[1],xe=arguments[2];Re.constructor_.call(this,G,re,Re.NULL_ORDINATE),this._m=xe}}}])}(Re);Qs.X=0,Qs.Y=1,Qs.Z=-1,Qs.M=2;var Pn=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(f,w){switch(f){case Re.X:this.x=w;break;case Re.Y:this.y=w;break;case Re.Z:this.z=w;break;case Re.M:this._m=w;break;default:throw new te("Invalid ordinate index: "+f)}}},{key:"setM",value:function(f){this._m=f}},{key:"getOrdinate",value:function(f){switch(f){case Re.X:return this.x;case Re.Y:return this.y;case Re.Z:return this.getZ();case Re.M:return this.getM()}throw new te("Invalid ordinate index: "+f)}},{key:"copy",value:function(){return new h(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(f){this.x=f.x,this.y=f.y,this.z=f.getZ(),this._m=f.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,arguments.length===0)Re.constructor_.call(this),this._m=0;else if(arguments.length===1){if(arguments[0]instanceof h){var f=arguments[0];Re.constructor_.call(this,f),this._m=f._m}else if(arguments[0]instanceof Re){var w=arguments[0];Re.constructor_.call(this,w),this._m=this.getM()}}else if(arguments.length===4){var G=arguments[0],re=arguments[1],xe=arguments[2],Ae=arguments[3];Re.constructor_.call(this,G,re,xe),this._m=Ae}}}])}(Re),Ks=function(){function N(){l(this,N)}return i(N,null,[{key:"measures",value:function(h){return h instanceof Es?0:h instanceof Qs||h instanceof Pn?1:0}},{key:"dimension",value:function(h){return h instanceof Es?2:h instanceof Qs?3:h instanceof Pn?4:3}},{key:"create",value:function(){if(arguments.length===1){var h=arguments[0];return N.create(h,0)}if(arguments.length===2){var f=arguments[0],w=arguments[1];return f===2?new Es:f===3&&w===0?new Re:f===3&&w===1?new Qs:f===4&&w===1?new Pn:new Re}}}])}(),xa=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"getCoordinate",value:function(f){return this.get(f)}},{key:"addAll",value:function(){if(arguments.length===2&&typeof arguments[1]=="boolean"&&zt(arguments[0],Qe)){for(var f=arguments[1],w=!1,G=arguments[0].iterator();G.hasNext();)this.add(G.next(),f),w=!0;return w}return P(h,"addAll",this,1).apply(this,arguments)}},{key:"clone",value:function(){for(var f=P(h,"clone",this,1).call(this),w=0;w<this.size();w++)f.add(w,this.get(w).clone());return f}},{key:"toCoordinateArray",value:function(){if(arguments.length===0)return this.toArray(h.coordArrayType);if(arguments.length===1){if(arguments[0])return this.toArray(h.coordArrayType);for(var f=this.size(),w=new Array(f).fill(null),G=0;G<f;G++)w[G]=this.get(f-G-1);return w}}},{key:"add",value:function(){if(arguments.length===1){var f=arguments[0];return P(h,"add",this,1).call(this,f)}if(arguments.length===2){if(arguments[0]instanceof Array&&typeof arguments[1]=="boolean"){var w=arguments[0],G=arguments[1];return this.add(w,G,!0),!0}if(arguments[0]instanceof Re&&typeof arguments[1]=="boolean"){var re=arguments[0];if(!arguments[1]&&this.size()>=1&&this.get(this.size()-1).equals2D(re))return null;P(h,"add",this,1).call(this,re)}else if(arguments[0]instanceof Object&&typeof arguments[1]=="boolean"){var xe=arguments[0],Ae=arguments[1];return this.add(xe,Ae),!0}}else if(arguments.length===3){if(typeof arguments[2]=="boolean"&&arguments[0]instanceof Array&&typeof arguments[1]=="boolean"){var tt=arguments[0],Nt=arguments[1];if(arguments[2])for(var Ut=0;Ut<tt.length;Ut++)this.add(tt[Ut],Nt);else for(var xs=tt.length-1;xs>=0;xs--)this.add(tt[xs],Nt);return!0}if(typeof arguments[2]=="boolean"&&Number.isInteger(arguments[0])&&arguments[1]instanceof Re){var $s=arguments[0],bn=arguments[1];if(!arguments[2]){var da=this.size();if(da>0&&($s>0&&this.get($s-1).equals2D(bn)||$s<da&&this.get($s).equals2D(bn)))return null}P(h,"add",this,1).call(this,$s,bn)}}else if(arguments.length===4){var wa=arguments[0],Lr=arguments[1],ur=arguments[2],si=arguments[3],Ei=1;ur>si&&(Ei=-1);for(var hr=ur;hr!==si;hr+=Ei)this.add(wa[hr],Lr);return!0}}},{key:"closeRing",value:function(){if(this.size()>0){var f=this.get(0).copy();this.add(f,!1)}}}
758],[{key:"constructor_",value:function(){if(arguments.length!==0){if(arguments.length===1){var f=arguments[0];this.ensureCapacity(f.length),this.add(f,!0)}else if(arguments.length===2){var w=arguments[0],G=arguments[1];this.ensureCapacity(w.length),this.add(w,G)}}}}])}(ps);xa.coordArrayType=new Array(0).fill(null);var Fn=function(){function N(){l(this,N)}return i(N,null,[{key:"isRing",value:function(h){return!(h.length<4)&&!!h[0].equals2D(h[h.length-1])}},{key:"ptNotInList",value:function(h,f){for(var w=0;w<h.length;w++){var G=h[w];if(N.indexOf(G,f)<0)return G}return null}},{key:"scroll",value:function(h,f){var w=N.indexOf(f,h);if(w<0)return null;var G=new Array(h.length).fill(null);Is.arraycopy(h,w,G,0,h.length-w),Is.arraycopy(h,0,G,h.length-w,w),Is.arraycopy(G,0,h,0,h.length)}},{key:"equals",value:function(){if(arguments.length===2){var h=arguments[0],f=arguments[1];if(h===f)return!0;if(h===null||f===null||h.length!==f.length)return!1;for(var w=0;w<h.length;w++)if(!h[w].equals(f[w]))return!1;return!0}if(arguments.length===3){var G=arguments[0],re=arguments[1],xe=arguments[2];if(G===re)return!0;if(G===null||re===null||G.length!==re.length)return!1;for(var Ae=0;Ae<G.length;Ae++)if(xe.compare(G[Ae],re[Ae])!==0)return!1;return!0}}},{key:"intersection",value:function(h,f){for(var w=new xa,G=0;G<h.length;G++)f.intersects(h[G])&&w.add(h[G],!0);return w.toCoordinateArray()}},{key:"measures",value:function(h){if(h===null||h.length===0)return 0;var f,w=0,G=_(h);try{for(G.s();!(f=G.n()).done;){var re=f.value;w=Math.max(w,Ks.measures(re))}}catch(xe){G.e(xe)}finally{G.f()}return w}},{key:"hasRepeatedPoints",value:function(h){for(var f=1;f<h.length;f++)if(h[f-1].equals(h[f]))return!0;return!1}},{key:"removeRepeatedPoints",value:function(h){return N.hasRepeatedPoints(h)?new xa(h,!1).toCoordinateArray():h}},{key:"reverse",value:function(h){for(var f=h.length-1,w=Math.trunc(f/2),G=0;G<=w;G++){var re=h[G];h[G]=h[f-G],h[f-G]=re}}},{key:"removeNull",value:function(h){for(var f=0,w=0;w<h.length;w++)h[w]!==null&&f++;var G=new Array(f).fill(null);if(f===0)return G;for(var re=0,xe=0;xe<h.length;xe++)h[xe]!==null&&(G[re++]=h[xe]);return G}},{key:"copyDeep",value:function(){if(arguments.length===1){for(var h=arguments[0],f=new Array(h.length).fill(null),w=0;w<h.length;w++)f[w]=h[w].copy();return f}if(arguments.length===5)for(var G=arguments[0],re=arguments[1],xe=arguments[2],Ae=arguments[3],tt=arguments[4],Nt=0;Nt<tt;Nt++)xe[Ae+Nt]=G[re+Nt].copy()}},{key:"isEqualReversed",value:function(h,f){for(var w=0;w<h.length;w++){var G=h[w],re=f[h.length-w-1];if(G.compareTo(re)!==0)return!1}return!0}},{key:"envelope",value:function(h){for(var f=new ft,w=0;w<h.length;w++)f.expandToInclude(h[w]);return f}},{key:"toCoordinateArray",value:function(h){return h.toArray(N.coordArrayType)}},{key:"dimension",value:function(h){if(h===null||h.length===0)return 3;var f,w=0,G=_(h);try{for(G.s();!(f=G.n()).done;){var re=f.value;w=Math.max(w,Ks.dimension(re))}}catch(xe){G.e(xe)}finally{G.f()}return w}},{key:"atLeastNCoordinatesOrNothing",value:function(h,f){return f.length>=h?f:[]}},{key:"indexOf",value:function(h,f){for(var w=0;w<f.length;w++)if(h.equals(f[w]))return w;return-1}},{key:"increasingDirection",value:function(h){for(var f=0;f<Math.trunc(h.length/2);f++){var w=h.length-1-f,G=h[f].compareTo(h[w]);if(G!==0)return G}return 1}},{key:"compare",value:function(h,f){for(var w=0;w<h.length&&w<f.length;){var G=h[w].compareTo(f[w]);if(G!==0)return G;w++}return w<f.length?-1:w<h.length?1:0}},{key:"minCoordinate",value:function(h){for(var f=null,w=0;w<h.length;w++)(f===null||f.compareTo(h[w])>0)&&(f=h[w]);return f}},{key:"extract",value:function(h,f,w){f=tn.clamp(f,0,h.length);var G=(w=tn.clamp(w,-1,h.length))-f+1;w<0&&(G=0),f>=h.length&&(G=0),w<f&&(G=0);var re=new Array(G).fill(null);if(G===0)return re;for(var xe=0,Ae=f;Ae<=w;Ae++)re[xe++]=h[Ae];return re}}])}(),Sa=function(){return i(function N(){l(this,N)},[{key:"compare",value:function(N,h){var f=N,w=h;return Fn.compare(f,w)}},{key:"interfaces_",get:function(){return[ve]}}])}(),sr=function(){return i(function N(){l(this,N)}
758,[{key:"compare",value:function(N,h){var f=N,w=h;if(f.length<w.length)return-1;if(f.length>w.length)return 1;if(f.length===0)return 0;var G=Fn.compare(f,w);return Fn.isEqualReversed(f,w)?0:G}},{key:"OLDcompare",value:function(N,h){var f=N,w=h;if(f.length<w.length)return-1;if(f.length>w.length)return 1;if(f.length===0)return 0;for(var G=Fn.increasingDirection(f),re=Fn.increasingDirection(w),xe=G>0?0:f.length-1,Ae=re>0?0:f.length-1,tt=0;tt<f.length;tt++){var Nt=f[xe].compareTo(w[Ae]);if(Nt!==0)return Nt;xe+=G,Ae+=re}return 0}},{key:"interfaces_",get:function(){return[ve]}}])}();Fn.ForwardComparator=Sa,Fn.BidirectionalComparator=sr,Fn.coordArrayType=new Array(0).fill(null);var An=function(){return i(function N(h){l(this,N),this.str=h},[{key:"append",value:function(N){this.str+=N}},{key:"setCharAt",value:function(N,h){this.str=this.str.substr(0,N)+h+this.str.substr(N+1)}},{key:"toString",value:function(){return this.str}}])}(),Ai=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"getM",value:function(h){return this.hasM()?this._coordinates[h].getM():Ee.NaN}},{key:"setOrdinate",value:function(h,f,w){switch(f){case Ts.X:this._coordinates[h].x=w;break;case Ts.Y:this._coordinates[h].y=w;break;default:this._coordinates[h].setOrdinate(f,w)}}},{key:"getZ",value:function(h){return this.hasZ()?this._coordinates[h].getZ():Ee.NaN}},{key:"size",value:function(){return this._coordinates.length}},{key:"getOrdinate",value:function(h,f){switch(f){case Ts.X:return this._coordinates[h].x;case Ts.Y:return this._coordinates[h].y;default:return this._coordinates[h].getOrdinate(f)}}},{key:"getCoordinate",value:function(){if(arguments.length===1){var h=arguments[0];return this._coordinates[h]}if(arguments.length===2){var f=arguments[0];arguments[1].setCoordinate(this._coordinates[f])}}},{key:"getCoordinateCopy",value:function(h){var f=this.createCoordinate();return f.setCoordinate(this._coordinates[h]),f}},{key:"createCoordinate",value:function(){return Ks.create(this.getDimension(),this.getMeasures())}},{key:"getDimension",value:function(){return this._dimension}},{key:"getX",value:function(h){return this._coordinates[h].x}},{key:"getMeasures",value:function(){return this._measures}},{key:"expandEnvelope",value:function(h){for(var f=0;f<this._coordinates.length;f++)h.expandToInclude(this._coordinates[f]);return h}},{key:"copy",value:function(){for(var h=new Array(this.size()).fill(null),f=0;f<this._coordinates.length;f++){var w=this.createCoordinate();
758w.setCoordinate(this._coordinates[f]),h[f]=w}return new N(h,this._dimension,this._measures)}},{key:"toString",value:function(){if(this._coordinates.length>0){var h=new An(17*this._coordinates.length);h.append("("),h.append(this._coordinates[0]);for(var f=1;f<this._coordinates.length;f++)h.append(", "),h.append(this._coordinates[f]);return h.append(")"),h.toString()}return"()"}},{key:"getY",value:function(h){return this._coordinates[h].y}},{key:"toCoordinateArray",value:function(){return this._coordinates}},{key:"interfaces_",get:function(){return[Ts,q]}}],[{key:"constructor_",value:function(){if(this._dimension=3,this._measures=0,this._coordinates=null,arguments.length===1){if(arguments[0]instanceof Array){var h=arguments[0];N.constructor_.call(this,h,Fn.dimension(h),Fn.measures(h))}else if(Number.isInteger(arguments[0])){var f=arguments[0];this._coordinates=new Array(f).fill(null);for(var w=0;w<f;w++)this._coordinates[w]=new Re}else if(zt(arguments[0],Ts)){var G=arguments[0];if(G===null)return this._coordinates=new Array(0).fill(null),null;this._dimension=G.getDimension(),this._measures=G.getMeasures(),this._coordinates=new Array(G.size()).fill(null);for(var re=0;re<this._coordinates.length;re++)this._coordinates[re]=G.getCoordinateCopy(re)}}else if(arguments.length===2){if(arguments[0]instanceof Array&&Number.isInteger(arguments[1])){var xe=arguments[0],Ae=arguments[1];N.constructor_.call(this,xe,Ae,Fn.measures(xe))}else if(Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var tt=arguments[0],Nt=arguments[1];this._coordinates=new Array(tt).fill(null),this._dimension=Nt;for(var Ut=0;Ut<tt;Ut++)this._coordinates[Ut]=Ks.create(Nt)}}else if(arguments.length===3){if(Number.isInteger(arguments[2])&&arguments[0]instanceof Array&&Number.isInteger(arguments[1])){var xs=arguments[0],$s=arguments[1],bn=arguments[2];this._dimension=$s,this._measures=bn,this._coordinates=xs===null?new Array(0).fill(null):xs}else if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var da=arguments[0],wa=arguments[1],Lr=arguments[2];this._coordinates=new Array(da).fill(null),this._dimension=wa,this._measures=Lr;for(var ur=0;ur<da;ur++)this._coordinates[ur]=this.createCoordinate()}}}}])}(),xi=function(){function N(){l(this,N)}return i(N,[{key:"readResolve",value:function(){return N.instance()}},{key:"create",value:function(){if(arguments.length===1){if(arguments[0]instanceof Array)return new Ai(arguments[0]);if(zt(arguments[0],Ts))return new Ai(arguments[0])}else{if(arguments.length===2){var h=arguments[1];return h>3&&(h=3),h<2&&(h=2),new Ai(arguments[0],h)}if(arguments.length===3){var f=arguments[2],w=arguments[1]-f;return f>1&&(f=1),w>3&&(w=3),w<2&&(w=2),new Ai(arguments[0],w+f,f)}}}},{key:"interfaces_",get:function(){return[Gs,q]}}],[{key:"instance",value:function(){return N.instanceObject}}])}();xi.instanceObject=new xi;var ei=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"copyInternal",value:function(){for(var f=new Array(this._geometries.length).fill(null),w=0;w<f.length;w++)f[w]=this._geometries[w].copy();return new h(f,this._factory)}},{key:"equalsExact",value:function(){if(arguments.length===2&&typeof arguments[1]=="number"&&arguments[0]instanceof Fe){var f=arguments[0],w=arguments[1];return!!this.isEquivalentClass(f)&&P(h,"equalsExact",this,1).call(this,f,w)}return P(h,"equalsExact",this,1).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return 1}},{key:"getTypeCode",value:function(){return Fe.TYPECODE_MULTIPOLYGON}},{key:"getDimension",value:function(){return 2}},{key:"getBoundary",value:function(){if(this.isEmpty())return this.getFactory().createMultiLineString();for(var f=new ps,w=0;w<this._geometries.length;w++)for(var G=this._geometries[w].getBoundary(),re=0;re<G.getNumGeometries();re++)f.add(G.getGeometryN(re));var xe=new Array(f.size()).fill(null);return this.getFactory().createMultiLineString(f.toArray(xe))}},{key:"getGeometryType",value:function(){return Fe.TYPENAME_MULTIPOLYGON}},{key:"interfaces_",get:function(){return[is]}}
758],[{key:"constructor_",value:function(){var f=arguments[0],w=arguments[1];xt.constructor_.call(this,f,w)}}])}(xt),Yr=function(){return i(function N(){l(this,N)},[{key:"get",value:function(){}},{key:"put",value:function(){}},{key:"size",value:function(){}},{key:"values",value:function(){}},{key:"entrySet",value:function(){}}])}(),Xo=function(N){function h(){var f;return l(this,h),(f=a(this,h)).map=new Map,f}return x(h,N),i(h,[{key:"get",value:function(f){return this.map.get(f)||null}},{key:"put",value:function(f,w){return this.map.set(f,w),w}},{key:"values",value:function(){for(var f=new ps,w=this.map.values(),G=w.next();!G.done;)f.add(G.value),G=w.next();return f}},{key:"entrySet",value:function(){var f=new as;return this.map.entries().forEach(function(w){return f.add(w)}),f}},{key:"size",value:function(){return this.map.size()}}])}(Yr),ra=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"equals",value:function(h){if(!(h instanceof N))return!1;var f=h;return this._modelType===f._modelType&&this._scale===f._scale}},{key:"compareTo",value:function(h){var f=h,w=this.getMaximumSignificantDigits(),G=f.getMaximumSignificantDigits();return _s.compare(w,G)}},{key:"getScale",value:function(){return this._scale}},{key:"isFloating",value:function(){return this._modelType===N.FLOATING||this._modelType===N.FLOATING_SINGLE}},{key:"getType",value:function(){return this._modelType}},{key:"toString",value:function(){var h="UNKNOWN";return this._modelType===N.FLOATING?h="Floating":this._modelType===N.FLOATING_SINGLE?h="Floating-Single":this._modelType===N.FIXED&&(h="Fixed (Scale="+this.getScale()+")"),h}},{key:"makePrecise",value:function(){if(typeof arguments[0]=="number"){var h=arguments[0];return Ee.isNaN(h)||this._modelType===N.FLOATING_SINGLE?h:this._modelType===N.FIXED?Math.round(h*this._scale)/this._scale:h}if(arguments[0]instanceof Re){var f=arguments[0];if(this._modelType===N.FLOATING)return null;f.x=this.makePrecise(f.x),f.y=this.makePrecise(f.y)}}},{key:"getMaximumSignificantDigits",value:function(){var h=16;return this._modelType===N.FLOATING?h=16:this._modelType===N.FLOATING_SINGLE?h=6:this._modelType===N.FIXED&&(h=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),h}},{key:"setScale",value:function(h){this._scale=Math.abs(h)}},{key:"interfaces_",get:function(){return[q,H]}}],[{key:"constructor_",value:function(){if(this._modelType=null,this._scale=null,arguments.length===0)this._modelType=N.FLOATING;else if(arguments.length===1){if(arguments[0]instanceof Ka){var h=arguments[0];this._modelType=h,h===N.FIXED&&this.setScale(1)}else if(typeof arguments[0]=="number"){var f=arguments[0];this._modelType=N.FIXED,this.setScale(f)}else if(arguments[0]instanceof N){var w=arguments[0];this._modelType=w._modelType,this._scale=w._scale}}}},{key:"mostPrecise",value:function(h,f){return h.compareTo(f)>=0?h:f}}])}(),Ka=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"readResolve",value:function(){return N.nameToTypeMap.get(this._name)}},{key:"toString",value:function(){return this._name}},{key:"interfaces_",get:function(){return[q]}}],[{key:"constructor_",value:function(){this._name=null;var h=arguments[0];this._name=h,N.nameToTypeMap.put(h,this)}}])}();Ka.nameToTypeMap=new Xo,ra.Type=Ka,ra.FIXED=new Ka("FIXED"),ra.FLOATING=new Ka("FLOATING"),ra.FLOATING_SINGLE=new Ka("FLOATING SINGLE"),ra.maximumPreciseValue=9007199254740992;var Ha=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"copyInternal",value:function(){for(var f=new Array(this._geometries.length).fill(null),w=0;w<f.length;w++)f[w]=this._geometries[w].copy();return new h(f,this._factory)}},{key:"equalsExact",value:function(){if(arguments.length===2&&typeof arguments[1]=="number"&&arguments[0]instanceof Fe){var f=arguments[0],w=arguments[1];return!!this.isEquivalentClass(f)&&P(h,"equalsExact",this,1).call(this,f,w)}return P(h,"equalsExact",this,1).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?De.FALSE:0}},{key:"isClosed",value:function(){if(this.isEmpty())return!1;for(var f=0;f<this._geometries.length;f++)if(!this._geometries[f].isClosed())return!1;return!0}},{key:"getTypeCode",value:function(){return Fe.TYPECODE_MULTILINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getBoundary",value:function(){throw new _t}},{key:"getGeometryType",value:function(){return Fe.TYPENAME_MULTILINESTRING}},{key:"interfaces_",get:function(){return[je]}}
758],[{key:"constructor_",value:function(){var f=arguments[0],w=arguments[1];xt.constructor_.call(this,f,w)}}])}(xt),qa=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"createEmpty",value:function(h){switch(h){case-1:return this.createGeometryCollection();case 0:return this.createPoint();case 1:return this.createLineString();case 2:return this.createPolygon();default:throw new te("Invalid dimension: "+h)}}},{key:"toGeometry",value:function(h){return h.isNull()?this.createPoint():h.getMinX()===h.getMaxX()&&h.getMinY()===h.getMaxY()?this.createPoint(new Re(h.getMinX(),h.getMinY())):h.getMinX()===h.getMaxX()||h.getMinY()===h.getMaxY()?this.createLineString([new Re(h.getMinX(),h.getMinY()),new Re(h.getMaxX(),h.getMaxY())]):this.createPolygon(this.createLinearRing([new Re(h.getMinX(),h.getMinY()),new Re(h.getMinX(),h.getMaxY()),new Re(h.getMaxX(),h.getMaxY()),new Re(h.getMaxX(),h.getMinY()),new Re(h.getMinX(),h.getMinY())]),null)}},{key:"createLineString",value:function(){if(arguments.length===0)return this.createLineString(this.getCoordinateSequenceFactory().create([]));if(arguments.length===1){if(arguments[0]instanceof Array){var h=arguments[0];return this.createLineString(h!==null?this.getCoordinateSequenceFactory().create(h):null)}if(zt(arguments[0],Ts))return new pe(arguments[0],this)}}},{key:"createMultiLineString",value:function(){return arguments.length===0?new Ha(null,this):arguments.length===1?new Ha(arguments[0],this):void 0}},{key:"buildGeometry",value:function(h){for(var f=null,w=!1,G=!1,re=h.iterator();re.hasNext();){var xe=re.next(),Ae=xe.getTypeCode();f===null&&(f=Ae),Ae!==f&&(w=!0),xe instanceof xt&&(G=!0)}if(f===null)return this.createGeometryCollection();if(w||G)return this.createGeometryCollection(N.toGeometryArray(h));var tt=h.iterator().next();if(h.size()>1){if(tt instanceof Ws)return this.createMultiPolygon(N.toPolygonArray(h));if(tt instanceof pe)return this.createMultiLineString(N.toLineStringArray(h));if(tt instanceof Zt)return this.createMultiPoint(N.toPointArray(h));ke.shouldNeverReachHere("Unhandled geometry type: "+tt.getGeometryType())}return tt}},{key:"createMultiPointFromCoords",value:function(h){return this.createMultiPoint(h!==null?this.getCoordinateSequenceFactory().create(h):null)}},{key:"createPoint",value:function(){if(arguments.length===0)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(arguments.length===1){if(arguments[0]instanceof Re){var h=arguments[0];return this.createPoint(h!==null?this.getCoordinateSequenceFactory().create([h]):null)}if(zt(arguments[0],Ts))return new Zt(arguments[0],this)}}},{key:"getCoordinateSequenceFactory",value:function(){return this._coordinateSequenceFactory}},{key:"createPolygon",value:function(){if(arguments.length===0)return this.createPolygon(null,null);if(arguments.length===1){if(zt(arguments[0],Ts)){var h=arguments[0];return this.createPolygon(this.createLinearRing(h))}if(arguments[0]instanceof Array){var f=arguments[0];return this.createPolygon(this.createLinearRing(f))}if(arguments[0]instanceof Ls){var w=arguments[0];return this.createPolygon(w,null)}}else if(arguments.length===2)return new Ws(arguments[0],arguments[1],this)}},{key:"getSRID",value:function(){return this._SRID}},{key:"createGeometryCollection",value:function(){return arguments.length===0?new xt(null,this):arguments.length===1?new xt(arguments[0],this):void 0}},{key:"getPrecisionModel",value:function(){return this._precisionModel}},{key:"createLinearRing",value:function(){if(arguments.length===0)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(arguments.length===1){if(arguments[0]instanceof Array){var h=arguments[0];return this.createLinearRing(h!==null?this.getCoordinateSequenceFactory().create(h):null)}if(zt(arguments[0],Ts))return new Ls(arguments[0],this)}}},{key:"createMultiPolygon",value:function(){return arguments.length===0?new ei(null,this):arguments.length===1?new ei(arguments[0],this):void 0}},{key:"createMultiPoint",value:function(){if(arguments.length===0)return new os(null,this);if(arguments.length===1){if(arguments[0]instanceof Array)return new os(arguments[0],this);if(zt(arguments[0],Ts)){var h=arguments[0];if(h===null)return this.createMultiPoint(new Array(0).fill(null));for(var f=new Array(h.size()).fill(null),w=0;w<h.size();w++){var G=this.getCoordinateSequenceFactory().create(1,h.getDimension(),h.getMeasures());Ge.copy(h,w,G,0,1),f[w]=this.createPoint(G)}return this.createMultiPoint(f)}}}},{key:"interfaces_",get:function(){return[q]}}
758],[{key:"constructor_",value:function(){if(this._precisionModel=null,this._coordinateSequenceFactory=null,this._SRID=null,arguments.length===0)N.constructor_.call(this,new ra,0);else if(arguments.length===1){if(zt(arguments[0],Gs)){var h=arguments[0];N.constructor_.call(this,new ra,0,h)}else if(arguments[0]instanceof ra){var f=arguments[0];N.constructor_.call(this,f,0,N.getDefaultCoordinateSequenceFactory())}}else if(arguments.length===2){var w=arguments[0],G=arguments[1];N.constructor_.call(this,w,G,N.getDefaultCoordinateSequenceFactory())}else if(arguments.length===3){var re=arguments[0],xe=arguments[1],Ae=arguments[2];this._precisionModel=re,this._coordinateSequenceFactory=Ae,this._SRID=xe}}},{key:"toMultiPolygonArray",value:function(h){var f=new Array(h.size()).fill(null);return h.toArray(f)}},{key:"toGeometryArray",value:function(h){if(h===null)return null;var f=new Array(h.size()).fill(null);return h.toArray(f)}},{key:"getDefaultCoordinateSequenceFactory",value:function(){return xi.instance()}},{key:"toMultiLineStringArray",value:function(h){var f=new Array(h.size()).fill(null);return h.toArray(f)}},{key:"toLineStringArray",value:function(h){var f=new Array(h.size()).fill(null);return h.toArray(f)}},{key:"toMultiPointArray",value:function(h){var f=new Array(h.size()).fill(null);return h.toArray(f)}},{key:"toLinearRingArray",value:function(h){var f=new Array(h.size()).fill(null);return h.toArray(f)}},{key:"toPointArray",value:function(h){var f=new Array(h.size()).fill(null);return h.toArray(f)}},{key:"toPolygonArray",value:function(h){var f=new Array(h.size()).fill(null);return h.toArray(f)}},{key:"createPointFromInternalCoord",value:function(h,f){return f.getPrecisionModel().makePrecise(h),f.getFactory().createPoint(h)}}])}(),Mn="XY",_r="XYZ",Ar="XYM",Zs="XYZM",Cn={POINT:"Point",LINE_STRING:"LineString",LINEAR_RING:"LinearRing",POLYGON:"Polygon",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon",GEOMETRY_COLLECTION:"GeometryCollection",CIRCLE:"Circle"},Na="EMPTY",Gn=1,sa=2,Pr=3,oi=4,Tr=5,Ko=6;for(var Za in Cn)Cn[Za].toUpperCase();var Gr=function(){return i(function N(h){l(this,N),this.wkt=h,this.index_=-1},[{key:"isAlpha_",value:function(N){return N>="a"&&N<="z"||N>="A"&&N<="Z"}},{key:"isNumeric_",value:function(N,h){return N>="0"&&N<="9"||N=="."&&!(h!==void 0&&h)}},{key:"isWhiteSpace_",value:function(N){return N==" "||N=="	"||N=="\r"||N==`
759`}},{key:"nextChar_",value:function(){return this.wkt.charAt(++this.index_)}},{key:"nextToken",value:function(){var N,h=this.nextChar_(),f=this.index_,w=h;if(h=="(")N=sa;else if(h==",")N=Tr;else if(h==")")N=Pr;else if(this.isNumeric_(h)||h=="-")N=oi,w=this.readNumber_();else if(this.isAlpha_(h))N=Gn,w=this.readText_();else{if(this.isWhiteSpace_(h))return this.nextToken();if(h!=="")throw new Error("Unexpected character: "+h);N=Ko}return{position:f,value:w,type:N}}},{key:"readNumber_",value:function(){var N,h=this.index_,f=!1,w=!1;do N=="."?f=!0:N!="e"&&N!="E"||(w=!0),N=this.nextChar_();while(this.isNumeric_(N,f)||!w&&(N=="e"||N=="E")||w&&(N=="-"||N=="+"));return parseFloat(this.wkt.substring(h,this.index_--))}},{key:"readText_",value:function(){var N,h=this.index_;do N=this.nextChar_();while(this.isAlpha_(N));return this.wkt.substring(h,this.index_--).toUpperCase()}}])}(),Xr=function(){return i(function N(h,f){l(this,N),this.lexer_=h,this.token_,this.layout_=Mn,this.factory=f},[{key:"consume_",value:function(){this.token_=this.lexer_.nextToken()}},{key:"isTokenType",value:function(N){return this.token_.type==N}},{key:"match",value:function(N){var h=this.isTokenType(N);return h&&this.consume_(),h}},{key:"parse",value:function(){return this.consume_(),this.parseGeometry_()}},{key:"parseGeometryLayout_",value:function(){var N=Mn,h=this.token_;if(this.isTokenType(Gn)){var f=h.value;f==="Z"?N=_r:f==="M"?N=Ar:f==="ZM"&&(N=Zs),N!==Mn&&this.consume_()}return N}},{key:"parseGeometryCollectionText_",value:function(){if(this.match(sa)){var N=[];do N.push(this.parseGeometry_());while(this.match(Tr));if(this.match(Pr))return N}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePointText_",value:function(){if(this.match(sa)){var N=this.parsePoint_();if(this.match(Pr))return N}else if(this.isEmptyGeometry_())return null;throw new Error(this.formatErrorMessage_())}},{key:"parseLineStringText_",value:function(){if(this.match(sa)){var N=this.parsePointList_();if(this.match(Pr))return N}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePolygonText_",value:function(){if(this.match(sa)){var N=this.parseLineStringTextList_();if(this.match(Pr))return N}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPointText_",value:function(){var N;if(this.match(sa)){if(N=this.token_.type==sa?this.parsePointTextList_():this.parsePointList_(),this.match(Pr))return N}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiLineStringText_",value:function(){if(this.match(sa)){var N=this.parseLineStringTextList_();if(this.match(Pr))return N}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPolygonText_",value:function(){if(this.match(sa)){var N=this.parsePolygonTextList_();if(this.match(Pr))return N}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePoint_",value:function(){for(var N=[],h=this.layout_.length,f=0;f<h;++f){var w=this.token_;if(!this.match(oi))break;N.push(w.value)}if(N.length==h)return N;throw new Error(this.formatErrorMessage_())}},{key:"parsePointList_",value:function(){for(var N=[this.parsePoint_()];this.match(Tr);)N.push(this.parsePoint_());return N}},{key:"parsePointTextList_",value:function(){for(var N=[this.parsePointText_()];this.match(Tr);)N.push(this.parsePointText_());return N}},{key:"parseLineStringTextList_",value:function(){for(var N=[this.parseLineStringText_()];this.match(Tr);)N.push(this.parseLineStringText_());return N}},{key:"parsePolygonTextList_",value:function(){for(var N=[this.parsePolygonText_()];this.match(Tr);)N.push(this.parsePolygonText_());return N}},{key:"isEmptyGeometry_",value:function(){var N=this.isTokenType(Gn)&&this.token_.value==Na;return N&&this.consume_(),N}},{key:"formatErrorMessage_",value:function(){return"Unexpected `"+this.token_.value+"` at position "+this.token_.position+" in `"+this.lexer_.wkt+"`"}},{key:"parseGeometry_",value:function(){var N=this.factory,h=function(wa){return c(Re,I(wa))},f=function(wa){var Lr=wa.map(function(ur){return N.createLinearRing(ur.map(h))});return Lr.length>1?N.createPolygon(Lr[0],Lr.slice(1)):N.createPolygon(Lr[0])},w=this.token_;if(this.match(Gn)){var G=w.value;if(this.layout_=this.parseGeometryLayout_(),G=="GEOMETRYCOLLECTION"){var re=this.parseGeometryCollectionText_();return N.createGeometryCollection(re)}switch(G){case"POINT":var xe=this.parsePointText_();return xe?N.createPoint(c(Re,I(xe))):N.createPoint();case"LINESTRING":var Ae=this.parseLineStringText_().map(h);return N.createLineString(Ae);case"LINEARRING":var tt=this.parseLineStringText_().map(h);return N.createLinearRing(tt);case"POLYGON":var Nt=this.parsePolygonText_();
759return Nt&&Nt.length!==0?f(Nt):N.createPolygon();case"MULTIPOINT":var Ut=this.parseMultiPointText_();if(!Ut||Ut.length===0)return N.createMultiPoint();var xs=Ut.map(h).map(function(wa){return N.createPoint(wa)});return N.createMultiPoint(xs);case"MULTILINESTRING":var $s=this.parseMultiLineStringText_().map(function(wa){return N.createLineString(wa.map(h))});return N.createMultiLineString($s);case"MULTIPOLYGON":var bn=this.parseMultiPolygonText_();if(!bn||bn.length===0)return N.createMultiPolygon();var da=bn.map(f);return N.createMultiPolygon(da);default:throw new Error("Invalid geometry type: "+G)}}throw new Error(this.formatErrorMessage_())}}])}();function rn(N){if(N.isEmpty())return"";var h=N.getCoordinate(),f=[h.x,h.y];return h.z===void 0||Number.isNaN(h.z)||f.push(h.z),h.m===void 0||Number.isNaN(h.m)||f.push(h.m),f.join(" ")}function In(N){for(var h=N.getCoordinates().map(function(re){var xe=[re.x,re.y];return re.z===void 0||Number.isNaN(re.z)||xe.push(re.z),re.m===void 0||Number.isNaN(re.m)||xe.push(re.m),xe}),f=[],w=0,G=h.length;w<G;++w)f.push(h[w].join(" "));return f.join(", ")}function Yi(N){var h=[];h.push("("+In(N.getExteriorRing())+")");for(var f=0,w=N.getNumInteriorRing();f<w;++f)h.push("("+In(N.getInteriorRingN(f))+")");return h.join(", ")}var jl={Point:rn,LineString:In,LinearRing:In,Polygon:Yi,MultiPoint:function(N){for(var h=[],f=0,w=N.getNumGeometries();f<w;++f)h.push("("+rn(N.getGeometryN(f))+")");return h.join(", ")},MultiLineString:function(N){for(var h=[],f=0,w=N.getNumGeometries();f<w;++f)h.push("("+In(N.getGeometryN(f))+")");return h.join(", ")},MultiPolygon:function(N){for(var h=[],f=0,w=N.getNumGeometries();f<w;++f)h.push("("+Yi(N.getGeometryN(f))+")");return h.join(", ")},GeometryCollection:function(N){for(var h=[],f=0,w=N.getNumGeometries();f<w;++f)h.push(Si(N.getGeometryN(f)));return h.join(", ")}};function Si(N){var h=N.getGeometryType(),f=jl[h];h=h.toUpperCase();var w=function(G){var re="";if(G.isEmpty())return re;var xe=G.getCoordinate();return xe.z===void 0||Number.isNaN(xe.z)||(re+="Z"),xe.m===void 0||Number.isNaN(xe.m)||(re+="M"),re}(N);return w.length>0&&(h+=" "+w),N.isEmpty()?h+" "+Na:h+" ("+f(N)+")"}var zo=function(){return i(function N(h){l(this,N),this.geometryFactory=h||new qa,this.precisionModel=this.geometryFactory.getPrecisionModel()},[{key:"read",value:function(N){var h=new Gr(N);return new Xr(h,this.geometryFactory).parse()}},{key:"write",value:function(N){return Si(N)}}])}(),Pc=function(){return i(function N(h){l(this,N),this.parser=new zo(h)},[{key:"write",value:function(N){return this.parser.write(N)}}],[{key:"toLineString",value:function(N,h){if(arguments.length!==2)throw new Error("Not implemented");return"LINESTRING ( "+N.x+" "+N.y+", "+h.x+" "+h.y+" )"}}])}(),Hr=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"getIndexAlongSegment",value:function(h,f){return this.computeIntLineIndex(),this._intLineIndex[h][f]}},{key:"getTopologySummary",value:function(){var h=new An;return this.isEndPoint()&&h.append(" endpoint"),this._isProper&&h.append(" proper"),this.isCollinear()&&h.append(" collinear"),h.toString()}},{key:"computeIntersection",value:function(h,f,w,G){this._inputLines[0][0]=h,this._inputLines[0][1]=f,this._inputLines[1][0]=w,this._inputLines[1][1]=G,this._result=this.computeIntersect(h,f,w,G)}},{key:"getIntersectionNum",value:function(){return this._result}},{key:"computeIntLineIndex",value:function(){if(arguments.length===0)this._intLineIndex===null&&(this._intLineIndex=Array(2).fill().map(function(){return Array(2)}),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(arguments.length===1){var h=arguments[0];this.getEdgeDistance(h,0)>this.getEdgeDistance(h,1)?(this._intLineIndex[h][0]=0,this._intLineIndex[h][1]=1):(this._intLineIndex[h][0]=1,this._intLineIndex[h][1]=0)}}},{key:"isProper",value:function(){return this.hasIntersection()&&this._isProper}},{key:"setPrecisionModel",value:function(h){this._precisionModel=h}},{key:"isInteriorIntersection",value:function(){if(arguments.length===0)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(arguments.length===1){for(var h=arguments[0],f=0;f<this._result;f++)if(!this._intPt[f].equals2D(this._inputLines[h][0])&&!this._intPt[f].equals2D(this._inputLines[h][1]))return!0;return!1}}},{key:"getIntersection",value:function(h){return this._intPt[h]}},{key:"isEndPoint",value:function(){return this.hasIntersection()&&
759!this._isProper}},{key:"hasIntersection",value:function(){return this._result!==N.NO_INTERSECTION}},{key:"getEdgeDistance",value:function(h,f){return N.computeEdgeDistance(this._intPt[f],this._inputLines[h][0],this._inputLines[h][1])}},{key:"isCollinear",value:function(){return this._result===N.COLLINEAR_INTERSECTION}},{key:"toString",value:function(){return Pc.toLineString(this._inputLines[0][0],this._inputLines[0][1])+" - "+Pc.toLineString(this._inputLines[1][0],this._inputLines[1][1])+this.getTopologySummary()}},{key:"getEndpoint",value:function(h,f){return this._inputLines[h][f]}},{key:"isIntersection",value:function(h){for(var f=0;f<this._result;f++)if(this._intPt[f].equals2D(h))return!0;return!1}},{key:"getIntersectionAlongSegment",value:function(h,f){return this.computeIntLineIndex(),this._intPt[this._intLineIndex[h][f]]}}],[{key:"constructor_",value:function(){this._result=null,this._inputLines=Array(2).fill().map(function(){return Array(2)}),this._intPt=new Array(2).fill(null),this._intLineIndex=null,this._isProper=null,this._pa=null,this._pb=null,this._precisionModel=null,this._intPt[0]=new Re,this._intPt[1]=new Re,this._pa=this._intPt[0],this._pb=this._intPt[1],this._result=0}},{key:"computeEdgeDistance",value:function(h,f,w){var G=Math.abs(w.x-f.x),re=Math.abs(w.y-f.y),xe=-1;if(h.equals(f))xe=0;else if(h.equals(w))xe=G>re?G:re;else{var Ae=Math.abs(h.x-f.x),tt=Math.abs(h.y-f.y);(xe=G>re?Ae:tt)!==0||h.equals(f)||(xe=Math.max(Ae,tt))}return ke.isTrue(!(xe===0&&!h.equals(f)),"Bad distance calculation"),xe}},{key:"nonRobustComputeEdgeDistance",value:function(h,f,w){var G=h.x-f.x,re=h.y-f.y,xe=Math.sqrt(G*G+re*re);return ke.isTrue(!(xe===0&&!h.equals(f)),"Invalid distance calculation"),xe}}])}();Hr.DONT_INTERSECT=0,Hr.DO_INTERSECT=1,Hr.COLLINEAR=2,Hr.NO_INTERSECTION=0,Hr.POINT_INTERSECTION=1,Hr.COLLINEAR_INTERSECTION=2;var ul=function(N){function h(){return l(this,h),a(this,h)}return x(h,N),i(h,[{key:"isInSegmentEnvelopes",value:function(f){var w=new ft(this._inputLines[0][0],this._inputLines[0][1]),G=new ft(this._inputLines[1][0],this._inputLines[1][1]);return w.contains(f)&&G.contains(f)}},{key:"computeIntersection",value:function(){if(arguments.length!==3)return P(h,"computeIntersection",this,1).apply(this,arguments);var f=arguments[0],w=arguments[1],G=arguments[2];if(this._isProper=!1,ft.intersects(w,G,f)&&bs.index(w,G,f)===0&&bs.index(G,w,f)===0)return this._isProper=!0,(f.equals(w)||f.equals(G))&&(this._isProper=!1),this._result=Hr.POINT_INTERSECTION,null;this._result=Hr.NO_INTERSECTION}},{key:"intersection",value:function(f,w,G,re){var xe=this.intersectionSafe(f,w,G,re);return this.isInSegmentEnvelopes(xe)||(xe=new Re(h.nearestEndpoint(f,w,G,re))),this._precisionModel!==null&&this._precisionModel.makePrecise(xe),xe}},{key:"checkDD",value:function(f,w,G,re,xe){var Ae=Ns.intersection(f,w,G,re),tt=this.isInSegmentEnvelopes(Ae);Is.out.println("DD in env = "+tt+"  --------------------- "+Ae),xe.distance(Ae)>1e-4&&Is.out.println("Distance = "+xe.distance(Ae))}},{key:"intersectionSafe",value:function(f,w,G,re){var xe=ds.intersection(f,w,G,re);return xe===null&&(xe=h.nearestEndpoint(f,w,G,re)),xe}},{key:"computeCollinearIntersection",value:function(f,w,G,re){var xe=ft.intersects(f,w,G),Ae=ft.intersects(f,w,re),tt=ft.intersects(G,re,f),Nt=ft.intersects(G,re,w);return xe&&Ae?(this._intPt[0]=G,this._intPt[1]=re,Hr.COLLINEAR_INTERSECTION):tt&&Nt?(this._intPt[0]=f,this._intPt[1]=w,Hr.COLLINEAR_INTERSECTION):xe&&tt?(this._intPt[0]=G,this._intPt[1]=f,!G.equals(f)||Ae||Nt?Hr.COLLINEAR_INTERSECTION:Hr.POINT_INTERSECTION):xe&&Nt?(this._intPt[0]=G,this._intPt[1]=w,!G.equals(w)||Ae||tt?Hr.COLLINEAR_INTERSECTION:Hr.POINT_INTERSECTION):Ae&&tt?(this._intPt[0]=re,this._intPt[1]=f,!re.equals(f)||xe||Nt?Hr.COLLINEAR_INTERSECTION:Hr.POINT_INTERSECTION):Ae&&Nt?(this._intPt[0]=re,this._intPt[1]=w,!re.equals(w)||xe||tt?Hr.COLLINEAR_INTERSECTION:Hr.POINT_INTERSECTION):Hr.NO_INTERSECTION}},{key:"computeIntersect",value:function(f,w,G,re){if(this._isProper=!1,!ft.intersects(f,w,G,re))return Hr.NO_INTERSECTION;var xe=bs.index(f,w,G),Ae=bs.index(f,w,re);if(xe>0&&Ae>0||xe<0&&Ae<0)return Hr.NO_INTERSECTION;var tt=bs.index(G,re,f),Nt=bs.index(G,re,w);return tt>0&&Nt>0||tt<0&&Nt<0?Hr.NO_INTERSECTION:xe===0&&Ae===0&&tt===0&&Nt===0?this.computeCollinearIntersection(f,w,G,re):(xe===0||Ae===0||tt===0||Nt===0?(this._isProper=!1,f.equals2D(G)||f.equals2D(re)?this._intPt[0]=f:w.equals2D(G)||w.equals2D(re)?this._intPt[0]=w:xe===0?this._intPt[0]=new Re(G):Ae===0?this._intPt[0]=new Re(re):tt===0?this._intPt[0]=new Re(f):Nt===0&&(this._intPt[0]=new Re(w))):(this._isProper=!0,this._intPt[0]=this.intersection(f,w,G,re)),Hr.POINT_INTERSECTION)}}],[{key:"nearestEndpoint",value:function(f,w,G,re){var xe=f,Ae=wn.pointToSegment(f,G,re),tt
vendor: 4,699 bytes, line 759
759=wn.pointToSegment(w,G,re);return tt<Ae&&(Ae=tt,xe=w),(tt=wn.pointToSegment(G,f,w))<Ae&&(Ae=tt,xe=G),(tt=wn.pointToSegment(re,f,w))<Ae&&(Ae=tt,xe=re),xe}}])}(Hr),hl=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"countSegment",value:function(h,f){if(h.x<this._p.x&&f.x<this._p.x)return null;if(this._p.x===f.x&&this._p.y===f.y)return this._isPointOnSegment=!0,null;if(h.y===this._p.y&&f.y===this._p.y){var w=h.x,G=f.x;return w>G&&(w=f.x,G=h.x),this._p.x>=w&&this._p.x<=G&&(this._isPointOnSegment=!0),null}if(h.y>this._p.y&&f.y<=this._p.y||f.y>this._p.y&&h.y<=this._p.y){var re=bs.index(h,f,this._p);if(re===bs.COLLINEAR)return this._isPointOnSegment=!0,null;f.y<h.y&&(re=-re),re===bs.LEFT&&this._crossingCount++}}},{key:"isPointInPolygon",value:function(){return this.getLocation()!==fe.EXTERIOR}},{key:"getLocation",value:function(){return this._isPointOnSegment?fe.BOUNDARY:this._crossingCount%2==1?fe.INTERIOR:fe.EXTERIOR}},{key:"isOnSegment",value:function(){return this._isPointOnSegment}}],[{key:"constructor_",value:function(){this._p=null,this._crossingCount=0,this._isPointOnSegment=!1;var h=arguments[0];this._p=h}},{key:"locatePointInRing",value:function(){if(arguments[0]instanceof Re&&zt(arguments[1],Ts)){for(var h=arguments[1],f=new N(arguments[0]),w=new Re,G=new Re,re=1;re<h.size();re++)if(h.getCoordinate(re,w),h.getCoordinate(re-1,G),f.countSegment(w,G),f.isOnSegment())return f.getLocation();return f.getLocation()}if(arguments[0]instanceof Re&&arguments[1]instanceof Array){for(var xe=arguments[1],Ae=new N(arguments[0]),tt=1;tt<xe.length;tt++){var Nt=xe[tt],Ut=xe[tt-1];if(Ae.countSegment(Nt,Ut),Ae.isOnSegment())return Ae.getLocation()}return Ae.getLocation()}}}])}(),Nr=function(){function N(){l(this,N)}return i(N,null,[{key:"isOnLine",value:function(){if(arguments[0]instanceof Re&&zt(arguments[1],Ts)){for(var h=arguments[0],f=arguments[1],w=new ul,G=new Re,re=new Re,xe=f.size(),Ae=1;Ae<xe;Ae++)if(f.getCoordinate(Ae-1,G),f.getCoordinate(Ae,re),w.computeIntersection(h,G,re),w.hasIntersection())return!0;return!1}if(arguments[0]instanceof Re&&arguments[1]instanceof Array){for(var tt=arguments[0],Nt=arguments[1],Ut=new ul,xs=1;xs<Nt.length;xs++){var $s=Nt[xs-1],bn=Nt[xs];if(Ut.computeIntersection(tt,$s,bn),Ut.hasIntersection())return!0}return!1}}},{key:"locateInRing",value:function(h,f){return hl.locatePointInRing(h,f)}},{key:"isInRing",value:function(h,f){return N.locateInRing(h,f)!==fe.EXTERIOR}}])}(),ui=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"setAllLocations",value:function(h){for(var f=0;f<this.location.length;f++)this.location[f]=h}},{key:"isNull",value:function(){for(var h=0;h<this.location.length;h++)if(this.location[h]!==fe.NONE)return!1;return!0}},{key:"setAllLocationsIfNull",value:function(h){for(var f=0;f<this.location.length;f++)this.location[f]===fe.NONE&&(this.location[f]=h)}},{key:"isLine",value:function(){return this.location.length===1}},{key:"merge",value:function(h){if(h.location.length>this.location.length){var f=new Array(3).fill(null);f[Xe.ON]=this.location[Xe.ON],f[Xe.LEFT]=fe.NONE,f[Xe.RIGHT]=fe.NONE,this.location=f}for(var w=0;w<this.location.length;w++)this.location[w]===fe.NONE&&w<h.location.length&&(this.location[w]=h.location[w])}},{key:"getLocations",value:function(){return this.location}},{key:"flip",value:function(){if(this.location.length<=1)return null;var h=this.location[Xe.LEFT];this.location[Xe.LEFT]=this.location[Xe.RIGHT],this.location[Xe.RIGHT]=h}},{key:"toString",value:function(){var h=new rs;return this.location.length>1&&h.append(fe.toLocationSymbol(this.location[Xe.LEFT])),h.append(fe.toLocationSymbol(this.location[Xe.ON])),this.location.length>1&&h.append(fe.toLocationSymbol(this.location[Xe.RIGHT])),h.toString()}},{key:"setLocations",value:function(h,f,w){this.location[Xe.ON]=h,this.location[Xe.LEFT]=f,this.location[Xe.RIGHT]=w}},{key:"get",value:function(h){return h<this.location.length?this.location[h]:fe.NONE}},{key:"isArea",value:function(){return this.location.length>1}},{key:"isAnyNull",value:function(){for(var h=0;h<this.location.length;h++)if(this.location[h]===fe.NONE)return!0;return!1}},{key:"setLocation",value:function(){if(arguments.length===1){var h=arguments[0];this.setLocation(Xe.ON,h)}else if(arguments.length===2){var f=arguments[0],w=arguments[1];this.location[f]=w}}},{key:"init",value:function(h){this.location=new Array(h).fill(null),this.setAllLocations(fe.NONE)}},{key:"isEqualOnSide",value:function(h,f){return this.location[f]===h.location[f]}},{key:"allPositionsEqual",value:function(h){for(var f=0;f<this.location.length;f++)if(this.location[f]!==h)return!1;return!0}}
759],[{key:"constructor_",value:function(){if(this.location=null,arguments.length===1){if(arguments[0]instanceof Array){var h=arguments[0];this.init(h.length)}else if(Number.isInteger(arguments[0])){var f=arguments[0];this.init(1),this.location[Xe.ON]=f}else if(arguments[0]instanceof N){var w=arguments[0];if(this.init(w.location.length),w!==null)for(var G=0;G<this.location.length;G++)this.location[G]=w.location[G]}}else if(arguments.length===3){var re=arguments[0],xe=arguments[1],Ae=arguments[2];this.init(3),this.location[Xe.ON]=re,this.location[Xe.LEFT]=xe,this.location[Xe.RIGHT]=Ae}}}])}(),Zr=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"getGeometryCount",value:function(){var h=0;return this.elt[0].isNull()||h++,this.elt[1].isNull()||h++,h}},{key:"setAllLocations",value:function(h,f){this.elt[h].setAllLocations(f)}},{key:"isNull",value:function(h){return this.elt[h].isNull()}},{key:"setAllLocationsIfNull",value:function(){if(arguments.length===1){var h=arguments[0];this.setAllLocationsIfNull(0,h),this.setAllLocationsIfNull(1,h)}else if(arguments.length===2){var f=arguments[0],w=arguments[1];this.elt[f].setAllLocationsIfNull(w)}}},{key:"isLine",value:function(h){return this.elt[h].isLine()}},{key:"merge",value:function(h){for(var f=0;f<2;f++)this.elt[f]===null&&h.elt[f]!==null?this.elt[f]=new ui(h.elt[f]):this.elt[f].merge(h.elt[f])}},{key:"flip",value:function(){this.elt[0].flip(),this.elt[1].flip()}},{key:"getLocation",value:function(){if(arguments.length===1){var h=arguments[0];return this.elt[h].get(Xe.ON)}if(arguments.length===2){var f=arguments[0],w=arguments[1];return this.elt[f].get(w)}}},{key:"toString",value:function(){var h=new rs;return this.elt[0]!==null&&(h.append("A:"),h.append(this.elt[0].toString())),this.elt[1]!==null&&(h.append(" B:"),h.append(this.elt[1].toString())),h.toString()}},{key:"isArea",value:function(){if(arguments.length===0)return this.elt[0].isArea()||this.elt[1].isArea();if(arguments.length===1){var h=arguments[0];return this.elt[h].isArea()}}},{key:"isAnyNull",value:function(h){return this.elt[h].isAnyNull()}},{key:"setLocation",value:function(){if(arguments.length===2){var h=arguments[0],f=arguments[1];this.elt[h].setLocation(Xe.ON,f)}else if(arguments.length===3){var w=arguments[0],G=arguments[1],re=arguments[2];this.elt[w].setLocation(G,re)}}},{key:"isEqualOnSide",value:function(h,f){return this.elt[0].isEqualOnSide(h.elt[0],f)&&this.elt[1].isEqualOnSide(h.elt[1],f)}},{key:"allPositionsEqual",value:function(h,f){return this.elt[h].allPositionsEqual(f)}},{key:"toLine",value:function(h){this.elt[h].isArea()&&(this.elt[h]=new ui(this.elt[h].location[0]))}}],[{key:"constructor_",value:function(){if(this.elt=new Array(2).fill(null),arguments.length===1){if(Number.isInteger(arguments[0])){var h=arguments[0];this.elt[0]=new ui(h),this.elt[1]=new ui(h)}else if(arguments[0]instanceof N){var f=arguments[0];this.elt[0]=new ui(f.elt[0]),this.elt[1]=new ui(f.elt[1])}}else if(arguments.length===2){var w=arguments[0],G=arguments[1];this.elt[0]=new ui(fe.NONE),this.elt[1]=new ui(fe.NONE),this.elt[w].setLocation(G)}else if(arguments.length===3){var re=arguments[0],xe=arguments[1],Ae=arguments[2];this.elt[0]=new ui(re,xe,Ae),this.elt[1]=new ui(re,xe,Ae)}else if(arguments.length===4){var tt=arguments[0],Nt=arguments[1],Ut=arguments[2],xs=arguments[3];this.elt[0]=new ui(fe.NONE,fe.NONE,fe.NONE),this.elt[1]=new ui(fe.NONE,fe.NONE,fe.NONE),this.elt[tt].setLocations(Nt,Ut,xs)}}},{key:"toLineLabel",value:function(h){for(var f=new N(fe.NONE),w=0;w<2;w++)f.setLocation(w,h.getLocation(w));return f}}])}(),Gi=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"computeRing",value:function(){if(this._ring!==null)return null;for(var N=new Array(this._pts.size()).fill(null),h=0;h<this._pts.size();h++)N[h]=this._pts.get(h);this._ring=this._geometryFactory.createLinearRing(N),this._isHole=bs.isCCW(this._ring.getCoordinates())}},{key:"isIsolated",value:function(){return this._label.getGeometryCount()===1}},{key:"computePoints",value:function(N){this._startDe=N;var h=N,f=!0;
759do{if(h===null)throw new Jt("Found null DirectedEdge");if(h.getEdgeRing()===this)throw new Jt("Directed Edge visited twice during ring-building at "+h.getCoordinate());this._edges.add(h);var w=h.getLabel();ke.isTrue(w.isArea()),this.mergeLabel(w),this.addPoints(h.getEdge(),h.isForward(),f),f=!1,this.setEdgeRing(h,this),h=this.getNext(h)}while(h!==this._startDe)}},{key:"getLinearRing",value:function(){return this._ring}},{key:"getCoordinate",value:function(N){return this._pts.get(N)}},{key:"computeMaxNodeDegree",value:function(){this._maxNodeDegree=0;var N=this._startDe;do{var h=N.getNode().getEdges().getOutgoingDegree(this);h>this._maxNodeDegree&&(this._maxNodeDegree=h),N=this.getNext(N)}while(N!==this._startDe);this._maxNodeDegree*=2}},{key:"addPoints",value:function(N,h,f){var w=N.getCoordinates();if(h){var G=1;f&&(G=0);for(var re=G;re<w.length;re++)this._pts.add(w[re])}else{var xe=w.length-2;f&&(xe=w.length-1);for(var Ae=xe;Ae>=0;Ae--)this._pts.add(w[Ae])}}},{key:"isHole",value:function(){return this._isHole}},{key:"setInResult",value:function(){var N=this._startDe;do N.getEdge().setInResult(!0),N=N.getNext();while(N!==this._startDe)}},{key:"containsPoint",value:function(N){var h=this.getLinearRing();if(!h.getEnvelopeInternal().contains(N)||!Nr.isInRing(N,h.getCoordinates()))return!1;for(var f=this._holes.iterator();f.hasNext();)if(f.next().containsPoint(N))return!1;return!0}},{key:"addHole",value:function(N){this._holes.add(N)}},{key:"isShell",value:function(){return this._shell===null}},{key:"getLabel",value:function(){return this._label}},{key:"getEdges",value:function(){return this._edges}},{key:"getMaxNodeDegree",value:function(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree}},{key:"getShell",value:function(){return this._shell}},{key:"mergeLabel",value:function(){if(arguments.length===1){var N=arguments[0];this.mergeLabel(N,0),this.mergeLabel(N,1)}else if(arguments.length===2){var h=arguments[1],f=arguments[0].getLocation(h,Xe.RIGHT);if(f===fe.NONE)return null;if(this._label.getLocation(h)===fe.NONE)return this._label.setLocation(h,f),null}}},{key:"setShell",value:function(N){this._shell=N,N!==null&&N.addHole(this)}},{key:"toPolygon",value:function(N){for(var h=new Array(this._holes.size()).fill(null),f=0;f<this._holes.size();f++)h[f]=this._holes.get(f).getLinearRing();return N.createPolygon(this.getLinearRing(),h)}}],[{key:"constructor_",value:function(){if(this._startDe=null,this._maxNodeDegree=-1,this._edges=new ps,this._pts=new ps,this._label=new Zr(fe.NONE),this._ring=null,this._isHole=null,this._shell=null,this._holes=new ps,this._geometryFactory=null,arguments.length!==0){if(arguments.length===2){var N=arguments[0],h=arguments[1];this._geometryFactory=h,this.computePoints(N),this.computeRing()}}}}])}(),fn=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"setEdgeRing",value:function(f,w){f.setMinEdgeRing(w)}},{key:"getNext",value:function(f){return f.getNextMin()}}],[{key:"constructor_",value:function(){var f=arguments[0],w=arguments[1];Gi.constructor_.call(this,f,w)}}])}(Gi),kr=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"buildMinimalRings",value:function(){var f=new ps,w=this._startDe;do{if(w.getMinEdgeRing()===null){var G=new fn(w,this._geometryFactory);f.add(G)}w=w.getNext()}while(w!==this._startDe);return f}},{key:"setEdgeRing",value:function(f,w){f.setEdgeRing(w)}},{key:"linkDirectedEdgesForMinimalEdgeRings",value:function(){var f=this._startDe;do f.getNode().getEdges().linkMinimalDirectedEdges(this),f=f.getNext();while(f!==this._startDe)}},{key:"getNext",value:function(f){return f.getNext()}}],[{key:"constructor_",value:function(){var f=arguments[0],w=arguments[1];Gi.constructor_.call(this,f,w)}}])}(Gi),nr=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"setVisited",value:function(N){this._isVisited=N}},{key:"setInResult",value:function(N){this._isInResult=N}},{key:"isCovered",value:function(){return this._isCovered}},{key:"isCoveredSet",value:function(){return this._isCoveredSet}},{key:"setLabel",value:function(N){this._label=N}},{key:"getLabel",value:function(){return this._label}},{key:"setCovered",value:function(N){this._isCovered=N,this._isCoveredSet=!0}},{key:"updateIM",value:function(N){ke.isTrue(this._label.getGeometryCount()>=2,"found partial label"),this.computeIM(N)}},{key:"isInResult",value:function(){return this._isInResult}},{key:"isVisited",value:function(){return this._isVisited}}
759],[{key:"constructor_",value:function(){if(this._label=null,this._isInResult=!1,this._isCovered=!1,this._isCoveredSet=!1,this._isVisited=!1,arguments.length!==0){if(arguments.length===1){var N=arguments[0];this._label=N}}}}])}(),Br=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"isIncidentEdgeInResult",value:function(){for(var f=this.getEdges().getEdges().iterator();f.hasNext();)if(f.next().getEdge().isInResult())return!0;return!1}},{key:"isIsolated",value:function(){return this._label.getGeometryCount()===1}},{key:"getCoordinate",value:function(){return this._coord}},{key:"print",value:function(f){f.println("node "+this._coord+" lbl: "+this._label)}},{key:"computeIM",value:function(f){}},{key:"computeMergedLocation",value:function(f,w){var G=fe.NONE;if(G=this._label.getLocation(w),!f.isNull(w)){var re=f.getLocation(w);G!==fe.BOUNDARY&&(G=re)}return G}},{key:"setLabel",value:function(){if(arguments.length!==2||!Number.isInteger(arguments[1])||!Number.isInteger(arguments[0]))return P(h,"setLabel",this,1).apply(this,arguments);var f=arguments[0],w=arguments[1];this._label===null?this._label=new Zr(f,w):this._label.setLocation(f,w)}},{key:"getEdges",value:function(){return this._edges}},{key:"mergeLabel",value:function(){if(arguments[0]instanceof h){var f=arguments[0];this.mergeLabel(f._label)}else if(arguments[0]instanceof Zr)for(var w=arguments[0],G=0;G<2;G++){var re=this.computeMergedLocation(w,G);this._label.getLocation(G)===fe.NONE&&this._label.setLocation(G,re)}}},{key:"add",value:function(f){this._edges.insert(f),f.setNode(this)}},{key:"setLabelBoundary",value:function(f){if(this._label===null)return null;var w=fe.NONE;this._label!==null&&(w=this._label.getLocation(f));var G=null;switch(w){case fe.BOUNDARY:G=fe.INTERIOR;break;case fe.INTERIOR:default:G=fe.BOUNDARY}this._label.setLocation(f,G)}}],[{key:"constructor_",value:function(){this._coord=null,this._edges=null;var f=arguments[0],w=arguments[1];this._coord=f,this._edges=w,this._label=new Zr(0,fe.NONE)}}])}(nr),wl=function(N){function h(){return l(this,h),a(this,h,arguments)}return x(h,N),i(h)}(Yr);function Nl(N){return N==null?0:N.color}function lr(N){return N==null?null:N.parent}function Xi(N,h){N!==null&&(N.color=h)}function ml(N){return N==null?null:N.left}function Co(N){return N==null?null:N.right}var ti=function(N){function h(){var f;return l(this,h),(f=a(this,h)).root_=null,f.size_=0,f}return x(h,N),i(h,[{key:"get",value:function(f){for(var w=this.root_;w!==null;){var G=f.compareTo(w.key);if(G<0)w=w.left;else{if(!(G>0))return w.value;w=w.right}}return null}},{key:"put",value:function(f,w){if(this.root_===null)return this.root_={key:f,value:w,left:null,right:null,parent:null,color:0,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var G,re,xe=this.root_;do if(G=xe,(re=f.compareTo(xe.key))<0)xe=xe.left;else{if(!(re>0)){var Ae=xe.value;return xe.value=w,Ae}xe=xe.right}while(xe!==null);var tt={key:f,left:null,right:null,value:w,parent:G,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return re<0?G.left=tt:G.right=tt,this.fixAfterInsertion(tt),this.size_++,null}},{key:"fixAfterInsertion",value:function(f){var w;for(f.color=1;f!=null&&f!==this.root_&&f.parent.color===1;)lr(f)===ml(lr(lr(f)))?Nl(w=Co(lr(lr(f))))===1?(Xi(lr(f),0),Xi(w,0),Xi(lr(lr(f)),1),f=lr(lr(f))):(f===Co(lr(f))&&(f=lr(f),this.rotateLeft(f)),Xi(lr(f),0),Xi(lr(lr(f)),1),this.rotateRight(lr(lr(f)))):Nl(w=ml(lr(lr(f))))===1?(Xi(lr(f),0),Xi(w,0),Xi(lr(lr(f)),1),f=lr(lr(f))):(f===ml(lr(f))&&(f=lr(f),this.rotateRight(f)),Xi(lr(f),0),Xi(lr(lr(f)),1),this.rotateLeft(lr(lr(f))));this.root_.color=0}},{key:"values",value:function(){var f=new ps,w=this.getFirstEntry();if(w!==null)for(f.add(w.value);(w=h.successor(w))!==null;)f.add(w.value);return f}},{key:"entrySet",value:function(){var f=new as,w=this.getFirstEntry();if(w!==null)for(f.add(w);(w=h.successor(w))!==null;)f.add(w);return f}},{key:"rotateLeft",value:function(f){if(f!=null){var w=f.right;f.right=w.left,w.left!=null&&(w.left.parent=f),w.parent=f.parent,f.parent==null?this.root_=w:f.parent.left===f?f.parent.left=w:f.parent.right=w,w.left=f,f.parent=w}}},{key:"rotateRight",value:function(f){if(f!=null){var w=f.left;f.left=w.right,w.right!=null&&(w.right.parent=f),w.parent=f.parent,f.parent==null?this.root_=w:f.parent.right===f?f.parent.right=w:f.parent.left=w,w.right=f,f.parent=w}}},{key:"getFirstEntry",value:function(){var f=this.root_;if(f!=null)for(;f.left!=null;)f=f.left;return f}},{key:"size",value:function(){return this.size_}},{key:"containsKey",value:function(f){for(var w=this.root_;w!==null;){var G=f.compareTo(w.key);if(G<0)w=w.left;else{if(!(G>0))return!0;w=w.right}}return!1}}],[{key:"successor",value:function(f){var w;if(f===null)return null;if(f.right!==null){for(w=f.right;w.left!==null;)w=w.left;return w}w=f.parent;for(var G=f;w!==null&&G===w.right;)G=w,w=w.parent;return w}}])}(wl),qs=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"find",value:function(N){return this.nodeMap.get(N)}},{key:"addNode",value:function(){if(arguments[0]instanceof Re){var N=arguments[0],h=this.nodeMap.get(N);return h===null&&(h=this.nodeFact.createNode(N),this.nodeMap.put(N,h)),h}if(arguments[0]instanceof Br){var f=arguments[0],w=this.nodeMap.get(f.getCoordinate());return w===null?(this.nodeMap.put(f.getCoordinate(),f),f):(w.mergeLabel(f),w)}}},{key:"print",value:function(N){for(var h=this.iterator();h.hasNext();)h.next().print(N)}},{key:"iterator",value:function(){return this.nodeMap.values().iterator()}},{key:"values",value:function(){return this.nodeMap.values()}},{key:"getBoundaryNodes",value:function(N){for(var h=new ps,f=this.iterator();f.hasNext();){var w=f.next();w.getLabel().getLocation(N)===fe.BOUNDARY&&h.add(w)}return h}},{key:"add",value:function(N){var h=N.getCoordinate();this.addNode(h).add(N)}}
759],[{key:"constructor_",value:function(){this.nodeMap=new ti,this.nodeFact=null;var N=arguments[0];this.nodeFact=N}}])}(),Tn=function(){function N(){l(this,N)}return i(N,null,[{key:"isNorthern",value:function(h){return h===N.NE||h===N.NW}},{key:"isOpposite",value:function(h,f){return h!==f&&(h-f+4)%4===2}},{key:"commonHalfPlane",value:function(h,f){if(h===f)return h;if((h-f+4)%4===2)return-1;var w=h<f?h:f;return w===0&&(h>f?h:f)===3?3:w}},{key:"isInHalfPlane",value:function(h,f){return f===N.SE?h===N.SE||h===N.SW:h===f||h===f+1}},{key:"quadrant",value:function(){if(typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var h=arguments[0],f=arguments[1];if(h===0&&f===0)throw new te("Cannot compute the quadrant for point ( "+h+", "+f+" )");return h>=0?f>=0?N.NE:N.SE:f>=0?N.NW:N.SW}if(arguments[0]instanceof Re&&arguments[1]instanceof Re){var w=arguments[0],G=arguments[1];if(G.x===w.x&&G.y===w.y)throw new te("Cannot compute the quadrant for two identical points "+w);return G.x>=w.x?G.y>=w.y?N.NE:N.SE:G.y>=w.y?N.NW:N.SW}}}])}();Tn.NE=0,Tn.NW=1,Tn.SW=2,Tn.SE=3;var oa=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"compareDirection",value:function(h){return this._dx===h._dx&&this._dy===h._dy?0:this._quadrant>h._quadrant?1:this._quadrant<h._quadrant?-1:bs.index(h._p0,h._p1,this._p1)}},{key:"getDy",value:function(){return this._dy}},{key:"getCoordinate",value:function(){return this._p0}},{key:"setNode",value:function(h){this._node=h}},{key:"print",value:function(h){var f=Math.atan2(this._dy,this._dx),w=this.getClass().getName(),G=w.lastIndexOf("."),re=w.substring(G+1);h.print("  "+re+": "+this._p0+" - "+this._p1+" "+this._quadrant+":"+f+"   "+this._label)}},{key:"compareTo",value:function(h){var f=h;return this.compareDirection(f)}},{key:"getDirectedCoordinate",value:function(){return this._p1}},{key:"getDx",value:function(){return this._dx}},{key:"getLabel",value:function(){return this._label}},{key:"getEdge",value:function(){return this._edge}},{key:"getQuadrant",value:function(){return this._quadrant}},{key:"getNode",value:function(){return this._node}},{key:"toString",value:function(){var h=Math.atan2(this._dy,this._dx),f=this.getClass().getName(),w=f.lastIndexOf(".");return"  "+f.substring(w+1)+": "+this._p0+" - "+this._p1+" "+this._quadrant+":"+h+"   "+this._label}},{key:"computeLabel",value:function(h){}},{key:"init",value:function(h,f){this._p0=h,this._p1=f,this._dx=f.x-h.x,this._dy=f.y-h.y,this._quadrant=Tn.quadrant(this._dx,this._dy),ke.isTrue(!(this._dx===0&&this._dy===0),"EdgeEnd with identical endpoints found")}},{key:"interfaces_",get:function(){return[H]}}],[{key:"constructor_",value:function(){if(this._edge=null,this._label=null,this._node=null,this._p0=null,this._p1=null,this._dx=null,this._dy=null,this._quadrant=null,arguments.length===1){var h=arguments[0];this._edge=h}else if(arguments.length===3){var f=arguments[0],w=arguments[1],G=arguments[2];N.constructor_.call(this,f,w,G,null)}else if(arguments.length===4){var re=arguments[0],xe=arguments[1],Ae=arguments[2],tt=arguments[3];N.constructor_.call(this,re),this.init(xe,Ae),this._label=tt}}}])}(),Pa=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"getNextMin",value:function(){return this._nextMin}},{key:"getDepth",value:function(f){return this._depth[f]}},{key:"setVisited",value:function(f){this._isVisited=f}},{key:"computeDirectedLabel",value:function(){this._label=new Zr(this._edge.getLabel()),this._isForward||this._label.flip()}},{key:"getNext",value:function(){return this._next}},{key:"setDepth",value:function(f,w){if(this._depth[f]!==-999&&this._depth[f]!==w)throw new Jt("assigned depths do not match",this.getCoordinate());this._depth[f]=w}},{key:"isInteriorAreaEdge",value:function(){for(var f=!0,w=0;w<2;w++)this._label.isArea(w)&&this._label.getLocation(w,Xe.LEFT)===fe.INTERIOR&&this._label.getLocation(w,Xe.RIGHT)===fe.INTERIOR||(f=!1);return f}},{key:"setNextMin",value:function(f){this._nextMin=f}},{key:"print",value:function(f){P(h,"print",this,1).call(this,f),f.print(" "+this._depth[Xe.LEFT]+"/"+this._depth[Xe.RIGHT]),f.print(" ("+this.getDepthDelta()+")"),this._isInResult&&f.print(" inResult")}},{key:"setMinEdgeRing",value:function(f){this._minEdgeRing=f}},{key:"isLineEdge",value:function(){var f=this._label.isLine(0)||this._label.isLine(1),w=!this._label.isArea(0)||this._label.allPositionsEqual(0,fe.EXTERIOR),G=!this._label.isArea(1)||this._label.allPositionsEqual(1,fe.EXTERIOR);return f&&w&&G}},{key:"setEdgeRing",value:function(f){this._edgeRing=f}},{key:"getMinEdgeRing",value:function(){return this._minEdgeRing}},{key:"getDepthDelta",value:function(){var f=this._edge.getDepthDelta();return this._isForward||(f=-f),f}},{key:"setInResult",value:function(f){this._isInResult=f}},{key:"getSym",value:function(){return this._sym}},{key:"isForward",value:function(){return this._isForward}},{key:"getEdge",value:function(){return this._edge}},{key:"printEdge",value:function(f){this.print(f),f.print(" "),this._isForward?this._edge.print(f):this._edge.printReverse(f)}},{key:"setSym",value:function(f){this._sym=f}},{key:"setVisitedEdge",value:function(f){this.setVisited(f),this._sym.setVisited(f)}},{key:"setEdgeDepths",value:function(f,w){var G=this.getEdge().getDepthDelta();this._isForward||(G=-G);var re=1;f===Xe.LEFT&&(re=-1);var xe=Xe.opposite(f),Ae=w+G*re;this.setDepth(f,w),this.setDepth(xe,Ae)}},{key:"getEdgeRing",value:function(){return this._edgeRing}},{key:"isInResult",value:function(){return this._isInResult}},{key:"setNext",value:function(f){this._next=f}},{key:"isVisited",value:function(){return this._isVisited}}
759],[{key:"constructor_",value:function(){this._isForward=null,this._isInResult=!1,this._isVisited=!1,this._sym=null,this._next=null,this._nextMin=null,this._edgeRing=null,this._minEdgeRing=null,this._depth=[0,-999,-999];var f=arguments[0],w=arguments[1];if(oa.constructor_.call(this,f),this._isForward=w,w)this.init(f.getCoordinate(0),f.getCoordinate(1));else{var G=f.getNumPoints()-1;this.init(f.getCoordinate(G),f.getCoordinate(G-1))}this.computeDirectedLabel()}},{key:"depthFactor",value:function(f,w){return f===fe.EXTERIOR&&w===fe.INTERIOR?1:f===fe.INTERIOR&&w===fe.EXTERIOR?-1:0}}])}(oa),mr=function(){return i(function N(){l(this,N)},[{key:"createNode",value:function(N){return new Br(N,null)}}])}(),$r=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"printEdges",value:function(N){N.println("Edges:");for(var h=0;h<this._edges.size();h++){N.println("edge "+h+":");var f=this._edges.get(h);f.print(N),f.eiList.print(N)}}},{key:"find",value:function(N){return this._nodes.find(N)}},{key:"addNode",value:function(){if(arguments[0]instanceof Br){var N=arguments[0];return this._nodes.addNode(N)}if(arguments[0]instanceof Re){var h=arguments[0];return this._nodes.addNode(h)}}},{key:"getNodeIterator",value:function(){return this._nodes.iterator()}},{key:"linkResultDirectedEdges",value:function(){for(var N=this._nodes.iterator();N.hasNext();)N.next().getEdges().linkResultDirectedEdges()}},{key:"debugPrintln",value:function(N){Is.out.println(N)}},{key:"isBoundaryNode",value:function(N,h){var f=this._nodes.find(h);if(f===null)return!1;var w=f.getLabel();return w!==null&&w.getLocation(N)===fe.BOUNDARY}},{key:"linkAllDirectedEdges",value:function(){for(var N=this._nodes.iterator();N.hasNext();)N.next().getEdges().linkAllDirectedEdges()}},{key:"matchInSameDirection",value:function(N,h,f,w){return!!N.equals(f)&&bs.index(N,h,w)===bs.COLLINEAR&&Tn.quadrant(N,h)===Tn.quadrant(f,w)}},{key:"getEdgeEnds",value:function(){return this._edgeEndList}},{key:"debugPrint",value:function(N){Is.out.print(N)}},{key:"getEdgeIterator",value:function(){return this._edges.iterator()}},{key:"findEdgeInSameDirection",value:function(N,h){for(var f=0;f<this._edges.size();f++){var w=this._edges.get(f),G=w.getCoordinates();if(this.matchInSameDirection(N,h,G[0],G[1])||this.matchInSameDirection(N,h,G[G.length-1],G[G.length-2]))return w}return null}},{key:"insertEdge",value:function(N){this._edges.add(N)}},{key:"findEdgeEnd",value:function(N){for(var h=this.getEdgeEnds().iterator();h.hasNext();){var f=h.next();if(f.getEdge()===N)return f}return null}},{key:"addEdges",value:function(N){for(var h=N.iterator();h.hasNext();){var f=h.next();this._edges.add(f);var w=new Pa(f,!0),G=new Pa(f,!1);w.setSym(G),G.setSym(w),this.add(w),this.add(G)}}},{key:"add",value:function(N){this._nodes.add(N),this._edgeEndList.add(N)}},{key:"getNodes",value:function(){return this._nodes.values()}},{key:"findEdge",value:function(N,h){for(var f=0;f<this._edges.size();f++){var w=this._edges.get(f),G=w.getCoordinates();if(N.equals(G[0])&&h.equals(G[1]))return w}return null}}],[{key:"constructor_",value:function(){if(this._edges=new ps,this._nodes=null,this._edgeEndList=new ps,arguments.length===0)this._nodes=new qs(new mr);else if(arguments.length===1){var N=arguments[0];this._nodes=new qs(N)}}},{key:"linkResultDirectedEdges",value:function(N){for(var h=N.iterator();h.hasNext();)h.next().getEdges().linkResultDirectedEdges()}}])}(),Jo=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"sortShellsAndHoles",value:function(h,f,w){for(var G=h.iterator();G.hasNext();){var re=G.next();re.isHole()?w.add(re):f.add(re)}}},{key:"computePolygons",value:function(h){for(var f=new ps,w=h.iterator();w.hasNext();){var G=w.next().toPolygon(this._geometryFactory);f.add(G)}return f}},{key:"placeFreeHoles",value:function(h,f){for(var w=f.iterator();w.hasNext();){var G=w.next();if(G.getShell()===null){var re=N.findEdgeRingContaining(G,h);if(re===null)throw new Jt("unable to assign hole to a shell",G.getCoordinate(0));G.setShell(re)}}}},{key:"buildMinimalEdgeRings",value:function(h,f,w){for(var G=new ps,re=h.iterator();re.hasNext();){var xe=re.next();if(xe.getMaxNodeDegree()>2){xe.linkDirectedEdgesForMinimalEdgeRings();var Ae=xe.buildMinimalRings(),tt=this.findShell(Ae);tt!==null?(this.placePolygonHoles(tt,Ae),f.add(tt)):w.addAll(Ae)}else G.add(xe)}return G}},{key:"buildMaximalEdgeRings",value:function(h){for(var f=new ps,w=h.iterator();w.hasNext();){var G=w.next();if(G.isInResult()&&G.getLabel().isArea()&&G.getEdgeRing()===null){var re=new kr(G,this._geometryFactory);f.add(re),re.setInResult()}}return f}},{key:"placePolygonHoles",value:function(h,f){for(var w=f.iterator();w.hasNext();){var G=w.next();G.isHole()&&G.setShell(h)}}},{key:"getPolygons",value:function(){return this.computePolygons(this._shellList)}},{key:"findShell",value:function(h){for(var f=0,w=null,G=h.iterator();G.hasNext();){var re=G.next();re.isHole()||(w=re,f++)}return ke.isTrue(f<=1,"found two shells in MinimalEdgeRing list"),w}},{key:"add",value:function(){if(arguments.length===1){var h=arguments[0];this.add(h.getEdgeEnds(),h.getNodes())}else if(arguments.length===2){var f=arguments[0],w=arguments[1];$r.linkResultDirectedEdges(w);var G=this.buildMaximalEdgeRings(f),re=new ps,xe=this.buildMinimalEdgeRings(G,this._shellList,re);this.sortShellsAndHoles(xe,this._shellList,re),this.placeFreeHoles(this._shellList,re)}}}
vendor: 6,653 bytes, line 759
759],[{key:"constructor_",value:function(){this._geometryFactory=null,this._shellList=new ps;var h=arguments[0];this._geometryFactory=h}},{key:"findEdgeRingContaining",value:function(h,f){for(var w=h.getLinearRing(),G=w.getEnvelopeInternal(),re=w.getCoordinateN(0),xe=null,Ae=null,tt=f.iterator();tt.hasNext();){var Nt=tt.next(),Ut=Nt.getLinearRing(),xs=Ut.getEnvelopeInternal();if(!xs.equals(G)&&xs.contains(G)){re=Fn.ptNotInList(w.getCoordinates(),Ut.getCoordinates());var $s=!1;Nr.isInRing(re,Ut.getCoordinates())&&($s=!0),$s&&(xe===null||Ae.contains(xs))&&(Ae=(xe=Nt).getLinearRing().getEnvelopeInternal())}}return xe}}])}(),na=function(){return i(function N(){l(this,N)},[{key:"getBounds",value:function(){}}])}(),Sn=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"getItem",value:function(){return this._item}},{key:"getBounds",value:function(){return this._bounds}},{key:"interfaces_",get:function(){return[na,q]}}],[{key:"constructor_",value:function(){this._bounds=null,this._item=null;var N=arguments[0],h=arguments[1];this._bounds=N,this._item=h}}])}(),Ui=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"poll",value:function(){if(this.isEmpty())return null;var N=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),N}},{key:"size",value:function(){return this._size}},{key:"reorder",value:function(N){for(var h=null,f=this._items.get(N);2*N<=this._size&&((h=2*N)!==this._size&&this._items.get(h+1).compareTo(this._items.get(h))<0&&h++,this._items.get(h).compareTo(f)<0);N=h)this._items.set(N,this._items.get(h));this._items.set(N,f)}},{key:"clear",value:function(){this._size=0,this._items.clear()}},{key:"peek",value:function(){return this.isEmpty()?null:this._items.get(1)}},{key:"isEmpty",value:function(){return this._size===0}},{key:"add",value:function(N){this._items.add(null),this._size+=1;var h=this._size;for(this._items.set(0,N);N.compareTo(this._items.get(Math.trunc(h/2)))<0;h/=2)this._items.set(h,this._items.get(Math.trunc(h/2)));this._items.set(h,N)}}],[{key:"constructor_",value:function(){this._size=null,this._items=null,this._size=0,this._items=new ps,this._items.add(null)}}])}(),Ma=function(){return i(function N(){l(this,N)},[{key:"insert",value:function(N,h){}},{key:"remove",value:function(N,h){}},{key:"query",value:function(){}}])}(),Di=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"getLevel",value:function(){return this._level}},{key:"size",value:function(){return this._childBoundables.size()}},{key:"getChildBoundables",value:function(){return this._childBoundables}},{key:"addChildBoundable",value:function(N){ke.isTrue(this._bounds===null),this._childBoundables.add(N)}},{key:"isEmpty",value:function(){return this._childBoundables.isEmpty()}},{key:"getBounds",value:function(){return this._bounds===null&&(this._bounds=this.computeBounds()),this._bounds}},{key:"interfaces_",get:function(){return[na,q]}}],[{key:"constructor_",value:function(){if(this._childBoundables=new ps,this._bounds=null,this._level=null,arguments.length!==0){if(arguments.length===1){var N=arguments[0];this._level=N}}}}])}(),Al={reverseOrder:function(){return{compare:function(N,h){return h.compareTo(N)}}},min:function(N){return Al.sort(N),N.get(0)},sort:function(N,h){var f=N.toArray();h?es.sort(f,h):es.sort(f);for(var w=N.iterator(),G=0,re=f.length;G<re;G++)w.next(),w.set(f[G])},singletonList:function(N){var h=new ps;return h.add(N),h}},cc=function(){function N(){l(this,N)}return i(N,null,[{key:"maxDistance",value:function(h,f,w,G,re,xe,Ae,tt){var Nt=N.distance(h,f,re,xe);return Nt=Math.max(Nt,N.distance(h,f,Ae,tt)),Nt=Math.max(Nt,N.distance(w,G,re,xe)),Nt=Math.max(Nt,N.distance(w,G,Ae,tt))}},{key:"distance",value:function(h,f,w,G){var re=w-h,xe=G-f;return Math.sqrt(re*re+xe*xe)}},{key:"maximumDistance",value:function(h,f){var w=Math.min(h.getMinX(),f.getMinX()),G=Math.min(h.getMinY(),f.getMinY()),re=Math.max(h.getMaxX(),f.getMaxX()),xe=Math.max(h.getMaxY(),f.getMaxY());return N.distance(w,G,re,xe)}},{key:"minMaxDistance",value:function(h,f){var w=h.getMinX(),G=h.getMinY(),re=h.getMaxX(),xe=h.getMaxY(),Ae=f.getMinX(),tt=f.getMinY(),Nt=f.getMaxX(),Ut=f.getMaxY(),xs=N.maxDistance(w,G,w,xe,Ae,tt,Ae,Ut);return xs=Math.min(xs,N.maxDistance(w,G,w,xe,Ae,tt,Nt,tt)),xs=Math.min(xs,N.maxDistance(w,G,w,xe,Nt,Ut,Ae,Ut)),xs=Math.min(xs,N.maxDistance(w,G,w,xe,Nt,Ut,Nt,tt)),xs=Math.min(xs,N.maxDistance(w,G,re,G,Ae,tt,Ae,Ut)),xs=Math.min(xs,N.maxDistance(w,G,re,G,Ae,tt,Nt,tt)),xs=Math.min(xs,N.maxDistance(w,G,re,G,Nt,Ut,Ae,Ut)),xs=Math.min(xs,N.maxDistance(w,G,re,G,Nt,Ut,Nt,tt)),xs=Math.min(xs,N.maxDistance(re,xe,w,xe,Ae,tt,Ae,Ut)),xs=Math.min(xs,N.maxDistance(re,xe,w,xe,Ae,tt,Nt,tt)),xs=Math.min(xs,N.maxDistance(re,xe,w,xe,Nt,Ut,Ae,Ut)),xs=Math.min(xs,N.maxDistance(re,xe,w,xe,Nt,Ut,Nt,tt)),xs=Math.min(xs,N.maxDistance(re,xe,re,G,Ae,tt,Ae,Ut)),xs=Math.min(xs,N.maxDistance(re,xe,re,G,Ae,tt,Nt,tt)),xs=Math.min(xs,N.maxDistance(re,xe,re,G,Nt,Ut,Ae,Ut)),xs=Math.min(xs,N.maxDistance(re,xe,re,G,Nt,Ut,Nt,tt))}}])}(),dc=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"maximumDistance",value:function(){return cc.maximumDistance(this._boundable1.getBounds(),this._boundable2.getBounds())}},{key:"expandToQueue",value:function(h,f){var w=N.isComposite(this._boundable1),G=N.isComposite(this._boundable2);if(w&&G)return N.area(this._boundable1)>N.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,!1,h,f),null):(this.expand(this._boundable2,this._boundable1,!0,h,f),null);if(w)return this.expand(this._boundable1,this._boundable2,!1,h,f),null;if(G)return this.expand(this._boundable2,this._boundable1,!0,h,f),null;throw new te("neither boundable is composite")}},{key:"isLeaves",value:function(){return!(N.isComposite(this._boundable1)||N.isComposite(this._boundable2))}},{key:"compareTo",value:function(h){var f=h;return this._distance<f._distance?-1:this._distance>f._distance?1:0}},{key:"expand",value:function(h,f,w,G,re){for(var xe=h.getChildBoundables().iterator();xe.hasNext();){var Ae=xe.next(),tt=null;(tt=w?new N(f,Ae,this._itemDistance):new N(Ae,f,this._itemDistance)).getDistance()<re&&G.add(tt)}}},{key:"getBoundable",value:function(h){return h===0?this._boundable1:this._boundable2}},{key:"getDistance",value:function(){return this._distance}},{key:"distance",value:function(){return this.isLeaves()?this._itemDistance.distance(this._boundable1,this._boundable2):this._boundable1.getBounds().distance(this._boundable2.getBounds())}},{key:"interfaces_",get:function(){return[H]}}
759],[{key:"constructor_",value:function(){this._boundable1=null,this._boundable2=null,this._distance=null,this._itemDistance=null;var h=arguments[0],f=arguments[1],w=arguments[2];this._boundable1=h,this._boundable2=f,this._itemDistance=w,this._distance=this.distance()}},{key:"area",value:function(h){return h.getBounds().getArea()}},{key:"isComposite",value:function(h){return h instanceof Di}}])}(),_u=function(){return i(function N(){l(this,N)},[{key:"visitItem",value:function(N){}}])}(),uc=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"queryInternal",value:function(){if(zt(arguments[2],_u)&&arguments[0]instanceof Object&&arguments[1]instanceof Di)for(var h=arguments[0],f=arguments[2],w=arguments[1].getChildBoundables(),G=0;G<w.size();G++){var re=w.get(G);this.getIntersectsOp().intersects(re.getBounds(),h)&&(re instanceof Di?this.queryInternal(h,re,f):re instanceof Sn?f.visitItem(re.getItem()):ke.shouldNeverReachHere())}else if(zt(arguments[2],Dt)&&arguments[0]instanceof Object&&arguments[1]instanceof Di)for(var xe=arguments[0],Ae=arguments[2],tt=arguments[1].getChildBoundables(),Nt=0;Nt<tt.size();Nt++){var Ut=tt.get(Nt);this.getIntersectsOp().intersects(Ut.getBounds(),xe)&&(Ut instanceof Di?this.queryInternal(xe,Ut,Ae):Ut instanceof Sn?Ae.add(Ut.getItem()):ke.shouldNeverReachHere())}}},{key:"getNodeCapacity",value:function(){return this._nodeCapacity}},{key:"lastNode",value:function(h){return h.get(h.size()-1)}},{key:"size",value:function(){if(arguments.length===0)return this.isEmpty()?0:(this.build(),this.size(this._root));if(arguments.length===1){for(var h=0,f=arguments[0].getChildBoundables().iterator();f.hasNext();){var w=f.next();w instanceof Di?h+=this.size(w):w instanceof Sn&&(h+=1)}return h}}},{key:"removeItem",value:function(h,f){for(var w=null,G=h.getChildBoundables().iterator();G.hasNext();){var re=G.next();re instanceof Sn&&re.getItem()===f&&(w=re)}return w!==null&&(h.getChildBoundables().remove(w),!0)}},{key:"itemsTree",value:function(){if(arguments.length===0){this.build();var h=this.itemsTree(this._root);return h===null?new ps:h}if(arguments.length===1){for(var f=arguments[0],w=new ps,G=f.getChildBoundables().iterator();G.hasNext();){var re=G.next();if(re instanceof Di){var xe=this.itemsTree(re);xe!==null&&w.add(xe)}else re instanceof Sn?w.add(re.getItem()):ke.shouldNeverReachHere()}return w.size()<=0?null:w}}},{key:"insert",value:function(h,f){ke.isTrue(!this._built,"Cannot insert items into an STR packed R-tree after it has been built."),this._itemBoundables.add(new Sn(h,f))}},{key:"boundablesAtLevel",value:function(){if(arguments.length===1){var h=arguments[0],f=new ps;return this.boundablesAtLevel(h,this._root,f),f}if(arguments.length===3){var w=arguments[0],G=arguments[1],re=arguments[2];if(ke.isTrue(w>-2),G.getLevel()===w)return re.add(G),null;for(var xe=G.getChildBoundables().iterator();xe.hasNext();){var Ae=xe.next();Ae instanceof Di?this.boundablesAtLevel(w,Ae,re):(ke.isTrue(Ae instanceof Sn),w===-1&&re.add(Ae))}return null}}},{key:"query",value:function(){if(arguments.length===1){var h=arguments[0];this.build();var f=new ps;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),h)&&this.queryInternal(h,this._root,f),f}if(arguments.length===2){var w=arguments[0],G=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),w)&&this.queryInternal(w,this._root,G)}}},{key:"build",value:function(){if(this._built)return null;this._root=this._itemBoundables.isEmpty()?this.createNode(0):this.createHigherLevels(this._itemBoundables,-1),this._itemBoundables=null,this._built=!0}},{key:"getRoot",value:function(){return this.build(),this._root}},{key:"remove",value:function(){if(arguments.length===2){var h=arguments[0],f=arguments[1];return this.build(),!!this.getIntersectsOp().intersects(this._root.getBounds(),h)&&this.remove(h,this._root,f)}if(arguments.length===3){var w=arguments[0],G=arguments[1],re=arguments[2],xe=this.removeItem(G,re);if(xe)return!0;for(var Ae=null,tt=G.getChildBoundables().iterator();tt.hasNext();){var Nt=tt.next();if(this.getIntersectsOp().intersects(Nt.getBounds(),w)&&Nt instanceof Di&&(xe=this.remove(w,Nt,re))){Ae=Nt;break}}return Ae!==null&&Ae.getChildBoundables().isEmpty()&&G.getChildBoundables().remove(Ae),xe}}},{key:"createHigherLevels",value:function(h,f){ke.isTrue(!h.isEmpty());var w=this.createParentBoundables(h,f+1);return w.size()===1?w.get(0):this.createHigherLevels(w,f+1)}},{key:"depth",value:function(){if(arguments.length===0)return this.isEmpty()?0:(this.build(),this.depth(this._root));if(arguments.length===1){for(var h=0,f=arguments[0].getChildBoundables().iterator();f.hasNext();){var w=f.next();if(w instanceof Di){var G=this.depth(w);G>h&&(h=G)}}return h+1}
759}},{key:"createParentBoundables",value:function(h,f){ke.isTrue(!h.isEmpty());var w=new ps;w.add(this.createNode(f));var G=new ps(h);Al.sort(G,this.getComparator());for(var re=G.iterator();re.hasNext();){var xe=re.next();this.lastNode(w).getChildBoundables().size()===this.getNodeCapacity()&&w.add(this.createNode(f)),this.lastNode(w).addChildBoundable(xe)}return w}},{key:"isEmpty",value:function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()}},{key:"interfaces_",get:function(){return[q]}}],[{key:"constructor_",value:function(){if(this._root=null,this._built=!1,this._itemBoundables=new ps,this._nodeCapacity=null,arguments.length===0)N.constructor_.call(this,N.DEFAULT_NODE_CAPACITY);else if(arguments.length===1){var h=arguments[0];ke.isTrue(h>1,"Node capacity must be greater than 1"),this._nodeCapacity=h}}},{key:"compareDoubles",value:function(h,f){return h>f?1:h<f?-1:0}}])}();uc.IntersectsOp=function(){},uc.DEFAULT_NODE_CAPACITY=10;var hc=function(){return i(function N(){l(this,N)},[{key:"distance",value:function(N,h){}}])}(),kl=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"createParentBoundablesFromVerticalSlices",value:function(f,w){ke.isTrue(f.length>0);for(var G=new ps,re=0;re<f.length;re++)G.addAll(this.createParentBoundablesFromVerticalSlice(f[re],w));return G}},{key:"nearestNeighbourK",value:function(){if(arguments.length===2){var f=arguments[0],w=arguments[1];return this.nearestNeighbourK(f,Ee.POSITIVE_INFINITY,w)}if(arguments.length===3){var G=arguments[0],re=arguments[2],xe=arguments[1],Ae=new Ui;Ae.add(G);for(var tt=new Ui;!Ae.isEmpty()&&xe>=0;){var Nt=Ae.poll(),Ut=Nt.getDistance();if(Ut>=xe)break;Nt.isLeaves()?tt.size()<re?tt.add(Nt):(tt.peek().getDistance()>Ut&&(tt.poll(),tt.add(Nt)),xe=tt.peek().getDistance()):Nt.expandToQueue(Ae,xe)}return h.getItems(tt)}}},{key:"createNode",value:function(f){return new Ki(f)}},{key:"size",value:function(){return arguments.length===0?P(h,"size",this,1).call(this):P(h,"size",this,1).apply(this,arguments)}},{key:"insert",value:function(){if(!(arguments.length===2&&arguments[1]instanceof Object&&arguments[0]instanceof ft))return P(h,"insert",this,1).apply(this,arguments);var f=arguments[0],w=arguments[1];if(f.isNull())return null;P(h,"insert",this,1).call(this,f,w)}},{key:"getIntersectsOp",value:function(){return h.intersectsOp}},{key:"verticalSlices",value:function(f,w){for(var G=Math.trunc(Math.ceil(f.size()/w)),re=new Array(w).fill(null),xe=f.iterator(),Ae=0;Ae<w;Ae++){re[Ae]=new ps;for(var tt=0;xe.hasNext()&&tt<G;){var Nt=xe.next();re[Ae].add(Nt),tt++}}return re}},{key:"query",value:function(){if(arguments.length===1){var f=arguments[0];return P(h,"query",this,1).call(this,f)}if(arguments.length===2){var w=arguments[0],G=arguments[1];P(h,"query",this,1).call(this,w,G)}}},{key:"getComparator",value:function(){return h.yComparator}},{key:"createParentBoundablesFromVerticalSlice",value:function(f,w){return P(h,"createParentBoundables",this,1).call(this,f,w)}},{key:"remove",value:function(){if(arguments.length===2&&arguments[1]instanceof Object&&arguments[0]instanceof ft){var f=arguments[0],w=arguments[1];return P(h,"remove",this,1).call(this,f,w)}return P(h,"remove",this,1).apply(this,arguments)}},{key:"depth",value:function(){return arguments.length===0?P(h,"depth",this,1).call(this):P(h,"depth",this,1).apply(this,arguments)}},{key:"createParentBoundables",value:function(f,w){ke.isTrue(!f.isEmpty());var G=Math.trunc(Math.ceil(f.size()/this.getNodeCapacity())),re=new ps(f);Al.sort(re,h.xComparator);var xe=this.verticalSlices(re,Math.trunc(Math.ceil(Math.sqrt(G))));return this.createParentBoundablesFromVerticalSlices(xe,w)}},{key:"nearestNeighbour",value:function(){if(arguments.length===1){if(zt(arguments[0],hc)){var f=arguments[0];if(this.isEmpty())return null;var w=new dc(this.getRoot(),this.getRoot(),f);return this.nearestNeighbour(w)}if(arguments[0]instanceof dc){var G=arguments[0],re=Ee.POSITIVE_INFINITY,xe=null,Ae=new Ui;for(Ae.add(G);!Ae.isEmpty()&&re>0;){var tt=Ae.poll(),Nt=tt.getDistance();if(Nt>=re)break;tt.isLeaves()?(re=Nt,xe=tt):tt.expandToQueue(Ae,re)}return xe===null?null:[xe.getBoundable(0).getItem(),xe.getBoundable(1).getItem()]}}else{if(arguments.length===2){var Ut=arguments[0],xs=arguments[1];if(this.isEmpty()||Ut.isEmpty())return null;var $s=new dc(this.getRoot(),Ut.getRoot(),xs);return this.nearestNeighbour($s)}if(arguments.length===3){var bn=arguments[2],da=new Sn(arguments[0],arguments[1]),wa=new dc(this.getRoot(),da,bn);return this.nearestNeighbour(wa)[0]}if(arguments.length===4){var Lr=arguments[2],ur=arguments[3],si=new Sn(arguments[0],arguments[1]),Ei=new dc(this.getRoot(),si,Lr);return this.nearestNeighbourK(Ei,ur)}}}},{key:"isWithinDistance",value:function(){if(arguments.length===2){var f=arguments[0],w=arguments[1],G=Ee.POSITIVE_INFINITY,re=new Ui;for(re.add(f);!re.isEmpty();){var xe=re.poll(),Ae=xe.getDistance();if(Ae>w)return!1;if(xe.maximumDistance()<=w)return!0;
759if(xe.isLeaves()){if((G=Ae)<=w)return!0}else xe.expandToQueue(re,G)}return!1}if(arguments.length===3){var tt=arguments[0],Nt=arguments[1],Ut=arguments[2],xs=new dc(this.getRoot(),tt.getRoot(),Nt);return this.isWithinDistance(xs,Ut)}}},{key:"interfaces_",get:function(){return[Ma,q]}}],[{key:"constructor_",value:function(){if(arguments.length===0)h.constructor_.call(this,h.DEFAULT_NODE_CAPACITY);else if(arguments.length===1){var f=arguments[0];uc.constructor_.call(this,f)}}},{key:"centreX",value:function(f){return h.avg(f.getMinX(),f.getMaxX())}},{key:"avg",value:function(f,w){return(f+w)/2}},{key:"getItems",value:function(f){for(var w=new Array(f.size()).fill(null),G=0;!f.isEmpty();){var re=f.poll();w[G]=re.getBoundable(0).getItem(),G++}return w}},{key:"centreY",value:function(f){return h.avg(f.getMinY(),f.getMaxY())}}])}(uc),Ki=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"computeBounds",value:function(){for(var f=null,w=this.getChildBoundables().iterator();w.hasNext();){var G=w.next();f===null?f=new ft(G.getBounds()):f.expandToInclude(G.getBounds())}return f}}],[{key:"constructor_",value:function(){var f=arguments[0];Di.constructor_.call(this,f)}}])}(Di);kl.STRtreeNode=Ki,kl.xComparator=new(function(){return i(function N(){l(this,N)},[{key:"interfaces_",get:function(){return[ve]}},{key:"compare",value:function(N,h){return uc.compareDoubles(kl.centreX(N.getBounds()),kl.centreX(h.getBounds()))}}])}()),kl.yComparator=new(function(){return i(function N(){l(this,N)},[{key:"interfaces_",get:function(){return[ve]}},{key:"compare",value:function(N,h){return uc.compareDoubles(kl.centreY(N.getBounds()),kl.centreY(h.getBounds()))}}])}()),kl.intersectsOp=new(function(){return i(function N(){l(this,N)},[{key:"interfaces_",get:function(){return[IntersectsOp]}},{key:"intersects",value:function(N,h){return N.intersects(h)}}])}()),kl.DEFAULT_NODE_CAPACITY=10;var Dl=function(){function N(){l(this,N)}return i(N,null,[{key:"relativeSign",value:function(h,f){return h<f?-1:h>f?1:0}},{key:"compare",value:function(h,f,w){if(f.equals2D(w))return 0;var G=N.relativeSign(f.x,w.x),re=N.relativeSign(f.y,w.y);switch(h){case 0:return N.compareValue(G,re);case 1:return N.compareValue(re,G);case 2:return N.compareValue(re,-G);case 3:return N.compareValue(-G,re);case 4:return N.compareValue(-G,-re);case 5:return N.compareValue(-re,-G);case 6:return N.compareValue(-re,G);case 7:return N.compareValue(G,-re)}return ke.shouldNeverReachHere("invalid octant value"),0}},{key:"compareValue",value:function(h,f){return h<0?-1:h>0?1:f<0?-1:f>0?1:0}}])}(),Ri=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(N){N.print(this.coord),N.print(" seg # = "+this.segmentIndex)}},{key:"compareTo",value:function(N){var h=N;return this.segmentIndex<h.segmentIndex?-1:this.segmentIndex>h.segmentIndex?1:this.coord.equals2D(h.coord)?0:this._isInterior?h._isInterior?Dl.compare(this._segmentOctant,this.coord,h.coord):1:-1}},{key:"isEndPoint",value:function(N){return this.segmentIndex===0&&!this._isInterior||this.segmentIndex===N}},{key:"toString",value:function(){return this.segmentIndex+":"+this.coord.toString()}},{key:"isInterior",value:function(){return this._isInterior}},{key:"interfaces_",get:function(){return[H]}}],[{key:"constructor_",value:function(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;var N=arguments[0],h=arguments[1],f=arguments[2],w=arguments[3];this._segString=N,this.coord=new Re(h),this.segmentIndex=f,this._segmentOctant=w,this._isInterior=!h.equals2D(N.getCoordinate(f))}}])}(),Qo=function(){return i(function N(){l(this,N)},[{key:"hasNext",value:function(){}},{key:"next",value:function(){}},{key:"remove",value:function(){}}])}(),Cl=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"getSplitCoordinates",value:function(){var N=new xa;this.addEndpoints();for(var h=this.iterator(),f=h.next();h.hasNext();){var w=h.next();this.addEdgeCoordinates(f,w,N),f=w}return N.toCoordinateArray()}},{key:"addCollapsedNodes",value:function(){var N=new ps;this.findCollapsesFromInsertedNodes(N),this.findCollapsesFromExistingVertices(N);for(var h=N.iterator();h.hasNext();){var f=h.next().intValue();this.add(this._edge.getCoordinate(f),f)}}},{key:"createSplitEdgePts",value:function(N,h){var f=h.segmentIndex-N.segmentIndex+2;if(f===2)return[new Re(N.coord),new Re(h.coord)];var w=this._edge.getCoordinate(h.segmentIndex),G=h.isInterior()||!h.coord.equals2D(w);G||f--;var re=new Array(f).fill(null),xe=0;re[xe++]=new Re(N.coord);for(var Ae=N.segmentIndex+1;Ae<=h.segmentIndex;Ae++)re[xe++]=this._edge.getCoordinate(Ae);return G&&(re[xe]=new Re(h.coord)),re}},{key:"print",value:function(N){N.println("Intersections:");for(var h=this.iterator();h.hasNext();)h.next().print(N)}},{key:"findCollapsesFromExistingVertices",value:function(N){for(var h=0;h<this._edge.size()-2;h++){var f=this._edge.getCoordinate(h);this._edge.getCoordinate(h+1);var w=this._edge.getCoordinate(h+2);f.equals2D(w)&&N.add(_s.valueOf(h+1))}}},{key:"addEdgeCoordinates",value:function(N,h,f){var w=this.createSplitEdgePts(N,h);f.add(w,!1)}},{key:"iterator",value:function(){return this._nodeMap.values().iterator()}},{key:"addSplitEdges",value:function(N){this.addEndpoints(),this.addCollapsedNodes();for(var h=this.iterator(),f=h.next();h.hasNext();){var w=h.next(),G=this.createSplitEdge(f,w);N.add(G),f=w}
vendor: 9,498 bytes, line 759
759}},{key:"findCollapseIndex",value:function(N,h,f){if(!N.coord.equals2D(h.coord))return!1;var w=h.segmentIndex-N.segmentIndex;return h.isInterior()||w--,w===1&&(f[0]=N.segmentIndex+1,!0)}},{key:"findCollapsesFromInsertedNodes",value:function(N){for(var h=new Array(1).fill(null),f=this.iterator(),w=f.next();f.hasNext();){var G=f.next();this.findCollapseIndex(w,G,h)&&N.add(_s.valueOf(h[0])),w=G}}},{key:"getEdge",value:function(){return this._edge}},{key:"addEndpoints",value:function(){var N=this._edge.size()-1;this.add(this._edge.getCoordinate(0),0),this.add(this._edge.getCoordinate(N),N)}},{key:"createSplitEdge",value:function(N,h){var f=this.createSplitEdgePts(N,h);return new So(f,this._edge.getData())}},{key:"add",value:function(N,h){var f=new Ri(this._edge,N,h,this._edge.getSegmentOctant(h)),w=this._nodeMap.get(f);return w!==null?(ke.isTrue(w.coord.equals2D(N),"Found equal nodes with different coordinates"),w):(this._nodeMap.put(f,f),f)}},{key:"checkSplitEdgesCorrectness",value:function(N){var h=this._edge.getCoordinates(),f=N.get(0).getCoordinate(0);if(!f.equals2D(h[0]))throw new we("bad split edge start point at "+f);var w=N.get(N.size()-1).getCoordinates(),G=w[w.length-1];if(!G.equals2D(h[h.length-1]))throw new we("bad split edge end point at "+G)}}],[{key:"constructor_",value:function(){this._nodeMap=new ti,this._edge=null;var N=arguments[0];this._edge=N}}])}(),Rl=function(){function N(){l(this,N)}return i(N,null,[{key:"octant",value:function(){if(typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var h=arguments[0],f=arguments[1];if(h===0&&f===0)throw new te("Cannot compute the octant for point ( "+h+", "+f+" )");var w=Math.abs(h),G=Math.abs(f);return h>=0?f>=0?w>=G?0:1:w>=G?7:6:f>=0?w>=G?3:2:w>=G?4:5}if(arguments[0]instanceof Re&&arguments[1]instanceof Re){var re=arguments[0],xe=arguments[1],Ae=xe.x-re.x,tt=xe.y-re.y;if(Ae===0&&tt===0)throw new te("Cannot compute the octant for two identical points "+re);return N.octant(Ae,tt)}}}])}(),Md=function(){return i(function N(){l(this,N)},[{key:"getCoordinates",value:function(){}},{key:"size",value:function(){}},{key:"getCoordinate",value:function(N){}},{key:"isClosed",value:function(){}},{key:"setData",value:function(N){}},{key:"getData",value:function(){}}])}(),fl=function(){return i(function N(){l(this,N)},[{key:"addIntersection",value:function(N,h){}},{key:"interfaces_",get:function(){return[Md]}}])}(),So=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"getCoordinates",value:function(){return this._pts}},{key:"size",value:function(){return this._pts.length}},{key:"getCoordinate",value:function(h){return this._pts[h]}},{key:"isClosed",value:function(){return this._pts[0].equals(this._pts[this._pts.length-1])}},{key:"getSegmentOctant",value:function(h){return h===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(h),this.getCoordinate(h+1))}},{key:"setData",value:function(h){this._data=h}},{key:"safeOctant",value:function(h,f){return h.equals2D(f)?0:Rl.octant(h,f)}},{key:"getData",value:function(){return this._data}},{key:"addIntersection",value:function(){if(arguments.length===2){var h=arguments[0],f=arguments[1];this.addIntersectionNode(h,f)}else if(arguments.length===4){var w=arguments[1],G=arguments[3],re=new Re(arguments[0].getIntersection(G));this.addIntersection(re,w)}}},{key:"toString",value:function(){return Pc.toLineString(new Ai(this._pts))}},{key:"getNodeList",value:function(){return this._nodeList}},{key:"addIntersectionNode",value:function(h,f){var w=f,G=w+1;if(G<this._pts.length){var re=this._pts[G];h.equals2D(re)&&(w=G)}return this._nodeList.add(h,w)}},{key:"addIntersections",value:function(h,f,w){for(var G=0;G<h.getIntersectionNum();G++)this.addIntersection(h,f,w,G)}},{key:"interfaces_",get:function(){return[fl]}}],[{key:"constructor_",value:function(){this._nodeList=new Cl(this),this._pts=null,this._data=null;var h=arguments[0],f=arguments[1];this._pts=h,this._data=f}},{key:"getNodedSubstrings",value:function(){if(arguments.length===1){var h=arguments[0],f=new ps;return N.getNodedSubstrings(h,f),f}if(arguments.length===2)for(var w=arguments[1],G=arguments[0].iterator();G.hasNext();)G.next().getNodeList().addSplitEdges(w)}}])}(),Kr=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"minX",value:function(){return Math.min(this.p0.x,this.p1.x)}},{key:"orientationIndex",value:function(){if(arguments[0]instanceof N){var h=arguments[0],f=bs.index(this.p0,this.p1,h.p0),w=bs.index(this.p0,this.p1,h.p1);return f>=0&&w>=0||f<=0&&w<=0?Math.max(f,w):0}if(arguments[0]instanceof Re){var G=arguments[0];return bs.index(this.p0,this.p1,G)}}},{key:"toGeometry",value:function(h){return h.createLineString([this.p0,this.p1])}},{key:"isVertical",value:function(){return this.p0.x===this.p1.x}},{key:"equals",value:function(h){if(!(h instanceof N))return!1;var f=h;return this.p0.equals(f.p0)&&this.p1.equals(f.p1)}},{key:"intersection",value:function(h){var f=new ul;return f.computeIntersection(this.p0,this.p1,h.p0,h.p1),f.hasIntersection()?f.getIntersection(0):null}},{key:"project",value:function(){if(arguments[0]instanceof Re){var h=arguments[0];if(h.equals(this.p0)||h.equals(this.p1))return new Re(h);var f=this.projectionFactor(h),w=new Re;return w.x=this.p0.x+f*(this.p1.x-this.p0.x),w.y=this.p0.y+f*(this.p1.y-this.p0.y),w}if(arguments[0]instanceof N){var G=arguments[0],re=this.projectionFactor(G.p0),xe=this.projectionFactor(G.p1);if(re>=1&&xe>=1||re<=0&&xe<=0)return null;var Ae=this.project(G.p0);re<0&&(Ae=this.p0),re>1&&(Ae=this.p1);var tt=this.project(G.p1);return xe<0&&(tt=this.p0),xe>1&&(tt=this.p1),new N(Ae,tt)}}},{key:"normalize",value:function(){this.p1.compareTo(this.p0)<0&&this.reverse()}},{key:"angle",value:function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)}},{key:"getCoordinate",value:function(h){return h===0?this.p0:this.p1}},{key:"distancePerpendicular",value:function(h){return wn.pointToLinePerpendicular(h,this.p0,this.p1)}},{key:"minY",value:function(){return Math.min(this.p0.y,this.p1.y)}},{key:"midPoint",value:function(){return N.midPoint(this.p0,this.p1)}},{key:"projectionFactor",value:function(h){if(h.equals(this.p0))return 0;if(h.equals(this.p1))return 1;var f=this.p1.x-this.p0.x,w=this.p1.y-this.p0.y,G=f*f+w*w;return G<=0?Ee.NaN:((h.x-this.p0.x)*f+(h.y-this.p0.y)*w)/G}},{key:"closestPoints",value:function(h){var f=this.intersection(h);if(f!==null)return[f,f];var w=new Array(2).fill(null),G=Ee.MAX_VALUE,re=null,xe=this.closestPoint(h.p0);G=xe.distance(h.p0),w[0]=xe,w[1]=h.p0;var Ae=this.closestPoint(h.p1);(re=Ae.distance(h.p1))<G&&(G=re,w[0]=Ae,w[1]=h.p1);var tt=h.closestPoint(this.p0);(re=tt.distance(this.p0))<G&&(G=re,w[0]=this.p0,w[1]=tt);var Nt=h.closestPoint(this.p1);return(re=Nt.distance(this.p1))<G&&(G=re,w[0]=this.p1,w[1]=Nt),w}},{key:"closestPoint",value:function(h){var f=this.projectionFactor(h);return f>0&&f<1?this.project(h):this.p0.distance(h)<this.p1.distance(h)?this.p0:this.p1}},{key:"maxX",value:function(){return Math.max(this.p0.x,this.p1.x)}},{key:"getLength",value:function(){return this.p0.distance(this.p1)}},{key:"compareTo",value:function(h){var f=h,w=this.p0.compareTo(f.p0);return w!==0?w:this.p1.compareTo(f.p1)}},{key:"reverse",value:function(){var h=this.p0;this.p0=this.p1,this.p1=h}},{key:"equalsTopo",value:function(h){return this.p0.equals(h.p0)&&this.p1.equals(h.p1)||this.p0.equals(h.p1)&&this.p1.equals(h.p0)}},{key:"lineIntersection",value:function(h){return ds.intersection(this.p0,this.p1,h.p0,h.p1)}},{key:"maxY",value:function(){return Math.max(this.p0.y,this.p1.y)}},{key:"pointAlongOffset",value:function(h,f){var w=this.p0.x+h*(this.p1.x-this.p0.x),G=this.p0.y+h*(this.p1.y-this.p0.y),re=this.p1.x-this.p0.x,xe=this.p1.y-this.p0.y,Ae=Math.sqrt(re*re+xe*xe),tt=0,Nt=0;if(f!==0){if(Ae<=0)throw new IllegalStateException("Cannot compute offset from zero-length line segment");tt=f*re/Ae,Nt=f*xe/Ae}return new Re(w-Nt,G+tt)}},{key:"setCoordinates",value:function(){if(arguments.length===1){var h=arguments[0];this.setCoordinates(h.p0,h.p1)}else if(arguments.length===2){var f=arguments[0],w=arguments[1];this.p0.x=f.x,this.p0.y=f.y,this.p1.x=w.x,this.p1.y=w.y}}},{key:"segmentFraction",value:function(h){var f=this.projectionFactor(h);return f<0?f=0:(f>1||Ee.isNaN(f))&&(f=1),f}},{key:"toString",value:function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"}},{key:"isHorizontal",value:function(){return this.p0.y===this.p1.y}},{key:"reflect",value:function(h){var f=this.p1.getY()-this.p0.getY(),w=this.p0.getX()-this.p1.getX(),G=this.p0.getY()*(this.p1.getX()-this.p0.getX())-this.p0.getX()*(this.p1.getY()-this.p0.getY()),re=f*f+w*w,xe=f*f-w*w,Ae=h.getX(),tt=h.getY();return new Re((-xe*Ae-2*f*w*tt-2*f*G)/re,(xe*tt-2*f*w*Ae-2*w*G)/re)}},{key:"distance",value:function(){if(arguments[0]instanceof N){var h=arguments[0];return wn.segmentToSegment(this.p0,this.p1,h.p0,h.p1)}if(arguments[0]instanceof Re){var f=arguments[0];return wn.pointToSegment(f,this.p0,this.p1)}}},{key:"pointAlong",value:function(h){var f=new Re;return f.x=this.p0.x+h*(this.p1.x-this.p0.x),f.y=this.p0.y+h*(this.p1.y-this.p0.y),f}},{key:"hashCode",value:function(){var h=Ee.doubleToLongBits(this.p0.x);h^=31*Ee.doubleToLongBits(this.p0.y);var f=Math.trunc(h)^Math.trunc(h>>32),w=Ee.doubleToLongBits(this.p1.x);return w^=31*Ee.doubleToLongBits(this.p1.y),f^(Math.trunc(w)^Math.trunc(w>>32))}},{key:"interfaces_",get:function(){return[H,q]}}
759],[{key:"constructor_",value:function(){if(this.p0=null,this.p1=null,arguments.length===0)N.constructor_.call(this,new Re,new Re);else if(arguments.length===1){var h=arguments[0];N.constructor_.call(this,h.p0,h.p1)}else if(arguments.length===2){var f=arguments[0],w=arguments[1];this.p0=f,this.p1=w}else if(arguments.length===4){var G=arguments[0],re=arguments[1],xe=arguments[2],Ae=arguments[3];N.constructor_.call(this,new Re(G,re),new Re(xe,Ae))}}},{key:"midPoint",value:function(h,f){return new Re((h.x+f.x)/2,(h.y+f.y)/2)}}])}(),hi=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"overlap",value:function(){if(arguments.length!==2){if(arguments.length===4){var N=arguments[1],h=arguments[2],f=arguments[3];arguments[0].getLineSegment(N,this._overlapSeg1),h.getLineSegment(f,this._overlapSeg2),this.overlap(this._overlapSeg1,this._overlapSeg2)}}}}],[{key:"constructor_",value:function(){this._overlapSeg1=new Kr,this._overlapSeg2=new Kr}}])}(),Jd=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"getLineSegment",value:function(N,h){h.p0=this._pts[N],h.p1=this._pts[N+1]}},{key:"computeSelect",value:function(N,h,f,w){var G=this._pts[h],re=this._pts[f];if(f-h==1)return w.select(this,h),null;if(!N.intersects(G,re))return null;var xe=Math.trunc((h+f)/2);h<xe&&this.computeSelect(N,h,xe,w),xe<f&&this.computeSelect(N,xe,f,w)}},{key:"getCoordinates",value:function(){for(var N=new Array(this._end-this._start+1).fill(null),h=0,f=this._start;f<=this._end;f++)N[h++]=this._pts[f];return N}},{key:"computeOverlaps",value:function(){if(arguments.length===2){var N=arguments[0],h=arguments[1];this.computeOverlaps(this._start,this._end,N,N._start,N._end,h)}else if(arguments.length===6){var f=arguments[0],w=arguments[1],G=arguments[2],re=arguments[3],xe=arguments[4],Ae=arguments[5];if(w-f==1&&xe-re==1)return Ae.overlap(this,f,G,re),null;if(!this.overlaps(f,w,G,re,xe))return null;var tt=Math.trunc((f+w)/2),Nt=Math.trunc((re+xe)/2);f<tt&&(re<Nt&&this.computeOverlaps(f,tt,G,re,Nt,Ae),Nt<xe&&this.computeOverlaps(f,tt,G,Nt,xe,Ae)),tt<w&&(re<Nt&&this.computeOverlaps(tt,w,G,re,Nt,Ae),Nt<xe&&this.computeOverlaps(tt,w,G,Nt,xe,Ae))}}},{key:"setId",value:function(N){this._id=N}},{key:"select",value:function(N,h){this.computeSelect(N,this._start,this._end,h)}},{key:"getEnvelope",value:function(){if(this._env===null){var N=this._pts[this._start],h=this._pts[this._end];this._env=new ft(N,h)}return this._env}},{key:"overlaps",value:function(N,h,f,w,G){return ft.intersects(this._pts[N],this._pts[h],f._pts[w],f._pts[G])}},{key:"getEndIndex",value:function(){return this._end}},{key:"getStartIndex",value:function(){return this._start}},{key:"getContext",value:function(){return this._context}},{key:"getId",value:function(){return this._id}}],[{key:"constructor_",value:function(){this._pts=null,this._start=null,this._end=null,this._env=null,this._context=null,this._id=null;var N=arguments[0],h=arguments[1],f=arguments[2],w=arguments[3];this._pts=N,this._start=h,this._end=f,this._context=w}}])}(),Id=function(){function N(){l(this,N)}return i(N,null,[{key:"findChainEnd",value:function(h,f){for(var w=f;w<h.length-1&&h[w].equals2D(h[w+1]);)w++;if(w>=h.length-1)return h.length-1;for(var G=Tn.quadrant(h[w],h[w+1]),re=f+1;re<h.length&&!(!h[re-1].equals2D(h[re])&&Tn.quadrant(h[re-1],h[re])!==G);)re++;return re-1}},{key:"getChains",value:function(){if(arguments.length===1){var h=arguments[0];return N.getChains(h,null)}if(arguments.length===2){var f=arguments[0],w=arguments[1],G=new ps,re=0;do{var xe=N.findChainEnd(f,re),Ae=new Jd(f,re,xe,w);G.add(Ae),re=xe}while(re<f.length-1);return G}}}])}(),Hl=function(){return i(function N(){l(this,N)},[{key:"computeNodes",value:function(N){}},{key:"getNodedSubstrings",value:function(){}}])}(),Sl=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"setSegmentIntersector",value:function(N){this._segInt=N}},{key:"interfaces_",get:function(){return[Hl]}}],[{key:"constructor_",value:function(){if(this._segInt=null,arguments.length!==0){if(arguments.length===1){var N=arguments[0];this.setSegmentIntersector(N)}}}}])}(),gd=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"getMonotoneChains",value:function(){return this._monoChains}},{key:"getNodedSubstrings",value:function(){return So.getNodedSubstrings(this._nodedSegStrings)}},{key:"getIndex",value:function(){return this._index}},{key:"add",value:function(f){for(var w=Id.getChains(f.getCoordinates(),f).iterator();w.hasNext();){var G=w.next();G.setId(this._idCounter++),this._index.insert(G.getEnvelope(),G),this._monoChains.add(G)}}},{key:"computeNodes",value:function(f){this._nodedSegStrings=f;for(var w=f.iterator();w.hasNext();)this.add(w.next());this.intersectChains()}},{key:"intersectChains",value:function(){for(var f=new Zl(this._segInt),w=this._monoChains.iterator();w.hasNext();)for(var G=w.next(),re=this._index.query(G.getEnvelope()).iterator();re.hasNext();){var xe=re.next();if(xe.getId()>G.getId()&&(G.computeOverlaps(xe,f),this._nOverlaps++),this._segInt.isDone())return null}}}
759],[{key:"constructor_",value:function(){if(this._monoChains=new ps,this._index=new kl,this._idCounter=0,this._nodedSegStrings=null,this._nOverlaps=0,arguments.length!==0){if(arguments.length===1){var f=arguments[0];Sl.constructor_.call(this,f)}}}}])}(Sl),Zl=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"overlap",value:function(){if(arguments.length!==4)return P(h,"overlap",this,1).apply(this,arguments);var f=arguments[1],w=arguments[2],G=arguments[3],re=arguments[0].getContext(),xe=w.getContext();this._si.processIntersections(re,f,xe,G)}}],[{key:"constructor_",value:function(){this._si=null;var f=arguments[0];this._si=f}}])}(hi);gd.SegmentOverlapAction=Zl;var Hi=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"isDeletable",value:function(h,f,w,G){var re=this._inputLine[h],xe=this._inputLine[f],Ae=this._inputLine[w];return!!this.isConcave(re,xe,Ae)&&!!this.isShallow(re,xe,Ae,G)&&this.isShallowSampled(re,xe,h,w,G)}},{key:"deleteShallowConcavities",value:function(){for(var h=1,f=this.findNextNonDeletedIndex(h),w=this.findNextNonDeletedIndex(f),G=!1;w<this._inputLine.length;){var re=!1;this.isDeletable(h,f,w,this._distanceTol)&&(this._isDeleted[f]=N.DELETE,re=!0,G=!0),h=re?w:f,f=this.findNextNonDeletedIndex(h),w=this.findNextNonDeletedIndex(f)}return G}},{key:"isShallowConcavity",value:function(h,f,w,G){return bs.index(h,f,w)===this._angleOrientation&&wn.pointToSegment(f,h,w)<G}},{key:"isShallowSampled",value:function(h,f,w,G,re){var xe=Math.trunc((G-w)/N.NUM_PTS_TO_CHECK);xe<=0&&(xe=1);for(var Ae=w;Ae<G;Ae+=xe)if(!this.isShallow(h,f,this._inputLine[Ae],re))return!1;return!0}},{key:"isConcave",value:function(h,f,w){var G=bs.index(h,f,w)===this._angleOrientation;return G}},{key:"simplify",value:function(h){this._distanceTol=Math.abs(h),h<0&&(this._angleOrientation=bs.CLOCKWISE),this._isDeleted=new Array(this._inputLine.length).fill(null);var f=!1;do f=this.deleteShallowConcavities();while(f);return this.collapseLine()}},{key:"findNextNonDeletedIndex",value:function(h){for(var f=h+1;f<this._inputLine.length&&this._isDeleted[f]===N.DELETE;)f++;return f}},{key:"isShallow",value:function(h,f,w,G){return wn.pointToSegment(f,h,w)<G}},{key:"collapseLine",value:function(){for(var h=new xa,f=0;f<this._inputLine.length;f++)this._isDeleted[f]!==N.DELETE&&h.add(this._inputLine[f]);return h.toCoordinateArray()}}],[{key:"constructor_",value:function(){this._inputLine=null,this._distanceTol=null,this._isDeleted=null,this._angleOrientation=bs.COUNTERCLOCKWISE;var h=arguments[0];this._inputLine=h}},{key:"simplify",value:function(h,f){return new N(h).simplify(f)}}])}();Hi.INIT=0,Hi.DELETE=1,Hi.KEEP=1,Hi.NUM_PTS_TO_CHECK=10;var eo=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"getCoordinates",value:function(){return this._ptList.toArray(N.COORDINATE_ARRAY_TYPE)}},{key:"setPrecisionModel",value:function(h){this._precisionModel=h}},{key:"addPt",value:function(h){var f=new Re(h);if(this._precisionModel.makePrecise(f),this.isRedundant(f))return null;this._ptList.add(f)}},{key:"reverse",value:function(){}},{key:"addPts",value:function(h,f){if(f)for(var w=0;w<h.length;w++)this.addPt(h[w]);else for(var G=h.length-1;G>=0;G--)this.addPt(h[G])}},{key:"isRedundant",value:function(h){if(this._ptList.size()<1)return!1;var f=this._ptList.get(this._ptList.size()-1);return h.distance(f)<this._minimimVertexDistance}},{key:"toString",value:function(){return new qa().createLineString(this.getCoordinates()).toString()}},{key:"closeRing",value:function(){if(this._ptList.size()<1)return null;var h=new Re(this._ptList.get(0)),f=this._ptList.get(this._ptList.size()-1);if(h.equals(f))return null;this._ptList.add(h)}},{key:"setMinimumVertexDistance",value:function(h){this._minimimVertexDistance=h}}],[{key:"constructor_",value:function(){this._ptList=null,this._precisionModel=null,this._minimimVertexDistance=0,this._ptList=new ps}}])}();eo.COORDINATE_ARRAY_TYPE=new Array(0).fill(null);var Wr=function(){function N(){l(this,N)}return i(N,null,[{key:"toDegrees",value:function(h){return 180*h/Math.PI}},{key:"normalize",value:function(h){for(;h>Math.PI;)h-=N.PI_TIMES_2;for(;h<=-Math.PI;)h+=N.PI_TIMES_2;return h}},{key:"angle",value:function(){if(arguments.length===1){var h=arguments[0];return Math.atan2(h.y,h.x)}if(arguments.length===2){var f=arguments[0],w=arguments[1],G=w.x-f.x,re=w.y-f.y;return Math.atan2(re,G)}}},{key:"isAcute",value:function(h,f,w){var G=h.x-f.x,re=h.y-f.y;return G*(w.x-f.x)+re*(w.y-f.y)>0}},{key:"isObtuse",value:function(h,f,w){var G=h.x-f.x,re=h.y-f.y;return G*(w.x-f.x)+re*(w.y-f.y)<0}},{key:"interiorAngle",value:function(h,f,w){var G=N.angle(f,h),re=N.angle(f,w);return Math.abs(re-G)}},{key:"normalizePositive",value:function(h){if(h<0){for(;h<0;)h+=N.PI_TIMES_2;h>=N.PI_TIMES_2&&(h=0)}else{for(;h>=N.PI_TIMES_2;)h-=N.PI_TIMES_2;h<0&&(h=0)}return h}},{key:"angleBetween",value:function(h,f,w){var G=N.angle(f,h),re=N.angle(f,w);return N.diff(G,re)}},{key:"diff",value:function(h,f){var w=null;return(w=h<f?f-h:h-f)>Math.PI&&(w=2*Math.PI-w),w}},{key:"toRadians",value:function(h){return h*Math.PI/180}},{key:"getTurn",value:function(h,f){var w=Math.sin(f-h);return w>0?N.COUNTERCLOCKWISE:w<0?N.CLOCKWISE:N.NONE}},{key:"angleBetweenOriented",value:function(h,f,w){var G=N.angle(f,h),re=N.angle(f,w)-G;return re<=-Math.PI?re+N.PI_TIMES_2:re>Math.PI?re-N.PI_TIMES_2:re}}])}();
vendor: 11,250 bytes, line 759
759Wr.PI_TIMES_2=2*Math.PI,Wr.PI_OVER_2=Math.PI/2,Wr.PI_OVER_4=Math.PI/4,Wr.COUNTERCLOCKWISE=bs.COUNTERCLOCKWISE,Wr.CLOCKWISE=bs.CLOCKWISE,Wr.NONE=bs.COLLINEAR;var Tc=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"addNextSegment",value:function(h,f){if(this._s0=this._s1,this._s1=this._s2,this._s2=h,this._seg0.setCoordinates(this._s0,this._s1),this.computeOffsetSegment(this._seg0,this._side,this._distance,this._offset0),this._seg1.setCoordinates(this._s1,this._s2),this.computeOffsetSegment(this._seg1,this._side,this._distance,this._offset1),this._s1.equals(this._s2))return null;var w=bs.index(this._s0,this._s1,this._s2),G=w===bs.CLOCKWISE&&this._side===Xe.LEFT||w===bs.COUNTERCLOCKWISE&&this._side===Xe.RIGHT;w===0?this.addCollinear(f):G?this.addOutsideTurn(w,f):this.addInsideTurn(w,f)}},{key:"addLineEndCap",value:function(h,f){var w=new Kr(h,f),G=new Kr;this.computeOffsetSegment(w,Xe.LEFT,this._distance,G);var re=new Kr;this.computeOffsetSegment(w,Xe.RIGHT,this._distance,re);var xe=f.x-h.x,Ae=f.y-h.y,tt=Math.atan2(Ae,xe);switch(this._bufParams.getEndCapStyle()){case X.CAP_ROUND:this._segList.addPt(G.p1),this.addDirectedFillet(f,tt+Math.PI/2,tt-Math.PI/2,bs.CLOCKWISE,this._distance),this._segList.addPt(re.p1);break;case X.CAP_FLAT:this._segList.addPt(G.p1),this._segList.addPt(re.p1);break;case X.CAP_SQUARE:var Nt=new Re;Nt.x=Math.abs(this._distance)*Math.cos(tt),Nt.y=Math.abs(this._distance)*Math.sin(tt);var Ut=new Re(G.p1.x+Nt.x,G.p1.y+Nt.y),xs=new Re(re.p1.x+Nt.x,re.p1.y+Nt.y);this._segList.addPt(Ut),this._segList.addPt(xs)}}},{key:"getCoordinates",value:function(){return this._segList.getCoordinates()}},{key:"addMitreJoin",value:function(h,f,w,G){var re=ds.intersection(f.p0,f.p1,w.p0,w.p1);if(re!==null&&(G<=0?1:re.distance(h)/Math.abs(G))<=this._bufParams.getMitreLimit())return this._segList.addPt(re),null;this.addLimitedMitreJoin(f,w,G,this._bufParams.getMitreLimit())}},{key:"addOutsideTurn",value:function(h,f){if(this._offset0.p1.distance(this._offset1.p0)<this._distance*N.OFFSET_SEGMENT_SEPARATION_FACTOR)return this._segList.addPt(this._offset0.p1),null;this._bufParams.getJoinStyle()===X.JOIN_MITRE?this.addMitreJoin(this._s1,this._offset0,this._offset1,this._distance):this._bufParams.getJoinStyle()===X.JOIN_BEVEL?this.addBevelJoin(this._offset0,this._offset1):(f&&this._segList.addPt(this._offset0.p1),this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,h,this._distance),this._segList.addPt(this._offset1.p0))}},{key:"createSquare",value:function(h){this._segList.addPt(new Re(h.x+this._distance,h.y+this._distance)),this._segList.addPt(new Re(h.x+this._distance,h.y-this._distance)),this._segList.addPt(new Re(h.x-this._distance,h.y-this._distance)),this._segList.addPt(new Re(h.x-this._distance,h.y+this._distance)),this._segList.closeRing()}},{key:"addSegments",value:function(h,f){this._segList.addPts(h,f)}},{key:"addFirstSegment",value:function(){this._segList.addPt(this._offset1.p0)}},{key:"addCornerFillet",value:function(h,f,w,G,re){var xe=f.x-h.x,Ae=f.y-h.y,tt=Math.atan2(Ae,xe),Nt=w.x-h.x,Ut=w.y-h.y,xs=Math.atan2(Ut,Nt);G===bs.CLOCKWISE?tt<=xs&&(tt+=2*Math.PI):tt>=xs&&(tt-=2*Math.PI),this._segList.addPt(f),this.addDirectedFillet(h,tt,xs,G,re),this._segList.addPt(w)}},{key:"addLastSegment",value:function(){this._segList.addPt(this._offset1.p1)}},{key:"initSideSegments",value:function(h,f,w){this._s1=h,this._s2=f,this._side=w,this._seg1.setCoordinates(h,f),this.computeOffsetSegment(this._seg1,w,this._distance,this._offset1)}},{key:"addLimitedMitreJoin",value:function(h,f,w,G){var re=this._seg0.p1,xe=Wr.angle(re,this._seg0.p0),Ae=Wr.angleBetweenOriented(this._seg0.p0,re,this._seg1.p1)/2,tt=Wr.normalize(xe+Ae),Nt=Wr.normalize(tt+Math.PI),Ut=G*w,xs=w-Ut*Math.abs(Math.sin(Ae)),$s=re.x+Ut*Math.cos(Nt),bn=re.y+Ut*Math.sin(Nt),da=new Re($s,bn),wa=new Kr(re,da),Lr=wa.pointAlongOffset(1,xs),ur=wa.pointAlongOffset(1,-xs);this._side===Xe.LEFT?(this._segList.addPt(Lr),this._segList.addPt(ur)):(this._segList.addPt(ur),this._segList.addPt(Lr))}},{key:"addDirectedFillet",value:function(h,f,w,G,re){var xe=G===bs.CLOCKWISE?-1:1,Ae=Math.abs(f-w),tt=Math.trunc(Ae/this._filletAngleQuantum+.5);if(tt<1)return null;for(var Nt=Ae/tt,Ut=new Re,xs=0;xs<tt;xs++){var $s=f+xe*xs*Nt;Ut.x=h.x+re*Math.cos($s),Ut.y=h.y+re*Math.sin($s),this._segList.addPt(Ut)}}},{key:"computeOffsetSegment",value:function(h,f,w,G){var re=f===Xe.LEFT?1:-1,xe=h.p1.x-h.p0.x,Ae=h.p1.y-h.p0.y,tt=Math.sqrt(xe*xe+Ae*Ae),Nt=re*w*xe/tt,Ut=re*w*Ae/tt;G.p0.x=h.p0.x-Ut,G.p0.y=h.p0.y+Nt,G.p1.x=h.p1.x-Ut,G.p1.y=h.p1.y+Nt}},{key:"addInsideTurn",value:function(h,f){if(this._li.computeIntersection(this._offset0.p0,this._offset0.p1,this._offset1.p0,this._offset1.p1),this._li.hasIntersection())this._segList.addPt(this._li.getIntersection(0));else if(this._hasNarrowConcaveAngle=!0,this._offset0.p1.distance(this._offset1.p0)<this._distance*N.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR)this._segList.addPt(this._offset0.p1);else{if(this._segList.addPt(this._offset0.p1),this._closingSegLengthFactor>0){var w=new Re((this._closingSegLengthFactor*this._offset0.p1.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset0.p1.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(w);var G=new Re((this._closingSegLengthFactor*this._offset1.p0.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset1.p0.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(G)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}}},{key:"createCircle",value:function(h){var f=new Re(h.x+this._distance,h.y);this._segList.addPt(f),this.addDirectedFillet(h,0,2*Math.PI,-1,this._distance),this._segList.closeRing()}},{key:"addBevelJoin",value:function(h,f){this._segList.addPt(h.p1),this._segList.addPt(f.p0)}},{key:"init",value:function(h){this._distance=h,this._maxCurveSegmentError=h*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new eo,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(h*N.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)}},{key:"addCollinear",value:function(h){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2),this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===X.JOIN_BEVEL||this._bufParams.getJoinStyle()===X.JOIN_MITRE?(h&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,bs.CLOCKWISE,this._distance))}},{key:"closeRing",value:function(){this._segList.closeRing()}},{key:"hasNarrowConcaveAngle",value:function(){return this._hasNarrowConcaveAngle}}],[{key:"constructor_",value:function(){this._maxCurveSegmentError=0,this._filletAngleQuantum=null,this._closingSegLengthFactor=1,this._segList=null,this._distance=0,this._precisionModel=null,this._bufParams=null,this._li=null,this._s0=null,this._s1=null,this._s2=null,this._seg0=new Kr,this._seg1=new Kr,this._offset0=new Kr,this._offset1=new Kr,this._side=0,this._hasNarrowConcaveAngle=!1;var h=arguments[0],f=arguments[1],w=arguments[2];this._precisionModel=h,this._bufParams=f,this._li=new ul,this._filletAngleQuantum=Math.PI/2/f.getQuadrantSegments(),f.getQuadrantSegments()>=8&&f.getJoinStyle()===X.JOIN_ROUND&&(this._closingSegLengthFactor=N.MAX_CLOSING_SEG_LEN_FACTOR),this.init(w)}}])}();Tc.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,Tc.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,Tc.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,Tc.MAX_CLOSING_SEG_LEN_FACTOR=80;var Wl=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"getOffsetCurve",value:function(h,f){if(this._distance=f,f===0)return null;var w=f<0,G=Math.abs(f),re=this.getSegGen(G);h.length<=1?this.computePointCurve(h[0],re):this.computeOffsetCurve(h,w,re);var xe=re.getCoordinates();return w&&Fn.reverse(xe),xe}},{key:"computeSingleSidedBufferCurve",value:function(h,f,w){var G=this.simplifyTolerance(this._distance);if(f){w.addSegments(h,!0);var re=Hi.simplify(h,-G),xe=re.length-1;w.initSideSegments(re[xe],re[xe-1],Xe.LEFT),w.addFirstSegment();for(var Ae=xe-2;Ae>=0;Ae--)w.addNextSegment(re[Ae],!0)}else{w.addSegments(h,!1);var tt=Hi.simplify(h,G),Nt=tt.length-1;w.initSideSegments(tt[0],tt[1],Xe.LEFT),w.addFirstSegment();for(var Ut=2;Ut<=Nt;Ut++)w.addNextSegment(tt[Ut],!0)}w.addLastSegment(),w.closeRing()}},{key:"computeRingBufferCurve",value:function(h,f,w){var G=this.simplifyTolerance(this._distance);f===Xe.RIGHT&&(G=-G);var re=Hi.simplify(h,G),xe=re.length-1;w.initSideSegments(re[xe-1],re[0],f);for(var Ae=1;Ae<=xe;Ae++){var tt=Ae!==1;w.addNextSegment(re[Ae],tt)}w.closeRing()}},{key:"computeLineBufferCurve",value:function(h,f){var w=this.simplifyTolerance(this._distance),G=Hi.simplify(h,w),re=G.length-1;f.initSideSegments(G[0],G[1],Xe.LEFT);for(var xe=2;xe<=re;xe++)f.addNextSegment(G[xe],!0);f.addLastSegment(),f.addLineEndCap(G[re-1],G[re]);var Ae=Hi.simplify(h,-w),tt=Ae.length-1;f.initSideSegments(Ae[tt],Ae[tt-1],Xe.LEFT);for(var Nt=tt-2;Nt>=0;Nt--)f.addNextSegment(Ae[Nt],!0);f.addLastSegment(),f.addLineEndCap(Ae[1],Ae[0]),f.closeRing()}},{key:"computePointCurve",value:function(h,f){switch(this._bufParams.getEndCapStyle()){case X.CAP_ROUND:f.createCircle(h);break;case X.CAP_SQUARE:f.createSquare(h)}}},{key:"getLineCurve",value:function(h,f){if(this._distance=f,this.isLineOffsetEmpty(f))return null;var w=Math.abs(f),G=this.getSegGen(w);if(h.length<=1)this.computePointCurve(h[0],G);else if(this._bufParams.isSingleSided()){var re=f<0;this.computeSingleSidedBufferCurve(h,re,G)}else this.computeLineBufferCurve(h,G);return G.getCoordinates()}},{key:"getBufferParameters",value:function(){return this._bufParams}},{key:"simplifyTolerance",value:function(h){return h*this._bufParams.getSimplifyFactor()}},{key:"getRingCurve",value:function(h,f,w){if(this._distance=w,h.length<=2)return this.getLineCurve(h,w);if(w===0)return N.copyCoordinates(h);var G=this.getSegGen(w);return this.computeRingBufferCurve(h,f,G),G.getCoordinates()}},{key:"computeOffsetCurve",value:function(h,f,w){var G=this.simplifyTolerance(this._distance);if(f){var re=Hi.simplify(h,-G),xe=re.length-1;w.initSideSegments(re[xe],re[xe-1],Xe.LEFT),w.addFirstSegment();for(var Ae=xe-2;Ae>=0;Ae--)w.addNextSegment(re[Ae],!0)}else{var tt=Hi.simplify(h,G),Nt=tt.length-1;w.initSideSegments(tt[0],tt[1],Xe.LEFT),w.addFirstSegment();for(var Ut=2;Ut<=Nt;Ut++)w.addNextSegment(tt[Ut],!0)}w.addLastSegment()}},{key:"isLineOffsetEmpty",value:function(h){return h===0||h<0&&!this._bufParams.isSingleSided()}},{key:"getSegGen",value:function(h){return new Tc(this._precisionModel,this._bufParams,h)}}],[{key:"constructor_",value:function(){this._distance=0,this._precisionModel=null,this._bufParams=null;var h=arguments[0],f=arguments[1];this._precisionModel=h,this._bufParams=f}},{key:"copyCoordinates",value:function(h){for(var f=new Array(h.length).fill(null),w=0;w<f.length;w++)f[w]=new Re(h[w]);return f}}])}(),_o=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"findStabbedSegments",value:function(){if(arguments.length===1){for(var N=arguments[0],h=new ps,f=this._subgraphs.iterator();f.hasNext();){var w=f.next(),G=w.getEnvelope();
759N.y<G.getMinY()||N.y>G.getMaxY()||this.findStabbedSegments(N,w.getDirectedEdges(),h)}return h}if(arguments.length===3){if(zt(arguments[2],Dt)&&arguments[0]instanceof Re&&arguments[1]instanceof Pa){for(var re=arguments[0],xe=arguments[1],Ae=arguments[2],tt=xe.getEdge().getCoordinates(),Nt=0;Nt<tt.length-1;Nt++)if(this._seg.p0=tt[Nt],this._seg.p1=tt[Nt+1],this._seg.p0.y>this._seg.p1.y&&this._seg.reverse(),!(Math.max(this._seg.p0.x,this._seg.p1.x)<re.x||this._seg.isHorizontal()||re.y<this._seg.p0.y||re.y>this._seg.p1.y||bs.index(this._seg.p0,this._seg.p1,re)===bs.RIGHT)){var Ut=xe.getDepth(Xe.LEFT);this._seg.p0.equals(tt[Nt])||(Ut=xe.getDepth(Xe.RIGHT));var xs=new Yl(this._seg,Ut);Ae.add(xs)}}else if(zt(arguments[2],Dt)&&arguments[0]instanceof Re&&zt(arguments[1],Dt))for(var $s=arguments[0],bn=arguments[2],da=arguments[1].iterator();da.hasNext();){var wa=da.next();wa.isForward()&&this.findStabbedSegments($s,wa,bn)}}}},{key:"getDepth",value:function(N){var h=this.findStabbedSegments(N);return h.size()===0?0:Al.min(h)._leftDepth}}],[{key:"constructor_",value:function(){this._subgraphs=null,this._seg=new Kr;var N=arguments[0];this._subgraphs=N}}])}(),Yl=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"compareTo",value:function(N){var h=N;if(this._upwardSeg.minX()>=h._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=h._upwardSeg.minX())return-1;var f=this._upwardSeg.orientationIndex(h._upwardSeg);return f!==0||(f=-1*h._upwardSeg.orientationIndex(this._upwardSeg))!==0?f:this._upwardSeg.compareTo(h._upwardSeg)}},{key:"compareX",value:function(N,h){var f=N.p0.compareTo(h.p0);return f!==0?f:N.p1.compareTo(h.p1)}},{key:"toString",value:function(){return this._upwardSeg.toString()}},{key:"interfaces_",get:function(){return[H]}}],[{key:"constructor_",value:function(){this._upwardSeg=null,this._leftDepth=null;var N=arguments[0],h=arguments[1];this._upwardSeg=new Kr(N),this._leftDepth=h}}])}();_o.DepthSegment=Yl;var Xl=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,null,[{key:"constructor_",value:function(){K.constructor_.call(this,"Projective point not representable on the Cartesian plane.")}}])}(K),pl=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"getY",value:function(){var h=this.y/this.w;if(Ee.isNaN(h)||Ee.isInfinite(h))throw new Xl;return h}},{key:"getX",value:function(){var h=this.x/this.w;if(Ee.isNaN(h)||Ee.isInfinite(h))throw new Xl;return h}},{key:"getCoordinate",value:function(){var h=new Re;return h.x=this.getX(),h.y=this.getY(),h}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.w=null,arguments.length===0)this.x=0,this.y=0,this.w=1;else if(arguments.length===1){var h=arguments[0];this.x=h.x,this.y=h.y,this.w=1}else if(arguments.length===2){if(typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var f=arguments[0],w=arguments[1];this.x=f,this.y=w,this.w=1}else if(arguments[0]instanceof N&&arguments[1]instanceof N){var G=arguments[0],re=arguments[1];this.x=G.y*re.w-re.y*G.w,this.y=re.x*G.w-G.x*re.w,this.w=G.x*re.y-re.x*G.y}else if(arguments[0]instanceof Re&&arguments[1]instanceof Re){var xe=arguments[0],Ae=arguments[1];this.x=xe.y-Ae.y,this.y=Ae.x-xe.x,this.w=xe.x*Ae.y-Ae.x*xe.y}}else if(arguments.length===3){var tt=arguments[0],Nt=arguments[1],Ut=arguments[2];this.x=tt,this.y=Nt,this.w=Ut}else if(arguments.length===4){var xs=arguments[0],$s=arguments[1],bn=arguments[2],da=arguments[3],wa=xs.y-$s.y,Lr=$s.x-xs.x,ur=xs.x*$s.y-$s.x*xs.y,si=bn.y-da.y,Ei=da.x-bn.x,hr=bn.x*da.y-da.x*bn.y;this.x=Lr*hr-Ei*ur,this.y=si*ur-wa*hr,this.w=wa*Ei-si*Lr}}}])}(),Fl=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"area",value:function(){return N.area(this.p0,this.p1,this.p2)}},{key:"signedArea",value:function(){return N.signedArea(this.p0,this.p1,this.p2)}},{key:"interpolateZ",value:function(h){if(h===null)throw new te("Supplied point is null.");return N.interpolateZ(h,this.p0,this.p1,this.p2)}},{key:"longestSideLength",value:function(){return N.longestSideLength(this.p0,this.p1,this.p2)}},{key:"isAcute",value:function(){return N.isAcute(this.p0,this.p1,this.p2)}},{key:"circumcentre",value:function(){return N.circumcentre(this.p0,this.p1,this.p2)}},{key:"area3D",value:function(){return N.area3D(this.p0,this.p1,this.p2)}},{key:"centroid",value:function(){return N.centroid(this.p0,this.p1,this.p2)}},{key:"inCentre",value:function(){return N.inCentre(this.p0,this.p1,this.p2)}}
vendor: 10,273 bytes, line 759
759],[{key:"constructor_",value:function(){this.p0=null,this.p1=null,this.p2=null;var h=arguments[0],f=arguments[1],w=arguments[2];this.p0=h,this.p1=f,this.p2=w}},{key:"area",value:function(h,f,w){return Math.abs(((w.x-h.x)*(f.y-h.y)-(f.x-h.x)*(w.y-h.y))/2)}},{key:"signedArea",value:function(h,f,w){return((w.x-h.x)*(f.y-h.y)-(f.x-h.x)*(w.y-h.y))/2}},{key:"det",value:function(h,f,w,G){return h*G-f*w}},{key:"interpolateZ",value:function(h,f,w,G){var re=f.x,xe=f.y,Ae=w.x-re,tt=G.x-re,Nt=w.y-xe,Ut=G.y-xe,xs=Ae*Ut-tt*Nt,$s=h.x-re,bn=h.y-xe,da=(Ut*$s-tt*bn)/xs,wa=(-Nt*$s+Ae*bn)/xs;return f.getZ()+da*(w.getZ()-f.getZ())+wa*(G.getZ()-f.getZ())}},{key:"longestSideLength",value:function(h,f,w){var G=h.distance(f),re=f.distance(w),xe=w.distance(h),Ae=G;return re>Ae&&(Ae=re),xe>Ae&&(Ae=xe),Ae}},{key:"circumcentreDD",value:function(h,f,w){var G=$t.valueOf(h.x).subtract(w.x),re=$t.valueOf(h.y).subtract(w.y),xe=$t.valueOf(f.x).subtract(w.x),Ae=$t.valueOf(f.y).subtract(w.y),tt=$t.determinant(G,re,xe,Ae).multiply(2),Nt=G.sqr().add(re.sqr()),Ut=xe.sqr().add(Ae.sqr()),xs=$t.determinant(re,Nt,Ae,Ut),$s=$t.determinant(G,Nt,xe,Ut),bn=$t.valueOf(w.x).subtract(xs.divide(tt)).doubleValue(),da=$t.valueOf(w.y).add($s.divide(tt)).doubleValue();return new Re(bn,da)}},{key:"isAcute",value:function(h,f,w){return!!Wr.isAcute(h,f,w)&&!!Wr.isAcute(f,w,h)&&!!Wr.isAcute(w,h,f)}},{key:"circumcentre",value:function(h,f,w){var G=w.x,re=w.y,xe=h.x-G,Ae=h.y-re,tt=f.x-G,Nt=f.y-re,Ut=2*N.det(xe,Ae,tt,Nt),xs=N.det(Ae,xe*xe+Ae*Ae,Nt,tt*tt+Nt*Nt),$s=N.det(xe,xe*xe+Ae*Ae,tt,tt*tt+Nt*Nt);return new Re(G-xs/Ut,re+$s/Ut)}},{key:"perpendicularBisector",value:function(h,f){var w=f.x-h.x,G=f.y-h.y,re=new pl(h.x+w/2,h.y+G/2,1),xe=new pl(h.x-G+w/2,h.y+w+G/2,1);return new pl(re,xe)}},{key:"angleBisector",value:function(h,f,w){var G=f.distance(h),re=G/(G+f.distance(w)),xe=w.x-h.x,Ae=w.y-h.y;return new Re(h.x+re*xe,h.y+re*Ae)}},{key:"area3D",value:function(h,f,w){var G=f.x-h.x,re=f.y-h.y,xe=f.getZ()-h.getZ(),Ae=w.x-h.x,tt=w.y-h.y,Nt=w.getZ()-h.getZ(),Ut=re*Nt-xe*tt,xs=xe*Ae-G*Nt,$s=G*tt-re*Ae,bn=Ut*Ut+xs*xs+$s*$s,da=Math.sqrt(bn)/2;return da}},{key:"centroid",value:function(h,f,w){var G=(h.x+f.x+w.x)/3,re=(h.y+f.y+w.y)/3;return new Re(G,re)}},{key:"inCentre",value:function(h,f,w){var G=f.distance(w),re=h.distance(w),xe=h.distance(f),Ae=G+re+xe,tt=(G*h.x+re*f.x+xe*w.x)/Ae,Nt=(G*h.y+re*f.y+xe*w.y)/Ae;return new Re(tt,Nt)}}])}(),Lc=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"addRingSide",value:function(N,h,f,w,G){if(h===0&&N.length<Ls.MINIMUM_VALID_SIZE)return null;var re=w,xe=G;N.length>=Ls.MINIMUM_VALID_SIZE&&bs.isCCW(N)&&(re=G,xe=w,f=Xe.opposite(f));var Ae=this._curveBuilder.getRingCurve(N,f,h);this.addCurve(Ae,re,xe)}},{key:"addRingBothSides",value:function(N,h){this.addRingSide(N,h,Xe.LEFT,fe.EXTERIOR,fe.INTERIOR),this.addRingSide(N,h,Xe.RIGHT,fe.INTERIOR,fe.EXTERIOR)}},{key:"addPoint",value:function(N){if(this._distance<=0)return null;var h=N.getCoordinates(),f=this._curveBuilder.getLineCurve(h,this._distance);this.addCurve(f,fe.EXTERIOR,fe.INTERIOR)}},{key:"addPolygon",value:function(N){var h=this._distance,f=Xe.LEFT;this._distance<0&&(h=-this._distance,f=Xe.RIGHT);var w=N.getExteriorRing(),G=Fn.removeRepeatedPoints(w.getCoordinates());if(this._distance<0&&this.isErodedCompletely(w,this._distance)||this._distance<=0&&G.length<3)return null;this.addRingSide(G,h,f,fe.EXTERIOR,fe.INTERIOR);for(var re=0;re<N.getNumInteriorRing();re++){var xe=N.getInteriorRingN(re),Ae=Fn.removeRepeatedPoints(xe.getCoordinates());this._distance>0&&this.isErodedCompletely(xe,-this._distance)||this.addRingSide(Ae,h,Xe.opposite(f),fe.INTERIOR,fe.EXTERIOR)}}},{key:"isTriangleErodedCompletely",value:function(N,h){var f=new Fl(N[0],N[1],N[2]),w=f.inCentre();return wn.pointToSegment(w,f.p0,f.p1)<Math.abs(h)}},{key:"addLineString",value:function(N){if(this._curveBuilder.isLineOffsetEmpty(this._distance))return null;var h=Fn.removeRepeatedPoints(N.getCoordinates());if(Fn.isRing(h)&&!this._curveBuilder.getBufferParameters().isSingleSided())this.addRingBothSides(h,this._distance);else{var f=this._curveBuilder.getLineCurve(h,this._distance);this.addCurve(f,fe.EXTERIOR,fe.INTERIOR)}}},{key:"addCurve",value:function(N,h,f){if(N===null||N.length<2)return null;var w=new So(N,new Zr(0,fe.BOUNDARY,h,f));this._curveList.add(w)}},{key:"getCurves",value:function(){return this.add(this._inputGeom),this._curveList}},{key:"add",value:function(N){if(N.isEmpty())return null;if(N instanceof Ws)this.addPolygon(N);else if(N instanceof pe)this.addLineString(N);else if(N instanceof Zt)this.addPoint(N);else if(N instanceof os)this.addCollection(N);else if(N instanceof Ha)this.addCollection(N);else if(N instanceof ei)this.addCollection(N);else{if(!(N instanceof xt))throw new _t(N.getGeometryType());this.addCollection(N)}}},{key:"isErodedCompletely",value:function(N,h){var f=N.getCoordinates();if(f.length<4)return h<0;if(f.length===4)return this.isTriangleErodedCompletely(f,h);var w=N.getEnvelopeInternal(),G=Math.min(w.getHeight(),w.getWidth());return h<0&&2*Math.abs(h)>G}},{key:"addCollection",value:function(N){for(var h=0;h<N.getNumGeometries();h++){var f=N.getGeometryN(h);this.add(f)}}}],[{key:"constructor_",value:function(){this._inputGeom=null,this._distance=null,this._curveBuilder=null,this._curveList=new ps;var N=arguments[0],h=arguments[1],f=arguments[2];this._inputGeom=N,this._distance=h,this._curveBuilder=f}}])}(),li=function(){return i(function N(){l(this,N)},[{key:"locate",value:function(N){}}])}(),Kl=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"next",value:function(){if(this._atStart)return this._atStart=!1,N.isAtomic(this._parent)&&this._index++,this._parent;if(this._subcollectionIterator!==null){if(this._subcollectionIterator.hasNext())return this._subcollectionIterator.next();this._subcollectionIterator=null}if(this._index>=this._max)throw new ht;var h=this._parent.getGeometryN(this._index++);return h instanceof xt?(this._subcollectionIterator=new N(h),this._subcollectionIterator.next()):h}},{key:"remove",value:function(){throw new _t(this.getClass().getName())}},{key:"hasNext",value:function(){if(this._atStart)return!0;if(this._subcollectionIterator!==null){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)}},{key:"interfaces_",get:function(){return[Qo]}}],[{key:"constructor_",value:function(){this._parent=null,this._atStart=null,this._max=null,this._index=null,this._subcollectionIterator=null;var h=arguments[0];this._parent=h,this._atStart=!0,this._index=0,this._max=h.getNumGeometries()}},{key:"isAtomic",value:function(h){return!(h instanceof xt)}}])}(),Ia=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"locate",value:function(h){return N.locate(h,this._geom)}},{key:"interfaces_",get:function(){return[li]}}],[{key:"constructor_",value:function(){this._geom=null;var h=arguments[0];this._geom=h}},{key:"locatePointInPolygon",value:function(h,f){if(f.isEmpty())return fe.EXTERIOR;var w=f.getExteriorRing(),G=N.locatePointInRing(h,w);if(G!==fe.INTERIOR)return G;for(var re=0;re<f.getNumInteriorRing();re++){var xe=f.getInteriorRingN(re),Ae=N.locatePointInRing(h,xe);if(Ae===fe.BOUNDARY)return fe.BOUNDARY;if(Ae===fe.INTERIOR)return fe.EXTERIOR}return fe.INTERIOR}},{key:"locatePointInRing",value:function(h,f){return f.getEnvelopeInternal().intersects(h)?Nr.locateInRing(h,f.getCoordinates()):fe.EXTERIOR}},{key:"containsPointInPolygon",value:function(h,f){return fe.EXTERIOR!==N.locatePointInPolygon(h,f)}},{key:"locateInGeometry",value:function(h,f){if(f instanceof Ws)return N.locatePointInPolygon(h,f);if(f instanceof xt)for(var w=new Kl(f);w.hasNext();){var G=w.next();if(G!==f){var re=N.locateInGeometry(h,G);if(re!==fe.EXTERIOR)return re}}return fe.EXTERIOR}},{key:"isContained",value:function(h,f){return fe.EXTERIOR!==N.locate(h,f)}},{key:"locate",value:function(h,f){return f.isEmpty()?fe.EXTERIOR:f.getEnvelopeInternal().intersects(h)?N.locateInGeometry(h,f):fe.EXTERIOR}}])}(),Jl=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"getNextCW",value:function(N){this.getEdges();var h=this._edgeList.indexOf(N),f=h-1;return h===0&&(f=this._edgeList.size()-1),this._edgeList.get(f)}},{key:"propagateSideLabels",value:function(N){for(var h=fe.NONE,f=this.iterator();f.hasNext();){var w=f.next().getLabel();w.isArea(N)&&w.getLocation(N,Xe.LEFT)!==fe.NONE&&(h=w.getLocation(N,Xe.LEFT))}if(h===fe.NONE)return null;for(var G=h,re=this.iterator();re.hasNext();){var xe=re.next(),Ae=xe.getLabel();if(Ae.getLocation(N,Xe.ON)===fe.NONE&&Ae.setLocation(N,Xe.ON,G),Ae.isArea(N)){var tt=Ae.getLocation(N,Xe.LEFT),Nt=Ae.getLocation(N,Xe.RIGHT);if(Nt!==fe.NONE){if(Nt!==G)throw new Jt("side location conflict",xe.getCoordinate());tt===fe.NONE&&ke.shouldNeverReachHere("found single null side (at "+xe.getCoordinate()+")"),G=tt}else ke.isTrue(Ae.getLocation(N,Xe.LEFT)===fe.NONE,"found single null side"),Ae.setLocation(N,Xe.RIGHT,G),Ae.setLocation(N,Xe.LEFT,G)}}}},{key:"getCoordinate",value:function(){var N=this.iterator();return N.hasNext()?N.next().getCoordinate():null}},{key:"print",value:function(N){Is.out.println("EdgeEndStar:   "+this.getCoordinate());for(var h=this.iterator();h.hasNext();)h.next().print(N)}},{key:"isAreaLabelsConsistent",value:function(N){return this.computeEdgeEndLabels(N.getBoundaryNodeRule()),this.checkAreaLabelsConsistent(0)}},{key:"checkAreaLabelsConsistent",value:function(N){var h=this.getEdges();if(h.size()<=0)return!0;var f=h.size()-1,w=h.get(f).getLabel().getLocation(N,Xe.LEFT);ke.isTrue(w!==fe.NONE,"Found unlabelled area edge");for(var G=w,re=this.iterator();re.hasNext();){var xe=re.next().getLabel();ke.isTrue(xe.isArea(N),"Found non-area edge");var Ae=xe.getLocation(N,Xe.LEFT),tt=xe.getLocation(N,Xe.RIGHT);if(Ae===tt||tt!==G)return!1;G=Ae}return!0}},{key:"findIndex",value:function(N){this.iterator();for(var h=0;h<this._edgeList.size();h++)if(this._edgeList.get(h)===N)return h;return-1}},{key:"iterator",value:function(){return this.getEdges().iterator()}},{key:"getEdges",value:function(){return this._edgeList===null&&(this._edgeList=new ps(this._edgeMap.values())
759),this._edgeList}},{key:"getLocation",value:function(N,h,f){return this._ptInAreaLocation[N]===fe.NONE&&(this._ptInAreaLocation[N]=Ia.locate(h,f[N].getGeometry())),this._ptInAreaLocation[N]}},{key:"toString",value:function(){var N=new rs;N.append("EdgeEndStar:   "+this.getCoordinate()),N.append(`
760`);for(var h=this.iterator();h.hasNext();){var f=h.next();N.append(f),N.append(`
761`)}return N.toString()}},{key:"computeEdgeEndLabels",value:function(N){for(var h=this.iterator();h.hasNext();)h.next().computeLabel(N)}},{key:"computeLabelling",value:function(N){this.computeEdgeEndLabels(N[0].getBoundaryNodeRule()),this.propagateSideLabels(0),this.propagateSideLabels(1);for(var h=[!1,!1],f=this.iterator();f.hasNext();)for(var w=f.next().getLabel(),G=0;G<2;G++)w.isLine(G)&&w.getLocation(G)===fe.BOUNDARY&&(h[G]=!0);for(var re=this.iterator();re.hasNext();)for(var xe=re.next(),Ae=xe.getLabel(),tt=0;tt<2;tt++)if(Ae.isAnyNull(tt)){var Nt=fe.NONE;if(h[tt])Nt=fe.EXTERIOR;else{var Ut=xe.getCoordinate();Nt=this.getLocation(tt,Ut,N)}Ae.setAllLocationsIfNull(tt,Nt)}}},{key:"getDegree",value:function(){return this._edgeMap.size()}},{key:"insertEdgeEnd",value:function(N,h){this._edgeMap.put(N,h),this._edgeList=null}}],[{key:"constructor_",value:function(){this._edgeMap=new ti,this._edgeList=null,this._ptInAreaLocation=[fe.NONE,fe.NONE]}}])}(),fr=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"linkResultDirectedEdges",value:function(){this.getResultAreaEdges();for(var f=null,w=null,G=this._SCANNING_FOR_INCOMING,re=0;re<this._resultAreaEdgeList.size();re++){var xe=this._resultAreaEdgeList.get(re),Ae=xe.getSym();if(xe.getLabel().isArea())switch(f===null&&xe.isInResult()&&(f=xe),G){case this._SCANNING_FOR_INCOMING:if(!Ae.isInResult())continue;w=Ae,G=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(!xe.isInResult())continue;w.setNext(xe),G=this._SCANNING_FOR_INCOMING}}if(G===this._LINKING_TO_OUTGOING){if(f===null)throw new Jt("no outgoing dirEdge found",this.getCoordinate());ke.isTrue(f.isInResult(),"unable to link last incoming dirEdge"),w.setNext(f)}}},{key:"insert",value:function(f){var w=f;this.insertEdgeEnd(w,w)}},{key:"getRightmostEdge",value:function(){var f=this.getEdges(),w=f.size();if(w<1)return null;var G=f.get(0);if(w===1)return G;var re=f.get(w-1),xe=G.getQuadrant(),Ae=re.getQuadrant();return Tn.isNorthern(xe)&&Tn.isNorthern(Ae)?G:Tn.isNorthern(xe)||Tn.isNorthern(Ae)?G.getDy()!==0?G:re.getDy()!==0?re:(ke.shouldNeverReachHere("found two horizontal edges incident on node"),null):re}},{key:"print",value:function(f){Is.out.println("DirectedEdgeStar: "+this.getCoordinate());for(var w=this.iterator();w.hasNext();){var G=w.next();f.print("out "),G.print(f),f.println(),f.print("in "),G.getSym().print(f),f.println()}}},{key:"getResultAreaEdges",value:function(){if(this._resultAreaEdgeList!==null)return this._resultAreaEdgeList;this._resultAreaEdgeList=new ps;for(var f=this.iterator();f.hasNext();){var w=f.next();(w.isInResult()||w.getSym().isInResult())&&this._resultAreaEdgeList.add(w)}return this._resultAreaEdgeList}},{key:"updateLabelling",value:function(f){for(var w=this.iterator();w.hasNext();){var G=w.next().getLabel();G.setAllLocationsIfNull(0,f.getLocation(0)),G.setAllLocationsIfNull(1,f.getLocation(1))}}},{key:"linkAllDirectedEdges",value:function(){this.getEdges();for(var f=null,w=null,G=this._edgeList.size()-1;G>=0;G--){var re=this._edgeList.get(G),xe=re.getSym();w===null&&(w=xe),f!==null&&xe.setNext(f),f=re}w.setNext(f)}},{key:"computeDepths",value:function(){if(arguments.length===1){var f=arguments[0],w=this.findIndex(f),G=f.getDepth(Xe.LEFT),re=f.getDepth(Xe.RIGHT),xe=this.computeDepths(w+1,this._edgeList.size(),G);if(this.computeDepths(0,w,xe)!==re)throw new Jt("depth mismatch at "+f.getCoordinate())}else if(arguments.length===3){for(var Ae=arguments[1],tt=arguments[2],Nt=arguments[0];Nt<Ae;Nt++){var Ut=this._edgeList.get(Nt);Ut.setEdgeDepths(Xe.RIGHT,tt),tt=Ut.getDepth(Xe.LEFT)}return tt}}},{key:"mergeSymLabels",value:function(){for(var f=this.iterator();f.hasNext();){var w=f.next();w.getLabel().merge(w.getSym().getLabel())}}},{key:"linkMinimalDirectedEdges",value:function(f){for(var w=null,G=null,re=this._SCANNING_FOR_INCOMING,xe=this._resultAreaEdgeList.size()-1;xe>=0;xe--){var Ae=this._resultAreaEdgeList.get(xe),tt=Ae.getSym();switch(w===null&&Ae.getEdgeRing()===f&&(w=Ae),re){case this._SCANNING_FOR_INCOMING:if(tt.getEdgeRing()!==f)continue;
761G=tt,re=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(Ae.getEdgeRing()!==f)continue;G.setNextMin(Ae),re=this._SCANNING_FOR_INCOMING}}re===this._LINKING_TO_OUTGOING&&(ke.isTrue(w!==null,"found null for first outgoing dirEdge"),ke.isTrue(w.getEdgeRing()===f,"unable to link last incoming dirEdge"),G.setNextMin(w))}},{key:"getOutgoingDegree",value:function(){if(arguments.length===0){for(var f=0,w=this.iterator();w.hasNext();)w.next().isInResult()&&f++;return f}if(arguments.length===1){for(var G=arguments[0],re=0,xe=this.iterator();xe.hasNext();)xe.next().getEdgeRing()===G&&re++;return re}}},{key:"getLabel",value:function(){return this._label}},{key:"findCoveredLineEdges",value:function(){for(var f=fe.NONE,w=this.iterator();w.hasNext();){var G=w.next(),re=G.getSym();if(!G.isLineEdge()){if(G.isInResult()){f=fe.INTERIOR;break}if(re.isInResult()){f=fe.EXTERIOR;break}}}if(f===fe.NONE)return null;for(var xe=f,Ae=this.iterator();Ae.hasNext();){var tt=Ae.next(),Nt=tt.getSym();tt.isLineEdge()?tt.getEdge().setCovered(xe===fe.INTERIOR):(tt.isInResult()&&(xe=fe.EXTERIOR),Nt.isInResult()&&(xe=fe.INTERIOR))}}},{key:"computeLabelling",value:function(f){P(h,"computeLabelling",this,1).call(this,f),this._label=new Zr(fe.NONE);for(var w=this.iterator();w.hasNext();)for(var G=w.next().getEdge().getLabel(),re=0;re<2;re++){var xe=G.getLocation(re);xe!==fe.INTERIOR&&xe!==fe.BOUNDARY||this._label.setLocation(re,fe.INTERIOR)}}}],[{key:"constructor_",value:function(){this._resultAreaEdgeList=null,this._label=null,this._SCANNING_FOR_INCOMING=1,this._LINKING_TO_OUTGOING=2}}])}(Jl),Dr=function(N){function h(){return l(this,h),a(this,h)}return x(h,N),i(h,[{key:"createNode",value:function(f){return new Br(f,new fr)}}])}(mr),zl=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"compareTo",value:function(h){var f=h;return N.compareOriented(this._pts,this._orientation,f._pts,f._orientation)}},{key:"interfaces_",get:function(){return[H]}}],[{key:"constructor_",value:function(){this._pts=null,this._orientation=null;var h=arguments[0];this._pts=h,this._orientation=N.orientation(h)}},{key:"orientation",value:function(h){return Fn.increasingDirection(h)===1}},{key:"compareOriented",value:function(h,f,w,G){for(var re=f?1:-1,xe=G?1:-1,Ae=f?h.length:-1,tt=G?w.length:-1,Nt=f?0:h.length-1,Ut=G?0:w.length-1;;){var xs=h[Nt].compareTo(w[Ut]);if(xs!==0)return xs;var $s=(Nt+=re)===Ae,bn=(Ut+=xe)===tt;if($s&&!bn)return-1;if(!$s&&bn)return 1;if($s&&bn)return 0}}}])}(),qe=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"print",value:function(N){N.print("MULTILINESTRING ( ");for(var h=0;h<this._edges.size();h++){var f=this._edges.get(h);h>0&&N.print(","),N.print("(");for(var w=f.getCoordinates(),G=0;G<w.length;G++)G>0&&N.print(","),N.print(w[G].x+" "+w[G].y);N.println(")")}N.print(")  ")}},{key:"addAll",value:function(N){for(var h=N.iterator();h.hasNext();)this.add(h.next())}},{key:"findEdgeIndex",value:function(N){for(var h=0;h<this._edges.size();h++)if(this._edges.get(h).equals(N))return h;return-1}},{key:"iterator",value:function(){return this._edges.iterator()}},{key:"getEdges",value:function(){return this._edges}},{key:"get",value:function(N){return this._edges.get(N)}},{key:"findEqualEdge",value:function(N){var h=new zl(N.getCoordinates());return this._ocaMap.get(h)}},{key:"add",value:function(N){this._edges.add(N);var h=new zl(N.getCoordinates());this._ocaMap.put(h,N)}}],[{key:"constructor_",value:function(){this._edges=new ps,this._ocaMap=new ti}}])}(),Xt=function(){return i(function N(){l(this,N)},[{key:"processIntersections",value:function(N,h,f,w){}},{key:"isDone",value:function(){}}])}(),js=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"isTrivialIntersection",value:function(h,f,w,G){if(h===w&&this._li.getIntersectionNum()===1){if(N.isAdjacentSegments(f,G))return!0;if(h.isClosed()){var re=h.size()-1;if(f===0&&G===re||G===0&&f===re)return!0}}return!1}},{key:"getProperIntersectionPoint",value:function(){return this._properIntersectionPoint}},{key:"hasProperInteriorIntersection",value:function(){return this._hasProperInterior}},{key:"getLineIntersector",value:function(){return this._li}},{key:"hasProperIntersection",value:function(){return this._hasProper}},{key:"processIntersections",value:function(h,f,w,G){if(h===w&&f===G)return null;this.numTests++;var re=h.getCoordinates()[f],xe=h.getCoordinates()[f+1],Ae=w.getCoordinates()[G],tt=w.getCoordinates()[G+1];this._li.computeIntersection(re,xe,Ae,tt),this._li.hasIntersection()&&(this.numIntersections++,this._li.isInteriorIntersection()&&(this.numInteriorIntersections++,this._hasInterior=!0),this.isTrivialIntersection(h,f,w,G)||(this._hasIntersection=!0,h.addIntersections(this._li,f,0),w.addIntersections(this._li,G,1),this._li.isProper()&&(this.numProperIntersections++,this._hasProper=!0,this._hasProperInterior=!0)))}},{key:"hasIntersection",value:function(){return this._hasIntersection}},{key:"isDone",value:function(){return!1}},{key:"hasInteriorIntersection",value:function(){return this._hasInterior}}
vendor: 6,147 bytes, line 761
761,{key:"interfaces_",get:function(){return[Xt]}}],[{key:"constructor_",value:function(){this._hasIntersection=!1,this._hasProper=!1,this._hasProperInterior=!1,this._hasInterior=!1,this._properIntersectionPoint=null,this._li=null,this._isSelfIntersection=null,this.numIntersections=0,this.numInteriorIntersections=0,this.numProperIntersections=0,this.numTests=0;var h=arguments[0];this._li=h}},{key:"isAdjacentSegments",value:function(h,f){return Math.abs(h-f)===1}}])}(),Rs=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"getSegmentIndex",value:function(){return this.segmentIndex}},{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(N){N.print(this.coord),N.print(" seg # = "+this.segmentIndex),N.println(" dist = "+this.dist)}},{key:"compareTo",value:function(N){var h=N;return this.compare(h.segmentIndex,h.dist)}},{key:"isEndPoint",value:function(N){return this.segmentIndex===0&&this.dist===0||this.segmentIndex===N}},{key:"toString",value:function(){return this.coord+" seg # = "+this.segmentIndex+" dist = "+this.dist}},{key:"getDistance",value:function(){return this.dist}},{key:"compare",value:function(N,h){return this.segmentIndex<N?-1:this.segmentIndex>N?1:this.dist<h?-1:this.dist>h?1:0}},{key:"interfaces_",get:function(){return[H]}}],[{key:"constructor_",value:function(){this.coord=null,this.segmentIndex=null,this.dist=null;var N=arguments[0],h=arguments[1],f=arguments[2];this.coord=new Re(N),this.segmentIndex=h,this.dist=f}}])}(),la=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"print",value:function(N){N.println("Intersections:");for(var h=this.iterator();h.hasNext();)h.next().print(N)}},{key:"iterator",value:function(){return this._nodeMap.values().iterator()}},{key:"addSplitEdges",value:function(N){this.addEndpoints();for(var h=this.iterator(),f=h.next();h.hasNext();){var w=h.next(),G=this.createSplitEdge(f,w);N.add(G),f=w}}},{key:"addEndpoints",value:function(){var N=this.edge.pts.length-1;this.add(this.edge.pts[0],0,0),this.add(this.edge.pts[N],N,0)}},{key:"createSplitEdge",value:function(N,h){var f=h.segmentIndex-N.segmentIndex+2,w=this.edge.pts[h.segmentIndex],G=h.dist>0||!h.coord.equals2D(w);G||f--;var re=new Array(f).fill(null),xe=0;re[xe++]=new Re(N.coord);for(var Ae=N.segmentIndex+1;Ae<=h.segmentIndex;Ae++)re[xe++]=this.edge.pts[Ae];return G&&(re[xe]=h.coord),new Oo(re,new Zr(this.edge._label))}},{key:"add",value:function(N,h,f){var w=new Rs(N,h,f),G=this._nodeMap.get(w);return G!==null?G:(this._nodeMap.put(w,w),w)}},{key:"isIntersection",value:function(N){for(var h=this.iterator();h.hasNext();)if(h.next().coord.equals(N))return!0;return!1}}],[{key:"constructor_",value:function(){this._nodeMap=new ti,this.edge=null;var N=arguments[0];this.edge=N}}])}(),Bn=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"isIntersects",value:function(){return!this.isDisjoint()}},{key:"isCovers",value:function(){return(N.isTrue(this._matrix[fe.INTERIOR][fe.INTERIOR])||N.isTrue(this._matrix[fe.INTERIOR][fe.BOUNDARY])||N.isTrue(this._matrix[fe.BOUNDARY][fe.INTERIOR])||N.isTrue(this._matrix[fe.BOUNDARY][fe.BOUNDARY]))&&this._matrix[fe.EXTERIOR][fe.INTERIOR]===De.FALSE&&this._matrix[fe.EXTERIOR][fe.BOUNDARY]===De.FALSE}},{key:"isCoveredBy",value:function(){return(N.isTrue(this._matrix[fe.INTERIOR][fe.INTERIOR])||N.isTrue(this._matrix[fe.INTERIOR][fe.BOUNDARY])||N.isTrue(this._matrix[fe.BOUNDARY][fe.INTERIOR])||N.isTrue(this._matrix[fe.BOUNDARY][fe.BOUNDARY]))&&this._matrix[fe.INTERIOR][fe.EXTERIOR]===De.FALSE&&this._matrix[fe.BOUNDARY][fe.EXTERIOR]===De.FALSE}},{key:"set",value:function(){if(arguments.length===1)for(var h=arguments[0],f=0;f<h.length;f++){var w=Math.trunc(f/3),G=f%3;this._matrix[w][G]=De.toDimensionValue(h.charAt(f))}else if(arguments.length===3){var re=arguments[0],xe=arguments[1],Ae=arguments[2];this._matrix[re][xe]=Ae}}},{key:"isContains",value:function(){return N.isTrue(this._matrix[fe.INTERIOR][fe.INTERIOR])&&this._matrix[fe.EXTERIOR][fe.INTERIOR]===De.FALSE&&this._matrix[fe.EXTERIOR][fe.BOUNDARY]===De.FALSE}},{key:"setAtLeast",value:function(){if(arguments.length===1)for(var h=arguments[0],f=0;f<h.length;f++){var w=Math.trunc(f/3),G=f%3;this.setAtLeast(w,G,De.toDimensionValue(h.charAt(f)))}else if(arguments.length===3){var re=arguments[0],xe=arguments[1],Ae=arguments[2];this._matrix[re][xe]<Ae&&(this._matrix[re][xe]=Ae)}}},{key:"setAtLeastIfValid",value:function(h,f,w){h>=0&&f>=0&&this.setAtLeast(h,f,w)}},{key:"isWithin",value:function(){return N.isTrue(this._matrix[fe.INTERIOR][fe.INTERIOR])&&this._matrix[fe.INTERIOR][fe.EXTERIOR]===De.FALSE&&this._matrix[fe.BOUNDARY][fe.EXTERIOR]===De.FALSE}},{key:"isTouches",value:function(h,f){return h>f?this.isTouches(f,h):(h===De.A&&f===De.A||h===De.L&&f===De.L||h===De.L&&f===De.A||h===De.P&&f===De.A||h===De.P&&f===De.L)&&this._matrix[fe.INTERIOR][fe.INTERIOR]===De.FALSE&&(N.isTrue(this._matrix[fe.INTERIOR][fe.BOUNDARY])||N.isTrue(this._matrix[fe.BOUNDARY][fe.INTERIOR])||N.isTrue(this._matrix[fe.BOUNDARY][fe.BOUNDARY]))}},{key:"isOverlaps",value:function(h,f){return h===De.P&&f===De.P||h===De.A&&f===De.A?N.isTrue(this._matrix[fe.INTERIOR][fe.INTERIOR])&&N.isTrue(this._matrix[fe.INTERIOR][fe.EXTERIOR])&&N.isTrue(this._matrix[fe.EXTERIOR][fe.INTERIOR]):h===De.L&&f===De.L&&this._matrix[fe.INTERIOR][fe.INTERIOR]===1&&N.isTrue(this._matrix[fe.INTERIOR][fe.EXTERIOR])&&N.isTrue(this._matrix[fe.EXTERIOR][fe.INTERIOR])}},{key:"isEquals",value:function(h,f){return h===f&&N.isTrue(this._matrix[fe.INTERIOR][fe.INTERIOR])&&this._matrix[fe.INTERIOR][fe.EXTERIOR]===De.FALSE&&this._matrix[fe.BOUNDARY][fe.EXTERIOR]===De.FALSE&&this._matrix[fe.EXTERIOR][fe.INTERIOR]===De.FALSE&&this._matrix[fe.EXTERIOR][fe.BOUNDARY]===De.FALSE}},{key:"toString",value:function(){for(var h=new An("123456789"),f=0;f<3;f++)for(var w=0;w<3;w++)h.setCharAt(3*f+w,De.toDimensionSymbol(this._matrix[f][w]));return h.toString()}},{key:"setAll",value:function(h){for(var f=0;f<3;f++)for(var w=0;w<3;w++)this._matrix[f][w]=h}},{key:"get",value:function(h,f){return this._matrix[h][f]}}
761,{key:"transpose",value:function(){var h=this._matrix[1][0];return this._matrix[1][0]=this._matrix[0][1],this._matrix[0][1]=h,h=this._matrix[2][0],this._matrix[2][0]=this._matrix[0][2],this._matrix[0][2]=h,h=this._matrix[2][1],this._matrix[2][1]=this._matrix[1][2],this._matrix[1][2]=h,this}},{key:"matches",value:function(h){if(h.length!==9)throw new te("Should be length 9: "+h);for(var f=0;f<3;f++)for(var w=0;w<3;w++)if(!N.matches(this._matrix[f][w],h.charAt(3*f+w)))return!1;return!0}},{key:"add",value:function(h){for(var f=0;f<3;f++)for(var w=0;w<3;w++)this.setAtLeast(f,w,h.get(f,w))}},{key:"isDisjoint",value:function(){return this._matrix[fe.INTERIOR][fe.INTERIOR]===De.FALSE&&this._matrix[fe.INTERIOR][fe.BOUNDARY]===De.FALSE&&this._matrix[fe.BOUNDARY][fe.INTERIOR]===De.FALSE&&this._matrix[fe.BOUNDARY][fe.BOUNDARY]===De.FALSE}},{key:"isCrosses",value:function(h,f){return h===De.P&&f===De.L||h===De.P&&f===De.A||h===De.L&&f===De.A?N.isTrue(this._matrix[fe.INTERIOR][fe.INTERIOR])&&N.isTrue(this._matrix[fe.INTERIOR][fe.EXTERIOR]):h===De.L&&f===De.P||h===De.A&&f===De.P||h===De.A&&f===De.L?N.isTrue(this._matrix[fe.INTERIOR][fe.INTERIOR])&&N.isTrue(this._matrix[fe.EXTERIOR][fe.INTERIOR]):h===De.L&&f===De.L&&this._matrix[fe.INTERIOR][fe.INTERIOR]===0}},{key:"interfaces_",get:function(){return[O]}}],[{key:"constructor_",value:function(){if(this._matrix=null,arguments.length===0)this._matrix=Array(3).fill().map(function(){return Array(3)}),this.setAll(De.FALSE);else if(arguments.length===1){if(typeof arguments[0]=="string"){var h=arguments[0];N.constructor_.call(this),this.set(h)}else if(arguments[0]instanceof N){var f=arguments[0];N.constructor_.call(this),this._matrix[fe.INTERIOR][fe.INTERIOR]=f._matrix[fe.INTERIOR][fe.INTERIOR],this._matrix[fe.INTERIOR][fe.BOUNDARY]=f._matrix[fe.INTERIOR][fe.BOUNDARY],this._matrix[fe.INTERIOR][fe.EXTERIOR]=f._matrix[fe.INTERIOR][fe.EXTERIOR],this._matrix[fe.BOUNDARY][fe.INTERIOR]=f._matrix[fe.BOUNDARY][fe.INTERIOR],this._matrix[fe.BOUNDARY][fe.BOUNDARY]=f._matrix[fe.BOUNDARY][fe.BOUNDARY],this._matrix[fe.BOUNDARY][fe.EXTERIOR]=f._matrix[fe.BOUNDARY][fe.EXTERIOR],this._matrix[fe.EXTERIOR][fe.INTERIOR]=f._matrix[fe.EXTERIOR][fe.INTERIOR],this._matrix[fe.EXTERIOR][fe.BOUNDARY]=f._matrix[fe.EXTERIOR][fe.BOUNDARY],this._matrix[fe.EXTERIOR][fe.EXTERIOR]=f._matrix[fe.EXTERIOR][fe.EXTERIOR]}}}},{key:"matches",value:function(){if(Number.isInteger(arguments[0])&&typeof arguments[1]=="string"){var h=arguments[0],f=arguments[1];return f===De.SYM_DONTCARE||f===De.SYM_TRUE&&(h>=0||h===De.TRUE)||f===De.SYM_FALSE&&h===De.FALSE||f===De.SYM_P&&h===De.P||f===De.SYM_L&&h===De.L||f===De.SYM_A&&h===De.A}if(typeof arguments[0]=="string"&&typeof arguments[1]=="string"){var w=arguments[1];return new N(arguments[0]).matches(w)}}},{key:"isTrue",value:function(h){return h>=0||h===De.TRUE}}])}(),Rr=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"size",value:function(){return this._size}},{key:"addAll",value:function(h){return h===null||h.length===0?null:(this.ensureCapacity(this._size+h.length),Is.arraycopy(h,0,this._data,this._size,h.length),void(this._size+=h.length))}},{key:"ensureCapacity",value:function(h){if(h<=this._data.length)return null;var f=Math.max(h,2*this._data.length);this._data=es.copyOf(this._data,f)}},{key:"toArray",value:function(){var h=new Array(this._size).fill(null);return Is.arraycopy(this._data,0,h,0,this._size),h}},{key:"add",value:function(h){this.ensureCapacity(this._size+1),this._data[this._size]=h,++this._size}}],[{key:"constructor_",value:function(){if(this._data=null,this._size=0,arguments.length===0)N.constructor_.call(this,10);else if(arguments.length===1){var h=arguments[0];this._data=new Array(h).fill(null)}}}])}(),Mc=function(){function N(){l(this,N)}return i(N,[{key:"getChainStartIndices",value:function(h){var f=0,w=new Rr(Math.trunc(h.length/2));w.add(f);do{var G=this.findChainEnd(h,f);w.add(G),f=G}while(f<h.length-1);return w.toArray()}},{key:"findChainEnd",value:function(h,f){for(var w=Tn.quadrant(h[f],h[f+1]),G=f+1;G<h.length&&Tn.quadrant(h[G-1],h[G])===w;)G++;return G-1}},{key:"OLDgetChainStartIndices",value:function(h){var f=0,w=new ps;w.add(f);do{var G=this.findChainEnd(h,f);w.add(G),f=G}while(f<h.length-1);return N.toIntArray(w)}}],[{key:"toIntArray",value:function(h){for(var f=new Array(h.size()).fill(null),w=0;w<f.length;w++)f[w]=h.get(w).intValue();return f}}])}(),Uo=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"getCoordinates",value:function(){return this.pts}},{key:"getMaxX",value:function(N){var h=this.pts[this.startIndex[N]].x,f=this.pts[this.startIndex[N+1]].x;return h>f?h:f}},{key:"getMinX",value:function(N){var h=this.pts[this.startIndex[N]].x,f=this.pts[this.startIndex[N+1]].x;return h<f?h:f}},{key:"computeIntersectsForChain",value:function(){if(arguments.length===4){var N=arguments[0],h=arguments[1],f=arguments[2],w=arguments[3];this.computeIntersectsForChain(this.startIndex[N],this.startIndex[N+1],h,h.startIndex[f],h.startIndex[f+1],w)}else if(arguments.length===6){var G=arguments[0],re=arguments[1],xe=arguments[2],Ae=arguments[3],tt=arguments[4],Nt=arguments[5];if(re-G==1&&tt-Ae==1)return Nt.addIntersections(this.e,G,xe.e,Ae),null;if(!this.overlaps(G,re,xe,Ae,tt))return null;var Ut=Math.trunc((G+re)/2),xs=Math.trunc((Ae+tt)/2);G<Ut&&(Ae<xs&&this.computeIntersectsForChain(G,Ut,xe,Ae,xs,Nt),xs<tt&&this.computeIntersectsForChain(G,Ut,xe,xs,tt,Nt)),Ut<re&&(Ae<xs&&this.computeIntersectsForChain(Ut,re,xe,Ae,xs,Nt),xs<tt&&this.computeIntersectsForChain(Ut,re,xe,xs,tt,Nt))}}},{key:"overlaps",value:function(N,h,f,w,G){return ft.intersects(this.pts[N],this.pts[h],f.pts[w],f.pts[G])}},{key:"getStartIndexes",value:function(){return this.startIndex}},{key:"computeIntersects",value:function(N,h){for(var f=0;f<this.startIndex.length-1;f++)for(var w=0;w<N.startIndex.length-1;w++)this.computeIntersectsForChain(f,N,w,h)}}
761],[{key:"constructor_",value:function(){this.e=null,this.pts=null,this.startIndex=null;var N=arguments[0];this.e=N,this.pts=N.getCoordinates();var h=new Mc;this.startIndex=h.getChainStartIndices(this.pts)}}])}(),el=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"getDepth",value:function(h,f){return this._depth[h][f]}},{key:"setDepth",value:function(h,f,w){this._depth[h][f]=w}},{key:"isNull",value:function(){if(arguments.length===0){for(var h=0;h<2;h++)for(var f=0;f<3;f++)if(this._depth[h][f]!==N.NULL_VALUE)return!1;return!0}if(arguments.length===1){var w=arguments[0];return this._depth[w][1]===N.NULL_VALUE}if(arguments.length===2){var G=arguments[0],re=arguments[1];return this._depth[G][re]===N.NULL_VALUE}}},{key:"normalize",value:function(){for(var h=0;h<2;h++)if(!this.isNull(h)){var f=this._depth[h][1];this._depth[h][2]<f&&(f=this._depth[h][2]),f<0&&(f=0);for(var w=1;w<3;w++){var G=0;this._depth[h][w]>f&&(G=1),this._depth[h][w]=G}}}},{key:"getDelta",value:function(h){return this._depth[h][Xe.RIGHT]-this._depth[h][Xe.LEFT]}},{key:"getLocation",value:function(h,f){return this._depth[h][f]<=0?fe.EXTERIOR:fe.INTERIOR}},{key:"toString",value:function(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2]}},{key:"add",value:function(){if(arguments.length===1)for(var h=arguments[0],f=0;f<2;f++)for(var w=1;w<3;w++){var G=h.getLocation(f,w);G!==fe.EXTERIOR&&G!==fe.INTERIOR||(this.isNull(f,w)?this._depth[f][w]=N.depthAtLocation(G):this._depth[f][w]+=N.depthAtLocation(G))}else if(arguments.length===3){var re=arguments[0],xe=arguments[1];arguments[2]===fe.INTERIOR&&this._depth[re][xe]++}}}],[{key:"constructor_",value:function(){this._depth=Array(2).fill().map(function(){return Array(3)});for(var h=0;h<2;h++)for(var f=0;f<3;f++)this._depth[h][f]=N.NULL_VALUE}},{key:"depthAtLocation",value:function(h){return h===fe.EXTERIOR?0:h===fe.INTERIOR?1:N.NULL_VALUE}}])}();el.NULL_VALUE=-1;var Oo=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"getDepth",value:function(){return this._depth}},{key:"getCollapsedEdge",value:function(){var f=new Array(2).fill(null);return f[0]=this.pts[0],f[1]=this.pts[1],new h(f,Zr.toLineLabel(this._label))}},{key:"isIsolated",value:function(){return this._isIsolated}},{key:"getCoordinates",value:function(){return this.pts}},{key:"setIsolated",value:function(f){this._isIsolated=f}},{key:"setName",value:function(f){this._name=f}},{key:"equals",value:function(f){if(!(f instanceof h))return!1;var w=f;if(this.pts.length!==w.pts.length)return!1;for(var G=!0,re=!0,xe=this.pts.length,Ae=0;Ae<this.pts.length;Ae++)if(this.pts[Ae].equals2D(w.pts[Ae])||(G=!1),this.pts[Ae].equals2D(w.pts[--xe])||(re=!1),!G&&!re)return!1;return!0}},{key:"getCoordinate",value:function(){if(arguments.length===0)return this.pts.length>0?this.pts[0]:null;if(arguments.length===1){var f=arguments[0];return this.pts[f]}}},{key:"print",value:function(f){f.print("edge "+this._name+": "),f.print("LINESTRING (");for(var w=0;w<this.pts.length;w++)w>0&&f.print(","),f.print(this.pts[w].x+" "+this.pts[w].y);f.print(")  "+this._label+" "+this._depthDelta)}},{key:"computeIM",value:function(f){h.updateIM(this._label,f)}},{key:"isCollapsed",value:function(){return!!this._label.isArea()&&this.pts.length===3&&!!this.pts[0].equals(this.pts[2])}},{key:"isClosed",value:function(){return this.pts[0].equals(this.pts[this.pts.length-1])}},{key:"getMaximumSegmentIndex",value:function(){return this.pts.length-1}},{key:"getDepthDelta",value:function(){return this._depthDelta}},{key:"getNumPoints",value:function(){return this.pts.length}},{key:"printReverse",value:function(f){f.print("edge "+this._name+": ");for(var w=this.pts.length-1;w>=0;w--)f.print(this.pts[w]+" ");f.println("")}},{key:"getMonotoneChainEdge",value:function(){return this._mce===null&&(this._mce=new Uo(this)),this._mce}},{key:"getEnvelope",value:function(){if(this._env===null){this._env=new ft;for(var f=0;f<this.pts.length;f++)this._env.expandToInclude(this.pts[f])}return this._env}},{key:"addIntersection",value:function(f,w,G,re){var xe=new Re(f.getIntersection(re)),Ae=w,tt=f.getEdgeDistance(G,re),Nt=Ae+1;if(Nt<this.pts.length){var Ut=this.pts[Nt];xe.equals2D(Ut)&&(Ae=Nt,tt=0)}this.eiList.add(xe,Ae,tt)}},{key:"toString",value:function(){var f=new An;f.append("edge "+this._name+": "),f.append("LINESTRING (");for(var w=0;w<this.pts.length;w++)w>0&&f.append(","),f.append(this.pts[w].x+" "+this.pts[w].y);return f.append(")  "+this._label+" "+this._depthDelta),f.toString()}},{key:"isPointwiseEqual",value:function(f){if(this.pts.length!==f.pts.length)return!1;for(var w=0;w<this.pts.length;w++)if(!this.pts[w].equals2D(f.pts[w]))return!1;return!0}},{key:"setDepthDelta",value:function(f){this._depthDelta=f}},{key:"getEdgeIntersectionList",value:function(){return this.eiList}},{key:"addIntersections",value:function(f,w,G){for(var re=0;re<f.getIntersectionNum();re++)this.addIntersection(f,w,G,re)}}
761],[{key:"constructor_",value:function(){if(this.pts=null,this._env=null,this.eiList=new la(this),this._name=null,this._mce=null,this._isIsolated=!0,this._depth=new el,this._depthDelta=0,arguments.length===1){var f=arguments[0];h.constructor_.call(this,f,null)}else if(arguments.length===2){var w=arguments[0],G=arguments[1];this.pts=w,this._label=G}}},{key:"updateIM",value:function(){if(!(arguments.length===2&&arguments[1]instanceof Bn&&arguments[0]instanceof Zr))return P(h,"updateIM",this).apply(this,arguments);var f=arguments[0],w=arguments[1];w.setAtLeastIfValid(f.getLocation(0,Xe.ON),f.getLocation(1,Xe.ON),1),f.isArea()&&(w.setAtLeastIfValid(f.getLocation(0,Xe.LEFT),f.getLocation(1,Xe.LEFT),2),w.setAtLeastIfValid(f.getLocation(0,Xe.RIGHT),f.getLocation(1,Xe.RIGHT),2))}}])}(nr),yo=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"setWorkingPrecisionModel",value:function(h){this._workingPrecisionModel=h}},{key:"insertUniqueEdge",value:function(h){var f=this._edgeList.findEqualEdge(h);if(f!==null){var w=f.getLabel(),G=h.getLabel();f.isPointwiseEqual(h)||(G=new Zr(h.getLabel())).flip(),w.merge(G);var re=N.depthDelta(G),xe=f.getDepthDelta()+re;f.setDepthDelta(xe)}else this._edgeList.add(h),h.setDepthDelta(N.depthDelta(h.getLabel()))}},{key:"buildSubgraphs",value:function(h,f){for(var w=new ps,G=h.iterator();G.hasNext();){var re=G.next(),xe=re.getRightmostCoordinate(),Ae=new _o(w).getDepth(xe);re.computeDepth(Ae),re.findResultEdges(),w.add(re),f.add(re.getDirectedEdges(),re.getNodes())}}},{key:"createSubgraphs",value:function(h){for(var f=new ps,w=h.getNodes().iterator();w.hasNext();){var G=w.next();if(!G.isVisited()){var re=new ts;re.create(G),f.add(re)}}return Al.sort(f,Al.reverseOrder()),f}},{key:"createEmptyResultGeometry",value:function(){return this._geomFact.createPolygon()}},{key:"getNoder",value:function(h){if(this._workingNoder!==null)return this._workingNoder;var f=new gd,w=new ul;return w.setPrecisionModel(h),f.setSegmentIntersector(new js(w)),f}},{key:"buffer",value:function(h,f){var w=this._workingPrecisionModel;w===null&&(w=h.getPrecisionModel()),this._geomFact=h.getFactory();var G=new Wl(w,this._bufParams),re=new Lc(h,f,G).getCurves();if(re.size()<=0)return this.createEmptyResultGeometry();this.computeNodedEdges(re,w),this._graph=new $r(new Dr),this._graph.addEdges(this._edgeList.getEdges());var xe=this.createSubgraphs(this._graph),Ae=new Jo(this._geomFact);this.buildSubgraphs(xe,Ae);var tt=Ae.getPolygons();return tt.size()<=0?this.createEmptyResultGeometry():this._geomFact.buildGeometry(tt)}},{key:"computeNodedEdges",value:function(h,f){var w=this.getNoder(f);w.computeNodes(h);for(var G=w.getNodedSubstrings().iterator();G.hasNext();){var re=G.next(),xe=re.getCoordinates();if(xe.length!==2||!xe[0].equals2D(xe[1])){var Ae=re.getData(),tt=new Oo(re.getCoordinates(),new Zr(Ae));this.insertUniqueEdge(tt)}}}},{key:"setNoder",value:function(h){this._workingNoder=h}}],[{key:"constructor_",value:function(){this._bufParams=null,this._workingPrecisionModel=null,this._workingNoder=null,this._geomFact=null,this._graph=null,this._edgeList=new qe;var h=arguments[0];this._bufParams=h}},{key:"depthDelta",value:function(h){var f=h.getLocation(0,Xe.LEFT),w=h.getLocation(0,Xe.RIGHT);return f===fe.INTERIOR&&w===fe.EXTERIOR?1:f===fe.EXTERIOR&&w===fe.INTERIOR?-1:0}},{key:"convertSegStrings",value:function(h){for(var f=new qa,w=new ps;h.hasNext();){var G=h.next(),re=f.createLineString(G.getCoordinates());w.add(re)}return f.buildGeometry(w)}}])}(),gl=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"rescale",value:function(){if(zt(arguments[0],Qe))for(var h=arguments[0].iterator();h.hasNext();){var f=h.next();this.rescale(f.getCoordinates())}else if(arguments[0]instanceof Array){for(var w=arguments[0],G=0;G<w.length;G++)w[G].x=w[G].x/this._scaleFactor+this._offsetX,w[G].y=w[G].y/this._scaleFactor+this._offsetY;w.length===2&&w[0].equals2D(w[1])&&Is.out.println(w)}}},{key:"scale",value:function(){if(zt(arguments[0],Qe)){for(var h=arguments[0],f=new ps(h.size()),w=h.iterator();w.hasNext();){var G=w.next();f.add(new So(this.scale(G.getCoordinates()),G.getData()))}return f}if(arguments[0]instanceof Array){for(var re=arguments[0],xe=new Array(re.length).fill(null),Ae=0;Ae<re.length;Ae++)xe[Ae]=new Re(Math.round((re[Ae].x-this._offsetX)*this._scaleFactor),Math.round((re[Ae].y-this._offsetY)*this._scaleFactor),re[Ae].getZ());return Fn.removeRepeatedPoints(xe)}}},{key:"isIntegerPrecision",value:function(){return this._scaleFactor===1}},{key:"getNodedSubstrings",value:function(){var h=this._noder.getNodedSubstrings();return this._isScaled&&this.rescale(h),h}},{key:"computeNodes",value:function(h){var f=h;this._isScaled&&(f=this.scale(h)),this._noder.computeNodes(f)}},{key:"interfaces_",get:function(){return[Hl]}}
761],[{key:"constructor_",value:function(){if(this._noder=null,this._scaleFactor=null,this._offsetX=null,this._offsetY=null,this._isScaled=!1,arguments.length===2){var h=arguments[0],f=arguments[1];N.constructor_.call(this,h,f,0,0)}else if(arguments.length===4){var w=arguments[0],G=arguments[1];this._noder=w,this._scaleFactor=G,this._isScaled=!this.isIntegerPrecision()}}}])}(),ci=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"checkEndPtVertexIntersections",value:function(){if(arguments.length===0)for(var h=this._segStrings.iterator();h.hasNext();){var f=h.next().getCoordinates();this.checkEndPtVertexIntersections(f[0],this._segStrings),this.checkEndPtVertexIntersections(f[f.length-1],this._segStrings)}else if(arguments.length===2){for(var w=arguments[0],G=arguments[1].iterator();G.hasNext();)for(var re=G.next().getCoordinates(),xe=1;xe<re.length-1;xe++)if(re[xe].equals(w))throw new we("found endpt/interior pt intersection at index "+xe+" :pt "+w)}}},{key:"checkInteriorIntersections",value:function(){if(arguments.length===0)for(var h=this._segStrings.iterator();h.hasNext();)for(var f=h.next(),w=this._segStrings.iterator();w.hasNext();){var G=w.next();this.checkInteriorIntersections(f,G)}else if(arguments.length===2)for(var re=arguments[0],xe=arguments[1],Ae=re.getCoordinates(),tt=xe.getCoordinates(),Nt=0;Nt<Ae.length-1;Nt++)for(var Ut=0;Ut<tt.length-1;Ut++)this.checkInteriorIntersections(re,Nt,xe,Ut);else if(arguments.length===4){var xs=arguments[0],$s=arguments[1],bn=arguments[2],da=arguments[3];if(xs===bn&&$s===da)return null;var wa=xs.getCoordinates()[$s],Lr=xs.getCoordinates()[$s+1],ur=bn.getCoordinates()[da],si=bn.getCoordinates()[da+1];if(this._li.computeIntersection(wa,Lr,ur,si),this._li.hasIntersection()&&(this._li.isProper()||this.hasInteriorIntersection(this._li,wa,Lr)||this.hasInteriorIntersection(this._li,ur,si)))throw new we("found non-noded intersection at "+wa+"-"+Lr+" and "+ur+"-"+si)}}},{key:"checkValid",value:function(){this.checkEndPtVertexIntersections(),this.checkInteriorIntersections(),this.checkCollapses()}},{key:"checkCollapses",value:function(){if(arguments.length===0)for(var h=this._segStrings.iterator();h.hasNext();){var f=h.next();this.checkCollapses(f)}else if(arguments.length===1)for(var w=arguments[0].getCoordinates(),G=0;G<w.length-2;G++)this.checkCollapse(w[G],w[G+1],w[G+2])}},{key:"hasInteriorIntersection",value:function(h,f,w){for(var G=0;G<h.getIntersectionNum();G++){var re=h.getIntersection(G);if(!re.equals(f)&&!re.equals(w))return!0}return!1}},{key:"checkCollapse",value:function(h,f,w){if(h.equals(w))throw new we("found non-noded collapse at "+N.fact.createLineString([h,f,w]))}}],[{key:"constructor_",value:function(){this._li=new ul,this._segStrings=null;var h=arguments[0];this._segStrings=h}}])}();ci.fact=new qa;var Eo=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"intersectsScaled",value:function(h,f){var w=Math.min(h.x,f.x),G=Math.max(h.x,f.x),re=Math.min(h.y,f.y),xe=Math.max(h.y,f.y),Ae=this._maxx<w||this._minx>G||this._maxy<re||this._miny>xe;if(Ae)return!1;var tt=this.intersectsToleranceSquare(h,f);return ke.isTrue(!(Ae&&tt),"Found bad envelope test"),tt}},{key:"initCorners",value:function(h){var f=.5;this._minx=h.x-f,this._maxx=h.x+f,this._miny=h.y-f,this._maxy=h.y+f,this._corner[0]=new Re(this._maxx,this._maxy),this._corner[1]=new Re(this._minx,this._maxy),this._corner[2]=new Re(this._minx,this._miny),this._corner[3]=new Re(this._maxx,this._miny)}},{key:"intersects",value:function(h,f){return this._scaleFactor===1?this.intersectsScaled(h,f):(this.copyScaled(h,this._p0Scaled),this.copyScaled(f,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled))}},{key:"scale",value:function(h){return Math.round(h*this._scaleFactor)}},{key:"getCoordinate",value:function(){return this._originalPt}},{key:"copyScaled",value:function(h,f){f.x=this.scale(h.x),f.y=this.scale(h.y)}},{key:"getSafeEnvelope",value:function(){if(this._safeEnv===null){var h=N.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new ft(this._originalPt.x-h,this._originalPt.x+h,this._originalPt.y-h,this._originalPt.y+h)}return this._safeEnv}},{key:"intersectsPixelClosure",value:function(h,f){return this._li.computeIntersection(h,f,this._corner[0],this._corner[1]),!!this._li.hasIntersection()||(this._li.computeIntersection(h,f,this._corner[1],this._corner[2]),!!this._li.hasIntersection()||(this._li.computeIntersection(h,f,this._corner[2],this._corner[3]),!!this._li.hasIntersection()||(this._li.computeIntersection(h,f,this._corner[3],this._corner[0]),!!this._li.hasIntersection())))}},{key:"intersectsToleranceSquare",value:function(h,f){var w=!1,G=!1;return this._li.computeIntersection(h,f,this._corner[0],this._corner[1]),!!this._li.isProper()||
761(this._li.computeIntersection(h,f,this._corner[1],this._corner[2]),!!this._li.isProper()||(this._li.hasIntersection()&&(w=!0),this._li.computeIntersection(h,f,this._corner[2],this._corner[3]),!!this._li.isProper()||(this._li.hasIntersection()&&(G=!0),this._li.computeIntersection(h,f,this._corner[3],this._corner[0]),!!this._li.isProper()||!(!w||!G)||!!h.equals(this._pt)||!!f.equals(this._pt))))}},{key:"addSnappedNode",value:function(h,f){var w=h.getCoordinate(f),G=h.getCoordinate(f+1);return!!this.intersects(w,G)&&(h.addIntersection(this.getCoordinate(),f),!0)}}],[{key:"constructor_",value:function(){this._li=null,this._pt=null,this._originalPt=null,this._ptScaled=null,this._p0Scaled=null,this._p1Scaled=null,this._scaleFactor=null,this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,this._corner=new Array(4).fill(null),this._safeEnv=null;var h=arguments[0],f=arguments[1],w=arguments[2];if(this._originalPt=h,this._pt=h,this._scaleFactor=f,this._li=w,f<=0)throw new te("Scale factor must be non-zero");f!==1&&(this._pt=new Re(this.scale(h.x),this.scale(h.y)),this._p0Scaled=new Re,this._p1Scaled=new Re),this.initCorners(this._pt)}}])}();Eo.SAFE_ENV_EXPANSION_FACTOR=.75;var tl=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"select",value:function(){if(arguments.length!==1){if(arguments.length===2){var N=arguments[1];arguments[0].getLineSegment(N,this.selectedSegment),this.select(this.selectedSegment)}}}}],[{key:"constructor_",value:function(){this.selectedSegment=new Kr}}])}(),xl=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"snap",value:function(){if(arguments.length===1){var N=arguments[0];return this.snap(N,null,-1)}if(arguments.length===3){var h=arguments[0],f=arguments[1],w=arguments[2],G=h.getSafeEnvelope(),re=new Bo(h,f,w);return this._index.query(G,new(function(){return i(function xe(){l(this,xe)},[{key:"interfaces_",get:function(){return[_u]}},{key:"visitItem",value:function(xe){xe.select(G,re)}}])}())),re.isNodeAdded()}}}],[{key:"constructor_",value:function(){this._index=null;var N=arguments[0];this._index=N}}])}(),Bo=function(N){function h(){var f;return l(this,h),f=a(this,h),h.constructor_.apply(f,arguments),f}return x(h,N),i(h,[{key:"isNodeAdded",value:function(){return this._isNodeAdded}},{key:"select",value:function(){if(!(arguments.length===2&&Number.isInteger(arguments[1])&&arguments[0]instanceof Jd))return P(h,"select",this,1).apply(this,arguments);var f=arguments[1],w=arguments[0].getContext();if(this._parentEdge===w&&(f===this._hotPixelVertexIndex||f+1===this._hotPixelVertexIndex))return null;this._isNodeAdded|=this._hotPixel.addSnappedNode(w,f)}}],[{key:"constructor_",value:function(){this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var f=arguments[0],w=arguments[1],G=arguments[2];this._hotPixel=f,this._parentEdge=w,this._hotPixelVertexIndex=G}}])}(tl);xl.HotPixelSnapAction=Bo;var Jc=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"processIntersections",value:function(N,h,f,w){if(N===f&&h===w)return null;var G=N.getCoordinates()[h],re=N.getCoordinates()[h+1],xe=f.getCoordinates()[w],Ae=f.getCoordinates()[w+1];if(this._li.computeIntersection(G,re,xe,Ae),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var tt=0;tt<this._li.getIntersectionNum();tt++)this._interiorIntersections.add(this._li.getIntersection(tt));N.addIntersections(this._li,h,0),f.addIntersections(this._li,w,1)}}},{key:"isDone",value:function(){return!1}},{key:"getInteriorIntersections",value:function(){return this._interiorIntersections}},{key:"interfaces_",get:function(){return[Xt]}}],[{key:"constructor_",value:function(){this._li=null,this._interiorIntersections=null;var N=arguments[0];this._li=N,this._interiorIntersections=new ps}}])}(),Cr=function(){return i(function N(){l(this,N),N.constructor_.apply(this,arguments)},[{key:"checkCorrectness",value:function(N){var h=So.getNodedSubstrings(N),f=new ci(h);try{f.checkValid()}catch(w){if(!(w instanceof K))throw w;w.printStackTrace()}}},{key:"getNodedSubstrings",value:function(){return So.getNodedSubstrings(this._nodedSegStrings)}},{key:"snapRound",value:function(N,h){var f=this.findInteriorIntersections(N,h);this.computeIntersectionSnaps(f),this.computeVertexSnaps(N)}},{key:"findInteriorIntersections",value:function(N,h){var f=new Jc(h);return this._noder.setSegmentIntersector(f),this._noder.computeNodes(N),f.getInteriorIntersections()}},{key:"computeVertexSnaps",value:function(){if(zt(arguments[0],Qe))for(var N=arguments[0].iterator();N.hasNext();){var h=N.next();this.computeVertexSnaps(h)}else if(arguments[0]instanceof So)for(var f=arguments[0],w=f.getCoordinates(),G=0;G<w.length;
761G++){var re=new Eo(w[G],this._scaleFactor,this._li);this._pointSnapper.snap(re,f,G)&&f.addIntersection(w[G],G)}}},{key:"computeNodes",value:function(N){this._nodedSegStrings=N,this._noder=new gd,this._pointSnapper=new xl(this._noder.getIndex()),this.snapRound(N,this._li)}},{key:"computeIntersectionSnaps",value:function(N){for(var h=N.iterator();h.hasNext();){var f=h.next(),w=new Eo(f,this._scaleFactor,this._li);this._pointSnapper.snap(w)}}},{key:"interfaces_",get:function(){return[Hl]}}],[{key:"constructor_",value:function(){this._pm=null,this._li=null,this._scaleFactor=null,this._noder=null,this._pointSnapper=null,this._nodedSegStrings=null;var N=arguments[0];this._pm=N,this._li=new ul,this._li.setPrecisionModel(N),this._scaleFactor=N.getScale()}}])}(),Ic=function(){function N(){l(this,N),N.constructor_.apply(this,arguments)}return i(N,[{key:"bufferFixedPrecision",value:function(h){var f=new gl(new Cr(new ra(1)),h.getScale()),w=new yo(this._bufParams);w.setWorkingPrecisionModel(h),w.setNoder(f),this._resultGeometry=w.buffer(this._argGeom,this._distance)}},{key:"bufferReducedPrecision",value:function(){if(arguments.length===0){for(var h=N.MAX_PRECISION_DIGITS;h>=0;h--){try{this.bufferReducedPrecision(h)}catch(re){if(!(re instanceof Jt))throw re;this._saveException=re}if(this._resultGeometry!==null)return null}throw this._saveException}if(arguments.length===1){var f=arguments[0],w=N.precisionScaleFactor(this._argGeom,this._distance,f),G=new ra(w);this.bufferFixedPrecision(G)}}},{key:"computeGeometry",value:function(){if(this.bufferOriginalPrecision(),this._resultGeometry!==null)return null;var h=this._argGeom.getFactory().getPrecisionModel();h.getType()===ra.FIXED?this.bufferFixedPrecision(h):this.bufferReducedPrecision()}},{key:"setQuadrantSegments",value:function(h){this._bufParams.setQuadrantSegments(h)}},{key:"bufferOriginalPrecision",value:function(){try{var h=new yo(this._bufParams);this._resultGeometry=h.buffer(this._argGeom,this._distance)}catch(f){if(!(f instanceof we))throw f;this._saveException=f}}},{key:"getResultGeometry",value:function(h){return this._distance=h,this.computeGeometry(),this._resultGeometry}},{key:"setEndCapStyle",value:function(h){this._bufParams.setEndCapStyle(h)}}],[{key:"constructor_",value:function(){if(this._argGeom=null,this._distance=null,this._bufParams=new X,this._resultGeometry=null,this._saveException=null,arguments.length===1){var h=arguments[0];this._argGeom=h}else if(arguments.length===2){var f=arguments[0],w=arguments[1];this._argGeom=f,this._bufParams=w}}},{key:"bufferOp",value:function(){if(arguments.length===2){var h=arguments[1];return new N(arguments[0]).getResultGeometry(h)}if(arguments.length===3){if(Number.isInteger(arguments[2])&&arguments[0]instanceof Fe&&typeof arguments[1]=="number"){var f=arguments[1],w=arguments[2],G=new N(arguments[0]);return G.setQuadrantSegments(w),G.getResultGeometry(f)}if(arguments[2]instanceof X&&arguments[0]instanceof Fe&&typeof arguments[1]=="number"){var re=arguments[1];return new N(arguments[0],arguments[2]).getResultGeometry(re)}}else if(arguments.length===4){var xe=arguments[1],Ae=arguments[2],tt=arguments[3],Nt=new N(arguments[0]);return Nt.setQuadrantSegments(Ae),Nt.setEndCapStyle(tt),Nt.getResultGeometry(xe)}}},{key:"precisionScaleFactor",value:function(h,f,w){var G=h.getEnvelopeInternal(),re=tn.max(Math.abs(G.getMaxX()),Math.abs(G.getMaxY()),Math.abs(G.getMinX()),Math.abs(G.getMinY()))+2*(f>0?f:0),xe=w-Math.trunc(Math.log(re)/Math.log(10)+1);return Math.pow(10,xe)}}])}();Ic.CAP_ROUND=X.CAP_ROUND,Ic.CAP_BUTT=X.CAP_FLAT,Ic.CAP_FLAT=X.CAP_FLAT,Ic.CAP_SQUARE=X.CAP_SQUARE,Ic.MAX_PRECISION_DIGITS=12;var yu=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],Qd=function(){return i(function N(h){l(this,N),this.geometryFactory=h||new qa},[{key:"read",value:function(N){var h,f=(h=typeof N=="string"?JSON.parse(N):N).type;if(!to[f])throw new Error("Unknown GeoJSON type: "+h.type);return yu.indexOf(f)!==-1?to[f].call(this,h.coordinates):f==="GeometryCollection"?to[f].call(this,h.geometries):to[f].call(this,h)}},{key:"write",value:function(N){var h=N.getGeometryType();if(!$o[h])throw new Error("Geometry is not supported");return $o[h].call(this,N)}}])}(),to={Feature:function(N){var h={};for(var f in N)h[f]=N[f];if(N.geometry){var w=N.geometry.type;if(!to[w])throw new Error("Unknown GeoJSON type: "+N.type);h.geometry=this.read(N.geometry)}return N.bbox&&(h.bbox=to.bbox.call(this,N.bbox)),h},FeatureCollection:function(N){var h={};if(N.features){h.features=[];for(var f=0;f<N.features.length;++f)h.features.push(this.read(N.features[f]))}return N.bbox&&(h.bbox=this.parse.bbox.call(this,N.bbox)),h},coordinates:function(N){for(var h=[],f=0;f<N.length;++f){var w=N[f];h.push(c(Re,I(w)))}return h},bbox:function(N){return this.geometryFactory.createLinearRing([new Re(N[0],N[1]),new Re(N[2],N[1]),new Re(N[2],N[3]),new Re(N[0],N[3]),new Re(N[0],N[1])])},Point:function(N){var h=c(Re,I(N));return this.geometryFactory.createPoint(h)},MultiPoint:function(N){for(var h=[],f=0;f<N.length;++f)h.push(to.Point.call(this,N[f]));return this.geometryFactory.createMultiPoint(h)},LineString:function(N){var h=to.coordinates.call(this,N);return this.geometryFactory.createLineString(h)},MultiLineString:function(N){for(var h=[],f=0;f<N.length;++f)h.push(to.LineString.call(this,N[f]));return this.geometryFactory.createMultiLineString(h)},Polygon:function(N){for(var h=to.coordinates.call(this,N[0]),f=this.geometryFactory.createLinearRing(h),w=[],G=1;G<N.length;++G){var re=N[G],xe=to.coordinates.call(this,re),Ae=this.geometryFactory.createLinearRing(xe);w.push(Ae)}return this.geometryFactory.createPolygon(f,w)},MultiPolygon:function(N){for(var h=[],f=0;f<N.length;++f){var w=N[f];h.push(to.Polygon.call(this,w))}return this.geometryFactory.createMultiPolygon(h)},GeometryCollection:function(N){for(var h=[],f=0;f<N.length;++f){var w=N[f];h.push(this.read(w))}return this.geometryFactory.createGeometryCollection(h)}},$o={coordinate:function(N){var h=[N.x,N.y];return N.z&&h.push(N.z),N.m&&h.push(N.m),h},Point:function(N){return{type:"Point",coordinates:$o.coordinate.call(this,N.getCoordinate())}},MultiPoint:function(N){for(var h=[],f=0;f<N._geometries.length;++f){var w=N._geometries[f],G=$o.Point.call(this,w);h.push(G.coordinates)}return{type:"MultiPoint",coordinates:h}},LineString:function(N){for(var h=[],f=N.getCoordinates(),w=0;w<f.length;++w){var G=f[w];h.push($o.coordinate.call(this,G))}return{type:"LineString",coordinates:h}},MultiLineString:function(N){for(var h=[],f=0;f<N._geometries.length;++f){var w=N._geometries[f],G=$o.LineString.call(this,w);h.push(G.coordinates)}return{type:"MultiLineString",coordinates:h}},Polygon:function(N){var h=[],f=$o.LineString.call(this,N._shell);h.push(f.coordinates);for(var w=0;w<N._holes.length;++w){var G=N._holes[w],re=$o.LineString.call(this,G);h.push(re.coordinates)}return{type:"Polygon",coordinates:h}},MultiPolygon:function(N){for(var h=[],f=0;f<N._geometries.length;++f){var w=N._geometries[f],G=$o.Polygon.call(this,w);h.push(G.coordinates)}return{type:"MultiPolygon",coordinates:h}},GeometryCollection:function(N){for(var h=[],f=0;f<N._geometries.length;++f){var w=N._geometries[f],G=w.getGeometryType();h.push($o[G].call(this,w))}return{type:"GeometryCollection",geometries:h}}};return{BufferOp:Ic,GeoJSONReader:function(){return i(function N(h){l(this,N),this.parser=new Qd(h||new qa)},[{key:"read",value:function(N){return this.parser.read(N)}}])}(),GeoJSONWriter:function(){return i(function N(){l(this,N),this.parser=new Qd(this.geometryFactory)},[{key:"write",value:function(N){return this.parser.write(N)}}])}()}})})(BP);var EF=BP.exports;
vendor: 4,442 bytes, line 761
761const PF=w1(EF);function $f(){return new c0}function c0(){this.reset()}c0.prototype={constructor:c0,reset:function(){this.s=this.t=0},add:function(t){Ak(X_,t,this.t),Ak(this,X_.s,this.s),this.s?this.t+=X_.t:this.s=X_.t},valueOf:function(){return this.s}};var X_=new c0;function Ak(t,s,n){var a=t.s=s+n,l=a-s,c=a-l;t.t=s-c+(n-l)}var Ro=1e-6,Vi=Math.PI,om=Vi/2,Dk=Vi/4,_m=Vi*2,pf=180/Vi,lh=Vi/180,Yc=Math.abs,TF=Math.atan,Sg=Math.atan2,vl=Math.cos,bl=Math.sin,Vg=Math.sqrt;function $P(t){return t>1?0:t<-1?Vi:Math.acos(t)}function yp(t){return t>1?om:t<-1?-om:Math.asin(t)}function xx(){}function d0(t,s){t&&Fk.hasOwnProperty(t.type)&&Fk[t.type](t,s)}var Rk={Feature:function(t,s){d0(t.geometry,s)},FeatureCollection:function(t,s){for(var n=t.features,a=-1,l=n.length;++a<l;)d0(n[a].geometry,s)}},Fk={Sphere:function(t,s){s.sphere()},Point:function(t,s){t=t.coordinates,s.point(t[0],t[1],t[2])},MultiPoint:function(t,s){for(var n=t.coordinates,a=-1,l=n.length;++a<l;)t=n[a],s.point(t[0],t[1],t[2])},LineString:function(t,s){s1(t.coordinates,s,0)},MultiLineString:function(t,s){for(var n=t.coordinates,a=-1,l=n.length;++a<l;)s1(n[a],s,0)},Polygon:function(t,s){zk(t.coordinates,s)},MultiPolygon:function(t,s){for(var n=t.coordinates,a=-1,l=n.length;++a<l;)zk(n[a],s)},GeometryCollection:function(t,s){for(var n=t.geometries,a=-1,l=n.length;++a<l;)d0(n[a],s)}};function s1(t,s,n){var a=-1,l=t.length-n,c;for(s.lineStart();++a<l;)c=t[a],s.point(c[0],c[1],c[2]);s.lineEnd()}function zk(t,s){var n=-1,a=t.length;for(s.polygonStart();++n<a;)s1(t[n],s,1);s.polygonEnd()}function LF(t,s){t&&Rk.hasOwnProperty(t.type)?Rk[t.type](t,s):d0(t,s)}$f();$f();function n1(t){return[Sg(t[1],t[0]),yp(t[2])]}function Eg(t){var s=t[0],n=t[1],a=vl(n);return[a*vl(s),a*bl(s),bl(n)]}function K_(t,s){return t[0]*s[0]+t[1]*s[1]+t[2]*s[2]}function u0(t,s){return[t[1]*s[2]-t[2]*s[1],t[2]*s[0]-t[0]*s[2],t[0]*s[1]-t[1]*s[0]]}function Vv(t,s){t[0]+=s[0],t[1]+=s[1],t[2]+=s[2]}function J_(t,s){return[t[0]*s,t[1]*s,t[2]*s]}function a1(t){var s=Vg(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=s,t[1]/=s,t[2]/=s}$f();function VP(t,s){function n(a,l){return a=t(a,l),s(a[0],a[1])}return t.invert&&s.invert&&(n.invert=function(a,l){return a=s.invert(a,l),a&&t.invert(a[0],a[1])}),n}function r1(t,s){return[t>Vi?t-_m:t<-Vi?t+_m:t,s]}r1.invert=r1;function MF(t,s,n){return(t%=_m)?s||n?VP(Bk(t),$k(s,n)):Bk(t):s||n?$k(s,n):r1}function Ok(t){return function(s,n){return s+=t,[s>Vi?s-_m:s<-Vi?s+_m:s,n]}}function Bk(t){var s=Ok(t);return s.invert=Ok(-t),s}function $k(t,s){var n=vl(t),a=bl(t),l=vl(s),c=bl(s);function u(i,_){var j=vl(_),y=vl(i)*j,x=bl(i)*j,v=bl(_),C=v*n+y*a;return[Sg(x*l-C*c,y*n-v*a),yp(C*l+x*c)]}return u.invert=function(i,_){var j=vl(_),y=vl(i)*j,x=bl(i)*j,v=bl(_),C=v*l-x*c;return[Sg(x*l+v*c,y*n+C*a),yp(C*n-y*a)]},u}function IF(t,s,n,a,l,c){if(n){var u=vl(s),i=bl(s),_=a*n;l==null?(l=s+a*_m,c=s-_/2):(l=Vk(u,l),c=Vk(u,c),(a>0?l<c:l>c)&&(l+=a*_m));for(var j,y=l;a>0?y>c:y<c;y-=_)j=n1([u,-i*vl(y),-i*bl(y)]),t.point(j[0],j[1])}}function Vk(t,s){s=Eg(s),s[0]-=t,a1(s);var n=$P(-s[1]);return((-s[2]<0?-n:n)+_m-Ro)%_m}function qP(){var t=[],s;return{point:function(n,a){s.push([n,a])},lineStart:function(){t.push(s=[])},lineEnd:xx,rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))},result:function(){var n=t;return t=[],s=null,n}}}function AF(t,s,n,a,l,c){var u=t[0],i=t[1],_=s[0],j=s[1],y=0,x=1,v=_-u,C=j-i,P;if(P=n-u,!(!v&&P>0)){if(P/=v,v<0){if(P<y)return;P<x&&(x=P)}else if(v>0){if(P>x)return;P>y&&(y=P)}if(P=l-u,!(!v&&P<0)){if(P/=v,v<0){if(P>x)return;P>y&&(y=P)}else if(v>0){if(P<y)return;P<x&&(x=P)}if(P=a-i,!(!C&&P>0)){if(P/=C,C<0){if(P<y)return;P<x&&(x=P)}else if(C>0){if(P>x)return;P>y&&(y=P)}if(P=c-i,!(!C&&P<0)){if(P/=C,C<0){if(P>x)return;P>y&&(y=P)}else if(C>0){if(P<y)return;P<x&&(x=P)}return y>0&&(t[0]=u+y*v,t[1]=i+y*C),x<1&&(s[0]=u+x*v,s[1]=i+x*C),!0}}}}}function Ey(t,s){return Yc(t[0]-s[0])<Ro&&Yc(t[1]-s[1])<Ro}function Q_(t,s,n,a){this.x=t,this.z=s,this.o=n,this.e=a,this.v=!1,this.n=this.p=null}function GP(t,s,n,a,l){var c=[],u=[],i,_;if(t.forEach(function(P){if(!((I=P.length-1)<=0)){var I,z=P[0],F=P[I],D;if(Ey(z,F)){for(l.lineStart(),i=0;i<I;++i)l.point((z=P[i])[0],z[1]);l.lineEnd();return}c.push(D=new Q_(z,P,null,!0)),u.push(D.o=new Q_(z,null,D,!1)),c.push(D=new Q_(F,P,null,!1)),u.push(D.o=new Q_(F,null,D,!0))}}),!!c.length){for(u.sort(s),qk(c),qk(u),i=0,_=u.length;i<_;++i)u[i].e=n=!n;for(var j=c[0],y,x;;){for(var v=j,C=!0;v.v;
vendor: 9,700 bytes, line 761
761)if((v=v.n)===j)return;y=v.z,l.lineStart();do{if(v.v=v.o.v=!0,v.e){if(C)for(i=0,_=y.length;i<_;++i)l.point((x=y[i])[0],x[1]);else a(v.x,v.n.x,1,l);v=v.n}else{if(C)for(y=v.p.z,i=y.length-1;i>=0;--i)l.point((x=y[i])[0],x[1]);else a(v.x,v.p.x,-1,l);v=v.p}v=v.o,y=v.z,C=!C}while(!v.v);l.lineEnd()}}}function qk(t){if(s=t.length){for(var s,n=0,a=t[0],l;++n<s;)a.n=l=t[n],l.p=a,a=l;a.n=l=t[0],l.p=a}}function HP(t,s){return t<s?-1:t>s?1:t>=s?0:NaN}function DF(t){return t.length===1&&(t=RF(t)),{left:function(s,n,a,l){for(a==null&&(a=0),l==null&&(l=s.length);a<l;){var c=a+l>>>1;t(s[c],n)<0?a=c+1:l=c}return a},right:function(s,n,a,l){for(a==null&&(a=0),l==null&&(l=s.length);a<l;){var c=a+l>>>1;t(s[c],n)>0?l=c:a=c+1}return a}}}function RF(t){return function(s,n){return HP(t(s),n)}}DF(HP);function ZP(t){for(var s=t.length,n,a=-1,l=0,c,u;++a<s;)l+=t[a].length;for(c=new Array(l);--s>=0;)for(u=t[s],n=u.length;--n>=0;)c[--l]=u[n];return c}var _x=1e9,U_=-_x;function FF(t,s,n,a){function l(j,y){return t<=j&&j<=n&&s<=y&&y<=a}function c(j,y,x,v){var C=0,P=0;if(j==null||(C=u(j,x))!==(P=u(y,x))||_(j,y)<0^x>0)do v.point(C===0||C===3?t:n,C>1?a:s);while((C=(C+x+4)%4)!==P);else v.point(y[0],y[1])}function u(j,y){return Yc(j[0]-t)<Ro?y>0?0:3:Yc(j[0]-n)<Ro?y>0?2:1:Yc(j[1]-s)<Ro?y>0?1:0:y>0?3:2}function i(j,y){return _(j.x,y.x)}function _(j,y){var x=u(j,1),v=u(y,1);return x!==v?x-v:x===0?y[1]-j[1]:x===1?j[0]-y[0]:x===2?j[1]-y[1]:y[0]-j[0]}return function(j){var y=j,x=qP(),v,C,P,I,z,F,D,X,K,te,J,H={point:O,lineStart:Z,lineEnd:oe,polygonStart:W,polygonEnd:Q};function O(ae,ie){l(ae,ie)&&y.point(ae,ie)}function q(){for(var ae=0,ie=0,de=C.length;ie<de;++ie)for(var ge=C[ie],We=1,Ee=ge.length,ve=ge[0],we,Ze,ke=ve[0],ze=ve[1];We<Ee;++We)we=ke,Ze=ze,ve=ge[We],ke=ve[0],ze=ve[1],Ze<=a?ze>a&&(ke-we)*(a-Ze)>(ze-Ze)*(t-we)&&++ae:ze<=a&&(ke-we)*(a-Ze)<(ze-Ze)*(t-we)&&--ae;return ae}function W(){y=x,v=[],C=[],J=!0}function Q(){var ae=q(),ie=J&&ae,de=(v=ZP(v)).length;(ie||de)&&(j.polygonStart(),ie&&(j.lineStart(),c(null,null,1,j),j.lineEnd()),de&&GP(v,i,ae,c,j),j.polygonEnd()),y=j,v=C=P=null}function Z(){H.point=ce,C&&C.push(P=[]),te=!0,K=!1,D=X=NaN}function oe(){v&&(ce(I,z),F&&K&&x.rejoin(),v.push(x.result())),H.point=O,K&&y.lineEnd()}function ce(ae,ie){var de=l(ae,ie);if(C&&P.push([ae,ie]),te)I=ae,z=ie,F=de,te=!1,de&&(y.lineStart(),y.point(ae,ie));else if(de&&K)y.point(ae,ie);else{var ge=[D=Math.max(U_,Math.min(_x,D)),X=Math.max(U_,Math.min(_x,X))],We=[ae=Math.max(U_,Math.min(_x,ae)),ie=Math.max(U_,Math.min(_x,ie))];AF(ge,We,t,s,n,a)?(K||(y.lineStart(),y.point(ge[0],ge[1])),y.point(We[0],We[1]),de||y.lineEnd(),J=!1):de&&(y.lineStart(),y.point(ae,ie),J=!1)}D=ae,X=ie,K=de}return H}}var qv=$f();function zF(t,s){var n=s[0],a=s[1],l=[bl(n),-vl(n),0],c=0,u=0;qv.reset();for(var i=0,_=t.length;i<_;++i)if(y=(j=t[i]).length)for(var j,y,x=j[y-1],v=x[0],C=x[1]/2+Dk,P=bl(C),I=vl(C),z=0;z<y;++z,v=D,P=K,I=te,x=F){var F=j[z],D=F[0],X=F[1]/2+Dk,K=bl(X),te=vl(X),J=D-v,H=J>=0?1:-1,O=H*J,q=O>Vi,W=P*K;if(qv.add(Sg(W*H*bl(O),I*te+W*vl(O))),c+=q?J+H*_m:J,q^v>=n^D>=n){var Q=u0(Eg(x),Eg(F));a1(Q);var Z=u0(l,Q);a1(Z);var oe=(q^J>=0?-1:1)*yp(Z[2]);(a>oe||a===oe&&(Q[0]||Q[1]))&&(u+=q^J>=0?1:-1)}}return(c<-Ro||c<Ro&&qv<-Ro)^u&1}$f();function Gk(t){return t}$f();$f();var Pg=1/0,h0=Pg,Yx=-Pg,m0=Yx,Hk={point:OF,lineStart:xx,lineEnd:xx,polygonStart:xx,polygonEnd:xx,result:function(){var t=[[Pg,h0],[Yx,m0]];return Yx=m0=-(h0=Pg=1/0),t}};function OF(t,s){t<Pg&&(Pg=t),t>Yx&&(Yx=t),s<h0&&(h0=s),s>m0&&(m0=s)}$f();function WP(t,s,n,a){return function(l,c){var u=s(c),i=l.invert(a[0],a[1]),_=qP(),j=s(_),y=!1,x,v,C,P={point:I,lineStart:F,lineEnd:D,polygonStart:function(){P.point=X,P.lineStart=K,P.lineEnd=te,v=[],x=[]},polygonEnd:function(){P.point=I,P.lineStart=F,P.lineEnd=D,v=ZP(v);var J=zF(x,i);v.length?(y||(c.polygonStart(),y=!0),GP(v,$F,J,n,c)):J&&(y||(c.polygonStart(),y=!0),c.lineStart(),n(null,null,1,c),c.lineEnd()),y&&(c.polygonEnd(),y=!1),v=x=null},sphere:function(){c.polygonStart(),c.lineStart(),n(null,null,1,c),c.lineEnd(),c.polygonEnd()}};function I(J,H){var O=l(J,H);t(J=O[0],H=O[1])&&c.point(J,H)}function z(J,H){var O=l(J,H);u.point(O[0],O[1])}function F(){P.point=z,u.lineStart()}function D(){P.point=I,u.lineEnd()}function X(J,H){C.push([J,H]);var O=l(J,H);j.point(O[0],O[1])}function K(){j.lineStart(),C=[]}function te(){X(C[0][0],C[0][1]),j.lineEnd();var J=j.clean(),H=_.result(),O,q=H.length,W,Q,Z;if(C.pop(),x.push(C),C=null,!!q){if(J&1){if(Q=H[0],(W=Q.length-1)>0){for(y||(c.polygonStart(),y=!0),c.lineStart(),O=0;O<W;++O)c.point((Z=Q[O])[0],Z[1]);c.lineEnd()}return}q>1&&J&2&&H.push(H.pop().concat(H.shift())),v.push(H.filter(BF))}}return P}}function BF(t){return t.length>1}function $F(t,s){return((t=t.x)[0]<0?t[1]-om-Ro:om-t[1])-((s=s.x)[0]<0?s[1]-om-Ro:om-s[1])}const Zk=WP(function(){return!0},VF,GF,[-Vi,-om]);function VF(t){var s=NaN,n=NaN,a=NaN,l;return{lineStart:function(){t.lineStart(),l=1},point:function(c,u){var i=c>0?Vi:-Vi,_=Yc(c-s);Yc(_-Vi)<Ro?(t.point(s,n=(n+u)/2>0?om:-om),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(i,n),t.point(c,n),l=0):a!==i&&_>=Vi&&(Yc(s-a)<Ro&&(s-=a*Ro),Yc(c-i)<Ro&&(c-=i*Ro),n=qF(s,n,c,u),t.point(a,n),t.lineEnd(),t.lineStart(),t.point(i,n),l=0),t.point(s=c,n=u),a=i},lineEnd:function(){t.lineEnd(),s=n=NaN},clean:function(){return 2-l}}}function qF(t,s,n,a){var l,c,u=bl(t-n);return Yc(u)>Ro?TF((bl(s)*(c=vl(a))*bl(n)-bl(a)*(l=vl(s))*bl(t))/(l*c*u)):(s+a)/2}function GF(t,s,n,a){var l;if(t==null)l=n*om,a.point(-Vi,l),a.point(0,l),a.point(Vi,l),a.point(Vi,0),a.point(Vi,-l),a.point(0,-l),a.point(-Vi,-l),a.point(-Vi,0),a.point(-Vi,l);else if(Yc(t[0]-s[0])>Ro){var c=t[0]<s[0]?Vi:-Vi;l=n*c/2,a.point(-c,l),a.point(0,l),a.point(c,l)}else a.point(s[0],s[1])}function HF(t,s){var n=vl(t),a=n>0,l=Yc(n)>Ro;function c(y,x,v,C){IF(C,t,s,v,y,x)}function u(y,x){return vl(y)*vl(x)>n}function i(y){var x,v,C,P,I;return{lineStart:function(){P=C=!1,I=1},point:function(z,F){var D=[z,F],X,K=u(z,F),te=a?K?0:j(z,F):K?j(z+(z<0?Vi:-Vi),F):0;if(!x&&(P=C=K)&&y.lineStart(),K!==C&&(X=_(x,D),(!X||Ey(x,X)||Ey(D,X))&&(D[0]+=Ro,D[1]+=Ro,K=u(D[0],D[1]))),K!==C)I=0,K?(y.lineStart(),X=_(D,x),y.point(X[0],X[1])):(X=_(x,D),y.point(X[0],X[1]),y.lineEnd()),x=X;else if(l&&x&&a^K){var J;!(te&v)&&(J=_(D,x,!0))&&(I=0,a?(y.lineStart(),y.point(J[0][0],J[0][1]),y.point(J[1][0],J[1][1]),y.lineEnd()):(y.point(J[1][0],J[1][1]),y.lineEnd(),y.lineStart(),y.point(J[0][0],J[0][1])))}K&&(!x||!Ey(x,D))&&y.point(D[0],D[1]),x=D,C=K,v=te},lineEnd:function(){C&&y.lineEnd(),x=null},clean:function(){return I|(P&&C)<<1}}}function _(y,x,v){var C=Eg(y),P=Eg(x),I=[1,0,0],z=u0(C,P),F=K_(z,z),D=z[0],X=F-D*D;if(!X)return!v&&y;var K=n*F/X,te=-n*D/X,J=u0(I,z),H=J_(I,K),O=J_(z,te);Vv(H,O);var q=J,W=K_(H,q),Q=K_(q,q),Z=W*W-Q*(K_(H,H)-1);if(!(Z<0)){var oe=Vg(Z),ce=J_(q,(-W-oe)/Q);if(Vv(ce,H),ce=n1(ce),!v)return ce;var ae=y[0],ie=x[0],de=y[1],ge=x[1],We;ie<ae&&(We=ae,ae=ie,ie=We);var Ee=ie-ae,ve=Yc(Ee-Vi)<Ro,we=ve||Ee<Ro;if(!ve&&ge<de&&(We=de,de=ge,ge=We),we?ve?de+ge>0^ce[1]<(Yc(ce[0]-ae)<Ro?de:ge):de<=ce[1]&&ce[1]<=ge:Ee>Vi^(ae<=ce[0]&&ce[0]<=ie)){var Ze=J_(q,(-W+oe)/Q);return Vv(Ze,H),[ce,n1(Ze)]}}}function j(y,x){var v=a?t:Vi-t,C=0;return y<-v?C|=1:y>v&&(C|=2),x<-v?C|=4:x>v&&(C|=8),C}return WP(u,i,c,a?[0,-t]:[-Vi,t-Vi])}function YP(t){return function(s){var n=new i1;for(var a in t)n[a]=t[a];return n.stream=s,n}}function i1(){}i1.prototype={constructor:i1,point:function(t,s){this.stream.point(t,s)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function XP(t,s,n){var a=s[1][0]-s[0][0],l=s[1][1]-s[0][1],c=t.clipExtent&&t.clipExtent();t.scale(150).translate([0,0]),c!=null&&t.clipExtent(null),LF(n,t.stream(Hk));var u=Hk.result(),i=Math.min(a/(u[1][0]-u[0][0]),l/(u[1][1]-u[0][1])),_=+s[0][0]+(a-i*(u[1][0]+u[0][0]))/2,j=+s[0][1]+(l-i*(u[1][1]+u[0][1]))/2;return c!=null&&t.clipExtent(c),t.scale(i*150).translate([_,j])}function ZF(t,s,n){return XP(t,[[0,0],s],n)}var Wk=16,WF=vl(30*lh);function Yk(t,s){return+s?XF(t,s):YF(t)}function YF(t){return YP({point:function(s,n){s=t(s,n),this.stream.point(s[0],s[1])}})}function XF(t,s){function n(a,l,c,u,i,_,j,y,x,v,C,P,I,z){var F=j-a,D=y-l,X=F*F+D*D;if(X>4*s&&I--){var K=u+v,te=i+C,J=_+P,H=Vg(K*K+te*te+J*J),O=yp(J/=H),q=Yc(Yc(J)-1)<Ro||Yc(c-x)<Ro?(c+x)/2:Sg(te,K),W=t(q,O),Q=W[0],Z=W[1],oe=Q-a,ce=Z-l,ae=D*oe-F*ce;(ae*ae/X>s||Yc((F*oe+D*ce)/X-.5)>.3||u*v+i*C+_*P<WF)&&(n(a,l,c,u,i,_,Q,Z,q,K/=H,te/=H,J,I,z),z.point(Q,Z),n(Q,Z,q,K,te,J,j,y,x,v,C,P,I,z))}}return function(a){var l,c,u,i,_,j,y,x,v,C,P,I,z={point:F,lineStart:D,lineEnd:K,polygonStart:function(){a.polygonStart(),z.lineStart=te},polygonEnd:function(){a.polygonEnd(),z.lineStart=D}};function F(O,q){O=t(O,q),a.point(O[0],O[1])}function D(){x=NaN,z.point=X,a.lineStart()}function X(O,q){var W=Eg([O,q]),Q=t(O,q);n(x,v,y,C,P,I,x=Q[0],v=Q[1],y=O,C=W[0],P=W[1],I=W[2],Wk,a),a.point(x,v)}function K(){z.point=F,a.lineEnd()}function te(){D(),z.point=J,z.lineEnd=H}function J(O,q){X(l=O,q),c=x,u=v,i=C,_=P,j=I,z.point=X}function H(){n(x,v,y,C,P,I,c,u,l,i,_,j,Wk,a),z.lineEnd=K,K()}return z}}var KF=YP({point:function(t,s){this.stream.point(t*lh,s*lh)}});function JF(t){return QF(function(){return t})()}function QF(t){var s,n=150,a=480,l=250,c,u,i=0,_=0,j=0,y=0,x=0,v,C,P=null,I=Zk,z=null,F,D,X,K=Gk,te=.5,J=Yk(Q,te),H,O;function q(ce){return ce=C(ce[0]*lh,ce[1]*lh),[ce[0]*n+c,u-ce[1]*n]}function W(ce){return ce=C.invert((ce[0]-c)/n,(u-ce[1])/n),ce&&[ce[0]*pf,ce[1]*pf]}function Q(ce,ae){return ce=s(ce,ae),[ce[0]*n+c,u-ce[1]*n]}q.stream=function(ce){return H&&O===ce?H:H=KF(I(v,J(K(O=ce))))}
761,q.clipAngle=function(ce){return arguments.length?(I=+ce?HF(P=ce*lh,6*lh):(P=null,Zk),oe()):P*pf},q.clipExtent=function(ce){return arguments.length?(K=ce==null?(z=F=D=X=null,Gk):FF(z=+ce[0][0],F=+ce[0][1],D=+ce[1][0],X=+ce[1][1]),oe()):z==null?null:[[z,F],[D,X]]},q.scale=function(ce){return arguments.length?(n=+ce,Z()):n},q.translate=function(ce){return arguments.length?(a=+ce[0],l=+ce[1],Z()):[a,l]},q.center=function(ce){return arguments.length?(i=ce[0]%360*lh,_=ce[1]%360*lh,Z()):[i*pf,_*pf]},q.rotate=function(ce){return arguments.length?(j=ce[0]%360*lh,y=ce[1]%360*lh,x=ce.length>2?ce[2]%360*lh:0,Z()):[j*pf,y*pf,x*pf]},q.precision=function(ce){return arguments.length?(J=Yk(Q,te=ce*ce),oe()):Vg(te)},q.fitExtent=function(ce,ae){return XP(q,ce,ae)},q.fitSize=function(ce,ae){return ZF(q,ce,ae)};function Z(){C=VP(v=MF(j,y,x),s);var ce=s(i,_);return c=a-ce[0]*n,u=l+ce[1]*n,oe()}function oe(){return H=O=null,q}return function(){return s=t.apply(this,arguments),q.invert=s.invert&&W,Z()}}function KP(t){return function(s,n){var a=vl(s),l=vl(n),c=t(a*l);return[c*l*bl(s),c*bl(n)]}}function JP(t){return function(s,n){var a=Vg(s*s+n*n),l=t(a),c=bl(l),u=vl(l);return[Sg(s*c,a*u),yp(a&&n*c/a)]}}var UF=KP(function(t){return Vg(2/(1+t))});UF.invert=JP(function(t){return 2*yp(t/2)});var QP=KP(function(t){return(t=$P(t))&&t/bl(t)});QP.invert=JP(function(t){return t});function ez(){return JF(QP).scale(79.4188).clipAngle(180-.001)}function Xk(t,s){return[t,s]}Xk.invert=Xk;var{BufferOp:tz,GeoJSONReader:sz,GeoJSONWriter:nz}=PF;function az(t,s,n){n=n||{};var a=n.units||"kilometers",l=n.steps||8;if(!t)throw new Error("geojson is required");if(typeof n!="object")throw new Error("options must be an object");if(typeof l!="number")throw new Error("steps must be an number");if(s===void 0)throw new Error("radius is required");if(l<=0)throw new Error("steps must be greater than 0");var c=[];switch(t.type){case"GeometryCollection":return r_(t,function(u){var i=Py(u,s,a,l);i&&c.push(i)}),Un(c);case"FeatureCollection":return vN(t,function(u){var i=Py(u,s,a,l);i&&vN(i,function(_){_&&c.push(_)})}),Un(c)}return Py(t,s,a,l)}function Py(t,s,n,a){var l=t.properties||{},c=t.type==="Feature"?t.geometry:t;if(c.type==="GeometryCollection"){var u=[];return r_(t,function(I){var z=Py(I,s,n,a);z&&u.push(z)}),Un(u)}var i=rz(c),_={type:c.type,coordinates:eT(c.coordinates,i)},j=new sz,y=j.read(_),x=DS(X3(s,n),"meters"),v=tz.bufferOp(y,x,a),C=new nz;if(v=C.write(v),!UP(v.coordinates)){var P={type:v.type,coordinates:tT(v.coordinates,i)};return qm(P,l)}}function UP(t){return Array.isArray(t[0])?UP(t[0]):isNaN(t[0])}function eT(t,s){return typeof t[0]!="object"?s(t):t.map(function(n){return eT(n,s)})}function tT(t,s){return typeof t[0]!="object"?s.invert(t):t.map(function(n){return tT(n,s)})}function rz(t){var s=SF(t).geometry.coordinates,n=[-s[0],-s[1]];return ez().rotate(n).scale(Td)}var dl=az;const sT={concrete:{fillColor:"#d1d5db",strokeColor:"#9ca3af",fillOpacity:.6},pavers:{fillColor:"#a8a29e",strokeColor:"#78716c",fillOpacity:.6}
761,brick:{fillColor:"#b45309",strokeColor:"#92400e",fillOpacity:.5},turf:{fillColor:"#86efac",strokeColor:"#22c55e",fillOpacity:.5}},Ty={sidewalk:{material:"concrete",defaultWidth:6},patio:{material:"pavers",defaultWidth:12},plaza:{material:"concrete",defaultWidth:20},service_area:{material:"concrete",defaultWidth:10}};function Tj(t){const s=t.map(n=>[n.lng,n.lat]);return s.length>0&&(s[0][0]!==s[s.length-1][0]||s[0][1]!==s[s.length-1][1])&&s.push([...s[0]]),Xn([s])}function fg(t){return t.geometry.coordinates[0].slice(0,-1).map(a=>({lat:a[1],lng:a[0]}))}function nT(t,s){if(!t||t.length<3||s<=0)return null;try{const n=Tj(t),a=s*3048e-7,l=dl(n,a,{units:"kilometers"});return l?fg(l):null}catch(n){return console.error("[BuildingBuffer] Error generating buffer:",n),null}}function iz(t,s){if(!t||t.length<3||s<=0)return null;try{const n=Tj(t),a=s*3048e-7,l=dl(n,a,{units:"kilometers"});if(!l)return null;const c=pd(Un([l,n]));return c?c.geometry.type==="Polygon"?[fg(c)]:c.geometry.type==="MultiPolygon"?c.geometry.coordinates.map(u=>{const i=Xn(u);return fg(i)}):null:null}catch(n){return console.error("[BuildingBuffer] Error generating buffer ring:",n),null}}function aT(t,s,n=6){if(!t||t.length<3)return[];const a=[];for(const[l,c]of Object.entries(s)){const u=parseInt(l,10);if(isNaN(u)||u<0||u>=t.length)continue;const i=c.widthFt??n;if(i<=0)continue;const _=t[u],j=t[(u+1)%t.length],y=Math.max(0,Math.min(100,c.startPercent??0))/100,x=Math.max(0,Math.min(100,c.endPercent??100))/100,v={lat:_.lat+(j.lat-_.lat)*y,lng:_.lng+(j.lng-_.lng)*y},C={lat:_.lat+(j.lat-_.lat)*x,lng:_.lng+(j.lng-_.lng)*x},P=us([v.lng,v.lat]),I=us([C.lng,C.lat]),z=us([_.lng,_.lat]),F=us([j.lng,j.lat]),X=(Or(z,F)-90+360)%360,K=On(P,i,X,{units:"feet"}),te=On(I,i,X,{units:"feet"});a.push({geometry:[{lat:v.lat,lng:v.lng},{lat:C.lat,lng:C.lng},{lat:te.geometry.coordinates[1],lng:te.geometry.coordinates[0]},{lat:K.geometry.coordinates[1],lng:K.geometry.coordinates[0]}],edgeIndex:u,config:c})}return a}function wf(t,s){return!s||s<=0?t:nT(t,s)}function f0(t){if(t.length===0)return[];if(t.length===1)return t;try{const s=t.filter(a=>a&&a.length>=3).map(a=>Tj(a));if(s.length===0)return[];if(s.length===1)return[fg(s[0])];let n=s[0];for(let a=1;a<s.length;a++){const l=aj(Un([n,s[a]]));l&&(n=l)}return n.geometry.type==="MultiPolygon"?n.geometry.coordinates.map(a=>{const l=Xn(a);return fg(l)}):[fg(n)]}catch(s){return console.error("[BuildingBuffer] Error merging exclusion zones:",s),t}}function oz(t){return sT[t||"concrete"]}const Kk=Object.freeze(Object.defineProperty({__proto__:null,BUFFER_MATERIAL_STYLES:sT,BUFFER_TYPE_DEFAULTS:Ty,generateBufferRing:iz,generateBuildingBuffer:nT,generatePerEdgeBuffers:aT,getBufferStyle:oz,getBuildingWithBuffer:wf,mergeExclusionZones:f0},Symbol.toStringTag,{value:"Module"})),lz=(t,s)=>{const n=t[0],a=t[1],l=s[0],c=s[1],u=(a+c)/2,i=111320,_=111320*Math.cos(u*Math.PI/180),j=(l-n)*_,y=(c-a)*i;return Math.sqrt(j*j+y*y)},Gv=(t,s)=>Math.atan2(Math.sin(t-s),Math.cos(t-s)),cz=(t,s,n,a)=>{const l={lat:(t.start.lat+t.end.lat)/2,lng:(t.start.lng+t.end.lng)/2},c=(t.end.lng-t.start.lng)*n,u=(t.end.lat-t.start.lat)*a,i=Math.sqrt(c*c+u*u)||1,_=-u/i,j=c/i,y=(l.lng-s.lng)*n,x=(l.lat-s.lat)*a,v=10,C=Math.sqrt((y+_*v)**2+(x+j*v)**2),P=Math.sqrt((y-_*v)**2+(x-j*v)**2),I=C<P?1:-1;return{x:-_*I,y:-j*I}},pg=(t,s)=>{if(t.length<3)return{frontLine:null,rearLine:null,sideLinesLeft:null,sideLinesRight:null,innerPolygon:null,combinedSetbackZone:null,frontBuffer:null,rearBuffer:null,sideLeftBuffer:null,sideRightBuffer:null,error:"Polygon must have at least 3 points"};try{const n=t.map(v=>[v.lng,v.lat]);n.push(n[0]);const a=Xn([n]),l=s.front_ft||0,c=s.rear_ft||0,u=s.side1_ft??s.side_ft??0,i=s.side2_ft??s.side_ft??0;if(!(l>0||c>0||u>0||i>0))return{frontLine:null,rearLine:null,sideLinesLeft:null,sideLinesRight:null,innerPolygon:null,combinedSetbackZone:null,frontBuffer:null,rearBuffer:null,sideLeftBuffer:null,sideRightBuffer:null};const j=dz(t,s);let y=null;if(j&&j.length>0){const v=j[0],C=v.length>=2&&v[0][0]===v[v.length-1][0]&&v[0][1]===v[v.length-1][1]?v:[...v,v[0]];y=[n,C]}const x=fz(t,s);return{frontLine:null,rearLine:null,sideLinesLeft:null,sideLinesRight:null,innerPolygon:j,combinedSetbackZ
761one:y,...x}}catch(n){return console.error("Error calculating setbacks:",n),{frontLine:null,rearLine:null,sideLinesLeft:null,sideLinesRight:null,innerPolygon:null,combinedSetbackZone:null,frontBuffer:null,rearBuffer:null,sideLeftBuffer:null,sideRightBuffer:null,error:"Failed to calculate setbacks"}}},dz=(t,s)=>{if(t.length<3)return null;const n=(()=>{const y=[...t];if(y.length>=2){const x=y[0],v=y[y.length-1];x.lat===v.lat&&x.lng===v.lng&&y.pop()}return y})();if(n.length<3)return null;const a=[];for(let y=0;y<n.length;y++){const x=n[y],v=n[(y+1)%n.length],C=Math.sqrt(Math.pow((v.lat-x.lat)*111320,2)+Math.pow((v.lng-x.lng)*111320*Math.cos(x.lat*Math.PI/180),2));a.push({start:x,end:v,length:C,index:y})}const l=hz(a,s,n);if(n.length>6){const y=uz(n,a,l);if(y)return y}const u=Math.max(s.front_ft||0,s.rear_ft||0,s.side1_ft??s.side_ft??0,s.side2_ft??s.side_ft??0)*.3048,i=Math.max(50,u*10),_=[];for(let y=0;y<a.length;y++){const x=a[y],v=l[y];v>0?_[y]=rT(x.start,x.end,v,"inward",n):_[y]=[[x.start.lng,x.start.lat],[x.end.lng,x.end.lat]]}const j=[];for(let y=0;y<a.length;y++){const x=_[y],v=_[(y+1)%a.length];let C=mz(x[0],x[1],v[0],v[1]);if(C){const P=[(x[1][0]+v[0][0])/2,(x[1][1]+v[0][1])/2],I=lz(C,P);(!Number.isFinite(I)||I>i)&&(C=null)}C?j.push(C):j.push([(x[1][0]+v[0][0])/2,(x[1][1]+v[0][1])/2])}return j.length<3?null:(j.push(j[0]),[j])},uz=(t,s,n)=>{var a;try{const l=t.map(j=>[j.lng,j.lat]);l.push(l[0]);const c=Xn([l]),u=[];for(let j=0;j<s.length;j++){const y=n[j]||0;if(y<=0)continue;const x=yx(s[j].start,s[j].end,y,t),v=Xn(x),C=xm(Un([v,c]));C!=null&&C.geometry&&u.push(C)}if(u.length===0)return null;let i=u[0];for(let j=1;j<u.length;j++){const y=u[j],x=aj(Un([i,y]));x&&(i=x)}const _=pd(Un([c,i]));if(!(_!=null&&_.geometry))return null;if(_.geometry.type==="Polygon"){const j=(a=_.geometry.coordinates)==null?void 0:a[0];return j&&j.length>=4?[j]:null}if(_.geometry.type==="MultiPolygon"){let j=null,y=0;for(const x of _.geometry.coordinates){const v=x==null?void 0:x[0];if(!v||v.length<4)continue;const C=Xn([v]),P=zr(C);P>y&&(y=P,j=v)}return j?[j]:null}return null}catch(l){return console.warn("Boolean inset failed, falling back to line-intersection inset:",l),null}},hz=(t,s,n)=>{const a=t.length,l=new Array(a).fill(0),c=s.front_ft||0,u=s.rear_ft||0,i=s.side1_ft??s.side_ft??0,_=s.side2_ft??s.side_ft??0;if(a===4){const y=[...t].sort((P,I)=>I.length-P.length)[0],x=(y.index+2)%4,v=(y.index+1)%4,C=(y.index+3)%4;l[y.index]=c,l[x]=u,l[v]=i,l[C]=_}else{const j=n.reduce((H,O)=>
761({lat:H.lat+O.lat/n.length,lng:H.lng+O.lng/n.length}),{lat:0,lng:0}),y=111320,x=111320*Math.cos(j.lat*Math.PI/180),v=t.map(H=>cz(H,j,x,y)),C=v.map(H=>Math.atan2(H.y,H.x)),P=25*Math.PI/180;let I=0,z=-1;for(let H=0;H<C.length;H++){let O=0;for(let q=0;q<C.length;q++)Math.abs(Gv(C[q],C[H]))<=P&&(O+=t[q].length);O>z&&(z=O,I=H)}const F=C[I],D=F+Math.PI,X=v[I],K=Math.sqrt(X.x*X.x+X.y*X.y)||1,te=X.x/K,J=X.y/K;for(let H=0;H<a;H++){const O=C[H];if(Math.abs(Gv(O,F))<=P){l[H]=c;continue}if(Math.abs(Gv(O,D))<=P){l[H]=u;continue}const q=v[H],W=Math.sqrt(q.x*q.x+q.y*q.y)||1,Q=q.x/W,Z=q.y/W,oe=te*Z-J*Q;l[H]=oe>=0?i:_}}return l},mz=(t,s,n,a)=>{const l=t[0],c=t[1],u=s[0],i=s[1],_=n[0],j=n[1],y=a[0],x=a[1],v=(l-u)*(j-x)-(c-i)*(_-y);if(Math.abs(v)<1e-10)return null;const C=((l-_)*(j-x)-(c-j)*(_-y))/v,P=l+C*(u-l),I=c+C*(i-c);return[P,I]},fz=(t,s)=>{const n={frontBuffer:null,rearBuffer:null,sideLeftBuffer:null,sideRightBuffer:null};if(t.length!==4)return n;const a=[];for(let P=0;P<t.length;P++){const I=t[P],z=t[(P+1)%t.length],F=Math.sqrt(Math.pow((z.lat-I.lat)*111320,2)+Math.pow((z.lng-I.lng)*111320*Math.cos(I.lat*Math.PI/180),2));a.push({start:I,end:z,length:F,index:P})}const c=[...a].sort((P,I)=>I.length-P.length)[0],u=(c.index+2)%4,i=a[u],_=(c.index+1)%4,j=(c.index+3)%4,y=a[_],x=a[j];s.front_ft&&s.front_ft>0&&(n.frontBuffer=yx(c.start,c.end,s.front_ft,t)),s.rear_ft&&s.rear_ft>0&&(n.rearBuffer=yx(i.start,i.end,s.rear_ft,t));const v=s.side1_ft??s.side_ft??0,C=s.side2_ft??s.side_ft??0;return v>0&&(n.sideLeftBuffer=yx(y.start,y.end,v,t)),C>0&&(n.sideRightBuffer=yx(x.start,x.end,C,t)),n},yx=(t,s,n,a)=>{const l=rT(t,s,n,"inward",a);return[[[t.lng,t.lat],[s.lng,s.lat],l[1],l[0],[t.lng,t.lat]]]},rT=(t,s,n,a,l)=>{const c=n*.3048,u=(t.lat+s.lat)/2,i=111320,_=111320*Math.cos(u*Math.PI/180),j=(s.lng-t.lng)*_,y=(s.lat-t.lat)*i,x=Math.sqrt(j*j+y*y);if(x===0)return[[t.lng,t.lat],[s.lng,s.lat]];const v=-y/x,C=j/x,P={lat:(t.lat+s.lat)/2,lng:(t.lng+s.lng)/2},I=10,z={lat:P.lat+C*I/i,lng:P.lng+v*I/_},F={lat:P.lat-C*I/i,lng:P.lng-v*I/_};let D=null;try{if(l.length>=3){const H=l.map(oe=>[oe.lng,oe.lat]),O=H[0],q=H[H.length-1];O&&q&&(O[0]!==q[0]||O[1]!==q[1])&&H.push(O);const W=Xn([H]),Q=uu(us([z.lng,z.lat]),W),Z=uu(us([F.lng,F.lat]),W);Q&&!Z?D=1:!Q&&Z&&(D=-1)}}catch{}if(D==null){const H=l.reduce((W,Q)=>({lat:W.lat+Q.lat/l.length,lng:W.lng+Q.lng/l.length}),{lat:0,lng:0}),O=Math.sqrt(Math.pow((z.lat-H.lat)*i,2)+Math.pow((z.lng-H.lng)*_,2)),q=Math.sqrt(Math.pow((
761F.lat-H.lat)*i,2)+Math.pow((F.lng-H.lng)*_,2));D=O<q?1:-1}const X=D*C*c/i,K=D*v*c/_,te=[t.lng+K,t.lat+X],J=[s.lng+K,s.lat+X];return[te,J]},gg=t=>{const s=[];return t.combinedSetbackZone&&s.push({type:"Feature",properties:{setbackType:"combined-setback-zone"},geometry:{type:"Polygon",coordinates:t.combinedSetbackZone}}),t.innerPolygon&&s.push({type:"Feature",properties:{setbackType:"buildable-area"},geometry:{type:"Polygon",coordinates:t.innerPolygon}}),t.frontBuffer&&s.push({type:"Feature",properties:{setbackType:"front-buffer",labelOnly:!0},geometry:{type:"Polygon",coordinates:t.frontBuffer}}),t.rearBuffer&&s.push({type:"Feature",properties:{setbackType:"rear-buffer",labelOnly:!0},geometry:{type:"Polygon",coordinates:t.rearBuffer}}),t.sideLeftBuffer&&s.push({type:"Feature",properties:{setbackType:"side-left-buffer",labelOnly:!0},geometry:{type:"Polygon",coordinates:t.sideLeftBuffer}}),t.sideRightBuffer&&s.push({type:"Feature",properties:{setbackType:"side-right-buffer",labelOnly:!0},geometry:{type:"Polygon",coordinates:t.sideRightBuffer}}),{type:"FeatureCollection",features:s}},Df=t=>{var n,a;const s={frontLine:null,rearLine:null,sideLinesLeft:null,sideLinesRight:null,innerPolygon:null,combinedSetbackZone:null,frontBuffer:null,rearBuffer:null,sideLeftBuffer:null,sideRightBuffer:null};if(!t||!t.features)return s;for(const l of t.features){const c=(n=l.properties)==null?void 0:n.setbackType,u=(a=l.geometry)==null?void 0:a.coordinates;if(!(!c||!u))switch(c){case"front":s.frontLine=u;break;case"rear":s.rearLine=u;break;case"side-left":s.sideLinesLeft=u;break;case"side-right":s.sideLinesRight=u;break;case"buildable-area":s.innerPolygon=u;break;case"combined-setback-zone":s.combinedSetbackZone=u;break;case"front-buffer":s.frontBuffer=u;break;case"rear-buffer":s.rearBuffer=u;break;case"side-left-buffer":s.sideLeftBuffer=u;break;case"side-right-buffer":s.sideRightBuffer=u;break}}return s},mu=t=>{if(t.length!==4)return[];const s=(()=>{const _=[...t];if(_.length>=2){const j=_[0],y=_[_.length-1];j.lat===y.lat&&j.lng===y.lng&&_.pop()}return _})();if(s.length!==4)return[];const n=[];for(let _=0;_<s.length;_++){const j=s[_],y=s[(_+1)%s.length],x=Math.sqrt(Math.pow((y.lat-j.lat)*111320,2)+Math.pow((y.lng-j.lng)*111320*Math.cos(j.lat*Math.PI/180),2));n.push({start:j,end:y,length:x,index:_})}const l=[...n].sort((_,j)=>j.length-_.length)[0],c=(l.index+2)%4,u=(l.index+1)%4;(l.index+3)%4;const i=[];return n.forEach((_,j)=>{const y={lat:(_.start.lat+_.end.lat)/2,lng:(_.start.lng+_.end.lng)/2};let x,v;j===l.index?(x="F",v="Front"):j===c?(x="R",v="Rear"):j===u?(x="S1",v="Side 1"):(x="S2",v="Side 2");const C=_.length*3.28084;i.push({label:x,fullLabel:v,midpoint:y,edgeIndex:j,lengthFt:C})}),i},f_=Object.freeze(Object.defineProperty({__proto__:null,calculateSetbacks:pg,classifyEdgesForSetbackLabels:mu,parseSetbackGeometry:Df,setbackResultToGeoJSON:gg},Symbol.toStringTag,{value:"Module"})),Jk=[{value:"sidewalk",label:"Sidewalk",description:"Pedestrian walkway"},{value:"patio",label:"Patio",description:"Outdoor seating/gathering"},{value:"plaza",label:"Plaza",description:"Public gathering space"},{value:"service_area",label:"Service Area",description:"Loading/service zone"}],Hv=[{value:"concrete",label:"Concrete",color:"#d1d5db"},{value:"pavers",label:"Pavers",color:"#a8a29e"},{value:"brick",label:"Brick",color:"#b45309"},{value:"turf",label:"Turf/Grass",color:"#86efac"}],pz=[4,6,8,10,12,15,20];function gz({overlay:t,onUpdate:s,isUpdating:n}){const[a,l]=k.useState(null),[c,u]=k.useState("uniform"),i=t.building_buffer_ft||0,_=t.building_buffer_type,j=t.building_buffer_material,y=t.building_buffer_edge_config||{},x=i>0||Object.keys(y).length>0,v=t.geometry,C=k.useMemo(()=>!v||v.length<3?[]:mu(v),[v]),P=Q=>{const Z=C.find(oe=>oe.edgeIndex===Q);return(Z==null?void 0:Z.label)||`E${Q}`},I=Q=>{const Z=C.find(oe=>oe.edgeIndex===Q);return(Z==null?void 0:Z.fullLabel)||`Edge ${Q}`},z=t.building_buffer_edge_config!=null?"per-edge":c,F=Q=>{if(Q){const Z="sidewalk",oe=Ty[Z];s({building_buffer_ft:oe.defaultWidth,building_buffer_type:Z,building_buffer_material:oe.material}),u("uniform")}else s({building_buffer_ft:null,building_buffer_type:null,building_buffer_material:null,building_buffer_edge_indices:null,building_buffer_edge_config:null})},D=Q=>{const Z=Ty[Q];s({building_buffer_type:Q,building_buffer_material:Z.material,...i===0||Object.values(Ty).some(oe=>oe.defaultWidth===i)?{building_buffer_ft:Z.defaultWidth}:{}})},X=Q=>{s({building_buffer_ft:Math.max(0,Q)})},K=Q=>{s({building_buffer_material:Q})},te=Q=>{u(Q),s(Q==="uniform"?{building_buffer_edge_config:null,building_buffer_ft:i||6,building_buffer_type:_||"sidewalk",building_buffer_material:j||"concrete"}:{building_buffer_edge_config:{}})},J=Q=>{const Z={...y};Z[String(Q)]={type:_||"sidewalk",widthFt:i||6,material:j||"concrete",startPercent:0,endPercent:100},s({building_buffer_edge_config:Z}),l(String(Q))},H=Q=>{const Z={...y};delete Z[String(Q)],s({building_buffer_edge_config:Z}),a===String(Q)&&l(null)},O=(Q,Z)=>{const oe={...y};oe[String(Q)]={...oe[String(Q)],...Z},s({building_buffer_edge_config:oe})},q=new Set(Object.keys(y).map(Q=>parseInt(Q,10))),W=v?Array.from({length:v.length},(Q,Z)=>Z).filter(Q=>!q.has(Q)):[];return e.jsx(ns,{title:"Building Buffer",icon:e.jsx(zu,{className:"w-4 h-4"}),badge:x?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:z==="per-edge"?`${Object.keys(y).length} edges`:`${i} ft`}):null,defaultOpen:!1,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2",children:"Add sidewalks, patios, or plazas around the building perimeter"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-sm",children:"Enable Buffer Zone"}),e.jsx(kt,{checked:x,onCheckedChange:F,disabled:n})]}),x&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{className:"my-3"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Buffer Thickness (inches
761)"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Ca,{value:[t.building_buffer_thickness_in||8],onValueChange:([Q])=>s({building_buffer_thickness_in:Q}),min:4,max:24,step:1,className:"flex-1",disabled:n}),e.jsxs("span",{className:"text-xs font-mono w-8 text-right",children:[t.building_buffer_thickness_in||8,'"']})]}),e.jsx("div",{className:"flex gap-1 flex-wrap",children:[4,6,8,12].map(Q=>e.jsxs("button",{onClick:()=>s({building_buffer_thickness_in:Q}),disabled:n,className:`px-2 py-1 text-[10px] rounded border transition-colors ${(t.building_buffer_thickness_in||8)===Q?"bg-primary text-primary-foreground border-primary":"bg-background hover:bg-muted border-input"}`,children:[Q,'"']},Q))})]}),e.jsx(ks,{className:"my-3"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Le,{variant:z==="uniform"?"default":"outline",size:"sm",className:"flex-1 h-8 text-xs",onClick:()=>te("uniform"),disabled:n,children:[e.jsx(Il,{className:"w-3 h-3 mr-1"}),"Uniform"]}),e.jsxs(Le,{variant:z==="per-edge"?"default":"outline",size:"sm",className:"flex-1 h-8 text-xs",onClick:()=>te("per-edge"),disabled:n,children:[e.jsx(Dh,{className:"w-3 h-3 mr-1"}),"Per Edge"]})]}),z==="uniform"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Buffer Type"}),e.jsxs(rt,{value:_||"sidewalk",onValueChange:Q=>D(Q),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:Jk.map(Q=>e.jsx(le,{value:Q.value,className:"text-xs",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:Q.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:Q.description})]})},Q.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Buffer Width (ft)"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(be,{type:"number",value:i,onChange:Q=>X(parseFloat(Q.target.value)||0),className:"h-8 text-sm flex-1",min:0,step:1,disabled:n})}),e.jsx("div",{className:"flex gap-1 flex-wrap",children:pz.map(Q=>e.jsxs("button",{onClick:()=>X(Q),disabled:n,className:`px-2 py-1 text-[10px] rounded border transition-colors ${i===Q?"bg-primary text-primary-foreground border-primary":"bg-background hover:bg-muted border-input"}`,children:[Q,"'"]},Q))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Material"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Hv.map(Q=>e.jsxs("button",{onClick:()=>K(Q.value),disabled:n,className:`flex items-center gap-2 px-3 py-2 text-xs rounded border transition-colors ${j===Q.value?"bg-primary/10 border-primary":"bg-background hover:bg-muted border-input"}`,children:[e.jsx("div",{className:"w-4 h-4 rounded-sm border",style:{backgroundColor:Q.color}}),e.jsx("span",{children:Q.label})]},Q.value))})]})]}),z==="per-edge"&&e.jsxs(e.Fragment,{children:[W.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Add Buffer to Edge"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:W.map(Q=>e.jsxs(Le,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>J(Q),disabled:n,children:[e.jsx(tr,{className:"w-3 h-3 mr-1"}),P(Q)]},Q))})]}),Object.keys(y).length>0&&e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dh,{className:"w-3 h-3 text-muted-foreground"}),e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Edge Buffers"})]}),e.jsx("div",{className:"space-y-1",children:Object.entries(y).map(([Q,Z])=>{const oe=parseInt(Q,10),ce=a===Q,ae=P(oe),ie=I(oe);return Hv.find(de=>de.value===Z.material),e.jsxs(wi,{open:ce,onOpenChange:de=>l(de?Q:null),children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full h-8 justify-between text-[10px] px-2",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Mt,{variant:"outline",className:"text-[9px] h-4 px-1.5",children:ae}),e.jsxs("span",{className:"text-muted-foreground",children:[Z.widthFt||6,"ft ",Z.type||"sidewalk"]}),Z.startPercent!==void 0&&Z.startPercent>0||Z.endPercent!==void 0&&Z.endPercent<100?e.jsxs(Mt,{variant:"secondary",className:"text-[8px] h-3.5",children:[Z.startPercent||0,"%-",Z.endPercent??100,"%"]}):null]}),e.jsx(Oa,{className:`w-3 h-3 transition-transform ${ce?"rotate-180":""}`})]})}),e.jsxs(ki,{className:"pt-2 pb-3 px-2 space-y-3 bg-muted/30 rounded-md mt-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium",children:ie}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-destructive hover:text-destructive",onClick:()=>H(oe),disabled:n,children:e.jsx(wr,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Type"}),e.jsxs(rt,{value:Z.type||"sidewalk",onValueChange:de=>O(oe,{type:de}),disabled:n,children:[e.jsx(it,{className:"h-6 text-[10px]",children:e.jsx(ct,{})}),e.jsx(ot,{children:Jk.map(de=>e.jsx(le,{value:de.value,className:"text-xs",children:de.label},de.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Material"}),e.jsxs(rt,{value:Z.material||"concrete",onValueChange:de=>O(oe,{material:de}),disabled:n,children:[e.jsx(it,{className:"h-6 text-[10px]",children:e.jsx(ct,{})}),e.jsx(ot,{children:Hv.map(de=>e.jsx(le,{value:de.value,className:"text-xs",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-sm",style:{backgroundColor:de.color}}),de.label]})},de.value))})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",value:Z.widthFt||6,onChange:de=>O(oe,{widthFt:Number(de.target.value)}),className:"h-6 text-[10px]",min:1,max:50,disabled:n})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-[9px] text-muted-foreground",children:"Edge Coverage"}),e.jsxs("span",{className:"text-[9px] text-muted-foreground",children:[Z.startPercent||0,"% - ",Z.endPercent??100,"%"]})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(be,{type:"number",value:Z.startPercent||0,onChange:de=>O(oe,{startPercent:Math.max(0,Math.min(100,Number(de.target.value)))}),className:"h-6 text-[10px] w-16",min:0,max:100,disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"to"}),e.jsx(be,{type:"number",value:Z.endPercent??100,onChange:de=>O(oe,{endPercent:Math.max(0,Math.min(100,Number(de.target.value)))}),className:"h-6 text-[10px] w-16",min:0,max:100,disabled:n})]}),e.jsx("p",{className:"text-[9px] text-muted-foreground",children:"Adjust to cover only part of the edge (e.g., 25%-75% for center patio)"})]})]})]},Q)})})]}),Object.keys(y).length===0&&e.jsx("div",{className:"text-center py-4 text-xs text-muted-foreground",children:"Click an edge button above to add a buffer zone"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-md p-3 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx(Il,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:z==="per-edge"?"Each edge can have different buffer settings":"Buffer will be rendered around the building perimeter"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx(y3,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Parking zones will automatically exclude these areas"})]})]})]})]})})}const xz={standard:Ml,ada:fh,reserved:Ep,ev_charging:Xd,compact:Ml,motorcycle:G1,van_accessible:fh,loading_zone:hu,no_parking:hS,island:Ih},_z=[{value:"landscape",label:"Landscape",description:"Grass with optional trees"},{value:"painted",label:"Painted",description:"Hatched concrete"},{value:"bushes",label:"Bushes",description:"Dense shrub hedge"},{value:"rock",label:"Rock",description:"Decorative stone/gravel"},{value:"mulch",label:"Mulch",description:"Bark/wood chip ground cover"},{value:"planter_box",label:"Planter Box",description:"Raised concrete planter"}],yz=[{value:"deciduous",label:"Deciduous"},{value:"evergreen",label:"Evergreen"},{value:"palm",label:"Palm"},{value:"shrub",label:"Shrub"}];function vz({stallId:t,stallOverride:s,rowIndex:n,stallIndex:a,isAda:l,onUpdate:c,onRemove:u,onClearOverride:i,onClose:_,isUpdating:j}){const y=(s==null?void 0:s.type)||(l?"ada":"standard"),x=Qw[y],v=y==="island",C=(s==null?void 0:s.islandFinish)||"landscape",P=(s==null?void 0:s.islandWidthStalls)||1,I=(s==null?void 0:s.islandTreeEnabled)??!0,z=(s==null?void 0:s.islandTreeSpecies)||"deciduous",F=v&&(C==="landscape"||C==="planter_box"),D=(s==null?void 0:s.edges)||{front:!1,back:!0,left:!0,right:!0},X=k.useMemo(()=>s?!!(s.type||s.color||s.label||s.edges||s.reservedFor||s.reservedUntil||s.islandFinish):!1,[s]),K=O=>{c(O==="island"?{type:"island",islandFinish:"landscape",islandWidthStalls:1,islandTreeEnabled:!0}:{type:O==="standard"&&!l?void 0:O,islandFinish:void 0,islandWidthStalls:void 0,islandTreeEnabled:void 0,islandTreeSpecies:void 0})},te=O=>{const q={...D,[O]:!D[O]};c({edges:q})},J=O=>{c({label:O||void 0})},H=O=>{c({reservedFor:O||void 0})};return e.jsx(ns,{title:"Stall Editor",icon:e.jsx(Ml,{className:"w-4 h-4"}),badge:e.jsx(Mt,{variant:"secondary",className:"text-[10px]",style:{backgroundColor:x.color,color:y==="standard"?"#000":"#fff"},children:x.label}),defaultOpen:!0,headerAction:e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:_,children:e.jsx(ja,{className:"w-4 h-4"})}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Stall: ",e.jsx("code",{className:"font-mono",children:t})]}),e.jsxs("span",{children:["Row ",n," | Position ",a]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Stall Type"}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:Object.entries(Qw).map(([O,q])=>{const W=xz[O],Q=y===O;return e.jsxs(Le,{variant:Q?"default":"outline",size:"sm",className:fs("h-auto py-2 px-2 flex flex-col items-center gap-1",Q&&"ring-2 ring-offset-1"),style:Q?{backgroundColor:q.color,color:O==="standard"?"#000":"#fff"}:void 0,onClick:()=>K(O),disabled:j,title:q.description,children:[e.jsx(W,{className:"w-4 h-4"}),e.jsx("span",{className:"text-[9px] leading-tight text-center",children:q.label})]},O)})}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:x.description})]}),v&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-xs font-semibold",children:"Island Configuration"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-[11px]",children:"Surface Finish"}),e.jsxs(rt,{value:C,onValueChange:O=>c({islandFinish:O}),disabled:j,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:_z.map(O=>e.jsx(le,{value:O.value,className:"text-xs",children:e.jsxs("div",{children:[e.jsx("span",{children:O.label}),e.jsxs("span",{className:"ml-1 text-muted-foreground",children:["— ",O.description]})]})},O.value))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-[11px]",children:"Width (stalls to span)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{type:"number",min:1,max:5,value:P,onChange:O=>c({islandWidthStalls:Math.max(1,Math.min(5,parseInt(O.target.value)||1))}),className:"h-8 w-20 text-xs",disabled:j}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:P===1?"Single stall":`Spans ${P} stalls`})]})]}),F&&e.jsxs("div",{className:"space-y-2 p-2 bg-muted/30 rounded-md",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-[11px] flex items-center gap-1",children:[e.jsx(Ih,{className:"w-3 h-3"}),"Include Tree"]}),e.jsx(kt,{checked:I,onCheckedChange:O=>c({islandTreeEnabled:O}),disabled:j})]}),I&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-[11px]",children:"Tree Species"}),e.jsxs(rt,{value:z,onValueChange:O=>c({islandTreeSpecies:O}),disabled:j,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:yz.map(O=>e.jsx(le,{value:O.value,className:"text-xs",children:O.label},O.value))})]})]})]})]})]}),!v&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-xs",children:"Edge Lines"}),e.jsx("p",{className:"text-[10px] text-muted-foreground -mt-1",children:"Control which edges have striping lines drawn"}),e.jsx("div",{className:"flex justify-center",children:e.jsxs("div",{className:"relative w-24 h-32 border-2 border-dashed border-muted rounded-md",children:[e.jsx("button",{onClick:()=>te("front"),className:fs("absolute -bottom-1 left-2 right-2 h-2 rounded-full transition-colors",D.front?"bg-primary":"bg-muted hover:bg-muted-foreground
761/30"),title:"Front (drive aisle)",disabled:j}),e.jsx("button",{onClick:()=>te("back"),className:fs("absolute -top-1 left-2 right-2 h-2 rounded-full transition-colors",D.back?"bg-primary":"bg-muted hover:bg-muted-foreground/30"),title:"Back (bumper)",disabled:j}),e.jsx("button",{onClick:()=>te("left"),className:fs("absolute -left-1 top-2 bottom-2 w-2 rounded-full transition-colors",D.left?"bg-primary":"bg-muted hover:bg-muted-foreground/30"),title:"Left side",disabled:j}),e.jsx("button",{onClick:()=>te("right"),className:fs("absolute -right-1 top-2 bottom-2 w-2 rounded-full transition-colors",D.right?"bg-primary":"bg-muted hover:bg-muted-foreground/30"),title:"Right side",disabled:j}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(Ml,{className:"w-8 h-8 text-muted-foreground/50"})}),e.jsx("span",{className:"absolute -bottom-5 left-1/2 -translate-x-1/2 text-[8px] text-muted-foreground",children:"Front"}),e.jsx("span",{className:"absolute -top-5 left-1/2 -translate-x-1/2 text-[8px] text-muted-foreground",children:"Back"})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/50 rounded",children:[e.jsx("span",{children:"Front"}),e.jsx(kt,{checked:D.front,onCheckedChange:()=>te("front"),disabled:j})]}),e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/50 rounded",children:[e.jsx("span",{children:"Back"}),e.jsx(kt,{checked:D.back,onCheckedChange:()=>te("back"),disabled:j})]}),e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/50 rounded",children:[e.jsx("span",{children:"Left"}),e.jsx(kt,{checked:D.left,onCheckedChange:()=>te("left"),disabled:j})]}),e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/50 rounded",children:[e.jsx("span",{children:"Right"}),e.jsx(kt,{checked:D.right,onCheckedChange:()=>te("right"),disabled:j})]})]})]})]}),!v&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Label"}),e.jsx(be,{value:(s==null?void 0:s.label)||"",onChange:O=>J(O.target.value),placeholder:"VIP, CEO, 1A...",className:"h-8",disabled:j})]}),(y==="reserved"||(s==null?void 0:s.reservedFor))&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{className:"text-xs flex items-center gap-1",children:[e.jsx(Ep,{className:"w-3 h-3"}),"Reserved For"]}),e.jsx(be,{value:(s==null?void 0:s.reservedFor)||"",onChange:O=>H(O.target.value),placeholder:"Name or department...",className:"h-8",disabled:j})]})]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2",children:[X&&e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full",onClick:i,disabled:j,children:[e.jsx(ES,{className:"w-4 h-4 mr-2"}),"Clear All Overrides"]}),e.jsxs(Le,{variant:"destructive",size:"sm",className:"w-full",onClick:u,disabled:j,children:[e.jsx(wr,{className:"w-4 h-4 mr-2"}),"Remove Stall"]}),e.jsx("p",{className:"text-[10px] text-muted-foreground text-center",children:"Removing hides the stall. Clear overrides to restore."})]})]})})}function bz({rowId:t,rowIndex:s,side:n,stallCount:a,onUpdateRow:l,onClearRowOverrides:c,onHideRow:u,onDeleteRow:i,isRowHidden:_=!1,onClose:j,isUpdating:y,rowEdges:x}){const v=x||{front:!1,back:!0,left:!0,right:!0},C=I=>{const z={...v,[I]:!v[I]};l({edges:z})},P=n==="top"?"Top Side":"Bottom Side";return e.jsx(ns,{title:"Row Editor",icon:e.jsx(kS,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"secondary",className:"text-[10px]",children:[a," stalls"]}),defaultOpen:!0,headerAction:e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:j,children:e.jsx(ja,{className:"w-4 h-4"})}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Row ",s+1," (",P,")"]}),e.jsxs(Mt,{variant:"outline",className:"text-[9px]",children:[a," stalls"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Row Actions"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[u&&e.jsxs(Le,{variant:_?"default":"outline",size:"sm",className:"text-xs h-8",onClick:u,disabled:y,children:[_?e.jsx(kc,{className:"w-3.5 h-3.5 mr-1.5"}):e.jsx(Wc,{className:"w-3.5 h-3.5 mr-1.5"}),_?"Show Row":"Hide Row"]}),i&&e.jsxs(Le,{variant:"destructive",size:"sm",className:"text-xs h-8",onClick:i,disabled:y,children:[e.jsx(wr,{className:"w-3.5 h-3.5 mr-1.5"}),"Delete Row"]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:_?"This row is hidden. Click Show to restore it.":"Hide removes stalls visually. Delete removes all stall overrides for this row."})]}),e.jsx(ks,{}),!_&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-xs",children:"Edge Lines (All Stalls)"}),e.jsx("p",{className:"text-[10px] text-muted-foreground -mt-1",children:"Toggle edges for the entire row"}),e.jsx("div",{className:"flex justify-center",children:e.jsxs("div",{className:"relative w-48 h-24 border-2 border-dashed border-muted rounded-md",children:[e.jsx("button",{onClick:()=>C("front"),className:`absolute -bottom-1 left-4 right-4 h-2 rounded-full transition-colors ${v.front?"bg-primary":"bg-muted hover:bg-muted-foreground
761/30"}`,title:"Front (drive aisle)",disabled:y}),e.jsx("button",{onClick:()=>C("back"),className:`absolute -top-1 left-4 right-4 h-2 rounded-full transition-colors ${v.back?"bg-primary":"bg-muted hover:bg-muted-foreground/30"}`,title:"Back (bumper)",disabled:y}),e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center gap-2",children:[e.jsx(Ml,{className:"w-6 h-6 text-muted-foreground/50"}),e.jsx(Ml,{className:"w-6 h-6 text-muted-foreground/50"}),e.jsx(Ml,{className:"w-6 h-6 text-muted-foreground/50"})]}),e.jsx("span",{className:"absolute -bottom-5 left-1/2 -translate-x-1/2 text-[8px] text-muted-foreground",children:"Front (Aisle)"}),e.jsx("span",{className:"absolute -top-5 left-1/2 -translate-x-1/2 text-[8px] text-muted-foreground",children:"Back (Bumper)"})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/50 rounded",children:[e.jsx("span",{children:"Front Edge"}),e.jsx(kt,{checked:v.front,onCheckedChange:()=>C("front"),disabled:y})]}),e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/50 rounded",children:[e.jsx("span",{children:"Back Edge"}),e.jsx(kt,{checked:v.back,onCheckedChange:()=>C("back"),disabled:y})]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Side edges (left/right) are controlled per-stall for divider lines."})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full",onClick:c,disabled:y,children:[e.jsx(ES,{className:"w-4 h-4 mr-2"}),"Clear All Row Overrides"]}),e.jsx("p",{className:"text-[10px] text-muted-foreground text-center",children:"Clears all edge overrides for stalls in this row."})]})]})})}const jz=[{value:"none",label:"None",icon:hS,description:"No arrows"},{value:"forward",label:"Forward",icon:W5,description:"One-way →"},{value:"backward",label:"Backward",icon:Y5,description:"One-way ←"},{value:"two_way",label:"Two-Way",icon:e_,description:"Both directions"}];function wz({overlay:t,driveAisles:s,onUpdate:n,isUpdating:a}){const l=t.style||{},c=l.parkingCirculation||{},u=c.aisleArrows||{},i=c.autoOneWayEnabled??!0,_=k.useCallback(P=>{const I=u[P.id];return I!=null&&I.direction?I.direction:i&&P.width_ft<=10?"forward":"none"},[u,i]),j=k.useMemo(()=>s.filter(P=>_(P)!=="none").length,[s,_]),y=k.useCallback(P=>{const I={...c,...P};n({style:{...l,parkingCirculation:I}})},[c,l,n,t.style]),x=k.useCallback(P=>{y({autoOneWayEnabled:P})},[y]),v=k.useCallback((P,I)=>{const z={...u};I==="none"?delete z[P]:z[P]={aisleId:P,direction:I,autoApplied:!1},y({aisleArrows:z})},[u,y]),C=k.useCallback(()=>{y({aisleArrows:{}})},[y]);return s.length===0?null:e.jsx(ns,{title:"Drive Aisle Arrows",icon:e.jsx(uo,{className:"w-4 h-4"}),badge:j>0?e.jsxs(Mt,{variant:"secondary",className:"text-[10px] h-5",children:[j," arrows"]}):void 0,defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/30 rounded-lg border",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Xd,{className:"w-3.5 h-3.5 text-amber-500"}),e.jsx(B,{className:"text-xs font-medium",children:"Auto One-Way"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Aisles ≤10' get one-way arrows"})]}),e.jsx(kt,{checked:i,onCheckedChange:x,disabled:a})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Configure each aisle:"}),s.map(P=>{const I=_(P),z=P.width_ft<=10,F=z&&i&&!u[P.id];return e.jsxs("div",{className:fs("p-2 rounded-lg border bg-background",F&&"border-amber-500/50 bg-amber-500/5"),children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:P.labelText||`Aisle ${P.id.split("-")[1]}`}),e.jsxs(Mt,{variant:z?"destructive":"secondary",className:"text-[9px] h-4",children:[P.width_ft,"'"]}),F&&e.jsx(Mt,{variant:"outline",className:"text-[9px] h-4 border-amber-500 text-amber-600",children:"Auto"})]})}),e.jsx("div",{className:"grid grid-cols-4 gap-1",children:jz.map(({value:D,label:X,icon:K})=>{const te=I===D;return e.jsx(Le,{variant:te?"default":"outline",size:"sm",className:fs("h-7 text-[10px] px-1",te&&D==="forward"&&"bg-green-600 hover:bg-green-700",te&&D==="backward"&&"bg-
761orange-600 hover:bg-orange-700",te&&D==="two_way"&&"bg-blue-600 hover:bg-blue-700"),onClick:()=>v(P.id,D),disabled:a,title:X,children:e.jsx(K,{className:"w-3 h-3"})},D)})})]},P.id)})]}),Object.keys(u).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(Le,{variant:"outline",size:"sm",className:"w-full text-xs",onClick:C,disabled:a,children:"Clear All Manual Overrides"})]})]})})}const ey=(t,s)=>{const a=111320*Math.cos(s*Math.PI/180)*3.28084;return t/a},Nz=(t,s)=>{const n=t[s],a=t[(s+1)%t.length];return{start:n,end:a}},kz=(t,s,n)=>{const a=n/100;return{lat:t.lat+a*(s.lat-t.lat),lng:t.lng+a*(s.lng-t.lng)}},Cz=(t,s,n)=>{const a=s.lng-t.lng,l=s.lat-t.lat,c=Math.sqrt(a*a+l*l)||1,u=-l/c,i=a/c,_={lat:(t.lat+s.lat)/2,lng:(t.lng+s.lng)/2},j=n.lng-_.lng,y=n.lat-_.lat;return u*j+i*y>=0?{dx:u,dy:i}:{dx:-u,dy:-i}},Sz=(t,s)=>{let n=s[0],a=1/0,l=0;for(let c=0;c<s.length;c++){const u=s[c],i=s[(c+1)%s.length],_=i.lng-u.lng,j=i.lat-u.lat,y=_*_+j*j;if(y===0)continue;const x=Math.max(0,Math.min(1,((t.lng-u.lng)*_+(t.lat-u.lat)*j)/y)),v={lat:u.lat+x*j,lng:u.lng+x*_},C=t.lng-v.lng,P=t.lat-v.lat,I=Math.sqrt(C*C+P*P);I<a&&(a=I,n=v,l=c)}return{point:n,distance:a,edgeIndex:l}},iT=(t,s,n,a=40,l)=>{if(!s||s.length<3)return null;const c=s.reduce((Q,Z)=>({lat:Q.lat+Z.lat/s.length,lng:Q.lng+Z.lng/s.length}),{lat:0,lng:0});let u=null;if(t.edge_label){const Q=n.filter(Z=>Z.label===t.edge_label);Q.length>0&&(u=Q[0])}if(!u&&n.length>0&&(u=n.find(Z=>Z.label==="F")||n[0]),!u)return null;const{start:i,end:_}=Nz(s,u.edgeIndex),j=t.position_percent??50,y=kz(i,_,j),x=Cz(i,_,c),v={dx:-x.dx,dy:-x.dy},C=c.lat,P=ey(t.width_ft/2,C),I=_.lng-i.lng,z=_.lat-i.lat,F=Math.sqrt(I*I+z*z)||1,D=I/F,X=z/F;let K,te;if(l&&l.length>=3){te=Sz(y,l).point;const Z=te.lng-y.lng,oe=te.lat-y.lat;K=Math.sqrt(Z*Z+oe*oe);const ce=ey(20,C);K<ce&&(K=ce)}else{const Q=t.depth_ft||a;K=ey(Q,C),te={lat:y.lat+v.dy*K,lng:y.lng+v.dx*K}}const J={lat:y.lat-X*P,lng:y.lng-D*P},H={lat:y.lat+X*P,lng:y.lng+D*P},O={lat:te.lat+X*P,lng:te.lng+D*P},q={lat:te.lat-X*P,lng:te.lng-D*P},W=K/ey(1,C);return{id:t.id,type:t.type,name:t.name,coordinates:[J,H,O,q,J],width_ft:t.width_ft,depth_ft:Math.round(W),has_gate:t.has_gate}},Ez=t=>{var i;const s=(()=>{const _=[...t];if(_.length>=2){const j=_[0],y=_[_.length-1];j.lat===y.lat&&j.lng===y.lng&&_.pop()}return _})();if(s.length<3)return[];const n=[];for(let _=0;_<s.length;_++){const j=s[_],y=s[(_+1)%s.length],x=Math.sqrt(Math.pow((y.lat-j.lat)*111320,2)+Math.pow((y.lng-j.lng)*111320*Math.cos(j.lat*Math.PI/180),2));n.push({index:_,length:x,start:j,end:y})}const l=((i=[...n].sort((_,j)=>j.length-_.length)[0])==null?void 0:i.index)??0,c=[];let u=1;for(let _=0;_<s.length;_++){const j=n[_];let y,x;_===l?(y="F",x="Front"):s.length>=4&&Math.abs(_-l)===Math.floor(s.length/2)?(y="R",x="Rear"):u===1?(y="S1",x="Side 1",u++):(y="S2",x="Side 2");const v={lat:(j.start.lat+j.end.lat)/2,lng:(j.start.lng+j.end.lng)/2};c.push({label:y,fullLabel:x,midpoint:v,edgeIndex:_,lengthFt:j.length*3.28084})}return c},Lj=(t,s,n=40,a)=>{if(!t||t.length===0||!s||s.length<3)return[];let l=mu(s);return l.length===0&&(l=Ez(s)),t.map(c=>iT(c,s,l,n,a)).filter(c=>c!==null)},oT=t=>{switch(t){case"main_entry":return"#22c55e";case"service_entry":return"#f97316";case"emergency_access":return"#ef4444";case"fire_lane":return"#dc2626";default:return"#3b82f6"}},Pz=(t,s)=>{let n="🚗";switch(t){case"main_entry":n="🚗";break;case"service_entry":n="🚚";break;case"emergency_access":n="🚨";break;case"fire_lane":n="🔥";break}return s&&(n+="🚧"),n},Tz=(t,s,n)=>{if(!s||s.length<3)return null;const a=(()=>{const i=[...s];if(i.length>=2){const _=i[0],j=i[i.length-1];_.lat===j.lat&&_.lng===j.lng&&i.pop()}return i})();if(a.length<3)return null;let l=null,c=1/0;n&&n.length>0||a.map((i,_)=>({edgeIndex:_,label:`Edge ${_+1}`}));const u=(()=>{var v;if(n&&n.length>0)return n;const i=[];for(let C=0;C<a.length;C++){const P=a[C],I=a[(C+1)%a.length],z=Math.sqrt(Math.pow((I.lat-P.lat)*111320,2)+Math.pow((I.lng-P.lng)*111320*Math.cos(P.lat*Math.PI/180),2));i.push({index:C,length:z})}const j=((v=[...i].sort((C,P)=>P.length-C.length)[0])==null?void 0:v.index)??0,y=[];let x=1;for(let C=0;C<a.length;C++){let P;C===j?P="F":a.length>=4&&Math.abs(C-j)===Math.floor(a.length/2)?P="R":(P=`S${x}`,x++),y.push({edgeIndex:C,label:P})}return y})();for(const i of u){const{edgeIndex:_,label:j}=i;if(_>=a.length)continue;const y=a[_],x=a[(_+1)%a.length],v=x.lng-y.lng,C=x.lat-y.lat,P=v*v+C*C;if(P===0)continue;const I=Math.max(0,Math.min(1,((t.lng-y.lng)*v+(t.lat-y.lat)*C)/P)),z=y.lng+I*v,F=y.lat+I*C,D=t.lng-z,X=t.lat-F,K=Math.sqrt(D*D+X*X);if(K<c){c=K;const te=Math.max(5,Math.min(95,I*100));l={edgeLabel:j,positionPercent:te,distance:K,edgeIndex:_}}}return l},lp=Object.freeze(Object.defineProperty({__proto__:null,findNearestEdgeFromPoint:Tz,generateAllEntryPointPolygons:Lj,generateEntryPointPolygon:iT,getEntryPointColor:oT,getEntryPointIcon:Pz},Symbol.toStringTag,{value:"Module"}));function Lz(t){if(t.startsWith("row-")){const n=t.split("-");return{type:"row",rowIndex:parseInt(n[1],10)||0,side:n[2]||"top"}}const s=t.split("-");return{type:"stall",rowIndex:parseInt(s[1],10)||0,side:s[2]||"top",position:parseInt(s[3],10)||0}}const ty=[{value:"main_entry",label:"Main Entry",icon:Ml,description:"Primary vehicle access"},{value:"service_entry",label:"Service Entry",icon:hu,description:"Tru
761ck/delivery access"},{value:"emergency_access",label:"Emergency Access",icon:ho,description:"Emergency vehicle only"},{value:"fire_lane",label:"Fire Lane",icon:Ff,description:"Fire department access"},{value:"right_in_right_out",label:"RIRO",icon:uo,description:"Right-in/right-out only"},{value:"full_access_drive",label:"Full Access",icon:pp,description:"Full movement drive"}],Mz=[{value:"full_movement",label:"Full Movement"},{value:"right_in_right_out",label:"Right-In/Right-Out"},{value:"left_in_left_out",label:"Left-In/Left-Out"},{value:"right_in_only",label:"Right-In Only"},{value:"right_out_only",label:"Right-Out Only"}],Qk={small:{capacity:12,label:"Small (Strip)",dims:"4ft × 10ft"},medium:{capacity:24,label:"Medium",dims:"4ft × 20ft"},large:{capacity:48,label:"Large (Grocery)",dims:"6ft × 24ft"}},Iz=[{value:"standard",label:"Standard"},{value:"raised",label:"Raised"},{value:"zebra",label:"Zebra"},{value:"continental",label:"Continental"},{value:"ladder",label:"Ladder"}],Az=[{value:"speed_bump",label:"Speed Bump"},{value:"speed_hump",label:"Speed Hump"},{value:"speed_table",label:"Speed Table"},{value:"speed_cushion",label:"Speed Cushion"}],Dz=[{id:"red_curb",label:"Red Curb",color:"#dc2626"},{id:"yellow_curb",label:"Yellow Curb",color:"#eab308"},{id:"no_parking_signs",label:"No Parking Signs",color:"#6b7280"}],Xp=["F","R","S1","S2"],Uk={F:"Front",R:"Rear",S1:"Side 1",S2:"Side 2"},Zv={enabled:!1,width_ft:20,striping_style:"red_curb",has_fire_hydrant:!1,hydrant_count:1,has_knox_box:!1};function Rz({overlay:t,onUpdate:s,isUpdating:n,stallEditorEnabled:a=!1,onToggleStallEditor:l,selectedStallId:c=null,onSelectedStallIdChange:u,driveAisles:i=[],parkingRows:_=[],hideHeader:j=!1,selectedEntryId:y=null,onSelectedEntryIdChange:x,entryPointPlacementMode:v=!1,onStartEntryPointPlacement:C,onCancelEntryPointPlacement:P}){var _t,He,as;const I=t.style||{},z=I.parkingCirculation||{},[F,D]=k.useState(z.entryPoints||[]),[X,K]=k.useState(z.fireLanes||{}),[te,J]=k.useState("main_entry"),H=k.useMemo(()=>c?Lz(c):null,[c]),O=(H==null?void 0:H.type)==="row",q=(H==null?void 0:H.type)==="stall",W=k.useMemo(()=>{var Ce;if(!c||O)return;const vt=(Ce=t.style)==null?void 0:Ce.parkingCirculation,Xe=vt==null?void 0:vt.stallOverrides;return Xe==null?void 0:Xe[c]},[c,t.style,O]),Q=k.useMemo(()=>!O||!H?0:10,[O,H]),Z=k.useCallback(vt=>{if(!c||O)return;const Xe=t.style||{},Ce=Xe.parkingCirculation||{},Be=Ce.stallOverrides||{},Dt={...Be[c],...vt,stallId:c};s({style:{...Xe,parkingCirculation:{...Ce,stallOverrides:{...Be,[c]:Dt}}}})},[c,t.style,s,O]),oe=k.useCallback(vt=>{if(!c||!O||!H)return;const Xe=t.style||{},Ce=Xe.parkingCirculation||{};Ce.stallOverrides;const Be=`row-${H.rowIndex}-${H.side}`,Dt=Ce.rowOverrides||{};s({style:{...Xe,parkingCirculation:{...Ce,rowOverrides:{...Dt,[Be]:{...Dt[Be],...vt}}}}}),Ve.success("Row edges updated")},[c,O,H,t.style,s]),ce=k.useMemo(()=>{var Be,Dt;if(!O||!H)return;const vt=`row-${H.rowIndex}-${H.side}`,Xe=(Be=t.style)==null?void 0:Be.parkingCirculation,Ce=Xe==null?void 0:Xe.rowOverrides;return(Dt=Ce==null?void 0:Ce[vt])==null?void 0:Dt.edges},[O,H,t.style]),ae=k.useCallback(()=>{if(!O||!H)return;const vt=t.style||{},Xe=vt.parkingCirculation||{},Ce=Xe.rowOverrides||{},Be=`row-${H.rowIndex}-${H.side}`,Dt=Ce[Be]||{},Rt=Dt.hidden===!0;s({style:{...vt,parkingCirculation:{...Xe,rowOverrides:{...Ce,[Be]:{...Dt,hidden:!Rt}}}}}),Ve.success(Rt?"Row restored":"Row hidden")},[O,H,t.style,s]),ie=k.useMemo(()=>{var Be,Dt;if(!O||!H)return!1;const vt=`row-${H.rowIndex}-${H.side}`,Xe=(Be=t.style)==null?void 0:Be.parkingCirculation,Ce=Xe==null?void 0:Xe.rowOverrides;return((Dt=Ce==null?void 0:Ce[vt])==null?void 0:Dt.hidden)===!0},[O,H,t.style]),de=k.useCallback(()=>{if(!O||!H)return;const vt=t.style||{},Xe=vt.parkingCirculation||{},Ce=Xe.stallOverrides||{},Be=Xe.rowOverrides||{},Dt=`row-${H.rowIndex}-${H.side}`,Rt={},zt=`stall-${H.rowIndex}-${H.side}-`;for(const[rs,_s]of Object.entries(Ce))rs.startsWith(zt)||(Rt[rs]=_s);s({style:{...vt,parkingCirculation:{...Xe,stallOverrides:Rt,rowOverrides:{...Be,[Dt]:{hidden:!0}}}}}),Ve.success("Row deleted"),u==null||u(null)},[O,H,t.style,s,u]),ge=k.useCallback(()=>
761{if(!O||!H)return;const vt=t.style||{},Xe=vt.parkingCirculation||{},Ce=Xe.rowOverrides||{},Be=`row-${H.rowIndex}-${H.side}`,{[Be]:Dt,...Rt}=Ce;s({style:{...vt,parkingCirculation:{...Xe,rowOverrides:Rt}}}),Ve.success("Row overrides cleared")},[O,H,t.style,s]),We=k.useCallback(()=>{Z({isRemoved:!0}),Ve.success("Stall marked as removed")},[Z]),Ee=k.useCallback(()=>{if(!c||O)return;const vt=t.style||{},Xe=vt.parkingCirculation||{},Ce=Xe.stallOverrides||{},{[c]:Be,...Dt}=Ce;s({style:{...vt,parkingCirculation:{...Xe,stallOverrides:Dt}}}),Ve.success("Stall override cleared")},[c,t.style,s]),ve=k.useMemo(()=>!t.geometry||t.geometry.length<3?[]:mu(t.geometry),[t.geometry]),we=k.useMemo(()=>{const vt={},Xe={};return ve.forEach(Ce=>{Xe[Ce.label]||(Xe[Ce.label]=[]),Xe[Ce.label].push(Ce)}),Xp.forEach(Ce=>{const Be=Xe[Ce]||[];vt[Ce]=Be.reduce((Dt,Rt)=>Dt+(Rt.lengthFt||0),0)}),vt},[ve]);k.useEffect(()=>{var Xe;const vt=((Xe=t.style)==null?void 0:Xe.parkingCirculation)||{};D(vt.entryPoints||[]),K(vt.fireLanes||{})},[(_t=t.style)==null?void 0:_t.parkingCirculation]);const Ze=vt=>{const Xe={...z,...vt};s({style:{...I,parkingCirculation:Xe}})},ke=k.useRef(new Map);k.useEffect(()=>{if(y){const vt=ke.current.get(y);vt&&vt.scrollIntoView({behavior:"smooth",block:"center"})}},[y]);const ze=k.useCallback(vt=>{var Xe;if(!(!t.geometry||t.geometry.length<3))try{const Ce={...kj(),stallWidth_ft:t.parking_stall_width_ft||9,stallDepth_ft:t.parking_stall_depth_ft||18,aisleWidth_ft:t.parking_aisle_width_ft||24,layoutType:t.parking_layout_type||"double_loaded",stripingVisible:t.parking_striping_visible??!0},Be=Hm(t.geometry,Ce);if(!Be.stalls||Be.stalls.length===0)return;const Dt=Lj(vt,t.geometry,40);if(Dt.length===0)return;const Rt=Cj(Be.stalls,Dt);if(Rt.length===0)return;const zt=t.style||{},rs=zt.parkingCirculation||{},vs={...rs.stallOverrides||{}};let $t=0;for(const Ns of Rt)(Xe=vs[Ns])!=null&&Xe.isRemoved||(vs[Ns]={...vs[Ns]||{},stallId:Ns,isRemoved:!0},$t++);$t>0&&(s({style:{...zt,parkingCirculation:{...rs,stallOverrides:vs}}}),Ve.success(`Auto-removed ${$t} stalls in entry zone`))}catch(Ce){console.warn("[ParkingCirculation] Auto-removal error:",Ce)}},[t,s]),Ke=(vt,Xe)=>{const Ce=F.map(Dt=>Dt.id===vt?{...Dt,...Xe}:Dt);D(Ce),Ze({entryPoints:Ce}),("position_percent"in Xe||"width_ft"in Xe||"depth_ft"in Xe||"edge_label"in Xe)&&setTimeout(()=>ze(Ce),100)},dt=vt=>{const Xe=F.filter(Ce=>Ce.id!==vt);D(Xe),Ze({entryPoints:Xe}),Ve.success("Entry point removed")},Re=vt=>{const Xe=X[vt]||{id:`fire-${vt}`,edge_label:vt,...Zv},Ce={...X,[vt]:{...Xe,enabled:!Xe.enabled}};K(Ce),Ze({fireLanes:Ce})},qt=(vt,Xe)=>{const Ce=X[vt]||{id:`fire-${vt}`,edge_label:vt,...Zv},Be={...X,[vt]:{...Ce,...Xe}};K(Be),Ze({fireLanes:Be})},ft=vt=>X[vt]||{id:`fire-${vt}`,edge_label:vt,...Zv},Fe=vt=>{const Xe=ty.find(Be=>Be.value===vt);if(!Xe)return e.jsx(pp,{className:"w-4 h-4"});const Ce=Xe.icon;return e.jsx(Ce,{className:"w-4 h-4"})},fe=Xp.filter(vt=>ft(vt).enabled).length,Qe=Xp.reduce((vt,Xe)=>{const Ce=ft(Xe);return vt+(Ce.enabled&&we[Xe]||0)},0),ht=Xp.reduce((vt,Xe)=>{const Ce=ft(Xe);return vt+(Ce.enabled&&Ce.has_fire_hydrant?Ce.hydrant_count||1:0)},0);return!t.geometry||t.geometry.length<3?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(ho,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No valid geometry"}),e.jsx("p",{className:"text-xs mt-1",children:"Draw a parking area to configure circulation"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx(ns,{title:"Entry / Access Points",icon:e.jsx(pp,{className:"w-4 h-4"}),badge:F.length>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:F.length}):void 0,defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[v&&e.jsx("div",{className:"p-2 bg-primary/10 border border-primary rounded-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wx,{className:"w-4 h-4 text-primary animate-pulse"}),e.jsxs("span",{className:"text-xs font-medium text-primary",children:["Click on map to place ",(He=ty.find(vt=>vt.value===te))==null?void 0:He.label]})]}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 px-2",onClick:P,children:"Cancel"})]})}),!v&&e.jsxs("div",{className:"space-y-2 p-2 bg-muted/30 rounded-lg border",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click the button below, then click on the map to place an entry point."}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:ty.map(vt=>{const Xe=vt.icon,Ce=te===vt.value;return e.jsx("button",{onClick:()=>J(vt.value),className:fs("p-1.5 rounded border text-left transition-colors",Ce?"bg-primary/10 border-primary":"bg-background hover:bg-muted"),disabled:n,children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Xe,{className:fs("w-3.5 h-3.5",Ce?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-[10px] font-medium",children:vt.label})]})},vt.value)})}),e.jsxs(Le,{onClick:()=>C==null?void 0:C(te),size:"sm",className:"w-full gap-1 h-7",disabled:n||!C,children:[e.jsx(wx,{className:"w-3 h-3"}),"Place ",(as=ty.find(vt=>vt.value===te))==null?void 0:as.label," on Map"]})]}),F.length>0&&e.jsx("div",{className:"space-y-2",children:F.map(vt=>{var Xe,Ce;return e.jsxs("div",{ref:Be=>{Be?ke.current.set(vt.id,Be):ke.current.delete(vt.id)},className:fs("p-2 rounded-lg border bg-background space-y-2 transition-all",y===vt.id&&"ring-2 ring-primary border-primary"),onClick:()=>x==null?void 0:x(y===vt.id?null:vt.id),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[Fe(vt.type),e.jsx(be,{value:vt.name,onChange:Be=>Ke(vt.id,{name:Be.target.value}),className:"h-6 text-xs font-medium w-28 border-0 bg-transparent p-0",disabled:n})]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>dt(vt.id),disabled:n,children:e.jsx(wr,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width"}),e.jsx(be,{type:"number",value:vt.width_ft,onChange:Be=>Ke(vt.id,{width_ft:parseFloat(Be.target.value)||24}),className:"h-6 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Depth"}),e.jsx(be,{type:"number",value:vt.depth_ft,onChange:Be=>Ke(vt.id,{depth_ft:parseFloat(Be.target.value)||40}),className:"h-6 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Edge"}),e.jsxs(rt,{value:vt.edge_label||"F",onValueChange:Be=>Ke(vt.id,{edge_label:Be}),disabled:n,children:[e.jsx(it,{className:"h-6 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:Xp.map(Be=>e.jsxs(le,{value:Be,className:"text-xs",children:[Be," - ",Uk[Be]]},Be))})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Position"}),e.jsxs("span",{className:"text-[10px] font-mono text-primary",children:[vt.position_percent??50,"%"]})]}),e.jsx(Ca,{value:[vt.position_percent??50],onValueChange:([Be])=>Ke(vt.id,{position_percent:Be}),min:5,max:95,step:1,disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between pt-1 border-t",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Gated Entry"}),e.jsx(kt,{checked:vt.has_gate,onCheckedChange:Be=>Ke(vt.id,{has_gate:Be}),disabled:n})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Access Type"}),e.jsxs(rt,{value:vt.access_type||"full_movement",onValueChange:Be=>Ke(vt.id,{access_type:Be}),disabled:n,children:[e.jsx(it,{className:"h-6 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:Mz.map(Be=>e.jsx(le,{value:Be.value,className:"text-xs",children:Be.label},Be.value))})]})]}),(vt.access_type==="right_in_right_out"||vt.type==="right_in_right_out")&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Channelization Island"}),e.jsx(kt,{checked:vt.has_channelization_island??!0,onCheckedChange:Be=>Ke(vt.id,{has_channelization_island:Be}),disabled:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Curb Radius (ft)"}),e.jsx(be,{type:"number",value:((Xe=vt.curb_return)==null?void 0:Xe.radius_ft)??25,onChange:Be=>Ke(vt.id,{curb_return:{...vt.curb_return||{radius_ft:25,flare_type:"standard",has_ada_ramp:!1},radius_ft:parseFloat(Be.target.value)||25}}),className:"h-6 text-xs",min:10,max:50,disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"ADA Ramp"}),e.jsx(kt,{checked:((Ce=vt.curb_return)==null?void 0:Ce.has_ada_ramp)??!1,onCheckedChange:Be=>Ke(vt.id,{curb_return:{...vt.curb_return||{radius_ft:25,flare_type:"standard",has_ada_ramp:!1},has_ada_ramp:Be}}),disabled:n})]})]})]},vt.id)})})]})}),e.jsx(ks,{}),e.jsx(ns,{title:"Fire Lanes / Emergency",icon:e.jsx(ej,{className:"w-4 h-4"}),badge:fe>0?e.jsxs(Mt,{variant:"destructive",className:"text-[10px] h-5",children:[fe," edges"]}):void 0,defaultOpen:!1,children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Configure fire lanes along parking zone edges. Min width: 20ft."}),Xp.map(vt=>{const Xe=ft(vt),Ce=we[vt]||0;return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",Xe.enabled?"border-red-500 bg-red-500/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>Re(vt),children:[e.jsx("div",{className:fs("w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold",Xe.enabled?"bg-red-500 text-white":"bg-muted text-muted-foreground"),children:vt}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs font-medium",children:Uk[vt]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[Math.round(Ce).toLocaleStr
761ing()," ft"]})]}),e.jsx("div",{className:fs("w-4 h-4 rounded-full flex items-center justify-center",Xe.enabled?"bg-red-500":"bg-muted"),children:Xe.enabled?e.jsx(cl,{className:"w-2.5 h-2.5 text-white"}):e.jsx(ja,{className:"w-2.5 h-2.5 text-muted-foreground"})})]}),Xe.enabled&&e.jsxs("div",{className:"p-2 pt-0 space-y-2 border-t",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Width (ft)"}),e.jsx(be,{type:"number",value:Xe.width_ft,onChange:Be=>qt(vt,{width_ft:parseFloat(Be.target.value)||20}),className:"h-7 text-xs",min:20,max:26})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Striping"}),e.jsxs(rt,{value:Xe.striping_style,onValueChange:Be=>qt(vt,{striping_style:Be}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:Dz.map(Be=>e.jsx(le,{value:Be.id,className:"text-xs",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm",style:{backgroundColor:Be.color}}),Be.label]})},Be.id))})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-[10px] flex items-center gap-1",children:[e.jsx(Fx,{className:"w-3 h-3 text-blue-500"}),"Fire Hydrant"]}),e.jsx(kt,{checked:Xe.has_fire_hydrant,onCheckedChange:Be=>qt(vt,{has_fire_hydrant:Be})})]}),Xe.has_fire_hydrant&&e.jsxs("div",{className:"pl-4 flex items-center gap-2",children:[e.jsx(B,{className:"text-[10px]",children:"Count:"}),e.jsx(be,{type:"number",value:Xe.hydrant_count||1,onChange:Be=>qt(vt,{hydrant_count:parseInt(Be.target.value)||1}),className:"h-6 text-xs w-14",min:1,max:5})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-[10px] flex items-center gap-1",children:[e.jsx(P5,{className:"w-3 h-3 text-amber-500"}),"Knox Box"]}),e.jsx(kt,{checked:Xe.has_knox_box,onCheckedChange:Be=>qt(vt,{has_knox_box:Be})})]})]})]},vt)}),fe>0&&e.jsxs("div",{className:"p-2 bg-red-500/10 rounded-lg text-xs space-y-1 border border-red-500/20 mt-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Length:"}),e.jsxs("span",{className:"font-mono",children:[Math.round(Qe).toLocaleString()," ft"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Fire Hydrants:"}),e.jsx("span",{children:ht})]})]})]})}),e.jsx(ks,{}),i.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(wz,{overlay:t,driveAisles:i,onUpdate:s,isUpdating:n}),e.jsx(ks,{})]}),_.length>0&&e.jsx(ns,{title:"Select Row",icon:e.jsx(kS,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"secondary",className:"text-[10px] h-5",children:[_.length," rows"]}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Click a row below to edit all stalls in that row at once."}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:_.map(vt=>{const Xe=c===vt.rowId;return e.jsxs(Le,{variant:Xe?"default":"outline",size:"sm",className:fs("h-auto py-2 flex flex-col items-center gap-0.5",Xe&&"ring-2 ring-offset-1"),onClick:()=>{!a&&l&&l(!0),u==null||u(vt.rowId)},disabled:n,children:[e.jsxs("span",{className:"text-[10px] font-medium",children:["Row ",vt.rowIndex+1," (",vt.side,")"]}),e.jsxs("span",{className:"text-[9px] text-muted-foreground",children:[vt.stallCount," stalls"]})]},vt.rowId)})})]})}),e.jsx(ks,{}),e.jsx(ns,{title:"Parking Amenities",icon:e.jsx(Xd,{className:"w-4 h-4"}),badge:(()=>{const vt=(z.evStations||[]).length,Xe=(z.cartCorrals||[]).length,Ce=(z.speedBumps||[]).length,Be=(z.crosswalks||[]).length,Dt=vt+Xe+Ce+Be;return Dt>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:Dt}):void 0})(),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Fz,{overlay:t,onUpdate:s,isUpdating:n}),e.jsx(zz,{overlay:t,onUpdate:s,isUpdating:n}),e.jsx(Oz,{overlay:t,onUpdate:s,isUpdating:n}),e.jsx(Bz,{overlay:t,onUpdate:s,isUpdating:n})]})}),e.jsx($z,{overlay:t,onUpdate:s,isUpdating:n}),e.jsxs("div",{className:"space-y-2 border-t pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wx,{className:"w-3.5 h-3.5 text-primary"}),e.jsx(B,{className:"text-xs font-medium",children:"Individual Stall Editing"})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Edit Stalls Mode"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Click stalls to customize type, edges, or remove"})]}),e.jsx(kt,{checked:a,onCheckedChange:vt=>l==null?void 0:l(vt),disabled:n})]}),a&&!c&&e.jsx("div",{className:"p-2 bg-primary/10 border border-primary/20 rounded-md",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(kp,{className:"w-3.5 h-3.5 text-primary shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-xs",children:[e.jsx("p",{className:"font-medium text-primary",children:"Click stalls or rows on the map"}),e.jsxs("p",{className:"text-muted-foreground mt-0.5",children:["Click a ",e.jsx("strong",{children:"stall"})," to edit individually, or click the ",e.jsx("strong",{children:"row edge"})," (back line) to edit all stalls in that row"]})]})]})}),a&&c&&O&&H&&e.jsx(bz,{rowId:c,rowIndex:H.rowIndex,side:H.side,stallCount:Q,onUpdateRow:oe,onClearRowOverrides:ge,onHideRow:ae,onDeleteRow:de,isRowHidden:ie,onClose:()=>u==null?void 0:u(null),isUpdating:n,rowEdges:ce}),a&&c&&q&&H&&e.jsx(vz,{stallId:c,stallOverride:W,rowIndex:H.rowIndex,stallIndex:H.position||0,isAda:(W==null?void 0:W.type)==="ada",onUpdate:Z,onRemove:We,onClearOverride:Ee,onClose:()=>u==null?void 0:u(null),isUpdating:n})]}),e.jsx(Vz,{overlay:t,onUpdate:s,isUpdating:n}),e.jsx(qz,{overlay:t,onUpdate:s,isUpdating:n}),e.jsxs("div",{className:"p-2 bg-primary/5 rounded-lg text-xs border",children:[e.jsxs("div",{className:"flex justify-between mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Entry Points:"}),e.jsx(Mt,{variant:"secondary",className:"text-[10px] h-4",children:F.length})]}),e.jsxs("div",{className:"flex justify-between mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Fire Lane Edges:"}),e.jsx(Mt,{variant:fe>0?"destructive":"secondary",className:"text-[10px] h-4",children:fe})]}),e.jsxs("div",{className:"flex justify-between mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"EV Stations:"}),e.jsx(Mt,{variant:"secondary",className:"text-[10px] h-4",children:(z.evStations||[]).length})]}),e.jsxs("div",{className:"flex justify-between mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cart Corral
761s:"}),e.jsx(Mt,{variant:"secondary",className:"text-[10px] h-4",children:(z.cartCorrals||[]).length})]}),e.jsxs("div",{className:"flex justify-between mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Bollards:"}),e.jsx(Mt,{variant:"secondary",className:"text-[10px] h-4",children:(z.bollards||[]).length})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Light Poles:"}),e.jsx(Mt,{variant:"secondary",className:"text-[10px] h-4",children:(z.lightPoles||[]).length})]})]})]})}function Fz({overlay:t,onUpdate:s,isUpdating:n}){const a=t.style||{},l=a.parkingCirculation||{},c=l.evStations||[],u=_=>{s({style:{...a,parkingCirculation:{...l,evStations:_}}})},i=()=>{var y;const _=((y=t.geometry)==null?void 0:y.length)>=3?t.geometry.reduce((x,v)=>({lat:x.lat+v.lat/t.geometry.length,lng:x.lng+v.lng/t.geometry.length}),{lat:0,lng:0}):{lat:0,lng:0},j={id:`ev-${Date.now()}`,name:`EV Station ${c.length+1}`,charger_type:"L2",connector_type:"J1772",stall_count:4,position:_,has_ada_access:!1};u([...c,j]),Ve.success("EV station added")};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-xs font-medium flex items-center gap-1.5",children:[e.jsx(Xd,{className:"w-3 h-3 text-primary"})," EV Charging"]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"h-6 text-[10px]",onClick:i,disabled:n,children:[e.jsx(tr,{className:"w-3 h-3 mr-1"})," Add"]})]}),c.map(_=>e.jsxs("div",{className:"p-2 rounded border bg-background space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium",children:_.name}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>u(c.filter(j=>j.id!==_.id)),children:e.jsx(wr,{className:"w-3 h-3 text-destructive"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Charger Type"}),e.jsxs(rt,{value:_.charger_type,onValueChange:j=>u(c.map(y=>y.id===_.id?{...y,charger_type:j}:y)),children:[e.jsx(it,{className:"h-6 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"L2",className:"text-xs",children:"Level 2"}),e.jsx(le,{value:"DC_Fast",className:"text-xs",children:"DC Fast"})]})]})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Connector"}),e.jsxs(rt,{value:_.connector_type,onValueChange:j=>u(c.map(y=>y.id===_.id?{...y,connector_type:j}:y)),children:[e.jsx(it,{className:"h-6 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"J1772",className:"text-xs",children:"J1772"}),e.jsx(le,{value:"CCS",className:"text-xs",children:"CCS"}),e.jsx(le,{value:"CHAdeMO",className:"text-xs",children:"CHAdeMO"}),e.jsx(le,{value:"Tesla",className:"text-xs",children:"Tesla"}),e.jsx(le,{value:"NACS",className:"text-xs",children:"NACS"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Stall Count"}),e.jsx(be,{type:"number",value:_.stall_count,onChange:j=>u(c.map(y=>y.id===_.id?{...y,stall_count:parseInt(j.target.value)||2}:y)),className:"h-6 text-xs",min:1,max:20,disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between pt-3",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"ADA"}),e.jsx(kt,{checked:_.has_ada_access,onCheckedChange:j=>u(c.map(y=>y.id===_.id?{...y,has_ada_access:j}:y)),disabled:n})]})]})]},_.id))]})}function zz({overlay:t,onUpdate:s,isUpdating:n}){const a=t.style||{},l=a.parkingCirculation||{},c=l.cartCorrals||[],u=_=>{s({style:{...a,parkingCirculation:{...l,cartCorrals:_}}})},i=_=>{var v;const j=((v=t.geometry)==null?void 0:v.length)>=3?t.geometry.reduce((C,P)=>({lat:C.lat+P.lat/t.geometry.length,lng:C.lng+P.lng/t.geometry.length}),{lat:0,lng:0}):{lat:0,lng:0},y=Qk[_],x={id:`corral-${Date.now()}`,size:_,capacity:y.capacity,position:j,covered:!1};u([...c,x]),Ve.success(`${y.label} cart corral added`)};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{className:"text-xs font-medium flex items-center gap-1.5",children:[e.jsx(fp,{className:"w-3 h-3 text-primary"}
761)," Cart Corrals"]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:Object.entries(Qk).map(([_,j])=>e.jsxs(Le,{variant:"outline",size:"sm",className:"h-auto py-1.5 flex flex-col text-[10px]",onClick:()=>i(_),disabled:n,children:[e.jsx(tr,{className:"w-3 h-3"}),e.jsx("span",{className:"font-medium capitalize",children:_}),e.jsxs("span",{className:"text-muted-foreground",children:[j.capacity," carts"]})]},_))}),c.map(_=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded border text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fp,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"capitalize",children:_.size}),e.jsxs("span",{className:"text-muted-foreground",children:["(",_.capacity," carts)"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"text-[10px]",children:"Covered"}),e.jsx(kt,{checked:_.covered,onCheckedChange:j=>u(c.map(y=>y.id===_.id?{...y,covered:j}:y)),disabled:n})]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>u(c.filter(j=>j.id!==_.id)),children:e.jsx(wr,{className:"w-3 h-3 text-destructive"})})]})]},_.id))]})}function Oz({overlay:t,onUpdate:s,isUpdating:n}){const a=t.style||{},l=a.parkingCirculation||{},c=l.speedBumps||[],u=_=>{s({style:{...a,parkingCirculation:{...l,speedBumps:_}}})},i=()=>{const _={id:`bump-${Date.now()}`,type:"speed_hump",width_ft:12,height_inches:3,color:"#eab308",has_signage:!0,position_percent:50};u([...c,_]),Ve.success("Speed bump added")};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-xs font-medium flex items-center gap-1.5",children:[e.jsx(ho,{className:"w-3 h-3 text-primary"})," Speed Bumps"]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"h-6 text-[10px]",onClick:i,disabled:n,children:[e.jsx(tr,{className:"w-3 h-3 mr-1"})," Add"]})]}),c.map(_=>e.jsxs("div",{className:"p-2 rounded border bg-background space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(rt,{value:_.type,onValueChange:j=>u(c.map(y=>y.id===_.id?{...y,type:j}:y)),children:[e.jsx(it,{className:"h-6 text-xs w-32",children:e.jsx(ct,{})}),e.jsx(ot,{children:Az.map(j=>e.jsx(le,{value:j.value,className:"text-xs",children:j.label},j.value))})]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>u(c.filter(j=>j.id!==_.id)),children:e.jsx(wr,{className:"w-3 h-3 text-destructive"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Height (in)"}),e.jsx(be,{type:"number",value:_.height_inches,onChange:j=>u(c.map(y=>y.id===_.id?{...y,height_inches:parseFloat(j.target.value)||3}:y)),className:"h-6 text-xs",min:1,max:6,disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between pt-3",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Signage"}),e.jsx(kt,{checked:_.has_signage,onCheckedChange:j=>u(c.map(y=>y.id===_.id?{...y,has_signage:j}:y)),disabled:n})]})]})]},_.id))]})}function Bz({overlay:t,onUpdate:s,isUpdating:n}){const a=t.style||{},l=a.parkingCirculation||{},c=l.crosswalks||[],u=_=>{s({style:{...a,parkingCirculation:{...l,crosswalks:_}}})},i=()=>{const _={id:`xwalk-${Date.now()}`,type:"continental",width_ft:10,has_ada_ramps:!0,has_signage:!0,position_percent:50};u([...c,_]),Ve.success("Crosswalk added")};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-xs font-medium flex items-center gap-1.5",children:[e.jsx(zu,{className:"w-3 h-3 text-primary"})," Crosswalks"]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"h-6 text-[10px]",onClick:i,disabled:n,children:[e.jsx(tr,{className:"w-3 h-3 mr-1"})," Add"]})]}),c.map(_=>e.jsxs("div",{className:"p-2 rounded border bg-background space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(rt,{value:_.type,onValueChange:j=>u(c.map(y=>y.id===_.id?{...y,type:j}:y)),children:[e.jsx(it,{className:"h-6 text-xs w-28",children:e.jsx(ct,{})}),e.jsx(ot,{children:Iz.map(j=>e.jsx(le,{value:j.value,className:"text-xs",children:j.label},j.value))})]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>u(c.filter(j=>j.id!==_.id)),children:e.jsx(wr,{className:"w-3 h-3 text-destructive"})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",value:_.width_ft,onChange:j=>u(c.map(y=>y.id===_.id?{...y,width_ft:parseFloat(j.target.value)||10}:y)),className:"h-6 text-xs",min:6,max:20,disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between pt-3",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"ADA"}),e.jsx(kt,{checked:_.has_ada_ramps,onCheckedChange:j=>u(c.map(y=>y.id===_.id?{...y,has_ada_ramps:j}:y)),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between pt-3",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Signs"}),e.jsx(kt,{checked:_.has_signage,onCheckedChange:j=>u(c.map(y=>y.id===_.id?{...y,has_signage:j}:y)),disabled:n})]})]})]},_.id))]})}function $z({overlay:t,onUpdate:s,isUpdating:n}){const a=t.style||{},l=a.parkingCirculation||{},c=l.stopBars||[],u=j=>{s({style:{...a,parkingCirculation:{...l,stopBars:j}}})},i=()=>{const j={id:`stop-${Date.now()}`,edge_label:"F",position_percent:50,width_ft:4,has_stop_sign:!0,has_do_not_enter_sign:!1};u([...c,j]),Ve.success("Stop bar added")},_=["F","R","S1","S2"];return e.jsx(ns,{title:"Stop Bars",icon:e.jsx(ho,{className:"w-4 h-4"}),badge:c.length>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:c.length}):void 0,defaultOpen:!1,children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full h-7 text-xs",onClick:i,disabled:n,children:[e.jsx(tr,{className:"w-3 h-3 mr-1"})," Add Stop Bar"]}),c.map(j=>e.jsxs("div",{className:"p-2 rounded border bg-background space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(rt,{value:j.edge_label,onValueChange:y=>u(c.map(x=>x.id===j.id?{...x,edge_label:y}:x)),children:[e.jsx(it,{className:"h-6 text-xs w-16",children:e.jsx(ct,{})}),e.jsx(ot,{children:_.map(y=>e.jsx(le,{value:y,className:"text-xs",children:y},y))})]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["@",j.position_percent,"%"]})]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>u(c.filter(y=>
761y.id!==j.id)),children:e.jsx(wr,{className:"w-3 h-3 text-destructive"})})]}),e.jsx(Ca,{value:[j.position_percent],onValueChange:([y])=>u(c.map(x=>x.id===j.id?{...x,position_percent:y}:x)),min:5,max:95,step:1,disabled:n}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Stop Sign"}),e.jsx(kt,{checked:j.has_stop_sign,onCheckedChange:y=>u(c.map(x=>x.id===j.id?{...x,has_stop_sign:y}:x)),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"DNE Sign"}),e.jsx(kt,{checked:j.has_do_not_enter_sign,onCheckedChange:y=>u(c.map(x=>x.id===j.id?{...x,has_do_not_enter_sign:y}:x)),disabled:n})]})]})]},j.id))]})})}function Vz({overlay:t,onUpdate:s,isUpdating:n}){const a=t.style||{},l=a.parkingCirculation||{},c=l.bollards||[],[u,i]=k.useState("fixed"),[_,j]=k.useState("36"),[y,x]=k.useState("6"),[v,C]=k.useState("#888888"),P=F=>{s({style:{...a,parkingCirculation:{...l,bollards:F}}})},I=()=>{if(!t.geometry||t.geometry.length<3)return;const F=t.geometry.reduce((X,K)=>({lat:X.lat+K.lat/t.geometry.length,lng:X.lng+K.lng/t.geometry.length}),{lat:0,lng:0}),D={id:`bollard-${Date.now()}`,position:F,type:u,height_in:parseInt(_)||36,diameter_in:parseInt(y)||6,color:v};P([...c,D]),Ve.success("Bollard added")},z=F=>{P(c.filter(D=>D.id!==F)),Ve.success("Bollard removed")};return e.jsx(ns,{title:"Bollards",icon:e.jsx(t_,{className:"w-4 h-4"}),badge:c.length>0?c.length.toString():void 0,defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Type"}),e.jsxs(rt,{value:u,onValueChange:F=>i(F),children:[e.jsx(it,{className:"h-8",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"fixed",children:"Fixed"}),e.jsx(le,{value:"removable",children:"Removable"}),e.jsx(le,{value:"flexible",children:"Flexible"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Height (in)"}),e.jsx(be,{type:"number",value:_,onChange:F=>j(F.target.value),min:12,max:48,className:"h-8",disabled:n})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Diameter (in)"}),e.jsx(be,{type:"number",value:y,onChange:F=>x(F.target.value),min:4,max:12,className:"h-8",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Color"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{type:"color",value:v,onChange:F=>C(F.target.value),className:"h-8 w-8 rounded border cursor-pointer"}),e.jsx(be,{value:v,onChange:F=>C(F.target.value),className:"h-8 flex-1 font-mono text-xs",disabled:n})]})]})]}),e.jsxs(Le,{onClick:I,size:"sm",className:"w-full",disabled:n,children:[e.jsx(tr,{className:"w-3.5 h-3.5 mr-1.5"})," Add Bollard"]}),c.length>0&&e.jsx("div",{className:"space-y-1.5 max-h-40 overflow-y-auto",children:c.map(F=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded border text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border",style:{backgroundColor:F.color}}),e.jsx("span",{className:"capitalize",children:F.type}),e.jsxs("span",{className:"text-muted-foreground",children:[F.height_in,'"×',F.diameter_in,'"']})]}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>z(F.id),children:e.jsx(wr,{className:"w-3 h-3 text-destructive"})})]},F.id))})]})})}function qz({overlay:t,onUpdate:s,isUpdating:n}){const a=t.style||{},l=a.parkingCirculation||{},c=l.lightPoles||[],[u,i]=k.useState("pole_mounted"),[_,j]=k.useState("25"),[y,x]=k.useState("2"),[v,C]=k.useState("4000K"),P=F=>{s({style:{...a,parkingCirculation:{...l,lightPoles:F}}})},I=()=>{if(!t.geometry||t.geometry.length<3)return;const F=t.geometry.reduce((X,K)=>({lat:X.lat+K.lat/t.geometry.length,lng:X.lng+K.lng/t.geometry.length}),{lat:0,lng:0}),D={id:`light-pole-${Date.now()}`,position:F,fixture_type:u,height_ft:parseInt(_)||25,arm_count:parseInt(y)||2,light_temperature:v,auto_placed:!1};P([...c,D]),Ve.success("Light pole added")},z=F=>{P(c.filter(D=>D.id!==F)),Ve.success("Light pole removed")};return e.jsx(ns,{title:"Light Poles",icon:e.jsx(gh,{className:"w-4 h-4"}),badge:c.length>0?c.length.toString():void 0,defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Fixture Type"}),e.jsxs(rt,{value:u,onValueChange:F=>i(F),children:[e.jsx(it,{className:"h-8",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"pole_mounted",children:"Pole Mounted"}),e.jsx(le,{value:"bollard_light",children:"Bollard Light"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Height (ft)"}
761),e.jsx(be,{type:"number",value:_,onChange:F=>j(F.target.value),min:5,max:40,className:"h-8",disabled:n})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Arms"}),e.jsxs(rt,{value:y,onValueChange:x,children:[e.jsx(it,{className:"h-8",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"1",children:"1 Arm"}),e.jsx(le,{value:"2",children:"2 Arms"}),e.jsx(le,{value:"3",children:"3 Arms"}),e.jsx(le,{value:"4",children:"4 Arms"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Temperature"}),e.jsxs(rt,{value:v,onValueChange:C,children:[e.jsx(it,{className:"h-8",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"3000K",children:"3000K Warm"}),e.jsx(le,{value:"4000K",children:"4000K Neutral"}),e.jsx(le,{value:"5000K",children:"5000K Cool"}),e.jsx(le,{value:"5700K",children:"5700K Daylight"})]})]})]})]}),e.jsxs(Le,{onClick:I,size:"sm",className:"w-full",disabled:n,children:[e.jsx(tr,{className:"w-3.5 h-3.5 mr-1.5"})," Add Light Pole"]}),c.length>0&&e.jsx("div",{className:"space-y-1.5 max-h-40 overflow-y-auto",children:c.map(F=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded border text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gh,{className:"w-3 h-3 text-amber-500"}),e.jsx("span",{className:"capitalize",children:F.fixture_type.replace("_"," ")}),e.jsxs("span",{className:"text-muted-foreground",children:[F.height_ft,"ft · ",F.arm_count," arm",F.arm_count>1?"s":""]})]}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>z(F.id),children:e.jsx(wr,{className:"w-3 h-3 text-destructive"})})]},F.id))})]})})}function lT(t){if(!t||t.length<3)return[];const s=(()=>{const l=[...t];if(l.length>=2){const c=l[0],u=l[l.length-1];c.lat===u.lat&&c.lng===u.lng&&l.pop()}return l})();if(s.length<3)return[];const n=[];for(let l=0;l<s.length;l++){const c=s[l],u=s[(l+1)%s.length],i=Math.sqrt(Math.pow((u.lat-c.lat)*111320,2)+Math.pow((u.lng-c.lng)*111320*Math.cos(c.lat*Math.PI/180),2));n.push({start:c,end:u,length:i,index:l})}const a=[];if(s.length===4){const c=[...n].sort((y,x)=>x.length-y.length)[0],u=(c.index+2)%4,i=(c.index+1)%4,_=(c.index+3)%4,j=["F","F","F","F"];j[c.index]="F",j[u]="R",j[i]="S1",j[_]="S2";for(let y=0;y<4;y++){const x=n[y],v=us([x.start.lng,x.start.lat]),C=us([x.end.lng,x.end.lat]),P=Or(v,C);a.push({label:j[y],start:x.start,end:x.end,bearing:P,length_ft:x.length*3.28084,edgeIndex:y})}}else{const l=s.reduce((D,X)=>({lat:D.lat+X.lat/s.length,lng:D.lng+X.lng/s.length}),{lat:0,lng:0}),c=111320,u=111320*Math.cos(l.lat*Math.PI/180),i=[];for(const D of n){const X={lat:(D.start.lat+D.end.lat)/2,lng:(D.start.lng+D.end.lng)/2},K=(D.end.lng-D.start.lng)*u,te=(D.end.lat-D.start.lat)*c,J=Math.sqrt(K*K+te*te)||1,H=-te/J,O=K/J,q=(X.lng-l.lng)*u,W=(X.lat-l.lat)*c,Q=10,Z=Math.sqrt((q+H*Q)**2+(W+O*Q)**2),oe=Math.sqrt((q-H*Q)**2+(W-O*Q)**2),ce=Z<oe?1:-1;i.push({x:-H*ce,y:-O*ce})}const _=i.map(D=>Math.atan2(D.y,D.x)),j=(D,X)=>Math.atan2(Math.sin(D-X),Math.cos(D-X)),y=25*Math.PI/180;let x=0,v=-1;for(let D=0;D<_.length;D++){let X=0;for(let K=0;K<_.length;K++)Math.abs(j(_[K],_[D]))<=y&&(X+=n[K].length);X>v&&(v=X,x=D)}const C=_[x],P=C+Math.PI,I=i[x],z=I.x/(Math.sqrt(I.x**2+I.y**2)||1),F=I.y/(Math.sqrt(I.x**2+I.y**2)||1);for(let D=0;D<n.length;D++){const X=n[D],K=us([X.start.lng,X.start.lat]),te=us([X.end.lng,X.end.lat]),J=Or(K,te);let H="S1";const O=_[D];if(Math.abs(j(O,C))<=y)H="F";else if(Math.abs(j(O,P))<=y)H="R";else{const q=i[D],W=Math.sqrt(q.x*q.x+q.y*q.y)||1,Q=q.x/W,Z=q.y/W;H=z*Z-F*Q>=0?"S1":"S2"}a.push({label:H,start:X.start,end:X.end,bearing:J,length_ft:X.length*3.28084,edgeIndex:D})}}return a}function Gz(t,s){if(!t||t.length<3||!s)return[];const n=[],a=lT(t);for(const[l,c]of Object.entries(s)){if(!(c!=null&&c.enabled))continue;const u=c.width_ft||20,i=a.filter(_=>_.label===l);for(const _ of i){const j=Hz(_.start,_.end,u,t);j&&j.length>=3&&n.push({type:"fire_lane",geometry:j,sourceId:`fire-lane-${l}-${_.edgeIndex}`,name:`Fire Lane (${l})`})}}return n}function Hz(t,s,n,a){try{const l=us([t.lng,t.lat]),c=us([s.lng,s.lat]),u=Or(l,c),i=a.reduce((H,O)=>
761({lat:H.lat+O.lat/a.length,lng:H.lng+O.lng/a.length}),{lat:0,lng:0}),_={lat:(t.lat+s.lat)/2,lng:(t.lng+s.lng)/2},j=(u+90+360)%360,y=(u-90+360)%360,x=On(us([_.lng,_.lat]),.01,j,{units:"kilometers"}),v=On(us([_.lng,_.lat]),.01,y,{units:"kilometers"}),C=Math.sqrt(Math.pow(x.geometry.coordinates[1]-i.lat,2)+Math.pow(x.geometry.coordinates[0]-i.lng,2)),P=Math.sqrt(Math.pow(v.geometry.coordinates[1]-i.lat,2)+Math.pow(v.geometry.coordinates[0]-i.lng,2)),I=C<P?j:y,z=n*3048e-7,F=t,D=s,X=On(us([s.lng,s.lat]),z,I,{units:"kilometers"}),K=On(us([t.lng,t.lat]),z,I,{units:"kilometers"}),te={lat:X.geometry.coordinates[1],lng:X.geometry.coordinates[0]},J={lat:K.geometry.coordinates[1],lng:K.geometry.coordinates[0]};return[F,D,te,J]}catch(l){return console.warn("[styleBasedExclusions] Failed to buffer edge inward:",l),null}}function Zz(t,s=10){if(!t||!Array.isArray(t))return[];const n=[];for(const a of t){if(a.position_lat==null||a.position_lng==null)continue;const l=(a.placard_width_ft||8)+s*2,c=(a.placard_depth_ft||2)+s*2,u=a.rotation_deg||0,i=Wz(a.position_lat,a.position_lng,l,c,u);i&&i.length>=3&&n.push({type:"signage",geometry:i,sourceId:a.id||`monument-sign-${a.position_lat}-${a.position_lng}`,name:"Monument Sign"})}return n}function Wz(t,s,n,a,l){const c=us([s,t]),u=n/2*3048e-7,i=a/2*3048e-7,_=[l+Math.atan2(i,u)*(180/Math.PI),l+180-Math.atan2(i,u)*(180/Math.PI),l+180+Math.atan2(i,u)*(180/Math.PI),l+360-Math.atan2(i,u)*(180/Math.PI)],j=Math.sqrt(u**2+i**2),y=[];for(const x of _){const v=On(c,j,x,{units:"kilometers"});y.push({lat:v.geometry.coordinates[1],lng:v.geometry.coordinates[0]})}return y}function Yz(t,s){if(!t||t.length<3||!s||!Array.isArray(s))return[];const n=[],a=lT(t);for(const l of s){if(!l.edge_label||l.position_percent==null)continue;const c=l.width_ft||24,u=l.depth_ft||40,i=l.position_percent/100,_=a.filter(x=>x.label===l.edge_label);if(_.length===0)continue;const j=_[0],y=Xz(j.start,j.end,i,c,u,t);y&&y.length>=3&&n.push({type:"entry_point",geometry:y,sourceId:l.id||`entry-${l.edge_label}-${l.position_percent}`,name:`Entry Point (${l.type||"Access"})`})}return n}function Xz(t,s,n,a,l,c){try{const u=us([t.lng,t.lat]),i=us([s.lng,s.lat]),_=Or(u,i),y=gi(u,i,{units:"kilometers"})*Math.max(0,Math.min(1,n)),x=On(u,y,_,{units:"kilometers"}),v={lat:x.geometry.coordinates[1],lng:x.geometry.coordinates[0]},C=c.reduce((Q,Z)=>({lat:Q.lat+Z.lat/c.length,lng:Q.lng+Z.lng/c.length}),{lat:0,lng:0}),P=(_+90+360)%360,I=(_-90+360)%360,z=On(us([v.lng,v.lat]),.01,P,{units:"kilometers"}),F=Math.sqrt(Math.pow(z.geometry.coordinates[1]-C.lat,2)+Math.pow(z.geometry.coordinates[0]-C.lng,2)),D=On(us([v.lng,v.lat]),.01,I,{units:"kilometers"}),X=Math.sqrt(Math.pow(D.geometry.coordinates[1]-C.lat,2)+Math.pow(D.geometry.coordinates[0]-C.lng,2)),K=F<X?P:I,te=a/2*3048e-7,J=l*3048e-7,H=On(us([v.lng,v.lat]),te,_+180,{units:"kilometers"}),O=On(us([v.lng,v.lat]),te,_,{units:"kilometers"}),q=On(H,J,K,{units:"kilometers"}),W=On(O,J,K,{units:"kilometers"});return[{lat:H.geometry.coordinates[1],lng:H.geometry.coordinates[0]},{lat:O.geometry.coordinates[1],lng:O.geometry.coordinates[0]},{lat:W.geometry.coordinates[1],lng:W.geometry.coordinates[0]},{lat:q.geometry.coordinates[1],lng:q.geometry.coordinates[0]}]}catch(u){return console.warn("[styleBasedExclusions] Failed to generate entry road polygon:",u),null}}function cT(t,s){if(!t||t.length<3||!s)return[];const n=[];if(s.fireLanes){const a=Gz(t,s.fireLanes);n.push(...a)}if(s.monument_signs&&Array.isArray(s.monument_signs)){const a=Zz(s.monument_signs);n.push(...a)}if(s.entryPoints&&Array.isArray(s.entryPoints)){const a=Yz(t,s.entryPoints);n.push(...a)}return n}function Kz(t){if(!t)return{fireLanes:0,monumentSigns:0,entryPoints:0};let s=0;if(t.fireLanes){const l=t.fireLanes;s=Object.values(l).filter(c=>c==null?void 0:c.enabled).length}const n=Array.isArray(t.monument_signs)?t.monument_signs.filter(l=>l.position_lat!=null).length:0,a=Array.isArray(t.entryPoints)?t.entryPoints.filter(l=>l.edge_label).length:0;return{fireLanes:s,monumentSigns:n,entryPoints:a}}function Px(t){const s=t.map(n=>[n.lng,n.lat]);return s.length>0&&(s[0][0]!==s[s.length-1][0]||s[0][1]!==s[s.length-1][1])&&s.push([...s[0]]),Xn([s])}function e2(t,s){if(!t||t.length<3)return{netGeometry:null,originalArea_sqft:0,netArea_sqft:0,reductionPercent:0};const n=Px(t),a=zr(n)*10.764;if(!s||s.length===0)return{netGeometry:t,originalArea_sqft:a,netArea_sqft:a,reductionPercent:0};try{let l=n;for(const i of s){if(!i||i.length<3)continue;const _=Px(i);try{const j=pd(l,_);j&&(l=j)}catch{}}const c=zr(l)*10.764;let u=null;return l.geometry.type==="Polygon"&&(u=l.geometry.coordinates[0].slice(0,-1).map(i=>({lat:i[1],lng:i[0]}))),{netGeometry:u,originalArea_sqft:a,netArea_sqft:c,reductionPercent:a>0?(a-c)/a*100:0}}catch(l){return console.error("[AutoFit] Error calculating net area:",l),{netGeometry:t,originalArea_sqft:a,netArea_sqft:a,reductionPercent:0}}}function Jz(t,s,n="single_unified"){const a=[];if(!t||t.length<3)return{polygons:[],totalArea_sqft:0,estimatedS
761paces:0,buildableArea_sqft:0,excludedArea_sqft:0,mode:n,warnings:["No valid buildable area provided"]};const l=Px(t),c=zr(l)*10.764;let u=l,i=0;if(s&&s.length>0){for(const x of s)if(!(!x||x.length<3))try{const v=Px(x),C=zr(v)*10.764;try{const P=pd(u,v);if(P){const I=zr(u)*10.764,z=zr(P)*10.764;i+=I-z,u=P}}catch{try{const I=pd(Un([u,v]));I&&(u=I)}catch{}}}catch(v){a.push(`Failed to subtract exclusion zone: ${v}`)}}const _=[];if(u.geometry.type==="Polygon"){const x=u.geometry.coordinates[0];if(x&&x.length>=3){const v=x.slice(0,-1).map(C=>({lat:C[1],lng:C[0]}));v.length>=3&&_.push(v)}}else if(u.geometry.type==="MultiPolygon"){if(n==="single_unified"){let x=null,v=0;for(const C of u.geometry.coordinates){const P=zr(Xn(C));P>v&&(v=P,x=C[0])}if(x&&x.length>=3){const C=x.slice(0,-1).map(I=>({lat:I[1],lng:I[0]}));_.push(C);const P=u.geometry.coordinates.length-1;P>0&&a.push(`${P} smaller polygon(s) were excluded. Use 'multiple_zones' mode to include them.`)}}else for(const v of u.geometry.coordinates)if(zr(Xn(v))*10.764>=500&&v[0]&&v[0].length>=3){const P=v[0].slice(0,-1).map(I=>({lat:I[1],lng:I[0]}));P.length>=3&&_.push(P)}}let j=0;for(const x of _)j+=zr(Px(x))*10.764;const y=Math.floor(j/350);return _.length===0&&a.push("No viable parking area remaining after subtracting exclusions"),{polygons:_,totalArea_sqft:j,estimatedSpaces:y,buildableArea_sqft:c,excludedArea_sqft:i,mode:n,warnings:a}}function o1(t,s,n={}){const{excludeBuildings:a=!0,excludeBuffers:l=!0,excludeStormwater:c=!0,excludeLandscaping:u=!0,excludeUtilities:i=!0,excludeTrash:_=!0,excludeAccess:j=!0,excludeTruckCourts:y=!0,excludeSignage:x=!0,excludeHardscape:v=!0,excludeCanopies:C=!0,excludeFireLanes:P=!0,excludeEntryPoints:I=!0}=n,z=[],F=ie=>{const de=s.filter(We=>We.parent_overlay_id===ie);let ge=[...de];for(const We of de)ge=[...ge,...F(We.id)];return ge},D=F(t),X=new Set(["building_footprint","building_core","warehouse_bay","retail_pad","office_area","floor_plan"]),K=new Set(["stormwater","detention_basin","retention_pond","bioswale"]),te=new Set(["landscaping","landscape_buffer","tree_save","tree_line"]),J=new Set(["utility_line","utility_corridor"]),H=new Set(["trash_enclosure","dumpster_pad"]),O=new Set(["drive_aisle","curb_cut","circulation_spine","fire_lane","sidewalk"]),q=new Set(["truck_court","loading_berth","trailer_parking"]),W=new Set(["monument_signage","pylon_signage"]),Q=new Set(["hardscape","amenity_area","outdoor_storage","plaza"]),Z=new Set(["canopy","awning","covered_walkway"]),oe=new Set(["easement","access_easement","utility_easement"]),ce=ie=>{const de=ie.toLowerCase();return de.includes("basin")||de.includes("pond")||de.includes("detention")||de.includes("retention")||de.includes("swale")?"stormwater":de.includes("landscape")||de.includes("buffer")||de.includes("tree")||de.includes("planting")?"landscape":de.includes("drive")||de.includes("aisle")||de.includes("fire lane")||de.includes("circulation")?"access":de.includes("truck")||de.includes("loading")||de.includes("trailer")?"truck":de.includes("sign")||de.includes("monument")||de.includes("pylon")?"signage":de.includes("plaza")||de.includes("patio")||de.includes("hardscape")||de.includes("amenity")?"hardscape":de.includes("canopy")||de.includes("awning")||de.includes("covered")?"canopy":de.includes("utility")||de.includes("electric")||de.includes("gas line")||de.includes("water main")?"utility":de.includes("easement")?"easement":de.includes("trash")||de.includes("dumpster")||de.includes("refuse")?"trash":null};for(const ie of D){const de=ie.layer_type||"",ge=ie.name||"",We=ie.geometry,Ee=ce(ge);if(!Array.isArray(We)||We.length<3)continue;const ve=We.map(we=>({lat:typeof we.lat=="number"?we.lat:0,lng:typeof we.lng=="number"?we.lng:0}));a&&X.has(de)&&z.push(ve),c&&(K.has(de)||Ee==="stormwater")&&z.push(ve),u&&(te.has(de)||Ee==="landscape")&&z.push(ve),i&&(J.has(de)||oe.has(de)||Ee==="utility"||Ee==="easement")&&z.push(ve),_&&(H.has(de)||Ee==="trash")&&z.push(ve),j&&(O.has(de)||Ee==="access")&&z.push(ve),y&&(q.has(de)||Ee==="truck")&&z.push(ve),x&&(W.has(de)||Ee==="signage")&&z.push(ve),v&&(Q.has(de)||Ee==="hardscape")&&z.push(ve),C&&(Z.has(de)||Ee==="canopy")&&z.push(ve)}const ae=s.find(ie=>ie.id===t);if(ae!=null&&ae.geometry&&ae.geometry.length>=3&&ae.style){const ie=cT(ae.geometry,ae.style);for(const de of ie)!de.geometry||de.geometry.length<3||de.type==="fire_lane"&&!P||de.type==="entry_point"&&!I||de.type==="signage"&&!x||z.push(de.geometry)}return z}const Mj=new Set(["stormwater","detention_basin","retention_pond","bioswale"]),Ij=new Set(["landscaping","landscape_buffer","tree_save","tree_line"]),Aj=new Set(["drive_aisle","curb_cut","circulation_spine","fire_lane","sidewalk"]),Dj=new Set(["truck_court","loading_berth","trailer_parking"]),Rj=new Set(["monument_signage","pylon_signage"]),Fj=new Set(["hardscape","amenity_area","outdoor_storage","plaza"]),zj=new Set(["canopy","awning","covered_walkway"]),Oj=new Set(["utility_line","utility_corridor"]),Bj=new Set(["easement","access_easement","utility_easement"]),$j=new Set(["trash_enclosure","dumpster_pad"]),vx=9;function oh(t){const s=t.toLowerCase();return s.includes("basin")||s.includes("pond")||s.includes("detention")||s.includes("retention")||s.includes("swale")?"stormwater"
761:s.includes("landscape")||s.includes("buffer")||s.includes("tree")||s.includes("planting")?"landscape":s.includes("drive")||s.includes("aisle")||s.includes("fire lane")||s.includes("circulation")?"access":s.includes("truck")||s.includes("loading")||s.includes("trailer")?"truck":s.includes("sign")||s.includes("monument")||s.includes("pylon")?"signage":s.includes("plaza")||s.includes("patio")||s.includes("hardscape")||s.includes("amenity")?"hardscape":s.includes("canopy")||s.includes("awning")||s.includes("covered")?"canopy":s.includes("utility")||s.includes("electric")||s.includes("gas line")||s.includes("water main")?"utility":s.includes("easement")?"easement":s.includes("trash")||s.includes("dumpster")||s.includes("refuse")?"trash":null}function Dm(t,s){var n,a;if(!t||t.length<2||s<=0)return null;try{const l=t.map(j=>[j.lng,j.lat]),c=l.length>=4&&Math.abs(l[0][0]-l[l.length-1][0])<1e-7&&Math.abs(l[0][1]-l[l.length-1][1])<1e-7,u=s*3048e-7;let i=null;if(c||l.length>=4){const j=[...l];c||j.push([...l[0]]);const y=Xn([j]);i=dl(y,u,{units:"kilometers"})}else{const j=Yd(l);i=dl(j,u,{units:"kilometers"})}const _=(a=(n=i==null?void 0:i.geometry)==null?void 0:n.coordinates)==null?void 0:a[0];if(_&&_.length>=4)return _.slice(0,-1).map(j=>({lat:j[1],lng:j[0]}))}catch(l){console.warn("[parkingExclusionUtils] Buffer operation failed:",l)}return null}function dT(t,s){var c;const n=[],a=new Set;let l=t.parent_overlay_id;for(;l&&!a.has(l);)a.add(l),n.push(l),l=((c=s.get(l))==null?void 0:c.parent_overlay_id)??null;return n}function Qz(t,s,n,a){if(!t.parent_overlay_id)return!0;const l=[s.id,...dT(s,a)];return s.parent_overlay_id&&l.push(s.parent_overlay_id),l.some(c=>n.has(c))}function p_(t){const{parkingOverlay:s,allOverlays:n,settings:a,getBuildingWithBuffer:l}=t,c=[],u=[],i=new Set,_=new Map(n.map(v=>[v.id,v])),j=new Set([s.id,...dT(s,_)]);s.parent_overlay_id&&j.add(s.parent_overlay_id);for(const v of n){if(v.id===s.id||!v.geometry||v.geometry.length<3||!Qz(s,v,j,_))continue;const C=v.layer_type||"",P=v.name||"";if((a.excludeBuildings!==!1||a.excludeBuffers!==!1)&&lu(C)){const I=v.building_buffer_edge_config;if(I!=null){if(a.excludeBuildings!==!1){const F=l?l(v.geometry,vx):Dm(v.geometry,vx);if(F&&u.push(F),a.excludeBuffers!==!1&&Object.keys(I).length>0)try{const D=aT(v.geometry,I,6);for(const{geometry:X}of D)X&&X.length>=3&&c.push(X)}catch{const D=Math.max(0,...Object.values(I).map(X=>Number((X==null?void 0:X.widthFt)??0)));if(D>0){const X=l?l(v.geometry,D):Dm(v.geometry,D);X&&c.push(X)}}i.add("building_buffer")}}else{const F=Number(v.building_buffer_ft??0),D=Math.max(F,vx),X=F>=vx;if(a.excludeBuildings!==!1&&l){const K=l(v.geometry,D);K&&(X?c.push(K):u.push(K),i.add("building_buffer"))}else if(a.excludeBuildings!==!1){const K=Dm(v.geometry,D);K&&(X?c.push(K):u.push(K),i.add("building_buffer"))}}continue}if(a.excludeStormwater!==!1&&(Mj.has(C)||oh(P)==="stormwater")){const I=v.style,z=I==null?void 0:I.stormwaterConfig;if((z==null?void 0:z.type)==="underground")continue;const D=I==null?void 0:I.stormwaterFencing,X=(D==null?void 0:D.enabled)===!0,K=D==null?void 0:D.buffer_ft;if(X&&K&&K>0){const te=K+2,J=Dm(v.geometry,te);c.push(J||v.geometry)}else{const te=Dm(v.geometry,10);c.push(te||v.geometry)}i.add("stormwater");continue}if(a.excludeLandscape!==!1&&(Ij.has(C)||oh(P)==="landscape")){c.push(v.geometry),i.add("landscape");continue}if(a.excludeAccess!==!1&&(Aj.has(C)||oh(P)==="access")){const I=v.circulation_width_ft||12,z=Dm(v.geometry,I);c.push(z||v.geometry),i.add("access");continue}if(a.excludeTruckCourts!==!1&&(Dj.has(C)||oh(P)==="truck")){c.push(v.geometry),i.add("truck_court");continue}if(a.excludeSignage!==!1&&(Rj.has(C)||oh(P)==="signage")){const I=Dm(v.geometry,10);c.push(I||v.geometry),i.add("signage");continue}if(a.excludeHardscape!==!1&&(Fj.has(C)||oh(P)==="hardscape")){c.push(v.geometry),i.add("hardscape");continue}if(a.excludeCanopies!==!1&&(zj.has(C)||oh(P)==="canopy")){c.push(v.geometry),i.add("canopy");continue}if(a.excludeUtilities!==!1&&(Oj.has(C)||oh(P)==="utility")){c.push(v.geometry),i.add("utility");continue}if(a.excludeEasements!==!1&&(Bj.has(C)||oh(P)==="easement")){c.push(v.geometry),i.add("easement");continue}if(a.excludeTrash!==!1&&($j.has(C)||oh(P)==="trash")){const I=Dm(v.geometry,20);c.push(I||v.geometry),i.add("trash");continue}}const y=s.style,x=y==null?void 0:y.manualExclusionZones;if(x&&Array.isArray(x))for(const v of x)v.enabled&&v.geometry&&v.geometry.length>=3&&(c.push(v.geometry),i.add("manual_cutout"));return{zones:c,stallOnlyZones:u,appliedCount:c.length+u.length,types:i}}function g_(t){const s=t.style||{};return{excludeBuildings:t.parking_exclude_buildings!==!1,excludeBuffers:t.parking_exclude_buffers!==!1,excludeStormwater:s.excludeStormwater!==!1,excludeLandscape:s.excludeLandscape!==!1,excludeUtilities:s.excludeUtilities!==!1,excludeTrash:s.excludeTrash!==!1,excludeAccess:s.excludeAccess!==!1,excludeTruckCourts:s.excludeTruckCourts!==!1,excludeSignage:s.excludeSignage!==!1,excludeHardscape:s.excludeHardscape!==!1,excludeCanopies:s.excludeCanopies!==!1,excludeEasements:s.excludeEasements!==!1}}function Uz(t,s){t.appliedCount>0&&console.log(`[${s}] Applied ${t.appliedCount} exclusion zones:`,Array.from(t.types).join(", "))}const eO=Object.freeze(Object.defineProperty({__proto__:null,ACCESS_TYPES:Aj,CANOPY_TYPES:zj,EASEMENT_TYPES:Bj,HARDSCAPE_TYPES:Fj,LANDSCAPE_TYPES:Ij,MIN_VEHICLE_CLEARANCE_FT:vx,SIGNAGE_TYPES:Rj,STORMWATER_TYPES:Mj,TRASH_TYPES:$j,TRUCK_TYPES:Dj,UTILITY_TYPES:Oj,bufferLinearFeature:Dm,collectSmartExclusionZones:p_,getExclusionSettingsFromOverlay:g_,inferConstraintType:
761oh,logExclusionSummary:Uz},Symbol.toStringTag,{value:"Module"}));function Wv(t,s){if(t.length<2||s<=0)return null;try{const n=t.map(c=>[c.lng,c.lat]),a=Yd(n),l=dl(a,s,{units:"feet"});if(l&&l.geometry.type==="Polygon")return l.geometry.coordinates[0].slice(0,-1).map(c=>({lat:c[1],lng:c[0]}))}catch(n){console.error("[SiteConstraintExclusions] Buffer line error:",n)}return null}function l1(t,s){var u;const n=[],a=new Set,l=new Map(s.map(i=>[i.id,i]));let c=t.parent_overlay_id;for(;c&&!a.has(c);)a.add(c),n.push(c),c=((u=l.get(c))==null?void 0:u.parent_overlay_id)??null;return n}function iu(t,s,n){if(!s.parent_overlay_id)return!0;const a=new Set([s.id,...l1(s,n)]);s.parent_overlay_id&&a.add(s.parent_overlay_id);const l=[t.id,...l1(t,n)];return t.parent_overlay_id&&l.push(t.parent_overlay_id),l.some(c=>a.has(c))}const uT=(t,s)=>{var _,j,y,x,v,C,P,I,z,F,D,X,K;const{data:n=[]}=Cp(),a={excludeBuildings:(t==null?void 0:t.parking_exclude_buildings)!==!1,excludeBuffers:(t==null?void 0:t.parking_exclude_buffers)!==!1,excludeStormwater:((_=t==null?void 0:t.style)==null?void 0:_.excludeStormwater)!==!1,excludeLandscape:((j=t==null?void 0:t.style)==null?void 0:j.excludeLandscape)!==!1,excludeUtilities:((y=t==null?void 0:t.style)==null?void 0:y.excludeUtilities)!==!1,excludeTrash:((x=t==null?void 0:t.style)==null?void 0:x.excludeTrash)!==!1,excludeCurbCuts:((v=t==null?void 0:t.style)==null?void 0:v.excludeCurbCuts)!==!1,excludeEasements:((C=t==null?void 0:t.style)==null?void 0:C.excludeEasements)===!0,excludeAccess:((P=t==null?void 0:t.style)==null?void 0:P.excludeAccess)!==!1,excludeTruckCourts:((I=t==null?void 0:t.style)==null?void 0:I.excludeTruckCourts)!==!1,excludeSignage:((z=t==null?void 0:t.style)==null?void 0:z.excludeSignage)!==!1,excludeHardscape:((F=t==null?void 0:t.style)==null?void 0:F.excludeHardscape)!==!1,excludeCanopies:((D=t==null?void 0:t.style)==null?void 0:D.excludeCanopies)!==!1,excludeFireLanes:((X=t==null?void 0:t.style)==null?void 0:X.excludeFireLanes)!==!1,excludeEntryPoints:((K=t==null?void 0:t.style)==null?void 0:K.excludeEntryPoints)!==!1},l=k.useMemo(()=>{if(!t)return{buildings:[],stormwater:[],landscape:[],utilities:[],trash:[],curbCuts:[],easements:[],access:[],truck:[],signage:[],hardscape:[],canopy:[]};const te=(ge,We,Ee)=>{const ve=ge.layer_type||"",we=ge.name||"";return We.has(ve)||oh(we)===Ee},J=n.filter(ge=>ge.id!==t.id&&lu(ge.layer_type||"")&&ge.geometry&&ge.geometry.length>=3&&iu(ge,t,n)),H=n.filter(ge=>ge.id!==t.id&&te(ge,Mj,"stormwater")&&ge.geometry&&ge.geometry.length>=3&&iu(ge,t,n)),O=n.filter(ge=>ge.id!==t.id&&te(ge,Ij,"landscape")&&ge.geometry&&ge.geometry.length>=3&&iu(ge,t,n)),q=n.filter(ge=>ge.id!==t.id&&te(ge,Oj,"utility")&&ge.geometry&&ge.geometry.length>=2&&iu(ge,t,n)),W=n.filter(ge=>ge.id!==t.id&&te(ge,$j,"trash")&&ge.geometry&&ge.geometry.length>=3&&iu(ge,t,n)),Q=n.filter(ge=>ge.id!==t.id&&ge.layer_type==="curb_cut"&&ge.geometry&&ge.geometry.length>=3&&iu(ge,t,n)),Z=n.filter(ge=>ge.id!==t.id&&te(ge,Bj,"easement")&&ge.geometry&&ge.geometry.length>=3&&iu(ge,t,n)),oe=n.filter(ge=>ge.id!==t.id&&te(ge,Aj,"access")&&ge.geometry&&ge.geometry.length>=2&&iu(ge,t,n)),ce=n.filter(ge=>ge.id!==t.id&&te(ge,Dj,"truck")&&ge.geometry&&ge.geometry.length>=3&&iu(ge,t,n)),ae=n.filter(ge=>ge.id!==t.id&&te(ge,Rj,"signage")&&ge.geometry&&ge.geometry.length>=3&&iu(ge,t,n)),ie=n.filter(ge=>ge.id!==t.id&&te(ge,Fj,"hardscape")&&ge.geometry&&ge.geometry.length>=3&&iu(ge,t,n)),de=n.filter(ge=>ge.id!==t.id&&te(ge,zj,"canopy")&&ge.geometry&&ge.geometry.length>=3&&iu(ge,t,n));return{buildings:J,stormwater:H,landscape:O,utilities:q,trash:W,curbCuts:Q,easements:Z,access:oe,truck:ce,signage:ae,hardscape:ie,canopy:de}},[n,t]),c=k.useMemo(()=>{if(!t)return{exclusions:[],counts:{fireLanes:0,monumentSigns:0,entryPoints:0}};const te=[];let J={fireLanes:0,monumentSigns:0,entryPoints:0};const H=l1(t,n),O=t.parent_overlay_id?[t.parent_overlay_id,...H]:H;for(const q of O){const W=n.find(ae=>ae.id===q);if(!W||!W.geometry||W.geometry.length<3)continue;const Q=W.style;if(!Q)continue;const oe=cT(W.geometry,Q).filter(ae=>!(ae.type==="fire_lane"&&!a.excludeFireLanes||ae.type==="entry_point"&&!a.excludeEntryPoints||ae.type==="signage"&&!a.excludeSignage));te.push(...oe);const ce=Kz(Q);J.fireLanes+=ce.fireLanes,J.monumentSigns+=ce.monumentSigns,J.entryPoints+=ce.entryPoints}return{exclusions:te,counts:J}},[t,n,a.excludeFireLanes,a.excludeEntryPoints,a.excludeSignage]),u=k.useMemo(()=>{var O,q,W,Q;if(!t)return{exclusionZones:[],mergedExclusions:[],hasExclusions:!1,buildingLayers:[],stormwaterLayers:[],landscapeLayers:[],utilityLayers:[],trashLayers:[],curbCutLayers:[],easementLayers:[],accessLayers:[],truckLayers:[],signageLayers:[],hardscapeLayers:[],canopyLayers:[],styleBasedExclusions:[],styleBasedCounts:{fireLanes:0,monumentSigns:0,entryPoints:0}};const te=[],J=[];
761if(a.excludeBuildings||a.excludeBuffers)for(const Z of l.buildings){if(!Z.geometry||Z.geometry.length<3)continue;const oe=Z.building_buffer_edge_config,ce=oe?Math.max(0,...Object.values(oe).map(ge=>Number((ge==null?void 0:ge.widthFt)??0))):0,ae=Number(Z.building_buffer_ft??0),ie=Math.max(ae,ce);if(a.excludeBuffers&&ie>0){const ge=wf(Z.geometry,ie);ge&&(te.push({id:`${Z.id}-combined`,name:`${Z.name} + Buffer`,type:"combined",geometry:ge,sourceLayerId:Z.id}),J.push(ge))}else a.excludeBuildings&&(te.push({id:Z.id,name:Z.name,type:"building",geometry:Z.geometry,sourceLayerId:Z.id}),J.push(Z.geometry))}if(a.excludeStormwater)for(const Z of l.stormwater){if(!Z.geometry||Z.geometry.length<3)continue;const oe=Z.style,ce=oe==null?void 0:oe.stormwaterConfig;if((ce==null?void 0:ce.type)==="underground")continue;const de=Wv(Z.geometry,10)||Z.geometry;te.push({id:Z.id,name:Z.name||"Stormwater",type:"stormwater",geometry:de,sourceLayerId:Z.id}),J.push(de)}if(a.excludeLandscape)for(const Z of l.landscape)!Z.geometry||Z.geometry.length<3||(te.push({id:Z.id,name:Z.name||"Landscape Buffer",type:"landscape_buffer",geometry:Z.geometry,sourceLayerId:Z.id}),J.push(Z.geometry));if(a.excludeUtilities)for(const Z of l.utilities){if(!Z.geometry||Z.geometry.length<2)continue;const oe=((O=Z.style)==null?void 0:O.corridorWidth_ft)||10,ce=Wv(Z.geometry,oe/2);ce&&(te.push({id:Z.id,name:Z.name||"Utility Corridor",type:"utility_line",geometry:ce,sourceLayerId:Z.id}),J.push(ce))}if(a.excludeTrash)for(const Z of l.trash){if(!Z.geometry||Z.geometry.length<3)continue;const oe=((q=Z.style)==null?void 0:q.accessBuffer_ft)||20,ce=wf(Z.geometry,oe);ce?(te.push({id:Z.id,name:`${Z.name||"Trash Enclosure"} + Access`,type:"trash_enclosure",geometry:ce,sourceLayerId:Z.id}),J.push(ce)):(te.push({id:Z.id,name:Z.name||"Trash Enclosure",type:"trash_enclosure",geometry:Z.geometry,sourceLayerId:Z.id}),J.push(Z.geometry))}if(a.excludeCurbCuts)for(const Z of l.curbCuts)!Z.geometry||Z.geometry.length<3||(te.push({id:Z.id,name:Z.name||"Curb Cut",type:"curb_cut",geometry:Z.geometry,sourceLayerId:Z.id}),J.push(Z.geometry));if(a.excludeEasements)for(const Z of l.easements)!Z.geometry||Z.geometry.length<3||(te.push({id:Z.id,name:Z.name||"Easement",type:"easement",geometry:Z.geometry,sourceLayerId:Z.id}),J.push(Z.geometry));if(a.excludeAccess)for(const Z of l.access){if(!Z.geometry||Z.geometry.length<2)continue;const oe=((W=Z.style)==null?void 0:W.width_ft)||12,ce=Wv(Z.geometry,oe/2);ce?(te.push({id:Z.id,name:Z.name||"Drive Aisle",type:"access",geometry:ce,sourceLayerId:Z.id}),J.push(ce)):Z.geometry.length>=3&&(te.push({id:Z.id,name:Z.name||"Drive Aisle",type:"access",geometry:Z.geometry,sourceLayerId:Z.id}),J.push(Z.geometry))}if(a.excludeTruckCourts)for(const Z of l.truck)!Z.geometry||Z.geometry.length<3||(te.push({id:Z.id,name:Z.name||"Truck Court",type:"truck_court",geometry:Z.geometry,sourceLayerId:Z.id}),J.push(Z.geometry));if(a.excludeSignage)for(const Z of l.signage){if(!Z.geometry||Z.geometry.length<3)continue;const oe=((Q=Z.style)==null?void 0:Q.clearance_ft)||10,ce=wf(Z.geometry,oe);ce?(te.push({id:Z.id,name:`${Z.name||"Monument Sign"} + Clearance`,type:"signage",geometry:ce,sourceLayerId:Z.id}),J.push(ce)):(te.push({id:Z.id,name:Z.name||"Monument Sign",type:"signage",geometry:Z.geometry,sourceLayerId:Z.id}),J.push(Z.geometry))}if(a.excludeHardscape)for(const Z of l.hardscape)!Z.geometry||Z.geometry.length<3||(te.push({id:Z.id,name:Z.name||"Hardscape",type:"hardscape",geometry:Z.geometry,sourceLayerId:Z.id}),J.push(Z.geometry));if(a.excludeCanopies)for(const Z of l.canopy)!Z.geometry||Z.geometry.length<3||(te.push({id:Z.id,name:Z.name||"Canopy",type:"canopy",geometry:Z.geometry,sourceLayerId:Z.id}),J.push(Z.geometry));for(const Z of c.exclusions)Z.geometry&&Z.geometry.length>=3&&(te.push({id:Z.sourceId||`style-${Z.type}`,name:Z.name||Z.type,type:Z.type,geometry:Z.geometry}),J.push(Z.geometry));const H=J.length>0?f0(J):[];return{exclusionZones:te,mergedExclusions:H,hasExclusions:te.length>0||c.exclusions.length>0,buildingLayers:l.buildings,stormwaterLayers:l.stormwater,landscapeLayers:l.landscape,utilityLayers:l.utilities,trashLayers:l.trash,curbCutLayers:l.curbCuts,easementLayers:l.easements,accessLayers:l.access,truckLayers:l.truck,signageLayers:l.signage,hardscapeLayers:l.hardscape,canopyLayers:l.canopy,styleBasedExclusions:c.exclusions,styleBasedCounts:c.counts}},[t,l,a,c]),i=k.useCallback((te,J)=>{var ce,ae,ie,de,ge,We,Ee,ve,we,Ze,ke,ze,Ke;const H=n.find(dt=>dt.id===te);
761if(!H)return{exclusionZones:[],mergedExclusions:[],hasExclusions:!1,buildingLayers:[],stormwaterLayers:[],landscapeLayers:[],utilityLayers:[],trashLayers:[],curbCutLayers:[],easementLayers:[],accessLayers:[],truckLayers:[],signageLayers:[],hardscapeLayers:[],canopyLayers:[],styleBasedExclusions:[],styleBasedCounts:{fireLanes:0,monumentSigns:0,entryPoints:0}};const O=n.filter(dt=>dt.id!==te&&dt.layer_type==="building_footprint"&&dt.geometry&&dt.geometry.length>=3&&iu(dt,H,n)),q=n.filter(dt=>dt.id!==te&&dt.layer_type==="stormwater"&&dt.geometry&&dt.geometry.length>=3&&iu(dt,H,n)),W=[],Q=[],Z={excludeBuildings:(J==null?void 0:J.excludeBuildings)??(H==null?void 0:H.parking_exclude_buildings)!==!1,excludeBuffers:(J==null?void 0:J.excludeBuffers)??(H==null?void 0:H.parking_exclude_buffers)!==!1,excludeStormwater:(J==null?void 0:J.excludeStormwater)??((ce=H==null?void 0:H.style)==null?void 0:ce.excludeStormwater)!==!1,excludeLandscape:(J==null?void 0:J.excludeLandscape)??((ae=H==null?void 0:H.style)==null?void 0:ae.excludeLandscape)!==!1,excludeUtilities:(J==null?void 0:J.excludeUtilities)??((ie=H==null?void 0:H.style)==null?void 0:ie.excludeUtilities)!==!1,excludeTrash:(J==null?void 0:J.excludeTrash)??((de=H==null?void 0:H.style)==null?void 0:de.excludeTrash)!==!1,excludeCurbCuts:(J==null?void 0:J.excludeCurbCuts)??((ge=H==null?void 0:H.style)==null?void 0:ge.excludeCurbCuts)!==!1,excludeEasements:(J==null?void 0:J.excludeEasements)??((We=H==null?void 0:H.style)==null?void 0:We.excludeEasements)===!0,excludeAccess:(J==null?void 0:J.excludeAccess)??((Ee=H==null?void 0:H.style)==null?void 0:Ee.excludeAccess)!==!1,excludeTruckCourts:(J==null?void 0:J.excludeTruckCourts)??((ve=H==null?void 0:H.style)==null?void 0:ve.excludeTruckCourts)!==!1,excludeSignage:(J==null?void 0:J.excludeSignage)??((we=H==null?void 0:H.style)==null?void 0:we.excludeSignage)!==!1,excludeHardscape:(J==null?void 0:J.excludeHardscape)??((Ze=H==null?void 0:H.style)==null?void 0:Ze.excludeHardscape)!==!1,excludeCanopies:(J==null?void 0:J.excludeCanopies)??((ke=H==null?void 0:H.style)==null?void 0:ke.excludeCanopies)!==!1,excludeFireLanes:(J==null?void 0:J.excludeFireLanes)??((ze=H==null?void 0:H.style)==null?void 0:ze.excludeFireLanes)!==!1,excludeEntryPoints:(J==null?void 0:J.excludeEntryPoints)??((Ke=H==null?void 0:H.style)==null?void 0:Ke.excludeEntryPoints)!==!1};if(Z.excludeBuildings||Z.excludeBuffers)for(const dt of O){if(!dt.geometry||dt.geometry.length<3)continue;const Re=dt.building_buffer_ft||0;if(Z.excludeBuffers&&Re>0){const ft=wf(dt.geometry,Re);ft&&(W.push({id:`${dt.id}-combined`,name:`${dt.name} + Buffer`,type:"combined",geometry:ft,sourceLayerId:dt.id}),Q.push(ft))}else Z.excludeBuildings&&(W.push({id:dt.id,name:dt.name,type:"building",geometry:dt.geometry,sourceLayerId:dt.id}),Q.push(dt.geometry))}if(Z.excludeStormwater)for(const dt of q)!dt.geometry||dt.geometry.length<3||(W.push({id:dt.id,name:dt.name||"Stormwater",type:"stormwater",geometry:dt.geometry,sourceLayerId:dt.id}),Q.push(dt.geometry));const oe=Q.length>0?f0(Q):[];return{exclusionZones:W,mergedExclusions:oe,hasExclusions:W.length>0,buildingLayers:O,stormwaterLayers:q,landscapeLayers:[],utilityLayers:[],trashLayers:[],curbCutLayers:[],easementLayers:[],accessLayers:[],truckLayers:[],signageLayers:[],hardscapeLayers:[],canopyLayers:[],styleBasedExclusions:[],styleBasedCounts:{fireLanes:0,monumentSigns:0,entryPoints:0}}},[n]);return{...u,getExclusionZonesForParking:i,settings:a}},Yv={customer:{label:"Customer",icon:Ml,color:"bg-slate-500",description:"Front-facing visitor/customer parking"},employee:{label:"Employee",icon:yl,color:"bg-orange-500",description:"Staff/employee parking, typically rear or side"},ada:{label:"ADA Accessible",icon:fh,color:"bg-blue-500",description:"Accessible parking near main entry"},overflow:{label:"Overflow",icon:fm,color:"bg-amber-500",description:"Remote/overflow parking for peak times"},reserved:{label:"Reserved",icon:pm,color:"bg-purple-500",description:"Reserved/VIP parking spaces"}};function tO({overlay:t,allOverlays:s,onUpdate:n,isUpdating:a,hideHeader:l=!1,onStartCutoutDrawing:c,renderMode:u="full"}){const{mergedExclusions:i,buildingLayers:_,stormwaterLayers:j,landscapeLayers:y,utilityLayers:x,trashLayers:v,curbCutLayers:C,easementLayers:P,accessLayers:I,truckLayers:z,signageLayers:F,hardscapeLayers:D,canopyLayers:X}=uT(t),K=t.style||{},te=K.excludeStormwater!==!1,J=K.excludeLandscape!==!1,H=K.excludeUtilities!==!1,O=K.excludeTrash!==!1,q=K.excludeCurbCuts!==!1,W=K.excludeEasements===!0,Q=K.excludeAccess!==!1,Z=K.excludeTruckCourts!==!1,oe=K.excludeSignage!==!1,ce=K.excludeHardscape!==!1,ae=K.excludeCanopies!==!1,ie=k.useMemo(()=>s.filter(Fe=>{const fe=Fe.style;return(fe==null?void 0:fe.entryPoints)&&Array.isArray(fe.entryPoints)&&fe.entryPoints.length>0}),[s]),de=k.useMemo(()=>
761t.parent_overlay_id?s.find(ft=>ft.id===t.parent_overlay_id):null,[t.parent_overlay_id,s]),ge=t.layer_type==="parking_zone",We=t.layer_type==="parking_field"||t.layer_type==="parking",Ee=k.useMemo(()=>t.parent_overlay_id?s.filter(ft=>ft.parent_overlay_id===t.parent_overlay_id&&ft.layer_type==="parking_zone"&&ft.id!==t.id):[],[s,t.parent_overlay_id,t.id]),ve=t.parking_zone_type,we=ve?Yv[ve]:null,Ze=lc(),ke=k.useMemo(()=>{var Gs;if(!t.geometry||t.geometry.length<3)return 0;const ft=t.parking_exclude_buildings!==!1,Fe=t.parking_exclude_buffers!==!1,fe=t.style||{},Qe=fe.excludeStormwater!==!1,ht=fe.excludeLandscape!==!1,_t=fe.excludeUtilities!==!1,He=fe.excludeTrash!==!1,as=fe.excludeAccess!==!1,vt=fe.excludeTruckCourts!==!1,Xe=fe.excludeSignage!==!1,Ce=fe.excludeHardscape!==!1,Be=fe.excludeCanopies!==!1,Dt=new Set(["stormwater","detention_basin","retention_pond","bioswale"]),Rt=new Set(["landscaping","landscape_buffer","tree_save"]),zt=new Set(["utility_line","easement"]),rs=new Set(["trash_enclosure"]),_s=new Set(["drive_aisle","curb_cut","circulation_spine","fire_lane","sidewalk"]),vs=new Set(["truck_court","loading_berth","trailer_parking"]),$t=new Set(["monument_signage"]),Ns=new Set(["hardscape","amenity_area","outdoor_storage"]),Ts=new Set(["canopy"]),bs=new Map(s.map(Ue=>[Ue.id,Ue])),en=Ue=>{var De;const Pe=[],je=new Set;let Ge=Ue.parent_overlay_id;for(;Ge&&!je.has(Ge);)je.add(Ge),Pe.push(Ge),Ge=((De=bs.get(Ge))==null?void 0:De.parent_overlay_id)??null;return Pe},Jt=new Set([t.id,...en(t)]);t.parent_overlay_id&&Jt.add(t.parent_overlay_id);const Vs=Ue=>{if(!t.parent_overlay_id)return!0;const Pe=[Ue.id,...en(Ue)];return Ue.parent_overlay_id&&Pe.push(Ue.parent_overlay_id),Pe.some(je=>Jt.has(je))},ps=[];for(const Ue of s){if(Ue.id===t.id||!Ue.geometry||Ue.geometry.length<3||!Vs(Ue))continue;const Pe=Ue.layer_type;if((ft||Fe)&&Pe==="building_footprint"){const je=Ue.building_buffer_edge_config,Ge=je?Math.max(0,...Object.values(je).map(pe=>Number((pe==null?void 0:pe.widthFt)??0))):0,De=Number(Ue.building_buffer_ft??0),bt=Math.max(De,Ge);if(Fe&&bt>0){const pe=wf(Ue.geometry,bt);pe&&ps.push(pe)}else ft&&ps.push(Ue.geometry)}Qe&&Pe&&Dt.has(Pe)&&ps.push(Ue.geometry),ht&&Pe&&Rt.has(Pe)&&ps.push(Ue.geometry),_t&&Pe&&zt.has(Pe)&&ps.push(Ue.geometry),He&&Pe&&rs.has(Pe)&&ps.push(Ue.geometry),as&&Pe&&_s.has(Pe)&&ps.push(Ue.geometry),vt&&Pe&&vs.has(Pe)&&ps.push(Ue.geometry),Xe&&Pe&&$t.has(Pe)&&ps.push(Ue.geometry),Ce&&Pe&&Ns.has(Pe)&&ps.push(Ue.geometry),Be&&Pe&&Ts.has(Pe)&&ps.push(Ue.geometry)}const nt=fe.manualExclusionZones||[];for(const Ue of nt)Ue.enabled&&Ue.geometry&&Ue.geometry.length>=3&&ps.push(Ue.geometry);const ts=ps.length>0?f0(ps):[];let ds=Hm(t.geometry,{stallWidth_ft:t.parking_stall_width_ft||9,stallDepth_ft:t.parking_stall_depth_ft||18,aisleWidth_ft:t.parking_aisle_width_ft||t.circulation_width_ft||24,layoutType:t.parking_layout_type||"double_loaded",stripingVisible:!0,aisleLabelsVisible:!0,exclusionZones:ts});const Is=(Gs=t.style)==null?void 0:Gs.parkingCirculation,tn=Is==null?void 0:Is.stallOverrides,wn=Is==null?void 0:Is.rowOverrides;return(tn&&Object.keys(tn).length>0||wn&&Object.keys(wn).length>0)&&(ds=H0(ds,tn||{},wn||{})),ds.metrics.totalSpaces},[t,s]),[ze,Ke]=k.useState(!1),dt=k.useCallback(async()=>{var ft;Ke(!0);try{console.log("[GenerateLayout] Starting consolidated generation...");const Fe=t.style||{},fe=Fe.parkingCirculation||{},Qe=t.parking_stall_width_ft||9,ht=t.parking_stall_depth_ft||18,_t=t.parking_aisle_width_ft||t.circulation_width_ft||24,He=t.parking_layout_type||"double_loaded",as=Fe.parking_max_stall_run||null,vt=Fe.parking_island_type||"painted",Xe=Fe.parking_island_width_ft||(vt==="landscape"?6:4),Ce=Fe.parking_island_trees??!1,Be=de!=null&&de.setback_geometry?Df(de.setback_geometry):null,Dt=(ft=Be==null?void 0:Be.innerPolygon)==null?void 0:ft[0],Rt=Dt==null?void 0:Dt.map(Jt=>({lat:Jt[1],lng:Jt[0]}));let zt=t.geometry;if(Rt&&Rt.length>=3){console.log("[GenerateLayout] Using parent buildable area for site-wide expansion");const Jt=o1((de==null?void 0:de.id)||t.parent_overlay_id||t.id,s,{excludeBuildings:t.parking_exclude_buildings!==!1,excludeBuffers:t.parking_exclude_buffers!==!1,excludeStormwater:Fe.excludeStormwater!==!1,excludeLandscaping:Fe.excludeLandscape!==!1,excludeUtilities:Fe.excludeUtilities!==!1,excludeTrash:Fe.excludeTrash!==!1,excludeAccess:Fe.excludeAccess!==!1,excludeTruckCourts:Fe.excludeTruckCourts!==!1,excludeSignage:Fe.excludeSignage!==!1,excludeHardscape:Fe.excludeHardscape!==!1,excludeCanopies:Fe.excludeCanopies!==!1}),Vs=e2(Rt,Jt);Vs.netGeometry&&Vs.netGeometry.length>=3?zt=Vs.netGeometry:console.log("[GenerateLayout] Net geometry invalid, using current polygon")}else if(!t.geometry||t.geometry.length<3){Ve.error("Parking area needs at least 3 points");return}if(!zt||zt.length<3){Ve.error("No valid parking geometry available");return}const rs=s.filter(Jt=>
761Jt.parent_overlay_id===t.parent_overlay_id&&Jt.layer_type==="building_footprint"&&Jt.geometry&&Jt.geometry.length>=3),_s=[];t.parking_exclude_buildings!==!1&&rs.forEach(Jt=>{Jt.geometry&&_s.push(Jt.geometry)});const $t=hP(zt,{stallWidth_ft:Qe,stallDepth_ft:ht,aisleWidth_ft:_t,layoutType:He,stripingVisible:!0,aisleLabelsVisible:!0,exclusionZones:_s,maxStallRun:as??void 0,islandType:vt,islandWidth_ft:Xe,islandTrees:Ce}),Ns=$t.layout.metrics.totalSpaces,Ts=$t.layout.metrics.islandCount||0,bs={parking_generated_spaces:Ns,parking_ada_count:$t.layout.metrics.adaSpaces,parking_spaces:Ns,parking_stall_width_ft:Qe,parking_stall_depth_ft:ht,parking_aisle_width_ft:_t,parking_layout_type:He,parking_striping_visible:!0,updated_at:new Date().toISOString(),style:{...Fe,parking_max_stall_run:as,parking_island_type:vt,parking_island_width_ft:Xe,parking_island_trees:Ce,parkingCirculation:{...fe,stallOverrides:{}}}};zt!==t.geometry&&(bs.geometry=zt),n(bs),await Ze.invalidateQueries({queryKey:["map-overlays"]});const en=Ts>0?` with ${Ts} islands`:"";Ve.success(`Generated ${Ns} parking spaces${en}`)}catch(Fe){console.error("Generate layout error:",Fe),Ve.error("Layout generation failed")}finally{Ke(!1)}},[t,s,n,de,Ze]),Re=k.useMemo(()=>t.parking_connected_entry_id?s.find(ft=>ft.id===t.parking_connected_entry_id):null,[t.parking_connected_entry_id,s]);if(!ge&&!We)return null;if(u==="generate_only")return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:[ke," spaces"]}),t.parking_zone_target_count&&ke<t.parking_zone_target_count&&e.jsxs(Mt,{variant:"destructive",className:"text-[10px]",children:["-",t.parking_zone_target_count-ke," deficit"]})]}),e.jsx(Le,{variant:"default",size:"sm",className:"w-full",onClick:dt,disabled:ze||a||!t.geometry||t.geometry.length<3,children:ze?e.jsxs(e.Fragment,{children:[e.jsx(Va,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Nf,{className:"w-4 h-4 mr-2"}),"Generate Layout"]})})]});const qt=e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Zone Purpose"}),e.jsxs(rt,{value:ve||"",onValueChange:ft=>n({parking_zone_type:ft}),disabled:a,children:[e.jsx(it,{className:"h-9",children:e.jsx(ct,{placeholder:"Select zone purpose..."})}),e.jsx(ot,{children:Object.entries(Yv).map(([ft,Fe])=>{const fe=Fe.icon;return e.jsx(le,{value:ft,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{className:"w-4 h-4"}),e.jsx("span",{children:Fe.label})]})},ft)})})]}),we&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:we.description})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Target Spaces"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{type:"number",value:t.parking_zone_target_count||"",onChange:ft=>n({parking_zone_target_count:ft.target.value?parseInt(ft.target.value):null}),placeholder:"Maximize",className:"h-8",disabled:a}),e.jsxs(Mt,{variant:"outline",className:"shrink-0 text-[10px]",children:[ke," actual"]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Leave empty to maximize spaces within zone boundary"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(uo,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Connected Entry Point"})]}),e.jsxs(rt,{value:t.parking_connected_entry_id||"__none__",onValueChange:ft=>n({parking_connected_entry_id:ft==="__none__"?null:ft}),disabled:a,children:[e.jsx(it,{className:"h-9",children:e.jsx(ct,{placeholder:"Not connected"})}),e.jsxs(ot,{children:[e.jsx(le,{value:"__none__",children:"Not connected"}),ie.length>0?ie.map(ft=>e.jsx(le,{value:ft.id,children:ft.name||`Entry Point ${ft.id.slice(0,6)}`},ft.id)):e.jsx(le,{value:"__no_entries__",disabled:!0,children:"No entry points defined"})]})]}),Re&&e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Drive aisle will route from ",Re.name||"entry"," to this zone"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Drive Aisle Width (ft)"}),e.jsx(be,{type:"number",value:t.circulation_width_ft||t.parking_aisle_width_ft||"",onChange:ft=>
761n({circulation_width_ft:ft.target.value?parseFloat(ft.target.value):null}),placeholder:"24",className:"h-8",disabled:a})]}),e.jsxs("div",{className:"space-y-2 border-t pt-3",children:[e.jsx(B,{className:"text-xs font-medium",children:"Edge Placement Mode"}),e.jsxs(rt,{value:K.edgePlacementMode||"longest_edge",onValueChange:ft=>{const Fe=t.style||{};n({style:{...Fe,edgePlacementMode:ft}})},disabled:a,children:[e.jsx(it,{className:"h-9",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"longest_edge",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pm,{className:"w-4 h-4"}),e.jsx("span",{children:"Longest Edge Only"})]})}),e.jsx(le,{value:"all_edges",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fm,{className:"w-4 h-4"}),e.jsx("span",{children:"All Edges"})]})}),e.jsx(le,{value:"perimeter_priority",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(uo,{className:"w-4 h-4"}),e.jsx("span",{children:"Perimeter Priority"})]})})]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:K.edgePlacementMode==="all_edges"?"Places stalls along all suitable edges for maximum capacity":K.edgePlacementMode==="perimeter_priority"?"Fills edges first (longest to shortest), then interior":"Aligns all rows parallel to the longest edge (default)"})]}),e.jsxs("div",{className:"space-y-2 border-t pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Nf,{className:"w-3.5 h-3.5 text-primary"}),e.jsx(B,{className:"text-xs font-medium",children:"Generate Layout"})]}),e.jsx(Le,{variant:"default",size:"sm",className:"w-full",onClick:dt,disabled:ze||a||!t.geometry||t.geometry.length<3,children:ze?e.jsxs(e.Fragment,{children:[e.jsx(Va,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Nf,{className:"w-4 h-4 mr-2"}),"Generate Layout"]})}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Builds the optimal parking layout using current settings. Fills the buildable site area and clears manual overrides."})]}),e.jsxs("div",{className:"space-y-3 border-t pt-3",children:[e.jsx(B,{className:"text-xs font-medium",children:"Site Constraint Exclusions"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Subtract these layers from parking area to prevent stall overlap."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pm,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Buildings"}),_.length>0&&e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 py-0",children:_.length})]}),e.jsx(kt,{checked:t.parking_exclude_buildings!==!1,onCheckedChange:ft=>n({parking_exclude_buildings:ft}),disabled:a})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ji,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Building Buffers"}),_.filter(ft=>{const Fe=Number(ft.building_buffer_ft??0),fe=ft.building_buffer_edge_config,Qe=fe?Math.max(0,...Object.values(fe).map(ht=>Number((ht==null?void 0:ht.widthFt)??0))):0;return Fe>0||Qe>0}).length>0&&e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 py-0",children:_.filter(ft=>{const Fe=Number(ft.building_buffer_ft??0),fe=ft.building_buffer_edge_config,Qe=fe?Math.max(0,...Object.values(fe).map(ht=>Number((ht==null?void 0:ht.widthFt)??0))):0;return Fe>0||Qe>0}).length})]}),e.jsx(kt,{checked:t.parking_exclude_buffers!==!1,onCheckedChange:ft=>n({parking_exclude_buffers:ft}),disabled:a})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Kc,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Stormwater"}),j.length>0&&e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 py-0",children:j.length})]}),e.jsx(kt,{checked:te,onCheckedChange:ft=>{const Fe=t.style||{};n({style:{...Fe,excludeStormwater:ft}})},disabled:a})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ih,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Landscape Buffers"}),y.length>0&&e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 py-0",children:y.length})]}),e.jsx(kt,{checked:J,onCheckedChange:ft=>{const Fe=t.style||{};n({style:{...Fe,excludeLandscape:ft}})},disabled:a})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xd,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Utility Corridors"}),x.length>0&&e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 py-0",children:x.length})]}),e.jsx(kt,{checked:H,onCheckedChange:ft=>{const Fe=t.style||{};n({style:{...Fe,excludeUtilities:ft}})},disabled:a})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wr,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Trash Enclosures"}),v.length>0&&e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 py-0",children:v.length})]}),e.jsx(kt,{checked:O,onCheckedChange:ft=>{const Fe=t.style||{};n({style:{...Fe,excludeTrash:ft}})},disabled:a})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(uo,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Curb Cuts"}),C.length>0&&e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 py-0",children:C.length})]}),e.jsx(kt,{checked:q,onCheckedChange:ft=>{const Fe=t.style||{};n({style:{...Fe,excludeCurbCuts:ft}})},disabled:a})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_S,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Easements"}),P.length>0&&e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 py-0",children:P.length})]}),e.jsx(kt,{checked:W,onCheckedChange:ft=>{const Fe=t.style||{};n({style:{...Fe,excludeEasements:ft}}
761)},disabled:a})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(uo,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Access & Circulation"}),I.length>0&&e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 py-0",children:I.length})]}),e.jsx(kt,{checked:Q,onCheckedChange:ft=>{const Fe=t.style||{};n({style:{...Fe,excludeAccess:ft}})},disabled:a})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hu,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Truck Courts"}),z.length>0&&e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 py-0",children:z.length})]}),e.jsx(kt,{checked:Z,onCheckedChange:ft=>{const Fe=t.style||{};n({style:{...Fe,excludeTruckCourts:ft}})},disabled:a})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ng,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Monument Signs"}),F.length>0&&e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 py-0",children:F.length})]}),e.jsx(kt,{checked:oe,onCheckedChange:ft=>{const Fe=t.style||{};n({style:{...Fe,excludeSignage:ft}})},disabled:a})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Da,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Hardscape / Amenities"}),D.length>0&&e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 py-0",children:D.length})]}),e.jsx(kt,{checked:ce,onCheckedChange:ft=>{const Fe=t.style||{};n({style:{...Fe,excludeHardscape:ft}})},disabled:a})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(TS,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs",children:"Canopies"}),X.length>0&&e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 py-0",children:X.length})]}),e.jsx(kt,{checked:ae,onCheckedChange:ft=>{const Fe=t.style||{};n({style:{...Fe,excludeCanopies:ft}})},disabled:a})]})]})]}),e.jsxs("div",{className:"space-y-3 border-t pt-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Zy,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs font-medium",children:"Cutout Zones"}),(()=>{const Fe=(K.manualExclusionZones||[]).filter(fe=>fe.enabled).length;return Fe>0?e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 py-0",children:Fe}):null})()]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:ft=>{ft.stopPropagation(),c?c(t.id):Ve.error("Cutout drawing is not available in this context")},disabled:a,children:[e.jsx(Zy,{className:"w-3 h-3"}),"Draw Cutout"]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Draw polygons to remove sections from the parking surface."}),(()=>{const ft=K.manualExclusionZones||[];return ft.length===0?null:e.jsx("div",{className:"space-y-1.5",children:ft.map((Fe,fe)=>e.jsxs("div",{className:"flex items-center justify-between p-1.5 bg-muted/50 rounded-md",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("button",{className:"text-muted-foreground hover:text-foreground",onClick:()=>{const Qe=ft.map((_t,He)=>He===fe?{..._t,enabled:!_t.enabled}:_t),ht=t.style||{};n({style:{...ht,manualExclusionZones:Qe}})},disabled:a,children:Fe.enabled?e.jsx(kc,{className:"w-3.5 h-3.5 text-primary"}):e.jsx(Wc,{className:"w-3.5 h-3.5"})}),e.jsx("span",{className:"text-xs truncate",children:Fe.name})]}),e.jsx("button",{className:"text-muted-foreground hover:text-destructive p-0.5",onClick:()=>{const Qe=ft.filter((_t,He)=>He!==fe),ht=t.style||{};n({style:{...ht,manualExclusionZones:Qe}})},disabled:a,children:e.jsx(ja,{className:"w-3.5 h-3.5"})})]},Fe.id))})})()]}),(()=>{var He;
761const ft=de!=null&&de.setback_geometry?Df(de.setback_geometry):null,Fe=(He=ft==null?void 0:ft.innerPolygon)==null?void 0:He[0],fe=Fe==null?void 0:Fe.map(as=>({lat:as[1],lng:as[0]}));if(!fe||fe.length<3)return null;const ht=o1((de==null?void 0:de.id)||t.parent_overlay_id||t.id,s,{excludeBuildings:!0,excludeBuffers:!0,excludeStormwater:te,excludeLandscaping:J,excludeUtilities:H,excludeTrash:O,excludeAccess:Q,excludeTruckCourts:Z,excludeSignage:oe,excludeHardscape:ce,excludeCanopies:ae}).filter(as=>{if(t.geometry&&t.geometry.length>=3){const vt=JSON.stringify(t.geometry),Xe=JSON.stringify(as);if(vt===Xe)return!1}return!0}),_t=e2(fe,ht);return e.jsxs("div",{className:"space-y-2 border-t pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hh,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs font-medium",children:"Buildable Area"})]}),e.jsxs("div",{className:"p-2 bg-muted/50 rounded-md text-xs space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Buildable Area:"}),e.jsxs("span",{className:"font-mono",children:[Math.round(_t.originalArea_sqft).toLocaleString()," sf"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Net After Exclusions:"}),e.jsxs("span",{className:"font-mono",children:[Math.round(_t.netArea_sqft).toLocaleString()," sf"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Est. Spaces:"}),e.jsx("span",{className:"font-mono font-medium",children:Math.floor(_t.netArea_sqft/350)})]})]})]})})(),e.jsxs("div",{className:"space-y-2 border-t pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ml,{className:"w-3.5 h-3.5 text-primary"}),e.jsx(B,{className:"text-xs font-medium",children:"Site Parking Balance"})]}),e.jsxs("div",{className:"p-2 bg-muted/50 rounded-md text-xs space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Current Spaces:"}),e.jsx("span",{className:"font-mono font-medium",children:ke})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Target (if set):"}),e.jsx("span",{className:"font-mono",children:t.parking_zone_target_count||"Maximize"})]}),t.parking_zone_target_count&&ke<t.parking_zone_target_count&&e.jsxs("div",{className:"flex justify-between text-destructive",children:[e.jsx("span",{children:"Deficit:"}),e.jsxs("span",{className:"font-mono font-medium",children:[t.parking_zone_target_count-ke," spaces"]})]}),t.parking_zone_target_count&&ke>=t.parking_zone_target_count&&e.jsxs("div",{className:"flex justify-between text-primary",children:[e.jsx("span",{children:"Target Met:"}),e.jsx("span",{className:"font-mono font-medium",children:"✓"})]})]})]}),Ee.length>0&&e.jsxs("div",{className:"p-2 bg-muted/50 rounded-md",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mb-1",children:[e.jsx(hh,{className:"w-3 h-3"}),"Site Parking Zones"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:Ee.map(ft=>{const Fe=ft.parking_zone_type,fe=Fe?Yv[Fe]:null;return e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:[(fe==null?void 0:fe.label)||ft.name||"Zone",ft.parking_generated_spaces?` (${ft.parking_generated_spaces})`:""]},ft.id)})})]}),ve==="ada"&&e.jsx("div",{className:"p-2 bg-blue-500/10 border border-blue-500/20 rounded-md",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(fh,{className:"w-4 h-4 text-blue-500 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-xs",children:[e.jsx("p",{className:"font-medium text-blue-600 dark:text-blue-400",children:"ADA Requirements"}),e.jsx("p",{className:"text-muted-foreground mt-0.5",children:"Locate near main entry with accessible route. Van-accessible space
761s require 8' width + 8' access aisle."})]})]})}),!de&&ge&&e.jsx("div",{className:"p-2 bg-amber-500/10 border border-amber-500/20 rounded-md",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ho,{className:"w-4 h-4 text-amber-500 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:"Parking zones should be children of a Site or Property layer to respect setbacks and connect to entry points."})]})})]});return l?qt:e.jsx(ns,{title:"Parking Zone",icon:e.jsx(fm,{className:"w-4 h-4"}),badge:we?e.jsx(Mt,{variant:"secondary",className:"text-[10px]",children:we.label}):void 0,defaultOpen:!0,children:qt})}function sO({overlay:t,onUpdate:s,isUpdating:n}){var C,P,I;const[a,l]=k.useState(((C=t.parking_stall_width_ft)==null?void 0:C.toString())||"9"),[c,u]=k.useState(((P=t.parking_stall_depth_ft)==null?void 0:P.toString())||"18"),[i,_]=k.useState(((I=t.parking_aisle_width_ft)==null?void 0:I.toString())||"24"),[j,y]=k.useState(t.parking_layout_type||"double_loaded"),[x,v]=k.useState(t.parking_striping_visible!==!1);return k.useEffect(()=>{var z,F,D;l(((z=t.parking_stall_width_ft)==null?void 0:z.toString())||"9"),u(((F=t.parking_stall_depth_ft)==null?void 0:F.toString())||"18"),_(((D=t.parking_aisle_width_ft)==null?void 0:D.toString())||"24"),y(t.parking_layout_type||"double_loaded"),v(t.parking_striping_visible!==!1)},[t.parking_stall_width_ft,t.parking_stall_depth_ft,t.parking_aisle_width_ft,t.parking_layout_type,t.parking_striping_visible]),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",value:a,onChange:z=>l(z.target.value),onBlur:()=>s({parking_stall_width_ft:parseFloat(a)||9}),min:8,max:12,step:.5,className:"h-8",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Depth (ft)"}),e.jsx(be,{type:"number",value:c,onChange:z=>u(z.target.value),onBlur:()=>s({parking_stall_depth_ft:parseFloat(c)||18}),min:15,max:22,step:.5,className:"h-8",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Aisle (ft)"}),e.jsx(be,{type:"number",value:i,onChange:z=>_(z.target.value),onBlur:()=>s({parking_aisle_width_ft:parseFloat(i)||24}),min:20,max:30,step:1,className:"h-8",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Layout Type"}),e.jsxs(rt,{value:j,onValueChange:z=>{const F=z;y(F),s({parking_layout_type:F})},children:[e.jsx(it,{className:"h-8",children:e.jsx(ct,{})}),e.jsx(ot,{children:lP.map(z=>e.jsx(le,{value:z.value,children:z.label},z.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Show Striping"}),e.jsx(kt,{checked:x,onCheckedChange:z=>{v(z),s({parking_striping_visible:z})},disabled:n})]})]})}const nO=[8,10,12,15],aO=[{value:"deciduous",label:"Deciduous",icon:"🌳"},{value:"evergreen",label:"Evergreen",icon:"🌲"},{value:"palm",label:"Palm",icon:"🌴"},{value:"shrub",label:"Shrub",icon:"🌿"},{value:"custom_3d",label:"3D Model",icon:"📦"}],t2={customer:{label:"Customer",icon:Ml,description:"Front-facing visitor/customer parking"},employee:{label:"Employee",icon:yl,description:"Staff/employee parking"},ada:{label:"ADA Accessible",icon:fh,description:"Accessible parking near main entry"},overflow:{label:"Overflow",icon:fm,description:"Remote/overflow parking for peak times"},reserved:{label:"Reserved",icon:pm,description:"Reserved/VIP parking spaces"}};function rO({overlay:t,allOverlays:s,onUpdate:n,isUpdating:a}){var ve,we,Ze,ke;const l=t.style||{},{data:c}=cS("tree"),[u,i]=k.useState(((ve=l.parking_max_stall_run)==null?void 0:ve.toString())||""),[_,j]=k.useState(l.parking_island_type||"painted"),[y,x]=k.useState(((we=l.parking_island_width_ft)==null?void 0:we.toString())||""),[v,C]=k.useState(l.parking_island_trees??!1),[P,I]=k.useState(l.parking_island_tree_species||"deciduous"),[z,F]=k.useState(((Ze=l.parking_island_tree_height_ft)==null?void 0:Ze.toString())||"30"),[D,X]=k.useState(((ke=l.parking_island_canopy_diameter_ft)==null?void 0:ke.toString())||"15"),[K,te]=k.useState(l.parking_island_custom_model_id||"");k.useEffect(()=>{var Ke,dt,Re,qt;const ze=t.style||{};i(((Ke=ze.parking_max_stall_run)==null?void 0:Ke.toString())||""),j(ze.parking_island_type||"painted"),x(((dt=ze.parking_island_width_ft)==null?void 0:dt.toString())||""),C(ze.parking_island_trees??!1),I(ze.parking_island_tree_species||"deciduous"),F(((Re=ze.parking_island_tree_height_ft)==null?void 0:Re.toString())||"30"),X(((qt=ze.parking_island_canopy_diameter_ft)==null?void 0:qt.toString())||"15"),te(ze.parking_island_custom_model_id||"")},[t.style]);const J=(ze,Ke)=>{const dt=t.style||{};n({style:{...dt,[ze]:Ke}})},H=ze=>{i(ze),J("parking_max_stall_run",parseInt(ze)||null)},O=ze=>{j(ze),J("parking_island_type",ze)},q=ze=>{x(ze),J("parking_island_width_ft",parseFloat(ze)||null)},W=ze=>{C(ze),J("parking_island_trees",ze)},Q=ze=>{I(ze),J("parking_island_tree_species",ze)},Z=ze=>{F(ze),J("parking_island_tree_height_ft",parseFloat(ze)||null)},oe=ze=>{X(ze),J("parking_island_canopy_diameter_ft",parseFloat(ze)||null)},ce=ze=>{te(ze),J("parking_island_custom_model_id",ze||null);const Ke=c==null?void 0:c.find(dt=>dt.id===ze);Ke!=null&&Ke.file_path?J("parking_island_custom_model_url",Db(Ke.file_path)):J("parking_island_custom_model_url",null)},ae=k.useMemo(()=>s.filter(ze=>{const Ke=ze.style;return(Ke==null?void 0:Ke.entryPoints)&&Array.isArray(Ke.entryPoints)&&Ke.entryPoints.length>0}),[s]),ie=k.useMemo(()=>t.parking_connected_entry_id?s.find(ze=>ze.id===t.parking_connected_entry_id):null,[t.parking_connected_entry_id,s]),de=t.parking_zone_type,ge=de?t2[de]:null,We=parseInt(u)||0,Ee=We>=4;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Edge Placement Mode"}),e.jsxs(rt,{value:l.edgePlacementMode||"longest_edge",onValueChange:ze=>J("edgePlacementMode",ze),disabled:a,children:[e.jsx(it,{className:"h-8",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"longest_edge",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pm,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Longest Edge Only"})]})}),e.jsx(le,{value:"all_edges",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fm,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"All Edges"})]})}),e.jsx(le,{value:"perimeter_priority",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(uo,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Perimeter Priority"})]})})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Max Stall Run"}),e.jsx(be,{type:"number",value:u,onChange:ze=>H(ze.target.value),min:4,max:30,step:1,placeholder:"Unlimited",className:"h-8",disabled:a}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[nO.map(ze=>e.jsx(Mt,{variant:We===ze?"default":"outline",className:"cursor-pointer text-[10px] px-1.5 py-0",onClick:()=>H(ze.toString()),children:ze},ze)),We>0&&e.jsx(Mt,{variant:"outline",className:"cursor-pointer text-[10px] px-1.5 py-0 text-destructive border-destructive",onClick:()=>H(""),children:"Clear"})]})]}),Ee&&e.jsxs("div",{className:"space-y-2 p-2 rounded-md border border-border bg-muted/30",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Island Type"}),e.jsxs(rt,{value:_,onValueChange:ze=>O(ze),children:[e.jsx(it,{className:"h-8",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"painted",children:"Painted"}),e.jsx(le,{value:"landscape",children:"Landscape"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",value:y,onChange:ze=>q(ze.target.value),min:3,max:12,step:.5,placeholder:_==="landscape"?"6":"4",className:"h-8",disabled:a})]})]}),_==="landscape"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ih,{className:"w-3 h-3 text-primary"}),e.jsx(B,{className:"text-[10px]",children:"Include Trees"})]}),e.jsx(kt,{checked:v,onCheckedChange:W,disabled:a})]}),_==="landscape"&&v&&e.jsxs("div",{className:"space-y-2 p-2 rounded-md border border-primary/20 bg-primary/5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(qy,{className:"w-3 h-3 text-primary"}),e.jsx(B,{className:"text-[10px] font-medium",children:"Tree Configuration"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Species"}),e.jsxs(rt,{value:P,onValueChange:ze=>Q(ze),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:aO.map(ze=>e.jsx(le,{value:ze.value,className:"text-xs",children:e.jsxs("span",{children:[ze.icon," ",ze.label]})},ze.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Height (ft)"}),e.jsx(be,{type:"number",value:z,onChange:ze=>Z(ze.target.value),min:5,max:80,className:"h-7 text-xs",disabled:a})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Canopy Diameter (ft)"}),e.jsx(be,{type:"number",value:D,onChange:ze=>oe(ze.target.value),min:3,max:40,className:"h-7 text-xs",disabled:a})]}),P==="custom_3d"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"3D Model"}),e.jsxs(rt,{value:K||"__none__",onValueChange:ze=>ce(ze==="__none__"?"":ze),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{placeholder:"Select model..."})}),e.jsxs(ot,{children:[e.jsx(le,{value:"__none__",children:"None"}),c==null?void 0:c.map(ze=>e.jsx(le,{value:ze.id,className:"text-xs",children:ze.name},ze.id))]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(uo,{className:"w-3 h-3 text-primary"}),e.jsx(B,{className:"text-[10px]",children:"Cross-Aisle at Islands"})]}),e.jsx(kt,{checked:l.parking_island_cross_aisle!==!1,onCheckedChange:ze=>J("parking_island_cross_aisle",ze),disabled:a})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Zone Purpose"}),e.jsxs(rt,{value:de||"",onValueChange:ze=>n({parking_zone_type:ze}),disabled:a,children:[e.jsx(it,{className:"h-8",children:e.jsx(ct,{placeholder:"Select purpose..."})}),e.jsx(ot,{children:Object.entries(t2).map(([ze,Ke])=>{const dt=Ke.icon;return e.jsx(le,{value:ze,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dt,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:Ke.label})]})},ze)})})]}),ge&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:ge.description})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Target Space
761s"}),e.jsx(be,{type:"number",value:t.parking_zone_target_count||"",onChange:ze=>n({parking_zone_target_count:ze.target.value?parseInt(ze.target.value):null}),placeholder:"Maximize",className:"h-8",disabled:a})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Connected Entry Point"}),e.jsxs(rt,{value:t.parking_connected_entry_id||"__none__",onValueChange:ze=>n({parking_connected_entry_id:ze==="__none__"?null:ze}),disabled:a,children:[e.jsx(it,{className:"h-8",children:e.jsx(ct,{placeholder:"Not connected"})}),e.jsxs(ot,{children:[e.jsx(le,{value:"__none__",children:"Not connected"}),ae.map(ze=>e.jsx(le,{value:ze.id,children:ze.name||`Entry Point ${ze.id.slice(0,6)}`},ze.id))]})]}),ie&&e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Drive aisle routes from ",ie.name||"entry"," to this zone"]})]})]})}function iO({overlay:t,onUpdate:s,isUpdating:n,onStartCutoutDrawing:a}){const{buildingLayers:l,stormwaterLayers:c,landscapeLayers:u,utilityLayers:i,trashLayers:_,curbCutLayers:j,easementLayers:y,accessLayers:x,truckLayers:v,signageLayers:C,hardscapeLayers:P,canopyLayers:I}=uT(t),z=t.style||{},F=z.excludeStormwater!==!1,D=z.excludeLandscape!==!1,X=z.excludeUtilities!==!1,K=z.excludeTrash!==!1,te=z.excludeCurbCuts!==!1,J=z.excludeEasements===!0,H=z.excludeAccess!==!1,O=z.excludeTruckCourts!==!1,q=z.excludeSignage!==!1,W=z.excludeHardscape!==!1,Q=z.excludeCanopies!==!1,Z=(de,ge)=>{const We=t.style||{};s({style:{...We,[de]:ge}})},oe=k.useMemo(()=>{let de=0;return t.parking_exclude_buildings!==!1&&de++,t.parking_exclude_buffers!==!1&&de++,F&&de++,D&&de++,X&&de++,K&&de++,te&&de++,J&&de++,H&&de++,O&&de++,q&&de++,W&&de++,Q&&de++,de},[t.parking_exclude_buildings,t.parking_exclude_buffers,F,D,X,K,te,J,H,O,q,W,Q]),ce=z.manualExclusionZones||[],ae=ce.filter(de=>de.enabled).length,ie=[{key:"buildings",label:"Buildings",icon:pm,checked:t.parking_exclude_buildings!==!1,onChange:de=>s({parking_exclude_buildings:de}),count:l.length,isOverlay:!0},{key:"buffers",label:"Building Buffers",icon:ji,checked:t.parking_exclude_buffers!==!1,onChange:de=>s({parking_exclude_buffers:de}),count:l.filter(de=>Number(de.building_buffer_ft??0)>0||(de.building_buffer_edge_config?Math.max(0,...Object.values(de.building_buffer_edge_config).map(ge=>Number((ge==null?void 0:ge.widthFt)??0))):0)>0).length,isOverlay:!0},{key:"stormwater",label:"Stormwater",icon:Kc,checked:F,onChange:de=>Z("excludeStormwater",de),count:c.length},{key:"landscape",label:"Landscape",icon:Ih,checked:D,onChange:de=>Z("excludeLandscape",de),count:u.length},{key:"utilities",label:"Utilities",icon:Xd,checked:X,onChange:de=>Z("excludeUtilities",de),count:i.length},{key:"trash",label:"Trash",icon:wr,checked:K,onChange:de=>Z("excludeTrash",de),count:_.length},{key:"curbcuts",label:"Curb Cuts",icon:uo,checked:te,onChange:de=>Z("excludeCurbCuts",de),count:j.length},{key:"easements",label:"Easements",icon:_S,checked:J,onChange:de=>Z("excludeEasements",de),count:y.length},{key:"access",label:"Access",icon:uo,checked:H,onChange:de=>Z("excludeAccess",de),count:x.length},{key:"trucks",label:"Truck Courts",icon:hu,checked:O,onChange:de=>Z("excludeTruckCourts",de),count:v.length},{key:"signage",label:"Signs",icon:Ng,checked:q,onChange:de=>Z("excludeSignage",de),count:C.length},{key:"hardscape",label:"Hardscape",icon:Da,checked:W,onChange:de=>Z("excludeHardscape",de),count:P.length},{key:"canopies",label:"Canopies",icon:TS,checked:Q,onChange:de=>Z("excludeCanopies",de),count:I.length}];return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[oe," of ",ie.length," constraint types active",ae>0&&` · ${ae} cutout zone${ae>1?"s":""}`]}),e.jsx("div",{className:"space-y-1.5",children:ie.map(de=>{const ge=de.icon;return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ge,{className:"w-3 h-3 text-muted-foreground"}),e.jsx(B,{className:"text-[10px]",children:de.label}),de.count>0&&e.jsx(Mt,{variant:"secondary",className:"text-[8px] px-1 py-0 h-3.5",children:de.count})]}),e.jsx(kt,{checked:de.checked,onCheckedChange:de.onChange,disabled:n,className:"scale-90"})]},de.key)})}),e.jsxs("div",{className:"space-y-2 border-t pt-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Zy,{className:"w-3 h-3 text-muted-foreground"}),e.jsx(B,{className:"text-[10px] font-medium",children:"Cutout Zones"}),ae>0&&e.jsx(Mt,{variant:"secondary",className:"text-[8px] px-1 py-0 h-3.5",children:ae})]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"h-6 text-[10px] gap-1 px-2",onClick:de=>{de.stopPropagation(),a?a(t.id):Ve.error("Cutout drawing not available")},disabled:n,children:[e.jsx(Zy,{className:"w-2.5 h-2.5"}),"Draw"]})]}),ce.length>0&&e.jsx("div",{className:"space-y-1",children:ce.map((de,ge)=>e.jsxs("div",{className:"flex items-center justify-between p-1 bg-muted/50 rounded",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-1 min-w-0",children:[e.jsx("button",{className:"text-muted-foreground hover:text-foreground",onClick:()=>{const We=ce.map((Ee,ve)=>ve===ge?{...Ee,enabled:!Ee.enabled}:Ee);Z("manualExclusionZones",We)},disabled:n,children:de.enabled?e.jsx(kc,{className:"w-3 h-3 text-primary"}):e.jsx(Wc,{className:"w-3 h-3"})}
761),e.jsx("span",{className:"text-[10px] truncate",children:de.name})]}),e.jsx("button",{className:"text-muted-foreground hover:text-destructive p-0.5",onClick:()=>{const We=ce.filter((Ee,ve)=>ve!==ge);Z("manualExclusionZones",We)},disabled:n,children:e.jsx(ja,{className:"w-3 h-3"})})]},de.id))})]})]})}function oO({overlay:t,onUpdate:s,isUpdating:n}){const a=t.guard_booth_lane_config||"single";return e.jsx(ns,{title:"Guard Booth / Security",icon:e.jsx(Fy,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Booth Type"}),e.jsxs(rt,{value:t.guard_booth_type||"gatehouse",onValueChange:l=>s({guard_booth_type:l}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"gatehouse",className:"text-xs",children:"Gatehouse"}),e.jsx(le,{value:"kiosk",className:"text-xs",children:"Kiosk"}),e.jsx(le,{value:"booth",className:"text-xs",children:"Booth"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Lane Configuration"}),e.jsxs(rt,{value:a,onValueChange:l=>s({guard_booth_lane_config:l}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"single",className:"text-xs",children:"Single Lane"}),e.jsx(le,{value:"split_inbound_outbound",className:"text-xs",children:"Split Inbound / Outbound"}),e.jsx(le,{value:"dual",className:"text-xs",children:"Dual Independent"})]})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[a==="single"&&"One shared lane for all traffic",a==="split_inbound_outbound"&&"Separate inbound and outbound lanes",a==="dual"&&"Two independent lanes with separate controls"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",min:4,max:30,className:"h-7 text-xs",value:t.guard_booth_width_ft??10,onChange:l=>s({guard_booth_width_ft:parseFloat(l.target.value)||10}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Depth (ft)"}),e.jsx(be,{type:"number",min:4,max:20,className:"h-7 text-xs",value:t.guard_booth_depth_ft??8,onChange:l=>s({guard_booth_depth_ft:parseFloat(l.target.value)||8}),disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Boom Barrier"}),e.jsx(kt,{checked:t.guard_booth_has_barrier??!0,onCheckedChange:l=>s({guard_booth_has_barrier:l}),disabled:n})]}),(t.guard_booth_has_barrier??!0)&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Barrier Type"}),e.jsxs(rt,{value:t.guard_booth_barrier_type||"boom",onValueChange:l=>s({guard_booth_barrier_type:l}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"boom",className:"text-xs",children:"Boom Gate"}),e.jsx(le,{value:"sliding_gate",className:"text-xs",children:"Sliding Gate"}),e.jsx(le,{value:"bollard",className:"text-xs",children:"Retractable Bollard"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Visitor Check-In Window"}),e.jsx(kt,{checked:t.guard_booth_has_visitor_window??!1,onCheckedChange:l=>s({guard_booth_has_visitor_window:l}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Canopy / Roof Overhang"}),e.jsx(kt,{checked:t.guard_booth_canopy_enabled??!1,onCheckedChange:l=>s({guard_booth_canopy_enabled:l}),disabled:n})]})]})})}function lO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Roof Mechanical / RTU",icon:e.jsx(Y1,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"RTU Count"}),e.jsx(be,{type:"number",min:1,max:50,className:"h-7 text-xs",value:t.roof_mech_count??4,onChange:a=>s({roof_mech_count:parseInt(a.target.value)||4}),disabled:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Pad Size (ft)"}),e.jsx(be,{type:"number",min:4,max:20,className:"h-7 text-xs",value:t.roof_mech_pad_size_ft??8,onChange:a=>s({roof_mech_pad_size_ft:parseFloat(a.target.value)||8}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Screen Height (ft)"}),e.jsx(be,{type:"number",min:3,max:12,className:"h-7 text-xs",value:t.roof_mech_screen_height_ft??6,onChange:a=>s({roof_mech_screen_height_ft:parseFloat(a.target.value)||6}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Screen Type"}),e.jsxs(rt,{value:t.roof_mech_screen_type||"louver",onValueChange:a=>s({roof_mech_screen_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"louver",className:"text-xs",children:"Louver"}),e.jsx(le,{value:"solid",className:"text-xs",children:"Solid Panel"}),e.jsx(le,{value:"perforated",className:"text-xs",children:"Perforated Metal"})]})]})]})]})})}function cO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Overhead Crane Rails",icon:e.jsx(e_,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Crane Type"}),e.jsxs(rt,{value:t.crane_type||"bridge",onValueChange:a=>s({crane_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"bridge",className:"text-xs",children:"Bridge Crane"}),e.jsx(le,{value:"jib",className:"text-xs",children:"Jib Crane"}),e.jsx(le,{value:"gantry",className:"text-xs",children:"Gantry Crane"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Capacity (tons)"}),e.jsx(be,{type:"number",min:1,max:200,className:"h-7 text-xs",value:t.crane_capacity_tons??10,onChange:a=>s({crane_capacity_tons:parseFloat(a.target.value)||10}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Rail Height (ft)"}),e.jsx(be,{type:"number",min:10,max:60,className:"h-7 text-xs",value:t.crane_rail_height_ft??20,onChange:a=>s({crane_rail_height_ft:parseFloat(a.target.value)||20}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Span (ft)"}),e.jsx(be,{type:"number",min:20,max:150,className:"h-7 text-xs",value:t.crane_span_ft??60,onChange:a=>s({crane_span_ft:parseFloat(a.target.value)||60}),disabled:n})]})]})})}function dO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Mezzanine / Interstitial",icon:e.jsx(Da,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Mezzanine Type"}),e.jsxs(rt,{value:t.mezzanine_type||"office",onValueChange:a=>s({mezzanine_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"office",className:"text-xs",children:"Office Mezzanine"}),e.jsx(le,{value:"storage",className:"text-xs",children:"Storage Platform"}),e.jsx(le,{value:"pick_module",className:"text-xs",children:"Pick Module"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Height (ft)"}),e.jsx(be,{type:"number",min:8,max:30,className:"h-7 text-xs",value:t.mezzanine_height_ft??12,onChange:a=>s({mezzanine_height_ft:parseFloat(a.target.value)||12}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Load (PSF)"}),e.jsx(be,{type:"number",min:50,max:500,className:"h-7 text-xs",value:t.mezzanine_load_psf??125,onChange:a=>s({mezzanine_load_psf:parseFloat(a.target.value)||125}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(B,{className:"text-xs",children:["Coverage: ",t.mezzanine_coverage_pct??30,"%"]}),e.jsx(Ca,{value:[t.mezzanine_coverage_pct??30],onValueChange:([a])=>s({mezzanine_coverage_pct:a}),min:5,max:80,step:5,disabled:n})]})]})})}function uO({overlay:t,onUpdate:s,isUpdating:n}){const a=t.truck_queue_position||"general";return e.jsx(ns,{title:"Truck Queuing / Staging",icon:e.jsx(w3,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Queue Position"}),e.jsxs(rt,{value:a,onValueChange:l=>s({truck_queue_position:l}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"pre_gate",className:"text-xs",children:"Pre-Gate Queue"}),e.jsx(le,{value:"post_gate",className:"text-xs",children:"Post-Gate Staging"}),e.jsx(le,{value:"general",className:"text-xs",children:"General"})]})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[a==="pre_gate"&&"Trucks queue on public road before the security gate",a==="post_gate"&&"Staging area inside the gate before dock assignment",a==="general"&&"General-purpose queuing/staging area"]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Lanes"}),e.jsx(be,{type:"number",min:1,max:8,className:"h-7 text-xs",value:t.truck_queue_lane_count??2,onChange:l=>s({truck_queue_lane_count:parseInt(l.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Length (ft)"}),e.jsx(be,{type:"number",min:50,max:500,className:"h-7 text-xs",value:t.truck_queue_lane_length_ft??200,onChange:l=>s({truck_queue_lane_length_ft:parseFloat(l.target.value)||200}
761),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",min:10,max:20,className:"h-7 text-xs",value:t.truck_queue_lane_width_ft??12,onChange:l=>s({truck_queue_lane_width_ft:parseFloat(l.target.value)||12}),disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Lane Striping"}),e.jsx(kt,{checked:t.truck_queue_has_striping??!0,onCheckedChange:l=>s({truck_queue_has_striping:l}),disabled:n})]})]})})}function hO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Fuel Island / CNG Station",icon:e.jsx(X1,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Fuel Type"}),e.jsxs(rt,{value:t.fuel_island_type||"diesel",onValueChange:a=>s({fuel_island_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"diesel",className:"text-xs",children:"Diesel"}),e.jsx(le,{value:"cng",className:"text-xs",children:"CNG / LNG"}),e.jsx(le,{value:"dual",className:"text-xs",children:"Dual Fuel"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Pump Count"}),e.jsx(be,{type:"number",min:1,max:12,className:"h-7 text-xs",value:t.fuel_island_pump_count??4,onChange:a=>s({fuel_island_pump_count:parseInt(a.target.value)||4}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Canopy Cover"}),e.jsx(kt,{checked:t.fuel_island_canopy_enabled??!0,onCheckedChange:a=>s({fuel_island_canopy_enabled:a}),disabled:n})]})]})})}function mO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Container / Chassis Yard",icon:e.jsx(Wm,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Capacity (TEU)"}),e.jsx(be,{type:"number",min:1,max:500,className:"h-7 text-xs",value:t.container_yard_capacity??50,onChange:a=>s({container_yard_capacity:parseInt(a.target.value)||50}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Stack Height"}),e.jsx(be,{type:"number",min:1,max:5,className:"h-7 text-xs",value:t.container_yard_stack_height??2,onChange:a=>s({container_yard_stack_height:parseInt(a.target.value)||2}),disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Chassis Storage"}),e.jsx(kt,{checked:t.container_yard_has_chassis??!0,onCheckedChange:a=>s({container_yard_has_chassis:a}),disabled:n})]})]})})}function fO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Scale House / Weigh Station",icon:e.jsx(CS,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Scale Count"}),e.jsx(be,{type:"number",min:1,max:4,className:"h-7 text-xs",value:t.scale_house_scale_count??1,onChange:a=>s({scale_house_scale_count:parseInt(a.target.value)||1}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Scale Length (ft)"}),e.jsx(be,{type:"number",min:40,max:100,className:"h-7 text-xs",value:t.scale_house_scale_length_ft??70,onChange:a=>s({scale_house_scale_length_ft:parseFloat(a.target.value)||70}),disabled:n})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Scale Width (ft)"}),e.jsx(be,{type:"number",min:10,max:14,className:"h-7 text-xs",value:t.scale_house_scale_width_ft??12,onChange:a=>s({scale_house_scale_width_ft:parseFloat(a.target.value)||12}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Approach Apron (ft)"}),e.jsx(be,{type:"number",min:10,max:60,className:"h-7 text-xs",value:t.scale_house_approach_length_ft??20,onChange:a=>s({scale_house_approach_length_ft:parseFloat(a.target.value)||20}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Scale Pad Material"}),e.jsxs(rt,{value:t.scale_house_pad_material||"concrete",onValueChange:a=>s({scale_house_pad_material:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"concrete",className:"text-xs",children:"Concrete"}),e.jsx(le,{value:"asphalt",className:"text-xs",children:"Asphalt"})]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Concrete is standard for heavy axle loads"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Operator Booth"}),e.jsx(kt,{checked:t.scale_house_has_booth??!0,onCheckedChange:a=>s({scale_house_has_booth:a}),disabled:n})]})]})})}function pO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Hazmat Containment",icon:e.jsx(ho,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Zone Type"}),e.jsxs(rt,{value:t.hazmat_zone_type||"containment",onValueChange:a=>s({hazmat_zone_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"containment",className:"text-xs",children:"Secondary Containment"}),e.jsx(le,{value:"spill_prevention",className:"text-xs",children:"Spill Prevention"}),e.jsx(le,{value:"storage",className:"text-xs",children:"Hazmat Storage"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Berm Height (ft)"}),e.jsx(be,{type:"number",min:.5,max:4,step:.5,className:"h-7 text-xs",value:t.hazmat_zone_berm_height_ft??1,onChange:a=>s({hazmat_zone_berm_height_ft:parseFloat(a.target.value)||1}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Capacity (gal)"}
761),e.jsx(be,{type:"number",min:100,max:1e5,className:"h-7 text-xs",value:t.hazmat_zone_capacity_gal??5e3,onChange:a=>s({hazmat_zone_capacity_gal:parseFloat(a.target.value)||5e3}),disabled:n})]})]})]})})}function gO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Emergency Assembly Point",icon:e.jsx(yl,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Personnel Capacity"}),e.jsx(be,{type:"number",min:10,max:2e3,className:"h-7 text-xs",value:t.emergency_assembly_capacity??100,onChange:a=>s({emergency_assembly_capacity:parseInt(a.target.value)||100}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Marker Type"}),e.jsxs(rt,{value:t.emergency_assembly_marker_type||"sign",onValueChange:a=>s({emergency_assembly_marker_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"sign",className:"text-xs",children:"Standing Sign"}),e.jsx(le,{value:"painted",className:"text-xs",children:"Painted Ground Marking"}),e.jsx(le,{value:"bollard",className:"text-xs",children:"Bollard Markers"})]})]})]})]})})}function xO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Generator / Transformer Pad",icon:e.jsx(Xd,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Equipment Type"}),e.jsxs(rt,{value:t.generator_pad_type||"generator",onValueChange:a=>s({generator_pad_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"generator",className:"text-xs",children:"Backup Generator"}),e.jsx(le,{value:"transformer",className:"text-xs",children:"Transformer"}),e.jsx(le,{value:"switchgear",className:"text-xs",children:"Switchgear"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Pad Size (ft)"}),e.jsx(be,{type:"number",min:6,max:30,className:"h-7 text-xs",value:t.generator_pad_size_ft??12,onChange:a=>s({generator_pad_size_ft:parseFloat(a.target.value)||12}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Fuel Type"}),e.jsxs(rt,{value:t.generator_pad_fuel_type||"diesel",onValueChange:a=>s({generator_pad_fuel_type:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"diesel",className:"text-xs",children:"Diesel"}),e.jsx(le,{value:"natural_gas",className:"text-xs",children:"Natural Gas"})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Bollard Protection"}),e.jsx(kt,{checked:t.generator_pad_has_bollards??!0,onCheckedChange:a=>s({generator_pad_has_bollards:a}),disabled:n})]})]})})}function _O({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Fire Suppression Equipment",icon:e.jsx(Ff,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Equipment Type"}),e.jsxs(rt,{value:t.fire_suppression_type||"fdc",onValueChange:a=>s({fire_suppression_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"fdc",className:"text-xs",children:"Fire Dept. Connection (FDC)"}),e.jsx(le,{value:"hydrant",className:"text-xs",children:"Hydrant"}),e.jsx(le,{value:"riser_room",className:"text-xs",children:"Sprinkler Riser Room"}),e.jsx(le,{value:"sprinkler_zone",className:"text-xs",children:"Sprinkler Zone"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"FDC / Hydrant Count"}),e.jsx(be,{type:"number",min:1,max:10,className:"h-7 text-xs",value:t.fire_suppression_fdc_count??1,onChange:a=>s({fire_suppression_fdc_count:parseInt(a.target.value)||1}),disabled:n})]})]})})}function yO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Rail Spur / Siding",icon:e.jsx(H3,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Track Gauge"}),e.jsxs(rt,{value:t.rail_spur_gauge||"standard",onValueChange:a=>s({rail_spur_gauge:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"standard",className:"text-xs",children:`Standard (4' 8½")`}),e.jsx(le,{value:"narrow",className:"text-xs",children:"Narrow Gauge"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Spur Length (ft)"}),e.jsx(be,{type:"number",min:100,max:5e3,className:"h-7 text-xs",value:t.rail_spur_length_ft??500,onChange:a=>s({rail_spur_length_ft:parseFloat(a.target.value)||500}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"End Bumper"}),e.jsx(kt,{checked:t.rail_spur_has_bumper??!0,onCheckedChange:a=>s({rail_spur_has_bumper:a}),disabled:n})]})]})})}function vO({overlay:t,onUpdate:s,isUpdating:n}){const a=k.useRef(),[l,c]=k.useState(null),u=k.useRef(),[i,_]=k.useState(null),j=k.useRef(),[y,x]=k.useState(null),v=
761I=>{const z=I[0];c(z),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{s({exhaust_fan_count:z})},300)},C=I=>{const z=I[0];_(z),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{s({exhaust_fan_size_in:z})},300)},P=I=>{const z=I[0];x(z),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{s({exhaust_fan_height_ft:z})},300)};return e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Wall-mounted exhaust fans for cross ventilation in warehouse/distribution buildings."}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Enable Exhaust Fans"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Add ventilation units to building walls"})]}),e.jsx(kt,{checked:t.exhaust_fan_enabled??!1,onCheckedChange:I=>s({exhaust_fan_enabled:I}),disabled:n})]}),t.exhaust_fan_enabled&&e.jsxs("div",{className:"space-y-3 p-3 bg-muted/50 rounded-lg border animate-in fade-in-50",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Fan Type"}),e.jsxs(rt,{value:t.exhaust_fan_type||"exhaust_fan",onValueChange:I=>s({exhaust_fan_type:I}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"exhaust_fan",className:"text-xs",children:"Exhaust Fan (Circular)"}),e.jsx(le,{value:"louver_vent",className:"text-xs",children:"Louver Vent (Rectangular)"}),e.jsx(le,{value:"ridge_vent",className:"text-xs",children:"Ridge Vent (Roof)"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(B,{className:"text-[10px]",children:"Count"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:l??t.exhaust_fan_count??4})]}),e.jsx(Ca,{value:[l??t.exhaust_fan_count??4],min:1,max:20,step:1,onValueChange:v,disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(B,{className:"text-[10px]",children:"Size (inches)"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[i??t.exhaust_fan_size_in??48,'"']})]}),e.jsx(Ca,{value:[i??t.exhaust_fan_size_in??48],min:24,max:72,step:6,onValueChange:C,disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(B,{className:"text-[10px]",children:"Mounting Height (ft)"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[y??t.exhaust_fan_height_ft??20," ft"]})]}),e.jsx(Ca,{value:[y??t.exhaust_fan_height_ft??20],min:10,max:40,step:2,onValueChange:P,disabled:n})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Placement"}),e.jsxs(rt,{value:t.exhaust_fan_placement||"single",onValueChange:I=>s({exhaust_fan_placement:I}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"single",className:"text-xs",children:"Single Wall"}),e.jsx(le,{value:"cross",className:"text-xs",children:"Cross Ventilation"}),e.jsx(le,{value:"custom",className:"text-xs",children:"Custom Edges"})]})]}),t.exhaust_fan_placement==="cross"&&e.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"Fans placed on opposing walls for through-building airflow"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Spacing"}),e.jsxs(rt,{value:t.exhaust_fan_spacing_mode||"even",onValueChange:I=>s({exhaust_fan_spacing_mode:I}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"even",className:"text-xs",children:"Evenly Spaced"}),e.jsx(le,{value:"clustered",className:"text-xs",children:"Clustered"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-[10px] shrink-0",children:"Color"}),e.jsx(be,{type:"color",value:t.exhaust_fan_color||"#808080",onChange:I=>s({exhaust_fan_color:I.target.value}),className:"h-6 w-10 p-0.5 cursor-pointer",disabled:n})]})]})]})}const bO=[{value:"unit",label:"Unit Skylight (Individual Panels)"},{value:"ridge",label:"Ridge Skylight (Continuous)"},{value:"tubular",label:"Tubular / Sun Tubes"}],jO=[{value:"clear",label:"Clear"},{value:"bronze",label:"Bronze"},{value:"gray",label:"Gray"},{value:"white_translucent",label:"White Translucent"}];function wO({overlay:t,onUpdate:s,isUpdating:n}){const a=t.skylight_enabled??!1;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs font-medium",children:"Enable Skylights"}),e.jsx(kt,{checked:a,onCheckedChange:l=>s({skylight_enabled:l}),disabled:n})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Skylight Type"}),e.jsxs(rt,{value:t.skylight_type||"unit",onValueChange:l=>s({skylight_type:l}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:bO.map(l=>e.jsx(le,{value:l.value,className:"text-xs",children:l.label},l.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Rows"}),e.jsx(be,{type:"number",min:1,max:20,value:t.skylight_rows??2,onCh
761ange:l=>s({skylight_rows:parseInt(l.target.value)||2}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Columns"}),e.jsx(be,{type:"number",min:1,max:40,value:t.skylight_cols??4,onChange:l=>s({skylight_cols:parseInt(l.target.value)||4}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",min:1,max:20,value:t.skylight_width_ft??4,onChange:l=>s({skylight_width_ft:parseFloat(l.target.value)||4}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Length (ft)"}),e.jsx(be,{type:"number",min:1,max:20,value:t.skylight_length_ft??8,onChange:l=>s({skylight_length_ft:parseFloat(l.target.value)||8}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Spacing Between Units (ft)"}),e.jsx(Ca,{value:[t.skylight_spacing_ft??10],min:2,max:30,step:1,onValueChange:([l])=>s({skylight_spacing_ft:l}),disabled:n}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[t.skylight_spacing_ft??10," ft"]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Setback from Roof Edge (ft)"}),e.jsx(Ca,{value:[t.skylight_setback_ft??5],min:1,max:20,step:1,onValueChange:([l])=>s({skylight_setback_ft:l}),disabled:n}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[t.skylight_setback_ft??5," ft"]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Tint / Color"}),e.jsxs(rt,{value:t.skylight_tint||"clear",onValueChange:l=>s({skylight_tint:l}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:jO.map(l=>e.jsx(le,{value:l.value,className:"text-xs",children:l.label},l.value))})]})]})]})]})}const NO=[{value:"open",label:"Open (No Enclosure)"},{value:"three_sided",label:"3-Sided Screen Wall"},{value:"full_enclosure",label:"Full Enclosure with Gate"}];function kO({overlay:t,onUpdate:s,isUpdating:n}){const a=t.trash_compactor_enabled??!1;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs font-medium",children:"Enable Trash Compactor"}),e.jsx(kt,{checked:a,onCheckedChange:l=>s({trash_compactor_enabled:l}),disabled:n})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",min:6,max:20,value:t.trash_compactor_width_ft??10,onChange:l=>s({trash_compactor_width_ft:parseFloat(l.target.value)||10}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Depth (ft)"}),e.jsx(be,{type:"number",min:10,max:40,value:t.trash_compactor_depth_ft??20,onChange:l=>s({trash_compactor_depth_ft:parseFloat(l.target.value)||20}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Enclosure Type"}),e.jsxs(rt,{value:t.trash_compactor_enclosure||"three_sided",onValueChange:l=>s({trash_compactor_enclosure:l}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:NO.map(l=>e.jsx(le,{value:l.value,className:"text-xs",children:l.label},l.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Dock Edge Index (Position)"}),e.jsx(be,{type:"number",min:0,value:t.trash_compactor_edge_index??"",onChange:l=>s({trash_compactor_edge_index:l.target.value?parseInt(l.target.value):null}),className:"h-8 text-xs",disabled:n,placeholder:"Auto (end of dock)"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Bollard Protection"}),e.jsx(kt,{checked:t.trash_compactor_bollards??!0,onCheckedChange:l=>s({trash_compactor_bollards:l}),disabled:n})]})]})]})}const CO=[{value:"wall_pack",label:"Wall Pack"},{value:"gooseneck",label:"Gooseneck"},{value:"sconce",label:"Sconce"},{value:"soffit_downlight",label:"Soffit Downlight"}],SO=[{value:"3000k",label:"Warm (3000K)"},{value:"4000k",label:"Neutral (4000K)"},{value:"5000k",label:"Cool (5000K)"}];function EO({overlay:t,onUpdate:s,isUpdating:n}){const a=t.building_light_enabled??!1;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs font-medium",children:"Enable Perimeter Lights"}),e.jsx(kt,{checked:a,onCheckedChange:l=>s({building_light_enabled:l}),disabled:n})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Light Type"}),e.jsxs(rt,{value:t.building_light_type||"wall_pack",onValueChange:l=>s({building_light_type:l}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:CO.map(l=>e.jsx(le,{value:l.value,className:"text-xs",children:l.label},l.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Spacing (ft)"}),e.jsx(Ca,{value:[t.building_light_spacing_ft??40],min:10,max:80,step:5,onValueChange:([l])=>s({building_light_spacing_ft:l}),disabled:n}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[t.building_light_spacing_ft??40," ft apart"]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Mount Height (ft)"}),e.jsx(Ca,{value:[t.building_light_height_ft??12],min:8,max:24,step:1,onValueChange:([l])=>s({building_light_height_ft:l}),disabled:n}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[t.building_light_height_ft??12," ft"]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Color Temperature"}),e.jsxs(rt,{value:t.building_light_temp||"4000k",onValueChange:l=>s({building_light_temp:l}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:SO.map(l=>e.jsx(le,{value:l.value,className:"text-xs",children:l.label},l.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Double Fixture at Corners"}),e.jsx(kt,{checked:t.building_light_corners??!0,onCheckedChange:l=>s({building_light_corners:l}),disabled:n})]})]})]})}const Xv=[{value:"data_hall",label:"Data Hall",icon:P1,description:"Primary compute space — no windows, raised floor, containment",defaults:{floor_height_ft:40,window_pattern:"none",floor_count:1}},{value:"admin_office",label:"Admin / Office",icon:Ci,description:"Administrative wing — glazing bands, standard office height",defaults:{floor_height_ft:12,window_pattern:"bands",floor_count:2}},{value:"service_loading",label:"Loading / Service",icon:hu,description:"Equipment receiving and staging — dock access, shorter bay",defaults:{floor_height_ft:20,window_pattern:"none",floor_count:1}},{value:"mep_highbay",label:"MEP High-Bay",icon:T1,description:"Mechanical/electrical plant — taller roofline, no windows",defaults:{floor_height_ft:50,window_pattern:"none",floor_count:1}},{value:"expansion_pad",label:"Expansion Pad",icon:gS,description:"Future phase — rendered dashed/ghosted",defaults:{floor_height_ft:40,window_pattern:"none",floor_count:1}}];function PO({overlay:t,onUpdate:s,isUpdating:n}){const a=t.dc_module_type,l=Xv.find(u=>u.value===a),c=u=>
761{const i=Xv.find(j=>j.value===u);if(!i)return;const _={dc_module_type:u,floor_height_ft:i.defaults.floor_height_ft,window_pattern:i.defaults.window_pattern,floor_count:i.defaults.floor_count};u==="expansion_pad"?(_.opacity=.35,_.animated_border=!0,_.fill_pattern="diagonal"):a==="expansion_pad"&&(_.opacity=1,_.animated_border=!1,_.fill_pattern=null),s(_)};return e.jsxs(ns,{title:"DC Module Type",icon:e.jsx(P1,{className:"w-4 h-4"}),badge:l?e.jsx(Mt,{variant:"outline",className:"text-[10px] h-5",children:l.label}):void 0,defaultOpen:!0,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Classify this footprint as a specific data center module"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(rt,{value:a||"",onValueChange:c,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{placeholder:"Select module type..."})}),e.jsx(ot,{children:Xv.map(u=>{const i=u.icon;return e.jsx(le,{value:u.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{children:u.label})]})},u.value)})})]}),l&&e.jsxs("div",{className:"bg-muted/50 rounded-md px-3 py-2",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground",children:l.description}),e.jsxs("div",{className:"flex gap-3 mt-1.5",children:[e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["Height: ",e.jsxs("span",{className:"text-foreground font-medium",children:[l.defaults.floor_height_ft," ft"]})]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["Fenestration: ",e.jsx("span",{className:"text-foreground font-medium",children:l.defaults.window_pattern==="none"?"None":"Bands"})]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["Floors: ",e.jsx("span",{className:"text-foreground font-medium",children:l.defaults.floor_count})]})]})]})]})]})}function TO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Raised Access Floor",icon:e.jsx(dm,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Floor Height (inches)"}),e.jsxs(rt,{value:String(t.dc_raf_height_in??24),onValueChange:a=>s({dc_raf_height_in:parseInt(a)}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:[18,24,30,36,42,48].map(a=>e.jsxs(le,{value:String(a),className:"text-xs",children:[a,'" (',(a/12).toFixed(1)," ft)"]},a))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Load Rating (PSF)"}),e.jsx(be,{type:"number",min:100,max:2500,className:"h-7 text-xs",value:t.dc_raf_load_psf??1250,onChange:a=>s({dc_raf_load_psf:parseFloat(a.target.value)||1250}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Coverage (%)"}),e.jsx(be,{type:"number",min:0,max:100,className:"h-7 text-xs",value:t.dc_raf_coverage_pct??80,onChange:a=>s({dc_raf_coverage_pct:parseFloat(a.target.value)||80}),disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Perforated Tile Zones"}),e.jsx(kt,{checked:t.dc_raf_perforated_zones??!0,onCheckedChange:a=>s({dc_raf_perforated_zones:a}),disabled:n})]})]})})}function LO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Hot/Cold Aisle Containment",icon:e.jsx(W1,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Containment Type"}),e.jsxs(rt,{value:t.dc_containment_type||"hac",onValueChange:a=>s({dc_containment_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"hac",className:"text-xs",children:"Hot Aisle Containment (HAC)"}),e.jsx(le,{value:"cac",className:"text-xs",children:"Cold Aisle Containment (CAC)"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Row Count"}),e.jsx(be,{type:"number",min:1,max:50,className:"h-7 text-xs",value:t.dc_containment_row_count??8,onChange:a=>s({dc_containment_row_count:parseInt(a.target.value)||8}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Aisle Width (ft)"}),e.jsx(be,{type:"number",min:3,max:8,step:.5,className:"h-7 text-xs",value:t.dc_containment_aisle_width_ft??4,onChange:a=>s({dc_containment_aisle_width_ft:parseFloat(a.target.value)||4}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Containment Style"}),e.jsxs(rt,{value:t.dc_containment_style||"rigid_panel",onValueChange:a=>s({dc_containment_style:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"curtain",className:"text-xs",children:"Curtain"}),e.jsx(le,{value:"rigid_panel",className:"text-xs",children:"Rigid Panel"}),e.jsx(le,{value:"chimney",className:"text-xs",children:"Chimney"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Cabinets per Row"}),e.jsx(be,{type:"number",min:1,max:60,className:"h-7 text-xs",value:t.dc_containment_cabinets_per_row??20,onChange:a=>s({dc_containment_cabinets_per_row:parseInt(a.target.value)||20}),disabled:n})]})]})})}function MO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"UPS / Battery Room",icon:e.jsx(mS,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"UPS Type"}),e.jsxs(rt,{value:t.dc_ups_type||"static",onValueChange:a=>s({dc_ups_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"static",className:"text-xs",children:"Static (Battery)"}),e.jsx(le,{value:"rotary",className:"text-xs",children:"Rotary (Flywheel)"}),e.jsx(le,{value:"modular",className:"text-xs",children:"Modular"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Battery Type"}),e.jsxs(rt,{value:t.dc_ups_battery_type||"lithium_ion",onValueChange:a=>s({dc_ups_battery_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"vrla",className:"text-xs",children:"VRLA (Lead-Acid)"}),e.jsx(le,{value:"lithium_ion",className:"text-xs",children:"Lithium-Ion"}),e.jsx(le,{value:"flywheel",className:"text-xs",children:"Flywheel"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Runtime (min)"}),e.jsx(be,{type:"number",min:1,max:60,className:"h-7 text-xs",value:t.dc_ups_runtime_min??15,onChange:a=>s({dc_ups_runtime_min:parseFloat(a.target.value)||15}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Redun
761dancy"}),e.jsxs(rt,{value:t.dc_ups_redundancy||"2N",onValueChange:a=>s({dc_ups_redundancy:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"N",className:"text-xs",children:"N"}),e.jsx(le,{value:"N+1",className:"text-xs",children:"N+1"}),e.jsx(le,{value:"2N",className:"text-xs",children:"2N"})]})]})]})]})]})})}function IO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Electrical Switchgear Room",icon:e.jsx(d3,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Voltage"}),e.jsxs(rt,{value:t.dc_switchgear_voltage||"480V",onValueChange:a=>s({dc_switchgear_voltage:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"480V",className:"text-xs",children:"480V"}),e.jsx(le,{value:"12.47kV",className:"text-xs",children:"12.47 kV"}),e.jsx(le,{value:"15kV",className:"text-xs",children:"15 kV"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Bus Configuration"}),e.jsxs(rt,{value:t.dc_switchgear_config||"dual_bus",onValueChange:a=>s({dc_switchgear_config:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"single_bus",className:"text-xs",children:"Single-Bus"}),e.jsx(le,{value:"dual_bus",className:"text-xs",children:"Dual-Bus"}),e.jsx(le,{value:"ring_bus",className:"text-xs",children:"Ring-Bus"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"PDU Count"}),e.jsx(be,{type:"number",min:1,max:50,className:"h-7 text-xs",value:t.dc_switchgear_pdu_count??8,onChange:a=>s({dc_switchgear_pdu_count:parseInt(a.target.value)||8}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Bus Duct Routing"}),e.jsxs(rt,{value:t.dc_switchgear_bus_routing||"overhead",onValueChange:a=>s({dc_switchgear_bus_routing:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"overhead",className:"text-xs",children:"Overhead"}),e.jsx(le,{value:"underfloor",className:"text-xs",children:"Underfloor"})]})]})]})]})]})})}function AO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"CRAH / CRAC Units",icon:e.jsx(Y1,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Type"}),e.jsxs(rt,{value:t.dc_crah_type||"crah",onValueChange:a=>s({dc_crah_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"crah",className:"text-xs",children:"CRAH (Chilled Water)"}),e.jsx(le,{value:"crac",className:"text-xs",children:"CRAC (DX Refrigerant)"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Unit Count"}),e.jsx(be,{type:"number",min:1,max:50,className:"h-7 text-xs",value:t.dc_crah_count??12,onChange:a=>s({dc_crah_count:parseInt(a.target.value)||12}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Capacity (tons ea.)"}),e.jsx(be,{type:"number",min:5,max:200,className:"h-7 text-xs",value:t.dc_crah_capacity_tons??30,onChange:a=>s({dc_crah_capacity_tons:parseFloat(a.target.value)||30}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Placement"}),e.jsxs(rt,{value:t.dc_crah_placement||"perimeter",onValueChange:a=>s({dc_crah_placement:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"perimeter",className:"text-xs",children:"Perimeter"}),e.jsx(le,{value:"in_row",className:"text-xs",children:"In-Row"})]})]})]})]})})}function DO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Fire Suppression (Clean Agent)",icon:e.jsx(Ff,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Agent Type"}),e.jsxs(rt,{value:t.dc_fire_agent_type||"novec_1230",onValueChange:a=>s({dc_fire_agent_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"fm200",className:"text-xs",children:"FM-200"}),e.jsx(le,{value:"novec_1230",className:"text-xs",children:"Novec 1230"}),e.jsx(le,{value:"inergen",className:"text-xs",children:"Inergen"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Suppression Zones"}),e.jsx(be,{type:"number",min:1,max:20,className:"h-7 text-xs",value:t.dc_fire_zone_count??4,onChange:a=>s({dc_fire_zone_count:parseInt(a.target.value)||4}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Pre-Action Sprinkler"}),e.jsx(kt,{checked:t.dc_fire_has_preaction??!0,onCheckedChange:a=>s({dc_fire_has_preaction:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"VESDA Detection"}),e.jsx(kt,{checked:t.dc_fire_has_vesda??!0,onCheckedChange:a=>s({dc_fire_has_vesda:a}),disabled:n})]})]})})}function RO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Meet-Me Room (MMR)",icon:e.jsx(T5,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Room Count"}),e.jsx(be,{type:"number",min:1,max:4,className:"h-7 text-xs",value:t.dc_mmr_room_count??1,onChange:a=>s({dc_mmr_room_count:parseInt(a.target.value)||1}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Fiber Entries"}),e.jsx(be,{type:"number",min:1,max:10,className:"h-7 text-xs",value:t.dc_mmr_fiber_entries??2,onCh
761ange:a=>s({dc_mmr_fiber_entries:parseInt(a.target.value)||2}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Cross-Connect Type"}),e.jsxs(rt,{value:t.dc_mmr_cross_connect||"both",onValueChange:a=>s({dc_mmr_cross_connect:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"fiber",className:"text-xs",children:"Fiber Only"}),e.jsx(le,{value:"copper",className:"text-xs",children:"Copper Only"}),e.jsx(le,{value:"both",className:"text-xs",children:"Fiber + Copper"})]})]})]})]})})}function FO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"NOC / SOC",icon:e.jsx(C3,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Type"}),e.jsxs(rt,{value:t.dc_noc_type||"combined",onValueChange:a=>s({dc_noc_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"noc",className:"text-xs",children:"NOC Only"}),e.jsx(le,{value:"soc",className:"text-xs",children:"SOC Only"}),e.jsx(le,{value:"combined",className:"text-xs",children:"Combined NOC/SOC"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Console Positions"}),e.jsx(be,{type:"number",min:1,max:30,className:"h-7 text-xs",value:t.dc_noc_console_positions??6,onChange:a=>s({dc_noc_console_positions:parseInt(a.target.value)||6}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Video Wall"}),e.jsx(kt,{checked:t.dc_noc_has_video_wall??!0,onCheckedChange:a=>s({dc_noc_has_video_wall:a}),disabled:n})]}),(t.dc_noc_has_video_wall??!0)&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Display Count"}),e.jsx(be,{type:"number",min:1,max:20,className:"h-7 text-xs",value:t.dc_noc_video_wall_count??9,onChange:a=>s({dc_noc_video_wall_count:parseInt(a.target.value)||9}),disabled:n})]})]})})}function zO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Electrical Substation",icon:e.jsx(Xd,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Ownership"}),e.jsxs(rt,{value:t.dc_substation_type||"utility_owned",onValueChange:a=>s({dc_substation_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"utility_owned",className:"text-xs",children:"Utility-Owned"}),e.jsx(le,{value:"customer_owned",className:"text-xs",children:"Customer-Owned"}),e.jsx(le,{value:"shared",className:"text-xs",children:"Shared"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Incoming Voltage"}),e.jsxs(rt,{value:t.dc_substation_voltage||"138kV",onValueChange:a=>s({dc_substation_voltage:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"34.5kV",className:"text-xs",children:"34.5 kV"}),e.jsx(le,{value:"69kV",className:"text-xs",children:"69 kV"}),e.jsx(le,{value:"138kV",className:"text-xs",children:"138 kV"}),e.jsx(le,{value:"230kV",className:"text-xs",children:"230 kV"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Transformers"}),e.jsx(be,{type:"number",min:1,max:4,className:"h-7 text-xs",value:t.dc_substation_transformer_count??2,onChange:a=>s({dc_substation_transformer_count:parseInt(a.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Capacity (MVA)"}),e.jsx(be,{type:"number",min:1,className:"h-7 text-xs",value:t.dc_substation_capacity_mva??30,onChange:a=>s({dc_substation_capacity_mva:parseFloat(a.target.value)||30}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Redun
761dancy"}),e.jsxs(rt,{value:t.dc_substation_redundancy||"N+1",onValueChange:a=>s({dc_substation_redundancy:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"N",className:"text-xs",children:"N"}),e.jsx(le,{value:"N+1",className:"text-xs",children:"N+1"}),e.jsx(le,{value:"2N",className:"text-xs",children:"2N"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Switchyard"}),e.jsx(kt,{checked:t.dc_substation_has_switchyard??!1,onCheckedChange:a=>s({dc_substation_has_switchyard:a}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Fencing"}),e.jsxs(rt,{value:t.dc_substation_fence_type||"chain_link_barbed",onValueChange:a=>s({dc_substation_fence_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"chain_link_barbed",className:"text-xs",children:"Chain Link + Barbed Wire"}),e.jsx(le,{value:"cmu_screen",className:"text-xs",children:"CMU Screen Wall"})]})]})]})]})})}function OO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Generator Yard",icon:e.jsx(Xd,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Generator Count"}),e.jsx(be,{type:"number",min:1,max:50,className:"h-7 text-xs",value:t.dc_gen_yard_count??4,onChange:a=>s({dc_gen_yard_count:parseInt(a.target.value)||4}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Rating (kW each)"}),e.jsx(be,{type:"number",min:100,className:"h-7 text-xs",value:t.dc_gen_yard_rating_kw??2e3,onChange:a=>s({dc_gen_yard_rating_kw:parseFloat(a.target.value)||2e3}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Fuel Type"}),e.jsxs(rt,{value:t.dc_gen_yard_fuel_type||"diesel",onValueChange:a=>s({dc_gen_yard_fuel_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"diesel",className:"text-xs",children:"Diesel"}),e.jsx(le,{value:"natural_gas",className:"text-xs",children:"Natural Gas"}),e.jsx(le,{value:"dual_fuel",className:"text-xs",children:"Dual-Fuel"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Layout"}),e.jsxs(rt,{value:t.dc_gen_yard_layout||"double_row",onValueChange:a=>s({dc_gen_yard_layout:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"single_row",className:"text-xs",children:"Single Row"}),e.jsx(le,{value:"double_row",className:"text-xs",children:"Double Row"}),e.jsx(le,{value:"u_shaped",className:"text-xs",children:"U-Shaped"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Sound Attenuation"}),e.jsxs(rt,{value:t.dc_gen_yard_sound_attenuation||"level_2",onValueChange:a=>s({dc_gen_yard_sound_attenuation:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"standard",className:"text-xs",children:"Standard"}),e.jsx(le,{value:"level_1",className:"text-xs",children:"Level 1"}),e.jsx(le,{value:"level_2",className:"text-xs",children:"Level 2"}),e.jsx(le,{value:"level_3",className:"text-xs",children:"Level 3"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Exhaust Stack Height (ft)"}),e.jsx(be,{type:"number",min:10,max:100,className:"h-7 text-xs",value:t.dc_gen_yard_stack_height_ft??30,onChange:a=>s({dc_gen_yard_stack_height_ft:parseFloat(a.target.value)||30}),disabled:n})]})]})})}function BO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Chiller Plant / Cooling Yard",icon:e.jsx(SS,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Chiller Type"}),e.jsxs(rt,{value:t.dc_chiller_type||"water_cooled",onValueChange:a=>s({dc_chiller_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"air_cooled",className:"text-xs",children:"Air-Cooled"}),e.jsx(le,{value:"water_cooled",className:"text-xs",children:"Water-Cooled"}),e.jsx(le,{value:"free_cooling",className:"text-xs",children:"Free-Cooling"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Chiller Count"}),e.jsx(be,{type:"number",min:1,max:20,className:"h-7 text-xs",value:t.dc_chiller_count??4,onChange:a=>s({dc_chiller_count:parseInt(a.target.value)||4}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Capacity (tons ea.)"}),e.jsx(be,{type:"number",min:50,className:"h-7 text-xs",value:t.dc_chiller_capacity_tons??500,onChange:a=>s({dc_chiller_capacity_tons:parseFloat(a.target.value)||500}),disabled:n})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Cooling Towers"}),e.jsx(be,{type:"number",min:0,max:20,className:"h-7 text-xs",value:t.dc_cooling_tower_count??4,onChange:a=>s({dc_cooling_tower_count:parseInt(a.target.value)||4}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Tower Type"}),e.jsxs(rt,{value:t.dc_cooling_tower_type||"open_evaporative",onValueChange:a=>s({dc_cooling_tower_type:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"open_evaporative",className:"text-xs",children:"Open Evaporative"}),e.jsx(le,{value:"closed_circuit",className:"text-xs",children:"Closed-Circuit"}),e.jsx(le,{value:"dry_cooler",className:"text-xs",children:"Dry Cooler"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Pipe Routing"}),e.jsxs(rt,{value:t.dc_chiller_pipe_routing||"underground",onValueChange:a=>s({dc_chiller_pipe_routing:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"underground",className:"text-xs",children:"Underground"}),e.jsx(le,{value:"above_grade",className:"text-xs",children:"Above-Grade Pipe Rack"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Thermal Energy Storage (TES)"}),e.jsx(kt,{checked:t.dc_chiller_has_tes??!1,onCheckedChange:a=>s({dc_chiller_has_tes:a}),disabled:n})]})]})})}function $O({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Fuel Tank Farm",icon:e.jsx(X1,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Tank Count"}),e.jsx(be,{type:"number",min:1,max:10,className:"h-7 text-xs",value:t.dc_fuel_tank_count??2,onChange:a=>s({dc_fuel_tank_count:parseInt(a.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Tank Type"}),e.jsxs(rt,{value:t.dc_fuel_tank_type||"bulk_ast",onValueChange:a=>s({dc_fuel_tank_type:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"bulk_ast",className:"text-xs",children:"Bulk AST"}),e.jsx(le,{value:"ast",className:"text-xs",children:"Above-Ground (AST)"}),e.jsx(le,{value:"ust",className:"text-xs",children:"Underground (UST)"}),e.jsx(le,{value:"day_tank",className:"text-xs",children:"Day Tank"}),e.jsx(le,{value:"belly_tank",className:"text-xs",children:"Belly Tank (Integral)"}),e.jsx(le,{value:"sub_base",className:"text-xs",children:"Sub-Base (Under Gen)"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Capacity (gal ea.)"}),e.jsx(be,{type:"number",min:500,className:"h-7 text-xs",value:t.dc_fuel_tank_capacity_gal??2e4,onChange:a=>s({dc_fuel_tank_capacity_gal:parseFloat(a.target.value)||2e4}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Runtime (hrs)"}
761),e.jsx(be,{type:"number",min:1,className:"h-7 text-xs",value:t.dc_fuel_tank_runtime_hrs??48,onChange:a=>s({dc_fuel_tank_runtime_hrs:parseFloat(a.target.value)||48}),disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Secondary Containment"}),e.jsx(kt,{checked:t.dc_fuel_tank_has_containment??!0,onCheckedChange:a=>s({dc_fuel_tank_has_containment:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"SPCC Compliant"}),e.jsx(kt,{checked:t.dc_fuel_tank_spcc_compliant??!0,onCheckedChange:a=>s({dc_fuel_tank_spcc_compliant:a}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Piping Type"}),e.jsxs(rt,{value:t.dc_fuel_piping_type||"double_wall",onValueChange:a=>s({dc_fuel_piping_type:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"single_wall",className:"text-xs",children:"Single-Wall"}),e.jsx(le,{value:"double_wall",className:"text-xs",children:"Double-Wall"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Truck Fill Station"}),e.jsx(kt,{checked:t.dc_fuel_fill_station??!1,onCheckedChange:a=>s({dc_fuel_fill_station:a}),disabled:n})]})]})})}function VO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Perimeter Security System",icon:e.jsx(hd,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Fence Type"}),e.jsxs(rt,{value:t.dc_security_fence_type||"anti_climb",onValueChange:a=>s({dc_security_fence_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"chain_link_razor",className:"text-xs",children:"Chain Link + Razor Wire"}),e.jsx(le,{value:"anti_climb",className:"text-xs",children:"Anti-Climb"}),e.jsx(le,{value:"concrete",className:"text-xs",children:"Concrete"}),e.jsx(le,{value:"bollard_line",className:"text-xs",children:"Bollard Line"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Fence Height (ft)"}),e.jsxs(rt,{value:String(t.dc_security_fence_height_ft??10),onValueChange:a=>s({dc_security_fence_height_ft:parseInt(a)}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"8",className:"text-xs",children:"8 ft"}),e.jsx(le,{value:"10",className:"text-xs",children:"10 ft"}),e.jsx(le,{value:"12",className:"text-xs",children:"12 ft"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Clear Zone (ft)"}),e.jsx(be,{type:"number",min:0,max:50,className:"h-7 text-xs",value:t.dc_security_clear_zone_ft??20,onChange:a=>s({dc_security_clear_zone_ft:parseFloat(a.target.value)||20}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Vehicle Barriers"}),e.jsxs(rt,{value:t.dc_security_barrier_type||"k_rated_bollards",onValueChange:a=>s({dc_security_barrier_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"k_rated_bollards",className:"text-xs",children:"K-Rated Bollards"}),e.jsx(le,{value:"planter_barriers",className:"text-xs",children:"Planter Barriers"}),e.jsx(le,{value:"jersey_barriers",className:"text-xs",children:"Jersey Barriers"}),e.jsx(le,{value:"wedge_barriers",className:"text-xs",children:"Wedge Barriers"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Crash Rating"}),e.jsxs(rt,{value:t.dc_security_k_rating||"K8",onValueChange:a=>s({dc_security_k_rating:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"K4",className:"text-xs",children:"K4"}),e.jsx(le,{value:"K8",className:"text-xs",children:"K8"}),e.jsx(le,{value:"K12",className:"text-xs",children:"K12"}),e.jsx(le,{value:"M30",className:"text-xs",children:"M30 (ASTM)"}),e.jsx(le,{value:"M40",className:"text-xs",children:"M40 (ASTM)"}),e.jsx(le,{value:"M50",className:"text-xs",children:"M50 (ASTM)"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Anti-Climb Topping"}),e.jsxs(rt,{value:t.dc_security_anti_climb_top||"concertina",onValueChange:a=>s({dc_security_anti_climb_top:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"razor_wire",className:"text-xs",children:"Razor Wire"}),e.jsx(le,{value:"concertina",className:"text-xs",children:"Concertina"}),e.jsx(le,{value:"rotating_spikes",className:"text-xs",children:"Rotating Spikes"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Intrusion Detection (IDS)"}),e.jsxs(rt,{value:t.dc_security_ids_type||"fence_sensor",onValueChange:a=>s({dc_security_ids_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"fence_sensor",className:"text-xs",children:"Fence-Mounted Sensor"}),e.jsx(le,{value:"buried_cable",className:"text-xs",children:"Buried Cable"}),e.jsx(le,{value:"microwave",className:"text-xs",children:"Microwave"}),e.jsx(le,{value:"laser",className:"text-xs",children:"Laser"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Guard Booths"}),e.jsx(be,{type:"number",min:0,max:10,className:"h-7 text-xs",value:t.dc_security_guard_count??2,onChange:a=>s({dc_security_guard_count:parseInt(a.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Camera Poles"}),e.jsx(be,{type:"number",min:0,max:100,className:"h-7 text-xs",value:t.dc_security_camera_count??20,onChange:a=>s({dc_security_camera_count:parseInt(a.target.value)||20}),disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Mantrap / Sally Port"}),e.jsx(kt,{checked:t.dc_security_has_mantrap??!0,onCheckedChange:a=>s({dc_security_has_mantrap:a}),disabled:n})]})]})})}function qO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Fiber Entry Vault",icon:e.jsx(lm,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Vault Count"}),e.jsx(be,{type:"number",min:1,max:6,className:"h-7 text-xs",value:t.dc_fiber_vault_count??2,onChange:a=>s({dc_fiber_vault_count:parseInt(a.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Vault Type"}),e.jsxs(rt,{value:t.dc_fiber_vault_type||"manhole",onValueChange:a=>s({dc_fiber_vault_type:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"manhole",className:"text-xs",children:"Manhole"}),e.jsx(le,{value:"handhole",className:"text-xs",children:"Handhole"}),e.jsx(le,{value:"direct_buried",className:"text-xs",children:"Direct Buried"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Diverse Paths"}),e.jsx(be,{type:"number",min:1,max:6,className:"h-7 text-xs",value:t.dc_fiber_diverse_paths??2,onCh
761ange:a=>s({dc_fiber_diverse_paths:parseInt(a.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Conduits"}),e.jsx(be,{type:"number",min:1,max:20,className:"h-7 text-xs",value:t.dc_fiber_conduit_count??4,onChange:a=>s({dc_fiber_conduit_count:parseInt(a.target.value)||4}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Carriers"}),e.jsx(be,{type:"number",min:1,max:20,className:"h-7 text-xs",value:t.dc_fiber_carrier_count??3,onChange:a=>s({dc_fiber_carrier_count:parseInt(a.target.value)||3}),disabled:n})]})]})]})})}function GO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Emergency Tie-In Pad",icon:e.jsx(I3,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Pad Count"}),e.jsx(be,{type:"number",min:1,max:6,className:"h-7 text-xs",value:t.dc_tiein_pad_count??2,onChange:a=>s({dc_tiein_pad_count:parseInt(a.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Capacity (MW)"}),e.jsx(be,{type:"number",min:.5,step:.5,className:"h-7 text-xs",value:t.dc_tiein_capacity_mw??2,onChange:a=>s({dc_tiein_capacity_mw:parseFloat(a.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Cam-Locks"}),e.jsx(be,{type:"number",min:1,max:20,className:"h-7 text-xs",value:t.dc_tiein_camlock_count??6,onChange:a=>s({dc_tiein_camlock_count:parseInt(a.target.value)||6}),disabled:n})]})]})})})}function HO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Water Treatment / Makeup",icon:e.jsx(Kc,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Water Source"}),e.jsxs(rt,{value:t.dc_water_source||"municipal",onValueChange:a=>s({dc_water_source:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"municipal",className:"text-xs",children:"Municipal"}),e.jsx(le,{value:"well_water",className:"text-xs",children:"Well Water"}),e.jsx(le,{value:"recycled",className:"text-xs",children:"Recycled Water"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Treatment"}),e.jsxs(rt,{value:t.dc_water_treatment||"chemical",onValueChange:a=>s({dc_water_treatment:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"ro",className:"text-xs",children:"Reverse Osmosis"}),e.jsx(le,{value:"chemical",className:"text-xs",children:"Chemical"}),e.jsx(le,{value:"filtration",className:"text-xs",children:"Filtration"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Storage (gallons)"}),e.jsx(be,{type:"number",min:1e3,className:"h-7 text-xs",value:t.dc_water_storage_gal??5e4,onChange:a=>s({dc_water_storage_gal:parseFloat(a.target.value)||5e4}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Redundant Feed"}),e.jsx(kt,{checked:t.dc_water_redundant_feed??!1,onCheckedChange:a=>s({dc_water_redundant_feed:a}),disabled:n})]})]})})}function ZO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Medium Voltage Distribution",icon:e.jsx(lm,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Voltage"}),e.jsxs(rt,{value:t.dc_mv_voltage||"15kV",onValueChange:a=>s({dc_mv_voltage:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"12.47kV",className:"text-xs",children:"12.47 kV"}),e.jsx(le,{value:"15kV",className:"text-xs",children:"15 kV"}),e.jsx(le,{value:"34.5kV",className:"text-xs",children:"34.5 kV"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Routing"}),e.jsxs(rt,{value:t.dc_mv_routing||"underground",onValueChange:a=>s({dc_mv_routing:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"underground",className:"text-xs",children:"Underground Duct Bank"}),e.jsx(le,{value:"overhead",className:"text-xs",children:"Overhead"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Conduit Count"}),e.jsx(be,{type:"number",min:1,max:20,className:"h-7 text-xs",value:t.dc_mv_conduit_count??6,onChange:a=>s({dc_mv_conduit_count:parseInt(a.target.value)||6}),disabled:n})]})]})})}function WO({overlay:t,onUpdate:s,isUpdating:n}
761){return e.jsx(ns,{title:"Dark Fiber / Conduit Network",icon:e.jsx(lm,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Conduits"}),e.jsx(be,{type:"number",min:1,max:20,className:"h-7 text-xs",value:t.dc_dark_fiber_conduit_count??4,onChange:a=>s({dc_dark_fiber_conduit_count:parseInt(a.target.value)||4}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Strands"}),e.jsx(be,{type:"number",min:12,max:864,className:"h-7 text-xs",value:t.dc_dark_fiber_strand_count??144,onChange:a=>s({dc_dark_fiber_strand_count:parseInt(a.target.value)||144}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Splice Vaults"}),e.jsx(be,{type:"number",min:0,max:20,className:"h-7 text-xs",value:t.dc_dark_fiber_splice_vaults??2,onChange:a=>s({dc_dark_fiber_splice_vaults:parseInt(a.target.value)||2}),disabled:n})]})]})})})}function YO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Redundant Utility Feeds",icon:e.jsx(zx,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Feed Count"}),e.jsx(be,{type:"number",min:1,max:4,className:"h-7 text-xs",value:t.dc_utility_feed_count??2,onChange:a=>s({dc_utility_feed_count:parseInt(a.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"ATS/STS Count"}),e.jsx(be,{type:"number",min:0,max:10,className:"h-7 text-xs",value:t.dc_utility_ats_count??2,onChange:a=>s({dc_utility_ats_count:parseInt(a.target.value)||2}),disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Diverse Paths"}),e.jsx(kt,{checked:t.dc_utility_diverse_paths??!0,onCheckedChange:a=>s({dc_utility_diverse_paths:a}),disabled:n})]})]})})}function XO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Chilled Water Distribution",icon:e.jsx(M3,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Pipe Size (in)"}),e.jsx(be,{type:"number",min:4,max:36,className:"h-7 text-xs",value:t.dc_chw_pipe_size_in??16,onChange:a=>s({dc_chw_pipe_size_in:parseFloat(a.target.value)||16}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Valve Stations"}),e.jsx(be,{type:"number",min:0,max:20,className:"h-7 text-xs",value:t.dc_chw_valve_stations??4,onChange:a=>s({dc_chw_valve_stations:parseInt(a.target.value)||4}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Routing"}),e.jsxs(rt,{value:t.dc_chw_routing||"underground",onValueChange:a=>s({dc_chw_routing:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"underground",className:"text-xs",children:"Underground"}),e.jsx(le,{value:"above_grade",className:"text-xs",children:"Above-Grade Pipe Rack"})]})]})]})]})})}function KO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"E-House / Switchgear Skid",icon:e.jsx(Xd,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Skid Count"}),e.jsx(be,{type:"number",min:1,max:20,className:"h-7 text-xs",value:t.dc_ehouse_count??1,onChange:a=>s({dc_ehouse_count:parseInt(a.target.value)||1}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Voltage Class"}),e.jsxs(rt,{value:t.dc_ehouse_voltage_class||"MV",onValueChange:a=>s({dc_ehouse_voltage_class:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"MV",className:"text-xs",children:"Medium Voltage (MV)"}),e.jsx(le,{value:"LV",className:"text-xs",children:"Low Voltage (LV)"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Configuration"}),e.jsxs(rt,{value:t.dc_ehouse_type||"walk_in",onValueChange:a=>s({dc_ehouse_type:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"walk_in",className:"text-xs",children:"Walk-In"}),e.jsx(le,{value:"non_walk_in",className:"text-xs",children:"Non-Walk-In"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Redun
761dancy"}),e.jsxs(rt,{value:t.dc_ehouse_redundancy||"N+1",onValueChange:a=>s({dc_ehouse_redundancy:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"N",className:"text-xs",children:"N (No Redundancy)"}),e.jsx(le,{value:"N+1",className:"text-xs",children:"N+1"})]})]})]})]})]})})}function JO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Battery Energy Storage (BESS)",icon:e.jsx(mS,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Container Count"}),e.jsx(be,{type:"number",min:1,max:50,className:"h-7 text-xs",value:t.dc_bess_count??1,onChange:a=>s({dc_bess_count:parseInt(a.target.value)||1}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Chemistry"}),e.jsxs(rt,{value:t.dc_bess_chemistry||"lfp",onValueChange:a=>s({dc_bess_chemistry:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"lithium_ion",className:"text-xs",children:"Lithium-Ion (NMC)"}),e.jsx(le,{value:"lfp",className:"text-xs",children:"LFP (Lithium Iron Phosphate)"}),e.jsx(le,{value:"flow",className:"text-xs",children:"Flow Battery"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Capacity (MWh ea.)"}),e.jsx(be,{type:"number",min:.1,step:.1,className:"h-7 text-xs",value:t.dc_bess_capacity_mwh??2,onChange:a=>s({dc_bess_capacity_mwh:parseFloat(a.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Power Rating (MW)"}),e.jsx(be,{type:"number",min:.1,step:.1,className:"h-7 text-xs",value:t.dc_bess_power_mw??1,onChange:a=>s({dc_bess_power_mw:parseFloat(a.target.value)||1}),disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Inverter Integrated"}),e.jsx(kt,{checked:t.dc_bess_inverter_integrated??!0,onCheckedChange:a=>s({dc_bess_inverter_integrated:a}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Fire Suppression"}),e.jsxs(rt,{value:t.dc_bess_fire_suppression||"aerosol",onValueChange:a=>s({dc_bess_fire_suppression:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"aerosol",className:"text-xs",children:"Aerosol"}),e.jsx(le,{value:"clean_agent",className:"text-xs",children:"Clean Agent"}),e.jsx(le,{value:"water_mist",className:"text-xs",children:"Water Mist"})]})]})]})]})})}function QO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Fuel Containment Berm",icon:e.jsx(hd,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Berm Height (ft)"}),e.jsx(be,{type:"number",min:1,max:10,step:.5,className:"h-7 text-xs",value:t.dc_berm_height_ft??3,onChange:a=>s({dc_berm_height_ft:parseFloat(a.target.value)||3}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Material"}),e.jsxs(rt,{value:t.dc_berm_material||"concrete",onValueChange:a=>s({dc_berm_material:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"concrete",className:"text-xs",children:"Concrete"}),e.jsx(le,{value:"earthen",className:"text-xs",children:"Earthen"}),e.jsx(le,{value:"steel",className:"text-xs",children:"Steel"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Capacity (% of Largest Tank)"}),e.jsx(be,{type:"number",min:100,max:200,className:"h-7 text-xs",value:t.dc_berm_capacity_pct??110,onChange:a=>s({dc_berm_capacity_pct:parseFloat(a.target.value)||110}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Leak Detection"}),e.jsx(kt,{checked:t.dc_berm_leak_detection??!1,onCheckedChange:a=>s({dc_berm_leak_detection:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Oil-Water Separator"}),e.jsx(kt,{checked:t.dc_berm_ows??!1,onCheckedChange:a=>s({dc_berm_ows:a}),disabled:n})]})]})})}function UO({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Acoustic Enclosure",icon:e.jsx(LS,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Attenuation (dBA)"}),e.jsxs(rt,{value:String(t.dc_acoustic_db_reduction??25),onValueChange:a=>s({dc_acoustic_db_reduction:parseFloat(a)}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"15",className:"text-xs",children:"15 dBA"}),e.jsx(le,{value:"25",className:"text-xs",children:"25 dBA"}),e.jsx(le,{value:"35",className:"text-xs",children:"35 dBA"}),e.jsx(le,{value:"45",className:"text-xs",children:"45 dBA"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Wall Type"}),e.jsxs(rt,{value:t.dc_acoustic_wall_type||"insulated_metal",onValueChange:a=>s({dc_acoustic_wall_type:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"cmu",className:"text-xs",children:"CMU"}),e.jsx(le,{value:"insulated_metal",className:"text-xs",children:"Insulated Metal Panel"}),e.jsx(le,{value:"modular",className:"text-xs",children:"Modular"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Roof Type"}),e.jsxs(rt,{value:t.dc_acoustic_roof_type||"flat",onValueChange:a=>s({dc_acoustic_roof_type:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"flat",className:"text-xs",children:"Flat"}),e.jsx(le,{value:"peaked",className:"text-xs",children:"Peaked"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Ventilation Louvers"}),e.jsx(kt,{checked:t.dc_acoustic_has_louvers??!0,onCheckedChange:a=>s({dc_acoustic_has_louvers:a}),disabled:n})]})]})})}function e6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Cooling Tower Yard",icon:e.jsx(Kc,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Tower Count"}),e.jsx(be,{type:"number",min:1,max:40,value:t.dc_ct_yard_count??4,onChange:a=>s({dc_ct_yard_count:parseInt(a.target.value)||4}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Cells / Tower"}),e.jsx(be,{type:"number",min:1,max:12,value:t.dc_ct_cells_per_tower??2,onChange:a=>s({dc_ct_cells_per_tower:parseInt(a.target.value)||2}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Tower Type"}),e.jsxs(rt,{value:t.dc_ct_yard_type??"open_evaporative",onValueChange:a=>s({dc_ct_yard_type:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"open_evaporative",children:"Open Evaporative"}),e.jsx(le,{value:"closed_circuit",children:"Closed Circuit"}),e.jsx(le,{value:"hybrid",children:"Hybrid"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Capacity (tons ea.)"}),e.jsx(be,{type:"number",min:50,step:50,value:t.dc_ct_capacity_tons??500,onChange:a=>s({dc_ct_capacity_tons:parseFloat(a.target.value)||500}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Fan Type"}),e.jsxs(rt,{value:t.dc_ct_fan_type??"axial",onValueChange:a=>s({dc_ct_fan_type:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"axial",children:"Axial"}),e.jsx(le,{value:"centrifugal",children:"Centrifugal"})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Basin Material"}),e.jsxs(rt,{value:t.dc_ct_basin_material??"concrete",onValueChange:a=>s({dc_ct_basin_material:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"concrete",children:"Concrete"}),e.jsx(le,{value:"frp",children:"FRP (Fiberglass)"}),e.jsx(le,{value:"steel",children:"Galvanized Steel"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Drift Eliminators"}),e.jsx(kt,{checked:t.dc_ct_drift_eliminators??!0,onCheckedChange:a=>s({dc_ct_drift_eliminators:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Plume Abatement"}),e.jsx(kt,{checked:t.dc_ct_plume_abatement??!1,onCheckedChange:a=>s({dc_ct_plume_abatement:a}),disabled:n})]}),e.jsxs("div",{className:"p-2 rounded bg-muted/50 text-xs text-muted-foreground",children:["Total Capacity: ",e.jsxs("span",{className:"font-medium text-foreground",children:[((t.dc_ct_yard_count??4)*(t.dc_ct_capacity_tons??500)).toLocaleStr
761ing()," tons"]})]})]})})}function t6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Dry / Adiabatic Cooler Yard",icon:e.jsx(T1,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Unit Count"}),e.jsx(be,{type:"number",min:1,max:60,value:t.dc_dry_cooler_count??4,onChange:a=>s({dc_dry_cooler_count:parseInt(a.target.value)||4}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Fans / Unit"}),e.jsx(be,{type:"number",min:1,max:16,value:t.dc_dry_cooler_fans_per_unit??4,onChange:a=>s({dc_dry_cooler_fans_per_unit:parseInt(a.target.value)||4}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Cooler Type"}),e.jsxs(rt,{value:t.dc_dry_cooler_type??"dry",onValueChange:a=>s({dc_dry_cooler_type:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"dry",children:"Dry Cooler"}),e.jsx(le,{value:"adiabatic",children:"Adiabatic"}),e.jsx(le,{value:"hybrid",children:"Hybrid (Dry + Adiabatic)"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Capacity / Unit (kW)"}),e.jsx(be,{type:"number",min:50,step:50,value:t.dc_dry_cooler_capacity_kw??500,onChange:a=>s({dc_dry_cooler_capacity_kw:parseFloat(a.target.value)||500}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Noise Level (dBA)"}),e.jsx(be,{type:"number",min:40,max:110,value:t.dc_dry_cooler_noise_dba??75,onChange:a=>s({dc_dry_cooler_noise_dba:parseFloat(a.target.value)||75}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Spray Assist (Adiabatic)"}),e.jsx(kt,{checked:t.dc_dry_cooler_spray_assist??!1,onCheckedChange:a=>s({dc_dry_cooler_spray_assist:a}),disabled:n})]}),e.jsxs("div",{className:"p-2 rounded bg-muted/50 text-xs text-muted-foreground",children:["Total Capacity: ",e.jsxs("span",{className:"font-medium text-foreground",children:[((t.dc_dry_cooler_count??4)*(t.dc_dry_cooler_capacity_kw??500)).toLocaleString()," kW"]})]})]})})}function s6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Cooling Pipe Rack",icon:e.jsx(uo,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Height (ft)"}),e.jsx(be,{type:"number",min:8,max:40,value:t.dc_pipe_rack_height_ft??15,onChange:a=>s({dc_pipe_rack_height_ft:parseFloat(a.target.value)||15}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",min:4,max:20,value:t.dc_pipe_rack_width_ft??8,onChange:a=>s({dc_pipe_rack_width_ft:parseFloat(a.target.value)||8}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Pipe Count"}),e.jsx(be,{type:"number",min:1,max:24,value:t.dc_pipe_rack_pipe_count??6,onChange:a=>s({dc_pipe_rack_pipe_count:parseInt(a.target.value)||6}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Rack Material"}),e.jsxs(rt,{value:t.dc_pipe_rack_material??"steel",onValueChange:a=>s({dc_pipe_rack_material:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"steel",children:"Structural Steel"}),e.jsx(le,{value:"aluminum",children:"Aluminum"}),e.jsx(le,{value:"frp",children:"FRP (Fiberglass)"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Includes Walkway"}),e.jsx(kt,{checked:t.dc_pipe_rack_has_walkway??!0,onCheckedChange:a=>s({dc_pipe_rack_has_walkway:a}),disabled:n})]})]})})}function n6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Heat Exchanger Skid",icon:e.jsx(A3,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"HX Count"}),e.jsx(be,{type:"number",min:1,max:20,value:t.dc_hx_count??2,onChange:a=>s({dc_hx_count:parseInt(a.target.value)||2}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Capacity (tons)"}),e.jsx(be,{type:"number",min:50,step:50,value:t.dc_hx_capacity_tons??500,onChange:a=>s({dc_hx_capacity_tons:parseFloat(a.target.value)||500}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"HX Type"}),e.jsxs(rt,{value:t.dc_hx_type??"plate_frame",onValueChange:a=>s({dc_hx_type:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"plate_frame",children:"Plate-and-Frame"}),e.jsx(le,{value:"shell_tube",children:"Shell-and-Tube"}),e.jsx(le,{value:"air_to_air",children:"Air-to-Air"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Working Fluid"}),e.jsxs(rt,{value:t.dc_hx_fluid??"water",onValueChange:a=>s({dc_hx_fluid:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"water",children:"Water"}),e.jsx(le,{value:"glycol",children:"Glycol"}),e.jsx(le,{value:"refrigerant",children:"Refrigerant"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Free-Cooling Enabled"}),e.jsx(kt,{checked:t.dc_hx_free_cooling??!0,onCheckedChange:a=>s({dc_hx_free_cooling:a}),disabled:n})]}),e.jsxs("div",{className:"p-2 rounded bg-muted/50 text-xs text-muted-foreground",children:["Total Capacity: ",e.jsxs("span",{className:"font-medium text-foreground",children:[((t.dc_hx_count??2)*(t.dc_hx_capacity_tons??500)).toLocaleStr
761ing()," tons"]})]})]})})}function a6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Pump House",icon:e.jsx(uh,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Pump Count"}),e.jsx(be,{type:"number",min:1,max:20,value:t.dc_pump_count??4,onChange:a=>s({dc_pump_count:parseInt(a.target.value)||4}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Motor HP"}),e.jsx(be,{type:"number",min:5,step:25,value:t.dc_pump_motor_hp??100,onChange:a=>s({dc_pump_motor_hp:parseFloat(a.target.value)||100}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Pump Type"}),e.jsxs(rt,{value:t.dc_pump_type??"chw_primary",onValueChange:a=>s({dc_pump_type:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"chw_primary",children:"CHW Primary"}),e.jsx(le,{value:"chw_secondary",children:"CHW Secondary"}),e.jsx(le,{value:"condenser_water",children:"Condenser Water"}),e.jsx(le,{value:"fire",children:"Fire Pump"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Redundancy"}),e.jsxs(rt,{value:t.dc_pump_redundancy??"N+1",onValueChange:a=>s({dc_pump_redundancy:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"N",children:"N (No Redundancy)"}),e.jsx(le,{value:"N+1",children:"N+1"}),e.jsx(le,{value:"2N",children:"2N"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"VFD Equipped"}),e.jsx(kt,{checked:t.dc_pump_vfd??!0,onCheckedChange:a=>s({dc_pump_vfd:a}),disabled:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Building L (ft)"}),e.jsx(be,{type:"number",min:10,max:200,value:t.dc_pump_building_l_ft??40,onChange:a=>s({dc_pump_building_l_ft:parseFloat(a.target.value)||40}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Building W (ft)"}),e.jsx(be,{type:"number",min:10,max:200,value:t.dc_pump_building_w_ft??30,onChange:a=>s({dc_pump_building_w_ft:parseFloat(a.target.value)||30}),className:"h-8 text-xs",disabled:n})]})]})]})})}function r6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"DC Roof Screen Yard",icon:e.jsx(W1,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Screen Height (ft)"}),e.jsx(be,{type:"number",min:4,max:30,value:t.dc_roof_screen_height_ft??12,onChange:a=>s({dc_roof_screen_height_ft:parseFloat(a.target.value)||12}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Screen Length (ft)"}),e.jsx(be,{type:"number",min:10,max:500,value:t.dc_roof_screen_length_ft??100,onChange:a=>s({dc_roof_screen_length_ft:parseFloat(a.target.value)||100}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Screen Material"}),e.jsxs(rt,{value:t.dc_roof_screen_material??"louver",onValueChange:a=>s({dc_roof_screen_material:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"louver",children:"Louver"}),e.jsx(le,{value:"solid",children:"Solid Panel"}),e.jsx(le,{value:"perforated_metal",children:"Perforated Metal"}),e.jsx(le,{value:"architectural",children:"Architectural Screen"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Number of Bays"}),e.jsx(be,{type:"number",min:1,max:30,value:t.dc_roof_screen_bays??6,onChange:a=>s({dc_roof_screen_bays:parseInt(a.target.value)||6}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Access Gate"}),e.jsx(kt,{checked:t.dc_roof_screen_has_gate??!0,onCheckedChange:a=>s({dc_roof_screen_has_gate:a}),disabled:n})]})]})})}function i6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"DC Security Guardhouse",icon:e.jsx(Fy,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Guardhouse Type"}),e.jsxs(rt,{value:t.dc_guardhouse_type||"hardened",onValueChange:a=>s({dc_guardhouse_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"standard",className:"text-xs",children:"Standard"}),e.jsx(le,{value:"hardened",className:"text-xs",children:"Hardened"}),e.jsx(le,{value:"blast_resistant",className:"text-xs",children:"Blast-Resistant"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Construction"}),e.jsxs(rt,{value:t.dc_guardhouse_construction||"precast_concrete",onValueChange:a=>s({dc_guardhouse_construction:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"cmu",className:"text-xs",children:"CMU"}),e.jsx(le,{value:"precast_concrete",className:"text-xs",children:"Precast Concrete"}),e.jsx(le,{value:"modular",className:"text-xs",children:"Modular"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",min:6,max:30,className:"h-7 text-xs",value:t.dc_guardhouse_size_s_ft??12,onChange:a=>s({dc_guardhouse_size_s_ft:parseFloat(a.target.value)||12}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Length (ft)"}),e.jsx(be,{type:"number",min:8,max:50,className:"h-7 text-xs",value:t.dc_guardhouse_size_l_ft??20,onChange:a=>s({dc_guardhouse_size_l_ft:parseFloat(a.target.value)||20}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Staffing"}),e.jsxs(rt,{value:t.dc_guardhouse_staffing||"24_7",onValueChange:a=>s({dc_guardhouse_staffing:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"24_7",className:"text-xs",children:"24/7"}),e.jsx(le,{value:"business_hours",className:"text-xs",children:"Business Hours"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Boom Barrier Count"}),e.jsx(be,{type:"number",min:0,max:6,className:"h-7 text-xs",value:t.dc_guardhouse_boom_count??2,onChange:a=>s({dc_guardhouse_boom_count:parseInt(a.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Vehicle Inspection Pit"}),e.jsx(kt,{checked:t.dc_guardhouse_vehicle_pit??!1,onCheckedChange:a=>s({dc_guardhouse_vehicle_pit:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Package Screening"}),e.jsx(kt,{checked:t.dc_guardhouse_pkg_screening??!0,onCheckedChange:a=>s({dc_guardhouse_pkg_screening:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Biometric Access"}),e.jsx(kt,{checked:t.dc_guardhouse_biometric??!0,onCheckedChange:a=>s({dc_guardhouse_biometric:a}),disabled:n})]})]})})}function o6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"DC Sally Port",icon:e.jsx(jc,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Gate Type"}),e.jsxs(rt,{value:t.dc_sally_gate_type||"slide",onValueChange:a=>s({dc_sally_gate_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"swing",className:"text-xs",children:"Swing"}),e.jsx(le,{value:"slide",className:"text-xs",children:"Slide"}),e.jsx(le,{value:"vertical_lift",className:"text-xs",children:"Vertical Lift"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Gate Width (ft)"}),e.jsx(be,{type:"number",min:10,max:40,className:"h-7 text-xs",value:t.dc_sally_gate_width_ft??20,onChange:a=>s({dc_sally_gate_width_ft:parseFloat(a.target.value)||20}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Gate Height (ft)"}),e.jsx(be,{type:"number",min:6,max:20,className:"h-7 text-xs",value:t.dc_sally_gate_height_ft??10,onChange:a=>s({dc_sally_gate_height_ft:parseFloat(a.target.value)||10}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Vehicle Trap Length (ft)"}),e.jsx(be,{type:"number",min:20,max:80,className:"h-7 text-xs",value:t.dc_sally_trap_length_ft??40,onChange:a=>s({dc_sally_trap_length_ft:parseFloat(a.target.value)||40}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Anti-Tailgate Detection"}),e.jsx(kt,{checked:t.dc_sally_anti_tailgate??!0,onCheckedChange:a=>s({dc_sally_anti_tailgate:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Tire Shredder"}),e.jsx(kt,{checked:t.dc_sally_tire_shredder??!1,onCheckedChange:a=>s({dc_sally_tire_shredder:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Under-Vehicle Inspection (UVIS)"}),e.jsx(kt,{checked:t.dc_sally_uvis??!0,onCheckedChange:a=>s({dc_sally_uvis:a}),disabled:n})]})]})})}function l6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"DC Wedge Barrier",icon:e.jsx(Ag,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Barrier Type"}
761),e.jsxs(rt,{value:t.dc_wedge_barrier_type||"wedge",onValueChange:a=>s({dc_wedge_barrier_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"wedge",className:"text-xs",children:"Wedge"}),e.jsx(le,{value:"drop_arm",className:"text-xs",children:"Drop Arm"}),e.jsx(le,{value:"retractable_bollard",className:"text-xs",children:"Retractable Bollard"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Crash Rating"}),e.jsxs(rt,{value:t.dc_wedge_crash_rating||"M30",onValueChange:a=>s({dc_wedge_crash_rating:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"K4",className:"text-xs",children:"K4"}),e.jsx(le,{value:"K8",className:"text-xs",children:"K8"}),e.jsx(le,{value:"K12",className:"text-xs",children:"K12"}),e.jsx(le,{value:"M30",className:"text-xs",children:"M30 (ASTM)"}),e.jsx(le,{value:"M40",className:"text-xs",children:"M40 (ASTM)"}),e.jsx(le,{value:"M50",className:"text-xs",children:"M50 (ASTM)"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Operation"}),e.jsxs(rt,{value:t.dc_wedge_operation||"hydraulic",onValueChange:a=>s({dc_wedge_operation:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"hydraulic",className:"text-xs",children:"Hydraulic"}),e.jsx(le,{value:"pneumatic",className:"text-xs",children:"Pneumatic"}),e.jsx(le,{value:"manual",className:"text-xs",children:"Manual"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",min:4,max:30,className:"h-7 text-xs",value:t.dc_wedge_width_ft??12,onChange:a=>s({dc_wedge_width_ft:parseFloat(a.target.value)||12}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Emergency Fast-Operate"}),e.jsx(kt,{checked:t.dc_wedge_fast_operate??!0,onCheckedChange:a=>s({dc_wedge_fast_operate:a}),disabled:n})]})]})})}function c6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"DC Camera Pole Array",icon:e.jsx(k0,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Pole Count"}),e.jsx(be,{type:"number",min:1,max:100,className:"h-7 text-xs",value:t.dc_camera_pole_count??8,onChange:a=>s({dc_camera_pole_count:parseInt(a.target.value)||8}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Pole Height (ft)"}),e.jsx(be,{type:"number",min:10,max:50,className:"h-7 text-xs",value:t.dc_camera_pole_height_ft??25,onChange:a=>s({dc_camera_pole_height_ft:parseFloat(a.target.value)||25}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Camera Type"}),e.jsxs(rt,{value:t.dc_camera_type||"ptz",onValueChange:a=>s({dc_camera_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"ptz",className:"text-xs",children:"PTZ"}),e.jsx(le,{value:"fixed",className:"text-xs",children:"Fixed"}),e.jsx(le,{value:"thermal",className:"text-xs",children:"Thermal"}),e.jsx(le,{value:"lpr",className:"text-xs",children:"LPR (License Plate)"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Spacing (ft)"}),e.jsx(be,{type:"number",min:20,max:300,className:"h-7 text-xs",value:t.dc_camera_spacing_ft??100,onChange:a=>s({dc_camera_spacing_ft:parseFloat(a.target.value)||100}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Monitoring"}),e.jsxs(rt,{value:t.dc_camera_monitoring||"both",onValueChange:a=>s({dc_camera_monitoring:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"on_site_soc",className:"text-xs",children:"On-Site SOC"}),e.jsx(le,{value:"remote_noc",className:"text-xs",children:"Remote NOC"}),e.jsx(le,{value:"both",className:"text-xs",children:"Both"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"IR Illuminator"}),e.jsx(kt,{checked:t.dc_camera_ir_illuminator??!0,onCheckedChange:a=>s({dc_camera_ir_illuminator:a}),disabled:n})]})]})})}function d6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"DC Security Lighting",icon:e.jsx(gh,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Pole Count"}),e.jsx(be,{type:"number",min:1,max:100,className:"h-7 text-xs",value:t.dc_sec_light_pole_count??12,onChange:a=>s({dc_sec_light_pole_count:parseInt(a.target.value)||12}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Pole Height (ft)"}),e.jsx(be,{type:"number",min:15,max:60,className:"h-7 text-xs",value:t.dc_sec_light_pole_height_ft??30,onChange:a=>s({dc_sec_light_pole_height_ft:parseFloat(a.target.value)||30}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Fixture Type"}),e.jsxs(rt,{value:t.dc_sec_light_fixture_type||"led_flood",onValueChange:a=>s({dc_sec_light_fixture_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"led_flood",className:"text-xs",children:"LED Flood"}),e.jsx(le,{value:"metal_halide",className:"text-xs",children:"Metal Halide"}),e.jsx(le,{value:"infrared",className:"text-xs",children:"Infrared"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Lumen Output"}),e.jsx(be,{type:"number",min:5e3,max:2e5,step:5e3,className:"h-7 text-xs",value:t.dc_sec_light_lumens??5e4,onCh
761ange:a=>s({dc_sec_light_lumens:parseFloat(a.target.value)||5e4}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Spacing (ft)"}),e.jsx(be,{type:"number",min:30,max:200,className:"h-7 text-xs",value:t.dc_sec_light_spacing_ft??80,onChange:a=>s({dc_sec_light_spacing_ft:parseFloat(a.target.value)||80}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Color Temperature"}),e.jsxs(rt,{value:t.dc_sec_light_temp||"5000k",onValueChange:a=>s({dc_sec_light_temp:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"3000k",className:"text-xs",children:"3000K (Warm)"}),e.jsx(le,{value:"4000k",className:"text-xs",children:"4000K (Neutral)"}),e.jsx(le,{value:"5000k",className:"text-xs",children:"5000K (Daylight)"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Emergency Backup"}),e.jsx(kt,{checked:t.dc_sec_light_backup??!0,onCheckedChange:a=>s({dc_sec_light_backup:a}),disabled:n})]})]})})}function u6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"DC Visitor Screening",icon:e.jsx(W3,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Screening Type"}),e.jsxs(rt,{value:t.dc_visitor_type||"standalone",onValueChange:a=>s({dc_visitor_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"lobby",className:"text-xs",children:"Lobby"}),e.jsx(le,{value:"standalone",className:"text-xs",children:"Standalone Building"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Visitor Badge System"}),e.jsxs(rt,{value:t.dc_visitor_badge_system||"electronic",onValueChange:a=>s({dc_visitor_badge_system:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"printed",className:"text-xs",children:"Printed"}),e.jsx(le,{value:"electronic",className:"text-xs",children:"Electronic"}),e.jsx(le,{value:"rfid",className:"text-xs",children:"RFID"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Max Occupancy"}),e.jsx(be,{type:"number",min:1,max:200,className:"h-7 text-xs",value:t.dc_visitor_max_occupancy??20,onChange:a=>s({dc_visitor_max_occupancy:parseInt(a.target.value)||20}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Metal Detector"}),e.jsx(kt,{checked:t.dc_visitor_metal_detector??!0,onCheckedChange:a=>s({dc_visitor_metal_detector:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"X-Ray Screening"}),e.jsx(kt,{checked:t.dc_visitor_xray??!0,onCheckedChange:a=>s({dc_visitor_xray:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Mantrap Vestibule"}),e.jsx(kt,{checked:t.dc_visitor_mantrap??!0,onCheckedChange:a=>s({dc_visitor_mantrap:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Escort Required"}),e.jsx(kt,{checked:t.dc_visitor_escort_required??!0,onCheckedChange:a=>s({dc_visitor_escort_required:a}),disabled:n})]})]})})}function h6({overlay:t,onUpdate:s,isUpdating:n}){const a=t;return e.jsxs(ns,{title:"DC Service Drive",icon:e.jsx(uo,{className:"w-4 h-4"}),defaultOpen:!0,children:[e.jsx("p",{className:"text-[10px] text-muted-foreground mb-3",children:"Heavy-duty pavement circuit connecting loading, generators, cooling yards, and substations"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Pavement Type"}),e.jsxs(rt,{value:a.dc_svc_drive_pavement||"reinforced_concrete",onValueChange:l=>s({dc_svc_drive_pavement:l}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}
761),e.jsxs(ot,{children:[e.jsx(le,{value:"reinforced_concrete",className:"text-xs",children:"Reinforced Concrete"}),e.jsx(le,{value:"heavy_duty_asphalt",className:"text-xs",children:"Heavy-Duty Asphalt"}),e.jsx(le,{value:"composite",className:"text-xs",children:"Composite"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Thickness (in)"}),e.jsx(be,{type:"number",min:4,max:18,className:"h-7 text-xs",value:a.dc_svc_drive_thickness_in??8,onChange:l=>s({dc_svc_drive_thickness_in:parseFloat(l.target.value)||8}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",min:16,max:40,className:"h-7 text-xs",value:a.dc_svc_drive_width_ft??24,onChange:l=>s({dc_svc_drive_width_ft:parseFloat(l.target.value)||24}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Designed Vehicle"}),e.jsxs(rt,{value:a.dc_svc_drive_vehicle||"box_truck",onValueChange:l=>s({dc_svc_drive_vehicle:l}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"box_truck",className:"text-xs",children:"Box Truck (SU-30)"}),e.jsx(le,{value:"panel_van",className:"text-xs",children:"Panel Van"}),e.jsx(le,{value:"fire_apparatus",className:"text-xs",children:"Fire Apparatus"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Direction"}),e.jsxs(rt,{value:a.dc_svc_drive_direction||"two_way",onValueChange:l=>s({dc_svc_drive_direction:l}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"one_way",className:"text-xs",children:"One-Way"}),e.jsx(le,{value:"two_way",className:"text-xs",children:"Two-Way"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Speed Limit (mph)"}),e.jsx(be,{type:"number",min:5,max:25,className:"h-7 text-xs",value:a.dc_svc_drive_speed_mph??15,onChange:l=>s({dc_svc_drive_speed_mph:parseInt(l.target.value)||15}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Has Curbing"}),e.jsx(kt,{checked:a.dc_svc_drive_curbing??!0,onCheckedChange:l=>s({dc_svc_drive_curbing:l}),disabled:n})]})]})]})}function m6({overlay:t,onUpdate:s,isUpdating:n}){const a=t;return e.jsxs(ns,{title:"Secure Loading Bay",icon:e.jsx(Lf,{className:"w-4 h-4"}),defaultOpen:!0,children:[e.jsx("p",{className:"text-[10px] text-muted-foreground mb-3",children:"Equipment delivery doors with screening — NOT a 40-dock industrial warehouse"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Door Count"}),e.jsx(be,{type:"number",min:1,max:4,className:"h-7 text-xs",value:a.dc_loading_door_count??2,onChange:l=>s({dc_loading_door_count:parseInt(l.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Door Type"}),e.jsxs(rt,{value:a.dc_loading_door_type||"overhead_roll_up",onValueChange:l=>s({dc_loading_door_type:l}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"overhead_roll_up",className:"text-xs",children:"Overhead Roll-Up"}),e.jsx(le,{value:"sectional",className:"text-xs",children:"Sectional"}),e.jsx(le,{value:"man_door",className:"text-xs",children:"Man Door"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Door Width (ft)"}),e.jsx(be,{type:"number",min:4,max:16,className:"h-7 text-xs",value:a.dc_loading_door_width_ft??10,onChange:l=>s({dc_loading_door_width_ft:parseFloat(l.target.value)||10}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Door Height (ft)"}),e.jsx(be,{type:"number",min:8,max:16,className:"h-7 text-xs",value:a.dc_loading_door_height_ft??12,onChange:l=>s({dc_loading_door_height_ft:parseFloat(l.target.value)||12}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Approach Type"}),e.jsxs(rt,{value:a.dc_loading_approach||"flush_grade",onValueChange:l=>s({dc_loading_approach:l}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"flush_grade",className:"text-xs",children:"Flush Grade"}),e.jsx(le,{value:"raised_dock",className:"text-xs",children:"Raised Dock"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Has Dock Leveler"}),e.jsx(kt,{checked:a.dc_loading_has_leveler??!1,onCheckedChange:l=>s({dc_loading_has_leveler:l}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Has Vestibule / Mantrap"}),e.jsx(kt,{checked:a.dc_loading_has_vestibule??!0,onCheckedChange:l=>s({dc_loading_has_vestibule:l}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"CCTV Coverage"}),e.jsx(kt,{checked:a.dc_loading_has_cctv??!0,onCheckedChange:l=>s({dc_loading_has_cctv:l}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Bollard Protection"}),e.jsx(kt,{checked:a.dc_loading_has_bollards??!0,onCheckedChange:l=>s({dc_loading_has_bollards:l}),disabled:n})]})]})]})}function f6({overlay:t,onUpdate:s,isUpdating:n}){const a=t;return e.jsxs(ns,{title:"Secure Parking Zone",icon:e.jsx(Ml,{className:"w-4 h-4"}),defaultOpen:!0,children:[e.jsx("p",{className:"text-[10px] text-muted-foreground mb-3",children:"Badge-controlled parking areas with tiered access levels"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Zone Type"}),e.jsxs(rt,{value:a.dc_parking_zone_type||"employee",onValueChange:l=>s({dc_parking_zone_type:l}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"employee",className:"text-xs",children:"Employee"}),e.jsx(le,{value:"visitor",className:"text-xs",children:"Visitor"}),e.jsx(le,{value:"contractor",className:"text-xs",children:"Contractor"}),e.jsx(le,{value:"executive",className:"text-xs",children:"Executive"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Access Level"}),e.jsxs(rt,{value:a.dc_parking_access_level||"badge",onValueChange:l=>s({dc_parking_access_level:l}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"badge",className:"text-xs",children:"Badge"}),e.jsx(le,{value:"badge_pin",className:"text-xs",children:"Badge + PIN"}),e.jsx(le,{value:"biometric",className:"text-xs",children:"Biometric"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Space Count"}),e.jsx(be,{type:"number",min:5,max:500,className:"h-7 text-xs",value:a.dc_parking_space_count??50,onChange:l=>s({dc_parking_space_count:parseInt(l.target.value)||50}),disabled:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Surface"}),e.jsxs(rt,{value:a.dc_parking_surface||"asphalt",onValueChange:l=>s({dc_parking_surface:l}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"asphalt",className:"text-xs",children:"Asphalt"}),e.jsx(le,{value:"concrete",className:"text-xs",children:"Concrete"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Lighting Level"}),e.jsxs(rt,{value:a.dc_parking_lighting||"enhanced",onValueChange:l=>s({dc_parking_lighting:l}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"standard",className:"text-xs",children:"Standard"}),e.jsx(le,{value:"enhanced",className:"text-xs",children:"Enhanced"}),e.jsx(le,{value:"security_grade",className:"text-xs",children:"Security-Grade"})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Gate Arm"}),e.jsx(kt,{checked:a.dc_parking_has_gate??!0,onCheckedChange:l=>s({dc_parking_has_gate:l}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"ALPR (License Plate Reader)"}),e.jsx(kt,{checked:a.dc_parking_has_alpr??!1,onCheckedChange:l=>s({dc_parking_has_alpr:l}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"EV Charging"}),e.jsx(kt,{checked:a.dc_parking_has_ev??!0,onCheckedChange:l=>s({dc_parking_has_ev:l}),disabled:n})]})]})]})}function p6({overlay:t,onUpdate:s,isUpdating:n}){const a=t,l=a.dc_emr_route_width_ft??26,c=l>=26;return e.jsxs(ns,{title:"Emergency Access Route",icon:e.jsx(ej,{className:"w-4 h-4"}),defaultOpen:!0,children:[e.jsx("p",{className:"text-[10px] text-muted-foreground mb-3",children:"Fire/emergency vehicle path — typically a perimeter loop. IFC requires minimum 26 ft width."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Route Width (ft)"}),e.jsx(be,{type:"number",min:20,max:40,className:"h-7 text-xs",value:l,onCh
761ange:u=>s({dc_emr_route_width_ft:parseFloat(u.target.value)||26}),disabled:n}),e.jsx("p",{className:`text-[10px] ${c?"text-green-600":"text-destructive"}`,children:c?"✓ Meets IFC minimum (26 ft)":"✗ Below IFC minimum (26 ft)"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Surface Type"}),e.jsxs(rt,{value:a.dc_emr_surface||"asphalt",onValueChange:u=>s({dc_emr_surface:u}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"asphalt",className:"text-xs",children:"Asphalt"}),e.jsx(le,{value:"concrete",className:"text-xs",children:"Concrete"}),e.jsx(le,{value:"stabilized_gravel",className:"text-xs",children:"Stabilized Gravel"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Knox Box Count"}),e.jsx(be,{type:"number",min:0,max:10,className:"h-7 text-xs",value:a.dc_emr_knox_box_count??2,onChange:u=>s({dc_emr_knox_box_count:parseInt(u.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Fire Hydrant Access Points"}),e.jsx(kt,{checked:a.dc_emr_hydrant_access??!0,onCheckedChange:u=>s({dc_emr_hydrant_access:u}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Turnaround / Hammerhead"}),e.jsx(kt,{checked:a.dc_emr_has_turnaround??!0,onCheckedChange:u=>s({dc_emr_has_turnaround:u}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Emergency Lighting"}),e.jsx(kt,{checked:a.dc_emr_has_emergency_light??!0,onCheckedChange:u=>s({dc_emr_has_emergency_light:u}),disabled:n})]})]})]})}const sy={su_30:{name:"SU-30 Box Truck",description:"30' single-unit box truck",radiusFt:28},su_40:{name:"SU-40 Delivery",description:"40' single-unit delivery truck",radiusFt:33},panel_van:{name:"Panel Van",description:"Standard cargo van",radiusFt:22},fire_apparatus:{name:"Fire Apparatus",description:"Ladder truck / pumper",radiu
761sFt:35}};function g6({overlay:t,onUpdate:s,isUpdating:n}){const a=t,l=a.dc_turn_vehicle||"su_30",c=sy[l]||sy.su_30,u=a.dc_turn_radius_ft??c.radiusFt;return e.jsxs(ns,{title:"DC Turning Template",icon:e.jsx(uo,{className:"w-4 h-4"}),defaultOpen:!0,children:[e.jsx("p",{className:"text-[10px] text-muted-foreground mb-3",children:"Pre-configured for DC-scale vehicles (box trucks, not WB-67 semis)"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Vehicle Type"}),e.jsxs(rt,{value:l,onValueChange:i=>{const _=sy[i];s({dc_turn_vehicle:i,dc_turn_radius_ft:(_==null?void 0:_.radiusFt)??28})},children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:Object.entries(sy).map(([i,_])=>e.jsx(le,{value:i,className:"text-xs",children:_.name},i))})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:c.description})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Min Turning Radius (ft)"}),e.jsx(be,{type:"number",min:15,max:45,className:"h-7 text-xs",value:u,onChange:i=>s({dc_turn_radius_ft:parseFloat(i.target.value)||28}),disabled:n}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Default for ",c.name,": ",c.radiusFt," ft"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Show Swept Path Overlay"}),e.jsx(kt,{checked:a.dc_turn_show_swept??!0,onCheckedChange:i=>s({dc_turn_show_swept:i}),disabled:n})]})]})]})}function x6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsxs(ns,{title:"Fire Pump Room",icon:e.jsx(Ff,{className:"w-4 h-4"}),badge:e.jsx(Mt,{variant:"outline",className:"text-[10px] h-5",children:t.dc_fire_pump_type||"electric"}),defaultOpen:!0,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"NFPA 20 fire pump equipment building"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Pump Type"}),e.jsxs(rt,{value:t.dc_fire_pump_type||"electric",onValueChange:a=>s({dc_fire_pump_type:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"electric",children:"Electric"}),e.jsx(le,{value:"diesel",children:"Diesel"}),e.jsx(le,{value:"jockey",children:"Jockey"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Pump Count"}),e.jsx(be,{type:"number",min:1,max:6,value:t.dc_fire_pump_count??2,onChange:a=>s({dc_fire_pump_count:parseInt(a.target.value)||2}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Capacity (GPM)"}),e.jsx(be,{type:"number",min:100,value:t.dc_fire_pump_gpm??1500,onChange:a=>s({dc_fire_pump_gpm:parseFloat(a.target.value)||1500}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Motor HP"}),e.jsx(be,{type:"number",min:10,value:t.dc_fire_pump_hp??100,onChange:a=>s({dc_fire_pump_hp:parseFloat(a.target.value)||100}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Room Length (ft)"}),e.jsx(be,{type:"number",min:10,value:t.dc_fire_pump_room_l_ft??30,onChange:a=>s({dc_fire_pump_room_l_ft:parseFloat(a.target.value)||30}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Room Width (ft)"}),e.jsx(be,{type:"number",min:10,value:t.dc_fire_pump_room_w_ft??20,onChange:a=>s({dc_fire_pump_room_w_ft:parseFloat(a.target.value)||20}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Transfer Switch"}),e.jsx(kt,{checked:t.dc_fire_pump_transfer_sw??!0,onCheckedChange:a=>s({dc_fire_pump_transfer_sw:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Generator Backup"}),e.jsx(kt,{checked:t.dc_fire_pump_gen_backup??!0,onCheckedChange:a=>s({dc_fire_pump_gen_backup:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"NFPA 20 Compliant"}),e.jsx(kt,{checked:t.dc_fire_pump_nfpa20??!0,onCheckedChange:a=>s({dc_fire_pump_nfpa20:a}),disabled:n})]})]})]})}function _6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsxs(ns,{title:"Fire Water Tank",icon:e.jsx(Kc,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:[(t.dc_fire_tank_capacity_gal??1e5).toLocaleStr
761ing()," gal"]}),defaultOpen:!0,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"NFPA 22 dedicated fire water storage"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1 col-span-2",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Tank Type"}),e.jsxs(rt,{value:t.dc_fire_tank_type||"above_ground_steel",onValueChange:a=>s({dc_fire_tank_type:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"above_ground_steel",children:"Above-Ground Steel"}),e.jsx(le,{value:"above_ground_fiberglass",children:"Above-Ground Fiberglass"}),e.jsx(le,{value:"below_ground_concrete",children:"Below-Ground Concrete"}),e.jsx(le,{value:"below_ground_fiberglass",children:"Below-Ground Fiberglass"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Capacity (gal)"}),e.jsx(be,{type:"number",min:1e3,value:t.dc_fire_tank_capacity_gal??1e5,onChange:a=>s({dc_fire_tank_capacity_gal:parseFloat(a.target.value)||1e5}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Diameter (ft)"}),e.jsx(be,{type:"number",min:5,value:t.dc_fire_tank_diameter_ft??20,onChange:a=>s({dc_fire_tank_diameter_ft:parseFloat(a.target.value)||20}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Height (ft)"}),e.jsx(be,{type:"number",min:5,value:t.dc_fire_tank_height_ft??30,onChange:a=>s({dc_fire_tank_height_ft:parseFloat(a.target.value)||30}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Freeze Protection / Heating"}),e.jsx(kt,{checked:t.dc_fire_tank_freeze_protect??!0,onCheckedChange:a=>s({dc_fire_tank_freeze_protect:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Level Monitoring"}),e.jsx(kt,{checked:t.dc_fire_tank_level_monitor??!0,onCheckedChange:a=>s({dc_fire_tank_level_monitor:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Fire Dept Fill Connection"}),e.jsx(kt,{checked:t.dc_fire_tank_fd_fill??!0,onCheckedChange:a=>s({dc_fire_tank_fd_fill:a}),disabled:n})]})]})]})}function y6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsxs(ns,{title:"Sanitary Lift Station",icon:e.jsx(r3,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:[t.dc_sanitary_pump_count??2," pumps"]}),defaultOpen:!0,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Below-grade sanitary sewer pump station"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Pump Count"}),e.jsx(be,{type:"number",min:1,max:6,value:t.dc_sanitary_pump_count??2,onChange:a=>s({dc_sanitary_pump_count:parseInt(a.target.value)||2}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Pump GPM"}),e.jsx(be,{type:"number",min:50,value:t.dc_sanitary_pump_gpm??200,onChange:a=>s({dc_sanitary_pump_gpm:parseFloat(a.target.value)||200}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Wet Well Depth (ft)"}),e.jsx(be,{type:"number",min:4,value:t.dc_sanitary_well_depth_ft??12,onChange:a=>s({dc_sanitary_well_depth_ft:parseFloat(a.target.value)||12}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Wet Well Diameter (ft)"}),e.jsx(be,{type:"number",min:3,value:t.dc_sanitary_well_diameter_ft??6,onChange:a=>s({dc_sanitary_well_diameter_ft:parseFloat(a.target.value)||6}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Force Main (in)"}),e.jsx(be,{type:"number",min:2,max:12,value:t.dc_sanitary_force_main_in??4,onChange:a=>s({dc_sanitary_force_main_in:parseFloat(a.target.value)||4}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Discharge Point"}),e.jsxs(rt,{value:t.dc_sanitary_discharge||"municipal",onValueChange:a=>s({dc_sanitary_discharge:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"municipal",children:"Municipal Sewer"}),e.jsx(le,{value:"on_site_treatment",children:"On-Site Treatment"}),e.jsx(le,{value:"septic",children:"Septic System"})]})]})]})]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Redun
761dant Pump"}),e.jsx(kt,{checked:t.dc_sanitary_redundant??!0,onCheckedChange:a=>s({dc_sanitary_redundant:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Alarm / SCADA"}),e.jsx(kt,{checked:t.dc_sanitary_scada??!0,onCheckedChange:a=>s({dc_sanitary_scada:a}),disabled:n})]})]})]})}function v6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsxs(ns,{title:"Water Storage Tank",icon:e.jsx(Wm,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:[(t.dc_water_tank_capacity_gal??5e4).toLocaleString()," gal"]}),defaultOpen:!0,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Cooling / process water storage (not fire water)"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1 col-span-2",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Tank Type"}),e.jsxs(rt,{value:t.dc_water_tank_type||"above_ground_steel",onValueChange:a=>s({dc_water_tank_type:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"above_ground_steel",children:"Above-Ground Steel"}),e.jsx(le,{value:"above_ground_frp",children:"Above-Ground FRP"}),e.jsx(le,{value:"below_ground_concrete",children:"Below-Ground Concrete"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Capacity (gal)"}),e.jsx(be,{type:"number",min:1e3,value:t.dc_water_tank_capacity_gal??5e4,onChange:a=>s({dc_water_tank_capacity_gal:parseFloat(a.target.value)||5e4}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Purpose"}),e.jsxs(rt,{value:t.dc_water_tank_purpose||"cooling_makeup",onValueChange:a=>s({dc_water_tank_purpose:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"cooling_makeup",children:"Cooling Makeup"}),e.jsx(le,{value:"process",children:"Process Water"}),e.jsx(le,{value:"potable_reserve",children:"Potable Reserve"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Diameter (ft)"}),e.jsx(be,{type:"number",min:5,value:t.dc_water_tank_diameter_ft??15,onChange:a=>s({dc_water_tank_diameter_ft:parseFloat(a.target.value)||15}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Height (ft)"}),e.jsx(be,{type:"number",min:5,value:t.dc_water_tank_height_ft??20,onChange:a=>s({dc_water_tank_height_ft:parseFloat(a.target.value)||20}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Recirculation Pump"}),e.jsx(kt,{checked:t.dc_water_tank_recirc??!0,onCheckedChange:a=>s({dc_water_tank_recirc:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Chemical Treatment"}),e.jsx(kt,{checked:t.dc_water_tank_chemical??!0,onCheckedChange:a=>s({dc_water_tank_chemical:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Secondary Containment"}),e.jsx(kt,{checked:t.dc_water_tank_containment??!1,onCheckedChange:a=>s({dc_water_tank_containment:a}),disabled:n})]})]})]})}function b6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsxs(ns,{title:"Sound Wall",icon:e.jsx(Ag,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:["STC ",t.sound_wall_stc_rating??50]}),defaultOpen:!0,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Engineered noise barrier wall with STC rating"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Wall Type"}),e.jsxs(rt,{value:t.sound_wall_type||"precast_concrete",onValueChange:a=>s({sound_wall_type:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"precast_concrete",children:"Precast Concrete"}),e.jsx(le,{value:"cmu",children:"CMU"}),e.jsx(le,{value:"composite",children:"Composite"}),e.jsx(le,{value:"timber",children:"Timber"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Height (ft)"}),e.jsx(be,{type:"number",min:6,max:25,value:t.sound_wall_height_ft??12,onChange:a=>s({sound_wall_height_ft:parseFloat(a.target.value)||12}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"STC Rating"}),e.jsx(be,{type:"number",min:25,max:70,value:t.sound_wall_stc_rating??50,onChange:a=>s({sound_wall_stc_rating:parseInt(a.target.value)||50}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Foundation"}),e.jsxs(rt,{value:t.sound_wall_foundation||"continuous_footing",onValueChange:a=>s({sound_wall_foundation:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"continuous_footing",children:"Continuous Footing"}),e.jsx(le,{value:"pier",children:"Pier"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Finish"}),e.jsxs(rt,{value:t.sound_wall_finish||"natural",onValueChange:a=>s({sound_wall_finish:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"natural",children:"Natural"}),e.jsx(le,{value:"painted",children:"Painted"}),e.jsx(le,{value:"form_liner",children:"Form-Liner Texture"})]})]})]}),(t.sound_wall_has_pilasters??!0)&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Pilaster Spacing (ft)"}),e.jsx(be,{type:"number",min:8,max:32,value:t.sound_wall_pilaster_spacing_ft??16,onChange:a=>s({sound_wall_pilaster_spacing_ft:parseFloat(a.target.value)||16}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Absorptive Face"}),e.jsx(kt,{checked:t.sound_wall_absorptive??!0,onCheckedChange:a=>s({sound_wall_absorptive:a}),disabled:n})]}),(t.sound_wall_absorptive??!0)&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Absorptive Material"}),e.jsxs(rt,{value:t.sound_wall_absorptive_material||"mineral_wool",onValueChange:a=>s({sound_wall_absorptive_material:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"mineral_wool",children:"Mineral Wool"}),e.jsx(le,{value:"recycled_rubber",children:"Recycled Rubber"}),e.jsx(le,{value:"foam_composite",children:"Foam Composite"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Has Pilasters"}),e.jsx(kt,{checked:t.sound_wall_has_pilasters??!0,onCheckedChange:a=>s({sound_wall_has_pilasters:a}),disabled:n})]})]})]})}function j6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsxs(ns,{title:"Screen Wall",icon:e.jsx(s_,{className:"w-4 h-4"}),badge:e.jsx(Mt,{variant:t.screen_wall_meets_code??!0?"default":"destructive",className:"text-[10px] h-5",children:t.screen_wall_meets_code??!0?"Code OK":"Review"}),defaultOpen:!0,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Code-compliant visual screening wall"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Wall Type"}),e.jsxs(rt,{value:t.screen_wall_type||"cmu",onValueChange:a=>s({screen_wall_type:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"cmu",children:"CMU"}),e.jsx(le,{value:"precast",children:"Precast"}),e.jsx(le,{value:"metal_panel",children:"Metal Panel"}),e.jsx(le,{value:"living_wall",children:"Living Wall"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Height (ft)"}),e.jsx(be,{type:"number",min:4,max:16,value:t.screen_wall_height_ft??8,onChange:a=>s({screen_wall_height_ft:parseFloat(a.target.value)||8}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Purpose"}),e.jsxs(rt,{value:t.screen_wall_purpose||"equipment_screening",onValueChange:a=>s({screen_wall_purpose:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"equipment_screening",children:"Equipment Screening"}),e.jsx(le,{value:"service_area",children:"Service Area"}),e.jsx(le,{value:"utility_yard",children:"Utility Yard"}),e.jsx(le,{value:"dumpster",children:"Dumpster"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Finish"}),e.jsxs(rt,{value:t.screen_wall_finish||"painted",onValueChange:a=>s({screen_wall_finish:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"painted",children:"Painted"}),e.jsx(le,{value:"split_face",children:"Split-Face"}),e.jsx(le,{value:"stucco",children:"Stucco"}),e.jsx(le,{value:"stone_veneer",children:"Stone Veneer"})]})]})]}),(t.screen_wall_has_openings??!1)&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Opening %"}),e.jsx(be,{type:"number",min:0,max:50,value:t.screen_wall_opening_pct??0,onChange:a=>s({screen_wall_opening_pct:parseFloat(a.target.value)||0}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Openings / Ventilation"}),e.jsx(kt,{checked:t.screen_wall_has_openings??!1,onCheckedChange:a=>s({screen_wall_has_openings:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Meets Code Height"}),e.jsx(kt,{checked:t.screen_wall_meets_code??!0,onCheckedChange:a=>s({screen_wall_meets_code:a}),disabled:n})]})]})]})}function w6({overlay:t,onUpdate:s,isUpdating:n}){const a=t.noise_buffer_source_dba??85,l=t.noise_buffer_target_dba??55,c=a-l;return e.jsxs(ns,{title:"Noise Buffer Zone",icon:e.jsx(LS,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:["−",c," dBA"]}),defaultOpen:!0,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Noise propagation overlay for approval drawings"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Source Type"}),e.jsxs(rt,{value:t.noise_buffer_source_type||"generator",onValueChange:u=>s({noise_buffer_source_type:u}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"generator",children:"Generator"}),e.jsx(le,{value:"cooling_tower",children:"Cooling Tower"}),e.jsx(le,{value:"substation",children:"Substation"}),e.jsx(le,{value:"hvac",children:"HVAC"}),e.jsx(le,{value:"general",children:"General"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Buffer Method"}),e.jsxs(rt,{value:t.noise_buffer_method||"fixed_radius",onValueChange:u=>s({noise_buffer_method:u}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"fixed_radius",children:"Fixed Radius"}),e.jsx(le,{value:"calculated",children:"Calculated"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Source Level (dBA)"}),e.jsx(be,{type:"number",min:40,max:130,value:a,onChange:u=>s({noise_buffer_source_dba:parseFloat(u.target.value)||85}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Target at Receiver (dBA)"}
761),e.jsx(be,{type:"number",min:30,max:80,value:l,onChange:u=>s({noise_buffer_target_dba:parseFloat(u.target.value)||55}),className:"h-8 text-xs",disabled:n})]}),(t.noise_buffer_method||"fixed_radius")==="fixed_radius"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Buffer Radius (ft)"}),e.jsx(be,{type:"number",min:25,max:1e3,value:t.noise_buffer_radius_ft??200,onChange:u=>s({noise_buffer_radius_ft:parseFloat(u.target.value)||200}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Fill Opacity"}),e.jsx(be,{type:"number",min:.05,max:.5,step:.05,value:t.noise_buffer_fill_opacity??.15,onChange:u=>s({noise_buffer_fill_opacity:parseFloat(u.target.value)||.15}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Fill Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:t.noise_buffer_fill_color||"#f97316",onChange:u=>s({noise_buffer_fill_color:u.target.value}),className:"w-8 h-8 rounded border cursor-pointer",disabled:n}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.noise_buffer_fill_color||"#f97316"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Show Contour Rings"}),e.jsx(kt,{checked:t.noise_buffer_contour_rings??!0,onCheckedChange:u=>s({noise_buffer_contour_rings:u}),disabled:n})]})]})]})}function s2({overlay:t,onUpdate:s,isUpdating:n}){return e.jsxs(ns,{title:"Roof Penthouse",icon:e.jsx(Ci,{className:"w-4 h-4"}),badge:e.jsx(Mt,{variant:"outline",className:"text-[10px] h-5",children:t.roof_pent_purpose||"mechanical"}),defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Enclosed rooftop structure for elevator, stair, or mechanical equipment"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Purpose"}),e.jsxs(rt,{value:t.roof_pent_purpose||"mechanical",onValueChange:a=>
761s({roof_pent_purpose:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"elevator",children:"Elevator"}),e.jsx(le,{value:"stair_overrun",children:"Stair Overrun"}),e.jsx(le,{value:"mechanical",children:"Mechanical"}),e.jsx(le,{value:"telecom",children:"Telecom"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Wall Material"}),e.jsxs(rt,{value:t.roof_pent_wall_material||"metal_panel",onValueChange:a=>s({roof_pent_wall_material:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"cmu",children:"CMU"}),e.jsx(le,{value:"metal_panel",children:"Metal Panel"}),e.jsx(le,{value:"precast",children:"Precast"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Length (ft)"}),e.jsx(be,{type:"number",min:8,max:60,value:t.roof_pent_length_ft??20,onChange:a=>s({roof_pent_length_ft:parseFloat(a.target.value)||20}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",min:6,max:40,value:t.roof_pent_width_ft??15,onChange:a=>
761s({roof_pent_width_ft:parseFloat(a.target.value)||15}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Height Above Roof (ft)"}),e.jsx(be,{type:"number",min:6,max:30,value:t.roof_pent_height_ft??12,onChange:a=>s({roof_pent_height_ft:parseFloat(a.target.value)||12}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Has Louvers"}),e.jsx(kt,{checked:t.roof_pent_has_louvers??!0,onCheckedChange:a=>s({roof_pent_has_louvers:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Has Access Door"}),e.jsx(kt,{checked:t.roof_pent_has_door??!0,onCheckedChange:a=>s({roof_pent_has_door:a}),disabled:n})]})]})]})}function n2({overlay:t,onUpdate:s,isUpdating:n}){return e.jsxs(ns,{title:"Industrial Exhaust Stack",icon:e.jsx(Ff,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:["×",t.exh_stack_count??1]}),defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Tall vertical stacks for industrial process or generator exhaust"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Stack Count"}),e.jsx(be,{type:"number",min:1,max:12,value:t.exh_stack_count??1,onChange:a=>s({exh_stack_count:parseInt(a.target.value)||1}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Height Above Roof (ft)"}),e.jsx(be,{type:"number",min:5,max:60,value:t.exh_stack_height_ft??15,onChange:a=>s({exh_stack_height_ft:parseFloat(a.target.value)||15}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Diameter (in)"}),e.jsx(be,{type:"number",min:6,max:72,value:t.exh_stack_diameter_in??24,onChange:a=>s({exh_stack_diameter_in:parseFloat(a.target.value)||24}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Material"}),e.jsxs(rt,{value:t.exh_stack_material||"galvanized_steel",onValueChange:a=>s({exh_stack_material:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"galvanized_steel",children:"Galvanized Steel"}),e.jsx(le,{value:"stainless",children:"Stainless Steel"}),e.jsx(le,{value:"painted",children:"Painted"})]})]})]}),e.jsxs("div",{className:"space-y-1 col-span-2",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Purpose"}),e.jsxs(rt,{value:t.exh_stack_purpose||"generator",onValueChange:a=>s({exh_stack_purpose:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"generator",children:"Generator"}),e.jsx(le,{value:"process",children:"Process"}),e.jsx(le,{value:"kitchen",children:"Kitchen"}),e.jsx(le,{value:"boiler",children:"Boiler"})]})]})]})]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Rain Cap"}),e.jsx(kt,{checked:t.exh_stack_rain_cap??!0,onCheckedChange:a=>s({exh_stack_rain_cap:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Spark Arrestor"}),e.jsx(kt,{checked:t.exh_stack_spark_arrestor??!1,onCheckedChange:a=>s({exh_stack_spark_arrestor:a}),disabled:n})]})]})]})}function a2({overlay:t,onUpdate:s,isUpdating:n}){return e.jsxs(ns,{title:"Intake Louver Bank",icon:e.jsx(T1,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:["×",t.intake_bank_count??2]}),defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Fresh air intake louver arrays for HVAC and pressurization"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Bank Count"}),e.jsx(be,{type:"number",min:1,max:12,value:t.intake_bank_count??2,onChange:a=>s({intake_bank_count:parseInt(a.target.value)||2}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Bank Width (ft)"}),e.jsx(be,{type:"number",min:2,max:20,value:t.intake_bank_width_ft??8,onChange:a=>s({intake_bank_width_ft:parseFloat(a.target.value)||8}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Bank Height (ft)"}),e.jsx(be,{type:"number",min:2,max:10,value:t.intake_bank_height_ft??4,onChange:a=>s({intake_bank_height_ft:parseFloat(a.target.value)||4}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Louver Type"}),e.jsxs(rt,{value:t.intake_louver_type||"fixed_blade",onValueChange:a=>s({intake_louver_type:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"fixed_blade",children:"Fixed Blade"}),e.jsx(le,{value:"adjustable",children:"Adjustable"}),e.jsx(le,{value:"storm_resistant",children:"Storm-Resistant"})]})]})]}),e.jsxs("div",{className:"space-y-1 col-span-2",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Mounting"}),e.jsxs(rt,{value:t.intake_mounting||"roof_curb",onValueChange:a=>s({intake_mounting:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"roof_curb",children:"Roof Curb"}),e.jsx(le,{value:"wall_penetration",children:"Wall Penetration"})]})]})]})]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Bird Screen"}),e.jsx(kt,{checked:t.intake_has_bird_screen??!0,onCheckedChange:a=>s({intake_has_bird_screen:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Has Damper"}),e.jsx(kt,{checked:t.intake_has_damper??!0,onCheckedChange:a=>s({intake_has_damper:a}),disabled:n})]})]})]})}function r2({overlay:t,onUpdate:s,isUpdating:n}){return e.jsxs(ns,{title:"Lightning Protection Mast",icon:e.jsx(Xd,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:["×",t.lightning_mast_count??4]}
761),defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Lightning protection rods/masts for flat roof installations"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Mast Count"}),e.jsx(be,{type:"number",min:1,max:20,value:t.lightning_mast_count??4,onChange:a=>s({lightning_mast_count:parseInt(a.target.value)||4}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Height Above Roof (ft)"}),e.jsx(be,{type:"number",min:3,max:30,value:t.lightning_mast_height_ft??10,onChange:a=>s({lightning_mast_height_ft:parseFloat(a.target.value)||10}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Mast Type"}),e.jsxs(rt,{value:t.lightning_mast_type||"air_terminal",onValueChange:a=>s({lightning_mast_type:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"air_terminal",children:"Air Terminal Rod"}),e.jsx(le,{value:"early_streamer",children:"Early Streamer Emission"}),e.jsx(le,{value:"franklin_rod",children:"Franklin Rod"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Material"}),e.jsxs(rt,{value:t.lightning_material||"copper",onValueChange:a=>s({lightning_material:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"copper",children:"Copper"}),e.jsx(le,{value:"aluminum",children:"Aluminum"}),e.jsx(le,{value:"stainless",children:"Stainless Steel"})]})]})]}),e.jsxs("div",{className:"space-y-1 col-span-2",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Grounding Type"}),e.jsxs(rt,{value:t.lightning_ground_type||"ring_ground",onValueChange:a=>s({lightning_ground_type:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"ground_rod",children:"Ground Rod"}),e.jsx(le,{value:"ring_ground",children:"Ring Ground"}),e.jsx(le,{value:"ufer",children:"Ufer (Foundation)"})]})]})]})]}),e.jsx("div",{className:"space-y-3 mt-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Down Conductor"}),e.jsx(kt,{checked:t.lightning_has_conductor??!0,onCheckedChange:a=>s({lightning_has_conductor:a}),disabled:n})]})})]})}function i2({overlay:t,onUpdate:s,isUpdating:n}){return e.jsxs(ns,{title:"DC Capacity Label",icon:e.jsx(n_,{className:"w-4 h-4"}),badge:t.dc_cap_label_value?e.jsxs(Mt,{variant:"default",className:"text-[10px] h-5",children:[t.dc_cap_label_value," ",t.dc_cap_label_unit||"MW"]}):null,defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"MW capacity, IT load, and redundancy annotations for marketing decks"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Label Type"}),e.jsxs(rt,{value:t.dc_cap_label_type||"mw_capacity",onValueChange:a=>s({dc_cap_label_type:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"mw_capacity",children:"MW Capacity"}),e.jsx(le,{value:"it_load",children:"IT Load"}),e.jsx(le,{value:"critical_load",children:"Critical Load"}),e.jsx(le,{value:"cooling_capacity",children:"Cooling Capacity"}),e.jsx(le,{value:"total_power",children:"Total Power"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Value"}),e.jsx(be,{type:"text",placeholder:"e.g. 12",value:t.dc_cap_label_value??"",onChange:a=>s({dc_cap_label_value:a.target.value}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Unit"}),e.jsxs(rt,{value:t.dc_cap_label_unit||"MW",onValueChange:a=>s({dc_cap_label_unit:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"MW",children:"MW"}),e.jsx(le,{value:"kW",children:"kW"}),e.jsx(le,{value:"tons",children:"Tons"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Redun
761dancy Tier"}),e.jsxs(rt,{value:t.dc_cap_label_redundancy||"N+1",onValueChange:a=>s({dc_cap_label_redundancy:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"N",children:"N"}),e.jsx(le,{value:"N+1",children:"N+1"}),e.jsx(le,{value:"2N",children:"2N"}),e.jsx(le,{value:"2N+1",children:"2N+1"}),e.jsx(le,{value:"concurrent_maintainable",children:"Concurrent Maintainable"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Display Style"}),e.jsxs(rt,{value:t.dc_cap_label_style||"badge",onValueChange:a=>s({dc_cap_label_style:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"badge",children:"Badge"}),e.jsx(le,{value:"banner",children:"Banner"}),e.jsx(le,{value:"callout",children:"Callout"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Font Size"}),e.jsxs(rt,{value:t.dc_cap_label_font_size||"md",onValueChange:a=>s({dc_cap_label_font_size:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"sm",children:"Small"}),e.jsx(le,{value:"md",children:"Medium"}),e.jsx(le,{value:"lg",children:"Large"})]})]})]})]})]})}function o2({overlay:t,onUpdate:s,isUpdating:n}){return e.jsxs(ns,{title:"Phase Overlay",icon:e.jsx(Da,{className:"w-4 h-4"}),badge:e.jsx(Mt,{variant:"outline",className:"text-[10px] h-5",children:t.phase_name||`Phase ${t.phase_number??1}`}),defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Construction phasing / staging dashed boun
761dary overlay"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Phase Number"}),e.jsx(be,{type:"number",min:1,max:10,value:t.phase_number??1,onChange:a=>s({phase_number:parseInt(a.target.value)||1}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Phase Name"}),e.jsx(be,{type:"text",value:t.phase_name??"Phase 1",onChange:a=>s({phase_name:a.target.value}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Border Style"}),e.jsxs(rt,{value:t.phase_border_style||"dashed",onValueChange:a=>s({phase_border_style:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"dashed",children:"Dashed"}),e.jsx(le,{value:"dotted",children:"Dotted"}),e.jsx(le,{value:"dash_dot",children:"Dash-Dot"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Border Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(be,{type:"color",value:t.phase_border_color??"#6366f1",onChange:a=>s({phase_border_color:a.target.value}),className:"h-8 w-10 p-0.5",disabled:n}),e.jsx(be,{type:"text",value:t.phase_border_color??"#6366f1",onChange:a=>s({phase_border_color:a.target.value}),className:"h-8 text-xs flex-1",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Fill Opacity"}),e.jsx(be,{type:"number",min:0,max:.5,step:.02,value:t.phase_fill_opacity??.08,onChange:a=>s({phase_fill_opacity:parseFloat(a.target.value)||.08}),className:"h-8 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Status"}),e.jsxs(rt,{value:t.phase_status||"planned",onValueChange:a=>s({phase_status:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"planned",children:"Planned"}),e.jsx(le,{value:"under_construction",children:"Under Construction"}),e.jsx(le,{value:"complete",children:"Complete"})]})]})]}),e.jsxs("div",{className:"space-y-1 col-span-2",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Target Date"}),e.jsx(be,{type:"text",placeholder:"e.g. Q3 2026",value:t.phase_target_date??"",onChange:a=>s({phase_target_date:a.target.value}),className:"h-8 text-xs",disabled:n})]})]})]})}function l2({overlay:t,onUpdate:s,isUpdating:n}){return e.jsxs(ns,{title:"Secure Zone Overlay",icon:e.jsx(hd,{className:"w-4 h-4"}),badge:e.jsx(Mt,{variant:"outline",className:"text-[10px] h-5",children:t.sec_zone_classification||"restricted"}),defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Security classification zone shading for approval drawings"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Classification"}),e.jsxs(rt,{value:t.sec_zone_classification||"restricted",onValueChange:a=>s({sec_zone_classification:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"public",children:"Public"}),e.jsx(le,{value:"restricted",children:"Restricted"}),e.jsx(le,{value:"secure",children:"Secure"}),e.jsx(le,{value:"critical",children:"Critical"}),e.jsx(le,{value:"mantrap",children:"Mantrap"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Access Requirement"}),e.jsxs(rt,{value:t.sec_zone_access||"badge",onValueChange:a=>s({sec_zone_access:a}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"badge",children:"Badge"}),e.jsx(le,{value:"badge_pin",children:"Badge + PIN"}),e.jsx(le,{value:"biometric",children:"Biometric"}),e.jsx(le,{value:"escort",children:"Escort Required"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Fill Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(be,{type:"color",value:t.sec_zone_fill_color??"#ef4444",onChange:a=>s({sec_zone_fill_color:a.target.value}),className:"h-8 w-10 p-0.5",disabled:n}),e.jsx(be,{type:"text",value:t.sec_zone_fill_color??"#ef4444",onChange:a=>s({sec_zone_fill_color:a.target.value}),className:"h-8 text-xs flex-1",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Fill Opacity"}
761),e.jsx(be,{type:"number",min:0,max:.5,step:.02,value:t.sec_zone_fill_opacity??.12,onChange:a=>s({sec_zone_fill_opacity:parseFloat(a.target.value)||.12}),className:"h-8 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Show Label"}),e.jsx(kt,{checked:t.sec_zone_has_label??!0,onCheckedChange:a=>s({sec_zone_has_label:a}),disabled:n})]}),(t.sec_zone_has_label??!0)&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Label Text"}),e.jsx(be,{type:"text",placeholder:"e.g. Critical Infrastructure",value:t.sec_zone_label_text??"",onChange:a=>s({sec_zone_label_text:a.target.value}),className:"h-8 text-xs",disabled:n})]})]})]})}const Vj={PWR:{prefix:"PWR",label:"Power",color:"bg-yellow-500",layerTypes:["dc_substation","dc_generator_yard","dc_fuel_tank_farm","dc_fuel_berm","dc_mv_distribution","dc_tiein_pad","dc_ehouse","dc_bess"]},CLG:{prefix:"CLG",label:"Cooling",color:"bg-cyan-500",layerTypes:["dc_chiller_plant","dc_cooling_tower_yard","dc_dry_cooler_yard","dc_pipe_rack","dc_heat_exchanger","dc_pump_house","dc_water_treatment"]},IT:{prefix:"IT",label:"IT / Building",color:"bg-indigo-500",layerTypes:["dc_raised_floor","dc_containment","dc_ups_room","dc_switchgear_room","dc_crah_crac","dc_fire_suppression","dc_meet_me_room","dc_noc_soc"]},SEC:{prefix:"SEC",label:"Security",color:"bg-red-500",layerTypes:["dc_perimeter_security","dc_guardhouse","dc_sally_port","dc_wedge_barrier","dc_camera_array","dc_security_lighting","dc_visitor_screening","dc_secure_loading","dc_secure_parking"]},NET:{prefix:"NET",label:"Connectivity",color:"bg-purple-500",layerTypes:["dc_fiber_vault","dc_dark_fiber","dc_redundant_feeds"]},CIR:{prefix:"CIR",label:"Circulation",color:"bg-slate-500",layerTypes:["dc_service_drive","dc_emergency_route","dc_turning_template"]},UTL:{prefix:"UTL",label:"Utilities",color:"bg-amber-600",layerTypes:["dc_fire_pump_room","dc_fire_water_tank","dc_sanitary_lift_station","dc_water_storage_tank"]},NSC:{prefix:"NSC",label:"Noise / Screening",color:"bg-stone-600",layerTypes:["sound_wall","screen_wall","noise_buffer_zone","dc_acoustic_enclosure"]},RFV:{prefix:"RFV",label:"Roof / Vertical",color:"bg-gray-500",layerTypes:["roof_penthouse","exhaust_stack","intake_louver_bank","lightning_mast","dc_roof_screen"]},CMP:{prefix:"CMP",label:"Compliance",color:"bg-indigo-400",layerTypes:["dc_capacity_label","phase_overlay","secure_zone"]}};function hT(t){for(const[s,n]of Object.entries(Vj))if(n.layerTypes.includes(t))return s;return null}function N6({overlay:t,onUpdate:s,isUpdating:n}){const a=t.layer_type?hT(t.layer_type):null,l=a?Vj[a]:null,c=Af.find(i=>i.value===t.layer_type);if(!l)return null;const u=[(c==null?void 0:c.label)||t.name,t.layer_sequence?`- ${t.layer_sequence}`:null,t.layer_qualifier||null].filter(Boolean).join(" ");return e.jsxs("div",{className:"space-y-2 pb-3 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n_,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium text-foreground",children:"Layer Identity"}),e.jsx(Mt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:l.prefix}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:l.label})]}),e.jsxs("div",{className:"text-xs text-muted-foreground truncate px-6",children:["Preview: ",e.jsx("span",{className:"font-medium text-foreground",children:u})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 px-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(B,{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[e.jsx(b3,{className:"w-3 h-3"})," Sequence"]}),e.jsx(be,{className:"h-7 text-xs",placeholder:"A",value:t.layer_sequence||"",onChange:i=>s({layer_sequence:i.target.value||null}),disabled:n,maxLength:5})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Qualifier"}),e.jsx(be,{className:"h-7 text-xs",placeholder:"North, Phase 1...",value:t.layer_qualifier||"",onChange:i=>s({layer_qualifier:i.target.value||null}),disabled:n})]})]})]})}function k6({overlay:t,onUpdate:s,isUpdating:n}){const a=t.mf_subtype||"mf_midrise";return e.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 p-2",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Building Form"}),a==="mf_garden"&&e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Entry Style"}),e.jsxs(rt,{value:t.mf_building_form||"breezeway",onValueChange:l=>s({mf_building_form:l}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"breezeway",className:"text-xs",children:"Breezeway"}),e.jsx(le,{value:"stacked_flats",className:"text-xs",children:"Stacked Flats"}),e.jsx(le,{value:"single_loaded",className:"text-xs",children:"Single-Loaded"})]})]})]})}),a==="mf_podium"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Form"}),e.jsxs(rt,{value:t.mf_building_form||"wrap_courtyard",onValueChange:l=>s({mf_building_form:l}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"wrap_courtyard",className:"text-xs",children:"Wrap w/ Courtyard"}),e.jsx(le,{value:"wrap_linear",className:"text-xs",children:"Linear Wrap"}),e.jsx(le,{value:"podium_block",className:"text-xs",children:"Podium Block"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Podium Parking Levels"}),e.jsx(be,{type:"number",min:1,max:3,className:"h-7 text-xs",value:t.mf_podium_parking_levels??1,onChange:l=>s({mf_podium_parking_levels:parseInt(l.target.value)||1}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Ground-Floor Retail"}),e.jsx(kt,{checked:t.mf_ground_retail_enabled??!1,onCheckedChange:l=>s({mf_ground_retail_enabled:l}),disabled:n})]})]}),a==="mf_midrise"&&e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Corridor Type"}),e.jsxs(rt,{value:t.mf_building_form||"double_loaded",onValueChange:l=>s({mf_building_form:l}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"double_loaded",className:"text-xs",children:"Double-Loaded"}),e.jsx(le,{value:"single_loaded",className:"text-xs",children:"Single-Loaded"}),e.jsx(le,{value:"skip_stop",className:"text-xs",children:"Skip-Stop"})]})]})]})}),a==="mf_highrise"&&e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Core Type"}),e.jsxs(rt,{value:t.mf_building_form||"central",onValueChange:l=>s({mf_building_form:l}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"central",className:"text-xs",children:"Central Core"}),e.jsx(le,{value:"offset",className:"text-xs",children:"Offset Core"})]})]})]})}),a==="mf_townhome"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Entry Side"}),e.jsxs(rt,{value:t.mf_townhome_entry_side||"front",onValueChange:l=>s({mf_townhome_entry_side:l}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"front",className:"text-xs",children:"Front"}),e.jsx(le,{value:"side",className:"text-xs",children:"Side"}),e.jsx(le,{value:"rear",className:"text-xs",children:"Rear"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Garage"}),e.jsxs(rt,{value:t.mf_townhome_garage_type||"none",onValueChange:l=>s({mf_townhome_garage_type:l}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"none",className:"text-xs",children:"None"}),e.jsx(le,{value:"tuck_under",className:"text-xs",children:"Tuck-Under"}),e.jsx(le,{value:"detached",className:"text-xs",children:"Detached"})]})]})]})]})]})}const ng=[{key:"studio",label:"Studio",defaultSf:525},{key:"one_bed",label:"1 BR",defaultSf:725},{key:"two_bed",label:"2 BR",defaultSf:1050},{key:"three_bed",label:"3 BR",defaultSf:1350}],c2={mf_garden:1.15,mf_podium:1.23,mf_midrise:1.28,mf_highrise:1.35,mf_townhome:1.1};function C6(t){const s={};for(const n of ng){const a=t==null?void 0:t[n.key];s[n.key]={sf:(a==null?void 0:a.sf)??n.defaultSf,count:(a==null?void 0:a.count)??0}}return s}function S6(t){return!t||t<=0?1.28:parseFloat((1/t).toFixed(2))}function Kv(t){return t<=0?1:parseFloat((1/t).toFixed(4))}function E6({overlay:t,onUpdate:s,isUpdating:n}){const a=k.useRef(!1),l=k.useMemo(()=>C6(t.mf_unit_mix),[t.mf_unit_mix]),c=k.useMemo(()=>S6(t.mf_efficiency_ratio),[t.mf_efficiency_ratio]),u=t.mf_target_units_per_floor??20,i=t.mf_subtype||"mf_midrise",_=k.useMemo(()=>{const P=ng.reduce((te,J)=>{var H;return te+(((H=l[J.key])==null?void 0:H.count)||0)},0),I=ng.reduce((te,J)=>{const H=l[J.key];return te+(H?H.sf*H.count:0)},0),z=Math.round(I*c),F=u>0?Math.ceil(P/u):1,D=F>0?Math.round(z/F):z,X=P>0?Math.round(I/P):0,K=Math.round(Math.sqrt(D));return{totalUnits:P,rsf:I,gsf:z,floors:F,footprintSf:D,avgUnitSf:X,approxSide:K}},[l,c,u]),j=k.useCallback((P,I,z)=>{const F={...l,[P]:{...l[P],[I]:z}},D=ng.reduce((te,J)=>{var H;return te+(((H=F[J.key])==null?void 0:H.count)||0)},0),X=ng.reduce((te,J)=>{const H=F[J.key];return te+(H?H.sf*H.count:0)},0),K=D>0?Math.round(X/D):0;s({mf_unit_mix:F,mf_total_units:D,mf_avg_unit_sf:K})},[l,s]),y=k.useCallback(P=>{const I={mf_subtype:P};if(!a.current){const z=c2[P]??1.28;I.mf_efficiency_ratio=Kv(z)}s(I)},[s]),x=k.useCallback(P=>{a.current=!0,s({mf_efficiency_ratio:Kv(P)})},[s]),v=k.useCallback(()=>{a.current=!1;const P=c2[i]??1.28;s({mf_efficiency_ratio:Kv(P)})},[i,s]),C=P=>
761P.toLocaleString();return e.jsx(ns,{title:"Building Generator",icon:e.jsx(pm,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Building Subtype"}),e.jsxs(rt,{value:i,onValueChange:y,disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"mf_garden",className:"text-xs",children:"Garden-Style (2-3 floors)"}),e.jsx(le,{value:"mf_midrise",className:"text-xs",children:"Mid-Rise (4-6 floors)"}),e.jsx(le,{value:"mf_highrise",className:"text-xs",children:"High-Rise (7+ floors)"}),e.jsx(le,{value:"mf_podium",className:"text-xs",children:"Podium / Wrap (4-7 floors)"}),e.jsx(le,{value:"mf_townhome",className:"text-xs",children:"Townhomes / Stacked Flats"})]})]})]}),e.jsx(k6,{overlay:t,onUpdate:s,isUpdating:n}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs font-medium",children:"Unit Mix"}),e.jsxs("div",{className:"grid grid-cols-[1fr_70px_60px] gap-x-2 gap-y-1 items-center text-[10px] text-muted-foreground",children:[e.jsx("span",{children:"Type"}),e.jsx("span",{children:"Size (SF)"}),e.jsx("span",{children:"Count"})]}),ng.map(P=>{const I=l[P.key];return e.jsxs("div",{className:"grid grid-cols-[1fr_70px_60px] gap-x-2 items-center",children:[e.jsx("span",{className:"text-xs truncate",children:P.label}),e.jsx(be,{type:"number",min:100,className:"h-7 text-xs",value:(I==null?void 0:I.sf)??P.defaultSf,onChange:z=>j(P.key,"sf",parseInt(z.target.value)||P.defaultSf),disabled:n}),e.jsx(be,{type:"number",min:0,className:"h-7 text-xs",value:(I==null?void 0:I.count)??0,onChange:z=>j(P.key,"count",parseInt(z.target.value)||0),disabled:n})]},P.key)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Grossing Factor"}),e.jsx("button",{type:"button",onClick:v,className:"text-[9px] text-primary hover:underline flex items-center gap-0.5",title:"Reset to subtype default",children:e.jsx(mh,{className:"w-2.5 h-2.5"})})]}),e.jsx(be,{type:"number",min:1,max:2,step:.01,className:"h-7 text-xs",value:c,onChange:P=>x(parseFloat(P.target.value)||1.28),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Units / Floor"}),e.jsx(be,{type:"number",min:1,className:"h-7 text-xs",value:u,onChange:P=>s({mf_target_units_per_floor:parseInt(P.target.value)||20}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs font-medium",children:"Building Metrics"}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[e.jsx(Kp,{label:"Total Units",value:C(_.totalUnits)}),e.jsx(Kp,{label:"Rentable SF",value:C(_.rsf)}),e.jsx(Kp,{label:"Gross SF",value:C(_.gsf)}),e.jsx(Kp,{label:"Floors",value:String(_.floors)}),e.jsx(Kp,{label:"Footprint SF",value:C(_.footprintSf)}),e.jsx(Kp,{label:"~Dimensions",value:`${C(_.approxSide)}' sq`})]})]})]})})}function Kp({label:t,value:s}){return e.jsxs("div",{className:"flex flex-col items-start rounded-md border border-border bg-muted/30 px-2 py-1.5",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground leading-none",children:t}),e.jsx("span",{className:"text-xs font-semibold leading-tight mt-0.5",children:s})]})}function P6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Corridor / Breezeway",icon:e.jsx(n5,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Corridor Type"}),e.jsxs(rt,{value:t.mf_corridor_type||"double_loaded",onValueChange:a=>s({mf_corridor_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"double_loaded",className:"text-xs",children:"Double-Loaded"}),e.jsx(le,{value:"single_loaded",className:"text-xs",children:"Single-Loaded"}),e.jsx(le,{value:"breezeway",className:"text-xs",children:"Breezeway (Exterior)"}),e.jsx(le,{value:"point_access",className:"text-xs",children:"Point Access"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",min:4,max:12,className:"h-7 text-xs",value:t.mf_corridor_width_ft??6,onChange:a=>s({mf_corridor_width_ft:parseFloat(a.target.value)||6}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Length (ft)"}),e.jsx(be,{type:"number",min:10,className:"h-7 text-xs",value:t.mf_corridor_length_ft??"",onChange:a=>s({mf_corridor_length_ft:parseFloat(a.target.value)||null}),disabled:n})]})]})]})})}function T6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Elevator / Stair Core",icon:e.jsx(e_,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Elevator Count"}),e.jsx(be,{type:"number",min:0,max:12,className:"h-7 text-xs",value:t.mf_elevator_count??1,onChange:a=>s({mf_elevator_count:parseInt(a.target.value)||1}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Type"}),e.jsxs(rt,{value:t.mf_elevator_type||"traction",onValueChange:a=>s({mf_elevator_type:a}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"hydraulic",className:"text-xs",children:"Hydraulic"}),e.jsx(le,{value:"traction",className:"text-xs",children:"Traction"}),e.jsx(le,{value:"mrl",className:"text-xs",children:"Machine-Room-Less"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Cab Width (ft)"}),e.jsx(be,{type:"number",min:4,max:10,className:"h-7 text-xs",value:t.mf_elevator_cab_width_ft??7,onChange:a=>s({mf_elevator_cab_width_ft:parseFloat(a.target.value)||7}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Cab Depth (ft)"}),e.jsx(be,{type:"number",min:4,max:10,className:"h-7 text-xs",value:t.mf_elevator_cab_depth_ft??6,onChange:a=>s({mf_elevator_cab_depth_ft:parseFloat(a.target.value)||6}),disabled:n})]})]})]})})}function L6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Stairwell",icon:e.jsx(zu,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Count"}),e.jsx(be,{type:"number",min:1,max:8,className:"h-7 text-xs",value:t.mf_stairwell_count??2,onChange:a=>s({mf_stairwell_count:parseInt(a.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",min:4,max:12,className:"h-7 text-xs",value:t.mf_stairwell_width_ft??8,onChange:a=>s({mf_stairwell_width_ft:parseFloat(a.target.value)||8}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Type"}),e.jsxs(rt,{value:t.mf_stairwell_type||"interior",onValueChange:a=>s({mf_stairwell_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"interior",className:"text-xs",children:"Interior"}),e.jsx(le,{value:"exterior",className:"text-xs",children:"Exterior"}),e.jsx(le,{value:"scissor",className:"text-xs",children:"Scissor"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Pressurized"}),e.jsx(kt,{checked:t.mf_stairwell_pressurized??!1,onCheckedChange:a=>s({mf_stairwell_pressurized:a}),disabled:n})]})]})})}const d2=[5,6,8];function M6({overlay:t,onUpdate:s,isUpdating:n}){const a=t.mf_balcony_coverage_pct??65,l=t.mf_balcony_preset_depth??6,c=t.mf_balcony_depth_ft??6,u=k.useCallback(i=>{s({mf_balcony_depth_ft:i,mf_balcony_preset_depth:i})},[s]);return e.jsx(ns,{title:"Balcony / Patio",icon:e.jsx(Il,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Type"}),e.jsxs(rt,{value:t.mf_balcony_type||"cantilevered",onValueChange:i=>s({mf_balcony_type:i}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"cantilevered",className:"text-xs",children:"Standard Rectangle"}),e.jsx(le,{value:"recessed",className:"text-xs",children:"Recessed"}),e.jsx(le,{value:"juliet",className:"text-xs",children:"Juliet"}),e.jsx(le,{value:"corner_wrap",className:"text-xs",children:"Corner Wrap"}),e.jsx(le,{value:"stacked_run",className:"text-xs",children:"Stacked Run"}),e.jsx(le,{value:"ground_patio",className:"text-xs",children:"Ground-Floor Patio"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Coverage"}),e.jsxs("span",{className:"text-xs font-medium text-primary",children:[a,"%"]})]}),e.jsx(Ca,{min:0,max:100,step:5,value:[a],onValueChange:([i])=>s({mf_balcony_coverage_pct:i}),disabled:n}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"% of units with balconies"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Placement"}),e.jsxs(rt,{value:t.mf_balcony_placement||"all",onValueChange:i=>s({mf_balcony_placement:i}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"all",className:"text-xs",children:"All Facades"}),e.jsx(le,{value:"courtyard_only",className:"text-xs",children:"Courtyard Side Only"}),e.jsx(le,{value:"street_only",className:"text-xs",children:"Street-Facing Only"}),e.jsx(le,{value:"premium_only",className:"text-xs",children:"Premium Units Only (2BR+)"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Depth"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[d2.map(i=>e.jsxs("button",{type:"button",onClick:()=>u(i),disabled:n,className:fs("h-7 px-2.5 text-xs rounded-md border transition-colors",l===i&&c===i?"bg-primary text-primary-foreground border-primary":"bg-muted/30 border-border hover:bg-muted/60"),
761children:[i,"'"]},i)),e.jsx(be,{type:"number",min:2,max:12,className:"h-7 text-xs w-16",value:c,onChange:i=>{const _=parseFloat(i.target.value)||6;s({mf_balcony_depth_ft:_,mf_balcony_preset_depth:d2.includes(_)?_:null})},disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",min:4,max:20,className:"h-7 text-xs",value:t.mf_balcony_width_ft??10,onChange:i=>s({mf_balcony_width_ft:parseFloat(i.target.value)||10}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Railing Material"}),e.jsxs(rt,{value:t.mf_balcony_railing||"metal",onValueChange:i=>s({mf_balcony_railing:i}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"glass",className:"text-xs",children:"Glass"}),e.jsx(le,{value:"metal",className:"text-xs",children:"Metal"}),e.jsx(le,{value:"cable",className:"text-xs",children:"Cable"}),e.jsx(le,{value:"solid",className:"text-xs",children:"Solid"})]})]})]})]})})}function I6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Parking Structure",icon:e.jsx(Ml,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Garage Type"}),e.jsxs(rt,{value:t.mf_garage_type||"podium",onValueChange:a=>s({mf_garage_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"podium",className:"text-xs",children:"Podium"}),e.jsx(le,{value:"standalone",className:"text-xs",children:"Standalone"}),e.jsx(le,{value:"underground",className:"text-xs",children:"Underground"}),e.jsx(le,{value:"tuck_under",className:"text-xs",children:"Tuck-Under"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Levels"}),e.jsx(be,{type:"number",min:1,max:10,className:"h-7 text-xs",value:t.mf_garage_levels??1,onChange:a=>s({mf_garage_levels:parseInt(a.target.value)||1}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Spaces/Level"}),e.jsx(be,{type:"number",min:10,className:"h-7 text-xs",value:t.mf_garage_spaces_per_level??"",onChange:a=>s({mf_garage_spaces_per_level:parseInt(a.target.value)||null}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Ramp Type"}),e.jsxs(rt,{value:t.mf_garage_ramp_type||"helix",onValueChange:a=>s({mf_garage_ramp_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"straight",className:"text-xs",children:"Straight"}),e.jsx(le,{value:"helix",className:"text-xs",children:"Helix"}),e.jsx(le,{value:"split_level",className:"text-xs",children:"Split Level"})]})]})]})]})})}function A6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Tuck-Under Garage Bay",icon:e.jsx(yg,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Count"}),e.jsx(be,{type:"number",min:1,className:"h-7 text-xs",value:t.mf_garage_bay_count??"",onChange:a=>s({mf_garage_bay_count:parseInt(a.target.value)||null}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",min:8,max:16,className:"h-7 text-xs",value:t.mf_garage_bay_width_ft??12,onChange:a=>s({mf_garage_bay_width_ft:parseFloat(a.target.value)||12}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Depth (ft)"}),e.jsx(be,{type:"number",min:18,max:30,className:"h-7 text-xs",value:t.mf_garage_bay_depth_ft??22,onChange:a=>s({mf_garage_bay_depth_ft:parseFloat(a.target.value)||22}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Door Type"}),e.jsxs(rt,{value:t.mf_garage_bay_door_type||"sectional",onValueChange:a=>s({mf_garage_bay_door_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"sectional",className:"text-xs",children:"Sectional"}),e.jsx(le,{value:"rolling",className:"text-xs",children:"Rolling"}),e.jsx(le,{value:"carriage",className:"text-xs",children:"Carriage"})]})]})]})]})})}function D6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Ground-Floor Retail",icon:e.jsx(Sc,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Depth (ft)"}),e.jsx(be,{type:"number",min:30,max:100,className:"h-7 text-xs",value:t.mf_retail_depth_ft??60,onChange:a=>s({mf_retail_depth_ft:parseFloat(a.target.value)||60}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Ceiling Height (ft)"}),e.jsx(be,{type:"number",min:10,max:20,className:"h-7 text-xs",value:t.mf_retail_height_ft??14,onChange:a=>s({mf_retail_height_ft:parseFloat(a.target.value)||14}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Tenant Count"}),e.jsx(be,{type:"number",min:1,max:20,className:"h-7 text-xs",value:t.mf_retail_tenant_count??3,onChange:a=>s({mf_retail_tenant_count:parseInt(a.target.value)||3}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Has Storefront"}),e.jsx(kt,{checked:t.mf_retail_has_storefront??!0,onCheckedChange:a=>s({mf_retail_has_storefront:a}),disabled:n})]})]})})}function R6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Trash / Recycling Room",icon:e.jsx(wr,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Compactor"}),e.jsx(kt,{checked:t.mf_dumpster_has_compactor??!1,onCheckedChange:a=>s({mf_dumpster_has_compactor:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Screened Enclosure"}),e.jsx(kt,{checked:t.mf_dumpster_screened??!0,onCheckedChange:a=>s({mf_dumpster_screened:a}),disabled:n})]})]})})}function F6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Mechanical / Electrical Room",icon:e.jsx(sj,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsx("div",{className:"space-y-3",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"Boiler room, electrical closet, and telecom room locations. Configure placement and sizing within the building footprint."})})})}function z6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Clubhouse / Leasing",icon:e.jsx(uh,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Square Footage"}),e.jsx(be,{type:"number",min:500,className:"h-7 text-xs",value:t.mf_clubhouse_sf??"",placeholder:"3000",onChange:a=>s({mf_clubhouse_sf:parseFloat(a.target.value)||null}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Fitness Center"}),e.jsx(kt,{checked:t.mf_clubhouse_has_fitness??!0,onCheckedChange:a=>s({mf_clubhouse_has_fitness:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Business Center"}),e.jsx(kt,{checked:t.mf_clubhouse_has_business_center??!1,onCheckedChange:a=>s({mf_clubhouse_has_business_center:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Community Kitchen"}),e.jsx(kt,{checked:t.mf_clubhouse_has_kitchen??!1,onCheckedChange:a=>s({mf_clubhouse_has_kitchen:a}),disabled:n})]})]})})}function O6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Pool / Spa",icon:e.jsx(gp,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Length (ft)"}),e.jsx(be,{type:"number",min:20,className:"h-7 text-xs",value:t.mf_pool_length_ft??60,onChange:a=>s({mf_pool_length_ft:parseFloat(a.target.value)||60}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",min:10,className:"h-7 text-xs",value:t.mf_pool_width_ft??30,onChange:a=>s({mf_pool_width_ft:parseFloat(a.target.value)||30}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Deck (ft)"}),e.jsx(be,{type:"number",min:4,className:"h-7 text-xs",value:t.mf_pool_deck_width_ft??8,onChange:a=>s({mf_pool_deck_width_ft:parseFloat(a.target.value)||8}),disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Spa / Hot Tub"}),e.jsx(kt,{checked:t.mf_pool_has_spa??!1,onCheckedChange:a=>s({mf_pool_has_spa:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Fenced"}),e.jsx(kt,{checked:t.mf_pool_fenced??!0,onCheckedChange:a=>s({mf_pool_fenced:a}),disabled:n})]})]})})}function B6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Playground / Tot Lot",icon:e.jsx(i3,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Area (SF)"}),e.jsx(be,{type:"number",min:500,className:"h-7 text-xs",value:t.mf_playground_sf??2500,onChange:a=>s({mf_playground_sf:parseFloat(a.target.value)||2500}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Surface Material"}),e.jsxs(rt,{value:t.mf_playground_surface||"rubber",onValueChange:a=>s({mf_playground_surface:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"rubber",className:"text-xs",children:"Rubber"}),e.jsx(le,{value:"mulch",className:"text-xs",children:"Mulch"}),e.jsx(le,{value:"sand",className:"text-xs",children:"Sand"}),e.jsx(le,{value:"synthetic_turf",className:"text-xs",children:"Synthetic Turf"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Fenced"}),e.jsx(kt,{checked:t.mf_playground_fenced??!0,onCheckedChange:a=>s({mf_playground_fenced:a}),disabled:n})]})]})})}function $6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Dog Park",icon:e.jsx(f3,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Area (SF)"}),e.jsx(be,{type:"number",min:1e3,className:"h-7 text-xs",value:t.mf_dog_par
761k_sf??5e3,onChange:a=>s({mf_dog_park_sf:parseFloat(a.target.value)||5e3}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Small Dog Area"}),e.jsx(kt,{checked:t.mf_dog_park_has_small_area??!0,onCheckedChange:a=>s({mf_dog_park_has_small_area:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Fenced"}),e.jsx(kt,{checked:t.mf_dog_park_fenced??!0,onCheckedChange:a=>s({mf_dog_park_fenced:a}),disabled:n})]})]})})}function V6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Courtyard / Plaza",icon:e.jsx(Bx,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Type"}),e.jsxs(rt,{value:t.mf_courtyard_type||"ground_level",onValueChange:a=>s({mf_courtyard_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"ground_level",className:"text-xs",children:"Ground Level"}),e.jsx(le,{value:"podium_deck",className:"text-xs",children:"Podium Deck"}),e.jsx(le,{value:"rooftop",className:"text-xs",children:"Rooftop"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Area (SF)"}),e.jsx(be,{type:"number",min:500,className:"h-7 text-xs",value:t.mf_courtyard_sf??"",placeholder:"5000",onChange:a=>s({mf_courtyard_sf:parseFloat(a.target.value)||null}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"BBQ Grills"}),e.jsx(kt,{checked:t.mf_courtyard_has_bbq??!1,onCheckedChange:a=>s({mf_courtyard_has_bbq:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Fire Pit"}),e.jsx(kt,{checked:t.mf_courtyard_has_fire_pit??!1,onCheckedChange:a=>s({mf_courtyard_has_fire_pit:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Seating Area"}),e.jsx(kt,{checked:t.mf_courtyard_has_seating??!0,onCheckedChange:a=>s({mf_courtyard_has_seating:a}),disabled:n})]})]})})}function q6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Sport Court",icon:e.jsx(Z3,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Court Type"}),e.jsxs(rt,{value:t.mf_sport_court_type||"basketball",onValueChange:a=>s({mf_sport_court_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"basketball",className:"text-xs",children:"Basketball"}),e.jsx(le,{value:"tennis",className:"text-xs",children:"Tennis"}),e.jsx(le,{value:"pickleball",className:"text-xs",children:"Pickleball"}),e.jsx(le,{value:"bocce",className:"text-xs",children:"Bocce"}),e.jsx(le,{value:"outdoor_fitness",className:"text-xs",children:"Outdoor Fitness"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Area (SF)"}),e.jsx(be,{type:"number",min:500,className:"h-7 text-xs",value:t.mf_sport_court_sf??"",placeholder:"5000",onChange:a=>s({mf_sport_court_sf:parseFloat(a.target.value)||null}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Lighted"}),e.jsx(kt,{checked:t.mf_sport_court_lighted??!1,onCheckedChange:a=>s({mf_sport_court_lighted:a}),disabled:n})]})]})})}function G6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Mail / Package Center",icon:e.jsx(Sb,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Mailbox Units"}),e.jsx(be,{type:"number",min:1,className:"h-7 text-xs",value:t.mf_mail_unit_count??"",placeholder:"200",onChange:a=>s({mf_mail_unit_count:parseInt(a.target.value)||null}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Package Lockers"}),e.jsx(kt,{checked:t.mf_mail_has_package_lockers??!0,onCheckedChange:a=>s({mf_mail_has_package_lockers:a}),disabled:n})]}),(t.mf_mail_has_package_lockers??!0)&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Locker Count"}),e.jsx(be,{type:"number",min:5,max:100,className:"h-7 text-xs",value:t.mf_mail_locker_count??20,onChange:a=>s({mf_mail_locker_count:parseInt(a.target.value)||20}),disabled:n})]})]})})}function H6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Bike Storage",icon:e.jsx(G1,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Spaces"}),e.jsx(be,{type:"number",min:4,className:"h-7 text-xs",value:t.mf_bike_spaces??20,onChange:a=>s({mf_bike_spaces:parseInt(a.target.value)||20}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Covered"}),e.jsx(kt,{checked:t.mf_bike_covered??!0,onCheckedChange:a=>s({mf_bike_covered:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Repair Station"}),e.jsx(kt,{checked:t.mf_bike_has_repair??!1,onCheckedChange:a=>s({mf_bike_has_repair:a}),disabled:n})]})]})})}function Z6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Dumpster Enclosure",icon:e.jsx(wr,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Dumpster Count"}),e.jsx(be,{type:"number",min:1,max:8,className:"h-7 text-xs",value:t.mf_dumpster_count??2,onChange:a=>s({mf_dumpster_count:parseInt(a.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Compactor"}),e.jsx(kt,{checked:t.mf_dumpster_has_compactor??!1,onCheckedChange:a=>s({mf_dumpster_has_compactor:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Screened"}),e.jsx(kt,{checked:t.mf_dumpster_screened??!0,onCheckedChange:a=>s({mf_dumpster_screened:a}),disabled:n})]})]})})}function W6({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"EV Charging Station",icon:e.jsx(Xd,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Stall Count"}),e.jsx(be,{type:"number",min:1,max:50,className:"h-7 text-xs",value:t.mf_bike_spaces??4,onChange:a=>s({mf_bike_spaces:parseInt(a.target.value)||4}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"ADA Accessible"}),e.jsx(kt,{checked:t.mf_bike_covered??!1,onCheckedChange:a=>s({mf_bike_covered:a}),disabled:n})]})]})})}
761const Jv=[{id:"standard",label:'Standard (6")',description:"Vertical barrier curb",defaultHeight:6},{id:"rolled",label:"Rolled",description:"Sloped transition curb",defaultHeight:4},{id:"mountable",label:"Mountable",description:"Low-profile driveable curb",defaultHeight:3},{id:"none",label:"No Curb",description:"Industrial flush edge",defaultHeight:0}],lx=["F","R","S1","S2"],Y6={F:"Front",R:"Rear",S1:"Side 1",S2:"Side 2"},X6={type:"standard",height_in:6,gutter_width_in:18,ada_ramps:!0};function u2({overlay:t,onUpdate:s,isUpdating:n}){const a=t.style||{},l=a.parkingCurbs||{},c=k.useMemo(()=>!t.geometry||t.geometry.length<3?[]:mu(t.geometry),[t.geometry]),u=k.useMemo(()=>{const y={},x={};return c.forEach(v=>{x[v.label]||(x[v.label]=[]),x[v.label].push(v)}),lx.forEach(v=>{y[v]=(x[v]||[]).reduce((C,P)=>C+(P.lengthFt||0),0)}),y},[c]),i=y=>l[y]||{...X6},_=(y,x)=>{const C={...i(y),...x};if(x.type){const P=Jv.find(I=>I.id===x.type);P&&(C.height_in=P.defaultHeight)}s({style:{...a,parkingCurbs:{...l,[y]:C}}})},j=lx.filter(y=>l[y]).length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:[j," of 4 edges configured"]}),e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:[lx.filter(y=>i(y).ada_ramps).length," ADA ramps"]})]}),lx.map(y=>{const x=i(y),v=u[y]||0,C=Jv.find(I=>I.id===x.type),P=x.type==="none";return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",P?"bg-muted/20 border-dashed":"bg-primary/5 border-primary/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2",children:[e.jsx("div",{className:fs("w-6 h-6 rounded flex items-center justify-center text-xs font-bold",P?"bg-muted text-muted-foreground":"bg-primary text-primary-foreground"),children:y}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:Y6[y]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[Math.round(v).toLocaleString()," ft"]})]}),e.jsx(Mt,{variant:"outline",className:"text-[10px]",children:(C==null?void 0:C.label)||"Standard"}),x.ada_ramps&&!P&&e.jsx(fh,{className:"w-3.5 h-3.5 text-blue-500"})]}),e.jsxs("div",{className:"p-3 pt-0 space-y-2 border-t",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Curb Type"}),e.jsxs(rt,{value:x.type,onValueChange:I=>_(y,{type:I}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:Jv.map(I=>e.jsx(le,{value:I.id,className:"text-xs",children:e.jsxs("div",{children:[e.jsx("span",{children:I.label}),e.jsxs("span",{className:"text-muted-foreground ml-1",children:["— ",I.description]})]})},I.id))})]})]}),!P&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Gutter (in)"}),e.jsx(be,{type:"number",value:x.gutter_width_in,onChange:I=>_(y,{gutter_width_in:parseInt(I.target.value)||18}),min:0,max:36,className:"h-7 text-xs",disabled:n})]})]}),!P&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(fh,{className:"w-3 h-3 text-blue-500"}),e.jsx(B,{className:"text-[10px]",children:"ADA Ramps at Crossings"})]}),e.jsx(kt,{checked:x.ada_ramps,onCheckedChange:I=>_(y,{ada_ramps:I}),disabled:n})]})]})]},y)}),e.jsx("div",{className:"p-2 bg-muted/50 rounded text-xs space-y-1",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Curb Length:"}),e.jsxs("span",{className:"font-mono",children:[Math.round(lx.reduce((y,x)=>y+(i(x).type!=="none"&&u[x]||0),0)).toLocaleString()," ","ft"]})]})})]})}const ny=[{id:"main_entry",label:"Main Entry Walk",icon:"🚶"},{id:"parking_to_building",label:"Parking to Building",icon:"🅿️"},{id:"parking_to_dock",label:"Parking to Trucker Door",icon:"🚛"},{id:"crosswalk",label:"Crosswalk Connection",icon:"🚸"},{id:"custom",label:"Custom Path",icon:"📍"}],h2=[{id:"concrete",label:"Concrete",color:"#d1d5db"},{id:"pavers",label:"Pavers",color:"#b45309"},{id:"asphalt",label:"Asphalt",color:"#374151"},{id:"permeable_pavers",label:"Permeable Pavers",color:"#065f46"},{id:"stamped_concrete",label:"Stamped Concrete",color:"#a78bfa"}],K6=[{id:"standard",label:'Standard (6")'},{id:"rolled",label:"Rolled"}
761,{id:"mountable",label:"Mountable"},{id:"none",label:"None"}],J6={name:"New Sidewalk Path",path_type:"parking_to_building",width_ft:5,material:"concrete",curb_type:"standard",ada_compliant:!0,has_lighting:!1,has_tactile_warning:!0,color:"#d1d5db"};function m2({overlay:t,onUpdate:s,isUpdating:n}){const[a,l]=k.useState(null),c=t.style||{},u=c.pedestrianPaths||[],i=v=>{s({style:{...c,pedestrianPaths:v}})},_=(v="parking_to_building")=>{const C=ny.find(I=>I.id===v),P={...J6,id:crypto.randomUUID(),name:(C==null?void 0:C.label)||"New Path",path_type:v};i([...u,P]),l(P.id)},j=(v,C)=>{i(u.map(P=>P.id===v?{...P,...C}:P))},y=v=>{i(u.filter(C=>C.id!==v)),a===v&&l(null)},x=u.filter(v=>v.ada_compliant).length;return e.jsxs("div",{className:"space-y-3",children:[u.length>0&&e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:[u.length," path",u.length!==1?"s":""," defined"]}),x>0&&e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:[e.jsx(fh,{className:"w-3 h-3 mr-1"}),x," ADA"]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:ny.map(v=>e.jsxs(Le,{variant:"outline",size:"sm",className:"h-8 text-[10px] justify-start",onClick:()=>_(v.id),disabled:n,children:[e.jsx("span",{className:"mr-1",children:v.icon}),v.label]},v.id))}),u.map(v=>{const C=a===v.id,P=ny.find(z=>z.id===v.path_type),I=h2.find(z=>z.id===v.material);return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",C?"border-primary bg-primary/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>l(C?null:v.id),children:[e.jsx(zu,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:v.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[P==null?void 0:P.icon," ",v.width_ft,"′ ",I==null?void 0:I.label]})]}),v.ada_compliant&&e.jsx(fh,{className:"w-3.5 h-3.5 text-blue-500"}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:z=>{z.stopPropagation(),y(v.id)},children:e.jsx(wr,{className:"w-3.5 h-3.5 text-destructive"})}),C?e.jsx(Cc,{className:"w-4 h-4"}):e.jsx(Oa,{className:"w-4 h-4"})]}),C&&e.jsxs("div",{className:"p-3 pt-0 space-y-3 border-t",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Name"}),e.jsx(be,{value:v.name,onChange:z=>j(v.id,{name:z.target.value}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",value:v.width_ft,onChange:z=>j(v.id,{width_ft:parseFloat(z.target.value)||5}),min:4,max:12,className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Material"}),e.jsxs(rt,{value:v.material,onValueChange:z=>j(v.id,{material:z}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:h2.map(z=>e.jsx(le,{value:z.id,className:"text-xs",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm border",style:{backgroundColor:z.color}}),z.label]})},z.id))})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Path Type"}),e.jsxs(rt,{value:v.path_type,onValueChange:z=>j(v.id,{path_type:z}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:ny.map(z=>e.jsxs(le,{value:z.id,className:"text-xs",children:[z.icon," ",z.label]},z.id))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Curb Type"}),e.jsxs(rt,{value:v.curb_type,onValueChange:z=>j(v.id,{curb_type:z}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:K6.map(z=>e.jsx(le,{value:z.id,className:"text-xs",children:z.label},z.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-[10px] flex items-center gap-1",children:[e.jsx(fh,{className:"w-3 h-3 text-blue-500"}),"ADA Compliant"]}),e.jsx(kt,{checked:v.ada_compliant,onCheckedChange:z=>j(v.id,{ada_compliant:z}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-[10px]",children:"Tactile Warning Strips"}),e.jsx(kt,{checked:v.has_tactile_warning,onCheckedChange:z=>j(v.id,{has_tactile_warning:z}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-[10px]",children:"Path Lighting"}),e.jsx(kt,{checked:v.has_lighting,onCheckedChange:z=>j(v.id,{has_lighting:z}),disabled:n})]})]})]})]},v.id)}),u.length===0&&e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(zu,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No pedestrian paths defined"}),e.jsx("p",{className:"text-[10px] mt-1",children:"Add sidewalk connections between parking and buildings"})]})]})}const ay=[{id:"corner",label:"Corner Island",icon:"🔲",description:"At parking lot corners"},{id:"entrance",label:"Entrance Island",icon:"🚗",description:"At driveway entrances"},{id:"median",label:"Median Island",icon:"🛣️",description:"Drive aisle median strip"},{id:"perimeter",label:"Perimeter Island",icon:"🌿",description:"Along lot perimeter"},{id:"custom",label:"Custom Placement",icon:"📍",description:"Free placement"}],f2=[{id:"grass",label:"Grass",color:"#4ade80"},{id:"mulch",label:"Mulch",color:"#92400e"},{id:"rock",label:"Decorative Rock",color:"#a8a29e"},{id:"groundcover",label:"Ground Cover",color:"#22c55e"},{id:"planter",label:"Raised Planter",color:"#78716c"}],Q6=[{id:"deciduous",label:"Deciduous",icon:"🌳"},{id:"evergreen",label:"Evergreen",icon:"🌲"},{id:"palm",label:"Palm",icon:"🌴"},{id:"ornamental",label:"Ornamental",icon:"🌸"}],U6={name:"Landscape Island",placement:"corner",surface:"grass",has_trees:!0,tree_species:"deciduous",tree_count:1,tree_height_ft:25,canopy_diameter_ft:15,has_shrubs:!0,shrub_density:"medium",has_irrigation:!0,has_curb:!0,curb_type:"standard",area_sf:200};function p2({overlay:t,onUpdate:s,isUpdating:n}){const[a,l]=k.useState(null),c=t.style||{},u=c.landscapeIslands||[],i=C=>{s({style:{...c,landscapeIslands:C}})},_=(C="corner")=>{const P=ay.find(z=>z.id===C),I={...U6,id:crypto.randomUUID(),name:(P==null?void 0:P.label)||"Landscape Island",placement:C};i([...u,I]),l(I.id)},j=(C,P)=>{i(u.map(I=>I.id===C?{...I,...P}:I))},y=C=>{i(u.filter(P=>P.id!==C)),a===C&&l(null)},x=u.reduce((C,P)=>C+P.area_sf,0),v=u.reduce((C,P)=>C+(P.has_trees?P.tree_count:0),0);return e.jsxs("div",{className:"space-y-3",children:[u.length>0&&e.jsxs("div",{className:"p-2 bg-muted/50 rounded text-xs space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Islands:"}),e.jsx("span",{children:u.length})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Area:"}
761),e.jsxs("span",{className:"font-mono",children:[x.toLocaleString()," sf"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Trees:"}),e.jsx("span",{children:v})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:ay.slice(0,4).map(C=>e.jsxs(Le,{variant:"outline",size:"sm",className:"h-8 text-[10px] justify-start",onClick:()=>_(C.id),disabled:n,children:[e.jsx("span",{className:"mr-1",children:C.icon}),C.label]},C.id))}),u.map(C=>{const P=a===C.id,I=ay.find(F=>F.id===C.placement),z=f2.find(F=>F.id===C.surface);return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",P?"border-primary bg-primary/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>l(P?null:C.id),children:[e.jsx(Ih,{className:"w-4 h-4 text-primary"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:C.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[I==null?void 0:I.icon," ",C.area_sf," sf • ",z==null?void 0:z.label]})]}),C.has_trees&&e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:[C.tree_count," tree",C.tree_count!==1?"s":""]}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:F=>{F.stopPropagation(),y(C.id)},children:e.jsx(wr,{className:"w-3.5 h-3.5 text-destructive"})}),P?e.jsx(Cc,{className:"w-4 h-4"}):e.jsx(Oa,{className:"w-4 h-4"})]}),P&&e.jsxs("div",{className:"p-3 pt-0 space-y-3 border-t",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Name"}),e.jsx(be,{value:C.name,onChange:F=>j(C.id,{name:F.target.value}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Area (sf)"}),e.jsx(be,{type:"number",value:C.area_sf,onChange:F=>j(C.id,{area_sf:parseInt(F.target.value)||200}),min:50,className:"h-7 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Placement"}),e.jsxs(rt,{value:C.placement,onValueChange:F=>j(C.id,{placement:F}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:ay.map(F=>e.jsxs(le,{value:F.id,className:"text-xs",children:[F.icon," ",F.label]},F.id))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Surface"}),e.jsxs(rt,{value:C.surface,onValueChange:F=>j(C.id,{surface:F}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:f2.map(F=>e.jsx(le,{value:F.id,className:"text-xs",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm border",style:{backgroundColor:F.color}}),F.label]})},F.id))})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-[10px]",children:"Curb Border"}),e.jsx(kt,{checked:C.has_curb,onCheckedChange:F=>j(C.id,{has_curb:F}),disabled:n})]}),C.has_curb&&e.jsxs(rt,{value:C.curb_type,onValueChange:F=>j(C.id,{curb_type:F}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"standard",className:"text-xs",children:'Standard (6")'}),e.jsx(le,{value:"rolled",className:"text-xs",children:"Rolled"}),e.jsx(le,{value:"decorative",className:"text-xs",children:"Decorative"})]})]}),e.jsxs("div",{className:"space-y-2 p-2 rounded-md border border-primary/20 bg-primary/5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ih,{className:"w-3 h-3 text-primary"}),e.jsx(B,{className:"text-[10px] font-medium",children:"Trees"})]}),e.jsx(kt,{checked:C.has_trees,onCheckedChange:F=>j(C.id,{has_trees:F}),disabled:n})]}),C.has_trees&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Species"}),e.jsxs(rt,{value:C.tree_species,onValueChange:F=>j(C.id,{tree_species:F}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:Q6.map(F=>e.jsxs(le,{value:F.id,className:"text-xs",children:[F.icon," ",F.label]},F.id))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Count"}),e.jsx(be,{type:"number",value:C.tree_count,onChange:F=>j(C.id,{tree_count:parseInt(F.target.value)||1}),min:1,max:10,className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Height (ft)"}),e.jsx(be,{type:"number",value:C.tree_height_ft,onChange:F=>j(C.id,{tree_height_ft:parseInt(F.target.value)||25}),min:5,max:80,className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Canopy (ft)"}),e.jsx(be,{type:"number",value:C.canopy_diameter_ft,onChange:F=>j(C.id,{canopy_diameter_ft:parseInt(F.target.value)||15}),min:3,max:40,className:"h-7 text-xs",disabled:n})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ob,{className:"w-3 h-3 text-primary"}),e.jsx(B,{className:"text-[10px]",children:"Shrubs / Groundcover"})]}),e.jsx(kt,{checked:C.has_shrubs,onCheckedChange:F=>j(C.id,{has_shrubs:F}),disabled:n})]}),C.has_shrubs&&e.jsxs(rt,{value:C.shrub_density,onValueChange:F=>j(C.id,{shrub_density:F}),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"sparse",className:"text-xs",children:"Sparse"}),e.jsx(le,{value:"medium",className:"text-xs",children:"Medium"}),e.jsx(le,{value:"dense",className:"text-xs",children:"Dense"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Kc,{className:"w-3 h-3 text-blue-500"}),e.jsx(B,{className:"text-[10px]",children:"Irrigation"})]}
761),e.jsx(kt,{checked:C.has_irrigation,onCheckedChange:F=>j(C.id,{has_irrigation:F}),disabled:n})]})]})]},C.id)}),u.length===0&&e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(Ih,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No standalone islands defined"}),e.jsx("p",{className:"text-[10px] mt-1",children:"Add landscape islands at corners, entrances, and medians"})]})]})}function eB({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Drop Lot",icon:e.jsx(Wm,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Dedicated area where drivers unhook trailers for yard jockeys to manage."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Trailer Capacity"}),e.jsx(be,{type:"number",min:1,max:200,className:"h-7 text-xs",value:t.drop_lot_capacity??20,onChange:a=>s({drop_lot_capacity:parseInt(a.target.value)||20}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Spot Length (ft)"}),e.jsx(be,{type:"number",min:40,max:65,className:"h-7 text-xs",value:t.drop_lot_spot_length_ft??53,onChange:a=>s({drop_lot_spot_length_ft:parseFloat(a.target.value)||53}),disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Striped Stalls"}),e.jsx(kt,{checked:t.drop_lot_striped??!0,onCheckedChange:a=>s({drop_lot_striped:a}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Surface Material"}),e.jsxs(rt,{value:t.material_preset||"concrete",onValueChange:a=>s({material_preset:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"concrete",className:"text-xs",children:"Concrete"}),e.jsx(le,{value:"metal_panel",className:"text-xs",children:"Asphalt"})]})]})]})]})})}function tB({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Yard Jockey / Staging",icon:e.jsx(hu,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Yard tractor parking and trailer staging lanes for internal yard operations."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Tractor Parking"}),e.jsx(be,{type:"number",min:1,max:20,className:"h-7 text-xs",value:t.yard_jockey_parking_count??4,onChange:a=>s({yard_jockey_parking_count:parseInt(a.target.value)||4}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Staging Lanes"}),e.jsx(be,{type:"number",min:1,max:6,className:"h-7 text-xs",value:t.yard_jockey_staging_lane_count??2,onChange:a=>s({yard_jockey_staging_lane_count:parseInt(a.target.value)||2}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Surface Type"}),e.jsxs(rt,{value:t.material_preset||"concrete",onValueChange:a=>s({material_preset:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"concrete",className:"text-xs",children:"Concrete"}),e.jsx(le,{value:"metal_panel",className:"text-xs",children:"Asphalt"})]})]})]})]})})}const ry={"WB-67":{name:"WB-67 (53' Trailer)",description:"Standard 53' semi-trailer",radiusFt:45},"WB-62":{name:"WB-62 (48' Trailer)",description:"48' semi-trailer",radiusFt:42},"SU-30":{name:"SU-30 (Single Unit)",description:"30' single-unit truck",radiusFt:28},"SU-40":{name:"SU-40 (Single Unit)",description:"40' single-unit truck",radiusFt:33}};function sB({overlay:t,onUpdate:s,isUpdating:n}){const a=t.turning_template_vehicle||"WB-67",l=ry[a]||ry["WB-67"],c=t.turning_template_radius_ft??l.radiusFt;return e.jsx(ns,{title:"Turning Template",icon:e.jsx(uo,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Vehicle Type"}),e.jsxs(rt,{value:a,onValueChange:u=>{const i=ry[u];s({turning_template_vehicle:u,turning_template_radius_ft:(i==null?void 0:i.radiusFt)??45})},children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:Object.entries(ry).map(([u,i])=>e.jsx(le,{value:u,className:"text-xs",children:i.name},u))})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:l.description})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Min Turning Radius (ft)"}),e.jsx(be,{type:"number",min:15,max:60,className:"h-7 text-xs",value:c,onChange:u=>s({turning_template_radius_ft:parseFloat(u.target.value)||45}),disabled:n}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["AASHTO default for ",a,": ",l.radiusFt," ft"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Show Swept Path Overlay"}),e.jsx(kt,{checked:t.turning_template_show_swept??!0,onCheckedChange:u=>s({turning_template_show_swept:u}),disabled:n})]})]})})}const g2=[{value:"catch_basin",label:"Catch Basin",description:"Standard stormwater collection"},{value:"curb_inlet",label:"Curb Inlet",description:"Street-level curb opening"},{value:"area_drain",label:"Area Drain",description:"Flat surface drain"},{value:"trench_drain",label:"Trench Drain",description:"Linear channel drain"},{value:"manhole",label:"Manhole",description:"Access point to storm sewer"}],nB=[{value:"concrete",label:"Concrete"},{value:"hdpe",label:"HDPE"},{value:"cast_iron",label:"Cast Iron"}],aB=[{value:"flat",label:"Flat Grate"},{value:"domed",label:"Domed Grate"},{value:"ada",label:"ADA-Compliant"}];function rB({overlay:t,onUpdate:s,isUpdating:n}
761){const a=t.stormwater_inlet_type||"catch_basin",l=g2.find(c=>c.value===a);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsx(t_,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium",children:"Stormwater Inlet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Catch basins, curb inlets, manholes"})]})]}),e.jsx(ns,{title:"Inlet Type",icon:e.jsx(Da,{className:"w-4 h-4"}),badge:e.jsx(Mt,{variant:"outline",className:"text-[10px] h-5",children:l==null?void 0:l.label}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs(rt,{value:a,onValueChange:c=>s({stormwater_inlet_type:c}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:g2.map(c=>e.jsx(le,{value:c.value,className:"text-xs",children:e.jsxs("div",{children:[e.jsx("span",{children:c.label}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:["— ",c.description]})]})},c.value))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Size (in)"}),e.jsxs(rt,{value:String(t.stormwater_inlet_size_in||24),onValueChange:c=>s({stormwater_inlet_size_in:parseFloat(c)}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:[12,18,24,36,48].map(c=>e.jsxs(le,{value:String(c),className:"text-xs",children:[c,'"']},c))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Material"}),e.jsxs(rt,{value:t.stormwater_inlet_material||"concrete",onValueChange:c=>s({stormwater_inlet_material:c}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:nB.map(c=>e.jsx(le,{value:c.value,className:"text-xs",children:c.label},c.value))})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Grate Type"}),e.jsxs(rt,{value:t.stormwater_inlet_grate_type||"flat",onValueChange:c=>s({stormwater_inlet_grate_type:c}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:aB.map(c=>e.jsx(le,{value:c.value,className:"text-xs",children:c.label},c.value))})]})]})]})}),e.jsx(ks,{}),e.jsxs(ns,{title:"Elevations",icon:e.jsx(Fo,{className:"w-4 h-4"}),defaultOpen:!1,children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Rim Elevation (ft)"}),e.jsx(be,{type:"number",step:.1,value:t.stormwater_inlet_rim_elev??"",onChange:c=>s({stormwater_inlet_rim_elev:c.target.value?parseFloat(c.target.value):null}),className:"h-7 text-xs",placeholder:"e.g. 100.5",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Invert Elevation (ft)"}),e.jsx(be,{type:"number",step:.1,value:t.stormwater_inlet_invert_elev??"",onChange:c=>s({stormwater_inlet_invert_elev:c.target.value?parseFloat(c.target.value):null}),className:"h-7 text-xs",placeholder:"e.g. 95.2",disabled:n})]})]}),t.stormwater_inlet_rim_elev!=null&&t.stormwater_inlet_invert_elev!=null&&e.jsxs("div",{className:"mt-2 p-2 bg-muted/50 rounded text-xs flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Depth:"}),e.jsxs("span",{className:"font-mono",children:[(t.stormwater_inlet_rim_elev-t.stormwater_inlet_invert_elev).toFixed(1)," ft"]})]})]})]})}const x2=[{value:"headwall",label:"Headwall",description:"Concrete end structure"},{value:"flared_end",label:"Flared End Section",description:"Flared pipe terminus"},{value:"riprap_apron",label:"Riprap Apron",description:"Energy dissipation pad"},{value:"pipe_daylight",label:"Pipe Daylight",description:"Open pipe discharge"}],iB=[{value:"concrete",label:"Concrete"},{value:"rcp",label:"RCP (Reinforced Concrete Pipe)"},{value:"hdpe",label:"HDPE"},{value:"cmp",label:"CMP (Corrugated Metal)"}],oB=[{value:"class_a",label:'Class A (2-6")'},{value:"class_b",label:'Class B (6-12")'},{value:"class_c",label:'Class C (12-18")'},{value:"class_d",label:'Class D (18-24")'}];function lB({overlay:t,onUpdate:s,isUpdating:n}){const a=t.outfall_type||"headwall",l=x2.find(c=>c.value===a);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsx(gp,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium",children:"Outfall / Headwall"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Stormwater discharge point"})]})]}),e.jsx(ns,{title:"Outfall Type",icon:e.jsx(Da,{className:"w-4 h-4"}),badge:e.jsx(Mt,{variant:"outline",className:"text-[10px] h-5",children:l==null?void 0:l.label}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs(rt,{value:a,onValueChange:c=>s({outfall_type:c}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:x2.map(c=>e.jsx(le,{value:c.value,className:"text-xs",children:e.jsxs("div",{children:[e.jsx("span",{children:c.label}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:["— ",c.description]})]})},c.value))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Pipe Diameter (in)"}
761),e.jsxs(rt,{value:String(t.outfall_pipe_diameter_in||18),onValueChange:c=>s({outfall_pipe_diameter_in:parseFloat(c)}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:[12,15,18,24,30,36,42,48,60,72].map(c=>e.jsxs(le,{value:String(c),className:"text-xs",children:[c,'"']},c))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Pipe Material"}),e.jsxs(rt,{value:t.outfall_material||"rcp",onValueChange:c=>s({outfall_material:c}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:iB.map(c=>e.jsx(le,{value:c.value,className:"text-xs",children:c.label},c.value))})]})]})]})]})}),e.jsx(ks,{}),e.jsx(ns,{title:"Riprap / Dissipation",icon:e.jsx(Fo,{className:"w-4 h-4"}),defaultOpen:a==="riprap_apron"||a==="headwall",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Riprap Class"}),e.jsxs(rt,{value:t.outfall_riprap_class||"class_b",onValueChange:c=>s({outfall_riprap_class:c}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:oB.map(c=>e.jsx(le,{value:c.value,className:"text-xs",children:c.label},c.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Riprap Extent"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[t.outfall_riprap_extent_ft||10," ft"]})]}),e.jsx(Ca,{value:[t.outfall_riprap_extent_ft||10],min:5,max:50,step:1,onValueChange:([c])=>s({outfall_riprap_extent_ft:c}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx(B,{className:"text-xs",children:"Concrete Apron"}),e.jsx(kt,{checked:t.outfall_has_apron??!1,onCheckedChange:c=>s({outfall_has_apron:c}),disabled:n})]})]})})]})}const cB=[{value:"residential",label:"Residential",description:"Low-pressure service"},{value:"commercial",label:"Commercial",description:"Mid-pressure service"},{value:"industrial",label:"Industrial",description:"High-pressure regulator"}];function dB({overlay:t,onUpdate:s,isUpdating:n}){const a=t.gas_meter_count||1,l=t.gas_meter_regulator_type||"commercial";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsx(Gw,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium",children:"Gas Meter Bank"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Utility gas metering station"})]})]}),e.jsx(ns,{title:"Meter Configuration",icon:e.jsx(Gw,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:[a," meter",a!==1?"s":""]}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Meter Count"}),e.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:a})]}),e.jsx(Ca,{value:[a],min:1,max:12,step:1,onValueChange:([c])=>s({gas_meter_count:c}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Regulator Type"}),e.jsxs(rt,{value:l,onValueChange:c=>s({gas_meter_regulator_type:c}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:cB.map(c=>e.jsx(le,{value:c.value,className:"text-xs",children:e.jsxs("div",{children:[e.jsx("span",{children:c.label}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:["— ",c.description]})]})},c.value))})]})]})]})}),e.jsx(ks,{}),e.jsx(ns,{title:"Protection & Pad",icon:e.jsx(hd,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Bollard Protection"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Steel bollards around meters"})]}),e.jsx(kt,{checked:t.gas_meter_has_bollards??!1,onCheckedChange:c=>s({gas_meter_has_bollards:c}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Concrete Pad"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Equipment mounting surface"})]}),e.jsx(kt,{checked:t.gas_meter_has_pad??!0,onCheckedChange:c=>s({gas_meter_has_pad:c}),disabled:n})]}),(t.gas_meter_has_pad??!0)&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Pad Width (ft)"}),e.jsx(be,{type:"number",step:.5,value:t.gas_meter_pad_width_ft??8,onChange:c=>s({gas_meter_pad_width_ft:parseFloat(c.target.value)||8}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Pad Depth (ft)"}),e.jsx(be,{type:"number",step:.5,value:t.gas_meter_pad_depth_ft??4,onChange:c=>s({gas_meter_pad_depth_ft:parseFloat(c.target.value)||4}),className:"h-7 text-xs",disabled:n})]})]})]})})]})}const _2=[{value:"vestibule",label:"Vestibule",description:"Enclosed glass entry box"},{value:"canopy",label:"Canopy Entry",description:"Open canopy over entrance"},{value:"recessed",label:"Recessed Entry",description:"Set-back entry alcove"},{value:"portico",label:"Portico",description:"Columned covered entry"}],uB=[{value:"none",label:"None"},{value:"flat",label:"Flat Canopy"},{value:"pitched",label:"Pitched / Gable"},{value:"curved",label:"Curved / Barrel"}];function hB({overlay:t,onUpdate:s,isUpdating:n}){const a=t.office_entrance_type||"vestibule",l=_2.find(c=>c.value===a);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsx(Lf,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium",children:"Office Entrance"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Entry vestibule or canopy massing"})]})]}),e.jsx(ns,{title:"Entry Type",icon:e.jsx(Da,{className:"w-4 h-4"}),badge:e.jsx(Mt,{variant:"outline",className:"text-[10px] h-5",children:l==null?void 0:l.label}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs(rt,{value:a,onValueChange:c=>s({office_entrance_type:c}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:_2.map(c=>e.jsx(le,{value:c.value,className:"text-xs",children:e.jsxs("div",{children:[e.jsx("span",{children:c.label}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:["— ",c.description]})]})},c.value))})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",step:1,value:t.office_entrance_width_ft??12,onChange:c=>s({office_entrance_width_ft:parseFloat(c.target.value)||12}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Depth (ft)"}),e.jsx(be,{type:"number",step:1,value:t.office_entrance_depth_ft??8,onChange:c=>s({office_entrance_depth_ft:parseFloat(c.target.value)||8}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Height (ft)"}),e.jsx(be,{type:"number",step:1,value:t.office_entrance_height_ft??14,onChange:c=>s({office_entrance_height_ft:parseFloat(c.target.value)||14}),className:"h-7 text-xs",disabled:n})]})]})]})}),e.jsx(ks,{}),e.jsx(ns,{title:"Glazing & Awning",icon:e.jsx(jS,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Glass Coverage"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[Math.round(t.office_entrance_glass_pct??80),"%"]})]}),e.jsx(Ca,{value:[t.office_entrance_glass_pct??80],min:0,max:100,step:5,onValueChange:([c])=>s({office_entrance_glass_pct:c}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Awning Type"}),e.jsxs(rt,{value:t.office_entrance_awning_type||"flat",onValueChange:c=>s({office_entrance_awning_type:c}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:uB.map(c=>e.jsx(le,{value:c.value,className:"text-xs",children:c.label},c.value))})]})]})]})})]})}function mB({overlay:t,onUpdate:s,isUpdating:n}){const a=t.office_glazing_band_enabled??!1;return e.jsx(ns,{title:"Office Glazing Band",icon:e.jsx(x3,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Enable Ribbon Window"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Horizontal glazing strip on office facade"})]}),e.jsx(kt,{checked:a,onCheckedChange:l=>s({office_glazing_band_enabled:l}),disabled:n})]}),a&&e.jsxs("div",{className:"space-y-3 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Band Height"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[t.office_glazing_band_height_ft??4," ft"]})]}),e.jsx(Ca,{value:[t.office_glazing_band_height_ft??4],min:2,max:8,step:.5,onValueChange:([l])=>s({office_glazing_band_height_ft:l}),disabled:n})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Sill Height"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[t.office_glazing_band_sill_height_ft??3," ft"]})]}),e.jsx(Ca,{value:[t.office_glazing_band_sill_height_ft??3],min:1,max:10,step:.5,onValueChange:([l])=>s({office_glazing_band_sill_height_ft:l}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Mullion Spacing (ft)"}),e.jsx(be,{type:"number",step:.5,value:t.office_glazing_band_mullion_spacing_ft??4,onChange:l=>s({office_glazing_band_mullion_spacing_ft:parseFloat(l.target.value)||4}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Glass Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:t.office_glazing_band_color||"#4A90D9",onChange:l=>s({office_glazing_band_color:l.target.value}),className:"w-8 h-7 rounded border cursor-pointer",disabled:n}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:t.office_glazing_band_color||"#4A90D9"})]})]})]})]})})}const fB=[{value:"concrete",label:"Concrete"},{value:"steel",label:"Steel Plate"},{value:"aluminum",label:"Aluminum"}];function pB({overlay:t,onUpdate:s,isUpdating:n}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsx(n3,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium",children:"Dock Ramp"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Grade-level loading ramp (non dock-high)"})]})]}),e.jsx(ns,{title:"Ramp Dimensions",icon:e.jsx(Fo,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",step:1,value:t.dock_ramp_width_ft??12,onChange:a=>s({dock_ramp_width_ft:parseFloat(a.target.value)||12}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Length (ft)"}),e.jsx(be,{type:"number",step:1,value:t.dock_ramp_length_ft??30,onChange:a=>s({dock_ramp_length_ft:parseFloat(a.target.value)||30}),className:"h-7 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Slope"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[t.dock_ramp_slope_pct??8,"%"]})]}),e.jsx(Ca,{value:[t.dock_ramp_slope_pct??8],min:3,max:15,step:.5,onValueChange:([a])=>s({dock_ramp_slope_pct:a}),disabled:n}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Rise: ",((t.dock_ramp_slope_pct??8)/100*(t.dock_ramp_length_ft??30)).toFixed(1)," ft over ",t.dock_ramp_length_ft??30," ft"]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Material"}),e.jsxs(rt,{value:t.dock_ramp_material||"concrete",onValueChange:a=>s({dock_ramp_material:a}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:fB.map(a=>e.jsx(le,{value:a.value,className:"text-xs",children:a.label},a.value))})]})]})]})}),e.jsx(ks,{}),e.jsx(ns,{title:"Safety Features",icon:e.jsx(hd,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Handrails"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"ADA-compliant grab rails"})]}),e.jsx(kt,{checked:t.dock_ramp_has_handrails??!0,onCheckedChange:a=>s({dock_ramp_has_handrails:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Bumper Rails"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Vehicle wheel guides"})]}),e.jsx(kt,{checked:t.dock_ramp_has_bumper_rails??!1,onCheckedChange:a=>s({dock_ramp_has_bumper_rails:a}),disabled:n})]})]})})]})}const y2=[{value:"open",label:"Open Bay",description:"No enclosure, slab only"},{value:"canopy",label:"Canopy",description:"Roof cover, open sides"},{value:"partial",label:"Partial Enclosure",description:"3-wall with roof"},{value:"fully_enclosed",label:"Fully Enclosed",description:"Complete building"}],gB=[{value:"sanitary",label:"To Sanitary Sewer"},{value:"storm",label:"To Storm Sewer"},{value:"reclaim",label:"Reclaim System"},{value:"holding_tank",label:"Holding Tank"}];function xB({overlay:t,onUpdate:s,isUpdating:n}){const a=t.truck_wash_bay_count||1,l=t.truck_wash_enclosure_type||"canopy";return y2.find(c=>c.value===l),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsx(z3,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium",children:"Truck Wash Bay"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Vehicle cleaning facility"})]})]}),e.jsx(ns,{title:"Bay Configuration",icon:e.jsx(Da,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:[a," bay",a!==1?"s":""]}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{classNam
761e:"text-xs",children:"Bay Count"}),e.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:a})]}),e.jsx(Ca,{value:[a],min:1,max:4,step:1,onValueChange:([c])=>s({truck_wash_bay_count:c}),disabled:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Bay Width (ft)"}),e.jsx(be,{type:"number",step:1,value:t.truck_wash_width_ft??16,onChange:c=>s({truck_wash_width_ft:parseFloat(c.target.value)||16}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Bay Depth (ft)"}),e.jsx(be,{type:"number",step:1,value:t.truck_wash_depth_ft??80,onChange:c=>s({truck_wash_depth_ft:parseFloat(c.target.value)||80}),className:"h-7 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Enclosure Type"}),e.jsxs(rt,{value:l,onValueChange:c=>s({truck_wash_enclosure_type:c}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:y2.map(c=>e.jsx(le,{value:c.value,className:"text-xs",children:e.jsxs("div",{children:[e.jsx("span",{children:c.label}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:["— ",c.description]})]})},c.value))})]})]})]})}),e.jsx(ks,{}),e.jsx(ns,{title:"Water & Drainage",icon:e.jsx(Kc,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Water Reclaim System"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Capture, filter, and reuse wash water"})]}),e.jsx(kt,{checked:t.truck_wash_has_reclaim??!1,onCheckedChange:c=>s({truck_wash_has_reclaim:c}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Drainage Routing"}),e.jsxs(rt,{value:t.truck_wash_drainage_type||"sanitary",onValueChange:c=>s({truck_wash_drainage_type:c}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:gB.map(c=>e.jsx(le,{value:c.value,className:"text-xs",children:c.label},c.value))})]})]}),e.jsxs("div",{className:"p-2 bg-muted/50 rounded text-xs space-y-1 border",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total footprint:"}),e.jsxs("span",{className:"font-mono",children:[((t.truck_wash_width_ft??16)*a).toLocaleString()," × ",t.truck_wash_depth_ft??80," ft"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total area:"}),e.jsxs("span",{className:"font-mono",children:[((t.truck_wash_width_ft??16)*a*(t.truck_wash_depth_ft??80)).toLocaleString()," sf"]})]})]})]})})]})}const v2=[{value:"cooler",label:"Cooler (34–40°F)",description:"Refrigerated storage"},{value:"freezer",label:"Freezer (0°F)",description:"Standard frozen storage"},{value:"deep_freeze",label:"Deep Freeze (-20°F)",description:"Ultra-low temperature"},{value:"blast_freeze",label:"Blast Freezer (-40°F)",description:"Rapid freeze-down"}],_B=[{value:"urethane",label:"Urethane (PUR)"},{value:"polyiso",label:"Polyisocyanurate (PIR)"},{value:"eps",label:"EPS (Expanded Polystyrene)"},{value:"xps",label:"XPS (Extruded Polystyrene)"}],yB=[{value:"rooftop",label:"Rooftop"},{value:"ground_level",label:"Ground Level (Yard)"},{value:"penthouse",label:"Mechanical Penthouse"}],vB=[{value:"ammonia",label:"Ammonia (R-717)"},{value:"r404a",label:"R-404A"},{value:"r448a",label:"R-448A (low GWP)"},{value:"co2",label:"CO₂ (R-744)"},{value:"cascade",label:"CO₂/Ammonia Cascade"}];function bB({overlay:t,onUpdate:s,isUpdating:n}){var u;const a=t.cold_storage_temp_zone||"freezer",l=v2.find(i=>i.value===a),c=t.cold_storage_condensing_unit_count||2;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsx(SS,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium",children:"Cold Storage"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Freezer walls, condensing units, refrigeration yard"})]})]}),e.jsx(ns,{title:"Insulated Envelope",icon:e.jsx(G3,{className:"w-4 h-4"}),badge:e.jsx(Mt,{variant:"outline",className:"text-[10px] h-5",children:(u=l==null?void 0:l.label)==null?void 0:u.split(" ")[0]}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Temperature Zone"}),e.jsxs(rt,{value:a,onValueChange:i=>s({cold_storage_temp_zone:i}),disabled:n,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:v2.map(i=>e.jsx(le,{value:i.value,className:"text-xs",children:e.jsxs("div",{children:[e.jsx("span",{children:i.label}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:["— ",i.description]})]})},i.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Wall Panel Thickness"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[t.cold_storage_wall_thickness_in??
7616,'"']})]}),e.jsx(Ca,{value:[t.cold_storage_wall_thickness_in??6],min:4,max:12,step:.5,onValueChange:([i])=>s({cold_storage_wall_thickness_in:i}),disabled:n}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["R-value ≈ ",((t.cold_storage_wall_thickness_in??6)*6.5).toFixed(0)," (urethane)"]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Panel Type"}),e.jsxs(rt,{value:t.cold_storage_panel_type||"urethane",onValueChange:i=>s({cold_storage_panel_type:i}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:_B.map(i=>e.jsx(le,{value:i.value,className:"text-xs",children:i.label},i.value))})]})]})]})}),e.jsx(ks,{}),e.jsx(ns,{title:"Condensing Units",icon:e.jsx(Y1,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:[c," unit",c!==1?"s":""]}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Unit Count"}),e.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:c})]}),e.jsx(Ca,{value:[c],min:1,max:12,step:1,onValueChange:([i])=>s({cold_storage_condensing_unit_count:i}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Placement"}),e.jsxs(rt,{value:t.cold_storage_condensing_placement||"ground_level",onValueChange:i=>s({cold_storage_condensing_placement:i}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:yB.map(i=>e.jsx(le,{value:i.value,className:"text-xs",children:i.label},i.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Refrigerant"}),e.jsxs(rt,{value:t.cold_storage_refrigerant_type||"ammonia",onValueChange:i=>s({cold_storage_refrigerant_type:i}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:vB.map(i=>e.jsx(le,{value:i.value,className:"text-xs",children:i.label},i.value))})]})]})]})}),e.jsx(ks,{}),e.jsx(ns,{title:"Refrigeration Yard",icon:e.jsx(s_,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Ground-level equipment pad for condensers, compressors, and evaporators."}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Security Fencing"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Chain link + barbed wire"})]}),e.jsx(kt,{checked:t.cold_storage_refrig_yard_fenced??!0,onCheckedChange:i=>s({cold_storage_refrig_yard_fenced:i}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Noise Barrier"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Sound attenuation wall"})]}),e.jsx(kt,{checked:t.cold_storage_refrig_yard_noise_barrier??!1,onCheckedChange:i=>s({cold_storage_refrig_yard_noise_barrier:i}),disabled:n})]})]})})]})}function jB({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Bike Rack",icon:e.jsx(G1,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Rack Count"}),e.jsx(be,{type:"number",min:1,max:100,className:"h-7 text-xs",value:t.bike_rack_count??10,onChange:a=>s({bike_rack_count:parseInt(a.target.value)||10}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Rack Style"}),e.jsxs(rt,{value:t.bike_rack_style||"inverted_u",onValueChange:a=>s({bike_rack_style:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"inverted_u",className:"text-xs",children:"Inverted-U"}),e.jsx(le,{value:"wave",className:"text-xs",children:"Wave"}),e.jsx(le,{value:"grid",className:"text-xs",children:"Grid"}),e.jsx(le,{value:"post_and_ring",className:"text-xs",children:"Post & Ring"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Covered"}),e.jsx(kt,{checked:t.bike_rack_covered??!1,onCheckedChange:a=>s({bike_rack_covered:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"ADA Accessible"}),e.jsx(kt,{checked:t.bike_rack_ada_accessible??!1,onCheckedChange:a=>s({bike_rack_ada_accessible:a}),disabled:n})]})]})})}function wB({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Bench",icon:e.jsx(dS,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Count"}),e.jsx(be,{type:"number",min:1,max:50,className:"h-7 text-xs",value:t.bench_count??4,onChange:a=>s({bench_count:parseInt(a.target.value)||4}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Material"}),e.jsxs(rt,{value:t.bench_material||"metal",onValueChange:a=>s({bench_material:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"metal",className:"text-xs",children:"Metal"}),e.jsx(le,{value:"wood",className:"text-xs",children:"Wood"}),e.jsx(le,{value:"concrete",className:"text-xs",children:"Concrete"}),e.jsx(le,{value:"recycled_plastic",className:"text-xs",children:"Recycled Plastic"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Backrest"}),e.jsx(kt,{checked:t.bench_has_backrest??!0,onCheckedChange:a=>s({bench_has_backrest:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"ADA Accessible"}),e.jsx(kt,{checked:t.bench_ada_accessible??!1,onCheckedChange:a=>s({bench_ada_accessible:a}),disabled:n})]})]})})}function NB({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Berm",icon:e.jsx(Rh,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Height (ft)"}),e.jsx(be,{type:"number",min:1,max:20,step:.5,className:"h-7 text-xs",value:t.berm_height_ft??4,onChange:a=>s({berm_height_ft:parseFloat(a.target.value)||4}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Top Width (ft)"}),e.jsx(be,{type:"number",min:1,max:20,step:.5,className:"h-7 text-xs",value:t.berm_top_width_ft??3,onChange:a=>s({berm_top_width_ft:parseFloat(a.target.value)||3}),disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Slope Ratio"}),e.jsxs(rt,{value:t.berm_slope_ratio||"3:1",onValueChange:a=>s({berm_slope_ratio:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"2:1",className:"text-xs",children:"2:1 (Steep)"}),e.jsx(le,{value:"3:1",className:"text-xs",children:"3:1 (Standard)"}),e.jsx(le,{value:"4:1",className:"text-xs",children:"4:1 (Gentle)"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Vegetated"}),e.jsx(kt,{checked:t.berm_vegetated??!0,onCheckedChange:a=>s({berm_vegetated:a}),disabled:n})]}),(t.berm_vegetated??!0)&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Vegetation Type"}),e.jsxs(rt,{value:t.berm_vegetation_type||"turf_grass",onValueChange:a=>s({berm_vegetation_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"turf_grass",className:"text-xs",children:"Turf Grass"}),e.jsx(le,{value:"native_grasses",className:"text-xs",children:"Native Grasses"}),e.jsx(le,{value:"ground_cover",className:"text-xs",children:"Ground Cover"}),e.jsx(le,{value:"shrubs",className:"text-xs",children:"Shrubs"})]})]})]})]})})}function kB({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Demising Wall",icon:e.jsx(W1,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Wall Type"}),e.jsxs(rt,{value:t.demising_wall_type||"cmu",onValueChange:a=>s({demising_wall_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"cmu",className:"text-xs",children:"CMU (Concrete Block)"}),e.jsx(le,{value:"drywall",className:"text-xs",children:"Drywall"}),e.jsx(le,{value:"demountable",className:"text-xs",children:"Demountable"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Wall Height"}),e.jsxs(rt,{value:t.demising_wall_height||"full",onValueChange:a=>s({demising_wall_height:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"full",className:"text-xs",children:"Full Height (Deck-to-Deck)"}),e.jsx(le,{value:"partial",className:"text-xs",children:"Partial Height"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Fire Rating"}),e.jsxs(rt,{value:t.demising_wall_fire_rating||"none",onValueChange:a=>s({demising_wall_fire_rating:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"none",className:"text-xs",children:"None"}),e.jsx(le,{value:"1hr",className:"text-xs",children:"1-Hour"}),e.jsx(le,{value:"2hr",className:"text-xs",children:"2-Hour"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"STC Rating"}),e.jsx(be,{type:"number",min:0,max:80,className:"h-7 text-xs",value:t.demising_wall_stc??45,onChange:a=>s({demising_wall_stc:parseInt(a.target.value)||45}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Pre-Planned Location"}),e.jsx(kt,{checked:t.demising_wall_preplan??!1,onCheckedChange:a=>s({demising_wall_preplan:a}),disabled:n})]})]})})}function CB({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Tenant Signage Zone",icon:e.jsx(ug,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Signage Type"}),e.jsxs(rt,{value:t.signage_type||"channel_letter",onValueChange:a=>s({signage_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"channel_letter",className:"text-xs",children:"Channel Letter"}),e.jsx(le,{value:"cabinet",className:"text-xs",children:"Cabinet Sign"}),e.jsx(le,{value:"banner",className:"text-xs",children:"Banner"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Max Sign Area (SF)"}),e.jsx(be,{type:"number",min:0,max:500,className:"h-7 text-xs",value:t.signage_max_area_sf??100,onChange:a=>s({signage_max_area_sf:parseFloat(a.target.value)||100}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Illumination"}),e.jsxs(rt,{value:t.signage_illumination||"internal",onValueChange:a=>s({signage_illumination:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"internal",className:"text-xs",children:"Internal"}),e.jsx(le,{value:"external",className:"text-xs",children:"Exter
761nal"}),e.jsx(le,{value:"none",className:"text-xs",children:"None"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Height Above Grade (ft)"}),e.jsx(be,{type:"number",min:0,max:60,className:"h-7 text-xs",value:t.signage_height_ft??20,onChange:a=>s({signage_height_ft:parseFloat(a.target.value)||20}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Mounting Surface"}),e.jsxs(rt,{value:t.signage_mount_surface||"fascia",onValueChange:a=>s({signage_mount_surface:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"fascia",className:"text-xs",children:"Fascia"}),e.jsx(le,{value:"parapet",className:"text-xs",children:"Parapet"}),e.jsx(le,{value:"canopy",className:"text-xs",children:"Canopy"})]})]})]})]})})}function SB({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Tenant Entry",icon:e.jsx(Lf,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Entry Style"}),e.jsxs(rt,{value:t.entry_style||"single",onValueChange:a=>s({entry_style:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"single",className:"text-xs",children:"Single Door"}),e.jsx(le,{value:"double",className:"text-xs",children:"Double Door"}),e.jsx(le,{value:"storefront",className:"text-xs",children:"Storefront"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Vestibule Depth (ft)"}),e.jsx(be,{type:"number",min:0,max:20,step:.5,className:"h-7 text-xs",value:t.entry_vestibule_depth_ft??6,onChange:a=>s({entry_vestibule_depth_ft:parseFloat(a.target.value)||6}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"ADA Compliant"}),e.jsx(kt,{checked:t.entry_ada_compliant??!0,onCheckedChange:a=>s({entry_ada_compliant:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Canopy / Awning"}),e.jsx(kt,{checked:t.entry_has_canopy??!1,onCheckedChange:a=>s({entry_has_canopy:a}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Access Control"}),e.jsxs(rt,{value:t.entry_access_control||"none",onValueChange:a=>s({entry_access_control:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"none",className:"text-xs",children:"None"}),e.jsx(le,{value:"keypad",className:"text-xs",children:"Keypad"}),e.jsx(le,{value:"intercom",className:"text-xs",children:"Intercom"}),e.jsx(le,{value:"card_reader",className:"text-xs",children:"Card Reader"})]})]})]})]})})}function EB({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Unit Label",icon:e.jsx(n_,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Label Text"}),e.jsx(be,{type:"text",className:"h-7 text-xs",placeholder:"Suite A",value:t.unit_label_text??"",onChange:a=>s({unit_label_text:a.target.value}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Display Format"}),e.jsxs(rt,{value:t.unit_label_format||"letter",onValueChange:a=>s({unit_label_format:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"letter",className:"text-xs",children:"Letter (A, B, C)"}),e.jsx(le,{value:"number",className:"text-xs",children:"Number (100, 200)"}),e.jsx(le,{value:"sf_block",className:"text-xs",children:"SF Block (±50,000 SF)"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Unit Square Footage"}),e.jsx(be,{type:"number",min:0,max:1e6,className:"h-7 text-xs",value:t.unit_label_sf??"",onChange:a=>s({unit_label_sf:parseFloat(a.target.value)||null}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Font Size (px)"}),e.jsx(be,{type:"number",min:8,max:72,className:"h-7 text-xs",value:t.unit_label_font_size??24,onChange:a=>s({unit_label_font_size:parseInt(a.target.value)||24}),disabled:n})]})]})})}function PB({overlay:t,onUpdate:s,isUpdating:n}){const a=t.dock_count_total??0,l=t.dock_count_standard??0,c=t.dock_count_drivein??0;return e.jsx(ns,{title:"Dock Count Label",icon:e.jsx(Wm,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Total Dock Doors"}),e.jsx(be,{type:"number",min:0,max:200,className:"h-7 text-xs",value:a,onChange:u=>s({dock_count_total:parseInt(u.target.value)||0}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Standard Docks"}),e.jsx(be,{type:"number",min:0,max:200,className:"h-7 text-xs",value:l,onCh
761ange:u=>s({dock_count_standard:parseInt(u.target.value)||0}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Drive-In Doors"}),e.jsx(be,{type:"number",min:0,max:50,className:"h-7 text-xs",value:c,onChange:u=>s({dock_count_drivein:parseInt(u.target.value)||0}),disabled:n})]}),a!==l+c&&a>0&&e.jsx("p",{className:"text-[10px] text-amber-500",children:"Standard + Drive-In doesn't sum to total"})]})})}function TB({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Car Parking Label",icon:e.jsx(Ml,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Total Stalls"}),e.jsx(be,{type:"number",min:0,max:5e3,className:"h-7 text-xs",value:t.car_parking_count??0,onChange:a=>s({car_parking_count:parseInt(a.target.value)||0}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Ratio (per 1,000 SF)"}),e.jsx(be,{type:"number",min:0,max:20,step:.1,className:"h-7 text-xs",value:t.car_parking_ratio??"",onChange:a=>s({car_parking_ratio:parseFloat(a.target.value)||null}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Reserved Stalls"}),e.jsx(be,{type:"number",min:0,max:500,className:"h-7 text-xs",value:t.car_parking_reserved??0,onChange:a=>s({car_parking_reserved:parseInt(a.target.value)||0}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Visitor Stalls"}),e.jsx(be,{type:"number",min:0,max:500,className:"h-7 text-xs",value:t.car_parking_visitor??0,onChange:a=>s({car_parking_visitor:parseInt(a.target.value)||0}),disabled:n})]})]})})}function LB({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Trailer Parking Label",icon:e.jsx(hu,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Total Trailer Stalls"}),e.jsx(be,{type:"number",min:0,max:500,className:"h-7 text-xs",value:t.trailer_count??0,onChange:a=>s({trailer_count:parseInt(a.target.value)||0}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Staging Stalls"}),e.jsx(be,{type:"number",min:0,max:200,className:"h-7 text-xs",value:t.trailer_staging??0,onChange:a=>s({trailer_staging:parseInt(a.target.value)||0}),disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Drop Stalls"}),e.jsx(be,{type:"number",min:0,max:200,className:"h-7 text-xs",value:t.trailer_drop??0,onChange:a=>s({trailer_drop:parseInt(a.target.value)||0}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Exclusive (Not Shared)"}),e.jsx(kt,{checked:t.trailer_exclusive??!1,onCheckedChange:a=>s({trailer_exclusive:a}),disabled:n})]})]})})}function MB({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Washdown Area",icon:e.jsx(Kc,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Floor Type"}),e.jsxs(rt,{value:t.washdown_floor_type||"epoxy",onValueChange:a=>s({washdown_floor_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"epoxy",className:"text-xs",children:"Epoxy"}),e.jsx(le,{value:"sealed_concrete",className:"text-xs",children:"Sealed Concrete"}),e.jsx(le,{value:"stainless",className:"text-xs",children:"Stainless Steel"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Drain Style"}),e.jsxs(rt,{value:t.washdown_drain_style||"trench",onValueChange:a=>s({washdown_drain_style:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"trench",className:"text-xs",children:"Trench Drain"}),e.jsx(le,{value:"point",className:"text-xs",children:"Point Drain"}),e.jsx(le,{value:"slot",className:"text-xs",children:"Slot Drain"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Slope to Drain (%)"}),e.jsx(be,{type:"number",min:.5,max:5,step:.25,className:"h-7 text-xs",value:t.washdown_slope_pct??2,onChange:a=>s({washdown_slope_pct:parseFloat(a.target.value)||2}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Chemical-Resistant Coating"}),e.jsx(kt,{checked:t.washdown_chem_resistant??!1,onCheckedChange:a=>s({washdown_chem_resistant:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Hot Water Supply"}),e.jsx(kt,{checked:t.washdown_hot_water??!1,onCheckedChange:a=>s({washdown_hot_water:a}),disabled:n})]})]})})}function IB({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Chemical Storage",icon:e.jsx(L5,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Storage Type"}),e.jsxs(rt,{value:t.chem_storage_type||"cabinet",onValueChange:a=>s({chem_storage_type:a}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"cabinet",className:"text-xs",children:"Flammable Cabinet"}),e.jsx(le,{value:"locker",className:"text-xs",children:"Chemical Locker"}),e.jsx(le,{value:"cage",className:"text-xs",children:"Storage Cage"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Capacity (gal)"}),e.jsx(be,{type:"number",min:5,max:1e4,className:"h-7 text-xs",value:t.chem_storage_capacity_gal??55,onChange:a=>s({chem_storage_capacity_gal:parseFloat(a.target.value)||55}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Ventilated"}),e.jsx(kt,{checked:t.chem_storage_ventilated??!1,onCheckedChange:a=>s({chem_storage_ventilated:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Fire-Rated"}),e.jsx(kt,{checked:t.chem_storage_fire_rated??!1,onCheckedChange:a=>s({chem_storage_fire_rated:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Spill Containment"}),e.jsx(kt,{checked:t.chem_storage_containment??!1,onCheckedChange:a=>s({chem_storage_containment:a}),disabled:n})]})]})})}function AB({overlay:t,onUpdate:s,isUpdating:n}){return e.jsx(ns,{title:"Bus Dropoff",icon:e.jsx(c3,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Lane Count"}),e.jsxs(rt,{value:String(t.bus_dropoff_lanes??1),onValueChange:a=>s({bus_dropoff_lanes:parseInt(a)}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"1",className:"text-xs",children:"1 Lane"}),e.jsx(le,{value:"2",className:"text-xs",children:"2 Lanes"}),e.jsx(le,{value:"3",className:"text-xs",children:"3 Lanes"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Lane Length (ft)"}),e.jsx(be,{type:"number",min:40,max:300,className:"h-7 text-xs",value:t.bus_dropoff_lane_length_ft??60,onChange:a=>s({bus_dropoff_lane_length_ft:parseFloat(a.target.value)||60}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Shelter"}),e.jsx(kt,{checked:t.bus_dropoff_has_shelter??!1,onCheckedChange:a=>s({bus_dropoff_has_shelter:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"ADA Compliant"}),e.jsx(kt,{checked:t.bus_dropoff_ada??!1,onCheckedChange:a=>s({bus_dropoff_ada:a}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Covered Waiting Area"}),e.jsx(kt,{checked:t.bus_dropoff_covered_wait??!1,onCheckedChange:a=>s({bus_dropoff_covered_wait:a}),disabled:n})]})]})})}
761const DB=[{id:"strip_center",label:"Strip Centers"},{id:"anchor",label:"Anchor Buildings"},{id:"pad",label:"Pad Buildings"},{id:"outparcel",label:"Outparcels / Standalone"}],mT=[{id:"strip_straight",label:"Straight Bar",category:"strip_center",description:"Linear multi-tenant strip with inline storefronts",icon:"LayoutList",sfRange:"16,000–40,000 SF",defaults:{floor_height_ft:20,material_preset:"stucco",show_storefront:!0,show_canopy:!0,dock_count:0,window_pattern:"bands",retail_shape:"straight",retail_bay_count:8,retail_bay_width_ft:25,retail_anchor_count:0}},{id:"strip_l",label:"L-Shape Center",category:"strip_center",description:"L-shaped strip with corner anchor position",icon:"CornerDownRight",sfRange:"24,000–60,000 SF",defaults:{floor_height_ft:20,material_preset:"stucco",show_storefront:!0,show_canopy:!0,dock_count:0,window_pattern:"bands",retail_shape:"l_shape",retail_bay_count:12,retail_bay_width_ft:25,retail_anchor_count:1}},{id:"strip_u",label:"U-Shape Center",category:"strip_center",description:"U-shaped strip enclosing parking court",icon:"Square",sfRange:"32,000–80,000 SF",defaults:{floor_height_ft:20,material_preset:"stucco",show_storefront:!0,show_canopy:!0,dock_count:0,window_pattern:"bands",retail_shape:"u_shape",retail_bay_count:16,retail_bay_width_ft:25,retail_anchor_count:1}},{id:"anchor_grocery",label:"Grocery Box",category:"anchor",description:"Full-service grocery with rear docks and storefront glazing",icon:"ShoppingCart",sfRange:"35,000–65,000 SF",defaults:{floor_height_ft:24,material_preset:"stucco",show_storefront:!0,show_canopy:!0,dock_count:2,window_pattern:"bands",retail_anchor_count:1}},{id:"anchor_fitness",label:"Fitness Box",category:"anchor",description:"Health club with minimal fenestration and large open floor",icon:"Dumbbell",sfRange:"25,000–45,000 SF",defaults:{floor_height_ft:22,material_preset:"metal_panel",show_storefront:!0,show_canopy:!1,dock_count:1,window_pattern:"none",retail_anchor_count:1}},{id:"anchor_bigbox",label:"Discount / Big Box",category:"anchor",description:"Large-format discount retailer with deep floor plate",icon:"Warehouse",sfRange:"80,000–150,000 SF",defaults:{floor_height_ft:28,material_preset:"tilt_up",show_storefront:!0,show_canopy:!0,dock_count:4,window_pattern:"none",retail_anchor_count:1}},{id:"pad_small",label:"Small Pad",category:"pad",description:"Small freestanding retail (coffee, salon, etc.)",icon:"Coffee",sfRange:"1,800–4,000 SF",defaults:{floor_height_ft:16,material_preset:"stucco",show_storefront:!0,show_canopy:!0,dock_count:0,window_pattern:"bands"}},{id:"pad_mid",label:"Mid Pad",category:"pad",description:"Mid-size freestanding retail (pharmacy, fast casual)",icon:"Store",sfRange:"4,000–10,000 SF",defaults:{floor_height_ft:18,material_preset:"stucco",show_storefront:!0,show_canopy:!0,dock_count:0,window_pattern:"bands"}},{id:"pad_large",label:"Large Pad",category:"pad",description:"Large freestanding retail (auto parts, sporting goods)",icon:"Building",sfRange:"10,000–20,000 SF",defaults:{floor_height_ft:20,material_preset:"stucco",show_storefront:!0,show_canopy:!0,dock_count:1,window_pattern:"bands"}},{id:"outparcel_bank",label:"Bank",category:"outparcel",description:"Branch bank with drive-through lanes and canopy",icon:"Landmark",sfRange:"3,000–5,000 SF",defaults:{floor_height_ft:14,material_preset:"brick",show_storefront:!0,show_canopy:!0,dock_count:0,window_pattern:"grid",retail_drive_thru:!0}},{id:"outparcel_restaurant",label:"Restaurant",category:"outparcel",description:"Full-service or fast-casual restaurant with patio option",icon:"UtensilsCrossed",sfRange:"3,500–7,000 SF",defaults:{floor_height_ft:16,material_preset:"brick",show_storefront:!0,show_canopy:!0,dock_count:0,window_pattern:"bands",retail_patio_seating:!0}},{id:"outparcel_cstore",label:"C-Store + Gas",category:"outparcel",description:"Convenience store with fuel canopy and pump islands",icon:"Fuel",sfRange:"2,500–4,500 SF",defaults:{floor_height_ft:14,material_preset:"stucco",show_storefront:!0,show_canopy:!0,dock_count:0,window_pattern:"bands",retail_gas_canopy:!0,retail_pump_count:8}},{id:"outparcel_urgent_care",label:"Urgent Care / Medical Retail",category:"outparcel",description:"Walk-in medical clinic with ADA-heavy design",icon:"Heart",sfRange:"4,000–8,000 SF",defaults:{floor_height_ft:14,material_preset
761:"brick",show_storefront:!0,show_canopy:!0,dock_count:0,window_pattern:"grid"}}];function b2(t){return t&&mT.find(s=>s.id===t)||null}function RB({overlay:t,onUpdate:s,isUpdating:n}){const a=t.retail_subtype,l=b2(a),c=y=>{const x=b2(y);if(!x)return;const v=x.defaults,C=t.floor_count||1,P=t.roof_height_ft||0,z=(t.base_elevation_ft||0)+C*v.floor_height_ft+P;s({retail_subtype:y,floor_height_ft:v.floor_height_ft,material_preset:v.material_preset,show_storefront:v.show_storefront,show_canopy:v.show_canopy,dock_count:v.dock_count,window_pattern:v.window_pattern,height_ft:z,retail_shape:v.retail_shape||null,retail_bay_count:v.retail_bay_count||null,retail_bay_width_ft:v.retail_bay_width_ft||null,retail_anchor_count:v.retail_anchor_count||null,retail_drive_thru:v.retail_drive_thru||!1,retail_gas_canopy:v.retail_gas_canopy||!1,retail_pump_count:v.retail_pump_count||null,retail_patio_seating:v.retail_patio_seating||!1})},u=(l==null?void 0:l.category)==="strip_center",i=a==="outparcel_cstore",_=a==="outparcel_restaurant",j=a==="outparcel_bank";return e.jsxs(ns,{title:"Retail Format",icon:e.jsx(Sc,{className:"w-4 h-4"}),badge:l?e.jsx(Mt,{variant:"secondary",className:"text-[10px] h-5",children:l.label}):null,defaultOpen:!0,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Select a retail building format to apply massing and feature defaults"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-xs font-medium",children:"Building Format"}),e.jsxs(rt,{value:a||"",onValueChange:c,disabled:n,children:[e.jsx(it,{className:"h-8 text-xs mt-1",children:e.jsx(ct,{placeholder:"Select format..."})}),e.jsx(ot,{children:DB.map(y=>e.jsxs(JC,{children:[e.jsx(QC,{className:"text-xs font-semibold text-muted-foreground",children:y.label}),mT.filter(x=>x.category===y.id).map(x=>e.jsx(le,{value:x.id,className:"text-xs",children:e.jsxs("div",{className:"flex items-center justify-between w-full gap-2",children:[e.jsx("span",{children:x.label}),e.jsx("span",{className:"text-muted-foreground text-[10px]",children:x.sfRange})]})},x.id))]},y.id))})]})]}),l&&e.jsx("p",{className:"text-[11px] text-muted-foreground italic",children:l.description}),u&&e.jsxs("div",{className:"space-y-2 pt-1 border-t border-border/50",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Bay Count"}),e.jsx(be,{type:"number",className:"h-7 text-xs mt-1",value:t.retail_bay_count??l.defaults.retail_bay_count??8,onChange:y=>s({retail_bay_count:parseInt(y.target.value)||8}),min:3,max:30,disabled:n})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Bay Width (ft)"}),e.jsx(be,{type:"number",className:"h-7 text-xs mt-1",value:t.retail_bay_width_ft??l.defaults.retail_bay_width_ft??25,onChange:y=>s({retail_bay_width_ft:parseFloat(y.target.value)||25}),min:18,max:50,disabled:n})]})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Anchor Tenant Count"}),e.jsx(be,{type:"number",className:"h-7 text-xs mt-1",value:t.retail_anchor_count??l.defaults.retail_anchor_count??0,onChange:y=>s({retail_anchor_count:parseInt(y.target.value)||0}),min:0,max:4,disabled:n})]})]}),i&&e.jsxs("div",{className:"space-y-2 pt-1 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Fuel Canopy"}),e.jsx(kt,{checked:t.retail_gas_canopy??!0,onCheckedChange:y=>s({retail_gas_canopy:y}),disabled:n})]}),(t.retail_gas_canopy??!0)&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Fuel Dispensers"}),e.jsx(be,{type:"number",className:"h-7 text-xs mt-1",value:t.retail_pump_count??8,onChange:y=>s({retail_pump_count:parseInt(y.target.value)||4}),min:2,max:24,disabled:n})]})]}),_&&e.jsxs("div",{className:"space-y-2 pt-1 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Patio Seating"}),e.jsx(kt,{checked:t.retail_patio_seating??!0,onCheckedChange:y=>s({retail_patio_seating:y}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Drive-Through"}),e.jsx(kt,{checked:t.retail_drive_thru??!1,onCheckedChange:y=>s({retail_drive_thru:y}),disabled:n})]})]}),j&&e.jsx("div",{className:"space-y-2 pt-1 border-t border-border/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Drive-Through"}),e.jsx(kt,{checked:t.retail_drive_thru??!0,onCheckedChange:y=>s({retail_drive_thru:y}),disabled:n})]})})]})]})}const j2=[{value:"aluminum",label:"Aluminum Storefront",description:"Standard aluminum-framed glazing system"},{value:"curtain_wall",label:"Glass Curtain Wall",description:"Floor-to-ceiling glass with structural framing"},{value:"rollup",label:"Roll-Up Storefront Doors",description:"Roll-up glass/metal doors for restaurants & cafés"}],FB=[{value:"flush",label:"Flush Entry",description:"Standard flush with facade"},{value:"recessed",label:"Recessed Entry",description:"Set back from facade plane"},{value:"corner",label:"Corner Entry",description:"Angled entry at building corner"},{value:"double_vestibule",label:"Double-Door Vestibule",description:"Airlock-style double entry"}],zB=[{value:"straight",label:"Straight",description:"Uniform parapet height"},{value:"stepped",label:"Stepped",description:"Stepped parapet sections"},{value:"tower",label:"Tower Feature",description:"Classic tower accent at entry"},{value:"modern_frame",label:"Modern Frame",description:"Contemporary open-frame accent"}],w2=[{value:"raceway_band",label:"Raceway Band",description:"Continuous channel for mou
761nted signage"},{value:"individual_letters",label:"Individual Letters",description:"Direct-mount individual characters"},{value:"blade",label:"Blade Signs",description:"Projecting blade signs (urban / mixed-use)"}],OB=[{value:"brick",label:"Brick"},{value:"cmu",label:"Split-Face CMU"},{value:"eifs",label:"EIFS / Stucco"},{value:"metal_panel",label:"Metal Panel"},{value:"wood_accent",label:"Wood-Look Accents"},{value:"stone_veneer",label:"Stone Veneer"},{value:"stucco",label:"Stucco"},{value:"tilt_up",label:"Tilt-Up Concrete"}];function BB({overlay:t,onUpdate:s,isUpdating:n}){var C,P;const a=t.storefront_system_type||"",l=t.entry_module_type||"",c=t.entry_module_depth_ft??4,u=t.entry_module_width_ft??8,i=t.parapet_style||"",_=t.parapet_step_count??2,j=t.parapet_tower_height_ft??6,y=t.parapet_tower_width_ft??12,x=t.signage_zone_type||"",v=t.exterior_primary_material||"";return e.jsx(ns,{title:"Architectural Detail",icon:e.jsx(Sf,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Storefront System"}),e.jsxs(rt,{value:a,onValueChange:I=>s({storefront_system_type:I}),disabled:n,children:[e.jsx(it,{children:e.jsx(ct,{placeholder:"Select system type"})}),e.jsx(ot,{children:j2.map(I=>e.jsx(le,{value:I.value,children:I.label},I.value))})]}),a&&e.jsx("p",{className:"text-xs text-muted-foreground",children:(C=j2.find(I=>I.value===a))==null?void 0:C.description})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Entry Module"}),e.jsxs(rt,{value:l,onValueChange:I=>s({entry_module_type:I}),disabled:n,children:[e.jsx(it,{children:e.jsx(ct,{placeholder:"Select entry type"})}),e.jsx(ot,{children:FB.map(I=>e.jsx(le,{value:I.value,children:I.label},I.value))})]}),(l==="recessed"||l==="double_vestibule")&&e.jsxs("div",{className:"grid grid-cols-2 gap-2 pt-1",children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Recess Depth (ft)"}),e.jsx(be,{type:"number",min:2,max:12,step:.5,value:c,onChange:I=>s({entry_module_depth_ft:parseFloat(I.target.value)||4}),disabled:n})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Entry Width (ft)"}),e.jsx(be,{type:"number",min:4,max:20,step:1,value:u,onChange:I=>s({entry_module_width_ft:parseFloat(I.target.value)||8}),disabled:n})]})]}),l==="corner"&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Entry Width (ft)"}),e.jsx(be,{type:"number",min:4,max:20,step:1,value:u,onChange:I=>s({entry_module_width_ft:parseFloat(I.target.value)||8}),disabled:n})]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Parapet Style"}),e.jsxs(rt,{value:i,onValueChange:I=>s({parapet_style:I}),disabled:n,children:[e.jsx(it,{children:e.jsx(ct,{placeholder:"Select parapet style"})}),e.jsx(ot,{children:zB.map(I=>e.jsx(le,{value:I.value,children:I.label},I.value))})]}),i==="stepped"&&e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Step Count"}),e.jsx(be,{type:"number",min:1,max:5,step:1,value:_,onChange:I=>s({parapet_step_count:parseInt(I.target.value)||2}),disabled:n})]}),(i==="tower"||i==="modern_frame")&&e.jsxs("div",{className:"grid grid-cols-2 gap-2 pt-1",children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Tower Height (ft)"}),e.jsx(be,{type:"number",min:2,max:20,step:1,value:j,onChange:I=>s({parapet_tower_height_ft:parseFloat(I.target.value)||6}),disabled:n})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Tower Width (ft)"}),e.jsx(be,{type:"number",min:4,max:40,step:1,value:y,onChange:I=>s({parapet_tower_width_ft:parseFloat(I.target.value)||12}),disabled:n})]})]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Storefront Signage Zone"}),e.jsxs(rt,{value:x,onValueChange:I=>s({signage_zone_type:I}),disabled:n,children:[e.jsx(it,{children:e.jsx(ct,{placeholder:"Select signage zone"})}),e.jsx(ot,{children:w2.map(I=>e.jsx(le,{value:I.value,children:I.label},I.value))})]}),x&&e.jsx("p",{className:"text-xs text-muted-foreground",children:(P=w2.find(I=>I.value===x))==null?void 0:P.description})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Primary Exterior Material"}),e.jsxs(rt,{value:v,onValueChange:I=>s({exterior_primary_material:I}),disabled:n,children:[e.jsx(it,{children:e.jsx(ct,{placeholder:"Select material"})}),e.jsx(ot,{children:OB.map(I=>e.jsx(le,{value:I.value,children:I.label},I.value))})]})]})]})})}const $B={box_truck_dock_enabled:!1,box_truck_dock_count:1,box_truck_dock_height:"grade",box_truck_door_width_ft:12,rear_service_drive_enabled:!1,rear_service_drive_width_ft:24,rear_service_drive_surface:"asphalt",rear_service_drive_direction:"two_way",rear_overhead_door_count:1,rear_overhead_door_width_ft:10,rear_overhead_door_height_ft:10};function VB({overlay:t,onUpdate:s,isUpdating:n}){const a=t.style||{},l={...$B,...a.retailLoading||{}},c=i=>{s({style:{...a,retailLoading:{...l,...i}}})},u=[l.box_truck_dock_enabled,l.rear_service_drive_enabled,l.rear_overhead_door_count>
7610].filter(Boolean).length;return e.jsxs(ns,{title:"Retail Loading",icon:e.jsx(hu,{className:"w-4 h-4"}),badge:u>0?e.jsxs(Mt,{variant:"default",className:"text-[10px] h-5",children:[u," active"]}):null,defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Back-of-house loading for retail operations"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs font-medium",children:"Box Truck Dock"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Grade-level or raised dock for delivery trucks"})]}),e.jsx(kt,{checked:l.box_truck_dock_enabled,onCheckedChange:i=>c({box_truck_dock_enabled:i}),disabled:n})]}),l.box_truck_dock_enabled&&e.jsxs("div",{className:"pl-2 border-l-2 border-primary/20 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Count"}),e.jsx(be,{type:"number",min:1,max:4,value:l.box_truck_dock_count,onChange:i=>c({box_truck_dock_count:parseInt(i.target.value)||1}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Door Width (ft)"}),e.jsx(be,{type:"number",min:10,max:14,value:l.box_truck_door_width_ft,onChange:i=>c({box_truck_door_width_ft:parseFloat(i.target.value)||12}),className:"h-7 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Dock Height"}),e.jsxs(rt,{value:l.box_truck_dock_height,onValueChange:i=>c({box_truck_dock_height:i}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"grade",children:"Grade Level"}),e.jsx(le,{value:"raised",children:"Raised (48″)"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs font-medium",children:"Rear Service Drive"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Dedicated rear access for service vehicles"})]}),e.jsx(kt,{checked:l.rear_service_drive_enabled,onCheckedChange:i=>c({rear_service_drive_enabled:i}),disabled:n})]}),l.rear_service_drive_enabled&&e.jsxs("div",{className:"pl-2 border-l-2 border-primary/20 space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Width (ft)"}),e.jsx(be,{type:"number",min:20,max:30,value:l.rear_service_drive_width_ft,onChange:i=>c({rear_service_drive_width_ft:parseFloat(i.target.value)||24}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Surface"}),e.jsxs(rt,{value:l.rear_service_drive_surface,onValueChange:i=>c({rear_service_drive_surface:i}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"asphalt",children:"Asphalt"}),e.jsx(le,{value:"concrete",children:"Concrete"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Direction"}),e.jsxs(rt,{value:l.rear_service_drive_direction,onValueChange:i=>c({rear_service_drive_direction:i}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"one_way",children:"One-Way"}),e.jsx(le,{value:"two_way",children:"Two-Way"})]})]})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lf,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs font-medium",children:"Rear Overhead Doors"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Count"}),e.jsx(be,{type:"number",min:0,max:6,value:l.rear_overhead_door_count,onChange:i=>c({rear_overhead_door_count:parseInt(i.target.value)||0}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Width (ft)"}),e.jsx(be,{type:"number",min:8,max:14,value:l.rear_overhead_door_width_ft,onChange:i=>c({rear_overhead_door_width_ft:parseFloat(i.target.value)||10}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Height (ft)"}),e.jsx(be,{type:"number",min:8,max:14,value:l.rear_overhead_door_height_ft,onChange:i=>c({rear_overhead_door_height_ft:parseFloat(i.target.value)||10}),className:"h-7 text-xs",disabled:n})]})]})]})]})]})}const N2=[{id:"transformer",label:"Transformer"},{id:"generator",label:"Generator"},{id:"hvac_condenser",label:"HVAC Condenser"},{id:"electrical_panel",label:"Electrical Panel"}],qB=[{id:"masonry",label:"Masonry"},{id:"wood",label:"Wood"},{id:"metal_panel",label:"Metal Panel"},{id:"chain_link_slats",label:"Chain Link w/ Slats"}],GB={name:"Equipment Screen",equipment_type:"transformer",screen_material:"masonry",screen_height_ft:6,has_gate:!0,pad_width_ft:10,pad_depth_ft:10};function HB({overlay:t,onUpdate:s,isUpdating:n}){const[a,l]=k.useState(null),c=t.style||{},u=c.groundMechanicalScreens||[],i=x=>{s({style:{...c,groundMechanicalScreens:x}})},_=()=>{const x={...GB,id:crypto.randomUUID(),name:`Equipment Screen ${u.length+1}`};i([...u,x]),l(x.id)},j=(x,v)=>{i(u.map(C=>C.id===x?{...C,...v}:C))},y=x=>{i(u.filter(v=>v.id!==x)),a===x&&l(null)};return e.jsxs(ns,{title:"Ground Equipment Screens",icon:e.jsx(hd,{className:"w-4 h-4"}),badge:u.length>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:u.length}):null,defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Screen walls for ground-level mechanical equipment"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full text-xs",onClick:_,disabled:n,children:[e.jsx(tr,{className:"w-3.5 h-3.5 mr-1"}),"Add Equipment Screen"]}),u.length===0?e.jsxs("div",{className:"text-center py-3 text-muted-foreground text-sm",children:[e.jsx(hd,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-xs",children:"No equipment screens defined"})]}):e.jsx("div",{className:"space-y-2",children:u.map(x=>{var P;const v=a===x.id,C=(P=N2.find(I=>I.id===x.equipment_type))==null?void 0:P.label;return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",v?"border-primary bg-primary/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>l(v?null:x.id),children:[e.jsx(hd,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:x.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[C," • ",x.pad_width_ft,"′×",x.pad_depth_ft,"′"]})]}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:I=>{I.stopPropagation(),y(x.id)},children:e.jsx(ja,{className:"w-3.5 h-3.5"})}),v?e.jsx(Cc,{className:"w-4 h-4 text-muted-foreground"}):e.jsx(Oa,{className:"w-4 h-4 text-muted-foreground"})]}),v&&e.jsxs("div",{className:"p-3 pt-0 space-y-3 border-t",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Name"}),e.jsx(be,{type:"text",value:x.name,onChange:I=>j(x.id,{name:I.target.value}),className:"h-8 text-sm",disabled:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Equipment Type"}),e.jsxs(rt,{value:x.equipment_type,onValueChange:I=>j(x.id,{equipment_type:I}),disabled:n,children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:N2.map(I=>e.jsx(le,{value:I.id,children:I.label},I.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Screen Material"}),e.jsxs(rt,{value:x.screen_material,onValueChange:I=>j(x.id,{screen_material:I}),disabled:n,children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:qB.map(I=>e.jsx(le,{value:I.id,children:I.label},I.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Screen Height (ft)"}),e.jsx(be,{type:"number",min:4,max:12,value:x.screen_height_ft,onChange:I=>j(x.id,{screen_height_ft:parseFloat(I.target.value)||6}),className:"h-8 text-sm",disabled:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Pad Width (ft)"}),e.jsx(be,{type:"number",min:6,max:30,value:x.pad_width_ft,onChange:I=>j(x.id,{pad_width_ft:parseFloat(I.target.value)||10}),className:"h-8 text-sm",disabled:n})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Pad Depth (ft)"}),e.jsx(be,{type:"number",min:6,max:30,value:x.pad_depth_ft,onChange:I=>j(x.id,{pad_depth_ft:parseFloat(I.target.value)||10}),className:"h-8 text-sm",disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Service Gate"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Access gate for maintenance"})]}),e.jsx(kt,{checked:x.has_gate,onCheckedChange:I=>j(x.id,{has_gate:I}),disabled:n})]})]})]},x.id)})})]})]})}const ZB={patio_depth_ft:12,patio_width_ft:30,patio_fencing_style:"metal_rail",patio_fencing_height_ft:3.5,has_host_stand:!1,exhaust_stack_count:1,exhaust_stack_height_ft:6,grease_trap_location:"rear",dt_stacking_capacity:"12",dt_stacking_width_ft:11,dt_has_bypass:!1,dt_bypass_width_ft:12,dt_menu_board_count:1,dt_pickup_window_side:"left",dt_dual_lane:!1,dt_order_point_count:1,dt_walk_up_window:!1,dt_mobile_pickup_zone
761:!1,receiving_depth_ft:60,receiving_width_ft:80,receiving_dock_count:2,truck_route_width_ft:30,truck_turning_radius_ft:50,cart_corral_count:6,has_fuel_pad:!1,fuel_pad_pump_count:8,fuel_pad_canopy:!0,fuel_pad_types:["gasoline"],bank_dt_lane_count:3,bank_dt_canopy:!0,bank_dt_canopy_length_ft:60,bank_atm_enabled:!0,bank_atm_type:"drive_up",bank_atm_canopy:!0,bank_pneumatic_tube:!0,med_ambulance_bay:!1,med_ambulance_width_ft:14,med_ambulance_depth_ft:30,med_covered_dropoff:!0,med_dropoff_width_ft:14,med_dropoff_length_ft:40,med_separate_patient_parking:!1,med_patient_spaces:12,med_separate_staff_parking:!1,med_staff_spaces:8,gs_station_scale:"standard",gs_dispenser_count:8,gs_fuel_types:["gasoline"],gs_canopy_enabled:!0,gs_canopy_width_ft:60,gs_canopy_depth_ft:40,gs_ust_count:3,gs_ust_location:"rear",gs_drive_thru:!1,gs_dual_entrance:!1,gs_truck_parking:!1,gs_truck_spaces:20,gs_truck_diesel_island:!1,gs_truck_diesel_lanes:2},WB=["outparcel_restaurant"],YB=["pad_small","pad_mid"],XB=["anchor_grocery"],KB=["outparcel_bank"],JB=["outparcel_urgent_care"],QB=["outparcel_cstore"];function UB({overlay:t,onUpdate:s,isUpdating:n}){const a=t.style||{},l={...ZB,...a.tenantKit||{}},c=t.retail_subtype||"",u=t.retail_drive_thru||!1,i=F=>{s({style:{...a,tenantKit:{...l,...F}}})},_=WB.includes(c),j=YB.includes(c)&&u,y=_&&u||j,x=XB.includes(c),v=KB.includes(c),C=JB.includes(c),P=QB.includes(c),I=_||j||x||v||C||P,z=_?"Restaurant":j?"Coffee/QSR":x?"Grocery":v?"Bank":C?"Medical":P?"Gas Station":null;return e.jsxs(ns,{title:"Tenant Kit",icon:e.jsx(oN,{className:"w-4 h-4"}),badge:z?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:z}):null,defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Context-specific operational modules for the selected retail format"}),!c&&e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-md bg-muted/50 text-muted-foreground",children:[e.jsx($y,{className:"w-4 h-4 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-xs",children:"Select a Retail Format in the section above to activate tenant-specific controls."})]}),c&&!I&&e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-md bg-muted/50 text-muted-foreground",children:[e.jsx($y,{className:"w-4 h-4 mt-0.5 shrink-0"}),e.jsxs("p",{className:"text-xs",children:['No tenant kit available for the selected retail format "',c,'".']})]}),_&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oN,{className:"w-3.5 h-3.5 text-orange-500"}),e.jsx(B,{className:"text-xs font-semibold",children:"Restaurant Kit"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs font-medium",children:"Patio Zone"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Depth (ft)"}),e.jsx(be,{type:"number",min:6,max:30,value:l.patio_depth_ft,onChange:F=>i({patio_depth_ft:parseFloat(F.target.value)||12}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Width (ft)"}),e.jsx(be,{type:"number",min:10,max:100,value:l.patio_width_ft,onChange:F=>i({patio_width_ft:parseFloat(F.target.value)||30}),className:"h-7 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Fencing Style"}),e.jsxs(rt,{value:l.patio_fencing_style,onValueChange:F=>i({patio_fencing_style:F}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"metal_rail",children:"Metal Rail"}),e.jsx(le,{value:"planter_wall",children:"Planter Wall"}),e.jsx(le,{value:"cable_rail",children:"Cable Rail"}),e.jsx(le,{value:"rope_stanchion",children:"Rope Stanchion"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Fence Height (ft)"}),e.jsx(be,{type:"number",min:2,max:6,step:.5,value:l.patio_fencing_height_ft,onChange:F=>i({patio_fencing_height_ft:parseFloat(F.target.value)||3.5}),className:"h-7 text-xs",disabled:n})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Host Stand / Entry Feature"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Covered vestibule marker"})]}),e.jsx(kt,{checked:l.has_host_stand,onCheckedChange:F=>i({has_host_stand:F}),disabled:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Exhaust Stacks"}),e.jsx(be,{type:"number",min:0,max:6,value:l.exhaust_stack_count,onChange:F=>i({exhaust_stack_count:parseInt(F.target.value)||1}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Stack Height (ft)"}),e.jsx(be,{type:"number",min:3,max:15,value:l.exhaust_stack_height_ft,onChange:F=>i({exhaust_stack_height_ft:parseFloat(F.target.value)||6}),className:"h-7 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Grease Trap Location"}),e.jsxs(rt,{value:l.grease_trap_location,onValueChange:F=>i({grease_trap_location:F}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"rear",children:"Rear"}),e.jsx(le,{value:"side",children:"Side"}),e.jsx(le,{value:"underground",children:"Underground"})]})]})]})]}),y&&e.jsxs(e.Fragment,{children:[_&&e.jsx(ks,{className:"my-3"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ml,{className:"w-3.5 h-3.5 text-blue-500"}),e.jsx(B,{className:"text-xs font-semibold",children:"Drive-Thru Configuration"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Stacking Capacity"}),e.jsxs(rt,{value:l.dt_stacking_capacity,onValueChange:F=>i({dt_stacking_capacity:F}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"8",children:"8 Cars"}),e.jsx(le,{value:"12",children:"12 Cars"}),e.jsx(le,{value:"15",children:"15 Cars"}),e.jsx(le,{value:"custom",children:"Custom"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Lane Width (ft)"}),e.jsx(be,{type:"number",min:10,max:14,value:l.dt_stacking_width_ft,onChange:F=>i({dt_stacking_width_ft:parseFloat(F.target.value)||11}),className:"h-7 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Bypass Lane"}),e.jsx(kt,{checked:l.dt_has_bypass,onCheckedChange:F=>i({dt_has_bypass:F}),disabled:n})]}),l.dt_has_bypass&&e.jsxs("div",{className:"pl-2 border-l-2 border-primary/20 space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Bypass Width (ft)"}),e.jsx(be,{type:"number",min:10,max:14,value:l.dt_bypass_width_ft,onChange:F=>i({dt_bypass_width_ft:parseFloat(F.target.value)||12}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Menu Boards"}),e.jsx(be,{type:"number",min:1,max:2,value:l.dt_menu_board_count,onChange:F=>i({dt_menu_board_count:parseInt(F.target.value)||1}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Order Points"}),e.jsx(be,{type:"number",min:1,max:2,value:l.dt_order_point_count,onChange:F=>i({dt_order_point_count:parseInt(F.target.value)||1}),className:"h-7 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Pickup Window Side"}),e.jsxs(rt,{value:l.dt_pickup_window_side,onValueChange:F=>i({dt_pickup_window_side:F}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"left",children:"Left"}),e.jsx(le,{value:"right",children:"Right"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Dual Lane Config"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Modern dual-lane split"})]}),e.jsx(kt,{checked:l.dt_dual_lane,onCheckedChange:F=>i({dt_dual_lane:F}),disabled:n})]}),j&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{className:"my-2"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Walk-Up Window"}),e.jsx(kt,{checked:l.dt_walk_up_window,onCheckedChange:F=>i({dt_walk_up_window:F}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Mobile Pickup Zone"}),e.jsx(kt,{checked:l.dt_mobile_pickup_zone,onCheckedChange:F=>
761i({dt_mobile_pickup_zone:F}),disabled:n})]})]})]})]}),x&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fp,{className:"w-3.5 h-3.5 text-green-500"}),e.jsx(B,{className:"text-xs font-semibold",children:"Grocery Anchor Kit"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Receiving Depth (ft)"}),e.jsx(be,{type:"number",min:30,max:100,value:l.receiving_depth_ft,onChange:F=>i({receiving_depth_ft:parseFloat(F.target.value)||60}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Receiving Width (ft)"}),e.jsx(be,{type:"number",min:40,max:120,value:l.receiving_width_ft,onChange:F=>i({receiving_width_ft:parseFloat(F.target.value)||80}),className:"h-7 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Dock Count"}),e.jsx(be,{type:"number",min:1,max:6,value:l.receiving_dock_count,onChange:F=>i({receiving_dock_count:parseInt(F.target.value)||2}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Route Width (ft)"}),e.jsx(be,{type:"number",min:24,max:40,value:l.truck_route_width_ft,onChange:F=>i({truck_route_width_ft:parseFloat(F.target.value)||30}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Turn Radius (ft)"}),e.jsx(be,{type:"number",min:40,max:70,value:l.truck_turning_radius_ft,onChange:F=>i({truck_turning_radius_ft:parseFloat(F.target.value)||50}),className:"h-7 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Cart Corral Count"}),e.jsx(be,{type:"number",min:0,max:20,value:l.cart_corral_count,onChange:F=>i({cart_corral_count:parseInt(F.target.value)||6}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Optional Fuel Pad"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Grocery fuel station"})]}),e.jsx(kt,{checked:l.has_fuel_pad,onCheckedChange:F=>i({has_fuel_pad:F}),disabled:n})]}),l.has_fuel_pad&&e.jsx("div",{className:"pl-2 border-l-2 border-primary/20 space-y-2",children:e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Pump Islands"}),e.jsx(be,{type:"number",min:4,max:16,value:l.fuel_pad_pump_count,onChange:F=>i({fuel_pad_pump_count:parseInt(F.target.value)||8}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4",children:[e.jsx(B,{className:"text-[10px]",children:"Canopy"}),e.jsx(kt,{checked:l.fuel_pad_canopy,onCheckedChange:F=>i({fuel_pad_canopy:F}),disabled:n})]})]})})]}),v&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Sf,{className:"w-3.5 h-3.5 text-indigo-500"}),e.jsx(B,{className:"text-xs font-semibold",children:"Bank Kit"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Drive-Thru Lanes"}),e.jsx(be,{type:"number",min:2,max:4,value:l.bank_dt_lane_count,onChange:F=>i({bank_dt_lane_count:parseInt(F.target.value)||3}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Canopy Length (ft)"}),e.jsx(be,{type:"number",min:30,max:100,value:l.bank_dt_canopy_length_ft,onChange:F=>i({bank_dt_canopy_length_ft:parseFloat(F.target.value)||60}),className:"h-7 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Drive-Thru Canopy"}),e.jsx(kt,{checked:l.bank_dt_canopy,onCheckedChange:F=>i({bank_dt_canopy:F}),disabled:n})]}),e.jsx(ks,{className:"my-2"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"ATM Island"}),e.jsx(kt,{checked:l.bank_atm_enabled,onCheckedChange:F=>i({bank_atm_enabled:F}),disabled:n})]}),l.bank_atm_enabled&&e.jsxs("div",{className:"pl-2 border-l-2 border-primary/20 space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"ATM Type"}),e.jsxs(rt,{value:l.bank_atm_type,onValueChange:F=>i({bank_atm_type:F}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"drive_up",children:"Drive-Up"}),e.jsx(le,{value:"walk_up",children:"Walk-Up"}),e.jsx(le,{value:"vestibule",children:"Vestibule"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-[10px]",children:"ATM Canopy"}),e.jsx(kt,{checked:l.bank_atm_canopy,onCheckedChange:F=>i({bank_atm_canopy:F}),disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Pneumatic Tube"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Legacy feature"})]}),e.jsx(kt,{checked:l.bank_pneumatic_tube,onCheckedChange:F=>i({bank_pneumatic_tube:F}),disabled:n})]})]}),C&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E0,{className:"w-3.5 h-3.5 text-red-500"}),e.jsx(B,{className:"text-xs font-semibold",children:"Medical / Urgent Care Kit"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Ambulance Bay"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Optional bay with clearance"})]}),e.jsx(kt,{checked:l.med_ambulance_bay,onCheckedChange:F=>i({med_ambulance_bay:F}),disabled:n})]}),l.med_ambulance_bay&&e.jsxs("div",{className:"pl-2 border-l-2 border-primary/20 grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Width (ft)"}),e.jsx(be,{type:"number",min:12,max:20,value:l.med_ambulance_width_ft,onChange:F=>i({med_ambulance_width_ft:parseFloat(F.target.value)||14}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Depth (ft)"}),e.jsx(be,{type:"number",min:20,max:50,value:l.med_ambulance_depth_ft,onChange:F=>i({med_ambulance_depth_ft:parseFloat(F.target.value)||30}),className:"h-7 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Covered Entry Drop-Off"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Porte-cochère style"})]}),e.jsx(kt,{checked:l.med_covered_dropoff,onCheckedChange:F=>i({med_covered_dropoff:F}),disabled:n})]}),l.med_covered_dropoff&&e.jsxs("div",{className:"pl-2 border-l-2 border-primary/20 grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Lane Width (ft)"}),e.jsx(be,{type:"number",min:12,max:20,value:l.med_dropoff_width_ft,onChange:F=>i({med_dropoff_width_ft:parseFloat(F.target.value)||14}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Lane Length (ft)"}),e.jsx(be,{type:"number",min:30,max:80,value:l.med_dropoff_length_ft,onChange:F=>i({med_dropoff_length_ft:parseFloat(F.target.value)||40}),className:"h-7 text-xs",disabled:n})]})]}),e.jsx(ks,{className:"my-2"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Separate Patient Parking"}),e.jsx(kt,{checked:l.med_separate_patient_parking,onCheckedChange:F=>i({med_separate_patient_parking:F}),disabled:n})]}),l.med_separate_patient_parking&&e.jsxs("div",{className:"pl-2 border-l-2 border-primary/20 space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Patient Spaces"}),e.jsx(be,{type:"number",min:4,max:50,value:l.med_patient_spaces,onChange:F=>i({med_patient_spaces:parseInt(F.target.value)||12}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Separate Staff Parking"}),e.jsx(kt,{checked:l.med_separate_staff_parking,onCheckedChange:F=>i({med_separate_staff_parking:F}),disabled:n})]}),l.med_separate_staff_parking&&e.jsxs("div",{className:"pl-2 border-l-2 border-primary/20 space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Staff Space
761s"}),e.jsx(be,{type:"number",min:4,max:30,value:l.med_staff_spaces,onChange:F=>i({med_staff_spaces:parseInt(F.target.value)||8}),className:"h-7 text-xs",disabled:n})]})]}),P&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X1,{className:"w-3.5 h-3.5 text-amber-500"}),e.jsx(B,{className:"text-xs font-semibold",children:"Gas Station / C-Store Kit"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Station Scale"}),e.jsxs(rt,{value:l.gs_station_scale,onValueChange:F=>i({gs_station_scale:F}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"standard",children:"Standard"}),e.jsx(le,{value:"travel_center",children:"Travel Center"}),e.jsx(le,{value:"truck_stop",children:"Truck Stop"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Fuel Dispensers"}),e.jsx(be,{type:"number",min:2,max:24,value:l.gs_dispenser_count,onChange:F=>i({gs_dispenser_count:parseInt(F.target.value)||8}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"UST Count"}),e.jsx(be,{type:"number",min:1,max:10,value:l.gs_ust_count,onChange:F=>i({gs_ust_count:parseInt(F.target.value)||3}),className:"h-7 text-xs",disabled:n})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"UST Location"}),e.jsxs(rt,{value:l.gs_ust_location,onValueChange:F=>i({gs_ust_location:F}),disabled:n,children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"rear",children:"Rear"}),e.jsx(le,{value:"side",children:"Side"}),e.jsx(le,{value:"under_canopy",children:"Under Canopy"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Gas Canopy"}),e.jsx(kt,{checked:l.gs_canopy_enabled,onCheckedChange:F=>i({gs_canopy_enabled:F}),disabled:n})]}),l.gs_canopy_enabled&&e.jsxs("div",{className:"pl-2 border-l-2 border-primary/20 grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Width (ft)"}),e.jsx(be,{type:"number",min:30,max:120,value:l.gs_canopy_width_ft,onChange:F=>i({gs_canopy_width_ft:parseFloat(F.target.value)||60}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Depth (ft)"}),e.jsx(be,{type:"number",min:20,max:80,value:l.gs_canopy_depth_ft,onChange:F=>i({gs_canopy_depth_ft:parseFloat(F.target.value)||40}),className:"h-7 text-xs",disabled:n})]})]}),e.jsx(ks,{className:"my-2"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"C-Store Drive-Thru"}),e.jsx(kt,{checked:l.gs_drive_thru,onCheckedChange:F=>i({gs_drive_thru:F}),disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Dual Entrance"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Second curb cut"})]}),e.jsx(kt,{checked:l.gs_dual_entrance,onCheckedChange:F=>i({gs_dual_entrance:F}),disabled:n})]}),(l.gs_station_scale==="travel_center"||l.gs_station_scale==="truck_stop")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{className:"my-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hu,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs font-medium",children:"Truck Operations"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Truck Parking"}),e.jsx(kt,{checked:l.gs_truck_parking,onCheckedChange:F=>i({gs_truck_parking:F}),disabled:n})]}),l.gs_truck_parking&&e.jsxs("div",{className:"pl-2 border-l-2 border-primary/20 space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Truck Spaces"}),e.jsx(be,{type:"number",min:5,max:200,value:l.gs_truck_spaces,onChange:F=>i({gs_truck_spaces:parseInt(F.target.value)||20}),className:"h-7 text-xs",disabled:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Truck Die
761sel Island"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Separate high-flow island"})]}),e.jsx(kt,{checked:l.gs_truck_diesel_island,onCheckedChange:F=>i({gs_truck_diesel_island:F}),disabled:n})]}),l.gs_truck_diesel_island&&e.jsxs("div",{className:"pl-2 border-l-2 border-primary/20 space-y-1",children:[e.jsx(B,{className:"text-[10px]",children:"Diesel Lanes"}),e.jsx(be,{type:"number",min:1,max:6,value:l.gs_truck_diesel_lanes,onChange:F=>i({gs_truck_diesel_lanes:parseInt(F.target.value)||2}),className:"h-7 text-xs",disabled:n})]})]})]})]})}function fT(t){if(!t||t.length<3)return[];const s=[];for(let n=0;n<t.length;n++){const a=(n+1)%t.length,l=t[n],c=t[a],u=gi(us([l.lng,l.lat]),us([c.lng,c.lat]),{units:"feet"}),i=Or(us([l.lng,l.lat]),us([c.lng,c.lat]));s.push({index:n,lengthFt:Math.round(u*10)/10,bearing:i,start:l,end:c})}return s}function e8(t){if(!t||t.length<3)return{widthFt:0,depthFt:0};const s=fT(t);if(s.length<2)return{widthFt:0,depthFt:0};let n=0;for(let u=1;u<s.length;u++)s[u].lengthFt>s[n].lengthFt&&(n=u);const a=s[n];let l=-1,c=999;for(let u=0;u<s.length;u++){if(u===n)continue;let i=Math.abs(Math.abs(s[u].bearing-a.bearing)-90);i>90&&(i=180-i),i<c&&(c=i,l=u)}return{widthFt:Math.round(a.lengthFt),depthFt:l>=0?Math.round(s[l].lengthFt):0}}function c1(t,s,n,a){const l=s/2*.3048/1e3,c=n/2*.3048/1e3,u=us([t.lng,t.lat]),i=On(On(u,l,a,{units:"kilometers"}),c,a+90,{units:"kilometers"}),_=On(On(u,l,a,{units:"kilometers"}),c,a-90,{units:"kilometers"}),j=On(On(u,l,a+180,{units:"kilometers"}),c,a-90,{units:"kilometers"}),y=On(On(u,l,a+180,{units:"kilometers"}),c,a+90,{units:"kilometers"});return[{lat:i.geometry.coordinates[1],lng:i.geometry.coordinates[0]},{lat:_.geometry.coordinates[1],lng:_.geometry.coordinates[0]},{lat:j.geometry.coordinates[1],lng:j.geometry.coordinates[0]},{lat:y.geometry.coordinates[1],lng:y.geometry.coordinates[0]}]}function t8(t,s,n,a,l,c,u){const i=P=>P*.3048/1e3,_=us([t.lng,t.lat]),j=(P,I,z,F)=>{const D=On(_,i(z*P),u,{units:"kilometers"}),X=On(D,i(F*I),u+90,{units:"kilometers"});return{lat:X.geometry.coordinates[1],lng:X.geometry.coordinates[0]}},y=n/2,x=a/2,v=l,C=c;if(s==="rectangle")return c1(t,n,a,u);if(s==="l_shape")return[j(-y,-x,1,1),j(y,-x,1,1),j(y,x-C,1,1),j(y-v,x-C,1,1),j(y-v,x,1,1),j(-y,x,1,1)];if(s==="u_shape")return[j(-y,-x,1,1),j(y,-x,1,1),j(y,x,1,1),j(y-v,x,1,1),j(y-v,-x+C,1,1),j(-y+v,-x+C,1,1),j(-y+v,x,1,1),j(-y,x,1,1)];if(s==="t_shape"){const P=v/2;return[j(-y,-x,1,1),j(y,-x,1,1),j(y,-x+C,1,1),j(P,-x+C,1,1),j(P,x,1,1),j(-P,x,1,1),j(-P,-x+C,1,1),j(-y,-x+C,1,1)]}return c1(t,n,a,u)}function s8(t,s,n){const a=[...t.map(I=>({...I}))],l=s,c=(s+1)%a.length,u=a[l],i=a[c],_=(u.lat+i.lat)/2,j=(u.lng+i.lng)/2,y=us([j,_]),x=Or(us([u.lng,u.lat]),us([i.lng,i.lat])),v=n/2*.3048/1e3,C=On(y,v,x+180,{units:"kilometers"}),P=On(y,v,x,{units:"kilometers"});return a[l]={lat:C.geometry.coordinates[1],lng:C.geometry.coordinates[0]},a[c]={lat:P.geometry.coordinates[1],lng:P.geometry.coordinates[0]},a}function n8(t,s){const n=[...t],a=t[s],l=t[(s+1)%t.length],c={lat:(a.lat+l.lat)/2,lng:(a.lng+l.lng)/2};return n.splice(s+1,0,c),n}function a8(t,s){if(t.length<=3)return null;const n=[...t];return n.splice(s,1),n}function r8({overlay:t,onUpdate:s,isUpdating:n}){const a=t.geometry,[l,c]=k.useState("quick"),[u,i]=k.useState(""),[_,j]=k.useState(""),[y,x]=k.useState("40"),[v,C]=k.useState("40"),P=k.useRef([]),I=k.useRef([]),z=k.useRef(null);t.id!==z.current&&(z.current=t.id,P.current=[],I.current=[]);const F=k.useCallback(ie=>{a&&ie.geometry&&(P.current.push(a.map(de=>({...de}))),I.current=[]),s(ie)},[a,s]),D=k.useCallback(()=>{if(P.current.length===0){Ve.info("Nothing to undo");return}a&&I.current.push(a.map(de=>({...de})));const ie=P.current.pop();s({geometry:ie}),Ve.success("Undid dimension change")},[a,s]),X=k.useCallback(()=>{if(I.current.length===0){Ve.info("Nothing to redo");return}a&&P.current.push(a.map(de=>({...de})));const ie=I.current.pop();s({geometry:ie}),Ve.success("Redid dimension change")},[a,s]),K=P.current.length>0,te=I.current.length>0,J=k.useMemo(()=>a?fT(a):[],[a]),H=k.useMemo(()=>a?e8(a):{widthFt:0,depthFt:0},[a]),O=k.useMemo(()=>
761{if(!a||a.length<3)return null;const ie=a.map(We=>[We.lng,We.lat]),de=Xn([[...ie,ie[0]]]),ge=Yo(de);return{lat:ge.geometry.coordinates[1],lng:ge.geometry.coordinates[0]}},[a]),q=k.useMemo(()=>{if(J.length===0)return 0;let ie=J[0];for(const de of J)de.lengthFt>ie.lengthFt&&(ie=de);return ie.bearing},[J]),W=k.useCallback(()=>{if(!O)return;const ie=parseFloat(u)||H.widthFt,de=parseFloat(_)||H.depthFt;if(ie<=0||de<=0)return;const ge=c1(O,ie,de,q);F({geometry:ge})},[O,u,_,H,q,F]),Q=k.useCallback(ie=>{if(!O)return;const de=parseFloat(u)||H.widthFt||200,ge=parseFloat(_)||H.depthFt||100,We=parseFloat(y)||40,Ee=parseFloat(v)||40,ve=t8(O,ie,de,ge,We,Ee,q);F({geometry:ve})},[O,u,_,y,v,H,q,F]),Z=k.useCallback((ie,de)=>{if(!a||de<=0)return;const ge=s8(a,ie,de);F({geometry:ge})},[a,F]),oe=k.useCallback(ie=>{if(!a)return;const de=n8(a,ie);F({geometry:de})},[a,F]),ce=k.useCallback(ie=>{if(!a)return;const de=a8(a,ie);de&&F({geometry:de})},[a,F]),ae=k.useMemo(()=>{if(!a||a.length<3)return 0;const ie=a.map(we=>[we.lng,we.lat]);ie.push(ie[0]);let de=0;for(let we=0;we<ie.length-1;we++)de+=ie[we][0]*ie[we+1][1]-ie[we+1][0]*ie[we][1];const ge=a.reduce((we,Ze)=>we+Ze.lat,0)/a.length,We=111320,Ee=111320*Math.cos(ge*Math.PI/180),ve=Math.abs(de/2)*We*Ee;return Math.round(ve*10.7639)},[a]);return!a||a.length<3?null:e.jsxs(ns,{title:"Dimensions",icon:e.jsx(Fo,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:[H.widthFt," × ",H.depthFt," ft"]}),defaultOpen:!1,children:[e.jsxs("div",{className:"flex items-center justify-between -mt-2 mb-3",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Set exact building dimensions or choose a shape template"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:D,disabled:!K||n,title:"Undo dimension change (Ctrl+Z)",children:e.jsx(zf,{className:"w-3.5 h-3.5"})}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:X,disabled:!te||n,title:"Redo dimension change (Ctrl+Y)",children:e.jsx(U1,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs(Zm,{value:l,onValueChange:c,children:[e.jsxs(mm,{className:"grid w-full grid-cols-3 h-8",children:[e.jsx(Bi,{value:"quick",className:"text-[10px]",children:"W × D"}),e.jsx(Bi,{value:"edges",className:"text-[10px]",children:"Per Edge"}),e.jsx(Bi,{value:"shapes",className:"text-[10px]",children:"Shapes"})]}),e.jsxs($i,{value:"quick",className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",className:"h-7 text-xs",placeholder:`${H.widthFt}`,value:u,onChange:ie=>i(ie.target.value),min:10,max:5e3,disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Depth (ft)"}),e.jsx(be,{type:"number",className:"h-7 text-xs",placeholder:`${H.depthFt}`,value:_,onChange:ie=>j(ie.target.value),min:10,max:5e3,disabled:n})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(Le,{size:"sm",className:"flex-1 h-7 text-xs",onClick:W,disabled:n||!u&&!_,children:[e.jsx(NS,{className:"w-3 h-3 mr-1"}),"Apply Dimensions"]})}),e.jsxs("div",{className:"text-[10px] text-muted-foreground text-center",children:["Area: ",ae.toLocaleString()," SF"]})]}),e.jsxs($i,{value:"edges",className:"space-y-2 mt-3",children:[e.jsx("div",{className:"space-y-1.5 max-h-[300px] overflow-y-auto",children:J.map((ie,de)=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"text-[10px] text-muted-foreground w-10 shrink-0",children:["E",de+1]}),e.jsx(be,{type:"number",className:"h-7 text-xs flex-1",defaultValue:Math.round(ie.lengthFt),onBlur:ge=>{const We=parseFloat(ge.target.value);We&&We>0&&Math.abs(We-ie.lengthFt)>.5&&Z(de,We)},onKeyDown:ge=>{if(ge.key==="Enter"){const We=parseFloat(ge.target.value);We&&We>0&&Z(de,We)}},min:1,disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground w-5",children:"ft"}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0",onClick:()=>oe(de),disabled:n,title:"Split edge (add vertex)",children:e.jsx(tr,{className:"w-3 h-3"})})]},de))}),a.length>3&&e.jsxs("div",{className:"pt-2 border-t",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground mb-1.5",children:"Remove vertex:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:a.map((ie,de)=>e.jsxs(Le,{variant:"outline",size:"sm",className:"h-6 w-8 text-[10px] p-0",onClick:()=>ce(de),disabled:n||a.length<=3,title:`Remove vertex ${de+1}`,children:["V",de+1]},de))})]})]}),e.jsxs($i,{value:"shapes",className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Main Width (ft)"}),e.jsx(be,{type:"number",className:"h-7 text-xs",placeholder:`${H.widthFt||200}`,value:u,onChange:ie=>i(ie.target.value),min:10,disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Main Depth (ft)"}),e.jsx(be,{type:"number",className:"h-7 text-xs",placeholder:`${H.depthFt||100}
761`,value:_,onChange:ie=>j(ie.target.value),min:10,disabled:n})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Wing Width (ft)"}),e.jsx(be,{type:"number",className:"h-7 text-xs",value:y,onChange:ie=>x(ie.target.value),min:10,disabled:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Wing Depth (ft)"}),e.jsx(be,{type:"number",className:"h-7 text-xs",value:v,onChange:ie=>C(ie.target.value),min:10,disabled:n})]})]}),e.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[{shape:"rectangle",label:"Rect",icon:"▬"},{shape:"l_shape",label:"L",icon:"⌐"},{shape:"u_shape",label:"U",icon:"⊔"},{shape:"t_shape",label:"T",icon:"⊤"}].map(({shape:ie,label:de,icon:ge})=>e.jsxs(Le,{variant:"outline",size:"sm",className:"h-10 flex flex-col gap-0.5 text-[10px]",onClick:()=>Q(ie),disabled:n,children:[e.jsx("span",{className:"text-lg leading-none",children:ge}),e.jsx("span",{children:de})]},ie))})]})]})]})}const i8=[{id:"warehouse",name:"Warehouse",icon:e.jsx(yg,{className:"w-4 h-4"}),floor_count:1,floor_height_ft:32,roof_type:"flat",material_preset:"tilt_up",dock_count:8},{id:"office_low",name:"Office (Low)",icon:e.jsx(Ci,{className:"w-4 h-4"}),floor_count:3,floor_height_ft:12,roof_type:"flat",material_preset:"glass",window_pattern:"bands"},{id:"retail",name:"Retail Pad",icon:e.jsx(Sc,{className:"w-4 h-4"}),floor_count:1,floor_height_ft:24,roof_type:"flat",material_preset:"stucco"},{id:"flex",name:"Flex/Industrial",icon:e.jsx(Ig,{className:"w-4 h-4"}),floor_count:1,floor_height_ft:24,roof_type:"flat",material_preset:"metal_panel",dock_count:4}],o8=[{value:"flat",label:"Flat"},{value:"parapet",label:"Parapet"},{value:"gabled",label:"Gabled"},{value:"hipped",label:"Hipped"},{value:"mansard",label:"Mansard"},{value:"shed",label:"Shed"}],l8=[10,12,24,32];function c8({overlay:t,allOverlays:s=[],onUpdate:n,mode:a,isUpdating:l,onStartWindowEdgeSelection:c,onCancelWindowEdgeSelection:u,windowEdgeSelectionMode:i=!1,onStartCanopyEdgeSelection:_,onCancelCanopyEdgeSelection:j,canopyEdgeSelectionMode:y=!1,onStartStorefrontEdgeSelection:x,onCancelStorefrontEdgeSelection:v,storefrontEdgeSelectionMode:C=!1,onStartDockEdgeSelection:P,onCancelDockEdgeSelection:I,dockEdgeSelectionMode:z=!1,onStartDriveInEdgeSelection:F,onCancelDriveInEdgeSelection:D,driveInEdgeSelectionMode:X=!1,stallEditorEnabled:K=!1,onToggleStallEditor:te,selectedStallId:J=null,onSelectedStallIdChange:H,driveAisles:O=[],parkingRows:q=[],selectedEntryId:W=null,onSelectedEntryIdChange:Q,entryPointPlacementMode:Z=!1,onStartEntryPointPlacement:oe,onCancelEntryPointPlacement:ce,onStartCutoutDrawing:ae,onCreateFloorSlab:ie,onUpdateChildOverlay:de,onDeleteChildOverlay:ge}){var He,as,vt;const[We,Ee]=k.useState(t.floor_height_ft||12),[ve,we]=k.useState(!1);k.useEffect(()=>{W&&we(!0)},[W]);const Ze=t.layer_type,ke=lu(Ze),ze=oo(Ze)||rm(Ze)||bf(Ze),Ke=YA(Ze),dt=aD(Ze);k.useEffect(()=>{t.floor_height_ft!==void 0&&Ee(t.floor_height_ft||12)},[t.floor_height_ft]);const Re=()=>{const Xe=t.floor_count||1,Ce=t.roof_height_ft||0;return(t.base_elevation_ft||0)+Xe*We+Ce},qt=(Xe,Ce)=>{const Be=Ce.floor_count??t.floor_count??1,Dt=Ce.floor_height_ft??t.floor_height_ft??12,Rt=t.roof_height_ft||0,rs=(t.base_elevation_ft||0)+Be*Dt+Rt;n({building_type:Xe,floor_count:Be,floor_height_ft:Dt,roof_type:Ce.roof_type??t.roof_type,material_preset:Ce.material_preset??t.material_preset,dock_count:Ce.dock_count??t.dock_count,window_pattern:Ce.window_pattern??t.window_pattern,show_canopy:Ce.show_canopy??t.show_canopy,show_storefront:Ce.show_storefront??t.show_storefront,show_column_grid:Ce.show_column_grid??t.show_column_grid,office_percentage:Ce.office_percentage??t.office_percentage,truck_court_depth_ft:Ce.truck_court_depth_ft??t.truck_court_depth_ft,height_ft:rs}),Ee(Dt)},ft=Xe=>{const Ce=Xe.floor_count*Xe.floor_height_ft+(t.roof_height_ft||0);n({floor_count:Xe.floor_count,floor_height_ft:Xe.floor_height_ft,roof_type:Xe.roof_type,material_preset
761:Xe.material_preset,height_ft:Ce,dock_count:Xe.dock_count??0,window_pattern:Xe.window_pattern??"none"}),Ee(Xe.floor_height_ft)},Fe=Xe=>{const Ce=t.floor_count??1,Be=Math.max(0,Ce+Xe),Dt=t.roof_height_ft||0,zt=(t.base_elevation_ft||0)+Be*We+Dt;n({floor_count:Be,height_ft:zt})},fe=Xe=>{Ee(Xe);const Ce=t.floor_count||1,Be=t.roof_height_ft||0,Rt=(t.base_elevation_ft||0)+Ce*Xe+Be;n({floor_height_ft:Xe,height_ft:Rt})};if(ze)return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(Il,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:oo(Ze)?"Site Boundary":rm(Ze)?"Property Boundary":"Lot Boundary"}),e.jsx("p",{className:"text-xs mt-2",children:"Boundary layers define constraints only."})]}),(rm(Ze)||bf(Ze))&&e.jsxs(ns,{title:"Curb Types",icon:e.jsx(Sf,{className:"w-4 h-4"}),defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Configure curb profiles along property edges"}),e.jsx(u2,{overlay:t,onUpdate:n,isUpdating:l})]}),(rm(Ze)||bf(Ze))&&e.jsxs(ns,{title:"Pedestrian Paths",icon:e.jsx(zu,{className:"w-4 h-4"}),defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Sidewalk connections to parking, buildings, and entries"}),e.jsx(m2,{overlay:t,onUpdate:n,isUpdating:l})]}),(rm(Ze)||bf(Ze))&&e.jsxs(ns,{title:"Landscape Islands",icon:e.jsx(Ih,{className:"w-4 h-4"}),defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Standalone islands at corners, entrances, and medians"}),e.jsx(p2,{overlay:t,onUpdate:n,isUpdating:l})]})]});if(Ke)return e.jsx(lF,{overlay:t,onUpdate:n,isUpdating:l});if(dt)return e.jsx(yF,{overlay:t,onUpdate:n,isUpdating:l,elementType:dt});const Qe={guard_booth:e.jsx(oO,{overlay:t,onUpdate:n,isUpdating:l}),roof_mechanical:e.jsx(lO,{overlay:t,onUpdate:n,isUpdating:l}),overhead_crane:e.jsx(cO,{overlay:t,onUpdate:n,isUpdating:l}),mezzanine:e.jsx(dO,{overlay:t,onUpdate:n,isUpdating:l}),truck_queue:e.jsx(uO,{overlay:t,onUpdate:n,isUpdating:l}),fuel_island:e.jsx(hO,{overlay:t,onUpdate:n,isUpdating:l}),container_yard:e.jsx(mO,{overlay:t,onUpdate:n,isUpdating:l}),scale_house:e.jsx(fO,{overlay:t,onUpdate:n,isUpdating:l}),amenity_pad:null,hazmat_zone:e.jsx(pO,{overlay:t,onUpdate:n,isUpdating:l}),emergency_assembly:e.jsx(gO,{overlay:t,onUpdate:n,isUpdating:l}),generator_pad:e.jsx(xO,{overlay:t,onUpdate:n,isUpdating:l}),fire_suppression:e.jsx(_O,{overlay:t,onUpdate:n,isUpdating:l}),rail_spur:e.jsx(yO,{overlay:t,onUpdate:n,isUpdating:l}),drop_lot:e.jsx(eB,{overlay:t,onUpdate:n,isUpdating:l}),yard_jockey:e.jsx(tB,{overlay:t,onUpdate:n,isUpdating:l}),turning_template:e.jsx(sB,{overlay:t,onUpdate:n,isUpdating:l}),stormwater_inlet:e.jsx(rB,{overlay:t,onUpdate:n,isUpdating:l}),outfall:e.jsx(lB,{overlay:t,onUpdate:n,isUpdating:l}),gas_meter_bank:e.jsx(dB,{overlay:t,onUpdate:n,isUpdating:l}),office_entrance:e.jsx(hB,{overlay:t,onUpdate:n,isUpdating:l}),dock_ramp:e.jsx(pB,{overlay:t,onUpdate:n,isUpdating:l}),truck_wash:e.jsx(xB,{overlay:t,onUpdate:n,isUpdating:l}),cold_storage:e.jsx(bB,{overlay:t,onUpdate:n,isUpdating:l}),bike_rack:e.jsx(jB,{overlay:t,onUpdate:n,isUpdating:l}),bench:e.jsx(wB,{overlay:t,onUpdate:n,isUpdating:l}),berm:e.jsx(NB,{overlay:t,onUpdate:n,isUpdating:l}),demising_wall:e.jsx(kB,{overlay:t,onUpdate:n,isUpdating:l}),tenant_signage_zone:e.jsx(CB,{overlay:t,onUpdate:n,isUpdating:l}),tenant_entry:e.jsx(SB,{overlay:t,onUpdate:n,isUpdating:l}),unit_label:e.jsx(EB,{overlay:t,onUpdate:n,isUpdating:l}),dock_count_label:e.jsx(PB,{overlay:t,onUpdate:n,isUpdating:l}),car_parking_label:e.jsx(TB,{overlay:t,onUpdate:n,isUpdating:l}),trailer_parking_label:e.jsx(LB,{overlay:t,onUpdate:n,isUpdating:l}),washdown_area:e.jsx(MB,{overlay:t,onUpdate:n,isUpdating:l}),chemical_storage:e.jsx(IB,{overlay:t,onUpdate:n,isUpdating:l}),bus_dropoff:e.jsx(AB,{overlay:t,onUpdate:n,isUpdating:l}),dc_substation:e.jsx(zO,{overlay:t,onUpdate:n,isUpdating:l}),dc_gen_yard:e.jsx(OO,{overlay:t,onUpdate:n,isUpdating:l}),dc_chiller_plant:e.jsx(BO,{overlay:t,onUpdate:n,isUpdating:l}),dc_fuel_tank_farm:e.jsx($O,{overlay:t,onUpdate:n,isUpdating:l}),dc_perimeter_security:e.jsx(VO,{overlay:t,onUpdate:n,isUpdating:l}),dc_fiber_vault:e.jsx(qO,{overlay:t,onUpdate:n,isUpdating:l}),dc_tie_in_pad:e.jsx(GO,{overlay:t,onUpdate:n,isUpdating:l}),dc_water_treatment:e.jsx(HO,{overlay:t,onUpdate:n,isUpdating:l}),dc_mv_distribution:e.jsx(ZO,{overlay:t,onUpdate:n,isUpdating:l}
761),dc_dark_fiber:e.jsx(WO,{overlay:t,onUpdate:n,isUpdating:l}),dc_redundant_feeds:e.jsx(YO,{overlay:t,onUpdate:n,isUpdating:l}),dc_chw_distribution:e.jsx(XO,{overlay:t,onUpdate:n,isUpdating:l}),dc_ehouse:e.jsx(KO,{overlay:t,onUpdate:n,isUpdating:l}),dc_bess:e.jsx(JO,{overlay:t,onUpdate:n,isUpdating:l}),dc_fuel_berm:e.jsx(QO,{overlay:t,onUpdate:n,isUpdating:l}),dc_acoustic_enclosure:e.jsx(UO,{overlay:t,onUpdate:n,isUpdating:l}),dc_cooling_tower_yard:e.jsx(e6,{overlay:t,onUpdate:n,isUpdating:l}),dc_dry_cooler_yard:e.jsx(t6,{overlay:t,onUpdate:n,isUpdating:l}),dc_pipe_rack:e.jsx(s6,{overlay:t,onUpdate:n,isUpdating:l}),dc_heat_exchanger:e.jsx(n6,{overlay:t,onUpdate:n,isUpdating:l}),dc_pump_house:e.jsx(a6,{overlay:t,onUpdate:n,isUpdating:l}),dc_roof_screen:e.jsx(r6,{overlay:t,onUpdate:n,isUpdating:l}),dc_guardhouse:e.jsx(i6,{overlay:t,onUpdate:n,isUpdating:l}),dc_sally_port:e.jsx(o6,{overlay:t,onUpdate:n,isUpdating:l}),dc_wedge_barrier:e.jsx(l6,{overlay:t,onUpdate:n,isUpdating:l}),dc_camera_array:e.jsx(c6,{overlay:t,onUpdate:n,isUpdating:l}),dc_security_lighting:e.jsx(d6,{overlay:t,onUpdate:n,isUpdating:l}),dc_visitor_screening:e.jsx(u6,{overlay:t,onUpdate:n,isUpdating:l}),dc_service_drive:e.jsx(h6,{overlay:t,onUpdate:n,isUpdating:l}),dc_secure_loading:e.jsx(m6,{overlay:t,onUpdate:n,isUpdating:l}),dc_secure_parking:e.jsx(f6,{overlay:t,onUpdate:n,isUpdating:l}),dc_emergency_route:e.jsx(p6,{overlay:t,onUpdate:n,isUpdating:l}),dc_turning_template:e.jsx(g6,{overlay:t,onUpdate:n,isUpdating:l}),dc_fire_pump_room:e.jsx(x6,{overlay:t,onUpdate:n,isUpdating:l}),dc_fire_water_tank:e.jsx(_6,{overlay:t,onUpdate:n,isUpdating:l}),dc_sanitary_lift_station:e.jsx(y6,{overlay:t,onUpdate:n,isUpdating:l}),dc_water_storage_tank:e.jsx(v6,{overlay:t,onUpdate:n,isUpdating:l}),sound_wall:e.jsx(b6,{overlay:t,onUpdate:n,isUpdating:l}),screen_wall:e.jsx(j6,{overlay:t,onUpdate:n,isUpdating:l}),noise_buffer_zone:e.jsx(w6,{overlay:t,onUpdate:n,isUpdating:l}),roof_penthouse:e.jsx(s2,{overlay:t,onUpdate:n,isUpdating:l}),exhaust_stack:e.jsx(n2,{overlay:t,onUpdate:n,isUpdating:l}),intake_louver_bank:e.jsx(a2,{overlay:t,onUpdate:n,isUpdating:l}),lightning_mast:e.jsx(r2,{overlay:t,onUpdate:n,isUpdating:l}),dc_capacity_label:e.jsx(i2,{overlay:t,onUpdate:n,isUpdating:l}),phase_overlay:e.jsx(o2,{overlay:t,onUpdate:n,isUpdating:l}),secure_zone:e.jsx(l2,{overlay:t,onUpdate:n,isUpdating:l}),mf_clubhouse:e.jsx(z6,{overlay:t,onUpdate:n,isUpdating:l}),mf_pool:e.jsx(O6,{overlay:t,onUpdate:n,isUpdating:l}),mf_playground:e.jsx(B6,{overlay:t,onUpdate:n,isUpdating:l}),mf_dog_park:e.jsx($6,{overlay:t,onUpdate:n,isUpdating:l}),mf_courtyard:e.jsx(V6,{overlay:t,onUpdate:n,isUpdating:l}),mf_sport_court:e.jsx(q6,{overlay:t,onUpdate:n,isUpdating:l}),mf_mail_package:e.jsx(G6,{overlay:t,onUpdate:n,isUpdating:l}),mf_bike_storage:e.jsx(H6,{overlay:t,onUpdate:n,isUpdating:l}),mf_ev_charging:e.jsx(W6,{overlay:t,onUpdate:n,isUpdating:l}),mf_dumpster_enclosure:e.jsx(Z6,{overlay:t,onUpdate:n,isUpdating:l})};if(Ze&&Qe[Ze]!==void 0&&Qe[Ze]!==null){const Xe=hT(Ze||"")!==null;return e.jsxs("div",{className:"space-y-2",children:[Xe&&e.jsx(N6,{overlay:t,onUpdate:n,isUpdating:l}),Qe[Ze]]})}if(PE(Ze))return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-2 border-b",children:[e.jsx(Ml,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium",children:"Parking Configuration"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Dimensions, layout, exclusions, and circulation"})]})]}),e.jsx(ns,{title:"Dimensions",icon:e.jsx(dm,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsx(sO,{overlay:t,onUpdate:n,isUpdating:l})}),e.jsx(ns,{title:"Layout Options",icon:e.jsx(Da,{className:"w-4 h-4"}),defaultOpen:!0,children:e.jsx(rO,{overlay:t,allOverlays:s,onUpdate:n,isUpdating:l})}),e.jsx(ns,{title:"Curb Types",icon:e.jsx(Sf,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsx(u2,{overlay:t,onUpdate:n,isUpdating:l})}),e.jsx(ns,{title:"Pedestrian Paths",icon:e.jsx(zu,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsx(m2,{overlay:t,onUpdate:n,isUpdating:l})}),e.jsx(ns,{title:"Landscape Islands",icon:e.jsx(Ih,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsx(p2,{overlay:t,onUpdate:n,isUpdating:l})}),e.jsx(ns,{title:"Site Exclusions",icon:e.jsx(Da,{className:"w-4 h-4"}),defaultOpen:!1,children:e.jsx(iO,{overlay:t,onUpdate:n,isUpdating:l,onStartCutoutDrawing:ae})}),e.jsx(ns,{title:"Circulation",icon:e.jsx(uo,{className:"w-4 h-4"}),open:ve,onOpenChange:we,children:e.jsx(Rz,{overlay:t,onUpdate:n,isUpdating:l,stallEditorEnabled:K,onToggleStallEditor:te,selectedStallId:J,onSelectedStallIdChange:H,driveAisles:O,parkingRows:q,hideHeader:!0,selectedEntryId:W,onSelectedEntryIdChange:Q,entryPointPlacementMode:Z,onStartEntryPointPlacement:oe,onCancelEntryPointPlacement:ce})}),e.jsx(tO,{overlay:t,allOverlays:s,onUpdate:n,isUpdating:l,hideHeader:!0,onStartCutoutDrawing:ae,renderMode:"generate_only"})]});if(Ze==="building_floor")return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-2 border-b",children:[e.jsx(Da,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium",children:"Floor Slab Configuration"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Structural floor plate within a building"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Floor Level"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>n({floor_level:Math.max(1,(t.floor_level??1)-1)}),disabled:l||(t.floor_level??1)<=1,children:e.jsx(Om,{className:"w-3 h-3"})}),e.jsx("span",{className:"w-8 text-center font-medium text-sm",children:t.floor_level??1}),e.jsx(Le,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>n({floor_level:(t.floor_level??1)+1}),disabled:l,children:e.jsx(tr,{className:"w-3 h-3"})}),e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:(t.floor_level??1)===1?"Ground":`Level ${t.floor_level}`})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Slab Thickness (inches
761)"}),e.jsx(be,{type:"number",value:t.floor_thickness_in??6,onChange:Xe=>n({floor_thickness_in:parseFloat(Xe.target.value)||6}),className:"h-8 text-sm",min:2,max:24,step:1,disabled:l}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:'Typical: 4-6" for slab-on-grade, 8-12" for elevated'})]})]})]});if(!ke)return e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ci,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"Building features are only available for building layer types."}),e.jsx("p",{className:"text-xs mt-1",children:"Change the layer type in the Layers tab."})]});const ht=t.building_type,_t=(()=>{const Xe=Array.isArray(t.geometry)?t.geometry:[];if(Xe.length<2)return 4;const Ce=Xe[0],Be=Xe[Xe.length-1];return typeof(Ce==null?void 0:Ce.lat)=="number"&&typeof(Be==null?void 0:Be.lat)=="number"&&Ce.lat===Be.lat&&Ce.lng===Be.lng?Math.max(1,Xe.length-1):Xe.length})();return e.jsxs("div",{className:"space-y-6",children:[e.jsx(HR,{currentType:ht,onSelect:qt,isUpdating:l}),e.jsx(ks,{}),(!ht||ht==="other")&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-sm font-medium",children:"Quick Presets"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:i8.map(Xe=>e.jsxs(Le,{variant:"outline",size:"sm",className:"h-auto py-2 px-3 flex flex-col items-center gap-1",onClick:()=>ft(Xe),disabled:l,children:[Xe.icon,e.jsx("span",{className:"text-[10px]",children:Xe.name})]},Xe.id))})]}),(!ht||ht==="other")&&e.jsx(ks,{}),e.jsx(r8,{overlay:t,onUpdate:n,isUpdating:l}),xr(ht,"floorConfig")&&e.jsxs(ns,{title:"Vertical Massing",icon:e.jsx(Da,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:[Re()," ft"]}),defaultOpen:!0,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Configure floor count and floor-to-floor height (clear height)"}),e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Floors"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>Fe(-1),disabled:l,children:e.jsx(Om,{className:"w-3 h-3"})}),e.jsx("span",{className:"w-8 text-center font-medium",children:t.floor_count??1}),e.jsx(Le,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>Fe(1),disabled:l,children:e.jsx(tr,{className:"w-3 h-3"})})]})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Floor Height (ft)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(be,{type:"number",value:We,onChange:Xe=>fe(parseFloat(Xe.target.value)||12),className:"h-8 text-sm",disabled:l}),e.jsx("div",{className:"flex gap-1",children:l8.map(Xe=>e.jsx(Le,{variant:We===Xe?"default":"outline",size:"sm",className:"h-8 w-8 text-[10px] px-0",onClick:()=>fe(Xe),disabled:l,children:Xe},Xe))})]})]})]}),xr(ht,"floorConfig")&&e.jsx(ks,{}),xr(ht,"floorConfig")&&e.jsxs(e.Fragment,{children:[e.jsxs(ns,{title:"Floor Slabs",icon:e.jsx(Da,{className:"w-4 h-4"}),badge:e.jsxs(Mt,{variant:"outline",className:"text-[10px] h-5",children:[s.filter(Xe=>Xe.parent_overlay_id===t.id&&Xe.layer_type==="building_floor").length," slabs"]}),defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Add structural floor plates to this building"}),(()=>{const Xe=s.filter(Ce=>Ce.parent_overlay_id===t.id&&Ce.layer_type==="building_floor").sort((Ce,Be)=>(Ce.floor_level??1)-(Be.floor_level??1));return Xe.length>0?e.jsx("div",{className:"space-y-2 mb-3",children:Xe.map(Ce=>e.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded px-2 py-1.5",children:[e.jsx("span",{className:"text-xs font-medium",children:(Ce.floor_level??1)===1?"Ground Floor":`Level ${Ce.floor_level}`}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{type:"number",value:Ce.floor_thickness_in??6,onChange:Be=>{const Dt=parseFloat(Be.target.value)||6;de==null||de(Ce.id,{floor_thickness_in:Dt})},className:"h-6 w-16 text-xs",min:2,max:24,step:1,disabled:l}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"in"}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>ge==null?void 0:ge(Ce.id),disabled:l,children:e.jsx(wr,{className:"w-3.5 h-3.5"})})]})]},Ce.id))}):e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"No floor slabs added yet."})})(),e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full h-8 text-xs",disabled:l,onClick:()=>
761{const Xe=s.filter(Be=>Be.parent_overlay_id===t.id&&Be.layer_type==="building_floor"),Ce=Xe.length>0?Math.max(...Xe.map(Be=>Be.floor_level??1))+1:1;ie==null||ie(t,Ce,6)},children:[e.jsx(tr,{className:"w-3 h-3 mr-1"}),"Add Floor Slab (Level ",(()=>{const Xe=s.filter(Ce=>Ce.parent_overlay_id===t.id&&Ce.layer_type==="building_floor");return Xe.length>0?Math.max(...Xe.map(Ce=>Ce.floor_level??1))+1:1})(),")"]})]}),e.jsx(ks,{})]}),ke&&e.jsxs(e.Fragment,{children:[e.jsx(gz,{overlay:t,onUpdate:n,isUpdating:l}),e.jsx(ks,{})]}),xr(ht,"roof")&&e.jsxs(ns,{title:"Roof System",icon:e.jsx(qd,{className:"w-4 h-4"}),badge:e.jsx(Mt,{variant:"outline",className:"text-[10px] h-5",children:t.roof_type||"flat"}),defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Roof type and parapet/ridge height"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Type"}),e.jsxs(rt,{value:t.roof_type||"flat",onValueChange:Xe=>n({roof_type:Xe}),disabled:l,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:o8.map(Xe=>e.jsx(le,{value:Xe.value,className:"text-xs",children:Xe.label},Xe.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Height (ft)"}),e.jsx(be,{type:"number",value:t.roof_height_ft||0,onChange:Xe=>n({roof_height_ft:parseFloat(Xe.target.value)||0}),className:"h-8 text-xs",disabled:l})]})]}),(t.roof_type==="gabled"||t.roof_type==="hipped"||t.roof_type==="shed")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{className:"my-3"}),e.jsx("p",{className:"text-xs font-medium mb-2",children:"Pitch Configuration"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Eave Height (ft)"}),e.jsx(be,{type:"number",value:t.roof_eave_height_ft??30,onChange:Xe=>{const Ce=parseFloat(Xe.target.value)||30,Be=t.roof_ridge_height_ft??42,Dt=t.width_ft??100,Rt=Be-Ce,zt=Dt/2,rs=zt>0?Math.atan(Rt/zt)*(180/Math.PI):0;n({roof_eave_height_ft:Ce,roof_pitch_degrees:Math.round(rs*10)/10})},className:"h-8 text-xs",disabled:l})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Ridge Height (ft)"}),e.jsx(be,{type:"number",value:t.roof_ridge_height_ft??42,onChange:Xe=>{const Ce=parseFloat(Xe.target.value)||42,Be=t.roof_eave_height_ft??30,Dt=t.width_ft??100,Rt=Ce-Be,zt=Dt/2,rs=zt>0?Math.atan(Rt/zt)*(180/Math.PI):0;n({roof_ridge_height_ft:Ce,roof_pitch_degrees:Math.round(rs*10)/10})},className:"h-8 text-xs",disabled:l})]})]}),(()=>{const Xe=t.roof_eave_height_ft??30,Be=(t.roof_ridge_height_ft??42)-Xe,Rt=(t.width_ft??100)/2,zt=Rt>0?Math.atan(Be/Rt)*(180/Math.PI):0,rs=Rt>0?Math.round(Be/Rt*12*10)/10:0;return e.jsxs("div",{className:"mt-2 p-2 rounded bg-muted/50 text-xs text-muted-foreground",children:["Calculated Pitch: ",e.jsxs("span",{className:"font-medium text-foreground",children:[rs,":12"]})," (",Math.round(zt*10)/10,"°)"]})})(),e.jsxs("div",{className:"space-y-1 mt-2",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Overhang Depth (ft)"}),e.jsx(be,{type:"number",min:0,max:10,step:.5,value:t.roof_overhang_ft??0,onChange:Xe=>n({roof_overhang_ft:parseFloat(Xe.target.value)||0}),className:"h-8 text-xs",disabled:l})]})]})]}),xr(ht,"roof")&&e.jsx(ks,{}),ke&&xr(ht,"docks")&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Loading Docks",icon:e.jsx(Lf,{className:"w-4 h-4"}),badge:(t.dock_count??0)>0?e.jsxs(Mt,{variant:"default",className:"text-[10px] h-5",children:[t.dock_count," docks"]}):null,defaultOpen:!0,children:e.jsx(tF,{overlay:t,onUpdate:n,isUpdating:l,onStartEdgeSelection:P,onCancelEdgeSelection:I,edgeSelectionMode:z})}),e.jsx(ks,{})]}),ke&&xr(ht,"exteriorFinishes")&&e.jsxs(e.Fragment,{children:[e.jsxs(ns,{title:"Exterior Finishes",icon:e.jsx(jS,{className:"w-4 h-4"}),badge:t.exterior_finishes?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:"Active"}):null,defaultOpen:!1,children:[e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Wainscoting, accent bands, cornice trim, color splits, and pilaster bump-outs"}),e.jsx(CF,{overlay:t,onUpdate:n,isUpdating:l,edgeCount:_t})]}),e.jsx(ks,{})]}),ke&&xr(ht,"officeBuildOut")&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Office Build-Out",icon:e.jsx(Ci,{className:"w-4 h-4"}),badge:t.office_percentage?e.jsxs(Mt,{variant:"default",className:"text-[10px] h-5",children:[t.office_percentage,"%"]}):null,defaultOpen:!1,children:e.jsx(LR,{overlay:t,onUpdate:n,isUpdating:l})}),e.jsx(ks,{}),e.jsx(mB,{overlay:t,onUpdate:n,isUpdating:l}),e.jsx(ks,{})]}),ke&&xr(ht,"columnGrid")&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Structural Bay",icon:e.jsx(dm,{className:"w-4 h-4"}),badge:t.show_column_grid?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:"On"}):null,defaultOpen:!1,children:e.jsx(zR,{overlay:t,onUpdate:n,isUpdating:l})}),e.jsx(ks,{})]}),ke&&xr(ht,"windows")&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Fenestration",icon:e.jsx(dm,{className:"w-4 h-4"}),badge:t.window_pattern&&t.window_pattern!=="none"?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:t.window_pattern}):null,defaultOpen:!1,children:e.jsx($R,{overlay:t,onUpdate:n,isUpdating:l,onStartEdgeSelection:c,onCancelEdgeSelection:u,edgeSelectionMode:i})}),e.jsx(ks,{})]}),ke&&xr(ht,"driveInDoors")&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Drive-In Doors",icon:e.jsx(Lf,{className:"w-4 h-4"}),badge:(t.drive_in_door_count??0)>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:t.drive_in_door_count}):null,defaultOpen:!1,children:e.jsx(BR,{overlay:t,onUpdate:n,isUpdating:l,onStartEdgeSelection:F,edgeSelectionMode:X})}),e.jsx(ks,{})]}),ke&&xr(ht,"storefront")&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Storefront Glazing",icon:e.jsx(Sc,{className:"w-4 h-4"}),badge:t.show_storefront?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:"On"}):null,defaultOpen:!1,children:e.jsx(qR,{overlay:t,onUpdate:n,isUpdating:l,onStartEdgeSelection:x,onCancelEdgeSelection:v,edgeSelectionMode:C})}),e.jsx(ks,{})]}),ke&&xr(ht,"canopy")&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Canopy / Awning",icon:e.jsx(P3,{className:"w-4 h-4"}),badge:t.show_canopy?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:"On"}):null,defaultOpen:!1,children:e.jsx(VR,{overlay:t,onUpdate:n,isUpdating:l,onStartEdgeSelection:_,onCancelEdgeSelection:j,edgeSelectionMode:y})}),e.jsx(ks,{})]}),ke&&xr(ht,"truckCourt")&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Truck Court & Trailer Staging",icon:e.jsx(hu,{className:"w-4 h-4"}),badge:t.truck_court_depth_ft?e.jsxs(Mt,{variant:"default",className:"text-[10px] h-5",children:[t.truck_court_depth_ft," ft"]}):null,defaultOpen:!1,children:e.jsx(oF,{overlay:t,allOverlays:s,onUpdate:n,isUpdating:l})}),e.jsx(ks,{})]}),ke&&xr(ht,"exhaustFans")&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Exhaust Fans / Ventilation",icon:e.jsx(Ig,{className:"w-4 h-4"}),badge:t.exhaust_fan_enabled?e.jsxs(Mt,{variant:"default",className:"text-[10px] h-5",children:[t.exhaust_fan_count??4," fans"]}):null,defaultOpen:!1,children:e.jsx(vO,{overlay:t,onUpdate:n,isUpdating:l})}),e.jsx(ks,{})]}),ke&&xr(ht,"skylights")&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Skylights",icon:e.jsx(nS,{className:"w-4 h-4"}),badge:t.skylight_enabled?e.jsxs(Mt,{variant:"default",className:"text-[10px] h-5",children:[(t.skylight_rows??2)*(t.skylight_cols??4)," units"]}):null,defaultOpen:!1,children:e.jsx(wO,{overlay:t,onUpdate:n,isUpdating:l})}),e.jsx(ks,{})]}),ke&&xr(ht,"trashCompactor")&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Trash Compactor",icon:e.jsx(Wm,{className:"w-4 h-4"}),badge:t.trash_compactor_enabled?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:"On"}):null,defaultOpen:!1,children:e.jsx(kO,{overlay:t,onUpdate:n,isUpdating:l})}),e.jsx(ks,{})]}),ke&&xr(ht,"buildingPerimeterLights")&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Building Perimeter Lights",icon:e.jsx(gh,{className:"w-4 h-4"}),badge:t.building_light_enabled?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:"On"}):null,defaultOpen:!1,children:e.jsx(EO,{overlay:t,onUpdate:n,isUpdating:l})}),e.jsx(ks,{})]}),ke&&ht==="data_center"&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(PO,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"dcRaisedFloor")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(TO,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"dcContainment")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(LO,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"dcUpsRoom")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(MO,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"dcSwitchgearRoom")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(IO,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"dcCrahCrac")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(AO,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"dcFireSuppression")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(DO,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"dcMeetMeRoom")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(RO,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"dcNocSoc")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(FO,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"retailSubtype")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(RB,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"retailArchDetail")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(BB,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"retailLoading")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(VB,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"groundMechanicalScreen")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(HB,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"tenantKit")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(UB,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"mfUnitLayout")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(E6,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"mfCorridor")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(P6,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"mfElevatorCore")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(T6,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"mfStairwell")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(L6,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"mfBalcony")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(M6,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"mfParkingGarage")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(I6,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"mfGarageBay")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(A6,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"mfGroundRetail")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(D6,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"mfTrashChute")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(R6,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"mfMechanicalRoom")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(F6,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(ns,{title:"Building Signage",icon:e.jsx(ug,{className:"w-4 h-4"}),badge:(He=t.style)!=null&&He.building_signs?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:((vt=(as=t.style)==null?void 0:as.building_signs)==null?void 0:vt.length)||0}):null,defaultOpen:!1,children:e.jsx(wF,{overlay:t,onUpdate:n,edgeCount:(()=>{const Xe=Array.isArray(t.geometry)?t.geometry:[];if(Xe.length<2)return 4;const Ce=Xe[0],Be=Xe[Xe.length-1];return typeof(Ce==null?void 0:Ce.lat)=="number"&&typeof(Ce==null?void 0:Ce.lng)=="number"&&typeof(Be==null?void 0:Be.lat)=="number"&&typeof(Be==null?void 0:Be.lng)=="number"&&Ce.lat===Be.lat&&Ce.lng===Be.lng?Math.max(1,Xe.length-1):Xe.length})()})})]}),ke&&xr(ht,"roofPenthouse")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(s2,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"exhaustStack")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(n2,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"intakeLouverBank")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(a2,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"lightningMast")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(r2,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"dcCapacityLabel")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(i2,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"phaseOverlay")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(o2,{overlay:t,onUpdate:n,isUpdating:l})]}),ke&&xr(ht,"secureZone")&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(l2,{overlay:t,onUpdate:n,isUpdating:l})]})]})}function xg(t){if(!t||t.length<3)return 0;const s=t.map(l=>[l.lng,l.lat]);s.length>0&&s.push(s[0]);const n=Xn([s]);return zr(n)*10.7639}function d8(t,s={}){const{parentProperty:n,childBuildings:a=[],parkingLayers:l=[],parkingRequirementSfPerSpace:c=500}=s,u=t.calculated_area_sqft||xg(t.geometry),i=(n==null?void 0:n.calculated_area_sqft)||(n!=null&&n.geometry?xg(n.geometry):u),_=i>0?u/i*100:0,j=t.floor_count||1,y=u*j,x=i>0?y/i:0,v=l.reduce((K,te)=>
761K+(te.parking_spaces||0),0)||t.parking_spaces||0,C=Math.ceil(y/c),P=v-C,I=v>0?Math.round(y/v):0,z=v>0?`1:${I}`:"N/A",F=t.dock_count||0,D=F>0?Math.round(u/F):0,X={min:F*2,max:F*3};return{buildingFootprintSf:Math.round(u),siteAreaSf:Math.round(i),buildingCoverageRatio:Math.round(_*10)/10,totalGfa:Math.round(y),far:Math.round(x*100)/100,providedParkingSpaces:v,requiredParkingSpaces:C,parkingRatio:z,parkingDeficit:P,parkingRequirementSfPerSpace:c,dockDoorCount:F,estimatedTurnsPerDay:X,sfPerDoor:D}}function cu(t){return t.toLocaleString("en-US")}function p0(t,s){const n=us([t.lng,t.lat]),a=us([s.lng,s.lat]);return gi(n,a,{units:"kilometers"})*3280.84}function k2(t,s,n){const a=s/3280.84,l=On(us([t.lng,t.lat]),a,n,{units:"kilometers"});return{lat:l.geometry.coordinates[1],lng:l.geometry.coordinates[0]}}function d1(t,s){return Or(us([t.lng,t.lat]),us([s.lng,s.lat]))}function pT(t,s){return`tree_${t}_${s}`}function gT(t,s,n,a,l=0){const c=[];if(n<=0)return c;const u=p0(t,s);if(u<n/2)return c;const i=d1(t,s),_=u-n,j=Math.max(1,Math.floor(_/n)+1),y=j>1?_/(j-1):0,x=n/2;for(let v=0;v<j;v++){const C=x+v*y;let P=k2(t,C,i);if(l>0){const I=(i+90)%360;P=k2(P,l,I)}c.push({lat:P.lat,lng:P.lng,index:v,edgeLabel:a,id:pT(a,v)})}return c}function u8(t,s,n,a,l){const c=[];if(!t||t.length<3)return c;n.forEach(i=>{const _=s[i.label];if(!(_!=null&&_.enabled)||_.type!=="tree_line")return;const j=_.tree_spacing_ft||(a==null?void 0:a.spacing_ft)||25,y=i.edgeIndex,x=(i.edgeIndex+1)%t.length,v=t[y],C=t[x];if(!v||!C)return;const P=(_.width_ft||20)/2,I=gT(v,C,j,i.label,P);c.push(...I)});let u=c;if(l&&(l.deletedTreeIds.length>0&&(u=u.filter(i=>!i.id||!l.deletedTreeIds.includes(i.id))),l.addedTrees.length>0)){const i=l.addedTrees.map((_,j)=>({lat:_.lat,lng:_.lng,index:j,edgeLabel:_.edgeLabel||"custom",id:_.id,isCustom:!0}));u=[...u,...i]}return u}function h8(t,s,n=25){let a=0;return t.forEach(l=>{const c=s[l.label];if(!(c!=null&&c.enabled)||c.type!=="tree_line")return;const u=c.tree_spacing_ft||n,i=l.lengthFt||0;if(i>=u/2&&u>0){const _=i-u;a+=Math.max(1,Math.floor(_/u)+1)}}),a}function u1(t,s){if(t<s/2||s<=0)return 0;const n=t-s;return Math.max(1,Math.floor(n/s)+1)}function m8(t){switch(t){case"deciduous":return"#22c55e";case"evergreen":return"#166534";case"palm":return"#65a30d";case"shrub":return"#84cc16";case"custom_3d":return"#8b5cf6";default:return"#22c55e"}}function xT(t){switch(t){case"deciduous":return"🌳";case"evergreen":return"🌲";case"palm":return"🌴";case"shrub":return"🌿";case"custom_3d":return"📦";default:return"🌳"}}function f8(t,s){if(!s||s.length===0)return!1;const n=us([t.lng,t.lat]);for(const a of s)if(!(a.coordinates.length<4))try{const l=a.coordinates.map(u=>[u.lng,u.lat]),c=Xn([l]);if(uu(n,c))return!0}catch{}return!1}function p8(t,s){return!s||s.length===0?t:t.filter(n=>!f8(n,s))}function g8(t,s,n,a=20){let l=null,c=1/0;for(const u of n){const i=p0({lat:t,lng:s},{lat:u.lat,lng:u.lng});i<c&&i<=a&&(c=i,l=u)}return{tree:l,distanceFt:c}}function x8(t,s,n,a,l){if(!n||n.length<3)return{inBuffer:!1,edgeLabel:null,bufferType:null};for(const c of l){const u=a[c.label];if(!(u!=null&&u.enabled))continue;const i=c.edgeIndex,_=(c.edgeIndex+1)%n.length,j=n[i],y=n[_];if(!j||!y)continue;const x=d1(j,y),v=p0(j,y),C=d1(j,{lat:t,lng:s}),P=p0(j,{lat:t,lng:s}),z=Math.abs((C-x+180)%360-180)*(Math.PI/180),F=Math.abs(P*Math.sin(z)),D=P*Math.cos(z),X=u.width_ft||20;if(F<=X&&D>=0&&D<=v)return{inBuffer:!0,edgeLabel:c.label,bufferType:u.type}}return{inBuffer:!1,edgeLabel:null,bufferType:null}}const Tg=Object.freeze(Object.defineProperty({__proto__:null,calculateEdgeTreeCount:u1,calculateTotalTreeCount:h8,filterTreesAwayFromEntryRoads:p8,findNearestTree:g8,generateAllTreePositions:u8,generateTreeId:pT,generateTreePositionsAlongEdge:gT,getTreeColor:m8,getTreeIcon:xT,isPointInBufferZone:x8},Symbol.toStringTag,{value:"Module"})),C2=[{value:"perimeter_screen",label:"Perimeter Screen",description:"Dense evergreen hedge or shrub wall providing visual privacy screening between properties—typically required by zoning to buffer industrial/commercial uses from residential areas.",color:"#166534"},{value:"setback_landscape",label:"Setback Landscape",description:"Fills the setback zone with grass/lawn (replaces orange setback color). Enable on any edge to turn the entire setback area green.",color:"#86efac"},{value:"tree_line",label:"Tree Line",description:"Row of individual trees planted at regular intervals along an edge—often deciduous shade trees or evergreens for wind breaks.",color:"#15803d"},{value:"bioswale",label:"Bioswale",description:"Vegetated drainage channel designed to collect, slow, and filter stormwater runoff naturally—a green infrastru
761cture alternative to storm drains.",color:"#38bdf8"}],_8=[{value:"sparse",label:"Sparse"},{value:"moderate",label:"Moderate"},{value:"dense",label:"Dense"}],y8=[{value:"deciduous",label:"Deciduous",icon:"🌳"},{value:"evergreen",label:"Evergreen",icon:"🌲"},{value:"palm",label:"Palm",icon:"🌴"},{value:"shrub",label:"Shrub",icon:"🌿"},{value:"custom_3d",label:"3D Model",icon:"📦"}];function v8({overlay:t,onUpdate:s,isUpdating:n,onStartEdgeSelection:a,onCancelEdgeSelection:l,edgeSelectionMode:c=!1,treeEditMode:u="none",onTreeEditModeChange:i}){var qt,ft,Fe;const{data:_}=cS("tree"),j=(qt=t.style)==null?void 0:qt.landscapeBuffers,y={enabled:!1,width_ft:20,type:"perimeter_screen",density:"moderate",tree_spacing_ft:25,tree_height_ft:30,tree_species:"deciduous",canopy_diameter_ft:15},[x,v]=k.useState(j||{}),[C,P]=k.useState(20),[I,z]=k.useState("perimeter_screen"),[F,D]=k.useState("moderate"),[X,K]=k.useState(25),[te,J]=k.useState(30),[H,O]=k.useState("deciduous"),[q,W]=k.useState(15),[Q,Z]=k.useState(""),oe=k.useMemo(()=>!t.geometry||t.geometry.length<3?[]:mu(t.geometry),[t.geometry]);k.useEffect(()=>{var Qe;const fe=(Qe=t.style)==null?void 0:Qe.landscapeBuffers;fe&&v(fe)},[(ft=t.style)==null?void 0:ft.landscapeBuffers]);const ce=Object.values(x).some(fe=>fe.enabled),ae=(fe,Qe)=>{var _t;const ht={...x,[fe]:{...y,...x[fe],enabled:Qe,width_ft:C,type:I,density:F,...I==="tree_line"&&{tree_spacing_ft:X,tree_height_ft:te,tree_species:H,canopy_diameter_ft:q,...H==="custom_3d"&&Q&&{custom_model_id:Q,custom_model_url:(_t=_==null?void 0:_.find(He=>He.id===Q))!=null&&_t.file_path?Db(_.find(He=>He.id===Q).file_path):void 0}}}};v(ht),Ee(ht)},ie=(fe,Qe)=>{const ht={...x,[fe]:{...y,...x[fe],width_ft:Qe}};v(ht),Ee(ht)},de=(fe,Qe)=>{const ht={...x,[fe]:{...y,...x[fe],tree_spacing_ft:Qe}};v(ht),Ee(ht)},ge=()=>{const fe={};oe.forEach(Qe=>{var ht;fe[Qe.label]={enabled:!0,width_ft:C,type:I,density:F,...I==="tree_line"&&{tree_spacing_ft:X,tree_height_ft:te,tree_species:H,canopy_diameter_ft:q,...H==="custom_3d"&&Q&&{custom_model_id:Q,custom_model_url:(ht=_==null?void 0:_.find(_t=>_t.id===Q))!=null&&ht.file_path?Db(_.find(_t=>_t.id===Q).file_path):void 0}}}}),v(fe),Ee(fe),Ve.success("Applied buffer to all edges")},We=()=>{v({}),Ee({}),Ve.success("Cleared all buffers")},Ee=fe=>{s({style:{...t.style||{},landscapeBuffers:fe}})},ve=k.useMemo(()=>{let fe=0;return oe.forEach(Qe=>{var ht;(ht=x[Qe.label])!=null&&ht.enabled&&(fe+=Qe.lengthFt||0)}),fe},[oe,x]),we=k.useMemo(()=>{let fe=0;return oe.forEach(Qe=>{const ht=x[Qe.label];if(ht!=null&&ht.enabled&&ht.type==="tree_line"){const _t=ht.tree_spacing_ft||X;fe+=u1(Qe.lengthFt||0,_t)}}),fe},[oe,x,X]),Ze=k.useMemo(()=>Object.values(x).some(fe=>fe.enabled&&fe.type==="tree_line"),[x]),ke=k.useMemo(()=>{var Qe,ht;const fe=t==null?void 0:t.style;return{deletedTreeIds:((Qe=fe==null?void 0:fe.treeModifications)==null?void 0:Qe.deletedTreeIds)||[],addedTrees:((ht=fe==null?void 0:fe.treeModifications)==null?void 0:ht.addedTrees)||[]}},[t==null?void 0:t.style]),ze=ke.addedTrees.length,Ke=ke.deletedTreeIds.length,dt=()=>{s({style:{...t.style||{},treeModifications:{...ke,addedTrees:[]}}}),Ve.success("Cleared all custom trees")},Re=()=>{s({style:{...t.style||{},treeModifications:{...ke,deletedTreeIds:[]}}}),Ve.success("Restored all deleted trees")};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3 p-3 bg-muted/50 rounded-lg border",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bx,{className:"w-4 h-4 text-primary"}),e.jsx(B,{className:"text-sm font-medium",children:"Buffer Settings"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Landscape buffers for perimeter screening and setback landscaping."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Default Width"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[C," ft"]})]}),e.jsx(Ca,{value:[C],min:5,max:50,step:5,onValueChange:([fe])=>P(fe),disabled:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Type"}),e.jsxs(rt,{value:I,onValueChange:z,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:C2.map(fe=>e.jsx(le,{value:fe.value,className:"text-xs",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:fe.color}}),fe.label]})},fe.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Density"}),e.jsxs(rt,{value:F,onValueChange:D,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:_8.map(fe=>e.jsx(le,{value:fe.value,className:"text-xs",children:fe.label},fe.value))})]})]})]}),I&&e.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:(Fe=C2.find(fe=>fe.value===I))==null?void 0:Fe.description}),I==="tree_line"&&e.jsxs("div",{className:"space-y-3 p-3 mt-2 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qy,{className:"w-4 h-4 text-primary"}),e.jsx(B,{className:"text-sm font-medium",children:"Tree Configuration"})]}),Ze&&i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Edit Mode"}),e.jsx(kt,{checked:u!=="none",onCheckedChange:fe=>{i(fe?"add":"none"),fe&&Ve.info("Tree Edit Mode ON: Click map to add trees, Shift+Click to delete")},disabled:n})]})]}),u!=="none"&&e.jsxs("div",{className:"flex items-center justify-between p-2 bg-emerald-500/20 rounded-md border border-emerald-500/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q1,{className:"w-4 h-4 text-emerald-600"}),e.jsx("span",{className:"text-xs font-medium text-emerald-700",children:u==="add"?"Click to add trees":"Click to delete trees"})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(Le,{variant:u==="add"?"default":"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>i==null?void 0:i("add"),children:[e.jsx(tr,{className:"w-3 h-3 mr-1"}),"Add"]}),e.jsxs(Le,{variant:u==="delete"?"destructive":"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>i==null?void 0:i("delete"),children:[e.jsx(wr,{className:"w-3 h-3 mr-1"}),"Delete"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Spacing"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(be,{type:"number",value:X,onChange:fe=>K(parseFloat(fe.target.value)||25),className:"h-7 text-xs w-16",min:10,max:100,disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"ft"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Height"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(be,{type:"number",value:te,onChange:fe=>J(parseFloat(fe.target.value)||30),className:"h-7 text-xs w-16",min:5,max:80,disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"ft"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Species"}),e.jsxs(rt,{value:H,onValueChange:fe=>O(fe),children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:y8.map(fe=>e.jsx(le,{value:fe.value,className:"text-xs",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{children:fe.icon}),e.jsx("span",{children:fe.label})]})},fe.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Canopy Ø"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(be,{type:"number",value:q,onChange:fe=>W(parseFloat(fe.target.value)||15),className:"h-7 text-xs w-16",min:5,max:40,disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"ft"})]})]})]}),H==="custom_3d"&&e.jsxs("div",{className:"space-y-2 mt-3 p-2 bg-violet-500/10 rounded-lg border border-violet-500/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cm,{className:"w-4 h-4 text-violet-500"}),e.jsx(B,{className:"text-xs font-medium",children:"3D Model"})]}),e.jsxs(rt,{value:Q,onValueChange:Z,children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{placeholder:"Select a 3D tree model..."})}),e.jsx(ot,{children:_&&_.length>0?_.map(fe=>e.jsx(le,{value:fe.id,className:"text-xs",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(cm,{className:"w-3 h-3 text-violet-500"}),fe.name]})},fe.id)):e.jsx(le,{value:"_none",disabled:!0,className:"text-xs text-muted-foreground",children:"No 3D tree models uploaded"})})]}),(!_||_.length===0)&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Upload tree models via Menu → 3D Models"})]}),(ze>0||Ke>0)&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground border-t border-border/50 pt-2",children:[ze>0&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(Mt,{variant:"secondary",className:"text-[10px]",children:["+",ze," added"]}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:dt,title:"Clear all added trees",children:e.jsx(mh,{className:"w-3 h-3"})})]}),Ke>0&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:["-",Ke," removed"]}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:Re,title:"Restore all deleted trees",children:e.jsx(zf,{className:"w-3 h-3"})})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(Le,{variant:"default",size:"sm",className:"flex-1 gap-1",onClick:ge,disabled:n,children:[e.jsx(tr,{className:"w-3 h-3"}),"Apply to All Edges"]}),ce&&e.jsx(Le,{variant:"outline",size:"sm",onClick:We,disabled:n,children:e.jsx(wr,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs font-medium",children:"Edge Configuration"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Toggle buffers on/off per edge. Labels match the setback edge markers (F, R, S1, S2)."}),e.jsx("div",{className:"space-y-2",children:oe.map(fe=>{const Qe=x[fe.label]||y,ht=Qe.enabled,_t=Qe.type==="tree_line",He=ht&&_t?u1(fe.lengthFt||0,Qe.tree_spacing_ft||X):0;return e.jsxs("div",{className:`p-2 rounded-lg border transition-colors ${ht?"bg-primary/10 border-primary/30":"bg-muted/30"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mt,{variant:ht?"default":"outline",className:"w-8 h-6 flex items-center justify-center text-xs font-mono",children:fe.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:fe.lengthFt?`${Math.round(fe.lengthFt)} ft`:""}),ht&&_t&&He>0&&e.jsxs("span",{className:"text-xs text-primary flex items-center gap-0.5",children:[xT(Qe.tree_species||"deciduous")," ~",He]})]}),e.jsx(kt,{checked:ht,onCheckedChange:as=>ae(fe.label,as),disabled:n})]}),ht&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-border/50 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground w-12",children:"Width:"}),e.jsx(be,{type:"number",value:Qe.width_ft,onChange:as=>ie(fe.label,parseFloat(as.target.value)||20),className:"h-6 text-xs w-16",disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"ft"})]}),_t&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground w-12",children:"Spacing:"}),e.jsx(be,{type:"number",value:Qe.tree_spacing_ft||X,onChange:as=>de(fe.label,parseFloat(as.target.value)||25),className:"h-6 text-xs w-16",disabled:n}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"ft"})]})]})]},fe.label)})})]}),ce&&e.jsxs("div",{className:"p-2 bg-primary/10 rounded-lg border border-primary/20 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(ji,{className:"w-3 h-3"}),"Total Buffer Length"]}),e.jsxs(Mt,{variant:"secondary",className:"font-mono",children:[Math.round(ve).toLocaleStr
761ing()," ft"]})]}),Ze&&we>0&&e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(qy,{className:"w-3 h-3"}),"Total Trees"]}),e.jsxs(Mt,{variant:"default",className:"font-mono",children:["~",we+ze-Ke]})]})]})]})}const np=[{value:"retention_pond",label:"Retention Pond",icon:gp,description:"Permanent water feature",color:"#3b82f6"},{value:"detention_basin",label:"Detention Basin",icon:Wm,description:"Dry basin, fills during storms",color:"#22c55e"},{value:"bioswale",label:"Bioswale",icon:Hy,description:"Vegetated drainage channel",color:"#22c55e"},{value:"underground",label:"Underground",icon:Fu,description:"Below-grade storage system",color:"#8b5cf6"},{value:"infiltration_bed",label:"Infiltration Bed",icon:Kc,description:"Subsurface gravel percolation",color:"#a78bfa"},{value:"rain_garden",label:"Rain Garden",icon:Hy,description:"Landscaped depression with plantings",color:"#4ade80"}],Qv={retention_pond:"#3b82f6",detention_basin:"#22c55e",bioswale:"#22c55e",underground:"#8b5cf6",infiltration_bed:"#a78bfa",rain_garden:"#4ade80"};function b8(t){return{ftPerDegLon:364e3*Math.cos(t*Math.PI/180),ftPerDegLat:364e3}}function S2(t,s,n,a,l,c,u=24){const i=[];for(let _=0;_<u;_++){const j=2*Math.PI*_/u,y=n*Math.cos(j),x=a*Math.sin(j);i.push({lat:t+x/c,lng:s+y/l})}return i}function E2(t,s,n,a,l,c){const u=n/2/l,i=a/2/c;return[{lat:t-i,lng:s-u},{lat:t-i,lng:s+u},{lat:t+i,lng:s+u},{lat:t+i,lng:s-u}]}function j8({overlay:t,childOverlays:s=[],onUpdate:n,isUpdating:a}){var J;const l=ym(),c=Sp(),u=pu(),i=k.useMemo(()=>s.filter(H=>H.layer_type==="stormwater"),[s]),[_,j]=k.useState("detention_basin"),[y,x]=k.useState(4),[v,C]=k.useState(!1),P=k.useMemo(()=>{const H=t.geometry;if(!H||!Array.isArray(H)||H.length<3)return null;try{const O=H.map(oe=>[oe.lng,oe.lat]);O.push(O[0]);const q=Xn([O]),W=Yo(q),Z=zr(q)*10.764;return{centerLat:W.geometry.coordinates[1],centerLng:W.geometry.coordinates[0],areaSqFt:Z}}catch{return null}},[t.geometry]),I=async()=>{if(!P){Ve.error("Cannot add stormwater area - parent overlay has no valid geometry");return}C(!0);try{const H=np.find(ae=>ae.value===_),O=Qv[_]||"#3b82f6",q=Math.min(P.areaSqFt*.1,1e4),W=Math.round(q*y*7.48),{ftPerDegLon:Q,ftPerDegLat:Z}=b8(P.centerLat),oe=Math.sqrt(q/Math.PI);let ce;if(_==="bioswale"){const ae=Math.sqrt(q*4),ie=q/ae;ce=E2(P.centerLat,P.centerLng,ae,ie,Q,Z)}else if(_==="underground"||_==="infiltration_bed"){const ae=Math.sqrt(q);ce=E2(P.centerLat,P.centerLng,ae,ae,Q,Z)}else _==="rain_garden"?ce=S2(P.centerLat,P.centerLng,oe*1.3,oe*.7,Q,Z,24):ce=S2(P.centerLat,P.centerLng,oe*1.2,oe*.8,Q,Z,32);await l.mutateAsync({name:(H==null?void 0:H.label)||"Stormwater Area",type:"polygon",geometry:ce,layer_type:"stormwater",parent_overlay_id:t.id,is_visible:!0,custom_sqft:Math.round(q),style:{color:O,fillColor:O,fillOpacity:.4,weight:2,stormwaterConfig:{type:_,capacity_gallons:W,depth_ft:y}}}),Ve.success(`Added ${H==null?void 0:H.label}`,{description:"Drag to reposition, edit properties in the panel"})}catch(H){console.error("Error creating stormwater overlay:",H),Ve.error("Failed to create stormwater area")}finally{C(!1)}},z=async H=>{try{await c.mutateAsync(H),Ve.success("Stormwater area removed")}catch(O){console.error("Error deleting stormwater overlay:",O),Ve.error("Failed to remove stormwater area")}},F=async(H,O)=>{try{await u.mutateAsync({id:H,...O})}catch(q){console.error("Error updating stormwater overlay:",q)}},D=async(H,O)=>{await F(H,{is_visible:!O})},X=H=>{const O=np.find(W=>W.value===H);if(!O)return e.jsx(Kc,{className:"w-4 h-4"});const q=O.icon;return e.jsx(q,{className:"w-4 h-4"})},K=H=>H>=1e6?`${(H/1e6).toFixed(1)}M`:H>=1e3?`${(H/1e3).toFixed(0)}K`:H.toString(),te=k.useMemo(()=>i.reduce((H,O)=>
761{var W;const q=(W=O.style)==null?void 0:W.stormwaterConfig;return H+((q==null?void 0:q.capacity_gallons)||0)},0),[i]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3 p-3 bg-muted/50 rounded-lg border",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Kc,{className:"w-4 h-4 text-blue-500"}),e.jsx(B,{className:"text-sm font-medium",children:"Add Stormwater Feature"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Creates a stormwater polygon on your site. Drag to reposition after placing."}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:np.map(H=>{const O=H.icon,q=_===H.value;return e.jsxs("button",{onClick:()=>j(H.value),className:`p-2 rounded-lg border text-left transition-colors ${q?"bg-blue-500/10 border-blue-500":"bg-background hover:bg-muted"}`,disabled:a||v,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:H.color}}),e.jsx(O,{className:`w-4 h-4 ${q?"text-blue-500":"text-muted-foreground"}`}),e.jsx("span",{className:"text-xs font-medium",children:H.label})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:H.description})]},H.value)})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Default Depth"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[y," ft"]})]}),e.jsx(Ca,{value:[y],min:2,max:12,step:1,onValueChange:([H])=>x(H),disabled:a||v})]}),e.jsxs(Le,{onClick:I,size:"sm",className:"w-full gap-1",disabled:a||v||!P,children:[v?e.jsx(Va,{className:"w-3 h-3 animate-spin"}):e.jsx(tr,{className:"w-3 h-3"}),v?"Creating...":`Add ${(J=np.find(H=>H.value===_))==null?void 0:J.label}`]}),!P&&e.jsx("p",{className:"text-[10px] text-destructive text-center",children:"Parent overlay must have valid geometry"})]}),i.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs(B,{className:"text-xs font-medium",children:["Stormwater Areas (",i.length,")"]})}),e.jsx("div",{className:"space-y-2",children:i.map(H=>{var Q,Z;const O=((Q=H.style)==null?void 0:Q.stormwaterConfig)||{},q=O.type||"detention_basin";np.find(oe=>oe.value===q);const W=((Z=H.style)==null?void 0:Z.fillColor)||Qv[q]||"#3b82f6";return e.jsxs("div",{className:"p-3 rounded-lg border bg-background space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border",style:{backgroundColor:W}}),X(q),e.jsx("span",{className:"text-xs font-medium truncate max-w-[100px]",children:H.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>D(H.id,H.is_visible??!0),children:H.is_visible!==!1?e.jsx(kc,{className:"w-3.5 h-3.5"}):e.jsx(Wc,{className:"w-3.5 h-3.5"})}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>z(H.id),children:e.jsx(wr,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Capacity (gal)"}),e.jsx(be,{type:"number",value:O.capacity_gallons||0,onChange:oe=>F(H.id,{style:{...H.style||{},stormwaterConfig:{...O,capacity_gallons:parseFloat(oe.target.value)||0}}}),className:"h-7 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Depth (ft)"}),e.jsx(be,{type:"number",value:O.depth_ft||4,onChange:oe=>F(H.id,{style:{...H.style||{},stormwaterConfig:{...O,depth_ft:parseFloat(oe.target.value)||4}}}),className:"h-7 text-xs"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Type"}),e.jsxs(rt,{value:q,onValueChange:oe=>{var ie;const ce=Qv[oe]||W,ae=((ie=np.find(de=>de.value===oe))==null?void 0:ie.label)||H.name;F(H.id,{name:ae,style:{...H.style||{},color:ce,fillColor:ce,stormwaterConfig:{...O,type:oe}}})},children:[e.jsx(it,{className:"h-7 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:np.map(oe=>e.jsx(le,{value:oe.value,className:"text-xs",children:oe.label},oe.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted-foreground pt-1 border-t border-border/50",children:[e.jsx("span",{children:"Area:"}),e.jsx("span",{className:"font-mono",children:H.custom_sqft?`${H.custom_sqft.toLocaleStr
761ing()} sf`:"—"})]})]},H.id)})})]}),i.length>0&&e.jsx("div",{className:"p-2 bg-blue-500/10 rounded-lg border border-blue-500/20",children:e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Areas:"}),e.jsx(Mt,{variant:"secondary",className:"font-mono h-5",children:i.length})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Capacity:"}),e.jsxs(Mt,{variant:"secondary",className:"font-mono h-5",children:[K(te)," gal"]})]})]})}),i.length===0&&e.jsx("p",{className:"text-[10px] text-muted-foreground italic text-center py-2",children:"💡 Stormwater features manage runoff and meet municipal drainage requirements."})]})}const iy=[{id:"electric",label:"Electric",icon:Xd,color:"#eab308"},{id:"gas",label:"Gas",icon:Ff,color:"#f97316"},{id:"water",label:"Water",icon:Kc,color:"#3b82f6"},{id:"sewer",label:"Sewer",icon:t_,color:"#78716c"},{id:"telecom",label:"Telecom",icon:MS,color:"#a855f7"}],oy={electric:"#eab308",gas:"#f97316",water:"#3b82f6",sewer:"#78716c",telecom:"#a855f7",mixed:"#6366f1"};function w8(t){return{ftPerDegLon:364e3*Math.cos(t*Math.PI/180),ftPerDegLat:364e3}}function N8(t,s,n,a,l,c,u){const i=a-s,_=n-t,j=Math.sqrt(i*i+_*_);if(j===0)return[];const y=-_/j,x=i/j,v=l/2/c,C=l/2/u;return[{lat:t+x*C,lng:s+y*v},{lat:n+x*C,lng:a+y*v},{lat:n-x*C,lng:a-y*v},{lat:t-x*C,lng:s-y*v}]}function k8({overlay:t,childOverlays:s=[],onUpdate:n,isUpdating:a}){const l=ym(),c=Sp(),u=pu(),i=k.useMemo(()=>s.filter(H=>{var O;return H.layer_type==="utility_line"||((O=H.style)==null?void 0:O.corridorConfig)!==void 0}),[s]),[_,j]=k.useState(["electric"]),[y,x]=k.useState(20),[v,C]=k.useState(!0),[P,I]=k.useState(!1),z=k.useMemo(()=>{const H=t.geometry;if(!H||!Array.isArray(H)||H.length<3)return null;try{const O=H.map(de=>[de.lng,de.lat]);O.push(O[0]);const q=Xn([O]),W=Yo(q),Q=H.map(de=>de.lat),Z=H.map(de=>de.lng),oe=Math.min(...Q),ce=Math.max(...Q),ae=Math.min(...Z),ie=Math.max(...Z);return{centerLat:W.geometry.coordinates[1],centerLng:W.geometry.coordinates[0],minLat:oe,maxLat:ce,minLng:ae,maxLng:ie,width:ie-ae,height:ce-oe}}catch{return null}},[t.geometry]),F=async()=>{var H;if(!z){Ve.error("Cannot add corridor - parent overlay has no valid geometry");return}I(!0);try{let O=oy.mixed;_.length===1&&(O=oy[_[0]]||oy.mixed);const{ftPerDegLon:q,ftPerDegLat:W}=w8(z.centerLat),Q=z.width*.7,Z=i.length*.05*z.height,oe=N8(z.centerLat+Z,z.minLng+z.width*.15,z.centerLat+Z,z.maxLng-z.width*.15,y,q,W),ce=_.length===1?((H=iy.find(ae=>ae.id===_[0]))==null?void 0:H.label)||"Utility":`Multi-Utility (${_.length})`;await l.mutateAsync({name:`${ce} Corridor`,type:"polygon",geometry:oe,layer_type:"utility_line",parent_overlay_id:t.id,is_visible:!0,style:{color:O,fillColor:O,fillOpacity:v?.3:.5,weight:2,dashArray:v?"5, 5":void 0,corridorConfig:{utility_types:_,width_ft:y,is_underground:v}}}),Ve.success(`Added ${ce} Corridor`,{description:"Drag to reposition, edit properties in the panel"})}catch(O){console.error("Error creating corridor overlay:",O),Ve.error("Failed to create utility corridor")}finally{I(!1)}},D=async H=>{try{await c.mutateAsync(H),Ve.success("Utility corridor removed")}catch(O){console.error("Error deleting corridor overlay:",O),Ve.error("Failed to remove utility corridor")}},X=async(H,O)=>{try{await u.mutateAsync({id:H,...O})}catch(q){console.error("Error updating corridor overlay:",q)}},K=async(H,O)=>{await X(H,{is_visible:!O})},te=H=>{j(O=>O.includes(H)?O.filter(q=>q!==H):[...O,H])},J=H=>{const O=iy.find(W=>W.id===H);if(!O)return null;const q=O.icon;return e.jsx(q,{className:"w-3 h-3",style:{color:O.color}})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3 p-3 bg-muted/50 rounded-lg border",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(lm,{className:"w-4 h-4 text-indigo-500"}),e.jsx(B,{className:"text-sm font-medium",children:"Add Utility Corridor"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Creates a utility corridor on your site. Drag to reposition after placing."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Utility Types"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:iy.map(H=>{const O=H.icon,q=_.includes(H.id);return e.jsxs("div",{className:fs("flex items-center gap-2 p-2 rounded-md border cursor-pointer transition-colors",q?"bg-primary/10 border-primary":"hover:bg-muted"),onClick:()=>te(H.id),children:[e.jsx(Ux,{checked:q,className:"pointer-events-none"}),e.jsx(O,{className:"w-4 h-4",style:{color:H.color}}),e.jsx("span",{className:"text-sm",children:H.label})]},H.id)})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Corridor Width"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:[y," ft"]})]}),e.jsx(be,{type:"number",value:y,onChange:H=>x(parseFloat(H.target.value)||10),className:"h-8 text-sm",min:5,max:100,disabled:a||P})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-sm",children:"Underground Installation"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Utilities run below grade (dashed line)"})]}),e.jsx(kt,{checked:v,onCheckedChange:C,disabled:a||P})]}),e.jsxs(Le,{onClick:F,size:"sm",className:"w-full gap-1",disabled:a||P||!z||_.length===0,children:[P?e.jsx(Va,{className:"w-3 h-3 animate-spin"}):e.jsx(tr,{className:"w-3 h-3"}),P?"Creating...":"Add Utility Corridor"]}),!z&&e.jsx("p",{className:"text-[10px] text-destructive text-center",children:"Parent overlay must have valid geometry"}),_.length===0&&e.jsx("p",{className:"text-[10px] text-destructive text-center",children:"Select at least one utility type"})]}),i.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs(B,{className:"text-xs font-medium",children:["Utility Corridors (",i.length,")"]})}),e.jsx("div",{className:"space-y-2",children:i.map(H=>{var Q,Z;const O=((Q=H.style)==null?void 0:Q.corridorConfig)||{},q=O.utility_types||["electric"],W=((Z=H.style)==null?void 0:Z.fillColor)||oy.mixed;return e.jsxs("div",{className:"p-3 rounded-lg border bg-background space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border",style:{backgroundColor:W}}),e.jsx(lm,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium truncate max-w-[100px]",children:H.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Mt,{variant:O.is_underground?"secondary":"outline",className:"text-[10px]",children:O.is_underground?"UG":"OH"}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>K(H.id,H.is_visible??!0),children:H.is_visible!==!1?e.jsx(kc,{className:"w-3.5 h-3.5"}):e.jsx(Wc,{className:"w-3.5 h-3.5"})}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>D(H.id),children:e.jsx(wr,{className:"w-3.5 h-3.5"})})]})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:q.map(oe=>{var ce;return e.jsxs("span",{className:"flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-muted",children:[J(oe),(ce=iy.find(ae=>ae.id===oe))==null?void 0:ce.label]},oe)})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",value:O.width_ft||20,onChange:oe=>X(H.id,{style:{...H.style||{},corridorConfig:{...O,width_ft:parseFloat(oe.target.value)||20}}}),className:"h-7 text-xs",min:5,max:100})]}),e.jsx("div",{className:"flex items-end pb-1",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kt,{checked:O.is_underground??!0,onCheckedChange:oe=>X(H.id,{style:{...H.style||{},dashArray:oe?"5, 5":void 0,fillOpacity:oe?.3:.5,corridorConfig:{...O,is_underground:oe}}})}),e.jsx(B,{className:"text-[10px]",children:"Underground"})]})})]})]},H.id)})})]}),i.length===0&&e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(lm,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No utility corridors on this site"}),e.jsx("p",{className:"text-xs mt-1",children:"Add corridors for electric, gas, water, sewer, or telecom"})]})]})}const C8=3280.84;function dh(t,s,n){const a=s/C8;return On(us(t),a,n,{units:"kilometers"}).geometry.coordinates}function S8(t){if(t.length<3){const n=t.reduce((l,c)=>l+c[0],0),a=t.reduce((l,c)=>l+c[1],0);return[n/t.length,a/t.length]}const s=[...t,t[0]];try{const n=Xn([s]);return Yo(n).geometry.coordinates}catch{const n=t.reduce((l,c)=>l+c[0],0),a=t.reduce((l,c)=>l+c[1],0);return[n/t.length,a/t.length]}}function Jp(t,s,n,a){const l=s/2,c=n/2,u=a,i=(a+90)%360,_=(a+180)%360,j=(a+270)%360,y=dh(t,c,u),x=dh(t,c,_),v=dh(y,l,j),C=dh(y,l,i),P=dh(x,l,j),I=dh(x,l,i);return[v,C,I,P,v]}function Uv(t,s,n=8){const a=s/2,l=[];for(let c=0;c<n;c++){const u=c*360/n;l.push(dh(t,a,u))}return l.push(l[0]),l}function E8(t,s,n=0){if(!t||t.length<3||!s||s.length===0)return{type:"FeatureCollection",features:[]};const a=t.map(u=>[u.lng,u.lat]),l=S8(a),c=[];for(const u of s){const i=[u.position_lng??l[0],u.position_lat??l[1]],_=u.rotation_deg??0,j=u.support_height_ft||8,y=u.support_width_ft||4,x=u.pole_diameter_ft||1,v=u.placard_width_ft||10,C=u.placard_height_ft||6,P=u.placard_depth_ft||1,I=n,z=n+j,F=z,D=F+C;if(u.support_type==="block_base"){const H=u.base_height_ft??Math.min(j,3),O=Jp(i,v,y,_);c.push({type:"Feature",geometry:{type:"Polygon",coordinates:[O]},properties:{signId:`${u.id}-support`,signName:u.name,featureType:"support",supportType:"block_base",baseHeight:I,topHeight:I+H,color:u.frame_color||"#4a5568"}})}else if(u.support_type==="single_pole"){const H=Uv(i,x,8);c.push({type:"Feature",geometry:{type:"Polygon",coordinates:[H]},properties:{signId:`${u.id}-support`,signName:u.name,featureType:"support",supportType:"single_pole",baseHeight:I,topHeight:z,color:u.frame_color||"#4a5568"}})}else{const H=v/2-.5,O=(_+270)%360,q=(_+90)%360,W=dh(i,H,O),Q=dh(i,H,q),Z=x||.75;c.push({type:"Feature",geometry:{type:"Polygon",coordinates:[Uv(W,Z,8)]},properties:{signId:`${u.id}-support-left`,signName:u.name,featureType:"support",supportType:"pillars",baseHeight:I,topHeight:z,color:u.frame_color||"#4a5568"}}),c.push({type:"Feature",geometry:{type:"Polygon",coordinates:[Uv(Q,Z,8)]},properties:{signId:`${u.id}-support-right`,signName:u.name,featureType:"support",supportType:"pillars",baseHeight:I,topHeight:z,color:u.frame_color||"#4a5568"}})}const X=u.tenants||[],K=u.placard_columns??1,te=u.connector_height_ft??.25,J=.25;if(console.log(`[PylonSignage] Sign "${u.name}": tenants array =`,JSON.stringify(X)),console.log(`[PylonSignage] ${X.length} tenants, numColumns=${K}`),X.length===0){const H=Jp(i,v,P,_);c.push({type:"Feature",geometry:{type:"Polygon",coordinates:[H]},properties:{signId:`${u.id}-placard`,signName:u.name,featureType:"placard",baseHeight:F,topHeight:D,color:u.background_color||"#ffffff"}})}else{const H=[];for(let Q=0;Q<K;Q++)H[Q]=[];
761X.forEach((Q,Z)=>{const oe=Math.min(Q.column??0,K-1);H[oe].push({tenant:Q,tenantIdx:Z})});const O=(v-(K-1)*J)/K,q=(_+270)%360,W=(_+90)%360;for(let Q=0;Q<K;Q++){const Z=H[Q];let oe=0;if(K===2){const Ee=O/2+J/2;oe=Ee}const ce=K===1?i:dh(i,oe,Q===0?q:W),ie=Math.max(0,Z.length-1)*te,de=C-ie,ge=Z.reduce((Ee,{tenant:ve})=>Ee+(ve.size_weight??1),0)||1;let We=0;Z.forEach(({tenant:Ee,tenantIdx:ve})=>{const Ze=(Ee.size_weight??1)/ge*de,ke=F+We,ze=ke+Ze,Ke=(ke+ze)/2,dt=Jp(ce,O,P,_);if(c.push({type:"Feature",geometry:{type:"Polygon",coordinates:[dt]},properties:{signId:`${u.id}-placard-${ve}`,signName:Ee.logo_name||`Panel ${ve+1}`,featureType:"placard",baseHeight:ke,topHeight:ze,color:u.background_color||"#ffffff"}}),Z.findIndex(ht=>ht.tenantIdx===ve)<Z.length-1){const ht=u.connector_width_pct??15,_t=u.connector_depth_pct??80,He=O*(ht/100),as=P*(_t/100),vt=ze,Xe=ze+te,Ce=Jp(ce,He,as,_);c.push({type:"Feature",geometry:{type:"Polygon",coordinates:[Ce]},properties:{signId:`${u.id}-connector-${Q}-${ve}`,signName:`Connector ${ve+1}`,featureType:"connector",baseHeight:vt,topHeight:Xe,color:u.frame_color||"#4a5568"}})}const qt=_,ft=P/2+.1,Fe=dh(ce,ft,qt),fe=O*.9,Qe=Ze*.85;if(c.push({type:"Feature",geometry:{type:"Polygon",coordinates:[Jp(Fe,fe,.1,_)]},properties:{signId:`${u.id}-logo-front-${ve}`,signName:Ee.logo_name||`Tenant ${ve+1}`,featureType:"logo_face",isLogoFace:!0,isFrontFace:!0,tenantId:Ee.id,tenantIndex:ve,logoId:Ee.logo_id,logoUrl:Ee.logo_url,logoName:Ee.logo_name,baseHeight:Ke-Qe/2,topHeight:Ke+Qe/2,color:"#ffffff",outwardBearingDeg:qt,logoWidthFt:fe,logoHeightFt:Qe,centerLng:Fe[0],centerLat:Fe[1]}}),u.double_sided){const ht=(_+180)%360,_t=dh(ce,ft,ht);c.push({type:"Feature",geometry:{type:"Polygon",coordinates:[Jp(_t,fe,.1,ht)]},properties:{signId:`${u.id}-logo-back-${ve}`,signName:Ee.logo_name||`Tenant ${ve+1}`,featureType:"logo_face",isLogoFace:!0,isFrontFace:!1,tenantId:Ee.id,tenantIndex:ve,logoId:Ee.logo_id,logoUrl:Ee.logo_url,logoName:Ee.logo_name,baseHeight:Ke-Qe/2,topHeight:Ke+Qe/2,color:"#ffffff",outwardBearingDeg:ht,logoWidthFt:fe,logoHeightFt:Qe,centerLng:_t[0],centerLat:_t[1]}})}We+=Ze+te})}}}return{type:"FeatureCollection",features:c}}function P8(t,s="Pylon Sign"){return{id:t,name:s,type:"pylon",support_type:"pillars",support_height_ft:10,support_width_ft:4,pole_diameter_ft:.75,placard_width_ft:12,placard_height_ft:8,placard_depth_ft:1.5,placard_columns:1,double_sided:!0,connector_height_ft:.25,connector_width_pct:15,connector_depth_pct:80,tenants:[],background_color:"#ffffff",frame_color:"#4a5568",illuminated:!0,illumination_type:"internal",rotation_deg:0}}const P2=[{id:"pillars",label:"Dual Pillars",icon:Z1,description:"Two columns flanking sign"},{id:"single_pole",label:"Single Pole",icon:t_,description:"Central support pole"},{id:"block_base",label:"Block Base",icon:Il,description:"Low masonry base"}],T8=[{id:"monument",label:"Monument"},{id:"pylon",label:"Pylon"},{id:"directional",label:"Directional"},{id:"wayfinding",label:"Wayfinding"}];function L8({overlay:t,onUpdate:s,onStartSignPlacement:n,onCancelSignPlacement:a,signPlacementMode:l=!1,placingSignId:c=null}){const u=t.style||{},i=W=>Array.isArray(W)?W:[],_=W=>i(W==null?void 0:W.tenants),j=i(u.monument_signs).map(W=>({...W,tenants:_(W)})),[y,x]=k.useState(null),[v,C]=k.useState(""),{data:P=[]}=OP(),I=P.filter(W=>W.name.toLowerCase().includes(v.toLowerCase())),z=W=>{s({style:{...u,monument_signs:W}})},F=()=>{const W=P8(crypto.randomUUID(),`Pylon Sign ${j.length+1}`);z([...j,W]),x(W.id)},D=(W,Q)=>{z(j.map(Z=>Z.id===W?{...Z,...Q}:Z))},X=W=>{z(j.filter(Q=>Q.id!==W)),y===W&&x(null)},K=W=>{const Q=j.find(ce=>ce.id===W);if(!Q)return;const Z=_(Q),oe={id:crypto.randomUUID(),position_index:Z.length};D(W,{tenants:[...Z,oe]})},te=(W,Q,Z)=>{const oe=j.find(ae=>ae.id===W);if(!oe)return;const ce=_(oe);D(W,{tenants:ce.map(ae=>ae.id===Q?{...ae,...Z}:ae)})},J=(W,Q)=>{const Z=j.find(ae=>ae.id===W);if(!Z)return;const ce=_(Z).filter(ae=>ae.id!==Q).map((ae,ie)=>({...ae,position_index:ie}));D(W,{tenants:ce})},H=(W,Q,Z)=>{const oe=j.find(ge=>ge.id===W);if(!oe)return;const ce=_(oe),ae=ce.findIndex(ge=>ge.id===Q);if(ae===-1)return;const ie=Z==="up"?ae-1:ae+1;if(ie<0||ie>=ce.length)return;const de=[...ce];[de[ae],de[ie]]=[de[ie],de[ae]],de.forEach((ge,We)=>ge.position_index=We),D(W,{tenants:de})},O=(W,Q,Z)=>
761{te(W,Q,{logo_id:Z.id,logo_url:Z.logo_url,logo_name:Z.name})},q=W=>{const Q=P2.find(Z=>Z.id===W);return(Q==null?void 0:Q.icon)||Z1};return e.jsxs("div",{className:"space-y-3",children:[j.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(Ng,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No pylon signage defined"}),e.jsx("p",{className:"text-xs mt-1",children:"Add freestanding monument or pylon signs"})]}):e.jsx("div",{className:"space-y-2",children:j.map(W=>{var oe,ce;q(W.support_type);const Q=y===W.id,Z=_(W);return e.jsxs("div",{className:"border rounded-lg bg-muted/30 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>x(Q?null:W.id),children:[e.jsx(Ng,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium flex-1 truncate",children:W.name}),e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:[Z.length," tenant",Z.length!==1?"s":""]}),W.double_sided&&e.jsx(Mt,{variant:"secondary",className:"text-[10px]",children:"2-sided"}),W.illuminated&&e.jsx(gh,{className:"w-3.5 h-3.5 text-yellow-500"}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:ae=>{ae.stopPropagation(),X(W.id)},children:e.jsx(wr,{className:"w-3 h-3 text-destructive"})})]}),Q&&e.jsxs("div",{className:"p-3 pt-0 space-y-4 border-t",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Sign Name"}),e.jsx(be,{value:W.name,onChange:ae=>D(W.id,{name:ae.target.value}),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Sign Type"}),e.jsxs(rt,{value:W.type,onValueChange:ae=>D(W.id,{type:ae}),children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:T8.map(ae=>e.jsx(le,{value:ae.id,children:ae.label},ae.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs font-medium",children:"Support Structure"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:P2.map(ae=>{const ie=ae.icon;return e.jsxs("button",{onClick:()=>D(W.id,{support_type:ae.id}),className:`p-2 rounded-md border text-center transition-colors ${W.support_type===ae.id?"border-primary bg-primary/10":"border-border hover:bg-muted"}`,children:[e.jsx(ie,{className:"w-5 h-5 mx-auto mb-1"}),e.jsx("span",{className:"text-[10px] block",children:ae.label})]},ae.id)})})]}),e.jsxs("div",{className:`grid gap-3 ${W.support_type==="block_base"?"grid-cols-3":"grid-cols-2"}`,children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Support Height (ft)"}),e.jsx(be,{type:"number",value:W.support_height_ft,onChange:ae=>D(W.id,{support_height_ft:parseFloat(ae.target.value)||0}),className:"h-8 text-sm",min:1,max:30})]}),W.support_type==="single_pole"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Pole Diameter (ft)"}),e.jsx(be,{type:"number",value:W.pole_diameter_ft||1,onChange:ae=>D(W.id,{pole_diameter_ft:parseFloat(ae.target.value)||1}),className:"h-8 text-sm",min:.5,max:3,step:.25})]}):W.support_type==="block_base"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Base Depth (ft)"}),e.jsx(be,{type:"number",value:W.support_width_ft||4,onChange:ae=>D(W.id,{support_width_ft:parseFloat(ae.target.value)||4}),className:"h-8 text-sm",min:2,max:20})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Base Height (ft)"}),e.jsx(be,{type:"number",value:W.base_height_ft||2,onChange:ae=>D(W.id,{base_height_ft:parseFloat(ae.target.value)||2}),className:"h-8 text-sm",min:.5,max:6,step:.5})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Pillar Spacing (ft)"}),e.jsx(be,{type:"number",value:W.support_width_ft||4,onChange:ae=>D(W.id,{support_width_ft:parseFloat(ae.target.value)||4}),className:"h-8 text-sm",min:2,max:20})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs font-medium",children:"Sign Face (Placard)"}),e.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (ft)"}),e.jsx(be,{type:"number",value:W.placard_width_ft,onChange:ae=>D(W.id,{placard_width_ft:parseFloat(ae.target.value)||10}),className:"h-7 text-sm",min:4,max:30})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Height (ft)"}),e.jsx(be,{type:"number",value:W.placard_height_ft,onChange:ae=>D(W.id,{placard_height_ft:parseFloat(ae.target.value)||6}),className:"h-7 text-sm",min:2,max:20})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Depth (ft)"}),e.jsx(be,{type:"number",value:W.placard_depth_ft,onChange:ae=>D(W.id,{placard_depth_ft:parseFloat(ae.target.value)||1}),className:"h-7 text-sm",min:.5,max:3,step:.25})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Columns"}),e.jsxs(rt,{value:String(W.placard_columns??1),onValueChange:ae=>D(W.id,{placard_columns:parseInt(ae)}),children:[e.jsx(it,{className:"h-7 text-sm",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"1",children:"1"}),e.jsx(le,{value:"2",children:"2"})]})]})]})]})]}),Z.length>=2&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs font-medium",children:"Panel Connectors"}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Height (ft)"}),e.jsx(be,{type:"number",value:W.connector_height_ft??.25,onChange:ae=>D(W.id,{connector_height_ft:parseFloat(ae.target.value)||.25}),className:"h-7 text-sm",min:.1,max:3,step:.1})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Width (%)"}),e.jsx(be,{type:"number",value:W.connector_width_pct??15,onChange:ae=>D(W.id,{connector_width_pct:parseFloat(ae.target.value)||15}),className:"h-7 text-sm",min:5,max:100,step:5})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Depth (%)"}),e.jsx(be,{type:"number",value:W.connector_depth_pct??80,onChange:ae=>D(W.id,{connector_depth_pct:parseFloat(ae.target.value)||80}),className:"h-7 text-sm",min:20,max:100,step:5})]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Controls the size of the frame c
761onnecting panels"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-xs flex items-center gap-1.5",children:[e.jsx(D3,{className:"w-3.5 h-3.5"}),"Rotation"]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[W.rotation_deg||0,"°"]})]}),e.jsx(Ca,{value:[W.rotation_deg||0],onValueChange:([ae])=>D(W.id,{rotation_deg:ae}),min:0,max:360,step:5,className:"w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-xs font-medium flex items-center gap-1.5",children:[e.jsx(ji,{className:"w-3.5 h-3.5"}),"Location"]}),W.position_lat&&W.position_lng?e.jsxs(Mt,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(cl,{className:"w-2.5 h-2.5"}),"Placed"]}):e.jsx(Mt,{variant:"secondary",className:"text-[10px]",children:"Using site center"})]}),l&&c===W.id?e.jsxs("div",{className:"p-2 rounded-md border border-primary bg-primary/10 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-primary",children:[e.jsx(tN,{className:"w-4 h-4 animate-pulse"}),e.jsx("span",{children:"Click on the map to place sign"})]}),e.jsx(Le,{variant:"outline",size:"sm",className:"w-full h-7 text-xs",onClick:()=>a==null?void 0:a(),children:"Cancel"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full h-7 text-xs gap-1.5",onClick:()=>n==null?void 0:n(W.id),disabled:!n,children:[e.jsx(tN,{className:"w-3 h-3"}),W.position_lat?"Reposition on Map":"Place on Map"]}),W.position_lat&&W.position_lng&&e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[10px]",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Latitude"}),e.jsx(be,{type:"number",value:((oe=W.position_lat)==null?void 0:oe.toFixed(6))||"",onChange:ae=>D(W.id,{position_lat:parseFloat(ae.target.value)||void 0}),className:"h-6 text-[10px]",step:1e-6})]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Longitude"}),e.jsx(be,{type:"number",value:((ce=W.position_lng)==null?void 0:ce.toFixed(6))||"",onChange:ae=>D(W.id,{position_lng:parseFloat(ae.target.value)||void 0}),className:"h-6 text-[10px]",step:1e-6})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(B,{className:"text-xs font-medium flex items-center gap-1.5",children:[e.jsx(yl,{className:"w-3.5 h-3.5"}),"Tenant Logos"]}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:"Add multiple tenants for retail center signs"})]}),e.jsxs(Le,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>K(W.id),children:[e.jsx(tr,{className:"w-3 h-3 mr-1"}),"Add Panel"]})]}),Z.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:'No tenants added. Click "Add" to add tenant logos.'}):e.jsx("div",{className:"space-y-1.5",children:Z.map((ae,ie)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded",children:[e.jsxs(Ef,{children:[e.jsx(Pf,{asChild:!0,children:ae.logo_url?e.jsx("button",{className:"w-10 h-10 rounded border bg-background hover:bg-muted flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:ae.logo_url,alt:ae.logo_name||"Logo",className:"w-9 h-9 object-contain"})}):e.jsx("button",{className:"w-10 h-10 bg-muted rounded border border-dashed flex items-center justify-center cursor-pointer hover:bg-muted/80",children:e.jsx(Zd,{className:"w-4 h-4 text-muted-foreground"})})}),e.jsx(Tf,{className:"w-72 p-2",side:"left",align:"start",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ld,{className:"absolute left-2.5 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(be,{placeholder:"Search logos...",value:v,onChange:de=>C(de.target.value),className:"h-8 pl-8 text-xs"})]}),e.jsx(Xc,{className:"h-48",children:I.length>0?e.jsx("div",{className:"grid grid-cols-4 gap-1",children:I.map(de=>e.jsx("button",{className:"p-1 rounded hover:bg-muted border border-transparent hover:border-primary",onClick:()=>O(W.id,ae.id,de),title:de.name,children:e.jsx("img",{src:de.logo_url,alt:de.name,className:"w-12 h-12 object-contain"})},de.id))}):e.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:v?"No logos match your search":"No logos available"})})]})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-xs block truncate",children:ae.logo_name||`Slot ${ie+1}`}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Size:"}),e.jsxs(rt,{value:String(ae.size_weight??1),onValueChange:de=>te(W.id,ae.id,{size_weight:parseFloat(de)}),children:[e.jsx(it,{className:"h-5 w-14 text-[10px] px-1",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"0.5",children:"0.5x"}),e.jsx(le,{value:"1",children:"1x"}),e.jsx(le,{value:"1.5",children:"1.5x"}),e.jsx(le,{value:"2",children:"2x"}),e.jsx(le,{value:"3",children:"3x"})]})]})]}),(W.placard_columns??1)>1&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Col:"}),e.jsxs(rt,{value:String(ae.column??0),onValueChange:de=>te(W.id,ae.id,{column:parseInt(de)}),children:[e.jsx(it,{className:"h-5 w-10 text-[10px] px-1",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"0",children:"L"}),e.jsx(le,{value:"1",children:"R"})]})]})]})]})]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",disabled:ie
761===0,onClick:()=>H(W.id,ae.id,"up"),children:e.jsx(Cc,{className:"w-3 h-3"})}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",disabled:ie===Z.length-1,onClick:()=>H(W.id,ae.id,"down"),children:e.jsx(Oa,{className:"w-3 h-3"})}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>J(W.id,ae.id),children:e.jsx(ja,{className:"w-3 h-3 text-destructive"})})]},ae.id))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Background Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(be,{type:"color",value:W.background_color,onChange:ae=>D(W.id,{background_color:ae.target.value}),className:"h-8 w-12 p-1"}),e.jsx(be,{value:W.background_color,onChange:ae=>D(W.id,{background_color:ae.target.value}),className:"h-8 text-xs flex-1"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Frame Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(be,{type:"color",value:W.frame_color,onChange:ae=>D(W.id,{frame_color:ae.target.value}),className:"h-8 w-12 p-1"}),e.jsx(be,{value:W.frame_color,onChange:ae=>D(W.id,{frame_color:ae.target.value}),className:"h-8 text-xs flex-1"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-sm",children:"Double-Sided"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show logos on both faces"})]}),e.jsx(kt,{checked:W.double_sided,onCheckedChange:ae=>D(W.id,{double_sided:ae})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(B,{className:"text-sm flex items-center gap-2",children:[e.jsx(gh,{className:"w-4 h-4 text-yellow-500"}),"Illuminated"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sign has internal lighting"})]}),e.jsx(kt,{checked:W.illuminated,onCheckedChange:ae=>D(W.id,{illuminated:ae})})]})]})]})]},W.id)})}),e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full",onClick:F,children:[e.jsx(tr,{className:"w-4 h-4 mr-2"}),"Add Pylon Sign"]}),j.length>0&&e.jsx("div",{className:"text-xs text-muted-foreground pt-2 border-t",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{children:[j.length," sign",j.length!==1?"s":""]}),e.jsxs("span",{children:[j.reduce((W,Q)=>W+_(Q).length,0)," tenant slots"]})]})})]})}const eb=[{id:"chain_link",label:"Chain Link",color:"#9ca3af"},{id:"wrought_iron",label:"Wrought Iron",color:"#1f2937"},{id:"privacy",label:"Privacy",color:"#78716c"},{id:"security",label:"Security",color:"#374151"},{id:"decorative",label:"Decorative",color:"#d4a574"}],ly={enabled:!1,height_ft:6,type:"chain_link",has_barbed_wire:!1,color:"#9ca3af"},Qp=["F","R","S1","S2"],M8={F:"Front",R:"Rear",S1:"Side 1",S2:"Side 2"};function I8({overlay:t,onUpdate:s}){const n=t.style||{},a=n.perimeterFencing||{},l=k.useMemo(()=>!t.geometry||t.geometry.length<3?[]:mu(t.geometry),[t.geometry]),c=k.useMemo(()=>{const P={};return l.forEach(I=>{P[I.label]||(P[I.label]=[]),P[I.label].push(I)}),P},[l]),u=k.useMemo(()=>{const P={};return Qp.forEach(I=>{const z=c[I]||[];P[I]=z.reduce((F,D)=>F+(D.lengthFt||0),0)}),P},[c]),i=(P,I)=>{const z=a[P]||{...ly},F={...a,[P]:{...z,...I}};s({style:{...n,perimeterFencing:F}})},_=P=>{const I=a[P]||{...ly};i(P,{enabled:!I.enabled})},j=()=>{const P={};Qp.forEach(I=>{P[I]={...ly,enabled:!0}}),s({style:{...n,perimeterFencing:P}})},y=()=>{s({style:{...n,perimeterFencing:{}}})},x=P=>a[P]||{...ly},v=Qp.filter(P=>x(P).enabled).length,C=Qp.reduce((P,I)=>{const z=x(I);return P+(z.enabled&&u[I]||0)},0);return!t.geometry||t.geometry.length<3?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(ho,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No valid geometry"}),e.jsx("p",{className:"text-xs mt-1",children:"Draw a polygon to configure fencing"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{variant:"outline",size:"sm",className:"flex-1 text-xs",onClick:j,children:"Fence All Edges"}),e.jsx(Le,{variant:"outline",size:"sm",className:"flex-1 text-xs",onClick:y,disabled:v===0,children:"Clear All"})]}),e.jsx("div",{className:"space-y-2",children:Qp.map(P=>{const I=x(P),z=u[P]||0,F=eb.find(D=>D.id===I.type);return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",I.enabled?"border-primary bg-primary/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>_(P),children:[e.jsx("div",{className:fs("w-6 h-6 rounded flex items-center justify-center text-xs font-bold",I.enabled?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:P}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:M8[P]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[Math.round(z).toLocaleStr
761ing()," ft"]})]}),I.enabled&&e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:[I.height_ft,"′ ",F==null?void 0:F.label]}),e.jsx("div",{className:fs("w-5 h-5 rounded-full flex items-center justify-center",I.enabled?"bg-primary":"bg-muted"),children:I.enabled?e.jsx(cl,{className:"w-3 h-3 text-primary-foreground"}):e.jsx(ja,{className:"w-3 h-3 text-muted-foreground"})})]}),I.enabled&&e.jsxs("div",{className:"p-3 pt-0 space-y-3 border-t",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Height (ft)"}),e.jsx(be,{type:"number",value:I.height_ft,onChange:D=>i(P,{height_ft:parseFloat(D.target.value)||6}),className:"h-8 text-sm",min:3,max:12})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Fence Type"}),e.jsxs(rt,{value:I.type,onValueChange:D=>{const X=eb.find(K=>K.id===D);i(P,{type:D,color:(X==null?void 0:X.color)||I.color})},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:eb.map(D=>e.jsx(le,{value:D.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm border",style:{backgroundColor:D.color}}),e.jsx("span",{children:D.label})]})},D.id))})]})]})]}),(I.type==="chain_link"||I.type==="security")&&e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Barbed Wire Top"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Security enhancement"})]}),e.jsx(kt,{checked:I.has_barbed_wire,onCheckedChange:D=>i(P,{has_barbed_wire:D})})]})]})]},P)})}),v>0&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg text-xs space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Fenced Edges:"}),e.jsxs("span",{className:"font-medium",children:[v," of 4"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Length:"}),e.jsxs("span",{className:"font-mono",children:[Math.round(C).toLocaleString()," ft"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Barbed Wire:"}),e.jsxs("span",{children:[Qp.filter(P=>x(P).enabled&&x(P).has_barbed_wire).length," edges"]})]})]})]})}const T2=[{id:"segmental_block",label:"Segmental Block"},{id:"cast_in_place",label:"Cast-in-Place"},{id:"mechanically_stabilized",label:"Mechanically Stabilized"},{id:"gravity",label:"Gravity Wall"}],tb=[{id:"concrete",label:"Concrete",color:"#9ca3af"},{id:"stone",label:"Stone",color:"#78716c"},{id:"timber",label:"Timber",color:"#a16207"},{id:"gabion",label:"Gabion",color:"#6b7280"}],sb={enabled:!1,height_ft:4,wall_type:"segmental_block",material:"concrete",has_guardrail:!1,color:"#9ca3af"},ap=["F","R","S1","S2"],A8={F:"Front",R:"Rear",S1:"Side 1",S2:"Side 2"},L2=2.5;function D8({overlay:t,onUpdate:s}){const n=t.style||{},a=n.retainingWalls||{},l=k.useMemo(()=>!t.geometry||t.geometry.length<3?[]:mu(t.geometry),[t.geometry]),c=k.useMemo(()=>{const I={};return l.forEach(z=>{I[z.label]||(I[z.label]=[]),I[z.label].push(z)}),I},[l]),u=k.useMemo(()=>{const I={};return ap.forEach(z=>{const F=c[z]||[];I[z]=F.reduce((D,X)=>D+(X.lengthFt||0),0)}),I},[c]),i=(I,z)=>{const D={...a[I]||{...sb},...z};z.height_ft&&z.height_ft>L2&&!D.has_guardrail&&(D.has_guardrail=!0);const X={...a,[I]:D};s({style:{...n,retainingWalls:X}})},_=I=>{const z=a[I]||{...sb};i(I,{enabled:!z.enabled})},j=()=>{s({style:{...n,retainingWalls:{}}})},y=I=>a[I]||{...sb},x=ap.filter(I=>y(I).enabled).length,v=ap.reduce((I,z)=>{const F=y(z);return I+(F.enabled&&u[z]||0)},0),C=ap.reduce((I,z)=>{const F=y(z);return F.enabled?Math.max(I,F.height_ft):I},0),P=ap.reduce((I,z)=>{const F=y(z);return F.enabled?I+F.height_ft*(u[z]||0):I},0);return!t.geometry||t.geometry.length<3?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(ho,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No valid geometry"}),e.jsx("p",{className:"text-xs mt-1",children:"Draw a polygon to configure retaining walls"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex gap-2",children:e.jsx(Le,{variant:"outline",size:"sm",className:"flex-1 text-xs",onClick:j,disabled:x===0,children:"Clear All"})}),e.jsx("div",{className:"space-y-2",children:ap.map(I=>{const z=y(I),F=u[I]||0,D=tb.find(K=>K.id===z.material);T2.find(K=>K.id===z.wall_type);const X=z.height_ft>L2;return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",z.enabled?"border-primary bg-primary/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>_(I),children:[e.jsx("div",{className:fs("w-6 h-6 rounded flex items-center justify-center text-xs font-bold",z.enabled?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:I}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:A8[I]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[Math.round(F).toLocaleStr
761ing()," ft"]})]}),z.enabled&&e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:[z.height_ft,"′ ",D==null?void 0:D.label]}),e.jsx("div",{className:fs("w-5 h-5 rounded-full flex items-center justify-center",z.enabled?"bg-primary":"bg-muted"),children:z.enabled?e.jsx(cl,{className:"w-3 h-3 text-primary-foreground"}):e.jsx(ja,{className:"w-3 h-3 text-muted-foreground"})})]}),z.enabled&&e.jsxs("div",{className:"p-3 pt-0 space-y-3 border-t",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Height (ft)"}),e.jsx(be,{type:"number",value:z.height_ft,onChange:K=>i(I,{height_ft:parseFloat(K.target.value)||4}),className:"h-8 text-sm",min:2,max:20})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Wall Type"}),e.jsxs(rt,{value:z.wall_type,onValueChange:K=>{i(I,{wall_type:K})},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:T2.map(K=>e.jsx(le,{value:K.id,children:K.label},K.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Material"}),e.jsxs(rt,{value:z.material,onValueChange:K=>{const te=tb.find(J=>J.id===K);i(I,{material:K,color:(te==null?void 0:te.color)||z.color})},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:tb.map(K=>e.jsx(le,{value:K.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm border",style:{backgroundColor:K.color}}),e.jsx("span",{children:K.label})]})},K.id))})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(B,{className:"text-xs flex items-center gap-1",children:["Has Guardrail",X&&e.jsx(Ag,{className:"w-3 h-3 text-amber-500"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:X?'Required (height > 30")':"Optional safety feature"})]}),e.jsx(kt,{checked:z.has_guardrail,onCheckedChange:K=>i(I,{has_guardrail:K})})]})]})]},I)})}),x>0&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg text-xs space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Length:"}),e.jsxs("span",{className:"font-mono",children:[Math.round(v).toLocaleString()," ft"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Max Height:"}),e.jsxs("span",{className:"font-mono",children:[C," ft"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Wall Area:"}),e.jsxs("span",{className:"font-mono",children:[Math.round(P).toLocaleString()," sf"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Guardrails:"}),e.jsxs("span",{children:[ap.filter(I=>y(I).enabled&&y(I).has_guardrail).length," edges"]})]})]})]})}const nb=[{id:"utility",label:"Utility",color:"#8b5cf6",description:"Electric, gas, water, sewer, telecom"},{id:"access",label:"Access",color:"#3b82f6",description:"Ingress/egress rights"},{id:"drainage",label:"Drainage",color:"#06b6d4",description:"Stormwater management"},{id:"conservation",label:"Conservation",color:"#22c55e",description:"Environmental protection"},{id:"pipeline",label:"Pipeline",color:"#f97316",description:"Gas, oil, water transmission"}],ab={enabled:!1,easement_type:"utility",width_ft:15,owner_grantor:"",recording_reference:""},cx=["F","R","S1","S2"],R8={F:"Front",R:"Rear",S1:"Side 1",S2:"Side 2"};function F8({overlay:t,onUpdate:s}){const n=t.style||{},a=n.easements||{},l=k.useMemo(()=>!t.geometry||t.geometry.length<3?[]:mu(t.geometry),[t.geometry]),c=k.useMemo(()=>{const P={};return l.forEach(I=>{P[I.label]||(P[I.label]=[]),P[I.label].push(I)}),P},[l]),u=k.useMemo(()=>{const P={};return cx.forEach(I=>{const z=c[I]||[];P[I]=z.reduce((F,D)=>F+(D.lengthFt||0),0)}),P},[c]),i=(P,I)=>{const z=a[P]||{...ab},F={...a,[P]:{...z,...I}};s({style:{...n,easements:F}})},_=P=>{const I=a[P]||{...ab};i(P,{enabled:!I.enabled})},j=()=>{s({style:{...n,easements:{}}})},y=P=>a[P]||{...ab},x=cx.filter(P=>y(P).enabled).length,v=cx.reduce((P,I)=>{const z=y(I);return z.enabled?P+z.width_ft*(u[I]||0):P},0),C=k.useMemo(()=>{const P={};
761return cx.forEach(I=>{const z=y(I);z.enabled&&(P[z.easement_type]=(P[z.easement_type]||0)+1)}),P},[a]);return!t.geometry||t.geometry.length<3?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(ho,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No valid geometry"}),e.jsx("p",{className:"text-xs mt-1",children:"Draw a polygon to configure easements"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex gap-2",children:e.jsx(Le,{variant:"outline",size:"sm",className:"flex-1 text-xs",onClick:j,disabled:x===0,children:"Clear All"})}),e.jsx("div",{className:"space-y-2",children:cx.map(P=>{const I=y(P),z=u[P]||0,F=nb.find(D=>D.id===I.easement_type);return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",I.enabled?"border-violet-500 bg-violet-500/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>_(P),children:[e.jsx("div",{className:fs("w-6 h-6 rounded flex items-center justify-center text-xs font-bold",I.enabled?"bg-violet-500 text-white":"bg-muted text-muted-foreground"),children:P}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:R8[P]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[Math.round(z).toLocaleString()," ft"]})]}),I.enabled&&F&&e.jsxs(Mt,{variant:"outline",className:"text-[10px]",style:{borderColor:F.color,color:F.color},children:[I.width_ft,"′ ",F.label]}),e.jsx("div",{className:fs("w-5 h-5 rounded-full flex items-center justify-center",I.enabled?"bg-violet-500":"bg-muted"),children:I.enabled?e.jsx(cl,{className:"w-3 h-3 text-white"}):e.jsx(ja,{className:"w-3 h-3 text-muted-foreground"})})]}),I.enabled&&e.jsxs("div",{className:"p-3 pt-0 space-y-3 border-t",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Easement Type"}),e.jsxs(rt,{value:I.easement_type,onValueChange:D=>{i(P,{easement_type:D})},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:nb.map(D=>e.jsx(le,{value:D.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm border",style:{backgroundColor:D.color}}),e.jsx("span",{children:D.label})]})},D.id))})]}),F&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:F.description})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Width (ft)"}),e.jsx(be,{type:"number",value:I.width_ft,onChange:D=>i(P,{width_ft:parseFloat(D.target.value)||15}),className:"h-8 text-sm",min:5,max:100})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Owner / Grantor"}),e.jsx(be,{type:"text",value:I.owner_grantor,onChange:D=>i(P,{owner_grantor:D.target.value}),className:"h-8 text-sm",placeholder:"e.g., City of Austin, AEP Texas"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Recording Reference"}),e.jsx(be,{type:"text",value:I.recording_reference,onChange:D=>i(P,{recording_reference:D.target.value}),className:"h-8 text-sm",placeholder:"e.g., Book 123, Page 456 or Inst. #2024-00001"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Book/page or instrument number"})]})]})]},P)})}),x>0&&e.jsxs("div",{className:"p-3 bg-violet-500/10 rounded-lg text-xs space-y-2 border border-violet-500/20",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Easement Area:"}),e.jsxs("span",{className:"font-mono",children:[Math.round(v).toLocaleString()," sf"]})]}),e.jsxs("div",{className:"pt-1 border-t border-violet-500/20",children:[e.jsx("span",{className:"text-muted-foreground",children:"By Type:"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(C).map(([P,I])=>{const z=nb.find(F=>F.id===P);return e.jsxs(Mt,{variant:"outline",className:"text-[10px]",style:{borderColor:z==null?void 0:z.color,color:z==null?void 0:z.color},children:[z==null?void 0:z.label,": ",I]},P)})})]})]})]})}const M2=[{id:"masonry",label:"Masonry",description:"CMU or brick screening"},{id:"wood",label:"Wood",description:"Timber fence enclosure"},{id:"metal",label:"Metal",description:"Steel panel enclosure"},{id:"chain_link",label:"Chain Link",description:"With privacy slats"}],z8=[{id:"front",label:"Front"},{id:"rear",label:"Rear"},{id:"side",label:"Side"}],O8=[{id:"standard",label:"Standard",description:"Single stream"},{id:"dual",label:"Dual",description:"Trash + Recycling split"}
761],B8={name:"Trash Enclosure",width_ft:12,depth_ft:10,enclosure_type:"masonry",has_roof:!1,service_access:"front",has_compactor:!1,enclosure_config:"standard",has_grease_interceptor:!1,has_concrete_pad:!0,bollard_count:4,screen_wall_height_ft:6};function $8({overlay:t,onUpdate:s}){const[n,a]=k.useState(null),l=t.style||{},c=l.trashEnclosures||[],u=x=>{s({style:{...l,trashEnclosures:x}})},i=()=>{const x={...B8,id:crypto.randomUUID(),name:`Trash Enclosure ${c.length+1}`};u([...c,x]),a(x.id)},_=(x,v)=>{u(c.map(C=>C.id===x?{...C,...v}:C))},j=x=>{u(c.filter(v=>v.id!==x)),n===x&&a(null)},y=c.reduce((x,v)=>x+v.width_ft*v.depth_ft,0);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full text-xs",onClick:i,children:[e.jsx(tr,{className:"w-3.5 h-3.5 mr-1"}),"Add Enclosure"]}),c.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(wr,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No enclosures defined"}),e.jsx("p",{className:"text-xs mt-1",children:"Add trash/recycling enclosures to the site"})]}):e.jsx("div",{className:"space-y-2",children:c.map(x=>{const v=n===x.id,C=M2.find(I=>I.id===x.enclosure_type),P=x.width_ft*x.depth_ft;return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",v?"border-primary bg-primary/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>a(v?null:x.id),children:[e.jsx(wr,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:x.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[x.width_ft,"′ × ",x.depth_ft,"′ • ",P," sf"]})]}),e.jsx(Mt,{variant:"outline",className:"text-[10px]",children:C==null?void 0:C.label}),x.has_compactor&&e.jsx(Mt,{variant:"secondary",className:"text-[10px]",children:"Compactor"}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:I=>{I.stopPropagation(),j(x.id)},children:e.jsx(ja,{className:"w-3.5 h-3.5"})}),v?e.jsx(Cc,{className:"w-4 h-4 text-muted-foreground"}):e.jsx(Oa,{className:"w-4 h-4 text-muted-foreground"})]}),v&&e.jsxs("div",{className:"p-3 pt-0 space-y-3 border-t",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Name / Label"}),e.jsx(be,{type:"text",value:x.name,onChange:I=>_(x.id,{name:I.target.value}),className:"h-8 text-sm",placeholder:"Trash Enclosure 1"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Width (ft)"}),e.jsx(be,{type:"number",value:x.width_ft,onChange:I=>_(x.id,{width_ft:parseFloat(I.target.value)||12}),className:"h-8 text-sm",min:6,max:30})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Depth (ft)"}),e.jsx(be,{type:"number",value:x.depth_ft,onChange:I=>_(x.id,{depth_ft:parseFloat(I.target.value)||10}),className:"h-8 text-sm",min:6,max:30})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Enclosure Type"}),e.jsxs(rt,{value:x.enclosure_type,onValueChange:I=>{_(x.id,{enclosure_type:I})},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:M2.map(I=>e.jsx(le,{value:I.id,children:I.label},I.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Service Access"}),e.jsxs(rt,{value:x.service_access,onValueChange:I=>{_(x.id,{service_access:I})},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:z8.map(I=>e.jsx(le,{value:I.id,children:I.label},I.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Configuration"}),e.jsxs(rt,{value:x.enclosure_config||"standard",onValueChange:I=>{const z={enclosure_config:I};I==="dual"&&x.width_ft<20&&(z.width_ft=20),_(x.id,z)},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:O8.map(I=>e.jsxs(le,{value:I.id,children:[I.label," — ",I.description]},I.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Screen Wall Height (ft)"}),e.jsx(be,{type:"number",value:x.screen_wall_height_ft??6,onChange:I=>_(x.id,{screen_wall_height_ft:parseFloat(I.target.value)||6}),className:"h-8 text-sm",min:4,max:12})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Bollard Count"}),e.jsx(be,{type:"number",value:x.bollard_count??4,onChange:I=>_(x.id,{bollard_count:parseInt(I.target.value)||0}),className:"h-8 text-sm",min:0,max:12})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Has Roof"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Covered enclosure"})]}),e.jsx(kt,{checked:x.has_roof,onCheckedChange:I=>_(x.id,{has_roof:I})})]}),e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Has Compactor"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Trash compactor unit"})]}),e.jsx(kt,{checked:x.has_compactor,onCheckedChange:I=>_(x.id,{has_compactor:I})})]}),e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Concrete Pad"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Apron for dumpster placement"})]}),e.jsx(kt,{checked:x.has_concrete_pad??!0,onCheckedChange:I=>_(x.id,{has_concrete_pad:I})})]}),e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Grease Interceptor"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Below-grade trap for restaurant pads"})]}),e.jsx(kt,{checked:x.has_grease_interceptor??!1,onCheckedChange:I=>_(x.id,{has_grease_interceptor:I})})]})]})]})]},x.id)})}),c.length>0&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg text-xs space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Enclosure Count:"}),e.jsx("span",{className:"font-medium",children:c.length})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Footprint:"}
761),e.jsxs("span",{className:"font-mono",children:[y.toLocaleString()," sf"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"With Compactor:"}),e.jsx("span",{children:c.filter(x=>x.has_compactor).length})]})]})]})}const cy=[{id:"pole_mounted",label:"Pole Mounted",icon:"🏮",defaultHeight:25},{id:"bollard",label:"Bollard",icon:"🔦",defaultHeight:3},{id:"wall_pack",label:"Wall Pack",icon:"💡",defaultHeight:12},{id:"flood",label:"Flood Light",icon:"🔆",defaultHeight:30}],I2=[{id:"warm_3000k",label:"3000K Warm",color:"#fbbf24"},{id:"neutral_4000k",label:"4000K Neutral",color:"#fef3c7"},{id:"cool_5000k",label:"5000K Cool",color:"#f0f9ff"}],V8={name:"Light Pole",fixture_type:"pole_mounted",height_ft:25,wattage:150,light_temperature:"neutral_4000k",footcandle_radius_ft:40};function q8({overlay:t,onUpdate:s}){const[n,a]=k.useState(null),l=t.style||{},c=l.siteLighting||[],u=x=>{s({style:{...l,siteLighting:x}})},i=()=>{const x={...V8,id:crypto.randomUUID(),name:`Light Pole ${c.length+1}`};u([...c,x]),a(x.id)},_=(x,v)=>{u(c.map(C=>C.id===x?{...C,...v}:C))},j=x=>{u(c.filter(v=>v.id!==x)),n===x&&a(null)},y=c.reduce((x,v)=>x+v.wattage,0);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full text-xs",onClick:i,children:[e.jsx(tr,{className:"w-3.5 h-3.5 mr-1"}),"Add Light Fixture"]}),c.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(gh,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No lighting defined"}),e.jsx("p",{className:"text-xs mt-1",children:"Add light poles and fixtures to the site"})]}):e.jsx("div",{className:"space-y-2",children:c.map(x=>{const v=n===x.id,C=cy.find(I=>I.id===x.fixture_type),P=I2.find(I=>I.id===x.light_temperature);return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",v?"border-amber-500 bg-amber-500/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>a(v?null:x.id),children:[e.jsx("div",{className:"w-6 h-6 rounded flex items-center justify-center text-sm",style:{backgroundColor:P==null?void 0:P.color},children:(C==null?void 0:C.icon)||"💡"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:x.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[x.height_ft,"′ tall • ",x.wattage,"W"]})]}),e.jsx(Mt,{variant:"outline",className:"text-[10px]",children:C==null?void 0:C.label}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:I=>{I.stopPropagation(),j(x.id)},children:e.jsx(ja,{className:"w-3.5 h-3.5"})}),v?e.jsx(Cc,{className:"w-4 h-4 text-muted-foreground"}):e.jsx(Oa,{className:"w-4 h-4 text-muted-foreground"})]}),v&&e.jsxs("div",{className:"p-3 pt-0 space-y-3 border-t",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Name / Label"}),e.jsx(be,{type:"text",value:x.name,onChange:I=>_(x.id,{name:I.target.value}),className:"h-8 text-sm",placeholder:"Light Pole 1"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Fixture Type"}),e.jsxs(rt,{value:x.fixture_type,onValueChange:I=>{const z=cy.find(F=>F.id===I);_(x.id,{fixture_type:I,height_ft:(z==null?void 0:z.defaultHeight)||x.height_ft})},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:cy.map(I=>e.jsx(le,{value:I.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:I.icon}),e.jsx("span",{children:I.label})]})},I.id))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Height (ft)"}),e.jsx(be,{type:"number",value:x.height_ft,onChange:I=>_(x.id,{height_ft:parseFloat(I.target.value)||25}),className:"h-8 text-sm",min:3,max:50})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Wattage (W)"}),e.jsx(be,{type:"number",value:x.wattage,onChange:I=>_(x.id,{wattage:parseInt(I.target.value)||150}),className:"h-8 text-sm",min:10,max:1e3})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(B,{className:"text-xs flex items-center gap-1",children:[e.jsx(nS,{className:"w-3 h-3"}),"Color Temperature"]}),e.jsxs(rt,{value:x.light_temperature,onValueChange:I=>{_(x.id,{light_temperature:I})},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:I2.map(I=>e.jsx(le,{value:I.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border",style:{backgroundColor:I.color}}),e.jsx("span",{children:I.label})]})},I.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Foot-Candle Radius (ft)"}),e.jsx(be,{type:"number",value:x.footcandle_radius_ft,onChange:I=>_(x.id,{footcandle_radius_ft:parseFloat(I.target.value)||40}),className:"h-8 text-sm",min:10,max:100}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Approximate coverage zone radius"})]})]})]},x.id)})}),c.length>0&&e.jsxs("div",{className:"p-3 bg-amber-500/10 rounded-lg text-xs space-y-1 border border-amber-500/20",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Fixtures:"}),e.jsx("span",{className:"font-medium",children:c.length})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Wattage:"}
761),e.jsxs("span",{className:"font-mono",children:[y.toLocaleString()," W"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"By Type:"}),e.jsx("div",{className:"flex gap-1",children:cy.map(x=>{const v=c.filter(C=>C.fixture_type===x.id).length;return v===0?null:e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:[x.icon," ",v]},x.id)})})]})]})]})}const dy=[{id:"trailer_parking",label:"Trailer Parking",icon:hu,color:"#3b82f6"},{id:"container_yard",label:"Container Yard",icon:Wm,color:"#f97316"},{id:"equipment_storage",label:"Equipment Storage",icon:sj,color:"#8b5cf6"},{id:"material_staging",label:"Material Staging",icon:A1,color:"#22c55e"}],G8=[{id:"fence",label:"Fence"},{id:"wall",label:"Wall"},{id:"landscape",label:"Landscape"}],H8={name:"Storage Zone",storage_type:"trailer_parking",area_sf:5e3,is_screened:!1};function Z8({overlay:t,onUpdate:s}){const[n,a]=k.useState(null),l=t.style||{},c=l.outdoorStorage||[],u=v=>{s({style:{...l,outdoorStorage:v}})},i=()=>{const v={...H8,id:crypto.randomUUID(),name:`Storage Zone ${c.length+1}`};u([...c,v]),a(v.id)},_=(v,C)=>{u(c.map(P=>P.id===v?{...P,...C}:P))},j=v=>{u(c.filter(C=>C.id!==v)),n===v&&a(null)},y=c.reduce((v,C)=>v+C.area_sf,0),x=dy.reduce((v,C)=>(v[C.id]=c.filter(P=>P.storage_type===C.id).length,v),{});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full text-xs",onClick:i,children:[e.jsx(tr,{className:"w-3.5 h-3.5 mr-1"}),"Add Storage Zone"]}),c.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(yg,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No storage zones defined"}),e.jsx("p",{className:"text-xs mt-1",children:"Add outdoor storage areas to the site"})]}):e.jsx("div",{className:"space-y-2",children:c.map(v=>{const C=n===v.id,P=dy.find(z=>z.id===v.storage_type),I=(P==null?void 0:P.icon)||yg;return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",C?"border-primary bg-primary/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>a(C?null:v.id),children:[e.jsx("div",{className:"w-6 h-6 rounded flex items-center justify-center",style:{backgroundColor:`${P==null?void 0:P.color}20`},children:e.jsx(I,{className:"w-3.5 h-3.5",style:{color:P==null?void 0:P.color}})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:v.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[v.area_sf.toLocaleString()," sf"]})]}),e.jsx(Mt,{variant:"outline",className:"text-[10px]",style:{borderColor:P==null?void 0:P.color,color:P==null?void 0:P.color},children:P==null?void 0:P.label}),v.is_screened&&e.jsx(Mt,{variant:"secondary",className:"text-[10px]",children:"Screened"}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:z=>{z.stopPropagation(),j(v.id)},children:e.jsx(ja,{className:"w-3.5 h-3.5"})}),C?e.jsx(Cc,{className:"w-4 h-4 text-muted-foreground"}):e.jsx(Oa,{className:"w-4 h-4 text-muted-foreground"})]}),C&&e.jsxs("div",{className:"p-3 pt-0 space-y-3 border-t",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Name / Label"}),e.jsx(be,{type:"text",value:v.name,onChange:z=>_(v.id,{name:z.target.value}),className:"h-8 text-sm",placeholder:"Storage Zone 1"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Storage Type"}),e.jsxs(rt,{value:v.storage_type,onValueChange:z=>{_(v.id,{storage_type:z})},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:dy.map(z=>{const F=z.icon;return e.jsx(le,{value:z.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"w-3.5 h-3.5",style:{color:z.color}}),e.jsx("span",{children:z.label})]})},z.id)})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Area (sf)"}),e.jsx(be,{type:"number",value:v.area_sf,onChange:z=>_(v.id,{area_sf:parseInt(z.target.value)||5e3}),className:"h-8 text-sm",min:100,max:5e5}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[(v.area_sf/43560).toFixed(2)," acres"]})]}),e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Is Screened"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Requires visual screening"})]}),e.jsx(kt,{checked:v.is_screened,onCheckedChange:z=>_(v.id,{is_screened:z,screening_type:z?"fence":void 0})})]}),v.is_screened&&e.jsxs("div",{className:"space-y-1.5 pl-4",children:[e.jsx(B,{className:"text-xs",children:"Screening Type"}),e.jsxs(rt,{value:v.screening_type||"fence",onValueChange:z=>{_(v.id,{screening_type:z})},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:G8.map(z=>e.jsx(le,{value:z.id,children:z.label},z.id))})]})]})]})]},v.id)})}),c.length>0&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg text-xs space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Zones:"}),e.jsx("span",{className:"font-medium",children:c.length})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Area:"}
761),e.jsxs("span",{className:"font-mono",children:[y.toLocaleString()," sf"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Screened:"}),e.jsxs("span",{children:[c.filter(v=>v.is_screened).length," zones"]})]}),e.jsxs("div",{className:"pt-1 border-t",children:[e.jsx("span",{className:"text-muted-foreground",children:"By Type:"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:dy.map(v=>{const C=x[v.id];if(C===0)return null;const P=v.icon;return e.jsxs(Mt,{variant:"outline",className:"text-[10px]",style:{borderColor:v.color},children:[e.jsx(P,{className:"w-3 h-3 mr-1",style:{color:v.color}}),C]},v.id)})})]})]})]})}const A2=[{id:"concrete",label:"Concrete",color:"#d1d5db"},{id:"pavers",label:"Pavers",color:"#b45309"},{id:"asphalt",label:"Asphalt",color:"#374151"},{id:"permeable_pavers",label:"Permeable Pavers",color:"#065f46"}],D2=[{id:"concrete",label:"Concrete",color:"#d1d5db"},{id:"pavers",label:"Pavers",color:"#b45309"},{id:"asphalt",label:"Asphalt",color:"#374151"},{id:"permeable_pavers",label:"Permeable Pavers",color:"#065f46"},{id:"stamped_concrete",label:"Stamped Concrete",color:"#a78bfa"},{id:"exposed_aggregate",label:"Exposed Aggregate",color:"#78716c"}],W8=[{id:"standard",label:'Standard (6")'},{id:"rolled",label:"Rolled"},{id:"mountable",label:"Mountable"},{id:"none",label:"None"}],rb={enabled:!1,width_ft:5,material:"concrete",is_ada_compliant:!0,curb_type:"standard"},Y8={name:"Plaza Area",material:"concrete",area_sf:1e3},dx=["F","R","S1","S2"],X8={F:"Front",R:"Rear",S1:"Side 1",S2:"Side 2"};function K8({overlay:t,onUpdate:s}){const[n,a]=k.useState("sidewalks"),[l,c]=k.useState(null),u=t.style||{},i=u.hardscape||{},_=i.sidewalks||{},j=i.plazas||[],y=k.useMemo(()=>!t.geometry||t.geometry.length<3?[]:mu(t.geometry),[t.geometry]),x=k.useMemo(()=>{const H={};return y.forEach(O=>{H[O.label]||(H[O.label]=[]),H[O.label].push(O)}),H},[y]),v=k.useMemo(()=>{const H={};return dx.forEach(O=>{const q=x[O]||[];H[O]=q.reduce((W,Q)=>W+(Q.lengthFt||0),0)}),H},[x]),C=H=>{s({style:{...u,hardscape:{...i,...H}}})},P=(H,O)=>{const q=_[H]||{...rb};C({sidewalks:{..._,[H]:{...q,...O}}})},I=H=>{const O=_[H]||{...rb};P(H,{enabled:!O.enabled})},z=H=>_[H]||{...rb},F=()=>{const H={...Y8,id:crypto.randomUUID(),name:`Plaza ${j.length+1}`};C({plazas:[...j,H]}),c(H.id)},D=(H,O)=>{C({plazas:j.map(q=>q.id===H?{...q,...O}:q)})},X=H=>{C({plazas:j.filter(O=>O.id!==H)}),l===H&&c(null)},K=dx.filter(H=>z(H).enabled).length,te=dx.reduce((H,O)=>
761{const q=z(O);return H+(q.enabled&&v[O]||0)},0),J=j.reduce((H,O)=>H+O.area_sf,0);return!t.geometry||t.geometry.length<3?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(ho,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No valid geometry"}),e.jsx("p",{className:"text-xs mt-1",children:"Draw a polygon to configure hardscape"})]}):e.jsx("div",{className:"space-y-4",children:e.jsxs(Zm,{value:n,onValueChange:H=>a(H),children:[e.jsxs(mm,{className:"w-full grid grid-cols-2",children:[e.jsxs(Bi,{value:"sidewalks",className:"text-xs",children:[e.jsx(zu,{className:"w-3.5 h-3.5 mr-1"}),"Sidewalks",K>0&&e.jsx(Mt,{variant:"secondary",className:"ml-1 text-[10px] h-4",children:K})]}),e.jsxs(Bi,{value:"plazas",className:"text-xs",children:[e.jsx(Il,{className:"w-3.5 h-3.5 mr-1"}),"Plazas",j.length>0&&e.jsx(Mt,{variant:"secondary",className:"ml-1 text-[10px] h-4",children:j.length})]})]}),e.jsxs($i,{value:"sidewalks",className:"space-y-3 mt-3",children:[dx.map(H=>{const O=z(H),q=v[H]||0,W=A2.find(Q=>Q.id===O.material);return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",O.enabled?"border-primary bg-primary/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>I(H),children:[e.jsx("div",{className:fs("w-6 h-6 rounded flex items-center justify-center text-xs font-bold",O.enabled?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:H}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:X8[H]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[Math.round(q).toLocaleString()," ft"]})]}),O.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:[O.width_ft,"′ ",W==null?void 0:W.label]}),O.is_ada_compliant&&e.jsx(fh,{className:"w-3.5 h-3.5 text-blue-500"})]}),e.jsx("div",{className:fs("w-5 h-5 rounded-full flex items-center justify-center",O.enabled?"bg-primary":"bg-muted"),children:O.enabled?e.jsx(cl,{className:"w-3 h-3 text-primary-foreground"}):e.jsx(ja,{className:"w-3 h-3 text-muted-foreground"})})]}),O.enabled&&e.jsxs("div",{className:"p-3 pt-0 space-y-3 border-t",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Width (ft)"}),e.jsx(be,{type:"number",value:O.width_ft,onChange:Q=>P(H,{width_ft:parseFloat(Q.target.value)||5}),className:"h-8 text-sm",min:4,max:12})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Material"}),e.jsxs(rt,{value:O.material,onValueChange:Q=>{P(H,{material:Q})},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:A2.map(Q=>e.jsx(le,{value:Q.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm border",style:{backgroundColor:Q.color}}),e.jsx("span",{children:Q.label})]})},Q.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Curb Type"}),e.jsxs(rt,{value:O.curb_type,onValueChange:Q=>{P(H,{curb_type:Q})},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:W8.map(Q=>e.jsx(le,{value:Q.id,children:Q.label},Q.id))})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(B,{className:"text-xs flex items-center gap-1",children:[e.jsx(fh,{className:"w-3 h-3 text-blue-500"}),"ADA Compliant"]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Tactile warnings, ramps"})]}),e.jsx(kt,{checked:O.is_ada_compliant,onCheckedChange:Q=>P(H,{is_ada_compliant:Q})})]})]})]},H)}),K>0&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg text-xs space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Sidewalk Length:"}),e.jsxs("span",{className:"font-mono",children:[Math.round(te).toLocaleStr
761ing()," ft"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"ADA Compliant:"}),e.jsxs("span",{children:[dx.filter(H=>z(H).enabled&&z(H).is_ada_compliant).length," edges"]})]})]})]}),e.jsxs($i,{value:"plazas",className:"space-y-3 mt-3",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full text-xs",onClick:F,children:[e.jsx(tr,{className:"w-3.5 h-3.5 mr-1"}),"Add Plaza / Hardscape Area"]}),j.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(Il,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No plaza areas defined"})]}):e.jsx("div",{className:"space-y-2",children:j.map(H=>{const O=l===H.id,q=D2.find(W=>W.id===H.material);return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",O?"border-primary bg-primary/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>c(O?null:H.id),children:[e.jsx(Il,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:H.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[H.area_sf.toLocaleString()," sf"]})]}),e.jsx(Mt,{variant:"outline",className:"text-[10px]",children:q==null?void 0:q.label}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:W=>{W.stopPropagation(),X(H.id)},children:e.jsx(ja,{className:"w-3.5 h-3.5"})}),O?e.jsx(Cc,{className:"w-4 h-4 text-muted-foreground"}):e.jsx(Oa,{className:"w-4 h-4 text-muted-foreground"})]}),O&&e.jsxs("div",{className:"p-3 pt-0 space-y-3 border-t",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Name"}),e.jsx(be,{type:"text",value:H.name,onChange:W=>D(H.id,{name:W.target.value}),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Area (sf)"}),e.jsx(be,{type:"number",value:H.area_sf,onChange:W=>D(H.id,{area_sf:parseInt(W.target.value)||1e3}),className:"h-8 text-sm",min:100})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Material"}),e.jsxs(rt,{value:H.material,onValueChange:W=>{D(H.id,{material:W})},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:D2.map(W=>e.jsx(le,{value:W.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm border",style:{backgroundColor:W.color}}),e.jsx("span",{children:W.label})]})},W.id))})]})]})]})]})]},H.id)})}),j.length>0&&e.jsx("div",{className:"p-3 bg-muted/50 rounded-lg text-xs space-y-1",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Plaza Area:"}),e.jsxs("span",{className:"font-mono",children:[J.toLocaleString()," sf"]})]})})]})]})})}const R2=[{id:"silt_fence",label:"Silt Fence",color:"#f97316"},{id:"wattle",label:"Fiber Wattle",color:"#a16207"},{id:"erosion_blanket",label:"Erosion Blanket",color:"#65a30d"}],ib=[{id:"inlet_protection",label:"Inlet Protection",icon:Fx,color:"#3b82f6"},{id:"stabilized_entrance",label:"Stabilized Entrance",icon:uo,color:"#78716c"},{id:"check_dam",label:"Check Dam",icon:Ag,color:"#f59e0b"},{id:"sediment_trap",label:"Sediment Trap",icon:Fx,color:"#8b5cf6"}],ob={enabled:!1,measure_type:"silt_fence",height_inches:24},J8={name:"Erosion Control Point",point_type:"inlet_protection"},uy=["F","R","S1","S2"],Q8={F:"Front",R:"Rear",S1:"Side 1",S2:"Side 2"};function U8({overlay:t,onUpdate:s}){const[n,a]=k.useState("perimeter"),[l,c]=k.useState(null),u=t.style||{},i=u.erosionControl||{},_=i.edgeMeasures||{},j=i.points||[],y=k.useMemo(()=>!t.geometry||t.geometry.length<3?[]:mu(t.geometry),[t.geometry]),x=k.useMemo(()=>{const H={};return y.forEach(O=>{H[O.label]||(H[O.label]=[]),H[O.label].push(O)}),H},[y]),v=k.useMemo(()=>{const H={};
761return uy.forEach(O=>{const q=x[O]||[];H[O]=q.reduce((W,Q)=>W+(Q.lengthFt||0),0)}),H},[x]),C=H=>{s({style:{...u,erosionControl:{...i,...H}}})},P=(H,O)=>{const q=_[H]||{...ob};C({edgeMeasures:{..._,[H]:{...q,...O}}})},I=H=>{const O=_[H]||{...ob};P(H,{enabled:!O.enabled})},z=H=>_[H]||{...ob},F=()=>{const H={...J8,id:crypto.randomUUID(),name:`Control Point ${j.length+1}`};C({points:[...j,H]}),c(H.id)},D=(H,O)=>{C({points:j.map(q=>q.id===H?{...q,...O}:q)})},X=H=>{C({points:j.filter(O=>O.id!==H)}),l===H&&c(null)},K=uy.filter(H=>z(H).enabled).length,te=uy.reduce((H,O)=>{const q=z(O);return H+(q.enabled&&v[O]||0)},0),J=k.useMemo(()=>{const H={};return j.forEach(O=>{H[O.point_type]=(H[O.point_type]||0)+1}),H},[j]);return!t.geometry||t.geometry.length<3?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(ho,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No valid geometry"}),e.jsx("p",{className:"text-xs mt-1",children:"Draw a polygon to configure erosion control"})]}):e.jsx("div",{className:"space-y-4",children:e.jsxs(Zm,{value:n,onValueChange:H=>a(H),children:[e.jsxs(mm,{className:"w-full grid grid-cols-2",children:[e.jsxs(Bi,{value:"perimeter",className:"text-xs",children:["Perimeter",K>0&&e.jsx(Mt,{variant:"secondary",className:"ml-1 text-[10px] h-4",children:K})]}),e.jsxs(Bi,{value:"points",className:"text-xs",children:["Points",j.length>0&&e.jsx(Mt,{variant:"secondary",className:"ml-1 text-[10px] h-4",children:j.length})]})]}),e.jsxs($i,{value:"perimeter",className:"space-y-3 mt-3",children:[uy.map(H=>{const O=z(H),q=v[H]||0,W=R2.find(Q=>Q.id===O.measure_type);return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",O.enabled?"border-orange-500 bg-orange-500/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>I(H),children:[e.jsx("div",{className:fs("w-6 h-6 rounded flex items-center justify-center text-xs font-bold",O.enabled?"bg-orange-500 text-white":"bg-muted text-muted-foreground"),children:H}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:Q8[H]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[Math.round(q).toLocaleString()," ft"]})]}),O.enabled&&W&&e.jsx(Mt,{variant:"outline",className:"text-[10px]",style:{borderColor:W.color,color:W.color},children:W.label}),e.jsx("div",{className:fs("w-5 h-5 rounded-full flex items-center justify-center",O.enabled?"bg-orange-500":"bg-muted"),children:O.enabled?e.jsx(cl,{className:"w-3 h-3 text-white"}):e.jsx(ja,{className:"w-3 h-3 text-muted-foreground"})})]}),O.enabled&&e.jsx("div",{className:"p-3 pt-0 space-y-3 border-t",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Measure Type"}),e.jsxs(rt,{value:O.measure_type,onValueChange:Q=>{P(H,{measure_type:Q})},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:R2.map(Q=>e.jsx(le,{value:Q.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm border",style:{backgroundColor:Q.color}}),e.jsx("span",{children:Q.label})]})},Q.id))})]})]}),O.measure_type==="silt_fence"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Height (in)"}),e.jsx(be,{type:"number",value:O.height_inches,onChange:Q=>P(H,{height_inches:parseInt(Q.target.value)||24}),className:"h-8 text-sm",min:18,max:36})]})]})})]},H)}),K>0&&e.jsx("div",{className:"p-3 bg-orange-500/10 rounded-lg text-xs space-y-1 border border-orange-500/20",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Perimeter Protected:"}),e.jsxs("span",{className:"font-mono",children:[Math.round(te).toLocaleString()," ft"]})]})})]}),e.jsxs($i,{value:"points",className:"space-y-3 mt-3",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full text-xs",onClick:F,children:[e.jsx(tr,{className:"w-3.5 h-3.5 mr-1"}),"Add Control Point"]}),j.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(Fx,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No control points defined"}),e.jsx("p",{className:"text-xs mt-1",children:"Add inlet protection, stabilized entrances, etc."})]}):e.jsx("div",{className:"space-y-2",children:j.map(H=>{const O=l===H.id,q=ib.find(Q=>Q.id===H.point_type),W=(q==null?void 0:q.icon)||Fx;return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",O?"border-primary bg-primary/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>c(O?null:H.id),children:[e.jsx("div",{className:"w-6 h-6 rounded flex items-center justify-center",style:{backgroundColor:`${q==null?void 0:q.color}20`},children:e.jsx(W,{className:"w-3.5 h-3.5",style:{color:q==null?void 0:q.color}})}),e.jsx("div",{className:"flex-1",children:e.jsx("div",{className:"text-sm font-medium",children:H.name})}),e.jsx(Mt,{variant:"outline",className:"text-[10px]",style:{borderColor:q==null?void 0:q.color},children:q==null?void 0:q.label}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:Q=>{Q.stopPropagation(),X(H.id)},children:e.jsx(ja,{className:"w-3.5 h-3.5"})}),O?e.jsx(Cc,{className:"w-4 h-4 text-muted-foreground"}):e.jsx(Oa,{className:"w-4 h-4 text-muted-foreground"})]}),O&&e.jsxs("div",{className:"p-3 pt-0 space-y-3 border-t",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Name"}),e.jsx(be,{type:"text",value:H.name,onChange:Q=>D(H.id,{name:Q.target.value}),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Type"}),e.jsxs(rt,{value:H.point_type,onValueChange:Q=>{D(H.id,{point_type:Q})},children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:ib.map(Q=>{const Z=Q.icon;return e.jsx(le,{value:Q.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"w-3.5 h-3.5",style:{color:Q.color}}),e.jsx("span",{children:Q.label})]})},Q.id)})})]})]})]})]},H.id)})}),j.length>0&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg text-xs space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Control Points:"}),e.jsx("span",{className:"font-medium",children:j.length})]}),e.jsxs("div",{className:"pt-1 border-t",children:[e.jsx("span",{className:"text-muted-foreground",children:"By Type:"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:ib.map(H=>{const O=J[H.id]||0;if(O===0)return null;const q=H.icon;return e.jsxs(Mt,{variant:"outline",className:"text-[10px]",style:{borderColor:H.color},children:[e.jsx(q,{className:"w-3 h-3 mr-1",style:{color:H.color}}),O]},H.id)})})]})]})]})]})})}const F2=[{value:"bike_rack",label:"Bike Rack"},{value:"bench",label:"Bench"},{value:"trash_receptacle",label:"Trash Receptacle"},{value:"ev_charging",label:"EV Charging Station"},{value:"planter",label:"Planter"}],e$=[{value:"metal",label:"Metal"},{value:"wood",label:"Wood"},{value:"concrete",label:"Concrete"},{value:"recycled_plastic",label:"Recycled Plastic"}],t$=[{value:"standard",label:"Standard"},{value:"recycling",label:"Recycling"},{value:"combo",label:"Combo (Trash + Recycling)"}],s$=[{value:"small",label:"Small (2-3 ft)"},{value:"medium",label:"Medium (4-6 ft)"},{value:"large",label:"Large (7+ ft)"}
761],n$=({overlay:t,onUpdate:s})=>{var j;const n=((j=t.style)==null?void 0:j.siteAmenities)||[],a=y=>{s({style:{...t.style||{},siteAmenities:y}})},l=()=>{const y={id:crypto.randomUUID(),name:`Amenity ${n.length+1}`,type:"bike_rack",rackCount:10,covered:!1};a([...n,y])},c=(y,x)=>{a(n.map(v=>v.id===y?{...v,...x}:v))},u=y=>{a(n.filter(x=>x.id!==y))},i=y=>{switch(y){case"bike_rack":return{rackCount:10,covered:!1};case"bench":return{seatCount:4,benchMaterial:"metal"};case"trash_receptacle":return{receptacleType:"standard"};case"ev_charging":return{portCount:2,chargerLevel:"2"};case"planter":return{planterSize:"medium",plantType:""};default:return{}}},_=n.reduce((y,x)=>(y[x.type]=(y[x.type]||0)+1,y),{});return e.jsxs("div",{className:"space-y-4",children:[n.length>0&&e.jsxs("div",{className:"text-xs text-muted-foreground bg-muted/50 p-2 rounded space-y-1",children:[e.jsx("div",{className:"font-medium",children:"Amenity Inventory:"}),Object.entries(_).map(([y,x])=>{var v;return e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{children:[((v=F2.find(C=>C.value===y))==null?void 0:v.label)||y,":"]}),e.jsx("span",{children:x})]},y)})]}),e.jsx("div",{className:"space-y-3",children:n.map((y,x)=>e.jsxs("div",{className:"border rounded-lg p-3 space-y-3 bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["#",x+1]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>u(y.id),children:e.jsx(wr,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(B,{className:"text-xs",children:"Name"}),e.jsx(be,{value:y.name,onChange:v=>c(y.id,{name:v.target.value}),className:"h-8 text-xs"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(B,{className:"text-xs",children:"Type"}),e.jsxs(rt,{value:y.type,onValueChange:v=>c(y.id,{type:v,...i(v)}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:F2.map(v=>e.jsx(le,{value:v.value,children:v.label},v.value))})]})]}),y.type==="bike_rack"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Rack Count"}),e.jsx(be,{type:"number",min:1,value:y.rackCount||10,onChange:v=>c(y.id,{rackCount:parseInt(v.target.value)||10}),className:"h-8 text-xs"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-4",children:[e.jsx(kt,{checked:y.covered||!1,onCheckedChange:v=>c(y.id,{covered:v})}),e.jsx(B,{className:"text-xs",children:"Covered"})]})]}),y.type==="bench"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Seat Count"}),e.jsx(be,{type:"number",min:1,value:y.seatCount||4,onChange:v=>c(y.id,{seatCount:parseInt(v.target.value)||4}),className:"h-8 text-xs"})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Material"}),e.jsxs(rt,{value:y.benchMaterial||"metal",onValueChange:v=>c(y.id,{benchMaterial:v}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:e$.map(v=>e.jsx(le,{value:v.value,children:v.label},v.value))})]})]})]}),y.type==="trash_receptacle"&&e.jsxs("div",{className:"col-span-2",children:[e.jsx(B,{className:"text-xs",children:"Receptacle Type"}),e.jsxs(rt,{value:y.receptacleType||"standard",onValueChange:v=>c(y.id,{receptacleType:v}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:t$.map(v=>e.jsx(le,{value:v.value,children:v.label},v.value))})]})]}),y.type==="ev_charging"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Port Count"}),e.jsx(be,{type:"number",min:1,value:y.portCount||2,onChange:v=>c(y.id,{portCount:parseInt(v.target.value)||2}),className:"h-8 text-xs"})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Charger Level"}),e.jsxs(rt,{value:y.chargerLevel||"2",onValueChange:v=>c(y.id,{chargerLevel:v}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"2",children:"Level 2 (240V)"}),e.jsx(le,{value:"3",children:"Level 3 (DC Fast)"})]})]})]})]}),y.type==="planter"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Size"}),e.jsxs(rt,{value:y.planterSize||"medium",onValueChange:v=>c(y.id,{planterSize:v}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:s$.map(v=>e.jsx(le,{value:v.value,children:v.label},v.value))})]})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Plant Type"}),e.jsx(be,{value:y.plantType||"",onChange:v=>c(y.id,{plantType:v.target.value}),placeholder:"e.g., Ornamental grass",className:"h-8 text-xs"})]})]})]})]},y.id))}),e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full",onClick:l,children:[e.jsx(tr,{className:"h-3 w-3 mr-1"}),"Add Amenity"]})]})},a$=[{value:"cut",label:"Cut (Excavation)"},{value:"fill",label:"Fill"},{value:"level",label:"Level / Grade"}],r$=({overlay:t,onUpdate:s})=>{var x;const n=((x=t.style)==null?void 0:x.grading)||{zones:[],highPointElevation:void 0,lowPointElevation:void 0},a=v=>{s({style:{...t.style||{},grading:{...n,...v}}})},l=()=>{const v={id:crypto.randomUUID(),name:`Zone ${n.zones.length+1}`,type:"cut",averageDepthFt:2,areaSqft:5e3};a({zones:[...n.zones,v]})},c=(v,C)=>{a({zones:n.zones.map(P=>P.id===v?{...P,...C}:P)})},u=v=>{a({zones:n.zones.filter(C=>C.id!==v)})},i=(v,C)=>Math.round(v*C/27),_=n.zones.filter(v=>v.type==="cut").reduce((v,C)=>v+i(C.areaSqft,C.averageDepthFt),0),j=n.zones.filter(v=>v.type==="fill").reduce((v,C)=>v+i(C.areaSqft,C.averageDepthFt),0),y=_-j;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"High Point (ft)"}),e.jsx(be,{type:"number",value:n.highPointElevation??"",onChange:v=>a({highPointElevation:v.target.value?parseFloat(v.target.value):void 0}),placeholder:"e.g., 425.5",className:"h-8 text-xs"})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Low Point (ft)"}),e.jsx(be,{type:"number",value:n.lowPointElevation??"",onChange:v=>a({lowPointElevation:v.target.value?parseFloat(v.target.value):void 0}),placeholder:"e.g., 412.0",className:"h-8 text-xs"})]})]}),n.zones.length>0&&e.jsxs("div",{className:"text-xs text-muted-foreground bg-muted/50 p-2 rounded space-y-1",children:[e.jsx("div",{className:"font-medium",children:"Earthwork Summary:"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Total Cut
761:"}),e.jsxs("span",{children:[_.toLocaleString()," CY"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Total Fill:"}),e.jsxs("span",{children:[j.toLocaleString()," CY"]})]}),e.jsxs("div",{className:"flex justify-between font-medium border-t pt-1 mt-1",children:[e.jsx("span",{children:"Net Balance:"}),e.jsxs("span",{className:y>0?"text-amber-600":y<0?"text-blue-600":"",children:[y>0?"+":"",y.toLocaleString()," CY",y>0?" (Export)":y<0?" (Import)":" (Balanced)"]})]}),n.highPointElevation!==void 0&&n.lowPointElevation!==void 0&&e.jsxs("div",{className:"flex justify-between pt-1",children:[e.jsx("span",{children:"Relief:"}),e.jsxs("span",{children:[(n.highPointElevation-n.lowPointElevation).toFixed(1)," ft"]})]})]}),e.jsx("div",{className:"space-y-3",children:n.zones.map((v,C)=>{const P=i(v.areaSqft,v.averageDepthFt);return e.jsxs("div",{className:"border rounded-lg p-3 space-y-3 bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["#",C+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[P.toLocaleString()," CY"]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>u(v.id),children:e.jsx(wr,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(B,{className:"text-xs",children:"Zone Name"}),e.jsx(be,{value:v.name,onChange:I=>c(v.id,{name:I.target.value}),className:"h-8 text-xs"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(B,{className:"text-xs",children:"Zone Type"}),e.jsxs(rt,{value:v.type,onValueChange:I=>c(v.id,{type:I}),children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:a$.map(I=>e.jsx(le,{value:I.value,children:I.label},I.value))})]})]}),e.jsxs("div",{children:[e.jsxs(B,{className:"text-xs",children:[v.type==="cut"?"Avg Cut Depth":v.type==="fill"?"Avg Fill Height":"Depth"," (ft)"]}),e.jsx(be,{type:"number",min:0,step:.5,value:v.averageDepthFt,onChange:I=>c(v.id,{averageDepthFt:parseFloat(I.target.value)||0}),className:"h-8 text-xs"})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Area (SF)"}),e.jsx(be,{type:"number",min:0,value:v.areaSqft,onChange:I=>c(v.id,{areaSqft:parseInt(I.target.value)||0}),className:"h-8 text-xs"})]})]})]},v.id)})}),e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full",onClick:l,children:[e.jsx(tr,{className:"h-3 w-3 mr-1"}),"Add Grading Zone"]})]})},lb=[{id:"accent",label:"Accent Wall",description:"Low decorative wall"},{id:"screen",label:"Screen Wall",description:"Taller screening wall"},{id:"knee_wall",label:"Knee Wall",description:"Seat-height wall"}],z2=[{id:"masonry",label:"Masonry"},{id:"stone_veneer",label:"Stone Veneer"},{id:"stucco",label:"Stucco"},{id:"split_face_cmu",label:"Split-Face CMU"}],i$=[{id:"precast",label:"Precast"},{id:"stone",label:"Stone"},{id:"none",label:"None"}],o$={name:"Decorative Wall",wall_type:"accent",material:"masonry",height_ft:3,cap_style:"precast",has_pilasters:!1,pilaster_spacing_ft:12,has_integrated_lighting:!1};function l$({overlay:t,onUpdate:s}){const[n,a]=k.useState(null),l=t.style||{},c=l.decorativeWalls||[],u=y=>{s({style:{...l,decorativeWalls:y}})},i=()=>{const y={...o$,id:crypto.randomUUID(),name:`Decorative Wall ${c.length+1}`};u([...c,y]),a(y.id)},_=(y,x)=>{u(c.map(v=>v.id===y?{...v,...x}:v))},j=y=>{u(c.filter(x=>x.id!==y)),n===y&&a(null)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full text-xs",onClick:i,children:[e.jsx(tr,{className:"w-3.5 h-3.5 mr-1"}),"Add Decorative Wall"]}),c.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(Uw,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No decorative walls defined"}),e.jsx("p",{className:"text-xs mt-1",children:"Add accent walls for retail entries and screening"})]}):e.jsx("div",{className:"space-y-2",children:c.map(y=>{var C;const x=n===y.id,v=lb.find(P=>P.id===y.wall_type);return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",x?"border-primary bg-primary/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>a(x?null:y.id),children:[e.jsx(Uw,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:y.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[v==null?void 0:v.label," • ",
761y.height_ft,"′ tall • ",(C=z2.find(P=>P.id===y.material))==null?void 0:C.label]})]}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:P=>{P.stopPropagation(),j(y.id)},children:e.jsx(ja,{className:"w-3.5 h-3.5"})}),x?e.jsx(Cc,{className:"w-4 h-4 text-muted-foreground"}):e.jsx(Oa,{className:"w-4 h-4 text-muted-foreground"})]}),x&&e.jsxs("div",{className:"p-3 pt-0 space-y-3 border-t",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Name"}),e.jsx(be,{type:"text",value:y.name,onChange:P=>_(y.id,{name:P.target.value}),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Wall Type"}),e.jsxs(rt,{value:y.wall_type,onValueChange:P=>_(y.id,{wall_type:P}),children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:lb.map(P=>e.jsx(le,{value:P.id,children:P.label},P.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Material"}),e.jsxs(rt,{value:y.material,onValueChange:P=>_(y.id,{material:P}),children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:z2.map(P=>e.jsx(le,{value:P.id,children:P.label},P.id))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Height (ft)"}),e.jsx(be,{type:"number",value:y.height_ft,onChange:P=>_(y.id,{height_ft:parseFloat(P.target.value)||3}),className:"h-8 text-sm",min:2,max:6})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Cap Style"}),e.jsxs(rt,{value:y.cap_style,onValueChange:P=>_(y.id,{cap_style:P}),children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:i$.map(P=>e.jsx(le,{value:P.id,children:P.label},P.id))})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Pilasters"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Vertical columns at intervals"})]}),e.jsx(kt,{checked:y.has_pilasters,onCheckedChange:P=>_(y.id,{has_pilasters:P})})]}),y.has_pilasters&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Pilaster Spacing (ft)"}),e.jsx(be,{type:"number",value:y.pilaster_spacing_ft,onChange:P=>_(y.id,{pilaster_spacing_ft:parseFloat(P.target.value)||12}),className:"h-8 text-sm",min:8,max:20})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Integrated Lighting"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Low-voltage accent lights in cap"})]}),e.jsx(kt,{checked:y.has_integrated_lighting,onCheckedChange:P=>_(y.id,{has_integrated_lighting:P})})]})]})]},y.id)})}),c.length>0&&e.jsxs("div",{className:"p-3 bg-primary/10 rounded-lg text-xs space-y-1 border border-primary/20",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Walls:"}),e.jsx("span",{className:"font-medium",children:c.length})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"By Type:"}),e.jsx("div",{className:"flex gap-1",children:lb.map(y=>{const x=c.filter(v=>v.wall_type===y.id).length;return x===0?null:e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:[y.label," ",x]},y.id)})})]})]})]})}const O2=[{id:"aluminum",label:"Aluminum"},{id:"fiberglass",label:"Fiberglass"},{id:"steel",label:"Steel"}],B2=[{id:"satin",label:"Satin"},{id:"bronze",label:"Bronze"},{id:"white",label:"White"},{id:"black",label:"Black"}],c$=[{id:"ground_sleeve",label:"Ground Sleeve"},{id:"shoe_base",label:"Shoe Base"}],d$=[{id:"ground_spot",label:"Ground Spot"},{id:"internal",label:"Internal Halyard"}],u$={name:"Flagpole",height_ft:25,material:"aluminum",finish:"satin",foundation:"ground_sleeve",has_lighting:!0,light_type:"ground_spot",has_outrigger:!1};function h$({overlay:t,onUpdate:s}){const[n,a]=k.useState(null),l=t.style||{},c=l.flagpoles||[],u=y=>{s({style:{...l,flagpoles:y}})},i=()=>{const y={...u$,id:crypto.randomUUID(),name:`Flagpole ${c.length+1}`};u([...c,y]),a(y.id)},_=(y,x)=>{u(c.map(v=>v.id===y?{...v,...x}:v))},j=y=>{u(c.filter(x=>x.id!==y)),n===y&&a(null)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full text-xs",onClick:i,children:[e.jsx(tr,{className:"w-3.5 h-3.5 mr-1"}),"Add Flagpole"]}),c.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(sN,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No flagpoles defined"}),e.jsx("p",{className:"text-xs mt-1",children:"Add flagpoles for retail entries and corporate sites"})]}):e.jsx("div",{className:"space-y-2",children:c.map(y=>{var v,C;const x=n===y.id;return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",x?"border-primary bg-primary/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>a(x?null:y.id),children:[e.jsx(sN,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:y.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[y.height_ft,"′ • ",(v=O2.find(P=>P.id===y.material))==null?void 0:v.label," • ",(C=B2.find(P=>P.id===y.finish))==null?void 0:C.label]})]}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:P=>{P.stopPropagation(),j(y.id)},children:e.jsx(ja,{className:"w-3.5 h-3.5"})}),x?e.jsx(Cc,{className:"w-4 h-4 text-muted-foreground"}):e.jsx(Oa,{className:"w-4 h-4 text-muted-foreground"})]}),x&&e.jsxs("div",{className:"p-3 pt-0 space-y-3 border-t",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Name"}),e.jsx(be,{type:"text",value:y.name,onChange:P=>_(y.id,{name:P.target.value}),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Pole Height (ft)"}),e.jsx(be,{type:"number",value:y.height_ft,onChange:P=>_(y.id,{height_ft:parseFloat(P.target.value)||25}),className:"h-8 text-sm",min:20,max:80})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Material"}),e.jsxs(rt,{value:y.material,onValueChange:P=>_(y.id,{material:P}),children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:O2.map(P=>e.jsx(le,{value:P.id,children:P.label},P.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Finish"}),e.jsxs(rt,{value:y.finish,onValueChange:P=>_(y.id,{finish:P}),children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:B2.map(P=>e.jsx(le,{value:P.id,children:P.label},P.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Foundation Type"}),e.jsxs(rt,{value:y.foundation,onValueChange:P=>_(y.id,{foundation:P}),children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:c$.map(P=>e.jsx(le,{value:P.id,children:P.label},P.id))})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Lighting"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Ground spot or internal halyard light"})]}),e.jsx(kt,{checked:y.has_lighting,onCheckedChange:P=>_(y.id,{has_lighting:P})})]}),y.has_lighting&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Light Type"}),e.jsxs(rt,{value:y.light_type,onValueChange:P=>_(y.id,{light_type:P}),children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:d$.map(P=>e.jsx(le,{value:P.id,children:P.label},P.id))})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Outrigger Arms"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"For banner display"})]}),e.jsx(kt,{checked:y.has_outrigger,onCheckedChange:P=>_(y.id,{has_outrigger:P})})]})]})]},y.id)})}),c.length>0&&e.jsxs("div",{className:"p-3 bg-primary/10 rounded-lg text-xs space-y-1 border border-primary/20",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Flagpoles:"}),e.jsx("span",{className:"font-medium",children:c.length})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Avg Height:"}),e.jsxs("span",{className:"font-mono",children:[Math.round(c.reduce((y,x)=>y+x.height_ft,0)/c.length),"′"]})]})]})]})}const cb=[{id:"entry_planting",label:"Entry Planting",description:"Accent planting beds"},{id:"water_feature",label:"Water Feature",description:"Fountain or cascading wall"},{id:"boulder_grouping",label:"Boulder Grouping",description:"Decorative boulders"},{id:"entry_column",label:"Entry Column",description:"Decorative pillars"}],m$=[{id:"tropical",label:"Tropical"},{id:"desert",label:"Desert"},{id:"temperate",label:"Temperate"},{id:"evergreen",label:"Evergreen"}],f$=[{id:"fountain",label:"Fountain"},{id:"cascading_wall",label:"Cascading Wall"},{id:"reflecting_pool",label:"Reflecting Pool"}],p$=[{id:"stone",label:"Stone"},{id:"brick",label:"Brick"},{id:"stucco",label:"Stucco"}
761],g$={name:"Entry Feature",feature_type:"entry_planting",width_ft:12,depth_ft:8,has_uplighting:!0,plant_palette:"temperate",water_type:"fountain",column_material:"stone",column_height_ft:6};function x$({overlay:t,onUpdate:s}){const[n,a]=k.useState(null),l=t.style||{},c=l.landscapeEntryFeatures||[],u=y=>{s({style:{...l,landscapeEntryFeatures:y}})},i=()=>{const y={...g$,id:crypto.randomUUID(),name:`Entry Feature ${c.length+1}`};u([...c,y]),a(y.id)},_=(y,x)=>{u(c.map(v=>v.id===y?{...v,...x}:v))},j=y=>{u(c.filter(x=>x.id!==y)),n===y&&a(null)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full text-xs",onClick:i,children:[e.jsx(tr,{className:"w-3.5 h-3.5 mr-1"}),"Add Entry Feature"]}),c.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground text-sm",children:[e.jsx(Ob,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No entry features defined"}),e.jsx("p",{className:"text-xs mt-1",children:"Add decorative landscape treatments at site entries"})]}):e.jsx("div",{className:"space-y-2",children:c.map(y=>{const x=n===y.id,v=cb.find(C=>C.id===y.feature_type);return e.jsxs("div",{className:fs("border rounded-lg overflow-hidden transition-colors",x?"border-green-500 bg-green-500/5":"bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 cursor-pointer hover:bg-muted/50",onClick:()=>a(x?null:y.id),children:[e.jsx(Ob,{className:"w-4 h-4 text-green-600"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:y.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[v==null?void 0:v.label," • ",
761y.width_ft,"′ × ",y.depth_ft,"′"]})]}),e.jsx(Mt,{variant:"outline",className:"text-[10px]",children:v==null?void 0:v.label}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:C=>{C.stopPropagation(),j(y.id)},children:e.jsx(ja,{className:"w-3.5 h-3.5"})}),x?e.jsx(Cc,{className:"w-4 h-4 text-muted-foreground"}):e.jsx(Oa,{className:"w-4 h-4 text-muted-foreground"})]}),x&&e.jsxs("div",{className:"p-3 pt-0 space-y-3 border-t",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Name"}),e.jsx(be,{type:"text",value:y.name,onChange:C=>_(y.id,{name:C.target.value}),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Feature Type"}),e.jsxs(rt,{value:y.feature_type,onValueChange:C=>_(y.id,{feature_type:C}),children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:cb.map(C=>e.jsx(le,{value:C.id,children:e.jsxs("div",{children:[e.jsx("span",{children:C.label}),e.jsxs("span",{className:"text-muted-foreground ml-1 text-xs",children:["— ",C.description]})]})},C.id))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Width (ft)"}),e.jsx(be,{type:"number",value:y.width_ft,onChange:C=>_(y.id,{width_ft:parseFloat(C.target.value)||12}),className:"h-8 text-sm",min:6,max:30})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Depth (ft)"}),e.jsx(be,{type:"number",value:y.depth_ft,onChange:C=>_(y.id,{depth_ft:parseFloat(C.target.value)||8}),className:"h-8 text-sm",min:4,max:20})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Uplighting"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Accent lighting for nighttime visibility"})]}),e.jsx(kt,{checked:y.has_uplighting,onCheckedChange:C=>_(y.id,{has_uplighting:C})})]}),y.feature_type==="entry_planting"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Plant Palette"}),e.jsxs(rt,{value:y.plant_palette||"temperate",onValueChange:C=>_(y.id,{plant_palette:C}),children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:m$.map(C=>e.jsx(le,{value:C.id,children:C.label},C.id))})]})]}),y.feature_type==="water_feature"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Water Type"}),e.jsxs(rt,{value:y.water_type||"fountain",onValueChange:C=>_(y.id,{water_type:C}),children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:f$.map(C=>e.jsx(le,{value:C.id,children:C.label},C.id))})]})]}),y.feature_type==="entry_column"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Column Material"}),e.jsxs(rt,{value:y.column_material||"stone",onValueChange:C=>_(y.id,{column_material:C}),children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:p$.map(C=>e.jsx(le,{value:C.id,children:C.label},C.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(B,{className:"text-xs",children:"Column Height (ft)"}),e.jsx(be,{type:"number",value:y.column_height_ft||6,onChange:C=>_(y.id,{column_height_ft:parseFloat(C.target.value)||6}),className:"h-8 text-sm",min:4,max:8})]})]})]})]},y.id)})}),c.length>0&&e.jsxs("div",{className:"p-3 bg-green-500/10 rounded-lg text-xs space-y-1 border border-green-500/20",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Features:"}),e.jsx("span",{className:"font-medium",children:c.length})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"By Type:"}),e.jsx("div",{className:"flex gap-1 flex-wrap",children:cb.map(y=>{const x=c.filter(v=>v.feature_type===y.id).length;return x===0?null:e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:[y.label," ",x]},y.id)})})]})]})]})}const _$=["easement","stormwater","landscape_buffer","utility_corridor","no_build_zone","floodplain","retaining_wall","erosion_control"];function y$({overlay:t,allOverlays:s,ruleset:n}){const a=k.useMemo(()=>{var D;const l=t.calculated_area_sqft||xg(t.geometry||[]);if(l<=0)return null;
761let c=0;if(t.setback_geometry){const X=Df(t.setback_geometry);if((D=X==null?void 0:X.innerPolygon)!=null&&D[0]){const K=X.innerPolygon[0].map(J=>({lat:J[1],lng:J[0]})),te=xg(K);c=Math.max(0,l-te)}}const u=s.filter(X=>X.parent_overlay_id===t.id),i=[];c>0&&i.push({label:"Setbacks",sqft:c,color:"hsl(var(--primary))"});const _={};for(const X of u){const K=X.layer_type||"";if(_$.includes(K)){const te=X.calculated_area_sqft||xg(X.geometry||[]);if(te>0){const J=K.replace(/_/g," ").replace(/\b\w/g,H=>H.toUpperCase());_[J]=(_[J]||0)+te}}}const j=["hsl(var(--destructive))","#eab308","#8b5cf6","#06b6d4","#ec4899","#6b7280"];let y=0;for(const[X,K]of Object.entries(_))i.push({label:X,sqft:K,color:j[y%j.length]}),y++;const x=i.reduce((X,K)=>X+K.sqft,0),v=Math.max(0,l-x),C=l/43560,P=v/43560,I=v*(n.building.max_coverage_pct/100),z=n.building.max_far?l*n.building.max_far:null,F=n.parking.ratio>0?Math.ceil(I/1e3*n.parking.ratio):0;return{grossSqft:Math.round(l),grossAcres:C.toFixed(2),deductions:i,totalDeductions:Math.round(x),netBuildable:Math.round(v),netAcres:P.toFixed(2),netPct:Math.round(v/l*100),maxBuildingFootprint:Math.round(I),maxFarCapacity:z?Math.round(z):null,parkingRequired:F,coveragePct:n.building.max_coverage_pct}},[t,s,n]);return a?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Net Buildable"}),e.jsxs("span",{className:"font-mono font-medium text-primary",children:[a.netPct,"%"]})]}),e.jsx(Ay,{value:a.netPct,className:"h-2"})]}),e.jsxs("div",{className:"space-y-1.5 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Gross Site Area"}),e.jsxs("span",{className:"font-mono",children:[cu(a.grossSqft)," sf (",a.grossAcres," ac)"]})]}),a.deductions.map((l,c)=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2 h-2 rounded-full inline-block",style:{backgroundColor:l.color}}),e.jsx("span",{className:"text-muted-foreground",children:l.label})]}),e.jsxs("span",{className:"font-mono text-destructive",children:["−",cu(Math.round(l.sqft))," sf"]})]},c)),e.jsxs("div",{className:"border-t border-border pt-1.5 flex justify-between font-medium",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ci,{className:"w-3 h-3 text-primary"}),"Net Buildable Area"]}),e.jsxs("span",{className:"font-mono text-primary",children:[cu(a.netBuildable)," sf (",a.netAcres," ac)"]})]})]}),e.jsxs("div",{className:"p-2.5 bg-muted/50 rounded-lg space-y-1.5 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Max Coverage (",a.coveragePct,"%)"]}),e.jsxs("span",{className:"font-mono",children:[cu(a.maxBuildingFootprint)," sf"]})]}),a.maxFarCapacity&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Max FAR Capacity"}),e.jsxs("span",{className:"font-mono",children:[cu(a.maxFarCapacity)," sf"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Est. Parking Required"}),e.jsxs("span",{className:"font-mono",children:[cu(a.parkingRequired)," spaces"]})]})]})]}):null}const h1={industrial:{setbacks:{front_ft:50,rear_ft:35,side_ft:25,side1_ft:25,side2_ft:25},parking:{ratio:.5,stall_width_ft:9,stall_depth_ft:18,aisle_width_ft:24,ada_ratio:.02,loading_berths_per_sf:5e4},building:{max_height_ft:45,max_coverage_pct:65,min_landscape_pct:10,max_far:.5},circulation:{fire_lane_width_ft:26,drive_aisle_width_ft:26,truck_court_depth_ft:135},industrial:{bay_depth_ft:{min:180,max:250,default:200},clear_height_ft:{min:28,max:40,default:32},dock_spacing_ft:60,column_bay_ft:50,office_pct:{min:3,max:15,default:8}},defaultBlocks:["industrial_warehouse","loading_dock","truck_court","parking_field"],defaultLayers:["site_boundary","buildable_area","building_footprint","truck_court","parking_field","loading_berth"]},distribution:{setbacks:{front_ft:50,rear_ft:50,side_ft:30,side1_ft:30,side2_ft:30},parking:{ratio:.3,stall_width_ft:9,stall_depth_ft:18,aisle_width_ft:24,ada_ratio:.02,loading_berths_per_sf:25e3},building:{max_height_ft:50,max_coverage_pct:60,min_landscape_pct:10,max_far:.45},circulation:{fire_lane_width_ft:26,drive_aisle_width_ft:26,truck_court_depth_ft:185},industrial:{bay_depth_ft:{min:200,max:300,default:240},clear_height_ft:{min:32,max:40,default:36},dock_spacing_ft:55,column_bay_ft:54,office_pct:{min:1,max:5,default:3}},defaultBlocks:["cross_dock_warehouse","loading_dock","truck_court","trailer_parking"],defaultLayers:["site_boundary","buildable_area","building_footprint","truck_court","trailer_parking","loading_berth"]},retail:{setbacks:{front_ft:30,rear_ft:20,side_ft:15,side1_ft:15,side2_ft:15},parking:{ratio:4,stall_width_ft:9.5,stall_depth_ft:19,aisle_width_ft:24,ada_ratio:.04},building:{max_height_ft:35,max_coverage_pct:30,min_landscape_pct:15,max_far:.35},circulation:{fire_lane_width_ft:24,drive_aisle_width_ft:24,sidewalk_width_ft:8},retail:{pad_depth_ft:{min:80,max:150,default:100}
761,storefront_min_ft:25,anchor_min_sf:4e4,inline_bay_width_ft:25},defaultBlocks:["strip_center_straight","anchor_grocery","pad_small","parking_field"],defaultLayers:["site_boundary","buildable_area","building_footprint","parking_field","drive_aisle","sidewalk"]},multifamily:{setbacks:{front_ft:25,rear_ft:20,side_ft:15,side1_ft:15,side2_ft:15},parking:{ratio:1.5,stall_width_ft:9,stall_depth_ft:18,aisle_width_ft:24,ada_ratio:.02},building:{max_height_ft:55,max_coverage_pct:40,min_landscape_pct:20,max_density_units_per_acre:30,min_open_space_pct:20},circulation:{fire_lane_width_ft:24,drive_aisle_width_ft:22,sidewalk_width_ft:6},multifamily:{unit_mix:{studio:.05,one_bed:.4,two_bed:.45,three_bed:.1},avg_unit_sf:950,corridor_width_ft:6,building_depth_ft:{min:50,max:70,default:60},efficiency_ratio:.85,parking_ratio_per_unit:1.5,amenity_sf_per_unit:15},defaultBlocks:["apartment_building","clubhouse","parking_garage","pool_area"],defaultLayers:["site_boundary","buildable_area","building_footprint","parking_field","amenity_area","landscaping"]},office:{setbacks:{front_ft:30,rear_ft:25,side_ft:20,side1_ft:20,side2_ft:20},parking:{ratio:3,stall_width_ft:9,stall_depth_ft:18,aisle_width_ft:24,ada_ratio:.02},building:{max_height_ft:75,max_coverage_pct:35,min_landscape_pct:20,max_far:1},circulation:{fire_lane_width_ft:24,drive_aisle_width_ft:24,sidewalk_width_ft:8},defaultBlocks:["office_building","parking_garage","plaza"],defaultLayers:["site_boundary","buildable_area","building_footprint","parking_field","plaza","landscaping"]},self_storage:{setbacks:{front_ft:25,rear_ft:15,side_ft:10,side1_ft:10,side2_ft:10},parking:{ratio:.25,stall_width_ft:9,stall_depth_ft:18,aisle_width_ft:28,ada_ratio:.02},building:{max_height_ft:45,max_coverage_pct:75,min_landscape_pct:8,max_far:.6},circulation:{fire_lane_width_ft:26,drive_aisle_width_ft:28},defaultBlocks:["storage_building","climate_controlled","office_retail"],defaultLayers:["site_boundary","buildable_area","building_footprint","drive_aisle","office_area"]},mixed_use:{setbacks:{front_ft:10,rear_ft:20,side_ft:10,side1_ft:10,side2_ft:10},parking:{ratio:2.5,stall_width_ft:9,stall_depth_ft:18,aisle_width_ft:24,ada_ratio:.03},building:{max_height_ft:85,max_coverage_pct:75,min_landscape_pct:10,max_far:3},circulation:{fire_lane_width_ft:24,drive_aisle_width_ft:22,sidewalk_width_ft:10},defaultBlocks:["mixed_use_podium","parking_garage","retail_ground_floor"],defaultLayers:["site_boundary","buildable_area","building_footprint","parking_garage","retail_pad","plaza"]},data_center:{setbacks:{front_ft:60,rear_ft:50,side_ft:40,side1_ft:40,side2_ft:40},parking:{ratio:.5,stall_width_ft:9,stall_depth_ft:18,aisle_width_ft:24,ada_ratio:.02},building:{max_height_ft:45,max_coverage_pct:70,min_landscape_pct:10,max_far:.65},circulation:{fire_lane_width_ft:26,drive_aisle_width_ft:26,sidewalk_width_ft:6},defaultBlocks:["data_hall","generator_yard","cooling_yard","substation","guardhouse"],defaultLayers:["site_boundary","buildable_area","building_footprint","generator_yard","cooling_yard","security_fence","parking_field"]},flex:{setbacks:{front_ft:40,rear_ft:25,side_ft:20,side1_ft:20,side2_ft:20},parking:{ratio:2,stall_width_ft:9,stall_depth_ft:18,aisle_width_ft:24,ada_ratio:.02,loading_berths_per_sf:2e4},building:{max_height_ft:35,max_coverage_pct:50,min_landscape_pct:15,max_far:.45},circulation:{fire_lane_width_ft:24,drive_aisle_width_ft:24,truck_court_depth_ft:60},defaultBlocks:["flex_building","loading_area","parking_field"],defaultLayers:["site_boundary","buildable_area","building_footprint","parking_field","loading_berth"]}};function qj(t){const s=t.toLowerCase().replace(/[\s-]/g,"_");return h1[s]||h1.industrial}function v$(t){return[t.lng,t.lat]}function b$(t){return{lat:t[1],lng:t[0]}}function $2(t){const s=t.map(v$);return s.length>0&&(s[0][0]!==s[s.length-1][0]||s[0][1]!==s[s.length-1][1])&&s.push([...s[0]]),Xn([s])}function hy(t){return t.geometry.coordinates[0].slice(0,-1).map(b$)}function bx(t){return t*10.7639}function yf(t){return t*3048e-7}function j$(t){const s=t.geometry.coordinates[0];if(s.length<4)return 0;let n=0,a=0;for(let l=0;l<s.length-1;l++){const c=us(s[l]),u=us(s[l+1]),i=gi(c,u,{units:"kilometers"});i>a&&(a=i,n=Or(c,u))}return n}
761function w$(t,s){switch(t.primary_orientation){case"site_aligned":return j$(s);case"east_west":return 90;case"north_south":default:return 0}}function N$(t,s,n,a){const l=us(t),c=s/2,u=n/2,i=[[-c,-u],[c,-u],[c,u],[-c,u]],_=a*Math.PI/180,j=i.map(([y,x])=>{const v=y*Math.sin(_)+x*Math.cos(_),C=y*Math.cos(_)-x*Math.sin(_),P=Math.sqrt(v*v+C*C);if(P<.1)return t;const I=Math.atan2(v,C)*(180/Math.PI);return On(l,yf(P),I,{units:"kilometers"}).geometry.coordinates});return j.push([...j[0]]),Xn([j])}function V2(t,s,n,a,l,c=.7){const u=N$(t,s,n,a);try{const i=xm(Un([u,l]));if(!i)return null;const _=bx(zr(i)),j=s*n;return _<j*c?null:{polygon:i,sqft:_}}catch{return null}}function db(t,s,n,a){const l=us(t),c=On(l,yf(s),a,{units:"kilometers"});return On(us(c.geometry.coordinates),yf(n),a+90,{units:"kilometers"}).geometry.coordinates}const my={data_hall:{fillColor:"#3b82f6",fillOpacity:.5,strokeColor:"#1d4ed8",strokeWeight:2},warehouse:{fillColor:"#3b82f6",fillOpacity:.4,strokeColor:"#1d4ed8",strokeWeight:2},office:{fillColor:"#8b5cf6",fillOpacity:.4,strokeColor:"#6d28d9",strokeWeight:2},admin:{fillColor:"#8b5cf6",fillOpacity:.4,strokeColor:"#6d28d9",strokeWeight:2},retail:{fillColor:"#f59e0b",fillOpacity:.4,strokeColor:"#d97706",strokeWeight:2},apartment_wing:{fillColor:"#3b82f6",fillOpacity:.4,strokeColor:"#1d4ed8",strokeWeight:2},storage:{fillColor:"#6b7280",fillOpacity:.4,strokeColor:"#374151",strokeWeight:2},flex:{fillColor:"#3b82f6",fillOpacity:.4,strokeColor:"#1d4ed8",strokeWeight:2},generator_yard:{fillColor:"#ef4444",fillOpacity:.3,strokeColor:"#dc2626",strokeWeight:1},cooling_yard:{fillColor:"#06b6d4",fillOpacity:.3,strokeColor:"#0891b2",strokeWeight:1},substation:{fillColor:"#eab308",fillOpacity:.3,strokeColor:"#ca8a04",strokeWeight:1},guardhouse:{fillColor:"#64748b",fillOpacity:.4,strokeColor:"#475569",strokeWeight:2},parking_field:{fillColor:"#6b7280",fillOpacity:.2,strokeColor:"#4b5563",strokeWeight:1},truck_court:{fillColor:"#78716c",fillOpacity:.3,strokeColor:"#57534e",strokeWeight:1},loading_area:{fillColor:"#78716c",fillOpacity:.25,strokeColor:"#57534e",strokeWeight:1},fuel_tank:{fillColor:"#f97316",fillOpacity:.3,strokeColor:"#ea580c",strokeWeight:1},fire_pump:{fillColor:"#ef4444",fillOpacity:.3,strokeColor:"#dc2626",strokeWeight:1}};function ub(t){if(my[t])return my[t];for(const s of Object.keys(my))if(t.includes(s)||s.includes(t))return my[s];return{fillColor:"#6b7280",fillOpacity:.3,strokeColor:"#4b5563",strokeWeight:1}}function k$(t,s){const n=t.geometry.coordinates[0],l=Yo(t).geometry.coordinates,c=(s+180)%360,u=(s-90+360)%360;let i=-1/0,_=l;for(let j=0;j<n.length-1;j++){const y=us(n[j]),x=us(l),v=gi(x,y,{units:"kilometers"})*Math.cos((Or(x,y)-c)*Math.PI/180),C=gi(x,y,{units:"kilometers"})*Math.cos((Or(x,y)-u)*Math.PI/180),P=v+C*.5;P>i&&(i=P,_=n[j])}return _}function C$(t,s,n,a,l){var We,Ee;const c=[],u=[],i=$2(t),_=$2(s),j=bx(zr(i)),y=bx(zr(_)),x=w$(n,_);console.log(`[Procedural] Bearing: ${x.toFixed(1)}°, Buildable: ${Math.round(y).toLocaleString()} SF`);const v=((We=a.circulation)==null?void 0:We.fire_lane_width_ft)||26,C=((Ee=a.circulation)==null?void 0:Ee.truck_court_depth_ft)||0,P=[];let I=0;for(const ve of n.building_modules)for(let we=0;we<ve.count;we++)P.push({type:ve.type,width_ft:ve.width_ft,depth_ft:ve.depth_ft,height_ft:ve.height_ft,index:I++});const z=k$(_,x),F=db(z,v,v,x);let D=0;const X=[];let K=0,te;switch(n.arrangement){case"single_row":te=1;break;case"double_row":te=2;break;case"grid":te=10;break;case"campus":te=6;break;case"L_shape":te=3;break;case"U_shape":te=3;break;default:te=4}let J=0,H=0,O=0;for(;H<P.length&&O<te;){const ve=P.filter((dt,Re)=>Re>=H);if(ve.length===0)break;const we=ve[0].depth_ft;let Ze=0,ke=0;const ze=n.arrangement==="single_row"?P.length:n.arrangement==="double_row"?Math.ceil(P.length/2):Math.ceil(P.length/te);for(let dt=H;dt<P.length&&ke<ze;dt++){const Re=P[dt],qt=Ze+Re.width_ft/2,ft=J+Re.depth_ft/2,Fe=db(F,qt,ft,x),fe=V2(Fe,Re.width_ft,Re.depth_ft,x,_,.7);if(fe){D+=fe.sqft,X.push(fe.polygon),K++;const Qe=Re.type.replace(/_/g," ").replace(/\b\w/g,ht=>ht.toUpperCase());u.push({name:`${Qe} ${String.fromCharCode(65+Re.index)}`,layer_type:"building_footprint",geometry:hy(fe.polygon),height_ft:Re.height_ft,width_ft:Re.width_ft,depth_ft:
761Re.depth_ft,style:ub(Re.type),description:`${Re.width_ft}ft × ${Re.depth_ft}ft ${Qe} (${Math.round(fe.sqft).toLocaleString()} SF)`}),Ze+=Re.width_ft+v,ke++,H=dt+1}else break}if(ke===0){if(J+=100,O++,J>y/100)break;continue}const Ke=C>0?C:v*2;J+=we+Ke,O++}if(H<P.length){const ve=P.length-H;c.push(`${ve} building(s) could not be placed — site too small or irregular`)}console.log(`[Procedural] Placed ${K}/${P.length} buildings, ${Math.round(D).toLocaleString()} SF`);let q=0,W=null;if(X.length>0)try{let ve=[];for(const ke of X){const ze=ke.geometry.coordinates[0];ve=ve.concat(ze)}const we=ve.map(ke=>ke[0]),Ze=ve.map(ke=>ke[1]);W=[Math.min(...we),Math.min(...Ze),Math.max(...we),Math.max(...Ze)]}catch{}for(const ve of n.infrastructure_zones){let we;if(W){const ke=(W[0]+W[2])/2,ze=(W[1]+W[3])/2,Ke=[ke,ze],dt=gi(us([W[0],ze]),us([W[2],ze]),{units:"kilometers"})*3280.84/2,Re=gi(us([ke,W[1]]),us([ke,W[3]]),{units:"kilometers"})*3280.84/2,qt=ve.depth_ft/2+v;switch(ve.placement){case"north":we=db(Ke,0,-(Re+qt),90),we=On(us(Ke),yf(Re+qt),0,{units:"kilometers"}).geometry.coordinates;break;case"south":we=On(us(Ke),yf(Re+qt),180,{units:"kilometers"}).geometry.coordinates;break;case"east":we=On(us(Ke),yf(dt+qt),90,{units:"kilometers"}).geometry.coordinates;break;case"west":we=On(us(Ke),yf(dt+qt),270,{units:"kilometers"}).geometry.coordinates;break;case"between_buildings":we=Ke;break;case"perimeter":default:we=On(us(Ke),yf(dt+qt),135,{units:"kilometers"}).geometry.coordinates;break}}else we=Yo(_).geometry.coordinates;const Ze=V2(we,ve.width_ft,ve.depth_ft,x,_,.5);if(Ze){q+=Ze.sqft;const ke=ve.type.includes("parking")?"parking_zone":ve.type.includes("truck")?"truck_court":ve.type;u.push({name:ve.type.replace(/_/g," ").replace(/\b\w/g,ze=>ze.toUpperCase()),layer_type:ke,geometry:hy(Ze.polygon),width_ft:ve.width_ft,depth_ft:ve.depth_ft,style:ub(ve.type),description:`${ve.width_ft}ft × ${ve.depth_ft}ft ${ve.type.replace(/_/g," ")}`})}}let Q=0,Z=_;try{for(const ve of X){const we=pd(Un([Z,ve]));we&&(Z=we)}}catch{}const oe=bx(zr(Z)),ce=Math.ceil(D/1e3*a.parking.ratio);if(oe>3e3){const ve=a.parking.stall_width_ft,we=a.parking.stall_depth_ft,Ze=a.parking.aisle_width_ft,ke=we*2+Ze;Q=Math.floor(oe*.65/(ve*ke)),Q<ce&&c.push(`Parking shortfall: ${Q} of ${ce} required spaces fit`),u.push({name:"Parking Field",layer_type:"parking_zone",geometry:hy(Z),style:ub("parking_field"),description:`~${Q} spaces (${ve}'×${we}', ${Ze}' aisles)`})}let ae=0;try{const ve=pd(Un([i,_]));ve&&(ae=bx(zr(ve)),u.push({name:"Landscape Buffer",layer_type:"landscape_buffer",geometry:hy(ve),style:{fillColor:"#22c55e",fillOpacity:.2,strokeColor:"#16a34a",strokeWeight:1},description:`${a.building.min_landscape_pct}% landscape requirement`}))}catch{}const ie=j>0?D/j*100:0,de=j>0?D/j:0,ge=u.filter(ve=>ve.layer_type==="building_footprint").length;return ge===0&&c.push("No buildings could be placed within the buildable area. Check setbacks or try a different property type."),{elements:u,metrics:{buildingSqft:Math.round(D),coveragePct:Math.round(ie*10)/10,parkingSpaces:Q,truckCourtSqft:Math.round(q),landscapeSqft:Math.round(ae),far:Math.round(de*100)/100},warnings:c,strategyUsed:{arrangement:n.arrangement,orientation:n.primary_orientation,buildingCount:ge,parkingStrategy:n.parking_strategy}}}function S$(t){return[t.lng,t.lat]}function E$(t){return{lat:t[1],lng:t[0]}}function up(t){const s=t.map(S$);return s.length>0&&(s[0][0]!==s[s.length-1][0]||s[0][1]!==s[s.length-1][1])&&s.push([...s[0]]),Xn([s])}function Xx(t){return t.geometry.coordinates[0].slice(0,-1).map(E$)}function um(t){return t*10.7639}function P$(t,s,n){const a=xp(t),l=a[0],c=a[1],u=a[2],i=a[3],_=n*(s/100),j=Xn([[[l,c],[u,c],[u,i],[l,i],[l,c]]]),y=xm(Un([j,t]));if(!y)return null;const x=um(zr(y));let v=y,C=x;if(C>_){const P=Math.sqrt(_/C),I=Yo(y),z=I.geometry.coordinates[0],F=I.geometry.coordinates[1],D=(u-l)/2*P,X=(i-c)/2*P,K=Xn([[[z-D,F-X],[z+D,F-X],[z+D,F+X],[z-D,F+X],[z-D,F-X]]]),te=xm(Un([K,t]));te&&(v=te,C=um(zr(te)))}return C<100?null:{rect:Xx(v),areaSqft:C}}function T$(t,s,n){if(s<=0)return null;try{const a=up(t),l=s*.3048,c=dl(a,l/1e3,{units:"kilometers"});if(!c)return null;const u=pd(Un([c,a]));if(!u)return null;const i=xm(Un([u,n]));if(!i)return null;const _=um(zr(i));return _<500?null:{geometry:Xx(i),areaSqft:_}}catch{return null}}function L$(t,s,n,a){if(n<=0)return null;try{const l=pd(Un([t,s]));if(!l)return null;const c=um(zr(l)),u=a*(n/100);if(c>=u*.8)return{geometry:Xx(l),areaSqft:c};const i=10*.3048,_=dl(s,-i/1e3,{units:"kilometers"});if(!_)return null;const j=pd(Un([t,_]));return j?{geometry:Xx(j),areaSqft:um(zr(j))}:null}catch{return null}}function q2(t,s){const n=s.parking.stall_depth_ft*2+s.parking.aisle_width_ft;return Math.floor(t*.65/(s.parking.stall_width_ft*n))}function M$(t,s,n,a){var K;const l=[],c=[];if(!t||t.length<3||!s||s.length<3)return{overlays:[],metrics:{buildingSqft:0,coveragePct:0,parkingSpaces:0,truckCourtSqft:0,landscape
761Sqft:0,far:0},warnings:["Insufficient geometry"]};const u=up(t),i=up(s),_=um(zr(u)),j=um(zr(i)),y=P$(i,n.building.max_coverage_pct,_);let x=0,v=null;if(y){x=y.areaSqft,v=y.rect;const te=n.building.max_height_ft||32,J=a.replace(/_/g," ").replace(/\b\w/g,H=>H.toUpperCase());c.push({name:`${J} Building`,layer_type:"building_footprint",geometry:y.rect,height_ft:te,style:{fillColor:"#3b82f6",fillOpacity:.4,strokeColor:"#1d4ed8",strokeWeight:2},description:`Auto-generated ${J} building footprint`})}else l.push("Could not fit a building footprint within constraints");let C=0;if(["industrial","distribution","flex"].includes(a)&&v){const te=((K=n.circulation)==null?void 0:K.truck_court_depth_ft)||135,J=T$(v,te,i);J&&(C=J.areaSqft,c.push({name:"Truck Court",layer_type:"truck_court",geometry:J.geometry,style:{fillColor:"#78716c",fillOpacity:.3,strokeColor:"#57534e",strokeWeight:1},description:`${Math.round(te)}ft deep truck court`}))}let P=0;const I=Math.max(0,j-x-C);if(I>2e3){const te=Math.ceil(x/1e3*n.parking.ratio);P=Math.min(q2(I,n),te>0?Math.max(te,10):q2(I,n)),P<te&&l.push(`Parking shortfall: ${P} of ${te} required`);try{let J=i;if(v){const O=pd(Un([J,up(v)]));O&&(J=O)}um(zr(J))>2e3&&c.push({name:"Parking Field",layer_type:"parking_zone",geometry:Xx(J),style:{fillColor:"#6b7280",fillOpacity:.2,strokeColor:"#4b5563",strokeWeight:1},description:`~${P} spaces`})}catch{l.push("Could not generate parking polygon")}}let z=0;const F=L$(u,i,n.building.min_landscape_pct,_);F&&(z=F.areaSqft,c.push({name:"Landscape Buffer",layer_type:"landscape_buffer",geometry:F.geometry,style:{fillColor:"#22c55e",fillOpacity:.2,strokeColor:"#16a34a",strokeWeight:1},description:`${n.building.min_landscape_pct}% landscape requirement`}));const D=_>0?x/_*100:0,X=_>0?x/_:0;return{overlays:c,metrics:{buildingSqft:Math.round(x),coveragePct:Math.round(D*10)/10,parkingSpaces:P,truckCourtSqft:Math.round(C),landscapeSqft:Math.round(z),far:Math.round(X*100)/100},warnings:l}}function I$(t,s){const n=up(t),a=up(s),l=xp(n),c=us([l[0],l[1]]),u=us([l[2],l[1]]),i=us([l[0],l[3]]),_=gi(c,u,{units:"kilometers"})*3280.84,j=gi(c,i,{units:"kilometers"})*3280.84,y=_>j?Or(c,u):Or(c,i),x=um(zr(a));return{width_ft:Math.round(_),depth_ft:Math.round(j),bearing_deg:Math.round((y%360+360)%360),buildable_sqft:Math.round(x)}}async function A$(t,s,n,a,l){if(!t||t.length<3||!s||s.length<3)return{overlays:[],metrics:{buildingSqft:0,coveragePct:0,parkingSpaces:0,truckCourtSqft:0,landscapeSqft:0,far:0},warnings:["Insufficient geometry"]};const c=up(t),i=um(zr(c))/43560,_=I$(t,s);l==null||l(10),console.log("[AI Layout] Phase 1: Requesting AI strategy...");const{data:j,error:y}=await Fs.functions.invoke("ai-site-layout",{body:{siteGeometry:t,buildableAreaGeometry:s,propertyType:a,ruleset:n,siteAcreage:Math.round(i*100)/100,siteDimensions:_}});if(l==null||l(40),y)throw console.error("AI strategy error:",y),new Error(y.message||"AI layout generation failed");if(j!=null&&j.error)throw new Error(j.error);const x=j;console.log(`[AI Layout] Strategy received: ${x.arrangement}, ${x.primary_orientation}`),console.log(`[AI Layout] ${x.building_modules.length} module types, ${x.infrastructure_zones.length} infra zones`),console.log(`[AI Layout] Parking: ${x.parking_strategy}, Reasoning: ${x.reasoning}`),l==null||l(50),console.log("[AI Layout] Phase 2: Executing procedural placement...");const v=C$(t,s,x,n);l==null||l(85);const C=v.elements.map(F=>({name:F.name,layer_type:F.layer_type,geometry:F.geometry,height_ft:F.height_ft,width_ft:F.width_ft,depth_ft:F.depth_ft,style:F.style,description:F.description})),P=[...v.warnings];x.reasoning&&P.push(`AI Strategy: ${x.reasoning}`);const{metrics:I,strategyUsed:z}=v;return console.log(`[AI Layout] ✅ Final: ${I.buildingSqft.toLocaleString()} SF building, ${I.coveragePct}% coverage, ${I.parkingSpaces} parking`),l==null||l(100),{overlays:C,metrics:I,warnings:P,strategyUsed:z}}function _T(t){return{...t,ruleset:t.ruleset||{},block_catalog:t.block_catalog||[],program:t.program||{}}}const D$=t=>fu({queryKey:["site-plans","development",t],queryFn:async()=>{if(!t)return[];const{data:s,error:n}=await Fs.from("site_plans").select("*").eq("development_id",t).order("created_at",{ascending:!1});if(n)throw n;return(s||[]).map(_T)},enabled:!!t}),R$=()=>{const t=lc();return md({mutationFn:async s=>{const n=qj(s.property_type),a=s.ruleset||{setbacks:n.setbacks,parking:n.parking,building:n.building,circulation:n.circulation},{data:l,error:c}=await Fs.from("site_plans").insert({name:s.name,description:s.description||null,property_type:s.property_type,building_type:s.building_type||null,ruleset:a,block_catalog:[],program:s.program||{}
761,root_overlay_id:s.root_overlay_id||null,development_id:s.development_id||null,existing_product_id:s.existing_product_id||null}).select().single();if(c)throw c;return _T(l)},onSuccess:()=>{t.invalidateQueries({queryKey:["site-plans"]})}})},F$=()=>{const t=lc();return md({mutationFn:async s=>{const{error:n}=await Fs.from("site_plans").delete().eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["site-plans"]})}})};function z$({open:t,onOpenChange:s,variations:n}){if(n.length<2)return null;const a=[{label:"Property Type",key:"property_type",format:c=>{var u;return(u=c.property_type)==null?void 0:u.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())}},{label:"Building SF",key:"target_sf",format:c=>{var u;return cu(((u=c.program)==null?void 0:u.target_sf)||0)}},{label:"Parking Spaces",key:"parking_spaces",format:c=>{var u;return(((u=c.program)==null?void 0:u.parking_spaces)||0).toString()}},{label:"Max Coverage %",key:"max_coverage",format:c=>{var u,i;return`${((i=(u=c.ruleset)==null?void 0:u.building)==null?void 0:i.max_coverage_pct)||"—"}%`}},{label:"Max Height",key:"max_height",format:c=>{var u,i;return`${((i=(u=c.ruleset)==null?void 0:u.building)==null?void 0:i.max_height_ft)||"—"} ft`}},{label:"Max FAR",key:"max_far",format:c=>{var u,i,_;return((_=(i=(u=c.ruleset)==null?void 0:u.building)==null?void 0:i.max_far)==null?void 0:_.toString())||"—"}},{label:"Parking Ratio",key:"parking_ratio",format:c=>{var u,i;return`${((i=(u=c.ruleset)==null?void 0:u.parking)==null?void 0:i.ratio)||"—"} / 1000 sf`}},{label:"Front Setback",key:"front_setback",format:c=>{var u,i;return`${((i=(u=c.ruleset)==null?void 0:u.setbacks)==null?void 0:i.front_ft)||"—"} ft`}},{label:"Rear Setback",key:"rear_setback",format:c=>{var u,i;return`${((i=(u=c.ruleset)==null?void 0:u.setbacks)==null?void 0:i.rear_ft)||"—"} ft`}}],l=c=>c==="target_sf"?Math.max(...n.map(u=>{var i;return((i=u.program)==null?void 0:i.target_sf)||0})):c==="parking_spaces"?Math.max(...n.map(u=>{var i;return((i=u.program)==null?void 0:i.parking_spaces)||0})):-1;return e.jsx(dd,{open:t,onOpenChange:s,children:e.jsxs(ud,{className:"max-w-2xl",children:[e.jsx(Gd,{children:e.jsx(Hd,{children:"Compare Variations"})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border",children:[e.jsx("th",{className:"text-left py-2 pr-4 text-muted-foreground font-medium",children:"Metric"}),n.map(c=>{var u;return e.jsx("th",{className:"text-right py-2 px-3 font-medium",children:e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx("span",{className:"truncate max-w-[120px]",children:c.name}),e.jsx(Mt,{variant:"secondary",className:"text-[9px] h-4",children:(u=c.property_type)==null?void 0:u.replace(/_/g," ")})]})},c.id)})]})}),e.jsx("tbody",{children:a.map(c=>{const u=l(c.key);return e.jsxs("tr",{className:"border-b border-border/50",children:[e.jsx("td",{className:"py-2 pr-4 text-muted-foreground",children:c.label}),n.map(i=>{var y,x;const _=c.format(i),j=u>0&&(c.key==="target_sf"&&(((y=i.program)==null?void 0:y.target_sf)||0)===u||c.key==="parking_spaces"&&(((x=i.program)==null?void 0:x.par
761king_spaces)||0)===u);return e.jsx("td",{className:`py-2 px-3 text-right font-mono ${j?"text-orange-500 font-semibold":""}`,children:_},i.id)})]},c.key)})})]})})]})})}function O$({developmentId:t,rootOverlayId:s,propertyType:n,currentRuleset:a,currentMetrics:l,generatedOverlayIds:c,onLoadVariation:u}){const[i,_]=k.useState(""),[j,y]=k.useState(!1),[x,v]=k.useState(!1),[C,P]=k.useState(null),[I,z]=k.useState([]),[F,D]=k.useState(!1),{data:X=[],isLoading:K}=D$(t),te=R$(),J=F$(),H=X.filter(Q=>Q.root_overlay_id===s),O=async()=>{if(!(!i.trim()||!l)){y(!0);try{await te.mutateAsync({name:i.trim(),property_type:n,ruleset:a,root_overlay_id:s,development_id:t||void 0,program:{target_sf:l.buildingSqft,parking_spaces:l.parkingSpaces}}),Ve.success(`Saved variation "${i.trim()}"`),_(""),v(!1)}catch{Ve.error("Failed to save variation")}finally{y(!1)}}},q=async()=>{if(C)try{await J.mutateAsync(C),Ve.success("Variation deleted")}catch{Ve.error("Failed to delete variation")}finally{P(null)}},W=Q=>{z(Z=>Z.includes(Q)?Z.filter(oe=>oe!==Q):Z.length<3?[...Z,Q]:Z)};return e.jsxs("div",{className:"space-y-3",children:[l&&e.jsx("div",{className:"space-y-2",children:x?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(be,{value:i,onChange:Q=>_(Q.target.value),placeholder:"Variation name...",className:"h-8 text-xs",onKeyDown:Q=>Q.key==="Enter"&&O()}),e.jsx(Le,{size:"sm",className:"h-8",onClick:O,disabled:!i.trim()||j,children:j?e.jsx(Va,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(jg,{className:"w-3.5 h-3.5"})})]}):e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full h-8 text-xs",onClick:()=>v(!0),children:[e.jsx(jg,{className:"w-3.5 h-3.5 mr-1.5"}),"Save as Variation"]})}),K?e.jsx("div",{className:"flex items-center justify-center py-3",children:e.jsx(Va,{className:"w-4 h-4 animate-spin text-muted-foreground"})}):H.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{className:"text-xs text-muted-foreground",children:["Saved Variations (",H.length,")"]}),H.map(Q=>{var oe;const Z=Q.program||{};return e.jsxs("div",{className:"p-2.5 rounded-lg border border-border bg-card hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-xs font-medium truncate flex-1",children:Q.name}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>W(Q.id),title:"Select for comparison",children:e.jsx(Jw,{className:`w-3 h-3 ${I.includes(Q.id)?"text-orange-500":""}`})}),u&&e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>u(Q),title:"Load this variation",children:e.jsx(kc,{className:"w-3 h-3"})}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive hover:text-destructive",onClick:()=>P(Q.id),title:"Delete variation",children:e.jsx(wr,{className:"w-3 h-3"})})]})]}),e.jsxs("div",{className:"flex gap-2 text-[10px] text-muted-foreground",children:[Z.target_sf&&e.jsxs("span",{children:[cu(Z.target_sf)," sf"]}),Z.parking_spaces&&e.jsxs("span",{children:["• ",Z.parking_spaces," spaces"]}),e.jsx(Mt,{variant:"secondary",className:"text-[9px] h-4 px-1.5",children:(oe=Q.property_type)==null?void 0:oe.replace(/_/g," ")})]})]},Q.id)}),I.length>=2&&e.jsxs(Le,{size:"sm",className:"w-full h-8 text-xs",onClick:()=>D(!0),children:[e.jsx(Jw,{className:"w-3.5 h-3.5 mr-1.5"}),"Compare (",I.length,") Variations"]})]}):null,e.jsx(R1,{open:!!C,onOpenChange:()=>P(null),children:e.jsxs(F1,{children:[e.jsxs(z1,{children:[e.jsx(O1,{children:"Delete Variation?"}),e.jsx(B1,{children:"This will permanently remove this saved variation. This action cannot be undone."})]}),e.jsxs($1,{children:[e.jsx(V1,{children:"Cancel"}),e.jsx(q1,{onClick:q,children:"Delete"})]})]})}),F&&e.jsx(z$,{open:F,onOpenChange:D,variations:H.filter(Q=>I.includes(Q.id))})]})}function B$({overlay:t,allOverlays:s,parentOverlay:n,onUpdate:a,isUpdating:l,treeEditMode:c="none",onTreeEditModeChange:u,onStartSignPlacement:i,onCancelSignPlacement:_,signPlacementMode:j=!1,placingSignId:y=null,stallEditorEnabled:x=!1,onToggleStallEditor:v,selectedStallId:C=null,onSelectedStallIdChange:P,onCreateParkingOverlay:I,onCreateChildOverlay:z,developmentId:F}){var vs,$t,Ns,Ts,bs,en,Jt,Vs,ps;const D=oo(t.layer_type)||rm(t.layer_type),X=!!t.parent_overlay_i
761d,K=k.useMemo(()=>t.setback_geometry?Df(t.setback_geometry):null,[t.setback_geometry]),te=k.useMemo(()=>{var ts;const nt=(ts=K==null?void 0:K.innerPolygon)==null?void 0:ts[0];return!nt||nt.length<3?null:nt.map(ds=>({lat:ds[1],lng:ds[0]}))},[K]),[J,H]=k.useState("single_unified"),[O,q]=k.useState(!1),[W,Q]=k.useState(null),[Z,oe]=k.useState(((vs=t.style)==null?void 0:vs.maximizePropertyType)||""),[ce,ae]=k.useState(!1),[ie,de]=k.useState(0),[ge,We]=k.useState(!1),[Ee,ve]=k.useState(null),[we,Ze]=k.useState([]),[ke,ze]=k.useState(!0),Ke=k.useMemo(()=>Z?qj(Z):null,[Z]),dt=k.useMemo(()=>Object.keys(h1).map(nt=>({value:nt,label:nt.replace(/_/g," ").replace(/\b\w/g,ts=>ts.toUpperCase())})),[]),Re=k.useCallback(()=>{if(!Ke)return;const nt=Ke.setbacks,ts=nt.front_ft,ds=nt.rear_ft,Is=nt.side1_ft??nt.side_ft,tn=nt.side2_ft??nt.side_ft;Fe(ts.toString()),Qe(ds.toString()),_t(Is.toString()),as(tn.toString());let wn=null;const Gs=t.geometry;if(Gs&&Gs.length>=3){const Pe=pg(Gs,{front_ft:ts,rear_ft:ds,side1_ft:Is,side2_ft:tn,side_ft:null});wn=gg(Pe)}a({setback_front_ft:ts,setback_rear_ft:ds,setback_side1_ft:Is,setback_side2_ft:tn,setback_geometry:wn,style:{...t.style,maximizePropertyType:Z}}),Ve.success(`Applied ${Z.replace(/_/g," ")} setbacks`)},[Ke,Z,t.style,t.geometry,a]),qt=k.useCallback(async()=>{if(!(!Ke||!te||!z)){ae(!0),de(10),We(!1);try{const nt=t.geometry;Re();let ts;ke?ts=await A$(nt,te,Ke,Z,Gs=>de(Math.min(Gs*.5,50))):(de(20),ts=M$(nt,te,Ke,Z)),de(50),ve(ts);const ds=[],Is=ts.overlays.length;for(let Gs=0;Gs<Is;Gs++){const Ue=ts.overlays[Gs];try{const Pe=await z({name:Ue.name,layer_type:Ue.layer_type,geometry:Ue.geometry,height_ft:Ue.height_ft,style:Ue.style,description:Ue.description,parent_overlay_id:t.id});Pe&&ds.push(Pe)}catch(Pe){console.warn(`Failed to create ${Ue.name}:`,Pe)}de(50+(Gs+1)/Is*45)}Ze(ds),de(100);const tn=ts.warnings.find(Gs=>Gs.startsWith("AI Strategy:"));tn&&Ve.info(tn.replace("AI Strategy: ",""),{duration:8e3});const wn=ts.strategyUsed?`[${ts.strategyUsed.arrangement}/${ts.strategyUsed.orientation}] `:"";ts.warnings.filter(Gs=>!Gs.startsWith("AI Strategy:")).forEach(Gs=>Ve.warning(Gs)),Ve.success(`Generated ${ds.length} layers: ${ts.metrics.buildingSqft.toLocaleString()} sf building, ${ts.metrics.parkingSpaces} parking spaces`)}catch(nt){console.error("Generate layout failed:",nt);const ts=(nt==null?void 0:nt.message)||"Failed to generate layout";ts.includes("Rate limit")||ts.includes("429")?Ve.error("AI rate limit hit. Please wait a moment and try again, or switch to basic engine."):ts.includes("credit")||ts.includes("402")?Ve.error("AI credits exhausted. Switch to basic engine or add credits."):Ve.error(ts)}finally{ae(!1),setTimeout(()=>de(0),1500)}}},[Ke,te,z,t,Z,Re,ke]),[ft,Fe]=k.useState((($t=t.setback_front_ft)==null?void 0:$t.toString())||""),[fe,Qe]=k.useState(((Ns=t.setback_rear_ft)==null?void 0:Ns.toString())||""),[ht,_t]=k.useState(((Ts=t.setback_side1_ft)==null?void 0:Ts.toString())||""),[He,as]=k.useState(((bs=t.setback_side2_ft)==null?void 0:bs.toString())||""),vt=((en=t.style)==null?void 0:en.setbackLineStyle)||"dashed",Xe=((Jt=t.style)==null?void 0:Jt.setbackColor)||"#f97316",Ce=nt=>{a({style:{...t.style,setbackColor:nt}})};k.useEffect(()=>{var nt,ts,ds,Is;Fe(((nt=t.setback_front_ft)==null?void 0:nt.toString())||""),Qe(((ts=t.setback_rear_ft)==null?void 0:ts.toString())||""),_t(((ds=t.setback_side1_ft)==null?void 0:ds.toString())||""),as(((Is=t.setback_side2_ft)==null?void 0:Is.toString())||"")},[t.setback_front_ft,t.setback_rear_ft,t.setback_side1_ft,t.setback_side2_ft]);const Be=nt=>{nt&&(nt==="solid"||nt==="dashed"||nt==="hidden")&&a({style:{...t.style,setbackLineStyle:nt}})},Dt=k.useMemo(()=>s.filter(nt=>nt.parent_overlay_id===t.id),[s,t.id]),Rt=k.useMemo(()=>{if(!te)return null;const nt=xg(te),ts=nt/43560;return{squareFeet:Math.round(nt),acres:ts.toFixed(2)}},[te]),zt=async()=>{try{const nt={front_ft:ft?parseFloat(ft):null,rear_ft:fe?parseFloat(fe):null,side1_ft:ht?parseFloat(ht):null,side2_ft:He?parseFloat(He):null,side_ft:null};let ts=null;const ds=t.geometry;if(ds&&ds.length>=3&&(nt.front_ft||nt.rear_ft||nt.side1_ft||nt.side2_ft)){const Is=pg(ds,nt);ts=gg(Is)}a({setback_front_ft:nt.front_ft,setback_rear_ft:nt.rear_ft,setback_side1_ft:nt.side1_ft,setback_side2_ft:nt.side2_ft,setback_geometry:ts}),Ve.success("Setbacks applied")}catch{Ve.error("Failed to apply setbacks")}},rs=()=>{Fe(""),Qe(""),_t(""),as(""),a({setback_front_ft:null,setback_rear_ft:null,setback_side1_ft:null,setback_side2_ft:null,setback_geometry:null}),Ve.success("Setbacks cleared")},_s=ft||fe||ht||He;return e.jsxs("div",{className:"space-y-6",children:[D&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hd,{className:"w-4 h-4 text-primary"}),e.jsx(B,{className:"text-sm font-medium",children:oo(t.layer_type)?"Site Setbacks":"Property Setbacks"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define setback distances to create the buildable area. Buildings that exceed these constraints will be highlighted in red in 3D view."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Front (ft)"}
761),e.jsx(be,{type:"number",value:ft,onChange:nt=>Fe(nt.target.value),placeholder:"0",className:"h-8",disabled:l})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Rear (ft)"}),e.jsx(be,{type:"number",value:fe,onChange:nt=>Qe(nt.target.value),placeholder:"0",className:"h-8",disabled:l})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Side 1 (ft)"}),e.jsx(be,{type:"number",value:ht,onChange:nt=>_t(nt.target.value),placeholder:"0",className:"h-8",disabled:l})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Side 2 (ft)"}),e.jsx(be,{type:"number",value:He,onChange:nt=>as(nt.target.value),placeholder:"0",className:"h-8",disabled:l})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{onClick:zt,disabled:l||!_s,size:"sm",className:"flex-1",children:"Apply Setbacks"}),_s&&e.jsx(Le,{variant:"outline",onClick:rs,disabled:l,size:"sm",children:e.jsx(wr,{className:"w-3.5 h-3.5"})})]}),Rt&&e.jsxs("div",{className:"p-3 bg-primary/10 rounded-lg border border-primary/20",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-primary font-medium mb-2",children:[e.jsx(hh,{className:"w-3.5 h-3.5"}),"Buildable Area"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Area:"}),e.jsxs("span",{className:"font-mono",children:[Rt.squareFeet.toLocaleString()," sf"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Acres:"}),e.jsxs("span",{className:"font-mono",children:[Rt.acres," ac"]})]})]})]}),_s&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Setback Zone Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ef,{children:[e.jsx(Pf,{asChild:!0,children:e.jsx("button",{className:"w-8 h-8 rounded border border-border shadow-sm cursor-pointer hover:ring-2 hover:ring-primary/50 transition-all",style:{backgroundColor:Xe},"aria-label":"Choose setback color"})}),e.jsx(Tf,{className:"w-auto p-3",align:"start",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Pick a color"}),e.jsx("input",{type:"color",value:Xe,onChange:nt=>Ce(nt.target.value),className:"w-full h-8 cursor-pointer rounded border-0"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 pt-1",children:["#f97316","#ef4444","#eab308","#22c55e","#3b82f6","#8b5cf6","#ec4899","#6b7280"].map(nt=>e.jsx("button",{className:"w-6 h-6 rounded border border-border hover:ring-2 hover:ring-primary/50 transition-all",style:{backgroundColor:nt},onClick:()=>Ce(nt),"aria-label":`Select color ${nt}`},nt))})]})})]}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:Xe})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Buildable Outline Style"}),e.jsxs(q0,{type:"single",value:vt,onValueChange:Be,className:"justify-start",children:[e.jsxs(Vm,{value:"dashed","aria-label":"Dashed line",className:"gap-1.5 text-xs",children:[e.jsx(Mg,{className:"w-3.5 h-3.5"}),"Dashed"]}),e.jsxs(Vm,{value:"solid","aria-label":"Solid line",className:"gap-1.5 text-xs",children:[e.jsx(Om,{className:"w-3.5 h-3.5"}),"Solid"]}),e.jsx(Vm,{value:"hidden","aria-label":"Hidden",className:"gap-1.5 text-xs",children:"Hidden"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"Show Edge Labels"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"F, R, S1, S2 markers on boundaries"})]}),e.jsx(kt,{checked:((Vs=t.style)==null?void 0:Vs.showEdgeLabels)!==!1,onCheckedChange:nt=>{a({style:{...t.style,showEdgeLabels:nt}})},disabled:l})]})]})]}),D&&e.jsx(ns,{title:"Maximize Site",icon:e.jsx(Mf,{className:"w-4 h-4"}),badge:Z?e.jsx(Mt,{variant:"secondary",className:"text-[10px] h-5",children:Z.replace(/_/g," ").replace(/\b\w/g,nt=>nt.toUpperCase())}):null,defaultOpen:!!Z,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Select a property type to auto-generate buildings, parking, and site elements within the buildable envelope."}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(rt,{value:Z,onValueChange:oe,children:[e.jsx(it,{className:"h-8 flex-1",children:e.jsx(ct,{placeholder:"Select property type..."})}),e.jsx(ot,{children:dt.map(nt=>e.jsx(le,{value:nt.value,children:nt.label},nt.value))})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{size:"sm",variant:"outline",className:"h-8 flex-1",onClick:Re,disabled:!Z||l,children:"Apply Setbacks"}),e.jsx(Le,{size:"sm",className:"h-8 flex-1 bg-orange-500 hover:bg-orange-600 text-white",onClick:()=>We(!0),disabled:!Z||l||ce||!te,children:ce?e.jsxs(e.Fragment,{children:[e.jsx(Va,{className:"w-3.5 h-3.5 animate-spin mr-1"})," Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(cN,{className:"w-3.5 h-3.5 mr-1"})," Generate Layout"]})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{className:"text-xs",children:"AI-Powered Layout"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:ke?"Uses AI for realistic building sizes":"Basic geometric placement"})]}),e.jsx(kt,{checked:ke,onCheckedChange:ze,disabled:ce})]}),ie>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ay,{value:ie,className:"h-1.5"}),e.jsx("p",{className:"text-[10px] text-muted-foreground text-center",children:ie<40?"AI planning strategy...":ie<85?"Placing buildings procedurally...":ie<95?"Creating layers...":"Complete!"})]}),Ee&&!ce&&e.jsxs("div",{className:"p-2.5 bg-orange-500/10 rounded-lg border border-orange-500/20 space-y-1.5 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-orange-600 dar
761k:text-orange-400 font-medium",children:[e.jsx(cN,{className:"w-3 h-3"}),Ee.strategyUsed?e.jsxs("span",{children:[Ee.strategyUsed.buildingCount," buildings | ",Ee.strategyUsed.arrangement.replace(/_/g," ")," | ",Ee.metrics.coveragePct,"% coverage"]}):e.jsxs("span",{children:[Ee.overlays.filter(nt=>nt.layer_type==="building_footprint").length," buildings | ",Ee.metrics.coveragePct,"% coverage"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Building:"}),e.jsxs("span",{className:"font-mono",children:[Ee.metrics.buildingSqft.toLocaleString()," sf"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Coverage:"}),e.jsxs("span",{className:"font-mono",children:[Ee.metrics.coveragePct,"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Parking:"}),e.jsxs("span",{className:"font-mono",children:[Ee.metrics.parkingSpaces," spaces"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"FAR:"}),e.jsx("span",{className:"font-mono",children:Ee.metrics.far})]})]}),Ee.warnings.find(nt=>nt.startsWith("AI Strategy:"))&&e.jsxs(wi,{children:[e.jsxs(Ni,{className:"flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors w-full",children:[e.jsx(Oa,{className:"w-3 h-3"}),"AI Reasoning"]}),e.jsx(ki,{children:e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 leading-relaxed",children:(ps=Ee.warnings.find(nt=>nt.startsWith("AI Strategy:")))==null?void 0:ps.replace("AI Strategy: ","")})})]})]}),Ke&&(t.setback_front_ft||t.setback_rear_ft)&&e.jsx(y$,{overlay:t,allOverlays:s,ruleset:Ke}),e.jsx(O$,{developmentId:F||null,rootOverlayId:t.id,propertyType:Z,currentRuleset:{setbacks:Ke==null?void 0:Ke.setbacks,parking:Ke==null?void 0:Ke.parking,building:Ke==null?void 0:Ke.building,circulation:Ke==null?void 0:Ke.circulation},currentMetrics:(Ee==null?void 0:Ee.metrics)||null,generatedOverlayIds:we})]})}),e.jsx(R1,{open:ge,onOpenChange:We,children:e.jsxs(F1,{children:[e.jsxs(z1,{children:[e.jsx(O1,{children:"Generate Site Layout?"}),e.jsxs(B1,{children:["This will auto-place buildings, parking, and site elements as child layers based on the ",e.jsx("strong",{children:Z.replace(/_/g," ")})," ruleset. You can save the result as a variation and regenerate anytime."]})]}),e.jsxs($1,{children:[e.jsx(V1,{children:"Cancel"}),e.jsx(q1,{onClick:qt,children:"Generate"})]})]})}),X&&n&&e.jsxs("div",{className:"space-y-3 p-3 bg-amber-500/10 rounded-lg border border-amber-500/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qd,{className:"w-4 h-4 text-amber-500"}),e.jsx(B,{className:"text-sm font-medium",children:"Parent Property Constraints"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This building is constrained by: ",e.jsx("span",{className:"font-medium text-foreground",children:n.name})]}),n.setback_front_ft||n.setback_rear_ft||n.setback_side1_ft||n.setback_side2_ft?e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[n.setback_front_ft&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Front:"}),e.jsxs("span",{className:"font-mono",children:[n.setback_front_ft," ft"]})]}),n.setback_rear_ft&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Rear:"}),e.jsxs("span",{className:"font-mono",children:[n.setback_rear_ft," ft"]})]}),n.setback_side1_ft&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Side 1:"}),e.jsxs("span",{className:"font-mono",children:[n.setback_side1_ft," ft"]})]}),n.setback_side2_ft&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Side 2:"}),e.jsxs("span",{className:"font-mono",children:[n.setback_side2_ft," ft"]})]})]}):e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No setbacks defined on parent property"}
761),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:"⚠️ Building areas outside constraints will be shown in red in 3D view"})]}),!D&&!X&&t.layer_type!=="parking_field"&&t.layer_type!=="parking_zone"&&e.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[e.jsx(ji,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"Site constraints are available for Site and Property layers."}),e.jsx("p",{className:"text-xs mt-1",children:"Mark this layer as a Site or Property in the Layers tab."})]}),D&&te&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Auto-Generate Parking",icon:e.jsx(fm,{className:"w-4 h-4"}),badge:W?e.jsxs(Mt,{variant:"default",className:"text-[10px] h-5",children:["~",W.estimatedSpaces," spaces"]}):null,defaultOpen:!1,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically generate parking polygons to fill remaining buildable area after subtracting buildings, buffers, stormwater, and other site improvements."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Generation Mode"}),e.jsxs(rt,{value:J,onValueChange:nt=>{H(nt),Q(null)},children:[e.jsx(it,{className:"h-8",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"single_unified",children:"Single Unified Field"}),e.jsx(le,{value:"multiple_zones",children:"Multiple Zones"})]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:J==="single_unified"?"One large parking polygon covering all available space":"Separate parking zones around each obstruction"})]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{if(!te){Ve.error("No buildable area defined. Set setbacks first.");return}const nt=o1(t.id,s,{excludeBuildings:!0,excludeBuffers:!0,excludeStormwater:!0,excludeLandscaping:!0,excludeUtilities:!0,excludeTrash:!0}),ts=Jz(te,nt,J);Q({polygons:ts.polygons,estimatedSpaces:ts.estimatedSpaces,totalArea_sqft:ts.totalArea_sqft,warnings:ts.warnings}),ts.polygons.length===0?Ve.error("No viable parking area found after exclusions"):Ve.success(`Found ${ts.polygons.length} parking zone(s) with ~${ts.estimatedSpaces} spaces`)},disabled:!te,children:[e.jsx(Nf,{className:"w-3.5 h-3.5 mr-2"}),"Preview Parking Areas"]}),W&&W.polygons.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"p-3 bg-primary/10 rounded-lg border border-primary/20",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-primary font-medium mb-2",children:[e.jsx(Ml,{className:"w-3.5 h-3.5"}),"Preview Results"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Zones:"}),e.jsx("span",{className:"font-mono",children:W.polygons.length})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Est. Spaces:"}),e.jsx("span",{className:"font-mono",children:W.estimatedSpaces})]}),e.jsxs("div",{className:"flex justify-between col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Area:"}),e.jsxs("span",{className:"font-mono",children:[Math.round(W.totalArea_sqft).toLocaleString()," sf"]})]})]})]}),W.warnings.length>0&&e.jsx("div",{className:"p-2 bg-amber-500/10 rounded border border-amber-500/20",children:e.jsxs("div",{className:"flex items-start gap-2 text-xs text-amber-600 dark:text-amber-400",children:[e.jsx($y,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("div",{className:"space-y-1",children:W.warnings.map((nt,ts)=>e.jsx("p",{children:nt},ts))})]})}),I&&e.jsx(Le,{size:"sm",className:"w-full",onClick:async()=>{if(!(!W||W.polygons.length===0)){q(!0);try{for(let nt=0;nt<W.polygons.length;nt++){const ts=W.polygons.length>1?`Parking Zone ${nt+1}`:"Parking Field";await I(W.polygons[nt],ts)}Ve.success(`Created ${W.polygons.length} parking zone(s)`),Q(null)}catch{Ve.error("Failed to create parking zones")}finally{q(!1)}}},disabled:O,children:O?e.jsx(e.Fragment,{children:"Creating..."}):e.jsxs(e.Fragment,{children:[e.jsx(fm,{className:"w-3.5 h-3.5 mr-2"}),"Create ",W.polygons.length," Parking Zone",W.polygons.length>
7611?"s":""]})})]})]})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Landscape Buffers",icon:e.jsx(Bx,{className:"w-4 h-4"}),badge:(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.landscapeBuffers,ts=nt?Object.values(nt).filter(Is=>Is==null?void 0:Is.enabled).length:0;return ts>0?e.jsxs(Mt,{variant:"default",className:"text-[10px] h-5",children:[ts," edges"]}):null})(),defaultOpen:!1,children:e.jsx(v8,{overlay:t,onUpdate:a,isUpdating:l,treeEditMode:c,onTreeEditModeChange:u})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Entry / Access Points",icon:e.jsx(pp,{className:"w-4 h-4"}),badge:(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.entryPoints,ts=Array.isArray(nt)?nt.length:0;return ts>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:ts}):null})(),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"p-2 bg-muted/50 rounded-lg border border-muted flex items-start gap-2",children:[e.jsx(hh,{className:"w-4 h-4 text-primary shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-xs",children:[e.jsx("p",{className:"font-medium",children:"Entry points are now configured on Parking layers"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Select a Parking Zone and use the Build tab to configure entry points, fire lanes, and circulation elements."})]})]}),(()=>{var ts;const nt=(ts=t.style)==null?void 0:ts.entryPoints;return!Array.isArray(nt)||nt.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Existing Entry Points (Legacy)"}),e.jsx("div",{className:"space-y-1",children:nt.map(ds=>e.jsxs("div",{className:"flex items-center justify-between p-2 bg-background rounded border text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ml,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{children:ds.name||"Entry Point"})]}),e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:[ds.edge_label||"F"," • ",ds.width_ft,"′"]})]},ds.id))})]})})()]})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Stormwater Detention",icon:e.jsx(Kc,{className:"w-4 h-4"}),badge:(()=>{const nt=Dt.filter(ts=>ts.layer_type==="stormwater").length;return nt>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:nt}):null})(),defaultOpen:!1,children:e.jsx(j8,{overlay:t,childOverlays:Dt,onUpdate:a,isUpdating:l})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Utility Corridors",icon:e.jsx(lm,{className:"w-4 h-4"}),badge:(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.utility_corridors,ts=Array.isArray(nt)?nt.length:0;return ts>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:ts}):null})(),defaultOpen:!1,children:e.jsx(k8,{overlay:t,childOverlays:Dt,onUpdate:a,isUpdating:l})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Monument Signage",icon:e.jsx(Ng,{className:"w-4 h-4"}),badge:(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.monument_signs,ts=Array.isArray(nt)?nt.length:0;return ts>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:ts}):null})(),defaultOpen:!1,children:e.jsx(L8,{overlay:t,onUpdate:a,onStartSignPlacement:i,onCancelSignPlacement:_,signPlacementMode:j,placingSignId:y})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Perimeter Fencing",icon:e.jsx(s_,{className:"w-4 h-4"}),badge:(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.perimeterFencing,ts=nt?Object.values(nt).filter(Is=>Is==null?void 0:Is.enabled).length:0;return ts>0?e.jsxs(Mt,{variant:"default",className:"text-[10px] h-5",children:[ts," edges"]}):null})(),defaultOpen:!1,children:e.jsx(I8,{overlay:t,onUpdate:a})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Retaining Walls",icon:e.jsx(Da,{className:"w-4 h-4"}),badge:(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.retainingWalls,ts=nt?Object.values(nt).filter(Is=>Is==null?void 0:Is.enabled).length:0;return ts>0?e.jsxs(Mt,{variant:"default",className:"text-[10px] h-5",children:[ts," edges"]}):null})(),defaultOpen:!1,children:e.jsx(D8,{overlay:t,onUpdate:a})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Fire Lanes / Emergency Access",icon:e.jsx(ej,{className:"w-4 h-4"}),badge:(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.fireLanes,ts=nt?Object.values(nt).filter(Is=>Is==null?void 0:Is.enabled).length:0;return ts>0?e.jsxs(Mt,{variant:"destructive",className:"text-[10px] h-5",children:[ts," edges"]}):null})(),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"p-2 bg-muted/50 rounded-lg border border-muted flex items-start gap-2",children:[e.jsx(hh,{className:"w-4 h-4 text-destructive shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-xs",children:[e.jsx("p",{className:"font-medium",children:"Fire lanes are now configured on Parking layers"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Select a Parking Zone and use the Build tab to configure fire lanes, hydrant locations, and Knox boxes."})]})]}),(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.fireLanes;if(!nt)return null;const ts=Object.entries(nt).filter(([Is,tn])=>tn==null?void 0:tn.enabled);return ts.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Existing Fire Lanes (Legacy)"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:ts.map(([Is,tn])=>e.jsxs(Mt,{variant:"destructive",className:"text-[10px]",children:[Is," • ",tn.width_ft,"′"]},Is))})]})})()]})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Easements / Right-of-Way",icon:e.jsx(R3,{className:"w-4 h-4"}),badge:(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.easements,ts=nt?Object.values(nt).filter(Is=>Is==null?void 0:Is.enabled).length:0;return ts>0?e.jsxs(Mt,{variant:"secondary",className:"text-[10px] h-5",children:[ts," edges"]}):null})(),defaultOpen:!1,children:e.jsx(F8,{overlay:t,onUpdate:a})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Trash / Recycling Enclosures",icon:e.jsx(wr,{className:"w-4 h-4"}),badge:(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.trashEnclosures,ts=Array.isArray(nt)?nt.length:0;return ts>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:ts}):null})(),defaultOpen:!1,children:e.jsx($8,{overlay:t,onUpdate:a})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Site Lighting / Photometrics",icon:e.jsx(gh,{className:"w-4 h-4"}),badge:(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.siteLighting,ts=Array.isArray(nt)?nt.length:0;return ts>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:ts}):null})(),defaultOpen:!1,children:e.jsx(q8,{overlay:t,onUpdate:a})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Outdoor Storage Areas",icon:e.jsx(yg,{className:"w-4 h-4"}),badge:(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.outdoorStorage,ts=Array.isArray(nt)?nt.length:0;return ts>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:ts}):null})(),defaultOpen:!1,children:e.jsx(Z8,{overlay:t,onUpdate:a})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Hardscape / Paving",icon:e.jsx(zu,{className:"w-4 h-4"}),badge:(()=>{var tn,wn;const nt=(tn=t.style)==null?void 0:tn.hardscape,ts=nt!=null&&nt.sidewalks?Object.values(nt.sidewalks).filter(Gs=>Gs==null?void 0:Gs.enabled).length:0,ds=((wn=nt==null?void 0:nt.plazas)==null?void 0:wn.length)||0,Is=ts+ds;return Is>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:Is}):null})(),defaultOpen:!1,children:e.jsx(K8,{overlay:t,onUpdate:a})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Erosion Control / SWPPP",icon:e.jsx(Ag,{className:"w-4 h-4"}),badge:(()=>{var tn,wn;const nt=(tn=t.style)==null?void 0:tn.erosionControl,ts=nt!=null&&nt.edgeMeasures?Object.values(nt.edgeMeasures).filter(Gs=>Gs==null?void 0:Gs.enabled).length:0,ds=((wn=nt==null?void 0:nt.points)==null?void 0:wn.length)||0,Is=ts+ds;return Is>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:Is}):null})(),defaultOpen:!1,children:e.jsx(U8,{overlay:t,onUpdate:a})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Site Amenities",icon:e.jsx(dS,{className:"w-4 h-4"}),badge:(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.siteAmenities,ts=Array.isArray(nt)?nt.length:0;return ts>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:ts}):null})(),defaultOpen:!1,children:e.jsx(n$,{overlay:t,onUpdate:a})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Grading / Earthwork",icon:e.jsx(Rh,{className:"w-4 h-4"}),badge:(()=>{var ds,Is;const nt=(ds=t.style)==null?void 0:ds.grading,ts=((Is=nt==null?void 0:nt.zones)==null?void 0:Is.length)||0;return ts>0?e.jsxs(Mt,{variant:"default",className:"text-[10px] h-5",children:[ts," zones"]}
761):null})(),defaultOpen:!1,children:e.jsx(r$,{overlay:t,onUpdate:a})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Decorative Site Walls",icon:e.jsx(Da,{className:"w-4 h-4"}),badge:(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.decorativeWalls,ts=Array.isArray(nt)?nt.length:0;return ts>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:ts}):null})(),defaultOpen:!1,children:e.jsx(l$,{overlay:t,onUpdate:a})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Flagpoles",icon:e.jsx(Ng,{className:"w-4 h-4"}),badge:(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.flagpoles,ts=Array.isArray(nt)?nt.length:0;return ts>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:ts}):null})(),defaultOpen:!1,children:e.jsx(h$,{overlay:t,onUpdate:a})}),e.jsx(ks,{})]}),oo(t.layer_type)&&e.jsx(e.Fragment,{children:e.jsx(ns,{title:"Landscape Entry Features",icon:e.jsx(Bx,{className:"w-4 h-4"}),badge:(()=>{var ds;const nt=(ds=t.style)==null?void 0:ds.landscapeEntryFeatures,ts=Array.isArray(nt)?nt.length:0;return ts>0?e.jsx(Mt,{variant:"default",className:"text-[10px] h-5",children:ts}):null})(),defaultOpen:!1,children:e.jsx(x$,{overlay:t,onUpdate:a})})})]})}function Lh({label:t,value:s,unit:n="",highlight:a=!1,status:l}){return e.jsxs("div",{className:`flex items-center justify-between py-1 ${a?"font-medium":""}`,children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[l==="ok"&&e.jsx(bp,{className:"w-3 h-3 text-green-500"}),l==="warning"&&e.jsx(ho,{className:"w-3 h-3 text-amber-500"}),l==="error"&&e.jsx(ho,{className:"w-3 h-3 text-red-500"}),e.jsxs("span",{className:`text-xs font-mono ${a?"text-primary":""}`,children:[s,n&&` ${n}`]})]})]})}function $$({overlay:t,parentProperty:s,parkingLayers:n=[],parkingRequirementSfPerSpace:a=500}){const l=k.useMemo(()=>d8(t,{parentProperty:s,parkingLayers:n,parkingRequirementSfPerSpace:a}),[t,s,n,a]),c=l.parkingDeficit>=0?"ok":l.parkingDeficit>=-10?"warning":"error";return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_g,{className:"w-4 h-4 text-primary"}),e.jsx(B,{className:"text-sm font-medium",children:"Building Metrics"})]}),e.jsxs("div",{className:"space-y-2 p-3 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[e.jsx(Ci,{className:"w-3.5 h-3.5 text-muted-foreground"}),"COVERAGE"]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Lh,{label:"Building Footprint",value:cu(l.buildingFootprintSf),unit:"sf"}),e.jsx(Lh,{label:"Site Area",value:cu(l.siteAreaSf),unit:"sf"}),e.jsx(Lh,{label:"Building Coverage",value:`${l.buildingCoverageRatio}%`,highlight:!0})]})]}),e.jsxs("div",{className:"space-y-2 p-3 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[e.jsx(_g,{className:"w-3.5 h-3.5 text-muted-foreground"}),"FAR (Floor Area Ratio)"]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Lh,{label:"Total GFA",value:cu(l.totalGfa),unit:"sf"}),e.jsx(Lh,{label:"FAR",value:l.far.toFixed(2),highlight:!0})]})]}),e.jsxs("div",{className:"space-y-2 p-3 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[e.jsx(Ml,{className:"w-3.5 h-3.5 text-muted-foreground"}),"PARKING"]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Lh,{label:`Required (1:${a})`,value:cu(l.requiredParkingSpaces),unit:"spaces"}),e.jsx(Lh,{label:"Provided",value:cu(l.providedParkingSpaces),unit:"spaces"}),e.jsx(Lh,{label:"Parking Ratio",value:l.parkingRatio,highlight:!0}),l.providedParkingSpaces>0&&e.jsxs("div",{className:`mt-2 p-2 rounded text-xs flex items-center gap-2 ${c==="ok"?"bg-green-500/10 text-green-600 dark:text-green-400":c==="warning"?"bg-amber-500/10 text-amber-600 dark:text-amber-400":"bg-red-500/10 text-red-600 dark:text-red-400"}`,children:[c==="ok"?e.jsx(bp,{className:"w-3.5 h-3.5"}):e.jsx(ho,{className:"w-3.5 h-3.5"}),l.parkingDeficit>=0?`${l.parkingDeficit} space surplus`:`${Math.abs(l.parkingDeficit)} spaces short`]})]})]}),l.dockDoorCount>0&&e.jsxs("div",{className:"space-y-2 p-3 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[e.jsx(hu,{className:"w-3.5 h-3.5 text-muted-foreground"}),"DOCK THROUGHPUT"]}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Lh,{label:"Dock Doors",value:l.dockDoorCount}),e.jsx(Lh,{label:"Est. Turns/Day",value:`${l.estimatedTurnsPerDay.min}-${l.estimatedTurnsPerDay.max}`}),e.jsx(Lh,{label:"SF per Door",value:cu(l.sfPerDoor),unit:"sf"})]})]}),e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-blue-500/5 rounded text-xs text-muted-foreground",children:[e.jsx(hh,{className:"w-3.5 h-3.5 mt-0.5 text-blue-500 shrink-0"}),e.jsx("span",{children:"Metrics are auto-calculated from geometry. Link parking layers and a parent property for accurate ratios."})]})]})}function V$({overlay:t,allOverlays:s,parentOverlay:n,onUpdate:a,toggleAreaLabel:l,setAreaLabelUnit:c,toggleMeasurements:u,isUpdating:i}){const _=k.useMemo(()=>s.filter(j=>
761j.parent_overlay_id===t.id&&(j.layer_type==="parking"||j.layer_type==="parking_field")),[s,t.id]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n_,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx(B,{className:"text-sm font-medium",children:"Show Area Label"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display area on polygon"})]})]}),e.jsx(kt,{checked:t.show_area_label||!1,onCheckedChange:l,disabled:i})]}),t.show_area_label&&e.jsxs(rt,{value:t.area_label_unit||"auto",onValueChange:j=>c(j),disabled:i,children:[e.jsx(it,{className:"h-8",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"auto",children:"Auto (Acres/SF)"}),e.jsx(le,{value:"acres",children:"Acres Only"}),e.jsx(le,{value:"sqft",children:"Square Feet Only"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fo,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx(B,{className:"text-sm font-medium",children:"Edge Measurements"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show dimensions on edges"})]})]}),e.jsx(kt,{checked:t.show_measurements||!1,onCheckedChange:u,disabled:i})]}),e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border space-y-2",children:[e.jsxs(B,{className:"text-xs font-medium flex items-center gap-2",children:[e.jsx(ji,{className:"w-3.5 h-3.5 text-muted-foreground"}),"Current Measurements"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Area:"}),e.jsx(Mt,{variant:"secondary",className:"font-mono text-[10px]",children:t.calculated_area_sqft?`${t.calculated_area_sqft.toLocaleString()} sf`:"N/A"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Perimeter:"}),e.jsx(Mt,{variant:"secondary",className:"font-mono text-[10px]",children:t.calculated_perimeter_ft?`${Math.round(t.calculated_perimeter_ft).toLocaleString()} ft`:"N/A"})]}),t.calculated_area_sqft&&t.calculated_area_sqft>=43560&&e.jsxs("div",{className:"flex justify-between col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Acres:"}),e.jsxs(Mt,{variant:"secondary",className:"font-mono text-[10px]",children:[(t.calculated_area_sqft/43560).toFixed(2)," ac"]})]})]})]}),e.jsx(ks,{}),e.jsx($$,{overlay:t,parentProperty:n,parkingLayers:_,parkingRequirementSfPerSpace:500})]})}function q$({o:t,overlay:s,onSelect:n,onDelete:a}){const l=rp(t.layer_type||"general"),c=t.id===s.id,{attributes:u,listeners:i,setNodeRef:_,transform:j,transition:y,isDragging:x}=_j({id:t.id}),v={transform:_p.Transform.toString(j),transition:y,opacity:x?.5:1};return e.jsxs("div",{ref:_,style:v,className:fs("flex items-center gap-1 px-1 py-1 rounded-md transition-colors group",c?"bg-primary/10 ring-1 ring-primary":"hover:bg-muted/50"),children:[e.jsx("button",{className:"cursor-grab text-muted-foreground hover:text-foreground shrink-0 touch-none",...u,...i,children:e.jsx(Fh,{className:"w-3 h-3"})}),e.jsxs("button",{onClick:C=>{C.stopPropagation(),n(t)},className:"flex items-center gap-2 flex-1 min-w-0 text-left",children:[e.jsx("div",{className:fs("w-2.5 h-2.5 rounded-full shrink-0",(l==null?void 0:l.color)||"bg-gray-500")}),e.jsx("span",{className:fs("text-xs truncate flex-1",c?"font-medium":"",!t.is_visible&&"text-muted-foreground line-through"),children:t.name}),!t.is_visible&&e.jsx(Wc,{className:"w-3 h-3 text-muted-foreground shrink-0"}),c&&e.jsx(Mt,{variant:"default",className:"text-[9px] px-1 h-4 shrink-0",children:"Current"})]}),e.jsx("button",{onClick:C=>{C.stopPropagation(),a(t.id)},className:"opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-destructive shrink-0 p-0.5 transition-opacity",title:"Delete layer",children:e.jsx(wr,{className:"w-3 h-3"})})]})}function G$({overlay:t,allOverlays:s,parentOverlay:n,childLayers:a,onUpdate:l,updateLayerType:c,onNavigateToOverlay:u,onCreateChildLayer:i,onSelectOverlay:_,isUpdating:j}){var Ee;const y=t.layer_type||"general",x=rp(y),v=pu(),C=Sp(),P=rE(t0(F0,{activationConstraint:{distance:5}}),t0(R0,{coordinateGetter:SE})),I=oo(y),z=rm(y),F=bf(y),D=Cy(y),X=(n==null?void 0:n.layer_type)||null,K=k.useMemo(()=>cD(y,X),[y,X]),te=k.useMemo(()=>uD(y,s,t.id),[y,s,t.id]),J=k.useMemo(()=>
761{if(Cy(t.layer_type)&&t.building_type)return t.building_type;let ve=t;for(;ve;){if(Cy(ve.layer_type)&&ve.building_type)return ve.building_type;ve=s.find(we=>we.id===(ve==null?void 0:ve.parent_overlay_id))}return null},[t,s]),H=k.useMemo(()=>qA(J),[J]),O=k.useMemo(()=>s.some(ve=>oo(ve.layer_type)),[s]),q=k.useMemo(()=>{if(I)return t;let ve=t;for(;ve;){if(oo(ve.layer_type))return ve;ve=s.find(we=>we.id===(ve==null?void 0:ve.parent_overlay_id))}return null},[t,s,I]),W=k.useMemo(()=>{if(!q)return[t];const ve=we=>s.filter(ke=>ke.parent_overlay_id===we).flatMap(ke=>[ke,...ve(ke.id)]);return[q,...ve(q.id)]},[q,s,t]),Q=k.useMemo(()=>[...W].sort((ve,we)=>(ve.display_order??0)-(we.display_order??0)),[W]);k.useMemo(()=>{const ve={polygon:[],polyline:[],marker:[]};return W.forEach(we=>{ve[we.type]&&ve[we.type].push(we)}),ve},[W]);const Z=k.useCallback(async ve=>{const{active:we,over:Ze}=ve;if(!Ze||we.id===Ze.id)return;const ke=Q.findIndex(dt=>dt.id===we.id),ze=Q.findIndex(dt=>dt.id===Ze.id);if(ke===-1||ze===-1)return;const Ke=Hx(Q,ke,ze);try{for(let dt=0;dt<Ke.length;dt++)await v.mutateAsync({id:Ke[dt].id,display_order:dt});Ve.success("Layer order updated")}catch{Ve.error("Failed to reorder layers")}},[Q,v]),oe=k.useCallback(async ve=>{if(ve===t.id){Ve.error("Cannot delete the currently selected layer from here. Use the Delete button below.");return}const we=s.find(Ze=>Ze.id===ve);if(we&&confirm(`Delete "${we.name}"? This cannot be undone.`))try{const Ze=s.filter(ke=>ke.parent_overlay_id===ve);for(const ke of Ze)await C.mutateAsync(ke.id);await C.mutateAsync(ve),Ve.success(`"${we.name}" deleted`)}catch{Ve.error("Failed to delete layer")}},[t.id,s,C]),ce=()=>{c("site"),Ve.success("Layer marked as Site. This is the parent container for all properties and improvements.")},ae=()=>{if(!O){c("site"),Ve.info("No Site exists. Creating this layer as Site (which can act as Site + Property for single-parcel projects).");return}const ve=s.filter(we=>oo(we.layer_type));ve.length===1?(c("property_outline"),l({parent_overlay_id:ve[0].id}),Ve.success(`Property created and linked to ${ve[0].name}.`)):(c("property_outline"),Ve.info("Property created. Please select a parent Site from the available options."))},ie=ve=>{i?i(ve,t.id):Ve.error("Child layer creation not available")},de=ve=>{l({parent_overlay_id:ve});const we=s.find(Ze=>Ze.id===ve);Ve.success(`Linked to ${(we==null?void 0:we.name)||"parent layer"}.`)},ge=ve=>{_?_(ve):u&&u(ve.id)},We=iD(y);return e.jsxs("div",{className:"space-y-4",children:[q&&e.jsx("div",{className:"p-2 bg-indigo-500/10 border border-indigo-500/20 rounded-lg",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx(mp,{className:"w-3.5 h-3.5 text-indigo-500"}),e.jsxs("span",{className:"font-medium text-indigo-600 dark:text-indigo-400",children:["Active Site: ",q.name]})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Da,{className:"w-4 h-4 text-primary"}),e.jsx(B,{className:"text-sm font-medium",children:"Site Drawings"}),e.jsx(Mt,{variant:"secondary",className:"ml-auto text-[10px]",children:W.length})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Drag to reorder · hover to delete"}),e.jsx(Xc,{className:"h-[200px] border rounded-md",children:e.jsxs("div",{className:"p-2 space-y-1",children:[e.jsx(jE,{sensors:P,collisionDetection:cE,onDragEnd:Z,children:e.jsx(ky,{items:Q.map(ve=>ve.id),strategy:Ny,children:Q.map(ve=>e.jsx(q$,{o:ve,overlay:t,onSelect:ge,onDelete:oe},ve.id))})}),W.length===0&&e.jsx("div",{className:"text-center py-6 text-xs text-muted-foreground",children:"No drawings in this site"}),!q&&W.length===1&&e.jsx("div",{className:"text-center py-2 text-xs text-muted-foreground",children:"Assign to a Site to see related layers"})]})})]}),e.jsx(ks,{}),e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-2",children:[e.jsx(Da,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"font-medium",children:"Layer Hierarchy"})]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx("span",{className:I?"text-indigo-500 font-semibold":"text-muted-foreground",children:"Site"}),e.jsx(Ao,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:z?"text-purple-500 font-semibold":"text-muted-foreground",children:"Property"}),e.jsx(Ao,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:F?"text-purple-400 font-semibold":"text-muted-foreground",children:"Lot"}),e.jsx(Ao,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:D?"text-orange-500 font-semibold":"text-muted-foreground",children:"Building"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Da,{className:"w-4 h-4 text-primary"}),e.jsx(B,{className:"text-sm font-medium",children:"Layer Type"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Categorize this polygon for proper stacking and 3D rendering"}),e.jsxs(rt,{value:y,onValueChange:ve=>c(ve),disabled:j,children:[e.jsx(it,{className:"h-9",children:e.jsx(ct,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-3 h-3 rounded-full ${(x==null?void 0:x.color)||"bg-gray-500"}`}),e.jsx("span",{children:(x==null?void 0:x.label)||"General"})]})})}),e.jsx(ot,{className:"max-h-80",children:Object.entries(Zx).map(([ve,we])=>{const Ze=H.filter(ke=>ke.category===ve);return Ze.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:we.label}),Ze.map(ke=>{const ze=rp(ke.value);return e.jsx(le,{value:ke.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-3 h-3 rounded-full ${(ze==null?void 0:ze.color)||"bg-gray-500"}`}),e.jsx("span",{children:ke.label})]})},ke.value)})]},ve)})})]}),y==="general"&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"gap-2",onClick:ce,disabled:j,children:[e.jsx(mp,{className:"w-4 h-4 text-indigo-500"}),"Define as Site"]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"gap-2",onClick:ae,disabled:j,children:[e.jsx(qd,{className:"w-4 h-4 text-purple-500"}),"Define as Property"]})]}),oD(y)&&!K&&e.jsxs(Dy,{variant:"destructive",className:"mt-3",children:[e.jsx(ho,{className:"h-4 w-4"}),e.jsx(Ry,{className:"text-xs",children:dD(y)}),te.length>0&&e.jsxs(rt,{onValueChange:de,children:[e.jsx(it,{className:"mt-2 h-8",children:e.jsx(ct,{placeholder:"Select parent layer..."})}),e.jsx(ot,{children:te.map(ve=>{const we=rp(ve.layer_type||"general");return e.jsx(le,{value:ve.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${(we==null?void 0:we.color)||"bg-gray-500"}`}),e.jsx("span",{className:"truncate",children:ve.name})]})},ve.id)})})]})]})]}),e.jsx(ks,{}),n&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(B,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Cf,{className:"w-4 h-4 text-muted-foreground"}),"Parent Layer"]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full justify-between",onClick:()=>ge(n),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-3 h-3 rounded-full ${((Ee=rp(n.layer_type||"general"))==null?void 0:Ee.color)||"bg-gray-500"}`}),e.jsx("span",{className:"truncate",children:n.name})]}),e.jsx(Ao,{className:"w-4 h-4"})]})]}),a.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(B,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Ci,{className:"w-4 h-4 text-muted-foreground"}),"Child Layers",e.jsx(Mt,{variant:"secondary",className:"ml-auto text-[10px]",children:a.length})]}),e.jsx("div",{className:"space-y-1",children:a.map(ve=>{var we;return e.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full justify-between h-8",onClick:()=>ge(ve),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${((we=rp(ve.layer_type||"general"))==null?void 0:we.color)||"bg-gray-500"}`}),e.jsx("span",{className:"truncate text-xs",children:ve.name})]}),e.jsx(Ao,{className:"w-3.5 h-3.5 text-muted-foreground"})]},ve.id)})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-sm font-medium",children:"Add Layer"}),e.jsxs(jp,{children:[e.jsx(wp,{asChild:!0,children:e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full gap-2",children:[e.jsx(tr,{className:"w-4 h-4"}),"Add Layer"]})}),e.jsxs(Np,{align:"start",className:"w-56 max-h-80 overflow-y-auto",children:[e.jsx(zm,{className:"text-xs text-muted-foreground",children:"Select layer type to add"}),e.jsx(cd,{}),Object.entries(Zx).map(([ve,we],Ze)=>
761{const ke=H.filter(ze=>ze.category===ve);return ke.length===0?null:e.jsxs("div",{children:[Ze>0&&e.jsx(cd,{}),e.jsx(zm,{className:"text-[10px] uppercase tracking-wider text-muted-foreground py-1",children:we.label}),ke.map(ze=>{const Ke=We.includes(ze.value);return e.jsx(co,{onClick:()=>ie(ze.value),className:"cursor-pointer",children:e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx("div",{className:`w-3 h-3 rounded-full shrink-0 ${ze.color||"bg-gray-500"}`}),e.jsx("span",{className:"flex-1",children:ze.label}),Ke&&e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 h-4",children:"Child"})]})},ze.value)})]},ve)})]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:'⚠️ Design elements vary by layer type. "Child" layers inherit from current.'})]}),e.jsx(ks,{}),x&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg text-xs space-y-1",children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx("div",{className:`w-3 h-3 rounded-full ${x.color}`}),x.label]}),e.jsx("p",{className:"text-muted-foreground",children:x.description})]})]})}function H$({overlay:t,onUpdate:s,onOpenImageDialog:n,onOpenSite360AI:a,isUpdating:l}){const[c,u]=k.useState(t.video_url||""),i=k.useRef(null),_=k.useRef(null),j=k.useRef(null),y=t.media_items||[],x=async F=>{var H;const D=(H=F.target.files)==null?void 0:H[0];if(!D)return;const X=URL.createObjectURL(D),K=D.type.startsWith("image/")?"image":D.type.startsWith("video/")?"video":"document",te={id:crypto.randomUUID(),url:X,type:K,name:D.name,uploadedAt:new Date().toISOString()},J=[...y,te];s({media_items:J}),Ve.success("Media added"),F.target.value=""},v=F=>{const D=y.filter(X=>X.id!==F);s({media_items:D}),Ve.success("Media removed")},C=()=>{s({video_url:c||null}),Ve.success(c?"Video URL saved":"Video URL removed")},P=async F=>{var K;const D=(K=F.target.files)==null?void 0:K[0];if(!D)return;const X=URL.createObjectURL(D);s({before_image_url:X}),Ve.success("Before image set"),F.target.value=""},I=async F=>{var K;const D=(K=F.target.files)==null?void 0:K[0];if(!D)return;const X=URL.createObjectURL(D);s({after_image_url:X}),Ve.success("After image set"),F.target.value=""},z=()=>{s({before_image_url:null,after_image_url:null}),Ve.success("Before/After images cleared")};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs(B,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Zd,{className:"w-4 h-4 text-muted-foreground"}),"Images & Media"]}),e.jsxs("div",{className:"flex gap-2",children:[n&&e.jsxs(Le,{variant:"outline",size:"sm",className:"flex-1 gap-1.5",onClick:n,children:[e.jsx(Zd,{className:"w-3.5 h-3.5"}),"Add Image"]}),a&&e.jsxs(Le,{variant:"outline",size:"sm",className:"flex-1 gap-1.5",onClick:a,children:[e.jsx(Nf,{className:"w-3.5 h-3.5"}),"Site360 AI"]})]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-sm font-medium",children:"Media Gallery"}),e.jsxs(Mt,{variant:"secondary",className:"text-[10px]",children:[y.length," items"]})]}),y.length>0?e.jsx("div",{className:"grid grid-cols-3 gap-2",children:y.map(F=>e.jsxs("div",{className:"relative group aspect-square bg-muted rounded-lg overflow-hidden border",children:[F.type==="image"?e.jsx("img",{src:F.url,alt:F.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(lN,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("button",{onClick:()=>v(F.id),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(ja,{className:"w-3 h-3"})})]},F.id))}):e.jsxs("div",{className:"text-center py-6 text-muted-foreground border-2 border-dashed rounded-lg",children:[e.jsx(Zd,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-xs",children:"No media attached"})]}),e.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*,video/*",onChange:x}),e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full gap-1.5",onClick:()=>{var F;return(F=i.current)==null?void 0:F.click()},disabled:l,children:[e.jsx(Ab,{className:"w-3.5 h-3.5"}),"Upload Media"]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(B,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(lN,{className:"w-4 h-4 text-muted-foreground"}),"Video URL"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(be,{value:c,onChange:F=>u(F.target.value),placeholder:"YouTube or Vimeo URL",className:"h-8 text-xs",disabled:l}),e.jsx(Le,{size:"sm",onClick:C,disabled:l,children:"Save"})]}),t.video_url&&e.jsxs("a",{href:t.video_url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary flex items-center gap-1 hover:underline",children:[e.jsx(Rx,{className:"w-3 h-3"}),"Open video"]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(PS,{className:"w-4 h-4 text-muted-foreground"}),"Before/After"]}),(t.before_image_url||t.after_image_url)&&e.jsxs(Le,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-destructive",onClick:z,children:[e.jsx(wr,{className:"w-3 h-3 mr-1"}),"Clear"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Before"}),e.jsx("div",{className:"aspect-video bg-muted rounded-lg border-2 border-dashed flex items-center justify-center cursor-pointer hover:bg-muted/80 transition-colors overflow-hidden",onClick:()=>{var F;return(F=_.current)==null?void 0:F.click()},children:t.before_image_url?e.jsx("img",{src:t.before_image_url,alt:"Before",className:"w-full h-full object-cover"}):e.jsx(tr,{className:"w-5 h-5 text-muted-foreground"})}),e.jsx("input",{type:"file",ref:_,className:"hidden",accept:"image/*",onChange:P})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"After"}),e.jsx("div",{className:"aspect-video bg-muted rounded-lg border-2 border-dashed flex items-center justify-center cursor-pointer hover:bg-muted/80 transition-colors overflow-hidden",onClick:()=>{var F;return(F=j.current)==null?void 0:F.click()},children:t.after_image_url?e.jsx("img",{src:t.after_image_url,alt:"After",className:"w-full h-full object-cover"}):e.jsx(tr,{className:"w-5 h-5 text-muted-foreground"})}),e.jsx("input",{type:"file",ref:j,className:"hidden",accept:"image/*",onChange:I})]})]})]})]})}const fy=[{value:"draft",label:"Draft",icon:D1,color:"bg-muted text-muted-foreground"}
761,{value:"pending",label:"Pending Review",icon:bg,color:"bg-amber-500 text-white"},{value:"approved",label:"Approved",icon:iS,color:"bg-emerald-500 text-white"},{value:"rejected",label:"Rejected",icon:M5,color:"bg-destructive text-white"}];function Z$({overlay:t,onUpdate:s,isUpdating:n}){const[a,l]=k.useState("");fy.find(x=>x.value===t.approval_status)||fy[0];const c=t.current_version||1,u=t.version_history||[],i=x=>{var v;s({approval_status:x,approved_at:x==="approved"?new Date().toISOString():null}),Ve.success(`Status changed to ${(v=fy.find(C=>C.value===x))==null?void 0:v.label}`)},_=()=>{if(!a.trim()){Ve.error("Please add a note describing the changes");return}const x={version:c+1,timestamp:new Date().toISOString(),changes:a.trim(),geometry:t.geometry},v=[...u,x];s({current_version:c+1,version_history:v}),l(""),Ve.success(`Version ${c+1} saved`)},j=x=>{if(!x.geometry){Ve.error("This version has no saved geometry");return}s({geometry:x.geometry}),Ve.success(`Restored to version ${x.version}`)},y=x=>new Date(x).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-sm font-medium",children:"Approval Status"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:fy.map(x=>{const v=x.icon,C=t.approval_status===x.value;return e.jsxs(Le,{variant:C?"default":"outline",size:"sm",className:`gap-1.5 ${C?x.color:""}`,onClick:()=>i(x.value),disabled:n,children:[e.jsx(v,{className:"w-3.5 h-3.5"}),x.label]},x.value)})}),t.approved_at&&t.approval_status==="approved"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Approved on ",y(t.approved_at)]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Ox,{className:"w-4 h-4 text-muted-foreground"}),"Version Snapshots"]}),e.jsxs(Mt,{variant:"secondary",className:"text-[10px]",children:["v",c]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{value:a,onChange:x=>l(x.target.value),placeholder:"Describe changes...",className:"h-8 text-xs",disabled:n}),e.jsxs(Le,{onClick:_,disabled:n||!a.trim(),size:"sm",className:"w-full gap-1.5",children:[e.jsx(jg,{className:"w-3.5 h-3.5"}),"Save Snapshot"]})]}),u.length>0?e.jsx(Xc,{className:"h-[200px]",children:e.jsx("div",{className:"space-y-2 pr-2",children:u.slice().reverse().map(x=>e.jsxs("div",{className:"p-2 bg-muted/50 rounded-lg border text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs(Mt,{variant:"outline",className:"text-[10px]",children:["v",x.version]}),e.jsx("span",{className:"text-muted-foreground text-[10px]",children:y(x.timestamp)})]}),e.jsx("p",{className:"text-muted-foreground mb-2 line-clamp-2",children:x.changes}),x.geometry&&e.jsxs(Le,{variant:"ghost",size:"sm",className:"h-6 px-2 text-[10px] gap-1",onClick:()=>j(x),disabled:n,children:[e.jsx(mh,{className:"w-3 h-3"}),"Restore"]})]},x.version))})}):e.jsxs("div",{className:"text-center py-4 text-muted-foreground border-2 border-dashed rounded-lg",children:[e.jsx(Ox,{className:"w-6 h-6 mx-auto mb-1 opacity-50"}),e.jsx("p",{className:"text-xs",children:"No versions saved yet"})]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Created:"}),e.jsx("span",{children:y(t.created_at)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Updated:"}),e.jsx("span",{children:y(t.updated_at)})]})]})]})}function W$({overlay:t,onUpdate:s,isUpdating:n}){const[a,l]=k.useState(""),[c,u]=k.useState(null),[i,_]=k.useState(""),{polygonMetrics:j,addCalloutMarker:y,removeCalloutMarker:x}=UE(t),v=t.callout_markers||[],C=()=>{if(!a.trim()){Ve.error("Please enter callout text");return}y({lat:j.centroid.lat,lng:j.centroid.lng,text:a.trim()}),l(""),Ve.success("Callout added")},P=D=>{x(D),Ve.success("Callout removed")},I=D=>{u(D),_(v[D].text)},z=()=>{if(c===null)return;const D=v.map((X,K)=>K===c?{...X,text:i.trim()}:X);s({callout_markers:D}),u(null),_(""),Ve.success("Callout updated")},F=()=>{u(null),_("")};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-sm font-medium",children:"Description"}),e.jsx(j1,{value:t.description||"",onChange:D=>s({description:D.target.value}),placeholder:"Add a description for this layer...",className:"min-h-[80px] text-sm",disabled:n})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Vy,{className:"w-4 h-4 text-muted-foreground"}),"Callout Markers"]}),e.jsx(Mt,{variant:"secondary",className:"text-[10px]",children:v.length})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(be,{value:a,onChange:D=>l(D.target.value),placeholder:"Add callout text...",className:"h-8 text-xs",disabled:n,onKeyDown:D=>D.key==="Enter"&&C()}),e.jsx(Le,{size:"sm",onClick:C,disabled:n||!a.trim(),children:e.jsx(tr,{className:"w-3.5 h-3.5"})})]}),v.length>0?e.jsx("div",{className:"space-y-2",children:v.map((D,X)=>e.jsxs("div",{className:"p-2 bg-muted/50 rounded-lg border text-xs flex items-start gap-2",children:[e.jsx(ji,{className:"w-3.5 h-3.5 text-primary mt-0.5 shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:c===X?e.jsxs("div",{className:"flex gap-1",children:[e.jsx(be,{value:i,onChange:K=>_(K.target.value),className:"h-6 text-xs",autoFocus:!0}),e.jsx(Le,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:z,children:e.jsx(cl,{className:"w-3 h-3"})}),e.jsx(Le,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:F,children:e.jsx(ja,{className:"w-3 h-3"})})]}):e.jsx("span",{className:"text-muted-foreground",children:D.text})}),c!==X&&e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx(Le,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>I(X),children:e.jsx(lS,{className:"w-3 h-3"})}),e.jsx(Le,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive",onClick:()=>P(D.id),children:e.jsx(wr,{className:"w-3 h-3"})})]})]},X))}):e.jsxs("div",{className:"text-center py-4 text-muted-foreground border-2 border-dashed rounded-lg",children:[e.jsx(Vy,{className:"w-6 h-6 mx-auto mb-1 opacity-50"}),e.jsx("p",{className:"text-xs",children:"No callouts yet"}),e.jsx("p",{className:"text-[10px] mt-0.5",children:"Click to place markers on the polygon"})]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-sm font-medium",children:"Layer Name"}),e.jsx(be,{value:t.name,onChange:D=>s({name:D.target.value}),placeholder:"Layer name",className:"h-8",disabled:n})]})]})}const Y$=[{id:"power_yard",name:"Power Yard",description:"Generator farm with fuel storage, containment, acoustic enclosure, exhaust stacks, and sound wall",subsystem:"PWR",category:"component",layers:[{layerType:"dc_generator_yard",label:"Generator Yard",area_weight:3,placement_priority:1,defaults:{dc_gen_yard_count:4,dc_gen_yard_rating_kw:3e3,dc_gen_yard_fuel_type:"diesel"}},{layerType:"dc_fuel_tank_farm",label:"Fuel Tank Farm",area_weight:2,placement_priority:2,defaults:{dc_fuel_tank_count:2,dc_fuel_tank_capacity_gal:2e4,dc_fuel_tank_type:"above_ground"}},{layerType:"dc_fuel_berm",label:"Fuel Containment Berm",area_weight:1.5,placement_priority:3,defaults:{dc_berm_height_ft:3,dc_berm_material:"concrete",dc_berm_leak_detection:!0}
761},{layerType:"dc_acoustic_enclosure",label:"Acoustic Enclosure",area_weight:1.5,placement_priority:4,defaults:{dc_acoustic_db_reduction:25,dc_acoustic_wall_type:"composite"}},{layerType:"exhaust_stack",label:"Exhaust Stacks",area_weight:.5,placement_priority:5,defaults:{exh_stack_count:4,exh_stack_height_ft:30,exh_stack_diameter_in:24}},{layerType:"sound_wall",label:"Sound Wall",area_weight:.5,placement_priority:6,defaults:{height_ft:12}}]},{id:"cooling_yard_water",name:"Cooling Yard (Water-Cooled)",description:"Evaporative cooling tower array with pipe rack, pump house, and water treatment",subsystem:"CLG",category:"component",layers:[{layerType:"dc_cooling_tower_yard",label:"Cooling Tower Yard",area_weight:3,placement_priority:1,defaults:{dc_cooling_tower_count:4,dc_cooling_tower_type:"induced_draft"}},{layerType:"dc_pipe_rack",label:"Cooling Pipe Rack",area_weight:1,placement_priority:2,defaults:{dc_pipe_rack_height_ft:15,dc_pipe_rack_material:"steel",dc_pipe_rack_pipe_count:8}},{layerType:"dc_pump_house",label:"Pump House",area_weight:1.5,placement_priority:3,defaults:{dc_pump_count:4,dc_pump_redundancy:"n_plus_1",height_ft:16}},{layerType:"dc_water_treatment",label:"Water Treatment",area_weight:1.5,placement_priority:4,defaults:{dc_water_treatment:"reverse_osmosis",height_ft:14}}]},{id:"cooling_yard_air",name:"Cooling Yard (Air-Cooled)",description:"Dry/adiabatic cooler yard with pipe rack and pump house",subsystem:"CLG",category:"component",layers:[{layerType:"dc_dry_cooler_yard",label:"Dry / Adiabatic Cooler",area_weight:3,placement_priority:1,defaults:{dc_dry_cooler_count:6,dc_dry_cooler_type:"adiabatic"}},{layerType:"dc_pipe_rack",label:"Cooling Pipe Rack",area_weight:1,placement_priority:2,defaults:{dc_pipe_rack_height_ft:15,dc_pipe_rack_material:"steel"}},{layerType:"dc_pump_house",label:"Pump House",area_weight:1.5,placement_priority:3,defaults:{dc_pump_count:3,dc_pump_redundancy:"n_plus_1",height_ft:16}}]},{id:"electrical_yard",name:"Electrical Yard",description:"Utility substation, E-House, BESS containers, and MV distribution",subsystem:"PWR",category:"component",layers:[{layerType:"dc_substation",label:"Electrical Substation",area_weight:3,placement_priority:1,defaults:{dc_substation_capacity_mva:50,dc_substation_type:"unit",dc_substation_voltage:"138kV"}},{layerType:"dc_ehouse",label:"E-House / Switchgear Skid",area_weight:2,placement_priority:2,defaults:{dc_ehouse_count:2,dc_ehouse_type:"switchgear",dc_ehouse_voltage_class:"15kV",height_ft:14}},{layerType:"dc_bess",label:"Battery Energy Storage",area_weight:2,placement_priority:3,defaults:{dc_bess_count:4,dc_bess_capacity_mwh:10,dc_bess_chemistry:"lfp"}},{layerType:"dc_mv_distribution",label:"MV Distribution",area_weight:1,placement_priority:4,defaults:{dc_mv_voltage:"15kV",dc_mv_conduit_count:6}}]},{id:"security_entry",name:"Security Entry",description:"Guardhouse, sally port, wedge barriers, camera array, and security lighting",subsystem:"SEC",category:"component",layers:[{layerType:"dc_guardhouse",label:"Security Guardhouse",area_weight:2,placement_priority:1,defaults:{dc_guardhouse_type:"full_service",dc_guardhouse_staffing:"24_7",height_ft:12}},{layerType:"dc_sally_port",label:"Sally Port",area_weight:2,placement_priority:2,defaults:{dc_sally_gate_type:"sliding",dc_sally_trap_length_ft:60}},{layerType:"dc_wedge_barrier",label:"Wedge Barrier",area_weight:1,placement_priority:3,defaults:{dc_wedge_barrier_type:"hydraulic",dc_wedge_crash_rating:"k12"}},{layerType:"dc_camera_array",label:"Camera Array",area_weight:1,placement_priority:4,defaults:{dc_camera_pole_count:8,dc_camera_type:"ptz",dc_camera_spacing_ft:100}},{layerType:"dc_security_lighting",label:"Security Lighting",area_weight:1,placement_priority:5,defaults:{dc_sec_light_pole_count:12,dc_sec_light_pole_height_ft:30}}]},{id:"fire_life_safety",name:"Fire / Life Safety",description:"Fire pump room, fire water tank, and fire suppression systems",subsystem:"UTL",category:"component",layers:[{layerType:"dc_fire_pump_room",label:"Fire Pump Room",area_weight:2,placement_priority:1,defaults:{dc_fire_pump_count:2,dc_fire_pump_gpm:1500,dc_fire_pump_type:"electric",height_ft:16}},{layerType:"dc_fire_water_tank",label:"Fire Water Tank",area_weight:2,placement_priority:2,defaults:{dc_fire_tank_capacity_gal:3e5,dc_fire_tank_type:"ground_level",dc_fire_tank_height_ft:30}},{layerType:"fire_suppression",label:"Fire Suppression",area_weight:1.5,placement_priority:3,defaults:{fire_suppression_type:"wet_sprinkler"}}]},{id:"utility_corridor",name:"Utility Corridor",description:"Pipe rack, CHW distribution, MV distribution, and dark fiber backbone",subsystem:"CLG",category:"component",layers:[{layerType:"dc_pipe_rack",label:"Cooling Pipe Rack",area_weight:1.5,placement_priority:1,defaults:{dc_pipe_rack_height_ft:15,dc_pipe_rack_material:"steel",dc_pipe_rack_pipe_count:12}},{layerType:"dc_chw_distribution",label:"CHW Distribution",area_weight:1.5,placement_priority:2,defaults:{dc_chw_pipe_size_in:16,dc_chw_valve_stations:4}},{layerType:"dc_mv_distribution",label:"MV Distribution",area_weight:1.5,placement_priority:3,defaults:{dc_mv_voltage:"15kV",dc_mv_conduit_count:8}}
761,{layerType:"dc_dark_fiber",label:"Dark Fiber Network",area_weight:1,placement_priority:4,defaults:{dc_dark_fiber_strand_count:288,dc_dark_fiber_conduit_count:4}}]},{id:"stormwater_kit",name:"Stormwater Kit",description:"Detention basin with landscape buffer and perimeter fencing",subsystem:"UTL",category:"component",layers:[{layerType:"detention_basin",label:"Detention Basin",area_weight:3,placement_priority:1,defaults:{depth_ft:6,stormwater_type:"detention"}},{layerType:"landscape_buffer",label:"Landscape Buffer",area_weight:1,placement_priority:2,defaults:{buffer_distance_ft:20}},{layerType:"stormwater_fence",label:"Basin Fencing",area_weight:.5,placement_priority:3,defaults:{dc_security_fence_height_ft:6,dc_security_fence_type:"chain_link"}}]},{id:"signage_branding",name:"Signage / Branding Kit",description:"Monument sign zone, pylon sign zone, and unit label areas",subsystem:"MKT",category:"component",layers:[{layerType:"monument_sign",label:"Monument Sign",area_weight:1.5,placement_priority:1,defaults:{height_ft:8}},{layerType:"pylon_sign",label:"Pylon Sign",area_weight:1.5,placement_priority:2,defaults:{height_ft:25}},{layerType:"unit_label_zone",label:"Unit Labels",area_weight:1,placement_priority:3}]},{id:"truck_operations",name:"Truck Operations Kit",description:"Truck court, scale house, queuing lane, and guard booth for freight operations",subsystem:"LOG",category:"component",layers:[{layerType:"truck_court",label:"Truck Court",area_weight:3,placement_priority:1,defaults:{depth_ft:135}},{layerType:"scale_house",label:"Scale House",area_weight:1.5,placement_priority:2,defaults:{height_ft:10}},{layerType:"queuing_lane",label:"Queuing Lane",area_weight:1.5,placement_priority:3,defaults:{depth_ft:200}},{layerType:"guard_booth",label:"Guard Booth",area_weight:1,placement_priority:4,defaults:{height_ft:10,guard_booth_type:"standard"}}]},{id:"container_yard",name:"Container Yard Kit",description:"Container storage, trailer parking, drive aisle, and perimeter fencing",subsystem:"LOG",category:"component",layers:[{layerType:"container_yard",label:"Container Yard",area_weight:3,placement_priority:1,defaults:{container_yard_capacity:200,container_yard_stack_height:3}},{layerType:"trailer_parking",label:"Trailer Parking",area_weight:2,placement_priority:2,defaults:{drop_lot_capacity:50}},{layerType:"drive_aisle",label:"Drive Aisle",area_weight:1,placement_priority:3,defaults:{circulation_width_ft:28}},{layerType:"perimeter_fence",label:"Perimeter Fencing",area_weight:.5,placement_priority:4,defaults:{dc_security_fence_height_ft:8,dc_security_fence_type:"chain_link"}}]},{id:"cold_storage_kit",name:"Cold Storage Kit",description:"Cold storage building zone, loading berths, and truck court",subsystem:"LOG",category:"component",layers:[{layerType:"building_footprint",label:"Cold Storage Building",area_weight:3,placement_priority:1,defaults:{height_ft:40,floor_count:1,building_type:"cold_storage",cold_storage_temp_zone:"freezer"}},{layerType:"loading_berth",label:"Loading Berth",area_weight:2,placement_priority:2,defaults:{dock_count:20,dock_spacing_ft:12}},{layerType:"truck_court",label:"Truck Court",area_weight:2,placement_priority:3,defaults:{depth_ft:135}}]},{id:"amenity_mf",name:"Amenity Kit (Multi-Family)",description:"Clubhouse, pool/spa, dog park, and EV charging area for residential communities",subsystem:"AMN",category:"component",layers:[{layerType:"building_footprint",label:"Clubhouse",area_weight:2.5,placement_priority:1,defaults:{height_ft:18,floor_count:1,building_type:"clubhouse"}},{layerType:"amenity_area",label:"Pool / Spa",area_weight:2,placement_priority:2,defaults:{amenity_pad_type:"pool"}},{layerType:"amenity_area",label:"Dog Park",area_weight:1.5,placement_priority:3,defaults:{amenity_pad_type:"dog_park"}},{layerType:"parking_field",label:"EV Charging",area_weight:1,placement_priority:4,defaults:{dc_parking_has_ev:!0}}]},{id:"parking_structure",name:"Parking Structure Kit",description:"Parking garage footprint, drive aisle access, and ADA stalls",subsystem:"CIR",category:"component",layers:[{layerType:"building_footprint",label:"Parking Garage",area_weight:4,placement_priority:1,defaults:{height_ft:36,floor_count:4,building_type:"parking_garage"}},{layerType:"drive_aisle",label:"Drive Aisle",area_weight:1,placement_priority:2,defaults:{cir
761culation_width_ft:24}},{layerType:"ada_stalls",label:"ADA Stalls",area_weight:.5,placement_priority:3}]},{id:"civil_infrastructure",name:"Civil Infrastructure Kit",description:"Sidewalk, fire lane, curb cut, and landscape buffer for site circulation",subsystem:"CIR",category:"component",layers:[{layerType:"sidewalk",label:"Sidewalk",area_weight:1.5,placement_priority:1,defaults:{circulation_width_ft:6}},{layerType:"fire_lane",label:"Fire Lane",area_weight:2,placement_priority:2,defaults:{circulation_width_ft:26}},{layerType:"drive_aisle",label:"Curb Cut",area_weight:.5,placement_priority:3,defaults:{circulation_width_ft:30}},{layerType:"landscape_buffer",label:"Landscape Buffer",area_weight:1,placement_priority:4,defaults:{buffer_distance_ft:15}}]},{id:"mezzanine_office",name:"Mezzanine Office Kit",description:"Mezzanine level, office area, and building core for warehouse office buildout",subsystem:"BLD",category:"component",layers:[{layerType:"building_footprint",label:"Mezzanine",area_weight:2.5,placement_priority:1,defaults:{height_ft:14,floor_count:1,floor_level:2,building_type:"mezzanine"}},{layerType:"office_area",label:"Office Area",area_weight:2,placement_priority:2,defaults:{height_ft:12}},{layerType:"building_footprint",label:"Building Core",area_weight:1,placement_priority:3,defaults:{height_ft:14,building_type:"core"}}]},{id:"future_phase",name:"Future Phase Kit",description:"Future expansion phase overlay, expansion area, and phase boundary",subsystem:"PLN",category:"component",layers:[{layerType:"buildable_area",label:"Future Phase",area_weight:3,placement_priority:1},{layerType:"buildable_area",label:"Expansion Area",area_weight:2,placement_priority:2},{layerType:"site_boundary",label:"Phase Overlay",area_weight:1,placement_priority:3}]}],X$=[{id:"site_industrial",name:"Industrial Site",description:"Complete industrial site: building, truck court, loading, parking, stormwater, fire lane, and landscaping",subsystem:"BLD",category:"full_site",propertyType:"industrial",layers:[{layerType:"buildable_area",label:"Buildable Area",area_weight:1,placement_priority:1},{layerType:"building_footprint",label:"Building Footprint",area_weight:5,placement_priority:2,defaults:{height_ft:32,floor_count:1,building_type:"industrial"}},{layerType:"truck_court",label:"Truck Court",area_weight:3,placement_priority:3,defaults:{depth_ft:135}},{layerType:"loading_berth",label:"Loading Berth",area_weight:1.5,placement_priority:4,defaults:{dock_count:30,dock_spacing_ft:10,dock_height_ft:4}},{layerType:"parking_field",label:"Parking Zone",area_weight:2.5,placement_priority:5,defaults:{car_parking_count:100}},{layerType:"fire_lane",label:"Fire Lane",area_weight:.8,placement_priority:6,defaults:{circulation_width_ft:26}},{layerType:"landscape_buffer",label:"Landscape Buffer",area_weight:.8,placement_priority:7,defaults:{buffer_distance_ft:15}},{layerType:"detention_basin",label:"Stormwater",area_weight:1.5,placement_priority:8,defaults:{depth_ft:6,stormwater_type:"detention"}}]},{id:"site_distribution",name:"Distribution / Cross-Dock Site",description:"Cross-dock facility with dual truck courts, trailer parking, loading, and parking",subsystem:"BLD",category:"full_site",propertyType:"distribution",layers:[{layerType:"buildable_area",label:"Buildable Area",area_weight:1,placement_priority:1},{layerType:"building_footprint",label:"Building Footprint",area_weight:5,placement_priority:2,defaults:{height_ft:36,floor_count:1,building_type:"distribution"}},{layerType:"truck_court",label:"Truck Court (Front)",area_weight:3,placement_priority:3,defaults:{depth_ft:185}},{layerType:"truck_court",label:"Truck Court (Rear)",area_weight:3,placement_priority:4,defaults:{depth_ft:185}},{layerType:"trailer_parking",label:"Trailer Parking",area_weight:2.5,placement_priority:5,defaults:{drop_lot_capacity:80}},{layerType:"loading_berth",label:"Loading Berth",area_weight:1.5,placement_priority:6,defaults:{dock_count:50,dock_spacing_ft:10,dock_height_ft:4}},{layerType:"parking_field",label:"Parking Zone",area_weight:2,placement_priority:7,defaults:{car_parking_count:60}},{layerType:"landscape_buffer",label:"Landscape Buffer",area_weight:.8,placement_priority:8,defaults:{buffer_distance_ft:15}}]}
761,{id:"site_retail",name:"Retail Center Site",description:"Full retail center with building, pad sites, parking, drive aisles, sidewalks, stormwater, and signage",subsystem:"BLD",category:"full_site",propertyType:"retail",layers:[{layerType:"buildable_area",label:"Buildable Area",area_weight:1,placement_priority:1},{layerType:"building_footprint",label:"Building Footprint",area_weight:3,placement_priority:2,defaults:{height_ft:24,floor_count:1,building_type:"retail"}},{layerType:"retail_pad",label:"Retail Pad",area_weight:1.5,placement_priority:3,defaults:{height_ft:20,building_type:"retail_pad"}},{layerType:"parking_field",label:"Parking Zone",area_weight:4,placement_priority:4,defaults:{car_parking_count:250}},{layerType:"drive_aisle",label:"Drive Aisle",area_weight:1,placement_priority:5,defaults:{circulation_width_ft:24}},{layerType:"sidewalk",label:"Sidewalk",area_weight:.5,placement_priority:6,defaults:{circulation_width_ft:8}},{layerType:"landscape_buffer",label:"Landscape Buffer",area_weight:.8,placement_priority:7,defaults:{buffer_distance_ft:15}},{layerType:"detention_basin",label:"Stormwater",area_weight:1.2,placement_priority:8,defaults:{depth_ft:5,stormwater_type:"detention"}},{layerType:"monument_sign",label:"Signage",area_weight:.5,placement_priority:9,defaults:{height_ft:8}}]},{id:"site_office",name:"Office Campus Site",description:"Office campus with building, parking, sidewalks, landscaping, plaza, and stormwater",subsystem:"BLD",category:"full_site",propertyType:"office",layers:[{layerType:"buildable_area",label:"Buildable Area",area_weight:1,placement_priority:1},{layerType:"building_footprint",label:"Building Footprint",area_weight:4,placement_priority:2,defaults:{height_ft:45,floor_count:3,building_type:"office"}},{layerType:"parking_field",label:"Parking Zone",area_weight:3,placement_priority:3,defaults:{car_parking_count:200}},{layerType:"sidewalk",label:"Sidewalk",area_weight:.8,placement_priority:4,defaults:{circulation_width_ft:8}},{layerType:"amenity_area",label:"Landscaping",area_weight:1.5,placement_priority:5,defaults:{amenity_pad_type:"landscaping"}},{layerType:"amenity_area",label:"Hardscape / Plaza",area_weight:1.2,placement_priority:6,defaults:{amenity_pad_type:"plaza"}},{layerType:"detention_basin",label:"Stormwater",area_weight:1,placement_priority:7,defaults:{depth_ft:5,stormwater_type:"detention"}}]},{id:"site_multifamily",name:"Multi-Family Site",description:"Residential community with buildings, clubhouse, pool, dog park, parking garage, EV charging, and stormwater",subsystem:"BLD",category:"full_site",propertyType:"multifamily",layers:[{layerType:"buildable_area",label:"Buildable Area",area_weight:1,placement_priority:1},{layerType:"building_footprint",label:"Building Footprint",area_weight:4,placement_priority:2,defaults:{height_ft:45,floor_count:4,building_type:"multifamily"}},{layerType:"building_footprint",label:"Clubhouse",area_weight:1.5,placement_priority:3,defaults:{height_ft:18,floor_count:1,building_type:"clubhouse"}},{layerType:"amenity_area",label:"Pool / Spa",area_weight:1,placement_priority:4,defaults:{amenity_pad_type:"pool"}},{layerType:"amenity_area",label:"Dog Park",area_weight:1,placement_priority:5,defaults:{amenity_pad_type:"dog_park"}},{layerType:"building_footprint",label:"Parking Garage",area_weight:2.5,placement_priority:6,defaults:{height_ft:36,floor_count:4,building_type:"parking_garage"}},{layerType:"drive_aisle",label:"Drive Aisle",area_weight:.8,placement_priority:7,defaults:{circulation_width_ft:22}},{layerType:"sidewalk",label:"Sidewalk",area_weight:.5,placement_priority:8,defaults:{circulation_width_ft:6}},{layerType:"parking_field",label:"EV Charging",area_weight:.5,placement_priority:9,defaults:{dc_parking_has_ev:!0}},{layerType:"landscape_buffer",label:"Landscape Buffer",area_weight:.8,placement_priority:10,defaults:{buffer_distance_ft:20}},{layerType:"detention_basin",label:"Stormwater",area_weight:1,placement_priority:11,defaults:{depth_ft:5,stormwater_type:"detention"}}]},{id:"site_data_center",name:"Data Center Campus",description:"Data center campus with building, generator yard, cooling yard, substation, E-House, security, and parking",subsystem:"BLD",category:"full_site",propertyType:"data_center",layers:[{layerType:"buildable_area",label:"Buildable Area",area_weight:1,placement_priority:1},{layerType:"building_footprint",label:"Data Hall",area_weight:4,placement_priority:2,defaults:{height_ft:40,floor_count:2,building_type:"data_center"}},{layerType:"dc_generator_yard",label:"Generator Yard",area_weight:2.5,placement_priority:3,defaults:{dc_gen_yard_count:8,dc_gen_yard_rating_kw:3e3,dc_gen_yard_fuel_type:"diesel"}},{layerType:"dc_cooling_tower_yard",label:"Cooling Yard",area_weight:2.5,placement_priority:4,defaults:{dc_cooling_tower_count:6,dc_cooling_tower_type:"induced_draft"}},{layerType:"dc_substation",label:"Substation",area_weight:2,placement_priority:5,defaults:{dc_substation_capacity_mva:100,dc_substation_type:"unit",dc_substation_voltage:"138kV"}},{layerType:"dc_ehouse",label:"E-House",area_weight:1.5,placement_priority:6,defaults:{dc_ehouse_count:4,dc_ehouse_type:"switchgear",height_ft:14}},{layerType:"perimeter_fence",label:"Security Fence",area_weight:.5,placement_priority:7,defaults:{dc_security_fence_height_ft:8,dc_security_fence_type:"anti_climb"}},{layerType:"dc_guardhouse",label:"Guardhouse",area_weight:.8,placement_priority:8,defaults:{dc_guardhouse_type:"full_service",dc_guardhouse_staffing:"24_7",height_ft:12}},{layerType:"parking_field",label:"Parking Zone",area_weight:1.5,placement_priority:9,defaults:{car_parking_count:75}},{layerType:"detention_basin",label:"Stormwater",area_weight:1,placement_priority:10,defaults:{depth_ft:6,stormwater_type:"detention"}}]},{id:"site_self_storage",name:"Self-Storage Site",description:"Self-storage facility with buildings, drive aisles, office, fencing, and parking",subsystem:"BLD",category:"full_site",propertyType:"self_storage",layers:[{layerType:"buildable_area",label:"Buildable Area",area_weight:1,placement_priority:1},{layerType:"building_footprint",label:"Storage Building",area_weight:5,placement_priority:2,defaults:{height_ft:30,floor_count:3,building_type:"self_storage"}},{layerType:"drive_aisle",label:"Drive Aisle",area_weight:2,placement_priority:3,defaults:{cir
761culation_width_ft:28}},{layerType:"office_area",label:"Office / Retail",area_weight:1.5,placement_priority:4,defaults:{height_ft:12}},{layerType:"perimeter_fence",label:"Fencing",area_weight:.5,placement_priority:5,defaults:{dc_security_fence_height_ft:8,dc_security_fence_type:"ornamental"}},{layerType:"parking_field",label:"Parking Zone",area_weight:1.5,placement_priority:6,defaults:{car_parking_count:15}}]},{id:"site_mixed_use",name:"Mixed-Use Site",description:"Mixed-use development with building, retail pad, parking garage, sidewalks, plaza, and landscaping",subsystem:"BLD",category:"full_site",propertyType:"mixed_use",layers:[{layerType:"buildable_area",label:"Buildable Area",area_weight:1,placement_priority:1},{layerType:"building_footprint",label:"Building Footprint",area_weight:4,placement_priority:2,defaults:{height_ft:65,floor_count:5,building_type:"mixed_use"}},{layerType:"retail_pad",label:"Retail Pad",area_weight:1.5,placement_priority:3,defaults:{height_ft:20,building_type:"retail_pad"}},{layerType:"building_footprint",label:"Parking Garage",area_weight:2.5,placement_priority:4,defaults:{height_ft:36,floor_count:4,building_type:"parking_garage"}},{layerType:"sidewalk",label:"Sidewalk",area_weight:.5,placement_priority:5,defaults:{circulation_width_ft:10}},{layerType:"amenity_area",label:"Hardscape / Plaza",area_weight:1.2,placement_priority:6,defaults:{amenity_pad_type:"plaza"}},{layerType:"landscape_buffer",label:"Landscape Buffer",area_weight:.8,placement_priority:7,defaults:{buffer_distance_ft:10}}]},{id:"site_flex",name:"Flex / R&D Site",description:"Flex/R&D campus with building, loading, parking, landscaping, and stormwater",subsystem:"BLD",category:"full_site",propertyType:"flex",layers:[{layerType:"buildable_area",label:"Buildable Area",area_weight:1,placement_priority:1},{layerType:"building_footprint",label:"Building Footprint",area_weight:4,placement_priority:2,defaults:{height_ft:28,floor_count:1,building_type:"flex"}},{layerType:"loading_berth",label:"Loading Berth",area_weight:1.5,placement_priority:3,defaults:{dock_count:8,dock_spacing_ft:12}},{layerType:"parking_field",label:"Parking Zone",area_weight:3,placement_priority:4,defaults:{car_parking_count:120}},{layerType:"landscape_buffer",label:"Landscape Buffer",area_weight:1,placement_priority:5,defaults:{buffer_distance_ft:15}},{layerType:"detention_basin",label:"Stormwater",area_weight:1,placement_priority:6,defaults:{depth_ft:5,stormwater_type:"detention"}}]}],yT=[...Y$,...X$],K$=yT.filter(t=>t.category==="component"),J$=yT.filter(t=>t.category==="full_site");function Q$({kit:t,onPlaceKit:s,onAutoPlaceKit:n,availableSites:a=[],disabled:l}){const c=Vj[t.subsystem];return e.jsxs("div",{className:"border border-border rounded-md p-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Da,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:t.name}),c&&e.jsx(Mt,{variant:"outline",className:"text-[9px] px-1 py-0",children:c.prefix})]}),e.jsx(Le,{size:"sm",variant:"outline",className:"h-6 text-[10px] px-2",onClick:()=>s(t),disabled:l,children:"Place Kit"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground leading-tight",children:t.description}),e.jsx("div",{className:"flex flex-wrap gap-1",children:t.layers.map(u=>e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1.5 py-0",children:u.label},`${u.layerType}-${u.placement_priority}`))}),a.length>0&&n&&e.jsx("div",{className:"pt-1",children:e.jsxs(rt,{onValueChange:u=>{const i=a.find(_=>_.id===u);i&&n(t,i.overlay)},children:[e.jsx(it,{className:"h-6 text-[10px]",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ji,{className:"w-3 h-3"}),e.jsx(ct,{placeholder:"Place in Site…"})]})}),e.jsx(ot,{children:a.map(u=>e.jsx(le,{value:u.id,className:"text-xs",children:u.name},u.id))})]})})]})}function G2({title:t,icon:s,kits:n,defaultOpen:a,...l}){const[c,u]=k.useState(a??!1);return e.jsxs(wi,{open:c,onOpenChange:u,children:[e.jsxs(Ni,{className:"flex items-center gap-1.5 w-full py-1 text-[10px] font-semibold text-muted-foreground uppercase tracking-wider hover:text-foreground transition-colors",children:[e.jsx(Ao,{className:`w-3 h-3 transition-transform ${c?"rotate-90":""}`}),s,e.jsx("span",{children:t}),e.jsx(Mt,{variant:"secondary",className:"text-[9px] px-1 py-0 ml-auto",children:n.length})]}),e.jsx(ki,{children:e.jsx("div",{className:"space-y-2 pt-1.5",children:n.map(i=>e.jsx(Q$,{kit:i,onPlaceKit:l.onPlaceKit,onAutoPlaceKit:l.onAutoPlaceKit,availableSites:l.availableSites,disabled:l.disabled},i.id))})})]})}function U$({onPlaceKit:t,onAutoPlaceKit:s,availableSites:n=[],disabled:a}){return e.jsxs(ns,{title:"Yard Kit Templates",icon:e.jsx(A1,{className:"w-4 h-4"}),defaultOpen:!1,children:[e.jsx("p",{className:"text-[10px] text-muted-foreground mb-3",children:"Place a pre-configured assembly of related layers as a 
761single unit. Each layer remains independently editable after placement."}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(G2,{title:"Component Kits",icon:e.jsx(Da,{className:"w-3 h-3"}),kits:K$,defaultOpen:!1,onPlaceKit:t,onAutoPlaceKit:s,availableSites:n,disabled:a}),e.jsx(G2,{title:"Full Site Kits",icon:e.jsx(Ci,{className:"w-3 h-3"}),kits:J$,defaultOpen:!1,onPlaceKit:t,onAutoPlaceKit:s,availableSites:n,disabled:a})]})]})}function e7({overlay:t}){const s=lu(t.layer_type),n=k.useMemo(()=>{const l=t.geometry;if(!l||l.length<3)return{areaAcres:0,areaSqft:0,perimeter:0,vertices:0,volume:0,centroid:{lat:0,lng:0}};const c=l.reduce((y,x)=>({lat:y.lat+x.lat/l.length,lng:y.lng+x.lng/l.length}),{lat:0,lng:0}),u=t.calculated_area_sqft||0,i=u/43560,_=t.calculated_perimeter_ft||0,j=t.height_ft?u*t.height_ft:0;return{areaAcres:i,areaSqft:u,perimeter:_,vertices:l.length,volume:j,centroid:c}},[t.geometry,t.calculated_area_sqft,t.calculated_perimeter_ft,t.height_ft]),a=()=>{const l=`${n.centroid.lat.toFixed(6)}, ${n.centroid.lng.toFixed(6)}`;navigator.clipboard.writeText(l),Ve.success("Coordinates copied")};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gy,{className:"w-4 h-4 text-primary"}),e.jsx(B,{className:"text-sm font-medium",children:"Polygon Metrics"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 border",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Area (Acres)"}),e.jsx("div",{className:"text-lg font-semibold",children:n.areaAcres.toFixed(2)})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 border",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Area (SF)"}),e.jsx("div",{className:"text-lg font-semibold",children:n.areaSqft.toLocaleString()})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 border",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Perimeter"}),e.jsxs("div",{className:"text-lg font-semibold",children:[Math.round(n.perimeter).toLocaleString()," ft"]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 border",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Vertices"}),e.jsx("div",{className:"text-lg font-semibold",children:n.vertices})]})]}),s&&t.height_ft&&t.height_ft>0&&e.jsxs("div",{className:"bg-primary/5 rounded-lg p-3 border border-primary/20",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-primary font-medium mb-1",children:[e.jsx(cm,{className:"w-3.5 h-3.5"}),"3D Volume"]}),e.jsxs("div",{className:"text-lg font-semibold",children:[n.volume.toLocaleString(void 0,{maximumFractionDigits:0})," cu ft"]}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[n.areaSqft.toLocaleString()," SF × ",t.height_ft," ft height"]})]}),e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ji,{className:"w-4 h-4 text-muted-foreground"}),"Centroid"]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 border flex items-center justify-between",children:[e.jsxs("div",{className:"font-mono text-xs",children:[n.centroid.lat.toFixed(6),", ",n.centroid.lng.toFixed(6)]}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:a,children:e.jsx(hp,{className:"w-3.5 h-3.5"})})]})]}),s&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(B,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Ci,{className:"w-4 h-4 text-muted-foreground"}),"Building Details"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"flex justify-between bg-muted/30 rounded p-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Floors:"}),e.jsx("span",{className:"font-medium",children:t.floor_count||1})]}),e.jsxs("div",{className:"flex justify-between bg-muted/30 rounded p-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Floor Height:"}),e.jsxs("span",{className:"font-medium",children:[t.floor_height_ft||12," ft"]})]}),e.jsxs("div",{className:"flex justify-between bg-muted/30 rounded p-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Height:"}),e.jsxs("span",{className:"font-medium",children:[t.height_ft||0," ft"]})]}),e.jsxs("div",{className:"flex justify-between bg-muted/30 rounded p-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Roof Type:"}),e.jsx("span",{className:"font-medium capitalize",children:t.roof_type||"flat"})]}),t.dock_count&&t.dock_count>0&&e.jsxs("div",{className:"flex justify-between bg-muted/30 rounded p-2 col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Dock Doors:"}),e.jsx("span",{className:"font-medium",children:t.dock_count})]})]})]})]}),(t.width_ft||t.depth_ft)&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(B,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Fo,{className:"w-4 h-4 text-muted-foreground"}),"Custom Dimensions"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[t.width_ft&&e.jsxs("div",{className:"flex justify-between bg-muted/30 rounded p-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Width:"}),e.jsxs("span",{className:"font-medium",children:[t.width_ft," ft"]})]}),t.depth_ft&&e.jsxs("div",{className:"flex justify-between bg-muted/30 rounded p-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Depth:"}),e.jsxs("span",{className:"font-medium",children:[t.depth_ft," ft"]})]})]})]})]})]})}function vT({open:t,onClose:s,overlay:n,allOverlays:a=[],mode:l="2d",onModeChange:c,initialTab:u,onNavigateToOverlay:i,onSelectOverlay:_,onCreateChildLayer:j,onPlaceYardKit:y,onAutoPlaceYardKit:x,isPinned:v=!1,onPinnedChange:C,transformMode:P,onTransformModeChange:I,scaleAxis:z,onScaleAxisChange:F,mapRef:D,onStartDockEdgeSelection:X,onCancelDockEdgeSelection:K,dockEdgeSelectionMode:te,pendingDockEdgeIndex:J,onStartWindowEdgeSelection:H,onCancelWindowEdgeSelection:O,windowEdgeSelectionMode:q,onStartCanopyEdgeSelection:W,onCancelCanopyEdgeSelection:Q,canopyEdgeSelectionMode:Z,onStartStorefrontEdgeSelection:oe,onCancelStorefrontEdgeSelection:ce,storefrontEdgeSelectionMode:ae,onStartDriveInEdgeSelection:ie,onCancelDriveInEdgeSelection:de,driveInEdgeSelectionMode:ge,treeEditMode:We,onTreeEditModeChange:Ee,onStart
761SignPlacement:ve,onCancelSignPlacement:we,signPlacementMode:Ze,placingSignId:ke,onOpenImageDialog:ze,onOpenSite360AI:Ke,developmentId:dt,propertyType:Re="industrial",stallEditorEnabled:qt,onStallEditorEnabledChange:ft,selectedStallId:Fe,onSelectedStallIdChange:fe,selectedEntryId:Qe,onSelectedEntryIdChange:ht,entryPointPlacementMode:_t=!1,onStartEntryPointPlacement:He,onCancelEntryPointPlacement:as,onStartCutoutDrawing:vt}){const[Xe,Ce]=k.useState("layers"),[Be,Dt]=k.useState(!1),[Rt,zt]=k.useState({x:window.innerWidth-536,y:80}),[rs,_s]=k.useState(!1),[vs,$t]=k.useState({x:0,y:0}),[Ns,Ts]=k.useState({width:500,height:1147}),[bs,en]=k.useState(null),[Jt,Vs]=k.useState({x:0,y:0,width:0,height:0}),[ps,nt]=k.useState(!1),[ts,ds]=k.useState(null),[Is,tn]=k.useState(null),wn=qt??ps,Gs=ft??nt,Ue=Fe??ts,Pe=fe??ds,je=Qe??Is,Ge=ht??tn,De=pu(),bt=Sp(),Ct=ym(),pe=async(Zs,Cn,Na)=>{try{await Ct.mutateAsync({name:`${Zs.name} - Floor L${Cn}`,type:"polygon",geometry:Zs.geometry,style:{color:"#b0b0b0",fillColor:"#b0b0b0",fillOpacity:.3,weight:1,dashArray:"4 4"},is_visible:!0,layer_type:"building_floor",parent_overlay_id:Zs.id,floor_level:Cn,floor_thickness_in:Na,development_id:Zs.development_id,existing_product_id:Zs.existing_product_id,folder_id:Zs.folder_id}),Ve.success(`Floor slab L${Cn} added`)}catch{Ve.error("Failed to create floor slab")}},wt=async(Zs,Cn)=>{try{await De.mutateAsync({id:Zs,...Cn})}catch{Ve.error("Failed to update floor slab")}},Zt=async Zs=>{try{await bt.mutateAsync(Zs),Ve.success("Floor slab removed")}catch{Ve.error("Failed to remove floor slab")}},{recalculateParking:ys}=XD(),es=k.useMemo(()=>{if(!n||!n.geometry||n.geometry.length<3)return{driveAisles:[],parkingRows:[]};if(!PE(n.layer_type))return{driveAisles:[],parkingRows:[]};n.style;const Zs={...kj(),stallWidth_ft:n.parking_stall_width_ft||9,stallDepth_ft:n.parking_stall_depth_ft||18,aisleWidth_ft:n.parking_aisle_width_ft||24,layoutType:n.parking_layout_type||"double_loaded",stripingVisible:n.parking_striping_visible??!0};try{const Cn=Hm(n.geometry,Zs),Na=Cn.driveAisles.map(Pr=>({id:Pr.id,width_ft:Pr.width_ft,labelText:Pr.labelText})),Gn=new Map;Cn.stalls.filter(Pr=>!Pr.isRemoved).forEach(Pr=>{const oi=Pr.id.split("-"),Tr=`row-${oi[1]}-${oi[2]||"top"}`;Gn.has(Tr)||Gn.set(Tr,{rowIndex:parseInt(oi[1],10)||0,side:oi[2]||"top",stallCount:0}),Gn.get(Tr).stallCount++});const sa=Array.from(Gn.entries()).map(([Pr,oi])=>({rowId:Pr,rowIndex:oi.rowIndex,side:oi.side,stallCount:oi.stallCount})).sort((Pr,oi)=>Pr.rowIndex-oi.rowIndex);return{driveAisles:Na,parkingRows:sa}}catch(Cn){return console.warn("[UnifiedDrawingPanel] Failed to generate parking layout:",Cn),{driveAisles:[],parkingRows:[]}}},[n==null?void 0:n.id,n==null?void 0:n.geometry,n==null?void 0:n.layer_type,n==null?void 0:n.parking_stall_width_ft,n==null?void 0:n.parking_stall_depth_ft,n==null?void 0:n.parking_aisle_width_ft,n==null?void 0:n.parking_layout_type,n==null?void 0:n.parking_striping_visible]),is=sP({overlay:n||void 0}),{transformState:Ws,setTransformMode:an,setScaleAxis:ya,startTransform:Hs,updateTransform:xt,endTransform:os,cancelTransform:Ls,resetTransform:Es,isUpdating:Qs}=tP({overlay:n||void 0,onTransformComplete:Zs=>{(n==null?void 0:n.layer_type)==="building_footprint"&&ys(n),is.pushToHistory(Ws.mode==="move"?"move":Ws.mode==="rotate"?"rotate":"scale",Zs,`${Ws.mode} transform applied`)}}),Pn=P!==void 0?P:Ws.mode==="none"?null:Ws.mode,Ks=I||an,xa=z||Ws.scaleAxis,Fn=F||ya;YD({isActive:t&&Pn!==null,onUndo:is.undo,onRedo:is.redo,canUndo:is.canUndo,canRedo:is.canRedo,onCancel:Ls,onReset:Es}),k.useEffect(()=>{if(!rs)return;const Zs=Na=>{const Gn=Na.clientX-vs.x,sa=Na.clientY-vs.y,Pr=20;zt({x:Math.max(Pr,Math.min(window.innerWidth-400,Gn)),y:Math.max(Pr,Math.min(window.innerHeight-200,sa))})},Cn=()=>{_s(!1)};return window.addEventListener("mousemove",Zs),window.addEventListener("mouseup",Cn),()=>{window.removeEventListener("mousemove",Zs),window.removeEventListener("mouseup",Cn)}},[rs,vs]),k.useEffect(()=>{if(!bs)return;const Zs=Na=>{const Gn=Na.clientX-Jt.x,sa=Na.clientY-Jt.y,Pr=320,oi=800,Tr=300,Ko=window.innerHeight-100;if(bs==="right"||bs==="corner"){const Za=Math.max(Pr,Math.min(oi,Jt.width+Gn));Ts(Gr=>({...Gr,width:Za}))}if(bs==="bottom"||bs==="corner"){const Za=Math.max(Tr,Math.min(Ko,Jt.height+sa));Ts(Gr=>({...Gr,height:Za}))}},Cn=()=>{en(null)};return window.addEventListener("mousemove",Zs),window.addEventListener("mouseup",Cn),()=>{window.removeEventListener("mousemove",Zs),window.removeEventListener("mouseup",Cn)}},[bs,Jt]);const Sa=(Zs,Cn)=>{Zs.preventDefault(),Zs.stopPropagation(),en(Cn),Vs({x:Zs.clientX,y:Zs.clientY,width:Ns.width,height:Ns.height})},{polygonMetrics:sr,isUpdating:An,updateVisualStyle:Ai,toggleAreaLabel:xi,setAreaLabelUnit:ei,toggleMeasurements:Yr,updateLayerType:Xo}=UE(n||void 0);if(k.useEffect(()=>{t&&!v&&C&&C(!0)},[t]),k.useEffect(()=>{n&&(u?Ce(u):l==="3d"&&lu(n.layer_type)&&Ce("build"),Gs(!1),Pe(null))},[n==null?void 0:n.id,l,u]),k.useEffect(()=>{var Na;if(!D||!Ws.isTransforming)return;(Na=D.dragging)==null||Na.disable();const Zs=Gn=>{xt({lat:Gn.latlng.lat,lng:Gn.latlng.lng})},Cn=()=>{os()};return D.on("mousemove",Zs),D.on("mouseup",Cn),()=>{var Gn;D.off("mousemove",Zs),D.off("mouseup",Cn);try{(Gn=D.dragging)==null||Gn.enable()}catch{}}},[D,Ws.isTransforming,xt,os]),!n){if(!t)return null;const Zs=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`px-6 py-4 border-b ${Be?"cursor-move":""}`,onMouseDown:Be?Cn=>{Cn.target.closest("button")||(Cn.preventDefault(),_s(!0),$t({x:Cn.clientX-Rt.x,y:Cn.clientY-Rt.y}))}:void 0,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsxs("h3",{className:"flex items-center gap-2 text-lg font-semibold cursor-default",children:[Be&&e.jsx(Fh,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(Da,{className:"w-5 h-5 text-orange-500"}),e.jsx("span",{children:"Site Layouts"}),e.jsx(Mt,{variant:"secondary",className:"ml-2",children:a.length})]})}),e.jsx(or,{children:"Unified Drawing Panel"})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Le,{variant:Be?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{Dt(!Be),Ve.success(Be?"Panel docked":"Panel detached")},title:Be?"Dock panel":"Detach panel",children:Be?e.jsx(Cf,{className:"h-3.5 w-3.5"}):e.jsx(Wy,{className:"h-3.5 w-3.5"})}),!Be&&e.jsx(Le,{variant:v?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{const Cn=!v;C==null||C(Cn),Ve.success(Cn?"Panel pinned":"Panel unpinned")},title:v?"Unpin panel":"Pin panel",children:v?e.jsx(rN,{className:"h-3.5 w-3.5"}):e.jsx(Bb,{className:"h-3.5 w-3.5"})}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:s,title:"Close",children:e.jsx(ja,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx(Xc,{className:"flex-1 min-h-0",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(wx,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm font-medium",children:"Select a layer from Site Layouts to edit"}),e.jsx("p",{className:"text-xs mt-1.5",children:"Choose a layer in the left sidebar, or draw a new polygon on the map"})]}),e.jsx(U$,{onPlaceKit:Cn=>{y==null||y(Cn)},onAutoPlaceKit:x?(Cn,Na)=>
761{x(Cn,Na)}:void 0,availableSites:a.filter(Cn=>{const Na=Cn.layer_type,Gn=Na==="site"||Na==="site_boundary"||Na==="assemblage"||Na==="property_outline",sa=Cn.geometry&&Array.isArray(Cn.geometry)&&Cn.geometry.length>=3;return Gn&&sa}).map(Cn=>({id:Cn.id,name:Cn.name,overlay:Cn}))})]})})]});return Be?e.jsx("div",{className:"fixed flex flex-col shadow-2xl overflow-hidden z-[1050] bg-background border rounded-lg",style:{left:Rt.x,top:Rt.y,width:480,height:"min(600px, calc(100vh - 100px))"},children:Zs}):e.jsx("div",{className:"fixed right-0 w-[420px] sm:w-[480px] flex flex-col p-0 shadow-2xl overflow-hidden z-[1050] bg-background border-l",style:{top:"100px",height:"calc(100vh - 100px)"},children:Zs})}const ra=!!n.parent_overlay_id,Ka=ra?a.find(Zs=>Zs.id===n.parent_overlay_id):null,Ha=a.filter(Zs=>Zs.parent_overlay_id===n.id);lu(n.layer_type);const qa=async Zs=>{await De.mutateAsync({id:n.id,...Zs})},Mn=async()=>{const Cn=Ha.length>0?`This will also delete ${Ha.length} child layer(s). Continue?`:`Delete "${n.name}"?`;if(confirm(Cn))try{for(const Na of Ha)await bt.mutateAsync(Na.id);await bt.mutateAsync(n.id),Ve.success("Layer deleted"),s()}catch{Ve.error("Failed to delete layer")}},_r=()=>Pn==="move"?"Drag":Pn==="rotate"?`${(n.rotation_degrees||0).toFixed(0)}°`:Pn==="scale"?`${((n.scale_factor||1)*100).toFixed(0)}%`:"",Ar=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`px-6 py-4 border-b ${Be?"cursor-move":""}`,onMouseDown:Be?Zs=>{Zs.target.closest("button")||(Zs.preventDefault(),_s(!0),$t({x:Zs.clientX-Rt.x,y:Zs.clientY-Rt.y}))}:void 0,children:[ra&&Ka&&e.jsxs("button",{onClick:()=>i==null?void 0:i(Ka.id),className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors mb-2 -mt-1",children:[e.jsx(t3,{className:"w-3 h-3"}),e.jsx("span",{className:"truncate max-w-[200px]",children:Ka.name})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[Be&&e.jsx(Fh,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(Il,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"truncate max-w-[140px] font-semibold",children:n.name}),ra&&e.jsx(Mt,{variant:"secondary",className:"text-[10px]",children:"Child"})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[c&&e.jsxs("div",{className:"flex items-center bg-muted/50 rounded-md p-0.5",children:[e.jsxs(Le,{variant:l==="2d"?"secondary":"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1",onClick:()=>c("2d"),children:[e.jsx(ph,{className:"w-3 h-3"}),"2D"]}),e.jsxs(Le,{variant:l==="3d"?"secondary":"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1",onClick:()=>c("3d"),children:[e.jsx(cm,{className:"w-3 h-3"}),"3D"]})]}),e.jsx(Le,{variant:Be?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{Dt(!Be),Ve.success(Be?"Panel docked":"Panel detached")},title:Be?"Dock panel":"Detach panel",children:Be?e.jsx(Cf,{className:"h-3.5 w-3.5"}):e.jsx(Wy,{className:"h-3.5 w-3.5"})}),!Be&&e.jsx(Le,{variant:v?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{const Zs=!v;C==null||C(Zs),Ve.success(Zs?"Panel pinned":"Panel unpinned")},title:v?"Unpin panel":"Pin panel",children:v?e.jsx(rN,{className:"h-3.5 w-3.5"}):e.jsx(Bb,{className:"h-3.5 w-3.5"})}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:s,title:"Hide panel",children:e.jsx(ja,{className:"h-3.5 w-3.5"})})]})]})]}),(l==="3d"||D)&&Ks&&e.jsxs("div",{className:"px-6 pb-3 border-b",children:[e.jsxs("div",{className:"flex items-center gap-0.5 bg-muted/50 rounded-lg p-0.5",children:[e.jsx(Le,{variant:Pn==="move"?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>Ks(Pn==="move"?null:"move"),title:"Move (M)",children:e.jsx(If,{className:"h-3.5 w-3.5"})}),e.jsx(Le,{variant:Pn==="rotate"?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>Ks(Pn==="rotate"?null:"rotate"),title:"Rotate (R)",children:e.jsx(S0,{className:"h-3.5 w-3.5"})}),e.jsx(Le,{variant:Pn==="scale"?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>Ks(Pn==="scale"?null:"scale"),title:"Scale (S)",children:e.jsx(Mf,{className:"h-3.5 w-3.5"})}),Pn&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-4 bg-border mx-0.5"}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:is.undo,disabled:!is.canUndo,title:"Undo (Ctrl+Z)",children:e.jsx(zf,{className:"h-3.5 w-3.5"})}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:is.redo,disabled:!is.canRedo,title:"Redo (Ctrl+Shift+Z)",children:e.jsx(U1,{className:"h-3.5 w-3.5"})})]})]}),Pn==="scale"&&Fn&&e.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-dashed",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Scale:"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(Le,{variant:xa==="width"?"secondary":"ghost",size:"sm",onClick:()=>Fn("width"),className:"h-6 text-xs px-2",children:[e.jsx(vS,{className:"w-3 h-3 mr-1"}),"Width"]}),e.jsxs(Le,{variant:xa==="length"?"secondary":"ghost",size:"sm",onClick:()=>Fn("length"),className:"h-6 text-xs px-2",children:[e.jsx(bS,{className:"w-3 h-3 mr-1"}),"Length"]}),e.jsxs(Le,{variant:xa==="both"?"secondary":"ghost",size:"sm",onClick:()=>Fn("both"),className:"h-6 text-xs px-2",children:[e.jsx(yS,{className:"w-3 h-3 mr-1"}),"Both"]})]}),Pn&&e.jsx(Mt,{variant:"secondary",className:"text-xs font-mono ml-auto",children:_r()})]})]}),e.jsxs(Zm,{value:Xe,onValueChange:Ce,className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-4 pt-3 border-b space-y-2",children:[e.jsxs(mm,{className:"w-full grid grid-cols-5 h-9",children:[e.jsxs(Bi,{value:"layers",className:"text-xs gap-1 px-2",children:[e.jsx(Da,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Layers"})]}),e.jsxs(Bi,{value:"visual",className:"text-xs gap-1 px-2",children:[e.jsx(C0,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Visual"})]}),e.jsxs(Bi,{value:"build",className:"text-xs gap-1 px-2",children:[e.jsx(sj,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Build"})]}),e.jsxs(Bi,{value:"site",className:"text-xs gap-1 px-2",children:[e.jsx(ji,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Site"})]}),e.jsxs(Bi,{value:"data",className:"text-xs gap-1 px-2",children:[e.jsx(_g,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Data"})]})]}),e.jsxs(mm,{className:"w-full grid grid-cols-4 h-8",children:[e.jsxs(Bi,{value:"media",className:"text-xs gap-1 px-2",children:[e.jsx(Zd,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Media"})]}),e.jsxs(Bi,{value:"annotate",className:"text-xs gap-1 px-2",children:[e.jsx(Vy,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Annotate"})]}),e.jsxs(Bi,{value:"workflow",className:"text-xs gap-1 px-2",children:[e.jsx(Ox,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Workflow"})]}),e.jsxs(Bi,{value:"stats",className:"text-xs gap-1 px-2",children:[e.jsx(Gy,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Stats"})]})]})]}),e.jsx(Xc,{className:"flex-1 min-h-0",children:e.jsxs("div",{className:"p-4 space-y-6 pb-6",children:[e.jsx($i,{value:"visual",className:"m-0",children:e.jsx(_R,{overlay:n,onUpdate:qa,mode:l,isUpdating:An})}),e.jsx($i,{value:"build",className:"m-0",children:e.jsx(c8,{overlay:n,allOverlays:a,onUpdate:qa,mode:l,isUpdating:An,onStartWindowEdgeSelection:H,onCancelWindowEdgeSelection:O,windowEdgeSelectionMode:q,onStartCanopyEdgeSelection:W,onCancelCanopyEdgeSelection:Q,canopyEdgeSelectionMode:Z,onStartStorefrontEdgeSelection:oe,onCancelStorefrontEdgeSelection:ce,storefrontEdgeSelectionMode:ae,onStartDockEdgeSelection:X,onCancelDockEdgeSelection:K,dockEdgeSelectionMode:te,onStartDriveInEdgeSelection:ie,onCancelDriveInEdgeSelection:de,driveInEdgeSelectionMode:ge,stallEditorEnabled:wn,onToggleStallEditor:Gs,selectedStallId:Ue,onSelectedStallIdChange:Pe,driveAisles:es.driveAisles,parkingRows:es.parkingRows,selectedEntryId:je,onSelectedEntryIdChange:Ge,entryPointPlacementMode:_t,onStartEntryPointPlacement:He,onCancelEntryPointPlacement:as,onStartCutoutDrawing:vt,onCreateFloorSlab:pe,onUpdateChildOverlay:wt,onDeleteChildOverlay:Zt})}),e.jsx($i,{value:"site",className:"m-0",children:e.jsx(B$,{overlay:n,allOverlays:a,parentOverlay:Ka,onUpdate:qa,isUpdating:An,treeEditMode:We,onTreeEditModeChange:Ee,onStart
761SignPlacement:ve,onCancelSignPlacement:we,signPlacementMode:Ze,placingSignId:ke,stallEditorEnabled:wn,onToggleStallEditor:Gs,selectedStallId:Ue,onSelectedStallIdChange:Pe,developmentId:dt,onCreateChildOverlay:async Zs=>{try{const Cn=await Ct.mutateAsync({name:Zs.name,type:"polygon",geometry:Zs.geometry,layer_type:Zs.layer_type,height_ft:Zs.height_ft||null,style:Zs.style||{},description:Zs.description||null,is_visible:!0,parent_overlay_id:Zs.parent_overlay_id,created_by:n.created_by,folder_id:n.folder_id||null});return Cn==null?void 0:Cn.id}catch(Cn){console.error("Failed to create child overlay:",Cn);return}}})}),e.jsx($i,{value:"data",className:"m-0",children:e.jsx(V$,{overlay:n,allOverlays:a,parentOverlay:Ka,onUpdate:qa,toggleAreaLabel:xi,setAreaLabelUnit:ei,toggleMeasurements:Yr,isUpdating:An})}),e.jsx($i,{value:"layers",className:"m-0",children:e.jsx(G$,{overlay:n,allOverlays:a,parentOverlay:Ka,childLayers:Ha,onUpdate:qa,updateLayerType:Xo,onNavigateToOverlay:i,onSelectOverlay:_,onCreateChildLayer:j,isUpdating:An})}),e.jsx($i,{value:"media",className:"m-0",children:e.jsx(H$,{overlay:n,onUpdate:qa,onOpenImageDialog:ze,onOpenSite360AI:Ke,isUpdating:An})}),e.jsx($i,{value:"annotate",className:"m-0",children:e.jsx(W$,{overlay:n,onUpdate:qa,isUpdating:An})}),e.jsx($i,{value:"workflow",className:"m-0",children:e.jsx(Z$,{overlay:n,onUpdate:qa,isUpdating:An})}),e.jsx($i,{value:"stats",className:"m-0",children:e.jsx(e7,{overlay:n})})]})})]}),e.jsxs("div",{className:"px-4 py-3 border-t bg-muted/30 flex justify-between",children:[e.jsxs(Le,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive gap-1",onClick:Mn,disabled:De.isPending||bt.isPending,children:[e.jsx(wr,{className:"w-3.5 h-3.5"}),"Delete"]}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[Ha.length>0&&e.jsxs("span",{children:[Ha.length," child layer",Ha.length>1?"s":""]}),Pn&&e.jsx(Mt,{variant:"outline",className:"text-[10px]",children:Pn==="move"?"Moving":Pn==="rotate"?"Rotating":"Scaling"})]})]})]});return Be&&t?e.jsxs("div",{className:`fixed z-[1002] bg-background border border-border rounded-xl shadow-2xl flex flex-col overflow-hidden ${rs?"cursor-grabbing":""} ${bs?"select-none":""}`,style:{left:Rt.x,top:Rt.y,width:Ns.width,height:Ns.height},children:[Ar,e.jsx("div",{className:"absolute top-0 right-0 w-2 h-full cursor-ew-resize hover:bg-primary/20 transition-colors",onMouseDown:Zs=>Sa(Zs,"right")}),e.jsx("div",{className:"absolute bottom-0 left-0 h-2 w-full cursor-ns-resize hover:bg-primary/20 transition-colors",onMouseDown:Zs=>Sa(Zs,"bottom")}),e.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize hover:bg-primary/30 transition-colors rounded-br-xl",onMouseDown:Zs=>Sa(Zs,"corner"),children:e.jsx("svg",{className:"w-4 h-4 text-muted-foreground/50",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M14 10v4h-4v-2h2v-2h2zm0-4v2h-2V6h2zm-4 6v2H8v-2h2zm-4 0v2H4v-2h2z"})})})]}):t?e.jsx("div",{className:"fixed right-0 w-[500px] flex flex-col p-0 shadow-2xl overflow-hidden z-[1050] bg-background border-l",style:{top:"100px",height:"calc(100vh - 100px)"},children:Ar}):null}function t7(t){const s=t.map(n=>[n.lng,n.lat]);if(s.length>0){const n=s[0],a=s[s.length-1];(n[0]!==a[0]||n[1]!==a[1])&&s.push([...n])}return s}function s7(t){let s=t.map(([n,a])=>({lat:a,lng:n}));if(s.length>=2){const n=s[0],a=s[s.length-1];n.lat===a.lat&&n.lng===a.lng&&(s=s.slice(0,-1))}return s}function n7(t){let s=0,n=0;for(let a=0;a<t.length-1;a++){const l=us(t[a]),c=us(t[a+1]),u=gi(l,c,{units:"kilometers"});u>n&&(n=u,s=Or(l,c))}return s}function a7(t,s,n,a,l,c){const u=us(t),i=n/2,_=-i+l*n,j=-i+c*n,y=a/2,x=s+90,v=On(u,_,s,{units:"kilometers"}),C=On(u,j,s,{units:"kilometers"}),P=On(v,-y,x,{units:"kilometers"}),I=On(v,y,x,{units:"kilometers"}),z=On(C,y,x,{units:"kilometers"}),F=On(C,-y,x,{units:"kilometers"}),D=[P.geometry.coordinates,I.geometry.coordinates,z.geometry.coordinates,F.geometry.coordinates,P.geometry.coordinates];return Xn([D])}function r7(t,s){const a=Yo(t).geometry.coordinates,l=t.geometry.coordinates[0];let c=1/0,u=-1/0,i=1/0,_=-1/0;const j=us(a);for(const y of l){const x=us(y),v=gi(j,x,{units:"kilometers"}),P=(Or(j,x)-s)*Math.PI/180,I=v*Math.cos(P),z=v*Math.sin(P);
761c=Math.min(c,I),u=Math.max(u,I),i=Math.min(i,z),_=Math.max(_,z)}return{lengthKm:u-c,widthKm:_-i,centroid:a}}function i7(t,s,n){var v;let a;if(s){const C=Df(s);(v=C==null?void 0:C.innerPolygon)!=null&&v[0]&&C.innerPolygon[0].length>=4?a=C.innerPolygon[0].map(P=>({lat:P[1],lng:P[0]})):a=Ib(t)}else a=Ib(t);if(a.length<3)return[];const l=t7(a);if(l.length<4)return[];let c;try{c=Xn([l])}catch{return[]}const u=n7(l),i=r7(c,u),_=[...n.layers].sort((C,P)=>(C.placement_priority??99)-(P.placement_priority??99)),j=_.reduce((C,P)=>C+(P.area_weight??1),0),y=[];let x=0;for(const C of _){const I=(C.area_weight??1)/j,z=x+I,F=a7(i.centroid,u,i.lengthKm*1.2,i.widthKm*1.2,x,z);try{const D=xm(Un([qm(c.geometry),qm(F.geometry)]));if(D&&D.geometry){const X=D.geometry.type==="MultiPolygon"?D.geometry.coordinates[0][0]:D.geometry.coordinates[0];zr(D)>10&&y.push({layerType:C.layerType,label:C.label,geometry:s7(X),defaults:C.defaults})}}catch(D){console.warn(`[yardKitAutoLayout] Failed to clip layer ${C.label}:`,D)}x=z}return y}const qi={building_footprint:{color:"#f97316",fillOpacity:.4,defaultHeightFt:32},dock_door:{color:"#d97706",fillOpacity:.6,defaultHeightFt:32},office_area:{color:"#3b82f6",fillOpacity:.5,defaultHeightFt:12},truck_court:{color:"#64748b",fillOpacity:.25},loading_berth:{color:"#f59e0b",fillOpacity:.35},parking_field:{color:"#64748b",fillOpacity:.3},ada_stalls:{color:"#0ea5e9",fillOpacity:.5},drive_aisle:{color:"#475569",fillOpacity:.2},retail_pad:{color:"#ec4899",fillOpacity:.4,defaultHeightFt:24},stormwater:{color:"#06b6d4",fillOpacity:.35},trash_enclosure:{color:"#78716c",fillOpacity:.5,defaultHeightFt:8},amenity_area:{color:"#22c55e",fillOpacity:.4},trailer_parking:{color:"#94a3b8",fillOpacity:.25}};function o7(t){return{ftPerDegLon:364e3*Math.cos(t*Math.PI/180),ftPerDegLat:364e3}}function Ah(t,s,n,a,l,c,u=0,i=0){const _=n/2/l,j=a/2/c,y=u/l,x=i/c,v=s+y,C=t+x;return[{lat:C-j,lng:v-_},{lat:C-j,lng:v+_},{lat:C+j,lng:v+_},{lat:C+j,lng:v-_}]}function l7(t,s,n,a,l){const c=[],u=n.width_ft||200,i=n.depth_ft||400,_=n.office_pct||8;n.dock_count,n.dock_spacing_ft;const j=n.clear_height_ft||32,y=Ah(t,s,u,i,a,l);if(c.push({name:"Warehouse Building",layerType:"building_footprint",geometry:y,style:{color:qi.building_footprint.color,fillColor:qi.building_footprint.color,fillOpacity:qi.building_footprint.fillOpacity,weight:2},metrics:{widthFt:u,depthFt:i,sqft:u*i},heightFt:j}),_>0){const P=i*_/100,I=i/2-P/2,z=Ah(t,s,u,P,a,l,0,I);c.push({name:"Office Area",layerType:"office_area",geometry:z,style:{color:qi.office_area.color,fillColor:qi.office_area.color,fillOpacity:qi.office_area.fillOpacity,weight:2},metrics:{widthFt:u,depthFt:P,sqft:u*P},heightFt:12})}const x=135,v=-(i/2)-x/2,C=Ah(t,s,u,x,a,l,0,v);return c.push({name:"Truck Court",layerType:"truck_court",geometry:C,style:{color:qi.truck_court.color,fillColor:qi.truck_court.color,fillOpacity:qi.truck_court.fillOpacity,weight:2},metrics:{widthFt:u,depthFt:x,sqft:u*x}}),c}function c7(t,s,n,a,l){const c=[],u=n.width_ft||150,i=n.depth_ft||300,_=n.loading_docks||2,j=Ah(t,s,u,i,a,l);if(c.push({name:"Retail Anchor Building",layerType:"building_footprint",geometry:j,style:{color:qi.building_footprint.color,fillColor:qi.building_footprint.color,fillOpacity:qi.building_footprint.fillOpacity,weight:2},metrics:{widthFt:u,depthFt:i,sqft:u*i},heightFt:24}),_>0){const y=_*12,x=60,v=-(i/2)-x/2,C=Ah(t,s,y,x,a,l,0,v);c.push({name:"Loading Area",layerType:"loading_berth",geometry:C,style:{color:qi.loading_berth.color,fillColor:qi.loading_berth.color,fillOpacity:qi.loading_berth.fillOpacity,weight:2},metrics:{widthFt:y,depthFt:x,sqft:y*x}})}return c}function d7(t,s,n,a,l){const c=[],u=n.target_spaces||100,i=n.stall_width_ft||9,_=n.stall_depth_ft||18,j=n.aisle_width_ft||24,y=n.ada_spaces||4,x=n.layout_type||0,v=Math.ceil(Math.sqrt(u)),C=Math.ceil(u/(v*2)),P=v*i,I=C*(_*2+j),z=Ah(t,s,P,I,a,l),D=["double_loaded","single_loaded","angled_45","angled_60"][x]||"double_loaded";if(c.push({name:`Parking Field (${u} spaces)`,layerType:"parking_field",geometry:z,style:{color:qi.parking_field.color,fillColor:qi.parking_field.color,fillOpacity:qi.parking_field.fillOpacity,weight:2},metrics:{widthFt:P,depthFt:I,sqft:P*I},parkingConfig:{stallWidth_ft:i,stallDepth_ft:_,aisleWidth_ft:j,layoutType:D,targetSpaces:u,adaSpaces:y}}),y>0){const X=y*12,K=Ah(t,s,X,_,a,l,-(P/2)+X/2,I/2-_/2);c.push({name:`ADA Stalls (${y})`,layerType:"ada_stalls",geometry:K,style:{color:qi.ada_stalls.color,fillColor:qi.ada_stalls.color,fillOpacity:qi.ada_stalls.fillOpacity,weight:2},metrics:{widthFt:X,depthFt:_,sqft:X*_}})}return c}function u7(t,s,n,a,l){const c=n.volume_cf||5e4,u=n.depth_ft||6,i=c/(u*.6),_=Math.sqrt(i);return[{name:"Stormwater Pond",layerType:"stormwater",geometry:Ah(t,s,_,_,a,l),style:{color:qi.stormwater.color,fillColor:qi.stormwater.color,fillOpacity:qi.stormwater.fillOpacity,weight:2},metrics:{widthFt:_,depthFt:_,sqft:i}}]}function h7(t,s,n,a,l){var y,x,v;const c=[],u=n.width_ft||400,i=n.depth_ft||135,_=n.trailer_parking_count||0,j=Ah(t,s,u,i,a,l);if(c.push({name:"Truck Court",layerType:"truck_court",geometry:j,style:{color:qi.truck_court.color,fillColor:qi.truck_court.color,fillOpacity:qi.truck_court.fillOpacity,weight:2},metrics:{widthFt:u,depthFt:i,sqft:u*i}}),_>0){const C=_*12,P=53,I=Ah(t,s,C,P,a,l,0,i/2+P/2+10);c.push({name:`Trailer Parking (${_})`,layerType:"trailer_parking",geometry:I,style:{color:(y=qi.trailer_parking)==null?void 0:y.color,fillColor:(x=qi.trailer_parking)==null?void 0:x.color,fillOpacity:(v=qi.trailer_parking)==null?void 0:v.fillOpacity,weight:2},metrics:{widthFt:C,depthFt:P,sqft:C*P}})}return c}function m7(t,s,n,a,l,c){const u=a.width_ft||a.bay_width_ft||100,i=a.depth_ft||100,_=Ah(s,n,u,i,l,c),j=qi[t.layer]||{color:"#6b7280",fillOpacity:.3};return[{name:t.name,layerType:t.layer,geometry:_,style:{color:j.color,fillColor:j.color,fillOpacity:j.fillOpacity,weight:2},metrics:{widthFt:u,depthFt:i,sqft:u*i},heightFt:j.defaultHeightFt}]}function f7(t,s,n){try{const a=n.geometry;if(!a||a.length<3)return{success:!1,layers:[],error:"Invalid parent geometry"};const l=a.map(v=>[v.lng,v.lat]);l.push([a[0].lng,a[0].lat]);const c=Xn([l]),u=Yo(c),i=u.geometry.coordinates[1],_=u.geometry.coordinates[0],{ftPerDegLon:j,ftPerDegLat:y}=o7(i);let x=[];switch(t.id){case"industrial_warehouse":case"cross_dock_warehouse":x=l7(i,_,s,j,y);break;case"retail_anchor":x=c7(i,_,s,j,y);break;case"parking_field":x=d7(i,_,s,j,y);break;case"stormwater_pond":x=u7(i,_,s,j,y);break;case"truck_court":x=h7(i,_,s,j,y);break;default:x=m7(t,i,_,s,j,y)}return{success:!0,layers:x}}catch(a){return console.error("Error generating block geometry:",a),{success:!1,layers:[],error:"Failed to generate geometry"}}}function p7(t){return qi[t]||{color:"#6b7280",fillOpacity:.3}}const g7={id:"industrial_warehouse",name:"Industrial Warehouse",category:"building",layer:"building_footprint",description:"Standard industrial warehouse with dock doors and office",propertyTypes:["industrial","distribution","flex"],params:{width_ft:{default:200,min:100,max:800,unit:"ft",label:"Building Width"},depth_ft:{default:400,min:200,max:1200,unit:"ft",label:"Building Depth"},clear_height_ft:{default:32,min:24,max:40,unit:"ft",label:"Clear Height"},office_pct:{default:8,min:0,max:30,unit:"pct",label:"Office %"},dock_count:{default:20,min:4,max:100,unit:"count",label:"Dock Doors"},dock_spacing_ft:{default:60,min:50,max:70,unit:"ft",label:"Dock Spacing"},column_bay_ft:{default:50,min:40,max:60,unit:"ft",label:"Column Bay"}},outputs:["building_footprint","dock_door","office_area","truck_court"],icon:"Warehouse"},x7={id:"cross_dock_warehouse",name:"Cross-Dock Warehouse",category:"building",layer:"building_footprint",description:"Distribution building with docks on both sides",propertyTypes:["distribution"],params:{width_ft:{default:180,min:140,max:300,unit:"ft",label:"Building Width"},depth_ft:{default:600,min:400,max:1500,unit:"ft",label:"Building Depth"},clear_height_ft:{default:36,min:32,max:40,unit:"ft",label:"Clear Height"},dock_count_front:{default:50,min:20,max:150,unit:"count",label:"Front Docks"},dock_count_rear:{default:50,min:20,max:150,unit:"count",label:"Rear Docks"},dock_spacing_ft:{default:55,min:50,max:65,unit:"ft",label:"Dock Spacing"}},outputs:["building_footprint","dock_door","truck_court"],icon:"ArrowLeftRight"},_7={id:"loading_dock",name:"Loading Dock Area",category:"access",layer:"loading_berth",description:"Tru
761ck loading/unloading area with docks",propertyTypes:["industrial","distribution","flex","retail"],params:{dock_count:{default:10,min:1,max:50,unit:"count",label:"Dock Doors"},dock_spacing_ft:{default:60,min:50,max:70,unit:"ft",label:"Dock Spacing"},apron_depth_ft:{default:70,min:60,max:90,unit:"ft",label:"Apron Depth"}},outputs:["loading_berth","dock_door"],icon:"Truck"},y7={id:"truck_court",name:"Truck Court",category:"access",layer:"truck_court",description:"Truck maneuvering and staging area",propertyTypes:["industrial","distribution"],params:{depth_ft:{default:135,min:120,max:185,unit:"ft",label:"Court Depth"},width_ft:{default:400,min:200,max:1200,unit:"ft",label:"Court Width"},trailer_parking_count:{default:0,min:0,max:50,unit:"count",label:"Trailer Spaces"}},outputs:["truck_court","trailer_parking"],icon:"Truck"},v7={id:"strip_center_straight",name:"Strip Center (Straight)",category:"building",layer:"building_footprint",description:"Linear multi-tenant strip with inline storefronts",propertyTypes:["retail"],params:{bay_count:{default:8,min:3,max:30,unit:"count",label:"Number of Bays"},bay_width_ft:{default:25,min:18,max:40,unit:"ft",label:"Bay Width"},depth_ft:{default:80,min:60,max:120,unit:"ft",label:"Building Depth"}},outputs:["building_footprint"],icon:"LayoutList"},b7={id:"strip_center_l",name:"Strip Center (L-Shape)",category:"building",layer:"building_footprint",description:"L-shaped strip with corner anchor position",propertyTypes:["retail"],params:{bay_count:{default:12,min:6,max:30,unit:"count",label:"Number of Bays"},bay_width_ft:{default:25,min:18,max:40,unit:"ft",label:"Bay Width"},depth_ft:{default:80,min:60,max:120,unit:"ft",label:"Building Depth"},anchor_count:{default:1,min:0,max:2,unit:"count",label:"Anchor Tenants"}},outputs:["building_footprint"],icon:"CornerDownRight"},j7={id:"strip_center_u",name:"Strip Center (U-Shape)",category:"building",layer:"building_footprint",description:"U-shaped strip enclosing parking court",propertyTypes:["retail"],params:{bay_count:{default:16,min:8,max:40,unit:"count",label:"Number of Bays"},bay_width_ft:{default:25,min:18,max:40,unit:"ft",label:"Bay Width"},depth_ft:{default:80,min:60,max:120,unit:"ft",label:"Building Depth"},anchor_count:{default:1,min:0,max:3,unit:"count",label:"Anchor Tenants"}},outputs:["building_footprint"],icon:"Square"},w7={id:"anchor_grocery",name:"Grocery Box",category:"building",layer:"building_footprint",description:"Full-service grocery with rear docks and storefront",propertyTypes:["retail"],params:{width_ft:{default:150,min:100,max:250,unit:"ft",label:"Building Width"},depth_ft:{default:300,min:200,max:450,unit:"ft",label:"Building Depth"},loading_docks:{default:2,min:1,max:6,unit:"count",label:"Loading Docks"}},outputs:["building_footprint","loading_berth"],icon:"ShoppingCart"},N7={id:"anchor_fitness",name:"Fitness Box",category:"building",layer:"building_footprint",description:"Health club with large open floor plate",propertyTypes:["retail"],params:{width_ft:{default:120,min:80,max:200,unit:"ft",label:"Building Width"},depth_ft:{default:250,min:180,max:400,unit:"ft",label:"Building Depth"},loading_docks:{default:1,min:0,max:3,unit:"count",label:"Loading Docks"}},outputs:["building_footprint"],icon:"Dumbbell"},k7={id:"anchor_bigbox",name:"Discount / Big Box",category:"building",layer:"building_footprint",description:"Large-format discount retailer with deep floor plate",propertyTypes:["retail"],params:{width_ft:{default:200,min:150,max:400,unit:"ft",label:"Building Width"},depth_ft:{default:500,min:300,max:700,unit:"ft",label:"Building Depth"},loading_docks:{default:4,min:2,max:10,unit:"count",label:"Loading Docks"}},outputs:["building_footprint","loading_berth"],icon:"Warehouse"},C7={id:"pad_small",name:"Small Pad (1.8–4K SF)",category:"building",layer:"retail_pad",description:"Small freestanding retail (coffee, salon)",propertyTypes:["retail"],params:{width_ft:{default:45,min:30,max:70,unit:"ft",label:"Building Width"},depth_ft:{default:45,min:30,max:70,unit:"ft",label:"Building Depth"},drive_thru:{default:0,min:0,max:1,unit:"count",label:"Has Drive-Thru"}
761,parking_spaces:{default:20,min:8,max:40,unit:"count",label:"Parking Spaces"}},outputs:["retail_pad","parking_field","drive_aisle"],icon:"Coffee"},S7={id:"pad_mid",name:"Mid Pad (4–10K SF)",category:"building",layer:"retail_pad",description:"Mid-size freestanding retail (pharmacy, fast casual)",propertyTypes:["retail"],params:{width_ft:{default:70,min:50,max:120,unit:"ft",label:"Building Width"},depth_ft:{default:80,min:50,max:120,unit:"ft",label:"Building Depth"},drive_thru:{default:0,min:0,max:1,unit:"count",label:"Has Drive-Thru"},parking_spaces:{default:35,min:15,max:60,unit:"count",label:"Parking Spaces"}},outputs:["retail_pad","parking_field","drive_aisle"],icon:"Store"},E7={id:"pad_large",name:"Large Pad (10–20K SF)",category:"building",layer:"retail_pad",description:"Large freestanding retail (auto parts, sporting goods)",propertyTypes:["retail"],params:{width_ft:{default:100,min:80,max:160,unit:"ft",label:"Building Width"},depth_ft:{default:120,min:80,max:180,unit:"ft",label:"Building Depth"},loading_docks:{default:1,min:0,max:3,unit:"count",label:"Loading Docks"},parking_spaces:{default:50,min:25,max:100,unit:"count",label:"Parking Spaces"}},outputs:["retail_pad","parking_field","loading_berth"],icon:"Building"},P7={id:"outparcel_bank",name:"Bank",category:"building",layer:"retail_pad",description:"Branch bank with drive-through lanes",propertyTypes:["retail"],params:{width_ft:{default:55,min:40,max:80,unit:"ft",label:"Building Width"},depth_ft:{default:55,min:40,max:80,unit:"ft",label:"Building Depth"},drive_thru_lanes:{default:3,min:1,max:5,unit:"count",label:"Drive-Thru Lanes"},parking_spaces:{default:25,min:10,max:40,unit:"count",label:"Parking Spaces"}},outputs:["retail_pad","parking_field","drive_aisle"],icon:"Landmark"},T7={id:"outparcel_restaurant",name:"Restaurant",category:"building",layer:"retail_pad",description:"Full-service or fast-casual restaurant with patio",propertyTypes:["retail"],params:{width_ft:{default:60,min:40,max:100,unit:"ft",label:"Building Width"},depth_ft:{default:60,min:40,max:100,unit:"ft",label:"Building Depth"},patio_seating:{default:1,min:0,max:1,unit:"count",label:"Has Patio"},drive_thru:{default:0,min:0,max:1,unit:"count",label:"Has Drive-Thru"},parking_spaces:{default:30,min:15,max:60,unit:"count",label:"Parking Spaces"}},outputs:["retail_pad","parking_field","drive_aisle"],icon:"UtensilsCrossed"},L7={id:"outparcel_cstore",name:"C-Store + Gas",category:"building",layer:"retail_pad",description:"Convenience store with fuel canopy and pump islands",propertyTypes:["retail"],params:{width_ft:{default:50,min:35,max:80,unit:"ft",label:"Building Width"},depth_ft:{default:50,min:35,max:80,unit:"ft",label:"Building Depth"},pump_count:{default:8,min:2,max:24,unit:"count",label:"Fuel Dispensers"},parking_spaces:{default:15,min:8,max:30,unit:"count",label:"Parking Spaces"}},outputs:["retail_pad","parking_field","fuel_island"],icon:"Fuel"},M7={id:"outparcel_urgent_care",name:"Urgent Care / Medical Retail",category:"building",layer:"retail_pad",description:"Walk-in medical clinic with ADA-heavy design",propertyTypes:["retail"],params:{width_ft:{default:65,min:50,max:100,unit:"ft",label:"Building Width"},depth_ft:{default:70,min:50,max:100,unit:"ft",label:"Building Depth"},parking_spaces:{default:30,min:15,max:50,unit:"count",label:"Parking Spaces"},ada_spaces:{default:4,min:2,max:10,unit:"count",label:"ADA Spaces"}},outputs:["retail_pad","parking_field"],icon:"Heart"},I7={id:"parking_field",name:"Surface Parking",category:"parking",layer:"parking_field",description:"Surface parking lot with auto-generated stalls and striping lines",propertyTypes:["industrial","retail","office","multifamily","flex","distribution"],params:{target_spaces:{default:100,min:10,max:500,unit:"count",label:"Target Spaces"},stall_width_ft:{default:9,min:8,max:12,step:.5,unit:"ft",label:"Stall Width"},stall_depth_ft:{default:18,min:15,max:22,step:.5,unit:"ft",label:"Stall Depth"},aisle_width_ft:{default:24,min:20,max:30,unit:"ft",label:"Aisle Width"},ada_spaces:{default:4,min:1,max:20,unit:"count",label:"ADA Spaces"},layout_type:{default:0,min:0,max:3,unit:"count",label:"Layout (0=Double, 1=Single, 2=45°, 3=60°)"}},outputs:["parking_field","ada_stalls","drive_aisle","striping_lines"],icon:"Car"},A7={id:"parking_garage",name:"Parking Garage",category:"parking",layer:"building_footprint",description:"Multi-level parking structure",propertyTypes:["office","multifamily","mixed_use","retail"],params:{levels:{default:4,min:2,max:8,unit:"count",label:"Levels"},spaces_per_level:{default:150,min:50,max:400,unit:"count",label:"Space
761s/Level"},width_ft:{default:120,min:60,max:180,unit:"ft",label:"Width"},depth_ft:{default:250,min:150,max:400,unit:"ft",label:"Depth"}},outputs:["building_footprint","drive_aisle"],icon:"Building"},D7={id:"apartment_building",name:"Apartment Building",category:"building",layer:"building_footprint",description:"Multi-story apartment building",propertyTypes:["multifamily"],params:{stories:{default:3,min:2,max:6,unit:"count",label:"Stories"},units_per_floor:{default:12,min:4,max:30,unit:"count",label:"Units/Floor"},avg_unit_sf:{default:950,min:600,max:1400,unit:"ft",label:"Avg Unit SF"},width_ft:{default:200,min:100,max:400,unit:"ft",label:"Building Width"},depth_ft:{default:60,min:50,max:80,unit:"ft",label:"Building Depth"}},outputs:["building_footprint","building_core"],icon:"Building2"},R7={id:"clubhouse",name:"Clubhouse/Amenity",category:"amenity",layer:"building_footprint",description:"Community clubhouse with amenities",propertyTypes:["multifamily"],params:{sqft:{default:5e3,min:2e3,max:15e3,unit:"ft",label:"Building SF"},pool:{default:1,min:0,max:1,unit:"count",label:"Has Pool"},fitness:{default:1,min:0,max:1,unit:"count",label:"Has Fitness"}},outputs:["building_footprint","amenity_area"],icon:"Dumbbell"},F7={id:"stormwater_pond",name:"Stormwater Pond",category:"utility",layer:"stormwater",description:"Detention/retention pond",propertyTypes:["industrial","retail","office","multifamily","distribution","flex"],params:{volume_cf:{default:5e4,min:1e4,max:5e5,unit:"count",label:"Volume (CF)"},depth_ft:{default:6,min:3,max:10,unit:"ft",label:"Depth"}},outputs:["stormwater"],icon:"Droplets"},z7={id:"trash_enclosure",name:"Trash Enclosure",category:"utility",layer:"trash_enclosure",description:"Screened trash/recycling area",propertyTypes:["industrial","retail","office","multifamily","distribution","flex"],params:{width_ft:{default:20,min:12,max:40,unit:"ft",label:"Width"},depth_ft:{default:12,min:10,max:20,unit:"ft",label:"Depth"},dumpster_count:{default:2,min:1,max:4,unit:"count",label:"Dumpsters"}},outputs:["trash_enclosure"],icon:"Trash2"},O7=[g7,x7,_7,y7,v7,b7,j7,w7,N7,k7,C7,S7,E7,P7,T7,L7,M7,I7,A7,D7,R7,F7,z7];function B7(t){const s=t.toLowerCase().replace(/[\s-]/g,"_");return O7.filter(n=>n.propertyTypes.includes(s))}const $7=t=>({front_ft:t.setbacks.front_ft,rear_ft:t.setbacks.rear_ft,side_ft:t.setbacks.side_ft,side1_ft:null,side2_ft:null}),H2={warehouse:{name:"Warehouse Layout",lotWidth:200,lotDepth:400,lotSpacing:30,aisleWidth:60,columnAreaSqft:500,parkingRatio:.5},retail:{name:"Retail Pad",lotWidth:80,lotDepth:120,lotSpacing:20,aisleWidth:24,columnAreaSqft:100,parkingRatio:4},residential:{name:"Residential Lots",lotWidth:60,lotDepth:120,lotSpacing:10,aisleWidth:20,columnAreaSqft:0,parkingRatio:2},industrial:{name:"Industrial Park",lotWidth:300,lotDepth:500,lotSpacing:40,aisleWidth:80,columnAreaSqft:800,parkingRatio:.3},parking:{name:"Parking Lot",lotWidth:9,lotDepth:18,lotSpacing:0,aisleWidth:24,columnAreaSqft:0,parkingRatio:0}},nm=9,Im=18,V7=({open:t,onClose:s,parentOverlay:n,onGenerateComplete:a,propertyType:l="industrial"})=>{const[c,u]=k.useState("lots"),[i,_]=k.useState(!1),[j,y]=k.useState([]),[x,v]=k.useState(!0),[C,P]=k.useState(!1),I=k.useMemo(()=>qj(l),[l]),z=k.useMemo(()=>$7(I),[I]),F=k.useMemo(()=>B7(l),[l]),[D,X]=k.useState({lotWidth:100,lotDepth:150,lotSpacing:20,aisleWidth:I.circulation.drive_aisle_width_ft||24,orientation:"auto",columnAreaSqft:200,parkingRatio:I.parking.ratio,targetLotCount:0,lotSetbackFront:20,lotSetbackRear:10,lotSetbackSide:5}),[K,te]=k.useState({spacesNeeded:0,driveAisleWidth:I.circulation.drive_aisle_width_ft||24,doubleLoaded:!0,handicapSpaces:2,generateInRemainingSpace:!1}),J=ym(),H=pu(),O=k.useMemo(()=>n?!!(n.setback_geometry||n.setback_front_ft||n.setback_rear_ft||n.setback_side_ft):!1,[n]),q=k.useMemo(()=>n!=null&&n.setback_geometry?Df(n.setback_geometry):null,[n==null?void 0:n.setback_geometry]),W=k.useMemo(()=>{if(!(n!=null&&n.geometry))return null;const ve=n.geometry;if(!Array.isArray(ve)||ve.length<3)return null;const we=ve.map(vt=>[vt.lng,vt.lat]);we.push([ve[0].lng,ve[0].lat]);const Ze=Xn([we]),ze=zr(Ze)*10.7639,Ke=ze/43560,dt=xp(Ze),Re=dt[2]-dt[0],qt=dt[3]-dt[1],ft=(dt[1]+dt[3])/2,Fe=364e3*Math.cos(ft*Math.PI/180),fe=364e3,Qe=Re*Fe,ht=qt*fe,_t=Yo(Ze);let He=ze,as=Ke;if(q!=null&&q.innerPolygon&&q.innerPolygon.length>0)try{const vt=Xn(q.innerPolygon);He=zr(vt)*10.7639,as=He/43560}catch(vt){console.error("Error calculating buildable area:",vt)}return{areaSqFt:ze,areaAcres:Ke,buildableAreaSqFt:He,buildableAreaAcres:as,widthFt:Qe,heightFt:ht,bbox:dt,centroid:{lng:_t.geometry.coordinates[0],lat:_t.geometry.coordinates[1]},ftPerDegLon:Fe,ftPerDegLat:fe}},[n,q]),Q=k.useMemo(()=>
761{if(!W)return null;const ve=O&&(q!=null&&q.innerPolygon)?W.buildableAreaSqFt:W.areaSqFt,we=D.lotWidth*D.lotDepth,Ze=(D.lotWidth+D.lotSpacing)*(D.lotDepth+D.aisleWidth),ke=Math.floor(ve*.7/Ze),ze=we-D.columnAreaSqft,Ke=ke*ze,dt=Math.ceil(Ke/1e3*D.parkingRatio),Re=dt*(nm*Im+12),qt=ke*Ze+Re,ft=ve-qt,Fe=ft>0?ft*.6:0,fe=ft>0?ft*.4:0;return{estimatedLots:ke,lotArea:we,buildablePerLot:ze,totalBuildableSqft:Ke,parkingSpacesNeeded:dt,parkingAreaNeeded:Re,landscapeArea:Fe,stormwaterArea:fe,remainingArea:ft,efficiency:qt>0?Math.min(100,qt/ve*100):0}},[W,D,O,q]);k.useEffect(()=>{t&&n&&!O&&x&&!C&&Z()},[t,n,O,x]),k.useEffect(()=>{t||P(!1)},[t]);const Z=async()=>{if(!(n!=null&&n.geometry))return;const ve=n.geometry,we=pg(ve,z);if(we.innerPolygon)try{await H.mutateAsync({id:n.id,setback_front_ft:z.front_ft,setback_rear_ft:z.rear_ft,setback_side_ft:z.side_ft,setback_geometry:gg(we)}),P(!0),Ve.success("Applied default setbacks",{description:`Front: ${z.front_ft}ft, Rear: ${z.rear_ft}ft, Sides: ${z.side_ft}ft`})}catch(Ze){console.error("Error applying default setbacks:",Ze),Ve.error("Failed to apply default setbacks")}},oe=ve=>{const we=H2[ve];X(Ze=>({...Ze,lotWidth:we.lotWidth,lotDepth:we.lotDepth,lotSpacing:we.lotSpacing,aisleWidth:we.aisleWidth,orientation:"auto",columnAreaSqft:we.columnAreaSqft,parkingRatio:we.parkingRatio})),Ve.success(`Applied ${we.name} preset`)},ce=k.useCallback(()=>{if(!n||!W)return null;const ve=n.geometry,we=ve.map(Ze=>[Ze.lng,Ze.lat]);return we.push([ve[0].lng,ve[0].lat]),q!=null&&q.innerPolygon&&q.innerPolygon.length>0?{polygon:Xn(q.innerPolygon),bbox:xp(Xn(q.innerPolygon)),usingSetbacks:!0}:{polygon:Xn([we]),bbox:W.bbox,usingSetbacks:!1}},[n,W,q]),ae=k.useCallback(async()=>{if(!n||!W){Ve.error("No parent polygon selected");return}const ve=ce();if(!ve){Ve.error("Could not determine buildable area");return}_(!0);try{const we=[],{ftPerDegLon:Ze,ftPerDegLat:ke}
761=W,{polygon:ze,bbox:Ke,usingSetbacks:dt}=ve;if(D.targetLotCount===1){const Be=ze.geometry.coordinates[0].slice(0,-1).map(([$t,Ns])=>({lat:Ns,lng:$t})),Dt=(Ke[2]-Ke[0])*Ze,Rt=(Ke[3]-Ke[1])*ke,rs=zr(ze)*10.764;let _s=null;if(D.lotSetbackFront>0||D.lotSetbackRear>0||D.lotSetbackSide>0){const $t={front_ft:D.lotSetbackFront||null,rear_ft:D.lotSetbackRear||null,side_ft:D.lotSetbackSide||null,side1_ft:D.lotSetbackSide||null,side2_ft:D.lotSetbackSide||null},Ns=pg(Be,$t);_s=gg(Ns)}we.push({id:"lot-1",type:"lot",geometry:Be,widthFt:Math.round(Dt),depthFt:Math.round(Rt),sqft:Math.round(rs),label:"Lot 1 (Maximized)",setbackFrontFt:D.lotSetbackFront||void 0,setbackRearFt:D.lotSetbackRear||void 0,setbackSideFt:D.lotSetbackSide||void 0,setbackGeometry:_s}),y(we);const vs=(rs/43560).toFixed(2);Ve.success(`Generated 1 maximized lot (${vs} acres)${dt?" within setbacks":""}`);return}const Re=D.lotWidth/Ze,qt=D.lotDepth/ke,ft=D.lotSpacing/Ze,Fe=D.aisleWidth/ke,fe=Re*.05,Qe=qt*.05,ht=Ke[0]+fe,_t=Ke[1]+Qe,He=Ke[2]-fe,as=Ke[3]-Qe;let vt=0;for(let Ce=_t;Ce+qt<=as;Ce+=qt+Fe){for(let Be=ht;Be+Re<=He&&!(D.targetLotCount>1&&vt>=D.targetLotCount);Be+=Re+ft){const Dt=[{lat:Ce,lng:Be},{lat:Ce,lng:Be+Re},{lat:Ce+qt,lng:Be+Re},{lat:Ce+qt,lng:Be}];if(Dt.every(zt=>{const rs=us([zt.lng,zt.lat]);return uu(rs,ze)})){vt++;let zt=null;if(D.lotSetbackFront>0||D.lotSetbackRear>0||D.lotSetbackSide>0){const rs={front_ft:D.lotSetbackFront||null,rear_ft:D.lotSetbackRear||null,side_ft:D.lotSetbackSide||null,side1_ft:D.lotSetbackSide||null,side2_ft:D.lotSetbackSide||null},_s=pg(Dt,rs);zt=gg(_s)}we.push({id:`lot-${vt}`,type:"lot",geometry:Dt,widthFt:D.lotWidth,depthFt:D.lotDepth,sqft:D.lotWidth*D.lotDepth,label:`Lot ${vt}`,setbackFrontFt:D.lotSetbackFront||void 0,setbackRearFt:D.lotSetbackRear||void 0,setbackSideFt:D.lotSetbackSide||void 0,setbackGeometry:zt})}}if(D.targetLotCount>1&&vt>=D.targetLotCount)break}y(we);const Xe=dt?`Generated ${we.length} lots within setback boundaries`:`Generated ${we.length} lots within boundary`;Ve.success(Xe,{description:'Review the layout and click "Create All Layers" to save'})}catch(we){console.error("Error generating layout:",we),Ve.error("Failed to generate layout")}finally{_(!1)}},[n,W,D,ce]),ie=k.useCallback(async()=>{if(!n||!W||j.length===0){Ve.error("Generate lots first, then add parking");return}const ve=ce();if(!ve){Ve.error("Could not determine buildable area");return}_(!0);try{const{ftPerDegLon:we,ftPerDegLat:Ze}=W,{polygon:ke,bbox:ze,usingSetbacks:Ke}=ve,dt=nm/we,Re=Im/Ze,qt=K.driveAisleWidth/Ze,ft=[];let Fe=0;const fe=dt*.1,Qe=Re*.1,ht=ze[0]+fe,_t=ze[1]+Qe,He=ze[2]-fe,as=ze[3]-Qe,vt=K.doubleLoaded?Re*2+qt:Re+qt;for(let Xe=_t;Xe+vt<=as;Xe+=vt+Re*.2){for(let Ce=ht;Ce+dt<=He;Ce+=dt+dt*.1){const Be=[{lat:Xe,lng:Ce},{lat:Xe,lng:Ce+dt},{lat:Xe+Re,lng:Ce+dt},{lat:Xe+Re,lng:Ce}],Dt=Be.every(zt=>{const rs=us([zt.lng,zt.lat]);return uu(rs,ke)}),Rt=j.some(zt=>{const rs={lat:zt.geometry.reduce(($t,Ns)=>$t+Ns.lat,0)/zt.geometry.length,lng:zt.geometry.reduce(($t,Ns)=>$t+Ns.lng,0)/zt.geometry.length},_s={lat:(Be[0].lat+Be[2].lat)/2,lng:(Be[0].lng+Be[2].lng)/2};return Math.sqrt(Math.pow((rs.lat-_s.lat)*Ze,2)+Math.pow((rs.lng-_s.lng)*we,2))<(zt.widthFt+nm)/2});if(Dt&&!Rt&&(Fe++,ft.push({id:`parking-${Fe}`,type:"parking",geometry:Be,widthFt:nm,depthFt:Im,sqft:nm*Im,label:`P${Fe}`}
761)),K.doubleLoaded){const zt=Xe+Re+qt,rs=[{lat:zt,lng:Ce},{lat:zt,lng:Ce+dt},{lat:zt+Re,lng:Ce+dt},{lat:zt+Re,lng:Ce}],_s=rs.every($t=>{const Ns=us([$t.lng,$t.lat]);return uu(Ns,ke)}),vs=j.some($t=>{const Ns={lat:$t.geometry.reduce((en,Jt)=>en+Jt.lat,0)/$t.geometry.length,lng:$t.geometry.reduce((en,Jt)=>en+Jt.lng,0)/$t.geometry.length},Ts={lat:(rs[0].lat+rs[2].lat)/2,lng:(rs[0].lng+rs[2].lng)/2};return Math.sqrt(Math.pow((Ns.lat-Ts.lat)*Ze,2)+Math.pow((Ns.lng-Ts.lng)*we,2))<($t.widthFt+nm)/2});_s&&!vs&&(Fe++,ft.push({id:`parking-${Fe}`,type:"parking",geometry:rs,widthFt:nm,depthFt:Im,sqft:nm*Im,label:`P${Fe}`}))}if(K.spacesNeeded>0&&Fe>=K.spacesNeeded)break}if(K.spacesNeeded>0&&Fe>=K.spacesNeeded)break}y(Xe=>[...Xe,...ft]),Ve.success(`Generated ${ft.length} parking spaces`,{description:Ke?"Parking placed within setback boundaries, avoiding lots":"Parking placed in remaining space, avoiding lots"})}catch(we){console.error("Error generating parking:",we),Ve.error("Failed to generate parking")}finally{_(!1)}},[n,W,j,K,ce]),de=async()=>{if(!(!n||j.length===0)){_(!0);try{for(const ve of j){const we=ve.type==="lot"?"lot":ve.type==="parking"?"parking":ve.type==="building"?"building_footprint":ve.type;await J.mutateAsync({name:ve.label,type:"polygon",geometry:ve.geometry,layer_type:we,parent_overlay_id:n.id,is_visible:!0,width_ft:ve.widthFt,depth_ft:ve.depthFt,custom_sqft:ve.sqft,setback_front_ft:ve.setbackFrontFt||null,setback_rear_ft:ve.setbackRearFt||null,setback_side_ft:ve.setbackSideFt||null,setback_geometry:ve.setbackGeometry||null,style:{color:ve.type==="lot"?"#f97316":ve.type==="parking"?"#64748b":"#22c55e",weight:2,fillColor:ve.type==="lot"?"#f97316":ve.type==="parking"?"#64748b":"#22c55e",fillOpacity:.3}})}Ve.success(`Created ${j.length} child layers`),y([]),a==null||a(),s()}catch(ve){console.error("Error creating layers:",ve),Ve.error("Failed to create some layers")}finally{_(!1)}}},ge=()=>{Q&&(te(ve=>({...ve,spacesNeeded:Q.parkingSpacesNeeded})),Ve.success(`Calculated ${Q.parkingSpacesNeeded} parking spaces needed`,{description:`Based on ${Q.totalBuildableSqft.toLocaleString()} sq ft @ ${D.parkingRatio} spaces/1000 sqft`}))};if(!n)return null;const We=j.filter(ve=>ve.type==="lot").length,Ee=j.filter(ve=>ve.type==="parking").length;return e.jsx(B0,{open:t,onOpenChange:ve=>!ve&&s(),children:e.jsxs(m_,{side:"right",hideOverlay:!0,className:"w-[450px] sm:w-[500px] flex flex-col p-0 shadow-2xl",children:[e.jsxs($0,{className:"px-6 py-4 border-b bg-gradient-to-r from-primary/10 to-orange-500/10",children:[e.jsxs(V0,{className:"flex items-center gap-2",children:[e.jsx(Nf,{className:"w-5 h-5 text-primary"}),"Site360 AI Layout"]}),e.jsxs(FE,{children:['Auto-generate lots, parking, and site elements for "',n.name,'"']})]}),e.jsx(Xc,{className:"flex-1",children:e.jsxs("div",{className:"p-6 space-y-6",children:[O||C?e.jsxs(Dy,{className:"bg-green-500/10 border-green-500/30",children:[e.jsx(Fy,{className:"h-4 w-4 text-green-600"}),e.jsxs(Ry,{className:"text-green-700 dark:text-green-400",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:"Setbacks Active"}),e.jsx(Mt,{variant:"outline",className:"bg-green-500/20 text-green-700 dark:text-green-400 border-green-500/30",children:"Protected"})]}),e.jsx("p",{className:"text-xs mt-1 text-green-600 dark:text-green-500",children:"Lots will be generated inside the buildable area, respecting setback boundaries."})]})]}):e.jsxs(Dy,{className:"bg-amber-500/10 border-amber-500/30",children:[e.jsx($y,{className:"h-4 w-4 text-amber-600"}),e.jsxs(Ry,{className:"text-amber-700 dark:text-amber-400",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:"No Setbacks Configured"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kt,{checked:x,onCheckedChange:v,className:"scale-75"}),e.jsx("span",{className:"text-xs",children:"Auto-apply"})]})]}),e.jsxs("p",{className:"text-xs mt-1 text-amber-600 dark:text-amber-500",children:["Toggle to automatically apply default setbacks (Front: ",z.front_ft,"ft, Rear: ",z.rear_ft,"ft, Sides: ",z.side_ft,"ft)"]}),!x&&e.jsx(Le,{variant:"outline",size:"sm",className:"mt-2 h-7 text-xs",onClick:Z,children:"Apply Default Setbacks"})]})]}),W&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-card border rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-lg font-bold text-primary",children:W.areaAcres.toFixed(2)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Gross Acres"})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-lg font-bold",children:W.areaSqFt.toLocaleStr
761ing(void 0,{maximumFractionDigits:0})}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Gross Sq Ft"})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-3 text-center",children:[e.jsxs("div",{className:"text-lg font-bold",children:[Math.round(W.widthFt)," × ",Math.round(W.heightFt)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Dimensions (ft)"})]})]}),(O||C)&&(q==null?void 0:q.innerPolygon)&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-lg font-bold text-green-600 dark:text-green-400",children:W.buildableAreaAcres.toFixed(2)}),e.jsx("div",{className:"text-xs text-green-600 dark:text-green-500",children:"Net Buildable Acres"})]}),e.jsxs("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-lg font-bold text-green-600 dark:text-green-400",children:W.buildableAreaSqFt.toLocaleString(void 0,{maximumFractionDigits:0})}),e.jsx("div",{className:"text-xs text-green-600 dark:text-green-500",children:"Net Buildable Sq Ft"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-sm font-medium",children:"Quick Presets"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(H2).map(([ve,we])=>e.jsx(Le,{variant:"outline",size:"sm",onClick:()=>oe(ve),className:"text-xs",children:we.name},ve))})]}),e.jsxs(Zm,{value:c,onValueChange:u,children:[e.jsxs(mm,{className:"grid grid-cols-4 w-full",children:[e.jsxs(Bi,{value:"lots",className:"text-xs gap-1",children:[e.jsx(dm,{className:"w-3.5 h-3.5"}),"Lots"]}),e.jsxs(Bi,{value:"blocks",className:"text-xs gap-1",children:[e.jsx(cm,{className:"w-3.5 h-3.5"}),"Blocks"]}),e.jsxs(Bi,{value:"parking",className:"text-xs gap-1",children:[e.jsx(Ml,{className:"w-3.5 h-3.5"}),"Parking"]}),e.jsxs(Bi,{value:"site",className:"text-xs gap-1",children:[e.jsx(pm,{className:"w-3.5 h-3.5"}),"Site Plan"]})]}),e.jsxs($i,{value:"lots",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Number of Lots"}),e.jsxs(rt,{value:String(D.targetLotCount),onValueChange:ve=>X(we=>({...we,targetLotCount:Number(ve)})),children:[e.jsx(it,{className:"h-9",children:e.jsx(ct,{})}),e.jsxs(ot,{children:[e.jsx(le,{value:"0",children:"Auto-fill (based on dimensions)"}),e.jsx(le,{value:"1",children:"1 Lot (Maximize buildable area)"}),e.jsx(le,{value:"2",children:"2 Lots"}),e.jsx(le,{value:"3",children:"3 Lots"}),e.jsx(le,{value:"4",children:"4 Lots"}),e.jsx(le,{value:"6",children:"6 Lots"}),e.jsx(le,{value:"8",children:"8 Lots"}),e.jsx(le,{value:"10",children:"10 Lots"})]})]}),D.targetLotCount===1&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Creates a single lot that fills the entire buildable area within setbacks."})]}),D.targetLotCount!==1&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Lot Width (ft)"}),e.jsx(be,{type:"number",value:D.lotWidth,onChange:ve=>X(we=>({...we,lotWidth:Number(ve.target.value)||0})),className:"h-9"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Lot Depth (ft)"}),e.jsx(be,{type:"number",value:D.lotDepth,onChange:ve=>X(we=>({...we,lotDepth:Number(ve.target.value)||0})),className:"h-9"})]})]}),D.targetLotCount!==1&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Lot Spacing (ft)"}),e.jsx(be,{type:"number",value:D.lotSpacing,onChange:ve=>X(we=>({...we,lotSpacing:Number(ve.target.value)||0})),className:"h-9"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Aisle Width (ft)"}),e.jsx(be,{type:"number",value:D.aisleWidth,onChange:ve=>X(we=>({...we,aisleWidth:Number(ve.target.value)||0})),className:"h-9"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{className:"text-xs flex items-center gap-2",children:[e.jsx(Ci,{className:"w-3.5 h-3.5"}),"Estimated Common Area (sq ft per lot)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ca,{value:[D.columnAreaSqft],min:0,max:2e3,step:50,onValueChange:([ve])=>X(we=>({...we,columnAreaSqft:ve})),className:"flex-1"}),e.jsx(be,{type:"number",value:D.columnAreaSqft,onChange:ve=>X(we=>({...we,columnAreaSqft:Number(ve.target.value)||0})),className:"w-20 h-8 text-xs"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{className:"text-xs flex items-center gap-2",children:[e.jsx(Ml,{className:"w-3.5 h-3.5"}),"Parking Ratio (spaces per 1,000 sq ft)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ca,{value:[D.parkingRatio],min:0,max:10,step:.25,onValueChange:([ve])=>X(we=>({...we,parkingRatio:ve})),className:"flex-1"}),e.jsx(be,{type:"number",value:D.parkingRatio,onChange:ve=>X(we=>({...we,parkingRatio:Number(ve.target.value)||0})),className:"w-20 h-8 text-xs",step:.25})]})]}),e.jsxs("div",{className:"space-y-3 pt-3 border-t",children:[e.jsxs(B,{className:"text-xs font-medium flex items-center gap-2",children:[e.jsx(Fy,{className:"w-3.5 h-3.5"}),"Lot Setbacks (Buildable Area per Lot)"]}),e.jsx("p",{className:"text-[10px] text-muted-foreground -mt-1",children:"Define setbacks within each lot to show the buildable envelope"}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Front (ft)"}),e.jsx(be,{type:"number",min:"0",value:D.lotSetbackFront,onChange:ve=>X(we=>({...we,lotSetbackFront:Number(ve.target.value)||0})),className:"h-8 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Rear (ft)"}),e.jsx(be,{type:"number",min:"0",value:D.lotSetbackRear,onChange:ve=>X(we=>({...we,lotSetbackRear:Number(ve.target.value)||0})),className:"h-8 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Sides (ft)"}
761),e.jsx(be,{type:"number",min:"0",value:D.lotSetbackSide,onChange:ve=>X(we=>({...we,lotSetbackSide:Number(ve.target.value)||0})),className:"h-8 text-xs"})]})]}),(D.lotSetbackFront>0||D.lotSetbackRear>0||D.lotSetbackSide>0)&&e.jsx("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-lg p-2 text-[10px] text-amber-600 dark:text-amber-400",children:"Each generated lot will include setback zones showing the buildable area within"})]}),Q&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Gy,{className:"w-4 h-4"}),"Estimates",(O||C)&&e.jsx(Mt,{variant:"outline",className:"text-[10px] bg-green-500/10 text-green-600 border-green-500/30",children:"Using Buildable Area"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Est. Lots:"}),e.jsx("span",{className:"ml-2 font-semibold",children:Q.estimatedLots})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Lot Area:"}),e.jsxs("span",{className:"ml-2 font-semibold",children:[Q.lotArea.toLocaleString()," sf"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Buildable/Lot:"}),e.jsxs("span",{className:"ml-2 font-semibold",children:[Q.buildablePerLot.toLocaleString()," sf"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Buildable:"}),e.jsxs("span",{className:"ml-2 font-semibold",children:[Q.totalBuildableSqft.toLocaleString()," sf"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Parking Needed:"}),e.jsxs("span",{className:"ml-2 font-semibold",children:[Q.parkingSpacesNeeded," spaces"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Site Efficiency:"}),e.jsxs("span",{className:"ml-2 font-semibold",children:[Q.efficiency.toFixed(0),"%"]})]})]})]}),e.jsxs(Le,{onClick:ae,disabled:i,className:"w-full gap-2",children:[i?e.jsx(Va,{className:"w-4 h-4 animate-spin"}):e.jsx(VC,{className:"w-4 h-4"}),"Generate Lot Layout"]})]}),e.jsxs($i,{value:"parking",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Required Parking Spaces"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(be,{type:"number",value:K.spacesNeeded,onChange:ve=>te(we=>({...we,spacesNeeded:Number(ve.target.value)||0})),className:"h-9"}),e.jsxs(Le,{variant:"outline",size:"sm",onClick:ge,children:[e.jsx(Gy,{className:"w-4 h-4 mr-1"}),"Auto Calculate"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Drive Aisle Width (ft)"}),e.jsx(be,{type:"number",value:K.driveAisleWidth,onChange:ve=>te(we=>({...we,driveAisleWidth:Number(ve.target.value)||24})),className:"h-9"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{className:"text-xs",children:"Handicap Spaces"}),e.jsx(be,{type:"number",value:K.handicapSpaces,onChange:ve=>te(we=>({...we,handicapSpaces:Number(ve.target.value)||0})),className:"h-9"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-xs flex items-center gap-2",children:[e.jsx(fm,{className:"w-3.5 h-3.5"}),"Double-Loaded Parking Rows"]}),e.jsx(kt,{checked:K.doubleLoaded,onCheckedChange:ve=>te(we=>({...we,doubleLoaded:ve}))})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Parking Area Required"}),e.jsxs("div",{className:"text-2xl font-bold text-primary",children:[(K.spacesNeeded*nm*Im+Math.ceil(K.spacesNeeded/2)*K.driveAisleWidth*Im).toLocaleString()," sq ft"]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Standard spaces: ",nm,"' × ",Im,"'"]})]}),e.jsxs(Le,{onClick:ie,disabled:i||j.filter(ve=>ve.type==="lot").length===0,variant:"outline",className:"w-full gap-2",children:[i?e.jsx(Va,{className:"w-4 h-4 animate-spin"}):e.jsx(fm,{className:"w-4 h-4"}),"Generate Parking in Remaining Space"]}),j.filter(ve=>ve.type==="lot").length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Generate lots first in the Lots tab, then add parking"})]}
761),e.jsx($i,{value:"blocks",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs(B,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(cm,{className:"w-4 h-4 text-primary"}),"Available Blocks for ",l]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Select a block to quickly place on the site"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:F.slice(0,8).map(ve=>e.jsx(Le,{variant:"outline",className:"justify-start h-auto py-3 text-left",disabled:i,onClick:async()=>{if(n){_(!0);try{const we={};Object.entries(ve.params).forEach(([ke,ze])=>{we[ke]=ze.default});const Ze=f7(ve,we,n);if(!Ze.success){Ve.error(Ze.error||"Failed to generate block");return}for(const ke of Ze.layers)await J.mutateAsync({name:ke.name,type:"polygon",geometry:ke.geometry,layer_type:ke.layerType,parent_overlay_id:n.id,is_visible:!0,width_ft:ke.metrics.widthFt,depth_ft:ke.metrics.depthFt,custom_sqft:ke.metrics.sqft,block_definition_id:ve.id,block_params:we,style:ke.style});Ve.success(`Placed ${ve.name}`,{description:`Created ${Ze.layers.length} layer${Ze.layers.length>1?"s":""}`}),a==null||a()}catch{Ve.error("Failed to place block")}finally{_(!1)}}},children:e.jsxs("div",{className:"flex items-start gap-2 w-full",children:[e.jsx(Ci,{className:"w-4 h-4 mt-0.5 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:ve.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:ve.description})]})]})},ve.id))}),F.length===0&&e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(cm,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-xs",children:"No blocks available for this property type"})]})]})}),e.jsx($i,{value:"site",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(pm,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{className:"text-sm",children:"Full site plan generation coming soon"}),e.jsx("p",{className:"text-xs mt-1",children:"Will auto-layout buildings, parking, landscaping & stormwater"})]})})]}),j.length>0&&e.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-sm font-medium",children:"Generated Layout"}),e.jsxs("div",{className:"flex gap-1",children:[We>0&&e.jsxs(Mt,{variant:"secondary",className:"text-xs",children:[We," lots"]}),Ee>0&&e.jsxs(Mt,{variant:"outline",className:"text-xs bg-slate-500/10",children:[Ee," parking"]})]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 max-h-32 overflow-auto",children:[j.slice(0,20).map(ve=>e.jsxs("div",{className:`rounded p-2 text-center ${ve.type==="parking"?"bg-slate-500/20":"bg-muted/50"}`,children:[e.jsx("div",{className:"text-xs font-medium truncate",children:ve.label}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[ve.sqft.toLocaleString()," sf"]})]},ve.id)),j.length>20&&e.jsx("div",{className:"bg-muted/50 rounded p-2 text-center flex items-center justify-center",children:e.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",j.length-20," more"]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Le,{variant:"outline",className:"flex-1",onClick:()=>y([]),children:[e.jsx(mh,{className:"w-4 h-4 mr-1"}),"Clear"]}),e.jsxs(Le,{className:"flex-1",onClick:de,disabled:i,children:[i?e.jsx(Va,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(Il,{className:"w-4 h-4 mr-1"}),"Create All Layers"]})]})]})]})})]})})},q7=({overlay:t,mode:s,isTransforming:n,previewGeometry:a})=>k.useMemo(()=>{if(!(t!=null&&t.geometry)||t.geometry.length<3||s==="none")return[];const l=a||t.geometry,c=eP(l),u=[];return s==="move"&&u.push({id:"center",type:"center",position:c.center,cursor:"move",action:"move"}),(s==="rotate"||s==="scale")&&(u.push({id:"topRight",type:s==="rotate"?"rotate":"corner",position:c.topRight,cursor:s==="rotate"?"grab":"nwse-resize",action:s==="rotate"?"rotate":"scale-ne"}),s==="scale"&&(u.push({id:"topLeft",type:"corner",position:c.topLeft,cursor:"nesw-resize",action:"scale-nw"}),u.push({id:"bottomLeft",type:"corner",position:c.bottomLeft,cursor:"nwse-resize",action:"scale-sw"}),u.push({id:"bottomRight",type:"corner",position:c.bottomRight,cursor:"nesw-resize",action:"scale-se"}))),s==="scale"&&(u.push({id:"top",type:"edge",position:c.top,cursor:"ns-resize",action:"scale-n"}),u.push({id:"right",type:"edge",position:c.right,cursor:"ew-resize",action:"scale-e"}),u.push({id:"bottom",type:"edge",position:c.bottom,cursor:"ns-resize",action:"scale-s"}),u.push({id:"left",type:"edge",position:c.left,cursor:"ew-resize",action:"scale-w"})),u},[t==null?void 0:t.geometry,s,a]),G7=(t,s,n)=>k.useMemo(()=>
761{if(!(t!=null&&t.geometry)||t.geometry.length<3||s==="none")return[];const a=n||t.geometry,l=Nj(a);return[{lat:l.maxLat,lng:l.minLng},{lat:l.maxLat,lng:l.maxLng},{lat:l.minLat,lng:l.maxLng},{lat:l.minLat,lng:l.minLng}]},[t==null?void 0:t.geometry,s,n]),Z2=(t,s=!1)=>{const n=t.type==="center"?24:t.type==="rotate"?20:12,a=t.type==="rotate"?"#22c55e":t.type==="center"?"#3b82f6":"#ffffff",l=t.type==="rotate"?"#15803d":t.type==="center"?"#1d4ed8":"#3b82f6",c=t.type==="rotate"?`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">
762        <path d="M21 12a9 9 0 11-3-6.7"/>
763        <path d="M21 3v6h-6"/>
764      </svg>`:t.type==="center"?`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">
765        <path d="M5 9l-3 3 3 3"/>
766        <path d="M9 5l3-3 3 3"/>
767        <path d="M15 19l3-3-3-3"/>
768        <path d="M19 9l3 3-3 3"/>
769      </svg>`:"";return`
770    <div style="
771      width: ${n}px;
772      height: ${n}px;
773      background: ${a};
774      border: 2px solid ${l};
775      border-radius: ${t.type==="edge"?"2px":"50%"};
776      cursor: ${t.cursor};
777      display: flex;
778      align-items: center;
779      justify-content: center;
780      box-shadow: 0 2px 4px rgba(0,0,0,0.2);
781      transition: transform 0.1s;
782      ${s?"transform: scale(1.2);":""}
783    ">
784      ${c}
785    </div>
786  `},Ly=(t,s)=>{const a=t.getContainer().getBoundingClientRect(),l=Bt.point(s.clientX-a.left,s.clientY-a.top);return t.containerPointToLatLng(l)},hb=({map:t,overlay:s,mode:n,isTransforming:a,previewGeometry:l,onHandleMouseDown:c,onHandleMouseUp:u})=>{const i=k.useRef([]),_=k.useRef(null),j=k.useRef(null),y=q7({overlay:s,mode:n,isTransforming:a,previewGeometry:l}),x=G7(s,n,l),v=k.useCallback(()=>{i.current.forEach(C=>{t!=null&&t.hasLayer(C)&&t.removeLayer(C)}),i.current=[],_.current&&(t!=null&&t.hasLayer(_.current))&&(t.removeLayer(_.current),_.current=null),j.current&&(t!=null&&t.hasLayer(j.current))&&(t.removeLayer(j.current),j.current=null)},[t]);return k.useEffect(()=>{if(!t)return;const C="transformHandlesPane",P="transformOutlinePane",I=t._norotatePane,z=t._rotatePane;t.getPane(C)||t.createPane(C,I),t.getPane(P)||t.createPane(P,z);const F=t.getPane(C);F&&(F.style.zIndex="900",F.style.pointerEvents="auto");const D=t.getPane(P);D&&(D.style.zIndex="850",D.style.pointerEvents="none");const X=t.getPane("tooltipsPane")?"tooltipsPane":void 0;if(v(),n==="none"||y.length===0)return;const K=(a&&l&&l.length>=3?l:s==null?void 0:s.geometry)||null;if(K&&K.length>=3){const te=K.map(J=>[J.lat,J.lng]);_.current=Bt.polygon(te,{color:"hsl(var(--primary))",weight:2,fill:!1,dashArray:"6, 4",className:"transform-outline",pane:P,interactive:!1}).addTo(t),_.current.bringToFront()}if(a&&l&&l.length>=3){const te=l.map(J=>[J.lat,J.lng]);j.current=Bt.polygon(te,{color:"hsl(var(--accent))",weight:2,fillColor:"hsl(var(--accent))",fillOpacity:.12,dashArray:"8, 4",className:"transform-preview-polygon",pane:P,interactive:!1}).addTo(t),j.current.bringToFront()}return y.forEach(te=>{const J=Bt.divIcon({className:`transform-handle transform-handle-${te.type}`,html:Z2(te,!1),iconSize:te.type==="center"?[24,24]:te.type==="rotate"?[20,20]:[12,12],iconAnchor:te.type==="center"?[12,12]:te.type==="rotate"?[10,10]:[6,6]}),H=Bt.marker([te.position.lat,te.position.lng],{icon:J,draggable:!1,interactive:!0,zIndexOffset:2e3,pane:C});H.on("add",()=>{const q=H.getElement();q&&(q.style.cursor=te.cursor)});const O=te.type==="center"?"Drag to move":te.type==="rotate"?"Drag to rotate":"Drag to scale";H.bindTooltip(O,{direction:"top",offset:[0,-10],permanent:!1,pane:X}),H.on("mousedown",q=>{const W=q;W.originalEvent&&(W.originalEvent.stopPropagation(),W.originalEvent.preventDefault());const Q=t?Ly(t,W.originalEvent):W.latlng;c({handle:te,latlng:Q});const Z=Bt.divIcon({className:`transform-handle transform-handle-${te.type} active`,html:Z2(te,!0),iconSize:te.type==="center"?[24,24]:te.type==="rotate"?[20,20]:[12,12],iconAnchor:te.type==="center"?[12,12]:te.type==="rotate"?[10,10]:[6,6]});H.setIcon(Z)}),H.on("mouseup",()=>{u(),H.setIcon(J)}),H.addTo(t),i.current.push(H)}),()=>{v()}},[t,n,y,x,a,l,v,c,u]),k.useEffect(()=>{if(!(!t||!a||!l||l.length<3)&&j.current&&t.hasLayer(j.current)){const C=l.map(P=>[P.lat,P.lng]);j.current.setLatLngs(C)}},[t,a,l]),k.useEffect(()=>()=>
786{v()},[v]),null};function Hc(t){return t?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"):""}const mb=({selectedOverlay:t,isActive:s,onTransformComplete:n})=>{const a=sP({overlay:t}),[l,c]=k.useState("none"),{transformState:u,setTransformMode:i,setScaleAxis:_,startTransform:j,updateTransform:y,endTransform:x,cancelTransform:v,applyNumericTransform:C,resetTransform:P,snapToAngle:I,setSnapToAngle:z,isUpdating:F}=tP({overlay:t,onTransformComplete:Q=>{const Z=l==="move"?"move":l==="rotate"?"rotate":"scale";a.pushToHistory(Z,Q,`${Z} transform applied`),n==null||n()}}),D=k.useCallback(Q=>{c(Q),i(Q)},[i]),X=k.useCallback(async Q=>{const Z=t==null?void 0:t.geometry;if(await C(Q),Z&&(t!=null&&t.geometry)){const oe=Q.rotationDegrees!==void 0?"rotate":Q.scalePercent!==void 0?"scale":"move";a.pushToHistory(oe,t.geometry,`${oe} transform applied`)}},[C,t,a]),K=ip(t),te=k.useCallback(Q=>{if(K){Ve.info("Property outlines and setbacks are locked");return}!(t!=null&&t.geometry)||t.geometry.length<3||X({rotationDegrees:Q})},[t,X,K]),J=k.useCallback(()=>{if(K){Ve.info("Property outlines and setbacks are locked");return}D("rotate")},[D,K]),H=k.useCallback(()=>{if(K){Ve.info("Property outlines and setbacks are locked");return}D("move")},[D,K]),O=k.useCallback(()=>{if(K){Ve.info("Property outlines and setbacks are locked");return}D("scale")},[D,K]),q=k.useCallback(()=>{D("none")},[D]),W=k.useCallback(Q=>{if(Q!=="none"&&K){Ve.info("Property outlines and setbacks are locked");return}D(Q)},[D,K]);return k.useEffect(()=>{if(!s)return;const Q=Z=>{if(!(Z.target instanceof HTMLInputElement||Z.target instanceof HTMLTextAreaElement||Z.target instanceof HTMLSelectElement)){if(Z.key.toLowerCase()==="r"&&!Z.ctrlKey&&!Z.metaKey&&!Z.altKey){if(Z.preventDefault(),t){if(ip(t)){Ve.info("Property outlines and setbacks are locked");return}J()}return}if(Z.key.toLowerCase()==="m"&&!Z.ctrlKey&&!Z.metaKey&&!Z.altKey){if(Z.preventDefault(),t){if(ip(t)){Ve.info("Property outlines and setbacks are locked");return}H()}return}if(Z.key.toLowerCase()==="s"&&!Z.ctrlKey&&!Z.metaKey&&!Z.altKey){if(Z.preventDefault(),t){if(ip(t)){Ve.info("Property outlines and setbacks are locked");return}O()}return}if(Z.key==="Escape"){Z.preventDefault(),u.isTransforming?v():u.mode!=="none"&&q();return}if((Z.ctrlKey||Z.metaKey)&&Z.key==="z"&&!Z.shiftKey){Z.preventDefault(),a.canUndo?a.undo():Ve.info("Nothing to undo - make a change first");return}if((Z.ctrlKey||Z.metaKey)&&(Z.key==="y"||Z.key==="z"&&Z.shiftKey)){a.canRedo&&(Z.preventDefault(),a.redo());return}if(u.mode==="rotate"&&(Z.key==="ArrowLeft"||Z.key==="ArrowRight")){Z.preventDefault();const oe=Z.key==="ArrowLeft"?-1:1,ce=Z.shiftKey?1:15;te(oe*ce);return}if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(Z.key)&&(u.mode==="move"||u.mode==="none")){if(!t||ip(t))return;Z.preventDefault();const oe=Z.shiftKey?1:5;let ce=0,ae=0;Z.key==="ArrowUp"&&(ae=oe),Z.key==="ArrowDown"&&(ae=-oe),Z.key==="ArrowRight"&&(ce=oe),Z.key==="ArrowLeft"&&(ce=-oe),X({offsetXFt:ce,offsetYFt:ae});return}}};return window.addEventListener("keydown",Q,!0),()=>window.removeEventListener("keydown",Q,!0)},[s,t,u.mode,u.isTransforming,a.canUndo,a.canRedo,J,H,O,q,v,te,X,a]),{transformState:u,mode:u.mode,isTransforming:u.isTransforming,previewGeometry:u.previewGeometry,scaleAxis:u.scaleAxis,setTransformMode:W,setScaleAxis:_,enterRotateMode:J,enterMoveMode:H,enterScaleMode:O,exitTransformMode:q,startTransform:j,updateTransform:y,endTransform:x,cancelTransform:v,applyNumericTransform:X,resetTransform:P,rotateByDegrees:te,snapToAngle:I,setSnapToAngle:z,canUndo:a.canUndo,canRedo:a.canRedo,undo:a.undo,redo:a.redo,isUpdating:F,isLocked:K}},H7=({overlay:t,position:s,activeMode:n,onModeChange:a,isTransforming:l,onConfirm:c,onCancel:u,onOpenPolygonTools:i,onDelete:_,onDuplicate:j,onMirror:y,canMirror:x=!1,onClose:v,onPositionChange:C,currentAngle:P=0,currentScale:I=1,scaleAxis:z="both",onScaleAxisChange:F,currentDimensions:D,canUndo:X=!1,canRedo:K=!1,onUndo:te,onRedo:J,onEditVertices:H})=>{const[O,q]=k.useState(!1),[W,Q]=k.useState({x:0,y:0}),[Z,oe]=k.useState({x:245,y:125}),ce=k.useRef(null),ae=ip(t),ie=k.useCallback(ge=>{ge.preventDefault(),q(!0),Q({x:ge.clientX-Z.x,y:ge.clientY-Z.y})},[Z]);if(k.useEffect(()=>{if(!O)return;const ge=Ee=>{const ve=Ee.clientX-W.x,we=Ee.clientY-W.y,Ze=20,ke=Math.max(Ze,Math.min(window.innerWidth-200,ve)),ze=Math.max(Ze,Math.min(window.innerHeight-200,we));oe({x:ke,y:ze}),C==null||C({x:ke,y:ze})},We=()=>{q(!1)};return window.addEventListener("mousemove",ge),window.addEventListener("mouseup",We),()=>{window.removeEventListener("mousemove",ge),window.removeEventListener("mouseup",We)}},[O,W,C]),!t||!s)return null;const de=ge=>{ae&&ge!=="none"||a(ge)};return e.jsx(hm,{children:e.jsx("div",{ref:ce,className:`fixed z-[1001] animate-in fade-in-0 zoom-in-95 duration-200 ${O?"cursor-grabbing":""}`,style:{left:Z.x,top:Z.y},children:e.jsxs("div",{className:"bg-card/95 backdrop-blur-sm border border-border rounded-xl shadow-xl p-2 w-[180px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 pb-2 border-b border-border 
786cursor-grab active:cursor-grabbing",onMouseDown:ie,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"flex gap-0.5",children:[e.jsx("div",{className:"w-1 h-1 rounded-full bg-muted-foreground/40"}),e.jsx("div",{className:"w-1 h-1 rounded-full bg-muted-foreground/40"})]}),e.jsxs("div",{className:"flex gap-0.5",children:[e.jsx("div",{className:"w-1 h-1 rounded-full bg-muted-foreground/40"}),e.jsx("div",{className:"w-1 h-1 rounded-full bg-muted-foreground/40"})]})]}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground truncate max-w-[100px]",children:t.name})]}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:v,children:e.jsx(ja,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-1 mb-2",children:[e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:n==="move"?"default":"outline",size:"sm",className:"h-9 p-0",onClick:()=>de(n==="move"?"none":"move"),disabled:ae||l,children:ae?e.jsx(jc,{className:"h-4 w-4"}):e.jsx(If,{className:"h-4 w-4"})})}),e.jsx(or,{side:"bottom",children:e.jsx("p",{children:ae?"Locked":"Move (M)"})})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:n==="rotate"?"default":"outline",size:"sm",className:"h-9 p-0",onClick:()=>de(n==="rotate"?"none":"rotate"),disabled:ae||l,children:ae?e.jsx(jc,{className:"h-4 w-4"}):e.jsx(S0,{className:"h-4 w-4"})})}),e.jsx(or,{side:"bottom",children:e.jsx("p",{children:ae?"Locked":"Rotate (R)"})})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:n==="scale"?"default":"outline",size:"sm",className:"h-9 p-0",onClick:()=>de(n==="scale"?"none":"scale"),disabled:ae||l,children:ae?e.jsx(jc,{className:"h-4 w-4"}):e.jsx(Mf,{className:"h-4 w-4"})})}),e.jsx(or,{side:"bottom",children:e.jsx("p",{children:ae?"Locked":"Scale (S)"})})]})]}),n!=="none"&&!ae&&e.jsxs("div",{className:"mb-2 p-2 bg-muted/50 rounded-lg",children:[n==="rotate"&&e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs(Mt,{variant:"secondary",className:"text-xs px-3 font-mono",children:[P.toFixed(1),"°"]})}),n==="scale"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(q0,{type:"single",value:z,onValueChange:ge=>ge&&(F==null?void 0:F(ge)),className:"justify-center gap-1",disabled:l,children:[e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Vm,{value:"width",size:"sm",className:"h-7 w-7 p-0 data-[state=on]:bg-primary data-[state=on]:text-primary-foreground",children:e.jsx(vS,{className:"h-3.5 w-3.5"})})}),e.jsx(or,{side:"bottom",children:"Width"})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Vm,{value:"length",size:"sm",className:"h-7 w-7 p-0 data-[state=on]:bg-primary data-[state=on]:text-primary-foreground",children:e.jsx(bS,{className:"h-3.5 w-3.5"})})}),e.jsx(or,{side:"bottom",children:"Length"})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Vm,{value:"both",size:"sm",className:"h-7 w-7 p-0 data-[state=on]:bg-primary data-[state=on]:text-primary-foreground",children:e.jsx(yS,{className:"h-3.5 w-3.5"})})}),e.jsx(or,{side:"bottom",children:"Uniform"})]})]}),e.jsx("div",{className:"flex justify-center",children:D&&l?e.jsxs(Mt,{variant:"secondary",className:"text-xs px-2 font-mono",children:[Math.round(D.widthFt),"' × ",Math.round(D.lengthFt),"'"]}):e.jsxs(Mt,{variant:"secondary",className:"text-xs px-2 font-mono",children:[(I*100).toFixed(0),"%"]})})]})]}),l&&e.jsxs("div",{className:"flex gap-1 mb-2",children:[e.jsxs(Le,{variant:"outline",size:"sm",className:"flex-1 h-8 text-destructive hover:text-destructive",onClick:u,children:[e.jsx(ja,{className:"h-4 w-4 mr-1"}),"Cancel"]}),e.jsxs(Le,{variant:"default",size:"sm",className:"flex-1 h-8 bg-emerald-600 hover:bg-emerald-700",onClick:c,children:[e.jsx(cl,{className:"h-4 w-4 mr-1"}),"Apply"]})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-1",children:[e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"sm",className:"h-8 p-0",onClick:te,disabled:!X,children:e.jsx(zf,{className:"h-4 w-4"})})}),e.jsx(or,{side:"bottom",children:"Undo"})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"sm",className:"h-8 p-0",onClick:J,disabled:!K,children:e.jsx(U1,{className:"h-4 w-4"})})}),e.jsx(or,{side:"bottom",children:"Redo"})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"sm",className:"h-8 p-0",onClick:H,disabled:l||!H,children:e.jsx(Du,{className:"h-4 w-4"})})}),e.jsx(or,{side:"bottom",children:"Edit Vertices"})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"sm",className:"h-8 p-0",onClick:j,disabled:l,children:e.jsx(hp,{className:"h-4 w-4"})})}),e.jsx(or,{side:"bottom",children:"Duplicate"})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"sm",className:"h-8 p-0",onClick:y,disabled:l||!x,children:e.jsx(p3,{className:"h-4 w-4"})})}),e.jsx(or,{side:"bottom",children:"Mirror to Opposite Side"})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"sm",className:"h-8 p-0 text-destructive hover:text-destructive",onClick:_,disabled:l,children:e.jsx(wr,{className:"h-4 w-4"})})}),e.jsx(or,{side:"bottom",children:"Delete"})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"sm",className:"h-8 p-0",onClick:i,disabled:l,children:e.jsx(Dh,{className:"h-4 w-4"})})}),e.jsx(or,{side:"bottom",children:"Tools"})]})]}),n==="none"&&!ae&&e.jsx("div",{className:"mt-2 pt-2 border-t border-border",children:e.jsx("p",{className:"text-[10px] text-muted-foreground text-center",children:"M · R · S · Del"})})]})})})},Z7=()=>fu({queryKey:["all-development-first-images"],queryFn:async()=>{const{data:t,error:s}=await Fs.from("development_files").select("development_id, file_path, file_type, display_order").like("file_type","image/%").order("display_order",{ascending:!0}).order("created_at",{ascending:!0});if(s)return console.error("Error fetching development first images:",s),{};const n={};for(const a of t||[])n[a.development_id]||(n[a.development_id]=a.file_path);return n},staleTime:5*60*1e3}),fb=t=>{const{data:s}=Fs.storage.from("development-files").getPublicUrl(t);return s.publicUrl},W7=()=>fu({queryKey:["all-existing-product-first-images"],queryFn:async()=>{const{data:t,error:s}=await Fs.from("existing_product_files").select("existing_product_id, file_path, file_type, display_order").like("file_type","image/%").order("display_order",{ascending:!0}).order("created_at",{ascending:!0});if(s)return console.error("Error fetching existing product first images:",s),{};const n={};for(const a of t||[])n[a.existing_product_id]||(n[a.existing_product_id]=a.file_path);return n},staleTime:5*60*1e3}),pb=t=>{const{data:s}=Fs.storage.from("existing-product-files").getPublicUrl(t);return s.publicUrl},m1=364e3,bT=12;function f1(t,s=0){return t+s/bT}
786function Y7(t,s=40){const n=t/m1,a=Math.cos(s*(Math.PI/180)),l=t/(m1*a);return{latDeg:n,lngDeg:l}}function Gj(t,s){const n=s.lng-t.lng,a=s.lat-t.lat;let l=Math.atan2(n,a)*(180/Math.PI);return l<0&&(l+=360),l}function jT(t,s){return Math.round(t/s)*s%360}function X7(t,s){const n=s.lat-t.lat,a=s.lng-t.lng;return Math.sqrt(n*n+a*a)}function K7(t,s){const n=s.lat-t.lat,a=s.lng-t.lng,l=Math.cos(t.lat*(Math.PI/180)),c=a*l;return Math.sqrt(n*n+c*c)*m1}function Hj(t,s){let n=t-s;return n=(n%360+360)%360,n}function wT(t,s){let n=t+s;return n=(n%360+360)%360,n}function gb(t,s,n,a=0){const l=X7(t,s);if(l<1e-5)return s;const c=Gj(t,s),u=Hj(c,a),i=jT(u,n),j=wT(i,a)*(Math.PI/180),y=l*Math.cos(j),x=l*Math.sin(j);return{lat:t.lat+y,lng:t.lng+x}}function J7(t,s,n){const{latDeg:a,lngDeg:l}=Y7(s,t.lat),c=n*(Math.PI/180),u=a*Math.cos(c),i=l*Math.sin(c);return{lat:t.lat+u,lng:t.lng+i}}function W2(t,s,n,a,l=0){const c=Gj(t,s);let u=c;if(a>0){const i=Hj(c,l),_=jT(i,a);u=wT(_,l)}return J7(t,n,u)}function Q7(t,s,n=0){const a=Gj(t,s);return Hj(a,n)}function U7(t,s=!1){const n=(t%360+360)%360,a=Math.round(n);return s?`${a}°`:`${a}°`}function xb(t){const s=Math.floor(t),n=Math.round((t-s)*bT);return n===0?`${s}'`:n===12?`${s+1}'`:`${s}' ${n}"`}function py(t,s,n,a){return s&&t?{isSnapping:!0,snapIncrement:45}:t?{isSnapping:!0,snapIncrement:90}:n?{isSnapping:!0,snapIncrement:a}:{isSnapping:!1,snapIncrement:a}}const eV={"bg-gray-500":"#6b7280","bg-gray-400":"#9ca3af","bg-gray-600":"#4b5563","bg-amber-500":"#f59e0b","bg-yellow-500":"#eab308","bg-stone-500":"#78716c","bg-stone-400":"#a8a29e","bg-purple-600":"#9333ea","bg-purple-500":"#a855f7","bg-purple-400":"#c084fc","bg-purple-300":"#d8b4fe","bg-purple-200":"#e9d5ff","bg-green-300":"#86efac","bg-green-500":"#22c55e","bg-green-600":"#16a34a","bg-red-300":"#fca5a5","bg-red-200":"#fecaca","bg-red-100":"#fee2e2","bg-red-500":"#ef4444","bg-red-600":"#dc2626","bg-teal-500":"#14b8a6","bg-blue-300":"#93c5fd","bg-blue-400":"#60a5fa","bg-blue-500":"#3b82f6","bg-orange-300":"#fdba74","bg-orange-400":"#fb923c","bg-orange-500":"#f97316","bg-orange-600":"#ea580c","bg-orange-700":"#c2410c","bg-slate-300":"#cbd5e1","bg-slate-400":"#94a3b8","bg-slate-500":"#64748b","bg-slate-600":"#475569","bg-slate-700":"#334155","bg-indigo-300":"#a5b4fc","bg-indigo-400":"#818cf8","bg-indigo-500":"#6366f1","bg-pink-500":"#ec4899","bg-violet-300":"#c4b5fd","bg-violet-400":"#a78bfa","bg-cyan-500":"#06b6d4"};function Y2(t){return eV[t]||"#6b7280"}const tV=[{value:"polygon",label:"Custom Polygon",icon:fd},{value:"polyline",label:"Route/Path",icon:uo},{value:"county",label:"County Boundary",icon:Da},{value:"township",label:"Township Boundary",icon:Da},{value:"state",label:"State Boundary",icon:Da},{value:"highway",label:"Highway",icon:uo}],sV=["#f59e0b","#ef4444","#22c55e","#3b82f6","#8b5cf6","#ec4899","#06b6d4","#f97316","#84cc16","#6366f1"],nV=({isDrawing:t,drawingType:s,pointsCount:n,onStartDrawing:a,onUndo:l,onCancel:c,onSave:u,isSaving:i=!1,snapEnabled:_=!1,snapIncrement:j=90,onSnapEnabledChange:y,onSnapIncrementChange:x,isShiftHeld:v=!1,currentAngle:C,currentDistanceFeet:P,lengthInputEnabled:I=!1,lengthFeet:z=0,lengthInches:F=0,onLengthInputEnabledChange:D,onLengthChange:X,onAddPointAtLength:K,triggerSaveForm:te=!1,onTriggerSaveFormHandled:J,defaultName:H})=>{const[O,q]=k.useState(!1),[W,Q]=k.useState(H||""),[Z,oe]=k.useState(""),[ce,ae]=k.useState("polygon"),[ie,de]=k.useState("general"),[ge,We]=k.useState("#f59e0b"),[Ee,ve]=k.useState(z.toString()),[we,Ze]=k.useState(F.toString()),[ke,ze]=k.useState(!1),[Ke,dt]=k.useState(!1),Re=_||v,qt=k.useCallback(_t=>{de(_t);const He=Af.find(as=>as.value===_t);if(He){const as=Y2(He.color);We(as)}},[]);k.useEffect(()=>{H&&Q(H)},[H]),k.useEffect(()=>{ve(z.toString()),Ze(F.toString())},[z,F]);const ft=s==="polygon"&&n>=3||s==="polyline"&&n>=2||s==="marker"&&n>=1;k.useEffect(()=>{te&&ft&&!O&&(q(!0),J==null||J())},[te,ft,O,J]);const Fe=k.useCallback((_t,He)=>{ve(_t),Ze(He);const as=parseFloat(_t)||0,vt=parseFloat(He)||0;X==null||X(as,vt)},[X]),fe=()=>{W.trim()&&(u(W.trim(),Z.trim(),ce,ge,ie!=="general"?ie:void 0),q(!1),Q(""),oe(""),de("general"))}
786,Qe=f1(parseFloat(Ee)||0,parseFloat(we)||0),ht=I&&Qe>0&&n>0;return t?e.jsxs("div",{className:"bg-card p-3 rounded-lg border border-border shadow-lg max-w-xs",children:[e.jsxs("div",{className:"text-sm font-medium mb-1 flex items-center gap-2",children:[s==="polygon"&&e.jsx(fd,{className:"w-4 h-4"}),s==="polyline"&&e.jsx(uo,{className:"w-4 h-4"}),s==="marker"&&e.jsx(ji,{className:"w-4 h-4"}),"Drawing ",s]}),e.jsxs("div",{className:"text-xs text-muted-foreground mb-1",children:[n," point",n!==1?"s":"",s==="polygon"&&n>=3&&" ✓",s==="polyline"&&n>=2&&" ✓",s==="marker"&&n>=1&&" ✓"]}),n>0&&e.jsxs("div",{className:"text-[10px] text-blue-500/80 mb-2 flex items-center gap-1",children:[e.jsx(Fh,{className:"w-3 h-3"}),"Drag any point to reposition"]}),(s==="polygon"||s==="polyline")&&e.jsx(wi,{open:ke,onOpenChange:ze,children:e.jsxs("div",{className:"border border-border rounded-md p-2 mb-3 bg-muted/30",children:[e.jsxs(Ni,{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Fo,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs font-medium cursor-pointer",children:"Snap to Angles"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[Re&&e.jsx("span",{className:"text-[9px] text-primary font-medium",children:"ON"}),e.jsx(Oa,{className:fs("w-3.5 h-3.5 text-muted-foreground transition-transform",ke?"":"-rotate-90")})]})]}),e.jsxs(ki,{className:"space-y-2 pt-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Enable"}),e.jsx(kt,{checked:_,onCheckedChange:y,className:"scale-75"})]}),_&&e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Le,{size:"sm",variant:j===90?"default":"outline",className:"flex-1 h-6 text-xs",onClick:()=>x==null?void 0:x(90),children:"90°"}),e.jsx(Le,{size:"sm",variant:j===45?"default":"outline",className:"flex-1 h-6 text-xs",onClick:()=>x==null?void 0:x(45),children:"45°"})]}),n>0&&(C!==null||P!==null)&&e.jsxs("div",{className:`text-[11px] font-mono px-2 py-1 rounded flex justify-between ${Re?"bg-primary/20 text-primary border border-primary/30":"bg-muted text-muted-foreground"}`,children:[C!=null&&e.jsxs("span",{children:["Angle: ",Math.round((C%360+360)%360),"°"]}),P!=null&&e.jsxs("span",{children:["Length: ",xb(P)]})]}),Re&&e.jsxs("div",{className:"text-[10px] text-primary font-medium",children:["✓ Snapping to ",j,"° angles"]}),!_&&e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"💡 Hold Shift for 90° • Ctrl+Shift for 45°"})]})]})}),(s==="polygon"||s==="polyline")&&n>0&&e.jsx(wi,{open:Ke,onOpenChange:dt,children:e.jsxs("div",{className:"border border-border rounded-md p-2 mb-3 bg-muted/30",children:[e.jsxs(Ni,{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(If,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs font-medium cursor-pointer",children:"Set Line Length"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[I&&e.jsx("span",{className:"text-[9px] text-primary font-medium",children:"ON"}),e.jsx(Oa,{className:fs("w-3.5 h-3.5 text-muted-foreground transition-transform",Ke?"":"-rotate-90")})]})]}),e.jsxs(ki,{className:"space-y-2 pt-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Enable"}),e.jsx(kt,{checked:I,onCheckedChange:D,className:"scale-75"})]}),I&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Feet"}),e.jsx(be,{type:"number",min:"0",step:"1",value:Ee,onChange:_t=>Fe(_t.target.value,we),className:"h-7 text-xs",placeholder:"0"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(B,{className:"text-[10px] text-muted-foreground",children:"Inches"}),e.jsx(be,{type:"number",min:"0",max:"11",step:"1",value:we,onChange:_t=>Fe(Ee,_t.target.value),className:"h-7 text-xs",placeholder:"0"})]})]}),Qe>0&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:["Total: ",xb(Qe)]}),e.jsxs(Le,{size:"sm",variant:"secondary",className:"w-full h-7 text-xs",disabled:!ht,onClick:K,children:[e.jsx(cl,{className:"w-3 h-3 mr-1"}),"Add Point at ",Qe>0?xb(Qe):"Length"]}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:'💡 Move cursor to set direction, then click "Add Point" or press Enter'})]})]})]})}),O?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Name"}),e.jsx(be,{placeholder:"e.g., Warehouse Building",value:W,onChange:_t=>Q(_t.target.value),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Layer Type"}),e.jsxs(rt,{value:ie,onValueChange:qt,children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:ge}}),e.jsx(ct,{})]})}),e.jsx(ot,{children:e.jsx(Xc,{className:"h-[280px]",children:GA().map(_t=>
786{const He=Zx[_t],as=Af.filter(vt=>vt.category===_t);return as.length===0?null:e.jsxs(JC,{children:[e.jsx(QC,{className:"text-xs text-muted-foreground font-medium",children:He.label}),as.map(vt=>e.jsx(le,{value:vt.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:Y2(vt.color)}}),e.jsx("span",{children:vt.label})]})},vt.value))]},_t)})})})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Category"}),e.jsxs(rt,{value:ce,onValueChange:ae,children:[e.jsx(it,{className:"h-8 text-sm",children:e.jsx(ct,{})}),e.jsx(ot,{children:tV.map(_t=>e.jsx(le,{value:_t.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_t.icon,{className:"w-4 h-4"}),_t.label]})},_t.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs text-muted-foreground",children:"Color (auto-set by layer type)"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:sV.map(_t=>e.jsx("button",{onClick:()=>We(_t),className:`w-6 h-6 rounded border-2 ${ge===_t?"border-white ring-2 ring-primary":"border-transparent"}`,style:{backgroundColor:_t}},_t))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(B,{className:"text-xs",children:"Description (optional)"}),e.jsx(j1,{placeholder:"Additional details...",value:Z,onChange:_t=>oe(_t.target.value),className:"h-16 text-sm resize-none"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>q(!1),children:"Back"}),e.jsxs(Le,{size:"sm",className:"flex-1",onClick:fe,disabled:!W.trim()||i,children:[i?e.jsx(Va,{className:"w-4 h-4 animate-spin"}):e.jsx(cl,{className:"w-4 h-4 mr-1"}),"Save"]})]})]}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(Le,{size:"sm",variant:"outline",onClick:l,disabled:n===0,className:"w-full",children:[e.jsx(zf,{className:"w-4 h-4 mr-1"}),"Undo",e.jsx("span",{className:"text-muted-foreground ml-1 text-xs",children:"(Ctrl+Z)"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Le,{size:"sm",variant:"secondary",onClick:c,className:"flex-1",children:[e.jsx(ja,{className:"w-4 h-4 mr-1"}),"Cancel"]}),e.jsxs(Le,{size:"sm",onClick:()=>q(!0),disabled:!ft,className:"flex-1",children:[e.jsx(cl,{className:"w-4 h-4 mr-1"}),"Next"]})]})]})]}):e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(Ef,{children:[e.jsx(Pf,{asChild:!0,children:e.jsxs(Le,{variant:"secondary",size:"sm",className:"bg-card border border-border",children:[e.jsx(kp,{className:"w-4 h-4 mr-2"}),"Draw"]})}),e.jsx(Tf,{className:"w-48 p-2 z-[9999]",align:"start",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full justify-start",onClick:()=>
786a("polygon"),children:[e.jsx(fd,{className:"w-4 h-4 mr-2"}),"Draw Polygon"]}),e.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full justify-start",onClick:()=>a("polyline"),children:[e.jsx(uo,{className:"w-4 h-4 mr-2"}),"Draw Line/Route"]}),e.jsxs(Le,{variant:"ghost",size:"sm",className:"w-full justify-start",onClick:()=>a("marker"),children:[e.jsx(ji,{className:"w-4 h-4 mr-2"}),"Add Marker"]})]})})]})})},p1=(t,s,n,a)=>{const c=(n-t)*Math.PI/180,u=(a-s)*Math.PI/180,i=Math.sin(c/2)*Math.sin(c/2)+Math.cos(t*Math.PI/180)*Math.cos(n*Math.PI/180)*Math.sin(u/2)*Math.sin(u/2);return 3959*(2*Math.atan2(Math.sqrt(i),Math.sqrt(1-i)))},aV=(t,s=50)=>{if(t.length<2)return t;let n=0;const a=[];for(let j=1;j<t.length;j++){const y=p1(t[j-1].lat,t[j-1].lng,t[j].lat,t[j].lng);a.push(y),n+=y}if(n===0)return t;const l=[],c=n/(s-1);let u=0,i=0,_=0;for(let j=0;j<s;j++){const y=j*c;for(;u<a.length-1&&_+a[u]<y;)_+=a[u],u++;i=y-_;const x=a[u]||1e-4,v=Math.min(1,Math.max(0,i/x)),C=t[u],P=t[Math.min(u+1,t.length-1)];l.push({lat:C.lat+(P.lat-C.lat)*v,lng:C.lng+(P.lng-C.lng)*v})}return l},rV=async t=>{var l,c,u;if(t.length===0)return{elevations:[],source:"fallback",resolution:"N/A"};const s=100;let n=t;if(t.length>s){const i=Math.ceil(t.length/s);n=t.filter((_,j)=>j%i===0),n[n.length-1]!==t[t.length-1]&&n.push(t[t.length-1])}const a=n.map(i=>`${i.lat},${i.lng}`).join("|");try{const i=await fetch(`https://api.opentopodata.org/v1/ned10m?locations=${a}`,{signal:AbortSignal.timeout(8e3)});if(i.ok){const _=await i.json();if(_.status==="OK"&&((l=_.results)==null?void 0:l.length)>0&&_.results.some(y=>y.elevation!==null))return{elevations:_.results.map(y=>y.elevation??0),source:"ned10m",resolution:"10m"}}}catch{console.log("NED 10m unavailable, trying ASTER...")}try{const i=await fetch(`https://api.opentopodata.org/v1/aster30m?locations=${a}`,{signal:AbortSignal.timeout(8e3)});if(i.ok){const _=await i.json();if(_.status==="OK"&&((c=_.results)==null?void 0:c.length)>0&&_.results.some(y=>y.elevation!==null))return{elevations:_.results.map(y=>y.elevation??0),source:"aster30m",resolution:"30m"}}}catch{console.log("ASTER 30m unavailable, trying SRTM...")}try{const i=await fetch(`https://api.open-elevation.com/api/v1/lookup?locations=${a}`,{signal:AbortSignal.timeout(1e4)});if(i.ok){const _=await i.json();if(((u=_.results)==null?void 0:u.length)>0)return{elevations:_.results.map(j=>j.elevation),source:"srtm",resolution:"~30m"}}}catch(i){console.error("All elevation APIs failed:",i)}return{elevations:n.map(()=>100),source:"fallback",resolution:"N/A"}},iV=(t,s)=>{if(s===0)return 0;const n=s*1609.34;return t/n*100},oV=({points:t,onHoverPoint:s})=>{const[n,a]=k.useState([]),[l,c]=k.useState(!1),[u,i]=k.useState(null),[_,j]=k.useState(null),[y,x]=k.useState({source:"fallback",resolution:"N/A"}),[v,C]=k.useState(!1),[P,I]=k.useState(!1),z=k.useRef(null),F=k.useMemo(()=>{if(n.length<2)return[];const fe=20,Qe=[];for(let ht=1;ht<n.length;ht++){const _t=n[ht-1].elevation*3.28084,He=n[ht].elevation*3.28084,as=n[ht-1].distance,vt=n[ht].distance,Xe=Math.min(_t,He),Ce=Math.max(_t,He),Be=Math.ceil(Xe/fe)*fe;for(let Dt=Be;Dt<=Ce;Dt+=fe)if(Dt>Xe&&Dt<=Ce){const Rt=(Dt-_t)/(He-_t),zt=as+Rt*(vt-as);Qe.push({distance:zt,elevation:Dt,isIndex:Dt%100===0})}}return Qe},[n]);k.useEffect(()=>{if(t.length<2){a([]);return}(async()=>{c(!0),i(null);try{let Qe=0;for(let Be=1;Be<t.length;Be++)Qe+=p1(t[Be-1].lat,t[Be-1].lng,t[Be].lat,t[Be].lng);const ht=v?100:50,_t=Qe*5280,He=v&&_t<500?100:ht,as=aV(t,He),vt=await rV(as);x({source:vt.source,resolution:vt.resolution});let Xe=0;const Ce=[];for(let Be=0;Be<as.length;Be++)Be>0&&(Xe+=p1(as[Be-1].lat,as[Be-1].lng,as[Be].lat,as[Be].lng)),Ce.push({lat:as[Be].lat,lng:as[Be].lng,elevation:vt.elevations[Be]??100,distance:Xe});a(Ce)}catch(Qe){i("Failed to load elevation data"),console.error(Qe)}finally{c(!1)}})()},[t,v]);const D=k.useCallback(fe=>{if(!z.current||n.length===0)return;const ht=z.current.getBoundingClientRect(),_t=fe.clientX-ht.left,He=ht.width,as=_t/He,vt=Math.min(Math.max(0,Math.round(as*(n.length-1))),n.length-1);j(vt),s&&n[vt]&&s({lat:n[vt].lat,lng:n[vt].lng})},[n,s]),X=k.useCallback(()=>{j(null),s&&s(null)},[s]);if(t.length<2)return null;if(l)return e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground py-2",children:[e.jsx(Va,{className:"w-3 h-3 animate-spin"}),"Loading elevation..."]});if(u||n.length===0)return null;const K=n.map(fe=>fe.elevation),te=Math.min(...K),J=Math.max(...K),H=K.reduce((fe,Qe,ht)=>{if(ht===0)return 0;
786const _t=Qe-K[ht-1];return _t>0?fe+_t:fe},0),O=K.reduce((fe,Qe,ht)=>{if(ht===0)return 0;const _t=K[ht-1]-Qe;return _t>0?fe+_t:fe},0),q=[];for(let fe=1;fe<n.length;fe++){const Qe=n[fe].elevation-n[fe-1].elevation,ht=n[fe].distance-n[fe-1].distance;q.push(iV(Qe,ht))}const W=Math.max(...q.map(Math.abs)),Q=q.length>0?q.reduce((fe,Qe)=>fe+Math.abs(Qe),0)/q.length:0,Z=fe=>{const Qe=Math.abs(fe);return Qe<3?"#22c55e":Qe<6?"#84cc16":Qe<10?"#eab308":Qe<15?"#f97316":"#ef4444"},oe=fe=>Math.round(fe*3.28084),ce=200,ae=50,ie=2,de=n[n.length-1].distance,ge=J-te||1,We=fe=>({x:ie+fe.distance/de*(ce-2*ie),y:ae-ie-(fe.elevation-te)/ge*(ae-2*ie)}),Ee=n.slice(1).map((fe,Qe)=>{const ht=n[Qe],_t=We(ht),He=We(fe),as=q[Qe];return{x1:_t.x,y1:_t.y,x2:He.x,y2:He.y,color:Z(as)}}),ve=n.slice(1).map((fe,Qe)=>{const ht=n[Qe],_t=We(ht),He=We(fe),as=q[Qe],vt=Math.abs(as),Xe=Math.min(.6,vt/20),Ce=as>0?.1:-.1,Be=Math.max(.05,Math.min(.7,Xe+Ce));return{x1:_t.x,x2:He.x,y1:Math.min(_t.y,He.y),shade:Be,isUphill:as>0}}),Ze=n.map((fe,Qe)=>{const{x:ht,y:_t}=We(fe);return`${Qe===0?"M":"L"} ${ht} ${_t}`}).join(" ")+` L ${ce-ie} ${ae-ie} L ${ie} ${ae-ie} Z`,ke=n[0],ze=n[n.length-1],Ke=We(ke),dt=We(ze),Re=_!==null?n[_]:null,qt=Re?We(Re):null,ft=_!==null&&_>0?q[_-1]:0,Fe=_!==null&&_>0?Z(ft):"#22c55e";return e.jsxs("div",{className:"space-y-2 border-t border-border/50 pt-2 mt-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[e.jsx(Rh,{className:"w-3 h-3"}),"Elevation Profile"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",title:"Increase sample density for better accuracy on short distances",children:[e.jsx(IS,{className:"w-3 h-3 text-muted-foreground"}),e.jsx(kt,{checked:v,onCheckedChange:C,className:"scale-75 data-[state=checked]:bg-blue-500"})]}),e.jsxs("div",{className:"flex items-center gap-1",title:"Show contour line crossings (20ft intervals)",children:[e.jsx(Da,{className:"w-3 h-3 text-muted-foreground"}),e.jsx(kt,{checked:P,onCheckedChange:I,className:"scale-75 data-[state=checked]:bg-purple-500"})]})]})]}),e.jsxs("div",{className:"bg-secondary/30 rounded-md p-1 relative",children:[e.jsxs("svg",{ref:z,width:"100%",viewBox:`0 0 ${ce} ${ae}`,className:"overflow-visible cursor-crosshair",onMouseMove:D,onMouseLeave:X,children:[ve.map((fe,Qe)=>{const ht=n[Qe],_t=n[Qe+1],He=We(ht),as=We(_t),vt=`${He.x},${He.y} ${as.x},${as.y} ${as.x},${ae-ie} ${He.x},${ae-ie}`;return e.jsx("polygon",{points:vt,fill:fe.isUphill?"#84cc16":"#78716c",opacity:fe.shade},`terrain-${Qe}`)}),e.jsx("path",{d:Ze,fill:"url(#elevGradient)",opacity:.15}),Ee.map((fe,Qe)=>e.jsx("line",{x1:fe.x1,y1:fe.y1,x2:fe.x2,y2:fe.y2,stroke:fe.color,strokeWidth:2,strokeLinecap:"round"},Qe)),n.map((fe,Qe)=>{if(Qe===0||Qe===n.length-1)return null;const{x:ht,y:_t}=We(fe);return e.jsx("circle",{cx:ht,cy:_t,r:1.5,fill:"hsl(var(--foreground))",opacity:.3},`sample-${Qe}`)}),P&&F.map((fe,Qe)=>{const ht=ie+fe.distance/de*(ce-2*ie);return e.jsxs("g",{children:[e.jsx("line",{x1:ht,y1:ae-ie,x2:ht,y2:ae-ie+4,stroke:fe.isIndex?"#a855f7":"#c084fc",strokeWidth:fe.isIndex?1.5:.75}),fe.isIndex&&e.jsxs("text",{x:ht,y:ae-ie+10,textAnchor:"middle",fontSize:6,fill:"#a855f7",fontWeight:"500",children:[fe.elevation,"′"]})]},`contour-${Qe}`)}),e.jsx("circle",{cx:Ke.x,cy:Ke.y,r:4,fill:"hsl(var(--background))",stroke:"#3b82f6",strokeWidth:2}),e.jsxs("text",{x:Ke.x,y:Ke.y-8,textAnchor:"start",fontSize:8,fontWeight:"600",fill:"hsl(var(--foreground))",children:[oe(ke.elevation),"′"]}),e.jsx("circle",{cx:dt.x,cy:dt.y,r:4,fill:"hsl(var(--background))",stroke:"#3b82f6",strokeWidth:2}),e.jsxs("text",{x:dt.x,y:dt.y-8,textAnchor:"end",fontSize:8,fontWeight:"600",fill:"hsl(var(--foreground))",children:[oe(ze.elevation),"′"]}),qt&&e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:qt.x,y1:ie,x2:qt.x,y2:ae-ie,stroke:"hsl(var(--foreground))",strokeWidth:.5,strokeDasharray:"2,2",opacity:.5}),e.jsx("circle",{cx:qt.x,cy:qt.y,r:3,fill:Fe,stroke:"hsl(var(--background))",strokeWidth:1.5})]}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"elevGradient",x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--muted-foreground))"}),e.jsx("stop",{offset:"100%",stopColor:"transparent"})]})})]}),Re&&qt&&e.jsxs("div",{className:"absolute bg-popover/95 backdrop-blur-sm border border-border rounded px-1.5 py-1 text-[10px] shadow-md pointer-events-none z-10",style:{left:`${qt.x/ce*100}%`,top:"-4px",transform:qt.x>ce/2?"translate(-100%, -100%)":"translate(0, -100%)"},children:[e.jsxs("div",{className:"font-medium",children:[oe(Re.elevation)," ft"]}),e.jsxs("div",{className:"text-muted-foreground",children:[Re.distance.toFixed(2)," mi"]}),_!==null&&_>0&&e.jsxs("div",{style:{color:Fe},children:[ft>0?"+":"",ft.toFixed(1),"% grade"]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1 text-[9px] text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx("span",{className:"w-2 h-1 rounded-sm",style:{backgroundColor:"#22c55e"}})," Flat"]}),e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx("span",{className:"w-2 h-1 rounded-sm",style:{backgroundColor:"#eab308"}})," Mod"]}),e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx("span",{className:"w-2 h-1 rounded-sm",style:{backgroundColor:"#ef4444"}})," Steep"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Start:"}),e.jsxs("span",{children:[oe(ke.elevation)," ft"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"End:"}),e.jsxs("span",{children:[oe(ze.elevation)," ft"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Min:"}),e.jsxs("span",{children:[oe(te)," ft"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Max:"}),e.jsxs("span",{children:[oe(J)," ft"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(qC,{className:"w-3 h-3 text-green-500"}),e.jsx("span",{className:"text-muted-foreground",children:"Gain:"}),e.jsxs("span",{className:"text-green-600",children:["+",oe(H)," ft"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(u5,{className:"w-3 h-3 text-red-500"}),e.jsx("span",{className:"text-muted-foreground",children:"Loss:"}),e.jsxs("span",{className:"text-red-600",children:["-",oe(O)," ft"]})]})]}),(()=>{const fe=ze.elevation-ke.elevation,Qe=oe(fe);return e.jsxs("div",{className:"flex items-center justify-between text-xs bg-secondary/30 rounded px-2 py-1",children:[e.jsx("span",{className:"text-muted-foreground font-medium",children:"Net Change:"}),e.jsxs("span",{className:`font-semibold ${Qe>0?"text-green-600":Qe<0?"text-red-600":""}`,children:[Qe>0?"+":"",Qe," ft (",Qe>0?"↑":Qe<0?"↓":"→",")"]})]})})(),e.jsxs("div",{className:"flex items-center gap-3 text-xs border-t border-border/50 pt-1.5 mt-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(L3,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Avg Grade:"}),e.jsxs("span",{children:[Q.toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Max:"}),e.jsxs("span",{className:W>10?"text-amber-600 font-medium":"",children:[W.toFixed(1),"%"]})]})]}),P&&F.length>0&&e.jsxs("div",{className:"flex items-center justify-between text-[10px] bg-purple-500/10 rounded px-2 py-1 border border-purple-500/20",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Da,{className:"w-3 h-3 text-purple-500"}
786),e.jsxs("span",{className:"text-purple-600 dark:text-purple-400 font-medium",children:[F.length," contour crossings"]})]}),e.jsxs("span",{className:"text-muted-foreground",children:[F.filter(fe=>fe.isIndex).length," index (100′)"]})]}),(()=>{const fe=de*5280,Qe=y.source==="ned10m"?33:(y.source==="aster30m",98),ht=fe/n.length;let _t,He;return fe<Qe*3?(_t="poor",He="text-red-500"):fe<Qe*10?(_t="fair",He="text-amber-500"):fe<Qe*30?(_t="good",He="text-green-500"):(_t="excellent",He="text-green-600"),e.jsxs("div",{className:"text-[10px] bg-secondary/40 rounded px-2 py-1.5 space-y-1 border-t border-border/30 mt-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Accuracy:"}),e.jsx("span",{className:`font-medium capitalize ${He}`,children:_t==="excellent"?"● Excellent":_t==="good"?"● Good":_t==="fair"?"◐ Fair":"○ Poor"})]}),e.jsxs("div",{className:"flex items-center justify-between text-muted-foreground",children:[e.jsx("span",{children:"Samples:"}),e.jsxs("span",{children:[n.length," pts @ ~",Math.round(ht)," ft apart"]})]}),e.jsxs("div",{className:"flex items-center justify-between text-muted-foreground",children:[e.jsx("span",{children:"Resolution:"}),e.jsxs("span",{children:["~",Qe," ft (",y.resolution,")"]})]}),_t==="poor"&&e.jsx("div",{className:"text-amber-600/80 text-[9px] mt-0.5",children:"⚠ Distance too short for reliable terrain detail"}),_t==="fair"&&e.jsx("div",{className:"text-amber-600/70 text-[9px] mt-0.5",children:"ⓘ May miss small terrain features"})]})})(),e.jsxs("div",{className:"text-[9px] text-muted-foreground/60 text-center pt-1",children:[y.source==="ned10m"&&e.jsx("span",{children:"Source: USGS National Elevation Dataset"}),y.source==="aster30m"&&e.jsx("span",{children:"Source: NASA ASTER GDEM"}),y.source==="srtm"&&e.jsx("span",{children:"Source: NASA SRTM"}),y.source==="fallback"&&e.jsx("span",{className:"text-amber-600/80",children:"Elevation data unavailable"})]})]})},NT=(t,s,n,a)=>{const c=(n-t)*Math.PI/180,u=(a-s)*Math.PI/180,i=Math.sin(c/2)*Math.sin(c/2)+Math.cos(t*Math.PI/180)*Math.cos(n*Math.PI/180)*Math.sin(u/2)*Math.sin(u/2);return 3959*(2*Math.atan2(Math.sqrt(i),Math.sqrt(1-i)))},Zj=t=>{let s=0;for(let n=1;n<t.length;n++)s+=NT(t[n-1].lat,t[n-1].lng,t[n].lat,t[n].lng);return s},kT=t=>{if(t.length<3)return 0;let s=Zj(t);return s+=NT(t[t.length-1].lat,t[t.length-1].lng,t[0].lat,t[0].lng),s},CT=t=>{const s=t/35;if(s<1)return`~${Math.round(s*60)} min`;{const n=Math.floor(s),a=Math.round((s-n)*60);return a>0?`~${n}h ${a}m`:`~${n}h`}},ST=t=>{const s=t/3;if(s<1)return`~${Math.round(s*60)} min`;{const n=Math.floor(s),a=Math.round((s-n)*60);return a>0?`~${n}h ${a}m`:`~${n}h`}},ET=t=>{if(t.length<3)return 0;const s=6371e3,n=t.reduce((i,_)=>i+_.lat,0)/t.length,a=s*Math.PI/180,l=s*Math.cos(n*Math.PI/180)*Math.PI/180,c=t.map(i=>({x:(i.lng-t[0].lng)*l,y:(i.lat-t[0].lat)*a}));let u=0;for(let i=0;i<c.length;i++){const _=(i+1)%c.length;u+=c[i].x*c[_].y,u-=c[_].x*c[i].y}return u=Math.abs(u)/2,u*10.7639},PT=t=>{const s=t/43560;return{sqFt:t>=1e6?`${(t/1e6).toFixed(2)}M sq ft`:t>=1e3?`${(t/1e3).toFixed(1)}K sq ft`:`${Math.round(t)} sq ft`,acres:s>=100?`${Math.round(s)} acres`:`${s.toFixed(2)} acres`}},g0=t=>{if(t>=1)return`${t.toFixed(2)} mi`;{const s=t*5280;return s>=1e3?`${(s/1e3).toFixed(1)}K ft`:`${Math.round(s)} ft`}},lV=({isMeasuring:t,measurementType:s,points:n,onStartMeasuring:a,onUndo:l,onCancel:c,onClear:u,onSave:i,onHoverElevationPoint:_})=>{const[j,y]=k.useState(!1),[x,v]=k.useState(""),[C,P]=k.useState(""),I=s==="distance"?Zj(n):0,z=s==="distance"?CT(I):"",F=s==="distance"?ST(I):"",D=s==="area"?PT(ET(n)):{sqFt:"0",acres:"0"},X=s==="area"?kT(n):0,K=s==="distance"&&n.length>=2||s==="area"&&n.length>=3,te=()=>{!x.trim()||!i||(i(x.trim(),C.trim()),v(""),P(""),y(!1))},J=k.useCallback(oe=>{if(!(oe.target instanceof HTMLInputElement||oe.target instanceof HTMLTextAreaElement))switch(oe.key){case"Escape":oe.preventDefault(),c();break;case"Delete":case"Backspace":oe.preventDefault(),n.length>0&&l();break;case"Enter":oe.preventDefault(),K&&!j&&y(!0);break}},[c,l,n.length,K,j]);if(k.useEffect(()=>{if(t)return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)}
786,[t,J]),!t)return null;const[H,O]=k.useState({x:0,y:0}),[q,W]=k.useState(!1),Q=k.useRef(null),Z=k.useCallback(oe=>{oe.preventDefault(),W(!0),Q.current={x:oe.clientX,y:oe.clientY,ox:H.x,oy:H.y}},[H]);return k.useEffect(()=>{if(!q)return;const oe=ae=>{Q.current&&O({x:Q.current.ox+(ae.clientX-Q.current.x),y:Q.current.oy+(ae.clientY-Q.current.y)})},ce=()=>W(!1);return window.addEventListener("mousemove",oe),window.addEventListener("mouseup",ce),()=>{window.removeEventListener("mousemove",oe),window.removeEventListener("mouseup",ce)}},[q]),e.jsxs("div",{style:{transform:`translate(${H.x}px, ${H.y}px)`},className:"bg-card p-3 rounded-lg border border-border shadow-lg min-w-[220px]",children:[e.jsxs("div",{onMouseDown:Z,className:"flex items-center justify-between cursor-grab active:cursor-grabbing mb-1 select-none",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[s==="distance"?e.jsx(Fo,{className:"w-4 h-4"}):e.jsx(iN,{className:"w-4 h-4"}),s==="distance"?"Distance":"Area"," Measurement"]}),e.jsx(If,{className:"w-3.5 h-3.5 text-muted-foreground"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground mb-2 flex items-center justify-between",children:[e.jsxs("span",{children:[n.length," point",n.length!==1?"s":""," placed"]}),e.jsx(hm,{children:e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx("button",{className:"p-0.5 hover:bg-secondary rounded",children:e.jsx(hh,{className:"w-3.5 h-3.5"})})}),e.jsx(or,{side:"left",className:"max-w-[200px] text-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Drag points"})," to adjust"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Click midpoints"})," to add new points"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Right-click point"})," to delete"]}),e.jsxs("div",{className:"border-t border-border/50 pt-1 mt-1",children:[e.jsxs("p",{children:[e.jsx("kbd",{className:"px-1 bg-muted rounded",children:"Esc"})," Cancel"]}),e.jsxs("p",{children:[e.jsx("kbd",{className:"px-1 bg-muted rounded",children:"Del"})," Undo last"]}),e.jsxs("p",{children:[e.jsx("kbd",{className:"px-1 bg-muted rounded",children:"Enter"})," Save"]})]})]})})]})})]}),n.length===0&&e.jsx("div",{className:"bg-secondary/30 rounded-md p-2 mb-3 text-xs text-muted-foreground space-y-1",children:e.jsxs("p",{className:"flex items-center gap-1.5",children:[e.jsx(Q1,{className:"w-3 h-3"}),"Click on map to add points"]})}),n.length>0&&n.length<3&&e.jsxs("div",{className:"bg-secondary/30 rounded-md p-2 mb-3 text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{className:"flex items-center gap-1.5",children:[e.jsx(Fh,{className:"w-3 h-3"}),"Drag points to move"]}),e.jsxs("p",{className:"flex items-center gap-1.5",children:[e.jsx(tr,{className:"w-3 h-3"}),"Click midpoints to add"]})]}),s==="distance"&&n.length>=2&&e.jsxs("div",{className:"bg-secondary/50 rounded-md p-2 mb-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Fo,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsxs("span",{className:"font-medium",children:[I.toFixed(2)," miles"]}),e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",g0(I),")"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Ml,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Drive: ",z]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(wS,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Walk: ",F]})]})]}),e.jsx(oV,{points:n,onHoverPoint:_})]}),s==="area"&&n.length>=3&&e.jsxs("div",{className:"bg-secondary/50 rounded-md p-2 mb-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(iN,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:D.sqFt})]}),e.jsx("div",{className:"text-sm text-muted-foreground pl-5",children:D.acres}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground border-t border-border/50 pt-1.5 mt-1.5",children:[e.jsx(zu,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Perimeter: ",g0(X)]})]})]}),j?e.jsxs("div",{className:"space-y-2 mb-3",children:[e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Name"}),e.jsx(be,{value:x,onChange:oe=>v(oe.target.value),placeholder:"e.g., Site Boundary",className:"h-7 text-xs",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(B,{className:"text-xs",children:"Description (optional)"}),e.jsx(be,{value:C,onChange:oe=>P(oe.target.value),placeholder:"Notes...",className:"h-7 text-xs"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{size:"sm",variant:"outline",onClick:()=>y(!1),className:"flex-1 h-7",children:"Cancel"}),e.jsxs(Le,{size:"sm",onClick:te,disabled:!x.trim(),className:"flex-1 h-7",children:[e.jsx(jg,{className:"w-3 h-3 mr-1"}),"Save"]})]})]}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(Le,{size:"sm",variant:"outline",onClick:l,disabled:n.length===0,className:"w-full",children:[e.jsx(zf,{className:"w-4 h-4 mr-1"}),"Undo"]}),K&&i&&e.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>y(!0),className:"w-full",children:[e.jsx(jg,{className:"w-4 h-4 mr-1"}),"Save as Overlay"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Le,{size:"sm",variant:"secondary",onClick:c,className:"flex-1",children:[e.jsx(ja,{className:"w-4 h-4 mr-1"}),"Done"]}),e.jsxs(Le,{size:"sm",variant:"destructive",onClick:u,disabled:n.length===0,className:"flex-1",children:[e.jsx(wr,{className:"w-4 h-4 mr-1"}),"Clear"]})]})]})]})},cV=({showDemographics:t=!1,showSchools:s=!1,showWalkability:n=!1,showCrime:a=!1,demographicsMetric:l="income",demographicsDisplayMode:c="popup",className:u})=>
786{if(!t&&!s&&!n&&!a)return null;const i=[{range:"0-5",label:"Car Dependent",color:"#ef4444"},{range:"6-10",label:"Somewhat Walkable",color:"#f97316"},{range:"11-14",label:"Walkable",color:"#eab308"},{range:"15-17",label:"Very Walkable",color:"#84cc16"},{range:"18-20",label:"Walker's Paradise",color:"#22c55e"}],_=[{type:"Elementary",color:"#22c55e",icon:"🏫"},{type:"Middle",color:"#3b82f6",icon:"🏛️"},{type:"High",color:"#a855f7",icon:"🎓"}],j={population:[{range:"<10k",label:"Rural",color:"#22c55e",icon:e.jsx(yl,{className:"w-3 h-3"})},{range:"10-50k",label:"Small Town",color:"#84cc16",icon:e.jsx(yl,{className:"w-3 h-3"})},{range:"50-100k",label:"Medium",color:"#eab308",icon:e.jsx(yl,{className:"w-3 h-3"})},{range:"100-500k",label:"Large",color:"#f97316",icon:e.jsx(yl,{className:"w-3 h-3"})},{range:">500k",label:"Metro",color:"#ef4444",icon:e.jsx(yl,{className:"w-3 h-3"})}],income:[{range:"<$30k",label:"Low Income",color:"#ef4444",icon:e.jsx(Vd,{className:"w-3 h-3"})},{range:"$30-50k",label:"Below Median",color:"#f97316",icon:e.jsx(Vd,{className:"w-3 h-3"})},{range:"$50-75k",label:"Median",color:"#eab308",icon:e.jsx(Vd,{className:"w-3 h-3"})},{range:"$75-100k",label:"Above Median",color:"#84cc16",icon:e.jsx(Vd,{className:"w-3 h-3"})},{range:">$100k",label:"High Income",color:"#22c55e",icon:e.jsx(Vd,{className:"w-3 h-3"})}],home_value:[{range:"<$150k",label:"Affordable",color:"#22c55e",icon:e.jsx(qd,{className:"w-3 h-3"})},{range:"$150-250k",label:"Moderate",color:"#84cc16",icon:e.jsx(qd,{className:"w-3 h-3"})},{range:"$250-400k",label:"Mid-Range",color:"#eab308",icon:e.jsx(qd,{className:"w-3 h-3"})},{range:"$400-600k",label:"High Value",color:"#f97316",icon:e.jsx(qd,{className:"w-3 h-3"})},{range:">$600k",label:"Premium",color:"#ef4444",icon:e.jsx(qd,{className:"w-3 h-3"})}],education:[{range:"<15%",label:"Low",color:"#ef4444",icon:e.jsx(tg,{className:"w-3 h-3"})},{range:"15-25%",label:"Below Avg",color:"#f97316",icon:e.jsx(tg,{className:"w-3 h-3"})},{range:"25-35%",label:"Average",color:"#eab308",icon:e.jsx(tg,{className:"w-3 h-3"})},{range:"35-50%",label:"Above Avg",color:"#84cc16",icon:e.jsx(tg,{className:"w-3 h-3"})},{range:">50%",label:"High",color:"#22c55e",icon:e.jsx(tg,{className:"w-3 h-3"})}]},y={population:"Population",income:"Median Income",home_value:"Home Value",education:"College Educated %"},x={popup:"Popup Only",county:"County Heatmap",tract:"Tract Heatmap"},v=j[l];return e.jsxs("div",{className:fs("bg-background/95 backdrop-blur-sm rounded-lg shadow-lg border border-border p-3 space-y-4",u),children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground flex items-center gap-2",children:[e.jsx(qC,{className:"w-3.5 h-3.5"}),"Area Intelligence"]}),n&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zu,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Walkability Index"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"h-3 rounded-full",style:{background:"linear-gradient(to right, #ef4444, #f97316, #eab308, #84cc16, #22c55e)"}}),e.jsxs("div",{className:"flex justify-between mt-1",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground",children:"0"}),e.jsx("span",{className:"text-[9px] text-muted-foreground",children:"20"})]})]}),e.jsx("div",{className:"space-y-0.5",children:i.map(C=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:C.color}}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[C.range,": ",C.label]})]},C.range))})]}),s&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j0,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Schools"})]}),e.jsx("div",{className:"space-y-1",children:_.map(C=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3.5 h-3.5 rounded-full border border-white/50 flex-shrink-0",style:{backgroundColor:C.color}}),e.jsx("span",{className:"text-[10px]",children:C.icon}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[C.type," School"]}
786)]},C.type))})]}),t&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yl,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:y[l]})]}),c!=="popup"&&e.jsx("span",{className:"text-[9px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:x[c]})]}),c!=="popup"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"h-3 rounded-full",style:{background:l==="population"||l==="home_value"?"linear-gradient(to right, #22c55e, #84cc16, #eab308, #f97316, #ef4444)":"linear-gradient(to right, #ef4444, #f97316, #eab308, #84cc16, #22c55e)"}})}),e.jsx("div",{className:"space-y-0.5",children:v.map(C=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:C.color}}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[C.range,": ",C.label]})]},C.range))})]}),c==="popup"&&e.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"Click map for detailed popup"})]}),a&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hd,{className:"w-3.5 h-3.5 text-amber-500"}),e.jsx("span",{className:"text-xs font-medium",children:"Crime Statistics"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0 bg-red-500"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Violent Crime Rate"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0 bg-amber-500"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Property Crime Rate"})]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"Click map for state-level data"})]}),(t||n||a)&&e.jsx("div",{className:"pt-2 border-t border-border/50",children:e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground",children:[e.jsx(S3,{className:"w-3 h-3"}),e.jsx("span",{children:"Click anywhere on map for detailed Area Intelligence popup"})]})})]})};function dV({lat:t,lng:s,onClose:n,isOpen:a}){var te,J,H,O;const[l,c]=k.useState([]),[u,i]=k.useState([]),[_,j]=k.useState([]),[y,x]=k.useState([]),[v,C]=k.useState(null),[P,I]=k.useState(""),[z,F]=k.useState({airports:!0,hospitals:!0,emergencyServices:!0,schools:!0,walkability:!0,address:!0});if(k.useEffect(()=>{if(!a)return;c([]),i([]),j([]),x([]),C(null),I(""),F({airports:!0,hospitals:!0,emergencyServices:!0,schools:!0,walkability:!0,address:!0});const q=5/69,W={north:t+q,south:t-q,east:s+q,west:s-q};Fs.functions.invoke("geocode-address",{body:{lat:t,lng:s}}).then(({data:Q,error:Z})=>{!Z&&(Q!=null&&Q.address)&&I(Q.address),F(oe=>({...oe,address:!1}))}).catch(()=>{F(Q=>({...Q,address:!1}))}),Fs.functions.invoke("geointeldata-explore",{body:{action:"fetch-endpoint",params:{endpoint:"/airports",bounds:W,limit:10}}}).then(({data:Q,error:Z})=>{var oe;if(!Z&&(Q!=null&&Q.success)&&((oe=Q==null?void 0:Q.data)!=null&&oe.features)){const ce=D(Q.data.features,t,s);c(ce.slice(0,5))}F(ce=>({...ce,airports:!1}))}).catch(()=>{F(Q=>({...Q,airports:!1}))}),Fs.functions.invoke("geointeldata-explore",{body:{action:"fetch-endpoint",params:{endpoint:"/hospitals",bounds:W,limit:10}}}).then(({data:Q,error:Z})=>{var oe;if(!Z&&(Q!=null&&Q.success)&&((oe=Q==null?void 0:Q.data)!=null&&oe.features)){const ce=D(Q.data.features,t,s);i(ce.slice(0,5))}F(ce=>({...ce,hospitals:!1}))}).catch(()=>{F(Q=>({...Q,hospitals:!1}))}),Fs.functions.invoke("geointeldata-explore",{body:{action:"fetch-endpoint",params:{endpoint:"/emergency-services",bounds:W,limit:10}}}).then(({data:Q,error:Z})=>{var oe;if(!Z&&(Q!=null&&Q.success)&&((oe=Q==null?void 0:Q.data)!=null&&oe.features)){const ce=D(Q.data.features,t,s);j(ce.slice(0,5))}F(ce=>({...ce,emergencyServices:!1}))}).catch(()=>{F(Q=>({...Q,emergencyServices:!1}))}),Fs.functions.invoke("geointeldata-explore",{body:{action:"fetch-endpoint",params:{endpoint:"/sch
786ool-districts",bounds:W,limit:10}}}).then(({data:Q,error:Z})=>{var oe;if(!Z&&(Q!=null&&Q.success)&&((oe=Q==null?void 0:Q.data)!=null&&oe.features)){const ce=D(Q.data.features,t,s);x(ce.slice(0,5))}F(ce=>({...ce,schools:!1}))}).catch(()=>{F(Q=>({...Q,schools:!1}))}),Fs.functions.invoke("fetch-walkability",{body:{lat:t,lng:s}}).then(({data:Q,error:Z})=>{!Z&&(Q!=null&&Q.walkability)&&C(Q.walkability),F(oe=>({...oe,walkability:!1}))}).catch(()=>{F(Q=>({...Q,walkability:!1}))})},[t,s,a]),!a)return null;const D=(q,W,Q)=>q.map(Z=>{const oe=Z,ce=oe.properties||{},ae=oe.geometry;let ie=null,de=null;if((ae==null?void 0:ae.type)==="Point"&&Array.isArray(ae.coordinates))de=ae.coordinates[0],ie=ae.coordinates[1];else if((ae==null?void 0:ae.type)==="Polygon"&&Array.isArray(ae.coordinates)){const We=ae.coordinates[0];(We==null?void 0:We.length)>0&&(ie=We.reduce((Ee,ve)=>Ee+ve[1],0)/We.length,de=We.reduce((Ee,ve)=>Ee+ve[0],0)/We.length)}if((ie===null||de===null)&&(ie=ce.latitude||ce.lat||ce.LAT||ce.LATITUDE,de=ce.longitude||ce.lng||ce.lon||ce.LON||ce.LONGITUDE),!ie||!de)return null;const ge=Math.sqrt(Math.pow((ie-W)*69,2)+Math.pow((de-Q)*69*Math.cos(W*Math.PI/180),2));return{id:String(ce.OBJECTID||ce.id||ce.fid||Math.random().toString(36).substr(2,9)),name:String(ce.NAME||ce.name||ce.FACILITY_NAME||ce.facility_name||"Unknown"),type:String(ce.TYPE||ce.type||ce.FACILITY_TYPE||""),lat:ie,lng:de,distance:ge,properties:ce}}).filter(Z=>Z!==null).sort((Z,oe)=>(Z.distance||0)-(oe.distance||0)),X=q=>q<=5?"bg-red-500":q<=10?"bg-orange-500":q<=14?"bg-yellow-500":q<=17?"bg-lime-500":"bg-green-500",K=q=>({"car-dependent":"Car Dependent","somewhat-walkable":"Somewhat Walkable",walkable:"Walkable","very-walkable":"Very Walkable","walkers-paradise":"Walker's Paradise"})[q]||q;return z.airports||z.hospitals||z.emergencyServices||z.schools||z.walkability,e.jsxs("div",{className:"fixed bottom-4 left-4 z-[1001] w-96 max-h-[70vh] bg-background border rounded-lg shadow-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border-b bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(ji,{className:"h-4 w-4 text-primary shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"font-semibold text-sm truncate",children:"Area Intelligence"}),z.address?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading address..."}):e.jsx("p",{className:"text-xs text-muted-foreground truncate",title:P||`${t.toFixed(4)}, ${s.toFixed(4)}`,children:P||`${t.toFixed(4)}, ${s.toFixed(4)}`})]})]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0",onClick:n,children:e.jsx(ja,{className:"h-4 w-4"})})]}),e.jsx(Xc,{className:"max-h-[calc(70vh-52px)]",children:e.jsxs(Zm,{defaultValue:"overview",className:"w-full",children:[e.jsxs(mm,{className:"w-full grid grid-cols-4 h-9 p-0.5",children:[e.jsx(Bi,{value:"overview",className:"text-xs px-2",children:"Overview"}),e.jsx(Bi,{value:"transport",className:"text-xs px-2",children:"Transport"}),e.jsx(Bi,{value:"services",className:"text-xs px-2",children:"Services"}),e.jsx(Bi,{value:"walkability",className:"text-xs px-2",children:"Walk"})]}),e.jsxs($i,{value:"overview",className:"p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lb,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-medium text-sm",children:"Nearby Airports"}),z.airports&&e.jsx(Va,{className:"h-3 w-3 animate-spin"})]}),l.length>0?e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l.length," airports within 5 miles",l[0]&&e.jsxs("div",{className:"mt-1 text-foreground",children:["Nearest: ",l[0].name," (",(te=l[0].distance)==null?void 0:te.toFixed(1)," mi)"]})]}):z.airports?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:"No airports found nearby"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Eb,{className:"h-4 w-4 text-red-500"}),e.jsx("span",{className:"font-medium text-sm",children:"Hospitals"}),z.hospitals&&e.jsx(Va,{className:"h-3 w-3 animate-spin"})]}),u.length>0?e.jsxs("div",{className:"text-xs text-muted-foreground",children:[u.length," hospitals within 5 miles",u[0]&&e.jsxs("div",{className:"mt-1 text-foreground",children:["Nearest: ",u[0].name," 
786(",(J=u[0].distance)==null?void 0:J.toFixed(1)," mi)"]})]}):z.hospitals?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:"No hospitals found nearby"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zu,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"font-medium text-sm",children:"Walkability"}),z.walkability&&e.jsx(Va,{className:"h-3 w-3 animate-spin"})]}),v?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center text-white font-bold text-sm ${X(v.walkabilityIndex)}`,children:typeof v.walkabilityIndex=="number"?v.walkabilityIndex.toFixed(2):v.walkabilityIndex}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:K(v.classification)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Score 1-20"})]})]}):z.walkability?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:"No walkability data available"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ho,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{className:"font-medium text-sm",children:"Emergency Services"}),z.emergencyServices&&e.jsx(Va,{className:"h-3 w-3 animate-spin"})]}),_.length>0?e.jsxs("div",{className:"text-xs text-muted-foreground",children:[_.length," services within 5 miles"]}):z.emergencyServices?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:"No emergency services found nearby"})]})]}),e.jsx($i,{value:"transport",className:"p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Lb,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-medium text-sm",children:"Airports"}),z.airports&&e.jsx(Va,{className:"h-3 w-3 animate-spin"})]}),l.length>0?l.map(q=>{var W;return e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-muted/30 rounded text-xs",children:[e.jsx("span",{className:"text-lg",children:"✈️"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:q.name}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[q.type&&e.jsx(Mt,{variant:"outline",className:"text-[10px] px-1 py-0",children:q.type}),e.jsxs("span",{children:[(W=q.distance)==null?void 0:W.toFixed(1)," mi away"]})]})]})]},q.id)}):z.airports?null:e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No airports found within 5 miles"})]})}),e.jsxs($i,{value:"services",className:"p-3 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Eb,{className:"h-4 w-4 text-red-500"}),e.jsx("span",{className:"font-medium text-sm",children:"Hospitals"}),z.hospitals&&e.jsx(Va,{className:"h-3 w-3 animate-spin"})]}),u.length>0?e.jsx("div",{className:"space-y-2",children:u.map(q=>{var W;return e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-muted/30 rounded text-xs",children:[e.jsx("span",{className:"text-lg",children:"🏥"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:q.name}),e.jsxs("div",{className:"text-muted-foreground",children:[(W=q.distance)==null?void 0:W.toFixed(1)," mi away"]})]})]},q.id)})}):z.hospitals?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:"No hospitals found nearby"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ho,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{className:"font-medium text-sm",children:"Emergency Services"}),z.emergencyServices&&e.jsx(Va,{className:"h-3 w-3 animate-spin"})]}),_.length>0?e.jsx("div",{className:"space-y-2",children:_.map(q=>{var W;return e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-muted/30 rounded text-xs",children:[e.jsx("span",{className:"text-lg",children:"🚨"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:q.name}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[q.type&&e.jsx(Mt,{variant:"outline",className:"text-[10px] px-1 py-0",children:q.type}),e.jsxs("span",{children:[(W=q.distance)==null?void 0:W.toFixed(1)," mi away"]})]})]})]},q.id)})}):z.emergencyServices?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:"No emergency services found nearby"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(j0,{className:"h-4 w-4 text-purple-500"}),e.jsx("span",{className:"font-medium text-sm",children:"School Districts"}),z.schools&&e.jsx(Va,{className:"h-3 w-3 animate-spin"})]}),y.length>0?e.jsx("div",{className:"space-y-2",children:y.map(q=>{var W;return e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-muted/30 rounded text-xs",children:[e.jsx("span",{className:"text-lg",children:"🏫"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:q.name}),e.jsxs("div",{className:"text-muted-foreground",children:[(W=q.distance)==null?void 0:W.toFixed(1)," mi away"]})]})]},q.id)})}):z.schools?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:"No school districts found nearby"})]})]}),e.jsx($i,{value:"walkability",className:"p-3",children:z.walkability?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Va,{className:"h-5 w-5 animate-spin"})}):v?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-4",children:[e.jsx("div",{className:`w-20 h-20 rounded-full flex items-center justify-center text-white text-xl font-bold ${X(v.walkabilityIndex)}`,children:typeof v.walkabilityIndex=="number"?v.walkabilityIndex.toFixed(2):v.walkabilityIndex}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-lg",children:K(v.classification)}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Walkability Score (1-20)"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Transit Access"}),e.jsx("span",{className:"font-medium",children:((H=v.transitAccess)==null?void 0:H.toFixed(2))||"N/A"})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Street Connectivity"}),e.jsx("span",{className:"font-medium",children:((O=v.streetConnectivity)==null?void 0:O.toFixed(2))||"N/A"})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:e.jsx("p",{children:"Source: EPA Smart Location Database"})})]}):e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No walkability data available for this location"})})]})}),e.jsx("div",{className:"p-2 border-t bg-muted/30 text-[10px] text-muted-foreground text-center",children:"Data powered by GeoIntelData.ai & EPA"})]})}const uV=[{label:"Street",zoom:18},{label:"Hood",zoom:15},{label:"City",zoom:12}],hV=({bearing:t,onResetBearing:s,onRotate:n,onZoomIn:a,onZoomOut:l,onSetZoom:c,currentZoom:u,isAdmin:i,onAddDevelopment:_,onAddExistingProduct:j,is3DMode:y,onToggle3DMode:x,isParcelLookupMode:v,onToggleParcelLo
786okup:C,onParcelSearch:P,onShowControls:I,onAIRecordCreated:z,onNavigateToRecord:F,isMeasuring:D,onStartMeasuring:X,isDrawingActive:K,onStartDrawing:te,onOpenPhotoOverlay:J,className:H})=>{const O=o_(),q=YM(),[W,Q]=k.useState(!1),[Z,oe]=k.useState(!1),[ce,ae]=k.useState(!1),[ie,de]=k.useState(()=>{const _t=localStorage.getItem("map-compass-collapsed");return _t!==null?_t==="true":!1}),ge=k.useRef(null),We=k.useRef(!1),Ee=k.useRef(0),ve=k.useRef(!1);k.useEffect(()=>{!ve.current&&O&&(localStorage.getItem("map-compass-collapsed")===null&&de(!0),ve.current=!0)},[O]);const we=(t%360+360)%360,Ze=Math.abs(t)>.5,ke=()=>{const _t=!ie;de(_t),localStorage.setItem("map-compass-collapsed",String(_t))},ze=k.useCallback((_t,He)=>{if(!ge.current)return 0;const as=ge.current.getBoundingClientRect(),vt=as.left+as.width/2,Xe=as.top+as.height/2;return Math.atan2(He-Xe,_t-vt)*(180/Math.PI)},[]),Ke=k.useCallback(_t=>{_t.preventDefault(),We.current=!0,Ee.current=ze(_t.clientX,_t.clientY),_t.target.setPointerCapture(_t.pointerId)},[ze]),dt=k.useCallback(_t=>{if(!We.current||!n)return;const He=ze(_t.clientX,_t.clientY),as=He-Ee.current;let vt=as;as>180&&(vt=as-360),as<-180&&(vt=as+360),n(-vt),Ee.current=He},[ze,n]),Re=k.useCallback(_t=>{We.current=!1,_t.target.releasePointerCapture(_t.pointerId)},[]),qt=O?"w-10 h-10":q?"w-12 h-12":"w-14 h-14",ft=O?"h-5":q?"h-6":"h-7",Fe=O?"h-4":q?"h-5":"h-6",fe=O?"p-1.5":q?"p-2":"p-2.5",Qe=O?"text-[10px]":"text-xs",ht=O?"h-3 w-3":"h-3.5 w-3.5";return ie?e.jsx(hm,{children:e.jsxs("div",{className:fs("flex items-center gap-2 bg-card/95 backdrop-blur-sm rounded-xl shadow-lg border border-border/50",O?"p-1.5":"p-2",H),children:[e.jsx("div",{className:fs("rounded-full bg-gradient-to-b from-background to-muted border border-border/70 flex items-center justify-center cursor-pointer",O?"w-6 h-6":"w-8 h-8"),onClick:ke,style:{transform:`rotate(${-t}deg)`},children:e.jsx("div",{className:fs("w-0 h-0 border-l-transparent border-r-transparent border-b-red-500",O?"border-l-[3px] border-r-[3px] border-b-[8px]":"border-l-[4px] border-r-[4px] border-b-[10px]")})}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"sm",className:fs(O?"h-5 w-5":"h-6 w-6","p-0"),onClick:ke,children:e.jsx(Oa,{className:O?"h-3 w-3":"h-4 w-4"})})}),e.jsx(or,{side:"bottom",children:e.jsx("p",{children:"Expand controls"})})]})]})}):e.jsx(hm,{children:e.jsxs("div",{className:fs("flex items-center bg-card/95 backdrop-blur-sm rounded-xl shadow-lg border border-border/50","transition-all duration-200",fe,"gap-3",Ze&&"ring-2 ring-primary/30",H),children:[e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"sm",className:fs("text-muted-foreground hover:text-foreground",Fe,"px-1"),onClick:ke,children:e.jsx(Cc,{className:O?"h-2.5 w-2.5":"h-3 w-3"})})}),e.jsx(or,{side:"bottom",children:e.jsx("p",{children:"Collapse controls"})})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx("button",{ref:ge,onPointerDown:Ke,onPointerMove:dt,onPointerUp:Re,onPointerCancel:Re,onDoubleClick:s,className:fs("relative rounded-full bg-gradient-to-b from-background to-muted border-2 border-border/70","hover:border-primary/50 cursor-grab active:cursor-grabbing","shadow-inner transition-[border-color] duration-200 touch-none select-none",qt),children:e.jsxs("div",{className:"absolute inset-0 rounded-full pointer-events-none",style:{transform:`rotate(${-t}deg)`},children:[e.jsx("span",{className:fs("absolute top-0.5 left-1/2 -translate-x-1/2 font-bold text-red-500",O?"text-[7px]":q?"text-[8px]":"text-[9px]"),children:"N"}),e.jsx("span",{className:fs("absolute top-1/2 right-0.5 -translate-y-1/2 font-medium text-muted-foreground",O?"text-[6px]":q?"text-[7px]":"text-[8px]"),children:"E"}),e.jsx("span",{className:fs("absolute bottom-0.5 left-1/2 -translate-x-1/2 font-medium text-muted-foreground",O?"text-[6px]":q?"text-[7px]":"text-[8px]"),children:"S"}),e.jsx("span",{className:fs("absolute top-1/2 left-0.5 -translate-y-1/2 font-medium text-muted-foreground",O?"text-[6px]":q?"text-[7px]":"text-[8px]"),children:"W"}),e.jsx("div",{className:fs("absolute left-1/2 -translate-x-1/2 w-0 h-0 border-l-transparent border-r-transparent border-b-red-500 drop-shadow-sm",O?"top-1.5 border-l-[3px] border-r-[3px] border-b-[10px]":q?"top-2 border-l-[4px] border-r-[4px] border-b-[12px]":"top-2.5 border-l-[5px] border-r-[5px] border-b-[16px]")}),e.jsx("div",{className:fs("absolute left-1/2 -translate-x-1/2 w-0 h-0 border-l-transparent border-r-transparent border-t-muted-foreground
786/40",O?"bottom-1.5 border-l-[3px] border-r-[3px] border-t-[10px]":q?"bottom-2 border-l-[4px] border-r-[4px] border-t-[12px]":"bottom-2.5 border-l-[5px] border-r-[5px] border-t-[16px]")}),e.jsx("div",{className:fs("absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-foreground shadow-md",O?"w-1.5 h-1.5":q?"w-2 h-2":"w-2.5 h-2.5")})]})})}),e.jsx(or,{side:"bottom",className:"text-xs",children:e.jsx("p",{children:"Drag to rotate • Double-click to reset"})})]}),e.jsxs("div",{className:fs("font-mono font-medium px-1.5 py-0.5 rounded-md",Qe,Ze?"bg-primary/10 text-primary":"text-muted-foreground"),children:[we.toFixed(0),"°"]}),Ze&&e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"sm",className:fs("gap-1 hover:bg-primary/10",Fe,Qe),onClick:s,children:e.jsx(mh,{className:O?"h-2.5 w-2.5":"h-3 w-3"})})}),e.jsx(or,{side:"bottom",children:e.jsx("p",{children:"Reset to north"})})]}),e.jsx("div",{className:"h-6 w-px bg-border/50"}),(a||l)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"outline",size:"sm",className:fs(ft,"px-2"),onClick:l,children:e.jsx(Om,{className:O?"h-3 w-3":"h-4 w-4"})})}),e.jsx(or,{side:"bottom",children:e.jsx("p",{children:"Zoom out"})})]}),u!==void 0&&e.jsxs("div",{className:fs("font-mono text-muted-foreground min-w-8 text-center",Qe),children:["z",u.toFixed(0)]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"outline",size:"sm",className:fs(ft,"px-2"),onClick:a,children:e.jsx(tr,{className:O?"h-3 w-3":"h-4 w-4"})})}),e.jsx(or,{side:"bottom",children:e.jsx("p",{children:"Zoom in"})})]}),c&&!O&&e.jsx("div",{className:"flex gap-0.5 ml-1",children:uV.map(_t=>e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:u!==void 0&&Math.abs(u-_t.zoom)<.5?"default":"ghost",size:"sm",className:fs("px-2",Fe,Qe),onClick:()=>c(_t.zoom),children:_t.label})}),e.jsx(or,{side:"bottom",children:e.jsxs("p",{children:["z",_t.zoom]})})]},_t.zoom))})]}),x&&e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:y?"default":"outline",size:"sm",className:fs("font-medium px-3",ft,Qe),onClick:x,children:y?"2D":"3D"})}),e.jsx(or,{side:"bottom",children:e.jsxs("p",{children:["Toggle ",y?"2D":"3D"," view"]})})]}),C&&e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsxs(Le,{variant:v?"default":"outline",size:"sm",className:fs("font-medium gap-1 px-3",ft,Qe,v&&"bg-emerald-600 hover:bg-emerald-700"),onClick:C,children:[e.jsx(Mh,{className:ht}),!O&&"Parcels"]})}),e.jsx(or,{side:"bottom",children:e.jsx("p",{children:v?"Exit parcel lookup":"Click map to get parcel details"})})]}),i&&_&&j&&e.jsx(e.Fragment,{children:ce?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(Le,{variant:"ghost",size:"sm",className:fs("gap-1 bg-amber-500/10 hover:bg-amber-500/20 text-amber-600 px-2",ft,Qe),onClick:()=>{_(),ae(!1)},children:[e.jsx(Ci,{className:ht}),!O&&"Dev"]}),e.jsxs(Le,{variant:"ghost",size:"sm",className:fs("gap-1 bg-cyan-500/10 hover:bg-cyan-500/20 text-cyan-600 px-2",ft,Qe),onClick:()=>{j(),ae(!1)},children:[e.jsx(Sc,{className:ht}),!O&&"Site"]}),e.jsx(Le,{variant:"ghost",size:"sm",className:fs("text-muted-foreground px-1",Fe),onClick:()=>ae(!1),children:e.jsx(ja,{className:"h-3 w-3"})})]}):e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"outline",size:"sm",className:fs("gap-1 bg-amber-500/10 hover:bg-amber-500/20 border-amber-500/30 px-3",ft,Qe),onClick:()=>ae(!0),children:e.jsx(tr,{className:ht})})}),e.jsx(or,{side:"bottom",children:e.jsx("p",{children:"Add property"})})]})}),(X||i&&te)&&!D&&!K&&e.jsxs("div",{className:"flex items-center gap-1",children:[X&&e.jsx(e.Fragment,{children:W?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Le,{variant:"ghost",size:"sm",className:fs("bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 px-2",Fe,Qe),onClick:()=>{X("distance"),Q(!1)},children:"Dist"}),e.jsx(Le,{variant:"ghost",size:"sm",className:fs("bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 px-2",Fe,Qe),onClick:()=>{X("area"),Q(!1)},children:"Area"}),e.jsx(Le,{variant:"ghost",size:"sm",className:fs("text-muted-foreground px-1","h-5"),onClick:()=>Q(!1),children:e.jsx(ja,{className:"h-3 w-3"})})]}):e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"outline",size:"sm",className:fs("gap-1 bg-emerald-500/10 hover:bg-emerald-500/20 border-emerald-500/30 px-2",ft,Qe),onClick:()=>Q(!0),children:e.jsx(Fo,{className:ht})})}),e.jsx(or,{side:"bottom",children:e.jsx("p",{children:"Measure"})})]})}),i&&te&&e.jsx(e.Fragment,{children:Z?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Le,{variant:"ghost",size:"sm",className:fs("bg-violet-500/10 hover:bg-violet-500/20 text-violet-600 px-2",Fe,Qe),onClick:()=>{te("polygon"),oe(!1)},children:"Poly"}),e.jsx(Le,{variant:"ghost",size:"sm",className:fs("bg-violet-500/10 hover:bg-violet-500/20 text-violet-600 px-2",Fe,Qe),onClick:()=>{te("polyline"),oe(!1)},children:"Line"}),e.jsx(Le,{variant:"ghost",size:"sm",className:fs("bg-violet-500/10 hover:bg-violet-500/20 text-violet-600 px-2",Fe,Qe),onClick:()=>{te("marker"),oe(!1)},children:"Pin"}),J&&e.jsx(Le,{variant:"ghost",size:"sm",className:fs("bg-amber-500/10 hover:bg-amber-500/20 text-amber-600 px-2",Fe,Qe),onClick:()=>{J(),oe(!1)},children:e.jsx(k0,{className:"w-3 h-3"})}),e.jsx(Le,{variant:"ghost",size:"sm",className:fs("text-muted-foreground px-1","h-5"),onClick:()=>oe(!1),children:e.jsx(ja,{className:"h-3 w-3"})})]}):e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"outline",size:"sm",className:fs("gap-1 bg-violet-500/10 hover:bg-violet-500/20 border-violet-500/30 px-2",ft,Qe),onClick:()=>oe(!0),children:e.jsx(kp,{className:ht})})}),e.jsx(or,{side:"bottom",children:e.jsx("p",{children:"Draw"})})]})})]}),I&&e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Le,{variant:"outline",size:"sm",className:fs("gap-1 px-2",ft,Qe),onClick:I,children:e.jsx(Dh,{className:ht})})}),e.jsx(or,{side:"bottom",children:e.jsx("p",{children:"Controls"})})]})]})})},mV=()=>({...fu({queryKey:["cached-parcels"],queryFn:async()=>{const{data:s,error:n}=await Fs.from("parcel_cache").select("*").order("created_at",{ascending:!1});if(n)throw n;return s}})}),TT=()=>fu({queryKey:["cached-parcel-count"],queryFn:async()=>{const{count:t,error:s}=await Fs.from("parcel_cache").select("*",{count:"exact",head:!0});if(s)throw s;return t??0},staleTime:3e4}),X2="map-view-presets",fV=({open:t,onOpenChange:s,isClusteringEnabled:n,onClusteringToggle:a,clusterRadius:l,onClusterRadiusChange:c,logoSize:u,onLogoSizeChange:i,logoShape:_,onLogoShapeChange:j,showTenantLogos:y,onTenantLogosToggle:x,showCrmLogos:v,onCrmLogosToggle:C,iconSize:P,onIconSizeChange:I,popupDensity:z="comfortable",onPopupDensityChange:F,isMeasuring:D=!1,mapStyle:X="light",currentCenter:K,
786currentZoom:te,onApplyPreset:J,preloadMunicipalities:H=!0,onPreloadMunicipalitiesToggle:O,municipalityCount:q=0,showParcelLayer:W=!1,onParcelLayerToggle:Q,isParcelLayerLocked:Z=!1,cachedParcelCount:oe,parcelLimit:ce=500,onLayerOrderChange:ae,showParcelDimensions:ie=!1,onParcelDimensionsToggle:de})=>{const[ge,We]=k.useState([]),[Ee,ve]=k.useState(!1),[we,Ze]=k.useState(""),{data:ke=0}=TT(),ze=oe??ke;k.useEffect(()=>{const Fe=localStorage.getItem(X2);if(Fe)try{We(JSON.parse(Fe))}catch{console.error("Failed to parse saved presets")}},[t]);const Ke=Fe=>{We(Fe),localStorage.setItem(X2,JSON.stringify(Fe))},dt=()=>{if(!we.trim()){Ve.error("Please enter a preset name");return}if(!K||!te){Ve.error("Unable to save current view");return}const Fe={id:Date.now().toString(),name:we.trim(),center:K,zoom:te,isSatellite:X==="satellite",isClusteringEnabled:n,clusterRadius:l};Ke([...ge,Fe]),Ze(""),ve(!1),Ve.success(`Saved preset "${Fe.name}"`)},Re=Fe=>{const fe=ge.find(Qe=>Qe.id===Fe);Ke(ge.filter(Qe=>Qe.id!==Fe)),Ve.success(`Deleted preset "${fe==null?void 0:fe.name}"`)},qt=Fe=>{Fe.isClusteringEnabled!==n&&a(),Fe.clusterRadius!==l&&c(Fe.clusterRadius),J==null||J(Fe),Ve.success(`Applied preset "${Fe.name}"`),s(!1)},ft=({children:Fe})=>e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(H1,{className:"w-3 h-3 text-muted-foreground cursor-help ml-1"})}),e.jsx(or,{side:"right",className:"max-w-[200px] text-xs",children:Fe})]});return e.jsx(dd,{open:t,onOpenChange:s,children:e.jsxs(ud,{className:"max-w-md max-h-[85vh] overflow-y-auto",children:[e.jsx(Gd,{children:e.jsxs(Hd,{className:"flex items-center gap-2",children:[e.jsx(Dh,{className:"w-5 h-5"}),"Map Controls"]})}),e.jsx(hm,{delayDuration:300,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("h3",{className:"text-xs font-medium",children:"Clustering"}),e.jsx(ft,{children:"Group nearby markers together when zoomed out for better readability."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Le,{variant:n?"default":"outline",size:"sm",onClick:a,className:"flex-1",children:[e.jsx(dm,{className:"w-4 h-4 mr-2"}),"Grouped"]}),e.jsxs(Le,{variant:n?"outline":"default",size:"sm",onClick:a,className:"flex-1",children:[e.jsx(E1,{className:"w-4 h-4 mr-2"}),"Individual"]})]}),n&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Cluster Radius"}),e.jsx("div",{className:"flex rounded-md overflow-hidden border border-border",children:["tight","medium","loose"].map(Fe=>e.jsx("button",{onClick:()=>c(Fe),className:fs("flex-1 px-3 py-2 text-xs font-medium capitalize transition-colors",l===Fe?"bg-primary text-primary-foreground":"bg-card text-muted-foreground hover:bg-secondary"),children:Fe},Fe))})]})]}),e.jsxs("div",{className:"space-y-3 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("h3",{className:"text-xs font-medium",children:"Logo Display"}),e.jsx(ft,{children:"Control how logos appear on map markers."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Le,{variant:y?"default":"outline",size:"sm",onClick:x,className:"flex-1",children:[e.jsx(Zd,{className:"w-4 h-4 mr-2"}),y?"Tenant Logos On":"Tenant Logos Off"]}),e.jsxs(Le,{variant:v?"default":"outline",size:"sm",onClick:C,className:"flex-1",children:[e.jsx(Zd,{className:"w-4 h-4 mr-2"}),v?"CRM Logos On":"CRM Logos Off"]})]}),y&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Logo Size"}),e.jsx("div",{className:"flex rounded-md overflow-hidden border border-border",children:["x-small","small","medium","large","xl"].map(Fe=>e.jsx("button",{onClick:()=>i(Fe),className:fs("flex-1 px-2 py-2 text-xs font-medium capitalize transition-colors",u===Fe?"bg-primary text-primary-foreground":"bg-card text-muted-foreground hover:bg-secondary"),children:Fe==="x-small"?"XS":Fe==="xl"?"XL":Fe.charAt(0).toUpperCase()},Fe))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Logo Shape"}),e.jsx("div",{className:"flex rounded-md overflow-hidden border border-border",children:["rounded","circle"].map(Fe=>e.jsx("button",{onClick:()=>j(Fe),className:fs("flex-1 px-3 py-2 text-xs font-medium capitalize transition-colors",_===Fe?"bg-primary text-primary-foreground":"bg-card text-muted-foreground hover:bg-secondary"),children:Fe},Fe))})]})]})]})]}),e.jsxs("div",{className:"space-y-3 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("h3",{className:"text-xs font-medium",children:"Icon Size"}),e.jsx(ft,{children:"Size of property type icons when logos are hidden."})]}),e.jsx("div",{className:"flex rounded-md overflow-hidden border border-border",children:["small","medium","large"].map(Fe=>e.jsx("button",{onClick:()=>I(Fe),className:fs("flex-1 px-3 py-2 text-xs font-medium capitalize transition-colors",P===Fe?"bg-primary text-primary-foreground":"bg-card text-muted-foreground hover:bg-secondary"),children:Fe},Fe))})]}),e.jsxs("div",{className:"space-y-3 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("h3",{className:"text-xs font-medium",children:"Popup Density"}),e.jsx(ft,{children:"Adjust popup size for easier side-by-side comparison."})]}),e.jsxs("div",{className:"flex rounded-md overflow-hidden border border-border",children:[e.jsx("button",{onClick:()=>F==null?void 0:F("compact"),className:fs("flex-1 px-3 py-2 text-xs font-medium transition-colors",z==="compact"?"bg-primary text-primary-foreground":"bg-card text-muted-foreground hover:bg-secondary"),children:"Compact"}),e.jsx("button",{onClick:()=>F==null?void 0:F("comfortable"),className:fs("flex-1 px-3 py-2 text-xs font-medium transition-colors",z==="comfortable"?"bg-primary text-primary-foreground":"bg-card text-muted-foreground hover:bg-secondary"),children:"Comfortable"})]})]}),Q&&e.jsxs("div",{className:"space-y-3 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx(Mh,{className:"w-4 h-4 mr-2 text-muted-foreground"}),e.jsx("h3",{className:"text-xs font-medium",children:"Parcel Layer"}),e.jsx(ft,{children:"Show parcel boundaries on the map. Click on any parcel to view details."}),Z&&e.jsxs(Mt,{variant:"outline",className:"ml-2 text-amber-500 border-amber-500/50",children:[e.jsx(jc,{className:"w-3 h-3 mr-1"}),"Locked"]})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(Le,{variant:W?"default":"outline",size:"sm",onClick:Q,disabled:Z,className:fs("flex-1",W&&"bg-teal-600 hover:bg-teal-700"),children:[e.jsx(Mh,{className:"w-4 h-4 mr-2"}),W?"Parcels On":"Parcels Off"]})}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Fu,{className:"w-3 h-3"}
786),ze.toLocaleString()," cached"]}),e.jsxs("span",{children:["Limit: ",ce.toLocaleString()]})]}),W&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Zoom in to see parcel boundaries (zoom 15+). Click to lookup parcel details."}),de&&e.jsxs("div",{className:"pt-2",children:[e.jsxs(Le,{variant:ie?"default":"outline",size:"sm",onClick:de,className:fs("w-full",ie&&"bg-teal-600 hover:bg-teal-700"),children:[e.jsx(Fo,{className:"w-4 h-4 mr-2"}),ie?"Dimensions On":"Dimensions Off"]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Press ",e.jsx("kbd",{className:"px-1 py-0.5 bg-secondary rounded text-[10px]",children:"D"})," to toggle • Zoom 16+"]})]})]})]}),O&&e.jsxs("div",{className:"space-y-3 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx(dm,{className:"w-4 h-4 mr-2 text-muted-foreground"}),e.jsx("h3",{className:"text-xs font-medium",children:"Municipality Preload"}),e.jsx(ft,{children:"Preload all municipality boundaries in the background for smoother panning."})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(Le,{variant:H?"default":"outline",size:"sm",onClick:O,className:"flex-1",children:[e.jsx(dm,{className:"w-4 h-4 mr-2"}),H?"Enabled":"Disabled"]})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[q>0?`${q} municipalit${q!==1?"ies":"y"} loaded`:"No municipalities loaded yet",H?" • Background preload enabled":" • Only visible area loaded"]})]}),e.jsxs("div",{className:"space-y-3 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx(Mb,{className:"w-4 h-4 mr-2 text-muted-foreground"}),e.jsx("h3",{className:"text-xs font-medium",children:"View Presets"}),e.jsx(ft,{children:"Save and restore map view configurations including location, zoom, and settings."})]}),ge.length>0&&e.jsx("div",{className:"space-y-1",children:ge.map(Fe=>e.jsxs("div",{className:"flex items-center gap-2 group",children:[e.jsxs("button",{onClick:()=>qt(Fe),className:"flex-1 flex items-center gap-2 px-3 py-2 rounded-md text-xs hover:bg-secondary transition-colors text-left",children:[e.jsx(Mb,{className:"w-3 h-3 text-primary"}),e.jsx("span",{className:"truncate",children:Fe.name}),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:["z",Fe.zoom]})]}),e.jsx("button",{onClick:()=>Re(Fe.id),className:"p-1.5 rounded hover:bg-destructive/20 text-muted-foreground hover:text-destructive transition-colors opacity-0 group-hover:opacity-100",children:e.jsx(wr,{className:"w-3.5 h-3.5"})})]},Fe.id))}),Ee?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(be,{value:we,onChange:Fe=>Ze(Fe.target.value),placeholder:"Preset name...",className:"h-8 text-xs",onKeyDown:Fe=>{Fe.key==="Enter"&&dt(),Fe.key==="Escape"&&ve(!1)},autoFocus:!0}),e.jsx(Le,{size:"sm",onClick:dt,className:"h-8",children:"Save"}),e.jsx(Le,{size:"sm",variant:"ghost",onClick:()=>ve(!1),className:"h-8 px-2",children:"✕"})]}):e.jsxs(Le,{variant:"outline",size:"sm",onClick:()=>ve(!0),className:"w-full",children:[e.jsx(tr,{className:"w-4 h-4 mr-2"}),"Save Current View"]})]})]})})]})})},pV=({open:t,onOpenChange:s})=>{const n=[{label:"Completed",color:"hsl(142 76% 36%)",description:"Project is finished and operational"},{label:"Under Construction",color:"hsl(38 92% 50%)",description:"Active construction in progress"},{label:"Approved",color:"hsl(280 65% 60%)",description:"Approved but not yet started"},{label:"Planned",color:"hsl(217 91% 60%)",description:"In planning/proposal stage"}],a=[{label:"New Development",color:"#f59e0b",description:"Upcoming or new construction projects"},{label:"Existing Site",color:"#06b6d4",description:"Currently operating properties"}],l=[{icon:qd,label:"Single Family",color:"text-amber-600"},{icon:yl,label:"Townhomes",color:"text-orange-600"},{icon:Ci,label:"Apartments",color:"text-blue-600"},{icon:Ig,label:"Industrial",color:"text-slate-600"},{icon:fp,label:"Retail",color:"text-pink-600"},{icon:uh,label:"Mixed-Use",color:"text-purple-600"},{icon:E0,label:"Medical",color:"text-red-600"}],c=[{type:"line",color:"#10b981",label:"Distance Measurement",description:"Measured paths on the map"},{type:"polygon",color:"#10b981",label:"Area Measurement",description:"Measured regions"},{type:"polygon",color:"#8b5cf6",label:"Custom Overlay",description:"User-drawn shapes and annotations"},{type:"polygon",color:"#22c55e",label:"Parcel Boundary",description:"Property parcel outlines"}],u=[{type:"polygon",color:"#6366f1",label:"States",description:"State boundaries"},{type:"line",color:"#0891b2",label:"Counties",description:"County boundaries"},{type:"line",color:"#2d6a4f",label:"Townships",description:"Township boundaries"},{type:"line",color:"#7b2cbf",label:"Census Tracts",description:"Census tract boundaries"},{type:"polygon",color:"#bc6c25",label:"School Districts",description:"School district boundaries"}],i=[{type:"line",color:"#dc2626",label:"Primary Roads",description:"Highways and major routes"},{type:"line",color:"#ea580c",label:"Secondary Roads",description:"State and county roads"},{type:"line",color:"#64748b",label:"Railroads",description:"Rail lines"},{type:"line",color:"#eab308",label:"Transmission Lines",description:"Power transmission infrastru
786cture"}];return e.jsx(dd,{open:t,onOpenChange:s,children:e.jsxs(ud,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(Gd,{children:e.jsxs(Hd,{className:"flex items-center gap-2",children:[e.jsx(hh,{className:"w-5 h-5"}),"Map Legend"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Marker Types"}),e.jsx("div",{className:"space-y-2",children:a.map(_=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow-sm mt-0.5 flex-shrink-0",style:{backgroundColor:_.color}}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:_.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:_.description})]})]},_.label))})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Property Types"}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:l.map(_=>{const j=_.icon;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{className:`w-4 h-4 ${_.color}`}),e.jsx("span",{className:"text-sm",children:_.label})]},_.label)})})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Development Status"}),e.jsx("div",{className:"space-y-2",children:n.map(_=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-4 h-4 rounded-sm mt-0.5 flex-shrink-0",style:{backgroundColor:_.color}}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:_.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:_.description})]})]},_.label))})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Overlays & Measurements"}),e.jsx("div",{className:"space-y-2",children:c.map(_=>e.jsxs("div",{className:"flex items-start gap-3",children:[_.type==="line"?e.jsx("div",{className:"w-5 h-0.5 rounded-full mt-2 flex-shrink-0",style:{backgroundColor:_.color}}):e.jsx("div",{className:"w-4 h-4 rounded-sm border border-white/50 mt-0.5 flex-shrink-0",style:{backgroundColor:_.color,opacity:.6}}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:_.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:_.description})]})]},_.label))})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Administrative Boundaries"}),e.jsx("div",{className:"space-y-2",children:u.map(_=>e.jsxs("div",{className:"flex items-start gap-3",children:[_.type==="line"?e.jsx("div",{className:"w-5 h-0.5 rounded-full mt-2 flex-shrink-0",style:{backgroundColor:_.color}}):e.jsx("div",{className:"w-4 h-4 rounded-sm border border-white/50 mt-0.5 flex-shrink-0",style:{backgroundColor:_.color,opacity:.4}}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:_.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:_.description})]})]},_.label))})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Infrastructure"}),e.jsx("div",{className:"space-y-2",children:i.map(_=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-5 h-0.5 rounded-full mt-2 flex-shrink-0",style:{backgroundColor:_.color}}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:_.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:_.description})]})]},_.label))})]})]})]})})},ic=[{date:"2014-02-20",label:"Feb 2014",timeId:10},{date:"2015-01-13",label:"Jan 2015",timeId:1090},{date:"2016-01-13",label:"Jan 2016",timeId:3515},{date:"2017-01-11",label:"Jan 2017",timeId:577},{date:"2018-01-08",label:"Jan 2018",timeId:13161},{date:"2019-01-09",label:"Jan 2019",timeId:6036},{date:"2020-01-08",label:"Jan 2020",timeId:23001},{date:"2021-01-13",label:"Jan 2021",timeId:1049},{date:"2022-01-12",label:"Jan 2022",timeId:42663},{date:"2023-01-11",label:"Jan 2023",timeId:11475},{date:"2024-01-10",label:"Jan 2024",timeId:54363}],gV=({onVersionChange:t,isActive:s,onClose:n,isLoading:a=!1,comparisonMode:l=!1,onComparisonModeChange:c,onComparisonVersionChange:u,comparisonPosition:i=50,onComparisonPositionChange:_})=>{const[j,y]=k.useState(ic.length-1),[x,v]=k.useState(!1),[C,P]=k.useState(1500),I=k.useRef(null),[z,F]=k.useState(0),[D,X]=k.useState(ic.length-1),K=k.useCallback(ce=>{const ae=ic[ce];t(ae.timeId,ae.label)},[t]);k.useEffect(()=>{if(l&&u){const ce=ic[z],ae=ic[D];u(ce.timeId,ae.timeId,ce.label,ae.label)}},[l,z,D,u]),k.useEffect(()=>(x&&!l?I.current=setInterval(()=>{y(ce=>(ce+1)%ic.length)},C):I.current&&(clearInterval(I.current),I.current=null),()=>
786{I.current&&clearInterval(I.current)}),[x,C,l]),k.useEffect(()=>{s&&!l&&K(j)},[j,s,K,l]);const te=ce=>{y(ce[0]),v(!1)},J=()=>{v(!1),y(ce=>Math.max(0,ce-1))},H=()=>{v(!1),y(ce=>Math.min(ic.length-1,ce+1))},O=()=>{v(!x)},q=ce=>{v(!1),c==null||c(ce)},W=ic[j],Q=new Date(W.date).getFullYear(),Z=ic[z],oe=ic[D];return s?e.jsxs("div",{className:"absolute bottom-24 left-1/2 -translate-x-1/2 z-[1000] bg-background border border-border rounded-xl shadow-xl p-4 min-w-[400px] max-w-[90vw]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bg,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Satellite Timeline"}),a&&e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(Va,{className:"w-3.5 h-3.5 animate-spin"}),e.jsx("span",{className:"text-xs",children:"Loading tiles..."})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[c&&e.jsxs("div",{className:"flex items-center gap-2 mr-2 pr-2 border-r border-border",children:[e.jsx(PS,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs text-muted-foreground",children:"Compare"}),e.jsx(kt,{checked:l,onCheckedChange:q})]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:n,children:e.jsx(ja,{className:"w-4 h-4"})})]})]}),l?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 bg-blue-500/10 px-3 py-1.5 rounded-full",children:[e.jsx(kf,{className:"w-3.5 h-3.5 text-blue-500"}),e.jsx("span",{className:"text-lg font-bold text-blue-500",children:new Date(Z.date).getFullYear()}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Left"})]})}),e.jsx("div",{className:"text-muted-foreground text-sm",children:"vs"}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 bg-emerald-500/10 px-3 py-1.5 rounded-full",children:[e.jsx(kf,{className:"w-3.5 h-3.5 text-emerald-500"}),e.jsx("span",{className:"text-lg font-bold text-emerald-500",children:new Date(oe.date).getFullYear()}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Right"})]})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"Left Side (Before)"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Z.label})]}),e.jsx(Ca,{value:[z],onValueChange:ce=>F(Math.min(ce[0],D-1)),min:0,max:ic.length-2,step:1,className:"w-full"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-emerald-500 font-medium",children:"Right Side (After)"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:oe.label})]}),e.jsx(Ca,{value:[D],onValueChange:ce=>X(Math.max(ce[0],z+1)),min:1,max:ic.length-1,step:1,className:"w-full"})]}),_&&e.jsxs("div",{className:"space-y-1 pt-2 border-t border-border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Swipe Position"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[i,"%"]})]}),e.jsx(Ca,{value:[i],onValueChange:ce=>_(ce[0]),min:0,max:100,step:1,className:"w-full"})]}),e.jsx("p",{className:"text-[10px] text-center text-muted-foreground",children:"Drag the slider on the map to compare satellite imagery between years"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-center mb-4",children:e.jsxs("div",{className:"flex items-center gap-2 bg-primary/10 px-4 py-2 rounded-full",children:[e.jsx(kf,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-xl font-bold text-primary",children:Q}),e.jsx("span",{className:"text-sm text-muted-foreground",children:W.label}),a&&e.jsx(Va,{className:"w-4 h-4 animate-spin text-primary"})]})}),e.jsxs("div",{className:"mb-4 px-2",children:[e.jsx(Ca,{value:[j],onValueChange:te,min:0,max:ic.length-1,step:1,className:"w-full"}),e.jsxs("div",{className:"flex justify-between mt-2",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ic[0].label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ic[ic.length-1].label})]})]}),e.jsx("div",{className:"flex justify-between px-2 mb-4",children:ic.filter((ce,ae)=>ae%2===0).map(ce=>e.jsx("button",{onClick:()=>{v(!1),y(ic.findIndex(ae=>ae.timeId===ce.timeId))},className:fs("text-[9px] px-1.5 py-0.5 rounded transition-colors",W.timeId===ce.timeId?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"),children:new Date(ce.date).getFullYear()},ce.timeId))}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(Le,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:J,disabled:j===0||a,children:e.jsx(eS,{className:"w-4 h-4"})}),e.jsx(Le,{variant:x?"secondary":"default",size:"icon",className:"h-10 w-10",onClick:O,disabled:a,children:x?e.jsx(a5,{className:"w-5 h-5"}):e.jsx(VC,{className:"w-5 h-5 ml-0.5"})}),e.jsx(Le,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:H,disabled:j===ic.length-1||a,children:e.jsx(Ao,{className:"w-4 h-4"})}),e.jsxs("div",{className:"ml-4 flex items-center gap-2 border-l pl-4",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Speed:"}),e.jsx("div",{className:"flex gap-1",children:[{label:"0.5x",value:3e3},{label:"1x",value:1500},{label:"2x",value:750}].map(ce=>e.jsx("button",{onClick:()=>P(ce.value),className:fs("text-[10px] px-2 py-0.5 rounded transition-colors",C===ce.value?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-muted/80"),children:ce.label},ce.label))})]})]}),e.jsx("p",{className:"text-[10px] text-center text-muted-foreground mt-3",children:"View historical satellite imagery from 2014 to present"})]})]}):null},og=ic,xV=()=>{const[t,s]=k.useState(null),[n,a]=k.useState(!1),[l,c]=k.useState(null),u=k.useCallback(async(_,j)=>{var y;a(!0),c(null);try{const{data:x,error:v}=await Fs.functions.invoke("fetch-zoneomics-data",{body:{lat:_,lng:j,output_fields:"plu,controls,geom"}});if(v)throw new Error(v.message);if(!(x!=null&&x.success)||!((y=x==null?void 0:x.data)!=null&&y.zone_details))return console.warn("No zoning data available for this location"),s(null),null;const C=x.data.zone_details,P=x.data.permitted_land_uses,I=x.data.controls,z=x.data.boundary||x.data.geom||(C==null?void 0:C.boundary)||null,F={zone_code:C.zone_code,zone_name:C.zone_name,zone_type:C.zone_type,zone_sub_type:C.zone_sub_type,zone_guide:C.zone_guide,link:C.link,boundary:z,permitted_land_uses:P,controls:I};return s(F),F}
786catch(x){const v=x instanceof Error?x.message:"Failed to fetch zoning data";return console.error("Zoneomics fetch error:",v),c(v),s(null),null}finally{a(!1)}},[]),i=k.useCallback(()=>{s(null),c(null)},[]);return{zoneomicsData:t,isLoading:n,error:l,fetchZoneomicsData:u,clearData:i}},_b=t=>t==null?"N/A":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(t),K2=(t,s=2)=>t==null?"N/A":new Intl.NumberFormat("en-US",{minimumFractionDigits:0,maximumFractionDigits:s}).format(t),_V=({parcel:t,onClose:s})=>{var X;const[n,a]=k.useState(null),[l,c]=k.useState(!1),[u,i]=k.useState(!1),[_,j]=k.useState(!1),{zoneomicsData:y,isLoading:x,error:v,fetchZoneomicsData:C,clearData:P}=xV(),I=ym();k.useEffect(()=>(t.lat&&t.lng&&C(t.lat,t.lng),()=>P()),[t.id,t.lat,t.lng,C,P]),k.useEffect(()=>{if(t.address||n)return;(async()=>{c(!0);try{const J=await(await fetch(`https://nominatim.openstreetmap.org/reverse?lat=${t.lat}&lon=${t.lng}&format=json`,{headers:{"User-Agent":"DevelopmentMapApp/1.0"}})).json();if(J.display_name){const O=J.display_name.split(", ").slice(0,3).join(", ");a(O);const{error:q}=await Fs.from("parcel_cache").update({address:O}).eq("id",t.id);q?console.error("Failed to cache geocoded address:",q):console.log("Cached geocoded address for parcel:",t.apn)}}catch(te){console.error("Reverse geocoding error:",te)}finally{c(!1)}})()},[t.id,t.lat,t.lng,t.address,t.apn,n]);const z=t.address||n,F=K=>K?Array.isArray(K)&&K.length>0&&K[0].lat!==void 0?K:K.type==="Polygon"&&K.coordinates?K.coordinates[0].map(J=>({lat:J[1],lng:J[0]})):K.type==="MultiPolygon"&&K.coordinates?K.coordinates[0][0].map(J=>({lat:J[1],lng:J[0]})):Array.isArray(K)&&K.length>0&&Array.isArray(K[0])?K.map(te=>({lat:te[1],lng:te[0]})):(console.warn("Unknown geometry format:",K),[]):[],D=async()=>{if(!t.geometry){Ve.error("No geometry available to copy");return}j(!0);try{const K=t.address||t.apn||"Parcel Polygon",te=F(t.geometry);if(te.length===0){Ve.error("Could not convert geometry format");return}await I.mutateAsync({name:K,type:"polygon",geometry:te,layer_type:"property_outline",is_visible:!0,style:{color:"#8b5cf6",fillColor:"#8b5cf6",weight:2,fillOpacity:.2},description:`Copied from parcel: ${t.apn}
787Owner: ${t.owner||"Unknown"}`,calculated_area_acres:t.acres||null,calculated_area_sqft:t.sqft||null}),Ve.success(`Parcel copied to Drawings as "${K}"`),s()}catch(K){console.error("Failed to copy parcel to drawings:",K),Ve.error("Failed to copy parcel to drawings")}finally{j(!1)}};return e.jsxs("div",{className:"absolute bottom-24 left-4 z-[1000] w-80 bg-background border border-border rounded-xl shadow-xl overflow-hidden animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-border bg-indigo-500/10",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-indigo-500/20 flex items-center justify-center",children:e.jsx(Ci,{className:"w-4 h-4 text-indigo-500"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Parcel Details"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t.apn})]})]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:s,children:e.jsx(ja,{className:"w-4 h-4"})})]}),e.jsx(Xc,{className:"h-[320px]",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ji,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Address"}),l?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(Va,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Looking up address..."})]}):z?e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:z}),!t.address&&n&&e.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"via reverse geocoding"})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No address available"})]})]}),t.owner&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ep,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Owner"}),e.jsx("p",{className:"text-sm font-medium",children:t.owner}),t.owner_address&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t.owner_address})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Fo,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Size"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[(()=>{const K=t.acres!==null?t.acres:t.sqft!==null?t.sqft/43560:null;return K!==null?e.jsxs(Mt,{variant:"secondary",className:"text-xs",children:[K2(K)," acres"]}):null})(),t.sqft!==null&&e.jsxs(Mt,{variant:"secondary",className:"text-xs",children:[K2(t.sqft,0)," sq ft"]})]})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(CS,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Zoning Information"}),x?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground mt-1",children:[e.jsx(Va,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading zoning data..."})]}):y?e.jsxs("div",{className:"mt-1 space-y-2",children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx(Mt,{variant:"outline",className:"text-xs bg-purple-500/10 text-purple-700 border-purple-500/30",children:y.zone_code}),y.zone_type&&e.jsx(Mt,{variant:"secondary",className:"text-xs",children:y.zone_type})]}),e.jsx("p",{className:"text-sm font-medium",children:y.zone_name}),y.zone_sub_type&&e.jsx("p",{className:"text-xs text-muted-foreground",children:y.zone_sub_type}),y.permitted_land_uses&&e.jsxs("div",{className:"flex gap-1.5 flex-wrap mt-1",children:[y.permitted_land_uses.single_family_permitted&&e.jsx(Mt,{variant:"outline",className:"text-[10px] bg-green-500/10 text-green-700 border-green-500/30",children:"Single Family ✓"}),y.permitted_land_uses.multi_family_permitted&&e.jsx(Mt,{variant:"outline",className:"text-[10px] bg-green-500/10 text-green-700 border-green-500/30",children:"Multi-Family ✓"}),y.permitted_land_uses.commercial_uses_permitted&&e.jsx(Mt,{variant:"outline",className:"text-[10px] bg-blue-500/10 text-blue-700 border-blue-500/30",children:"Commercial ✓"}),y.permitted_land_uses.industrial_uses_permitted&&e.jsx(Mt,{variant:"outline",className:"text-[10px] bg-
787orange-500/10 text-orange-700 border-orange-500/30",children:"Industrial ✓"})]}),e.jsxs(wi,{open:u,onOpenChange:i,children:[e.jsx(Ni,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs w-full justify-between",children:[e.jsx("span",{children:"View Details"}),u?e.jsx(Cc,{className:"w-3 h-3"}):e.jsx(Oa,{className:"w-3 h-3"})]})}),e.jsxs(ki,{className:"mt-2 space-y-2",children:[y.zone_guide&&e.jsxs("div",{className:"bg-muted/50 rounded p-2",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground mb-1",children:"Purpose"}),e.jsx("p",{className:"text-xs leading-relaxed",children:y.zone_guide})]}),((X=y.permitted_land_uses)==null?void 0:X.as_of_right)&&y.permitted_land_uses.as_of_right.length>0&&e.jsxs("div",{className:"bg-green-500/5 rounded p-2",children:[e.jsxs("p",{className:"text-[10px] font-medium text-green-700 mb-1",children:["Permitted Uses (",y.permitted_land_uses.as_of_right.length,")"]}),e.jsxs("ul",{className:"text-[10px] text-muted-foreground space-y-0.5 max-h-20 overflow-y-auto",children:[y.permitted_land_uses.as_of_right.slice(0,5).map((K,te)=>e.jsxs("li",{children:["• ",K]},te)),y.permitted_land_uses.as_of_right.length>5&&e.jsxs("li",{className:"text-muted-foreground/70",children:["...and ",y.permitted_land_uses.as_of_right.length-5," more"]})]})]}),y.link&&e.jsxs("a",{href:y.link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(Rx,{className:"w-3 h-3"}),"View Full Zoning Code"]})]})]})]}):e.jsxs("div",{className:"flex gap-2 flex-wrap mt-1",children:[t.land_use&&e.jsx(Mt,{variant:"outline",className:"text-xs",children:t.land_use}),t.zoning&&e.jsx(Mt,{variant:"outline",className:"text-xs bg-amber-500/10 text-amber-700 border-amber-500/30",children:t.zoning}),v&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Enhanced zoning data unavailable"})]})]})]}),t.year_built&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(kf,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Year Built"}),e.jsx("p",{className:"text-sm font-medium",children:t.year_built})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Vd,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Values & Taxes"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-1",children:[e.jsxs("div",{className:"bg-muted/50 rounded p-2",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Assessed"}),e.jsx("p",{className:"text-xs font-medium",children:_b(t.assessed_value)})]}),e.jsxs("div",{className:"bg-muted/50 rounded p-2",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Market"}),e.jsx("p",{className:"text-xs font-medium",children:_b(t.market_value)})]}),t.tax_amount!==null&&e.jsxs("div",{className:"bg-muted/50 rounded p-2 col-span-2",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Annual Taxes"}),e.jsx("p",{className:"text-xs font-medium",children:_b(t.tax_amount)})]})]})]})]}),t.geometry&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsx(WS,{geometry:t.geometry,reportedAcres:t.acres,reportedSqft:t.sqft,compact:!0}),e.jsxs(Le,{size:"sm",variant:"default",className:"w-full gap-2 mt-2 bg-violet-600 hover:bg-violet-700 text-white",onClick:D,disabled:_,children:[_?e.jsx(Va,{className:"h-4 w-4 animate-spin"}):e.jsx(fd,{className:"h-4 w-4"}),"Copy Parcel to Drawings"]})]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground pt-2 border-t border-border flex items-center justify-between",children:[e.jsxs("span",{children:[t.lat.toFixed(6),", ",t.lng.toFixed(6)]}),t.source&&e.jsx(Mt,{variant:"outline",className:"text-[9px]",children:t.source})]})]})})]})};function yV({className:t="",compact:s=!1}){const{stats:n,isLoading:a,refreshStats:l,clearCache:c}=I5(),u=()=>n.hitRate>=70?"text-green-500":n.hitRate>=40?"text-yellow-500":"text-muted-foreground";return s?e.jsx(hm,{children:e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsxs("div",{className:`flex items-center gap-1.5 text-xs ${t}`,children:[e.jsx(Fu,{className:`h-3.5 w-3.5 ${u()}`}),e.jsxs("span",{className:"text-muted-foreground",children:[n.totalTiles," tiles (",n.totalSizeMB," MB)"]})]})}),e.jsx(or,{side:"bottom",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("p",{children:e.jsx("strong",{children:"Tile Cache"})}),e.jsxs("p",{children:["Cached: ",n.totalTiles," tiles (",n.totalSizeMB," MB)"]}),e.jsxs("p",{children:["Hit Rate: ",n.hitRateFormatted]}),e.jsxs("p",{children:["Hits: ",n.cacheHits," | Misses: ",n.cacheMisses]}),e.jsxs("p",{children:["Oldest: ",n.oldestTileAgeFormatted]})]})})]})}):e.jsxs("div",{className:`bg-card border rounded-lg p-3 ${t}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fu,{className:`h-4 w-4 ${u(
787)}`}),e.jsx("span",{className:"text-sm font-medium",children:"Tile Cache"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:l,disabled:a,children:e.jsx(N0,{className:`h-3 w-3 ${a?"animate-spin":""}`})}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive hover:text-destructive",onClick:c,disabled:a||n.totalTiles===0,children:e.jsx(wr,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Cached:"}),e.jsxs("span",{className:"ml-1 font-medium",children:[n.totalTiles," tiles"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Size:"}),e.jsxs("span",{className:"ml-1 font-medium",children:[n.totalSizeMB," MB"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Hit Rate:"}),e.jsx("span",{className:`ml-1 font-medium ${u()}`,children:n.hitRateFormatted})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Age:"}),e.jsx("span",{className:"ml-1 font-medium",children:n.oldestTileAgeFormatted})]})]}),e.jsxs("div",{className:"mt-2 pt-2 border-t text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Hits: ",n.cacheHits]}),e.jsx("span",{className:"mx-2",children:"•"}),e.jsxs("span",{children:["Misses: ",n.cacheMisses]})]})]})}let Tx=0,x0=0,LT=0;const cp=new Map,vV=200;let J2=0;const bV=2e3;function Q2(t){const s=Date.now();s-J2>bV&&(console.log(t),J2=s)}function U2(){const t=Tx+x0;return{cacheHits:Tx,cacheMisses:x0,fetchedFromAPI:LT,hitRate:t>0?Tx/t*100:0,total:t}}function eC(){cp.size>vV&&Array.from(cp.keys()).slice(0,50).forEach(s=>{const n=cp.get(s);n&&URL.revokeObjectURL(n),cp.delete(s)})}const jV=Bt.TileLayer.extend({_loadTile:function(t,s){const n=this.getTileUrl(s),a=cp.get(n);if(a){Tx++,t.src=a;return}A5(n).then(l=>{if(l){Tx++;const c=URL.createObjectURL(l);cp.set(n,c),eC(),t.src=c,Q2(`[ParcelTiles] Cache hit rate: ${U2().hitRate.toFixed(0)}%`);return}x0++,this._loadFromNetwork(t,n)}).catch(()=>{x0++,this._loadFromNetwork(t,n)})},_loadFromNetwork:function(t,s){LT++,fetch(s).then(n=>{if(!n.ok)throw new Error(`HTTP ${n.status}`);return n.blob()}).then(n=>{D5(s,n).catch(console.error);const a=URL.createObjectURL(n);cp.set(s,a),eC(),t.src=a,Q2(`[ParcelTiles] Fetched tile, cache miss rate: ${(100-U2().hitRate).toFixed(0)}%`)}).catch(n=>{console.error("[CachedTileLayer] Network fetch error:",n),t.dispatchEvent(new Event("error"))})},createTile:function(t,s){const n=document.createElement("img");return Bt.DomEvent.on(n,"load",Bt.Util.bind(this._tileOnLoad,this,s,n)),Bt.DomEvent.on(n,"error",Bt.Util.bind(this._tileOnError,this,s,n)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(n.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),n.alt="",n.setAttribute("role","presentation"),this._loadTile(n,t),n}});function wV(t,s){return new jV(t,s)}const NV=({map:t,visible:s,currentZoom:n})=>{const a=k.useRef(null),[l,c]=k.useState([]),u=k.useRef(null),i=k.useCallback(async()=>{const _=await R5();c(_)},[]);return k.useEffect(()=>{if(s)return i(),u.current=setInterval(i,5e3),()=>{u.current&&(clearInterval(u.current),u.current=null)}},[s,i]),k.useEffect(()=>{if(!t)return;if(!t.getPane("cacheCoveragePane")){const P=t.createPane("cacheCoveragePane");P.style.zIndex="350",P.style.pointerEvents="none"}if(a.current&&(t.removeLayer(a.current),a.current=null),!s||l.length===0)return;a.current=Bt.layerGroup([],{pane:"cacheCoveragePane"}).addTo(t);const _=t.getBounds(),j=Math.floor(n),y=Math.max(0,j-2),x=j+2,C=l.filter(P=>{if(P.z<y||P.z>x)return!1;const I=Zw(P.x,P.y,P.z),z=Bt.latLngBounds([I.south,I.west],[I.north,I.east]);return _.intersects(z)}).slice(0,500);
787return C.forEach(P=>{var X;const I=Zw(P.x,P.y,P.z),z=Math.abs(P.z-j),F=z===0?.3:z===1?.2:.1,D=Bt.rectangle([[I.south,I.west],[I.north,I.east]],{color:"#22c55e",weight:1,opacity:.6,fillColor:"#22c55e",fillOpacity:F,pane:"cacheCoveragePane",interactive:!1});(X=a.current)==null||X.addLayer(D)}),console.log(`[CacheCoverageOverlay] Rendered ${C.length} cached tile regions`),()=>{a.current&&t&&(t.removeLayer(a.current),a.current=null)}},[t,s,l,n]),k.useEffect(()=>{if(!t||!s)return;const _=()=>{c(j=>[...j])};return t.on("moveend",_),t.on("zoomend",_),()=>{t.off("moveend",_),t.off("zoomend",_)}},[t,s]),k.useEffect(()=>()=>{a.current&&t&&(t.removeLayer(a.current),a.current=null)},[t]),null},tC={electric:["substations","transmissionLines"]},sC={substations:{label:"Substations",color:"#f97316",icon:"⚡"},transmissionLines:{label:"Transmission Lines",color:"#fbbf24",icon:"🔌"}};function kV(t,s){const n=t.properties||{},a=t.geometry;if(!a)return null;let l=0,c=0;if(a.type==="Point")c=a.coordinates[0],l=a.coordinates[1];else if(n.LATITUDE&&n.LONGITUDE)l=Number(n.LATITUDE),c=Number(n.LONGITUDE);else if(a.type==="LineString"&&a.coordinates.length>0){const i=Math.floor(a.coordinates.length/2);c=a.coordinates[i][0],l=a.coordinates[i][1]}else if(a.type==="MultiLineString"&&a.coordinates.length>0&&a.coordinates[0].length>0){const i=a.coordinates[0],_=Math.floor(i.length/2);c=i[_][0],l=i[_][1]}let u="Unknown";switch(s){case"substations":u=n.NAME||"Unknown Substation";break;case"transmissionLines":u=n.OWNER||`${n.VOLTAGE||"Unknown"} kV Line`;break}return{id:String(n.OBJECTID||n.FID||Math.random()),name:u,lat:l,lng:c,properties:n,geometry:a,layerType:s}}function CV(){const[t,s]=k.useState(()=>{const F={};return Object.keys(sC).forEach(D=>{F[D]={features:[],fetchedAt:null,count:0}}),F}),[n,a]=k.useState(!1),[l,c]=k.useState(null),[u,i]=k.useState(0),[_,j]=k.useState([]),y=k.useRef(!1),x=k.useRef(0),v=k.useCallback(async(F,D)=>{var X;if(!(y.current||D.length===0)){y.current=!0,a(!0),c(null);try{console.log("[Energy] Fetching layers:",D,"bounds:",F,"states:",_);const{data:K,error:te}=await Fs.functions.invoke("fetch-energy-infrastructure",{body:{bounds:F,layerTypes:D,minVoltage:u>0?u:void 0,states:_.length>0?_:void 0}});if(te)throw new Error(te.message||"Failed to fetch energy data");if(K!=null&&K.error)throw new Error(K.error);const J={...t},H=new Date(((X=K==null?void 0:K.metadata)==null?void 0:X.fetchedAt)||new Date);let O=0;for(const W of D){const Q=K==null?void 0:K[W];if(Q!=null&&Q.features){const Z=Q.features.map(oe=>kV(oe,W)).filter(Boolean);J[W]={features:Z,fetchedAt:H,count:Z.length},O+=Z.length}}s(J);const q=Date.now();return q-x.current>5e3&&(x.current=q,O>0&&Ve.success(`Loaded ${O.toLocaleString()} energy infrastructure features`)),J}catch(K){const te=K.message||"Failed to fetch energy data";console.error("[Energy] Fetch error:",te),c(te);const J=Date.now();return J-x.current>1e4&&(x.current=J,Ve.error(`Energy data fetch failed: ${te}`)),null}finally{a(!1),y.current=!1}}},[t,u,_]),C=k.useCallback(async(F,D)=>v(F,tC[D]),[v]),P=k.useCallback(F=>{s(D=>{const X={...D},K=F||Object.keys(sC);for(const te of K)X[te]={features:[],fetchedAt:null,count:0};return X}),console.log("[Energy] Cleared layers:",F||"all")},[]),I=k.useCallback(F=>F.flatMap(D=>{var X;return((X=t[D])==null?void 0:X.features)||[]}),[t]),z=k.useCallback(F=>I(tC[F]),[I]);return{data:t,isLoading:n,error:l,minVoltage:u,setMinVoltage:i,selectedStates:_,setSelectedStates:j,fetchLayers:v,fetchCategory:C,clearLayers:P,getFeatures:I,getCategoryFeatures:z}}const nC={AL:"01",AK:"02",AZ:"04",AR:"05",CA:"06",CO:"08",CT:"09",DE:"10",FL:"12",GA:"13",HI:"15",ID:"16",IL:"17",IN:"18",IA:"19",KS:"20",KY:"21",LA:"22",ME:"23",MD:"24",MA:"25",MI:"26",MN:"27",MS:"28",MO:"29",MT:"30",NE:"31",NV:"32",NH:"33",NJ:"34",NM:"35",NY:"36",NC:"37",ND:"38",OH:"39",OK:"40",OR:"41",PA:"42",RI:"44",SC:"45",SD:"46",TN:"47",TX:"48",UT:"49",VT:"50",VA:"51",WA:"53",WV:"54",WI:"55",WY:"56",DC:"11"};function SV(){const[t,s]=k.useState({demographics:[],schools:[],crimeData:null,walkability:[],isLoading:{demographics:!1,schools:!1,crime:!1,walkability:!1},error:{demographics:null,schools:null,crime:null,walkability:null}}),n=k.useCallback(async(j,y)=>{const x=nC[j.toUpperCase()];if(!x){Ve.error("Invalid state code");return}s(v=>({...v,isLoading:{...v.isLoading,demographics:!0},error:{...v.error,demographics:null}}));try{const{data:v,error:C}=await Fs.functions.invoke("fetch-census-demographics",{body:{state:x,county:y}});if(C)throw C;return s(P=>({...P,demographics:v.demographics||[],isLoading:{...P.isLoading,demographics:!1}})),v.demographics}catch(v){console.error("Error fetching demographics:",v),s(C=>({...C,isLoading:{...C.isLoading,demographics:!1},error:{...C.error,demographics:v.message}})),Ve.error("Failed to load demographics data")}},[]),a=k.useCallback(async(j,y)=>{s(x=>({...x,isLoading:{...x.isLoading,schools:!0},error:{...x.error,schools:null}}));try{const{data:x,error:v}
787=await Fs.functions.invoke("fetch-school-data",{body:{bounds:j,schoolTypes:y}});if(v)throw v;return s(C=>({...C,schools:x.schools||[],isLoading:{...C.isLoading,schools:!1}})),x.schools}catch(x){console.error("Error fetching schools:",x),s(v=>({...v,isLoading:{...v.isLoading,schools:!1},error:{...v.error,schools:x.message}})),Ve.error("Failed to load school data")}},[]),l=k.useCallback(async(j,y)=>{s(x=>({...x,isLoading:{...x.isLoading,crime:!0},error:{...x.error,crime:null}}));try{const{data:x,error:v}=await Fs.functions.invoke("fetch-crime-data",{body:{state:j,year:y}});if(v)throw v;return s(C=>({...C,crimeData:x.crimeData,isLoading:{...C.isLoading,crime:!1}})),x.crimeData}catch(x){console.error("Error fetching crime data:",x),s(v=>({...v,isLoading:{...v.isLoading,crime:!1},error:{...v.error,crime:x.message}})),Ve.error("Failed to load crime data")}},[]),c=k.useCallback(async j=>{s(y=>({...y,isLoading:{...y.isLoading,walkability:!0},error:{...y.error,walkability:null}}));try{const y="lat"in j?{lat:j.lat,lng:j.lng}:{bounds:j},{data:x,error:v}=await Fs.functions.invoke("fetch-walkability",{body:y});if(v)throw v;const C=x.walkability?[x.walkability]:x.walkabilityData||[];return s(P=>({...P,walkability:C,isLoading:{...P.isLoading,walkability:!1}})),C}catch(y){console.error("Error fetching walkability:",y),s(x=>({...x,isLoading:{...x.isLoading,walkability:!1},error:{...x.error,walkability:y.message}})),Ve.error("Failed to load walkability data")}},[]),u=k.useCallback(()=>{s({demographics:[],schools:[],crimeData:null,walkability:[],isLoading:{demographics:!1,schools:!1,crime:!1,walkability:!1},error:{demographics:null,schools:null,crime:null,walkability:null}})},[]),i=k.useCallback(j=>j<=5?"#ef4444":j<=10?"#f97316":j<=14?"#eab308":j<=17?"#84cc16":"#22c55e",[]),_=k.useCallback(j=>{switch(j){case"elementary":return"🏫";case"middle":return"🏛️";case"high":return"🎓";default:return"📚"}},[]);return{...t,fetchDemographics:n,fetchSchools:a,fetchCrimeData:l,fetchWalkability:c,clearData:u,getWalkabilityColor:i,getSchoolIcon:_,stateFips:nC}}const _0={airport:{id:"airport",name:"Airports",icon:"✈️",color:"#3b82f6",description:"Standard airports with runways"},heliport:{id:"heliport",name:"Heliports",icon:"🚁",color:"#8b5cf6",description:"Helicopter landing facilities"},seaplane:{id:"seaplane",name:"Seaplane Bases",icon:"🌊",color:"#06b6d4",description:"Water landing facilities"},balloonport:{id:"balloonport",name:"Balloonports",icon:"🎈",color:"#f59e0b",description:"Balloon launch sites"},gliderport:{id:"gliderport",name:"Gliderports",icon:"🪂",color:"#84cc16",description:"Glider operations"},ultralight:{id:"ultralight",name:"Ultralight",icon:"🛩️",color:"#f97316",description:"Ultralight aircraft facilities"},stolport:{id:"stolport",name:"STOLports",icon:"🛬",color:"#14b8a6",description:"Short takeoff and landing"}};function EV(){const[t,s]=k.useState([]),[n,a]=k.useState(!1),[l,c]=k.useState(null),[u,i]=k.useState(null),_=k.useRef(!1),j=k.useCallback(async(x,v)=>{var C;if(_.current)return[];_.current=!0,a(!0),c(null);try{console.log("[Airports] Fetching with bounds:",x,"filters:",v);const{data:P,error:I}=await Fs.functions.invoke("geointeldata-explore",{body:{action:"fetch-airports",params:{bounds:x,...v}}});if(I)throw console.error("[Airports] Edge function error:",I),new Error(I.message||"Failed to fetch airports");if(!(P!=null&&P.success))throw console.error("[Airports] API error:",P==null?void 0:P.error),new Error((P==null?void 0:P.error)||"Failed to fetch airports");const z=[],F=P==null?void 0:P.data,D=(F==null?void 0:F.type)==="FeatureCollection"?F:((C=F==null?void 0:F.data)==null?void 0:C.type)==="FeatureCollection"?F.data:F,X=Array.isArray(D==null?void 0:D.features)?D.features:[];console.log("[Airports] Raw response type:",D==null?void 0:D.type,"features:",X.length);for(const te of X){const J=te,H=J.properties||J,O=J.geometry;let q=H.latitude||H.lat||H.LATITUDE,W=H.longitude||H.lng||H.LONGITUDE||H.lon;(O==null?void 0:O.type)==="Point"&&O.coordinates&&(W=O.coordinates[0],q=O.coordinates[1]),!(typeof q!="number"||typeof W!="number")&&z.push({id:String(H.id||H.OBJECTID||H.objectid||H.faa_id||Math.random()),name:String(H.name||H.NAME||H.facility_name||H.FACILITY_NAME||"Unknown Airport"),city:String(H.city||H.CITY||""),state:String(H.state||H.STATE||H.state_id||H.state_abbr||""),county:String(H.county||H.COUNTY||H.county_name||""),faaId:String(H.faa_id||H.FAA_ID||H.loc_id||H.ident||""),icaoId:String(H.icao_id||H.ICAO_ID||H.icao||""),type:String(H.type||H.TYPE||H.type_code||H.facility_type||H.airport_type||"AIRPORT"),ownership:String(H.ownership||H.OWNERSHIP||H.owner_type||""),use:String(H.use||H.USE||H.use_type||""),lat:q,lng:W,elevation:H.elevation?Number(H.elevation):H.elev?Number(H.elev):H.elevation_ft?Number(H.elevation_ft):null,runways:H.runways?Number(H.runways):H.runway_count?Number(H.runway_count):null,longestRunway:H.longest_runway||H.LONGEST_RUNWAY||H.longest_rwy||H.longest_runway_ft?Number(H.longest_runway||H.LONGEST_RUNWAY||H.longest_rwy||H.longest_runway_ft):null,services:H.services?String(H.services):H.fuel_types?String(H.fuel_types):null,
787source:"GeoIntel"})}let K=z;return v!=null&&v.types&&v.types.length>0&&(K=K.filter(te=>{const J=Wj(te.type);return v.types.includes(J)})),v!=null&&v.minRunwayLength&&(K=K.filter(te=>te.longestRunway!==null&&te.longestRunway>=v.minRunwayLength)),v!=null&&v.publicOnly&&(K=K.filter(te=>{var J,H;return((J=te.use)==null?void 0:J.toUpperCase().includes("PUBLIC"))||((H=te.ownership)==null?void 0:H.toUpperCase().includes("PUBLIC"))})),console.log(`[Airports] Parsed ${z.length} airports, filtered to ${K.length}`),s(K),i(new Date),K.length===0?Ve.info("No airports found matching filters"):Ve.success(`Loaded ${K.length.toLocaleString()} airports`),K}catch(P){const I=P instanceof Error?P.message:"Failed to fetch airports";return console.error("[Airports] Fetch error:",I),c(I),Ve.error(`Airport fetch failed: ${I}`),[]}finally{a(!1),_.current=!1}},[]),y=k.useCallback(()=>{s([]),i(null),c(null)},[]);return{airports:t,isLoading:n,error:l,lastFetched:u,fetchAirports:j,clearAirports:y}}const Wj=t=>{const s=(t||"").toUpperCase().trim();return s==="HP"||s.includes("HELIPORT")?"heliport":s==="SPB"||s.includes("SEAPLANE")?"seaplane":s==="BP"||s.includes("BALLOON")?"balloonport":s==="GP"||s.includes("GLIDER")?"gliderport":s==="UL"||s.includes("ULTRALIGHT")?"ultralight":s==="ST"||s.includes("STOL")||s.includes("STOLPORT")?"stolport":"airport"},PV=t=>{const s=Wj(t);return _0[s].icon},TV=t=>{const s=Wj(t);return _0[s].color};function aC(t,s){return gi(us(t),us(s),{units:"kilometers"})*3280.84}function Ur(t,s,n){const a=s/3280.84;return On(us(t),a,n,{units:"kilometers"}).geometry.coordinates}function qg(t,s){const n=t.bearingDeg,a=(n+90)%360,l=(n-90+360)%360,c=Ur(t.midpoint,10,a),u=aC(c,s),i=aC(Ur(t.midpoint,10,l),s);return u>i?a:l}function Pp(t){const s=Xn([[...t,t[0]]]);return Yo(s).geometry.coordinates}function Ru(t,s,n,a,l){const c=Ur(Ur(t,s,(a+180)%360),n,l),u=Ur(Ur(t,s,a),n,l),i=Ur(Ur(t,s,a),n,(l+180)%360),_=Ur(Ur(t,s,(a+180)%360),n,(l+180)%360);return[c,u,i,_,c]}function MT(t,s,n,a=3,l=1.5){var j;if(!t.features.length||s.length<3||n<=0)return Un([]);const c=Ec(s),u=Pp(s),i=[],_=new Map;for(const y of t.features){const x=((j=y.properties)==null?void 0:j.edgeIndex)??0;_.has(x)||_.set(x,[]),_.get(x).push(y)}for(const[y,x]of _){const v=c[y];if(!v)continue;const C=qg(v,u);for(let P=0;P<x.length;P++)if((P+1)%n===0&&P<x.length-1){const I=x[P].geometry.coordinates[0],z=x[P+1].geometry.coordinates[0],F=I[1],D=z[0],X=(F[0]+D[0])/2,K=(F[1]+D[1])/2,te=[X,K],J=a/2,H=v.bearingDeg,O=Ur(te,J,(H+180)%360),q=Ur(te,J,H),W=Ur(O,l,C),Q=Ur(q,l,C);i.push({type:"Feature",properties:{equipmentType:"man_door",edgeIndex:y,afterDockIndex:P},geometry:{type:"Polygon",coordinates:[[O,q,Q,W,O]]}})}}return Un(i)}function IT(t,s,n=4,a=.917,l=4){var v;if(!t.features.length||s.length<3||n<=0)return Un([]);const c=Ec(s),u=Pp(s),i=[],_=Math.ceil(n/.833),j=n/_,y=3,x=l;for(const C of t.features){const P=((v=C.properties)==null?void 0:v.edgeIndex)??0,I=c[P];if(!I)continue;const z=qg(I,u),F=I.bearingDeg,D=C.geometry.coordinates[0],X=D[3],K=D[2],te=[(X[0]+K[0])/2,(X[1]+K[1])/2],J=Ur(te,y/2,z),H=Ru(J,x/2,y/2,F,z);i.push({type:"Feature",properties:{equipmentType:"man_door_landing",stepHeightFt:n-j,stepRiseFt:j,edgeIndex:P,dockHeightFt:n},geometry:{type:"Polygon",coordinates:[H]}});const O=Ur(te,y,z);for(let q=0;q<_;q++){const W=a*(q+1),Q=l/2+q*.25,Z=Ur(O,W,z),oe=Ru(Z,Q,a/2,F,z);i.push({type:"Feature",properties:{equipmentType:"man_door_step",stepIndex:q,stepCount:_,stepHeightFt:n-j*(q+1),stepRiseFt:j,edgeIndex:P},geometry:{type:"Polygon",coordinates:[oe]}})}}return Un(i)}function AT(t,s,n="gooseneck",a=1.5){var i,_;if(!t.features.length||s.length<3)return Un([]);const l=Ec(s),c=Pp(s),u=[];for(const j of t.features){const y=((i=j.properties)==null?void 0:i.edgeIndex)??0,x=l[y];if(!x)continue;const v=j.geometry.coordinates[0],C=v[0],P=v[1],I=qg(x,c),z=x.bearingDeg,F=(C[0]+P[0])/2,D=(C[1]+P[1])/2,te=Ur([F,D],n==="gooseneck"?1.5:.5,I),J=a/2,H=Ru(te,J,J,z,I);u.push({type:"Feature",properties:{equipmentType:"dock_light",lightType:n,dockIndex:(_=j.properties)==null?void 0:_.dockIndex,edgeIndex:y},geometry:{type:"Polygon",coordinates:[H]}})}return Un(u)}function DT(t,s=4,n=48,a,l="even",c="exhaust_fan",u="single"){if(t.length<3||s<=0)return Un([]);const i=Ec(t),_=Pp(t),j=[];if(c==="ridge_vent")return MV(t,i,_,s,n);let y;u==="custom"&&a&&a.length>0?y=a.map(C=>
787i[C]).filter(Boolean):u==="cross"?y=LV(i):y=[i.reduce((C,P)=>C.lengthFt>P.lengthFt?C:P)],y.length===0&&(y=[i.reduce((C,P)=>C.lengthFt>P.lengthFt?C:P)]);const x=n/12/2,v=Math.ceil(s/y.length);for(const C of y){const P=qg(C,_),I=C.lengthFt/(v+1);for(let z=0;z<v;z++){const F=I*(z+1),D=Ur(C.start,F,C.bearingDeg),X=Ur(D,x+.5,P);let K;if(c==="louver_vent"){const te=x*1.5,J=x*.6;K=Ru(X,te,J,C.bearingDeg,P)}else{K=[];for(let te=0;te<8;te++){const J=te*45;K.push(Ur(X,x,J))}K.push(K[0])}j.push({type:"Feature",properties:{equipmentType:"exhaust_fan",fanType:c,edgeIndex:C.index,fanIndex:z},geometry:{type:"Polygon",coordinates:[K]}})}}return Un(j)}function LV(t){let n=null,a=0;for(let l=0;l<t.length;l++)for(let c=l+1;c<t.length;c++){const u=Math.abs(t[l].bearingDeg-t[c].bearingDeg),i=Math.min(u,360-u);if(Math.abs(i-180)<=15){const _=t[l].lengthFt+t[c].lengthFt;_>a&&(a=_,n=[t[l],t[c]])}}return n?[n[0],n[1]]:[]}function MV(t,s,n,a,l){const c=[],i=[...s].sort((v,C)=>C.lengthFt-v.lengthFt)[0];if(!i)return Un([]);const _=i.bearingDeg,j=l/12*2,y=l/12/2,x=i.lengthFt/(a+1);for(let v=0;v<a;v++){const C=x*(v+1),P=Ur(n,C-i.lengthFt/2,_),I=Ru(P,j/2,y/2,_,(_+90)%360);c.push({type:"Feature",properties:{equipmentType:"exhaust_fan",fanType:"ridge_vent",fanIndex:v},geometry:{type:"Polygon",coordinates:[I]}})}return Un(c)}function RT(t,s=40,n,a=!0,l=1){if(t.length<3)return Un([]);const c=Ec(t),u=Pp(t),i=[],_=n&&n.length>0?n.map(j=>c[j]).filter(Boolean):c;for(const j of _){const y=qg(j,u),x=j.bearingDeg,v=l/2,C=Math.max(1,Math.floor(j.lengthFt/s)),P=j.lengthFt/(C+1);for(let I=0;I<C;I++){const z=P*(I+1),F=Ur(j.start,z,x),D=Ur(F,.5,y),X=Ru(D,v,v,x,y);i.push({type:"Feature",properties:{equipmentType:"building_light",edgeIndex:j.index,lightIndex:I},geometry:{type:"Polygon",coordinates:[X]}})}if(a)for(const I of[j.start,j.end]){const z=Ur(I,.5,y),F=Ru(z,v,v,x,y);i.push({type:"Feature",properties:{equipmentType:"building_light_corner",edgeIndex:j.index},geometry:{type:"Polygon",coordinates:[F]}})}}return Un(i)}function FT(t,s=2,n=4,a=4,l=8,c=10,u=5){if(t.length<3||s<=0||n<=0)return Un([]);const i=Ec(t),_=Pp(t),j=[],y=[...i].sort((D,X)=>X.lengthFt-D.lengthFt),x=y[0],v=y.length>1?y[1]:y[0];if(!x)return Un([]);const C=x.bearingDeg,P=v.bearingDeg,I=(n-1)*(a+c),z=(s-1)*(l+c),F=Ur(Ur(_,I/2,(C+180)%360),z/2,(P+180)%360);for(let D=0;D<s;D++)for(let X=0;X<n;X++){const K=X*(a+c),te=D*(l+c),J=Ur(Ur(F,K,C),te,P),H=Ru(J,a/2,l/2,C,P);j.push({type:"Feature",properties:{equipmentType:"skylight",row:D,col:X},geometry:{type:"Polygon",coordinates:[H]}})}return Un(j)}function zT(t,s,n=10,a=20,l="three_sided",c,u=!0){var F;if(t.length<3)return Un([]);const i=Ec(t),_=Pp(t),j=[];let y;if(c!=null&&i[c])y=i[c];else if(s&&s.features.length>0){const X=((F=s.features[s.features.length-1].properties)==null?void 0:F.edgeIndex)??0;y=i[X]}else y=i[0];if(!y)return Un([]);const x=qg(y,_),v=y.bearingDeg,C=Ur(y.end,-n/2,v),P=Ur(C,a/2,x),I=Ru(P,n/2,a/2,v,x);j.push({type:"Feature",properties:{equipmentType:"trash_compactor_pad",enclosureType:l},geometry:{type:"Polygon",coordinates:[I]}});const z=.67;if(l==="three_sided"||l==="full_enclosure"){const D=Ur(P,n/2,(v+180)%360),X=Ru(D,z/2,a/2,v,x);j.push({type:"Feature",properties:{equipmentType:"trash_compactor_wall",wallSide:"left"},geometry:{type:"Polygon",coordinates:[X]}});const K=Ur(P,n/2,v),te=Ru(K,z/2,a/2,v,x);j.push({type:"Feature",properties:{equipmentType:"trash_compactor_wall",wallSide:"right"},geometry:{type:"Polygon",coordinates:[te]}});const J=Ur(P,a/2,x),H=Ru(J,n/2,z/2,v,x);if(j.push({type:"Feature",properties:{equipmentType:"trash_compactor_wall",wallSide:"back"},geometry:{type:"Polygon",coordinates:[H]}}),l==="full_enclosure"){const O=Ur(P,a/2,(x+180)%360),q=Ru(O,n/2,z/2,v,x);j.push({type:"Feature",properties:{equipmentType:"trash_compactor_wall",wallSide:"gate"},geometry:{type:"Polygon",coordinates:[q]}})}}if(u){const X=[Ur(Ur(P,n/2+2,(v+180)%360),a/2,x),Ur(Ur(P,n/2+2,v),a/2,x)];for(let K=0;K<X.length;K++){const te=[];for(let J=0;J<6;J++)te.push(Ur(X[K],.5,J*60));te.push(te[0]),j.push({type:"Feature",properties:{equipmentType:"trash_compactor_bollard",bollardIndex:K},geometry:{type:"Polygon",coordinates:[te]}})}}return Un(j)}function OT(t,s,n,a){var u;if(!t||t.length<3)return[];const l=Math.min(Math.max(Math.floor(s*1.5),4),8),c=[];try{const i=t.map(C=>[C.lng,C.lat]);i.push(i[0]);const _=Xn([i]),y=30/(l+2),x=IV(n);if(!x)return[];let v=null;for(let C=0;C<l;C++){const I=-((C+1)*y)*.3048;if(!(I<-50))try{const z=dl(_,I,{units:"meters"});if(z&&z.geometry){const F=z.geometry.type==="Polygon"?z.geometry.coordinates[0]:z.geometry.type==="MultiPolygon"?(u=z.geometry.coordinates[0])==null?void 0:u[0]:null;if(F&&F.length>=3){const D=F.slice(0,-1).map(J=>({lat:J[1],lng:J[0]})),X=.05+C*.07,K=rC(x,Math.min(X,.55)),te=.4+C*.06;c.push({geometry:D,color:K,opacity:Math.min(te,.85),depthLevel:C}),v=D}}}catch{continue}}if(v&&v.length>=3){const P=.05+(l-1)*.07+.12,I=rC(x,Math.min(P,.55));c.push({geometry:v,color:I,opacity:.8,depthLevel:l})}}catch(i){return console.warn("Failed to generate basin depth rings:",i),[]}return c}function IV(t){const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16)}:null}function rC(t,s){const n=Math.max(0,Math.round(t.r*(1-s))),a=Math.max(0,Math.round(t.g*(1-s))),l=Math.max(0,Math.round(t.b*(1-s)));return`#${n.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}`}function BT(t){var a;if(t.layer_type!=="stormwater")return!1;const s=(a=t.style)==null?void 0:a.stormwaterConfig;if(!s)return!1;const n=s.type;return n==="retention_pond"||n==="detention_basin"}function $T(t){var n;const s=(n=t.style)==null?void 0:n.stormwaterConfig;return(s==null?void 0:s.depth_ft)||4}function VT(t){const s=t.style,n=s==null?void 0:s.stormwaterConfig;if(s!=null&&s.fillColor)return s.fillColor;const a=n==null?void 0:n.type;return a==="retention_pond"?"#3b82f6":a==="detention_basin"?"#22c55e":"#3b82f6"}const iC={grass:"#86efac",gravel:"#a8a29e",concrete:"#d4d4d4"},AV={chain_link:"#9ca3af",chain_link_privacy:"#6b7280",ornamental:"#1f2937",wood:"#92400e"},DV="#6b7280";function qT(t,s,n=3){if(!t||t.length<3||!s.enabled)return{segments:[],posts:[],barbedWire:[],bufferZone:null};
787const a=AV[s.type]||"#9ca3af",l=s.height_ft*.3048,c=[],u=[],i=[];let _=null;try{const j=t.map(K=>[K.lng,K.lat]);j.push(j[0]);const y=Xn([j]),x=dl(y,n,{units:"feet"});if(!x||!x.geometry)return{segments:[],posts:[],barbedWire:[],bufferZone:null};const v=x.geometry.type==="Polygon"?x.geometry.coordinates[0]:null;if(!v||v.length<3)return{segments:[],posts:[],barbedWire:[],bufferZone:null};const C=v.slice(0,-1).map(K=>({lat:K[1],lng:K[0]})),P=s.buffer_material||"grass";_={geometry:C,material:P,color:iC[P]||iC.grass};const I=Yd(v),z=i_(I,{units:"meters"}),F=[];if(s.has_gates&&s.gate_count>0){const K=1/(s.gate_count+1);for(let te=1;te<=s.gate_count;te++)F.push(K*te)}c.push({geometry:C,color:a,heightMeters:l,isGate:!1});const X=Math.floor(z/2.4);for(let K=0;K<C.length;K++)u.push({position:C[K],heightMeters:l+.1,color:a});s.has_barbed_wire&&i.push({geometry:C,color:DV,heightMeters:l+.15})}catch(j){return console.warn("Failed to generate stormwater fence geometry:",j),{segments:[],posts:[],barbedWire:[],bufferZone:null}}return{segments:c,posts:u,barbedWire:i,bufferZone:_}}function Yj(t){const s=t.style,n=s==null?void 0:s.stormwaterFencing;return!n||!n.enabled?null:{enabled:n.enabled,height_ft:n.height_ft||6,type:n.type||"chain_link",has_barbed_wire:n.has_barbed_wire||!1,has_gates:n.has_gates||!1,gate_count:n.gate_count||1,buffer_ft:n.buffer_ft||5,buffer_material:n.buffer_material||"grass"}}function GT(t){if(t.layer_type!=="stormwater")return!1;const s=Yj(t);return s!==null&&s.enabled}const oC={tight:40,medium:60,loose:100},lC=36,cC=3,dC={"x-small":{logoMax:20},small:{logoMax:28},medium:{logoMax:32},large:{logoMax:42},xl:{logoMax:48}},uC={small:{fontSize:14,markerSize:28},medium:{fontSize:18,markerSize:36},large:{fontSize:22,markerSize:44}},od={closeButton:!0,autoPan:!0,autoPanPadding:Bt.point(50,50),closeOnClick:!1,autoClose:!1,pane:"popupsPane",className:"layer-popup",maxWidth:300,offset:Bt.point(0,-20)},RV='<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg>',hC=t=>t?Array.isArray(t)&&t.length>0&&typeof t[0]=="object"&&t[0].lat!==void 0?t:t.type==="Polygon"&&t.coordinates?t.coordinates[0].map(n=>({lat:n[1],lng:n[0]})):t.type==="MultiPolygon"&&t.coordinates?t.coordinates[0][0].map(n=>({lat:n[1],lng:n[0]})):Array.isArray(t)&&t.length>0&&Array.isArray(t[0])?t.map(s=>({lat:s[1],lng:s[0]})):(console.warn("Unknown geometry format, returning empty array:",t),[]):[],ld=(t,s,n)=>`
788    <div class="pinnable-popup-content" data-pinned="false">
789      <div class="popup-header">
790        <div class="popup-header-title">
791          ${n?`<span class="text-lg">${n}</span>`:""}
792          <strong class="text-sm">${t??"Unknown"}</strong>
793        </div>
794        <button class="popup-pin-button" title="Pin popup to keep it open" onclick="this.classList.toggle('pinned'); this.closest('.leaflet-popup').classList.toggle('pinned-popup'); this.closest('.pinnable-popup-content').dataset.pinned = this.classList.contains('pinned');">
795          ${RV}
796        </button>
797      </div>
798      <div class="popup-body">
799        ${s}
800      </div>
801    </div>
802  `,FV=k.forwardRef(({developments:t,existingProducts:s=[],selectedDevelopment:n,selectedExistingProduct:a,onSelectDevelopment:l,onSelectExistingProduct:c,filters:u,isAdmin:i=!1,onMapClick:_,onMarkerDrag:j,drawBoundaryFor:y,onClearDrawBoundary:x,navigateToOverlay:v,onClearNavigateToOverlay:C,mapTitle:P="Development Map",mapSettings:I,mapStyle:z,onMapStyleChange:F,boundaryLayers:D,onBoundaryLayerToggle:X,layerOpacity:K,onLayerOpacityChange:te,layerVisibility:J={},airportCategories:H=[],isDrawingRegion:O=!1,regionDrawingType:q=null,presetCircleRadius:W,onRegionDrawn:Q,onCancelRegionDraw:Z,activeRegionFilter:oe,onUpdateActiveRegionRadius:ce,onCreateProximityFilter:ae,onAddDevelopment:ie,onAddExistingProduct:de,is3DMode:ge,onToggle3DMode:We,isParcelLookupMode:Ee,onToggleParcelLo
802okup:ve,onParcelSearch:we,onParcelClick:Ze,onViewportParcelClickForAssemblage:ke,isParcelLoading:ze,parcelClickLocation:Ke,parcelCenter:dt,parcelGeometry:Re,assemblageParcels:qt=[],assemblageCustomAreas:ft=[],isAssemblageMode:Fe=!1,isDrawingAssemblageArea:fe=!1,onAssemblageAreaDrawn:Qe,onCancelAssemblageAreaDraw:ht,onShowControls:_t,showControlsDialog:He=!1,onControlsDialogChange:as,showLegendDialog:vt=!1,onLegendDialogChange:Xe,onAIRecordCreated:Ce,onNavigateToRecord:Be,isMeasuring:Dt,measurementType:Rt,measurementPoints:zt,onStartMeasuring:rs,onAddMeasurementPoint:_s,onUndoMeasurement:vs,onCancelMeasurement:$t,onClearMeasurement:Ns,onSaveMeasurement:Ts,previewLocation:bs,onPreviewLocationDrag:en,temporaryMarker:Jt,onClearTemporaryMarker:Vs,onMapPositionChange:ps,drawingPanelOpen:nt,onDrawingPanelOpenChange:ts,drawingPanelOverlayId:ds,onDrawingPanelOverlayIdChange:Is,activeSiteLayoutId:tn,onActiveSiteLayoutIdChange:wn,isSiteLayoutsMode:Gs=!1,activeGroupId:Ue},Pe)=>{var pc,km;const je=lc();o_();const{isEnabled:Ge}=$g(),De=[parseFloat((I==null?void 0:I.map_center_lat)||"40.3285"),parseFloat((I==null?void 0:I.map_center_lng)||"-76.0110")],bt=parseInt((I==null?void 0:I.map_zoom)||"13",10),Ct=k.useRef(null),pe=k.useRef(null),wt=k.useRef(0);wt.current++,wt.current%10===0&&console.warn(`[DevelopmentMap] Rendered ${wt.current} times`);const[Zt,ys]=k.useState(!1),es=k.useRef([]),is=k.useRef([]),Ws=k.useRef(null),an=k.useRef(null),ya=k.useRef([]),Hs=k.useRef([]),[xt,os]=k.useState(()=>{const Ne=localStorage.getItem("map-clustering-enabled");return Ne!==null?Ne==="true":!0}),[Ls,Es]=k.useState(()=>localStorage.getItem("map-cluster-radius")||"medium"),[Qs,Pn]=k.useState(()=>{const Ne=localStorage.getItem("map-logo-size");return Ne==="tiny"||Ne==="xs"?"x-small":Ne==="xxl"?"medium":Ne==="xxxl"?"large":Ne==="x-small"||Ne==="small"||Ne==="medium"||Ne==="large"||Ne==="xl"?Ne:"medium"}),[Ks,xa]=k.useState(()=>{const Ne=localStorage.getItem("map-show-tenant-logos");return Ne!==null?Ne==="true":!0}),[Fn,Sa]=k.useState(()=>{const Ne=localStorage.getItem("map-show-crm-logos");return Ne!==null?Ne==="true":!1}),[sr,An]=k.useState(()=>localStorage.getItem("map-icon-size")||"medium"),[Ai,xi]=k.useState(()=>localStorage.getItem("map-logo-shape")||"rounded"),[ei,Yr]=k.useState(()=>localStorage.getItem("map-popup-density")||"comfortable"),[Xo,ra]=k.useState(null),[Ka,Ha]=k.useState(()=>{const Ne=localStorage.getItem("map-preload-municipalities");return Ne!==null?Ne==="true":!0}),[qa,Mn]=k.useState(null),[_r,Ar]=k.useState(0),[Zs,Cn]=k.useState({type:null,id:null,name:null}),[Na,Gn]=k.useState(()=>{const Ne=localStorage.getItem("map-parcel-indicator-position");if(Ne)try{return JSON.parse(Ne)}catch{return{x:8,y:window.innerHeight-150}}return{x:8,y:window.innerHeight-150}}),sa=k.useRef(null),Pr=k.useRef(null),oi=k.useRef(De),Tr=k.useRef(bt),[Ko,Za]=k.useState(De),[Gr,Xr]=k.useState(bt),rn=k.useRef({states:null,statesLabels:null,statesGeoJson:null,countiesGeoJson:null,counties:null,countiesLabels:null,cities:null,citiesLabels:null,municipalities:null,zipCodes:null,congressionalDistricts:null,congressionalDistrictsLabels:null,censusTracks:null,censusTracksLabels:null,schoolDistricts:null,schoolDistrictsLabels:null,primaryRoads:null,secondaryRoads:null,localRoads:null,railroads:null,roadsOverlay:null,majorRoads:null,transmissionLines:null,substations:null,powerPlants:null,hifldTransmission:null,hifldSubstations:null,wetlands:null,floodZones:null,hydrology:null,brownfields:null,superfund:null,toxicRelease:null,geology:null,soils:null,bedrock:null,groundwater:null,usgsImagery:null,shadedRelief:null,topographic:null,schools:null,walkability:null,opportunityZones:null,airports:null}),In=k.useRef({substations:!1,transmissionLines:!1});k.useState(!1),k.useState(!1);const[Yi,jl]=k.useState(!1),[Si,zo]=k.useState(null),[Pc,Hr]=k.useState(""),[ul,hl]=k.useState(!1),Nr=k.useRef(null),[ui,Zr]=k.useState(!1),[Gi,fn]=k.useState(null),[kr,nr]=k.useState(null),[Br,wl]=k.useState(""),[Nl,lr]=k.useState(""),[Xi,ml]=k.useState(null),Co=k.useRef(null),ti=k.useRef(null),qs=k.useRef(null),Tn=k.useRef(null),[oa,Pa]=k.useState(50),mr=k.useRef(null),$r=k.useRef(null),Jo=k.useRef(null),[na,Sn]=k.useState(null),[Ui,Ma]=k.useState("5"),[Di,Al]=k.useState(!1),[cc,dc]=k.useState(null),[_u,uc]=k.useState(!1),[hc,kl]=k.useState(null),Ki=nt??_u,Dl=ds??hc,Ri=k.useCallback(Ne=>{ts?ts(Ne):uc(Ne)},[ts]),Qo=k.useCallback(Ne=>{Is?Is(Ne):kl(Ne)},[Is]),[Cl,Rl]=k.useState(!1),[Md,fl]=k.useState(void 0),[So,Kr]=k.useState(!1),[hi,Jd]=k.useState("none"),[Id,Hl]=k.useState(!1),[Sl,gd]=k.useState(null),[Zl,Hi]=k.useState(!1),[eo,Wr]=k.useState(null),[Tc,Wl]=k.useState(null),[_o,Yl]=k.useState(!1),[Xl,pl]=k.useState(null),[Fl,Lc]=k.useState(null),li=k.useRef([]),Kl=k.useRef(null),Ia=k.useRef([]);k.useEffect(()=>
802{console.log("[StallEditor State] stallEditorEnabled:",Zl,"polygonToolsOverlayId:",Dl)},[Zl,Dl]);const[Jl,fr]=k.useState(!1),[Dr,zl]=k.useState(null),qe=k.useRef(null),[Xt,js]=k.useState(null),[Rs,la]=k.useState(null),[Bn,Rr]=k.useState(null),Mc=k.useRef(!1),Uo=k.useRef(null),[el,Oo]=k.useState(!1),[yo,gl]=k.useState(null),{substations:ci,transmissionLines:Eo,fetchBoth:tl,isLoading:xl,minVoltage:Bo}=F5();CV();const{schools:Jc,walkability:Cr,isLoading:Ic,fetchSchools:yu,fetchWalkability:Qd,getWalkabilityColor:to,getSchoolIcon:$o}=SV(),{airports:N,isLoading:h,fetchAirports:f,clearAirports:w}=EV(),[G,re]=k.useState(!1),xe=k.useRef(null),{data:Ae=[]}=mV(),[tt,Nt]=k.useState(()=>uk()),Ut=k.useCallback(Ne=>{if(!pe.current)return;const Oe={states:"boundaryPane",counties:"boundaryPane",municipalities:"boundaryPane",zipCodes:"boundaryPane",congressionalDistricts:"boundaryPane",schoolDistricts:"boundaryPane",censusTracks:"boundaryPane",parcels:"parcelPane",roads:"boundaryPane",railroads:"boundaryPane",transmissionLines:"boundaryPane",substations:"boundaryPane",powerPlants:"boundaryPane",hifldTransmission:"boundaryPane",hifldSubstations:"boundaryPane",overlays:"overlayPane",drawnRegions:"overlayPane",wetlands:"overlayPane",floodZones:"overlayPane",hydrology:"overlayPane",schools:"overlayPane",walkability:"overlayPane",developments:"markersPane",existingProducts:"markersPane",searchMarker:"markersPane"},lt={};Ne.forEach(Qt=>{const Ft=Oe[Qt.id];if(Ft){const Gt=Lm(Qt.id,Ne);(!lt[Ft]||Gt>lt[Ft])&&(lt[Ft]=Gt)}});const pt=Math.min(lt.boundaryPane||350,369),It=Math.max(lt.parcelPane||650,650,pt+281),yt=Math.max(lt.overlayPane||700,700,It+50),at=Math.max(lt.markersPane||800,800,yt+100),Pt=Qt=>{var Ft;return(Ft=pe.current)==null?void 0:Ft.getPane(Qt)};Pt("boundaryPane")&&(Pt("boundaryPane").style.zIndex=String(pt)),Pt("parcelPane")&&(Pt("parcelPane").style.zIndex=String(It)),Pt("overlayPane")&&(Pt("overlayPane").style.zIndex=String(yt)),Pt("overlayBasePane")&&(Pt("overlayBasePane").style.zIndex=String(yt)),Pt("overlayParkingPane")&&(Pt("overlayParkingPane").style.zIndex=String(yt+150)),Pt("overlayBuildingPane")&&(Pt("overlayBuildingPane").style.zIndex=String(yt+300)),Pt("overlayParkingStripingPane")&&(Pt("overlayParkingStripingPane").style.zIndex=String(yt+320)),Pt("markersPane")&&(Pt("markersPane").style.zIndex=String(at)),Nt(Ne)},[]);k.useImperativeHandle(Pe,()=>({flyToLocation:(Ne,Oe,lt=18,pt)=>{const It=pe.current;It&&(It.flyTo([Ne,Oe],lt,{duration:1,easeLinearity:.5}),pt&&(ti.current&&window.clearTimeout(ti.current),Co.current&&It.hasLayer(Co.current)&&It.removeLayer(Co.current),ml({lat:Ne,lng:Oe,displayName:pt}),setTimeout(()=>{const yt=pe.current;if(!yt)return;const at=Bt.divIcon({className:"search-location-marker",html:`
803              <div class="relative cursor-pointer" id="search-marker-pin">
804                <div class="absolute -top-8 -left-4 w-8 h-8 bg-red-500 rounded-full border-4 border-white shadow-lg flex items-center justify-center animate-bounce hover:scale-110 transition-transform">
805                  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
806                    <path d="M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"/>
807                    <circle cx="12" cy="10" r="3"/>
808                  </svg>
809                </div>
810              </div>
811            `,iconSize:[0,0],iconAnchor:[0,0]}),Pt=Bt.marker([Ne,Oe],{icon:at,className:"search-location-marker"}).addTo(yt),Qt=`
812            <div class="p-2 min-w-[200px]">
813              <p class="font-medium text-sm mb-1">${pt.split(",")[0]}</p>
814              <p class="text-xs text-muted-foreground mb-3">${pt.split(",").slice(1,3).join(",")}</p>
815              <div class="flex flex-col gap-2">
816                <button id="create-dev-btn" class="flex items-center gap-2 w-full px-3 py-2 text-xs font-medium bg-amber-500/10 hover:bg-amber-500/20 text-amber-700 rounded-md transition-colors">
817                  <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="16" height="20" x="4" y="2" rx="2" ry="2"/><path d="M9 22v-4h6v4"/><path d="M8 6h.01"/><path d="M16 6h.01"/><path d="M12 6h.01"/><path d="M12 10h.01"/><path d="M12 14h.01"/><path d="M16 10h.01"/><path d="M16 14h.01"/><path d="M8 10h.01"/><path d="M8 14h.01"/></svg>
818                  Create Development Here
819                </button>
820                <button id="create-existing-btn" class="flex items-center gap-2 w-full px-3 py-2 text-xs font-medium bg-cyan-500/10 hover:bg-cyan-500/20 text-cyan-700 rounded-md transition-colors">
821                  <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
821<path d="m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7"/><path d="M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"/><path d="M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4"/><path d="M2 7h20"/><path d="M22 7v3a2 2 0 0 1-2 2v0a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12v0a2 2 0 0 1-2-2V7"/></svg>
822                  Create Existing Site Here
823                </button>
824                <a id="get-directions-btn" href="https://www.google.com/maps/dir/?api=1&destination=${Ne},${Oe}" target="_blank" rel="noopener noreferrer" class="flex items-center gap-2 w-full px-3 py-2 text-xs font-medium bg-blue-500/10 hover:bg-blue-500/20 text-blue-700 rounded-md transition-colors no-underline">
825                  <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polygon points="16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76"/></svg>
826                  Get Directions
827                </a>
828              </div>
829            </div>
830          `;Pt.bindPopup(Qt,{className:"search-marker-popup",closeButton:!0,autoPan:!1,closeOnClick:!1,autoClose:!1,pane:"popupsPane",maxWidth:250}),Pt.on("click",()=>{Pt.openPopup()}),Pt.on("popupopen",()=>{requestAnimationFrame(()=>{const Ft=document.getElementById("create-dev-btn"),Gt=document.getElementById("create-existing-btn");Ft&&(Ft.onclick=()=>{Pt.closePopup(),ie&&ie(Ne,Oe)}),Gt&&(Gt.onclick=()=>{Pt.closePopup(),de&&de(Ne,Oe)})})}),Co.current=Pt,requestAnimationFrame(()=>{yt.hasLayer(Pt)&&Pt.openPopup()}),ti.current=window.setTimeout(()=>{const Ft=pe.current;Ft!=null&&Ft.hasLayer(Pt)&&Ft.removeLayer(Pt),ml(null),Co.current=null},3e4)},1050)))},flyToMunicipality:(Ne,Oe,lt)=>{if(pe.current&&(Tn.current&&window.clearTimeout(Tn.current),qs.current&&pe.current.hasLayer(qs.current)&&pe.current.removeLayer(qs.current),pe.current.flyToBounds(Ne,{padding:[50,50],duration:1.2,maxZoom:14}),lt)){let pt=[];lt.type==="Polygon"?pt=lt.coordinates[0].map(yt=>[yt[1],yt[0]]):lt.type==="MultiPolygon"&&(pt=lt.coordinates.map(yt=>yt[0].map(at=>[at[1],at[0]])));const It=Bt.polygon(pt,{color:"#10b981",weight:4,opacity:1,fillColor:"#10b981",fillOpacity:.25,className:"municipality-highlight",pane:"markerPane"}).addTo(pe.current);qs.current=It,Tn.current=window.setTimeout(()=>{var yt;(yt=pe.current)!=null&&yt.hasLayer(It)&&pe.current.removeLayer(It),qs.current=null},8e3)}},getMapRef:()=>pe,openPolygonTools:Ne=>{Qo(Ne),Ri(!0)},startOverlayDrawing:Ne=>{jo(Ne),jn([]),bo(!0)}}),[ie,de,Qo,Ri]);const xs=Ne=>{Pn(Ne),localStorage.setItem("map-logo-size",Ne)},$s=Ne=>{xi(Ne),localStorage.setItem("map-logo-shape",Ne)},bn=()=>{xa(Ne=>{const Oe=!Ne;return localStorage.setItem("map-show-tenant-logos",String(Oe)),Oe})},da=()=>{Sa(Ne=>{const Oe=!Ne;return localStorage.setItem("map-show-crm-logos",String(Oe)),Oe})},wa=Ne=>{An(Ne),localStorage.setItem("map-icon-size",Ne)},Lr=Ne=>{Yr(Ne),localStorage.setItem("map-popup-density",Ne)};k.useCallback(()=>{pe.current&&(pe.current.eachLayer(Ne=>{if(Ne.getPopup){const Oe=Ne.getPopup();if(Oe&&Oe.isOpen()){const lt=Oe.getElement();(!lt||!lt.classList.contains("pinned-popup"))&&Ne.closePopup()}}}),Ve.success("Closed all unpinned popups"))},[]);const ur=k.useCallback(()=>{pe.current&&pe.current.zoomIn()},[]),si=k.useCallback(()=>{pe.current&&pe.current.zoomOut()},[]),Ei=k.useCallback(Ne=>{if(pe.current){const Oe=pe.current.getCenter();pe.current.flyTo(Oe,Ne,{duration:.5,easeLinearity:.25})}},[]),{data:hr}=dj(),{data:mo}=uj(),{developers:Ud}=Jx(),{owners:mc}=Qx(),_i=new Map(Ud.map(Ne=>[Ne.id,Ne])),sl=new Map(mc.map(Ne=>[Ne.id,Ne])),{data:Ba=[]}=Cp(),{data:xd=[]}=yj(),nl=ym(),so=pu(),Qc=Sp(),_d=IE(),ai=Dl&&Ba.find(Ne=>Ne.id===Dl)||null,eu=Xt&&Ba.find(Ne=>Ne.id===Xt)||null,Vr=Rs&&Ba.find(Ne=>Ne.id===Rs)||null,Fi=mb({selectedOverlay:eu,isActive:!!eu&&!Ki,onTransformComplete:()=>{}}),ri=mb({selectedOverlay:Vr,isActive:!!Vr&&!Ki,onTransformComplete:()=>{}}),vo=mb({selectedOverlay:ai,isActive:!!ai&&Ki,onTransformComplete:()=>{}});k.useCallback(()=>({x:window.innerWidth-120,y:160}),[]);const vu=k.useCallback(Ne=>{Mc.current=!0,Uo.current=Ne,Rr(Ne)},[]),tu=k.useCallback(()=>{la(null),Rr(null),ri.setTransformMode("none")},[ri]),bu=k.useCallback(Ne=>{const Oe=String(Ne.layer_type||Ne.type||"");return["building_footprint","building","warehouse","retail_building","office_building"].includes(Oe)?"build":["stormwater_detention","landscape_buffer","utility_corridor","perimeter_fencing","easement","fire_lane","site_lighting","site_amenity","erosion_control","grading","retaining_wall","trash_enclosure","monument_signage","hardscape","outdoor_storage","landscaping"].includes(Oe)?"site":["parking","parking_field","parking_zone","truck_court","trailer_parking"].includes(Oe)?"build":["property","site","lot","polygon"].includes(Oe)?"data":"build"},[]),Bh=k.useCallback((Ne,Oe)=>{if(Jl||hi!=="none")return;const lt=bu(Ne);fl(lt),Qo(Ne.id),Ri(!0),Rs&&(la(null),Rr(null))},[Jl,hi,Rs,bu,Qo,Ri]),p=k.useCallback(()=>{fr(!0),zl(null),Ve.info("Click on a building edge to toggle canopy placement")},[]),M=k.useCallback(()=>{fr(!1),zl(null),qe.current&&pe.current&&(pe.current.removeLayer(qe.current),qe.current=null),pe.current&&(pe.current.getContainer().style.cursor="")},[]);k.useEffect(()=>{var pt;if(!pe.current||!Fi.isTransforming)return;const Ne=pe.current;(pt=Ne.dragging)==null||pt.disable();const Oe=It=>{try{if(!Ne.getContainer())return;const yt=Ly(Ne,It);Fi.updateTransform({lat:yt.lat,lng:yt.lng})}catch{}},lt=()=>{Fi.endTransform()};return document.addEventListener("mousemove",Oe),document.addEventListener("mouseup",lt),()=>{var It;document.removeEventListener("mousemove",Oe),document.removeEventListener("mouseup",lt);try{(It=Ne.dragging)==null||It.enable()}catch{}}},[Fi.isTransforming,Fi.updateTransform,Fi.endTransform]),k.useEffect(()=>{var pt;if(!pe.current||!ri.isTransforming)return;const Ne=pe.current;(pt=Ne.dragging)==null||pt.disable();const Oe=It=>{try{if(!Ne.getContainer())return;const yt=Ly(Ne,It);ri.updateTransform({lat:yt.lat,lng:yt.lng})}catch{}},lt=()=>{ri.endTransform()};return document.addEventListener("mousemove",Oe),document.addEventListener("mouseup",lt),()=>{var It;document.removeEventListener("mousemove",Oe),document.removeEventListener("mouseup",lt);try{(It=Ne.dragging)==null||It.enable()}catch{}}},[ri.isTransforming,ri.updateTransform,ri.endTransform]),k.useEffect(()=>{var pt;if(!pe.current||!vo.isTransforming)return;const Ne=pe.current;(pt=Ne.dragging)==null||pt.disable();const Oe=It=>{try{if(!Ne.getContainer())return;const yt=Ly(Ne,It);vo.updateTransform({lat:yt.lat,lng:yt.lng})}catch{}},lt=()=>{vo.endTransform()};return document.addEventListener("mousemove",Oe),document.addEventListener("mouseup",lt),()=>{var It;document.removeEventListener("mousemove",Oe),document.removeEventListener("mouseup",lt);try{(It=Ne.dragging)==null||It.enable()}catch{}}},[vo.isTransforming,vo.updateTransform,vo.endTransform]),k.useEffect(()=>{if(!pe.current||!Jl||!ai)return;const Ne=pe.current,Oe=ai.geometry;if(!Oe||Oe.length<3)return;const lt=Oe.map(yt=>[yt.lng,yt.lat]);Ne.getContainer().style.cursor="crosshair";const pt=yt=>{const at=[yt.latlng.lng,yt.latlng.lat],Pt=l0(at,lt);zl(Pt);const Ft=PP(lt,Pt).geometry.coordinates.map(Gt=>[Gt[1],Gt[0]]);qe.current&&Ne.removeLayer(qe.current),qe.current=Bt.polyline(Ft,{color:"#78716c",weight:6,opacity:.9,dashArray:void 0}).addTo(Ne)},It=yt=>{const at=[yt.latlng.lng,yt.latlng.lat],Pt=l0(at,lt),Qt=ai.canopy_edge_indices||[];let Ft;Qt.includes(Pt)?Ft=Qt.filter(ms=>ms!==Pt):Ft=[...Qt,Pt];const Gt=Ft.length===0?null:Ft;so.mutate({id:ai.id,canopy_edge_indices:Gt}),Ve.success(Ft.length===0?"Canopy set to all edges":`Edge ${Pt} ${Qt.includes(Pt)?"removed":"added"}`),M()};return Ne.on("mousemove",pt),Ne.on("click",It),()=>{Ne.off("mousemove",pt),Ne.off("click",It),Ne.getContainer().style.cursor="",qe.current&&Ne.hasLayer(qe.current)&&(Ne.removeLayer(qe.current),qe.current=null)}},[Jl,ai,M,so]),k.useEffect(()=>{if(!pe.current||!Id||!Sl||!ai)return;const Ne=pe.current,Oe=lt=>{const pt=lt.latlng,It=ai.style||{},yt=Array.isArray(It.monument_signs)?[...It.monument_signs]:[],at=yt.findIndex(Pt=>Pt.id===Sl);at!==-1&&(yt[at]={...yt[at],position_lat:pt.lat,position_lng:pt.lng},so.mutate({id:ai.id,style:{...It,monument_signs:yt}}),Ve.success("Sign placed on map")),Hl(!1),gd(null)};return Ne.getContainer().style.cursor="crosshair",Ne.on("click",Oe),()=>{Ne.off("click",Oe),Ne.getContainer().style.cursor=""}},[Id,Sl,ai,so]),k.useEffect(()=>{if(!pe.current||!_o||!Xl||!ai)return;const Ne=pe.current,Oe=async lt=>{const pt=lt.latlng,It=ai.geometry;if(!It||It.length<3){Ve.error("Invalid parking zone geometry"),Yl(!1),pl(null);return}const{classifyEdgesForSetbackLabels:yt}=await br(async()=>{const{classifyEdgesForSetbackLabels:Ga}=await Promise.resolve().then(()=>f_);return{classifyEdgesForSetbackLabels:Ga}},void 0),{findNearestEdgeFromPoint:at}=await br(async()=>{const{findNearestEdgeFromPoint:Ga}=await Promise.resolve().then(()=>lp);return{findNearestEdgeFromPoint:Ga}},void 0),Pt=yt(It),Qt=at({lat:pt.lat,lng:pt.lng},It,Pt);if(!Qt){Ve.error("Could not determine nearest edge"),Yl(!1),pl(null);return}const Ft={main_entry:"Main Entry",service_entry:"Service Entry",emergency_access:"Emergency Access",fire_lane:"Fire Lane"},Gt={id:`entry-${Date.now()}`,type:Xl,name:Ft[Xl]||"Entry Point",width_ft:24,depth_ft:40,curb_cut_type:"standard",has_gate:!1,edge_label:Qt.edgeLabel,position_percent:Qt.positionPercent},ms=ai.style||{},Wt=ms.parkingCirculation||{},Ms=[...Array.isArray(Wt.entryPoints)?[...Wt.entryPoints]:[],Gt];let hn;
830if(ai.parent_overlay_id&&Ba){const Ga=Ba.find(Zi=>Zi.id===ai.parent_overlay_id);Ga!=null&&Ga.geometry&&Array.isArray(Ga.geometry)&&Ga.geometry.length>=3&&(hn=Ga.geometry)}const{autoMarkIntersectingStallsRemoved:Vn}=await br(async()=>{const{autoMarkIntersectingStallsRemoved:Ga}=await Promise.resolve().then(()=>t1);return{autoMarkIntersectingStallsRemoved:Ga}},void 0),{generateAllEntryPointPolygons:ka}=await br(async()=>{const{generateAllEntryPointPolygons:Ga}=await Promise.resolve().then(()=>lp);return{generateAllEntryPointPolygons:Ga}},void 0),{stallOverrides:Fa,removedCount:Er}=Vn(It,ms,{stallWidth_ft:ai.parking_stall_width_ft??9,stallDepth_ft:ai.parking_stall_depth_ft??18,aisleWidth_ft:ai.parking_aisle_width_ft??24,layoutType:ai.parking_layout_type||"double_loaded"},Ms,hn,ka);so.mutate({id:ai.id,style:{...ms,parkingCirculation:{...Wt,entryPoints:Ms,stallOverrides:Fa}}}),Er>0?Ve.success(`${Ft[Xl]||"Entry Point"} placed, ${Er} stalls auto-removed`):Ve.success(`${Ft[Xl]||"Entry Point"} placed on ${Qt.edgeLabel} edge`),Yl(!1),pl(null)};return Ne.getContainer().style.cursor="crosshair",Ne.on("click",Oe),()=>{Ne.off("click",Oe),Ne.getContainer().style.cursor=""}},[_o,Xl,ai,so]),k.useEffect(()=>{Hi(!1),Wr(null),Wl(null)},[Dl]);const{data:Y={}}=Z7(),{data:ue={}}=W7(),[Se,st]=k.useState(!1),[At,hs]=k.useState([]),[ws,Os]=k.useState(null),_n=k.useRef(null),Ta=k.useRef([]),yr=k.useRef(null),[cr,bo]=k.useState(!1),[zi,jo]=k.useState(null),[$a,jn]=k.useState([]),[Ou,xh]=k.useState(!1),Ac=k.useRef(null),Uc=k.useRef([]),[Dc,fo]=k.useState(!1),[Ua,vm]=k.useState(90),[_h,yh]=k.useState(!1),[Bu,Ad]=k.useState(!1),[Vf,Ym]=k.useState(null),[Tp,qf]=k.useState(null),[Gf,Hf]=k.useState(null),ed=k.useRef(null),no=k.useRef(null),[yi,$u]=k.useState(!1),[Vu,$h]=k.useState(0),[Vh,vh]=k.useState(0),[bh,yd]=k.useState(null),[wo,ea]=k.useState(null),[ia,qh]=k.useState(null),[Xm,Km]=k.useState(!1),[R,r]=k.useState(null),[g,S]=k.useState([]),E=Dt!==void 0,A=E?Dt??!1:Xm,ee=E?Rt??null:R,se=E?zt??[]:g,he=E?Ne=>{}:S,_e=k.useRef(null),Ie=k.useRef([]),Me=k.useRef(null),[Je,ut]=k.useState(null),[gt,St]=k.useState([]),[Lt,Vt]=k.useState(null),[Ht,Et]=k.useState(0),Kt=k.useRef(null),ss=k.useRef([]),cs=k.useRef(null),As=k.useRef(null),sn=k.useRef(null),pn=k.useRef(null),Ln=k.useRef(null),[Js,on]=k.useState([]),Hn=k.useRef(null),Ra=k.useRef([]),[ln,Nn]=k.useState(null),[aa,mi]=k.useState([]),er=k.useRef(null),Sr=k.useRef([]),Pi=k.useRef([]),[al,Dd]=k.useState(!1),[Ti,fc]=k.useState(90),[El,Ql]=k.useState({x:445,y:125}),[Ol,Rd]=k.useState(!1),[qu,Jm]=k.useState({x:0,y:0});k.useEffect(()=>{if(!Ol)return;const Ne=lt=>{const pt=lt.clientX-qu.x,It=lt.clientY-qu.y,yt=20;Ql({x:Math.max(yt,Math.min(window.innerWidth-yt,pt)),y:Math.max(yt,Math.min(window.innerHeight-yt,It))})},Oe=()=>{Rd(!1)};return window.addEventListener("mousemove",Ne),window.addEventListener("mouseup",Oe),()=>{window.removeEventListener("mousemove",Ne),window.removeEventListener("mouseup",Oe)}},[Ol,qu]);const Vo=k.useRef(null),Bl=k.useRef(null),[Zf,Wf]=k.useState(null),td="parcel-layer-visible",[vd,ju]=k.useState(()=>{try{return localStorage.getItem(td)==="true"}catch{return!1}}),Rc=1e3,$l="558222",[rl,Fc]=k.useState(!1),[qr,su]=k.useState(!1),[Gu,jh]=k.useState(""),[Yf,Xf]=k.useState(!1),{data:wh=0}=TT();k.useEffect(()=>{if(!pe.current||!Fl)return;const Ne=pe.current,Oe=pt=>{const It={lat:pt.latlng.lat,lng:pt.latlng.lng},yt=li.current;if(yt.length>=3){const at=yt[0],Pt=Ne.latLngToContainerPoint([at.lat,at.lng]),Qt=Ne.latLngToContainerPoint([It.lat,It.lng]);if(Pt.distanceTo(Qt)<15){const Gt=Ba.find(Wt=>Wt.id===Fl);if(Gt){const Wt=Gt.style||{},Ss=Wt.manualExclusionZones||[],Ms={id:crypto.randomUUID(),name:`Cutout ${Ss.length+1}`,geometry:[...yt],enabled:!0};so.mutate({id:Fl,style:{...Wt,manualExclusionZones:[...Ss,Ms]}}),Ve.success(`Cutout zone "${Ms.name}" added`)}const ms=Fl;li.current=[],Lc(null),Ne.getContainer().style.cursor="",Kl.current&&(Kl.current.remove(),Kl.current=null),Ia.current.forEach(Wt=>Wt.remove()),Ia.current=[],Qo(ms),Ri(!0);return}}yt.push(It),li.current=[...yt],Kl.current&&Kl.current.remove(),Ia.current.forEach(at=>at.remove()),Ia.current=[],yt.length>=2&&(Kl.current=Bt.polygon(yt.map(at=>[at.lat,at.lng]),{color:"#ef4444",fillColor:"#ef4444",fillOpacity:.2,weight:2,dashArray:"6, 4"}).addTo(Ne)),yt.forEach((at,Pt)=>{const Qt=Pt===0,Ft=Bt.circleMarker([at.lat,at.lng],{radius:Qt?7:5,fillColor:Qt?"#22c55e":"#ef4444",color:"#ffffff",weight:2,fillOpacity:1}).addTo(Ne);Qt&&yt.length>=3&&Ft.bindTooltip("Click to close",{permanent:!1,direction:"top"}),Ia.current.push(Ft)})};Ne.on("click",Oe);const lt=pt=>{pt.key==="Escape"&&(li.current=[],Lc(null),Ne.getContainer().style.cursor="",Kl.current&&(Kl.current.remove(),Kl.current=null),Ia.current.forEach(It=>
830It.remove()),Ia.current=[],Ve.info("Cutout drawing cancelled"))};return document.addEventListener("keydown",lt),()=>{Ne.off("click",Oe),document.removeEventListener("keydown",lt),Ne.getContainer().style.cursor=""}},[Fl,Ba,so]),HS();const sd=[],Lp=Gr>=17;k.useEffect(()=>{wh>=Rc&&!rl&&(Fc(!0),ju(!1),Ee&&(ve==null||ve()),Ve.warning(`Parcel limit reached (${Rc}). Parcel layer has been locked.`,{duration:5e3}))},[wh,rl,Ee,ve]),k.useCallback(()=>{if(rl){su(!0);return}ju(Ne=>{const Oe=!Ne;try{localStorage.setItem(td,String(Oe))}catch{}return Oe})},[rl]);const bm=k.useCallback(()=>{Gu===$l?(Fc(!1),su(!1),jh(""),Xf(!1),Ve.success("Parcel layer unlocked successfully")):Xf(!0)},[Gu]),[jm,Gh]=k.useState(0);k.useEffect(()=>{if(!Ct.current||pe.current)return;pe.current=Bt.map(Ct.current,{center:De,zoom:bt,maxZoom:21,zoomControl:!1,closePopupOnClick:!1,rotate:!0,touchRotate:!1,rotateControl:!1,bearing:0}),ys(!0);const Ne=uk(),Oe=pe.current.getPane("tilePane");Oe&&(Oe.style.zIndex="200",console.log("Set tilePane (base map) z-index to 200"));const lt=pe.current._rotatePane,pt=pe.current._norotatePane;pe.current.createPane("boundaryPane",lt);const It=Math.max(Lm("states",Ne),Lm("counties",Ne),Lm("municipalities",Ne),Lm("roads",Ne),350),yt=Math.min(It,369);pe.current.getPane("boundaryPane").style.zIndex=String(yt),pe.current.createPane("parcelPane",lt);const at=Math.max(Lm("parcels",Ne),380,yt+11);pe.current.getPane("parcelPane").style.zIndex=String(at),pe.current.createPane("parcelTilesPane",lt),pe.current.getPane("parcelTilesPane").style.zIndex=String(Math.max(at+100,520)),pe.current.createPane("overlayBasePane",lt);const Pt=Math.max(Lm("overlays",Ne),400,at+10);pe.current.getPane("overlayBasePane").style.zIndex=String(Pt),pe.current.createPane("overlayParkingPane",lt),pe.current.getPane("overlayParkingPane").style.zIndex=String(Pt+150),pe.current.createPane("overlayBuildingPane",lt),pe.current.getPane("overlayBuildingPane").style.zIndex=String(Pt+300),pe.current.createPane("overlayParkingStripingPane",lt),pe.current.getPane("overlayParkingStripingPane").style.zIndex=String(Pt+320),pe.current.createPane("overlayPane",lt);const Qt=Pt;pe.current.getPane("overlayPane").style.zIndex=String(Qt),pe.current.createPane("markersPane",pt);const Ft=Math.max(Lm("developments",Ne),Lm("existingProducts",Ne),800,Qt+100);pe.current.getPane("markersPane").style.zIndex=String(Ft),pe.current.createPane("tooltipsPane",pt),pe.current.getPane("tooltipsPane").style.zIndex="850",pe.current.createPane("setbackLabelsPane",pt),pe.current.getPane("setbackLabelsPane").style.zIndex="750",pe.current.createPane("measurementLabelsPane",pt),pe.current.getPane("measurementLabelsPane").style.zIndex="800",pe.current.createPane("popupsPane",pt),pe.current.getPane("popupsPane").style.zIndex="200000",pe.current.createPane("municipalityPopupPane",pt),pe.current.getPane("municipalityPopupPane").style.zIndex="200010";const Gt=xf[z]||xf.light;sa.current=Bt.tileLayer(Gt.url,{attribution:Gt.attribution,maxZoom:21,zIndex:0,pane:"tilePane",tileSize:Gt.tileSize||256,zoomOffset:Gt.tileSize===512?-1:0}).addTo(pe.current),sa.current.bringToBack();const ms=()=>{var hn,Vn,ka,Fa;const Wt=(hn=pe.current)==null?void 0:hn.getCenter(),Ss=(Vn=pe.current)==null?void 0:Vn.getZoom(),Ms=(ka=pe.current)==null?void 0:ka.getBounds();Wt&&Ss!==void 0&&(oi.current=[Wt.lat,Wt.lng],Tr.current=Ss,Za([Wt.lat,Wt.lng]),Xr(Ss),(Fa=Nh.current)==null||Fa.call(Nh,{lat:Wt.lat,lng:Wt.lng},Ss)),Ms&&Wf({minLat:Ms.getSouth(),maxLat:Ms.getNorth(),minLng:Ms.getWest(),maxLng:Ms.getEast()})};return pe.current.on("moveend",ms),pe.current.on("zoomend",ms),ms(),()=>{pe.current&&(pe.current.remove(),pe.current=null)}},[]);const Nh=k.useRef(ps);Nh.current=ps,k.useEffect(()=>{if(!pe.current)return;const Ne=()=>{const lt=pe.current;lt&&typeof lt.getBearing=="function"&&Gh(lt.getBearing()||0)},Oe=()=>{Ne(),Vo.current&&pe.current&&setTimeout(()=>{var pt,It;const lt=pe.current;lt&&(lt.invalidateSize(!1),(pt=sa.current)==null||pt.redraw(),(It=Pr.current)==null||It.redraw(),Vo.current&&(Vo.current.redraw(),Vo.current.bringToFront()))},50)};return pe.current.on("rotate",Ne),pe.current.on("rotateend",Oe),()=>{var lt,pt;(lt=pe.current)==null||lt.off("rotate",Ne),(pt=pe.current)==null||pt.off("rotateend",Oe)}},[]);const Hu=k.useCallback(()=>{const Ne=pe.current;if(!(!Ne||typeof Ne.setBearing!="function")&&!(!Ne._loaded||!Ne._mapPane))try{Ne.setBearing(0),Gh(0)}catch(Oe){console.warn("[Map] resetBearing failed:",Oe)}},[]),Zu=k.useCallback(Ne=>{const Oe=pe.current;if(!(!Oe||typeof Oe.setBearing!="function"||typeof Oe.getBearing!="function")&&!(!Oe._loaded||!Oe._mapPane))try{const pt=(Oe.getBearing()||0)+Ne;Oe.setBearing(pt),Gh(pt)}catch(lt){console.warn("[Map] rotateBearing failed:",lt)}},[]);k.useEffect(()=>{if(!pe.current)return;As.current&&(pe.current.removeLayer(As.current),As.current=null);const Ne=Oe=>{if(!(Oe!=null&&Oe.type)||!(Oe!=null&&Oe.coordinates)||!dt)return Oe;const lt=(()=>{var Gt,ms,Wt,Ss,Ms;try{return Oe.type==="Polygon"?(ms=(Gt=Oe.coordinates)==null?void 0:Gt[0])==null?void 0:ms[0]:Oe.type==="MultiPolygon"?(Ms=(Ss=(Wt=Oe.coordinates)==null?void 0:Wt[0])==null?void 0:Ss[0])==null?void 0:Ms[0]:null}catch{return null}})();if(!Array.isArray(lt)||lt.length<2)return Oe;const[pt,It]=lt,yt=(Gt,ms)=>{const Wt=Gt-dt.lat,Ss=ms-dt.lng;return Wt*Wt+Ss*Ss},at=yt(It,pt);if(!(yt(pt,It)<at))return Oe;const Ft=Gt=>Array.isArray(Gt)?Gt.length===2&&typeof Gt[0]=="number"&&typeof Gt[1]=="number"?[Gt[1],Gt[0]]:Gt.map(Ft):Gt;return{...Oe,coordinates:Ft(Oe.coordinates)}};if(Re){const Oe=Ne(Re),lt={type:"Feature",properties:{},geometry:Oe};pe.current.getPane("parcelPane")||pe.current.createPane("parcelPane"),pe.current.getPane("parcelPane").style.zIndex="650";try{As.current=Bt.geoJSON(lt,{style:{color:"#10b981",weight:3,opacity:1,fillColor:"#10b981",fillOpacity:.15,dashArray:"5, 5"}}).addTo(pe.current);const pt=sn.current!==Re,It=As.current.getBounds();It.isValid()&&pt&&pe.current.fitBounds(It,{padding:[50,50],maxZoom:18}),sn.current=Re}catch(pt){console.error("Failed to add parcel layer:",pt)}}else sn.current=null}
830,[Re,dt]),k.useEffect(()=>{if(!pe.current||(pn.current&&(pe.current.removeLayer(pn.current),pn.current=null),!qt||qt.length===0))return;pe.current.getPane("parcelPane")||(pe.current.createPane("parcelPane"),pe.current.getPane("parcelPane").style.zIndex="650"),pn.current=Bt.layerGroup().addTo(pe.current);const Ne=(Oe,lt,pt)=>{if(!(Oe!=null&&Oe.type)||!(Oe!=null&&Oe.coordinates)||!lt||!pt)return Oe;const It=(()=>{var Wt,Ss,Ms,hn,Vn;try{return Oe.type==="Polygon"?(Ss=(Wt=Oe.coordinates)==null?void 0:Wt[0])==null?void 0:Ss[0]:Oe.type==="MultiPolygon"?(Vn=(hn=(Ms=Oe.coordinates)==null?void 0:Ms[0])==null?void 0:hn[0])==null?void 0:Vn[0]:null}catch{return null}})();if(!Array.isArray(It)||It.length<2)return Oe;const[yt,at]=It,Pt=(Wt,Ss)=>{const Ms=Wt-lt,hn=Ss-pt;return Ms*Ms+hn*hn},Qt=Pt(at,yt);if(!(Pt(yt,at)<Qt))return Oe;const ms=Wt=>Array.isArray(Wt)?Wt.length===2&&typeof Wt[0]=="number"&&typeof Wt[1]=="number"?[Wt[1],Wt[0]]:Wt.map(ms):Wt;return{...Oe,coordinates:ms(Oe.coordinates)}};qt.forEach(Oe=>{var lt;if(Oe.geometry)try{const pt=Ne(Oe.geometry,Oe.lat,Oe.lng),It={type:"Feature",properties:{id:Oe.id},geometry:pt},yt=Bt.geoJSON(It,{style:{color:"#8b5cf6",weight:3,opacity:1,fillColor:"#8b5cf6",fillOpacity:.25,dashArray:"3, 3"}});(lt=pn.current)==null||lt.addLayer(yt)}catch(pt){console.warn("Failed to add assemblage parcel:",Oe.id,pt)}}),console.log(`[Assemblage] Rendered ${qt.length} highlighted parcels`)},[qt]);const Wu=k.useRef(null);k.useEffect(()=>{if(pe.current){if(Wu.current&&(pe.current.removeLayer(Wu.current),Wu.current=null),ze&&Ke){const Ne=Bt.divIcon({className:"parcel-loading-marker",html:`
831          <div style="
832            display: flex;
833            align-items: center;
834            justify-content: center;
835            width: 48px;
836            height: 48px;
837            background: rgba(16, 185, 129, 0.9);
838            border-radius: 50%;
839            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
840            animation: pulse 1.5s ease-in-out infinite;
841          ">
842            <div style="
843              width: 24px;
844              height: 24px;
845              border: 3px solid rgba(255, 255, 255, 0.3);
846              border-top-color: white;
847              border-radius: 50%;
848              animation: spin 0.8s linear infinite;
849            "></div>
850          </div>
851          <style>
852            @keyframes spin {
853              to { transform: rotate(360deg); }
854            }
855            @keyframes pulse {
856              0%, 100% { transform: scale(1); opacity: 1; }
857              50% { transform: scale(1.1); opacity: 0.8; }
858            }
859          </style>
860        `,iconSize:[48,48],iconAnchor:[24,24]});Wu.current=Bt.marker([Ke.lat,Ke.lng],{icon:Ne,pane:"markerPane"}).addTo(pe.current)}return()=>{Wu.current&&pe.current&&(pe.current.removeLayer(Wu.current),Wu.current=null)}}},[ze,Ke]);const[X0,Qm]=k.useState("none");k.useEffect(()=>{if(!pe.current){Qm("none");return}const Ne=J.parcels!==!1;if(!Ee||Gr<15||!Ne){Vo.current&&(console.log(`Removing parcel tile layer (mode: ${Ee}, zoom: ${Gr.toFixed(1)}, visible: ${Ne})`),pe.current.removeLayer(Vo.current),Vo.current=null),Qm("none");return}let Oe=pe.current.getPane("parcelTilesPane");if(Oe||(Oe=pe.current.createPane("parcelTilesPane"),Oe.style.zIndex="520",console.log("Created missing parcelTilesPane with z-index 520")),!Vo.current){const pt="https://ntrjyokaupvmnftawavp.supabase.co/functions/v1/parcel-tiles?x={x}&y={y}&z={z}";console.log(`Creating parcel tile layer (zoom: ${Gr.toFixed(1)}, url: ${pt})`),Vo.current=wV(pt,{minZoom:15,maxZoom:21,opacity:1,pane:"parcelTilesPane",attribution:'&copy; <a href="https://reportallusa.com">Report All USA</a>'}),Qm("created")}return Vo.current&&!pe.current.hasLayer(Vo.current)?(Vo.current.addTo(pe.current),Vo.current.bringToFront(),console.log("Added parcel tile layer from Report All USA (opacity: 1.0, pane: parcelTilesPane)"),Qm("on-map")):Vo.current&&pe.current.hasLayer(Vo.current)&&(Vo.current.bringToFront(),Qm("on-map")),()=>{}},[Ee,Gr,J]),k.useEffect(()=>{if(!pe.current||(Bl.current&&(pe.current.removeLayer(Bl.current),Bl.current=null),!Ee||!sd||sd.length===0))return;Bl.current=Bt.layerGroup();const Ne=Ee&&!A;
860sd.forEach(Oe=>{if(Oe.geometry)try{const lt={type:"Feature",properties:{apn:Oe.apn,address:Oe.address,owner:Oe.owner,parcelId:Oe.id},geometry:Oe.geometry},pt={color:"#0d9488",weight:2,opacity:.8,fillColor:"#0d9488",fillOpacity:.1},It={color:"#14b8a6",weight:3,opacity:1,fillColor:"#14b8a6",fillOpacity:.2},yt=Bt.geoJSON(lt,{style:pt,interactive:Ne});if(Ne){yt.on("mouseover",()=>{yt.setStyle(It)}),yt.on("mouseout",()=>{yt.setStyle(pt)}),yt.on("click",async Qt=>{Bt.DomEvent.stopPropagation(Qt);const Gt=yt.getBounds().getCenter();if(Fe&&ke){ke(Oe);return}const ms={id:Oe.id,apn:Oe.apn,address:Oe.address,owner:Oe.owner,owner_address:Oe.ownerAddress||null,acres:Oe.acres??null,sqft:Oe.sqft??null,land_use:Oe.landUse||null,zoning:Oe.zoning||null,year_built:Oe.yearBuilt??null,assessed_value:Oe.assessedValue??null,market_value:Oe.marketValue??null,tax_amount:null,geometry:Oe.geometry,lat:Gt.lat,lng:Gt.lng,source:Oe.source||"viewport-fetch",created_at:new Date().toISOString()};ra(ms);try{const Wt={apn:Oe.apn,address:Oe.address||null,owner:Oe.owner||null,owner_address:Oe.ownerAddress||null,acres:Oe.acres??null,sqft:Oe.sqft??null,land_use:Oe.landUse||null,zoning:Oe.zoning||null,year_built:Oe.yearBuilt??null,assessed_value:Oe.assessedValue??null,market_value:Oe.marketValue??null,geometry:Oe.geometry?JSON.parse(JSON.stringify(Oe.geometry)):null,lat:Gt.lat,lng:Gt.lng,source:Oe.source||"clicked"};await Fs.from("parcel_cache").upsert(Wt,{onConflict:"apn",ignoreDuplicates:!0}),je.invalidateQueries({queryKey:["cached-parcels"]})}catch(Wt){console.warn("Failed to cache clicked parcel:",Wt)}}),yt.on("contextmenu",Qt=>{var Ft;(Ft=pe.current)==null||Ft.fire("contextmenu",Qt)});const at=Oe.acres?Number(Oe.acres):Oe.sqft?Number(Oe.sqft)/43560:null,Pt=at?`${at.toFixed(2)} acres`:"";yt.bindTooltip(`<strong>${Oe.address||Oe.apn}</strong><br/>${Oe.owner||"Unknown owner"}${Pt?`<br/>${Pt}`:""}<br/><em class="text-xs">Click for details</em>`,{sticky:!0})}else{const at=Oe.acres?Number(Oe.acres):Oe.sqft?Number(Oe.sqft)/43560:null,Pt=at?`${at.toFixed(2)} acres`:"";yt.bindTooltip(`<strong>${Oe.address||Oe.apn}</strong><br/>${Oe.owner||"Unknown owner"}${Pt?`<br/>${Pt}`:""}`,{sticky:!0})}yt.addTo(Bl.current)}catch(lt){console.warn("Failed to render viewport parcel:",Oe.apn,lt)}}),Bl.current.addTo(pe.current)},[sd,Ee,A,Ze,ke,Fe]),k.useEffect(()=>{const Ne=Oe=>{if(Oe.target instanceof HTMLInputElement||Oe.target instanceof HTMLTextAreaElement)return;const lt=15,pt=5;switch(Oe.key){case"ArrowLeft":Oe.preventDefault(),Zu(Oe.shiftKey?-pt:-lt);break;case"ArrowRight":Oe.preventDefault(),Zu(Oe.shiftKey?pt:lt);break;case"Home":Oe.preventDefault(),Hu();break;case"d":case"D":Ee&&Gr>=16&&(Oe.preventDefault(),re(It=>{const yt=!It;return Ve.info(yt?"Parcel dimensions shown":"Parcel dimensions hidden",{duration:2e3}),yt}));break}};return window.addEventListener("keydown",Ne),()=>window.removeEventListener("keydown",Ne)},[Zu,Hu,Ee,Gr]),k.useEffect(()=>{if(!pe.current||(xe.current&&(xe.current.clearLayers(),pe.current.removeLayer(xe.current),xe.current=null),!G||!Ee||Gr<16))return;const Ne=pe.current.getBounds(),Oe=Ne.getSouth(),lt=Ne.getNorth(),pt=Ne.getWest(),It=Ne.getEast(),at=[...Ae.filter(Ft=>Ft.geometry&&Ft.lat>=Oe&&Ft.lat<=lt&&Ft.lng>=pt&&Ft.lng<=It).map(Ft=>({geometry:Ft.geometry,id:Ft.id})),...sd.filter(Ft=>Ft.geometry).map(Ft=>({geometry:Ft.geometry,id:Ft.id}))],Pt=new Set,Qt=at.filter(Ft=>Pt.has(Ft.id)?!1:(Pt.add(Ft.id),!0));if(Qt.length!==0)return xe.current=Bt.layerGroup(),Qt.forEach(Ft=>{if(!Ft.geometry)return;const Gt=cI(Ft.geometry);Gt&&Gt.forEach(ms=>{var hn;const Wt=ms.lengthFeet>=1e3?`${Math.round(ms.lengthFeet).toLocaleString()}'`:`${Math.round(ms.lengthFeet)}'`,Ss=Bt.divIcon({className:"parcel-dimension-label",html:`
861            <div style="
862              background: #1a1a2e;
863              color: #f8fafc;
864              padding: 4px 10px;
865              border-radius: 4px;
866              font-size: 13px;
867              font-weight: 700;
868              font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
869              letter-spacing: 0.5px;
870              white-space: nowrap;
871              transform: rotate(${ms.angle}deg);
872              pointer-events: none;
873              box-shadow: 0 2px 6px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.15);
874              text-shadow: 0 1px 2px rgba(0,0,0,0.5);
875            ">
876              ${Wt}
877            </div>
878          `,iconSize:[0,0],iconAnchor:[0,0]}),Ms=Bt.marker([ms.midpointLat,ms.midpointLng],{icon:Ss,interactive:!1,pane:"tooltipPane"});(hn=xe.current)==null||hn.addLayer(Ms)})}),xe.current.addTo(pe.current),()=>{xe.current&&pe.current&&(pe.current.removeLayer(xe.current),xe.current=null)}},[G,Ee,Gr,sd,Ae]);const bd=z==="dark"||z==="satellite";k.useEffect(()=>{if(!pe.current||Yi&&z==="satellite")return;sa.current&&sa.current.remove(),Pr.current&&(Pr.current.remove(),Pr.current=null),Nr.current&&(Nr.current.remove(),Nr.current=null);const Ne=xf[z];sa.current=Bt.tileLayer(Ne.url,{attribution:Ne.attribution,maxZoom:21,zIndex:0,pane:"tilePane",tileSize:Ne.tileSize||256,zoomOffset:Ne.tileSize===512?-1:0}).addTo(pe.current),sa.current.bringToBack(),Ne.labelsUrl&&(Pr.current=Bt.tileLayer(Ne.labelsUrl,{attribution:"",maxZoom:21,pane:"overlayPane",zIndex:1}).addTo(pe.current))},[z,Yi]),k.useEffect(()=>
878{if(pe.current&&!ui){if(Yi&&Si!==null){hl(!0),sa.current&&sa.current.remove(),Nr.current&&Nr.current.remove();const Ne=`https://wayback.maptiles.arcgis.com/arcgis/rest/services/world_imagery/wmts/1.0.0/default028mm/mapserver/tile/${Si}/{z}/{y}/{x}`;Nr.current=Bt.tileLayer(Ne,{attribution:"Tiles &copy; Esri — Source: Esri World Imagery Wayback",maxZoom:21,zIndex:0,pane:"tilePane"}).addTo(pe.current),Nr.current.bringToBack(),Nr.current.on("load",()=>{hl(!1)}),Nr.current.on("loading",()=>{hl(!0)}),!Pr.current&&xf.satellite.labelsUrl&&(Pr.current=Bt.tileLayer(xf.satellite.labelsUrl,{attribution:"",maxZoom:21,pane:"overlayPane",zIndex:1}).addTo(pe.current))}else if(!Yi&&Nr.current&&(Nr.current.remove(),Nr.current=null,hl(!1),z==="satellite")){const Ne=xf.satellite;sa.current=Bt.tileLayer(Ne.url,{attribution:Ne.attribution,maxZoom:21,zIndex:0,pane:"tilePane",tileSize:Ne.tileSize||256,zoomOffset:Ne.tileSize===512?-1:0}).addTo(pe.current),sa.current.bringToBack()}}},[Yi,Si,z,ui]),k.useEffect(()=>{if(!pe.current)return;const Ne=pe.current,Oe=Ne.getContainer();if(ui&&Gi&&kr){hl(!0),Nr.current&&(Nr.current.remove(),Nr.current=null),sa.current&&sa.current.remove(),mr.current&&mr.current.remove(),$r.current&&$r.current.remove();const lt=`https://wayback.maptiles.arcgis.com/arcgis/rest/services/world_imagery/wmts/1.0.0/default028mm/mapserver/tile/${kr}/{z}/{y}/{x}`;$r.current=Bt.tileLayer(lt,{attribution:"Esri World Imagery Wayback",maxZoom:21,zIndex:0}).addTo(Ne);const pt=`https://wayback.maptiles.arcgis.com/arcgis/rest/services/world_imagery/wmts/1.0.0/default028mm/mapserver/tile/${Gi}/{z}/{y}/{x}`;mr.current=Bt.tileLayer(pt,{attribution:"Esri World Imagery Wayback",maxZoom:21,zIndex:1}).addTo(Ne);let It=!1,yt=!1;const at=()=>{It&&yt&&hl(!1)};mr.current.on("load",()=>{It=!0,at()}),$r.current.on("load",()=>{yt=!0,at()});const Pt=mr.current.getContainer();if(Pt&&(Pt.style.clipPath=`inset(0 ${100-oa}% 0 0)`),!Jo.current){const Qt=document.createElement("div");Qt.className="satellite-comparison-divider",Qt.style.cssText=`
879          position: absolute;
880          top: 0;
881          bottom: 0;
882          width: 4px;
883          background: white;
884          box-shadow: 0 0 8px rgba(0,0,0,0.5);
885          cursor: ew-resize;
886          z-index: 1000;
887          left: ${oa}%;
888          transform: translateX(-50%);
889        `;const Ft=document.createElement("div");Ft.style.cssText=`
890          position: absolute;
891          top: 50%;
892          left: 50%;
893          transform: translate(-50%, -50%);
894          width: 32px;
895          height: 32px;
896          background: white;
897          border-radius: 50%;
898          box-shadow: 0 2px 8px rgba(0,0,0,0.3);
899          display: flex;
900          align-items: center;
901          justify-content: center;
902          font-size: 14px;
903        `,Ft.innerHTML="⇔",Qt.appendChild(Ft);const Gt=document.createElement("div");Gt.className="comparison-left-label",Gt.style.cssText=`
904          position: absolute;
905          top: 8px;
906          left: 8px;
907          background: hsl(217, 91%, 60%);
908          color: white;
909          padding: 4px 8px;
910          border-radius: 4px;
911          font-size: 12px;
912          font-weight: 600;
913          z-index: 1001;
914          pointer-events: none;
915        `,Gt.textContent=Br;const ms=document.createElement("div");ms.className="comparison-right-label",ms.style.cssText=`
916          position: absolute;
917          top: 8px;
918          right: 8px;
919          background: hsl(142, 76%, 36%);
920          color: white;
921          padding: 4px 8px;
922          border-radius: 4px;
923          font-size: 12px;
924          font-weight: 600;
925          z-index: 1001;
926          pointer-events: none;
927        `,ms.textContent=Nl,Oe.appendChild(Gt),Oe.appendChild(ms),Oe.appendChild(Qt),Jo.current=Qt;let Wt=!1;const Ss=Er=>{Wt=!0,Er.preventDefault()},Ms=Er=>{if(!Wt)return;const Ga=Oe.getBoundingClientRect(),Zi=Er.clientX-Ga.left,Po=Math.max(0,Math.min(100,Zi/Ga.width*100));Pa(Po)},hn=()=>{Wt=!1};Qt.addEventListener("mousedown",Ss),document.addEventListener("mousemove",Ms),document.addEventListener("mouseup",hn);const Vn=Er=>{Wt=!0,Er.preventDefault()},ka=Er=>{if(!Wt)return;const Ga=Oe.getBoundingClientRect(),Zi=Er.touches[0].clientX-Ga.left,Po=Math.max(0,Math.min(100,Zi/Ga.width*100));Pa(Po)},Fa=()=>{Wt=!1};Qt.addEventListener("touchstart",Vn),document.addEventListener("touchmove",ka),document.addEventListener("touchend",Fa)}}else ui||(mr.current&&(mr.current.remove(),mr.current=null),$r.current&&($r.current.remove(),$r.current=null),Jo.current&&(Jo.current.remove(),Jo.current=null),Oe.querySelectorAll(".comparison-left-label, .comparison-right-label").forEach(lt=>lt.remove()))},[ui,Gi,kr,Br,Nl]),k.useEffect(()=>{if(!ui||!mr.current||!Jo.current)return;const Ne=mr.current.getContainer();
927Ne&&(Ne.style.clipPath=`inset(0 ${100-oa}% 0 0)`),Jo.current.style.left=`${oa}%`},[oa,ui]);const Gg=k.useCallback(()=>{z!=="satellite"&&F("satellite"),jl(!0)},[z,F]),Um=k.useCallback(()=>{jl(!1),zo(null),Hr(""),Zr(!1),fn(null),nr(null)},[]),ef=k.useCallback((Ne,Oe)=>{zo(Ne),Hr(Oe)},[]),kh=k.useCallback(Ne=>{if(Zr(Ne),!Ne&&Si){const Oe=Si;zo(null),setTimeout(()=>zo(Oe),50)}},[Si]),wu=k.useCallback((Ne,Oe,lt,pt)=>{fn(Ne),nr(Oe),wl(lt),lr(pt)},[]);k.useEffect(()=>{if(!pe.current)return;const Ne="https://tigerweb.geo.census.gov/arcgis/services/TIGERweb/tigerWMS_Current/MapServer/WMSServer",Oe=pe.current;Oe.getPane("boundaryPane")||Oe.createPane("boundaryPane");const lt=Oe.getPane("boundaryPane");lt&&(lt.style.zIndex="520"),Oe.getPane("municipalityPopupPane")||Oe.createPane("municipalityPopupPane");const pt=Oe.getPane("municipalityPopupPane");pt&&(pt.style.zIndex="200010");const It="https://ntrjyokaupvmnftawavp.supabase.co",yt=(zn,Ja,En,pr,jt,Ys,dn)=>{var zs;const qn=rn.current[zn];if(Ja&&qn&&((zs=qn.options)==null?void 0:zs.pane)!=="boundaryPane"&&(qn.remove(),rn.current[zn]=null),Ja&&!rn.current[zn]){let mn;if(dn)mn=Bt.tileLayer.wms(En,{layers:pr,format:"image/png",transparent:!0,opacity:jt,pane:"boundaryPane",zIndex:1e3,className:""}).addTo(pe.current);else{const Xs=`${It}/functions/v1/wms-proxy?UPSTREAM=${encodeURIComponent(En)}`;mn=Bt.tileLayer.wms(Xs,{layers:pr,format:"image/png",transparent:!0,opacity:jt,pane:"boundaryPane",zIndex:1e3,className:"",uppercase:!0}).addTo(pe.current)}rn.current[zn]=mn}else!Ja&&rn.current[zn]&&(rn.current[zn].remove(),rn.current[zn]=null)},at=(zn,Ja,En,pr)=>{var Ys;const jt=rn.current[zn];Ja&&jt&&((Ys=jt.options)==null?void 0:Ys.pane)!=="boundaryPane"&&(jt.remove(),rn.current[zn]=null),Ja&&!rn.current[zn]?rn.current[zn]=Bt.tileLayer(En,{...pr,pane:"boundaryPane",zIndex:1e3}).addTo(pe.current):!Ja&&rn.current[zn]&&(rn.current[zn].remove(),rn.current[zn]=null)},Pt="https://cdn.jsdelivr.net/npm/us-atlas@3/states-10m.json",Qt=async(zn,Ja)=>{if(Ja&&!rn.current[zn])try{const En=await fetch(Pt);if(!En.ok){console.warn(`States TopoJSON returned ${En.status}`);return}const pr=await En.json(),jt=pr.objects.states,Ys=pr.arcs,dn=pr.transform,qn=nn=>{const xn=Ys[nn<0?~nn:nn],Zn=[];let ua=0,Ya=0;for(const Ea of xn){ua+=Ea[0],Ya+=Ea[1];const Mr=ua*dn.scale[0]+dn.translate[0],ao=Ya*dn.scale[1]+dn.translate[1];Zn.push([Mr,ao])}return nn<0&&Zn.reverse(),Zn},zs=nn=>
927{const xn=[];for(const Zn of nn){const ua=qn(Zn),Ya=xn.length>0?1:0;for(let Ea=Ya;Ea<ua.length;Ea++)xn.push(ua[Ea])}return xn},mn={"01":"Alabama","02":"Alaska","04":"Arizona","05":"Arkansas","06":"California","08":"Colorado","09":"Connecticut",10:"Delaware",11:"District of Columbia",12:"Florida",13:"Georgia",15:"Hawaii",16:"Idaho",17:"Illinois",18:"Indiana",19:"Iowa",20:"Kansas",21:"Kentucky",22:"Louisiana",23:"Maine",24:"Maryland",25:"Massachusetts",26:"Michigan",27:"Minnesota",28:"Mississippi",29:"Missouri",30:"Montana",31:"Nebraska",32:"Nevada",33:"New Hampshire",34:"New Jersey",35:"New Mexico",36:"New York",37:"North Carolina",38:"North Dakota",39:"Ohio",40:"Oklahoma",41:"Oregon",42:"Pennsylvania",44:"Rhode Island",45:"South Carolina",46:"South Dakota",47:"Tennessee",48:"Texas",49:"Utah",50:"Vermont",51:"Virginia",53:"Washington",54:"West Virginia",55:"Wisconsin",56:"Wyoming",60:"American Samoa",66:"Guam",69:"Northern Mariana Islands",72:"Puerto Rico",78:"U.S. Virgin Islands"},Xs=[];for(const nn of jt.geometries){const xn=nn.id,Zn=mn[xn]||`State ${xn}`;let ua;if(nn.type==="Polygon")ua={type:"Polygon",coordinates:nn.arcs.map(Ya=>zs(Ya))};else if(nn.type==="MultiPolygon")ua={type:"MultiPolygon",coordinates:nn.arcs.map(Ya=>Ya.map(Ea=>zs(Ea)))};else continue;Xs.push({type:"Feature",properties:{NAME:Zn,GEOID:xn},geometry:ua})}if(Xs.length===0){console.warn("No states found in TopoJSON");return}const Bs=Bt.layerGroup(),Dn=Bt.layerGroup(),gn=K.states??.85,un="#6366f1",Qn=Bt.geoJSON({type:"FeatureCollection",features:Xs},{pane:"boundaryPane",style:()=>({color:un,weight:2.5,opacity:gn,fillOpacity:gn*.05,dashArray:"8, 4"}),onEachFeature:(nn,xn)=>{const Zn=nn.properties||{},ua=Zn.NAME||"State",Ya=Zn.GEOID?` (${Zn.GEOID})`:"";if(xn.bindPopup(ld(ua,`<span class="text-xs text-muted-foreground">FIPS${Ya}</span>`,"🗺️"),od),xn.on("contextmenu",Ea=>{var Mr;(Mr=pe.current)==null||Mr.fire("contextmenu",Ea)}),nn.geometry&&(nn.geometry.type==="Polygon"||nn.geometry.type==="MultiPolygon")){const Mr=xn.getBounds().getCenter(),ao=bd?"rgba(50, 50, 50, 0.9)":"rgba(255, 255, 255, 0.95)",Oc=bd?"white":"#1e1b4b",ku=Bt.divIcon({className:"state-boundary-label",html:`<div style="
928                    background: ${ao};
929                    color: ${Oc};
930                    padding: 4px 10px;
931                    border-radius: 4px;
932                    font-size: 11px;
933                    font-weight: 600;
934                    white-space: nowrap;
935                    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
936                    text-align: center;
937                    opacity: ${gn};
938                    border-left: 4px solid ${un};
939                    letter-spacing: 0.5px;
940                  ">${ua}</div>`,iconSize:[0,0],iconAnchor:[0,0]}),au=Bt.marker(Mr,{icon:ku,interactive:!1});Dn.addLayer(au)}}});Bs.addLayer(Qn),Bs.addTo(pe.current),pe.current.getZoom()>=5&&Dn.addTo(pe.current);const Wa=()=>{var xn,Zn,ua;const nn=((xn=pe.current)==null?void 0:xn.getZoom())??0;nn>=5&&!((Zn=pe.current)!=null&&Zn.hasLayer(Dn))?Dn.addTo(pe.current):nn<5&&((ua=pe.current)!=null&&ua.hasLayer(Dn))&&Dn.remove()};pe.current.on("zoomend",Wa),rn.current[zn]={mainGroup:Bs,labelsGroup:Dn,cleanup:()=>{var nn;(nn=pe.current)==null||nn.off("zoomend",Wa),Bs.remove(),Dn.remove()}}}catch(En){console.warn("Failed to load states GeoJSON:",En)}else if(!Ja&&rn.current[zn]){const En=rn.current[zn];En!=null&&En.cleanup&&En.cleanup(),rn.current[zn]=null}},Ft=J.states!==!1;Qt("statesGeoJson",D.states&&Ft);const Gt="https://cdn.jsdelivr.net/npm/us-atlas@3/counties-10m.json",ms=async(zn,Ja)=>{var En;if(Ja&&!rn.current[zn])try{const pr=await fetch(Gt);if(!pr.ok){console.warn(`Counties TopoJSON returned ${pr.status}`);return}const jt=await pr.json(),Ys=jt.objects.counties,dn=jt.arcs,qn=jt.transform,zs=nn=>{const xn=dn[nn<0?~nn:nn],Zn=[];let ua=0,Ya=0;for(const Ea of xn){ua+=Ea[0],Ya+=Ea[1];const Mr=ua*qn.scale[0]+qn.translate[0],ao=Ya*qn.scale[1]+qn.translate[1];Zn.push([Mr,ao])}return nn<0&&Zn.reverse(),Zn},mn=nn=>{const xn=[];for(const Zn of nn){const ua=zs(Zn),Ya=xn.length>0?1:0;for(let Ea=Ya;Ea<ua.length;Ea++)xn.push(ua[Ea])}return xn},Xs=[];for(const nn of Ys.geometries){const xn=nn.id,Zn=((En=nn.properties)==null?void 0:En.name)||`County ${xn}`;let ua;if(nn.type==="Polygon")ua={type:"Polygon",coordinates:nn.arcs.map(Ya=>mn(Ya))};else if(nn.type==="MultiPolygon")ua={type:"MultiPolygon",coordinates:nn.arcs.map(Ya=>Ya.map(Ea=>mn(Ea)))};else continue;
940Xs.push({type:"Feature",properties:{NAME:Zn,GEOID:xn},geometry:ua})}if(Xs.length===0){console.warn("No counties found in TopoJSON");return}const Bs=Bt.layerGroup(),Dn=Bt.layerGroup(),gn=K.counties??.8,un="#0891b2",Qn=Bt.geoJSON({type:"FeatureCollection",features:Xs},{pane:"boundaryPane",style:()=>({color:un,weight:1.5,opacity:gn,fillOpacity:gn*.03}),onEachFeature:(nn,xn)=>{const Zn=nn.properties||{},ua=Zn.NAME||"County",Ya=Zn.GEOID?` (FIPS: ${Zn.GEOID})`:"";if(xn.bindPopup(ld(ua,`<span class="text-xs text-muted-foreground">${Ya}</span>`,"🏛️"),od),xn.on("contextmenu",Ea=>{var Mr;(Mr=pe.current)==null||Mr.fire("contextmenu",Ea)}),nn.geometry&&(nn.geometry.type==="Polygon"||nn.geometry.type==="MultiPolygon")){const Mr=xn.getBounds().getCenter(),ao=bd?"rgba(50, 50, 50, 0.85)":"rgba(255, 255, 255, 0.9)",Oc=bd?"white":"#164e63",ku=Bt.divIcon({className:"county-boundary-label",html:`<div style="
941                    background: ${ao};
942                    color: ${Oc};
943                    padding: 2px 6px;
944                    border-radius: 3px;
945                    font-size: 9px;
946                    font-weight: 500;
947                    white-space: nowrap;
948                    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
949                    text-align: center;
950                    opacity: ${gn};
951                    border-left: 3px solid ${un};
952                  ">${ua}</div>`,iconSize:[0,0],iconAnchor:[0,0]}),au=Bt.marker(Mr,{icon:ku,interactive:!1});Dn.addLayer(au)}}});Bs.addLayer(Qn),Bs.addTo(pe.current),pe.current.getZoom()>=8&&Dn.addTo(pe.current);const Wa=()=>{var xn,Zn,ua;const nn=((xn=pe.current)==null?void 0:xn.getZoom())??0;nn>=8&&!((Zn=pe.current)!=null&&Zn.hasLayer(Dn))?Dn.addTo(pe.current):nn<8&&((ua=pe.current)!=null&&ua.hasLayer(Dn))&&Dn.remove()};pe.current.on("zoomend",Wa),rn.current[zn]={mainGroup:Bs,labelsGroup:Dn,cleanup:()=>{var nn;(nn=pe.current)==null||nn.off("zoomend",Wa),Bs.remove(),Dn.remove()}}}catch(pr){console.warn("Failed to load counties GeoJSON:",pr)}else if(!Ja&&rn.current[zn]){const pr=rn.current[zn];pr!=null&&pr.cleanup&&pr.cleanup(),rn.current[zn]=null}},Wt=D.counties&&J.counties!==!1;ms("countiesGeoJson",Wt),yt("cities",D.cities,Ne,"28,29",.75);const Ss="https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/Tracts_Blocks/MapServer";(async(zn,Ja)=>{if(Ja&&!rn.current[zn])try{const En=pe.current.getBounds(),pr=pe.current.getZoom();if(pr<10){console.log("Census tracts require zoom >= 10");return}const jt=`${En.getWest()},${En.getSouth()},${En.getEast()},${En.getNorth()}`,Ys=`${Ss}/8/query?where=1=1&geometry=${encodeURIComponent(jt)}&geometryType=esriGeometryEnvelope&inSR=4326&spatialRel=esriSpatialRelIntersects&outFields=BASENAME,NAME,GEOID,TRACTCE&f=geojson`,dn=await fetch(Ys);if(!dn.ok){console.warn(`Census tracts returned ${dn.status}`);return}const qn=await dn.json();if(!qn.features||qn.features.length===0){console.warn("No census tracts found in current view");return}const zs=Bt.layerGroup(),mn=Bt.layerGroup(),Xs=K.boundaries??.65,Bs=Bt.geoJSON(qn,{pane:"boundaryPane",style:()=>({color:"#7b2cbf",weight:1.5,opacity:Xs,fillOpacity:Xs*.08,fillColor:"#7b2cbf"}),onEachFeature:(un,Qn)=>{const ar=un.properties||{},Wa=ar.NAME||ar.BASENAME||ar.TRACTCE||"Unknown",nn=ar.GEOID||"",xn=nn?`<span class="text-xs text-muted-foreground">GEOID: ${nn}</span>`:"";if(Qn.bindPopup(ld(`Census Tract ${Wa}`,xn,"📊"),od),un.geometry&&pr>=12){const Zn=Bt.geoJSON(un).getBounds().getCenter(),ua=bd?"rgba(50, 50, 50, 0.85)":"rgba(255, 255, 255, 0.9)",Ya=bd?"white":"black",Ea=Bt.divIcon({className:"census-tract-label",html:`<div style="
953                    background: ${ua};
954                    color: ${Ya};
955                    padding: 2px 6px;
956                    border-radius: 3px;
957                    font-size: 10px;
958                    font-weight: 500;
959                    white-space: nowrap;
960                    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
961                    border-left: 2px solid #7b2cbf;
962                    opacity: ${Xs};
963                  ">${Wa}</div>`,iconSize:[0,0],iconAnchor:[0,0]}),Mr=Bt.marker(Zn,{icon:Ea,interactive:!1});mn.addLayer(Mr)}}});zs.addLayer(Bs),zs.addTo(pe.current),pr>=12&&mn.addTo(pe.current);const Dn=()=>{var Qn,ar,Wa;const un=((Qn=pe.current)==null?void 0:Qn.getZoom())??0;un>=12&&!((ar=pe.current)!=null&&ar.hasLayer(mn))?mn.addTo(pe.current):un<12&&((Wa=pe.current)!=null&&Wa.hasLayer(mn))&&mn.remove()},gn=async()=>{var Qn,ar;if((((Qn=pe.current)==null?void 0:Qn.getZoom())??0)<10){zs.clearLayers(),mn.clearLayers();return}try{const Wa=pe.current.getBounds(),nn=`${Wa.getWest()},${Wa.getSouth()},${Wa.getEast()},${Wa.getNorth()}`,xn=`${Ss}/8/query?where=1=1&geometry=${encodeURIComponent(nn)}&geometryType=esriGeometryEnvelope&inSR=4326&spatialRel=esriSpatialRelIntersects&outFields=BASENAME,NAME,GEOID,TRACTCE&f=geojson`,Zn=await fetch(xn);if(!Zn.ok)return;const ua=await Zn.json();if(!((ar=ua.features)!=null&&ar.length))return;zs.clearLayers(),mn.clearLayers();const Ya=K.boundaries??.65,Ea=Bt.geoJSON(ua,{pane:"boundaryPane",style:()=>({color:"#7b2cbf",weight:1.5,opacity:Ya,fillOpacity:Ya*.08,fillColor:"#7b2cbf"}),onEachFeature:(Mr,ao)=>{var vi;const Oc=Mr.properties||{},ku=Oc.NAME||Oc.BASENAME||Oc.TRACTCE||"Unknown",au=Oc.GEOID||"",Qa=au?`<span class="text-xs text-muted-foreground">GEOID: ${au}</span>`:"";if(ao.bindPopup(ld(`Census Tract ${ku}`,Qa,"📊"),od),Mr.geometry&&(((vi=pe.current)==null?void 0:vi.getZoom())??0)>=12){const qo=Bt.geoJSON(Mr).getBounds().getCenter(),No=bd?"rgba(50, 50, 50, 0.85)":"rgba(255, 255, 255, 0.9)",ec=bd?"white":"black",Ju=Bt.divIcon({className:"census-tract-label",html:`<div style="
964                        background: ${No};
965                        color: ${ec};
966                        padding: 2px 6px;
967                        border-radius: 3px;
968                        font-size: 10px;
969                        font-weight: 500;
970                        white-space: nowrap;
971                        box-shadow: 0 1px 3px rgba(0,0,0,0.2);
972                        border-left: 2px solid #7b2cbf;
973                        opacity: ${Ya};
974                      ">${ku}</div>`,iconSize:[0,0],iconAnchor:[0,0]}),Tl=Bt.marker(qo,{icon:Ju,interactive:!1});mn.addLayer(Tl)}}});zs.addLayer(Ea)}catch(Wa){console.warn("Failed to update census tracts:",Wa)}};pe.current.on("zoomend",Dn),pe.current.on("moveend",gn),rn.current[zn]={mainGroup:zs,labelsGroup:mn,cleanup:()=>{var un,Qn;(un=pe.current)==null||un.off("zoomend",Dn),(Qn=pe.current)==null||Qn.off("moveend",gn),zs.remove(),mn.remove()}}}catch(En){console.error("Failed to load census tracts:",En)}else if(!Ja&&rn.current[zn]){const En=rn.current[zn];En!=null&&En.cleanup&&En.cleanup(),rn.current[zn]=null}})("censusTracks",D.censusTracks);const hn="https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/School/MapServer";(async(zn,Ja)=>
974{if(Ja&&!rn.current[zn])try{const En=pe.current.getBounds(),pr=`${En.getWest()},${En.getSouth()},${En.getEast()},${En.getNorth()}`,jt=[{id:0,type:"Unified School District",color:"#2563eb"},{id:1,type:"Secondary School District",color:"#16a34a"},{id:2,type:"Elementary School District",color:"#f97316"}],Ys=await Promise.all(jt.map(async gn=>{const un=`${hn}/${gn.id}/query?where=1=1&geometry=${encodeURIComponent(pr)}&geometryType=esriGeometryEnvelope&inSR=4326&spatialRel=esriSpatialRelIntersects&outFields=BASENAME,NAME,GEOID,LSADC&f=geojson`,Qn=await fetch(un);if(!Qn.ok)return console.warn(`School layer ${gn.id} returned ${Qn.status}`),null;const ar=await Qn.json();return!ar.features||ar.features.length===0?null:(ar.features.forEach(Wa=>{Wa.properties=Wa.properties||{},Wa.properties.__districtType=gn.type,Wa.properties.__districtColor=gn.color}),ar)})),dn=[];if(Ys.forEach(gn=>{gn&&gn.features&&dn.push(...gn.features)}),dn.length===0){console.warn("No school districts found in current view");return}const qn=Bt.layerGroup(),zs=Bt.layerGroup(),mn=K.schoolDistricts??.75,Xs=Bt.geoJSON({type:"FeatureCollection",features:dn},{pane:"boundaryPane",style:gn=>({color:gn.properties.__districtColor||"#0f766e",weight:1.5,opacity:mn,fillOpacity:mn*.1}),onEachFeature:(gn,un)=>{const Qn=gn.properties||{},ar=Qn.BASENAME||Qn.NAME||"School District",Wa=Qn.__districtType||"School District",nn=Qn.GEOID?` (${Qn.GEOID})`:"",xn=Qn.__districtColor||"#0f766e";if(un.bindPopup(ld(ar,`<span class="text-xs text-muted-foreground">${Wa}${nn}</span>`,"🏫"),od),un.on("contextmenu",Zn=>{var ua;(ua=pe.current)==null||ua.fire("contextmenu",Zn)}),gn.geometry&&(gn.geometry.type==="Polygon"||gn.geometry.type==="MultiPolygon")){const ua=un.getBounds().getCenter(),Ya=bd?"rgba(50, 50, 50, 0.85)":"rgba(255, 255, 255, 0.9)",Ea=bd?"white":"black",Mr=Bt.divIcon({className:"school-district-label",html:`<div style="
975                      background: ${Ya};
976                      color: ${Ea};
977                      padding: 3px 8px;
978                      border-radius: 4px;
979                      font-size: 10px;
980                      font-weight: 500;
981                      white-space: nowrap;
982                      box-shadow: 0 1px 4px rgba(0,0,0,0.3);
983                      text-align: center;
984                      opacity: ${mn};
985                      border-left: 3px solid ${xn};
986                    ">${ar}</div>`,iconSize:[0,0],iconAnchor:[0,0]}),ao=Bt.marker(ua,{icon:Mr,interactive:!1});zs.addLayer(ao)}}});qn.addLayer(Xs),qn.addTo(pe.current),pe.current.getZoom()>=10&&zs.addTo(pe.current);const Dn=()=>{var un,Qn,ar;const gn=((un=pe.current)==null?void 0:un.getZoom())??0;gn>=10&&!((Qn=pe.current)!=null&&Qn.hasLayer(zs))?zs.addTo(pe.current):gn<10&&((ar=pe.current)!=null&&ar.hasLayer(zs))&&zs.remove()};pe.current.on("zoomend",Dn),rn.current[zn]={mainGroup:qn,labelsGroup:zs,cleanup:()=>{var gn;(gn=pe.current)==null||gn.off("zoomend",Dn),qn.remove(),zs.remove()}}}catch(En){console.warn("Failed to load school districts:",En)}else if(!Ja&&rn.current[zn]){const En=rn.current[zn];En!=null&&En.cleanup?En.cleanup():En!=null&&En.remove&&En.remove(),rn.current[zn]=null}})("schoolDistricts",D.schoolDistricts);const ka=async(zn,Ja)=>{var jt;const En=async()=>{if(!pe.current)return;const Ys=pe.current.getBounds(),dn=`${Ys.getWest()},${Ys.getSouth()},${Ys.getEast()},${Ys.getNorth()}`,qn=`https://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/tigerWMS_Current/MapServer/2/query?geometry=${encodeURIComponent(dn)}&geometryType=esriGeometryEnvelope&inSR=4326&outSR=4326&spatialRel=esriSpatialRelIntersects&outFields=ZCTA5,GEOID&f=geojson&resultRecordCount=500`,zs=await fetch(qn);
986if(!zs.ok)throw new Error("Failed to fetch ZIP codes");return await zs.json()},pr=Ys=>{var Dn;if(!pe.current||!((Dn=Ys==null?void 0:Ys.features)!=null&&Dn.length))return;const dn=rn.current[zn];dn!=null&&dn.mainGroup&&(dn.mainGroup.clearLayers(),dn.labelsGroup.clearLayers());const qn=(dn==null?void 0:dn.mainGroup)||Bt.layerGroup(),zs=(dn==null?void 0:dn.labelsGroup)||Bt.layerGroup(),mn=K.boundaries??.75,Xs=Bt.geoJSON(Ys,{pane:"boundaryPane",style:()=>({color:"#10b981",weight:1.5,opacity:mn,fillOpacity:mn*.1}),onEachFeature:(gn,un)=>{const Qn=gn.properties||{},ar=Qn.ZCTA5||Qn.GEOID||"Unknown";if(un.bindPopup(ld(`ZIP Code: ${ar}`,"","📮"),od),un.on("contextmenu",Wa=>{var nn;(nn=pe.current)==null||nn.fire("contextmenu",Wa)}),gn.geometry&&(gn.geometry.type==="Polygon"||gn.geometry.type==="MultiPolygon")){const nn=un.getBounds().getCenter(),xn=bd?"rgba(50, 50, 50, 0.85)":"rgba(255, 255, 255, 0.9)",Zn=bd?"white":"black",ua=Bt.divIcon({className:"zip-code-label",html:`<div style="
987                  background: ${xn};
988                  color: ${Zn};
989                  padding: 3px 8px;
990                  border-radius: 4px;
991                  font-size: 11px;
992                  font-weight: 600;
993                  white-space: nowrap;
994                  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
995                  text-align: center;
996                  opacity: ${mn};
997                  border-left: 3px solid #10b981;
998                ">${ar}</div>`,iconSize:[0,0],iconAnchor:[0,0]}),Ya=Bt.marker(nn,{icon:ua,interactive:!1});zs.addLayer(Ya)}}});qn.addLayer(Xs),pe.current.hasLayer(qn)||qn.addTo(pe.current);const Bs=pe.current.getZoom();return Bs>=10&&!pe.current.hasLayer(zs)?zs.addTo(pe.current):Bs<10&&pe.current.hasLayer(zs)&&zs.remove(),{mainGroup:qn,labelsGroup:zs}};if(Ja&&!rn.current[zn])try{const Ys=await En();if(!((jt=Ys==null?void 0:Ys.features)!=null&&jt.length)){console.warn("No ZIP codes found in current view");return}const{mainGroup:dn,labelsGroup:qn}=pr(Ys)||{};if(!dn||!qn)return;const zs=()=>{var Bs,Dn,gn;const Xs=((Bs=pe.current)==null?void 0:Bs.getZoom())??0;Xs>=10&&!((Dn=pe.current)!=null&&Dn.hasLayer(qn))?qn.addTo(pe.current):Xs<10&&((gn=pe.current)!=null&&gn.hasLayer(qn))&&qn.remove()},mn=async()=>{var Xs;try{const Bs=await En();(Xs=Bs==null?void 0:Bs.features)!=null&&Xs.length&&pr(Bs)}catch(Bs){console.warn("Failed to update ZIP codes on move:",Bs)}};pe.current.on("zoomend",zs),pe.current.on("moveend",mn),rn.current[zn]={mainGroup:dn,labelsGroup:qn,cleanup:()=>{var Xs,Bs;(Xs=pe.current)==null||Xs.off("zoomend",zs),(Bs=pe.current)==null||Bs.off("moveend",mn),dn.remove(),qn.remove()}}}catch(Ys){console.warn("Failed to load ZIP codes:",Ys)}else if(!Ja&&rn.current[zn]){const Ys=rn.current[zn];Ys!=null&&Ys.cleanup?Ys.cleanup():Ys!=null&&Ys.remove&&Ys.remove(),rn.current[zn]=null}},Fa=J.zipCodes!==!1;ka("zipCodes",D.zipCodes&&Fa);const Er=async(zn,Ja)=>{var mn;const En=window.__fetchedMunicIds||new Set;window.__fetchedMunicIds=En;let pr=!1;const jt=async(Xs=!1)=>{var gn;if(!pe.current||pr)return null;pr=!0,Oo(!0);const Bs=pe.current.getBounds(),Dn={minLng:Bs.getWest(),minLat:Bs.getSouth(),maxLng:Bs.getEast(),maxLat:Bs.getNorth()};console.log(`Fetching municipalities for viewport: [${Dn.minLng.toFixed(4)},${Dn.minLat.toFixed(4)},${Dn.maxLng.toFixed(4)},${Dn.maxLat.toFixed(4)}]`);try{const un=await Fs.functions.invoke("fetch-boundaries",{body:{boundaryType:"municipalities",bbox:Dn}});if(un.error)throw new Error(un.error.message||"Failed to fetch municipalities");const Qn=un.data;if(!((gn=Qn==null?void 0:Qn.features)!=null&&gn.length))return console.log("No municipalities in current viewport"),pr=!1,null;const ar=Qn.features.filter(Wa=>{var xn,Zn;const nn=((xn=Wa.properties)==null?void 0:xn.FIPS_MUN_CODE)||((Zn=Wa.properties)==null?void 0:Zn.MUNICIPAL_NAME);return En.has(nn)?!1:(En.add(nn),!0)});return console.log(`Fetched ${Qn.features.length} municipalities, ${ar.length} new`),Ar(En.size),pr=!1,Oo(!1),{...Qn,features:ar}}catch(un){return console.error("Failed to fetch municipalities:",un),pr=!1,Oo(!1),null}};let Ys=null;const dn=Xs=>{switch(Xs){case"Township":return"#f59e0b";
998case"Borough":return"#fb923c";case"City":return"#dc2626";default:return"#f59e0b"}},qn=Xs=>{switch(Xs){case"Township":return"6, 4";case"Borough":return;case"City":return;default:return"6, 4"}},zs=(Xs,Bs)=>{var ar,Wa;if(console.log("renderMunicipalities called with",(ar=Xs==null?void 0:Xs.features)==null?void 0:ar.length,"features"),!pe.current||!((Wa=Xs==null?void 0:Xs.features)!=null&&Wa.length))return console.log("renderMunicipalities early return - no map or no features"),Bs;const Dn=(Bs==null?void 0:Bs.mainGroup)||Bt.layerGroup(),gn=(Bs==null?void 0:Bs.labelsGroup)||Bt.layerGroup(),un=K.municipalities??.75;Ys||(Ys=Bt.geoJSON(void 0,{pane:"boundaryPane",style:nn=>{var Zn;const xn=((Zn=nn==null?void 0:nn.properties)==null?void 0:Zn.CLASS_OF_MUNIC)||"";return{color:dn(xn),weight:xn==="City"?2.5:1.5,opacity:un,fillOpacity:un*.1,dashArray:qn(xn)}},onEachFeature:(nn,xn)=>{const Zn=nn.properties||{},ua=Zn.MUNICIPAL_NAME||"Unknown",Ya=Zn.CLASS_OF_MUNIC||"",Ea=Zn.COUNTY_NAME||"",Mr=Zn.FIPS_MUNIC_CODE||Zn.FIPS_CODE||"",ao=Zn.STATE_CODE||Zn.STATE||"PA",Oc=dn(Ya),ku=`
999                <div style="min-width: 200px;">
1000                  <div style="display: grid; gap: 6px; font-size: 12px;">
1001                    <div style="display: flex; justify-content: space-between;">
1002                      <span class="text-muted-foreground">Type:</span>
1003                      <span style="font-weight: 500;">${Ya||"N/A"}</span>
1004                    </div>
1005                    ${Ea?`<div style="display: flex; justify-content: space-between;">
1006                      <span class="text-muted-foreground">County:</span>
1007                      <span style="font-weight: 500;">${Ea}</span>
1008                    </div>`:""}
1009                    <div style="display: flex; justify-content: space-between;">
1010                      <span class="text-muted-foreground">State:</span>
1011                      <span style="font-weight: 500;">${ao}</span>
1012                    </div>
1013                    ${Mr?`<div style="display: flex; justify-content: space-between;">
1014                      <span class="text-muted-foreground">FIPS Code:</span>
1015                      <span style="font-weight: 500; font-family: monospace;">${Mr}</span>
1016                    </div>`:""}
1017                  </div>
1018                </div>
1019              `;if(xn.bindPopup(ld(ua,ku,"🏘️"),{...od,maxWidth:280,className:"layer-popup municipality-popup"}),xn.on("contextmenu",au=>{var Qa;(Qa=pe.current)==null||Qa.fire("contextmenu",au)}),xn.on("mouseover",function(){xn.setStyle({weight:4,fillOpacity:un*.25})}),xn.on("mouseout",function(){xn.setStyle({weight:Ya==="City"?2.5:1.5,fillOpacity:un*.1})}),xn.on("click",function(){xn.bringToFront(),xn.setStyle({weight:5,opacity:1,fillOpacity:un*.35}),setTimeout(()=>{xn.setStyle({weight:Ya==="City"?2.5:1.5,opacity:un,fillOpacity:un*.1})},3e3)}),nn.geometry&&(nn.geometry.type==="Polygon"||nn.geometry.type==="MultiPolygon")){const Qa=xn.getBounds().getCenter(),vi=bd?"rgba(50, 50, 50, 0.85)":"rgba(255, 255, 255, 0.9)",qo=bd?"white":"black",No=Bt.divIcon({className:"municipality-label",html:`<div style="
1020                    background: ${vi};
1021                    color: ${qo};
1022                    padding: 3px 8px;
1023                    border-radius: 4px;
1024                    font-size: 10px;
1025                    font-weight: 500;
1026                    white-space: nowrap;
1027                    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
1028                    text-align: center;
1029                    opacity: ${un};
1030                    border-left: 3px solid ${Oc};
1031                  ">${ua}</div>`,iconSize:[0,0],iconAnchor:[0,0]}),ec=Bt.marker(Qa,{icon:No,interactive:!1});gn.addLayer(ec)}}}),Dn.addLayer(Ys),console.log("Created single GeoJSON layer for municipalities")),Ys.addData(Xs),console.log("Added",Xs.features.length,"features to existing GeoJSON layer"),pe.current.hasLayer(Dn)||(Dn.addTo(pe.current),console.log("Added mainGroup to map"));const Qn=pe.current.getZoom();return Qn>=10&&!pe.current.hasLayer(gn)?gn.addTo(pe.current):Qn<10&&pe.current.hasLayer(gn)&&gn.remove(),{mainGroup:Dn,labelsGroup:gn,geoJsonLayer:Ys}};if(Ja&&!rn.current[zn])try{Ve.loading("Loading municipalities...",{id:"municipalities-loading"});const Xs=await jt(!0);Ve.dismiss("municipalities-loading");const Bs=zs(Xs);if(!Bs){Ve.info("No municipalities in current viewport");const nn=Bt.layerGroup().addTo(pe.current),xn=Bt.layerGroup(),Zn=()=>{var Mr,ao,Oc;const Ea=((Mr=pe.current)==null?void 0:Mr.getZoom())??0;Ea>=10&&!((ao=pe.current)!=null&&ao.hasLayer(xn))?xn.addTo(pe.current):Ea<10&&((Oc=pe.current)!=null&&Oc.hasLayer(xn))&&xn.remove()};let ua=null;const Ya=async()=>{ua&&clearTimeout(ua),ua=window.setTimeout(async()=>{var Mr;const Ea=await jt();(Mr=Ea==null?void 0:Ea.features)!=null&&Mr.length&&zs(Ea,{mainGroup:nn,labelsGroup:xn})},300)};pe.current.on("zoomend",Zn),pe.current.on("moveend",Ya),rn.current[zn]={mainGroup:nn,labelsGroup:xn,cleanup:()=>{var Ea,Mr;ua&&clearTimeout(ua),(Ea=pe.current)==null||Ea.off("zoomend",Zn),(Mr=pe.current)==null||Mr.off("moveend",Ya),nn.remove(),xn.remove(),En.clear(),Ys=null,Ar(0)}};return}const{mainGroup:Dn,labelsGroup:gn}=Bs,un=()=>{var xn,Zn,ua;const nn=((xn=pe.current)==null?void 0:xn.getZoom())??0;nn>=10&&!((Zn=pe.current)!=null&&Zn.hasLayer(gn))?gn.addTo(pe.current):nn<10&&((ua=pe.current)!=null&&ua.hasLayer(gn))&&gn.remove()};let Qn=null;const ar=async()=>{Qn&&clearTimeout(Qn),Qn=window.setTimeout(async()=>{var xn;const nn=await jt();(xn=nn==null?void 0:nn.features)!=null&&xn.length&&zs(nn,{mainGroup:Dn,labelsGroup:gn})},300)};pe.current.on("zoomend",un),pe.current.on("moveend",ar),rn.current[zn]={mainGroup:Dn,labelsGroup:gn,cleanup:()=>{var nn,xn;Qn&&clearTimeout(Qn),(nn=pe.current)==null||nn.off("zoomend",un),(xn=pe.current)==null||xn.off("moveend",ar),Dn.remove(),gn.remove(),En.clear(),Ys=null,Ar(0)}};let Wa=window.__municipalityPreloadRunning||!1;Ve.success(`Loaded ${((mn=Xs==null?void 0:Xs.features)==null?void 0:mn.length)||0} municipalities`),Ka&&!Wa&&(window.__municipalityPreloadRunning=!0,setTimeout(async()=>{var nn;try{console.log("Starting background preload of all municipalities..."),Mn({loaded:En.size,total:2569});const xn=await Fs.functions.invoke("fetch-boundaries",{body:{boundaryType:"municipalities"}});
1031if(xn.error){console.error("Background preload failed:",xn.error),Mn(null),window.__municipalityPreloadRunning=!1;return}const Zn=xn.data;if(!((nn=Zn==null?void 0:Zn.features)!=null&&nn.length)){Mn(null),window.__municipalityPreloadRunning=!1;return}const ua=Zn.features.filter(Ya=>{var Mr,ao;const Ea=((Mr=Ya.properties)==null?void 0:Mr.FIPS_MUN_CODE)||((ao=Ya.properties)==null?void 0:ao.MUNICIPAL_NAME);return En.has(Ea)?!1:(En.add(Ea),!0)});if(console.log(`Background preload: ${ua.length} new municipalities to add`),ua.length>0)for(let Ea=0;Ea<ua.length;Ea+=250){const Mr=ua.slice(Ea,Ea+250);zs({type:"FeatureCollection",features:Mr},{mainGroup:Dn,labelsGroup:gn}),Mn({loaded:En.size,total:Zn.features.length}),Ar(En.size),await new Promise(ao=>setTimeout(ao,20))}Mn(null),Ar(En.size),window.__municipalityPreloadRunning=!1,console.log(`Background preload complete. Total municipalities: ${En.size}`)}catch(xn){console.error("Background preload error:",xn),Mn(null),window.__municipalityPreloadRunning=!1}},1e3))}catch(Xs){Ve.dismiss("municipalities-loading"),Ve.error("Failed to load municipalities"),console.warn("Failed to load municipalities:",Xs)}else if(!Ja&&rn.current[zn]){const Xs=rn.current[zn];Xs!=null&&Xs.cleanup?Xs.cleanup():Xs!=null&&Xs.remove&&Xs.remove(),rn.current[zn]=null}},Ga=J.municipalities!==!1;Er("municipalities",D.municipalities&&Ga);const Zi="https://carto.nationalmap.gov/arcgis/services/transportation/MapServer/WMSServer";yt("primaryRoads",D.primaryRoads,Zi,"29,16",.85),yt("secondaryRoads",D.secondaryRoads,Zi,"30,17,18",.75),yt("localRoads",D.localRoads,Zi,"31,32",.65),at("railroads",D.railroads||D.railLines,"https://{s}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png",{attribution:"Map data: OpenRailwayMap",maxZoom:21,opacity:.7}),at("roadsOverlay",D.roadsOverlay,"https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}",{attribution:"Tiles &copy; Esri",maxZoom:20,opacity:K.roads??.6}),at("majorRoads",D.majorRoads,"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:"&copy; OpenStreetMap contributors",maxZoom:21,opacity:K.roads??.6});const Po=async(zn,Ja,En,pr,jt)=>{var Ys;if(Ja&&!rn.current[zn])try{const dn=pe.current.getBounds(),qn=`${dn.getSouth()},${dn.getWest()},${dn.getNorth()},${dn.getEast()}`,mn=`[out:json][timeout:25];(${(()=>{const un=En.trim();return(un.endsWith(";")?un:`${un};`).replace(/\{bbox\}/g,qn)})()});out geom;`,Xs=`https://overpass-api.de/api/interpreter?data=${encodeURIComponent(mn)}`,Bs=await fetch(Xs);if(!Bs.ok){console.warn(`OSM ${zn} returned ${Bs.status}`);return}const Dn=await Bs.json(),gn=[];if((Ys=Dn.elements)==null||Ys.forEach(un=>{if(un.type==="node"&&un.lat&&un.lon)gn.push({type:"Feature",properties:{...un.tags,osmId:un.id},geometry:{type:"Point",coordinates:[un.lon,un.lat]}});else if(un.type==="way"&&un.geometry){const Qn=un.geometry.map(ar=>[ar.lon,ar.lat]);gn.push({type:"Feature",properties:{...un.tags,osmId:un.id},geometry:{type:"LineString",coordinates:Qn}})}else un.type==="relation"&&un.members&&un.members.forEach(Qn=>{if(Qn.type==="way"&&Qn.geometry){const ar=Qn.geometry.map(Wa=>[Wa.lon,Wa.lat]);gn.push({type:"Feature",properties:{...un.tags,osmId:un.id},geometry:{type:"LineString",coordinates:ar}})}})}),gn.length>0){const un={type:"FeatureCollection",features:gn},Qn=Bt.geoJSON(un,{style:typeof pr=="function"?pr:()=>pr,pointToLayer:jt,onEachFeature:(ar,Wa)=>{const nn=ar.properties,xn=nn.name||nn.operator||nn["plant:source"]||"Unknown",Zn=nn.power||"";Wa.bindPopup(ld(xn,Zn?`<em class="text-xs text-muted-foreground">${Zn}</em>`:"","⚡"),od),Wa.on("contextmenu",ua=>{var Ya;(Ya=pe.current)==null||Ya.fire("contextmenu",ua)})}}).addTo(pe.current);rn.current[zn]=Qn}}catch(dn){console.warn(`Failed to load ${zn}:`,dn)}else!Ja&&rn.current[zn]&&(rn.current[zn].remove(),rn.current[zn]=null)},po=D.transmissionLines&&(J==null?void 0:J.transmissionLines)!==!1;Po("transmissionLines",po,'way["power"="line"]({bbox})',{color:"#fbbf24",weight:2,opacity:.8});const Pl=D.substations&&(J==null?void 0:J.substations)!==!1;Po("substations",Pl,'node["power"="substation"]({bbox});way["power"="substation"]({bbox})',{},(zn,Ja)=>Bt.circleMarker(Ja,{radius:6,fillColor:"#f97316",color:"#ea580c",weight:2,opacity:1,fillOpacity:.8}));const zc=D.powerPlants&&(J==null?void 0:J.powerPlants)!==!1;(async()=>{var zn;if(zc&&!rn.current.powerPlants)try{const Ja=(zn=pe.current)==null?void 0:zn.getBounds(),En=Ja?{north:Ja.getNorth(),south:Ja.getSouth(),east:Ja.getEast(),west:Ja.getWest()}:void 0,pr=()=>{let zs=Fs.from("eia_power_plants").select("*").not("latitude","is",null).not("longitude","is",null);return En&&(zs=zs.gte("latitude",En.south).lte("latitude",En.north).gte("longitude",En.west).lte("longitude",En.east)),zs.limit(2e3)};let{data:jt,error:Ys}=await pr();if(Ys){console.warn("Failed to fetch EIA power plants:",Ys);return}let dn=jt??[];if(dn.length===0&&En){console.log("No power plants in viewport cache - fetching from source...");const{data:zs,error:mn}=await Fs.functions.invoke("fetch-eia-power-plants",{body:{bounds:En}});if(mn){console.warn("Failed to fetch power plants:",mn),Ve.error("Failed to load power plants for this area.");return}if(zs!=null&&zs.warning&&Ve.error(zs.warning),dn=Array.isArray(zs==null?void 0:zs.plants)?zs.plants:[],dn.length===0&&(zs!=null&&zs.count)){const{data:Xs}=await pr();dn=Xs??[]}}if(dn.length===0){Ve.info("No power plants found in this area.");return}const qn=Bt.layerGroup();dn.forEach(zs=>{const mn=zs.latitude,Xs=zs.longitude;if(!mn||!Xs)return;const Bs=zs.plant_name||"Power Plant",Dn=zs.primary_source||"",gn=zs.nameplate_capacity_mw,un=zs.operating_capacity_mw,Qn=zs.utility_name||"",ar=zs.city||"",Wa=zs.state_code||"",nn=ld(Bs,`<div class="text-xs space-y-1">
1032                ${Dn?`<div><strong>Primary Source:</strong> ${Dn}</div>`:""}
1033                ${gn?`<div><strong>Nameplate Capacity:</strong>
1033 ${gn.toLocaleString()} MW</div>`:""}
1034                ${un?`<div><strong>Operating Capacity:</strong> ${un.toLocaleString()} MW</div>`:""}
1035                ${Qn?`<div><strong>Utility:</strong> ${Qn}</div>`:""}
1036                ${ar||Wa?`<div><strong>Location:</strong> ${[ar,Wa].filter(Boolean).join(", ")}</div>`:""}
1037                <div class="text-muted-foreground">EIA Plant ID: ${zs.id}</div>
1038              </div>`,"⚡"),Zn={SUN:"#f59e0b",WND:"#06b6d4",WAT:"#3b82f6",NG:"#10b981",COL:"#6b7280",NUC:"#8b5cf6",PET:"#1f2937",BIO:"#22c55e",GEO:"#ef4444"}[Dn]||"#dc2626",ua=Zn.replace("#",""),Ya=Bt.divIcon({className:"power-plant-marker",html:`<div style="
1039                width: 24px; 
1040                height: 24px; 
1041                background: ${Zn}; 
1042                border: 2px solid rgba(0,0,0,0.3); 
1043                border-radius: 50% 50% 50% 0; 
1044                transform: rotate(-45deg);
1045                display: flex;
1046                align-items: center;
1047                justify-content: center;
1048                box-shadow: 0 2px 4px rgba(0,0,0,0.3);
1049              ">
1050                <span style="transform: rotate(45deg); font-size: 12px;">⚡</span>
1051              </div>`,iconSize:[24,24],iconAnchor:[12,24],popupAnchor:[0,-24]}),Ea=Bt.marker([mn,Xs],{icon:Ya});Ea.bindPopup(nn,od),Ea.on("contextmenu",Mr=>{var ao;return(ao=pe.current)==null?void 0:ao.fire("contextmenu",Mr)}),qn.addLayer(Ea)}),qn.getLayers().length>0&&(qn.addTo(pe.current),rn.current.powerPlants=qn,console.log(`Loaded ${qn.getLayers().length} EIA power plants`))}catch(Ja){console.warn("Failed to load power plants:",Ja)}else!zc&&rn.current.powerPlants&&(rn.current.powerPlants.remove(),rn.current.powerPlants=null)})(),yt("wetlands",D.wetlands,"https://fwspublicservices.wim.usgs.gov/wetlandsmapservice/services/Wetlands/MapServer/WMSServer","0",.6),yt("floodZones",D.floodZones,"https://hazards.fema.gov/arcgis/services/public/NFHLWMS/MapServer/WMSServer","28",.5,void 0,!0),yt("hydrology",D.hydrology,"https://basemap.nationalmap.gov/arcgis/services/USGSHydroCached/MapServer/WMSServer","0",.5),at("shadedRelief",D.shadedRelief,"https://basemap.nationalmap.gov/arcgis/rest/services/USGSShadedReliefOnly/MapServer/tile/{z}/{y}/{x}",{attribution:"USGS",maxZoom:16,opacity:.5}),at("topographic",D.topographic,"https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/M
1051apServer/tile/{z}/{y}/{x}",{attribution:"USGS National Map",maxZoom:16,opacity:.7}),at("usgsImagery",D.usgsImagery,"https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}",{attribution:"USGS NAIP",maxZoom:21,opacity:.9}),yt("geology",D.geology,"https://www.sciencebase.gov/arcgis/services/Catalog/5888bf4fe4b05ccb964bab9d/MapServer/WMSServer","0,1,2",.65),yt("soils",D.soils,"https://sdmdataaccess.sc.egov.usda.gov/Spatial/SDM.wms","mapunitpoly",.55),at("bedrock",D.bedrock,"https://mrdata.usgs.gov/mapcache/wmts/1.0.0/sgmc2contact/default/GoogleMapsCompatible/{z}/{y}/{x}.png",{attribution:"USGS SGMC",maxZoom:16,opacity:.7,tileSize:256}),yt("groundwater",D.groundwater,"https://hydro.nationalmap.gov/arcgis/services/wbd/MapServer/WMSServer","0,1,2,3,4,5",.4);const nu=J.zoneomicsTiles!==!1&&D.zoneomicsTiles;if(nu&&!rn.current.zoneomicsTiles){const En=Bt.tileLayer("https://ntrjyokaupvmnftawavp.supabase.co/functions/v1/zoneomics-tiles?x={x}&y={y}&z={z}",{attribution:"© Zoneomics",maxZoom:20,minZoom:10,opacity:.6,pane:"boundaryPane",zIndex:1100});console.log("Zoneomics tile layer enabled via edge function proxy"),En.addTo(pe.current),rn.current.zoneomicsTiles=En}else!nu&&rn.current.zoneomicsTiles&&(rn.current.zoneomicsTiles.remove(),rn.current.zoneomicsTiles=null)},[D,J]),k.useEffect(()=>{if(!pe.current)return;const Ne=pe.current,Oe=D.geology,lt=D.soils,pt=D.bedrock,It=D.groundwater;if(!(Oe||lt||pt||It))return;const at=async(Ft,Gt,ms,Wt,Ss)=>{try{const Ms=Ne.getBounds(),hn=Ne.getSize(),Vn=Ne.latLngToContainerPoint(ms),ka=new URLSearchParams({SERVICE:"WMS",VERSION:"1.1.1",REQUEST:"GetFeatureInfo",LAYERS:Gt,QUERY_LAYERS:Gt,INFO_FORMAT:"application/json",X:Math.round(Vn.x).toString(),Y:Math.round(Vn.y).toString(),WIDTH:hn.x.toString(),HEIGHT:hn.y.toString(),BBOX:`${Ms.getWest()},${Ms.getSouth()},${Ms.getEast()},${Ms.getNorth()}`,SRS:"EPSG:4326",FEATURE_COUNT:"5"}),Fa=await fetch(`${Ft}?${ka.toString()}`);if(!Fa.ok)return null;if((Fa.headers.get("content-type")||"").includes("json")){const Ga=await Fa.json();if(Ga.features&&Ga.features.length>0){const Zi=Ga.features[0].properties||{};return{layerName:Wt,icon:Ss,content:Pt(Zi,Wt)}}}else{const Ga=await Fa.text();if(Ga.includes("FIELDS")||Ga.includes("properties")||Ga.length>100)return{layerName:Wt,icon:Ss,content:'<div class="text-xs text-muted-foreground">Feature data available at this location</div>'}}return null}catch(Ms){return console.warn(`GetFeatureInfo failed for ${Wt}:`,Ms),null}},Pt=(Ft,Gt)=>{const ms=(Ss,Ms)=>
1051Ms==null||Ms===""?"N/A":typeof Ms=="number"?Ms.toLocaleString():String(Ms);let Wt=[];if(Gt==="Geology"){const Ss={UNIT_NAME:{label:"Unit Name",description:"The geologic formation or unit name"},UNIT_LINK:{label:"Unit Code",description:"Unique identifier for this geologic unit"},LITH_TYPE:{label:"Lithology",description:"The type of rock or sediment"},UNIT_AGE:{label:"Age",description:"Geologic age of the unit"},ROCKTYPE1:{label:"Primary Rock Type",description:"The dominant rock type in this area"},ROCKTYPE2:{label:"Secondary Rock Type",description:"Secondary rock type present"},GUNIT:{label:"Unit",description:"Geologic unit abbreviation"},GUNIT_DESC:{label:"Description",description:"Full description of the geologic unit"},UNITDESC:{label:"Description",description:"Description of the geologic unit"}};for(const[Ms,{label:hn,description:Vn}]of Object.entries(Ss))Ft[Ms]&&Wt.push({label:hn,value:ms(Ms,Ft[Ms]),description:Vn});if(Wt.length===0)for(const[Ms,hn]of Object.entries(Ft))!Ms.startsWith("OBJECTID")&&hn!==null&&hn!==""&&Wt.push({label:Ms.replace(/_/g," "),value:ms(Ms,hn)})}else if(Gt==="Soils"){const Ss={muname:{label:"Soil Name",description:"The name of this soil map unit"},musym:{label:"Symbol",description:"Map unit symbol"},mukey:{label:"Map Unit Key",description:"Unique identifier for this soil unit"},mukind:{label:"Kind",description:"Type of map unit (e.g., consociation, complex)"},drclassdcd:{label:"Drainage Class",description:"How well the soil drains water"},hydgrpdcd:{label:"Hydrologic Group",description:"Runoff potential (A=low, D=high)"},taxorder:{label:"Soil Order",description:"Taxonomic classification order"},taxsuborder:{label:"Suborder",description:"Taxonomic suborder"},slopegraddcp:{label:"Slope (%)",description:"Dominant slope gradient"},brockdepmin:{label:"Bedrock Depth (min)",description:"Minimum depth to bedrock in cm"},aws025wta:{label:"Water Storage",description:"Available water storage (0-25cm)"}};for(const[Ms,{label:hn,description:Vn}]of Object.entries(Ss)){const ka=Object.keys(Ft).find(Fa=>Fa.toLowerCase()===Ms.toLowerCase());ka&&Ft[ka]&&Wt.push({label:hn,value:ms(ka,Ft[ka]),description:Vn})}if(Wt.length===0)for(const[Ms,hn]of Object.entries(Ft))hn!==null&&hn!==""&&Wt.push({label:Ms.replace(/_/g," "),value:ms(Ms,hn)})}else if(Gt==="Watersheds"){const Ss={name:{label:"Watershed Name",description:"Name of this watershed/drainage area"},huc4:{label:"HUC-4",description:"Subregion code (4-digit)"},huc6:{label:"HUC-6",description:"Basin code (6-digit)"},huc8:{label:"HUC-8",description:"Subbasin code (8-digit)"},huc10:{label:"HUC-10",description:"Watershed code (10-digit)"},huc12:{label:"HUC-12",description:"Subwatershed code (12-digit)"},areasqkm:{label:"Area (sq km)",description:"Total watershed area"},states:{label:"States",description:"States this watershed covers"},hutype:{label:"Type",description:"Hydrologic unit type"}};for(const[Ms,{label:hn,description:Vn}]of Object.entries(Ss)){const ka=Object.keys(Ft).find(Fa=>Fa.toLowerCase()===Ms.toLowerCase());ka&&Ft[ka]&&Wt.push({label:hn,value:ms(ka,Ft[ka]),description:Vn})}if(Wt.length===0)for(const[Ms,hn]of Object.entries(Ft))hn!==null&&hn!==""&&Wt.push({label:Ms.replace(/_/g," "),value:ms(Ms,hn)})}
1051else for(const[Ss,Ms]of Object.entries(Ft))Ms!==null&&Ms!==""&&Wt.push({label:Ss.replace(/_/g," "),value:ms(Ss,Ms)});return Wt=Wt.slice(0,8),Wt.length===0?'<div class="text-xs text-muted-foreground">No detailed information available</div>':`
1052        <div class="space-y-1.5">
1053          ${Wt.map(Ss=>`
1054            <div class="flex justify-between gap-2 text-xs">
1055              <span class="text-muted-foreground" ${Ss.description?`title="${Ss.description}"`:""}>${Ss.label}:</span>
1056              <span class="font-medium text-right max-w-[140px] truncate" title="${Ss.value}">${Ss.value}</span>
1057            </div>
1058          `).join("")}
1059        </div>
1060      `},Qt=async Ft=>{const Gt=Ft.latlng,ms=[],Wt=Bt.popup(od).setLatLng(Gt).setContent(`
1061          <div class="p-2 text-center">
1062            <div class="animate-spin inline-block w-5 h-5 border-2 border-primary border-t-transparent rounded-full mb-2"></div>
1063            <div class="text-xs text-muted-foreground">Loading geology data...</div>
1064          </div>
1065        `).openOn(Ne),Ss=[];if(Oe&&Ss.push(at("https://www.sciencebase.gov/arcgis/services/Catalog/5888bf4fe4b05ccb964bab9d/MapServer/WMSServer","0,1,2",Gt,"Geology","🪨")),lt&&Ss.push(at("https://sdmdataaccess.sc.egov.usda.gov/Spatial/SDM.wms","mapunitpoly",Gt,"Soils","🌱")),It&&Ss.push(at("https://hydro.nationalmap.gov/arcgis/services/wbd/MapServer/WMSServer","0,1,2,3,4,5",Gt,"Watersheds","💧")),pt&&ms.push({layerName:"Bedrock",icon:"⛰️",content:`
1066            <div class="space-y-1.5 text-xs">
1067              <div class="text-muted-foreground">Showing geologic contacts and fault lines from the State Geologic Map Compilation.</div>
1068              <div class="flex justify-between">
1069                <span class="text-muted-foreground">Source:</span>
1070                <span class="font-medium">USGS SGMC</span>
1071              </div>
1072              <div class="text-muted-foreground mt-1">
1072Lines indicate geologic boundaries, faults, and structural features.</div>
1073            </div>
1074          `}),(await Promise.all(Ss)).forEach(Vn=>{Vn&&ms.push(Vn)}),ms.length===0){Wt.setContent(`
1075          <div class="p-2 text-center text-xs text-muted-foreground">
1076            No geology data found at this location. Try clicking on a colored area.
1077          </div>
1078        `);return}const hn=`
1079        <div class="geology-popup max-w-[320px]">
1080          ${ms.map((Vn,ka)=>`
1081            <div class="${ka>0?"mt-3 pt-3 border-t border-border":""}">
1082              <div class="flex items-center gap-2 mb-2">
1083                <span class="text-lg">${Vn.icon}</span>
1084                <span class="font-semibold text-sm">${Vn.layerName}</span>
1085              </div>
1086              ${Vn.content}
1087            </div>
1088          `).join("")}
1089          <div class="mt-3 pt-2 border-t border-border text-[10px] text-muted-foreground">
1090            Click on colored areas to see detailed information
1091          </div>
1092        </div>
1093      `;Wt.setContent(ld("Geology & Soil Info",hn,"🗺️"))};return Ne.on("click",Qt),()=>{Ne.off("click",Qt)}},[D.geology,D.soils,D.bedrock,D.groundwater]),k.useEffect(()=>{if(!pe.current)return;const Ne=pe.current;Ne.getPane("boundaryPane")||Ne.createPane("boundaryPane");const Oe=["brownfields","superfund","toxicRelease"],lt={brownfields:{color:"#a16207",radius:7},superfund:{color:"#dc2626",radius:10},toxicRelease:{color:"#7c3aed",radius:6}},pt=ms=>!!D[ms]&&(J==null?void 0:J[ms])!==!1,It=ms=>{var Ss;const Wt=rn.current[ms];return Wt&&typeof Wt.clearLayers!="function"&&((Ss=Wt.remove)==null||Ss.call(Wt),rn.current[ms]=null),pt(ms)?(rn.current[ms]||(rn.current[ms]=Bt.layerGroup().addTo(Ne)),rn.current[ms]):(rn.current[ms]&&(rn.current[ms].remove(),rn.current[ms]=null),null)};Oe.forEach(ms=>It(ms));let yt=!1,at="";const Pt=()=>{const ms=Ne.getBounds();return{north:ms.getNorth(),south:ms.getSouth(),east:ms.getEast(),west:ms.getWest()}},Qt=async()=>{const ms=Oe.filter(pt);if(ms.length===0||yt)return;const Wt=Pt(),Ss=`${Wt.west.toFixed(3)},${Wt.south.toFixed(3)},${Wt.east.toFixed(3)},${Wt.north.toFixed(3)}`;if(Ss!==at){at=Ss,yt=!0;try{const{data:{session:Ms}}=await Fs.auth.getSession(),hn=(Ms==null?void 0:Ms.access_token)??"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im50cmp5b2thdXB2bW5mdGF3YXZwIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjQ5ODczOTQsImV4cCI6MjA4MDU2MzM5NH0.ed9VsCnPJRDqqmSZl0P6voa_3iH2G4fi7B4fBcCTjO0";for(const Vn of ms){const ka=It(Vn);if(!ka)continue;ka.clearLayers();const{data:Fa,error:Er}=await Fs.functions.invoke("fetch-environmental-data",{body:{layerType:Vn,bounds:Wt},headers:{Authorization:`Bearer ${hn}`}});if(Er){console.warn(`[Environmental] Failed to load ${Vn}:`,Er);continue}const Ga=Array.isArray(Fa==null?void 0:Fa.features)?Fa.features:[],{color:Zi,radius:Po}=lt[Vn];for(const po of Ga){if(!(po!=null&&po.lat)||!(po!=null&&po.lng))continue;const Pl=Bt.circleMarker([po.lat,po.lng],{radius:Po,color:Zi,weight:2,opacity:1,fillColor:Zi,fillOpacity:.6,pane:"boundaryPane"}),zc=String(po.name||"Unknown Site"),di=Vn==="brownfields"?"🏭":Vn==="superfund"?"☢️":"⚠️";Pl.bindPopup(ld(zc,`<div class="text-xs text-muted-foreground">${Vn.charAt(0).toUpperCase()+Vn.slice(1).replace(/([A-Z])/g," $1")} Site</div>`,di),od),Pl.on("contextmenu",Ku=>{Ne.fire("contextmenu",Ku)}),Pl.addTo(ka)}}}finally{yt=!1}}};if(!Oe.some(pt))return;const Gt=()=>{Qt()};return Ne.on("moveend",Gt),Qt(),()=>{Ne.off("moveend",Gt)}},[D,J]),k.useEffect(()=>{var pt,It;if(!pe.current)return;const Ne=rn.current;["states","statesLabels","counties","countiesLabels","cities","citiesLabels","congressionalDistricts","congressionalDistrictsLabels"].forEach(yt=>{const at=Ne[yt];at&&typeof at.setOpacity=="function"&&at.setOpacity(K.boundaries)});const Oe=Ne.censusTracks;if(Oe!=null&&Oe.mainGroup){const yt=K.boundaries??.65;Oe.mainGroup.eachLayer(at=>{at.setStyle&&at.setStyle({opacity:yt,fillOpacity:yt*.08})}),(pt=Oe.labelsGroup)==null||pt.eachLayer(at=>{var Qt;const Pt=(Qt=at.getElement)==null?void 0:Qt.call(at);if(Pt){const Ft=Pt.querySelector("div");Ft&&(Ft.style.opacity=yt.toString())}})}
1093const lt=Ne.schoolDistricts;if(lt!=null&&lt.mainGroup){const yt=K.schoolDistricts??.75;lt.mainGroup.eachLayer(at=>{at.setStyle&&at.setStyle({opacity:yt,fillOpacity:yt*.1})}),(It=lt.labelsGroup)==null||It.eachLayer(at=>{var Qt,Ft;if((Qt=at.getIcon)==null?void 0:Qt.call(at)){const Gt=(Ft=at.getElement)==null?void 0:Ft.call(at);if(Gt){const ms=Gt.querySelector("div");ms&&(ms.style.opacity=yt.toString())}}})}["primaryRoads","railroads"].forEach(yt=>{const at=Ne[yt];at&&typeof at.setOpacity=="function"&&at.setOpacity(K.infrastructure)}),["wetlands","floodZones","hydrology"].forEach(yt=>{const at=Ne[yt];at&&typeof at.setOpacity=="function"&&at.setOpacity(K.environmental)}),["geology","soils","bedrock","groundwater"].forEach(yt=>{const at=Ne[yt];at&&typeof at.setOpacity=="function"&&at.setOpacity(K.environmental)}),["shadedRelief","topographic","usgsImagery"].forEach(yt=>{const at=Ne[yt];at&&typeof at.setOpacity=="function"&&at.setOpacity(K.terrain)})},[K]),k.useEffect(()=>{In.current={substations:D.substations===!0,transmissionLines:D.transmissionLines===!0}},[D]),k.useEffect(()=>{if(!pe.current)return;const Ne=rn.current,Oe=D.substations===!0,lt=D.transmissionLines===!0,pt=Oe||lt;if(console.log("[HIFLD] Layer visibility check:",{hifldSubstationsVisible:Oe,hifldTransmissionVisible:lt}),lt||Ne.hifldTransmission&&(console.log("[HIFLD] Removing transmission lines layer (visibility off)"),Ne.hifldTransmission.remove(),Ne.hifldTransmission=null),Oe||Ne.hifldSubstations&&(console.log("[HIFLD] Removing substations layer (visibility off)"),Ne.hifldSubstations.remove(),Ne.hifldSubstations=null),!pt){console.log("[HIFLD] No HIFLD layers visible, skipping render (data remains cached)");return}const It=()=>{if(!pe.current||!lt||Eo.length===0)return;Ne.hifldTransmission&&(Ne.hifldTransmission.remove(),Ne.hifldTransmission=null);const Ft=Bt.layerGroup();Eo.forEach(Gt=>{var Wt,Ss;let ms=[];((Wt=Gt.geometry)==null?void 0:Wt.type)==="LineString"?ms=[Gt.geometry.coordinates]:((Ss=Gt.geometry)==null?void 0:Ss.type)==="MultiLineString"&&(ms=Gt.geometry.coordinates),ms.forEach(Ms=>{if(Ms&&Ms.length>=2){const hn=Ms.map(([Ga,Zi])=>[Zi,Ga]),Vn=Ww(Gt.voltage),ka=Gt.voltage?Math.min(Math.max(Gt.voltage/150,1),4):2,Fa=Bt.polyline(hn,{color:Vn,weight:ka,opacity:.8,pane:"boundaryPane"}),Er=`
1094              <div class="text-sm">
1095                ${Gt.voltage?`<strong>${Gt.voltage} kV</strong> - ${Gt.voltClass}`:"Unknown voltage"}<br/>
1096                Owner: ${Gt.owner||"Unknown"}<br/>
1097                Status: ${Gt.status||"Unknown"}<br/>
1098                Type: ${Gt.type||"Unknown"}
1099              </div>
1100            `;Fa.bindPopup(ld("Transmission Line",Er,"⚡"),od),Ft.addLayer(Fa)}})}),Ft.addTo(pe.current),Ne.hifldTransmission=Ft,console.log(`[HIFLD] Rendered ${Eo.length} transmission lines on map`)},yt=()=>{if(!pe.current||!Oe||ci.length===0)return;Ne.hifldSubstations&&(Ne.hifldSubstations.remove(),Ne.hifldSubstations=null);const Ft=Bt.layerGroup();ci.forEach(Gt=>{if(Gt.lat&&Gt.lng){const ms=z5(Gt.maxVolt),Wt=Ww(Gt.maxVolt),Ss=Bt.circleMarker([Gt.lat,Gt.lng],{radius:ms,fillColor:Wt,color:"#1f2937",weight:2,opacity:1,fillOpacity:.9,pane:"boundaryPane"}),Ms=`
1101            <div class="text-sm">
1102              ${Gt.city?`${Gt.city}, `:""}${Gt.state} ${Gt.zip}<br/>
1103              ${Gt.maxVolt?`Max Voltage: <strong>${Gt.maxVolt} kV</strong>`:""}<br/>
1104              ${Gt.minVolt?`Min Voltage: ${Gt.minVolt} kV<br/>`:""}
1105              ${Gt.lines?`Lines: ${Gt.lines}<br/>`:""}
1106              Status: ${Gt.status||"Unknown"}<br/>
1107              Source: ${Gt.source||"HIFLD"}
1108            </div>
1109          `;Ss.bindPopup(ld(Gt.name,Ms,"⚡"),od),Ft.addLayer(Ss)}}),Ft.addTo(pe.current),Ne.hifldSubstations=Ft,console.log(`[HIFLD] Rendered ${ci.length} substations on map`)},at=()=>{if(!pe.current||xl)return;const Ft=In.current;if(!Ft.substations&&!Ft.transmissionLines){console.log("[HIFLD] Skipping fetch - layers not visible (from ref)");return}const Gt=pe.current.getBounds();tl({north:Gt.getNorth(),south:Gt.getSouth(),east:Gt.getEast(),west:Gt.getWest()})};let Pt=null;const Qt=()=>{const Ft=In.current;if(!Ft.substations&&!Ft.transmissionLines){console.log("[HIFLD] Skipping moveend fetch - no visible layers");return}Pt&&clearTimeout(Pt),Pt=window.setTimeout(()=>{at()},500)};return pt&&(ci.length===0&&Eo.length===0&&!xl&&at(),pe.current.on("moveend",Qt)),lt&&Eo.length>0?It():!lt&&Ne.hifldTransmission&&(Ne.hifldTransmission.remove(),Ne.hifldTransmission=null),Oe&&ci.length>0?yt():!Oe&&Ne.hifldSubstations&&(Ne.hifldSubstations.remove(),Ne.hifldSubstations=null),()=>{var Ft;Pt&&clearTimeout(Pt),(Ft=pe.current)==null||Ft.off("moveend",Qt)}},[D.substations,D.transmissionLines,ci,Eo,xl,tl]),k.useEffect(()=>{if(!pe.current)return;const Ne=rn.current;if(!(D.schools===!0&&J.schools!==!1)){Ne.schools&&(Ne.schools.remove(),Ne.schools=null);return}const lt=()=>{if(!pe.current)return;const yt=pe.current.getBounds();yu({north:yt.getNorth(),south:yt.getSouth(),east:yt.getEast(),west:yt.getWest()})};lt();let pt=null;const It=()=>{pt&&clearTimeout(pt),pt=window.setTimeout(lt,500)};return pe.current.on("moveend",It),()=>{var yt;pt&&clearTimeout(pt),(yt=pe.current)==null||yt.off("moveend",It)}},[D.schools,J.schools,yu]),k.useEffect(()=>{const Ne=D.schools===!0&&J.schools!==!1;if(!pe.current||!Ne||Jc.length===0)return;const Oe=rn.current;Oe.schools&&(Oe.schools.remove(),Oe.schools=null);const lt=Bt.layerGroup();
1109Jc.forEach(pt=>{if(!pt.lat||!pt.lng)return;const It=$o(pt.type),yt=pt.type==="elementary"?"#22c55e":pt.type==="middle"?"#3b82f6":pt.type==="high"?"#a855f7":"#6b7280",at=Bt.circleMarker([pt.lat,pt.lng],{radius:8,fillColor:yt,fillOpacity:.8,color:"#fff",weight:2,pane:"overlayPane"}),Pt=`
1110        <div class="text-xs space-y-1 text-muted-foreground min-w-[200px]">
1111          <div>${pt.address||""}</div>
1112          <div>${pt.city}, ${pt.state} ${pt.zip||""}</div>
1113          <div class="mt-2">
1114            <span class="font-medium">Type:</span> ${pt.level||pt.type}
1115          </div>
1116          ${pt.enrollment?`<div><span class="font-medium">Enrollment:</span> ${pt.enrollment.toLocaleString()}</div>`:""}
1117          ${pt.startGrade&&pt.endGrade?`<div><span class="font-medium">Grades:</span> ${pt.startGrade} - ${pt.endGrade}</div>`:""}
1118        </div>
1119      `;at.bindPopup(ld(pt.name,Pt,It),od),lt.addLayer(at)}),lt.addTo(pe.current),Oe.schools=lt,console.log(`[AreaIntel] Rendered ${Jc.length} schools`)},[Jc,D.schools,J.schools,$o]),k.useEffect(()=>{if(!pe.current)return;const Ne=rn.current;if(!(D.walkability===!0&&J.walkability!==!1)){Ne.walkability&&(Ne.walkability.remove(),Ne.walkability=null);return}const lt=()=>{if(!pe.current)return;const yt=pe.current.getBounds();Qd({north:yt.getNorth(),south:yt.getSouth(),east:yt.getEast(),west:yt.getWest()})};lt();let pt=null;const It=()=>{pt&&clearTimeout(pt),pt=window.setTimeout(lt,500)};return pe.current.on("moveend",It),()=>{var yt;pt&&clearTimeout(pt),(yt=pe.current)==null||yt.off("moveend",It)}},[D.walkability,J.walkability,Qd]),k.useEffect(()=>{const Ne=D.walkability===!0&&J.walkability!==!1;if(!pe.current||!Ne||Cr.length===0)return;const Oe=rn.current;Oe.walkability&&(Oe.walkability.remove(),Oe.walkability=null);const lt=Bt.layerGroup();Cr.forEach(pt=>{if(!pt.lat||!pt.lng)return;const It=to(pt.walkabilityIndex),yt=Math.min(Math.max(Math.sqrt(pt.totalAcres||100)*5,15),50),at=Bt.circleMarker([pt.lat,pt.lng],{radius:yt,fillColor:It,fillOpacity:.5,color:It,weight:2,opacity:.8,pane:"overlayPane"}),Pt=`
1120        <div class="min-w-[180px]">
1121          <div class="text-2xl font-bold mt-1" style="color: ${It}">${pt.walkabilityIndex}/20</div>
1122          <div class="text-xs mt-2 capitalize">${pt.classification.replace(/-/g," ")}</div>
1123          ${pt.population?`<div class="text-xs text-muted-foreground mt-1">Population: ${pt.population.toLocaleString()}</div>`:""}
1124          ${pt.totalAcres?`<div class="text-xs text-muted-foreground">Area: ${pt.totalAcres.toFixed(1)} acres</div>`:""}
1125        </div>
1126      `;at.bindPopup(ld("Walkability Index",Pt,"🚶"),od),lt.addLayer(at)}),lt.addTo(pe.current),Oe.walkability=lt,console.log(`[AreaIntel] Rendered ${Cr.length} walkability blocks as circles`)},[Cr,D.walkability,J.walkability,to]),k.useEffect(()=>{if(!pe.current)return;const Ne=rn.current;if(!(D.opportunityZones===!0&&J.opportunityZones!==!1)){Ne.opportunityZones&&(Ne.opportunityZones.remove(),Ne.opportunityZones=null);return}const lt=async()=>{if(!pe.current)return;const yt=pe.current.getBounds();if(pe.current.getZoom()<9){console.log("[OpportunityZones] Zoom too low, skipping fetch");return}try{const{data:Pt,error:Qt}=await Fs.functions.invoke("fetch-opportunity-zones",{body:{bounds:{north:yt.getNorth(),south:yt.getSouth(),east:yt.getEast(),west:yt.getWest()}}});if(Qt){console.error("[OpportunityZones] Error:",Qt);return}if(!(Pt!=null&&Pt.features)||Pt.features.length===0){console.log("[OpportunityZones] No features found");return}Ne.opportunityZones&&(Ne.opportunityZones.remove(),Ne.opportunityZones=null);const Ft=Bt.layerGroup();Pt.features.forEach(Gt=>{if(Gt.geometry)try{const ms=Bt.geoJSON(Gt,{style:{fillColor:"#14b8a6",fillOpacity:.18,color:"#0d9488",weight:2,opacity:.8},pane:"overlayPane"}),Wt=Gt.properties||{},Ss=`
1127              <div class="min-w-[220px]">
1128                <div class="text-xs space-y-1 border-t pt-2">
1129                  <p><span class="text-muted-foreground">Census Tract:</span> ${Wt.tract||Wt.geoid||"N/A"}</p>
1130                  <p><span class="text-muted-foreground">GEOID:</span> ${Wt.geoid||"N/A"}</p>
1131                  <p><span class="text-muted-foreground">State:</span> ${Wt.state||"N/A"}</p>
1132                  <p><span class="text-muted-foreground">County:</span> ${Wt.county||"N/A"}</p>
1133                  ${Wt.cbsaTitle?`<p><span class="text-muted-foreground">Metro Area:</span> ${Wt.cbsaTitle}</p>`:""}
1134                </div>
1135                ${Wt.totalPop||Wt.povertyRate||Wt.medianIncomePct?`
1136                <div class="text-xs space-y-1 border-t pt-2 mt-2">
1137                  <p class="font-medium text-muted-foreground">EPA Data:</p>
1138                  ${Wt.totalPop?`<p>
1138• Population: ${Number(Wt.totalPop).toLocaleString()}</p>`:""}
1139                  ${Wt.povertyRate?`<p>• Poverty Rate: ${Number(Wt.povertyRate).toFixed(1)}%</p>`:""}
1140                  ${Wt.medianIncomePct?`<p>• Median Income (% of area): ${Number(Wt.medianIncomePct).toFixed(0)}%</p>`:""}
1141                  ${Wt.designatedQOZ?`<p>• Designation: ${Wt.designatedQOZ}</p>`:""}
1142                </div>
1143                `:""}
1144                <div class="text-[10px] text-muted-foreground mt-2 pt-2 border-t">
1145                  Source: EPA / CDFI Fund / US Treasury
1146                </div>
1147              </div>
1148            `;ms.bindPopup(ld("Opportunity Zone",Ss,"🎯"),{...od,maxWidth:280,className:"layer-popup opportunity-zone-popup"}),Ft.addLayer(ms)}catch(ms){console.warn("[OpportunityZones] Failed to render feature:",ms)}}),Ft.addTo(pe.current),Ne.opportunityZones=Ft,console.log(`[OpportunityZones] Rendered ${Pt.features.length} zones`)}catch(Pt){console.error("[OpportunityZones] Fetch error:",Pt)}};lt();let pt=null;const It=()=>{pt&&clearTimeout(pt),pt=window.setTimeout(lt,500)};return pe.current.on("moveend",It),()=>{var yt;pt&&clearTimeout(pt),(yt=pe.current)==null||yt.off("moveend",It)}},[D.opportunityZones,J.opportunityZones]),k.useEffect(()=>{if(!pe.current)return;const Ne=rn.current;if(!(D.airports===!0&&J.airports!==!1)){Ne.airports&&(Ne.airports.remove(),Ne.airports=null),w();return}const lt=async()=>{if(!pe.current)return;const yt=pe.current.getBounds();if(pe.current.getZoom()<7){console.log("[Airports] Zoom too low, skipping fetch");return}await f({north:yt.getNorth(),south:yt.getSouth(),east:yt.getEast(),west:yt.getWest()},{types:H.length>0?H:void 0})};lt();let pt=null;const It=()=>{pt&&clearTimeout(pt),pt=window.setTimeout(lt,500)};return pe.current.on("moveend",It),()=>{var yt;pt&&clearTimeout(pt),(yt=pe.current)==null||yt.off("moveend",It)}},[D.airports,J.airports,f,w,H]),k.useEffect(()=>{const Ne=D.airports===!0&&J.airports!==!1;if(!pe.current||!Ne||N.length===0)return;const Oe=rn.current;Oe.airports&&(Oe.airports.remove(),Oe.airports=null);const lt=Bt.layerGroup();N.forEach(pt=>{const It=TV(pt.type),yt=PV(pt.type),at=Bt.circleMarker([pt.lat,pt.lng],{radius:8,fillColor:It,color:"#ffffff",weight:2,opacity:1,fillOpacity:.9,pane:"overlayPane"}),Pt=ld(pt.name||"Airport",`
1149          <div class="text-xs space-y-1">
1150            <div class="flex items-center gap-1">
1151              <span class="font-medium">Type:</span> ${pt.type||"Unknown"}
1152            </div>
1153            ${pt.city?`<div><span class="font-medium">City:</span> ${pt.city}, ${pt.state}</div>`:""}
1154            ${pt.faaId?`<div><span class="font-medium">FAA ID:</span> ${pt.faaId}</div>`:""}
1155            ${pt.icaoId?`<div><span class="font-medium">ICAO:</span> ${pt.icaoId}</div>`:""}
1156            ${pt.elevation?`<div><span class="font-medium">Elevation:</span> ${pt.elevation.toLocaleString()} ft</div>`:""}
1157            ${pt.longestRunway?`<div><span class="font-medium">Longest Runway:</span> ${pt.longestRunway.toLocaleString()} ft</div>`:""}
1158            ${pt.ownership?`<div><span class="font-medium">Ownership:</span> ${pt.ownership}</div>`:""}
1159          </div>
1160        `,yt);at.bindPopup(Pt,od),lt.addLayer(at)}),lt.addTo(pe.current),Oe.airports=lt,console.log(`[Airports] Rendered ${N.length} airports`)},[N,D.airports,J.airports]),k.useEffect(()=>{if(!pe.current)return;const Ne=lt=>{var pt,It;if(Se){const yt={lat:lt.latlng.lat,lng:lt.latlng.lng};hs(at=>[...at,yt])}else if(cr){let yt={lat:lt.latlng.lat,lng:lt.latlng.lng};if($a.length>0&&zi!=="marker"){const at=$a[$a.length-1],Pt=py(lt.originalEvent.shiftKey,lt.originalEvent.ctrlKey,Dc,Ua),Qt=((It=(pt=pe.current)==null?void 0:pt.getBearing)==null?void 0:It.call(pt))||0;Pt.isSnapping&&(yt=gb(at,yt,Pt.snapIncrement,Qt))}if(wo&&wo.parentGeometry.length>=3)try{const at=wo.parentGeometry.map(Ft=>[Ft.lng,Ft.lat]);at.push(at[0]);const Pt=Xn([at]),Qt=us([yt.lng,yt.lat]);if(!uu(Qt,Pt)){Ve.error("Point must be inside the parent polygon",{description:`Draw within "${wo.parentName}"`,duration:3e3});return}}catch(at){console.error("Error validating point within parent:",at)}jn(at=>[...at,yt])}else if(A){const yt={lat:lt.latlng.lat,lng:lt.latlng.lng};E&&_s?_s(yt):S(at=>[...at,yt])}else if(O&&q==="circle"){if(!Lt){const yt={lat:lt.latlng.lat,lng:lt.latlng.lng};W&&W>0&&Q?Q({type:"circle",center:yt,radius:W}):Vt(yt)}}else if(O&&q==="polygon"){const yt={lat:lt.latlng.lat,lng:lt.latlng.lng};St(at=>[...at,yt])}else if(fe){const yt={lat:lt.latlng.lat,lng:lt.latlng.lng};on(at=>[...at,yt])}else Ee&&Ze?Ze(lt.latlng.lat,lt.latlng.lng):((D.demographics||D.schools||D.walkability||D.crimeStats)&&gl({lat:lt.latlng.lat,lng:lt.latlng.lng}),_&&_(lt.latlng.lat,lt.latlng.lng))};pe.current.on("click",Ne);const Oe=async lt=>{if(Se||cr||A||O||fe)return;lt.originalEvent.preventDefault();const pt=lt.containerPoint,It=lt.latlng.lat,yt=lt.latlng.lng;Sn({x:pt.x,y:pt.y,lat:It,lng:yt});try{const{data:at,error:Pt}=await Fs.functions.invoke("geocode-address",{body:{lat:It,lng:yt}}
1160);!Pt&&(at!=null&&at.address)?Ve.info(`📍 ${at.address}`,{description:`${It.toFixed(6)}, ${yt.toFixed(6)}`,duration:4e3}):Ve.info("📍 Location selected",{description:`${It.toFixed(6)}, ${yt.toFixed(6)}`,duration:3e3})}catch{Ve.info("📍 Location selected",{description:`${It.toFixed(6)}, ${yt.toFixed(6)}`,duration:3e3})}};return pe.current.on("contextmenu",Oe),()=>{var lt,pt;(lt=pe.current)==null||lt.off("click",Ne),(pt=pe.current)==null||pt.off("contextmenu",Oe)}},[Se,cr,A,O,q,Lt,Ee,Ze,_,E,_s,fe,D.demographics,D.schools,D.walkability,D.crimeStats]),k.useEffect(()=>{if(!pe.current||!O||q!=="circle"||!Lt)return;const Ne=lt=>{const It=(lt.latlng.lat-Lt.lat)*Math.PI/180,yt=(lt.latlng.lng-Lt.lng)*Math.PI/180,at=Math.sin(It/2)*Math.sin(It/2)+Math.cos(Lt.lat*Math.PI/180)*Math.cos(lt.latlng.lat*Math.PI/180)*Math.sin(yt/2)*Math.sin(yt/2),Qt=3959*(2*Math.atan2(Math.sqrt(at),Math.sqrt(1-at)));Et(Qt)},Oe=lt=>{const It=(lt.latlng.lat-Lt.lat)*Math.PI/180,yt=(lt.latlng.lng-Lt.lng)*Math.PI/180,at=Math.sin(It/2)*Math.sin(It/2)+Math.cos(Lt.lat*Math.PI/180)*Math.cos(lt.latlng.lat*Math.PI/180)*Math.sin(yt/2)*Math.sin(yt/2),Qt=3959*(2*Math.atan2(Math.sqrt(at),Math.sqrt(1-at)));Qt>.1&&Q&&Q({type:"circle",center:Lt,radius:Qt}),Vt(null),Et(0)};return pe.current.on("mousemove",Ne),pe.current.on("click",Oe),()=>{var lt,pt;(lt=pe.current)==null||lt.off("mousemove",Ne),(pt=pe.current)==null||pt.off("click",Oe)}},[O,q,Lt,Q]),k.useEffect(()=>{if(pe.current&&(_n.current&&(_n.current.remove(),_n.current=null),Ta.current.forEach(Ne=>Ne.remove()),Ta.current=[],Se&&At.length>0)){const Ne=At.map(lt=>[lt.lat,lt.lng]);_n.current=Bt.polygon(Ne,{color:"#f59e0b",weight:3,fillColor:"#f59e0b",fillOpacity:.2,dashArray:"5, 5"}).addTo(pe.current);const Oe=()=>{const lt=At;for(let pt=0;pt<lt.length;pt++){const It=(pt+1)%lt.length,yt=(lt[pt].lat+lt[It].lat)/2,at=(lt[pt].lng+lt[It].lng)/2,Pt=Bt.marker([yt,at],{icon:Bt.divIcon({className:"polygon-midpoint-marker",html:`<div style="
1161                width: 16px;
1162                height: 16px;
1163                background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
1164                border: 2px solid white;
1165                border-radius: 50%;
1166                cursor: pointer;
1167                opacity: 0.7;
1168                transition: opacity 0.2s, transform 0.2s;
1169                display: flex;
1170                align-items: center;
1171                justify-content: center;
1172                box-shadow: 0 2px 4px rgba(0,0,0,0.3);
1173              " onmouseover="this.style.opacity='1';this.style.transform='scale(1.2)'" 
1174                 onmouseout="this.style.opacity='0.7';this.style.transform='scale(1)'">
1175                <svg width="8" height="8" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="3" stroke-linecap="round">
1176                  <line x1="12" y1="5" x2="12" y2="19"></line>
1177                  <line x1="5" y1="12" x2="19" y2="12"></line>
1178                </svg>
1179              </div>`,iconSize:[16,16],iconAnchor:[8,8]})}).addTo(pe.current);Pt.bindTooltip("Click to add point",{direction:"top",offset:[0,-10],opacity:.9});const Qt=pt+1;Pt.on("click",Ft=>{Bt.DomEvent.stopPropagation(Ft),hs(Gt=>{const ms=[...Gt];return ms.splice(Qt,0,{lat:yt,lng:at}),ms})}),Ta.current.push(Pt)}};At.length>=2&&Oe(),At.forEach((lt,pt)=>{const It=pt===0,yt=It?"#22c55e":"#ffffff",at=Bt.divIcon({className:"polygon-drawing-point",html:`<div style="
1180            width: 14px;
1181            height: 14px;
1182            border-radius: 50%;
1183            background: ${yt};
1184            border: 2px solid #f59e0b;
1185            cursor: grab;
1186            box-shadow: 0 2px 4px rgba(0,0,0,0.3);
1187          "></div>`,iconSize:[14,14],iconAnchor:[7,7]}),Pt=Bt.marker([lt.lat,lt.lng],{icon:at,draggable:!0,zIndexOffset:1e3}).addTo(pe.current);It&&At.length>=3?(Pt.bindTooltip("Click to close polygon",{permanent:!1,direction:"top"}),Pt.on("click",Qt=>{var Ft;Qt.originalEvent.stopPropagation(),Qt.originalEvent.preventDefault(),(Ft=yr.current)==null||Ft.call(yr)})):Pt.bindTooltip(`Point ${pt+1} - Drag to move, right-click to delete`,{direction:"top",offset:[0,-10],opacity:.9}),Pt.on("contextmenu",Qt=>{Qt.originalEvent.stopPropagation(),Qt.originalEvent.preventDefault();
1187const Ft=document.querySelector(".polygon-drawing-context-menu");Ft&&Ft.remove();const Gt=3,ms=At.length>Gt,Wt=document.createElement("div");Wt.className="polygon-drawing-context-menu",Wt.style.cssText=`
1188            position: fixed;
1189            left: ${Qt.originalEvent.clientX}px;
1190            top: ${Qt.originalEvent.clientY}px;
1191            background: hsl(var(--card));
1192            border: 1px solid hsl(var(--border));
1193            border-radius: 6px;
1194            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
1195            z-index: 99999;
1196            min-width: 150px;
1197            overflow: hidden;
1198          `;const Ss=document.createElement("button");if(Ss.innerHTML=`
1199            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="margin-right: 8px;">
1200              <path d="M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
1201            </svg>
1202            Delete Point ${pt+1}
1203          `,Ss.style.cssText=`
1204            display: flex;
1205            align-items: center;
1206            width: 100%;
1207            padding: 10px 14px;
1208            border: none;
1209            background: transparent;
1210            color: ${ms?"hsl(var(--destructive))":"hsl(var(--muted-foreground))"};
1211            cursor: ${ms?"pointer":"not-allowed"};
1212            font-size: 13px;
1213            text-align: left;
1214            opacity: ${ms?"1":"0.5"};
1215          `,ms&&(Ss.onmouseover=()=>{Ss.style.background="hsl(var(--accent))"},Ss.onmouseout=()=>{Ss.style.background="transparent"},Ss.onclick=()=>{hs(hn=>hn.filter((Vn,ka)=>ka!==pt)),Wt.remove()}),Wt.appendChild(Ss),!ms){const hn=document.createElement("div");hn.style.cssText=`
1216              padding: 8px 14px;
1217              font-size: 11px;
1218              color: hsl(var(--muted-foreground));
1219              border-top: 1px solid hsl(var(--border));
1220            `,hn.textContent=`Min ${Gt} points required`,Wt.appendChild(hn)}document.body.appendChild(Wt);const Ms=hn=>{Wt.contains(hn.target)||(Wt.remove(),document.removeEventListener("click",Ms))};setTimeout(()=>document.addEventListener("click",Ms),0)}),Pt.on("dragstart",()=>{const Qt=Pt.getElement();Qt&&(Qt.style.cursor="grabbing"),Pt.closeTooltip()}),Pt.on("drag",()=>{const Qt=Pt.getLatLng(),Ft=[...Ne];Ft[pt]=[Qt.lat,Qt.lng],_n.current&&_n.current.setLatLngs(Ft)}),Pt.on("dragend",Qt=>{const Ft=Qt.target.getLatLng();hs(Gt=>{const ms=[...Gt];return ms[pt]={lat:Ft.lat,lng:Ft.lng},ms})}),Ta.current.push(Pt)})}},[At,Se]),k.useEffect(()=>{if(pe.current&&(Ac.current&&(Ac.current.remove(),Ac.current=null),Uc.current.forEach(Ne=>Ne.remove()),Uc.current=[],cr&&$a.length>0)){const Ne=$a.map(lt=>[lt.lat,lt.lng]);zi==="polygon"&&$a.length>=2?Ac.current=Bt.polygon(Ne,{color:"#3b82f6",weight:3,fillColor:"#3b82f6",fillOpacity:.2,dashArray:"5, 5"}).addTo(pe.current):zi==="polyline"&&$a.length>=1&&(Ac.current=Bt.polyline(Ne,{color:"#3b82f6",weight:3,dashArray:"5, 5"}).addTo(pe.current));const Oe=()=>{const lt=$a,pt=zi==="polygon"?lt.length:lt.length-1;for(let It=0;It<pt;It++){const yt=(It+1)%lt.length;if(zi==="polyline"&&yt===0)continue;const at=(lt[It].lat+lt[yt].lat)/2,Pt=(lt[It].lng+lt[yt].lng)/2,Qt=Bt.marker([at,Pt],{icon:Bt.divIcon({className:"overlay-midpoint-marker",html:`<div style="
1221                width: 16px;
1222                height: 16px;
1223                background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
1224                border: 2px solid white;
1225                border-radius: 50%;
1226                cursor: pointer;
1227                opacity: 0.7;
1228                transition: opacity 0.2s, transform 0.2s;
1229                display: flex;
1230                align-items: center;
1231                justify-content: center;
1232                box-shadow: 0 2px 4px rgba(0,0,0,0.3);
1233              " onmouseover="this.style.opacity='1';this.style.transform='scale(1.2)'" 
1234                 onmouseout="this.style.opacity='0.7';this.style.transform='scale(1)'">
1235                <svg width="8" height="8" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="3" stroke-linecap="round">
1236                  <line x1="12" y1="5" x2="12" y2="19"></line>
1237                  <line x1="5" y1="12" x2="19" y2="12"></line>
1238                </svg>
1239              </div>`,iconSize:[16,16],iconAnchor:[8,8]})}).addTo(pe.current);Qt.bindTooltip("Click to add point",{direction:"top",offset:[0,-10],opacity:.9});const Ft=It+1;Qt.on("click",Gt=>{Bt.DomEvent.stopPropagation(Gt),jn(ms=>{const Wt=[...ms];return Wt.splice(Ft,0,{lat:at,lng:Pt}),Wt})}),Uc.current.push(Qt)}};$a.length>=2&&Oe(),$a.forEach((lt,pt)=>
1239{const It=pt===0,yt=It?"#22c55e":"#ffffff",at=Bt.divIcon({className:"overlay-drawing-point",html:`<div style="
1240            width: 14px;
1241            height: 14px;
1242            border-radius: 50%;
1243            background: ${yt};
1244            border: 2px solid #3b82f6;
1245            cursor: grab;
1246            box-shadow: 0 2px 4px rgba(0,0,0,0.3);
1247          " title="Drag to reposition${It?" (first point)":""}"></div>`,iconSize:[14,14],iconAnchor:[7,7]}),Pt=Bt.marker([lt.lat,lt.lng],{icon:at,draggable:!0,zIndexOffset:1e3}).addTo(pe.current);Pt.bindTooltip(`Point ${pt+1} - Drag to move, right-click to delete`,{direction:"top",offset:[0,-10],opacity:.9}),Pt.on("contextmenu",Qt=>{Qt.originalEvent.stopPropagation(),Qt.originalEvent.preventDefault();const Ft=document.querySelector(".overlay-drawing-context-menu");Ft&&Ft.remove();const Gt=zi==="polygon"?3:2,ms=$a.length>Gt,Wt=document.createElement("div");Wt.className="overlay-drawing-context-menu",Wt.style.cssText=`
1248            position: fixed;
1249            left: ${Qt.originalEvent.clientX}px;
1250            top: ${Qt.originalEvent.clientY}px;
1251            background: hsl(var(--card));
1252            border: 1px solid hsl(var(--border));
1253            border-radius: 6px;
1254            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
1255            z-index: 99999;
1256            min-width: 150px;
1257            overflow: hidden;
1258          `;const Ss=document.createElement("button");if(Ss.innerHTML=`
1259            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="margin-right: 8px;">
1260              <path d="M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
1261            </svg>
1262            Delete Point ${pt+1}
1263          `,Ss.style.cssText=`
1264            display: flex;
1265            align-items: center;
1266            width: 100%;
1267            padding: 10px 14px;
1268            border: none;
1269            background: transparent;
1270            color: ${ms?"hsl(var(--destructive))":"hsl(var(--muted-foreground))"};
1271            cursor: ${ms?"pointer":"not-allowed"};
1272            font-size: 13px;
1273            text-align: left;
1274            opacity: ${ms?"1":"0.5"};
1275          `,ms&&(Ss.onmouseover=()=>{Ss.style.background="hsl(var(--accent))"},Ss.onmouseout=()=>{Ss.style.background="transparent"},Ss.onclick=()=>{jn(hn=>hn.filter((Vn,ka)=>ka!==pt)),Wt.remove()}),Wt.appendChild(Ss),!ms){const hn=document.createElement("div");hn.style.cssText=`
1276              padding: 8px 14px;
1277              font-size: 11px;
1278              color: hsl(var(--muted-foreground));
1279              border-top: 1px solid hsl(var(--border));
1280            `,hn.textContent=`Min ${Gt} points required`,Wt.appendChild(hn)}document.body.appendChild(Wt);const Ms=hn=>{Wt.contains(hn.target)||(Wt.remove(),document.removeEventListener("click",Ms))};setTimeout(()=>document.addEventListener("click",Ms),0)}),Pt.on("dragend",Qt=>{const Ft=Qt.target.getLatLng();jn(Gt=>{const ms=[...Gt];return ms[pt]={lat:Ft.lat,lng:Ft.lng},ms})}),Pt.on("dragstart",()=>{const Qt=Pt.getElement();Qt&&(Qt.style.cursor="grabbing"),Pt.closeTooltip()}),Pt.on("drag",()=>{const Qt=Pt.getLatLng(),Ft=[...Ne];Ft[pt]=[Qt.lat,Qt.lng],Ac.current&&Ac.current.setLatLngs(Ft)}),It&&$a.length>=3&&zi==="polygon"&&(Pt.unbindTooltip(),Pt.bindTooltip("Click to close polygon",{permanent:!1,direction:"top"}),Pt.on("click",Qt=>{Bt.DomEvent.stopPropagation(Qt.originalEvent),Bt.DomEvent.preventDefault(Qt.originalEvent),xh(!0)})),Uc.current.push(Pt)})}},[$a,cr,zi]),k.useEffect(()=>{if(pe.current){if(Kt.current&&(Kt.current.remove(),Kt.current=null),ss.current.forEach(Ne=>Ne.remove()),ss.current=[],O&&q==="circle"&&Lt){const Ne=Ht*1609.34;Kt.current=Bt.circle([Lt.lat,Lt.lng],{radius:Ne,color:"#8b5cf6",weight:3,fillColor:"#8b5cf6",fillOpacity:.15,dashArray:"5, 5"}).addTo(pe.current);const Oe=Bt.circleMarker([Lt.lat,Lt.lng],{radius:8,color:"#8b5cf6",fillColor:"#22c55e",fillOpacity:1,weight:2}).addTo(pe.current);Oe.bindTooltip(`Radius: ${Ht.toFixed(2)} mi`,{permanent:!0,direction:"top"}),ss.current.push(Oe)}else if(O&&q==="polygon"&&gt.length>0){const Ne=gt.map(lt=>[lt.lat,lt.lng]);Kt.current=Bt.polygon(Ne,{color:"#8b5cf6",weight:3,fillColor:"#8b5cf6",fillOpacity:.15,dashArray:"5, 5"}).addTo(pe.current);const Oe=()=>{const lt=gt;for(let pt=0;pt<lt.length;pt++){const It=(pt+1)%lt.length,yt=(lt[pt].lat+lt[It].lat)/2,at=(lt[pt].lng+lt[It].lng)/2,Pt=Bt.marker([yt,at],{icon:Bt.divIcon({className:"region-midpoint-marker",html:`<div style="
1281                width: 16px;
1282                height: 16px;
1283                background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
1284                border: 2px solid white;
1285                border-radius: 50%;
1286                cursor: pointer;
1287                opacity: 0.7;
1288                transition: opacity 0.2s, transform 0.2s;
1289                display: flex;
1290                align-items: center;
1291                justify-content: center;
1292                box-shadow: 0 2px 4px rgba(0,0,0,0.3);
1293              " onmouseover="this.style.opacity='1';this.style.transform='scale(1.2)'" 
1294                 onmouseout="this.style.opacity='0.7';this.style.transform='scale(1)'">
1295                <svg width="8" height="8" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="3" stroke-linecap="round">
1296                  <line x1="12" y1="5" x2="12" y2="19"></line>
1297                  <line x1="5" y1="12" x2="19" y2="12"></line>
1298                </svg>
1299              </div>`,iconSize:[16,16],iconAnchor:[8,8]})}).addTo(pe.current);Pt.bindTooltip("Click to add point",{direction:"top",offset:[0,-10],opacity:.9});const Qt=pt+1;Pt.on("click",Ft=>
1299{Bt.DomEvent.stopPropagation(Ft),St(Gt=>{const ms=[...Gt];return ms.splice(Qt,0,{lat:yt,lng:at}),ms})}),ss.current.push(Pt)}};gt.length>=2&&Oe(),gt.forEach((lt,pt)=>{const It=pt===0,yt=It?"#22c55e":"#ffffff",at=Bt.marker([lt.lat,lt.lng],{draggable:!0,icon:Bt.divIcon({className:"region-point-marker",html:`<div style="
1300              width: 14px;
1301              height: 14px;
1302              border-radius: 50%;
1303              background: ${yt};
1304              border: 2px solid #8b5cf6;
1305              cursor: grab;
1306              box-shadow: 0 2px 4px rgba(0,0,0,0.3);
1307            "></div>`,iconSize:[14,14],iconAnchor:[7,7]})}).addTo(pe.current);It&&gt.length>=3?at.bindTooltip("Click to complete",{permanent:!1}):at.bindTooltip(`Point ${pt+1} - Drag to move, right-click to delete`,{direction:"top",offset:[0,-10],opacity:.9}),at.on("contextmenu",Pt=>{Pt.originalEvent.stopPropagation(),Pt.originalEvent.preventDefault();const Qt=document.querySelector(".region-drawing-context-menu");Qt&&Qt.remove();const Ft=3,Gt=gt.length>Ft,ms=document.createElement("div");ms.className="region-drawing-context-menu",ms.style.cssText=`
1308            position: fixed;
1309            left: ${Pt.originalEvent.clientX}px;
1310            top: ${Pt.originalEvent.clientY}px;
1311            background: hsl(var(--card));
1312            border: 1px solid hsl(var(--border));
1313            border-radius: 6px;
1314            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
1315            z-index: 99999;
1316            min-width: 150px;
1317            overflow: hidden;
1318          `;const Wt=document.createElement("button");if(Wt.innerHTML=`
1319            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="margin-right: 8px;">
1320              <path d="M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
1321            </svg>
1322            Delete Point ${pt+1}
1323          `,Wt.style.cssText=`
1324            display: flex;
1325            align-items: center;
1326            width: 100%;
1327            padding: 10px 14px;
1328            border: none;
1329            background: transparent;
1330            color: ${Gt?"hsl(var(--destructive))":"hsl(var(--muted-foreground))"};
1331            cursor: ${Gt?"pointer":"not-allowed"};
1332            font-size: 13px;
1333            text-align: left;
1334            opacity: ${Gt?"1":"0.5"};
1335          `,Gt&&(Wt.onmouseover=()=>{Wt.style.background="hsl(var(--accent))"},Wt.onmouseout=()=>{Wt.style.background="transparent"},Wt.onclick=()=>{St(Ms=>Ms.filter((hn,Vn)=>Vn!==pt)),ms.remove()}),ms.appendChild(Wt),!Gt){const Ms=document.createElement("div");Ms.style.cssText=`
1336              padding: 8px 14px;
1337              font-size: 11px;
1338              color: hsl(var(--muted-foreground));
1339              border-top: 1px solid hsl(var(--border));
1340            `,Ms.textContent=`Min ${Ft} points required`,ms.appendChild(Ms)}document.body.appendChild(ms);const Ss=Ms=>{ms.contains(Ms.target)||(ms.remove(),document.removeEventListener("click",Ss))};setTimeout(()=>document.addEventListener("click",Ss),0)}),at.on("dragstart",()=>{const Pt=at.getElement();Pt&&(Pt.style.cursor="grabbing"),at.closeTooltip()}),at.on("drag",()=>{const Pt=at.getLatLng(),Qt=[...Ne];Qt[pt]=[Pt.lat,Pt.lng],Kt.current&&Kt.current.setLatLngs(Qt)}),at.on("dragend",Pt=>{const Qt=Pt.target.getLatLng();St(Ft=>{const Gt=[...Ft];return Gt[pt]={lat:Qt.lat,lng:Qt.lng},Gt})}),It&&gt.length>=3&&at.on("click",()=>{gt.length>=3&&Q&&(Q({type:"polygon",points:gt}),St([]))}),ss.current.push(at)})}}},[O,q,Lt,Ht,gt,Q]),k.useEffect(()=>{if(!pe.current||(Hn.current&&(Hn.current.remove(),Hn.current=null),Ra.current.forEach(lt=>lt.remove()),Ra.current=[],!fe||Js.length===0))return;const Ne=Js.map(lt=>[lt.lat,lt.lng]);Hn.current=Bt.polygon(Ne,{color:"#f97316",weight:3,fillColor:"#f97316",fillOpacity:.2,dashArray:"5, 5"}).addTo(pe.current);const Oe=()=>{const lt=Js;for(let pt=0;pt<lt.length;pt++){const It=(pt+1)%lt.length,yt=(lt[pt].lat+lt[It].lat)/2,at=(lt[pt].lng+lt[It].lng)/2,Pt=Bt.marker([yt,at],{icon:Bt.divIcon({className:"assemblage-midpoint-marker",html:`<div style="
1341              width: 16px;
1342              height: 16px;
1343              background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
1344              border: 2px solid white;
1345              border-radius: 50%;
1346              cursor: pointer;
1347              opacity: 0.7;
1348              transition: opacity 0.2s, transform 0.2s;
1349              display: flex;
1350              align-items: center;
1351              justify-content: center;
1352              box-shadow: 0 2px 4px rgba(0,0,0,0.3);
1353            " onmouseover="this.style.opacity='1';this.style.transform='scale(1.2)'" 
1354               onmouseout="this.style.opacity='0.7';this.style.transform='scale(1)'">
1355              <svg width="8" height="8" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="3" stroke-linecap="round">
1356                <line x1="12" y1="5" x2="12" y2="19"></line>
1357                <line x1="5" y1="12" x2="19" y2="12"></line>
1358              </svg>
1359            </div>`,iconSize:[16,16],iconAnchor:[8,8]})}).addTo(pe.current);Pt.bindTooltip("Click to add point",{direction:"top",offset:[0,-10],opacity:.9});const Qt=pt+1;Pt.on("click",Ft=>
1359{Bt.DomEvent.stopPropagation(Ft),on(Gt=>{const ms=[...Gt];return ms.splice(Qt,0,{lat:yt,lng:at}),ms})}),Ra.current.push(Pt)}};Js.length>=2&&Oe(),Js.forEach((lt,pt)=>{const It=Bt.marker([lt.lat,lt.lng],{draggable:!0,icon:Bt.divIcon({className:"assemblage-point-marker",html:`<div style="
1360            width: 14px;
1361            height: 14px;
1362            border-radius: 50%;
1363            background: ${pt===0?"#22c55e":"#ffffff"};
1364            border: 2px solid #f97316;
1365            cursor: grab;
1366            box-shadow: 0 1px 3px rgba(0,0,0,0.3);
1367          "></div>`,iconSize:[14,14],iconAnchor:[7,7]})}).addTo(pe.current);pt===0&&Js.length>=3?It.bindTooltip("Click to complete",{permanent:!1}):It.bindTooltip(`Point ${pt+1} - Drag to move, right-click to delete`,{direction:"top",offset:[0,-10],opacity:.9}),It.on("contextmenu",yt=>{yt.originalEvent.stopPropagation(),yt.originalEvent.preventDefault();const at=document.querySelector(".assemblage-drawing-context-menu");at&&at.remove();const Pt=3,Qt=Js.length>Pt,Ft=document.createElement("div");Ft.className="assemblage-drawing-context-menu",Ft.style.cssText=`
1368          position: fixed;
1369          left: ${yt.originalEvent.clientX}px;
1370          top: ${yt.originalEvent.clientY}px;
1371          background: hsl(var(--card));
1372          border: 1px solid hsl(var(--border));
1373          border-radius: 6px;
1374          box-shadow: 0 4px 12px rgba(0,0,0,0.15);
1375          z-index: 99999;
1376          min-width: 150px;
1377          overflow: hidden;
1378        `;const Gt=document.createElement("button");if(Gt.innerHTML=`
1379          <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="margin-right: 8px;">
1380            <path d="M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
1381          </svg>
1382          Delete Point ${pt+1}
1383        `,Gt.style.cssText=`
1384          display: flex;
1385          align-items: center;
1386          width: 100%;
1387          padding: 10px 14px;
1388          border: none;
1389          background: transparent;
1390          color: ${Qt?"hsl(var(--destructive))":"hsl(var(--muted-foreground))"};
1391          cursor: ${Qt?"pointer":"not-allowed"};
1392          font-size: 13px;
1393          text-align: left;
1394          opacity: ${Qt?"1":"0.5"};
1395        `,Qt&&(Gt.onmouseover=()=>{Gt.style.background="hsl(var(--accent))"},Gt.onmouseout=()=>{Gt.style.background="transparent"},Gt.onclick=()=>{on(Wt=>Wt.filter((Ss,Ms)=>Ms!==pt)),Ft.remove()}),Ft.appendChild(Gt),!Qt){const Wt=document.createElement("div");Wt.style.cssText=`
1396            padding: 8px 14px;
1397            font-size: 11px;
1398            color: hsl(var(--muted-foreground));
1399            border-top: 1px solid hsl(var(--border));
1400          `,Wt.textContent=`Min ${Pt} points required`,Ft.appendChild(Wt)}document.body.appendChild(Ft);const ms=Wt=>{Ft.contains(Wt.target)||(Ft.remove(),document.removeEventListener("click",ms))};setTimeout(()=>document.addEventListener("click",ms),0)}),It.on("dragstart",()=>{const yt=It.getElement();yt&&(yt.style.cursor="grabbing"),It.closeTooltip()}),It.on("drag",yt=>{const at=yt.target.getLatLng(),Pt=[...Ne];Pt[pt]=[at.lat,at.lng],Hn.current&&Hn.current.setLatLngs(Pt)}),It.on("dragend",yt=>{const at=yt.target.getLatLng();on(Pt=>{const Qt=[...Pt];return Qt[pt]={lat:at.lat,lng:at.lng},Qt})}),pt===0&&Js.length>=3&&It.on("click",()=>{if(Js.length>=3&&Qe){const yt=[...Js.map(Pt=>[Pt.lng,Pt.lat]),[Js[0].lng,Js[0].lat]];Qe({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[yt]}}),on([])}}),Ra.current.push(It)})},[fe,Js,Qe]),k.useEffect(()=>{fe||on([])},[fe]),k.useEffect(()=>{pe.current&&(Ln.current?Ln.current.clearLayers():Ln.current=Bt.layerGroup().addTo(pe.current),!(!ft||ft.length===0)&&ft.forEach((Ne,Oe)=>{var lt,pt;if(!(!Ne.geometry||!pe.current))try{const It=Ne.geometry.type==="Feature"?Ne.geometry:{type:"Feature",properties:{},geometry:Ne.geometry},yt=Bt.geoJSON(It,{style:{color:"#f97316",weight:3,fillColor:"#f97316",fillOpacity:.3,opacity:1},pane:"markersPane"}),at=yt.getBounds();if(at.isValid()){const Pt=at.getCenter(),Qt=Ne.name||`Custom Area ${Oe+1}`,Ft=Bt.marker(Pt,{pane:"markersPane",icon:Bt.divIcon({className:"custom-area-label",html:`<div style="background: rgba(249, 115, 22, 0.9); color: white; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,0.3);">${Qt}</div>`,iconSize:[0,0],iconAnchor:[0,0]})});(lt=Ln.current)==null||lt.addLayer(Ft)}(pt=Ln.current)==null||pt.addLayer(yt)}catch(It){console.warn("Failed to render assemblage custom area:",It)}}))},[ft]);const Fd=k.useRef(null),Ul=k.useRef(null),Hh=k.useCallback((Ne,Oe,lt=90)=>{const It=lt*Math.PI/180,yt=Ne.lat*Math.PI/180,at=Ne.lng*Math.PI/180,Pt=Oe/3959,Qt=Math.asin(Math.sin(yt)*Math.cos(Pt)+Math.cos(yt)*Math.sin(Pt)*Math.cos(It)),Ft=at+Math.atan2(Math.sin(It)*Math.sin(Pt)*Math.cos(yt),Math.cos(Pt)-Math.sin(yt)*Math.sin(Qt));return{lat:Qt*180/Math.PI,lng:Ft*180/Math.PI}},[]),Hg=k.useCallback((Ne,Oe)=>{const pt=(Oe.lat-Ne.lat)*Math.PI/180,It=(Oe.lng-Ne.lng)*Math.PI/180,yt=Math.sin(pt/2)*Math.sin(pt/2)+Math.cos(Ne.lat*Math.PI/180)*Math.cos(Oe.lat*Math.PI/180)*Math.sin(It/2)*Math.sin(It/2);return 3959*(2*Math.atan2(Math.sqrt(yt),Math.sqrt(1-yt)))},[]);k.useEffect(()=>{if(pe.current&&(cs.current&&(cs.current.remove(),cs.current=null),Fd.current&&(Fd.current.remove(),Fd.current=null),Ul.current&&(Ul.current.remove(),Ul.current=null),oe)){if(oe.region_type==="circle"&&oe.center_lat&&oe.center_lng&&oe.radius_miles){const Ne=oe.radiu
1400s_miles*1609.34,Oe=[oe.center_lat,oe.center_lng],lt={lat:oe.center_lat,lng:oe.center_lng};cs.current=Bt.circle(Oe,{radius:Ne,color:"#8b5cf6",weight:3,dashArray:"10, 6",fillColor:"#8b5cf6",fillOpacity:.08,interactive:!0}).addTo(pe.current),cs.current.bindTooltip(`<div class="text-center"><strong>${oe.name}</strong><br/><span class="text-xs">${oe.radius_miles.toFixed(1)} mile radius</span></div>`,{sticky:!0,direction:"top",className:"filter-region-tooltip"}),cs.current.bindPopup(`<div style="text-align: center; padding: 4px;">
1401            <strong style="color: #8b5cf6;">${oe.name}</strong><br/>
1402            <span style="font-size: 12px;">Radius: ${oe.radius_miles.toFixed(1)} miles</span><br/>
1403            <span style="font-size: 11px; color: #888;">Drag edge handle to resize • Click "Clear Filter" to remove</span>
1404          </div>`,{closeButton:!0,autoPan:!0,closeOnClick:!1});const pt=Bt.divIcon({className:"region-center-label",html:`
1405            <div style="
1406              display: flex;
1407              flex-direction: column;
1408              align-items: center;
1409              transform: translate(-50%, -50%);
1410            ">
1411              <div style="
1412                width: 12px;
1413                height: 12px;
1414                background: #8b5cf6;
1415                border: 2px solid white;
1416                border-radius: 50%;
1417                box-shadow: 0 2px 6px rgba(139, 92, 246, 0.4);
1418              "></div>
1419              <div style="
1420                margin-top: 4px;
1421                background: rgba(139, 92, 246, 0.9);
1422                color: white;
1423                padding: 2px 8px;
1424                border-radius: 4px;
1425                font-size: 11px;
1426                font-weight: 600;
1427                white-space: nowrap;
1428                box-shadow: 0 2px 6px rgba(0,0,0,0.2);
1429              ">${oe.radius_miles.toFixed(1)} mi</div>
1430            </div>
1431          `,iconSize:[0,0],iconAnchor:[0,0]});if(Fd.current=Bt.marker(Oe,{icon:pt,interactive:!1}).addTo(pe.current),ce){const yt=Hh(lt,oe.radius_miles,90),at=Bt.divIcon({className:"region-edge-handle",html:`
1432              <div style="
1433                width: 20px;
1434                height: 20px;
1435                background: white;
1436                border: 3px solid #8b5cf6;
1437                border-radius: 50%;
1438                box-shadow: 0 2px 8px rgba(0,0,0,0.3);
1439                cursor: ew-resize;
1440                display: flex;
1441                align-items: center;
1442                justify-content: center;
1443                transform: translate(-50%, -50%);
1444              ">
1445                <div style="
1446                  width: 6px;
1447                  height: 10px;
1448                  display: flex;
1449                  flex-direction: column;
1450                  justify-content: space-between;
1451                ">
1452                  <div style="width: 100%; height: 2px; background: #8b5cf6;"></div>
1453                  <div style="width: 100%; height: 2px; background: #8b5cf6;"></div>
1454                  <div style="width: 100%; height: 2px; background: #8b5cf6;"></div>
1455                </div>
1456              </div>
1457            `,iconSize:[20,20],iconAnchor:[10,10]});Ul.current=Bt.marker([yt.lat,yt.lng],{icon:at,draggable:!0,autoPan:!0}).addTo(pe.current),Ul.current.bindTooltip("Drag to resize radius",{direction:"top",offset:[0,-12],permanent:!1}),Ul.current.on("dragstart",()=>{Ul.current&&(Ul.current.unbindTooltip(),Ul.current.bindTooltip(`<div style="font-weight: 600; font-size: 13px; padding: 2px 4px;">${oe.radius_miles.toFixed(1)} mi</div>`,{direction:"top",offset:[0,-12],permanent:!0,className:"radius-drag-tooltip"}).openTooltip())}),Ul.current.on("drag",Pt=>{const Ft=Pt.target.getLatLng(),Gt=Hg(lt,{lat:Ft.lat,lng:Ft.lng}),ms=Math.max(.1,Math.min(100,Gt));if(Ul.current&&Ul.current.setTooltipContent(`<div style="font-weight: 600; font-size: 13px; padding: 2px 4px;">${ms.toFixed(1)} mi</div>`),cs.current&&cs.current.setRadius(ms*1609.34),Fd.current){const Wt=Bt.divIcon({className:"region-center-label",html:`
1458                  <div style="
1459                    display: flex;
1460                    flex-direction: column;
1461                    align-items: center;
1462                    transform: translate(-50%, -50%);
1463                  ">
1464                    <div style="
1465                      width: 12px;
1466                      height: 12px;
1467                      background: #8b5cf6;
1468                      border: 2px solid white;
1469                      border-radius: 50%;
1470                      box-shadow: 0 2px 6px rgba(139, 92, 246, 0.4);
1471                    "></div>
1472                    <div style="
1473                      margin-top: 4px;
1474                      background: rgba(139, 92, 246, 0.9);
1475                      color: white;
1476                      padding: 2px 8px;
1477                      border-radius: 4px;
1478                      font-size: 11px;
1479                      font-weight: 600;
1480                      white-space: nowrap;
1481                      box-shadow: 0 2px 6px rgba(0,0,0,0.2);
1482                    ">${Gt.toFixed(1)} mi</div>
1483                  </div>
1484                `,iconSize:[0,0],iconAnchor:[0,0]});Fd.current.setIcon(Wt)}}),Ul.current.on("dragend",Pt=>{const Ft=Pt.target.getLatLng(),Gt=Hg(lt,{lat:Ft.lat,lng:Ft.lng}),ms=Math.max(.1,Math.min(100,Gt));Ul.current&&(Ul.current.closeTooltip(),Ul.current.unbindTooltip(),Ul.current.bindTooltip("Drag to resize radius",{direction:"top",offset:[0,-12],permanent:!1})),ce(ms),Ve.success(`Radius updated to ${ms.toFixed(1)} miles`)})}const It=cs.current.getBounds();pe.current.fitBounds(It,{padding:[50,50],maxZoom:14})}else if(oe.region_type==="polygon"&&oe.polygon_points&&oe.polygon_points.length>=3){const Ne=oe.polygon_points,Oe=Ne.map(pt=>[pt.lat,pt.lng]);cs.current=Bt.polygon(Oe,{color:"#8b5cf6",weight:3,dashArray:"10, 6",fillColor:"#8b5cf6",fillOpacity:.08,interactive:!0}).addTo(pe.current),cs.current.bindTooltip(`<div class="text-center"><strong>${oe.name}</strong><br/><span class="text-xs">Polygon filter</span></div>`,{sticky:!0,direction:"top",className:"filter-region-tooltip"}),cs.current.bindPopup(`<div style="text-align: center; padding: 4px;">
1485            <strong style="color: #8b5cf6;">${oe.name}</strong><br/>
1486            <span style="font-size: 12px;">Polygon filter (${Ne.length} points)</span><br/>
1487            <span style="font-size: 11px; color: #888;">Click "Clear Filter" to remove</span>
1488          </div>`,{closeButton:!0,autoPan:!0,closeOnClick:!1});const lt=cs.current.getBounds();pe.current.fitBounds(lt,{padding:[50,50],maxZoom:14})}}},[oe,ce,Hh,Hg]);const Nu=k.useRef(null),Oi=k.useRef(null);k.useEffect(()=>{if(pe.current){if(Nu.current&&(Nu.current.remove(),Nu.current=null),Oi.current&&(Oi.current.remove(),Oi.current=null),bs){const Ne=bs.type==="development"?"#f59e0b":"#06b6d4";Oi.current=Bt.polyline([[bs.originalLat,bs.originalLng],[bs.lat,bs.lng]],{color:Ne,weight:2,dashArray:"8, 8",opacity:.8}).addTo(pe.current);const Oe=Bt.divIcon({className:"preview-marker-wrapper",html:`
1489          <div style="
1490            position: relative;
1491            width: 44px;
1492            height: 44px;
1493          ">
1494            <div style="
1495              width: 40px;
1496              height: 40px;
1497              background: ${Ne};
1498              border: 3px solid white;
1499              border-radius: 50%;
1500              box-shadow: 0 4px 12px rgba(0,0,0,0.4), 0 0 20px ${Ne}40;
1501              display: flex;
1502              align-items: center;
1503              justify-content: center;
1504              cursor: grab;
1505              animation: pulse-preview 2s infinite;
1506            ">
1507              <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
1508                <path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/>
1509                <circle cx="12" cy="10" r="3"/>
1510              </svg>
1511            </div>
1512            <div style="
1513              position: absolute;
1514              top: -28px;
1515              left: 50%;
1516              transform: translateX(-50%);
1517              background: ${Ne};
1518              color: white;
1519              padding: 3px 8px;
1520              border-radius: 4px;
1521              font-size: 11px;
1522              font-weight: 600;
1523              white-space: nowrap;
1524              box-shadow: 0 2px 6px rgba(0,0,0,0.3);
1525            ">
1526              New Location
1527            </div>
1528          </div>
1529        `,iconSize:[44,44],iconAnchor:[22,22]});Nu.current=Bt.marker([bs.lat,bs.lng],{icon:Oe,draggable:!0,zIndexOffset:1e3}).addTo(pe.current),Nu.current.on("drag",lt=>{const It=lt.target.getLatLng();Oi.current&&Oi.current.setLatLngs([[bs.originalLat,bs.originalLng],[It.lat,It.lng]])}),Nu.current.on("dragend",lt=>{const pt=lt.target.getLatLng();en&&en(pt.lat,pt.lng)}),Nu.current.bindTooltip("Drag to adjust location",{direction:"bottom",offset:[0,20],opacity:.9})}return()=>{Nu.current&&(Nu.current.remove(),Nu.current=null),Oi.current&&(Oi.current.remove(),Oi.current=null)}}},[bs,en]);const Yu=k.useRef(null);k.useEffect(()=>{if(pe.current){if(Yu.current&&(Yu.current.remove(),Yu.current=null),Jt){const Oe=Jt.type==="existing"?"#06b6d4":"#f59e0b",lt=Bt.divIcon({className:"temporary-marker-icon",html:`
1530          <div style="
1531            position: relative;
1532            width: 60px;
1533            height: 60px;
1534          ">
1535            <div style="
1536              position: absolute;
1537              width: 60px;
1538              height: 60px;
1539              background: ${Oe};
1540              border-radius: 50%;
1541              opacity: 0.4;
1542              animation: tempMarkerPulse 1.5s ease-in-out infinite;
1543            "></div>
1544            <div style="
1545              position: absolute;
1546              width: 40px;
1547              height: 40px;
1548              top: 10px;
1549              left: 10px;
1550              background: ${Oe};
1551              border-radius: 50%;
1552              opacity: 0.5;
1553              animation: tempMarkerPulse 1.5s ease-in-out infinite 0.3s;
1554            "></div>
1555            <div style="
1556              position: absolute;
1557              top: 50%;
1558              left: 50%;
1559              transform: translate(-50%, -50%);
1560              width: 28px;
1561              height: 28px;
1562              background: ${Oe};
1563              border: 4px solid white;
1564              border-radius: 50%;
1565              box-shadow: 0 4px 12px rgba(0,0,0,0.4);
1566            "></div>
1567          </div>
1568        `,iconSize:[60,60],iconAnchor:[30,30]});Yu.current=Bt.marker([Jt.lat,Jt.lng],{icon:lt,interactive:!1,zIndexOffset:3e3}).addTo(pe.current),Yu.current.bindTooltip(Jt.name,{permanent:!0,direction:"top",offset:[0,-35],className:"temporary-marker-tooltip"}).openTooltip();const pt=pe.current.getZoom(),It=Math.max(pt,14);pe.current.setView([Jt.lat,Jt.lng],It,{animate:!0,duration:.5})}return()=>{Yu.current&&(Yu.current.remove(),Yu.current=null)}}},[Jt]),k.useEffect(()=>{O||(St([]),Vt(null),Et(0),Kt.current&&(Kt.current.remove(),Kt.current=null),ss.current.forEach(Ne=>Ne.remove()),ss.current=[])},[O]),k.useEffect(()=>{if(pe.current&&(_e.current&&(_e.current.remove(),_e.current=null),Ie.current.forEach(Ne=>Ne.remove()),Ie.current=[],A&&se.length>0)){const Ne=se.map(lt=>[lt.lat,lt.lng]);ee==="area"&&se.length>=2?_e.current=Bt.polygon(Ne,{color:"#10b981",weight:3,fillColor:"#10b981",fillOpacity:.2,dashArray:"5, 5",interactive:!1}).addTo(pe.current):ee==="distance"&&se.length>=1&&(_e.current=Bt.polyline(Ne,{color:"#10b981",weight:3,dashArray:"5, 5",interactive:!1}).addTo(pe.current));const Oe=()=>{const lt=se,pt=ee==="area"?lt.length:lt.length-1;for(let It=0;It<pt;It++){const yt=(It+1)%lt.length;if(ee==="distance"&&yt===0)continue;const at=(lt[It].lat+lt[yt].lat)/2,Pt=(lt[It].lng+lt[yt].lng)/2,Qt=Bt.marker([at,Pt],{icon:Bt.divIcon({className:"measurement-midpoint-marker",html:`<div style="
1569                width: 18px;
1570                height: 18px;
1571                background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
1572                border: 2px solid white;
1573                border-radius: 50%;
1574                cursor: pointer;
1575                opacity: 0.7;
1576                transition: opacity 0.2s, transform 0.2s;
1577                display: flex;
1578                align-items: center;
1579                justify-content: center;
1580                box-shadow: 0 2px 4px rgba(0,0,0,0.3);
1581              " onmouseover="this.style.opacity='1';this.style.transform='scale(1.2)'" 
1582                 onmouseout="this.style.opacity='0.7';this.style.transform='scale(1)'">
1583                <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="3" stroke-linecap="round">
1584                  <line x1="12" y1="5" x2="12" y2="19"></line>
1585                  <line x1="5" y1="12" x2="19" y2="12"></line>
1586                </svg>
1587              </div>`,iconSize:[18,18],iconAnchor:[9,9]})}).addTo(pe.current);Qt.bindTooltip("Click to add point",{direction:"top",offset:[0,-10],opacity:.9});const Ft=It+1;Qt.on("click",Gt=>{Bt.DomEvent.stopPropagation(Gt),he(ms=>{const Wt=[...ms];return Wt.splice(Ft,0,{lat:at,lng:Pt}),Wt})}),Ie.current.push(Qt)}};se.length>=2&&Oe(),se.forEach((lt,pt)=>{const It=Bt.marker([lt.lat,lt.lng],{draggable:!0,icon:Bt.divIcon({className:"measurement-drag-marker",html:`<div style="
1588              width: 14px;
1589              height: 14px;
1590              background: ${pt===0?"#22c55e":"#ffffff"};
1591              border: 2px solid #10b981;
1592              border-radius: 50%;
1593              cursor: grab;
1594              box-shadow: 0 2px 4px rgba(0,0,0,0.3);
1595            "></div>`,iconSize:[14,14],iconAnchor:[7,7]})}).addTo(pe.current);It.bindTooltip(`Point ${pt+1} - Drag to move, right-click for options`,{direction:"top",offset:[0,-10],opacity:.9}),It.on("contextmenu",yt=>{yt.originalEvent.stopPropagation(),yt.originalEvent.preventDefault();const at=document.querySelector(".measurement-context-menu");at&&at.remove();const Pt=ee==="area"?3:2,Qt=se.length>Pt,Ft=document.createElement("div");Ft.className="measurement-context-menu",Ft.style.cssText=`
1596            position: fixed;
1597            left: ${yt.originalEvent.clientX}px;
1598            top: ${yt.originalEvent.clientY}px;
1599            background: hsl(var(--card));
1600            border: 1px solid hsl(var(--border));
1601            border-radius: 6px;
1602            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
1603            z-index: 99999;
1604            min-width: 150px;
1605            overflow: hidden;
1606          `;const Gt=document.createElement("button");if(Gt.innerHTML=`
1607            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="margin-right: 8px;">
1608              <path d="M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
1609            </svg>
1610            Delete Point ${pt+1}
1611          `,Gt.style.cssText=`
1612            display: flex;
1613            align-items: center;
1614            width: 100%;
1615            padding: 10px 14px;
1616            border: none;
1617            background: transparent;
1618            color: ${Qt?"hsl(var(--destructive))":"hsl(var(--muted-foreground))"};
1619            cursor: ${Qt?"pointer":"not-allowed"};
1620            font-size: 13px;
1621            text-align: left;
1622            opacity: ${Qt?"1":"0.5"};
1623          `,Qt&&(Gt.onmouseover=()=>{Gt.style.background="hsl(var(--accent))"},Gt.onmouseout=()=>{Gt.style.background="transparent"},Gt.onclick=()=>{he(Wt=>Wt.filter((Ss,Ms)=>Ms!==pt)),Ft.remove()}),Ft.appendChild(Gt),!Qt){const Wt=document.createElement("div");Wt.style.cssText=`
1624              padding: 8px 14px;
1625              font-size: 11px;
1626              color: hsl(var(--muted-foreground));
1627              border-top: 1px solid hsl(var(--border));
1628            `,Wt.textContent=`Min ${Pt} points required`,Ft.appendChild(Wt)}document.body.appendChild(Ft);const ms=Wt=>{Ft.contains(Wt.target)||(Ft.remove(),document.removeEventListener("click",ms))};setTimeout(()=>document.addEventListener("click",ms),0)}),It.on("dragstart",yt=>{var Pt;yt.target.getLatLng(),It.closeTooltip(),(Pt=It.getElement())==null||Pt.style.setProperty("cursor","grabbing")}),It.on("drag",yt=>{const Pt=yt.target.getLatLng();if(_e.current&&"setLatLngs"in _e.current){const Qt=_e.current.getLatLngs(),Gt=(Array.isArray(Qt[0])?Qt[0]:Qt).map((ms,Wt)=>Wt===pt?Pt:ms);_e.current.setLatLngs(Gt)}}),It.on("dragend",yt=>{var Qt;const Pt=yt.target.getLatLng();(Qt=It.getElement())==null||Qt.style.setProperty("cursor","grab"),he(Ft=>{const Gt=[...Ft];return Gt[pt]={lat:Pt.lat,lng:Pt.lng},Gt})}),Ie.current.push(It)})}},[se,A,ee]),k.useEffect(()=>{if(pe.current)return Me.current&&(Me.current.remove(),Me.current=null),Je&&A&&(Me.current=Bt.circleMarker([Je.lat,Je.lng],{radius:8,color:"#ffffff",fillColor:"#f97316",fillOpacity:1,weight:3,className:"elevation-hover-marker"}).addTo(pe.current),Me.current.bringToFront()),()=>{Me.current&&(Me.current.remove(),Me.current=null)}},[Je,A]);const Zg=k.useRef(Bh);Zg.current=Bh;
1628const Zh=k.useRef(ri.isTransforming);Zh.current=ri.isTransforming;const Wh=k.useRef(vo.isTransforming);Wh.current=vo.isTransforming;const Yh=k.useRef(null),Mp=k.useRef(""),wm=k.useRef(()=>{});k.useEffect(()=>(wm.current=()=>{Yh.current&&clearTimeout(Yh.current),Yh.current=setTimeout(()=>{const Ne=performance.now(),Oe=pe.current;if(!Oe)return;const lt=Math.floor(Oe.getZoom()),pt=Ba.filter(jt=>lu(jt.layer_type||"")).map(jt=>{var Ys;return`${jt.id}:${((Ys=jt.geometry)==null?void 0:Ys.map(dn=>`${dn.lat.toFixed(7)},${dn.lng.toFixed(7)}`).join(";"))||""}:${jt.building_buffer_ft??0}:${JSON.stringify(jt.building_buffer_edge_config??"")}`}).join("|"),It=Ba.map(jt=>{const Ys=jt.geometry;if(!Ys||Ys.length===0)return`${jt.id}:0`;const dn=Ys[Ys.length-1];return`${jt.id}:${Ys.length}:${Ys[0].lat.toFixed(7)},${Ys[0].lng.toFixed(7)}:${dn.lat.toFixed(7)},${dn.lng.toFixed(7)}`}).join("|"),yt=[Ba.length,Ba.map(jt=>`${jt.id}:${jt.is_visible}:${jt.layer_type}:${jt.updated_at||""}`).join(","),Ba.map(jt=>{var Ys,dn,qn,zs;return`${jt.id}:${(Ys=jt.style)==null?void 0:Ys.color}:${(dn=jt.style)==null?void 0:dn.fillColor}:${(qn=jt.style)==null?void 0:qn.fillOpacity}:${(zs=jt.style)==null?void 0:zs.weight}`}).join(","),xd.map(jt=>`${jt.id}:${jt.is_visible}`).join(","),JSON.stringify(J),ln||"",Rs||"",Dl||"",tn||"",hi?"1":"0",Zl?"1":"0",eo||"",cr?"1":"0",lt,pt,It].join("|");if(yt===Mp.current){console.log("[2D Overlay] Fingerprint match — skipped render in",(performance.now()-Ne).toFixed(1),"ms");return}console.warn("[2D Overlay] Fingerprint CHANGED — full render starting. Overlays:",Ba.length,"Zoom:",lt),Mp.current=yt,wm._cancelBatch&&wm._cancelBatch();const at=[...Hs.current];Hs.current=[];const Pt=50,Qt=jt=>{const Ys=Math.min(jt+Pt,at.length);for(let dn=jt;dn<Ys;dn++)try{at[dn].remove()}catch{}Ys<at.length&&setTimeout(()=>Qt(Ys),0)};if(at.length>0&&Qt(0),!(J.overlays!==!1))return;const Gt="http://www.w3.org/2000/svg",ms=()=>{const jt=Oe.getPane("overlayPane");return(jt==null?void 0:jt.querySelector("svg"))??null},Wt=()=>{const jt=ms();if(!jt)return null;let Ys=jt.querySelector("defs#dw360-overlay-defs");return Ys||(Ys=document.createElementNS(Gt,"defs"),Ys.setAttribute("id","dw360-overlay-defs"),jt.insertBefore(Ys,jt.firstChild)),Ys},Ss=(jt,Ys)=>{const dn=jt.querySelector(`#${CSS.escape(Ys.id)}`);dn&&dn.remove(),jt.appendChild(Ys)},Ms=(jt,Ys,dn,qn)=>{const zs=document.createElementNS(Gt,"pattern");zs.setAttribute("id",jt),zs.setAttribute("patternUnits","userSpaceOnUse"),zs.setAttribute("width","12"),zs.setAttribute("height","12");const mn=document.createElementNS(Gt,"rect");mn.setAttribute("width","12"),mn.setAttribute("height","12"),mn.setAttribute("fill",dn),zs.appendChild(mn);const Xs=(Bs,Dn,gn,un)=>{const Qn=document.createElementNS(Gt,"line");return Qn.setAttribute("x1",Bs),Qn.setAttribute("y1",Dn),Qn.setAttribute("x2",gn),Qn.setAttribute("y2",un),Qn.setAttribute("stroke",qn),Qn.setAttribute("stroke-width","1"),Qn.setAttribute("opacity","0.35"),Qn};if(Ys==="diagonal")zs.appendChild(Xs("0","12","12","0"));else if(Ys==="horizontal")zs.appendChild(Xs("0","6","12","6"));else if(Ys==="vertical")zs.appendChild(Xs("6","0","6","12"));else if(Ys==="crosshatch")zs.appendChild(Xs("0","12","12","0")),zs.appendChild(Xs("0","0","12","12"));else if(Ys==="dots"){const Bs=document.createElementNS(Gt,"circle");Bs.setAttribute("cx","6"),Bs.setAttribute("cy","6"),Bs.setAttribute("r","2"),Bs.setAttribute("fill",qn),Bs.setAttribute("opacity","0.35"),zs.appendChild(Bs)}return zs},hn=(jt,Ys,dn)=>{const qn=Ys==="radial",zs=document.createElementNS(Gt,qn?"radialGradient":"linearGradient");return zs.setAttribute("id",jt),qn?(zs.setAttribute("cx","50%"),zs.setAttribute("cy","50%"),zs.setAttribute("r","50%")):(zs.setAttribute("x1","0%"),zs.setAttribute("y1","0%"),zs.setAttribute("x2","100%"),zs.setAttribute("y2","100%")),dn.forEach((mn,Xs)=>{const Bs=document.createElementNS(Gt,"stop"),Dn=dn.length===1?0:Xs/(dn.length-1)*100;Bs.setAttribute("offset",`${Dn}%`),Bs.setAttribute("stop-color",mn),Bs.setAttribute("stop-opacity","1"),zs.appendChild(Bs)}),zs},Vn=jt=>{requestAnimationFrame(jt)},ka=new Map;
1628xd.forEach(jt=>ka.set(jt.id,jt));const Fa=new Map;Ba.forEach(jt=>Fa.set(jt.id,jt));const Er={overlaysById:Fa,foldersById:ka,allOverlays:Ba,activeGroupId:Ue},Ga=new Set;ln&&Ga.add(ln),Zh.current&&Rs&&Ga.add(Rs),Wh.current&&Dl&&Ga.add(Dl);const Zi=BE(Ba,Er,Ga,!1),Po=jt=>{if(!tn||jt===tn)return!0;const Ys=(mn,Xs)=>{const Bs=new Set;return Xs.forEach((Dn,gn)=>{Dn.parent_overlay_id===mn&&(Bs.add(gn),Ys(gn,Xs).forEach(un=>Bs.add(un)))}),Bs};if(Ys(tn,Fa).has(jt))return!0;const qn=new Set;let zs=tn;for(;zs&&!qn.has(zs);){qn.add(zs);const mn=Fa.get(zs);if(!mn)break;const Xs=mn.parent_overlay_id??null;if(Xs===jt)return!0;zs=Xs}return!1},po={};Zi.forEach(jt=>{po[jt.id]=jt.parent_overlay_id??null});const Pl={},zc=jt=>{if(Pl[jt]!==void 0)return Pl[jt];if(!po[jt])return Pl[jt]=0,0;const dn=new Set;let qn=0,zs=jt;for(;zs&&po[zs]&&!dn.has(zs);)dn.add(zs),qn++,zs=po[zs];return Pl[jt]=qn,qn};Zi.forEach(jt=>zc(jt.id));const di=TE(Zi,Pl),Ku=3,nu={cancelled:!1};wm._cancelBatch=()=>{nu.cancelled=!0};const zn=jt=>{if(nu.cancelled)return;const Ys=Math.min(jt+Ku,di.length);for(let dn=jt;dn<Ys;dn++){if(nu.cancelled)return;const qn=di[dn];pr(qn)}Ys<di.length?requestAnimationFrame(()=>setTimeout(()=>zn(Ys),0)):En()},Ja=[],En=()=>{const jt=Wt();jt&&jt.querySelectorAll('[id^="dw360-pattern-"], [id^="dw360-gradient-"]').forEach(Ys=>{const dn=Ys.id;Ba.some(zs=>zs.is_visible&&(dn.endsWith(zs.id)||dn===`dw360-pattern-${zs.id}`))||Ys.remove()});for(const Ys of Ja)try{Ys.bringToFront()}catch{}console.warn("[2D Overlay] Render complete in",(performance.now()-Ne).toFixed(1),"ms. Layers created:",Hs.current.length,"buildings brought to front:",Ja.length)},pr=jt=>{var ar,Wa,nn,xn,Zn,ua,Ya,Ea,Mr,ao,Oc,ku,au;if(jt.type==="wms"&&jt.wms_url){const Qa=Bt.tileLayer.wms(jt.wms_url,{layers:jt.wms_layers||"",format:jt.wms_format||"image/png",transparent:jt.wms_transparent??!0,attribution:jt.wms_attribution||"",opacity:jt.opacity??1}).addTo(Oe);Hs.current.push(Qa);return}const Ys=hC(jt.geometry);if(!Ys||Ys.length===0)return;const dn=jt.style||{},qn=dn.color||"#3b82f6",zs=dn.fillColor||qn,mn=dn.fillOpacity??.2,Xs=dn.weight??2,Bs=Ys.map(Qa=>[Qa.lat,Qa.lng]);let Dn=null;if(jt.type==="polyline"||jt.type==="highway"){const Qa="overlayBasePane",vi=Po(jt.id),qo=Bt.polyline(Bs,{color:qn,weight:vi?Xs:Xs*.5,opacity:vi?1:.3,dashArray:dn.dashArray,interactive:vi&&!cr,pane:Qa}).addTo(Oe);Dn=qo;const No=Pl[jt.id]??0,ec=Wx(jt.layer_type,No);Vn(()=>{const Ju=qo.getElement();Ju&&(Ju.style.zIndex=String(ec))})}else if(jt.type==="marker"){const Qa=Po(jt.id),vi=Qa?1:.3,qo=Bt.divIcon({className:"custom-overlay-marker",html:`<div style="width: 24px; height: 24px; background: ${qn}; border-radius: 50%; border: 2px solid white; display: flex; align-items: center; justify-content: center; opacity: ${vi};">
1629              <svg width="12" height="12" viewBox="0 0 24 24" fill="white"><circle cx="12" cy="12" r="4"/></svg>
1630            </div>`,iconSize:[24,24],iconAnchor:[12,12]});Dn=Bt.marker(Bs[0],{icon:qo,interactive:Qa&&!cr,pane:"overlayBuildingPane"}).addTo(Oe)}else{const Qa=jt.layer_type==="parking"||jt.layer_type==="parking_field"||jt.layer_type==="parking_zone",vi=new Set(["building_footprint","building_core","warehouse_bay","retail_pad","canopy","trash_enclosure","office_area","building_floor","cold_storage"]),qo=jt.layer_type&&vi.has(jt.layer_type),No=Qa?"overlayParkingPane":qo?"overlayBuildingPane":"overlayBasePane",ec=Po(jt.id),Ju=ec?1:.15,Tl={color:qn,weight:ec?Xs:Xs*.5,fillColor:zs,fillOpacity:jt.image_url?0:mn*Ju,opacity:ec?1:.3,dashArray:dn.dashArray,interactive:ec&&!cr,pane:No};jt.animated_border&&jt.animation_style&&(Tl.className=`polygon-animated-${jt.animation_style}`);const zd=jt.layer_type==="parking_field"||jt.layer_type==="parking"||jt.layer_type==="parking_zone";let To=Bs;if(zd&&Bs.length>=3)try{const fa=g_(jt),pa=p_({parkingOverlay:jt,allOverlays:Ba,settings:fa,getBuildingWithBuffer:wf});if(pa.zones.length>0){const ca=Bs.map(([Jn,yn])=>[yn,Jn]);ca.push([...ca[0]]);let Kn=Xn([ca]);for(const Jn of pa.zones)if(!(!Jn||Jn.length<3))try{const yn=Jn.map(ha=>[ha.lng,ha.lat]);yn.push([...yn[0]]);const cn=Xn([yn]),Wn=pd({type:"FeatureCollection",features:[Kn,cn]});Wn&&Wn.geometry&&(Kn=Wn)}catch{}let Aa=[];((ar=Kn.geometry)==null?void 0:ar.type)==="Polygon"?Aa=Kn.geometry.coordinates.map(Jn=>Jn.map(yn=>[yn[1],yn[0]])):((Wa=Kn.geometry)==null?void 0:Wa.type)==="MultiPolygon"&&(Aa=Kn.geometry.coordinates.flatMap(Jn=>Jn.map(yn=>yn.map(cn=>
1630[cn[1],cn[0]])))),Aa.length>0&&(To=Aa)}}catch(fa){console.warn("[DevelopmentMap] Synchronous parking surface clipping failed:",fa)}const gc=Bt.polygon(To,Tl).addTo(Oe);Dn=gc;const xc=new Set(["building_footprint","building_core","warehouse_bay","retail_pad","canopy","trash_enclosure","office_area","building_floor","cold_storage"]);if(jt.layer_type&&xc.has(jt.layer_type)&&Ja.push(gc),jt.layer_type==="truck_court"){const fa=jt.style,pa=fa==null?void 0:fa.trailerSpots;if(pa&&pa.length>0){const ca=(fa==null?void 0:fa.trailerFillColor)||"#64748b",Kn=(fa==null?void 0:fa.trailerStripingColor)||"#ffffff",Jn=((fa==null?void 0:fa.trailerStripingStyle)||"solid")==="dashed"?"8 4":void 0;for(const yn of pa){const cn=yn.polygon.map(([Wn,ha])=>[ha,Wn]),vn=Bt.polygon(cn,{color:Kn,fillColor:ca,fillOpacity:.35,weight:1,opacity:.8,interactive:!1,pane:No,...Jn?{dashArray:Jn}:{}}).addTo(Oe);Hs.current.push(vn)}}}const Cu=Pl[jt.id]??0,Qu=Wx(jt.layer_type,Cu);if(Vn(()=>{const fa=gc.getElement();fa&&(fa.style.zIndex=String(Qu))}),BT(jt)&&Bs.length>=3){const fa=Bs.map(([Aa,Jn])=>({lat:Aa,lng:Jn})),pa=$T(jt),ca=VT(jt),Kn=OT(fa,pa,ca);Kn.length>0&&Kn.forEach((Aa,Jn)=>{const yn=Aa.geometry.map(vn=>[vn.lat,vn.lng]),cn=Bt.polygon(yn,{color:Aa.color,weight:.5,fillColor:Aa.color,fillOpacity:Aa.opacity,interactive:!1,pane:No}).addTo(Oe);Vn(()=>{const vn=cn.getElement();vn&&(vn.style.zIndex=String(Qu+Jn+1))}),Hs.current.push(cn)})}if(GT(jt)&&Bs.length>=3){const fa=Bs.map(([ca,Kn])=>({lat:ca,lng:Kn})),pa=Yj(jt);if(pa){const ca=qT(fa,pa,pa.buffer_ft||5);if(ca.bufferZone&&ca.bufferZone.geometry.length>=3){const Kn=ca.bufferZone.geometry.map(yn=>[yn.lat,yn.lng]),Aa=fa.map(yn=>[yn.lat,yn.lng]),Jn=Bt.polygon([Kn,Aa],{color:ca.bufferZone.color,weight:1,fillColor:ca.bufferZone.color,fillOpacity:.7,interactive:!1,pane:No}).addTo(Oe);Vn(()=>{const yn=Jn.getElement();yn&&(yn.style.zIndex=String(Qu+50))}),Hs.current.push(Jn)}ca.segments.length>0&&ca.segments.forEach((Kn,Aa)=>{if(Kn.geometry.length<2)return;const Jn=Kn.geometry.map(cn=>[cn.lat,cn.lng]);Jn.push(Jn[0]);const yn=Bt.polyline(Jn,{color:Kn.color,weight:3,opacity:.9,dashArray:pa.type==="chain_link"?"6, 3":void 0,interactive:!1,pane:No}).addTo(Oe);Vn(()=>{const cn=yn.getElement();cn&&(cn.style.zIndex=String(Qu+60))}),Hs.current.push(yn)}),ca.posts.forEach((Kn,Aa)=>{const Jn=Bt.circleMarker([Kn.position.lat,Kn.position.lng],{radius:3,color:Kn.color,fillColor:Kn.color,fillOpacity:1,weight:1,interactive:!1,pane:No}).addTo(Oe);Vn(()=>{const yn=Jn.getElement();yn&&(yn.style.zIndex=String(Qu+65))}),Hs.current.push(Jn)}),ca.barbedWire.length>0&&ca.barbedWire.forEach((Kn,Aa)=>{if(Kn.geometry.length<2)return;const Jn=Kn.geometry.map(cn=>[cn.lat,cn.lng]);Jn.push(Jn[0]);const yn=Bt.polyline(Jn,{color:Kn.color,weight:1.5,opacity:.8,dashArray:"2, 2",interactive:!1,pane:No}).addTo(Oe);Vn(()=>{const cn=yn.getElement();cn&&(cn.style.zIndex=String(Qu+70))}),Hs.current.push(yn)})}}const Ch=lu(jt.layer_type)&&jt.building_buffer_edge_config!=null,Cm=lu(jt.layer_type)&&!Ch&&jt.building_buffer_ft&&jt.building_buffer_ft>0,Fp=Ch&&Object.keys(jt.building_buffer_edge_config).length>0;if(Cm||Fp){const fa=Bs.map(([pa,ca])=>({lat:pa,lng:ca}));br(async()=>{const{generateBufferRing:pa,generatePerEdgeBuffers:ca,getBufferStyle:Kn}=await Promise.resolve().then(()=>Kk);return{generateBufferRing:pa,generatePerEdgeBuffers:ca,getBufferStyle:Kn}},void 0).then(({generateBufferRing:pa,generatePerEdgeBuffers:ca,getBufferStyle:Kn})=>{if(!(!Oe||!Oe.getPane("overlayBasePane"))){if(Fp&&jt.building_buffer_edge_config)ca(fa,jt.building_buffer_edge_config,6).forEach(({geometry:Jn,config:yn})=>{const cn=Jn.map(ha=>[ha.lat,ha.lng]),vn=Kn(yn.material),Wn=Bt.polygon(cn,{color:vn.strokeColor,weight:1,fillColor:vn.fillColor,fillOpacity:vn.fillOpacity,dashArray:"4, 4",interactive:!1,pane:"overlayBasePane"}).addTo(Oe);Vn(()=>{const ha=Wn.getElement();ha&&(ha.style.zIndex=String(550));try{gc.bringToFront()}catch{}}),Hs.current.push(Wn)});else if(Cm){const Aa=pa(fa,jt.building_buffer_ft);if(!Aa||Aa.length===0)return;const Jn=jt.building_buffer_material,yn=Kn(Jn);Aa.forEach(cn=>{const vn=cn.map(ha=>[ha.lat,ha.lng]),Wn=Bt.polygon(vn,{color:yn.strokeColor,weight:1,fillColor:yn.fillColor,fillOpacity:yn.fillOpacity,dashArray:"4, 4",interactive:!1,pane:"overlayBasePane"}).addTo(Oe);Vn(()=>{const ha=Wn.getElement();ha&&(ha.style.zIndex=String(550));try{gc.bringToFront()}catch{}}),Hs.current.push(Wn)})}}}).catch(pa=>{console.error("Error rendering building buffer:",pa)})}let af=jt.dock_count||0;if(lu(jt.layer_type)&&Bs.length>=3){const fa=Bs.map(([vn,Wn])=>({lat:vn,lng:Wn})),pa=fa.map(vn=>[vn.lng,vn.lat]),ca=jt.dock_width_ft||10,Kn=jt.dock_spacing_ft||12,Aa=jt.dock_depth_ft||4,Jn=jt.dock_edge_indices,yn=jt.dock_config||"single_rear";if(jt.dock_layout_mode==="maximize"&&pa.length>=3)try{const vn=Ec(pa);let Wn;if(Jn&&Jn.length>0)Wn=Jn;else{const va=kg(pa);Wn=Cg(yn,va).map(gr=>gr.index)}let ha=999;for(const va of Wn){const gr=vn[va];if(!gr)continue;const Jr=jt.dock_end_gap_left_ft||0,Lo=jt.dock_end_gap_right_ft||0,Go=gr.lengthFt-Jr-Lo,il=ca+Kn,fi=Math.max(1,Math.floor((Go+Kn)/il));fi<ha&&(ha=fi)}ha<999&&ha>0&&(af=ha)}catch{}if(af>0){let vn;Jn&&Jn.length>0?vn=TP(pa,Jn,af,ca,Kn,Aa).features:vn=RP(pa,yn,af,ca,Kn,Aa);const Wn=(va,gr,Jr,Lo,Go)=>{const il=va.geometry.coordinates[0].map(Ho=>[Ho[1],Ho[0]]),fi=Bt.polygon(il,{color:gr,fillColor:gr,fillOpacity:Jr,weight:.5,opacity:.8,interactive:!1,pane:Lo}).addTo(Oe);Go&&Vn(()=>{const Ho=fi.getElement();Ho&&(Ho.style.zIndex=String(Go))}),Hs.current.push(fi)};if(jt.dock_seal_type&&vn.features.length>
16300&&MP(vn,pa,jt.dock_seal_depth_in||18,ca).features.forEach(gr=>Wn(gr,jt.dock_seal_color||"#1a1a1a",.7,"overlayBuildingPane",710)),jt.dock_bumpers_enabled&&vn.features.length>0&&IP(vn,pa).features.forEach(gr=>Wn(gr,jt.dock_bumper_color||"#111827",.8,"overlayBuildingPane",710)),jt.dock_canopy_enabled&&vn.features.length>0){const va=jt.dock_canopy_depth_ft||6;AP(vn,pa,va,ca).features.forEach(Jr=>Wn(Jr,jt.dock_canopy_color||jt.roof_color||"#6B7280",.4,"overlayBuildingPane",720))}if(jt.dock_apron_enabled){const va=Jn&&Jn.length>0?Jn:(()=>{try{const gr=kg(pa);return Cg(yn,gr).map(Jr=>Jr.index)}catch{return[]}})();if(va.length>0){const gr=jt.dock_apron_depth_ft||70;DP(pa,va,gr).features.forEach(Lo=>Wn(Lo,jt.dock_apron_color||"#D1D5DB",.5,"overlayBasePane",500))}}const ha=jt.dock_man_door_interval||0;if(ha>0&&vn.features.length>0){const va=jt.dock_man_door_width_ft||3,gr=MT(vn,pa,ha,va);gr.features.forEach(Lo=>Wn(Lo,"#6B7280",.85,"overlayBuildingPane",715));const Jr=jt.dock_height_ft||4;Jr>1&&IT(gr,pa,Jr).features.forEach(Go=>{var ko;const il=((ko=Go.properties)==null?void 0:ko.stepIndex)??0,fi=Math.min(220,180+il*15),Ho=`rgb(${fi},${fi},${fi})`;Wn(Go,Ho,.7,"overlayBuildingPane",714)})}if(jt.dock_light_enabled&&vn.features.length>0){const va=jt.dock_light_type||"gooseneck";AT(vn,pa,va).features.forEach(Jr=>Wn(Jr,jt.dock_light_color||"#FFD700",.9,"overlayBuildingPane",725))}}const cn=jt.drive_in_door_count||0;if(cn>0){const vn=jt.drive_in_door_width_ft||14,Wn=jt.drive_in_door_height_ft||16,ha=jt.drive_in_door_spacing_ft||20,va=jt.drive_in_door_color||"#94a3b8",gr=jt.drive_in_door_edge_indices,Jr=Pj(fa,{doorCount:cn,doorWidthFt:vn,doorHeightFt:Wn,spacingFt:ha,edgeIndices:gr&&gr.length>0?gr:void 0,doorColor:va});if(Jr&&Jr.doors.length>0){const Lo=SP(Jr.doors,vn,Wn,va),Go=(fi,Ho,ko)=>{const Su=fi.geometry.coordinates[0].map(tc=>[tc[1],tc[0]]),Ll=Bt.polygon(Su,{color:Ho,fillColor:Ho,fillOpacity:ko,weight:1,opacity:.9,interactive:!1,pane:"overlayBasePane"}).addTo(Oe);Vn(()=>{const tc=Ll.getElement();tc&&(tc.style.zIndex="712")}),Hs.current.push(Ll)};Lo.features.forEach(fi=>Go(fi,va,.8)),EP(Jr.doors,vn,Wn).features.forEach(fi=>Go(fi,"#1f2937",.6))}}}if(lu(jt.layer_type)&&Bs.length>=3){const fa=Bs.map(([ca,Kn])=>[Kn,ca]),pa=(ca,Kn,Aa,Jn,yn)=>{const cn=ca.geometry.coordinates[0].map(Wn=>[Wn[1],Wn[0]]),vn=Bt.polygon(cn,{color:Kn,fillColor:Kn,fillOpacity:Aa,weight:.5,opacity:.8,interactive:!1,pane:Jn}).addTo(Oe);yn&&Vn(()=>{const Wn=vn.getElement();Wn&&(Wn.style.zIndex=String(yn))}),Hs.current.push(vn)};if(jt.exhaust_fan_enabled){const ca=jt.exhaust_fan_count||4,Kn=jt.exhaust_fan_size_in||48,Aa=jt.exhaust_fan_edge_indices,Jn=jt.exhaust_fan_spacing_mode||"even",yn=jt.exhaust_fan_type||"exhaust_fan",cn=jt.exhaust_fan_placement||"single",vn=DT(fa,ca,Kn,Aa,Jn,yn,cn),Wn=yn==="louver_vent"?"#A0AEC0":yn==="ridge_vent"?"#718096":jt.exhaust_fan_color||"#808080";vn.features.forEach(ha=>pa(ha,Wn,.75,"overlayBuildingPane",730))}if(jt.building_light_enabled){const ca=jt.building_light_spacing_ft||40,Kn=jt.building_light_edges,Aa=jt.building_light_corners??!0;RT(fa,ca,Kn,Aa).features.forEach(yn=>pa(yn,"#FCD34D",.9,"overlayBuildingPane",725))}if(jt.skylight_enabled){const ca=jt.skylight_rows||2,Kn=jt.skylight_cols||4,Aa=jt.skylight_width_ft||4,Jn=jt.skylight_length_ft||8,yn=jt.skylight_spacing_ft||10,cn=jt.skylight_setback_ft||5,vn=FT(fa,ca,Kn,Aa,Jn,yn,cn),Wn=jt.skylight_tint||"clear",ha=Wn==="bronze"?"#C4956A":Wn==="gray"?"#9CA3AF":Wn==="white_translucent"?"#E5E7EB":"#87CEEB";vn.features.forEach(va=>pa(va,ha,.5,"overlayBuildingPane",735))}if(jt.trash_compactor_enabled){const ca=jt.trash_compactor_width_ft||10,Kn=jt.trash_compactor_depth_ft||20,Aa=jt.trash_compactor_enclosure||"three_sided",Jn=jt.trash_compactor_edge_index,yn=jt.trash_compactor_bollards??!0;zT(fa,null,ca,Kn,Aa,Jn,yn).features.forEach(vn=>{var ha;const Wn=(ha=vn.properties)==null?void 0:ha.equipmentType;Wn==="trash_compactor_pad"?pa(vn,"#D1D5DB",.6,"overlayBuildingPane",710):Wn==="trash_compactor_wall"?pa(vn,"#6B7280",.8,"overlayBuildingPane",711):Wn==="trash_compactor_bollard"&&pa(vn,"#EAB308",.9,"overlayBuildingPane",712)})}}if(Vn(()=>{const fa=Wt();if(!fa)return;const pa=Array.isArray(jt.gradient_colors)?jt.gradient_colors:[],ca=!!jt.gradient_type&&jt.gradient_type!=="none"&&pa.length>=2,Kn=!!jt.fill_pattern&&jt.fill_pattern!=="solid";let Aa=null;if(ca){const yn=`dw360-gradient-${jt.id}`;Ss(fa,hn(yn,jt.gradient_type,pa)),Aa=`url(#${yn})`}else if(Kn){const yn=`dw360-pattern-${jt.id}`;Ss(fa,Ms(yn,jt.fill_pattern,zs,qn)),Aa=`url(#${yn})`}if(!Aa)return;const Jn=gc.getElement();Jn&&(Jn.setAttribute("fill",Aa),Jn.setAttribute("fill-opacity",String(jt.image_url?0:mn)))}),jt.show_area_label&&jt.type==="polygon"){const fa=Bs.reduce((yn,[cn,vn])=>({lat:yn.lat+cn/Bs.length,lng:yn.lng+vn/Bs.length}),{lat:0,lng:0}),pa=Bs.map(([yn,cn])=>({lat:yn,lng:cn}));let ca=jt.calculated_area_acres,Kn=jt.calculated_area_sqft;if(pa.length>=3)try{const yn=Xn([[...pa.map(vn=>[vn.lng,vn.lat]),[pa[0].lng,pa[0].lat]]]);Kn=zr(yn)*10.7639,ca=Kn/43560}catch{}const Aa=jt.area_label_unit||"auto";let Jn="";if(Aa==="acres"&&ca!=null?Jn=`${ca.toFixed(2)}
1630 ac`:Aa==="sqft"&&Kn!=null?Jn=`${Math.round(Kn).toLocaleString()} sf`:Jn=ca&&ca>=1?`${ca.toFixed(2)} ac`:Kn?`${Math.round(Kn).toLocaleString()} sf`:"",Jn){if(!Oe.getPane("measurementLabelsPane")){const cn=Oe._norotatePane;Oe.createPane("measurementLabelsPane",cn),Oe.getPane("measurementLabelsPane").style.zIndex="800"}const yn=Bt.marker([fa.lat,fa.lng],{icon:Bt.divIcon({className:"polygon-area-label-wrapper",html:`<div class="polygon-area-label">${Jn}</div>`,iconSize:[80,24],iconAnchor:[40,12]}),interactive:!1,pane:"measurementLabelsPane"}).addTo(Oe);Hs.current.push(yn)}}if(jt.show_measurements&&jt.type==="polygon")for(let fa=0;fa<Bs.length;fa++){const pa=Bs[fa],ca=Bs[(fa+1)%Bs.length],Kn=[(pa[0]+ca[0])/2,(pa[1]+ca[1])/2],Aa=3958.8,Jn=(ca[0]-pa[0])*Math.PI/180,yn=(ca[1]-pa[1])*Math.PI/180,cn=Math.sin(Jn/2)*Math.sin(Jn/2)+Math.cos(pa[0]*Math.PI/180)*Math.cos(ca[0]*Math.PI/180)*Math.sin(yn/2)*Math.sin(yn/2),vn=2*Math.atan2(Math.sqrt(cn),Math.sqrt(1-cn)),Wn=Math.round(Aa*vn*5280);if(Wn>0){if(!Oe.getPane("measurementLabelsPane")){const va=Oe._norotatePane;Oe.createPane("measurementLabelsPane",va),Oe.getPane("measurementLabelsPane").style.zIndex="800"}const ha=Bt.marker(Kn,{icon:Bt.divIcon({className:"polygon-measurement-label-wrapper",html:`<div class="polygon-measurement-label">${Wn.toLocaleString()} ft</div>`,iconSize:[60,18],iconAnchor:[30,9]}),interactive:!1,pane:"measurementLabelsPane"}).addTo(Oe);Hs.current.push(ha)}}if(jt.setback_geometry&&jt.type==="polygon")try{const fa=jt.setback_geometry;if(fa&&fa.features){const pa=(nn=jt.style)==null?void 0:nn.landscapeBuffers,Kn=pa&&Object.values(pa).some(cn=>(cn==null?void 0:cn.enabled)&&(cn==null?void 0:cn.type)==="setback_landscape")?"#86efac":((xn=jt.style)==null?void 0:xn.setbackColor)||"#f97316",Aa=fa.features.find(cn=>{var vn;return((vn=cn.properties)==null?void 0:vn.setbackType)==="combined-setback-zone"});if(Aa&&((Zn=Aa.geometry)!=null&&Zn.coordinates)){const cn=Aa.geometry.coordinates,vn=((ua=cn[0])==null?void 0:ua.map(ha=>[ha[1],ha[0]]))||[],Wn=((Ya=cn[1])==null?void 0:Ya.map(ha=>[ha[1],ha[0]]))||[];if(vn.length>=3){const ha=vn.map(vr=>vr[0]),va=vn.map(vr=>vr[1]),gr=Math.min(...ha),Jr=Math.max(...ha),Lo=Math.min(...va),Go=Math.max(...va),il=Bt.latLngBounds([[gr,Lo],[Jr,Go]]),fi=(vr,go)=>{const _c=(go-Lo)/(Go-Lo)*100,dr=(Jr-vr)/(Jr-gr)*100;return[_c,dr]},Ho=vn.map((vr,go)=>{const[_c,dr]=fi(vr[0],vr[1]);return go===0?`M ${_c} ${dr}`:`L ${_c} ${dr}`}).join(" ")+" Z";let ko="";Wn.length>=3&&(ko=" "+Wn.map((vr,go)=>{const[_c,dr]=fi(vr[0],vr[1]);return go===0?`M ${_c} ${dr}`:`L ${_c} ${dr}`}).join(" ")+" Z");const Su="http://www.w3.org/2000/svg",Ll=document.createElementNS(Su,"svg");Ll.setAttribute("viewBox","0 0 100 100"),Ll.setAttribute("preserveAspectRatio","none"),Ll.style.width="100%",Ll.style.height="100%";const tc=document.createElementNS(Su,"path");tc.setAttribute("d",Ho+ko),tc.setAttribute("fill",Kn),tc.setAttribute("fill-opacity","0.25"),tc.setAttribute("fill-rule","evenodd"),tc.setAttribute("stroke","none"),Ll.appendChild(tc);const rf=Bt.svgOverlay(Ll,il,{interactive:!1,pane:"overlayBasePane"}).addTo(Oe);Hs.current.push(rf);const Od=fa.features.find(vr=>{var go;return((go=vr.properties)==null?void 0:go.setbackType)==="buildable-area"}),ii=((Ea=jt.style)==null?void 0:Ea.setbackLineStyle)||"dashed";if(ii!=="hidden"){let vr=[];if((ao=(Mr=Od==null?void 0:Od.geometry)==null?void 0:Mr.coordinates)!=null&&ao[0]?vr=Od.geometry.coordinates[0].map(go=>[go[1],go[0]]):Wn.length>=3&&(vr=Wn),vr.length>=3){const go=vr[0],_c=vr[vr.length-1];(go[0]!==_c[0]||go[1]!==_c[1])&&(vr=[...vr,go]);const dr=Bt.polyline(vr,{color:"#22c55e",weight:2,dashArray:ii==="dashed"?"6, 6":void 0,opacity:.8,pane:"overlayBasePane"}).addTo(Oe);Hs.current.push(dr)}}}}else fa.features.forEach(cn=>{var ha,va;if(!cn.geometry||!cn.geometry.coordinates)return;const vn=(ha=cn.properties)==null?void 0:ha.setbackType,Wn=(va=cn.properties)==null?void 0:va.labelOnly;if(!(!(vn!=null&&vn.endsWith("-buffer"))||Wn)&&cn.geometry.type==="Polygon"){const gr=cn.geometry.coordinates[0].map(Lo=>[Lo[1],Lo[0]]),Jr=Bt.polygon(gr,{stroke:!1,fillColor:Kn,fillOpacity:.25,pane:"overlayBasePane"}).addTo(Oe);Hs.current.push(Jr)}});if(!Oe.getPane("setbackLabelsPane")){const cn=Oe._norotatePane;Oe.createPane("setbackLabelsPane",cn),Oe.getPane("setbackLabelsPane").style.zIndex="750"}
1630fa.features.forEach(cn=>{var va;if(!cn.geometry||!cn.geometry.coordinates)return;const vn=(va=cn.properties)==null?void 0:va.setbackType;if(!(vn!=null&&vn.endsWith("-buffer"))||cn.geometry.type!=="Polygon")return;let Wn="",ha=null;if(vn==="front-buffer"?(Wn="Front",ha=jt.setback_front_ft??null):vn==="rear-buffer"?(Wn="Rear",ha=jt.setback_rear_ft??null):vn==="side-left-buffer"?(Wn="Side",ha=jt.setback_side1_ft??jt.setback_side_ft??null):vn==="side-right-buffer"&&(Wn="Side",ha=jt.setback_side2_ft??jt.setback_side_ft??null),Wn){const gr=cn.geometry.coordinates[0].map(fi=>[fi[1],fi[0]]),Jr=gr.reduce((fi,[Ho,ko])=>({lat:fi.lat+Ho/gr.length,lng:fi.lng+ko/gr.length}),{lat:0,lng:0}),Lo=ha?` (${ha}')`:"",Go=`${Wn}${Lo}`,il=Bt.marker([Jr.lat,Jr.lng],{icon:Bt.divIcon({className:"setback-buffer-label",html:`<div style="background: ${Kn}; color: white; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,0.3);">${Go}</div>`,iconSize:[60,18],iconAnchor:[30,9]}),interactive:!1,pane:"setbackLabelsPane"}).addTo(Oe);Hs.current.push(il)}});const Jn=((Oc=jt.style)==null?void 0:Oc.showEdgeLabels)!==!1;if(Bs.length===4&&Jn){const cn=Bs.map(([Wn,ha])=>({lat:Wn,lng:ha}));mu(cn).forEach(Wn=>{const ha=Bt.marker([Wn.midpoint.lat,Wn.midpoint.lng],{icon:Bt.divIcon({className:"setback-edge-label",html:`<div style="background: #1e293b; color: white; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; white-space: nowrap; box-shadow: 0 2px 4px rgba(0,0,0,0.4); border: 2px solid white;">${Wn.label}</div>`,iconSize:[30,24],iconAnchor:[15,12]}),interactive:!1,pane:"setbackLabelsPane"}).addTo(Oe);Hs.current.push(ha)})}const yn=(ku=jt.style)==null?void 0:ku.landscapeBuffers;if(yn&&Bs.length>=3){const cn=Bs.map(([va,gr])=>({lat:va,lng:gr})),vn=mu(cn);Object.values(yn).some(va=>va==null?void 0:va.enabled)&&br(async()=>{const{generateAllBufferPolygons:va,getBufferTypeColor:gr,getBufferDensityOpacity:Jr}=await Promise.resolve().then(()=>Dq);return{generateAllBufferPolygons:va,getBufferTypeColor:gr,getBufferDensityOpacity:Jr}},void 0).then(({generateAllBufferPolygons:va,getBufferTypeColor:gr,getBufferDensityOpacity:Jr})=>{if(!Oe||!Oe.getPane("overlayBasePane"))return;va(cn,yn,vn).filter(il=>il.type!=="setback_landscape").forEach(il=>{const fi=il.coordinates.map(Ll=>[Ll.lat,Ll.lng]),Ho=gr(il.type),ko=Jr(il.density),Su=Bt.polygon(fi,{color:Ho,fillColor:Ho,fillOpacity:ko,weight:1.5,opacity:.8,interactive:!1,pane:"overlayBasePane"}).addTo(Oe);Hs.current.push(Su)})}).catch(va=>{console.error("Error loading landscape buffer geometry:",va)}),Object.values(yn).some(va=>(va==null?void 0:va.enabled)&&(va==null?void 0:va.type)==="tree_line")&&Promise.all([br(()=>Promise.resolve().then(()=>Tg),void 0),br(()=>Promise.resolve().then(()=>lp),void 0)]).then(([va,gr])=>{var rf,Od;const{generateAllTreePositions:Jr,getTreeColor:Lo,filterTreesAwayFromEntryRoads:Go}=va,{generateAllEntryPointPolygons:il}=gr,fi=(rf=jt.style)==null?void 0:rf.parkingCirculation,Ho=fi==null?void 0:fi.entryPoints;let ko;if(jt.parent_overlay_id){const ii=Ba.find(vr=>vr.id===jt.parent_overlay_id);ii!=null&&ii.geometry&&Array.isArray(ii.geometry)&&ii.geometry.length>=3&&(ko=ii.geometry)}const Su=Ho&&Ho.length>0?il(Ho,cn,40,ko):[],Ll=(Od=jt.style)==null?void 0:Od.treeModifications;let tc=Jr(cn,yn,vn,void 0,Ll?{deletedTreeIds:Ll.deletedTreeIds||[],addedTrees:Ll.addedTrees||[]}:void 0);Su.length>0&&(tc=Go(tc,Su)),tc.forEach(ii=>{const vr=yn[ii.edgeLabel],go=(vr==null?void 0:vr.tree_species)||"deciduous",_c=(vr==null?void 0:vr.canopy_diameter_ft)||15,dr=Lo(go==="custom_3d"?"deciduous":go),Sh=Math.max(4,Math.min(12,_c/3)),zp=Bt.circleMarker([ii.lat,ii.lng],{radius:Sh,color:"#166534",fillColor:dr,fillOpacity:.8,weight:1.5,interactive:!1,pane:"overlayBasePane"}).addTo(Oe);Hs.current.push(zp)})}).catch(va=>{console.error("Error loading tree geometry:",va)})}}}catch(fa){console.error("Error rendering setbacks:",fa)}if((jt.layer_type==="parking_field"||jt.layer_type==="parking"||jt.layer_type==="parking_zone")&&jt.parking_str
1630iping_visible!==!1&&Bs.length>=3){const fa=Oe.getZoom(),pa=17;if(!(fa<15))try{br(async()=>{const{generateParkingLayout:Kn,getStallClosedEdges:Aa,applyStallOverrides:Jn,getStallCentroid:yn,getStallBackEdgeCenter:cn,generateDiagonalHatching:vn}=await Promise.resolve().then(()=>t1);return{generateParkingLayout:Kn,getStallClosedEdges:Aa,applyStallOverrides:Jn,getStallCentroid:yn,getStallBackEdgeCenter:cn,generateDiagonalHatching:vn}},void 0).then(({generateParkingLayout:Kn,getStallClosedEdges:Aa,applyStallOverrides:Jn,getStallCentroid:yn,getStallBackEdgeCenter:cn,generateDiagonalHatching:vn})=>{br(async()=>{const{getBuildingWithBuffer:Wn,mergeExclusionZones:ha}=await Promise.resolve().then(()=>Kk);return{getBuildingWithBuffer:Wn,mergeExclusionZones:ha}},void 0).then(({getBuildingWithBuffer:Wn,mergeExclusionZones:ha})=>{br(async()=>{const{collectSmartExclusionZones:va,getExclusionSettingsFromOverlay:gr,logExclusionSummary:Jr}=await Promise.resolve().then(()=>eO);return{collectSmartExclusionZones:va,getExclusionSettingsFromOverlay:gr,logExclusionSummary:Jr}},void 0).then(({collectSmartExclusionZones:va,getExclusionSettingsFromOverlay:gr,logExclusionSummary:Jr})=>{var b_;const Lo=Bs.map(([ba,Ji])=>({lat:ba,lng:Ji})),Go=gr(jt),il=va({parkingOverlay:jt,allOverlays:Ba,settings:Go,getBuildingWithBuffer:Wn});Jr(il,"DevelopmentMap");const fi=[...il.zones,...il.stallOnlyZones],Ho=fi.length>0?ha(fi):[],ko=jt.style||{},Su=ko.parking_max_stall_run||void 0,Ll=ko.parking_island_type||"painted",tc=ko.parking_island_width_ft||(Ll==="landscape"?6:4),rf=ko.parking_island_trees===!0,Od=ko.parking_island_cross_aisle!==!1,ii={stallWidth_ft:jt.parking_stall_width_ft||9,stallDepth_ft:jt.parking_stall_depth_ft||18,aisleWidth_ft:jt.parking_aisle_width_ft||24,layoutType:jt.parking_layout_type||"double_loaded",stripingVisible:jt.parking_striping_visible!==!1,aisleLabelsVisible:jt.parking_aisle_labels_visible!==!1,exclusionZones:Ho,maxStallRun:Su,islandType:Ll,islandWidth_ft:tc,islandTrees:rf,islandCrossAisle:Od,islandTreeSpecies:ko.parking_island_tree_species||"deciduous",islandTreeHeight_ft:ko.parking_island_tree_height_ft||30,islandCanopyDiameter_ft:ko.parking_island_canopy_diameter_ft||15,islandCustomModelId:ko.parking_island_custom_model_id||void 0,islandCustomModelUrl:ko.parking_island_custom_model_url||void 0};let vr=Kn(Lo,ii);const go=(b_=jt.style)==null?void 0:b_.parkingCirculation,_c=go==null?void 0:go.stallOverrides,dr=go==null?void 0:go.rowOverrides;(_c&&Object.keys(_c).length>0||dr&&Object.keys(dr).length>0)&&(vr=Jn(vr,_c||{},dr)),vr.stripingLines.filter(ba=>{var Ji;if(!(ba.type==="row_edge"||ba.type==="aisle_edge"))return!1;if(ba.type==="row_edge"){const Qr=String(ba.id).split("-"),ni=Qr[2]??"0",Eu=Qr[3]??"top",Vl=`row-${ni}-${Eu}`,ro=dr==null?void 0:dr[Vl];if(ro!=null&&ro.hidden||((Ji=ro==null?void 0:ro.edges)==null?void 0:Ji.back)===!1)return!1}return!0}).forEach(ba=>{const Ji=Bt.polyline([[ba.start.lat,ba.start.lng],[ba.end.lat,ba.end.lng]],{color:"#ffffff",weight:4,opacity:1,dashArray:"4, 4",interactive:!1,pane:"overlayParkingStripingPane"}).addTo(Oe);Hs.current.push(Ji)});const Sh=Zl&&Dl===jt.id;Sh&&console.log("[StallEditor 2D] Stall editor active for overlay:",jt.id,"- rendering",vr.stalls.length,"clickable stalls");const zp=fa<pa&&!Sh,Op=vr.stalls.filter(ba=>!ba.isRemoved),Uu=1500,of=Op.length>Uu&&!Sh?Op.slice(0,Uu):Op;if(zp||(of.forEach(ba=>{const Ji=ba.isAda,Qr=eo===ba.id,ni=ba.renderType||(Ji?"ada":"standard"),Eu={standard:"#ffffff",ada:"#3b82f6",van_accessible:"#3b82f6",reserved:"#8b5cf6",ev_charging:"#22c55e",compact:"#eab308",motorcycle:"#f97316",loading_zone:"#78716c",no_parking:"#fbbf24"},Vl=ba.customColor||Eu[ni]||"#ffffff",ro="#f97316";Aa(ba).forEach(Li=>{const Zo=Bt.polyline([[Li.start.lat,Li.start.lng],[Li.end.lat,Li.end.lng]],{color:Qr?ro:Vl,weight:Qr?6:Ji?5:4,opacity:1,interactive:!1,pane:"overlayParkingStripingPane"}).addTo(Oe);Hs.current.push(Zo)});const nd=yn(ba.geometry);if(ni==="ada"||ni==="van_accessible"){const Li=Bt.marker([nd.lat,nd.lng],{icon:Bt.divIcon({className:"stall-icon-ada",html:`<div style="
1631                          font-size: 14px;
1632                          color: #ffffff;
1633                          text-shadow: 0 1px 2px rgba(0,0,0,0.5);
1634                          font-weight: bold;
1635                        ">♿</div>`,iconSize:[20,20],iconAnchor:[10,10]}),interactive:!1,pane:"overlayParkingStripingPane"}).addTo(Oe);Hs.current.push(Li)}if(ni==="reserved"&&ba.displayLabel){const Li=Bt.marker([nd.lat,nd.lng],{icon:Bt.divIcon({className:"stall-number-reserved",html:`<div style="
1636                          font-size: 12px;
1637                          font-weight: bold;
1638                          color: #ffffff;
1639                          text-shadow: 0 1px 2px rgba(0,0,0,0.5);
1640                        ">${ba.displayLabel}</div>`,iconSize:[20,20],iconAnchor:[10,10]}),interactive:!1,pane:"overlayParkingStripingPane"}).addTo(Oe);Hs.current.push(Li)}if(ni==="ev_charging"){const Li=cn(ba),Zo=Bt.marker([Li.lat,Li.lng],{icon:Bt.divIcon({className:"stall-ev-pillar",html:`<div style="
1641                          width: 10px;
1642                          height: 10px;
1643                          background: #22c55e;
1644                          border: 2px solid white;
1645                          border-radius: 2px;
1646                          box-shadow: 0 1px 3px rgba(0,0,0,0.4);
1647                        "></div>`,iconSize:[14,14],iconAnchor:[7,7]}),interactive:!1,pane:"overlayParkingStripingPane"}).addTo(Oe);Hs.current.push(Zo)}if((ba.hasHatching||ni==="loading_zone"||ni==="no_parking")&&vn(ba.geometry,4).forEach(Zo=>{const Sm=Bt.polyline([[Zo.start.lat,Zo.start.lng],[Zo.end.lat,Zo.end.lng]],{color:ni==="no_parking"?"#fbbf24":"#78716c",weight:2,opacity:.8,dashArray:"4, 4",interactive:!1,pane:"overlayParkingStripingPane"}).addTo(Oe);Hs.current.push(Sm)}),ni==="island"){const Li=ba.islandFinish||"landscape",Zo={landscape:{fill:"#86efac",border:"#166534",opacity:.7},painted:{fill:"#d1d5db",border:"#9ca3af",opacity:.6},bushes:{fill:"#166534",border:"#14532d",opacity:.8},rock:{fill:"#78716c",border:"#57534e",opacity:.7},mulch:{fill:"#92400e",border:"#78350f",opacity:.7},planter_box:{fill:"#86efac",border:"#9ca3af",opacity:.7}},Sm=Zo[Li]||Zo.landscape,eh=Bt.polygon(ba.geometry.map(th=>[th.lat,th.lng]),{fillColor:Sm.fill,fillOpacity:Sm.opacity,color:Sm.border,weight:2,interactive:!1,pane:"overlayParkingStripingPane"}).addTo(Oe);if(Hs.current.push(eh),Li==="painted"&&vn(ba.geometry,4).forEach(ad=>{const ol=Bt.polyline([[ad.start.lat,ad.start.lng],[ad.end.lat,ad.end.lng]],{color:"#9ca3af",weight:1.5,opacity:.6,dashArray:"3, 3",interactive:!1,pane:"overlayParkingStripingPane"}).addTo(Oe);Hs.current.push(ol)}),(Li==="landscape"||Li==="planter_box")&&ba.islandTreeEnabled){const th=yn(ba.geometry),ad=ba.islandTreeSpecies||"deciduous",Xg={deciduous:"#22c55e",evergreen:"#166534",palm:"#84cc16",shrub:"#65a30d"}[ad]||"#22c55e",j_=Bt.circleMarker([th.lat,th.lng],{radius:8,fillColor:Xg,fillOpacity:.8,color:"#166534",weight:1.5,interactive:!1,pane:"overlayParkingStripingPane"}).addTo(Oe);Hs.current.push(j_)}}if(Sh){const Li=Bt.polygon(ba.geometry.map(Zo=>[Zo.lat,Zo.lng]),{fillColor:Qr?ro:"#ffffff",fillOpacity:Qr?.3:.01,stroke:Qr,color:Qr?ro:"transparent",weight:Qr?2:0,opacity:Qr?.8:0,interactive:!0,pane:"overlayParkingStripingPane",bubblingMouseEvents:!1});Li.on("click",Zo=>
1647{Bt.DomEvent.stopPropagation(Zo),console.log("[StallEditor] Clicked stall:",ba.id),Wr(ba.id)}),Li.on("mouseover",()=>{Qr||Li.setStyle({fillColor:"#fbbf24",fillOpacity:.3,stroke:!0,color:"#fbbf24",weight:2,opacity:.8})}),Li.on("mouseout",()=>{Qr||Li.setStyle({fillColor:"#ffffff",fillOpacity:.01,stroke:!1,color:"transparent",weight:0,opacity:0})}),Li.addTo(Oe),Hs.current.push(Li)}}),vr.islands.length>0&&vr.islands.forEach(ba=>{const Ji=ba.geometry.map(Qr=>[Qr.lat,Qr.lng]);if(ba.type==="painted"){const Qr=Bt.polygon(Ji,{fillColor:"#d1d5db",fillOpacity:.7,color:"#9ca3af",weight:2,dashArray:"4, 4",interactive:!1,pane:"overlayParkingStripingPane"}).addTo(Oe);Hs.current.push(Qr)}else{const Qr=Bt.polygon(Ji,{fillColor:"#4ade80",fillOpacity:.75,color:"#6b7280",weight:3,interactive:!1,pane:"overlayParkingStripingPane"}).addTo(Oe);Hs.current.push(Qr),ba.hasTree&&br(async()=>{const{getTreeColor:ni}=await Promise.resolve().then(()=>Tg);return{getTreeColor:ni}},void 0).then(({getTreeColor:ni})=>{const Eu=ba.treeSpecies||"deciduous",Vl=ni(Eu),ro=ba.canopyDiameter_ft||15,sc=Math.max(14,Math.min(32,ro*1.2)),nd=Bt.marker([ba.centerPosition.lat,ba.centerPosition.lng],{icon:Bt.divIcon({className:"island-tree-icon",html:`<div style="
1648                                width: ${sc}px;
1649                                height: ${sc}px;
1650                                background: ${Vl};
1651                                border: 2px solid #166534;
1652                                border-radius: 50%;
1653                                box-shadow: 0 1px 4px rgba(0,0,0,0.3);
1654                                opacity: 0.85;
1655                              "></div>`,iconSize:[sc+4,sc+4],iconAnchor:[(sc+4)/2,(sc+4)/2]}),interactive:!1,pane:"overlayParkingStripingPane"}).addTo(Oe);Hs.current.push(nd)})}})),Sh){const ba=new Map;vr.stalls.filter(Ji=>!Ji.isRemoved).forEach(Ji=>{const Qr=`row-${Ji.rowIndex}-${Ji.id.split("-")[2]||"top"}`;ba.has(Qr)||ba.set(Qr,[]),Ji.geometry.forEach(ni=>ba.get(Qr).push(ni))}),ba.forEach((Ji,Qr)=>{if(Ji.length<4)return;const ni=Ji.map(ol=>ol.lat),Eu=Ji.map(ol=>ol.lng),Vl=Math.min(...ni),ro=Math.max(...ni),sc=Math.min(...Eu),nd=Math.max(...Eu),Li=Qr.includes("-top"),Zo=(ro-Vl)*.15,Sm=Li?[[ro,sc],[ro,nd],[ro-Zo,nd],[ro-Zo,sc]]:[[Vl,sc],[Vl,nd],[Vl+Zo,nd],[Vl+Zo,sc]],eh=eo===Qr,th="#22c55e",ad=Bt.polygon(Sm,{fillColor:eh?th:"transparent",fillOpacity:eh?.3:0,stroke:eh,color:eh?th:"transparent",weight:eh?3:0,opacity:eh?1:0,interactive:!0,pane:"overlayParkingStripingPane",bubblingMouseEvents:!1});ad.on("click",ol=>{Bt.DomEvent.stopPropagation(ol),console.log("[StallEditor] Clicked row:",Qr),Wr(Qr)}),ad.on("mouseover",()=>{eh||ad.setStyle({fillColor:"#22c55e",fillOpacity:.25,stroke:!0,color:"#22c55e",weight:2,opacity:.8})}),ad.on("mouseout",()=>{eh||ad.setStyle({fillColor:"transparent",fillOpacity:0,stroke:!1,color:"transparent",weight:0,opacity:0})}),ad.addTo(Oe),Hs.current.push(ad)})}ii.aisleLabelsVisible&&vr.driveAisles.length>0&&vr.driveAisles.forEach(ba=>{if(ba.labelPosition&&ba.labelText){const Ji=Bt.marker([ba.labelPosition.lat,ba.labelPosition.lng],{icon:Bt.divIcon({className:"parking-aisle-label",html:`<div style="
1656                            background: rgba(0,0,0,0.7);
1657                            color: white;
1658                            padding: 2px 6px;
1659                            border-radius: 3px;
1660                            font-size: 10px;
1661                            font-weight: 500;
1662                            white-space: nowrap;
1663                            transform: translate(-50%, -50%);
1664                          ">${ba.labelText}</div>`,iconSize:[0,0],iconAnchor:[0,0]}),interactive:!1,pane:"overlayParkingStripingPane"}).addTo(Oe);Hs.current.push(Ji)}});const v_=(jt.style||{}).parkingCirculation||{},U0=v_.aisleArrows||{},ev=v_.autoOneWayEnabled??!0;vr.driveAisles.forEach(ba=>{if(!ba.centerPosition||ba.bearing===void 0)return;const Ji=U0[ba.id];let Qr=(Ji==null?void 0:Ji.direction)||"none";if(Qr==="none"&&ev&&ba.width_ft<=10&&(Qr="forward"),Qr==="none")return;const ni=20,Eu="#ffffff",Vl=ba.bearing||0;if(Qr==="forward"||Qr==="two_way"){const ro=Vl,sc=Bt.marker([ba.centerPosition.lat,ba.centerPosition.lng],{icon:Bt.divIcon({className:"parking-aisle-arrow",html:`<div style="
1665                          transform: rotate(${ro}deg) translate(-50%, -50%);
1666                          transform-origin: center;
1667                          width: ${ni}px;
1668                          height: ${ni}px;
1669                          display: flex;
1670                          align-items: center;
1671                          justify-content: center;
1672                        ">
1673                          <svg width="${ni}" height="${ni}" viewBox="0 0 24 24" fill="none" stroke="${Eu}" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
1674                            <path d="M12 19V5M5 12l7-7 7 7"/>
1675                          </svg>
1676                        </div>`,iconSize:[ni,ni],iconAnchor:[ni/2,ni/2]}),interactive:!1,pane:"overlayParkingStripingPane"}).addTo(Oe);Hs.current.push(sc)}if(Qr==="backward"||Qr==="two_way"){const ro=(Vl+180)%360,sc=Qr==="two_way"?5e-5:0,nd=ba.centerPosition.lat+sc*Math.cos(Vl*Math.PI/180),Li=ba.centerPosition.lng+sc*Math.sin(Vl*Math.PI/180),Zo=Bt.marker([nd,Li],{icon:Bt.divIcon({className:"parking-aisle-arrow",html:`<div style="
1677                          transform: rotate(${ro}deg) translate(-50%, -50%);
1678                          transform-origin: center;
1679                          width: ${ni}px;
1680                          height: ${ni}px;
1681                          display: flex;
1682                          align-items: center;
1683                          justify-content: center;
1684                        ">
1685                          <svg width="${ni}" height="${ni}" viewBox="0 0 24 24" fill="none" stroke="${Eu}" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
1686                            <path d="M12 19V5M5 12l7-7 7 7"/>
1687                          </svg>
1688                        </div>`,iconSize:[ni,ni],iconAnchor:[ni/2,ni/2]}),interactive:!1,pane:"overlayParkingStripingPane"}).addTo(Oe);Hs.current.push(Zo)}})})})})}catch(Kn){console.error("Error rendering parking striping:",Kn)}}if(jt.image_url&&Bs.length>=3){const fa=Bt.latLngBounds(Bs),pa=Bt.svgOverlay((()=>{const ca=document.createElementNS(Gt,"svg");ca.setAttribute("xmlns",Gt),ca.setAttribute("viewBox","0 0 100 100"),
1688ca.setAttribute("preserveAspectRatio","none");const Kn=document.createElementNS(Gt,"defs"),Aa=document.createElementNS(Gt,"clipPath");Aa.setAttribute("id",`clip-${jt.id}`);const Jn=document.createElementNS(Gt,"polygon"),yn=Bs.map(([vn,Wn])=>{const ha=(Wn-fa.getWest())/(fa.getEast()-fa.getWest())*100,va=(fa.getNorth()-vn)/(fa.getNorth()-fa.getSouth())*100;return`${ha},${va}`}).join(" ");Jn.setAttribute("points",yn),Aa.appendChild(Jn),Kn.appendChild(Aa),ca.appendChild(Kn);const cn=document.createElementNS(Gt,"image");return cn.setAttribute("href",jt.image_url),cn.setAttribute("x","0"),cn.setAttribute("y","0"),cn.setAttribute("width","100"),cn.setAttribute("height","100"),cn.setAttribute("preserveAspectRatio","none"),cn.setAttribute("clip-path",`url(#clip-${jt.id})`),cn.setAttribute("opacity",String(jt.opacity??.7)),cn.setAttribute("transform-origin","50 50"),cn.setAttribute("transform-box","fill-box"),cn.setAttribute("transform",`rotate(${jt.rotation_degrees||0} 50 50)`),ca.appendChild(cn),ca})(),fa,{interactive:!1}).addTo(Oe);Hs.current.push(pa)}}if(!Dn)return;Array.isArray(jt.callout_markers)&&jt.callout_markers.length>0&&jt.callout_markers.forEach(Qa=>{const vi=Bt.marker([Qa.lat,Qa.lng],{icon:Bt.divIcon({className:"polygon-callout-marker-wrapper",html:`<div class="polygon-callout-marker" style="border-color: ${Qa.color||"hsl(var(--primary))"};">${Qa.text}</div>`,iconSize:[150,40],iconAnchor:[75,20]}),interactive:!0}).addTo(Oe);Hs.current.push(vi)});const gn=(au=jt.style)==null?void 0:au.parkingCirculation,un=gn==null?void 0:gn.entryPoints;if(Array.isArray(un)&&un.length>0&&Bs.length>=3&&br(async()=>{const{generateAllEntryPointPolygons:Qa,getEntryPointColor:vi,getEntryPointIcon:qo}=await Promise.resolve().then(()=>lp);return{generateAllEntryPointPolygons:Qa,getEntryPointColor:vi,getEntryPointIcon:qo}},void 0).then(({generateAllEntryPointPolygons:Qa,getEntryPointColor:vi,getEntryPointIcon:qo})=>{if(!Oe)return;const No=Bs.map(([Tl,zd])=>({lat:Tl,lng:zd}));let ec;if(jt.parent_overlay_id){const Tl=Ba.find(zd=>zd.id===jt.parent_overlay_id);Tl!=null&&Tl.geometry&&Array.isArray(Tl.geometry)&&Tl.geometry.length>=3&&(ec=Tl.geometry)}Qa(un,No,40,ec).forEach(Tl=>{const zd=Tl.coordinates.map(Cu=>[Cu.lat,Cu.lng]),To=vi(Tl.type),gc=Cu=>{switch(Cu){case"main_entry":return"Main Entry";case"service_entry":return"Service Entry";case"emergency_access":return"Emergency Access";case"fire_lane":return"Fire Lane";default:return"Access Point"}},xc=Bt.polygon(zd,{color:To,fillColor:"#4a5568",fillOpacity:.85,weight:2,opacity:1,interactive:!0,pane:"overlayBasePane"}).addTo(Oe);xc.on("click",Cu=>{Bt.DomEvent.stop(Cu),Wl(Tl.id),fl("build"),Qo(jt.id),Ri(!0),Rs&&(la(null),Rr(null))}),xc.bindTooltip(`${Tl.name} - ${gc(Tl.type)}`,{permanent:!1,direction:"top",className:"entry-road-tooltip"}),xc.on("mouseover",()=>{xc.setStyle({fillOpacity:.95,weight:3})}),xc.on("mouseout",()=>{xc.setStyle({fillOpacity:.85,weight:2})}),Hs.current.push(xc)})}),jt.show_column_grid&&lu(jt.layer_type)&&Ys.length>=3){const Qa={bayWidthFt:jt.column_bay_width_ft||50,bayDepthFt:jt.column_bay_depth_ft||50,columnSizeInches:jt.column_size_inches||24,offsetFrontFt:jt.column_offset_front_ft??4,offsetRearFt:jt.column_offset_rear_ft??4,offsetSide1Ft:jt.column_offset_side1_ft??4,offsetSide2Ft:jt.column_offset_side2_ft??4,frontEdgeIndex:jt.column_grid_front_edge??null,extraLinesX:jt.column_extra_lines_x??0,extraLinesY:jt.column_extra_lines_y??0},vi=jt.column_line_overrides;if(vi!=null&&vi.x){Qa.lineOverridesX={};for(const[No,ec]of Object.entries(vi.x))Qa.lineOverridesX[Number(No)]=ec}if(vi!=null&&vi.y){Qa.lineOverridesY={};for(const[No,ec]of Object.entries(vi.y))Qa.lineOverridesY[Number(No)]=ec}const qo=Ej(Ys,Qa);if(qo){const Ju=Qa.columnSizeInches/12*.3048/2/1e3,zd=qo.bearingDeg*Math.PI/180;qo.columns.forEach(To=>{const gc=Ju/111.32,xc=Ju/(111.32*Math.cos(To.lat*Math.PI/180)),Qu=[[-xc,-gc],[xc,-gc],[xc,gc],[-xc,gc]].map(([Ch,Cm])=>{const Fp=Ch*Math.cos(zd)-Cm*Math.sin(zd),af=Ch*Math.sin(zd)+Cm*Math.cos(zd);return[To.lat+af,To.lng+Fp]}),Rp=Bt.polygon(Qu,{fillColor:"#1e293b",fillOpacity:.95,color:"#ffffff",weight:2,interactive:!1,pane:"overlayBasePane"}).addTo(Oe);Hs.current.push(Rp)}),qo.bays.forEach(To=>{const gc=To.corners.map(([Cu,Qu])=>[Qu,Cu]),xc=Bt.polygon(gc,{fillColor:"transparent",fillOpacity:0,color:"transparent",weight:0,interactive:!0,pane:"overlayBasePane"}).addTo(Oe);xc.bindPopup(`<div style="font-family:monospace;font-size:12px;line-height:1.6">
1689                  <strong>Bay ${To.label}</strong><br/>
1690                  <b>
1690${Math.round(To.areaSqFt).toLocaleString()} SF</b><br/>
1691                  Width: ${To.widthFt%1===0?To.widthFt:To.widthFt.toFixed(1)}′ × Depth: ${To.depthFt%1===0?To.depthFt:To.depthFt.toFixed(1)}′
1692                </div>`,{className:"bay-info-popup"}),Hs.current.push(xc)}),qo.gridLines.forEach(To=>{const gc=Bt.polyline([[To.start[1],To.start[0]],[To.end[1],To.end[0]]],{color:"#94a3b8",weight:.5,opacity:.4,dashArray:"4, 4",interactive:!1,pane:"overlayBasePane"}).addTo(Oe);Hs.current.push(gc)})}}jt.type!=="polyline"&&jt.type!=="highway"&&jt.type!=="marker"&&jt.type!=="wms"&&Dn.on&&(Dn.on("click",Qa=>{var qo;if(hi!=="none"){(qo=Dn.closePopup)==null||qo.call(Dn),Oe.closePopup();return}Bt.DomEvent.stop(Qa);const vi=Oe.latLngToContainerPoint(Qa.latlng);Zg.current(jt,{x:vi.x,y:vi.y})}),Dn.on("contextmenu",Qa=>{Bt.DomEvent.stop(Qa),Qa.originalEvent.preventDefault(),Qa.originalEvent.stopPropagation();const vi=Oe.latLngToContainerPoint(Qa.latlng);Sn({x:vi.x,y:vi.y,lat:Qa.latlng.lat,lng:Qa.latlng.lng,overlay:jt})})),Hs.current.push(Dn)};di.length>0?zn(0):En()},350)},wm.current(),()=>{Yh.current&&clearTimeout(Yh.current)}),[Ba,xd,J,cr,ln,Rs,Dl,tn,hi,Zl,eo]),k.useEffect(()=>{const Ne=pe.current;if(!Ne)return;let Oe=Math.floor(Ne.getZoom());const lt=()=>{const pt=Math.floor(Ne.getZoom());pt!==Oe&&(Oe=pt,wm.current())};return Ne.on("zoomend",lt),()=>{Ne.off("zoomend",lt)}},[]),k.useEffect(()=>{var at;const Ne=pe.current;if(!Ne||((at=er.current)==null||at.remove(),er.current=null,Sr.current.forEach(Pt=>Pt.remove()),Sr.current=[],Pi.current.forEach(Pt=>Pt.remove()),Pi.current=[],!ln||aa.length===0))return;const Oe=Ba.find(Pt=>Pt.id===ln);if(!Oe)return;const lt=Oe.type==="polyline"||Oe.type==="highway",It=(Oe.style||{}).color||"#f59e0b",yt=aa.map(Pt=>[Pt.lat,Pt.lng]);lt?er.current=Bt.polyline(yt,{color:It,weight:3,dashArray:"8, 4",opacity:.9}).addTo(Ne):er.current=Bt.polygon(yt,{color:It,weight:3,fillColor:It,fillOpacity:.15,dashArray:"8, 4"}).addTo(Ne),aa.forEach((Pt,Qt)=>{const Ft=Bt.circleMarker([Pt.lat,Pt.lng],{radius:8,color:"#ffffff",weight:2,fillColor:It,fillOpacity:1,className:"editing-vertex-marker"}).addTo(Ne);Ft.dragging=!0,Ft.on("mousedown",Gt=>{Bt.DomEvent.stop(Gt);const ms=Ss=>{var Er;const Ms={x:Ss.clientX,y:Ss.clientY},hn=Ne.getContainer().getBoundingClientRect(),Vn={x:Ms.x-hn.left,y:Ms.y-hn.top};let ka=Ne.containerPointToLatLng([Vn.x,Vn.y]);const Fa=py(Ss.shiftKey,Ss.ctrlKey,al,Ti);if(Fa.isSnapping&&aa.length>1){const Ga=Qt===0?aa.length-1:Qt-1,Zi=aa[Ga],Po=((Er=Ne.getBearing)==null?void 0:Er.call(Ne))||0,po=gb(Zi,{lat:ka.lat,lng:ka.lng},Fa.snapIncrement,Po);ka=Bt.latLng(po.lat,po.lng)}mi(Ga=>{const Zi=[...Ga];return Zi[Qt]={lat:ka.lat,lng:ka.lng},Zi})},Wt=()=>{document.removeEventListener("mousemove",ms),document.removeEventListener("mouseup",Wt),Ne.dragging.enable()};Ne.dragging.disable(),document.addEventListener("mousemove",ms),document.addEventListener("mouseup",Wt)}),Ft.on("contextmenu",Gt=>{Gt.originalEvent.stopPropagation(),Gt.originalEvent.preventDefault();const ms=document.querySelector(".editing-overlay-context-menu");ms&&ms.remove();const Wt=lt?2:3,Ss=aa.length>Wt,Ms=document.createElement("div");Ms.className="editing-overlay-context-menu",Ms.style.cssText=`
1693          position: fixed;
1694          left: ${Gt.originalEvent.clientX}px;
1695          top: ${Gt.originalEvent.clientY}px;
1696          background: hsl(var(--card));
1697          border: 1px solid hsl(var(--border));
1698          border-radius: 6px;
1699          box-shadow: 0 4px 12px rgba(0,0,0,0.15);
1700          z-index: 99999;
1701          min-width: 150px;
1702          overflow: hidden;
1703        `;const hn=document.createElement("button");hn.innerHTML=`
1704          <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="margin-right: 8px;">
1705            <path d="M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
1706          </svg>
1707          Delete Point ${Qt+1}
1708        `,hn.style.cssText=`
1709          display: flex;
1710          align-items: center;
1711          width: 100%;
1712          padding: 10px 14px;
1713          border: none;
1714          background: transparent;
1715          color: ${Ss?"hsl(var(--destructive))":"hsl(var(--muted-foreground))"};
1716          cursor: ${Ss?"pointer":"not-allowed"};
1717          font-size: 13px;
1718          text-align: left;
1719          opacity: ${Ss?"1":"0.5"};
1720        `,Ss&&(hn.onmouseover=()=>{hn.style.background="hsl(var(--accent))"},hn.onmouseout=()=>{hn.style.background="transparent"},hn.onclick=()=>{mi(ka=>ka.filter((Fa,Er)=>Er!==Qt)),Ms.remove()}),Ms.appendChild(hn),document.body.appendChild(Ms);const Vn=ka=>{Ms.contains(ka.target)||(Ms.remove(),document.removeEventListener("click",Vn))};setTimeout(()=>document.addEventListener("click",Vn),10)}),Ft.bindTooltip(`Point ${Qt+1} - Drag to move`,{direction:"top",offset:[0,-10],opacity:.9}),Sr.current.push(Ft)});for(let Pt=0;Pt<aa.length;Pt++){const Qt=lt&&Pt===aa.length-1?-1:(Pt+1)%aa.length;if(Qt===-1)continue;const Ft=aa[Pt],Gt=aa[Qt],ms=(Ft.lat+Gt.lat)/2,Wt=(Ft.lng+Gt.lng)/2,Ss=Bt.divIcon({className:"editing-midpoint-marker",html:`<div style="
1721          width: 16px; height: 16px; 
1722          background: hsl(var(--background)); 
1723          border: 2px solid ${It}; 
1724          border-radius: 50%;
1725          display: flex; align-items: center; justify-content: center;
1726          cursor: pointer;
1727          font-size: 12px; font-weight: bold; color: ${It};
1728        ">+</div>`,iconSize:[16,16],iconAnchor:[8,8]}),Ms=Bt.marker([ms,Wt],{icon:Ss}).addTo(Ne);Ms.on("click",()=>{mi(hn=>{const Vn=[...hn];return Vn.splice(Pt+1,0,{lat:ms,lng:Wt}),Vn})}),Ms.bindTooltip("Click to add point",{direction:"top",offset:[0,-10],opacity:.9}),Pi.current.push(Ms)}return()=>{var Pt;(Pt=er.current)==null||Pt.remove(),Sr.current.forEach(Qt=>Qt.remove()),Pi.current.forEach(Qt=>Qt.remove())}},[ln,aa,Ba,al,Ti]),k.useEffect(()=>{if(v&&pe.current){const Ne=hC(v.geometry);if(Ne.length>0){if(Ne.length===1){const Oe=Ne[0];pe.current.flyTo([Oe.lat,Oe.lng],18,{animate:!0,duration:1,easeLinearity:.5})}else{const lt=Bt.latLngBounds(Ne.map(pt=>[pt.lat,pt.lng])).getCenter();pe.current.flyTo([lt.lat,lt.lng],18,{animate:!0,duration:1,easeLinearity:.5})}C==null||C()}else if(v.type==="marker"){const Oe=v.geometry;Oe&&typeof Oe.lat=="number"&&typeof Oe.lng=="number"&&(pe.current.flyTo([Oe.lat,Oe.lng],18,{animate:!0,duration:1,easeLinearity:.5}),C==null||C())}}},[v,C]);const Kf=k.useCallback(Ne=>{Os(Ne),hs([]),st(!0),Ve.info(`Click on the map to draw boundary for ${Ne.name}. Click first point to complete.`)},[]),Wg=k.useCallback(async Ne=>{if(!confirm(`Delete the boundary polygon for "${Ne.name}"?`))return;const{error:Oe}=await Fs.from("developments").update({boundary:null}).eq("id",Ne.id);Oe?Ve.error("Failed to delete boundary"):Ve.success("Boundary deleted")},[]),Yg=k.useCallback(()=>{At.length>0&&(hs(Ne=>Ne.slice(0,-1)),Ve.info(`Point removed. ${At.length-1} points remaining.`))},[At.length]),Nm=k.useCallback(()=>{st(!1),hs([]),Os(null),_n.current&&(_n.current.remove(),_n.current=null),Ta.current.forEach(Ne=>Ne.remove()),Ta.current=[]},[]),Jf=k.useCallback(async()=>{if(!ws||At.length<3){Ve.error("Please draw at least 3 points");return}const Ne=At.map(lt=>({lat:lt.lat,lng:lt.lng})),{error:Oe}=await Fs.from("developments").update({boundary:Ne}).eq("id",ws.id);Oe?Ve.error("Failed to save boundary"):(Ve.success(`Boundary saved for ${ws.name}`),Nm())},[ws,At,Nm]);k.useEffect(()=>{yr.current=Jf},[Jf]);const tf=k.useCallback(Ne=>{jo(Ne),jn([]),bo(!0),$u(!1),$h(0),vh(0),yd(null),Hf(null),Ve.info(`Click on the map to draw ${Ne}. ${Ne==="marker"?"Click once to place.":"Add at least "+(Ne==="polygon"?"3":"2")+" points."}`)},[]),Ip=k.useCallback(()=>{$a.length>0&&jn(Ne=>Ne.slice(0,-1))},[$a.length]),Ap=k.useCallback(()=>{var yt,at;if($a.length===0||!bh){Ve.error("Move cursor to set direction first");return}const Ne=f1(Vu,Vh);if(Ne<=0){Ve.error("Enter a valid length");return}const Oe=$a[$a.length-1],lt=((at=(yt=pe.current)==null?void 0:yt.getBearing)==null?void 0:at.call(yt))||0,pt=py(_h,Bu,Dc,Ua),It=W2(Oe,bh,Ne,pt.isSnapping?pt.snapIncrement:0,lt);if(wo&&wo.parentGeometry.length>=3)try{const Pt=wo.parentGeometry.map(Gt=>[Gt.lng,Gt.lat]);Pt.push(Pt[0]);const Qt=Xn([Pt]),Ft=us([It.lng,It.lat]);if(!uu(Ft,Qt)){Ve.error("Point must be inside the parent polygon");return}}catch(Pt){console.error("Error validating point within parent:",Pt)}jn(Pt=>[...Pt,It]),Ve.success(`Added point at ${Math.round(Ne)}'`)},[$a,bh,Vu,Vh,_h,Bu,Dc,Ua,wo]),Xu=k.useCallback(()=>{bo(!1),jo(null),jn([]),ea(null),qh(null),$u(!1),$h(0),vh(0),yd(null),Hf(null),Ac.current&&(Ac.current.remove(),Ac.current=null),Uc.current.forEach(Ne=>Ne.remove()),Uc.current=[]},[]),K0=k.useCallback(async(Ne,Oe,lt,pt,It)=>{if($a.length===0){Ve.error("Please draw at least one point");return}if(wo&&wo.parentGeometry.length>=3&&!GD($a,wo.parentGeometry)){Ve.error("Layer must be placed inside the parent polygon",{description:`The ${wo.layerType.replace(/_/g," ")} must be drawn within "${wo.parentName}"`,duration:5e3});return}const yt=It||(wo==null?void 0:wo.layerType)||void 0;try{const at=await nl.mutateAsync({name:Ne,type:lt,geometry:$a,style:{color:pt,fillColor:pt,fillOpacity:.2,weight:2},description:Oe,is_visible:!0,...yt&&{layer_type:yt}
1728,...wo&&{parent_overlay_id:wo.parentId},...ia&&{yard_kit_id:ia.id,yard_kit_type:ia.id,layer_type:"site_boundary"}});if(ia&&(at!=null&&at.id)){const Pt=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#84cc16"],Qt=ia.layers.map((Ft,Gt)=>{const ms=Pt[Gt%Pt.length];return nl.mutateAsync({name:Ft.label,type:"polygon",geometry:$a,style:{color:ms,fillColor:ms,fillOpacity:.15,weight:2},is_visible:!0,layer_type:Ft.layerType,parent_overlay_id:at.id,yard_kit_id:ia.id})});try{await Promise.all(Qt),Ve.success(`${ia.name} placed with ${ia.layers.length} layers`)}catch{Ve.error("Kit placed but some child layers failed to create")}qh(null)}else Ve.success(`${Ne} saved`);Xu(),ea(null)}catch{Ve.error("Failed to save overlay")}},[$a,nl,Xu,wo,ia]),sf=k.useCallback(Ne=>{E&&rs?rs(Ne):(r(Ne),S([]),Km(!0)),Ve.info(`Click on the map to ${Ne==="distance"?"add points for distance measurement":"draw polygon for area measurement"}.`)},[E,rs]),nf=k.useCallback(()=>{E&&vs?vs():se.length>0&&S(Ne=>Ne.slice(0,-1))},[E,vs,se.length]),Xh=k.useCallback(()=>{E&&$t?$t():(Km(!1),r(null),S([])),_e.current&&(_e.current.remove(),_e.current=null),Ie.current.forEach(Ne=>Ne.remove()),Ie.current=[],ut(null),Me.current&&(Me.current.remove(),Me.current=null)},[E,$t]),__=k.useCallback(()=>{E&&Ns?Ns():S([]),_e.current&&(_e.current.remove(),_e.current=null),Ie.current.forEach(Ne=>Ne.remove()),Ie.current=[],ut(null),Me.current&&(Me.current.remove(),Me.current=null)},[E,Ns]),y_=k.useCallback(async(Ne,Oe)=>{if(se.length===0){Ve.error("No measurement to save");return}try{const lt=ee==="distance"?"polyline":"polygon";await nl.mutateAsync({name:Ne,type:lt,geometry:se,style:{color:"#10b981",fillColor:"#10b981",fillOpacity:.2,weight:2},description:Oe||`${ee==="distance"?"Distance":"Area"} measurement`,is_visible:!0}),Ve.success(`Saved "${Ne}" as overlay`),Xh()}catch{Ve.error("Failed to save measurement")}},[se,ee,nl,Xh]);k.useEffect(()=>{if(!Se&&!cr&&!A&&!O&&!fe)return;const Ne=Oe=>{if(Oe.key==="Escape"&&(Oe.preventDefault(),Se?(Nm(),Ve.info("Drawing cancelled")):cr?(Xu(),Ve.info("Drawing cancelled")):A?(Xh(),Ve.info("Measurement cancelled")):O?(Z==null||Z(),Ve.info("Region drawing cancelled")):fe&&(on([]),ht==null||ht(),Ve.info("Custom area drawing cancelled"))),(Oe.ctrlKey||Oe.metaKey)&&Oe.key==="z"&&(Oe.preventDefault(),Se&&At.length>0?Yg():cr&&$a.length>0?Ip():A&&se.length>0?nf():O&&q==="polygon"&&gt.length>0?St(lt=>lt.slice(0,-1)):fe&&Js.length>0&&on(lt=>lt.slice(0,-1))),Oe.key==="Enter"){if(Oe.preventDefault(),Se&&At.length>=3)Jf();else if(cr&&zi==="polygon"&&$a.length>=3)xh(!0);else if(fe&&Js.length>=3&&Qe){const lt=[...Js.map(It=>[It.lng,It.lat]),[Js[0].lng,Js[0].lat]];Qe({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[lt]}}),on([])}}};return window.addEventListener("keydown",Ne),()=>window.removeEventListener("keydown",Ne)},[Se,cr,A,O,fe,q,gt.length,Js,Nm,Xu,Xh,Z,ht,Qe,Yg,Ip,nf,Jf,At.length,$a.length,zi,se.length]),k.useEffect(()=>{const Ne=Oe=>{if(!(Oe.target instanceof HTMLInputElement||Oe.target instanceof HTMLTextAreaElement||Oe.target instanceof HTMLSelectElement)){if((Oe.ctrlKey||Oe.metaKey)&&Oe.key.toLowerCase()==="z"&&!Oe.shiftKey){!Se&&!cr&&!A&&!O&&!fe&&Fi.canUndo&&(Oe.preventDefault(),Fi.undo());return}if((Oe.ctrlKey||Oe.metaKey)&&(Oe.key.toLowerCase()==="y"||Oe.key.toLowerCase()==="z"&&Oe.shiftKey)){!Se&&!cr&&!A&&!O&&!fe&&Fi.canRedo&&(Oe.preventDefault(),Fi.redo());return}}};return window.addEventListener("keydown",Ne),()=>window.removeEventListener("keydown",Ne)},[Se,cr,A,O,fe,Fi.canUndo,Fi.canRedo,Fi.undo,Fi.redo]),k.useEffect(()=>{if(!cr){yh(!1),Ad(!1);return}const Ne=lt=>{lt.key==="Shift"&&yh(!0),lt.key==="Control"&&Ad(!0),lt.key==="Enter"&&yi&&$a.length>0&&(lt.preventDefault(),Ap())},Oe=lt=>{lt.key==="Shift"&&yh(!1),lt.key==="Control"&&Ad(!1)};return window.addEventListener("keydown",Ne),window.addEventListener("keyup",Oe),()=>{window.removeEventListener("keydown",Ne),window.removeEventListener("keyup",Oe)}},[cr,yi,$a.length,Ap]),k.useEffect(()=>{if(!pe.current||!cr||zi==="marker"||Ou){ed.current&&(ed.current.remove(),ed.current=null),no.current&&(no.current.remove(),no.current=null),Ym(null),qf(null);return}if($a.length===0){ed.current&&(ed.current.remove(),ed.current=null),no.current&&(no.current.remove(),no.current=null),qf(null);return}const Ne=$a[$a.length-1],Oe=lt=>{var ka,Fa;const pt={lat:lt.latlng.lat,lng:lt.latlng.lng};let It=pt;const yt=((Fa=(ka=pe.current)==null?void 0:ka.getBearing)==null?void 0:Fa.call(ka))||0,at=py(_h,Bu,Dc,Ua);
1728yd(pt);const Pt=f1(Vu,Vh);yi&&Pt>0?It=W2(Ne,pt,Pt,at.isSnapping?at.snapIncrement:0,yt):at.isSnapping&&(It=gb(Ne,It,at.snapIncrement,yt));const Qt=Q7(Ne,It,yt);qf(Qt);const Ft=K7(Ne,It);Hf(Ft),Ym(It);const Gt=[[Ne.lat,Ne.lng],[It.lat,It.lng]],ms=yi&&Pt>0,Wt=ms?{color:"#f59e0b",weight:2,dashArray:void 0,opacity:.9}:at.isSnapping?{color:"#22c55e",weight:2,dashArray:void 0,opacity:.9}:{color:"#3b82f6",weight:2,dashArray:"6, 4",opacity:.7};ed.current?(ed.current.setLatLngs(Gt),ed.current.setStyle(Wt)):ed.current=Bt.polyline(Gt,{...Wt,interactive:!1}).addTo(pe.current);const Ss=It,Ms=U7(Qt,at.isSnapping),hn=ms?"#f59e0b":at.isSnapping?"#22c55e":"#3b82f6",Vn=Bt.divIcon({className:"drawing-angle-badge",html:`<div style="
1729          background: ${hn};
1730          color: white;
1731          padding: 2px 6px;
1732          border-radius: 4px;
1733          font-size: 11px;
1734          font-weight: 600;
1735          white-space: nowrap;
1736          box-shadow: 0 1px 3px rgba(0,0,0,0.3);
1737          transform: translate(10px, -10px);
1738        ">${Ms}${ms?` • ${Math.round(Pt)}'`:""}</div>`,iconSize:[0,0],iconAnchor:[0,0]});no.current?(no.current.setLatLng([Ss.lat,Ss.lng]),no.current.setIcon(Vn)):no.current=Bt.marker([Ss.lat,Ss.lng],{icon:Vn,interactive:!1,pane:"_norotatePane"}).addTo(pe.current)};return pe.current.on("mousemove",Oe),()=>{pe.current&&pe.current.off("mousemove",Oe),ed.current&&(ed.current.remove(),ed.current=null),no.current&&(no.current.remove(),no.current=null)}},[cr,zi,$a,_h,Bu,Dc,Ua,yi,Vu,Vh,Ou]),k.useEffect(()=>{y&&(Kf(y),x==null||x())},[y,Kf,x]),k.useEffect(()=>{pe.current&&(ya.current.forEach(Ne=>Ne.remove()),ya.current=[],t.forEach(Ne=>{if(Ne.boundary&&Array.isArray(Ne.boundary)&&Ne.boundary.length>2){const Oe=Rm(Ne.status),lt=Ne.boundary.map(It=>[It.lat,It.lng]),pt=Bt.polygon(lt,{color:Oe,weight:2,fillColor:Oe,fillOpacity:.15}).addTo(pe.current);if(i){const It=document.createElement("div"),yt=document.createElement("div");yt.style.cssText="min-width: 180px; padding: 8px;";const at=document.createElement("div");at.style.cssText="font-size: 14px; font-weight: 600; margin-bottom: 8px;",at.textContent=Ne.name,yt.appendChild(at);const Pt=document.createElement("div");Pt.style.cssText="font-size: 12px; color: #888; margin-bottom: 12px;",Pt.textContent=`Boundary: ${Ne.boundary.length} points`,yt.appendChild(Pt);const Qt=document.createElement("div");Qt.style.cssText="display: flex; gap: 8px;";const Ft=document.createElement("button");Ft.id=`redraw-${Ne.id}`,Ft.style.cssText="flex: 1; padding: 6px 12px; background: #f59e0b; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 12px;",Ft.textContent="Redraw",Qt.appendChild(Ft);const Gt=document.createElement("button");Gt.id=`delete-${Ne.id}`,Gt.style.cssText="flex: 1; padding: 6px 12px; background: #ef4444; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 12px;",Gt.textContent="Delete",Qt.appendChild(Gt),yt.appendChild(Qt),It.appendChild(yt),pt.bindPopup(It,{closeButton:!0,autoPan:!0,autoPanPadding:Bt.point(50,50),closeOnClick:!1,autoClose:!1,pane:"popupsPane"}),pt.on("popupopen",()=>{const ms=document.getElementById(`redraw-${Ne.id}`),Wt=document.getElementById(`delete-${Ne.id}`);ms&&(ms.onclick=()=>{var Ss;(Ss=pe.current)==null||Ss.closePopup(),Kf(Ne)}),Wt&&(Wt.onclick=()=>{var Ss;(Ss=pe.current)==null||Ss.closePopup(),Wg(Ne)})})}pt.on("click",It=>{Bt.DomEvent.stopPropagation(It),l(Ne),i&&pt.openPopup()}),ya.current.push(pt)}}))},[t,l,i,Kf,Wg]);const Dp=k.useCallback((Ne,Oe)=>{const lt=Ne.getChildCount(),pt=Ne.getAllChildMarkers(),It=new Set,yt=[];pt.forEach(Ft=>{const Gt=Ft._clusterData;Gt!=null&&Gt.color&&It.add(Gt.color),Gt!=null&&Gt.logoUrl&&yt.length<3&&!yt.includes(Gt.logoUrl)&&yt.push(Gt.logoUrl)});const at=Oe==="development"?"hsl(38, 92%, 50%)":"hsl(180, 70%, 45%)",Pt=lt<10?56:lt<50?68:80,Qt=yt.length>0?`<div style="display: flex; gap: 2px; margin-top: 2px;">
1739          ${yt.map(Ft=>`<img src="${Ft}" style="height: 14px; width: auto; max-width: 18px; object-fit: contain; background: white; border-radius: 2px; padding: 1px;" onerror="this.style.display='none'" />`).join("")}
1740        </div>`:"";return Bt.divIcon({html:`
1741        <div class="marker-cluster-custom" style="
1742          width: ${Pt}px;
1743          height: ${Pt}px;
1744          background: ${at};
1745          border-radius: 50%;
1746          border: 4px solid white;
1747          box-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.3), 0 0 0 1px rgba(0,0,0,0.15);
1748          display: flex;
1749          flex-direction: column;
1750          align-items: center;
1751          justify-content: center;
1752          color: ${Oe==="development"?"hsl(220, 20%, 10%)":"white"};
1753          font-weight: 700;
1754          cursor: pointer;
1755          transition: transform 0.2s ease;
1756        ">
1757          <div style="font-size: ${lt<10?"16px":"18px"}; line-height: 1;">${lt}</div>
1758          <div style="font-size: 9px; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.5px;">
1758${Oe==="development"?"New":"Existing"}</div>
1759          ${Qt}
1760        </div>
1761      `,className:"marker-cluster-wrapper",iconSize:Bt.point(Pt,Pt),iconAnchor:Bt.point(Pt/2,Pt/2)})},[]);return k.useCallback(()=>{os(Ne=>{const Oe=!Ne;return localStorage.setItem("map-clustering-enabled",String(Oe)),Oe})},[]),k.useEffect(()=>{var pt,It,yt;if(!pe.current||(es.current.forEach(at=>at.remove()),Ws.current&&(Ws.current.clearLayers(),pe.current.removeLayer(Ws.current)),es.current=[],!(J.developments!==!1)))return;const Oe=(((pt=u.visibleDeveloperIds)==null?void 0:pt.size)??0)>0||(((It=u.visibleOwnerIds)==null?void 0:It.size)??0)>0||(((yt=u.visibleTenantIds)==null?void 0:yt.size)??0)>0;if(u.showDevelopments===!1&&!Oe)return;xt&&(Ws.current=Bt.markerClusterGroup({maxClusterRadius:oC[Ls],spiderfyOnMaxZoom:!0,showCoverageOnHover:!1,zoomToBoundsOnClick:!0,disableClusteringAtZoom:16,iconCreateFunction:at=>Dp(at,"development"),clusterPane:"markersPane"})),t.filter(at=>{var ms,Wt;if(u.hiddenDevelopmentIds&&u.hiddenDevelopmentIds.includes(at.id))return!1;const Pt=u.types.length===0||u.types.includes(at.type),Qt=u.statuses.length===0||u.statuses.includes(at.status);let Ft=!0;if(u.tenantIds&&u.tenantIds.length>0){const Ms=((hr==null?void 0:hr.get(at.id))||[]).map(hn=>hn.retailer_logo_id);Ft=u.tenantIds.some(hn=>Ms.includes(hn))}let Gt=!0;if(Zs.type==="developer"&&Zs.id?Gt=at.developer_id===Zs.id:Zs.type==="owner"&&Zs.id&&(Gt=at.owner_id===Zs.id),u.showDevelopments===!1&&Oe){const Ms=((hr==null?void 0:hr.get(at.id))||[]).map(Fa=>Fa.tenant_id).filter(Boolean),hn=at.developer_id&&((ms=u.visibleDeveloperIds)==null?void 0:ms.has(at.developer_id)),Vn=at.owner_id&&((Wt=u.visibleOwnerIds)==null?void 0:Wt.has(at.owner_id)),ka=Ms.some(Fa=>{var Er;return Fa&&((Er=u.visibleTenantIds)==null?void 0:Er.has(Fa))});if(!hn&&!Vn&&!ka)return!1}return Pt&&Qt&&Ft&&Gt}).forEach(at=>{const Pt=Rm(at.status),Qt=Dx(at.type),Ft=(hr==null?void 0:hr.get(at.id))||[],Gt=Ft.length>0&&Ks,ms=Ft[0],Wt=at.developer_id?_i.get(at.developer_id):null,Ss=at.owner_id?sl.get(at.owner_id):null,Ms=(Wt==null?void 0:Wt.logo_url)||(Ss==null?void 0:Ss.logo_url),hn=(Wt==null?void 0:Wt.name)||(Ss==null?void 0:Ss.true_owner_name)||"",Vn=Fn&&!Ks&&Ms,ka=dC[Qs],Fa=uC[sr],Er=Gt||Vn?lC:Fa.markerSize,Ga=ka.logoMax,Zi=cC;let Po="",po="";const Pl=Ft.length>0?Ft[0].retailer_logo.name:"";if(Gt){const mn=Ai==="circle"?"50%":"4px";Po=`
1762          <img src="${ms.retailer_logo.logo_url}" 
1763               alt="${ms.retailer_logo.name}" 
1764               style="height: ${Ga}px; width: ${Ga}px; object-fit: contain; background: white; border-radius: ${mn}; padding: 2px; box-shadow: 0 1px 3px rgba(0,0,0,0.3);" 
1765               onerror="this.outerHTML='<span style=font-size:${Fa.fontSize}px;line-height:1;>${Qt}</span>'" />
1766        `,Ft.length>1&&(po=`
1767            <div style="position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; background: rgba(0,0,0,0.8); padding: 2px 4px; border-radius: 4px;">
1768              ${Ft.slice(1,4).map(Dn=>`<img src="${Dn.retailer_logo.logo_url}" alt="${Dn.retailer_logo.name}" style="height: 12px; width: auto; max-width: 24px; object-fit: contain; background: white; border-radius: 2px; padding: 1px;" onerror="this.style.display='none'" />`).join("")}
1769              ${Ft.length>4?`<span style="color: white; font-size: 9px; line-height: 12px;">+${Ft.length-4}</span>`:""}
1770            </div>
1771          `)}else Vn?Po=`
1772          <img src="${Ms}" 
1773               alt="${hn}" 
1774               style="height: ${Ga}px; width: ${Ga}px; object-fit: contain; background: white; border-radius: ${Ai==="circle"?"50%":"4px"}; padding: 2px; box-shadow: 0 1px 3px rgba(0,0,0,0.3);" 
1775               onerror="this.outerHTML='<span style=font-size:${Fa.fontSize}px;line-height:1;>${Qt}</span>'" />
1776        `:Po=`<span style="font-size: ${Fa.fontSize}px; line-height: 1;">${Qt}</span>`;const zc=Bt.divIcon({className:"custom-marker-wrapper",html:`
1777          <div class="custom-marker" style="
1778            width: ${Er}px;
1779            height: ${Er}px;
1780            background: ${Pt};
1781            cursor: ${i?"grab":"pointer"};
1782            position: relative;
1783            display: flex;
1784            align-items: center;
1785            justify-content: center;
1786            border: ${Zi}px solid white;
1787            overflow: visible;
1788            border-radius: 50%;
1789            box-shadow: 0 0 0 3px rgba(255,255,255,0.95), 0 2px 10px rgba(0,0,0,0.5), 0 4px 6px rgba(0,0,0,0.25);
1790            isolation: isolate;
1791          ">
1792            <div style="position: absolute; inset: -4px; border-radius: 50%; background: white; opacity: 0.85; z-index: -1;"></div>
1793            ${Po}
1794          </div>
1795          ${po}
1796        `,iconSize:[Er,Er+(Ft.length>1?16:0)],iconAnchor:[Er/2,Er/2]}),di=Bt.marker([at.lat,at.lng],{icon:zc,draggable:i,pane:"markersPane"});di._clusterData={color:Pt,logoUrl:Gt?ms.retailer_logo.logo_url:null},i&&di.on("dragend",async mn=>{const Xs=mn.target.getLatLng(),{error:Bs}=await Fs.from("developments").update({lat:Xs.lat,lng:Xs.lng}).eq("id",at.id);if(Bs)Ve.error("Failed to update location"),di.setLatLng([at.lat,at.lng]);else{je.setQueryData(["developments"],gn=>gn&&gn.map(un=>un.id===at.id?{...un,lat:Xs.lat,lng:Xs.lng}:un));const Dn=di.getElement();Dn&&(Dn.classList.add("marker-relocate-success"),setTimeout(()=>{Dn.classList.remove("marker-relocate-success")},800)),Ve.success(`Updated location for ${at.name}`),j&&j(at.id,Xs.lat,Xs.lng)}});const Ku=zy(at.type)?at.square_footage?`${(at.square_footage/1e6).toFixed(2)}
1796M SF`:"N/A SF":`${(at.units||0).toLocaleString()} Units`;let nu="";Ft.length>0&&(nu=`
1797          <div style="margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.1);">
1798            <div style="font-size: 11px; color: hsl(220 10% 60%); margin-bottom: 4px;">Tenants:</div>
1799            <div style="display: flex; flex-wrap: wrap; gap: 4px;">
1800              ${Ft.map(Xs=>`<img src="${Hc(Xs.retailer_logo.logo_url)}" alt="${Hc(Xs.retailer_logo.name)}" title="${Hc(Xs.retailer_logo.name)}" style="height: 20px; width: auto; max-width: 40px; object-fit: contain; background: white; border-radius: 2px; padding: 2px;" onerror="this.style.display='none'" />`).join("")}
1801            </div>
1802          </div>
1803        `);const zn=Y[at.id];zn&&`${fb(zn)}`;const Ja=Wt==null?void 0:Wt.logo_url,En=zn?fb(zn):null,Ys=`
1804        <div style="min-width: 220px; padding: 8px;">
1805          ${Ja||En?`
1806        <div style="display: flex; gap: 8px; margin-bottom: 10px;">
1807          ${Ja?`
1808            <div style="flex: 1; min-width: 0;">
1809              <div style="font-size: 10px; color: hsl(220 10% 50%); margin-bottom: 4px;">Developer</div>
1810              <div style="width: 60px; height: 60px; background: white; border-radius: 6px; display: flex; align-items: center; justify-content: center; overflow: hidden; border: 1px solid rgba(255,255,255,0.1);">
1811                <img src="${Hc(Ja)}" alt="${Hc((Wt==null?void 0:Wt.name)||"Developer")}" style="max-width: 52px; max-height: 52px; object-fit: contain;" onerror="this.parentElement.innerHTML='<span style=font-size:10px;color:#666;>No Logo</span>'" />
1812              </div>
1813            </div>
1814          `:""}
1815          ${En?`
1816            <div style="flex: 1; min-width: 0;">
1817              <div style="font-size: 10px; color: hsl(220 10% 50%); margin-bottom: 4px;">Photo</div>
1818              <div style="width: 60px; height: 60px; background: hsl(210 22% 20%); border-radius: 6px; overflow: hidden; border: 1px solid rgba(255,255,255,0.1);">
1819                <img src="${En}" alt="Property" style="width: 100%; height: 100%; object-fit: cover;" onerror="this.parentElement.style.display='none'" />
1820              </div>
1821            </div>
1822          `:""}
1823        </div>
1824      `:""}
1825          <div style="display: flex; align-items: center; font-size: 14px; font-weight: 600; margin-bottom: 8px;">
1826            <span>${Hc(at.name)}</span>
1827          </div>
1828          <div style="display: flex; align-items: center; gap: 6px; margin-bottom: 6px;">
1829            <span style="
1830              display: inline-block;
1831              width: 10px;
1832              height: 10px;
1833              border-radius: 50%;
1834              background: ${Pt};
1835            "></span>
1836            <span style="font-size: 12px; color: hsl(220 10% 70%);">
1837              ${_f(at.status)}
1838            </span>
1839          </div>
1840          <div style="font-size: 13px; margin-bottom: 4px;">
1841            <strong>${op(at.type)}</strong> • ${Ku}
1842          </div>
1843          <div style="font-size: 12px; color: hsl(220 10% 60%);">
1844            ${Hc(at.description||"")}
1845          </div>
1846          ${at.jobs?`<div style="font-size: 12px; color: hsl(38 92% 50%); margin-top: 6px;">Creating ${at.jobs.toLocaleString()} jobs</div>`:""}
1847          ${nu}
1848          ${i?'<div style="font-size: 11px; color: hsl(220 10% 50%); margin-top: 8px;">📍 Drag to relocate</div>':""}
1849        </div>
1850      `;di.bindPopup(Ys,{closeButton:!0,autoPan:!0,autoPanPadding:Bt.point(50,50),closeOnClick:!1,autoClose:!1,className:"custom-popup",pane:"popupsPane"});const dn=Y[at.id],zs=`
1851        <div style="min-width: 180px; max-width: 220px;">
1852          ${dn?`<div style="margin-bottom: 8px; border-radius: 4px; overflow: hidden;">
1853            <img src="${fb(dn)}" alt="Preview" style="width: 100%; height: 80px; object-fit: cover;" loading="lazy" onerror="this.parentElement.style.display='none'" />
1854          </div>`:""}
1855          <div style="font-weight: 600; font-size: 13px; margin-bottom: 4px;">${Hc(at.name)}</div>
1856          <div style="display: flex; align-items: center; gap: 4px; margin-bottom: 3px;">
1857            <span style="width: 8px; height: 8px; border-radius: 50%; background: ${Pt};"></span>
1858            <span style="font-size: 11px; color: #999;">${_f(at.status)}</span>
1859          </div>
1860          <div style="font-size: 12px; margin-bottom: 2px;">${op(at.type)} • ${Ku}</div>
1861          ${at.year?`<div style="font-size: 11px; color: #888;">Year: ${at.year}</div>`:""}
1862          ${Pl?`<div style="font-size: 11px; color: hsl(38, 92%, 50%); margin-top: 3px;">Tenant: ${Hc(Pl)}</div>`:""}
1863        </div>
1864      `;di.bindTooltip(zs,{direction:"top",offset:[0,-Er/2-5],className:"custom-tooltip",opacity:1}),di.on("click",()=>{l(at)}),di.on("contextmenu",mn=>{mn.originalEvent.stopPropagation(),mn.originalEvent.preventDefault();const Xs=pe.current.latLngToContainerPoint(mn.latlng);Sn({x:Xs.x,y:Xs.y,lat:at.lat,lng:at.lng,propertyType:"development",propertyName:at.name})}),xt?Ws.current.addLayer(di):di.addTo(pe.current),es.current.push(di)}),xt&&Ws.current&&pe.current.addLayer(Ws.current)},[u,t,l,i,j,hr,Dp,xt,Ls,Y,Qs,Ai,Ks,Fn,sr,_i,sl,Zs,J]),k.useEffect(()=>{var pt,It,yt;if(!pe.current||(is.current.forEach(at=>at.remove()),an.current&&(an.current.clearLayers(),pe.current.removeLayer(an.current)),is.current=[],!(J.existingProducts!==!1)))return;const Oe=(((pt=u.visibleDeveloperIds)==null?void 0:pt.size)??0)>0||(((It=u.visibleOwnerIds)==null?void 0:It.size)??0)>0||(((yt=u.visibleTenantIds)==null?void 0:yt.size)??0)>0;if(u.showExistingProducts===!1&&!Oe)return;xt&&(an.current=Bt.markerClusterGroup({maxClusterRadius:oC[Ls],spiderfyOnMaxZoom:!0,showCoverageOnHover:!1,zoomToBoundsOnClick:!0,disableClusteringAtZoom:16,iconCreateFunction:at=>Dp(at,"existing"),clusterPane:"markersPane"})),s.filter(at=>{var Gt,ms;if(u.hiddenExistingProductIds&&u.hiddenExistingProductIds.includes(at.id))return!1;const Pt=u.types.length===0||u.types.includes(at.type),Qt=u.statuses.length===0||u.statuses.includes(at.status);let Ft=!0;if(Zs.type==="developer"&&Zs.id?Ft=at.developer_id===Zs.id:Zs.type==="owner"&&Zs.id&&(Ft=at.owner_id===Zs.id),u.showExistingProducts===!1&&Oe){const Ss=((mo==null?void 0:mo.get(at.id))||[]).map(ka=>ka.tenant_id).filter(Boolean),Ms=at.developer_id&&((Gt=u.visibleDeveloperIds)==null?void 0:Gt.has(at.developer_id)),hn=at.owner_id&&((ms=u.visibleOwnerIds)==null?void 0:ms.has(at.owner_id)),Vn=Ss.some(ka=>{var Fa;return ka&&((Fa=u.visibleTenantIds)==null?void 0:Fa.has(ka))});if(!Ms&&!hn&&!Vn)return!1}return Pt&&Qt&&Ft}).forEach(at=>{const Pt=OE(),Qt=Dx(at.type),Ft=(mo==null?void 0:mo.get(at.id))||[],Gt=Ft.length>0&&Ks,ms=Ft[0],Wt=at.developer_id?_i.get(at.developer_id):null,Ss=at.owner_id?sl.get(at.owner_id):null,Ms=(Wt==null?void 0:Wt.logo_url)||(Ss==null?void 0:Ss.logo_url),hn=(Wt==null?void 0:Wt.name)||(Ss==null?void 0:Ss.true_owner_name)||"",Vn=Fn&&!Ks&&Ms,ka=dC[Qs],Fa=uC[sr],Er=Gt||Vn?lC:Fa.markerSize,Ga=ka.logoMax,Zi=cC;let Po="",po="";const Pl=Ft.length>0?Ft[0].retailer_logo.name:"";if(Gt){const Xs=Ai==="circle"?"50%":"4px";Po=`
1865          <img src="${ms.retailer_logo.logo_url}" 
1866               alt="${ms.retailer_logo.name}" 
1867               style="height: ${Ga}px; width: ${Ga}px; object-fit: contain; background: white; border-radius: ${Xs}; padding: 2px; box-shadow: 0 1px 3px rgba(0,0,0,0.3);" 
1868               onerror="this.outerHTML='<span style=font-size:${Fa.fontSize}px;line-height:1;>${Qt}</span>'" />
1869        `,Ft.length>1&&(po=`
1870            <div style="position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; background: rgba(0,0,0,0.8); padding: 2px 4px; border-radius: 4px;">
1871              ${Ft.slice(1,4).map(gn=>`<img src="${gn.retailer_logo.logo_url}" alt="${gn.retailer_logo.name}" style="height: 12px; width: auto; max-width: 24px; object-fit: contain; background: white; border-radius: 2px; padding: 1px;" onerror="this.style.display='none'" />`).join("")}
1872              ${Ft.length>4?`<span style="color: white; font-size: 9px; line-height: 12px;">+${Ft.length-4}</span>`:""}
1873            </div>
1874          `)}else Vn?Po=`
1875          <img src="${Ms}" 
1876               alt="${hn}" 
1877               style="height: ${Ga}px; width: ${Ga}px; object-fit: contain; background: white; border-radius: ${Ai==="circle"?"50%":"4px"}; padding: 2px; box-shadow: 0 1px 3px rgba(0,0,0,0.3);" 
1878               onerror="this.outerHTML='<span style=font-size:${Fa.fontSize}px;line-height:1;>${Qt}</span>'" />
1879        `:Po=`<span style="font-size: ${Fa.fontSize}px; line-height: 1;">${Qt}</span>`;const zc=Bt.divIcon({className:"custom-marker-wrapper existing-product-marker",html:`
1880          <div class="custom-marker" style="
1881            width: ${Er}px;
1882            height: ${Er}px;
1883            background: ${Pt};
1884            cursor: ${i?"grab":"pointer"};
1885            position: relative;
1886            display: flex;
1887            align-items: center;
1888            justify-content: center;
1889            border: ${Zi}px solid white;
1890            overflow: visible;
1891            border-radius: 50%;
1892            box-shadow: 0 0 0 3px rgba(255,255,255,0.95), 0 2px 10px rgba(0,0,0,0.5), 0 4px 6px rgba(0,0,0,0.25);
1893            isolation: isolate;
1894          ">
1895            <div style="position: absolute; inset: -4px; border-radius: 50%; background: white; opacity: 0.85; z-index: -1;"></div>
1896            ${Po}
1897          </div>
1898          ${Gt?po:`<div style="position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); background: ${Pt}; color: white; font-size: 8px; padding: 1px 4px; border-radius: 3px; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,0.3);">EXISTING</div>`}
1899        `,iconSize:[Er,Er+(Ft.length>1?16:12)],iconAnchor:[Er/2,Er/2]}),di=Bt.marker([at.lat,at.lng],{icon:zc,draggable:i,pane:"markersPane"});di._clusterData={color:Pt,logoUrl:Gt?ms.retailer_logo.logo_url:null},i&&di.on("dragend",async Xs=>{const Bs=Xs.target.getLatLng(),{error:Dn}=await Fs.from("existing_products").update({lat:Bs.lat,lng:Bs.lng}).eq("id",at.id);if(Dn)Ve.error("Failed to update location"),di.setLatLng([at.lat,at.lng]);else{je.setQueryData(["existing-products"],un=>un&&un.map(Qn=>Qn.id===at.id?{...Qn,lat:Bs.lat,lng:Bs.lng}:Qn));const gn=di.getElement();gn&&(gn.classList.add("marker-relocate-success"),setTimeout(()=>{gn.classList.remove("marker-relocate-success")},800)),Ve.success(`Updated location for ${at.name}`)}});const Ku=zy(at.type)?at.square_footage?`${(at.square_footage/1e6).toFixed(2)}
1899M SF`:"N/A SF":`${(at.units||0).toLocaleString()} Units`;let nu="";Ft.length>0&&(nu=`
1900          <div style="margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.1);">
1901            <div style="font-size: 11px; color: hsl(180 70% 45%); margin-bottom: 4px;">Tenants:</div>
1902            <div style="display: flex; flex-wrap: wrap; gap: 4px;">
1903              ${Ft.map(Bs=>`<img src="${Hc(Bs.retailer_logo.logo_url)}" alt="${Hc(Bs.retailer_logo.name)}" title="${Hc(Bs.retailer_logo.name)}" style="height: 20px; width: auto; max-width: 40px; object-fit: contain; background: white; border-radius: 2px; padding: 2px;" onerror="this.style.display='none'" />`).join("")}
1904            </div>
1905          </div>
1906        `);const zn=ue[at.id];zn&&`${pb(zn)}`;const Ja=(Wt==null?void 0:Wt.logo_url)||(Ss==null?void 0:Ss.logo_url),En=Wt!=null&&Wt.logo_url?"Developer":Ss!=null&&Ss.logo_url?"Owner":null,pr=(Wt==null?void 0:Wt.name)||(Ss==null?void 0:Ss.true_owner_name)||"",jt=zn?pb(zn):null,qn=`
1907        <div style="min-width: 220px; padding: 8px;">
1908          ${Ja||jt?`
1909        <div style="display: flex; gap: 8px; margin-bottom: 10px;">
1910          ${Ja?`
1911            <div style="flex: 1; min-width: 0;">
1912              <div style="font-size: 10px; color: hsl(180 70% 45%); margin-bottom: 4px;">${En}</div>
1913              <div style="width: 60px; height: 60px; background: white; border-radius: 6px; display: flex; align-items: center; justify-content: center; overflow: hidden; border: 1px solid rgba(255,255,255,0.1);">
1914                <img src="${Hc(Ja)}" alt="${Hc(pr)}" style="max-width: 52px; max-height: 52px; object-fit: contain;" onerror="this.parentElement.innerHTML='<span style=font-size:10px;color:#666;>No Logo</span>'" />
1915              </div>
1916            </div>
1917          `:""}
1918          ${jt?`
1919            <div style="flex: 1; min-width: 0;">
1920              <div style="font-size: 10px; color: hsl(180 70% 45%); margin-bottom: 4px;">Photo</div>
1921              <div style="width: 60px; height: 60px; background: hsl(210 22% 20%); border-radius: 6px; overflow: hidden; border: 1px solid rgba(255,255,255,0.1);">
1922                <img src="${jt}" alt="Property" style="width: 100%; height: 100%; object-fit: cover;" onerror="this.parentElement.style.display='none'" />
1923              </div>
1924            </div>
1925          `:""}
1926        </div>
1927      `:""}
1928          <div style="display: flex; align-items: center; gap: 6px; margin-bottom: 8px;">
1929            <span style="background: ${Pt}; color: white; font-size: 10px; padding: 2px 6px; border-radius: 3px; font-weight: 600;">EXISTING SITE</span>
1930          </div>
1931          <div style="font-size: 14px; font-weight: 600; margin-bottom: 8px;">
1932            ${Hc(at.name)}
1933          </div>
1934          <div style="font-size: 13px; margin-bottom: 4px;">
1935            <strong>${op(at.type)}</strong> • ${Ku}
1936          </div>
1937          <div style="font-size: 12px; color: hsl(220 10% 60%);">
1938            ${Hc(at.description||"")}
1939          </div>
1940          ${at.year?`<div style="font-size: 12px; color: hsl(180 70% 45%); margin-top: 6px;">Built ${at.year}</div>`:""}
1941          ${at.jobs?`<div style="font-size: 12px; color: hsl(180 70% 45%); margin-top: 4px;">${at.jobs.toLocaleString()} jobs</div>`:""}
1942          ${nu}
1943          ${i?'<div style="font-size: 11px; color: hsl(220 10% 50%); margin-top: 8px;">📍 Drag to relocate</div>':""}
1944        </div>
1945      `;di.bindPopup(qn,{closeButton:!0,autoPan:!0,autoPanPadding:Bt.point(50,50),closeOnClick:!1,autoClose:!1,className:"custom-popup existing-product-popup",pane:"popupsPane"});const mn=`
1946        <div style="min-width: 180px; max-width: 220px;">
1947          ${zn?`<div style="margin-bottom: 8px; border-radius: 4px; overflow: hidden;">
1948            <img src="${pb(zn)}" alt="Preview" style="width: 100%; height: 80px; object-fit: cover;" loading="lazy" onerror="this.parentElement.style.display='none'" />
1949          </div>`:""}
1950          <div style="font-weight: 600; font-size: 13px; margin-bottom: 4px;">${Hc(at.name)}</div>
1951          <div style="display: flex; align-items: center; gap: 4px; margin-bottom: 3px;">
1952            <span style="background: ${Pt}; color: white; font-size: 9px; padding: 1px 4px; border-radius: 2px;">EXISTING</span>
1953          </div>
1954          <div style="font-size: 12px; margin-bottom: 2px;">${op(at.type)} • ${Ku}</div>
1955          ${at.year?`<div style="font-size: 11px; color: #888;">Year: ${at.year}</div>`:""}
1956          ${Pl?`<div style="font-size: 11px; color: hsl(180, 70%, 45%); margin-top: 3px;">Tenant: ${Hc(Pl)}</div>`:""}
1957        </div>
1958      `;di.bindTooltip(mn,{direction:"top",offset:[0,-Er/2-5],className:"custom-tooltip",opacity:1}),di.on("click",()=>{c==null||c(at)}),di.on("contextmenu",Xs=>{Xs.originalEvent.stopPropagation(),Xs.originalEvent.preventDefault();const Bs=pe.current.latLngToContainerPoint(Xs.latlng);Sn({x:Bs.x,y:Bs.y,lat:at.lat,lng:at.lng,propertyType:"existing",propertyName:at.name})}),xt?an.current.addLayer(di):di.addTo(pe.current),is.current.push(di)}),xt&&an.current&&pe.current.addLayer(an.current)},[u,s,c,i,mo,Dp,xt,Ls,ue,Qs,Ai,Ks,Fn,sr,_i,sl,Zs,J]),k.useEffect(()=>{if(n&&pe.current){pe.current.setView([n.lat,n.lng],16,{animate:!0,duration:.5});const Oe=t.filter(lt=>{const pt=u.types.length===0||u.types.includes(lt.type),It=u.statuses.length===0||u.statuses.includes(lt.status);return pt&&It}).findIndex(lt=>lt.id===n.id);Oe!==-1&&es.current[Oe]&&es.current[Oe].openPopup()}},[n,u,t]),k.useEffect(()=>{a&&pe.current&&pe.current.setView([a.lat,a.lng],16,{animate:!0,duration:.5})},[a]),e.jsxs("div",{id:"development-map-container",className:`relative w-full h-full popup-density-${ei}`,children:[e.jsx("div",{ref:Ct,className:"absolute inset-0"}),e.jsx(NV,{map:pe.current,visible:J.cacheCoverage===!0,currentZoom:Gr}),e.jsx("div",{className:"absolute top-0 left-0 right-0 h-24 bg-gradient-to-b from-background/80 to-transparent pointer-events-none z-[400]"}),e.jsx("div",{className:"absolute top-3 left-3 right-3 md:left-4 md:right-auto z-[500] flex flex-col md:flex-row items-center gap-2",children:Xi&&e.jsxs(Le,{variant:"outline",size:"sm",className:"gap-2 bg-card/90 backdrop-blur-md border-border shadow-card h-9",onClick:()=>{var Ne;ti.current&&window.clearTimeout(ti.current),Co.current&&((Ne=pe.current)!=null&&Ne.hasLayer(Co.current))&&pe.current.removeLayer(Co.current),ml(null),Co.current=null},children:[e.jsx(ja,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Clear"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate max-w-[120px]",children:Xi.displayName.split(",")[0]})]})}),e.jsx("div",{className:"absolute top-2 left-3 z-[500]",children:e.jsx(hV,{bearing:jm,onResetBearing:Hu,onRotate:Zu,onZoomIn:ur,onZoomOut:si,onSetZoom:Ei,currentZoom:Gr,isAdmin:i,onAddDevelopment:ie,onAddExistingProduct:de,is3DMode:ge,onToggle3DMode:We,isParcelLookupMode:Ee,onToggleParcelLookup:ve,onParcelSearch:we,onShowControls:_t,onAIRecordCreated:Ce,onNavigateToRecord:Be,isMeasuring:A,onStartMeasuring:sf,isDrawingActive:cr,onStartDrawing:tf})}),e.jsx("div",{className:"absolute top-3 right-3 md:right-4 z-[500] flex flex-col gap-1.5",children:e.jsx(yV,{compact:!0})}),i&&cr&&e.jsx("div",{className:`absolute top-20 z-[10000] ${Ki?"right-[520px]":"right-4"}`,children:e.jsx(nV,{isDrawing:cr,drawingType:zi,pointsCount:$a.length,onStartDrawing:tf,onUndo:Ip,onCancel:Xu,onSave:K0,isSaving:nl.isPending,snapEnabled:Dc,snapIncrement:Ua,onSnapEnabledChange:fo,onSnapIncrementChange:vm,isShiftHeld:_h,currentAngle:Tp,currentDistanceFeet:Gf,lengthInputEnabled:yi,lengthFeet:Vu,lengthInches:Vh,onLengthInputEnabledChange:$u,onLengthChange:(Ne,Oe)=>{$h(Ne),vh(Oe)},onAddPointAtLength:Ap,triggerSaveForm:Ou,onTriggerSaveFormHandled:()=>xh(!1),defaultName:ia==null?void 0:ia.name})}),ln&&e.jsx("div",{className:`fixed z-[1002] ${Ol?"cursor-grabbing":""}`,style:{left:El.x,top:El.y},children:e.jsxs("div",{className:"bg-card/95 backdrop-blur-md p-3 rounded-xl border border-border shadow-xl min-w-[220px]",children:[e.jsx("div",{className:"flex items-center justify-between mb-2 pb-2 border-b border-border cursor-grab active:cursor-grabbing",onMouseDown:Ne=>{Ne.preventDefault(),Rd(!0),Jm({x:Ne.clientX-El.x,y:Ne.clientY-El.y})},children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"flex gap-0.5",children:[e.jsx("div",{className:"w-1 h-1 rounded-full bg-muted-foreground
1958/40"}),e.jsx("div",{className:"w-1 h-1 rounded-full bg-muted-foreground/40"})]}),e.jsxs("div",{className:"flex gap-0.5",children:[e.jsx("div",{className:"w-1 h-1 rounded-full bg-muted-foreground/40"}),e.jsx("div",{className:"w-1 h-1 rounded-full bg-muted-foreground/40"})]})]}),e.jsx(fd,{className:"w-4 h-4 text-amber-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Edit Vertices"})]})}),e.jsx("div",{className:"text-xs text-muted-foreground mb-2 truncate max-w-[180px]",children:((pc=Ba.find(Ne=>Ne.id===ln))==null?void 0:pc.name)||"Overlay"}),e.jsxs("div",{className:"text-xs font-medium text-primary mb-3",children:[aa.length," point",aa.length!==1?"s":""]}),e.jsx("div",{className:"text-xs text-muted-foreground mb-3",children:"Drag points to move • Click + to add • Right-click to delete"}),e.jsxs("div",{className:"border border-border rounded-md p-2 mb-3 space-y-2 bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Fo,{className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(B,{className:"text-xs font-medium",children:"Snap to Angles"})]}),e.jsx(kt,{checked:al,onCheckedChange:Dd,className:"scale-75"})]}),al&&e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Le,{size:"sm",variant:Ti===90?"default":"outline",className:"flex-1 h-6 text-xs",onClick:()=>fc(90),children:"90°"}),e.jsx(Le,{size:"sm",variant:Ti===45?"default":"outline",className:"flex-1 h-6 text-xs",onClick:()=>fc(45),children:"45°"})]}),!al&&e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"💡 Hold Shift for 90° • Ctrl+Shift for 45°"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>{Nn(null),mi([])},className:"flex-1",children:[e.jsx(ja,{className:"w-4 h-4 mr-1"}),"Cancel"]}),e.jsxs(Le,{size:"sm",onClick:async()=>{if(!(!ln||aa.length<2))try{await so.mutateAsync({id:ln,geometry:aa}),Ve.success("Overlay updated successfully"),Nn(null),mi([])}catch(Ne){console.error("Failed to update overlay:",Ne),Ve.error("Failed to update overlay")}},disabled:so.isPending||aa.length<2,className:"flex-1",children:[so.isPending?e.jsx(bg,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(cl,{className:"w-4 h-4 mr-1"}),"Save"]})]})]})}),Se&&e.jsx("div",{className:"absolute top-20 sm:top-32 right-2 sm:right-4 left-2 sm:left-auto z-[500] flex flex-col gap-2",children:e.jsxs("div",{className:"bg-card/95 backdrop-blur-md p-3 rounded-lg border border-border shadow-lg max-w-xs sm:max-w-none mx-auto sm:mx-0",children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Drawing Boundary"}),e.jsx("div",{className:"text-xs text-muted-foreground mb-2 truncate",children:ws==null?void 0:ws.name}),e.jsxs("div",{className:"text-xs font-medium text-primary mb-3",children:[At.length," point",At.length!==1?"s":""," ",At.length>=3&&"✓"]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(Le,{size:"sm",variant:"outline",onClick:Yg,disabled:At.length===0,className:"w-full touch-manipulation",children:[e.jsx(zf,{className:"w-4 h-4 mr-1"}),e.jsx("span",{children:"Undo"}),e.jsx("span",{className:"hidden sm:inline text-muted-foreground ml-1 text-xs",children:"(Ctrl+Z)"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Le,{size:"sm",variant:"secondary",onClick:Nm,className:"flex-1 touch-manipulation",children:[e.jsx(ja,{className:"w-4 h-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Cancel"})]}),e.jsxs(Le,{size:"sm",onClick:Jf,disabled:At.length<3,className:"flex-1 touch-manipulation",children:[e.jsx(cl,{className:"w-4 h-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Save"})]})]})]})]})}),i&&n&&!Se&&!cr&&e.jsx("div",{className:"absolute top-40 right-4 z-[500]",children:e.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>Kf(n),className:"bg-card/90 backdrop-blur-md border border-border touch-manipulation",children:[e.jsx(fd,{className:"w-4 h-4 mr-2"}),"Draw Boundary"]})}),A&&!Se&&!cr&&e.jsx("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 z-[500]",children:e.jsx(lV,{isMeasuring:A,measurementType:ee,points:se,onStartMeasuring:sf,onUndo:nf,onCancel:Xh,onClear:__,onSave:y_,onHoverElevationPoint:ut})}),(Se||cr)&&e.jsx("div",{className:"absolute bottom-4 left-2 sm:left-4 right-2 sm:right-auto z-[500]",children:e.jsxs("div",{className:"bg-amber-500/90 text-white px-3 py-1.5 rounded-full text-xs font-medium text-center sm:text-left",children:[e.jsx("span",{className:"hidden sm:inline",children:"Drawing Mode: Click to add points • Esc to cancel • Ctrl+Z to undo"}),e.jsx("span",{className:"sm:hidden",children:"Tap map to add points"})]})}),A&&e.jsx("div",{className:"absolute bottom-4 left-2 sm:left-4 right-2 sm:right-auto z-[500]",children:e.jsxs("div",{className:"bg-emerald-500/90 text-white px-3 py-1.5 rounded-full text-xs font-medium text-center sm:text-left",children:[e.jsx("span",{className:"hidden sm:inline",children:"Measuring: Click to add points • Esc to cancel • Ctrl+Z to undo"}),e.jsx("span",{className:"sm:hidden",children:"Tap map to add points"})]})}),Jt&&Vs&&e.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-[600]",children:e.jsxs(Le,{size:"sm",variant:"secondary",onClick:Vs,className:"shadow-lg bg-background/95 hover:bg-background border gap-2",children:[e.jsx(ja,{className:"w-4 h-4"}),"Clear Map View"]}
1958)}),O&&e.jsx("div",{className:"absolute bottom-4 left-2 sm:left-4 right-2 sm:right-auto z-[500]",children:e.jsxs("div",{className:"bg-violet-500/90 text-white px-3 py-2 rounded-lg text-xs font-medium flex flex-col sm:flex-row items-center gap-2",children:[e.jsx("span",{children:q==="circle"?Lt?`Click to set radius (${Ht.toFixed(2)} mi)`:"Click to set center point":`Drawing filter polygon (${gt.length} points)${gt.length>=3?" - click first point to complete":""}`}),e.jsx("button",{onClick:Z,className:"bg-white/20 hover:bg-white/30 px-2 py-0.5 rounded text-xs",children:"Cancel"})]})}),Ee&&e.jsx("div",{className:"absolute z-[500] cursor-move select-none",style:{left:Na.x,top:Na.y},onMouseDown:Ne=>{if(Ne.target.tagName==="BUTTON")return;Ne.preventDefault();const Oe=Ne.clientX-Na.x,lt=Ne.clientY-Na.y,pt=yt=>{Gn({x:Math.max(0,Math.min(yt.clientX-Oe,window.innerWidth-280)),y:Math.max(0,Math.min(yt.clientY-lt,window.innerHeight-100))})},It=()=>{document.removeEventListener("mousemove",pt),document.removeEventListener("mouseup",It),Gn(yt=>(localStorage.setItem("map-parcel-indicator-position",JSON.stringify(yt)),yt))};document.addEventListener("mousemove",pt),document.addEventListener("mouseup",It)},onTouchStart:Ne=>{if(Ne.target.tagName==="BUTTON")return;const Oe=Ne.touches[0],lt=Oe.clientX-Na.x,pt=Oe.clientY-Na.y,It=at=>{const Pt=at.touches[0];Gn({x:Math.max(0,Math.min(Pt.clientX-lt,window.innerWidth-280)),y:Math.max(0,Math.min(Pt.clientY-pt,window.innerHeight-100))})},yt=()=>{document.removeEventListener("touchmove",It),document.removeEventListener("touchend",yt),Gn(at=>(localStorage.setItem("map-parcel-indicator-position",JSON.stringify(at)),at))};document.addEventListener("touchmove",It),document.addEventListener("touchend",yt)},children:e.jsxs("div",{className:"bg-teal-600 text-white px-3 py-2 rounded-lg text-xs font-medium flex flex-col gap-1.5 shadow-lg border border-teal-500",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fh,{className:"w-3 h-3 opacity-60"}),e.jsx(Mh,{className:"w-4 h-4"}),e.jsx("span",{className:"font-semibold",children:"Parcel Locator Active"}),e.jsx("button",{onClick:ve,className:"ml-auto bg-white/20 hover:bg-white/30 px-2 py-0.5 rounded text-xs cursor-pointer transition-colors",children:"Exit"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-white/90",children:[e.jsx("span",{className:"flex items-center gap-1.5",children:Lp?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-green-400"}),"Click on map to lookup"]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-amber-400 animate-pulse"}),"Zoom in to see parcels"]})}),e.jsxs("span",{className:"bg-black/20 px-1.5 py-0.5 rounded text-[10px] font-mono",children:["Zoom: ",(Gr==null?void 0:Gr.toFixed(0))??"--"," / 15+"]})]})]})}),vd&&!Ee&&wh>0&&e.jsx("div",{className:"absolute top-20 right-4 z-[400]",children:e.jsxs(Mt,{variant:"secondary",className:"bg-teal-600/90 text-white hover:bg-teal-600 shadow-lg flex items-center gap-1.5 px-3 py-1.5",children:[e.jsx(Mh,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"font-medium",children:wh.toLocaleString()}),e.jsx("span",{className:"text-white/80 text-xs",children:"cached"})]})}),Ee&&e.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-[500]",children:e.jsxs("div",{className:"bg-emerald-600 text-white rounded-full shadow-lg px-4 py-2 flex items-center gap-2 cursor-pointer hover:bg-emerald-700 transition-colors animate-pulse-glow",onClick:ve,style:{boxShadow:"0 0 20px rgba(16, 185, 129, 0.5)"},children:[e.jsx(Mh,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-semibold",children:"Parcel Inspect Mode"}),e.jsx("span",{className:"text-emerald-200 text-xs",children:"Click parcel for details"}),e.jsx(ja,{className:"w-4 h-4 ml-1 opacity-70 hover:opacity-100"})]})}),Ee&&Gr<15&&J.parcels!==!1&&e.jsxs("div",{className:"absolute top-16 left-1/2 -translate-x-1/2 z-[500] bg-amber-500/90 backdrop-blur-md border border-amber-400 rounded-lg shadow-lg px-4 py-2 flex items-center gap-3",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-900",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.3-4.3"}),e.jsx("path",{d:"M11 8v6"}),e.jsx("path",{d:"M8 11h6"})]}),e.jsxs("span",{className:"text-sm font-medium text-amber-900",children:["Zoom to level 15+ to view parcel boundaries (current: ",Gr.toFixed(1),")"]})]}),e.jsx(fV,{open:He,onOpenChange:as||(()=>{}),isClusteringEnabled:xt,onClusteringToggle:()=>{os(Ne=>{const Oe=!Ne;return localStorage.setItem("map-clustering-enabled",String(Oe)),Oe})},clusterRadius:Ls,onClusterRadiusChange:Ne=>{Es(Ne),localStorage.setItem("map-cluster-radius",Ne)},logoSize:Qs,onLogoSizeChange:xs,logoShape:Ai,onLogoShapeChange:$s,showTenantLogos:Ks,onTenantLogosToggle:bn,showCrmLogos:Fn,onCrmLogosToggle:da,iconSize:sr,onIconSizeChange:wa,popupDensity:ei,onPopupDensityChange:Lr,isMeasuring:A,mapStyle:z,currentCenter:Ko,currentZoom:Gr,onApplyPreset:Ne=>{pe.current&&pe.current.setView(Ne.center,Ne.zoom,{animate:!0})},preloadMunicipalities:Ka,onPreloadMunicipalitiesToggle:()=>{Ha(Ne=>{const Oe=!Ne;return localStorage.setItem("map-preload-municipalities",String(Oe)),Oe})},municipalityCount:_r,showParcelLayer:Ee,onParcelLayerToggle:ve,isParcelLayerLocked:rl,cachedParcelCount:wh,parcelLimit:Rc,onLayerOrderChange:Ut,showParcelDimensions:G,onParcelDimensionsToggle:()=>{re(Ne=>{const Oe=!Ne;return Ve.info(Oe?"Parcel dimensions shown":"Parcel dimensions hidden",{duration:2e3}),Oe})}}),e.jsx(dd,{open:qr,onOpenChange:su,children:e.jsxs(ud,{className:"sm:max-w-md",children:[e.jsxs(Gd,{children:[e.jsxs(Hd,{className:"flex items-center gap-2",children:[e.jsx(jc,{className:"w-5 h-5 text-amber-500"}),"Parcel Layer Locked"]}),e.jsxs(vg,{children:["The parcel layer has been locked because you've cached ",wh.toLocaleStr
1958ing()," parcels (limit: ",Rc,"). Enter the unlock code to continue using this feature."]})]}),e.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[e.jsx(be,{type:"password",placeholder:"Enter unlock code",value:Gu,onChange:Ne=>{jh(Ne.target.value),Xf(!1)},onKeyDown:Ne=>Ne.key==="Enter"&&bm(),className:Yf?"border-destructive":""}),Yf&&e.jsx("p",{className:"text-sm text-destructive",children:"Incorrect code. Please try again."})]}),e.jsxs(vf,{children:[e.jsx(Le,{variant:"outline",onClick:()=>su(!1),children:"Cancel"}),e.jsx(Le,{onClick:bm,children:"Unlock"})]})]})}),e.jsx(pV,{open:vt,onOpenChange:Xe||(()=>{})}),Xo&&!A&&e.jsx(_V,{parcel:Xo,onClose:()=>ra(null)}),el&&e.jsxs("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-[500] bg-card/95 backdrop-blur-md border border-border rounded-lg shadow-lg px-4 py-2 flex items-center gap-3",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:"Loading municipalities..."})]}),qa&&e.jsxs("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-[500] bg-card/95 backdrop-blur-md border border-border rounded-lg shadow-lg px-4 py-2 flex items-center gap-3",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-emerald-500 border-t-transparent rounded-full animate-spin"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:"Preloading municipalities..."}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("div",{className:"w-32 h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-emerald-500 transition-all duration-300",style:{width:`${Math.round(qa.loaded/qa.total*100)}%`}})}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[qa.loaded," / ",qa.total]})]})]})]}),e.jsx(cV,{showDemographics:D.demographics,showSchools:D.schools,showWalkability:D.walkability,showCrime:D.crimeStats,demographicsMetric:D.demographicsMetric||"income",demographicsDisplayMode:D.demographicsDisplayMode||"popup",className:"absolute bottom-4 left-56 z-[450] max-w-[200px]"}),yo&&e.jsx(dV,{lat:yo.lat,lng:yo.lng,isOpen:!!yo,onClose:()=>gl(null)}),(z==="satellite"||Yi)&&!A&&!Se&&!cr&&e.jsx("div",{className:"absolute bottom-4 right-4 z-[500]",children:e.jsxs(Le,{variant:Yi?"default":"secondary",size:"sm",onClick:()=>Yi?Um():Gg(),className:"bg-card/90 backdrop-blur-md border border-border shadow-lg",children:[e.jsx(bg,{className:"w-4 h-4 mr-2"}),Yi?e.jsxs("span",{className:"flex items-center gap-2",children:["Timeline: ",Pc,e.jsx(ja,{className:"w-3 h-3"})]}):"Satellite Timeline"]})}),e.jsx(gV,{onVersionChange:ef,isActive:Yi,onClose:Um,isLoading:ul,comparisonMode:ui,onComparisonModeChange:kh,onComparisonVersionChange:wu,comparisonPosition:oa,onComparisonPositionChange:Pa}),na&&e.jsx("div",{className:"absolute z-[1000] bg-popover border border-border rounded-lg shadow-xl overflow-hidden",style:{left:na.x,top:na.y,transform:"translate(-50%, 8px)"},children:e.jsxs("div",{className:"p-1 min-w-[200px]",children:[na.overlay&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground truncate max-w-[200px]",children:[na.overlay.name,na.overlay.parent_overlay_id&&e.jsxs("span",{className:"block text-[10px] opacity-70",children:["Child of: ",((km=Ba.find(Ne=>Ne.id===na.overlay.parent_overlay_id))==null?void 0:km.name)||"Unknown"]})]}),e.jsxs("button",{className:"flex items-center gap-2 w-full px-2 py-2 text-sm hover:bg-accent rounded-md transition-colors",onClick:()=>{var Oe;const Ne=na.overlay;Nn(Ne.id),mi(((Oe=Ne.geometry)==null?void 0:Oe.map(lt=>({lat:lt.lat,lng:lt.lng})))||[]),Sn(null)},children:[e.jsx(fd,{className:"w-4 h-4 text-amber-500"}),e.jsx("span",{children:"Edit Vertices"})]}),(()=>{const Ne=ip(na.overlay);return e.jsxs("div",{className:"flex gap-1 px-2 py-1.5",children:[e.jsxs("button",{className:`flex-1 flex items-center justify-center gap-1 px-2 py-1.5 text-xs rounded-md transition-colors ${Ne?"opacity-50 cursor-not-allowed":"hover:bg-accent"}`,onClick:()=>
1958{if(Ne){Ve.info("Property outlines and setbacks are locked");return}js(na.overlay.id),Fi.enterMoveMode(),Sn(null)},title:Ne?"Locked layer cannot be moved":"Move (M)",disabled:Ne,children:[Ne?e.jsx(jc,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(Fh,{className:"w-3 h-3 text-blue-500"}),"Move"]}),e.jsxs("button",{className:`flex-1 flex items-center justify-center gap-1 px-2 py-1.5 text-xs rounded-md transition-colors ${Ne?"opacity-50 cursor-not-allowed":"hover:bg-accent bg-primary/10"}`,onClick:()=>{if(Ne){Ve.info("Property outlines and setbacks are locked");return}js(na.overlay.id),Fi.enterRotateMode(),Sn(null)},title:Ne?"Locked layer cannot be rotated":"Rotate (R)",disabled:Ne,children:[Ne?e.jsx(jc,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(mh,{className:"w-3 h-3 text-green-500"}),"Rotate"]}),e.jsxs("button",{className:`flex-1 flex items-center justify-center gap-1 px-2 py-1.5 text-xs rounded-md transition-colors ${Ne?"opacity-50 cursor-not-allowed":"hover:bg-accent"}`,onClick:()=>{if(Ne){Ve.info("Property outlines and setbacks are locked");return}js(na.overlay.id),Fi.enterScaleMode(),Sn(null)},title:Ne?"Locked layer cannot be scaled":"Scale (S)",disabled:Ne,children:[Ne?e.jsx(jc,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(N3,{className:"w-3 h-3 text-purple-500"}),"Scale"]})]})})(),e.jsxs("button",{className:"flex items-center gap-2 w-full px-2 py-2 text-sm hover:bg-accent rounded-md transition-colors",onClick:()=>{Qo(na.overlay.id),Ri(!0),Sn(null)},children:[e.jsx(Dh,{className:"w-4 h-4 text-primary"}),e.jsx("span",{children:"Polygon Tools"})]}),na.overlay.parent_overlay_id&&e.jsxs("button",{className:"flex items-center gap-2 w-full px-2 py-2 text-sm hover:bg-accent rounded-md transition-colors",onClick:()=>{const Ne=na.overlay.parent_overlay_id;Ne&&(Qo(Ne),Ri(!0)),Sn(null)},children:[e.jsx(Da,{className:"w-4 h-4 text-violet-500"}),e.jsx("span",{children:"Go to Parent"})]}),e.jsxs("button",{className:"flex items-center gap-2 w-full px-2 py-2 text-sm hover:bg-accent rounded-md transition-colors",onClick:()=>{dc(na.overlay),Al(!0),Sn(null)},children:[e.jsx(Zd,{className:"w-4 h-4 text-emerald-500"}),e.jsx("span",{children:na.overlay.image_url?"Edit Site Plan":"Add Site Plan"})]}),e.jsx("div",{className:"border-t border-border my-1"})]}),na.propertyType&&i&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground truncate max-w-[200px]",children:na.propertyName}),e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5",children:[e.jsx("input",{type:"number",value:Ui,onChange:Ne=>Ma(Ne.target.value),className:"w-14 h-7 text-xs bg-background border border-input rounded px-2 text-center",min:"0.5",step:"0.5",onClick:Ne=>Ne.stopPropagation()}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"miles"})]}),e.jsxs("button",{className:"flex items-center gap-2 w-full px-2 py-2 text-sm hover:bg-accent rounded-md transition-colors",onClick:()=>{const Ne=parseFloat(Ui)||5;ae&&(ae({lat:na.lat,lng:na.lng},Ne),Ve.success(`Showing properties within ${Ne} miles`)),Sn(null)},children:[e.jsx(E1,{className:"w-4 h-4 text-violet-500"}),e.jsxs("span",{children:["Show within ",Ui||5," mi"]})]}),e.jsx("div",{className:"border-t border-border my-1"})]}),!na.overlay&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Add at this location"}),e.jsxs("button",{className:"flex items-center gap-2 w-full px-2 py-2 text-sm hover:bg-accent rounded-md transition-colors",onClick:()=>{_&&_(na.lat,na.lng),ie&&ie(na.lat,na.lng),Sn(null)},children:[e.jsx(uh,{className:"w-4 h-4 text-primary"}),e.jsx("span",{children:"New Development"})]}),e.jsxs("button",{className:"flex items-center gap-2 w-full px-2 py-2 text-sm hover:bg-accent rounded-md transition-colors",onClick:()=>{_&&_(na.lat,na.lng),de&&de(na.lat,na.lng),Sn(null)},children:[e.jsx(Sc,{className:"w-4 h-4 text-cyan-500"}),e.jsx("span",{children:"New Existing Site"})]})]})]})}),na&&e.jsx("div",{className:"fixed inset-0 z-[999]",onClick:()=>Sn(null),onContextMenu:Ne=>{Ne.preventDefault(),Sn(null)}}),e.jsx($D,{open:Di,onClose:()=>{Al(!1),dc(null)},overlay:cc}),Ge&&e.jsx(vT,{open:Ki,onClose:()=>{Ri(!1),Qo(null),fl(void 0)},overlay:ai,allOverlays:Ba,mode:"2d",initialTab:Md,onModeChange:Ne=>{Ne==="3d"&&We&&We()},mapRef:pe.current,isPinned:Cl,onPinnedChange:Rl,transformMode:vo.mode==="none"?null:vo.mode,onTransformModeChange:Ne=>vo.setTransformMode(Ne||"none"),scaleAxis:vo.scaleAxis,onScaleAxisChange:vo.setScaleAxis,onOpenImageDialog:()=>{dc(ai),Al(!0)},onOpenSite360AI:()=>{Kr(!0)},onNavigateToOverlay:Ne=>{Qo(Ne)},onSelectOverlay:Ne=>{Qo(Ne.id),Ne.is_visible||so.mutate({id:Ne.id,is_visible:!0});const Oe=pt=>{const It=Ba.find(at=>at.id===pt);if(!It)return pt;
1958const yt=It.parent_overlay_id;return yt?Oe(yt):pt},lt=Oe(Ne.id);if(wn==null||wn(lt),Gs&&Rl(!0),Ne.geometry){const pt=Ne.geometry;if(pt.length>0&&pe.current)if(pt.length===1)pe.current.flyTo([pt[0].lat,pt[0].lng],17,{animate:!0,duration:.8});else{const It=Bt.latLngBounds(pt.map(yt=>[yt.lat,yt.lng]));pe.current.flyToBounds(It,{padding:[60,60],maxZoom:18,animate:!0,duration:.8})}}},onCreateChildLayer:(Ne,Oe)=>{if(pe.current&&ai){const lt=ai.geometry||[];Ve.info(`Draw a ${Ne.replace(/_/g," ")} within the property boundary`,{description:"The layer must be placed inside the parent polygon",duration:5e3}),ea({layerType:Ne,parentId:Oe,parentName:ai.name,parentGeometry:lt}),tf("polygon"),Ri(!1)}},onStartCanopyEdgeSelection:p,onCancelCanopyEdgeSelection:M,canopyEdgeSelectionMode:Jl,treeEditMode:hi,onTreeEditModeChange:Jd,onStartSignPlacement:Ne=>{Hl(!0),gd(Ne)},onCancelSignPlacement:()=>{Hl(!1),gd(null)},signPlacementMode:Id,placingSignId:Sl,stallEditorEnabled:Zl,onStallEditorEnabledChange:Hi,selectedStallId:eo,onSelectedStallIdChange:Wr,selectedEntryId:Tc,onSelectedEntryIdChange:Wl,entryPointPlacementMode:_o,onStartEntryPointPlacement:Ne=>{Yl(!0),pl(Ne)},onCancelEntryPointPlacement:()=>{Yl(!1),pl(null)},onStartCutoutDrawing:Ne=>{Lc(Ne),li.current=[],Ri(!1),Ve.info("Click on the map to draw a cutout zone. Click the first point again to close."),pe.current&&(pe.current.getContainer().style.cursor="crosshair")},onPlaceYardKit:Ne=>{qh(Ne),Ve.info(`Draw the boundary for "${Ne.name}"`,{description:`Draw a polygon on the map, then save to place ${Ne.layers.length} layers`,duration:5e3}),tf("polygon")},onAutoPlaceYardKit:async(Ne,Oe)=>{try{const lt=i7(Oe.geometry,Oe.setback_geometry,Ne);if(lt.length===0){Ve.error("Could not generate layout — site may be too small or have invalid geometry");return}const pt=Oe.geometry,It=await nl.mutateAsync({name:Ne.name,type:"polygon",geometry:pt,style:{color:"#6b7280",fillColor:"#6b7280",fillOpacity:.05,weight:1,dashArray:"6 3"},is_visible:!0,layer_type:"site_boundary",parent_overlay_id:Oe.id,yard_kit_id:Ne.id,development_id:Oe.development_id,existing_product_id:Oe.existing_product_id,folder_id:Oe.folder_id});if(!(It!=null&&It.id)){Ve.error("Failed to create kit parent overlay");return}const yt=lt.map(at=>{const Pt=p7(at.layerType);return nl.mutateAsync({name:at.label,type:"polygon",geometry:at.geometry,style:{color:Pt.color,fillColor:Pt.color,fillOpacity:Pt.fillOpacity,weight:2},is_visible:!0,layer_type:at.layerType,parent_overlay_id:It.id,yard_kit_id:Ne.id,development_id:Oe.development_id,existing_product_id:Oe.existing_product_id,folder_id:Oe.folder_id,...at.defaults||{}})});await Promise.all(yt),Ve.success(`${Ne.name} placed in "${Oe.name}" with ${lt.length} layers`)}catch(lt){console.error("[AutoPlaceYardKit] Error:",lt),Ve.error("Failed to auto-place kit")}}}),e.jsx(V7,{open:So,onClose:()=>Kr(!1),parentOverlay:ai,onGenerateComplete:()=>{je.invalidateQueries({queryKey:["map-overlays"]})}}),Vr&&Bn&&e.jsx(H7,{overlay:Vr,position:Bn,activeMode:ri.mode,onModeChange:ri.setTransformMode,isTransforming:ri.isTransforming,onConfirm:()=>ri.endTransform(),onCancel:()=>ri.cancelTransform(),onOpenPolygonTools:()=>{Qo(Rs),Ri(!0),tu()},onDelete:async()=>{if(Vr&&confirm(`Delete "${Vr.name}"?`))try{await Qc.mutateAsync(Vr.id),Ve.success(`Deleted ${Vr.name}`),tu()}catch{Ve.error("Failed to delete overlay")}},onDuplicate:()=>{Vr&&_d.mutate({overlay:Vr,allOverlays:Ba})},onMirror:async()=>{if(!Vr)return;const Ne=Vr.parent_overlay_id;if(!Ne){Ve.error("No parent building to mirror against");return}const Oe=Ba.find(lt=>lt.id===Ne);if(!Oe){Ve.error("Parent building not found");return}try{const{mirrorOverlayGeometry:lt,getOppositePlacement:pt}=await br(async()=>{const{mirrorOverlayGeometry:Qt,getOppositePlacement:Ft}=await import("./mirrorGeometry-fBud_E6H.js");return{mirrorOverlayGeometry:Qt,getOppositePlacement:Ft}},__vite__mapDeps([31,3,1,2,4,5,6])),It=lt(Vr.geometry,Oe.geometry);if(It.length===0){Ve.error("Could not compute mirrored geometry");return}const yt={name:`${Vr.name} (mirrored)`,type:Vr.type,geometry:It,layer_type:Vr.layer_type,style:Vr.style,parent_overlay_i
1958d:Ne,development_id:Vr.development_id,existing_product_id:Vr.existing_product_id};Vr.layer_type==="truck_court"&&Vr.truck_court_placement&&(yt.truck_court_placement=pt(Vr.truck_court_placement));const at=await nl.mutateAsync(yt),Pt=at==null?void 0:at.id;if(Pt){const Qt=Ba.filter(Ft=>Ft.parent_overlay_id===Vr.id);for(const Ft of Qt){const Gt=lt(Ft.geometry,Oe.geometry);if(Gt.length===0)continue;const ms={name:`${Ft.name} (mirrored)`,type:Ft.type,geometry:Gt,layer_type:Ft.layer_type,style:Ft.style,parent_overlay_id:Pt,development_id:Ft.development_id,existing_product_id:Ft.existing_product_id};await nl.mutateAsync(ms)}}Ve.success(`Mirrored ${Vr.name} to opposite side`)}catch(lt){console.error("Mirror failed:",lt),Ve.error("Failed to mirror overlay")}},canMirror:!!(Vr!=null&&Vr.parent_overlay_id),onClose:tu,onPositionChange:vu,currentAngle:ri.transformState.currentAngle,currentScale:ri.transformState.currentScale,scaleAxis:ri.scaleAxis,onScaleAxisChange:ri.setScaleAxis,currentDimensions:ri.transformState.currentDimensions,canUndo:ri.canUndo,canRedo:ri.canRedo,onUndo:ri.undo,onRedo:ri.redo,onEditVertices:()=>{var Ne;Vr&&(Nn(Vr.id),mi(((Ne=Vr.geometry)==null?void 0:Ne.map(Oe=>({lat:Oe.lat,lng:Oe.lng})))||[]),tu())}}),Zt&&pe.current&&Vr&&ri.mode!=="none"&&!Ki&&e.jsx(hb,{map:pe.current,overlay:Vr,mode:ri.mode,isTransforming:ri.isTransforming,previewGeometry:ri.previewGeometry,onHandleMouseDown:Ne=>{ri.startTransform({lat:Ne.latlng.lat,lng:Ne.latlng.lng})},onHandleMouseUp:()=>{}}),Zt&&pe.current&&eu&&Fi.mode!=="none"&&!Ki&&!Vr&&e.jsx(hb,{map:pe.current,overlay:eu,mode:Fi.mode,isTransforming:Fi.isTransforming,previewGeometry:Fi.previewGeometry,onHandleMouseDown:Ne=>{Fi.startTransform({lat:Ne.latlng.lat,lng:Ne.latlng.lng})},onHandleMouseUp:()=>{}}),Zt&&pe.current&&ai&&vo.mode!=="none"&&Ki&&e.jsx(hb,{map:pe.current,overlay:ai,mode:vo.mode,isTransforming:vo.isTransforming,previewGeometry:vo.previewGeometry,onHandleMouseDown:Ne=>{vo.startTransform({lat:Ne.latlng.lat,lng:Ne.latlng.lng})},onHandleMouseUp:()=>{}})]})});function Ir(t,s,n,a){if(t.getSource(s))try{t.getSource(s).setData(n.data)}catch{}else t.addSource(s,n);a.sourceIds.push(s)}function jr(t,s,n,a){t.getLayer(s.id)||(t.addLayer(s,a),n.layerIds.push(s.id))}function mC(t,s){for(const n of s.layerIds)n.includes("-logo-threejs")&&br(async()=>{const{removeSignageLogosFromMap:a}=await import("./signageLogoRenderer-BfZvTPj_.js");return{removeSignageLogosFromMap:a}},__vite__mapDeps([32,33,1,2,12,4,5,11,8,10,13,3,6,9,15,16,17,20,14,21,22,19,23,24,25,18,26,27,28])).then(({removeSignageLogosFromMap:a})=>{a(t,n.replace("-logo-threejs",""))}),n.includes("-columns-threejs")&&br(async()=>{const{removeColumnGrid3D:a}=await import("./columnGrid3DRenderer-DB5Ueeni.js");return{removeColumnGrid3D:a}},__vite__mapDeps([34,33,1,2,12,4,5,11,8,10,13,3,6,9,15,16,17,20,14,21,22,19,23,24,25,18,26,27,28])).then(({removeColumnGrid3D:a})=>{a(t,n)}),n.includes("-slab-threejs")&&br(async()=>{const{removeFloorSlab3D:a}=await import("./floorSlab3DRenderer-CXkN0Q74.js");return{removeFloorSlab3D:a}},__vite__mapDeps([35,33,1,2,12,4,5,11,8,10,13,3,6,9,15,16,17,20,14,21,22,19,23,24,25,18,26,27,28])).then(({removeFloorSlab3D:a})=>{a(t,n)}),t.getLayer(n)&&t.removeLayer(n);for(const n of s.sourceIds)t.getSource(n)&&t.removeSource(n);if(s.markers)for(const n of s.markers)n.remove()}function Kd(){return{layerIds:[],sourceIds:[],markers:[]}}function zV(t,s){const n={validGeometry:null,violationGeometry:null,hasViolation:!1};if(!s)return n;const a=t.geometry,l=s.geometry;if(!Array.isArray(a)||a.length<3||!Array.isArray(l)||l.length<3)return n;let c;if(s.setback_geometry){const i=Df(s.setback_geometry);i.innerPolygon&&i.innerPolygon[0]&&i.innerPolygon[0].length>=4?c=i.innerPolygon[0]:(c=l.map(_=>[_.lng,_.lat]),c.push(c[0]))}else c=l.map(i=>[i.lng,i.lat]),c.push(c[0]);if(c.length>=3){const i=c[0],_=c[c.length-1];(i[0]!==_[0]||i[1]!==_[1])&&c.push([...c[0]])}const u=a.map(i=>[i.lng,i.lat]);u.push(u[0]);try{const i=Xn([u]),_=Xn([c]),j=xm(Un([i,_])),y=pd(Un([i,_]));let x=null,v=null;j!=null&&j.geometry&&(j.geometry.type==="Polygon"?x=j.geometry.coordinates:j.geometry.type==="MultiPolygon"&&(x=j.geometry.coordinates[0])),y!=null&&y.geometry&&(y.geometry.type==="Polygon"?v=y.geometry.coordinates:y.geometry.type==="MultiPolygon"&&(v=y.geometry.coordinates[0]));const C=v!==null&&v.length>0&&v[0].length>=4;return{validGeometry:x,violationGeometry:C?v:null,hasViolation:C}}catch(i){return console.warn("Error calculating building violation:",i),n}}const fC={concrete:"#6b7280",glass:"#38bdf8",brick:"#b45309",metal_panel:"#94a3b8",stucco:"#d6d3d1",tilt_up:"#78716c"},OV=t=>(t.building_buffer_thickness_in||8)/12*.3048;function HT(t,s){let n=s.fillColor||s.color||"#3b82f6";const a=t.layer_type;a==="warehouse_bay"?n="#64748b":a==="office_area"?n="#0ea5e9":a==="retail_pad"?n="#f59e0b":a==="building_footprint"?n="#6366f1":a==="building_core"&&(n="#8b5cf6");const l=t.material_preset;return l&&fC[l]&&(n=fC[l]),t.wall_color&&(n=t.wall_color),n}function gy(t,s){try{const n=Xn([[...t,t[0]]]),a=dl(n,s,{units:"meters"});if(a&&a.geometry)return a.geometry.coordinates[0].slice(0,-1)}catch{}return t}function BV(t,s,n,a,l,c,u){var ce;const i=Kd(),{buildingHeight:_,buildingOpacity:j}=u,y=s.height_ft;if(!y||y<=0)return i;const x=s.style||{},v=y*.3048,C=(s.base_elevation_ft||0)*.3048,P=OV(s),I=C+P,z=HT(s,x),F=`${a}
1958-fill`,D=s.parent_overlay_id?u.overlaysById.get(s.parent_overlay_id):void 0,X=zV(s,D);if(X.hasViolation&&X.violationGeometry){const ae=`${n}-violation`,ie=`${a}-violation`;Ir(t,ae,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:X.violationGeometry},properties:{name:`${s.name} - Violation`}}},i),jr(t,{id:ie,type:"fill-extrusion",source:ae,paint:{"fill-extrusion-color":"#ef4444","fill-extrusion-height":(I+v)*_,"fill-extrusion-base":I*_,"fill-extrusion-opacity":.9,"fill-extrusion-vertical-gradient":!0}},i)}if(X.hasViolation&&X.validGeometry)try{t.getSource(n)&&t.getSource(n).setData({type:"Feature",geometry:{type:"Polygon",coordinates:X.validGeometry},properties:{name:s.name}})}catch{}const K=s.roof_type||"",J=(s.roof_height_ft||4)*.3048,H=["gabled","hipped","shed","mansard"].includes(K);jr(t,{id:F,type:"fill-extrusion",source:n,paint:{"fill-extrusion-color":z,"fill-extrusion-height":H?(I+v-J)*_:(I+v)*_,"fill-extrusion-base":I*_,"fill-extrusion-opacity":s.opacity??j,"fill-extrusion-vertical-gradient":!s.show_column_grid}},i),$V(t,s,n,a,l,P,i);const O=s.floor_count||1,W=(s.floor_height_ft||12)*.3048;if(O>1)for(let ie=1;ie<O;ie++){const de=`${n}-floor-${ie}`,ge=`${a}-floor-${ie}`,We=I+ie*W;Ir(t,de,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[[...l,l[0]]]},properties:{name:`${s.name} - Floor ${ie}`}}},i),jr(t,{id:ge,type:"fill-extrusion",source:de,paint:{"fill-extrusion-color":"#1f2937","fill-extrusion-height":(We+.15)*_,"fill-extrusion-base":(We-.15)*_,"fill-extrusion-opacity":.8,"fill-extrusion-vertical-gradient":!1}},i)}VV(t,s,n,a,l,I,v,J,K,z,_,j,i);const Q=s.facade_peaks||[],Z=((ce=s.exterior_finishes)==null?void 0:ce.peaks_above_cornice)===!0,oe=()=>{GV(t,s,n,a,l,Q,I,v,J,K,z,_,j,i)};return Z||oe(),HV(t,s,n,a,l,I,v,J,K,z,_,j,Q,Z,i),Z&&oe(),i}function $V(t,s,n,a,l,c,u){var I,z;const i=s.building_buffer_type,_=s.building_buffer_ft||0;if(!i||i==="none"||_<=0)return;const j=s.building_buffer_edge_indices,y=s.building_buffer_edge_config,x=j&&j.length>0,v=y&&Object.keys(y).length>0,C={concrete:"#9ca3af",brick_pavers:"#b45309",stamped_concrete:"#78716c",flagstone:"#6b7280",turf:"#86efac",gravel:"#d1d5db"};if(!x&&!v){const F=s.building_buffer_material||"concrete",D=C[F]||"#9ca3af",X=[...l,l[0]];try{const K=Xn([X]),te=_*.3048,J=dl(K,te,{units:"meters"}),H=(I=J==null?void 0:J.geometry)==null?void 0:I.coordinates;if(((z=H==null?void 0:H[0])==null?void 0:z.length)>=4){const O=[H[0],X],q=`${n}-buffer-full`,W=`${a}-buffer-full`;Ir(t,q,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:O},properties:{name:`${s.name} - Buffer`}}},u),jr(t,{id:W,type:"fill-extrusion",source:q,paint:{"fill-extrusion-color":D,"fill-extrusion-height":c,"fill-extrusion-base":0,"fill-extrusion-opacity":.7,"fill-extrusion-vertical-gradient":!1}},u)}}catch{}return}(x?j:Object.keys(y).map(F=>parseInt(F,10)).filter(F=>!isNaN(F))).forEach((F,D)=>{const X=l[F],K=l[(F+1)%l.length];if(!X||!K)return;const te=(y==null?void 0:y[String(F)])||{},J=te.width_ft||_,H=te.material||s.building_buffer_material||"concrete",O=K[0]-X[0],q=K[1]-X[1],W=Math.sqrt(O*O+q*q);if(W===0)return;const Q=-q/W,Z=O/W,oe=l.reduce((Re,qt)=>Re+qt[0],0)/l.length,ce=l.reduce((Re,qt)=>Re+qt[1],0)/l.length,ae=(X[0]+K[0])/2,ie=(X[1]+K[1])/2;let de=Q,ge=Z;(oe-ae)*Q+(ce-ie)*Z>0&&(de=-Q,ge=-Z);const ve=J*.3048/111320,we=Math.cos(X[1]*Math.PI/180),Ze=[X[0]+de*ve/we,X[1]+ge*ve],ke=[K[0]+de*ve/we,K[1]+ge*ve],ze=C[H]||"#9ca3af",Ke=`${n}-buffer-${D}`,dt=`${a}-buffer-${D}`;Ir(t,Ke,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[[X,K,ke,Ze,X]]},properties:{name:`${s.name} - Buffer Edge ${F}`}}},u),jr(t,{id:dt,type:"fill-extrusion",source:Ke,paint:{"fill-extrusion-color":ze,"fill-extrusion-height":c,"fill-extrusion-base":0,"fill-extrusion-opacity":.7,"fill-extrusion-vertical-gradient":!1}},u)})}function VV(t,s,n,a,l,c,u,i,_,j,y,x,v){var I,z;const C=s.roof_color||j,P=[...l,l[0]];if(_==="parapet"){let D=null;try{const J=Xn([P]),H=dl(J,-.6,{units:"meters"}),O=(I=H==null?void 0:H.geometry)==null?void 0:I.coordinates;((z=O==null?void 0:O[0])==null?void 0:z.length)>=4&&(D=O[0])}catch{}const X=D?[P,D]:[P],K=`${n}-parapet`,te=`${a}-parapet`;Ir(t,K,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:X},properties:{name:`${s.name} - Parapet`}}},v),jr(t,{id:te,type:"fill-extrusion",source:K,paint:{"fill-extrusion-color":C,"fill-extrusion-height":(c+u+i)*y,"fill-extrusion-base":(c+u)*y,"fill-extrusion-opacity":Math.min((s.opacity??x)+.1,1),"fill-extrusion-vertical-gradient":!1}},v)}else["shed","mansard","hipped","gabled"].includes(_)&&qV(t,s,n,a,l,c,u,i,_,C,y,x,v);if(!_||_==="flat"||_==="parapet"){const D=`${n}-roof-flat-cap`,X=`${a}-roof-flat-cap`;Ir(t,D,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[P]},properties:{name:`${s.name} - Roof Cap`}}},v),jr(t,{id:X,type:"fill-extrusion",source:D,paint:{"fill-extrusion-color":C,"fill-extrusion-height":(c+u+.15)*y,"fill-extrusion-base":(c+u-.15)*y,"fill-extrusion-opacity":Math.min((s.opacity??x)+.15,1),"f
1958ill-extrusion-vertical-gradient":!1}},v)}}function qV(t,s,n,a,l,c,u,i,_,j,y,x,v){var O,q,W,Q;const P=s.roof_eave_height_ft||0,F=((s.roof_ridge_height_ft||P+(s.roof_height_ft||4))-P)*.3048,D=c+u-i,X=[...l,l[0]],K=Xn([X]),H=(s.width_ft||100)*.3048*.45;for(let Z=0;Z<8;Z++){const oe=Z/8,ce=(Z+1)/8;let ae,ie;_==="shed"?(ae=oe,ie=ce):_==="mansard"?(ae=1-Math.pow(1-oe,3),ie=1-Math.pow(1-ce,3)):(ae=oe,ie=ce);const de=oe*H,ge=ce*H;let We=X,Ee=null;if(de>.1)try{const Ke=dl(K,-de,{units:"meters"}),dt=(O=Ke==null?void 0:Ke.geometry)==null?void 0:O.coordinates;if(((q=dt==null?void 0:dt[0])==null?void 0:q.length)>=4)We=dt[0];else continue}catch{continue}if(Z<7)try{const Ke=dl(K,-ge,{units:"meters"}),dt=(W=Ke==null?void 0:Ke.geometry)==null?void 0:W.coordinates;((Q=dt==null?void 0:dt[0])==null?void 0:Q.length)>=4&&(Ee=dt[0])}catch{}const ve=D+ae*F,we=D+ie*F,Ze=`${a}-pitched-${Z}`,ke=`${n}-pitched-${Z}`;Ir(t,ke,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:Ee?[We,Ee]:[We]},properties:{name:`${s.name} - Roof Step ${Z}`}}},v),jr(t,{id:Ze,type:"fill-extrusion",source:ke,paint:{"fill-extrusion-color":j,"fill-extrusion-height":we*y,"fill-extrusion-base":ve*y,"fill-extrusion-opacity":s.opacity??x,"fill-extrusion-vertical-gradient":!1}},v)}}function GV(t,s,n,a,l,c,u,i,_,j,y,x,v,C){if(c.length===0||l.length<3)return;const I=["gabled","hipped","shed","mansard"].includes(j||"")?u+i-_:u+i+_,z=s.wall_color||y;c.forEach((F,D)=>{const X=F.edgeIndex??0,K=l[X%l.length],te=l[(X+1)%l.length];if(!K||!te)return;const J=(F.startPct??0)/100,H=(F.endPct??100)/100,O=F.heightFt??4,q=F.depthFt??5,W=F.color||z,Q=[K[0]+(te[0]-K[0])*J,K[1]+(te[1]-K[1])*J],Z=[K[0]+(te[0]-K[0])*H,K[1]+(te[1]-K[1])*H],oe=te[0]-K[0],ce=te[1]-K[1],ae=Math.sqrt(oe*oe+ce*ce);if(ae===0)return;const ie=l.reduce((fe,Qe)=>fe+Qe[0],0)/l.length,de=l.reduce((fe,Qe)=>fe+Qe[1],0)/l.length,ge=(K[0]+te[0])/2,We=(K[1]+te[1])/2;let Ee=-ce/ae,ve=oe/ae;(ie-ge)*Ee+(de-We)*ve<0&&(Ee=-Ee,ve=-ve);const Ze=q*.3048/111320,ke=Ee*Ze/Math.cos(Q[1]*Math.PI/180),ze=ve*Ze,Ke=[Z[0]+ke,Z[1]+ze],dt=[Q[0]+ke,Q[1]+ze],Re=[Q,Z,Ke,dt,Q],qt=O*.3048,ft=`${n}-peak-${D}`,Fe=`${a}-peak-${D}`;Ir(t,ft,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[Re]},properties:{name:`${s.name} - Peak ${D+1}`}}},C),jr(t,{id:Fe,type:"fill-extrusion",source:ft,paint:{"fill-extrusion-color":W,"fill-extrusion-height":(I+qt)*x,"fill-extrusion-base":I*x,"fill-extrusion-opacity":Math.min((s.opacity??v)+.05,1),"f
1958ill-extrusion-vertical-gradient":!1}},C)})}function HV(t,s,n,a,l,c,u,i,_,j,y,x,v,C,P){const I=s.exterior_finishes;if(!I||l.length<3)return;const F=["gabled","hipped","shed","mansard"].includes(_||"")?(c+u-i)*y:(c+u+i)*y,D=c*y,X=s.wall_color||j,K=.3048;if(I.wainscot_enabled){const H=Math.min((I.wainscot_height_ft||4)*K,u*.5),O=I.wainscot_color||"#78716c",q=gy(l,.05),W=`${n}-wainscot`,Q=`${a}-wainscot`;Ir(t,W,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[[...q,q[0]]]},properties:{}}},P),jr(t,{id:Q,type:"fill-extrusion",source:W,paint:{"fill-extrusion-color":O,"fill-extrusion-height":D+H*y,"fill-extrusion-base":D,"fill-extrusion-opacity":Math.min((s.opacity??x)+.1,1),"fill-extrusion-vertical-gradient":!1}},P)}if(I.color_split_enabled){const H=(I.color_split_height_ft||10)*K*y,O=I.lower_color||"#78716c",q=I.upper_color||"#e5e7eb",W=gy(l,.03),Q=[...W,W[0]],Z=`${n}-cs-lower`,oe=`${a}-cs-lower`;Ir(t,Z,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[Q]},properties:{}}},P),jr(t,{id:oe,type:"fill-extrusion",source:Z,paint:{"fill-extrusion-color":O,"fill-extrusion-height":D+H,"fill-extrusion-base":D,"fill-extrusion-opacity":Math.min((s.opacity??x)+.05,1),"fill-extrusion-vertical-gradient":!1}},P);const ce=`${n}-cs-upper`,ae=`${a}-cs-upper`;Ir(t,ce,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[Q]},properties:{}}},P),jr(t,{id:ae,type:"fill-extrusion",source:ce,paint:{"fill-extrusion-color":q,"fill-extrusion-height":F,"fill-extrusion-base":D+H,"fill-extrusion-opacity":Math.min((s.opacity??x)+.05,1),"fill-extrusion-vertical-gradient":!1}},P)}if((I.accent_bands||[]).forEach((H,O)=>
1958{const q=(H.height_ft||12)*K*y,W=(H.thickness_ft||1)*K*y,Q=D+q+W/2,Z=D+q-W/2;if(Z>=F)return;const oe=gy(l,.08),ce=`${n}-band-${O}`,ae=`${a}-band-${O}`;Ir(t,ce,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[[...oe,oe[0]]]},properties:{}}},P),jr(t,{id:ae,type:"fill-extrusion",source:ce,paint:{"fill-extrusion-color":H.color||"#b91c1c","fill-extrusion-height":Math.min(Q,F),"fill-extrusion-base":Z,"fill-extrusion-opacity":Math.min((s.opacity??x)+.1,1),"fill-extrusion-vertical-gradient":!1}},P)}),I.cornice_enabled){const H=(I.cornice_height_ft||1.5)*K*y,O=(I.cornice_depth_ft||1)*K,q=I.cornice_color||"#374151",W=gy(l,O),Q=[...W,W[0]],Z=[...l,l[0]];let oe={type:"Feature",geometry:{type:"Polygon",coordinates:[Q,Z]},properties:{}};if(C&&v.length>0)for(let ie=0;ie<v.length;ie++){const de=v[ie],ge=de.edgeIndex??0,We=l[ge%l.length],Ee=l[(ge+1)%l.length];if(!We||!Ee)continue;const ve=(de.startPct??0)/100,we=(de.endPct??100)/100,Ze=de.depthFt??5,ke=[We[0]+(Ee[0]-We[0])*ve,We[1]+(Ee[1]-We[1])*ve],ze=[We[0]+(Ee[0]-We[0])*we,We[1]+(Ee[1]-We[1])*we],Ke=Ee[0]-We[0],dt=Ee[1]-We[1],Re=Math.sqrt(Ke*Ke+dt*dt);if(Re===0)continue;const qt=l.reduce((zt,rs)=>zt+rs[0],0)/l.length,ft=l.reduce((zt,rs)=>zt+rs[1],0)/l.length,Fe=(We[0]+Ee[0])/2,fe=(We[1]+Ee[1])/2;let Qe=-dt/Re,ht=Ke/Re;(qt-Fe)*Qe+(ft-fe)*ht<0&&(Qe=-Qe,ht=-ht);const as=Math.max(Ze,(I.cornice_depth_ft||1)*3.281+2)*.3048/111320,vt=Qe*as/Math.cos(ke[1]*Math.PI/180),Xe=ht*as,Ce=1*.3048/111320,Be=-Qe*Ce/Math.cos(ke[1]*Math.PI/180),Dt=-ht*Ce,Rt={type:"Feature",geometry:{type:"Polygon",coordinates:[[[ke[0]+Be,ke[1]+Dt],[ze[0]+Be,ze[1]+Dt],[ze[0]+vt,ze[1]+Xe],[ke[0]+vt,ke[1]+Xe],[ke[0]+Be,ke[1]+Dt]]]},properties:{}};try{const rs=pd({type:"FeatureCollection",features:[oe,Rt]});rs&&rs.geometry&&(oe=rs)}catch{}}const ce=`${n}-cornice`,ae=`${a}-cornice`;Ir(t,ce,{type:"geojson",data:oe},P),jr(t,{id:ae,type:"fill-extrusion",source:ce,paint:{"fill-extrusion-color":q,"fill-extrusion-height":F+H*.2,"fill-extrusion-base":F-H,"fill-extrusion-opacity":Math.min((s.opacity??x)+.15,1),"fill-extrusion-vertical-gradient":!1}},P)}(I.pilasters||[]).forEach((H,O)=>{const q=H.edgeIndex??0,W=l[q%l.length],Q=l[(q+1)%l.length];if(!W||!Q)return;const Z=Math.max(2,Math.min(98,H.positionPct??50))/100,oe=H.widthFt??2,ce=H.depthFt??1.5,ae=H.color||I.wainscot_color||X,ie=[W[0]+(Q[0]-W[0])*Z,W[1]+(Q[1]-W[1])*Z],de=Q[0]-W[0],ge=Q[1]-W[1],We=Math.sqrt(de*de+ge*ge);if(We===0)return;const Ee=de/We,ve=ge/We,we=l.reduce((Xe,Ce)=>Xe+Ce[0],0)/l.length,Ze=l.reduce((Xe,Ce)=>Xe+Ce[1],0)/l.length;let ke=-ve,ze=Ee;(we-ie[0])*ke+(Ze-ie[1])*ze>0&&(ke=-ke,ze=-ze);const dt=oe*K/2/111320,Re=ce*K/111320,qt=Math.cos(ie[1]*Math.PI/180),ft=[ie[0]-Ee*dt/qt,ie[1]-ve*dt],Fe=[ie[0]+Ee*dt/qt,ie[1]+ve*dt],fe=[Fe[0]+ke*Re/qt,Fe[1]+ze*Re],Qe=[ft[0]+ke*Re/qt,ft[1]+ze*Re];let ht=D,_t=F;const He=s.height_ft||12;H.heightMode==="partial"&&(ht=D+(H.startHeightFt||0)*K*y,_t=D+(H.endHeightFt||He)*K*y);const as=`${n}-pilaster-${O}`,vt=`${a}-pilaster-${O}`;Ir(t,as,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[[ft,Fe,fe,Qe,ft]]},properties:{}}},P),jr(t,{id:vt,type:"fill-extrusion",source:as,paint:{"fill-extrusion-color":ae,"fill-extrusion-height":_t,"fill-extrusion-base":ht,"fill-extrusion-opacity":Math.min((s.opacity??x)+.05,1),"fill-extrusion-vertical-gradient":!1}},P)})}function Nc(t,s,n){const a=s/3280.84;return On(us(t),a,n,{units:"kilometers"}).geometry.coordinates}function W0(t,s){const n=(t.bearingDeg+90)%360,a=(t.bearingDeg-90+360)%360,l=Nc(t.midpoint,10,n),c=Nc(t.midpoint,10,a),u=Math.sqrt(Math.pow(l[0]-s[0],2)+Math.pow(l[1]-s[1],2)),i=Math.sqrt(Math.pow(c[0]-s[0],2)+Math.pow(c[1]-s[1],2));return u>i?n:a}function ZV(t){const{edge:s,pattern:n,floorCount:a,floorHeightFt:l,baseElevationFt:c,buildingHeightFt:u,buildingCentroid:i}=t;if(n==="none"||a<=0)return{features:Un([]),edgeIndex:s.index,pattern:n};switch(n){case"bands":return WV(s,a,l,c,i);case"grid":return YV(s,a,l,c,i);case"curtainwall":return XV(s,c,u,i);case"warehouse":return KV(s,c,u,i,t.warehouseWindowHeightFt,t.warehouseOffsetFromTopFt);default:return{features:Un([]),edgeIndex:s.index,pattern:n}}}function WV(t,s,n,a,l){const c=[],u=n*.4,i=n*.35,_=1.5,j=5;if(Math.max(0,t.lengthFt-j*2)<=0)return{features:Un([]),edgeIndex:t.index,pattern:"bands"};const x=t.bearingDeg,v=l?W0(t,l):(x+90)%360;for(let C=0;C<s;C++){const I=a+C*n+i,z=I+u,F=Nc(t.start,j,x),D=Nc(t.start,t.lengthFt-j,x),X=Nc(F,_,v),K=Nc(D,_,v),te=[F,D,K,X,F];c.push({type:"Feature",properties:{type:"window_band",floor:C,edgeIndex:t.index,baseHeight:I,topHeight:z,extrusionHeight:u},geometry:{type:"Polygon",coordinates:[te]}})}return{features:Un(c),edgeIndex:t.index,pattern:"bands"}}function YV(t,s,n,a,l){const c=[],j=n*.3,y=1.5,x=6,v=Math.max(0,t.lengthFt-x*2),C=Math.max(1,Math.floor(v/8));if(C<=0||v<4)return{features:Un([]),edgeIndex:t.index,pattern:"grid"};const P=t.bearingDeg,I=l?W0(t,l):(P+90)%360,z=(C-1)*8,F=x+(v-z)/2;for(let D=0;D<s;D++){const K=a+D*n+j,te=K+5;for(let J=0;J<C;J++){const H=F+J*8,O=Nc(t.start,H,P),q=4/2,W=Nc(O,q,(P+180)%360),Q=Nc(O,q,P),Z=Nc(W,y,I),oe=Nc(Q,y,I),ce=[W,Q,oe,Z,W];c.push({type:"Feature",properties:{type:"window_grid",floor:D,windowIndex:J,edgeIndex:t.index,baseHeight:K,topHeight:te,extrusionHeight:5},geometry:{type:"Polygon",coordinates:[ce]}})}}return{features:Un(c),edgeIndex:t.index,pattern:"grid"}}function XV(t,s,n,a){const l=[],i=n-s;
1958if(i<=0||t.lengthFt<=1*2)return{features:Un([]),edgeIndex:t.index,pattern:"curtainwall"};const _=t.bearingDeg,j=a?W0(t,a):(_+90)%360,y=Nc(t.start,1,_),x=Nc(t.start,t.lengthFt-1,_),v=Nc(y,2,j),C=Nc(x,2,j),P=[y,x,C,v,y];return l.push({type:"Feature",properties:{type:"curtainwall",edgeIndex:t.index,baseHeight:s,topHeight:n,extrusionHeight:i},geometry:{type:"Polygon",coordinates:[P]}}),{features:Un(l),edgeIndex:t.index,pattern:"curtainwall"}}function KV(t,s,n,a,l=4,c=3){const u=[];if(n-s<=0||t.lengthFt<=3*2)return{features:Un([]),edgeIndex:t.index,pattern:"warehouse"};const y=n-c,x=Math.max(s,y-l),v=y-x;if(v<=0)return{features:Un([]),edgeIndex:t.index,pattern:"warehouse"};const C=t.bearingDeg,P=a?W0(t,a):(C+90)%360,I=Nc(t.start,3,C),z=Nc(t.start,t.lengthFt-3,C),F=Nc(I,1.5,P),D=Nc(z,1.5,P),X=[I,z,D,F,I];return u.push({type:"Feature",properties:{type:"window_warehouse",edgeIndex:t.index,baseHeight:x,topHeight:y,extrusionHeight:v},geometry:{type:"Polygon",coordinates:[X]}}),{features:Un(u),edgeIndex:t.index,pattern:"warehouse"}}function JV(t){if(t.length<3)return t[0]||[0,0];const s=[...t];(s[0][0]!==s[s.length-1][0]||s[0][1]!==s[s.length-1][1])&&s.push(s[0]);try{const n=Xn([s]);return Yo(n).geometry.coordinates}catch{const n=t.reduce((l,c)=>l+c[0],0),a=t.reduce((l,c)=>l+c[1],0);return[n/t.length,a/t.length]}}function QV(t,s,n,a,l,c=0,u,i,_){if(s==="none"||t.length<3||a<=0)return Un([]);const j=Ec(t),y=JV(t),x=n&&n.length>0?j.filter(C=>n.includes(C.index)):j,v=[];for(const C of x){const P=ZV({edge:C,pattern:s,floorCount:a,floorHeightFt:l,baseElevationFt:c,buildingHeightFt:u,buildingCentroid:y,warehouseWindowHeightFt:i,warehouseOffsetFromTopFt:_});v.push(...P.features.features)}return Un(v)}function UV(t,s,n,a,l){const c=Kd(),u=t.window_pattern||"none";if(u==="none")return c;const i=t.height_ft;if(!i||i<=0)return c;const _=i*.3048,j=t.floor_count||1,y=t.floor_height_ft||12;if(j<1||_<=0)return c;const x=t.window_color||"#38bdf8",v=t.window_edge_indices,C=t.base_elevation_ft||0,P=QV(a,u,v,j,y,C,i,t.warehouse_window_height_ft,t.warehouse_window_offset_ft);if(P.features.length===0)return c;const I=`${s}-windows`,z=`${n}-windows`,F=u==="curtainwall"?.75:.7,D=.3048;return Ir(l.map,I,{type:"geojson",data:P},c),jr(l.map,{id:z,type:"fill-extrusion",source:I,paint:{"fill-extrusion-color":x,"fill-extrusion-height":["*",["get","topHeight"],D*l.buildingHeight],"fill-extrusion-base":["*",["get","baseHeight"],D*l.buildingHeight],"fill-extrusion-opacity":F,"fill-extrusion-vertical-gradient":u==="curtainwall"}},c),c}const Gl=.3048,Ed=1.22;function eq(t,s,n,a,l){var te;const c=Kd(),{map:u,buildingHeight:i}=l,j=(t.height_ft||0)*Gl,x=(t.base_elevation_ft||0)*Gl;let v=t.dock_count||0;const C=t.dock_height_ft||12,P=t.dock_width_ft||10,I=t.dock_spacing_ft||12,z=t.dock_depth_ft||4,F=t.dock_color||"#374151",D=t.dock_config||"single_rear",X=t.dock_edge_indices;if(t.dock_layout_mode==="maximize"&&a.length>=3)try{const J=Ec(a);let H;if(X&&X.length>0)H=X;else{const q=kg(a);H=Cg(D,q).map(W=>W.index)}let O=999;for(const q of H){const W=J[q];if(!W)continue;const Q=t.dock_end_gap_left_ft||0,Z=t.dock_end_gap_right_ft||0,oe=W.lengthFt-Q-Z,ce=P+I,ae=Math.max(1,Math.floor((oe+I)/ce));ae<O&&(O=ae)}O<999&&O>0&&(v=O)}catch{}let K=null;if(v>0&&j>0){const J=C*Gl;if(X&&X.length>0){const H=TP(a,X,v,P,I,z);K=H.features,H.reduced&&console.warn(`Docks reduced from ${H.requestedCount} to ${H.actualCount} for overlay ${t.name}`)}else K=RP(a,D,v,P,I,z);if(K.features.length>0){const H=`${s}-docks`,O=`${n}-docks`,q=t.dock_style||"steel_gray",W=q==="custom"?F||yy.steel_gray.color:((te=yy[q])==null?void 0:te.color)||yy.steel_gray.color,Q=t.dock_vertical_gradient??!0;Ir(u,H,{type:"geojson",data:K},c),jr(u,{id:O,type:"fill-extrusion",source:H,paint:{"fill-extrusion-color":W,"fill-extrusion-height":x+Ed+J,"fill-extrusion-base":x+Ed,"fill-extrusion-opacity":.9,"fill-extrusion-vertical-gradient":Q}},c);const Z=X&&X.length>0?X:(()=>{try{const ce=kg(a);return Cg(D,ce).map(ae=>ae.index)}catch{return[]}})();if(t.dock_seal_type){const ce=t.dock_seal_depth_in||18,ae=MP(K,a,ce,P,C);if(ae.features.length>0){const ie=`${s}-dock-seals`,de=`${n}-dock-seals`;Ir(u,ie,{type:"geojson",data:ae},c),jr(u,{id:de,type:"fill-extrusion",source:ie,paint:{"fill-extrusion-color":t.dock_seal_color||"#1a1a1a","fill-extrusion-height":x+Ed+J,"fill-extrusion-base":x+Ed,"fill-extrusion-opacity":.85}},c)}}if(t.dock_leveler_type){const ce=UR(K,a,6);if(ce.features.length>0){const ae=`${s}-dock-levelers`,ie=`${n}-dock-levelers`;Ir(u,ae,{type:"geojson",data:ce},c),jr(u,{id:ie,type:"fill-extrusion",source:ae,paint:{"fill-extrusion-color":t.dock_leveler_color||"#9CA3AF","fill-extrusion-height":x+Ed+.15,"fill-extrusion-base":x+Ed,"fill-extrusion-opacity":.8}},c)}}if(t.dock_bumpers_enabled){const ce=IP(K,a);if(ce.features.length>0){const ae=`${s}-dock-bumpers`,ie=`${n}-dock-bumpers`;Ir(u,ae,{type:"geojson",data:ce},c),jr(u,{id:ie,type:"fill-extrusion",source:ae,paint:{"fill-extrusion-color":t.dock_bumper_color||"#111827","fill-extrusion-height":x+Ed+.9,"fill-extrusion-base":x+Ed,"fill-extrusion-opacity":.9}},c)}}if(t.dock_restraints_enabled){const ce=eF(K,a);if(ce.features.length>0){const ae=`${s}-dock-restraints`,ie=`${n}-dock-restraints`;Ir(u,ae,{type:"geojson",data:ce},c),jr(u,{id:ie,type:"fill-extrusion",source:ae,paint:{"fill-extrusion-color":t.dock_restraint_color||"#EAB308","fill-extrusion-height":x+Ed+.15,"fill-extrusion-base":x+Ed,"fill-extrusion-opacity":.9}},c)}}if(t.dock_canopy_enabled){const ce=t.dock_canopy_depth_ft||6,ae=AP(K,a,ce,P);if(ae.features.length>0){const ie=`${s}-dock-canopies`,de=`${n}-dock-canopies`;Ir(u,ie,{type:"geojson",data:ae},c);const ge=x+Ed+J+.3,We=x+Ed+J;jr(u,{id:de,type:"fill-extrusion",source:ie,paint:{"fill-extrusion-color":t.dock_canopy_color||t.roof_color||"#6B7280","fill-extrusion-height":ge,"fill-extrusion-base":We,"fill-extrusion-opacity":.8}},c)}}if(t.dock_apron_enabled&&Z.length>0){const ce=t.dock_apron_depth_ft||70,ae=DP(a,Z,ce);
1958if(ae.features.length>0){const ie=`${s}-dock-apron`,de=`${n}-dock-apron`;Ir(u,ie,{type:"geojson",data:ae},c),jr(u,{id:de,type:"fill-extrusion",source:ie,paint:{"fill-extrusion-color":t.dock_apron_color||"#D1D5DB","fill-extrusion-height":.35*i,"fill-extrusion-base":0,"fill-extrusion-opacity":.7}},c)}}const oe=t.dock_man_door_interval||0;if(oe>0&&K.features.length>0){const ce=t.dock_man_door_width_ft||3,ae=MT(K,a,oe,ce);if(ae.features.length>0){const ie=`${s}-man-doors`,de=`${n}-man-doors`,We=(t.dock_man_door_height_ft||7)*Gl;Ir(u,ie,{type:"geojson",data:ae},c),jr(u,{id:de,type:"fill-extrusion",source:ie,paint:{"fill-extrusion-color":"#6B7280","fill-extrusion-height":x+Ed+We,"fill-extrusion-base":x+Ed,"fill-extrusion-opacity":.9}},c);const Ee=4;{const ve=IT(ae,a,Ee);if(ve.features.length>0){const we={type:"FeatureCollection",features:ve.features.filter(ke=>{var ze;return((ze=ke.properties)==null?void 0:ze.equipmentType)==="man_door_landing"})};if(we.features.length>0){const ke=`${s}-man-door-landings`,ze=`${n}-man-door-landings`;Ir(u,ke,{type:"geojson",data:we},c),jr(u,{id:ze,type:"fill-extrusion",source:ke,paint:{"fill-extrusion-color":"#7B8794","fill-extrusion-height":["+",x,["*",["get","dockHeightFt"],Gl]],"fill-extrusion-base":x,"fill-extrusion-opacity":.9}},c)}const Ze={type:"FeatureCollection",features:ve.features.filter(ke=>{var ze;return((ze=ke.properties)==null?void 0:ze.equipmentType)==="man_door_step"})};if(Ze.features.length>0){const ke=`${s}-man-door-steps`,ze=`${n}-man-door-steps`;Ir(u,ke,{type:"geojson",data:Ze},c),jr(u,{id:ze,type:"fill-extrusion",source:ke,paint:{"fill-extrusion-color":"#9CA3AF","fill-extrusion-height":["+",x,["*",["+",["get","stepHeightFt"],["get","stepRiseFt"]],Gl]],"fill-extrusion-base":x,"fill-extrusion-opacity":.85}},c)}}}}}if(t.dock_light_enabled&&K.features.length>0){const ce=t.dock_light_type||"gooseneck",ae=AT(K,a,ce);if(ae.features.length>0){const ie=`${s}-dock-lights`,de=`${n}-dock-lights`,We=(t.dock_light_height_ft||14)*Gl;Ir(u,ie,{type:"geojson",data:ae},c),jr(u,{id:de,type:"fill-extrusion",source:ie,paint:{"fill-extrusion-color":t.dock_light_color||"#FFD700","fill-extrusion-height":x+Ed+We,"fill-extrusion-base":x+Ed+We-.3,"fill-extrusion-opacity":.95}},c)}}}}if(t.trash_compactor_enabled){const J=aq(t,s,n,a,K,l);c.layerIds.push(...J.layerIds),c.sourceIds.push(...J.sourceIds)}return c}function tq(t,s,n,a,l){const c=Kd(),{map:u,buildingHeight:i}=l,j=(t.height_ft||0)*Gl,x=(t.base_elevation_ft||0)*Gl;if(!t.exhaust_fan_enabled||j<=0)return c;const v=t.exhaust_fan_count||4,C=t.exhaust_fan_size_in||48,P=t.exhaust_fan_edge_indices,I=t.exhaust_fan_spacing_mode||"even",z=t.exhaust_fan_type||"exhaust_fan",D=(t.exhaust_fan_height_ft||20)*Gl,X=t.exhaust_fan_placement||"single",K=DT(a,v,C,P,I,z,X);if(K.features.length>0){const te=`${s}-exhaust-fans`,J=`${n}-exhaust-fans`,H=z==="louver_vent"?"#A0AEC0":z==="ridge_vent"?"#718096":t.exhaust_fan_color||"#808080",O=z==="louver_vent"?.3:z==="ridge_vent"?.2:.6;Ir(u,te,{type:"geojson",data:K},c),jr(u,{id:J,type:"fill-extrusion",source:te,paint:{"fill-extrusion-color":H,"fill-extrusion-height":x+D+O,"fill-extrusion-base":x+D-O,"fill-extrusion-opacity":.85}},c)}return c}function sq(t,s,n,a,l){const c=Kd(),{map:u,buildingHeight:i}=l,j=(t.height_ft||0)*Gl,x=(t.base_elevation_ft||0)*Gl;if(!t.building_light_enabled||j<=0)return c;const v=t.building_light_spacing_ft||40,C=t.building_light_edges,P=t.building_light_corners??!0,z=(t.building_light_height_ft||12)*Gl,F=RT(a,v,C,P);if(F.features.length>0){const D=`${s}-building-lights`,X=`${n}-building-lights`;Ir(u,D,{type:"geojson",data:F},c),jr(u,{id:X,type:"fill-extrusion",source:D,paint:{"fill-extrusion-color":"#FCD34D","fill-extrusion-height":x+z+.15,"fill-extrusion-base":x+z-.15,"fill-extrusion-opacity":.9}},c)}return c}function nq(t,s,n,a,l){const c=Kd(),{map:u,buildingHeight:i}=l,j=(t.height_ft||0)*Gl,x=(t.base_elevation_ft||0)*Gl;if(!t.skylight_enabled||j<=0)return c;try{const v=t.skylight_rows||2,C=t.skylight_cols||4,P=t.skylight_width_ft||4,I=t.skylight_length_ft||8,z=t.skylight_spacing_ft||10,F=t.skylight_setback_ft||5,D=FT(a,v,C,P,I,z,F);if(D.features.length>0){const X=`${s}-skylights`,K=`${n}-skylights`,te=`${s}-skylight-curbs`,J=`${n}-skylight-curbs`,H=t.skylight_tint||"clear",O=H==="bronze"?"#C4956A"
1958:H==="gray"?"#9CA3AF":H==="white_translucent"?"#E5E7EB":"#87CEEB";Ir(u,X,{type:"geojson",data:D},c),Ir(u,te,{type:"geojson",data:D},c);const q=t.roof_type||"flat",Q=(q==="flat"||q==="parapet"?0:t.roof_height_ft||0)*Gl,Z=(x+j+Q)*i;jr(u,{id:J,type:"fill-extrusion",source:te,paint:{"fill-extrusion-color":"#4A5568","fill-extrusion-height":Z+.05,"fill-extrusion-base":Z,"fill-extrusion-opacity":.9}},c),jr(u,{id:K,type:"fill-extrusion",source:X,paint:{"fill-extrusion-color":O,"fill-extrusion-height":Z+.15,"fill-extrusion-base":Z+.05,"fill-extrusion-opacity":.4}},c)}}catch(v){console.error("[Skylights] Error rendering skylights:",v)}return c}function aq(t,s,n,a,l,c){const u=Kd(),{map:i}=c,_=(t.base_elevation_ft||0)*Gl;if(!t.trash_compactor_enabled)return u;const j=t.trash_compactor_width_ft||10,y=t.trash_compactor_depth_ft||20,x=t.trash_compactor_enclosure||"three_sided",v=t.trash_compactor_edge_index,C=t.trash_compactor_bollards??!0,P=zT(a,l,j,y,x,v,C);if(P.features.length>0){const I={type:"FeatureCollection",features:P.features.filter(D=>{var X;return((X=D.properties)==null?void 0:X.equipmentType)==="trash_compactor_pad"})};I.features.length>0&&(Ir(i,`${s}-tc-pad`,{type:"geojson",data:I},u),jr(i,{id:`${n}-tc-pad`,type:"fill-extrusion",source:`${s}-tc-pad`,paint:{"fill-extrusion-color":"#D1D5DB","fill-extrusion-height":_+.15,"fill-extrusion-base":_,"fill-extrusion-opacity":.7}},u));const z={type:"FeatureCollection",features:P.features.filter(D=>{var X;return((X=D.properties)==null?void 0:X.equipmentType)==="trash_compactor_wall"})};z.features.length>0&&(Ir(i,`${s}-tc-walls`,{type:"geojson",data:z},u),jr(i,{id:`${n}-tc-walls`,type:"fill-extrusion",source:`${s}-tc-walls`,paint:{"fill-extrusion-color":"#6B7280","fill-extrusion-height":_+2.4,"fill-extrusion-base":_,"fill-extrusion-opacity":.85}},u));const F={type:"FeatureCollection",features:P.features.filter(D=>{var X;return((X=D.properties)==null?void 0:X.equipmentType)==="trash_compactor_bollard"})};F.features.length>0&&(Ir(i,`${s}-tc-bollards`,{type:"geojson",data:F},u),jr(i,{id:`${n}-tc-bollards`,type:"fill-extrusion",source:`${s}-tc-bollards`,paint:{"fill-extrusion-color":"#EAB308","fill-extrusion-height":_+1.1,"f
1958ill-extrusion-base":_,"fill-extrusion-opacity":.9}},u))}return u}function rq(t,s,n,a,l,c){const u=Kd(),{map:i,buildingHeight:_}=c,y=(t.height_ft||0)*Gl,x=(t.base_elevation_ft||0)*Gl,v=t.drive_in_door_count||0;if(v<=0||y<=0)return u;const C=t.drive_in_door_width_ft||14,P=t.drive_in_door_height_ft||16,I=t.drive_in_door_spacing_ft||20,z=t.drive_in_door_color||"#94a3b8",F=t.drive_in_door_edge_indices,D=Pj(l,{doorCount:v,doorWidthFt:C,doorHeightFt:P,spacingFt:I,edgeIndices:F&&F.length>0?F:void 0,doorColor:z});if(D&&D.doors.length>0){const X=SP(D.doors,C,P,z),K=`${s}-drive-in-doors`,te=`${n}-drive-in-doors`,J=P*Gl;Ir(i,K,{type:"geojson",data:X},u),jr(i,{id:te,type:"fill-extrusion",source:K,paint:{"fill-extrusion-color":z,"fill-extrusion-height":(x+J)*_,"fill-extrusion-base":x*_,"fill-extrusion-opacity":.9,"fill-extrusion-vertical-gradient":!0}},u);const H=EP(D.doors,C,P);if(H.features.length>0){const O=`${s}-drive-in-frames`,q=`${n}-drive-in-frames`,W=(P+.75)*Gl;Ir(i,O,{type:"geojson",data:H},u),jr(i,{id:q,type:"fill-extrusion",source:O,paint:{"fill-extrusion-color":"#1f2937","fill-extrusion-height":(x+W)*_,"fill-extrusion-base":x*_,"fill-extrusion-opacity":.7}},u)}}return u}const Up=.3048,pC=.2;function iq(t,s,n,a,l,c){var W,Q;const u=Kd(),{map:i,buildingHeight:_}=c,y=(t.height_ft||0)*Up,x=(t.base_elevation_ft||0)*Up;if(!(t.show_canopy??!1)||y<=0)return u;const C=t.canopy_depth_ft||8,P=t.canopy_height_ft||12,I=t.canopy_color||l,z=t.canopy_edge_indices,F=t.canopy_show_pillars??C>12,D=t.canopy_pillar_spacing_ft??20,X=t.canopy_pillar_size_inches??8,K=C*Up,te=P*Up,J=D*Up,H=X/12*Up,O=[...a,a[0]],q=(Z,oe,ce,ae,ie)=>{if(!F||C<=12)return;const de=oe[0]-Z[0],ge=oe[1]-Z[1],Ee=Math.sqrt(de*de+ge*ge)*111319,ve=Math.max(2,Math.ceil(Ee/J)+1);for(let we=0;we<ve;we++){const Ze=ve===1?.5:we/(ve-1),ke=ce[0]+(ae[0]-ce[0])*Ze,ze=ce[1]+(ae[1]-ce[1])*Ze,Ke=`${s}-canopy-pillar-${ie}-${we}`,dt=`${n}-canopy-pillar-${ie}-${we}`,Re=H/2/111319,qt=[[ke-Re,ze-Re],[ke+Re,ze-Re],[ke+Re,ze+Re],[ke-Re,ze+Re],[ke-Re,ze-Re]];try{Ir(i,Ke,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[qt]},properties:{name:`${t.name} - Pillar ${ie}-${we}`}}},u),jr(i,{id:dt,type:"fill-extrusion",source:Ke,paint:{"fill-extrusion-color":"#6b7280","fill-extrusion-height":(x+te)*_,"fill-extrusion-base":0,"fill-extrusion-opacity":.9,"fill-extrusion-vertical-gradient":!1}},u)}catch{}}};if(z&&z.length>0)for(const Z of z){if(Z<0||Z>=a.length)continue;const oe=`${s}-canopy-edge-${Z}`,ce=`${n}-canopy-edge-${Z}`,ae=a[Z],ie=a[(Z+1)%a.length],de=ie[0]-ae[0],ge=ie[1]-ae[1],We=Math.sqrt(de*de+ge*ge);if(We===0)continue;const Ee=-ge/We,ve=de/We,we=K/111319,Ze=[ae[0]+Ee*we,ae[1]+ve*we],ke=[ie[0]+Ee*we,ie[1]+ve*we],ze=[ae,ie,ke,Ze,ae];try{Ir(i,oe,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[ze]},properties:{name:`${t.name} - Canopy Edge ${Z}`}}},u),jr(i,{id:ce,type:"fill-extrusion",source:oe,paint:{"fill-extrusion-color":I,"fill-extrusion-height":(x+te+pC)*_,"fill-extrusion-base":(x+te)*_,"fill-extrusion-opacity":.85,"fill-extrusion-vertical-gradient":!1}},u),q(ae,ie,Ze,ke,Z)}catch{}}else{const Z=`${s}-canopy`,oe=`${n}-canopy`;let ce=[O];try{const ae=Xn([O]),ie=dl(ae,K,{units:"meters"}),de=(W=ie==null?void 0:ie.geometry)==null?void 0:W.coordinates;((Q=de==null?void 0:de[0])==null?void 0:Q.length)>=4&&(ce=[de[0],O])}catch{ce=[]}if(ce.length>0&&(Ir(i,Z,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:ce},properties:{name:`${t.name} - Canopy`}}},u),jr(i,{id:oe,type:"fill-extrusion",source:Z,paint:{"fill-extrusion-color":I,"fill-extrusion-height":(x+te+pC)*_,"fill-extrusion-base":(x+te)*_,"fill-extrusion-opacity":.85,"fill-extrusion-vertical-gradient":!1}},u),F&&C>12))for(let ae=0;ae<a.length;ae++){const ie=a[ae],de=a[(ae+1)%a.length],ge=de[0]-ie[0],We=de[1]-ie[1],Ee=Math.sqrt(ge*ge+We*We);
1958if(Ee===0)continue;const ve=-We/Ee,we=ge/Ee,Ze=K/111319,ke=[ie[0]+ve*Ze,ie[1]+we*Ze],ze=[de[0]+ve*Ze,de[1]+we*Ze];q(ie,de,ke,ze,ae)}}return u}const Mi=.3048,gC=.3,oq=.05;function lq(t,s,n,a,l,c){if(s==="uniform")return c;const u=Math.max(n,a),i=Math.min(n,a);if(s==="center_peak"){const _=(50-l/2)/100,j=(50+l/2)/100;return t<_?i+(u-i)*(t/_):t>j?i+(u-i)*((1-t)/(1-j)):u}return s==="left_peak"?u+(i-u)*t:s==="right_peak"?i+(u-i)*t:c}function cq(t,s,n,a,l){const c=Kd(),{map:u,buildingHeight:i}=l,j=(t.height_ft||0)*Mi,y=(t.base_elevation_ft||0)*Mi;if(!(t.show_storefront??!1)||j<=0)return c;const v=t.storefront_height_ft||10,C=v*Mi,P=t.storefront_edge_indices,I=t.storefront_style||"continuous",z=t.storefront_mullion_spacing_ft||8;t.storefront_transom_height_ft;const F=t.storefront_mullion_color||"#374151",D=t.storefront_door_count||0,X=t.storefront_door_type||"none",K=t.storefront_door_placement||"center",te=t.storefront_door_color||"#1f2937",J=t.storefront_glass_color||"#38bdf8",H=X==="single"?3:X==="double"?6:X==="sliding"?8:0,O=X==="sliding"?8:7,q=t.storefront_door_width_ft||H,W=t.storefront_door_height_ft||O,Q=t.storefront_doors_only_edge_indices,Z=t.storefront_show_door_transom??!0,oe=t.storefront_edge_config||{},ce=t.storefront_coverage_start_pct??0,ae=t.storefront_coverage_end_pct??100,ie=t.storefront_height_profile??"uniform",de=t.storefront_peak_height_ft??14,ge=t.storefront_base_height_ft??8,We=t.storefront_peak_width_pct??40,Ee=dt=>{const Re=oe[String(dt)]||{};return{showTransom:Re.showTransom??Z,doorWidthFt:Re.doorWidthFt??q,doorHeightFt:Re.doorHeightFt??W,coverageStartPct:Re.coverageStartPct??ce,coverageEndPct:Re.coverageEndPct??ae,heightProfile:Re.heightProfile??ie,peakHeightFt:Re.peakHeightFt??de,baseHeightFt:Re.baseHeightFt??ge,peakWidthPct:Re.peakWidthPct??We,zones:Re.zones}},ve=z*Mi,we=P&&P.length>0?P:a.map((dt,Re)=>Re),Ze=[],ke=[],ze=[],Ke=[];for(const dt of we){if(dt<0||dt>=a.length)continue;const Re=Ee(dt),qt=Re.doorWidthFt*Mi,ft=Math.min(Re.doorHeightFt*Mi,C*.95),Fe=Re.showTransom,fe=(Q==null?void 0:Q.includes(dt))??!1,Qe=a[dt],ht=a[(dt+1)%a.length],_t=ht[0]-Qe[0],He=ht[1]-Qe[1],as=Math.sqrt(_t*_t+He*He);if(as<1e-6)continue;const vt=as*111319,Xe=-He/as,Ce=_t/as,Be=gC/111320,Dt=(gC+.05)/111320,Rt=oq/111320,zt=I==="paneled"&&!fe;if(fe){const _s=qt/111320/as,vs=[];if(X!=="none"&&D>0){if(K==="center")vs.push({t:.5,widthDeg:_s});else if(K==="left")vs.push({t:.15,widthDeg:_s});else if(K==="right")vs.push({t:.85,widthDeg:_s});else if(K==="evenly_spaced")for(let $t=0;$t<D;$t++)vs.push({t:($t+1)/(D+1),widthDeg:_s})}for(const $t of vs){const Ns=$t.widthDeg/2,Ts=[Qe[0]+_t*($t.t-Ns),Qe[1]+He*($t.t-Ns)],bs=[Qe[0]+_t*($t.t+Ns),Qe[1]+He*($t.t+Ns)],en=[Ts[0]+Xe*Dt,Ts[1]+Ce*Dt],Jt=[bs[0]+Xe*Dt,bs[1]+Ce*Dt];ze.push({type:"Feature",geometry:{type:"Polygon",coordinates:[[Ts,bs,Jt,en,Ts]]},properties:{baseHeight:y/Mi,topHeight:(y+ft)/Mi}}),Fe&&ft<C-.1&&Ze.push({type:"Feature",geometry:{type:"Polygon",coordinates:[[Ts,bs,Jt,en,Ts]]},properties:{baseHeight:(y+ft)/Mi,topHeight:(y+C)/Mi}})}continue}const rs=Re.zones&&Re.zones.length>0?Re.zones:[{startPct:Re.coverageStartPct,endPct:Re.coverageEndPct,heightProfile:Re.heightProfile,peakHeightFt:Re.peakHeightFt,baseHeightFt:Re.baseHeightFt,peakWidthPct:Re.peakWidthPct,doorType:X,doorCount:D,doorPlacement:K}];for(const _s of rs){const vs=Math.max(0,Math.min(1,(_s.startPct??0)/100)),$t=Math.max(0,Math.min(1,(_s.endPct??100)/100));if(vs>=$t)continue;const Ns=_s.heightProfile??Re.heightProfile,Ts=_s.peakHeightFt??Re.peakHeightFt,bs=_s.baseHeightFt??Re.baseHeightFt,en=_s.peakWidthPct??Re.peakWidthPct,Jt=_s.doorType??X,Vs=_s.doorCount??D,ps=_s.doorPlacement??K,nt=Is=>{const tn=$t>vs?(Is-vs)/($t-vs):0;return lq(tn,Ns,Ts,bs,en,v)},ts=[];if(Jt!=="none"&&Vs>0){const Is=qt/111320/as,tn=(vs+$t)/2,wn=$t-vs;if(ps==="center")ts.push({t:tn,widthDeg:Is});else if(ps==="left")ts.push({t:vs+wn*.15,widthDeg:Is});else if(ps==="right")ts.push({t:vs+wn*.85,widthDeg:Is});else if(ps==="evenly_spaced")for(let Gs=0;Gs<Vs;Gs++){const Ue=vs+wn*((Gs+1)/(Vs+1));ts.push({t:Ue,widthDeg:Is})}}const ds=(Is,tn,wn)=>{const Gs=[Qe[0]+_t*Is,Qe[1]+He*Is],Ue=[Qe[0]+_t*tn,Qe[1]+He*tn],Pe=ts.find(je=>je.t>=Is&&je.t<=tn);if(Pe){const je=Pe.widthDeg/2;if(Pe.t-je>Is){const pe=Gs,wt=[Qe[0]+_t*(Pe.t-je),Qe[1]+He*(Pe.t-je)],Zt=[pe[0]+Xe*Be,pe[1]+Ce*Be],ys=[wt[0]+Xe*Be,wt[1]+Ce*Be];Ze.push({type:"Feature",geometry:{type:"Polygon",coordinates:[[pe,wt,ys,Zt,pe]]},properties:{baseHeight:y/Mi,topHeight:(y+wn)/Mi}})}if(Pe.t+je<tn){const pe=[Qe[0]+_t*(Pe.t+je),Qe[1]+He*(Pe.t+je)],wt=Ue,Zt=[pe[0]+Xe*Be,pe[1]+Ce*Be],ys=[wt[0]+Xe*Be,wt[1]+Ce*Be];Ze.push({type:"Feature",geometry:{type:"Polygon",coordinates:[[pe,wt,ys,Zt,pe]]},properties:{baseHeight:y/Mi,topHeight:(y+wn)/Mi}})}const Ge=[Qe[0]+_t*(Pe.t-je),Qe[1]+He*(Pe.t-je)],De=[Qe[0]+_t*(Pe.t+je),Qe[1]+He*(Pe.t+je)],bt=[Ge[0]+Xe*Dt,Ge[1]+Ce*Dt],Ct=[De[0]+Xe*Dt,De[1]+Ce*Dt];ze.push({type:"Feature",geometry:{type:"Polygon",coordinates:[[Ge,De,Ct,bt,Ge]]},properties:{baseHeight:y/Mi,topHeight:(y+ft)/Mi}}),Fe&&ft<wn-.1&&Ze.push({type:"Feature",geometry:{type:"Polygon",coordinates:[[Ge,De,Ct,bt,Ge]]},properties:{baseHeight:(y+ft)/Mi,topHeight:(y+wn)/Mi}})}else{const je=[Gs[0]+Xe*Be,Gs[1]+Ce*Be],Ge=[Ue[0]+Xe*Be,Ue[1]+Ce*Be];Ze.push({type:"Feature",geometry:{type:"Polygon",coordinates:[[Gs,Ue,Ge,je,Gs]]},properties:{baseHeight:y/Mi,topHeight:(y+wn)/Mi}})}};if(zt&&ve>0){const Is=qt*1.1,tn=Math.max(ve,Is),wn=($t-vs)*vt,Gs=Math.max(1,Math.ceil(wn/tn));for(let Ue=0;Ue<Gs;Ue++){const Pe=vs+($t-vs)*(Ue/Gs),je=vs+($t-vs)*((Ue+1)/Gs),Ge=(Pe+je)/2,De=nt(Ge)*Mi;if(ds(Pe,je,De),Ue>0){const bt=Pe,Ct=nt(bt)*Mi,pe=[Qe[0]+_t*bt-He/as*Rt/2,Qe[1]+He*bt+_t/as*Rt/2],wt=[Qe[0]+_t*bt+He/as*Rt/2,Qe[1]+He*bt-_t/as*Rt/2],Zt=[pe[0]+Xe*Be*1.2,pe[1]+Ce*Be*1.2],ys=[wt[0]+Xe*Be*1.2,wt[1]+Ce*Be*1.2];ke.push({type:"Feature",geometry:{type:"Polygon",coordinates:[[pe,wt,ys,Zt,pe]]},properties:{baseHeight:y/Mi,topHeight:(y+Ct)/Mi}})}}}else{const tn=Ns!=="uniform"?10:1;for(let wn=0;wn<tn;wn++){const Gs=vs+($t-vs)*(wn/tn),Ue=vs+($t-vs)*((wn+1)/tn),Pe=(Gs+Ue)/2,je=nt(Pe)*Mi;ds(Gs,Ue,je)}}}}return Ze.length>0&&(Ir(u,`${s}-storefront`,{type:"geojson",data:{type:"FeatureCollection",features:Ze}},c),jr(u,{id:`${n}-storefront`,type:"fill-extrusion",source:`${s}-storefront`,paint:{"fill-extrusion-color":J,"fill-extrusion-height":["*",["get","to
1958pHeight"],Mi*i],"fill-extrusion-base":["*",["get","baseHeight"],Mi*i],"fill-extrusion-opacity":.7,"fill-extrusion-vertical-gradient":!0}},c)),ke.length>0&&(Ir(u,`${s}-storefront-mullions`,{type:"geojson",data:{type:"FeatureCollection",features:ke}},c),jr(u,{id:`${n}-storefront-mullions`,type:"fill-extrusion",source:`${s}-storefront-mullions`,paint:{"fill-extrusion-color":F,"fill-extrusion-height":["*",["get","topHeight"],Mi*i],"fill-extrusion-base":["*",["get","baseHeight"],Mi*i],"fill-extrusion-opacity":.95,"fill-extrusion-vertical-gradient":!1}},c)),ze.length>0&&(Ir(u,`${s}-storefront-doors`,{type:"geojson",data:{type:"FeatureCollection",features:ze}},c),jr(u,{id:`${n}-storefront-doors`,type:"fill-extrusion",source:`${s}-storefront-doors`,paint:{"fill-extrusion-color":te,"fill-extrusion-height":["*",["get","topHeight"],Mi*i],"fill-extrusion-base":["*",["get","baseHeight"],Mi*i],"fill-extrusion-opacity":.9,"fill-extrusion-vertical-gradient":!1}},c)),Ke.length>0&&(Ir(u,`${s}-storefront-transoms`,{type:"geojson",data:{type:"FeatureCollection",features:Ke}},c),jr(u,{id:`${n}-storefront-transoms`,type:"fill-extrusion",source:`${s}-storefront-transoms`,paint:{"fill-extrusion-color":F,"fill-extrusion-height":["*",["get","topHeight"],Mi*i],"fill-extrusion-base":["*",["get","baseHeight"],Mi*i],"fill-extrusion-opacity":.95,"fill-extrusion-vertical-gradient":!1}},c)),c}const ZT=3280.84,yb=2.5,vb=2;function g1(t,s){return gi(us(t),us(s),{units:"kilometers"})*ZT}function Au(t,s,n){const a=s/ZT;return On(us(t),a,n,{units:"kilometers"}).geometry.coordinates}function dq(t){if(t.length<3)return t;const s=t[0],n=t[t.length-1];return s[0]===n[0]&&s[1]===n[1]?t.slice(0,-1):t}function uq(t){const s=[...t];s.length>=3&&s.push(s[0]);try{const n=Xn([s]);return Yo(n).geometry.coordinates}catch{const n=t.reduce((l,c)=>l+c[0],0),a=t.reduce((l,c)=>l+c[1],0);return[n/t.length,a/t.length]}}function hq(t,s,n){const a=(s+90)%360,l=(s-90+360)%360,c=Au(t,10,a),u=Au(t,10,l),i=g1(c,n),_=g1(u,n);return i>_?a:l}function mq(t,s,n=0){if(!t||t.length<3||!s||s.length===0)return{type:"FeatureCollection",features:[]};const a=t.map(i=>[i.lng,i.lat]),l=dq(a);if(l.length<3)return{type:"FeatureCollection",features:[]};const c=uq(l),u=[];for(const i of s){const _=i.edge_index??0,j=Math.min(Math.max(0,_),l.length-1),y=l[j],x=l[(j+1)%l.length],v=(Or(us(y),us(x))+360)%360,C=g1(y,x),P=Math.min(Math.max(1,i.width_ft),Math.max(1,C-vb*2));if(C<3)continue;const I=i.edge_position_t??.5,z=P/2,F=vb+z,D=C-vb-z,X=I*C,K=Math.max(F,Math.min(D,X)),te=Au(y,K,v),J=hq(te,v,c),H=Au(te,P/2,(v+180)%360),O=Au(te,P/2,v),q=Au(H,yb,J),W=Au(O,yb,J),Q=[H,O,W,q,H],Z=n+(i.mounting_height_ft||0),oe=Z+Math.max(.1,i.height_ft||0);if(i.type!=="wall_logo"&&u.push({type:"Feature",geometry:{type:"Polygon",coordinates:[Q]},properties:{signId:i.id,signName:i.name,signType:i.type,baseHeight:Z,topHeight:oe,color:i.background_color,letterColor:i.letter_color,illuminated:i.illuminated,edgeIndex:j,logoId:i.logo_id,logoUrl:i.logo_url,logoName:i.logo_name,isLogoFace:!1}}),(i.type==="box_sign"||i.type==="wall_logo")&&i.logo_url){const ce=P*.9,ae=Math.max(.1,(i.height_ft||0)*.9),ie=i.type==="wall_logo"?.15:yb+.1,de=Au(te,ce/2,(v+180)%360),ge=Au(te,ce/2,v),We=Au(de,ie,J),Ee=Au(ge,ie,J),ve=.1,we=Au(de,ie-ve,J),Ze=Au(ge,ie-ve,J),ke=[We,Ee,Ze,we,We],ze=Z+.25,Ke=ze+ae;u.push({type:"Feature",geometry:{type:"Polygon",coordinates:[ke]},properties:{signId:`${i.id}-logo`,signName:i.logo_name||"Logo",signType:"logo_face",baseHeight:ze,topHeight:Ke,color:i.letter_color,letterColor:i.letter_color,illuminated:i.illuminated,edgeIndex:j,logoId:i.logo_id,logoUrl:i.logo_url,logoName:i.logo_name,isLogoFace:!0,outwardBearingDeg:J,logoWidthFt:ce,logoHeightFt:ae,centerLng:(We[0]+Ee[0])/2,centerLat:(We[1]+Ee[1])/2}})}}return{type:"FeatureCollection",features:u}}const lg=.3048,fq=t=>(t.building_buffer_thickness_in||8)/12*.3048;function pq(t,s,n,a,l){var P;const c=Kd(),{map:u,buildingHeight:i}=a,_=((P=t.style)==null?void 0:P.building_signs)||[];if(_.length===0)return c;const j=t.base_elevation_ft||0,y=mq(t.geometry,_,j);if(y.features.length===0)return c;const x=y.features.filter(I=>{var z;return!((z=I.properties)!=null&&z.isLogoFace)}),v=y.features.filter(I=>{var z;return(z=I.properties)==null?void 0:z.isLogoFace}),C=fq(t)*i;
1958if(x.length>0){const I=`${s}-signage`,z=`${n}-signage`;Ir(u,I,{type:"geojson",data:{type:"FeatureCollection",features:x}},c),jr(u,{id:z,type:"fill-extrusion",source:I,paint:{"fill-extrusion-color":["get","color"],"fill-extrusion-height":["+",["*",["get","topHeight"],lg*i],C],"fill-extrusion-base":["+",["*",["get","baseHeight"],lg*i],C],"fill-extrusion-opacity":.95,"fill-extrusion-vertical-gradient":!1}},c)}if(v.length>0){const I=`${s}-signage-logos`,z=`${n}-signage-logo`;Ir(u,I,{type:"geojson",data:{type:"FeatureCollection",features:v}},c),jr(u,{id:z,type:"fill-extrusion",source:I,paint:{"fill-extrusion-color":"#ffffff","fill-extrusion-height":["+",["*",["get","topHeight"],lg*i],C],"fill-extrusion-base":["+",["*",["get","baseHeight"],lg*i],C],"fill-extrusion-opacity":1,"fill-extrusion-vertical-gradient":!1}},c),br(async()=>{const{addSignageLogosToMap:F}=await import("./signageLogoRenderer-BfZvTPj_.js");return{addSignageLogosToMap:F}},__vite__mapDeps([32,33,1,2,12,4,5,11,8,10,13,3,6,9,15,16,17,20,14,21,22,19,23,24,25,18,26,27,28])).then(({addSignageLogosToMap:F})=>{F(u,n,v,i,C).then(D=>{l&&l(D)})})}return c}function gq(t,s,n,a,l){const c=Kd(),{map:u,buildingHeight:i}=a;if(!t.show_column_grid||n.length<3)return c;const _=t.height_ft||0,j=(t.base_elevation_ft||0)*lg,y={bayWidthFt:t.column_bay_width_ft||50,bayDepthFt:t.column_bay_depth_ft||50,columnSizeInches:t.column_size_inches||24,offsetFrontFt:t.column_offset_front_ft??4,offsetRearFt:t.column_offset_rear_ft??4,offsetSide1Ft:t.column_offset_side1_ft??4,offsetSide2Ft:t.column_offset_side2_ft??4,frontEdgeIndex:t.column_grid_front_edge??null,extraLinesX:t.column_extra_lines_x??0,extraLinesY:t.column_extra_lines_y??0},x=t.column_line_overrides;if(x!=null&&x.x){y.lineOverridesX={};for(const[P,I]of Object.entries(x.x))y.lineOverridesX[Number(P)]=I}if(x!=null&&x.y){y.lineOverridesY={};for(const[P,I]of Object.entries(x.y))y.lineOverridesY[Number(P)]=I}const v=t.geometry,C=Ej(v,y);if(C&&C.columns.length>0){const P=t.floor_count||1;br(async()=>{const{addColumnGrid3D:I}=await import("./columnGrid3DRenderer-DB5Ueeni.js");return{addColumnGrid3D:I}},__vite__mapDeps([34,33,1,2,12,4,5,11,8,10,13,3,6,9,15,16,17,20,14,21,22,19,23,24,25,18,26,27,28])).then(({addColumnGrid3D:I})=>{const z=I(u,s,C.columns,y.columnSizeInches,_,C.bearingDeg,P,j/lg,i);l&&l([z])})}return c}function xq(t,s,n,a,l,c,u,i,_){const j=[],y=[],x=C=>{j.push(...C.layerIds),y.push(...C.sourceIds)};x(UV(t,s,n,l,i)),x(eq(t,s,n,l,i)),x(rq(t,s,n,l,c,i)),x(tq(t,s,n,l,i)),x(sq(t,s,n,l,i)),x(nq(t,s,n,l,i));const v=HT(t,u);return x(iq(t,s,n,l,v,i)),x(cq(t,s,n,l,i)),x(pq(t,s,n,i,_)),x(gq(t,a,l,i,_)),{layerIds:j,sourceIds:y}}const _q=new Set(["site","site_boundary","assemblage","property_outline","parcel_assembly","legal_line","lot_line","lot"]),yq=new Set(["parking","parking_field","parking_zone","parking_bay","stormwater","landscaping","drive_aisle","truck_court","sidewalk"]),WT=t=>_q.has(t||""),YT=t=>yq.has(t||""),xC=.15,vq=.35,bq=t=>t&&(t==="parking"||t==="parking_zone"||t==="parking_field")?vq:xC;function jq(t,s,n,a,l){const c=Kd(),u=s.layer_type;return WT(u)?t.getLayer(a)||(t.addLayer({id:a,type:"fill",source:n,paint:{"fill-color":l.fillColor||l.color||"#3b82f6","fill-opacity":l.fillOpacity??.2}}),c.layerIds.push(a)):YT(u)?(u==="stormwater"&&BT(s)?wq(t,s,n,a,l,c):t.getLayer(a)||(t.addLayer({id:a,type:"fill-extrusion",source:n,paint:{"fill-extrusion-color":u==="parking"||u==="parking_field"||u==="parking_zone"?"#4a5568":l.fillColor||l.color||"#64748b","fill-extrusion-height":bq(s.layer_type),"fill-extrusion-base":0,"fill-extrusion-opacity":l.fillOpacity??.5,"fill-extrusion-vertical-gradient":!1}}),c.layerIds.push(a)),u==="truck_court"&&Cq(t,s,n,a,c)):t.getLayer(a)||(t.addLayer({id:a,type:"fill",source:n,paint:{"fill-color":l.fillColor||l.color||"#3b82f6","fill-opacity":l.fillOpacity??.2}}),c.layerIds.push(a)),c}function wq(t,s,n,a,l,c){const u=s.geometry,i=$T(s),_=VT(s);if(u&&Array.isArray(u)&&u.length>=3){const j=OT(u,i,_);j.length>0?(Nq(t,u,n,a,_,c),j.forEach((y,x)=>{const v=`${n}-depth-ring-${x}`,C=`${a}-depth-ring-${x}`,P=y.geometry.map(I=>[I.lng,I.lat]);P.push(P[0]),t.addSource(v,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[P]},properties:{}}}
1958),t.addLayer({id:C,type:"fill",source:v,paint:{"fill-color":y.color,"fill-opacity":y.opacity}}),c.layerIds.push(C),c.sourceIds.push(v)})):_C(t,n,a,l,c)}else _C(t,n,a,l,c);if(GT(s)){const j=Yj(s);j&&u&&Array.isArray(u)&&u.length>=3&&kq(t,u,s,n,a,j,c)}}function Nq(t,s,n,a,l,c){const u=`${n}-rim`,i=`${a}-rim`;try{const _=s.map(x=>[x.lng,x.lat]);_.push(_[0]);const j=Xn([_]),y=dl(j,-1,{units:"meters"});y&&y.geometry&&(t.addSource(u,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[_,...y.geometry.type==="Polygon"?[y.geometry.coordinates[0]]:[]]},properties:{}}}),t.addLayer({id:i,type:"fill-extrusion",source:u,paint:{"fill-extrusion-color":l,"fill-extrusion-height":.3,"fill-extrusion-base":0,"fill-extrusion-opacity":.7,"fill-extrusion-vertical-gradient":!1}}),c.layerIds.push(i),c.sourceIds.push(u))}catch(_){console.warn("Failed to create basin rim:",_)}}function _C(t,s,n,a,l){t.getLayer(n)||(t.addLayer({id:n,type:"fill-extrusion",source:s,paint:{"fill-extrusion-color":a.fillColor||a.color||"#64748b","fill-extrusion-height":.15,"fill-extrusion-base":0,"fill-extrusion-opacity":a.fillOpacity??.5,"fill-extrusion-vertical-gradient":!1}}),l.layerIds.push(n))}function kq(t,s,n,a,l,c,u){const i=qT(s,c,c.buffer_ft||5);if(i.segments.forEach((_,j)=>{if(_.geometry.length<2)return;const y=`${a}-fence-${j}`,x=`${l}-fence-${j}`;try{const v=_.geometry.map(I=>[I.lng,I.lat]);v.push(v[0]);const C=Yd(v.slice(0,-1)),P=dl(C,.05,{units:"meters"});P&&P.geometry&&(t.addSource(y,{type:"geojson",data:{type:"Feature",geometry:P.geometry,properties:{}}}),t.addLayer({id:x,type:"fill-extrusion",source:y,paint:{"fill-extrusion-color":_.color,"fill-extrusion-height":_.heightMeters,"fill-extrusion-base":0,"fill-extrusion-opacity":.85,"fill-extrusion-vertical-gradient":!0}}),u.layerIds.push(x),u.sourceIds.push(y))}catch(v){console.warn("Failed to render stormwater fence segment:",v)}}),i.posts.forEach((_,j)=>{const y=`${a}-fence-post-${j}`,x=`${l}-fence-post-${j}`;try{const v=us([_.position.lng,_.position.lat]),C=dl(v,.05,{units:"meters"});C&&C.geometry&&(t.addSource(y,{type:"geojson",data:{type:"Feature",geometry:C.geometry,properties:{}}}),t.addLayer({id:x,type:"fill-extrusion",source:y,paint:{"fill-extrusion-color":_.color,"fill-extrusion-height":_.heightMeters,"fill-extrusion-base":0,"fill-extrusion-opacity":1,"fill-extrusion-vertical-gradient":!1}}),u.layerIds.push(x),u.sourceIds.push(y))}catch{}}),i.barbedWire.forEach((_,j)=>{if(_.geometry.length<2)return;const y=`${a}-barbed-wire-${j}`,x=`${l}-barbed-wire-${j}`;try{const v=_.geometry.map(I=>[I.lng,I.lat]);v.push(v[0]);const C=Yd(v.slice(0,-1)),P=dl(C,.03,{units:"meters"});P&&P.geometry&&(t.addSource(y,{type:"geojson",data:{type:"Feature",geometry:P.geometry,properties:{}}}),t.addLayer({id:x,type:"fill-extrusion",source:y,paint:{"fill-extrusion-color":_.color,"fill-extrusion-height":_.heightMeters+.3,"fill-extrusion-base":_.heightMeters-.15,"fill-extrusion-opacity":.9,"fill-extrusion-vertical-gradient":!1}}),u.layerIds.push(x),u.sourceIds.push(y))}catch{}}),i.bufferZone&&s.length>=3){const _=`${a}-buffer-zone`,j=`${l}-buffer-zone`;try{const y=i.bufferZone.geometry.map(P=>[P.lng,P.lat]);y.push(y[0]);const x=s.map(P=>[P.lng,P.lat]);x.push(x[0]);const v=[...x].reverse(),C={type:"Polygon",coordinates:[y,v]};t.addSource(_,{type:"geojson",data:{type:"Feature",geometry:C,properties:{}}}),t.addLayer({id:j,type:"fill-extrusion",source:_,paint:{"fill-extrusion-color":i.bufferZone.color,"fill-extrusion-height":.4,"fill-extrusion-base":.35,"fill-extrusion-opacity":.9,"fill-extrusion-vertical-gradient":!1}}),u.layerIds.push(j),u.sourceIds.push(_)}catch(y){console.warn("Failed to render stormwater buffer zone:",y)}}}function Cq(t,s,n,a,l){const c=s.style,u=c==null?void 0:c.trailerSpots;if(!u||u.length===0)return;const i=(c==null?void 0:c.trailerFillColor)||"#64748b",_=.35;for(const j of u){const y=`${n}-trailer-spot-${j.index}`,x=`${a}-trailer-spot-${j.index}`,v=j.polygon.map(([C,P])=>[C,P]);v.push(v[0]);try{t.getSource(y)||t.addSource(y,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[v]},properties:{}}}),t.addLayer({id:x,type:"fill-extrusion",source:y,paint:{"fill-extrusion-color":i,"fill-extrusion-height":.05,"fill-extrusion-base":0,"fill-extrusion-opacity":_,"fill-extrusion-vertical-gradient":!1}}),l.layerIds.push(x),l.sourceIds.push(y)}catch{}}}const lo=.35,Sq={standard:"#ffffff",ada:"#3b82f6",van_accessible:"#3b82f6",reserved:"#8b5cf6",ev_charging:"#22c55e",compact:"#eab308",motorcycle:"#f97316",loading_zone:"#78716c",no_parking:"#fbbf24"},yC={landscape:{color:"#4ade80",height:.44,baseOffset:.42,borderColor:"#6b7280",borderHeight:.45},painted:{color:"#d1d5db",height:lo+.01,baseOffset:lo},bushes:{color:"#166534",height:lo+1.2,baseOffset:lo},rock:{color:"#78716c",height:lo+.3,baseOffset:lo},mulch:{color:"#92400e",height:lo+.15,baseOffset:lo},planter_box:{color:"#4ade80",height:.44,baseOffset:.42,borderColor:"#9ca3af",borderHeight:.5}};function Eq(t,s,n,a,l,c,u){var H;
1958if(l.length<3||s.parking_striping_visible===!1)return;const i=l.map(([O,q])=>({lat:q,lng:O})),_=g_(s),j=p_({parkingOverlay:s,allOverlays:c,settings:_}),y=[...j.zones,...j.stallOnlyZones],x=s.style||{},v=x.parking_max_stall_run||void 0,C=x.parking_island_type||"painted",P=x.parking_island_width_ft||(C==="landscape"?6:4),I=x.parking_island_trees===!0,z=x.parking_island_cross_aisle!==!1,F={stallWidth_ft:s.parking_stall_width_ft||9,stallDepth_ft:s.parking_stall_depth_ft||18,aisleWidth_ft:s.parking_aisle_width_ft||24,layoutType:s.parking_layout_type||"double_loaded",stripingVisible:!0,aisleLabelsVisible:s.parking_aisle_labels_visible!==!1,exclusionZones:y,maxStallRun:v,islandType:C,islandWidth_ft:P,islandTrees:I,islandCrossAisle:z,islandTreeSpecies:x.parking_island_tree_species||"deciduous",islandTreeHeight_ft:x.parking_island_tree_height_ft||30,islandCanopyDiameter_ft:x.parking_island_canopy_diameter_ft||15,islandCustomModelId:x.parking_island_custom_model_id||void 0,islandCustomModelUrl:x.parking_island_custom_model_url||void 0};let D=Hm(i,F);const X=(H=s.style)==null?void 0:H.parkingCirculation,K=X==null?void 0:X.stallOverrides,te=X==null?void 0:X.rowOverrides;(K&&Object.keys(K).length>0||te&&Object.keys(te).length>0)&&(D=H0(D,K||{},te)),Pq(t,D,n,a,te,u);const J=D.stalls.filter(O=>!O.isRemoved);Tq(t,J,n,a,u),Lq(t,J,n,a,u),Mq(t,J,n,a,u),Iq(t,D,n,a,u)}function Pq(t,s,n,a,l,c){if(s.stripingLines.length===0)return;const u=.12,i=lo+.002,_=i+.02,j=`${n}-parking-stripes`,y=`${a}-parking-stripes`,x=s.stripingLines.filter(C=>{var P;if(!(C.type==="row_edge"||C.type==="aisle_edge"))return!1;if(C.type==="row_edge"){const I=String(C.id).split("-"),z=I[2]??"0",F=I[3]??"top",D=`row-${z}-${F}`,X=(P=l==null?void 0:l[D])==null?void 0:P.edges;if((X==null?void 0:X.back)===!1)return!1}return!0}).flatMap(C=>{try{const P=Yd([[C.start.lng,C.start.lat],[C.end.lng,C.end.lat]]),I=dl(P,u,{units:"meters"});return I!=null&&I.geometry?[{type:"Feature",geometry:I.geometry,properties:{id:C.id,type:C.type,isDashed:!0}}]:[]}catch{return[]}});if(x.length===0)return;t.addSource(j,{type:"geojson",data:{type:"FeatureCollection",features:x}}),t.addLayer({id:y,type:"fill-extrusion",source:j,filter:["==",["get","isDashed"],!1],paint:{"fill-extrusion-color":"#ffffff","fill-extrusion-height":_,"fill-extrusion-base":i,"fill-extrusion-opacity":.9,"fill-extrusion-vertical-gradient":!1}});const v=`${a}-parking-stripes-dashed`;t.addLayer({id:v,type:"fill-extrusion",source:j,filter:["==",["get","isDashed"],!0],paint:{"fill-extrusion-color":"#ffffff","fill-extrusion-height":_,"fill-extrusion-base":i,"fill-extrusion-opacity":.65,"fill-extrusion-vertical-gradient":!1}}),c([y,v,j])}function Tq(t,s,n,a,l){const c={};s.forEach(j=>{const y=j.renderType||(j.isAda?"ada":"standard"),x=j.customColor||Sq[y]||"#ffffff";c[x]||(c[x]=[]),c[x].push(j)});const u=.08,i=lo+.005,_=i+.02;Object.entries(c).forEach(([j,y],x)=>{const v=`${n}-parking-stalls-edges-${x}`,C=`${a}-parking-stalls-edges-${x}`,P=y.flatMap(I=>uP(I).flatMap((F,D)=>{try{const X=Yd([[F.start.lng,F.start.lat],[F.end.lng,F.end.lat]]),K=dl(X,u,{units:"meters"});return K!=null&&K.geometry?[{type:"Feature",geometry:K.geometry,properties:{id:`${I.id}-edge-${D}`}}]:[]}catch{return[]}}));P.length>0&&(t.addSource(v,{type:"geojson",data:{type:"FeatureCollection",features:P}}),t.addLayer({id:C,type:"fill-extrusion",source:v,paint:{"fill-extrusion-color":j,"fill-extrusion-height":_,"fill-extrusion-base":i,"fill-extrusion-opacity":1,"fill-extrusion-vertical-gradient":!1}}),l([C,v]))})}function Lq(t,s,n,a,l){const c=lo+.01,u=c+.03,i=s.filter(x=>{const v=x.renderType||(x.isAda?"ada":"standard");return v==="ada"||v==="van_accessible"});if(i.length>0){const x=`${n}-ada-symbols`,v=`${a}-ada-symbols`,C=i.map(P=>({type:"Feature",geometry:{type:"Point",coordinates:[jf(P.geometry).lng,jf(P.geometry).lat]},properties:{id:P.id}}));t.addSource(x,{type:"geojson",data:{type:"FeatureCollection",features:C}}),t.addLayer({id:v,type:"circle",source:x,paint:{"circle-radius":6,"circle-color":"#ffffff","circle-stroke-color":"#3b82f6","circle-stroke-width":2,"circle-opacity":.9}}),l([v,x])}const _=s.filter(x=>x.renderType==="reserved");if(_.length>0){const x=`${n}-reserved-labels`,v=`${a}-reserved-labels`,C=_.map((P,I)=>({type:"Feature",geometry:{type:"Point",coordinates:[jf(P.geometry).lng,jf(P.geometry).lat]},properties:{id:P.id,label:P.displayLabel||String(I+1)}}));t.addSource(x,{type:"geojson",data:{type:"FeatureCollection",features:C}}),t.addLayer({id:v,type:"symbol",source:x,layout:{"text-field":["get","label"],"text-size":12,"text-font":["Open Sans Bold"]},paint:{"text-color":"#ffffff","text-halo-color":"#8b5cf6","text-halo-width":2}}),l([v,x])}const j=s.filter(x=>x.renderType==="ev_charging");if(j.length>0){const x=`${n}-ev-pillars`,v=`${a}-ev-pillars`,C=j.flatMap(P=>{const I=cP(P),z=3e-6;return[{type:"Feature",geometry:{type:"Polygon",coordinates:[[[I.lng-z,I.lat-z],[I.lng+z,I.lat-z],[I.lng+z,I.lat+z],[I.lng-z,I.lat+z],[I.lng-z,I.lat-z]]]},properties:{id:P.id}}]});t.addSource(x,{type:"geojson",data:{type:"FeatureCollection",features:C}}),t.addLayer({id:v,type:"fill-extrusion",source:x,paint:{"fill-extrusion-color":"#22c55e","fill-extrusion-height":lo+1.2,"fill-extrusion-base":lo,"fill-extrusion-opacity":1}}),l([v,x])}const y=s.filter(x=>x.hasHatching||x.renderType==="loading_zone"||x.renderType==="no_parking");if(y.length>0){const x=`${n}-hatching`,v=`${a}-hatching`,C=.06,P=y.flatMap(I=>{const z=G0(I.geometry,4),D=(I.renderType||"loading_zone")==="no_parking"?"#fbbf24":"#78716c";return z.flatMap(X=>{try{const K=Yd([[X.start.lng,X.start.lat],[X.end.lng,X.end.lat]]),te=dl(K,C,{units:"meters"});return te!=null&&te.geometry?[{type:"Feature",geometry:te.geometry,properties:{color:D}}]:[]}catch{return[]}})});P.length>0&&(t.addSource(x,{type:"geojson",data:{type:"FeatureCollection",features:P}}),t.addLayer({id:v,type:"fill-extrusion",source:x,paint:{"fill-extrusion-color":["get","color"],"fill-extrusion-height":u,"fill-extrusion-base":c,"fill-extrusion-opacity":.8}}),l([v,x]))}}function Mq(t,s,n,a,l){const c=s.filter(j=>j.renderType==="island");if(c.length===0)return;const u=`${n}-island-stalls`,i=`${a}-island-stalls`,_={};
1958c.forEach(j=>{const y=j.islandFinish||"landscape";_[y]||(_[y]=[]),_[y].push(j)}),Object.entries(_).forEach(([j,y])=>{const x=yC[j]||yC.landscape,v=y.map(F=>({type:"Feature",geometry:{type:"Polygon",coordinates:[[...F.geometry.map(D=>[D.lng,D.lat]),[F.geometry[0].lng,F.geometry[0].lat]]]},properties:{id:F.id}}));if(x.borderColor){const F=`${u}-${j}-border`,D=`${i}-${j}-border`;t.addSource(F,{type:"geojson",data:{type:"FeatureCollection",features:v}}),t.addLayer({id:D,type:"fill-extrusion",source:F,paint:{"fill-extrusion-color":x.borderColor,"fill-extrusion-height":lo+(x.borderHeight||.45),"fill-extrusion-base":lo,"fill-extrusion-opacity":.9}}),l([D,F])}const C=`${u}-${j}-fill`,P=`${i}-${j}-fill`,I=x.borderColor?lo+x.height:x.height,z=x.borderColor?lo+x.baseOffset:x.baseOffset;if(t.addSource(C,{type:"geojson",data:{type:"FeatureCollection",features:v}}),t.addLayer({id:P,type:"fill-extrusion",source:C,paint:{"fill-extrusion-color":x.color,"fill-extrusion-height":I,"fill-extrusion-base":z,"fill-extrusion-opacity":.85}}),l([P,C]),j==="painted"){const F=`${u}-painted-hatch`,D=`${i}-painted-hatch`,X=y.flatMap(K=>G0(K.geometry,4).flatMap(J=>{try{const H=Yd([[J.start.lng,J.start.lat],[J.end.lng,J.end.lat]]),O=dl(H,.06,{units:"meters"});return O!=null&&O.geometry?[{type:"Feature",geometry:O.geometry,properties:{}}]:[]}catch{return[]}}));X.length>0&&(t.addSource(F,{type:"geojson",data:{type:"FeatureCollection",features:X}}),t.addLayer({id:D,type:"fill-extrusion",source:F,paint:{"fill-extrusion-color":"#9ca3af","fill-extrusion-height":lo+.015,"fill-extrusion-base":lo+.01,"fill-extrusion-opacity":.7}}),l([D,F]))}if((j==="landscape"||j==="planter_box")&&y.some(F=>F.islandTreeEnabled)){const F=y.filter(J=>J.islandTreeEnabled),D=`${u}-${j}-trees`,X=`${i}-${j}-trees`,K=`${u}-${j}-trunks`,te=`${i}-${j}-trunks`;br(async()=>{const{getTreeColor:J}=await Promise.resolve().then(()=>Tg);return{getTreeColor:J}},void 0).then(({getTreeColor:J})=>{const H=F.map(O=>{const q=jf(O.geometry),W=O.islandTreeSpecies||"deciduous",Q=J(W);return{type:"Feature",geometry:{type:"Point",coordinates:[q.lng,q.lat]},properties:{color:Q,radius:10}}});H.length>0&&t.getSource(D)===void 0&&(t.addSource(D,{type:"geojson",data:{type:"FeatureCollection",features:H}}),t.addSource(K,{type:"geojson",data:{type:"FeatureCollection",features:H}}),t.addLayer({id:te,type:"circle",source:K,paint:{"circle-radius":3,"circle-color":"#78350f","circle-opacity":.9}}),t.addLayer({id:X,type:"circle",source:D,paint:{"circle-radius":["get","radius"],"circle-color":["get","color"],"circle-stroke-color":"#166534","circle-stroke-width":1.5,"circle-opacity":.8,"circle-blur":.3}}),l([X,D,te,K]))})}})}function Iq(t,s,n,a,l){if(s.islands.length===0)return;const c=`${n}-parking-islands`,u=`${a}-parking-islands`,i=s.islands.filter(j=>j.type==="painted"),_=s.islands.filter(j=>j.type==="landscape");if(i.length>0){const j=`${c}-painted`,y=`${u}-painted`,x=i.map(I=>({type:"Feature",geometry:{type:"Polygon",coordinates:[[...I.geometry.map(z=>[z.lng,z.lat]),[I.geometry[0].lng,I.geometry[0].lat]]]},properties:{id:I.id}}));t.addSource(j,{type:"geojson",data:{type:"FeatureCollection",features:x}}),t.addLayer({id:y,type:"fill-extrusion",source:j,paint:{"fill-extrusion-color":"#d1d5db","fill-extrusion-height":lo+.01,"fill-extrusion-base":lo,"fill-extrusion-opacity":.9,"fill-extrusion-vertical-gradient":!1}}),l([y,j]);const v=`${c}-painted-hatch`,C=`${u}-painted-hatch`,P=i.flatMap(I=>G0(I.geometry,5).flatMap(F=>{try{const D=Yd([[F.start.lng,F.start.lat],[F.end.lng,F.end.lat]]),X=dl(D,.06,{units:"meters"});return X!=null&&X.geometry?[{type:"Feature",geometry:X.geometry,properties:{}}]:[]}catch{return[]}}));P.length>0&&(t.addSource(v,{type:"geojson",data:{type:"FeatureCollection",features:P}}),t.addLayer({id:C,type:"fill-extrusion",source:v,paint:{"fill-extrusion-color":"#9ca3af","fill-extrusion-height":lo+.015,"fill-extrusion-base":lo+.01,"fill-extrusion-opacity":.7,"fill-extrusion-vertical-gradient":!1}}),l([C,v]))}if(_.length>0){const j=_.map(F=>({type:"Feature",geometry:{type:"Polygon",coordinates:[[...F.geometry.map(D=>[D.lng,D.lat]),[F.geometry[0].lng,F.geometry[0].lat]]]},properties:{id:F.id}})),y=`${c}-landscape-curb`,x=`${u}-landscape-curb`;t.addSource(y,{type:"geojson",data:{type:"FeatureCollection",features:j}}),t.addLayer({id:x,type:"fill-extrusion",source:y,paint:{"fill-extrusion-color":"#6b7280","fill-extrusion-height":lo+.45,"fill-extrusion-base":lo,"fill-extrusion-opacity":.9,"fill-extrusion-vertical-gradient":!1}}),l([x,y]);const v=`${c}-landscape-mulch`,C=`${u}-landscape-mulch`;t.addSource(v,{type:"geojson",data:{type:"FeatureCollection",features:j}}),t.addLayer({id:C,type:"fill-extrusion",source:v,paint:{"fill-extrusion-color":"#78716c","fill-extrusion-height":lo+.42,"fill-extrusion-base":lo+.4,"fill-extrusion-opacity":.85,"fill-extrusion-vertical-gradient":!1}}),l([C,v]);const P=`${c}-landscape`,I=`${u}-landscape`;t.addSource(P,{type:"geojson",data:{type:"FeatureCollection",features:j}}),t.addLayer({id:I,type:"fill-extrusion",source:P,paint:{"fill-extrusion-color":"#4ade80","fill-extrusion-height":lo+.44,"fill-extrusion-base":lo+.42,"fill-extrusion-opacity":.8,"fill-extrusion-vertical-gradient":!1}}),l([I,P]);const z=_.filter(F=>F.hasTree);z.length>0&&br(async()=>{const{getTreeColor:F}=await Promise.resolve().then(()=>Tg);return{getTreeColor:F}},void 0).then(({getTreeColor:F})=>{const D=`${c}-trees`,X=`${u}-trees`,K=`${c}-trunks`,te=`${u}-trunks`,J=z.map(H=>{const O=H.treeSpecies||"deciduous",q=F(O),W=H.canopyDiameter_ft||15,Q=Math.max(6,Math.min(20,W/2));return{type:"Feature",geometry:{type:"Point",coordinates:[H.centerPosition.lng,H.centerPosition.lat]}
1958,properties:{id:H.id,color:q,radius:Q,species:O}}});t.getSource(D)||(t.addSource(D,{type:"geojson",data:{type:"FeatureCollection",features:J}}),t.addSource(K,{type:"geojson",data:{type:"FeatureCollection",features:J}}),t.addLayer({id:te,type:"circle",source:K,paint:{"circle-radius":3,"circle-color":"#78350f","circle-opacity":.9}}),t.addLayer({id:X,type:"circle",source:D,paint:{"circle-radius":["get","radius"],"circle-color":["get","color"],"circle-stroke-color":"#166534","circle-stroke-width":1.5,"circle-opacity":.8,"circle-blur":.3}}),l([X,D,te,K]))})}}function XT(t){switch(t){case"perimeter_screen":return"#166534";case"setback_landscape":return"#86efac";case"tree_line":return"#15803d";case"bioswale":return"#38bdf8";default:return"#86efac"}}function KT(t){switch(t){case"sparse":return .3;case"moderate":return .5;case"dense":return .7;default:return .5}}function vC(t,s,n){const a=s/3280.84,l=On(us([t.lng,t.lat]),a,n,{units:"kilometers"});return{lat:l.geometry.coordinates[1],lng:l.geometry.coordinates[0]}}function Aq(t,s){return Or(us([t.lng,t.lat]),us([s.lng,s.lat]))}function JT(t,s,n,a,l,c){const i=(Aq(t,s)+90)%360,_=t,j=s,y=vC(s,n,i),x=vC(t,n,i);return{coordinates:[_,j,y,x,_],edgeLabel:a,type:l,width_ft:n,density:c}}function QT(t,s,n){const a=[];return!t||t.length<3||n.forEach(l=>{const c=s[l.label];if(!(c!=null&&c.enabled))return;const u=l.edgeIndex,i=(l.edgeIndex+1)%t.length,_=t[u],j=t[i];if(!_||!j)return;const y=JT(_,j,c.width_ft||20,l.label,c.type||"perimeter_screen",c.density||"moderate");a.push(y)}),a}const Dq=Object.freeze(Object.defineProperty({__proto__:null,generateAllBufferPolygons:QT,generateEdgeBufferPolygon:JT,getBufferDensityOpacity:KT,getBufferTypeColor:XT},Symbol.toStringTag,{value:"Module"})),xy=(t,s)=>{const n=parseInt(t.slice(1,3),16),a=parseInt(t.slice(3,5),16),l=parseInt(t.slice(5,7),16),c=Math.min(255,Math.max(0,Math.round(n*s))),u=Math.min(255,Math.max(0,Math.round(a*s))),i=Math.min(255,Math.max(0,Math.round(l*s)));return`#${c.toString(16).padStart(2,"0")}${u.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`};function Rq(t,s,n,a,l,c){var i;const u=(i=s.style)==null?void 0:i.landscapeBuffers;if(!(!u||l.length<3))try{const _=l.map(([v,C])=>({lat:C,lng:v})),j=mu(_);QT(_,u,j).filter(v=>v.type!=="setback_landscape").forEach((v,C)=>{const P=`${n}-landscape-buffer-${C}`,I=`${a}-landscape-buffer-${C}`,z=v.coordinates.map(te=>[te.lng,te.lat]);t.addSource(P,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[z]},properties:{type:v.type,edgeLabel:v.edgeLabel}}});const F=XT(v.type),D=KT(v.density);let X=.15,K=.05;switch(v.type){case"perimeter_screen":X=2.5,K=0;break;case"tree_line":X=.15,K=.05;break;case"bioswale":X=.25,K=.1;break}t.addLayer({id:I,type:"fill-extrusion",source:P,paint:{"fill-extrusion-color":F,"fill-extrusion-height":X+K,"fill-extrusion-base":K,"fill-extrusion-opacity":D+.2,"fill-extrusion-vertical-gradient":v.type==="perimeter_screen"}}),c([I,P])})}catch(_){console.warn("Failed to render landscape buffers in 3D:",_)}}function Fq(t,s,n,a,l,c,u,i){var y;const _=(y=s.style)==null?void 0:y.landscapeBuffers;!_||l.length<3||!Object.values(_).some(x=>(x==null?void 0:x.enabled)&&(x==null?void 0:x.type)==="tree_line")||Promise.all([br(()=>Promise.resolve().then(()=>Tg),void 0),br(()=>Promise.resolve().then(()=>f_),void 0),br(()=>import("./tree3DModelRenderer-DA0T29pn.js"),__vite__mapDeps([36,33,1,2,12,4,5,11,8,10,13,3,6,9,15,16,17,20,14,21,22,19,23,24,25,18,26,27,28])),br(()=>Promise.resolve().then(()=>lp),void 0)]).then(([x,v,C,P])=>{var ge,We;const{generateAllTreePositions:I,getTreeColor:z,filterTreesAwayFromEntryRoads:F}=x,{classifyEdgesForSetbackLabels:D}=v,{addTree3DModelsToMap:X,isCustom3DTree:K,getTreeModelUrl:te}=C,{generateAllEntryPointPolygons:J}=P,H=l.map(([Ee,ve])=>({lat:ve,lng:Ee})),O=D(H),q=(ge=s.style)==null?void 0:ge.parkingCirculation,W=q==null?void 0:q.entryPoints;let Q;if(s.parent_overlay_id){const Ee=c.find(ve=>ve.id===s.parent_overlay_id);Ee!=null&&Ee.geometry&&Array.isArray(Ee.geometry)&&Ee.geometry.length>=3&&(Q=Ee.geometry)}const Z=W&&W.length>0?J(W,H,40,Q):[],oe=(We=s.style)==null?void 0:We.treeModifications;let ce=I(H,_,O,void 0,oe?{deletedTreeIds:oe.deletedTreeIds||[],addedTrees:oe.addedTrees||[]}:void 0);if(Z.length>0&&(ce=F(ce,Z)),ce.length===0)return;const ae=`${n}-trees`;if(t.getSource(ae))return;const ie=[],de=[];if(ce.forEach(Ee=>{const ve=_[Ee.edgeLabel]||{};K(ve)?ie.push(Ee):de.push(Ee)}),ie.length>0){const Ee={};ie.forEach(we=>{const Ze=_[we.edgeLabel]||{},ke=te(Ze);ke&&(Ee[ke]||(Ee[ke]={trees:[],config:Ze}),Ee[ke].trees.push(we))});let ve=0;Object.entries(Ee).forEach(([we,{trees:Ze,config:ke}])=>{const ze=`${a}-custom-3d-trees-${ve}`,Ke=(ke==null?void 0:ke.tree_height_ft)||25;X(t,ze,Ze,{modelUrl:we,heightFt:Ke*u,scale:1,rotation:0}).then(dt=>{i(dt)}).catch(dt=>{console.warn("Failed to render custom 3D trees:",dt)}),ve++})}de.length>0&&zq(t,de,_,n,a,ae,u,z,i)}).catch(x=>{console.warn(`Failed to render trees for ${s.name}:`,x)})}function zq(t,s,n,a,l,c,u,i,_){const x=F=>{const D=Math.sin(F*12.9898+78.233)*43758.5453;return D-Math.floor(D)},v=[],C=[];
1958s.forEach((F,D)=>{const X=n[F.edgeLabel]||{},K=(X==null?void 0:X.tree_species)||"deciduous",te=(X==null?void 0:X.canopy_diameter_ft)||15,J=(X==null?void 0:X.tree_height_ft)||25,H=i(K),q=.85+x(D*1e3)*.3,W=te/2*.3048*q,Q=J*.3048*q,Z=Q*.35,oe=Q-Z,ae=.25*q/111319,ie=[];for(let de=0;de<=8;de++){const ge=de/8*2*Math.PI,We=1+(x(D*100+de)*.1-.05);ie.push([F.lng+ae*We*Math.cos(ge),F.lat+ae*We*Math.sin(ge)])}C.push({type:"Feature",geometry:{type:"Polygon",coordinates:[ie]},properties:{index:D,heightMeters:Z*u,baseMeters:0}});for(let de=0;de<10;de++){const ge=de/9;let We,Ee=H;if(K==="evergreen")We=1-ge*.88,Ee=xy(H,.85+ge*.2);else if(K==="palm")We=.2+ge*.8,Ee=xy(H,1+ge*.15);else if(K==="shrub"){const Re=ge-.4;We=Math.max(.4,1.05-Re*Re*1.5),Ee=xy(H,.88+ge*.18)}else{const Re=ge-.35;We=Math.max(.25,1.1-Re*Re*2.2),Ee=xy(H,.82+ge*.25)}const ve=.92+x(D*1e3+de*50)*.16,Ze=W*We*ve/111319,ke=Z+oe*(de/10),ze=Z+oe*((de+1)/10),Ke=12+Math.floor(x(D*500+de)*4),dt=[];for(let Re=0;Re<=Ke;Re++){const qt=Re/Ke*2*Math.PI,ft=.88+x(D*200+de*30+Re)*.24,Fe=Ze*ft,fe=x(D*333)*Math.PI*2,Qe=qt+fe;dt.push([F.lng+Fe*Math.cos(Qe),F.lat+Fe*Math.sin(Qe)])}v.push({type:"Feature",geometry:{type:"Polygon",coordinates:[dt]},properties:{index:D,layer:de,species:K,color:Ee,heightMeters:ze*u,baseMeters:ke*u}})}});const P=`${a}-tree-trunks`,I=`${l}-tree-trunks`;t.addSource(P,{type:"geojson",data:{type:"FeatureCollection",features:C}}),t.addLayer({id:I,type:"fill-extrusion",source:P,paint:{"fill-extrusion-color":"#5D4037","fill-extrusion-height":["get","heightMeters"],"fill-extrusion-base":["get","baseMeters"],"fill-extrusion-opacity":.95,"fill-extrusion-vertical-gradient":!0}});const z=`${l}-trees`;t.addSource(c,{type:"geojson",data:{type:"FeatureCollection",features:v}}),t.addLayer({id:z,type:"fill-extrusion",source:c,paint:{"fill-extrusion-color":["get","color"],"fill-extrusion-height":["get","heightMeters"],"fill-extrusion-base":["get","baseMeters"],"fill-extrusion-opacity":.88,"fill-extrusion-vertical-gradient":!1}}),_([z,c,I,P])}const Oq=.35;function Bq(t,s,n,a,l){var te,J,H,O,q;const c=s.setback_geometry,u=oo(s.layer_type)||rm(s.layer_type)||bf(s.layer_type);if(!c||!u||!c.features)return;const i=(te=s.style)==null?void 0:te.landscapeBuffers,_=i&&Object.values(i).some(W=>(W==null?void 0:W.enabled)&&(W==null?void 0:W.type)==="setback_landscape"),j=_?"#86efac":"#f97316",y=_?.08:.3,x=_?.6:.35,v=c.features.find(W=>{var Q;return((Q=W.properties)==null?void 0:Q.setbackType)==="combined-setback-zone"});if(!((J=v==null?void 0:v.geometry)!=null&&J.coordinates))return;const C=v.geometry.coordinates,P=C[0],I=C[1],z=`${n}-setback-zone`,F=`${a}-setback-zone`;t.addSource(z,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:(I==null?void 0:I.length)>=3?[P,I]:[P]},properties:{}}}),t.addLayer({id:F,type:"fill-extrusion",source:z,paint:{"fill-extrusion-color":j,"fill-extrusion-height":y,"fill-extrusion-base":0,"fill-extrusion-opacity":x,"fill-extrusion-vertical-gradient":!1}});const D=[F,z],X=c.features.find(W=>{var Q;return((Q=W.properties)==null?void 0:Q.setbackType)==="buildable-area"});let K=null;if((O=(H=X==null?void 0:X.geometry)==null?void 0:H.coordinates)!=null&&O[0]?K=X.geometry.coordinates[0]:(I==null?void 0:I.length)>=3&&(K=I),K&&K.length>=3){const W=`${n}-buildable-outline`,Q=`${a}-buildable-outline`,Z=K[0],oe=K[K.length-1],ae=Z[0]!==oe[0]||Z[1]!==oe[1]?[...K,Z]:K;t.addSource(W,{type:"geojson",data:{type:"Feature",geometry:{type:"LineString",coordinates:ae},properties:{}}});const ie=((q=s.style)==null?void 0:q.setbackLineStyle)||"dashed",de=ie==="hidden";t.addLayer({id:Q,type:"line",source:W,paint:{"line-color":"#22c55e","line-width":de?0:3,"line-dasharray":ie==="dashed"?[4,2]:[1,0],"line-opacity":de?0:.9}}),D.push(Q,W)}l(D)}function $q(t,s,n,a,l,c){var v;const u=(v=s.style)==null?void 0:v.parkingCirculation,i=u==null?void 0:u.entryPoints;if(!Array.isArray(i)||i.length===0||n.length<3)return;const _=n.map(([C,P])=>({lat:P,lng:C}));let j;if(s.parent_overlay_id){const C=a.find(P=>P.id===s.parent_overlay_id);C!=null&&C.geometry&&Array.isArray(C.geometry)&&C.geometry.length>=3&&(j=C.geometry)}const y=Lj(i,_,40,j),x=[];
1958y.forEach(C=>{const P=`entry-road-${C.id}-${s.id}`,I=`entry-road-layer-${C.id}-${s.id}`,z=oT(C.type),F=C.coordinates.map(D=>[D.lng,D.lat]);t.getSource(P)||(t.addSource(P,{type:"geojson",data:{type:"Feature",properties:{id:C.id,name:C.name,type:C.type,typeLabel:Vq(C.type),width_ft:C.width_ft,depth_ft:C.depth_ft,has_gate:C.has_gate,color:z},geometry:{type:"Polygon",coordinates:[F]}}}),t.addLayer({id:I,type:"fill-extrusion",source:P,paint:{"fill-extrusion-color":"#4a5568","fill-extrusion-height":Oq,"fill-extrusion-base":0,"fill-extrusion-opacity":.95}}),c&&t.on("click",I,D=>{var X,K;(X=D.features)!=null&&X[0]&&(c(s.id,C.id),(K=D.originalEvent)==null||K.stopPropagation())}),t.on("mouseenter",I,()=>{t.getCanvas().style.cursor="pointer"}),t.on("mouseleave",I,()=>{t.getCanvas().style.cursor=""}),x.push(P,I))}),l(x)}function Vq(t){switch(t){case"main_entry":return"Main Entry";case"service_entry":return"Service Entry";case"emergency_access":return"Emergency Access";case"fire_lane":return"Fire Lane";default:return"Access Point"}}const bC=.3048;function qq(t,s,n,a){var P;const l=(P=s.style)==null?void 0:P.monument_signs;if(!Array.isArray(l)||l.length===0||n.length<3)return;const c=n.map(([I,z])=>({lat:z,lng:I})),u=s.base_elevation_ft||0,i=E8(c,l,u);if(i.features.length===0)return;const _=[],j=i.features.filter(I=>{var z;return((z=I.properties)==null?void 0:z.featureType)==="support"}),y=i.features.filter(I=>{var z;return((z=I.properties)==null?void 0:z.featureType)==="connector"}),x=i.features.filter(I=>{var z;return((z=I.properties)==null?void 0:z.featureType)==="placard"}),v=i.features.filter(I=>{var z;return((z=I.properties)==null?void 0:z.featureType)==="logo_face"}),C=(I,z,F,D)=>{if(z.length===0)return;const X=`pylon-${I}-${s.id}`,K=`pylon-${I}-layer-${s.id}`;t.addSource(X,{type:"geojson",data:{type:"FeatureCollection",features:z}}),t.addLayer({id:K,type:"fill-extrusion",source:X,paint:{"fill-extrusion-color":F,"fill-extrusion-height":["*",["get","topHeight"],bC],"fill-extrusion-base":["*",["get","baseHeight"],bC],"fill-extrusion-opacity":D,"fill-extrusion-vertical-gradient":!1}}),_.push(K,X)};C("support",j,["get","color"],.95),C("connector",y,["get","color"],.95),C("placard",x,["get","color"],.98),C("logos",v,"#ffffff",1),v.length>0&&br(async()=>{const{addPylonLogosToMap:I}=await import("./pylonLogoRenderer-uqbojm-r.js");return{addPylonLogosToMap:I}},__vite__mapDeps([37,33,1,2,12,4,5,11,8,10,13,3,6,9,15,16,17,20,14,21,22,19,23,24,25,18,26,27,28])).then(({addPylonLogosToMap:I})=>{I(t,`pylon-${s.id}`,v,1).then(z=>{a(z)})}),a(_)}var UT={exports:{}};/**
1959 * MapLibre GL JS
1960 * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v4.7.1/LICENSE.txt
1961 */(function(t,s){(function(n,a){t.exports=a()})(Fm,function(){var n={},a={};function l(u,i,_){if(a[u]=_,u==="index"){var j="var sharedModule = {}; ("+a.shared+")(sharedModule); ("+a.worker+")(sharedModule);",y={};return a.shared(y),a.index(n,y),typeof window<"u"&&n.setWorkerUrl(window.URL.createObjectURL(new Blob([j],{type:"text/javascript"}))),n}}l("shared",["exports"],function(u){function i(d,o,m,b){return new(m||(m=Promise))(function(T,$){function V(me){try{ne(b.next(me))}catch(ye){$(ye)}}function U(me){try{ne(b.throw(me))}catch(ye){$(ye)}}function ne(me){var ye;me.done?T(me.value):(ye=me.value,ye instanceof m?ye:new m(function(Te){Te(ye)})).then(V,U)}ne((b=b.apply(d,o||[])).next())})}function _(d){return d&&d.__esModule&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d}typeof SuppressedError=="function"&&SuppressedError;var j=y;function y(d,o){this.x=d,this.y=o}y.prototype={clone:function(){return new y(this.x,this.y)},add:function(d){return this.clone()._add(d)},sub:function(d){return this.clone()._sub(d)},multByPoint:function(d){return this.clone()._multByPoint(d)},divByPoint:function(d){return this.clone()._divByPoint(d)},mult:function(d){return this.clone()._mult(d)},div:function(d){return this.clone()._div(d)},rotate:function(d){return this.clone()._rotate(d)},rotateAround:function(d,o){return this.clone()._rotateAround(d,o)},matMult:function(d){return this.clone()._matMult(d)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(d){return this.x===d.x&&this.y===d.y},dist:function(d){return Math.sqrt(this.distSqr(d))},distSqr:function(d){var o=d.x-this.x,m=d.y-this.y;return o*o+m*m},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(d){return Math.atan2(this.y-d.y,this.x-d.x)},angleWith:function(d){return this.angleWithSep(d.x,d.y)},angleWithSep:function(d,o){return Math.atan2(this.x*o-this.y*d,this.x*d+this.y*o)},_matMult:function(d){var o=d[2]*this.x+d[3]*this.y;
1961return this.x=d[0]*this.x+d[1]*this.y,this.y=o,this},_add:function(d){return this.x+=d.x,this.y+=d.y,this},_sub:function(d){return this.x-=d.x,this.y-=d.y,this},_mult:function(d){return this.x*=d,this.y*=d,this},_div:function(d){return this.x/=d,this.y/=d,this},_multByPoint:function(d){return this.x*=d.x,this.y*=d.y,this},_divByPoint:function(d){return this.x/=d.x,this.y/=d.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var d=this.y;return this.y=this.x,this.x=-d,this},_rotate:function(d){var o=Math.cos(d),m=Math.sin(d),b=m*this.x+o*this.y;return this.x=o*this.x-m*this.y,this.y=b,this},_rotateAround:function(d,o){var m=Math.cos(d),b=Math.sin(d),T=o.y+b*(this.x-o.x)+m*(this.y-o.y);return this.x=o.x+m*(this.x-o.x)-b*(this.y-o.y),this.y=T,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},y.convert=function(d){return d instanceof y?d:Array.isArray(d)?new y(d[0],d[1]):d};var x=_(j),v=C;function C(d,o,m,b){this.cx=3*d,this.bx=3*(m-d)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*o,this.by=3*(b-o)-this.cy,this.ay=1-this.cy-this.by,this.p1x=d,this.p1y=o,this.p2x=m,this.p2y=b}C.prototype={sampleCurveX:function(d){return((this.ax*d+this.bx)*d+this.cx)*d},sampleCurveY:function(d){return((this.ay*d+this.by)*d+this.cy)*d},sampleCurveDerivativeX:function(d){return(3*this.ax*d+2*this.bx)*d+this.cx},solveCurveX:function(d,o){if(o===void 0&&(o=1e-6),d<0)return 0;if(d>1)return 1;for(var m=d,b=0;b<8;b++){var T=this.sampleCurveX(m)-d;if(Math.abs(T)<o)return m;var $=this.sampleCurveDerivativeX(m);if(Math.abs($)<1e-6)break;m-=T/$}var V=0,U=1;for(m=d,b=0;b<20&&(T=this.sampleCurveX(m),!(Math.abs(T-d)<o));b++)d>T?V=m:U=m,m=.5*(U-V)+V;return m},solve:function(d,o){return this.sampleCurveY(this.solveCurveX(d,o))}};var P=_(v);let I,z;function F(){return I==null&&(I=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),I}function D(){if(z==null&&(z=!1,F())){const o=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(o){for(let b=0;b<5*5;b++){const T=4*b;o.fillStyle=`rgb(${T},${T+1},${T+2})`,o.fillRect(b%5,Math.floor(b/5),1,1)}const m=o.getImageData(0,0,5,5).data;for(let b=0;b<5*5*4;b++)if(b%4!=3&&m[b]!==b){z=!0;break}}}return z||!1}function X(d,o,m,b){const T=new P(d,o,m,b);return $=>T.solve($)}const K=X(.25,.1,.25,1);function te(d,o,m){return Math.min(m,Math.max(o,d))}function J(d,o,m){const b=m-o,T=((d-o)%b+b)%b+o;return T===o?m:T}function H(d,...o){for(const m of o)for(const b in m)d[b]=m[b];return d}let O=1;function q(d,o,m){const b={};for(const T in d)b[T]=o.call(this,d[T],T,d);return b}function W(d,o,m){const b={};for(const T in d)o.call(this,d[T],T,d)&&(b[T]=d[T]);return b}function Q(d){return Array.isArray(d)?d.map(Q):typeof d=="object"&&d?q(d,Q):d}const Z={};function oe(d){Z[d]||(typeof console<"u"&&console.warn(d),Z[d]=!0)}function ce(d,o,m){return(m.y-d.y)*(o.x-d.x)>(o.y-d.y)*(m.x-d.x)}function ae(d){return typeof WorkerGlobalScope<"u"&&d!==void 0&&d instanceof WorkerGlobalScope}let ie=null;function de(d){return typeof ImageBitmap<"u"&&d instanceof ImageBitmap}const ge="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function We(d,o,m,b,T){return i(this,void 0,void 0,function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const $=new VideoFrame(d,{timestamp:0});try{const V=$==null?void 0:$.format;if(!V||!V.startsWith("BGR")&&!V.startsWith("RGB"))throw new Error(`Unrecognized format ${V}`);const U=V.startsWith("BGR"),ne=new Uint8ClampedArray(b*T*4);if(yield $.copyTo(ne,function(me,ye,Te,$e,Ye){const et=4*Math.max(-ye,0),mt=(Math.max(0,Te)-Te)*$e*4+et,Tt=4*$e,Ot=Math.max(0,ye),gs=Math.max(0,Te);return{rect:{x:Ot,y:gs,width:Math.min(me.width,ye+$e)-Ot,height:Math.min(me.height,Te+Ye)-gs},layout:[{offset:mt,stride:Tt}]}}(d,o,m,b,T)),U)for(let me=0;me<ne.length;me+=4){const ye=ne[me];ne[me]=ne[me+2],ne[me+2]=ye}return ne}finally{$.close()}})}let Ee,ve;const we="AbortError";function Ze(){return new Error(we)}const ke={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ze(d){return ke.REGISTERED_PROTOCOLS[d.substring(0,d.indexOf("://"))]}
vendor: 4,117 bytes, line 1961
1961const Ke="global-dispatcher";class dt extends Error{constructor(o,m,b,T){super(`AJAXError: ${m} (${o}): ${b}`),this.status=o,this.statusText=m,this.url=b,this.body=T}}const Re=()=>ae(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,qt=function(d,o){if(/:\/\//.test(d.url)&&!/^https?:|^file:/.test(d.url)){const b=ze(d.url);if(b)return b(d,o);if(ae(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:d,targetMapId:Ke},o)}if(!(/^file:/.test(m=d.url)||/^file:/.test(Re())&&!/^\w+:/.test(m))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(b,T){return i(this,void 0,void 0,function*(){const $=new Request(b.url,{method:b.method||"GET",body:b.body,credentials:b.credentials,headers:b.headers,cache:b.cache,referrer:Re(),signal:T.signal});b.type!=="json"||$.headers.has("Accept")||$.headers.set("Accept","application/json");const V=yield fetch($);if(!V.ok){const me=yield V.blob();throw new dt(V.status,V.statusText,b.url,me)}let U;U=b.type==="arrayBuffer"||b.type==="image"?V.arrayBuffer():b.type==="json"?V.json():V.text();const ne=yield U;if(T.signal.aborted)throw Ze();return{data:ne,cacheControl:V.headers.get("Cache-Control"),expires:V.headers.get("Expires")}})}(d,o);if(ae(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:d,mustQueue:!0,targetMapId:Ke},o)}var m;return function(b,T){return new Promise(($,V)=>{var U;const ne=new XMLHttpRequest;ne.open(b.method||"GET",b.url,!0),b.type!=="arrayBuffer"&&b.type!=="image"||(ne.responseType="arraybuffer");for(const me in b.headers)ne.setRequestHeader(me,b.headers[me]);b.type==="json"&&(ne.responseType="text",!((U=b.headers)===null||U===void 0)&&U.Accept||ne.setRequestHeader("Accept","application/json")),ne.withCredentials=b.credentials==="include",ne.onerror=()=>{V(new Error(ne.statusText))},ne.onload=()=>{if(!T.signal.aborted)if((ne.status>=200&&ne.status<300||ne.status===0)&&ne.response!==null){let me=ne.response;if(b.type==="json")try{me=JSON.parse(ne.response)}catch(ye){return void V(ye)}$({data:me,cacheControl:ne.getResponseHeader("Cache-Control"),expires:ne.getResponseHeader("Expires")})}else{const me=new Blob([ne.response],{type:ne.getResponseHeader("Content-Type")});V(new dt(ne.status,ne.statusText,b.url,me))}},T.signal.addEventListener("abort",()=>{ne.abort(),V(Ze())}),ne.send(b.body)})}(d,o)};function ft(d){if(!d||d.indexOf("://")<=0||d.indexOf("data:image/")===0||d.indexOf("blob:")===0)return!0;const o=new URL(d),m=window.location;return o.protocol===m.protocol&&o.host===m.host}function Fe(d,o,m){m[d]&&m[d].indexOf(o)!==-1||(m[d]=m[d]||[],m[d].push(o))}function fe(d,o,m){if(m&&m[d]){const b=m[d].indexOf(o);b!==-1&&m[d].splice(b,1)}}class Qe{constructor(o,m={}){H(this,m),this.type=o}}class ht extends Qe{constructor(o,m={}){super("error",H({error:o},m))}}class _t{on(o,m){return this._listeners=this._listeners||{},Fe(o,m,this._listeners),this}off(o,m){return fe(o,m,this._listeners),fe(o,m,this._oneTimeListeners),this}once(o,m){return m?(this._oneTimeListeners=this._oneTimeListeners||{},Fe(o,m,this._oneTimeListeners),this):new Promise(b=>this.once(o,b))}fire(o,m){typeof o=="string"&&(o=new Qe(o,m||{}));const b=o.type;if(this.listens(b)){o.target=this;const T=this._listeners&&this._listeners[b]?this._listeners[b].slice():[];for(const U of T)U.call(this,o);const $=this._oneTimeListeners&&this._oneTimeListeners[b]?this._oneTimeListeners[b].slice():[];for(const U of $)fe(b,U,this._oneTimeListeners),U.call(this,o);const V=this._eventedParent;V&&(H(o,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),V.fire(o))}else o instanceof ht&&console.error(o.error);return this}listens(o){return this._listeners&&this._listeners[o]&&this._listeners[o].length>0||this._oneTimeListeners&&this._oneTimeListeners[o]&&this._oneTimeListeners[o].length>0||this._eventedParent&&this._eventedParent.listens(o)}setEventedParent(o,m){return this._eventedParent=o,this._eventedParentData=m,this}}
vendor: 3,743 bytes, line 1961
1961var He={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade
vendor: 8,509 bytes, line 1961
1961","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}
vendor: 8,873 bytes, line 1961
1961,"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"enum",default:"mercator",values:{mercator:{},globe:{}}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}
vendor: 9,830 bytes, line 1961
1961,"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const 
vendor: 6,689 bytes, line 1961
1961as=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function vt(d,o){const m={};for(const b in d)b!=="ref"&&(m[b]=d[b]);return as.forEach(b=>{b in o&&(m[b]=o[b])}),m}function Xe(d,o){if(Array.isArray(d)){if(!Array.isArray(o)||d.length!==o.length)return!1;for(let m=0;m<d.length;m++)if(!Xe(d[m],o[m]))return!1;return!0}if(typeof d=="object"&&d!==null&&o!==null){if(typeof o!="object"||Object.keys(d).length!==Object.keys(o).length)return!1;for(const m in d)if(!Xe(d[m],o[m]))return!1;return!0}return d===o}function Ce(d,o){d.push(o)}function Be(d,o,m){Ce(m,{command:"addSource",args:[d,o[d]]})}function Dt(d,o,m){Ce(o,{command:"removeSource",args:[d]}),m[d]=!0}function Rt(d,o,m,b){Dt(d,m,b),Be(d,o,m)}function zt(d,o,m){let b;for(b in d[m])if(Object.prototype.hasOwnProperty.call(d[m],b)&&b!=="data"&&!Xe(d[m][b],o[m][b]))return!1;for(b in o[m])if(Object.prototype.hasOwnProperty.call(o[m],b)&&b!=="data"&&!Xe(d[m][b],o[m][b]))return!1;return!0}function rs(d,o,m,b,T,$){d=d||{},o=o||{};for(const V in d)Object.prototype.hasOwnProperty.call(d,V)&&(Xe(d[V],o[V])||m.push({command:$,args:[b,V,o[V],T]}));for(const V in o)Object.prototype.hasOwnProperty.call(o,V)&&!Object.prototype.hasOwnProperty.call(d,V)&&(Xe(d[V],o[V])||m.push({command:$,args:[b,V,o[V],T]}))}function _s(d){return d.id}function vs(d,o){return d[o.id]=o,d}class $t{constructor(o,m,b,T){this.message=(o?`${o}: `:"")+b,T&&(this.identifier=T),m!=null&&m.__line__&&(this.line=m.__line__)}}function Ns(d,...o){for(const m of o)for(const b in m)d[b]=m[b];return d}class Ts extends Error{constructor(o,m){super(m),this.message=m,this.key=o}}class bs{constructor(o,m=[]){this.parent=o,this.bindings={};for(const[b,T]of m)this.bindings[b]=T}concat(o){return new bs(this,o)}get(o){if(this.bindings[o])return this.bindings[o];if(this.parent)return this.parent.get(o);throw new Error(`${o} not found in scope.`)}has(o){return!!this.bindings[o]||!!this.parent&&this.parent.has(o)}}const en={kind:"null"},Jt={kind:"number"},Vs={kind:"string"},ps={kind:"boolean"},nt={kind:"color"},ts={kind:"object"},ds={kind:"value"},Is={kind:"collator"},tn={kind:"formatted"},wn={kind:"padding"},Gs={kind:"resolvedImage"},Ue={kind:"variableAnchorOffsetCollection"};function Pe(d,o){return{kind:"array",itemType:d,N:o}}function je(d){if(d.kind==="array"){const o=je(d.itemType);return typeof d.N=="number"?`array<${o}, ${d.N}>`:d.itemType.kind==="value"?"array":`array<${o}>`}return d.kind}const Ge=[en,Jt,Vs,ps,nt,tn,ts,Pe(ds),wn,Gs,Ue];function De(d,o){if(o.kind==="error")return null;if(d.kind==="array"){if(o.kind==="array"&&(o.N===0&&o.itemType.kind==="value"||!De(d.itemType,o.itemType))&&(typeof d.N!="number"||d.N===o.N))return null}else{if(d.kind===o.kind)return null;if(d.kind==="value"){for(const m of Ge)if(!De(m,o))return null}}return`Expected ${je(d)} but found ${je(o)} instead.`}function bt(d,o){return o.some(m=>m.kind===d.kind)}function Ct(d,o){return o.some(m=>m==="null"?d===null:m==="array"?Array.isArray(d):m==="object"?d&&!Array.isArray(d)&&typeof d=="object":m===typeof d)}function pe(d,o){return d.kind==="array"&&o.kind==="array"?d.itemType.kind===o.itemType.kind&&typeof d.N=="number":d.kind===o.kind}const wt=.96422,Zt=.82521,ys=4/29,es=6/29,is=3*es*es,Ws=es*es*es,an=Math.PI/180,ya=180/Math.PI;function Hs(d){return(d%=360)<0&&(d+=360),d}function xt([d,o,m,b]){let T,$;const V=Ls((.2225045*(d=os(d))+.7168786*(o=os(o))+.0606169*(m=os(m)))/1);d===o&&o===m?T=$=V:(T=Ls((.4360747*d+.3850649*o+.1430804*m)/wt),$=Ls((.0139322*d+.0971045*o+.7141733*m)/Zt));const U=116*V-16;return[U<0?0:U,500*(T-V),200*(V-$),b]}function os(d){return d<=.04045?d/12.92:Math.pow((d+.055)/1.055,2.4)}function Ls(d){return d>Ws?Math.pow(d,1/3):d/is+ys}function Es([d,o,m,b]){let T=(d+16)/116,$=isNaN(o)?T:T+o/500,V=isNaN(m)?T:T-m/200;return T=1*Pn(T),$=wt*Pn($),V=Zt*Pn(V),[Qs(3.1338561*$-1.6168667*T-.4906146*V),Qs(-.9787684*$+1.9161415*T+.033454*V),Qs(.0719453*$-.2289914*T+1.4052427*V),b]}function Qs(d){return(d=d<=.00304?12.92*d:1.055*Math.pow(d,1/2.4)-.055)<0?0:d>1?1:d}function Pn(d){return d>es?d*d*d:is*(d-ys)}function Ks(d){return parseInt(d.padEnd(2,d),16)/255}function xa(d,o){return Fn(o?d/100:d,0,1)}function Fn(d,o,m){return Math.min(Math.max(o,d),m)}function Sa(d){return!d.some(Number.isNaN)}const sr={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],ol
1961ive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};class An{constructor(o,m,b,T=1,$=!0){this.r=o,this.g=m,this.b=b,this.a=T,$||(this.r*=T,this.g*=T,this.b*=T,T||this.overwriteGetter("rgb",[o,m,b,T]))}static parse(o){if(o instanceof An)return o;if(typeof o!="string")return;const m=function(b){if((b=b.toLowerCase().trim())==="transparent")return[0,0,0,0];const T=sr[b];if(T){const[V,U,ne]=T;return[V/255,U/255,ne/255,1]}if(b.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(b)){const V=b.length<6?1:2;let U=1;return[Ks(b.slice(U,U+=V)),Ks(b.slice(U,U+=V)),Ks(b.slice(U,U+=V)),Ks(b.slice(U,U+V)||"ff")]}if(b.startsWith("rgb")){const V=b.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(V){const[U,ne,me,ye,Te,$e,Ye,et,mt,Tt,Ot,gs]=V,Yt=[ye||" ",Ye||" ",Tt].join("");if(Yt==="  "||Yt==="  /"||Yt===",,"||Yt===",,,"){const ls=[me,$e,mt].join(""),Cs=ls==="%%%"?100:ls===""?255:0;if(Cs){const Us=[Fn(+ne/Cs,0,1),Fn(+Te/Cs,0,1),Fn(+et/Cs,0,1),Ot?xa(+Ot,gs):1];if(Sa(Us))return Us}}return}}const $=b.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if($){const[V,U,ne,me,ye,Te,$e,Ye,et]=$,mt=[ne||" ",ye||" ",$e].join("");if(mt==="  "||mt==="  /"||mt===",,"||mt===",,,"){const Tt=[+U,Fn(+me,0,100),Fn(+Te,0,100),Ye?xa(+Ye,et):1];if(Sa(Tt))return function([Ot,gs,Yt,ls]){function Cs(Us){const $n=(Us+Ot/30)%12,La=gs*Math.min(Yt,1-Yt);return Yt-La*Math.max(-1,Math.min($n-3,9-$n,1))}return Ot=Hs(Ot),gs/=100,Yt/=100,[Cs(0),Cs(8),Cs(4),ls]}(Tt)}}}(o);return m?new An(...m,!1):void 0}get rgb(){const{r:o,g:m,b,a:T}=this,$=T||1/0;return this.overwriteGetter("rgb",[o/$,m/$,b/$,T])}get hcl(){return this.overwriteGetter("hcl",function(o){const[m,b,T,$]=xt(o),V=Math.sqrt(b*b+T*T);return[Math.round(1e4*V)?Hs(Math.atan2(T,b)*ya):NaN,V,m,$]}(this.rgb))}get lab(){return this.overwriteGetter("lab",xt(this.rgb))}overwriteGetter(o,m){return Object.defineProperty(this,o,{value:m}),m}toString(){const[o,m,b,T]=this.rgb;return`rgba(${[o,m,b].map($=>Math.round(255*$)).join(",")},${T})`}}An.black=new An(0,0,0,1),An.white=new An(1,1,1,1),An.transparent=new An(0,0,0,0),An.red=new An(1,0,0,1);class Ai{constructor(o,m,b){this.sensitivity=o?m?"variant":"case":m?"accent":"base",this.locale=b,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(o,m){return this.collator.compare(o,m)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class xi{constructor(o,m,b,T,$){this.text=o,this.image=m,this.scale=b,this.fontStack=T,this.textColor=$}}class ei{constructor(o){this.sections=o}static fromString(o){return new ei([new xi(o,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(o=>o.text.length!==0||o.image&&o.image.name.length!==0)}static factory(o){return o instanceof ei?o:ei.fromString(o)}toString(){return this.sections.length===0?"":this.sections.map(o=>o.text).join("")}}class Yr{constructor(o){this.values=o.slice()}static parse(o){if(o instanceof Yr)return o;if(typeof o=="number")return new Yr([o,o,o,o]);if(Array.isArray(o)&&!(o.length<1||o.length>4)){for(const m of o)if(typeof m!="number")return;switch(o.length){case 1:o=[o[0],o[0],o[0],o[0]];break;case 2:o=[o[0],o[1],o[0],o[1]];break;case 3:o=[o[0],o[1],o[2],o[1]]}return new Yr(o)}}toString(){return JSON.stringify(this.values)}}const Xo=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class ra{constructor(o){this.values=o.slice()}static parse(o){if(o instanceof ra)return o;if(Array.isArray(o)&&!(o.length<1)&&o.length%2==0){for(let m=0;m<o.length;m+=2){const b=o[m],T=o[m+1];if(typeof b!="string"||!Xo.has(b)||!Array.isArray(T)||T.length!==2||typeof T[0]!="number"||typeof T[1]!="number")return}return new ra(o)}}toString(){return JSON.stringify(this.values)}}class Ka{constructor(o){this.name=o.name,this.available=o.available}toString(){return this.name}static fromString(o){return o?new Ka({name:o,available:!1}):null}}function Ha(d,o,m,b){return typeof d=="number"&&d>=0&&d<=255&&typeof o=="number"&&o>=0&&o<=255&&typeof m=="number"&&m>=0&&m<=255?b===void 0||typeof b=="number"&&b>=0&&b<=1?null:`Invalid rgba value [${[d,o,m,b].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof b=="number"?[d,o,m,b]:[d,o,m]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}
vendor: 17,416 bytes, line 1961
1961function qa(d){if(d===null||typeof d=="string"||typeof d=="boolean"||typeof d=="number"||d instanceof An||d instanceof Ai||d instanceof ei||d instanceof Yr||d instanceof ra||d instanceof Ka)return!0;if(Array.isArray(d)){for(const o of d)if(!qa(o))return!1;return!0}if(typeof d=="object"){for(const o in d)if(!qa(d[o]))return!1;return!0}return!1}function Mn(d){if(d===null)return en;if(typeof d=="string")return Vs;if(typeof d=="boolean")return ps;if(typeof d=="number")return Jt;if(d instanceof An)return nt;if(d instanceof Ai)return Is;if(d instanceof ei)return tn;if(d instanceof Yr)return wn;if(d instanceof ra)return Ue;if(d instanceof Ka)return Gs;if(Array.isArray(d)){const o=d.length;let m;for(const b of d){const T=Mn(b);if(m){if(m===T)continue;m=ds;break}m=T}return Pe(m||ds,o)}return ts}function _r(d){const o=typeof d;return d===null?"":o==="string"||o==="number"||o==="boolean"?String(d):d instanceof An||d instanceof ei||d instanceof Yr||d instanceof ra||d instanceof Ka?d.toString():JSON.stringify(d)}class Ar{constructor(o,m){this.type=o,this.value=m}static parse(o,m){if(o.length!==2)return m.error(`'literal' expression requires exactly one argument, but found ${o.length-1} instead.`);if(!qa(o[1]))return m.error("invalid value");const b=o[1];let T=Mn(b);const $=m.expectedType;return T.kind!=="array"||T.N!==0||!$||$.kind!=="array"||typeof $.N=="number"&&$.N!==0||(T=$),new Ar(T,b)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class Zs{constructor(o){this.name="ExpressionEvaluationError",this.message=o}toJSON(){return this.message}}const Cn={string:Vs,number:Jt,boolean:ps,object:ts};class Na{constructor(o,m){this.type=o,this.args=m}static parse(o,m){if(o.length<2)return m.error("Expected at least one argument.");let b,T=1;const $=o[0];if($==="array"){let U,ne;if(o.length>2){const me=o[1];if(typeof me!="string"||!(me in Cn)||me==="object")return m.error('The item type argument of "array" must be one of string, number, boolean',1);U=Cn[me],T++}else U=ds;if(o.length>3){if(o[2]!==null&&(typeof o[2]!="number"||o[2]<0||o[2]!==Math.floor(o[2])))return m.error('The length argument to "array" must be a positive integer literal',2);ne=o[2],T++}b=Pe(U,ne)}else{if(!Cn[$])throw new Error(`Types doesn't contain name = ${$}`);b=Cn[$]}const V=[];for(;T<o.length;T++){const U=m.parse(o[T],T,ds);if(!U)return null;V.push(U)}return new Na(b,V)}evaluate(o){for(let m=0;m<this.args.length;m++){const b=this.args[m].evaluate(o);if(!De(this.type,Mn(b)))return b;if(m===this.args.length-1)throw new Zs(`Expected value to be of type ${je(this.type)}, but found ${je(Mn(b))} instead.`)}throw new Error}eachChild(o){this.args.forEach(o)}outputDefined(){return this.args.every(o=>o.outputDefined())}}const Gn={"to-boolean":ps,"to-color":nt,"to-number":Jt,"to-string":Vs};class sa{constructor(o,m){this.type=o,this.args=m}static parse(o,m){if(o.length<2)return m.error("Expected at least one argument.");const b=o[0];if(!Gn[b])throw new Error(`Can't parse ${b} as it is not part of the known types`);if((b==="to-boolean"||b==="to-string")&&o.length!==2)return m.error("Expected one argument.");const T=Gn[b],$=[];for(let V=1;V<o.length;V++){const U=m.parse(o[V],V,ds);if(!U)return null;$.push(U)}return new sa(T,$)}evaluate(o){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(o);case"color":{let m,b;for(const T of this.args){if(m=T.evaluate(o),b=null,m instanceof An)return m;if(typeof m=="string"){const $=o.parseColor(m);if($)return $}else if(Array.isArray(m)&&(b=m.length<3||m.length>4?`Invalid rbga value ${JSON.stringify(m)}: expected an array containing either three or four numeric values.`:Ha(m[0],m[1],m[2],m[3]),!b))return new An(m[0]/255,m[1]/255,m[2]/255,m[3])}throw new Zs(b||`Could not parse color from value '${typeof m=="string"?m:JSON.stringify(m)}'`)}case"padding":{let m;for(const b of this.args){m=b.evaluate(o);const T=Yr.parse(m);if(T)return T}throw new Zs(`Could not parse padding from value '${typeof m=="string"?m:JSON.stringify(m)}'`)}case"variableAnchorOffsetCollection":{let m;for(const b of this.args){m=b.evaluate(o);const T=ra.parse(m);if(T)return T}throw new Zs(`Could not parse variableAnchorOffsetCollection from value '${typeof m=="string"?m:JSON.stringify(m)}'`)}case"number":{let m=null;for(const b of this.args){if(m=b.evaluate(o),m===null)return 0;const T=Number(m);if(!isNaN(T))return T}throw new Zs(`Could not convert ${JSON.stringify(m)} to number.`)}case"formatted":return ei.fromString(_r(this.args[0].evaluate(o)));case"resolvedImage":return Ka.fromString(_r(this.args[0].evaluate(o)));default:return _r(this.args[0].evaluate(o))}}eachChild(o){this.args.forEach(o)}outputDefined(){return this.args.every(o=>o.outputDefined())}}const Pr=["Unknown","Point","LineString","Polygon"];class oi{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Pr[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(o){let m=this._parseColorCache[o];return m||(m=this._parseColorCache[o]=An.parse(o)),m}}class Tr{constructor(o,m,b=[],T,$=new bs,V=[]){this.registry=o,this.path=b,this.key=b.map(U=>`[${U}]`).join(""),this.scope=$,this.errors=V,this.expectedType=T,this._isConstant=m}parse(o,m,b,T,$={}){return m?this.concat(m,b,T)._parse(o,$):this._parse(o,$)}_parse(o,m){function b(T,$,V){return V==="assert"?new Na($,[T]):V==="coerce"?new sa($,[T]):T}if(o!==null&&typeof o!="string"&&typeof o!="boolean"&&typeof o!="number"||(o=["literal",o]),Array.isArray(o)){if(o.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const T=o[0];if(typeof T!="string")return this.error(`Expression name must be a string, but found ${typeof T} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const $=this.registry[T];if($){let V=$.parse(o,this);if(!V)return null;if(this.expectedType){const U=this.expectedType,ne=V.type;if(U.kind!=="string"&&U.kind!=="number"&&U.kind!=="boolean"&&U.kind!=="object"&&U.kind!=="array"||ne.kind!=="value")if(U.kind!=="color"&&U.kind!=="formatted"&&U.kind!=="resolvedImage"||ne.kind!=="value"&&ne.kind!=="string")if(U.kind!=="padding"||ne.kind!=="value"&&ne.kind!=="number"&&ne.kind!=="array")if(U.kind!=="variableAnchorOffsetCollection"||ne.kind!=="value"&&ne.kind!=="array"){if(this.checkSubtype(U,ne))return null}else V=b(V,U,m.typeAnnotation||"coerce");else V=b(V,U,m.typeAnnotation||"coerce");else V=b(V,U,m.typeAnnotation||"coerce");else V=b(V,U,m.typeAnnotation||"assert")}if(!(V instanceof Ar)&&V.type.kind!=="resolvedImage"&&this._isConstant(V)){const U=new oi;try{V=new Ar(V.type,V.evaluate(U))}catch(ne){return this.error(ne.message),null}}return V}return this.error(`Unknown expression "${T}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(o===void 0?"'undefined' value invalid. Use null instead.":typeof o=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof o} instead.`)}concat(o,m,b){const T=typeof o=="number"?this.path.concat(o):this.path,$=b?this.scope.concat(b):this.scope;return new Tr(this.registry,this._isConstant,T,m||null,$,this.errors)}error(o,...m){const b=`${this.key}${m.map(T=>`[${T}]`).join("")}`;this.errors.push(new Ts(b,o))}checkSubtype(o,m){const b=De(o,m);return b&&this.error(b),b}}class Ko{constructor(o,m){this.type=m.type,this.bindings=[].concat(o),this.result=m}evaluate(o){return this.result.evaluate(o)}eachChild(o){for(const m of this.bindings)o(m[1]);o(this.result)}static parse(o,m){if(o.length<4)return m.error(`Expected at least 3 arguments, but found ${o.length-1} instead.`);const b=[];for(let $=1;$<o.length-1;$+=2){const V=o[$];if(typeof V!="string")return m.error(`Expected string, but found ${typeof V} instead.`,$);if(/[^a-zA-Z0-9_]/.test(V))return m.error("Variable names must contain only alphanumeric characters or '_'.",$);const U=m.parse(o[$+1],$+1);if(!U)return null;b.push([V,U])}const T=m.parse(o[o.length-1],o.length-1,m.expectedType,b);return T?new Ko(b,T):null}outputDefined(){return this.result.outputDefined()}}class Za{constructor(o,m){this.type=m.type,this.name=o,this.boundExpression=m}static parse(o,m){if(o.length!==2||typeof o[1]!="string")return m.error("'var' expression requires exactly one string literal argument.");const b=o[1];return m.scope.has(b)?new Za(b,m.scope.get(b)):m.error(`Unknown variable "${b}". Make sure "${b}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(o){return this.boundExpression.evaluate(o)}eachChild(){}outputDefined(){return!1}}class Gr{constructor(o,m,b){this.type=o,this.index=m,this.input=b}static parse(o,m){if(o.length!==3)return m.error(`Expected 2 arguments, but found ${o.length-1} instead.`);const b=m.parse(o[1],1,Jt),T=m.parse(o[2],2,Pe(m.expectedType||ds));return b&&T?new Gr(T.type.itemType,b,T):null}evaluate(o){const m=this.index.evaluate(o),b=this.input.evaluate(o);if(m<0)throw new Zs(`Array index out of bounds: ${m} < 0.`);if(m>=b.length)throw new Zs(`Array index out of bounds: ${m} > ${b.length-1}.`);if(m!==Math.floor(m))throw new Zs(`Array index must be an integer, but found ${m} instead.`);return b[m]}eachChild(o){o(this.index),o(this.input)}outputDefined(){return!1}}class Xr{constructor(o,m){this.type=ps,this.needle=o,this.haystack=m}static parse(o,m){if(o.length!==3)return m.error(`Expected 2 arguments, but found ${o.length-1} instead.`);const b=m.parse(o[1],1,ds),T=m.parse(o[2],2,ds);return b&&T?bt(b.type,[ps,Vs,Jt,en,ds])?new Xr(b,T):m.error(`Expected first argument to be of type boolean, string, number or null, but found ${je(b.type)} instead`):null}evaluate(o){const m=this.needle.evaluate(o),b=this.haystack.evaluate(o);if(!b)return!1;if(!Ct(m,["boolean","string","number","null"]))throw new Zs(`Expected first argument to be of type boolean, string, number or null, but found ${je(Mn(m))} instead.`);if(!Ct(b,["string","array"]))throw new Zs(`Expected second argument to be of type array or string, but found ${je(Mn(b))} instead.`);return b.indexOf(m)>=0}eachChild(o){o(this.needle),o(this.haystack)}outputDefined(){return!0}}class rn{constructor(o,m,b){this.type=Jt,this.needle=o,this.haystack=m,this.fromIndex=b}static parse(o,m){if(o.length<=2||o.length>=5)return m.error(`Expected 3 or 4 arguments, but found ${o.length-1} instead.`);const b=m.parse(o[1],1,ds),T=m.parse(o[2],2,ds);if(!b||!T)return null;if(!bt(b.type,[ps,Vs,Jt,en,ds]))return m.error(`Expected first argument to be of type boolean, string, number or null, but found ${je(b.type)} instead`);if(o.length===4){const $=m.parse(o[3],3,Jt);return $?new rn(b,T,$):null}return new rn(b,T)}evaluate(o){const m=this.needle.evaluate(o),b=this.haystack.evaluate(o);if(!Ct(m,["boolean","string","number","null"]))throw new Zs(`Expected first argument to be of type boolean, string, number or null, but found ${je(Mn(m))} instead.`);let T;if(this.fromIndex&&(T=this.fromIndex.evaluate(o)),Ct(b,["string"])){const $=b.indexOf(m,T);return $===-1?-1:[...b.slice(0,$)].length}if(Ct(b,["array"]))return b.indexOf(m,T);throw new Zs(`Expected second argument to be of type array or string, but found ${je(Mn(b))} instead.`)}eachChild(o){o(this.needle),o(this.haystack),this.fromIndex&&o(this.fromIndex)}outputDefined(){return!1}}class In{constructor(o,m,b,T,$,V){this.inputType=o,this.type=m,this.input=b,this.cases=T,this.outputs=$,this.otherwise=V}static parse(o,m){if(o.length<5)return m.error(`Expected at least 4 arguments, but found only ${o.length-1}.`);if(o.length%2!=1)return m.error("Expected an even number of arguments.");let b,T;m.expectedType&&m.expectedType.kind!=="value"&&(T=m.expectedType);const $={},V=[];for(let me=2;me<o.length-1;me+=2){let ye=o[me];const Te=o[me+1];Array.isArray(ye)||(ye=[ye]);const $e=m.concat(me);if(ye.length===0)return $e.error("Expected at least one branch label.");for(const et of ye){if(typeof et!="number"&&typeof et!="string")return $e.error("Branch labels must be numbers or strings.");if(typeof et=="number"&&Math.abs(et)>Number.MAX_SAFE_INTEGER)return $e.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof et=="number"&&Math.floor(et)!==et)return $e.error("Numeric branch labels must be integer values.");if(b){if($e.checkSubtype(b,Mn(et)))return null}else b=Mn(et);if($[String(et)]!==void 0)return $e.error("Branch labels must be unique.");$[String(et)]=V.length}const Ye=m.parse(Te,me,T);if(!Ye)return null;T=T||Ye.type,V.push(Ye)}const U=m.parse(o[1],1,ds);if(!U)return null;const ne=m.parse(o[o.length-1],o.length-1,T);return ne?U.type.kind!=="value"&&m.concat(1).checkSubtype(b,U.type)?null:new In(b,T,U,$,V,ne):null}evaluate(o){const m=this.input.evaluate(o);return(Mn(m)===this.inputType&&this.outputs[this.cases[m]]||this.otherwise).evaluate(o)}eachChild(o){o(this.input),this.outputs.forEach(o),o(this.otherwise)}outputDefined(){return this.outputs.every(o=>o.outputDefined())&&this.otherwise.outputDefined()}}class Yi{constructor(o,m,b){this.type=o,this.branches=m,this.otherwise=b}static parse(o,m){if(o.length<4)return m.error(`Expected at least 3 arguments, but found only ${o.length-1}.`);if(o.length%2!=0)return m.error("Expected an odd number of arguments.");let b;m.expectedType&&m.expectedType.kind!=="value"&&(b=m.expectedType);const T=[];for(let V=1;V<o.length-1;V+=2){const U=m.parse(o[V],V,ps);if(!U)return null;const ne=m.parse(o[V+1],V+1,b);if(!ne)return null;T.push([U,ne]),b=b||ne.type}const $=m.parse(o[o.length-1],o.length-1,b);if(!$)return null;if(!b)throw new Error("Can't infer output type");return new Yi(b,T,$)}evaluate(o){for(const[m,b]of this.branches)if(m.evaluate(o))return b.evaluate(o);return this.otherwise.evaluate(o)}eachChild(o){for(const[m,b]of this.branches)o(m),o(b);o(this.otherwise)}outputDefined(){return this.branches.every(([o,m])=>m.outputDefined())&&this.otherwise.outputDefined()}}class jl{constructor(o,m,b,T){this.type=o,this.input=m,this.beginIndex=b,this.endIndex=T}static parse(o,m){if(o.length<=2||o.length>=5)return m.error(`Expected 3 or 4 arguments, but found ${o.length-1} instead.`);const b=m.parse(o[1],1,ds),T=m.parse(o[2],2,Jt);if(!b||!T)return null;if(!bt(b.type,[Pe(ds),Vs,ds]))return m.error(`Expected first argument to be of type array or string, but found ${je(b.type)} instead`);if(o.length===4){const $=m.parse(o[3],3,Jt);return $?new jl(b.type,b,T,$):null}return new jl(b.type,b,T)}evaluate(o){const m=this.input.evaluate(o),b=this.beginIndex.evaluate(o);let T;if(this.endIndex&&(T=this.endIndex.evaluate(o)),Ct(m,["string"]))return[...m].slice(b,T).join("");if(Ct(m,["array"]))return m.slice(b,T);throw new Zs(`Expected first argument to be of type array or string, but found ${je(Mn(m))} instead.`)}eachChild(o){o(this.input),o(this.beginIndex),this.endIndex&&o(this.endIndex)}outputDefined(){return!1}}function Si(d,o){const m=d.length-1;let b,T,$=0,V=m,U=0;for(;$<=V;)if(U=Math.floor(($+V)/2),b=d[U],T=d[U+1],b<=o){if(U===m||o<T)return U;$=U+1}else{if(!(b>o))throw new Zs("Input is not a number.");V=U-1}return 0}class zo{constructor(o,m,b){this.type=o,this.input=m,this.labels=[],this.outputs=[];for(const[T,$]of b)this.labels.push(T),this.outputs.push($)}static parse(o,m){if(o.length-1<4)return m.error(`Expected at least 4 arguments, but found only ${o.length-1}.`);if((o.length-1)%2!=0)return m.error("Expected an even number of arguments.");const b=m.parse(o[1],1,Jt);if(!b)return null;const T=[];let $=null;m.expectedType&&m.expectedType.kind!=="value"&&($=m.expectedType);for(let V=1;V<o.length;V+=2){const U=V===1?-1/0:o[V],ne=o[V+1],me=V,ye=V+1;if(typeof U!="number")return m.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',me);if(T.length&&T[T.length-1][0]>=U)return m.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',me);const Te=m.parse(ne,ye,$);if(!Te)return null;$=$||Te.type,T.push([U,Te])}return new zo($,b,T)}evaluate(o){const m=this.labels,b=this.outputs;if(m.length===1)return b[0].evaluate(o);const T=this.input.evaluate(o);if(T<=m[0])return b[0].evaluate(o);const $=m.length;return T>=m[$-1]?b[$-1].evaluate(o):b[Si(m,T)].evaluate(o)}eachChild(o){o(this.input);for(const m of this.outputs)o(m)}outputDefined(){return this.outputs.every(o=>o.outputDefined())}}function Pc(d){return d&&d.__esModule&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d}var Hr=ul;function ul(d,o,m,b){this.cx=3*d,this.bx=3*(m-d)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*o,this.by=3*(b-o)-this.cy,this.ay=1-this.cy-this.by,this.p1x=d,this.p1y=o,this.p2x=m,this.p2y=b}ul.prototype={sampleCurveX:function(d){return((this.ax*d+this.bx)*d+this.cx)*d},sampleCurveY:function(d){return((this.ay*d+this.by)*d+this.cy)*d},sampleCurveDerivativeX:function(d){return(3*this.ax*d+2*this.bx)*d+this.cx},solveCurveX:function(d,o){if(o===void 0&&(o=1e-6),d<0)return 0;if(d>1)return 1;for(var m=d,b=0;b<8;b++){var T=this.sampleCurveX(m)-d;
1961if(Math.abs(T)<o)return m;var $=this.sampleCurveDerivativeX(m);if(Math.abs($)<1e-6)break;m-=T/$}var V=0,U=1;for(m=d,b=0;b<20&&(T=this.sampleCurveX(m),!(Math.abs(T-d)<o));b++)d>T?V=m:U=m,m=.5*(U-V)+V;return m},solve:function(d,o){return this.sampleCurveY(this.solveCurveX(d,o))}};var hl=Pc(Hr);function Nr(d,o,m){return d+m*(o-d)}function ui(d,o,m){return d.map((b,T)=>Nr(b,o[T],m))}const Zr={number:Nr,color:function(d,o,m,b="rgb"){switch(b){case"rgb":{const[T,$,V,U]=ui(d.rgb,o.rgb,m);return new An(T,$,V,U,!1)}case"hcl":{const[T,$,V,U]=d.hcl,[ne,me,ye,Te]=o.hcl;let $e,Ye;if(isNaN(T)||isNaN(ne))isNaN(T)?isNaN(ne)?$e=NaN:($e=ne,V!==1&&V!==0||(Ye=me)):($e=T,ye!==1&&ye!==0||(Ye=$));else{let gs=ne-T;ne>T&&gs>180?gs-=360:ne<T&&T-ne>180&&(gs+=360),$e=T+m*gs}const[et,mt,Tt,Ot]=function([gs,Yt,ls,Cs]){return gs=isNaN(gs)?0:gs*an,Es([ls,Math.cos(gs)*Yt,Math.sin(gs)*Yt,Cs])}([$e,Ye??Nr($,me,m),Nr(V,ye,m),Nr(U,Te,m)]);return new An(et,mt,Tt,Ot,!1)}case"lab":{const[T,$,V,U]=Es(ui(d.lab,o.lab,m));return new An(T,$,V,U,!1)}}},array:ui,padding:function(d,o,m){return new Yr(ui(d.values,o.values,m))},variableAnchorOffsetCollection:function(d,o,m){const b=d.values,T=o.values;if(b.length!==T.length)throw new Zs(`Cannot interpolate values of different length. from: ${d.toString()}, to: ${o.toString()}`);const $=[];for(let V=0;V<b.length;V+=2){if(b[V]!==T[V])throw new Zs(`Cannot interpolate values containing mismatched anchors. from[${V}]: ${b[V]}, to[${V}]: ${T[V]}`);$.push(b[V]);const[U,ne]=b[V+1],[me,ye]=T[V+1];$.push([Nr(U,me,m),Nr(ne,ye,m)])}return new ra($)}};class Gi{constructor(o,m,b,T,$){this.type=o,this.operator=m,this.interpolation=b,this.input=T,this.labels=[],this.outputs=[];for(const[V,U]of $)this.labels.push(V),this.outputs.push(U)}static interpolationFactor(o,m,b,T){let $=0;if(o.name==="exponential")$=fn(m,o.base,b,T);else if(o.name==="linear")$=fn(m,1,b,T);else if(o.name==="cubic-bezier"){const V=o.controlPoints;$=new hl(V[0],V[1],V[2],V[3]).solve(fn(m,1,b,T))}return $}static parse(o,m){let[b,T,$,...V]=o;if(!Array.isArray(T)||T.length===0)return m.error("Expected an interpolation type expression.",1);if(T[0]==="linear")T={name:"linear"};else if(T[0]==="exponential"){const me=T[1];if(typeof me!="number")return m.error("Exponential interpolation requires a numeric base.",1,1);T={name:"exponential",base:me}}else{if(T[0]!=="cubic-bezier")return m.error(`Unknown interpolation type ${String(T[0])}`,1,0);{const me=T.slice(1);if(me.length!==4||me.some(ye=>typeof ye!="number"||ye<0||ye>1))return m.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);T={name:"cubic-bezier",controlPoints:me}}}if(o.length-1<4)return m.error(`Expected at least 4 arguments, but found only ${o.length-1}.`);if((o.length-1)%2!=0)return m.error("Expected an even number of arguments.");if($=m.parse($,2,Jt),!$)return null;const U=[];let ne=null;b==="interpolate-hcl"||b==="interpolate-lab"?ne=nt:m.expectedType&&m.expectedType.kind!=="value"&&(ne=m.expectedType);for(let me=0;me<V.length;me+=2){const ye=V[me],Te=V[me+1],$e=me+3,Ye=me+4;if(typeof ye!="number")return m.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',$e);if(U.length&&U[U.length-1][0]>=ye)return m.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',$e);const et=m.parse(Te,Ye,ne);if(!et)return null;ne=ne||et.type,U.push([ye,et])}return pe(ne,Jt)||pe(ne,nt)||pe(ne,wn)||pe(ne,Ue)||pe(ne,Pe(Jt))?new Gi(ne,b,T,$,U):m.error(`Type ${je(ne)} is not interpolatable.`)}evaluate(o){const m=this.labels,b=this.outputs;if(m.length===1)return b[0].evaluate(o);const T=this.input.evaluate(o);if(T<=m[0])return b[0].evaluate(o);const $=m.length;if(T>=m[$-1])return b[$-1].evaluate(o);const V=Si(m,T),U=Gi.interpolationFactor(this.interpolation,T,m[V],m[V+1]),ne=b[V].evaluate(o),me=b[V+1].evaluate(o);switch(this.operator){case"interpolate":return Zr[this.type.kind](ne,me,U);case"interpolate-hcl":return Zr.color(ne,me,U,"hcl");case"interpolate-lab":return Zr.color(ne,me,U,"lab")}}eachChild(o){o(this.input);for(const m of this.outputs)o(m)}outputDefined(){return this.outputs.every(o=>o.outputDefined())}}function fn(d,o,m,b){const T=b-m,$=d-m;return T===0?0:o===1?$/T:(Math.pow(o,$)-1)/(Math.pow(o,T)-1)}class kr{constructor(o,m){this.type=o,this.args=m}static parse(o,m){if(o.length<2)return m.error("Expectected at least one argument.");let b=null;const T=m.expectedType;T&&T.kind!=="value"&&(b=T);const $=[];for(const U of o.slice(1)){const ne=m.parse(U,1+$.length,b,void 0,{typeAnnotation:"omit"});if(!ne)return null;b=b||ne.type,$.push(ne)}if(!b)throw new Error("No output type");const V=T&&$.some(U=>De(T,U.type));return new kr(V?ds:b,$)}evaluate(o){let m,b=null,T=0;for(const $ of this.args)if(T++,b=$.evaluate(o),b&&b instanceof Ka&&!b.available&&(m||(m=b.name),b=null,T===this.args.length&&(b=m)),b!==null)break;return b}
vendor: 29,894 bytes, line 1961
1961eachChild(o){this.args.forEach(o)}outputDefined(){return this.args.every(o=>o.outputDefined())}}function nr(d,o){return d==="=="||d==="!="?o.kind==="boolean"||o.kind==="string"||o.kind==="number"||o.kind==="null"||o.kind==="value":o.kind==="string"||o.kind==="number"||o.kind==="value"}function Br(d,o,m,b){return b.compare(o,m)===0}function wl(d,o,m){const b=d!=="=="&&d!=="!=";return class eL{constructor($,V,U){this.type=ps,this.lhs=$,this.rhs=V,this.collator=U,this.hasUntypedArgument=$.type.kind==="value"||V.type.kind==="value"}static parse($,V){if($.length!==3&&$.length!==4)return V.error("Expected two or three arguments.");const U=$[0];let ne=V.parse($[1],1,ds);if(!ne)return null;if(!nr(U,ne.type))return V.concat(1).error(`"${U}" comparisons are not supported for type '${je(ne.type)}'.`);let me=V.parse($[2],2,ds);if(!me)return null;if(!nr(U,me.type))return V.concat(2).error(`"${U}" comparisons are not supported for type '${je(me.type)}'.`);if(ne.type.kind!==me.type.kind&&ne.type.kind!=="value"&&me.type.kind!=="value")return V.error(`Cannot compare types '${je(ne.type)}' and '${je(me.type)}'.`);b&&(ne.type.kind==="value"&&me.type.kind!=="value"?ne=new Na(me.type,[ne]):ne.type.kind!=="value"&&me.type.kind==="value"&&(me=new Na(ne.type,[me])));let ye=null;if($.length===4){if(ne.type.kind!=="string"&&me.type.kind!=="string"&&ne.type.kind!=="value"&&me.type.kind!=="value")return V.error("Cannot use collator to compare non-string types.");if(ye=V.parse($[3],3,Is),!ye)return null}return new eL(ne,me,ye)}evaluate($){const V=this.lhs.evaluate($),U=this.rhs.evaluate($);if(b&&this.hasUntypedArgument){const ne=Mn(V),me=Mn(U);if(ne.kind!==me.kind||ne.kind!=="string"&&ne.kind!=="number")throw new Zs(`Expected arguments for "${d}" to be (string, string) or (number, number), but found (${ne.kind}, ${me.kind}) instead.`)}if(this.collator&&!b&&this.hasUntypedArgument){const ne=Mn(V),me=Mn(U);if(ne.kind!=="string"||me.kind!=="string")return o($,V,U)}return this.collator?m($,V,U,this.collator.evaluate($)):o($,V,U)}eachChild($){$(this.lhs),$(this.rhs),this.collator&&$(this.collator)}outputDefined(){return!0}}}const Nl=wl("==",function(d,o,m){return o===m},Br),lr=wl("!=",function(d,o,m){return o!==m},function(d,o,m,b){return!Br(0,o,m,b)}),Xi=wl("<",function(d,o,m){return o<m},function(d,o,m,b){return b.compare(o,m)<0}),ml=wl(">",function(d,o,m){return o>m},function(d,o,m,b){return b.compare(o,m)>0}),Co=wl("<=",function(d,o,m){return o<=m},function(d,o,m,b){return b.compare(o,m)<=0}),ti=wl(">=",function(d,o,m){return o>=m},function(d,o,m,b){return b.compare(o,m)>=0});class qs{constructor(o,m,b){this.type=Is,this.locale=b,this.caseSensitive=o,this.diacriticSensitive=m}static parse(o,m){if(o.length!==2)return m.error("Expected one argument.");const b=o[1];if(typeof b!="object"||Array.isArray(b))return m.error("Collator options argument must be an object.");const T=m.parse(b["case-sensitive"]!==void 0&&b["case-sensitive"],1,ps);if(!T)return null;const $=m.parse(b["diacritic-sensitive"]!==void 0&&b["diacritic-sensitive"],1,ps);if(!$)return null;let V=null;return b.locale&&(V=m.parse(b.locale,1,Vs),!V)?null:new qs(T,$,V)}evaluate(o){return new Ai(this.caseSensitive.evaluate(o),this.diacriticSensitive.evaluate(o),this.locale?this.locale.evaluate(o):null)}eachChild(o){o(this.caseSensitive),o(this.diacriticSensitive),this.locale&&o(this.locale)}outputDefined(){return!1}}class Tn{constructor(o,m,b,T,$){this.type=Vs,this.number=o,this.locale=m,this.currency=b,this.minFractionDigits=T,this.maxFractionDigits=$}static parse(o,m){if(o.length!==3)return m.error("Expected two arguments.");const b=m.parse(o[1],1,Jt);if(!b)return null;const T=o[2];if(typeof T!="object"||Array.isArray(T))return m.error("NumberFormat options argument must be an object.");let $=null;if(T.locale&&($=m.parse(T.locale,1,Vs),!$))return null;let V=null;if(T.currency&&(V=m.parse(T.currency,1,Vs),!V))return null;let U=null;if(T["min-fraction-digits"]&&(U=m.parse(T["min-fraction-digits"],1,Jt),!U))return null;let ne=null;return T["max-fraction-digits"]&&(ne=m.parse(T["max-fraction-digits"],1,Jt),!ne)?null:new Tn(b,$,V,U,ne)}evaluate(o){return new Intl.NumberFormat(this.locale?this.locale.evaluate(o):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(o):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(o):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(o):void 0}).format(this.number.evaluate(o))}eachChild(o){o(this.number),this.locale&&o(this.locale),this.currency&&o(this.currency),this.minFractionDigits&&o(this.minFractionDigits),this.maxFractionDigits&&o(this.maxFractionDigits)}outputDefined(){return!1}}class oa{constructor(o){this.type=tn,this.sections=o}static parse(o,m){if(o.length<2)return m.error("Expected at least one argument.");const b=o[1];if(!Array.isArray(b)&&typeof b=="object")return m.error("First argument must be an image or text section.");const T=[];let $=!1;for(let V=1;V<=o.length-1;++V){const U=o[V];if($&&typeof U=="object"&&!Array.isArray(U)){$=!1;let ne=null;if(U["font-scale"]&&(ne=m.parse(U["font-scale"],1,Jt),!ne))return null;let me=null;if(U["text-font"]&&(me=m.parse(U["text-font"],1,Pe(Vs)),!me))return null;let ye=null;if(U["text-color"]&&(ye=m.parse(U["text-color"],1,nt),!ye))return null;const Te=T[T.length-1];Te.scale=ne,Te.font=me,Te.textColor=ye}else{const ne=m.parse(o[V],1,ds);if(!ne)return null;const me=ne.type.kind;if(me!=="string"&&me!=="value"&&me!=="null"&&me!=="resolvedImage")return m.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");$=!0,T.push({content:ne,scale:null,font:null,textColor:null})}}return new oa(T)}evaluate(o){return new ei(this.sections.map(m=>{const b=m.content.evaluate(o);return Mn(b)===Gs?new xi("",b,null,null,null):new xi(_r(b),null,m.scale?m.scale.evaluate(o):null,m.font?m.font.evaluate(o).join(","):null,m.textColor?m.textColor.evaluate(o):null)}))}eachChild(o){for(const m of this.sections)o(m.content),m.scale&&o(m.scale),m.font&&o(m.font),m.textColor&&o(m.textColor)}outputDefined(){return!1}}class Pa{constructor(o){this.type=Gs,this.input=o}static parse(o,m){if(o.length!==2)return m.error("Expected two arguments.");const b=m.parse(o[1],1,Vs);return b?new Pa(b):m.error("No image name provided.")}evaluate(o){const m=this.input.evaluate(o),b=Ka.fromString(m);return b&&o.availableImages&&(b.available=o.availableImages.indexOf(m)>-1),b}eachChild(o){o(this.input)}outputDefined(){return!1}}class mr{constructor(o){this.type=Jt,this.input=o}static parse(o,m){if(o.length!==2)return m.error(`Expected 1 argument, but found ${o.length-1} instead.`);const b=m.parse(o[1],1);return b?b.type.kind!=="array"&&b.type.kind!=="string"&&b.type.kind!=="value"?m.error(`Expected argument of type string or array, but found ${je(b.type)} instead.`):new mr(b):null}evaluate(o){const m=this.input.evaluate(o);if(typeof m=="string")return[...m].length;if(Array.isArray(m))return m.length;throw new Zs(`Expected value to be of type string or array, but found ${je(Mn(m))} instead.`)}eachChild(o){o(this.input)}outputDefined(){return!1}}const $r=8192;function Jo(d,o){const m=(180+d[0])/360,b=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+d[1]*Math.PI/360)))/360,T=Math.pow(2,o.z);return[Math.round(m*T*$r),Math.round(b*T*$r)]}function na(d,o){const m=Math.pow(2,o.z);return[(T=(d[0]/$r+o.x)/m,360*T-180),(b=(d[1]/$r+o.y)/m,360/Math.PI*Math.atan(Math.exp((180-360*b)*Math.PI/180))-90)];var b,T}function Sn(d,o){d[0]=Math.min(d[0],o[0]),d[1]=Math.min(d[1],o[1]),d[2]=Math.max(d[2],o[0]),d[3]=Math.max(d[3],o[1])}function Ui(d,o){return!(d[0]<=o[0]||d[2]>=o[2]||d[1]<=o[1]||d[3]>=o[3])}function Ma(d,o,m){const b=d[0]-o[0],T=d[1]-o[1],$=d[0]-m[0],V=d[1]-m[1];return b*V-$*T==0&&b*$<=0&&T*V<=0}function Di(d,o,m,b){return(T=[b[0]-m[0],b[1]-m[1]])[0]*($=[o[0]-d[0],o[1]-d[1]])[1]-T[1]*$[0]!=0&&!(!hc(d,o,m,b)||!hc(m,b,d,o));var T,$}function Al(d,o,m){for(const b of m)for(let T=0;T<b.length-1;++T)if(Di(d,o,b[T],b[T+1]))return!0;return!1}function cc(d,o,m=!1){let b=!1;for(const U of o)for(let ne=0;ne<U.length-1;ne++){if(Ma(d,U[ne],U[ne+1]))return m;($=U[ne])[1]>(T=d)[1]!=(V=U[ne+1])[1]>T[1]&&T[0]<(V[0]-$[0])*(T[1]-$[1])/(V[1]-$[1])+$[0]&&(b=!b)}var T,$,V;return b}function dc(d,o){for(const m of o)if(cc(d,m))return!0;return!1}function _u(d,o){for(const m of d)if(!cc(m,o))return!1;for(let m=0;m<d.length-1;++m)if(Al(d[m],d[m+1],o))return!1;return!0}function uc(d,o){for(const m of o)if(_u(d,m))return!0;return!1}function hc(d,o,m,b){const T=b[0]-m[0],$=b[1]-m[1],V=(d[0]-m[0])*$-T*(d[1]-m[1]),U=(o[0]-m[0])*$-T*(o[1]-m[1]);return V>0&&U<0||V<0&&U>0}function kl(d,o,m){const b=[];for(let T=0;T<d.length;T++){const $=[];for(let V=0;V<d[T].length;V++){const U=Jo(d[T][V],m);Sn(o,U),$.push(U)}b.push($)}return b}function Ki(d,o,m){const b=[];for(let T=0;T<d.length;T++){const $=kl(d[T],o,m);b.push($)}return b}function Dl(d,o,m,b){if(d[0]<m[0]||d[0]>m[2]){const T=.5*b;let $=d[0]-m[0]>T?-b:m[0]-d[0]>T?b:0;$===0&&($=d[0]-m[2]>T?-b:m[2]-d[0]>T?b:0),d[0]+=$}Sn(o,d)}function Ri(d,o,m,b){const T=Math.pow(2,b.z)*$r,$=[b.x*$r,b.y*$r],V=[];for(const U of d)for(const ne of U){const me=[ne.x+$[0],ne.y+$[1]];Dl(me,o,m,T),V.push(me)}return V}function Qo(d,o,m,b){const T=Math.pow(2,b.z)*$r,$=[b.x*$r,b.y*$r],V=[];for(const ne of d){const me=[];for(const ye of ne){const Te=[ye.x+$[0],ye.y+$[1]];Sn(o,Te),me.push(Te)}V.push(me)}if(o[2]-o[0]<=T/2){(U=o)[0]=U[1]=1/0,U[2]=U[3]=-1/0;for(const ne of V)for(const me of ne)Dl(me,o,m,T)}var U;return V}class Cl{constructor(o,m){this.type=ps,this.geojson=o,this.geometries=m}static parse(o,m){if(o.length!==2)return m.error(`'within' expression requires exactly one argument, but found ${o.length-1} instead.`);if(qa(o[1])){const b=o[1];if(b.type==="FeatureCollection"){const T=[];for(const $ of b.features){const{type:V,coordinates:U}=$.geometry;V==="Polygon"&&T.push(U),V==="MultiPolygon"&&T.push(...U)}if(T.length)return new Cl(b,{type:"MultiPolygon",coordinates:T})}else if(b.type==="Feature"){const T=b.geometry.type;if(T==="Polygon"||T==="MultiPolygon")return new Cl(b,b.geometry)}else if(b.type==="Polygon"||b.type==="MultiPolygon")return new Cl(b,b)}return m.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(o){if(o.geometry()!=null&&o.canonicalID()!=null){if(o.geometryType()==="Point")return function(m,b){const T=[1/0,1/0,-1/0,-1/0],$=[1/0,1/0,-1/0,-1/0],V=m.canonicalID();if(b.type==="Polygon"){const U=kl(b.coordinates,$,V),ne=Ri(m.geometry(),T,$,V);if(!Ui(T,$))return!1;for(const me of ne)if(!cc(me,U))return!1}if(b.type==="MultiPolygon"){const U=Ki(b.coordinates,$,V),ne=Ri(m.geometry(),T,$,V);if(!Ui(T,$))return!1;for(const me of ne)if(!dc(me,U))return!1}return!0}(o,this.geometries);if(o.geometryType()==="LineString")return function(m,b){const T=[1/0,1/0,-1/0,-1/0],$=[1/0,1/0,-1/0,-1/0],V=m.canonicalID();if(b.type==="Polygon"){const U=kl(b.coordinates,$,V),ne=Qo(m.geometry(),T,$,V);if(!Ui(T,$))return!1;for(const me of ne)if(!_u(me,U))return!1}if(b.type==="MultiPolygon"){const U=Ki(b.coordinates,$,V),ne=Qo(m.geometry(),T,$,V);if(!Ui(T,$))return!1;for(const me of ne)if(!uc(me,U))return!1}return!0}(o,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Rl=class{constructor(d=[],o=(m,b)=>m<b?-1:m>b?1:0){if(this.data=d,this.length=this.data.length,this.compare=o,this.length>0)for(let m=(this.length>>1)-1;m>=0;m--)this._down(m)}push(d){this.data.push(d),this._up(this.length++)}pop(){if(this.length===0)return;const d=this.data[0],o=this.data.pop();return--this.length>0&&(this.data[0]=o,this._down(0)),d}peek(){return this.data[0]}_up(d){const{data:o,compare:m}=this,b=o[d];for(;d>0;){const T=d-1>>1,$=o[T];if(m(b,$)>=0)break;o[d]=$,d=T}o[d]=b}_down(d){const{data:o,compare:m}=this,b=this.length>>1,T=o[d];for(;d<b;){let $=1+(d<<1);const V=$+1;if(V<this.length&&m(o[V],o[$])<0&&($=V),m(o[$],T)>=0)break;o[d]=o[$],d=$}o[d]=T}};function Md(d,o,m,b,T){fl(d,o,m,b||d.length-1,T||Kr)}function fl(d,o,m,b,T){for(;b>m;){if(b-m>600){var $=b-m+1,V=o-m+1,U=Math.log($),ne=.5*Math.exp(2*U/3),me=.5*Math.sqrt(U*ne*($-ne)/$)*(V-$/2<0?-1:1);fl(d,o,Math.max(m,Math.floor(o-V*ne/$+me)),Math.min(b,Math.floor(o+($-V)*ne/$+me)),T)}var ye=d[o],Te=m,$e=b;for(So(d,m,o),T(d[b],ye)>0&&So(d,m,b);Te<$e;){for(So(d,Te,$e),Te++,$e--;T(d[Te],ye)<0;)Te++;for(;T(d[$e],ye)>0;)$e--}T(d[m],ye)===0?So(d,m,$e):So(d,++$e,b),$e<=o&&(m=$e+1),o<=$e&&(b=$e-1)}}function So(d,o,m){var b=d[o];d[o]=d[m],d[m]=b}function Kr(d,o){return d<o?-1:d>o?1:0}function hi(d,o){if(d.length<=1)return[d];const m=[];let b,T;for(const $ of d){const V=Id($);V!==0&&($.area=Math.abs(V),T===void 0&&(T=V<0),T===V<0?(b&&m.push(b),b=[$]):b.push($))}if(b&&m.push(b),o>1)for(let $=0;$<m.length;$++)m[$].length<=o||(Md(m[$],o,1,m[$].length-1,Jd),m[$]=m[$].slice(0,o));return m}function Jd(d,o){return o.area-d.area}function Id(d){let o=0;for(let m,b,T=0,$=d.length,V=$-1;T<$;V=T++)m=d[T],b=d[V],o+=(b.x-m.x)*(m.y+b.y);return o}const Hl=1/298.257223563,Sl=Hl*(2-Hl),gd=Math.PI/180;class Zl{constructor(o){const m=6378.137*gd*1e3,b=Math.cos(o*gd),T=1/(1-Sl*(1-b*b)),$=Math.sqrt(T);this.kx=m*$*b,this.ky=m*$*T*(1-Sl)}distance(o,m){const b=this.wrap(o[0]-m[0])*this.kx,T=(o[1]-m[1])*this.ky;return Math.sqrt(b*b+T*T)}pointOnLine(o,m){let b,T,$,V,U=1/0;for(let ne=0;ne<o.length-1;ne++){let me=o[ne][0],ye=o[ne][1],Te=this.wrap(o[ne+1][0]-me)*this.kx,$e=(o[ne+1][1]-ye)*this.ky,Ye=0;Te===0&&$e===0||(Ye=(this.wrap(m[0]-me)*this.kx*Te+(m[1]-ye)*this.ky*$e)/(Te*Te+$e*$e),Ye>1?(me=o[ne+1][0],ye=o[ne+1][1]):Ye>0&&(me+=Te/this.kx*Ye,ye+=$e/this.ky*Ye)),Te=this.wrap(m[0]-me)*this.kx,$e=(m[1]-ye)*this.ky;const et=Te*Te+$e*$e;et<U&&(U=et,b=me,T=ye,$=ne,V=Ye)}return{point:[b,T],index:$,t:Math.max(0,Math.min(1,V))}}wrap(o){for(;o<-180;)o+=360;for(;o>180;)o-=360;return o}}function Hi(d,o){return o[0]-d[0]}function eo(d){return d[1]-d[0]+1}function Wr(d,o){return d[1]>=d[0]&&d[1]<o}function Tc(d,o){if(d[0]>d[1])return[null,null];const m=eo(d);if(o){if(m===2)return[d,null];const T=Math.floor(m/2);return[[d[0],d[0]+T],[d[0]+T,d[1]]]}if(m===1)return[d,null];const b=Math.floor(m/2)-1;return[[d[0],d[0]+b],[d[0]+b+1,d[1]]]}function Wl(d,o){if(!Wr(o,d.length))return[1/0,1/0,-1/0,-1/0];const m=[1/0,1/0,-1/0,-1/0];for(let b=o[0];b<=o[1];++b)Sn(m,d[b]);return m}function _o(d){const o=[1/0,1/0,-1/0,-1/0];for(const m of d)for(const b of m)Sn(o,b);return o}function Yl(d){return d[0]!==-1/0&&d[1]!==-1/0&&d[2]!==1/0&&d[3]!==1/0}function Xl(d,o,m){if(!Yl(d)||!Yl(o))return NaN;let b=0,T=0;return d[2]<o[0]&&(b=o[0]-d[2]),d[0]>o[2]&&(b=d[0]-o[2]),d[1]>o[3]&&(T=d[1]-o[3]),d[3]<o[1]&&(T=o[1]-d[3]),m.distance([0,0],[b,T])}function pl(d,o,m){const b=m.pointOnLine(o,d);return m.distance(d,b.point)}function Fl(d,o,m,b,T){const $=Math.min(pl(d,[m,b],T),pl(o,[m,b],T)),V=Math.min(pl(m,[d,o],T),pl(b,[d,o],T));return Math.min($,V)}function Lc(d,o,m,b,T){if(!Wr(o,d.length)||!Wr(b,m.length))return 1/0;let $=1/0;for(let V=o[0];V<o[1];++V){const U=d[V],ne=d[V+1];for(let me=b[0];me<b[1];++me){const ye=m[me],Te=m[me+1];if(Di(U,ne,ye,Te))return 0;$=Math.min($,Fl(U,ne,ye,Te,T))}}return $}function li(d,o,m,b,T){if(!Wr(o,d.length)||!Wr(b,m.length))return NaN;let $=1/0;for(let V=o[0];V<=o[1];++V)for(let U=b[0];U<=b[1];++U)if($=Math.min($,T.distance(d[V],m[U])),$===0)return $;return $}function Kl(d,o,m){if(cc(d,o,!0))return 0;let b=1/0;for(const T of o){const $=T[0],V=T[T.length-1];if($!==V&&(b=Math.min(b,pl(d,[V,$],m)),b===0))return b;const U=m.pointOnLine(T,d);if(b=Math.min(b,m.distance(d,U.point)),b===0)return b}return b}function Ia(d,o,m,b){if(!Wr(o,d.length))return NaN;for(let $=o[0];$<=o[1];++$)if(cc(d[$],m,!0))return 0;let T=1/0;for(let $=o[0];$<o[1];++$){const V=d[$],U=d[$+1];for(const ne of m)for(let me=0,ye=ne.length,Te=ye-1;me<ye;Te=me++){const $e=ne[Te],Ye=ne[me];if(Di(V,U,$e,Ye))return 0;T=Math.min(T,Fl(V,U,$e,Ye,b))}}return T}function Jl(d,o){for(const m of d)for(const b of m)if(cc(b,o,!0))return!0;return!1}function fr(d,o,m,b=1/0){const T=_o(d),$=_o(o);if(b!==1/0&&Xl(T,$,m)>=b)return b;if(Ui(T,$)){if(Jl(d,o))return 0}else if(Jl(o,d))return 0;let V=1/0;for(const U of d)for(let ne=0,me=U.length,ye=me-1;ne<me;ye=ne++){const Te=U[ye],$e=U[ne];for(const Ye of o)for(let et=0,mt=Ye.length,Tt=mt-1;et<mt;Tt=et++){const Ot=Ye[Tt],gs=Ye[et];if(Di(Te,$e,Ot,gs))return 0;V=Math.min(V,Fl(Te,$e,Ot,gs,m))}}return V}function Dr(d,o,m,b,T,$){if(!$)return;const V=Xl(Wl(b,$),T,m);V<o&&d.push([V,$,[0,0]])}function zl(d,o,m,b,T,$,V){if(!$||!V)return;const U=Xl(Wl(b,$),Wl(T,V),m);U<o&&d.push([U,$,V])}function qe(d,o,m,b,T=1/0){let $=Math.min(b.distance(d[0],m[0][0]),T);if($===0)return $;const V=new Rl([[0,[0,d.length-1],[0,0]]],Hi),U=_o(m);for(;V.length>0;){const ne=V.pop();if(ne[0]>=$)continue;const me=ne[1],ye=o?50:100;if(eo(me)<=ye){if(!Wr(me,d.length))return NaN;if(o){const Te=Ia(d,me,m,b);if(isNaN(Te)||Te===0)return Te;$=Math.min($,Te)}else for(let Te=me[0];Te<=me[1];++Te){const $e=Kl(d[Te],m,b);if($=Math.min($,$e),$===0)return 0}}else{const Te=Tc(me,o);Dr(V,$,b,d,U,Te[0]),Dr(V,$,b,d,U,Te[1])}}return $}function Xt(d,o,m,b,T,$=1/0){let V=Math.min($,T.distance(d[0],m[0]));if(V===0)return V;const U=new Rl([[0,[0,d.length-1],[0,m.length-1]]],Hi);for(;U.length>0;){const ne=U.pop();if(ne[0]>=V)continue;const me=ne[1],ye=ne[2],Te=o?50:100,$e=b?50:100;if(eo(me)<=Te&&eo(ye)<=$e){if(!Wr(me,d.length)&&Wr(ye,m.length))return NaN;let Ye;if(o&&b)Ye=Lc(d,me,m,ye,T),V=Math.min(V,Ye);else if(o&&!b){const et=d.slice(me[0],me[1]+1);for(let mt=ye[0];mt<=ye[1];++mt)if(Ye=pl(m[mt],et,T),V=Math.min(V,Ye),V===0)return V}else if(!o&&b){const et=m.slice(ye[0],ye[1]+1);for(let mt=me[0];mt<=me[1];++mt)if(Ye=pl(d[mt],et,T),V=Math.min(V,Ye),V===0)return V}else Ye=li(d,me,m,ye,T),V=Math.min(V,Ye)}else{const Ye=Tc(me,o),et=Tc(ye,b);zl(U,V,T,d,m,Ye[0],et[0]),zl(U,V,T,d,m,Ye[0],et[1]),zl(U,V,T,d,m,Ye[1],et[0]),zl(U,V,T,d,m,Ye[1],et[1])}}return V}function js(d){return d.type==="MultiPolygon"?d.coordinates.map(o=>({type:"Polygon",coordinates:o})):d.type==="MultiLineString"?d.coordinates.map(o=>({type:"LineString",coordinates:o})):d.type==="MultiPoint"?d.coordinates.map(o=>({type:"Point",coordinates:o})):[d]}class Rs{constructor(o,m){this.type=Jt,this.geojson=o,this.geometries=m}static parse(o,m){if(o.length!==2)return m.error(`'distance' expression requires exactly one argument, but found ${o.length-1} instead.`);if(qa(o[1])){const b=o[1];if(b.type==="FeatureCollection")return new Rs(b,b.features.map(T=>js(T.geometry)).flat());if(b.type==="Feature")return new Rs(b,js(b.geometry));if("type"in b&&"coordinates"in b)return new Rs(b,js(b))}return m.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(o){if(o.geometry()!=null&&o.canonicalID()!=null){if(o.geometryType()==="Point")return function(m,b){const T=m.geometry(),$=T.flat().map(ne=>na([ne.x,ne.y],m.canonical));if(T.length===0)return NaN;const V=new Zl($[0][1]);let U=1/0;for(const ne of b){switch(ne.type){case"Point":U=Math.min(U,Xt($,!1,[ne.coordinates],!1,V,U));break;case"LineString":U=Math.min(U,Xt($,!1,ne.coordinates,!0,V,U));break;case"Polygon":U=Math.min(U,qe($,!1,ne.coordinates,V,U))}if(U===0)return U}return U}(o,this.geometries);if(o.geometryType()==="LineString")return function(m,b){const T=m.geometry(),$=T.flat().map(ne=>na([ne.x,ne.y],m.canonical));if(T.length===0)return NaN;const V=new Zl($[0][1]);let U=1/0;for(const ne of b){switch(ne.type){case"Point":U=Math.min(U,Xt($,!0,[ne.coordinates],!1,V,U));break;case"LineString":U=Math.min(U,Xt($,!0,ne.coordinates,!0,V,U));break;case"Polygon":U=Math.min(U,qe($,!0,ne.coordinates,V,U))}if(U===0)return U}return U}(o,this.geometries);if(o.geometryType()==="Polygon")return function(m,b){const T=m.geometry();if(T.length===0||T[0].length===0)return NaN;const $=hi(T,0).map(ne=>ne.map(me=>me.map(ye=>na([ye.x,ye.y],m.canonical)))),V=new Zl($[0][0][0][1]);let U=1/0;for(const ne of b)for(const me of $){switch(ne.type){case"Point":U=Math.min(U,qe([ne.coordinates],!1,me,V,U));break;case"LineString":U=Math.min(U,qe(ne.coordinates,!0,me,V,U));break;case"Polygon":U=Math.min(U,fr(me,ne.coordinates,V,U))}if(U===0)return U}return U}(o,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}const la={"==":Nl,"!=":lr,">":ml,"<":Xi,">=":ti,"<=":Co,array:Na,at:Gr,boolean:Na,case:Yi,coalesce:kr,collator:qs,format:oa,image:Pa,in:Xr,"index-of":rn,interpolate:Gi,"interpolate-hcl":Gi,"interpolate-lab":Gi,length:mr,let:Ko,literal:Ar,match:In,number:Na,"number-format":Tn,object:Na,slice:jl,step:zo,string:Na,"to-boolean":sa,"to-color":sa,"to-number":sa,"to-string":sa,var:Za,within:Cl,distance:Rs};class Bn{constructor(o,m,b,T){this.name=o,this.type=m,this._evaluate=b,this.args=T}evaluate(o){return this._evaluate(o,this.args)}eachChild(o){this.args.forEach(o)}outputDefined(){return!1}static parse(o,m){const b=o[0],T=Bn.definitions[b];if(!T)return m.error(`Unknown expression "${b}". If you wanted a literal array, use ["literal", [...]].`,0);const $=Array.isArray(T)?T[0]:T.type,V=Array.isArray(T)?[[T[1],T[2]]]:T.overloads,U=V.filter(([me])=>!Array.isArray(me)||me.length===o.length-1);let ne=null;for(const[me,ye]of U){ne=new Tr(m.registry,Oo,m.path,null,m.scope);const Te=[];let $e=!1;for(let Ye=1;Ye<o.length;Ye++){const et=o[Ye],mt=Array.isArray(me)?me[Ye-1]:me.type,Tt=ne.parse(et,1+Te.length,mt);if(!Tt){$e=!0;break}Te.push(Tt)}if(!$e)if(Array.isArray(me)&&me.length!==Te.length)ne.error(`Expected ${me.length} arguments, but found ${Te.length} instead.`);else{for(let Ye=0;Ye<Te.length;Ye++){const et=Array.isArray(me)?me[Ye]:me.type,mt=Te[Ye];ne.concat(Ye+1).checkSubtype(et,mt.type)}if(ne.errors.length===0)return new Bn(b,$,ye,Te)}}if(U.length===1)m.errors.push(...ne.errors);else{const me=(U.length?U:V).map(([Te])=>{return $e=Te,Array.isArray($e)?`(${$e.map(je).join(", ")})`:`(${je($e.type)}...)`;var $e}).join(" | "),ye=[];for(let Te=1;Te<o.length;Te++){const $e=m.parse(o[Te],1+ye.length);if(!$e)return null;ye.push(je($e.type))}m.error(`Expected arguments of type ${me}, but found (${ye.join(", ")}) instead.`)}return null}static register(o,m){Bn.definitions=m;for(const b in m)o[b]=Bn}}function Rr(d,[o,m,b,T]){o=o.evaluate(d),m=m.evaluate(d),b=b.evaluate(d);const $=T?T.evaluate(d):1,V=Ha(o,m,b,$);if(V)throw new Zs(V);return new An(o/255,m/255,b/255,$,!1)}function Mc(d,o){return d in o}function Uo(d,o){const m=o[d];return m===void 0?null:m}function el(d){return{type:d}}function Oo(d){if(d instanceof Za)return Oo(d.boundExpression);if(d instanceof Bn&&d.name==="error"||d instanceof qs||d instanceof Cl||d instanceof Rs)return!1;const o=d instanceof sa||d instanceof Na;let m=!0;return d.eachChild(b=>{m=o?m&&Oo(b):m&&b instanceof Ar}),!!m&&yo(d)&&ci(d,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function yo(d){if(d instanceof Bn&&(d.name==="get"&&d.args.length===1||d.name==="feature-state"||d.name==="has"&&d.args.length===1||d.name==="properties"||d.name==="geometry-type"||d.name==="id"||/^filter-/.test(d.name))||d instanceof Cl||d instanceof Rs)return!1;let o=!0;return d.eachChild(m=>{o&&!yo(m)&&(o=!1)}),o}function gl(d){if(d instanceof Bn&&d.name==="feature-state")return!1;let o=!0;return d.eachChild(m=>{o&&!gl(m)&&(o=!1)}),o}function ci(d,o){if(d instanceof Bn&&o.indexOf(d.name)>=0)return!1;let m=!0;return d.eachChild(b=>{m&&!ci(b,o)&&(m=!1)}),m}function Eo(d){return{result:"success",value:d}}function tl(d){return{result:"error",value:d}}function xl(d){return d["property-type"]==="data-driven"||d["property-type"]==="cross-faded-data-driven"}function Bo(d){return!!d.expression&&d.expression.parameters.indexOf("zoom")>-1}function Jc(d){return!!d.expression&&d.expression.interpolated}function Cr(d){return d instanceof Number?"number":d instanceof String?"string":d instanceof Boolean?"boolean":Array.isArray(d)?"array":d===null?"null":typeof d}function Ic(d){return typeof d=="object"&&d!==null&&!Array.isArray(d)}function yu(d){return d}function Qd(d,o){const m=o.type==="color",b=d.stops&&typeof d.stops[0][0]=="object",T=b||!(b||d.property!==void 0),$=d.type||(Jc(o)?"exponential":"interval");if(m||o.type==="padding"){const ye=m?An.parse:Yr.parse;(d=Ns({},d)).stops&&(d.stops=d.stops.map(Te=>[Te[0],ye(Te[1])])),d.default=ye(d.default?d.default:o.default)}if(d.colorSpace&&(V=d.colorSpace)!=="rgb"&&V!=="hcl"&&V!=="lab")throw new Error(`Unknown color space: "${d.colorSpace}"`);var V;let U,ne,me;if($==="exponential")U=h;else if($==="interval")U=N;else if($==="categorical"){U=$o,ne=Object.create(null);for(const ye of d.stops)ne[ye[0]]=ye[1];me=typeof d.stops[0][0]}else{if($!=="identity")throw new Error(`Unknown function type "${$}"`);U=f}if(b){const ye={},Te=[];for(let et=0;et<d.stops.length;et++){const mt=d.stops[et],Tt=mt[0].zoom;ye[Tt]===void 0&&(ye[Tt]={zoom:Tt,type:d.type,property:d.property,default:d.default,stops:[]},Te.push(Tt)),ye[Tt].stops.push([mt[0].value,mt[1]])}const $e=[];for(const et of Te)$e.push([ye[et].zoom,Qd(ye[et],o)]);const Ye={name:"linear"};return{kind:"composite",interpolationType:Ye,interpolationFactor:Gi.interpolationFactor.bind(void 0,Ye),zoomStops:$e.map(et=>et[0]),evaluate:({zoom:et},mt)=>h({stops:$e,base:d.base},o,et).evaluate(et,mt)}}if(T){const ye=$==="exponential"?{name:"exponential",base:d.base!==void 0?d.base:1}:null;return{kind:"camera",interpolationType:ye,interpolationFactor:Gi.interpolationFactor.bind(void 0,ye),zoomStops:d.stops.map(Te=>Te[0]),evaluate:({zoom:Te})=>U(d,o,Te,ne,me)}}return{kind:"source",evaluate(ye,Te){const $e=Te&&Te.properties?Te.properties[d.property]:void 0;return $e===void 0?to(d.default,o.default):U(d,o,$e,ne,me)}}}function to(d,o,m){return d!==void 0?d:o!==void 0?o:m!==void 0?m:void 0}function $o(d,o,m,b,T){return to(typeof m===T?b[m]:void 0,d.default,o.default)}function N(d,o,m){if(Cr(m)!=="number")return to(d.default,o.default);const b=d.stops.length;if(b===1||m<=d.stops[0][0])return d.stops[0][1];if(m>=d.stops[b-1][0])return d.stops[b-1][1];const T=Si(d.stops.map($=>$[0]),m);return d.stops[T][1]}function h(d,o,m){const b=d.base!==void 0?d.base:1;if(Cr(m)!=="number")return to(d.default,o.default);const T=d.stops.length;if(T===1||m<=d.stops[0][0])return d.stops[0][1];if(m>=d.stops[T-1][0])return d.stops[T-1][1];const $=Si(d.stops.map(ye=>ye[0]),m),V=function(ye,Te,$e,Ye){const et=Ye-$e,mt=ye-$e;return et===0?0:Te===1?mt/et:(Math.pow(Te,mt)-1)/(Math.pow(Te,et)-1)}(m,b,d.stops[$][0],d.stops[$+1][0]),U=d.stops[$][1],ne=d.stops[$+1][1],me=Zr[o.type]||yu;return typeof U.evaluate=="function"?{evaluate(...ye){const Te=U.evaluate.apply(void 0,ye),$e=ne.evaluate.apply(void 0,ye);if(Te!==void 0&&$e!==void 0)return me(Te,$e,V,d.colorSpace)}}:me(U,ne,V,d.colorSpace)}function f(d,o,m){switch(o.type){case"color":m=An.parse(m);break;case"formatted":m=ei.fromString(m.toString());break;case"resolvedImage":m=Ka.fromString(m.toString());break;case"padding":m=Yr.parse(m);break;default:Cr(m)===o.type||o.type==="enum"&&o.values[m]||(m=void 0)}return to(m,d.default,o.default)}Bn.register(la,{error:[{kind:"error"},[Vs],(d,[o])=>{throw new Zs(o.evaluate(d))}],typeof:[Vs,[ds],(d,[o])=>je(Mn(o.evaluate(d)))],"to-rgba":[Pe(Jt,4),[nt],(d,[o])=>{const[m,b,T,$]=o.evaluate(d).rgb;return[255*m,255*b,255*T,$]}],rgb:[nt,[Jt,Jt,Jt],Rr],rgba:[nt,[Jt,Jt,Jt,Jt],Rr],has:{type:ps,overloads:[[[Vs],(d,[o])=>Mc(o.evaluate(d),d.properties())],[[Vs,ts],(d,[o,m])=>Mc(o.evaluate(d),m.evaluate(d))]]},get:{type:ds,overloads:[[[Vs],(d,[o])=>Uo(o.evaluate(d),d.properties())],[[Vs,ts],(d,[o,m])=>Uo(o.evaluate(d),m.evaluate(d))]]},"feature-state":[ds,[Vs],(d,[o])=>Uo(o.evaluate(d),d.featureState||{})],properties:[ts,[],d=>d.properties()],"geometry-type":[Vs,[],d=>d.geometryType()],id:[ds,[],d=>d.id()],zoom:[Jt,[],d=>d.globals.zoom],"heatmap-density":[Jt,[],d=>d.globals.heatmapDensity||0],"line-progress":[Jt,[],d=>d.globals.lineProgress||0],accumulated:[ds,[],d=>d.globals.accumulated===void 0?null:d.globals.accumulated],"+":[Jt,el(Jt),(d,o)=>{let m=0;for(const b of o)m+=b.evaluate(d);return m}],"*":[Jt,el(Jt),(d,o)=>{let m=1;for(const b of o)m*=b.evaluate(d);return m}],"-":{type:Jt,overloads:[[[Jt,Jt],(d,[o,m])=>o.evaluate(d)-m.evaluate(d)],[[Jt],(d,[o])=>-o.evaluate(d)]]},"/":[Jt,[Jt,Jt],(d,[o,m])=>o.evaluate(d)/m.evaluate(d)],"%":[Jt,[Jt,Jt],(d,[o,m])=>o.evaluate(d)%m.evaluate(d)],ln2:[Jt,[],()=>Math.LN2],pi:[Jt,[],()=>Math.PI],e:[Jt,[],()=>Math.E],"^":[Jt,[Jt,Jt],(d,[o,m])=>Math.pow(o.evaluate(d),m.evaluate(d))],sqrt:[Jt,[Jt],(d,[o])=>Math.sqrt(o.evaluate(d))],log10:[Jt,[Jt],(d,[o])=>Math.log(o.evaluate(d))/Math.LN10],ln:[Jt,[Jt],(d,[o])=>Math.log(o.evaluate(d))],log2:[Jt,[Jt],(d,[o])=>Math.log(o.evaluate(d))/Math.LN2],sin:[Jt,[Jt],(d,[o])=>Math.sin(o.evaluate(d))],cos:[Jt,[Jt],(d,[o])=>Math.cos(o.evaluate(d))],tan:[Jt,[Jt],(d,[o])=>Math.tan(o.evaluate(d))],asin:[Jt,[Jt],(d,[o])=>Math.asin(o.evaluate(d))],acos:[Jt,[Jt],(d,[o])=>Math.acos(o.evaluate(d))],atan:[Jt,[Jt],(d,[o])=>Math.atan(o.evaluate(d))],min:[Jt,el(Jt),(d,o)=>Math.min(...o.map(m=>m.evaluate(d)))],max:[Jt,el(Jt),(d,o)=>Math.max(...o.map(m=>m.evaluate(d)))],abs:[Jt,[Jt],(d,[o])=>Math.abs(o.evaluate(d))],round:[Jt,[Jt],(d,[o])=>{const m=o.evaluate(d);return m<0?-Math.round(-m):Math.round(m)}],floor:[Jt,[Jt],(d,[o])=>Math.floor(o.evaluate(d))],ceil:[Jt,[Jt],(d,[o])=>Math.ceil(o.evaluate(d))],"filter-==":[ps,[Vs,ds],(d,[o,m])=>d.properties()[o.value]===m.value],"filter-id-==":[ps,[ds],(d,[o])=>d.id()===o.value],"filter-type-==":[ps,[Vs],(d,[o])=>d.geometryType()===o.value],"filter-<":[ps,[Vs,ds],(d,[o,m])=>{const b=d.properties()[o.value],T=m.value;return typeof b==typeof T&&b<T}],"filter-id-<":[ps,[ds],(d,[o])=>{const m=d.id(),b=o.value;return typeof m==typeof b&&m<b}],"filter->":[ps,[Vs,ds],(d,[o,m])=>{const b=d.properties()[o.value],T=m.value;return typeof b==typeof T&&b>T}],"filter-id->":[ps,[ds],(d,[o])=>{const m=d.id(),b=o.value;return typeof m==typeof b&&m>b}
1961],"filter-<=":[ps,[Vs,ds],(d,[o,m])=>{const b=d.properties()[o.value],T=m.value;return typeof b==typeof T&&b<=T}],"filter-id-<=":[ps,[ds],(d,[o])=>{const m=d.id(),b=o.value;return typeof m==typeof b&&m<=b}],"filter->=":[ps,[Vs,ds],(d,[o,m])=>{const b=d.properties()[o.value],T=m.value;return typeof b==typeof T&&b>=T}],"filter-id->=":[ps,[ds],(d,[o])=>{const m=d.id(),b=o.value;return typeof m==typeof b&&m>=b}],"filter-has":[ps,[ds],(d,[o])=>o.value in d.properties()],"filter-has-id":[ps,[],d=>d.id()!==null&&d.id()!==void 0],"filter-type-in":[ps,[Pe(Vs)],(d,[o])=>o.value.indexOf(d.geometryType())>=0],"filter-id-in":[ps,[Pe(ds)],(d,[o])=>o.value.indexOf(d.id())>=0],"filter-in-small":[ps,[Vs,Pe(ds)],(d,[o,m])=>m.value.indexOf(d.properties()[o.value])>=0],"filter-in-large":[ps,[Vs,Pe(ds)],(d,[o,m])=>function(b,T,$,V){for(;$<=V;){const U=$+V>>1;if(T[U]===b)return!0;T[U]>b?V=U-1:$=U+1}return!1}(d.properties()[o.value],m.value,0,m.value.length-1)],all:{type:ps,overloads:[[[ps,ps],(d,[o,m])=>o.evaluate(d)&&m.evaluate(d)],[el(ps),(d,o)=>{for(const m of o)if(!m.evaluate(d))return!1;return!0}]]},any:{type:ps,overloads:[[[ps,ps],(d,[o,m])=>o.evaluate(d)||m.evaluate(d)],[el(ps),(d,o)=>{for(const m of o)if(m.evaluate(d))return!0;return!1}]]},"!":[ps,[ps],(d,[o])=>!o.evaluate(d)],"is-supported-script":[ps,[Vs],(d,[o])=>{const m=d.globals&&d.globals.isSupportedScript;return!m||m(o.evaluate(d))}],upcase:[Vs,[Vs],(d,[o])=>o.evaluate(d).toUpperCase()],downcase:[Vs,[Vs],(d,[o])=>o.evaluate(d).toLowerCase()],concat:[Vs,el(ds),(d,o)=>o.map(m=>_r(m.evaluate(d))).join("")],"resolved-locale":[Vs,[Is],(d,[o])=>o.evaluate(d).resolvedLocale()]});class w{constructor(o,m){var b;this.expression=o,this._warningHistory={},this._evaluator=new oi,this._defaultValue=m?(b=m).type==="color"&&Ic(b.default)?new An(0,0,0,0):b.type==="color"?An.parse(b.default)||null:b.type==="padding"?Yr.parse(b.default)||null:b.type==="variableAnchorOffsetCollection"?ra.parse(b.default)||null:b.default===void 0?null:b.default:null,this._enumValues=m&&m.type==="enum"?m.values:null}evaluateWithoutErrorHandling(o,m,b,T,$,V){return this._evaluator.globals=o,this._evaluator.feature=m,this._evaluator.featureState=b,this._evaluator.canonical=T,this._evaluator.availableImages=$||null,this._evaluator.formattedSection=V,this.expression.evaluate(this._evaluator)}evaluate(o,m,b,T,$,V){this._evaluator.globals=o,this._evaluator.feature=m||null,this._evaluator.featureState=b||null,this._evaluator.canonical=T,this._evaluator.availableImages=$||null,this._evaluator.formattedSection=V||null;try{const U=this.expression.evaluate(this._evaluator);if(U==null||typeof U=="number"&&U!=U)return this._defaultValue;if(this._enumValues&&!(U in this._enumValues))throw new Zs(`Expected value to be one of ${Object.keys(this._enumValues).map(ne=>JSON.stringify(ne)).join(", ")}, but found ${JSON.stringify(U)} instead.`);return U}catch(U){return this._warningHistory[U.message]||(this._warningHistory[U.message]=!0,typeof console<"u"&&console.warn(U.message)),this._defaultValue}}}function G(d){return Array.isArray(d)&&d.length>0&&typeof d[0]=="string"&&d[0]in la}function re(d,o){const m=new Tr(la,Oo,[],o?function(T){const $={color:nt,string:Vs,number:Jt,enum:Vs,boolean:ps,formatted:tn,padding:wn,resolvedImage:Gs,variableAnchorOffsetCollection:Ue};return T.type==="array"?Pe($[T.value]||ds,T.length):$[T.type]}(o):void 0),b=m.parse(d,void 0,void 0,void 0,o&&o.type==="string"?{typeAnnotation:"coerce"}:void 0);return b?Eo(new w(b,o)):tl(m.errors)}class xe{constructor(o,m){this.kind=o,this._styleExpression=m,this.isStateDependent=o!=="constant"&&!gl(m.expression)}evaluateWithoutErrorHandling(o,m,b,T,$,V){return this._styleExpression.evaluateWithoutErrorHandling(o,m,b,T,$,V)}evaluate(o,m,b,T,$,V){return this._styleExpression.evaluate(o,m,b,T,$,V)}}class Ae{constructor(o,m,b,T){this.kind=o,this.zoomStops=b,this._styleExpression=m,this.isStateDependent=o!=="camera"&&!gl(m.expression),this.interpolationType=T}evaluateWithoutErrorHandling(o,m,b,T,$,V){return this._styleExpression.evaluateWithoutErrorHandling(o,m,b,T,$,V)}evaluate(o,m,b,T,$,V){return this._styleExpression.evaluate(o,m,b,T,$,V)}interpolationFactor(o,m,b){return this.interpolationType?Gi.interpolationFactor(this.interpolationType,o,m,b):0}}function tt(d,o){const m=re(d,o);if(m.result==="error")return m;const b=m.value.expression,T=yo(b);if(!T&&!xl(o))return tl([new Ts("","data expressions not supported")]);const $=ci(b,["zoom"]);if(!$&&!Bo(o))return tl([new Ts("","zoom expressions not supported")]);const V=Ut(b);return V||$?V instanceof Ts?tl([V]):V instanceof Gi&&!Jc(o)?tl([new Ts("",'"interpolate" expressions cannot be used with this property')]):Eo(V?new Ae(T?"camera":"composite",m.value,V.labels,V instanceof Gi?V.interpolation:void 0):new xe(T?"constant":"source",m.value)):tl([new Ts("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Nt{constructor(o,m){this._parameters=o,this._specification=m,Ns(this,Qd(this._parameters,this._specification))}static deserialize(o){return new Nt(o._parameters,o._specification)}static serialize(o){return{_parameters:o._parameters,_specification:o._specification}}}function Ut(d){let o=null;if(d instanceof Ko)o=Ut(d.result);else if(d instanceof kr){for(const m of d.args)if(o=Ut(m),o)break}else(d instanceof zo||d instanceof Gi)&&d.input instanceof Bn&&d.input.name==="zoom"&&(o=d);return o instanceof Ts||d.eachChild(m=>{const b=Ut(m);b instanceof Ts?o=b:!o&&b?o=new Ts("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):o&&b&&o!==b&&(o=new Ts("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),o}
vendor: 4,504 bytes, line 1961
1961function xs(d){if(d===!0||d===!1)return!0;if(!Array.isArray(d)||d.length===0)return!1;switch(d[0]){case"has":return d.length>=2&&d[1]!=="$id"&&d[1]!=="$type";case"in":return d.length>=3&&(typeof d[1]!="string"||Array.isArray(d[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return d.length!==3||Array.isArray(d[1])||Array.isArray(d[2]);case"any":case"all":for(const o of d.slice(1))if(!xs(o)&&typeof o!="boolean")return!1;return!0;default:return!0}}const $s={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function bn(d){if(d==null)return{filter:()=>!0,needGeometry:!1};xs(d)||(d=Lr(d));const o=re(d,$s);if(o.result==="error")throw new Error(o.value.map(m=>`${m.key}: ${m.message}`).join(", "));return{filter:(m,b,T)=>o.value.evaluate(m,b,{},T),needGeometry:wa(d)}}function da(d,o){return d<o?-1:d>o?1:0}function wa(d){if(!Array.isArray(d))return!1;if(d[0]==="within"||d[0]==="distance")return!0;for(let o=1;o<d.length;o++)if(wa(d[o]))return!0;return!1}function Lr(d){if(!d)return!0;const o=d[0];return d.length<=1?o!=="any":o==="=="?ur(d[1],d[2],"=="):o==="!="?hr(ur(d[1],d[2],"==")):o==="<"||o===">"||o==="<="||o===">="?ur(d[1],d[2],o):o==="any"?(m=d.slice(1),["any"].concat(m.map(Lr))):o==="all"?["all"].concat(d.slice(1).map(Lr)):o==="none"?["all"].concat(d.slice(1).map(Lr).map(hr)):o==="in"?si(d[1],d.slice(2)):o==="!in"?hr(si(d[1],d.slice(2))):o==="has"?Ei(d[1]):o!=="!has"||hr(Ei(d[1]));var m}function ur(d,o,m){switch(d){case"$type":return[`filter-type-${m}`,o];case"$id":return[`filter-id-${m}`,o];default:return[`filter-${m}`,d,o]}}function si(d,o){if(o.length===0)return!1;switch(d){case"$type":return["filter-type-in",["literal",o]];case"$id":return["filter-id-in",["literal",o]];default:return o.length>200&&!o.some(m=>typeof m!=typeof o[0])?["filter-in-large",d,["literal",o.sort(da)]]:["filter-in-small",d,["literal",o]]}}function Ei(d){switch(d){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",d]}}function hr(d){return["!",d]}function mo(d){const o=typeof d;if(o==="number"||o==="boolean"||o==="string"||d==null)return JSON.stringify(d);if(Array.isArray(d)){let T="[";for(const $ of d)T+=`${mo($)},`;return`${T}]`}const m=Object.keys(d).sort();let b="{";for(let T=0;T<m.length;T++)b+=`${JSON.stringify(m[T])}:${mo(d[m[T]])},`;return`${b}}`}function Ud(d){let o="";for(const m of as)o+=`/${mo(d[m])}`;return o}function mc(d){const o=d.value;return o?[new $t(d.key,o,"constants have been deprecated as of v8")]:[]}function _i(d){return d instanceof Number||d instanceof String||d instanceof Boolean?d.valueOf():d}function sl(d){if(Array.isArray(d))return d.map(sl);if(d instanceof Object&&!(d instanceof Number||d instanceof String||d instanceof Boolean)){const o={};for(const m in d)o[m]=sl(d[m]);return o}return _i(d)}function Ba(d){const o=d.key,m=d.value,b=d.valueSpec||{},T=d.objectElementValidators||{},$=d.style,V=d.styleSpec,U=d.validateSpec;let ne=[];const me=Cr(m);if(me!=="object")return[new $t(o,m,`object expected, ${me} found`)];for(const ye in m){const Te=ye.split(".")[0],$e=b[Te]||b["*"];let Ye;if(T[Te])Ye=T[Te];else if(b[Te])Ye=U;else if(T["*"])Ye=T["*"];else{if(!b["*"]){ne.push(new $t(o,m[ye],`unknown property "${ye}"`));continue}Ye=U}ne=ne.concat(Ye({key:(o&&`${o}.`)+ye,value:m[ye],valueSpec:$e,style:$,styleSpec:V,object:m,objectKey:ye,validateSpec:U},m))}for(const ye in b)T[ye]||b[ye].required&&b[ye].default===void 0&&m[ye]===void 0&&ne.push(new $t(o,m,`missing required property "${ye}"`));return ne}function xd(d){const o=d.value,m=d.valueSpec,b=d.style,T=d.styleSpec,$=d.key,V=d.arrayElementValidator||d.validateSpec;if(Cr(o)!=="array")return[new $t($,o,`array expected, ${Cr(o)} found`)];if(m.length&&o.length!==m.length)return[new $t($,o,`array length ${m.length} expected, length ${o.length} found`)];if(m["min-length"]&&o.length<m["min-length"])return[new $t($,o,`array length at least ${m["min-length"]} expected, length ${o.length} found`)];let U={type:m.value,values:m.values};T.$version<7&&(U.function=m.function),Cr(m.value)==="object"&&(U=m.value);let ne=[];for(let me=0;me<o.length;me++)ne=ne.concat(V({array:o,arrayIndex:me,value:o[me],valueSpec:U,validateSpec:d.validateSpec,style:b,styleSpec:T,key:`${$}[${me}]`}));return ne}function nl(d){const o=d.key,m=d.value,b=d.valueSpec;let T=Cr(m);return T==="number"&&m!=m&&(T="NaN"),T!=="number"?[new $t(o,m,`number expected, ${T}
1961 found`)]:"minimum"in b&&m<b.minimum?[new $t(o,m,`${m} is less than the minimum value ${b.minimum}`)]:"maximum"in b&&m>b.maximum?[new $t(o,m,`${m} is greater than the maximum value ${b.maximum}`)]:[]}function so(d){const o=d.valueSpec,m=_i(d.value.type);let b,T,$,V={};const U=m!=="categorical"&&d.value.property===void 0,ne=!U,me=Cr(d.value.stops)==="array"&&Cr(d.value.stops[0])==="array"&&Cr(d.value.stops[0][0])==="object",ye=Ba({key:d.key,value:d.value,valueSpec:d.styleSpec.function,validateSpec:d.validateSpec,style:d.style,styleSpec:d.styleSpec,objectElementValidators:{stops:function(Ye){if(m==="identity")return[new $t(Ye.key,Ye.value,'identity function may not have a "stops" property')];let et=[];const mt=Ye.value;return et=et.concat(xd({key:Ye.key,value:mt,valueSpec:Ye.valueSpec,validateSpec:Ye.validateSpec,style:Ye.style,styleSpec:Ye.styleSpec,arrayElementValidator:Te})),Cr(mt)==="array"&&mt.length===0&&et.push(new $t(Ye.key,mt,"array must have at least one stop")),et},default:function(Ye){return Ye.validateSpec({key:Ye.key,value:Ye.value,valueSpec:o,validateSpec:Ye.validateSpec,style:Ye.style,styleSpec:Ye.styleSpec})}}});return m==="identity"&&U&&ye.push(new $t(d.key,d.value,'missing required property "property"')),m==="identity"||d.value.stops||ye.push(new $t(d.key,d.value,'missing required property "stops"')),m==="exponential"&&d.valueSpec.expression&&!Jc(d.valueSpec)&&ye.push(new $t(d.key,d.value,"exponential functions not supported")),d.styleSpec.$version>=8&&(ne&&!xl(d.valueSpec)?ye.push(new $t(d.key,d.value,"property functions not supported")):U&&!Bo(d.valueSpec)&&ye.push(new $t(d.key,d.value,"zoom functions not supported"))),m!=="categorical"&&!me||d.value.property!==void 0||ye.push(new $t(d.key,d.value,'"property" property is required')),ye;function Te(Ye){let et=[];const mt=Ye.value,Tt=Ye.key;if(Cr(mt)!=="array")return[new $t(Tt,mt,`array expected, ${Cr(mt)} found`)];if(mt.length!==2)return[new $t(Tt,mt,`array length 2 expected, length ${mt.length} found`)];if(me){if(Cr(mt[0])!=="object")return[new $t(Tt,mt,`object expected, ${Cr(mt[0])} found`)];if(mt[0].zoom===void 0)return[new $t(Tt,mt,"object stop key must have zoom")];if(mt[0].value===void 0)return[new $t(Tt,mt,"object stop key must have value")];if($&&$>_i(mt[0].zoom))return[new $t(Tt,mt[0].zoom,"stop zoom values must appear in ascending order")];_i(mt[0].zoom)!==$&&($=_i(mt[0].zoom),T=void 0,V={}),et=et.concat(Ba({key:`${Tt}[0]`,value:mt[0],valueSpec:{zoom:{}},validateSpec:Ye.validateSpec,style:Ye.style,styleSpec:Ye.styleSpec,objectElementValidators:{zoom:nl,value:$e}}))}else et=et.concat($e({key:`${Tt}[0]`,value:mt[0],valueSpec:{},validateSpec:Ye.validateSpec,style:Ye.style,styleSpec:Ye.styleSpec},mt));return G(sl(mt[1]))?et.concat([new $t(`${Tt}[1]`,mt[1],"expressions are not allowed in function stops.")]):et.concat(Ye.validateSpec({key:`${Tt}[1]`,value:mt[1],valueSpec:o,validateSpec:Ye.validateSpec,style:Ye.style,styleSpec:Ye.styleSpec}))}function $e(Ye,et){const mt=Cr(Ye.value),Tt=_i(Ye.value),Ot=Ye.value!==null?Ye.value:et;if(b){if(mt!==b)return[new $t(Ye.key,Ot,`${mt} stop domain type must match previous stop domain type ${b}`)]}else b=mt;if(mt!=="number"&&mt!=="string"&&mt!=="boolean")return[new $t(Ye.key,Ot,"stop domain value must be a number, string, or boolean")];if(mt!=="number"&&m!=="categorical"){let gs=`number expected, ${mt} found`;return xl(o)&&m===void 0&&(gs+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new $t(Ye.key,Ot,gs)]}return m!=="categorical"||mt!=="number"||isFinite(Tt)&&Math.floor(Tt)===Tt?m!=="categorical"&&mt==="number"&&T!==void 0&&Tt<T?[new $t(Ye.key,Ot,"stop domain values must appear in ascending order")]:(T=Tt,m==="categorical"&&Tt in V?[new $t(Ye.key,Ot,"stop domain values must be unique")]:(V[Tt]=!0,[])):[new $t(Ye.key,Ot,`integer expected, found ${Tt}`)]}}function Qc(d){const o=(d.expressionContext==="property"?tt:re)(sl(d.value),d.valueSpec);if(o.result==="error")return o.value.map(b=>new $t(`${d.key}${b.key}`,d.value,b.message));const m=o.value.expression||o.value._styleExpression.expression;if(d.expressionContext==="property"&&d.propertyKey==="text-font"&&!m.outputDefined())return[new $t(d.key,d.value,`Invalid data expression for "${d.propertyKey}". Output values must be contained as literals within the expression.`)];if(d.expressionContext==="property"&&d.propertyType==="layout"&&!gl(m))return[new $t(d.key,d.value,'"feature-state" data expressions are not supported with layout properties.')];if(d.expressionContext==="filter"&&!gl(m))return[new $t(d.key,d.value,'"feature-state" data expressions are not supported with filters.')];if(d.expressionContext&&d.expressionContext.indexOf("cluster")===0){if(!ci(m,["zoom","feature-state"]))return[new $t(d.key,d.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(d.expressionContext==="cluster-initial"&&!yo(m))return[new $t(d.key,d.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function _d(d){const o=d.key,m=d.value,b=d.valueSpec,T=[];return Array.isArray(b.values)?b.values.indexOf(_i(m))===-1&&T.push(new $t(o,m,`expected one of [${b.values.join(", ")}], ${JSON.stringify(m)} found`)):Object.keys(b.values).indexOf(_i(m))===-1&&T.push(new $t(o,m,`expected one of [${Object.keys(b.values).join(", ")}], ${JSON.stringify(m)} found`)),T}function ai(d){return xs(sl(d.value))?Qc(Ns({},d,{expressionContext:"filter",valueSpec:{value:"boolean"}})):eu(d)}function eu(d){const o=d.value,m=d.key;if(Cr(o)!=="array")return[new $t(m,o,`array expected, ${Cr(o)} found`)];const b=d.styleSpec;let T,$=[];if(o.length<1)return[new $t(m,o,"filter array must have at least 1 element")];switch($=$.concat(_d({key:`${m}[0]`,value:o[0],valueSpec:b.filter_operator,style:d.style,styleSpec:d.styleSpec})),_i(o[0])){case"<":case"<=":case">":case">=":o.length>=2&&_i(o[1])==="$type"&&$.push(new $t(m,o,`"$type" cannot be use with operator "${o[0]}"`));case"==":case"!=":o.length!==3&&$.push(new $t(m,o,`filter array for operator "${o[0]}" must have 3 elements`));case"in":case"!in":o.length>=2&&(T=Cr(o[1]),T!=="string"&&$.push(new $t(`${m}[1]`,o[1],`string expected, ${T}
1961 found`)));for(let V=2;V<o.length;V++)T=Cr(o[V]),_i(o[1])==="$type"?$=$.concat(_d({key:`${m}[${V}]`,value:o[V],valueSpec:b.geometry_type,style:d.style,styleSpec:d.styleSpec})):T!=="string"&&T!=="number"&&T!=="boolean"&&$.push(new $t(`${m}[${V}]`,o[V],`string, number, or boolean expected, ${T} found`));break;case"any":case"all":case"none":for(let V=1;V<o.length;V++)$=$.concat(eu({key:`${m}[${V}]`,value:o[V],style:d.style,styleSpec:d.styleSpec}));break;case"has":case"!has":T=Cr(o[1]),o.length!==2?$.push(new $t(m,o,`filter array for "${o[0]}" operator must have 2 elements`)):T!=="string"&&$.push(new $t(`${m}[1]`,o[1],`string expected, ${T} found`))}return $}function Vr(d,o){const m=d.key,b=d.validateSpec,T=d.style,$=d.styleSpec,V=d.value,U=d.objectKey,ne=$[`${o}_${d.layerType}`];if(!ne)return[];const me=U.match(/^(.*)-transition$/);if(o==="paint"&&me&&ne[me[1]]&&ne[me[1]].transition)return b({key:m,value:V,valueSpec:$.transition,style:T,styleSpec:$});const ye=d.valueSpec||ne[U];if(!ye)return[new $t(m,V,`unknown property "${U}"`)];let Te;if(Cr(V)==="string"&&xl(ye)&&!ye.tokens&&(Te=/^{([^}]+)}$/.exec(V)))return[new $t(m,V,`"${U}" does not support interpolation syntax
1962Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(Te[1])} }\`.`)];const $e=[];return d.layerType==="symbol"&&(U==="text-field"&&T&&!T.glyphs&&$e.push(new $t(m,V,'use of "text-field" requires a style "glyphs" property')),U==="text-font"&&Ic(sl(V))&&_i(V.type)==="identity"&&$e.push(new $t(m,V,'"text-font" does not support identity functions'))),$e.concat(b({key:d.key,value:V,valueSpec:ye,style:T,styleSpec:$,expressionContext:"property",propertyType:o,propertyKey:U}))}function Fi(d){return Vr(d,"paint")}function ri(d){return Vr(d,"layout")}function vo(d){let o=[];const m=d.value,b=d.key,T=d.style,$=d.styleSpec;m.type||m.ref||o.push(new $t(b,m,'either "type" or "ref" is required'));let V=_i(m.type);const U=_i(m.ref);if(m.id){const ne=_i(m.id);for(let me=0;me<d.arrayIndex;me++){const ye=T.layers[me];_i(ye.id)===ne&&o.push(new $t(b,m.id,`duplicate layer id "${m.id}", previously used at line ${ye.id.__line__}`))}}if("ref"in m){let ne;["type","source","source-layer","filter","layout"].forEach(me=>{me in m&&o.push(new $t(b,m[me],`"${me}" is prohibited for ref layers`))}),T.layers.forEach(me=>{_i(me.id)===U&&(ne=me)}),ne?ne.ref?o.push(new $t(b,m.ref,"ref cannot reference another ref layer")):V=_i(ne.type):o.push(new $t(b,m.ref,`ref layer "${U}" not found`))}else if(V!=="background")if(m.source){const ne=T.sources&&T.sources[m.source],me=ne&&_i(ne.type);ne?me==="vector"&&V==="raster"?o.push(new $t(b,m.source,`layer "${m.id}" requires a raster source`)):me!=="raster-dem"&&V==="hillshade"?o.push(new $t(b,m.source,`layer "${m.id}" requires a raster-dem source`)):me==="raster"&&V!=="raster"?o.push(new $t(b,m.source,`layer "${m.id}" requires a vector source`)):me!=="vector"||m["source-layer"]?me==="raster-dem"&&V!=="hillshade"?o.push(new $t(b,m.source,"raster-dem source can only be used with layer type 'hillshade'.")):V!=="line"||!m.paint||!m.paint["line-gradient"]||me==="geojson"&&ne.lineMetrics||o.push(new $t(b,m,`layer "${m.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):o.push(new $t(b,m,`layer "${m.id}" must specify a "source-layer"`)):o.push(new $t(b,m.source,`source "${m.source}" not found`))}else o.push(new $t(b,m,'missing required property "source"'));return o=o.concat(Ba({key:b,value:m,valueSpec:$.layer,style:d.style,styleSpec:d.styleSpec,validateSpec:d.validateSpec,objectElementValidators:{"*":()=>[],type:()=>d.validateSpec({key:`${b}.type`,value:m.type,valueSpec:$.layer.type,style:d.style,styleSpec:d.styleSpec,validateSpec:d.validateSpec,object:m,objectKey:"type"}),filter:ai,layout:ne=>Ba({layer:m,key:ne.key,value:ne.value,style:ne.style,styleSpec:ne.styleSpec,validateSpec:ne.validateSpec,objectElementValidators:{"*":me=>ri(Ns({layerType:V},me))}}),paint:ne=>Ba({layer:m,key:ne.key,value:ne.value,style:ne.style,styleSpec:ne.styleSpec,validateSpec:ne.validateSpec,objectElementValidators:{"*":me=>Fi(Ns({layerType:V},me))}})}})),o}function vu(d){const o=d.value,m=d.key,b=Cr(o);return b!=="string"?[new $t(m,o,`string expected, ${b} found`)]:[]}const tu={promoteId:function({key:d,value:o}
vendor: 10,745 bytes, line 1962
1962){if(Cr(o)==="string")return vu({key:d,value:o});{const m=[];for(const b in o)m.push(...vu({key:`${d}.${b}`,value:o[b]}));return m}}};function bu(d){const o=d.value,m=d.key,b=d.styleSpec,T=d.style,$=d.validateSpec;if(!o.type)return[new $t(m,o,'"type" is required')];const V=_i(o.type);let U;switch(V){case"vector":case"raster":return U=Ba({key:m,value:o,valueSpec:b[`source_${V.replace("-","_")}`],style:d.style,styleSpec:b,objectElementValidators:tu,validateSpec:$}),U;case"raster-dem":return U=function(ne){var me;const ye=(me=ne.sourceName)!==null&&me!==void 0?me:"",Te=ne.value,$e=ne.styleSpec,Ye=$e.source_raster_dem,et=ne.style;let mt=[];const Tt=Cr(Te);if(Te===void 0)return mt;if(Tt!=="object")return mt.push(new $t("source_raster_dem",Te,`object expected, ${Tt} found`)),mt;const Ot=_i(Te.encoding)==="custom",gs=["redFactor","greenFactor","blueFactor","baseShift"],Yt=ne.value.encoding?`"${ne.value.encoding}"`:"Default";for(const ls in Te)!Ot&&gs.includes(ls)?mt.push(new $t(ls,Te[ls],`In "${ye}": "${ls}" is only valid when "encoding" is set to "custom". ${Yt} encoding found`)):Ye[ls]?mt=mt.concat(ne.validateSpec({key:ls,value:Te[ls],valueSpec:Ye[ls],validateSpec:ne.validateSpec,style:et,styleSpec:$e})):mt.push(new $t(ls,Te[ls],`unknown property "${ls}"`));return mt}({sourceName:m,value:o,style:d.style,styleSpec:b,validateSpec:$}),U;case"geojson":if(U=Ba({key:m,value:o,valueSpec:b.source_geojson,style:T,styleSpec:b,validateSpec:$,objectElementValidators:tu}),o.cluster)for(const ne in o.clusterProperties){const[me,ye]=o.clusterProperties[ne],Te=typeof me=="string"?[me,["accumulated"],["get",ne]]:me;U.push(...Qc({key:`${m}.${ne}.map`,value:ye,validateSpec:$,expressionContext:"cluster-map"})),U.push(...Qc({key:`${m}.${ne}.reduce`,value:Te,validateSpec:$,expressionContext:"cluster-reduce"}))}return U;case"video":return Ba({key:m,value:o,valueSpec:b.source_video,style:T,validateSpec:$,styleSpec:b});case"image":return Ba({key:m,value:o,valueSpec:b.source_image,style:T,validateSpec:$,styleSpec:b});case"canvas":return[new $t(m,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return _d({key:`${m}.type`,value:o.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:T,validateSpec:$,styleSpec:b})}}function Bh(d){const o=d.value,m=d.styleSpec,b=m.light,T=d.style;let $=[];const V=Cr(o);if(o===void 0)return $;if(V!=="object")return $=$.concat([new $t("light",o,`object expected, ${V} found`)]),$;for(const U in o){const ne=U.match(/^(.*)-transition$/);$=$.concat(ne&&b[ne[1]]&&b[ne[1]].transition?d.validateSpec({key:U,value:o[U],valueSpec:m.transition,validateSpec:d.validateSpec,style:T,styleSpec:m}):b[U]?d.validateSpec({key:U,value:o[U],valueSpec:b[U],validateSpec:d.validateSpec,style:T,styleSpec:m}):[new $t(U,o[U],`unknown property "${U}"`)])}return $}function p(d){const o=d.value,m=d.styleSpec,b=m.sky,T=d.style,$=Cr(o);if(o===void 0)return[];if($!=="object")return[new $t("sky",o,`object expected, ${$} found`)];let V=[];for(const U in o)V=V.concat(b[U]?d.validateSpec({key:U,value:o[U],valueSpec:b[U],style:T,styleSpec:m}):[new $t(U,o[U],`unknown property "${U}"`)]);return V}function M(d){const o=d.value,m=d.styleSpec,b=m.terrain,T=d.style;let $=[];const V=Cr(o);if(o===void 0)return $;if(V!=="object")return $=$.concat([new $t("terrain",o,`object expected, ${V} found`)]),$;for(const U in o)$=$.concat(b[U]?d.validateSpec({key:U,value:o[U],valueSpec:b[U],validateSpec:d.validateSpec,style:T,styleSpec:m}):[new $t(U,o[U],`unknown property "${U}"`)]);return $}function Y(d){let o=[];const m=d.value,b=d.key;if(Array.isArray(m)){const T=[],$=[];for(const V in m)m[V].id&&T.includes(m[V].id)&&o.push(new $t(b,m,`all the sprites' ids must be unique, but ${m[V].id} is duplicated`)),T.push(m[V].id),m[V].url&&$.includes(m[V].url)&&o.push(new $t(b,m,`all the sprites' URLs must be unique, but ${m[V].url} is duplicated`)),$.push(m[V].url),o=o.concat(Ba({key:`${b}[${V}]`,value:m[V],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:d.validateSpec}));return o}return vu({key:b,value:m})}const ue={"*":()=>[],array:xd,boolean:function(d){const o=d.value,m=d.key,b=Cr(o);return b!=="boolean"?[new $t(m,o,`boolean expected, ${b} found`)]:[]},number:nl,color:function(d){const o=d.key,m=d.value,b=Cr(m);return b!=="string"?[new $t(o,m,`color expected, ${b} found`)]:An.parse(String(m))?[]:[new $t(o,m,`color expected, "${m}" found`)]},constants:mc,enum:_d,filter:ai,function:so,layer:vo,object:Ba,source:bu,light:Bh,sky:p,terrain:M,projection:function(d){const o=d.value,m=d.styleSpec,b=m.projection,T=d.style,$=Cr(o);if(o===void 0)return[];if($!=="object")return[new $t("projection",o,`object expected, ${$} found`)];let V=[];for(const U in o)V=V.concat(b[U]?d.validateSpec({key:U,value:o[U],valueSpec:b[U],style:T,styleSpec:m}):[new $t(U,o[U],`unknown property "${U}"`)]);return V},string:vu,formatted:function(d){return vu(d).length===0?[]:Qc(d)},resolvedImage:function(d){return vu(d).length===0?[]:Qc(d)},padding:function(d){const o=d.key,m=d.value;if(Cr(m)==="array"){if(m.length<1||m.length>4)return[new $t(o,m,`padding requires 1 to 4 values; ${m.length} values found`)];const b={type:"number"};let T=[];for(let $=0;$<m.length;$++)T=T.concat(d.validateSpec({key:`${o}[${$}]`,value:m[$],validateSpec:d.validateSpec,valueSpec:b}));return T}return nl({key:o,value:m,valueSpec:{}})},variableAnchorOffsetCollection:function(d){const o=d.key,m=d.value,b=Cr(m),T=d.styleSpec;if(b!=="array"||m.length<1||m.length%2!=0)return[new $t(o,m,"variableAnchorOffsetCollection requires a non-empty array of even length")];let $=[];for(let V=0;V<m.length;V+=2)$=$.concat(_d({key:`${o}[${V}]`,value:m[V],valueSpec:T.layout_symbol["text-anchor"]})),$=$.concat(xd({key:`${o}[${V+1}]`,value:m[V+1],valueSpec:{length:2,value:"number"},validateSpec:d.validateSpec,style:d.style,styleSpec:T}));return $},sprite:Y};function Se(d){const o=d.value,m=d.valueSpec,b=d.styleSpec;return d.validateSpec=Se,m.expression&&Ic(_i(o))?so(d):m.expression&&G(sl(o))?Qc(d):m.type&&ue[m.type]?ue[m.type](d):Ba(Ns({},d,{valueSpec:m.type?b[m.type]:m}))}function st(d){const o=d.value,m=d.key,b=vu(d);return b.length||(o.indexOf("{fontstack}")===-1&&b.push(new $t(m,o,'"glyphs" url must include a "{fontstack}" token')),o.indexOf("{range}")===-1&&b.push(new $t(m,o,'"glyphs" url must include a "{range}" token'))),b}function At(d,o=He){let m=[];return m=m.concat(Se({key:"",value:d,valueSpec:o.$root,styleSpec:o,style:d,validateSpec:Se,objectElementValidators:{glyphs:st,"*":()=>[]}})),d.constants&&(m=m.concat(mc({key:"constants",value:d.constants,style:d,styleSpec:o,validateSpec:Se}))),ws(m)}function hs(d){return function(o){return d({...o,validateSpec:Se})}}function ws(d){return[].concat(d).sort((o,m)=>o.line-m.line)}function Os(d){return function(...o){return ws(d.apply(this,o))}}At.source=Os(hs(bu)),At.sprite=Os(hs(Y)),At.glyphs=Os(hs(st)),At.light=Os(hs(Bh)),At.sky=Os(hs(p)),At.terrain=Os(hs(M)),At.layer=Os(hs(vo)),At.filter=Os(hs(ai)),At.paintProperty=Os(hs(Fi)),At.layoutProperty=Os(hs(ri));const _n=At,Ta=_n.light,yr=_n.sky,cr=_n.paintProperty,bo=_n.layoutProperty;function zi(d,o){let m=!1;if(o&&o.length)for(const b of o)d.fire(new ht(new Error(b.message))),m=!0;return m}class jo{constructor(o,m,b){const T=this.cells=[];if(o instanceof ArrayBuffer){this.arrayBuffer=o;const V=new Int32Array(this.arrayBuffer);o=V[0],this.d=(m=V[1])+2*(b=V[2]);for(let ne=0;ne<this.d*this.d;ne++){const me=V[3+ne],ye=V[3+ne+1];T.push(me===ye?null:V.subarray(me,ye))}const U=V[3+T.length+1];this.keys=V.subarray(V[3+T.length],U),this.bboxes=V.subarray(U),this.insert=this._insertReadonly}else{this.d=m+2*b;for(let V=0;V<this.d*this.d;V++)T.push([]);this.keys=[],this.bboxes=[]}this.n=m,this.extent=o,this.padding=b,this.scale=m/o,this.uid=0;const $=b/m*o;this.min=-$,this.max=o+$}insert(o,m,b,T,$){this._forEachCell(m,b,T,$,this._insertCell,this.uid++,void 0,void 0),this.keys.push(o),this.bboxes.push(m),this.bboxes.push(b),this.bboxes.push(T),this.bboxes.push($)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(o,m,b,T,$,V){this.cells[$].push(V)}query(o,m,b,T,$){const V=this.min,U=this.max;if(o<=V&&m<=V&&U<=b&&U<=T&&!$)return Array.prototype.slice.call(this.keys);{const ne=[];return this._forEachCell(o,m,b,T,this._queryCell,ne,{},$),ne}}_queryCell(o,m,b,T,$,V,U,ne){const me=this.cells[$];if(me!==null){const ye=this.keys,Te=this.bboxes;for(let $e=0;$e<me.length;$e++){const Ye=me[$e];if(U[Ye]===void 0){const et=4*Ye;(ne?ne(Te[et+0],Te[et+1],Te[et+2],Te[et+3]):o<=Te[et+2]&&m<=Te[et+3]&&b>=Te[et+0]&&T>=Te[et+1])?(U[Ye]=!0,V.push(ye[Ye])):U[Ye]=!1}}}}_forEachCell(o,m,b,T,$,V,U,ne){const me=this._convertToCellCoord(o),ye=this._convertToCellCoord(m),Te=this._convertToCellCoord(b),$e=this._convertToCellCoord(T);for(let Ye=me;Ye<=Te;Ye++)for(let et=ye;et<=$e;et++){const mt=this.d*et+Ye;if((!ne||ne(this._convertFromCellCoord(Ye),this._convertFromCellCoord(et),this._convertFromCellCoord(Ye+1),this._convertFromCellCoord(et+1)))&&$.call(this,o,m,b,T,mt,V,U,ne))return}}_convertFromCellCoord(o){return(o-this.padding)/this.scale}_convertToCellCoord(o){return Math.max(0,Math.min(this.d-1,Math.floor(o*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const o=this.cells,m=3+this.cells.length+1+1;let b=0;for(let V=0;V<this.cells.length;V++)b+=this.cells[V].length;const T=new Int32Array(m+b+this.keys.length+this.bboxes.length);T[0]=this.extent,T[1]=this.n,T[2]=this.padding;let $=m;for(let V=0;V<o.length;V++){const U=o[V];T[3+V]=$,T.set(U,$),$+=U.length}return T[3+o.length]=$,T.set(this.keys,$),$+=this.keys.length,T[3+o.length+1]=$,T.set(this.bboxes,$),$+=this.bboxes.length,T.buffer}static serialize(o,m){const b=o.toArrayBuffer();return m&&m.push(b),{buffer:b}}static deserialize(o){return new jo(o.buffer)}}const $a={};function jn(d,o,m={}){if($a[d])throw new Error(`${d} is already registered.`);Object.defineProperty(o,"_classRegistryKey",{value:d,writeable:!1}),$a[d]={klass:o,omit:m.omit||[],shallow:m.shallow||[]}}jn("Object",Object),jn("TransferableGridIndex",jo),jn("Color",An),jn("Error",Error),jn("AJAXError",dt),jn("ResolvedImage",Ka),jn("StylePropertyFunction",Nt),jn("StyleExpression",w,{omit:["_evaluator"]}),jn("ZoomDependentExpression",Ae),jn("ZoomConstantExpression",xe),jn("CompoundExpression",Bn,{omit:["_evaluate"]});for(const d in la)la[d]._classRegistryKey||jn(`Expression_${d}`,la[d]);function Ou(d){return d&&typeof ArrayBuffer<"u"&&(d instanceof ArrayBuffer||d.constructor&&d.constructor.name==="ArrayBuffer")}function xh(d){return d.$name||d.constructor._classRegistryKey}
1962function Ac(d){return!function(o){if(o===null||typeof o!="object")return!1;const m=xh(o);return!(!m||m==="Object")}(d)&&(d==null||typeof d=="boolean"||typeof d=="number"||typeof d=="string"||d instanceof Boolean||d instanceof Number||d instanceof String||d instanceof Date||d instanceof RegExp||d instanceof Blob||d instanceof Error||Ou(d)||de(d)||ArrayBuffer.isView(d)||d instanceof ImageData)}function Uc(d,o){if(Ac(d))return(Ou(d)||de(d))&&o&&o.push(d),ArrayBuffer.isView(d)&&o&&o.push(d.buffer),d instanceof ImageData&&o&&o.push(d.data.buffer),d;if(Array.isArray(d)){const $=[];for(const V of d)$.push(Uc(V,o));return $}if(typeof d!="object")throw new Error("can't serialize object of type "+typeof d);const m=xh(d);if(!m)throw new Error(`can't serialize object of unregistered class ${d.constructor.name}`);if(!$a[m])throw new Error(`${m} is not registered.`);const{klass:b}=$a[m],T=b.serialize?b.serialize(d,o):{};if(b.serialize){if(o&&T===o[o.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const $ in d){if(!d.hasOwnProperty($)||$a[m].omit.indexOf($)>=0)continue;const V=d[$];T[$]=$a[m].shallow.indexOf($)>=0?V:Uc(V,o)}d instanceof Error&&(T.message=d.message)}if(T.$name)throw new Error("$name property is reserved for worker serialization logic.");return m!=="Object"&&(T.$name=m),T}function Dc(d){if(Ac(d))return d;if(Array.isArray(d))return d.map(Dc);if(typeof d!="object")throw new Error("can't deserialize object of type "+typeof d);const o=xh(d)||"Object";if(!$a[o])throw new Error(`can't deserialize unregistered class ${o}`);const{klass:m}=$a[o];if(!m)throw new Error(`can't deserialize unregistered class ${o}`);if(m.deserialize)return m.deserialize(d);const b=Object.create(m.prototype);for(const T of Object.keys(d)){if(T==="$name")continue;const $=d[T];b[T]=$a[o].shallow.indexOf(T)>=0?$:Dc($)}return b}class fo{constructor(){this.first=!0}update(o,m){const b=Math.floor(o);return this.first?(this.first=!1,this.lastIntegerZoom=b,this.lastIntegerZoomTime=0,this.lastZoom=o,this.lastFloorZoom=b,!0):(this.lastFloorZoom>b?(this.lastIntegerZoom=b+1,this.lastIntegerZoomTime=m):this.lastFloorZoom<b&&(this.lastIntegerZoom=b,this.lastIntegerZoomTime=m),o!==this.lastZoom&&(this.lastZoom=o,this.lastFloorZoom=b,!0))}}const Ua={"Latin-1 Supplement":d=>d>=128&&d<=255,"Hangul Jamo":d=>d>=4352&&d<=4607,Khmer:d=>d>=6016&&d<=6143,"General Punctuation":d=>d>=8192&&d<=8303,"Letterlike Symbols":d=>d>=8448&&d<=8527,"Number Forms":d=>d>=8528&&d<=8591,"Miscellaneous Technical":d=>d>=8960&&d<=9215,"Control Pictures":d=>d>=9216&&d<=9279,"Optical Character Recognition":d=>d>=9280&&d<=9311,"Enclosed Alphanumerics":d=>d>=9312&&d<=9471,"Geometric Shapes":d=>d>=9632&&d<=9727,"Miscellaneous Symbols":d=>d>=9728&&d<=9983,"Miscellaneous Symbols and Arrows":d=>d>=11008&&d<=11263,"Ideographic Description Characters":d=>d>=12272&&d<=12287,"CJK Symbols and Punctuation":d=>d>=12288&&d<=12351,Katakana:d=>d>=12448&&d<=12543,Kanbun:d=>d>=12688&&d<=12703,"CJK Strokes":d=>d>=12736&&d<=12783,"Enclosed CJK Letters and Months":d=>d>=12800&&d<=13055,"CJK Compatibility":d=>d>=13056&&d<=13311,"Yijing Hexagram Symbols":d=>d>=19904&&d<=19967,"Private Use Area":d=>d>=57344&&d<=63743,"Vertical Forms":d=>d>=65040&&d<=65055,"CJK Compatibility Forms":d=>d>=65072&&d<=65103,"Small Form Variants":d=>d>=65104&&d<=65135,"Halfwidth and Fullwidth Forms":d=>d>=65280&&d<=65519};function vm(d){for(const o of d)if(Ym(o.charCodeAt(0)))return!0;return!1}function _h(d){for(const o of d)if(!Ad(o.charCodeAt(0)))return!1;return!0}function yh(d){const o=d.map(m=>{try{return new RegExp(`\\p{sc=${m}}`,"u").source}catch{return null}}).filter(m=>m);return new RegExp(o.join("|"),"u")}const Bu=yh(["Arab","Dupl","Mong","Ougr","Syrc"]);function Ad(d){return!Bu.test(String.fromCodePoint(d))}const Vf=yh(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function Ym(d){return!(d!==746&&d!==747&&(d<4352||!(Ua["CJK Compatibility Forms"](d)&&!(d>=65097&&d<=65103)||Ua["CJK Compatibility"](d)||Ua["CJK Strokes"](d)||!(!Ua["CJK Symbols and Punctuation"](d)||d>=12296&&d<=12305||d>=12308&&d<=12319||d===12336)||Ua["Enclosed CJK Letters and Months"](d)||Ua["Ideographic Description Characters"](d)||Ua.Kanbun(d)||Ua.Katakana(d)&&d!==12540||!(!Ua["Halfwidth and Fullwidth Forms"](d)||d===65288||d===65289||d===65293||d>=65306&&d<=65310||d===65339||d===65341||d===65343||d>=65371&&d<=65503||d===65507||d>=65512&&d<=65519)||!(!Ua["Small Form Variants"](d)||d>=65112&&d<=65118||d>=65123&&d<=65126)||Ua["Vertical Forms"](d)||Ua["Yijing Hexagram Symbols"](d)||new RegExp("\\p{sc=Cans}","u").test(String.fromCodePoint(d))||new RegExp("\\p{sc=Hang}","u").test(String.fromCodePoint(d))||Vf.test(String.fromCodePoint(d)))))}function Tp(d){return!(Ym(d)||function(o){return!!(Ua["Latin-1 Supplement"](o)&&(o===167||o===169||o===174||o===177||o===188||o===189||o===190||o===215||o===247)||Ua["General Punctuation"](o)&&(o===8214||o===8224||o===8225||o===8240||o===8241||o===8251||o===8252||o===8258||o===8263||o===8264||o===8265||o===8273)||Ua["Letterlike Symbols"](o)||Ua["
1962Number Forms"](o)||Ua["Miscellaneous Technical"](o)&&(o>=8960&&o<=8967||o>=8972&&o<=8991||o>=8996&&o<=9e3||o===9003||o>=9085&&o<=9114||o>=9150&&o<=9165||o===9167||o>=9169&&o<=9179||o>=9186&&o<=9215)||Ua["Control Pictures"](o)&&o!==9251||Ua["Optical Character Recognition"](o)||Ua["Enclosed Alphanumerics"](o)||Ua["Geometric Shapes"](o)||Ua["Miscellaneous Symbols"](o)&&!(o>=9754&&o<=9759)||Ua["Miscellaneous Symbols and Arrows"](o)&&(o>=11026&&o<=11055||o>=11088&&o<=11097||o>=11192&&o<=11243)||Ua["CJK Symbols and Punctuation"](o)||Ua.Katakana(o)||Ua["Private Use Area"](o)||Ua["CJK Compatibility Forms"](o)||Ua["Small Form Variants"](o)||Ua["Halfwidth and Fullwidth Forms"](o)||o===8734||o===8756||o===8757||o>=9984&&o<=10087||o>=10102&&o<=10131||o===65532||o===65533)}(d))}const qf=yh(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Gf(d){return qf.test(String.fromCodePoint(d))}function Hf(d,o){return!(!o&&Gf(d)||d>=2304&&d<=3583||d>=3840&&d<=4255||Ua.Khmer(d))}function ed(d){for(const o of d)if(Gf(o.charCodeAt(0)))return!0;return!1}const no=new class{constructor(){this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null}setState(d){this.pluginStatus=d.pluginStatus,this.pluginURL=d.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(d){this.applyArabicShaping=d.applyArabicShaping,this.processBidirectionalText=d.processBidirectionalText,this.processStyledBidirectionalText=d.processStyledBidirectionalText}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getPluginURL(){return this.pluginURL}getRTLTextPluginStatus(){return this.pluginStatus}};class yi{constructor(o,m){this.zoom=o,m?(this.now=m.now,this.fadeDuration=m.fadeDuration,this.zoomHistory=m.zoomHistory,this.transition=m.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new fo,this.transition={})}isSupportedScript(o){return function(m,b){for(const T of m)if(!Hf(T.charCodeAt(0),b))return!1;return!0}(o,no.getRTLTextPluginStatus()==="loaded")}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const o=this.zoom,m=o-Math.floor(o),b=this.crossFadingFactor();return o>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:m+(1-m)*b}:{fromScale:.5,toScale:1,t:1-(1-b)*m}}}class $u{constructor(o,m){this.property=o,this.value=m,this.expression=function(b,T){if(Ic(b))return new Nt(b,T);if(G(b)){const $=tt(b,T);if($.result==="error")throw new Error($.value.map(V=>`${V.key}: ${V.message}`).join(", "));return $.value}{let $=b;return T.type==="color"&&typeof b=="string"?$=An.parse(b):T.type!=="padding"||typeof b!="number"&&!Array.isArray(b)?T.type==="variableAnchorOffsetCollection"&&Array.isArray(b)&&($=ra.parse(b)):$=Yr.parse(b),{kind:"constant",evaluate:()=>$}}}(m===void 0?o.specification.default:m,o.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(o,m,b){return this.property.possiblyEvaluate(this,o,m,b)}}class Vu{constructor(o){this.property=o,this.value=new $u(o,void 0)}transitioned(o,m){return new Vh(this.property,this.value,m,H({},o.transition,this.transition),o.now)}untransitioned(){return new Vh(this.property,this.value,null,{},0)}}class $h{constructor(o){this._properties=o,this._values=Object.create(o.defaultTransitionablePropertyValues)}getValue(o){return Q(this._values[o].value.value)}setValue(o,m){Object.prototype.hasOwnProperty.call(this._values,o)||(this._values[o]=new Vu(this._values[o].property)),this._values[o].value=new $u(this._values[o].property,m===null?void 0:Q(m))}getTransition(o){return Q(this._values[o].transition)}setTransition(o,m){Object.prototype.hasOwnProperty.call(this._values,o)||(this._values[o]=new Vu(this._values[o].property)),this._values[o].transition=Q(m)||void 0}serialize(){const o={};for(const m of Object.keys(this._values)){const b=this.getValue(m);b!==void 0&&(o[m]=b);const T=this.getTransition(m);T!==void 0&&(o[`${m}-transition`]=T)}return o}transitioned(o,m){const b=new vh(this._properties);for(const T of Object.keys(this._values))b._values[T]=this._values[T].transitioned(o,m._values[T]);return b}untransitioned(){const o=new vh(this._properties);for(const m of Object.keys(this._values))o._values[m]=this._values[m].untransitioned();return o}}class Vh{constructor(o,m,b,T,$){this.property=o,this.value=m,this.begin=$+T.delay||0,this.end=this.begin+T.duration||0,o.specification.transition&&(T.delay||T.duration)&&(this.prior=b)}possiblyEvaluate(o,m,b){const T=o.now||0,$=this.value.possiblyEvaluate(o,m,b),V=this.prior;if(V){if(T>this.end)return this.prior=null,$;if(this.value.isDataDriven())return this.prior=null,$;if(T<this.begin)return V.possiblyEvaluate(o,m,b);{const U=(T-this.begin)/(this.end-this.begin);return this.property.interpolate(V.possiblyEvaluate(o,m,b),$,function(ne){if(ne<=0)return 0;if(ne>=1)return 1;const me=ne*ne,ye=me*ne;return 4*(ne<.5?ye:3*(ne-me)+ye-.75)}(U))}}return $}}class vh{constructor(o){this._properties=o,this._values=Object.create(o.defaultTransitioningPropertyValues)}possiblyEvaluate(o,m,b){const T=new wo(this._properties);for(const $ of Object.keys(this._values))T._values[$]=this._values[$].possiblyEvaluate(o,m,b);return T}hasTransition(){for(const o of Object.keys(this._values))if(this._values[o].prior)return!0;return!1}}class bh{constructor(o){this._properties=o,this._values=Object.create(o.defaultPropertyValues)}hasValue(o){return this._values[o].value!==void 0}getValue(o){return Q(this._values[o].value)}setValue(o,m){this._values[o]=new $u(this._values[o].property,m===null?void 0:Q(m))}serialize(){const o={};for(const m of Object.keys(this._values)){const b=this.getValue(m);b!==void 0&&(o[m]=b)}return o}possiblyEvaluate(o,m,b){const T=new wo(this._properties);for(const $ of Object.keys(this._values))T._values[$]=this._values[$].possiblyEvaluate(o,m,b);return T}}class yd{constructor(o,m,b){this.property=o,this.value=m,this.parameters=b}isConstant(){return this.value.kind==="constant"}constantOr(o){return this.value.kind==="constant"?this.value.value:o}evaluate(o,m,b,T){return this.property.evaluate(this.value,this.parameters,o,m,b,T)}}class wo{constructor(o){this._properties=o,this._values=Object.create(o.defaultPossiblyEvaluatedValues)}get(o){return this._values[o]}}class ea{constructor(o){this.specification=o}possiblyEvaluate(o,m){if(o.isDataDriven())throw new Error("Value should not be data driven");return o.expression.evaluate(m)}interpolate(o,m,b){const T=Zr[this.specification.type];return T?T(o,m,b):o}}class ia{constructor(o,m){this.specification=o,this.overrides=m}possiblyEvaluate(o,m,b,T){return new yd(this,o.expression.kind==="constant"||o.expression.kind==="camera"?{kind:"constant",value:o.expression.evaluate(m,null,{},b,T)}:o.expression,m)}interpolate(o,m,b){if(o.value.kind!=="constant"||m.value.kind!=="constant")return o;if(o.value.value===void 0||m.value.value===void 0)return new yd(this,{kind:"constant",value:void 0},o.parameters);const T=Zr[this.specification.type];if(T){const $=T(o.value.value,m.value.value,b);return new yd(this,{kind:"constant",value:$},o.parameters)}return o}evaluate(o,m,b,T,$,V){return o.kind==="constant"?o.value:o.evaluate(m,b,T,$,V)}}class qh extends ia{possiblyEvaluate(o,m,b,T){if(o.value===void 0)return new yd(this,{kind:"constant",value:void 0},m);if(o.expression.kind==="constant"){const $=o.expression.evaluate(m,null,{},b,T),V=o.property.specification.type==="resolvedImage"&&typeof $!="string"?$.name:$,U=this._calculate(V,V,V,m);return new yd(this,{kind:"constant",value:U},m)}if(o.expression.kind==="camera"){const $=this._calculate(o.expression.evaluate({zoom:m.zoom-1}),o.expression.evaluate({zoom:m.zoom}),o.expression.evaluate({zoom:m.zoom+1}),m);return new yd(this,{kind:"constant",value:$},m)}return new yd(this,o.expression,m)}evaluate(o,m,b,T,$,V){if(o.kind==="source"){const U=o.evaluate(m,b,T,$,V);return this._calculate(U,U,U,m)}return o.kind==="composite"?this._calculate(o.evaluate({zoom:Math.floor(m.zoom)-1},b,T),o.evaluate({zoom:Math.floor(m.zoom)},b,T),o.evaluate({zoom:Math.floor(m.zoom)+1},b,T),m):o.value}_calculate(o,m,b,T){return T.zoom>T.zoomHistory.lastIntegerZoom?{from:o,to:m}:{from:b,to:m}}interpolate(o){return o}}class Xm{constructor(o){this.specification=o}possiblyEvaluate(o,m,b,T){if(o.value!==void 0){if(o.expression.kind==="constant"){const $=o.expression.evaluate(m,null,{},b,T);return this._calculate($,$,$,m)}return this._calculate(o.expression.evaluate(new yi(Math.floor(m.zoom-1),m)),o.expression.evaluate(new yi(Math.floor(m.zoom),m)),o.expression.evaluate(new yi(Math.floor(m.zoom+1),m)),m)}}_calculate(o,m,b,T){return T.zoom>T.zoomHistory.lastIntegerZoom?{from:o,to:m}:{from:b,to:m}}interpolate(o){return o}}class Km{constructor(o){this.specification=o}possiblyEvaluate(o,m,b,T){return!!o.expression.evaluate(m,null,{},b,T)}interpolate(){return!1}}class R{constructor(o){this.properties=o,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const m in o){const b=o[m];b.specification.overridable&&this.overridableProperties.push(m);const T=this.defaultPropertyValues[m]=new $u(b,void 0),$=this.defaultTransitionablePropertyValues[m]=new Vu(b);this.defaultTransitioningPropertyValues[m]=$.untransitioned(),this.defaultPossiblyEvaluatedValues[m]=T.possiblyEvaluate({})}}}jn("DataDrivenProperty",ia),jn("DataConstantProperty",ea),jn("CrossFadedDataDrivenProperty",qh),jn("CrossFadedProperty",Xm),jn("ColorRampProperty",Km);const r="-transition";class g extends _t{constructor(o,m){if(super(),this.id=o.id,this.type=o.type,this._featureFilter={filter:()=>!0,needGeometry:!1},o.type!=="custom"&&(this.metadata=o.metadata,this.minzoom=o.minzoom,this.maxzoom=o.maxzoom,o.type!=="background"&&(this.source=o.source,this.sourceLayer=o["source-layer"],this.filter=o.filter),m.layout&&(this._unevaluatedLayout=new bh(m.layout)),m.paint)){this._transitionablePaint=new $h(m.paint);for(const b in o.paint)this.setPaintProperty(b,o.paint[b],{validate:!1});for(const b in o.layout)this.setLayoutProperty(b,o.layout[b],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new wo(m.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(o){return o==="visibility"?this.visibility:this._unevaluatedLayout.getValue(o)}setLayoutProperty(o,m,b={}
1962){m!=null&&this._validate(bo,`layers.${this.id}.layout.${o}`,o,m,b)||(o!=="visibility"?this._unevaluatedLayout.setValue(o,m):this.visibility=m)}getPaintProperty(o){return o.endsWith(r)?this._transitionablePaint.getTransition(o.slice(0,-11)):this._transitionablePaint.getValue(o)}setPaintProperty(o,m,b={}){if(m!=null&&this._validate(cr,`layers.${this.id}.paint.${o}`,o,m,b))return!1;if(o.endsWith(r))return this._transitionablePaint.setTransition(o.slice(0,-11),m||void 0),!1;{const T=this._transitionablePaint._values[o],$=T.property.specification["property-type"]==="cross-faded-data-driven",V=T.value.isDataDriven(),U=T.value;this._transitionablePaint.setValue(o,m),this._handleSpecialPaintPropertyUpdate(o);const ne=this._transitionablePaint._values[o].value;return ne.isDataDriven()||V||$||this._handleOverridablePaintPropertyUpdate(o,U,ne)}}_handleSpecialPaintPropertyUpdate(o){}_handleOverridablePaintPropertyUpdate(o,m,b){return!1}isHidden(o){return!!(this.minzoom&&o<this.minzoom)||!!(this.maxzoom&&o>=this.maxzoom)||this.visibility==="none"}updateTransitions(o){this._transitioningPaint=this._transitionablePaint.transitioned(o,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(o,m){o.getCrossfadeParameters&&(this._crossfadeParameters=o.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(o,void 0,m)),this.paint=this._transitioningPaint.possiblyEvaluate(o,void 0,m)}
vendor: 6,689 bytes, line 1962
1962serialize(){const o={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(o.layout=o.layout||{},o.layout.visibility=this.visibility),W(o,(m,b)=>!(m===void 0||b==="layout"&&!Object.keys(m).length||b==="paint"&&!Object.keys(m).length))}_validate(o,m,b,T,$={}){return(!$||$.validate!==!1)&&zi(this,o.call(_n,{key:m,layerType:this.type,objectKey:b,value:T,styleSpec:He,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const o in this.paint._values){const m=this.paint.get(o);if(m instanceof yd&&xl(m.property.specification)&&(m.value.kind==="source"||m.value.kind==="composite")&&m.value.isStateDependent)return!0}return!1}}const S={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class E{constructor(o,m){this._structArray=o,this._pos1=m*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class A{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(o,m){return o._trim(),m&&(o.isTransferred=!0,m.push(o.arrayBuffer)),{length:o.length,arrayBuffer:o.arrayBuffer}}static deserialize(o){const m=Object.create(this.prototype);return m.arrayBuffer=o.arrayBuffer,m.length=o.length,m.capacity=o.arrayBuffer.byteLength/m.bytesPerElement,m._refreshViews(),m}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(o){this.reserve(o),this.length=o}reserve(o){if(o>this.capacity){this.capacity=Math.max(o,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const m=this.uint8;this._refreshViews(),m&&this.uint8.set(m)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function ee(d,o=1){let m=0,b=0;return{members:d.map(T=>{const $=S[T.type].BYTES_PER_ELEMENT,V=m=se(m,Math.max(o,$)),U=T.components||1;return b=Math.max(b,$),m+=$*U,{name:T.name,type:T.type,components:U,offset:V}}),size:se(m,Math.max(b,o)),alignment:o}}function se(d,o){return Math.ceil(d/o)*o}class he extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(o,m){const b=this.length;return this.resize(b+1),this.emplace(b,o,m)}emplace(o,m,b){const T=2*o;return this.int16[T+0]=m,this.int16[T+1]=b,o}}he.prototype.bytesPerElement=4,jn("StructArrayLayout2i4",he);class _e extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(o,m,b){const T=this.length;return this.resize(T+1),this.emplace(T,o,m,b)}emplace(o,m,b,T){const $=3*o;return this.int16[$+0]=m,this.int16[$+1]=b,this.int16[$+2]=T,o}}_e.prototype.bytesPerElement=6,jn("StructArrayLayout3i6",_e);class Ie extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(o,m,b,T){const $=this.length;return this.resize($+1),this.emplace($,o,m,b,T)}emplace(o,m,b,T,$){const V=4*o;return this.int16[V+0]=m,this.int16[V+1]=b,this.int16[V+2]=T,this.int16[V+3]=$,o}}Ie.prototype.bytesPerElement=8,jn("StructArrayLayout4i8",Ie);class Me extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(o,m,b,T,$,V){const U=this.length;return this.resize(U+1),this.emplace(U,o,m,b,T,$,V)}emplace(o,m,b,T,$,V,U){const ne=6*o;return this.int16[ne+0]=m,this.int16[ne+1]=b,this.int16[ne+2]=T,this.int16[ne+3]=$,this.int16[ne+4]=V,this.int16[ne+5]=U,o}}Me.prototype.bytesPerElement=12,jn("StructArrayLayout2i4i12",Me);class Je extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(o,m,b,T,$,V){const U=this.length;return this.resize(U+1),this.emplace(U,o,m,b,T,$,V)}emplace(o,m,b,T,$,V,U){const ne=4*o,me=8*o;return this.int16[ne+0]=m,this.int16[ne+1]=b,this.uint8[me+4]=T,this.uint8[me+5]=$,this.uint8[me+6]=V,this.uint8[me+7]=U,o}}Je.prototype.bytesPerElement=8,jn("StructArrayLayout2i4ub8",Je);class ut extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(o,m){const b=this.length;return this.resize(b+1),this.emplace(b,o,m)}emplace(o,m,b){const T=2*o;return this.float32[T+0]=m,this.float32[T+1]=b,o}}ut.prototype.bytesPerElement=8,jn("StructArrayLayout2f8",ut);class gt extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(o,m,b,T,$,V,U,ne,me,ye){const Te=this.length;return this.resize(Te+1),this.emplace(Te,o,m,b,T,$,V,U,ne,me,ye)}emplace(o,m,b,T,$,V,U,ne,me,ye,Te){const $e=10*o;return this.uint16[$e+0]=m,this.uint16[$e+1]=b,this.uint16[$e+2]=T,this.uint16[$e+3]=$,this.uint16[$e+4]=V,this.uint16[$e+5]=U,this.uint16[$e+6]=ne,this.uint16[$e+7]=me,this.uint16[$e+8]=ye,this.uint16[$e+9]=Te,o}}gt.prototype.bytesPerElement=20,jn("StructArrayLayout10ui20",gt);class St extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(o,m,b,T,$,V,U,ne,me,ye,Te,$e){const Ye=this.length;return this.resize(Ye+1),this.emplace(Ye,o,m,b,T,$,V,U,ne,me,ye,Te,$e)}emplace(o,m,b,T,$,V,U,ne,me,ye,Te,$e,Ye){const et=12*o;return this.int16[et+0]=m,this.int16[et+1]=b,this.int16[et+2]=T,this.int16[et+3]=$,this.uint16[et+4]=V,this.uint16[et+5]=U,this.uint16[et+6]=ne,this.uint16[et+7]=me,this.int16[et+8]=ye,this.int16[et+9]=Te,this.int16[et+10]=$e,this.int16[et+11]=Ye,o}}St.prototype.bytesPerElement=24,jn("StructArrayLayout4i4ui4i24",St);class Lt extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(o,m,b){const T=this.length;return this.resize(T+1),this.emplace(T,o,m,b)}emplace(o,m,b,T){const $=3*o;return this.float32[$+0]=m,this.float32[$+1]=b,this.float32[$+2]=T,o}}Lt.prototype.bytesPerElement=12,jn("StructArrayLayout3f12",Lt);class Vt extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(o){const m=this.length;return this.resize(m+1),this.emplace(m,o)}emplace(o,m){return this.uint32[1*o+0]=m,o}}
vendor: 16,588 bytes, line 1962
1962Vt.prototype.bytesPerElement=4,jn("StructArrayLayout1ul4",Vt);class Ht extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(o,m,b,T,$,V,U,ne,me){const ye=this.length;return this.resize(ye+1),this.emplace(ye,o,m,b,T,$,V,U,ne,me)}emplace(o,m,b,T,$,V,U,ne,me,ye){const Te=10*o,$e=5*o;return this.int16[Te+0]=m,this.int16[Te+1]=b,this.int16[Te+2]=T,this.int16[Te+3]=$,this.int16[Te+4]=V,this.int16[Te+5]=U,this.uint32[$e+3]=ne,this.uint16[Te+8]=me,this.uint16[Te+9]=ye,o}}Ht.prototype.bytesPerElement=20,jn("StructArrayLayout6i1ul2ui20",Ht);class Et extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(o,m,b,T,$,V){const U=this.length;return this.resize(U+1),this.emplace(U,o,m,b,T,$,V)}emplace(o,m,b,T,$,V,U){const ne=6*o;return this.int16[ne+0]=m,this.int16[ne+1]=b,this.int16[ne+2]=T,this.int16[ne+3]=$,this.int16[ne+4]=V,this.int16[ne+5]=U,o}}Et.prototype.bytesPerElement=12,jn("StructArrayLayout2i2i2i12",Et);class Kt extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(o,m,b,T,$){const V=this.length;return this.resize(V+1),this.emplace(V,o,m,b,T,$)}emplace(o,m,b,T,$,V){const U=4*o,ne=8*o;return this.float32[U+0]=m,this.float32[U+1]=b,this.float32[U+2]=T,this.int16[ne+6]=$,this.int16[ne+7]=V,o}}Kt.prototype.bytesPerElement=16,jn("StructArrayLayout2f1f2i16",Kt);class ss extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(o,m,b,T,$,V){const U=this.length;return this.resize(U+1),this.emplace(U,o,m,b,T,$,V)}emplace(o,m,b,T,$,V,U){const ne=16*o,me=4*o,ye=8*o;return this.uint8[ne+0]=m,this.uint8[ne+1]=b,this.float32[me+1]=T,this.float32[me+2]=$,this.int16[ye+6]=V,this.int16[ye+7]=U,o}}ss.prototype.bytesPerElement=16,jn("StructArrayLayout2ub2f2i16",ss);class cs extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(o,m,b){const T=this.length;return this.resize(T+1),this.emplace(T,o,m,b)}emplace(o,m,b,T){const $=3*o;return this.uint16[$+0]=m,this.uint16[$+1]=b,this.uint16[$+2]=T,o}}cs.prototype.bytesPerElement=6,jn("StructArrayLayout3ui6",cs);class As extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(o,m,b,T,$,V,U,ne,me,ye,Te,$e,Ye,et,mt,Tt,Ot){const gs=this.length;return this.resize(gs+1),this.emplace(gs,o,m,b,T,$,V,U,ne,me,ye,Te,$e,Ye,et,mt,Tt,Ot)}emplace(o,m,b,T,$,V,U,ne,me,ye,Te,$e,Ye,et,mt,Tt,Ot,gs){const Yt=24*o,ls=12*o,Cs=48*o;return this.int16[Yt+0]=m,this.int16[Yt+1]=b,this.uint16[Yt+2]=T,this.uint16[Yt+3]=$,this.uint32[ls+2]=V,this.uint32[ls+3]=U,this.uint32[ls+4]=ne,this.uint16[Yt+10]=me,this.uint16[Yt+11]=ye,this.uint16[Yt+12]=Te,this.float32[ls+7]=$e,this.float32[ls+8]=Ye,this.uint8[Cs+36]=et,this.uint8[Cs+37]=mt,this.uint8[Cs+38]=Tt,this.uint32[ls+10]=Ot,this.int16[Yt+22]=gs,o}}As.prototype.bytesPerElement=48,jn("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",As);class sn extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(o,m,b,T,$,V,U,ne,me,ye,Te,$e,Ye,et,mt,Tt,Ot,gs,Yt,ls,Cs,Us,$n,La,Rn,kn,ga,ta){const Yn=this.length;return this.resize(Yn+1),this.emplace(Yn,o,m,b,T,$,V,U,ne,me,ye,Te,$e,Ye,et,mt,Tt,Ot,gs,Yt,ls,Cs,Us,$n,La,Rn,kn,ga,ta)}emplace(o,m,b,T,$,V,U,ne,me,ye,Te,$e,Ye,et,mt,Tt,Ot,gs,Yt,ls,Cs,Us,$n,La,Rn,kn,ga,ta,Yn){const Ds=32*o,_a=16*o;return this.int16[Ds+0]=m,this.int16[Ds+1]=b,this.int16[Ds+2]=T,this.int16[Ds+3]=$,this.int16[Ds+4]=V,this.int16[Ds+5]=U,this.int16[Ds+6]=ne,this.int16[Ds+7]=me,this.uint16[Ds+8]=ye,this.uint16[Ds+9]=Te,this.uint16[Ds+10]=$e,this.uint16[Ds+11]=Ye,this.uint16[Ds+12]=et,this.uint16[Ds+13]=mt,this.uint16[Ds+14]=Tt,this.uint16[Ds+15]=Ot,this.uint16[Ds+16]=gs,this.uint16[Ds+17]=Yt,this.uint16[Ds+18]=ls,this.uint16[Ds+19]=Cs,this.uint16[Ds+20]=Us,this.uint16[Ds+21]=$n,this.uint16[Ds+22]=La,this.uint32[_a+12]=Rn,this.float32[_a+13]=kn,this.float32[_a+14]=ga,this.uint16[Ds+30]=ta,this.uint16[Ds+31]=Yn,o}}sn.prototype.bytesPerElement=64,jn("StructArrayLayout8i15ui1ul2f2ui64",sn);class pn extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(o){const m=this.length;return this.resize(m+1),this.emplace(m,o)}emplace(o,m){return this.float32[1*o+0]=m,o}}pn.prototype.bytesPerElement=4,jn("StructArrayLayout1f4",pn);class Ln extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(o,m,b){const T=this.length;return this.resize(T+1),this.emplace(T,o,m,b)}emplace(o,m,b,T){const $=3*o;return this.uint16[6*o+0]=m,this.float32[$+1]=b,this.float32[$+2]=T,o}}Ln.prototype.bytesPerElement=12,jn("StructArrayLayout1ui2f12",Ln);class Js extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(o,m,b){const T=this.length;return this.resize(T+1),this.emplace(T,o,m,b)}emplace(o,m,b,T){const $=4*o;return this.uint32[2*o+0]=m,this.uint16[$+2]=b,this.uint16[$+3]=T,o}}Js.prototype.bytesPerElement=8,jn("StructArrayLayout1ul2ui8",Js);class on extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(o,m){const b=this.length;return this.resize(b+1),this.emplace(b,o,m)}emplace(o,m,b){const T=2*o;return this.uint16[T+0]=m,this.uint16[T+1]=b,o}}on.prototype.bytesPerElement=4,jn("StructArrayLayout2ui4",on);class Hn extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(o){const m=this.length;return this.resize(m+1),this.emplace(m,o)}emplace(o,m){return this.uint16[1*o+0]=m,o}}Hn.prototype.bytesPerElement=2,jn("StructArrayLayout1ui2",Hn);class Ra extends A{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(o,m,b,T){const $=this.length;return this.resize($+1),this.emplace($,o,m,b,T)}emplace(o,m,b,T,$){const V=4*o;return this.float32[V+0]=m,this.float32[V+1]=b,this.float32[V+2]=T,this.float32[V+3]=$,o}}Ra.prototype.bytesPerElement=16,jn("StructArrayLayout4f16",Ra);class ln extends E{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new x(this.anchorPointX,this.anchorPointY)}}ln.prototype.size=20;class Nn extends Ht{get(o){return new ln(this,o)}}jn("CollisionBoxArray",Nn);class aa extends E{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(o){this._structArray.uint8[this._pos1+37]=o}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(o){this._structArray.uint8[this._pos1+38]=o}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(o){this._structArray.uint32[this._pos4+10]=o}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}aa.prototype.size=48;class mi extends As{get(o){return new aa(this,o)}}jn("PlacedSymbolArray",mi);class er extends E{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(o){this._structArray.uint32[this._pos4+12]=o}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}er.prototype.size=64;class Sr extends sn{get(o){return new er(this,o)}}jn("SymbolInstanceArray",Sr);class Pi extends pn{getoffsetX(o){return this.float32[1*o+0]}}jn("GlyphOffsetArray",Pi);class al extends _e{getx(o){return this.int16[3*o+0]}gety(o){return this.int16[3*o+1]}gettileUnitDistanceFromAnchor(o){return this.int16[3*o+2]}}jn("SymbolLineVertexArray",al);class Dd extends E{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Dd.prototype.size=12;class Ti extends Ln{get(o){return new Dd(this,o)}}jn("TextAnchorOffsetArray",Ti);class fc extends E{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}fc.prototype.size=8;class El extends Js{get(o){return new fc(this,o)}}jn("FeatureIndexArray",El);class Ql extends he{}class Ol extends he{}class Rd extends he{}class qu extends Me{}class Jm extends Je{}class Vo extends ut{}class Bl extends gt{}class Zf extends St{}class Wf extends Lt{}class td extends Vt{}class vd extends Et{}class ju extends ss{}class Rc extends cs{}class $l extends on{}const rl=ee([{name:"a_pos",components:2,type:"Int16"}],4),{members:Fc}=rl;class qr{constructor(o=[]){this.segments=o}prepareSegment(o,m,b,T){let $=this.segments[this.segments.length-1];return o>qr.MAX_VERTEX_ARRAY_LENGTH&&oe(`Max vertices per segment is ${qr.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${o}`),(!$||$.vertexLength+o>qr.MAX_VERTEX_ARRAY_LENGTH||$.sortKey!==T)&&($={vertexOffset:m.length,primitiveOffset:b.length,vertexLength:0,primitiveLength:0},T!==void 0&&($.sortKey=T),this.segments.push($)),$}get(){return this.segments}destroy(){for(const o of this.segments)for(const m in o.vaos)o.vaos[m].destroy()}static simpleSegment(o,m,b,T){return new qr([{vertexOffset:o,primitiveOffset:m,vertexLength:b,primitiveLength:T,vaos:{},sortKey:0}])}}function su(d,o){return 256*(d=te(Math.floor(d),0,255))+te(Math.floor(o),0,255)}qr.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,jn("SegmentVector",qr);const Gu=ee([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var jh={exports:{}},Yf={exports:{}};Yf.exports=function(d,o){var m,b,T,$,V,U,ne,me;for(b=d.length-(m=3&d.length),T=o,V=3432918353,U=461845907,me=0;me<b;)ne=255&d.charCodeAt(me)|(255&d.charCodeAt(++me))<<8|(255&d.charCodeAt(++me))<<16|(255&d.charCodeAt(++me))<<24,++me,T=27492+(65535&($=5*(65535&(T=(T^=ne=(65535&(ne=(ne=(65535&ne)*V+(((ne>>>16)*V&65535)<<16)&4294967295)<<15|ne>>>17))*U+(((ne>>>16)*U&65535)<<16)&4294967295)<<13|T>>>19))+((5*(T>>>16)&65535)<<16)&4294967295))+((58964+($>>>16)&65535)<<16);switch(ne=0,m){case 3:ne^=(255&d.charCodeAt(me+2))<<16;case 2:ne^=(255&d.charCodeAt(me+1))<<8;case 1:T^=ne=(65535&(ne=(ne=(65535&(ne^=255&d.charCodeAt(me)))*V+(((ne>>>16)*V&65535)<<16)&4294967295)<<15|ne>>>17))*U+(((ne>>>16)*U&65535)<<16)&4294967295}return T^=d.length,T=2246822507*(65535&(T^=T>>>16))+((2246822507*(T>>>16)&65535)<<16)&4294967295,T=3266489909*(65535&(T^=T>>>13))+((3266489909*(T>>>16)&65535)<<16)&4294967295,(T^=T>>>16)>>>0};var Xf=Yf.exports,wh={exports:{}};wh.exports=function(d,o){for(var m,b=d.length,T=o^b,$=0;b>=4;)m=1540483477*(65535&(m=255&d.charCodeAt($)|(255&d.charCodeAt(++$))<<8|(255&d.charCodeAt(++$))<<16|(255&d.charCodeAt(++$))<<24))+((1540483477*(m>>>16)&65535)<<16),T=1540483477*(65535&T)+((1540483477*(T>>>16)&65535)<<16)^(m=1540483477*(65535&(m^=m>>>24))+((1540483477*(m>>>16)&65535)<<16)),b-=4,++$;switch(b){case 3:T^=(255&d.charCodeAt($+2))<<16;case 2:T^=(255&d.charCodeAt($+1))<<8;case 1:T=1540483477*(65535&(T^=255&d.charCodeAt($)))+((1540483477*(T>>>16)&65535)<<16)}return T=1540483477*(65535&(T^=T>>>13))+((1540483477*(T>>>16)&65535)<<16),(T^=T>>>15)>>>0};var sd=Xf,Lp=wh.exports;jh.exports=sd,jh.exports.murmur3=sd,jh.exports.murmur2=Lp;var bm=_(jh.exports);class jm{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(o,m,b,T){this.ids.push(Gh(o)),this.positions.push(m,b,T)}getPositions(o){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const m=Gh(o);let b=0,T=this.ids.length-1;for(;b<T;){const V=b+T>>1;this.ids[V]>=m?T=V:b=V+1}const $=[];for(;this.ids[b]===m;)$.push({index:this.positions[3*b],start:this.positions[3*b+1],end:this.positions[3*b+2]}),b++;return $}static serialize(o,m){const b=new Float64Array(o.ids),T=new Uint32Array(o.positions);return Nh(b,T,0,b.length-1),m&&m.push(b.buffer,T.buffer),{ids:b,positions:T}}static deserialize(o){const m=new jm;return m.ids=o.ids,m.positions=o.positions,m.indexed=!0,m}}function Gh(d){const o=+d;return!isNaN(o)&&o<=Number.MAX_SAFE_INTEGER?o:bm(String(d))}function Nh(d,o,m,b){for(;m<b;){const T=d[m+b>>1];let $=m-1,V=b+1;for(;;){do $++;while(d[$]<T);do V--;while(d[V]>T);if($>=V)break;Hu(d,$,V),Hu(o,3*$,3*V),Hu(o,3*$+1,3*V+1),Hu(o,3*$+2,3*V+2)}V-m<b-V?(Nh(d,o,m,V),m=V+1):(Nh(d,o,V+1,b),b=V)}}function Hu(d,o,m){const b=d[o];d[o]=d[m],d[m]=b}jn("FeaturePositionMap",jm);class Zu{constructor(o,m){this.gl=o.gl,this.location=m}}class Wu extends Zu{constructor(o,m){super(o,m),this.current=0}
1962set(o){this.current!==o&&(this.current=o,this.gl.uniform1f(this.location,o))}}class X0 extends Zu{constructor(o,m){super(o,m),this.current=[0,0,0,0]}set(o){o[0]===this.current[0]&&o[1]===this.current[1]&&o[2]===this.current[2]&&o[3]===this.current[3]||(this.current=o,this.gl.uniform4f(this.location,o[0],o[1],o[2],o[3]))}}class Qm extends Zu{constructor(o,m){super(o,m),this.current=An.transparent}set(o){o.r===this.current.r&&o.g===this.current.g&&o.b===this.current.b&&o.a===this.current.a||(this.current=o,this.gl.uniform4f(this.location,o.r,o.g,o.b,o.a))}}const bd=new Float32Array(16);function Gg(d){return[su(255*d.r,255*d.g),su(255*d.b,255*d.a)]}class Um{constructor(o,m,b){this.value=o,this.uniformNames=m.map(T=>`u_${T}`),this.type=b}setUniform(o,m,b){o.set(b.constantOr(this.value))}getBinding(o,m,b){return this.type==="color"?new Qm(o,m):new Wu(o,m)}}class ef{constructor(o,m){this.uniformNames=m.map(b=>`u_${b}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(o,m){this.pixelRatioFrom=m.pixelRatio,this.pixelRatioTo=o.pixelRatio,this.patternFrom=m.tlbr,this.patternTo=o.tlbr}setUniform(o,m,b,T){const $=T==="u_pattern_to"?this.patternTo:T==="u_pattern_from"?this.patternFrom:T==="u_pixel_ratio_to"?this.pixelRatioTo:T==="u_pixel_ratio_from"?this.pixelRatioFrom:null;$&&o.set($)}getBinding(o,m,b){return b.substr(0,9)==="u_pattern"?new X0(o,m):new Wu(o,m)}}class kh{constructor(o,m,b,T){this.expression=o,this.type=b,this.maxValue=0,this.paintVertexAttributes=m.map($=>({name:`a_${$}`,type:"Float32",components:b==="color"?2:1,offset:0})),this.paintVertexArray=new T}populatePaintArray(o,m,b,T,$){const V=this.paintVertexArray.length,U=this.expression.evaluate(new yi(0),m,{},T,[],$);this.paintVertexArray.resize(o),this._setPaintValue(V,o,U)}updatePaintArray(o,m,b,T){const $=this.expression.evaluate({zoom:0},b,T);this._setPaintValue(o,m,$)}_setPaintValue(o,m,b){if(this.type==="color"){const T=Gg(b);for(let $=o;$<m;$++)this.paintVertexArray.emplace($,T[0],T[1])}else{for(let T=o;T<m;T++)this.paintVertexArray.emplace(T,b);this.maxValue=Math.max(this.maxValue,Math.abs(b))}}upload(o){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=o.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class wu{constructor(o,m,b,T,$,V){this.expression=o,this.uniformNames=m.map(U=>`u_${U}_t`),this.type=b,this.useIntegerZoom=T,this.zoom=$,this.maxValue=0,this.paintVertexAttributes=m.map(U=>({name:`a_${U}`,type:"Float32",components:b==="color"?4:2,offset:0})),this.paintVertexArray=new V}populatePaintArray(o,m,b,T,$){const V=this.expression.evaluate(new yi(this.zoom),m,{},T,[],$),U=this.expression.evaluate(new yi(this.zoom+1),m,{},T,[],$),ne=this.paintVertexArray.length;this.paintVertexArray.resize(o),this._setPaintValue(ne,o,V,U)}updatePaintArray(o,m,b,T){const $=this.expression.evaluate({zoom:this.zoom},b,T),V=this.expression.evaluate({zoom:this.zoom+1},b,T);this._setPaintValue(o,m,$,V)}_setPaintValue(o,m,b,T){if(this.type==="color"){const $=Gg(b),V=Gg(T);for(let U=o;U<m;U++)this.paintVertexArray.emplace(U,$[0],$[1],V[0],V[1])}else{for(let $=o;$<m;$++)this.paintVertexArray.emplace($,b,T);this.maxValue=Math.max(this.maxValue,Math.abs(b),Math.abs(T))}}upload(o){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=o.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(o,m){const b=this.useIntegerZoom?Math.floor(m.zoom):m.zoom,T=te(this.expression.interpolationFactor(b,this.zoom,this.zoom+1),0,1);o.set(T)}getBinding(o,m,b){return new Wu(o,m)}}class Fd{constructor(o,m,b,T,$,V){this.expression=o,this.type=m,this.useIntegerZoom=b,this.zoom=T,this.layerId=V,this.zoomInPaintVertexArray=new $,this.zoomOutPaintVertexArray=new $}populatePaintArray(o,m,b){const T=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(o),this.zoomOutPaintVertexArray.resize(o),this._setPaintValues(T,o,m.patterns&&m.patterns[this.layerId],b)}updatePaintArray(o,m,b,T,$){this._setPaintValues(o,m,b.patterns&&b.patterns[this.layerId],$)}_setPaintValues(o,m,b,T){if(!T||!b)return;const{min:$,mid:V,max:U}=b,ne=T[$],me=T[V],ye=T[U];if(ne&&me&&ye)for(let Te=o;Te<m;Te++)this.zoomInPaintVertexArray.emplace(Te,me.tl[0],me.tl[1],me.br[0],me.br[1],ne.tl[0],ne.tl[1],ne.br[0],ne.br[1],me.pixelRatio,ne.pixelRatio),this.zoomOutPaintVertexArray.emplace(Te,me.tl[0],me.tl[1],me.br[0],me.br[1],ye.tl[0],ye.tl[1],ye.br[0],ye.br[1],me.pixelRatio,ye.pixelRatio)}upload(o){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=o.createVertexBuffer(this.zoomInPaintVertexArray,Gu.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=o.createVertexBuffer(this.zoomOutPaintVertexArray,Gu.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class Ul{constructor(o,m,b){this.binders={},this._buffers=[];const T=[];for(const $ in o.paint._values){if(!b($))continue;const V=o.paint.get($);if(!(V instanceof yd&&xl(V.property.specification)))continue;const U=Hg($,o.type),ne=V.value,me=V.property.specification.type,ye=V.property.useIntegerZoom,Te=V.property.specification["property-type"],$e=Te==="cross-faded"||Te==="cross-faded-data-driven";if(ne.kind==="constant")this.binders[$]=$e?new ef(ne.value,U):new Um(ne.value,U,me),T.push(`/u_${$}`);else if(ne.kind==="source"||$e){const Ye=Nu($,me,"source");this.binders[$]=$e?new Fd(ne,me,ye,m,Ye,o.id):new kh(ne,U,me,Ye),T.push(`/a_${$}`)}else{const Ye=Nu($,me,"composite");this.binders[$]=new wu(ne,U,me,ye,m,Ye),T.push(`/z_${$}`)}}this.cacheKey=T.sort().join("")}getMaxValue(o){const m=this.binders[o];return m instanceof kh||m instanceof wu?m.maxValue:0}populatePaintArrays(o,m,b,T,$){for(const V in this.binders){const U=this.binders[V];(U instanceof kh||U instanceof wu||U instanceof Fd)&&U.populatePaintArray(o,m,b,T,$)}}setConstantPatternPositions(o,m){for(const b in this.binders){const T=this.binders[b];T instanceof ef&&T.setConstantPatternPositions(o,m)}}updatePaintArrays(o,m,b,T,$){let V=!1;for(const U in o){const ne=m.getPositions(U);for(const me of ne){const ye=b.feature(me.index);for(const Te in this.binders){const $e=this.binders[Te];if(($e instanceof kh||$e instanceof wu||$e instanceof Fd)&&$e.expression.isStateDependent===!0){const Ye=T.paint.get(Te);$e.expression=Ye.value,$e.updatePaintArray(me.start,me.end,ye,o[U],$),V=!0}}}}return V}defines(){const o=[];for(const m in this.binders){const b=this.binders[m];(b instanceof Um||b instanceof ef)&&o.push(...b.uniformNames.map(T=>`#define HAS_UNIFORM_${T}`))}return o}getBinderAttributes(){const o=[];for(const m in this.binders){const b=this.binders[m];if(b instanceof kh||b instanceof wu)for(let T=0;T<b.paintVertexAttributes.length;T++)o.push(b.paintVertexAttributes[T].name);else if(b instanceof Fd)for(let T=0;T<Gu.members.length;T++)o.push(Gu.members[T].name)}return o}getBinderUniforms(){const o=[];for(const m in this.binders){const b=this.binders[m];if(b instanceof Um||b instanceof ef||b instanceof wu)for(const T of b.uniformNames)o.push(T)}return o}getPaintVertexBuffers(){return this._buffers}getUniforms(o,m){const b=[];for(const T in this.binders){const $=this.binders[T];if($ instanceof Um||$ instanceof ef||$ instanceof wu){for(const V of $.uniformNames)if(m[V]){const U=$.getBinding(o,m[V],V);b.push({name:V,property:T,binding:U})}}}return b}setUniforms(o,m,b,T){for(const{name:$,property:V,binding:U}of m)this.binders[V].setUniform(U,T,b.get(V),$)}updatePaintBuffers(o){this._buffers=[];for(const m in this.binders){const b=this.binders[m];if(o&&b instanceof Fd){const T=o.fromScale===2?b.zoomInPaintVertexBuffer:b.zoomOutPaintVertexBuffer;T&&this._buffers.push(T)}else(b instanceof kh||b instanceof wu)&&b.paintVertexBuffer&&this._buffers.push(b.paintVertexBuffer)}}upload(o){for(const m in this.binders){const b=this.binders[m];(b instanceof kh||b instanceof wu||b instanceof Fd)&&b.upload(o)}this.updatePaintBuffers()}destroy(){for(const o in this.binders){const m=this.binders[o];(m instanceof kh||m instanceof wu||m instanceof Fd)&&m.destroy()}}}class Hh{constructor(o,m,b=()=>!0){this.programConfigurations={};for(const T of o)this.programConfigurations[T.id]=new Ul(T,m,b);this.needsUpload=!1,this._featureMap=new jm,this._bufferOffset=0}populatePaintArrays(o,m,b,T,$,V){for(const U in this.programConfigurations)this.programConfigurations[U].populatePaintArrays(o,m,T,$,V);
1962m.id!==void 0&&this._featureMap.add(m.id,b,this._bufferOffset,o),this._bufferOffset=o,this.needsUpload=!0}updatePaintArrays(o,m,b,T){for(const $ of b)this.needsUpload=this.programConfigurations[$.id].updatePaintArrays(o,this._featureMap,m,$,T)||this.needsUpload}get(o){return this.programConfigurations[o]}upload(o){if(this.needsUpload){for(const m in this.programConfigurations)this.programConfigurations[m].upload(o);this.needsUpload=!1}}destroy(){for(const o in this.programConfigurations)this.programConfigurations[o].destroy()}}function Hg(d,o){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[d]||[d.replace(`${o}-`,"").replace(/-/g,"_")]}function Nu(d,o,m){const b={color:{source:ut,composite:Ra},number:{source:pn,composite:ut}},T=function($){return{"line-pattern":{source:Bl,composite:Bl},"fill-pattern":{source:Bl,composite:Bl},"fill-extrusion-pattern":{source:Bl,composite:Bl}}[$]}(d);return T&&T[m]||b[o][m]}jn("ConstantBinder",Um),jn("CrossFadedConstantBinder",ef),jn("SourceExpressionBinder",kh),jn("CrossFadedCompositeBinder",Fd),jn("CompositeExpressionBinder",wu),jn("ProgramConfiguration",Ul,{omit:["_buffers"]}),jn("ProgramConfigurationSet",Hh);const Oi=8192,Yu=Math.pow(2,14)-1,Zg=-Yu-1;function Zh(d){const o=Oi/d.extent,m=d.loadGeometry();for(let b=0;b<m.length;b++){const T=m[b];for(let $=0;$<T.length;$++){const V=T[$],U=Math.round(V.x*o),ne=Math.round(V.y*o);V.x=te(U,Zg,Yu),V.y=te(ne,Zg,Yu),(U<V.x||U>V.x+1||ne<V.y||ne>V.y+1)&&oe("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return m}function Wh(d,o){return{type:d.type,id:d.id,properties:d.properties,geometry:o?Zh(d):[]}}function Yh(d,o,m,b,T){d.emplaceBack(2*o+(b+1)/2,2*m+(T+1)/2)}class Mp{constructor(o){this.zoom=o.zoom,this.overscaling=o.overscaling,this.layers=o.layers,this.layerIds=this.layers.map(m=>m.id),this.index=o.index,this.hasPattern=!1,this.layoutVertexArray=new Ol,this.indexArray=new Rc,this.segments=new qr,this.programConfigurations=new Hh(o.layers,o.zoom),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id)}populate(o,m,b){const T=this.layers[0],$=[];let V=null,U=!1;T.type==="circle"&&(V=T.layout.get("circle-sort-key"),U=!V.isConstant());for(const{feature:ne,id:me,index:ye,sourceLayerIndex:Te}of o){const $e=this.layers[0]._featureFilter.needGeometry,Ye=Wh(ne,$e);if(!this.layers[0]._featureFilter.filter(new yi(this.zoom),Ye,b))continue;const et=U?V.evaluate(Ye,{},b):void 0,mt={id:me,properties:ne.properties,type:ne.type,sourceLayerIndex:Te,index:ye,geometry:$e?Ye.geometry:Zh(ne),patterns:{},sortKey:et};$.push(mt)}U&&$.sort((ne,me)=>ne.sortKey-me.sortKey);for(const ne of $){const{geometry:me,index:ye,sourceLayerIndex:Te}=ne,$e=o[ye].feature;this.addFeature(ne,me,ye,b),m.featureIndex.insert($e,me,ye,Te,this.index)}}update(o,m,b){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(o,m,this.stateDependentLayers,b)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(o){this.uploaded||(this.layoutVertexBuffer=o.createVertexBuffer(this.layoutVertexArray,Fc),this.indexBuffer=o.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(o),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(o,m,b,T){for(const $ of m)for(const V of $){const U=V.x,ne=V.y;if(U<0||U>=Oi||ne<0||ne>=Oi)continue;const me=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,o.sortKey),ye=me.vertexLength;Yh(this.layoutVertexArray,U,ne,-1,-1),Yh(this.layoutVertexArray,U,ne,1,-1),Yh(this.layoutVertexArray,U,ne,1,1),Yh(this.layoutVertexArray,U,ne,-1,1),this.indexArray.emplaceBack(ye,ye+1,ye+2),this.indexArray.emplaceBack(ye,ye+3,ye+2),me.vertexLength+=4,me.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,o,b,{},T)}}function wm(d,o){for(let m=0;m<d.length;m++)if(Xu(o,d[m]))return!0;for(let m=0;m<o.length;m++)if(Xu(d,o[m]))return!0;return!!Nm(d,o)}function Kf(d,o,m){return!!Xu(d,o)||!!tf(o,d,m)}function Wg(d,o){if(d.length===1)return Ap(o,d[0]);for(let m=0;m<o.length;m++){const b=o[m];for(let T=0;T<b.length;T++)if(Xu(d,b[T]))return!0}for(let m=0;m<d.length;m++)if(Ap(o,d[m]))return!0;for(let m=0;m<o.length;m++)if(Nm(d,o[m]))return!0;return!1}function Yg(d,o,m){if(d.length>1){if(Nm(d,o))return!0;for(let b=0;b<o.length;b++)if(tf(o[b],d,m))return!0}for(let b=0;b<d.length;b++)if(tf(d[b],o,m))return!0;return!1}function Nm(d,o){if(d.length===0||o.length===0)return!1;for(let m=0;m<d.length-1;m++){const b=d[m],T=d[m+1];for(let $=0;$<o.length-1;$++)if(Jf(b,T,o[$],o[$+1]))return!0}return!1}function Jf(d,o,m,b){return ce(d,m,b)!==ce(o,m,b)&&ce(d,o,m)!==ce(d,o,b)}function tf(d,o,m){const b=m*m;if(o.length===1)return d.distSqr(o[0])<b;for(let T=1;T<o.length;
vendor: 18,242 bytes, line 1962
1962T++)if(Ip(d,o[T-1],o[T])<b)return!0;return!1}function Ip(d,o,m){const b=o.distSqr(m);if(b===0)return d.distSqr(o);const T=((d.x-o.x)*(m.x-o.x)+(d.y-o.y)*(m.y-o.y))/b;return d.distSqr(T<0?o:T>1?m:m.sub(o)._mult(T)._add(o))}function Ap(d,o){let m,b,T,$=!1;for(let V=0;V<d.length;V++){m=d[V];for(let U=0,ne=m.length-1;U<m.length;ne=U++)b=m[U],T=m[ne],b.y>o.y!=T.y>o.y&&o.x<(T.x-b.x)*(o.y-b.y)/(T.y-b.y)+b.x&&($=!$)}return $}function Xu(d,o){let m=!1;for(let b=0,T=d.length-1;b<d.length;T=b++){const $=d[b],V=d[T];$.y>o.y!=V.y>o.y&&o.x<(V.x-$.x)*(o.y-$.y)/(V.y-$.y)+$.x&&(m=!m)}return m}function K0(d,o,m){const b=m[0],T=m[2];if(d.x<b.x&&o.x<b.x||d.x>T.x&&o.x>T.x||d.y<b.y&&o.y<b.y||d.y>T.y&&o.y>T.y)return!1;const $=ce(d,o,m[0]);return $!==ce(d,o,m[1])||$!==ce(d,o,m[2])||$!==ce(d,o,m[3])}function sf(d,o,m){const b=o.paint.get(d).value;return b.kind==="constant"?b.value:m.programConfigurations.get(o.id).getMaxValue(d)}function nf(d){return Math.sqrt(d[0]*d[0]+d[1]*d[1])}function Xh(d,o,m,b,T){if(!o[0]&&!o[1])return d;const $=x.convert(o)._mult(T);m==="viewport"&&$._rotate(-b);const V=[];for(let U=0;U<d.length;U++)V.push(d[U].sub($));return V}let __,y_;jn("CircleBucket",Mp,{omit:["layers"]});var Dp={get paint(){return y_=y_||new R({"circle-radius":new ia(He.paint_circle["circle-radius"]),"circle-color":new ia(He.paint_circle["circle-color"]),"circle-blur":new ia(He.paint_circle["circle-blur"]),"circle-opacity":new ia(He.paint_circle["circle-opacity"]),"circle-translate":new ea(He.paint_circle["circle-translate"]),"circle-translate-anchor":new ea(He.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new ea(He.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new ea(He.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new ia(He.paint_circle["circle-stroke-width"]),"circle-stroke-color":new ia(He.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new ia(He.paint_circle["circle-stroke-opacity"])})},get layout(){return __=__||new R({"circle-sort-key":new ia(He.layout_circle["circle-sort-key"])})}},pc=1e-6,km=typeof Float32Array<"u"?Float32Array:Array;function Ne(d){return d[0]=1,d[1]=0,d[2]=0,d[3]=0,d[4]=0,d[5]=1,d[6]=0,d[7]=0,d[8]=0,d[9]=0,d[10]=1,d[11]=0,d[12]=0,d[13]=0,d[14]=0,d[15]=1,d}function Oe(d,o,m){var b=o[0],T=o[1],$=o[2],V=o[3],U=o[4],ne=o[5],me=o[6],ye=o[7],Te=o[8],$e=o[9],Ye=o[10],et=o[11],mt=o[12],Tt=o[13],Ot=o[14],gs=o[15],Yt=m[0],ls=m[1],Cs=m[2],Us=m[3];return d[0]=Yt*b+ls*U+Cs*Te+Us*mt,d[1]=Yt*T+ls*ne+Cs*$e+Us*Tt,d[2]=Yt*$+ls*me+Cs*Ye+Us*Ot,d[3]=Yt*V+ls*ye+Cs*et+Us*gs,d[4]=(Yt=m[4])*b+(ls=m[5])*U+(Cs=m[6])*Te+(Us=m[7])*mt,d[5]=Yt*T+ls*ne+Cs*$e+Us*Tt,d[6]=Yt*$+ls*me+Cs*Ye+Us*Ot,d[7]=Yt*V+ls*ye+Cs*et+Us*gs,d[8]=(Yt=m[8])*b+(ls=m[9])*U+(Cs=m[10])*Te+(Us=m[11])*mt,d[9]=Yt*T+ls*ne+Cs*$e+Us*Tt,d[10]=Yt*$+ls*me+Cs*Ye+Us*Ot,d[11]=Yt*V+ls*ye+Cs*et+Us*gs,d[12]=(Yt=m[12])*b+(ls=m[13])*U+(Cs=m[14])*Te+(Us=m[15])*mt,d[13]=Yt*T+ls*ne+Cs*$e+Us*Tt,d[14]=Yt*$+ls*me+Cs*Ye+Us*Ot,d[15]=Yt*V+ls*ye+Cs*et+Us*gs,d}Math.hypot||(Math.hypot=function(){for(var d=0,o=arguments.length;o--;)d+=arguments[o]*arguments[o];return Math.sqrt(d)});var lt,pt=Oe;function It(d,o,m){var b=o[0],T=o[1],$=o[2],V=o[3];return d[0]=m[0]*b+m[4]*T+m[8]*$+m[12]*V,d[1]=m[1]*b+m[5]*T+m[9]*$+m[13]*V,d[2]=m[2]*b+m[6]*T+m[10]*$+m[14]*V,d[3]=m[3]*b+m[7]*T+m[11]*$+m[15]*V,d}lt=new km(4),km!=Float32Array&&(lt[0]=0,lt[1]=0,lt[2]=0,lt[3]=0);class yt extends g{constructor(o){super(o,Dp)}createBucket(o){return new Mp(o)}queryRadius(o){const m=o;return sf("circle-radius",this,m)+sf("circle-stroke-width",this,m)+nf(this.paint.get("circle-translate"))}queryIntersectsFeature(o,m,b,T,$,V,U,ne){const me=Xh(o,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),V.angle,U),ye=this.paint.get("circle-radius").evaluate(m,b)+this.paint.get("circle-stroke-width").evaluate(m,b),Te=this.paint.get("circle-pitch-alignment")==="map",$e=Te?me:function(et,mt){return et.map(Tt=>at(Tt,mt))}(me,ne),Ye=Te?ye*U:ye;for(const et of T)for(const mt of et){const Tt=Te?mt:at(mt,ne);let Ot=Ye;const gs=It([],[mt.x,mt.y,0,1],ne);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?Ot*=gs[3]/V.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(Ot*=V.cameraToCenterDistance/gs[3]),Kf($e,Tt,Ot))return!0}return!1}}function at(d,o){const m=It([],[d.x,d.y,0,1],o);return new x(m[0]/m[3],m[1]/m[3])}class Pt extends Mp{}let Qt;jn("HeatmapBucket",Pt,{omit:["layers"]});var Ft={get paint(){return Qt=Qt||new R({"heatmap-radius":new ia(He.paint_heatmap["heatmap-radius"]),"heatmap-weight":new ia(He.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new ea(He.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Km(He.paint_heatmap["heatmap-color"]),"heatmap-opacity":new ea(He.paint_heatmap["heatmap-opacity"])})}};function Gt(d,{width:o,height:m},b,T){if(T){if(T instanceof Uint8ClampedArray)T=new Uint8Array(T.buffer);else if(T.length!==o*m*b)throw new RangeError(`mismatched image size. expected: ${T.length} but got: ${o*m*b}`)}else T=new Uint8Array(o*m*b);return d.width=o,d.height=m,d.data=T,d}function ms(d,{width:o,height:m},b){if(o===d.width&&m===d.height)return;const T=Gt({},{width:o,height:m},b);Wt(d,T,{x:0,y:0},{x:0,y:0},{width:Math.min(d.width,o),height:Math.min(d.height,m)},b),d.width=o,d.height=m,d.data=T.data}function Wt(d,o,m,b,T,$){if(T.width===0||T.height===0)return o;if(T.width>d.width||T.height>d.height||m.x>d.width-T.width||m.y>d.height-T.height)throw new RangeError("out of range source coordinates for image copy");if(T.width>o.width||T.height>o.height||b.x>o.width-T.width||b.y>o.height-T.height)throw new RangeError("out of range destination coordinates for image copy");const V=d.data,U=o.data;if(V===U)throw new Error("srcData equals dstData, so image is already copied");for(let ne=0;ne<T.height;ne++){const me=((m.y+ne)*d.width+m.x)*$,ye=((b.y+ne)*o.width+b.x)*$;for(let Te=0;Te<T.width*$;Te++)U[ye+Te]=V[me+Te]}return o}class Ss{constructor(o,m){Gt(this,o,1,m)}resize(o){ms(this,o,1)}clone(){return new Ss({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(o,m,b,T,$){Wt(o,m,b,T,$,1)}}class Ms{constructor(o,m){Gt(this,o,4,m)}resize(o){ms(this,o,4)}replace(o,m){m?this.data.set(o):this.data=o instanceof Uint8ClampedArray?new Uint8Array(o.buffer):o}clone(){return new Ms({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(o,m,b,T,$){Wt(o,m,b,T,$,4)}}function hn(d){const o={},m=d.resolution||256,b=d.clips?d.clips.length:1,T=d.image||new Ms({width:m,height:b});if(Math.log(m)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${m}`);const $=(V,U,ne)=>{o[d.evaluationKey]=ne;const me=d.expression.evaluate(o);T.data[V+U+0]=Math.floor(255*me.r/me.a),T.data[V+U+1]=Math.floor(255*me.g/me.a),T.data[V+U+2]=Math.floor(255*me.b/me.a),T.data[V+U+3]=Math.floor(255*me.a)};if(d.clips)for(let V=0,U=0;V<b;++V,U+=4*m)for(let ne=0,me=0;ne<m;ne++,me+=4){const ye=ne/(m-1),{start:Te,end:$e}=d.clips[V];$(U,me,Te*(1-ye)+$e*ye)}else for(let V=0,U=0;V<m;V++,U+=4)$(0,U,V/(m-1));return T}jn("AlphaImage",Ss),jn("RGBAImage",Ms);const Vn="big-fb";class ka extends g{createBucket(o){return new Pt(o)}constructor(o){super(o,Ft),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(o){o==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=hn({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Vn)&&this.heatmapFbos.delete(Vn)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}}let Fa;var Er={get paint(){return Fa=Fa||new R({"hillshade-illumination-direction":new ea(He.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new ea(He.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new ea(He.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new ea(He.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new ea(He.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new ea(He.paint_hillshade["hillshade-accent-color"])})}};class Ga extends g{constructor(o){super(o,Er)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}}const Zi=ee([{name:"a_pos",components:2,type:"Int16"}],4),{members:Po}=Zi;function po(d,o,m=2){const b=o&&o.length,T=b?o[0]*m:d.length;let $=Pl(d,0,T,m,!0);const V=[];if(!$||$.next===$.prev)return V;let U,ne,me;if(b&&($=function(ye,Te,$e,Ye){const et=[];for(let mt=0,Tt=Te.length;mt<Tt;mt++){const Ot=Pl(ye,Te[mt]*Ye,mt<Tt-1?Te[mt+1]*Ye:ye.length,Ye,!1);Ot===Ot.next&&(Ot.steiner=!0),et.push(dn(Ot))}et.sort(En);for(let mt=0;mt<et.length;mt++)$e=pr(et[mt],$e);return $e}(d,o,$,m)),d.length>80*m){U=1/0,ne=1/0;let ye=-1/0,Te=-1/0;for(let $e=m;$e<T;$e+=m){const Ye=d[$e],et=d[$e+1];Ye<U&&(U=Ye),et<ne&&(ne=et),Ye>ye&&(ye=Ye),et>Te&&(Te=et)}me=Math.max(ye-U,Te-ne),me=me!==0?32767/me:0}return di($,V,m,U,ne,me,0),V}function Pl(d,o,m,b,T){let $;if(T===function(V,U,ne,me){let ye=0;for(let Te=U,$e=ne-me;Te<ne;Te+=me)ye+=(V[$e]-V[Te])*(V[Te+1]+V[$e+1]),$e=Te;return ye}(d,o,m,b)>0)for(let V=o;V<m;V+=b)$=ar(V/b|0,d[V],d[V+1],$);else for(let V=m-b;V>=o;V-=b)$=ar(V/b|0,d[V],d[V+1],$);return $&&Xs($,$.next)&&(Wa($),$=$.next),$}function zc(d,o){if(!d)return d;o||(o=d);let m,b=d;do if(m=!1,b.steiner||!Xs(b,b.next)&&mn(b.prev,b,b.next)!==0)b=b.next;else{if(Wa(b),b=o=b.prev,b===b.next)break;m=!0}while(m||b!==o);return o}function di(d,o,m,b,T,$,V){if(!d)return;!V&&$&&function(ne,me,ye,Te){let $e=ne;do $e.z===0&&($e.z=Ys($e.x,$e.y,me,ye,Te)),$e.prevZ=$e.prev,$e.nextZ=$e.next,$e=$e.next;while($e!==ne);$e.prevZ.nextZ=null,$e.prevZ=null,function(Ye){let et,mt=1;do{let Tt,Ot=Ye;Ye=null;let gs=null;for(et=0;Ot;){et++;let Yt=Ot,ls=0;for(let Us=0;Us<mt&&(ls++,Yt=Yt.nextZ,Yt);Us++);let Cs=mt;for(;ls>0||Cs>0&&Yt;)ls!==0&&(Cs===0||!Yt||Ot.z<=Yt.z)?(Tt=Ot,Ot=Ot.nextZ,ls--):(Tt=Yt,Yt=Yt.nextZ,Cs--),gs?gs.nextZ=Tt:Ye=Tt,Tt.prevZ=gs,gs=Tt;Ot=Yt}gs.nextZ=null,mt*=2}while(et>1)}($e)}(d,b,T,$);let U=d;for(;d.prev!==d.next;){const ne=d.prev,me=d.next;if($?nu(d,b,T,$):Ku(d))o.push(ne.i,d.i,me.i),Wa(d),d=me.next,U=me.next;else if((d=me)===U){V?V===1?di(d=zn(zc(d),o),o,m,b,T,$,2):V===2&&Ja(d,o,m,b,T,$):di(zc(d),o,m,b,T,$,1);break}}}function Ku(d){const o=d.prev,m=d,b=d.next;if(mn(o,m,b)>=0)return!1;const T=o.x,$=m.x,V=b.x,U=o.y,ne=m.y,me=b.y,ye=T<$?T<V?T:V:$<V?$:V,Te=U<ne?U<me?U:me:ne<me?ne:me,$e=T>$?T>V?T:V:$>V?$:V,Ye=U>ne?U>me?U:me:ne>me?ne:me;let et=b.next;for(;et!==o;){if(et.x>=ye&&et.x<=$e&&et.y>=Te&&et.y<=Ye&&qn(T,U,$,ne,V,me,et.x,et.y)&&mn(et.prev,et,et.next)>=0)return!1;et=et.next}return!0}function nu(d,o,m,b){const T=d.prev,$=d,V=d.next;if(mn(T,$,V)>=0)return!1;const U=T.x,ne=$.x,me=V.x,ye=T.y,Te=$.y,$e=V.y,Ye=U<ne?U<me?U:me:ne<me?ne:me,et=ye<Te?ye<$e?ye:$e:Te<$e?Te:$e,mt=U>ne?U>me?U:me:ne>me?ne:me,Tt=ye>Te?ye>$e?ye:$e:Te>$e?Te:$e,Ot=Ys(Ye,et,o,m,b),gs=Ys(mt,Tt,o,m,b);let Yt=d.prevZ,ls=d.nextZ;for(;Yt&&Yt.z>=Ot&&ls&&ls.z<=gs;){if(Yt.x>=Ye&&Yt.x<=mt&&Yt.y>=et&&Yt.y<=Tt&&Yt!==T&&Yt!==V&&qn(U,ye,ne,Te,me,$e,Yt.x,Yt.y)&&mn(Yt.prev,Yt,Yt.next)>=0||(Yt=Yt.prevZ,ls.x>=Ye&&ls.x<=mt&&ls.y>=et&&ls.y<=Tt&&ls!==T&&ls!==V&&qn(U,ye,ne,Te,me,$e,ls.x,ls.y)&&mn(ls.prev,ls,ls.next)>=0))return!1;ls=ls.nextZ}for(;Yt&&Yt.z>=Ot;){if(Yt.x>=Ye&&Yt.x<=mt&&Yt.y>=et&&Yt.y<=Tt&&Yt!==T&&Yt!==V&&qn(U,ye,ne,Te,me,$e,Yt.x,Yt.y)&&mn(Yt.prev,Yt,Yt.next)>=0)return!1;Yt=Yt.prevZ}for(;ls&&ls.z<=gs;){if(ls.x>=Ye&&ls.x<=mt&&ls.y>=et&&ls.y<=Tt&&ls!==T&&ls!==V&&qn(U,ye,ne,Te,me,$e,ls.x,ls.y)&&mn(ls.prev,ls,ls.next)>=0)return!1;ls=ls.nextZ}return!0}function zn(d,o){let m=d;do{const b=m.prev,T=m.next.next;!Xs(b,T)&&Bs(b,m,m.next,T)&&un(b,T)&&un(T,b)&&(o.push(b.i,m.i,T.i),Wa(m),Wa(m.next),m=d=T),m=m.next}while(m!==d);return zc(m)}function Ja(d,o,m,b,T,$){let V=d;do{let U=V.next.next;for(;U!==V.prev;){if(V.i!==U.i&&zs(V,U)){let ne=Qn(V,U);return V=zc(V,V.next),ne=zc(ne,ne.next),di(V,o,m,b,T,$,0),void di(ne,o,m,b,T,$,0)}U=U.next}V=V.next}while(V!==d)}function En(d,o){return d.x-o.x}function pr(d,o){const m=function(T,$){let V=$;const U=T.x,ne=T.y;let me,ye=-1/0;do{if(ne<=V.y&&ne>=V.next.y&&V.next.y!==V.y){const mt=V.x+(ne-V.y)*(V.next.x-V.x)/(V.next.y-V.y);if(mt<=U&&mt>ye&&(ye=mt,me=V.x<V.next.x?V:V.next,mt===U))return me}V=V.next}while(V!==$);if(!me)return null;const Te=me,$e=me.x,Ye=me.y;let et=1/0;V=me;do{if(U>=V.x&&V.x>=$e&&U!==V.x&&qn(ne<Ye?U:ye,ne,$e,Ye,ne<Ye?ye:U,ne,V.x,V.y)){const mt=Math.abs(ne-V.y)/(U-V.x);un(V,T)&&(mt<et||mt===et&&(V.x>me.x||V.x===me.x&&jt(me,V)))&&(me=V,et=mt)}V=V.next}while(V!==Te);return me}(d,o);if(!m)return o;const b=Qn(m,d);return zc(b,b.next),zc(m,m.next)}function jt(d,o){return mn(d.prev,d,o.prev)<0&&mn(o.next,d,d.next)<0}function Ys(d,o,m,b,T){return(d=1431655765&((d=858993459&((d=252645135&((d=16711935&((d=(d-m)*T|0)|d<<8))|d<<4))|d<<2))|d<<1))|(o=1431655765&((o=858993459&((o=252645135&((o=16711935&((o=(o-b)*T|0)|o<<8))|o<<4))|o<<2))|o<<1))<<1}function dn(d){let o=d,m=d;do(o.x<m.x||o.x===m.x&&o.y<m.y)&&(m=o),o=o.next;while(o!==d);return m}function qn(d,o,m,b,T,$,V,U){return(T-V)*(o-U)>=(d-V)*($-U)&&(d-V)*(b-U)>=(m-V)*(o-U)&&(m-V)*($-U)>=(T-V)*(b-U)}function zs(d,o){return d.next.i!==o.i&&d.prev.i!==o.i&&!function(m,b){let T=m;do{if(T.i!==m.i&&T.next.i!==m.i&&T.i!==b.i&&T.next.i!==b.i&&Bs(T,T.next,m,b))return!0;T=T.next}while(T!==m);return!1}(d,o)&&(un(d,o)&&un(o,d)&&function(m,b){let T=m,$=!1;const V=(m.x+b.x)/2,U=(m.y+b.y)/2;do T.y>U!=T.next.y>U&&T.next.y!==T.y&&V<(T.next.x-T.x)*(U-T.y)/(T.next.y-T.y)+T.x&&($=!$),T=T.next;while(T!==m);return $}(d,o)&&(mn(d.prev,d,o.prev)||mn(d,o.prev,o))||Xs(d,o)&&mn(d.prev,d,d.next)>0&&mn(o.prev,o,o.next)>0)}function mn(d,o,m){return(o.y-d.y)*(m.x-o.x)-(o.x-d.x)*(m.y-o.y)}function Xs(d,o){return d.x===o.x&&d.y===o.y}function Bs(d,o,m,b){const T=gn(mn(d,o,m)),$=gn(mn(d,o,b)),V=gn(mn(m,b,d)),U=gn(mn(m,b,o));return T!==$&&V!==U||!(T!==0||!Dn(d,m,o))||!($!==0||!Dn(d,b,o))||!(V!==0||!Dn(m,d,b))||!(U!==0||!Dn(m,o,b))}function Dn(d,o,m){return o.x<=Math.max(d.x,m.x)&&o.x>=Math.min(d.x,m.x)&&o.y<=Math.max(d.y,m.y)&&o.y>=Math.min(d.y,m.y)}function gn(d){return d>0?1:d<0?-1:0}function un(d,o){return mn(d.prev,d,d.next)<0?mn(d,o,d.next)>=0&&mn(d,d.prev,o)>=0:mn(d,o,d.prev)<0||mn(d,d.next,o)<0}function Qn(d,o){const m=nn(d.i,d.x,d.y),b=nn(o.i,o.x,o.y),T=d.next,$=o.prev;return d.next=o,o.prev=d,m.next=T,T.prev=m,b.next=m,m.prev=b,$.next=b,b.prev=$,b}function ar(d,o,m,b){const T=nn(d,o,m);return b?(T.next=b.next,T.prev=b,b.next.prev=T,b.next=T):(T.prev=T,T.next=T),T}function Wa(d){d.next.prev=d.prev,d.prev.next=d.next,d.prevZ&&(d.prevZ.nextZ=d.nextZ),d.nextZ&&(d.nextZ.prevZ=d.prevZ)}function nn(d,o,m){return{i:d,x:o,y:m,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function xn(d,o,m){const b=m.patternDependencies;let T=!1;for(const $ of o){const V=$.paint.get(`${d}-pattern`);V.isConstant()||(T=!0);const U=V.constantOr(null);U&&(T=!0,b[U.to]=!0,b[U.from]=!0)}return T}function Zn(d,o,m,b,T){const $=T.patternDependencies;for(const V of o){const U=V.paint.get(`${d}-pattern`).value;if(U.kind!=="constant"){let ne=U.evaluate({zoom:b-1},m,{},T.availableImages),me=U.evaluate({zoom:b},m,{},T.availableImages),ye=U.evaluate({zoom:b+1},m,{},T.availableImages);ne=ne&&ne.name?ne.name:ne,me=me&&me.name?me.name:me,ye=ye&&ye.name?ye.name:ye,$[ne]=!0,$[me]=!0,$[ye]=!0,m.patterns[V.id]={min:ne,mid:me,max:ye}}}return m}class ua{constructor(o){this.zoom=o.zoom,this.overscaling=o.overscaling,this.layers=o.layers,this.layerIds=this.layers.map(m=>m.id),this.index=o.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Rd,this.indexArray=new Rc,this.indexArray2=new $l,this.programConfigurations=new Hh(o.layers,o.zoom),this.segments=new qr,this.segments2=new qr,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id)}populate(o,m,b){this.hasPattern=xn("fill",this.layers,m);const T=this.layers[0].layout.get("fill-sort-key"),$=!T.isConstant(),V=[];for(const{feature:U,id:ne,index:me,sourceLayerIndex:ye}of o){const Te=this.layers[0]._featureFilter.needGeometry,$e=Wh(U,Te);if(!this.layers[0]._featureFilter.filter(new yi(this.zoom),$e,b))continue;const Ye=$?T.evaluate($e,{},b,m.availableImages):void 0,et={id:ne,properties:U.properties,type:U.type,sourceLayerIndex:ye,index:me,geometry:Te?$e.geometry:Zh(U),patterns:{},sortKey:Ye};V.push(et)}$&&V.sort((U,ne)=>U.sortKey-ne.sortKey);for(const U of V){const{geometry:ne,index:me,sourceLayerIndex:ye}=U;if(this.hasPattern){const Te=Zn("fill",this.layers,U,this.zoom,m);this.patternFeatures.push(Te)}else this.addFeature(U,ne,me,b,{});m.featureIndex.insert(o[me].feature,ne,me,ye,this.index)}}update(o,m,b){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(o,m,this.stateDependentLayers,b)}addFeatures(o,m,b){for(const T of this.patternFeatures)this.addFeature(T,T.geometry,T.index,m,b)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(o){this.uploaded||(this.layoutVertexBuffer=o.createVertexBuffer(this.layoutVertexArray,Po),this.indexBuffer=o.createIndexBuffer(this.indexArray),this.indexBuffer2=o.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(o),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(o,m,b,T,$){for(const V of hi(m,500)){let U=0;for(const Ye of V)U+=Ye.length;const ne=this.segments.prepareSegment(U,this.layoutVertexArray,this.indexArray),me=ne.vertexLength,ye=[],Te=[];for(const Ye of V){if(Ye.length===0)continue;Ye!==V[0]&&Te.push(ye.length/2);const et=this.segments2.prepareSegment(Ye.length,this.layoutVertexArray,this.indexArray2),mt=et.vertexLength;this.layoutVertexArray.emplaceBack(Ye[0].x,Ye[0].y),this.indexArray2.emplaceBack(mt+Ye.length-1,mt),ye.push(Ye[0].x),ye.pu
1962sh(Ye[0].y);for(let Tt=1;Tt<Ye.length;Tt++)this.layoutVertexArray.emplaceBack(Ye[Tt].x,Ye[Tt].y),this.indexArray2.emplaceBack(mt+Tt-1,mt+Tt),ye.push(Ye[Tt].x),ye.push(Ye[Tt].y);et.vertexLength+=Ye.length,et.primitiveLength+=Ye.length}const $e=po(ye,Te);for(let Ye=0;Ye<$e.length;Ye+=3)this.indexArray.emplaceBack(me+$e[Ye],me+$e[Ye+1],me+$e[Ye+2]);ne.vertexLength+=U,ne.primitiveLength+=$e.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,o,b,$,T)}}let Ya,Ea;jn("FillBucket",ua,{omit:["layers","patternFeatures"]});var Mr={get paint(){return Ea=Ea||new R({"fill-antialias":new ea(He.paint_fill["fill-antialias"]),"fill-opacity":new ia(He.paint_fill["fill-opacity"]),"fill-color":new ia(He.paint_fill["fill-color"]),"fill-outline-color":new ia(He.paint_fill["fill-outline-color"]),"fill-translate":new ea(He.paint_fill["fill-translate"]),"fill-translate-anchor":new ea(He.paint_fill["fill-translate-anchor"]),"fill-pattern":new qh(He.paint_fill["fill-pattern"])})},get layout(){return Ya=Ya||new R({"fill-sort-key":new ia(He.layout_fill["fill-sort-key"])})}};class ao extends g{constructor(o){super(o,Mr)}recalculate(o,m){super.recalculate(o,m);const b=this.paint._values["fill-outline-color"];b.value.kind==="constant"&&b.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(o){return new ua(o)}queryRadius(){return nf(this.paint.get("fill-translate"))}queryIntersectsFeature(o,m,b,T,$,V,U){return Wg(Xh(o,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),V.angle,U),T)}isTileClipped(){return!0}}const Oc=ee([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),ku=ee([{name:"a_centroid",components:2,type:"Int16"}],4),{members:au}=Oc;var Qa={},vi=j,qo=No;function No(d,o,m,b,T){this.properties={},this.extent=m,this.type=0,this._pbf=d,this._geometry=-1,this._keys=b,this._values=T,d.readFields(ec,this,o)}function ec(d,o,m){d==1?o.id=m.readVarint():d==2?function(b,T){for(var $=b.readVarint()+b.pos;b.pos<$;){var V=T._keys[b.readVarint()],U=T._values[b.readVarint()];T.properties[V]=U}}(m,o):d==3?o.type=m.readVarint():d==4&&(o._geometry=m.pos)}function Ju(d){for(var o,m,b=0,T=0,$=d.length,V=$-1;T<$;V=T++)b+=((m=d[V]).x-(o=d[T]).x)*(o.y+m.y);return b}No.types=["Unknown","Point","LineString","Polygon"],No.prototype.loadGeometry=function(){var d=this._pbf;d.pos=this._geometry;for(var o,m=d.readVarint()+d.pos,b=1,T=0,$=0,V=0,U=[];d.pos<m;){if(T<=0){var ne=d.readVarint();b=7&ne,T=ne>>3}if(T--,b===1||b===2)$+=d.readSVarint(),V+=d.readSVarint(),b===1&&(o&&U.push(o),o=[]),o.push(new vi($,V));else{if(b!==7)throw new Error("unknown command "+b);o&&o.push(o[0].clone())}}return o&&U.push(o),U},No.prototype.bbox=function(){var d=this._pbf;d.pos=this._geometry;for(var o=d.readVarint()+d.pos,m=1,b=0,T=0,$=0,V=1/0,U=-1/0,ne=1/0,me=-1/0;d.pos<o;){if(b<=0){var ye=d.readVarint();m=7&ye,b=ye>>3}if(b--,m===1||m===2)(T+=d.readSVarint())<V&&(V=T),T>U&&(U=T),($+=d.readSVarint())<ne&&(ne=$),$>me&&(me=$);else if(m!==7)throw new Error("unknown command "+m)}return[V,ne,U,me]},No.prototype.toGeoJSON=function(d,o,m){var b,T,$=this.extent*Math.pow(2,m),V=this.extent*d,U=this.extent*o,ne=this.loadGeometry(),me=No.types[this.type];function ye(Ye){for(var et=0;et<Ye.length;et++){var mt=Ye[et];Ye[et]=[360*(mt.x+V)/$-180,360/Math.PI*Math.atan(Math.exp((180-360*(mt.y+U)/$)*Math.PI/180))-90]}}switch(this.type){case 1:var Te=[];for(b=0;b<ne.length;b++)Te[b]=ne[b][0];ye(ne=Te);break;case 2:for(b=0;b<ne.length;b++)ye(ne[b]);break;case 3:for(ne=function(Ye){var et=Ye.length;if(et<=1)return[Ye];for(var mt,Tt,Ot=[],gs=0;gs<et;gs++){var Yt=Ju(Ye[gs]);Yt!==0&&(Tt===void 0&&(Tt=Yt<0),Tt===Yt<0?(mt&&Ot.push(mt),mt=[Ye[gs]]):mt.push(Ye[gs]))}return mt&&Ot.push(mt),Ot}(ne),b=0;b<ne.length;b++)for(T=0;T<ne[b].length;T++)ye(ne[b][T])}ne.length===1?ne=ne[0]:me="Multi"+me;var $e={type:"Feature",geometry:{type:me,coordinates:ne},properties:this.properties};return"id"in this&&($e.id=this.id),$e};var Tl=qo,zd=To;function To(d,o){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=d,this._keys=[],this._values=[],this._features=[],d.readFields(gc,this,o),this.length=this._features.length}function gc(d,o,m){d===15?o.version=m.readVarint():d===1?o.name=m.readString():d===5?o.extent=m.readVarint():d===2?o._features.push(m.pos):d===3?o._keys.push(m.readString()):d===4&&o._values.push(function(b){for(var T=null,$=b.readVarint()+b.pos;b.pos<$;){var V=b.readVarint()>>3;T=V===1?b.readString():V===2?b.readFloat():V===3?b.readDouble():V===4?b.readVarint64():V===5?b.readVarint():V===6?b.readSVarint():V===7?b.readBoolean():null}return T}(m))}To.prototype.feature=function(d){if(d<0||d>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[d];var o=this._pbf.readVarint()+this._pbf.pos;return new Tl(this._pbf,o,this.extent,this._keys,this._values)};var xc=zd;function Cu(d,o,m){if(d===3){var b=new xc(m,m.readVarint()+m.pos);b.length&&(o[b.name]=b)}}Qa.VectorTile=function(d,o){this.layers=d.readFields(Cu,{},o)},Qa.VectorTileFeature=qo,Qa.VectorTileLayer=zd;const Qu=Qa.VectorTileFeature.types,Rp=Math.pow(2,13);function Ch(d,o,m,b,T,$,V,U){d.emplaceBack(o,m,2*Math.floor(b*Rp)+V,T*Rp*2,$*Rp*2,Math.round(U))}class Cm{constructor(o){this.zoom=o.zoom,this.overscaling=o.overscaling,this.layers=o.layers,this.layerIds=this.layers.map(m=>m.id),this.index=o.index,this.hasPattern=!1,this.layoutVertexArray=new qu,this.centroidVertexArray=new Ql,this.indexArray=new Rc,this.programConfigurations=new Hh(o.layers,o.zoom),this.segments=new qr,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id)}populate(o,m,b){this.features=[],this.hasPattern=xn("fill-extrusion",this.layers,m);for(const{feature:T,id:$,index:V,sourceLayerIndex:U}of o){const ne=this.layers[0]._featureFilter.needGeometry,me=Wh(T,ne);if(!this.layers[0]._featureFilter.filter(new yi(this.zoom),me,b))continue;const ye={id:$,sourceLayerIndex:U,index:V,geometry:ne?me.geometry:Zh(T),properties:T.properties,type:T.type,patterns:{}};this.hasPattern?this.features.push(Zn("fill-extrusion",this.layers,ye,this.zoom,m)):this.addFeature(ye,ye.geometry,V,b,{}),m.featureIndex.insert(T,ye.geometry,V,U,this.index,!0)}}addFeatures(o,m,b){for(const T of this.features){const{geometry:$}=T;this.addFeature(T,$,T.index,m,b)}}update(o,m,b){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(o,m,this.stateDependentLayers,b)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(o){this.uploaded||(this.layoutVertexBuffer=o.createVertexBuffer(this.layoutVertexArray,au),this.centroidVertexBuffer=o.createVertexBuffer(this.centroidVertexArray,ku.members,!0),this.indexBuffer=o.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(o),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(o,m,b,T,$){for(const V of hi(m,500)){const U={x:0,y:0,vertexCount:0};let ne=0;for(const et of V)ne+=et.length;let me=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const et of V){if(et.length===0||af(et))continue;let mt=0;for(let Tt=0;Tt<et.length;Tt++){const Ot=et[Tt];if(Tt>=1){const gs=et[Tt-1];if(!Fp(Ot,gs)){me.vertexLength+4>qr.MAX_VERTEX_ARRAY_LENGTH&&(me=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const Yt=Ot.sub(gs)._perp()._unit(),ls=gs.dist(Ot);mt+ls>32768&&(mt=0),Ch(this.layoutVertexArray,Ot.x,Ot.y,Yt.x,Yt.y,0,0,mt),Ch(this.layoutVertexArray,Ot.x,Ot.y,Yt.x,Yt.y,0,1,mt),U.x+=2*Ot.x,U.y+=2*Ot.y,U.vertexCount+=2,mt+=ls,Ch(this.layoutVertexArray,gs.x,gs.y,Yt.x,Yt.y,0,0,mt),Ch(this.layoutVertexArray,gs.x,gs.y,Yt.x,Yt.y,0,1,mt),U.x+=2*gs.x,U.y+=2*gs.y,U.vertexCount+=2;const Cs=me.vertexLength;this.indexArray.emplaceBack(Cs,Cs+2,Cs+1),this.indexArray.emplaceBack(Cs+1,Cs+2,Cs+3),me.vertexLength+=4,me.primitiveLength+=2}}}}if(me.vertexLength+ne>qr.MAX_VERTEX_ARRAY_LENGTH&&(me=this.segments.prepareSegment(ne,this.layoutVertexArray,this.indexArray)),Qu[o.type]!=="Polygon")continue;const ye=[],Te=[],$e=me.vertexLength;for(const et of V)if(et.length!==0){et!==V[0]&&Te.push(ye.length/2);for(let mt=0;mt<et.length;mt++){const Tt=et[mt];Ch(this.layoutVertexArray,Tt.x,Tt.y,0,0,1,1,0),U.x+=Tt.x,U.y+=Tt.y,U.vertexCount+=1,ye.push(Tt.x),ye.pu
vendor: 5,815 bytes, line 1962
1962sh(Tt.y)}}const Ye=po(ye,Te);for(let et=0;et<Ye.length;et+=3)this.indexArray.emplaceBack($e+Ye[et],$e+Ye[et+2],$e+Ye[et+1]);me.primitiveLength+=Ye.length/3,me.vertexLength+=ne;for(let et=0;et<U.vertexCount;et++){const mt=Math.floor(U.x/U.vertexCount),Tt=Math.floor(U.y/U.vertexCount);this.centroidVertexArray.emplaceBack(mt,Tt)}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,o,b,$,T)}}function Fp(d,o){return d.x===o.x&&(d.x<0||d.x>Oi)||d.y===o.y&&(d.y<0||d.y>Oi)}function af(d){return d.every(o=>o.x<0)||d.every(o=>o.x>Oi)||d.every(o=>o.y<0)||d.every(o=>o.y>Oi)}let J0;jn("FillExtrusionBucket",Cm,{omit:["layers","features"]});var Jj={get paint(){return J0=J0||new R({"fill-extrusion-opacity":new ea(He["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new ia(He["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new ea(He["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new ea(He["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new qh(He["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new ia(He["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new ia(He["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new ea(He["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class fa extends g{constructor(o){super(o,Jj)}createBucket(o){return new Cm(o)}queryRadius(){return nf(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(o,m,b,T,$,V,U,ne){const me=Xh(o,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),V.angle,U),ye=this.paint.get("fill-extrusion-height").evaluate(m,b),Te=this.paint.get("fill-extrusion-base").evaluate(m,b),$e=function(et,mt,Tt,Ot){const gs=[];for(const Yt of et){const ls=[Yt.x,Yt.y,0,1];It(ls,ls,mt),gs.push(new x(ls[0]/ls[3],ls[1]/ls[3]))}return gs}(me,ne),Ye=function(et,mt,Tt,Ot){const gs=[],Yt=[],ls=Ot[8]*mt,Cs=Ot[9]*mt,Us=Ot[10]*mt,$n=Ot[11]*mt,La=Ot[8]*Tt,Rn=Ot[9]*Tt,kn=Ot[10]*Tt,ga=Ot[11]*Tt;for(const ta of et){const Yn=[],Ds=[];for(const _a of ta){const ma=_a.x,Xa=_a.y,Qi=Ot[0]*ma+Ot[4]*Xa+Ot[12],Wi=Ot[1]*ma+Ot[5]*Xa+Ot[13],nc=Ot[2]*ma+Ot[6]*Xa+Ot[14],sh=Ot[3]*ma+Ot[7]*Xa+Ot[15],$c=nc+Us,ac=sh+$n,jd=Qi+La,wd=Wi+Rn,Nd=nc+kn,ll=sh+ga,rc=new x((Qi+ls)/ac,(Wi+Cs)/ac);rc.z=$c/ac,Yn.push(rc);const rd=new x(jd/ll,wd/ll);rd.z=Nd/ll,Ds.push(rd)}gs.push(Yn),Yt.push(Ds)}return[gs,Yt]}(T,Te,ye,ne);return function(et,mt,Tt){let Ot=1/0;Wg(Tt,mt)&&(Ot=ca(Tt,mt[0]));for(let gs=0;gs<mt.length;gs++){const Yt=mt[gs],ls=et[gs];for(let Cs=0;Cs<Yt.length-1;Cs++){const Us=Yt[Cs],$n=[Us,Yt[Cs+1],ls[Cs+1],ls[Cs],Us];wm(Tt,$n)&&(Ot=Math.min(Ot,ca(Tt,$n)))}}return Ot!==1/0&&Ot}(Ye[0],Ye[1],$e)}}function pa(d,o){return d.x*o.x+d.y*o.y}function ca(d,o){if(d.length===1){let m=0;const b=o[m++];let T;for(;!T||b.equals(T);)if(T=o[m++],!T)return 1/0;for(;m<o.length;m++){const $=o[m],V=d[0],U=T.sub(b),ne=$.sub(b),me=V.sub(b),ye=pa(U,U),Te=pa(U,ne),$e=pa(ne,ne),Ye=pa(me,U),et=pa(me,ne),mt=ye*$e-Te*Te,Tt=($e*Ye-Te*et)/mt,Ot=(ye*et-Te*Ye)/mt,gs=b.z*(1-Tt-Ot)+T.z*Tt+$.z*Ot;if(isFinite(gs))return gs}return 1/0}{let m=1/0;for(const b of o)m=Math.min(m,b.z);return m}}const Kn=ee([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:Aa}=Kn,Jn=ee([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:yn}=Jn,cn=Qa.VectorTileFeature.types,vn=Math.cos(Math.PI/180*37.5),Wn=Math.pow(2,14)/.5;class ha{constructor(o){this.zoom=o.zoom,this.overscaling=o.overscaling,this.layers=o.layers,this.layerIds=this.layers.map(m=>m.id),this.index=o.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(m=>{this.gradients[m.id]={}}),this.layoutVertexArray=new Jm,this.layoutVertexArray2=new Vo,this.indexArray=new Rc,this.programConfigurations=new Hh(o.layers,o.zoom),this.segments=new qr,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id)}populate(o,m,b){this.hasPattern=xn("line",this.layers,m);const T=this.layers[0].layout.get("line-sort-key"),$=!T.isConstant(),V=[];for(const{feature:U,id:ne,index:me,sourceLayerIndex:ye}of o){const Te=this.layers[0]._featureFilter.needGeometry,$e=Wh(U,Te);if(!this.layers[0]._featureFilter.filter(new yi(this.zoom),$e,b))continue;const Ye=$?T.evaluate($e,{},b):void 0,et={id:ne,properties:U.properties,type:U.type,sourceLayerIndex:ye,index:me,geometry:Te?$e.geometry:Zh(U),patterns:{},sortKey:Ye};V.push(et)}$&&V.sort((U,ne)=>U.sortKey-ne.sortKey);for(const U of V){const{geometry:ne,index:me,sourceLayerIndex:ye}=U;if(this.hasPattern){const Te=Zn("line",this.layers,U,this.zoom,m);this.patternFeatures.push(Te)}else this.addFeature(U,ne,me,b,{});m.featureIndex.insert(o[me].feature,ne,me,ye,this.index)}}update(o,m,b){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(o,m,this.stateDependentLayers,b)}addFeatures(o,m,b){for(const T of this.patternFeatures)this.addFeature(T,T.geometry,T.index,m,b)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(o){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=o.createVertexBuffer(this.layoutVertexArray2,yn)),this.layoutVertexBuffer=o.createVertexBuffer(this.layoutVertexArray,Aa),this.indexBuffer=o.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(o),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}
vendor: 7,397 bytes, line 1962
1962lineFeatureClips(o){if(o.properties&&Object.prototype.hasOwnProperty.call(o.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(o.properties,"mapbox_clip_end"))return{start:+o.properties.mapbox_clip_start,end:+o.properties.mapbox_clip_end}}addFeature(o,m,b,T,$){const V=this.layers[0].layout,U=V.get("line-join").evaluate(o,{}),ne=V.get("line-cap"),me=V.get("line-miter-limit"),ye=V.get("line-round-limit");this.lineClips=this.lineFeatureClips(o);for(const Te of m)this.addLine(Te,o,U,ne,me,ye);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,o,b,$,T)}addLine(o,m,b,T,$,V){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let Ot=0;Ot<o.length-1;Ot++)this.totalDistance+=o[Ot].dist(o[Ot+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const U=cn[m.type]==="Polygon";let ne=o.length;for(;ne>=2&&o[ne-1].equals(o[ne-2]);)ne--;let me=0;for(;me<ne-1&&o[me].equals(o[me+1]);)me++;if(ne<(U?3:2))return;b==="bevel"&&($=1.05);const ye=this.overscaling<=16?15*Oi/(512*this.overscaling):0,Te=this.segments.prepareSegment(10*ne,this.layoutVertexArray,this.indexArray);let $e,Ye,et,mt,Tt;this.e1=this.e2=-1,U&&($e=o[ne-2],Tt=o[me].sub($e)._unit()._perp());for(let Ot=me;Ot<ne;Ot++){if(et=Ot===ne-1?U?o[me+1]:void 0:o[Ot+1],et&&o[Ot].equals(et))continue;Tt&&(mt=Tt),$e&&(Ye=$e),$e=o[Ot],Tt=et?et.sub($e)._unit()._perp():mt,mt=mt||Tt;let gs=mt.add(Tt);gs.x===0&&gs.y===0||gs._unit();const Yt=mt.x*Tt.x+mt.y*Tt.y,ls=gs.x*Tt.x+gs.y*Tt.y,Cs=ls!==0?1/ls:1/0,Us=2*Math.sqrt(2-2*ls),$n=ls<vn&&Ye&&et,La=mt.x*Tt.y-mt.y*Tt.x>0;if($n&&Ot>me){const ga=$e.dist(Ye);if(ga>2*ye){const ta=$e.sub($e.sub(Ye)._mult(ye/ga)._round());this.updateDistance(Ye,ta),this.addCurrentVertex(ta,mt,0,0,Te),Ye=ta}}const Rn=Ye&&et;let kn=Rn?b:U?"butt":T;if(Rn&&kn==="round"&&(Cs<V?kn="miter":Cs<=2&&(kn="fakeround")),kn==="miter"&&Cs>$&&(kn="bevel"),kn==="bevel"&&(Cs>2&&(kn="flipbevel"),Cs<$&&(kn="miter")),Ye&&this.updateDistance(Ye,$e),kn==="miter")gs._mult(Cs),this.addCurrentVertex($e,gs,0,0,Te);else if(kn==="flipbevel"){if(Cs>100)gs=Tt.mult(-1);else{const ga=Cs*mt.add(Tt).mag()/mt.sub(Tt).mag();gs._perp()._mult(ga*(La?-1:1))}this.addCurrentVertex($e,gs,0,0,Te),this.addCurrentVertex($e,gs.mult(-1),0,0,Te)}else if(kn==="bevel"||kn==="fakeround"){const ga=-Math.sqrt(Cs*Cs-1),ta=La?ga:0,Yn=La?0:ga;if(Ye&&this.addCurrentVertex($e,mt,ta,Yn,Te),kn==="fakeround"){const Ds=Math.round(180*Us/Math.PI/20);for(let _a=1;_a<Ds;_a++){let ma=_a/Ds;if(ma!==.5){const Qi=ma-.5;ma+=ma*Qi*(ma-1)*((1.0904+Yt*(Yt*(3.55645-1.43519*Yt)-3.2452))*Qi*Qi+(.848013+Yt*(.215638*Yt-1.06021)))}const Xa=Tt.sub(mt)._mult(ma)._add(mt)._unit()._mult(La?-1:1);this.addHalfVertex($e,Xa.x,Xa.y,!1,La,0,Te)}}et&&this.addCurrentVertex($e,Tt,-ta,-Yn,Te)}else if(kn==="butt")this.addCurrentVertex($e,gs,0,0,Te);else if(kn==="square"){const ga=Ye?1:-1;this.addCurrentVertex($e,gs,ga,ga,Te)}else kn==="round"&&(Ye&&(this.addCurrentVertex($e,mt,0,0,Te),this.addCurrentVertex($e,mt,1,1,Te,!0)),et&&(this.addCurrentVertex($e,Tt,-1,-1,Te,!0),this.addCurrentVertex($e,Tt,0,0,Te)));if($n&&Ot<ne-1){const ga=$e.dist(et);if(ga>2*ye){const ta=$e.add(et.sub($e)._mult(ye/ga)._round());this.updateDistance($e,ta),this.addCurrentVertex(ta,Tt,0,0,Te),$e=ta}}}}addCurrentVertex(o,m,b,T,$,V=!1){const U=m.y*T-m.x,ne=-m.y-m.x*T;this.addHalfVertex(o,m.x+m.y*b,m.y-m.x*b,V,!1,b,$),this.addHalfVertex(o,U,ne,V,!0,-T,$),this.distance>Wn/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(o,m,b,T,$,V))}addHalfVertex({x:o,y:m},b,T,$,V,U,ne){const me=.5*(this.lineClips?this.scaledDistance*(Wn-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((o<<1)+($?1:0),(m<<1)+(V?1:0),Math.round(63*b)+128,Math.round(63*T)+128,1+(U===0?0:U<0?-1:1)|(63&me)<<2,me>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const ye=ne.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,ye),ne.primitiveLength++),V?this.e2=ye:this.e1=ye}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(o,m){this.distance+=o.dist(m),this.updateScaledDistance()}}let va,gr;jn("LineBucket",ha,{omit:["layers","patternFeatures"]});var Jr={get paint(){return gr=gr||new R({"line-opacity":new ia(He.paint_line["line-opacity"]),"line-color":new ia(He.paint_line["line-color"]),"line-translate":new ea(He.paint_line["line-translate"]),"line-translate-anchor":new ea(He.paint_line["line-translate-anchor"]),"line-width":new ia(He.paint_line["line-width"]),"line-gap-width":new ia(He.paint_line["line-gap-width"]),"line-offset":new ia(He.paint_line["line-offset"]),"line-blur":new ia(He.paint_line["line-blur"]),"line-dasharray":new Xm(He.paint_line["line-dasharray"]),"line-pattern":new qh(He.paint_line["line-pattern"]),"line-gradient":new Km(He.paint_line["line-gradient"])})},get layout(){return va=va||new R({"line-cap":new ea(He.layout_line["line-cap"]),"line-join":new ia(He.layout_line["line-join"]),"line-miter-limit":new ea(He.layout_line["line-miter-limit"]),"line-round-limit":new ea(He.layout_line["line-round-limit"]),"line-sort-key":new ia(He.layout_line["line-sort-key"])})}};class Lo extends ia{possiblyEvaluate(o,m){return m=new yi(Math.floor(m.zoom),{now:m.now,fadeDuration:m.fadeDuration,zoomHistory:m.zoomHistory,transition:m.transition}),super.possiblyEvaluate(o,m)}evaluate(o,m,b,T){return m=H({},m,{zoom:Math.floor(m.zoom)}),super.evaluate(o,m,b,T)}}let Go;class il extends g{constructor(o){super(o,Jr),this.gradientVersion=0,Go||(Go=new Lo(Jr.paint.properties["line-width"].specification),Go.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(o){if(o==="line-gradient"){const m=this.gradientExpression();this.stepInterpolant=!!function(b){return b._styleExpression!==void 0}(m)&&m._styleExpression.expression instanceof zo,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(o,m){super.recalculate(o,m),this.paint._values["line-floorwidth"]=Go.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,o)}createBucket(o){return new ha(o)}queryRadius(o){const m=o,b=fi(sf("line-width",this,m),sf("line-gap-width",this,m)),T=sf("line-offset",this,m);return b/2+Math.abs(T)+nf(this.paint.get("line-translate"))}queryIntersectsFeature(o,m,b,T,$,V,U){const ne=Xh(o,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),V.angle,U),me=U/2*fi(this.paint.get("line-width").evaluate(m,b),this.paint.get("line-gap-width").evaluate(m,b)),ye=this.paint.get("line-offset").evaluate(m,b);return ye&&(T=function(Te,$e){const Ye=[];for(let et=0;et<Te.length;et++){const mt=Te[et],Tt=[];for(let Ot=0;Ot<mt.length;Ot++){const gs=mt[Ot-1],Yt=mt[Ot],ls=mt[Ot+1],Cs=Ot===0?new x(0,0):Yt.sub(gs)._unit()._perp(),Us=Ot===mt.length-1?new x(0,0):ls.sub(Yt)._unit()._perp(),$n=Cs._add(Us)._unit(),La=$n.x*Us.x+$n.y*Us.y;La!==0&&$n._mult(1/La),Tt.push($n._mult($e)._add(Yt))}Ye.push(Tt)}return Ye}(T,ye*U)),function(Te,$e,Ye){for(let et=0;et<$e.length;et++){const mt=$e[et];
1962if(Te.length>=3){for(let Tt=0;Tt<mt.length;Tt++)if(Xu(Te,mt[Tt]))return!0}if(Yg(Te,mt,Ye))return!0}return!1}(ne,T,me)}isTileClipped(){return!0}}function fi(d,o){return o>0?o+2*d:d}const Ho=ee([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),ko=ee([{name:"a_projected_pos",components:3,type:"Float32"}],4);ee([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Su=ee([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);ee([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Ll=ee([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),tc=ee([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function rf(d,o,m){return d.sections.forEach(b=>{b.text=function(T,$,V){const U=$.layout.get("text-transform").evaluate(V,{});return U==="uppercase"?T=T.toLocaleUpperCase():U==="lowercase"&&(T=T.toLocaleLowerCase()),no.applyArabicShaping&&(T=no.applyArabicShaping(T)),T}(b.text,o,m)}),d}ee([{name:"triangle",components:3,type:"Uint16"}]),ee([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),ee([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),ee([{type:"Float32",name:"offsetX"}]),ee([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),ee([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Od={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var ii=24,vr=dr,go=function(d,o,m,b,T){var $,V,U=8*T-b-1,ne=(1<<U)-1,me=ne>>1,ye=-7,Te=T-1,$e=-1,Ye=d[o+Te];for(Te+=$e,$=Ye&(1<<-ye)-1,Ye>>=-ye,ye+=U;ye>0;
1962$=256*$+d[o+Te],Te+=$e,ye-=8);for(V=$&(1<<-ye)-1,$>>=-ye,ye+=b;ye>0;V=256*V+d[o+Te],Te+=$e,ye-=8);if($===0)$=1-me;else{if($===ne)return V?NaN:1/0*(Ye?-1:1);V+=Math.pow(2,b),$-=me}return(Ye?-1:1)*V*Math.pow(2,$-b)},_c=function(d,o,m,b,T,$){var V,U,ne,me=8*$-T-1,ye=(1<<me)-1,Te=ye>>1,$e=T===23?Math.pow(2,-24)-Math.pow(2,-77):0,Ye=0,et=1,mt=o<0||o===0&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(U=isNaN(o)?1:0,V=ye):(V=Math.floor(Math.log(o)/Math.LN2),o*(ne=Math.pow(2,-V))<1&&(V--,ne*=2),(o+=V+Te>=1?$e/ne:$e*Math.pow(2,1-Te))*ne>=2&&(V++,ne/=2),V+Te>=ye?(U=0,V=ye):V+Te>=1?(U=(o*ne-1)*Math.pow(2,T),V+=Te):(U=o*Math.pow(2,Te-1)*Math.pow(2,T),V=0));T>=8;d[m+Ye]=255&U,Ye+=et,U/=256,T-=8);for(V=V<<T|U,me+=T;me>0;d[m+Ye]=255&V,Ye+=et,V/=256,me-=8);d[m+Ye-et]|=128*mt};function dr(d){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(d)?d:new Uint8Array(d||0),this.pos=0,this.type=0,this.length=this.buf.length}dr.Varint=0,dr.Fixed64=1,dr.Bytes=2,dr.Fixed32=5;var Sh=4294967296,zp=1/Sh,Op=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function Uu(d){return d.type===dr.Bytes?d.readVarint()+d.pos:d.pos+1}function of(d,o,m){return m?4294967296*o+(d>>>0):4294967296*(o>>>0)+(d>>>0)}function Q0(d,o,m){var b=o<=16383?1:o<=2097151?2:o<=268435455?3:Math.floor(Math.log(o)/(7*Math.LN2));m.realloc(b);for(var T=m.pos-1;T>=d;T--)m.buf[T+b]=m.buf[T]}function v_(d,o){for(var m=0;m<d.length;m++)o.writeVarint(d[m])}function U0(d,o){for(var m=0;m<d.length;m++)o.writeSVarint(d[m])}function ev(d,o){for(var m=0;m<d.length;m++)o.writeFloat(d[m])}function b_(d,o){for(var m=0;m<d.length;m++)o.writeDouble(d[m])}function ba(d,o){for(var m=0;m<d.length;m++)o.writeBoolean(d[m])}function Ji(d,o){for(var m=0;m<d.length;m++)o.writeFixed32(d[m])}function Qr(d,o){for(var m=0;m<d.length;m++)o.writeSFixed32(d[m])}function ni(d,o){for(var m=0;m<d.length;m++)o.writeFixed64(d[m])}function Eu(d,o){for(var m=0;m<d.length;m++)o.writeSFixed64(d[m])}function Vl(d,o){return(d[o]|d[o+1]<<8|d[o+2]<<16)+16777216*d[o+3]}function ro(d,o,m){d[m]=o,d[m+1]=o>>>8,d[m+2]=o>>>16,d[m+3]=o>>>24}function sc(d,o){return(d[o]|d[o+1]<<8|d[o+2]<<16)+(d[o+3]<<24)}dr.prototype={destroy:function(){this.buf=null},readFields:function(d,o,m){for(m=m||this.length;this.pos<m;){var b=this.readVarint(),T=b>>3,$=this.pos;this.type=7&b,d(T,o,this),this.pos===$&&this.skip(b)}return o},readMessage:function(d,o){return this.readFields(d,o,this.readVarint()+this.pos)},readFixed32:function(){var d=Vl(this.buf,this.pos);return this.pos+=4,d},readSFixed32:function(){var d=sc(this.buf,this.pos);return this.pos+=4,d},readFixed64:function(){var d=Vl(this.buf,this.pos)+Vl(this.buf,this.pos+4)*Sh;return this.pos+=8,d},readSFixed64:function(){var d=Vl(this.buf,this.pos)+sc(this.buf,this.pos+4)*Sh;return this.pos+=8,d},readFloat:function(){var d=go(this.buf,this.pos,!0,23,4);return this.pos+=4,d},readDouble:function(){var d=go(this.buf,this.pos,!0,52,8);return this.pos+=8,d},readVarint:function(d){var o,m,b=this.buf;return o=127&(m=b[this.pos++]),m<128?o:(o|=(127&(m=b[this.pos++]))<<7,m<128?o:(o|=(127&(m=b[this.pos++]))<<14,m<128?o:(o|=(127&(m=b[this.pos++]))<<21,m<128?o:function(T,$,V){var U,ne,me=V.buf;if(U=(112&(ne=me[V.pos++]))>>4,ne<128||(U|=(127&(ne=me[V.pos++]))<<3,ne<128)||(U|=(127&(ne=me[V.pos++]))<<10,ne<128)||(U|=(127&(ne=me[V.pos++]))<<17,ne<128)||(U|=(127&(ne=me[V.pos++]))<<24,ne<128)||(U|=(1&(ne=me[V.pos++]))<<31,ne<128))return of(T,U,$);throw new Error("Expected varint not more than 10 bytes")}(o|=(15&(m=b[this.pos]))<<28,d,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var d=this.readVarint();return d%2==1?(d+1)/-2:d/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var d=this.readVarint()+this.pos,o=this.pos;return this.pos=d,d-o>=12&&Op?function(m,b,T){return Op.decode(m.subarray(b,T))}(this.buf,o,d):function(m,b,T){for(var $="",V=b;V<T;){var U,ne,me,ye=m[V],Te=null,$e=ye>239?4:ye>223?3:ye>191?2:1;if(V+$e>T)break;$e===1?ye<128&&(Te=ye):$e===2?(192&(U=m[V+1]))==128&&(Te=(31&ye)<<6|63&U)<=127&&(Te=null):$e===3?(ne=m[V+2],(192&(U=m[V+1]))==128&&(192&ne)==128&&((Te=(15&ye)<<12|(63&U)<<6|63&ne)<=2047||Te>=55296&&Te<=57343)&&(Te=null)):$e===4&&(ne=m[V+2],me=m[V+3],(192&(U=m[V+1]
vendor: 6,022 bytes, line 1962
1962))==128&&(192&ne)==128&&(192&me)==128&&((Te=(15&ye)<<18|(63&U)<<12|(63&ne)<<6|63&me)<=65535||Te>=1114112)&&(Te=null)),Te===null?(Te=65533,$e=1):Te>65535&&(Te-=65536,$+=String.fromCharCode(Te>>>10&1023|55296),Te=56320|1023&Te),$+=String.fromCharCode(Te),V+=$e}return $}(this.buf,o,d)},readBytes:function(){var d=this.readVarint()+this.pos,o=this.buf.subarray(this.pos,d);return this.pos=d,o},readPackedVarint:function(d,o){if(this.type!==dr.Bytes)return d.push(this.readVarint(o));var m=Uu(this);for(d=d||[];this.pos<m;)d.push(this.readVarint(o));return d},readPackedSVarint:function(d){if(this.type!==dr.Bytes)return d.push(this.readSVarint());var o=Uu(this);for(d=d||[];this.pos<o;)d.push(this.readSVarint());return d},readPackedBoolean:function(d){if(this.type!==dr.Bytes)return d.push(this.readBoolean());var o=Uu(this);for(d=d||[];this.pos<o;)d.push(this.readBoolean());return d},readPackedFloat:function(d){if(this.type!==dr.Bytes)return d.push(this.readFloat());var o=Uu(this);for(d=d||[];this.pos<o;)d.push(this.readFloat());return d},readPackedDouble:function(d){if(this.type!==dr.Bytes)return d.push(this.readDouble());var o=Uu(this);for(d=d||[];this.pos<o;)d.push(this.readDouble());return d},readPackedFixed32:function(d){if(this.type!==dr.Bytes)return d.push(this.readFixed32());var o=Uu(this);for(d=d||[];this.pos<o;)d.push(this.readFixed32());return d},readPackedSFixed32:function(d){if(this.type!==dr.Bytes)return d.push(this.readSFixed32());var o=Uu(this);for(d=d||[];this.pos<o;)d.push(this.readSFixed32());return d},readPackedFixed64:function(d){if(this.type!==dr.Bytes)return d.push(this.readFixed64());var o=Uu(this);for(d=d||[];this.pos<o;)d.push(this.readFixed64());return d},readPackedSFixed64:function(d){if(this.type!==dr.Bytes)return d.push(this.readSFixed64());var o=Uu(this);for(d=d||[];this.pos<o;)d.push(this.readSFixed64());return d},skip:function(d){var o=7&d;if(o===dr.Varint)for(;this.buf[this.pos++]>127;);else if(o===dr.Bytes)this.pos=this.readVarint()+this.pos;else if(o===dr.Fixed32)this.pos+=4;else{if(o!==dr.Fixed64)throw new Error("Unimplemented type: "+o);this.pos+=8}},writeTag:function(d,o){this.writeVarint(d<<3|o)},realloc:function(d){for(var o=this.length||16;o<this.pos+d;)o*=2;if(o!==this.length){var m=new Uint8Array(o);m.set(this.buf),this.buf=m,this.length=o}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(d){this.realloc(4),ro(this.buf,d,this.pos),this.pos+=4},writeSFixed32:function(d){this.realloc(4),ro(this.buf,d,this.pos),this.pos+=4},writeFixed64:function(d){this.realloc(8),ro(this.buf,-1&d,this.pos),ro(this.buf,Math.floor(d*zp),this.pos+4),this.pos+=8},writeSFixed64:function(d){this.realloc(8),ro(this.buf,-1&d,this.pos),ro(this.buf,Math.floor(d*zp),this.pos+4),this.pos+=8},writeVarint:function(d){(d=+d||0)>268435455||d<0?function(o,m){var b,T;if(o>=0?(b=o%4294967296|0,T=o/4294967296|0):(T=~(-o/4294967296),4294967295^(b=~(-o%4294967296))?b=b+1|0:(b=0,T=T+1|0)),o>=18446744073709552e3||o<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");m.realloc(10),function($,V,U){U.buf[U.pos++]=127&$|128,$>>>=7,U.buf[U.pos++]=127&$|128,$>>>=7,U.buf[U.pos++]=127&$|128,$>>>=7,U.buf[U.pos++]=127&$|128,U.buf[U.pos]=127&($>>>=7)}(b,0,m),function($,V){var U=(7&$)<<4;V.buf[V.pos++]|=U|(($>>>=3)?128:0),$&&(V.buf[V.pos++]=127&$|(($>>>=7)?128:0),$&&(V.buf[V.pos++]=127&$|(($>>>=7)?128:0),$&&(V.buf[V.pos++]=127&$|(($>>>=7)?128:0),$&&(V.buf[V.pos++]=127&$|(($>>>=7)?128:0),$&&(V.buf[V.pos++]=127&$)))))}(T,m)}(d,this):(this.realloc(4),this.buf[this.pos++]=127&d|(d>127?128:0),d<=127||(this.buf[this.pos++]=127&(d>>>=7)|(d>127?128:0),d<=127||(this.buf[this.pos++]=127&(d>>>=7)|(d>127?128:0),d<=127||(this.buf[this.pos++]=d>>>7&127))))},writeSVarint:function(d){this.writeVarint(d<0?2*-d-1:2*d)},writeBoolean:function(d){this.writeVarint(!!d)},writeString:function(d){d=String(d),this.realloc(4*d.length),this.pos++;var o=this.pos;this.pos=function(b,T,$){for(var V,U,ne=0;ne<T.length;ne++){if((V=T.charCodeAt(ne))>55295&&V<57344){if(!U){V>56319||ne+1===T.length?(b[$++]=239,b[$++]=191,b[$++]=189):U=V;continue}if(V<56320){b[$++]=239,b[$++]=191,b[$++]=189,U=V;continue}V=U-55296<<10|V-56320|65536,U=null}else U&&(b[$++]=239,b[$++]=191,b[$++]=189,U=null);V<128?b[$++]=V:(V<2048?b[$++]=V>>6|192:(V<65536?b[$++]=V>>12|224:(b[$++]=V>>18|240,b[$++]=V>>12&63|128),b[$++]=V>>6&63|128),b[$++]=63&V|128)}return $}(this.buf,d,this.pos);var m=this.pos-o;m>=128&&Q0(o,m,this),this.pos=o-1,this.writeVarint(m),this.pos+=m},writeFloat:function(d){this.realloc(4),_c(this.buf,d,this.pos,!0,23,4),this.pos+=4},writeDouble:function(d){this.realloc(8),_c(this.buf,d,this.pos,!0,52,8),this.pos+=8},writeBytes:function(d){var o=d.length;this.writeVarint(o),this.realloc(o);for(var m=0;m<o;m++)this.buf[this.pos++]=d[m]},writeRawMessage:function(d,o){this.pos++;var m=this.pos;d(o,this);var b=this.pos-m;b>=128&&Q0(m,b,this),this.pos=m-1,this.writeVarint(b),this.pos+=b},writeMessage:function(d,o,m){this.writeTag(d,dr.Bytes),this.writeRawMessage(o,m)},writePackedVarint:function(d,o){o.length&&this.writeMessage(d,v_,o)},writePackedSVarint:function(d,o){o.length&&this.writeMessage(d,U0,o)},writePackedBoolean:function(d,o){o.length&&this.writeMessage(d,ba,o)},writePackedFloat:function(d,o){o.length&&this.writeMessage(d,ev,o)},writePackedDouble:function(d,o){o.length&&this.writeMessage(d,b_,o)},writePackedFixed32:function(d,o){o.length&&this.writeMessage(d,Ji,o)},writePackedSFixed32:function(d,o){o.length&&this.writeMessage(d,Qr,o)},writePackedFixed64:function(d,o){o.length&&this.writeMessage(d,ni,o)},writePackedSFixed64:function(d,o){o.length&&this.writeMessage(d,Eu,o)},writeBytesField:function(d,o){this.writeTag(d,dr.Bytes),this.writeBytes(o)},writeFixed32Field:function(d,o){this.writeTag(d,dr.Fixed32),this.writeFixed32(o)},writeSFixed32Field:function(d,o){this.writeTag(d,dr.Fixed32),this.writeSFixed32(o)},writeFixed64Field:function(d,o){this.writeTag(d,dr.Fixed64),this.writeFixed64
vendor: 10,551 bytes, line 1962
1962(o)},writeSFixed64Field:function(d,o){this.writeTag(d,dr.Fixed64),this.writeSFixed64(o)},writeVarintField:function(d,o){this.writeTag(d,dr.Varint),this.writeVarint(o)},writeSVarintField:function(d,o){this.writeTag(d,dr.Varint),this.writeSVarint(o)},writeStringField:function(d,o){this.writeTag(d,dr.Bytes),this.writeString(o)},writeFloatField:function(d,o){this.writeTag(d,dr.Fixed32),this.writeFloat(o)},writeDoubleField:function(d,o){this.writeTag(d,dr.Fixed64),this.writeDouble(o)},writeBooleanField:function(d,o){this.writeVarintField(d,!!o)}};var nd=_(vr);const Li=3;function Zo(d,o,m){d===1&&m.readMessage(Sm,o)}function Sm(d,o,m){if(d===3){const{id:b,bitmap:T,width:$,height:V,left:U,top:ne,advance:me}=m.readMessage(eh,{});o.push({id:b,bitmap:new Ss({width:$+2*Li,height:V+2*Li},T),metrics:{width:$,height:V,left:U,top:ne,advance:me}})}}function eh(d,o,m){d===1?o.id=m.readVarint():d===2?o.bitmap=m.readBytes():d===3?o.width=m.readVarint():d===4?o.height=m.readVarint():d===5?o.left=m.readSVarint():d===6?o.top=m.readSVarint():d===7&&(o.advance=m.readVarint())}const th=Li;function ad(d){let o=0,m=0;for(const V of d)o+=V.w*V.h,m=Math.max(m,V.w);d.sort((V,U)=>U.h-V.h);const b=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(o/.95)),m),h:1/0}];let T=0,$=0;for(const V of d)for(let U=b.length-1;U>=0;U--){const ne=b[U];if(!(V.w>ne.w||V.h>ne.h)){if(V.x=ne.x,V.y=ne.y,$=Math.max($,V.y+V.h),T=Math.max(T,V.x+V.w),V.w===ne.w&&V.h===ne.h){const me=b.pop();U<b.length&&(b[U]=me)}else V.h===ne.h?(ne.x+=V.w,ne.w-=V.w):V.w===ne.w?(ne.y+=V.h,ne.h-=V.h):(b.push({x:ne.x+V.w,y:ne.y,w:ne.w-V.w,h:V.h}),ne.y+=V.h,ne.h-=V.h);break}}return{w:T,h:$,fill:o/(T*$)||0}}const ol=1;class Xg{constructor(o,{pixelRatio:m,version:b,stretchX:T,stretchY:$,content:V,textFitWidth:U,textFitHeight:ne}){this.paddedRect=o,this.pixelRatio=m,this.stretchX=T,this.stretchY=$,this.content=V,this.version=b,this.textFitWidth=U,this.textFitHeight=ne}get tl(){return[this.paddedRect.x+ol,this.paddedRect.y+ol]}get br(){return[this.paddedRect.x+this.paddedRect.w-ol,this.paddedRect.y+this.paddedRect.h-ol]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2*ol)/this.pixelRatio,(this.paddedRect.h-2*ol)/this.pixelRatio]}}class j_{constructor(o,m){const b={},T={};this.haveRenderCallbacks=[];const $=[];this.addImages(o,b,$),this.addImages(m,T,$);const{w:V,h:U}=ad($),ne=new Ms({width:V||1,height:U||1});for(const me in o){const ye=o[me],Te=b[me].paddedRect;Ms.copy(ye.data,ne,{x:0,y:0},{x:Te.x+ol,y:Te.y+ol},ye.data)}for(const me in m){const ye=m[me],Te=T[me].paddedRect,$e=Te.x+ol,Ye=Te.y+ol,et=ye.data.width,mt=ye.data.height;Ms.copy(ye.data,ne,{x:0,y:0},{x:$e,y:Ye},ye.data),Ms.copy(ye.data,ne,{x:0,y:mt-1},{x:$e,y:Ye-1},{width:et,height:1}),Ms.copy(ye.data,ne,{x:0,y:0},{x:$e,y:Ye+mt},{width:et,height:1}),Ms.copy(ye.data,ne,{x:et-1,y:0},{x:$e-1,y:Ye},{width:1,height:mt}),Ms.copy(ye.data,ne,{x:0,y:0},{x:$e+et,y:Ye},{width:1,height:mt})}this.image=ne,this.iconPositions=b,this.patternPositions=T}addImages(o,m,b){for(const T in o){const $=o[T],V={x:0,y:0,w:$.data.width+2*ol,h:$.data.height+2*ol};b.push(V),m[T]=new Xg(V,$),$.hasRenderCallback&&this.haveRenderCallbacks.push(T)}}patchUpdatedImages(o,m){o.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const b in o.updatedImages)this.patchUpdatedImage(this.iconPositions[b],o.getImage(b),m),this.patchUpdatedImage(this.patternPositions[b],o.getImage(b),m)}patchUpdatedImage(o,m,b){if(!o||!m||o.version===m.version)return;o.version=m.version;const[T,$]=o.tl;b.update(m.data,void 0,{x:T,y:$})}}var lf;jn("ImagePosition",Xg),jn("ImageAtlas",j_),u.ah=void 0,(lf=u.ah||(u.ah={}))[lf.none=0]="none",lf[lf.horizontal=1]="horizontal",lf[lf.vertical=2]="vertical",lf[lf.horizontalOnly=3]="horizontalOnly";const Kg=-17;class Jg{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(o,m){const b=new Jg;return b.scale=o||1,b.fontStack=m,b}static forImage(o){const m=new Jg;return m.imageName=o,m}}class Bp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(o,m){const b=new Bp;for(let T=0;T<o.sections.length;T++){const $=o.sections[T];$.image?b.addImageSection($):b.addTextSection($,m)}return b}length(){return this.text.length}getSection(o){return this.sections[this.sectionIndex[o]]}getSectionIndex(o){return this.sectionIndex[o]}getCharCode(o){return this.text.charCodeAt(o)}verticalizePunctuation(){this.text=function(o){let m="";for(let b=0;b<o.length;b++){const T=o.charCodeAt(b+1)||null,$=o.charCodeAt(b-1)||null;m+=T&&Tp(T)&&!Od[o[b+1]]||$&&Tp($)&&!Od[o[b-1]]||!Od[o[b]]?o[b]:Od[o[b]]}return m}(this.text)}trim(){let o=0;for(let b=0;b<this.text.length&&N_[this.text.charCodeAt(b)];b++)o++;let m=this.text.length;for(let b=this.text.length-1;b>=0&&b>=o&&N_[this.text.charCodeAt(b)];b--)m--;this.text=this.text.substring(o,m),this.sectionIndex=this.sectionIndex.slice(o,m)}substring(o,m){const b=new Bp;return b.text=this.text.substring(o,m),b.sectionIndex=this.sectionIndex.slice(o,m),b.sections=this.sections,b}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((o,m)=>Math.max(o,this.sections[m].scale),0)}addTextSection(o,m){this.text+=o.text,this.sections.push(Jg.forText(o.scale,o.fontStack||m));const b=this.sections.length-1;for(let T=0;T<o.text.length;++T)this.sectionIndex.push(b)}addImageSection(o){const m=o.image?o.image.name:"";if(m.length===0)return void oe("Can't add FormattedSection with an empty image.");const b=this.getNextImageSectionCharCode();b?(this.text+=String.fromCharCode(b),this.sections.push(Jg.forImage(m)),this.sectionIndex.push(this.sections.length-1)):oe("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function w_(d,o,m,b,T,$,V,U,ne,me,ye,Te,$e,Ye,et){const mt=Bp.fromFeature(d,T);let Tt;Te===u.ah.vertical&&mt.verticalizePunctuation();const{processBidirectionalText:Ot,processStyledBidirectionalText:gs}=no;if(Ot&&mt.sections.length===1){Tt=[];const Cs=Ot(mt.toString(),tv(mt,me,$,o,b,Ye));for(const Us of Cs){const $n=new Bp;$n.text=Us,$n.sections=mt.sections;for(let La=0;La<Us.length;La++)$n.sectionIndex.push(0);Tt.push($n)}}else if(gs){Tt=[];const Cs=gs(mt.text,mt.sectionIndex,tv(mt,me,$,o,b,Ye));for(const Us of Cs){const $n=new Bp;$n.text=Us[0],$n.sectionIndex=Us[1],$n.sections=mt.sections,Tt.push($n)}}else Tt=function(Cs,Us){const $n=[],La=Cs.text;let Rn=0;for(const kn of Us)$n.push(Cs.substring(Rn,kn)),Rn=kn;return Rn<La.length&&$n.push(Cs.substring(Rn,La.length)),$n}(mt,tv(mt,me,$,o,b,Ye));const Yt=[],ls={positionedLines:Yt,text:mt.toString(),top:ye[1],bottom:ye[1],left:ye[0],right:ye[0],writingMode:Te,iconsInText:!1,verticalizable:!1};return function(Cs,Us,$n,La,Rn,kn,ga,ta,Yn,Ds,_a,ma){let Xa=0,Qi=Kg,Wi=0,nc=0;const sh=ta==="right"?1:ta==="left"?0:.5;let $c=0;for(const ll of Rn){ll.trim();const rc=ll.getMaxScale(),rd=(rc-1)*ii,Vc={positionedGlyphs:[],lineOffset:0};Cs.positionedLines[$c]=Vc;const kd=Vc.positionedGlyphs;let qc=0;if(!ll.length()){Qi+=kn,++$c;continue}for(let Bd=0;Bd<ll.length();Bd++){const pi=ll.getSection(Bd),io=ll.getSectionIndex(Bd),xo=ll.getCharCode(Bd);let ru=0,Wo=null,Gp=null,Jh=null,Qh=ii;const nh=!(Yn===u.ah.horizontal||!_a&&!Ym(xo)||_a&&(N_[xo]||(ac=xo,new RegExp("\\p{sc=Arab}","u").test(String.fromCodePoint(ac)))));if(pi.imageName){const Lu=La[pi.imageName];if(!Lu)continue;Jh=pi.imageName,Cs.iconsInText=Cs.iconsInText||!0,Gp=Lu.paddedRect;const yc=Lu.displaySize;pi.scale=pi.scale*ii/ma,Wo={width:yc[0],height:yc[1],left:ol,top:-th,advance:nh?yc[1]:yc[0]},ru=rd+(ii-yc[1]*pi.scale),Qh=Wo.advance;const Em=nh?yc[0]*pi.scale-ii*rc:yc[1]*pi.scale-ii*rc;Em>0&&Em>qc&&(qc=Em)}else{const Lu=$n[pi.fontStack],yc=Lu&&Lu[xo];if(yc&&yc.rect)Gp=yc.rect,Wo=yc.metrics;else{const Em=Us[pi.fontStack],nx=Em&&Em[xo];if(!nx)continue;Wo=nx.metrics}ru=(rc-pi.scale)*ii}nh?(Cs.verticalizable=!0,kd.push({glyph:xo,imageName:Jh,x:Xa,y:Qi+ru,vertical:nh,scale:pi.scale,fontStack:pi.fontStack,sectionIndex:io,metrics:Wo,rect:Gp}),Xa+=Qh*pi.scale+Ds):(kd.push({glyph:xo,imageName:Jh,x:Xa,y:Qi+ru,vertical:nh,scale:pi.scale,fontStack:pi.fontStack,sectionIndex:io,metrics:Wo,rect:Gp}),Xa+=Wo.advance*pi.scale+Ds)}kd.length!==0&&(Wi=Math.max(Xa-Ds,Wi),bL(kd,0,kd.length-1,sh,qc)),Xa=0;const Tu=kn*rc+qc;Vc.lineOffset=Math.max(qc,rd),Qi+=Tu,nc=Math.max(Tu,nc),++$c}var ac;const jd=Qi-Kg,{horizontalAlign:wd,verticalAlign:Nd}=sv(ga);(function(ll,rc,rd,Vc,kd,qc,Tu,Bd,pi){const io=(rc-rd)*kd;let xo=0;xo=qc!==Tu?-Bd*Vc-Kg:(-Vc*pi+.5)*Tu;for(const ru of ll)for(const Wo of ru.positionedGlyphs)Wo.x+=io,Wo.y+=xo})(Cs.positionedLines,sh,wd,Nd,Wi,nc,kn,jd,Rn.length),Cs.top+=-Nd*jd,Cs.bottom=Cs.top+jd,Cs.left+=-wd*Wi,Cs.right=Cs.left+Wi}(ls,o,m,b,Tt,V,U,ne,Te,me,$e,et),!function(Cs){for(const Us of Cs)if(Us.positionedGlyphs.length!==0)return!1;return!0}(Yt)&&ls}const N_={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},_L={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},yL={40:!0};function Qj(d,o,m,b,T,$){if(o.imageName){const V=b[o.imageName];return V?V.displaySize[0]*o.scale*ii/$+T:0}{const V=m[o.fontStack],U=V&&V[d];return U?U.metrics.advance*o.scale+T:0}}function Uj(d,o,m,b){const T=Math.pow(d-o,2);return b?d<o?T/2:2*T:T+Math.abs(m)*m}function vL(d,o,m){let b=0;return d===10&&(b-=1e4),m&&(b+=150),d!==40&&d!==65288||(b+=50),o!==41&&o!==65289||(b+=50),b}function ew(d,o,m,b,T,$){let V=null,U=Uj(o,m,T,$);for(const ne of b){const me=Uj(o-ne.x,m,T,$)+ne.badness;me<=U&&(V=ne,U=me)}return{index:d,x:o,priorBreak:V,badness:U}}function tw(d){return d?tw(d.priorBreak).concat(d.index):[]}function tv(d,o,m,b,T,$){if(!d)return[];const V=[],U=function(Te,$e,Ye,et,mt,Tt){let Ot=0;for(let gs=0;gs<Te.length();gs++){const Yt=Te.getSection(gs);Ot+=Qj(Te.getCharCode(gs),Yt,et,mt,$e,Tt)}return Ot/Math.max(1,Math.ceil(Ot/Ye))}(d,o,m,b,T,$),ne=d.text.indexOf("​")>=0;let me=0;for(let Te=0;Te<d.length();Te++){const $e=d.getSection(Te),Ye=d.getCharCode(Te);if(N_[Ye]||(me+=Qj(Ye,$e,b,T,o,$)),Te<d.length()-1){const et=!((ye=Ye)<11904)&&(!!Ua["CJK Compatibility Forms"](ye)||!!Ua["CJK Compatibility"](ye)||!!Ua["CJK Strokes"](ye)||!!Ua["CJK Symbols and Punctuation"](ye)||!!Ua["Enclosed CJK Letters and Months"](ye)||!!Ua["Halfwidth and Fullwidth Forms"](ye)||!!Ua["Ideographic Description Characters"](ye)||!!Ua["Vertical Forms"](ye)||Vf.test(String.fromCodePoint(ye)));(_L[Ye]||et||$e.imageName||Te!==d.length()-2&&yL[d.getCharCode(Te+1)])&&
vendor: 11,070 bytes, line 1962
1962V.push(ew(Te+1,me,U,V,vL(Ye,d.getCharCode(Te+1),et&&ne),!1))}}var ye;return tw(ew(d.length(),me,U,V,0,!0))}function sv(d){let o=.5,m=.5;switch(d){case"right":case"top-right":case"bottom-right":o=1;break;case"left":case"top-left":case"bottom-left":o=0}switch(d){case"bottom":case"bottom-right":case"bottom-left":m=1;break;case"top":case"top-right":case"top-left":m=0}return{horizontalAlign:o,verticalAlign:m}}function bL(d,o,m,b,T){if(!b&&!T)return;const $=d[m],V=(d[m].x+$.metrics.advance*$.scale)*b;for(let U=o;U<=m;U++)d[U].x-=V,d[U].y+=T}function jL(d,o,m){const{horizontalAlign:b,verticalAlign:T}=sv(m),$=o[0]-d.displaySize[0]*b,V=o[1]-d.displaySize[1]*T;return{image:d,top:V,bottom:V+d.displaySize[1],left:$,right:$+d.displaySize[0]}}function sw(d){var o,m;let b=d.left,T=d.top,$=d.right-b,V=d.bottom-T;const U=(o=d.image.textFitWidth)!==null&&o!==void 0?o:"stretchOrShrink",ne=(m=d.image.textFitHeight)!==null&&m!==void 0?m:"stretchOrShrink",me=(d.image.content[2]-d.image.content[0])/(d.image.content[3]-d.image.content[1]);if(ne==="proportional"){if(U==="stretchOnly"&&$/V<me||U==="proportional"){const ye=Math.ceil(V*me);b*=ye/$,$=ye}}else if(U==="proportional"&&ne==="stretchOnly"&&me!==0&&$/V>me){const ye=Math.ceil($/me);T*=ye/V,V=ye}return{x1:b,y1:T,x2:b+$,y2:T+V}}function nw(d,o,m,b,T,$){const V=d.image;let U;if(V.content){const Tt=V.content,Ot=V.pixelRatio||1;U=[Tt[0]/Ot,Tt[1]/Ot,V.displaySize[0]-Tt[2]/Ot,V.displaySize[1]-Tt[3]/Ot]}const ne=o.left*$,me=o.right*$;let ye,Te,$e,Ye;m==="width"||m==="both"?(Ye=T[0]+ne-b[3],Te=T[0]+me+b[1]):(Ye=T[0]+(ne+me-V.displaySize[0])/2,Te=Ye+V.displaySize[0]);const et=o.top*$,mt=o.bottom*$;return m==="height"||m==="both"?(ye=T[1]+et-b[0],$e=T[1]+mt+b[2]):(ye=T[1]+(et+mt-V.displaySize[1])/2,$e=ye+V.displaySize[1]),{image:V,top:ye,right:Te,bottom:$e,left:Ye,collisionPadding:U}}const Qg=255,Kh=128,cf=Qg*Kh;function aw(d,o){const{expression:m}=o;if(m.kind==="constant")return{kind:"constant",layoutSize:m.evaluate(new yi(d+1))};if(m.kind==="source")return{kind:"source"};{const{zoomStops:b,interpolationType:T}=m;let $=0;for(;$<b.length&&b[$]<=d;)$++;$=Math.max(0,$-1);let V=$;for(;V<b.length&&b[V]<d+1;)V++;V=Math.min(b.length-1,V);const U=b[$],ne=b[V];return m.kind==="composite"?{kind:"composite",minZoom:U,maxZoom:ne,interpolationType:T}:{kind:"camera",minZoom:U,maxZoom:ne,minSize:m.evaluate(new yi(U)),maxSize:m.evaluate(new yi(ne)),interpolationType:T}}}function nv(d,o,m){let b="never";const T=d.get(o);return T?b=T:d.get(m)&&(b="always"),b}const wL=Qa.VectorTileFeature.types,NL=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function k_(d,o,m,b,T,$,V,U,ne,me,ye,Te,$e){const Ye=U?Math.min(cf,Math.round(U[0])):0,et=U?Math.min(cf,Math.round(U[1])):0;d.emplaceBack(o,m,Math.round(32*b),Math.round(32*T),$,V,(Ye<<1)+(ne?1:0),et,16*me,16*ye,256*Te,256*$e)}function av(d,o,m){d.emplaceBack(o.x,o.y,m),d.emplaceBack(o.x,o.y,m),d.emplaceBack(o.x,o.y,m),d.emplaceBack(o.x,o.y,m)}function kL(d){for(const o of d.sections)if(ed(o.text))return!0;return!1}class rv{constructor(o){this.layoutVertexArray=new Zf,this.indexArray=new Rc,this.programConfigurations=o,this.segments=new qr,this.dynamicLayoutVertexArray=new Wf,this.opacityVertexArray=new td,this.hasVisibleVertices=!1,this.placedSymbolArray=new mi}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(o,m,b,T){this.isEmpty()||(b&&(this.layoutVertexBuffer=o.createVertexBuffer(this.layoutVertexArray,Ho.members),this.indexBuffer=o.createIndexBuffer(this.indexArray,m),this.dynamicLayoutVertexBuffer=o.createVertexBuffer(this.dynamicLayoutVertexArray,ko.members,!0),this.opacityVertexBuffer=o.createVertexBuffer(this.opacityVertexArray,NL,!0),this.opacityVertexBuffer.itemSize=1),(b||T)&&this.programConfigurations.upload(o))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}jn("SymbolBuffers",rv);class iv{constructor(o,m,b){this.layoutVertexArray=new o,this.layoutAttributes=m,this.indexArray=new b,this.segments=new qr,this.collisionVertexArray=new ju}upload(o){this.layoutVertexBuffer=o.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=o.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=o.createVertexBuffer(this.collisionVertexArray,Su.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}jn("CollisionBuffers",iv);class $p{constructor(o){this.collisionBoxArray=o.collisionBoxArray,this.zoom=o.zoom,this.overscaling=o.overscaling,this.layers=o.layers,this.layerIds=this.layers.map(V=>V.id),this.index=o.index,this.pixelRatio=o.pixelRatio,this.sourceLayerIndex=o.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Ne([]),this.placementViewportMatrix=Ne([]);const m=this.layers[0]._unevaluatedLayout._values;this.textSizeData=aw(this.zoom,m["text-size"]),this.iconSizeData=aw(this.zoom,m["icon-size"]);const b=this.layers[0].layout,T=b.get("symbol-sort-key"),$=b.get("symbol-z-order");this.canOverlap=nv(b,"text-overlap","text-allow-overlap")!=="never"||nv(b,"icon-overlap","icon-allow-overlap")!=="never"||b.get("text-ignore-placement")||b.get("icon-ignore-placement"),this.sortFeaturesByKey=$!=="viewport-y"&&!T.isConstant(),this.sortFeaturesByY=($==="viewport-y"||$==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,b.get("symbol-placement")==="point"&&(this.writingModes=b.get("text-writing-mode").map(V=>u.ah[V])),this.stateDependentLayerIds=this.layers.filter(V=>V.isStateDependent()).map(V=>V.id),this.sourceID=o.sourceID}createArrays(){this.text=new rv(new Hh(this.layers,this.zoom,o=>/^text/.test(o))),this.icon=new rv(new Hh(this.layers,this.zoom,o=>/^icon/.test(o))),this.glyphOffsetArray=new Pi,this.lineVertexArray=new al,this.symbolInstances=new Sr,this.textAnchorOffsets=new Ti}calculateGlyphDependencies(o,m,b,T,$){for(let V=0;V<o.length;V++)if(m[o.charCodeAt(V)]=!0,(b||T)&&$){const U=Od[o.charAt(V)];U&&(m[U.charCodeAt(0)]=!0)}}populate(o,m,b){const T=this.layers[0],$=T.layout,V=$.get("text-font"),U=$.get("text-field"),ne=$.get("icon-image"),me=(U.value.kind!=="constant"||U.value.value instanceof ei&&!U.value.value.isEmpty()||U.value.value.toString().length>0)&&(V.value.kind!=="constant"||V.value.value.length>0),ye=ne.value.kind!=="constant"||!!ne.value.value||Object.keys(ne.parameters).length>0,Te=$.get("symbol-sort-key");if(this.features=[],!me&&!ye)return;const $e=m.iconDependencies,Ye=m.glyphDependencies,et=m.availableImages,mt=new yi(this.zoom);for(const{feature:Tt,id:Ot,index:gs,sourceLayerIndex:Yt}of o){const ls=T._featureFilter.needGeometry,Cs=Wh(Tt,ls);if(!T._featureFilter.filter(mt,Cs,b))continue;let Us,$n;if(ls||(Cs.geometry=Zh(Tt)),me){const Rn=T.getValueAndResolveTokens("text-field",Cs,b,et),kn=ei.factory(Rn),ga=this.hasRTLText=this.hasRTLText||kL(kn);(!ga||no.getRTLTextPluginStatus()==="unavailable"||ga&&no.isParsed())&&(Us=rf(kn,T,Cs))}if(ye){const Rn=T.getValueAndResolveTokens("icon-image",Cs,b,et);$n=Rn instanceof Ka?Rn:Ka.fromString(Rn)}if(!Us&&!$n)continue;const La=this.sortFeaturesByKey?Te.evaluate(Cs,{},b):void 0;if(this.features.push({id:Ot,text:Us,icon:$n,index:gs,sourceLayerIndex:Yt,geometry:Cs.geometry,properties:Tt.properties,type:wL[Tt.type],sortKey:La}),$n&&($e[$n.name]=!0),Us){const Rn=V.evaluate(Cs,{},b).join(","),kn=$.get("text-rotation-alignment")!=="viewport"&&$.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(u.ah.vertical)>=0;for(const ga of Us.sections)if(ga.image)$e[ga.image.name]=!0;else{const ta=vm(Us.toString()),Yn=ga.fontStack||Rn,Ds=Ye[Yn]=Ye[Yn]||{};this.calculateGlyphDependencies(ga.text,Ds,kn,this.allowVerticalPlacement,ta)}}}$.get("symbol-placement")==="line"&&(this.features=function(Tt){const Ot={},gs={},Yt=[];let ls=0;function Cs(Rn){Yt.push(Tt[Rn]),ls++}function Us(Rn,kn,ga){const ta=gs[Rn];return delete gs[Rn],gs[kn]=ta,Yt[ta].geometry[0].pop(),Yt[ta].geometry[0]=Yt[ta].geometry[0].concat(ga[0]),ta}function $n(Rn,kn,ga){const ta=Ot[kn];return delete Ot[kn],Ot[Rn]=ta,Yt[ta].geometry[0].shift(),Yt[ta].geometry[0]=ga[0].concat(Yt[ta].geometry[0]),ta}function La(Rn,kn,ga){const ta=ga?kn[0][kn[0].length-1]:kn[0][0];return`${Rn}:${ta.x}:${ta.y}`}for(let Rn=0;Rn<Tt.length;Rn++){const kn=Tt[Rn],ga=kn.geometry,ta=kn.text?kn.text.toString():null;if(!ta){Cs(Rn);continue}const Yn=La(ta,ga),Ds=La(ta,ga,!0);if(Yn in gs&&Ds in Ot&&gs[Yn]!==Ot[Ds]){const _a=$n(Yn,Ds,ga),ma=Us(Yn,Ds,Yt[_a].geometry);delete Ot[Yn],delete gs[Ds],gs[La(ta,Yt[ma].geometry,!0)]=ma,Yt[_a].geometry=null}else Yn in gs?Us(Yn,Ds,ga):Ds in Ot?$n(Yn,Ds,ga):(Cs(Rn),Ot[Yn]=ls-1,gs[Ds]=ls-1)}return Yt.filter(Rn=>Rn.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((Tt,Ot)=>Tt.sortKey-Ot.sortKey)}update(o,m,b){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(o,m,this.layers,b),this.icon.programConfigurations.updatePaintArrays(o,m,this.layers,b))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(o){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(o),this.iconCollisionBox.upload(o)),this.text.upload(o,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(o,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(o,m){const b=this.lineVertexArray.length;if(o.segment!==void 0){let T=o.dist(m[o.segment+1]),$=o.dist(m[o.segment]);const V={};for(let U=o.segment+1;U<m.length;U++)V[U]={x:m[U].x,y:m[U].y,tileUnitDistanceFromAnchor:T},U<m.length-1&&(T+=m[U+1].dist(m[U]));for(let U=o.segment||0;U>=0;U--)V[U]={x:m[U].x,y:m[U].y,tileUnitDistanceFromAnchor:$},U>0&&($+=m[U-1].dist(m[U]));for(let U=0;U<m.length;U++){const ne=V[U];this.lineVertexArray.emplaceBack(ne.x,ne.y,ne.tileUnitDistanceFromAnchor)}}return{lineStartIndex:b,lineLength:this.lineVertexArray.length-b}}addSymbols(o,m,b,T,$,V,U,ne,me,ye,Te,$e){const Ye=o.indexArray,et=o.layoutVertexArray,mt=o.segments.prepareSegment(4*m.length,et,Ye,this.canOverlap?V.sortKey:void 0),Tt=this.glyphOffsetArray.length,Ot=mt.vertexLength,gs=this.allowVerticalPlacement&&U===u.ah.vertical?Math.PI/2:0,Yt=V.text&&V.text.sections;for(let ls=0;ls<m.length;ls++){const{tl:Cs,tr:Us,bl:$n,br:La,tex:Rn,pixelOffsetTL:kn,pixelOffsetBR:ga,minFontScaleX:ta,minFontScaleY:Yn,glyphOffset:Ds,isSDF:_a,sectionIndex:ma}
vendor: 4,102 bytes, line 1962
1962=m[ls],Xa=mt.vertexLength,Qi=Ds[1];k_(et,ne.x,ne.y,Cs.x,Qi+Cs.y,Rn.x,Rn.y,b,_a,kn.x,kn.y,ta,Yn),k_(et,ne.x,ne.y,Us.x,Qi+Us.y,Rn.x+Rn.w,Rn.y,b,_a,ga.x,kn.y,ta,Yn),k_(et,ne.x,ne.y,$n.x,Qi+$n.y,Rn.x,Rn.y+Rn.h,b,_a,kn.x,ga.y,ta,Yn),k_(et,ne.x,ne.y,La.x,Qi+La.y,Rn.x+Rn.w,Rn.y+Rn.h,b,_a,ga.x,ga.y,ta,Yn),av(o.dynamicLayoutVertexArray,ne,gs),Ye.emplaceBack(Xa,Xa+1,Xa+2),Ye.emplaceBack(Xa+1,Xa+2,Xa+3),mt.vertexLength+=4,mt.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(Ds[0]),ls!==m.length-1&&ma===m[ls+1].sectionIndex||o.programConfigurations.populatePaintArrays(et.length,V,V.index,{},$e,Yt&&Yt[ma])}o.placedSymbolArray.emplaceBack(ne.x,ne.y,Tt,this.glyphOffsetArray.length-Tt,Ot,me,ye,ne.segment,b?b[0]:0,b?b[1]:0,T[0],T[1],U,0,!1,0,Te)}_addCollisionDebugVertex(o,m,b,T,$,V){return m.emplaceBack(0,0),o.emplaceBack(b.x,b.y,T,$,Math.round(V.x),Math.round(V.y))}addCollisionDebugVertices(o,m,b,T,$,V,U){const ne=$.segments.prepareSegment(4,$.layoutVertexArray,$.indexArray),me=ne.vertexLength,ye=$.layoutVertexArray,Te=$.collisionVertexArray,$e=U.anchorX,Ye=U.anchorY;this._addCollisionDebugVertex(ye,Te,V,$e,Ye,new x(o,m)),this._addCollisionDebugVertex(ye,Te,V,$e,Ye,new x(b,m)),this._addCollisionDebugVertex(ye,Te,V,$e,Ye,new x(b,T)),this._addCollisionDebugVertex(ye,Te,V,$e,Ye,new x(o,T)),ne.vertexLength+=4;const et=$.indexArray;et.emplaceBack(me,me+1),et.emplaceBack(me+1,me+2),et.emplaceBack(me+2,me+3),et.emplaceBack(me+3,me),ne.primitiveLength+=4}addDebugCollisionBoxes(o,m,b,T){for(let $=o;$<m;$++){const V=this.collisionBoxArray.get($);this.addCollisionDebugVertices(V.x1,V.y1,V.x2,V.y2,T?this.textCollisionBox:this.iconCollisionBox,V.anchorPoint,b)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new iv(vd,Ll.members,$l),this.iconCollisionBox=new iv(vd,Ll.members,$l);for(let o=0;o<this.symbolInstances.length;o++){const m=this.symbolInstances.get(o);this.addDebugCollisionBoxes(m.textBoxStartIndex,m.textBoxEndIndex,m,!0),this.addDebugCollisionBoxes(m.verticalTextBoxStartIndex,m.verticalTextBoxEndIndex,m,!0),this.addDebugCollisionBoxes(m.iconBoxStartIndex,m.iconBoxEndIndex,m,!1),this.addDebugCollisionBoxes(m.verticalIconBoxStartIndex,m.verticalIconBoxEndIndex,m,!1)}}_deserializeCollisionBoxesForSymbol(o,m,b,T,$,V,U,ne,me){const ye={};for(let Te=m;Te<b;Te++){const $e=o.get(Te);ye.textBox={x1:$e.x1,y1:$e.y1,x2:$e.x2,y2:$e.y2,anchorPointX:$e.anchorPointX,anchorPointY:$e.anchorPointY},ye.textFeatureIndex=$e.featureIndex;break}for(let Te=T;Te<$;Te++){const $e=o.get(Te);ye.verticalTextBox={x1:$e.x1,y1:$e.y1,x2:$e.x2,y2:$e.y2,anchorPointX:$e.anchorPointX,anchorPointY:$e.anchorPointY},ye.verticalTextFeatureIndex=$e.featureIndex;break}for(let Te=V;Te<U;Te++){const $e=o.get(Te);ye.iconBox={x1:$e.x1,y1:$e.y1,x2:$e.x2,y2:$e.y2,anchorPointX:$e.anchorPointX,anchorPointY:$e.anchorPointY},ye.iconFeatureIndex=$e.featureIndex;break}for(let Te=ne;Te<me;Te++){const $e=o.get(Te);ye.verticalIconBox={x1:$e.x1,y1:$e.y1,x2:$e.x2,y2:$e.y2,anchorPointX:$e.anchorPointX,anchorPointY:$e.anchorPointY},ye.verticalIconFeatureIndex=$e.featureIndex;break}return ye}deserializeCollisionBoxes(o){this.collisionArrays=[];for(let m=0;m<this.symbolInstances.length;m++){const b=this.symbolInstances.get(m);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(o,b.textBoxStartIndex,b.textBoxEndIndex,b.verticalTextBoxStartIndex,b.verticalTextBoxEndIndex,b.iconBoxStartIndex,b.iconBoxEndIndex,b.verticalIconBoxStartIndex,b.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(o,m){const b=o.placedSymbolArray.get(m),T=b.vertexStartIndex+4*b.numGlyphs;for(let $=b.vertexStartIndex;$<T;$+=4)o.indexArray.emplaceBack($,$+1,$+2),o.indexArray.emplaceBack($+1,$+2,$+3)}
vendor: 8,700 bytes, line 1962
1962getSortedSymbolIndexes(o){if(this.sortedAngle===o&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const m=Math.sin(o),b=Math.cos(o),T=[],$=[],V=[];for(let U=0;U<this.symbolInstances.length;++U){V.push(U);const ne=this.symbolInstances.get(U);T.push(0|Math.round(m*ne.anchorX+b*ne.anchorY)),$.push(ne.featureIndex)}return V.sort((U,ne)=>T[U]-T[ne]||$[ne]-$[U]),V}addToSortKeyRanges(o,m){const b=this.sortKeyRanges[this.sortKeyRanges.length-1];b&&b.sortKey===m?b.symbolInstanceEnd=o+1:this.sortKeyRanges.push({sortKey:m,symbolInstanceStart:o,symbolInstanceEnd:o+1})}sortFeatures(o){if(this.sortFeaturesByY&&this.sortedAngle!==o&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(o),this.sortedAngle=o,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const m of this.symbolInstanceIndexes){const b=this.symbolInstances.get(m);this.featureSortOrder.push(b.featureIndex),[b.rightJustifiedTextSymbolIndex,b.centerJustifiedTextSymbolIndex,b.leftJustifiedTextSymbolIndex].forEach((T,$,V)=>{T>=0&&V.indexOf(T)===$&&this.addIndicesForPlacedSymbol(this.text,T)}),b.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,b.verticalPlacedTextSymbolIndex),b.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,b.placedIconSymbolIndex),b.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,b.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let rw,iw;jn("SymbolBucket",$p,{omit:["layers","collisionBoxArray","features","compareText"]}),$p.MAX_GLYPHS=65535,$p.addDynamicAttributes=av;var ov={get paint(){return iw=iw||new R({"icon-opacity":new ia(He.paint_symbol["icon-opacity"]),"icon-color":new ia(He.paint_symbol["icon-color"]),"icon-halo-color":new ia(He.paint_symbol["icon-halo-color"]),"icon-halo-width":new ia(He.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ia(He.paint_symbol["icon-halo-blur"]),"icon-translate":new ea(He.paint_symbol["icon-translate"]),"icon-translate-anchor":new ea(He.paint_symbol["icon-translate-anchor"]),"text-opacity":new ia(He.paint_symbol["text-opacity"]),"text-color":new ia(He.paint_symbol["text-color"],{runtimeType:nt,getOverride:d=>d.textColor,hasOverride:d=>!!d.textColor}),"text-halo-color":new ia(He.paint_symbol["text-halo-color"]),"text-halo-width":new ia(He.paint_symbol["text-halo-width"]),"text-halo-blur":new ia(He.paint_symbol["text-halo-blur"]),"text-translate":new ea(He.paint_symbol["text-translate"]),"text-translate-anchor":new ea(He.paint_symbol["text-translate-anchor"])})},get layout(){return rw=rw||new R({"symbol-placement":new ea(He.layout_symbol["symbol-placement"]),"symbol-spacing":new ea(He.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new ea(He.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ia(He.layout_symbol["symbol-sort-key"]),"symbol-z-order":new ea(He.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new ea(He.layout_symbol["icon-allow-overlap"]),"icon-overlap":new ea(He.layout_symbol["icon-overlap"]),"icon-ignore-placement":new ea(He.layout_symbol["icon-ignore-placement"]),"icon-optional":new ea(He.layout_symbol["icon-optional"]),"icon-rotation-alignment":new ea(He.layout_symbol["icon-rotation-alignment"]),"icon-size":new ia(He.layout_symbol["icon-size"]),"icon-text-fit":new ea(He.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ea(He.layout_symbol["icon-text-fit-padding"]),"icon-image":new ia(He.layout_symbol["icon-image"]),"icon-rotate":new ia(He.layout_symbol["icon-rotate"]),"icon-padding":new ia(He.layout_symbol["icon-padding"]),"icon-keep-upright":new ea(He.layout_symbol["icon-keep-upright"]),"icon-offset":new ia(He.layout_symbol["icon-offset"]),"icon-anchor":new ia(He.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new ea(He.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new ea(He.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new ea(He.layout_symbol["text-rotation-alignment"]),"text-field":new ia(He.layout_symbol["text-field"]),"text-font":new ia(He.layout_symbol["text-font"]),"text-size":new ia(He.layout_symbol["text-size"]),"text-max-width":new ia(He.layout_symbol["text-max-width"]),"text-line-height":new ea(He.layout_symbol["text-line-height"]),"text-letter-spacing":new ia(He.layout_symbol["text-letter-spacing"]),"text-justify":new ia(He.layout_symbol["text-justify"]),"text-radial-offset":new ia(He.layout_symbol["text-radial-offset"]),"text-variable-anchor":new ea(He.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new ia(He.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new ia(He.layout_symbol["text-anchor"]),"text-max-angle":new ea(He.layout_symbol["text-max-angle"]),"text-writing-mode":new ea(He.layout_symbol["text-writing-mode"]),"text-rotate":new ia(He.layout_symbol["text-rotate"]),"text-padding":new ea(He.layout_symbol["text-padding"]),"text-keep-upright":new ea(He.layout_symbol["text-keep-upright"]),"text-transform":new ia(He.layout_symbol["text-transform"]),"text-offset":new ia(He.layout_symbol["text-offset"]),"text-allow-overlap":new ea(He.layout_symbol["text-allow-overlap"]),"text-overlap":new ea(He.layout_symbol["text-overlap"]),"text-ignore-placement":new ea(He.layout_symbol["text-ignore-placement"]),"text-optional":new ea(He.layout_symbol["text-optional"])})}};class ow{constructor(o){if(o.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=o.property.overrides?o.property.overrides.runtimeType:en,this.defaultValue=o}evaluate(o){if(o.formattedSection){const m=this.defaultValue.property.overrides;if(m&&m.hasOverride(o.formattedSection))return m.getOverride(o.formattedSection)}return o.feature&&o.featureState?this.defaultValue.evaluate(o.feature,o.featureState):this.defaultValue.property.specification.default}eachChild(o){this.defaultValue.isConstant()||o(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}jn("FormatSectionOverride",ow,{omit:["defaultValue"]});class C_ extends g{constructor(o){super(o,ov)}recalculate(o,m){if(super.recalculate(o,m),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const b=this.layout.get("text-writing-mode");if(b){const T=[];for(const $ of b)T.indexOf($)<0&&T.push($);this.layout._values["text-writing-mode"]=T}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(o,m,b,T){const $=this.layout.get(o).evaluate(m,{},b,T),V=this._unevaluatedLayout._values[o];return V.isDataDriven()||G(V.value)||!$?$:function(U,ne){return ne.replace(/{([^{}]+)}/g,(me,ye)=>U&&ye in U?String(U[ye]):"")}(m.properties,$)}createBucket(o){return new $p(o)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const o of ov.paint.overridableProperties){if(!C_.hasPaintOverride(this.layout,o))continue;const m=this.paint.get(o),b=new ow(m),T=new w(b,m.property.specification);let $=null;$=m.value.kind==="constant"||m.value.kind==="source"?new xe("source",T):new Ae("composite",T,m.value.zoomStops),this.paint._values[o]=new yd(m.property,$,m.parameters)}}_handleOverridablePaintPropertyUpdate(o,m,b){return!(!this.layout||m.isDataDriven()||b.isDataDriven())&&C_.hasPaintOverride(this.layout,o)}static hasPaintOverride(o,m){const b=o.get("text-field"),T=ov.paint.properties[m];let $=!1;const V=U=>{for(const ne of U)if(T.overrides&&T.overrides.hasOverride(ne))return void($=!0)};if(b.value.kind==="constant"&&b.value.value instanceof ei)V(b.value.value.sections);else if(b.value.kind==="source"){const U=me=>{$||(me instanceof Ar&&Mn(me.value)===tn?V(me.value.sections):me instanceof oa?V(me.sections):me.eachChild(U))},ne=b.value;ne._styleExpression&&U(ne._styleExpression.expression)}return $}}let lw;
vendor: 12,306 bytes, line 1962
1962var CL={get paint(){return lw=lw||new R({"background-color":new ea(He.paint_background["background-color"]),"background-pattern":new Xm(He.paint_background["background-pattern"]),"background-opacity":new ea(He.paint_background["background-opacity"])})}};class SL extends g{constructor(o){super(o,CL)}}let cw;var EL={get paint(){return cw=cw||new R({"raster-opacity":new ea(He.paint_raster["raster-opacity"]),"raster-hue-rotate":new ea(He.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new ea(He.paint_raster["raster-brightness-min"]),"raster-brightness-max":new ea(He.paint_raster["raster-brightness-max"]),"raster-saturation":new ea(He.paint_raster["raster-saturation"]),"raster-contrast":new ea(He.paint_raster["raster-contrast"]),"raster-resampling":new ea(He.paint_raster["raster-resampling"]),"raster-fade-duration":new ea(He.paint_raster["raster-fade-duration"])})}};class PL extends g{constructor(o){super(o,EL)}}class TL extends g{constructor(o){super(o,{}),this.onAdd=m=>{this.implementation.onAdd&&this.implementation.onAdd(m,m.painter.context.gl)},this.onRemove=m=>{this.implementation.onRemove&&this.implementation.onRemove(m,m.painter.context.gl)},this.implementation=o}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class LL{constructor(o){this._methodToThrottle=o,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const lv=63710088e-1;class df{constructor(o,m){if(isNaN(o)||isNaN(m))throw new Error(`Invalid LngLat object: (${o}, ${m})`);if(this.lng=+o,this.lat=+m,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new df(J(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(o){const m=Math.PI/180,b=this.lat*m,T=o.lat*m,$=Math.sin(b)*Math.sin(T)+Math.cos(b)*Math.cos(T)*Math.cos((o.lng-this.lng)*m);return lv*Math.acos(Math.min($,1))}static convert(o){if(o instanceof df)return o;if(Array.isArray(o)&&(o.length===2||o.length===3))return new df(Number(o[0]),Number(o[1]));if(!Array.isArray(o)&&typeof o=="object"&&o!==null)return new df(Number("lng"in o?o.lng:o.lon),Number(o.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const dw=2*Math.PI*lv;function uw(d){return dw*Math.cos(d*Math.PI/180)}function hw(d){return(180+d)/360}function mw(d){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+d*Math.PI/360)))/360}function fw(d,o){return d/uw(o)}function cv(d){return 360/Math.PI*Math.atan(Math.exp((180-360*d)*Math.PI/180))-90}class Ug{constructor(o,m,b=0){this.x=+o,this.y=+m,this.z=+b}static fromLngLat(o,m=0){const b=df.convert(o);return new Ug(hw(b.lng),mw(b.lat),fw(m,b.lat))}toLngLat(){return new df(360*this.x-180,cv(this.y))}toAltitude(){return this.z*uw(cv(this.y))}meterInMercatorCoordinateUnits(){return 1/dw*(o=cv(this.y),1/Math.cos(o*Math.PI/180));var o}}function pw(d,o,m){var b=2*Math.PI*6378137/256/Math.pow(2,m);return[d*b-2*Math.PI*6378137/2,o*b-2*Math.PI*6378137/2]}class dv{constructor(o,m,b){if(!function(T,$,V){return!(T<0||T>25||V<0||V>=Math.pow(2,T)||$<0||$>=Math.pow(2,T))}(o,m,b))throw new Error(`x=${m}, y=${b}, z=${o} outside of bounds. 0<=x<${Math.pow(2,o)}, 0<=y<${Math.pow(2,o)} 0<=z<=25 `);this.z=o,this.x=m,this.y=b,this.key=ex(0,o,o,m,b)}equals(o){return this.z===o.z&&this.x===o.x&&this.y===o.y}url(o,m,b){const T=(V=this.y,U=this.z,ne=pw(256*($=this.x),256*(V=Math.pow(2,U)-V-1),U),me=pw(256*($+1),256*(V+1),U),ne[0]+","+ne[1]+","+me[0]+","+me[1]);var $,V,U,ne,me;const ye=function(Te,$e,Ye){let et,mt="";for(let Tt=Te;Tt>0;Tt--)et=1<<Tt-1,mt+=($e&et?1:0)+(Ye&et?2:0);return mt}(this.z,this.x,this.y);return o[(this.x+this.y)%o.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(b==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,m>1?"@2x":"").replace(/{quadkey}/g,ye).replace(/{bbox-epsg-3857}/g,T)}isChildOf(o){const m=this.z-o.z;return m>0&&o.x===this.x>>m&&o.y===this.y>>m}getTilePoint(o){const m=Math.pow(2,this.z);return new x((o.x*m-this.x)*Oi,(o.y*m-this.y)*Oi)}toString(){return`${this.z}/${this.x}/${this.y}`}}class gw{constructor(o,m){this.wrap=o,this.canonical=m,this.key=ex(o,m.z,m.z,m.x,m.y)}}class Pu{constructor(o,m,b,T,$){if(o<b)throw new Error(`overscaledZ should be >= z; overscaledZ = ${o}; z = ${b}`);this.overscaledZ=o,this.wrap=m,this.canonical=new dv(b,+T,+$),this.key=ex(m,o,b,T,$)}clone(){return new Pu(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(o){return this.overscaledZ===o.overscaledZ&&this.wrap===o.wrap&&this.canonical.equals(o.canonical)}scaledTo(o){if(o>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${o}; overscaledZ = ${this.overscaledZ}`);const m=this.canonical.z-o;return o>this.canonical.z?new Pu(o,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Pu(o,this.wrap,o,this.canonical.x>>m,this.canonical.y>>m)}calculateScaledKey(o,m){if(o>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${o}; overscaledZ = ${this.overscaledZ}`);const b=this.canonical.z-o;return o>this.canonical.z?ex(this.wrap*+m,o,this.canonical.z,this.canonical.x,this.canonical.y):ex(this.wrap*+m,o,o,this.canonical.x>>b,this.canonical.y>>b)}isChildOf(o){if(o.wrap!==this.wrap)return!1;const m=this.canonical.z-o.canonical.z;return o.overscaledZ===0||o.overscaledZ<this.overscaledZ&&o.canonical.x===this.canonical.x>>m&&o.canonical.y===this.canonical.y>>m}children(o){if(this.overscaledZ>=o)return[new Pu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const m=this.canonical.z+1,b=2*this.canonical.x,T=2*this.canonical.y;return[new Pu(m,this.wrap,m,b,T),new Pu(m,this.wrap,m,b+1,T),new Pu(m,this.wrap,m,b,T+1),new Pu(m,this.wrap,m,b+1,T+1)]}isLessThan(o){return this.wrap<o.wrap||!(this.wrap>o.wrap)&&(this.overscaledZ<o.overscaledZ||!(this.overscaledZ>o.overscaledZ)&&(this.canonical.x<o.canonical.x||!(this.canonical.x>o.canonical.x)&&this.canonical.y<o.canonical.y))}wrapped(){return new Pu(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(o){return new Pu(this.overscaledZ,o,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new gw(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(o){return this.canonical.getTilePoint(new Ug(o.x-this.wrap,o.y))}}function ex(d,o,m,b,T){(d*=2)<0&&(d=-1*d-1);const $=1<<m;return($*$*d+$*T+b).toString(36)+m.toString(36)+o.toString(36)}jn("CanonicalTileID",dv),jn("OverscaledTileID",Pu,{omit:["posMatrix"]});class xw{constructor(o,m,b,T=1,$=1,V=1,U=0){if(this.uid=o,m.height!==m.width)throw new RangeError("DEM tiles must be square");if(b&&!["mapbox","terrarium","custom"].includes(b))return void oe(`"${b}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=m.height;const ne=this.dim=m.height-2;switch(this.data=new Uint32Array(m.data.buffer),b){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=T,this.greenFactor=$,this.blueFactor=V,this.baseShift=U;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let me=0;me<ne;me++)this.data[this._idx(-1,me)]=this.data[this._idx(0,me)],this.data[this._idx(ne,me)]=this.data[this._idx(ne-1,me)],this.data[this._idx(me,-1)]=this.data[this._idx(me,0)],this.data[this._idx(me,ne)]=this.data[this._idx(me,ne-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(ne,-1)]=this.data[this._idx(ne-1,0)],this.data[this._idx(-1,ne)]=this.data[this._idx(0,ne-1)],this.data[this._idx(ne,ne)]=this.data[this._idx(ne-1,ne-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let me=0;me<ne;me++)for(let ye=0;ye<ne;ye++){const Te=this.get(me,ye);Te>this.max&&(this.max=Te),Te<this.min&&(this.min=Te)}}get(o,m){const b=new Uint8Array(this.data.buffer),T=4*this._idx(o,m);return this.unpack(b[T],b[T+1],b[T+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(o,m){if(o<-1||o>=this.dim+1||m<-1||m>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(m+1)*this.stride+(o+1)}unpack(o,m,b){return o*this.redFactor+m*this.greenFactor+b*this.blueFactor-this.baseShift}getPixels(){return new Ms({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(o,m,b){if(this.dim!==o.dim)throw new Error("dem dimension mismatch");let T=m*this.dim,$=m*this.dim+this.dim,V=b*this.dim,U=b*this.dim+this.dim;switch(m){case-1:T=$-1;break;case 1:$=T+1}switch(b){case-1:V=U-1;break;case 1:U=V+1}const ne=-m*this.dim,me=-b*this.dim;for(let ye=V;ye<U;ye++)for(let Te=T;Te<$;Te++)this.data[this._idx(Te,ye)]=o.data[this._idx(Te+ne,ye+me)]}}jn("DEMData",xw);class _w{constructor(o){this._stringToNumber={},this._numberToString=[];for(let m=0;m<o.length;m++){const b=o[m];this._stringToNumber[b]=m,this._numberToString[m]=b}}encode(o){return this._stringToNumber[o]}decode(o){if(o>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${o} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[o]}}class yw{constructor(o,m,b,T,$){this.type="Feature",this._vectorTileFeature=o,o._z=m,o._x=b,o._y=T,this.properties=o.properties,this.id=$}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(o){this._geometry=o}toJSON(){const o={geometry:this.geometry};for(const m in this)m!=="_geometry"&&m!=="_vectorTileFeature"&&(o[m]=this[m]);return o}}class vw{constructor(o,m){this.tileID=o,this.x=o.canonical.x,this.y=o.canonical.y,this.z=o.canonical.z,this.grid=new jo(Oi,16,0),this.grid3D=new jo(Oi,16,0),this.featureIndexArray=new El,this.promoteId=m}insert(o,m,b,T,$,V){const U=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(b,T,$);const ne=V?this.grid3D:this.grid;for(let me=0;me<m.length;me++){const ye=m[me],Te=[1/0,1/0,-1/0,-1/0];for(let $e=0;$e<ye.length;$e++){const Ye=ye[$e];Te[0]=Math.min(Te[0],Ye.x),Te[1]=Math.min(Te[1],Ye.y),Te[2]=Math.max(Te[2],Ye.x),Te[3]=Math.max(Te[3],Ye.y)}Te[0]<Oi&&Te[1]<Oi&&Te[2]>=0&&Te[3]>=0&&ne.insert(U,Te[0],Te[1],Te[2],Te[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Qa.VectorTile(new nd(this.rawTileData)).layers,this.sourceLayerCoder=new _w(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(o,m,b,T){this.loadVTLayers();const $=o.params||{},V=Oi/o.tileSize/o.scale,U=bn($.filter),ne=o.queryGeometry,me=o.queryPadding*V,ye=jw(ne),Te=this.grid.query(ye.minX-me,ye.minY-me,ye.maxX+me,ye.maxY+me),$e=jw(o.cameraQueryGeometry),Ye=this.grid3D.query($e.minX-me,$e.minY-me,$e.maxX+me,$e.maxY+me,(Tt,Ot,gs,Yt)=>function(ls,Cs,Us,$n,La){for(const kn of ls)if(Cs<=kn.x&&Us<=kn.y&&$n>=kn.x&&La>=kn.y)return!0;const Rn=[new x(Cs,Us),new x(Cs,La),new x($n,La),new x($n,Us)];if(ls.length>2){for(const kn of Rn)if(Xu(ls,kn))return!0}for(let kn=0;kn<ls.length-1;kn++)if(K0(ls[kn],ls[kn+1],Rn))return!0;return!1}(o.cameraQueryGeometry,Tt-me,Ot-me,gs+me,Yt+me));for(const Tt of Ye)Te.push(Tt);Te.sort(ML);const et={};let mt;for(let Tt=0;Tt<Te.length;Tt++){const Ot=Te[Tt];if(Ot===mt)continue;mt=Ot;const gs=this.featureIndexArray.get(Ot);let Yt=null;
1962this.loadMatchingFeature(et,gs.bucketIndex,gs.sourceLayerIndex,gs.featureIndex,U,$.layers,$.availableImages,m,b,T,(ls,Cs,Us)=>(Yt||(Yt=Zh(ls)),Cs.queryIntersectsFeature(ne,ls,Us,Yt,this.z,o.transform,V,o.pixelPosMatrix)))}return et}loadMatchingFeature(o,m,b,T,$,V,U,ne,me,ye,Te){const $e=this.bucketLayerIDs[m];if(V&&!function(Tt,Ot){for(let gs=0;gs<Tt.length;gs++)if(Ot.indexOf(Tt[gs])>=0)return!0;return!1}(V,$e))return;const Ye=this.sourceLayerCoder.decode(b),et=this.vtLayers[Ye].feature(T);if($.needGeometry){const Tt=Wh(et,!0);if(!$.filter(new yi(this.tileID.overscaledZ),Tt,this.tileID.canonical))return}else if(!$.filter(new yi(this.tileID.overscaledZ),et))return;const mt=this.getId(et,Ye);for(let Tt=0;Tt<$e.length;Tt++){const Ot=$e[Tt];if(V&&V.indexOf(Ot)<0)continue;const gs=ne[Ot];if(!gs)continue;let Yt={};mt&&ye&&(Yt=ye.getState(gs.sourceLayer||"_geojsonTileLayer",mt));const ls=H({},me[Ot]);ls.paint=bw(ls.paint,gs.paint,et,Yt,U),ls.layout=bw(ls.layout,gs.layout,et,Yt,U);const Cs=!Te||Te(et,gs,Yt);if(!Cs)continue;const Us=new yw(et,this.z,this.x,this.y,mt);Us.layer=ls;let $n=o[Ot];$n===void 0&&($n=o[Ot]=[]),$n.push({featureIndex:T,feature:Us,intersectionZ:Cs})}}lookupSymbolFeatures(o,m,b,T,$,V,U,ne){const me={};this.loadVTLayers();const ye=bn($);for(const Te of o)this.loadMatchingFeature(me,b,T,Te,ye,V,U,ne,m);return me}hasLayer(o){for(const m of this.bucketLayerIDs)for(const b of m)if(o===b)return!0;return!1}getId(o,m){let b=o.id;return this.promoteId&&(b=o.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[m]],typeof b=="boolean"&&(b=Number(b))),b}}function bw(d,o,m,b,T){return q(d,($,V)=>{const U=o instanceof wo?o.get(V):null;return U&&U.evaluate?U.evaluate(m,b,T):U})}function jw(d){let o=1/0,m=1/0,b=-1/0,T=-1/0;for(const $ of d)o=Math.min(o,$.x),m=Math.min(m,$.y),b=Math.max(b,$.x),T=Math.max(T,$.y);return{minX:o,minY:m,maxX:b,maxY:T}}function ML(d,o){return o-d}function ww(d,o,m,b,T){const $=[];for(let V=0;V<d.length;V++){const U=d[V];let ne;for(let me=0;me<U.length-1;me++){let ye=U[me],Te=U[me+1];ye.x<o&&Te.x<o||(ye.x<o?ye=new x(o,ye.y+(o-ye.x)/(Te.x-ye.x)*(Te.y-ye.y))._round():Te.x<o&&(Te=new x(o,ye.y+(o-ye.x)/(Te.x-ye.x)*(Te.y-ye.y))._round()),ye.y<m&&Te.y<m||(ye.y<m?ye=new x(ye.x+(m-ye.y)/(Te.y-ye.y)*(Te.x-ye.x),m)._round():Te.y<m&&(Te=new x(ye.x+(m-ye.y)/(Te.y-ye.y)*(Te.x-ye.x),m)._round()),ye.x>=b&&Te.x>=b||(ye.x>=b?ye=new x(b,ye.y+(b-ye.x)/(Te.x-ye.x)*(Te.y-ye.y))._round():Te.x>=b&&(Te=new x(b,ye.y+(b-ye.x)/(Te.x-ye.x)*(Te.y-ye.y))._round()),ye.y>=T&&Te.y>=T||(ye.y>
vendor: 10,310 bytes, line 1962
1962=T?ye=new x(ye.x+(T-ye.y)/(Te.y-ye.y)*(Te.x-ye.x),T)._round():Te.y>=T&&(Te=new x(ye.x+(T-ye.y)/(Te.y-ye.y)*(Te.x-ye.x),T)._round()),ne&&ye.equals(ne[ne.length-1])||(ne=[ye],$.push(ne)),ne.push(Te)))))}}return $}jn("FeatureIndex",vw,{omit:["rawTileData","sourceLayerCoder"]});class uf extends x{constructor(o,m,b,T){super(o,m),this.angle=b,T!==void 0&&(this.segment=T)}clone(){return new uf(this.x,this.y,this.angle,this.segment)}}function Nw(d,o,m,b,T){if(o.segment===void 0||m===0)return!0;let $=o,V=o.segment+1,U=0;for(;U>-m/2;){if(V--,V<0)return!1;U-=d[V].dist($),$=d[V]}U+=d[V].dist(d[V+1]),V++;const ne=[];let me=0;for(;U<m/2;){const ye=d[V],Te=d[V+1];if(!Te)return!1;let $e=d[V-1].angleTo(ye)-ye.angleTo(Te);for($e=Math.abs(($e+3*Math.PI)%(2*Math.PI)-Math.PI),ne.push({distance:U,angleDelta:$e}),me+=$e;U-ne[0].distance>b;)me-=ne.shift().angleDelta;if(me>T)return!1;V++,U+=ye.dist(Te)}return!0}function kw(d){let o=0;for(let m=0;m<d.length-1;m++)o+=d[m].dist(d[m+1]);return o}function Cw(d,o,m){return d?.6*o*m:0}function Sw(d,o){return Math.max(d?d.right-d.left:0,o?o.right-o.left:0)}function IL(d,o,m,b,T,$){const V=Cw(m,T,$),U=Sw(m,b)*$;let ne=0;const me=kw(d)/2;for(let ye=0;ye<d.length-1;ye++){const Te=d[ye],$e=d[ye+1],Ye=Te.dist($e);if(ne+Ye>me){const et=(me-ne)/Ye,mt=Zr.number(Te.x,$e.x,et),Tt=Zr.number(Te.y,$e.y,et),Ot=new uf(mt,Tt,$e.angleTo(Te),ye);return Ot._round(),!V||Nw(d,Ot,U,V,o)?Ot:void 0}ne+=Ye}}function AL(d,o,m,b,T,$,V,U,ne){const me=Cw(b,$,V),ye=Sw(b,T),Te=ye*V,$e=d[0].x===0||d[0].x===ne||d[0].y===0||d[0].y===ne;return o-Te<o/4&&(o=Te+o/4),Ew(d,$e?o/2*U%o:(ye/2+2*$)*V*U%o,o,me,m,Te,$e,!1,ne)}function Ew(d,o,m,b,T,$,V,U,ne){const me=$/2,ye=kw(d);let Te=0,$e=o-m,Ye=[];for(let et=0;et<d.length-1;et++){const mt=d[et],Tt=d[et+1],Ot=mt.dist(Tt),gs=Tt.angleTo(mt);for(;$e+m<Te+Ot;){$e+=m;const Yt=($e-Te)/Ot,ls=Zr.number(mt.x,Tt.x,Yt),Cs=Zr.number(mt.y,Tt.y,Yt);if(ls>=0&&ls<ne&&Cs>=0&&Cs<ne&&$e-me>=0&&$e+me<=ye){const Us=new uf(ls,Cs,gs,et);Us._round(),b&&!Nw(d,Us,$,b,T)||Ye.push(Us)}}Te+=Ot}return U||Ye.length||V||(Ye=Ew(d,Te/2,m,b,T,$,V,!0,ne)),Ye}jn("Anchor",uf);const Vp=ol;function Pw(d,o,m,b){const T=[],$=d.image,V=$.pixelRatio,U=$.paddedRect.w-2*Vp,ne=$.paddedRect.h-2*Vp;let me={x1:d.left,y1:d.top,x2:d.right,y2:d.bottom};const ye=$.stretchX||[[0,U]],Te=$.stretchY||[[0,ne]],$e=(Ds,_a)=>Ds+_a[1]-_a[0],Ye=ye.reduce($e,0),et=Te.reduce($e,0),mt=U-Ye,Tt=ne-et;let Ot=0,gs=Ye,Yt=0,ls=et,Cs=0,Us=mt,$n=0,La=Tt;if($.content&&b){const Ds=$.content,_a=Ds[2]-Ds[0],ma=Ds[3]-Ds[1];($.textFitWidth||$.textFitHeight)&&(me=sw(d)),Ot=S_(ye,0,Ds[0]),Yt=S_(Te,0,Ds[1]),gs=S_(ye,Ds[0],Ds[2]),ls=S_(Te,Ds[1],Ds[3]),Cs=Ds[0]-Ot,$n=Ds[1]-Yt,Us=_a-gs,La=ma-ls}const Rn=me.x1,kn=me.y1,ga=me.x2-Rn,ta=me.y2-kn,Yn=(Ds,_a,ma,Xa)=>{const Qi=E_(Ds.stretch-Ot,gs,ga,Rn),Wi=P_(Ds.fixed-Cs,Us,Ds.stretch,Ye),nc=E_(_a.stretch-Yt,ls,ta,kn),sh=P_(_a.fixed-$n,La,_a.stretch,et),$c=E_(ma.stretch-Ot,gs,ga,Rn),ac=P_(ma.fixed-Cs,Us,ma.stretch,Ye),jd=E_(Xa.stretch-Yt,ls,ta,kn),wd=P_(Xa.fixed-$n,La,Xa.stretch,et),Nd=new x(Qi,nc),ll=new x($c,nc),rc=new x($c,jd),rd=new x(Qi,jd),Vc=new x(Wi/V,sh/V),kd=new x(ac/V,wd/V),qc=o*Math.PI/180;if(qc){const pi=Math.sin(qc),io=Math.cos(qc),xo=[io,-pi,pi,io];Nd._matMult(xo),ll._matMult(xo),rd._matMult(xo),rc._matMult(xo)}const Tu=Ds.stretch+Ds.fixed,Bd=_a.stretch+_a.fixed;return{tl:Nd,tr:ll,bl:rd,br:rc,tex:{x:$.paddedRect.x+Vp+Tu,y:$.paddedRect.y+Vp+Bd,w:ma.stretch+ma.fixed-Tu,h:Xa.stretch+Xa.fixed-Bd},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Vc,pixelOffsetBR:kd,minFontScaleX:Us/V/ga,minFontScaleY:La/V/ta,isSDF:m}};if(b&&($.stretchX||$.stretchY)){const Ds=Tw(ye,mt,Ye),_a=Tw(Te,Tt,et);for(let ma=0;ma<Ds.length-1;ma++){const Xa=Ds[ma],Qi=Ds[ma+1];for(let Wi=0;Wi<_a.length-1;Wi++)T.push(Yn(Xa,_a[Wi],Qi,_a[Wi+1]))}}else T.push(Yn({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:U+1},{fixed:0,stretch:ne+1}));return T}function S_(d,o,m){let b=0;for(const T of d)b+=Math.max(o,Math.min(m,T[1]))-Math.max(o,Math.min(m,T[0]));return b}function Tw(d,o,m){const b=[{fixed:-Vp,stretch:0}];for(const[T,$]of d){const V=b[b.length-1];b.push({fixed:T-V.stretch,stretch:V.stretch}),b.push({fixed:T-V.stretch,stretch:V.stretch+($-T)})}return b.push({fixed:o+Vp,stretch:m}),b}function E_(d,o,m,b){return d/o*m+b}function P_(d,o,m,b){return d-o*m/b}class T_{constructor(o,m,b,T,$,V,U,ne,me,ye){var Te;if(this.boxStartIndex=o.length,me){let $e=V.top,Ye=V.bottom;const et=V.collisionPadding;et&&($e-=et[1],Ye+=et[3]);let mt=Ye-$e;mt>0&&(mt=Math.max(10,mt),this.circleDiameter=mt)}else{const $e=!((Te=V.image)===null||Te===void 0)&&Te.content&&(V.image.textFitWidth||V.image.textFitHeight)?sw(V):{x1:V.left,y1:V.top,x2:V.right,y2:V.bottom};$e.y1=$e.y1*U-ne[0],$e.y2=$e.y2*U+ne[2],$e.x1=$e.x1*U-ne[3],$e.x2=$e.x2*U+ne[1];const Ye=V.collisionPadding;if(Ye&&($e.x1-=Ye[0]*U,$e.y1-=Ye[1]*U,$e.x2+=Ye[2]*U,$e.y2+=Ye[3]*U),ye){const et=new x($e.x1,$e.y1),mt=new x($e.x2,$e.y1),Tt=new x($e.x1,$e.y2),Ot=new x($e.x2,$e.y2),gs=ye*Math.PI/180;et._rotate(gs),mt._rotate(gs),Tt._rotate(gs),Ot._rotate(gs),$e.x1=Math.min(et.x,mt.x,Tt.x,Ot.x),$e.x2=Math.max(et.x,mt.x,Tt.x,Ot.x),$e.y1=Math.min(et.y,mt.y,Tt.y,Ot.y),$e.y2=Math.max(et.y,mt.y,Tt.y,Ot.y)}o.emplaceBack(m.x,m.y,$e.x1,$e.y1,$e.x2,$e.y2,b,T,$)}this.boxEndIndex=o.length}}class DL{constructor(o=[],m=(b,T)=>b<T?-1:b>T?1:0){if(this.data=o,this.length=this.data.length,this.compare=m,this.length>0)for(let b=(this.length>>1)-1;b>=0;b--)this._down(b)}push(o){this.data.push(o),this._up(this.length++)}pop(){if(this.length===0)return;const o=this.data[0],m=this.data.pop();return--this.length>0&&(this.data[0]=m,this._down(0)),o}peek(){return this.data[0]}_up(o){const{data:m,compare:b}=this,T=m[o];for(;o>0;){const $=o-1>>1,V=m[$];if(b(T,V)>=0)break;m[o]=V,o=$}m[o]=T}_down(o){const{data:m,compare:b}=this,T=this.length>>1,$=m[o];for(;o<T;){let V=1+(o<<1);const U=V+1;if(U<this.length&&b(m[U],m[V])<0&&(V=U),b(m[V],$)>=0)break;m[o]=m[V],o=V}m[o]=$}}function RL(d,o=1,m=!1){let b=1/0,T=1/0,$=-1/0,V=-1/0;const U=d[0];for(let Ye=0;Ye<U.length;Ye++){const et=U[Ye];(!Ye||et.x<b)&&(b=et.x),(!Ye||et.y<T)&&(T=et.y),(!Ye||et.x>$)&&($=et.x),(!Ye||et.y>V)&&(V=et.y)}const ne=Math.min($-b,V-T);let me=ne/2;const ye=new DL([],FL);if(ne===0)return new x(b,T);for(let Ye=b;Ye<$;Ye+=ne)for(let et=T;et<V;et+=ne)ye.push(new qp(Ye+me,et+me,me,d));let Te=function(Ye){let et=0,mt=0,Tt=0;const Ot=Ye[0];for(let gs=0,Yt=Ot.length,ls=Yt-1;gs<Yt;ls=gs++){const Cs=Ot[gs],Us=Ot[ls],$n=Cs.x*Us.y-Us.x*Cs.y;mt+=(Cs.x+Us.x)*$n,Tt+=(Cs.y+Us.y)*$n,et+=3*$n}return new qp(mt/et,Tt/et,0,Ye)}(d),$e=ye.length;for(;ye.length;){const Ye=ye.pop();(Ye.d>Te.d||!Te.d)&&(Te=Ye,m&&console.log("found best %d after %d probes",Math.round(1e4*Ye.d)/1e4,$e)),Ye.max-Te.d<=o||(me=Ye.h/2,ye.push(new qp(Ye.p.x-me,Ye.p.y-me,me,d)),ye.push(new qp(Ye.p.x+me,Ye.p.y-me,me,d)),ye.push(new qp(Ye.p.x-me,Ye.p.y+me,me,d)),ye.push(new qp(Ye.p.x+me,Ye.p.y+me,me,d)),$e+=4)}return m&&(console.log(`num probes: ${$e}`),console.log(`best distance: ${Te.d}`)),Te.p}function FL(d,o){return o.max-d.max}function qp(d,o,m,b){this.p=new x(d,o),this.h=m,this.d=function(T,$){let V=!1,U=1/0;for(let ne=0;ne<$.length;ne++){const me=$[ne];for(let ye=0,Te=me.length,$e=Te-1;ye<Te;$e=ye++){const Ye=me[ye],et=me[$e];Ye.y>T.y!=et.y>T.y&&T.x<(et.x-Ye.x)*(T.y-Ye.y)/(et.y-Ye.y)+Ye.x&&(V=!V),U=Math.min(U,Ip(T,Ye,et))}}return(V?1:-1)*Math.sqrt(U)}(this.p,b),this.max=this.d+this.h*Math.SQRT2}var Bc;u.aq=void 0,(Bc=u.aq||(u.aq={}))[Bc.center=1]="center",Bc[Bc.left=2]="left",Bc[Bc.right=3]="right",Bc[Bc.top=4]="top",Bc[Bc.bottom=5]="bottom",Bc[Bc["top-left"]=6]="top-left",Bc[Bc["top-right"]=7]="top-right",Bc[Bc["bottom-left"]=8]="bottom-left",Bc[Bc["bottom-right"]=9]="bottom-right";const hf=7,uv=Number.POSITIVE_INFINITY;function Lw(d,o){return o[1]!==uv?function(m,b,T){let $=0,V=0;switch(b=Math.abs(b),T=Math.abs(T),m){case"top-right":case"top-left":case"top":V=T-hf;break;case"bottom-right":case"bottom-left":case"bottom":V=-T+hf}switch(m){case"top-right":case"bottom-right":case"right":$=-b;break;case"top-left":case"bottom-left":case"left":$=b}return[$,V]}(d,o[0],o[1]):function(m,b){let T=0,$=0;b<0&&(b=0);const V=b/Math.SQRT2;switch(m){case"top-right":case"top-left":$=V-hf;break;case"bottom-right":case"bottom-left":$=-V+hf;break;case"bottom":$=-b+hf;break;case"top":$=b-hf}switch(m){case"top-right":case"bottom-right":T=-V;break;case"top-left":case"bottom-left":T=V;break;case"left":T=b;break;case"right":T=-b}return[T,$]}(d,o[0])}function Mw(d,o,m){var b;const T=d.layout,$=(b=T.get("text-variable-anchor-offset"))===null||b===void 0?void 0:b.evaluate(o,{},m);if($){const U=$.values,ne=[];for(let me=0;me<U.length;me+=2){const ye=ne[me]=U[me],Te=U[me+1].map($e=>$e*ii);ye.startsWith("top")?Te[1]-=hf:ye.startsWith("bottom")&&(Te[1]+=hf),ne[me+1]=Te}return new ra(ne)}const V=T.get("text-variable-anchor");if(V){let U;U=d._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[T.get("text-radial-offset").evaluate(o,{},m)*ii,uv]:T.get("text-offset").evaluate(o,{},m).map(me=>me*ii);const ne=[];for(const me of V)ne.push(me,Lw(me,U));return new ra(ne)}return null}function hv(d){switch(d){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function zL(d,o,m,b,T,$,V,U,ne,me,ye){let Te=$.textMaxSize.evaluate(o,{});Te===void 0&&(Te=V);const $e=d.layers[0].layout,Ye=$e.get("icon-offset").evaluate(o,{},ye),et=Aw(m.horizontal),mt=V/24,Tt=d.tilePixelRatio*mt,Ot=d.tilePixelRatio*Te/24,gs=d.tilePixelRatio*U,Yt=d.tilePixelRatio*$e.get("symbol-spacing"),ls=$e.get("text-padding")*d.tilePixelRatio,Cs=function(Ds,_a,ma,Xa=1){const Qi=Ds.get("icon-padding").evaluate(_a,{},ma),Wi=Qi&&Qi.values;return[Wi[0]*Xa,Wi[1]*Xa,Wi[2]*Xa,Wi[3]*Xa]}($e,o,ye,d.tilePixelRatio),Us=$e.get("text-max-angle")/180*Math.PI,$n=$e.get("text-rotation-alignment")!=="viewport"&&$e.get("symbol-placement")!=="point",La=$e.get("icon-rotation-alignment")==="map"&&$e.get("symbol-placement")!=="point",Rn=$e.get("symbol-placement"),kn=Yt/2,ga=$e.get("icon-text-fit");let ta;b&&ga!=="none"&&(d.allowVerticalPlacement&&m.vertical&&(ta=nw(b,m.vertical,ga,$e.get("icon-text-fit-padding"),Ye,mt)),et&&(b=nw(b,et,ga,$e.get("icon-text-fit-padding"),Ye,mt)));const Yn=(Ds,_a)=>{_a.x<0||_a.x>=Oi||_a.y<0||_a.y>
vendor: 2,219 bytes, line 1962
1962=Oi||function(ma,Xa,Qi,Wi,nc,sh,$c,ac,jd,wd,Nd,ll,rc,rd,Vc,kd,qc,Tu,Bd,pi,io,xo,ru,Wo,Gp){const Jh=ma.addToLineVertexArray(Xa,Qi);let Qh,nh,Lu,yc,Em=0,nx=0,zw=0,Ow=0,vv=-1,bv=-1;const Pm={};let Bw=bm("");if(ma.allowVerticalPlacement&&Wi.vertical){const id=ac.layout.get("text-rotate").evaluate(io,{},Wo)+90;Lu=new T_(jd,Xa,wd,Nd,ll,Wi.vertical,rc,rd,Vc,id),$c&&(yc=new T_(jd,Xa,wd,Nd,ll,$c,qc,Tu,Vc,id))}if(nc){const id=ac.layout.get("icon-rotate").evaluate(io,{}),Mu=ac.layout.get("icon-text-fit")!=="none",Qf=Pw(nc,id,ru,Mu),Ph=$c?Pw($c,id,ru,Mu):void 0;nh=new T_(jd,Xa,wd,Nd,ll,nc,qc,Tu,!1,id),Em=4*Qf.length;const Uf=ma.iconSizeData;let Uh=null;Uf.kind==="source"?(Uh=[Kh*ac.layout.get("icon-size").evaluate(io,{})],Uh[0]>cf&&oe(`${ma.layerIds[0]}: Value for "icon-size" is >= ${Qg}. Reduce your "icon-size".`)):Uf.kind==="composite"&&(Uh=[Kh*xo.compositeIconSizes[0].evaluate(io,{},Wo),Kh*xo.compositeIconSizes[1].evaluate(io,{},Wo)],(Uh[0]>cf||Uh[1]>cf)&&oe(`${ma.layerIds[0]}: Value for "icon-size" is >= ${Qg}. Reduce your "icon-size".`)),ma.addSymbols(ma.icon,Qf,Uh,pi,Bd,io,u.ah.none,Xa,Jh.lineStartIndex,Jh.lineLength,-1,Wo),vv=ma.icon.placedSymbolArray.length-1,Ph&&(nx=4*Ph.length,ma.addSymbols(ma.icon,Ph,Uh,pi,Bd,io,u.ah.vertical,Xa,Jh.lineStartIndex,Jh.lineLength,-1,Wo),bv=ma.icon.placedSymbolArray.length-1)}const $w=Object.keys(Wi.horizontal);for(const id of $w){const Mu=Wi.horizontal[id];if(!Qh){Bw=bm(Mu.text);const Ph=ac.layout.get("text-rotate").evaluate(io,{},Wo);Qh=new T_(jd,Xa,wd,Nd,ll,Mu,rc,rd,Vc,Ph)}const Qf=Mu.positionedLines.length===1;if(zw+=Iw(ma,Xa,Mu,sh,ac,Vc,io,kd,Jh,Wi.vertical?u.ah.horizontal:u.ah.horizontalOnly,Qf?$w:[id],Pm,vv,xo,Wo),Qf)break}Wi.vertical&&(Ow+=Iw(ma,Xa,Wi.vertical,sh,ac,Vc,io,kd,Jh,u.ah.vertical,["vertical"],Pm,bv,xo,Wo));const $L=Qh?Qh.boxStartIndex:ma.collisionBoxArray.length,VL=Qh?Qh.boxEndIndex:ma.collisionBoxArray.length,qL=Lu?Lu.boxStartIndex:ma.collisionBoxArray.length,GL=Lu?Lu.boxEndIndex:ma.collisionBoxArray.length,HL=nh?nh.boxStartIndex:ma.collisionBoxArray.length,ZL=nh?nh.boxEndIndex:ma.collisionBoxArray.length,WL=yc?yc.boxStartIndex:ma.collisionBoxArray.length,YL=yc?yc.boxEndIndex:ma.collisionBoxArray.length;let Eh=-1;const M_=(id,Mu)=>
1962id&&id.circleDiameter?Math.max(id.circleDiameter,Mu):Mu;Eh=M_(Qh,Eh),Eh=M_(Lu,Eh),Eh=M_(nh,Eh),Eh=M_(yc,Eh);const Vw=Eh>-1?1:0;Vw&&(Eh*=Gp/ii),ma.glyphOffsetArray.length>=$p.MAX_GLYPHS&&oe("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),io.sortKey!==void 0&&ma.addToSortKeyRanges(ma.symbolInstances.length,io.sortKey);const XL=Mw(ac,io,Wo),[KL,JL]=function(id,Mu){const Qf=id.length,Ph=Mu==null?void 0:Mu.values;if((Ph==null?void 0:Ph.length)>0)for(let Uf=0;Uf<Ph.length;Uf+=2){const Uh=Ph[Uf+1];id.emplaceBack(u.aq[Ph[Uf]],Uh[0],Uh[1])}return[Qf,id.length]}(ma.textAnchorOffsets,XL);ma.symbolInstances.emplaceBack(Xa.x,Xa.y,Pm.right>=0?Pm.right:-1,Pm.center>=0?Pm.center:-1,Pm.left>=0?Pm.left:-1,Pm.vertical||-1,vv,bv,Bw,$L,VL,qL,GL,HL,ZL,WL,YL,wd,zw,Ow,Em,nx,Vw,0,rc,Eh,KL,JL)}(d,_a,Ds,m,b,T,ta,d.layers[0],d.collisionBoxArray,o.index,o.sourceLayerIndex,d.index,Tt,[ls,ls,ls,ls],$n,ne,gs,Cs,La,Ye,o,$,me,ye,V)};if(Rn==="line")for(const Ds of ww(o.geometry,0,0,Oi,Oi)){const _a=AL(Ds,Yt,Us,m.vertical||et,b,24,Ot,d.overscaling,Oi);for(const ma of _a)et&&OL(d,et.text,kn,ma)||Yn(Ds,ma)}else if(Rn==="line-center"){for(const Ds of o.geometry)if(Ds.length>1){const _a=IL(Ds,Us,m.vertical||et,b,24,Ot);_a&&Yn(Ds,_a)}}else if(o.type==="Polygon")for(const Ds of hi(o.geometry,0)){const _a=RL(Ds,16);Yn(Ds[0],new uf(_a.x,_a.y,0))}else if(o.type==="LineString")for(const Ds of o.geometry)Yn(Ds,new uf(Ds[0].x,Ds[0].y,0));else if(o.type==="Point")for(const Ds of o.geometry)for(const _a of Ds)Yn([_a],new uf(_a.x,_a.y,0))}function Iw(d,o,m,b,T,$,V,U,ne,me,ye,Te,$e,Ye,et){const mt=function(gs,Yt,ls,Cs,Us,$n,La,Rn){const kn=Cs.layout.get("text-rotate").evaluate($n,{})*Math.PI/180,ga=[];for(const ta of Yt.positionedLines)for(const Yn of ta.positionedGlyphs){if(!Yn.rect)continue;const Ds=Yn.rect||{};let _a=th+1,ma=!0,Xa=1,Qi=0;const Wi=(Us||Rn)&&Yn.vertical,nc=Yn.metrics.advance*Yn.scale/2;if(Rn&&Yt.verticalizable&&(Qi=ta.lineOffset/2-(Yn.imageName?-(ii-Yn.metrics.width*Yn.scale)/2:(Yn.scale-1)*ii)),Yn.imageName){const pi=La[Yn.imageName];ma=pi.sdf,Xa=pi.pixelRatio,_a=ol/Xa}const sh=Us?[Yn.x+nc,Yn.y]:[0,0];let $c=Us?[0,0]:[Yn.x+nc+ls[0],Yn.y+ls[1]-Qi],ac=[0,0];Wi&&(ac=$c,$c=[0,0]);const jd=Yn.metrics.isDoubleResolution?2:1,wd=(Yn.metrics.left-_a)*Yn.scale-nc+$c[0],Nd=(-Yn.metrics.top-_a)*Yn.scale+$c[1],ll=wd+Ds.w/jd*Yn.scale/Xa,rc=Nd+Ds.h/jd*Yn.scale/Xa,rd=new x(wd,Nd),Vc=new x(ll,Nd),kd=new x(wd,rc),qc=new x(ll,rc);if(Wi){const pi=new x(-nc,nc-Kg),io=-Math.PI/2,xo=ii/2-nc,ru=new x(5-Kg-xo,-(Yn.imageName?xo:0)),Wo=new x(...ac);rd._rotateAround(io,pi)._add(ru)._add(Wo),Vc._rotateAround(io,pi)._add(ru)._add(Wo),kd._rotateAround(io,pi)._add(ru)._add(Wo),qc._rotateAround(io,pi)._add(ru)._add(Wo)}if(kn){const pi=Math.sin(kn),io=Math.cos(kn),xo=[io,-pi,pi,io];rd._matMult(xo),Vc._matMult(xo),kd._matMult(xo),qc._matMult(xo)}const Tu=new x(0,0),Bd=new x(0,0);ga.push({tl:rd,tr:Vc,bl:kd,br:qc,tex:Ds,writingMode:Yt.writingMode,glyphOffset:sh,sectionIndex:Yn.sectionIndex,isSDF:ma,pixelOffsetTL:Tu,pixelOffsetBR:Bd,minFontScaleX:0,minFontScaleY:0})}return ga}(0,m,U,T,$,V,b,d.allowVerticalPlacement),Tt=d.textSizeData;let Ot=null;Tt.kind==="source"?(Ot=[Kh*T.layout.get("text-size").evaluate(V,{})],Ot[0]>cf&&oe(`${d.layerIds[0]}: Value for "text-size" is >= ${Qg}. Reduce your "text-size".`)):Tt.kind==="composite"&&(Ot=[Kh*Ye.compositeTextSizes[0].evaluate(V,{},et),Kh*Ye.compositeTextSizes[1].evaluate(V,{},et)],(Ot[0]>cf||Ot[1]>cf)&&oe(`${d.layerIds[0]}: Value for "text-size" is >= ${Qg}. Reduce your "text-size".`)),d.addSymbols(d.text,mt,Ot,U,$,V,me,o,ne.lineStartIndex,ne.lineLength,$e,et);for(const gs of ye)Te[gs]=d.text.placedSymbolArray.length-1;return 4*mt.length}function Aw(d){for(const o in d)return d[o];return null}function OL(d,o,m,b){const T=d.compareText;if(o in T){const $=T[o];for(let V=$.length-1;V>=0;V--)if(b.dist($[V])<m)return!0}else T[o]=[];return T[o].push(b),!1}const Dw=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class mv{static from(o){if(!(o instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[m,b]=new Uint8Array(o,0,2);
vendor: 23,184 bytes, line 1962
1962if(m!==219)throw new Error("Data does not appear to be in a KDBush format.");const T=b>>4;if(T!==1)throw new Error(`Got v${T} data when expected v1.`);const $=Dw[15&b];if(!$)throw new Error("Unrecognized array type.");const[V]=new Uint16Array(o,2,1),[U]=new Uint32Array(o,4,1);return new mv(U,V,$,o)}constructor(o,m=64,b=Float64Array,T){if(isNaN(o)||o<0)throw new Error(`Unpexpected numItems value: ${o}.`);this.numItems=+o,this.nodeSize=Math.min(Math.max(+m,2),65535),this.ArrayType=b,this.IndexArrayType=o<65536?Uint16Array:Uint32Array;const $=Dw.indexOf(this.ArrayType),V=2*o*this.ArrayType.BYTES_PER_ELEMENT,U=o*this.IndexArrayType.BYTES_PER_ELEMENT,ne=(8-U%8)%8;if($<0)throw new Error(`Unexpected typed array class: ${b}.`);T&&T instanceof ArrayBuffer?(this.data=T,this.ids=new this.IndexArrayType(this.data,8,o),this.coords=new this.ArrayType(this.data,8+U+ne,2*o),this._pos=2*o,this._finished=!0):(this.data=new ArrayBuffer(8+V+U+ne),this.ids=new this.IndexArrayType(this.data,8,o),this.coords=new this.ArrayType(this.data,8+U+ne,2*o),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+$]),new Uint16Array(this.data,2,1)[0]=m,new Uint32Array(this.data,4,1)[0]=o)}add(o,m){const b=this._pos>>1;return this.ids[b]=b,this.coords[this._pos++]=o,this.coords[this._pos++]=m,b}finish(){const o=this._pos>>1;if(o!==this.numItems)throw new Error(`Added ${o} items when expected ${this.numItems}.`);return fv(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(o,m,b,T){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:$,coords:V,nodeSize:U}=this,ne=[0,$.length-1,0],me=[];for(;ne.length;){const ye=ne.pop()||0,Te=ne.pop()||0,$e=ne.pop()||0;if(Te-$e<=U){for(let Tt=$e;Tt<=Te;Tt++){const Ot=V[2*Tt],gs=V[2*Tt+1];Ot>=o&&Ot<=b&&gs>=m&&gs<=T&&me.push($[Tt])}continue}const Ye=$e+Te>>1,et=V[2*Ye],mt=V[2*Ye+1];et>=o&&et<=b&&mt>=m&&mt<=T&&me.push($[Ye]),(ye===0?o<=et:m<=mt)&&(ne.push($e),ne.push(Ye-1),ne.push(1-ye)),(ye===0?b>=et:T>=mt)&&(ne.push(Ye+1),ne.push(Te),ne.push(1-ye))}return me}within(o,m,b){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:T,coords:$,nodeSize:V}=this,U=[0,T.length-1,0],ne=[],me=b*b;for(;U.length;){const ye=U.pop()||0,Te=U.pop()||0,$e=U.pop()||0;if(Te-$e<=V){for(let Tt=$e;Tt<=Te;Tt++)Fw($[2*Tt],$[2*Tt+1],o,m)<=me&&ne.push(T[Tt]);continue}const Ye=$e+Te>>1,et=$[2*Ye],mt=$[2*Ye+1];Fw(et,mt,o,m)<=me&&ne.push(T[Ye]),(ye===0?o-b<=et:m-b<=mt)&&(U.push($e),U.push(Ye-1),U.push(1-ye)),(ye===0?o+b>=et:m+b>=mt)&&(U.push(Ye+1),U.push(Te),U.push(1-ye))}return ne}}function fv(d,o,m,b,T,$){if(T-b<=m)return;const V=b+T>>1;Rw(d,o,V,b,T,$),fv(d,o,m,b,V-1,1-$),fv(d,o,m,V+1,T,1-$)}function Rw(d,o,m,b,T,$){for(;T>b;){if(T-b>600){const me=T-b+1,ye=m-b+1,Te=Math.log(me),$e=.5*Math.exp(2*Te/3),Ye=.5*Math.sqrt(Te*$e*(me-$e)/me)*(ye-me/2<0?-1:1);Rw(d,o,m,Math.max(b,Math.floor(m-ye*$e/me+Ye)),Math.min(T,Math.floor(m+(me-ye)*$e/me+Ye)),$)}const V=o[2*m+$];let U=b,ne=T;for(tx(d,o,b,m),o[2*T+$]>V&&tx(d,o,b,T);U<ne;){for(tx(d,o,U,ne),U++,ne--;o[2*U+$]<V;)U++;for(;o[2*ne+$]>V;)ne--}o[2*b+$]===V?tx(d,o,b,ne):(ne++,tx(d,o,ne,T)),ne<=m&&(b=ne+1),m<=ne&&(T=ne-1)}}function tx(d,o,m,b){pv(d,m,b),pv(o,2*m,2*b),pv(o,2*m+1,2*b+1)}function pv(d,o,m){const b=d[o];d[o]=d[m],d[m]=b}function Fw(d,o,m,b){const T=d-m,$=o-b;return T*T+$*$}var gv;u.bg=void 0,(gv=u.bg||(u.bg={})).create="create",gv.load="load",gv.fullLoad="fullLoad";let L_=null,sx=[];const xv=1e3/60,_v="loadTime",yv="fullLoadTime",BL={mark(d){performance.mark(d)},frame(d){const o=d;L_!=null&&sx.push(o-L_),L_=o},clearMetrics(){L_=null,sx=[],performance.clearMeasures(_v),performance.clearMeasures(yv);for(const d in u.bg)performance.clearMarks(u.bg[d])},getPerformanceMetrics(){performance.measure(_v,u.bg.create,u.bg.load),performance.measure(yv,u.bg.create,u.bg.fullLoad);const d=performance.getEntriesByName(_v)[0].duration,o=performance.getEntriesByName(yv)[0].duration,m=sx.length,b=1/(sx.reduce(($,V)=>$+V,0)/m/1e3),T=sx.filter($=>$>xv).reduce(($,V)=>$+(V-xv)/xv,0);return{loadTime:d,fullLoadTime:o,fps:b,percentDroppedFrames:T/(m+T)*100,totalFrames:m}}};u.$=class extends Ie{},u.A=km,u.B=yr,u.C=function(d){if(ie==null){const o=d.navigator?d.navigator.userAgent:null;ie=!!d.safari||!(!o||!(/\b(iPad|iPhone|iPod)\b/.test(o)||o.match("Safari")&&!o.match("Chrome")))}return ie},u.D=ea,u.E=_t,u.F=class{constructor(d,o){this.target=d,this.mapId=o,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new LL(()=>this.process()),this.subscription=function(m,b,T,$){return m.addEventListener(b,T,!1),{unsubscribe:()=>{m.removeEventListener(b,T,!1)}}}(this.target,"message",m=>this.receive(m)),this.globalScope=ae(self)?d:window}registerMessageHandler(d,o){this.messageHandlers[d]=o}sendAsync(d,o){return new Promise((m,b)=>{const T=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[T]={resolve:m,reject:b},o&&o.signal.addEventListener("abort",()=>{delete this.resolveRejects[T];const U={id:T,type:"<cancel>",origin:location.origin,targetMapId:d.targetMapId,sourceMapId:this.mapId};this.target.postMessage(U)},{once:!0});const $=[],V=Object.assign(Object.assign({},d),{id:T,sourceMapId:this.mapId,origin:location.origin,data:Uc(d.data,$)});this.target.postMessage(V,{transfer:$})})}receive(d){const o=d.data,m=o.id;if(!(o.origin!=="file://"&&location.origin!=="file://"&&o.origin!=="resource://android"&&location.origin!=="resource://android"&&o.origin!==location.origin||o.targetMapId&&this.mapId!==o.targetMapId)){if(o.type==="<cancel>"){delete this.tasks[m];const b=this.abortControllers[m];return delete this.abortControllers[m],void(b&&b.abort())}if(ae(self)||o.mustQueue)return this.tasks[m]=o,this.taskQueue.push(m),void this.invoker.trigger();this.processTask(m,o)}}process(){if(this.taskQueue.length===0)return;const d=this.taskQueue.shift(),o=this.tasks[d];delete this.tasks[d],this.taskQueue.length>0&&this.invoker.trigger(),o&&this.processTask(d,o)}processTask(d,o){return i(this,void 0,void 0,function*(){if(o.type==="<response>"){const T=this.resolveRejects[d];return delete this.resolveRejects[d],T?void(o.error?T.reject(Dc(o.error)):T.resolve(Dc(o.data))):void 0}if(!this.messageHandlers[o.type])return void this.completeTask(d,new Error(`Could not find a registered handler for ${o.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const m=Dc(o.data),b=new AbortController;this.abortControllers[d]=b;try{const T=yield this.messageHandlers[o.type](o.sourceMapId,m,b);this.completeTask(d,null,T)}catch(T){this.completeTask(d,T)}})}completeTask(d,o,m){const b=[];delete this.abortControllers[d];const T={id:d,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:o?Uc(o):null,data:Uc(m,b)};this.target.postMessage(T,{transfer:b})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},u.G=Ke,u.H=function(){var d=new km(16);return km!=Float32Array&&(d[1]=0,d[2]=0,d[3]=0,d[4]=0,d[6]=0,d[7]=0,d[8]=0,d[9]=0,d[11]=0,d[12]=0,d[13]=0,d[14]=0),d[0]=1,d[5]=1,d[10]=1,d[15]=1,d},u.I=Xg,u.J=function(d,o,m){var b,T,$,V,U,ne,me,ye,Te,$e,Ye,et,mt=m[0],Tt=m[1],Ot=m[2];return o===d?(d[12]=o[0]*mt+o[4]*Tt+o[8]*Ot+o[12],d[13]=o[1]*mt+o[5]*Tt+o[9]*Ot+o[13],d[14]=o[2]*mt+o[6]*Tt+o[10]*Ot+o[14],d[15]=o[3]*mt+o[7]*Tt+o[11]*Ot+o[15]):(T=o[1],$=o[2],V=o[3],U=o[4],ne=o[5],me=o[6],ye=o[7],Te=o[8],$e=o[9],Ye=o[10],et=o[11],d[0]=b=o[0],d[1]=T,d[2]=$,d[3]=V,d[4]=U,d[5]=ne,d[6]=me,d[7]=ye,d[8]=Te,d[9]=$e,d[10]=Ye,d[11]=et,d[12]=b*mt+U*Tt+Te*Ot+o[12],d[13]=T*mt+ne*Tt+$e*Ot+o[13],d[14]=$*mt+me*Tt+Ye*Ot+o[14],d[15]=V*mt+ye*Tt+et*Ot+o[15]),d},u.K=function(d,o,m){var b=m[0],T=m[1],$=m[2];return d[0]=o[0]*b,d[1]=o[1]*b,d[2]=o[2]*b,d[3]=o[3]*b,d[4]=o[4]*T,d[5]=o[5]*T,d[6]=o[6]*T,d[7]=o[7]*T,d[8]=o[8]*$,d[9]=o[9]*$,d[10]=o[10]*$,d[11]=o[11]*$,d[12]=o[12],d[13]=o[13],d[14]=o[14],d[15]=o[15],d},u.L=Oe,u.M=function(d,o){const m={};for(let b=0;b<o.length;b++){const T=o[b];T in d&&(m[T]=d[T])}return m},u.N=df,u.O=hw,u.P=x,u.Q=mw,u.R=Ms,u.S=Pu,u.T=$h,u.U=F,u.V=D,u.W=We,u.X=Oi,u.Y=ee,u.Z=Ug,u._=i,u.a=ke,u.a$=function(d,o){var m=d[0],b=d[1],T=d[2],$=d[3],V=d[4],U=d[5],ne=d[6],me=d[7],ye=d[8],Te=d[9],$e=d[10],Ye=d[11],et=d[12],mt=d[13],Tt=d[14],Ot=d[15],gs=o[0],Yt=o[1],ls=o[2],Cs=o[3],Us=o[4],$n=o[5],La=o[6],Rn=o[7],kn=o[8],ga=o[9],ta=o[10],Yn=o[11],Ds=o[12],_a=o[13],ma=o[14],Xa=o[15];return Math.abs(m-gs)<=pc*Math.max(1,Math.abs(m),Math.abs(gs))&&Math.abs(b-Yt)<=pc*Math.max(1,Math.abs(b),Math.abs(Yt))&&Math.abs(T-ls)<=pc*Math.max(1,Math.abs(T),Math.abs(ls))&&Math.abs($-Cs)<=pc*Math.max(1,Math.abs($),Math.abs(Cs))&&Math.abs(V-Us)<=pc*Math.max(1,Math.abs(V),Math.abs(Us))&&Math.abs(U-$n)<=pc*Math.max(1,Math.abs(U),Math.abs($n))&&Math.abs(ne-La)<=pc*Math.max(1,Math.abs(ne),Math.abs(La))&&Math.abs(me-Rn)<=pc*Math.max(1,Math.abs(me),Math.abs(Rn))&&Math.abs(ye-kn)<=pc*Math.max(1,Math.abs(ye),Math.abs(kn))&&Math.abs(Te-ga)<=pc*Math.max(1,Math.abs(Te),Math.abs(ga))&&Math.abs($e-ta)<=pc*Math.max(1,Math.abs($e),Math.abs(ta))&&Math.abs(Ye-Yn)<=pc*Math.max(1,Math.abs(Ye),Math.abs(Yn))&&Math.abs(et-Ds)<=pc*Math.max(1,Math.abs(et),Math.abs(Ds))&&Math.abs(mt-_a)<=pc*Math.max(1,Math.abs(mt),Math.abs(_a))&&Math.abs(Tt-ma)<=pc*Math.max(1,Math.abs(Tt),Math.abs(ma))&&Math.abs(Ot-Xa)<=pc*Math.max(1,Math.abs(Ot),Math.abs(Xa))},u.a0=qr,u.a1=dv,u.a2=$t,u.a3=d=>{const o=window.document.createElement("video");return o.muted=!0,new Promise(m=>{o.onloadstart=()=>{m(o)};for(const b of d){const T=window.document.createElement("source");ft(b)||(o.crossOrigin="Anonymous"),T.src=b,o.appendChild(T)}})},u.a4=function(){return O++},u.a5=Nn,u.a6=$p,u.a7=bn,u.a8=Wh,u.a9=yw,u.aA=function(d){if(d.type==="custom")return new TL(d);switch(d.type){case"background":return new SL(d);case"circle":return new yt(d);case"fill":return new ao(d);case"fill-extrusion":return new fa(d);case"heatmap":return new ka(d);case"hillshade":return new Ga(d);case"line":return new il(d);case"raster":return new PL(d);case"symbol":return new C_(d)}},u.aB=Q,u.aC=function(d,o){if(!d)return[{command:"setStyle",args:[o]}];let m=[];try{if(!Xe(d.version,o.version))return[{command:"setStyle",args:[o]}];Xe(d.center,o.center)||m.push({command:"setCenter",args:[o.center]}),Xe(d.zoom,o.zoom)||m.push({command:"setZoom",args:[o.zoom]}),Xe(d.bearing,o.bearing)||m.push({command:"setBearing",args:[o.bearing]}),Xe(d.pitch,o.pitch)||m.push({command:"setPitch",args:[o.pitch]}),Xe(d.sprite,o.sprite)||m.push({command:"setSprite",args:[o.sprite]}),Xe(d.glyphs,o.glyphs)||m.push({command:"setGlyphs",args:[o.glyphs]}),Xe(d.transition,o.transition)||m.push({command:"setTransition",args:[o.transition]}),Xe(d.light,o.light)||m.push({command:"setLight",args:[o.light]}),Xe(d.terrain,o.terrain)||m.push({command:"setTerrain",args:[o.terrain]}),Xe(d.sky,o.sky)||m.push({command:"setSky",args:[o.sky]}),Xe(d.projection,o.projection)||m.push({command:"setProjection",args:[o.projection]});const b={},T=[];(function(V,U,ne,me){let ye;for(ye in U=U||{},V=V||{})Object.prototype.hasOwnProperty.call(V,ye)&&(Object.prototype.hasOwnProperty.call(U,ye)||Dt(ye,ne,me));for(ye in U)Object.prototype.hasOwnProperty.call(U,ye)&&(Object.prototype.hasOwnProperty.call(V,ye)?Xe(V[ye],U[ye])||(V[ye].type==="geojson"&&U[ye].type==="geojson"&&zt(V,U,ye)?Ce(ne,{command:"setGeoJSONSourceData",args:[ye,U[ye].data]}):Rt(ye,U,ne,me)):Be(ye,U,ne))})(d.sources,o.sources,T,b);const $=[];d.layers&&d.layers.forEach(V=>{"source"in V&&b[V.source]?m.push({command:"removeLayer",args:[V.id]}):$.push(V)}),m=m.concat(T),function(V,U,ne){U=U||[];const me=(V=V||[]).map(_s),ye=U.map(_s),Te=V.reduce(vs,{}),$e=U.reduce(vs,{}),Ye=me.slice(),et=Object.create(null);let mt,Tt,Ot,gs,Yt;for(let ls=0,Cs=0;ls<me.length;ls++)mt=me[ls],Object.prototype.hasOwnProperty.call($e,mt)?Cs++:(Ce(ne,{command:"removeLayer",args:[mt]}),Ye.splice(Ye.indexOf(mt,Cs),1));for(let ls=0,Cs=0;ls<ye.length;ls++)mt=ye[ye.length-1-ls],Ye[Ye.length-1-ls]!==mt&&(Object.prototype.hasOwnProperty.call(Te,mt)?(Ce(ne,{command:"removeLayer",args:[mt]}),Ye.splice(Ye.lastIndexOf(mt,Ye.length-Cs),1)):Cs++,gs=Ye[Ye.length-ls],Ce(ne,{command:"addLayer",args:[$e[mt],gs]}),Ye.splice(Ye.length-ls,0,mt),et[mt]=!0);for(let ls=0;ls<ye.length;ls++)if(mt=ye[ls],Tt=Te[mt],Ot=$e[mt],!et[mt]&&!Xe(Tt,Ot))if(Xe(Tt.source,Ot.source)&&Xe(Tt["source-layer"],Ot["source-layer"])&&Xe(Tt.type,Ot.type)){for(Yt in rs(Tt.layout,Ot.layout,ne,mt,null,"setLayoutProperty"),rs(Tt.paint,Ot.paint,ne,mt,null,"setPaintProperty"),Xe(Tt.filter,Ot.filter)||Ce(ne,{command:"setFilter",args:[mt,Ot.filter]}),Xe(Tt.minzoom,Ot.minzoom)&&Xe(Tt.maxzoom,Ot.maxzoom)||Ce(ne,{command:"setLayerZoomRange",args:[mt,Ot.minzoom,Ot.maxzoom]}),Tt)Object.prototype.hasOwnProperty.call(Tt,Yt)&&Yt!=="layout"&&Yt!=="paint"&&Yt!=="filter"&&Yt!=="metadata"&&Yt!=="minzoom"&&Yt!=="maxzoom"&&(Yt.indexOf("paint.")===0?rs(Tt[Yt],Ot[Yt],ne,mt,Yt.slice(6),"setPaintProperty"):Xe(Tt[Yt],Ot[Yt])||Ce(ne,{command:"setLayerProperty",args:[mt,Yt,Ot[Yt]]}));for(Yt in Ot)Object.prototype.hasOwnProperty.call(Ot,Yt)&&!Object.prototype.hasOwnProperty.call(Tt,Yt)&&Yt!=="layout"&&Yt!=="paint"&&Yt!=="filter"&&Yt!=="metadata"&&Yt!=="minzoom"&&Yt!=="maxzoom"&&(Yt.indexOf("paint.")===0?rs(Tt[Yt],Ot[Yt],ne,mt,Yt.slice(6),"setPaintProperty"):Xe(Tt[Yt],Ot[Yt])||Ce(ne,{command:"setLayerProperty",args:[mt,Yt,Ot[Yt]]}))}else Ce(ne,{command:"removeLayer",args:[mt]}),gs=Ye[Ye.lastIndexOf(mt)+1],Ce(ne,{command:"addLayer",args:[Ot,gs]})}($,o.layers,m)}catch(b){console.warn("Unable to compute style diff:",b),m=[{command:"setStyle",args:[o]}]}return m},u.aD=function(d){const o=[],m=d.id;return m===void 0&&o.push({message:`layers.${m}: missing required property "id"`}),d.render===void 0&&o.push({message:`layers.${m}: missing required method "render"`}),d.renderingMode&&d.renderingMode!=="2d"&&d.renderingMode!=="3d"&&o.push({message:`layers.${m}: property "renderingMode" must be either "2d" or "3d"`}),o},u.aE=function d(o,m){if(Array.isArray(o)){if(!Array.isArray(m)||o.length!==m.length)return!1;for(let b=0;b<o.length;b++)if(!d(o[b],m[b]))return!1;return!0}if(typeof o=="object"&&o!==null&&m!==null){if(typeof m!="object"||Object.keys(o).length!==Object.keys(m).length)return!1;for(const b in o)if(!d(o[b],m[b]))return!1;return!0}return o===m},u.aF=q,u.aG=W,u.aH=class extends Zu{constructor(d,o){super(d,o),this.current=0}set(d){this.current!==d&&(this.current=d,this.gl.uniform1i(this.location,d))}},u.aI=Wu,u.aJ=class extends Zu{constructor(d,o){super(d,o),this.current=bd}set(d){if(d[12]!==this.current[12]||d[0]!==this.current[0])return this.current=d,void this.gl.uniformMatrix4fv(this.location,!1,d);for(let o=1;o<16;o++)if(d[o]!==this.current[o]){this.current=d,this.gl.uniformMatrix4fv(this.location,!1,d);break}}},u.aK=X0,u.aL=Qm,u.aM=An,u.aN=class extends Zu{constructor(d,o){super(d,o),this.current=[0,0,0]}set(d){d[0]===this.current[0]&&d[1]===this.current[1]&&d[2]===this.current[2]||(this.current=d,this.gl.uniform3f(this.location,d[0],d[1],d[2]))}},u.aO=class extends Zu{constructor(d,o){super(d,o),this.current=[0,0]}set(d){d[0]===this.current[0]&&d[1]===this.current[1]||(this.current=d,this.gl.uniform2f(this.location,d[0],d[1]))}},u.aP=function(d,o,m,b,T,$,V){var U=1/(o-m),ne=1/(b-T),me=1/($-V);return d[0]=-2*U,d[1]=0,d[2]=0,d[3]=0,d[4]=0,d[5]=-2*ne,d[6]=0,d[7]=0,d[8]=0,d[9]=0,d[10]=2*me,d[11]=0,d[12]=(o+m)*U,d[13]=(T+b)*ne,d[14]=(V+$)*me,d[15]=1,d},u.aQ=pt,u.aR=class extends Kt{},u.aS=tc,u.aT=class extends cs{},u.aU=Vn,u.aV=function(d){return d<=1?1:Math.pow(2,Math.ceil(Math.log(d)/Math.LN2))},u.aW=hn,u.aX=Ql,u.aY=Rc,u.aZ=class extends Hn{},u.a_=function(d,o){return d[0]===o[0]&&d[1]===o[1]&&d[2]===o[2]&&d[3]===o[3]&&d[4]===o[4]&&d[5]===o[5]&&d[6]===o[6]&&d[7]===o[7]&&d[8]===o[8]&&d[9]===o[9]&&d[10]===o[10]&&d[11]===o[11]&&d[12]===o[12]&&d[13]===o[13]&&d[14]===o[14]&&d[15]===o[15]},u.aa=function(d){const o={};if(d.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(m,b,T,$)=>{const V=T||$;return o[b]=!V||V.toLowerCase(),""}),o["max-age"]){const m=parseInt(o["max-age"],10);isNaN(m)?delete o["max-age"]:o["max-age"]=m}return o},u.ab=function(d,o){const m=[];for(const b in d)b in o||m.push(b);return m},u.ac=te,u.ad=function(d,o,m){var b=Math.sin(m),T=Math.cos(m),$=o[0],V=o[1],U=o[2],ne=o[3],me=o[4],ye=o[5],Te=o[6],$e=o[7];return o!==d&&(d[8]=o[8],d[9]=o[9],d[10]=o[10],d[11]=o[11],d[12]=o[12],d[13]=o[13],d[14]=o[14],d[15]=o[15]),d[0]=$*T+me*b,d[1]=V*T+ye*b,d[2]=U*T+Te*b,d[3]=ne*T+$e*b,d[4]=me*T-$*b,d[5]=ye*T-V*b,d[6]=Te*T-U*b,d[7]=$e*T-ne*b,d},u.ae=function(d){var o=new km(16);return o[0]=d[0],o[1]=d[1],o[2]=d[2],o[3]=d[3],o[4]=d[4],o[5]=d[5],o[6]=d[6],o[7]=d[7],o[8]=d[8],o[9]=d[9],o[10]=d[10],o[11]=d[11],o[12]=d[12],o[13]=d[13],o[14]=d[14],o[15]=d[15],o},u.af=It,u.ag=function(d,o){let m=0,b=0;if(d.kind==="constant")b=d.layoutSize;else if(d.kind!=="source"){const{interpolationType:T,minZoom:$,maxZoom:V}=d,U=T?te(Gi.interpolationFactor(T,o,$,V),0,1):0;d.kind==="camera"?b=Zr.number(d.minSize,d.maxSize,U):m=U}return{uSizeT:m,uSize:b}},u.ai=function(d,{uSize:o,uSizeT:m},{lowerSize:b,upperSize:T}){return d.kind==="source"?b/Kh:d.kind==="composite"?Zr.number(b/Kh,T/Kh,m):o},u.aj=av,u.ak=function(d,o,m,b){const T=o.y-d.y,$=o.x-d.x,V=b.y-m.y,U=b.x-m.x,ne=V*$-U*T;if(ne===0)return null;const me=(U*(d.y-m.y)-V*(d.x-m.x))/ne;return new x(d.x+me*$,d.y+me*T)},u.al=ww,u.am=wm,u.an=Ne,u.ao=function(d){let o=1/0,m=1/0,b=-1/0,T=-1/0;for(const $ of d)o=Math.min(o,$.x),m=Math.min(m,$.y),b=Math.max(b,$.x),T=Math.max(T,$.y);return[o,m,b,T]},u.ap=ii,u.ar=nv,u.as=function(d,o){var m=o[0],b=o[1],T=o[2],$=o[3],V=o[4],U=o[5],ne=o[6],me=o[7],ye=o[8],Te=o[9],$e=o[10],Ye=o[11],et=o[12],mt=o[13],Tt=o[14],Ot=o[15],gs=m*U-b*V,Yt=m*ne-T*V,ls=m*me-$*V,Cs=b*ne-T*U,Us=b*me-$*U,$n=T*me-$*ne,La=ye*mt-Te*et,Rn=ye*Tt-$e*et,kn=ye*Ot-Ye*et,ga=Te*Tt-$e*mt,ta=Te*Ot-Ye*mt,Yn=$e*Ot-Ye*Tt,Ds=gs*Yn-Yt*ta+ls*ga+Cs*kn-Us*Rn+$n*La;return Ds?(d[0]=(U*Yn-ne*ta+me*ga)*(Ds=1/Ds),d[1]=(T*ta-b*Yn-$*ga)*Ds,d[2]=(mt*$n-Tt*Us+Ot*Cs)*Ds,d[3]=($e*Us-Te*$n-Ye*Cs)*Ds,d[4]=(ne*kn-V*Yn-me*Rn)*Ds,d[5]=(m*Yn-T*kn+$*Rn)*Ds,d[6]=(Tt*ls-et*$n-Ot*Yt)*Ds,d[7]=(ye*$n-$e*ls+Ye*Yt)*Ds,d[8]=(V*ta-U*kn+me*La)*Ds,d[9]=(b*kn-m*ta-$*La)*Ds,d[10]=(et*Us-mt*ls+Ot*gs)*Ds,d[11]=(Te*ls-ye*Us-Ye*gs)*Ds,d[12]=(U*Rn-V*ga-ne*La)*Ds,d[13]=(m*ga-b*Rn+T*La)*Ds,d[14]=(mt*Yt-et*Cs-Tt*gs)*Ds,d[15]=(ye*Cs-Te*Yt+$e*gs)*Ds,d):null},u.at=hv,u.au=sv,u.av=mv,u.aw=function(){const d={},o=He.$version;for(const m in He.$root){const b=He.$root[m];if(b.required){let T=null;T=m==="version"?o:b.type==="array"?[]:{},T!=null&&(d[m]=T)}}return d},u.ax=fo,u.ay=Re,u.az=function(d){d=d.slice();const o=Object.create(null);for(let m=0;m<d.length;m++)o[d[m].id]=d[m];for(let m=0;m<d.length;m++)"ref"in d[m]&&(d[m]=vt(d[m],o[d[m].ref]));return d},u.b=de,u.b0=function(d,o){return d[0]=o[0],d[1]=o[1],d[2]=o[2],d[3]=o[3],d[4]=o[4],d[5]=o[5],d[6]=o[6],d[7]=o[7],d[8]=o[8],d[9]=o[9],d[10]=o[10],d[11]=o[11],d[12]=o[12],d[13]=o[13],d[14]=o[14],d[15]=o[15],d},u.b1=function(d,o,m){return d[0]=o[0]*m[0],d[1]=o[1]*m[1],d[2]=o[2]*m[2],d[3]=o[3]*m[3],d},u.b2=function(d,o){return d[0]*o[0]+d[1]*o[1]+d[2]*o[2]+d[3]*o[3]},u.b3=J,u.b4=gw,u.b5=fw,u.b6=function(d,o,m,b,T){var $,V=1/Math.tan(o/2);return d[0]=V/m,d[1]=0,d[2]=0,d[3]=0,d[4]=0,d[5]=V,d[6]=0,d[7]=0,d[8]=0,d[9]=0,d[11]=-1,d[12]=0,d[13]=0,d[15]=0,T!=null&&T!==1/0?(d[10]=(T+b)*($=1/(b-T)),d[14]=2*T*b*$):(d[10]=-1,d[14]=-2*b),d},u.b7=function(d,o,m){var b=Math.sin(m),T=Math.cos(m),$=o[4],V=o[5],U=o[6],ne=o[7],me=o[8],ye=o[9],Te=o[10],$e=o[11];return o!==d&&(d[0]=o[0],d[1]=o[1],d[2]=o[2],d[3]=o[3],d[12]=o[12],d[13]=o[13],d[14]=o[14],d[15]=o[15]),d[4]=$*T+me*b,d[5]=V*T+ye*b,d[6]=U*T+Te*b,d[7]=ne*T+$e*b,d[8]=me*T-$*b,d[9]=ye*T-V*b,d[10]=Te*T-U*b,d[11]=$e*T-ne*b,d},u.b8=X,u.b9=K,u.bA=vr,u.bB=function(d){return d.message===we},u.bC=re,u.bD=no,u.ba=function(d){return d*Math.PI/180},u.bb=function(d,o){const{x:m,y:b}=Ug.fromLngLat(o);return!(d<0||d>25||b<0||b>=1||m<0||m>=1)},u.bc=function(d,o){return d[0]=o[0],d[1]=0,d[2]=0,d[3]=0,d[4]=0,d[5]=o[1],d[6]=0,d[7]=0,d[8]=0,d[9]=0,d[10]=o[2],d[11]=0,d[12]=0,d[13]=0,d[14]=0,d[15]=1,d},u.bd=class extends _e{},u.be=lv,u.bf=BL,u.bh=dt,u.bi=function(d,o){ke.REGISTERED_PROTOCOLS[d]=o},u.bj=function(d){delete ke.REGISTERED_PROTOCOLS[d]},u.bk=function(d,o){const m={};for(let T=0;T<d.length;T++){const $=o&&o[d[T].id]||Ud(d[T]);o&&(o[d[T].id]=$);let V=m[$];V||(V=m[$]=[]),V.push(d[T])}const b=[];for(const T in m)b.push(m[T]);return b},u.bl=jn,u.bm=_w,u.bn=vw,u.bo=j_,u.bp=function(d){d.bucket.createArrays(),d.bucket.tilePixelRatio=Oi/(512*d.bucket.overscaling),d.bucket.compareText={},d.bucket.iconsNeedLinear=!1;const o=d.bucket.layers[0],m=o.layout,b=o._unevaluatedLayout._values,T={layoutIconSize:b["icon-size"].possiblyEvaluate(new yi(d.bucket.zoom+1),d.canonical),layoutTextSize:b["text-size"].possiblyEvaluate(new yi(d.bucket.zoom+1),d.canonical),textMaxSize:b["text-size"].possiblyEvaluate(new yi(18))};if(d.bucket.textSizeData.kind==="composite"){const{minZoom:me,maxZoom:ye}=d.bucket.textSizeData;T.compositeTextSizes=[b["text-size"].possiblyEvaluate(new yi(me),d.canonical),b["text-size"].possiblyEvaluate(new yi(ye),d.canonical)]}if(d.bucket.iconSizeData.kind==="composite"){const{minZoom:me,maxZoom:ye}=d.bucket.iconSizeData;T.compositeIconSizes=[b["icon-size"].possiblyEvaluate(new yi(me),d.canonical),b["icon-size"].possiblyEvaluate(new yi(ye),d.canonical)]}const $=m.get("text-line-height")*ii,V=m.get("text-rotation-alignment")!=="viewport"&&m.get("symbol-placement")!=="point",U=m.get("text-keep-upright"),ne=m.get("text-size");for(const me of d.bucket.features){const ye=m.get("text-font").evaluate(me,{},d.canonical).join(","),Te=ne.evaluate(me,{},d.canonical),$e=T.layoutTextSize.evaluate(me,{},d.canonical),Ye=T.layoutIconSize.evaluate(me,{},d.canonical),et={horizontal:{},vertical:void 0},mt=me.text;let Tt,Ot=[0,0];if(mt){const ls=mt.toString(),Cs=m.get("text-letter-spacing").evaluate(me,{},d.canonical)*ii,Us=_h(ls)?Cs:0,$n=m.get("text-anchor").evaluate(me,{},d.canonical),La=Mw(o,me,d.canonical);if(!La){const ta=m.get("text-radial-offset").evaluate(me,{},d.canonical);Ot=ta?Lw($n,[ta*ii,uv]):m.get("text-offset").evaluate(me,{},d.canonical).map(Yn=>Yn*ii)}let Rn=V?"center":m.get("text-justify").evaluate(me,{},d.canonical);const kn=m.get("symbol-placement")==="point"?m.get("text-max-width").evaluate(me,{},d.canonical)*ii:1/0,ga=()=>{d.bucket.allowVerticalPlacement&&vm(ls)&&(et.vertical=w_(mt,d.glyphMap,d.glyphPositions,d.imagePositions,ye,kn,$,$n,"left",Us,Ot,u.ah.vertical,!0,$e,Te))};if(!V&&La){const ta=new Set;if(Rn==="auto")for(let Ds=0;Ds<La.values.length;Ds+=2)ta.add(hv(La.values[Ds]));else ta.add(Rn);let Yn=!1;for(const Ds of ta)if(!et.horizontal[Ds])if(Yn)et.horizontal[Ds]=et.horizontal[0];else{const _a=w_(mt,d.glyphMap,d.glyphPositions,d.imagePositions,ye,kn,$,"center",Ds,Us,Ot,u.ah.horizontal,!1,$e,Te);_a&&(et.horizontal[Ds]=_a,Yn=_a.positionedLines.length===1)}ga()}else{Rn==="auto"&&(Rn=hv($n));const ta=w_(mt,d.glyphMap,d.glyphPositions,d.imagePositions,ye,kn,$,$
1962n,Rn,Us,Ot,u.ah.horizontal,!1,$e,Te);ta&&(et.horizontal[Rn]=ta),ga(),vm(ls)&&V&&U&&(et.vertical=w_(mt,d.glyphMap,d.glyphPositions,d.imagePositions,ye,kn,$,$n,Rn,Us,Ot,u.ah.vertical,!1,$e,Te))}}let gs=!1;if(me.icon&&me.icon.name){const ls=d.imageMap[me.icon.name];ls&&(Tt=jL(d.imagePositions[me.icon.name],m.get("icon-offset").evaluate(me,{},d.canonical),m.get("icon-anchor").evaluate(me,{},d.canonical)),gs=!!ls.sdf,d.bucket.sdfIcons===void 0?d.bucket.sdfIcons=gs:d.bucket.sdfIcons!==gs&&oe("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(ls.pixelRatio!==d.bucket.pixelRatio||m.get("icon-rotate").constantOr(1)!==0)&&(d.bucket.iconsNeedLinear=!0))}const Yt=Aw(et.horizontal)||et.vertical;d.bucket.iconsInText=!!Yt&&Yt.iconsInText,(Yt||Tt)&&zL(d.bucket,me,et,Tt,d.imageMap,T,$e,Ye,Ot,gs,d.canonical)}d.showCollisionBoxes&&d.bucket.generateCollisionDebugBuffers()},u.bq=ha,u.br=ua,u.bs=Cm,u.bt=Qa,u.bu=nd,u.bv=class{constructor(d){this._marks={start:[d.url,"start"].join("#"),end:[d.url,"end"].join("#"),measure:d.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let d=performance.getEntriesByName(this._marks.measure);return d.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),d=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),d}},u.bw=function(d,o,m,b,T){return i(this,void 0,void 0,function*(){if(D())try{return yield We(d,o,m,b,T)}catch{}return function($,V,U,ne,me){const ye=$.width,Te=$.height;Ee&&ve||(Ee=new OffscreenCanvas(ye,Te),ve=Ee.getContext("2d",{willReadFrequently:!0})),Ee.width=ye,Ee.height=Te,ve.drawImage($,0,0,ye,Te);const $e=ve.getImageData(V,U,ne,me);return ve.clearRect(0,0,ye,Te),$e.data}(d,o,m,b,T)})},u.bx=xw,u.by=_,u.bz=j,u.c=Ze,u.d=d=>i(void 0,void 0,void 0,function*(){if(d.byteLength===0)return createImageBitmap(new ImageData(1,1));const o=new Blob([new Uint8Array(d)],{type:"image/png"});try{return createImageBitmap(o)}catch(m){throw new Error(`Could not load image because of ${m.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),u.e=H,u.f=d=>new Promise((o,m)=>{const b=new Image;b.onload=()=>{o(b),URL.revokeObjectURL(b.src),b.onload=null,window.requestAnimationFrame(()=>{b.src=ge})},b.onerror=()=>m(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const T=new Blob([new Uint8Array(d)],{type:"image/png"});b.src=d.byteLength?URL.createObjectURL(T):ge}),u.g=ze,u.h=(d,o)=>qt(H(d,{type:"json"}),o),u.i=ae,u.j=ht,u.k=Qe,u.l=(d,o)=>qt(H(d,{type:"arrayBuffer"}),o),u.m=qt,u.n=function(d){return new nd(d).readFields(Zo,[])},u.o=Ss,u.p=ad,u.q=R,u.r=Ta,u.s=ft,u.t=zi,u.u=_n,u.v=He,u.w=oe,u.x=function([d,o,m]){return o+=90,o*=Math.PI/180,m*=Math.PI/180,{x:d*Math.cos(o)*Math.sin(m),y:d*Math.sin(o)*Math.sin(m),z:d*Math.cos(m)}},u.y=Zr,u.z=yi}),l("worker",["./shared"],function(u){class i{constructor(Pe){this.keyCache={},Pe&&this.replace(Pe)}replace(Pe){this._layerConfigs={},this._layers={},this.update(Pe,[])}update(Pe,je){for(const De of Pe){this._layerConfigs[De.id]=De;const bt=this._layers[De.id]=u.aA(De);bt._featureFilter=u.a7(bt.filter),this.keyCache[De.id]&&delete this.keyCache[De.id]}for(const De of je)delete this.keyCache[De],delete this._layerConfigs[De],delete this._layers[De];this.familiesBySource={};const Ge=u.bk(Object.values(this._layerConfigs),this.keyCache);for(const De of Ge){const bt=De.map(es=>this._layers[es.id]),Ct=bt[0];if(Ct.visibility==="none")continue;const pe=Ct.source||"";let wt=this.familiesBySource[pe];wt||(wt=this.familiesBySource[pe]={});const Zt=Ct.sourceLayer||"_geojsonTileLayer";let ys=wt[Zt];ys||(ys=wt[Zt]=[]),ys.push(bt)}}}class _{constructor(Pe){const je={},Ge=[];for(const pe in Pe){const wt=Pe[pe],Zt=je[pe]={};for(const ys in wt){const es=wt[+ys];if(!es||es.bitmap.width===0||es.bitmap.height===0)continue;const is={x:0,y:0,w:es.bitmap.width+2,h:es.bitmap.height+2};Ge.push(is),Zt[ys]={rect:is,metrics:es.metrics}}}const{w:De,h:bt}=u.p(Ge),Ct=new u.o({width:De||1,height:bt||1});for(const pe in Pe){const wt=Pe[pe];for(const Zt in wt){const ys=wt[+Zt];if(!ys||ys.bitmap.width===0||ys.bitmap.height===0)continue;const es=je[pe][Zt].rect;u.o.copy(ys.bitmap,Ct,{x:0,y:0},{x:es.x+1,y:es.y+1},ys.bitmap)}}this.image=Ct,this.positions=je}}u.bl("GlyphAtlas",_);class j{constructor(Pe){this.tileID=new u.S(Pe.tileID.overscaledZ,Pe.tileID.wrap,Pe.tileID.canonical.z,Pe.tileID.canonical.x,Pe.tileID.canonical.y),this.uid=Pe.uid,this.zoom=Pe.zoom,this.pixelRatio=Pe.pixelRatio,this.tileSize=Pe.tileSize,this.source=Pe.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=Pe.showCollisionBoxes,this.collectResourceTiming=!!Pe.collectResourceTiming,this.returnDependencies=!!Pe.returnDependencies,this.promoteId=Pe.promoteId,this.inFlightDependencies=[]}parse(Pe,je,Ge,De){return u._(this,void 0,void 0,function*(){this.status="parsing",this.data=Pe,this.collisionBoxArray=new u.a5;const bt=new u.bm(Object.keys(Pe.layers).sort()),Ct=new u.bn(this.tileID,this.promoteId);Ct.bucketLayerIDs=[];const pe={},wt={featureIndex:Ct,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:Ge},Zt=je.familiesBySource[this.source];for(const Qs in Zt){const Pn=Pe.layers[Qs];if(!Pn)continue;Pn.version===1&&u.w(`Vector tile source "${this.source}" layer "${Qs}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const Ks=bt.encode(Qs),xa=[];for(let Fn=0;Fn<Pn.length;Fn++){const Sa=Pn.feature(Fn),sr=Ct.getId(Sa,Qs);xa.push({feature:Sa,id:sr,index:Fn,sourceLayerIndex:Ks})}for(const Fn of Zt[Qs]){const Sa=Fn[0];Sa.source!==this.source&&u.w(`layer.source = ${Sa.source} does not equal this.source = ${this.source}`),Sa.minzoom&&this.zoom<Math.floor(Sa.minzoom)||Sa.maxzoom&&this.zoom>=Sa.maxzoom||Sa.visibility!=="none"&&(y(Fn,this.zoom,Ge),(pe[Sa.id]=Sa.createBucket({index:Ct.bucketLayerIDs.length,layers:Fn,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Ks,sourceID:this.source}
1962)).populate(xa,wt,this.tileID.canonical),Ct.bucketLayerIDs.push(Fn.map(sr=>sr.id)))}}const ys=u.aF(wt.glyphDependencies,Qs=>Object.keys(Qs).map(Number));this.inFlightDependencies.forEach(Qs=>Qs==null?void 0:Qs.abort()),this.inFlightDependencies=[];let es=Promise.resolve({});if(Object.keys(ys).length){const Qs=new AbortController;this.inFlightDependencies.push(Qs),es=De.sendAsync({type:"GG",data:{stacks:ys,source:this.source,tileID:this.tileID,type:"glyphs"}},Qs)}const is=Object.keys(wt.iconDependencies);let Ws=Promise.resolve({});if(is.length){const Qs=new AbortController;this.inFlightDependencies.push(Qs),Ws=De.sendAsync({type:"GI",data:{icons:is,source:this.source,tileID:this.tileID,type:"icons"}},Qs)}const an=Object.keys(wt.patternDependencies);let ya=Promise.resolve({});if(an.length){const Qs=new AbortController;this.inFlightDependencies.push(Qs),ya=De.sendAsync({type:"GI",data:{icons:an,source:this.source,tileID:this.tileID,type:"patterns"}},Qs)}const[Hs,xt,os]=yield Promise.all([es,Ws,ya]),Ls=new _(Hs),Es=new u.bo(xt,os);for(const Qs in pe){const Pn=pe[Qs];Pn instanceof u.a6?(y(Pn.layers,this.zoom,Ge),u.bp({bucket:Pn,glyphMap:Hs,glyphPositions:Ls.positions,imageMap:xt,imagePositions:Es.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):Pn.hasPattern&&(Pn instanceof u.bq||Pn instanceof u.br||Pn instanceof u.bs)&&(y(Pn.layers,this.zoom,Ge),Pn.addFeatures(wt,this.tileID.canonical,Es.patternPositions))}return this.status="done",{buckets:Object.values(pe).filter(Qs=>!Qs.isEmpty()),featureIndex:Ct,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Ls.image,imageAtlas:Es,glyphMap:this.returnDependencies?Hs:null,iconMap:this.returnDependencies?xt:null,glyphPositions:this.returnDependencies?Ls.positions:null}})}}function y(Ue,Pe,je){const Ge=new u.z(Pe);for(const De of Ue)De.recalculate(Ge,je)}class x{constructor(Pe,je,Ge){this.actor=Pe,this.layerIndex=je,this.availableImages=Ge,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(Pe,je){return u._(this,void 0,void 0,function*(){const Ge=yield u.l(Pe.request,je);try{return{vectorTile:new u.bt.VectorTile(new u.bu(Ge.data)),rawData:Ge.data,cacheControl:Ge.cacheControl,expires:Ge.expires}}catch(De){const bt=new Uint8Array(Ge.data);let Ct=`Unable to parse the tile at ${Pe.request.url}, `;throw Ct+=bt[0]===31&&bt[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${De.message}`,new Error(Ct)}})}loadTile(Pe){return u._(this,void 0,void 0,function*(){const je=Pe.uid,Ge=!!(Pe&&Pe.request&&Pe.request.collectResourceTiming)&&new u.bv(Pe.request),De=new j(Pe);this.loading[je]=De;const bt=new AbortController;De.abort=bt;try{const Ct=yield this.loadVectorTile(Pe,bt);if(delete this.loading[je],!Ct)return null;const pe=Ct.rawData,wt={};Ct.expires&&(wt.expires=Ct.expires),Ct.cacheControl&&(wt.cacheControl=Ct.cacheControl);const Zt={};if(Ge){const es=Ge.finish();es&&(Zt.resourceTiming=JSON.parse(JSON.stringify(es)))}De.vectorTile=Ct.vectorTile;const ys=De.parse(Ct.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[je]=De,this.fetching[je]={rawTileData:pe,cacheControl:wt,resourceTiming:Zt};try{const es=yield ys;return u.e({rawTileData:pe.slice(0)},es,wt,Zt)}finally{delete this.fetching[je]}}catch(Ct){throw delete this.loading[je],De.status="done",this.loaded[je]=De,Ct}})}reloadTile(Pe){return u._(this,void 0,void 0,function*(){const je=Pe.uid;if(!this.loaded||!this.loaded[je])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const Ge=this.loaded[je];if(Ge.showCollisionBoxes=Pe.showCollisionBoxes,Ge.status==="parsing"){const De=yield Ge.parse(Ge.vectorTile,this.layerIndex,this.availableImages,this.actor);let bt;if(this.fetching[je]){const{rawTileData:Ct,cacheControl:pe,resourceTiming:wt}=this.fetching[je];delete this.fetching[je],bt=u.e({rawTileData:Ct.slice(0)},De,pe,wt)}else bt=De;return bt}if(Ge.status==="done"&&Ge.vectorTile)return Ge.parse(Ge.vectorTile,this.layerIndex,this.availableImages,this.actor)})}abortTile(Pe){return u._(this,void 0,void 0,function*(){const je=this.loading,Ge=Pe.uid;je&&je[Ge]&&je[Ge].abort&&(je[Ge].abort.abort(),delete je[Ge])})}removeTile(Pe){return u._(this,void 0,void 0,function*(){this.loaded&&this.loaded[Pe.uid]&&delete this.loaded[Pe.uid]})}}class v{constructor(){this.loaded={}}loadTile(Pe){return u._(this,void 0,void 0,function*(){const{uid:je,encoding:Ge,rawImageData:De,redFactor:bt,greenFactor:Ct,blueFactor:pe,baseShift:wt}=Pe,Zt=De.width+2,ys=De.height+2,es=u.b(De)?new u.R({width:Zt,height:ys},yield u.bw(De,-1,-1,Zt,ys)):De,is=new u.bx(je,es,Ge,bt,Ct,pe,wt);return this.loaded=this.loaded||{},this.loaded[je]=is,is})}removeTile(Pe){const je=this.loaded,Ge=Pe.uid;je&&je[Ge]&&delete je[Ge]}}function C(Ue,Pe){if(Ue.length!==0){P(Ue[0],Pe);for(var je=1;
1962je<Ue.length;je++)P(Ue[je],!Pe)}}function P(Ue,Pe){for(var je=0,Ge=0,De=0,bt=Ue.length,Ct=bt-1;De<bt;Ct=De++){var pe=(Ue[De][0]-Ue[Ct][0])*(Ue[Ct][1]+Ue[De][1]),wt=je+pe;Ge+=Math.abs(je)>=Math.abs(pe)?je-wt+pe:pe-wt+je,je=wt}je+Ge>=0!=!!Pe&&Ue.reverse()}var I=u.by(function Ue(Pe,je){var Ge,De=Pe&&Pe.type;if(De==="FeatureCollection")for(Ge=0;Ge<Pe.features.length;Ge++)Ue(Pe.features[Ge],je);else if(De==="GeometryCollection")for(Ge=0;Ge<Pe.geometries.length;Ge++)Ue(Pe.geometries[Ge],je);else if(De==="Feature")Ue(Pe.geometry,je);else if(De==="Polygon")C(Pe.coordinates,je);else if(De==="MultiPolygon")for(Ge=0;Ge<Pe.coordinates.length;Ge++)C(Pe.coordinates[Ge],je);return Pe});const z=u.bt.VectorTileFeature.prototype.toGeoJSON;var F={exports:{}},D=u.bz,X=u.bt.VectorTileFeature,K=te;function te(Ue,Pe){this.options=Pe||{},this.features=Ue,this.length=Ue.length}function J(Ue,Pe){this.id=typeof Ue.id=="number"?Ue.id:void 0,this.type=Ue.type,this.rawGeometry=Ue.type===1?[Ue.geometry]:Ue.geometry,this.properties=Ue.tags,this.extent=Pe||4096}te.prototype.feature=function(Ue){return new J(this.features[Ue],this.options.extent)},J.prototype.loadGeometry=function(){var Ue=this.rawGeometry;this.geometry=[];for(var Pe=0;Pe<Ue.length;Pe++){for(var je=Ue[Pe],Ge=[],De=0;De<je.length;De++)Ge.push(new D(je[De][0],je[De][1]));this.geometry.push(Ge)}return this.geometry},J.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var Ue=this.geometry,Pe=1/0,je=-1/0,Ge=1/0,De=-1/0,bt=0;bt<Ue.length;bt++)for(var Ct=Ue[bt],pe=0;pe<Ct.length;pe++){var wt=Ct[pe];Pe=Math.min(Pe,wt.x),je=Math.max(je,wt.x),Ge=Math.min(Ge,wt.y),De=Math.max(De,wt.y)}return[Pe,Ge,je,De]},J.prototype.toGeoJSON=X.prototype.toGeoJSON;var H=u.bA,O=K;function q(Ue){var Pe=new H;return function(je,Ge){for(var De in je.layers)Ge.writeMessage(3,W,je.layers[De])}(Ue,Pe),Pe.finish()}function W(Ue,Pe){var je;Pe.writeVarintField(15,Ue.version||1),Pe.writeStringField(1,Ue.name||""),Pe.writeVarintField(5,Ue.extent||4096);var Ge={keys:[],values:[],keycache:{},valuecache:{}};for(je=0;je<Ue.length;je++)Ge.feature=Ue.feature(je),Pe.writeMessage(2,Q,Ge);var De=Ge.keys;for(je=0;je<De.length;je++)Pe.writeStringField(3,De[je]);var bt=Ge.values;for(je=0;je<bt.length;je++)Pe.writeMessage(4,ie,bt[je])}function Q(Ue,Pe){var je=Ue.feature;je.id!==void 0&&Pe.writeVarintField(1,je.id),Pe.writeMessage(2,Z,Ue),Pe.writeVarintField(3,je.type),Pe.writeMessage(4,ae,je)}function Z(Ue,Pe){var je=Ue.feature,Ge=Ue.keys,De=Ue.values,bt=Ue.keycache,Ct=Ue.valuecache;for(var pe in je.properties){var wt=je.properties[pe],Zt=bt[pe];if(wt!==null){Zt===void 0&&(Ge.push(pe),bt[pe]=Zt=Ge.length-1),Pe.writeVarint(Zt);var ys=typeof wt;ys!=="string"&&ys!=="boolean"&&ys!=="number"&&(wt=JSON.stringify(wt));var es=ys+":"+wt,is=Ct[es];is===void 0&&(De.push(wt),Ct[es]=is=De.length-1),Pe.writeVarint(is)}}}function oe(Ue,Pe){return(Pe<<3)+(7&Ue)}function ce(Ue){return Ue<<1^Ue>>31}function ae(Ue,Pe){for(var je=Ue.loadGeometry(),Ge=Ue.type,De=0,bt=0,Ct=je.length,pe=0;pe<Ct;pe++){var wt=je[pe],Zt=1;Ge===1&&(Zt=wt.length),Pe.writeVarint(oe(1,Zt));for(var ys=Ge===3?wt.length-1:wt.length,es=0;es<ys;es++){es===1&&Ge!==1&&Pe.writeVarint(oe(2,ys-1));var is=wt[es].x-De,Ws=wt[es].y-bt;Pe.writeVarint(ce(is)),Pe.writeVarint(ce(Ws)),De+=is,bt+=Ws}Ge===3&&Pe.writeVarint(oe(7,1))}}function ie(Ue,Pe){var je=typeof Ue;je==="string"?Pe.writeStringField(1,Ue):je==="boolean"?Pe.writeBooleanField(7,Ue):je==="number"&&(Ue%1!=0?Pe.writeDoubleField(3,Ue):Ue<0?Pe.writeSVarintField(6,Ue):Pe.writeVarintField(5,Ue))}F.exports=q,F.exports.fromVectorTileJs=q,F.exports.fromGeojsonVt=function(Ue,Pe){Pe=Pe||{};var je={};for(var Ge in Ue)je[Ge]=new O(Ue[Ge].features,Pe),je[Ge].name=Ge,je[Ge].version=Pe.version,je[Ge].extent=Pe.extent;return q({layers:je})},F.exports.GeoJSONWrapper=O;var de=u.by(F.exports);const ge={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:Ue=>Ue},We=Math.fround||(Ee=new Float32Array(1),Ue=>(Ee[0]=+Ue,Ee[0]));var Ee;const ve=3,we=5,Ze=6;class ke{constructor(Pe){this.options=Object.assign(Object.create(ge),Pe),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(Pe){const{log:je,minZoom:Ge,maxZoom:De}=this.options;je&&console.time("total time");const bt=`prepare ${Pe.length} points`;je&&console.time(bt),this.points=Pe;const Ct=[];for(let wt=0;wt<Pe.length;wt++){const Zt=Pe[wt];if(!Zt.geometry)continue;const[ys,es]=Zt.geometry.coordinates,is=We(dt(ys)),Ws=We(Re(es));Ct.push(is,Ws,1/0,wt,-1,1),this.options.reduce&&Ct.push(0)}let pe=this.trees[De+1]=this._createTree(Ct);je&&console.timeEnd(bt);for(let wt=De;wt>=Ge;wt--){const Zt=+Date.now();pe=this.trees[wt]=this._createTree(this._cluster(pe,wt)),je&&console.log("z%d: %d clusters in %dms",wt,pe.numItems,+Date.now()-Zt)}return je&&console.timeEnd("total time"),this}getClusters(Pe,je){let Ge=((Pe[0]+180)%360+360)%360-180;const De=Math.max(-90,Math.min(90,Pe[1]));let bt=Pe[2]===180?180:((Pe[2]+180)%360+360)%360-180;const Ct=Math.max(-90,Math.min(90,Pe[3]));if(Pe[2]-Pe[0]>=360)Ge=-180,bt=180;else if(Ge>bt){const es=this.getClusters([Ge,De,180,Ct],je),is=this.getClusters([-180,De,bt,Ct],je);return es.concat(is)}const pe=this.trees[this._limitZoom(je)],wt=pe.range(dt(Ge),Re(Ct),dt(bt),Re(De)),Zt=pe.data,ys=[];for(const es of wt){const is=this.stride*es;ys.push(Zt[is+we]>1?ze(Zt,is,this.clusterProps):this.points[Zt[is+ve]])}return ys}getChildren(Pe){const je=this._getOriginId(Pe),Ge=this._getOriginZoom(Pe),De="No cluster with the specified id.",bt=this.trees[Ge];if(!bt)throw new Error(De);const Ct=bt.data;if(je*this.stride>=Ct.length)throw new Error(De);const pe=this.options.radius/(this.options.extent*Math.pow(2,Ge-1)),wt=bt.within(Ct[je*this.stride],Ct[je*this.stride+1],pe),Zt=[];for(const ys of wt){const es=ys*this.stride;Ct[es+4]===Pe&&Zt.push(Ct[es+we]>1?ze(Ct,es,this.clusterProps):this.points[Ct[es+ve]])}if(Zt.length===0)throw new Error(De);return Zt}getLeaves(Pe,je,Ge){const De=[];return this._appendLeaves(De,Pe,je=je||10,Ge=Ge||0,0),De}getTile(Pe,je,Ge){const De=this.trees[this._limitZoom(Pe)],bt=Math.pow(2,Pe),{extent:Ct,radius:pe}=this.options,wt=pe/Ct,Zt=(Ge-wt)/bt,ys=(Ge+1+wt)/bt,es={features:[]};return this._addTileFeatures(De.range((je-wt)/bt,Zt,(je+1+wt)/bt,ys),De.data,je,Ge,bt,es),je===0&&this._addTileFeatures(De.range(1-wt/bt,Zt,1,ys),De.data,bt,Ge,bt,es),je===bt-1&&this._addTileFeatures(De.range(0,Zt,wt/bt,ys),De.data,-1,Ge,bt,es),es.features.length?es:null}getClusterExpansionZoom(Pe){let je=this._getOriginZoom(Pe)-1;for(;je<=this.options.maxZoom;){const Ge=this.getChildren(Pe);if(je++,Ge.length!==1)break;Pe=Ge[0].properties.cluster_id}return je}
vendor: 15,471 bytes, line 1962
1962_appendLeaves(Pe,je,Ge,De,bt){const Ct=this.getChildren(je);for(const pe of Ct){const wt=pe.properties;if(wt&&wt.cluster?bt+wt.point_count<=De?bt+=wt.point_count:bt=this._appendLeaves(Pe,wt.cluster_id,Ge,De,bt):bt<De?bt++:Pe.push(pe),Pe.length===Ge)break}return bt}_createTree(Pe){const je=new u.av(Pe.length/this.stride|0,this.options.nodeSize,Float32Array);for(let Ge=0;Ge<Pe.length;Ge+=this.stride)je.add(Pe[Ge],Pe[Ge+1]);return je.finish(),je.data=Pe,je}_addTileFeatures(Pe,je,Ge,De,bt,Ct){for(const pe of Pe){const wt=pe*this.stride,Zt=je[wt+we]>1;let ys,es,is;if(Zt)ys=Ke(je,wt,this.clusterProps),es=je[wt],is=je[wt+1];else{const ya=this.points[je[wt+ve]];ys=ya.properties;const[Hs,xt]=ya.geometry.coordinates;es=dt(Hs),is=Re(xt)}const Ws={type:1,geometry:[[Math.round(this.options.extent*(es*bt-Ge)),Math.round(this.options.extent*(is*bt-De))]],tags:ys};let an;an=Zt||this.options.generateId?je[wt+ve]:this.points[je[wt+ve]].id,an!==void 0&&(Ws.id=an),Ct.features.push(Ws)}}_limitZoom(Pe){return Math.max(this.options.minZoom,Math.min(Math.floor(+Pe),this.options.maxZoom+1))}_cluster(Pe,je){const{radius:Ge,extent:De,reduce:bt,minPoints:Ct}=this.options,pe=Ge/(De*Math.pow(2,je)),wt=Pe.data,Zt=[],ys=this.stride;for(let es=0;es<wt.length;es+=ys){if(wt[es+2]<=je)continue;wt[es+2]=je;const is=wt[es],Ws=wt[es+1],an=Pe.within(wt[es],wt[es+1],pe),ya=wt[es+we];let Hs=ya;for(const xt of an){const os=xt*ys;wt[os+2]>je&&(Hs+=wt[os+we])}if(Hs>ya&&Hs>=Ct){let xt,os=is*ya,Ls=Ws*ya,Es=-1;const Qs=((es/ys|0)<<5)+(je+1)+this.points.length;for(const Pn of an){const Ks=Pn*ys;if(wt[Ks+2]<=je)continue;wt[Ks+2]=je;const xa=wt[Ks+we];os+=wt[Ks]*xa,Ls+=wt[Ks+1]*xa,wt[Ks+4]=Qs,bt&&(xt||(xt=this._map(wt,es,!0),Es=this.clusterProps.length,this.clusterProps.push(xt)),bt(xt,this._map(wt,Ks)))}wt[es+4]=Qs,Zt.push(os/Hs,Ls/Hs,1/0,Qs,-1,Hs),bt&&Zt.push(Es)}else{for(let xt=0;xt<ys;xt++)Zt.push(wt[es+xt]);if(Hs>1)for(const xt of an){const os=xt*ys;if(!(wt[os+2]<=je)){wt[os+2]=je;for(let Ls=0;Ls<ys;Ls++)Zt.push(wt[os+Ls])}}}}return Zt}_getOriginId(Pe){return Pe-this.points.length>>5}_getOriginZoom(Pe){return(Pe-this.points.length)%32}_map(Pe,je,Ge){if(Pe[je+we]>1){const Ct=this.clusterProps[Pe[je+Ze]];return Ge?Object.assign({},Ct):Ct}const De=this.points[Pe[je+ve]].properties,bt=this.options.map(De);return Ge&&bt===De?Object.assign({},bt):bt}}function ze(Ue,Pe,je){return{type:"Feature",id:Ue[Pe+ve],properties:Ke(Ue,Pe,je),geometry:{type:"Point",coordinates:[(Ge=Ue[Pe],360*(Ge-.5)),qt(Ue[Pe+1])]}};var Ge}function Ke(Ue,Pe,je){const Ge=Ue[Pe+we],De=Ge>=1e4?`${Math.round(Ge/1e3)}k`:Ge>=1e3?Math.round(Ge/100)/10+"k":Ge,bt=Ue[Pe+Ze],Ct=bt===-1?{}:Object.assign({},je[bt]);return Object.assign(Ct,{cluster:!0,cluster_id:Ue[Pe+ve],point_count:Ge,point_count_abbreviated:De})}function dt(Ue){return Ue/360+.5}function Re(Ue){const Pe=Math.sin(Ue*Math.PI/180),je=.5-.25*Math.log((1+Pe)/(1-Pe))/Math.PI;return je<0?0:je>1?1:je}function qt(Ue){const Pe=(180-360*Ue)*Math.PI/180;return 360*Math.atan(Math.exp(Pe))/Math.PI-90}function ft(Ue,Pe,je,Ge){let De=Ge;const bt=Pe+(je-Pe>>1);let Ct,pe=je-Pe;const wt=Ue[Pe],Zt=Ue[Pe+1],ys=Ue[je],es=Ue[je+1];for(let is=Pe+3;is<je;is+=3){const Ws=Fe(Ue[is],Ue[is+1],wt,Zt,ys,es);if(Ws>De)Ct=is,De=Ws;else if(Ws===De){const an=Math.abs(is-bt);an<pe&&(Ct=is,pe=an)}}De>Ge&&(Ct-Pe>3&&ft(Ue,Pe,Ct,Ge),Ue[Ct+2]=De,je-Ct>3&&ft(Ue,Ct,je,Ge))}function Fe(Ue,Pe,je,Ge,De,bt){let Ct=De-je,pe=bt-Ge;if(Ct!==0||pe!==0){const wt=((Ue-je)*Ct+(Pe-Ge)*pe)/(Ct*Ct+pe*pe);wt>1?(je=De,Ge=bt):wt>0&&(je+=Ct*wt,Ge+=pe*wt)}return Ct=Ue-je,pe=Pe-Ge,Ct*Ct+pe*pe}function fe(Ue,Pe,je,Ge){const De={id:Ue??null,type:Pe,geometry:je,tags:Ge,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(Pe==="Point"||Pe==="MultiPoint"||Pe==="LineString")Qe(De,je);else if(Pe==="Polygon")Qe(De,je[0]);else if(Pe==="MultiLineString")for(const bt of je)Qe(De,bt);else if(Pe==="MultiPolygon")for(const bt of je)Qe(De,bt[0]);return De}function Qe(Ue,Pe){for(let je=0;je<Pe.length;je+=3)Ue.minX=Math.min(Ue.minX,Pe[je]),Ue.minY=Math.min(Ue.minY,Pe[je+1]),Ue.maxX=Math.max(Ue.maxX,Pe[je]),Ue.maxY=Math.max(Ue.maxY,Pe[je+1])}function ht(Ue,Pe,je,Ge){if(!Pe.geometry)return;const De=Pe.geometry.coordinates;if(De&&De.length===0)return;const bt=Pe.geometry.type,Ct=Math.pow(je.tolerance/((1<<je.maxZoom)*je.extent),2);let pe=[],wt=Pe.id;if(je.promoteId?wt=Pe.properties[je.promoteId]:je.generateId&&(wt=Ge||0),bt==="Point")_t(De,pe);else if(bt==="MultiPoint")for(const Zt of De)_t(Zt,pe);else if(bt==="LineString")He(De,pe,Ct,!1);else if(bt==="MultiLineString"){if(je.lineMetrics){for(const Zt of De)pe=[],He(Zt,pe,Ct,!1),Ue.push(fe(wt,"LineString",pe,Pe.properties));return}as(De,pe,Ct,!1)}else if(bt==="Polygon")as(De,pe,Ct,!0);else{if(bt!=="MultiPolygon"){if(bt==="GeometryCollection"){for(const Zt of Pe.geometry.geometries)ht(Ue,{id:wt,geometry:Zt,properties:Pe.properties},je,Ge);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const Zt of De){const ys=[];as(Zt,ys,Ct,!0),pe.push(ys)}}Ue.push(fe(wt,bt,pe,Pe.properties))}function _t(Ue,Pe){Pe.push(vt(Ue[0]),Xe(Ue[1]),0)}function He(Ue,Pe,je,Ge){let De,bt,Ct=0;for(let wt=0;wt<Ue.length;wt++){const Zt=vt(Ue[wt][0]),ys=Xe(Ue[wt][1]);Pe.push(Zt,ys,0),wt>0&&(Ct+=Ge?(De*ys-Zt*bt)/2:Math.sqrt(Math.pow(Zt-De,2)+Math.pow(ys-bt,2))),De=Zt,bt=ys}const pe=Pe.length-3;Pe[2]=1,ft(Pe,0,pe,je),Pe[pe+2]=1,Pe.size=Math.abs(Ct),Pe.start=0,Pe.end=Pe.size}function as(Ue,Pe,je,Ge){for(let De=0;De<Ue.length;De++){const bt=[];He(Ue[De],bt,je,Ge),Pe.push(bt)}}function vt(Ue){return Ue/360+.5}function Xe(Ue){const Pe=Math.sin(Ue*Math.PI/180),je=.5-.25*Math.log((1+Pe)/(1-Pe))/Math.PI;return je<0?0:je>1?1:je}function Ce(Ue,Pe,je,Ge,De,bt,Ct,pe){if(Ge/=Pe,bt>=(je/=Pe)&&Ct<Ge)return Ue;if(Ct<je||bt>=Ge)return null;const wt=[];for(const Zt of Ue){const ys=Zt.geometry;let es=Zt.type;const is=De===0?Zt.minX:Zt.minY,Ws=De===0?Zt.maxX:Zt.maxY;if(is>=je&&Ws<Ge){wt.push(Zt);continue}if(Ws<je||is>=Ge)continue;let an=[];if(es==="Point"||es==="MultiPoint")Be(ys,an,je,Ge,De);else if(es==="LineString")Dt(ys,an,je,Ge,De,!1,pe.lineMetrics);else if(es==="MultiLineString")zt(ys,an,je,Ge,De,!1);else if(es==="Polygon")zt(ys,an,je,Ge,De,!0);else if(es==="MultiPolygon")for(const ya of ys){const Hs=[];zt(ya,Hs,je,Ge,De,!0),Hs.length&&an.push(Hs)}if(an.length){if(pe.lineMetrics&&es==="LineString"){for(const ya of an)wt.push(fe(Zt.id,es,ya,Zt.tags));continue}es!=="LineString"&&es!=="MultiLineString"||(an.length===1?(es="LineString",an=an[0]):es="MultiLineString"),es!=="Point"&&es!=="MultiPoint"||(es=an.length===3?"Point":"MultiPoint"),wt.push(fe(Zt.id,es,an,Zt.tags))}}return wt.length?wt:null}function Be(Ue,Pe,je,Ge,De){for(let bt=0;bt<Ue.length;bt+=3){const Ct=Ue[bt+De];Ct>=je&&Ct<=Ge&&rs(Pe,Ue[bt],Ue[bt+1],Ue[bt+2])}}function Dt(Ue,Pe,je,Ge,De,bt,Ct){let pe=Rt(Ue);const wt=De===0?_s:vs;let Zt,ys,es=Ue.start;for(let Hs=0;Hs<Ue.length-3;Hs+=3){const xt=Ue[Hs],os=Ue[Hs+1],Ls=Ue[Hs+2],Es=Ue[Hs+3],Qs=Ue[Hs+4],Pn=De===0?xt:os,Ks=De===0?Es:Qs;let xa=!1;Ct&&(Zt=Math.sqrt(Math.pow(xt-Es,2)+Math.pow(os-Qs,2))),Pn<je?Ks>je&&(ys=wt(pe,xt,os,Es,Qs,je),Ct&&(pe.start=es+Zt*ys)):Pn>Ge?Ks<Ge&&(ys=wt(pe,xt,os,Es,Qs,Ge),Ct&&(pe.start=es+Zt*ys)):rs(pe,xt,os,Ls),Ks<je&&Pn>=je&&(ys=wt(pe,xt,os,Es,Qs,je),xa=!0),Ks>Ge&&Pn<=Ge&&(ys=wt(pe,xt,os,Es,Qs,Ge),xa=!0),!bt&&xa&&(Ct&&(pe.end=es+Zt*ys),Pe.push(pe),pe=Rt(Ue)),Ct&&(es+=Zt)}let is=Ue.length-3;const Ws=Ue[is],an=Ue[is+1],ya=De===0?Ws:an;ya>=je&&ya<=Ge&&rs(pe,Ws,an,Ue[is+2]),is=pe.length-3,bt&&is>=3&&(pe[is]!==pe[0]||pe[is+1]!==pe[1])&&rs(pe,pe[0],pe[1],pe[2]),pe.length&&Pe.push(pe)}function Rt(Ue){const Pe=[];return Pe.size=Ue.size,Pe.start=Ue.start,Pe.end=Ue.end,Pe}function zt(Ue,Pe,je,Ge,De,bt){for(const Ct of Ue)Dt(Ct,Pe,je,Ge,De,bt,!1)}function rs(Ue,Pe,je,Ge){Ue.push(Pe,je,Ge)}function _s(Ue,Pe,je,Ge,De,bt){const Ct=(bt-Pe)/(Ge-Pe);return rs(Ue,bt,je+(De-je)*Ct,1),Ct}function vs(Ue,Pe,je,Ge,De,bt){const Ct=(bt-je)/(De-je);return rs(Ue,Pe+(Ge-Pe)*Ct,bt,1),Ct}function $t(Ue,Pe){const je=[];for(let Ge=0;Ge<Ue.length;Ge++){const De=Ue[Ge],bt=De.type;let Ct;if(bt==="Point"||bt==="MultiPoint"||bt==="LineString")Ct=Ns(De.geometry,Pe);else if(bt==="MultiLineString"||bt==="Polygon"){Ct=[];for(const pe of De.geometry)Ct.push(Ns(pe,Pe))}else if(bt==="MultiPolygon"){Ct=[];for(const pe of De.geometry){const wt=[];for(const Zt of pe)wt.push(Ns(Zt,Pe));Ct.push(wt)}}je.push(fe(De.id,bt,Ct,De.tags))}return je}function Ns(Ue,Pe){const je=[];je.size=Ue.size,Ue.start!==void 0&&(je.start=Ue.start,je.end=Ue.end);for(let Ge=0;Ge<Ue.length;Ge+=3)je.push(Ue[Ge]+Pe,Ue[Ge+1],Ue[Ge+2]);return je}function Ts(Ue,Pe){if(Ue.transformed)return Ue;const je=1<<Ue.z,Ge=Ue.x,De=Ue.y;for(const bt of Ue.features){const Ct=bt.geometry,pe=bt.type;if(bt.geometry=[],pe===1)for(let wt=0;wt<Ct.length;wt+=2)bt.geometry.push(bs(Ct[wt],Ct[wt+1],Pe,je,Ge,De));else for(let wt=0;wt<Ct.length;wt++){const Zt=[];for(let ys=0;ys<Ct[wt].length;ys+=2)Zt.push(bs(Ct[wt][ys],Ct[wt][ys+1],Pe,je,Ge,De));bt.geometry.push(Zt)}}return Ue.transformed=!0,Ue}function bs(Ue,Pe,je,Ge,De,bt){return[Math.round(je*(Ue*Ge-De)),Math.round(je*(Pe*Ge-bt))]}function en(Ue,Pe,je,Ge,De){const bt=Pe===De.maxZoom?0:De.tolerance/((1<<Pe)*De.extent),Ct={features:[],numPoints:0,numSimplified:0,numFeatures:Ue.length,source:null,x:je,y:Ge,z:Pe,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const pe of Ue)Jt(Ct,pe,bt,De);return Ct}function Jt(Ue,Pe,je,Ge){const De=Pe.geometry,bt=Pe.type,Ct=[];if(Ue.minX=Math.min(Ue.minX,Pe.minX),Ue.minY=Math.min(Ue.minY,Pe.minY),Ue.maxX=Math.max(Ue.maxX,Pe.maxX),Ue.maxY=Math.max(Ue.maxY,Pe.maxY),bt==="Point"||bt==="MultiPoint")for(let pe=0;pe<De.length;pe+=3)Ct.push(De[pe],De[pe+1]),Ue.numPoints++,Ue.numSimplified++;else if(bt==="LineString")Vs(Ct,De,Ue,je,!1,!1);else if(bt==="MultiLineString"||bt==="Polygon")for(let pe=0;pe<De.length;pe++)Vs(Ct,De[pe],Ue,je,bt==="Polygon",pe===0);else if(bt==="MultiPolygon")for(let pe=0;pe<De.length;pe++){const wt=De[pe];for(let Zt=0;Zt<wt.length;Zt++)Vs(Ct,wt[Zt],Ue,je,!0,Zt===0)}if(Ct.length){let pe=Pe.tags||null;if(bt==="LineString"&&Ge.lineMetrics){pe={};for(const Zt in Pe.tags)pe[Zt]=Pe.tags[Zt];pe.mapbox_clip_start=De.start/De.size,pe.mapbox_clip_end=De.end/De.size}const wt={geometry:Ct,type:bt==="Polygon"||bt==="MultiPolygon"?3:bt==="LineString"||bt==="MultiLineString"?2:1,tags:pe};Pe.id!==null&&(wt.id=Pe.id),Ue.features.push(wt)}}function Vs(Ue,Pe,je,Ge,De,bt){const Ct=Ge*Ge;if(Ge>0&&Pe.size<(De?Ct:Ge))return void(je.numPoints+=Pe.length/3);const pe=[];for(let wt=0;wt<Pe.length;wt+=3)(Ge===0||Pe[wt+2]>Ct)&&(je.numSimplified++,pe.push(Pe[wt],Pe[wt+1])),je.numPoints++;De&&function(wt,Zt){let ys=0;for(let es=0,is=wt.length,Ws=is-2;es<is;Ws=es,es+=2)ys+=(wt[es]-wt[Ws])*(wt[es+1]+wt[Ws+1]);if(ys>0===Zt)for(let es=0,is=wt.length;es<is/2;es+=2){const Ws=wt[es],an=wt[es+1];wt[es]=wt[is-2-es],wt[es+1]=wt[is-1-es],wt[is-2-es]=Ws,wt[is-1-es]=an}}(pe,bt),Ue.push(pe)}const ps={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class nt{constructor(Pe,je){const Ge=(je=this.options=function(bt,Ct){for(const pe in Ct)bt[pe]=Ct[pe];return bt}(Object.create(ps),je)).debug;if(Ge&&console.time("preprocess data"),je.maxZoom<0||je.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(je.promoteId&&je.generateId)throw new Error("promoteId and generateId cannot be used together.");let De=function(bt,Ct){const pe=[];if(bt.type==="FeatureCollection")for(let wt=0;wt<bt.features.length;wt++)ht(pe,bt.features[wt],Ct,wt);else ht(pe,bt.type==="Feature"?bt:{geometry:bt},Ct);return pe}(Pe,je);this.tiles={},this.tileCoords=[],Ge&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",je.indexMaxZoom,je.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),De=function(bt,Ct){const pe=Ct.buffer/Ct.extent;let wt=bt;const Zt=Ce(bt,1,-1-pe,pe,0,-1,2,Ct),ys=Ce(bt,1,1-pe,2+pe,0,-1,2,Ct);return(Zt||ys)&&(wt=Ce(bt,1,-pe,1+pe,0,-1,2,Ct)||[],Zt&&(wt=$t(Zt,1).concat(wt)),ys&&(wt=wt.concat($t(ys,-1)))),wt}(De,je),De.length&&this.splitTile(De,0,0,0),Ge&&(De.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(Pe,je,Ge,De,bt,Ct,pe){const wt=[Pe,je,Ge,De],Zt=this.options,ys=Zt.debug;for(;wt.length;){De=wt.pop(),Ge=wt.pop(),je=wt.pop(),Pe=wt.pop();const es=1<<je,is=ts(je,Ge,De);let Ws=this.tiles[is];if(!Ws&&(ys>1&&console.time("creation"),Ws=this.tiles[is]=en(Pe,je,Ge,De,Zt),this.tileCoords.push({z:je,x:Ge,y:De}),ys)){ys>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",je,Ge,De,Ws.numFeatures,Ws.numPoints,Ws.numSimplified),console.timeEnd("creation"));const xa=`z${je}`;this.stats[xa]=(this.stats[xa]||0)+1,this.total++}if(Ws.source=Pe,bt==null){if(je===Zt.indexMaxZoom||Ws.numPoints<=Zt.indexMaxPoints)continue}else{if(je===Zt.maxZoom||je===bt)continue;if(bt!=null){const xa=bt-je;if(Ge!==Ct>>xa||De!==pe>>xa)continue}}if(Ws.source=null,Pe.length===0)continue;ys>1&&console.time("clipping");const an=.5*Zt.buffer/Zt.extent,ya=.5-an,Hs=.5+an,xt=1+an;let os=null,Ls=null,Es=null,Qs=null,Pn=Ce(Pe,es,Ge-an,Ge+Hs,0,Ws.minX,Ws.maxX,Zt),Ks=Ce(Pe,es,Ge+ya,Ge+xt,0,Ws.minX,Ws.maxX,Zt);Pe=null,Pn&&(os=Ce(Pn,es,De-an,De+Hs,1,Ws.minY,Ws.maxY,Zt),Ls=Ce(Pn,es,De+ya,De+xt,1,Ws.minY,Ws.maxY,Zt),Pn=null),Ks&&(Es=Ce(Ks,es,De-an,De+Hs,1,Ws.minY,Ws.maxY,Zt),Qs=Ce(Ks,es,De+ya,De+xt,1,Ws.minY,Ws.maxY,Zt),Ks=null),ys>1&&console.timeEnd("clipping"),wt.push(os||[],je+1,2*Ge,2*De),wt.push(Ls||[],je+1,2*Ge,2*De+1),wt.push(Es||[],je+1,2*Ge+1,2*De),wt.push(Qs||[],je+1,2*Ge+1,2*De+1)}}getTile(Pe,je,Ge){Pe=+Pe,je=+je,Ge=+Ge;const De=this.options,{extent:bt,debug:Ct}=De;if(Pe<0||Pe>24)return null;const pe=1<<Pe,wt=ts(Pe,je=je+pe&pe-1,Ge);if(this.tiles[wt])return Ts(this.tiles[wt],bt);Ct>1&&console.log("drilling down to z%d-%d-%d",Pe,je,Ge);let Zt,ys=Pe,es=je,is=Ge;for(;!Zt&&ys>0;)ys--,es>>=1,is>>=1,Zt=this.tiles[ts(ys,es,is)];return Zt&&Zt.source?(Ct>1&&(console.log("found parent tile z%d-%d-%d",ys,es,is),console.time("drilling down")),this.splitTile(Zt.source,ys,es,is,Pe,je,Ge),Ct>1&&console.timeEnd("drilling down"),this.tiles[wt]?Ts(this.tiles[wt],bt):null):null}}function ts(Ue,Pe,je){return 32*((1<<Ue)*je+Pe)+Ue}function ds(Ue,Pe){return Pe?Ue.properties[Pe]:Ue.id}function Is(Ue,Pe){if(Ue==null)return!0;if(Ue.type==="Feature")return ds(Ue,Pe)!=null;if(Ue.type==="FeatureCollection"){const je=new Set;for(const Ge of Ue.features){const De=ds(Ge,Pe);if(De==null||je.has(De))return!1;je.add(De)}return!0}return!1}function tn(Ue,Pe){const je=new Map;if(Ue!=null)if(Ue.type==="Feature")je.set(ds(Ue,Pe),Ue);else for(const Ge of Ue.features)je.set(ds(Ge,Pe),Ge);return je}class wn extends x{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(Pe,je){return u._(this,void 0,void 0,function*(){const Ge=Pe.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const De=this._geoJSONIndex.getTile(Ge.z,Ge.x,Ge.y);if(!De)return null;const bt=new class{constructor(pe){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=u.X,this.length=pe.length,this._features=pe}feature(pe){return new class{constructor(wt){this._feature=wt,this.extent=u.X,this.type=wt.type,this.properties=wt.tags,"id"in wt&&!isNaN(wt.id)&&(this.id=p
1962arseInt(wt.id,10))}loadGeometry(){if(this._feature.type===1){const wt=[];for(const Zt of this._feature.geometry)wt.push([new u.P(Zt[0],Zt[1])]);return wt}{const wt=[];for(const Zt of this._feature.geometry){const ys=[];for(const es of Zt)ys.push(new u.P(es[0],es[1]));wt.push(ys)}return wt}}toGeoJSON(wt,Zt,ys){return z.call(this,wt,Zt,ys)}}(this._features[pe])}}(De.features);let Ct=de(bt);return Ct.byteOffset===0&&Ct.byteLength===Ct.buffer.byteLength||(Ct=new Uint8Array(Ct)),{vectorTile:bt,rawData:Ct.buffer}})}loadData(Pe){return u._(this,void 0,void 0,function*(){var je;(je=this._pendingRequest)===null||je===void 0||je.abort();const Ge=!!(Pe&&Pe.request&&Pe.request.collectResourceTiming)&&new u.bv(Pe.request);this._pendingRequest=new AbortController;try{this._pendingData=this.loadAndProcessGeoJSON(Pe,this._pendingRequest),this._geoJSONIndex=Pe.cluster?new ke(function({superclusterOptions:Ct,clusterProperties:pe}){if(!pe||!Ct)return Ct;const wt={},Zt={},ys={accumulated:null,zoom:0},es={properties:null},is=Object.keys(pe);for(const Ws of is){const[an,ya]=pe[Ws],Hs=u.bC(ya),xt=u.bC(typeof an=="string"?[an,["accumulated"],["get",Ws]]:an);wt[Ws]=Hs.value,Zt[Ws]=xt.value}return Ct.map=Ws=>{es.properties=Ws;const an={};for(const ya of is)an[ya]=wt[ya].evaluate(ys,es);return an},Ct.reduce=(Ws,an)=>{es.properties=an;for(const ya of is)ys.accumulated=Ws[ya],Ws[ya]=Zt[ya].evaluate(ys,es)},Ct}(Pe)).load((yield this._pendingData).features):(De=yield this._pendingData,new nt(De,Pe.geojsonVtOptions)),this.loaded={};const bt={};if(Ge){const Ct=Ge.finish();Ct&&(bt.resourceTiming={},bt.resourceTiming[Pe.source]=JSON.parse(JSON.stringify(Ct)))}return bt}catch(bt){if(delete this._pendingRequest,u.bB(bt))return{abandoned:!0};throw bt}var De})}getData(){return u._(this,void 0,void 0,function*(){return this._pendingData})}reloadTile(Pe){const je=this.loaded;return je&&je[Pe.uid]?super.reloadTile(Pe):this.loadTile(Pe)}loadAndProcessGeoJSON(Pe,je){return u._(this,void 0,void 0,function*(){let Ge=yield this.loadGeoJSON(Pe,je);if(delete this._pendingRequest,typeof Ge!="object")throw new Error(`Input data given to '${Pe.source}' is not a valid GeoJSON object.`);if(I(Ge,!0),Pe.filter){const De=u.bC(Pe.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(De.result==="error")throw new Error(De.value.map(Ct=>`${Ct.key}: ${Ct.message}`).join(", "));Ge={type:"FeatureCollection",features:Ge.features.filter(Ct=>De.value.evaluate({zoom:0},Ct))}}return Ge})}loadGeoJSON(Pe,je){return u._(this,void 0,void 0,function*(){const{promoteId:Ge}=Pe;if(Pe.request){const De=yield u.h(Pe.request,je);return this._dataUpdateable=Is(De.data,Ge)?tn(De.data,Ge):void 0,De.data}if(typeof Pe.data=="string")try{const De=JSON.parse(Pe.data);return this._dataUpdateable=Is(De,Ge)?tn(De,Ge):void 0,De}catch{throw new Error(`Input data given to '${Pe.source}' is not a valid GeoJSON object.`)}if(!Pe.dataDiff)throw new Error(`Input data given to '${Pe.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${Pe.source}`);return function(De,bt,Ct){var pe,wt,Zt,ys;if(bt.removeAll&&De.clear(),bt.remove)for(const es of bt.remove)De.delete(es);if(bt.add)for(const es of bt.add){const is=ds(es,Ct);is!=null&&De.set(is,es)}if(bt.update)for(const es of bt.update){let is=De.get(es.id);if(is==null)continue;const Ws=!es.removeAllProperties&&(((pe=es.removeProperties)===null||pe===void 0?void 0:pe.length)>0||((wt=es.addOrUpdateProperties)===null||wt===void 0?void 0:wt.length)>0);if((es.newGeometry||es.removeAllProperties||Ws)&&(is=Object.assign({},is),De.set(es.id,is),Ws&&(is.properties=Object.assign({},is.properties))),es.newGeometry&&(is.geometry=es.newGeometry),es.removeAllProperties)is.properties={};else if(((Zt=es.removeProperties)===null||Zt===void 0?void 0:Zt.length)>0)for(const an of es.removeProperties)Object.prototype.hasOwnProperty.call(is.properties,an)&&delete is.properties[an];if(((ys=es.addOrUpdateProperties)===null||ys===void 0?void 0:ys.length)>0)for(const{key:an,value:ya}of es.addOrUpdateProperties)is.properties[an]=ya}}(this._dataUpdateable,Pe.dataDiff,Ge),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}})}removeSource(Pe){return u._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(Pe){return this._geoJSONIndex.getClusterExpansionZoom(Pe.clusterId)}getClusterChildren(Pe){return this._geoJSONIndex.getChildren(Pe.clusterId)}getClusterLeaves(Pe){return this._geoJSONIndex.getLeaves(Pe.clusterId,Pe.limit,Pe.offset)}}class Gs{constructor(Pe){this.self=Pe,this.actor=new u.F(Pe),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={}
1962,this.self.registerWorkerSource=(je,Ge)=>{if(this.externalWorkerSourceTypes[je])throw new Error(`Worker source with name "${je}" already registered.`);this.externalWorkerSourceTypes[je]=Ge},this.self.addProtocol=u.bi,this.self.removeProtocol=u.bj,this.self.registerRTLTextPlugin=je=>{if(u.bD.isParsed())throw new Error("RTL text plugin already registered.");u.bD.setMethods(je)},this.actor.registerMessageHandler("LDT",(je,Ge)=>this._getDEMWorkerSource(je,Ge.source).loadTile(Ge)),this.actor.registerMessageHandler("RDT",(je,Ge)=>u._(this,void 0,void 0,function*(){this._getDEMWorkerSource(je,Ge.source).removeTile(Ge)})),this.actor.registerMessageHandler("GCEZ",(je,Ge)=>u._(this,void 0,void 0,function*(){return this._getWorkerSource(je,Ge.type,Ge.source).getClusterExpansionZoom(Ge)})),this.actor.registerMessageHandler("GCC",(je,Ge)=>u._(this,void 0,void 0,function*(){return this._getWorkerSource(je,Ge.type,Ge.source).getClusterChildren(Ge)})),this.actor.registerMessageHandler("GCL",(je,Ge)=>u._(this,void 0,void 0,function*(){return this._getWorkerSource(je,Ge.type,Ge.source).getClusterLeaves(Ge)})),this.actor.registerMessageHandler("LD",(je,Ge)=>this._getWorkerSource(je,Ge.type,Ge.source).loadData(Ge)),this.actor.registerMessageHandler("GD",(je,Ge)=>this._getWorkerSource(je,Ge.type,Ge.source).getData()),this.actor.registerMessageHandler("LT",(je,Ge)=>this._getWorkerSource(je,Ge.type,Ge.source).loadTile(Ge)),this.actor.registerMessageHandler("RT",(je,Ge)=>this._getWorkerSource(je,Ge.type,Ge.source).reloadTile(Ge)),this.actor.registerMessageHandler("AT",(je,Ge)=>this._getWorkerSource(je,Ge.type,Ge.source).abortTile(Ge)),this.actor.registerMessageHandler("RMT",(je,Ge)=>this._getWorkerSource(je,Ge.type,Ge.source).removeTile(Ge)),this.actor.registerMessageHandler("RS",(je,Ge)=>u._(this,void 0,void 0,function*(){if(!this.workerSources[je]||!this.workerSources[je][Ge.type]||!this.workerSources[je][Ge.type][Ge.source])return;const De=this.workerSources[je][Ge.type][Ge.source];delete this.workerSources[je][Ge.type][Ge.source],De.removeSource!==void 0&&De.removeSource(Ge)})),this.actor.registerMessageHandler("RM",je=>u._(this,void 0,void 0,function*(){delete this.layerIndexes[je],delete this.availableImages[je],delete this.workerSources[je],delete this.demWorkerSources[je]})),this.actor.registerMessageHandler("SR",(je,Ge)=>u._(this,void 0,void 0,function*(){this.referrer=Ge})),this.actor.registerMessageHandler("SRPS",(je,Ge)=>this._syncRTLPluginState(je,Ge)),this.actor.registerMessageHandler("IS",(je,Ge)=>u._(this,void 0,void 0,function*(){this.self.importScripts(Ge)})),this.actor.registerMessageHandler("SI",(je,Ge)=>this._setImages(je,Ge)),this.actor.registerMessageHandler("UL",(je,Ge)=>u._(this,void 0,void 0,function*(){this._getLayerIndex(je).update(Ge.layers,Ge.removedIds)})),this.actor.registerMessageHandler("SL",(je,Ge)=>u._(this,void 0,void 0,function*(){this._getLayerIndex(je).replace(Ge)}))}_setImages(Pe,je){return u._(this,void 0,void 0,function*(){this.availableImages[Pe]=je;for(const Ge in this.workerSources[Pe]){const De=this.workerSources[Pe][Ge];for(const bt in De)De[bt].availableImages=je}})}_syncRTLPluginState(Pe,je){return u._(this,void 0,void 0,function*(){if(u.bD.isParsed())return u.bD.getState();if(je.pluginStatus!=="loading")return u.bD.setState(je),je;const Ge=je.pluginURL;if(this.self.importScripts(Ge),u.bD.isParsed()){const De={pluginStatus:"loaded",pluginURL:Ge};return u.bD.setState(De),De}throw u.bD.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${Ge}`)})}_getAvailableImages(Pe){let je=this.availableImages[Pe];return je||(je=[]),je}_getLayerIndex(Pe){let je=this.layerIndexes[Pe];return je||(je=this.layerIndexes[Pe]=new i),je}_getWorkerSource(Pe,je,Ge){if(this.workerSources[Pe]||(this.workerSources[Pe]={}),this.workerSources[Pe][je]||(this.workerSources[Pe][je]={}),!this.workerSources[Pe][je][Ge]){const De={sendAsync:(bt,Ct)=>(bt.targetMapId=Pe,this.actor.sendAsync(bt,Ct))};switch(je){case"vector":this.workerSources[Pe][je][Ge]=new x(De,this._getLayerIndex(Pe),this._getAvailableImages(Pe));break;case"geojson":this.workerSources[Pe][je][Ge]=new wn(De,this._getLayerIndex(Pe),this._getAvailableImages(Pe));break;default:this.workerSources[Pe][je][Ge]=new this.externalWorkerSourceTypes[je](De,this._getLayerIndex(Pe),this._getAvailableImages(Pe))}}return this.workerSources[Pe][je][Ge]}_getDEMWorkerSource(Pe,je){return this.demWorkerSources[Pe]||(this.demWorkerSources[Pe]={}),this.demWorkerSources[Pe][je]||(this.demWorkerSources[Pe][je]=new v),this.demWorkerSources[Pe][je]}}return u.i(self)&&(self.worker=new Gs(self)),Gs}),l("index",["exports","./shared"],function(u,i){var _="4.7.1";let j,y;const x={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:R=>new Promise((r,g)=>
1962{const S=requestAnimationFrame(r);R.signal.addEventListener("abort",()=>{cancelAnimationFrame(S),g(i.c())})}),getImageData(R,r=0){return this.getImageCanvasContext(R).getImageData(-r,-r,R.width+2*r,R.height+2*r)},getImageCanvasContext(R){const r=window.document.createElement("canvas"),g=r.getContext("2d",{willReadFrequently:!0});if(!g)throw new Error("failed to create canvas 2d context");return r.width=R.width,r.height=R.height,g.drawImage(R,0,0,R.width,R.height),g},resolveURL:R=>(j||(j=document.createElement("a")),j.href=R,j.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(y==null&&(y=matchMedia("(prefers-reduced-motion: reduce)")),y.matches)}};class v{static testProp(r){if(!v.docStyle)return r[0];for(let g=0;g<r.length;g++)if(r[g]in v.docStyle)return r[g];return r[0]}static create(r,g,S){const E=window.document.createElement(r);return g!==void 0&&(E.className=g),S&&S.appendChild(E),E}static createNS(r,g){return window.document.createElementNS(r,g)}static disableDrag(){v.docStyle&&v.selectProp&&(v.userSelect=v.docStyle[v.selectProp],v.docStyle[v.selectProp]="none")}static enableDrag(){v.docStyle&&v.selectProp&&(v.docStyle[v.selectProp]=v.userSelect)}static setTransform(r,g){r.style[v.transformProp]=g}static addEventListener(r,g,S,E={}){r.addEventListener(g,S,"passive"in E?E:E.capture)}static removeEventListener(r,g,S,E={}){r.removeEventListener(g,S,"passive"in E?E:E.capture)}static suppressClickInternal(r){r.preventDefault(),r.stopPropagation(),window.removeEventListener("click",v.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",v.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",v.suppressClickInternal,!0)},0)}static getScale(r){const g=r.getBoundingClientRect();return{x:g.width/r.offsetWidth||1,y:g.height/r.offsetHeight||1,boundingClientRect:g}}static getPoint(r,g,S){const E=g.boundingClientRect;return new i.P((S.clientX-E.left)/g.x-r.clientLeft,(S.clientY-E.top)/g.y-r.clientTop)}static mousePos(r,g){const S=v.getScale(r);return v.getPoint(r,S,g)}static touchPos(r,g){const S=[],E=v.getScale(r);for(let A=0;A<g.length;A++)S.push(v.getPoint(r,E,g[A]));return S}static mouseButton(r){return r.button}static remove(r){r.parentNode&&r.parentNode.removeChild(r)}}v.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,v.selectProp=v.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),v.transformProp=v.testProp(["transform","WebkitTransform"]);const C={supported:!1,testSupport:function(R){!z&&I&&(F?D(R):P=R)}};let P,I,z=!1,F=!1;function D(R){const r=R.createTexture();R.bindTexture(R.TEXTURE_2D,r);try{if(R.texImage2D(R.TEXTURE_2D,0,R.RGBA,R.RGBA,R.UNSIGNED_BYTE,I),R.isContextLost())return;C.supported=!0}
1962catch{}R.deleteTexture(r),z=!0}var X;typeof document<"u"&&(I=document.createElement("img"),I.onload=()=>{P&&D(P),P=null,F=!0},I.onerror=()=>{z=!0,P=null},I.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(R){let r,g,S,E;R.resetRequestQueue=()=>{r=[],g=0,S=0,E={}},R.addThrottleControl=he=>{const _e=S++;return E[_e]=he,_e},R.removeThrottleControl=he=>{delete E[he],ee()},R.getImage=(he,_e,Ie=!0)=>new Promise((Me,Je)=>{C.supported&&(he.headers||(he.headers={}),he.headers.accept="image/webp,*/*"),i.e(he,{type:"image"}),r.push({abortController:_e,requestParameters:he,supportImageRefresh:Ie,state:"queued",onError:ut=>{Je(ut)},onSuccess:ut=>{Me(ut)}}),ee()});const A=he=>i._(this,void 0,void 0,function*(){he.state="running";const{requestParameters:_e,supportImageRefresh:Ie,onError:Me,onSuccess:Je,abortController:ut}=he,gt=Ie===!1&&!i.i(self)&&!i.g(_e.url)&&(!_e.headers||Object.keys(_e.headers).reduce((Vt,Ht)=>Vt&&Ht==="accept",!0));g++;const St=gt?se(_e,ut):i.m(_e,ut);try{const Vt=yield St;delete he.abortController,he.state="completed",Vt.data instanceof HTMLImageElement||i.b(Vt.data)?Je(Vt):Vt.data&&Je({data:yield(Lt=Vt.data,typeof createImageBitmap=="function"?i.d(Lt):i.f(Lt)),cacheControl:Vt.cacheControl,expires:Vt.expires})}catch(Vt){delete he.abortController,Me(Vt)}finally{g--,ee()}var Lt}),ee=()=>{const he=(()=>{for(const _e of Object.keys(E))if(E[_e]())return!0;return!1})()?i.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:i.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let _e=g;_e<he&&r.length>0;_e++){const Ie=r.shift();Ie.abortController.signal.aborted?_e--:A(Ie)}},se=(he,_e)=>new Promise((Ie,Me)=>{const Je=new Image,ut=he.url,gt=he.credentials;gt&&gt==="include"?Je.crossOrigin="use-credentials":(gt&&gt==="same-origin"||!i.s(ut))&&(Je.crossOrigin="anonymous"),_e.signal.addEventListener("abort",()=>{Je.src="",Me(i.c())}),Je.fetchPriority="high",Je.onload=()=>{Je.onerror=Je.onload=null,Ie({data:Je})},Je.onerror=()=>{Je.onerror=Je.onload=null,_e.signal.aborted||Me(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},Je.src=ut})}(X||(X={})),X.resetRequestQueue();class K{constructor(r){this._transformRequestFn=r}transformRequest(r,g){return this._transformRequestFn&&this._transformRequestFn(r,g)||{url:r}}setTransformRequest(r){this._transformRequestFn=r}}function te(R){var r=new i.A(3);return r[0]=R[0],r[1]=R[1],r[2]=R[2],r}var J,H=function(R,r,g){return R[0]=r[0]-g[0],R[1]=r[1]-g[1],R[2]=r[2]-g[2],R};J=new i.A(3),i.A!=Float32Array&&(J[0]=0,J[1]=0,J[2]=0);var O=function(R){var r=R[0],g=R[1];return r*r+g*g};function q(R){const r=[];if(typeof R=="string")r.push({id:"default",url:R});else if(R&&R.length>0){const g=[];for(const{id:S,url:E}of R){const A=`${S}${E}`;g.indexOf(A)===-1&&(g.push(A),r.push({id:S,url:E}))}}return r}function W(R,r,g){const S=R.split("?");return S[0]+=`${r}${g}`,S.join("?")}(function(){var R=new i.A(2);i.A!=Float32Array&&(R[0]=0,R[1]=0)})();class Q{constructor(r,g,S,E){this.context=r,this.format=S,this.texture=r.gl.createTexture(),this.update(g,E)}update(r,g,S){const{width:E,height:A}=r,ee=!(this.size&&this.size[0]===E&&this.size[1]===A||S),{context:se}=this,{gl:he}=se;if(this.useMipmap=!!(g&&g.useMipmap),he.bindTexture(he.TEXTURE_2D,this.texture),se.pixelStoreUnpackFlipY.set(!1),se.pixelStoreUnpack.set(1),se.pixelStoreUnpackPremultiplyAlpha.set(this.format===he.RGBA&&(!g||g.premultiply!==!1)),ee)this.size=[E,A],r instanceof HTMLImageElement||r instanceof HTMLCanvasElement||r instanceof HTMLVideoElement||r instanceof ImageData||i.b(r)?he.texImage2D(he.TEXTURE_2D,0,this.format,this.format,he.UNSIGNED_BYTE,r):he.texImage2D(he.TEXTURE_2D,0,this.format,E,A,0,this.format,he.UNSIGNED_BYTE,r.data);else{const{x:_e,y:Ie}=S||{x:0,y:0};r instanceof HTMLImageElement||r instanceof HTMLCanvasElement||r instanceof HTMLVideoElement||r instanceof ImageData||i.b(r)?he.texSubImage2D(he.TEXTURE_2D,0,_e,Ie,he.RGBA,he.UNSIGNED_BYTE,r):he.texSubImage2D(he.TEXTURE_2D,0,_e,Ie,E,A,he.RGBA,he.UNSIGNED_BYTE,r.data)}this.useMipmap&&this.isSizePowerOfTwo()&&he.generateMipmap(he.TEXTURE_2D)}bind(r,g,S){const{context:E}=this,{gl:A}=E;A.bindTexture(A.TEXTURE_2D,this.texture),S!==A.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(S=A.LINEAR),r!==this.filter&&(A.texParameteri(A.TEXTURE_2D,A.TEXTURE_MAG_FILTER,r),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_MIN_FILTER,S||r),this.filter=r),g!==this.wrap&&(A.texParameteri(A.TEXTURE_2D,A.TEXTURE_WRAP_S,g),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_WRAP_T,g),this.wrap=g)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:r}=this.context;r.deleteTexture(this.texture),this.texture=null}}function Z(R){const{userImage:r}=R;return!!(r&&r.render&&r.render())&&(R.data.replace(new Uint8Array(r.data.buffer)),!0)}class oe extends i.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(r){if(this.loaded!==r&&(this.loaded=r,r)){for(const{ids:g,promiseResolve:S}
vendor: 5,084 bytes, line 1962
1962of this.requestors)S(this._getImagesForIds(g));this.requestors=[]}}getImage(r){const g=this.images[r];if(g&&!g.data&&g.spriteData){const S=g.spriteData;g.data=new i.R({width:S.width,height:S.height},S.context.getImageData(S.x,S.y,S.width,S.height).data),g.spriteData=null}return g}addImage(r,g){if(this.images[r])throw new Error(`Image id ${r} already exist, use updateImage instead`);this._validate(r,g)&&(this.images[r]=g)}_validate(r,g){let S=!0;const E=g.data||g.spriteData;return this._validateStretch(g.stretchX,E&&E.width)||(this.fire(new i.j(new Error(`Image "${r}" has invalid "stretchX" value`))),S=!1),this._validateStretch(g.stretchY,E&&E.height)||(this.fire(new i.j(new Error(`Image "${r}" has invalid "stretchY" value`))),S=!1),this._validateContent(g.content,g)||(this.fire(new i.j(new Error(`Image "${r}" has invalid "content" value`))),S=!1),S}_validateStretch(r,g){if(!r)return!0;let S=0;for(const E of r){if(E[0]<S||E[1]<E[0]||g<E[1])return!1;S=E[1]}return!0}_validateContent(r,g){if(!r)return!0;if(r.length!==4)return!1;const S=g.spriteData,E=S&&S.width||g.data.width,A=S&&S.height||g.data.height;return!(r[0]<0||E<r[0]||r[1]<0||A<r[1]||r[2]<0||E<r[2]||r[3]<0||A<r[3]||r[2]<r[0]||r[3]<r[1])}updateImage(r,g,S=!0){const E=this.getImage(r);if(S&&(E.data.width!==g.data.width||E.data.height!==g.data.height))throw new Error(`size mismatch between old image (${E.data.width}x${E.data.height}) and new image (${g.data.width}x${g.data.height}).`);g.version=E.version+1,this.images[r]=g,this.updatedImages[r]=!0}removeImage(r){const g=this.images[r];delete this.images[r],delete this.patterns[r],g.userImage&&g.userImage.onRemove&&g.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(r){return new Promise((g,S)=>{let E=!0;if(!this.isLoaded())for(const A of r)this.images[A]||(E=!1);this.isLoaded()||E?g(this._getImagesForIds(r)):this.requestors.push({ids:r,promiseResolve:g})})}_getImagesForIds(r){const g={};for(const S of r){let E=this.getImage(S);E||(this.fire(new i.k("styleimagemissing",{id:S})),E=this.getImage(S)),E?g[S]={data:E.data.clone(),pixelRatio:E.pixelRatio,sdf:E.sdf,version:E.version,stretchX:E.stretchX,stretchY:E.stretchY,content:E.content,textFitWidth:E.textFitWidth,textFitHeight:E.textFitHeight,hasRenderCallback:!!(E.userImage&&E.userImage.render)}:i.w(`Image "${S}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return g}getPixelSize(){const{width:r,height:g}=this.atlasImage;return{width:r,height:g}}getPattern(r){const g=this.patterns[r],S=this.getImage(r);if(!S)return null;if(g&&g.position.version===S.version)return g.position;if(g)g.position.version=S.version;else{const E={w:S.data.width+2,h:S.data.height+2,x:0,y:0},A=new i.I(E,S);this.patterns[r]={bin:E,position:A}}return this._updatePatternAtlas(),this.patterns[r].position}bind(r){const g=r.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new Q(r,this.atlasImage,g.RGBA),this.atlasTexture.bind(g.LINEAR,g.CLAMP_TO_EDGE)}_updatePatternAtlas(){const r=[];for(const A in this.patterns)r.push(this.patterns[A].bin);const{w:g,h:S}=i.p(r),E=this.atlasImage;E.resize({width:g||1,height:S||1});for(const A in this.patterns){const{bin:ee}=this.patterns[A],se=ee.x+1,he=ee.y+1,_e=this.getImage(A).data,Ie=_e.width,Me=_e.height;i.R.copy(_e,E,{x:0,y:0},{x:se,y:he},{width:Ie,height:Me}),i.R.copy(_e,E,{x:0,y:Me-1},{x:se,y:he-1},{width:Ie,height:1}),i.R.copy(_e,E,{x:0,y:0},{x:se,y:he+Me},{width:Ie,height:1}),i.R.copy(_e,E,{x:Ie-1,y:0},{x:se-1,y:he},{width:1,height:Me}),i.R.copy(_e,E,{x:0,y:0},{x:se+Ie,y:he},{width:1,height:Me})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(r){for(const g of r){if(this.callbackDispatchedThisFrame[g])continue;this.callbackDispatchedThisFrame[g]=!0;const S=this.getImage(g);S||i.w(`Image with ID: "${g}" was not found`),Z(S)&&this.updateImage(g,S)}}}const ce=1e20;function ae(R,r,g,S,E,A,ee,se,he){for(let _e=r;_e<r+S;_e++)ie(R,g*A+_e,A,E,ee,se,he);for(let _e=g;_e<g+E;_e++)ie(R,_e*A+r,1,S,ee,se,he)}function ie(R,r,g,S,E,A,ee){A[0]=0,ee[0]=-ce,ee[1]=ce,E[0]=R[r];for(let se=1,he=0,_e=0;se<S;se++){E[se]=R[r+se*g];const Ie=se*se;do{const Me=A[he];_e=(E[se]-E[Me]+Ie-Me*Me)/(se-Me)/2}while(_e<=ee[he]&&--he>-1);he++,A[he]=se,ee[he]=_e,ee[he+1]=ce}for(let se=0,he=0;se<S;se++){for(;ee[he+1]<se;)he++;const _e=A[he],Ie=se-_e;R[r+se*g]=E[_e]+Ie*Ie}}class de{constructor(r,g){this.requestManager=r,this.localIdeographFontFamily=g,this.entries={}}setURL(r){this.url=r}getGlyphs(r){return i._(this,void 0,void 0,function*(){const g=[];for(const A in r)for(const ee of r[A])g.push(this._getAndCacheGlyphsPromise(A,ee));const S=yield Promise.all(g),E={};for(const{stack:A,id:ee,glyph:se}of S)E[A]||(E[A]={}),E[A][ee]=se&&{id:se.id,bitmap:se.bitmap.clone(),metrics:se.metrics};return E})}_getAndCacheGlyphsPromise(r,g){return i._(this,void 0,void 0,function*(){let S=this.entries[r];
1962S||(S=this.entries[r]={glyphs:{},requests:{},ranges:{}});let E=S.glyphs[g];if(E!==void 0)return{stack:r,id:g,glyph:E};if(E=this._tinySDF(S,r,g),E)return S.glyphs[g]=E,{stack:r,id:g,glyph:E};const A=Math.floor(g/256);if(256*A>65535)throw new Error("glyphs > 65535 not supported");if(S.ranges[A])return{stack:r,id:g,glyph:E};if(!this.url)throw new Error("glyphsUrl is not set");if(!S.requests[A]){const se=de.loadGlyphRange(r,A,this.url,this.requestManager);S.requests[A]=se}const ee=yield S.requests[A];for(const se in ee)this._doesCharSupportLocalGlyph(+se)||(S.glyphs[+se]=ee[+se]);return S.ranges[A]=!0,{stack:r,id:g,glyph:ee[g]||null}})}_doesCharSupportLocalGlyph(r){return!!this.localIdeographFontFamily&&new RegExp("\\p{Ideo}|\\p{sc=Hang}|\\p{sc=Hira}|\\p{sc=Kana}","u").test(String.fromCodePoint(r))}_tinySDF(r,g,S){const E=this.localIdeographFontFamily;if(!E||!this._doesCharSupportLocalGlyph(S))return;let A=r.tinySDF;if(!A){let se="400";/bold/i.test(g)?se="900":/medium/i.test(g)?se="500":/light/i.test(g)&&(se="200"),A=r.tinySDF=new de.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:E,fontWeight:se})}const ee=A.draw(String.fromCharCode(S));return{id:S,bitmap:new i.o({width:ee.width||60,height:ee.height||60},ee.data),metrics:{width:ee.glyphWidth/2||24,height:ee.glyphHeight/2||24,left:ee.glyphLeft/2+.5||0,top:ee.glyphTop/2-27.5||-8,advance:ee.glyphAdvance/2||24,isDoubleResolution:!0}}}}de.loadGlyphRange=function(R,r,g,S){return i._(this,void 0,void 0,function*(){const E=256*r,A=E+255,ee=S.transformRequest(g.replace("{fontstack}",R).replace("{range}",`${E}-${A}`),"Glyphs"),se=yield i.l(ee,new AbortController);if(!se||!se.data)throw new Error(`Could not load glyph range. range: ${r}, ${E}-${A}`);const he={};for(const _e of i.n(se.data))he[_e.id]=_e;return he})},de.TinySDF=class{constructor({fontSize:R=24,buffer:r=3,radius:g=8,cutoff:S=.25,fontFamily:E="sans-serif",fontWeight:A="normal",fontStyle:ee="normal"}={}){this.buffer=r,this.cutoff=S,this.radius=g;const se=this.size=R+4*r,he=this._createCanvas(se),_e=this.ctx=he.getContext("2d",{willReadFrequently:!0});_e.font=`${ee} ${A} ${R}px ${E}`,_e.textBaseline="alphabetic",_e.textAlign="left",_e.fillStyle="black",this.gridOuter=new Float64Array(se*se),this.gridInner=new Float64Array(se*se),this.f=new Float64Array(se),this.z=new Float64Array(se+1),this.v=new Uint16Array(se)}_createCanvas(R){const r=document.createElement("canvas");return r.width=r.height=R,r}draw(R){const{width:r,actualBoundingBoxAscent:g,actualBoundingBoxDescent:S,actualBoundingBoxLeft:E,actualBoundingBoxRight:A}=this.ctx.measureText(R),ee=Math.ceil(g),se=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(A-E))),he=Math.min(this.size-this.buffer,ee+Math.ceil(S)),_e=se+2*this.buffer,Ie=he+2*this.buffer,Me=Math.max(_e*Ie,0),Je=new Uint8ClampedArray(Me),ut={data:Je,width:_e,height:Ie,glyphWidth:se,glyphHeight:he,glyphTop:ee,glyphLeft:0,glyphAdvance:r};if(se===0||he===0)return ut;const{ctx:gt,buffer:St,gridInner:Lt,gridOuter:Vt}=this;gt.clearRect(St,St,se,he),gt.fillText(R,St,St+ee);const Ht=gt.getImageData(St,St,se,he);Vt.fill(ce,0,Me),Lt.fill(0,0,Me);for(let Et=0;Et<he;Et++)for(let Kt=0;Kt<se;Kt++){const ss=Ht.data[4*(Et*se+Kt)+3]/255;if(ss===0)continue;const cs=(Et+St)*_e+Kt+St;if(ss===1)Vt[cs]=0,Lt[cs]=ce;else{const As=.5-ss;Vt[cs]=As>0?As*As:0,Lt[cs]=As<0?As*As:0}}ae(Vt,0,0,_e,Ie,_e,this.f,this.v,this.z),ae(Lt,St,St,se,he,_e,this.f,this.v,this.z);for(let Et=0;Et<Me;Et++){const Kt=Math.sqrt(Vt[Et])-Math.sqrt(Lt[Et]);Je[Et]=Math.round(255-255*(Kt/this.radius+this.cutoff))}return ut}};class ge{constructor(){this.specification=i.v.light.position}possiblyEvaluate(r,g){return i.x(r.expression.evaluate(g))}interpolate(r,g,S){return{x:i.y.number(r.x,g.x,S),y:i.y.number(r.y,g.y,S),z:i.y.number(r.z,g.z,S)}}}let We;class Ee extends i.E{constructor(r){super(),We=We||new i.q({anchor:new i.D(i.v.light.anchor),position:new ge,color:new i.D(i.v.light.color),intensity:new i.D(i.v.light.intensity)}),this._transitionable=new i.T(We),this.setLight(r),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(r,g={}
vendor: 4,706 bytes, line 1962
1962){if(!this._validate(i.r,r,g))for(const S in r){const E=r[S];S.endsWith("-transition")?this._transitionable.setTransition(S.slice(0,-11),E):this._transitionable.setValue(S,E)}}updateTransitions(r){this._transitioning=this._transitionable.transitioned(r,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(r){this.properties=this._transitioning.possiblyEvaluate(r)}_validate(r,g,S){return(!S||S.validate!==!1)&&i.t(this,r.call(i.u,{value:g,style:{glyphs:!0,sprite:!0},styleSpec:i.v}))}}const ve=new i.q({"sky-color":new i.D(i.v.sky["sky-color"]),"horizon-color":new i.D(i.v.sky["horizon-color"]),"fog-color":new i.D(i.v.sky["fog-color"]),"fog-ground-blend":new i.D(i.v.sky["fog-ground-blend"]),"horizon-fog-blend":new i.D(i.v.sky["horizon-fog-blend"]),"sky-horizon-blend":new i.D(i.v.sky["sky-horizon-blend"]),"atmosphere-blend":new i.D(i.v.sky["atmosphere-blend"])});class we extends i.E{constructor(r){super(),this._transitionable=new i.T(ve),this.setSky(r),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new i.z(0))}setSky(r,g={}){if(!this._validate(i.B,r,g)){r||(r={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const S in r){const E=r[S];S.endsWith("-transition")?this._transitionable.setTransition(S.slice(0,-11),E):this._transitionable.setValue(S,E)}}}getSky(){return this._transitionable.serialize()}updateTransitions(r){this._transitioning=this._transitionable.transitioned(r,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(r){this.properties=this._transitioning.possiblyEvaluate(r)}_validate(r,g,S={}){return(S==null?void 0:S.validate)!==!1&&i.t(this,r.call(i.u,i.e({value:g,style:{glyphs:!0,sprite:!0},styleSpec:i.v})))}calculateFogBlendOpacity(r){return r<60?0:r<70?(r-60)/10:1}}class Ze{constructor(r,g){this.width=r,this.height=g,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(r,g){const S=r.join(",")+String(g);return this.dashEntry[S]||(this.dashEntry[S]=this.addDash(r,g)),this.dashEntry[S]}getDashRanges(r,g,S){const E=[];let A=r.length%2==1?-r[r.length-1]*S:0,ee=r[0]*S,se=!0;E.push({left:A,right:ee,isDash:se,zeroLength:r[0]===0});let he=r[0];for(let _e=1;_e<r.length;_e++){se=!se;const Ie=r[_e];A=he*S,he+=Ie,ee=he*S,E.push({left:A,right:ee,isDash:se,zeroLength:Ie===0})}return E}addRoundDash(r,g,S){const E=g/2;for(let A=-S;A<=S;A++){const ee=this.width*(this.nextRow+S+A);let se=0,he=r[se];for(let _e=0;_e<this.width;_e++){_e/he.right>1&&(he=r[++se]);const Ie=Math.abs(_e-he.left),Me=Math.abs(_e-he.right),Je=Math.min(Ie,Me);let ut;const gt=A/S*(E+1);if(he.isDash){const St=E-Math.abs(gt);ut=Math.sqrt(Je*Je+St*St)}else ut=E-Math.sqrt(Je*Je+gt*gt);this.data[ee+_e]=Math.max(0,Math.min(255,ut+128))}}}addRegularDash(r){for(let se=r.length-1;se>=0;--se){const he=r[se],_e=r[se+1];he.zeroLength?r.splice(se,1):_e&&_e.isDash===he.isDash&&(_e.left=he.left,r.splice(se,1))}const g=r[0],S=r[r.length-1];g.isDash===S.isDash&&(g.left=S.left-this.width,S.right=g.right+this.width);const E=this.width*this.nextRow;let A=0,ee=r[A];for(let se=0;se<this.width;se++){se/ee.right>1&&(ee=r[++A]);const he=Math.abs(se-ee.left),_e=Math.abs(se-ee.right),Ie=Math.min(he,_e);this.data[E+se]=Math.max(0,Math.min(255,(ee.isDash?Ie:-Ie)+128))}}addDash(r,g){const S=g?7:0,E=2*S+1;if(this.nextRow+E>this.height)return i.w("LineAtlas out of space"),null;let A=0;for(let se=0;se<r.length;se++)A+=r[se];if(A!==0){const se=this.width/A,he=this.getDashRanges(r,this.width,se);g?this.addRoundDash(he,se,S):this.addRegularDash(he)}const ee={y:(this.nextRow+S+.5)/this.height,height:2*S/this.height,width:A};return this.nextRow+=E,this.dirty=!0,ee}bind(r){const g=r.gl;this.texture?(g.bindTexture(g.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,g.texSubImage2D(g.TEXTURE_2D,0,0,0,this.width,this.height,g.ALPHA,g.UNSIGNED_BYTE,this.data))):(this.texture=g.createTexture(),g.bindTexture(g.TEXTURE_2D,this.texture),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_S,g.REPEAT),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_T,g.REPEAT),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MIN_FILTER,g.LINEAR),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MAG_FILTER,g.LINEAR),g.texImage2D(g.TEXTURE_2D,0,g.ALPHA,this.width,this.height,0,g.ALPHA,g.UNSIGNED_BYTE,this.data))}}const ke="maplibre_preloaded_worker_pool";class ze{constructor(){this.active={}}acquire(r){if(!this.workers)for(this.workers=[];this.workers.length<ze.workerCount;)this.workers.push(new Worker(i.a.WORKER_URL));return this.active[r]=!0,this.workers.slice()}release(r){delete this.active[r],this.numActive()===0&&(this.workers.forEac
1962h(g=>{g.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[ke]}numActive(){return Object.keys(this.active).length}}const Ke=Math.floor(x.hardwareConcurrency/2);let dt,Re;function qt(){return dt||(dt=new ze),dt}ze.workerCount=i.C(globalThis)?Math.max(Math.min(Ke,3),1):1;class ft{constructor(r,g){this.workerPool=r,this.actors=[],this.currentActor=0,this.id=g;const S=this.workerPool.acquire(g);for(let E=0;E<S.length;E++){const A=new i.F(S[E],g);A.name=`Worker ${E}`,this.actors.push(A)}if(!this.actors.length)throw new Error("No actors found")}broadcast(r,g){const S=[];for(const E of this.actors)S.push(E.sendAsync({type:r,data:g}));return Promise.all(S)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(r=!0){this.actors.forEach(g=>{g.remove()}),this.actors=[],r&&this.workerPool.release(this.id)}registerMessageHandler(r,g){for(const S of this.actors)S.registerMessageHandler(r,g)}}function Fe(){return Re||(Re=new ft(qt(),i.G),Re.registerMessageHandler("GR",(R,r,g)=>i.m(r,g))),Re}function fe(R,r){const g=i.H();return i.J(g,g,[1,1,0]),i.K(g,g,[.5*R.width,.5*R.height,1]),i.L(g,g,R.calculatePosMatrix(r.toUnwrapped()))}function Qe(R,r,g,S,E,A){const ee=function(Me,Je,ut){if(Me)for(const gt of Me){const St=Je[gt];if(St&&St.source===ut&&St.type==="fill-extrusion")return!0}else for(const gt in Je){const St=Je[gt];if(St.source===ut&&St.type==="fill-extrusion")return!0}return!1}(E&&E.layers,r,R.id),se=A.maxPitchScaleFactor(),he=R.tilesIn(S,se,ee);he.sort(ht);const _e=[];for(const Me of he)_e.push({wrappedTileID:Me.tileID.wrapped().key,queryResults:Me.tile.queryRenderedFeatures(r,g,R._state,Me.queryGeometry,Me.cameraQueryGeometry,Me.scale,E,A,se,fe(R.transform,Me.tileID))});const Ie=function(Me){const Je={},ut={};for(const gt of Me){const St=gt.queryResults,Lt=gt.wrappedTileID,Vt=ut[Lt]=ut[Lt]||{};for(const Ht in St){const Et=St[Ht],Kt=Vt[Ht]=Vt[Ht]||{},ss=Je[Ht]=Je[Ht]||[];for(const cs of Et)Kt[cs.featureIndex]||(Kt[cs.featureIndex]=!0,ss.push(cs))}}return Je}(_e);for(const Me in Ie)Ie[Me].forEach(Je=>{const ut=Je.feature,gt=R.getFeatureState(ut.layer["source-layer"],ut.id);ut.source=ut.layer.source,ut.layer["source-layer"]&&(ut.sourceLayer=ut.layer["source-layer"]),ut.state=gt});return Ie}function ht(R,r){const g=R.tileID,S=r.tileID;return g.overscaledZ-S.overscaledZ||g.canonical.y-S.canonical.y||g.wrap-S.wrap||g.canonical.x-S.canonical.x}function _t(R,r,g){return i._(this,void 0,void 0,function*(){let S=R;if(R.url?S=(yield i.h(r.transformRequest(R.url,"Source"),g)).data:yield x.frameAsync(g),!S)return null;const E=i.M(i.e(S,R),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in S&&S.vector_layers&&(E.vectorLayerIds=S.vector_layers.map(A=>A.id)),E})}class He{constructor(r,g){r&&(g?this.setSouthWest(r).setNorthEast(g):Array.isArray(r)&&(r.length===4?this.setSouthWest([r[0],r[1]]).setNorthEast([r[2],r[3]]):this.setSouthWest(r[0]).setNorthEast(r[1])))}setNorthEast(r){return this._ne=r instanceof i.N?new i.N(r.lng,r.lat):i.N.convert(r),this}setSouthWest(r){return this._sw=r instanceof i.N?new i.N(r.lng,r.lat):i.N.convert(r),this}extend(r){const g=this._sw,S=this._ne;let E,A;if(r instanceof i.N)E=r,A=r;else{if(!(r instanceof He))return Array.isArray(r)?r.length===4||r.every(Array.isArray)?this.extend(He.convert(r)):this.extend(i.N.convert(r)):r&&("lng"in r||"lon"in r)&&"lat"in r?this.extend(i.N.convert(r)):this;if(E=r._sw,A=r._ne,!E||!A)return this}return g||S?(g.lng=Math.min(E.lng,g.lng),g.lat=Math.min(E.lat,g.lat),S.lng=Math.max(A.lng,S.lng),S.lat=Math.max(A.lat,S.lat)):(this._sw=new i.N(E.lng,E.lat),this._ne=new i.N(A.lng,A.lat)),this}getCenter(){return new i.N((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new i.N(this.getWest(),this.getNorth())}getSouthEast(){return new i.N(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(r){const{lng:g,lat:S}=i.N.convert(r);let E=this._sw.lng<=g&&g<=this._ne.lng;return this._sw.lng>this._ne.lng&&(E=this._sw.lng>=g&&g>=this._ne.lng),this._sw.lat<=S&&S<=this._ne.lat&&E}static convert(r){return r instanceof He?r:r&&new He(r)}static fromLngLat(r,g=0){const S=360*g/40075017,E=S/Math.cos(Math.PI/180*r.lat);return new He(new i.N(r.lng-E,r.lat-S),new i.N(r.lng+E,r.lat+S))}adjustAntiMeridian(){const r=new i.N(this._sw.lng,this._sw.lat),g=new i.N(this._ne.lng,this._ne.lat);return new He(r,r.lng>g.lng?new i.N(g.lng+360,g.lat):g)}}class as{constructor(r,g,S){this.bounds=He.convert(this.validateBounds(r)),this.minzoom=g||0,this.maxzoom=S||24}
1962validateBounds(r){return Array.isArray(r)&&r.length===4?[Math.max(-180,r[0]),Math.max(-90,r[1]),Math.min(180,r[2]),Math.min(90,r[3])]:[-180,-90,180,90]}contains(r){const g=Math.pow(2,r.z),S=Math.floor(i.O(this.bounds.getWest())*g),E=Math.floor(i.Q(this.bounds.getNorth())*g),A=Math.ceil(i.O(this.bounds.getEast())*g),ee=Math.ceil(i.Q(this.bounds.getSouth())*g);return r.x>=S&&r.x<A&&r.y>=E&&r.y<ee}}class vt extends i.E{constructor(r,g,S,E){if(super(),this.id=r,this.dispatcher=S,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.e(this,i.M(g,["url","scheme","tileSize","promoteId"])),this._options=i.e({type:"vector"},g),this._collectResourceTiming=g.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(E)}load(){return i._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new i.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const r=yield _t(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),r&&(i.e(this,r),r.bounds&&(this.tileBounds=new as(r.bounds,this.minzoom,this.maxzoom)),this.fire(new i.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.k("data",{dataType:"source",sourceDataType:"content"})))}catch(r){this._tileJSONRequest=null,this.fire(new i.j(r))}})}loaded(){return this._loaded}hasTile(r){return!this.tileBounds||this.tileBounds.contains(r.canonical)}onAdd(r){this.map=r,this.load()}setSourceProperty(r){this._tileJSONRequest&&this._tileJSONRequest.abort(),r(),this.load()}setTiles(r){return this.setSourceProperty(()=>{this._options.tiles=r}),this}setUrl(r){return this.setSourceProperty(()=>{this.url=r,this._options.url=r}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return i.e({},this._options)}loadTile(r){return i._(this,void 0,void 0,function*(){const g=r.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),S={request:this.map._requestManager.transformRequest(g,"Tile"),uid:r.uid,tileID:r.tileID,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.t
1962ype,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};S.request.collectResourceTiming=this._collectResourceTiming;let E="RT";if(r.actor&&r.state!=="expired"){if(r.state==="loading")return new Promise((A,ee)=>{r.reloadPromise={resolve:A,reject:ee}})}else r.actor=this.dispatcher.getActor(),E="LT";r.abortController=new AbortController;try{const A=yield r.actor.sendAsync({type:E,data:S},r.abortController);if(delete r.abortController,r.aborted)return;this._afterTileLoadWorkerResponse(r,A)}catch(A){if(delete r.abortController,r.aborted)return;if(A&&A.status!==404)throw A;this._afterTileLoadWorkerResponse(r,null)}})}_afterTileLoadWorkerResponse(r,g){if(g&&g.resourceTiming&&(r.resourceTiming=g.resourceTiming),g&&this.map._refreshExpiredTiles&&r.setExpiryData(g),r.loadVectorData(g,this.map.painter),r.reloadPromise){const S=r.reloadPromise;r.reloadPromise=null,this.loadTile(r).then(S.resolve).catch(S.reject)}}abortTile(r){return i._(this,void 0,void 0,function*(){r.abortController&&(r.abortController.abort(),delete r.abortController),r.actor&&(yield r.actor.sendAsync({type:"AT",data:{uid:r.uid,type:this.t
1962ype,source:this.id}}))})}unloadTile(r){return i._(this,void 0,void 0,function*(){r.unloadVectorData(),r.actor&&(yield r.actor.sendAsync({type:"RMT",data:{uid:r.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class Xe extends i.E{constructor(r,g,S,E){super(),this.id=r,this.dispatcher=S,this.setEventedParent(E),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=i.e({type:"raster"},g),i.e(this,i.M(g,["url","scheme","tileSize"]))}load(){return i._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new i.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const r=yield _t(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,r&&(i.e(this,r),r.bounds&&(this.tileBounds=new as(r.bounds,this.minzoom,this.maxzoom)),this.fire(new i.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.k("data",{dataType:"source",sourceDataType:"content"})))}catch(r){this._tileJSONRequest=null,this.fire(new i.j(r))}})}loaded(){return this._loaded}onAdd(r){this.map=r,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(r){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),r(),this.load()}setTiles(r){return this.setSourceProperty(()=>{this._options.tiles=r}),this}setUrl(r){return this.setSourceProperty(()=>{this.url=r,this._options.url=r}),this}serialize(){return i.e({},this._options)}hasTile(r){return!this.tileBounds||this.tileBounds.contains(r.canonical)}loadTile(r){return i._(this,void 0,void 0,function*(){const g=r.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);r.abortController=new AbortController;try{const S=yield X.getImage(this.map._requestManager.transformRequest(g,"Tile"),r.abortController,this.map._refreshExpiredTiles);if(delete r.abortController,r.aborted)return void(r.state="unloaded");if(S&&S.data){this.map._refreshExpiredTiles&&S.cacheControl&&S.expires&&r.setExpiryData({cacheControl:S.cacheControl,expires:S.expires});const E=this.map.painter.context,A=E.gl,ee=S.data;r.texture=this.map.painter.getTileTexture(ee.width),r.texture?r.texture.update(ee,{useMipmap:!0}):(r.texture=new Q(E,ee,A.RGBA,{useMipmap:!0}),r.texture.bind(A.LINEAR,A.CLAMP_TO_EDGE,A.LINEAR_MIPMAP_NEAREST)),r.state="loaded"}}catch(S){if(delete r.abortController,r.aborted)r.state="unloaded";else if(S)throw r.state="errored",S}})}abortTile(r){return i._(this,void 0,void 0,function*(){r.abortController&&(r.abortController.abort(),delete r.abortController)})}unloadTile(r){return i._(this,void 0,void 0,function*(){r.texture&&this.map.painter.saveTileTexture(r.texture)})}hasTransition(){return!1}}class Ce extends Xe{constructor(r,g,S,E){super(r,g,S,E),this.type="raster-dem",this.maxzoom=22,this._options=i.e({type:"raster-dem"},g),this.encoding=g.encoding||"mapbox",this.redFactor=g.redFactor,this.greenFactor=g.greenFactor,this.blueFactor=g.blueFactor,this.baseShift=g.baseShift}loadTile(r){return i._(this,void 0,void 0,function*(){const g=r.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),S=this.map._requestManager.transformRequest(g,"Tile");r.neighboringTiles=this._getNeighboringTiles(r.tileID),r.abortController=new AbortController;try{const E=yield X.getImage(S,r.abortController,this.map._refreshExpiredTiles);if(delete r.abortController,r.aborted)return void(r.state="unloaded");if(E&&E.data){const A=E.data;this.map._refreshExpiredTiles&&E.cacheControl&&E.expires&&r.setExpiryData({cacheControl:E.cacheControl,expires:E.expires});const ee=i.b(A)&&i.U()?A:yield this.readImageNow(A),se={type:this.type,uid:r.uid,source:this.id,rawImageData:ee,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!r.actor||r.state==="expired"){r.actor=this.dispatcher.getActor();const he=yield r.actor.sendAsync({type:"LDT",data:se});r.dem=he,r.needsHillshadePrepare=!0,r.needsTerrainPrepare=!0,r.state="loaded"}}}
1962catch(E){if(delete r.abortController,r.aborted)r.state="unloaded";else if(E)throw r.state="errored",E}})}readImageNow(r){return i._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&i.V()){const g=r.width+2,S=r.height+2;try{return new i.R({width:g,height:S},yield i.W(r,-1,-1,g,S))}catch{}}return x.getImageData(r,1)})}_getNeighboringTiles(r){const g=r.canonical,S=Math.pow(2,g.z),E=(g.x-1+S)%S,A=g.x===0?r.wrap-1:r.wrap,ee=(g.x+1+S)%S,se=g.x+1===S?r.wrap+1:r.wrap,he={};return he[new i.S(r.overscaledZ,A,g.z,E,g.y).key]={backfilled:!1},he[new i.S(r.overscaledZ,se,g.z,ee,g.y).key]={backfilled:!1},g.y>0&&(he[new i.S(r.overscaledZ,A,g.z,E,g.y-1).key]={backfilled:!1},he[new i.S(r.overscaledZ,r.wrap,g.z,g.x,g.y-1).key]={backfilled:!1},he[new i.S(r.overscaledZ,se,g.z,ee,g.y-1).key]={backfilled:!1}),g.y+1<S&&(he[new i.S(r.overscaledZ,A,g.z,E,g.y+1).key]={backfilled:!1},he[new i.S(r.overscaledZ,r.wrap,g.z,g.x,g.y+1).key]={backfilled:!1},he[new i.S(r.overscaledZ,se,g.z,ee,g.y+1).key]={backfilled:!1}),he}unloadTile(r){return i._(this,void 0,void 0,function*(){r.demTexture&&this.map.painter.saveTileTexture(r.demTexture),r.fbo&&(r.fbo.destroy(),delete r.fbo),r.dem&&delete r.dem,delete r.neighboringTiles,r.state="unloaded",r.actor&&(yield r.actor.sendAsync({type:"RDT",data:{type:this.type,uid:r.uid,source:this.id}}))})}}class Be extends i.E{constructor(r,g,S,E){super(),this.id=r,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._pendingLoads=0,this.actor=S.getActor(),this.setEventedParent(E),this._data=g.data,this._options=i.e({},g),this._collectResourceTiming=g.collectResourceTiming,g.maxzoom!==void 0&&(this.maxzoom=g.maxzoom),g.type&&(this.type=g.type),g.attribution&&(this.attribution=g.attribution),this.promoteId=g.promoteId;const A=i.X/this.tileSize;
1962g.clusterMaxZoom!==void 0&&this.maxzoom<=g.clusterMaxZoom&&i.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${g.clusterMaxZoom}".`),this.workerOptions=i.e({source:this.id,cluster:g.cluster||!1,geojsonVtOptions:{buffer:(g.buffer!==void 0?g.buffer:128)*A,tolerance:(g.tolerance!==void 0?g.tolerance:.375)*A,extent:i.X,maxZoom:this.maxzoom,lineMetrics:g.lineMetrics||!1,generateId:g.generateId||!1},superclusterOptions:{maxZoom:g.clusterMaxZoom!==void 0?g.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,g.clusterMinPoints||2),extent:i.X,radius:(g.clusterRadius||50)*A,log:!1,generateId:g.generateId||!1},clusterProperties:g.clusterProperties,filter:g.filter},g.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}load(){return i._(this,void 0,void 0,function*(){yield this._updateWorkerData()})}onAdd(r){this.map=r,this.load()}setData(r){return this._data=r,this._updateWorkerData(),this}updateData(r){return this._updateWorkerData(r),this}getData(){return i._(this,void 0,void 0,function*(){const r=i.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:r})})}setClusterOptions(r){return this.workerOptions.cluster=r.cluster,r&&(r.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=r.clusterRadius),r.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=r.clusterMaxZoom)),this._updateWorkerData(),this}getClusterExpansionZoom(r){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:r,source:this.id}})}getClusterChildren(r){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:r,source:this.id}})}getClusterLeaves(r,g,S){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:r,limit:g,offset:S}})}_updateWorkerData(r){return i._(this,void 0,void 0,function*(){const g=i.e({type:this.type},this.workerOptions);
1962r?g.dataDiff=r:typeof this._data=="string"?(g.request=this.map._requestManager.transformRequest(x.resolveURL(this._data),"Source"),g.request.collectResourceTiming=this._collectResourceTiming):g.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new i.k("dataloading",{dataType:"source"}));try{const S=yield this.actor.sendAsync({type:"LD",data:g});if(this._pendingLoads--,this._removed||S.abandoned)return void this.fire(new i.k("dataabort",{dataType:"source"}));let E=null;S.resourceTiming&&S.resourceTiming[this.id]&&(E=S.resourceTiming[this.id].slice(0));const A={dataType:"source"};this._collectResourceTiming&&E&&E.length>0&&i.e(A,{resourceTiming:E}),this.fire(new i.k("data",Object.assign(Object.assign({},A),{sourceDataType:"metadata"}))),this.fire(new i.k("data",Object.assign(Object.assign({},A),{sourceDataType:"content"})))}catch(S){if(this._pendingLoads--,this._removed)return void this.fire(new i.k("dataabort",{dataType:"source"}));this.fire(new i.j(S))}})}loaded(){return this._pendingLoads===0}loadTile(r){return i._(this,void 0,void 0,function*(){const g=r.actor?"RT":"LT";r.actor=this.actor;const S={type:this.type,uid:r.uid,tileID:r.tileID,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};r.abortController=new AbortController;const E=yield this.actor.sendAsync({type:g,data:S},r.abortController);delete r.abortController,r.unloadVectorData(),r.aborted||r.loadVectorData(E,this.map.painter,g==="RT")})}abortTile(r){return i._(this,void 0,void 0,function*(){r.abortController&&(r.abortController.abort(),delete r.abortController),r.aborted=!0})}unloadTile(r){return i._(this,void 0,void 0,function*(){r.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:r.uid,type:this.t
1962ype,source:this.id}})})}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return i.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var Dt=i.Y([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Rt extends i.E{constructor(r,g,S,E){super(),this.id=r,this.dispatcher=S,this.coordinates=g.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(E),this.options=g}load(r){return i._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new i.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const g=yield X.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,g&&g.data&&(this.image=g.data,r&&(this.coordinates=r),this._finishLoading())}catch(g){this._request=null,this._loaded=!0,this.fire(new i.j(g))}})}loaded(){return this._loaded}updateImage(r){return r.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=r.url,this.load(r.coordinates).finally(()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.k("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(r){this.map=r,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(r){this.coordinates=r;const g=r.map(i.Z.fromLngLat);this.tileID=function(E){let A=1/0,ee=1/0,se=-1/0,he=-1/0;for(const Je of E)A=Math.min(A,Je.x),ee=Math.min(ee,Je.y),se=Math.max(se,Je.x),he=Math.max(he,Je.y);const _e=Math.max(se-A,he-ee),Ie=Math.max(0,Math.floor(-Math.log(_e)/Math.LN2)),Me=Math.pow(2,Ie);return new i.a1(Ie,Math.floor((A+se)/2*Me),Math.floor((ee+he)/2*Me))}(g),this.minzoom=this.maxzoom=this.tileID.z;const S=g.map(E=>this.tileID.getTilePoint(E)._round());return this._boundsArray=new i.$,this._boundsArray.emplaceBack(S[0].x,S[0].y,0,0),this._boundsArray.emplaceBack(S[1].x,S[1].y,i.X,0),this._boundsArray.emplaceBack(S[3].x,S[3].y,0,i.X),this._boundsArray.emplaceBack(S[2].x,S[2].y,i.X,i.X),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new i.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const r=this.map.painter.context,g=r.gl;this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,Dt.members)),this.boundsSegments||(this.boundsSegments=i.a0.simpleSegment(0,0,4,2)),this.texture||(this.texture=new Q(r,this.image,g.RGBA),this.texture.bind(g.LINEAR,g.CLAMP_TO_EDGE));let S=!1;for(const E in this.tiles){const A=this.tiles[E];A.state!=="loaded"&&(A.state="loaded",A.texture=this.texture,S=!0)}S&&this.fire(new i.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(r){return i._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(r.tileID.canonical)?(this.tiles[String(r.tileID.wrap)]=r,r.buckets={}):r.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class zt extends Rt{constructor(r,g,S,E){super(r,g,S,E),this.roundZoom=!0,this.type="video",this.options=g}load(){return i._(this,void 0,void 0,function*(){this._loaded=!1;const r=this.options;this.urls=[];for(const g of r.urls)this.urls.push(this.map._requestManager.transformRequest(g,"Source").url);try{const g=yield i.a3(this.urls);if(this._loaded=!0,!g)return;this.video=g,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(g){this.fire(new i.j(g))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(r){if(this.video){const g=this.video.seekable;r<g.start(0)||r>g.end(0)?this.fire(new i.j(new i.a2(`sources.${this.id}`,null,`Playback for this video can be set only between the ${g.start(0)} and ${g.end(0)}-second mark.`))):this.video.currentTime=r}}getVideo(){return this.video}
1962onAdd(r){this.map||(this.map=r,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const r=this.map.painter.context,g=r.gl;this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,Dt.members)),this.boundsSegments||(this.boundsSegments=i.a0.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(g.LINEAR,g.CLAMP_TO_EDGE),g.texSubImage2D(g.TEXTURE_2D,0,0,0,g.RGBA,g.UNSIGNED_BYTE,this.video)):(this.texture=new Q(r,this.video,g.RGBA),this.texture.bind(g.LINEAR,g.CLAMP_TO_EDGE));let S=!1;for(const E in this.tiles){const A=this.tiles[E];A.state!=="loaded"&&(A.state="loaded",A.texture=this.texture,S=!0)}S&&this.fire(new i.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class rs extends Rt{constructor(r,g,S,E){super(r,g,S,E),g.coordinates?Array.isArray(g.coordinates)&&g.coordinates.length===4&&!g.coordinates.some(A=>!Array.isArray(A)||A.length!==2||A.some(ee=>typeof ee!="number"))||this.fire(new i.j(new i.a2(`sources.${r}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.j(new i.a2(`sources.${r}`,null,'missing required property "coordinates"'))),g.animate&&typeof g.animate!="boolean"&&this.fire(new i.j(new i.a2(`sources.${r}`,null,'optional "animate" property must be a boolean value'))),g.canvas?typeof g.canvas=="string"||g.canvas instanceof HTMLCanvasElement||this.fire(new i.j(new i.a2(`sources.${r}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new i.j(new i.a2(`sources.${r}`,null,'missing required property "canvas"'))),this.options=g,this.animate=g.animate===void 0||g.animate}load(){return i._(this,void 0,void 0,function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())})}getCanvas(){return this.canvas}onAdd(r){this.map=r,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let r=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,r=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,r=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const g=this.map.painter.context,S=g.gl;this.boundsBuffer||(this.boundsBuffer=g.createVertexBuffer(this._boundsArray,Dt.members)),this.boundsSegments||(this.boundsSegments=i.a0.simpleSegment(0,0,4,2)),this.texture?(r||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Q(g,this.canvas,S.RGBA,{premultiply:!0});let E=!1;for(const A in this.tiles){const ee=this.tiles[A];ee.state!=="loaded"&&(ee.state="loaded",ee.texture=this.texture,E=!0)}E&&this.fire(new i.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const r of[this.canvas.width,this.canvas.height])if(isNaN(r)||r<=0)return!0;return!1}}const _s={},vs=R=>{switch(R){case"geojson":return Be;case"image":return Rt;case"raster":return Xe;case"raster-dem":return Ce;case"vector":return vt;case"video":return zt;case"canvas":return rs}return _s[R]},$t="RTLPluginLoaded";class Ns extends i.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=Fe()}_syncState(r){return this.status=r,this.dispatcher.broadcast("SRPS",{pluginStatus:r,pluginURL:this.url}).catch(g=>{throw this.status="error",g})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(r){return i._(this,arguments,void 0,function*(g,S=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=x.resolveURL(g),!this.url)throw new Error(`requested url ${g}
1962 is invalid`);if(this.status==="unavailable"){if(!S)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()})}_requestImport(){return i._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new i.k($t))})}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let Ts=null;function bs(){return Ts||(Ts=new Ns),Ts}class en{constructor(r,g){this.timeAdded=0,this.fadeEndTime=0,this.tileID=r,this.uid=i.a4(),this.uses=0,this.tileSize=g,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(r){const g=r+this.timeAdded;g<this.fadeEndTime||(this.fadeEndTime=g)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(r){this.demTexture&&r.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(r,g,S){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",r){r.featureIndex&&(this.latestFeatureIndex=r.featureIndex,r.rawTileData?(this.latestRawTileData=r.rawTileData,this.latestFeatureIndex.rawTileData=r.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=r.collisionBoxArray,this.buckets=function(E,A){const ee={};if(!A)return ee;for(const se of E){const he=se.layerIds.map(_e=>A.getLayer(_e)).filter(Boolean);if(he.length!==0){se.layers=he,se.stateDependentLayerIds&&(se.stateDependentLayers=se.stateDependentLayerIds.map(_e=>he.filter(Ie=>Ie.id===_e)[0]));for(const _e of he)ee[_e.id]=se}}return ee}(r.buckets,g.style),this.hasSymbolBuckets=!1;for(const E in this.buckets){const A=this.buckets[E];if(A instanceof i.a6){if(this.hasSymbolBuckets=!0,!S)break;A.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const E in this.buckets){const A=this.buckets[E];if(A instanceof i.a6&&A.hasRTLText){this.hasRTLText=!0,bs().lazyLoad();break}}this.queryPadding=0;for(const E in this.buckets){const A=this.buckets[E];this.queryPadding=Math.max(this.queryPadding,g.style.getLayer(E).queryRadius(A))}r.imageAtlas&&(this.imageAtlas=r.imageAtlas),r.glyphAtlasImage&&(this.glyphAtlasImage=r.glyphAtlasImage)}else this.collisionBoxArray=new i.a5}unloadVectorData(){for(const r in this.buckets)this.buckets[r].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(r){return this.buckets[r.id]}upload(r){for(const S in this.buckets){const E=this.buckets[S];E.uploadPending()&&E.upload(r)}const g=r.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Q(r,this.imageAtlas.image,g.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Q(r,this.glyphAtlasImage,g.ALPHA),this.glyphAtlasImage=null)}prepare(r){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(r,this.imageAtlasTexture)}queryRenderedFeatures(r,g,S,E,A,ee,se,he,_e,Ie){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:E,cameraQueryGeometry:A,scale:ee,tileSize:this.tileSize,pixelPosMatrix:Ie,transform:he,params:se,queryPadding:this.queryPadding*_e},r,g,S):{}}querySourceFeatures(r,g){const S=this.latestFeatureIndex;if(!S||!S.rawTileData)return;const E=S.loadVTLayers(),A=g&&g.sourceLayer?g.sourceLayer:"",ee=E._geojsonTileLayer||E[A];if(!ee)return;const se=i.a7(g&&g.filter),{z:he,x:_e,y:Ie}=this.tileID.canonical,Me={z:he,x:_e,y:Ie};for(let Je=0;Je<ee.length;Je++){const ut=ee.feature(Je);if(se.needGeometry){const Lt=i.a8(ut,!0);if(!se.filter(new i.z(this.tileID.overscaledZ),Lt,this.tileID.canonical))continue}else if(!se.filter(new i.z(this.tileID.overscaledZ),ut))continue;const gt=S.getId(ut,A),St=new i.a9(ut,he,_e,Ie,gt);St.tile=Me,r.push(St)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(r){const g=this.expirationTime;if(r.cacheControl){const S=i.aa(r.cacheControl);S["max-age"]&&(this.expirationTime=Date.now()+1e3*S["max-age"])}else r.expires&&(this.expirationTime=new Date(r.expires).getTime());if(this.expirationTime){const S=Date.now();let E=!1;if(this.expirationTime>S)E=!1;else if(g)if(this.expirationTime<g)E=!0;else{const A=this.expirationTime-g;A?this.expirationTime=S+Math.max(A,3e4):E=!0}else E=!0;E?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(r,g){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(r).length===0)return;const S=this.latestFeatureIndex.loadVTLayers();for(const E in this.buckets){if(!g.style.hasLayer(E))continue;const A=this.buckets[E],ee=A.layers[0].sourceLayer||"_geojsonTileLayer",se=S[ee],he=r[ee];if(!se||!he||Object.keys(he).length===0)continue;A.update(he,se,this.imageAtlas&&this.imageAtlas.patternPositions||{});const _e=g&&g.style&&g.style.getLayer(E);_e&&(this.queryPadding=Math.max(this.queryPadding,_e.queryRadius(A)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<x.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(r){this.symbolFadeHoldUntil=x.now()+r}
vendor: 4,282 bytes, line 1962
1962setDependencies(r,g){const S={};for(const E of g)S[E]=!0;this.dependencies[r]=S}hasDependency(r,g){for(const S of r){const E=this.dependencies[S];if(E){for(const A of g)if(E[A])return!0}}return!1}}class Jt{constructor(r,g){this.max=r,this.onRemove=g,this.reset()}reset(){for(const r in this.data)for(const g of this.data[r])g.timeout&&clearTimeout(g.timeout),this.onRemove(g.value);return this.data={},this.order=[],this}add(r,g,S){const E=r.wrapped().key;this.data[E]===void 0&&(this.data[E]=[]);const A={value:g,timeout:void 0};if(S!==void 0&&(A.timeout=setTimeout(()=>{this.remove(r,A)},S)),this.data[E].push(A),this.order.push(E),this.order.length>this.max){const ee=this._getAndRemoveByKey(this.order[0]);ee&&this.onRemove(ee)}return this}has(r){return r.wrapped().key in this.data}getAndRemove(r){return this.has(r)?this._getAndRemoveByKey(r.wrapped().key):null}_getAndRemoveByKey(r){const g=this.data[r].shift();return g.timeout&&clearTimeout(g.timeout),this.data[r].length===0&&delete this.data[r],this.order.splice(this.order.indexOf(r),1),g.value}getByKey(r){const g=this.data[r];return g?g[0].value:null}get(r){return this.has(r)?this.data[r.wrapped().key][0].value:null}remove(r,g){if(!this.has(r))return this;const S=r.wrapped().key,E=g===void 0?0:this.data[S].indexOf(g),A=this.data[S][E];return this.data[S].splice(E,1),A.timeout&&clearTimeout(A.timeout),this.data[S].length===0&&delete this.data[S],this.onRemove(A.value),this.order.splice(this.order.indexOf(S),1),this}setMaxSize(r){for(this.max=r;this.order.length>this.max;){const g=this._getAndRemoveByKey(this.order[0]);g&&this.onRemove(g)}return this}filter(r){const g=[];for(const S in this.data)for(const E of this.data[S])r(E.value)||g.push(E);for(const S of g)this.remove(S.value.tileID,S)}}class Vs{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(r,g,S){const E=String(g);if(this.stateChanges[r]=this.stateChanges[r]||{},this.stateChanges[r][E]=this.stateChanges[r][E]||{},i.e(this.stateChanges[r][E],S),this.deletedStates[r]===null){this.deletedStates[r]={};for(const A in this.state[r])A!==E&&(this.deletedStates[r][A]=null)}else if(this.deletedStates[r]&&this.deletedStates[r][E]===null){this.deletedStates[r][E]={};for(const A in this.state[r][E])S[A]||(this.deletedStates[r][E][A]=null)}else for(const A in S)this.deletedStates[r]&&this.deletedStates[r][E]&&this.deletedStates[r][E][A]===null&&delete this.deletedStates[r][E][A]}removeFeatureState(r,g,S){if(this.deletedStates[r]===null)return;const E=String(g);if(this.deletedStates[r]=this.deletedStates[r]||{},S&&g!==void 0)this.deletedStates[r][E]!==null&&(this.deletedStates[r][E]=this.deletedStates[r][E]||{},this.deletedStates[r][E][S]=null);else if(g!==void 0)if(this.stateChanges[r]&&this.stateChanges[r][E])for(S in this.deletedStates[r][E]={},this.stateChanges[r][E])this.deletedStates[r][E][S]=null;else this.deletedStates[r][E]=null;else this.deletedStates[r]=null}getState(r,g){const S=String(g),E=i.e({},(this.state[r]||{})[S],(this.stateChanges[r]||{})[S]);if(this.deletedStates[r]===null)return{};if(this.deletedStates[r]){const A=this.deletedStates[r][g];if(A===null)return{};for(const ee in A)delete E[ee]}return E}initializeTileState(r,g){r.setFeatureState(this.state,g)}coalesceChanges(r,g){const S={};for(const E in this.stateChanges){this.state[E]=this.state[E]||{};const A={};for(const ee in this.stateChanges[E])this.state[E][ee]||(this.state[E][ee]={}),i.e(this.state[E][ee],this.stateChanges[E][ee]),A[ee]=this.state[E][ee];S[E]=A}for(const E in this.deletedStates){this.state[E]=this.state[E]||{};const A={};if(this.deletedStates[E]===null)for(const ee in this.state[E])A[ee]={},this.state[E][ee]={};else for(const ee in this.deletedStates[E]){if(this.deletedStates[E][ee]===null)this.state[E][ee]={};else for(const se of Object.keys(this.deletedStates[E][ee]))delete this.state[E][ee][se];A[ee]=this.state[E][ee]}S[E]=S[E]||{},i.e(S[E],A)}if(this.stateChanges={},this.deletedStates={},Object.keys(S).length!==0)for(const E in r)r[E].setFeatureState(S,g)}}class ps extends i.E{constructor(r,g,S){super(),this.id=r,this.dispatcher=S,this.on("data",E=>this._dataHandler(E)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}
1962),this._source=((E,A,ee,se)=>{const he=new(vs(A.type))(E,A,ee,se);if(he.id!==E)throw new Error(`Expected Source id to be ${E} instead of ${he.id}`);return he})(r,g,S,this),this._tiles={},this._cache=new Jt(0,E=>this._unloadTile(E)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new Vs,this._didEmitContent=!1,this._updated=!1}onAdd(r){this.map=r,this._maxTileCacheSize=r?r._maxTileCacheSize:null,this._maxTileCacheZoomLevels=r?r._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(r)}onRemove(r){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(r)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const r in this._tiles){const g=this._tiles[r];if(g.state!=="loaded"&&g.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const r=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,r&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(r,g,S){return i._(this,void 0,void 0,function*(){try{yield this._source.loadTile(r),this._tileLoaded(r,g,S)}catch(E){r.state="errored",E.status!==404?this._source.fire(new i.j(E,{tile:r})):this.update(this.transform,this.terrain)}})}_unloadTile(r){this._source.unloadTile&&this._source.unloadTile(r)}_abortTile(r){this._source.abortTile&&this._source.abortTile(r),this._source.fire(new i.k("dataabort",{tile:r,coord:r.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(r){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const g in this._tiles){const S=this._tiles[g];S.upload(r),S.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(r=>r.tileID).sort(nt).map(r=>r.key)}getRenderableIds(r){const g=[];for(const S in this._tiles)this._isIdRenderable(S,r)&&g.push(this._tiles[S]);return r?g.sort((S,E)=>{const A=S.tileID,ee=E.tileID,se=new i.P(A.canonical.x,A.canonical.y)._rotate(this.transform.angle),he=new i.P(ee.canonical.x,ee.canonical.y)._rotate(this.transform.angle);return A.overscaledZ-ee.overscaledZ||he.y-se.y||he.x-se.x}).map(S=>S.tileID.key):g.map(S=>S.tileID).sort(nt).map(S=>S.key)}hasRenderableParent(r){const g=this.findLoadedParent(r,0);return!!g&&this._isIdRenderable(g.tileID.key)}_isIdRenderable(r,g){return this._tiles[r]&&this._tiles[r].hasData()&&!this._coveredTiles[r]&&(g||!this._tiles[r].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const r in this._tiles)this._tiles[r].state!=="errored"&&this._reloadTile(r,"reloading")}}_reloadTile(r,g){return i._(this,void 0,void 0,function*(){const S=this._tiles[r];S&&(S.state!=="loading"&&(S.state=g),yield this._loadTile(S,r,g))})}_tileLoaded(r,g,S){r.timeAdded=x.now(),S==="expired"&&(r.refreshedUponExpiration=!0),this._setTileReloadTimer(g,r),this.getSource().type==="raster-dem"&&r.dem&&this._backfillDEM(r),this._state.initializeTileState(r,this.map?this.map.painter:null),r.aborted||this._source.fire(new i.k("data",{dataType:"source",tile:r,coord:r.tileID}))}_backfillDEM(r){const g=this.getRenderableIds();for(let E=0;E<g.length;E++){const A=g[E];if(r.neighboringTiles&&r.neighboringTiles[A]){const ee=this.getTileByID(A);S(r,ee),S(ee,r)}}function S(E,A){E.needsHillshadePrepare=!0,E.needsTerrainPrepare=!0;let ee=A.tileID.canonical.x-E.tileID.canonical.x;const se=A.tileID.canonical.y-E.tileID.canonical.y,he=Math.pow(2,E.tileID.canonical.z),_e=A.tileID.key;ee===0&&se===0||Math.abs(se)>1||(Math.abs(ee)>1&&(Math.abs(ee+he)===1?ee+=he:Math.abs(ee-he)===1&&(ee-=he)),A.dem&&E.dem&&(E.dem.backfillBorder(A.dem,ee,se),E.neighboringTiles&&E.neighboringTiles[_e]&&(E.neighboringTiles[_e].backfilled=!0)))}}getTile(r){return this.getTileByID(r.key)}getTileByID(r){return this._tiles[r]}_retainLoadedChildren(r,g,S,E){for(const A in this._tiles){let ee=this._tiles[A];if(E[A]||!ee.hasData()||ee.tileID.overscaledZ<=g||ee.tileID.overscaledZ>S)continue;let se=ee.tileID;for(;ee&&ee.tileID.overscaledZ>g+1;){const _e=ee.tileID.scaledTo(ee.tileID.overscaledZ-1);ee=this._tiles[_e.key],ee&&ee.hasData()&&(se=_e)}let he=se;for(;he.overscaledZ>g;)if(he=he.scaledTo(he.overscaledZ-1),r[he.key]){E[se.key]=se;break}}}findLoadedParent(r,g){if(r.key in this._loadedParentTiles){const S=this._loadedParentTiles[r.key];return S&&S.tileID.overscaledZ>=g?S:null}for(let S=r.overscaledZ-1;S>=g;S--){const E=r.scaledTo(S),A=this._getLoadedTile(E);if(A)return A}}findLoadedSibling(r){return this._getLoadedTile(r)}_getLoadedTile(r){const g=this._tiles[r.key];return g&&g.hasData()?g:this._cache.getByKey(r.wrapped().key)}updateCacheSize(r){const g=Math.ceil(r.width/this._source.tileSize)+1,S=Math.ceil(r.height/this._source.tileSize)+1,E=Math.floor(g*S*(this._maxTileC
vendor: 4,211 bytes, line 1962
1962acheZoomLevels===null?i.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),A=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,E):E;this._cache.setMaxSize(A)}handleWrapJump(r){const g=Math.round((r-(this._prevLng===void 0?r:this._prevLng))/360);if(this._prevLng=r,g){const S={};for(const E in this._tiles){const A=this._tiles[E];A.tileID=A.tileID.unwrapTo(A.tileID.wrap+g),S[A.tileID.key]=A}this._tiles=S;for(const E in this._timers)clearTimeout(this._timers[E]),delete this._timers[E];for(const E in this._tiles)this._setTileReloadTimer(E,this._tiles[E])}}_updateCoveredAndRetainedTiles(r,g,S,E,A,ee){const se={},he={},_e=Object.keys(r),Ie=x.now();for(const Me of _e){const Je=r[Me],ut=this._tiles[Me];if(!ut||ut.fadeEndTime!==0&&ut.fadeEndTime<=Ie)continue;const gt=this.findLoadedParent(Je,g),St=this.findLoadedSibling(Je),Lt=gt||St||null;Lt&&(this._addTile(Lt.tileID),se[Lt.tileID.key]=Lt.tileID),he[Me]=Je}this._retainLoadedChildren(he,E,S,r);for(const Me in se)r[Me]||(this._coveredTiles[Me]=!0,r[Me]=se[Me]);if(ee){const Me={},Je={};for(const ut of A)this._tiles[ut.key].hasData()?Me[ut.key]=ut:Je[ut.key]=ut;for(const ut in Je){const gt=Je[ut].children(this._source.maxzoom);this._tiles[gt[0].key]&&this._tiles[gt[1].key]&&this._tiles[gt[2].key]&&this._tiles[gt[3].key]&&(Me[gt[0].key]=r[gt[0].key]=gt[0],Me[gt[1].key]=r[gt[1].key]=gt[1],Me[gt[2].key]=r[gt[2].key]=gt[2],Me[gt[3].key]=r[gt[3].key]=gt[3],delete Je[ut])}for(const ut in Je){const gt=Je[ut],St=this.findLoadedParent(gt,this._source.minzoom),Lt=this.findLoadedSibling(gt),Vt=St||Lt||null;if(Vt){Me[Vt.tileID.key]=r[Vt.tileID.key]=Vt.tileID;for(const Ht in Me)Me[Ht].isChildOf(Vt.tileID)&&delete Me[Ht]}}for(const ut in this._tiles)Me[ut]||(this._coveredTiles[ut]=!0)}}update(r,g){if(!this._sourceLoaded||this._paused)return;let S;this.transform=r,this.terrain=g,this.updateCacheSize(r),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?S=r.getVisibleUnwrappedCoordinates(this._source.tileID).map(Ie=>new i.S(Ie.canonical.z,Ie.wrap,Ie.canonical.z,Ie.canonical.x,Ie.canonical.y)):(S=r.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:g}),this._source.hasTile&&(S=S.filter(Ie=>this._source.hasTile(Ie)))):S=[];const E=r.coveringZoomLevel(this._source),A=Math.max(E-ps.maxOverzooming,this._source.minzoom),ee=Math.max(E+ps.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const Ie={};for(const Me of S)if(Me.canonical.z>this._source.minzoom){const Je=Me.scaledTo(Me.canonical.z-1);Ie[Je.key]=Je;const ut=Me.scaledTo(Math.max(this._source.minzoom,Math.min(Me.canonical.z,5)));Ie[ut.key]=ut}S=S.concat(Object.values(Ie))}const se=S.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,se&&this.fire(new i.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const he=this._updateRetainedTiles(S,E);ts(this._source.type)&&this._updateCoveredAndRetainedTiles(he,A,ee,E,S,g);for(const Ie in he)this._tiles[Ie].clearFadeHold();const _e=i.ab(this._tiles,he);for(const Ie of _e){const Me=this._tiles[Ie];Me.hasSymbolBuckets&&!Me.holdingForFade()?Me.setHoldDuration(this.map._fadeDuration):Me.hasSymbolBuckets&&!Me.symbolFadeFinished()||this._removeTile(Ie)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const r in this._tiles)this._tiles[r].holdingForFade()&&this._removeTile(r)}_updateRetainedTiles(r,g){var S;const E={},A={},ee=Math.max(g-ps.maxOverzooming,this._source.minzoom),se=Math.max(g+ps.maxUnderzooming,this._source.minzoom),he={};for(const _e of r){const Ie=this._addTile(_e);E[_e.key]=_e,Ie.hasData()||g<this._source.maxzoom&&(he[_e.key]=_e)}this._retainLoadedChildren(he,g,se,E);for(const _e of r){let Ie=this._tiles[_e.key];if(Ie.hasData())continue;if(g+1>this._source.maxzoom){const Je=_e.children(this._source.maxzoom)[0],ut=this.getTile(Je);if(ut&&ut.hasData()){E[Je.key]=Je;continue}}else{const Je=_e.children(this._source.maxzoom);
1962if(E[Je[0].key]&&E[Je[1].key]&&E[Je[2].key]&&E[Je[3].key])continue}let Me=Ie.wasRequested();for(let Je=_e.overscaledZ-1;Je>=ee;--Je){const ut=_e.scaledTo(Je);if(A[ut.key])break;if(A[ut.key]=!0,Ie=this.getTile(ut),!Ie&&Me&&(Ie=this._addTile(ut)),Ie){const gt=Ie.hasData();if((gt||!(!((S=this.map)===null||S===void 0)&&S.cancelPendingTileRequestsWhileZooming)||Me)&&(E[ut.key]=ut),Me=Ie.wasRequested(),gt)break}}}return E}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const r in this._tiles){const g=[];let S,E=this._tiles[r].tileID;for(;E.overscaledZ>0;){if(E.key in this._loadedParentTiles){S=this._loadedParentTiles[E.key];break}g.push(E.key);const A=E.scaledTo(E.overscaledZ-1);if(S=this._getLoadedTile(A),S)break;E=A}for(const A of g)this._loadedParentTiles[A]=S}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const r in this._tiles){const g=this._tiles[r].tileID,S=this._getLoadedTile(g);this._loadedSiblingTiles[g.key]=S}}_addTile(r){let g=this._tiles[r.key];if(g)return g;g=this._cache.getAndRemove(r),g&&(this._setTileReloadTimer(r.key,g),g.tileID=r,this._state.initializeTileState(g,this.map?this.map.painter:null),this._cacheTimers[r.key]&&(clearTimeout(this._cacheTimers[r.key]),delete this._cacheTimers[r.key],this._setTileReloadTimer(r.key,g)));const S=g;return g||(g=new en(r,this._source.tileSize*r.overscaleFactor()),this._loadTile(g,r.key,g.state)),g.uses++,this._tiles[r.key]=g,S||this._source.fire(new i.k("dataloading",{tile:g,coord:g.tileID,dataType:"source"})),g}_setTileReloadTimer(r,g){r in this._timers&&(clearTimeout(this._timers[r]),delete this._timers[r]);const S=g.getExpiryTimeout();S&&(this._timers[r]=setTimeout(()=>{this._reloadTile(r,"expired"),delete this._timers[r]},S))}_removeTile(r){const g=this._tiles[r];g&&(g.uses--,delete this._tiles[r],this._timers[r]&&(clearTimeout(this._timers[r]),delete this._timers[r]),g.uses>0||(g.hasData()&&g.state!=="reloading"?this._cache.add(g.tileID,g,g.getExpiryTimeout()):(g.aborted=!0,this._abortTile(g),this._unloadTile(g))))}_dataHandler(r){const g=r.sourceDataType;r.dataType==="source"&&g==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&r.dataType==="source"&&g==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const r in this._tiles)this._removeTile(r);this._cache.reset()}tilesIn(r,g,S){const E=[],A=this.transform;if(!A)return E;const ee=S?A.getCameraQueryGeometry(r):r,se=r.map(gt=>A.pointCoordinate(gt,this.terrain)),he=ee.map(gt=>A.pointCoordinate(gt,this.terrain)),_e=this.getIds();let Ie=1/0,Me=1/0,Je=-1/0,ut=-1/0;for(const gt of he)Ie=Math.min(Ie,gt.x),Me=Math.min(Me,gt.y),Je=Math.max(Je,gt.x),ut=Math.max(ut,gt.y);for(let gt=0;gt<_e.length;gt++){const St=this._tiles[_e[gt]];if(St.holdingForFade())continue;const Lt=St.tileID,Vt=Math.pow(2,A.zoom-St.tileID.overscaledZ),Ht=g*St.queryPadding*i.X/St.tileSize/Vt,Et=[Lt.getTilePoint(new i.Z(Ie,Me)),Lt.getTilePoint(new i.Z(Je,ut))];if(Et[0].x-Ht<i.X&&Et[0].y-Ht<i.X&&Et[1].x+Ht>=0&&Et[1].y+Ht>=0){const Kt=se.map(cs=>Lt.getTilePoint(cs)),ss=he.map(cs=>Lt.getTilePoint(cs));E.push({tile:St,tileID:Lt,queryGeometry:Kt,cameraQueryGeometry:ss,scale:Vt})}}return E}getVisibleCoordinates(r){const g=this.getRenderableIds(r).map(S=>this._tiles[S].tileID);for(const S of g)S.posMatrix=this.transform.calculatePosMatrix(S.toUnwrapped());return g}hasTransition(){if(this._source.hasTransition())return!0;if(ts(this._source.type)){const r=x.now();for(const g in this._tiles)if(this._tiles[g].fadeEndTime>=r)return!0}return!1}setFeatureState(r,g,S){this._state.updateState(r=r||"_geojsonTileLayer",g,S)}removeFeatureState(r,g,S){this._state.removeFeatureState(r=r||"_geojsonTileLayer",g,S)}getFeatureState(r,g){return this._state.getState(r=r||"_geojsonTileLayer",g)}
vendor: 4,286 bytes, line 1962
1962setDependencies(r,g,S){const E=this._tiles[r];E&&E.setDependencies(g,S)}reloadTilesForDependencies(r,g){for(const S in this._tiles)this._tiles[S].hasDependency(r,g)&&this._reloadTile(S,"reloading");this._cache.filter(S=>!S.hasDependency(r,g))}}function nt(R,r){const g=Math.abs(2*R.wrap)-+(R.wrap<0),S=Math.abs(2*r.wrap)-+(r.wrap<0);return R.overscaledZ-r.overscaledZ||S-g||r.canonical.y-R.canonical.y||r.canonical.x-R.canonical.x}function ts(R){return R==="raster"||R==="image"||R==="video"}ps.maxOverzooming=10,ps.maxUnderzooming=3;class ds{constructor(r,g){this.reset(r,g)}reset(r,g){this.points=r||[],this._distances=[0];for(let S=1;S<this.points.length;S++)this._distances[S]=this._distances[S-1]+this.points[S].dist(this.points[S-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(g||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(r){if(this.points.length===1)return this.points[0];r=i.ac(r,0,1);let g=1,S=this._distances[g];const E=r*this.paddedLength+this.padding;for(;S<E&&g<this._distances.length;)S=this._distances[++g];const A=g-1,ee=this._distances[A],se=S-ee,he=se>0?(E-ee)/se:0;return this.points[A].mult(1-he).add(this.points[g].mult(he))}}function Is(R,r){let g=!0;return R==="always"||R!=="never"&&r!=="never"||(g=!1),g}class tn{constructor(r,g,S){const E=this.boxCells=[],A=this.circleCells=[];this.xCellCount=Math.ceil(r/S),this.yCellCount=Math.ceil(g/S);for(let ee=0;ee<this.xCellCount*this.yCellCount;ee++)E.push([]),A.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=r,this.height=g,this.xScale=this.xCellCount/r,this.yScale=this.yCellCount/g,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(r,g,S,E,A){this._forEachCell(g,S,E,A,this._insertBoxCell,this.boxUid++),this.boxKeys.push(r),this.bboxes.push(g),this.bboxes.push(S),this.bboxes.push(E),this.bboxes.push(A)}insertCircle(r,g,S,E){this._forEachCell(g-E,S-E,g+E,S+E,this._insertCircleCell,this.circleUid++),this.circleKeys.push(r),this.circles.push(g),this.circles.push(S),this.circles.push(E)}_insertBoxCell(r,g,S,E,A,ee){this.boxCells[A].push(ee)}_insertCircleCell(r,g,S,E,A,ee){this.circleCells[A].push(ee)}_query(r,g,S,E,A,ee,se){if(S<0||r>this.width||E<0||g>this.height)return[];const he=[];if(r<=0&&g<=0&&this.width<=S&&this.height<=E){if(A)return[{key:null,x1:r,y1:g,x2:S,y2:E}];for(let _e=0;_e<this.boxKeys.length;_e++)he.push({key:this.boxKeys[_e],x1:this.bboxes[4*_e],y1:this.bboxes[4*_e+1],x2:this.bboxes[4*_e+2],y2:this.bboxes[4*_e+3]});for(let _e=0;_e<this.circleKeys.length;_e++){const Ie=this.circles[3*_e],Me=this.circles[3*_e+1],Je=this.circles[3*_e+2];he.push({key:this.circleKeys[_e],x1:Ie-Je,y1:Me-Je,x2:Ie+Je,y2:Me+Je})}}else this._forEachCell(r,g,S,E,this._queryCell,he,{hitTest:A,overlapMode:ee,seenUids:{box:{},circle:{}}},se);return he}query(r,g,S,E){return this._query(r,g,S,E,!1,null)}hitTest(r,g,S,E,A,ee){return this._query(r,g,S,E,!0,A,ee).length>0}hitTestCircle(r,g,S,E,A){const ee=r-S,se=r+S,he=g-S,_e=g+S;if(se<0||ee>this.width||_e<0||he>this.height)return!1;const Ie=[];return this._forEachCell(ee,he,se,_e,this._queryCellCircle,Ie,{hitTest:!0,overlapMode:E,circle:{x:r,y:g,radius:S},seenUids:{box:{},circle:{}}},A),Ie.length>0}_queryCell(r,g,S,E,A,ee,se,he){const{seenUids:_e,hitTest:Ie,overlapMode:Me}=se,Je=this.boxCells[A];if(Je!==null){const gt=this.bboxes;for(const St of Je)if(!_e.box[St]){_e.box[St]=!0;const Lt=4*St,Vt=this.boxKeys[St];if(r<=gt[Lt+2]&&g<=gt[Lt+3]&&S>=gt[Lt+0]&&E>=gt[Lt+1]&&(!he||he(Vt))&&(!Ie||!Is(Me,Vt.overlapMode))&&(ee.push({key:Vt,x1:gt[Lt],y1:gt[Lt+1],x2:gt[Lt+2],y2:gt[Lt+3]}),Ie))return!0}}const ut=this.circleCells[A];if(ut!==null){const gt=this.circles;for(const St of ut)if(!_e.circle[St]){_e.circle[St]=!0;const Lt=3*St,Vt=this.circleKeys[St];if(this._circleAndRectCollide(gt[Lt],gt[Lt+1],gt[Lt+2],r,g,S,E)&&(!he||he(Vt))&&(!Ie||!Is(Me,Vt.overlapMode))){const Ht=gt[Lt],Et=gt[Lt+1],Kt=gt[Lt+2];if(ee.push({key:Vt,x1:Ht-Kt,y1:Et-Kt,x2:Ht+Kt,y2:Et+Kt}),Ie)return!0}}}return!1}_queryCellCircle(r,g,S,E,A,ee,se,he){const{circle:_e,seenUids:Ie,overlapMode:Me}=se,Je=this.boxCells[A];if(Je!==null){const gt=this.bboxes;for(const St of Je)if(!Ie.box[St]){Ie.box[St]=!0;const Lt=4*St,Vt=this.boxKeys[St];
vendor: 18,505 bytes, line 1962
1962if(this._circleAndRectCollide(_e.x,_e.y,_e.radius,gt[Lt+0],gt[Lt+1],gt[Lt+2],gt[Lt+3])&&(!he||he(Vt))&&!Is(Me,Vt.overlapMode))return ee.push(!0),!0}}const ut=this.circleCells[A];if(ut!==null){const gt=this.circles;for(const St of ut)if(!Ie.circle[St]){Ie.circle[St]=!0;const Lt=3*St,Vt=this.circleKeys[St];if(this._circlesCollide(gt[Lt],gt[Lt+1],gt[Lt+2],_e.x,_e.y,_e.radius)&&(!he||he(Vt))&&!Is(Me,Vt.overlapMode))return ee.push(!0),!0}}}_forEachCell(r,g,S,E,A,ee,se,he){const _e=this._convertToXCellCoord(r),Ie=this._convertToYCellCoord(g),Me=this._convertToXCellCoord(S),Je=this._convertToYCellCoord(E);for(let ut=_e;ut<=Me;ut++)for(let gt=Ie;gt<=Je;gt++)if(A.call(this,r,g,S,E,this.xCellCount*gt+ut,ee,se,he))return}_convertToXCellCoord(r){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(r*this.xScale)))}_convertToYCellCoord(r){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(r*this.yScale)))}_circlesCollide(r,g,S,E,A,ee){const se=E-r,he=A-g,_e=S+ee;return _e*_e>se*se+he*he}_circleAndRectCollide(r,g,S,E,A,ee,se){const he=(ee-E)/2,_e=Math.abs(r-(E+he));if(_e>he+S)return!1;const Ie=(se-A)/2,Me=Math.abs(g-(A+Ie));if(Me>Ie+S)return!1;if(_e<=he||Me<=Ie)return!0;const Je=_e-he,ut=Me-Ie;return Je*Je+ut*ut<=S*S}}function wn(R,r,g,S,E){const A=i.H();return r?(i.K(A,A,[1/E,1/E,1]),g||i.ad(A,A,S.angle)):i.L(A,S.labelPlaneMatrix,R),A}function Gs(R,r,g,S,E){if(r){const A=i.ae(R);return i.K(A,A,[E,E,1]),g||i.ad(A,A,-S.angle),A}return S.glCoordMatrix}function Ue(R,r,g,S){let E;S?(E=[R,r,S(R,r),1],i.af(E,E,g)):(E=[R,r,0,1],ya(E,E,g));const A=E[3];return{point:new i.P(E[0]/A,E[1]/A),signedDistanceFromCamera:A,isOccluded:!1}}function Pe(R,r){return .5+R/r*.5}function je(R,r){return R.x>=-r[0]&&R.x<=r[0]&&R.y>=-r[1]&&R.y<=r[1]}function Ge(R,r,g,S,E,A,ee,se,he,_e,Ie,Me,Je,ut,gt){const St=S?R.textSizeData:R.iconSizeData,Lt=i.ag(St,g.transform.zoom),Vt=[256/g.width*2+1,256/g.height*2+1],Ht=S?R.text.dynamicLayoutVertexArray:R.icon.dynamicLayoutVertexArray;Ht.clear();const Et=R.lineVertexArray,Kt=S?R.text.placedSymbolArray:R.icon.placedSymbolArray,ss=g.transform.width/g.transform.height;let cs=!1;for(let As=0;As<Kt.length;As++){const sn=Kt.get(As);if(sn.hidden||sn.writingMode===i.ah.vertical&&!cs){an(sn.numGlyphs,Ht);continue}cs=!1;const pn=Ue(sn.anchorX,sn.anchorY,r,gt);if(!je(pn.point,Vt)){an(sn.numGlyphs,Ht);continue}const Ln=Pe(g.transform.cameraToCenterDistance,pn.signedDistanceFromCamera),Js=i.ai(St,Lt,sn),on=ee?Js/Ln:Js*Ln,Hn={getElevation:gt,labelPlaneMatrix:E,lineVertexArray:Et,pitchWithMap:ee,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},projection:_e,tileAnchorPoint:new i.P(sn.anchorX,sn.anchorY),unwrappedTileID:Ie,width:Me,height:Je,translation:ut},Ra=Ct(Hn,sn,on,!1,se,r,A,R.glyphOffsetArray,Ht,ss,he);cs=Ra.useVertical,(Ra.notEnoughRoom||cs||Ra.needsFlipping&&Ct(Hn,sn,on,!0,se,r,A,R.glyphOffsetArray,Ht,ss,he).notEnoughRoom)&&an(sn.numGlyphs,Ht)}S?R.text.dynamicLayoutVertexBuffer.updateData(Ht):R.icon.dynamicLayoutVertexBuffer.updateData(Ht)}function De(R,r,g,S,E,A,ee,se){const he=A.glyphStartIndex+A.numGlyphs,_e=A.lineStartIndex,Ie=A.lineStartIndex+A.lineLength,Me=r.getoffsetX(A.glyphStartIndex),Je=r.getoffsetX(he-1),ut=is(R*Me,g,S,E,A.segment,_e,Ie,se,ee);if(!ut)return null;const gt=is(R*Je,g,S,E,A.segment,_e,Ie,se,ee);return gt?se.projectionCache.anyProjectionOccluded?null:{first:ut,last:gt}:null}function bt(R,r,g,S){return R===i.ah.horizontal&&Math.abs(g.y-r.y)>Math.abs(g.x-r.x)*S?{useVertical:!0}:(R===i.ah.vertical?r.y<g.y:r.x>g.x)?{needsFlipping:!0}:null}function Ct(R,r,g,S,E,A,ee,se,he,_e,Ie){const Me=g/24,Je=r.lineOffsetX*Me,ut=r.lineOffsetY*Me;let gt;if(r.numGlyphs>1){const St=r.glyphStartIndex+r.numGlyphs,Lt=r.lineStartIndex,Vt=r.lineStartIndex+r.lineLength,Ht=De(Me,se,Je,ut,S,r,Ie,R);if(!Ht)return{notEnoughRoom:!0};const Et=Ue(Ht.first.point.x,Ht.first.point.y,ee,R.getElevation).point,Kt=Ue(Ht.last.point.x,Ht.last.point.y,ee,R.getElevation).point;if(E&&!S){const ss=bt(r.writingMode,Et,Kt,_e);if(ss)return ss}gt=[Ht.first];for(let ss=r.glyphStartIndex+1;ss<St-1;ss++)gt.push(is(Me*se.getoffsetX(ss),Je,ut,S,r.segment,Lt,Vt,R,Ie));gt.push(Ht.last)}else{if(E&&!S){const Lt=Ue(R.tileAnchorPoint.x,R.tileAnchorPoint.y,A,R.getElevation).point,Vt=r.lineStartIndex+r.segment+1,Ht=new i.P(R.lineVertexArray.getx(Vt),R.lineVertexArray.gety(Vt)),Et=Ue(Ht.x,Ht.y,A,R.getElevation),Kt=Et.signedDistanceFromCamera>0?Et.point:function(cs,As,sn,pn,Ln,Js){return pe(cs,As,sn,1,Ln,Js)}(R.tileAnchorPoint,Ht,Lt,0,A,R),ss=bt(r.writingMode,Lt,Kt,_e);if(ss)return ss}const St=is(Me*se.getoffsetX(r.glyphStartIndex),Je,ut,S,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,R,Ie);if(!St||R.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};gt=[St]}for(const St of gt)i.aj(he,St.point,St.angle);return{}}function pe(R,r,g,S,E,A){const ee=R.add(R.sub(r)._unit()),se=E!==void 0?Ue(ee.x,ee.y,E,A.getElevation).point:Zt(ee.x,ee.y,A).point,he=g.sub(se);return g.add(he._mult(S/he.mag()))}function wt(R,r,g){const S=r.projectionCache;if(S.projections[R])return S.projections[R];const E=new i.P(r.lineVertexArray.getx(R),r.lineVertexArray.gety(R)),A=Zt(E.x,E.y,r);if(A.signedDistanceFromCamera>0)return S.projections[R]=A.point,S.anyProjectionOccluded=S.anyProjectionOccluded||A.isOccluded,A.point;const ee=R-g.direction;return function(se,he,_e,Ie,Me){return pe(se,he,_e,Ie,void 0,Me)}(g.distanceFromAnchor===0?r.tileAnchorPoint:new i.P(r.lineVertexArray.getx(ee),r.lineVertexArray.gety(ee)),E,g.previousVertex,g.absOffsetX-g.distanceFromAnchor+1,r)}function Zt(R,r,g){const S=R+g.translation[0],E=r+g.translation[1];let A;return!g.pitchWithMap&&g.projection.useSpecialProjectionForSymbols?(A=g.projection.projectTileCoordinates(S,E,g.unwrappedTileID,g.getElevation),A.point.x=(.5*A.point.x+.5)*g.width,A.point.y=(.5*-A.point.y+.5)*g.height):(A=Ue(S,E,g.labelPlaneMatrix,g.getElevation),A.isOccluded=!1),A}function ys(R,r,g){return R._unit()._perp()._mult(r*g)}function es(R,r,g,S,E,A,ee,se,he){if(se.projectionCache.offsets[R])return se.projectionCache.offsets[R];const _e=g.add(r);if(R+he.direction<S||R+he.direction>=E)return se.projectionCache.offsets[R]=_e,_e;const Ie=wt(R+he.direction,se,he),Me=ys(Ie.sub(g),ee,he.direction),Je=g.add(Me),ut=Ie.add(Me);return se.projectionCache.offsets[R]=i.ak(A,_e,Je,ut)||_e,se.projectionCache.offsets[R]}function is(R,r,g,S,E,A,ee,se,he){const _e=S?R-r:R+r;let Ie=_e>0?1:-1,Me=0;S&&(Ie*=-1,Me=Math.PI),Ie<0&&(Me+=Math.PI);let Je,ut=Ie>0?A+E:A+E+1;se.projectionCache.cachedAnchorPoint?Je=se.projectionCache.cachedAnchorPoint:(Je=Zt(se.tileAnchorPoint.x,se.tileAnchorPoint.y,se).point,se.projectionCache.cachedAnchorPoint=Je);let gt,St,Lt=Je,Vt=Je,Ht=0,Et=0;const Kt=Math.abs(_e),ss=[];let cs;for(;Ht+Et<=Kt;){if(ut+=Ie,ut<A||ut>=ee)return null;Ht+=Et,Vt=Lt,St=gt;const pn={absOffsetX:Kt,direction:Ie,distanceFromAnchor:Ht,previousVertex:Vt};if(Lt=wt(ut,se,pn),g===0)ss.push(Vt),cs=Lt.sub(Vt);else{let Ln;const Js=Lt.sub(Vt);Ln=Js.mag()===0?ys(wt(ut+Ie,se,pn).sub(Lt),g,Ie):ys(Js,g,Ie),St||(St=Vt.add(Ln)),gt=es(ut,Ln,Lt,A,ee,St,g,se,pn),ss.push(St),cs=gt.sub(St)}Et=cs.mag()}const As=cs._mult((Kt-Ht)/Et)._add(St||Vt),sn=Me+Math.atan2(Lt.y-Vt.y,Lt.x-Vt.x);return ss.push(As),{point:As,angle:he?sn:0,path:ss}}const Ws=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function an(R,r){for(let g=0;g<R;g++){const S=r.length;r.resize(S+4),r.float32.set(Ws,3*S)}}function ya(R,r,g){const S=r[0],E=r[1];return R[0]=g[0]*S+g[4]*E+g[12],R[1]=g[1]*S+g[5]*E+g[13],R[3]=g[3]*S+g[7]*E+g[15],R}const Hs=100;class xt{constructor(r,g,S=new tn(r.width+200,r.height+200,25),E=new tn(r.width+200,r.height+200,25)){this.transform=r,this.mapProjection=g,this.grid=S,this.ignoredGrid=E,this.pitchFactor=Math.cos(r._pitch)*r.cameraToCenterDistance,this.screenRightBoundary=r.width+Hs,this.screenBottomBoundary=r.height+Hs,this.gridRightBoundary=r.width+200,this.gridBottomBoundary=r.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(r,g,S,E,A,ee,se,he,_e,Ie,Me){const Je=r.anchorPointX+he[0],ut=r.anchorPointY+he[1],gt=this.projectAndGetPerspectiveRatio(E,Je,ut,A,Ie),St=S*gt.perspectiveRatio;let Lt;if(ee||se)Lt=this._projectCollisionBox(r,St,E,A,ee,se,he,gt,Ie,Me);else{const ss=gt.point.x+(Me?Me.x*St:0),cs=gt.point.y+(Me?Me.y*St:0);Lt={allPointsOccluded:!1,box:[ss+r.x1*St,cs+r.y1*St,ss+r.x2*St,cs+r.y2*St]}}const[Vt,Ht,Et,Kt]=Lt.box;return this.mapProjection.useSpecialProjectionForSymbols&&(ee?Lt.allPointsOccluded:this.mapProjection.isOccluded(Je,ut,A))||gt.perspectiveRatio<this.perspectiveRatioCutoff||!this.isInsideGrid(Vt,Ht,Et,Kt)||g!=="always"&&this.grid.hitTest(Vt,Ht,Et,Kt,g,_e)?{box:[Vt,Ht,Et,Kt],placeable:!1,offscreen:!1}:{box:[Vt,Ht,Et,Kt],placeable:!0,offscreen:this.isOffscreen(Vt,Ht,Et,Kt)}}placeCollisionCircles(r,g,S,E,A,ee,se,he,_e,Ie,Me,Je,ut,gt,St,Lt){const Vt=[],Ht=new i.P(g.anchorX,g.anchorY),Et=this.getPerspectiveRatio(ee,Ht.x,Ht.y,se,Lt),Kt=(Me?A/Et:A*Et)/i.ap,ss={getElevation:Lt,labelPlaneMatrix:he,lineVertexArray:S,pitchWithMap:Me,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},projection:this.mapProjection,tileAnchorPoint:Ht,unwrappedTileID:se,width:this.transform.width,height:this.transform.height,translation:St},cs=De(Kt,E,g.lineOffsetX*Kt,g.lineOffsetY*Kt,!1,g,!1,ss);let As=!1,sn=!1,pn=!0;if(cs){const Ln=.5*ut*Et+gt,Js=new i.P(-100,-100),on=new i.P(this.screenRightBoundary,this.screenBottomBoundary),Hn=new ds,Ra=cs.first,ln=cs.last;let Nn=[];for(let er=Ra.path.length-1;er>=1;er--)Nn.push(Ra.path[er]);for(let er=1;er<ln.path.length;er++)Nn.push(ln.path[er]);const aa=2.5*Ln;if(_e){const er=this.projectPathToScreenSpace(Nn,ss,_e);Nn=er.some(Sr=>Sr.signedDistanceFromCamera<=0)?[]:er.map(Sr=>Sr.point)}let mi=[];if(Nn.length>0){const er=Nn[0].clone(),Sr=Nn[0].clone();for(let Pi=1;Pi<Nn.length;Pi++)er.x=Math.min(er.x,Nn[Pi].x),er.y=Math.min(er.y,Nn[Pi].y),Sr.x=Math.max(Sr.x,Nn[Pi].x),Sr.y=Math.max(Sr.y,Nn[Pi].y);mi=er.x>=Js.x&&Sr.x<=on.x&&er.y>=Js.y&&Sr.y<=on.y?[Nn]:Sr.x<Js.x||er.x>on.x||Sr.y<Js.y||er.y>on.y?[]:i.al([Nn],Js.x,Js.y,on.x,on.y)}for(const er of mi){Hn.reset(er,.25*Ln);let Sr=0;Sr=Hn.length<=.5*Ln?1:Math.ceil(Hn.paddedLength/aa)+1;for(let Pi=0;Pi<Sr;Pi++){const al=Pi/Math.max(Sr-1,1),Dd=Hn.lerp(al),Ti=Dd.x+Hs,fc=Dd.y+Hs;Vt.push(Ti,fc,Ln,0);const El=Ti-Ln,Ql=fc-Ln,Ol=Ti+Ln,Rd=fc+Ln;if(pn=pn&&this.isOffscreen(El,Ql,Ol,Rd),sn=sn||this.isInsideGrid(El,Ql,Ol,Rd),r!=="always"&&this.grid.hitTestCircle(Ti,fc,Ln,r,Je)&&(As=!0,!Ie))return{circles:[],offscreen:!1,collisionDetected:As}}}}return{circles:!Ie&&As||!sn||Et<this.perspectiveRatioCutoff?[]:Vt,offscreen:pn,collisionDetected:As}}projectPathToScreenSpace(r,g,S){return r.map(E=>Ue(E.x,E.y,S,g.getElevation))}queryRenderedSymbols(r){if(r.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const g=[];let S=1/0,E=1/0,A=-1/0,ee=-1/0;for(const Ie of r){const Me=new i.P(Ie.x+Hs,Ie.y+Hs);S=Math.min(S,Me.x),E=Math.min(E,Me.y),A=Math.max(A,Me.x),ee=Math.max(ee,Me.y),g.push(Me)}const se=this.grid.query(S,E,A,ee).concat(this.ignoredGrid.query(S,E,A,ee)),he={},_e={};for(const Ie of se){const Me=Ie.key;if(he[Me.bucketInstanceId]===void 0&&(he[Me.bucketInstanceId]={}),he[Me.bucketInstanceId][Me.featureIndex])continue;const Je=[new i.P(Ie.x1,Ie.y1),new i.P(Ie.x2,Ie.y1),new i.P(Ie.x2,Ie.y2),new i.P(Ie.x1,Ie.y2)];i.am(g,Je)&&(he[Me.bucketInstanceId][Me.featureIndex]=!0,_e[Me.bucketInstanceId]===void 0&&(_e[Me.bucketInstanceId]=[]),_e[Me.bucketInstanceId].push(Me.featureIndex))}return _e}insertCollisionBox(r,g,S,E,A,ee){(S?this.ignoredGrid:this.grid).insert({bucketInstanceId:E,featureIndex:A,collisionGroupID:ee,overlapMode:g},r[0],r[1],r[2],r[3])}insertCollisionCircles(r,g,S,E,A,ee){const se=S?this.ignoredGrid:this.grid,he={bucketInstanceId:E,featureIndex:A,collisionGroupID:ee,overlapMode:g};for(let _e=0;_e<r.length;_e+=4)se.insertCircle(he,r[_e],r[_e+1],r[_e+2])}projectAndGetPerspectiveRatio(r,g,S,E,A){let ee;A?(ee=[g,S,A(g,S),1],i.af(ee,ee,r)):(ee=[g,S,0,1],ya(ee,ee,r));const se=ee[3];return{point:new i.P((ee[0]/se+1)/2*this.transform.width+Hs,(-ee[1]/se+1)/2*this.transform.height+Hs),perspectiveRatio:.5+this.transform.cameraToCenterDistance/se*.5,isOccluded:!1,signedDistanceFromCamera:se}}getPerspectiveRatio(r,g,S,E,A){const ee=this.mapProjection.useSpecialProjectionForSymbols?this.mapProjection.projectTileCoordinates(g,S,E,A):Ue(g,S,r,A);return .5+this.transform.cameraToCenterDistance/ee.signedDistanceFromCamera*.5}isOffscreen(r,g,S,E){return S<Hs||r>=this.screenRightBoundary||E<Hs||g>this.screenBottomBoundary}isInsideGrid(r,g,S,E){return S>=0&&r<this.gridRightBoundary&&E>=0&&g<this.gridBottomBoundary}getViewportMatrix(){const r=i.an([]);return i.J(r,r,[-100,-100,0]),r}_projectCollisionBox(r,g,S,E,A,ee,se,he,_e,Ie){let Me=new i.P(1,0),Je=new i.P(0,1);const ut=new i.P(r.anchorPointX+se[0],r.anchorPointY+se[1]);if(ee&&!A){const pn=this.projectAndGetPerspectiveRatio(S,ut.x+1,ut.y,E,_e).point.sub(he.point).unit(),Ln=Math.atan(pn.y/pn.x)+(pn.x<0?Math.PI:0),Js=Math.sin(Ln),on=Math.cos(Ln);Me=new i.P(on,Js),Je=new i.P(-Js,on)}else if(!ee&&A){const pn=-this.transform.angle,Ln=Math.sin(pn),Js=Math.cos(pn);Me=new i.P(Js,Ln),Je=new i.P(-Ln,Js)}let gt=he.point,St=g;if(A){gt=ut;const pn=this.transform.zoom-Math.floor(this.transform.zoom);St=Math.pow(2,-pn),St*=this.mapProjection.getPitchedTextCorrection(this.transform,ut,E),Ie||(St*=i.ac(.5+he.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))}Ie&&(gt=gt.add(Me.mult(Ie.x*St)).add(Je.mult(Ie.y*St)));const Lt=r.x1*St,Vt=r.x2*St,Ht=(Lt+Vt)/2,Et=r.y1*St,Kt=r.y2*St,ss=(Et+Kt)/2,cs=[{offsetX:Lt,offsetY:Et},{offsetX:Ht,offsetY:Et},{offsetX:Vt,offsetY:Et},{offsetX:Vt,offsetY:ss},{offsetX:Vt,offsetY:Kt},{offsetX:Ht,offsetY:Kt},{offsetX:Lt,offsetY:Kt},{offsetX:Lt,offsetY:ss}];let As=[];for(const{offsetX:pn,offsetY:Ln}of cs)As.push(new i.P(gt.x+Me.x*pn+Je.x*Ln,gt.y+Me.y*pn+Je.y*Ln));let sn=!1;if(A){const pn=As.map(Ln=>this.projectAndGetPerspectiveRatio(S,Ln.x,Ln.y,E,_e));sn=pn.some(Ln=>!Ln.isOccluded),As=pn.map(Ln=>Ln.point)}else sn=!0;return{box:i.ao(As),allPointsOccluded:!sn}}}function os(R,r,g){return r*(i.X/(R.tileSize*Math.pow(2,g-R.tileID.overscaledZ)))}class Ls{constructor(r,g,S,E){this.opacity=r?Math.max(0,Math.min(1,r.opacity+(r.placed?g:-g))):E&&S?1:0,this.placed=S}isHidden(){return this.opacity===0&&!this.placed}}class Es{constructor(r,g,S,E,A){this.text=new Ls(r?r.text:null,g,S,A),this.icon=new Ls(r?r.icon:null,g,E,A)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Qs{constructor(r,g,S){this.text=r,this.icon=g,this.skipFade=S}}class Pn{constructor(){this.invProjMatrix=i.H(),this.viewportMatrix=i.H(),this.circles=[]}}class Ks{constructor(r,g,S,E,A){this.bucketInstanceId=r,this.featureIndex=g,this.sourceLayerIndex=S,this.bucketIndex=E,this.tileID=A}}class xa{constructor(r){this.crossSourceCollisions=r,this.maxGroupID=0,this.collisionGroups={}}get(r){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[r]){const g=++this.maxGroupID;this.collisionGroups[r]={ID:g,predicate:S=>S.collisionGroupID===g}}return this.collisionGroups[r]}}function Fn(R,r,g,S,E){const{horizontalAlign:A,verticalAlign:ee}=i.au(R);return new i.P(-(A-.5)*r+S[0]*E,-(ee-.5)*g+S[1]*E)}class Sa{constructor(r,g,S,E,A,ee){this.transform=r.clone(),this.terrain=S,this.collisionIndex=new xt(this.transform,g),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=E,this.retainedQueryData={},this.collisionGroups=new xa(A),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=ee,ee&&(ee.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(r){const g=this.terrain;return g?(S,E)=>g.getElevation(r,S,E):null}getBucketParts(r,g,S,E){const A=S.getBucket(g),ee=S.latestFeatureIndex;if(!A||!ee||g.id!==A.layerIds[0])return;const se=S.collisionBoxArray,he=A.layers[0].layout,_e=A.layers[0].paint,Ie=Math.pow(2,this.transform.zoom-S.tileID.overscaledZ),Me=S.tileSize/i.X,Je=S.tileID.toUnwrapped(),ut=this.transform.calculatePosMatrix(Je),gt=he.get("text-pitch-alignment")==="map",St=he.get("text-rotation-alignment")==="map",Lt=os(S,1,this.transform.zoom),Vt=this.collisionIndex.mapProjection.translatePosition(this.transform,S,_e.get("text-translate"),_e.get("text-translate-anchor")),Ht=this.collisionIndex.mapProjection.translatePosition(this.transform,S,_e.get("icon-translate"),_e.get("icon-translate-anchor")),Et=wn(ut,gt,St,this.transform,Lt);let Kt=null;if(gt){const cs=Gs(ut,gt,St,this.transform,Lt);Kt=i.L([],this.transform.labelPlaneMatrix,cs)}this.retainedQueryData[A.bucketInstanceId]=new Ks(A.bucketInstanceId,ee,A.sourceLayerIndex,A.index,S.tileID);const ss={bucket:A,layout:he,translationText:Vt,translationIcon:Ht,posMatrix:ut,unwrappedTileID:Je,textLabelPlaneMatrix:Et,labelToScreenMatrix:Kt,scale:Ie,textPixelRatio:Me,holdingForFade:S.holdingForFade(),collisionBoxArray:se,partiallyEvaluatedTextSize:i.ag(A.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(A.sourceID)};if(E)for(const cs of A.sortKeyRanges){const{sortKey:As,symbolInstanceStart:sn,symbolInstanceEnd:pn}=cs;r.push({sortKey:As,symbolInstanceStart:sn,symbolInstanceEnd:pn,parameters:ss})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:A.symbolInstances.length,parameters:ss})}attemptAnchorPlacement(r,g,S,E,A,ee,se,he,_e,Ie,Me,Je,ut,gt,St,Lt,Vt,Ht,Et){const Kt=i.aq[r.textAnchor],ss=[r.textOffset0,r.textOffset1],cs=Fn(Kt,S,E,ss,A),As=this.collisionIndex.placeCollisionBox(g,Je,he,_e,Ie,se,ee,Lt,Me.predicate,Et,cs);if((!Ht||this.collisionIndex.placeCollisionBox(Ht,Je,he,_e,Ie,se,ee,Vt,Me.predicate,Et,cs).placeable)&&As.placeable){let sn;if(this.prevPlacement&&this.prevPlacement.variableOffsets[ut.crossTileID]&&this.prevPlacement.placements[ut.crossTileID]&&this.prevPlacement.placements[ut.crossTileID].text&&(sn=this.prevPlacement.variableOffsets[ut.crossTileID].anchor),ut.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[ut.crossTileID]={textOffset:ss,width:S,height:E,anchor:Kt,textBoxScale:A,prevAnchor:sn},this.markUsedJustification(gt,Kt,ut,St),gt.allowVerticalPlacement&&(this.markUsedOrientation(gt,St,ut),this.placedOrientations[ut.crossTileID]=St),{shift:cs,placedGlyphBoxes:As}}}placeLayerBucketPart(r,g,S){const{bucket:E,layout:A,translationText:ee,translationIcon:se,posMatrix:he,unwrappedTileID:_e,textLabelPlaneMatr
1962ix:Ie,labelToScreenMatrix:Me,textPixelRatio:Je,holdingForFade:ut,collisionBoxArray:gt,partiallyEvaluatedTextSize:St,collisionGroup:Lt}=r.parameters,Vt=A.get("text-optional"),Ht=A.get("icon-optional"),Et=i.ar(A,"text-overlap","text-allow-overlap"),Kt=Et==="always",ss=i.ar(A,"icon-overlap","icon-allow-overlap"),cs=ss==="always",As=A.get("text-rotation-alignment")==="map",sn=A.get("text-pitch-alignment")==="map",pn=A.get("icon-text-fit")!=="none",Ln=A.get("symbol-z-order")==="viewport-y",Js=Kt&&(cs||!E.hasIconData()||Ht),on=cs&&(Kt||!E.hasTextData()||Vt);!E.collisionArrays&&gt&&E.deserializeCollisionBoxes(gt);const Hn=this._getTerrainElevationFunc(this.retainedQueryData[E.bucketInstanceId].tileID),Ra=(ln,Nn,aa)=>{var mi,er;if(g[ln.crossTileID])return;if(ut)return void(this.placements[ln.crossTileID]=new Qs(!1,!1,!1));let Sr=!1,Pi=!1,al=!0,Dd=null,Ti={box:null,placeable:!1,offscreen:null},fc={box:null,placeable:!1,offscreen:null},El=null,Ql=null,Ol=null,Rd=0,qu=0,Jm=0;Nn.textFeatureIndex?Rd=Nn.textFeatureIndex:ln.useRuntimeCollisionCircles&&(Rd=ln.featureIndex),Nn.verticalTextFeatureIndex&&(qu=Nn.verticalTextFeatureIndex);const Vo=Nn.textBox;if(Vo){const td=$l=>{let rl=i.ah.horizontal;if(E.allowVerticalPlacement&&!$l&&this.prevPlacement){const Fc=this.prevPlacement.placedOrientations[ln.crossTileID];Fc&&(this.placedOrientations[ln.crossTileID]=Fc,rl=Fc,this.markUsedOrientation(E,rl,ln))}return rl},vd=($l,rl)=>{if(E.allowVerticalPlacement&&ln.numVerticalGlyphVertices>0&&Nn.verticalTextBox){for(const Fc of E.writingModes)if(Fc===i.ah.vertical?(Ti=rl(),fc=Ti):Ti=$l(),Ti&&Ti.placeable)break}else Ti=$l()},ju=ln.textAnchorOffsetStartIndex,Rc=ln.textAnchorOffsetEndIndex;if(Rc===ju){const $l=(rl,Fc)=>{const qr=this.collisionIndex.placeCollisionBox(rl,Et,Je,he,_e,sn,As,ee,Lt.predicate,Hn);return qr&&qr.placeable&&(this.markUsedOrientation(E,Fc,ln),this.placedOrientations[ln.crossTileID]=Fc),qr};vd(()=>$l(Vo,i.ah.horizontal),()=>{const rl=Nn.verticalTextBox;return E.allowVerticalPlacement&&ln.numVerticalGlyphVertices>0&&rl?$l(rl,i.ah.vertical):{box:null,offscreen:null}}),td(Ti&&Ti.placeable)}else{let $l=i.aq[(er=(mi=this.prevPlacement)===null||mi===void 0?void 0:mi.variableOffsets[ln.crossTileID])===null||er===void 0?void 0:er.anchor];const rl=(qr,su,Gu)=>{const jh=qr.x2-qr.x1,Yf=qr.y2-qr.y1,Xf=ln.textBoxScale,wh=pn&&ss==="never"?su:null;let sd=null,Lp=Et==="never"?1:2,bm="never";$l&&Lp++;for(let jm=0;jm<Lp;jm++){for(let Gh=ju;Gh<Rc;Gh++){const Nh=E.textAnchorOffsets.get(Gh);if($l&&Nh.textAnchor!==$l)continue;const Hu=this.attemptAnchorPlacement(Nh,qr,jh,Yf,Xf,As,sn,Je,he,_e,Lt,bm,ln,E,Gu,ee,se,wh,Hn);if(Hu&&(sd=Hu.placedGlyphBoxes,sd&&sd.placeable))return Sr=!0,Dd=Hu.shift,sd}$l?$l=null:bm=Et}return S&&!sd&&(sd={box:this.collisionIndex.placeCollisionBox(Vo,"always",Je,he,_e,sn,As,ee,Lt.predicate,Hn,new i.P(0,0)).box,offscreen:!1,placeable:!1}),sd};vd(()=>rl(Vo,Nn.iconBox,i.ah.horizontal),()=>{const qr=Nn.verticalTextBox;return E.allowVerticalPlacement&&(!Ti||!Ti.placeable)&&ln.numVerticalGlyphVertices>0&&qr?rl(qr,Nn.verticalIconBox,i.ah.vertical):{box:null,occluded:!0,offscreen:null}}),Ti&&(Sr=Ti.placeable,al=Ti.offscreen);const Fc=td(Ti&&Ti.placeable);if(!Sr&&this.prevPlacement){const qr=this.prevPlacement.variableOffsets[ln.crossTileID];qr&&(this.variableOffsets[ln.crossTileID]=qr,this.markUsedJustification(E,qr.anchor,ln,Fc))}}}if(El=Ti,Sr=El&&El.placeable,al=El&&El.offscreen,ln.useRuntimeCollisionCircles){const td=E.text.placedSymbolArray.get(ln.centerJustifiedTextSymbolIndex),vd=i.ai(E.textSizeData,St,td),ju=A.get("text-padding");Ql=this.collisionIndex.placeCollisionCircles(Et,td,E.lineVertexArray,E.glyphOffsetArray,vd,he,_e,Ie,Me,S,sn,Lt.predicate,ln.collisionCircleDiameter,ju,ee,Hn),Ql.circles.length&&Ql.collisionDetected&&!S&&i.w("Collisions detected, but collision boxes are not shown"),Sr=Kt||Ql.circles.length>0&&!Ql.collisionDetected,al=al&&Ql.offscreen}if(Nn.iconFeatureIndex&&(Jm=Nn.iconFeatureIndex),Nn.iconBox){const td=vd=>this.collisionIndex.placeCollisionBox(vd,ss,Je,he,_e,sn,As,se,Lt.predicate,Hn,pn&&Dd?Dd:void 0);fc&&fc.placeable&&Nn.verticalIconBox?(Ol=td(Nn.verticalIconBox),Pi=Ol.placeable):(Ol=td(Nn.iconBox),Pi=Ol.placeable),al=al&&Ol.offscreen}const Bl=Vt||ln.numHorizontalGlyphVertices===0&&ln.numVerticalGlyphVertices===0,Zf=Ht||ln.numIconVertices===0;Bl||Zf?Zf?Bl||(Pi=Pi&&Sr):Sr=Pi&&Sr:Pi=Sr=Pi&&Sr;const Wf=Pi&&Ol.placeable;if(Sr&&El.placeable&&this.collisionIndex.insertCollisionBox(El.box,Et,A.get("text-ignore-placement"),E.bucketInstanceId,fc&&fc.placeable&&qu?qu:Rd,Lt.ID),Wf&&this.collisionIndex.insertCollisionBox(Ol.box,ss,A.get("icon-ignore-placement"),E.bucketInstanceId,Jm,Lt.ID),Ql&&Sr&&this.collisionIndex.insertCollisionCircles(Ql.cir
vendor: 9,977 bytes, line 1962
1962cles,Et,A.get("text-ignore-placement"),E.bucketInstanceId,Rd,Lt.ID),S&&this.storeCollisionData(E.bucketInstanceId,aa,Nn,El,Ol,Ql),ln.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(E.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[ln.crossTileID]=new Qs(Sr||Js,Pi||on,al||E.justReloaded),g[ln.crossTileID]=!0};if(Ln){if(r.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const ln=E.getSortedSymbolIndexes(this.transform.angle);for(let Nn=ln.length-1;Nn>=0;--Nn){const aa=ln[Nn];Ra(E.symbolInstances.get(aa),E.collisionArrays[aa],aa)}}else for(let ln=r.symbolInstanceStart;ln<r.symbolInstanceEnd;ln++)Ra(E.symbolInstances.get(ln),E.collisionArrays[ln],ln);if(S&&E.bucketInstanceId in this.collisionCircleArrays){const ln=this.collisionCircleArrays[E.bucketInstanceId];i.as(ln.invProjMatrix,he),ln.viewportMatrix=this.collisionIndex.getViewportMatrix()}E.justReloaded=!1}storeCollisionData(r,g,S,E,A,ee){if(S.textBox||S.iconBox){let se,he;this.collisionBoxArrays.has(r)?se=this.collisionBoxArrays.get(r):(se=new Map,this.collisionBoxArrays.set(r,se)),se.has(g)?he=se.get(g):(he={text:null,icon:null},se.set(g,he)),S.textBox&&(he.text=E.box),S.iconBox&&(he.icon=A.box)}if(ee){let se=this.collisionCircleArrays[r];se===void 0&&(se=this.collisionCircleArrays[r]=new Pn);for(let he=0;he<ee.circles.length;he+=4)se.circles.push(ee.circles[he+0]),se.circles.push(ee.circles[he+1]),se.circles.push(ee.circles[he+2]),se.circles.push(ee.collisionDetected?1:0)}}markUsedJustification(r,g,S,E){let A;A=E===i.ah.vertical?S.verticalPlacedTextSymbolIndex:{left:S.leftJustifiedTextSymbolIndex,center:S.centerJustifiedTextSymbolIndex,right:S.rightJustifiedTextSymbolIndex}[i.at(g)];const ee=[S.leftJustifiedTextSymbolIndex,S.centerJustifiedTextSymbolIndex,S.rightJustifiedTextSymbolIndex,S.verticalPlacedTextSymbolIndex];for(const se of ee)se>=0&&(r.text.placedSymbolArray.get(se).crossTileID=A>=0&&se!==A?0:S.crossTileID)}markUsedOrientation(r,g,S){const E=g===i.ah.horizontal||g===i.ah.horizontalOnly?g:0,A=g===i.ah.vertical?g:0,ee=[S.leftJustifiedTextSymbolIndex,S.centerJustifiedTextSymbolIndex,S.rightJustifiedTextSymbolIndex];for(const se of ee)r.text.placedSymbolArray.get(se).placedOrientation=E;S.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(S.verticalPlacedTextSymbolIndex).placedOrientation=A)}commit(r){this.commitTime=r,this.zoomAtLastRecencyCheck=this.transform.zoom;const g=this.prevPlacement;let S=!1;this.prevZoomAdjustment=g?g.zoomAdjustment(this.transform.zoom):0;const E=g?g.symbolFadeChange(r):1,A=g?g.opacities:{},ee=g?g.variableOffsets:{},se=g?g.placedOrientations:{};for(const he in this.placements){const _e=this.placements[he],Ie=A[he];Ie?(this.opacities[he]=new Es(Ie,E,_e.text,_e.icon),S=S||_e.text!==Ie.text.placed||_e.icon!==Ie.icon.placed):(this.opacities[he]=new Es(null,E,_e.text,_e.icon,_e.skipFade),S=S||_e.text||_e.icon)}for(const he in A){const _e=A[he];if(!this.opacities[he]){const Ie=new Es(_e,E,!1,!1);Ie.isHidden()||(this.opacities[he]=Ie,S=S||_e.text.placed||_e.icon.placed)}}for(const he in ee)this.variableOffsets[he]||!this.opacities[he]||this.opacities[he].isHidden()||(this.variableOffsets[he]=ee[he]);for(const he in se)this.placedOrientations[he]||!this.opacities[he]||this.opacities[he].isHidden()||(this.placedOrientations[he]=se[he]);if(g&&g.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");S?this.lastPlacementChangeTime=r:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=g?g.lastPlacementChangeTime:r)}updateLayerOpacities(r,g){const S={};for(const E of g){const A=E.getBucket(r);A&&E.latestFeatureIndex&&r.id===A.layerIds[0]&&this.updateBucketOpacities(A,E.tileID,S,E.collisionBoxArray)}}updateBucketOpacities(r,g,S,E){r.hasTextData()&&(r.text.opacityVertexArray.clear(),r.text.hasVisibleVertices=!1),r.hasIconData()&&(r.icon.opacityVertexArray.clear(),r.icon.hasVisibleVertices=!1),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const A=r.layers[0],ee=A.layout,se=new Es(null,0,!1,!1,!0),he=ee.get("text-allow-overlap"),_e=ee.get("icon-allow-overlap"),Ie=A._unevaluatedLayout.hasValue("text-variable-anchor")||A._unevaluatedLayout.hasValue("text-variable-anchor-offset"),Me=ee.get("text-rotation-alignment")==="map",Je=ee.get("text-pitch-alignment")==="map",ut=ee.get("icon-text-fit")!=="none",gt=new Es(null,0,he&&(_e||!r.hasIconData()||ee.get("icon-optional")),_e&&(he||!r.hasTextData()||ee.get("text-optional")),!0);!r.collisionArrays&&E&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(E);const St=(Vt,Ht,Et)=>{for(let Kt=0;Kt<Ht/4;Kt++)Vt.opacityVertexArray.emplaceBack(Et);Vt.hasVisibleVertices=Vt.hasVisibleVertices||Et!==Ha},Lt=this.collisionBoxArrays.get(r.bucketInstanceId);for(let Vt=0;Vt<r.symbolInstances.length;Vt++){const Ht=r.symbolInstances.get(Vt),{numHorizontalGlyphVertices:Et,numVerticalGlyphVertices:Kt,crossTileID:ss}=Ht;let cs=this.opacities[ss];S[ss]?cs=se:cs||(cs=gt,this.opacities[ss]=cs),S[ss]=!0;const As=Ht.numIconVertices>0,sn=this.placedOrientations[Ht.crossTileID],pn=sn===i.ah.vertical,Ln=sn===i.ah.horizontal||sn===i.ah.horizontalOnly;if(Et>0||Kt>0){const on=Ka(cs.text);St(r.text,Et,pn?Ha:on),St(r.text,Kt,Ln?Ha:on);const Hn=cs.text.isHidden();[Ht.rightJustifiedTextSymbolIndex,Ht.centerJustifiedTextSymbolIndex,Ht.leftJustifiedTextSymbolIndex].forEach(Nn=>{Nn>=0&&(r.text.placedSymbolArray.get(Nn).hidden=Hn||pn?1:0)}),Ht.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(Ht.verticalPlacedTextSymbolIndex).hidden=Hn||Ln?1:0);const Ra=this.variableOffsets[Ht.crossTileID];Ra&&this.markUsedJustification(r,Ra.anchor,Ht,sn);const ln=this.placedOrientations[Ht.crossTileID];ln&&(this.markUsedJustification(r,"left",Ht,ln),this.markUsedOrientation(r,ln,Ht))}if(As){const on=Ka(cs.icon),Hn=!(ut&&Ht.verticalPlacedIconSymbolIndex&&pn);Ht.placedIconSymbolIndex>=0&&(St(r.icon,Ht.numIconVertices,Hn?on:Ha),r.icon.placedSymbolArray.get(Ht.placedIconSymbolIndex).hidden=cs.icon.isHidden()),Ht.verticalPlacedIconSymbolIndex>=0&&(St(r.icon,Ht.numVerticalIconVertices,Hn?Ha:on),r.icon.placedSymbolArray.get(Ht.verticalPlacedIconSymbolIndex).hidden=cs.icon.isHidden())}const Js=Lt&&Lt.has(Vt)?Lt.get(Vt):{text:null,icon:null};if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const on=r.collisionArrays[Vt];if(on){let Hn=new i.P(0,0);if(on.textBox||on.verticalTextBox){let Ra=!0;if(Ie){const ln=this.variableOffsets[ss];ln?(Hn=Fn(ln.anchor,ln.width,ln.height,ln.textOffset,ln.textBoxScale),Me&&Hn._rotate(Je?this.transform.angle:-this.transform.angle)):Ra=!1}if(on.textBox||on.verticalTextBox){let ln;on.textBox&&(ln=pn),on.verticalTextBox&&(ln=Ln),sr(r.textCollisionBox.collisionVertexArray,cs.text.placed,!Ra||ln,Js.text,Hn.x,Hn.y)}}if(on.iconBox||on.verticalIconBox){const Ra=!!(!Ln&&on.verticalIconBox);let ln;on.iconBox&&(ln=Ra),on.verticalIconBox&&(ln=!Ra),sr(r.iconCollisionBox.collisionVertexArray,cs.icon.placed,ln,Js.icon,ut?Hn.x:0,ut?Hn.y:0)}}}}if(r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.text.opacityVertexArray.length!==r.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${r.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${r.text.layoutVertexArray.length}) / 4`);if(r.icon.opacityVertexArray.length!==r.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${r.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${r.icon.layoutVertexArray.length}) / 4`);if(r.bucketInstanceId in this.collisionCircleArrays){const Vt=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=Vt.invProjMatrix,r.placementViewportMatrix=Vt.viewportMatrix,r.collisionCircleArray=Vt.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(r){return this.fadeDuration===0?1:(r-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(r){return Math.max(0,(this.transform.zoom-r)/1.5)}hasTransitions(r){return this.stale||r-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(r,g){const S=this.zoomAtLastRecencyCheck===g?1-this.zoomAdjustment(g):1;return this.zoomAtLastRecencyCheck=g,this.commitTime+this.fadeDuration*S>r}setStale(){this.stale=!0}}function sr(R,r,g,S,E,A){S&&S.length!==0||(S=[0,0,0,0]);const ee=S[0]-Hs,se=S[1]-Hs,he=S[2]-Hs,_e=S[3]-Hs;R.emplaceBack(r?1:0,g?1:0,E||0,A||0,ee,se),R.emplaceBack(r?1:0,g?1:0,E||0,A||0,he,se),R.emplaceBack(r?1:0,g?1:0,E||0,A||0,he,_e),R.emplaceBack(r?1:0,g?1:0,E||0,A||0,ee,_e)}const An=Math.pow(2,25),Ai=Math.pow(2,24),xi=Math.pow(2,17),ei=Math.pow(2,16),Yr=Math.pow(2,9),Xo=Math.pow(2,8),ra=Math.pow(2,1);function Ka(R){if(R.opacity===0&&!R.placed)return 0;if(R.opacity===1&&R.placed)return 4294967295;const r=R.placed?1:0,g=Math.floor(127*R.opacity);return g*An+r*Ai+g*xi+r*ei+g*Yr+r*Xo+g*ra+r}const Ha=0;function qa(){return{isOccluded:(R,r,g)=>!1,getPitchedTextCorrection:(R,r,g)=>1,get useSpecialProjectionForSymbols(){return!1},projectTileCoordinates(R,r,g,S){throw new Error("Not implemented.")},translatePosition:(R,r,g,S)=>
1962function(E,A,ee,se,he=!1){if(!ee[0]&&!ee[1])return[0,0];const _e=he?se==="map"?E.angle:0:se==="viewport"?-E.angle:0;if(_e){const Ie=Math.sin(_e),Me=Math.cos(_e);ee=[ee[0]*Me-ee[1]*Ie,ee[0]*Ie+ee[1]*Me]}return[he?ee[0]:os(A,ee[0],E.zoom),he?ee[1]:os(A,ee[1],E.zoom)]}(R,r,g,S),getCircleRadiusCorrection:R=>1}}class Mn{constructor(r){this._sortAcrossTiles=r.layout.get("symbol-z-order")!=="viewport-y"&&!r.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(r,g,S,E,A){const ee=this._bucketParts;for(;this._currentTileIndex<r.length;)if(g.getBucketParts(ee,E,r[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,A())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,ee.sort((se,he)=>se.sortKey-he.sortKey));this._currentPartIndex<ee.length;)if(g.placeLayerBucketPart(ee[this._currentPartIndex],this._seenCrossTileIDs,S),this._currentPartIndex++,A())return!0;return!1}}class _r{constructor(r,g,S,E,A,ee,se,he){this.placement=new Sa(r,qa(),g,ee,se,he),this._currentPlacementIndex=S.length-1,this._forceFullPlacement=E,this._showCollisionBoxes=A,this._done=!1}isDone(){return this._done}continuePlacement(r,g,S){const E=x.now(),A=()=>!this._forceFullPlacement&&x.now()-E>2;for(;this._currentPlacementIndex>=0;){const ee=g[r[this._currentPlacementIndex]],se=this.placement.collisionIndex.transform.zoom;if(ee.type==="symbol"&&(!ee.minzoom||ee.minzoom<=se)&&(!ee.maxzoom||ee.maxzoom>se)){if(this._inProgressLayer||(this._inProgressLayer=new Mn(ee)),this._inProgressLayer.continuePlacement(S[ee.source],this.placement,this._showCollisionBoxes,ee,A))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(r){return this.placement.commit(r),this.placement}}const Ar=512/i.X/2;class Zs{constructor(r,g,S){this.tileID=r,this.bucketInstanceId=S,this._symbolsByKey={};const E=new Map;for(let A=0;A<g.length;A++){const ee=g.get(A),se=ee.key,he=E.get(se);he?he.push(ee):E.set(se,[ee])}for(const[A,ee]of E){const se={positions:ee.map(he=>({x:Math.floor(he.anchorX*Ar),y:Math.floor(he.anchorY*Ar)})),crossTileIDs:ee.map(he=>he.crossTileID)};if(se.positions.length>128){const he=new i.av(se.positions.length,16,Uint16Array);for(const{x:_e,y:Ie}of se.positions)he.add(_e,Ie);he.finish(),delete se.positions,se.index=he}this._symbolsByKey[A]=se}}getScaledCoordinates(r,g){const{x:S,y:E,z:A}=this.tileID.canonical,{x:ee,y:se,z:he}=g.canonical,_e=Ar/Math.pow(2,he-A),Ie=(se*i.X+r.anchorY)*_e,Me=E*i.X*Ar;return{x:Math.floor((ee*i.X+r.anchorX)*_e-S*i.X*Ar),y:Math.floor(Ie-Me)}}
1962findMatches(r,g,S){const E=this.tileID.canonical.z<g.canonical.z?1:Math.pow(2,this.tileID.canonical.z-g.canonical.z);for(let A=0;A<r.length;A++){const ee=r.get(A);if(ee.crossTileID)continue;const se=this._symbolsByKey[ee.key];if(!se)continue;const he=this.getScaledCoordinates(ee,g);if(se.index){const _e=se.index.range(he.x-E,he.y-E,he.x+E,he.y+E).sort();for(const Ie of _e){const Me=se.crossTileIDs[Ie];if(!S[Me]){S[Me]=!0,ee.crossTileID=Me;break}}}else if(se.positions)for(let _e=0;_e<se.positions.length;_e++){const Ie=se.positions[_e],Me=se.crossTileIDs[_e];if(Math.abs(Ie.x-he.x)<=E&&Math.abs(Ie.y-he.y)<=E&&!S[Me]){S[Me]=!0,ee.crossTileID=Me;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:r})=>r)}}class Cn{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Na{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(r){const g=Math.round((r-this.lng)/360);if(g!==0)for(const S in this.indexes){const E=this.indexes[S],A={};for(const ee in E){const se=E[ee];se.tileID=se.tileID.unwrapTo(se.tileID.wrap+g),A[se.tileID.key]=se}this.indexes[S]=A}this.lng=r}addBucket(r,g,S){if(this.indexes[r.overscaledZ]&&this.indexes[r.overscaledZ][r.key]){if(this.indexes[r.overscaledZ][r.key].bucketInstanceId===g.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(r.overscaledZ,this.indexes[r.overscaledZ][r.key])}for(let A=0;A<g.symbolInstances.length;A++)g.symbolInstances.get(A).crossTileID=0;this.usedCrossTileIDs[r.overscaledZ]||(this.usedCrossTileIDs[r.overscaledZ]={});const E=this.usedCrossTileIDs[r.overscaledZ];for(const A in this.indexes){const ee=this.indexes[A];if(Number(A)>r.overscaledZ)for(const se in ee){const he=ee[se];he.tileID.isChildOf(r)&&he.findMatches(g.symbolInstances,r,E)}else{const se=ee[r.scaledTo(Number(A)).key];se&&se.findMatches(g.symbolInstances,r,E)}}for(let A=0;A<g.symbolInstances.length;A++){const ee=g.symbolInstances.get(A);ee.crossTileID||(ee.crossTileID=S.generate(),E[ee.crossTileID]=!0)}return this.indexes[r.overscaledZ]===void 0&&(this.indexes[r.overscaledZ]={}),this.indexes[r.overscaledZ][r.key]=new Zs(r,g.symbolInstances,g.bucketInstanceId),!0}removeBucketCrossTileIDs(r,g){for(const S of g.getCrossTileIDsLists())for(const E of S)delete this.usedCrossTileIDs[r][E]}removeStaleBuckets(r){let g=!1;for(const S in this.indexes){const E=this.indexes[S];for(const A in E)r[E[A].bucketInstanceId]||(this.removeBucketCrossTileIDs(S,E[A]),delete E[A],g=!0)}return g}}class Gn{constructor(){this.layerIndexes={},this.crossTileIDs=new Cn,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(r,g,S){let E=this.layerIndexes[r.id];E===void 0&&(E=this.layerIndexes[r.id]=new Na);let A=!1;const ee={};E.handleWrapJump(S);for(const se of g){const he=se.getBucket(r);he&&r.id===he.layerIds[0]&&(he.bucketInstanceId||(he.bucketInstanceId=++this.maxBucketInstanceId),E.addBucket(se.tileID,he,this.crossTileIDs)&&(A=!0),ee[he.bucketInstanceId]=!0)}return E.removeStaleBuckets(ee)&&(A=!0),A}pruneUnusedLayers(r){const g={};r.forEach(S=>{g[S]=!0});for(const S in this.layerIndexes)g[S]||delete this.layerIndexes[S]}}const sa=(R,r)=>i.t(R,r&&r.filter(g=>g.identifier!=="source.canvas")),Pr=i.aw();class oi extends i.E{constructor(r,g={}){super(),this._rtlPluginLoaded=()=>{for(const S in this.sourceCaches){const E=this.sourceCaches[S].getSource().type;E!=="vector"&&E!=="geojson"||this.sourceCaches[S].reload()}},this.map=r,this.dispatcher=new ft(qt(),r._getMapId()),this.dispatcher.registerMessageHandler("GG",(S,E)=>this.getGlyphs(S,E)),this.dispatcher.registerMessageHandler("GI",(S,E)=>this.getImages(S,E)),this.imageManager=new oe,this.imageManager.setEventedParent(this),this.glyphManager=new de(r._requestManager,g.localIdeographFontFamily),this.lineAtlas=new Ze(256,512),this.crossTileSymbolIndex=new Gn,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new i.ax,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",i.ay()),bs().on($t,this._rtlPluginLoaded),this.on("data",S=>{if(S.dataType!=="source"||S.sourceDataType!=="metadata")return;const E=this.sourceCaches[S.sourceId];if(!E)return;const A=E.getSource();if(A&&A.vectorLayerIds)for(const ee in this._layers){const se=this._layers[ee];
1962se.source===A.id&&this._validateLayer(se)}})}loadURL(r,g={},S){this.fire(new i.k("dataloading",{dataType:"style"})),g.validate=typeof g.validate!="boolean"||g.validate;const E=this.map._requestManager.transformRequest(r,"Style");this._loadStyleRequest=new AbortController;const A=this._loadStyleRequest;i.h(E,this._loadStyleRequest).then(ee=>{this._loadStyleRequest=null,this._load(ee.data,g,S)}).catch(ee=>{this._loadStyleRequest=null,ee&&!A.signal.aborted&&this.fire(new i.j(ee))})}loadJSON(r,g={},S){this.fire(new i.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,x.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,g.validate=g.validate!==!1,this._load(r,g,S)}).catch(()=>{})}loadEmpty(){this.fire(new i.k("dataloading",{dataType:"style"})),this._load(Pr,{validate:!1})}_load(r,g,S){var E;const A=g.transformStyle?g.transformStyle(S,r):r;if(!g.validate||!sa(this,i.u(A))){this._loaded=!0,this.stylesheet=A;for(const ee in A.sources)this.addSource(ee,A.sources[ee],{validate:!1});A.sprite?this._loadSprite(A.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(A.glyphs),this._createLayers(),this.light=new Ee(this.stylesheet.light),this.sky=new we(this.stylesheet.sky),this.map.setTerrain((E=this.stylesheet.terrain)!==null&&E!==void 0?E:null),this.fire(new i.k("data",{dataType:"style"})),this.fire(new i.k("style.load"))}}_createLayers(){const r=i.az(this.stylesheet.layers);this.dispatcher.broadcast("SL",r),this._order=r.map(g=>g.id),this._layers={},this._serializedLayers=null;for(const g of r){const S=i.aA(g);S.setEventedParent(this,{layer:{id:g.id}}),this._layers[g.id]=S}}_loadSprite(r,g=!1,S=void 0){let E;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(A,ee,se,he){return i._(this,void 0,void 0,function*(){const _e=q(A),Ie=se>1?"@2x":"",Me={},Je={};for(const{id:ut,url:gt}of _e){const St=ee.transformRequest(W(gt,Ie,".json"),"SpriteJSON");Me[ut]=i.h(St,he);const Lt=ee.transformRequest(W(gt,Ie,".png"),"SpriteImage");Je[ut]=X.getImage(Lt,he)}return yield Promise.all([...Object.values(Me),...Object.values(Je)]),function(ut,gt){return i._(this,void 0,void 0,function*(){const St={};for(const Lt in ut){St[Lt]={};const Vt=x.getImageCanvasContext((yield gt[Lt]).data),Ht=(yield ut[Lt]).data;for(const Et in Ht){const{width:Kt,height:ss,x:cs,y:As,sdf:sn,pixelRatio:pn,stretchX:Ln,stretchY:Js,content:on,textFitWidth:Hn,textFitHeight:Ra}=Ht[Et];St[Lt][Et]={data:null,pixelRatio:pn,sdf:sn,stretchX:Ln,stretchY:Js,content:on,textFitWidth:Hn,textFitHeight:Ra,spriteData:{width:Kt,height:ss,x:cs,y:As,context:Vt}}}}return St})}(Me,Je)})}(r,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(A=>{if(this._spriteRequest=null,A)for(const ee in A){this._spritesImagesIds[ee]=[];const se=this._spritesImagesIds[ee]?this._spritesImagesIds[ee].filter(he=>!(he in A)):[];for(const he of se)this.imageManager.removeImage(he),this._changedImages[he]=!0;for(const he in A[ee]){const _e=ee==="default"?he:`${ee}:${he}`;this._spritesImagesIds[ee].push(_e),_e in this.imageManager.images?this.imageManager.updateImage(_e,A[ee][he],!1):this.imageManager.addImage(_e,A[ee][he]),g&&(this._changedImages[_e]=!0)}}}).catch(A=>{this._spriteRequest=null,E=A,this.fire(new i.j(E))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),g&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new i.k("data",{dataType:"style"})),S&&S(E)})}_unloadSprite(){for(const r of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(r),this._changedImages[r]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new i.k("data",{dataType:"style"}))}_validateLayer(r){const g=this.sourceCaches[r.source];if(!g)return;const S=r.sourceLayer;if(!S)return;const E=g.getSource();(E.type==="geojson"||E.vectorLayerIds&&E.vectorLayerIds.indexOf(S)===-1)&&this.fire(new i.j(new Error(`Source layer "${S}" does not exist on source "${E.id}" as specified by style layer "${r.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const r in this.sourceCaches)if(!this.sourceCaches[r].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(r,g=!1){const S=this._serializedAllLayers();if(!r||r.length===0)return Object.values(g?i.aB(S):S);const E=[];for(const A of r)if(S[A]){const ee=g?i.aB(S[A]):S[A];E.push(ee)}return E}_serializedAllLayers(){let r=this._serializedLayers;if(r)return r;r=this._serializedLayers={};const g=Object.keys(this._layers);for(const S of g){const E=this._layers[S];E.type!=="custom"&&(r[S]=E.serialize())}return r}hasTransitions(){if(this.light&&this.light.hasTransition()||this.sky&&this.sky.hasTransition())return!0;for(const r in this.sourceCaches)if(this.sourceCaches[r].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(r){if(!this._loaded)return;const g=this._changed;if(g){const E=Object.keys(this._updatedLayers),A=Object.keys(this._removedLayers);(E.length||A.length)&&this._updateWorkerLayers(E,A);for(const ee in this._updatedSources){const se=this._updatedSources[ee];if(se==="reload")this._reloadSource(ee);else{if(se!=="clear")throw new Error(`Invalid action ${se}`);this._clearSource(ee)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const ee in this._updatedPaintProps)this._layers[ee].updateTransitions(r);this.light.updateTransitions(r),this.sky.updateTransitions(r),this._resetUpdates()}const S={};for(const E in this.sourceCaches){const A=this.sourceCaches[E];S[E]=A.used,A.used=!1}for(const E of this._order){const A=this._layers[E];A.recalculate(r,this._availableImages),!A.isHidden(r.zoom)&&A.source&&(this.sourceCaches[A.source].used=!0)}for(const E in S){const A=this.sourceCaches[E];!!S[E]!=!!A.used&&A.fire(new i.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:E}))}this.light.recalculate(r),this.sky.recalculate(r),this.z=r.zoom,g&&this.fire(new i.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){const r=Object.keys(this._changedImages);if(r.length){for(const g in this.sourceCaches)this.sourceCaches[g].reloadTilesForDependencies(["icons","patterns"],r);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const r in this.sourceCaches)this.sourceCaches[r].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(r,g){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(r,!1),removedIds:g})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(r,g={}){var S;this._checkLoaded();const E=this.serialize();if(r=g.transformStyle?g.transformStyle(E,r):r,((S=g.validate)===null||S===void 0||S)&&sa(this,i.u(r)))return!1;(r=i.aB(r)).layers=i.az(r.layers);const A=i.aC(E,r),ee=this._getOperationsToPerform(A);if(ee.unimplemented.length>0)throw new Error(`Unimplemented: ${ee.unimplemented.join(", ")}.`);
1962if(ee.operations.length===0)return!1;for(const se of ee.operations)se();return this.stylesheet=r,this._serializedLayers=null,!0}_getOperationsToPerform(r){const g=[],S=[];for(const E of r)switch(E.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":continue;case"addLayer":g.push(()=>this.addLayer.apply(this,E.args));break;case"removeLayer":g.push(()=>this.removeLayer.apply(this,E.args));break;case"setPaintProperty":g.push(()=>this.setPaintProperty.apply(this,E.args));break;case"setLayoutProperty":g.push(()=>this.setLayoutProperty.apply(this,E.args));break;case"setFilter":g.push(()=>this.setFilter.apply(this,E.args));break;case"addSource":g.push(()=>this.addSource.apply(this,E.args));break;case"removeSource":g.push(()=>this.removeSource.apply(this,E.args));break;case"setLayerZoomRange":g.push(()=>this.setLayerZoomRange.apply(this,E.args));break;case"setLight":g.push(()=>this.setLight.apply(this,E.args));break;case"setGeoJSONSourceData":g.push(()=>this.setGeoJSONSourceData.apply(this,E.args));break;case"setGlyphs":g.push(()=>this.setGlyphs.apply(this,E.args));break;case"setSprite":g.push(()=>this.setSprite.apply(this,E.args));break;case"setSky":g.push(()=>this.setSky.apply(this,E.args));break;case"setTerrain":g.push(()=>this.map.setTerrain.apply(this,E.args));break;case"setTransition":g.push(()=>{});break;default:S.push(E.command)}return{operations:g,unimplemented:S}}addImage(r,g){if(this.getImage(r))return this.fire(new i.j(new Error(`An image named "${r}" already exists.`)));this.imageManager.addImage(r,g),this._afterImageUpdated(r)}updateImage(r,g){this.imageManager.updateImage(r,g)}getImage(r){return this.imageManager.getImage(r)}removeImage(r){if(!this.getImage(r))return this.fire(new i.j(new Error(`An image named "${r}" does not exist.`)));this.imageManager.removeImage(r),this._afterImageUpdated(r)}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new i.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(r,g,S={}){if(this._checkLoaded(),this.sourceCaches[r]!==void 0)throw new Error(`Source "${r}" already exists.`);if(!g.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(g).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(g.type)>=0&&this._validate(i.u.source,`sources.${r}`,g,null,S))return;this.map&&this.map._collectResourceTiming&&(g.collectResourceTiming=!0);const E=this.sourceCaches[r]=new ps(r,g,this.dispatcher);E.style=this,E.setEventedParent(this,()=>({isSourceLoaded:E.loaded(),source:E.serialize(),sourceId:r})),E.onAdd(this.map),this._changed=!0}removeSource(r){if(this._checkLoaded(),this.sourceCaches[r]===void 0)throw new Error("There is no source with this ID");for(const S in this._layers)if(this._layers[S].source===r)return this.fire(new i.j(new Error(`Source "${r}" cannot be removed while layer "${S}" is using it.`)));const g=this.sourceCaches[r];delete this.sourceCaches[r],delete this._updatedSources[r],g.fire(new i.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:r})),g.setEventedParent(null),g.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(r,g){if(this._checkLoaded(),this.sourceCaches[r]===void 0)throw new Error(`There is no source with this ID=${r}`);const S=this.sourceCaches[r].getSource();if(S.type!=="geojson")throw new Error(`geojsonSource.type is ${S.type}, which is !== 'geojson`);S.setData(g),this._changed=!0}getSource(r){return this.sourceCaches[r]&&this.sourceCaches[r].getSource()}addLayer(r,g,S={}){this._checkLoaded();const E=r.id;if(this.getLayer(E))return void this.fire(new i.j(new Error(`Layer "${E}" already exists on this map.`)));let A;if(r.type==="custom"){if(sa(this,i.aD(r)))return;A=i.aA(r)}else{if("source"in r&&typeof r.source=="object"&&(this.addSource(E,r.source),r=i.aB(r),r=i.e(r,{source:E})),this._validate(i.u.layer,`layers.${E}`,r,{arrayIndex:-1},S))return;
vendor: 6,056 bytes, line 1962
1962A=i.aA(r),this._validateLayer(A),A.setEventedParent(this,{layer:{id:E}})}const ee=g?this._order.indexOf(g):this._order.length;if(g&&ee===-1)this.fire(new i.j(new Error(`Cannot add layer "${E}" before non-existing layer "${g}".`)));else{if(this._order.splice(ee,0,E),this._layerOrderChanged=!0,this._layers[E]=A,this._removedLayers[E]&&A.source&&A.type!=="custom"){const se=this._removedLayers[E];delete this._removedLayers[E],se.type!==A.type?this._updatedSources[A.source]="clear":(this._updatedSources[A.source]="reload",this.sourceCaches[A.source].pause())}this._updateLayer(A),A.onAdd&&A.onAdd(this.map)}}moveLayer(r,g){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new i.j(new Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===g)return;const S=this._order.indexOf(r);this._order.splice(S,1);const E=g?this._order.indexOf(g):this._order.length;g&&E===-1?this.fire(new i.j(new Error(`Cannot move layer "${r}" before non-existing layer "${g}".`))):(this._order.splice(E,0,r),this._layerOrderChanged=!0)}removeLayer(r){this._checkLoaded();const g=this._layers[r];if(!g)return void this.fire(new i.j(new Error(`Cannot remove non-existing layer "${r}".`)));g.setEventedParent(null);const S=this._order.indexOf(r);this._order.splice(S,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=g,delete this._layers[r],this._serializedLayers&&delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],g.onRemove&&g.onRemove(this.map)}getLayer(r){return this._layers[r]}getLayersOrder(){return[...this._order]}hasLayer(r){return r in this._layers}setLayerZoomRange(r,g,S){this._checkLoaded();const E=this.getLayer(r);E?E.minzoom===g&&E.maxzoom===S||(g!=null&&(E.minzoom=g),S!=null&&(E.maxzoom=S),this._updateLayer(E)):this.fire(new i.j(new Error(`Cannot set the zoom range of non-existing layer "${r}".`)))}setFilter(r,g,S={}){this._checkLoaded();const E=this.getLayer(r);if(E){if(!i.aE(E.filter,g))return g==null?(E.filter=void 0,void this._updateLayer(E)):void(this._validate(i.u.filter,`layers.${E.id}.filter`,g,null,S)||(E.filter=i.aB(g),this._updateLayer(E)))}else this.fire(new i.j(new Error(`Cannot filter non-existing layer "${r}".`)))}getFilter(r){return i.aB(this.getLayer(r).filter)}setLayoutProperty(r,g,S,E={}){this._checkLoaded();const A=this.getLayer(r);A?i.aE(A.getLayoutProperty(g),S)||(A.setLayoutProperty(g,S,E),this._updateLayer(A)):this.fire(new i.j(new Error(`Cannot style non-existing layer "${r}".`)))}getLayoutProperty(r,g){const S=this.getLayer(r);if(S)return S.getLayoutProperty(g);this.fire(new i.j(new Error(`Cannot get style of non-existing layer "${r}".`)))}setPaintProperty(r,g,S,E={}){this._checkLoaded();const A=this.getLayer(r);A?i.aE(A.getPaintProperty(g),S)||(A.setPaintProperty(g,S,E)&&this._updateLayer(A),this._changed=!0,this._updatedPaintProps[r]=!0,this._serializedLayers=null):this.fire(new i.j(new Error(`Cannot style non-existing layer "${r}".`)))}getPaintProperty(r,g){return this.getLayer(r).getPaintProperty(g)}setFeatureState(r,g){this._checkLoaded();const S=r.source,E=r.sourceLayer,A=this.sourceCaches[S];if(A===void 0)return void this.fire(new i.j(new Error(`The source '${S}' does not exist in the map's style.`)));const ee=A.getSource().type;ee==="geojson"&&E?this.fire(new i.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):ee!=="vector"||E?(r.id===void 0&&this.fire(new i.j(new Error("The feature id parameter must be provided."))),A.setFeatureState(E,r.id,g)):this.fire(new i.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(r,g){this._checkLoaded();const S=r.source,E=this.sourceCaches[S];if(E===void 0)return void this.fire(new i.j(new Error(`The source '${S}' does not exist in the map's style.`)));const A=E.getSource().type,ee=A==="vector"?r.sourceLayer:void 0;A!=="vector"||ee?g&&typeof r.id!="string"&&typeof r.id!="number"?this.fire(new i.j(new Error("A feature id is required to remove its specific state property."))):E.removeFeatureState(ee,r.id,g):this.fire(new i.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(r){this._checkLoaded();const g=r.source,S=r.sourceLayer,E=this.sourceCaches[g];if(E!==void 0)return E.getSource().type!=="vector"||S?(r.id===void 0&&this.fire(new i.j(new Error("The feature id parameter must be provided."))),E.getFeatureState(S,r.id)):void this.fire(new i.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new i.j(new Error(`The source '${g}' does not exist in the map's style.`)))}getTransition(){return i.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const r=i.aF(this.sourceCaches,A=>A.serialize()),g=this._serializeByIds(this._order,!0),S=this.map.getTerrain()||void 0,E=this.stylesheet;return i.aG({version:E.version,name:E.name,metadata:E.metadata,light:E.light,sky:E.sky,center:E.center,zoom:E.zoom,bearing:E.bearing,pitch:E.pitch,sprite:E.sprite,glyphs:E.glyphs,transition:E.transition,sources:r,layers:g,terrain:S},A=>A!==void 0)}_updateLayer(r){this._updatedLayers[r.id]=!0,r.source&&!this._updatedSources[r.source]&&this.sourceCaches[r.source].getSource().type!=="raster"&&(this._updatedSources[r.source]="reload",this.sourceCaches[r.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(r){const g=ee=>this._layers[ee].type==="fill-extrusion",S={},E=[];for(let ee=this._order.length-1;ee>=0;ee--){const se=this._order[ee];if(g(se)){S[se]=ee;for(const he of r){const _e=he[se];if(_e)for(const Ie of _e)E.push(Ie)}}}E.sort((ee,se)=>se.intersectionZ-ee.intersectionZ);const A=[];for(let ee=this._order.length-1;ee>=0;ee--){const se=this._order[ee];if(g(se))for(let he=E.length-1;he>=0;he--){const _e=E[he].feature;if(S[_e.layer.id]<ee)break;A.push(_e),E.pop()}else for(const he of r){const _e=he[se];if(_e)for(const Ie of _e)A.push(Ie.feature)}}return A}
1962queryRenderedFeatures(r,g,S){g&&g.filter&&this._validate(i.u.filter,"queryRenderedFeatures.filter",g.filter,null,g);const E={};if(g&&g.layers){if(!Array.isArray(g.layers))return this.fire(new i.j(new Error("parameters.layers must be an Array."))),[];for(const se of g.layers){const he=this._layers[se];if(!he)return this.fire(new i.j(new Error(`The layer '${se}' does not exist in the map's style and cannot be queried for features.`))),[];E[he.source]=!0}}const A=[];g.availableImages=this._availableImages;const ee=this._serializedAllLayers();for(const se in this.sourceCaches)g.layers&&!E[se]||A.push(Qe(this.sourceCaches[se],this._layers,ee,r,g,S));return this.placement&&A.push(function(se,he,_e,Ie,Me,Je,ut){const gt={},St=Je.queryRenderedSymbols(Ie),Lt=[];for(const Vt of Object.keys(St).map(Number))Lt.push(ut[Vt]);Lt.sort(ht);for(const Vt of Lt){const Ht=Vt.featureIndex.lookupSymbolFeatures(St[Vt.bucketInstanceId],he,Vt.bucketIndex,Vt.sourceLayerIndex,Me.filter,Me.layers,Me.availableImages,se);for(const Et in Ht){const Kt=gt[Et]=gt[Et]||[],ss=Ht[Et];ss.sort((cs,As)=>{const sn=Vt.featureSortOrder;if(sn){const pn=sn.indexOf(cs.featureIndex);return sn.indexOf(As.featureIndex)-pn}return As.featureIndex-cs.featureIndex});for(const cs of ss)Kt.push(cs)}}for(const Vt in gt)gt[Vt].forEach(Ht=>{const Et=Ht.feature,Kt=_e[se[Vt].source].getFeatureState(Et.layer["source-layer"],Et.id);Et.source=Et.layer.source,Et.layer["source-layer"]&&(Et.sourceLayer=Et.layer["source-layer"]),Et.state=Kt});return gt}(this._layers,ee,this.sourceCaches,r,g,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(A)}querySourceFeatures(r,g){g&&g.filter&&this._validate(i.u.filter,"querySourceFeatures.filter",g.filter,null,g);const S=this.sourceCaches[r];return S?function(E,A){const ee=E.getRenderableIds().map(_e=>E.getTileByID(_e)),se=[],he={};for(let _e=0;_e<ee.length;_e++){const Ie=ee[_e],Me=Ie.tileID.canonical.key;he[Me]||(he[Me]=!0,Ie.querySourceFeatures(se,A))}return se}(S,g):[]}getLight(){return this.light.getLight()}setLight(r,g={}){this._checkLoaded();const S=this.light.getLight();let E=!1;for(const ee in r)if(!i.aE(r[ee],S[ee])){E=!0;break}if(!E)return;const A={now:x.now(),transition:i.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(r,g),this.light.updateTransitions(A)}getSky(){var r;return(r=this.stylesheet)===null||r===void 0?void 0:r.sky}setSky(r,g={}){const S=this.getSky();let E=!1;if(!r&&!S)return;if(r&&!S)E=!0;else if(!r&&S)E=!0;else for(const ee in r)if(!i.aE(r[ee],S[ee])){E=!0;break}if(!E)return;const A={now:x.now(),transition:i.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=r,this.sky.setSky(r,g),this.sky.updateTransitions(A)}_validate(r,g,S,E,A={}){return(!A||A.validate!==!1)&&sa(this,r.call(i.u,i.e({key:g,style:this.serialize(),value:S,styleSpec:i.v},E)))}_remove(r=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),bs().off($t,this._rtlPluginLoaded);for(const g in this._layers)this._layers[g].setEventedParent(null);for(const g in this.sourceCaches){const S=this.sourceCaches[g];S.setEventedParent(null),S.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),r&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(r)}_clearSource(r){this.sourceCaches[r].clearTiles()}_reloadSource(r){this.sourceCaches[r].resume(),this.sourceCaches[r].reload()}_updateSources(r){for(const g in this.sourceCaches)this.sourceCaches[g].update(r,this.map.terrain)}_generateCollisionBoxes(){for(const r in this.sourceCaches)this._reloadSource(r)}_updatePlacement(r,g,S,E,A=!1){let ee=!1,se=!1;const he={};for(const _e of this._order){const Ie=this._layers[_e];if(Ie.type!=="symbol")continue;if(!he[Ie.source]){const Je=this.sourceCaches[Ie.source];he[Ie.source]=Je.getRenderableIds(!0).map(ut=>Je.getTileByID(ut)).sort((ut,gt)=>gt.tileID.overscaledZ-ut.tileID.overscaledZ||(ut.tileID.isLessThan(gt.tileID)?-1:1))}const Me=this.crossTileSymbolIndex.addLayer(Ie,he[Ie.source],r.center.lng);ee=ee||Me}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((A=A||this._layerOrderChanged||S===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(x.now(),r.zoom))&&(this.pauseablePlacement=new _r(r,this.map.terrain,this._order,A,g,S,E,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,he),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(x.now()),se=!0),ee&&this.pauseablePlacement.placement.setStale()),se||ee)for(const _e of this._order){const Ie=this._layers[_e];Ie.type==="symbol"&&this.placement.updateLayerOpacities(Ie,he[Ie.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(x.now())}_releaseSymbolFadeTiles(){for(const r in this.sourceCaches)this.sourceCaches[r].releaseSymbolFadeTiles()}getImages(r,g){return i._(this,void 0,void 0,function*(){const S=yield this.imageManager.getImages(g.icons);this._updateTilesForChangedImages();const E=this.sourceCaches[g.source];return E&&E.setDependencies(g.tileID.key,g.type,g.icons),S})}getGlyphs(r,g){return i._(this,void 0,void 0,function*(){const S=yield this.glyphManager.getGlyphs(g.stacks),E=this.sourceCaches[g.source];return E&&E.setDependencies(g.tileID.key,g.type,[""]),S})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(r,g={}
vendor: 4,518 bytes, lines 1962-2021
1962){this._checkLoaded(),r&&this._validate(i.u.glyphs,"glyphs",r,null,g)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=r,this.glyphManager.entries={},this.glyphManager.setURL(r))}addSprite(r,g,S={},E){this._checkLoaded();const A=[{id:r,url:g}],ee=[...q(this.stylesheet.sprite),...A];this._validate(i.u.sprite,"sprite",ee,null,S)||(this.stylesheet.sprite=ee,this._loadSprite(A,!0,E))}removeSprite(r){this._checkLoaded();const g=q(this.stylesheet.sprite);if(g.find(S=>S.id===r)){if(this._spritesImagesIds[r])for(const S of this._spritesImagesIds[r])this.imageManager.removeImage(S),this._changedImages[S]=!0;g.splice(g.findIndex(S=>S.id===r),1),this.stylesheet.sprite=g.length>0?g:void 0,delete this._spritesImagesIds[r],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new i.k("data",{dataType:"style"}))}else this.fire(new i.j(new Error(`Sprite "${r}" doesn't exists on this map.`)))}getSprite(){return q(this.stylesheet.sprite)}setSprite(r,g={},S){this._checkLoaded(),r&&this._validate(i.u.sprite,"sprite",r,null,g)||(this.stylesheet.sprite=r,r?this._loadSprite(r,!0,S):(this._unloadSprite(),S&&S(null)))}}var Tr=i.Y([{name:"a_pos",type:"Int16",components:2}]);const Ko={prelude:Za(`#ifdef GL_ES
1963precision mediump float;
1964#else
1965#if !defined(lowp)
1966#define lowp
1967#endif
1968#if !defined(mediump)
1969#define mediump
1970#endif
1971#if !defined(highp)
1972#define highp
1973#endif
1974#endif
1975`,`#ifdef GL_ES
1976precision highp float;
1977#else
1978#if !defined(lowp)
1979#define lowp
1980#endif
1981#if !defined(mediump)
1982#define mediump
1983#endif
1984#if !defined(highp)
1985#define highp
1986#endif
1987#endif
1988vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
1989);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}
1990#ifdef TERRAIN3D
1991uniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;
1992#endif
1993const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {
1994#ifdef TERRAIN3D
1995highp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));
1996#else
1997return 1.0;
1998#endif
1999}float calculate_visibility(vec4 pos) {
2000#ifdef TERRAIN3D
2001vec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;
2002#else
2003return 1.0;
2004#endif
2005}float ele(vec2 pos) {
2006#ifdef TERRAIN3D
2007vec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;
2008#else
2009return 0.0;
2010#endif
2011}float get_elevation(vec2 pos) {
2012#ifdef TERRAIN3D
2013vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;
2014#else
2015return 0.0;
2016#endif
2017}`),background:Za(`uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;
2018#ifdef OVERDRAW_INSPECTOR
2019gl_FragColor=vec4(1.0);
2020#endif
2021}`,"attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:Za(`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;
2021uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;
2022#ifdef OVERDRAW_INSPECTOR
2023gl_FragColor=vec4(1.0);
2024#endif
2025}`,"uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:Za(`varying vec3 v_data;varying float v_visibility;
2026#pragma mapbox: define highp vec4 color
2027#pragma mapbox: define mediump float radius
2028#pragma mapbox: define lowp float blur
2029#pragma mapbox: define lowp float opacity
2030#pragma mapbox: define highp vec4 stroke_color
2031#pragma mapbox: define mediump float stroke_width
2032#pragma mapbox: define lowp float stroke_opacity
2033void main() {
2034#pragma mapbox: initialize highp vec4 color
2035#pragma mapbox: initialize mediump float radius
2036#pragma mapbox: initialize lowp float blur
2037#pragma mapbox: initialize lowp float opacity
2038#pragma mapbox: initialize highp vec4 stroke_color
2039#pragma mapbox: initialize mediump float stroke_width
2040#pragma mapbox: initialize lowp float stroke_opacity
2041vec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);
2042#ifdef OVERDRAW_INSPECTOR
2043gl_FragColor=vec4(1.0);
2044#endif
2045}`,`uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;
2046#pragma mapbox: define highp vec4 color
2047#pragma mapbox: define mediump float radius
2048#pragma mapbox: define lowp float blur
2049#pragma mapbox: define lowp float opacity
2050#pragma mapbox: define highp vec4 stroke_color
2051#pragma mapbox: define mediump float stroke_width
2052#pragma mapbox: define lowp float stroke_opacity
2053void main(void) {
2054#pragma mapbox: initialize highp vec4 color
2055#pragma mapbox: initialize mediump float radius
2056#pragma mapbox: initialize lowp float blur
2057#pragma mapbox: initialize lowp float opacity
2058#pragma mapbox: initialize highp vec4 stroke_color
2059#pragma mapbox: initialize mediump float stroke_width
2060#pragma mapbox: initialize lowp float stroke_opacity
2061vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`),clippingMask:Za("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}
2061"),heatmap:Za(`uniform highp float u_intensity;varying vec2 v_extrude;
2062#pragma mapbox: define highp float weight
2063#define GAUSS_COEF 0.3989422804014327
2064void main() {
2065#pragma mapbox: initialize highp float weight
2066float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);
2067#ifdef OVERDRAW_INSPECTOR
2068gl_FragColor=vec4(1.0);
2069#endif
2070}`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;
2071#pragma mapbox: define highp float weight
2072#pragma mapbox: define mediump float radius
2073const highp float ZERO=1.0/255.0/16.0;
2074#define GAUSS_COEF 0.3989422804014327
2075void main(void) {
2076#pragma mapbox: initialize highp float weight
2077#pragma mapbox: initialize mediump float radius
2078vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,get_elevation(floor(a_pos*0.5)),1);gl_Position=u_matrix*pos;}`),heatmapTexture:Za(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;
2079#ifdef OVERDRAW_INSPECTOR
2080gl_FragColor=vec4(0.0);
2081#endif
2082}`,"uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:Za("varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_anchor_pos;attribute vec2 a_placed;attribute vec2 a_box_real;uniform mat4 u_matrix;uniform vec2 u_pixel_extrude_scale;varying float v_placed;varying float v_notUsed;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Za("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd  =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz  /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:Za("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}"),fill:Za(`#pragma mapbox: define highp vec4 color
2083#pragma mapbox: define lowp float opacity
2084void main() {
2085#pragma mapbox: initialize highp vec4 color
2086#pragma mapbox: initialize lowp float opacity
2087gl_FragColor=color*opacity;
2088#ifdef OVERDRAW_INSPECTOR
2089gl_FragColor=vec4(1.0);
2090#endif
2091}`,`attribute vec2 a_pos;uniform mat4 u_matrix;
2092#pragma mapbox: define highp vec4 color
2093#pragma mapbox: define lowp float opacity
2094void main() {
2095#pragma mapbox: initialize highp vec4 color
2096#pragma mapbox: initialize lowp float opacity
2097gl_Position=u_matrix*vec4(a_pos,0,1);}`),fillOutline:Za(`varying vec2 v_pos;
2098#pragma mapbox: define highp vec4 outline_color
2099#pragma mapbox: define lowp float opacity
2100void main() {
2101#pragma mapbox: initialize highp vec4 outline_color
2102#pragma mapbox: initialize lowp float opacity
2103float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);
2104#ifdef OVERDRAW_INSPECTOR
2105gl_FragColor=vec4(1.0);
2106#endif
2107}`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;
2108#pragma mapbox: define highp vec4 outline_color
2109#pragma mapbox: define lowp float opacity
2110void main() {
2111#pragma mapbox: initialize highp vec4 outline_color
2112#pragma mapbox: initialize lowp float opacity
2113gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillOutlinePattern:Za(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;
2114#pragma mapbox: define lowp float opacity
2115#pragma mapbox: define lowp vec4 pattern_from
2116#pragma mapbox: define lowp vec4 pattern_to
2117void main() {
2118#pragma mapbox: initialize lowp float opacity
2119#pragma mapbox: initialize mediump vec4 pattern_from
2120#pragma mapbox: initialize mediump vec4 pattern_to
2121vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;
2122#ifdef OVERDRAW_INSPECTOR
2123gl_FragColor=vec4(1.0);
2124#endif
2125}`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;
2126#pragma mapbox: define lowp float opacity
2127#pragma mapbox: define lowp vec4 pattern_from
2128#pragma mapbox: define lowp vec4 pattern_to
2129#pragma mapbox: define lowp float pixel_ratio_from
2130#pragma mapbox: define lowp float pixel_ratio_to
2131void main() {
2132#pragma mapbox: initialize lowp float opacity
2133#pragma mapbox: initialize mediump vec4 pattern_from
2134#pragma mapbox: initialize mediump vec4 pattern_to
2135#pragma mapbox: initialize lowp float pixel_ratio_from
2136#pragma mapbox: initialize lowp float pixel_ratio_to
2137vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillPattern:Za(`#ifdef GL_ES
2138precision highp float;
2139#endif
2140uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;
2141#pragma mapbox: define lowp float opacity
2142#pragma mapbox: define lowp vec4 pattern_from
2143#pragma mapbox: define lowp vec4 pattern_to
2144void main() {
2145#pragma mapbox: initialize lowp float opacity
2146#pragma mapbox: initialize mediump vec4 pattern_from
2147#pragma mapbox: initialize mediump vec4 pattern_to
2148vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;
2149#ifdef OVERDRAW_INSPECTOR
2150gl_FragColor=vec4(1.0);
2151#endif
2152}`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;
2153#pragma mapbox: define lowp float opacity
2154#pragma mapbox: define lowp vec4 pattern_from
2155#pragma mapbox: define lowp vec4 pattern_to
2156#pragma mapbox: define lowp float pixel_ratio_from
2157#pragma mapbox: define lowp float pixel_ratio_to
2158void main() {
2159#pragma mapbox: initialize lowp float opacity
2160#pragma mapbox: initialize mediump vec4 pattern_from
2161#pragma mapbox: initialize mediump vec4 pattern_to
2162#pragma mapbox: initialize lowp float pixel_ratio_from
2163#pragma mapbox: initialize lowp float pixel_ratio_to
2164vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}`),fillExtrusion:Za(`varying vec4 v_color;void main() {gl_FragColor=v_color;
2165#ifdef OVERDRAW_INSPECTOR
2166gl_FragColor=vec4(1.0);
2167#endif
2168}`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;
2169#ifdef TERRAIN3D
2170attribute vec2 a_centroid;
2171#endif
2172varying vec4 v_color;
2173#pragma mapbox: define highp float base
2174#pragma mapbox: define highp float height
2175#pragma mapbox: define highp vec4 color
2176void main() {
2177#pragma mapbox: initialize highp float base
2178#pragma mapbox: initialize highp float height
2179#pragma mapbox: initialize highp vec4 color
2180vec3 normal=a_normal_ed.xyz;
2181#ifdef TERRAIN3D
2182float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
2183#else
2184float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
2185#endif
2186base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}`),fillExtrusionPattern:Za(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;
2187#pragma mapbox: define lowp float base
2188#pragma mapbox: define lowp float height
2189#pragma mapbox: define lowp vec4 pattern_from
2190#pragma mapbox: define lowp vec4 pattern_to
2191#pragma mapbox: define lowp float pixel_ratio_from
2192#pragma mapbox: define lowp float pixel_ratio_to
2193void main() {
2194#pragma mapbox: initialize lowp float base
2195#pragma mapbox: initialize lowp float height
2196#pragma mapbox: initialize mediump vec4 pattern_from
2197#pragma mapbox: initialize mediump vec4 pattern_to
2198#pragma mapbox: initialize lowp float pixel_ratio_from
2199#pragma mapbox: initialize lowp float pixel_ratio_to
2200vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;
2201#ifdef OVERDRAW_INSPECTOR
2202gl_FragColor=vec4(1.0);
2203#endif
2204}`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;
2205#ifdef TERRAIN3D
2206attribute vec2 a_centroid;
2207#endif
2208varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;
2209#pragma mapbox: define lowp float base
2210#pragma mapbox: define lowp float height
2211#pragma mapbox: define lowp vec4 pattern_from
2212#pragma mapbox: define lowp vec4 pattern_to
2213#pragma mapbox: define lowp float pixel_ratio_from
2214#pragma mapbox: define lowp float pixel_ratio_to
2215void main() {
2216#pragma mapbox: initialize lowp float base
2217#pragma mapbox: initialize lowp float height
2218#pragma mapbox: initialize mediump vec4 pattern_from
2219#pragma mapbox: initialize mediump vec4 pattern_to
2220#pragma mapbox: initialize lowp float pixel_ratio_from
2221#pragma mapbox: initialize lowp float pixel_ratio_to
2222vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;
2223#ifdef TERRAIN3D
2224float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
2225#else
2226float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
2227#endif
2228base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0
2229? a_pos
2230: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_
2230gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}`),hillshadePrepare:Za(`#ifdef GL_ES
2231precision highp float;
2232#endif
2233uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);
2234#ifdef OVERDRAW_INSPECTOR
2235gl_FragColor=vec4(1.0);
2236#endif
2237}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Za(`uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;
2238#define PI 3.141592653589793
2239void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;
2240#ifdef OVERDRAW_INSPECTOR
2241gl_FragColor=vec4(1.0);
2242#endif
2243}`,"uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}"),line:Za(`uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;
2244#pragma mapbox: define highp vec4 color
2245#pragma mapbox: define lowp float blur
2246#pragma mapbox: define lowp float opacity
2247void main() {
2248#pragma mapbox: initialize highp vec4 color
2249#pragma mapbox: initialize lowp float blur
2250#pragma mapbox: initialize lowp float opacity
2251float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);
2252#ifdef OVERDRAW_INSPECTOR
2253gl_FragColor=vec4(1.0);
2254#endif
2255}`,`
2256#define scale 0.015873016
2257attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;
2258#pragma mapbox: define highp vec4 color
2259#pragma mapbox: define lowp float blur
2260#pragma mapbox: define lowp float opacity
2261#pragma mapbox: define mediump float gapwidth
2262#pragma mapbox: define lowp float offset
2263#pragma mapbox: define mediump float width
2264void main() {
2265#pragma mapbox: initialize highp vec4 color
2266#pragma mapbox: initialize lowp float blur
2267#pragma mapbox: initialize lowp float opacity
2268#pragma mapbox: initialize mediump float gapwidth
2269#pragma mapbox: initialize lowp float offset
2270#pragma mapbox: initialize mediump float width
2271float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;
2272#ifdef TERRAIN3D
2273v_gamma_scale=1.0;
2274#else
2275float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
2276#endif
2277v_width2=vec2(outset,inset);}`),lineGradient:Za(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;
2278#pragma mapbox: define lowp float blur
2279#pragma mapbox: define lowp float opacity
2280void main() {
2281#pragma mapbox: initialize lowp float blur
2282#pragma mapbox: initialize lowp float opacity
2283float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);
2284#ifdef OVERDRAW_INSPECTOR
2285gl_FragColor=vec4(1.0);
2286#endif
2287}`,`
2288#define scale 0.015873016
2289attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;
2290#pragma mapbox: define lowp float blur
2291#pragma mapbox: define lowp float opacity
2292#pragma mapbox: define mediump float gapwidth
2293#pragma mapbox: define lowp float offset
2294#pragma mapbox: define mediump float width
2295void main() {
2296#pragma mapbox: initialize lowp float blur
2297#pragma mapbox: initialize lowp float opacity
2298#pragma mapbox: initialize mediump float gapwidth
2299#pragma mapbox: initialize lowp float offset
2300#pragma mapbox: initialize mediump float width
2301float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;
2302#ifdef TERRAIN3D
2303v_gamma_scale=1.0;
2304#else
2305float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
2306#endif
2307v_width2=vec2(outset,inset);}`),linePattern:Za(`#ifdef GL_ES
2308precision highp float;
2309#endif
2310uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
2311#pragma mapbox: define lowp vec4 pattern_from
2312#pragma mapbox: define lowp vec4 pattern_to
2313#pragma mapbox: define lowp float pixel_ratio_from
2314#pragma mapbox: define lowp float pixel_ratio_to
2315#pragma mapbox: define lowp float blur
2316#pragma mapbox: define lowp float opacity
2317void main() {
2318#pragma mapbox: initialize mediump vec4 pattern_from
2319#pragma mapbox: initialize mediump vec4 pattern_to
2320#pragma mapbox: initialize lowp float pixel_ratio_from
2321#pragma mapbox: initialize lowp float pixel_ratio_to
2322#pragma mapbox: initialize lowp float blur
2323#pragma mapbox: initialize lowp float opacity
2324vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;
2325#ifdef OVERDRAW_INSPECTOR
2326gl_FragColor=vec4(1.0);
2327#endif
2328}`,`
2329#define scale 0.015873016
2330#define LINE_DISTANCE_SCALE 2.0
2331attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
2332#pragma mapbox: define lowp float blur
2333#pragma mapbox: define lowp float opacity
2334#pragma mapbox: define lowp float offset
2335#pragma mapbox: define mediump float gapwidth
2336#pragma mapbox: define mediump float width
2337#pragma mapbox: define lowp float floorwidth
2338#pragma mapbox: define lowp vec4 pattern_from
2339#pragma mapbox: define lowp vec4 pattern_to
2340#pragma mapbox: define lowp float pixel_ratio_from
2341#pragma mapbox: define lowp float pixel_ratio_to
2342void main() {
2343#pragma mapbox: initialize lowp float blur
2344#pragma mapbox: initialize lowp float opacity
2345#pragma mapbox: initialize lowp float offset
2346#pragma mapbox: initialize mediump float gapwidth
2347#pragma mapbox: initialize mediump float width
2348#pragma mapbox: initialize lowp float floorwidth
2349#pragma mapbox: initialize mediump vec4 pattern_from
2350#pragma mapbox: initialize mediump vec4 pattern_to
2351#pragma mapbox: initialize lowp float pixel_ratio_from
2352#pragma mapbox: initialize lowp float pixel_ratio_to
2353float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;
2354#ifdef TERRAIN3D
2355v_gamma_scale=1.0;
2356#else
2357float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
2358#endif
2359v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:Za(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;
2359uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;
2360#pragma mapbox: define highp vec4 color
2361#pragma mapbox: define lowp float blur
2362#pragma mapbox: define lowp float opacity
2363#pragma mapbox: define mediump float width
2364#pragma mapbox: define lowp float floorwidth
2365void main() {
2366#pragma mapbox: initialize highp vec4 color
2367#pragma mapbox: initialize lowp float blur
2368#pragma mapbox: initialize lowp float opacity
2369#pragma mapbox: initialize mediump float width
2370#pragma mapbox: initialize lowp float floorwidth
2371float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);
2372#ifdef OVERDRAW_INSPECTOR
2373gl_FragColor=vec4(1.0);
2374#endif
2375}`,`
2376#define scale 0.015873016
2377#define LINE_DISTANCE_SCALE 2.0
2378attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;
2379#pragma mapbox: define highp vec4 color
2380#pragma mapbox: define lowp float blur
2381#pragma mapbox: define lowp float opacity
2382#pragma mapbox: define mediump float gapwidth
2383#pragma mapbox: define lowp float offset
2384#pragma mapbox: define mediump float width
2385#pragma mapbox: define lowp float floorwidth
2386void main() {
2387#pragma mapbox: initialize highp vec4 color
2388#pragma mapbox: initialize lowp float blur
2389#pragma mapbox: initialize lowp float opacity
2390#pragma mapbox: initialize mediump float gapwidth
2391#pragma mapbox: initialize lowp float offset
2392#pragma mapbox: initialize mediump float width
2393#pragma mapbox: initialize lowp float floorwidth
2394float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;
2395#ifdef TERRAIN3D
2396v_gamma_scale=1.0;
2397#else
2398float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
2399#endif
2400v_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}`),raster:Za(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);
2401#ifdef OVERDRAW_INSPECTOR
2402gl_FragColor=vec4(1.0);
2403#endif
2404}`,"uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:Za(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;
2405#pragma mapbox: define lowp float opacity
2406void main() {
2407#pragma mapbox: initialize lowp float opacity
2408lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;
2409#ifdef OVERDRAW_INSPECTOR
2410gl_FragColor=vec4(1.0);
2411#endif
2412}`,`attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_tex;varying float v_fade_opacity;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}
2413#pragma mapbox: define lowp float opacity
2414void main() {
2415#pragma mapbox: initialize lowp float opacity
2416vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
2417camera_to_anchor_distance/u_camera_to_center_distance :
2418u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}`),symbolSDF:Za(`#define SDF_PX 8.0
2419uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;
2420#pragma mapbox: define highp vec4 fill_color
2421#pragma mapbox: define highp vec4 halo_color
2422#pragma mapbox: define lowp float opacity
2423#pragma mapbox: define lowp float halo_width
2424#pragma mapbox: define lowp float halo_blur
2425void main() {
2426#pragma mapbox: initialize highp vec4 fill_color
2427#pragma mapbox: initialize highp vec4 halo_color
2428#pragma mapbox: initialize lowp float opacity
2429#pragma mapbox: initialize lowp float halo_width
2430#pragma mapbox: initialize lowp float halo_blur
2431float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);
2432#ifdef OVERDRAW_INSPECTOR
2433gl_FragColor=vec4(1.0);
2434#endif
2435}`,`attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_data0;varying vec3 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}
2436#pragma mapbox: define highp vec4 fill_color
2437#pragma mapbox: define highp vec4 halo_color
2438#pragma mapbox: define lowp float opacity
2439#pragma mapbox: define lowp float halo_width
2440#pragma mapbox: define lowp float halo_blur
2441void main() {
2442#pragma mapbox: initialize highp vec4 fill_color
2443#pragma mapbox: initialize highp vec4 halo_color
2444#pragma mapbox: initialize lowp float opacity
2445#pragma mapbox: initialize lowp float halo_width
2446#pragma mapbox: initialize lowp float halo_blur
2447vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
2448camera_to_anchor_distance/u_camera_to_center_distance :
2449u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}`),symbolTextAndIcon:Za(`#define SDF_PX 8.0
2450#define SDF 1.0
2451#define ICON 0.0
2452uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;
2453#pragma mapbox: define highp vec4 fill_color
2454#pragma mapbox: define highp vec4 halo_color
2455#pragma mapbox: define lowp float opacity
2456#pragma mapbox: define lowp float halo_width
2457#pragma mapbox: define lowp float halo_blur
2458void main() {
2459#pragma mapbox: initialize highp vec4 fill_color
2460#pragma mapbox: initialize highp vec4 halo_color
2461#pragma mapbox: initialize lowp float opacity
2462#pragma mapbox: initialize lowp float halo_width
2463#pragma mapbox: initialize lowp float halo_blur
2464float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;
2464gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;
2465#ifdef OVERDRAW_INSPECTOR
2466gl_FragColor=vec4(1.0);
2467#endif
2468return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);
2469#ifdef OVERDRAW_INSPECTOR
2470gl_FragColor=vec4(1.0);
2471#endif
2472}`,`attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec4 v_data0;varying vec4 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}
2473#pragma mapbox: define highp vec4 fill_color
2474#pragma mapbox: define highp vec4 halo_color
2475#pragma mapbox: define lowp float opacity
2476#pragma mapbox: define lowp float halo_width
2477#pragma mapbox: define lowp float halo_blur
2478void main() {
2479#pragma mapbox: initialize highp vec4 fill_color
2480#pragma mapbox: initialize highp vec4 halo_color
2481#pragma mapbox: initialize lowp float opacity
2482#pragma mapbox: initialize lowp float halo_width
2483#pragma mapbox: initialize lowp float halo_blur
2484vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
2485camera_to_anchor_distance/u_camera_to_center_distance :
2486u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}`),terrain:Za("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;varying vec2 v_texture_pos;varying float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture2D(u_texture,v_texture_pos);if (v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);
2486float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);gl_FragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {gl_FragColor=surface_color;}}","attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform mat4 u_fog_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:Za("varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}","attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:Za("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);}"),sky:Za("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform float u_horizon;uniform float u_sky_horizon_blend;void main() {float y=gl_FragCoord.y;if (y > u_horizon) {float blend=y-u_horizon;if (blend < u_sky_horizon_blend) {gl_FragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {gl_FragColor=u_sky_color;}}}","attribute vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function Za(R,r){const g=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,S=r.match(/attribute ([\w]+) ([\w]+)/g),E=R.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),A=r.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),ee=A?A.concat(E):E,se={};return{fragmentSource:R=R.replace(g,(he,_e,Ie,Me,Je)=>(se[Je]=!0,_e==="define"?`
2487#ifndef HAS_UNIFORM_u_${Je}
2488varying ${Ie} ${Me} ${Je};
2489#else
2490uniform ${Ie} ${Me} u_${Je};
2491#endif
2492`:`
2493#ifdef HAS_UNIFORM_u_${Je}
2494    ${Ie} ${Me} ${Je} = u_${Je};
2495#endif
2496`)),vertexSource:r=r.replace(g,(he,_e,Ie,Me,Je)=>{const ut=Me==="float"?"vec2":"vec4",gt=Je.match(/color/)?"color":ut;return se[Je]?_e==="define"?`
2497#ifndef HAS_UNIFORM_u_${Je}
2498uniform lowp float u_${Je}_t;
2499attribute ${Ie} ${ut} a_${Je};
2500varying ${Ie} ${Me} ${Je};
2501#else
2502uniform ${Ie} ${Me} u_${Je};
2503#endif
2504`:gt==="vec4"?`
2505#ifndef HAS_UNIFORM_u_${Je}
2506    ${Je} = a_${Je};
2507#else
2508    ${Ie} ${Me} ${Je} = u_${Je};
2509#endif
2510`:`
2511#ifndef HAS_UNIFORM_u_${Je}
2512    ${Je} = unpack_mix_${gt}(a_${Je}, u_${Je}_t);
2513#else
2514    ${Ie} ${Me} ${Je} = u_${Je};
2515#endif
2516`:_e==="define"?`
2517#ifndef HAS_UNIFORM_u_${Je}
2518uniform lowp float u_${Je}_t;
2519attribute ${Ie} ${ut} a_${Je};
2520#else
2521uniform ${Ie} ${Me} u_${Je};
2522#endif
2523`:gt==="vec4"?`
2524#ifndef HAS_UNIFORM_u_${Je}
2525    ${Ie} ${Me} ${Je} = a_${Je};
2526#else
2527    ${Ie} ${Me} ${Je} = u_${Je};
2528#endif
2529`:`
2530#ifndef HAS_UNIFORM_u_${Je}
2531    ${Ie} ${Me} ${Je} = unpack_mix_${gt}(a_${Je}, u_${Je}_t);
2532#else
2533    ${Ie} ${Me} ${Je} = u_${Je};
2534#endif
2535`}),staticAttributes:S,staticUniforms:ee}}class Gr{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(r,g,S,E,A,ee,se,he,_e){this.context=r;let Ie=this.boundPaintVertexBuffers.length!==E.length;for(let Me=0;!Ie&&Me<E.length;Me++)this.boundPaintVertexBuffers[Me]!==E[Me]&&(Ie=!0);!this.vao||this.boundProgram!==g||this.boundLayoutVertexBuffer!==S||Ie||this.boundIndexBuffer!==A||this.boundVertexOffset!==ee||this.boundDynamicVertexBuffer!==se||this.boundDynamicVertexBuffer2!==he||this.boundDynamicVertexBuffer3!==_e?this.freshBind(g,S,E,A,ee,se,he,_e):(r.bindVertexArray.set(this.vao),se&&se.bind(),A&&A.dynamicDraw&&A.bind(),he&&he.bind(),_e&&_e.bind())}freshBind(r,g,S,E,A,ee,se,he){const _e=r.numAttributes,Ie=this.context,Me=Ie.gl;this.vao&&this.destroy(),this.vao=Ie.createVertexArray(),Ie.bindVertexArray.set(this.vao),this.boundProgram=r,this.boundLayoutVertexBuffer=g,this.boundPaintVertexBuffers=S,this.boundIndexBuffer=E,this.boundVertexOffset=A,this.boundDynamicVertexBuffer=ee,this.boundDynamicVertexBuffer2=se,this.boundDynamicVertexBuffer3=he,g.enableAttributes(Me,r);for(const Je of S)Je.enableAttributes(Me,r);ee&&ee.enableAttributes(Me,r),se&&se.enableAttributes(Me,r),he&&he.enableAttributes(Me,r),g.bind(),g.setVertexAttribPointers(Me,r,A);for(const Je of S)Je.bind(),Je.setVertexAttribPointers(Me,r,A);ee&&(ee.bind(),ee.setVertexAttribPointers(Me,r,A)),E&&E.bind(),se&&(se.bind(),se.setVertexAttribPointers(Me,r,A)),he&&(he.bind(),he.setVertexAttribPointers(Me,r,A)),Ie.currentNumAttributes=_e}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const Xr=(R,r,g,S,E)=>({u_matrix:R,u_texture:0,u_ele_delta:r,u_fog_matrix:g,u_fog_color:S?S.properties.get("fog-color"):i.aM.white,u_fog_ground_blend:S?S.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:S?S.calculateFogBlendOpacity(E):0,u_horizon_color:S?S.properties.get("horizon-color"):i.aM.white,u_horizon_fog_blend:S?S.properties.get("horizon-fog-blend"):1});function rn(R){const r=[];for(let g=0;g<R.length;g++){if(R[g]===null)continue;const S=R[g].split(" ");r.push(S.pop())}return r}class In{constructor(r,g,S,E,A,ee){const se=r.gl;this.program=se.createProgram();const he=rn(g.staticAttributes),_e=S?S.getBinderAttributes():[],Ie=he.concat(_e),Me=Ko.prelude.staticUniforms?rn(Ko.prelude.staticUniforms):[],Je=g.staticUniforms?rn(g.staticUniforms):[],ut=S?S.getBinderUniforms():[],gt=Me.concat(Je).concat(ut),St=[];for(const cs of gt)St.indexOf(cs)<0&&St.push(cs);const Lt=S?S.defines():[];A&&Lt.push("#define OVERDRAW_INSPECTOR;"),ee&&Lt.push("#define TERRAIN3D;");const Vt=Lt.concat(Ko.prelude.fragmentSource,g.fragmentSource).join(`
2536`),Ht=Lt.concat(Ko.prelude.vertexSource,g.vertexSource).join(`
2537`),Et=se.createShader(se.FRAGMENT_SHADER);if(se.isContextLost())return void(this.failedToCreate=!0);if(se.shaderSource(Et,Vt),se.compileShader(Et),!se.getShaderParameter(Et,se.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${se.getShaderInfoLog(Et)}`);se.attachShader(this.program,Et);const Kt=se.createShader(se.VERTEX_SHADER);if(se.isContextLost())return void(this.failedToCreate=!0);if(se.shaderSource(Kt,Ht),se.compileShader(Kt),!se.getShaderParameter(Kt,se.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${se.getShaderInfoLog(Kt)}`);se.attachShader(this.program,Kt),this.attributes={};const ss={};this.numAttributes=Ie.length;for(let cs=0;cs<this.numAttributes;cs++)Ie[cs]&&(se.bindAttribLocation(this.program,cs,Ie[cs]),this.attributes[Ie[cs]]=cs);if(se.linkProgram(this.program),!se.getProgramParameter(this.program,se.LINK_STATUS))throw new Error(`Program failed to link: ${se.getProgramInfoLog(this.program)}`);se.deleteShader(Kt),se.deleteShader(Et);for(let cs=0;cs<St.length;cs++){const As=St[cs];if(As&&!ss[As]){const sn=se.getUniformLocation(this.program,As);sn&&(ss[As]=sn)}}this.fixedUniforms=E(r,ss),this.terrainUniforms=((cs,As)=>({u_depth:new i.aH(cs,As.u_depth),u_terrain:new i.aH(cs,As.u_terrain),u_terrain_dim:new i.aI(cs,As.u_terrain_dim),u_terrain_matrix:new i.aJ(cs,As.u_terrain_matrix),u_terrain_unpack:new i.aK(cs,As.u_terrain_unpack),u_terrain_exaggeration:new i.aI(cs,As.u_terrain_exaggeration)}))(r,ss),this.binderUniforms=S?S.getUniforms(r,ss):[]}draw(r,g,S,E,A,ee,se,he,_e,Ie,Me,Je,ut,gt,St,Lt,Vt,Ht){const Et=r.gl;if(this.failedToCreate)return;if(r.program.set(this.program),r.setDepthMode(S),r.setStencilMode(E),r.setColorMode(A),r.setCullFace(ee),he){r.activeTexture.set(Et.TEXTURE2),Et.bindTexture(Et.TEXTURE_2D,he.depthTexture),r.activeTexture.set(Et.TEXTURE3),Et.bindTexture(Et.TEXTURE_2D,he.texture);for(const ss in this.terrainUniforms)this.terrainUniforms[ss].set(he[ss])}for(const ss in this.fixedUniforms)this.fixedUniforms[ss].set(se[ss]);St&&St.setUniforms(r,this.binderUniforms,ut,{zoom:gt});let Kt=0;switch(g){case Et.LINES:Kt=2;break;case Et.TRIANGLES:Kt=3;break;case Et.LINE_STRIP:Kt=1}for(const ss of Je.get()){const cs=ss.vaos||(ss.vaos={});(cs[_e]||(cs[_e]=new Gr)).bind(r,this,Ie,St?St.getPaintVertexBuffers():[],Me,ss.vertexOffset,Lt,Vt,Ht),Et.drawElements(g,ss.primitiveLength*Kt,Et.UNSIGNED_SHORT,ss.primitiveOffset*Kt*2)}}}function Yi(R,r,g){const S=1/os(g,1,r.transform.tileZoom),E=Math.pow(2,g.tileID.overscaledZ
vendor: 4,395 bytes, line 2537
2537),A=g.tileSize*Math.pow(2,r.transform.tileZoom)/E,ee=A*(g.tileID.canonical.x+g.tileID.wrap*E),se=A*g.tileID.canonical.y;return{u_image:0,u_texsize:g.imageAtlasTexture.size,u_scale:[S,R.fromScale,R.toScale],u_fade:R.t,u_pixel_coord_upper:[ee>>16,se>>16],u_pixel_coord_lower:[65535&ee,65535&se]}}const jl=(R,r,g,S)=>{const E=r.style.light,A=E.properties.get("position"),ee=[A.x,A.y,A.z],se=function(){var _e=new i.A(9);return i.A!=Float32Array&&(_e[1]=0,_e[2]=0,_e[3]=0,_e[5]=0,_e[6]=0,_e[7]=0),_e[0]=1,_e[4]=1,_e[8]=1,_e}();E.properties.get("anchor")==="viewport"&&function(_e,Ie){var Me=Math.sin(Ie),Je=Math.cos(Ie);_e[0]=Je,_e[1]=Me,_e[2]=0,_e[3]=-Me,_e[4]=Je,_e[5]=0,_e[6]=0,_e[7]=0,_e[8]=1}(se,-r.transform.angle),function(_e,Ie,Me){var Je=Ie[0],ut=Ie[1],gt=Ie[2];_e[0]=Je*Me[0]+ut*Me[3]+gt*Me[6],_e[1]=Je*Me[1]+ut*Me[4]+gt*Me[7],_e[2]=Je*Me[2]+ut*Me[5]+gt*Me[8]}(ee,ee,se);const he=E.properties.get("color");return{u_matrix:R,u_lightpos:ee,u_lightintensity:E.properties.get("intensity"),u_lightcolor:[he.r,he.g,he.b],u_vertical_gradient:+g,u_opacity:S}},Si=(R,r,g,S,E,A,ee)=>i.e(jl(R,r,g,S),Yi(A,r,ee),{u_height_factor:-Math.pow(2,E.overscaledZ)/ee.tileSize/8}),zo=R=>({u_matrix:R}),Pc=(R,r,g,S)=>i.e(zo(R),Yi(g,r,S)),Hr=(R,r)=>({u_matrix:R,u_world:r}),ul=(R,r,g,S,E)=>i.e(Pc(R,r,g,S),{u_world:E}),hl=(R,r,g,S)=>{const E=R.transform;let A,ee;if(S.paint.get("circle-pitch-alignment")==="map"){const se=os(g,1,E.zoom);A=!0,ee=[se,se]}else A=!1,ee=E.pixelsToGLUnits;return{u_camera_to_center_distance:E.cameraToCenterDistance,u_scale_with_map:+(S.paint.get("circle-pitch-scale")==="map"),u_matrix:R.translatePosMatrix(r.posMatrix,g,S.paint.get("circle-translate"),S.paint.get("circle-translate-anchor")),u_pitch_with_map:+A,u_device_pixel_ratio:R.pixelRatio,u_extrude_scale:ee}},Nr=(R,r,g)=>({u_matrix:R,u_inv_matrix:r,u_camera_to_center_distance:g.cameraToCenterDistance,u_viewport_size:[g.width,g.height]}),ui=(R,r,g=1)=>({u_matrix:R,u_color:r,u_overlay:0,u_overlay_scale:g}),Zr=R=>({u_matrix:R}),Gi=(R,r,g,S)=>({u_matrix:R,u_extrude_scale:os(r,1,g),u_intensity:S}),fn=(R,r,g,S)=>{const E=i.H();i.aP(E,0,R.width,R.height,0,0,1);const A=R.context.gl;return{u_matrix:E,u_world:[A.drawingBufferWidth,A.drawingBufferHeight],u_image:g,u_color_ramp:S,u_opacity:r.paint.get("heatmap-opacity")}};function kr(R,r){const g=Math.pow(2,r.canonical.z),S=r.canonical.y;return[new i.Z(0,S/g).toLngLat().lat,new i.Z(0,(S+1)/g).toLngLat().lat]}const nr=(R,r,g,S)=>{const E=R.transform;return{u_matrix:Xi(R,r,g,S),u_ratio:1/os(r,1,E.zoom),u_device_pixel_ratio:R.pixelRatio,u_units_to_pixels:[1/E.pixelsToGLUnits[0],1/E.pixelsToGLUnits[1]]}},Br=(R,r,g,S,E)=>i.e(nr(R,r,g,E),{u_image:0,u_image_height:S}),wl=(R,r,g,S,E)=>{const A=R.transform,ee=lr(r,A);return{u_matrix:Xi(R,r,g,E),u_texsize:r.imageAtlasTexture.size,u_ratio:1/os(r,1,A.zoom),u_device_pixel_ratio:R.pixelRatio,u_image:0,u_scale:[ee,S.fromScale,S.toScale],u_fade:S.t,u_units_to_pixels:[1/A.pixelsToGLUnits[0],1/A.pixelsToGLUnits[1]]}},Nl=(R,r,g,S,E,A)=>{const ee=R.lineAtlas,se=lr(r,R.transform),he=g.layout.get("line-cap")==="round",_e=ee.getDash(S.from,he),Ie=ee.getDash(S.to,he),Me=_e.width*E.fromScale,Je=Ie.width*E.toScale;return i.e(nr(R,r,g,A),{u_patternscale_a:[se/Me,-_e.height/2],u_patternscale_b:[se/Je,-Ie.height/2],u_sdfgamma:ee.width/(256*Math.min(Me,Je)*R.pixelRatio)/2,u_image:0,u_tex_y_a:_e.y,u_tex_y_b:Ie.y,u_mix:E.t})};function lr(R,r){return 1/os(R,1,r.tileZoom)}function Xi(R,r,g,S){return R.translatePosMatrix(S?S.posMatrix:r.tileID.posMatrix,r,g.paint.get("line-translate"),g.paint.get("line-translate-anchor"))}const ml=(R,r,g,S,E)=>{return{u_matrix:R,u_tl_parent:r,u_scale_parent:g,u_buffer_scale:1,u_fade_t:S.mix,u_opacity:S.opacity*E.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:E.paint.get("raster-brightness-min"),u_brightness_high:E.paint.get("raster-brightness-max"),u_saturation_factor:(ee=E.paint.get("raster-saturation"),ee>0?1-1/(1.001-ee):-ee),u_contrast_factor:(A=E.paint.get("raster-contrast"),A>0?1/(1-A):1+A),u_spin_weights:Co(E.paint.get("raster-hue-rotate"))};var A,ee};function Co(R){R*=Math.PI/180;const r=Math.sin(R),g=Math.cos(R);return[(2*g+1)/3,(-Math.sqrt(3)*r-g+1)/3,(Math.sqrt(3)*r-g+1)/3]}const ti=(R,r,g,S,E,A,ee,se,he,_e,Ie,Me,Je,ut)=>{const gt=ee.transform;return{u_is_size_zoom_constant:+(R==="constant"||R==="source"),u_is_size_feature_constant:+(R==="constant"||R==="c
2537amera"),u_size_t:r?r.uSizeT:0,u_size:r?r.uSize:0,u_camera_to_center_distance:gt.cameraToCenterDistance,u_pitch:gt.pitch/360*2*Math.PI,u_rotate_symbol:+g,u_aspect_ratio:gt.width/gt.height,u_fade_change:ee.options.fadeDuration?ee.symbolFadeChange:1,u_matrix:se,u_label_plane_matrix:he,u_coord_matrix:_e,u_is_text:+Me,u_pitch_with_map:+S,u_is_along_line:E,u_is_variable_anchor:A,u_texsize:Je,u_texture:0,u_translation:Ie,u_pitched_scale:ut}},qs=(R,r,g,S,E,A,ee,se,he,_e,Ie,Me,Je,ut,gt)=>{const St=ee.transform;return i.e(ti(R,r,g,S,E,A,ee,se,he,_e,Ie,Me,Je,gt),{u_gamma_scale:S?Math.cos(St._pitch)*St.cameraToCenterDistance:1,u_device_pixel_ratio:ee.pixelRatio,u_is_halo:+ut})},Tn=(R,r,g,S,E,A,ee,se,he,_e,Ie,Me,Je,ut)=>i.e(qs(R,r,g,S,E,A,ee,se,he,_e,Ie,!0,Me,!0,ut),{u_texsize_icon:Je,u_texture_icon:1}),oa=(R,r,g)=>({u_matrix:R,u_opacity:r,u_color:g}),Pa=(R,r,g,S,E,A)=>i.e(function(ee,se,he,_e){const Ie=he.imageManager.getPattern(ee.from.toString()),Me=he.imageManager.getPattern(ee.to.toString()),{width:Je,height:ut}=he.imageManager.getPixelSize(),gt=Math.pow(2,_e.tileID.overscaledZ),St=_e.tileSize*Math.pow(2,he.transform.tileZoom)/gt,Lt=St*(_e.tileID.canonical.x+_e.tileID.wrap*gt),Vt=St*_e.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:Ie.tl,u_pattern_br_a:Ie.br,u_pattern_tl_b:Me.tl,u_pattern_br_b:Me.br,u_texsize:[Je,ut],u_mix:se.t,u_pattern_size_a:Ie.displaySize,u_pattern_size_b:Me.dis
vendor: 4,193 bytes, line 2537
2537playSize,u_scale_a:se.fromScale,u_scale_b:se.toScale,u_tile_units_to_pixels:1/os(_e,1,he.transform.tileZoom),u_pixel_coord_upper:[Lt>>16,Vt>>16],u_pixel_coord_lower:[65535&Lt,65535&Vt]}}(S,A,g,E),{u_matrix:R,u_opacity:r}),mr={fillExtrusion:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_lightpos:new i.aN(R,r.u_lightpos),u_lightintensity:new i.aI(R,r.u_lightintensity),u_lightcolor:new i.aN(R,r.u_lightcolor),u_vertical_gradient:new i.aI(R,r.u_vertical_gradient),u_opacity:new i.aI(R,r.u_opacity)}),fillExtrusionPattern:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_lightpos:new i.aN(R,r.u_lightpos),u_lightintensity:new i.aI(R,r.u_lightintensity),u_lightcolor:new i.aN(R,r.u_lightcolor),u_vertical_gradient:new i.aI(R,r.u_vertical_gradient),u_height_factor:new i.aI(R,r.u_height_factor),u_image:new i.aH(R,r.u_image),u_texsize:new i.aO(R,r.u_texsize),u_pixel_coord_upper:new i.aO(R,r.u_pixel_coord_upper),u_pixel_coord_lower:new i.aO(R,r.u_pixel_coord_lower),u_scale:new i.aN(R,r.u_scale),u_fade:new i.aI(R,r.u_fade),u_opacity:new i.aI(R,r.u_opacity)}),fill:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix)}),fillPattern:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_image:new i.aH(R,r.u_image),u_texsize:new i.aO(R,r.u_texsize),u_pixel_coord_upper:new i.aO(R,r.u_pixel_coord_upper),u_pixel_coord_lower:new i.aO(R,r.u_pixel_coord_lower),u_scale:new i.aN(R,r.u_scale),u_fade:new i.aI(R,r.u_fade)}),fillOutline:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_world:new i.aO(R,r.u_world)}),fillOutlinePattern:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_world:new i.aO(R,r.u_world),u_image:new i.aH(R,r.u_image),u_texsize:new i.aO(R,r.u_texsize),u_pixel_coord_upper:new i.aO(R,r.u_pixel_coord_upper),u_pixel_coord_lower:new i.aO(R,r.u_pixel_coord_lower),u_scale:new i.aN(R,r.u_scale),u_fade:new i.aI(R,r.u_fade)}),circle:(R,r)=>({u_camera_to_center_distance:new i.aI(R,r.u_camera_to_center_distance),u_scale_with_map:new i.aH(R,r.u_scale_with_map),u_pitch_with_map:new i.aH(R,r.u_pitch_with_map),u_extrude_scale:new i.aO(R,r.u_extrude_scale),u_device_pixel_ratio:new i.aI(R,r.u_device_pixel_ratio),u_matrix:new i.aJ(R,r.u_matrix)}),collisionBox:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_pixel_extrude_scale:new i.aO(R,r.u_pixel_extrude_scale)}),collisionCircle:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_inv_matrix:new i.aJ(R,r.u_inv_matrix),u_camera_to_center_distance:new i.aI(R,r.u_camera_to_center_distance),u_viewport_size:new i.aO(R,r.u_viewport_size)}),debug:(R,r)=>({u_color:new i.aL(R,r.u_color),u_matrix:new i.aJ(R,r.u_matrix),u_overlay:new i.aH(R,r.u_overlay),u_overlay_scale:new i.aI(R,r.u_overlay_scale)}),clippingMask:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix)}),heatmap:(R,r)=>({u_extrude_scale:new i.aI(R,r.u_extrude_scale),u_intensity:new i.aI(R,r.u_intensity),u_matrix:new i.aJ(R,r.u_matrix)}),heatmapTexture:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_world:new i.aO(R,r.u_world),u_image:new i.aH(R,r.u_image),u_color_ramp:new i.aH(R,r.u_color_ramp),u_opacity:new i.aI(R,r.u_opacity)}),hillshade:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_image:new i.aH(R,r.u_image),u_latrange:new i.aO(R,r.u_latrange),u_light:new i.aO(R,r.u_light),u_shadow:new i.aL(R,r.u_shadow),u_highlight:new i.aL(R,r.u_highlight),u_accent:new i.aL(R,r.u_accent)}),hillshadePrepare:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_image:new i.aH(R,r.u_image),u_dimension:new i.aO(R,r.u_dimension),u_zoom:new i.aI(R,r.u_zoom),u_unpack:new i.aK(R,r.u_unpack)}),line:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_ratio:new i.aI(R,r.u_ratio),u_device_pixel_ratio:new i.aI(R,r.u_device_pixel_ratio),u_units_to_pixels:new i.aO(R,r.u_units_to_pixels)}),lineGradient:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_ratio:new i.aI(R,r.u_ratio),u_device_pixel_ratio:new i.aI(R,r.u_device_pixel_ratio),u_units_to_pixels:new i.aO(R,r.u_units_to_pixels),u_image:new i.aH(R,r.u_image),u_image_height:new i.aI(R,r.u_image_height)}),linePattern:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_texsize:new i.aO(R,r.u_texsize),u_ratio:new i.aI(R,r.u_ratio),u_device_pixel_ratio:new i.aI(R,r.u_device_pixel_ratio),u_image:new i.aH(R,r.u_image),u_units_to_pixels:new i.aO(R,r.u_units_to_pixels),u_scale:new i.aN(R,r.u_scale),u_fade:new i.aI(R,r.u_fade)}),lineSDF:(R,r)=>
2537({u_matrix:new i.aJ(R,r.u_matrix),u_ratio:new i.aI(R,r.u_ratio),u_device_pixel_ratio:new i.aI(R,r.u_device_pixel_ratio),u_units_to_pixels:new i.aO(R,r.u_units_to_pixels),u_patternscale_a:new i.aO(R,r.u_patternscale_a),u_patternscale_b:new i.aO(R,r.u_patternscale_b),u_sdfgamma:new i.aI(R,r.u_sdfgamma),u_image:new i.aH(R,r.u_image),u_tex_y_a:new i.aI(R,r.u_tex_y_a),u_tex_y_b:new i.aI(R,r.u_tex_y_b),u_mix:new i.aI(R,r.u_mix)}),raster:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_tl_parent:new i.aO(R,r.u_tl_parent),u_scale_parent:new i.aI(R,r.u_scale_parent),u_buffer_scale:new i.aI(R,r.u_buffer_scale),u_fade_t:new i.aI(R,r.u_fade_t),u_opacity:new i.aI(R,r.u_opacity),u_image0:new i.aH(R,r.u_image0),u_image1:new i.aH(R,r.u_image1),u_brightness_low:new i.aI(R,r.u_brightness_low),u_brightness_high:new i.aI(R,r.u_brightness_high),u_saturation_factor:new i.aI(R,r.u_saturation_factor),u_contrast_factor:new i.aI(R,r.u_contrast_factor),u_spin_weights:new i.aN(R,r.u_spin_weights)}),symbolIcon:(R,r)=>({u_is_size_zoom_constant:new i.aH(R,r.u_is_size_zoom_constant),u_is_size_feature_constant:new i.aH(R,r.u_is_size_feature_constant),u_size_t:new i.aI(R,r.u_size_t),u_size:new i.aI(R,r.u_size),u_camera_to_center_distance:new i.aI(R,r.u_camera_to_center_distance),u_pitch:new i.aI(R,r.u_pitch),u_rotate_symbol:new i.aH(R,r.u_rotate_symbol),u_aspect_ratio:new i.aI(R,r.u_aspect_ratio),u_fade_change:new i.aI(R,r.u_fade_change),u_matrix:new i.aJ(R,r.u_matrix),u_label_plane_matrix:new i.aJ(R,r.u_label_plane_matrix),u_coord_matrix:new i.aJ(R,r.u_coord_matrix),u_is_text:new i.aH(R,r.u_is_text),u_pitch_with_map:new i.aH(R,r.u_pitch_with_map),u_is_along_line:new i.aH(R,r.u_is_along_line),u_is_variable_anchor:new i.aH(R,r.u_is_variable_anchor),u_texsize:new i.aO(R,r.u_texsize),u_texture:new i.aH(R,r.u_texture),u_translation:new i.aO(R,r.u_translation),u_pitched_scale:new i.aI(R,r.u_pitched_scale)}),symbolSDF:(R,r)=>
vendor: 18,942 bytes, line 2537
2537({u_is_size_zoom_constant:new i.aH(R,r.u_is_size_zoom_constant),u_is_size_feature_constant:new i.aH(R,r.u_is_size_feature_constant),u_size_t:new i.aI(R,r.u_size_t),u_size:new i.aI(R,r.u_size),u_camera_to_center_distance:new i.aI(R,r.u_camera_to_center_distance),u_pitch:new i.aI(R,r.u_pitch),u_rotate_symbol:new i.aH(R,r.u_rotate_symbol),u_aspect_ratio:new i.aI(R,r.u_aspect_ratio),u_fade_change:new i.aI(R,r.u_fade_change),u_matrix:new i.aJ(R,r.u_matrix),u_label_plane_matrix:new i.aJ(R,r.u_label_plane_matrix),u_coord_matrix:new i.aJ(R,r.u_coord_matrix),u_is_text:new i.aH(R,r.u_is_text),u_pitch_with_map:new i.aH(R,r.u_pitch_with_map),u_is_along_line:new i.aH(R,r.u_is_along_line),u_is_variable_anchor:new i.aH(R,r.u_is_variable_anchor),u_texsize:new i.aO(R,r.u_texsize),u_texture:new i.aH(R,r.u_texture),u_gamma_scale:new i.aI(R,r.u_gamma_scale),u_device_pixel_ratio:new i.aI(R,r.u_device_pixel_ratio),u_is_halo:new i.aH(R,r.u_is_halo),u_translation:new i.aO(R,r.u_translation),u_pitched_scale:new i.aI(R,r.u_pitched_scale)}),symbolTextAndIcon:(R,r)=>({u_is_size_zoom_constant:new i.aH(R,r.u_is_size_zoom_constant),u_is_size_feature_constant:new i.aH(R,r.u_is_size_feature_constant),u_size_t:new i.aI(R,r.u_size_t),u_size:new i.aI(R,r.u_size),u_camera_to_center_distance:new i.aI(R,r.u_camera_to_center_distance),u_pitch:new i.aI(R,r.u_pitch),u_rotate_symbol:new i.aH(R,r.u_rotate_symbol),u_aspect_ratio:new i.aI(R,r.u_aspect_ratio),u_fade_change:new i.aI(R,r.u_fade_change),u_matrix:new i.aJ(R,r.u_matrix),u_label_plane_matrix:new i.aJ(R,r.u_label_plane_matrix),u_coord_matrix:new i.aJ(R,r.u_coord_matrix),u_is_text:new i.aH(R,r.u_is_text),u_pitch_with_map:new i.aH(R,r.u_pitch_with_map),u_is_along_line:new i.aH(R,r.u_is_along_line),u_is_variable_anchor:new i.aH(R,r.u_is_variable_anchor),u_texsize:new i.aO(R,r.u_texsize),u_texsize_icon:new i.aO(R,r.u_texsize_icon),u_texture:new i.aH(R,r.u_texture),u_texture_icon:new i.aH(R,r.u_texture_icon),u_gamma_scale:new i.aI(R,r.u_gamma_scale),u_device_pixel_ratio:new i.aI(R,r.u_device_pixel_ratio),u_is_halo:new i.aH(R,r.u_is_halo),u_translation:new i.aO(R,r.u_translation),u_pitched_scale:new i.aI(R,r.u_pitched_scale)}),background:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_opacity:new i.aI(R,r.u_opacity),u_color:new i.aL(R,r.u_color)}),backgroundPattern:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_opacity:new i.aI(R,r.u_opacity),u_image:new i.aH(R,r.u_image),u_pattern_tl_a:new i.aO(R,r.u_pattern_tl_a),u_pattern_br_a:new i.aO(R,r.u_pattern_br_a),u_pattern_tl_b:new i.aO(R,r.u_pattern_tl_b),u_pattern_br_b:new i.aO(R,r.u_pattern_br_b),u_texsize:new i.aO(R,r.u_texsize),u_mix:new i.aI(R,r.u_mix),u_pattern_size_a:new i.aO(R,r.u_pattern_size_a),u_pattern_size_b:new i.aO(R,r.u_pattern_size_b),u_scale_a:new i.aI(R,r.u_scale_a),u_scale_b:new i.aI(R,r.u_scale_b),u_pixel_coord_upper:new i.aO(R,r.u_pixel_coord_upper),u_pixel_coord_lower:new i.aO(R,r.u_pixel_coord_lower),u_tile_units_to_pixels:new i.aI(R,r.u_tile_units_to_pixels)}),terrain:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_texture:new i.aH(R,r.u_texture),u_ele_delta:new i.aI(R,r.u_ele_delta),u_fog_matrix:new i.aJ(R,r.u_fog_matrix),u_fog_color:new i.aL(R,r.u_fog_color),u_fog_ground_blend:new i.aI(R,r.u_fog_ground_blend),u_fog_ground_blend_opacity:new i.aI(R,r.u_fog_ground_blend_opacity),u_horizon_color:new i.aL(R,r.u_horizon_color),u_horizon_fog_blend:new i.aI(R,r.u_horizon_fog_blend)}),terrainDepth:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_ele_delta:new i.aI(R,r.u_ele_delta)}),terrainCoords:(R,r)=>({u_matrix:new i.aJ(R,r.u_matrix),u_texture:new i.aH(R,r.u_texture),u_terrain_coords_id:new i.aI(R,r.u_terrain_coords_id),u_ele_delta:new i.aI(R,r.u_ele_delta)}),sky:(R,r)=>({u_sky_color:new i.aL(R,r.u_sky_color),u_horizon_color:new i.aL(R,r.u_horizon_color),u_horizon:new i.aI(R,r.u_horizon),u_sky_horizon_blend:new i.aI(R,r.u_sky_horizon_blend)})};class $r{constructor(r,g,S){this.context=r;const E=r.gl;this.buffer=E.createBuffer(),this.dynamicDraw=!!S,this.context.unbindVAO(),r.bindElementBuffer.set(this.buffer),E.bufferData(E.ELEMENT_ARRAY_BUFFER,g.arrayBuffer,this.dynamicDraw?E.DYNAMIC_DRAW:E.STATIC_DRAW),this.dynamicDraw||delete g.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(r){const g=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),g.bufferSubData(g.ELEMENT_ARRAY_BUFFER,0,r.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Jo={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class na{constructor(r,g,S,E){this.length=g.length,this.attributes=S,this.itemSize=g.bytesPerElement,this.dynamicDraw=E,this.context=r;const A=r.gl;this.buffer=A.createBuffer(),r.bindVertexBuffer.set(this.buffer),A.bufferData(A.ARRAY_BUFFER,g.arrayBuffer,this.dynamicDraw?A.DYNAMIC_DRAW:A.STATIC_DRAW),this.dynamicDraw||delete g.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(r){if(r.length!==this.length)throw new Error(`Length of new data is ${r.length}, which doesn't match current length of ${this.length}`);const g=this.context.gl;this.bind(),g.bufferSubData(g.ARRAY_BUFFER,0,r.arrayBuffer)}enableAttributes(r,g){for(let S=0;S<this.attributes.length;S++){const E=g.attributes[this.attributes[S].name];E!==void 0&&r.enableVertexAttribArray(E)}}setVertexAttribPointers(r,g,S){for(let E=0;E<this.attributes.length;E++){const A=this.attributes[E],ee=g.attributes[A.name];ee!==void 0&&r.vertexAttribPointer(ee,A.components,r[Jo[A.type]],!1,this.itemSize,A.offset+this.itemSize*(S||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Sn=new WeakMap;function Ui(R){var r;if(Sn.has(R))return Sn.get(R);{const g=(r=R.getParameter(R.VERSION))===null||r===void 0?void 0:r.startsWith("WebGL 2.0");return Sn.set(R,g),g}}class Ma{constructor(r){this.gl=r.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(r){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Di extends Ma{getDefault(){return i.aM.transparent}set(r){const g=this.current;(r.r!==g.r||r.g!==g.g||r.b!==g.b||r.a!==g.a||this.dirty)&&(this.gl.clearColor(r.r,r.g,r.b,r.a),this.current=r,this.dirty=!1)}}class Al extends Ma{getDefault(){return 1}set(r){(r!==this.current||this.dirty)&&(this.gl.clearDepth(r),this.current=r,this.dirty=!1)}}class cc extends Ma{getDefault(){return 0}set(r){(r!==this.current||this.dirty)&&(this.gl.clearStencil(r),this.current=r,this.dirty=!1)}}class dc extends Ma{getDefault(){return[!0,!0,!0,!0]}set(r){const g=this.current;(r[0]!==g[0]||r[1]!==g[1]||r[2]!==g[2]||r[3]!==g[3]||this.dirty)&&(this.gl.colorMask(r[0],r[1],r[2],r[3]),this.current=r,this.dirty=!1)}}class _u extends Ma{getDefault(){return!0}set(r){(r!==this.current||this.dirty)&&(this.gl.depthMask(r),this.current=r,this.dirty=!1)}}class uc extends Ma{getDefault(){return 255}set(r){(r!==this.current||this.dirty)&&(this.gl.stencilMask(r),this.current=r,this.dirty=!1)}}class hc extends Ma{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(r){const g=this.current;(r.func!==g.func||r.ref!==g.ref||r.mask!==g.mask||this.dirty)&&(this.gl.stencilFunc(r.func,r.ref,r.mask),this.current=r,this.dirty=!1)}}class kl extends Ma{getDefault(){const r=this.gl;return[r.KEEP,r.KEEP,r.KEEP]}set(r){const g=this.current;(r[0]!==g[0]||r[1]!==g[1]||r[2]!==g[2]||this.dirty)&&(this.gl.stencilOp(r[0],r[1],r[2]),this.current=r,this.dirty=!1)}}class Ki extends Ma{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const g=this.gl;r?g.enable(g.STENCIL_TEST):g.disable(g.STENCIL_TEST),this.current=r,this.dirty=!1}}class Dl extends Ma{getDefault(){return[0,1]}set(r){const g=this.current;(r[0]!==g[0]||r[1]!==g[1]||this.dirty)&&(this.gl.depthRange(r[0],r[1]),this.current=r,this.dirty=!1)}}class Ri extends Ma{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const g=this.gl;r?g.enable(g.DEPTH_TEST):g.disable(g.DEPTH_TEST),this.current=r,this.dirty=!1}}class Qo extends Ma{getDefault(){return this.gl.LESS}set(r){(r!==this.current||this.dirty)&&(this.gl.depthFunc(r),this.current=r,this.dirty=!1)}}class Cl extends Ma{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const g=this.gl;r?g.enable(g.BLEND):g.disable(g.BLEND),this.current=r,this.dirty=!1}}class Rl extends Ma{getDefault(){const r=this.gl;return[r.ONE,r.ZERO]}set(r){const g=this.current;(r[0]!==g[0]||r[1]!==g[1]||this.dirty)&&(this.gl.blendFunc(r[0],r[1]),this.current=r,this.dirty=!1)}}class Md extends Ma{getDefault(){return i.aM.transparent}set(r){const g=this.current;(r.r!==g.r||r.g!==g.g||r.b!==g.b||r.a!==g.a||this.dirty)&&(this.gl.blendColor(r.r,r.g,r.b,r.a),this.current=r,this.dirty=!1)}}class fl extends Ma{getDefault(){return this.gl.FUNC_ADD}set(r){(r!==this.current||this.dirty)&&(this.gl.blendEquation(r),this.current=r,this.dirty=!1)}}class So extends Ma{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const g=this.gl;r?g.enable(g.CULL_FACE):g.disable(g.CULL_FACE),this.current=r,this.dirty=!1}}class Kr extends Ma{getDefault(){return this.gl.BACK}set(r){(r!==this.current||this.dirty)&&(this.gl.cullFace(r),this.current=r,this.dirty=!1)}}class hi extends Ma{getDefault(){return this.gl.CCW}set(r){(r!==this.current||this.dirty)&&(this.gl.frontFace(r),this.current=r,this.dirty=!1)}}class Jd extends Ma{getDefault(){return null}set(r){(r!==this.current||this.dirty)&&(this.gl.useProgram(r),this.current=r,this.dirty=!1)}}class Id extends Ma{getDefault(){return this.gl.TEXTURE0}set(r){(r!==this.current||this.dirty)&&(this.gl.activeTexture(r),this.current=r,this.dirty=!1)}}class Hl extends Ma{getDefault(){const r=this.gl;return[0,0,r.drawingBufferWidth,r.drawingBufferHeight]}set(r){const g=this.current;(r[0]!==g[0]||r[1]!==g[1]||r[2]!==g[2]||r[3]!==g[3]||this.dirty)&&(this.gl.viewport(r[0],r[1],r[2],r[3]),this.current=r,this.dirty=!1)}}class Sl extends Ma{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const g=this.gl;g.bindFramebuffer(g.FRAMEBUFFER,r),this.current=r,this.dirty=!1}}class gd extends Ma{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const g=this.gl;g.bindRenderbuffer(g.RENDERBUFFER,r),this.current=r,this.dirty=!1}}class Zl extends Ma{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const g=this.gl;g.bindTexture(g.TEXTURE_2D,r),this.current=r,this.dirty=!1}}class Hi extends Ma{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const g=this.gl;g.bindBuffer(g.ARRAY_BUFFER,r),this.current=r,this.dirty=!1}}class eo extends Ma{getDefault(){return null}set(r){const g=this.gl;g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,r),this.current=r,this.dirty=!1}}class Wr extends Ma{getDefault(){return null}set(r){var g;if(r===this.current&&!this.dirty)return;const S=this.gl;Ui(S)?S.bindVertexArray(r):(g=S.getExtension("OES_vertex_array_object"))===null||g===void 0||g.bindVertexArrayOES(r),this.current=r,this.dirty=!1}}class Tc extends Ma{getDefault(){return 4}set(r){if(r===this.current&&!this.dirty)return;const g=this.gl;g.pixelStorei(g.UNPACK_ALIGNMENT,r),this.current=r,this.dirty=!1}}class Wl extends Ma{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const g=this.gl;g.pixelStorei(g.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r),this.current=r,this.dirty=!1}}class _o extends Ma{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const g=this.gl;g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL,r),this.current=r,this.dirty=!1}}class Yl extends Ma{constructor(r,g){super(r),this.context=r,this.parent=g}getDefault(){return null}}class Xl extends Yl{setDirty(){this.dirty=!0}set(r){if(r===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const g=this.gl;g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,g.TEXTURE_2D,r,0),this.current=r,this.dirty=!1}}class pl extends Yl{set(r){if(r===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const g=this.gl;g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_ATTACHMENT,g.RENDERBUFFER,r),this.current=r,this.dirty=!1}}class Fl extends Yl{set(r){if(r===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const g=this.gl;g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_STENCIL_ATTACHMENT,g.RENDERBUFFER,r),this.current=r,this.dirty=!1}}class Lc{constructor(r,g,S,E,A){this.context=r,this.width=g,this.height=S;const ee=r.gl,se=this.framebuffer=ee.createFramebuffer();if(this.colorAttachment=new Xl(r,se),E)this.depthAttachment=A?new Fl(r,se):new pl(r,se);else if(A)throw new Error("Stencil cannot be set without depth");if(ee.checkFramebufferStatus(ee.FRAMEBUFFER)!==ee.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){const r=this.context.gl,g=this.colorAttachment.get();if(g&&r.deleteTexture(g),this.depthAttachment){const S=this.depthAttachment.get();S&&r.deleteRenderbuffer(S)}r.deleteFramebuffer(this.framebuffer)}}class li{constructor(r,g,S){this.blendFunction=r,this.blendColor=g,this.mask=S}}li.Replace=[1,0],li.disabled=new li(li.Replace,i.aM.transparent,[!1,!1,!1,!1]),li.unblended=new li(li.Replace,i.aM.transparent,[!0,!0,!0,!0]),li.alphaBlended=new li([1,771],i.aM.transparent,[!0,!0,!0,!0]);class Kl{constructor(r){var g,S;if(this.gl=r,this.clearColor=new Di(this),this.clearDepth=new Al(this),this.clearStencil=new cc(this),this.colorMask=new dc(this),this.depthMask=new _u(this),this.stencilMask=new uc(this),this.stencilFunc=new hc(this),this.stencilOp=new kl(this),this.stencilTest=new Ki(this),this.depthRange=new Dl(this),this.depthTest=new Ri(this),this.depthFunc=new Qo(this),this.blend=new Cl(this),this.blendFunc=new Rl(this),this.blendColor=new Md(this),this.blendEquation=new fl(this),this.cullFace=new So(this),this.cullFaceSide=new Kr(this),this.frontFace=new hi(this),this.program=new Jd(this),this.activeTexture=new Id(this),this.viewport=new Hl(this),this.bindFramebuffer=new Sl(this),this.bindRenderbuffer=new gd(this),this.bindTexture=new Zl(this),this.bindVertexBuffer=new Hi(this),this.bindElementBuffer=new eo(this),this.bindVertexArray=new Wr(this),this.pixelStoreUnpack=new Tc(this),this.pixelStoreUnpackPremultiplyAlpha=new Wl(this),this.pixelStoreUnpackFlipY=new _o(this),this.extTextureFilterAnisotropic=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=r.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=r.getParameter(r.MAX_TEXTURE_SIZE),Ui(r)){this.HALF_FLOAT=r.HALF_FLOAT;const E=r.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(g=r.RGBA16F)!==null&&g!==void 0?g:E==null?void 0:E.RGBA16F_EXT,this.RGB16F=(S=r.RGB16F)!==null&&S!==void 0?S:E==null?void 0:E.RGB16F_EXT,r.getExtension("EXT_color_buffer_float")}else{r.getExtension("EXT_color_buffer_half_float"),r.getExtension("OES_texture_half_float_linear");const E=r.getExtension("OES_texture_half_float");this.HALF_FLOAT=E==null?void 0:E.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(r,g){return new $r(this,r,g)}createVertexBuffer(r,g,S){return new na(this,r,g,S)}createRenderbuffer(r,g,S){const E=this.gl,A=E.createRenderbuffer();return this.bindRenderbuffer.set(A),E.renderbufferStorage(E.RENDERBUFFER,r,g,S),this.bindRenderbuffer.set(null),A}createFramebuffer(r,g,S,E){return new Lc(this,r,g,S,E)}clear({color:r,depth:g,stencil:S}){const E=this.gl;let A=0;r&&(A|=E.COLOR_BUFFER_BIT,this.clearColor.set(r),this.colorMask.set([!0,!0,!0,!0])),g!==void 0&&(A|=E.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(g),this.depthMask.set(!0)),S!==void 0&&(A|=E.STENCIL_BUFFER_BIT,this.clearStencil.set(S),this.stencilMask.set(255)),E.clear(A)}setCullFace(r){r.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(r.mode),this.frontFace.set(r.frontFace))}setDepthMode(r){r.func!==this.gl.ALWAYS||r.mask?(this.depthTest.set(!0),this.depthFunc.set(r.func),this.depthMask.set(r.mask),this.depthRange.set(r.range)):this.depthTest.set(!1)}setStencilMode(r){r.test.func!==this.gl.ALWAYS||r.mask?(this.stencilTest.set(!0),this.stencilMask.set(r.mask),this.stencilOp.set([r.fail,r.depthFail,r.pass]),this.stencilFunc.set({func:r.test.func,ref:r.ref,mask:r.test.mask})):this.stencilTest.set(!1)}setColorMode(r){i.aE(r.blendFunction,li.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(r.blendFunction),this.blendColor.set(r.blendColor)),this.colorMask.set(r.mask)}createVertexArray(){var r;return Ui(this.gl)?this.gl.createVertexArray():(r=this.gl.getExtension("OES_vertex_array_object"))===null||r===void 0?void 0:r.createVertexArrayOES()}deleteVertexArray(r){var g;return Ui(this.gl)?this.gl.deleteVertexArray(r):(g=this.gl.getExtension("OES_vertex_array_object"))===null||g===void 0?void 0:g.deleteVertexArrayOES(r)}unbindVAO(){this.bindVertexArray.set(null)}}class Ia{constructor(r,g,S){this.func=r,this.mask=g,this.range=S}}Ia.ReadOnly=!1,Ia.ReadWrite=!0,Ia.disabled=new Ia(519,Ia.ReadOnly,[0,1]);const Jl=7680;
vendor: 4,742 bytes, line 2537
2537class fr{constructor(r,g,S,E,A,ee){this.test=r,this.ref=g,this.mask=S,this.fail=E,this.depthFail=A,this.pass=ee}}fr.disabled=new fr({func:519,mask:0},0,0,Jl,Jl,Jl);class Dr{constructor(r,g,S){this.enable=r,this.mode=g,this.frontFace=S}}let zl;function qe(R,r,g,S,E){const A=R.context,ee=A.gl,se=R.useProgram("collisionBox"),he=[];let _e=0,Ie=0;for(let Vt=0;Vt<S.length;Vt++){const Ht=S[Vt],Et=r.getTile(Ht).getBucket(g);if(!Et)continue;const Kt=E?Et.textCollisionBox:Et.iconCollisionBox,ss=Et.collisionCircleArray;if(ss.length>0){const cs=i.H();i.aQ(cs,Et.placementInvProjMatrix,R.transform.glCoordMatrix),i.aQ(cs,cs,Et.placementViewportMatrix),he.push({circleArray:ss,circleOffset:Ie,transform:Ht.posMatrix,invTransform:cs,coord:Ht}),_e+=ss.length/4,Ie=_e}Kt&&se.draw(A,ee.LINES,Ia.disabled,fr.disabled,R.colorModeForRenderPass(),Dr.disabled,{u_matrix:Ht.posMatrix,u_pixel_extrude_scale:[1/(Me=R.transform).width,1/Me.height]},R.style.map.terrain&&R.style.map.terrain.getTerrainData(Ht),g.id,Kt.layoutVertexBuffer,Kt.indexBuffer,Kt.segments,null,R.transform.zoom,null,null,Kt.collisionVertexBuffer)}var Me;if(!E||!he.length)return;const Je=R.useProgram("collisionCircle"),ut=new i.aR;ut.resize(4*_e),ut._trim();let gt=0;for(const Vt of he)for(let Ht=0;Ht<Vt.circleArray.length/4;Ht++){const Et=4*Ht,Kt=Vt.circleArray[Et+0],ss=Vt.circleArray[Et+1],cs=Vt.circleArray[Et+2],As=Vt.circleArray[Et+3];ut.emplace(gt++,Kt,ss,cs,As,0),ut.emplace(gt++,Kt,ss,cs,As,1),ut.emplace(gt++,Kt,ss,cs,As,2),ut.emplace(gt++,Kt,ss,cs,As,3)}(!zl||zl.length<2*_e)&&(zl=function(Vt){const Ht=2*Vt,Et=new i.aT;Et.resize(Ht),Et._trim();for(let Kt=0;Kt<Ht;Kt++){const ss=6*Kt;Et.uint16[ss+0]=4*Kt+0,Et.uint16[ss+1]=4*Kt+1,Et.uint16[ss+2]=4*Kt+2,Et.uint16[ss+3]=4*Kt+2,Et.uint16[ss+4]=4*Kt+3,Et.uint16[ss+5]=4*Kt+0}return Et}(_e));const St=A.createIndexBuffer(zl,!0),Lt=A.createVertexBuffer(ut,i.aS.members,!0);for(const Vt of he){const Ht=Nr(Vt.transform,Vt.invTransform,R.transform);Je.draw(A,ee.TRIANGLES,Ia.disabled,fr.disabled,R.colorModeForRenderPass(),Dr.disabled,Ht,R.style.map.terrain&&R.style.map.terrain.getTerrainData(Vt.coord),g.id,Lt,St,i.a0.simpleSegment(0,2*Vt.circleOffset,Vt.circleArray.length,Vt.circleArray.length/2),null,R.transform.zoom,null,null,null)}Lt.destroy(),St.destroy()}Dr.disabled=new Dr(!1,1029,2305),Dr.backCCW=new Dr(!0,1029,2305);const Xt=i.an(new Float32Array(16));function js(R,r,g,S,E,A){const{horizontalAlign:ee,verticalAlign:se}=i.au(R);return new i.P((-(ee-.5)*r/E+S[0])*A,(-(se-.5)*g/E+S[1])*A)}function Rs(R,r,g,S,E,A){const ee=r.tileAnchorPoint.add(new i.P(r.translation[0],r.translation[1]));if(r.pitchWithMap){let se=S.mult(A);g||(se=se.rotate(-E));const he=ee.add(se);return Ue(he.x,he.y,r.labelPlaneMatrix,r.getElevation).point}if(g){const se=Zt(r.tileAnchorPoint.x+1,r.tileAnchorPoint.y,r).point.sub(R),he=Math.atan(se.y/se.x)+(se.x<0?Math.PI:0);return R.add(S.rotate(he))}return R.add(S)}function la(R,r,g,S,E,A,ee,se,he,_e,Ie,Me,Je,ut){const gt=R.text.placedSymbolArray,St=R.text.dynamicLayoutVertexArray,Lt=R.icon.dynamicLayoutVertexArray,Vt={};St.clear();for(let Ht=0;Ht<gt.length;Ht++){const Et=gt.get(Ht),Kt=Et.hidden||!Et.crossTileID||R.allowVerticalPlacement&&!Et.placedOrientation?null:S[Et.crossTileID];if(Kt){const ss=new i.P(Et.anchorX,Et.anchorY),cs={getElevation:ut,width:E.width,height:E.height,labelPlaneMatrix:A,lineVertexArray:null,pitchWithMap:g,projection:Ie,projectionCache:null,tileAnchorPoint:ss,translation:Me,unwrappedTileID:Je},As=g?Ue(ss.x,ss.y,ee,ut):Zt(ss.x,ss.y,cs),sn=Pe(E.cameraToCenterDistance,As.signedDistanceFromCamera);let pn=i.ai(R.textSizeData,he,Et)*sn/i.ap;g&&(pn*=R.tilePixelRatio/se);const{width:Ln,height:Js,anchor:on,textOffset:Hn,textBoxScale:Ra}=Kt,ln=js(on,Ln,Js,Hn,Ra,pn),Nn=Ie.getPitchedTextCorrection(E,ss.add(new i.P(Me[0],Me[1])),Je),aa=Rs(As.point,cs,r,ln,E.angle,Nn),mi=R.allowVerticalPlacement&&Et.placedOrientation===i.ah.vertical?Math.PI/2:0;for(let er=0;er<Et.numGlyphs;er++)i.aj(St,aa,mi);_e&&Et.associatedIconIndex>=0&&(Vt[Et.associatedIconIndex]={shiftedAnchor:aa,angle:mi})}else an(Et.numGlyphs,St)}if(_e){Lt.clear();const Ht=R.icon.placedSymbolArray;for(let Et=0;Et<Ht.length;Et++){const Kt=Ht.get(Et);if(Kt.hidden)an(Kt.numGlyphs,Lt);else{const ss=Vt[Et];if(ss)for(let cs=0;cs<Kt.numGlyphs;cs++)i.aj(Lt,ss.shiftedAnchor,ss.angle);else an(Kt.numGlyphs,Lt)}}R.icon.dynamicLayoutVertexBuffer.updateData(Lt)}R.text.dynamicLayoutVertexBuffer.updateData(St)}function Bn(R,r,g){return g.iconsInText&&r?"symbolTextAndIcon":R?"symbolSDF":"symbolIcon"}function Rr(R,r,g,S,E,A,ee,se,he,_e,Ie,Me){const Je=R.context,ut=Je.gl,gt=R.transform,St=qa(),Lt=se==="map",Vt=he==="map",Ht=se!=="viewport"&&g.layout.get("symbol-placement")!=="point",Et=Lt&&!Vt&&!Ht,Kt=!Vt&&Ht,
2537ss=!g.layout.get("symbol-sort-key").isConstant();let cs=!1;const As=R.depthModeForSublayer(0,Ia.ReadOnly),sn=g._unevaluatedLayout.hasValue("text-variable-anchor")||g._unevaluatedLayout.hasValue("text-variable-anchor-offset"),pn=[],Ln=St.getCircleRadiusCorrection(gt);for(const Js of S){const on=r.getTile(Js),Hn=on.getBucket(g);if(!Hn)continue;const Ra=E?Hn.text:Hn.icon;if(!Ra||!Ra.segments.get().length||!Ra.hasVisibleVertices)continue;const ln=Ra.programConfigurations.get(g.id),Nn=E||Hn.sdfIcons,aa=E?Hn.textSizeData:Hn.iconSizeData,mi=Vt||gt.pitch!==0,er=R.useProgram(Bn(Nn,E,Hn),ln),Sr=i.ag(aa,gt.zoom),Pi=R.style.map.terrain&&R.style.map.terrain.getTerrainData(Js);let al,Dd,Ti,fc,El=[0,0],Ql=null;if(E)Dd=on.glyphAtlasTexture,Ti=ut.LINEAR,al=on.glyphAtlasTexture.size,Hn.iconsInText&&(El=on.imageAtlasTexture.size,Ql=on.imageAtlasTexture,fc=mi||R.options.rotating||R.options.zooming||aa.kind==="composite"||aa.kind==="camera"?ut.LINEAR:ut.NEAREST);else{const qr=g.layout.get("icon-size").constantOr(0)!==1||Hn.iconsNeedLinear;Dd=on.imageAtlasTexture,Ti=Nn||R.options.rotating||R.options.zooming||qr||mi?ut.LINEAR:ut.NEAREST,al=on.imageAtlasTexture.size}const Ol=os(on,1,R.transform.zoom),Rd=Kt?Js.posMatrix:Xt,qu=wn(Rd,Vt,Lt,R.transform,Ol),Jm=Gs(Rd,Vt,Lt,R.transform,Ol),Vo=Gs(Js.posMatrix,Vt,Lt,R.transform,Ol),Bl=St.translatePosition(R.transform,on,A,ee),Zf=sn&&Hn.hasTextData(),Wf=g.layout.get("icon-text-fit")!=="none"&&Zf&&Hn.hasIconData();if(Ht){const qr=R.style.map.terrain?(Gu,jh)=>R.style.map.terrain.getElevation(Js,Gu,jh):null,su=g.layout.get("text-rotation-alignment")==="map";Ge(Hn,Js.posMatrix,R,E,qu,Vo,Vt,_e,su,St,Js.toUnwrapped(),gt.width,gt.height,Bl,qr)}const td=Js.posMatrix,vd=E&&sn||Wf,ju=Ht||vd?Xt:qu,Rc=Jm,$l=Nn&&g.paint.get(E?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let rl;rl=Nn?Hn.iconsInText?Tn(aa.kind,Sr,Et,Vt,Ht,vd,R,td,ju,Rc,Bl,al,El,Ln):qs(aa.kind,Sr,Et,Vt,Ht,vd,R,td,ju,Rc,Bl,E,al,!0,Ln):ti(aa.kind,Sr,Et,Vt,Ht,vd,R,td,ju,Rc,Bl,E,al,Ln);const Fc={program:er,buffers:Ra,uniformValues:rl,atlasTexture:Dd,atlasTextureIcon:Ql,atlasInterpolation:Ti,atlasInterpolationIcon:fc,isSDF:Nn,hasHalo:$l};if(ss&&Hn.canOverlap){cs=!0;const qr=Ra.segments.get();for(const su of qr)pn.push({segments:new i.a0([su]),sortKey:su.sortKey,state:Fc,terrainData:Pi})}else pn.push({segments:Ra.segments,sortKey:0,state:Fc,terrainData:Pi})}cs&&pn.sort((Js,on)=>Js.sortKey-on.sortKey);for(const Js of pn){const on=Js.state;if(Je.activeTexture.set(ut.TEXTURE0),on.atlasTexture.bind(on.atlasInterpolation,ut.CLAMP_TO_EDGE),on.atlasTextureIcon&&(Je.activeTexture.set(ut.TEXTURE1),on.atlasTextureIcon&&on.atlasTextureIcon.bind(on.atlasInterpolationIcon,ut.CLAMP_TO_EDGE)),on.isSDF){const Hn=on.uniformValues;on.hasHalo&&(Hn.u_is_halo=1,Mc(on.buffers,Js.segments,g,R,on.program,As,Ie,Me,Hn,Js.terrainData)),Hn.u_is_halo=0}Mc(on.buffers,Js.segments,g,R,on.program,As,Ie,Me,on.uniformValues,Js.terrainData)}}function Mc(R,r,g,S,E,A,ee,se,he,_e){const Ie=S.context;E.draw(Ie,Ie.gl.TRIANGLES,A,ee,se,Dr.disabled,he,_e,g.id,R.layoutVertexBuffer,R.indexBuffer,r,g.paint,S.transform.zoom,R.programConfigurations.get(g.id),R.dynamicLayoutVertexBuffer,R.opacityVertexBuffer)}function Uo(R,r,g,S){const E=R.context,A=E.gl,ee=fr.disabled,se=new li([A.ONE,A.ONE],i.aM.transparent,[!0,!0,!0,!0]),he=r.getBucket(g);if(!he)return;const _e=S.key;let Ie=g.heatmapFbos.get(_e);Ie||(Ie=Oo(E,r.tileSize,r.tileSize),g.heatmapFbos.set(_e,Ie)),E.bindFramebuffer.set(Ie.framebuffer),E.viewport.set([0,0,r.tileSize,r.tileSize]),E.clear({color:i.aM.transparent});const Me=he.programConfigurations.get(g.id),Je=R.useProgram("heatmap",Me),ut=R.style.map.terrain.getTerrainData(S);Je.draw(E,A.TRIANGLES,Ia.disabled,ee,se,Dr.disabled,Gi(S.posMatrix,r,R.transform.zoom,g.paint.get("heatmap-intensity")),ut,g.id,he.layoutVertexBuffer,he.indexBuffer,he.segments,g.paint,R.transform.zoom,Me)}function el(R,r,g){const S=R.context,E=S.gl;S.setColorMode(R.colorModeForRenderPass());const A=yo(S,r),ee=g.key,se=r.heatmapFbos.get(ee);se&&(S.activeTexture.set(E.TEXTURE0),E.bindTexture(E.TEXTURE_2D,se.colorAttachment.get()),S.activeTexture.set(E.TEXTURE1),A.bind(E.LINEAR,E.CLAMP_TO_EDGE),R.useProgram("heatmapTexture").draw(S,E.TRIANGLES,Ia.disabled,fr.disabled,R.colorModeForRenderPass(),Dr.disabled,fn(R,r,0,1),null,r.id,R.rasterBoundsBuffer,R.quadTriangleIndexBuffer,R.rasterBoundsSegments,r.paint,R.transform.zoom),se.destroy(),r.heatmapFbos.delete(ee))}function Oo(R,r,g){var S,E;const A=R.gl,ee=A.createTexture();A.bindTexture(A.TEXTURE_2D,ee),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_WRAP_S,A.CLAMP_TO_EDGE),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_WRAP_T,A.CLAMP_TO_EDGE),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_MIN_FILTER,A.LINEAR),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_MAG_FILTER,A.LINEAR);const se=(S=R.HALF_FLOAT)!==null&&S!==void 0?S:A.UNSIGNED_BYTE,he
vendor: 18,981 bytes, line 2537
2537=(E=R.RGBA16F)!==null&&E!==void 0?E:A.RGBA;A.texImage2D(A.TEXTURE_2D,0,he,r,g,0,A.RGBA,se,null);const _e=R.createFramebuffer(r,g,!1,!1);return _e.colorAttachment.set(ee),_e}function yo(R,r){return r.colorRampTexture||(r.colorRampTexture=new Q(R,r.colorRamp,R.gl.RGBA)),r.colorRampTexture}function gl(R,r,g,S,E){if(!g||!S||!S.imageAtlas)return;const A=S.imageAtlas.patternPositions;let ee=A[g.to.toString()],se=A[g.from.toString()];if(!ee&&se&&(ee=se),!se&&ee&&(se=ee),!ee||!se){const he=E.getPaintProperty(r);ee=A[he],se=A[he]}ee&&se&&R.setConstantPatternPositions(ee,se)}function ci(R,r,g,S,E,A,ee){const se=R.context.gl,he="fill-pattern",_e=g.paint.get(he),Ie=_e&&_e.constantOr(1),Me=g.getCrossfadeParameters();let Je,ut,gt,St,Lt;ee?(ut=Ie&&!g.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",Je=se.LINES):(ut=Ie?"fillPattern":"fill",Je=se.TRIANGLES);const Vt=_e.constantOr(null);for(const Ht of S){const Et=r.getTile(Ht);if(Ie&&!Et.patternsLoaded())continue;const Kt=Et.getBucket(g);if(!Kt)continue;const ss=Kt.programConfigurations.get(g.id),cs=R.useProgram(ut,ss),As=R.style.map.terrain&&R.style.map.terrain.getTerrainData(Ht);Ie&&(R.context.activeTexture.set(se.TEXTURE0),Et.imageAtlasTexture.bind(se.LINEAR,se.CLAMP_TO_EDGE),ss.updatePaintBuffers(Me)),gl(ss,he,Vt,Et,g);const sn=As?Ht:null,pn=R.translatePosMatrix(sn?sn.posMatrix:Ht.posMatrix,Et,g.paint.get("fill-translate"),g.paint.get("fill-translate-anchor"));if(ee){St=Kt.indexBuffer2,Lt=Kt.segments2;const Ln=[se.drawingBufferWidth,se.drawingBufferHeight];gt=ut==="fillOutlinePattern"&&Ie?ul(pn,R,Me,Et,Ln):Hr(pn,Ln)}else St=Kt.indexBuffer,Lt=Kt.segments,gt=Ie?Pc(pn,R,Me,Et):zo(pn);cs.draw(R.context,Je,E,R.stencilModeForClipping(Ht),A,Dr.disabled,gt,As,g.id,Kt.layoutVertexBuffer,St,Lt,g.paint,R.transform.zoom,ss)}}function Eo(R,r,g,S,E,A,ee){const se=R.context,he=se.gl,_e="fill-extrusion-pattern",Ie=g.paint.get(_e),Me=Ie.constantOr(1),Je=g.getCrossfadeParameters(),ut=g.paint.get("fill-extrusion-opacity"),gt=Ie.constantOr(null);for(const St of S){const Lt=r.getTile(St),Vt=Lt.getBucket(g);if(!Vt)continue;const Ht=R.style.map.terrain&&R.style.map.terrain.getTerrainData(St),Et=Vt.programConfigurations.get(g.id),Kt=R.useProgram(Me?"fillExtrusionPattern":"fillExtrusion",Et);Me&&(R.context.activeTexture.set(he.TEXTURE0),Lt.imageAtlasTexture.bind(he.LINEAR,he.CLAMP_TO_EDGE),Et.updatePaintBuffers(Je)),gl(Et,_e,gt,Lt,g);const ss=R.translatePosMatrix(St.posMatrix,Lt,g.paint.get("fill-extrusion-translate"),g.paint.get("fill-extrusion-translate-anchor")),cs=g.paint.get("fill-extrusion-vertical-gradient"),As=Me?Si(ss,R,cs,ut,St,Je,Lt):jl(ss,R,cs,ut);Kt.draw(se,se.gl.TRIANGLES,E,A,ee,Dr.backCCW,As,Ht,g.id,Vt.layoutVertexBuffer,Vt.indexBuffer,Vt.segments,g.paint,R.transform.zoom,Et,R.style.map.terrain&&Vt.centroidVertexBuffer)}}function tl(R,r,g,S,E,A,ee){const se=R.context,he=se.gl,_e=g.fbo;if(!_e)return;const Ie=R.useProgram("hillshade"),Me=R.style.map.terrain&&R.style.map.terrain.getTerrainData(r);se.activeTexture.set(he.TEXTURE0),he.bindTexture(he.TEXTURE_2D,_e.colorAttachment.get()),Ie.draw(se,he.TRIANGLES,E,A,ee,Dr.disabled,((Je,ut,gt,St)=>{const Lt=gt.paint.get("hillshade-shadow-color"),Vt=gt.paint.get("hillshade-highlight-color"),Ht=gt.paint.get("hillshade-accent-color");let Et=gt.paint.get("hillshade-illumination-direction")*(Math.PI/180);gt.paint.get("hillshade-illumination-anchor")==="viewport"&&(Et-=Je.transform.angle);const Kt=!Je.options.moving;return{u_matrix:St?St.posMatrix:Je.transform.calculatePosMatrix(ut.tileID.toUnwrapped(),Kt),u_image:0,u_latrange:kr(0,ut.tileID),u_light:[gt.paint.get("hillshade-exaggeration"),Et],u_shadow:Lt,u_highlight:Vt,u_accent:Ht}})(R,g,S,Me?r:null),Me,S.id,R.rasterBoundsBuffer,R.quadTriangleIndexBuffer,R.rasterBoundsSegments)}function xl(R,r,g,S,E,A){const ee=R.context,se=ee.gl,he=r.dem;if(he&&he.data){const _e=he.dim,Ie=he.stride,Me=he.getPixels();if(ee.activeTexture.set(se.TEXTURE1),ee.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||R.getTileTexture(Ie),r.demTexture){const ut=r.demTexture;ut.update(Me,{premultiply:!1}),ut.bind(se.NEAREST,se.CLAMP_TO_EDGE)}else r.demTexture=new Q(ee,Me,se.RGBA,{premultiply:!1}),r.demTexture.bind(se.NEAREST,se.CLAMP_TO_EDGE);ee.activeTexture.set(se.TEXTURE0);let Je=r.fbo;if(!Je){const ut=new Q(ee,{width:_e,height:_e,data:null},se.RGBA);ut.bind(se.LINEAR,se.CLAMP_TO_EDGE),Je=r.fbo=ee.createFramebuffer(_e,_e,!0,!1),Je.colorAttachment.set(ut.texture)}ee.bindFramebuffer.set(Je.framebuffer),ee.viewport.set([0,0,_e,_e]),R.useProgram("hillshadePrepare").draw(ee,se.TRIANGLES,S,E,A,Dr.disabled,((ut,gt)=>{const St=gt.stride,Lt=i.H();return i.aP(Lt,0,i.X,-i.X,0,0,1),i.J(Lt,Lt,[0,-i.X,0]),{u_matrix:Lt,u_image:1,u_dimension:[St,St],u_zoom:ut.overscaledZ,u_unpack:gt.getUnpackVector()}})(r.tileID,he),null,g.id,R.rasterBoundsBuffer,R.quadTriangleIndexBuffer,R.rasterBoundsSegments),r.needsHillshadePrepare=!1}}function Bo(R,r,g,S,E,A){const ee=S.paint.get("raster-fade-duration");if(!A&&ee>0){const se=x.now(),he=(se-R.timeAdded)/ee,_e=r?(se-r.timeAdded)/ee:-1,Ie=g.getSource(),Me=E.coveringZoomLevel({tileSize:Ie.tileSize,roundZoom:Ie.roundZoom}),Je=!r||Math.abs(r.tileID.overscaledZ-Me)>Math.abs(R.tileID.overscaledZ-Me),ut=Je&&R.refreshedUponExpiration?1:i.ac(Je?he:1-_e,0,1);return R.refreshedUponExpiration&&he>=1&&(R.refreshedUponExpiration=!1),r?{opacity:1,mix:1-ut}:{opacity:ut,mix:0}}return{opacity:1,mix:0}}const Jc=new i.aM(1,0,0,1),Cr=new i.aM(0,1,0,1),Ic=new i.aM(0,0,1,1),yu=new i.aM(1,0,1,1),Qd=new i.aM(0,1,1,1);function to(R,r,g,S){N(R,0,r+g/2,R.transform.width,g,S)}function $o(R,r,g,S){N(R,r-g/2,0,g,R.transform.height,S)}function N(R,r,g,S,E,A){const ee=R.context,se=ee.gl;se.enable(se.SCISSOR_TEST),se.scissor(r*R.pixelRatio,g*R.pixelRatio,S*R.pixelRatio,E*R.pixelRatio),ee.clear({color:A}),se.disable(se.SCISSOR_TEST)}function h(R,r,g){const S=R.context,E=S.gl,A=g.posMatrix,ee=R.useProgram("debug"),se=Ia.disabled,he=fr.disabled,_e=R.colorModeForRenderPass(),Ie="$debug",Me=R.style.map.terrain&&R.style.map.terrain.getTerrainData(g);S.activeTexture.set(E.TEXTURE0);const Je=r.getTileByID(g.key).latestRawTileData,ut=Math.floor((Je&&Je.byteLength||0)/1024),gt=r.getTile(g).tileSize,St=512/Math.min(gt,512)*(g.overscaledZ/R.transform.zoom)*.5;let Lt=g.canonical.toString();g.overscaledZ!==g.canonical.z&&(Lt+=` => ${g.overscaledZ}`),function(Vt,Ht){Vt.initDebugOverlayCanvas();const Et=Vt.debugOverlayCanvas,Kt=Vt.context.gl,ss=Vt.debugOverlayCanvas.getContext("2d");ss.clearRect(0,0,Et.width,Et.height),ss.shadowColor="white",ss.shadowBlur=2,ss.lineWidth=1.5,ss.strokeStyle="white",ss.textBaseline="top",ss.font="bold 36px Open Sans, sans-serif",ss.fillText(Ht,5,5),ss.strokeText(Ht,5,5),Vt.debugOverlayTexture.update(Et),Vt.debugOverlayTexture.bind(Kt.LINEAR,Kt.CLAMP_TO_EDGE)}(R,`${Lt} ${ut}kB`),ee.draw(S,E.TRIANGLES,se,he,li.alphaBlended,Dr.disabled,ui(A,i.aM.transparent,St),null,Ie,R.debugBuffer,R.quadTriangleIndexBuffer,R.debugSegments),ee.draw(S,E.LINE_STRIP,se,he,_e,Dr.disabled,ui(A,i.aM.red),Me,Ie,R.debugBuffer,R.tileBorderIndexBuffer,R.debugSegments)}function f(R,r,g){const S=R.context,E=S.gl,A=R.colorModeForRenderPass(),ee=new Ia(E.LEQUAL,Ia.ReadWrite,R.depthRangeFor3D),se=R.useProgram("terrain"),he=r.getTerrainMesh();S.bindFramebuffer.set(null),S.viewport.set([0,0,R.width,R.height]);for(const _e of g){const Ie=R.renderToTexture.getTexture(_e),Me=r.getTerrainData(_e.tileID);S.activeTexture.set(E.TEXTURE0),E.bindTexture(E.TEXTURE_2D,Ie.texture);const Je=R.transform.calculatePosMatrix(_e.tileID.toUnwrapped()),ut=r.getMeshFrameDelta(R.transform.zoom),gt=R.transform.calculateFogMatrix(_e.tileID.toUnwrapped()),St=Xr(Je,ut,gt,R.style.sky,R.transform.pitch);se.draw(S,E.TRIANGLES,ee,fr.disabled,A,Dr.backCCW,St,Me,"terrain",he.vertexBuffer,he.indexBuffer,he.segments)}}class w{constructor(r,g,S){this.vertexBuffer=r,this.indexBuffer=g,this.segments=S}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class G{constructor(r,g){this.context=new Kl(r),this.transform=g,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:i.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=ps.maxUnderzooming+ps.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Gn}resize(r,g,S){if(this.width=Math.floor(r*S),this.height=Math.floor(g*S),this.pixelRatio=S,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const E of this.style._order)this.style._layers[E].resize()}setup(){const r=this.context,g=new i.aX;g.emplaceBack(0,0),g.emplaceBack(i.X,0),g.emplaceBack(0,i.X),g.emplaceBack(i.X,i.X),this.tileExtentBuffer=r.createVertexBuffer(g,Tr.members),this.tileExtentSegments=i.a0.simpleSegment(0,0,4,2);const S=new i.aX;S.emplaceBack(0,0),S.emplaceBack(i.X,0),S.emplaceBack(0,i.X),S.emplaceBack(i.X,i.X),this.debugBuffer=r.createVertexBuffer(S,Tr.members),this.debugSegments=i.a0.simpleSegment(0,0,4,5);const E=new i.$;E.emplaceBack(0,0,0,0),E.emplaceBack(i.X,0,i.X,0),E.emplaceBack(0,i.X,0,i.X),E.emplaceBack(i.X,i.X,i.X,i.X),this.rasterBoundsBuffer=r.createVertexBuffer(E,Dt.members),this.rasterBoundsSegments=i.a0.simpleSegment(0,0,4,2);const A=new i.aX;A.emplaceBack(0,0),A.emplaceBack(1,0),A.emplaceBack(0,1),A.emplaceBack(1,1),this.viewportBuffer=r.createVertexBuffer(A,Tr.members),this.viewportSegments=i.a0.simpleSegment(0,0,4,2);const ee=new i.aZ;ee.emplaceBack(0),ee.emplaceBack(1),ee.emplaceBack(3),ee.emplaceBack(2),ee.emplaceBack(0),this.tileBorderIndexBuffer=r.createIndexBuffer(ee);const se=new i.aY;se.emplaceBack(0,1,2),se.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=r.createIndexBuffer(se);const he=this.context.gl;this.stencilClearMode=new fr({func:he.ALWAYS,mask:0},0,255,he.ZERO,he.ZERO,he.ZERO)}clearStencil(){const r=this.context,g=r.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const S=i.H();i.aP(S,0,this.width,this.height,0,0,1),i.K(S,S,[g.drawingBufferWidth,g.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(r,g.TRIANGLES,Ia.disabled,this.stencilClearMode,li.disabled,Dr.disabled,Zr(S),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(r,g){if(this.currentStencilSource===r.source||!r.isTileClipped()||!g||!g.length)return;this.currentStencilSource=r.source;const S=this.context,E=S.gl;this.nextStencilID+g.length>256&&this.clearStencil(),S.setColorMode(li.disabled),S.setDepthMode(Ia.disabled);const A=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const ee of g){const se=this._tileClippingMaskIDs[ee.key]=this.nextStencilID++,he=this.style.map.terrain&&this.style.map.terrain.getTerrainData(ee);A.draw(S,E.TRIANGLES,Ia.disabled,new fr({func:E.ALWAYS,mask:0},se,255,E.KEEP,E.KEEP,E.REPLACE),li.disabled,Dr.disabled,Zr(ee.posMatrix),he,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const r=this.nextStencilID++,g=this.context.gl;return new fr({func:g.NOTEQUAL,mask:255},r,255,g.KEEP,g.KEEP,g.REPLACE)}stencilModeForClipping(r){const g=this.context.gl;return new fr({func:g.EQUAL,mask:255},this._tileClippingMaskIDs[r.key],0,g.KEEP,g.KEEP,g.REPLACE)}stencilConfigForOverlap(r){const g=this.context.gl,S=r.sort((ee,se)=>se.overscaledZ-ee.overscaledZ),E=S[S.length-1].overscaledZ,A=S[0].overscaledZ-E+1;if(A>1){this.currentStencilSource=void 0,this.nextStencilID+A>256&&this.clearStencil();const ee={};for(let se=0;se<A;se++)ee[se+E]=new fr({func:g.GEQUAL,mask:255},se+this.nextStencilID,255,g.KEEP,g.KEEP,g.REPLACE);return this.nextStencilID+=A,[ee,S]}return[{[E]:fr.disabled},S]}colorModeForRenderPass(){const r=this.context.gl;return this._showOverdrawInspector?new li([r.CONSTANT_COLOR,r.ONE],new i.aM(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?li.unblended:li.alphaBlended}depthModeForSublayer(r,g,S){if(!this.opaquePassEnabledForLayer())return Ia.disabled;const E=1-((1+this.currentLayer)*this.numSublayers+r)*this.depthEpsilon;return new Ia(S||this.context.gl.LEQUAL,g,[E,E])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(r,g){this.style=r,this.options=g,this.lineAtlas=r.lineAtlas,this.imageManager=r.imageManager,this.glyphManager=r.glyphManager,this.symbolFadeChange=r.placement.symbolFadeChange(x.now()),this.imageManager.beginFrame();const S=this.style._order,E=this.style.sourceCaches,A={},ee={},se={};for(const he in E){const _e=E[he];_e.used&&_e.prepare(this.context),A[he]=_e.getVisibleCoordinates(),ee[he]=A[he].slice().reverse(),se[he]=_e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let he=0;he<S.length;he++)if(this.style._layers[S[he]].is3D()){this.opaquePassCutoff=he;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const he of S){const _e=this.style._layers[he];if(!_e.hasOffscreenPass()||_e.isHidden(this.transform.zoom))continue;const Ie=ee[_e.source];(_e.type==="custom"||Ie.length)&&this.renderLayer(this,E[_e.source],_e,Ie)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:g.showOverdrawInspector?i.aM.black:i.aM.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(he,_e){const Ie=he.context,Me=Ie.gl,Je=((Vt,Ht,Et)=>({u_sky_color:Vt.properties.get("sky-color"),u_horizon_color:Vt.properties.get("horizon-color"),u_horizon:(Ht.height/2+Ht.getHorizon())*Et,u_sky_horizon_blend:Vt.properties.get("sky-horizon-blend")*Ht.height/2*Et}))(_e,he.style.map.transform,he.pixelRatio),ut=new Ia(Me.LEQUAL,Ia.ReadWrite,[0,1]),gt=fr.disabled,St=he.colorModeForRenderPass(),Lt=he.useProgram("sky");if(!_e.mesh){const Vt=new i.aX;Vt.emplaceBack(-1,-1),Vt.emplaceBack(1,-1),Vt.emplaceBack(1,1),Vt.emplaceBack(-1,1);const Ht=new i.aY;Ht.emplaceBack(0,1,2),Ht.emplaceBack(0,2,3),_e.mesh=new w(Ie.createVertexBuffer(Vt,Tr.members),Ie.createIndexBuffer(Ht),i.a0.simpleSegment(0,0,Vt.length,Ht.length))}Lt.draw(Ie,Me.TRIANGLES,ut,gt,St,Dr.disabled,Je,void 0,"sky",_e.mesh.vertexBuffer,_e.mesh.indexBuffer,_e.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=g.showOverdrawInspector,this.depthRangeFor3D=[0,1-(r._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=S.length-1;this.currentLayer>=0;this.currentLayer--){const he=this.style._layers[S[this.currentLayer]],_e=E[he.source],Ie=A[he.source];this._renderTileClippingMasks(he,Ie),this.renderLayer(this,_e,he,Ie)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<S.length;this.currentLayer++){const he=this.style._layers[S[this.currentLayer]],_e=E[he.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(he))continue;const Ie=(he.type==="symbol"?se:ee)[he.source];this._renderTileClippingMasks(he,A[he.source]),this.renderLayer(this,_e,he,Ie)}if(this.options.showTileBoundaries){const he=function(_e,Ie){let Me=null;const Je=Object.values(_e._layers).flatMap(Lt=>Lt.source&&!Lt.isHidden(Ie)?[_e.sourceCaches[Lt.source]]:[]),ut=Je.filter(Lt=>Lt.getSource().type==="vector"),gt=Je.filter(Lt=>Lt.getSource().type!=="vector"),St=Lt=>{(!Me||Me.getSource().maxzoom<Lt.getSource().maxzoom)&&(Me=Lt)};return ut.forEach(Lt=>St(Lt)),Me||gt.forEach(Lt=>St(Lt)),Me}(this.style,this.transform.zoom);he&&function(_e,Ie,Me){for(let Je=0;Je<Me.length;Je++)h(_e,Ie,Me[Je])}(this,he,he.getVisibleCoordinates())}this.options.showPadding&&function(he){const _e=he.transform.padding;to(he,he.transform.height-(_e.top||0),3,Jc),to(he,_e.bottom||0,3,Cr),$o(he,_e.left||0,3,Ic),$o(he,he.transform.width-(_e.right||0),3,yu);const Ie=he.transform.centerPoint;(function(Me,Je,ut,gt){N(Me,Je-1,ut-10,2,20,gt),N(Me,Je-10,ut-1,20,2,gt)})(he,Ie.x,he.transform.height-Ie.y,Qd)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(r){if(!this.style||!this.style.map||!this.style.map.terrain)return;const g=this.terrainFacilitator.matrix,S=this.transform.modelViewProjectionMatrix;let E=this.terrainFacilitator.dirty;E||(E=r?!i.a_(g,S):!i.a$(g,S)),E||(E=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),E&&(i.b0(g,S),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(A,ee){const se=A.context,he=se.gl,_e=li.unblended,Ie=new Ia(he.LEQUAL,Ia.ReadWrite,[0,1]),Me=ee.getTerrainMesh(),Je=ee.sourceCache.getRenderableTiles(),ut=A.useProgram("terrainDepth");se.bindFramebuffer.set(ee.getFramebuffer("depth").framebuffer),se.viewport.set([0,0,A.width/devicePixelRatio,A.height/devicePixelRatio]),se.clear({color:i.aM.transparent,depth:1});for(const gt of Je){const St=ee.getTerrainData(gt.tileID),Lt={u_matrix:A.transform.calculatePosMatrix(gt.tileID.toUnwrapped()),u_ele_delta:ee.getMeshFrameDelta(A.transform.zoom)};ut.draw(se,he.TRIANGLES,Ie,fr.disabled,_e,Dr.backCCW,Lt,St,"terrain",Me.vertexBuffer,Me.indexBuffer,Me.segments)}se.bindFramebuffer.set(null),se.viewport.set([0,0,A.width,A.height])}(this,this.style.map.terrain),function(A,ee){const se=A.context,he=se.gl,_e=li.unblended,Ie=new Ia(he.LEQUAL,Ia.ReadWrite,[0,1]),Me=ee.getTerrainMesh(),Je=ee.getCoordsTexture(),ut=ee.sourceCache.getRenderableTiles(),gt=A.useProgram("terrainCoords");se.bindFramebuffer.set(ee.getFramebuffer("coords").framebuffer),se.viewport.set([0,0,A.width/devicePixelRatio,A.height/devicePixelRatio]),se.clear({color:i.aM.transparent,depth:1}),ee.coordsIndex=[];for(const St of ut){const Lt=ee.getTerrainData(St.tileID);se.activeTexture.set(he.TEXTURE0),he.bindTexture(he.TEXTURE_2D,Je.texture);const Vt={u_matrix:A.transform.calculatePosMatrix(St.tileID.toUnwrapped()),u_terrain_coords_id:(255-ee.coordsIndex.length)/255,u_texture:0,u_ele_delta:ee.getMeshFrameDelta(A.transform.zoom)};gt.draw(se,he.TRIANGLES,Ie,fr.disabled,_e,Dr.backCCW,Vt,Lt,"terrain",Me.vertexBuffer,Me.indexBuffer,Me.segments),ee.coordsIndex.push(St.tileID.key)}se.bindFramebuffer.set(null),se.viewport.set([0,0,A.width,A.height])}(this,this.style.map.terrain))}renderLayer(r,g,S,E){if(!S.isHidden(this.transform.zoom)&&(S.type==="background"||S.type==="custom"||(E||[]).length))switch(this.id=S.id,S.type){case"symbol":(function(A,ee,se,he,_e){if(A.renderPass!=="translucent")return;const Ie=fr.disabled,Me=A.colorModeForRenderPass();(se._unevaluatedLayout.hasValue("text-variable-anchor")||se._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(Je,ut,gt,St,Lt,Vt,Ht,Et,Kt){const ss=ut.transform,cs=qa(),As=Lt==="map",sn=Vt==="map";for(const pn of Je){const Ln=St.getTile(pn),Js=Ln.getBucket(gt);if(!Js||!Js.text||!Js.text.segments.get().length)continue;const on=i.ag(Js.textSizeData,ss.zoom),Hn=os(Ln,1,ut.transform.zoom),Ra=wn(pn.posMatrix,sn,As,ut.transform,Hn),ln=gt.layout.get("icon-text-fit")!=="none"&&Js.hasIconData();
2537if(on){const Nn=Math.pow(2,ss.zoom-Ln.tileID.overscaledZ),aa=ut.style.map.terrain?(er,Sr)=>ut.style.map.terrain.getElevation(pn,er,Sr):null,mi=cs.translatePosition(ss,Ln,Ht,Et);la(Js,As,sn,Kt,ss,Ra,pn.posMatrix,Nn,on,ln,cs,mi,pn.toUnwrapped(),aa)}}}(he,A,se,ee,se.layout.get("text-rotation-alignment"),se.layout.get("text-pitch-alignment"),se.paint.get("text-translate"),se.paint.get("text-translate-anchor"),_e),se.paint.get("icon-opacity").constantOr(1)!==0&&Rr(A,ee,se,he,!1,se.paint.get("icon-translate"),se.paint.get("icon-translate-anchor"),se.layout.get("icon-rotation-alignment"),se.layout.get("icon-pitch-alignment"),se.layout.get("icon-keep-upright"),Ie,Me),se.paint.get("text-opacity").constantOr(1)!==0&&Rr(A,ee,se,he,!0,se.paint.get("text-translate"),se.paint.get("text-translate-anchor"),se.layout.get("text-rotation-alignment"),se.layout.get("text-pitch-alignment"),se.layout.get("text-keep-upright"),Ie,Me),ee.map.showCollisionBoxes&&(qe(A,ee,se,he,!0),qe(A,ee,se,he,!1))})(r,g,S,E,this.style.placement.variableOffsets);break;case"circle":(function(A,ee,se,he){if(A.renderPass!=="translucent")return;const _e=se.paint.get("circle-opacity"),Ie=se.paint.get("circle-stroke-width"),Me=se.paint.get("circle-stroke-opacity"),Je=!se.layout.get("circle-sort-key").isConstant();if(_e.constantOr(1)===0&&(Ie.constantOr(1)===0||Me.constantOr(1)===0))return;const ut=A.context,gt=ut.gl,St=A.depthModeForSublayer(0,Ia.ReadOnly),Lt=fr.disabled,Vt=A.colorModeForRenderPass(),Ht=[];for(let Et=0;Et<he.length;Et++){const Kt=he[Et],ss=ee.getTile(Kt),cs=ss.getBucket(se);if(!cs)continue;const As=cs.programConfigurations.get(se.id),sn=A.useProgram("circle",As),pn=cs.layoutVertexBuffer,Ln=cs.indexBuffer,Js=A.style.map.terrain&&A.style.map.terrain.getTerrainData(Kt),on={programConfiguration:As,program:sn,layoutVertexBuffer:pn,indexBuffer:Ln,uniformValues:hl(A,Kt,ss,se),terrainData:Js};if(Je){const Hn=cs.segments.get();for(const Ra of Hn)Ht.push({segments:new i.a0([Ra]),sortKey:Ra.sortKey,state:on})}else Ht.push({segments:cs.segments,sortKey:0,state:on})}Je&&Ht.sort((Et,Kt)=>Et.sortKey-Kt.sortKey);for(const Et of Ht){const{programConfiguration:Kt,program:ss,layoutVertexBuffer:cs,indexBuffer:As,uniformValues:sn,terrainData:pn}=Et.state;ss.draw(ut,gt.TRIANGLES,St,Lt,Vt,Dr.disabled,sn,pn,se.id,cs,As,Et.segments,se.paint,A.transform.zoom,Kt)}})(r,g,S,E);break;case"heatmap":(function(A,ee,se,he){if(se.paint.get("heatmap-opacity")===0)return;const _e=A.context;if(A.style.map.terrain){for(const Ie of he){const Me=ee.getTile(Ie);ee.hasRenderableParent(Ie)||(A.renderPass==="offscreen"?Uo(A,Me,se,Ie):A.renderPass==="translucent"&&el(A,se,Ie))}_e.viewport.set([0,0,A.width,A.height])}else A.renderPass==="offscreen"?function(Ie,Me,Je,ut){const gt=Ie.context,St=gt.gl,Lt=fr.disabled,Vt=new li([St.ONE,St.ONE],i.aM.transparent,[!0,!0,!0,!0]);(function(Ht,Et,Kt){const ss=Ht.gl;Ht.activeTexture.set(ss.TEXTURE1),Ht.viewport.set([0,0,Et.width/4,Et.height/4]);let cs=Kt.heatmapFbos.get(i.aU);cs?(ss.bindTexture(ss.TEXTURE_2D,cs.colorAttachment.get()),Ht.bindFramebuffer.set(cs.framebuffer)):(cs=Oo(Ht,Et.width/4,Et.height/4),Kt.heatmapFbos.set(i.aU,cs))})(gt,Ie,Je),gt.clear({color:i.aM.transparent});for(let Ht=0;Ht<ut.length;Ht++){const Et=ut[Ht];if(Me.hasRenderableParent(Et))continue;const Kt=Me.getTile(Et),ss=Kt.getBucket(Je);if(!ss)continue;const cs=ss.programConfigurations.get(Je.id),As=Ie.useProgram("heatmap",cs),{zoom:sn}=Ie.transform;As.draw(gt,St.TRIANGLES,Ia.disabled,Lt,Vt,Dr.disabled,Gi(Et.posMatrix,Kt,sn,Je.paint.get("heatmap-intensity")),null,Je.id,ss.layoutVertexBuffer,ss.indexBuffer,ss.segments,Je.paint,Ie.transform.zoom,cs)}gt.viewport.set([0,0,Ie.width,Ie.height])}(A,ee,se,he):A.renderPass==="translucent"&&function(Ie,Me){const Je=Ie.context,ut=Je.gl;Je.setColorMode(Ie.colorModeForRenderPass());const gt=Me.heatmapFbos.get(i.aU);gt&&(Je.activeTexture.set(ut.TEXTURE0),ut.bindTexture(ut.TEXTURE_2D,gt.colorAttachment.get()),Je.activeTexture.set(ut.TEXTURE1),yo(Je,Me).bind(ut.LINEAR,ut.CLAMP_TO_EDGE),Ie.useProgram("heatmapTexture").draw(Je,ut.TRIANGLES,Ia.disabled,fr.disabled,Ie.colorModeForRenderPass(),Dr.disabled,fn(Ie,Me,0,1),null,Me.id,Ie.viewportBuffer,Ie.quadTriangleIndexBuffer,Ie.viewportSegments,Me.paint,Ie.transform.zoom))}(A,se)})(r,g,S,E);break;case"line":(function(A,ee,se,he){if(A.renderPass!=="translucent")return;const _e=se.paint.get("line-opacity"),Ie=se.paint.get("line-width");if(_e.constantOr(1)===0||Ie.constantOr(1)===0)return;const Me=A.depthModeForSublayer(0,Ia.ReadOnly),Je=A.colorModeForRenderPass(),ut=se.paint.get("line-dasharray"),gt=se.paint.get("line-pattern"),St=gt.constantOr(1),Lt=se.paint.get("line-gradient"),Vt=se.getCrossfadeParameters(),Ht=St?"linePattern":ut?"lineSDF":Lt?"lineGradient":"line",Et=A.context,Kt=Et.gl;let ss=!0;for(const cs of he){const As=ee.getTile(cs);if(St&&!As.patternsLoaded())continue;const sn=As.getBucket(se);if(!sn)continue;const pn=sn.programConfigurations.get(se.id),Ln=A.context.program.get(),Js=A.useProgram(Ht,pn),on=ss||Js.program!==Ln,Hn=A.style.map.terrain&&A.style.map.terrain.getTerrainData(cs),Ra=gt.constantOr(null);if(Ra&&As.imageAtlas){const aa=As.imageAtlas,mi=aa.patternPositions[Ra.to.toString()],er=aa.patternPositions[Ra.from.toString()];mi&&er&&pn.setConstantPatternPositions(mi,er)}const ln=Hn?cs:null,Nn=St?wl(A,As,se,Vt,ln):ut?Nl(A,As,se,ut,Vt,ln):Lt?Br(A,As,se,sn.lineClipsArray.length,ln):nr(A,As,se,ln);if(St)Et.activeTexture.set(Kt.TEXTURE0),As.imageAtlasTexture.bind(Kt.LINEAR,Kt.CLAMP_TO_EDGE),pn.updatePaintBuffers(Vt);else if(ut&&(on||A.lineAtlas.dirty))Et.activeTexture.set(Kt.TEXTURE0),A.lineAtlas.bind(Et);else if(Lt){const aa=sn.gradients[se.id];let mi=aa.texture;if(se.gradientVersion!==aa.version){let er=256;if(se.stepInterpolant){const Sr=ee.getSource().maxzoom,Pi=cs.canonical.z===Sr?Math.ceil(1<<A.transform.maxZoom-cs.canonical.z):1;er=i.ac(i.aV(sn.maxLineLength/i.X*1024*Pi),256,Et.maxTextureSize)}aa.gradient=i.aW({expression:se.gradientExpression(),evaluationKey:"lineProgress",resolution:er,image:aa.gradient||void 0,clips:sn.lineClipsArray}),aa.texture?aa.texture.update(aa.gradient):aa.texture=new Q(Et,aa.gradient,Kt.RGBA),aa.version=se.gradientVersion,mi=aa.texture}Et.activeTexture.set(Kt.TEXTURE0),mi.bind(se.stepInterpolant?Kt.NEAREST:Kt.LINEAR,Kt.CLAMP_TO_EDGE)}Js.draw(Et,Kt.TRIANGLES,Me,A.stencilModeForClipping(cs),Je,Dr.disabled,Nn,Hn,se.id,sn.layoutVertexBuffer,sn.indexBuffer,sn.segments,se.paint,A.transform.zoom,pn,sn.layoutVertexBuffer2),ss=!1}})(r,g,S,E);break;case"fill":(function(A,ee,se,he){const _e=se.paint.get("fill-color"),Ie=se.paint.get("fill-opacity");if(Ie.constantOr(1)===0)return;const Me=A.colorModeForRenderPass(),Je=se.paint.get("fill-pattern"),ut=A.opaquePassEnabledForLayer()&&!Je.constantOr(1)&&_e.constantOr(i.aM.transparent).a===1&&Ie.constantOr(0)===1?"opaque":"translucent";if(A.renderPass===ut){const gt=A.depthModeForSublayer(1,A.renderPass==="opaque"?Ia.ReadWrite:Ia.ReadOnly);ci(A,ee,se,he,gt,Me,!1)}if(A.renderPass==="translucent"&&se.paint.get("fill-antialias")){const gt=A.depthModeForSublayer(se.getPaintProperty("fill-outline-color")?2:0,Ia.ReadOnly);ci(A,ee,se,he,gt,Me,!0)}})(r,g,S,E);break;case"fill-extrusion":(function(A,ee,se,he){const _e=se.paint.get("fill-extrusion-opacity");if(_e!==0&&A.renderPass==="translucent"){const Ie=new Ia(A.context.gl.LEQUAL,Ia.ReadWrite,A.depthRangeFor3D);if(_e!==1||se.paint.get("fill-extrusion-pattern").constantOr(1))Eo(A,ee,se,he,Ie,fr.disabled,li.disabled),Eo(A,ee,se,he,Ie,A.stencilModeFor3D(),A.colorModeForRenderPass());else{const Me=A.colorModeForRenderPass();Eo(A,ee,se,he,Ie,fr.disabled,Me)}}})(r,g,S,E);break;case"hillshade":(function(A,ee,se,he){if(A.renderPass!=="offscreen"&&A.renderPass!=="translucent")return;const _e=A.context,Ie=A.depthModeForSublayer(0,Ia.ReadOnly),Me=A.colorModeForRenderPass(),[Je,ut]=A.renderPass==="translucent"?A.stencilConfigForOverlap(he):[{},he];for(const gt of ut){const St=ee.getTile(gt);St.needsHillshadePrepare!==void 0&&St.needsHillshadePrepare&&A.renderPass==="offscreen"?xl(A,St,se,Ie,fr.disabled,Me):A.renderPass==="translucent"&&tl(A,gt,St,se,Ie,Je[gt.overscaledZ],Me)}_e.viewport.set([0,0,A.width,A.height])})(r,g,S,E);break;case"raster":(function(A,ee,se,he){if(A.renderPass!=="translucent"||se.paint.get("raster-opacity")===0||!he.length)return;const _e=A.context,Ie=_e.gl,Me=ee.getSource(),Je=A.useProgram("raster"),ut=A.colorModeForRenderPass(),[gt,St]=Me instanceof Rt?[{},he]:A.stencilConfigForOverlap(he),Lt=St[St.length-1].overscaledZ,Vt=!A.options.moving;for(const Ht of St){const Et=A.depthModeForSublayer(Ht.overscaledZ-Lt,se.paint.get("raster-opacity")===1?Ia.ReadWrite:Ia.ReadOnly,Ie.LESS),Kt=ee.getTile(Ht);Kt.registerFadeDuration(se.paint.get("raster-fade-duration"));const ss=ee.findLoadedParent(Ht,0),cs=ee.findLoadedSibling(Ht),As=Bo(Kt,ss||cs||null,ee,se,A.transform,A.style.map.terrain);let sn,pn;const Ln=se.paint.get("raster-resampling")==="nearest"?Ie.NEAREST:Ie.LINEAR;_e.activeTexture.set(Ie.TEXTURE0),Kt.texture.bind(Ln,Ie.CLAMP_TO_EDGE,Ie.LINEAR_MIPMAP_NEAREST),_e.activeTexture.set(Ie.TEXTURE1),ss?(ss.texture.bind(Ln,Ie.CLAMP_TO_EDGE,Ie.LINEAR_MIPMAP_NEAREST),sn=Math.pow(2,ss.tileID.overscaledZ-Kt.tileID.overscaledZ
2537),pn=[Kt.tileID.canonical.x*sn%1,Kt.tileID.canonical.y*sn%1]):Kt.texture.bind(Ln,Ie.CLAMP_TO_EDGE,Ie.LINEAR_MIPMAP_NEAREST),Kt.texture.useMipmap&&_e.extTextureFilterAnisotropic&&A.transform.pitch>20&&Ie.texParameterf(Ie.TEXTURE_2D,_e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,_e.extTextureFilterAnisotropicMax);const Js=A.style.map.terrain&&A.style.map.terrain.getTerrainData(Ht),on=Js?Ht:null,Hn=on?on.posMatrix:A.transform.calculatePosMatrix(Ht.toUnwrapped(),Vt),Ra=ml(Hn,pn||[0,0],sn||1,As,se);Me instanceof Rt?Je.draw(_e,Ie.TRIANGLES,Et,fr.disabled,ut,Dr.disabled,Ra,Js,se.id,Me.boundsBuffer,A.quadTriangleIndexBuffer,Me.boundsSegments):Je.draw(_e,Ie.TRIANGLES,Et,gt[Ht.overscaledZ],ut,Dr.disabled,Ra,Js,se.id,A.rasterBoundsBuffer,A.quadTriangleIndexBuffer,A.rasterBoundsSegments)}})(r,g,S,E);break;case"background":(function(A,ee,se,he){const _e=se.paint.get("background-color"),Ie=se.paint.get("background-opacity");if(Ie===0)return;const Me=A.context,Je=Me.gl,ut=A.transform,gt=ut.tileSize,St=se.paint.get("background-pattern");if(A.isPatternMissing(St))return;const Lt=!St&&_e.a===1&&Ie===1&&A.opaquePassEnabledForLayer()?"opaque":"translucent";if(A.renderPass!==Lt)return;const Vt=fr.disabled,Ht=A.depthModeForSublayer(0,Lt==="opaque"?Ia.ReadWrite:Ia.ReadOnly),Et=A.colorModeForRenderPass(),Kt=A.useProgram(St?"backgroundPattern":"background"),ss=he||ut.coveringTiles({tileSize:gt,terrain:A.style.map.terrain});St&&(Me.activeTexture.set(Je.TEXTURE0),A.imageManager.bind(A.context));const cs=se.getCrossfadeParameters();for(const As of ss){const sn=he?As.posMatrix:A.transform.calculatePosMatrix(As.toUnwrapped()),pn=St?Pa(sn,Ie,A,St,{tileID:As,tileSize:gt},cs):oa(sn,Ie,_e),Ln=A.style.map.terrain&&A.style.map.terrain.getTerrainData(As);Kt.draw(Me,Je.TRIANGLES,Ht,Vt,Et,Dr.disabled,pn,Ln,se.id,A.tileExtentBuffer,A.quadTriangleIndexBuffer,A.tileExtentSegments)}})(r,0,S,E);break;case"custom":(function(A,ee,se){const he=A.context,_e=se.implementation;if(A.renderPass==="offscreen"){const Ie=_e.prerender;Ie&&(A.setCustomLayerDefaults(),he.setColorMode(A.colorModeForRenderPass()),Ie.call(_e,he.gl,A.transform.customLayerMatrix()),he.setDirty(),A.setBaseState())}else if(A.renderPass==="translucent"){A.setCustomLayerDefaults(),he.setColorMode(A.colorModeForRenderPass()),he.setStencilMode(fr.disabled);const Ie=_e.renderingMode==="3d"?new Ia(A.context.gl.LEQUAL,Ia.ReadWrite,A.depthRangeFor3D):A.depthModeForSublayer(0,Ia.ReadOnly);he.setDepthMode(Ie),_e.render(he.gl,A.transform.customLayerMatrix(),{farZ:A.transform.farZ,nearZ:A.transform.nearZ,fov:A.transform._fov,modelViewProjectionMatrix:A.transform.modelViewProjectionMatrix,projectionMatrix:A.transform.projectionMatrix}),he.setDirty(),A.setBaseState(),he.bindFramebuffer.set(null)}})(r,0,S)}}translatePosMatrix(r,g,S,E,A){if(!S[0]&&!S[1])return r;const ee=A?E==="map"?this.transform.angle:0:E==="viewport"?-this.transform.angle:0;if(ee){const _e=Math.sin(ee),Ie=Math.cos(ee);S=[S[0]*Ie-S[1]*_e,S[0]*_e+S[1]*Ie]}const se=[A?S[0]:os(g,S[0],this.transform.zoom),A?S[1]:os(g,S[1],this.transform.zoom),0],he=new Float32Array(16);return i.J(he,r,se),he}saveTileTexture(r){const g=this._tileTextures[r.size[0]];g?g.push(r):this._tileTextures[r.size[0]]=[r]}getTileTexture(r){const g=this._tileTextures[r];return g&&g.length>0?g.pop():null}isPatternMissing(r){if(!r)return!1;if(!r.from||!r.to)return!0;const g=this.imageManager.getPattern(r.from.toString()),S=this.imageManager.getPattern(r.to.toString());return!g||!S}useProgram(r,g){this.cache=this.cache||{};const S=r+(g?g.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[S]||(this.cache[S]=new In(this.context,Ko[r],g,mr[r],this._showOverdrawInspector,this.style.map.terrain)),this.cache[S]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const r=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(r.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Q(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:r,drawingBufferHeight:g}=this.context.gl;return this.width!==r||this.height!==g}}class re{constructor(r,g){this.points=r,this.planes=g}static fromInvProjectionMatrix(r,g,S){const E=Math.pow(2,S),A=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(se=>{const he=1/(se=i.af([],se,r))[3]/g*E;return i.b1(se,se,[he,he,1/se[3],he])}),ee=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(se=>{const he=function(Je,ut){var gt=ut[0],St=ut[1],Lt=ut[2],Vt=gt*gt+St*St+Lt*Lt;return Vt>0&&(Vt=1/Math.sqrt(Vt)),Je[0]=ut[0]*Vt,Je[1]=ut[1]*Vt,Je[2]=ut[2]*Vt,Je}([],function(Je,ut,gt){var St=ut[0],Lt=ut[1],Vt=ut[2],Ht=gt[0],Et=gt[1],Kt=gt[2];return Je[0]=Lt*Kt-Vt*Et,Je[1]=Vt*Ht-St*Kt,Je[2]=St*Et-Lt*Ht,Je}([],H([],A[se[0]],A[se[1]]),H([],A[se[2]],A[se[1]]))),_e=-((Ie=he)[0]*(Me=A[se[1]])[0]+Ie[1]*Me[1]+Ie[2]*Me[2]);var Ie,Me;return he.concat(_e)});return new re(A,ee)}}class xe{constructor(r,g){this.min=r,this.max=g,this.center=function(S,E,A){return S[0]=.5*E[0],S[1]=.5*E[1],S[2]=.5*E[2],S}([],function(S,E,A){return S[0]=E[0]+A[0],S[1]=E[1]+A[1],S[2]=E[2]+A[2],S}([],this.min,this.max))}quadrant(r){const g=[r%2==0,r<2],S=te(this.min),E=te(this.max);for(let A=0;A<g.length;A++)S[A]=g[A]?this.min[A]:this.center[A],E[A]=g[A]?this.center[A]:this.max[A];return E[2]=this.max[2],new xe(S,E)}distanceX(r){return Math.max(Math.min(this.max[0],r[0]),this.min[0])-r[0]}distanceY(r){return Math.max(Math.min(this.max[1],r[1]),this.min[1])-r[1]}intersects(r){const g=[[this.min[0],this.min[1],this.min[2],1],[this.max[0],this.min[1],this.min[2],1],[this.max[0],this.max[1],this.min[2],1],[this.min[0],this.max[1],this.min[2],1],[this.min[0],this.min[1],this.max[2],
vendor: 6,329 bytes, line 2537
25371],[this.max[0],this.min[1],this.max[2],1],[this.max[0],this.max[1],this.max[2],1],[this.min[0],this.max[1],this.max[2],1]];let S=!0;for(let E=0;E<r.planes.length;E++){const A=r.planes[E];let ee=0;for(let se=0;se<g.length;se++)i.b2(A,g[se])>=0&&ee++;if(ee===0)return 0;ee!==g.length&&(S=!1)}if(S)return 2;for(let E=0;E<3;E++){let A=Number.MAX_VALUE,ee=-Number.MAX_VALUE;for(let se=0;se<r.points.length;se++){const he=r.points[se][E]-this.min[E];A=Math.min(A,he),ee=Math.max(ee,he)}if(ee<0||A>this.max[E]-this.min[E])return 0}return 1}}class Ae{constructor(r=0,g=0,S=0,E=0){if(isNaN(r)||r<0||isNaN(g)||g<0||isNaN(S)||S<0||isNaN(E)||E<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=r,this.bottom=g,this.left=S,this.right=E}interpolate(r,g,S){return g.top!=null&&r.top!=null&&(this.top=i.y.number(r.top,g.top,S)),g.bottom!=null&&r.bottom!=null&&(this.bottom=i.y.number(r.bottom,g.bottom,S)),g.left!=null&&r.left!=null&&(this.left=i.y.number(r.left,g.left,S)),g.right!=null&&r.right!=null&&(this.right=i.y.number(r.right,g.right,S)),this}getCenter(r,g){const S=i.ac((this.left+r-this.right)/2,0,r),E=i.ac((this.top+g-this.bottom)/2,0,g);return new i.P(S,E)}equals(r){return this.top===r.top&&this.bottom===r.bottom&&this.left===r.left&&this.right===r.right}clone(){return new Ae(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const tt=85.051129;class Nt{constructor(r,g,S,E,A){this.tileSize=512,this._renderWorldCopies=A===void 0||!!A,this._minZoom=r||0,this._maxZoom=g||22,this._minPitch=S??0,this._maxPitch=E??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new i.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Ae,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const r=new Nt(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return r.apply(this),r}apply(r){this.tileSize=r.tileSize,this.latRange=r.latRange,this.lngRange=r.lngRange,this.width=r.width,this.height=r.height,this._center=r._center,this._elevation=r._elevation,this.minElevationForCurrentTile=r.minElevationForCurrentTile,this.zoom=r.zoom,this.angle=r.angle,this._fov=r._fov,this._pitch=r._pitch,this._unmodified=r._unmodified,this._edgeInsets=r._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(r){this._minZoom!==r&&(this._minZoom=r,this.zoom=Math.max(this.zoom,r))}get maxZoom(){return this._maxZoom}set maxZoom(r){this._maxZoom!==r&&(this._maxZoom=r,this.zoom=Math.min(this.zoom,r))}get minPitch(){return this._minPitch}set minPitch(r){this._minPitch!==r&&(this._minPitch=r,this.pitch=Math.max(this.pitch,r))}get maxPitch(){return this._maxPitch}set maxPitch(r){this._maxPitch!==r&&(this._maxPitch=r,this.pitch=Math.min(this.pitch,r))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(r){r===void 0?r=!0:r===null&&(r=!1),this._renderWorldCopies=r}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new i.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(r){const g=-i.b3(r,-180,180)*Math.PI/180;this.angle!==g&&(this._unmodified=!1,this.angle=g,this._calcMatrices(),this.rotationMatrix=function(){var S=new i.A(4);return i.A!=Float32Array&&(S[1]=0,S[2]=0),S[0]=1,S[3]=1,S}(),function(S,E,A){var ee=E[0],se=E[1],he=E[2],_e=E[3],Ie=Math.sin(A),Me=Math.cos(A);S[0]=ee*Me+he*Ie,S[1]=se*Me+_e*Ie,S[2]=ee*-Ie+he*Me,S[3]=se*-Ie+_e*Me}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(r){const g=i.ac(r,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==g&&(this._unmodified=!1,this._pitch=g,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(r){r=Math.max(.01,Math.min(60,r)),this._fov!==r&&(this._unmodified=!1,this._fov=r/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(r){const g=Math.min(Math.max(r,this.minZoom),this.maxZoom);this._zoom!==g&&(this._unmodified=!1,this._zoom=g,this.tileZoom=Math.max(0,Math.floor(g)),this.scale=this.zoomScale(g),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(r){r.lat===this._center.lat&&r.lng===this._center.lng||(this._unmodified=!1,this._center=r,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(r){r!==this._elevation&&(this._elevation=r,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(r){this._edgeInsets.equals(r)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,r,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(r){return this._edgeInsets.equals(r)}interpolatePadding(r,g,S){this._unmodified=!1,this._edgeInsets.interpolate(r,g,S),this._constrain(),this._calcMatrices()}coveringZoomLevel(r){const g=(r.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/r.tileSize));return Math.max(0,g)}getVisibleUnwrappedCoordinates(r){const g=[new i.b4(0,r)];if(this._renderWorldCopies){const S=this.pointCoordinate(new i.P(0,0)),E=this.pointCoordinate(new i.P(this.width,0)),A=this.pointCoordinate(new i.P(this.width,this.height)),ee=this.pointCoordinate(new i.P(0,this.height)),se=Math.floor(Math.min(S.x,E.x,A.x,ee.x)),he=Math.floor(Math.max(S.x,E.x,A.x,ee.x)),_e=1;for(let Ie=se-_e;Ie<=he+_e;Ie++)Ie!==0&&g.push(new i.b4(Ie,r))}return g}coveringTiles(r){var g,S;let E=this.coveringZoomLevel(r);const A=E;if(r.minzoom!==void 0&&E<r.minzoom)return[];r.maxzoom!==void 0&&E>r.maxzoom&&(E=r.maxzoom);const ee=this.pointCoordinate(this.getCameraPoint()),se=i.Z.fromLngLat(this.center),he=Math.pow(2,E),_e=[he*ee.x,he*ee.y,0],Ie=[he*se.x,he*se.y,0],Me=re.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,E);let Je=r.minzoom||0;!r.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(Je=E);const ut=r.terrain?2/Math.min(this.tileSize,r.tileSize)*this.tileSize:3,gt=Et=>({aabb:new xe([Et*he,0,0],[(Et+1)*he,he,0]),zoom:0,x:0,y:0,wrap:Et,fullyVisible:!1}
2537),St=[],Lt=[],Vt=E,Ht=r.reparseOverscaled?A:E;if(this._renderWorldCopies)for(let Et=1;Et<=3;Et++)St.push(gt(-Et)),St.push(gt(Et));for(St.push(gt(0));St.length>0;){const Et=St.pop(),Kt=Et.x,ss=Et.y;let cs=Et.fullyVisible;if(!cs){const Js=Et.aabb.intersects(Me);if(Js===0)continue;cs=Js===2}const As=r.terrain?_e:Ie,sn=Et.aabb.distanceX(As),pn=Et.aabb.distanceY(As),Ln=Math.max(Math.abs(sn),Math.abs(pn));if(Et.zoom===Vt||Ln>ut+(1<<Vt-Et.zoom)-2&&Et.zoom>=Je){const Js=Vt-Et.zoom,on=_e[0]-.5-(Kt<<Js),Hn=_e[1]-.5-(ss<<Js);Lt.push({tileID:new i.S(Et.zoom===Vt?Ht:Et.zoom,Et.wrap,Et.zoom,Kt,ss),distanceSq:O([Ie[0]-.5-Kt,Ie[1]-.5-ss]),tileDistanceToCamera:Math.sqrt(on*on+Hn*Hn)})}else for(let Js=0;Js<4;Js++){const on=(Kt<<1)+Js%2,Hn=(ss<<1)+(Js>>1),Ra=Et.zoom+1;let ln=Et.aabb.quadrant(Js);if(r.terrain){const Nn=new i.S(Ra,Et.wrap,Ra,on,Hn),aa=r.terrain.getMinMaxElevation(Nn),mi=(g=aa.minElevation)!==null&&g!==void 0?g:this.elevation,er=(S=aa.maxElevation)!==null&&S!==void 0?S:this.elevation;ln=new xe([ln.min[0],ln.min[1],mi],[ln.max[0],ln.max[1],er])}St.push({aabb:ln,zoom:Ra,x:on,y:Hn,wrap:Et.wrap,fullyVisible:cs})}}return Lt.sort((Et,Kt)=>Et.distanceSq-Kt.distanceSq).map(Et=>Et.tileID)}resize(r,g){this.width=r,this.height=g,this.pixelsToGLUnits=[2/r,-2/g],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(r){return Math.pow(2,r)}scaleZoom(r){return Math.log(r)/Math.LN2}project(r){const g=i.ac(r.lat,-85.051129,tt);return new i.P(i.O(r.lng)*this.worldSize,i.Q(g)*this.worldSize)}unproject(r){return new i.Z(r.x/this.worldSize,r.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(r){const g=this.elevation,S=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,E=this.pointLocation(this.centerPoint,r),A=r.getElevationForLngLatZoom(E,this.tileZoom);if(!(this.elevation-A))return;const ee=S+g-A,se=Math.cos(this._pitch)*this.cameraToCenterDistance/ee/i.b5(1,E.lat),he=this.scaleZoom(se/this.tileSize);this._elevation=A,this._center=E,this.zoom=he}setLocationAtPoint(r,g){const S=this.pointCoordinate(g),E=this.pointCoordinate(this.centerPoint),A=this.locationCoordinate(r),ee=new i.Z(A.x-(S.x-E.x),A.y-(S.y-E.y));this.center=this.coordinateLocation(ee),this._renderWorldCopies&&
vendor: 7,448 bytes, line 2537
2537(this.center=this.center.wrap())}locationPoint(r,g){return g?this.coordinatePoint(this.locationCoordinate(r),g.getElevationForLngLatZoom(r,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(r))}pointLocation(r,g){return this.coordinateLocation(this.pointCoordinate(r,g))}locationCoordinate(r){return i.Z.fromLngLat(r)}coordinateLocation(r){return r&&r.toLngLat()}pointCoordinate(r,g){if(g){const Je=g.pointCoordinate(r);if(Je!=null)return Je}const S=[r.x,r.y,0,1],E=[r.x,r.y,1,1];i.af(S,S,this.pixelMatrixInverse),i.af(E,E,this.pixelMatrixInverse);const A=S[3],ee=E[3],se=S[1]/A,he=E[1]/ee,_e=S[2]/A,Ie=E[2]/ee,Me=_e===Ie?0:(0-_e)/(Ie-_e);return new i.Z(i.y.number(S[0]/A,E[0]/ee,Me)/this.worldSize,i.y.number(se,he,Me)/this.worldSize)}coordinatePoint(r,g=0,S=this.pixelMatrix){const E=[r.x*this.worldSize,r.y*this.worldSize,g,1];return i.af(E,E,S),new i.P(E[0]/E[3],E[1]/E[3])}getBounds(){const r=Math.max(0,this.height/2-this.getHorizon());return new He().extend(this.pointLocation(new i.P(0,r))).extend(this.pointLocation(new i.P(this.width,r))).extend(this.pointLocation(new i.P(this.width,this.height))).extend(this.pointLocation(new i.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new He([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(r){r?(this.lngRange=[r.getWest(),r.getEast()],this.latRange=[r.getSouth(),r.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,tt])}calculateTileMatrix(r){const g=r.canonical,S=this.worldSize/this.zoomScale(g.z),E=g.x+Math.pow(2,g.z)*r.wrap,A=i.an(new Float64Array(16));return i.J(A,A,[E*S,g.y*S,0]),i.K(A,A,[S/i.X,S/i.X,1]),A}calculatePosMatrix(r,g=!1){const S=r.key,E=g?this._alignedPosMatrixCache:this._posMatrixCache;if(E[S])return E[S];const A=this.calculateTileMatrix(r);return i.L(A,g?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,A),E[S]=new Float32Array(A),E[S]}calculateFogMatrix(r){const g=r.key,S=this._fogMatrixCache;if(S[g])return S[g];const E=this.calculateTileMatrix(r);return i.L(E,this.fogMatrix,E),S[g]=new Float32Array(E),S[g]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(r,g){g=i.ac(+g,this.minZoom,this.maxZoom);const S={center:new i.N(r.lng,r.lat),zoom:g};let E=this.lngRange;if(!this._renderWorldCopies&&E===null){const Et=179.9999999999;E=[-Et,Et]}const A=this.tileSize*this.zoomScale(S.zoom);let ee=0,se=A,he=0,_e=A,Ie=0,Me=0;const{x:Je,y:ut}=this.size;if(this.latRange){const Et=this.latRange;ee=i.Q(Et[1])*A,se=i.Q(Et[0])*A,se-ee<ut&&(Ie=ut/(se-ee))}E&&(he=i.b3(i.O(E[0])*A,0,A),_e=i.b3(i.O(E[1])*A,0,A),_e<he&&(_e+=A),_e-he<Je&&(Me=Je/(_e-he)));const{x:gt,y:St}=this.project.call({worldSize:A},r);let Lt,Vt;const Ht=Math.max(Me||0,Ie||0);if(Ht){const Et=new i.P(Me?(_e+he)/2:gt,Ie?(se+ee)/2:St);return S.center=this.unproject.call({worldSize:A},Et).wrap(),S.zoom+=this.scaleZoom(Ht),S}if(this.latRange){const Et=ut/2;St-Et<ee&&(Vt=ee+Et),St+Et>se&&(Vt=se-Et)}if(E){const Et=(he+_e)/2;let Kt=gt;this._renderWorldCopies&&(Kt=i.b3(gt,Et-A/2,Et+A/2));const ss=Je/2;Kt-ss<he&&(Lt=he+ss),Kt+ss>_e&&(Lt=_e-ss)}if(Lt!==void 0||Vt!==void 0){const Et=new i.P(Lt??gt,Vt??St);S.center=this.unproject.call({worldSize:A},Et).wrap()}return S}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const r=this._unmodified,{center:g,zoom:S}=this.getConstrained(this.center,this.zoom);this.center=g,this.zoom=S,this._unmodified=r,this._constraining=!1}_calcMatrices(){if(!this.height)return;const r=this.centerOffset,g=this.point.x,S=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=i.b5(1,this.center.lat)*this.worldSize;let E=i.an(new Float64Array(16));i.K(E,E,[this.width/2,-this.height/2,1]),i.J(E,E,[1,-1,0]),this.labelPlaneMatrix=E,E=i.an(new Float64Array(16)),i.K(E,E,[1,-1,1]),i.J(E,E,[-1,-1,0]),i.K(E,E,[2/this.width,2/this.height,1]),this.glCoordMatrix=E;const A=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),ee=Math.min(this.elevation,this.minElevationForCurrentTile),se=A-ee*this._pixelPerMeter/Math.cos(this._pitch),he=ee<0?se:A,_e=Math.PI/2+this._pitch,Ie=this._fov*(.5+r.y/this.height),Me=Math.sin(Ie)*he/Math.sin(i.ac(Math.PI-_e-Ie,.01,Math.PI-.01)),Je=this.getHorizon(),ut=2*Math.atan(Je/this.cameraToCenterDistance)*(.5+r.y/(2*Je)),gt=Math.sin(ut)*he/Math.sin(i.ac(Math.PI-_e-ut,.01,Math.PI-.01)),St=Math.min(Me,gt);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*St+he),this.nearZ=this.height/50,E=new Float64Array(16),i.b6(E,this._fov,this.width/this.height,this.nearZ,this.farZ),E[8]=2*-r.x/this.width,E[9]=2*r.y/this.height,this.projectionMatrix=i.ae(E),i.K(E,E,[1,-1,1]),i.J(E,E,[0,0,-this.cameraToCenterDistance]),i.b7(E,E,this._pitch),i.ad(E,E,this.angle),i.J(E,E,[-g,-S,0]),this.mercatorMatrix=i.K([],E,[this.worldSize,this.worldSize,this.worldSize]),i.K(E,E,[1,1,this._pixelPerMeter]),this.pixelMatrix=i.L(new Float64Array(16),this.labelPlaneMatrix,E),i.J(E,E,[0,0,-this.elevation]),this.modelViewProjectionMatrix=E,this.invModelViewProjectionMatrix=i.as([],E),this.fogMatrix=new Float64Array(16),i.b6(this.fogMatrix,this._fov,this.width/this.height,A,this.farZ),this.fogMatrix[8]=2*-r.x/this.width,this.fogMatrix[9]=2*r.y/this.height,i.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),i.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),i.b7(this.fogMatrix,this.fogMatrix,this._pitch),i.ad(this.fogMatrix,this.fogMatrix,this.angle),i.J(this.fogMatrix,this.fogMatrix,[-g,-S,0]),i.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),i.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=i.L(new Float64Array(16),this.labelPlaneMatrix,E);const Lt=this.width%2/2,Vt=this.height%2/2,Ht=Math.cos(this.angle),Et=Math.sin(this.angle),Kt=g-Math.round(g)+Ht*Lt+Et*Vt,ss=S-Math.round(S)+Ht*Vt+Et*Lt,cs=new Float64Array(E);if(i.J(cs,cs,[Kt>.5?Kt-1:Kt,ss>.5?ss-1:ss,0]),this.alignedModelViewProjectionMatrix=cs,E=i.as(new Float64Array(16),this.pixelMatrix),!E)throw new Error("failed to invert matrix");this.pixelMatrixInverse=E,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const r=this.pointCoordinate(new i.P(0,0)),g=[r.x*this.worldSize,r.y*this.worldSize,0,1];return i.af(g,g,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const r=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.P(0,r))}getCameraQueryGeometry(r){const g=this.getCameraPoint();if(r.length===1)return[r[0],g];{let S=g.x,E=g.y,A=g.x,ee=g.y;for(const se of r)S=Math.min(S,se.x),E=Math.min(E,se.y),A=Math.max(A,se.x),ee=Math.max(ee,se.y);return[new i.P(S,E),new i.P(A,E),new i.P(A,ee),new i.P(S,ee),new i.P(S,E)]}}lngLatToCameraDepth(r,g){const S=this.locationCoordinate(r),E=[S.x*this.worldSize,S.y*this.worldSize,g,1];return i.af(E,E,this.modelViewProjectionMatrix),E[2]/E[3]}}function Ut(R,r){let g,S=!1,E=null,A=null;const ee=()=>{E=null,S&&(R.apply(A,g),E=setTimeout(ee,r),S=!1)};return(...se)=>(S=!0,A=this,g=se,E||ee(),E)}class xs{constructor(r){this._getCurrentHash=()=>{const g=window.location.hash.replace("#","");if(this._hashName){let S;return g.split("&").map(E=>
vendor: 13,291 bytes, line 2537
2537E.split("=")).forEach(E=>{E[0]===this._hashName&&(S=E)}),(S&&S[1]||"").split("/")}return g.split("/")},this._onHashChange=()=>{const g=this._getCurrentHash();if(g.length>=3&&!g.some(S=>isNaN(S))){const S=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(g[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+g[2],+g[1]],zoom:+g[0],bearing:S,pitch:+(g[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const g=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,g)},this._removeHash=()=>{const g=this._getCurrentHash();if(g.length===0)return;const S=g.join("/");let E=S;E.split("&").length>0&&(E=E.split("&")[0]),this._hashName&&(E=`${this._hashName}=${S}`);let A=window.location.hash.replace(E,"");A.startsWith("#&")?A=A.slice(0,1)+A.slice(2):A==="#"&&(A="");let ee=window.location.href.replace(/(#.+)?$/,A);ee=ee.replace("&&","&"),window.history.replaceState(window.history.state,null,ee)},this._updateHash=Ut(this._updateHashUnthrottled,300),this._hashName=r&&encodeURIComponent(r)}addTo(r){return this._map=r,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(r){const g=this._map.getCenter(),S=Math.round(100*this._map.getZoom())/100,E=Math.ceil((S*Math.LN2+Math.log(512/360/.5))/Math.LN10),A=Math.pow(10,E),ee=Math.round(g.lng*A)/A,se=Math.round(g.lat*A)/A,he=this._map.getBearing(),_e=this._map.getPitch();let Ie="";if(Ie+=r?`/${ee}/${se}/${S}`:`${S}/${se}/${ee}`,(he||_e)&&(Ie+="/"+Math.round(10*he)/10),_e&&(Ie+=`/${Math.round(_e)}`),this._hashName){const Me=this._hashName;let Je=!1;const ut=window.location.hash.slice(1).split("&").map(gt=>{const St=gt.split("=")[0];return St===Me?(Je=!0,`${St}=${Ie}`):gt}).filter(gt=>gt);return Je||ut.push(`${Me}=${Ie}`),`#${ut.join("&")}`}return`#${Ie}`}}const $s={linearity:.3,easing:i.b8(0,0,.3,1)},bn=i.e({deceleration:2500,maxSpeed:1400},$s),da=i.e({deceleration:20,maxSpeed:1400},$s),wa=i.e({deceleration:1e3,maxSpeed:360},$s),Lr=i.e({deceleration:1e3,maxSpeed:90},$s);class ur{constructor(r){this._map=r,this.clear()}clear(){this._inertiaBuffer=[]}record(r){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:x.now(),settings:r})}_drainInertiaBuffer(){const r=this._inertiaBuffer,g=x.now();for(;r.length>0&&g-r[0].time>160;)r.shift()}_onMoveEnd(r){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const g={zoom:0,bearing:0,pitch:0,pan:new i.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:A}of this._inertiaBuffer)g.zoom+=A.zoomDelta||0,g.bearing+=A.bearingDelta||0,g.pitch+=A.pitchDelta||0,A.panDelta&&g.pan._add(A.panDelta),A.around&&(g.around=A.around),A.pinchAround&&(g.pinchAround=A.pinchAround);const S=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,E={};if(g.pan.mag()){const A=Ei(g.pan.mag(),S,i.e({},bn,r||{}));E.offset=g.pan.mult(A.amount/g.pan.mag()),E.center=this._map.transform.center,si(E,A)}if(g.zoom){const A=Ei(g.zoom,S,da);E.zoom=this._map.transform.zoom+A.amount,si(E,A)}if(g.bearing){const A=Ei(g.bearing,S,wa);E.bearing=this._map.transform.bearing+i.ac(A.amount,-179,179),si(E,A)}if(g.pitch){const A=Ei(g.pitch,S,Lr);E.pitch=this._map.transform.pitch+A.amount,si(E,A)}if(E.zoom||E.bearing){const A=g.pinchAround===void 0?g.around:g.pinchAround;E.around=A?this._map.unproject(A):this._map.getCenter()}return this.clear(),i.e(E,{noMoveStart:!0})}}function si(R,r){(!R.duration||R.duration<r.duration)&&(R.duration=r.duration,R.easing=r.easing)}function Ei(R,r,g){const{maxSpeed:S,linearity:E,deceleration:A}=g,ee=i.ac(R*E/(r/1e3),-S,S),se=Math.abs(ee)/(A*E);return{easing:g.easing,duration:1e3*se,amount:ee*(se/2)}}class hr extends i.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,g,S,E={}){const A=v.mousePos(g.getCanvas(),S),ee=g.unproject(A);super(r,i.e({point:A,lngLat:ee,originalEvent:S},E)),this._defaultPrevented=!1,this.target=g}}class mo extends i.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,g,S){const E=r==="touchend"?S.changedTouches:S.touches,A=v.touchPos(g.getCanvasContainer(),E),ee=A.map(he=>g.unproject(he)),se=A.reduce((he,_e,Ie,Me)=>he.add(_e.div(Me.length)),new i.P(0,0));super(r,{points:A,point:se,lngLats:ee,lngLat:g.unproject(se),originalEvent:S}),this._defaultPrevented=!1}}class Ud extends i.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,g,S){super(r,{originalEvent:S}),this._defaultPrevented=!1}}class mc{constructor(r,g){this._map=r,this._clickTolerance=g.clickTolerance}reset(){delete this._mousedownPos}wheel(r){return this._firePreventable(new Ud(r.type,this._map,r))}mousedown(r,g){return this._mousedownPos=g,this._firePreventable(new hr(r.type,this._map,r))}mouseup(r){this._map.fire(new hr(r.type,this._map,r))}click(r,g){this._mousedownPos&&this._mousedownPos.dist(g)>=this._clickTolerance||this._map.fire(new hr(r.type,this._map,r))}dblclick(r){return this._firePreventable(new hr(r.type,this._map,r))}mouseover(r){this._map.fire(new hr(r.type,this._map,r))}mouseout(r){this._map.fire(new hr(r.type,this._map,r))}touchstart(r){return this._firePreventable(new mo(r.type,this._map,r))}touchmove(r){this._map.fire(new mo(r.type,this._map,r))}touchend(r){this._map.fire(new mo(r.type,this._map,r))}touchcancel(r){this._map.fire(new mo(r.type,this._map,r))}_firePreventable(r){if(this._map.fire(r),r.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class _i{constructor(r){this._map=r}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(r){this._map.fire(new hr(r.type,this._map,r))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new hr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(r){this._delayContextMenu?this._contextMenuEvent=r:this._ignoreContextMenu||this._map.fire(new hr(r.type,this._map,r)),this._map.listens("contextmenu")&&r.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class sl{constructor(r){this._map=r}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(r){return this.transform.pointLocation(i.P.convert(r),this._map.terrain)}}class Ba{constructor(r,g){this._map=r,this._tr=new sl(r),this._el=r.getCanvasContainer(),this._container=r.getContainer(),this._clickTolerance=g.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(r,g){this.isEnabled()&&r.shiftKey&&r.button===0&&(v.disableDrag(),this._startPos=this._lastPos=g,this._active=!0)}mousemoveWindow(r,g){if(!this._active)return;const S=g;if(this._lastPos.equals(S)||!this._box&&S.dist(this._startPos)<this._clickTolerance)return;const E=this._startPos;this._lastPos=S,this._box||(this._box=v.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",r));const A=Math.min(E.x,S.x),ee=Math.max(E.x,S.x),se=Math.min(E.y,S.y),he=Math.max(E.y,S.y);v.setTransform(this._box,`translate(${A}px,${se}px)`),this._box.style.width=ee-A+"px",this._box.style.height=he-se+"px"}mouseupWindow(r,g){if(!this._active||r.button!==0)return;const S=this._startPos,E=g;if(this.reset(),v.suppressClick(),S.x!==E.x||S.y!==E.y)return this._map.fire(new i.k("boxzoomend",{originalEvent:r})),{cameraAnimation:A=>A.fitScreenCoordinates(S,E,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",r)}keydown(r){this._active&&r.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",r))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(v.remove(this._box),this._box=null),v.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(r,g){return this._map.fire(new i.k(r,{originalEvent:g}))}}function xd(R,r){if(R.length!==r.length)throw new Error(`The number of touches and points are not equal - touches ${R.length}, points ${r.length}`);const g={};for(let S=0;S<R.length;S++)g[R[S].identifier]=r[S];return g}class nl{constructor(r){this.reset(),this.numTouches=r.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(r,g,S){(this.centroid||S.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=r.timeStamp),S.length===this.numTouches&&(this.centroid=function(E){const A=new i.P(0,0);for(const ee of E)A._add(ee);return A.div(E.length)}(g),this.touches=xd(S,g)))}touchmove(r,g,S){if(this.aborted||!this.centroid)return;const E=xd(S,g);for(const A in this.touches){const ee=E[A];(!ee||ee.dist(this.touches[A])>30)&&(this.aborted=!0)}}touchend(r,g,S){if((!this.centroid||r.timeStamp-this.startTime>500)&&(this.aborted=!0),S.length===0){const E=!this.aborted&&this.centroid;if(this.reset(),E)return E}}}class so{constructor(r){this.singleTap=new nl(r),this.numTaps=r.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(r,g,S){this.singleTap.touchstart(r,g,S)}touchmove(r,g,S){this.singleTap.touchmove(r,g,S)}touchend(r,g,S){const E=this.singleTap.touchend(r,g,S);if(E){const A=r.timeStamp-this.lastTime<500,ee=!this.lastTap||this.lastTap.dist(E)<30;if(A&&ee||this.reset(),this.count++,this.lastTime=r.timeStamp,this.lastTap=E,this.count===this.numTaps)return this.reset(),E}}}class Qc{constructor(r){this._tr=new sl(r),this._zoomIn=new so({numTouches:1,numTaps:2}),this._zoomOut=new so({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(r,g,S){this._zoomIn.touchstart(r,g,S),this._zoomOut.touchstart(r,g,S)}touchmove(r,g,S){this._zoomIn.touchmove(r,g,S),this._zoomOut.touchmove(r,g,S)}touchend(r,g,S){const E=this._zoomIn.touchend(r,g,S),A=this._zoomOut.touchend(r,g,S),ee=this._tr;return E?(this._active=!0,r.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:se=>se.easeTo({duration:300,zoom:ee.zoom+1,around:ee.unproject(E)},{originalEvent:r})}):A?(this._active=!0,r.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:se=>se.easeTo({duration:300,zoom:ee.zoom-1,around:ee.unproject(A)},{originalEvent:r})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class _d{constructor(r){this._enabled=!!r.enable,this._moveStateManager=r.moveStateManager,this._clickTolerance=r.clickTolerance||1,this._moveFunction=r.move,this._activateOnStart=!!r.activateOnStart,r.assignEvents(this),this.reset()}reset(r){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(r)}_move(...r){const g=this._moveFunction(...r);if(g.bearingDelta||g.pitchDelta||g.around||g.panDelta)return this._active=!0,g}dragStart(r,g){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(r)&&(this._moveStateManager.startMove(r),this._lastPoint=g.length?g[0]:g,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(r,g){if(!this.isEnabled())return;const S=this._lastPoint;if(!S)return;if(r.preventDefault(),!this._moveStateManager.isValidMoveEvent(r))return void this.reset(r);const E=g.length?g[0]:g;return!this._moved&&E.dist(S)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=E,this._move(S,E))}dragEnd(r){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(r)&&(this._moved&&v.suppressClick(),this.reset(r))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const ai={0:1,2:2};class eu{constructor(r){this._correctEvent=r.checkCorrectEvent}startMove(r){const g=v.mouseButton(r);this._eventButton=g}endMove(r){delete this._eventButton}isValidStartEvent(r){return this._correctEvent(r)}isValidMoveEvent(r){return!function(g,S){const E=ai[S];return g.buttons===void 0||(g.buttons&E)!==E}(r,this._eventButton)}isValidEndEvent(r){return v.mouseButton(r)===this._eventButton}}class Vr{constructor(){this._firstTouch=void 0}_isOneFingerTouch(r){return r.targetTouches.length===1}_isSameTouchEvent(r){return r.targetTouches[0].identifier===this._firstTouch}startMove(r){this._firstTouch=r.targetTouches[0].identifier}endMove(r){delete this._firstTouch}isValidStartEvent(r){return this._isOneFingerTouch(r)}isValidMoveEvent(r){return this._isOneFingerTouch(r)&&this._isSameTouchEvent(r)}isValidEndEvent(r){return this._isOneFingerTouch(r)&&this._isSameTouchEvent(r)}}const Fi=R=>
vendor: 4,041 bytes, line 2537
2537{R.mousedown=R.dragStart,R.mousemoveWindow=R.dragMove,R.mouseup=R.dragEnd,R.contextmenu=r=>{r.preventDefault()}},ri=({enable:R,clickTolerance:r,bearingDegreesPerPixelMoved:g=.8})=>{const S=new eu({checkCorrectEvent:E=>v.mouseButton(E)===0&&E.ctrlKey||v.mouseButton(E)===2});return new _d({clickTolerance:r,move:(E,A)=>({bearingDelta:(A.x-E.x)*g}),moveStateManager:S,enable:R,assignEvents:Fi})},vo=({enable:R,clickTolerance:r,pitchDegreesPerPixelMoved:g=-.5})=>{const S=new eu({checkCorrectEvent:E=>v.mouseButton(E)===0&&E.ctrlKey||v.mouseButton(E)===2});return new _d({clickTolerance:r,move:(E,A)=>({pitchDelta:(A.y-E.y)*g}),moveStateManager:S,enable:R,assignEvents:Fi})};class vu{constructor(r,g){this._clickTolerance=r.clickTolerance||1,this._map=g,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new i.P(0,0)}_shouldBePrevented(r){return r<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(r,g,S){return this._calculateTransform(r,g,S)}touchmove(r,g,S){if(this._active){if(!this._shouldBePrevented(S.length))return r.preventDefault(),this._calculateTransform(r,g,S);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",r)}}touchend(r,g,S){this._calculateTransform(r,g,S),this._active&&this._shouldBePrevented(S.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(r,g,S){S.length>0&&(this._active=!0);const E=xd(S,g),A=new i.P(0,0),ee=new i.P(0,0);let se=0;for(const _e in E){const Ie=E[_e],Me=this._touches[_e];Me&&(A._add(Ie),ee._add(Ie.sub(Me)),se++,E[_e]=Ie)}if(this._touches=E,this._shouldBePrevented(se)||!ee.mag())return;const he=ee.div(se);return this._sum._add(he),this._sum.mag()<this._clickTolerance?void 0:{around:A.div(se),panDelta:he}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class tu{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(r,g,S){this._firstTwoTouches||S.length<2||(this._firstTwoTouches=[S[0].identifier,S[1].identifier],this._start([g[0],g[1]]))}touchmove(r,g,S){if(!this._firstTwoTouches)return;r.preventDefault();const[E,A]=this._firstTwoTouches,ee=bu(S,g,E),se=bu(S,g,A);if(!ee||!se)return;const he=this._aroundCenter?null:ee.add(se).div(2);return this._move([ee,se],he,r)}touchend(r,g,S){if(!this._firstTwoTouches)return;const[E,A]=this._firstTwoTouches,ee=bu(S,g,E),se=bu(S,g,A);ee&&se||(this._active&&v.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(r){this._enabled=!0,this._aroundCenter=!!r&&r.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function bu(R,r,g){for(let S=0;S<R.length;S++)if(R[S].identifier===g)return r[S]}function Bh(R,r){return Math.log(R/r)/Math.LN2}class p extends tu{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(r){this._startDistance=this._distance=r[0].dist(r[1])}_move(r,g){const S=this._distance;if(this._distance=r[0].dist(r[1]),this._active||!(Math.abs(Bh(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Bh(this._distance,S),pinchAround:g}}}function M(R,r){return 180*R.angleWith(r)/Math.PI}class Y extends tu{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(r){this._startVector=this._vector=r[0].sub(r[1]),this._minDiameter=r[0].dist(r[1])}_move(r,g,S){const E=this._vector;if(this._vector=r[0].sub(r[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:M(this._vector,E),pinchAround:g}}_isBelowThreshold(r){this._minDiameter=Math.min(this._minDiameter,r.mag());const g=25/(Math.PI*this._minDiameter)*360,S=M(r,this._startVector);return Math.abs(S)<g}}function ue(R){return Math.abs(R.y)>Math.abs(R.x)}class Se extends tu{constructor(r){super(),this._currentTouchCount=0,this._map=r}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(r,g,S){super.touchstart(r,g,S),this._currentTouchCount=S.length}
2537_start(r){this._lastPoints=r,ue(r[0].sub(r[1]))&&(this._valid=!1)}_move(r,g,S){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const E=r[0].sub(this._lastPoints[0]),A=r[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(E,A,S.timeStamp),this._valid?(this._lastPoints=r,this._active=!0,{pitchDelta:(E.y+A.y)/2*-.5}):void 0}gestureBeginsVertically(r,g,S){if(this._valid!==void 0)return this._valid;const E=r.mag()>=2,A=g.mag()>=2;if(!E&&!A)return;if(!E||!A)return this._firstMove===void 0&&(this._firstMove=S),S-this._firstMove<100&&void 0;const ee=r.y>0==g.y>0;return ue(r)&&ue(g)&&ee}}const st={panStep:100,bearingStep:15,pitchStep:10};class At{constructor(r){this._tr=new sl(r);const g=st;this._panStep=g.panStep,this._bearingStep=g.bearingStep,this._pitchStep=g.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(r){if(r.altKey||r.ctrlKey||r.metaKey)return;let g=0,S=0,E=0,A=0,ee=0;switch(r.keyCode){case 61:case 107:case 171:case 187:g=1;break;case 189:case 109:case 173:g=-1;break;case 37:r.shiftKey?S=-1:(r.preventDefault(),A=-1);break;case 39:r.shiftKey?S=1:(r.preventDefault(),A=1);break;case 38:r.shiftKey?E=1:(r.preventDefault(),ee=-1);break;case 40:r.shiftKey?E=-1:(r.preventDefault(),ee=1);break;default:return}return this._rotationDisabled&&(S=0,E=0),{cameraAnimation:se=>{const he=this._tr;se.easeTo({duration:300,easeId:"keyboardHandler",easing:hs,zoom:g?Math.round(he.zoom)+g*(r.shiftKey?2:1):he.zoom,bearing:he.bearing+S*this._bearingStep,pitch:he.pitch+E*this._pitchStep,offset:[-A*this._panStep,-ee*this._panStep],center:he.center},{originalEvent:r})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function hs(R){return R*(2-R)}const ws=4.000244140625;class Os{constructor(r,g){this._onTimeout=S=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(S)},this._map=r,this._tr=new sl(r),this._triggerRenderFrame=g,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(r){this._defaultZoomRate=r}setWheelZoomRate(r){this._wheelZoomRate=r}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(r){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!r&&r.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(r){return!!this._map.cooperativeGestures.isEnabled()&&!(r.ctrlKey||this._map.cooperativeGestures.isBypassed(r))}wheel(r){if(!this.isEnabled())return;if(this._shouldBePrevented(r))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",r);let g=r.deltaMode===WheelEvent.DOM_DELTA_LINE?40*r.deltaY:r.deltaY;const S=x.now(),E=S-(this._lastWheelEventTime||0);this._lastWheelEventTime=S,g!==0&&g%ws==0?this._type="wheel":g!==0&&Math.abs(g)<4?this._type="trackpad":E>400?(this._type=null,this._lastValue=g,this._timeout=setTimeout(this._onTimeout,40,r)):this._type||(this._type=Math.abs(E*g)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,g+=this._lastValue)),r.shiftKey&&g&&(g/=4),this._type&&(this._lastWheelEvent=r,this._delta-=g,this._active||this._start(r)),r.preventDefault()}_start(r){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const g=v.mousePos(this._map.getCanvas(),r),S=this._tr;this._around=g.y>S.transform.height/2-S.transform.getHorizon()?i.N.convert(this._aroundCenter?S.center:S.unproject(g)):i.N.convert(S.center),this._aroundPoint=S.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const r=this._tr.transform;if(this._delta!==0){const he=this._type==="wheel"&&Math.abs(this._delta)>ws?this._wheelZoomRate:this._defaultZoomRate;let _e=2/(1+Math.exp(-Math.abs(this._delta*he)));this._delta<0&&_e!==0&&(_e=1/_e);const Ie=typeof this._targetZoom=="number"?r.zoomScale(this._targetZoom):r.scale;this._targetZoom=Math.min(r.maxZoom,Math.max(r.minZoom,r.scaleZoom(Ie*_e))),this._type==="wheel"&&(this._startZoom=r.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const g=typeof this._targetZoom=="number"?this._targetZoom:r.zoom,S=this._startZoom,E=this._easing;let A,ee=!1;const se=x.now()-this._lastWheelEventTime;if(this._type==="wheel"&&S&&E&&se){const he=Math.min(se/200,1),_e=E(he);A=i.y.number(S,g,_e),he<1?this._frameId||(this._frameId=!0):ee=!0}else A=g,ee=!0;return this._active=!0,ee&&(this._active=!1,this._finishTimeout=setTimeout(()=>
vendor: 2,174 bytes, line 2537
2537{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!ee,zoomDelta:A-r.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(r){let g=i.b9;if(this._prevEase){const S=this._prevEase,E=(x.now()-S.start)/S.duration,A=S.easing(E+.01)-S.easing(E),ee=.27/Math.sqrt(A*A+1e-4)*.01,se=Math.sqrt(.0729-ee*ee);g=i.b8(ee,se,.25,1)}return this._prevEase={start:x.now(),duration:r,easing:g},g}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class _n{constructor(r,g){this._clickZoom=r,this._tapZoom=g}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Ta{constructor(r){this._tr=new sl(r),this.reset()}reset(){this._active=!1}dblclick(r,g){return r.preventDefault(),{cameraAnimation:S=>{S.easeTo({duration:300,zoom:this._tr.zoom+(r.shiftKey?-1:1),around:this._tr.unproject(g)},{originalEvent:r})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class yr{constructor(){this._tap=new so({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(r,g,S){if(!this._swipePoint)if(this._tapTime){const E=g[0],A=r.timeStamp-this._tapTime<500,ee=this._tapPoint.dist(E)<30;A&&ee?S.length>0&&(this._swipePoint=E,this._swipeTouch=S[0].identifier):this.reset()}else this._tap.touchstart(r,g,S)}touchmove(r,g,S){if(this._tapTime){if(this._swipePoint){if(S[0].identifier!==this._swipeTouch)return;const E=g[0],A=E.y-this._swipePoint.y;return this._swipePoint=E,r.preventDefault(),this._active=!0,{zoomDelta:A/128}}}else this._tap.touchmove(r,g,S)}touchend(r,g,S){if(this._tapTime)this._swipePoint&&S.length===0&&this.reset();else{const E=this._tap.touchend(r,g,S);
2537E&&(this._tapTime=r.timeStamp,this._tapPoint=E)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class cr{constructor(r,g,S){this._el=r,this._mousePan=g,this._touchPan=S}enable(r){this._inertiaOptions=r||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class bo{constructor(r,g,S){this._pitchWithRotate=r.pitchWithRotate,this._mouseRotate=g,this._mousePitch=S}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class zi{constructor(r,g,S,E){this._el=r,this._touchZoom=g,this._touchRotate=S,this._tapDragZoom=E,this._rotationDisabled=!1,this._enabled=!0}enable(r){this._touchZoom.enable(r),this._rotationDisabled||this._touchRotate.enable(r),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class jo{constructor(r,g){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=r,this._options=g,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const r=this._map.getCanvasContainer();r.classList.add("maplibregl-cooperative-gestures"),this._container=v.create("div","maplibregl-cooperative-gesture-screen",r);let g=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(g=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const S=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),E=document.createElement("div");E.className="maplibregl-desktop-message",E.textContent=g,this._container.appendChild(E);const A=document.createElement("div");A.className="maplibregl-mobile-message",A.textContent=S,this._container.appendChild(A),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(v.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(r){return r[this._bypassKey]}notifyGestureBlocked(r,g){this._enabled&&(this._map.fire(new i.k("cooperativegestureprevented",{gestureType:r,originalEvent:g})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const $a=R=>R.zoom||R.drag||R.pitch||R.rotate;class jn extends i.k{}function Ou(R){return R.panDelta&&R.panDelta.mag()||R.zoomDelta||R.bearingDelta||R.pitchDelta}class xh{constructor(r,g){this.handleWindowEvent=E=>{this.handleEvent(E,`${E.type}Window`)},this.handleEvent=(E,A)=>{if(E.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const ee=E.type==="renderFrame"?void 0:E,se={needsRenderFrame:!1},he={},_e={},Ie=E.touches,Me=Ie?this._getMapTouches(Ie):void 0,Je=Me?v.touchPos(this._map.getCanvas(),Me):v.mousePos(this._map.getCanvas(),E);for(const{handlerName:St,handler:Lt,allowed:Vt}of this._handlers){if(!Lt.isEnabled())continue;let Ht;this._blockedByActive(_e,Vt,St)?Lt.reset():Lt[A||E.type]&&(Ht=Lt[A||E.type](E,Je,Me),this.mergeHandlerResult(se,he,Ht,St,ee),Ht&&Ht.needsRenderFrame&&this._triggerRe
vendor: 5,526 bytes, line 2537
2537nderFrame()),(Ht||Lt.isActive())&&(_e[St]=Lt)}const ut={};for(const St in this._previousActiveHandlers)_e[St]||(ut[St]=ee);this._previousActiveHandlers=_e,(Object.keys(ut).length||Ou(se))&&(this._changes.push([se,he,ut]),this._triggerRenderFrame()),(Object.keys(_e).length||Ou(se))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:gt}=se;gt&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],gt(this._map))},this._map=r,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ur(r),this._bearingSnap=g.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(g);const S=this._el;this._listeners=[[S,"touchstart",{passive:!0}],[S,"touchmove",{passive:!1}],[S,"touchend",void 0],[S,"touchcancel",void 0],[S,"mousedown",void 0],[S,"mousemove",void 0],[S,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[S,"mouseover",void 0],[S,"mouseout",void 0],[S,"dblclick",void 0],[S,"click",void 0],[S,"keydown",{capture:!1}],[S,"keyup",void 0],[S,"wheel",{passive:!1}],[S,"contextmenu",void 0],[window,"blur",void 0]];for(const[E,A,ee]of this._listeners)v.addEventListener(E,A,E===document?this.handleWindowEvent:this.handleEvent,ee)}destroy(){for(const[r,g,S]of this._listeners)v.removeEventListener(r,g,r===document?this.handleWindowEvent:this.handleEvent,S)}_addDefaultHandlers(r){const g=this._map,S=g.getCanvasContainer();this._add("mapEvent",new mc(g,r));const E=g.boxZoom=new Ba(g,r);this._add("boxZoom",E),r.interactive&&r.boxZoom&&E.enable();const A=g.cooperativeGestures=new jo(g,r.cooperativeGestures);this._add("cooperativeGestures",A),r.cooperativeGestures&&A.enable();const ee=new Qc(g),se=new Ta(g);g.doubleClickZoom=new _n(se,ee),this._add("tapZoom",ee),this._add("clickZoom",se),r.interactive&&r.doubleClickZoom&&g.doubleClickZoom.enable();const he=new yr;this._add("tapDragZoom",he);const _e=g.touchPitch=new Se(g);this._add("touchPitch",_e),r.interactive&&r.touchPitch&&g.touchPitch.enable(r.touchPitch);const Ie=ri(r),Me=vo(r);g.dragRotate=new bo(r,Ie,Me),this._add("mouseRotate",Ie,["mousePitch"]),this._add("mousePitch",Me,["mouseRotate"]),r.interactive&&r.dragRotate&&g.dragRotate.enable();const Je=(({enable:Ht,clickTolerance:Et})=>{const Kt=new eu({checkCorrectEvent:ss=>v.mouseButton(ss)===0&&!ss.ctrlKey});return new _d({clickTolerance:Et,move:(ss,cs)=>({around:cs,panDelta:cs.sub(ss)}),activateOnStart:!0,moveStateManager:Kt,enable:Ht,assignEvents:Fi})})(r),ut=new vu(r,g);g.dragPan=new cr(S,Je,ut),this._add("mousePan",Je),this._add("touchPan",ut,["touchZoom","touchRotate"]),r.interactive&&r.dragPan&&g.dragPan.enable(r.dragPan);const gt=new Y,St=new p;g.touchZoomRotate=new zi(S,St,gt,he),this._add("touchRotate",gt,["touchPan","touchZoom"]),this._add("touchZoom",St,["touchPan","touchRotate"]),r.interactive&&r.touchZoomRotate&&g.touchZoomRotate.enable(r.touchZoomRotate);const Lt=g.scrollZoom=new Os(g,()=>this._triggerRenderFrame());this._add("scrollZoom",Lt,["mousePan"]),r.interactive&&r.scrollZoom&&g.scrollZoom.enable(r.scrollZoom);const Vt=g.keyboard=new At(g);this._add("keyboard",Vt),r.interactive&&r.keyboard&&g.keyboard.enable(),this._add("blockableMapEvent",new _i(g))}_add(r,g,S){this._handlers.push({handlerName:r,handler:g,allowed:S}),this._handlersById[r]=g}stop(r){if(!this._updatingCamera){for(const{handler:g}of this._handlers)g.reset();this._inertia.clear(),this._fireEvents({},{},r),this._changes=[]}}isActive(){for(const{handler:r}of this._handlers)if(r.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!$a(this._eventsInProgress)||this.isZooming()}_blockedByActive(r,g,S){for(const E in r)if(E!==S&&(!g||g.indexOf(E)<0))return!0;return!1}_getMapTouches(r){const g=[];for(const S of r)this._el.contains(S.target)&&g.push(S);return g}mergeHandlerResult(r,g,S,E,A){if(!S)return;i.e(r,S);const ee={handlerName:E,originalEvent:S.originalEvent||A};S.zoomDelta!==void 0&&(g.zoom=ee),S.panDelta!==void 0&&(g.drag=ee),S.pitchDelta!==void 0&&(g.pitch=ee),S.bearingDelta!==void 0&&(g.rotate=ee)}_applyChanges(){const r={},g={},S={};for(const[E,A,ee]of this._changes)E.panDelta&&(r.panDelta=(r.panDelta||new i.P(0,0))._add(E.panDelta)),E.zoomDelta&&(r.zoomDelta=(r.zoomDelta||0)+E.zoomDelta),E.bearingDelta&&(r.bearingDelta=(r.bearingDelta||0)+E.bearingDelta),E.pitchDelta&&(r.pitchDelta=(r.pitchDelta||0)+E.pitchDelta),E.around!==void 0&&(r.around=E.around),E.pinchAround!==void 0&&(r.pinchAround=E.pinchAround),E.noInertia&&(r.noInertia=E.noInertia),i.e(g,A),i.e(S,ee);this._updateMapTransform(r,g,S),this._changes=[]}_updateMapTransform(r,g,S){const E=this._map,A=E._getTransformForUpdate(),ee=E.terrain;if(!(Ou(r)||ee&&this._terrainMovement))return this._fireEvents(g,S,!0);let{panDelta:se,zoomDelta:he,bearingDelta:_e,pitchDelta:Ie,around:Me,pinchAround:Je}=r;Je!==void 0&&(Me=Je),E._stop(!0),Me=Me||E.transform.centerPoint;const ut=A.pointLocation(se?Me.sub(se):Me);_e&&(A.bearing+=_e),Ie&&(A.pitch+=Ie),he&&(A.zoom+=he),ee?this._terrainMovement||!g.drag&&!g.zoom?g.drag&&this._terrainMovement?A.center=A.pointLocation(A.centerPoint.sub(se)):A.setLocationAtPoint(ut,Me):(this._terrainMovement=!0,this._map._elevationFreeze=!0,A.setLocationAtPoint(ut,Me)):A.setLocationAtPoint(ut,Me),E._applyUpdatedTransform(A),this._map._update(),r.noInertia||this._inertia.record(r),this._fireEvents(g,S,!0)}
vendor: 1,646 bytes, line 2537
2537_fireEvents(r,g,S){const E=$a(this._eventsInProgress),A=$a(r),ee={};for(const Me in r){const{originalEvent:Je}=r[Me];this._eventsInProgress[Me]||(ee[`${Me}start`]=Je),this._eventsInProgress[Me]=r[Me]}!E&&A&&this._fireEvent("movestart",A.originalEvent);for(const Me in ee)this._fireEvent(Me,ee[Me]);A&&this._fireEvent("move",A.originalEvent);for(const Me in r){const{originalEvent:Je}=r[Me];this._fireEvent(Me,Je)}const se={};let he;for(const Me in this._eventsInProgress){const{handlerName:Je,originalEvent:ut}=this._eventsInProgress[Me];this._handlersById[Je].isActive()||(delete this._eventsInProgress[Me],he=g[Je]||ut,se[`${Me}end`]=he)}for(const Me in se)this._fireEvent(Me,se[Me]);const _e=$a(this._eventsInProgress),Ie=(E||A)&&!_e;if(Ie&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const Me=this._map._getTransformForUpdate();Me.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(Me)}if(S&&Ie){this._updatingCamera=!0;const Me=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),Je=ut=>ut!==0&&-this._bearingSnap<ut&&ut<this._bearingSnap;!Me||!Me.essential&&x.prefersReducedMotion?(this._map.fire(new i.k("moveend",{originalEvent:he})),Je(this._map.getBearing())&&this._map.resetNorth()):(Je(Me.bearing||this._map.getBearing())&&(Me.bearing=0),Me.freezeElevation=!0,this._map.easeTo(Me,{originalEvent:he})),this._updatingCamera=!1}}_fireEvent(r,g){this._map.fire(new i.k(r,g?{originalEvent:g}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(r=>{delete this._frameId,this.handleEvent(new jn("renderFrame",{timeStamp:r})),this._applyChanges()})}
2537_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Ac extends i.E{constructor(r,g){super(),this._renderFrameCallback=()=>{const S=Math.min((x.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(S)),S<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=r,this._bearingSnap=g.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new i.N(this.transform.center.lng,this.transform.center.lat)}setCenter(r,g){return this.jumpTo({center:r},g)}panBy(r,g,S){return r=i.P.convert(r).mult(-1),this.panTo(this.transform.center,i.e({offset:r},g),S)}panTo(r,g,S){return this.easeTo(i.e({center:r},g),S)}getZoom(){return this.transform.zoom}setZoom(r,g){return this.jumpTo({zoom:r},g),this}zoomTo(r,g,S){return this.easeTo(i.e({zoom:r},g),S)}zoomIn(r,g){return this.zoomTo(this.getZoom()+1,r,g),this}zoomOut(r,g){return this.zoomTo(this.getZoom()-1,r,g),this}getBearing(){return this.transform.bearing}setBearing(r,g){return this.jumpTo({bearing:r},g),this}getPadding(){return this.transform.padding}setPadding(r,g){return this.jumpTo({padding:r},g),this}rotateTo(r,g,S){return this.easeTo(i.e({bearing:r},g),S)}resetNorth(r,g){return this.rotateTo(0,i.e({duration:1e3},r),g),this}resetNorthPitch(r,g){return this.easeTo(i.e({bearing:0,pitch:0,duration:1e3},r),g),this}snapToNorth(r,g){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(r,g):this}getPitch(){return this.transform.pitch}setPitch(r,g){return this.jumpTo({pitch:r},g),this}cameraForBounds(r,g){r=He.convert(r).adjustAntiMeridian();const S=g&&g.bearing||0;return this._cameraForBoxAndBearing(r.getNorthWest(),r.getSouthEast(),S,g)}_cameraForBoxAndBearing(r,g,S,E){const A={top:0,bottom:0,right:0,left:0};if(typeof(E=i.e({padding:A,offset:[0,0],maxZoom:this.transform.maxZoom},E)).padding=="number"){const Js=E.padding;E.padding={top:Js,bottom:Js,right:Js,left:Js}}E.padding=i.e(A,E.padding);const ee=this.transform,se=ee.padding,he=new He(r,g),_e=ee.project(he.getNorthWest()),Ie=ee.project(he.getNorthEast()),Me=ee.project(he.getSouthEast()),Je=ee.project(he.getSouthWest
vendor: 7,504 bytes, line 2537
2537()),ut=i.ba(-S),gt=_e.rotate(ut),St=Ie.rotate(ut),Lt=Me.rotate(ut),Vt=Je.rotate(ut),Ht=new i.P(Math.max(gt.x,St.x,Vt.x,Lt.x),Math.max(gt.y,St.y,Vt.y,Lt.y)),Et=new i.P(Math.min(gt.x,St.x,Vt.x,Lt.x),Math.min(gt.y,St.y,Vt.y,Lt.y)),Kt=Ht.sub(Et),ss=(ee.width-(se.left+se.right+E.padding.left+E.padding.right))/Kt.x,cs=(ee.height-(se.top+se.bottom+E.padding.top+E.padding.bottom))/Kt.y;if(cs<0||ss<0)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const As=Math.min(ee.scaleZoom(ee.scale*Math.min(ss,cs)),E.maxZoom),sn=i.P.convert(E.offset),pn=new i.P((E.padding.left-E.padding.right)/2,(E.padding.top-E.padding.bottom)/2).rotate(i.ba(S)),Ln=sn.add(pn).mult(ee.scale/ee.zoomScale(As));return{center:ee.unproject(_e.add(Me).div(2).sub(Ln)),zoom:As,bearing:S}}fitBounds(r,g,S){return this._fitInternal(this.cameraForBounds(r,g),g,S)}fitScreenCoordinates(r,g,S,E,A){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(i.P.convert(r)),this.transform.pointLocation(i.P.convert(g)),S,E),E,A)}_fitInternal(r,g,S){return r?(delete(g=i.e(r,g)).padding,g.linear?this.easeTo(g,S):this.flyTo(g,S)):this}jumpTo(r,g){this.stop();const S=this._getTransformForUpdate();let E=!1,A=!1,ee=!1;return"zoom"in r&&S.zoom!==+r.zoom&&(E=!0,S.zoom=+r.zoom),r.center!==void 0&&(S.center=i.N.convert(r.center)),"bearing"in r&&S.bearing!==+r.bearing&&(A=!0,S.bearing=+r.bearing),"pitch"in r&&S.pitch!==+r.pitch&&(ee=!0,S.pitch=+r.pitch),r.padding==null||S.isPaddingEqual(r.padding)||(S.padding=r.padding),this._applyUpdatedTransform(S),this.fire(new i.k("movestart",g)).fire(new i.k("move",g)),E&&this.fire(new i.k("zoomstart",g)).fire(new i.k("zoom",g)).fire(new i.k("zoomend",g)),A&&this.fire(new i.k("rotatestart",g)).fire(new i.k("rotate",g)).fire(new i.k("rotateend",g)),ee&&this.fire(new i.k("pitchstart",g)).fire(new i.k("pitch",g)).fire(new i.k("pitchend",g)),this.fire(new i.k("moveend",g))}calculateCameraOptionsFromTo(r,g,S,E=0){const A=i.Z.fromLngLat(r,g),ee=i.Z.fromLngLat(S,E),se=ee.x-A.x,he=ee.y-A.y,_e=ee.z-A.z,Ie=Math.hypot(se,he,_e);if(Ie===0)throw new Error("Can't calculate camera options with same From and To");const Me=Math.hypot(se,he),Je=this.transform.scaleZoom(this.transform.cameraToCenterDistance/Ie/this.transform.tileSize),ut=180*Math.atan2(se,-he)/Math.PI;let gt=180*Math.acos(Me/Ie)/Math.PI;return gt=_e<0?90-gt:90+gt,{center:ee.toLngLat(),zoom:Je,pitch:gt,bearing:ut}}easeTo(r,g){var S;this._stop(!1,r.easeId),((r=i.e({offset:[0,0],duration:500,easing:i.b9},r)).animate===!1||!r.essential&&x.prefersReducedMotion)&&(r.duration=0);const E=this._getTransformForUpdate(),A=E.zoom,ee=E.bearing,se=E.pitch,he=E.padding,_e="bearing"in r?this._normalizeBearing(r.bearing,ee):ee,Ie="pitch"in r?+r.pitch:se,Me="padding"in r?r.padding:E.padding,Je=i.P.convert(r.offset);let ut=E.centerPoint.add(Je);const gt=E.pointLocation(ut),{center:St,zoom:Lt}=E.getConstrained(i.N.convert(r.center||gt),(S=r.zoom)!==null&&S!==void 0?S:A);this._normalizeCenter(St,E);const Vt=E.project(gt),Ht=E.project(St).sub(Vt),Et=E.zoomScale(Lt-A);let Kt,ss;r.around&&(Kt=i.N.convert(r.around),ss=E.locationPoint(Kt));const cs={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||Lt!==A,this._rotating=this._rotating||ee!==_e,this._pitching=this._pitching||Ie!==se,this._padding=!E.isPaddingEqual(Me),this._easeId=r.easeId,this._prepareEase(g,r.noMoveStart,cs),this.terrain&&this._prepareElevation(St),this._ease(As=>{if(this._zooming&&(E.zoom=i.y.number(A,Lt,As)),this._rotating&&(E.bearing=i.y.number(ee,_e,As)),this._pitching&&(E.pitch=i.y.number(se,Ie,As)),this._padding&&(E.interpolatePadding(he,Me,As),ut=E.centerPoint.add(Je)),this.terrain&&!r.freezeElevation&&this._updateElevation(As),Kt)E.setLocationAtPoint(Kt,ss);else{const sn=E.zoomScale(E.zoom-A),pn=Lt>A?Math.min(2,Et):Math.max(.5,Et),Ln=Math.pow(pn,1-As),Js=E.unproject(Vt.add(Ht.mult(As*Ln)).mult(sn));E.setLocationAtPoint(E.renderWorldCopies?Js.wrap():Js,ut)}this._applyUpdatedTransform(E),this._fireMoveEvents(g)},As=>{this.terrain&&r.freezeElevation&&this._finalizeElevation(),this._afterEase(g,As)},r),this}_prepareEase(r,g,S={}){this._moving=!0,g||S.moving||this.fire(new i.k("movestart",r)),this._zooming&&!S.zooming&&this.fire(new i.k("zoomstart",r)),this._rotating&&!S.rotating&&this.fire(new i.k("rotatestart",r)),this._pitching&&!S.pitching&&this.fire(new i.k("pitchstart",r))}_prepareElevation(r){this._elevationCenter=r,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(r,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(r){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const g=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(r<1&&g!==this._elevationTarget){const S=this._elevationTarget-this._elevationStart;this._elevationStart+=r*(S-(g-(S*r+this._elevationStart))/(1-r)),this._elevationTarget=g}this.transform.elevation=i.y.number(this._elevationStart,this._elevationTarget,r)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(r){const g=r.getCameraPosition(),S=this.terrain.getElevationForLngLatZoom(g.lngLat,r.zoom);if(g.altitude<S){const E=this.calculateCameraOptionsFromTo(g.lngLat,S,r.center,r.elevation);return{pitch:E.pitch,zoom:E.zoom}}return{}}_applyUpdatedTransform(r){const g=[];if(this.terrain&&g.push(E=>this._elevateCameraIfInsideTerrain(E)),this.transformCameraUpdate&&g.push(E=>this.transformCameraUpdate(E)),!g.length)return;const S=r.clone();for(const E of g){const A=S.clone(),{center:ee,zoom:se,pitch:he,bearing:_e,elevation:Ie}=E(A);ee&&(A.center=ee),se!==void 0&&(A.zoom=se),he!==void 0&&(A.pitch=he),_e!==void 0&&(A.bearing=_e),Ie!==void 0&&(A.elevation=Ie),S.apply(A)}this.transform.apply(S)}_fireMoveEvents(r){this.fire(new i.k("move",r)),this._zooming&&this.fire(new i.k("zoom",r)),this._rotating&&this.fire(new i.k("rotate",r)),this._pitching&&this.fire(new i.k("pitch",r))}_afterEase(r,g){if(this._easeId&&g&&this._easeId===g)return;delete this._easeId;const S=this._zooming,E=this._rotating,A=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,S&&this.fire(new i.k("zoomend",r)),E&&this.fire(new i.k("rotateend",r)),A&&this.fire(new i.k("pitchend",r)),this.fire(new i.k("moveend",r))}flyTo(r,g){var S;if(!r.essential&&x.prefersReducedMotion){const Nn=i.M(r,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Nn,g)}this.stop(),r=i.e({offset:[0,0],speed:1.2,curve:1.42,easing:i.b9},r);const E=this._getTransformForUpdate(),A=E.zoom,ee=E.bearing,se=E.pitch,he=E.padding,_e="bearing"in r?this._normalizeBearing(r.bearing,ee):ee,Ie="pitch"in r?+r.pitch:se,Me="padding"in r?r.padding:E.padding,Je=i.P.convert(r.offset);let ut=E.centerPoint.add(Je);const gt=E.pointLocation(ut),{center:St,zoom:Lt}=E.getConstrained(i.N.convert(r.center||gt),(S=r.zoom)!==null&&S!==void 0?S:A);this._normalizeCenter(St,E);const Vt=E.zoomScale(Lt-A),Ht=E.project(gt),Et=E.project(St).sub(Ht);let Kt=r.curve;const ss=Math.max(E.width,E.height),cs=ss/Vt,As=Et.mag();
2537if("minZoom"in r){const Nn=i.ac(Math.min(r.minZoom,A,Lt),E.minZoom,E.maxZoom),aa=ss/E.zoomScale(Nn-A);Kt=Math.sqrt(aa/As*2)}const sn=Kt*Kt;function pn(Nn){const aa=(cs*cs-ss*ss+(Nn?-1:1)*sn*sn*As*As)/(2*(Nn?cs:ss)*sn*As);return Math.log(Math.sqrt(aa*aa+1)-aa)}function Ln(Nn){return(Math.exp(Nn)-Math.exp(-Nn))/2}function Js(Nn){return(Math.exp(Nn)+Math.exp(-Nn))/2}const on=pn(!1);let Hn=function(Nn){return Js(on)/Js(on+Kt*Nn)},Ra=function(Nn){return ss*((Js(on)*(Ln(aa=on+Kt*Nn)/Js(aa))-Ln(on))/sn)/As;var aa},ln=(pn(!0)-on)/Kt;if(Math.abs(As)<1e-6||!isFinite(ln)){if(Math.abs(ss-cs)<1e-6)return this.easeTo(r,g);const Nn=cs<ss?-1:1;ln=Math.abs(Math.log(cs/ss))/Kt,Ra=()=>0,Hn=aa=>Math.exp(Nn*Kt*aa)}return r.duration="duration"in r?+r.duration:1e3*ln/("screenSpeed"in r?+r.screenSpeed/Kt:+r.speed),r.maxDuration&&r.duration>r.maxDuration&&(r.duration=0),this._zooming=!0,this._rotating=ee!==_e,this._pitching=Ie!==se,this._padding=!E.isPaddingEqual(Me),this._prepareEase(g,!1),this.terrain&&this._prepareElevation(St),this._ease(Nn=>{const aa=Nn*ln,mi=1/Hn(aa);E.zoom=Nn===1?Lt:A+E.scaleZoom(mi),this._rotating&&(E.bearing=i.y.number(ee,_e,Nn)),this._pitching&&(E.pitch=i.y.number(se,Ie,Nn)),this._padding&&(E.interpolatePadding(he,Me,Nn),ut=E.centerPoint.add(Je)),this.terrain&&!r.freezeElevation&&this._updateElevation(Nn);const er=Nn===1?St:E.unproject(Ht.add(Et.mult(Ra(aa))).mult(mi));E.setLocationAtPoint(E.renderWorldCopies?er.wrap():er,ut),this._applyUpdatedTransform(E),this._fireMoveEvents(g)},()=>{this.terrain&&r.freezeElevation&&this._finalizeElevation(),this._afterEase(g)},r),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(r,g){var S;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const E=this._onEaseEnd;delete this._onEaseEnd,E.call(this,g)}return r||(S=this.handlers)===null||S===void 0||S.stop(!1),this}_ease(r,g,S){S.animate===!1||S.duration===0?(r(1),g()):(this._easeStart=x.now(),this._easeOptions=S,this._onEaseFrame=r,this._onEaseEnd=g,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(r,g){r=i.b3(r,-180,180);const S=Math.abs(r-g);return Math.abs(r-360-g)<S&&(r-=360),Math.abs(r+360-g)<S&&(r+=360),r}_normalizeCenter(r,g){if(!g.renderWorldCopies||g.lngRange)return;const S=r.lng-g.center.lng;r.lng+=S>180?-360:S<-180?360:0}queryTerrainElevation(r){return this.terrain?this.terrain.getElevationForLngLatZoom(i.N.convert(r),this.transform.tileZoom)-this.transform.elevation:null}}const Uc={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Dc{constructor(r=Uc){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=g=>{!g||g.sourceDataType!=="metadata"&&g.sourceDataType!=="visibility"&&g.dataType!=="style"&&g.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=r}getDefaultPosition(){return"bottom-right"}onAdd(r){return this._map=r,this._compact=this.options.compact,this._container=v.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=v.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=v.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){v.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(r,g){const S=this._map._getUIString(`AttributionControl.${g}`);r.title=S,r.setAttribute("aria-label",S)}_updateAttributions(){if(!this._map.style)return;let r=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?r=r.concat(this.options.customAttribution.map(E=>
vendor: 22,152 bytes, line 2537
2537typeof E!="string"?"":E)):typeof this.options.customAttribution=="string"&&r.push(this.options.customAttribution)),this._map.style.stylesheet){const E=this._map.style.stylesheet;this.styleOwner=E.owner,this.styleId=E.id}const g=this._map.style.sourceCaches;for(const E in g){const A=g[E];if(A.used||A.usedForTerrain){const ee=A.getSource();ee.attribution&&r.indexOf(ee.attribution)<0&&r.push(ee.attribution)}}r=r.filter(E=>String(E).trim()),r.sort((E,A)=>E.length-A.length),r=r.filter((E,A)=>{for(let ee=A+1;ee<r.length;ee++)if(r[ee].indexOf(E)>=0)return!1;return!0});const S=r.join(" | ");S!==this._attribHTML&&(this._attribHTML=S,r.length?(this._innerContainer.innerHTML=S,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class fo{constructor(r={}){this._updateCompact=()=>{const g=this._container.children;if(g.length){const S=g[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&S.classList.add("maplibregl-compact"):S.classList.remove("maplibregl-compact")}},this.options=r}getDefaultPosition(){return"bottom-left"}onAdd(r){this._map=r,this._compact=this.options&&this.options.compact,this._container=v.create("div","maplibregl-ctrl");const g=v.create("a","maplibregl-ctrl-logo");return g.target="_blank",g.rel="noopener nofollow",g.href="https://maplibre.org/",g.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),g.setAttribute("rel","noopener nofollow"),this._container.appendChild(g),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){v.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Ua{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(r){const g=++this._id;return this._queue.push({callback:r,id:g,cancelled:!1}),g}remove(r){const g=this._currentlyRunning,S=g?this._queue.concat(g):this._queue;for(const E of S)if(E.id===r)return void(E.cancelled=!0)}run(r=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const g=this._currentlyRunning=this._queue;this._queue=[];for(const S of g)if(!S.cancelled&&(S.callback(r),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var vm=i.Y([{name:"a_pos3d",type:"Int16",components:3}]);class _h extends i.E{constructor(r){super(),this.sourceCache=r,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,r.usedForTerrain=!0,r.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(r,g){this.sourceCache.update(r,g),this._renderableTilesKeys=[];const S={};for(const E of r.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:g}))S[E.key]=!0,this._renderableTilesKeys.push(E.key),this._tiles[E.key]||(E.posMatrix=new Float64Array(16),i.aP(E.posMatrix,0,i.X,0,i.X,0,1),this._tiles[E.key]=new en(E,this.tileSize));for(const E in this._tiles)S[E]||delete this._tiles[E]}freeRtt(r){for(const g in this._tiles){const S=this._tiles[g];(!r||S.tileID.equals(r)||S.tileID.isChildOf(r)||r.isChildOf(S.tileID))&&(S.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(r=>this.getTileByID(r))}getTileByID(r){return this._tiles[r]}getTerrainCoords(r){const g={};for(const S of this._renderableTilesKeys){const E=this._tiles[S].tileID;if(E.canonical.equals(r.canonical)){const A=r.clone();A.posMatrix=new Float64Array(16),i.aP(A.posMatrix,0,i.X,0,i.X,0,1),g[S]=A}else if(E.canonical.isChildOf(r.canonical)){const A=r.clone();A.posMatrix=new Float64Array(16);const ee=E.canonical.z-r.canonical.z,se=E.canonical.x-(E.canonical.x>>ee<<ee),he=E.canonical.y-(E.canonical.y>>ee<<ee),_e=i.X>>ee;i.aP(A.posMatrix,0,_e,0,_e,0,1),i.J(A.posMatrix,A.posMatrix,[-se*_e,-he*_e,0]),g[S]=A}else if(r.canonical.isChildOf(E.canonical)){const A=r.clone();A.posMatrix=new Float64Array(16);const ee=r.canonical.z-E.canonical.z,se=r.canonical.x-(r.canonical.x>>ee<<ee),he=r.canonical.y-(r.canonical.y>>ee<<ee),_e=i.X>>ee;i.aP(A.posMatrix,0,i.X,0,i.X,0,1),i.J(A.posMatrix,A.posMatrix,[se*_e,he*_e,0]),i.K(A.posMatrix,A.posMatrix,[1/2**ee,1/2**ee,0]),g[S]=A}}return g}getSourceTile(r,g){const S=this.sourceCache._source;let E=r.overscaledZ-this.deltaZoom;if(E>S.maxzoom&&(E=S.maxzoom),E<S.minzoom)return null;this._sourceTileCache[r.key]||(this._sourceTileCache[r.key]=r.scaledTo(E).key);let A=this.sourceCache.getTileByID(this._sourceTileCache[r.key]);if((!A||!A.dem)&&g)for(;E>=S.minzoom&&(!A||!A.dem);)A=this.sourceCache.getTileByID(r.scaledTo(E--).key);return A}tilesAfterTime(r=Date.now()){return Object.values(this._tiles).filter(g=>g.timeAdded>=r)}}class yh{constructor(r,g,S){this.painter=r,this.sourceCache=new _h(g),this.options=S,this.exaggeration=typeof S.exaggeration=="number"?S.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(r,g,S,E=i.X){var A;if(!(g>=0&&g<E&&S>=0&&S<E))return 0;const ee=this.getTerrainData(r),se=(A=ee.tile)===null||A===void 0?void 0:A.dem;if(!se)return 0;const he=function(gt,St,Lt){var Vt=St[0],Ht=St[1];return gt[0]=Lt[0]*Vt+Lt[4]*Ht+Lt[12],gt[1]=Lt[1]*Vt+Lt[5]*Ht+Lt[13],gt}([],[g/E*i.X,S/E*i.X],ee.u_terrain_matrix),_e=[he[0]*se.dim,he[1]*se.dim],Ie=Math.floor(_e[0]),Me=Math.floor(_e[1]),Je=_e[0]-Ie,ut=_e[1]-Me;return se.get(Ie,Me)*(1-Je)*(1-ut)+se.get(Ie+1,Me)*Je*(1-ut)+se.get(Ie,Me+1)*(1-Je)*ut+se.get(Ie+1,Me+1)*Je*ut}getElevationForLngLatZoom(r,g){if(!i.bb(g,r.wrap()))return 0;const{tileID:S,mercatorX:E,mercatorY:A}=this._getOverscaledTileIDFromLngLatZoom(r,g);return this.getElevation(S,E%i.X,A%i.X,i.X)}getElevation(r,g,S,E=i.X){return this.getDEMElevation(r,g,S,E)*this.exaggeration}getTerrainData(r){if(!this._emptyDemTexture){const E=this.painter.context,A=new i.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Q(E,A,E.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Q(E,new i.R({width:1,height:1}),E.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(E.gl.NEAREST,E.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=i.an([])}const g=this.sourceCache.getSourceTile(r,!0);if(g&&g.dem&&(!g.demTexture||g.needsTerrainPrepare)){const E=this.painter.context;g.demTexture=this.painter.getTileTexture(g.dem.stride),g.demTexture?g.demTexture.update(g.dem.getPixels(),{premultiply:!1}):g.demTexture=new Q(E,g.dem.getPixels(),E.gl.RGBA,{premultiply:!1}),g.demTexture.bind(E.gl.NEAREST,E.gl.CLAMP_TO_EDGE),g.needsTerrainPrepare=!1}const S=g&&g+g.tileID.key+r.key;if(S&&!this._demMatrixCache[S]){const E=this.sourceCache.sourceCache._source.maxzoom;let A=r.canonical.z-g.tileID.canonical.z;r.overscaledZ>r.canonical.z&&(r.canonical.z>=E?A=r.canonical.z-E:i.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const ee=r.canonical.x-(r.canonical.x>>A<<A),se=r.canonical.y-(r.canonical.y>>A<<A),he=i.bc(new Float64Array(16),[1/(i.X<<A),1/(i.X<<A),0]);i.J(he,he,[ee*i.X,se*i.X,0]),this._demMatrixCache[r.key]={matrix:he,coord:r}}return{u_depth:2,u_terrain:3,u_terrain_dim:g&&g.dem&&g.dem.dim||1,u_terrain_matrix:S?this._demMatrixCache[r.key].matrix:this._emptyDemMatrix,u_terrain_unpack:g&&g.dem&&g.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(g&&g.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:g}}getFramebuffer(r){const g=this.painter,S=g.width/devicePixelRatio,E=g.height/devicePixelRatio;return!this._fbo||this._fbo.width===S&&this._fbo.height===E||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Q(g.context,{width:S,height:E,data:null},g.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(g.context.gl.NEAREST,g.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Q(g.context,{width:S,height:E,data:null},g.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(g.context.gl.NEAREST,g.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=g.context.createFramebuffer(S,E,!0,!1),this._fbo.depthAttachment.set(g.context.createRenderbuffer(g.context.gl.DEPTH_COMPONENT16,S,E))),this._fbo.colorAttachment.set(r==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const r=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const g=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let A=0,ee=0;A<this._coordsTextureSize;A++)for(let se=0;se<this._coordsTextureSize;se++,ee+=4)g[ee+0]=255&se,g[ee+1]=255&A,g[ee+2]=se>>8<<4|A>>8,g[ee+3]=0;const S=new i.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(g.buffer)),E=new Q(r,S,r.gl.RGBA,{premultiply:!1});return E.bind(r.gl.NEAREST,r.gl.CLAMP_TO_EDGE),this._coordsTexture=E,E}pointCoordinate(r){this.painter.maybeDrawDepthAndCoords(!0);const g=new Uint8Array(4),S=this.painter.context,E=S.gl,A=Math.round(r.x*this.painter.pixelRatio/devicePixelRatio),ee=Math.round(r.y*this.painter.pixelRatio/devicePixelRatio),se=Math.round(this.painter.height/devicePixelRatio);S.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),E.readPixels(A,se-ee-1,1,1,E.RGBA,E.UNSIGNED_BYTE,g),S.bindFramebuffer.set(null);const he=g[0]+(g[2]>>4<<8),_e=g[1]+((15&g[2])<<8),Ie=this.coordsIndex[255-g[3]],Me=Ie&&this.sourceCache.getTileByID(Ie);if(!Me)return null;const Je=this._coordsTextureSize,ut=(1<<Me.tileID.canonical.z)*Je;return new i.Z((Me.tileID.canonical.x*Je+he)/ut+Me.tileID.wrap,(Me.tileID.canonical.y*Je+_e)/ut,this.getElevation(Me.tileID,he,_e,Je))}depthAtPoint(r){const g=new Uint8Array(4),S=this.painter.context,E=S.gl;return S.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),E.readPixels(r.x,this.painter.height/devicePixelRatio-r.y-1,1,1,E.RGBA,E.UNSIGNED_BYTE,g),S.bindFramebuffer.set(null),(g[0]/16777216+g[1]/65536+g[2]/256+g[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;const r=this.painter.context,g=new i.bd,S=new i.aY,E=this.meshSize,A=i.X/E,ee=E*E;for(let Me=0;Me<=E;Me++)for(let Je=0;Je<=E;Je++)g.emplaceBack(Je*A,Me*A,0);for(let Me=0;Me<ee;Me+=E+1)for(let Je=0;Je<E;Je++)S.emplaceBack(Je+Me,E+Je+Me+1,E+Je+Me+2),S.emplaceBack(Je+Me,E+Je+Me+2,Je+Me+1);const se=g.length,he=se+2*(E+1);for(const Me of[0,1])for(let Je=0;Je<=E;Je++)for(const ut of[0,1])g.emplaceBack(Je*A,Me*i.X,ut);for(let Me=0;Me<2*E;Me+=2)S.emplaceBack(he+Me,he+Me+1,he+Me+3),S.emplaceBack(he+Me,he+Me+3,he+Me+2),S.emplaceBack(se+Me,se+Me+3,se+Me+1),S.emplaceBack(se+Me,se+Me+2,se+Me+3);const _e=g.length,Ie=_e+2*(E+1);for(const Me of[0,1])for(let Je=0;Je<=E;Je++)for(const ut of[0,1])g.emplaceBack(Me*i.X,Je*A,ut);for(let Me=0;Me<2*E;Me+=2)S.emplaceBack(_e+Me,_e+Me+1,_e+Me+3),S.emplaceBack(_e+Me,_e+Me+3,_e+Me+2),S.emplaceBack(Ie+Me,Ie+Me+3,Ie+Me+1),S.emplaceBack(Ie+Me,Ie+Me+2,Ie+Me+3);return this._mesh=new w(r.createVertexBuffer(g,vm.members),r.createIndexBuffer(S),i.a0.simpleSegment(0,0,g.length,S.length)),this._mesh}getMeshFrameDelta(r){return 2*Math.PI*i.be/Math.pow(2,r)/5}getMinTileElevationForLngLatZoom(r,g){var S;const{tileID:E}=this._getOverscaledTileIDFromLngLatZoom(r,g);return(S=this.getMinMaxElevation(E).minElevation)!==null&&S!==void 0?S:0}getMinMaxElevation(r){const g=this.getTerrainData(r).tile,S={minElevation:null,maxElevation:null};return g&&g.dem&&(S.minElevation=g.dem.min*this.exaggeration,S.maxElevation=g.dem.max*this.exaggeration),S}_getOverscaledTileIDFromLngLatZoom(r,g){const S=i.Z.fromLngLat(r.wrap()),E=(1<<g)*i.X,A=S.x*E,ee=S.y*E,se=Math.floor(A/i.X),he=Math.floor(ee/i.X);return{tileID:new i.S(g,0,g,se,he),mercatorX:A,mercatorY:ee}}}class Bu{constructor(r,g,S){this._context=r,this._size=g,this._tileSize=S,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const r of this._objects)r.texture.destroy(),r.fbo.destroy()}_createObject(r){const g=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),S=new Q(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return S.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),g.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),g.colorAttachment.set(S.texture),{id:r,fbo:g,texture:S,stamp:-1,inUse:!1}}getObjectForId(r){return this._objects[r]}useObject(r){r.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(g=>r.id!==g),this._recentlyUsed.push(r.id)}stampObject(r){r.stamp=++this._stamp}getOrCreateFreeObject(){for(const g of this._recentlyUsed)if(!this._objects[g].inUse)return this._objects[g];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const r=this._createObject(this._objects.length);return this._objects.push(r),r}freeObject(r){r.inUse=!1}freeAllObjects(){for(const r of this._objects)this.freeObject(r)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(r=>!r.inUse)===!1}}const Ad={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Vf{constructor(r,g){this.painter=r,this.terrain=g,this.pool=new Bu(r.context,30,g.sourceCache.tileSize*g.qualityFactor)}destruct(){this.pool.destruct()}getTexture(r){return this.pool.getObjectForId(r.rtt[this._stacks.length-1].id).texture}prepareForRender(r,g){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=r._order.filter(S=>!r._layers[S].isHidden(g)),this._coordsDescendingInv={};for(const S in r.sourceCaches){this._coordsDescendingInv[S]={};const E=r.sourceCaches[S].getVisibleCoordinates();for(const A of E){const ee=this.terrain.sourceCache.getTerrainCoords(A);for(const se in ee)this._coordsDescendingInv[S][se]||(this._coordsDescendingInv[S][se]=[]),this._coordsDescendingInv[S][se].push(ee[se])}}this._coordsDescendingInvStr={};for(const S of r._order){const E=r._layers[S],A=E.source;if(Ad[E.type]&&!this._coordsDescendingInvStr[A]){this._coordsDescendingInvStr[A]={};for(const ee in this._coordsDescendingInv[A])this._coordsDescendingInvStr[A][ee]=this._coordsDescendingInv[A][ee].map(se=>se.key).sort().join()}}for(const S of this._renderableTiles)for(const E in this._coordsDescendingInvStr){const A=this._coordsDescendingInvStr[E][S.tileID.key];A&&A!==S.rttCoords[E]&&(S.rtt=[])}}renderLayer(r){if(r.isHidden(this.painter.transform.zoom))return!1;const g=r.type,S=this.painter,E=this._renderableLayerIds[this._renderableLayerIds.length-1]===r.id;if(Ad[g]&&(this._prevType&&Ad[this._prevType]||this._stacks.push([]),this._prevType=g,this._stacks[this._stacks.length-1].push(r.id),!E))return!0;if(Ad[this._prevType]||Ad[g]&&E){this._prevType=g;const A=this._stacks.length-1,ee=this._stacks[A]||[];for(const se of this._renderableTiles){if(this.pool.isFull()&&(f(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(se),se.rtt[A]){const _e=this.pool.getObjectForId(se.rtt[A].id);if(_e.stamp===se.rtt[A].stamp){this.pool.useObject(_e);continue}}const he=this.pool.getOrCreateFreeObject();this.pool.useObject(he),this.pool.stampObject(he),se.rtt[A]={id:he.id,stamp:he.stamp},S.context.bindFramebuffer.set(he.fbo.framebuffer),S.context.clear({color:i.aM.transparent,stencil:0}),S.currentStencilSource=void 0;for(let _e=0;_e<ee.length;_e++){const Ie=S.style._layers[ee[_e]],Me=Ie.source?this._coordsDescendingInv[Ie.source][se.tileID.key]:[se.tileID];S.context.viewport.set([0,0,he.fbo.width,he.fbo.height]),S._renderTileClippingMasks(Ie,Me),S.renderLayer(S,S.style.sourceCaches[Ie.source],Ie,Me),Ie.source&&(se.rttCoords[Ie.source]=this._coordsDescendingInvStr[Ie.source][se.tileID.key])}}return f(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Ad[g]}return!1}}const Ym={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},Tp=_,qf={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Uc,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,refreshExpiredTiles:!0,scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],zoom:0,bearing:0,pitch:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:i.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0},Gf=R=>{R.touchstart=R.dragStart,R.touchmoveWindow=R.dragMove,R.touchend=R.dragEnd},Hf={showCompass:!0,showZoom:!0,visualizePitch:!1};class ed{constructor(r,g,S=!1){this.mousedown=ee=>{this.startMouse(i.e({},ee,{ctrlKey:!0,preventDefault:()=>ee.preventDefault()}),v.mousePos(this.element,ee)),v.addEventListener(window,"mousemove",this.mousemove),v.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=ee=>{this.moveMouse(ee,v.mousePos(this.element,ee))},this.mouseup=ee=>{this.mouseRotate.dragEnd(ee),this.mousePitch&&this.mousePitch.dragEnd(ee),this.offTemp()},this.touchstart=ee=>{ee.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=v.touchPos(this.element,ee.targetTouches)[0],this.startTouch(ee,this._startPos),v.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),v.addEventListener(window,"touchend",this.touchend))},this.touchmove=ee=>{ee.targetTouches.length!==1?this.reset():(this._lastPos=v.touchPos(this.element,ee.targetTouches)[0],this.moveTouch(ee,this._lastPos))},this.touchend=ee=>{ee.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;const E=r.dragRotate._mouseRotate.getClickTolerance(),A=r.dragRotate._mousePitch.getClickTolerance();this.element=g,this.mouseRotate=ri({clickTolerance:E,enable:!0}),this.touchRotate=(({enable:ee,clickTolerance:se,bearingDegreesPerPixelMoved:he=.8})=>{const _e=new Vr;return new _d({clickTolerance:se,move:(Ie,Me)=>({bearingDelta:(Me.x-Ie.x)*he}),moveStateManager:_e,enable:ee,assignEvents:Gf})})({clickTolerance:E,enable:!0}),this.map=r,S&&(this.mousePitch=vo({clickTolerance:A,enable:!0}),this.touchPitch=(({enable:ee,clickTolerance:se,pitchDegreesPerPixelMoved:he=-.5})=>{const _e=new Vr;return new _d({clickTolerance:se,move:(Ie,Me)=>({pitchDelta:(Me.y-Ie.y)*he}),moveStateManager:_e,enable:ee,assignEvents:Gf})})({clickTolerance:A,enable:!0})),v.addEventListener(g,"mousedown",this.mousedown),v.addEventListener(g,"touchstart",this.touchstart,{passive:!1}),v.addEventListener(g,"touchcancel",this.reset)}startMouse(r,g){this.mouseRotate.dragStart(r,g),this.mousePitch&&this.mousePitch.dragStart(r,g),v.disableDrag()}startTouch(r,g){this.touchRotate.dragStart(r,g),this.touchPitch&&this.touchPitch.dragStart(r,g),v.disableDrag()}moveMouse(r,g){const S=this.map,{bearingDelta:E}=this.mouseRotate.dragMove(r,g)||{};if(E&&S.setBearing(S.getBearing()+E),this.mousePitch){const{pitchDelta:A}=this.mousePitch.dragMove(r,g)||{};A&&S.setPitch(S.getPitch()+A)}}moveTouch(r,g){const S=this.map,{bearingDelta:E}=this.touchRotate.dragMove(r,g)||{};if(E&&S.setBearing(S.getBearing()+E),this.touchPitch){const{pitchDelta:A}=this.touchPitch.dragMove(r,g)||{};A&&S.setPitch(S.getPitch()+A)}}off(){const r=this.element;v.removeEventListener(r,"mousedown",this.mousedown),v.removeEventListener(r,"touchstart",this.touchstart,{passive:!1}),v.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),v.removeEventListener(window,"touchend",this.touchend),v.removeEventListener(r,"touchcancel",this.reset),this.offTemp()}offTemp(){v.enableDrag(),v.removeEventListener(window,"mousemove",this.mousemove),v.removeEventListener(window,"mouseup",this.mouseup),v.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),v.removeEventListener(window,"touchend",this.touchend)}}let no;function yi(R,r,g){const S=new i.N(R.lng,R.lat);if(R=new i.N(R.lng,R.lat),r){const E=new i.N(R.lng-360,R.lat),A=new i.N(R.lng+360,R.lat),ee=g.locationPoint(R).distSqr(r);g.locationPoint(E).distSqr(r)<ee?R=E:g.locationPoint(A).distSqr(r)<ee&&(R=A)}for(;Math.abs(R.lng-g.center.lng)>180;){const E=g.locationPoint(R);if(E.x>=0&&E.y>=0&&E.x<=g.width&&E.y<=g.height)break;R.lng>g.center.lng?R.lng-=360:R.lng+=360}return R.lng!==S.lng&&g.locationPoint(R).y>g.height/2-g.getHorizon()?R:S}
2537const $u={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Vu(R,r,g){const S=R.classList;for(const E in $u)S.remove(`maplibregl-${g}-anchor-${E}`);S.add(`maplibregl-${g}-anchor-${r}`)}class $h extends i.E{constructor(r){if(super(),this._onKeyPress=g=>{const S=g.code,E=g.charCode||g.keyCode;S!=="Space"&&S!=="Enter"&&E!==32&&E!==13||this.togglePopup()},this._onMapClick=g=>{const S=g.originalEvent.target,E=this._element;this._popup&&(S===E||E.contains(S))&&this.togglePopup()},this._update=g=>{var S;if(!this._map)return;const E=this._map.loaded()&&!this._map.isMoving();((g==null?void 0:g.type)==="terrain"||(g==null?void 0:g.type)==="render"&&!E)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?yi(this._lngLat,this._flatPos,this._map.transform):(S=this._lngLat)===null||S===void 0?void 0:S.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let A="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?A=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(A=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let ee="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?ee="rotateX(0deg)":this._pitchAlignment==="map"&&(ee=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||g&&g.type!=="moveend"||(this._pos=this._pos.round()),v.setTransform(this._element,`${$u[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${ee} ${A}`),x.frameAsync(new AbortController).then(()=>{this._updateOpacity(g&&g.type==="moveend")}).catch(()=>{})},this._onMove=g=>{if(!this._isDragging){const S=this._clickTolerance||this._map._clickTolerance;this._isDragging=g.point.dist(this._pointerdownPos)>=S}this._isDragging&&(this._pos=g.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new i.k("dragstart"))),this.fire(new i.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new i.k("dragend")),this._state="inactive"},this._addDragHandler=g=>{this._element.contains(g.originalEvent.target)&&(g.preventDefault(),this._positionDelta=g.point.sub(this._pos).add(this._offset),this._pointerdownPos=g.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=r&&r.anchor||"center",this._color=r&&r.color||"#3FB1CE",this._scale=r&&r.scale||1,this._draggable=r&&r.draggable||!1,this._clickTolerance=r&&r.clickTolerance||0,this._subpixelPositioning=r&&r.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=r&&r.rotation||0,this._rotationAlignment=r&&r.rotationAlignment||"auto",this._pitchAlignment=r&&r.pitchAlignment&&r.pitchAlignment!=="auto"?r.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(r==null?void 0:r.opacity,r==null?void 0:r.opacityWhenCovered),r&&r.element)this._element=r.element,this._offset=i.P.convert(r&&r.offset||[0,0]);else{this._defaultMarker=!0,this._element=v.create("div");const g=v.createNS("http://www.w3.org/2000/svg","svg"),S=41,E=27;g.setAttributeNS(null,"display","block"),g.setAttributeNS(null,"height",`${S}px`),g.setAttributeNS(null,"width",`${E}px`),g.setAttributeNS(null,"viewBox",`0 0 ${E} ${S}`);const A=v.createNS("http://www.w3.org/2000/svg","g");A.setAttributeNS(null,"stroke","none"),A.setAttributeNS(null,"stroke-width","1"),A.setAttributeNS(null,"fill","none"),A.setAttributeNS(null,"fill-rule","evenodd");const ee=v.createNS("http://www.w3.org/2000/svg","g");ee.setAttributeNS(null,"fill-rule","nonzero");const se=v.createNS("http://www.w3.org/2000/svg","g");se.setAttributeNS(null,"transform","translate(3.0, 29.0)"),se.setAttributeNS(null,"fill","#000000");const he=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const Vt of he){const Ht=v.createNS("http://www.w3.org/2000/svg","ellipse");Ht.setAttributeNS(null,"opacity","0.04"),Ht.setAttributeNS(null,"cx","10.5"),Ht.setAttributeNS(null,"cy","5.80029008"),Ht.setAttributeNS(null,"rx",Vt.rx),Ht.setAttributeNS(null,"ry",Vt.ry),se.appendChild(Ht)}const _e=v.createNS("http://www.w3.org/2000/svg","g");_e.setAttributeNS(null,"fill",this._color);const Ie=v.createNS("http://www.w3.org/2000/svg","path");Ie.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),_e.appendChild(Ie);const Me=v.createNS("http://www.w3.org/2000/svg","g");Me.setAttributeNS(null,"opacity","0.25"),Me.setAttributeNS(null,"fill","#000000");const Je=v.createNS("http://www.w3.org/2000/svg","path");Je.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),Me.appendChild(Je);const ut=v.createNS("http://www.w3.org/2000/svg","g");ut.setAttributeNS(null,"transform","translate(6.0, 7.0)"),ut.setAttributeNS(null,"fill","#FFFFFF");const gt=v.createNS("http://www.w3.org/2000/svg","g");gt.setAttributeNS(null,"transform","translate(8.0, 8.0)");const St=v.createNS("http://www.w3.org/2000/svg","circle");St.setAttributeNS(null,"fill","#000000"),St.setAttributeNS(null,"opacity","0.25"),St.setAttributeNS(null,"cx","5.5"),St.setAttributeNS(null,"cy","5.5"),St.setAttributeNS(null,"r","5.4999962");const Lt=v.createNS("http://www.w3.org/2000/svg","circle");Lt.setAttributeNS(null,"fill","#FFFFFF"),Lt.setAttributeNS(null,"cx","5.5"),Lt.setAttributeNS(null,"cy","5.5"),Lt.setAttributeNS(null,"r","5.4999962"),gt.appendChild(St),gt.appendChild(Lt),ee.appendChild(se),ee.appendChild(_e),ee.appendChild(Me),ee.appendChild(ut),ee.appendChild(gt),g.appendChild(ee),g.setAttributeNS(null,"height",S*this._scale+"px"),g.setAttributeNS(null,"width",E*this._scale+"px"),this._element.appendChild(g),this._offset=i.P.convert(r&&r.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",g=>{g.preventDefault()}),this._element.addEventListener("mousedown",g=>{g.preventDefault()}),Vu(this._element,this._anchor,"marker"),r&&r.className)for(const g of r.className.split(" "))this._element.classList.add(g);this._popup=null}addTo(r){return this.remove(),this._map=r,this._element.setAttribute("aria-label",r._getUIString("Marker.Title")),r.getCanvasContainer().appendChild(this._element),r.on("move",this._update),r.on("moveend",this._update),r.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),v.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(r){return this._lngLat=i.N.convert(r),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(r){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),r){if(!("offset"in r.options)){const E=Math.abs(13.5)/Math.SQRT2;r.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[
25370,-38.1],"bottom-left":[E,-1*(38.1-13.5+E)],"bottom-right":[-E,-1*(38.1-13.5+E)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=r,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(r){return this._subpixelPositioning=r,this}getPopup(){return this._popup}togglePopup(){const r=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:r?(r.isOpen()?r.remove():(r.setLngLat(this._lngLat),r.addTo(this._map)),this):this}_updateOpacity(r=!1){var g,S;if(!(!((g=this._map)===null||g===void 0)&&g.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(r)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const E=this._map,A=E.terrain.depthAtPoint(this._pos),ee=E.terrain.getElevationForLngLatZoom(this._lngLat,E.transform.tileZoom);if(E.transform.lngLatToCameraDepth(this._lngLat,ee)-A<.006)return void(this._element.style.opacity=this._opacity);const se=-this._offset.y/E.transform._pixelPerMeter,he=Math.sin(E.getPitch()*Math.PI/180)*se,_e=E.terrain.depthAtPoint(new i.P(this._pos.x,this._pos.y-this._offset.y)),Ie=E.transform.lngLatToCameraDepth(this._lngLat,ee+he)-_e>.006;!((S=this._popup)===null||S===void 0)&&S.isOpen()&&Ie&&this._popup.remove(),this._element.style.opacity=Ie?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(r){return this._offset=i.P.convert(r),this._update(),this}addClassName(r){this._element.classList.add(r)}removeClassName(r){this._element.classList.remove(r)}toggleClassName(r){return this._element.classList.toggle(r)}setDraggable(r){return this._draggable=!!r,this._map&&(r?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(r){return this._rotation=r||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(r){return this._rotationAlignment=r||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(r){return this._pitchAlignment=r&&r!=="auto"?r:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(r,g){return r===void 0&&g===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),r!==void 0&&(this._opacity=r),g!==void 0&&(this._opacityWhenCovered=g),this._map&&this._updateOpacity(!0),this}}const Vh={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let vh=0,bh=!1;const yd={maxWidth:100,unit:"metric"};function wo(R,r,g){const S=g&&g.maxWidth||100,E=R._container.clientHeight/2,A=R.unproject([0,E]),ee=R.unproject([S,E]),se=A.distanceTo(ee);if(g&&g.unit==="imperial"){const he=3.2808*se;he>5280?ea(r,S,he/5280,R._getUIString("ScaleControl.Miles")):ea(r,S,he,R._getUIString("ScaleControl.Feet"))}else g&&g.unit==="nautical"?ea(r,S,se/1852,R._getUIString("ScaleControl.NauticalMiles")):se>=1e3?ea(r,S,se/1e3,R._getUIString("ScaleControl.Kilometers")):ea(r,S,se,R._getUIString("ScaleControl.Meters"))}function ea(R,r,g,S){const E=function(A){const ee=Math.pow(10,`${Math.floor(A)}`.length-1);let se=A/ee;return se=se>=10?10:se>=5?5:se>=3?3:se>=2?2:se>=1?1:function(he){const _e=Math.pow(10,Math.ceil(-Math.log(he)/Math.LN10));return Math.round(he*_e)/_e}(se),ee*se}(g);R.style.width=r*(E/g)+"px",R.innerHTML=`${E}&nbsp;${S}`}const ia={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},qh=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Xm(R){if(R){if(typeof R=="number"){const r=Math.round(Math.abs(R)/Math.SQRT2);return{center:new i.P(0,0),top:new i.P(0,R),"top-left":new i.P(r,r),"top-right":new i.P(-r,r),bottom:new i.P(0,-R),"bottom-left":new i.P(r,-r),"bottom-right":new i.P(-r,-r),left:new i.P(R,0),right:new i.P(-R,0)}}if(R instanceof i.P||Array.isArray(R)){const r=i.P.convert(R);return{center:r,top:r,"top-left":r,"top-right":r,bottom:r,"bottom-left":r,"bottom-right":r,left:r,right:r}}return{center:i.P.convert(R.center||[0,0]),top:i.P.convert(R.top||[0,0]),"top-left":i.P.convert(R["top-left"]||[0,0]),"top-right":i.P.convert(R["top-right"]||[0,0]),bottom:i.P.convert(R.bottom||[0,0]),"bottom-left":i.P.convert(R["bottom-left"]||[0,0]),"bottom-right":i.P.convert(R["bottom-right"]||[0,0]),left:i.P.convert(R.left||[0,0]),right:i.P.convert(R.right||[0,0])}}return Xm(new i.P(0,0))}const Km=_;u.AJAXError=i.bh,u.Evented=i.E,u.LngLat=i.N,u.MercatorCoordinate=i.Z,u.Point=i.P,u.addProtocol=i.bi,u.config=i.a,u.removeProtocol=i.bj,u.AttributionControl
vendor: 4,924 bytes, line 2537
2537=Dc,u.BoxZoomHandler=Ba,u.CanvasSource=rs,u.CooperativeGesturesHandler=jo,u.DoubleClickZoomHandler=_n,u.DragPanHandler=cr,u.DragRotateHandler=bo,u.EdgeInsets=Ae,u.FullscreenControl=class extends i.E{constructor(R={}){super(),this._onFullscreenChange=()=>{var r;let g=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((r=g==null?void 0:g.shadowRoot)===null||r===void 0)&&r.fullscreenElement;)g=g.shadowRoot.fullscreenElement;g===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,R&&R.container&&(R.container instanceof HTMLElement?this._container=R.container:i.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(R){return this._map=R,this._container||(this._container=this._map.getContainer()),this._controlContainer=v.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){v.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const R=this._fullscreenButton=v.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);v.create("span","maplibregl-ctrl-icon",R).setAttribute("aria-hidden","true"),R.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const R=this._getTitle();this._fullscreenButton.setAttribute("aria-label",R),this._fullscreenButton.title=R}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new i.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new i.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},u.GeoJSONSource=Be,u.GeolocateControl=class extends i.E{constructor(R){super(),this._onSuccess=r=>{if(this._map){if(this._isOutOfMapMaxBounds(r))return this._setErrorState(),this.fire(new i.k("outofmaxbounds",r)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=r,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(r),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(r),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new i.k("geolocate",r)),this._finish()}},this._updateCamera=r=>
2537{const g=new i.N(r.coords.longitude,r.coords.latitude),S=r.coords.accuracy,E=this._map.getBearing(),A=i.e({bearing:E},this.options.fitBoundsOptions),ee=He.fromLngLat(g,S);this._map.fitBounds(ee,A,{geolocateSource:!0})},this._updateMarker=r=>{if(r){const g=new i.N(r.coords.longitude,r.coords.latitude);this._accuracyCircleMarker.setLngLat(g).addTo(this._map),this._userLocationDotMarker.setLngLat(g).addTo(this._map),this._accuracy=r.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=r=>{if(this._map){if(this.options.trackUserLocation)if(r.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const g=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=g,this._geolocateButton.setAttribute("aria-label",g),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(r.code===3&&bh)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new i.k("error",r)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",r=>r.preventDefault()),this._geolocateButton=v.create("button","maplibregl-ctrl-geolocate",this._container),v.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=r=>{if(this._map){if(r===!1){i.w("Geolocation support is not available so the GeolocateControl will be disabled.");const g=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=g,this._geolocateButton.setAttribute("aria-label",g)}else{const g=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=g,this._geolocateButton.setAttribute("aria-label",g)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=v.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new $h({element:this._dotElement}),this._circleElement=v.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new $h({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",g=>{g.geolocateSource||this._watchState!=="ACTIVE_LOCK"||g.originalEvent&&g.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new i.k("trackuserlocationend")),this.fire(new i.k("userlocationlostfocus")))})}},this.options=i.e({},Vh,R)}onAdd(R){return this._map=R,this._container=v.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return i._(this,arguments,void 0,function*(r=!1){if(no!==void 0&&!r)return no;if(window.navigator.permissions===void 0)return no=!!window.navigator.geolocation,no;try{no=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{no=!!window.navigator.geolocation}return no})}().then(r=>this._finishSetupUI(r)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),v.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,vh=0,bh=!1}_isOutOfMapMaxBounds(R){const r=this._map.getMaxBounds(),g=R.coords;return r&&(g.longitude<r.getWest()||g.longitude>r.getEast()||g.latitude<r.getSouth()||g.latitude>r.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_E
2537RROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const R=this._map.getBounds(),r=R.getSouthEast(),g=R.getNorthEast(),S=r.distanceTo(g),E=Math.ceil(this._accuracy/(S/this._map._container.clientHeight)*2);this._circleElement.style.width=`${E}px`,this._circleElement.style.height=`${E}px`}trigger(){if(!this._setup)return i.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new i.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":vh--,bh=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new i.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new i.k("trackuserlocationstart")),this.fire(new i.k("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let R;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),vh++,vh>1?(R={maximumAge:6e5,timeout:0},bh=!0):(R=this.options.positionOptions,bh=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,R)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},u.Hash=xs,u.ImageSource=Rt,u.KeyboardHandler=At,u.LngLatBounds=He,u.LogoControl=fo,u.Map=class extends Ac{constructor(R){i.bf.mark(i.bg.create);const r=Object.assign(Object.assign({},qf),R);if(r.minZoom!=null&&r.maxZoom!=null&&r.minZoom>r.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(r.minPitch!=null&&r.maxPitch!=null&&r.minPitch>r.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(r.minPitch!=null&&r.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(r.maxPitch!=null&&r.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Nt(r.minZoom,r.maxZoom,r.minPitch,r.maxPitch,r.renderWorldCopies),{bearingSnap:r.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ua,this._controls=[],this._mapId=i.a4(),this._contextLost=g=>{g.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new i.k("webglcontextlost",{originalEvent:g}))},this._contextRestored=g=>{this._setupPainter(),this.resize(),this._update(),this.fire(new i.k("webglcontextrestored",{originalEvent:g}))},this._onMapScroll=g=>{if(g.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()}
2537,this._interactive=r.interactive,this._maxTileCacheSize=r.maxTileCacheSize,this._maxTileCacheZoomLevels=r.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=r.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=r.preserveDrawingBuffer===!0,this._antialias=r.antialias===!0,this._trackResize=r.trackResize===!0,this._bearingSnap=r.bearingSnap,this._refreshExpiredTiles=r.refreshExpiredTiles===!0,this._fadeDuration=r.fadeDuration,this._crossSourceCollisions=r.crossSourceCollisions===!0,this._collectResourceTiming=r.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Ym),r.locale),this._clickTolerance=r.clickTolerance,this._overridePixelRatio=r.pixelRatio,this._maxCanvasSize=r.maxCanvasSize,this.transformCameraUpdate=r.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=r.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=X.addThrottleControl(()=>this.isMoving()),this._requestManager=new K(r.transformRequest),typeof r.container=="string"){if(this._container=document.getElementById(r.container),!this._container)throw new Error(`Container '${r.container}' not found.`)}else{if(!(r.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=r.container}if(r.maxBounds&&this.setMaxBounds(r.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)).on("moveend",()=>this._update(!1)).on("zoom",()=>this._update(!0)).on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}).once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let g=!1;const S=Ut(E=>{this._trackResize&&!this._removed&&(this.resize(E),this.redraw())},50);this._resizeObserver=new ResizeObserver(E=>{g?S(E):g=!0}),this._resizeObserver.observe(this._container)}this.handlers=new xh(this,r),this._hash=r.hash&&new xs(typeof r.hash=="string"&&r.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch}),r.bounds&&(this.resize(),this.fitBounds(r.bounds,i.e({},r.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=r.localIdeographFontFamily,this._validateStyle=r.validateStyle,r.style&&this.setStyle(r.style,{localIdeographFontFamily:r.localIdeographFontFamily}),r.attributionControl&&this.addControl(new Dc(typeof r.attributionControl=="boolean"?void 0:r.attributionControl)),r.maplibreLogo&&this.addControl(new fo,r.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",g=>{this._update(g.dataType==="style"),this.fire(new i.k(`${g.dataType}data`,g))}),this.on("dataloading",g=>{this.fire(new i.k(`${g.dataType}dataloading`,g))}),this.on("dataabort",g=>{this.fire(new i.k("sourcedataabort",g))})}_getMapId(){return this._mapId}addControl(R,r){if(r===void 0&&(r=R.getDefaultPosition?R.getDefaultPosition():"top-right"),!R||!R.onAdd)return this.fire(new i.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const g=R.onAdd(this);this._controls.push(R);const S=this._controlPositions[r];return r.indexOf("bottom")!==-1?S.insertBefore(g,S.firstChild):S.appendChild(g),this}removeControl(R){if(!R||!R.onRemove)return this.fire(new i.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const r=this._controls.indexOf(R);return r>-1&&this._controls.splice(r,1),R.onRemove(this),this}hasControl(R){return this._controls.indexOf(R)>-1}calculateCameraOptionsFromTo(R,r,g,S){return S==null&&this.terrain&&(S=this.terrain.getElevationForLngLatZoom(g,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(R,r,g,S)}resize(R){var r;const g=this._containerDimensions(),S=g[0],E=g[1],A=this._getClampedPixelRatio(S,E);if(this._resizeCanvas(S,E,A),this.painter.resize(S,E,A),this.painter.overLimit()){const se=this.painter.context.gl;this._maxCanvasSize=[se.drawingBufferWidth,se.drawingBufferHeight];const he=this._getClampedPixelRatio(S,E);this._resizeCanvas(S,E,he),this.painter.resize(S,E,he)}this.transform.resize(S,E),(r=this._requestedCameraState)===null||r===void 0||r.resize(S,E);const ee=!this._moving;return ee&&(this.stop(),this.fire(new i.k("movestart",R)).fire(new i.k("move",R))
vendor: 5,022 bytes, line 2537
2537),this.fire(new i.k("resize",R)),ee&&this.fire(new i.k("moveend",R)),this}_getClampedPixelRatio(R,r){const{0:g,1:S}=this._maxCanvasSize,E=this.getPixelRatio(),A=R*E,ee=r*E;return Math.min(A>g?g/A:1,ee>S?S/ee:1)*E}getPixelRatio(){var R;return(R=this._overridePixelRatio)!==null&&R!==void 0?R:devicePixelRatio}setPixelRatio(R){this._overridePixelRatio=R,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(R){return this.transform.setMaxBounds(He.convert(R)),this._update()}setMinZoom(R){if((R=R??-2)>=-2&&R<=this.transform.maxZoom)return this.transform.minZoom=R,this._update(),this.getZoom()<R&&this.setZoom(R),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(R){if((R=R??22)>=this.transform.minZoom)return this.transform.maxZoom=R,this._update(),this.getZoom()>R&&this.setZoom(R),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(R){if((R=R??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(R>=0&&R<=this.transform.maxPitch)return this.transform.minPitch=R,this._update(),this.getPitch()<R&&this.setPitch(R),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(R){if((R=R??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(R>=this.transform.minPitch)return this.transform.maxPitch=R,this._update(),this.getPitch()>R&&this.setPitch(R),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(R){return this.transform.renderWorldCopies=R,this._update()}project(R){return this.transform.locationPoint(i.N.convert(R),this.style&&this.terrain)}unproject(R){return this.transform.pointLocation(i.P.convert(R),this.terrain)}isMoving(){var R;return this._moving||((R=this.handlers)===null||R===void 0?void 0:R.isMoving())}isZooming(){var R;return this._zooming||((R=this.handlers)===null||R===void 0?void 0:R.isZooming())}isRotating(){var R;return this._rotating||((R=this.handlers)===null||R===void 0?void 0:R.isRotating())}_createDelegatedListener(R,r,g){if(R==="mouseenter"||R==="mouseover"){let S=!1;return{layers:r,listener:g,delegates:{mousemove:A=>{const ee=r.filter(he=>this.getLayer(he)),se=ee.length!==0?this.queryRenderedFeatures(A.point,{layers:ee}):[];se.length?S||(S=!0,g.call(this,new hr(R,this,A.originalEvent,{features:se}))):S=!1},mouseout:()=>{S=!1}}}}if(R==="mouseleave"||R==="mouseout"){let S=!1;return{layers:r,listener:g,delegates:{mousemove:ee=>{const se=r.filter(he=>this.getLayer(he));(se.length!==0?this.queryRenderedFeatures(ee.point,{layers:se}):[]).length?S=!0:S&&(S=!1,g.call(this,new hr(R,this,ee.originalEvent)))},mouseout:ee=>{S&&(S=!1,g.call(this,new hr(R,this,ee.originalEvent)))}}}}{const S=E=>{const A=r.filter(se=>this.getLayer(se)),ee=A.length!==0?this.queryRenderedFeatures(E.point,{layers:A}):[];ee.length&&(E.features=ee,g.call(this,E),delete E.features)};return{layers:r,listener:g,delegates:{[R]:S}}}}_saveDelegatedListener(R,r){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[R]=this._delegatedListeners[R]||[],this._delegatedListeners[R].push(r)}_removeDelegatedListener(R,r,g){if(!this._delegatedListeners||!this._delegatedListeners[R])return;const S=this._delegatedListeners[R];for(let E=0;E<S.length;E++){const A=S[E];if(A.listener===g&&A.layers.length===r.length&&A.layers.every(ee=>r.includes(ee))){for(const ee in A.delegates)this.off(ee,A.delegates[ee]);return void S.splice(E,1)}}}on(R,r,g){if(g===void 0)return super.on(R,r);const S=this._createDelegatedListener(R,typeof r=="string"?[r]:r,g);this._saveDelegatedListener(R,S);for(const E in S.delegates)this.on(E,S.delegates[E]);return this}once(R,r,g){if(g===void 0)return super.once(R,r);const S=typeof r=="string"?[r]:r,E=this._createDelegatedListener(R,S,g);for(const A in E.delegates){const ee=E.delegates[A];E.delegates[A]=(...se)=>{this._removeDelegatedListener(R,S,g),ee(...se)}}this._saveDelegatedListener(R,E);for(const A in E.delegates)this.once(A,E.delegates[A]);return this}off(R,r,g){return g===void 0?super.off(R,r):(this._removeDelegatedListener(R,typeof r=="string"?[r]:r,g),this)}queryRenderedFeatures(R,r){if(!this.style)return[];let g;const S=R instanceof i.P||Array.isArray(R),E=S?R:[[0,0],[this.transform.width,this.transform.height]];if(r=r||(S?{}:R)||{},E instanceof i.P||typeof E[0]=="number")g=[i.P.convert(E)];else{const A=i.P.convert(E[0]),ee=i.P.convert(E[1]);g=[A,new i.P(ee.x,A.y),ee,new i.P(A.x,ee.y),A]}return this.style.queryRenderedFeatures(g,r,this.transform)}querySourceFeatures(R,r){return this.style.querySourceFeatures(R,r)}setStyle(R,r){return(r=i.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._val
2537idateStyle},r)).diff!==!1&&r.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&R?(this._diffStyle(R,r),this):(this._localIdeographFontFamily=r.localIdeographFontFamily,this._updateStyle(R,r))}setTransformRequest(R){return this._requestManager.setTransformRequest(R),this}_getUIString(R){const r=this._locale[R];if(r==null)throw new Error(`Missing UI string '${R}'`);return r}_updateStyle(R,r){if(r.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(R,r));const g=this.style&&r.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!R)),R?(this.style=new oi(this,r||{}),this.style.setEventedParent(this,{style:this.style}),typeof R=="string"?this.style.loadURL(R,r,g):this.style.loadJSON(R,r,g),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new oi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(R,r){if(typeof R=="string"){const g=this._requestManager.transformRequest(R,"Style");i.h(g,new AbortController).then(S=>{this._updateDiff(S.data,r)}).catch(S=>{S&&this.fire(new i.j(S))})}else typeof R=="object"&&this._updateDiff(R,r)}_updateDiff(R,r){try{this.style.setState(R,r)&&this._update(!0)}catch(g){i.w(`Unable to perform style diff: ${g.message||g.error||g}.  Rebuilding the style from scratch.`),this._updateStyle(R,r)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():i.w("There is no style added to the map.")}addSource(R,r){return this._lazyInitEmptyStyle(),this.style.addSource(R,r),this._update(!0)}isSourceLoaded(R){const r=this.style&&this.style.sourceCaches[R];if(r!==void 0)return r.loaded();this.fire(new i.j(new Error(`There is no source with ID '${R}'`)))}setTerrain(R){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),R){const r=this.style.sourceCaches[R.source];if(!r)throw new Error(`cannot load terrain, because there exists no source with ID: ${R.source}`);this.terrain===null&&r.reload();for(const g in this.style._layers){const S=this.style._layers[g];S.type==="hillshade"&&S.source===R.source&&i.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new yh(this.painter,r,R),this.painter.renderToTexture=new Vf(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=g=>{g.dataType==="style"?this.terrain.sourceCache.freeRtt():g.dataType==="source"&&g.tile&&(g.sourceId!==R.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(g.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new i.k("terrain",{terrain:R})),this}getTerrain(){var R,r;return(r=(R=this.terrain)===null||R===void 0?void 0:R.options)!==null&&r!==void 0?r:null}areTilesLoaded(){const R=this.style&&this.style.sourceCaches;for(const r in R){const g=R[r]._tiles;for(const S in g){const E=g[S];if(E.state!=="loaded"&&E.state!=="errored")return!1}}return!0}removeSource(R){return this.style.removeSource(R),this._update(!0)}getSource(R){return this.style.getSource(R)}addImage(R,r,g={}){const{pixelRatio:S=1,sdf:E=!1,stretchX:A,stretchY:ee,content:se,textFitWidth:he,textFitHeight:_e}=g;if(this._lazyInitEmptyStyle(),!(r instanceof HTMLImageElement||i.b(r))){if(r.width===void 0||r.he
vendor: 4,568 bytes, line 2537
2537ight===void 0)return this.fire(new i.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:Ie,height:Me,data:Je}=r,ut=r;return this.style.addImage(R,{data:new i.R({width:Ie,height:Me},new Uint8Array(Je)),pixelRatio:S,stretchX:A,stretchY:ee,content:se,textFitWidth:he,textFitHeight:_e,sdf:E,version:0,userImage:ut}),ut.onAdd&&ut.onAdd(this,R),this}}{const{width:Ie,height:Me,data:Je}=x.getImageData(r);this.style.addImage(R,{data:new i.R({width:Ie,height:Me},Je),pixelRatio:S,stretchX:A,stretchY:ee,content:se,textFitWidth:he,textFitHeight:_e,sdf:E,version:0})}}updateImage(R,r){const g=this.style.getImage(R);if(!g)return this.fire(new i.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const S=r instanceof HTMLImageElement||i.b(r)?x.getImageData(r):r,{width:E,height:A,data:ee}=S;if(E===void 0||A===void 0)return this.fire(new i.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(E!==g.data.width||A!==g.data.height)return this.fire(new i.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const se=!(r instanceof HTMLImageElement||i.b(r));return g.data.replace(ee,se),this.style.updateImage(R,g),this}getImage(R){return this.style.getImage(R)}hasImage(R){return R?!!this.style.getImage(R):(this.fire(new i.j(new Error("Missing required image id"))),!1)}removeImage(R){this.style.removeImage(R)}loadImage(R){return X.getImage(this._requestManager.transformRequest(R,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(R,r){return this._lazyInitEmptyStyle(),this.style.addLayer(R,r),this._update(!0)}moveLayer(R,r){return this.style.moveLayer(R,r),this._update(!0)}removeLayer(R){return this.style.removeLayer(R),this._update(!0)}getLayer(R){return this.style.getLayer(R)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(R,r,g){return this.style.setLayerZoomRange(R,r,g),this._update(!0)}setFilter(R,r,g={}){return this.style.setFilter(R,r,g),this._update(!0)}getFilter(R){return this.style.getFilter(R)}setPaintProperty(R,r,g,S={}){return this.style.setPaintProperty(R,r,g,S),this._update(!0)}getPaintProperty(R,r){return this.style.getPaintProperty(R,r)}setLayoutProperty(R,r,g,S={}){return this.style.setLayoutProperty(R,r,g,S),this._update(!0)}getLayoutProperty(R,r){return this.style.getLayoutProperty(R,r)}setGlyphs(R,r={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(R,r),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(R,r,g={}){return this._lazyInitEmptyStyle(),this.style.addSprite(R,r,g,S=>{S||this._update(!0)}),this}removeSprite(R){return this._lazyInitEmptyStyle(),this.style.removeSprite(R),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(R,r={}){return this._lazyInitEmptyStyle(),this.style.setSprite(R,r,g=>{g||this._update(!0)}),this}setLight(R,r={}){return this._lazyInitEmptyStyle(),this.style.setLight(R,r),this._update(!0)}getLight(){return this.style.getLight()}setSky(R){return this._lazyInitEmptyStyle(),this.style.setSky(R),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(R,r){return this.style.setFeatureState(R,r),this._update()}removeFeatureState(R,r){return this.style.removeFeatureState(R,r),this._update()}getFeatureState(R){return this.style.getFeatureState(R)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let R=0,r=0;return this._container&&(R=this._container.clientWidth||400,r=this._container.clientHeight||300),[R,r]}_setupContainer(){const R=this._container;R.classList.add("maplibregl-map");const r=this._canvasContainer=v.create("div","maplibregl-canvas-container",R);this._interactive&&r.classList.add("maplibregl-interactive"),this._canvas=v.create("canvas","maplibregl-canvas",r),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","regi
2537on");const g=this._containerDimensions(),S=this._getClampedPixelRatio(g[0],g[1]);this._resizeCanvas(g[0],g[1],S);const E=this._controlContainer=v.create("div","maplibregl-control-container",R),A=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(ee=>{A[ee]=v.create("div",`maplibregl-ctrl-${ee} `,E)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(R,r,g){this._canvas.width=Math.floor(g*R),this._canvas.height=Math.floor(g*r),this._canvas.style.width=`${R}px`,this._canvas.style.height=`${r}px`}_setupPainter(){const R={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let r=null;this._canvas.addEventListener("webglcontextcreationerror",S=>{r={requestedAttributes:R},S&&(r.statusMessage=S.statusMessage,r.type=S.type)},{once:!0});const g=this._canvas.getContext("webgl2",R)||this._canvas.getContext("webgl",R);if(!g){const S="Failed to initialize WebGL";throw r?(r.message=S,new Error(JSON.stringify(r))):new Error(S)}this.painter=new G(g,this.transform),C.testSupport(g)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(R){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||R,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(R){return this._update(),this._renderTaskQueue.add(R)}_cancelRenderFrame(R){this._renderTaskQueue.remove(R)}_render(R){const r=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(R),this._removed)return;let g=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const E=this.transform.zoom,A=x.now();this.style.zoomHistory.update(E,A);const ee=new i.z(E,{now:A,fadeDuration:r,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),se=ee.crossFadingFactor();se===1&&se===this._crossFadingFactor||(g=!0,this._crossFadingFactor=se),this.style.update(ee)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,r,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:r,showPadding:this.showPadding}),this.fire(new i.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,i.bf.mark(i.bg.load),this.fire(new i.k("load"))),this.style&&(this.style.hasTransitions()||g)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const S=this._sourcesDirty||this._styleDirty||this._placementDirty;return S||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new i.k("idle")),!this._loaded||this._fullyLoaded||S||(this._fullyLoaded=!0,i.bf.mark(i.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var R;this._hash&&this._hash.remove();for(const g of this._controls)g.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),X.removeThrottleControl(this._imageQueueHandle),(R=this._resizeObserver)===null||R===void 0||R.disconnect();const r=this.painter.context.gl.getExtension("WEBGL_lose_context");r!=null&&r.loseContext&&r.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),v.remove(this._canvasContainer),v.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),i.bf.clearMetrics(),this._removed=!0,this.fire(new i.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,x.frameAsync(this._frameRequest).then(R=>{i.bf.frame(R),this._frameRequest=null,this._render(R)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(R){this._showTileBoundaries!==R&&(this._showTileBoundaries=R,this._update())}get showPadding(){return!!this._showPadding}set showPadding(R){this._showPadding!==R&&(this._showPadding=R,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(R){this._showCollisionBoxes!==R&&(this._showCollisionBoxes=R,R?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(R){this._showOverdrawInspector!==R&&(this._showOverdrawInspector=R,this._update())}get repaint(){return!!this._repaint}set repaint(R){this._repaint!==R&&(this._repaint=R,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(R){this._vertices=R,this._update()}get version(){return Tp}getCameraTargetElevation(){return this.transform.elevation}},u.MapMouseEvent=hr,u.MapTouchEvent=mo,u.MapWheelEvent=Ud,u.Marker=$h,u.NavigationControl
vendor: 5,121 bytes, line 2537
2537=class{constructor(R){this._updateZoomButtons=()=>{const r=this._map.getZoom(),g=r===this._map.getMaxZoom(),S=r===this._map.getMinZoom();this._zoomInButton.disabled=g,this._zoomOutButton.disabled=S,this._zoomInButton.setAttribute("aria-disabled",g.toString()),this._zoomOutButton.setAttribute("aria-disabled",S.toString())},this._rotateCompassArrow=()=>{const r=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=r},this._setButtonTitle=(r,g)=>{const S=this._map._getUIString(`NavigationControl.${g}`);r.title=S,r.setAttribute("aria-label",S)},this.options=i.e({},Hf,R),this._container=v.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",r=>r.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",r=>this._map.zoomIn({},{originalEvent:r})),v.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",r=>this._map.zoomOut({},{originalEvent:r})),v.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",r=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:r}):this._map.resetNorth({},{originalEvent:r})}),this._compassIcon=v.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(R){return this._map=R,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ed(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){v.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(R,r){const g=v.create("button",R,this._container);return g.type="button",g.addEventListener("click",r),g}},u.Popup=class extends i.E{constructor(R){super(),this.remove=()=>(this._content&&v.remove(this._content),this._container&&(v.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new i.k("close"))),this),this._onMouseUp=r=>{this._update(r.point)},this._onMouseMove=r=>{this._update(r.point)},this._onDrag=r=>{this._update(r.point)},this._update=r=>{var g;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=v.create("div","maplibregl-popup",this._map.getContainer()),this._tip=v.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const se of this.options.className.split(" "))this._container.classList.add(se);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?yi(this._lngLat,this._flatPos,this._map.transform):(g=this._lngLat)===null||g===void 0?void 0:g.wrap(),this._trackPointer&&!r)return;const S=this._flatPos=this._pos=this._trackPointer&&r?r:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&r?r:this._map.transform.locationPoint(this._lngLat));let E=this.options.anchor;const A=Xm(this.options.offset);if(!E){const se=this._container.offsetWidth,he=this._container.offsetHeight;let _e;_e=S.y+A.bottom.y<he?["top"]:S.y>this._map.transform.height-he?["bottom"]:[],S.x<se/2?_e.push("left"):S.x>this._map.transform.width-se/2&&_e.push("right"),E=_e.length===0?"bottom":_e.join("-")}let ee=S.add(A[E]);this.options.subpixelPositioning||(ee=ee.round()),v.setTransform(this._container,`${$u[E]} translate(${ee.x}px,${ee.y}px)`),Vu(this._container,E,"popup")},this._onClose=()=>{this.remove()},this.options=i.e(Object.create(ia),R)}
vendor: 4,482 bytes, line 2537
2537addTo(R){return this._map&&this.remove(),this._map=R,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new i.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(R){return this._lngLat=i.N.convert(R),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(R){return this.setDOMContent(document.createTextNode(R))}setHTML(R){const r=document.createDocumentFragment(),g=document.createElement("body");let S;for(g.innerHTML=R;S=g.firstChild,S;)r.appendChild(S);return this.setDOMContent(r)}getMaxWidth(){var R;return(R=this._container)===null||R===void 0?void 0:R.style.maxWidth}setMaxWidth(R){return this.options.maxWidth=R,this._update(),this}setDOMContent(R){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=v.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(R),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(R){return this._container&&this._container.classList.add(R),this}removeClassName(R){return this._container&&this._container.classList.remove(R),this}setOffset(R){return this.options.offset=R,this._update(),this}toggleClassName(R){if(this._container)return this._container.classList.toggle(R)}setSubpixelPositioning(R){this.options.subpixelPositioning=R}_createCloseButton(){this.options.closeButton&&(this._closeButton=v.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const R=this._container.querySelector(qh);R&&R.focus()}},u.RasterDEMTileSource=Ce,u.RasterTileSource=Xe,u.ScaleControl=class{constructor(R){this._onMove=()=>{wo(this._map,this._container,this.options)},this.setUnit=r=>{this.options.unit=r,wo(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},yd),R)}getDefaultPosition(){return"bottom-left"}onAdd(R){return this._map=R,this._container=v.create("div","maplibregl-ctrl maplibregl-ctrl-scale",R.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){v.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},u.ScrollZoomHandler=Os,u.Style=oi,u.TerrainControl=class{constructor(R){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=R}onAdd(R){return this._map=R,this._container=v.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=v.create("button","maplibregl-ctrl-terrain",this._container),v.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.t
2537ype="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){v.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},u.TwoFingersTouchPitchHandler=Se,u.TwoFingersTouchRotateHandler=Y,u.TwoFingersTouchZoomHandler=p,u.TwoFingersTouchZoomRotateHandler=zi,u.VectorTileSource=vt,u.VideoSource=zt,u.addSourceType=(R,r)=>i._(void 0,void 0,void 0,function*(){if(vs(R))throw new Error(`A source type called "${R}" already exists.`);((g,S)=>{_s[g]=S})(R,r)}),u.clearPrewarmedResources=function(){const R=dt;R&&(R.isPreloaded()&&R.numActive()===1?(R.release(ke),dt=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},u.getMaxParallelImageRequests=function(){return i.a.MAX_PARALLEL_IMAGE_REQUESTS},u.getRTLTextPluginStatus=function(){return bs().getRTLTextPluginStatus()},u.getVersion=function(){return Km},u.getWorkerCount=function(){return ze.workerCount},u.getWorkerUrl=function(){return i.a.WORKER_URL},u.importScriptInWorkers=function(R){return Fe().broadcast("IS",R)},u.prewarm=function(){qt().acquire(ke)},u.setMaxParallelImageRequests=function(R){i.a.MAX_PARALLEL_IMAGE_REQUESTS=R},u.setRTLTextPlugin=function(R,r){return bs().setRTLTextPlugin(R,r)},u.setWorkerCount=function(R){ze.workerCount=R},u.setWorkerUrl=function(R){i.a.WORKER_URL=R}});var c=n;return c})})(UT);var tL=UT.exports;const Lg=w1(tL),Gq=s3({__proto__:null,default:Lg},[tL]);function Hq(t,s,n,a,l,c,u,i){var _;if(!(l.length<3))try{const j=l.map(([K,te])=>({lat:te,lng:K})),y=g_(s),x=p_({parkingOverlay:s,allOverlays:c,settings:y}),v=[...x.zones,...x.stallOnlyZones],C=s.style||{},P={stallWidth_ft:s.parking_stall_width_ft||9,stallDepth_ft:s.parking_stall_depth_ft||18,aisleWidth_ft:s.parking_aisle_width_ft||24,layoutType:s.parking_layout_type||"double_loaded",stripingVisible:!0,aisleLabelsVisible:s.parking_aisle_labels_visible!==!1,exclusionZones:v,maxStallRun:C.parking_max_stall_run||void 0,islandType:C.parking_island_type||"painted",islandWidth_ft:C.parking_island_width_ft||(C.parking_island_type==="landscape"?6:4),islandTrees:C.parking_island_trees===!0,islandCrossAisle:C.parking_island_cross_aisle!==!1,islandTreeSpecies:C.parking_island_tree_species||"deciduous",islandTreeHeight_ft:C.parking_island_tree_height_ft||30,islandCanopyDiameter_ft:C.parking_island_canopy_diameter_ft||15,islandCustomModelId:C.parking_island_custom_model_id||void 0,islandCustomModelUrl:C.parking_island_custom_model_url||void 0};let I=Hm(j,P);const z=(_=s.style)==null?void 0:_.parkingCirculation,F=z==null?void 0:z.stallOverrides,D=z==null?void 0:z.rowOverrides;if((F&&Object.keys(F).length>0||D&&Object.keys(D).length>0)&&(I=H0(I,F||{},D)),u.stallEditorEnabled&&u.selectedOverlayId===s.id){const K=`${n}-stall-click-targets`,te=`${a}-stall-click-targets`,J=`${a}-stall-click-highlight`,H=I.stalls.map(oe=>{const ce=u.selectedStallId===oe.id;return{type:"Feature",geometry:{type:"Polygon",coordinates:[[...oe.geometry.map(ae=>[ae.lng,ae.lat]),[oe.geometry[0].lng,oe.geometry[0].lat]]]},properties:{id:oe.id,isAda:oe.isAda,isSelected:ce,overlayId:s.id}}});t.addSource(K,{type:"geojson",data:{type:"FeatureCollection",features:H}}),t.addLayer({id:te,type:"fill",source:K,paint:{"fill-color":"#ffffff","fill-opacity":.01}}),t.addLayer({id:J,type:"fill",source:K,filter:["==",["get","isSelected"],!0],paint:{"fill-color":"#f97316","fill-opacity":.3}}),i([te,J,K]);const O=`${n}-row-click-targets`,q=`${a}-row-click-targets`,W=`${a}-row-click-highlight`,Q={};I.stalls.filter(oe=>!oe.isRemoved).forEach(oe=>{const ce=oe.id.split("-"),ae=`row-${ce[1]}-${ce[2]||"top"}`;Q[ae]||(Q[ae]=[]),oe.geometry.forEach(ie=>Q[ae].push(ie))});const Z=[];Object.entries(Q).forEach(([oe,ce])=>{if(ce.length<4)return;const ae=ce.map(ke=>ke.lat),ie=ce.map(ke=>ke.lng),de=Math.min(...ae),ge=Math.max(...ae),We=Math.min(...ie),Ee=Math.max(...ie),ve=(ge-de)*.15,Ze=oe.includes("-top")?[[We,ge],[Ee,ge],[Ee,ge-ve],[We,ge-ve],[We,ge]]:[[We,de],[Ee,de],[Ee,de+ve],[We,de+ve],[We,de]];Z.push({type:"Feature",geometry:{type:"Polygon",coordinates:[Ze]},properties:{id:oe,isSelected:u.selectedStallId===oe,overlayId:s.id}})}),Z.length>0&&(t.addSource(O,{type:"geojson",data:{type:"FeatureCollection",features:Z}}
2537),t.addLayer({id:q,type:"fill",source:O,paint:{"fill-color":"#22c55e","fill-opacity":.02}}),t.addLayer({id:W,type:"fill",source:O,filter:["==",["get","isSelected"],!0],paint:{"fill-color":"#22c55e","fill-opacity":.4}}),i([q,W,O]))}P.aisleLabelsVisible&&I.driveAisles.length>0&&I.driveAisles.forEach(K=>{if(K.labelPosition&&K.labelText){const te=document.createElement("div");te.innerHTML=`<div style="
2538            background: rgba(0,0,0,0.7);
2539            color: white;
2540            padding: 2px 6px;
2541            border-radius: 3px;
2542            font-size: 10px;
2543            font-weight: 500;
2544            white-space: nowrap;
2545            transform: translate(-50%, -50%);
2546          ">${K.labelText}</div>`;const J=new Lg.Marker({element:te}).setLngLat([K.labelPosition.lng,K.labelPosition.lat]).addTo(t);J._isParkingLabel=!0,J._overlayId=s.id}})}catch(j){console.warn(`Failed to render parking interaction for ${s.name}:`,j)}}const Zq=.35*2;function Wq(t){return(t.building_buffer_thickness_in||8)/12*.3048}function Yq(t,s,n,a,l,c,u,i){const _=s.parent_overlay_id,j=_?c.get(_):void 0,y=(j==null?void 0:j.floor_height_ft)||12,x=(j==null?void 0:j.base_elevation_ft)||0,v=s.floor_level||1,P=(s.floor_thickness_in||6)/12,I=x+(v-1)*y,z=j?Wq(j):Zq,F=I*.3048+z,D=P*.3048,X=.02;if((j==null?void 0:j.show_column_grid)===!0){const te=s.geometry;br(async()=>{const{addFloorSlab3D:J}=await import("./floorSlab3DRenderer-CXkN0Q74.js");return{addFloorSlab3D:J}},__vite__mapDeps([35,33,1,2,12,4,5,11,8,10,13,3,6,9,15,16,17,20,14,21,22,19,23,24,25,18,26,27,28])).then(({addFloorSlab3D:J})=>{try{const H=J(t,a,te,I,P,x,z,l);i([H])}catch(H){console.warn("[FloorSlab] Failed to add 3D slab:",H)}}).catch(J=>console.warn("[FloorSlab] Failed to load 3D renderer:",J))}else u({id:a,type:"fill-extrusion",source:n,paint:{"fill-extrusion-color":"#b0b0b0","fill-extrusion-height":(F+D+X)*l,"fill-extrusion-base":(F+X)*l,"fill-extrusion-opacity":.9,"fill-extrusion-vertical-gradient":!1}})}function Xq(t,s,n,a){try{const l=g_(t),c=p_({parkingOverlay:t,allOverlays:n,settings:l,getBuildingWithBuffer:wf});if(c.zones.length>0){let u=Xn(a.coordinates);for(const i of c.zones)if(i.length>=3){const _=i.map(y=>[y.lng,y.lat]);_.push(_[0]);const j=Xn([_]);try{const x=pd({type:"FeatureCollection",features:[u,j]});x&&x.geometry&&(u=x)}catch(y){console.warn("Failed to subtract exclusion zone from parking:",y)}}if(u.geometry)return u.geometry}}catch(l){console.warn("Failed to process parking exclusions for 3D:",l)}return a}function Kq(t,s){if(Math.abs(s)<.1)return t;const n=-s*Math.PI/180,a=Math.cos(n),l=Math.sin(n);let c=0,u=0;for(const[i,_]of t)c+=i,u+=_;return c/=t.length,u/=t.length,t.map(([i,_])=>{const j=i-c,y=_-u;return[c+j*a-y*l,u+j*l+y*a]})}function Jq(t){return!!(t.image_url&&t.geometry&&t.geometry.length>=3)}const jC=new Map;function Qq(t,s){const n=s*Math.PI/180,a=document.createElement("canvas");a.width=t.width,a.height=t.height;const l=a.getContext("2d");return l?(l.clearRect(0,0,a.width,a.height),l.translate(a.width/2,a.height/2),l.rotate(n),l.drawImage(t,-t.width/2,-t.height/2,t.width,t.height),a.toDataURL("image/png")):""}function Uq(t,s,n){const a=Kd();if(!s.image_url||n.length<3)return a;const l=`overlay-image-${s.id}`,c=`overlay-image-layer-${s.id}`,u=s.rotation_degrees||0,i=s.image_url,_=Kq(n,u);let j=1/0,y=1/0,x=-1/0,v=-1/0;for(const[z,F]of _)z<j&&(j=z),z>x&&(x=z),F<y&&(y=F),F>v&&(v=F);const C=[[j,v],[x,v],[x,y],[j,y]];
2546if(Math.abs(u)<.1){try{t.getLayer(c)&&t.removeLayer(c),t.getSource(l)&&t.removeSource(l),t.addSource(l,{type:"image",url:i,coordinates:C}),a.sourceIds.push(l),t.addLayer({id:c,type:"raster",source:l,paint:{"raster-opacity":s.opacity??.85,"raster-fade-duration":0}}),a.layerIds.push(c)}catch(z){console.warn("[imageOverlayRenderer] Failed:",z)}return a}const P=jC.get(s.id);if(P&&P.rotation===u&&P.sourceUrl===s.image_url){try{t.getLayer(c)&&t.removeLayer(c),t.getSource(l)&&t.removeSource(l),t.addSource(l,{type:"image",url:P.url,coordinates:C}),a.sourceIds.push(l),t.addLayer({id:c,type:"raster",source:l,paint:{"raster-opacity":s.opacity??.85,"raster-fade-duration":0}}),a.layerIds.push(c)}catch(z){console.warn("[imageOverlayRenderer] Failed:",z)}return a}const I=new Image;return I.crossOrigin="anonymous",I.onload=()=>{const z=Qq(I,u);if(z){jC.set(s.id,{url:z,rotation:u,sourceUrl:s.image_url});try{t.getLayer(c)&&t.removeLayer(c),t.getSource(l)&&t.removeSource(l),t.addSource(l,{type:"image",url:z,coordinates:C}),t.addLayer({id:c,type:"raster",source:l,paint:{"raster-opacity":s.opacity??.85,"raster-fade-duration":0}})}catch(F){console.warn("[imageOverlayRenderer] Failed:",F)}}},I.src=s.image_url,a.sourceIds.push(l),a.layerIds.push(c),a}function eG(t,s,n,a,l,c){var z,F;const u=Kd(),i=D=>{D.forEach(X=>{!u.layerIds.includes(X)&&!u.sourceIds.includes(X)&&u.layerIds.push(X)})},_=`overlay-${s.id}`,j=`overlay-layer-${s.id}`,y=s.geometry;if(!y||y.length<2)return u;const x=y.map(D=>[D.lng,D.lat]),v=s.type==="polygon"||s.type==="county"||s.type==="township"||s.type==="state"||s.type==="parcel";let C=v&&x.length>=3?{type:"Polygon",coordinates:[[...x,x[0]]]}:{type:"LineString",coordinates:x};const P=s.layer_type,I=P==="parking"||P==="parking_field"||P==="parking_zone";if(I&&v&&x.length>=3)try{C=Xq(s,x,a,C)}catch(D){console.warn("Failed to process parking exclusions for 3D:",D)}try{const D={type:"Feature",geometry:C,properties:{name:s.name}};Ir(t,_,{type:"geojson",data:D},u);const X=s.style||{};if(v&&x.length>=3){const J=`${j}-fill`,H=s.height_ft;if(s.layer_type==="building_floor")Yq(t,s,_,J,l.buildingHeight,l.overlaysById,O=>jr(t,O,u),O=>i(O));else if(H&&H>0){const O=BV(t,s,_,j,x,C,l);u.layerIds.push(...O.layerIds),u.sourceIds.push(...O.sourceIds);const q=xq(s,_,j,J,x,y,X,l,W=>i(W));u.layerIds.push(...q.layerIds),u.sourceIds.push(...q.sourceIds)}else{const O=jq(t,s,_,J,X);u.layerIds.push(...O.layerIds),u.sourceIds.push(...O.sourceIds)}u.layerIds.push(J)}const K=X.weight??2;K>0&&jr(t,{id:j,type:"line",source:_,paint:{"line-color":X.color||"#3b82f6","line-width":K}},u),Bq(t,s,_,j,J=>i(J));const te=oo(s.layer_type)||rm(s.layer_type)||bf(s.layer_type);if((z=s.style)!=null&&z.landscapeBuffers&&te&&x.length>=3&&Rq(t,s,_,j,x,J=>i(J)),I&&s.parking_striping_visible!==!1&&x.length>=3)try{Eq(t,s,_,j,x,a,J=>i(J))}catch(J){console.warn("Failed to render parking striping in 3D:",J)}if(I&&x.length>=3&&Hq(t,s,_,j,x,a,{stallEditorEnabled:l.stallEditorEnabled,selectedOverlayId:l.selectedOverlayId,selectedStallId:l.selectedStallId},J=>i(J)),(F=s.style)!=null&&F.landscapeBuffers&&x.length>=3&&Fq(t,s,_,j,x,a,l.buildingHeight,J=>i(J)),$q(t,s,x,a,J=>i(J),c!=null&&c.onEntryPointClick?(J,H)=>c.onEntryPointClick(J,H,s):void 0),qq(t,s,x,J=>i(J)),Jq(s)){const J=Uq(t,s,x);u.layerIds.push(...J.layerIds),u.sourceIds.push(...J.sourceIds)}}catch(D){console.warn(`Failed to add overlay ${s.name}:`,D)}return u}function tG(t,s){const n={id:t.id,geometry:t.geometry,type:t.type,name:t.name,is_visible:t.is_visible,folder_id:t.folder_id,parent_overlay_id:t.parent_overlay_id,height_ft:t.height_ft,style:t.style,layer_type:t.layer_type,building_type:t.building_type,rotation_degrees:t.rotation_degrees,opacity:t.opacity,updated_at:t.updated_at,bh:s.buildingHeight,bo:s.buildingOpacity,se:s.stallEditorEnabled&&s.selectedOverlayId===t.id,ss:s.stallEditorEnabled&&s.selectedOverlayId===t.id?s.selectedStallId:null};if(t.layer_type==="parking"&&t.parent_overlay_id&&s.allOverlays){const a=s.allOverlays.filter(l=>l.parent_overlay_id===t.parent_overlay_id&&l.layer_type==="building_footprint"&&l.id!==t.id);a.length>
25460&&(n._siblingBuildings=a.map(l=>({id:l.id,geometry:l.geometry,building_buffer_ft:l.building_buffer_ft,updated_at:l.updated_at})))}return JSON.stringify(n)}class sG{constructor(){za(this,"overlayStates",new Map)}renderIncremental(s,n,a){const l={added:0,updated:0,removed:0,unchanged:0},c=new Set(s.map(u=>u.id));for(const[u,i]of this.overlayStates)c.has(u)||(this.cleanupOverlay(n.map,u),l.removed++);return s.forEach((u,i)=>{const _=tG(u,n),j=this.overlayStates.get(u.id);if(j&&j.fingerprint===_){l.unchanged++;return}if(j){for(const y of j.results)mC(n.map,y);l.updated++}else l.added++;try{const y=a(u,i);this.overlayStates.set(u.id,{fingerprint:_,results:y})}catch(y){console.error(`[OverlayOrchestrator] Failed to render overlay ${u.id}:`,y),this.overlayStates.set(u.id,{fingerprint:"",results:[]})}}),l}cleanupOverlay(s,n){const a=this.overlayStates.get(n);if(a){for(const l of a.results)mC(s,l);this.overlayStates.delete(n)}}cleanupAll(s){for(const[n]of this.overlayStates)this.cleanupOverlay(s,n);this.overlayStates.clear()}invalidate(s){const n=this.overlayStates.get(s);n&&(n.fingerprint="")}invalidateAll(){for(const s of this.overlayStates.values())s.fingerprint=""}getAllLayerIds(){const s=[];for(const n of this.overlayStates.values())for(const a of n.results)s.push(...a.layerIds,...a.sourceIds);return s}addResults(s,n){const a=this.overlayStates.get(s);a&&a.results.push(...n)}get size(){return this.overlayStates.size}}function ux(t){const{active:s,map:n,isMapReady:a,overlay:l,highlightId:c,highlightColor:u,onHover:i,onClick:_,paintExpression:j,currentEdges:y}=t;k.useEffect(()=>{if(!n||!a||!s||!l)return;const x=l.geometry;if(!x||x.length<3)return;const v=x.map(F=>[F.lng,F.lat]),C=c,P=`${c}-layer`;n.getSource(C)||n.addSource(C,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),n.getLayer(P)||n.addLayer({id:P,type:"line",source:C,paint:{"line-color":j??u,"line-width":6,"line-opacity":j?.9:.8}});const I=F=>{const D=[F.lngLat.lng,F.lngLat.lat],X=l0(D,v);i(X);const K=PP(v,X);y&&(K.properties={...K.properties,selected:y.includes(X)});const te=n.getSource(C);te&&te.setData({type:"FeatureCollection",features:[K]}),n.getCanvas().style.cursor="crosshair"},z=F=>{const D=[F.lngLat.lng,F.lngLat.lat],X=l0(D,v);_(X)};return n.on("mousemove",I),n.on("click",z),()=>{n.off("mousemove",I),n.off("click",z),n.getCanvas().style.cursor="",n.getLayer(P)&&n.removeLayer(P),n.getSource(C)&&n.removeSource(C)}},[s,n,a,l,c,u,i,_,j,y])}function nG(t,s,n,a){const[l,c]=k.useState(!1),[u,i]=k.useState(!1),[_,j]=k.useState(!1),[y,x]=k.useState(!1),[v,C]=k.useState(!1),[P,I]=k.useState(null),[z,F]=k.useState(null),D=k.useCallback(()=>{var de,ge;c(!1),I(null),F(null),(de=t.current)!=null&&de.getLayer("dock-edge-highlight")&&t.current.removeLayer("dock-edge-highlight"),(ge=t.current)!=null&&ge.getSource("dock-edge-highlight")&&t.current.removeSource("dock-edge-highlight")},[t]),X=k.useCallback(()=>{c(!0),I(null),F(null)},[]),K=k.useCallback(de=>{if(!s)return;const ge=s.dock_edge_indices||[];if(ge.length===1&&!ge.includes(de)){const We=[...ge,de];a(s.id,{dock_edge_indices:We}),Ve.success(`Cross dock configured on edges ${We.join(" and ")}`)}else a(s.id,{dock_edge_indices:[de]}),Ve.success(`Dock face set to edge ${de}`);D()},[s,a,D]),te=k.useCallback(()=>{var de,ge;i(!1),I(null),(de=t.current)!=null&&de.getLayer("window-edge-highlight")&&t.current.removeLayer("window-edge-highlight"),(ge=t.current)!=null&&ge.getSource("window-edge-highlight")&&t.current.removeSource("window-edge-highlight")},[t]),J=k.useCallback(()=>{i(!0),c(!1),I(null)},[]),H=k.useCallback(de=>{if(!s)return;const ge=s.window_edge_indices||[];if(ge.includes(de)){const We=ge.filter(Ee=>Ee!==de);a(s.id,{window_edge_indices:We.length>0?We:null}),Ve.success(We.length>0?`Window face removed from edge ${de}`:"Window faces cleared")}else{const We=[...ge,de];a(s.id,{window_edge_indices:We}),Ve.success(`Window face added on edge ${de}`)}te()},[s,a,te]),O=k.useCallback(()=>{var de,ge;j(!1),I(null),(de=t.current)!=null&&de.getLayer("canopy-edge-highlight")&&t.current.removeLayer("canopy-edge-highlight"),(ge=t.current)!=null&&ge.getSource("canopy-edge-highlight")&&t.current.removeSource("canopy-edge-highlight")},[t]),q=k.useCallback(()=>{j(!0),c(!1),i(!1),x(!1),I(null)},[]),W=k.useCallback(de=>{if(!s)return;const ge=n.find(Ee=>Ee.id===s.id);if(!ge)return;const We=ge.canopy_edge_indices||[];if(We.includes(de)){const Ee=We.filter(ve=>ve!==de);a(s.id,{canopy_edge_indices:Ee.length>0?Ee:null}),Ve.success(Ee.length>0?`Canopy removed from edge ${de}`:"Canopy edges cleared - using all sides")}else{const Ee=[...We,de];a(s.id,{canopy_edge_indices:Ee}),Ve.success(`Canopy added on edge ${de}`)}
2546O()},[s,n,a,O]),Q=k.useCallback(()=>{var de,ge;x(!1),I(null),(de=t.current)!=null&&de.getLayer("storefront-edge-highlight")&&t.current.removeLayer("storefront-edge-highlight"),(ge=t.current)!=null&&ge.getSource("storefront-edge-highlight")&&t.current.removeSource("storefront-edge-highlight")},[t]),Z=k.useCallback(()=>{x(!0),c(!1),i(!1),j(!1),I(null)},[]),oe=k.useCallback(de=>{if(!s)return;const ge=n.find(Ee=>Ee.id===s.id);if(!ge)return;const We=ge.storefront_edge_indices||[];if(We.includes(de)){const Ee=We.filter(ve=>ve!==de);a(s.id,{storefront_edge_indices:Ee.length>0?Ee:null}),Ve.success(Ee.length>0?`Storefront removed from edge ${de}`:"Storefront edges cleared - using all sides")}else{const Ee=[...We,de];a(s.id,{storefront_edge_indices:Ee}),Ve.success(`Storefront added on edge ${de}`)}},[s,n,a]),ce=k.useCallback(()=>{var de,ge;C(!1),I(null),(de=t.current)!=null&&de.getLayer("drivein-edge-highlight")&&t.current.removeLayer("drivein-edge-highlight"),(ge=t.current)!=null&&ge.getSource("drivein-edge-highlight")&&t.current.removeSource("drivein-edge-highlight")},[t]),ae=k.useCallback(()=>{C(!0),c(!1),i(!1),I(null)},[]),ie=k.useCallback(de=>{if(!s)return;const ge=n.find(Ee=>Ee.id===s.id);if(!ge)return;const We=ge.drive_in_door_edge_indices||[];if(We.includes(de)){const Ee=We.filter(ve=>ve!==de);a(s.id,{drive_in_door_edge_indices:Ee.length>0?Ee:null}),Ve.success(Ee.length>0?`Drive-in door removed from edge ${de}`:"Drive-in door edges cleared")}else{const Ee=[...We,de];a(s.id,{drive_in_door_edge_indices:Ee}),Ve.success(`Drive-in door added on edge ${de}`)}},[s,n,a]);return{dockEdgeSelectionMode:l,windowEdgeSelectionMode:u,canopyEdgeSelectionMode:_,storefrontEdgeSelectionMode:y,driveInEdgeSelectionMode:v,hoveredEdgeIndex:P,pendingDockEdgeIndex:z,handleStartDockEdgeSelection:X,handleCancelDockEdgeSelection:D,handleDockEdgeClick:K,handleStartWindowEdgeSelection:J,handleCancelWindowEdgeSelection:te,handleWindowEdgeClick:H,handleStartCanopyEdgeSelection:q,handleCancelCanopyEdgeSelection:O,handleCanopyEdgeClick:W,handleStartStorefrontEdgeSelection:Z,handleCancelStorefrontEdgeSelection:Q,handleStorefrontEdgeClick:oe,handleStartDriveInEdgeSelection:ae,handleCancelDriveInEdgeSelection:ce,handleDriveInEdgeClick:ie,setHoveredEdgeIndex:I}}function aG(t){const{map:s,isMapReady:n,isMeasuring:a,measurementType:l,measurementPoints:c,onSetMeasurementPoint:u,onDeleteMeasurementPoint:i,onInsertMeasurementPoint:_}=t,j=k.useRef([]),y=k.useRef([]);k.useEffect(()=>{if(!s||!n)return;try{s.getStyle()}catch{return}s.constructor.__proto__.constructor;let x;try{x=Object.getPrototypeOf(s).constructor}catch{}if(s.getLayer("measurement-line")&&s.removeLayer("measurement-line"),s.getLayer("measurement-fill")&&s.removeLayer("measurement-fill"),s.getSource("measurement")&&s.removeSource("measurement"),j.current.forEach(P=>P.remove()),j.current=[],y.current.forEach(P=>P.remove()),y.current=[],!a||c.length===0)return;const v=c.map(P=>[P.lng,P.lat]),C=l==="area"&&v.length>=3?{type:"Polygon",coordinates:[[...v,v[0]]]}:{type:"LineString",coordinates:v};s.addSource("measurement",{type:"geojson",data:{type:"Feature",geometry:C,properties:{}}}),l==="area"&&v.length>=3&&s.addLayer({id:"measurement-fill",type:"fill",source:"measurement",paint:{"fill-color":"#10b981","fill-opacity":.2}}),s.addLayer({id:"measurement-line",type:"line",source:"measurement",paint:{"line-color":"#10b981","line-width":3,"line-dasharray":[2,1]}}),br(async()=>{const{Marker:P}=await Promise.resolve().then(()=>Gq);return{Marker:P}},void 0).then(({Marker:P})=>{if(c.forEach((I,z)=>{const F=z===0,D=z===c.length-1,X=document.createElement("div");X.className="measurement-marker",X.style.cssText=`
2547          width: 24px; height: 24px;
2548          background: ${F?"#22c55e":D?"#ef4444":"#10b981"};
2549          border: 3px solid white; border-radius: 50%;
2550          cursor: grab; box-shadow: 0 2px 6px rgba(0,0,0,0.4);
2551          display: flex; align-items: center; justify-content: center;
2552          color: white; font-size: 10px; font-weight: bold; transition: transform 0.1s;
2553        `,X.innerHTML=`${z+1}`,X.addEventListener("mouseenter",()=>{X.style.transform="scale(1.1)"}),X.addEventListener("mouseleave",()=>{X.style.transform="scale(1)"}),X.addEventListener("contextmenu",te=>{te.preventDefault(),te.stopPropagation(),i&&c.length>1&&i(z)});const K=new P({element:X,draggable:!0}).setLngLat([I.lng,I.lat]).addTo(s);K.on("dragend",()=>{const te=K.getLngLat();u==null||u(z,{lat:te.lat,lng:te.lng})}),j.current.push(K)}),c.length>=2){const I=(z,F,D)=>{const X=document.createElement("div");X.className="midpoint-marker",X.style.cssText=`
2554            width: 16px; height: 16px;
2555            background: rgba(16, 185, 129, 0.6);
2556            border: 2px dashed white; border-radius: 50%;
2557            cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,0.3);
2558            display: flex; align-items: center; justify-content: center;
2559            color: white; font-size: 12px; transition: all 0.15s;
2560          `,X.innerHTML="+",X.addEventListener("mouseenter",()=>{X.style.transform="scale(1.3)",X.style.background="rgba(16, 185, 129, 0.9)"}),X.addEventListener("mouseleave",()=>{X.style.transform="scale(1)",X.style.background="rgba(16, 185, 129, 0.6)"}),X.addEventListener("click",te=>{te.stopPropagation(),_==null||_(D,{lat:z,lng:F})});const K=new P({element:X}).setLngLat([F,z]).addTo(s);y.current.push(K)};for(let z=0;z<c.length-1;z++){const F=c[z],D=c[z+1];I((F.lat+D.lat)/2,(F.lng+D.lng)/2,z+1)}if(l==="area"&&c.length>=3){const z=c[c.length-1],F=c[0];I((z.lat+F.lat)/2,(z.lng+F.lng)/2,c.length)}}})},[s,a,c,l,n,u,i,_])}function rG(t){const{map:s,isMapReady:n,mapOverlays:a,overlayLayerIds:l,isMeasuring:c,dockEdgeSelectionMode:u,windowEdgeSelectionMode:i,canopyEdgeSelectionMode:_,treeEditMode:j,cutoutDrawingTargetId:y,onSelectOverlay:x,onHeightEdit:v}=t;k.useEffect(()=>{if(!s||!n)return;const C=P=>{if(c||y||u||i||_||j!=="none")return;const I=l.filter(te=>te.includes("-fill")||te.includes("-parking-stripes")||te.includes("-parking-stalls-edges")||te.includes("-parking-ada-edges"));if(I.length===0)return;const z=I.filter(te=>s.getLayer(te));if(z.length===0)return;const F=s.queryRenderedFeatures(P.point,{layers:z}),D=[],X=new Set,K=P.lngLat;
2560for(const te of a){if(!te.image_url||!te.geometry||X.has(te.id)||te.is_visible===!1)continue;const J=te.geometry;let H;if(Array.isArray(J)&&J.length>=3){const O=J[0];if(typeof O=="object"&&O!==null&&"lat"in O&&"lng"in O)H=J.map(q=>[q.lng,q.lat]);else if(Array.isArray(O)&&O.length>=2)H=J.map(q=>[q[0],q[1]]);else continue}else continue;try{const O=[...H,H[0]],q=us([K.lng,K.lat]),W=Xn([O]);uu(q,W)&&(X.add(te.id),D.push({overlay:te,score:2600}))}catch{}}if(F.length>0){const te=J=>{const H=J.match(/^overlay-layer-(.+?)-fill/);if(H!=null&&H[1])return H[1];const O=J.match(/^overlay-layer-(.+?)-(parking-stripes|parking-stalls-edges|parking-ada-edges)/);return O!=null&&O[1]?O[1]:null};for(const J of F){const H=J.layer.id,O=te(H);if(!O||X.has(O))continue;X.add(O);const q=a.find(ce=>ce.id===O);if(!q)continue;let W=0;const Q=q.height_ft||0,Z=q.layer_type||"";Q>0?W=3e3:YT(Z)?W=2e3:lu(Z)?W=1500:WT(Z)?W=0:W=500;const oe=Wx(Z,0);D.push({overlay:q,score:W+oe/10})}}if(D.length>0){D.sort((Q,Z)=>Z.score-Q.score);const te=D[0].overlay,J=String(te.layer_type||te.type||""),H=["building_footprint","building","warehouse","retail_building","office_building"],O=["parking","parking_field","parking_zone","truck_court","trailer_parking"],q=["stormwater_detention","stormwater","landscape_buffer","utility_corridor","perimeter_fencing","easement","fire_lane","site_lighting","site_amenity","erosion_control","grading","retaining_wall","trash_enclosure","monument_signage","hardscape","outdoor_storage","landscaping"];let W="build";H.includes(J)||O.includes(J)?W="build":q.includes(J)?W="site":["property","site","lot","polygon","property_outline"].includes(J)&&(W="data"),x(te,W),lu(te.layer_type)&&v(te,{x:P.point.x,y:P.point.y})}};return s.on("click",C),()=>{s.off("click",C)}},[s,a,n,c,u,i,_,j,y,l,x,v])}function iG(t){const{map:s,isMapReady:n,selectedOverlay:a,updateOverlay:l,treeEditMode:c}=t;k.useEffect(()=>{if(!s||!n||c==="none"||!a)return;const u=async i=>{var I,z;const _=i.lngLat.lat,j=i.lngLat.lng,y=a,x=(I=y.style)==null?void 0:I.landscapeBuffers;if(!x){Ve.error("No landscape buffers configured");return}if(!Object.values(x).some(F=>(F==null?void 0:F.enabled)&&(F==null?void 0:F.type)==="tree_line")){Ve.error("No tree lines configured");return}const C=(z=y.style)==null?void 0:z.treeModifications,P={deletedTreeIds:(C==null?void 0:C.deletedTreeIds)||[],addedTrees:(C==null?void 0:C.addedTrees)||[]};if(c==="add"){const F={id:`custom_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,lat:_,lng:j,edgeLabel:"custom"},D={...P,addedTrees:[...P.addedTrees,F]};l.mutate({id:y.id,style:{...y.style||{},treeModifications:D}}),Ve.success("Tree added")}else if(c==="delete"){const{generateAllTreePositions:F,findNearestTree:D}=await br(async()=>{const{generateAllTreePositions:W,findNearestTree:Q}=await Promise.resolve().then(()=>Tg);return{generateAllTreePositions:W,findNearestTree:Q}},void 0),{classifyEdgesForSetbackLabels:X}=await br(async()=>{const{classifyEdgesForSetbackLabels:W}=await Promise.resolve().then(()=>f_);return{classifyEdgesForSetbackLabels:W}},void 0),K=y.geometry,te=X(K),J=F(K,x,te,void 0,P),{tree:H}=D(_,j,J,25);if(!H||!H.id){Ve.error("No tree found near click location");return}const q=P.addedTrees.some(W=>W.id===H.id)?{...P,addedTrees:P.addedTrees.filter(W=>W.id!==H.id)}:{...P,deletedTreeIds:[...P.deletedTreeIds,H.id]};l.mutate({id:y.id,style:{...y.style||{},treeModifications:q}}),Ve.success("Tree removed")}};return s.getCanvas().style.cursor=c==="add"?"crosshair":"not-allowed",s.on("click",u),()=>{s.off("click",u),s.getCanvas().style.cursor=""}},[s,n,c,a,l])}function oG(t){const{map:s,isMapReady:n,selectedOverlay:a,updateOverlay:l,signPlacementMode:c,placingSignId:u,onSignPlacementDone:i}=t;k.useEffect(()=>{if(!s||!n||!c||!u||!a)return;const _=j=>{const y=j.lngLat,x=a.style||{},v=Array.isArray(x.monument_signs)?[...x.monument_signs]:[],C=v.findIndex(P=>P.id===u);C!==-1&&(v[C]={...v[C],position_lat:y.lat,position_lng:y.lng},l.mutate({id:a.id,style:{...x,monument_signs:v}}),Ve.success("Sign placed on map")),i()};return s.getCanvas().style.cursor="crosshair",s.on("click",_),()=>{s.off("click",_),s.getCanvas().style.cursor=""}},[s,n,c,u,a,l,i])}function lG(t){const{map:s,isMapReady:n,selectedOverlay:a,allOverlays:l,updateOverlay:c,entryPointPlacementMode:u,placingEntryType:i,onEntryPointPlacementDone:_}=t;k.useEffect(()=>{if(!s||!n||!u||!i||!a)return;const j=async y=>{const x=y.lngLat,v=a.geometry;if(!v||v.length<3){Ve.error("Invalid parking zone geometry"),_();return}const{classifyEdgesForSetbackLabels:C}=await br(async()=>{const{classifyEdgesForSetbackLabels:Z}=await Promise.resolve().then(()=>f_);return{classifyEdgesForSetbackLabels:Z}},void 0),{findNearestEdgeFromPoint:P}=await br(async()=>{const{findNearestEdgeFromPoint:Z}=await Promise.resolve().then(()=>lp);return{findNearestEdgeFromPoint:Z}},void 0),I=C(v),z=P({lat:x.lat,lng:x.lng},v,I);if(!z){Ve.error("Could not determine nearest edge"),_();return}const F={main_entry:"Main Entry",service_entry:"Service Entry",emergency_access:"Emergency Access",fire_lane:"Fire Lane"},D={id:`entry-${Date.now()}`,type:i,name:F[i]||"Entry Point",width_ft:24,depth_ft:40,curb_cut_type:"standard",has_gate:!1,edge_label:z.edgeLabel,position_percent:z.positionPercent},X=a.style||{},K=X.parkingCirculation||{},J=[...Array.isArray(K.entryPoints)?[...K.entryPoints]:[],D];let H;
2560if(a.parent_overlay_id&&l){const Z=l.find(oe=>oe.id===a.parent_overlay_id);Z!=null&&Z.geometry&&Array.isArray(Z.geometry)&&Z.geometry.length>=3&&(H=Z.geometry)}const{autoMarkIntersectingStallsRemoved:O}=await br(async()=>{const{autoMarkIntersectingStallsRemoved:Z}=await Promise.resolve().then(()=>t1);return{autoMarkIntersectingStallsRemoved:Z}},void 0),{generateAllEntryPointPolygons:q}=await br(async()=>{const{generateAllEntryPointPolygons:Z}=await Promise.resolve().then(()=>lp);return{generateAllEntryPointPolygons:Z}},void 0),{stallOverrides:W,removedCount:Q}=O(v,X,{stallWidth_ft:a.parking_stall_width_ft??9,stallDepth_ft:a.parking_stall_depth_ft??18,aisleWidth_ft:a.parking_aisle_width_ft??24,layoutType:a.parking_layout_type||"double_loaded"},J,H,q);c.mutate({id:a.id,style:{...X,parkingCirculation:{...K,entryPoints:J,stallOverrides:W}}}),Q>0?Ve.success(`${F[i]||"Entry Point"} placed, ${Q} stalls auto-removed`):Ve.success(`${F[i]||"Entry Point"} placed on ${z.edgeLabel} edge`),_()};return s.getCanvas().style.cursor="crosshair",s.on("click",j),()=>{s.off("click",j),s.getCanvas().style.cursor=""}},[s,n,u,i,a,l,c,_])}const cG=["parking_field","parking","parking_zone"];function dG(t){const{map:s,isMapReady:n,stallEditorEnabled:a,selectedOverlay:l,setSelectedStallId:c}=t;k.useEffect(()=>{if(!s||!n||!a||!l||!cG.includes(l.layer_type||""))return;const u=`overlay-layer-${l.id}-stall-click-targets`,i=`overlay-layer-${l.id}-stall-click-highlight`,_=`overlay-layer-${l.id}-row-click-targets`,j=`overlay-layer-${l.id}-row-click-highlight`,y=z=>{var D,X,K;const F=s.queryRenderedFeatures(z.point,{layers:[i,u].filter(te=>s.getLayer(te))});if(F&&F.length>0){const te=(D=F[0].properties)==null?void 0:D.id;te&&(c(te),(K=(X=z.originalEvent)==null?void 0:X.stopPropagation)==null||K.call(X))}},x=z=>{var D,X,K;const F=s.queryRenderedFeatures(z.point,{layers:[j,_].filter(te=>s.getLayer(te))});if(F&&F.length>0){const te=(D=F[0].properties)==null?void 0:D.id;te&&(c(te),(K=(X=z.originalEvent)==null?void 0:X.stopPropagation)==null||K.call(X))}},v=()=>{s.getCanvas().style.cursor="pointer"},C=()=>{s.getCanvas().style.cursor=""},P=[u,i].filter(z=>s.getLayer(z)),I=[_,j].filter(z=>s.getLayer(z));return P.forEach(z=>{s.on("click",z,y),s.on("mouseenter",z,v),s.on("mouseleave",z,C)}),I.forEach(z=>{s.on("click",z,x),s.on("mouseenter",z,v),s.on("mouseleave",z,C)}),()=>{P.forEach(z=>{s.off("click",z,y),s.off("mouseenter",z,v),s.off("mouseleave",z,C)}),I.forEach(z=>{s.off("click",z,x),s.off("mouseenter",z,v),s.off("mouseleave",z,C)}),s.getCanvas().style.cursor=""}},[s,n,a,l,c])}function uG(t){const{map:s,isMapReady:n,isParcelLookupMode:a,viewportParcels:l}=t;k.useEffect(()=>{if(!s||!n)return;const c="viewport-parcels",u="viewport-parcels-fill",i="viewport-parcels-line";if(s.getLayer(u)&&s.removeLayer(u),s.getLayer(i)&&s.removeLayer(i),s.getSource(c)&&s.removeSource(c),!a||l.length===0)return;const _=l.filter(j=>j.geometry).map(j=>({type:"Feature",properties:{apn:j.apn,address:j.address,owner:j.owner,acres:j.acres},geometry:j.geometry}));if(_.length!==0)try{s.addSource(c,{type:"geojson",data:{type:"FeatureCollection",features:_}}),s.addLayer({id:u,type:"fill",source:c,paint:{"fill-color":"#0d9488","fill-opacity":.2}}),s.addLayer({id:i,type:"line",source:c,paint:{"line-color":"#0d9488","line-width":2}})}catch(j){console.warn("Failed to add viewport parcels layer:",j)}},[s,a,l,n])}const bb="https://ntrjyokaupvmnftawavp.supabase.co";function hG(t,s){const n=k.useRef(!1),[a,l]=k.useState(!1),[c,u]=k.useState(og[og.length-1].timeId),[i,_]=k.useState(og[og.length-1].label),[j,y]=k.useState(!1),[x,v]=k.useState(!1),[C,P]=k.useState(50),[I,z]=k.useState(null),[F,D]=k.useState(null),[X,K]=k.useState(""),[te,J]=k.useState(""),H=k.useCallback(q=>{v(q)},[]),O=k.useCallback((q,W,Q,Z)=>{z(q),D(W),K(Q),J(Z)},[]);return k.useEffect(()=>{if(!t.current||!s)return;if(!n.current){n.current=!0;return}const q=t.current;if(!x)try{if(a){y(!0);const W=`${bb}/functions/v1/satellite-tiles?z={z}&x={x}&y={y}&source=wayback&timeId=${c}`;q.getLayer("satellite-layer")&&q.removeLayer("satellite-layer"),q.getSource("satellite")&&q.removeSource("satellite"),q.getSource("wayback-satellite")?(q.getLayer("wayback-satellite-layer")&&q.removeLayer("wayback-satellite-layer"),q.removeSource("wayback-satellite"),q.addSource("wayback-satellite",{type:"raster",tiles:[W],tileSize:256,attribution:"Esri World Imagery Wayback"})):q.addSource("wayback-satellite",{type:"raster",tiles:[W],tileSize:256,attribution:"Esri World Imagery Wayback"}),q.getLayer("wayback-satellite-layer")||q.addLayer({id:"wayback-satellite-layer",type:"raster",source:"wayback-satellite",minzoom:0,maxzoom:22});const Q=Z=>{Z.sourceId==="wayback-satellite"&&Z.isSourceLoaded&&y(!1)};q.on("sourcedata",Q),setTimeout(()=>y(!1),3e3)}else{q.getLayer("wayback-satellite-layer")&&q.removeLayer("wayback-satellite-layer"),q.getSource("wayback-satellite")&&q.removeSource("wayback-satellite");const W=q.getSource("satellite"),Q=q.getLayer("satellite-layer");!W&&!Q?(q.addSource("satellite",{type:"raster",tiles:[`${bb}/functions/v1/satellite-tiles?z={z}&x={x}&y={y}&source=esri`],tileSize:256,maxzoom:19,attribution:"© Esri, Maxar, Earthstar Geographics"}),q.addLayer({id:"satellite-layer",type:"raster",source:"satellite",paint:{"raster-opacity":1}})):W&&!Q&&q.addLayer({id:"satellite-layer",type:"raster",source:"satellite",paint:{"raster-opacity":1}}),y(!1)}}catch(W){console.warn("Failed to update satellite timeline:",W),y(!1)}},[a,c,s,x,t]),k.useEffect(()=>{var oe,ce;if(!t.current||!s||!x)return;const q=t.current,Q=C>50?F:I;if(!Q)return;y(!0);const Z=`${bb}/functions/v1/satellite-tiles?z={z}&x={x}&y={y}&source=wayback&timeId=${Q}`;try{q.getLayer("satellite-layer")&&q.removeLayer("satellite-layer"),q.getSource("satellite")&&q.removeSource("satellite"),q.getLayer("wayback-satellite-layer")&&q.removeLayer("wayback-satellite-layer"),q.getSource("wayback-satellite")&&q.removeSource("wayback-satellite"),q.addSource("wayback-satellite",{type:"raster",tiles:[Z],tileSize:256,attribution:"Esri World Imagery Wayback"});const ae=(ce=(oe=q.getStyle().layers)==null?void 0:oe[0])==null?void 0:ce.id;q.addLayer({id:"wayback-satellite-layer",type:"raster",source:"wayback-satellite",minzoom:0,maxzoom:22},ae),setTimeout(()=>y(!1),2e3)}catch(ae){console.warn("Failed to update comparison:",ae),y(!1)}},[x,C,I,F,s,t]),{satelliteTimelineActive:a,setSatelliteTimelineActive:l,satelliteTimelineVersion:c,setSatelliteTimelineVersion:u,satelliteTimelineLabel:i,setSatelliteTimelineLabel:_,satelliteTimelineLoading:j,comparisonMode:x,comparisonPosition:C,setComparisonPosition:P,comparisonLeftTimeId:I,comparisonRightTimeId:F,comparisonLeftLabel:X,comparisonRightLabel:te,handleComparisonModeChange:H,handleComparisonVersionChange:O}}function eg(t,s){const n=localStorage.getItem(t);return n?parseFloat(n):s}function _y(t,s){const n=localStorage.getItem(t);return n!==null?n==="true":s}function mG(t,s,n,a){const[l,c]=k.useState(()=>eg("map-3d-pitch",45)),[u,i]=k.useState(()=>_y("map-3d-terrain",!0)),[_,j]=k.useState(()=>_y("map-3d-buildings",!0)),[y,x]=k.useState(()=>eg("map-3d-exaggeration",1.5)),[v,C]=k.useState(()=>eg("map-3d-building-height",1)),[P,I]=k.useState(()=>localStorage.getItem("map-3d-building-theme")||"day"),[z,F]=k.useState(()=>eg("map-3d-sun-azimuth",135)),[D,X]=k.useState(()=>eg("map-3d-sun-altitude",45)),[K,te]=k.useState(()=>_y("map-3d-labels",!0)),[J,H]=k.useState(()=>eg("map-3d-building-opacity",.85)),[O,q]=k.useState(()=>_y("map-3d-wireframe",!1)),W=k.useCallback(Ee=>{switch(Ee){case"night":return{base:"hsl(220, 30%, 20%)",mid:"hsl(220, 25%, 25%)",high:"hsl(220, 20%, 30%)",top:"hsl(220, 15%, 35%)"};case"concrete":return{base:"hsl(0, 0%, 60%)",mid:"hsl(0, 0%, 55%)",high:"hsl(0, 0%, 50%)",top:"hsl(0, 0%, 45%)"};case"glass":return{base:"hsl(200, 40%, 55%)",mid:"hsl(200, 35%, 50%)",high:"hsl(200, 30%, 45%)",top:"hsl(200, 25%, 40%)"};case"terracotta":return{base:"hsl(15, 50%, 55%)",mid:"hsl(15, 45%, 50%)",high:"hsl(15, 40%, 45%)",top:"hsl(15, 35%, 40%)"};case"day":default:return{base:"hsl(35, 30%, 70%)",mid:"hsl(35, 25%, 60%)",high:"hsl(35, 20%, 55%)",top:"hsl(35, 15%, 50%)"}}},[]);k.useEffect(()=>{if(!(!t.current||!s)){try{u&&t.current.getSource("terrain")?t.current.setTerrain({source:"terrain",exaggeration:y}):t.current.setTerrain(void 0)}catch(Ee){console.warn("Failed to update terrain:",Ee)}localStorage.setItem("map-3d-terrain",u.toString()),localStorage.setItem("map-3d-exaggeration",y.toString())}},[u,y,s,t]),k.useEffect(()=>{if(!(!t.current||!s)){try{const Ee=t.current,ve=W(P);Ee.getLayer("3d-buildings")&&(Ee.setLayoutProperty("3d-buildings","visibility",_?"visible":"none"),_&&(Ee.setPaintProperty("3d-buildings","fill-extrusion-color",["interpolate",["linear"],["get","render_height"],0,ve.base,50,ve.mid,100,ve.high,200,ve.top]),Ee.setPaintProperty("3d-buildings","fill-extrusion-height",["*",["coalesce",["get","render_height"],["get","height"],10],v]),Ee.setPaintProperty("3d-buildings","fill-extrusion-base",["*",["coalesce",["get","render_min_height"],0],v]),Ee.setPaintProperty("3d-buildings","fill-extrusion-opacity",J))),Ee.getLayer("building-outlines")&&Ee.setLayoutProperty("building-outlines","visibility",O&&_?"visible":"none"),Ee.setLight({anchor:"viewport",color:P==="night"?"#4477aa":"#ffffff",intensity:P==="night"?.3:.5,position:[1.5,z,D]})}catch(Ee){console.warn("Failed to update buildings:",Ee)}localStorage.setItem("map-3d-buildings",_.toString()),localStorage.setItem("map-3d-building-height",v.toString()),localStorage.setItem("map-3d-building-theme",P),localStorage.setItem("map-3d-building-opacity",J.toString()),localStorage.setItem("map-3d-wireframe",O.toString()),localStorage.setItem("map-3d-sun-azimuth",z.toString()),localStorage.setItem("map-3d-sun-altitude",D.toString())}},[_,v,P,J,O,z,D,s,W,t]),k.useEffect(()=>{if(!t.current||!s)return;const Ee=t.current,ve=K?"visible":"none";["highway-labels","road-labels","place-labels","poi-labels","water-labels"].forEach(we=>{Ee.getLayer(we)&&Ee.setLayoutProperty(we,"visibility",ve)}),localStorage.setItem("map-3d-labels",K.toString())},[K,s,t]);const Q=k.useRef(!1);k.useEffect(()=>{!t.current||!s||Q.current||(Q.current=!0,t.current.easeTo({pitch:l,duration:300}),setTimeout(()=>{Q.current=!1},350))},[l,s,t]);const Z=k.useRef(!1),oe=k.useRef(n);k.useEffect(()=>{if(!t.current||!s)return;const Ee=ke=>(ke%360+360)%360,ve=(ke,ze)=>Math.abs((ze-ke+540)%360-180),we=Ee(t.current.getBearing()),Ze=Ee(n);if(ve(we,Ze)<1){oe.current=n;return}Z.current||(Z.current=!0,oe.current=n,t.current.rotateTo(Ze,{duration:250}),setTimeout(()=>{Z.current=!1},300))},[n,s,t]);const ce=k.useCallback(Ee=>c(Ee[0]),[]),ae=k.useCallback(Ee=>x(Ee[0]),[]),ie=k.useCallback(Ee=>C(Ee[0]),[]),de=k.useCallback(Ee=>F(Ee[0]),[]),ge=k.useCallback(Ee=>X(Ee[0]),[]),We=k.useCallback(()=>{t.current&&(t.current.easeTo({pitch:45,bearing:0,duration:500}),c(45),a==null||a(0))},[t,a]);return{pitch:l,setPitch:c,terrainEnabled:u,setTerrainEnabled:i,buildingsEnabled:_,setBuildingsEnabled:j,exaggeration:y,setExaggeration:x,buildingHeight:v,setBuildingHeight:C,buildingTheme:P,setBu
2560ildingTheme:I,sunAzimuth:z,setSunAzimuth:F,sunAltitude:D,setSunAltitude:X,labelsEnabled:K,setLabelsEnabled:te,buildingOpacity:J,setBuildingOpacity:H,wireframeEnabled:O,setWireframeEnabled:q,getBuildingColors:W,handlePitchChange:ce,handleExaggerationChange:ae,handleBuildingHeightChange:ie,handleSunAzimuthChange:de,handleSunAltitudeChange:ge,resetView:We}}function fG(t){const{map:s,isMapReady:n,developments:a,existingProducts:l,selectedDevelopment:c,selectedExistingProduct:u,filters:i,onSelectDevelopment:_,onSelectExistingProduct:j}=t,y=k.useRef([]),x=k.useRef(_);x.current=_;const v=k.useRef(j);v.current=j;const C=k.useMemo(()=>JSON.stringify({types:i.types,statuses:i.statuses,showDev:i.showDevelopments,showEP:i.showExistingProducts,hiddenDev:i.hiddenDevelopmentIds,hiddenEP:i.hiddenExistingProductIds,devIds:i.visibleDeveloperIds?[...i.visibleDeveloperIds]:[],ownIds:i.visibleOwnerIds?[...i.visibleOwnerIds]:[],tenIds:i.visibleTenantIds?[...i.visibleTenantIds]:[]}),[i]);k.useEffect(()=>{var F,D,X;if(!s||!n)return;y.current.forEach(K=>K.remove()),y.current=[];const P=(((F=i.visibleDeveloperIds)==null?void 0:F.size)??0)>0||(((D=i.visibleOwnerIds)==null?void 0:D.size)??0)>0||(((X=i.visibleTenantIds)==null?void 0:X.size)??0)>0,I=a.filter(K=>{var te,J,H;if(i.showDevelopments===!1&&!P||(te=i.hiddenDevelopmentIds)!=null&&te.includes(K.id)||i.types.length>0&&!i.types.includes(K.type)||i.statuses.length>0&&!i.statuses.includes(K.status))return!1;if(i.showDevelopments===!1&&P){const O=K.developer_id&&((J=i.visibleDeveloperIds)==null?void 0:J.has(K.developer_id)),q=K.owner_id&&((H=i.visibleOwnerIds)==null?void 0:H.has(K.owner_id));if(!O&&!q)return!1}return!0}),z=l.filter(K=>{var te,J,H;if(i.showExistingProducts===!1&&!P||(te=i.hiddenExistingProductIds)!=null&&te.includes(K.id))return!1;if(i.showExistingProducts===!1&&P){const O=K.developer_id&&((J=i.visibleDeveloperIds)==null?void 0:J.has(K.developer_id)),q=K.owner_id&&((H=i.visibleOwnerIds)==null?void 0:H.has(K.owner_id));if(!O&&!q)return!1}return!0});I.forEach(K=>{const te=Rm(K.status),J=Dx(K.type),H=(c==null?void 0:c.id)===K.id,O=document.createElement("div");O.className="map-3d-marker",O.innerHTML=`
2561        <div style="
2562          width: ${H?44:36}px;
2563          height: ${H?44:36}px;
2564          background: ${te};
2565          border-radius: 50%;
2566          display: flex;
2567          align-items: center;
2568          justify-content: center;
2569          box-shadow: 0 2px 8px rgba(0,0,0,0.3);
2570          border: ${H?"3px solid white":"2px solid rgba(255,255,255,0.8)"};
2571          cursor: pointer;
2572          font-size: ${H?20:16}px;
2573          transition: all 0.2s;
2574        ">
2575          ${J}
2576        </div>
2577      `,O.addEventListener("click",()=>x.current(K));const q=new Lg.Marker({element:O}).setLngLat([K.lng,K.lat]).addTo(s);y.current.push(q)}),z.forEach(K=>{const te=OE(),J=Dx(K.type),H=(u==null?void 0:u.id)===K.id,O=document.createElement("div");O.className="map-3d-marker",O.innerHTML=`
2578        <div style="
2579          width: ${H?44:36}px;
2580          height: ${H?44:36}px;
2581          background: ${te};
2582          border-radius: 50%;
2583          display: flex;
2584          align-items: center;
2585          justify-content: center;
2586          box-shadow: 0 2px 8px rgba(0,0,0,0.3);
2587          border: ${H?"3px solid white":"2px solid rgba(255,255,255,0.8)"};
2588          cursor: pointer;
2589          font-size: ${H?20:16}px;
2590          transition: all 0.2s;
2591        ">
2592          ${J}
2593        </div>
2594      `,O.addEventListener("click",()=>{var W;return(W=v.current)==null?void 0:W.call(v,K)});const q=new Lg.Marker({element:O}).setLngLat([K.lng,K.lat]).addTo(s);y.current.push(q)})},[s,a,l,c==null?void 0:c.id,u==null?void 0:u.id,C,n]),k.useEffect(()=>{!s||!n||(c?s.flyTo({center:[c.lng,c.lat],zoom:Math.max(s.getZoom(),15),duration:1e3}):u&&s.flyTo({center:[u.lng,u.lat],zoom:Math.max(s.getZoom(),15),duration:1e3}))},[s,c,u,n])}const pG="https://ntrjyokaupvmnftawavp.supabase.co",gG={version:8,glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf",sources:{},layers:[{id:"background",type:"background",paint:{"background-color":"#1a1a2e"}}]};function xG(t){var Z,oe,ce;const s=k.useRef(null),n=k.useRef(null),a=k.useRef(!1),l=k.useRef(!1),c=k.useRef(!1),[u,i]=k.useState(!1),[_,j]=k.useState(null),[y,x]=k.useState(null),[v,C]=k.useState(13),[P,I]=k.useState(null),z=k.useRef(t.initialCenter?[t.initialCenter.lng,t.initialCenter.lat]:[parseFloat(((Z=t.mapSettings)==null?void 0:Z.map_center_lng)||"-76.0110"),parseFloat(((oe=t.mapSettings)==null?void 0:oe.map_center_lat)||"40.3285")]),F=k.useRef(t.initialZoom??parseInt(((ce=t.mapSettings)==null?void 0:ce.map_zoom)||"13",10)),D=k.useRef(t.pitch),X=k.useRef(t.bearing),K=k.useRef(t.onBearing
2594Change);K.current=t.onBearingChange;const te=k.useRef(t.onPositionChange);te.current=t.onPositionChange;const J=k.useRef(t.buildingTheme),H=k.useRef(t.buildingHeight),O=k.useRef(t.buildingOpacity),q=k.useRef(t.buildingsEnabled),W=k.useRef(t.wireframeEnabled),Q=k.useRef(t.getBuildingColors);return Q.current=t.getBuildingColors,k.useEffect(()=>{if(a.current||!s.current)return;const ae=document.createElement("canvas");if(!!!(ae.getContext("webgl2")||ae.getContext("webgl"))){j("Your browser does not support WebGL, which is required for 3D maps.");return}const de=s.current.getBoundingClientRect();if(de.width===0||de.height===0){console.error("Map container has zero dimensions:",de);return}console.log("Initializing 3D map with dimensions:",de.width,"x",de.height),a.current=!0;const ge=new Lg.Map({container:s.current,style:gG,center:z.current,zoom:F.current,pitch:D.current,bearing:X.current,maxPitch:85,antialias:!0});n.current=ge,l.current=!1;const We=new Lg.NavigationControl({visualizePitch:!0});ge.addControl(We,"top-left"),setTimeout(()=>{const ve=s.current;if(ve){const we=ve.querySelector(".maplibregl-ctrl-top-left .maplibregl-ctrl-group");we&&(we.style.marginLeft="320px",we.style.marginTop="8px")}},100),ge.on("sourcedata",ve=>{ve.sourceId==="satellite"&&ve.isSourceLoaded&&(l.current=!0,console.log("Satellite tiles loaded successfully"))});const Ee=setTimeout(()=>{!l.current&&n.current&&console.warn("Satellite tiles did not load within timeout")},1e4);return ge.on("load",()=>{console.log("MapLibre map loaded, adding layers..."),setTimeout(()=>{var Ze;(Ze=n.current)==null||Ze.resize(),console.log("Map resized")},100);const ve=`${pG}/functions/v1/satellite-tiles?z={z}&x={x}&y={y}&source=esri`;ge.addSource("satellite",{type:"raster",tiles:[ve],tileSize:256,maxzoom:19,attribution:"© Esri, Maxar, Earthstar Geographics"}),ge.addLayer({id:"satellite-layer",type:"raster",source:"satellite",paint:{"raster-opacity":1}}),console.log("Satellite layer added"),ge.addSource("openmaptiles",{type:"vector",url:"https://api.maptiler.com/tiles/v3/tiles.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL"}),ge.addSource("osm-buildings",{type:"vector",tiles:["https://tiles.openfreemap.org/planet/{z}/{x}/{y}.pbf"],maxzoom:14});const we=Q.current(J.current);ge.addLayer({id:"3d-buildings",source:"osm-buildings","source-layer":"building",type:"fill-extrusion",minzoom:14,paint:{"fill-extrusion-color":["interpolate",["linear"],["coalesce",["get","render_height"],["get","height"],10],0,we.base,50,we.mid,100,we.high,200,we.top],"fill-extrusion-height":["*",["coalesce",["get","render_height"],["get","height"],10],H.current],"fill-extrusion-base":["*",["coalesce",["get","render_min_height"],["get","min_height"],0],H.current],"fill-extrusion-opacity":O.current},layout:{visibility:q.current?"visible":"none"}}),ge.addLayer({id:"building-outlines",source:"osm-buildings","source-layer":"building",type:"line",minzoom:14,paint:{"line-color":"rgba(255, 255, 255, 0.3)","line-width":.5},layout:{visibility:W.current?"visible":"none"}}),console.log("3D buildings layer added"),i(!0)}),ge.on("rotateend",()=>{!c.current&&K.current&&K.current(ge.getBearing())}),ge.on("moveend",()=>{if(te.current){const we=ge.getCenter(),Ze=ge.getZoom();te.current({lat:we.lat,lng:we.lng},Ze)}const ve=ge.getBounds();I({minLat:ve.getSouth(),maxLat:ve.getNorth(),minLng:ve.getWest(),maxLng:ve.getEast()}),C(ge.getZoom())}),ge.on("error",ve=>{console.error("MapLibre error:",ve)}),()=>{clearTimeout(Ee),n.current&&(n.current.remove(),n.current=null),a.current=!1}},[]),{mapContainer:s,mapRef:n,isMapReady:u,webGLError:_,renderError:y,isBearingScrubbingRef:c,currentZoom:v,viewportBounds:P}}const _G=18,yG=(t,s)=>{const{enabled:n,zoom:a,minZoom:l=_G,onRequestMade:c,isLocked:u=!1,cacheMode:i="none"}=s,[_,j]=k.useState([]),[y,x]=k.useState(!1),[v,C]=k.useState(null),[P,I]=k.useState([]),z=lc(),F=k.useRef(null),D=k.useRef(null),X=k.useRef(null),K=k.useRef(0),te=k.useCallback(async O=>{const q=O.filter(W=>W.apn&&W.geometry);if(q.length!==0)try{const W=q.map(Z=>{var ae;let oe=0,ce=0;if((ae=Z.geometry)!=null&&ae.coordinates)try{const ie=Z.geometry.type==="MultiPolygon"?Z.geometry.coordinates[0][0][0]:Z.geometry.coordinates[0][0];Array.isArray(ie)&&ie.length>=2&&typeof ie[0]=="number"&&(ce=ie[0],oe=ie[1])}catch{}return{apn:Z.apn,address:Z.address||null,owner:Z.owner||null,owner_address:Z.ownerAddress||null,acres:Z.acres??null,sqft:Z.sqft??null,land_use:Z.landUse||null,zoning:Z.zoning||null,year_built:Z.yearBuilt??null,assessed_value:Z.assessedValue??null,market_value:Z.marketValue??null,geometry:Z.geometry?JSON.parse(JSON.stringify(Z.geometry)):null,lat:oe,lng:ce,source:Z.source||"viewport-fetch"}}),{error:Q}=await Fs.from("parcel_cache").upsert(W,{onConflict:"apn",ignoreDuplicates:!0});
2594Q?console.warn("Failed to cache viewport parcels:",Q):z.invalidateQueries({queryKey:["cached-parcels"]})}catch(W){console.warn("Error caching viewport parcels:",W)}},[z]),J=k.useCallback(async O=>{if(u){console.log("Parcel fetch blocked: usage limit reached"),Ve.warning("Parcel loading disabled: session limit reached",{id:"parcel-limit-reached",duration:3e3});return}const q=Date.now(),W=q-K.current;if(W<2e3){console.log(`Rate limiting: ${2e3-W}ms until next request allowed`);return}if(c&&!c()){console.log("Parcel fetch blocked by usage tracker");return}F.current&&F.current.abort(),F.current=new AbortController,K.current=q,x(!0),C(null);try{const{data:Q,error:Z}=await Fs.functions.invoke("fetch-viewport-parcels",{body:{...O,limit:25}});if(Z)throw new Error(Z.message);if(!Q.success){if(Q.message){j([]),I([]);return}throw new Error(Q.error||"Failed to fetch parcels")}const oe=Q.parcels||[];j(oe),I(Q.sources||[]),i==="all"&&oe.length>0&&te(oe),oe.length>0&&Ve.success(`Loaded ${oe.length} parcels`,{duration:2e3,id:"viewport-parcels-loaded"})}catch(Q){if(Q instanceof Error&&Q.name==="AbortError")return;const Z=Q instanceof Error?Q.message:"Failed to fetch parcels";C(Z),console.error("Viewport parcels error:",Z)}finally{x(!1)}},[te,i,u,c]);k.useEffect(()=>{if(X.current&&clearTimeout(X.current),!n||u||a<l||!t){j([]),I([]);return}const O=`${t.minLat.toFixed(4)},${t.maxLat.toFixed(4)},${t.minLng.toFixed(4)},${t.maxLng.toFixed(4)}`;if(O!==D.current)return X.current=setTimeout(()=>{D.current=O,J(t)},1500),()=>{X.current&&clearTimeout(X.current)}},[n,a,l,t,J,u]),k.useEffect(()=>()=>{F.current&&F.current.abort(),X.current&&clearTimeout(X.current)},[]);const H=k.useCallback(()=>{t&&n&&a>=l&&!u&&(D.current=null,J(t))},[t,n,a,l,J,u]);return{parcels:_,isLoading:y,error:v,sources:P,refresh:H,isZoomSufficient:a>=l}};function vG(t){return t.map(s=>[s.lng,s.lat])}function bG(t){return t.map(([s,n])=>({lat:n,lng:s}))}function jG(t){if(t.length<3)return t[0]||[0,0];const s=[...t,t[0]],n=Xn([s]);return Yo(n).geometry.coordinates}function wG(t,s,n){return t.map(a=>{const l=us(a),c=us(s),u=gi(c,l,{units:"meters"}),_=Or(c,l)+n;return On(c,u,_,{units:"meters"}).geometry.coordinates})}function NG(t,s,n){return t.map(a=>{const l=us(a),c=us(s),u=gi(c,l,{units:"meters"}),i=Or(c,l),_=u*n;return On(c,_,i,{units:"meters"}).geometry.coordinates})}function kG(t,s,n){return t.map(([a,l])=>[a+s,l+n])}function CG({map:t,overlayId:s,geometry:n,transformMode:a,onTransformModeChange:l,onGeometryChange:c,rotationDegrees:u,hasImageOverlay:i,onRotationChange:_,onTransformEnd:j}){const y=k.useRef(!1),x=k.useRef(!1),v=k.useRef(null),C=k.useRef([]),P=k.useRef([0,0]),I=k.useRef(0),[z,F]=k.useState(!1),D=k.useMemo(()=>Ib(n),[n]),X=k.useMemo(()=>vG(D),[D]),K=k.useMemo(()=>jG(X),[X]);k.useEffect(()=>{if(!t||!z||X.length<3)return;const O="transform-preview-source",q="transform-preview-layer",W="transform-preview-outline";t.getLayer(W)&&t.removeLayer(W),t.getLayer(q)&&t.removeLayer(q),t.getSource(O)&&t.removeSource(O);const Q=[...X,X[0]];return t.addSource(O,{type:"geojson",data:{type:"Feature",geometry:{type:"Polygon",coordinates:[Q]},properties:{}}}),t.addLayer({id:q,type:"fill",source:O,paint:{"fill-color":"#22d3ee","fill-opacity":.3}}),t.addLayer({id:W,type:"line",source:O,paint:{"line-color":"#22d3ee","line-width":2,"line-dasharray":[4,2]}}),()=>{t.getLayer(W)&&t.removeLayer(W),t.getLayer(q)&&t.removeLayer(q),t.getSource(O)&&t.removeSource(O)}},[t,X,z]);const te=k.useCallback(O=>{!a||X.length<3||(y.current=!0,x.current=!1,v.current=[O.lngLat.lng,O.lngLat.lat],C.current=[...X],P.current=K,I.current=u||0,F(!(i&&a==="rotate")),t&&(t.getCanvas().style.cursor=a==="move"?"grabbing":a==="rotate"?"crosshair":a==="scale"?"nwse-resize":"default"))},[a,X,K,u,i,t]),J=k.useCallback(O=>{if(!y.current||!v.current||!a)return;const q=[O.lngLat.lng,O.lngLat.lat],W=v.current,Q=C.current,Z=P.current;if(a==="rotate"&&i){const ce=Or(us(Z),us(W)),ie=Or(us(Z),us(q))-ce;_(I.current+ie,!0),x.current=!0;return}let oe;if(a==="move"){const ce=q[0]-W[0],ae=q[1]-W[1];oe=kG(Q,ce,ae)}else if(a==="rotate"){const ce=Or(us(Z),us(W)),ie=Or(us(Z),us(q))-ce;oe=wG(Q,Z,ie)}else if(a==="scale"){const ce=gi(us(Z),us(W),{units:"meters"}),ae=gi(us(Z),us(q),{units:"meters"}),ie=ce>0?ae/ce:1;oe=NG(Q,Z,Math.max(.1,Math.min(5,ie)))}else return;c(bG(oe),!0),x.current=!0},[a,i,c,_]),H=k.useCallback(()=>{y.current&&(y.current=!1,v.current=null,F(!1),t&&(t.getCanvas().style.cursor=""),x.current&&j())},[t,j]);return k.useEffect(()=>{if(!(!t||!a||X.length<3))return t.on("mousedown",te),t.on("mousemove",J),t.on("mouseup",H),t.dragPan.disable(),(
2594)=>{t.off("mousedown",te),t.off("mousemove",J),t.off("mouseup",H),t.dragPan.enable()}},[t,a,X.length,te,J,H]),null}const SG=({isMapReady:t,pitch:s,handlePitchChange:n,bearing:a,bearingDraft:l,onBearingSliderChange:c,onBearingSliderCommit:u,satelliteTimelineActive:i,setSatelliteTimelineActive:_,satelliteTimelineVersion:j,setSatelliteTimelineVersion:y,satelliteTimelineLabel:x,setSatelliteTimelineLabel:v,satelliteTimelineLoading:C,selectedOverlay3D:P,transformMode3D:I,setTransformMode3D:z,resetView:F,onExit3D:D,drawing3DToolboxOpen:X,onOpenTools:K})=>e.jsxs("div",{className:"absolute top-4 left-4 bg-background/95 backdrop-blur-sm rounded-lg shadow-lg border border-border p-4 space-y-4 z-10 w-72 animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rh,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"3D View"})]}),t&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/20 text-emerald-600 border border-emerald-500/30",children:"Live"})]}),e.jsxs("div",{className:"space-y-3 pb-3 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[e.jsx(pS,{className:"w-3 h-3"}),"Camera"]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Pitch"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s,"°"]})]}),e.jsx(Ca,{value:[s],onValueChange:n,min:0,max:85,step:1,className:"w-full"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-xs",children:"Rotation"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(l??a),"°"]})]}),e.jsx(Ca,{value:[l??a],onValueChange:c,onValueCommit:u,min:-180,max:180,step:1,className:"w-full"})]})]}),e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-border",children:[e.jsxs(B,{className:"text-xs flex items-center gap-1",children:[e.jsx(bg,{className:"w-3 h-3"}),"Historical Imagery"]}),e.jsx(kt,{checked:i,onCheckedChange:_})]}),i&&e.jsxs("div",{className:"space-y-2 pb-3 border-b border-border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Year"}),e.jsx("span",{className:"text-xs font-medium",children:x})]}),C&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Va,{className:"w-3 h-3 animate-spin"}),"Loading..."]}),e.jsxs(rt,{value:j.toString(),onValueChange:te=>{const J=og.find(H=>H.timeId.toString()===te);J&&(y(J.timeId),v(J.label))},children:[e.jsx(it,{className:"h-8 text-xs",children:e.jsx(ct,{})}),e.jsx(ot,{children:og.map(te=>e.jsx(le,{value:te.timeId.toString(),children:te.label},te.timeId))})]})]}),P&&e.jsxs("div",{className:"pb-3 border-b border-border space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[e.jsx(If,{className:"w-3 h-3"}),"Transform"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Le,{size:"sm",variant:I==="move"?"default":"ghost",className:"h-7 w-7 p-0",onClick:()=>z(I==="move"?null:"move"),title:"Move",children:e.jsx(If,{className:"w-3 h-3"})}),e.jsx(Le,{size:"sm",variant:I==="rotate"?"default":"ghost",className:"h-7 w-7 p-0",onClick:()=>z(I==="rotate"?null:"rotate"),title:"Rotate",children:e.jsx(S0,{className:"w-3 h-3"})}),e.jsx(Le,{size:"sm",variant:I==="scale"?"default":"ghost",className:"h-7 w-7 p-0",onClick:()=>z(I==="scale"?null:"scale"),title:"Scale",children:e.jsx(Mf,{className:"w-3 h-3"})}),e.jsxs("span",{className:"text-[10px] text-muted-foreground ml-2",children:[I==="move"&&"Drag to move",I==="rotate"&&"Drag to rotate",I==="scale"&&"Drag to resize",!I&&"Select mode"]})]})]}),e.jsxs("div",{className:"flex gap-2 justify-center",children:[e.jsxs(Le,{variant:"outline",size:"sm",onClick:F,className:"h-8 px-3",children:[e.jsx(mh,{className:"w-3 h-3 mr-1"}),"Reset"]}),D&&e.jsxs(Le,{variant:"default",size:"sm",onClick:D,className:"h-8 px-3",children:[e.jsx(ph,{className:"w-3 h-3 mr-1"}),"2D"]}),!X&&e.jsxs(Le,{variant:"outline",size:"sm",onClick:K,className:"h-8 px-3",children:[e.jsx(cm,{className:"w-3 h-3 mr-1"}),"Tools"]})]})]}),EG=({developments:t,existingProducts:s=[],selectedDevelopment:n,selectedExistingProduct:a,onSelectDevelopment:l,onSelectExistingProduct:c,filters:u,mapSettings:i,mapStyle:_,bearing:j=0,onBearing
2594Change:y,onExit3D:x,initialCenter:v,initialZoom:C,onPositionChange:P,isMeasuring:I=!1,measurementType:z=null,measurementPoints:F=[],onStartMeasuring:D,onAddMeasurementPoint:X,onSetMeasurementPoint:K,onDeleteMeasurementPoint:te,onInsertMeasurementPoint:J,onUndoMeasurement:H,onCancelMeasurement:O,onClearMeasurement:q,isParcelLookupMode:W=!1,drawingPanelOpen:Q,onDrawingPanelOpenChange:Z,drawingPanelOverlayId:oe,onDrawingPanelOverlayIdChange:ce,navigateToOverlay:ae,onClearNavigateToOverlay:ie,stallEditorEnabled:de,onStallEditorEnabledChange:ge,selectedStallId:We,onSelectedStallIdChange:Ee,selectedEntryId:ve,onSelectedEntryIdChange:we,activeGroupId:Ze})=>{const{isEnabled:ke}=$g(),ze=k.useRef([]),Ke=k.useRef(new sG),[dt,Re]=k.useState(!1),[qt,ft]=k.useState(null),[Fe,fe]=k.useState(null),Qe=de??dt,ht=ge??Re,_t=We??qt,He=Ee??ft,as=ve??Fe,vt=we??fe,{mapContainer:Xe,mapRef:Ce,isMapReady:Be,webGLError:Dt,renderError:Rt,isBearingScrubbingRef:zt,currentZoom:rs,viewportBounds:_s}=xG({initialCenter:v,initialZoom:C,pitch:45,bearing:j,buildingTheme:localStorage.getItem("map-3d-building-theme")||"day",buildingHeight:parseFloat(localStorage.getItem("map-3d-building-height")||"1"),buildingOpacity:parseFloat(localStorage.getItem("map-3d-building-opacity")||"0.85"),buildingsEnabled:localStorage.getItem("map-3d-buildings")!=="false",wireframeEnabled:localStorage.getItem("map-3d-wireframe")==="true",getBuildingColors:qs=>{switch(qs){case"night":return{base:"hsl(220, 30%, 20%)",mid:"hsl(220, 25%, 25%)",high:"hsl(220, 20%, 30%)",top:"hsl(220, 15%, 35%)"};case"concrete":return{base:"hsl(0, 0%, 60%)",mid:"hsl(0, 0%, 55%)",high:"hsl(0, 0%, 50%)",top:"hsl(0, 0%, 45%)"};case"glass":return{base:"hsl(200, 40%, 55%)",mid:"hsl(200, 35%, 50%)",high:"hsl(200, 30%, 45%)",top:"hsl(200, 25%, 40%)"};case"terracotta":return{base:"hsl(15, 50%, 55%)",mid:"hsl(15, 45%, 50%)",high:"hsl(15, 40%, 45%)",top:"hsl(15, 35%, 40%)"};default:return{base:"hsl(35, 30%, 70%)",mid:"hsl(35, 25%, 60%)",high:"hsl(35, 20%, 55%)",top:"hsl(35, 15%, 50%)"}}},onBearingChange:y,onPositionChange:P,mapSettings:i}),vs=mG(Ce,Be,j,y),{pitch:$t,buildingHeight:Ns,buildingOpacity:Ts}=vs,{handlePitchChange:bs,resetView:en}=vs,{satelliteTimelineActive:Jt,setSatelliteTimelineActive:Vs,satelliteTimelineVersion:ps,setSatelliteTimelineVersion:nt,satelliteTimelineLabel:ts,setSatelliteTimelineLabel:ds,satelliteTimelineLoading:Is}=hG(Ce,Be),[tn,wn]=k.useState(!1),[Gs,Ue]=k.useState(""),[Pe,je]=k.useState(""),[Ge,De]=k.useState(null),bt=ym(),Ct=pu(),{data:pe=[]}=Cp(),{data:wt=[]}=yj(),[Zt,ys]=k.useState(null),[es,is]=k.useState(!0),[Ws,an]=k.useState(()=>localStorage.getItem("polygon-tools-pinned-3d")==="true"),[ya,Hs]=k.useState(void 0),xt=Q??es,os=qs=>{Z?Z(qs):is(qs)},Ls=oe?pe.find(qs=>qs.id===oe):null,Es=Ls??Zt;k.useEffect(()=>{console.log("[StallEditor State 3D] stallEditorEnabled:",Qe,"selectedOverlay3D ID:",Es==null?void 0:Es.id,"layer_type:",Es==null?void 0:Es.layer_type)},[Qe,Es]),k.useEffect(()=>{Ls&&Ls.id!==(Zt==null?void 0:Zt.id)&&ys(Ls)},[Ls,Zt==null?void 0:Zt.id]);const Qs=k.useCallback(qs=>{ce&&ce((qs==null?void 0:qs.id)??null),ys(qs)},[ce]),[Pn,Ks]=k.useState("none"),[xa,Fn]=k.useState(!1),[Sa,sr]=k.useState(null),[An,Ai]=k.useState(!1),[xi,ei]=k.useState(null),[Yr,Xo]=k.useState(null),ra=k.useRef([]),[Ka,Ha]=k.useState(null),[qa,Mn]=k.useState(null),[_r,Ar]=k.useState(null),[Zs,Cn]=k.useState(null),Na=k.useCallback((qs,Tn)=>{Ct.mutate({id:qs,...Tn}),ys(oa=>!oa||oa.id!==qs?oa:{...oa,...Tn}),Tn.geometry&&Mn(null),Object.prototype.hasOwnProperty.call(Tn,"rotation_degrees")&&Ar(null)},[Ct]),Gn=k.useCallback((qs,Tn)=>{Tn&&(Mn(qs),ys(oa=>oa&&{...oa,geometry:qs}))},[]),sa=k.useCallback((qs,Tn)=>{if(Tn){const oa=(qs%360+360)%360;Ar(oa),ys(Pa=>Pa&&{...Pa,rotation_degrees:oa})}},[]),Pr=k.useCallback(()=>{if(!Es)return;const qs={};qa&&(qs.geometry=qa),_r!==null&&(qs.rotation_degrees=_r),Object.keys(qs).length!==0&&(Na(Es.id,qs),Mn(null),Ar(null),Ha(null),Ve.success("Overlay updated"))},[Es,qa,_r,Na]);k.useEffect(()=>{const qs=Tn=>{if(!Es||["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].indexOf(Tn.key)===-1||Tn.target instanceof HTMLInputElement||Tn.target instanceof HTMLTextAreaElement)return;Tn.preventDefault();
2594const oa=Tn.shiftKey?1:5,Pa=Es.geometry;if(!Array.isArray(Pa)||Pa.length<3)return;const mr=Pa.reduce((Ma,Di)=>Ma+Di.lat,0)/Pa.length,$r=364e3,Jo=364e3*Math.cos(mr*Math.PI/180);let na=0,Sn=0;Tn.key==="ArrowUp"&&(na=oa/$r),Tn.key==="ArrowDown"&&(na=-oa/$r),Tn.key==="ArrowRight"&&(Sn=oa/Jo),Tn.key==="ArrowLeft"&&(Sn=-oa/Jo);const Ui=Pa.map(Ma=>({lat:Ma.lat+na,lng:Ma.lng+Sn}));Na(Es.id,{geometry:Ui})};return window.addEventListener("keydown",qs),()=>window.removeEventListener("keydown",qs)},[Es,Na]);const{dockEdgeSelectionMode:oi,windowEdgeSelectionMode:Tr,canopyEdgeSelectionMode:Ko,storefrontEdgeSelectionMode:Za,driveInEdgeSelectionMode:Gr,hoveredEdgeIndex:Xr,pendingDockEdgeIndex:rn,handleStartDockEdgeSelection:In,handleCancelDockEdgeSelection:Yi,handleDockEdgeClick:jl,handleStartWindowEdgeSelection:Si,handleCancelWindowEdgeSelection:zo,handleWindowEdgeClick:Pc,handleStartCanopyEdgeSelection:Hr,handleCancelCanopyEdgeSelection:ul,handleCanopyEdgeClick:hl,handleStartStorefrontEdgeSelection:Nr,handleCancelStorefrontEdgeSelection:ui,handleStorefrontEdgeClick:Zr,handleStartDriveInEdgeSelection:Gi,handleCancelDriveInEdgeSelection:fn,handleDriveInEdgeClick:kr,setHoveredEdgeIndex:nr}=nG(Ce,Es,pe,Na),{parcels:Br}=yG(_s,{enabled:W,zoom:rs,minZoom:16});fG({map:Ce.current,isMapReady:Be,developments:t,existingProducts:s,selectedDevelopment:n,selectedExistingProduct:a??null,filters:u,onSelectDevelopment:l,onSelectExistingProduct:c}),k.useEffect(()=>{if(!ae||!Ce.current||!Be)return;const qs=ae.geometry;if(Array.isArray(qs)&&qs.length>0){const Tn=qs.map(Pa=>Pa.lng),oa=qs.map(Pa=>Pa.lat);Ce.current.flyTo({center:[(Math.min(...Tn)+Math.max(...Tn))/2,(Math.min(...oa)+Math.max(...oa))/2],zoom:18,duration:1e3}),ie==null||ie()}else if(qs&&typeof qs.lat=="number"){const Tn=qs;Ce.current.flyTo({center:[Tn.lng,Tn.lat],zoom:18,duration:1e3}),ie==null||ie()}},[ae,ie,Be]),aG({map:Ce.current,isMapReady:Be,isMeasuring:I,measurementType:z,measurementPoints:F,onSetMeasurementPoint:K,onDeleteMeasurementPoint:te,onInsertMeasurementPoint:J});const wl=k.useRef(!1);k.useEffect(()=>{if(!Ce.current||!Be||wl.current)return;const qs=Ce.current;wl.current=!0;const Tn=qs.addLayer.bind(qs),oa=qs.addSource.bind(qs);qs.addLayer=(Pa,mr)=>{if(qs.getLayer(Pa.id))return qs;const $r=Tn(Pa,mr);return ze.current.includes(Pa.id)||ze.current.push(Pa.id),$r},qs.addSource=(Pa,mr)=>{if(qs.getSource(Pa)){try{qs.getSource(Pa).setData(mr.data)}catch{}return qs}const $r=oa(Pa,mr);return ze.current.includes(Pa)||ze.current.push(Pa),$r}},[Be]);const Nl=k.useRef(null);k.useEffect(()=>{if(!(!Ce.current||!Be))return Nl.current&&clearTimeout(Nl.current),Nl.current=setTimeout(()=>{const qs=Ce.current;if(qs)try{const Tn=new globalThis.Map;wt.forEach(Sn=>Tn.set(Sn.id,Sn));const oa={map:qs,buildingHeight:Ns,buildingOpacity:Ts,allOverlays:pe,allFolders:wt,overlaysById:new globalThis.Map,foldersById:Tn,stallEditorEnabled:Qe,selectedStallId:_t,selectedOverlayId:(Es==null?void 0:Es.id)??null};pe.forEach(Sn=>oa.overlaysById.set(Sn.id,Sn));const Pa={overlaysById:oa.overlaysById,foldersById:Tn,allOverlays:pe,activeGroupId:Ze},mr=BE(pe,Pa),$r=TE(mr),Jo=Ke.current,na=Jo.renderIncremental($r,oa,(Sn,Ui)=>[eG(qs,Sn,Ui,pe,oa,{onEntryPointClick:(Di,Al,cc)=>{vt(Al),Hs("build"),Qs(cc),os(!0)}})]);ze.current=Jo.getAllLayerIds(),na.added+na.updated+na.removed>0&&console.log(`[Map3D Incremental] ${na.unchanged} unchanged, ${na.added} added, ${na.updated} updated, ${na.removed} removed`)}catch(Tn){console.error("[Map3D] Overlay rendering error:",Tn)}},100),()=>{Nl.current&&clearTimeout(Nl.current)}},[pe,wt,Be,Ns,Ts,Qe,_t]);const lr=k.useCallback((qs,Tn)=>{Hs(Tn),Qs(qs),os(!0)},[Qs,os]),Xi=k.useCallback((qs,Tn)=>{De({overlay:qs,position:Tn})},[]);rG({map:Ce.current,isMapReady:Be,mapOverlays:pe,overlayLayerIds:ze.current,isMeasuring:I,dockEdgeSelectionMode:oi,windowEdgeSelectionMode:Tr,canopyEdgeSelectionMode:Ko,treeEditMode:Pn,cutoutDrawingTargetId:Yr,onSelectOverlay:lr,onHeightEdit:Xi}),iG({map:Ce.current,isMapReady:Be,selectedOverlay:Es,updateOverlay:Ct,treeEditMode:Pn});const ml=k.useCallback(()=>{Fn(!1),sr(null)},[]);oG({map:Ce.current,isMapReady:Be,selectedOverlay:Es,updateOverlay:Ct,signPlacementMode:xa,placingSignId:Sa,onSignPlacementDone:ml});const Co=k.useCallback(()=>{Ai(!1),ei(null)},[]);return lG({map:Ce.current,isMapReady:Be,selectedOverlay:Es,allOverlays:pe,updateOverlay:Ct,entryPointPlacementMode:An,placingEntryType:xi,onEntryPointPlacementDone:Co}),dG({map:Ce.current,isMapReady:Be,stallEditorEnabled:Qe,selectedOverlay:Es,setSelectedStallId:He}),k.useEffect(()=>{ht(!1),He(null)},[Es==null?void 0:Es.id,ht,He]),ux({active:oi,map:Ce.current,isMapReady:Be,overlay:Es,highlightId:"dock-edge-highlight",highlightColor:"#22d3ee",onHover:nr,onClick:jl}),ux({active:Tr,map:Ce.current,isMapReady:Be,overlay:Es,highlightId:"window-edge-highlight",highlightColor:"#38bdf8",onHover:nr,onClick:Pc}),ux({active:Ko,map:Ce.current,isMapReady:Be,overlay:Es,highlightId:"canopy-edge-highlight",highlightColor:"#78716c",onHover:nr,onClick:hl}),ux({active:Za,map:Ce.current,isMapReady:Be,overlay:Es,highlightId:"storefront-edge-highlight",highlightColor:"#38bdf8",onHover:nr,onClick:Zr,paintExpression:["case",["get","selected"],"#22c55e","#38bdf8"],currentEdges:(Es==null?void 0:Es.storefront_edge_indices)||[]}),ux({active:Gr,map:Ce.current,isMapReady:Be,overlay:Es,highlightId:"drivein-edge-highlight",highlightColor:"#f59e0b",onHover:nr,onClick:kr}),k.useCallback((qs,Tn)=>{const oa=Ce.current;if(!oa)return;const Pa=`overlay-layer-${qs}-fill`;if(oa.getLayer(Pa))try{const mr=oa.getLayer(Pa);mr&&mr.type==="fill-extrusion"&&oa.setPaintProperty(Pa,"fill-extrusion-height",Tn*.3048)}catch(mr){console.warn("Failed to update height preview:",mr)}},[]),uG({map:Ce.current,isMapReady:Be,isParcelLookupMode:W,viewportParcels:Br}),k.useCallback(()=>
2594{if(!F.length)return null;if(z==="distance"){const qs=Zj(F);return{distance:g0(qs),driveTime:CT(qs),walkTime:ST(qs)}}else if(z==="area"&&F.length>=3)return{area:PT(ET(F)),perimeter:g0(kT(F))};return null},[F,z])(),z==="distance"&&F.length>=2||z==="area"&&F.length>=3,k.useCallback(async()=>{if(!Gs.trim()||F.length===0){Ve.error("Please enter a name");return}try{await bt.mutateAsync({name:Gs.trim(),type:z==="distance"?"polyline":"polygon",geometry:F,style:{color:"#10b981",fillColor:"#10b981",fillOpacity:.2,weight:2},description:Pe.trim()||`${z==="distance"?"Distance":"Area"} measurement`,is_visible:!0}),Ve.success(`Saved "${Gs}" as overlay`),Ue(""),je(""),wn(!1),O==null||O()}catch{Ve.error("Failed to save measurement")}},[F,z,bt,Gs,Pe,O]),Dt||Rt?e.jsx("div",{className:"relative w-full h-full flex items-center justify-center bg-background",children:e.jsxs("div",{className:"max-w-md p-6 rounded-lg border border-border bg-card text-center space-y-4 shadow-lg",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"p-3 rounded-full bg-muted",children:e.jsx(Rh,{className:"w-10 h-10 text-muted-foreground"})})}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"3D View Under Redesign"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"We're improving the 3D satellite experience. Features returning soon:"}),e.jsxs("ul",{className:"text-xs text-muted-foreground text-left list-disc pl-6 space-y-1.5",children:[e.jsx("li",{children:"Terrain elevation with hill shading"}),e.jsx("li",{children:"Historical satellite timeline (2014–present)"}),e.jsx("li",{children:"3D building extrusions"}),e.jsx("li",{children:"Compare mode for before/after views"})]}),(Dt||Rt)&&e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-destructive/10 border border-destructive/20 text-xs text-destructive",children:[e.jsx(ho,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:Dt||Rt})]}),x&&e.jsxs(Le,{onClick:x,className:"w-full",children:[e.jsx(ph,{className:"w-4 h-4 mr-2"}),"Back to 2D Map"]})]})}):e.jsxs("div",{className:"relative w-full h-full",children:[e.jsx("div",{ref:Xe,className:"absolute inset-0 w-full h-full",style:{minHeight:"400px"}}),!Be&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx(Va,{className:"w-8 h-8 animate-spin text-primary"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading 3D satellite view..."})]})}),e.jsx(SG,{isMapReady:Be,pitch:$t,handlePitchChange:bs,bearing:j,bearingDraft:Zs,onBearingSliderChange:qs=>{zt.current=!0,Cn(qs[0]),Ce.current&&Ce.current.setBearing(qs[0])},onBearingSliderCommit:qs=>{zt.current=!1,Cn(null),y==null||y(qs[0])},satelliteTimelineActive:Jt,setSatelliteTimelineActive:Vs,satelliteTimelineVersion:ps,setSatelliteTimelineVersion:nt,satelliteTimelineLabel:ts,setSatelliteTimelineLabel:ds,satelliteTimelineLoading:Is,selectedOverlay3D:Es,transformMode3D:Ka,setTransformMode3D:Ha,resetView:en,onExit3D:x,drawing3DToolboxOpen:xt,onOpenTools:()=>{if(os(!0),!Es){const qs=["property_outline","site_boundary","lot","easement","landscaping","stormwater"],Tn=pe.find(oa=>oa.is_visible!==!1&&oa.geometry&&Array.isArray(oa.geometry)&&oa.geometry.length>=3&&!qs.includes(oa.layer_type||""));Tn&&Qs(Tn)}}}),Es&&Es.geometry&&Es.geometry.length>=3&&Be&&e.jsx(CG,{map:Ce.current,overlayId:Es.id,geometry:qa||Es.geometry,transformMode:Ka,onTransformModeChange:Ha,onGeometryChange:Gn,rotationDegrees:Es.rotation_degrees||0,hasImageOverlay:!!Es.image_url,onRotationChange:sa,onTransformEnd:Pr}),ke&&e.jsx(vT,{open:xt&&!!Es,onClose:()=>{Ws||(os(!1),Qs(null))},overlay:Es,allOverlays:pe,mode:"3d",initialTab:ya,isPinned:Ws,onPinnedChange:qs=>{an(qs),localStorage.setItem("polygon-tools-pinned-3d",qs.toString())},onModeChange:qs=>{qs==="2d"&&x&&x()},transformMode:Ka,onTransformModeChange:Ha,onStartDockEdgeSelection:In,onCancelDockEdgeSelection:Yi,dockEdgeSelectionMode:oi,pendingDockEdgeIndex:rn,onStartWindowEdgeSelection:Si,onCancelWindowEdgeSelection:zo,windowEdgeSelectionMode:Tr,onStartCanopyEdgeSelection:Hr,onCancelCanopyEdgeSelection:ul,canopyEdgeSelectionMode:Ko,onStartStorefrontEdgeSelection:Nr,onCancelStorefrontEdgeSelection:ui,storefrontEdgeSelectionMode:Za,onStartDriveInEdgeSelection:Gi,onCancelDriveInEdgeSelection:fn,driveInEdgeSelectionMode:Gr,treeEditMode:Pn,onTreeEditModeChange:Ks,onStartSignPlacement:qs=>{Fn(!0),sr(qs)},onCancelSignPlacement:()=>{Fn(!1),sr(null)},signPlacementMode:xa,placingSignId:Sa,onNavigateToOverlay:qs=>{const Tn=pe.find(oa=>oa.id===qs);Tn&&Qs(Tn)},onSelectOverlay:qs=>{if(Qs(qs),qs.geometry&&Ce.current){const Tn=qs.geometry;if(Tn.length===1)Ce.current.flyTo({center:[Tn[0].lng,Tn[0].lat],zoom:17,duration:800});else if(Tn.length>1){const oa=Tn.map(mr=>mr.lng),Pa=Tn.map(mr=>mr.lat);Ce.current.fitBounds([[Math.min(...oa),Math.min(...Pa)],[Math.max(...oa),Math.max(...Pa)]],{padding:60,maxZoom:18,duration:800})}}},stallEditorEnabled:Qe,onStallEditorEnabledChange:ht,selectedStallId:_t,onSelectedStallIdChange:He,selectedEntryId:as,onSelectedEntryIdChange:vt,entryPointPlacementMode:An,onStartEntryPointPlacement:qs=>{Ai(!0),ei(qs)},onCancelEntryPointPlacement:()=>{Ai(!1),ei(null)},onCreateChildLayer:(qs,Tn)=>{const oa=pe.find(Pa=>Pa.id===Tn);if(oa&&oa.geometry){const Pa=oa.geometry;Pa.length>0&&bt.mutateAsync({name:`${qs.replace(/_/g," ").replace(/\b\w/g,mr=>mr.toUpperCase())}`,layer_type:qs,type:"polygon",geometry:Pa,style:{}
2594,is_visible:!0,parent_overlay_id:Tn,development_id:oa.development_id||void 0,existing_product_id:oa.existing_product_id||void 0}).then(mr=>{mr&&(Qs(mr),Ve.success(`Created ${qs.replace(/_/g," ")} child layer`))}).catch(()=>{Ve.error("Failed to create child layer")})}},onStartCutoutDrawing:qs=>{Xo(qs),ra.current=[],os(!1),Ve.info("Click on the map to draw a cutout zone. Click the first point again to close."),Ce.current&&(Ce.current.getCanvas().style.cursor="crosshair")}})]})},PG=({user:t,isAdmin:s,onSignOut:n,onShowEmbedCode:a,onShowSuggestionsPanel:l,onShowUserManagement:c,onShowMapOverlays:u,onOpenAdminDashboardTab:i,onShowAdminPanel:_,onShowUserDashboard:j,onShowRegionFilter:y,onShowSidebar:x,onShowSiteArchitectDashboard:v})=>{const C=b0(),[P,I]=k.useState(!1),{isEnabled:z}=$g(),F=({icon:X,label:K,onClick:te,active:J=!1})=>e.jsxs("button",{onClick:te,className:fs("flex flex-col items-center justify-center gap-1 flex-1 py-2 px-1 min-w-0 touch-manipulation min-h-[44px]","text-muted-foreground hover:text-foreground active:text-foreground transition-colors",J&&"text-primary"),children:[e.jsx(X,{className:"w-5 h-5"}),e.jsx("span",{className:"text-[10px] font-medium truncate w-full text-center",children:K})]}),D=({icon:X,label:K,onClick:te})=>e.jsxs(Le,{variant:"ghost",className:"w-full justify-start gap-3 h-12",onClick:()=>{te(),I(!1)},children:[e.jsx(X,{className:"w-5 h-5"}),e.jsx("span",{children:K})]});return e.jsx("div",{className:"md:hidden fixed bottom-0 left-0 right-0 z-50 bg-background border-t border-border safe-area-bottom",children:e.jsxs("nav",{className:"flex items-stretch h-16 px-1",children:[x&&e.jsx(F,{icon:GC,label:"Sites",onClick:x}),e.jsx(F,{icon:Bm,label:"Dashboard",onClick:j}),e.jsx(F,{icon:wg,label:"Filter",onClick:y}),s&&e.jsx(F,{icon:dp,label:"Admin",onClick:_}),e.jsxs(B0,{open:P,onOpenChange:I,children:[e.jsx(xD,{asChild:!0,children:e.jsxs("button",{className:fs("flex flex-col items-center justify-center gap-1 flex-1 py-2 px-1 min-w-0 touch-manipulation min-h-[44px]","text-muted-foreground hover:text-foreground active:text-foreground transition-colors"),children:[e.jsx(Mg,{className:"w-5 h-5"}),e.jsx("span",{className:"text-[10px] font-medium",children:"More"})]})}),e.jsxs(m_,{side:"bottom",className:"h-auto max-h-[80vh]",children:[e.jsx($0,{children:e.jsx(V0,{children:"Menu"})}),e.jsxs("div",{className:"py-4 space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground px-4 py-2",children:"Views"}),e.jsx(D,{icon:L1,label:"Embed Map",onClick:a}),e.jsx(D,{icon:wg,label:"Filter",onClick:y}),z&&s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-4 py-2 mt-4 flex items-center gap-2",children:e.jsx(Oy,{size:"sm"})}),v&&e.jsx(D,{icon:Bm,label:"Site Architect Dashboard",onClick:v}),e.jsx(D,{icon:Da,label:"Map Overlays",onClick:u}),e.jsx(D,{icon:Zd,label:"Retailer Logos",onClick:()=>i("logos")})]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground px-4 py-2 mt-4",children:"Admin"}),e.jsx(D,{icon:dp,label:"Admin Panel",onClick:_}),e.jsx(D,{icon:K1,label:"Suggestions",onClick:l}),e.jsx(D,{icon:yl,label:"User Management",onClick:c})]}),e.jsx("div",{className:"pt-4 mt-4 border-t border-border",children:t?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground px-4",children:t.email}),e.jsx(D,{icon:J1,label:"Sign Out",onClick:n})]}):e.jsx(D,{icon:pp,label:"Sign In",onClick:()=>C("/auth")})})]})]})]})]})})},TG={tilePane:"base",boundaryPane:"boundary",parcelPane:"parcel",overlayPane:"overlay",markersPane:"marker",tooltipsPane:"ui",popupsPane:"ui",municipalityPopupPane:"ui"},LG={base:"bg-slate-500",boundary:"bg-blue-500",parcel:"bg-amber-500",overlay:"bg-green-500",marker:"bg-purple-500",ui:"bg-gray-400"};function MG({mapRef:t,className:s,parcelDiagnostics:n}){var I;const[a,l]=k.useState(!1),[c,u]=k.useState([]),[i,_]=k.useState(null),[j,y]=k.useState(!1),[x,v]=k.useState(!0),C=k.useCallback(()=>{if(!t.current)return;const z=["tilePane","shadowPane","boundaryPane","parcelPane","overlayPane","markersPane","tooltipsPane","popupsPane","municipalityPopupPane"],F=[];z.forEach(D=>{var K;const X=(K=t.current)==null?void 0:K.getPane(D);if(X){const J=window.getComputedStyle(X).zIndex;F.push({name:D,inlineZIndex:X.style.zIndex||"none",computedZIndex:J||"auto",className:X.className||"",childCount:X.childElementCount,category:TG[D]||"base"})}}),F.sort((D,X)=>{const K=parseInt(D.computedZIndex)||0;return(parseInt(X.computedZIndex)||0)-K}),u(F),_(new Date)},[t]);k.useEffect(()=>
2594{if(a&&(C(),x)){const z=setInterval(C,500);return()=>clearInterval(z)}},[a,t,x,C]);const P=n&&n.isParcelLookupMode&&(!n.parcelsLayerVisible||n.currentZoom<15||!n.tileLayerOnMap);return a?e.jsxs("div",{className:fs("fixed right-14 top-14 bg-background/95 backdrop-blur-sm border border-border rounded-lg shadow-lg p-3 min-w-[280px] max-w-[320px] max-h-[calc(100vh-80px)] overflow-y-auto z-50",s),children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Da,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Layer Debug"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Le,{variant:"ghost",size:"icon",onClick:C,className:"h-6 w-6",title:"Refresh",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"}),e.jsx("path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"}),e.jsx("path",{d:"M16 16h5v5"})]})}),e.jsx(Le,{variant:"ghost",size:"icon",onClick:()=>l(!1),className:"h-6 w-6",children:e.jsx(ja,{className:"h-3 w-3"})})]})]}),n&&e.jsxs("div",{className:"mb-3 pb-3 border-b border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-amber-500"}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Parcel Diagnostics"})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx(Am,{label:"Parcel Locator",value:n.isParcelLookupMode?"ON":"OFF",isOk:n.isParcelLookupMode,highlight:!n.isParcelLookupMode}),e.jsx(Am,{label:"Zoom",value:n.currentZoom.toFixed(1),isOk:n.currentZoom>=15,highlight:n.isParcelLookupMode&&n.currentZoom<15,warning:n.isParcelLookupMode&&n.currentZoom<15?"Need 15+":void 0}),e.jsx(Am,{label:"Layer Visible",value:n.parcelsLayerVisible?"YES":"NO",isOk:n.parcelsLayerVisible,highlight:n.isParcelLookupMode&&!n.parcelsLayerVisible}),e.jsx(Am,{label:"Pane Exists",value:n.parcelPaneExists?"YES":"NO",isOk:n.parcelPaneExists,highlight:!n.parcelPaneExists}),e.jsx(Am,{label:"Tile Layer",value:n.tileLayerExists?"CREATED":"NULL",isOk:n.tileLayerExists||!n.isParcelLookupMode}),e.jsx(Am,{label:"On Map",value:n.tileLayerOnMap?"YES":"NO",isOk:n.tileLayerOnMap||!n.isParcelLookupMode,highlight:n.isParcelLookupMode&&n.currentZoom>=15&&!n.tileLayerOnMap}),n.tileLayerExists&&e.jsxs(e.Fragment,{children:[e.jsx(Am,{label:"Pane Name",value:n.tileLayerPaneName||"default",isOk:n.tileLayerPaneName==="parcelPane"}),e.jsx(Am,{label:"Z-Index",value:n.tileLayerZIndex||"auto",isOk:!0}),e.jsx(Am,{label:"Opacity",value:((I=n.tileLayerOpacity)==null?void 0:I.toFixed(1))||"N/A",isOk:n.tileLayerOpacity!=null&&n.tileLayerOpacity>.5})]})]})]}),e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Pane Z-Indices (Computed)"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Le,{variant:"ghost",size:"icon",onClick:()=>y(!j),className:"h-5 w-5",title:j?"Hide details":"Show details",children:j?e.jsx(Wc,{className:"h-3 w-3"}):e.jsx(kc,{className:"h-3 w-3"})}),e.jsx(Le,{variant:"ghost",size:"icon",onClick:()=>v(!x),className:fs("h-5 w-5",x&&"text-emerald-500"),title:x?"Auto-refresh ON":"Auto-refresh OFF",children:e.jsx(N0,{className:fs("h-3 w-3",x&&"animate-spin"),style:{animationDuration:"3s"}})})]})]}),i&&e.jsxs("div",{className:"text-[10px] text-muted-foreground mb-2",children:["Last updated: ",i.toLocaleTimeString()]}),e.jsx("div",{className:"space-y-1.5",children:c.map(z=>{const F=parseInt(z.computedZIndex)||0,D=parseInt(z.inlineZIndex)||0,X=z.inlineZIndex!=="none"&&F!==D;return e.jsxs("div",{className:fs("text-xs py-1 px-2 rounded bg-muted/50",X&&"border border-amber-500/50"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:fs("w-2 h-2 rounded-full",LG[z.category])}),e.jsx("span",{className:"font-mono text-muted-foreground",children:z.name.replace("Pane","")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:fs("font-mono font-bold tabular-nums",z.category==="parcel"?"text-amber-400":""),children:z.computedZIndex}),X&&e.jsxs("span",{className:"text-[10px] text-amber-500",title:"Inline vs computed mismatch",children:["(inline: ",z.inlineZIndex,")"]})]})]}),j&&e.jsxs("div",{className:"mt-1 text-[10px] text-muted-foreground space-y-0.5 pl-4",children:[e.jsxs("div",{children:["Class: ",e.jsx("span",{className:"font-mono",children:z.className.split(" ").slice(0,2).join(" ")})]}),e.jsxs("div",{children:["Children: ",z.childCount]})]})]},z.name)}
2594)}),e.jsx("div",{className:"mt-3 pt-2 border-t border-border/50",children:e.jsxs("div",{className:"flex flex-wrap gap-2 text-[10px]",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500"}),e.jsx("span",{className:"text-muted-foreground",children:"Boundary"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-amber-500"}),e.jsx("span",{className:"text-muted-foreground",children:"Parcel"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500"}),e.jsx("span",{className:"text-muted-foreground",children:"Overlay"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-purple-500"}),e.jsx("span",{className:"text-muted-foreground",children:"Marker"})]})]})}),e.jsx("div",{className:"mt-2 text-[10px] text-muted-foreground",children:"✓ Correct order: boundary < parcel < overlay < marker"})]}):e.jsx(Le,{variant:"outline",size:"icon",onClick:()=>l(!0),className:fs("h-8 w-8 bg-background/90 backdrop-blur-sm border-border/50 hover:bg-background",P&&"border-amber-500/50",s),title:"Layer Debug Panel",children:e.jsx(l3,{className:fs("h-4 w-4",P?"text-amber-500":"text-muted-foreground")})})}function Am({label:t,value:s,isOk:n,highlight:a=!1,warning:l}){return e.jsxs("div",{className:fs("flex items-center justify-between py-0.5 px-1.5 rounded",a&&"bg-amber-500/10"),children:[e.jsx("span",{className:"text-muted-foreground",children:t}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[l&&e.jsx("span",{className:"text-amber-500 text-[10px]",children:l}),e.jsx("span",{className:fs("font-mono font-medium",n?"text-emerald-500":"text-amber-500"),children:s}),n?e.jsx(bp,{className:"w-3 h-3 text-emerald-500"}):e.jsx(ho,{className:"w-3 h-3 text-amber-500"})]})]})}function IG({parcelRequests:t,tileRequests:s,parcelUsagePercent:n,tileUsagePercent:a,isParcelWarning:l,isTileWarning:c,isParcelLimitReached:u,isTileLimitReached:i,isLocked:_,limits:j,onSyncWithApi:y}){const[x,v]=k.useState(!1),C=l||c,P=u||i,I=()=>_||P?"bg-destructive text-destructive-foreground":C?"bg-warning text-warning-foreground":"bg-muted text-muted-foreground",z=async()=>{v(!0);try{const{data:F,error:D}=await Fs.functions.invoke("check-parcel-quota");if(D)throw D;if(F&&y){const X=F.parcelLimit-F.parcelRemaining,K=F.tileLimit-F.tileRemaining;y(X,K,F.parcelLimit,F.tileLimit),Ve.success(`Synced with API: ${X.toLocaleString()} parcels, ${K.toLocaleString()} tiles used`)}}catch(F){console.error("Failed to sync with API:",F),Ve.error("Failed to sync with API quota")}finally{v(!1)}};return e.jsxs(Ef,{children:[e.jsx(Pf,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",size:"sm",className:fs("h-8 px-2 gap-1.5 transition-colors",I()),children:[_?e.jsx(jc,{className:"h-4 w-4"}):C?e.jsx(ho,{className:"h-4 w-4"}):e.jsx(Fu,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:_?"Limit Reached":`${t.toLocaleString()}/${j.maxParcelRequests.toLocaleString()}`})]})}),e.jsx(Tf,{className:"w-80",align:"end",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-semibold text-sm",children:"API Usage (Account)"}),_&&e.jsx(Mt,{variant:"destructive",className:"text-xs",children:"Limit Reached"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Fu,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:"Parcel Requests"})]}),e.jsxs("span",{className:fs("font-medium",u&&"text-destructive",l&&"text-warning"),children:[t.toLocaleString()," / ",j.maxParcelRequests.toLocaleString()]})]}),e.jsx(Ay,{value:n*100,className:"h-2"}),u&&e.jsx("p",{className:"text-xs text-destructive",children:"Account limit reached. Parcel loading disabled."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ph,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:"Tile Requests"})]}),e.jsxs("span",{className:fs("font-medium",i&&"text-destructive",c&&"text-warning"),children:[s.toLocaleStr
2594ing()," / ",j.maxTileRequests.toLocaleString()]})]}),e.jsx(Ay,{value:a*100,className:"h-2"}),i&&e.jsx("p",{className:"text-xs text-destructive",children:"Account limit reached. Tile loading disabled."})]})]}),e.jsxs("div",{className:"border-t pt-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Account-level API quota from Report All USA. Contact support if you need higher limits."}),y&&e.jsxs(Le,{variant:"outline",size:"sm",className:"w-full gap-2",onClick:z,disabled:x,children:[e.jsx(N0,{className:`h-4 w-4 ${x?"animate-spin":""}`}),"Sync with API Quota"]})]})]})})]})}const AG=({isAdmin:t=!1,compact:s=!1})=>{const[n,a]=k.useState(!1),[l,c]=k.useState("permits"),[u,i]=k.useState(!1);return k.useEffect(()=>{const _=()=>{a(!0)};return window.addEventListener("open-municipal-intel",_),()=>{window.removeEventListener("open-municipal-intel",_)}},[]),t?e.jsxs(dd,{open:n,onOpenChange:a,children:[e.jsx(X5,{asChild:!0,children:e.jsxs(Le,{variant:"outline",size:"sm",className:s?"h-7 w-full text-[10px] gap-1 bg-gradient-to-r from-blue-500/10 to-cyan-500/10 border-blue-500/30 hover:border-blue-500/50":"gap-2 bg-gradient-to-r from-blue-500/10 to-cyan-500/10 border-blue-500/30 hover:border-blue-500/50",children:[e.jsx(hd,{className:s?"w-3.5 h-3.5 text-blue-500":"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"font-medium",children:s?"Intel":"Municipal Intel"})]})}),e.jsxs(ud,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsx(Gd,{children:e.jsxs(Hd,{className:"flex items-center gap-2",children:[e.jsx(hd,{className:"w-5 h-5 text-blue-500"}),"Municipal Intel — Public Records",e.jsx(Le,{variant:"ghost",size:"icon",className:"ml-auto h-7 w-7",onClick:()=>i(!u),children:e.jsx(H1,{className:"w-4 h-4 text-muted-foreground"})})]})}),u&&e.jsxs("div",{className:"p-4 rounded-lg bg-gradient-to-br from-blue-500/5 to-cyan-500/5 border border-blue-500/20 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(hd,{className:"w-4 h-4 text-blue-500"}),"What I Do"]}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-6 w-6 -mt-1 -mr-1",onClick:()=>i(!1),children:e.jsx(ja,{className:"w-3.5 h-3.5"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"I search and monitor municipal records including building permits, zoning applications, planning board agendas, and official government filings to identify development activity at its earliest stages."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-medium",children:"What I Provide"}),e.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"Building permit applications and approvals"}),e.jsx("li",{children:"Zoning variance and conditional use requests"}),e.jsx("li",{children:"Planning board meeting agendas and minutes"}),e.jsx("li",{children:"Land development plan submissions"}),e.jsx("li",{children:"Official municipal notifications"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1",children:[e.jsx(ho,{className:"w-3 h-3"}),"What I Don't Do"]}),e.jsx("p",{className:"text-xs text-muted-foreground/80 italic",children:"I don't analyze market trends, interpret competitive signals, or provide strategic insights. My role is to surface official records — not interpret what they mean for your business."})]})]}),e.jsxs(Zm,{value:l,onValueChange:_=>c(_),className:"flex-1 flex flex-col min-h-0",children:[e.jsxs(mm,{className:"grid w-full grid-cols-3 h-auto gap-1 p-1",children:[e.jsxs(Bi,{value:"permits",className:"flex flex-col items-center gap-1 py-2 px-3",children:[e.jsx(zb,{className:"w-5 h-5"}),e.jsx("span",{className:"text-xs",children:"Permits"})]}),e.jsxs(Bi,{value:"zoning",className:"flex flex-col items-center gap-1 py-2 px-3",children:[e.jsx(nN,{className:"w-5 h-5"}),e.jsx("span",{className:"text-xs",children:"Zoning"})]}),e.jsxs(Bi,{value:"agendas",className:"flex flex-col items-center gap-1 py-2 px-3",children:[e.jsx(Sf,{className:"w-5 h-5"}),e.jsx("span",{className:"text-xs",children:"Agendas"})]})]}
2594),e.jsxs($i,{value:"permits",className:"space-y-4 mt-4 flex-1 overflow-auto",children:[e.jsx("div",{className:"p-3 rounded-lg bg-blue-500/5 border border-blue-500/20",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"Search building permit applications, approvals, and construction filings from municipal databases."})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Search Permits"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ld,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(be,{placeholder:"e.g., commercial construction Lancaster County",className:"pl-9"})]}),e.jsx(Le,{size:"icon",children:e.jsx(Ld,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(zb,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm font-medium",children:"Permit Search Coming Soon"}),e.jsx("p",{className:"text-xs mt-1",children:"Municipal Intel integration is in development."}),e.jsx(Mt,{variant:"secondary",className:"mt-3 bg-blue-500/10 text-blue-600",children:"Planned Feature"})]})]}),e.jsxs($i,{value:"zoning",className:"space-y-4 mt-4 flex-1 overflow-auto",children:[e.jsx("div",{className:"p-3 rounded-lg bg-blue-500/5 border border-blue-500/20",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"Track zoning variance requests, conditional use applications, and land use changes."})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Search Zoning Actions"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ld,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(be,{placeholder:"e.g., variance request retail development",className:"pl-9"})]}),e.jsx(Le,{size:"icon",children:e.jsx(Ld,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(nN,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm font-medium",children:"Zoning Search Coming Soon"}),e.jsx("p",{className:"text-xs mt-1",children:"Municipal Intel integration is in development."}),e.jsx(Mt,{variant:"secondary",className:"mt-3 bg-blue-500/10 text-blue-600",children:"Planned Feature"})]})]}),e.jsxs($i,{value:"agendas",className:"space-y-4 mt-4 flex-1 overflow-auto",children:[e.jsx("div",{className:"p-3 rounded-lg bg-blue-500/5 border border-blue-500/20",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monitor planning board and zoning hearing board agendas for upcoming development discussions."})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:"Search Meeting Agendas"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ld,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(be,{placeholder:"e.g., planning commission January 2024",className:"pl-9"})]}),e.jsx(Le,{size:"icon",children:e.jsx(Ld,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Sf,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm font-medium",children:"Agenda Search Coming Soon"}),e.jsx("p",{className:"text-xs mt-1",children:"Municipal Intel integration is in development."}),e.jsx(Mt,{variant:"secondary",className:"mt-3 bg-blue-500/10 text-blue-600",children:"Planned Feature"})]})]})]}),e.jsx("div",{className:"pt-4 border-t border-border mt-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(hd,{className:"w-3.5 h-3.5 text-blue-500"}),e.jsx("span",{children:"Municipal Intel — Official Records"})]})})})]})]}):null},DG=({user:t,isAdmin:s,onSignOut:n,onShowEmbedCode:a,onShowSuggestionsPanel:l,onShowUserManagement:c,onShowMapOverlays:u,onShowMapStyle:i,onShowNomenclature:_,onShowAdminDashboard:j,onShowUserDashboard:y,onOpenAdminDashboardTab:x,onShowLegend:v,onShowReviewPanel:C,mapTitle:P="",onMapTitleChange:I,mapSettings:z,onMapSett
2594ingChange:F,onLayerOrderChange:D,onLayerVisibilityChange:X,onShowControls:K,onStartMeasuring:te,onShowDrawingTools:J,onShowSiteArchitectDashboard:H})=>{var ve;const O=b0(),{toast:q}=r5(),{isEnabled:W}=$g(),[Q,Z]=k.useState(!1),[oe,ce]=k.useState(!1),[ae,ie]=k.useState(P);k.useState(!1);const[de,ge]=k.useState(!1),We=async()=>{ge(!0);try{const{supabase:we}=await br(async()=>{const{supabase:Re}=await import("./index-Do7gCgTf.js").then(qt=>qt.aP);return{supabase:Re}},__vite__mapDeps([1,2])),{data:{session:Ze}}=await we.auth.getSession();if(!Ze)throw new Error("Not authenticated");const ke=await fetch("https://ntrjyokaupvmnftawavp.supabase.co/functions/v1/export-devwatch-data",{headers:{Authorization:`Bearer ${Ze.access_token}`}});if(!ke.ok)throw new Error(await ke.text());const ze=await ke.blob(),Ke=URL.createObjectURL(ze),dt=document.createElement("a");dt.href=Ke,dt.download=`site-architect-export-${new Date().toISOString().slice(0,10)}.sql`,dt.click(),URL.revokeObjectURL(Ke),q({title:"Export downloaded",description:"SQL file ready to import into your remix."})}catch(we){q({title:"Export failed",description:we.message,variant:"destructive"})}finally{ge(!1)}},Ee=({icon:we,label:Ze,onClick:ke,badge:ze,disabled:Ke=!1})=>e.jsxs(co,{onClick:()=>{ke(),Z(!1)},disabled:Ke,className:"gap-3 cursor-pointer",children:[e.jsx(we,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{className:"flex-1",children:Ze}),ze!==void 0&&ze>0&&e.jsx(Mt,{variant:"destructive",className:"text-xs h-5 px-1.5 min-w-5 justify-center",children:ze})]});return e.jsxs(jp,{open:Q,onOpenChange:Z,children:[e.jsx(wp,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(GC,{className:"h-4 w-4"})})}),e.jsxs(Np,{align:"end",className:"w-64 max-h-[80vh] overflow-y-auto bg-popover",sideOffset:8,children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(zm,{className:"flex items-center gap-2",children:[e.jsx(Ep,{className:"w-4 h-4"}),e.jsx("span",{className:"truncate flex-1",children:((ve=t.email)==null?void 0:ve.split("@")[0])||"User"}),s&&e.jsx(Mt,{variant:"default",className:"text-[10px] px-1.5 py-0",children:"Admin"})]}),e.jsx(cd,{})]}),e.jsxs(I_,{children:[e.jsxs(zm,{className:"text-xs text-muted-foreground flex items-center gap-2",children:[e.jsx(tj,{className:"w-3 h-3"}),"Tools"]}),te&&e.jsx(Ee,{icon:Fo,label:"Measure",onClick:()=>te("distance")})]}),s&&W&&J&&e.jsxs(e.Fragment,{children:[e.jsx(cd,{}),e.jsxs(I_,{children:[e.jsxs(zm,{className:"text-xs text-muted-foreground flex items-center gap-2",children:[e.jsx(Du,{className:"w-3 h-3"}),"Site Architect"]}),e.jsx(Ee,{icon:T3,label:"Draw",onClick:J})]})]}),s&&e.jsxs(e.Fragment,{children:[e.jsx(cd,{}),e.jsxs(I_,{children:[e.jsxs(zm,{className:"text-xs text-muted-foreground flex items-center gap-2",children:[e.jsx(hd,{className:"w-3 h-3"}),"Administration"]}),e.jsx(Ee,{icon:Fu,label:"Dashboard",onClick:()=>O("/dashboard")}),e.jsx(co,{onSelect:we=>we.preventDefault(),className:"gap-3 p-0",children:e.jsx(AG,{isAdmin:s,compact:!1})}),e.jsx(Ee,{icon:yl,label:"User Management",onClick:()=>O("/dashboard?tab=users")}),e.jsx(Ee,{icon:cm,label:"3D Models",onClick:()=>O("/admin/3d-models")}),e.jsx(Ee,{icon:L1,label:"Embed Code",onClick:a}),e.jsx(Ee,{icon:h5,label:de?"Exporting...":"Export Data",onClick:We,disabled:de})]})]}),s&&I&&e.jsxs(e.Fragment,{children:[e.jsx(cd,{}),e.jsxs(I_,{children:[e.jsxs(zm,{className:"text-xs text-muted-foreground flex items-center gap-2",children:[e.jsx(dp,{className:"w-3 h-3"}),"Map Settings"]}),e.jsx("div",{className:"px-2 py-1.5",children:oe?e.jsxs("div",{className:"flex gap-1",children:[e.jsx(be,{value:ae,onChange:we=>ie(we.target.value),className:"h-7 text-xs",autoFocus:!0,onKeyDown:we=>{we.key==="Enter"?(I(ae),ce(!1)):we.key==="Escape"&&(ie(P),ce(!1)),we.stopPropagation()},onClick:we=>we.stopPropagation()}),e.jsx(Le,{size:"icon",variant:"ghost",className:"h-7 w-7 shrink-0",onClick:we=>{we.stopPropagation(),I(ae),ce(!1)},children:e.jsx(cl,{className:"w-3 h-3"})}),e.jsx(Le,{size:"icon",variant:"ghost",className:"h-7 w-7 shrink-0",onClick:we=>{we.stopPropagation(),ie(P),ce(!1)},children:e.jsx(ja,{className:"w-3 h-3"})})]}):e.jsxs("button",{onClick:we=>{we.stopPropagation(),ie(P),ce(!0)},className:"w-full flex items-center gap-2 p-1.5 rounded hover:bg-accent transition-colors text-left text-xs",children:[e.jsx("span",{className:"truncate flex-1",children:P||"Click to set map title"}),e.jsx(kp,{className:"w-3 h-3 text-muted-foreground shrink-0"})]})}),e.jsxs(Mx,{children:[e.jsxs(Ix,{className:"gap-3",children:[e.jsx(dp,{className:"w-4 h-4"}),e.jsx("span",{children:"Center & Zoom"})]}),e.jsx(Ax,{className:"w-48 p-2 space-y-2",children:F&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Center Latitude"}),e.jsx(be,{value:(z==null?void 0:z.map_center_lat)||"",onChange:we=>F("map_center_lat",we.target.value),className:"h-7 text-xs",placeholder:"40.3285",onClick:we=>we.stopPropagation()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Center Longitude"}),e.jsx(be,{value:(z==null?void 0:z.map_center_lng)||"",onChange:we=>F("map_center_lng",we.target.value),className:"h-7 text-xs",placeholder:"-76.0110",onClick:we=>we.stopPropagation()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Default Zoom (1-19)"}),e.jsx(be,{type:"number",min:"1",max:"19",value:(z==null?void 0:z.map_zoom)||"",onChange:we=>F("map_zoom",we.target.value),className:"h-7 text-xs",placeholder:"13",onClick:we=>we.stopPropagation()})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground pt-1",children:"Changes apply on page reload"})]})})]})]})]}),e.jsx(cd,{}),t?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{icon:dp,label:"Profile Settings",onClick:()=>O("/settings")}),e.jsxs(co,{onClick:()=>{n(),Z(!1)},className:"gap-3 cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(J1,{className:"w-4 h-4"}),e.jsx("span",{children:"Sign Out"})]})]}):e.jsx(Ee,{icon:pp,label:"Sign In",onClick:()=>O("/auth")})]})]})},RG=(t="PA")=>fu({queryKey:["municipality-search",t],queryFn:async()=>{const{data:s,error:n}=await Fs.from("municipality_cache").select("id, municipality_name, county_name, region_name, is_visible, center_lat, center_lng, bounds_sw_lat, bounds_sw_lng, bounds_ne_lat, bounds_ne_lng").eq("state",t).order("municipality_name",{ascending:!0});if(n)throw n;return s},staleTime:1e3*60*30}
2594),cg=new Map,FG=5*60*1e3,y0=new Map,zG=2*60*1e3;function OG(t,s){const n=t.toLowerCase().trim();return s?`${n}|${s.lat.toFixed(2)},${s.lng.toFixed(2)}`:n}function BG(t){const s=cg.get(t);return s?Date.now()-s.timestamp>FG?(cg.delete(t),null):s.suggestions:null}function $G(t,s){if(cg.size>100){const n=Array.from(cg.entries());n.sort((a,l)=>a[1].timestamp-l[1].timestamp);for(let a=0;a<20;a++)cg.delete(n[a][0])}cg.set(t,{suggestions:s,timestamp:Date.now()})}function VG(t){const s=y0.get(t);return s?Date.now()-s.timestamp>zG?(y0.delete(t),null):{lat:s.lat,lng:s.lng}:null}async function qG(t,s,n){const a=OG(t,s),l=BG(a);if(l)return l;const{data:c,error:u}=await Fs.functions.invoke("address-autocomplete",{body:{query:t,bias:s}});if(n!=null&&n.aborted)throw new DOMException("Aborted","AbortError");if(u)return console.error("Autocomplete Edge Function error:",u),[];const i=(c==null?void 0:c.suggestions)||[];return $G(a,i),i}async function GG(t){const s=t.slice(0,3).filter(n=>!n.lat&&!n.lng&&!y0.has(n.displayName));s.length!==0&&await Promise.allSettled(s.map(async n=>{var a,l;try{const{data:c}=await Fs.functions.invoke("geocode-address",{body:{address:n.displayName}});c!=null&&c.found&&((a=c.best)!=null&&a.lat)&&((l=c.best)!=null&&l.lng)&&y0.set(n.displayName,{lat:c.best.lat,lng:c.best.lng,timestamp:Date.now()})}catch{}}))}function HG(t){const[s,n]=k.useState([]),[a,l]=k.useState(!1),c=k.useRef(null),u=k.useRef(null),i=k.useRef(null),_=k.useCallback(async x=>{if(c.current&&c.current.abort(),x.length<2){n([]),l(!1);return}l(!0),c.current=new AbortController;try{const v=await qG(x,t,c.current.signal);n(v),i.current&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{GG(v)},300)}catch(v){v.name!=="AbortError"&&(console.error("Autocomplete error:",v),n([]))}finally{l(!1)}},[t]),j=k.useCallback(x=>{if(u.current&&window.clearTimeout(u.current),x.length<2){n([]);return}u.current=window.setTimeout(()=>{_(x)},150)},[_]),y=k.useCallback(()=>{n([]),c.current&&c.current.abort()},[]);return k.useEffect(()=>()=>{u.current&&window.clearTimeout(u.current),i.current&&window.clearTimeout(i.current),c.current&&c.current.abort()},[]),{suggestions:s,isLoading:a,fetchSuggestions:j,clearSuggestions:y}}const Xj="map-search-history",sL=10,ZG=7*24*60*60*1e3;function WG(){try{const t=localStorage.getItem(Xj);if(!t)return[];const s=JSON.parse(t),n=Date.now();return s.filter(a=>n-a.timestamp<ZG)}catch{return[]}}function wC(t){try{localStorage.setItem(Xj,JSON.stringify(t.slice(0,sL)))}catch{}}function YG(){const[t,s]=k.useState([]);k.useEffect(()=>{s(WG())},[]);const n=k.useCallback(c=>{s(u=>{const i=u.filter(j=>Math.abs(j.lat-c.lat)>.001||Math.abs(j.lng-c.lng)>.001),_=[{...c,timestamp:Date.now()},...i].slice(0,sL);return wC(_),_})},[]),a=k.useCallback(()=>{s([]),localStorage.removeItem(Xj)},[]),l=k.useCallback(c=>{s(u=>{const i=u.filter((_,j)=>j!==c);return wC(i),i})},[]);return{history:t,addToHistory:n,clearHistory:a,removeFromHistory:l}}const XG=10,jb=100;function KG({developments:t,existingProducts:s,onSelectDevelopment:n,onSelectExistingProduct:a,onSelectLocation:l,onSelectMu
2594nicipality:c,className:u,mapCenter:i}){const[_,j]=k.useState(""),[y,x]=k.useState(!1),[v,C]=k.useState(!1),[P,I]=k.useState(!1),[z,F]=k.useState(!1),[D,X]=k.useState([]),K=k.useRef(null),te=k.useRef(null),J=k.useRef(null),{suggestions:H,isLoading:O,fetchSuggestions:q,clearSuggestions:W}=HG(i),{history:Q,addToHistory:Z,clearHistory:oe,removeFromHistory:ce}=YG(),{data:ae}=RG("PA"),ie=k.useMemo(()=>ae?ae.map(Fe=>({id:Fe.id,name:Fe.municipality_name||"Unknown",county:Fe.county_name,center_lat:Fe.center_lat,center_lng:Fe.center_lng,bounds_sw_lat:Fe.bounds_sw_lat,bounds_sw_lng:Fe.bounds_sw_lng,bounds_ne_lat:Fe.bounds_ne_lat,bounds_ne_lng:Fe.bounds_ne_lng})):[],[ae]);k.useEffect(()=>{const Fe=fe=>{te.current&&!te.current.contains(fe.target)&&(x(!1),C(!1))};return document.addEventListener("mousedown",Fe),document.addEventListener("touchstart",Fe),()=>{document.removeEventListener("mousedown",Fe),document.removeEventListener("touchstart",Fe)}},[]);const de=k.useCallback(async Fe=>{try{const fe={address:Fe};i!=null&&i.lat&&(i!=null&&i.lng)&&(fe.bias={lat:i.lat,lng:i.lng});const{data:Qe,error:ht}=await Fs.functions.invoke("geocode-address",{body:fe});return!ht&&(Qe!=null&&Qe.found)&&Qe.best?Qe.best:null}catch(fe){return console.error("Geocode error:",fe),null}},[i]),ge=_.trim().slice(0,jb).toLowerCase(),We=ge.length>=2?[...t.filter(Fe=>Fe.name.toLowerCase().includes(ge)).map(Fe=>({id:Fe.id,name:Fe.name,type:"development",propertyType:Fe.type,status:Fe.status,item:Fe})),...s.filter(Fe=>Fe.name.toLowerCase().includes(ge)).map(Fe=>({id:Fe.id,name:Fe.name,type:"existing",propertyType:Fe.type,status:Fe.status,item:Fe}))].slice(0,XG-H.length):[],Ee=ge.length>=2?ie.filter(Fe=>Fe.name.toLowerCase().includes(ge)||Fe.county&&Fe.county.toLowerCase().includes(ge)).slice(0,8).map(Fe=>({id:`muni-${Fe.id}`,name:Fe.name,type:"municipality",municipality:Fe})):[],ve=H.slice(0,5).map((Fe,fe)=>({id:`autocomplete-${fe}`,name:Fe.displayName,type:"autocomplete",autocomplete:Fe})),we=ge.length<2&&Q.length>0?Q.slice(0,5).map((Fe,fe)=>({id:`history-${fe}`,name:Fe.displayName,type:"history",historyItem:Fe})):[],Ze=ge.length<2&&we.length>0,ke=Ze?we:[...We,...Ee,...ve,...D.map((Fe,fe)=>({id:`location-${fe}`,name:Fe.formattedAddress,type:"location",location:Fe}))],ze=k.useCallback(async Fe=>{var fe,Qe;if(Fe.bounds_sw_lat&&Fe.bounds_sw_lng&&Fe.bounds_ne_lat&&Fe.bounds_ne_lng){const ht=[[Fe.bounds_sw_lat,Fe.bounds_sw_lng],[Fe.bounds_ne_lat,Fe.bounds_ne_lng]];if(c){F(!0);try{const{data:_t}=await Fs.from("municipality_cache").select("geojson_data").eq("id",Fe.id).maybeSingle(),He=(fe=_t==null?void 0:_t.geojson_data)==null?void 0:fe.geometry;c(ht,Fe.name,He),Ve.success(`Zooming to ${Fe.name}`)}catch{c(ht,Fe.name,void 0),Ve.success(`Zooming to ${Fe.name}`)}finally{F(!1)}}}else Fe.center_lat&&Fe.center_lng&&l?(l(Fe.center_lat,Fe.center_lng,13,Fe.name),Ve.success(`Navigating to ${Fe.name}`)):Ve.error("No location data available for this municipality");j(""),x(!1),X([]),(Qe=K.current)==null||Qe.blur()},[c,l]),Ke=async Fe=>{var fe;if(Fe.type==="development"&&Fe.item)n(Fe.item);else if(Fe.type==="existing"&&Fe.item)a(Fe.item);else if(Fe.type==="municipality"&&Fe.municipality){ze(Fe.municipality);return}else if(Fe.type==="history"&&Fe.historyItem&&l)l(Fe.historyItem.lat,Fe.historyItem.lng,18,Fe.historyItem.displayName),Ve.success(`Navigating to ${Fe.historyItem.shortName}`);else if(Fe.type==="autocomplete"&&Fe.autocomplete&&l){const Qe=VG(Fe.autocomplete.displayName),ht=(Qe==null?void 0:Qe.lat)??Fe.autocomplete.lat,_t=(Qe==null?void 0:Qe.lng)??Fe.autocomplete.lng;if(ht&&_t&&!isNaN(ht)&&!isNaN(_t))l(ht,_t,18,Fe.autocomplete.displayName),Z({displayName:Fe.autocomplete.displayName,shortName:Fe.autocomplete.shortName,lat:ht,lng:_t}),Ve.success(`Navigating to ${Fe.autocomplete.shortName}`);else{I(!0);const He=await de(Fe.autocomplete.displayName);if(I(!1),He)l(He.lat,He.lng,18,He.formattedAddress),Z({displayName:He.formattedAddress,shortName:He.formattedAddress.split(",")[0],lat:He.lat,lng:He.lng}),Ve.success(`Navigating to ${Fe.autocomplete.shortName}`);else{Ve.error("Could not find exact location");return}}}else Fe.type==="location"&&Fe.location&&l&&(l(Fe.location.lat,Fe.location.lng,18,Fe.location.formattedAddress),Z({displayName:Fe.location.formattedAddress,shortName:Fe.location.formattedAddress.split(",")[0],lat:Fe.location.lat,lng:Fe.location.lng}),Ve.success(`Navigating to ${Fe.location.formattedAddress.split(",")[0]}`));j(""),x(!1),X([]),W(),(fe=K.current)==null||fe.blur()},dt=()=>{var Fe;j(""),X([]),W(),(Fe=K.current)==null||Fe.focus()},Re=Fe=>{const fe=Fe.target.value.slice(0,jb);j(fe),x(fe.trim().length>=2),J.current&&window.clearTimeout(J.current),fe.trim().length>=2?q(fe.trim()):(W(),X([]))};k.useEffect(()=>()=>{J.current&&window.clearTimeout(J.current)},[]);const qt=(Fe,fe,Qe)=>{Qe.stopPropagation(),window.open(`https://www.google.com/maps?q=${Fe},${fe}`,"_blank")},ft=Fe=>{const fe=Fe.formattedAddress.split(",").map(_t=>_t.trim()),Qe=fe[0],ht=fe.slice(1,3).join(", ");return{primary:Qe,secondary:ht}};return e.jsxs("div",{ref:te,className:fs("relative w-full max-w-md",u),children:[e.jsxs("div",{className:fs("flex items-center gap-2 bg-background rounded-full border shadow-lg",v?"border-primary ring-2 ring-primary/20":"border-border"),children:[P?e.jsx(Va,{className:"w-4 h-4 text-primary ml-4 shrink-0 animate-spin"}):e.jsx(Ld,{className:"w-4 h-4 text-muted-foreground ml-4 shrink-0"}
2594),e.jsx("input",{ref:K,type:"text",value:_,onChange:Re,onKeyDown:async Fe=>{var fe;if(Fe.key==="Enter"&&_.trim().length>=2){if(Fe.preventDefault(),ke.length>0)Ke(ke[0]);else if(l){I(!0);const Qe=await de(_.trim());I(!1),Qe?(l(Qe.lat,Qe.lng,18,Qe.formattedAddress),Z({displayName:Qe.formattedAddress,shortName:Qe.formattedAddress.split(",")[0],lat:Qe.lat,lng:Qe.lng}),Ve.success(`Navigating to ${Qe.formattedAddress.split(",")[0]}`),j(""),x(!1),(fe=K.current)==null||fe.blur()):Ve.error("Address not found. Try a more specific address.")}}},onFocus:()=>{C(!0),(_.trim().length>=2||Q.length>0)&&x(!0)},onBlur:()=>C(!1),placeholder:"Search projects, addresses, municipalities...",className:"flex-1 bg-transparent border-none outline-none text-sm py-3 pr-2 placeholder:text-muted-foreground touch-manipulation",maxLength:jb,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false"}),_&&e.jsx("button",{onClick:dt,className:"p-2 mr-2 rounded-full hover:bg-secondary active:bg-secondary/80 transition-colors touch-manipulation","aria-label":"Clear search",children:e.jsx(ja,{className:"w-4 h-4 text-muted-foreground"})})]}),v&&_.length>0&&_.length<3&&e.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 px-4 py-1",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:"Tip: Include city, state, or ZIP for best results"})}),y&&(ke.length>0||Ze)&&e.jsx("div",{className:"absolute top-full left-0 right-0 mt-2 bg-background rounded-lg border border-border shadow-xl overflow-hidden z-50 max-h-[60vh] overflow-y-auto",children:ke.length>0?e.jsxs("div",{className:"py-1",children:[Ze&&we.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/30 flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ox,{className:"w-3 h-3"}),"Recent Searches"]}),e.jsxs("button",{onClick:Fe=>{Fe.stopPropagation(),oe()},className:"text-xs text-muted-foreground hover:text-destructive transition-colors flex items-center gap-1",children:[e.jsx(wr,{className:"w-3 h-3"}),"Clear"]})]}),we.map((Fe,fe)=>{const ht=Fe.historyItem.displayName.split(","),_t=ht[0],He=ht.slice(1,3).join(",").trim();return e.jsxs("button",{onClick:()=>Ke(Fe),className:"w-full flex items-start gap-3 px-4 py-3 hover:bg-secondary/50 active:bg-secondary transition-colors text-left touch-manipulation group",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0 mt-0.5 bg-muted",children:e.jsx(Ox,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:_t}),He&&e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:He})]}),e.jsx("button",{onClick:as=>{as.stopPropagation(),ce(fe)},className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-all","aria-label":"Remove from history",children:e.jsx(ja,{className:"w-3 h-3 text-muted-foreground hover:text-destructive"})})]},Fe.id)})]}),We.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/30",children:"Projects & Sites"}),We.map(Fe=>e.jsxs("button",{onClick:()=>Ke(Fe),className:"w-full flex items-start gap-3 px-4 py-3 hover:bg-secondary/50 active:bg-secondary transition-colors text-left touch-manipulation",children:[e.jsx("div",{className:fs("w-8 h-8 rounded-full flex items-center justify-center shrink-0 mt-0.5",Fe.type==="development"?"bg-amber-500/20":"bg-cyan-500/20"),children:Fe.type==="development"?e.jsx(Ci,{className:"w-4 h-4 text-amber-500"}):e.jsx(Sc,{className:"w-4 h-4 text-cyan-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Fe.name}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[e.jsx("span",{children:Fe.propertyType&&Dx(Fe.propertyType)}),e.jsx("span",{className:"truncate",children:Fe.status&&_f(Fe.status)})]})]}),e.jsx(ji,{className:"w-4 h-4 text-muted-foreground shrink-0 mt-1"})]},`${Fe.type}-${Fe.id}`))]}),Ee.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/30",children:"Municipalities"}),Ee.map(Fe=>{const fe=Fe.municipality;return e.jsxs("button",{onClick:()=>Ke(Fe),className:"w-full flex items-start gap-3 px-4 py-3 hover:bg-secondary/50 active:bg-secondary transition-colors text-left touch-manipulation",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0 mt-0.5 bg-emerald-500/20",children:e.jsx(mp,{className:"w-4 h-4 text-emerald-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:fe.name}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[e.jsx("span",{children:"Municipality"}),fe.county&&e.jsxs("span",{children:["• ",fe.county," County"]})]})]}),e.jsx(ji,{className:"w-4 h-4 text-muted-foreground shrink-0 mt-1"})]},Fe.id)})]}),ve.length>0&&D.length===0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/30",children:"Address Suggestions"}),ve.map(Fe=>{const fe=Fe.autocomplete;return e.jsxs("button",{onClick:()=>Ke(Fe),className:"w-full flex items-start gap-3 px-4 py-3 hover:bg-secondary/50 active:bg-secondary transition-colors text-left touch-manipulation",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0 mt-0.5 bg-blue-500/20",children:e.jsx(ji,{className:"w-4 h-4 text-blue-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:fe.shortName}),e.jsx("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:e.jsx("span",{className:"truncate",children:fe.secondaryText})})]}),e.jsx(Ld,{className:"w-4 h-4 text-muted-foreground shrink-0 mt-1"})]},Fe.id)})]}),D.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/30",children:"Addresses & Places"}),D.map((Fe,fe)=>{const{primary:Qe,secondary:ht}=ft(Fe),_t={id:`location-${fe}`,name:Fe.formattedAddress,type:"location",location:Fe};return e.jsxs("button",{onClick:()=>Ke(_t),className:"w-full flex items-start gap-3 px-4 py-3 hover:bg-secondary/50 active:bg-secondary transition-colors text-left touch-manipulation group",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0 mt-0.5 bg-red-500/20",children:e.jsx(ji,{className:"w-4 h-4 text-red-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Qe}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[e.jsx("span",{className:"truncate",children:ht}),Fe.distance!==void 0&&e.jsxs("span",{className:"text-primary/70",children:["• ",Math.round(Fe.distance)," km away"]})]})]}),e.jsx("div",{role:"button",tabIndex:0,onClick:He=>qt(Fe.lat,Fe.lng,He),onKeyDown:He=>{He.key==="Enter"&&qt(Fe.lat,Fe.lng,He)},className:"p-1.5 rounded-full hover:bg-primary/10 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",title:"Open in Google Maps",children:e.jsx(Rx,{className:"w-3.5 h-3.5 text-muted-foreground"})})]},`location-${fe}`)})]})]}):P?e.jsxs("div",{className:"px-4 py-6 text-center text-muted-foreground text-sm flex items-center justify-center gap-2",children:[e.jsx(Va,{className:"w-4 h-4 animate-spin"}),"Searching locations..."]}):ge.length>=2?e.jsxs("div",{className:"px-4 py-6 text-center text-muted-foreground text-sm",children:[e.jsxs("p",{children:['No results found for "',ge,'"']}),e.jsx("p",{className:"text-xs mt-1",children:"Try including city, state, or ZIP code"})]}):null})]})}const JG=({isAdmin:t=!1,user:s,developments:n=[],existingProducts:a=[],mapCenter:l,onSelectDevelopment:c,onSelectExistingProduct:u,onSelectLocation:i,onSelectMu
2594nicipality:_,mapStyle:j="light",onMapStyleChange:y,onShowDashboardSummary:x,onShowControls:v,onShowLegend:C,boundaryLayers:P,onBoundaryLayerToggle:I,onDemographicsOptionsChange:z,isParcelLookupMode:F,onToggleParcelLookup:D,isAssemblageMode:X,onToggleAssemblageMode:K,assemblageParcelCount:te,onOpenAI:J,onAIRecordCreated:H,onNavigateToRecord:O,onLayerOrderChange:q,onLayerVisibilityChange:W,airportCategories:Q=[],onAirportCategoriesChange:Z,mapRef:oe,parcelDiagnostics:ce,onPinMetric:ae,pinnedMetricIds:ie=[],onSignOut:de,onShowEmbedCode:ge,onShowSuggestionsPanel:We,onShowUserManagement:Ee,onShowMapOverlays:ve,onShowMapStyle:we,onShowNomenclature:Ze,onShowAdminDashboard:ke,onShowUserDashboard:ze,onOpenAdminDashboardTab:Ke,onShowReviewPanel:dt,mapTitle:Re,onMapTitleChange:qt,mapSettings:ft,onMapSettingChange:Fe,onStartMeasuring:fe,onShowDrawingTools:Qe,onShowSiteArchitectDashboard:ht,apiUsage:_t})=>(o_(),e.jsxs("div",{className:"h-12 bg-background border-b border-border flex items-center justify-between px-3 gap-3 shrink-0 relative z-50",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0 flex-1 max-w-md",children:e.jsx(KG,{developments:n,existingProducts:a,mapCenter:l,onSelectDevelopment:c||(()=>{}),onSelectExistingProduct:u||(()=>{}),onSelectLocation:i,onSelectMunicipality:_,className:"w-full"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[_t&&e.jsx("div",{className:"hidden md:block",children:e.jsx(IG,{parcelRequests:_t.parcelRequests,tileRequests:_t.tileRequests,parcelUsagePercent:_t.parcelUsagePercent,tileUsagePercent:_t.tileUsagePercent,isParcelWarning:_t.isParcelWarning,isTileWarning:_t.isTileWarning,isParcelLimitReached:_t.isParcelLimitReached,isTileLimitReached:_t.isTileLimitReached,isLocked:_t.isLocked,limits:_t.limits,onSyncWithApi:_t.syncWithApiQuota})}),t&&oe&&e.jsx(MG,{mapRef:oe,parcelDiagnostics:ce}),de&&we&&C&&ve&&e.jsx(DG,{user:s,isAdmin:t,onSignOut:de,onShowEmbedCode:ge||(()=>{}),onShowSuggestionsPanel:We||(()=>{}),onShowUserManagement:Ee||(()=>{}),onShowMapOverlays:ve,onShowMapStyle:we,onShowNomenclature:Ze||(()=>{}),onShowAdminDashboard:ke||(()=>{}),onShowUserDashboard:ze||(()=>{}),onOpenAdminDashboardTab:Ke||(()=>{}),onShowLegend:C,onShowReviewPanel:dt||(()=>{}),mapTitle:Re,onMapTitleChange:qt,mapSettings:ft,onMapSettingChange:Fe,onLayerOrderChange:q,onLayerVisibilityChange:W,onShowControls:v,onStartMeasuring:fe,onShowDrawingTools:Qe,onShowSiteArchitectDashboard:ht})]})]}));var NC=1,QG=.9,UG=.8,e9=.17,wb=.1,Nb=.999,t9=.9999,s9=.99,n9=/[\\\/_+.#"@\[\(\{&]/,a9=/[\\\/_+.#"@\[\(\{&]/g,r9=/[\s-]/,nL=/[\s-]/g;function x1(t,s,n,a,l,c,u){if(c===s.length)return l===t.length?NC:s9;var i=`${l},${c}`;if(u[i]!==void 0)return u[i];for(var _=a.charAt(c),j=n.indexOf(_,l),y=0,x,v,C,P;j>=0;)x=x1(t,s,n,a,j+1,c+1,u),x>y&&(j===l?x*=NC:n9.test(t.charAt(j-1))?(x*=UG,C=t.slice(l,j-1).match(a9),C&&l>0&&(x*=Math.pow(Nb,C.length))):r9.test(t.charAt(j-1))?(x*=QG,P=t.slice(l,j-1).match(nL),P&&l>0&&(x*=Math.pow(Nb,P.length))):(x*=e9,l>0&&(x*=Math.pow(Nb,j-l))),t.charAt(j)!==s.charAt(c)&&(x*=t9)),(x<wb&&n.charAt(j-1)===a.charAt(c+1)||a.charAt(c+1)===a.charAt(c)&&n.charAt(j-1)!==a.charAt(c))&&(v=x1(t,s,n,a,j+1,c+2,u),v*wb>x&&(x=v*wb)),x>y&&(y=x),j=n.indexOf(_,j+1);return u[i]=y,y}function kC(t){return t.toLowerCase().replace(nL," ")}function i9(t,s,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,x1(t,s,kC(t),kC(s),0,0,{})}var hx='[cmdk-group=""]',kb='[cmdk-group-items=""]',o9='[cmdk-group-heading=""]',aL='[cmdk-item=""]',CC=`${aL}:not([aria-disabled="true"])`,_1="cmdk-item-select",ag="data-value",l9=(t,s,n)=>i9(t,s,n),rL=k.createContext(void 0),x_=()=>k.useContext(rL),iL=k.createContext(void 0),Kj=()=>k.useContext(iL),oL=k.createContext(void 0),lL=k.forwardRef((t,s)=>{let n=rg(()=>{var we,Ze;return{search:"",value:(Ze=(we=t.value)!=null?we:t.defaultValue)!=null?Ze:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),a=rg(()=>new Set),l=rg(()=>new Map),c=rg(()=>new Map),u=rg(()=>new Set),i=cL(t),{label:_,children:j,value:y,onValueChange:x,filter:v,shouldFilter:C,loop:P,disablePointerSelection:I=!1,vimBindings:z=!0,...F}=t,D=dg(),X=dg(),K=dg(),te=k.useRef(null),J=y9();vp(()=>
vendor: 9,935 bytes, line 2594
2594{if(y!==void 0){let we=y.trim();n.current.value=we,H.emit()}},[y]),vp(()=>{J(6,oe)},[]);let H=k.useMemo(()=>({subscribe:we=>(u.current.add(we),()=>u.current.delete(we)),snapshot:()=>n.current,setState:(we,Ze,ke)=>{var ze,Ke,dt,Re;if(!Object.is(n.current[we],Ze)){if(n.current[we]=Ze,we==="search")Z(),W(),J(1,Q);else if(we==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let qt=document.getElementById(K);qt?qt.focus():(ze=document.getElementById(D))==null||ze.focus()}if(J(7,()=>{var qt;n.current.selectedItemId=(qt=ce())==null?void 0:qt.id,H.emit()}),ke||J(5,oe),((Ke=i.current)==null?void 0:Ke.value)!==void 0){let qt=Ze??"";(Re=(dt=i.current).onValueChange)==null||Re.call(dt,qt);return}}H.emit()}},emit:()=>{u.current.forEach(we=>we())}}),[]),O=k.useMemo(()=>({value:(we,Ze,ke)=>{var ze;Ze!==((ze=c.current.get(we))==null?void 0:ze.value)&&(c.current.set(we,{value:Ze,keywords:ke}),n.current.filtered.items.set(we,q(Ze,ke)),J(2,()=>{W(),H.emit()}))},item:(we,Ze)=>(a.current.add(we),Ze&&(l.current.has(Ze)?l.current.get(Ze).add(we):l.current.set(Ze,new Set([we]))),J(3,()=>{Z(),W(),n.current.value||Q(),H.emit()}),()=>{c.current.delete(we),a.current.delete(we),n.current.filtered.items.delete(we);let ke=ce();J(4,()=>{Z(),(ke==null?void 0:ke.getAttribute("id"))===we&&Q(),H.emit()})}),group:we=>(l.current.has(we)||l.current.set(we,new Set),()=>{c.current.delete(we),l.current.delete(we)}),filter:()=>i.current.shouldFilter,label:_||t["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:D,inputId:K,labelId:X,listInnerRef:te}),[]);function q(we,Ze){var ke,ze;let Ke=(ze=(ke=i.current)==null?void 0:ke.filter)!=null?ze:l9;return we?Ke(we,n.current.search,Ze):0}function W(){if(!n.current.search||i.current.shouldFilter===!1)return;let we=n.current.filtered.items,Ze=[];n.current.filtered.groups.forEach(ze=>{let Ke=l.current.get(ze),dt=0;Ke.forEach(Re=>{let qt=we.get(Re);dt=Math.max(qt,dt)}),Ze.push([ze,dt])});let ke=te.current;ae().sort((ze,Ke)=>{var dt,Re;let qt=ze.getAttribute("id"),ft=Ke.getAttribute("id");return((dt=we.get(ft))!=null?dt:0)-((Re=we.get(qt))!=null?Re:0)}).forEach(ze=>{let Ke=ze.closest(kb);Ke?Ke.appendChild(ze.parentElement===Ke?ze:ze.closest(`${kb} > *`)):ke.appendChild(ze.parentElement===ke?ze:ze.closest(`${kb} > *`))}),Ze.sort((ze,Ke)=>Ke[1]-ze[1]).forEach(ze=>{var Ke;let dt=(Ke=te.current)==null?void 0:Ke.querySelector(`${hx}[${ag}="${encodeURIComponent(ze[0])}"]`);dt==null||dt.parentElement.appendChild(dt)})}function Q(){let we=ae().find(ke=>ke.getAttribute("aria-disabled")!=="true"),Ze=we==null?void 0:we.getAttribute(ag);H.setState("value",Ze||void 0)}function Z(){var we,Ze,ke,ze;if(!n.current.search||i.current.shouldFilter===!1){n.current.filtered.count=a.current.size;return}n.current.filtered.groups=new Set;let Ke=0;for(let dt of a.current){let Re=(Ze=(we=c.current.get(dt))==null?void 0:we.value)!=null?Ze:"",qt=(ze=(ke=c.current.get(dt))==null?void 0:ke.keywords)!=null?ze:[],ft=q(Re,qt);n.current.filtered.items.set(dt,ft),ft>0&&Ke++}for(let[dt,Re]of l.current)for(let qt of Re)if(n.current.filtered.items.get(qt)>0){n.current.filtered.groups.add(dt);break}n.current.filtered.count=Ke}function oe(){var we,Ze,ke;let ze=ce();ze&&(((we=ze.parentElement)==null?void 0:we.firstChild)===ze&&((ke=(Ze=ze.closest(hx))==null?void 0:Ze.querySelector(o9))==null||ke.scrollIntoView({block:"nearest"})),ze.scrollIntoView({block:"nearest"}))}function ce(){var we;return(we=te.current)==null?void 0:we.querySelector(`${aL}[aria-selected="true"]`)}function ae(){var we;return Array.from(((we=te.current)==null?void 0:we.querySelectorAll(CC))||[])}function ie(we){let Ze=ae()[we];Ze&&H.setState("value",Ze.getAttribute(ag))}function de(we){var Ze;let ke=ce(),ze=ae(),Ke=ze.findIndex(Re=>Re===ke),dt=ze[Ke+we];(Ze=i.current)!=null&&Ze.loop&&(dt=Ke+we<0?ze[ze.length-1]:Ke+we===ze.length?ze[0]:ze[Ke+we]),dt&&H.setState("value",dt.getAttribute(ag))}function ge(we){let Ze=ce(),ke=Ze==null?void 0:Ze.closest(hx),ze;for(;ke&&!ze;)ke=we>0?x9(ke,hx):_9(ke,hx),ze=ke==null?void 0:ke.querySelector(CC);ze?H.setState("value",ze.getAttribute(ag)):de(we)}let We=()=>ie(ae().length-1),Ee=we=>{we.preventDefault(),we.metaKey?We():we.altKey?ge(1):de(1)},ve=we=>{we.preventDefault(),we.metaKey?ie(0):we.altKey?ge(-1):de(-1)};return k.createElement(Wd.div,{ref:s,tabIndex:-1,...F,"cmdk-root":"",onKeyDown:we=>{var Ze;(Ze=F.onKeyDown)==null||Ze.call(F,we);let ke=we.nativeEvent.isComposing||we.keyCode===229;if(!(we.defaultPrevented||ke))switch(we.key){case"n":case"j":{z&&we.ctrlKey&&Ee(we);break}case"ArrowDown":{Ee(we);break}case"p":case"k":{z&&we.ctrlKey&&ve(we);break}case"ArrowUp":{ve(we);break}case"Home":{we.preventDefault(),ie(0);break}case"End":{we.preventDefault(),We();break}case"Enter":{we.preventDefault();let ze=ce();if(ze){let Ke=new Event(_1);ze.dispatchEvent(Ke)}}}}},k.createElement("label",{"cmdk-label":"",htmlFor:O.inputId,id:O.labelId,style:b9},_),Y0(t,we=>k.createElement(iL.Provider,{value:H},k.createElement(rL.Provider,{value:O},we))))}),c9=k.forwardRef((t,s)=>{var n,a;let l=dg(),c=k.useRef(null),u=k.useContext(oL),i=x_(),_=cL(t),j=(a=(n=_.current)==null?void 0:n.forceMount)!=null?a:u==null?void 0:u.forceMount;vp(()=>{if(!j)return i.item(l,u==null?void 0:u.id)},[j]);let y=dL(l,c,[t.value,t.children,c],t.keywords),x=Kj(),v=Rf(J=>J.value&&J.value===y.current),C=Rf(J=>j||i.filter()===!1?!0:J.search?J.filtered.items.get(l)>0:!0);k.useEffect(()=>{let J=c.current;if(!(!J||t.disabled))return J.addEventListener(_1,P),()=>J.removeEventListener(_1,P)},[C,t.onSelect,t.disabled]);function P(){var J,H;I(),(H=(J=_.current).onSelect)==null||H.call(J,y.current)}function I(){x.setState("value",y.current,!0)}if(!C)return null;let{disabled:z,value:F,onSelect:D,forceMount:X,keywords:K,...te}=t;return k.createElement(Wd.div,{ref:Lx(c,s),...te,id:l,"cmdk-item":"",role:"option","aria-disabled":!!z,"aria-selected":!!v,"data-disabled":!!z,"data-selected":!!v,onPointerMove:z||i.getDisablePointerSelection()?void 0:I,onClick:z?void 0:P},t.children)}),d9=k.forwardRef((t,s)=>{let{heading:n,children:a,forceMount:l,...c}=t,u=dg(),i=k.useRef(null),_=k.useRef(null),j=dg(),y=x_(),x=Rf(C=>l||y.filter()===!1?!0:C.search?C.filtered.groups.has(u):!0);vp(()=>y.group(u),[]),dL(u,i,[t.value,t.heading,_]);let v=k.useMemo(()=>({id:u,forceMount:l}),[l]);return k.createElement(Wd.div,{ref:Lx(i,s),...c,"cmdk-group":"",role:"presentation",hidden:x?void 0:!0},n&&k.createElement("div",{ref:_,"cmdk-group-heading":"","aria-hidden":!0,id:j},n),Y0(t,C=>k.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?j:void 0},k.createElement(oL.Provider,{value:v},C))))}),u9=k.forwardRef((t,s)=>{let{alwaysRender:n,...a}=t,l=k.useRef(null),c=Rf(u=>!u.search);return!n&&!c?null:k.createElement(Wd.div,{ref:Lx(l,s),...a,"cmdk-separator":"",role:"separator"})}),h9=k.forwardRef((t,s)=>{let{onValueChange:n,...a}=t,l=t.value!=null,c=Kj(),u=Rf(j=>j.search),i=Rf(j=>j.selectedItemId),_=x_();return k.useEffect(()=>{t.value!=null&&c.setState("search",t.value)},[t.value]),k.createElement(Wd.input,{ref:s,...a,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":_.listId,"aria-labelledby":_.labelId,"aria-activedescendant":i,id:_.inputId,type:"text",value:l?t.value:u,onChange:j=>{l||c.setState("search",j.target.value),n==null||n(j.target.value)}})}),m9=k.forwardRef((t,s)=>{let{children:n,label:a="Suggestions",...l}=t,c=k.useRef(null),u=k.useRef(null),i=Rf(j=>j.selectedItemId),_=x_();return k.useEffect(()=>{if(u.current&&c.current){let j=u.current,y=c.current,x,v=new ResizeObserver(()=>{x=requestAnimationFrame(()=>{let C=j.offsetHeight;y.style.setProperty("--cmdk-list-height",C.toFixed(1)+"px")})});return v.observe(j),()=>{cancelAnimationFrame(x),v.unobserve(j)}}},[]),k.createElement(Wd.div,{ref:Lx(c,s),...l,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":a,id:_.listId},Y0(t,j=>k.createElement("div",{ref:Lx(u,_.listInnerRef),"cmdk-list-sizer":""},j)))}),f9=k.forwardRef((t,s)=>{let{open:n,onOpenChange:a,overlayClassName:l,contentClassName:c,container:u,...i}=t;return k.createElement(YC,{open:n,onOpenChange:a},k.createElement(XC,{container:u},k.createElement(C1,{"cmdk-overlay":"",className:l}),k.createElement(S1,{"aria-label":t.label,"cmdk-dialog":"",className:c},k.createElement(lL,{ref:s,...i}))))}),p9=k.forwardRef((t,s)=>Rf(n=>n.filtered.count===0)?k.createElement(Wd.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),g9=k.forwardRef((t,s)=>{let{progress:n,children:a,label:l="Loading...",...c}=t;return k.createElement(Wd.div,{ref:s,...c,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":l},Y0(t,u=>k.createElement("div",{"aria-hidden":!0},u)))}),xu=Object.assign(lL,{List:m9,Item:c9,Input:h9,Group:d9,Separator:u9,Dialog:f9,Empty:p9,Loading:g9});function x9(t,s){let n=t.nextElementSibling;for(;n;){if(n.matches(s))return n;n=n.nextElementSibling}}function _9(t,s){let n=t.previousElementSibling;for(;n;){if(n.matches(s))return n;n=n.previousElementSibling}}function cL(t){let s=k.useRef(t);return vp(()=>{s.current=t}),s}var vp=typeof window>"u"?k.useEffect:k.useLayoutEffect;function rg(t){let s=k.useRef();return s.current===void 0&&(s.current=t()),s}function Rf(t){let s=Kj(),n=()=>t(s.snapshot());return k.useSyncExternalStore(s.subscribe,n,n)}function dL(t,s,n,a=[]){let l=k.useRef(),c=x_();return vp(()=>{var u;let i=(()=>{var j;for(let y of n){if(typeof y=="string")return y.trim();if(typeof y=="object"&&"current"in y)return y.current?(j=y.current.textContent)==null?void 0:j.trim():l.current}})(),_=a.map(j=>j.trim());c.value(t,i,_),(u=s.current)==null||u.setAttribute(ag,i),l.current=i}),l}var y9=()=>{let[t,s]=k.useState(),n=rg(()=>new Map);return vp(()=>{n.current.forEach(a=>
2594a()),n.current=new Map},[t]),(a,l)=>{n.current.set(a,l),s({})}};function v9(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function Y0({asChild:t,children:s},n){return t&&k.isValidElement(s)?k.cloneElement(v9(s),{ref:s.ref},n(s.props.children)):n(s)}var b9={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const uL=k.forwardRef(({className:t,...s},n)=>e.jsx(xu,{ref:n,className:fs("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));uL.displayName=xu.displayName;const j9=({children:t,...s})=>e.jsx(dd,{...s,children:e.jsx(ud,{className:"overflow-hidden p-0 shadow-lg",children:e.jsx(uL,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:t})})}),hL=k.forwardRef(({className:t,...s},n)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(Ld,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(xu.Input,{ref:n,className:fs("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));hL.displayName=xu.Input.displayName;const mL=k.forwardRef(({className:t,...s},n)=>e.jsx(xu.List,{ref:n,className:fs("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));mL.displayName=xu.List.displayName;const fL=k.forwardRef((t,s)=>e.jsx(xu.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));fL.displayName=xu.Empty.displayName;const jx=k.forwardRef(({className:t,...s},n)=>e.jsx(xu.Group,{ref:n,className:fs("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));jx.displayName=xu.Group.displayName;const My=k.forwardRef(({className:t,...s},n)=>e.jsx(xu.Separator,{ref:n,className:fs("-mx-1 h-px bg-border",t),...s}));My.displayName=xu.Separator.displayName;const Pd=k.forwardRef(({className:t,...s},n)=>e.jsx(xu.Item,{ref:n,className:fs("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",t),...s}));Pd.displayName=xu.Item.displayName;function w9({open:t,onOpenChange:s,isAdmin:n,user:a,onShowDashboardSummary:l,onShowMapStyle:c,onShowMapOverlays:u,onShowLegend:i,onShowRegionFilter:_,onShowControls:j,onShowUserDashboard:y,onShowUserManagement:x,onShowSuggestionsPanel:v,onShowAdminPanel:C,onShowReviewPanel:P,onShowEmbedCode:I,onSignOut:z}){const F=b0(),D=k.useCallback(X=>{s(!1),X()},[s]);return e.jsxs(j9,{open:t,onOpenChange:s,children:[e.jsx(hL,{placeholder:"Type a command or search..."}),e.jsxs(mL,{children:[e.jsx(fL,{children:"No results found."}),e.jsxs(jx,{heading:"Views & Analysis",children:[e.jsxs(Pd,{onSelect:()=>D(y),children:[e.jsx(Bm,{className:"mr-2 h-4 w-4"}),"Dashboard"]}),e.jsxs(Pd,{onSelect:()=>D(l),children:[e.jsx(Bm,{className:"mr-2 h-4 w-4"}),"Dashboard"]}),e.jsxs(Pd,{onSelect:()=>D(_),children:[e.jsx(wg,{className:"mr-2 h-4 w-4"}),"Filter"]})]}),e.jsx(My,{}),e.jsxs(jx,{heading:"Controls",children:[e.jsxs(Pd,{onSelect:()=>D(c),children:[e.jsx(ph,{className:"mr-2 h-4 w-4"}),"Map Style"]}),e.jsxs(Pd,{onSelect:()=>D(i),children:[e.jsx(ji,{className:"mr-2 h-4 w-4"}),"Legend"]}),e.jsxs(Pd,{onSelect:()=>D(u),children:[e.jsx(Da,{className:"mr-2 h-4 w-4"}),"Map Overlays"]}),e.jsxs(Pd,{onSelect:()=>D(j),children:[e.jsx(tj,{className:"mr-2 h-4 w-4"}),"Map Controls"]})]}),n&&e.jsxs(e.Fragment,{children:[e.jsx(My,{}),e.jsxs(jx,{heading:"Administration",children:[e.jsxs(Pd,{onSelect:()=>D(C),children:[e.jsx(Fu,{className:"mr-2 h-4 w-4"}),"Admin Dashboard"]}),e.jsxs(Pd,{onSelect:()=>
2594D(P),children:[e.jsx(fS,{className:"mr-2 h-4 w-4"}),"Review"]}),e.jsxs(Pd,{onSelect:()=>D(v),children:[e.jsx(K1,{className:"mr-2 h-4 w-4"}),"Suggestions"]}),e.jsxs(Pd,{onSelect:()=>D(x),children:[e.jsx(yl,{className:"mr-2 h-4 w-4"}),"User Management"]}),e.jsxs(Pd,{onSelect:()=>D(I),children:[e.jsx(L1,{className:"mr-2 h-4 w-4"}),"Embed Code"]})]})]}),e.jsx(My,{}),e.jsxs(jx,{heading:"Navigation",children:[e.jsxs(Pd,{onSelect:()=>D(()=>F("/settings")),children:[e.jsx(dp,{className:"mr-2 h-4 w-4"}),"Settings"]}),a?e.jsxs(Pd,{onSelect:()=>D(z),children:[e.jsx(J1,{className:"mr-2 h-4 w-4"}),"Sign Out"]}):e.jsxs(Pd,{onSelect:()=>D(()=>F("/auth")),children:[e.jsx(pp,{className:"mr-2 h-4 w-4"}),"Sign In"]})]})]})]})}function N9(){const[t,s]=k.useState(!1);return k.useEffect(()=>{const n=a=>{a.key==="k"&&(a.metaKey||a.ctrlKey)&&(a.preventDefault(),s(l=>!l))};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[]),{open:t,setOpen:s}}const SC=[{key:"states",label:"States",icon:e.jsx(ph,{className:"w-4 h-4"})},{key:"counties",label:"Counties",icon:e.jsx(Ci,{className:"w-4 h-4"})},{key:"municipalities",label:"Municipalities",icon:e.jsx(Sf,{className:"w-4 h-4"})},{key:"zipCodes",label:"ZIP Codes",icon:e.jsx(ji,{className:"w-4 h-4"})},{key:"censusTracks",label:"Census Tracts",icon:e.jsx(dm,{className:"w-4 h-4"})},{key:"congressionalDistricts",label:"Congressional Districts",icon:e.jsx(yl,{className:"w-4 h-4"})},{key:"schoolDistricts",label:"School Districts",icon:e.jsx($b,{className:"w-4 h-4"})},{key:"majorRoads",label:"Major Roads",icon:e.jsx(uo,{className:"w-4 h-4"})}],EC=[{key:"substations",label:"Substations",icon:e.jsx(Xd,{className:"w-4 h-4"}),category:"Electric"},{key:"transmissionLines",label:"Transmission Lines",icon:e.jsx(lm,{className:"w-4 h-4"}),category:"Electric"},{key:"powerPlants",label:"Power Plants",icon:e.jsx(Ff,{className:"w-4 h-4"}),category:"Electric"}],PC=[{key:"floodZones",label:"FEMA Flood Zones",icon:e.jsx(gp,{className:"w-4 h-4"}),description:"FEMA National Flood Hazard Layer"},{key:"wetlands",label:"Wetlands (NWI)",icon:e.jsx(Kc,{className:"w-4 h-4"}),description:"USFWS National Wetlands Inventory"},{key:"brownfields",label:"Brownfields",icon:e.jsx(Ig,{className:"w-4 h-4"}),description:"EPA contaminated sites"},{key:"superfund",label:"Superfund Sites",icon:e.jsx(ho,{className:"w-4 h-4"}),description:"EPA NPL Superfund sites"},{key:"toxicRelease",label:"Toxic Release",icon:e.jsx(ho,{className:"w-4 h-4"}),description:"EPA TRI facilities"}],TC=[{key:"geology",label:"Geology",icon:e.jsx(Rh,{className:"w-4 h-4"}),description:"State geologic map (USGS SGMC)"},{key:"bedrock",label:"Bedrock",icon:e.jsx(Rh,{className:"w-4 h-4"}),description:"Geologic contacts & structures"},{key:"soils",label:"Soils",icon:e.jsx(Mh,{className:"w-4 h-4"}),description:"USDA Web Soil Survey data"},{key:"groundwater",label:"Watersheds",icon:e.jsx(Kc,{className:"w-4 h-4"}),description:"USGS watershed boundaries (HUC)"},{key:"usgsImagery",label:"USGS Imagery",icon:e.jsx(k0,{className:"w-4 h-4"}),description:"High-resolution NAIP aerial imagery"}],LC=[{key:"demographics",label:"Demographics",icon:e.jsx(_g,{className:"w-4 h-4"}),description:"Census demographics (income, population)"},{key:"schools",label:"Schools",icon:e.jsx(j0,{className:"w-4 h-4"}),description:"Public school locations"},{key:"crimeStats",label:"Crime Statistics",icon:e.jsx(Ag,{className:"w-4 h-4"}),description:"FBI crime data by state"},{key:"walkability",label:"Walkability",icon:e.jsx(zu,{className:"w-4 h-4"}),description:"EPA walkability index"}],MC=[{key:"opportunityZones",label:"Opportunity Zones",icon:e.jsx(m5,{className:"w-4 h-4"}),description:"Qualified Opportunity Zone census tracts"}],Cb=[{key:"airports",label:"Airports",icon:e.jsx(Lb,{className:"w-4 h-4"}),description:"FAA airports and heliports"},{key:"ports",label:"Ports",icon:e.jsx(B5,{className:"w-4 h-4"}),description:"Sea and river ports"},{key:"railLines",label:"Rail Lines",icon:e.jsx($5,{className:"w-4 h-4"}),description:"Rail infrastructure"}],IC=[{key:"zoneomicsTiles",label:"Zoning Overlay",icon:e.jsx(mp,{className:"w-4 h-4"}),description:"Zoneomics zoning map tiles"},{key:"zoningBoundary",label:"Zone Boundary",icon:e.jsx(Mh,{className:"w-4 h-4"}),description:"Show zone area outline on parcel click"}],k9=({boundaryLayers:t,onBoundaryLayerToggle:s,onDemographicsOptionsChange:n,isParcelLookupMode:a,onToggleParcelLo
2594okup:l,isAssemblageMode:c,onToggleAssemblageMode:u,assemblageParcelCount:i=0,onOpenAI:_,layerLoadingState:j={},className:y,airportCategories:x=[],onAirportCategoriesChange:v})=>{const[C,P]=k.useState(!1),[I,z]=k.useState(!1),[F,D]=k.useState(!1),{hasLayerAccess:X,isPremiumLayer:K}=O5(),te=ke=>{if(!v)return;const ze=x.includes(ke)?x.filter(Ke=>Ke!==ke):[...x,ke];v(ze)},J=ke=>{if(K(ke)&&!X(ke)){Ve.error("Premium layer - contact admin to enable access");return}s(ke)},H=SC.filter(ke=>t[ke.key]).length,O=IC.filter(ke=>t[ke.key]).length,q=EC.filter(ke=>t[ke.key]).length,W=PC.filter(ke=>t[ke.key]).length,Q=TC.filter(ke=>t[ke.key]).length,Z=LC.filter(ke=>t[ke.key]).length,oe=MC.filter(ke=>t[ke.key]).length,ce=Cb.filter(ke=>t[ke.key]).length,ae=H+O+q+W+Q+Z+oe+ce+(a?1:0)+(c?1:0),ie=Object.values(j).some(Boolean),de=t.demographicsMetric||"income",ge=t.demographicsDisplayMode||"popup",We=ke=>{n==null||n({metric:ke})},Ee=ke=>{n==null||n({displayMode:ke})},ve=[{value:"population",label:"Population",icon:e.jsx(yl,{className:"w-3.5 h-3.5"})},{value:"income",label:"Median Income",icon:e.jsx(Vd,{className:"w-3.5 h-3.5"})},{value:"home_value",label:"Home Value",icon:e.jsx(qd,{className:"w-3.5 h-3.5"})},{value:"education",label:"Education %",icon:e.jsx(tg,{className:"w-3.5 h-3.5"})}],we=[{value:"popup",label:"Popup Only"},{value:"county",label:"County Heatmap"},{value:"tract",label:"Tract Heatmap"}],Ze=ke=>{const ze=j[ke.key],Ke=K(ke.key)&&!X(ke.key),dt=e.jsxs(Le,{variant:t[ke.key]?"default":"ghost",size:"sm",onClick:()=>J(ke.key),disabled:ze,className:fs("h-8 px-3 gap-2 justify-start text-xs w-full",t[ke.key]&&"bg-primary text-primary-foreground",Ke&&"text-destructive hover:text-destructive"),title:Ke?void 0:ke.description,children:[ze?e.jsx(Va,{className:"w-4 h-4 animate-spin"}):ke.icon,e.jsx("span",{className:fs("flex-1 text-left",Ke&&"text-destructive"),children:ke.label}),Ke&&e.jsx(jc,{className:"w-3 h-3 text-destructive"}),ze&&e.jsx("span",{className:"text-[10px] opacity-70",children:"Loading..."})]},ke.key);return Ke?e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:dt}),e.jsx(or,{side:"right",children:e.jsx("p",{className:"text-xs",children:"Premium Layer"})})]},ke.key):dt};return e.jsx(hm,{children:e.jsxs(Ef,{open:C,onOpenChange:P,children:[e.jsx(Pf,{asChild:!0,children:e.jsxs(Le,{variant:"outline",size:"sm",className:fs("bg-card text-card-foreground shadow-md border border-border gap-1.5 h-8 px-2 relative",y),children:[ie?e.jsx(Va,{className:"w-4 h-4 animate-spin"}):e.jsx(Da,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs font-medium hidden sm:inline",children:"Layers"}),ae>0&&e.jsx("span",{className:"absolute -top-1.5 -right-1.5 bg-primary text-primary-foreground text-[10px] font-bold rounded-full w-4 h-4 flex items-center justify-center",children:ae})]})}),e.jsx(Tf,{side:"bottom",align:"start",className:"w-auto p-1.5 max-h-[70vh] overflow-y-auto bg-popover text-popover-foreground border border-border z-[100]",sideOffset:8,children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-muted-foreground font-medium",children:"Boundaries"}),SC.map(ke=>{const ze=j[ke.key];return e.jsxs(Le,{variant:t[ke.key]?"default":"ghost",size:"sm",onClick:()=>s(ke.key),disabled:ze,className:fs("h-8 px-3 gap-2 justify-start text-xs w-full",t[ke.key]&&"bg-primary text-primary-foreground"),children:[ze?e.jsx(Va,{className:"w-4 h-4 animate-spin"}):ke.icon,e.jsx("span",{children:ke.label}),ze&&e.jsx("span",{className:"ml-auto text-[10px] opacity-70",children:"Loading..."})]},ke.key)}),e.jsx(ks,{className:"my-1"}),e.jsxs("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-muted-foreground font-medium flex items-center gap-1",children:["Energy Infrastructure",e.jsx(jc,{className:"w-3 h-3"})]}),EC.map(ke=>Ze(ke)),e.jsx(ks,{className:"my-1"}),e.jsx("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-muted-foreground font-medium",children:"Topography"}),Ze({key:"topographic",label:"Topo Map",icon:e.jsx(Rh,{className:"w-4 h-4"}),description:"USGS topographic map with contours & terrain"}),e.jsx(ks,{className:"my-1"}),e.jsxs("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-muted-foreground font-medium flex items-center gap-1",children:["Environmental & Diligence",e.jsx(jc,{className:"w-3 h-3"})]}),PC.map(ke=>Ze(ke)),e.jsx(ks,{className:"my-1"}),e.jsxs("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-muted-foreground font-medium flex items-center gap-1",children:["Geology & Soils",e.jsx(jc,{className:"w-3 h-3"})]}),TC.map(ke=>Ze(ke)),e.jsx(ks,{className:"my-1"}),e.jsxs("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-muted-foreground font-medium flex items-center gap-1",children:["Area Intelligence",e.jsx(jc,{className:"w-3 h-3"})]}),LC.map(ke=>{const ze=j[ke.key],Ke=K(ke.key)&&!X(ke.key),dt=e.jsxs(Le,{variant:t[ke.key]?"default":"ghost",size:"sm",disabled:ze,onClick:()=>
2594{if(Ke){Ve.error("Premium layer - contact admin to enable access");return}s(ke.key),ke.key==="demographics"&&!t.demographics&&z(!0)},className:fs("h-8 px-3 gap-2 justify-start text-xs w-full",t[ke.key]&&"bg-primary text-primary-foreground",Ke&&"text-destructive hover:text-destructive"),title:Ke?void 0:ke.description,children:[ze?e.jsx(Va,{className:"w-4 h-4 animate-spin"}):ke.icon,e.jsx("span",{className:fs("flex-1 text-left",Ke&&"text-destructive"),children:ke.label}),Ke&&e.jsx(jc,{className:"w-3 h-3 text-destructive"}),ze&&e.jsx("span",{className:"text-[10px] opacity-70",children:"Loading..."}),ke.key==="demographics"&&t.demographics&&!ze&&!Ke&&e.jsx(Ao,{className:fs("w-3.5 h-3.5 transition-transform",I&&"rotate-90"),onClick:Re=>{Re.stopPropagation(),z(!I)}})]});return e.jsxs("div",{children:[Ke?e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:dt}),e.jsx(or,{side:"right",children:e.jsx("p",{className:"text-xs",children:"Premium Layer"})})]}):dt,ke.key==="demographics"&&t.demographics&&I&&!Ke&&e.jsxs("div",{className:"ml-4 mt-1 p-2 space-y-3 bg-muted/50 rounded-md border border-border/50",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide",children:"Display Mode"}),e.jsx(i0,{value:ge,onValueChange:Re=>Ee(Re),className:"space-y-1",children:we.map(Re=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(o0,{value:Re.value,id:`display-${Re.value}`,className:"h-3 w-3"}),e.jsx(B,{htmlFor:`display-${Re.value}`,className:"text-[11px] cursor-pointer",children:Re.label})]},Re.value))})]}),ge!=="popup"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide",children:"Heatmap Metric"}),e.jsx(i0,{value:de,onValueChange:Re=>We(Re),className:"space-y-1",children:ve.map(Re=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(o0,{value:Re.value,id:`metric-${Re.value}`,className:"h-3 w-3"}),e.jsxs(B,{htmlFor:`metric-${Re.value}`,className:"text-[11px] cursor-pointer flex items-center gap-1",children:[Re.icon,Re.label]})]},Re.value))})]})]})]},ke.key)}),e.jsx(ks,{className:"my-1"}),e.jsxs("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-muted-foreground font-medium flex items-center gap-1",children:["Tax Incentives",e.jsx(jc,{className:"w-3 h-3"})]}),MC.map(ke=>Ze(ke)),e.jsx(ks,{className:"my-1"}),e.jsxs("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-muted-foreground font-medium flex items-center gap-1",children:["Transportation",e.jsx(jc,{className:"w-3 h-3"})]}),(()=>{const ke=Cb.find(ft=>ft.key==="airports");if(!ke)return null;const ze=j[ke.key],Ke=K(ke.key)&&!X(ke.key),dt=t[ke.key],Re=x.length,qt=e.jsxs(Le,{variant:dt?"default":"ghost",size:"sm",disabled:ze,onClick:()=>{if(Ke){Ve.error("Premium layer - contact admin to enable access");return}J(ke.key),dt||D(!0)},className:fs("h-8 px-3 gap-2 justify-start text-xs w-full",dt&&"bg-primary text-primary-foreground",Ke&&"text-destructive hover:text-destructive"),title:Ke?void 0:ke.description,children:[ze?e.jsx(Va,{className:"w-4 h-4 animate-spin"}):ke.icon,e.jsx("span",{className:fs("flex-1 text-left",Ke&&"text-destructive"),children:ke.label}),Re>0&&Re<Object.keys(_0).length&&!Ke&&e.jsx("span",{className:"text-[10px] bg-background/20 px-1.5 py-0.5 rounded",children:Re}),Ke&&e.jsx(jc,{className:"w-3 h-3 text-destructive"}),ze&&e.jsx("span",{className:"text-[10px] opacity-70",children:"Loading..."}),dt&&!ze&&!Ke&&e.jsx(Ao,{className:fs("w-3.5 h-3.5 transition-transform",F&&"rotate-90"),onClick:ft=>{ft.stopPropagation(),D(!F)}})]});return e.jsxs("div",{children:[Ke?e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:qt}),e.jsx(or,{side:"right",children:e.jsx("p",{className:"text-xs",children:"Premium Layer"})})]}):qt,dt&&F&&!Ke&&v&&e.jsxs("div",{className:"ml-4 mt-1 p-2 space-y-1.5 bg-muted/50 rounded-md border border-border/50",children:[e.jsx("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide mb-2",children:"Airport Types"}
2594),Object.entries(_0).map(([ft,Fe])=>{const fe=x.length===0||x.includes(ft);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ux,{id:`airport-${ft}`,checked:fe,onCheckedChange:()=>te(ft),className:"h-3.5 w-3.5"}),e.jsxs(B,{htmlFor:`airport-${ft}`,className:"text-[11px] cursor-pointer flex items-center gap-1.5 flex-1",children:[e.jsx("span",{children:Fe.icon}),e.jsx("span",{children:Fe.name})]})]},ft)}),e.jsx("p",{className:"text-[9px] text-muted-foreground mt-2 pt-1 border-t border-border/30",children:x.length===0?"Showing all types":`Showing ${x.length} type(s)`})]})]})})(),Cb.filter(ke=>ke.key!=="airports").map(ke=>Ze(ke)),e.jsx(ks,{className:"my-1"}),e.jsx("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-muted-foreground font-medium",children:"Parcels & Zoning"}),l&&e.jsxs(Le,{variant:a?"default":"ghost",size:"sm",onClick:()=>{l(),P(!1)},className:fs("h-8 px-3 gap-2 justify-start text-xs w-full",a&&"bg-primary text-primary-foreground"),children:[e.jsx(Mh,{className:"w-4 h-4"}),e.jsx("span",{children:"Parcels"})]}),IC.map(ke=>{const ze=j[ke.key];return e.jsxs(Le,{variant:t[ke.key]?"default":"ghost",size:"sm",onClick:()=>s(ke.key),disabled:ze,className:fs("h-8 px-3 gap-2 justify-start text-xs w-full",t[ke.key]&&"bg-primary text-primary-foreground"),title:ke.description,children:[ze?e.jsx(Va,{className:"w-4 h-4 animate-spin"}):ke.icon,e.jsx("span",{children:ke.label}),ze&&e.jsx("span",{className:"ml-auto text-[10px] opacity-70",children:"Loading..."})]},ke.key)}),u&&e.jsxs(Le,{variant:c?"default":"ghost",size:"sm",onClick:()=>{u(),P(!1)},className:fs("h-8 px-3 gap-2 justify-start text-xs w-full",c&&"bg-primary text-primary-foreground"),children:[e.jsx(V3,{className:"w-4 h-4"}),e.jsx("span",{children:"Assemblage Mode"}),i>0&&e.jsx("span",{className:"ml-auto bg-background/20 text-[10px] px-1.5 py-0.5 rounded-full",children:i})]}),_&&e.jsxs(Le,{variant:"ghost",size:"sm",onClick:()=>{_(),P(!1)},className:"h-8 px-3 gap-2 justify-start text-xs w-full text-primary hover:text-primary hover:bg-primary/10",children:[e.jsx(Nf,{className:"w-4 h-4"}),e.jsx("span",{children:"AI Assistant"})]})]})})]})})},C9=["user-dashboard","filter"];function S9({isAdmin:t,onShowDashboardSummary:s,onShowMapStyle:n,onShowMapOverlays:a,onShowLegend:l,onShowRegionFilter:c,onShowControls:u,onShowUserDashboard:i,onShowUserManagement:_,onShowSuggestionsPanel:j,onShowAdminPanel:y,onShowExistingProductPanel:x,onShowLogoLibrary:v,onShowReviewPanel:C,onOpenCommandPalette:P,onShowActivityFeed:I,onShowSiteArchitectDashboard:z,onShowMetrics:F,boundaryLayers:D,onBoundaryLayerToggle:X,onDemographicsOptionsChange:K,isParcelLookupMode:te,onToggleParcelLookup:J,isAssemblageMode:H,onToggleAssemblageMode:O,assemblageParcelCount:q,onOpenAI:W,airportCategories:Q=[],onAirportCategoriesChange:Z}){var ve;const{preferences:oe,savePreferences:ce}=Kx(),[ae,ie]=k.useState(C9),de=[{id:"user-dashboard",icon:Bm,label:"Dashboard",action:i},{id:"summary",icon:Bm,label:"Summary",action:s},{id:"filter",icon:wg,label:"Filter",action:c},{id:"activity-feed",icon:Pb,label:"Activity",action:I||(()=>{})},{id:"map-style",icon:ph,label:"Map Style",action:n},{id:"legend",icon:ji,label:"Legend",action:l},{id:"overlays",icon:Da,label:"Overlays",action:a},{id:"controls",icon:tj,label:"Controls",action:u},{id:"developments",icon:Ci,label:"Developments",action:y,adminOnly:!0},{id:"existing-sites",icon:Sc,label:"Sites",action:x,adminOnly:!0},{id:"users",icon:yl,label:"Users",action:_,adminOnly:!0},{id:"suggestions",icon:K1,label:"Suggestions",action:j,adminOnly:!0},{id:"review",icon:fS,label:"Review",action:C,adminOnly:!0},{id:"logos",icon:Zd,label:"Logos",action:v,adminOnly:!0},{id:"site-architect",icon:Du,label:"Site Architect",action:z||(()=>{}),adminOnly:!0}];k.useEffect(()=>{var Ze;const we=(Ze=oe.preferences)==null?void 0:Ze.quickActions;we&&we.length>0&&ie(we)},[(ve=oe.preferences)==null?void 0:ve.quickActions]);const ge=we=>{let Ze;ae.includes(we)?Ze=ae.filter(ke=>ke!==we):ae.length>=6?Ze=[...ae.slice(1),we]:Ze=[...ae,we],ie(Ze),ce({preferences:{...oe.preferences,quickActions:Ze}})},We=de.filter(we=>ae.includes(we.id)&&(!we.adminOnly||t)),Ee=de.filter(we=>!we.adminOnly||t);return e.jsxs("div",{className:"hidden md:flex items-center gap-1 px-2 py-1 bg-background/80 backdrop-blur-sm border-b border-border",children:[e.jsxs(jp,{children:[e.jsx(wp,{asChild:!0,children:e.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx(dp,{className:"w-3.5 h-3.5"})})}),e.jsxs(Np,{align:"start",className:"w-48",children:[e.jsx(zm,{className:"text-xs",children:"Qu
2594ick Actions (max 6)"}),e.jsx(cd,{}),Ee.map(we=>e.jsxs(f5,{checked:ae.includes(we.id),onCheckedChange:()=>ge(we.id),className:"text-xs",children:[e.jsx(we.icon,{className:"w-3.5 h-3.5 mr-2"}),we.label]},we.id))]})]}),We.map(we=>e.jsxs(Le,{variant:"ghost",size:"sm",onClick:we.action,className:"h-7 gap-1.5 text-xs",title:we.label,children:[e.jsx(we.icon,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden lg:inline",children:we.label})]},we.id)),e.jsxs(Le,{variant:"ghost",size:"sm",onClick:P,className:"h-7 gap-1.5 text-xs ml-auto",title:"Command Palette (⌘K)",children:[e.jsx(h3,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden lg:inline text-muted-foreground",children:"⌘K"})]}),e.jsx("div",{className:"mx-1 h-4 w-px bg-border"}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",size:"sm",onClick:i,className:"h-7 gap-1.5 text-xs",children:[e.jsx(Bm,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden lg:inline",children:"Dashboard"})]})}),e.jsx(or,{children:"Dashboard"})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-7 gap-1.5 text-xs",children:[e.jsx(Da,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden lg:inline",children:"Map Overlays"})]})}),e.jsx(or,{children:"Map Overlays"})]}),e.jsx(k9,{boundaryLayers:D,onBoundaryLayerToggle:X,onDemographicsOptionsChange:K,isParcelLookupMode:te,onToggleParcelLookup:J,isAssemblageMode:H,onToggleAssemblageMode:O,assemblageParcelCount:q,onOpenAI:W,airportCategories:Q,onAirportCategoriesChange:Z}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",size:"sm",onClick:n,className:"h-7 gap-1.5 text-xs",children:[e.jsx(ph,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden lg:inline",children:"Map Views"})]})}),e.jsx(or,{children:"Map Views"})]}),e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsxs(Le,{variant:"ghost",size:"sm",onClick:F,className:"h-7 gap-1.5 text-xs",children:[e.jsx(_g,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden lg:inline",children:"Metrics"})]})}),e.jsx(or,{children:"Metrics"})]})]})}const E9=({metric:t,onClose:s,onPositionChange:n})=>{const[a,l]=k.useState(!1),[c,u]=k.useState(!1),i=k.useRef(null),_=k.useRef({x:0,y:0}),j=x=>{if(!i.current)return;x.preventDefault(),x.stopPropagation();const v=i.current.getBoundingClientRect();_.current={x:x.clientX-v.left,y:x.clientY-v.top},l(!0)};k.useEffect(()=>{if(!a)return;const x=C=>{var D,X;C.preventDefault(),C.stopPropagation();let P=C.clientX-_.current.x,I=C.clientY-_.current.y;const z=((D=i.current)==null?void 0:D.offsetWidth)||160,F=((X=i.current)==null?void 0:X.offsetHeight)||80;P=Math.max(0,Math.min(P,window.innerWidth-z)),I=Math.max(0,Math.min(I,window.innerHeight-F)),n(t.id,{x:P,y:I})},v=C=>{C.preventDefault(),C.stopPropagation(),l(!1)};return document.addEventListener("mousemove",x,{capture:!0}),document.addEventListener("mouseup",v,{capture:!0}),()=>{document.removeEventListener("mousemove",x,{capture:!0}),document.removeEventListener("mouseup",v,{capture:!0})}},[a,t.id,n]);const y=t.color||"text-foreground";return e.jsxs("div",{ref:i,className:fs("fixed z-[1000] bg-background border border-border rounded-lg shadow-lg",a&&"cursor-grabbing shadow-xl",c?"p-2":"p-3"),style:{left:t.position.x,top:t.position.y,pointerEvents:"auto",transform:"translate(0, 0)"},children:[e.jsxs("div",{className:"flex items-center gap-1 cursor-grab active:cursor-grabbing select-none",onMouseDown:j,children:[e.jsx(Fh,{className:"w-3 h-3 text-muted-foreground"}),!c&&e.jsx("span",{className:"text-xs text-muted-foreground flex-1 truncate max-w-[100px]",children:t.label}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5 hover:bg-muted",onClick:()=>u(!c),children:e.jsx(k3,{className:"w-3 h-3"})}),e.jsx(Le,{variant:"ghost",size:"icon",className:"h-5 w-5 hover:bg-destructive/20 hover:text-destructive",onClick:()=>s(t.id),children:e.jsx(ja,{className:"w-3 h-3"})})]})]}),!c&&e.jsx("div",{className:"mt-2 text-center",children:e.jsx("p",{className:fs("text-2xl font-bold",y
2594),children:t.value.toLocaleString()})}),c&&e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsx("p",{className:fs("text-lg font-bold",y),children:t.value.toLocaleString()})})]})},P9=({metrics:t,onClose:s,onPositionChange:n})=>t.length===0?null:e.jsx(e.Fragment,{children:t.map(a=>e.jsx(E9,{metric:a,onClose:s,onPositionChange:n},a.id))}),T9={light:"",dark:".dark"},pL=k.createContext(null);function gL(){const t=k.useContext(pL);if(!t)throw new Error("useChart must be used within a <ChartContainer />");return t}const y1=k.forwardRef(({id:t,className:s,children:n,config:a,...l},c)=>{const u=k.useId(),i=`chart-${t||u.replace(/:/g,"")}`;return e.jsx(pL.Provider,{value:{config:a},children:e.jsxs("div",{"data-chart":i,ref:c,className:fs("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",s),...l,children:[e.jsx(L9,{id:i,config:a}),e.jsx(Tb,{children:n})]})})});y1.displayName="Chart";const L9=({id:t,config:s})=>{const n=Object.entries(s).filter(([a,l])=>l.theme||l.color);return n.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(T9).map(([a,l])=>`
2595${l} [data-chart=${t}] {
2596${n.map(([c,u])=>{var _;const i=((_=u.theme)==null?void 0:_[a])||u.color;return i?`  --color-${c}: ${i};`:null}).join(`
2597`)}
2598}
2599`).join(`
2600`)}}):null},AC=p5,v1=k.forwardRef(({active:t,payload:s,className:n,indicator:a="dot",hideLabel:l=!1,hideIndicator:c=!1,label:u,labelFormatter:i,labelClassName:_,formatter:j,color:y,nameKey:x,labelKey:v},C)=>{const{config:P}=gL(),I=k.useMemo(()=>{var te;if(l||!(s!=null&&s.length))return null;const[F]=s,D=`${v||F.dataKey||F.name||"value"}`,X=b1(P,F,D),K=!v&&typeof u=="string"?((te=P[u])==null?void 0:te.label)||u:X==null?void 0:X.label;return i?e.jsx("div",{className:fs("font-medium",_),children:i(K,s)}):K?e.jsx("div",{className:fs("font-medium",_),children:K}):null},[u,i,s,l,_,P,v]);if(!t||!(s!=null&&s.length))return null;const z=s.length===1&&a!=="dot";return e.jsxs("div",{ref:C,className:fs("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",n),children:[z?null:I,e.jsx("div",{className:"grid gap-1.5",children:s.map((F,D)=>{const X=`${x||F.name||F.dataKey||"value"}`,K=b1(P,F,X),te=y||F.payload.fill||F.color;return e.jsx("div",{className:fs("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",a==="dot"&&"items-center"),children:j&&(F==null?void 0:F.value)!==void 0&&F.name?j(F.value,F.name,F,D,F.payload):e.jsxs(e.Fragment,{children:[K!=null&&K.icon?e.jsx(K.icon,{}):!c&&e.jsx("div",{className:fs("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":a==="dot","w-1":a==="line","w-0 border-[1.5px] border-dashed bg-transparent":a==="dashed","my-0.5":z&&a==="dashed"}),style:{"--color-bg":te,"--color-border":te}}),e.jsxs("div",{className:fs("flex flex-1 justify-between leading-none",z?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[z?I:null,e.jsx("span",{className:"text-muted-foreground",children:(K==null?void 0:K.label)||F.name})]}),F.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:F.value.toLocaleString()})]})]})},F.dataKey)})})]})});v1.displayName="ChartTooltip";const M9=k.forwardRef(({className:t,hideIcon:s=!1,payload:n,verticalAlign:a="bottom",nameKey:l},c)=>{const{config:u}=gL();return n!=null&&n.length?e.jsx("div",{ref:c,className:fs("flex items-center justify-center gap-4",a==="top"?"pb-3":"pt-3",t),children:n.map(i=>{const _=`${l||i.dataKey||"value"}`,j=b1(u,i,_);return e.jsxs("div",{className:fs("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[j!=null&&j.icon&&!s?e.jsx(j.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:i.color}}),j==null?void 0:j.label]},i.value)})}):null});M9.displayName="ChartLegend";function b1(t,s,n){if(typeof s!="object"||s===null)return;const a="payload"in s&&typeof s.payload=="object"&&s.payload!==null?s.payload:void 0;let l=n;return n in s&&typeof s[n]=="string"?l=s[n]:a&&n in a&&typeof a[n]=="string"&&(l=a[n]),l in t?t[l]:t[n]}function I9({onClose:t}){const s=[],n=[],a=k.useMemo(()=>[...s,...n],[s,n]),l=k.useMemo(()=>{const j=["singles","townhomes","apartments"],y=a.filter(X=>j.includes(X.type)).reduce((X,K)=>X+(K.units||0),0),x=a.filter(X=>X.type==="singles").reduce((X,K)=>X+(K.units||0),0),v=a.filter(X=>X.type==="townhomes").reduce((X,K)=>X+(K.units||0),0),C=a.filter(X=>X.type==="apartments").reduce((X,K)=>X+(K.units||0),0),P=a.filter(X=>X.type==="industrial").reduce((X,K)=>X+(K.square_footage||0),0),I=a.filter(X=>X.type==="retail").reduce((X,K)=>X+(K.square_footage||0),0),z=a.filter(X=>X.type==="medical").reduce((X,K)=>X+(K.square_footage||0),0),F=a.filter(X=>X.type==="mixed_use").reduce((X,K)=>X+(K.square_footage||0),0),D=P+I+z+F;return{residentialUnits:y,singlesUnits:x,townhomesUnits:v,apartmentsUnits:C,industrialSF:P,retailSF:I,medicalSF:z,mixedUseSF:F,totalCommercialSF:D}},[a]),c=[{name:"Single Family",value:l.singlesUnits,fill:"hsl(var(--chart-1))"},{name:"Townhomes",value:l.townhomesUnits,fill:"hsl(var(--chart-2))"},{name:"Apartments",value:l.apartmentsUnits,fill:"hsl(var(--chart-3))"}].filter(j=>j.value>0),u=[{name:"Industrial",value:l.industrialSF,fill:"hsl(var(--chart-2))"},{name:"Retail",value:l.retailSF,fill:"hsl(var(--chart-3))"},{name:"Medical",value:l.medicalSF,fill:"hsl(var(--chart-4))"},{name:"Mixed-Use",value:l.mixedUseSF,fill:"hsl(var(--chart-5))"}].filter(j=>j.value>0),i={residential:{label:"Residential Units",color:"hsl(var(--chart-1))"},industrial:{label:"Industrial SF",color:"hsl(var(--chart-2))"},retail:{label:"Retail SF",color:"hsl(var(--chart-3))"},medical:{label:"Medical SF",color:"hsl(var(--chart-4))"},mixed_use:{label:"Mixed-Use SF",color:"hsl(var(--chart-5))"}},_=j=>j>=1e6?`${(j/1e6).toFixed(2)}M`:j>=1e3?`${(j/1e3).toFixed(1)}
2600K`:j.toLocaleString();return e.jsxs("div",{className:"p-4 space-y-4 bg-background/95 backdrop-blur-sm rounded-lg border border-border shadow-lg max-w-4xl w-full max-h-[90vh] overflow-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-xl font-bold text-foreground",children:"Dashboard Summary"}),t&&e.jsx(Le,{variant:"ghost",size:"icon",onClick:t,children:e.jsx(ja,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-3",children:[e.jsx(Mo,{className:"bg-card/80",children:e.jsxs(Io,{className:"p-4 text-center",children:[e.jsx("div",{className:"flex items-center justify-center mb-2",children:e.jsx(qd,{className:"h-5 w-5 text-chart-1"})}),e.jsx("p",{className:"text-2xl font-bold text-chart-1",children:_(l.residentialUnits)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Residential Units"})]})}),e.jsx(Mo,{className:"bg-card/80",children:e.jsxs(Io,{className:"p-4 text-center",children:[e.jsx("div",{className:"flex items-center justify-center mb-2",children:e.jsx(Ig,{className:"h-5 w-5 text-chart-2"})}),e.jsx("p",{className:"text-2xl font-bold text-chart-2",children:_(l.industrialSF)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Industrial SF"})]})}),e.jsx(Mo,{className:"bg-card/80",children:e.jsxs(Io,{className:"p-4 text-center",children:[e.jsx("div",{className:"flex items-center justify-center mb-2",children:e.jsx(fp,{className:"h-5 w-5 text-chart-3"})}),e.jsx("p",{className:"text-2xl font-bold text-chart-3",children:_(l.retailSF)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Retail SF"})]})}),e.jsx(Mo,{className:"bg-card/80",children:e.jsxs(Io,{className:"p-4 text-center",children:[e.jsx("div",{className:"flex items-center justify-center mb-2",children:e.jsx(E0,{className:"h-5 w-5 text-chart-4"})}),e.jsx("p",{className:"text-2xl font-bold text-chart-4",children:_(l.medicalSF)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Medical SF"})]})}),e.jsx(Mo,{className:"bg-card/80",children:e.jsxs(Io,{className:"p-4 text-center",children:[e.jsx("div",{className:"flex items-center justify-center mb-2",children:e.jsx(Da,{className:"h-5 w-5 text-chart-5"})}),e.jsx("p",{className:"text-2xl font-bold text-chart-5",children:_(l.mixedUseSF)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Mixed-Use SF"})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(Mo,{className:"bg-card/80",children:[e.jsx(vc,{className:"pb-2",children:e.jsxs(bc,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(qd,{className:"h-4 w-4"}),"Residential Units Breakdown"]})}),e.jsx(Io,{children:c.length>0?e.jsx(y1,{config:i,className:"h-[200px] w-full",children:e.jsx(Tb,{width:"100%",height:"100%",children:e.jsxs(g5,{children:[e.jsx(x5,{data:c,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:70,label:({name:j,value:y})=>`${j}: ${_(y)}`,labelLine:!1,children:c.map((j,y)=>e.jsx(Hw,{fill:j.fill},`cell-${y}`))}),e.jsx(AC,{content:e.jsx(v1,{})}),e.jsx(_5,{})]})})}):e.jsx("div",{className:"h-[200px] flex items-center justify-center text-muted-foreground",children:"No residential data available"})})]}),e.jsxs(Mo,{className:"bg-card/80",children:[e.jsx(vc,{className:"pb-2",children:e.jsxs(bc,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Ci,{className:"h-4 w-4"}),"Commercial Square Footage"]})}),e.jsx(Io,{children:u.length>0?e.jsx(y1,{config:i,className:"h-[200px] w-full",children:e.jsx(Tb,{width:"100%",height:"100%",children:e.jsxs(y5,{data:u,layout:"vertical",children:[e.jsx(v5,{type:"number",tickFormatter:j=>_(j),fontSize:10}),e.jsx(b5,{dataKey:"name",type:"category",width:70,fontSize:10}),e.jsx(AC,{content:e.jsx(v1,{}),formatter:j=>[`${_(j)} SF`,""]}),e.jsx(j5,{dataKey:"value",radius:[0,4,4,0],children:u.map((j,y)=>e.jsx(Hw,{fill:j.fill},`cell-${y}`))})]})})}):e.jsx("div",{className:"h-[200px] flex items-center justify-center text-muted-foreground",children:"No commercial data available"})})]})]}),e.jsx(Mo,{className:"bg-card/80",children:e.jsx(Io,{className:"p-4",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:s.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Developments"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:n.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Existing Sites"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:_(l.residentialUnits)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Units"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:_(l.totalCommercialSF)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Commercial SF"})]})]})})})]})}const A9=()=>{const t=lc(),{data:s=[],isLoading:n,error:a}=fu({queryKey:["custom-metrics"],queryFn:async()=>{const{data:i,error:_}=await Fs.from("custom_metrics").select("*").order("display_order");if(_)throw console.error("Error fetching custom metrics:",_),_;return(i||[]).map(j=>({...j,entity_type:j.entity_type,aggregation_type:j.aggregation_type,filter_conditions:j.filter_conditions||{}}))}}),l=md({mutationFn:async i=>{const{data:_,error:j}=await Fs.from("custom_metrics").insert({name:i.name,description:i.description,entity_type:i.entity_type,aggregation_type:i.aggregation_type,field_name:i.field_name,filter_conditions:i.filter_conditions,display_order:i.display_order,is_visible:i.is_visible,icon:i.icon,color:i.color}).select().single();if(j)throw j;return _},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-metrics"]}),Ve.success("Metric created successfully")},onError:i=>{Ve.error("Failed to create metric: "+i.message)}}),c=md({mutationFn:async({id:i,..._})=>{const j={};
2600_.name!==void 0&&(j.name=_.name),_.description!==void 0&&(j.description=_.description),_.entity_type!==void 0&&(j.entity_type=_.entity_type),_.aggregation_type!==void 0&&(j.aggregation_type=_.aggregation_type),_.field_name!==void 0&&(j.field_name=_.field_name),_.filter_conditions!==void 0&&(j.filter_conditions=_.filter_conditions),_.display_order!==void 0&&(j.display_order=_.display_order),_.is_visible!==void 0&&(j.is_visible=_.is_visible),_.icon!==void 0&&(j.icon=_.icon),_.color!==void 0&&(j.color=_.color);const{data:y,error:x}=await Fs.from("custom_metrics").update(j).eq("id",i).select().single();if(x)throw x;return y},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-metrics"]}),Ve.success("Metric updated successfully")},onError:i=>{Ve.error("Failed to update metric: "+i.message)}}),u=md({mutationFn:async i=>{const{error:_}=await Fs.from("custom_metrics").delete().eq("id",i);if(_)throw _},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-metrics"]}),Ve.success("Metric deleted successfully")},onError:i=>{Ve.error("Failed to delete metric: "+i.message)}});return{customMetrics:s,isLoading:n,error:a,createMetric:l,updateMetric:c,deleteMetric:u}},DC={amber:"bg-amber-500/10 text-amber-500",cyan:"bg-cyan-500/10 text-cyan-500",green:"bg-green-500/10 text-green-500",blue:"bg-blue-500/10 text-blue-500",purple:"bg-purple-500/10 text-purple-500",red:"bg-red-500/10 text-red-500"};function D9({className:t}){const{customMetrics:s,isLoading:n}=A9(),a=[],l=[],{tenants:c=[]}=I1(),{developers:u=[]}=Jx(),{owners:i=[]}=Qx(),_=s.filter(y=>y.is_visible),j=k.useMemo(()=>y=>{let x=[];switch(y.entity_type){case"developments":x=a;break;case"existing_products":x=l;break;case"tenants":x=c;break;case"developers":x=u;break;case"owners":x=i;break}switch(y.filter_conditions&&Object.keys(y.filter_conditions).length>0&&(x=x.filter(v=>Object.entries(y.filter_conditions).every(([C,P])=>v[C]===P))),y.aggregation_type){case"count":return x.length;case"sum":return y.field_name?x.reduce((C,P)=>C+(Number(P[y.field_name])||0),0):0;case"average":if(!y.field_name||x.length===0)return 0;const v=x.reduce((C,P)=>C+(Number(P[y.field_name])||0),0);return Math.round(v/x.length);default:return 0}},[a,l,c,u,i]);return n||_.length===0?null:e.jsx("div",{className:t,children:_.map(y=>{const x=j(y),v=DC[y.color||"amber"]||DC.amber;return e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",title:y.description||void 0,children:[e.jsx("p",{className:`text-2xl font-bold ${v.split(" ")[1]}`,children:x.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:y.name})]},y.id)})})}const R9={residential_units:{entity_type:"developments",aggregation_type:"sum",field_name:"units",filter_conditions:{},include_existing_products:!1,type_filter:["singles","townhomes","apartments"]},industrial_sf:{entity_type:"developments",aggregation_type:"sum",field_name:"square_footage",filter_conditions:{type:"industrial"},include_existing_products:!1},retail_sf:{entity_type:"developments",aggregation_type:"sum",field_name:"square_footage",filter_conditions:{type:"retail"},include_existing_products:!1},medical_sf:{entity_type:"developments",aggregation_type:"sum",field_name:"square_footage",filter_conditions:{type:"medical"},include_existing_products:!1},mixed_use_sf:{entity_type:"developments",aggregation_type:"sum",field_name:"square_footage",filter_conditions:{type:"mixed_use"},include_existing_products:!1},projects:{entity_type:"developments",aggregation_type:"count",filter_conditions:{},include_existing_products:!0},jobs_created:{entity_type:"developments",aggregation_type:"sum",field_name:"jobs",filter_conditions:{},include_existing_products:!1}},RC=()=>{try{const t=localStorage.getItem("hidden-builtin-metrics");return t?JSON.parse(t):[]}catch{return[]}},FC=()=>{try{const t=localStorage.getItem("builtin-metric-labels");return t?JSON.parse(t):{}}catch{return{}}},zC=()=>{try{const t=localStorage.getItem("builtin-metric-configs");return t?JSON.parse(t):{}}catch{return{}}},F9=({open:t,onOpenChange:s,onPinMetric:n,pinnedMetricIds:a=[]})=>{const l=[],c=[],[u,i]=k.useState(()=>RC()),[_,j]=k.useState(()=>FC()),[y,x]=k.useState(()=>zC());k.useEffect(()=>{const K=()=>{i(RC()),j(FC()),x(zC())};return window.addEventListener("storage",K),window.addEventListener("builtin-metrics-updated",K),(
2600)=>{window.removeEventListener("storage",K),window.removeEventListener("builtin-metrics-updated",K)}},[]);const v=K=>{const te=y[K]||R9[K];let H=(te.entity_type==="developments"?l:te.entity_type==="existing_products"?c:[]).filter(W=>te.type_filter&&te.type_filter.length>0&&!te.type_filter.includes(W.type)?!1:te.filter_conditions?Object.entries(te.filter_conditions).every(([Q,Z])=>W[Q]===Z):!0);const O=(W,Q)=>{if(Q.startsWith("custom:")){const Z=Q.replace("custom:",""),oe=W.custom_fields;return Number(oe==null?void 0:oe[Z])||0}return Number(W[Q])||0};let q=0;if(te.aggregation_type==="count")q=H.length,te.include_existing_products&&te.entity_type==="developments"&&(q+=c.length);else if(te.aggregation_type==="sum"&&te.field_name)q=H.reduce((W,Q)=>W+O(Q,te.field_name),0);else if(te.aggregation_type==="average"&&te.field_name){const W=H.reduce((Q,Z)=>Q+O(Z,te.field_name),0);q=H.length>0?Math.round(W/H.length):0}return q},C=(K,te)=>_[K]||te,P=v("residential_units"),I=v("industrial_sf"),z=v("projects"),F=v("jobs_created"),D=(K,te,J)=>{if(!n)return;const H=window.innerWidth-250;n({id:K,label:te,value:J,position:{x:H,y:120}}),s(!1)},X=({id:K,value:te,label:J})=>{const H=a.includes(K);return e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsxs("div",{className:`bg-muted/50 rounded-lg p-4 text-center cursor-pointer transition-all hover:bg-muted/80 hover:scale-[1.02] relative group ${H?"ring-2 ring-primary/50":""}`,onClick:()=>D(K,J,te),children:[e.jsx("p",{className:"text-3xl font-bold text-foreground",children:te.toLocaleString()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:J}),e.jsx(Bb,{className:`absolute top-2 right-2 w-3 h-3 transition-opacity ${H?"opacity-100 text-primary":"opacity-0 group-hover:opacity-50"}`})]})}),e.jsx(or,{children:e.jsx("p",{children:H?"Already pinned to map":"Click to pin to map"})})]})};return e.jsx(dd,{open:t,onOpenChange:s,children:e.jsxs(ud,{className:"sm:max-w-md",children:[e.jsxs(Gd,{children:[e.jsxs(rr,{children:[e.jsx(ir,{asChild:!0,children:e.jsx(Hd,{children:"Metrics Overview"})}),e.jsx(or,{children:"MetricsDialog"})]}),e.jsx(vg,{className:"text-xs",children:"Click any metric to pin it to the map as a floating widget"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 py-4",children:[!u.includes("residential_units")&&e.jsx(X,{id:"residential_units",value:P,label:C("residential_units","Residential Units")}),!u.includes("industrial_sf")&&e.jsx(X,{id:"industrial_sf",value:I,label:C("industrial_sf","Industrial SF")}),!u.includes("projects")&&e.jsx(X,{id:"projects",value:z,label:C("projects","Projects")}),!u.includes("jobs_created")&&e.jsx(X,{id:"jobs_created",value:F,label:C("jobs_created","Jobs Created")}),e.jsx(D9,{className:"col-span-2 grid grid-cols-2 gap-3"})]})]})})},z9=t=>{const s=lc();return k.useEffect(()=>{const n=Fs.channel("activity-log").on("postgres_changes",{event:"INSERT",schema:"public",table:"activity_log"},()=>{s.invalidateQueries({queryKey:["activity-log"]})}).subscribe();return()=>{Fs.removeChannel(n)}},[t,s]),fu({queryKey:["activity-log"],queryFn:async()=>{let n=Fs.from("activity_log").select("*").order("created_at",{ascending:!1}).limit(50);const{data:a,error:l}=await n;if(l)throw l;const c=[...new Set(a.filter(_=>_.user_id).map(_=>_.user_id))],{data:u}=await Fs.from("profiles").select("id, email").in("id",c),i=new Map((u==null?void 0:u.map(_=>[_.id,_.email]))||[]);return a.map(_=>({id:_.id,development_id:_.development_id,existing_product_id:_.existing_product_id,developer_id:_.developer_id,owner_id:_.owner_id,tenant_id:_.tenant_id,user_id:_.user_id,action:_.action,details:_.details,created_at:_.created_at,user_email:_.user_id?i.get(_.user_id)||"Unknown":"System"}))}})},O9=({open:t,onOpenChange:s,onNavigateToRecord:n,onNavigateToCrm:a})=>{const{data:l=[],isLoading:c}=z9(),u=x=>{var C;const v=(C=x.details)==null?void 0:C.entity_type;return v==="existing_product"||x.existing_product_id?e.jsx(Sc,{className:"h-4 w-4"}):v==="development"||x.development_id?e.jsx(Ci,{className:"h-4 w-4"}):v==="developer"||x.developer_id?e.jsx(e3,{className:"h-4 w-4"}):v==="owner"||x.owner_id?e.jsx(Sf,{className:"h-4 w-4"}):v==="tenant"||x.tenant_id?e.jsx(yl,{className:"h-4 w-4"}):e.jsx(Pb,{className:"h-4 w-4"})},i=(x,v)=>{const C=(v==null?void 0:v.name)||"Unknown";switch(x){case"created":return`Created "${C}"`;case"updated":const P=v==null?void 0:v.changes;if(P){const I=Object.entries(P).filter(([z,F])=>F!==null).map(([z])=>z);if(I.length>0)return`Updated "${C}" (${I.join(", ")})`}return`Updated "${C}"`;case"deleted":return`Deleted "${C}"`;default:return`${x} "${C}"`}},_=x=>{switch(x){case"created":return"text-green-500";case"updated":return"text-amber-500";case"deleted":return"text-red-500";default:return"text-muted-foreground"}},j=x=>{x.action!=="deleted"&&(x.development_id&&n?(n(x.development_id,"development"),s(!1)):x.existing_product_id&&n?(n(x.existing_product_id,"existing"),s(!1)):x.developer_id&&a?(a(x.developer_id,"developer"),s(!1)):x.owner_id&&a?(a(x.owner_id,"owner"),s(!1)):x.tenant_id&&a&&(a(x.tenant_id,"tenant"),s(!1)))},y=x=>{if(x.action==="deleted")return!1;const v=(x.development_id||x.existing_product_id)&&n,C=(x.developer_id||x.owner_id||x.tenant_id)&&a;return v||C};return e.jsx(dd,{open:t,onOpenChange:s,children:e.jsxs(ud,{className:"sm:max-w-md fixed right-4 left-auto translate-x-0 h-[80vh] flex flex-col",children:[e.jsx(Gd,{children:e.jsxs(Hd,{className:"flex items-center gap-2",children:[e.jsx(Pb,{className:"h-5 w-5 text-primary"}),"Activity Feed",l.length>0&&e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",l.length," entries)"]}
2600)]})}),e.jsx(Xc,{className:"flex-1 -mx-6 px-6",children:c?e.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"Loading activity..."}):l.length===0?e.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"No recent activity"}):e.jsx("div",{className:"space-y-2 pb-4",children:l.map(x=>{var v;return e.jsxs("div",{onClick:()=>j(x),className:`flex items-start gap-3 p-3 rounded-lg bg-muted/30 border border-border/50 transition-colors ${y(x)?"hover:bg-muted/50 hover:border-border cursor-pointer":"opacity-75"}`,children:[e.jsx("div",{className:`mt-0.5 ${_(x.action)}`,children:u(x)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:i(x.action,x.details)}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Ep,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate max-w-[120px]",children:((v=x.user_email)==null?void 0:v.split("@")[0])||"System"})]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(bg,{className:"h-3 w-3"}),e.jsx("span",{children:M1(new Date(x.created_at),{addSuffix:!0})})]})]})]})]},x.id)})})})]})})},B9=({open:t,onOpenChange:s,onStartDrawing:n})=>{const a=l=>{n(l),s(!1)};return e.jsx(dd,{open:t,onOpenChange:s,children:e.jsxs(ud,{className:"sm:max-w-sm fixed right-4 left-auto translate-x-0",children:[e.jsx(Gd,{children:e.jsxs(Hd,{className:"flex items-center gap-2",children:[e.jsx(F3,{className:"w-5 h-5"}),"Drawing Tools"]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsxs(Le,{variant:"outline",size:"lg",className:"w-full justify-start gap-3 h-14",onClick:()=>
2600a("polygon"),children:[e.jsx(fd,{className:"w-5 h-5 text-amber-500"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:"Polygon"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Draw a closed shape area"})]})]}),e.jsxs(Le,{variant:"outline",size:"lg",className:"w-full justify-start gap-3 h-14",onClick:()=>a("polyline"),children:[e.jsx(uo,{className:"w-5 h-5 text-blue-500"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:"Polyline"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Draw a line or route"})]})]}),e.jsxs(Le,{variant:"outline",size:"lg",className:"w-full justify-start gap-3 h-14",onClick:()=>a("marker"),children:[e.jsx(ji,{className:"w-5 h-5 text-red-500"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:"Marker"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Place a point marker"})]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center pt-2",children:"Click on the map to start drawing"})]})})},$9=k.lazy(()=>br(()=>import("./EmbedCodeDialog-C-KeS9Bz.js"),__vite__mapDeps([38,1,2,8,4,5,13,12,11,10,16]))),V9=k.lazy(()=>br(()=>import("./UserManagement-6rQIctMZ.js"),__vite__mapDeps([39,1,2,8,4,5,11,12,10,17,22]))),q9=k.lazy(()=>br(()=>import("./MapOverlaysPanel-CxdUloM5.js"),__vite__mapDeps([40,1,2,3,4,5,6,8,24,11,12,10,21,15,17,18,13,19,9,16,20,14,22,23,25,26,27,28]))),G9=k.lazy(()=>br(()=>Promise.resolve().then(()=>ED),void 0)),H9=k.lazy(()=>br(()=>import("./RetailerLogoLibrary-D5BzLU2y.js"),__vite__mapDeps([41,1,2,8,4,5,11,12,10,42,18,13,17,3,6,9,15,16,20,14,21,22,19,23,24,25,26,27,28]))),Z9=k.lazy(()=>br(()=>import("./NomenclaturePanel-BX76q8Vd.js"),__vite__mapDeps([43,1,2,8,4,5,11,12,10,9,13,21,27,16,3,6,15,17,20,14,22,19,23,24,25,18,26,28]))),W9=k.lazy(()=>br(()=>import("./EditOverlayDialog-B-XCtPpB.js"),__vite__mapDeps([44,1,2,8,4,5,11,12,10,14,3,6,21,17,22,13,9,15,16,20,19,23,24,25,18,26,27,28]))),Y9=k.lazy(()=>br(()=>import("./RegionFilterPanel-BwKxSs_h.js"),__vite__mapDeps([45,1,2,8,4,5,11,12,10,23,22,19,13,3,6,9,15,16,17,20,14,21,24,25,18,26,27,28]))),xL="map-visibility-preferences",X9=()=>{try{const t=localStorage.getItem(xL);if(t)return JSON.parse(t)}catch(t){console.error("Failed to load visibility preferences:",t)}return null},K9=t=>{try{localStorage.setItem(xL,JSON.stringify(t))}catch(s){console.error("Failed to save visibility preferences:",s)}},J9=()=>{const t=localStorage.getItem("map-style");if(t&&["light","dark","satellite","terrain","topo","street","voyager"].includes(t))return t;const s=localStorage.getItem("map-satellite")==="true",n=localStorage.getItem("map-dark-mode")==="true";return s?"satellite":n?"dark":"light"},Q9=()=>{const t=localStorage.getItem("map-boundary-layers");if(t)try{return JSON.parse(t)}catch{}return{states:!1,counties:!1,cities:!1,municipalities:!1,zipCodes:!1,congressionalDistricts:!1,censusTracks:!1,schoolDistricts:!1,primaryRoads:!1,secondaryRoads:!1,localRoads:!1,railroads:!1,roadsOverlay:!1,majorRoads:!1,transmissionLines:!1,substations:!1,powerPlants:!1,wetlands:!1,floodZones:!1,hydrology:!1,brownfields:!1,superfund:!1,toxicRelease:!1,geology:!1,soils:!1,bedrock:!1,groundwater:!1,shadedRelief:!1,topographic:!1,usgsImagery:!1,demographics:!1,schools:!1,crimeStats:!1,walkability:!1,opportunityZones:!1,airports:!1,ports:!1,railLines:!1,zoneomicsTiles:!1,zoningBoundary:!1,demographicsMetric:"income",demographicsDisplayMode:"popup"}},U9=()=>{const t=localStorage.getItem("map-layer-opacity");if(t)try{return JSON.parse(t)}catch{}
2600return{boundaries:.75,infrastructure:.75,environmental:.5,terrain:.6,schoolDistricts:.75,states:.85,counties:.8,municipalities:.75,roads:.6}},eH=()=>{var zl;const t=b0(),s=o_(),{user:n,isAdmin:a,loading:l,signOut:c}=HC(),{preferences:u,isLoading:i,updateCrmFilter:_,updateMapVisibility:j,updateRegionFilterSettings:y}=Kx(),x=N9(),{isEnabled:v}=$g(),C=HS(),P=k.useRef(!1),[I,z]=k.useState(null),[F,D]=k.useState(null),[X,K]=k.useState(!1),[te,J]=k.useState(0),[H,O]=k.useState(()=>{try{const qe=localStorage.getItem("crm-visible-developers");return qe?new Set(JSON.parse(qe)):new Set}catch{return new Set}}),[q,W]=k.useState(()=>{try{const qe=localStorage.getItem("crm-visible-owners");return qe?new Set(JSON.parse(qe)):new Set}catch{return new Set}}),[Q,Z]=k.useState(()=>{try{const qe=localStorage.getItem("crm-visible-tenants");return qe?new Set(JSON.parse(qe)):new Set}catch{return new Set}}),[oe,ce]=k.useState(()=>{const qe=X9();return{types:[],statuses:[],tenantIds:[],showDevelopments:(qe==null?void 0:qe.showDevelopments)??!0,showExistingProducts:(qe==null?void 0:qe.showExistingProducts)??!0,hiddenDevelopmentIds:(qe==null?void 0:qe.hiddenDevelopmentIds)??[],hiddenExistingProductIds:(qe==null?void 0:qe.hiddenExistingProductIds)??[],developerId:void 0,ownerId:void 0,existingSiteType:"all"}}),ae=k.useMemo(()=>({...oe,visibleDeveloperIds:H,visibleOwnerIds:q,visibleTenantIds:Q}),[oe,H,q,Q]);k.useEffect(()=>{if(!i&&n&&!P.current){P.current=!0,u.crmFilter.type&&u.crmFilter.id&&ce(Xt=>({...Xt,developerId:u.crmFilter.type==="developer"?u.crmFilter.id:void 0,ownerId:u.crmFilter.type==="owner"?u.crmFilter.id:void 0}));const qe=u.mapVisibility;Object.keys(qe).length>0&&ce(Xt=>({...Xt,showDevelopments:qe.showDevelopments??Xt.showDevelopments,showExistingProducts:qe.showExistingProducts??Xt.showExistingProducts}))}},[i,n,u]);const[ie,de]=k.useState(!1),[ge,We]=k.useState(!1),[Ee,ve]=k.useState(!1),[we,Ze]=k.useState(!1),[ke,ze]=k.useState(!1),[Ke,dt]=k.useState(!1),[Re,qt]=k.useState(!1),[ft,Fe]=k.useState(!1),[fe,Qe]=k.useState(!1),[ht,_t]=k.useState(!1),[He,as]=k.useState(!1),[vt,Xe]=k.useState(!1),[Ce,Be]=k.useState(!1),[Dt,Rt]=k.useState(!1),[zt,rs]=k.useState(!1),[_s,vs]=k.useState(!1),[$t,Ns]=k.useState(!1),[Ts,bs]=k.useState(!1),en=qe=>t(qe?`/dashboard?tab=${qe}`:"/dashboard"),Jt=k.useRef(null),[Vs,ps]=k.useState({lat:40.3285,lng:-76.011}),[nt,ts]=k.useState(13),ds=k.useCallback((qe,Xt)=>{ps(qe),ts(Xt)},[]),[Is,tn]=k.useState(!1),[wn,Gs]=k.useState(()=>{try{return localStorage.getItem("sidebar-collapsed")==="true"}catch{return!1}}),Ue=k.useCallback(()=>{Gs(qe=>!qe)},[]),[Pe,je]=k.useState(()=>{try{const qe=localStorage.getItem("sidebar-width");return qe?parseInt(qe,10):420}catch{return 420}}),[Ge,De]=k.useState(!1),bt=k.useRef(null),Ct=k.useCallback(qe=>{qe.preventDefault(),De(!0)},[]);k.useEffect(()=>{if(!Ge)return;const qe=js=>{const Rs=Math.max(320,Math.min(600,js.clientX));je(Rs)},Xt=()=>{De(!1),localStorage.setItem("sidebar-width",String(Pe))};return document.addEventListener("mousemove",qe),document.addEventListener("mouseup",Xt),()=>{document.removeEventListener("mousemove",qe),document.removeEventListener("mouseup",Xt)}},[Ge,Pe]),k.useEffect(()=>{try{localStorage.setItem("sidebar-collapsed",String(wn))}catch(qe){console.error("Failed to save sidebar state:",qe)}},[wn]);const[pe,wt]=k.useState(null),[Zt,ys]=k.useState(null),es=k.useCallback(()=>{wt(null),ys(null)},[]),[is,Ws]=k.useState(J9),[an,ya]=k.useState(Q9),[Hs,xt]=k.useState(U9),[os,Ls]=k.useState(!1),[Es,Qs]=k.useState([]),[Pn,Ks]=k.useState(()=>{const qe=localStorage.getItem("map-layer-visibility");if(qe)try{return JSON.parse(qe)}catch{return{}}return{}}),xa=k.useCallback(qe=>{Ks(qe)},[]),[Fn,Sa]=k.useState(()=>localStorage.getItem("map-3d-mode")==="true"),[sr,An]=k.useState(0),[Ai,xi]=k.useState(!1),[ei,Yr]=k.useState(null),[Xo,ra]=k.useState(!1),[Ka,Ha]=k.useState(null),[qa,Mn]=k.useState(null),_r=k.useCallback(qe=>{Xo&&!qe||xi(qe)},[Xo]),[Ar,Zs]=k.useState(!1),[Cn,Na]=k.useState(!1),[Gn,sa]=k.useState(null),[Pr,oi]=k.useState(null),{isLoading:Tr,parcel:Ko,lookupParcel:Za,loadParcelById:Gr,clearParcel:Xr,forceRefreshFromAPI:rn}=uM(),In=qS(),[Yi,jl]=k.useState(!1),[Si,zo]=k.useState(null),[Pc,Hr]=k.useState(!1),[ul,hl]=k.useState(!1),Nr=ym(),ui=k.useCallback(async()=>
2600{if(!In.stats.combinedBoundary){Ve.error("No boundary available to copy");return}Hr(!0);try{const qe=In.stats.combinedBoundary.geometry,js=(qe.type==="Polygon"?qe.coordinates[0]:qe.coordinates[0][0]).map(la=>({lat:la[1],lng:la[0]})),Rs=`Assemblage (${In.stats.totalItems} ${In.stats.totalItems===1?"item":"items"})`;await Nr.mutateAsync({name:Rs,type:"polygon",geometry:js,layer_type:"property_outline",is_visible:!0,style:{color:"#8b5cf6",fillColor:"#8b5cf6",weight:2,fillOpacity:.2},description:`Copied from assemblage with ${In.stats.parcelCount} parcels and ${In.stats.customAreaCount} custom areas.
2601Total: ${In.stats.totalAcres.toFixed(2)} acres`,calculated_area_acres:In.stats.totalAcres,calculated_area_sqft:In.stats.totalAcres*43560}),Ve.success(`Assemblage outline copied to Drawings as "${Rs}"`)}catch(qe){console.error("Failed to copy assemblage to drawings:",qe),Ve.error("Failed to copy assemblage to drawings")}finally{Hr(!1)}},[In.stats,Nr]),Zr=k.useCallback(async(qe,Xt)=>{var Rs;const js=qe||((Rs=In.stats.combinedBoundary)==null?void 0:Rs.geometry);if(!js){Ve.error("No boundary available");return}hl(!0);try{const la=js.type==="Polygon"?js.coordinates[0]:js.coordinates[0][0],Bn=la.map(Bo=>({lat:Bo[1],lng:Bo[0]})),Rr=la.map(Bo=>Bo[1]),Mc=la.map(Bo=>Bo[0]),Uo=(Math.min(...Rr)+Math.max(...Rr))/2,el=(Math.min(...Mc)+Math.max(...Mc))/2,Oo=In.stats.totalAcres||0,{data:{user:yo}}=await Fs.auth.getUser(),gl=Xt||`Assemblage Site (${In.stats.totalItems||0} items)`,{data:ci,error:Eo}=await Fs.from("developments").insert({name:gl,lat:Uo,lng:el,type:"industrial",status:"planned",units:0,description:`Site layout created from assemblage. ${Oo.toFixed(2)} acres.`,created_by:yo==null?void 0:yo.id}).select("id").single();if(Eo)throw Eo;const tl=await Nr.mutateAsync({name:gl,type:"polygon",geometry:Bn,layer_type:"site",is_visible:!0,development_id:ci.id,style:{color:"#4f46e5",fillColor:"#4f46e5",weight:2,fillOpacity:.15},description:"Site layout from assemblage",calculated_area_acres:Oo,calculated_area_sqft:Oo*43560}),xl=tl==null?void 0:tl.id;xl&&await Nr.mutateAsync({name:"Property Outline",type:"polygon",geometry:Bn,layer_type:"property_outline",is_visible:!0,parent_overlay_id:xl,development_id:ci.id,style:{color:"#8b5cf6",fillColor:"#8b5cf6",weight:2,fillOpacity:.1},calculated_area_acres:Oo,calculated_area_sqft:Oo*43560}),xl&&(ra(!0),Ha(xl),xi(!0),Yr(xl)),Ve.success("Site Layout created from assemblage")}catch(la){console.error("Failed to create site layout:",la),Ve.error("Failed to create site layout")}finally{hl(!1)}},[In.stats,Nr,ra,Ha,xi,Yr]),Gi=k.useCallback(async qe=>{if(!(qe!=null&&qe.geometry)){Ve.error("No geometry available");return}hl(!0);try{const Xt=qe.geometry,js=Xt.type==="Polygon"?Xt.coordinates[0]:Xt.type==="MultiPolygon"?Xt.coordinates[0][0]:null;if(!js){Ve.error("Unsupported geometry format");return}const Rs=js.map(ci=>({lat:ci[1],lng:ci[0]})),la=qe.clickedLat||js.reduce((ci,Eo)=>ci+Eo[1],0)/js.length,Bn=qe.clickedLng||js.reduce((ci,Eo)=>ci+Eo[0],0)/js.length,Rr=qe.acres||0,{data:{user:Mc}}=await Fs.auth.getUser(),Uo=qe.address||qe.apn||"Parcel Site",{data:el,error:Oo}=await Fs.from("developments").insert({name:Uo,lat:la,lng:Bn,type:"industrial",status:"planned",units:0,description:`Site layout from parcel: ${qe.apn||"N/A"}
2602Owner: ${qe.owner||"Unknown"}`,created_by:Mc==null?void 0:Mc.id}).select("id").single();if(Oo)throw Oo;const yo=await Nr.mutateAsync({name:Uo,type:"polygon",geometry:Rs,layer_type:"site",is_visible:!0,development_id:el.id,style:{color:"#4f46e5",fillColor:"#4f46e5",weight:2,fillOpacity:.15},description:`Site layout from parcel: ${qe.apn||"N/A"}`,calculated_area_acres:Rr,calculated_area_sqft:Rr*43560}),gl=yo==null?void 0:yo.id;gl&&(await Nr.mutateAsync({name:"Property Outline",type:"polygon",geometry:Rs,layer_type:"property_outline",is_visible:!0,parent_overlay_id:gl,development_id:el.id,style:{color:"#8b5cf6",fillColor:"#8b5cf6",weight:2,fillOpacity:.1},calculated_area_acres:Rr,calculated_area_sqft:Rr*43560}),ra(!0),Ha(gl),xi(!0),Yr(gl)),Ve.success(`Site Layout created: ${Uo}`),Xr(),sa(null)}catch(Xt){console.error("Failed to create site layout from parcel:",Xt),Ve.error("Failed to create site layout")}finally{hl(!1)}},[Nr,ra,Ha,xi,Yr,Xr]),fn=Gn||Ko;XM({onSwipeRight:()=>{s&&!Is&&tn(!0)},onSwipeLeft:()=>{s&&Is&&tn(!1)},edgeThreshold:40,minSwipeDistance:60});const[kr,nr]=k.useState(null),[Br,wl]=k.useState({}),[Nl,lr]=k.useState(!1),[Xi,ml]=k.useState(null),[Co,ti]=k.useState(null),[qs,Tn]=k.useState(null),[oa,Pa]=k.useState(!1),[mr,$r]=k.useState(null),[Jo,na]=k.useState([]),[Sn,Ui]=k.useState([]),Ma=k.useCallback(qe=>{Ui(Xt=>{if(Xt.find(la=>la.id===qe.id))return Xt.filter(la=>la.id!==qe.id);const Rs=Xt.length*30;return[...Xt,{...qe,position:{x:qe.position.x+Rs,y:qe.position.y+Rs}}]})},[]),Di=k.useCallback(qe=>{Ui(Xt=>Xt.filter(js=>js.id!==qe))},[]),Al=k.useCallback((qe,Xt)=>{Ui(js=>
2602js.map(Rs=>Rs.id===qe?{...Rs,position:Xt}:Rs))},[]),cc=k.useMemo(()=>Sn.map(qe=>qe.id),[Sn]);k.useState(null);const[dc,_u]=k.useState(null),[uc,hc]=k.useState(null),[kl,Ki]=k.useState(null),[Dl,Ri]=k.useState(null),[Qo,Cl]=k.useState(null),[Rl,Md]=k.useState(null),{data:fl}=sS(),So=V5(),Kr=[],hi=[],Jd=!1,{data:Id=[]}=KM(),Hl=k.useMemo(()=>{let qe=Kr;return kr&&(qe=qe.filter(Xt=>CN({lat:Xt.lat,lng:Xt.lng},kr))),Br.county&&(qe=qe.filter(Xt=>Xt.county===Br.county)),Br.zip_code&&(qe=qe.filter(Xt=>Xt.zip_code===Br.zip_code)),Br.market_region&&(qe=qe.filter(Xt=>Xt.market_region===Br.market_region)),qe},[Kr,kr,Br]),Sl=k.useMemo(()=>{let qe=hi;return kr&&(qe=qe.filter(Xt=>CN({lat:Xt.lat,lng:Xt.lng},kr))),Br.county&&(qe=qe.filter(Xt=>Xt.county===Br.county)),Br.zip_code&&(qe=qe.filter(Xt=>Xt.zip_code===Br.zip_code)),Br.market_region&&(qe=qe.filter(Xt=>Xt.market_region===Br.market_region)),qe},[hi,kr,Br]),gd=kr||Br.county||Br.zip_code||Br.market_region,Zl=k.useCallback(()=>{nr(null),wl({})},[]);k.useEffect(()=>{if(!i&&n&&Id.length>0&&u.regionFilterSettings.activeRegionId){const qe=Id.find(Xt=>Xt.id===u.regionFilterSettings.activeRegionId);qe&&!kr&&nr(qe)}},[i,n,Id,u.regionFilterSettings.activeRegionId,kr]),k.useEffect(()=>{K9({showDevelopments:oe.showDevelopments,showExistingProducts:oe.showExistingProducts,hiddenDevelopmentIds:oe.hiddenDevelopmentIds,hiddenExistingProductIds:oe.hiddenExistingProductIds}),n&&P.current&&j({showDevelopments:oe.showDevelopments,showExistingProducts:oe.showExistingProducts})},[oe.showDevelopments,oe.showExistingProducts,oe.hiddenDevelopmentIds,oe.hiddenExistingProductIds,n,j]),k.useEffect(()=>{if(n&&P.current){const qe=oe.developerId?"developer":oe.ownerId?"owner":null,Xt=oe.developerId||oe.ownerId||null;_({type:qe,id:Xt,name:null})}},[oe.developerId,oe.ownerId,n,_]),k.useEffect(()=>{n&&P.current&&kr?y({activeRegionId:kr.id}):n&&P.current&&!kr&&y({activeRegionId:null})},[kr,n,y]),k.useEffect(()=>{!l&&!n&&t("/auth")},[n,l,t]);const Hi=k.useCallback(qe=>{z(qe),D(null),hc(null),K(!1),qe&&(!oe.showDevelopments||oe.hiddenDevelopmentIds.includes(qe.id))?Ki({lat:qe.lat,lng:qe.lng,name:qe.name,type:"development"}):Ki(null)},[oe.showDevelopments,oe.hiddenDevelopmentIds]),eo=k.useCallback(qe=>{D(qe),z(null),hc(null),K(!1),qe&&(!oe.showExistingProducts||oe.hiddenExistingProductIds.includes(qe.id))?Ki({lat:qe.lat,lng:qe.lng,name:qe.name,type:"existing"}):Ki(null)},[oe.showExistingProducts,oe.hiddenExistingProductIds]);k.useEffect(()=>{const qe=Xt=>{if(Xt.key==="Escape"&&(I||F)&&(z(null),D(null),hc(null),Ki(null)),Xt.key==="a"||Xt.key==="A"){const js=Xt.target;!(js.tagName==="INPUT"||js.tagName==="TEXTAREA"||js.isContentEditable)&&Ar&&(Xt.preventDefault(),In.toggleAssemblageMode())}};return window.addEventListener("keydown",qe),()=>window.removeEventListener("keydown",qe)},[I,F,Ar,In]);const Wr=k.useCallback((qe,Xt)=>{if(Xt==="development"){const js=Kr.find(Rs=>Rs.id===qe);js&&Hi(js)}else{const js=hi.find(Rs=>Rs.id===qe);js&&eo(js)}},[Kr,hi,Hi,eo]),Tc=k.useCallback((qe,Xt)=>{if(Xt==="development"){const js=Kr.find(Rs=>Rs.id===qe);js&&Ki({lat:js.lat,lng:js.lng,name:js.name,type:"development"})}else{const js=hi.find(Rs=>Rs.id===qe);js&&Ki({lat:js.lat,lng:js.lng,name:js.name,type:"existing"})}},[Kr,hi]),Wl=k.useCallback((qe,Xt,js,Rs)=>{qe==="developer"?(O(la=>{const Bn=new Set(la);return Rs?Bn.add(Xt):Bn.delete(Xt),localStorage.setItem("crm-visible-developers",JSON.stringify([...Bn])),Bn}),Ve.success(Rs?`Showing locations for "${js}"`:`Hiding locations for "${js}"`)):qe==="owner"?(W(la=>{const Bn=new Set(la);return Rs?Bn.add(Xt):Bn.delete(Xt),localStorage.setItem("crm-visible-owners",JSON.stringify([...Bn])),Bn}),Ve.success(Rs?`Showing locations for "${js}"`:`Hiding locations for "${js}"`)):qe==="tenant"&&(Z(la=>{const Bn=new Set(la);return Rs?Bn.add(Xt):Bn.delete(Xt),localStorage.setItem("crm-visible-tenants",JSON.stringify([...Bn])),Bn}),Ve.success(Rs?`Showing locations for "${js}"`:`Hiding locations for "${js}"`))},[]);k.useCallback(()=>{O(new Set),W(new Set),Z(new Set),localStorage.removeItem("crm-visible-developers"),localStorage.removeItem("crm-visible-owners"),localStorage.removeItem("crm-visible-tenants"),Ve.success("Cleared all CRM visibility filters")},[]),k.useCallback(qe=>{if((qe==="developer"?H:qe==="owner"?q:Q).size===0){Ve.info("No CRM entities are currently visible");return}const js=[];if(qe==="developer"?(Kr.forEach(Bn=>{Bn.developer_id&&H.has(Bn.developer_id)&&js.push({lat:Bn.lat,lng:Bn.lng})}),hi.forEach(Bn=>{Bn.developer_id&&H.has(Bn.developer_id)&&js.push({lat:Bn.lat,lng:Bn.lng})})):qe==="owner"&&(Kr.forEach(Bn=>{Bn.owner_id&&q.has(Bn.owner_id)&&js.push({lat:Bn.lat,lng:Bn.lng})}),hi.forEach(Bn=>{Bn.owner_id&&q.has(Bn.owner_id)&&js.push({lat:Bn.lat,lng:Bn.lng})})),js.length===0){Ve.info("No properties found for the selected CRM entities");return}const Rs=js.reduce((Bn,Rr)=>Bn+Rr.lat,0)/js.length,la=js.reduce((Bn,Rr)=>Bn+Rr.lng,0)/js.length;Ki({lat:Rs,lng:la,name:`${js.length} visible properties`,type:"development"}),Ve.success(`Found ${js.length} properties - click map pin to view`)},[Kr,hi,H,q,Q]);const _o=k.useCallback(()=>{Ki(null)},[]),Yl=k.useCallback(qe=>{So.mutate({key:"map_title",value:qe})},[So]),Xl=k.useCallback((qe,Xt)=>{So.mutate({key:qe,value:Xt})},[So]);k.useCallback(()=>{ce(qe=>({...qe,showDevelopments:!qe.showDevelopments}))},[]),k.useCallback(()=>{ce(qe=>({...qe,showExistingProducts:!qe.showExistingProducts}))},[]),k.useCallback(()=>{ce(qe=>({...qe,hiddenDevelopmentIds:[]}))},[]),k.useCallback(()=>{ce(qe=>({...qe,hiddenExistingProductIds:[]}))},[]);const pl=k.useCallback((qe,Xt)=>{a&&ft&&_u({lat:qe,lng:Xt})},[a,ft]);k.useCallback(async qe=>{try{const{data:Xt,error:js}=await Fs.from("existing_products").insert([{name:qe.name,type:qe.type,units:qe.units,status:qe.status,description:qe.de
2602scription,year:qe.year,jobs:qe.jobs,lat:qe.lat,lng:qe.lng,boundary:qe.boundary,county:qe.county,zip_code:qe.zip_code,market_region:qe.market_region,developer_id:qe.developer_id,owner_id:qe.owner_id,display_logo_type:qe.display_logo_type,custom_fields:qe.custom_fields}]).select().single();if(js)throw js;const{data:Rs}=await Fs.from("development_tenants").select("*").eq("development_id",qe.id);Rs&&Rs.length>0&&await Fs.from("existing_product_tenants").insert(Rs.map(la=>({existing_product_id:Xt.id,retailer_logo_id:la.retailer_logo_id,tenant_id:la.tenant_id,display_order:la.display_order}))),await Fs.from("developments").update({deleted_at:new Date().toISOString()}).eq("id",qe.id),z(null),Ve.success(`Converted "${qe.name}" to Existing Site`)}catch(Xt){console.error("Conversion error:",Xt),Ve.error("Failed to convert record")}},[]),k.useCallback(async qe=>{try{const{data:Xt,error:js}=await Fs.from("developments").insert([{name:qe.name,type:qe.type,units:qe.units,status:qe.status,description:qe.description,year:qe.year,jobs:qe.jobs,lat:qe.lat,lng:qe.lng,boundary:qe.boundary,county:qe.county,zip_code:qe.zip_code,market_region:qe.market_region,developer_id:qe.developer_id,owner_id:qe.owner_id,display_logo_type:qe.display_logo_type,custom_fields:qe.custom_fields}]).select().single();if(js)throw js;const{data:Rs}=await Fs.from("existing_product_tenants").select("*").eq("existing_product_id",qe.id);Rs&&Rs.length>0&&await Fs.from("development_tenants").insert(Rs.map(la=>({development_id:Xt.id,retailer_logo_id:la.retailer_logo_id,tenant_id:la.tenant_id,display_order:la.display_order}))),await Fs.from("existing_products").update({deleted_at:new Date().toISOString()}).eq("id",qe.id),D(null),Ve.success(`Converted "${qe.name}" to Development`)}catch(Xt){console.error("Conversion error:",Xt),Ve.error("Failed to convert record")}},[]);const Fl=k.useCallback(qe=>{Ws(qe),localStorage.setItem("map-style",qe)},[]),Lc=k.useCallback(qe=>{ya(Xt=>{const js={...Xt,[qe]:!Xt[qe]};return localStorage.setItem("map-boundary-layers",JSON.stringify(js)),js})},[]),li=k.useCallback(qe=>{ya(Xt=>{const js={...Xt,...qe.metric&&{demographicsMetric:qe.metric},...qe.displayMode&&{demographicsDisplayMode:qe.displayMode}};return localStorage.setItem("map-boundary-layers",JSON.stringify(js)),js})},[]),Kl=k.useCallback((qe,Xt)=>{xt(js=>{const Rs={...js,[qe]:Xt};return localStorage.setItem("map-layer-opacity",JSON.stringify(Rs)),Rs})},[]),Ia=k.useCallback(()=>{Sa(qe=>{const Xt=!qe;return localStorage.setItem("map-3d-mode",Xt.toString()),Xt})},[]),Jl=k.useCallback(()=>{Zs(qe=>!qe)},[]),fr=k.useCallback(async(qe,Xt)=>{oi({lat:qe,lng:Xt});const js=await Za(qe,Xt);if(In.isAssemblageMode&&js){const Rs=In.isParcelSelected(js.id);In.toggleParcelSelection(js),Ve.success(Rs?"Parcel removed from assemblage":"Parcel added to assemblage",{description:`APN: ${js.apn}`,duration:2e3}),oi(null);return}Ve("Parcel clicked",{description:"Would you like to zoom in to see details?",duration:5e3,action:{label:"Zoom to Z18",onClick:()=>{var Rs;(Rs=Jt.current)==null||Rs.flyToLocation(qe,Xt,18)}},cancel:{label:"Stay here",onClick:()=>{}}}),oi(null)},[Za,In]),Dr=k.useCallback(qe=>{const Xt={id:qe.id,apn:qe.apn,address:qe.address,owner:qe.owner,ownerAddress:qe.ownerAddress,acres:qe.acres,sqft:qe.sqft,landUse:qe.landUse,zoning:qe.zoning,yearBuilt:qe.yearBuilt,assessedValue:qe.assessedValue,marketValue:qe.marketValue,geometry:qe.geometry,source:qe.source||"viewport",clickedLat:qe.geometry?(()=>{try{return(qe.geometry.type==="MultiPolygon"?qe.geometry.coordinates[0][0][0]:qe.geometry.coordinates[0][0])[1]}catch{return 0}})():0,clickedLng:qe.geometry?(()=>{try{return(qe.geometry.type==="MultiPolygon"?qe.geometry.coordinates[0][0][0]:qe.geometry.coordinates[0][0])[0]}catch{return 0}})():0},js=In.isParcelSelected(Xt.id);In.toggleParcelSelection(Xt),Ve.success(js?"Parcel removed from assemblage":"Parcel added to assemblage",{description:`APN: ${Xt.apn}`,duration:2e3})},[In]);return l?e.jsx(qw,{}):n?(Hl.filter(qe=>!oe.hiddenDevelopmentIds.includes(qe.id)).length,Sl.filter(qe=>!oe.hiddenExistingProductIds.includes(qe.id)).length,e.jsxs(k.Suspense,{fallback:e.jsx(qw,{}),children:[e.jsx(w9,{open:x.open,onOpenChange:x.setOpen,isAdmin:a,user:n,onShowDashboardSummary:()=>Rt(!0),onShowMapStyle:()=>Ls(!0),onShowMapOverlays:()=>Ze(!0),onShowLegend:()=>ze(!0),onShowRegionFilter:()=>Be(!0),onShowControls:()=>dt(!0),onShowUserDashboard:()=>en(),onShowUserManagement:()=>ve(!0),onShowSuggestionsPanel:()=>We(!0),onShowAdminPanel:()=>Fe(!0),onShowReviewPanel:()=>rs(!0),onShowEmbedCode:()=>de(!0),onSignOut:c}),e.jsxs("div",{className:"flex flex-col h-screen w-screen overflow-hidden bg-background",children:[!s&&e.jsx(S9,{isAdmin:a,onShowDashboardSummary:()=>Rt(!0),onShowMapStyle:()=>Ls(!0),onShowMapOverlays:()=>Ze(!0),onShowLegend:()=>ze(!0),onShowRegionFilter:()=>Be(!0),onShowControls:()=>dt(!0),onShowUserDashboard:()=>en(),onShowUserManagement:()=>ve(!0),onShowSuggestionsPanel:()=>We(!0),onShowAdminPanel:()=>Fe(!0),onShowExistingProductPanel:()=>Qe(!0),onShowLogoLibrary:()=>qt(!0),onShowReviewPanel:()=>rs(!0),onOpenCommandPalette:()=>x.setOpen(!0),onShowSiteArchitectDashboard:()=>en(),onShowMetrics:()=>bs(!0),boundaryLayers:an,onBoundaryLayerToggle:Lc,onDemographicsOptionsChange:li,isParcelLookupMode:Ar,onToggleParcelLo
2602okup:Jl,isAssemblageMode:In.isAssemblageMode,onToggleAssemblageMode:In.toggleAssemblageMode,assemblageParcelCount:In.selectedParcels.length,onOpenAI:()=>{},airportCategories:Es,onAirportCategoriesChange:Qs}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!s&&e.jsxs("div",{ref:bt,className:fs("shrink-0 border-r border-border relative",!Ge&&"transition-all duration-300"),style:{width:wn?48:Pe},children:[e.jsx(em,{children:e.jsx(nk,{developments:Hl,existingProducts:Sl,selectedDevelopment:I,selectedExistingProduct:F,onSelectDevelopment:Hi,onSelectExistingProduct:eo,filters:oe,onFiltersChange:ce,isLoading:Jd,scrollPosition:te,onScrollPositionChange:J,isCollapsed:wn,onToggleCollapse:Ue,isAdmin:a,pendingDeveloperId:pe,pendingOwnerId:Zt,onClearPendingCrm:es,onNavigateToProperty:Wr,onViewOnMap:Tc,onToggleCrmVisibility:Wl,visibleDeveloperIds:H,visibleOwnerIds:q,visibleTenantIds:Q,assemblages:In.savedAssemblages,isLoadingAssemblages:In.isLoadingAssemblages,selectedAssemblageId:Si==null?void 0:Si.id,onSelectAssemblage:qe=>{zo(qe),In.loadAssemblageParcels(qe)},onDeleteAssemblage:In.deleteAssemblage,isDeletingAssemblage:In.isDeleting,onNavigateToOverlay:qe=>Cl(qe),onEditOverlay:qe=>{Md(qe)},onOpenPolygonTools:qe=>{var Xt;Fn?(Yr(qe.id),xi(!0)):(Xt=Jt.current)==null||Xt.openPolygonTools(qe.id)},onStartDrawing:qe=>{var Xt;(Xt=Jt.current)==null||Xt.startOverlayDrawing(qe)},onSiteLayoutsModeChange:qe=>{ra(qe),qe?(Yr(null),xi(!0)):Ha(null)},activeSiteLayoutId:Ka,activeFocusId:qa,onActiveFocusIdChange:Mn,onShowSiteArchitectDashboard:()=>en()})}),!wn&&e.jsx("div",{className:fs("absolute top-0 right-0 w-1 h-full cursor-col-resize group z-10","hover:bg-primary/20 active:bg-primary/40",Ge&&"bg-primary/40"),onMouseDown:Ct,children:e.jsx("div",{className:fs("absolute top-1/2 -translate-y-1/2 right-0 w-1 h-16 rounded-full","bg-border group-hover:bg-primary/50 transition-colors",Ge&&"bg-primary")})})]}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(JG,{isAdmin:a,user:n,developments:Kr,existingProducts:hi,mapCenter:Vs,onSelectDevelopment:Hi,onSelectExistingProduct:eo,onSelectLocation:(qe,Xt,js,Rs)=>{var la;(la=Jt.current)==null||la.flyToLocation(qe,Xt,js,Rs)},onSelectMunicipality:(qe,Xt,js)=>{var Rs;(Rs=Jt.current)==null||Rs.flyToMunicipality(qe,Xt,js)},mapStyle:is,onMapStyleChange:Fl,onShowDashboardSummary:()=>Rt(!0),onShowControls:()=>dt(!0),onShowLegend:()=>ze(!0),boundaryLayers:an,onBoundaryLayerToggle:Lc,onDemographicsOptionsChange:li,isParcelLookupMode:Ar,onToggleParcelLookup:Jl,isAssemblageMode:In.isAssemblageMode,onToggleAssemblageMode:In.toggleAssemblageMode,assemblageParcelCount:In.selectedParcels.length,onOpenAI:()=>{},onLayerVisibilityChange:xa,airportCategories:Es,onAirportCategoriesChange:Qs,mapRef:(zl=Jt.current)==null?void 0:zl.getMapRef(),onPinMetric:Ma,pinnedMetricIds:cc,onSignOut:c,onShowEmbedCode:()=>de(!0),onShowSuggestionsPanel:()=>We(!0),onShowUserManagement:()=>ve(!0),onShowMapOverlays:()=>Ze(!0),onShowMapStyle:()=>Ls(!0),onShowNomenclature:()=>Xe(!0),onShowAdminDashboard:()=>en("users"),onShowUserDashboard:()=>en(),onOpenAdminDashboardTab:qe=>en(qe),onShowReviewPanel:()=>rs(!0),mapTitle:(fl==null?void 0:fl.map_title)||"",onMapTitleChange:Yl,mapSettings:fl,onMapSettingChange:Xl,onAIRecordCreated:(qe,Xt)=>{Xt==="development"?(z(qe),D(null)):(D(qe),z(null))},onNavigateToRecord:(qe,Xt)=>{if(Xt==="development"){const js=Kr.find(Rs=>Rs.id===qe);js&&(z(js),D(null))}else{const js=hi.find(Rs=>Rs.id===qe);js&&(D(js),z(null))}},onStartMeasuring:qe=>{Pa(!0),$r(qe),na([])},onShowDrawingTools:()=>Ns(!0),onShowSiteArchitectDashboard:()=>en(),apiUsage:{parcelRequests:C.parcelRequests,tileRequests:C.tileRequests,parcelUsagePercent:C.parcelUsagePercent,tileUsagePercent:C.tileUsagePercent,isParcelWarning:C.isParcelWarning,isTileWarning:C.isTileWarning,isParcelLimitReached:C.isParcelLimitReached,isTileLimitReached:C.isTileLimitReached,isLocked:C.isLocked,limits:C.limits,syncWithApiQuota:C.syncWithApiQuota}}),e.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[Fn?e.jsx("div",{className:"absolute inset-0 animate-fade-in",children:e.jsx(EG,{developments:Hl,existingProducts:Sl,selectedDevelopment:I,selectedExistingProduct:F,onSelectDevelopment:Hi,onSelectExistingProduct:eo,filters:oe,mapSettings:fl,mapStyle:is,bearing:sr,onBearing
2602Change:An,onExit3D:Ia,initialCenter:Vs,initialZoom:nt,onPositionChange:(qe,Xt)=>{ps(qe),ts(Xt)},isMeasuring:oa,measurementType:mr,measurementPoints:Jo,onStartMeasuring:qe=>{Pa(!0),$r(qe),na([])},onAddMeasurementPoint:qe=>{na(Xt=>[...Xt,qe])},onSetMeasurementPoint:(qe,Xt)=>{na(js=>{const Rs=[...js];return Rs[qe]=Xt,Rs})},onDeleteMeasurementPoint:qe=>{na(Xt=>Xt.filter((js,Rs)=>Rs!==qe))},onInsertMeasurementPoint:(qe,Xt)=>{na(js=>{const Rs=[...js];return Rs.splice(qe,0,Xt),Rs})},onUndoMeasurement:()=>{na(qe=>qe.slice(0,-1))},onCancelMeasurement:()=>{Pa(!1),$r(null),na([])},onClearMeasurement:()=>{na([])},isParcelLookupMode:Ar,drawingPanelOpen:Ai,onDrawingPanelOpenChange:_r,drawingPanelOverlayId:ei,onDrawingPanelOverlayIdChange:Yr,navigateToOverlay:Qo,onClearNavigateToOverlay:()=>Cl(null),activeGroupId:qa})},"3d-view"):e.jsx("div",{className:"absolute inset-0 animate-fade-in",children:e.jsx(FV,{ref:Jt,developments:Hl,existingProducts:Sl,selectedDevelopment:I,selectedExistingProduct:F,onSelectDevelopment:Hi,onSelectExistingProduct:eo,filters:ae,isAdmin:a,onMapClick:pl,drawBoundaryFor:Dl,onClearDrawBoundary:()=>Ri(null),navigateToOverlay:Qo,onClearNavigateToOverlay:()=>Cl(null),mapTitle:(fl==null?void 0:fl.map_title)||"Development Map",mapSettings:fl,mapStyle:is,onMapStyleChange:Fl,boundaryLayers:an,onBoundaryLayerToggle:Lc,layerOpacity:Hs,onLayerOpacityChange:Kl,layerVisibility:Pn,airportCategories:Es,isDrawingRegion:Nl,regionDrawingType:Xi,presetCircleRadius:Co,onRegionDrawn:qe=>{Tn(qe),lr(!1),ml(null),ti(null),Be(!0)},onCancelRegionDraw:()=>{lr(!1),ml(null),ti(null)},activeRegionFilter:kr,onUpdateActiveRegionRadius:qe=>{kr&&kr.region_type==="circle"&&nr({...kr,radius_miles:qe,name:`${qe.toFixed(1)} mi radius`,updated_at:new Date().toISOString()})},onCreateProximityFilter:(qe,Xt)=>{const js={id:`quick-proximity-${Date.now()}`,name:`${Xt} mi radius`,region_type:"circle",center_lat:qe.lat,center_lng:qe.lng,radius_miles:Xt,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};nr(js)},onAddDevelopment:(qe,Xt)=>{_t(!0),Fe(!0),qe!==void 0&&Xt!==void 0&&hc({lat:qe,lng:Xt,type:"development",originalLat:qe,originalLng:Xt})},onAddExistingProduct:(qe,Xt)=>{as(!0),Qe(!0),qe!==void 0&&Xt!==void 0&&hc({lat:qe,lng:Xt,type:"existing",originalLat:qe,originalLng:Xt})},is3DMode:Fn,onToggle3DMode:Ia,isParcelLookupMode:Ar,onToggleParcelLookup:Jl,onParcelSearch:()=>Na(!0),onParcelClick:fr,onViewportParcelClickForAssemblage:Dr,isParcelLoading:Tr,parcelClickLocation:Pr,parcelCenter:In.isAssemblageMode?null:(fn==null?void 0:fn.clickedLat)!=null&&(fn==null?void 0:fn.clickedLng)!=null?{lat:fn.clickedLat,lng:fn.clickedLng}:null,parcelGeometry:In.isAssemblageMode||fn==null?void 0:fn.geometry,assemblageParcels:In.selectedParcels.map(qe=>({id:qe.id,geometry:qe.geometry,lat:qe.clickedLat,lng:qe.clickedLng})),assemblageCustomAreas:In.customAreas.map(qe=>({id:qe.id,name:qe.name,geometry:qe.geometry})),isAssemblageMode:In.isAssemblageMode,isDrawingAssemblageArea:In.isDrawingCustomArea,onAssemblageAreaDrawn:In.addCustomArea,onCancelAssemblageAreaDraw:In.cancelDrawingCustomArea,onShowControls:()=>dt(!0),showControlsDialog:Ke,onControlsDialogChange:dt,showLegendDialog:ke,onLegendDialogChange:ze,isMeasuring:oa,measurementType:mr,measurementPoints:Jo,onStartMeasuring:qe=>{Pa(!0),$r(qe),na([])},onAddMeasurementPoint:qe=>{na(Xt=>[...Xt,qe])},onSetMeasurementPoint:(qe,Xt)=>{na(js=>{const Rs=[...js];return Rs[qe]=Xt,Rs})},onDeleteMeasurementPoint:qe=>{na(Xt=>Xt.filter((js,Rs)=>Rs!==qe))},onInsertMeasurementPoint:(qe,Xt)=>{na(js=>{const Rs=[...js];return Rs.splice(qe,0,Xt),Rs})},onUndoMeasurement:()=>{na(qe=>qe.slice(0,-1))},onCancelMeasurement:()=>{Pa(!1),$r(null),na([])},onClearMeasurement:()=>{na([])},onAIRecordCreated:(qe,Xt)=>{Xt==="development"?(z(qe),D(null)):(D(qe),z(null))},onNavigateToRecord:(qe,Xt)=>{if(Xt==="development"){const js=Kr.find(Rs=>Rs.id===qe);js&&(z(js),D(null))}else{const js=hi.find(Rs=>Rs.id===qe);js&&(D(js),z(null))}},previewLocation:uc,onPreviewLocationDrag:(qe,Xt)=>{uc&&hc({...uc,lat:qe,lng:Xt})},temporaryMarker:kl,onClearTemporaryMarker:_o,onMapPositionChange:ds,drawingPanelOpen:Ai,onDrawingPanelOpenChange:_r,drawingPanelOverlayId:ei,onDrawingPanelOverlayIdChange:Yr,activeSiteLayoutId:Ka,onActiveSiteLayoutIdChange:Ha,isSiteLayoutsMode:Xo,activeGroupId:qa})},"2d-view"),gd&&e.jsxs("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-[1400] flex items-center gap-2 bg-background/95 backdrop-blur-sm border border-border rounded-full px-4 py-2 shadow-lg",children:[e.jsx(wg,{className:"w-4 h-4 text-primary"}),e.jsxs("span",{className:"text-sm font-medium",children:[kr?kr.name:"Filtered",Br.county&&` • ${Br.county}`,Br.zip_code&&` • ${Br.zip_code}`,Br.market_region&&` • ${Br.market_region}`]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",Hl.length+Sl.length," of ",Kr.length+hi.length,")"]}),e.jsxs(Le,{variant:"outline",size:"sm",className:"h-7 px-2.5 ml-2 text-xs gap-1.5 border-destructive/30 text-destructive hover:bg-destructive hover:text-destructive-foreground",onClick:Zl,children:[e.jsx(ja,{className:"w-3.5 h-3.5"}),"Clear Filter"]})]}),e.jsxs("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 z-[1300] flex items-center gap-2 rounded-full px-3 py-1.5 shadow-lg border bg-[hsl(25,95%,53%)]/90 text-white border-[hsl(25,95%,43%)]",children:[e.jsx(Oy,{size:"sm",className:"h-4 brightness-0 invert"}),e.jsx("span",{className:"text-xs font-medium",children:"Site Architect"})]}),qa&&!Xo&&e.jsxs("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 z-[1400] flex items-center gap-2 bg-primary text-primary-foreground rounded-full px-4 py-2 shadow-lg",children:[e.jsx(Da,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Hierarchy Focus"}),e.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-primary-foreground hover:bg-primary-foreground
2602/20",onClick:()=>Mn(null),children:e.jsx(ja,{className:"w-3.5 h-3.5"})})]}),Ar&&e.jsx("div",{className:"absolute bottom-24 left-4 z-[1400]",children:e.jsx(ZI,{isActive:In.isAssemblageMode,assemblageItems:In.assemblageItems,stats:In.stats,isDrawingCustomArea:In.isDrawingCustomArea,onToggleMode:In.toggleAssemblageMode,onClearSelection:In.clearSelection,onRemoveItem:In.removeItem,onSave:()=>jl(!0),onCreateDevelopment:()=>{if(In.stats.combinedBoundary){_t(!0),Fe(!0);const qe=In.stats.combinedBoundary.geometry,Xt=qe.type==="Polygon"?qe.coordinates[0]:qe.coordinates[0][0],js=Xt.map(Rr=>Rr[1]),Rs=Xt.map(Rr=>Rr[0]),la=(Math.min(...js)+Math.max(...js))/2,Bn=(Math.min(...Rs)+Math.max(...Rs))/2;hc({lat:la,lng:Bn,type:"development",originalLat:la,originalLng:Bn})}},onCreateExistingSite:()=>{if(In.stats.combinedBoundary){as(!0),Qe(!0);const qe=In.stats.combinedBoundary.geometry,Xt=qe.type==="Polygon"?qe.coordinates[0]:qe.coordinates[0][0],js=Xt.map(Rr=>Rr[1]),Rs=Xt.map(Rr=>Rr[0]),la=(Math.min(...js)+Math.max(...js))/2,Bn=(Math.min(...Rs)+Math.max(...Rs))/2;hc({lat:la,lng:Bn,type:"existing",originalLat:la,originalLng:Bn})}},onStartDrawingCustomArea:In.startDrawingCustomArea,onCancelDrawingCustomArea:In.cancelDrawingCustomArea,onRenameCustomArea:In.renameCustomArea,onCopyToDrawings:ui,onCreateSiteLayout:()=>Zr(),isSaving:In.isSaving,isCopyingToDrawings:Pc,isCreatingSiteLayout:ul})}),Cn&&!fn&&e.jsx("div",{className:"absolute top-20 left-4 z-[1500]",children:e.jsx(HI,{onParcelFound:qe=>{sa(qe),Na(!1)},onClose:()=>Na(!1)})}),(fn||Tr)&&e.jsx("div",{className:fs("fixed z-[1000] bg-background shadow-xl transition-all duration-300",s?"inset-x-0 bottom-0 h-[85vh] rounded-t-xl border-t animate-in slide-in-from-bottom":"top-0 right-0 h-full w-[500px] border-l animate-in slide-in-from-right"),children:e.jsx(VI,{parcel:fn,isLoading:Tr,isAdmin:a,onClose:()=>{Xr(),sa(null)},onSelectDevelopment:Hi,onSelectExistingProduct:eo,onAddAsDevelopment:a?async qe=>{try{const Xt=qe.owner||"",js=qe.address||"",Rs=Xt&&js?`${Xt} - ${js}`:js||Xt||"New Development",{data:la}=await Fs.from("parcel_cache").select("id").eq("apn",qe.apn).maybeSingle(),{error:Bn}=await Fs.from("developments").insert([{name:Rs,lat:qe.clickedLat||0,lng:qe.clickedLng||0,type:"retail",status:"planned",units:0,parcel_id:(la==null?void 0:la.id)??null,description:`APN: ${qe.apn}
2603Owner: ${qe.owner}${qe.ownerAddress?`
2604${qe.ownerAddress}`:""}`,boundary:qe.geometry?{type:"Feature",geometry:qe.geometry,properties:{}}:null}]);if(Bn)throw Bn;Ve.success("Development created from parcel"),Xr()}catch(Xt){console.error(Xt),Ve.error("Failed to create development")}}:void 0,onAddAsExistingProduct:a?async qe=>{try{const Xt=qe.owner||"",js=qe.address||"",Rs=Xt&&js?`${Xt} - ${js}`:js||Xt||"New Existing Site",{data:la}=await Fs.from("parcel_cache").select("id").eq("apn",qe.apn).maybeSingle(),{error:Bn}=await Fs.from("existing_products").insert([{name:Rs,lat:qe.clickedLat||0,lng:qe.clickedLng||0,type:"retail",status:"completed",units:0,parcel_id:(la==null?void 0:la.id)??null,description:`APN: ${qe.apn}
2605Owner: ${qe.owner}${qe.ownerAddress?`
2606${qe.ownerAddress}`:""}`,boundary:qe.geometry?{type:"Feature",geometry:qe.geometry,properties:{}}:null}]);if(Bn)throw Bn;Ve.success("Existing Site created from parcel"),Xr()}catch(Xt){console.error(Xt),Ve.error("Failed to create existing site")}}:void 0,onCopyBoundaryToDevelopment:a&&(fn!=null&&fn.geometry)?async qe=>{try{const{error:Xt}=await Fs.from("developments").update({boundary:{type:"Feature",geometry:fn.geometry,properties:{}}}).eq("id",qe);if(Xt)throw Xt;Ve.success("Parcel boundary copied to development"),Xr()}catch(Xt){console.error(Xt),Ve.error("Failed to copy boundary")}}:void 0,onCopyBoundaryToExistingProduct:a&&(fn!=null&&fn.geometry)?async qe=>{try{const{error:Xt}=await Fs.from("existing_products").update({boundary:{type:"Feature",geometry:fn.geometry,properties:{}}}).eq("id",qe);if(Xt)throw Xt;Ve.success("Parcel boundary copied to existing site"),Xr()}catch(Xt){console.error(Xt),Ve.error("Failed to copy boundary")}}:void 0,onCopyToDrawings:fn!=null&&fn.geometry?async qe=>{try{const Xt=qe.address||qe.apn||"Parcel Polygon",js=qe.geometry;let Rs=qe.clickedLat||0,la=qe.clickedLng||0,Bn=qe.acres||null,Rr=qe.sqft||null;await Nr.mutateAsync({name:Xt,type:"polygon",geometry:js,layer_type:"property_outline",is_visible:!0,style:{color:"#8b5cf6",fillColor:"#8b5cf6",weight:2,fillOpacity:.2}
2606,description:`Copied from parcel: ${qe.apn}
2607Owner: ${qe.owner||"Unknown"}`,calculated_area_acres:Bn,calculated_area_sqft:Rr}),Ve.success(`Parcel copied to Drawings as "${Xt}"`),Xr(),sa(null)}catch(Xt){console.error("Failed to copy parcel to drawings:",Xt),Ve.error("Failed to copy parcel to drawings")}}:void 0,onCreateSiteLayout:a&&(fn!=null&&fn.geometry)?Gi:void 0,onViewOnMap:(qe,Xt)=>{var js;(js=Jt.current)==null||js.flyToLocation(qe,Xt,18)},developments:Kr,existingProducts:hi,isParcelsLayerVisible:Pn.parcels!==!1,onToggleParcelsLayer:()=>{const qe={...Pn,parcels:!0};Ks(qe),localStorage.setItem("map-layer-visibility",JSON.stringify(qe))},onRefreshFromAPI:fn!=null&&fn.clickedLat&&(fn!=null&&fn.clickedLng)?async()=>{await rn(fn.clickedLat,fn.clickedLng)}:void 0})})]})]}),s&&e.jsx(PG,{user:n,isAdmin:a,onSignOut:c,onShowAdminPanel:()=>Fe(!0),onShowUserDashboard:()=>en(),onShowSuggestionsPanel:()=>We(!0),onShowUserManagement:()=>ve(!0),onShowMapOverlays:()=>Ze(!0),onOpenAdminDashboardTab:qe=>en(qe),onShowEmbedCode:()=>de(!0),onShowRegionFilter:()=>Be(!0),onShowSidebar:()=>tn(!0),onShowSiteArchitectDashboard:()=>en()}),e.jsx(B0,{open:Is,onOpenChange:tn,children:e.jsx(m_,{side:"left",className:"w-80 p-0",children:e.jsx(em,{children:e.jsx(nk,{developments:Kr,existingProducts:hi,selectedDevelopment:I,selectedExistingProduct:F,onSelectDevelopment:qe=>{Hi(qe),tn(!1)},onSelectExistingProduct:qe=>{eo(qe),tn(!1)},filters:oe,onFiltersChange:ce,isLoading:Jd,isAdmin:a,onNavigateToProperty:(qe,Xt)=>{Wr(qe,Xt),tn(!1)},onViewOnMap:Tc,onToggleCrmVisibility:(qe,Xt,js,Rs)=>{Wl(qe,Xt,js,Rs),tn(!1)},visibleDeveloperIds:H,visibleOwnerIds:q,visibleTenantIds:Q,onNavigateToOverlay:qe=>{Cl(qe),tn(!1)},onEditOverlay:qe=>{Md(qe),tn(!1)},onOpenPolygonTools:qe=>{var Xt;Fn?(Yr(qe.id),xi(!0)):(Xt=Jt.current)==null||Xt.openPolygonTools(qe.id),tn(!1)},onSiteLayoutsModeChange:qe=>{ra(qe),qe?(Yr(null),xi(!0)):Ha(null),tn(!1)},activeSiteLayoutId:Ka,onShowSiteArchitectDashboard:()=>{en(),tn(!1)}})})})}),Si&&!X&&e.jsx("div",{className:fs("fixed z-[1050] bg-background shadow-lg border-l transition-all duration-300",s?"inset-x-0 bottom-0 h-[85vh] rounded-t-xl border-t":"right-0 w-[500px]"),style:s?void 0:{top:"100px",height:"calc(100vh - 100px)"},children:e.jsx(XI,{assemblage:Si,onClose:()=>zo(null),onLoad:qe=>{In.loadAssemblageParcels(qe),zo(null)},onCreateSiteLayout:qe=>{qe.combined_boundary&&Zr(qe.combined_boundary,qe.name)},isCreatingSiteLayout:ul,onZoomToBoundary:qe=>{if(qe&&Jt.current){const Xt=qe.type==="Polygon"?qe.coordinates[0]:qe.coordinates[0][0],js=Xt.map(Rr=>Rr[1]),Rs=Xt.map(Rr=>Rr[0]),la=(Math.min(...js)+Math.max(...js))/2,Bn=(Math.min(...Rs)+Math.max(...Rs))/2;Jt.current.flyToLocation(la,Bn,16)}}})}),(I||F||Si)&&X&&e.jsx("div",{className:"fixed right-0 top-1/2 -translate-y-1/2 z-[9999] bg-background border border-r-0 rounded-l-lg shadow-lg cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>K(!1),children:e.jsxs("div",{className:"p-2 flex flex-col items-center gap-2",children:[e.jsx(eS,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs font-medium writing-mode-vertical",style:{writingMode:"vertical-rl",textOrientation:"mixed"},children:I?I.name:F?F.name:Si==null?void 0:Si.name})]})}),e.jsx(em,{children:e.jsx(k.Suspense,{fallback:null,children:e.jsx($9,{open:ie,onClose:()=>de(!1)})})}),a&&e.jsx(em,{children:e.jsx(k.Suspense,{fallback:null,children:e.jsx(V9,{open:Ee,onClose:()=>ve(!1)})})}),a&&e.jsx(em,{children:e.jsx(k.Suspense,{fallback:null,children:e.jsx(q9,{open:we,onClose:()=>Ze(!1),onNavigateToOverlay:qe=>{Cl(qe),Ze(!1)},onEditOverlay:qe=>{Md(qe),Ze(!1)}})})}),e.jsx(em,{children:e.jsx(k.Suspense,{fallback:null,children:e.jsx(G9,{open:os,onClose:()=>Ls(!1),mapStyle:is,onMapStyleChange:Fl,boundaryLayers:an,onBoundaryLayerToggle:Lc,layerOpacity:Hs,onLayerOpacityChange:Kl,isAdmin:a})})}),e.jsx(em,{children:e.jsx(k.Suspense,{fallback:null,children:e.jsx(W9,{overlay:Rl,open:!!Rl,onClose:()=>Md(null)})})}),a&&e.jsx(em,{children:e.jsx(k.Suspense,{fallback:null,children:e.jsx(H9,{open:Re,onClose:()=>qt(!1)})})}),a&&e.jsx(em,{children:e.jsx(k.Suspense,{fallback:null,children:e.jsx(Z9,{open:vt,onClose:()=>Xe(!1)})})}),e.jsx(em,{children:e.jsx(k.Suspense,{fallback:null,children:e.jsx(Y9,{open:Ce,onClose:()=>Be(!1),developments:Kr,existingProducts:hi,isDrawingRegion:Nl,onStartDrawCircle:qe=>{lr(!0),ml("circle"),ti(qe||null),Be(!1)},onStartDrawPolygon:()=>{lr(!0),ml("polygon"),Be(!1)},onCancelDraw:()=>{lr(!1),ml(null)}
2607,drawnRegion:qs,onClearDrawnRegion:()=>Tn(null),activeRegionFilter:kr,onSetActiveRegionFilter:nr,customFieldFilters:Br,onCustomFieldFiltersChange:wl})})}),e.jsx(dd,{open:Dt,onOpenChange:Rt,children:e.jsx(ud,{className:"max-w-4xl p-0 bg-transparent border-0 shadow-none",children:e.jsx(I9,{onClose:()=>Rt(!1)})})}),e.jsx(O9,{open:_s,onOpenChange:vs,onNavigateToRecord:(qe,Xt)=>{if(Xt==="development"){const js=Kr.find(Rs=>Rs.id===qe);js&&(z(js),D(null))}else{const js=hi.find(Rs=>Rs.id===qe);js&&(D(js),z(null))}}}),e.jsx(WI,{open:Yi,onOpenChange:jl,stats:In.stats,onSave:(qe,Xt)=>{In.saveAssemblage({name:qe,description:Xt}),jl(!1)},isSaving:In.isSaving}),v&&e.jsx(B9,{open:$t,onOpenChange:Ns,onStartDrawing:qe=>{var Xt;(Xt=Jt.current)==null||Xt.startOverlayDrawing(qe)}}),e.jsx(F9,{open:Ts,onOpenChange:bs,onPinMetric:Ma,pinnedMetricIds:cc}),e.jsx(P9,{metrics:Sn,onClose:Di,onPositionChange:Al})]})]})]})):null},DH=Object.freeze(Object.defineProperty({__proto__:null,default:eH},Symbol.toStringTag,{value:"Module"}));export{zb as C,Zd as I,Mh as L,fd as P,uo as R,cN as W,MH as a,IH as b,AH as c,Cf as d,Wp as e,Zx as f,Af as g,rp as h,jS as i,KM as j,EH as k,PH as l,CN as m,pm as n,Lg as o,DH as p,OP as u};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.