@nice2dev/ui-buildings 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/dist/index.cjs +5 -0
- package/dist/index.d.ts +1191 -0
- package/dist/index.mjs +6959 -0
- package/dist/ui-buildings.css +1 -0
- package/package.json +88 -0
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @nice2dev/ui-buildings
|
|
2
|
+
|
|
3
|
+
> Building automation & unified spatial editor — floor plans, CAD, network topology, interior design, infrastructure, game scenes.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
### NiceSpatialEditor
|
|
8
|
+
|
|
9
|
+
One React component with 6 editing modes, replacing 5+ separate editors:
|
|
10
|
+
|
|
11
|
+
| Mode | Description |
|
|
12
|
+
|------|-------------|
|
|
13
|
+
| **floor-plan** | 2D floor plan for smart home / building automation |
|
|
14
|
+
| **network-topology** | Network topology overlay on floor plan or standalone |
|
|
15
|
+
| **infrastructure** | Data center, server racks, network closets |
|
|
16
|
+
| **cad** | 3D CAD mode — walls, floors, rooms, dimensions, DXF |
|
|
17
|
+
| **interior** | 3D interior design / Sims mode — furniture placement (140+ items) |
|
|
18
|
+
| **game-scene** | 2D/3D game scene editing — tilemap, terrain, objects |
|
|
19
|
+
|
|
20
|
+
### Common Features (all modes)
|
|
21
|
+
- Snap to grid — unified snap system (`useSnapToGrid` + spatial-core)
|
|
22
|
+
- Layers panel, object library sidebar
|
|
23
|
+
- Measurement tools (distance, area, angle)
|
|
24
|
+
- Undo/redo, multi-select, properties panel
|
|
25
|
+
- Minimap, zoom/pan (scroll + keyboard)
|
|
26
|
+
- Export — PNG, SVG, PDF, DXF, `.nsp.json`
|
|
27
|
+
|
|
28
|
+
### Dependencies
|
|
29
|
+
- [`@nice2dev/spatial-core`](../spatial-core/) — grid system, object catalog, floor-plan model, .nsp.json serialization
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install @nice2dev/ui-buildings @nice2dev/spatial-core
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
MIT © NiceToDev
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),U=require("@nice2dev/spatial-core"),ss=require("@nice2dev/ui"),ns="_root_5uamu_1",os="_dark_5uamu_27",as="_topBar_5uamu_41",cs="_floorTabs_5uamu_71",ls="_floorTab_5uamu_71",rs="_floorTabActive_5uamu_107",is="_overlayControls_5uamu_119",ds="_overlayBtn_5uamu_131",us="_overlayBtnActive_5uamu_163",hs="_zoomBar_5uamu_175",_s="_editorBody_5uamu_229",ps="_toolPalette_5uamu_243",ms="_toolBtn_5uamu_273",xs="_toolBtnActive_5uamu_309",fs="_canvasWrapper_5uamu_323",gs="_canvas_5uamu_323",ys="_cur_select_5uamu_359",vs="_cur_drawzone_5uamu_361",bs="_cur_drawwall_5uamu_363",js="_cur_placedevice_5uamu_365",ws="_cur_placedoor_5uamu_367",Ns="_cur_placewindow_5uamu_369",ks="_cur_pan_5uamu_371",Cs="_cur_erase_5uamu_373",Is="_cur_measure_5uamu_375",Ss="_cur_annotate_5uamu_377",Ls="_gridLine_5uamu_383",zs="_zoneGroup_5uamu_397",$s="_zonePath_5uamu_405",Bs="_zoneLabel_5uamu_413",Ts="_climateLabel_5uamu_431",Ps="_occupancyLabel_5uamu_443",Ms="_dimLabel_5uamu_455",Os="_deviceGroup_5uamu_467",As="_devCircle_5uamu_471",Es="_devOnline_5uamu_483",Ds="_devOffline_5uamu_485",Rs="_devSelected_5uamu_487",Ws="_propPanel_5uamu_499",Gs="_propTitle_5uamu_527",Fs="_propRow_5uamu_545",Vs="_statusBar_5uamu_581",Hs="_emptyState_5uamu_613",se={root:ns,dark:os,topBar:as,floorTabs:cs,floorTab:ls,floorTabActive:rs,overlayControls:is,overlayBtn:ds,overlayBtnActive:us,zoomBar:hs,editorBody:_s,toolPalette:ps,toolBtn:ms,toolBtnActive:xs,canvasWrapper:fs,canvas:gs,cur_select:ys,cur_drawzone:vs,cur_drawwall:bs,cur_placedevice:js,cur_placedoor:ws,cur_placewindow:Ns,cur_pan:ks,cur_erase:Cs,cur_measure:Is,cur_annotate:Ss,gridLine:Ls,zoneGroup:zs,zonePath:$s,zoneLabel:Bs,climateLabel:Ts,occupancyLabel:Ps,dimLabel:Ms,deviceGroup:Os,devCircle:As,devOnline:Es,devOffline:Ds,devSelected:Rs,propPanel:Ws,propTitle:Gs,propRow:Fs,statusBar:Vs,emptyState:Hs},Us={living_room:"#dbeafe",bedroom:"#fce7f3",master_bedroom:"#f3e8ff",kids_room:"#fef3c7",bathroom:"#cffafe",kitchen:"#fef9c3",dining_room:"#fde8d8",hallway:"#f1f5f9",office:"#dcfce7",garage:"#e2e8f0",basement:"#e5e7eb",attic:"#f0fdf4",balcony:"#ecfdf5",garden:"#d1fae5",gym:"#fee2e2",cinema:"#ede9fe",open_office:"#dcfce7",private_office:"#d1fae5",meeting_room:"#dbeafe",boardroom:"#ede9fe",reception:"#fef3c7",waiting_area:"#fef9c3",server_room:"#fee2e2",it_room:"#fde8d8",break_room:"#fce7f3",lobby:"#f0f4ff",corridor:"#f8fafc",stairwell:"#f1f5f9",parking:"#e2e8f0",mechanical_room:"#f3f4f6"};function Zs(t){return Us[t]??"#f0f4ff"}function St(t){if(!t.length)return{x:0,y:0};const s=t.reduce((a,o)=>({x:a.x+o.x,y:a.y+o.y}),{x:0,y:0});return{x:s.x/t.length,y:s.y/t.length}}function Lt(t,s=!0){return t.length<2?"":t.map((a,o)=>`${o===0?"M":"L"}${a.x.toFixed(1)},${a.y.toFixed(1)}`).join(" ")+(s?" Z":"")}function Ys(t,s,a){return a?{x:Math.round(t.x/s)*s,y:Math.round(t.y/s)*s}:t}function Ks(t,s){switch(s.t){case"TOOL":return{...t,tool:s.v,drawing:null,selected:null};case"FLOOR":return{...t,floorId:s.v,drawing:null,selected:null};case"SELECT":return{...t,selected:s.v};case"ZOOM":return{...t,zoom:Math.max(.15,Math.min(5,s.v))};case"PAN":return{...t,pan:s.v};case"DRAW_PT":return{...t,drawing:[...t.drawing??[],s.v]};case"DRAW_END":return{...t,drawing:null};case"TOGGLE":return s.v==="grid"?{...t,showGrid:!t.showGrid}:s.v==="dim"?{...t,showDim:!t.showDim}:s.v==="labels"?{...t,showLabels:!t.showLabels}:s.v==="occupancy"?{...t,showOccupancy:!t.showOccupancy}:{...t,showClimate:!t.showClimate};default:return t}}const Xs=[{tool:"select",icon:"↖",label:"Zaznaczenie"},{tool:"draw_zone",icon:"⬡",label:"Rysuj strefę"},{tool:"draw_wall",icon:"▬",label:"Rysuj ścianę"},{tool:"place_device",icon:"📡",label:"Urządzenie"},{tool:"place_door",icon:"🚪",label:"Drzwi"},{tool:"place_window",icon:"🪟",label:"Okno"},{tool:"annotate",icon:"✏",label:"Adnotacja"},{tool:"measure",icon:"📏",label:"Miarka"},{tool:"erase",icon:"🗑",label:"Usuń"},{tool:"pan",icon:"✋",label:"Przesuń"}],Js={light:"💡",dimmer:"🔆",rgb_light:"🌈",led_strip:"〰",thermostat:"🌡",air_conditioner:"❄",fan:"💨",heat_pump:"♨",lock:"🔒",door:"🚪",window:"🪟",blind:"▦",camera:"📷",doorbell:"🔔",alarm:"🚨",motion_sensor:"👁",smoke_detector:"🔴",temperature_sensor:"🌡",humidity_sensor:"💧",switch:"🔌",outlet:"🔌",speaker:"🔈",tv:"📺",vacuum:"🤖",ev_charger:"⚡",solar_panel:"☀",energy_meter:"⚡",hub:"📡",router:"📡"},qs=({floors:t,devices:s=[],onFloorChange:a,onDeviceMove:o,readOnly:n=!1,initialFloorId:c,showDevices:d=!0,showDimensions:f=!1,showGrid:y=!0,showOccupancy:v=!1,showClimate:u=!0,className:N,style:b,theme:g="light"})=>{var oe,Z;const p=l.useRef(null),x=l.useRef(!1),j=l.useRef({x:0,y:0}),[r,L]=l.useReducer(Ks,{floorId:c??((oe=t[0])==null?void 0:oe.id)??"",tool:"select",selected:null,zoom:1,pan:{x:0,y:0},drawing:null,showGrid:y,showDim:f,showLabels:!0,showOccupancy:v,showClimate:u,snapGrid:!0,gridSize:20}),h=t.find(k=>k.id===r.floorId)??t[0],C=l.useCallback(k=>{var re;const F=(re=p.current)==null?void 0:re.getBoundingClientRect();return F?{x:(k.clientX-F.left-r.pan.x)/r.zoom,y:(k.clientY-F.top-r.pan.y)/r.zoom}:{x:0,y:0}},[r.pan,r.zoom]),w=l.useCallback(k=>{r.tool==="pan"&&(x.current=!0,j.current={x:k.clientX,y:k.clientY})},[r.tool]),i=l.useCallback(k=>{x.current&&(L({t:"PAN",v:{x:r.pan.x+k.clientX-j.current.x,y:r.pan.y+k.clientY-j.current.y}}),j.current={x:k.clientX,y:k.clientY})},[r.pan]),$=l.useCallback(()=>{x.current=!1},[]),E=l.useCallback(k=>{if(r.tool==="draw_zone"){const F=Ys(C(k),r.gridSize,r.snapGrid);L({t:"DRAW_PT",v:F})}else r.tool==="select"&&L({t:"SELECT",v:null})},[r.tool,r.gridSize,r.snapGrid,C]),H=l.useCallback(k=>{if(r.tool==="draw_zone"&&r.drawing&&r.drawing.length>=3&&a&&h){const F={id:`zone-${Date.now()}`,name:"Nowa strefa",type:"other",floorId:h.id,polygon:[...r.drawing]};a(t.map(re=>re.id===h.id?{...h,zones:[...h.zones,F]}:re)),L({t:"DRAW_END"})}},[r.tool,r.drawing,h,t,a]),G=l.useCallback(k=>{k.preventDefault(),L({t:"ZOOM",v:r.zoom*(k.deltaY>0?.9:1.1)})},[r.zoom]),me=l.useCallback((k,F)=>{k.stopPropagation(),r.tool==="select"?L({t:"SELECT",v:{type:"zone",id:F.id}}):r.tool==="erase"&&!n&&a&&h&&a(t.map(re=>re.id===h.id?{...h,zones:h.zones.filter(je=>je.id!==F.id)}:re))},[r.tool,n,h,t,a]);if(!h)return e.jsx("div",{className:se.emptyState,children:"Brak kondygnacji."});const Q=((Z=r.selected)==null?void 0:Z.type)==="zone"?h.zones.find(k=>{var F;return k.id===((F=r.selected)==null?void 0:F.id)}):null,ve=d?s.filter(k=>h.zones.some(F=>F.id===k.zoneId)||k.floorPlanPosition):[],be=[{key:"grid",icon:"⊞",active:r.showGrid},{key:"dim",icon:"↔",active:r.showDim},{key:"labels",icon:"🏷",active:r.showLabels},{key:"occupancy",icon:"👥",active:r.showOccupancy},{key:"climate",icon:"🌡",active:r.showClimate}];return e.jsxs("div",{className:`${se.root} ${g==="dark"?se.dark:""} ${N??""}`,style:b,children:[e.jsxs("div",{className:se.topBar,children:[e.jsx("div",{className:se.floorTabs,children:[...t].sort((k,F)=>k.level-F.level).map(k=>e.jsx("button",{className:`${se.floorTab} ${r.floorId===k.id?se.floorTabActive:""}`,onClick:()=>L({t:"FLOOR",v:k.id}),children:k.name},k.id))}),e.jsx("div",{className:se.overlayControls,children:be.map(k=>e.jsx("button",{title:k.key,className:`${se.overlayBtn} ${k.active?se.overlayBtnActive:""}`,onClick:()=>L({t:"TOGGLE",v:k.key}),children:k.icon},k.key))}),e.jsxs("div",{className:se.zoomBar,children:[e.jsx("button",{onClick:()=>L({t:"ZOOM",v:r.zoom*1.2}),children:"+"}),e.jsxs("span",{children:[Math.round(r.zoom*100),"%"]}),e.jsx("button",{onClick:()=>L({t:"ZOOM",v:r.zoom*.8}),children:"−"}),e.jsx("button",{title:"Resetuj widok",onClick:()=>{L({t:"ZOOM",v:1}),L({t:"PAN",v:{x:0,y:0}})},children:"⊡"})]})]}),e.jsxs("div",{className:se.editorBody,children:[!n&&e.jsx("div",{className:se.toolPalette,children:Xs.map(({tool:k,icon:F,label:re})=>e.jsx("button",{title:re,className:`${se.toolBtn} ${r.tool===k?se.toolBtnActive:""}`,onClick:()=>L({t:"TOOL",v:k}),children:F},k))}),e.jsx("div",{className:se.canvasWrapper,children:e.jsxs("svg",{ref:p,className:`${se.canvas} ${se[`cur_${r.tool.replace("_","")}`]??""}`,onMouseDown:w,onMouseMove:i,onMouseUp:$,onClick:E,onDoubleClick:H,onWheel:G,children:[h.backgroundImage&&e.jsx("image",{href:h.backgroundImage,x:r.pan.x,y:r.pan.y,width:h.width*r.zoom,height:h.height*r.zoom,preserveAspectRatio:"xMidYMid meet",opacity:.35}),e.jsxs("g",{transform:`translate(${r.pan.x},${r.pan.y}) scale(${r.zoom})`,children:[r.showGrid&&(()=>{const k=[];for(let F=0;F<=h.width;F+=r.gridSize)k.push(e.jsx("line",{x1:F,y1:0,x2:F,y2:h.height,className:se.gridLine},`v${F}`));for(let F=0;F<=h.height;F+=r.gridSize)k.push(e.jsx("line",{x1:0,y1:F,x2:h.width,y2:F,className:se.gridLine},`h${F}`));return e.jsx("g",{children:k})})(),h.zones.map(k=>{var ke;const F=((ke=r.selected)==null?void 0:ke.id)===k.id,re=St(k.polygon),je=k.color??Zs(k.type);return e.jsxs("g",{className:se.zoneGroup,onClick:xe=>me(xe,k),children:[e.jsx("path",{d:Lt(k.polygon),fill:je,fillOpacity:k.opacity??.55,stroke:F?"#2563eb":"#94a3b8",strokeWidth:F?2.5:1.5,className:se.zonePath}),r.showLabels&&e.jsx("text",{x:re.x,y:re.y,textAnchor:"middle",dominantBaseline:"middle",className:se.zoneLabel,children:k.name}),r.showClimate&&k.temperature!=null&&e.jsxs("text",{x:re.x,y:re.y+14,textAnchor:"middle",className:se.climateLabel,children:[k.temperature.toFixed(1),"°C"," ",k.humidity!=null?`· ${k.humidity}%`:""]}),r.showOccupancy&&k.occupancy!=null&&e.jsxs("text",{x:re.x,y:re.y+26,textAnchor:"middle",className:se.occupancyLabel,children:["👥 ",k.occupancy]}),r.showDim&&k.polygon.length>1&&k.polygon.map((xe,Te)=>{const Se=k.polygon[(Te+1)%k.polygon.length],De=(xe.x+Se.x)/2,Ye=(xe.y+Se.y)/2,Re=Math.sqrt((Se.x-xe.x)**2+(Se.y-xe.y)**2),Le=h.scale??0;return e.jsx("text",{x:De,y:Ye-4,textAnchor:"middle",className:se.dimLabel,children:Le>0?`${(Re/Le).toFixed(1)}m`:`${Re.toFixed(0)}px`},Te)})]},k.id)}),ve.map(k=>{var ke;const F=h.zones.find(xe=>xe.id===k.zoneId),re=k.floorPlanPosition??(F?St(F.polygon):null);if(!re)return null;const je=((ke=r.selected)==null?void 0:ke.id)===k.id;return e.jsxs("g",{transform:`translate(${re.x},${re.y})`,className:se.deviceGroup,onClick:xe=>{xe.stopPropagation(),L({t:"SELECT",v:{type:"device",id:k.id}})},children:[e.jsx("circle",{r:14,className:`${se.devCircle} ${k.status==="online"?se.devOnline:se.devOffline} ${je?se.devSelected:""}`}),e.jsx("text",{y:5,textAnchor:"middle",fontSize:12,children:Js[k.type]??"📟"})]},k.id)}),r.drawing&&r.drawing.length>0&&e.jsxs("g",{children:[e.jsx("path",{d:Lt(r.drawing,!1),fill:"none",stroke:"#2563eb",strokeWidth:2,strokeDasharray:"6,3"}),r.drawing.map((k,F)=>e.jsx("circle",{cx:k.x,cy:k.y,r:4,fill:"#2563eb"},F))]})]})]})}),Q&&e.jsxs("div",{className:se.propPanel,children:[e.jsx("div",{className:se.propTitle,children:Q.name}),e.jsxs("div",{className:se.propRow,children:[e.jsx("span",{children:"Typ"}),e.jsx("span",{children:Q.type})]}),Q.area!=null&&e.jsxs("div",{className:se.propRow,children:[e.jsx("span",{children:"Pow."}),e.jsxs("span",{children:[Q.area," m²"]})]}),Q.temperature!=null&&e.jsxs("div",{className:se.propRow,children:[e.jsx("span",{children:"Temp."}),e.jsxs("span",{children:[Q.temperature.toFixed(1)," °C"]})]}),Q.humidity!=null&&e.jsxs("div",{className:se.propRow,children:[e.jsx("span",{children:"Wilgotność"}),e.jsxs("span",{children:[Q.humidity," %"]})]}),Q.co2!=null&&e.jsxs("div",{className:se.propRow,children:[e.jsx("span",{children:"CO₂"}),e.jsxs("span",{children:[Q.co2," ppm"]})]}),Q.occupancy!=null&&e.jsxs("div",{className:se.propRow,children:[e.jsx("span",{children:"Obecność"}),e.jsxs("span",{children:[Q.occupancy," os."]})]})]})]}),e.jsxs("div",{className:se.statusBar,children:[r.tool==="draw_zone"?"Klikaj punkty, dwa kliknięcia by zamknąć strefę.":r.selected?`Zaznaczono: ${r.selected.type} #${r.selected.id}`:`${h.name} — ${h.zones.length} strefa(y)`,r.tool==="draw_zone"&&r.drawing&&` (${r.drawing.length} pkt)`]})]})},Qs="_overlay_1vdhp_9",en="_dialog_1vdhp_55",tn="_header_1vdhp_103",sn="_title_1vdhp_119",nn="_closeButton_1vdhp_133",on="_content_1vdhp_163",an="_preview_1vdhp_179",cn="_previewCanvas_1vdhp_199",ln="_previewSvg_1vdhp_217",rn="_info_1vdhp_227",dn="_section_1vdhp_237",un="_sectionTitle_1vdhp_245",hn="_statGrid_1vdhp_265",_n="_stat_1vdhp_265",pn="_statLabel_1vdhp_289",mn="_statValue_1vdhp_301",xn="_warningsList_1vdhp_313",fn="_warning_1vdhp_313",gn="_warningIcon_1vdhp_357",yn="_error_1vdhp_367",vn="_errorIcon_1vdhp_399",bn="_footer_1vdhp_409",jn="_cancelButton_1vdhp_429",wn="_confirmButton_1vdhp_461",Nn="_noWarnings_1vdhp_503",kn="_layersList_1vdhp_515",Cn="_layer_1vdhp_515",In="_layerIcon_1vdhp_557",Sn="_layerName_1vdhp_565",Ln="_layerCount_1vdhp_575",W={overlay:Qs,dialog:en,header:tn,title:sn,closeButton:nn,content:on,preview:an,previewCanvas:cn,previewSvg:ln,info:rn,section:dn,sectionTitle:un,statGrid:hn,stat:_n,statLabel:pn,statValue:mn,warningsList:xn,warning:fn,warningIcon:gn,error:yn,errorIcon:vn,footer:bn,cancelButton:jn,confirmButton:wn,noWarnings:Nn,layersList:kn,layer:Cn,layerIcon:In,layerName:Sn,layerCount:Ln},zn=()=>e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),zt=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"currentColor",children:e.jsx("path",{d:"M7 0a7 7 0 1 0 0 14A7 7 0 0 0 7 0zm0 12.5a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5zm.75-3.25a.75.75 0 0 1-1.5 0v-4a.75.75 0 0 1 1.5 0v4z"})}),$t=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"currentColor",children:e.jsx("path",{d:"M7 0a7 7 0 1 0 0 14A7 7 0 0 0 7 0zm2.8 9.15a.5.5 0 0 1-.65.65L7 8.45l-2.15 1.35a.5.5 0 0 1-.65-.65L5.55 7 4.2 4.85a.5.5 0 0 1 .65-.65L7 5.55l2.15-1.35a.5.5 0 0 1 .65.65L8.45 7l1.35 2.15z"})}),Bt=()=>e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",children:e.jsx("path",{d:"M6 0L0 3l6 3 6-3-6-3zM0 6l6 3 6-3M0 9l6 3 6-3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})}),$n=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"currentColor",children:e.jsx("path",{d:"M2 12h2V5H2v7zm4 0h2V2H6v10zm4 0h2V7h-2v5z"})});function Bn({result:t,onConfirm:s,onCancel:a}){const o=t.document,n=l.useMemo(()=>{var L,h;if(!((L=o==null?void 0:o.floors)!=null&&L.length))return null;const u=o.floors[0],N=(u==null?void 0:u.layers)||[],b=N.flatMap(C=>C.objects);let g=1/0,p=1/0,x=-1/0,j=-1/0;for(const C of b)C.bounds?(g=Math.min(g,C.bounds.x),p=Math.min(p,C.bounds.y),x=Math.max(x,C.bounds.x+C.bounds.width),j=Math.max(j,C.bounds.y+C.bounds.height)):(h=C.transform)!=null&&h.position&&(g=Math.min(g,C.transform.position.x),p=Math.min(p,C.transform.position.y),x=Math.max(x,C.transform.position.x),j=Math.max(j,C.transform.position.y));isFinite(g)||(u!=null&&u.bounds?(g=u.bounds.x,p=u.bounds.y,x=u.bounds.x+u.bounds.width,j=u.bounds.y+u.bounds.height):(g=0,p=0,x=1e3,j=800));const r=20;return{viewBox:{x:g-r,y:p-r,width:x-g+r*2,height:j-p+r*2},objects:b,layers:N}},[o]),c=l.useMemo(()=>{if(!n||!o)return null;const{viewBox:u,objects:N}=n,b=[],g=50,p=`
|
|
2
|
+
<pattern id="grid" width="${g}" height="${g}" patternUnits="userSpaceOnUse">
|
|
3
|
+
<path d="M ${g} 0 L 0 0 0 ${g}" fill="none" stroke="#e2e8f0" strokeWidth="0.5"/>
|
|
4
|
+
</pattern>
|
|
5
|
+
`;return N.forEach((x,j)=>{if(x.type==="wall"&&x.bounds)b.push(e.jsx("rect",{x:x.bounds.x,y:x.bounds.y,width:x.bounds.width,height:x.bounds.height,fill:"#475569",stroke:"#334155",strokeWidth:"1"},`wall-${j}`));else if(x.type==="zone"&&x.boundary){const L=x.boundary.map((h,C)=>`${C===0?"M":"L"} ${h.x} ${h.y}`).join(" ")+" Z";b.push(e.jsx("path",{d:L,fill:"rgba(59, 130, 246, 0.2)",stroke:"#3b82f6",strokeWidth:"1"},`zone-${j}`))}else if(x.type==="room"&&x.boundary){const L=x.boundary.map((h,C)=>`${C===0?"M":"L"} ${h.x} ${h.y}`).join(" ")+" Z";b.push(e.jsx("path",{d:L,fill:"rgba(34, 197, 94, 0.15)",stroke:"#22c55e",strokeWidth:"1"},`room-${j}`))}else x.bounds&&b.push(e.jsx("rect",{x:x.bounds.x,y:x.bounds.y,width:x.bounds.width,height:x.bounds.height,fill:"rgba(99, 102, 241, 0.3)",stroke:"#6366f1",strokeWidth:"0.5",rx:"2"},`obj-${j}`))}),e.jsxs("svg",{viewBox:`${u.x} ${u.y} ${u.width} ${u.height}`,className:W.previewSvg,preserveAspectRatio:"xMidYMid meet",children:[e.jsx("defs",{dangerouslySetInnerHTML:{__html:p}}),e.jsx("rect",{x:u.x,y:u.y,width:u.width,height:u.height,fill:"url(#grid)"}),b]})},[n,o]),d=l.useCallback(u=>{u.key==="Escape"&&a()},[a]),f=l.useCallback(u=>{u.target===u.currentTarget&&a()},[a]),y=t.errors.some(u=>u.fatal),v=t.errors.filter(u=>!u.fatal);return e.jsx("div",{className:W.overlay,onClick:f,onKeyDown:d,tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":"import-preview-title",children:e.jsxs("div",{className:W.dialog,children:[e.jsxs("div",{className:W.header,children:[e.jsx("h2",{id:"import-preview-title",className:W.title,children:"Import Preview"}),e.jsx("button",{className:W.closeButton,onClick:a,title:"Close","aria-label":"Close dialog",children:e.jsx(zn,{})})]}),e.jsxs("div",{className:W.content,children:[e.jsx("div",{className:W.preview,children:c||e.jsx("div",{className:W.previewCanvas,children:"No preview available"})}),e.jsxs("div",{className:W.info,children:[e.jsxs("div",{className:W.section,children:[e.jsxs("h3",{className:W.sectionTitle,children:[e.jsx($n,{})," Import Statistics"]}),e.jsxs("div",{className:W.statGrid,children:[e.jsxs("div",{className:W.stat,children:[e.jsx("div",{className:W.statLabel,children:"Walls"}),e.jsx("div",{className:W.statValue,children:t.stats.wallsImported})]}),e.jsxs("div",{className:W.stat,children:[e.jsx("div",{className:W.statLabel,children:"Zones"}),e.jsx("div",{className:W.statValue,children:t.stats.zonesImported})]}),e.jsxs("div",{className:W.stat,children:[e.jsx("div",{className:W.statLabel,children:"Objects"}),e.jsx("div",{className:W.statValue,children:t.stats.objectsImported})]}),e.jsxs("div",{className:W.stat,children:[e.jsx("div",{className:W.statLabel,children:"Skipped"}),e.jsx("div",{className:W.statValue,children:t.stats.entitiesSkipped})]})]})]}),n&&n.layers.length>0&&e.jsxs("div",{className:W.section,children:[e.jsxs("h3",{className:W.sectionTitle,children:[e.jsx(Bt,{})," Layers (",n.layers.length,")"]}),e.jsxs("ul",{className:W.layersList,children:[n.layers.slice(0,6).map((u,N)=>{var b;return e.jsxs("li",{className:W.layer,children:[e.jsx("span",{className:W.layerIcon,children:e.jsx(Bt,{})}),e.jsx("span",{className:W.layerName,children:u.name}),e.jsx("span",{className:W.layerCount,children:((b=u.objects)==null?void 0:b.length)||0})]},u.id||N)}),n.layers.length>6&&e.jsx("li",{className:W.layer,children:e.jsxs("span",{className:W.layerName,children:["+",n.layers.length-6," more..."]})})]})]}),t.warnings.length>0&&e.jsxs("div",{className:W.section,children:[e.jsxs("h3",{className:W.sectionTitle,children:[e.jsx(zt,{})," Warnings (",t.warnings.length,")"]}),e.jsxs("ul",{className:W.warningsList,children:[t.warnings.slice(0,5).map((u,N)=>e.jsxs("li",{className:W.warning,children:[e.jsx("span",{className:W.warningIcon,children:e.jsx(zt,{})}),e.jsx("span",{children:u.message})]},N)),t.warnings.length>5&&e.jsxs("li",{className:W.warning,children:["+",t.warnings.length-5," more warnings..."]})]})]}),v.length>0&&e.jsxs("div",{className:W.section,children:[e.jsxs("h3",{className:W.sectionTitle,children:[e.jsx($t,{})," Errors (",v.length,")"]}),e.jsx("ul",{className:W.warningsList,children:v.slice(0,5).map((u,N)=>e.jsxs("li",{className:W.error,children:[e.jsx("span",{className:W.errorIcon,children:e.jsx($t,{})}),e.jsx("span",{children:u.message})]},N))})]}),t.warnings.length===0&&v.length===0&&e.jsx("div",{className:W.section,children:e.jsx("p",{className:W.noWarnings,children:"✓ No warnings or errors found"})})]})]}),e.jsxs("div",{className:W.footer,children:[e.jsx("button",{className:W.cancelButton,onClick:a,children:"Cancel"}),e.jsx("button",{className:W.confirmButton,onClick:s,disabled:y,children:y?"Cannot Import (Fatal Errors)":"Confirm Import"})]})]})})}const Tn="_overlay_r24gy_9",Pn="_dialog_r24gy_55",Mn="_header_r24gy_103",On="_title_r24gy_119",An="_closeButton_r24gy_133",En="_content_r24gy_163",Dn="_description_r24gy_175",Rn="_mappingTable_r24gy_187",Wn="_sourceLayer_r24gy_237",Gn="_layerIcon_r24gy_249",Fn="_layerName_r24gy_257",Vn="_objectCount_r24gy_269",Hn="_targetSelect_r24gy_281",Un="_skipOption_r24gy_323",Zn="_arrowIcon_r24gy_333",Yn="_presets_r24gy_343",Kn="_presetButton_r24gy_357",Xn="_footer_r24gy_389",Jn="_footerLeft_r24gy_409",qn="_checkbox_r24gy_421",Qn="_checkboxLabel_r24gy_433",eo="_footerRight_r24gy_443",to="_cancelButton_r24gy_453",so="_confirmButton_r24gy_485",ae={overlay:Tn,dialog:Pn,header:Mn,title:On,closeButton:An,content:En,description:Dn,mappingTable:Rn,sourceLayer:Wn,layerIcon:Gn,layerName:Fn,objectCount:Vn,targetSelect:Hn,skipOption:Un,arrowIcon:Zn,presets:Yn,presetButton:Kn,footer:Xn,footerLeft:Jn,checkbox:qn,checkboxLabel:Qn,footerRight:eo,cancelButton:to,confirmButton:so},Tt=()=>e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),no=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.2",children:e.jsx("path",{d:"M7 1L1 4l6 3 6-3-6-3zM1 7l6 3 6-3M1 10l6 3 6-3"})}),oo=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M4 8h8M9 5l3 3-3 3",strokeLinecap:"round",strokeLinejoin:"round"})}),Pt={"floor-plan":"Plan piętra",walls:"Ściany",rooms:"Pomieszczenia",zones:"Strefy","doors-windows":"Drzwi i okna",furniture:"Meble",devices:"Urządzenia",network:"Sieć",infrastructure:"Infrastruktura",electrical:"Elektryka",plumbing:"Hydraulika",hvac:"HVAC",annotations:"Adnotacje",dimensions:"Wymiary",grid:"Siatka",background:"Tło","game-objects":"Obiekty gry",collision:"Kolizje",custom:"Własne"};function ao(t){if(!t.document)return[];const s=[];for(const a of t.document.floors)for(const o of a.layers)s.push({id:o.id,name:o.name,type:o.type,objectCount:o.objects.length});return s}function co(t){if(!t)return[];const s=[];for(const a of t.floors)for(const o of a.layers)s.find(n=>n.id===o.id)||s.push(o);return s}function Mt(t,s){const a=new Map;for(const o of t){const n=s.find(f=>f.type===o.type);if(n){a.set(o.id,n.id);continue}const c=o.name.toLowerCase(),d=s.find(f=>f.name.toLowerCase()===c);if(d){a.set(o.id,d.id);continue}a.set(o.id,o.id)}return a}const lo=({importResult:t,existingDocument:s,onConfirm:a,onCancel:o})=>{const n=l.useMemo(()=>ao(t),[t]),c=l.useMemo(()=>co(s),[s]),[d,f]=l.useState(()=>Mt(n,c)),[y,v]=l.useState(!0),u=l.useCallback((x,j)=>{f(r=>{const L=new Map(r);return L.set(x,j),L})},[]),N=l.useCallback(x=>{const j=new Map;switch(x){case"auto":f(Mt(n,c));return;case"skip-all":for(const r of n)j.set(r.id,"skip");break;case"preserve":for(const r of n)j.set(r.id,r.id);break}f(j)},[n,c]),b=l.useCallback(()=>{a(d,y)},[d,y,a]),g=l.useCallback(x=>{x.key==="Escape"?o():x.key==="Enter"&&(x.ctrlKey||x.metaKey)&&b()},[o,b]),p=l.useCallback(x=>{x.target===x.currentTarget&&o()},[o]);return n.length===0?e.jsx("div",{className:ae.overlay,onClick:p,onKeyDown:g,tabIndex:-1,children:e.jsxs("div",{className:ae.dialog,children:[e.jsxs("div",{className:ae.header,children:[e.jsx("h2",{className:ae.title,children:"Mapowanie warstw"}),e.jsx("button",{className:ae.closeButton,onClick:o,children:e.jsx(Tt,{})})]}),e.jsx("div",{className:ae.content,children:e.jsx("p",{className:ae.description,children:"Importowany plik nie zawiera żadnych warstw."})}),e.jsxs("div",{className:ae.footer,children:[e.jsx("div",{className:ae.footerLeft}),e.jsx("div",{className:ae.footerRight,children:e.jsx("button",{className:ae.cancelButton,onClick:o,children:"Zamknij"})})]})]})}):e.jsx("div",{className:ae.overlay,onClick:p,onKeyDown:g,tabIndex:-1,children:e.jsxs("div",{className:ae.dialog,children:[e.jsxs("div",{className:ae.header,children:[e.jsx("h2",{className:ae.title,children:"Mapowanie warstw"}),e.jsx("button",{className:ae.closeButton,onClick:o,children:e.jsx(Tt,{})})]}),e.jsxs("div",{className:ae.content,children:[e.jsx("p",{className:ae.description,children:"Wybierz jak warstwy z importowanego pliku mają być przypisane do warstw w edytorze."}),e.jsxs("table",{className:ae.mappingTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Warstwa źródłowa"}),e.jsx("th",{}),e.jsx("th",{children:"Warstwa docelowa"})]})}),e.jsx("tbody",{children:n.map(x=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("div",{className:ae.sourceLayer,children:[e.jsx("span",{className:ae.layerIcon,children:e.jsx(no,{})}),e.jsx("span",{className:ae.layerName,children:x.name}),e.jsxs("span",{className:ae.objectCount,children:["(",x.objectCount," ",x.objectCount===1?"obiekt":"obiektów",")"]})]})}),e.jsx("td",{className:ae.arrowIcon,children:e.jsx(oo,{})}),e.jsx("td",{children:e.jsxs("select",{className:ae.targetSelect,value:d.get(x.id)||x.id,onChange:j=>u(x.id,j.target.value),children:[e.jsx("option",{value:"skip",className:ae.skipOption,children:"— Pomiń tę warstwę —"}),e.jsxs("option",{value:x.id,children:["Utwórz: ",x.name," (",Pt[x.type],")"]}),c.map(j=>e.jsxs("option",{value:j.id,children:[j.name," (",Pt[j.type],")"]},j.id))]})})]},x.id))})]}),e.jsxs("div",{className:ae.presets,children:[e.jsx("button",{className:ae.presetButton,onClick:()=>N("auto"),children:"Auto-mapowanie"}),e.jsx("button",{className:ae.presetButton,onClick:()=>N("preserve"),children:"Zachowaj wszystkie"}),e.jsx("button",{className:ae.presetButton,onClick:()=>N("skip-all"),children:"Pomiń wszystkie"})]})]}),e.jsxs("div",{className:ae.footer,children:[e.jsxs("div",{className:ae.footerLeft,children:[e.jsx("input",{type:"checkbox",id:"createMissing",className:ae.checkbox,checked:y,onChange:x=>v(x.target.checked)}),e.jsx("label",{htmlFor:"createMissing",className:ae.checkboxLabel,children:"Utwórz brakujące warstwy"})]}),e.jsxs("div",{className:ae.footerRight,children:[e.jsx("button",{className:ae.cancelButton,onClick:o,children:"Anuluj"}),e.jsx("button",{className:ae.confirmButton,onClick:b,children:"Zastosuj mapowanie"})]})]})]})})},ro="_root_cknl0_9",io="_header_cknl0_21",uo="_title_cknl0_31",ho="_layerList_cknl0_45",_o="_layerItem_cknl0_55",po="_hidden_cknl0_83",mo="_locked_cknl0_91",xo="_visibilityBtn_cknl0_99",fo="_lockBtn_cknl0_101",go="_layerIcon_cknl0_139",yo="_layerName_cknl0_147",vo="_opacitySlider_cknl0_157",Ne={root:ro,header:io,title:uo,layerList:ho,layerItem:_o,hidden:po,locked:mo,visibilityBtn:xo,lockBtn:fo,layerIcon:go,layerName:yo,opacitySlider:vo},bo={"floor-plan":{icon:"🏠",label:"Floor Plan"},zones:{icon:"⬡",label:"Zones"},devices:{icon:"📡",label:"Devices"},furniture:{icon:"🛋️",label:"Furniture"},network:{icon:"🌐",label:"Network"},infrastructure:{icon:"⚙️",label:"Infrastructure"},annotations:{icon:"📝",label:"Annotations"},dimensions:{icon:"↔",label:"Dimensions"},grid:{icon:"⊞",label:"Grid"},background:{icon:"🖼️",label:"Background"},"game-objects":{icon:"🎮",label:"Game Objects"},collision:{icon:"⬜",label:"Collision"}},Zt=({layers:t,onVisibilityToggle:s,onLockToggle:a,onOpacityChange:o,className:n})=>{const c=[...t].sort((d,f)=>f.zIndex-d.zIndex);return e.jsxs("div",{className:`${Ne.root} ${n??""}`,children:[e.jsx("div",{className:Ne.header,children:e.jsx("h3",{className:Ne.title,children:"Layers"})}),e.jsx("div",{className:Ne.layerList,children:c.map(d=>{const f=bo[d.type]||{icon:"📦",label:d.type};return e.jsxs("div",{className:`${Ne.layerItem} ${d.visible?"":Ne.hidden} ${d.locked?Ne.locked:""}`,children:[e.jsx("button",{className:Ne.visibilityBtn,onClick:()=>s(d.type),title:d.visible?"Hide layer":"Show layer",children:d.visible?"👁":"👁🗨"}),e.jsx("button",{className:Ne.lockBtn,onClick:()=>a(d.type),title:d.locked?"Unlock layer":"Lock layer",children:d.locked?"🔒":"🔓"}),e.jsx("span",{className:Ne.layerIcon,children:f.icon}),e.jsx("span",{className:Ne.layerName,children:f.label}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:d.opacity,onChange:y=>o(d.type,parseFloat(y.target.value)),className:Ne.opacitySlider,title:`Opacity: ${Math.round(d.opacity*100)}%`})]},d.type)})})]})},jo="_root_jk21s_9",wo="_svg_jk21s_31",No="_viewportRect_jk21s_41",ko="_zoomIndicator_jk21s_49",nt={root:jo,svg:wo,viewportRect:No,zoomIndicator:ko},Yt=({document:t,activeFloorId:s,viewport:a,onViewportChange:o,size:n=150,className:c})=>{var h,C;const d=l.useRef(null),f=l.useMemo(()=>t.floors.find(w=>w.id===s)??t.floors[0]??null,[t,s]);if(!f)return null;const y=((h=f.dimensions)==null?void 0:h.width)??1e3,v=((C=f.dimensions)==null?void 0:C.height)??800,u=Math.min(n/y,n/v)*.9,N=y*u,b=v*u,g=n/a.zoom*u,p=n/a.zoom*u,x=-a.pan.x/a.zoom*u,j=-a.pan.y/a.zoom*u,r=l.useCallback(w=>{var me;const i=(me=d.current)==null?void 0:me.getBoundingClientRect();if(!i)return;const $=(w.clientX-i.left-(n-N)/2)/u,E=(w.clientY-i.top-(n-b)/2)/u,H=-($-n/a.zoom/2)*a.zoom,G=-(E-n/a.zoom/2)*a.zoom;o({pan:{x:H,y:G}})},[u,n,N,b,a.zoom,o]),L=l.useMemo(()=>{const w=f.layers.find(i=>i.name==="zones");return w?w.objects.map(i=>{const $=i;if(!$.polygon||$.polygon.length<3)return null;const E=$.polygon.map((H,G)=>`${G===0?"M":"L"}${H.x*u},${H.y*u}`).join(" ")+" Z";return e.jsx("path",{d:E,fill:$.color??"#dbeafe",fillOpacity:.6,stroke:"#94a3b8",strokeWidth:.5},$.id)}):null},[f,u]);return e.jsxs("div",{className:`${nt.root} ${c??""}`,children:[e.jsxs("svg",{ref:d,width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:nt.svg,onClick:r,children:[e.jsx("rect",{x:(n-N)/2,y:(n-b)/2,width:N,height:b,fill:"#1e293b",stroke:"#475569",strokeWidth:1}),e.jsx("g",{transform:`translate(${(n-N)/2}, ${(n-b)/2})`,children:L}),e.jsx("rect",{x:(n-N)/2+x,y:(n-b)/2+j,width:Math.min(g,N),height:Math.min(p,b),fill:"rgba(59, 130, 246, 0.2)",stroke:"#3b82f6",strokeWidth:1.5,rx:2,className:nt.viewportRect})]}),e.jsxs("div",{className:nt.zoomIndicator,children:[Math.round(a.zoom*100),"%"]})]})},Co="_panel_16o5d_9",Io="_header_16o5d_27",So="_title_16o5d_45",Lo="_closeButton_16o5d_59",zo="_content_16o5d_85",$o="_endpointSection_16o5d_99",Bo="_endpointLabel_16o5d_107",To="_endpointSelect_16o5d_123",Po="_optionsSection_16o5d_157",Mo="_metricButton_16o5d_169",Oo="_metricButtonActive_16o5d_205",Ao="_analyzeButton_16o5d_219",Eo="_resultsSection_16o5d_267",Do="_resultsTitle_16o5d_277",Ro="_noResults_16o5d_293",Wo="_pathCard_16o5d_309",Go="_pathCardSelected_16o5d_333",Fo="_pathCardHeader_16o5d_343",Vo="_pathCardTitle_16o5d_361",Ho="_pathBadge_16o5d_373",Uo="_badgePrimary_16o5d_389",Zo="_badgeAlternate_16o5d_399",Yo="_pathName_16o5d_409",Ko="_pathStatus_16o5d_421",Xo="_statusDot_16o5d_435",Jo="_statusActive_16o5d_447",qo="_statusDegraded_16o5d_449",Qo="_statusInactive_16o5d_451",ea="_statusError_16o5d_453",ta="_pathStats_16o5d_459",sa="_statItem_16o5d_473",na="_statValue_16o5d_481",oa="_statLabel_16o5d_493",aa="_pathVisualization_16o5d_507",ca="_pathDiagram_16o5d_519",la="_pathNode_16o5d_535",ra="_pathNodeStart_16o5d_567",ia="_pathNodeEnd_16o5d_569",da="_pathLink_16o5d_579",ua="_pathLinkLine_16o5d_591",ha="_showOnMapButton_16o5d_605",_a="_loading_16o5d_641",pa="_spinner_16o5d_655",ma="_spin_16o5d_655",R={panel:Co,header:Io,title:So,closeButton:Lo,content:zo,endpointSection:$o,endpointLabel:Bo,endpointSelect:To,optionsSection:Po,metricButton:Mo,metricButtonActive:Oo,analyzeButton:Ao,resultsSection:Eo,resultsTitle:Do,noResults:Ro,pathCard:Wo,pathCardSelected:Go,pathCardHeader:Fo,pathCardTitle:Vo,pathBadge:Ho,badgePrimary:Uo,badgeAlternate:Zo,pathName:Yo,pathStatus:Ko,statusDot:Xo,statusActive:Jo,statusDegraded:qo,statusInactive:Qo,statusError:ea,pathStats:ta,statItem:sa,statValue:na,statLabel:oa,pathVisualization:aa,pathDiagram:ca,pathNode:la,pathNodeStart:ra,pathNodeEnd:ia,pathLink:da,pathLinkLine:ua,showOnMapButton:ha,loading:_a,spinner:pa,spin:ma},xa=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),fa=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M4 8h8M9 5l3 3-3 3",strokeLinecap:"round",strokeLinejoin:"round"})});function ga(t){switch(t){case"active":return"Aktywna";case"degraded":return"Degradacja";case"inactive":return"Nieaktywna";case"error":return"Błąd";default:return"Nieznany"}}function ya(t){return t<1?"<1ms":t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(1)}s`}function va(t){return t>=1e3?`${(t/1e3).toFixed(1)} Gbps`:`${Math.round(t)} Mbps`}const ba=({document:t,connections:s,onHighlightPath:a,onClose:o})=>{const[n,c]=l.useState(""),[d,f]=l.useState(""),[y,v]=l.useState("latency"),[u,N]=l.useState([]),[b,g]=l.useState(null),[p,x]=l.useState(!1),j=l.useMemo(()=>{const w=[];for(const i of t.floors)for(const $ of i.layers)if($.type==="network"||$.type==="devices"||$.type==="infrastructure")for(const E of $.objects)w.push({id:E.id,name:E.name??E.id});return w},[t]),r=l.useCallback(w=>{var i;return((i=j.find($=>$.id===w))==null?void 0:i.name)??w},[j]),L=l.useCallback(()=>{!n||!d||n===d||(x(!0),N([]),g(null),setTimeout(()=>{const w=U.findShortestPath(s,n,d,y),i=U.findAllPaths(s,n,d,5),$=[];w&&$.push(w);for(const E of i)$.some(H=>H.connectionIds.length===E.connectionIds.length&&H.connectionIds.every((G,me)=>E.connectionIds[me]===G))||$.push({...E,isPrimary:!1});N($),$.length>0&&(g($[0].id),a==null||a($[0])),x(!1)},300))},[n,d,y,s,a]),h=l.useCallback(w=>{g(w.id),a==null||a(w)},[a]),C=l.useCallback(w=>{const i=[w.startDeviceId];for(const $ of w.connectionIds){const E=s.find(H=>H.id===$);if(E){const H=i[i.length-1],G=E.sourceId===H?E.targetId:E.sourceId;i.includes(G)||i.push(G)}}return i},[s]);return e.jsxs("div",{className:R.panel,children:[e.jsxs("div",{className:R.header,children:[e.jsx("h3",{className:R.title,children:"Analiza ścieżki sieciowej"}),o&&e.jsx("button",{className:R.closeButton,onClick:o,children:e.jsx(xa,{})})]}),e.jsxs("div",{className:R.content,children:[e.jsxs("div",{className:R.endpointSection,children:[e.jsx("label",{className:R.endpointLabel,children:"Urządzenie źródłowe"}),e.jsxs("select",{className:R.endpointSelect,value:n,onChange:w=>c(w.target.value),children:[e.jsx("option",{value:"",children:"— Wybierz urządzenie —"}),j.map(w=>e.jsx("option",{value:w.id,children:w.name},w.id))]})]}),e.jsxs("div",{className:R.endpointSection,children:[e.jsx("label",{className:R.endpointLabel,children:"Urządzenie docelowe"}),e.jsxs("select",{className:R.endpointSelect,value:d,onChange:w=>f(w.target.value),children:[e.jsx("option",{value:"",children:"— Wybierz urządzenie —"}),j.filter(w=>w.id!==n).map(w=>e.jsx("option",{value:w.id,children:w.name},w.id))]})]}),e.jsxs("div",{className:R.optionsSection,children:[e.jsx("button",{className:`${R.metricButton} ${y==="latency"?R.metricButtonActive:""}`,onClick:()=>v("latency"),children:"Latencja"}),e.jsx("button",{className:`${R.metricButton} ${y==="hops"?R.metricButtonActive:""}`,onClick:()=>v("hops"),children:"Hops"}),e.jsx("button",{className:`${R.metricButton} ${y==="bandwidth"?R.metricButtonActive:""}`,onClick:()=>v("bandwidth"),children:"Przepustowość"})]}),e.jsx("button",{className:R.analyzeButton,onClick:L,disabled:!n||!d||n===d||p,children:p?"Analizowanie...":"Analizuj ścieżkę"}),p?e.jsx("div",{className:R.loading,children:e.jsx("div",{className:R.spinner})}):u.length>0?e.jsxs("div",{className:R.resultsSection,children:[e.jsxs("div",{className:R.resultsTitle,children:["Znalezione ścieżki (",u.length,")"]}),u.map((w,i)=>{const $=C(w),E=b===w.id;return e.jsxs("div",{className:`${R.pathCard} ${E?R.pathCardSelected:""}`,onClick:()=>h(w),children:[e.jsxs("div",{className:R.pathCardHeader,children:[e.jsxs("div",{className:R.pathCardTitle,children:[e.jsx("span",{className:`${R.pathBadge} ${w.isPrimary?R.badgePrimary:R.badgeAlternate}`,children:w.isPrimary?"Optymalna":`Alt ${i}`}),e.jsxs("span",{className:R.pathName,children:[w.connectionIds.length," połączeń"]})]}),e.jsxs("div",{className:R.pathStatus,children:[e.jsx("span",{className:`${R.statusDot} ${R[`status${w.status.charAt(0).toUpperCase()+w.status.slice(1)}`]??""}`}),e.jsx("span",{children:ga(w.status)})]})]}),e.jsxs("div",{className:R.pathStats,children:[e.jsxs("div",{className:R.statItem,children:[e.jsx("div",{className:R.statValue,children:ya(w.totalLatency)}),e.jsx("div",{className:R.statLabel,children:"Latencja"})]}),e.jsxs("div",{className:R.statItem,children:[e.jsx("div",{className:R.statValue,children:w.connectionIds.length}),e.jsx("div",{className:R.statLabel,children:"Hops"})]}),e.jsxs("div",{className:R.statItem,children:[e.jsx("div",{className:R.statValue,children:w.bottleneckBandwidth>0?va(w.bottleneckBandwidth):"N/A"}),e.jsx("div",{className:R.statLabel,children:"Przepustowość"})]})]}),E&&e.jsxs("div",{className:R.pathVisualization,children:[e.jsx("div",{className:R.pathDiagram,children:$.map((H,G)=>e.jsxs(l.Fragment,{children:[e.jsx("div",{className:`${R.pathNode} ${G===0?R.pathNodeStart:G===$.length-1?R.pathNodeEnd:""}`,children:r(H).substring(0,8)}),G<$.length-1&&e.jsxs("div",{className:R.pathLink,children:[e.jsx("div",{className:R.pathLinkLine}),e.jsx(fa,{})]})]},H))}),e.jsx("button",{className:R.showOnMapButton,onClick:H=>{H.stopPropagation(),a==null||a(w)},children:"Pokaż na mapie"})]})]},w.id)})]}):n&&d&&n!==d?e.jsx("div",{className:R.noResults,children:'Wybierz urządzenia i kliknij „Analizuj ścieżkę"'}):e.jsx("div",{className:R.noResults,children:"Wybierz urządzenie źródłowe i docelowe"})]})]})},ja="_root_h6ehl_9",wa="_header_h6ehl_27",Na="_title_h6ehl_37",ka="_search_h6ehl_51",Ca="_categories_h6ehl_79",Ia="_category_h6ehl_91",Sa="_categoryHeader_h6ehl_107",La="_categoryIcon_h6ehl_143",za="_categoryLabel_h6ehl_151",$a="_categoryCount_h6ehl_161",Ba="_expandIcon_h6ehl_171",Ta="_items_h6ehl_181",Pa="_item_h6ehl_181",Ma="_itemIcon_h6ehl_241",Oa="_itemName_h6ehl_249",Aa="_emptyState_h6ehl_269",ye={root:ja,header:wa,title:Na,search:ka,categories:Ca,category:Ia,categoryHeader:Sa,categoryIcon:La,categoryLabel:za,categoryCount:$a,expandIcon:Ba,items:Ta,item:Pa,itemIcon:Ma,itemName:Oa,emptyState:Aa},Ea={"floor-plan":["smart-home","building"],"network-topology":["network"],infrastructure:["infrastructure","network"],cad:["building"],interior:["furniture","smart-home"],"game-scene":["game"]},Da={"smart-home":{icon:"🏠",label:"Smart Home"},furniture:{icon:"🛋️",label:"Furniture"},network:{icon:"🌐",label:"Network"},infrastructure:{icon:"⚙️",label:"Infrastructure"},building:{icon:"🏗️",label:"Building"},zone:{icon:"🗺️",label:"Zones"},game:{icon:"🎮",label:"Game Objects"},annotation:{icon:"📝",label:"Annotations"}},Kt=({mode:t,onObjectSelect:s,customObjects:a=[],className:o})=>{const[n,c]=l.useState(""),[d,f]=l.useState(new Set(["smart-home","furniture","network"])),y=Ea[t]||[],v=l.useMemo(()=>{const b={},g=U.OBJECT_CATALOG.reduce((p,x)=>{var j;return(p[j=x.category]??(p[j]=[])).push(x),p},{});return Object.entries(g).forEach(([p,x])=>{if(!y.includes(p))return;const j=x.filter(r=>!n||r.name.toLowerCase().includes(n.toLowerCase()));j.length>0&&(b[p]=j.map(r=>({id:r.id,name:r.name,category:p,icon:r.icon})))}),a.forEach(p=>{y.includes(p.category)&&(!n||p.name.toLowerCase().includes(n.toLowerCase()))&&(b[p.category]||(b[p.category]=[]),b[p.category].push(p))}),b},[y,n,a]),u=b=>{f(g=>{const p=new Set(g);return p.has(b)?p.delete(b):p.add(b),p})},N=(b,g)=>{b.dataTransfer.setData("application/json",JSON.stringify(g)),b.dataTransfer.effectAllowed="copy"};return e.jsxs("div",{className:`${ye.root} ${o??""}`,children:[e.jsxs("div",{className:ye.header,children:[e.jsx("h3",{className:ye.title,children:"Objects"}),e.jsx("input",{type:"text",className:ye.search,placeholder:"Search...",value:n,onChange:b=>c(b.target.value)})]}),e.jsxs("div",{className:ye.categories,children:[Object.entries(v).map(([b,g])=>{const p=Da[b]||{icon:"📦",label:b},x=d.has(b);return e.jsxs("div",{className:ye.category,children:[e.jsxs("button",{className:ye.categoryHeader,onClick:()=>u(b),children:[e.jsx("span",{className:ye.categoryIcon,children:p.icon}),e.jsx("span",{className:ye.categoryLabel,children:p.label}),e.jsxs("span",{className:ye.categoryCount,children:["(",g.length,")"]}),e.jsx("span",{className:ye.expandIcon,children:x?"▼":"▶"})]}),x&&e.jsx("div",{className:ye.items,children:g.map(j=>e.jsxs("div",{className:ye.item,draggable:!0,onDragStart:r=>N(r,j),onClick:()=>s(j),title:j.name,children:[e.jsx("span",{className:ye.itemIcon,children:j.icon||"📦"}),e.jsx("span",{className:ye.itemName,children:j.name})]},j.id))})]},b)}),Object.keys(v).length===0&&e.jsx("div",{className:ye.emptyState,children:n?`No objects matching "${n}"`:"No objects available for this mode"})]})]})},Ra="_root_17h1m_9",Wa="_header_17h1m_23",Ga="_title_17h1m_39",Fa="_multiSelect_17h1m_53",Va="_content_17h1m_63",Ha="_section_17h1m_73",Ua="_sectionHeader_17h1m_89",Za="_sectionContent_17h1m_127",Ya="_fieldRow_17h1m_135",Ka="_fieldLabel_17h1m_157",Xa="_textInput_17h1m_169",Ja="_numberInput_17h1m_171",qa="_select_17h1m_173",Qa="_checkbox_17h1m_215",ec="_colorInput_17h1m_227",tc="_readOnly_17h1m_245",sc="_emptyState_17h1m_263",ne={root:Ra,header:Wa,title:Ga,multiSelect:Fa,content:Va,section:Ha,sectionHeader:Ua,sectionContent:Za,fieldRow:Ya,fieldLabel:Ka,textInput:Xa,numberInput:Ja,select:qa,checkbox:Qa,colorInput:ec,readOnly:tc,emptyState:sc},jt=[{key:"name",label:"Name",type:"text"},{key:"position.x",label:"X",type:"number",step:1},{key:"position.y",label:"Y",type:"number",step:1},{key:"rotation",label:"Rotation",type:"number",min:0,max:360,step:1},{key:"visible",label:"Visible",type:"boolean"},{key:"locked",label:"Locked",type:"boolean"}],nc=[{key:"type",label:"Zone Type",type:"select",options:[{value:"living_room",label:"Living Room"},{value:"bedroom",label:"Bedroom"},{value:"bathroom",label:"Bathroom"},{value:"kitchen",label:"Kitchen"},{value:"office",label:"Office"},{value:"hallway",label:"Hallway"},{value:"other",label:"Other"}]},{key:"color",label:"Color",type:"color"},{key:"opacity",label:"Opacity",type:"number",min:0,max:1,step:.1}],oc=[{key:"deviceType",label:"Device Type",type:"text"},{key:"status",label:"Status",type:"select",options:[{value:"online",label:"Online"},{value:"offline",label:"Offline"},{value:"error",label:"Error"}]}],Xt=({selection:t,document:s,onPropertyChange:a,className:o})=>{const[n,c]=l.useState(new Set(["general","position","appearance"])),d=t.objectIds.map(g=>{for(const p of s.floors)for(const x of p.layers){const j=x.objects.find(r=>r.id===g);if(j)return j}return null}).filter(Boolean),f=g=>{c(p=>{const x=new Set(p);return x.has(g)?x.delete(g):x.add(g),x})},y=l.useCallback((g,p)=>{const x=p.split(".");let j=g;for(const r of x)if(j&&typeof j=="object"&&r in j)j=j[r];else return;return j},[]),v=l.useCallback((g,p)=>{var j;const x=y(p,g.key);switch(g.type){case"text":return e.jsx("input",{type:"text",value:String(x??""),onChange:r=>a(p.id,g.key,r.target.value),className:ne.textInput});case"number":return e.jsx("input",{type:"number",value:Number(x??0),min:g.min,max:g.max,step:g.step,onChange:r=>a(p.id,g.key,parseFloat(r.target.value)),className:ne.numberInput});case"boolean":return e.jsx("input",{type:"checkbox",checked:!!x,onChange:r=>a(p.id,g.key,r.target.checked),className:ne.checkbox});case"color":return e.jsx("input",{type:"color",value:String(x??"#ffffff"),onChange:r=>a(p.id,g.key,r.target.value),className:ne.colorInput});case"select":return e.jsx("select",{value:String(x??""),onChange:r=>a(p.id,g.key,r.target.value),className:ne.select,children:(j=g.options)==null?void 0:j.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))});default:return e.jsx("span",{children:String(x??"-")})}},[y,a]);if(d.length===0)return e.jsxs("div",{className:`${ne.root} ${o??""}`,children:[e.jsx("div",{className:ne.header,children:e.jsx("h3",{className:ne.title,children:"Properties"})}),e.jsx("div",{className:ne.emptyState,children:"No object selected"})]});const u=d[0],N=d.length>1,b=u.category==="zone"?nc:["smart-home","network","infrastructure"].includes(u.category??"")?oc:[];return e.jsxs("div",{className:`${ne.root} ${o??""}`,children:[e.jsxs("div",{className:ne.header,children:[e.jsx("h3",{className:ne.title,children:"Properties"}),N&&e.jsxs("span",{className:ne.multiSelect,children:[d.length," selected"]})]}),e.jsxs("div",{className:ne.content,children:[e.jsxs("div",{className:ne.section,children:[e.jsxs("button",{className:ne.sectionHeader,onClick:()=>f("general"),children:[e.jsx("span",{children:n.has("general")?"▼":"▶"}),e.jsx("span",{children:"General"})]}),n.has("general")&&e.jsxs("div",{className:ne.sectionContent,children:[jt.slice(0,1).map(g=>e.jsxs("div",{className:ne.fieldRow,children:[e.jsx("label",{className:ne.fieldLabel,children:g.label}),v(g,u)]},g.key)),e.jsxs("div",{className:ne.fieldRow,children:[e.jsx("label",{className:ne.fieldLabel,children:"ID"}),e.jsx("span",{className:ne.readOnly,children:u.id})]}),e.jsxs("div",{className:ne.fieldRow,children:[e.jsx("label",{className:ne.fieldLabel,children:"Category"}),e.jsx("span",{className:ne.readOnly,children:u.category})]})]})]}),e.jsxs("div",{className:ne.section,children:[e.jsxs("button",{className:ne.sectionHeader,onClick:()=>f("position"),children:[e.jsx("span",{children:n.has("position")?"▼":"▶"}),e.jsx("span",{children:"Transform"})]}),n.has("position")&&e.jsx("div",{className:ne.sectionContent,children:jt.slice(1,4).map(g=>e.jsxs("div",{className:ne.fieldRow,children:[e.jsx("label",{className:ne.fieldLabel,children:g.label}),v(g,u)]},g.key))})]}),b.length>0&&e.jsxs("div",{className:ne.section,children:[e.jsxs("button",{className:ne.sectionHeader,onClick:()=>f("appearance"),children:[e.jsx("span",{children:n.has("appearance")?"▼":"▶"}),e.jsx("span",{children:"Appearance"})]}),n.has("appearance")&&e.jsx("div",{className:ne.sectionContent,children:b.map(g=>e.jsxs("div",{className:ne.fieldRow,children:[e.jsx("label",{className:ne.fieldLabel,children:g.label}),v(g,u)]},g.key))})]}),e.jsxs("div",{className:ne.section,children:[e.jsxs("button",{className:ne.sectionHeader,onClick:()=>f("visibility"),children:[e.jsx("span",{children:n.has("visibility")?"▼":"▶"}),e.jsx("span",{children:"Visibility"})]}),n.has("visibility")&&e.jsx("div",{className:ne.sectionContent,children:jt.slice(4).map(g=>e.jsxs("div",{className:ne.fieldRow,children:[e.jsx("label",{className:ne.fieldLabel,children:g.label}),v(g,u)]},g.key))})]})]})]})},ac="_panel_9nj82_9",cc="_header_9nj82_33",lc="_headerTitle_9nj82_51",rc="_title_9nj82_65",ic="_closeButton_9nj82_79",dc="_summarySection_9nj82_111",uc="_summaryStats_9nj82_121",hc="_statBadge_9nj82_133",_c="_statValue_9nj82_147",pc="_statLabel_9nj82_159",mc="_visibilityControls_9nj82_175",xc="_visibilityLabel_9nj82_193",fc="_visibilityButtons_9nj82_203",gc="_visibilityBtn_9nj82_213",yc="_active_9nj82_243",vc="_content_9nj82_257",bc="_emptyState_9nj82_271",jc="_emptyHint_9nj82_317",wc="_vlanList_9nj82_329",Nc="_vlanCard_9nj82_343",kc="_highlighted_9nj82_369",Cc="_hidden_9nj82_379",Ic="_vlanHeader_9nj82_387",Sc="_colorIndicator_9nj82_413",Lc="_vlanInfo_9nj82_427",zc="_vlanName_9nj82_437",$c="_vlanId_9nj82_451",Bc="_vlanNameText_9nj82_463",Tc="_vlanSubnet_9nj82_479",Pc="_vlanStats_9nj82_495",Mc="_chipStat_9nj82_507",Oc="_vlanActions_9nj82_537",Ac="_iconBtn_9nj82_549",Ec="_inactive_9nj82_587",Dc="_expanded_9nj82_603",Rc="_vlanDetails_9nj82_615",Wc="_detailRow_9nj82_627",Gc="_detailLabel_9nj82_649",Fc="_detailValue_9nj82_667",Vc="_badge_9nj82_679",Hc="_badgeSuccess_9nj82_693",Uc="_badgeNeutral_9nj82_703",Zc="_deviceList_9nj82_715",Yc="_deviceItems_9nj82_723",Kc="_deviceItem_9nj82_723",Xc="_deviceDot_9nj82_757",Jc="_deviceMore_9nj82_771",qc="_highlightButton_9nj82_787",Qc="_footer_9nj82_827",el="_legendTitle_9nj82_839",tl="_legend_9nj82_839",sl="_legendItem_9nj82_867",nl="_legendColor_9nj82_879",ol="_legendLabel_9nj82_893",T={panel:ac,header:cc,headerTitle:lc,title:rc,closeButton:ic,summarySection:dc,summaryStats:uc,statBadge:hc,statValue:_c,statLabel:pc,visibilityControls:mc,visibilityLabel:xc,visibilityButtons:fc,visibilityBtn:gc,active:yc,content:vc,emptyState:bc,emptyHint:jc,vlanList:wc,vlanCard:Nc,highlighted:kc,hidden:Cc,vlanHeader:Ic,colorIndicator:Sc,vlanInfo:Lc,vlanName:zc,vlanId:$c,vlanNameText:Bc,vlanSubnet:Tc,vlanStats:Pc,chipStat:Mc,vlanActions:Oc,iconBtn:Ac,inactive:Ec,expanded:Dc,vlanDetails:Rc,detailRow:Wc,detailLabel:Gc,detailValue:Fc,badge:Vc,badgeSuccess:Hc,badgeNeutral:Uc,deviceList:Zc,deviceItems:Yc,deviceItem:Kc,deviceDot:Xc,deviceMore:Jc,highlightButton:qc,footer:Qc,legendTitle:el,legend:tl,legendItem:sl,legendColor:nl,legendLabel:ol},al=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),cl=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("ellipse",{cx:"8",cy:"8",rx:"6",ry:"4"}),e.jsx("circle",{cx:"8",cy:"8",r:"2"})]}),ll=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M2 8s2.5-4 6-4 6 4 6 4-2.5 4-6 4-6-4-6-4z"}),e.jsx("path",{d:"M3 13L13 3",strokeLinecap:"round"})]}),Ot=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"2",y:"2",width:"4",height:"4",rx:"1"}),e.jsx("rect",{x:"10",y:"2",width:"4",height:"4",rx:"1"}),e.jsx("rect",{x:"6",y:"10",width:"4",height:"4",rx:"1"}),e.jsx("path",{d:"M4 6v2a2 2 0 002 2h4a2 2 0 002-2V6"}),e.jsx("path",{d:"M8 10V8"})]}),rl=()=>e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"7",cy:"7",r:"6"}),e.jsx("path",{d:"M7 6v4M7 4h0",strokeLinecap:"round"})]});function il(t){var s;return((s=t.deviceIds)==null?void 0:s.length)??0}function dl(t,s){return s.filter(a=>a.vlanId===t.id).length}function ul(t){return t||"—"}const hl=({document:t,connections:s,vlans:a,visibleVlanIds:o,onVlanVisibilityChange:n,onHighlightVlan:c,onClose:d})=>{const[f,y]=l.useState(null),[v,u]=l.useState(null),N=l.useMemo(()=>[...a].sort((h,C)=>h.id-C.id),[a]),b=l.useMemo(()=>{const h=new Set,C=new Set;for(const w of a)for(const i of w.deviceIds??[])h.add(i);for(const w of s)w.vlanId!==void 0&&C.add(w.id);return{vlanCount:a.length,deviceCount:h.size,connectionCount:C.size}},[a,s]),g=l.useCallback(h=>{const C=o.has(h);n==null||n(h,!C)},[o,n]),p=l.useCallback(h=>{for(const C of a)n==null||n(C.id,h)},[a,n]),x=l.useCallback(h=>{y((h==null?void 0:h.id)??null),c==null||c(h)},[c]),j=l.useCallback(h=>{u(C=>C===h?null:h)},[]),r=l.useCallback(h=>{const C=[];for(const w of h.deviceIds??[])for(const i of t.floors)for(const $ of i.layers){const E=$.objects.find(H=>H.id===w);E&&C.push({id:w,name:E.name??w})}return C},[t]),L=l.useMemo(()=>{const h=a.filter(C=>o.has(C.id)).length;return{visible:h,total:a.length,allVisible:h===a.length,noneVisible:h===0}},[a,o]);return e.jsxs("div",{className:T.panel,children:[e.jsxs("div",{className:T.header,children:[e.jsxs("div",{className:T.headerTitle,children:[e.jsx(Ot,{}),e.jsx("h3",{className:T.title,children:"Nakładka VLAN"})]}),d&&e.jsx("button",{className:T.closeButton,onClick:d,title:"Zamknij",children:e.jsx(al,{})})]}),e.jsx("div",{className:T.summarySection,children:e.jsxs("div",{className:T.summaryStats,children:[e.jsxs("div",{className:T.statBadge,children:[e.jsx("span",{className:T.statValue,children:b.vlanCount}),e.jsx("span",{className:T.statLabel,children:"VLAN"})]}),e.jsxs("div",{className:T.statBadge,children:[e.jsx("span",{className:T.statValue,children:b.deviceCount}),e.jsx("span",{className:T.statLabel,children:"Urządzeń"})]}),e.jsxs("div",{className:T.statBadge,children:[e.jsx("span",{className:T.statValue,children:b.connectionCount}),e.jsx("span",{className:T.statLabel,children:"Połączeń"})]})]})}),e.jsxs("div",{className:T.visibilityControls,children:[e.jsxs("span",{className:T.visibilityLabel,children:["Widoczność: ",L.visible,"/",L.total]}),e.jsxs("div",{className:T.visibilityButtons,children:[e.jsx("button",{className:`${T.visibilityBtn} ${L.allVisible?T.active:""}`,onClick:()=>p(!0),title:"Pokaż wszystkie",children:"Wszystkie"}),e.jsx("button",{className:`${T.visibilityBtn} ${L.noneVisible?T.active:""}`,onClick:()=>p(!1),title:"Ukryj wszystkie",children:"Żaden"})]})]}),e.jsx("div",{className:T.content,children:N.length===0?e.jsxs("div",{className:T.emptyState,children:[e.jsx(Ot,{}),e.jsx("p",{children:"Brak zdefiniowanych VLAN-ów"}),e.jsx("span",{className:T.emptyHint,children:"Dodaj VLAN w trybie network-topology lub infrastructure"})]}):e.jsx("div",{className:T.vlanList,children:N.map(h=>{const C=o.has(h.id),w=f===h.id,i=v===h.id,$=il(h),E=dl(h,s),H=i?r(h):[];return e.jsxs("div",{className:`${T.vlanCard} ${w?T.highlighted:""} ${C?"":T.hidden}`,onMouseEnter:()=>x(h),onMouseLeave:()=>x(null),children:[e.jsxs("div",{className:T.vlanHeader,children:[e.jsx("div",{className:T.colorIndicator,style:{backgroundColor:h.color}}),e.jsxs("div",{className:T.vlanInfo,children:[e.jsxs("div",{className:T.vlanName,children:[e.jsxs("span",{className:T.vlanId,children:["VLAN ",h.id]}),h.name&&e.jsx("span",{className:T.vlanNameText,children:h.name})]}),h.subnet&&e.jsx("div",{className:T.vlanSubnet,children:ul(h.subnet)})]}),e.jsxs("div",{className:T.vlanStats,children:[e.jsx("span",{className:T.chipStat,title:"Urządzenia",children:$}),e.jsx("span",{className:T.chipStat,title:"Połączenia",children:E})]}),e.jsxs("div",{className:T.vlanActions,children:[e.jsx("button",{className:`${T.iconBtn} ${C?"":T.inactive}`,onClick:G=>{G.stopPropagation(),g(h.id)},title:C?"Ukryj VLAN":"Pokaż VLAN",children:C?e.jsx(cl,{}):e.jsx(ll,{})}),e.jsx("button",{className:`${T.iconBtn} ${i?T.expanded:""}`,onClick:G=>{G.stopPropagation(),j(h.id)},title:"Szczegóły",children:e.jsx(rl,{})})]})]}),i&&e.jsxs("div",{className:T.vlanDetails,children:[h.description&&e.jsxs("div",{className:T.detailRow,children:[e.jsx("span",{className:T.detailLabel,children:"Opis:"}),e.jsx("span",{className:T.detailValue,children:h.description})]}),h.subnet&&e.jsxs("div",{className:T.detailRow,children:[e.jsx("span",{className:T.detailLabel,children:"Podsieć:"}),e.jsx("span",{className:T.detailValue,children:h.subnet})]}),h.gateway&&e.jsxs("div",{className:T.detailRow,children:[e.jsx("span",{className:T.detailLabel,children:"Brama:"}),e.jsx("span",{className:T.detailValue,children:h.gateway})]}),e.jsxs("div",{className:T.detailRow,children:[e.jsx("span",{className:T.detailLabel,children:"DHCP:"}),e.jsx("span",{className:`${T.detailValue} ${T.badge} ${h.dhcpEnabled?T.badgeSuccess:T.badgeNeutral}`,children:h.dhcpEnabled?"Włączone":"Wyłączone"})]}),H.length>0&&e.jsxs("div",{className:T.deviceList,children:[e.jsxs("span",{className:T.detailLabel,children:["Urządzenia (",H.length,"):"]}),e.jsxs("ul",{className:T.deviceItems,children:[H.slice(0,10).map(G=>e.jsxs("li",{className:T.deviceItem,children:[e.jsx("span",{className:T.deviceDot,style:{backgroundColor:h.color}}),G.name]},G.id)),H.length>10&&e.jsxs("li",{className:T.deviceMore,children:["... i ",H.length-10," więcej"]})]})]}),e.jsx("button",{className:T.highlightButton,onClick:()=>c==null?void 0:c(h),children:"Zaznacz na mapie"})]})]},h.id)})})}),N.length>0&&e.jsxs("div",{className:T.footer,children:[e.jsx("div",{className:T.legendTitle,children:"Legenda kolorów"}),e.jsx("div",{className:T.legend,children:N.map(h=>e.jsxs("div",{className:T.legendItem,children:[e.jsx("span",{className:T.legendColor,style:{backgroundColor:h.color}}),e.jsxs("span",{className:T.legendLabel,children:[h.id,h.name?`: ${h.name}`:""]})]},h.id))})]})]})},_l="_root_1iwvh_9",pl="_dark_1iwvh_35",ml="_topBar_1iwvh_59",xl="_modeSwitcher_1iwvh_77",fl="_modeBtn_1iwvh_87",gl="_modeBtnActive_1iwvh_123",yl="_modeIcon_1iwvh_135",vl="_modeLabel_1iwvh_143",bl="_floorTabs_1iwvh_151",jl="_floorTab_1iwvh_151",wl="_floorTabActive_1iwvh_195",Nl="_viewportControls_1iwvh_207",kl="_active_1iwvh_249",Cl="_disabled_1iwvh_259",Il="_separator_1iwvh_273",Sl="_zoomLevel_1iwvh_287",Ll="_exportDropdown_1iwvh_305",zl="_exportMenu_1iwvh_353",$l="_mainContent_1iwvh_427",Bl="_editorContainer_1iwvh_443",Tl="_toolbar_1iwvh_461",Pl="_toolGroup_1iwvh_481",Ml="_toolBtn_1iwvh_509",Ol="_toolBtnActive_1iwvh_549",Al="_canvasWrapper_1iwvh_573",El="_canvas_1iwvh_573",Dl="_cursor_select_1iwvh_601",Rl="_cursor_multi_select_1iwvh_603",Wl="_cursor_pan_1iwvh_605",Gl="_cursor_zoom_1iwvh_609",Fl="_cursor_draw_wall_1iwvh_611",Vl="_cursor_draw_zone_1iwvh_613",Hl="_cursor_draw_polyline_1iwvh_615",Ul="_cursor_draw_rectangle_1iwvh_617",Zl="_cursor_draw_circle_1iwvh_619",Yl="_cursor_draw_arc_1iwvh_621",Kl="_cursor_place_device_1iwvh_623",Xl="_cursor_place_furniture_1iwvh_625",Jl="_cursor_place_network_1iwvh_627",ql="_cursor_place_infra_1iwvh_629",Ql="_cursor_place_door_1iwvh_631",er="_cursor_place_window_1iwvh_633",tr="_cursor_place_stairs_1iwvh_635",sr="_cursor_connect_1iwvh_637",nr="_cursor_route_cable_1iwvh_639",or="_cursor_annotate_1iwvh_641",ar="_cursor_dimension_1iwvh_643",cr="_cursor_label_1iwvh_645",lr="_cursor_measure_distance_1iwvh_647",rr="_cursor_measure_angle_1iwvh_649",ir="_cursor_measure_area_1iwvh_651",dr="_cursor_move_1iwvh_653",ur="_cursor_rotate_1iwvh_655",hr="_cursor_scale_1iwvh_657",_r="_cursor_erase_1iwvh_659",pr="_cursor_copy_1iwvh_661",mr="_cursor_paste_1iwvh_663",xr="_grid_1iwvh_669",fr="_gridLine_1iwvh_671",gr="_zonesLayer_1iwvh_683",yr="_zone_1iwvh_683",vr="_zoneLabel_1iwvh_689",br="_connectionsLayer_1iwvh_703",jr="_connection_1iwvh_703",wr="_connectionPreview_1iwvh_709",Nr="_guides_1iwvh_715",kr="_guideLine_1iwvh_717",Cr="_drawingPreview_1iwvh_731",Ir="_rightSidebar_1iwvh_739",Sr="_statusBar_1iwvh_761",Lr="_modeIndicator_1iwvh_783",zr="_toolIndicator_1iwvh_785",$r="_selectionInfo_1iwvh_797",Br="_drawingInfo_1iwvh_799",Tr="_connectingInfo_1iwvh_813",Pr="_gridInfo_1iwvh_827",Mr="_emptyState_1iwvh_839",Or="_emptyIcon_1iwvh_861",Ar="_primaryBtn_1iwvh_891",Er="_modeActions_1iwvh_925",Dr="_actionBtn_1iwvh_943",O={root:_l,dark:pl,topBar:ml,modeSwitcher:xl,modeBtn:fl,modeBtnActive:gl,modeIcon:yl,modeLabel:vl,floorTabs:bl,floorTab:jl,floorTabActive:wl,viewportControls:Nl,active:kl,disabled:Cl,separator:Il,zoomLevel:Sl,exportDropdown:Ll,exportMenu:zl,mainContent:$l,editorContainer:Bl,toolbar:Tl,toolGroup:Pl,toolBtn:Ml,toolBtnActive:Ol,canvasWrapper:Al,canvas:El,cursor_select:Dl,cursor_multi_select:Rl,cursor_pan:Wl,cursor_zoom:Gl,cursor_draw_wall:Fl,cursor_draw_zone:Vl,cursor_draw_polyline:Hl,cursor_draw_rectangle:Ul,cursor_draw_circle:Zl,cursor_draw_arc:Yl,cursor_place_device:Kl,cursor_place_furniture:Xl,cursor_place_network:Jl,cursor_place_infra:ql,cursor_place_door:Ql,cursor_place_window:er,cursor_place_stairs:tr,cursor_connect:sr,cursor_route_cable:nr,cursor_annotate:or,cursor_dimension:ar,cursor_label:cr,cursor_measure_distance:lr,cursor_measure_angle:rr,cursor_measure_area:ir,cursor_move:dr,cursor_rotate:ur,cursor_scale:hr,cursor_erase:_r,cursor_copy:pr,cursor_paste:mr,grid:xr,gridLine:fr,zonesLayer:gr,zone:yr,zoneLabel:vr,connectionsLayer:br,connection:jr,connectionPreview:wr,guides:Nr,guideLine:kr,drawingPreview:Cr,rightSidebar:Ir,statusBar:Sr,modeIndicator:Lr,toolIndicator:zr,selectionInfo:$r,drawingInfo:Br,connectingInfo:Tr,gridInfo:Pr,emptyState:Mr,emptyIcon:Or,primaryBtn:Ar,modeActions:Er,actionBtn:Dr},Ze={"floor-plan":{mode:"floor-plan",label:"Floor Plan",icon:"🏠",tools:["select","pan","draw-zone","draw-wall","place-device","place-door","place-window","annotate","dimension","measure-distance","measure-area","erase"],layerTypes:["background","floor-plan","zones","devices","annotations","dimensions","grid"],defaultGridSize:20,enable3D:!1},"network-topology":{mode:"network-topology",label:"Network Topology",icon:"🌐",tools:["select","pan","place-network","connect","route-cable","annotate","label","measure-distance","erase"],layerTypes:["background","floor-plan","network","annotations","grid"],defaultGridSize:40,enable3D:!1},infrastructure:{mode:"infrastructure",label:"Infrastructure",icon:"🏢",tools:["select","pan","draw-zone","place-infra","place-network","connect","route-cable","annotate","dimension","measure-distance","measure-area","erase"],layerTypes:["background","floor-plan","zones","infrastructure","network","annotations","dimensions","grid"],defaultGridSize:50,enable3D:!1},cad:{mode:"cad",label:"CAD",icon:"📐",tools:["select","multi-select","pan","draw-wall","draw-zone","draw-polyline","draw-rectangle","draw-circle","draw-arc","place-door","place-window","place-stairs","annotate","dimension","measure-distance","measure-angle","measure-area","move","rotate","scale","copy","paste","erase"],layerTypes:["background","floor-plan","zones","annotations","dimensions","grid"],defaultGridSize:10,enable3D:!0},interior:{mode:"interior",label:"Interior Design",icon:"🛋️",tools:["select","pan","draw-zone","draw-wall","place-furniture","place-device","place-door","place-window","annotate","measure-distance","measure-area","move","rotate","erase"],layerTypes:["background","floor-plan","zones","furniture","devices","annotations","grid"],defaultGridSize:25,enable3D:!0},"game-scene":{mode:"game-scene",label:"Game Scene",icon:"🎮",tools:["select","multi-select","pan","draw-zone","draw-polyline","draw-rectangle","draw-circle","annotate","move","rotate","scale","copy","paste","erase"],layerTypes:["background","floor-plan","zones","game-objects","collision","annotations","grid"],defaultGridSize:32,enable3D:!0}},kt={select:{tool:"select",icon:"↖",label:"Select",shortcut:"V",group:"select"},"multi-select":{tool:"multi-select",icon:"⊞",label:"Multi-Select",shortcut:"M",group:"select"},pan:{tool:"pan",icon:"✋",label:"Pan",shortcut:"H",group:"select"},zoom:{tool:"zoom",icon:"🔍",label:"Zoom",shortcut:"Z",group:"select"},"draw-wall":{tool:"draw-wall",icon:"▬",label:"Wall",shortcut:"W",group:"draw"},"draw-zone":{tool:"draw-zone",icon:"⬡",label:"Zone",shortcut:"R",group:"draw"},"draw-polyline":{tool:"draw-polyline",icon:"〰",label:"Polyline",shortcut:"L",group:"draw"},"draw-rectangle":{tool:"draw-rectangle",icon:"▢",label:"Rectangle",shortcut:"U",group:"draw"},"draw-circle":{tool:"draw-circle",icon:"○",label:"Circle",shortcut:"C",group:"draw"},"draw-arc":{tool:"draw-arc",icon:"⌒",label:"Arc",shortcut:"A",group:"draw"},"place-device":{tool:"place-device",icon:"📡",label:"Device",shortcut:"D",group:"place"},"place-furniture":{tool:"place-furniture",icon:"🪑",label:"Furniture",shortcut:"F",group:"place"},"place-network":{tool:"place-network",icon:"🖧",label:"Network",shortcut:"N",group:"place"},"place-infra":{tool:"place-infra",icon:"⚙",label:"Infrastructure",shortcut:"I",group:"place"},"place-door":{tool:"place-door",icon:"🚪",label:"Door",group:"place"},"place-window":{tool:"place-window",icon:"🪟",label:"Window",group:"place"},"place-stairs":{tool:"place-stairs",icon:"🪜",label:"Stairs",group:"place"},connect:{tool:"connect",icon:"⟷",label:"Connect",shortcut:"K",group:"connect"},"route-cable":{tool:"route-cable",icon:"〰",label:"Cable Route",group:"connect"},annotate:{tool:"annotate",icon:"✏",label:"Annotate",shortcut:"T",group:"annotate"},dimension:{tool:"dimension",icon:"↔",label:"Dimension",group:"annotate"},label:{tool:"label",icon:"🏷",label:"Label",group:"annotate"},"measure-distance":{tool:"measure-distance",icon:"📏",label:"Distance",group:"measure"},"measure-angle":{tool:"measure-angle",icon:"∠",label:"Angle",group:"measure"},"measure-area":{tool:"measure-area",icon:"⊡",label:"Area",group:"measure"},move:{tool:"move",icon:"✥",label:"Move",shortcut:"G",group:"edit"},rotate:{tool:"rotate",icon:"↻",label:"Rotate",shortcut:"R",group:"edit"},scale:{tool:"scale",icon:"⤡",label:"Scale",shortcut:"S",group:"edit"},erase:{tool:"erase",icon:"🗑",label:"Delete",shortcut:"Del",group:"edit"},copy:{tool:"copy",icon:"📋",label:"Copy",shortcut:"Ctrl+C",group:"edit"},paste:{tool:"paste",icon:"📄",label:"Paste",shortcut:"Ctrl+V",group:"edit"}};function Rr(t){var n,c;const s=t.defaultMode??"floor-plan",a=Ze[s],o=[{type:"grid",visible:!0,locked:!0,opacity:.3,zIndex:0},{type:"background",visible:!0,locked:!0,opacity:.5,zIndex:1},{type:"floor-plan",visible:!0,locked:!1,opacity:1,zIndex:10},{type:"zones",visible:!0,locked:!1,opacity:.6,zIndex:20},{type:"furniture",visible:!0,locked:!1,opacity:1,zIndex:30},{type:"devices",visible:!0,locked:!1,opacity:1,zIndex:40},{type:"network",visible:!0,locked:!1,opacity:1,zIndex:50},{type:"infrastructure",visible:!0,locked:!1,opacity:1,zIndex:60},{type:"game-objects",visible:!0,locked:!1,opacity:1,zIndex:70},{type:"collision",visible:!1,locked:!1,opacity:.4,zIndex:80},{type:"annotations",visible:!0,locked:!1,opacity:1,zIndex:90},{type:"dimensions",visible:!0,locked:!1,opacity:1,zIndex:100}];return{mode:s,tool:a.tools[0]??"select",document:t.document??t.initialDocument??null,activeFloorId:((c=(n=t.document)==null?void 0:n.floors[0])==null?void 0:c.id)??null,layers:o,selection:{objectIds:[],bounds:null,locked:!1},viewport:{zoom:1,pan:{x:0,y:0},rotation:0,showGrid:!0,gridSize:t.gridSize??a.defaultGridSize,snapEnabled:t.snapEnabled??!0,snapModes:["grid","endpoint","midpoint"]},drawing:{active:!1,points:[],preview:null},connecting:{active:!1,sourceId:null,sourcePosition:null,previewPosition:null},history:{past:[],future:[]},guides:[],dragging:null,clipboard:[],ui:{showObjectLibrary:t.showObjectLibrary??!0,showLayerPanel:t.showLayerPanel??!0,showPropertiesPanel:t.showPropertiesPanel??!0,showMinimap:t.showMinimap??!0}}}function He(t,s,a,o){return{id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,timestamp:Date.now(),type:t,objectIds:s,before:a,after:o}}function Ue(t,s){return{history:{past:[...t.history.past.slice(-49),s],future:[]}}}function Ee(t,s){if(t)for(const a of t.floors)for(const o of a.layers){const n=o.objects.find(c=>c.id===s);if(n)return n}}function ot(t,s,a){return{...t,floors:t.floors.map(o=>({...o,layers:o.layers.map(n=>({...n,objects:n.objects.map(c=>c.id===s?{...c,...a}:c)}))})),metadata:{...t.metadata,modified:new Date().toISOString()}}}function at(t,s){const a=new Set(s);return{...t,floors:t.floors.map(o=>({...o,layers:o.layers.map(n=>({...n,objects:n.objects.filter(c=>!a.has(c.id))}))})),metadata:{...t.metadata,modified:new Date().toISOString()}}}function ct(t,s,a,o){return{...t,floors:t.floors.map(n=>n.id!==s?n:{...n,layers:n.layers.map(c=>c.name!==a?c:{...c,objects:[...c.objects,o]})}),metadata:{...t.metadata,modified:new Date().toISOString()}}}function Wr(t,s){var a;switch(s.type){case"SET_MODE":{const o=Ze[s.mode];return{...t,mode:s.mode,tool:o.tools.includes(t.tool)?t.tool:o.tools[0],viewport:{...t.viewport,gridSize:o.defaultGridSize}}}case"SET_TOOL":return{...t,tool:s.tool,drawing:{active:!1,points:[],preview:null},connecting:{active:!1,sourceId:null,sourcePosition:null,previewPosition:null}};case"SET_DOCUMENT":return{...t,document:s.document,activeFloorId:((a=s.document.floors[0])==null?void 0:a.id)??null};case"SET_ACTIVE_FLOOR":return{...t,activeFloorId:s.floorId};case"SET_SELECTION":return{...t,selection:s.selection};case"CLEAR_SELECTION":return{...t,selection:{objectIds:[],bounds:null,locked:!1}};case"SET_VIEWPORT":return{...t,viewport:{...t.viewport,...s.viewport}};case"ZOOM":{const o=Math.max(.1,Math.min(10,t.viewport.zoom*(1+s.delta*.1)));return{...t,viewport:{...t.viewport,zoom:o}}}case"PAN":return{...t,viewport:{...t.viewport,pan:{x:t.viewport.pan.x+s.delta.x,y:t.viewport.pan.y+s.delta.y}}};case"RESET_VIEW":return{...t,viewport:{...t.viewport,zoom:1,pan:{x:0,y:0}}};case"TOGGLE_GRID":return{...t,viewport:{...t.viewport,showGrid:!t.viewport.showGrid}};case"TOGGLE_SNAP":return{...t,viewport:{...t.viewport,snapEnabled:!t.viewport.snapEnabled}};case"SET_GRID_SIZE":return{...t,viewport:{...t.viewport,gridSize:s.size}};case"SET_SNAP_MODES":return{...t,viewport:{...t.viewport,snapModes:s.modes}};case"SET_LAYER_VISIBILITY":return{...t,layers:t.layers.map(o=>o.type===s.layerType?{...o,visible:s.visible}:o)};case"SET_LAYER_LOCKED":return{...t,layers:t.layers.map(o=>o.type===s.layerType?{...o,locked:s.locked}:o)};case"SET_LAYER_OPACITY":return{...t,layers:t.layers.map(o=>o.type===s.layerType?{...o,opacity:s.opacity}:o)};case"START_DRAWING":return{...t,drawing:{active:!0,points:[s.point],preview:null}};case"ADD_DRAWING_POINT":return{...t,drawing:{...t.drawing,points:[...t.drawing.points,s.point]}};case"UPDATE_DRAWING_PREVIEW":return{...t,drawing:{...t.drawing,preview:s.point}};case"FINISH_DRAWING":return{...t,drawing:{active:!1,points:[],preview:null}};case"CANCEL_DRAWING":return{...t,drawing:{active:!1,points:[],preview:null}};case"START_CONNECTING":return{...t,connecting:{active:!0,sourceId:s.sourceId,sourcePort:s.sourcePort,sourcePosition:s.sourcePosition,previewPosition:s.sourcePosition}};case"UPDATE_CONNECTING_PREVIEW":return{...t,connecting:{...t.connecting,previewPosition:s.position}};case"FINISH_CONNECTING":return{...t,connecting:{active:!1,sourceId:null,sourcePosition:null,previewPosition:null}};case"CANCEL_CONNECTING":return{...t,connecting:{active:!1,sourceId:null,sourcePosition:null,previewPosition:null}};case"SET_GUIDES":return{...t,guides:s.guides};case"TOGGLE_OBJECT_LIBRARY":return{...t,ui:{...t.ui,showObjectLibrary:!t.ui.showObjectLibrary}};case"TOGGLE_LAYER_PANEL":return{...t,ui:{...t.ui,showLayerPanel:!t.ui.showLayerPanel}};case"TOGGLE_PROPERTIES_PANEL":return{...t,ui:{...t.ui,showPropertiesPanel:!t.ui.showPropertiesPanel}};case"TOGGLE_MINIMAP":return{...t,ui:{...t.ui,showMinimap:!t.ui.showMinimap}};case"ADD_OBJECT":{if(!t.document||!t.activeFloorId)return t;const o=s.object.layer||"devices",n=ct(t.document,t.activeFloorId,o,s.object),c=He("create",[s.object.id],null,s.object);return{...t,document:n,...Ue(t,c)}}case"UPDATE_OBJECT":{if(!t.document)return t;const o=Ee(t.document,s.objectId);if(!o)return t;const n=ot(t.document,s.objectId,s.updates),c=He("update",[s.objectId],o,{...o,...s.updates});return{...t,document:n,...Ue(t,c)}}case"DELETE_OBJECTS":{if(!t.document||s.objectIds.length===0)return t;const o=s.objectIds.map(d=>Ee(t.document,d)).filter(Boolean),n=at(t.document,s.objectIds),c=He("delete",s.objectIds,o,null);return{...t,document:n,selection:{objectIds:[],bounds:null,locked:!1},...Ue(t,c)}}case"MOVE_OBJECTS":{if(!t.document||s.objectIds.length===0)return t;const o=s.objectIds.map(f=>Ee(t.document,f)).filter(Boolean);let n=t.document;for(const f of s.objectIds){const y=Ee(n,f);if(y&&"transform"in y&&y.transform&&"position"in y.transform){const v=y.transform.position;n=ot(n,f,{transform:{...y.transform,position:{x:v.x+s.delta.x,y:v.y+s.delta.y}}})}}const c=s.objectIds.map(f=>Ee(n,f)).filter(Boolean),d=He("move",s.objectIds,o,c);return{...t,document:n,...Ue(t,d)}}case"UNDO":{if(t.history.past.length===0||!t.document)return t;const o=t.history.past[t.history.past.length-1];let n=t.document;switch(o.type){case"create":{n=at(n,o.objectIds);break}case"delete":{const c=o.before;for(const d of c){const f=d.layer||"devices";n=ct(n,t.activeFloorId??n.floors[0].id,f,d)}break}case"update":case"move":{const c=o.before;for(const d of c)n=ot(n,d.id,d);break}}return{...t,document:n,history:{past:t.history.past.slice(0,-1),future:[o,...t.history.future]}}}case"REDO":{if(t.history.future.length===0||!t.document)return t;const o=t.history.future[0];let n=t.document;switch(o.type){case"create":{const c=o.after,d=c.layer||"devices";n=ct(n,t.activeFloorId??n.floors[0].id,d,c);break}case"delete":{n=at(n,o.objectIds);break}case"update":case"move":{const c=o.after;for(const d of c)n=ot(n,d.id,d);break}}return{...t,document:n,history:{past:[...t.history.past,o],future:t.history.future.slice(1)}}}case"COPY":{if(!t.document||t.selection.objectIds.length===0)return t;const o=t.selection.objectIds.map(n=>Ee(t.document,n)).filter(Boolean);return{...t,clipboard:o}}case"CUT":{if(!t.document||t.selection.objectIds.length===0)return t;const o=t.selection.objectIds.map(d=>Ee(t.document,d)).filter(Boolean),n=at(t.document,t.selection.objectIds),c=He("delete",t.selection.objectIds,o,null);return{...t,document:n,clipboard:o,selection:{objectIds:[],bounds:null,locked:!1},...Ue(t,c)}}case"PASTE":{if(!t.document||!t.activeFloorId||t.clipboard.length===0)return t;let o=t.document;const n=[],c=[];for(const f of t.clipboard){const y=`${f.id}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,v=f.transform,u={position:{x:v.position.x+s.position.x+20,y:v.position.y+s.position.y+20},rotation:v.rotation,scale:v.scale},N={...f,id:y,transform:u},b=N.layer||"devices";o=ct(o,t.activeFloorId,b,N),n.push(y),c.push(N)}const d=He("create",n,null,c);return{...t,document:o,selection:{objectIds:n,bounds:null,locked:!1},...Ue(t,d)}}case"START_DRAG":return{...t,dragging:{objectType:s.objectType,objectData:s.objectData,position:null}};case"UPDATE_DRAG_POSITION":return t.dragging?{...t,dragging:{...t.dragging,position:s.position}}:t;case"END_DRAG":return{...t,dragging:null};case"CANCEL_DRAG":return{...t,dragging:null};default:return t}}const Gr=({mode:t,activeTool:s,onToolSelect:a,readOnly:o})=>{const c=Ze[t].tools.map(f=>kt[f]).filter(Boolean),d=["select","draw","place","connect","annotate","measure","edit"];return e.jsx("div",{className:O.toolbar,children:d.map(f=>{const y=c.filter(v=>v.group===f);return y.length===0?null:e.jsx("div",{className:O.toolGroup,children:y.map(({tool:v,icon:u,label:N,shortcut:b})=>e.jsx("button",{title:`${N}${b?` (${b})`:""}`,className:`${O.toolBtn} ${s===v?O.toolBtnActive:""}`,onClick:()=>a(v),disabled:o&&!["select","pan","zoom","measure-distance","measure-angle","measure-area"].includes(v),children:u},v))},f)})})},Fr=({currentMode:t,availableModes:s,onModeChange:a})=>e.jsx("div",{className:O.modeSwitcher,children:s.map(o=>{const n=Ze[o];return e.jsxs("button",{title:n.label,className:`${O.modeBtn} ${t===o?O.modeBtnActive:""}`,onClick:()=>a(o),children:[e.jsx("span",{className:O.modeIcon,children:n.icon}),e.jsx("span",{className:O.modeLabel,children:n.label})]},o)})});function At(t){if(!t)return[];const s=[];for(const a of t.floors)for(const o of a.layers)if(o.type==="network"||o.type==="infrastructure"){for(const n of o.objects)if(n.type==="connection"){const c=n.metadata;c!=null&&c.sourceId&&(c!=null&&c.targetId)&&s.push({id:n.id,sourceId:c.sourceId,sourcePort:c.sourcePort,targetId:c.targetId,targetPort:c.targetPort,medium:c.medium??"ethernet-cat6",status:c.status??"unknown",bandwidth:c.bandwidth,latency:c.latency??1,waypoints:c.waypoints??[]})}}return s}function Vr(t){if(!t)return[];const s=[],a=new Set;for(const o of t.floors)for(const n of o.layers)if(n.type==="network"||n.type==="infrastructure")for(const c of n.objects){const d=c.metadata;if((d==null?void 0:d.vlanId)!==void 0&&!a.has(d.vlanId))a.add(d.vlanId),s.push({id:d.vlanId,name:d.vlanName??`VLAN ${d.vlanId}`,color:d.vlanColor??Hr(d.vlanId),deviceIds:[c.id],subnet:d.subnet,gateway:d.gateway,dhcpEnabled:d.dhcpEnabled});else if((d==null?void 0:d.vlanId)!==void 0){const f=s.find(y=>y.id===d.vlanId);f&&!f.deviceIds.includes(c.id)&&f.deviceIds.push(c.id)}}return s.sort((o,n)=>o.id-n.id)}function Hr(t){const s=["#3b82f6","#22c55e","#f59e0b","#ef4444","#8b5cf6","#ec4899","#06b6d4","#f97316","#14b8a6","#a855f7"];return s[t%s.length]}const Ur=t=>{var Ce,It;const{defaultMode:s="floor-plan",availableModes:a=Object.keys(Ze),readOnly:o=!1,theme:n="light",locale:c="en",onDocumentChange:d,onSelectionChange:f,onModeChange:y,onExport:v,onImport:u,className:N,style:b,cookies:g=!1,localStorage:p=!0,sessionStorage:x=!1,storageMode:j,storageKey:r,persistPreferences:L=!1}=t,h=ss.useStorageAdapter(r??"nice-spatial-editor"),[C]=l.useState(()=>L?h.get("prefs")??{}:{}),[w,i]=l.useReducer(Wr,t,Rr),$=l.useRef(null),E=l.useRef(!1),H=l.useRef({x:0,y:0}),[G,me]=l.useState(!1),[Q,ve]=l.useState(!1),[be,oe]=l.useState(null),[Z,k]=l.useState(null),[F,re]=l.useState(!1),[je,ke]=l.useState(!1),[xe,Te]=l.useState(!1),[Se,De]=l.useState(new Set),[Ye,Re]=l.useState(null),Le=l.useRef(null),We=l.useRef(null),ze=l.useRef(null),{mode:we,tool:he,document:q,activeFloorId:Pe,layers:Me,selection:pe,viewport:ee,drawing:_e,connecting:ce,guides:fe,ui:Be,history:Ke}=w,Ae=Ze[we],Qe=Ke.past.length>0,et=Ke.future.length>0;l.useEffect(()=>{var m,M,P;!L||!C||((C.zoom||C.pan)&&i({type:"SET_VIEWPORT",viewport:{zoom:C.zoom,pan:C.pan,showGrid:(m=C.gridConfig)==null?void 0:m.visible,gridSize:(M=C.gridConfig)==null?void 0:M.size,snapEnabled:(P=C.gridConfig)==null?void 0:P.snapEnabled}}),C.mode&&i({type:"SET_MODE",mode:C.mode}),C.tool&&i({type:"SET_TOOL",tool:C.tool}),C.layerVisibility&&Object.entries(C.layerVisibility).forEach(([D,Y])=>{Y!==void 0&&i({type:"SET_LAYER_VISIBILITY",layerType:D,visible:Y})}))},[]),l.useEffect(()=>{if(!L)return;const m={zoom:ee.zoom,pan:ee.pan,gridConfig:{size:ee.gridSize,visible:ee.showGrid,snapEnabled:ee.snapEnabled},mode:we,tool:he,layerVisibility:Object.fromEntries(Me.map(M=>[M.type,M.visible])),uiPanels:Be};h.set("prefs",m)},[L,ee,we,he,Me,Be,h]);const ue=l.useMemo(()=>(q==null?void 0:q.floors.find(m=>m.id===Pe))??(q==null?void 0:q.floors[0])??null,[q,Pe]),Oe=l.useCallback((m,M)=>{var D;const P=(D=$.current)==null?void 0:D.getBoundingClientRect();return P?{x:(m-P.left-ee.pan.x)/ee.zoom,y:(M-P.top-ee.pan.y)/ee.zoom}:{x:0,y:0}},[ee.pan,ee.zoom]),Ge=l.useCallback(m=>{if(!ee.snapEnabled)return m;const M={cellSize:ee.gridSize,majorInterval:10,origin:{x:0,y:0},visible:ee.showGrid,color:"#e5e7eb",majorColor:"#9ca3af",opacity:1,snapModes:["grid"],snapThreshold:10,angleIncrement:15};return U.snapToGrid(m,M)},[ee.snapEnabled,ee.gridSize,ee.showGrid]),dt=l.useCallback(m=>{if(he==="pan"||m.button===1){E.current=!0,H.current={x:m.clientX,y:m.clientY};return}const M=Ge(Oe(m.clientX,m.clientY));if(he==="draw-zone"||he==="draw-wall"||he==="draw-polyline")_e.active?i({type:"ADD_DRAWING_POINT",point:M}):i({type:"START_DRAWING",point:M});else if(he==="connect"){const P=ue==null?void 0:ue.layers.flatMap(D=>D.objects).find(D=>{if(!D.bounds)return!1;const Y=D.bounds;return M.x>=Y.x&&M.x<=Y.x+Y.width&&M.y>=Y.y&&M.y<=Y.y+Y.height});if(P)if(ce.active){i({type:"FINISH_CONNECTING",targetId:P.id});const D=`conn-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,Y=P.bounds?{x:P.bounds.x+P.bounds.width/2,y:P.bounds.y+P.bounds.height/2}:M,X={id:D,type:"connection",category:"network",name:"Connection",transform:{position:{x:0,y:0},rotation:0,scale:{x:1,y:1}},layer:"network",locked:!1,visible:!0,childIds:[],bounds:{x:Math.min(ce.sourcePosition.x,Y.x),y:Math.min(ce.sourcePosition.y,Y.y),width:Math.abs(Y.x-ce.sourcePosition.x),height:Math.abs(Y.y-ce.sourcePosition.y)},metadata:{sourceId:ce.sourceId,targetId:P.id,sourcePosition:ce.sourcePosition,targetPosition:Y,medium:"ethernet-cat6",status:"active"}};i({type:"ADD_OBJECT",object:X})}else{const D=P.bounds?{x:P.bounds.x+P.bounds.width/2,y:P.bounds.y+P.bounds.height/2}:M;i({type:"START_CONNECTING",sourceId:P.id,sourcePosition:D})}else ce.active&&i({type:"CANCEL_CONNECTING"})}else he==="select"&&i({type:"CLEAR_SELECTION"})},[he,_e.active,ce.active,ce.sourceId,ce.sourcePosition,Ge,Oe,ue]),ut=l.useCallback(m=>{if(E.current){const P=m.clientX-H.current.x,D=m.clientY-H.current.y;i({type:"PAN",delta:{x:P,y:D}}),H.current={x:m.clientX,y:m.clientY};return}const M=Ge(Oe(m.clientX,m.clientY));if(_e.active&&(i({type:"UPDATE_DRAWING_PREVIEW",point:M}),ee.snapEnabled&&ue)){const P=ue.layers.flatMap(X=>X.objects.filter(le=>le.bounds).map(le=>({id:le.id,bounds:le.bounds}))),D={x:M.x,y:M.y,width:1,height:1},Y=U.generateAlignmentGuides(D,P,10);i({type:"SET_GUIDES",guides:Y})}ce.active&&i({type:"UPDATE_CONNECTING_PREVIEW",position:M})},[_e.active,ce.active,Ge,Oe,ee.snapEnabled,ue]),ht=l.useCallback(()=>{E.current=!1},[]),_t=l.useCallback(m=>{_e.active&&_e.points.length>=2&&i({type:"FINISH_DRAWING"})},[_e.active,_e.points.length]),pt=l.useCallback(m=>{m.preventDefault();const M=m.deltaY>0?-1:1;i({type:"ZOOM",delta:M,center:Oe(m.clientX,m.clientY)})},[Oe]),mt=l.useCallback(m=>{m.key==="Escape"&&(_e.active?i({type:"CANCEL_DRAWING"}):ce.active?i({type:"CANCEL_CONNECTING"}):i({type:"CLEAR_SELECTION"})),m.key==="Delete"&&pe.objectIds.length>0&&i({type:"DELETE_OBJECTS",objectIds:pe.objectIds}),(m.ctrlKey||m.metaKey)&&(m.key==="z"&&i({type:"UNDO"}),m.key==="y"&&i({type:"REDO"}),m.key==="c"&&i({type:"COPY"}),m.key==="v"&&i({type:"PASTE",position:{x:0,y:0}}),m.key==="x"&&i({type:"CUT"}))},[_e.active,ce.active,pe.objectIds]),xt=l.useCallback(m=>{i({type:"SET_MODE",mode:m}),y==null||y(m)},[y]),ft=l.useCallback(m=>{i({type:"SET_TOOL",tool:m})},[]),Fe=l.useCallback(async m=>{var M;if(q){me(!1);try{const P={includeGrid:!1,includeDimensions:!0};if(m==="nsp"){const D=U.exportToNSP(q,P);U.downloadExport(D),v==null||v(m,D.data)}else if(m==="svg"){const D=U.exportToSVG(q,P);U.downloadExport(D),v==null||v(m,D.data)}else if(m==="dxf"){const D=U.exportToDXF(q,P);U.downloadExport(D),v==null||v(m,D.data)}else if(m==="png"&&$.current){const D=await U.exportSVGToPNG($.current,((M=q.metadata)==null?void 0:M.name)||"export");U.downloadExport(D),v==null||v(m,D.data)}}catch(P){console.error(`Export to ${m} failed:`,P)}}},[q,v]),gt=l.useCallback(async m=>{var P;const M=(P=m.target.files)==null?void 0:P[0];if(M){ve(!1);try{const D={convertClosedPolylinesToZones:!0,minZoneArea:1},Y=await U.importFromBrowserFile(M,D);Y.success&&Y.document?k(Y):oe(Y),ze.current&&(ze.current.value="")}catch(D){console.error("Import failed:",D),oe({success:!1,warnings:[],errors:[{code:"IMPORT_ERROR",message:D instanceof Error?D.message:"Unknown import error",fatal:!0}],stats:{wallsImported:0,zonesImported:0,objectsImported:0,layersFound:0,entitiesSkipped:0,importTimeMs:0}})}}},[]),yt=l.useCallback(()=>{Z!=null&&Z.success&&Z.document?re(!0):k(null)},[Z]),vt=l.useCallback(()=>{k(null),re(!1)},[]),tt=l.useCallback((m,M)=>{if(!(Z!=null&&Z.document)){re(!1);return}const P=Z.document,D={...P,floors:P.floors.map(Y=>({...Y,layers:Y.layers.filter(X=>m.get(X.id)!=="skip").map(X=>{const le=m.get(X.id);if(le===X.id||!le)return X;const Ie=q==null?void 0:q.floors.flatMap(Ve=>Ve.layers).find(Ve=>Ve.id===le);return Ie?{...X,id:Ie.id,name:Ie.name,type:Ie.type}:X})}))};i({type:"SET_DOCUMENT",document:D}),u==null||u(D),oe(Z),re(!1),k(null)},[Z,q,u]),_=l.useCallback(()=>{re(!1)},[]),I=l.useCallback(m=>{if(ze.current){let M=".dxf,.svg,.geojson,.json,.ifc";m==="dxf"?M=".dxf":m==="svg"?M=".svg":m==="geojson"?M=".geojson,.json":m==="ifc"&&(M=".ifc"),ze.current.accept=M,ze.current.click()}ve(!1)},[]);l.useEffect(()=>{const m=M=>{Le.current&&!Le.current.contains(M.target)&&me(!1),We.current&&!We.current.contains(M.target)&&ve(!1)};return(G||Q)&&document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[G,Q]);const z=l.useCallback(()=>{var Y,X;if(!ee.showGrid||!ue)return null;const m=[],{gridSize:M}=ee,P=((Y=ue.bounds)==null?void 0:Y.width)??1e3,D=((X=ue.bounds)==null?void 0:X.height)??800;for(let le=0;le<=P;le+=M)m.push(e.jsx("line",{x1:le,y1:0,x2:le,y2:D,className:O.gridLine},`v${le}`));for(let le=0;le<=D;le+=M)m.push(e.jsx("line",{x1:0,y1:le,x2:P,y2:le,className:O.gridLine},`h${le}`));return e.jsx("g",{className:O.grid,children:m})},[ee.showGrid,ee.gridSize,ue]),J=l.useCallback(()=>{if(!ue)return null;const m=ue.layers.find(M=>M.name==="zones");return m?e.jsx("g",{className:O.zonesLayer,children:m.objects.map(M=>{const P=M;if(!P.boundary||P.boundary.length<3)return null;const D=P.boundary.map((le,Ie)=>`${Ie===0?"M":"L"}${le.x},${le.y}`).join(" ")+" Z",Y=pe.objectIds.includes(P.id),X=P.boundary.reduce((le,Ie)=>({x:le.x+Ie.x/P.boundary.length,y:le.y+Ie.y/P.boundary.length}),{x:0,y:0});return e.jsxs("g",{className:O.zone,onClick:le=>{le.stopPropagation(),i({type:"SET_SELECTION",selection:{objectIds:[P.id],bounds:null,locked:!1}})},children:[e.jsx("path",{d:D,fill:P.color??"#dbeafe",fillOpacity:.5,stroke:Y?"#2563eb":"#94a3b8",strokeWidth:Y?2:1}),P.name&&e.jsx("text",{x:X.x,y:X.y,textAnchor:"middle",dominantBaseline:"middle",className:O.zoneLabel,children:P.name})]},P.id)})}):null},[ue,pe.objectIds]),ie=l.useCallback(()=>fe.length===0?null:e.jsx("g",{className:O.guides,children:fe.map((m,M)=>e.jsx("line",{x1:m.start.x,y1:m.start.y,x2:m.end.x,y2:m.end.y,className:O.guideLine},M))}),[fe]),te=l.useCallback(()=>{if(!_e.active||_e.points.length===0)return null;const m=[..._e.points];_e.preview&&m.push(_e.preview);const M=m.map((D,Y)=>`${Y===0?"M":"L"}${D.x},${D.y}`).join(" "),P=he==="draw-zone"&&m.length>2;return e.jsxs("g",{className:O.drawingPreview,children:[e.jsx("path",{d:M+(P?" Z":""),fill:P?"rgba(37, 99, 235, 0.1)":"none",stroke:"#2563eb",strokeWidth:2,strokeDasharray:P?"none":"6,3"}),m.map((D,Y)=>e.jsx("circle",{cx:D.x,cy:D.y,r:4,fill:"#2563eb"},Y))]})},[_e,he]),de=l.useCallback(()=>!ce.active||!ce.sourcePosition||!ce.previewPosition?null:e.jsxs("g",{className:O.connectionPreview,children:[e.jsx("line",{x1:ce.sourcePosition.x,y1:ce.sourcePosition.y,x2:ce.previewPosition.x,y2:ce.previewPosition.y,stroke:"#10b981",strokeWidth:2,strokeDasharray:"8,4",markerEnd:"url(#connectionArrow)"}),e.jsx("circle",{cx:ce.sourcePosition.x,cy:ce.sourcePosition.y,r:6,fill:"#10b981"}),e.jsx("circle",{cx:ce.previewPosition.x,cy:ce.previewPosition.y,r:6,fill:"#10b981",fillOpacity:.5,stroke:"#10b981",strokeWidth:2}),e.jsx("defs",{children:e.jsx("marker",{id:"connectionArrow",markerWidth:"10",markerHeight:"10",refX:"9",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:e.jsx("path",{d:"M0,0 L0,6 L9,3 z",fill:"#10b981"})})})]}),[ce]),ge=l.useCallback(()=>{if(!ue)return null;const m=ue.layers.find(Y=>Y.type==="network");if(!m)return null;const M=m.objects.filter(Y=>Y.type==="connection");if(M.length===0)return null;const P={"ethernet-cat5":{color:"#3b82f6",width:2},"ethernet-cat6":{color:"#2563eb",width:2},"ethernet-cat6a":{color:"#1d4ed8",width:2},"ethernet-cat7":{color:"#1e40af",width:3},"fiber-single":{color:"#f59e0b",width:3},"fiber-multi":{color:"#d97706",width:3},"wifi-2.4ghz":{color:"#8b5cf6",dashArray:"6,4",width:2},"wifi-5ghz":{color:"#7c3aed",dashArray:"6,4",width:2},"wifi-6ghz":{color:"#6d28d9",dashArray:"6,4",width:2},default:{color:"#64748b",width:2}},D={active:"#10b981",inactive:"#94a3b8",error:"#ef4444",degraded:"#f59e0b",unknown:"#64748b"};return e.jsx("g",{className:O.connectionsLayer,children:M.map(Y=>{const X=Y.metadata;if(!(X!=null&&X.sourcePosition)||!(X!=null&&X.targetPosition))return null;const le=P[X.medium??"default"]||P.default,Ie=D[X.status??"unknown"]||D.unknown,Ve=pe.objectIds.includes(Y.id);let bt=`M${X.sourcePosition.x},${X.sourcePosition.y}`;if(X.waypoints&&X.waypoints.length>0)for(const st of X.waypoints)bt+=` L${st.x},${st.y}`;return bt+=` L${X.targetPosition.x},${X.targetPosition.y}`,e.jsxs("g",{className:O.connection,onClick:st=>{st.stopPropagation(),i({type:"SET_SELECTION",selection:{objectIds:[Y.id],bounds:null,locked:!1}})},children:[e.jsx("path",{d:bt,fill:"none",stroke:Ve?"#2563eb":le.color,strokeWidth:Ve?le.width+1:le.width,strokeDasharray:le.dashArray,strokeLinecap:"round",strokeLinejoin:"round"}),X.status&&X.status!=="active"&&e.jsx("circle",{cx:(X.sourcePosition.x+X.targetPosition.x)/2,cy:(X.sourcePosition.y+X.targetPosition.y)/2,r:5,fill:Ie}),e.jsx("circle",{cx:X.sourcePosition.x,cy:X.sourcePosition.y,r:4,fill:le.color,stroke:"white",strokeWidth:1}),e.jsx("circle",{cx:X.targetPosition.x,cy:X.targetPosition.y,r:4,fill:le.color,stroke:"white",strokeWidth:1})]},Y.id)})})},[ue,pe.objectIds]);return!q&&!ue?e.jsx("div",{className:`${O.root} ${O[n]} ${N??""}`,style:b,children:e.jsxs("div",{className:O.emptyState,children:[e.jsx("div",{className:O.emptyIcon,children:Ae.icon}),e.jsx("h3",{children:"No Document Open"}),e.jsx("p",{children:"Create a new document or open an existing .nsp.json file"}),e.jsx("button",{className:O.primaryBtn,onClick:()=>{const m=U.createFloorPlanDocument("New Project","floor-plan");i({type:"SET_DOCUMENT",document:m})},children:"Create New Document"})]})}):e.jsxs("div",{className:`${O.root} ${O[n]} ${N??""}`,style:b,tabIndex:0,onKeyDown:mt,children:[e.jsxs("div",{className:O.topBar,children:[e.jsx(Fr,{currentMode:we,availableModes:a,onModeChange:xt}),q&&q.floors.length>1&&e.jsx("div",{className:O.floorTabs,children:q.floors.map(m=>e.jsx("button",{className:`${O.floorTab} ${Pe===m.id?O.floorTabActive:""}`,onClick:()=>i({type:"SET_ACTIVE_FLOOR",floorId:m.id}),children:m.name},m.id))}),e.jsxs("div",{className:O.viewportControls,children:[!o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{title:"Undo (Ctrl+Z)",onClick:()=>i({type:"UNDO"}),disabled:!Qe,className:Qe?"":O.disabled,children:"↶"}),e.jsx("button",{title:"Redo (Ctrl+Y)",onClick:()=>i({type:"REDO"}),disabled:!et,className:et?"":O.disabled,children:"↷"}),e.jsx("div",{className:O.separator})]}),e.jsx("button",{title:"Toggle Grid",onClick:()=>i({type:"TOGGLE_GRID"}),className:ee.showGrid?O.active:"",children:"⊞"}),e.jsx("button",{title:"Toggle Snap",onClick:()=>i({type:"TOGGLE_SNAP"}),className:ee.snapEnabled?O.active:"",children:"🧲"}),e.jsxs("span",{className:O.zoomLevel,children:[Math.round(ee.zoom*100),"%"]}),e.jsx("button",{title:"Zoom In",onClick:()=>i({type:"ZOOM",delta:1}),children:"+"}),e.jsx("button",{title:"Zoom Out",onClick:()=>i({type:"ZOOM",delta:-1}),children:"−"}),e.jsx("button",{title:"Reset View",onClick:()=>i({type:"RESET_VIEW"}),children:"⊡"}),!o&&e.jsxs("div",{className:O.exportDropdown,ref:We,children:[e.jsx("input",{type:"file",ref:ze,onChange:gt,style:{display:"none"}}),e.jsx("button",{title:"Import",onClick:()=>ve(!Q),className:Q?O.active:"",children:"📥 Import"}),Q&&e.jsxs("div",{className:O.exportMenu,children:[e.jsx("button",{onClick:()=>I(),children:"📄 Auto-detect format"}),e.jsx("button",{onClick:()=>I("dxf"),children:"📐 AutoCAD DXF (.dxf)"}),e.jsx("button",{onClick:()=>I("svg"),children:"🖼️ SVG Vector Graphics (.svg)"}),e.jsx("button",{onClick:()=>I("geojson"),children:"🌍 GeoJSON (.geojson)"}),e.jsx("button",{onClick:()=>I("ifc"),children:"🏗️ IFC (BIM) (.ifc)"})]})]}),q&&e.jsxs("div",{className:O.exportDropdown,ref:Le,children:[e.jsx("button",{title:"Export",onClick:()=>me(!G),className:G?O.active:"",children:"📤 Export"}),G&&e.jsxs("div",{className:O.exportMenu,children:[e.jsx("button",{onClick:()=>Fe("nsp"),children:"📄 NiceToDev Spatial Plan (.nsp.json)"}),e.jsx("button",{onClick:()=>Fe("svg"),children:"🖼️ SVG Vector Graphics (.svg)"}),e.jsx("button",{onClick:()=>Fe("dxf"),children:"📐 AutoCAD DXF (.dxf)"}),e.jsx("button",{onClick:()=>Fe("png"),children:"🖼️ PNG Image (.png)"})]})]})]})]}),e.jsxs("div",{className:O.mainContent,children:[Be.showObjectLibrary&&!o&&e.jsx(Kt,{mode:we,onObjectSelect:m=>{i({type:"SET_TOOL",tool:`place-${m.category}`}),i({type:"START_DRAG",objectType:m.category,objectData:m})}}),e.jsxs("div",{className:O.editorContainer,children:[!o&&e.jsx(Gr,{mode:we,activeTool:he,onToolSelect:ft,readOnly:o}),(we==="network-topology"||we==="infrastructure")&&e.jsxs("div",{className:O.modeActions,children:[e.jsx("button",{className:`${O.actionBtn} ${je?O.active:""}`,onClick:()=>ke(!je),title:"Analiza ścieżki sieciowej",children:"📊 Analiza ścieżki"}),e.jsx("button",{className:`${O.actionBtn} ${xe?O.active:""}`,onClick:()=>Te(!xe),title:"Nakładka VLAN",children:"🌐 VLAN Overlay"})]}),e.jsxs("div",{className:O.canvasWrapper,children:[e.jsx("svg",{ref:$,className:`${O.canvas} ${O[`cursor_${he.replace("-","_")}`]??""}`,onMouseDown:dt,onMouseMove:ut,onMouseUp:ht,onDoubleClick:_t,onWheel:pt,children:e.jsxs("g",{transform:`translate(${ee.pan.x}, ${ee.pan.y}) scale(${ee.zoom})`,children:[z(),J(),ge(),ie(),te(),de()]})}),Be.showMinimap&&e.jsx(Yt,{document:q,activeFloorId:Pe,viewport:ee,onViewportChange:m=>i({type:"SET_VIEWPORT",viewport:m})})]})]}),e.jsxs("div",{className:O.rightSidebar,children:[Be.showLayerPanel&&e.jsx(Zt,{layers:Me.filter(m=>Ae.layerTypes.includes(m.type)),onVisibilityToggle:m=>{var M;return i({type:"SET_LAYER_VISIBILITY",layerType:m,visible:!((M=Me.find(P=>P.type===m))!=null&&M.visible)})},onLockToggle:m=>{var M;return i({type:"SET_LAYER_LOCKED",layerType:m,locked:!((M=Me.find(P=>P.type===m))!=null&&M.locked)})},onOpacityChange:(m,M)=>i({type:"SET_LAYER_OPACITY",layerType:m,opacity:M})}),Be.showPropertiesPanel&&pe.objectIds.length>0&&e.jsx(Xt,{selection:pe,document:q,onPropertyChange:(m,M,P)=>{i({type:"UPDATE_OBJECT",objectId:m,updates:{[M]:P}})}})]})]}),e.jsxs("div",{className:O.statusBar,children:[e.jsxs("span",{className:O.modeIndicator,children:[Ae.icon," ",Ae.label]}),e.jsxs("span",{className:O.toolIndicator,children:[(Ce=kt[he])==null?void 0:Ce.icon," ",(It=kt[he])==null?void 0:It.label]}),pe.objectIds.length>0&&e.jsxs("span",{className:O.selectionInfo,children:[pe.objectIds.length," selected"]}),_e.active&&e.jsxs("span",{className:O.drawingInfo,children:["Drawing: ",_e.points.length," points"]}),ce.active&&e.jsx("span",{className:O.connectingInfo,children:"Connecting: click target device or ESC to cancel"}),e.jsxs("span",{className:O.gridInfo,children:["Grid: ",ee.gridSize,"px | Snap: ",ee.snapEnabled?"ON":"OFF"]})]}),Z&&!F&&e.jsx(Bn,{result:Z,onConfirm:yt,onCancel:vt}),Z&&F&&e.jsx(lo,{importResult:Z,existingDocument:q??void 0,onConfirm:tt,onCancel:_}),je&&q&&e.jsx(ba,{document:q,connections:At(q),onHighlightPath:m=>{i(m?{type:"SET_SELECTION",selection:{objectIds:m.connectionIds,bounds:null,locked:!1}}:{type:"SET_SELECTION",selection:{objectIds:[],bounds:null,locked:!1}})},onClose:()=>ke(!1)}),xe&&q&&e.jsx(hl,{document:q,connections:At(q),vlans:Vr(q),visibleVlanIds:Se,onVlanVisibilityChange:(m,M)=>{De(P=>{const D=new Set(P);return M?D.add(m):D.delete(m),D})},onHighlightVlan:m=>{Re((m==null?void 0:m.id)??null),i(m?{type:"SET_SELECTION",selection:{objectIds:m.deviceIds,bounds:null,locked:!1}}:{type:"SET_SELECTION",selection:{objectIds:[],bounds:null,locked:!1}})},onClose:()=>Te(!1)})]})},Zr="_viewer_ug28h_13",Yr="_theme_light_ug28h_37",Kr="_theme_dark_ug28h_59",Xr="_debugOverlay_ug28h_85",Jr="_topBar_ug28h_137",qr="_searchContainer_ug28h_159",Qr="_searchInput_ug28h_171",ei="_clearBtn_ug28h_227",ti="_searchResults_ug28h_261",si="_searchResultItem_ug28h_291",ni="_searchResultInfo_ug28h_335",oi="_searchResultName_ug28h_347",ai="_searchResultDesc_ug28h_357",ci="_floorSelector_ug28h_371",li="_navBtn_ug28h_421",ri="_active_ug28h_459",ii="_layersBtn_ug28h_475",di="_legendBtn_ug28h_529",ui="_content_ug28h_583",hi="_navPanel_ug28h_599",_i="_navPanelHeader_ug28h_617",pi="_routeInputs_ug28h_671",mi="_routeInput_ug28h_671",xi="_routeMarker_ug28h_705",fi="_routeHint_ug28h_745",gi="_routeInfo_ug28h_761",yi="_routeStat_ug28h_779",vi="_routeStatLabel_ug28h_791",bi="_routeStatValue_ug28h_805",ji="_clearRouteBtn_ug28h_817",wi="_refPointsList_ug28h_851",Ni="_refPointItem_ug28h_879",ki="_refPointIcon_ug28h_917",Ci="_layersPanel_ug28h_929",Ii="_layersPanelHeader_ug28h_947",Si="_layersList_ug28h_1001",Li="_layerItem_ug28h_1015",zi="_layerToggle_ug28h_1039",$i="_layerName_ug28h_1075",Bi="_layerType_ug28h_1087",Ti="_canvasWrapper_ug28h_1101",Pi="_canvas_ug28h_1101",Mi="_grid_ug28h_1137",Oi="_gridLine_ug28h_1145",Ai="_zonesLayer_ug28h_1161",Ei="_zone_ug28h_1161",Di="_zoneSelected_ug28h_1185",Ri="_zoneLabel_ug28h_1195",Wi="_objectsLayer_ug28h_1211",Gi="_object_ug28h_1211",Fi="_objectSelected_ug28h_1233",Vi="_objectLabel_ug28h_1241",Hi="_referencePoints_ug28h_1257",Ui="_referencePoint_ug28h_1257",Zi="_refLabel_ug28h_1277",Yi="_routeLayer_ug28h_1293",Ki="_routePath_ug28h_1297",Xi="_routeDash_ug28h_1",Ji="_routeMarkers_ug28h_1323",qi="_currentLocation_ug28h_1331",Qi="_locationPulse_ug28h_1335",ed="_pulse_ug28h_1",td="_zoomControls_ug28h_1369",sd="_minimap_ug28h_1445",nd="_minimapContent_ug28h_1471",od="_minimapViewport_ug28h_1485",ad="_legendPanel_ug28h_1505",cd="_legendPanelHeader_ug28h_1537",ld="_legendList_ug28h_1593",rd="_legendItem_ug28h_1609",id="_legendColor_ug28h_1633",dd="_legendIcon_ug28h_1649",ud="_legendLabel_ug28h_1663",hd="_legendType_ug28h_1675",_d="_objectInfo_ug28h_1693",pd="_objectInfoHeader_ug28h_1721",md="_navigateBtn_ug28h_1791",S={viewer:Zr,theme_light:Yr,theme_dark:Kr,debugOverlay:Xr,topBar:Jr,searchContainer:qr,searchInput:Qr,clearBtn:ei,searchResults:ti,searchResultItem:si,searchResultInfo:ni,searchResultName:oi,searchResultDesc:ai,floorSelector:ci,navBtn:li,active:ri,layersBtn:ii,legendBtn:di,content:ui,navPanel:hi,navPanelHeader:_i,routeInputs:pi,routeInput:mi,routeMarker:xi,routeHint:fi,routeInfo:gi,routeStat:yi,routeStatLabel:vi,routeStatValue:bi,clearRouteBtn:ji,refPointsList:wi,refPointItem:Ni,refPointIcon:ki,layersPanel:Ci,layersPanelHeader:Ii,layersList:Si,layerItem:Li,layerToggle:zi,layerName:$i,layerType:Bi,canvasWrapper:Ti,canvas:Pi,grid:Mi,gridLine:Oi,zonesLayer:Ai,zone:Ei,zoneSelected:Di,zoneLabel:Ri,objectsLayer:Wi,object:Gi,objectSelected:Fi,objectLabel:Vi,referencePoints:Hi,referencePoint:Ui,refLabel:Zi,routeLayer:Yi,routePath:Ki,routeDash:Xi,routeMarkers:Ji,currentLocation:qi,locationPulse:Qi,pulse:ed,zoomControls:td,minimap:sd,minimapContent:nd,minimapViewport:od,legendPanel:ad,legendPanelHeader:cd,legendList:ld,legendItem:rd,legendColor:id,legendIcon:dd,legendLabel:ud,legendType:hd,objectInfo:_d,objectInfoHeader:pd,navigateBtn:md},xd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"7",cy:"7",r:"5"}),e.jsx("path",{d:"M11 11l3 3",strokeLinecap:"round"})]}),Et=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M8 1l6 14-6-4-6 4 6-14z"})}),fd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"8",cy:"6",r:"3"}),e.jsx("path",{d:"M8 15c4-4 6-6.7 6-9a6 6 0 10-12 0c0 2.3 2 5 6 9z"})]}),gd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"1"}),e.jsx("line",{x1:"2",y1:"6",x2:"14",y2:"6"}),e.jsx("line",{x1:"2",y1:"10",x2:"14",y2:"10"})]}),yd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"4",cy:"4",r:"2"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"}),e.jsx("path",{d:"M6 4h4a2 2 0 012 2v4",strokeLinecap:"round"})]}),vd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"7",cy:"7",r:"5"}),e.jsx("path",{d:"M11 11l3 3M7 5v4M5 7h4",strokeLinecap:"round"})]}),bd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"7",cy:"7",r:"5"}),e.jsx("path",{d:"M11 11l3 3M5 7h4",strokeLinecap:"round"})]}),Xe=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M12 4L4 12M4 4l8 8",strokeLinecap:"round"})}),Dt=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M2 6l6-4 6 4-6 4-6-4z"}),e.jsx("path",{d:"M2 10l6 4 6-4"}),e.jsx("path",{d:"M2 8l6 4 6-4",opacity:"0.5"})]}),Rt=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"2",y:"3",width:"4",height:"3",rx:"0.5",fill:"currentColor",opacity:"0.3"}),e.jsx("rect",{x:"2",y:"8",width:"4",height:"3",rx:"0.5",fill:"currentColor",opacity:"0.3"}),e.jsx("line",{x1:"8",y1:"4.5",x2:"14",y2:"4.5"}),e.jsx("line",{x1:"8",y1:"9.5",x2:"14",y2:"9.5"})]}),jd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M1 8c1.5-3 4-5 7-5s5.5 2 7 5c-1.5 3-4 5-7 5s-5.5-2-7-5z"}),e.jsx("circle",{cx:"8",cy:"8",r:"2"})]}),wd=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M6.5 6.5a2 2 0 012.8 2.8M3 3l10 10",strokeLinecap:"round"}),e.jsx("path",{d:"M4.5 5.5C2.8 6.8 1.5 8 1 8c1.5 3 4 5 7 5 1 0 2-.3 3-.7"}),e.jsx("path",{d:"M12.5 9.5c1-.9 2-2 2.5-3-1.5-3-4-5-7-5-.6 0-1.2.1-1.8.2"})]});function Nd(t,s){return Math.sqrt((s.x-t.x)**2+(s.y-t.y)**2)}function kd(t){return t<1?"<1m":t<1e3?`${Math.round(t)}m`:`${(t/1e3).toFixed(1)}km`}function Cd(t){if(t<60)return"<1 min";const s=Math.round(t/60);if(s<60)return`${s} min`;const a=Math.floor(s/60),o=s%60;return`${a}h ${o}min`}const Id=({document:t,initialFloorId:s,showNavigation:a=!0,showMinimap:o=!0,showFloorSelector:n=!0,showSearch:c=!0,showLayersPanel:d=!0,showLegend:f=!0,enableRoutePlanning:y=!0,referencePoints:v=[],onObjectClick:u,onRouteCalculated:N,currentLocation:b,theme:g="light",className:p,virtualRendering:x,virtualRenderingThreshold:j=200,debugVirtualRendering:r=!1})=>{var tt;const[L,h]=l.useState(s??((tt=t.floors[0])==null?void 0:tt.id)??""),[C,w]=l.useState({zoom:1,pan:{x:0,y:0}}),[i,$]=l.useState(""),[E,H]=l.useState([]),[G,me]=l.useState(null),[Q,ve]=l.useState(null),[be,oe]=l.useState(null),[Z,k]=l.useState(null),[F,re]=l.useState(!1),[je,ke]=l.useState(!1),[xe,Te]=l.useState(!1),[Se,De]=l.useState(new Map),[Ye,Re]=l.useState({width:1e3,height:600}),Le=l.useRef(null),We=l.useRef(null),ze=l.useRef(!1),we=l.useRef({x:0,y:0}),he=l.useMemo(()=>{const _=t.floors.find(I=>I.id===L);return _?_.layers.reduce((I,z)=>{var J;return I+(((J=z.objects)==null?void 0:J.length)??0)},0):0},[t.floors,L]),q=x??U.shouldUseVirtualRendering(he,j),Pe=l.useMemo(()=>{if(!q)return null;const _=t.floors.find(z=>z.id===L);if(!_)return null;const I=[];for(const z of _.layers)if(!(z.type==="zones"||z.type==="grid"||z.type==="background"))for(const J of z.objects??[]){const ie=J.position??{x:0,y:0},te=J.size??{width:20,height:20};I.push({id:J.id,position:ie,size:te,data:{object:J,layerId:z.id}})}return U.createFloorPlanQuadTree(I)},[t.floors,L,q]),Me=l.useMemo(()=>U.calculateVisibleBounds(C,Ye,100),[C,Ye]),pe=l.useMemo(()=>!q||!Pe?null:Pe.query(Me),[q,Pe,Me]),ee=l.useMemo(()=>!r||!q?null:U.calculateRenderStats(he,(pe==null?void 0:pe.length)??he,C),[r,q,he,pe,C]);l.useEffect(()=>{const _=We.current;if(!_)return;const I=new ResizeObserver(z=>{for(const J of z)Re({width:J.contentRect.width,height:J.contentRect.height})});return I.observe(_),()=>I.disconnect()},[]),l.useEffect(()=>{const _=t.floors.find(I=>I.id===L);if(_){const I=new Map;for(const z of _.layers)I.set(z.id,Se.get(z.id)??!0);De(I)}},[L,t.floors]);const _e=l.useCallback(_=>{De(I=>{const z=new Map(I);return z.set(_,!I.get(_)),z})},[]),ce=l.useCallback(_=>Se.get(_)!==!1,[Se]),fe=l.useMemo(()=>t.floors.find(_=>_.id===L)??t.floors[0],[t.floors,L]),Be=l.useMemo(()=>{if(!fe)return[];const _=[],I=fe.layers.find(te=>te.type==="zones");if(I){const te=new Map;for(const de of I.objects){const ge=de.metadata,Ce=(ge==null?void 0:ge.zoneType)??de.type??"zone";te.has(Ce)||te.set(Ce,(ge==null?void 0:ge.fill)??"#3b82f6")}for(const[de,ge]of te)_.push({id:`zone-${de}`,label:de.charAt(0).toUpperCase()+de.slice(1).replace(/-/g," "),color:ge,type:"zone"})}const z=new Map;for(const te of fe.layers)if(!(te.type==="zones"||te.type==="grid"||te.type==="background"))for(const de of te.objects){const ge=de.type??"object",Ce=z.get(ge);Ce?Ce.count++:z.set(ge,{count:1,color:"#64748b"})}for(const[te,de]of z)_.push({id:`obj-${te}`,label:`${te.charAt(0).toUpperCase()+te.slice(1).replace(/-/g," ")} (${de.count})`,color:de.color,type:"object"});const J=new Map,ie={entrance:"🚪",elevator:"🛗",stairs:"🪜",exit:"🚨",poi:"📍",parking:"🅿️"};for(const te of v.filter(de=>de.floorId===L))J.has(te.type)||J.set(te.type,ie[te.type]??"📍");for(const[te,de]of J)_.push({id:`ref-${te}`,label:te.charAt(0).toUpperCase()+te.slice(1),color:"#3b82f6",icon:de,type:"reference"});return _},[fe,v,L]),Ke=l.useCallback((_,I)=>{var J;const z=(J=Le.current)==null?void 0:J.getBoundingClientRect();return z?{x:(_-z.left-C.pan.x)/C.zoom,y:(I-z.top-C.pan.y)/C.zoom}:{x:0,y:0}},[C]);l.useEffect(()=>{if(!i.trim()){H([]);return}const _=i.toLowerCase(),I=[];for(const z of t.floors)for(const J of z.layers)for(const ie of J.objects){const te=(ie.name??ie.id).toLowerCase(),de=(ie.description??"").toLowerCase();(te.includes(_)||de.includes(_))&&I.push(ie)}H(I.slice(0,10))},[i,t.floors]);const Ae=l.useCallback((_,I)=>{const z=Nd(_,I);return{id:`route-${Date.now()}`,startPoint:_,endPoint:I,path:[_,I],floorTransitions:[],totalDistance:z,estimatedTime:z/1.4,instructions:[{type:"straight",distance:z,direction:"forward"},{type:"arrive"}]}},[]);l.useEffect(()=>{if(Q&&be){const _=Ae(Q,be);k(_),N==null||N(_)}else k(null),N==null||N(null)},[Q,be,Ae,N]);const Qe=l.useCallback(_=>{(_.button===1||_.button===0&&_.altKey)&&(ze.current=!0,we.current={x:_.clientX,y:_.clientY},_.preventDefault())},[]),et=l.useCallback(_=>{if(ze.current){const I=_.clientX-we.current.x,z=_.clientY-we.current.y;we.current={x:_.clientX,y:_.clientY},w(J=>({...J,pan:{x:J.pan.x+I,y:J.pan.y+z}}))}},[]),ue=l.useCallback(()=>{ze.current=!1},[]),Oe=l.useCallback(_=>{var te;_.preventDefault();const I=_.deltaY>0?.9:1.1,z=(te=Le.current)==null?void 0:te.getBoundingClientRect();if(!z)return;const J=_.clientX-z.left,ie=_.clientY-z.top;w(de=>{const ge=Math.min(Math.max(de.zoom*I,.1),10),Ce=ge/de.zoom;return{zoom:ge,pan:{x:J-(J-de.pan.x)*Ce,y:ie-(ie-de.pan.y)*Ce}}})},[]),Ge=l.useCallback(_=>{if(y&&_.ctrlKey){const I=Ke(_.clientX,_.clientY);Q?be?(ve(I),oe(null)):oe(I):ve(I)}},[y,Q,be,Ke]),dt=l.useCallback(()=>{w(_=>({..._,zoom:Math.min(_.zoom*1.25,10)}))},[]),ut=l.useCallback(()=>{w(_=>({..._,zoom:Math.max(_.zoom/1.25,.1)}))},[]),ht=l.useCallback(()=>{w({zoom:1,pan:{x:0,y:0}})},[]),_t=l.useCallback(_=>{me(_);for(const z of t.floors)for(const J of z.layers)if(J.objects.find(ie=>ie.id===_.id)){h(z.id);break}const I=_.position??{x:0,y:0};w(z=>({...z,pan:{x:-(I.x*z.zoom)+400,y:-(I.y*z.zoom)+300}})),$(""),H([]),u==null||u(_)},[t.floors,u]),pt=l.useCallback(()=>{ve(null),oe(null),k(null)},[]),mt=l.useCallback(()=>{const I=[];for(let z=-2e3;z<=2e3;z+=50)I.push(e.jsx("line",{x1:z,y1:-2e3,x2:z,y2:2e3,className:S.gridLine},`v-${z}`));for(let z=-2e3;z<=2e3;z+=50)I.push(e.jsx("line",{x1:-2e3,y1:z,x2:2e3,y2:z,className:S.gridLine},`h-${z}`));return e.jsx("g",{className:S.grid,children:I})},[]),xt=l.useCallback(()=>{if(!fe)return null;const _=fe.layers.find(I=>I.type==="zones");return!_||!ce(_.id)?null:e.jsx("g",{className:S.zonesLayer,children:_.objects.map(I=>{const z=I.metadata;if(!(z!=null&&z.points)||z.points.length<3)return null;const J=`M${z.points.map(te=>`${te.x},${te.y}`).join(" L")} Z`,ie=(G==null?void 0:G.id)===I.id;return e.jsxs("g",{className:`${S.zone} ${ie?S.zoneSelected:""}`,onClick:()=>{me(I),u==null||u(I)},children:[e.jsx("path",{d:J,fill:z.fill??"#3b82f6",fillOpacity:.2,stroke:z.fill??"#3b82f6",strokeWidth:ie?2:1}),I.name&&e.jsx("text",{x:z.points[0].x+10,y:z.points[0].y+20,className:S.zoneLabel,children:I.name})]},I.id)})})},[fe,G,u,ce]),ft=l.useCallback(()=>fe?q&&pe?e.jsx("g",{className:S.objectsLayer,children:pe.map(_=>{const{object:I,layerId:z}=_.data;if(!ce(z))return null;const J=I.position??{x:0,y:0},ie=I.size??{width:20,height:20},te=(G==null?void 0:G.id)===I.id;return e.jsxs("g",{className:`${S.object} ${te?S.objectSelected:""}`,transform:`translate(${J.x}, ${J.y})`,onClick:de=>{de.stopPropagation(),me(I),u==null||u(I)},children:[e.jsx("rect",{x:-ie.width/2,y:-ie.height/2,width:ie.width,height:ie.height,rx:4,fill:te?"#3b82f6":"#64748b",fillOpacity:.8,stroke:te?"#1d4ed8":"transparent",strokeWidth:2}),I.name&&e.jsx("text",{y:ie.height/2+14,textAnchor:"middle",className:S.objectLabel,children:I.name})]},I.id)})}):e.jsx("g",{className:S.objectsLayer,children:fe.layers.map(_=>_.type==="zones"||_.type==="grid"||_.type==="background"||!ce(_.id)?null:_.objects.map(I=>{const z=I.position??{x:0,y:0},J=I.size??{width:20,height:20},ie=(G==null?void 0:G.id)===I.id;return e.jsxs("g",{className:`${S.object} ${ie?S.objectSelected:""}`,transform:`translate(${z.x}, ${z.y})`,onClick:te=>{te.stopPropagation(),me(I),u==null||u(I)},children:[e.jsx("rect",{x:-J.width/2,y:-J.height/2,width:J.width,height:J.height,rx:4,fill:ie?"#3b82f6":"#64748b",fillOpacity:.8,stroke:ie?"#1d4ed8":"transparent",strokeWidth:2}),I.name&&e.jsx("text",{y:J.height/2+14,textAnchor:"middle",className:S.objectLabel,children:I.name})]},I.id)}))}):null,[fe,G,u,ce,q,pe]),Fe=l.useCallback(()=>{const _=v.filter(z=>z.floorId===L),I={entrance:"🚪",elevator:"🛗",stairs:"🪜",exit:"🚨",poi:"📍",parking:"🅿️"};return e.jsx("g",{className:S.referencePoints,children:_.map(z=>e.jsxs("g",{className:S.referencePoint,transform:`translate(${z.position.x}, ${z.position.y})`,onClick:()=>{y&&(Q?oe(z.position):ve(z.position))},children:[e.jsx("circle",{r:16,fill:"white",stroke:"#3b82f6",strokeWidth:2}),e.jsx("text",{y:5,textAnchor:"middle",fontSize:"16",children:z.icon??I[z.type]??"📍"}),e.jsx("text",{y:30,textAnchor:"middle",className:S.refLabel,children:z.name})]},z.id))})},[v,L,y,Q]),gt=l.useCallback(()=>{if(!Z)return null;const _=`M${Z.path.map(I=>`${I.x},${I.y}`).join(" L")}`;return e.jsxs("g",{className:S.routeLayer,children:[e.jsx("path",{d:_,fill:"none",stroke:"#3b82f6",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"12,6",className:S.routePath}),e.jsx("circle",{cx:Z.startPoint.x,cy:Z.startPoint.y,r:8,fill:"#10b981",stroke:"white",strokeWidth:2}),e.jsx("circle",{cx:Z.endPoint.x,cy:Z.endPoint.y,r:8,fill:"#ef4444",stroke:"white",strokeWidth:2})]})},[Z]),yt=l.useCallback(()=>b?e.jsxs("g",{className:S.currentLocation,children:[e.jsx("circle",{cx:b.x,cy:b.y,r:12,fill:"#3b82f6",fillOpacity:.3,className:S.locationPulse}),e.jsx("circle",{cx:b.x,cy:b.y,r:6,fill:"#3b82f6",stroke:"white",strokeWidth:2})]}):null,[b]),vt=l.useCallback(()=>e.jsx("g",{className:S.routeMarkers,children:Q&&!Z&&e.jsx("circle",{cx:Q.x,cy:Q.y,r:8,fill:"#10b981",stroke:"white",strokeWidth:2})}),[Q,Z]);return e.jsxs("div",{ref:We,className:`${S.viewer} ${S[`theme_${g}`]} ${p??""}`,children:[r&&ee&&e.jsxs("div",{className:S.debugOverlay,children:[e.jsx("div",{children:"Virtual: ON"}),e.jsxs("div",{children:["Total: ",ee.total]}),e.jsxs("div",{children:["Visible: ",ee.visible]}),e.jsxs("div",{children:["Culled: ",ee.culled," (",ee.cullPercentage,"%)"]}),e.jsxs("div",{children:["Zoom: ",ee.zoom.toFixed(2),"x"]})]}),e.jsxs("div",{className:S.topBar,children:[c&&e.jsxs("div",{className:S.searchContainer,children:[e.jsxs("div",{className:S.searchInput,children:[e.jsx(xd,{}),e.jsx("input",{type:"text",placeholder:"Szukaj lokalizacji...",value:i,onChange:_=>$(_.target.value)}),i&&e.jsx("button",{className:S.clearBtn,onClick:()=>$(""),children:e.jsx(Xe,{})})]}),E.length>0&&e.jsx("div",{className:S.searchResults,children:E.map(_=>e.jsxs("button",{className:S.searchResultItem,onClick:()=>_t(_),children:[e.jsx(fd,{}),e.jsxs("div",{className:S.searchResultInfo,children:[e.jsx("span",{className:S.searchResultName,children:_.name??_.id}),_.description&&e.jsx("span",{className:S.searchResultDesc,children:_.description})]})]},_.id))})]}),n&&t.floors.length>1&&e.jsxs("div",{className:S.floorSelector,children:[e.jsx(gd,{}),e.jsx("select",{value:L,onChange:_=>h(_.target.value),children:t.floors.map(_=>e.jsx("option",{value:_.id,children:_.name??`Piętro ${_.level}`},_.id))})]}),a&&e.jsxs("button",{className:`${S.navBtn} ${F?S.active:""}`,onClick:()=>re(!F),children:[e.jsx(Et,{}),e.jsx("span",{children:"Nawigacja"})]}),d&&e.jsxs("button",{className:`${S.layersBtn} ${je?S.active:""}`,onClick:()=>ke(!je),children:[e.jsx(Dt,{}),e.jsx("span",{children:"Warstwy"})]}),f&&e.jsxs("button",{className:`${S.legendBtn} ${xe?S.active:""}`,onClick:()=>Te(!xe),children:[e.jsx(Rt,{}),e.jsx("span",{children:"Legenda"})]})]}),e.jsxs("div",{className:S.content,children:[F&&e.jsxs("div",{className:S.navPanel,children:[e.jsxs("div",{className:S.navPanelHeader,children:[e.jsx(yd,{}),e.jsx("span",{children:"Planowanie trasy"}),e.jsx("button",{onClick:()=>re(!1),children:e.jsx(Xe,{})})]}),e.jsxs("div",{className:S.routeInputs,children:[e.jsxs("div",{className:S.routeInput,children:[e.jsx("div",{className:S.routeMarker,style:{background:"#10b981"}}),e.jsx("input",{type:"text",placeholder:"Punkt startowy",value:Q?`${Q.x.toFixed(0)}, ${Q.y.toFixed(0)}`:"",readOnly:!0})]}),e.jsxs("div",{className:S.routeInput,children:[e.jsx("div",{className:S.routeMarker,style:{background:"#ef4444"}}),e.jsx("input",{type:"text",placeholder:"Punkt docelowy",value:be?`${be.x.toFixed(0)}, ${be.y.toFixed(0)}`:"",readOnly:!0})]})]}),e.jsx("p",{className:S.routeHint,children:"Ctrl+kliknięcie na mapie, aby wybrać punkty"}),Z&&e.jsxs("div",{className:S.routeInfo,children:[e.jsxs("div",{className:S.routeStat,children:[e.jsx("span",{className:S.routeStatLabel,children:"Dystans"}),e.jsx("span",{className:S.routeStatValue,children:kd(Z.totalDistance)})]}),e.jsxs("div",{className:S.routeStat,children:[e.jsx("span",{className:S.routeStatLabel,children:"Czas"}),e.jsx("span",{className:S.routeStatValue,children:Cd(Z.estimatedTime)})]})]}),(Q||be)&&e.jsx("button",{className:S.clearRouteBtn,onClick:pt,children:"Wyczyść trasę"}),v.length>0&&e.jsxs("div",{className:S.refPointsList,children:[e.jsx("h4",{children:"Punkty odniesienia"}),v.filter(_=>_.floorId===L).map(_=>e.jsxs("button",{className:S.refPointItem,onClick:()=>{Q?oe(_.position):ve(_.position)},children:[e.jsx("span",{className:S.refPointIcon,children:_.icon??"📍"}),e.jsx("span",{children:_.name})]},_.id))]})]}),je&&fe&&e.jsxs("div",{className:S.layersPanel,children:[e.jsxs("div",{className:S.layersPanelHeader,children:[e.jsx(Dt,{}),e.jsx("span",{children:"Warstwy"}),e.jsx("button",{onClick:()=>ke(!1),children:e.jsx(Xe,{})})]}),e.jsx("div",{className:S.layersList,children:fe.layers.map(_=>{const I=ce(_.id);return e.jsxs("div",{className:S.layerItem,children:[e.jsx("button",{className:S.layerToggle,onClick:()=>_e(_.id),title:I?"Ukryj warstwę":"Pokaż warstwę",children:I?e.jsx(jd,{}):e.jsx(wd,{})}),e.jsx("span",{className:S.layerName,children:_.name??_.id}),e.jsxs("span",{className:S.layerType,children:["(",_.type,")"]})]},_.id)})})]}),e.jsxs("div",{className:S.canvasWrapper,children:[e.jsx("svg",{ref:Le,className:S.canvas,onMouseDown:Qe,onMouseMove:et,onMouseUp:ue,onMouseLeave:ue,onWheel:Oe,onClick:Ge,children:e.jsxs("g",{transform:`translate(${C.pan.x}, ${C.pan.y}) scale(${C.zoom})`,children:[mt(),xt(),ft(),Fe(),vt(),gt(),yt()]})}),e.jsxs("div",{className:S.zoomControls,children:[e.jsx("button",{onClick:dt,title:"Powiększ",children:e.jsx(vd,{})}),e.jsx("button",{onClick:ut,title:"Pomniejsz",children:e.jsx(bd,{})}),e.jsx("button",{onClick:ht,title:"Resetuj widok",children:"⟲"})]}),o&&e.jsx("div",{className:S.minimap,children:e.jsx("div",{className:S.minimapContent,children:e.jsx("div",{className:S.minimapViewport})})}),xe&&Be.length>0&&e.jsxs("div",{className:S.legendPanel,children:[e.jsxs("div",{className:S.legendPanelHeader,children:[e.jsx(Rt,{}),e.jsx("span",{children:"Legenda"}),e.jsx("button",{onClick:()=>Te(!1),children:e.jsx(Xe,{})})]}),e.jsx("div",{className:S.legendList,children:Be.map(_=>e.jsxs("div",{className:S.legendItem,children:[_.icon?e.jsx("span",{className:S.legendIcon,children:_.icon}):e.jsx("span",{className:S.legendColor,style:{background:_.color}}),e.jsx("span",{className:S.legendLabel,children:_.label}),e.jsx("span",{className:S.legendType,children:_.type==="zone"?"strefa":_.type==="object"?"obiekt":"punkt ref."})]},_.id))})]})]})]}),G&&e.jsxs("div",{className:S.objectInfo,children:[e.jsxs("div",{className:S.objectInfoHeader,children:[e.jsx("h4",{children:G.name??G.id}),e.jsx("button",{onClick:()=>me(null),children:e.jsx(Xe,{})})]}),G.description&&e.jsx("p",{children:G.description}),y&&e.jsxs("button",{className:S.navigateBtn,onClick:()=>{const _=G.position??{x:0,y:0};Q?oe(_):ve(_)},children:[e.jsx(Et,{}),Q?"Ustaw jako cel":"Ustaw jako start"]})]})]})};function Sd(t={}){var be;const{initialDocument:s,defaultMode:a="floor-plan",gridSize:o=20,snapEnabled:n=!0,onChange:c}=t,d={mode:a,tool:"select",document:s??null,activeFloorId:((be=s==null?void 0:s.floors[0])==null?void 0:be.id)??null,layers:[],selection:{objectIds:[],bounds:null,locked:!1},viewport:{zoom:1,pan:{x:0,y:0},rotation:0,showGrid:!0,gridSize:o,snapEnabled:n,snapModes:["grid","endpoint","midpoint"]},drawing:{active:!1,points:[],preview:null},history:{past:[],future:[]},guides:[],dragging:null,connecting:{active:!1,sourceId:null,sourcePosition:null,previewPosition:null},clipboard:[],ui:{showObjectLibrary:!0,showLayerPanel:!0,showPropertiesPanel:!0,showMinimap:!0}},[f,y]=l.useReducer((oe,Z)=>({...oe,...Z}),d),v=l.useCallback(oe=>{y({mode:oe})},[]),u=l.useCallback(oe=>{y({tool:oe})},[]),N=l.useCallback((oe="Untitled")=>{var k;const Z=U.createFloorPlanDocument(oe,"floor-plan");y({document:Z,activeFloorId:((k=Z.floors[0])==null?void 0:k.id)??null}),c==null||c(Z)},[c]),b=l.useCallback(oe=>{var Z;y({document:oe,activeFloorId:((Z=oe.floors[0])==null?void 0:Z.id)??null}),c==null||c(oe)},[c]),g=l.useCallback(oe=>{y({viewport:{...f.viewport,zoom:Math.max(.1,Math.min(10,f.viewport.zoom*(1+oe*.1)))}})},[f.viewport]),p=l.useCallback(oe=>{y({viewport:{...f.viewport,pan:{x:f.viewport.pan.x+oe.x,y:f.viewport.pan.y+oe.y}}})},[f.viewport]),x=l.useCallback(()=>{y({viewport:{...f.viewport,zoom:1,pan:{x:0,y:0}}})},[f.viewport]),j=l.useCallback(()=>{y({viewport:{...f.viewport,showGrid:!f.viewport.showGrid}})},[f.viewport]),r=l.useCallback(()=>{y({viewport:{...f.viewport,snapEnabled:!f.viewport.snapEnabled}})},[f.viewport]),L=l.useCallback(oe=>{y({viewport:{...f.viewport,gridSize:oe}})},[f.viewport]),h=l.useCallback((oe,Z)=>{y({layers:f.layers.map(k=>k.type===oe?{...k,visible:Z}:k)})},[f.layers]),C=l.useCallback((oe,Z)=>{y({layers:f.layers.map(k=>k.type===oe?{...k,locked:Z}:k)})},[f.layers]),w=l.useCallback(oe=>{y({selection:{objectIds:oe,bounds:null,locked:!1}})},[]),i=l.useCallback(()=>{y({selection:{objectIds:[],bounds:null,locked:!1}})},[]),$=l.useCallback(()=>{},[]),E=l.useCallback(()=>{},[]),H=f.history.past.length>0,G=f.history.future.length>0,me=l.useCallback(()=>{},[]),Q=l.useCallback(oe=>{},[]),ve=l.useCallback(()=>{},[]);return{state:f,setMode:v,setTool:u,newDocument:N,loadDocument:b,zoom:g,pan:p,resetView:x,toggleGrid:j,toggleSnap:r,setGridSize:L,setLayerVisible:h,setLayerLocked:C,select:w,clearSelection:i,undo:$,redo:E,canUndo:H,canRedo:G,copy:me,paste:Q,cut:ve}}function Ld(t={}){const{gridSize:s=20,enabled:a=!0,snapModes:o=["grid","endpoint","midpoint"],objects:n=[],threshold:c=10}=t,d=l.useMemo(()=>({...U.DEFAULT_GRID_CONFIG,cellSize:s,snapModes:o,snapThreshold:c}),[s,o,c]),f=l.useMemo(()=>n.map((g,p)=>({id:`obj-${p}`,bounds:g})),[n]),y=l.useCallback(g=>a?U.snapToGrid(g,d):g,[a,d]),v=l.useCallback(g=>a?U.snapToGrid3D(g,s):g,[a,s]),u=l.useCallback(g=>{if(!a||f.length===0)return[];const p={x:g.x,y:g.y,width:0,height:0};return U.generateAlignmentGuides(p,f,c)},[a,f,c]),N=l.useCallback(g=>{if(!a)return{point:g,snapped:!1,guides:[]};const p=U.performSnap(g,f,d);return{point:p.position,snapped:p.snapped,guides:p.guides??[]}},[a,d,f]),b=l.useCallback((g,p)=>{const x=[];for(let j=0;j<=g;j+=s)x.push({x1:j,y1:0,x2:j,y2:p});for(let j=0;j<=p;j+=s)x.push({x1:0,y1:j,x2:g,y2:j});return x},[s]);return{snap:y,snap3D:v,getGuides:u,performAdvancedSnap:N,generateGridLines:b}}function zd(t={}){const{unitSystem:s="metric",lengthUnit:a="m",areaUnit:o="m2",angleUnit:n="deg",scale:c=100}=t,[d,f]=l.useState(null),[y,v]=l.useState([]),u=l.useCallback(i=>i/c,[c]),N=l.useCallback(i=>{f(i),v([])},[]),b=l.useCallback((i,$=!1)=>{v(E=>[...E,{position:i,snapped:$}])},[]),g=l.useCallback(()=>{f(null),v([])},[]),p=l.useCallback(()=>{if(!d||y.length<2)return null;const i=y.map($=>$.position);if(d==="distance"&&y.length===2){const $=U.distance2D(i[0],i[1]),E=u($);return{type:"distance",value:E,formatted:U.autoFormatLength(E,s).formatted,points:i}}if(d==="angle"&&y.length===3){const $=U.angleAtVertex(i[0],i[1],i[2]);return{type:"angle",value:$,formatted:U.formatAngle($,n).formatted,points:i}}if(d==="area"&&y.length>=3){const E=U.polygonArea(i)/(c*c);return{type:"area",value:E,formatted:U.autoFormatArea(E,s).formatted,points:i}}return null},[d,y,c,s,n,u]),x=y.length>=2&&d==="distance"?U.autoFormatLength(u(U.distance2D(y[0].position,y[y.length-1].position)),s).formatted:null,j=y.length>=3&&d==="angle"?U.formatAngle(U.angleAtVertex(y[0].position,y[1].position,y[2].position),n).formatted:null,r=y.length>=3&&d==="area"?U.autoFormatArea(U.polygonArea(y.map(i=>i.position))/(c*c),s).formatted:null,L=l.useCallback((i,$)=>{const E=U.distance2D(i,$),H=u(E);return{value:H,formatted:U.autoFormatLength(H,s).formatted}},[u,s]),h=l.useCallback((i,$,E)=>{const H=U.angleAtVertex(i,$,E);return{value:H,formatted:U.formatAngle(H,n).formatted}},[n]),C=l.useCallback(i=>{const E=U.polygonArea(i)/(c*c);return{value:E,formatted:U.autoFormatArea(E,s).formatted}},[c,s]),w=l.useCallback(i=>{const $=U.polylineLength(i),E=u($);return{value:E,formatted:U.autoFormatLength(E,s).formatted}},[u,s]);return{startMeasurement:N,addPoint:b,clearMeasurement:g,finishMeasurement:p,measurementType:d,points:y,liveDistance:x,liveAngle:j,liveArea:r,getDistance:L,getAngle:h,getArea:C,getLength:w}}const $d="_root_t1s4p_3",Bd="_dark_t1s4p_25",Td="_header_t1s4p_31",Pd="_buildingInfo_t1s4p_45",Md="_buildingName_t1s4p_49",Od="_buildingAddress_t1s4p_67",Ad="_modeSelector_t1s4p_81",Ed="_modeBtn_t1s4p_93",Dd="_modeBtnActive_t1s4p_127",Rd="_weather_t1s4p_141",Wd="_weatherTemp_t1s4p_155",Gd="_weatherDesc_t1s4p_171",Fd="_statsRow_t1s4p_183",Vd="_statsCard_t1s4p_195",Hd="_statsHeader_t1s4p_225",Ud="_statsIcon_t1s4p_239",Zd="_statsLabel_t1s4p_243",Yd="_statsValue_t1s4p_257",Kd="_statsSub_t1s4p_275",Xd="_zoneGrid_t1s4p_289",Jd="_zoneCard_t1s4p_303",qd="_zoneOccupied_t1s4p_347",Qd="_zoneCardHeader_t1s4p_351",eu="_zoneCardIcon_t1s4p_365",tu="_zoneCardTitles_t1s4p_369",su="_zoneCardName_t1s4p_379",nu="_zoneCardArea_t1s4p_403",ou="_occupancyBadge_t1s4p_413",au="_occupancyBadgeOn_t1s4p_431",cu="_sensorRow_t1s4p_443",lu="_sensorChip_t1s4p_457",ru="_sensorWarn_t1s4p_475",iu="_deviceList_t1s4p_489",du="_deviceChip_t1s4p_501",uu="_deviceChipOn_t1s4p_535",hu="_deviceChipName_t1s4p_547",_u="_deviceChipVal_t1s4p_561",pu="_moreBtn_t1s4p_571",mu="_scenesBar_t1s4p_597",xu="_sceneBarLabel_t1s4p_627",fu="_sceneList_t1s4p_645",gu="_sceneBtn_t1s4p_657",yu="_sceneBtnActive_t1s4p_683",V={root:$d,dark:Bd,header:Td,buildingInfo:Pd,buildingName:Md,buildingAddress:Od,modeSelector:Ad,modeBtn:Ed,modeBtnActive:Dd,weather:Rd,weatherTemp:Wd,weatherDesc:Gd,statsRow:Fd,statsCard:Vd,statsHeader:Hd,statsIcon:Ud,statsLabel:Zd,statsValue:Yd,statsSub:Kd,zoneGrid:Xd,zoneCard:Jd,zoneOccupied:qd,zoneCardHeader:Qd,zoneCardIcon:eu,zoneCardTitles:tu,zoneCardName:su,zoneCardArea:nu,occupancyBadge:ou,occupancyBadgeOn:au,sensorRow:cu,sensorChip:lu,sensorWarn:ru,deviceList:iu,deviceChip:du,deviceChipOn:uu,deviceChipName:hu,deviceChipVal:_u,moreBtn:pu,scenesBar:mu,sceneBarLabel:xu,sceneList:fu,sceneBtn:gu,sceneBtnActive:yu},Jt={living_room:"🛋",bedroom:"🛏",master_bedroom:"🛏",kids_room:"🧸",bathroom:"🚿",kitchen:"🍳",dining_room:"🍽",hallway:"🚪",office:"💼",garage:"🚗",gym:"🏋",cinema:"🎬",balcony:"🌿",garden:"🌳",open_office:"💼",private_office:"🖥",meeting_room:"📋",boardroom:"🤝",reception:"🏢",server_room:"🖥",lobby:"🏛",corridor:"↔",stairwell:"🪜",parking:"🅿",break_room:"☕",it_room:"💻",cafeteria:"🍽"};function vu(t){return Jt[t]??"🏠"}function bu(t){if(!t.state)return null;const s=t.state;return typeof s.brightness=="number"?`${s.brightness}%`:typeof s.on=="boolean"?s.on?"Wł":"Wył":typeof s.temperature=="number"?`${s.temperature.toFixed(1)}°`:typeof s.locked=="boolean"?s.locked?"🔒":"🔓":null}const qt=({zone:t,devices:s=[],expanded:a=!1,onExpand:o,onDeviceControl:n,onClick:c,theme:d="light",className:f,style:y})=>{const v=t.occupancy!=null&&t.occupancy>0,u=a?s:s.slice(0,4);return e.jsxs("div",{className:`${V.zoneCard} ${d==="dark"?V.dark:""} ${v?V.zoneOccupied:""} ${f??""}`,style:y,onClick:c,children:[e.jsxs("div",{className:V.zoneCardHeader,children:[e.jsx("span",{className:V.zoneCardIcon,children:vu(t.type)}),e.jsxs("div",{className:V.zoneCardTitles,children:[e.jsx("span",{className:V.zoneCardName,children:t.name}),t.area!=null&&e.jsxs("span",{className:V.zoneCardArea,children:[t.area," m²"]})]}),t.occupancy!=null&&e.jsxs("span",{className:`${V.occupancyBadge} ${v?V.occupancyBadgeOn:""}`,children:["👥 ",t.occupancy]})]}),(t.temperature!=null||t.humidity!=null||t.co2!=null)&&e.jsxs("div",{className:V.sensorRow,children:[t.temperature!=null&&e.jsxs("span",{className:V.sensorChip,children:["🌡 ",t.temperature.toFixed(1),"°C"]}),t.humidity!=null&&e.jsxs("span",{className:V.sensorChip,children:["💧 ",t.humidity,"%"]}),t.co2!=null&&e.jsxs("span",{className:`${V.sensorChip} ${t.co2>1e3?V.sensorWarn:""}`,children:["CO₂ ",t.co2]})]}),u.length>0&&e.jsxs("div",{className:V.deviceList,children:[u.map(N=>{const b=N.state,g=(b==null?void 0:b.on)===!0||(b==null?void 0:b.locked)===!1;return e.jsxs("button",{className:`${V.deviceChip} ${g?V.deviceChipOn:""}`,onClick:p=>{p.stopPropagation(),n==null||n(N.id,{on:!g})},title:N.name,children:[e.jsx("span",{children:Jt[N.type]??"📟"}),e.jsx("span",{className:V.deviceChipName,children:N.name}),e.jsx("span",{className:V.deviceChipVal,children:bu(N)})]},N.id)}),s.length>4&&e.jsx("button",{className:V.moreBtn,onClick:N=>{N.stopPropagation(),o==null||o()},children:a?"−":`+${s.length-4}`})]})]})},wt={home:"Dom",away:"Wyjazd",night:"Noc",vacation:"Urlop",guest:"Gość",party:"Impreza",occupied:"Zajęty",closed:"Zamknięty",weekend:"Weekend",event:"Wydarzenie",emergency:"Alarm",maintenance:"Serwis"},Wt={home:"🏠",away:"🚗",night:"🌙",vacation:"✈",guest:"👋",party:"🎉",occupied:"🏢",closed:"🔒",weekend:"☀",event:"🎉",emergency:"🚨",maintenance:"🔧"},ju=({temperature:t,description:s})=>t!=null?e.jsxs("div",{className:V.weather,children:[e.jsxs("span",{className:V.weatherTemp,children:[t,"°C"]}),s&&e.jsx("span",{className:V.weatherDesc,children:s})]}):null,lt=({label:t,value:s,sub:a,icon:o,accent:n})=>e.jsxs("div",{className:V.statsCard,style:n?{borderTopColor:n}:void 0,children:[e.jsxs("div",{className:V.statsHeader,children:[o&&e.jsx("span",{className:V.statsIcon,children:o}),e.jsx("span",{className:V.statsLabel,children:t})]}),e.jsx("div",{className:V.statsValue,children:s}),a&&e.jsx("div",{className:V.statsSub,children:a})]}),wu=({building:t,state:s,onModeChange:a,onDeviceControl:o,onSceneActivate:n,onZoneClick:c,className:d,style:f,theme:y="light",weather:v})=>{var h,C,w;const[u,N]=l.useState(null);t.floors[0];const b=t.floors.flatMap(i=>i.zones??[]).filter(i=>i.type!=="hallway"&&i.type!=="corridor"),g=((h=s==null?void 0:s.activeAlerts)==null?void 0:h.length)??0,p=(C=s==null?void 0:s.energy)==null?void 0:C.currentPowerW,x=(w=s==null?void 0:s.energy)==null?void 0:w.todayKwh,j=s!=null&&s.occupancy?Object.values(s.occupancy).reduce((i,$)=>i+(($==null?void 0:$.occupancy)??0),0):null;t.floors.flatMap(i=>i.zones??[]).flatMap(i=>i.deviceIds??[]).slice(0,8);const r=t.type==="office"||t.type==="retail"?["occupied","closed","weekend","event","emergency","maintenance"]:["home","away","night","vacation","guest","emergency"],L=(s==null?void 0:s.mode)??"home";return e.jsxs("div",{className:`${V.root} ${y==="dark"?V.dark:""} ${d??""}`,style:f,children:[e.jsxs("div",{className:V.header,children:[e.jsxs("div",{className:V.buildingInfo,children:[e.jsx("h2",{className:V.buildingName,children:t.name}),t.address&&e.jsx("p",{className:V.buildingAddress,children:t.address})]}),e.jsx("div",{className:V.modeSelector,children:r.map(i=>e.jsxs("button",{title:wt[i],className:`${V.modeBtn} ${L===i?V.modeBtnActive:""}`,onClick:()=>a==null?void 0:a(i),children:[Wt[i],e.jsx("span",{children:wt[i]})]},i))}),e.jsx(ju,{temperature:v==null?void 0:v.temperature,description:v==null?void 0:v.description})]}),e.jsxs("div",{className:V.statsRow,children:[p!=null&&e.jsx(lt,{icon:"⚡",label:"Moc",value:p>=1e3?`${(p/1e3).toFixed(2)} kW`:`${p} W`,sub:x!=null?`Dziś: ${x.toFixed(2)} kWh`:void 0,accent:"#f59e0b"}),j!=null&&e.jsx(lt,{icon:"👥",label:"Obecność",value:`${j} os.`,sub:`${b.length} stref`,accent:"#22c55e"}),g>0&&e.jsx(lt,{icon:"🚨",label:"Alarmy",value:e.jsx("span",{style:{color:"#ef4444"},children:g}),sub:"aktywnych",accent:"#ef4444"}),e.jsx(lt,{icon:Wt[L],label:"Tryb",value:wt[L],accent:"#8b5cf6"})]}),e.jsx("div",{className:V.zoneGrid,children:b.map(i=>{const $=t.floors.flatMap(E=>(E.zones??[]).find(H=>H.id===i.id)?t.devices??[]:[]).filter(E=>E.zoneId===i.id);return e.jsx(qt,{zone:i,devices:$,expanded:u===i.id,onExpand:()=>N(u===i.id?null:i.id),onDeviceControl:o,onClick:()=>c==null?void 0:c(i.id),theme:y},i.id)})}),t.scenes&&t.scenes.length>0&&e.jsxs("div",{className:V.scenesBar,children:[e.jsx("span",{className:V.sceneBarLabel,children:"Sceny"}),e.jsx("div",{className:V.sceneList,children:t.scenes.map(i=>{var $;return e.jsxs("button",{className:`${V.sceneBtn} ${($=s==null?void 0:s.activeScenes)!=null&&$.includes(i.id)?V.sceneBtnActive:""}`,onClick:()=>n==null?void 0:n(i.id),children:[i.icon??"🎭"," ",i.name]},i.id)})})]})]})},Nu="_deviceControl_118z0_3",ku="_dark_118z0_23",Cu="_compact_118z0_35",Iu="_offline_118z0_39",Su="_offlineBanner_118z0_43",Lu="_toggleControl_118z0_67",zu="_toggleLabel_118z0_81",$u="_toggleBtn_118z0_97",Bu="_toggleOn_118z0_123",Tu="_blindControl_118z0_137",Pu="_blindLabel_118z0_139",Mu="_blindActions_118z0_143",Ou="_blindBtn_118z0_145",Au="_blindSlider_118z0_149",Eu="_blindPct_118z0_151",Du="_lockControl_118z0_157",Ru="_lockLabel_118z0_159",Wu="_lockBtn_118z0_163",Gu="_lockLocked_118z0_165",Fu="_lockUnlocked_118z0_167",Vu="_cameraControl_118z0_173",Hu="_cameraLabel_118z0_175",Uu="_cameraSnapshot_118z0_179",Zu="_cameraPlaceholder_118z0_181",Yu="_cameraStatus_118z0_183",Ku="_cameraDot_118z0_185",Xu="_cameraOnline_118z0_187",Ju="_cameraOffline_118z0_189",qu="_sensorControl_118z0_195",Qu="_sensorLabel_118z0_197",eh="_sensorValues_118z0_201",th="_sensorRow_118z0_203",sh="_sensorKey_118z0_205",nh="_sensorVal_118z0_201",oh="_thermostat_118z0_215",ah="_thermostatTitle_118z0_229",ch="_thermostatDial_118z0_247",lh="_dialTempCurrent_118z0_257",rh="_dialTempLabel_118z0_273",ih="_dialTempTarget_118z0_283",dh="_dialHumidity_118z0_299",uh="_thermostatAdjust_118z0_309",hh="_adjustBtn_118z0_321",_h="_adjustTemp_118z0_355",ph="_hvacModes_118z0_375",mh="_hvacModeBtn_118z0_389",xh="_hvacModeBtnActive_118z0_413",fh="_hvacAction_118z0_425",gh="_hvacActionDot_118z0_441",yh="_lightControl_118z0_455",vh="_lightHeader_118z0_467",bh="_lightIcon_118z0_479",jh="_lightName_118z0_483",wh="_lightToggle_118z0_507",Nh="_lightToggleOn_118z0_535",kh="_sliderRow_118z0_547",Ch="_sliderIcon_118z0_561",Ih="_slider_118z0_547",Sh="_sliderVal_118z0_579",Lh="_colorRow_118z0_591",zh="_colorSwatch_118z0_605",$h="_colorPicker_118z0_621",Bh="_colorPresets_118z0_637",Th="_colorPreset_118z0_637",Ph="_lightOff_118z0_663",B={deviceControl:Nu,dark:ku,compact:Cu,offline:Iu,offlineBanner:Su,toggleControl:Lu,toggleLabel:zu,toggleBtn:$u,toggleOn:Bu,blindControl:Tu,blindLabel:Pu,blindActions:Mu,blindBtn:Ou,blindSlider:Au,blindPct:Eu,lockControl:Du,lockLabel:Ru,lockBtn:Wu,lockLocked:Gu,lockUnlocked:Fu,cameraControl:Vu,cameraLabel:Hu,cameraSnapshot:Uu,cameraPlaceholder:Zu,cameraStatus:Yu,cameraDot:Ku,cameraOnline:Xu,cameraOffline:Ju,sensorControl:qu,sensorLabel:Qu,sensorValues:eh,sensorRow:th,sensorKey:sh,sensorVal:nh,thermostat:oh,thermostatTitle:ah,thermostatDial:ch,dialTempCurrent:lh,dialTempLabel:rh,dialTempTarget:ih,dialHumidity:dh,thermostatAdjust:uh,adjustBtn:hh,adjustTemp:_h,hvacModes:ph,hvacModeBtn:mh,hvacModeBtnActive:xh,hvacAction:fh,hvacActionDot:gh,lightControl:yh,lightHeader:vh,lightIcon:bh,lightName:jh,lightToggle:wh,lightToggleOn:Nh,sliderRow:kh,sliderIcon:Ch,slider:Ih,sliderVal:Sh,colorRow:Lh,colorSwatch:zh,colorPicker:$h,colorPresets:Bh,colorPreset:Th,lightOff:Ph};function Gt(t){const s=Math.max(0,Math.min(1,(t-2700)/3800)),a=Math.round(255-s*80),o=Math.round(200+s*30),n=Math.round(100+s*155);return`rgb(${a},${o},${n})`}function Mh(t,s,a){return"#"+[t,s,a].map(o=>o.toString(16).padStart(2,"0")).join("")}function Ft(t){const s=parseInt(t.slice(1,3),16),a=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);return[s,a,o]}const Qt=({device:t,onControl:s,compact:a=!1,theme:o="light",className:n,style:c})=>{var L,h,C;const d=t.state,f=(d==null?void 0:d.on)??!1,y=(d==null?void 0:d.brightness)??100,v=(d==null?void 0:d.colorTemperature)??4e3,u=d==null?void 0:d.rgbColor,[N,b]=l.useState(!1),g=l.useCallback(w=>{s==null||s(t.id,w)},[t.id,s]),p=u?Mh(u[0],u[1],u[2]):"#ffffff",x=((L=t.capabilities)==null?void 0:L.includes("dimming"))??y!==void 0,j=(h=t.capabilities)==null?void 0:h.includes("color_temperature"),r=((C=t.capabilities)==null?void 0:C.includes("color"))||t.type==="rgb_light";return e.jsxs("div",{className:`${B.lightControl} ${a?B.compact:""} ${o==="dark"?B.dark:""} ${n??""}`,style:c,children:[e.jsxs("div",{className:B.lightHeader,children:[e.jsx("span",{className:B.lightIcon,style:{opacity:f?1:.4},children:"💡"}),e.jsx("span",{className:B.lightName,children:t.name}),e.jsx("button",{className:`${B.lightToggle} ${f?B.lightToggleOn:""}`,onClick:()=>g({on:!f}),children:f?"●":"○"})]}),f&&e.jsxs(e.Fragment,{children:[x&&e.jsxs("div",{className:B.sliderRow,children:[e.jsx("span",{className:B.sliderIcon,children:"🔅"}),e.jsx("input",{type:"range",min:1,max:100,value:y,className:B.slider,style:{"--pct":`${y}%`},onChange:w=>g({brightness:+w.target.value})}),e.jsxs("span",{className:B.sliderVal,children:[y,"%"]})]}),j&&e.jsxs("div",{className:B.sliderRow,children:[e.jsx("span",{className:B.sliderIcon,children:"🌡"}),e.jsx("input",{type:"range",min:2700,max:6500,step:100,value:v,className:B.slider,style:{background:`linear-gradient(to right, ${Gt(2700)}, ${Gt(6500)})`},onChange:w=>g({colorTemperature:+w.target.value})}),e.jsxs("span",{className:B.sliderVal,children:[Math.round(v/100)*100,"K"]})]}),r&&e.jsxs("div",{className:B.colorRow,children:[e.jsx("span",{className:B.sliderIcon,children:"🎨"}),e.jsx("button",{className:B.colorSwatch,style:{background:p},onClick:()=>b(w=>!w)}),N&&e.jsx("input",{type:"color",value:p,className:B.colorPicker,onChange:w=>{const[i,$,E]=Ft(w.target.value);g({rgbColor:[i,$,E]})}}),e.jsx("div",{className:B.colorPresets,children:["#ffffff","#fde68a","#fca5a5","#93c5fd","#86efac","#c4b5fd"].map(w=>e.jsx("button",{className:B.colorPreset,style:{background:w},onClick:()=>{const[i,$,E]=Ft(w);g({rgbColor:[i,$,E]})}},w))})]})]}),!f&&!a&&e.jsx("div",{className:B.lightOff,children:"Wyłączone"})]})},Vt={heat:"🔥 Grzanie",cool:"❄ Chłodzenie",auto:"⚡ Auto",off:"⏻ Wyłącz",fan_only:"💨 Wentylacja",dry:"💧 Osuszanie"},Oh={heating:"#ef4444",cooling:"#3b82f6",fan:"#22c55e",drying:"#f59e0b",idle:"#94a3b8",off:"#e2e8f0"};function Ht(t,s,a,o,n){const c=N=>(N-90)*(Math.PI/180),d=t+a*Math.cos(c(o)),f=s+a*Math.sin(c(o)),y=t+a*Math.cos(c(n)),v=s+a*Math.sin(c(n)),u=n-o>180?1:0;return`M${d.toFixed(2)},${f.toFixed(2)} A${a},${a} 0 ${u},1 ${y.toFixed(2)},${v.toFixed(2)}`}const Je=5,rt=35,it=-140,es=140;function Ut(t){return it+(t-Je)/(rt-Je)*(es-it)}const ts=({device:t,onControl:s,compact:a=!1,theme:o="light",className:n,style:c})=>{const d=t.state,f=(d==null?void 0:d.temperature)??20,y=(d==null?void 0:d.targetTemperature)??21,v=d==null?void 0:d.humidity,u=(d==null?void 0:d.mode)??"auto",N=(d==null?void 0:d.hvacAction)??"idle",b=80,g=80,p=60,x=Ht(b,g,p,it,es),j=Ut(Math.min(Math.max(f,Je),rt)),r=Ut(Math.min(Math.max(y,Je),rt)),L=Ht(b,g,p,it,Math.min(j,r)),h=Oh[N]??"#94a3b8",C=l.useCallback(i=>{const $=Math.round((y+i)*2)/2;$>=Je&&$<=rt&&(s==null||s(t.id,{targetTemperature:$}))},[y,t.id,s]),w=l.useCallback(i=>{s==null||s(t.id,{mode:i})},[t.id,s]);return e.jsxs("div",{className:`${B.thermostat} ${a?B.compact:""} ${o==="dark"?B.dark:""} ${n??""}`,style:c,children:[e.jsx("div",{className:B.thermostatTitle,children:t.name}),e.jsxs("svg",{width:160,height:160,className:B.thermostatDial,children:[e.jsx("path",{d:x,fill:"none",stroke:"#e2e8f0",strokeWidth:8,strokeLinecap:"round"}),e.jsx("path",{d:L,fill:"none",stroke:h,strokeWidth:8,strokeLinecap:"round",opacity:.4}),e.jsx("circle",{cx:b+p*Math.cos((r-90)*(Math.PI/180)),cy:g+p*Math.sin((r-90)*(Math.PI/180)),r:7,fill:h,stroke:"#fff",strokeWidth:2}),e.jsxs("text",{x:b,y:g-6,textAnchor:"middle",className:B.dialTempCurrent,children:[f.toFixed(1),"°"]}),e.jsx("text",{x:b,y:g+14,textAnchor:"middle",className:B.dialTempLabel,children:"aktualnie"}),e.jsxs("text",{x:b,y:g+32,textAnchor:"middle",className:B.dialTempTarget,children:["▶ ",y.toFixed(1),"°"]}),v!=null&&e.jsxs("text",{x:b,y:g+48,textAnchor:"middle",className:B.dialHumidity,children:["💧 ",v,"%"]})]}),e.jsxs("div",{className:B.thermostatAdjust,children:[e.jsx("button",{className:B.adjustBtn,onClick:()=>C(-.5),children:"−"}),e.jsxs("span",{className:B.adjustTemp,children:[y.toFixed(1)," °C"]}),e.jsx("button",{className:B.adjustBtn,onClick:()=>C(.5),children:"+"})]}),!a&&e.jsx("div",{className:B.hvacModes,children:["heat","cool","auto","fan_only","off"].map(i=>e.jsx("button",{title:Vt[i],className:`${B.hvacModeBtn} ${u===i?B.hvacModeBtnActive:""}`,onClick:()=>w(i),children:Vt[i].split(" ")[0]},i))}),e.jsxs("div",{className:B.hvacAction,style:{color:h},children:[e.jsx("span",{className:B.hvacActionDot,style:{background:h}}),N]})]})},Ah=({device:t,onControl:s})=>{const a=t.state,o=(a==null?void 0:a.on)===!0;return e.jsxs("div",{className:B.toggleControl,children:[e.jsx("span",{className:B.toggleLabel,children:t.name}),e.jsx("button",{className:`${B.toggleBtn} ${o?B.toggleOn:""}`,onClick:()=>s==null?void 0:s(t.id,{on:!o}),children:o?"WŁĄCZONE":"WYŁĄCZONE"})]})},Eh=({device:t,onControl:s})=>{const a=t.state,o=typeof(a==null?void 0:a.position)=="number"?a.position:50;return e.jsxs("div",{className:B.blindControl,children:[e.jsx("span",{className:B.blindLabel,children:t.name}),e.jsxs("div",{className:B.blindActions,children:[e.jsx("button",{className:B.blindBtn,onClick:()=>s==null?void 0:s(t.id,{command:"open"}),children:"▲"}),e.jsx("button",{className:B.blindBtn,onClick:()=>s==null?void 0:s(t.id,{command:"stop"}),children:"■"}),e.jsx("button",{className:B.blindBtn,onClick:()=>s==null?void 0:s(t.id,{command:"close"}),children:"▼"})]}),e.jsx("input",{type:"range",min:0,max:100,value:o,className:B.blindSlider,onChange:n=>s==null?void 0:s(t.id,{position:+n.target.value})}),e.jsxs("span",{className:B.blindPct,children:[o,"%"]})]})},Dh=({device:t,onControl:s})=>{const a=t.state,o=(a==null?void 0:a.locked)!==!1;return e.jsxs("div",{className:B.lockControl,children:[e.jsx("span",{className:B.lockLabel,children:t.name}),e.jsx("button",{className:`${B.lockBtn} ${o?B.lockLocked:B.lockUnlocked}`,onClick:()=>s==null?void 0:s(t.id,{locked:!o}),children:o?"🔒 Zablokowany":"🔓 Odblokowany"})]})},Rh=({device:t})=>{const s=t.state;return e.jsxs("div",{className:B.cameraControl,children:[e.jsx("span",{className:B.cameraLabel,children:t.name}),s!=null&&s.snapshotUrl?e.jsx("img",{src:s.snapshotUrl,alt:"snapshot",className:B.cameraSnapshot}):e.jsxs("div",{className:B.cameraPlaceholder,children:[e.jsx("span",{children:"📷"}),e.jsx("span",{children:s!=null&&s.streaming?"Streaming":"Brak podglądu"})]}),e.jsxs("div",{className:B.cameraStatus,children:[e.jsx("span",{className:`${B.cameraDot} ${t.status==="online"?B.cameraOnline:B.cameraOffline}`}),t.status]})]})},Wh=({device:t})=>{const s=t.state;return e.jsxs("div",{className:B.sensorControl,children:[e.jsx("span",{className:B.sensorLabel,children:t.name}),e.jsx("div",{className:B.sensorValues,children:Object.entries(s??{}).map(([a,o])=>o!=null&&e.jsxs("div",{className:B.sensorRow,children:[e.jsx("span",{className:B.sensorKey,children:a}),e.jsx("span",{className:B.sensorVal,children:String(o)})]},a))})]})},Gh=({device:t,onControl:s,compact:a=!1,className:o,style:n,theme:c="light"})=>{const d=t.type,f=["light","dimmer","rgb_light","led_strip"].includes(d)?e.jsx(Qt,{device:t,onControl:s,compact:a,theme:c}):["thermostat","air_conditioner","heat_pump","floor_heating"].includes(d)?e.jsx(ts,{device:t,onControl:s,compact:a,theme:c}):["blind","shutter","curtain","awning","garage_door"].includes(d)?e.jsx(Eh,{device:t,onControl:s}):["lock","door"].includes(d)?e.jsx(Dh,{device:t,onControl:s}):["camera","doorbell"].includes(d)?e.jsx(Rh,{device:t}):d.endsWith("_sensor")||["motion_sensor","smoke_detector","water_leak_sensor","alarm"].includes(d)?e.jsx(Wh,{device:t}):e.jsx(Ah,{device:t,onControl:s});return e.jsxs("div",{className:`${B.deviceControl} ${c==="dark"?B.dark:""} ${a?B.compact:""} ${t.status==="offline"?B.offline:""} ${o??""}`,style:n,children:[f,t.status==="offline"&&e.jsx("div",{className:B.offlineBanner,children:"Offline"})]})},Fh="_root_1vnlf_3",Vh="_dark_1vnlf_27",Hh="_listPanel_1vnlf_33",Uh="_listHeader_1vnlf_55",Zh="_listTitle_1vnlf_75",Yh="_addBtn_1vnlf_89",Kh="_list_1vnlf_33",Xh="_listItem_1vnlf_117",Jh="_listItemActive_1vnlf_145",qh="_listItemName_1vnlf_151",Qh="_listItemMeta_1vnlf_175",e_="_enableToggle_1vnlf_189",t_="_enableOn_1vnlf_207",s_="_detailPanel_1vnlf_213",n_="_detailHeader_1vnlf_225",o_="_nameInput_1vnlf_239",a_="_deleteBtn_1vnlf_267",c_="_section_1vnlf_293",l_="_sectionHeader_1vnlf_301",r_="_sectionTitle_1vnlf_315",i_="_sectionAddBtn_1vnlf_331",d_="_ruleBlock_1vnlf_357",u_="_ruleBlockHeader_1vnlf_377",h_="_typeSelect_1vnlf_391",__="_removeBtn_1vnlf_415",p_="_ruleFields_1vnlf_447",m_="_input_1vnlf_479",x_="_textarea_1vnlf_503",f_="_dayPicker_1vnlf_531",g_="_dayBtn_1vnlf_535",y_="_dayBtnActive_1vnlf_555",v_="_noSelection_1vnlf_561",b_="_emptyHint_1vnlf_561",A={root:Fh,dark:Vh,listPanel:Hh,listHeader:Uh,listTitle:Zh,addBtn:Yh,list:Kh,listItem:Xh,listItemActive:Jh,listItemName:qh,listItemMeta:Qh,enableToggle:e_,enableOn:t_,detailPanel:s_,detailHeader:n_,nameInput:o_,deleteBtn:a_,section:c_,sectionHeader:l_,sectionTitle:r_,sectionAddBtn:i_,ruleBlock:d_,ruleBlockHeader:u_,typeSelect:h_,removeBtn:__,ruleFields:p_,input:m_,textarea:x_,dayPicker:f_,dayBtn:g_,dayBtnActive:y_,noSelection:v_,emptyHint:b_},$e=(t,s,a="")=>{const o=t[s];return typeof o=="string"?o:a},Ct=(t,s,a=0)=>{const o=t[s];return typeof o=="number"?o:a},j_=(t,s,a)=>{const o=t[s];return Array.isArray(o)?o:a},w_=(t,s)=>{const a=t[s];return a&&typeof a=="object"?a:{}},N_=({trigger:t,devices:s,onChange:a,onRemove:o})=>{const n=c=>a({...t,...c});return e.jsxs("div",{className:A.ruleBlock,children:[e.jsxs("div",{className:A.ruleBlockHeader,children:[e.jsxs("select",{className:A.typeSelect,value:t.type,onChange:c=>a({type:c.target.value}),children:[e.jsx("option",{value:"time",children:"⏰ Czas"}),e.jsx("option",{value:"sunrise",children:"🌅 Wschód słońca"}),e.jsx("option",{value:"sunset",children:"🌇 Zachód słońca"}),e.jsx("option",{value:"device_state",children:"📡 Stan urządzenia"}),e.jsx("option",{value:"sensor_threshold",children:"📊 Próg sensora"}),e.jsx("option",{value:"occupancy",children:"👥 Obecność"}),e.jsx("option",{value:"webhook",children:"🔗 Webhook"}),e.jsx("option",{value:"calendar",children:"📅 Kalendarz"})]}),e.jsx("button",{className:A.removeBtn,onClick:o,title:"Usuń",children:"✕"})]}),t.type==="time"&&e.jsxs("div",{className:A.ruleFields,children:[e.jsxs("label",{children:["Godzina",e.jsx("input",{type:"time",className:A.input,value:$e(t,"time","08:00"),onChange:c=>n({time:c.target.value})})]}),e.jsxs("label",{children:["Dni",e.jsx("div",{className:A.dayPicker,children:["Pon","Wt","Śr","Czw","Pt","Sob","Nd"].map((c,d)=>{const f=j_(t,"days",[0,1,2,3,4]),y=f.includes(d);return e.jsx("button",{className:`${A.dayBtn} ${y?A.dayBtnActive:""}`,onClick:()=>n({days:y?f.filter(v=>v!==d):[...f,d]}),children:c},d)})})]})]}),(t.type==="sunrise"||t.type==="sunset")&&e.jsx("div",{className:A.ruleFields,children:e.jsxs("label",{children:["Offset (minuty)",e.jsx("input",{type:"number",className:A.input,min:-120,max:120,step:5,value:Ct(t,"offsetMinutes",0),onChange:c=>n({offsetMinutes:+c.target.value})})]})}),(t.type==="device_state"||t.type==="sensor_threshold")&&e.jsxs("div",{className:A.ruleFields,children:[e.jsxs("label",{children:["Urządzenie",e.jsxs("select",{className:A.input,value:$e(t,"deviceId",""),onChange:c=>n({deviceId:c.target.value}),children:[e.jsx("option",{value:"",children:"— wybierz —"}),s.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))]})]}),t.type==="sensor_threshold"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:["Atrybut",e.jsx("input",{className:A.input,value:$e(t,"attribute",""),onChange:c=>n({attribute:c.target.value})})]}),e.jsxs("label",{children:["Operator",e.jsxs("select",{className:A.input,value:$e(t,"operator","above"),onChange:c=>n({operator:c.target.value}),children:[e.jsx("option",{value:"above",children:"powyżej"}),e.jsx("option",{value:"below",children:"poniżej"}),e.jsx("option",{value:"equals",children:"równe"})]})]}),e.jsxs("label",{children:["Próg",e.jsx("input",{type:"number",className:A.input,value:Ct(t,"threshold",0),onChange:c=>n({threshold:+c.target.value})})]})]})]}),t.type==="webhook"&&e.jsx("div",{className:A.ruleFields,children:e.jsxs("label",{children:["Endpoint ID",e.jsx("input",{className:A.input,value:$e(t,"webhookId",""),onChange:c=>n({webhookId:c.target.value})})]})})]})},k_=({action:t,devices:s,onChange:a,onRemove:o})=>{const n=c=>a({...t,...c});return e.jsxs("div",{className:A.ruleBlock,children:[e.jsxs("div",{className:A.ruleBlockHeader,children:[e.jsxs("select",{className:A.typeSelect,value:t.type,onChange:c=>a({type:c.target.value}),children:[e.jsx("option",{value:"device_control",children:"📡 Urządzenie"}),e.jsx("option",{value:"scene_activate",children:"🎭 Aktywuj scenę"}),e.jsx("option",{value:"notification",children:"🔔 Powiadomienie"}),e.jsx("option",{value:"delay",children:"⏱ Opóźnienie"}),e.jsx("option",{value:"http_request",children:"🌐 HTTP Request"})]}),e.jsx("button",{className:A.removeBtn,onClick:o,title:"Usuń",children:"✕"})]}),t.type==="device_control"&&e.jsxs("div",{className:A.ruleFields,children:[e.jsxs("label",{children:["Urządzenie",e.jsxs("select",{className:A.input,value:$e(t,"deviceId",""),onChange:c=>n({deviceId:c.target.value}),children:[e.jsx("option",{value:"",children:"— wybierz —"}),s.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))]})]}),e.jsxs("label",{children:["Stan (JSON)",e.jsx("textarea",{className:A.textarea,rows:3,value:JSON.stringify(w_(t,"state"),null,2),onChange:c=>{try{n({state:JSON.parse(c.target.value)})}catch{}}})]})]}),t.type==="notification"&&e.jsxs("div",{className:A.ruleFields,children:[e.jsxs("label",{children:["Kanał",e.jsxs("select",{className:A.input,value:$e(t,"channel","push"),onChange:c=>n({channel:c.target.value}),children:[e.jsx("option",{value:"push",children:"Push"}),e.jsx("option",{value:"email",children:"Email"}),e.jsx("option",{value:"sms",children:"SMS"}),e.jsx("option",{value:"in_app",children:"In-app"}),e.jsx("option",{value:"teams",children:"Teams"}),e.jsx("option",{value:"slack",children:"Slack"})]})]}),e.jsxs("label",{children:["Wiadomość",e.jsx("input",{className:A.input,value:$e(t,"message",""),onChange:c=>n({message:c.target.value})})]})]}),t.type==="delay"&&e.jsx("div",{className:A.ruleFields,children:e.jsxs("label",{children:["Opóźnienie (sekundy)",e.jsx("input",{type:"number",className:A.input,min:1,value:Ct(t,"delaySeconds",60),onChange:c=>n({delaySeconds:+c.target.value})})]})}),t.type==="http_request"&&e.jsxs("div",{className:A.ruleFields,children:[e.jsxs("label",{children:["URL",e.jsx("input",{className:A.input,value:$e(t,"url",""),onChange:c=>n({url:c.target.value})})]}),e.jsxs("label",{children:["Metoda",e.jsxs("select",{className:A.input,value:$e(t,"method","POST"),onChange:c=>n({method:c.target.value}),children:[e.jsx("option",{children:"GET"}),e.jsx("option",{children:"POST"}),e.jsx("option",{children:"PUT"}),e.jsx("option",{children:"PATCH"})]})]})]})]})},C_=({automations:t,devices:s=[],onAutomationsChange:a,readOnly:o=!1,className:n,style:c,theme:d="light"})=>{var g;const[f,y]=l.useState(((g=t[0])==null?void 0:g.id)??null),v=t.find(p=>p.id===f)??null,u=l.useCallback(p=>{v&&(a==null||a(t.map(x=>x.id===v.id?{...x,...p}:x)))},[v,t,a]),N=l.useCallback(()=>{const p={id:`auto-${Date.now()}`,name:"Nowa automatyzacja",enabled:!0,triggers:[],conditions:[],actions:[]};a==null||a([...t,p]),y(p.id)},[t,a]),b=l.useCallback(p=>{var x;a==null||a(t.filter(j=>j.id!==p)),f===p&&y(((x=t.find(j=>j.id!==p))==null?void 0:x.id)??null)},[t,f,a]);return e.jsxs("div",{className:`${A.root} ${d==="dark"?A.dark:""} ${n??""}`,style:c,children:[e.jsxs("div",{className:A.listPanel,children:[e.jsxs("div",{className:A.listHeader,children:[e.jsx("span",{className:A.listTitle,children:"Automatyzacje"}),!o&&e.jsx("button",{className:A.addBtn,onClick:N,children:"+ Dodaj"})]}),e.jsxs("div",{className:A.list,children:[t.map(p=>e.jsxs("div",{className:`${A.listItem} ${f===p.id?A.listItemActive:""}`,onClick:()=>y(p.id),children:[e.jsx("div",{className:A.listItemName,children:p.name}),e.jsxs("div",{className:A.listItemMeta,children:[p.triggers.length," wyzw · ",p.actions.length," akcji"]}),e.jsx("button",{className:`${A.enableToggle} ${p.enabled?A.enableOn:""}`,onClick:x=>{x.stopPropagation(),u({enabled:!p.enabled})},title:p.enabled?"Wyłącz":"Włącz",children:p.enabled?"●":"○"})]},p.id)),t.length===0&&e.jsx("div",{className:A.emptyHint,children:"Brak automatyzacji"})]})]}),e.jsx("div",{className:A.detailPanel,children:v?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:A.detailHeader,children:[e.jsx("input",{className:A.nameInput,value:v.name,onChange:p=>u({name:p.target.value}),readOnly:o}),!o&&e.jsx("button",{className:A.deleteBtn,onClick:()=>b(v.id),children:"Usuń"})]}),e.jsxs("section",{className:A.section,children:[e.jsxs("div",{className:A.sectionHeader,children:[e.jsx("span",{className:A.sectionTitle,children:"Wyzwalacze"}),!o&&e.jsx("button",{className:A.sectionAddBtn,onClick:()=>u({triggers:[...v.triggers,{type:"time"}]}),children:"+ Dodaj"})]}),v.triggers.map((p,x)=>e.jsx(N_,{trigger:p,devices:s,onChange:j=>u({triggers:v.triggers.map((r,L)=>L===x?j:r)}),onRemove:()=>u({triggers:v.triggers.filter((j,r)=>r!==x)})},x)),v.triggers.length===0&&e.jsx("div",{className:A.emptyHint,children:"Brak wyzwalaczy"})]}),e.jsxs("section",{className:A.section,children:[e.jsxs("div",{className:A.sectionHeader,children:[e.jsx("span",{className:A.sectionTitle,children:"Akcje"}),!o&&e.jsx("button",{className:A.sectionAddBtn,onClick:()=>u({actions:[...v.actions,{type:"device_control"}]}),children:"+ Dodaj"})]}),v.actions.map((p,x)=>e.jsx(k_,{action:p,devices:s,onChange:j=>u({actions:v.actions.map((r,L)=>L===x?j:r)}),onRemove:()=>u({actions:v.actions.filter((j,r)=>r!==x)})},x)),v.actions.length===0&&e.jsx("div",{className:A.emptyHint,children:"Brak akcji"})]})]}):e.jsx("div",{className:A.noSelection,children:"Wybierz automatyzację lub dodaj nową"})})]})},I_="_root_fbi4h_3",S_="_dark_fbi4h_27",L_="_gridPanel_fbi4h_33",z_="_gridHeader_fbi4h_55",$_="_gridTitle_fbi4h_75",B_="_addBtn_fbi4h_81",T_="_sceneGrid_fbi4h_105",P_="_sceneCard_fbi4h_123",M_="_sceneCardActive_fbi4h_147",O_="_sceneCardSelected_fbi4h_149",A_="_sceneCardIcon_fbi4h_153",E_="_sceneCardName_fbi4h_157",D_="_sceneCardDevices_fbi4h_175",R_="_activeBadge_fbi4h_193",W_="_activateBtn_fbi4h_197",G_="_emptyGrid_fbi4h_237",F_="_detailPanel_fbi4h_255",V_="_metaRow_fbi4h_273",H_="_iconPicker_fbi4h_285",U_="_currentIcon_fbi4h_289",Z_="_iconGrid_fbi4h_307",Y_="_iconOpt_fbi4h_323",K_="_iconOptActive_fbi4h_345",X_="_metaFields_fbi4h_349",J_="_nameInput_fbi4h_353",q_="_descInput_fbi4h_381",Q_="_colorPicker_fbi4h_411",ep="_colorOpt_fbi4h_421",tp="_colorOptActive_fbi4h_437",sp="_targetsSection_fbi4h_443",np="_targetsSectionHeader_fbi4h_447",op="_addTargetBtn_fbi4h_469",ap="_targetRow_fbi4h_493",cp="_targetSelect_fbi4h_517",lp="_targetState_fbi4h_541",rp="_targetField_fbi4h_555",ip="_tempInput_fbi4h_575",dp="_removeTargetBtn_fbi4h_593",up="_noTargets_fbi4h_627",hp="_detailActions_fbi4h_647",_p="_activateFullBtn_fbi4h_661",pp="_deleteBtn_fbi4h_689",K={root:I_,dark:S_,gridPanel:L_,gridHeader:z_,gridTitle:$_,addBtn:B_,sceneGrid:T_,sceneCard:P_,sceneCardActive:M_,sceneCardSelected:O_,sceneCardIcon:A_,sceneCardName:E_,sceneCardDevices:D_,activeBadge:R_,activateBtn:W_,emptyGrid:G_,detailPanel:F_,metaRow:V_,iconPicker:H_,currentIcon:U_,iconGrid:Z_,iconOpt:Y_,iconOptActive:K_,metaFields:X_,nameInput:J_,descInput:q_,colorPicker:Q_,colorOpt:ep,colorOptActive:tp,targetsSection:sp,targetsSectionHeader:np,addTargetBtn:op,targetRow:ap,targetSelect:cp,targetState:lp,targetField:rp,tempInput:ip,removeTargetBtn:dp,noTargets:up,detailActions:hp,activateFullBtn:_p,deleteBtn:pp},qe=t=>t&&typeof t=="object"?t:{},mp=(t,s,a=!1)=>{const o=qe(t)[s];return typeof o=="boolean"?o:a},Nt=(t,s,a=0)=>{const o=qe(t)[s];return typeof o=="number"?o:a},xp=["🎭","🌙","🌅","🎬","🎮","💼","🍽","☕","🏃","🛁","🎵","🌿","🔆","❄","🔒","🏠"],fp=["#e0f2fe","#fce7f3","#dcfce7","#fef9c3","#ede9fe","#fee2e2","#f0fdf4","#fff7ed"],gp=({target:t,devices:s,onChange:a,onRemove:o})=>{const n=s.find(c=>c.id===t.deviceId);return e.jsxs("div",{className:K.targetRow,children:[e.jsxs("select",{className:K.targetSelect,value:t.deviceId,onChange:c=>a({...t,deviceId:c.target.value}),children:[e.jsx("option",{value:"",children:"— urządzenie —"}),s.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))]}),n&&e.jsxs("div",{className:K.targetState,children:[e.jsxs("label",{className:K.targetField,children:[e.jsx("span",{children:"Wł/Wył"}),e.jsx("input",{type:"checkbox",checked:mp(t.state,"on",!1),onChange:c=>a({...t,state:{...qe(t.state),on:c.target.checked}})})]}),(n.type==="dimmer"||n.type==="light"||n.type==="rgb_light"||n.type==="led_strip")&&e.jsxs("label",{className:K.targetField,children:[e.jsx("span",{children:"Jasność"}),e.jsx("input",{type:"range",min:0,max:100,value:Nt(t.state,"brightness",100),onChange:c=>a({...t,state:{...qe(t.state),brightness:+c.target.value}})}),e.jsxs("span",{children:[Nt(t.state,"brightness",100),"%"]})]}),(n.type==="thermostat"||n.type==="air_conditioner")&&e.jsxs("label",{className:K.targetField,children:[e.jsx("span",{children:"Temp."}),e.jsx("input",{type:"number",className:K.tempInput,min:10,max:30,step:.5,value:Nt(t.state,"targetTemperature",20),onChange:c=>a({...t,state:{...qe(t.state),targetTemperature:+c.target.value}})}),e.jsx("span",{children:"°C"})]})]}),e.jsx("button",{className:K.removeTargetBtn,onClick:o,title:"Usuń",children:"✕"})]})},yp=({scenes:t,devices:s=[],activeSceneIds:a=[],onScenesChange:o,onActivate:n,readOnly:c=!1,className:d,style:f,theme:y="light"})=>{var j;const[v,u]=l.useState(((j=t[0])==null?void 0:j.id)??null),N=t.find(r=>r.id===v)??null,b=l.useCallback(r=>{N&&(o==null||o(t.map(L=>L.id===N.id?{...L,...r}:L)))},[N,t,o]),g=l.useCallback(()=>{const r={id:`scene-${Date.now()}`,name:"Nowa scena",deviceTargets:[],icon:"🎭",color:"#e0f2fe"};o==null||o([...t,r]),u(r.id)},[t,o]),p=l.useCallback(r=>{var L;o==null||o(t.filter(h=>h.id!==r)),v===r&&u(((L=t.find(h=>h.id!==r))==null?void 0:L.id)??null)},[t,v,o]),x=()=>{if(!N)return;const r={deviceId:"",state:{on:!0},transitionMs:1e3};b({deviceTargets:[...N.deviceTargets,r]})};return e.jsxs("div",{className:`${K.root} ${y==="dark"?K.dark:""} ${d??""}`,style:f,children:[e.jsxs("div",{className:K.gridPanel,children:[e.jsxs("div",{className:K.gridHeader,children:[e.jsx("span",{className:K.gridTitle,children:"Sceny"}),!c&&e.jsx("button",{className:K.addBtn,onClick:g,children:"+ Nowa"})]}),e.jsxs("div",{className:K.sceneGrid,children:[t.map(r=>{const L=a.includes(r.id),h=v===r.id;return e.jsxs("div",{className:`${K.sceneCard} ${L?K.sceneCardActive:""} ${h?K.sceneCardSelected:""}`,style:{background:r.color??"#f8fafc"},onClick:()=>u(r.id),children:[e.jsx("div",{className:K.sceneCardIcon,children:r.icon??"🎭"}),e.jsx("div",{className:K.sceneCardName,children:r.name}),e.jsxs("div",{className:K.sceneCardDevices,children:[r.deviceTargets.length," urządzeń",L&&e.jsx("span",{className:K.activeBadge,children:"●"})]}),e.jsx("button",{className:K.activateBtn,onClick:C=>{C.stopPropagation(),n==null||n(r.id)},children:"▶"})]},r.id)}),t.length===0&&e.jsx("div",{className:K.emptyGrid,children:"Brak scen. Dodaj pierwszą!"})]})]}),N&&e.jsxs("div",{className:K.detailPanel,children:[e.jsxs("div",{className:K.metaRow,children:[e.jsxs("div",{className:K.iconPicker,children:[e.jsx("span",{className:K.currentIcon,children:N.icon??"🎭"}),e.jsx("div",{className:K.iconGrid,children:xp.map(r=>e.jsx("button",{className:`${K.iconOpt} ${N.icon===r?K.iconOptActive:""}`,onClick:()=>b({icon:r}),children:r},r))})]}),e.jsxs("div",{className:K.metaFields,children:[e.jsx("input",{className:K.nameInput,value:N.name,readOnly:c,onChange:r=>b({name:r.target.value}),placeholder:"Nazwa sceny"}),e.jsx("textarea",{className:K.descInput,value:N.description??"",readOnly:c,onChange:r=>b({description:r.target.value}),placeholder:"Opis (opcjonalny)",rows:2})]})]}),!c&&e.jsx("div",{className:K.colorPicker,children:fp.map(r=>e.jsx("button",{className:`${K.colorOpt} ${N.color===r?K.colorOptActive:""}`,style:{background:r},onClick:()=>b({color:r})},r))}),e.jsxs("div",{className:K.targetsSection,children:[e.jsxs("div",{className:K.targetsSectionHeader,children:[e.jsx("span",{children:"Urządzenia w scenie"}),!c&&e.jsx("button",{className:K.addTargetBtn,onClick:x,children:"+ Dodaj"})]}),N.deviceTargets.map((r,L)=>e.jsx(gp,{target:r,devices:s,onChange:h=>b({deviceTargets:N.deviceTargets.map((C,w)=>w===L?h:C)}),onRemove:()=>b({deviceTargets:N.deviceTargets.filter((h,C)=>C!==L)})},L)),N.deviceTargets.length===0&&e.jsx("div",{className:K.noTargets,children:"Dodaj urządzenia, które powinna kontrolować ta scena."})]}),e.jsxs("div",{className:K.detailActions,children:[e.jsx("button",{className:K.activateFullBtn,onClick:()=>n==null?void 0:n(N.id),children:"▶ Aktywuj scenę"}),!c&&e.jsx("button",{className:K.deleteBtn,onClick:()=>p(N.id),children:"Usuń"})]})]})]})};exports.LayerPanel=Zt;exports.Minimap=Yt;exports.NiceAutomationEditor=C_;exports.NiceBuildingDashboard=wu;exports.NiceDeviceControl=Gh;exports.NiceFloorPlanEditor=qs;exports.NiceLightControl=Qt;exports.NiceSceneEditor=yp;exports.NiceSpatialEditor=Ur;exports.NiceSpatialViewer=Id;exports.NiceThermostatControl=ts;exports.NiceZoneCard=qt;exports.ObjectLibrary=Kt;exports.PropertiesPanel=Xt;exports.useMeasurement=zd;exports.useSnapToGrid=Ld;exports.useSpatialEditor=Sd;
|